From 403acb1f804d133d0ce57caf9863bcdadb4a953a Mon Sep 17 00:00:00 2001 From: Ana Cabral Date: Thu, 18 Nov 2021 16:04:42 +0100 Subject: [PATCH 001/110] release: bump version to 1.35.0 (development) --- configure.ac | 4 ++-- meson.build | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index f81a30bb27..f9baf12428 100644 --- a/configure.ac +++ b/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], [33]) -m4_define([nm_micro_version], [90]) +m4_define([nm_minor_version], [35]) +m4_define([nm_micro_version], [0]) m4_define([nm_version], [nm_major_version.nm_minor_version.nm_micro_version]) diff --git a/meson.build b/meson.build index 6c87662a19..36b6e6db4e 100644 --- a/meson.build +++ b/meson.build @@ -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.33.90', + version: '1.35.0', license: 'GPL2+', default_options: [ 'buildtype=debugoptimized', From 58287cbcc0c8a4964309e6d528aa65ea508b70d2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 6 Aug 2021 15:17:05 +0200 Subject: [PATCH 002/110] core: rework IP configuration in NetworkManager using layer 3 configuration Completely rework IP configuration in the daemon. Use NML3Cfg as layer 3 manager for the IP configuration of an interface. Use NML3ConfigData as pieces of configuration that the various components collect and configure. NMDevice is managing most of the IP configuration at a higher level, that is, it starts DHCP and other IP methods. Rework the state handling there. This is a huge rework of how NetworkManager daemon handles IP configuration. Some fallout is to be expected. It appears the patch deletes many lines of code. That is not accurate, because you also have to count the files `src/core/nm-l3*`, which were unused previously. Co-authored-by: Beniamino Galvani --- .gitignore | 4 +- Makefile.am | 75 +- contrib/fedora/rpm/NetworkManager.spec | 1 - po/POTFILES.in | 1 - src/core/NetworkManagerUtils.c | 204 +- src/core/NetworkManagerUtils.h | 14 +- src/core/README.l3cfg.md | 368 + src/core/README.next.ip-config.md | 59 + src/core/devices/adsl/nm-device-adsl.c | 351 +- src/core/devices/bluetooth/nm-device-bt.c | 103 +- src/core/devices/nm-acd-manager.c | 497 - src/core/devices/nm-acd-manager.h | 34 - src/core/devices/nm-device-bond.c | 1 - src/core/devices/nm-device-dummy.c | 1 - src/core/devices/nm-device-ethernet.c | 436 +- src/core/devices/nm-device-infiniband.c | 1 - src/core/devices/nm-device-ip-tunnel.c | 1 - src/core/devices/nm-device-macsec.c | 2 +- src/core/devices/nm-device-macvlan.c | 1 - src/core/devices/nm-device-ppp.c | 286 +- src/core/devices/nm-device-private.h | 107 +- src/core/devices/nm-device-tun.c | 1 - src/core/devices/nm-device-utils.c | 7 +- src/core/devices/nm-device-utils.h | 11 +- src/core/devices/nm-device-vlan.c | 16 +- src/core/devices/nm-device-vxlan.c | 1 - src/core/devices/nm-device-wireguard.c | 77 +- src/core/devices/nm-device-wpan.c | 1 - src/core/devices/nm-device.c | 8101 +++++++---------- src/core/devices/nm-device.h | 44 +- src/core/devices/ovs/nm-device-ovs-bridge.c | 18 +- .../devices/ovs/nm-device-ovs-interface.c | 54 +- src/core/devices/ovs/nm-device-ovs-port.c | 18 +- src/core/devices/team/nm-device-team.c | 1 - src/core/devices/tests/meson.build | 1 - src/core/devices/tests/test-acd.c | 259 - src/core/devices/wifi/nm-device-iwd.c | 6 +- src/core/devices/wifi/nm-device-wifi-p2p.c | 47 +- src/core/devices/wifi/nm-device-wifi.c | 161 +- src/core/devices/wwan/libnm-wwan.ver | 5 +- src/core/devices/wwan/nm-device-modem.c | 195 +- src/core/devices/wwan/nm-modem-broadband.c | 438 +- src/core/devices/wwan/nm-modem-ofono.c | 148 +- src/core/devices/wwan/nm-modem.c | 949 +- src/core/devices/wwan/nm-modem.h | 77 +- src/core/dhcp/README.next.md | 103 + src/core/dhcp/nm-dhcp-client.c | 1173 +-- src/core/dhcp/nm-dhcp-client.h | 256 +- src/core/dhcp/nm-dhcp-dhclient-utils.c | 1 - src/core/dhcp/nm-dhcp-dhclient.c | 141 +- src/core/dhcp/nm-dhcp-dhcpcanon.c | 2 +- src/core/dhcp/nm-dhcp-dhcpcd.c | 22 +- src/core/dhcp/nm-dhcp-manager.c | 372 +- src/core/dhcp/nm-dhcp-manager.h | 48 +- src/core/dhcp/nm-dhcp-nettools.c | 334 +- src/core/dhcp/nm-dhcp-systemd.c | 327 +- src/core/dhcp/nm-dhcp-utils.c | 299 +- src/core/dhcp/nm-dhcp-utils.h | 27 +- src/core/dhcp/tests/test-dhcp-dhclient.c | 1 - src/core/dhcp/tests/test-dhcp-utils.c | 559 +- src/core/dns/nm-dns-dnsmasq.c | 33 +- src/core/dns/nm-dns-manager.c | 592 +- src/core/dns/nm-dns-manager.h | 18 +- src/core/dns/nm-dns-systemd-resolved.c | 63 +- src/core/dnsmasq/nm-dnsmasq-manager.c | 51 +- src/core/dnsmasq/nm-dnsmasq-manager.h | 10 +- src/core/main-utils.h | 3 - src/core/main.c | 10 - src/core/meson.build | 41 +- src/core/ndisc/nm-fake-ndisc.c | 38 +- src/core/ndisc/nm-fake-ndisc.h | 2 +- src/core/ndisc/nm-lndp-ndisc.c | 92 +- src/core/ndisc/nm-lndp-ndisc.h | 13 +- src/core/ndisc/nm-ndisc.c | 490 +- src/core/ndisc/nm-ndisc.h | 39 +- src/core/ndisc/tests/test-ndisc-fake.c | 70 +- src/core/ndisc/tests/test-ndisc-linux.c | 53 +- src/core/nm-act-request.c | 38 +- src/core/nm-act-request.h | 8 - src/core/nm-active-connection.h | 3 + src/core/nm-config-data.c | 84 +- src/core/nm-config-data.h | 6 +- src/core/nm-config.c | 36 +- src/core/nm-config.h | 3 +- src/core/nm-connectivity.c | 1 + src/core/nm-dhcp-config.c | 101 +- src/core/nm-dhcp-config.h | 5 +- src/core/nm-dispatcher.c | 181 +- src/core/nm-dispatcher.h | 8 +- src/core/nm-iface-helper.c | 857 -- src/core/nm-ip-config.c | 778 +- src/core/nm-ip-config.h | 59 +- src/core/nm-ip4-config.c | 3337 ------- src/core/nm-ip4-config.h | 673 -- src/core/nm-ip6-config.c | 2675 ------ src/core/nm-ip6-config.h | 205 - src/core/nm-l3-config-data.c | 40 +- src/core/nm-l3-config-data.h | 5 + src/core/nm-l3cfg.c | 79 + src/core/nm-l3cfg.h | 6 + src/core/nm-manager.c | 12 - src/core/nm-netns.c | 4 +- src/core/nm-netns.h | 4 +- src/core/nm-pacrunner-manager.c | 101 +- src/core/nm-pacrunner-manager.h | 7 +- src/core/nm-policy.c | 329 +- src/core/nm-proxy-config.c | 172 - src/core/nm-proxy-config.h | 41 - src/core/nm-types.h | 3 - src/core/platform/nm-fake-platform.c | 2 - src/core/platform/tests/test-route.c | 104 +- src/core/ppp/nm-ppp-manager-call.c | 18 - src/core/ppp/nm-ppp-manager-call.h | 6 - src/core/ppp/nm-ppp-manager.c | 252 +- src/core/ppp/nm-ppp-manager.h | 3 +- src/core/ppp/nm-ppp-mgr.c | 620 ++ src/core/ppp/nm-ppp-mgr.h | 131 + src/core/ppp/nm-ppp-plugin-api.h | 6 - src/core/ppp/nm-ppp-status.h | 5 +- src/core/tests/meson.build | 2 - src/core/tests/test-ip4-config.c | 380 - src/core/tests/test-ip6-config.c | 538 -- src/core/tests/test-l3cfg.c | 4 +- src/core/vpn/nm-vpn-connection.c | 4045 ++++---- src/core/vpn/nm-vpn-connection.h | 7 +- src/libnm-platform/nm-linux-platform.c | 1 - src/libnm-platform/nm-platform.c | 41 +- src/libnm-platform/nm-platform.h | 12 - src/libnm-systemd-core/meson.build | 2 - src/libnm-systemd-core/nm-sd.h | 2 - .../src/libsystemd-network/sd-ipv4acd.c | 616 -- .../src/libsystemd-network/sd-ipv4ll.c | 382 - .../src/systemd/sd-ipv4acd.h | 63 - .../src/systemd/sd-ipv4ll.h | 65 - tools/test-build.sh | 1 - 135 files changed, 12299 insertions(+), 23336 deletions(-) create mode 100644 src/core/README.l3cfg.md create mode 100644 src/core/README.next.ip-config.md delete mode 100644 src/core/devices/nm-acd-manager.c delete mode 100644 src/core/devices/nm-acd-manager.h delete mode 100644 src/core/devices/tests/test-acd.c create mode 100644 src/core/dhcp/README.next.md delete mode 100644 src/core/nm-iface-helper.c delete mode 100644 src/core/nm-ip4-config.c delete mode 100644 src/core/nm-ip4-config.h delete mode 100644 src/core/nm-ip6-config.c delete mode 100644 src/core/nm-ip6-config.h delete mode 100644 src/core/nm-proxy-config.c delete mode 100644 src/core/nm-proxy-config.h create mode 100644 src/core/ppp/nm-ppp-mgr.c create mode 100644 src/core/ppp/nm-ppp-mgr.h delete mode 100644 src/core/tests/test-ip4-config.c delete mode 100644 src/core/tests/test-ip6-config.c delete mode 100644 src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c delete mode 100644 src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c delete mode 100644 src/libnm-systemd-core/src/systemd/sd-ipv4acd.h delete mode 100644 src/libnm-systemd-core/src/systemd/sd-ipv4ll.h diff --git a/.gitignore b/.gitignore index 25c60b1270..8750c30c43 100644 --- a/.gitignore +++ b/.gitignore @@ -240,7 +240,6 @@ test-*.trs /src/core/NetworkManager-all-sym /src/core/NetworkManager.ver /src/core/devices/bluetooth/tests/nm-bt-test -/src/core/devices/tests/test-acd /src/core/devices/tests/test-lldp /src/core/devices/wifi/tests/test-devices-wifi /src/core/devices/wwan/tests/test-service-providers @@ -249,7 +248,6 @@ test-*.trs /src/core/dhcp/tests/test-dhcp-options /src/core/dhcp/tests/test-dhcp-utils /src/core/dnsmasq/tests/test-dnsmasq-utils -/src/core/nm-iface-helper /src/core/ndisc/tests/test-ndisc-fake /src/core/ndisc/tests/test-ndisc-linux /src/core/platform/tests/monitor @@ -406,10 +404,12 @@ test-*.trs /src/NetworkManager /src/NetworkManager-all-sym /src/NetworkManager.ver +/src/core/devices/tests/test-acd /src/core/initrd/nm-initrd-generator /src/core/initrd/tests/test-cmdline-reader /src/core/initrd/tests/test-dt-reader /src/core/initrd/tests/test-ibft-reader +/src/core/nm-iface-helper /src/devices/bluetooth/tests/nm-bt-test /src/devices/tests/test-acd /src/devices/tests/test-arping diff --git a/Makefile.am b/Makefile.am index 23bee4f89c..98b1507c7c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2074,9 +2074,6 @@ src_core_ldflags = $(CODE_COVERAGE_LDFLAGS) sbin_PROGRAMS += \ src/core/NetworkManager -libexec_PROGRAMS += \ - src/core/nm-iface-helper - noinst_LTLIBRARIES += \ src/core/libNetworkManagerBase.la \ src/core/libNetworkManager.la \ @@ -2323,8 +2320,6 @@ src_libnm_systemd_core_libnm_systemd_core_la_SOURCES = \ src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-lease.c \ src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c \ src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-lease.c \ - src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c \ - src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c \ src/libnm-systemd-core/src/libsystemd-network/sd-lldp-rx.c \ src/libnm-systemd-core/src/libsystemd/sd-event/event-source.h \ src/libnm-systemd-core/src/libsystemd/sd-event/event-util.c \ @@ -2342,8 +2337,6 @@ src_libnm_systemd_core_libnm_systemd_core_la_SOURCES = \ src/libnm-systemd-core/src/systemd/sd-dhcp6-option.h \ src/libnm-systemd-core/src/systemd/sd-event.h \ src/libnm-systemd-core/src/systemd/sd-id128.h \ - src/libnm-systemd-core/src/systemd/sd-ipv4acd.h \ - src/libnm-systemd-core/src/systemd/sd-ipv4ll.h \ src/libnm-systemd-core/src/systemd/sd-lldp-rx.h \ src/libnm-systemd-core/src/systemd/sd-lldp.h \ src/libnm-systemd-core/src/systemd/sd-ndisc.h \ @@ -2394,10 +2387,6 @@ src_core_libNetworkManagerBase_la_SOURCES = \ src/core/nm-l3cfg.h \ src/core/nm-ip-config.c \ src/core/nm-ip-config.h \ - src/core/nm-ip4-config.c \ - src/core/nm-ip4-config.h \ - src/core/nm-ip6-config.c \ - src/core/nm-ip6-config.h \ \ src/core/dhcp/nm-dhcp-client.c \ src/core/dhcp/nm-dhcp-client.h \ @@ -2436,8 +2425,6 @@ src_core_libNetworkManager_la_SOURCES = \ src/core/nm-checkpoint-manager.c \ src/core/nm-checkpoint-manager.h \ \ - src/core/devices/nm-acd-manager.c \ - src/core/devices/nm-acd-manager.h \ src/core/devices/nm-lldp-listener.c \ src/core/devices/nm-lldp-listener.h \ src/core/devices/nm-device-utils.c \ @@ -2513,6 +2500,8 @@ src_core_libNetworkManager_la_SOURCES = \ src/core/dnsmasq/nm-dnsmasq-utils.c \ src/core/dnsmasq/nm-dnsmasq-utils.h \ \ + src/core/ppp/nm-ppp-mgr.c \ + src/core/ppp/nm-ppp-mgr.h \ src/core/ppp/nm-ppp-manager-call.c \ src/core/ppp/nm-ppp-manager-call.h \ src/core/ppp/nm-ppp-manager.h \ @@ -2586,8 +2575,6 @@ src_core_libNetworkManager_la_SOURCES = \ src/core/nm-firewall-utils.h \ src/core/nm-firewalld-manager.c \ src/core/nm-firewalld-manager.h \ - src/core/nm-proxy-config.c \ - src/core/nm-proxy-config.h \ src/core/nm-auth-manager.c \ src/core/nm-auth-manager.h \ src/core/nm-auth-utils.c \ @@ -2721,44 +2708,6 @@ $(src_core_NetworkManager_OBJECTS): $(src_libnm_core_public_mkenums_h) ############################################################################### -src_core_nm_iface_helper_CPPFLAGS = $(src_core_cppflags) - -src_core_nm_iface_helper_SOURCES = \ - src/core/nm-iface-helper.c - -src_core_nm_iface_helper_LDADD = \ - src/core/libNetworkManagerBase.la \ - src/libnm-core-aux-extern/libnm-core-aux-extern.la \ - src/libnm-core-impl/libnm-core-impl.la \ - $(libnm_crypto_lib) \ - src/libnm-core-aux-intern/libnm-core-aux-intern.la \ - src/libnm-platform/libnm-platform.la \ - src/libnm-base/libnm-base.la \ - src/libnm-log-core/libnm-log-core.la \ - src/libnm-udev-aux/libnm-udev-aux.la \ - src/libnm-glib-aux/libnm-glib-aux.la \ - src/libnm-std-aux/libnm-std-aux.la \ - src/libnm-systemd-core/libnm-systemd-core.la \ - src/libnm-systemd-shared/libnm-systemd-shared.la \ - src/n-acd/libn-acd.la \ - src/n-dhcp4/libn-dhcp4.la \ - src/c-rbtree/libc-rbtree.la \ - src/c-siphash/libc-siphash.la \ - $(SYSTEMD_JOURNAL_LIBS) \ - $(GLIB_LIBS) \ - $(LIBUDEV_LIBS) \ - $(LIBNDP_LIBS) \ - $(DL_LIBS) \ - $(NULL) - -src_core_nm_iface_helper_LDFLAGS = \ - -Wl,--version-script="$(srcdir)/linker-script-binary.ver" \ - $(SANITIZER_EXEC_LDFLAGS) - -$(src_core_nm_iface_helper_OBJECTS): $(src_libnm_core_public_mkenums_h) - -############################################################################### - noinst_LTLIBRARIES += src/nm-initrd-generator/libnmi-core.la src_nm_initrd_generator_libnmi_core_la_CPPFLAGS = \ @@ -4275,20 +4224,14 @@ src_core_devices_tests_ldflags = \ check_programs += \ src/core/devices/tests/test-lldp \ - src/core/devices/tests/test-acd + $(NULL) src_core_devices_tests_test_lldp_CPPFLAGS = $(src_core_cppflags_test) src_core_devices_tests_test_lldp_LDFLAGS = $(src_core_devices_tests_ldflags) src_core_devices_tests_test_lldp_LDADD = \ src/core/libNetworkManagerTest.la -src_core_devices_tests_test_acd_CPPFLAGS = $(src_core_cppflags_test) -src_core_devices_tests_test_acd_LDFLAGS = $(src_core_devices_tests_ldflags) -src_core_devices_tests_test_acd_LDADD = \ - src/core/libNetworkManagerTest.la - $(src_core_devices_tests_test_lldp_OBJECTS): $(src_libnm_core_public_mkenums_h) -$(src_core_devices_tests_test_acd_OBJECTS): $(src_libnm_core_public_mkenums_h) EXTRA_DIST += \ src/core/devices/tests/meson.build @@ -4391,22 +4334,12 @@ check_programs += \ src/core/tests/test-core \ src/core/tests/test-core-with-expect \ src/core/tests/test-dcb \ - src/core/tests/test-ip4-config \ - src/core/tests/test-ip6-config \ src/core/tests/test-l3cfg \ src/core/tests/test-systemd \ src/core/tests/test-utils \ src/core/tests/test-wired-defname \ $(NULL) -src_core_tests_test_ip4_config_CPPFLAGS = $(src_core_cppflags_test) -src_core_tests_test_ip4_config_LDFLAGS = $(src_core_tests_ldflags) -src_core_tests_test_ip4_config_LDADD = $(src_core_tests_ldadd) - -src_core_tests_test_ip6_config_CPPFLAGS = $(src_core_cppflags_test) -src_core_tests_test_ip6_config_LDFLAGS = $(src_core_tests_ldflags) -src_core_tests_test_ip6_config_LDADD = $(src_core_tests_ldadd) - src_core_tests_test_dcb_CPPFLAGS = $(src_core_cppflags_test) src_core_tests_test_dcb_LDFLAGS = $(src_core_tests_ldflags) src_core_tests_test_dcb_LDADD = $(src_core_tests_ldadd) @@ -4434,8 +4367,6 @@ src_core_tests_test_l3cfg_LDADD = $(src_core_tests_ldadd) $(src_core_tests_test_core_OBJECTS): $(src_libnm_core_public_mkenums_h) $(src_core_tests_test_core_with_expect_OBJECTS): $(src_libnm_core_public_mkenums_h) $(src_core_tests_test_dcb_OBJECTS): $(src_libnm_core_public_mkenums_h) -$(src_core_tests_test_ip4_config_OBJECTS): $(src_libnm_core_public_mkenums_h) -$(src_core_tests_test_ip6_config_OBJECTS): $(src_libnm_core_public_mkenums_h) $(src_core_tests_test_l3cfg_OBJECTS): $(src_libnm_core_public_mkenums_h) $(src_core_tests_test_utils_OBJECTS): $(src_libnm_core_public_mkenums_h) $(src_core_tests_test_wired_defname_OBJECTS): $(src_libnm_core_public_mkenums_h) diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index 0d8e392316..f1b814cbd0 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -1000,7 +1000,6 @@ fi %ghost %attr(755, root, root) %{_sbindir}/ifdown %{_libexecdir}/nm-dhcp-helper %{_libexecdir}/nm-dispatcher -%{_libexecdir}/nm-iface-helper %{_libexecdir}/nm-initrd-generator %{_libexecdir}/nm-daemon-helper %{_libexecdir}/nm-sudo diff --git a/po/POTFILES.in b/po/POTFILES.in index 0cd24d9940..76d20094d0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -33,7 +33,6 @@ src/core/dns/nm-dns-manager.c src/core/main-utils.c src/core/main.c src/core/nm-config.c -src/core/nm-iface-helper.c src/core/nm-manager.c src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c diff --git a/src/core/NetworkManagerUtils.c b/src/core/NetworkManagerUtils.c index 0da8e0a949..fdb2b40443 100644 --- a/src/core/NetworkManagerUtils.c +++ b/src/core/NetworkManagerUtils.c @@ -227,6 +227,21 @@ out: /*****************************************************************************/ +void +nm_utils_ppp_ip_methods_enabled(NMConnection *connection, + gboolean * out_ip4_enabled, + gboolean * out_ip6_enabled) +{ + NM_SET_OUT(out_ip4_enabled, + nm_streq0(nm_utils_get_ip_config_method(connection, AF_INET), + NM_SETTING_IP4_CONFIG_METHOD_AUTO)); + NM_SET_OUT(out_ip6_enabled, + nm_streq0(nm_utils_get_ip_config_method(connection, AF_INET6), + NM_SETTING_IP6_CONFIG_METHOD_AUTO)); +} + +/*****************************************************************************/ + void _nm_utils_complete_generic_with_params(NMPlatform * platform, NMConnection * connection, @@ -1298,7 +1313,7 @@ void nm_utils_ip_route_attribute_to_platform(int addr_family, NMIPRoute * s_route, NMPlatformIPRoute *r, - guint32 route_table) + gint64 route_table) { GVariant * variant; guint32 table; @@ -1310,6 +1325,8 @@ nm_utils_ip_route_attribute_to_platform(int addr_family, nm_assert(s_route); nm_assert_addr_family(addr_family); nm_assert(r); + nm_assert(route_table >= -1); + nm_assert(route_table <= (gint64) G_MAXUINT32); #define GET_ATTR(name, dst, variant_type, type, dflt) \ G_STMT_START \ @@ -1336,10 +1353,16 @@ nm_utils_ip_route_attribute_to_platform(int addr_family, GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_TABLE, table, UINT32, uint32, 0); - if (!table && r->type_coerced == nm_platform_route_type_coerce(RTN_LOCAL)) + if (table != 0) + r->table_coerced = nm_platform_route_table_coerce(table); + else if (r->type_coerced == nm_platform_route_type_coerce(RTN_LOCAL)) r->table_coerced = nm_platform_route_table_coerce(RT_TABLE_LOCAL); + else if (route_table == 0) + r->table_coerced = nm_platform_route_table_coerce(RT_TABLE_MAIN); + else if (route_table > 0) + r->table_coerced = nm_platform_route_table_coerce(route_table); else - r->table_coerced = nm_platform_route_table_coerce(table ?: (route_table ?: RT_TABLE_MAIN)); + r->table_any = TRUE; if (NM_IS_IPv4(addr_family)) { guint8 scope; @@ -1395,39 +1418,20 @@ nm_utils_ip_route_attribute_to_platform(int addr_family, /*****************************************************************************/ -static int -_addresses_sort_cmp_4(gconstpointer a, gconstpointer b, gpointer user_data) -{ - return nm_platform_ip4_address_pretty_sort_cmp( - NMP_OBJECT_CAST_IP4_ADDRESS(*((const NMPObject **) a)), - NMP_OBJECT_CAST_IP4_ADDRESS(*((const NMPObject **) b))); -} - -static int -_addresses_sort_cmp_6(gconstpointer a, gconstpointer b, gpointer user_data) -{ - return nm_platform_ip6_address_pretty_sort_cmp( - NMP_OBJECT_CAST_IP6_ADDRESS(*((const NMPObject **) a)), - NMP_OBJECT_CAST_IP6_ADDRESS(*((const NMPObject **) b)), - (((NMSettingIP6ConfigPrivacy) GPOINTER_TO_INT(user_data)) - == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR)); -} - void nm_utils_ip_addresses_to_dbus(int addr_family, const NMDedupMultiHeadEntry *head_entry, const NMPObject * best_default_route, - NMSettingIP6ConfigPrivacy ipv6_privacy, GVariant ** out_address_data, GVariant ** out_addresses) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - GVariantBuilder builder_data; - GVariantBuilder builder_legacy; - char addr_str[NM_UTILS_INET_ADDRSTRLEN]; - gs_free const NMPObject **addresses = NULL; - guint naddr; - guint i; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + GVariantBuilder builder_data; + GVariantBuilder builder_legacy; + char addr_str[NM_UTILS_INET_ADDRSTRLEN]; + NMDedupMultiIter iter; + const NMPObject *obj; + guint i; nm_assert_addr_family(addr_family); @@ -1443,19 +1447,11 @@ nm_utils_ip_addresses_to_dbus(int addr_family, if (!head_entry) goto out; - addresses = - (const NMPObject **) nm_dedup_multi_objs_to_array_head(head_entry, NULL, NULL, &naddr); - - nm_assert(addresses && naddr); - - g_qsort_with_data(addresses, - naddr, - sizeof(addresses[0]), - IS_IPv4 ? _addresses_sort_cmp_4 : _addresses_sort_cmp_6, - GINT_TO_POINTER(ipv6_privacy)); - - for (i = 0; i < naddr; i++) { - const NMPlatformIPXAddress *address = NMP_OBJECT_CAST_IPX_ADDRESS(addresses[i]); + i = 0; + nm_dedup_multi_iter_init(&iter, head_entry); + while ( + nm_platform_dedup_multi_iter_next_obj(&iter, &obj, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4))) { + const NMPlatformIPXAddress *address = NMP_OBJECT_CAST_IPX_ADDRESS(obj); if (out_address_data) { GVariantBuilder addr_builder; @@ -1527,6 +1523,8 @@ nm_utils_ip_addresses_to_dbus(int addr_family, : &in6addr_any)); } } + + i++; } out: @@ -1654,6 +1652,128 @@ nm_utils_ip_routes_to_dbus(int addr_family, /*****************************************************************************/ +NMSetting * +nm_utils_platform_capture_ip_setting(NMPlatform *platform, + int addr_family, + int ifindex, + gboolean maybe_ipv6_disabled) +{ + const int IS_IPv4 = NM_IS_IPv4(addr_family); + gs_unref_object NMSettingIPConfig *s_ip = NULL; + NMPLookup lookup; + NMDedupMultiIter iter; + const NMPObject * obj; + const char * method = NULL; + char sbuf[NM_UTILS_INET_ADDRSTRLEN]; + const NMPlatformIPXRoute * best_default_route = NULL; + + s_ip = + NM_SETTING_IP_CONFIG(IS_IPv4 ? nm_setting_ip4_config_new() : nm_setting_ip6_config_new()); + + if (ifindex <= 0 || !nm_platform_link_get(platform, ifindex)) { + g_object_set(s_ip, + NM_SETTING_IP_CONFIG_METHOD, + IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_DISABLED + : NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NULL); + return NM_SETTING(g_steal_pointer(&s_ip)); + } + + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex); + nm_platform_iter_obj_for_each (&iter, platform, &lookup, &obj) { + const NMPlatformIPXAddress *address = NMP_OBJECT_CAST_IPX_ADDRESS(obj); + nm_auto_unref_ip_address NMIPAddress *s_addr = NULL; + + if (!IS_IPv4) { + /* Ignore link-local address. */ + if (IN6_IS_ADDR_LINKLOCAL(address->ax.address_ptr)) { + if (!method) + method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL; + continue; + } + } + + /* Detect dynamic address */ + if (address->ax.lifetime != NM_PLATFORM_LIFETIME_PERMANENT) { + method = + IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_AUTO : NM_SETTING_IP6_CONFIG_METHOD_AUTO; + continue; + } + + /* Static address found. */ + if (IS_IPv4) { + if (!method) + method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; + } else { + if (NM_IN_STRSET(method, NULL, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) + method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; + } + + s_addr = + nm_ip_address_new_binary(addr_family, address->ax.address_ptr, address->ax.plen, NULL); + + if (IS_IPv4) { + if (address->a4.label[0]) { + nm_ip_address_set_attribute(s_addr, + NM_IP_ADDRESS_ATTRIBUTE_LABEL, + g_variant_new_string(address->a4.label)); + } + } + + nm_setting_ip_config_add_address(s_ip, s_addr); + } + + if (!method) { + /* Use 'disabled/ignore' if the method wasn't previously set */ + if (IS_IPv4) + method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; + else + method = maybe_ipv6_disabled ? NM_SETTING_IP6_CONFIG_METHOD_DISABLED + : NM_SETTING_IP6_CONFIG_METHOD_IGNORE; + } + g_object_set(s_ip, NM_SETTING_IP_CONFIG_METHOD, method, NULL); + + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4), ifindex); + nm_platform_iter_obj_for_each (&iter, platform, &lookup, &obj) { + const NMPlatformIPXRoute *route = NMP_OBJECT_CAST_IPX_ROUTE(obj); + nm_auto_unref_ip_route NMIPRoute *s_route = NULL; + + if (!IS_IPv4) { + /* Ignore link-local route. */ + if (IN6_IS_ADDR_LINKLOCAL(route->rx.network_ptr)) + continue; + } + + if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route)) { + if (!best_default_route) + best_default_route = route; + continue; + } + + s_route = nm_ip_route_new_binary(addr_family, + route->rx.network_ptr, + route->rx.plen, + nm_platform_ip_route_get_gateway(addr_family, &route->rx), + route->rx.metric, + NULL); + nm_setting_ip_config_add_route(s_ip, s_route); + } + + if (best_default_route && nm_setting_ip_config_get_num_addresses(s_ip) > 0) { + g_object_set(s_ip, + NM_SETTING_IP_CONFIG_GATEWAY, + nm_utils_inet_ntop( + addr_family, + nm_platform_ip_route_get_gateway(addr_family, &best_default_route->rx), + sbuf), + NULL); + } + + return NM_SETTING(g_steal_pointer(&s_ip)); +} + +/*****************************************************************************/ + /* Singleton NMPlatform subclass instance and cached class object */ NM_DEFINE_SINGLETON_INSTANCE(NMPlatform); diff --git a/src/core/NetworkManagerUtils.h b/src/core/NetworkManagerUtils.h index a2ac732e83..0f68a3f6ef 100644 --- a/src/core/NetworkManagerUtils.h +++ b/src/core/NetworkManagerUtils.h @@ -19,6 +19,10 @@ const char *nm_utils_get_ip_config_method(NMConnection *connection, int addr_fam const char *nm_utils_get_shared_wifi_permission(NMConnection *connection); +void nm_utils_ppp_ip_methods_enabled(NMConnection *connection, + gboolean * out_ip4_enabled, + gboolean * out_ip6_enabled); + void _nm_utils_complete_generic_with_params(NMPlatform * platform, NMConnection * connection, const char * ctype, @@ -195,12 +199,11 @@ nm_utils_tfilters_from_tc_setting(NMPlatform *platform, NMSettingTCConfig *s_tc, void nm_utils_ip_route_attribute_to_platform(int addr_family, NMIPRoute * s_route, NMPlatformIPRoute *r, - guint32 route_table); + gint64 route_table); void nm_utils_ip_addresses_to_dbus(int addr_family, const NMDedupMultiHeadEntry *head_entry, const NMPObject * best_default_route, - NMSettingIP6ConfigPrivacy ipv6_privacy, GVariant ** out_address_data, GVariant ** out_addresses); @@ -271,6 +274,13 @@ NM_AUTO_DEFINE_FCN(NMDhcpLease *, _nm_auto_unref_dhcplease, nm_dhcp_lease_unref) /*****************************************************************************/ +NMSetting *nm_utils_platform_capture_ip_setting(NMPlatform *platform, + int addr_family, + int ifindex, + gboolean maybe_ipv6_disabled); + +/*****************************************************************************/ + void nm_platform_setup(NMPlatform *instance); NMPlatform *nm_platform_get(void); diff --git a/src/core/README.l3cfg.md b/src/core/README.l3cfg.md new file mode 100644 index 0000000000..901d40b4a9 --- /dev/null +++ b/src/core/README.l3cfg.md @@ -0,0 +1,368 @@ +L3Cfg Rework +============ + +NMDevice is complex. Together with NMManager, NMDevice does too much. + +The goal is to rework the IP configuration (Layer 3) to be a more separate +part of the code that is better maintainable, easier to understand and +extend and more correct. + +Current Situation +----------------- + +- [NMManager](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-manager.c): + this is the main object (a singleton) that drives most things. + Among many other things, it creates NMDevice instances and coordinates. + +- [NMDevice](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c): + this represents a device. This is a subclass of NMDBusObject, + it is thus directly exported on D-Bus (as D-Bus objects like + `/org/freedesktop/NetworkManager/Devices/1`). + It also manages all aspects of the device. It has an overall state + (`NM_DEVICE_STATE`) but lots of more specific states (e.g. current state + of DHCP configuration). As always, the hardest part in programming are + stateful objects, and NMDevice has *a lot* of state. The code is huge and + hard to understand and the class has (too) many responsibilities. \ + \ + NMDevice also has subclasses, which are determined based on the "device type". That + means, there are subclasses like NMDeviceEthernet and NMDeviceBridge. As such, the + subclasses also export additional D-Bus interfaces. These subclasses also handle + the Layer 2 specific aspects of the device. For this aspect, delegation probably + would have been a better choice. On the other hand, IP configuration is almost entirely + managed by the parent class. Which is good, because the IP configuration is common to all + device types, but is bad because NMDevice already does so many things. + +- [NMIP4Config](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-ip4-config.c) (and NMIP6Config): + these are also subclasses of NMDBusObject + and exported on D-Bus on paths like `/org/freedesktop/NetworkManager/IP4Config/1`. + The device's `IP4Config` property refers to these objects. They contain + the runtime IP information of that device. I don't think these objects + should exist on the D-Bus API, as NMDevice could directly expose these properties. + But for historic reasons, such is our D-Bus API. + Other than that, NMIP4Config objects are also used internally for tracking + IP configuration. For example, [when](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/dhcp/nm-dhcp-nettools.c#L563) + we receive a DHCP lease, we construct a NMIP4Config object with the addresses, DNS settings, + and so on. These + instances are then [tracked by](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c#L519) + NMDevice, and [merged](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c#L8928) + into an instance that is then exposed on D-Bus. As such, this class has two + mostly independent purposes. + +- [NMDhcpClient](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/dhcp/nm-dhcp-client.c): + our DHCP "library". It's a simple object with a clear API that + abstracts most of the complexity of handling DHCP. But still, NMDevice + needs to drive the DHCP client instance. Meaning, it needs to create (start) and stop + them and hook up signals for changes (new lease) and timeout. This is mostly + fine and unavoidable. The point is that while specific tasks are well abstracted + (like the details of DHCP), there is still some state in NMDevice that is related + to manage these tasks. DHCP is one of many such tasks, like also + link local addresses, SLAAC or LLDP. + This leads to the increased complexity of NMDevice, which manages a large variety + of such tasks. + +### Problems: + +1. first the sheer code size of [nm-device.c](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c#L19030). + It's hard to understand and maintain, and this results in misbehaviours. Also, features that should be easy to implement + are not. Also, there are inefficiencies that are hard to fix. + +2. NMDevice and NMIP4Config are both exported on D-Bus while having other responsibilities. + Being subclasses of NMDBusObject, they are glued to the D-Bus API. For example, NMIP4Config is + also used for other purposes (for tracking IP configuration internally). + +3. NMDevice simply does too much. IP configuration should be a separate, encapsulated + API to make allow NMDevice to be smaller and the IP configuration part better + testable, understandable and smaller too. + +4. in the current model, NMDevice can be related to zero, one or two ifindexes. For example, + for ethernet devices, there is commonly only one actual netdev device (and one ifindex). + For OVS devices, there is no ifindex. For NMDeviceModem or NMDeviceBluetooth there is + a NMDevice instance that has initially no ifindex (it represents the tty serial port + or the bluetooth device) but during activation it gets and ip ifindex. With PPPoE, + the ethernet device can even have two ifindexes (one for the underlying ethernet and + one for the PPP device). That is all utterly confusing, inconsistent and limited. + For example, not all interfaces you see in `ip link` can be found in the D-Bus API. + The D-Bus API also does not give access to the ifindex (which is the real identifier + for a netdev devices). It only exposes the IpInterface name. That should be improved too, + but even such seemingly simple things are not done for years, because it's not trivially + clear what the right ifindex is. + Also a device instance on D-Bus significantly changes its meaning when it activates/deactivates + and it starts/stops being responsible for an ifindex. + In the future there should be devices that represent exactly one netdev device (an ifindex) + and devices that don't have an ifindex. That is follow up work and hinted by + [rhbz#1066703](https://bugzilla.redhat.com/show_bug.cgi?id=1066703). But simplifying + the IP configuration is a requisite before addressing that rework. + With this we will have controller and controlled devices. That means, a controller devices + (that for example represents a bluetooth device) will need to configure IP address on the + controlled IP device. That would be doable by injecting the IP config on that device, + but as the device already does so much, it would be better if this would be a separate + IP configuration manager for that ifindex. + +5. NMIP4Config exports properties on D-Bus like [AddressData](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/introspection/org.freedesktop.NetworkManager.IP4Config.xml#L26). + which are the currently configured IP addresses. These should be directly obtained + from the NMPlatform cache, which contains the correct list of addresses as kernel + exposes them via rtnetlink. Instead, whenever there are changes in platform we + [generate](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c#L14223) + an NMIP4Config instance, then we merge, intersect and subtract this captured information + with the IP configs we want to configure. Finally we merge them together again + and sync the result to platform. This is bad, wrong and inefficient. + We must not mix "what is configured" with "what we want to configure". The current + approach also re-generates these IP config instance whenever something in platform changes. + That does not scale. If we have any hope to handle thousands of routes, this needs to change. + +6. The NMIP4Config objects are mutable, and they are heavily mutated. When we create an NMIP4Config + instance that represent a DHCP lease, we will [subtract](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c#L14236) + addresses that were externally removed. That is wrong, because during a reapply we + will need to know these addresses again. The solution for that is not to mutate this + data, but track whether IP addresses are removed separately. + +7. NMDevice also does ACD, but it can only do it for addresses received via DHCP. + It implicitly also does ACD for IPv4LL, but that is via using the n_ipv4ll library. + It would be good to have an option that we can configure IPv4LL for any address. + Also, if you manually configure an address like 192.168.2.5 (for which we don't do + ACD) and the same address is obtained via DHCP, then doing ACD for the address is wrong. + There needs to be link-wide view of the addresses, and not only looking at individual + addresses when deciding to do ACD. + +8. As IP configuration is done by NMDevice, VPN connections have limited capabilities + in this regard. + When a VPN has IP addresses, then it injects them into NMDevice by + [providing](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c#L13696) + an NMIP4Config. However, that means VPNs cannot do DHCP or IPv4LL, because it can + only inject known configuration. That would be very useful for example with a tap + device with openvpn. The real problem here is that NMVpnConnection are + treated special, when they should be more like devices. That should be reworked in the future, + by reworking VPN plugins. Regardless, having IP configuration handled by NMDevice is limiting. + +9. NetworkManager currently supports `ipv4.method` which can be "manual", "disabled" or + "auto". This scheme does not allow for example to enable IPv4LL together with DHCPv4. + As a special case, you can configure `ipv4.method=auto` together with static + addresses in `ipv4.addresses`, so combining DHCP and static addressing works. But in general, + this scheme is limited. In the future we should have more flexible schemes, where + addressing methods can be independently enabled or disabled. Also, we currently + have `ipv4.may-fail`, but that is limited as well. For example, + `ipv4.may-fail=yes` and `ipv6.may-fail=yes` still means that at least one of the + address families must succeed. That makes sense for certain use cases, but it + means, you cannot have truly best-effort, opportunistic DHCP with this way. + As workaround for that there is `ipv4.dhcp-timeout=infinity`. In + general it is not only useful to enable methods independently, we also configure + independently whether they are required or optional (and possibly, that they are optional + but at least one of several optional methods must succeed). Anyway. The point + is there is a need to make IP configuration more flexible. Currently it is not. + Such a seemingly simple extension would be surprisingly difficult to implement + because [the code](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c#L6616) is + all over the place. The way how NMDevice tracks the overall activation state is + hard to understand. This should be improved and possibly could be improved in a + smaller refactoring effort. But instead of a smaller effort, we will use the big hammer + with L3Cfg rework. + +10. There are two classes NMIP4Config and NMIP6Config. Handling both address families is + commonly similar, so there is lot of similar code in both. They should be unified + so that similar code can handle both address families. + + +Solution and Future +------------------- + +NML3Cfg work is supposed to simplify some part of NMDevice: the part related to +IP configuration. This is a huge rework of a core part of NetworkManager. Arguably, +some parts maybe could be done more evolutionary, but the fundamental problems require +to rip out NMIP4Config and replace it by something better. Doing that is a large rework +that changes NMDevice heavily. That is also the opportunity to get the smaller issues +right. + +There is already a new class [NML3Cfg](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3cfg.h#L141) +(currently unused). An NML3Cfg instance is responsible for handling IP configuration +of an ifindex. Consequently, we can ask NMNetns to [get](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-netns.c#L142) +(or create) a NML3Cfg instance for an ifindex. +The idea is that there can be multiple users (NMDevice and NMVpnConnection and future controller devices) +that use the same NML3Cfg instance. Especially with a future rework of NMDevice where +a NMDevice only manages one ifindex (or none), there is a need that multiple +devices manage the IP configuration on the same device. Independent users can cooperate +to configure IP configuration on the same device. Already now with Libreswan VPN, where the VPN "injects" +its NMIP4Config in NMDevice. Or with PPPoE, where the NMDeviceEthernet is both about IP configuration +for the PPPoE device. + +There is also a new class [NML3ConfigData](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3-config-data.h). +This replaces some aspect of NMIP4Config/NMIP6Config. A NML3ConfigData object is immutable and has no real logic +(or state). It has some "logic", like comparing two NML3ConfigData instances, logging it, or merging two (immutable) +instances into a new instance. But as the class is immutable, that logic is rather simple. This class is +used to track information. As it's immutable, anybody who is interested can keep a reference +for it's own purpose. For example, NMDhcpClient will generate a NML3ConfigData with the information +of the lease. It may keep the reference, but it will also tell NMDevice about it. The NMDevice +will then itself tell NML3Cfg to accept this configuration. This works by calling +[add()/remove()](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3cfg.c#L2654). +One NML3ConfigData can also track both IPv4 and IPv6 information. It's a general set of IP related +configuration, that has some address specific properties. Those are then duplicated for both address +families and implemented in a way to minimize code duplication and encourage to treat them the same. +As this replaces an aspect of NMIP4Config, NMIP4Config can focus on it's other purpose: to expose data on D-Bus. + +What NML3Cfg then does, is to merge all NML3ConfigData, and "commit" it to platform. Thereby it knows +which addresses it configured the last time (if they no longer are to be configured, they must be removed). +This is done [here](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3cfg.c#L3442). + +As independent users should be able to cooperate, it is not appropriate that they call "commit". +Instead, they set a commit type ([here](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3cfg.c#L3476), +and whenever something changes, NML3Cfg knows the aggregated commit type. That is necessary +because when we activate a device, we may want to preserve the existing IP configuration (e.g. after +a restart of NetworkManager). During that time is the NML3Cfg instance set to a reduced commit +mode (ASSUME). + +NML3Cfg will also handle IPv4 ACD. Any user of NML3Cfg registers/unregisters NML3ConfigData instances +that should be configured. Thereby they also say whether ACD should be done for the IPv4 addresses. +NML3Cfg then keeps state for each IPv4 address, whether ACD should be performed, and whether the +address is ready to be configured. NML3Cfg does not do DHCP or similar. That is still the responsibility +of NMDevice to run a NMDhcpClient. But it does run ACD, because whether to perform ACD on an address +requires a holistic view of all addresses of that interface. For example, if you configure a static +IP address 192.168.2.5 (with ACD disabled) and you also get the same address via DHCP, then ACD should +not performed for that address (even if the user configured ACD with DHCP). Of course, that is a very +unlikely example. More likely is that NetworkManager is restarted and it leaves the addresses (that passed +ACD) configured. After restart, DHCP finds the same addresses and no new ACD should be performed. This shows +that the ACD state depends all the IP addresses on an interface, +and thus it's done by NML3Cfg. The API for this is very simple. Users enable/disable ACD during nm_l3cfg_add_config() +and receive events like [NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3cfg.c#L303). +Another advantage is that ACD now works for any kinds of addresses. Currently it only works for addresses +from DHCP and link local addresses. + +NML3Cfg does not implement or drive DHCP. However, as it already does ACD it gained it's own IPv4LL +"library": [NML3IPv4LL](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3cfg.c#L3624). +This will replace nettools' n-ipv4ll library, because that library also does ACD internally, while we want +to use the holistic view that NML3Cfg has. What this means, is that the user (NMDevice) +can request a NML3IPv4LL handle from the NML3Cfg instance, and it just does it with a simple API. +All the user might do is to enable/disable the handle and to react to signals (if it cares to find +out whether IPv4LL fails). + +The general parts of NML3Cfg are already implemented. It has unit tests and can be tested independently. +You might note that NML3Cfg is not trivial already, but the API that it provides is as simple as possible: +create immutable NML3ConfigData instance, and add/remove them. Optionally, handle the ACD events and +listen to some events. The complexity that NML3Cfg has, will lead in the same amount simplify NMDevice. + +What is missing is NMDevice using this new API. Instead of creating and tracking NMIP4Config instances, +it needs to track NML3ConfigData instances. In principle that sounds simple, in practice that changes +large part of "nm-device.c". + +Thereby also the state machine for NM_DEVICE_STATE will be improved. It's anyway a rewrite. This will lay the +groundwork for more flexible configuration of IP methods, with different failure modes (opportunistic or +mandatory). + +What then also should be easier, to combine IPv4LL with other addressing methods. In Windows AFAIK, if you +don't get a DHCP address it will configure a IPv4LL address. That is also what RFC suggests, but which we +currently don't support. + +In general, change the way how external IP addresses/routes are tracked. This merge, intersect, subtract +approach does not perform well. Currently we react on signals and it's hard to understand what happens +in response to that, or whether it's really the correct thing to do. See yourself starting from +[here](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/devices/nm-device.c#L14214). + +### DHCP + +Currently, when NMDhcpClient receives a lease, it emits a signal with two things: the NMIP4Config +instance (containing addresses, routes, DNS settings and other information for later use), and a string +dictionary with the DHCP lease options (they are mainly used to expose them on D-Bus). The latter is +immutable (meaning, it's not changed afterwards). That does not significantly change with L3Cfg. The +difference is that instead of NMIP4Config a NML3ConfigData instance gets created. That instance then +references the (immutable) strdict. With that, any part of the code that has access to the NML3ConfigData, +also has access to the lease options. So instead of two separate +pieces of information, the result of a lease event will only be a NML3ConfigData instance (which internally +tracks the strdict with the DHCP lease options). + +Later, when NML3Cfg configures an interface, it takes all NML3ConfigData instances that were added to +it, and merges them. [Currently](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3-config-data.c#L2693), +the merged data will not contain the lease information, but it's probably not needed anyway. + +If it would be needed, the question is what happens if multiple lease informations are present +during the merge. Duplicate leases would not commonly happen, but in general, the merging algorithm +needs to take into account priorities and conflicting data. +That is done by users who call [add](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3cfg.c#L2658) +to provide a priority for the NML3ConfigData instance. +Later, the instances get sorted by priority and merging is smart to take that into account +([here](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/nm-l3cfg.c#L2983)). + +Also, we currently inject the route-metric and table into the generated NMIP4Config. +Those settings come from the connection profiles and not from DHCP. We will avoid that +by allowing the routes in NML3ConfigData to be marked as metric\_any and table\_any. +That way,the NML3ConfigData is independent (and immutable) with respect to those settings. +The same happens for example with PPP, where the modem starts PPP, and currently the +route and metric needs to be passed several layers down. But worst, those settings +can change during reapply. Currently that means we need to hack NMIP4Config with +those changes. Later, we will only tell NML3Cfg to track the NML3ConfigData with +different settings. + +### DNS + +DNS information is currently set in the NMIP4Config instances. That happens for example with the DNS information +from a DHCP lease, but also with the static DNS settings from the connection profile. Later, the same information +will packed in NML3ConfigData. + +One nice difference is again the immutability. Currently, NMDnsManager keeps a reference to all relevant NMIP4Config instances, +but as they are mutable, it needs to [subscribe](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/6b64fac06d2f6e0d9fa530ebb1ab28d53a1c5d03/src/core/dns/nm-dns-manager.c#L275) +to changes. Later, when a NML3ConfigData instance "changes", it means it was +replaced by a different one and NMDnsManager needs to update its list of tracked NML3ConfigData. I find that +cleaner, because adding and removal to the list of NMIP4Config/NML3ConfigData happens anyway and needs to be handled. + + +Related Bugs +------------ + +* Main bug: + + - [rh#1868254](https://bugzilla.redhat.com/show_bug.cgi?id=1868254): + "refactor NetworkManager's IP configuration done by NMDevice" + +* Follow up but to improve model of devices: + + - [rh#1066703](https://bugzilla.redhat.com/show_bug.cgi?id=1066703): + "\[RFE\] Handle parent/child relationships more cleanly" + +* Flexible IP methods: + + - [rh#1791624](https://bugzilla.redhat.com/show_bug.cgi?id=1791624): + "NetworkManager must not remove used bridge" + +* Improving performance issues, this will lay ground work: + + - [rh#1847125](https://bugzilla.redhat.com/show_bug.cgi?id=1847125): + "\[RFE\] Improve 20% performance on creating 1000 bridge over 1000 VLANs" + + - [rh#1861527](https://bugzilla.redhat.com/show_bug.cgi?id=1861527): + "Excessive memory and CPU usage on a router with IPv6 BGP feed" + + - [rh#1753677](https://bugzilla.redhat.com/show_bug.cgi?id=1753677): + "High cpu usage while non-controlled interface is mangling tc filters" + +TODO +---- + +- Before considering an IP method completely activated, check that all addresses + we want to configure are no longer tentative. + For example, when activating a `connection.type=pppoe`, we might get an IPv6 address + from the pppd daemon. We set that via + `nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, ip_data->l3cd)` + Note that this currently already is sufficient to make the IP method (as far as PPP + is concerned), to be "ready". + We should however wait for IPv6 DAD to complete. See how that is already done + for ipmanual (`_dev_ipmanual_check_ready()`). + +- NMDevicePPP fails to re-activate a profile that is currently active. This is not + new on "next" branch, but also happened before. Have a pppoe profile active, + and issue `nmcli connection up $PROFILE` again. This, as expected, brings down + the device but fails to re-activate it. It's not trivial to fix (I think), because + of the ip-ifindex madness. Check the logs. Test with contrib/scripts/test-ppp.sh + script. Possibly affects other types. + +- NMDevice's ip4_config_pre_commit() had only one effect, to call nm_modem_ip4_pre_commit() + which set IFF_NOARP. That is currently dropped. Find a different way to achieve that. + Theoretically, we still could do that from NML3Cfg's post-commit notification. But + this really should be handled by NML3Cfg. That means, to disable IFF_NOARP needs somehow + configured by NMDeviceModem -- possibly by setting a flag in NML3ConfigData that indicates + to do this. Or maybe NML3Cfg should detect automatically when to set IFF_NOARP. + +- `ipvx.method=auto` usually means autoconf6/DHCPv4, but it doesn't have to. For example + with PPP/VPN it might mean that the IP configuration is provided by pppd/VPN or with + Wi-Fi-P2P it might mean that the controller of a peer runs a DHCP server (shared). + Now the parents implementation activate_stage3_ip_config() can no longer be overwritten + by subclasses, and they always perform their steps. For subclasses to modify what a + method means there is klass->get_ip_method_auto(self(). NMDeviceModem does not yet + implement that, which is most certainly lacking. We need to test at least NMDeviceModem + whether IP methods work correctly in this regard. Possibly other subclasses are affected + too (NMDeviceBluetooth?). diff --git a/src/core/README.next.ip-config.md b/src/core/README.next.ip-config.md new file mode 100644 index 0000000000..e5be74f133 --- /dev/null +++ b/src/core/README.next.ip-config.md @@ -0,0 +1,59 @@ +Rework `NMIP[46]Config` for `next` branch +========================================= + +The `next` branch is a large rework of internals, how IP configuration is done by `NMDevice`. + +Previously, there are two `GObject`s named `NMIP4Config` and `NMIP6Config`. These +serve different purposes: + +1) They are data containers that can track IP configuration. As such, `NMDevice` + and various parts (like `NMDhcpClient`) create them, pass them around and + mutate/merge them to track the IP configuration. + +2) They are also subclasses of `NMDBusObject` and exported on D-Bus as + `/org/freedesktop/NetworkManager/IP4Config/1`, etc. As such, see their + [D-Bus API](../../introspection/org.freedesktop.NetworkManager.IP4Config.xml) + (and [for IPv6](../../introspection/org.freedesktop.NetworkManager.IP6Config.xml)). + +`next` branch will replace use 1) with `NML3ConfigData`. `NML3ConfigData` are immutable +(sealable) data containers with little logic. This leaves `NMIP4Config` to only +implement 2). + +This needs to be reworked. + +* Now `NMIP4Config` and `NMIP6Config` are subclasses of `NMIPConfig`. The goal + is to treat IPv4/IPv6 similar and generically. Probably there should be very + little code in the subclasses left and most should move to the parent classes. + We still need separate GObject types though, because that is how `NMDBusObject`'s + glue code can handle different D-Bus paths. + +* Now `NML3Cfg` is a handle for the IP configuration parameters of a device (ifindex). + As `NMIPConfig` mostly is about exporting the current IP configuration, it probably + can get most of it from there (and by listening to signals to that). + +* Note that `NMDevice`, `NMActiveConnection` refer `NMIP[46]Config`s, and most + importantly, the respective D-Bus objects refer to them. As `NMVpnConnection` + (and "org.freedesktop.NetworkManager.VPN.Connection" interface) are modeled + as "subclasses" of `NMActiveConnection`, they also have one. That means, + it's not entirely clear what these properties even are. For example, currently, + `NMDevice` does a (terrible) dance of tracking external `NMIP[46]Config` objects, + merging, intersecting and subtracting them with other `NMIP4Config` objects + to get the merged one, which is then exported on D-Bus. That merged object + does therefore not directly expose the IP addresses that are actually + configured on the interface (`ip addr`), but more what NetworkManager + wanted to configure and the (terrible) feedback loop where the platform + addresses get synced. With `next` branch and `NML3Cfg` there is a clear distinction + between what NetworkManager wants to configure vs. what is actually configured. + I think for `NMDevice` and `NMActiveConnection`, the IP addresses on + "org.freedesktop.NetworkManager.IP4Config" should expose the IP addresses + that are actually in platform (`ip addr`). If there is a need to expose + additional information (like things that NetworkManager wanted to configure), + then this should be different/new API. + On the other hand, currently `NMVpnConnection`'s `NMIP4Config` only tracks the + IP addresses that come from the VPN plugin. So it's much more what it wants + to configure (from the VPN plugin), and not at all about what is configured + on the interface. + I think that needs to change. A `NMIPConfig` object on D-Bus exposes IP configuration + information about an netdev interface. Period. That also means that a `NMVpnConnection` + (which currently is like a active connection associated with the device) links to + the same `NMIPConfig` object as the underlying device. diff --git a/src/core/devices/adsl/nm-device-adsl.c b/src/core/devices/adsl/nm-device-adsl.c index adcf878523..6133a3d056 100644 --- a/src/core/devices/adsl/nm-device-adsl.c +++ b/src/core/devices/adsl/nm-device-adsl.c @@ -15,13 +15,12 @@ #include #include -#include "nm-ip4-config.h" #include "devices/nm-device-private.h" #include "libnm-platform/nm-platform.h" -#include "ppp/nm-ppp-manager-call.h" -#include "ppp/nm-ppp-status.h" +#include "nm-manager.h" #include "nm-setting-adsl.h" #include "nm-utils.h" +#include "ppp/nm-ppp-mgr.h" #define _NMLOG_DEVICE_TYPE NMDeviceAdsl #include "devices/nm-device-logging.h" @@ -34,15 +33,14 @@ typedef struct { guint carrier_poll_id; int atm_index; - /* PPP */ - NMPPPManager *ppp_manager; + NMPppMgr *ppp_mgr; /* RFC 2684 bridging (PPPoE over ATM) */ - int brfd; - int nas_ifindex; - char *nas_ifname; - guint nas_update_id; - guint nas_update_count; + int brfd; + int nas_ifindex; + char * nas_ifname; + GSource *nas_update_source; + guint nas_update_count; } NMDeviceAdslPrivate; struct _NMDeviceAdsl { @@ -271,7 +269,7 @@ pppoe_vcc_config(NMDeviceAdsl *self) } static gboolean -nas_update_cb(gpointer user_data) +nas_update_timeout_cb(gpointer user_data) { NMDeviceAdsl * self = NM_DEVICE_ADSL(user_data); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); @@ -284,33 +282,35 @@ nas_update_cb(gpointer user_data) nm_assert(priv->nas_ifindex <= 0); priv->nas_ifindex = nm_platform_link_get_ifindex(nm_device_get_platform(device), priv->nas_ifname); + + if (priv->nas_ifindex <= 0 && priv->nas_update_count <= 10) { + /* Keep waiting for it to appear */ + return G_SOURCE_CONTINUE; + } + + nm_clear_g_source_inst(&priv->nas_update_source); + if (priv->nas_ifindex <= 0) { - if (priv->nas_update_count <= 10) { - /* Keep waiting for it to appear */ - return G_SOURCE_CONTINUE; - } - priv->nas_update_id = 0; _LOGW(LOGD_ADSL, "failed to find br2684 interface %s ifindex after timeout", priv->nas_ifname); nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BR2684_FAILED); - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } - priv->nas_update_id = 0; _LOGD(LOGD_ADSL, "using br2684 iface '%s' index %d", priv->nas_ifname, priv->nas_ifindex); if (!pppoe_vcc_config(self)) { nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BR2684_FAILED); - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } nm_device_activate_schedule_stage2_device_config(device, TRUE); - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } static gboolean @@ -319,11 +319,11 @@ br2684_create_iface(NMDeviceAdsl *self) NMDeviceAdslPrivate * priv = NM_DEVICE_ADSL_GET_PRIVATE(self); struct atm_newif_br2684 ni; nm_auto_close int fd = -1; - int err, errsv; + int err; + int errsv; guint num = 0; - if (nm_clear_g_source(&priv->nas_update_id)) - nm_assert_not_reached(); + nm_assert(!priv->nas_update_source); fd = socket(PF_ATMPVC, SOCK_DGRAM | SOCK_CLOEXEC, ATM_AAL5); if (fd < 0) { @@ -358,174 +358,187 @@ br2684_create_iface(NMDeviceAdsl *self) nm_strdup_reset(&priv->nas_ifname, ni.ifname); _LOGD(LOGD_ADSL, "waiting for br2684 iface '%s' to appear", priv->nas_ifname); - priv->nas_update_count = 0; - priv->nas_update_id = g_timeout_add(100, nas_update_cb, self); + priv->nas_update_count = 0; + priv->nas_update_source = nm_g_timeout_add_source(100, nas_update_timeout_cb, self); return TRUE; } } +/*****************************************************************************/ + +static void +_ppp_mgr_cleanup(NMDeviceAdsl *self) +{ + NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); + + nm_clear_pointer(&priv->ppp_mgr, nm_ppp_mgr_destroy); +} + +static void +_ppp_mgr_stage3_maybe_ready(NMDeviceAdsl *self) +{ + NMDevice * device = NM_DEVICE(self); + NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); + int IS_IPv4; + + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + const int addr_family = IS_IPv4 ? AF_INET : AF_INET6; + const NMPppMgrIPData *ip_data; + + ip_data = nm_ppp_mgr_get_ip_data(priv->ppp_mgr, addr_family); + if (ip_data->ip_received) + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, ip_data->l3cd); + } + + if (nm_ppp_mgr_get_state(priv->ppp_mgr) >= NM_PPP_MGR_STATE_HAVE_IP_CONFIG) + nm_device_devip_set_state(device, AF_UNSPEC, NM_DEVICE_IP_STATE_READY, NULL); +} + +static void +_ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, gpointer user_data) +{ + NMDeviceAdsl *self = NM_DEVICE_ADSL(user_data); + NMDevice * device = NM_DEVICE(self); + NMDeviceState device_state; + + if (callback_data->callback_type != NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED) + return; + + device_state = nm_device_get_state(device); + + if (callback_data->data.state >= _NM_PPP_MGR_STATE_FAILED_START) { + if (device_state <= NM_DEVICE_STATE_ACTIVATED) + nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, callback_data->data.reason); + return; + } + + if (device_state < NM_DEVICE_STATE_IP_CONFIG) { + if (callback_data->data.state >= NM_PPP_MGR_STATE_HAVE_IFINDEX) { + gs_free char *old_name = NULL; + gs_free_error GError *error = NULL; + + if (!nm_device_take_over_link(device, callback_data->data.ifindex, &old_name, &error)) { + _LOGW(LOGD_DEVICE | LOGD_PPP, + "could not take control of link %d: %s", + callback_data->data.ifindex, + error->message); + _ppp_mgr_cleanup(self); + nm_device_state_changed(device, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_CONFIG_FAILED); + return; + } + + if (old_name) + nm_manager_remove_device(NM_MANAGER_GET, old_name, NM_DEVICE_TYPE_ADSL); + + nm_device_activate_schedule_stage2_device_config(device, FALSE); + } + return; + } + + _ppp_mgr_stage3_maybe_ready(self); +} + +/*****************************************************************************/ + static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { NMDeviceAdsl * self = NM_DEVICE_ADSL(device); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); - NMSettingAdsl * s_adsl; - const char * protocol; - s_adsl = nm_device_get_applied_setting(device, NM_TYPE_SETTING_ADSL); + if (!priv->ppp_mgr) { + gs_free_error GError *error = NULL; + NMSettingAdsl * s_adsl; + const char * protocol; + NMActRequest * req; + const char * ppp_iface; - g_return_val_if_fail(s_adsl, NM_ACT_STAGE_RETURN_FAILURE); + req = nm_device_get_act_request(device); + g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); - protocol = nm_setting_adsl_get_protocol(s_adsl); - _LOGD(LOGD_ADSL, "using ADSL protocol '%s'", protocol); + s_adsl = nm_device_get_applied_setting(device, NM_TYPE_SETTING_ADSL); + g_return_val_if_fail(s_adsl, NM_ACT_STAGE_RETURN_FAILURE); - if (nm_streq0(protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA)) { - /* PPPoA doesn't need anything special */ - return NM_ACT_STAGE_RETURN_SUCCESS; - } + protocol = nm_setting_adsl_get_protocol(s_adsl); - if (nm_streq0(protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)) { - /* PPPoE needs RFC2684 bridging before we can do PPP over it */ - if (priv->nas_ifindex <= 0) { - if (priv->nas_update_id == 0) { - if (!br2684_create_iface(self)) { - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_BR2684_FAILED); - return NM_ACT_STAGE_RETURN_FAILURE; + _LOGD(LOGD_ADSL, "using ADSL protocol '%s'", protocol); + + if (nm_streq0(protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA)) { + /* PPPoA doesn't need anything special */ + } else if (nm_streq0(protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)) { + /* PPPoE needs RFC2684 bridging before we can do PPP over it */ + if (priv->nas_ifindex <= 0) { + if (!priv->nas_update_source) { + if (!br2684_create_iface(self)) { + NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_BR2684_FAILED); + return NM_ACT_STAGE_RETURN_FAILURE; + } } + return NM_ACT_STAGE_RETURN_POSTPONE; } - return NM_ACT_STAGE_RETURN_POSTPONE; + } else + nm_assert(nm_streq0(protocol, NM_SETTING_ADSL_PROTOCOL_IPOATM)); + + /* PPPoE uses the NAS interface, not the ATM interface */ + if (nm_streq0(protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)) { + nm_assert(priv->nas_ifname); + ppp_iface = priv->nas_ifname; + _LOGD(LOGD_ADSL, "starting PPPoE on br2684 interface %s", priv->nas_ifname); + } else { + ppp_iface = nm_device_get_iface(device); + _LOGD(LOGD_ADSL, "starting PPPoA"); } - return NM_ACT_STAGE_RETURN_SUCCESS; + + priv->ppp_mgr = nm_ppp_mgr_start(&((const NMPppMgrConfig){ + .netns = nm_device_get_netns(device), + .parent_iface = ppp_iface, + .callback = _ppp_mgr_callback, + .user_data = self, + .act_req = req, + .ppp_username = nm_setting_adsl_get_username(s_adsl), + .timeout_secs = 30, + .baud_override = 0, + }), + &error); + if (!priv->ppp_mgr) { + _LOGW(LOGD_DEVICE | LOGD_PPP, "PPPoE failed to start: %s", error->message); + *out_failure_reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; + return NM_ACT_STAGE_RETURN_FAILURE; + } + + return NM_ACT_STAGE_RETURN_POSTPONE; } - _LOGW(LOGD_ADSL, "unhandled ADSL protocol '%s'", protocol); + if (nm_ppp_mgr_get_state(priv->ppp_mgr) < NM_PPP_MGR_STATE_HAVE_IFINDEX) + return NM_ACT_STAGE_RETURN_POSTPONE; + return NM_ACT_STAGE_RETURN_SUCCESS; } static void -ppp_state_changed(NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_data) -{ - NMDevice *device = NM_DEVICE(user_data); - - switch (status) { - case NM_PPP_STATUS_DISCONNECT: - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_PPP_DISCONNECT); - break; - case NM_PPP_STATUS_DEAD: - nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED); - break; - default: - break; - } -} - -static void -ppp_ifindex_set(NMPPPManager *ppp_manager, int ifindex, const char *iface, gpointer user_data) -{ - NMDevice *device = NM_DEVICE(user_data); - - if (!nm_device_set_ip_ifindex(device, ifindex)) { - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } -} - -static void -ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data) -{ - NMDevice *device = NM_DEVICE(user_data); - - /* Ignore PPP IP4 events that come in after initial configuration */ - if (nm_device_activate_ip4_state_in_conf(device)) - nm_device_activate_schedule_ip_config_result(device, AF_INET, NM_IP_CONFIG_CAST(config)); -} - -static NMActStageReturn -act_stage3_ip4_config_start(NMDevice * device, - NMIP4Config ** out_config, - NMDeviceStateReason *out_failure_reason) +act_stage3_ip_config(NMDevice *device, int addr_family) { NMDeviceAdsl * self = NM_DEVICE_ADSL(device); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); - NMSettingAdsl * s_adsl; - NMActRequest * req; - GError * err = NULL; - const char * ppp_iface; + NMPppMgrState ppp_state; - req = nm_device_get_act_request(device); - - g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); - - s_adsl = nm_device_get_applied_setting(device, NM_TYPE_SETTING_ADSL); - - g_return_val_if_fail(s_adsl, NM_ACT_STAGE_RETURN_FAILURE); - - /* PPPoE uses the NAS interface, not the ATM interface */ - if (nm_streq0(nm_setting_adsl_get_protocol(s_adsl), NM_SETTING_ADSL_PROTOCOL_PPPOE)) { - nm_assert(priv->nas_ifname); - ppp_iface = priv->nas_ifname; - - _LOGD(LOGD_ADSL, "starting PPPoE on br2684 interface %s", priv->nas_ifname); - } else { - ppp_iface = nm_device_get_iface(device); - _LOGD(LOGD_ADSL, "starting PPPoA"); + if (!priv->ppp_mgr) { + nm_assert_not_reached(); + return; } - priv->ppp_manager = nm_ppp_manager_create(ppp_iface, &err); + ppp_state = nm_ppp_mgr_get_state(priv->ppp_mgr); - if (priv->ppp_manager) { - nm_ppp_manager_set_route_parameters(priv->ppp_manager, - nm_device_get_route_table(device, AF_INET), - nm_device_get_route_metric(device, AF_INET), - nm_device_get_route_table(device, AF_INET6), - nm_device_get_route_metric(device, AF_INET6)); + nm_assert(NM_IN_SET(ppp_state, NM_PPP_MGR_STATE_HAVE_IFINDEX, NM_PPP_MGR_STATE_HAVE_IP_CONFIG)); + + if (ppp_state < NM_PPP_MGR_STATE_HAVE_IP_CONFIG) { + nm_device_devip_set_state(device, AF_UNSPEC, NM_DEVICE_IP_STATE_PENDING, NULL); + return; } - if (!priv->ppp_manager - || !nm_ppp_manager_start(priv->ppp_manager, - req, - nm_setting_adsl_get_username(s_adsl), - 30, - 0, - &err)) { - _LOGW(LOGD_ADSL, "PPP failed to start: %s", err->message); - g_error_free(err); - - g_clear_object(&priv->ppp_manager); - - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, - G_CALLBACK(ppp_state_changed), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IFINDEX_SET, - G_CALLBACK(ppp_ifindex_set), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, - G_CALLBACK(ppp_ip4_config), - self); - return NM_ACT_STAGE_RETURN_POSTPONE; -} - -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) -{ - if (addr_family == AF_INET) - return act_stage3_ip4_config_start(device, (NMIP4Config **) out_config, out_failure_reason); - - return NM_DEVICE_CLASS(nm_device_adsl_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); + _ppp_mgr_stage3_maybe_ready(self); } static void @@ -533,23 +546,15 @@ adsl_cleanup(NMDeviceAdsl *self) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); - if (priv->ppp_manager) { - g_signal_handlers_disconnect_by_func(priv->ppp_manager, - G_CALLBACK(ppp_state_changed), - self); - g_signal_handlers_disconnect_by_func(priv->ppp_manager, G_CALLBACK(ppp_ip4_config), self); - nm_ppp_manager_stop(priv->ppp_manager, NULL, NULL, NULL); - g_clear_object(&priv->ppp_manager); - } + _ppp_mgr_cleanup(self); g_signal_handlers_disconnect_by_func(nm_device_get_platform(NM_DEVICE(self)), G_CALLBACK(link_changed_cb), self); - nm_close(priv->brfd); - priv->brfd = -1; + nm_clear_fd(&priv->brfd); - nm_clear_g_source(&priv->nas_update_id); + nm_clear_g_source_inst(&priv->nas_update_source); /* FIXME: kernel has no way of explicitly deleting the 'nasX' interface yet, * so it gets leaked. It does get destroyed when it's no longer in use, @@ -699,9 +704,9 @@ nm_device_adsl_class_init(NMDeviceAdslClass *klass) device_class->check_connection_compatible = check_connection_compatible; device_class->complete_connection = complete_connection; - device_class->act_stage2_config = act_stage2_config; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; - device_class->deactivate = deactivate; + device_class->act_stage2_config = act_stage2_config; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->deactivate = deactivate; obj_properties[PROP_ATM_INDEX] = g_param_spec_int(NM_DEVICE_ADSL_ATM_INDEX, diff --git a/src/core/devices/bluetooth/nm-device-bt.c b/src/core/devices/bluetooth/nm-device-bt.c index 3dbfbbe06e..5346aaed62 100644 --- a/src/core/devices/bluetooth/nm-device-bt.c +++ b/src/core/devices/bluetooth/nm-device-bt.c @@ -26,7 +26,6 @@ #include "settings/nm-settings-connection.h" #include "nm-utils.h" #include "nm-bt-error.h" -#include "nm-ip4-config.h" #include "libnm-platform/nm-platform.h" #include "devices/wwan/nm-modem-manager.h" @@ -425,43 +424,9 @@ static void ppp_failed(NMModem *modem, guint i_reason, gpointer user_data) { NMDevice * device = NM_DEVICE(user_data); - NMDeviceBt * self = NM_DEVICE_BT(user_data); NMDeviceStateReason reason = i_reason; - switch (nm_device_get_state(device)) { - case NM_DEVICE_STATE_PREPARE: - case NM_DEVICE_STATE_CONFIG: - case NM_DEVICE_STATE_NEED_AUTH: - nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, reason); - break; - case NM_DEVICE_STATE_IP_CONFIG: - case NM_DEVICE_STATE_IP_CHECK: - case NM_DEVICE_STATE_SECONDARIES: - case NM_DEVICE_STATE_ACTIVATED: - if (nm_device_activate_ip4_state_in_conf(device)) - nm_device_activate_schedule_ip_config_timeout(device, AF_INET); - else if (nm_device_activate_ip6_state_in_conf(device)) - nm_device_activate_schedule_ip_config_timeout(device, AF_INET6); - else if (nm_device_activate_ip4_state_done(device)) { - nm_device_ip_method_failed(device, - AF_INET, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } else if (nm_device_activate_ip6_state_done(device)) { - nm_device_ip_method_failed(device, - AF_INET6, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } else { - _LOGW(LOGD_MB, - "PPP failure in unexpected state %u", - (guint) nm_device_get_state(device)); - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } - break; - default: - break; - } + nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, reason); } static void @@ -547,22 +512,35 @@ device_state_changed(NMDevice * device, } static void -modem_ip4_config_result(NMModem *modem, NMIP4Config *config, GError *error, gpointer user_data) +modem_new_config(NMModem * modem, + int addr_family, + const NML3ConfigData * l3cd, + gboolean do_auto, + const NMUtilsIPv6IfaceId *iid, + int failure_reason_i, + GError * error, + gpointer user_data) { - NMDeviceBt *self = NM_DEVICE_BT(user_data); - NMDevice * device = NM_DEVICE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDeviceBt *self = NM_DEVICE_BT(user_data); + NMDevice * device = NM_DEVICE(self); - g_return_if_fail(nm_device_activate_ip4_state_in_conf(device) == TRUE); + g_return_if_fail(nm_device_devip_get_state(device, addr_family) == NM_DEVICE_IP_STATE_PENDING); if (error) { - _LOGW(LOGD_MB | LOGD_IP4 | LOGD_BT, - "retrieving IP4 configuration failed: %s", - error->message); - nm_device_ip_method_failed(device, AF_INET, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + _LOGW(LOGD_MB | LOGD_IP4, "retrieving IP configuration failed: %s", error->message); + nm_device_devip_set_failed(device, addr_family, failure_reason_i); return; } - nm_device_activate_schedule_ip_config_result(device, AF_INET, NM_IP_CONFIG_CAST(config)); + if (do_auto) { + if (IS_IPv4) + nm_device_ip_method_dhcp4_start(device); + else + nm_device_ip_method_autoconf6_start(device); + } + + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, l3cd); } static void @@ -687,7 +665,7 @@ modem_try_claim(NMDeviceBt *self, NMModem *modem) g_signal_connect(modem, NM_MODEM_PPP_STATS, G_CALLBACK(ppp_stats), self); g_signal_connect(modem, NM_MODEM_PPP_FAILED, G_CALLBACK(ppp_failed), self); g_signal_connect(modem, NM_MODEM_PREPARE_RESULT, G_CALLBACK(modem_prepare_result), self); - g_signal_connect(modem, NM_MODEM_IP4_CONFIG_RESULT, G_CALLBACK(modem_ip4_config_result), self); + g_signal_connect(modem, NM_MODEM_NEW_CONFIG, G_CALLBACK(modem_new_config), self); g_signal_connect(modem, NM_MODEM_AUTH_REQUESTED, G_CALLBACK(modem_auth_requested), self); g_signal_connect(modem, NM_MODEM_AUTH_RESULT, G_CALLBACK(modem_auth_result), self); g_signal_connect(modem, NM_MODEM_STATE_CHANGED, G_CALLBACK(modem_state_cb), self); @@ -992,35 +970,22 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) NMDeviceBt * self = NM_DEVICE_BT(device); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); - if (priv->connect_bt_type == NM_BT_CAPABILITY_DUN) - nm_modem_act_stage2_config(priv->modem); + if (priv->connect_bt_type != NM_BT_CAPABILITY_DUN) + return NM_ACT_STAGE_RETURN_SUCCESS; - return NM_ACT_STAGE_RETURN_SUCCESS; + return nm_modem_act_stage2_config(priv->modem, device, out_failure_reason); } -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) +static void +act_stage3_ip_config(NMDevice *device, int addr_family) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(device); - gboolean autoip4 = FALSE; - NMActStageReturn ret; + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(device); if (priv->connect_bt_type != NM_BT_CAPABILITY_DUN) - goto out_chain_up; + return; - if (!NM_IS_IPv4(addr_family)) - return nm_modem_stage3_ip6_config_start(priv->modem, device, out_failure_reason); - - ret = nm_modem_stage3_ip4_config_start(priv->modem, device, &autoip4, out_failure_reason); - if (ret != NM_ACT_STAGE_RETURN_SUCCESS || !autoip4) - return ret; - -out_chain_up: - return NM_DEVICE_CLASS(nm_device_bt_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); + if (nm_modem_stage3_ip_config_start(priv->modem, addr_family, device)) + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_PENDING, NULL); } static void @@ -1344,7 +1309,7 @@ nm_device_bt_class_init(NMDeviceBtClass *klass) device_class->deactivate = deactivate; device_class->act_stage1_prepare = act_stage1_prepare; device_class->act_stage2_config = act_stage2_config; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->act_stage3_ip_config = act_stage3_ip_config; device_class->check_connection_compatible = check_connection_compatible; device_class->check_connection_available = check_connection_available; device_class->complete_connection = complete_connection; diff --git a/src/core/devices/nm-acd-manager.c b/src/core/devices/nm-acd-manager.c deleted file mode 100644 index c041163ef8..0000000000 --- a/src/core/devices/nm-acd-manager.c +++ /dev/null @@ -1,497 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2015 - 2018 Red Hat, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include "nm-acd-manager.h" - -#include -#include -#include -#include - -#include "libnm-platform/nm-platform.h" -#include "nm-utils.h" -#include "NetworkManagerUtils.h" -#include "n-acd/src/n-acd.h" - -/*****************************************************************************/ - -typedef enum { - STATE_INIT, - STATE_PROBING, - STATE_PROBE_DONE, - STATE_ANNOUNCING, -} State; - -typedef struct { - in_addr_t address; - gboolean duplicate; - NAcdProbe *probe; -} AddressInfo; - -struct _NMAcdManager { - int ifindex; - guint8 hwaddr[ETH_ALEN]; - State state; - GHashTable *addresses; - guint completed; - NAcd * acd; - GSource * event_source; - - NMAcdCallbacks callbacks; - gpointer user_data; -}; - -/*****************************************************************************/ - -#define _NMLOG_DOMAIN LOGD_IP4 -#define _NMLOG_PREFIX_NAME "acd" -#define _NMLOG(level, ...) \ - G_STMT_START \ - { \ - char _sbuf[64]; \ - \ - nm_log((level), \ - _NMLOG_DOMAIN, \ - self && self->ifindex > 0 \ - ? nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex) \ - : NULL, \ - NULL, \ - "%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME, \ - self ? nm_sprintf_buf(_sbuf, "[%p,%d]", self, self->ifindex) \ - : "" _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } \ - G_STMT_END - -/*****************************************************************************/ - -static const char * -_acd_event_to_string(unsigned int event) -{ - switch (event) { - case N_ACD_EVENT_READY: - return "ready"; - case N_ACD_EVENT_USED: - return "used"; - case N_ACD_EVENT_DEFENDED: - return "defended"; - case N_ACD_EVENT_CONFLICT: - return "conflict"; - case N_ACD_EVENT_DOWN: - return "down"; - } - return NULL; -} - -#define ACD_EVENT_TO_STRING_BUF_SIZE 50 - -static const char * -_acd_event_to_string_buf(unsigned event, char buffer[static ACD_EVENT_TO_STRING_BUF_SIZE]) -{ - const char *s; - - s = _acd_event_to_string(event); - if (s) - return s; - - g_snprintf(buffer, ACD_EVENT_TO_STRING_BUF_SIZE, "(%u)", event); - return buffer; -} - -static const char * -acd_error_to_string(int error) -{ - if (error < 0) - return nm_strerror_native(-error); - - switch (error) { - case _N_ACD_E_SUCCESS: - return "success"; - case N_ACD_E_PREEMPTED: - return "preempted"; - case N_ACD_E_INVALID_ARGUMENT: - return "invalid argument"; - } - - g_return_val_if_reached(NULL); -} - -static int -acd_error_to_nmerr(int error, gboolean always_fail) -{ - if (error < 0) - return -nm_errno_native(error); - - if (always_fail) { - if (NM_IN_SET(error, N_ACD_E_PREEMPTED, N_ACD_E_INVALID_ARGUMENT)) - return -NME_UNSPEC; - g_return_val_if_reached(-NME_UNSPEC); - } - - /* so, @error is either zero (indicating success) or one - * of the special status codes like N_ACD_E_*. In both cases, - * return the positive value here. */ - if (NM_IN_SET(error, _N_ACD_E_SUCCESS, N_ACD_E_PREEMPTED, N_ACD_E_INVALID_ARGUMENT)) - return error; - - g_return_val_if_reached(error); -} - -/*****************************************************************************/ - -/** - * nm_acd_manager_add_address: - * @self: a #NMAcdManager - * @address: an IP address - * - * Add @address to the list of IP addresses to probe. - - * Returns: %TRUE on success, %FALSE if the address was already in the list - */ -gboolean -nm_acd_manager_add_address(NMAcdManager *self, in_addr_t address) -{ - AddressInfo *info; - - g_return_val_if_fail(self, FALSE); - g_return_val_if_fail(self->state == STATE_INIT, FALSE); - - if (g_hash_table_lookup(self->addresses, GUINT_TO_POINTER(address))) - return FALSE; - - info = g_slice_new0(AddressInfo); - info->address = address; - - g_hash_table_insert(self->addresses, GUINT_TO_POINTER(address), info); - - return TRUE; -} - -static gboolean -acd_event(int fd, GIOCondition condition, gpointer data) -{ - NMAcdManager *self = data; - NAcdEvent * event; - AddressInfo * info; - gboolean emit_probe_terminated = FALSE; - char address_str[INET_ADDRSTRLEN]; - int r; - - if (n_acd_dispatch(self->acd)) - return G_SOURCE_CONTINUE; - - while (!n_acd_pop_event(self->acd, &event) && event) { - char to_string_buffer[ACD_EVENT_TO_STRING_BUF_SIZE]; - gs_free char *hwaddr_str = NULL; - gboolean check_probing_done = FALSE; - char buf[ETH_ALEN * 3]; - - switch (event->event) { - case N_ACD_EVENT_READY: - n_acd_probe_get_userdata(event->ready.probe, (void **) &info); - info->duplicate = FALSE; - if (self->state == STATE_ANNOUNCING) { - /* fake probe ended, start announcing */ - r = n_acd_probe_announce(info->probe, N_ACD_DEFEND_ONCE); - if (r) { - _LOGW("couldn't announce address %s on interface '%s': %s", - _nm_utils_inet4_ntop(info->address, address_str), - nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex), - acd_error_to_string(r)); - } else { - _LOGD("announcing address %s (hw-addr %s)", - _nm_utils_inet4_ntop(info->address, address_str), - _nm_utils_hwaddr_ntoa(self->hwaddr, ETH_ALEN, TRUE, buf, sizeof(buf))); - } - } - check_probing_done = TRUE; - break; - case N_ACD_EVENT_USED: - n_acd_probe_get_userdata(event->used.probe, (void **) &info); - info->duplicate = TRUE; - check_probing_done = TRUE; - break; - case N_ACD_EVENT_DEFENDED: - n_acd_probe_get_userdata(event->defended.probe, (void **) &info); - _LOGD("defended address %s from host %s", - _nm_utils_inet4_ntop(info->address, address_str), - (hwaddr_str = - nm_utils_hwaddr_ntoa(event->defended.sender, event->defended.n_sender))); - break; - case N_ACD_EVENT_CONFLICT: - n_acd_probe_get_userdata(event->conflict.probe, (void **) &info); - _LOGW("conflict for address %s detected with host %s on interface '%s'", - _nm_utils_inet4_ntop(info->address, address_str), - (hwaddr_str = - nm_utils_hwaddr_ntoa(event->defended.sender, event->defended.n_sender)), - nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex)); - break; - default: - _LOGD("unhandled event '%s'", _acd_event_to_string_buf(event->event, to_string_buffer)); - break; - } - - if (check_probing_done && self->state == STATE_PROBING - && ++self->completed == g_hash_table_size(self->addresses)) { - self->state = STATE_PROBE_DONE; - emit_probe_terminated = TRUE; - } - } - - if (emit_probe_terminated) { - if (self->callbacks.probe_terminated_callback) { - self->callbacks.probe_terminated_callback(self, self->user_data); - } - } - - return G_SOURCE_CONTINUE; -} - -static gboolean -acd_probe_add(NMAcdManager *self, AddressInfo *info, guint64 timeout) -{ - NAcdProbeConfig *probe_config; - int r; - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - - r = n_acd_probe_config_new(&probe_config); - if (r) { - _LOGW("could not create probe config for %s on interface '%s': %s", - _nm_utils_inet4_ntop(info->address, sbuf), - nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex), - acd_error_to_string(r)); - return FALSE; - } - - n_acd_probe_config_set_ip(probe_config, (struct in_addr){info->address}); - n_acd_probe_config_set_timeout(probe_config, timeout); - - r = n_acd_probe(self->acd, &info->probe, probe_config); - if (r) { - _LOGW("could not start probe for %s on interface '%s': %s", - _nm_utils_inet4_ntop(info->address, sbuf), - nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex), - acd_error_to_string(r)); - n_acd_probe_config_free(probe_config); - return FALSE; - } - - n_acd_probe_set_userdata(info->probe, info); - n_acd_probe_config_free(probe_config); - - return TRUE; -} - -static int -acd_init(NMAcdManager *self) -{ - NAcdConfig *config; - int r; - - if (self->acd) - return 0; - - r = n_acd_config_new(&config); - if (r) - return r; - - n_acd_config_set_ifindex(config, self->ifindex); - n_acd_config_set_transport(config, N_ACD_TRANSPORT_ETHERNET); - n_acd_config_set_mac(config, self->hwaddr, ETH_ALEN); - - r = n_acd_new(&self->acd, config); - n_acd_config_free(config); - return r; -} - -/** - * nm_acd_manager_start_probe: - * @self: a #NMAcdManager - * @timeout: maximum probe duration in milliseconds - * @error: location to store error, or %NULL - * - * Start probing IP addresses for duplicates; when the probe terminates a - * PROBE_TERMINATED signal is emitted. - * - * Returns: 0 on success or a negative NetworkManager error code (NME_*). - */ -int -nm_acd_manager_start_probe(NMAcdManager *self, guint timeout) -{ - GHashTableIter iter; - AddressInfo * info; - gboolean success = FALSE; - int fd, r; - - g_return_val_if_fail(self, FALSE); - g_return_val_if_fail(self->state == STATE_INIT, FALSE); - - r = acd_init(self); - if (r) { - _LOGW("couldn't init ACD for probing on interface '%s': %s", - nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex), - acd_error_to_string(r)); - return acd_error_to_nmerr(r, TRUE); - } - - self->completed = 0; - - g_hash_table_iter_init(&iter, self->addresses); - while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &info)) - success |= acd_probe_add(self, info, timeout); - - if (success) - self->state = STATE_PROBING; - - nm_assert(!self->event_source); - n_acd_get_fd(self->acd, &fd); - self->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, acd_event, self); - - return success ? 0 : -NME_UNSPEC; -} - -/** - * nm_acd_manager_check_address: - * @self: a #NMAcdManager - * @address: an IP address - * - * Check if an IP address is duplicate. @address must have been added with - * nm_acd_manager_add_address(). - * - * Returns: %TRUE if the address is not duplicate, %FALSE otherwise - */ -gboolean -nm_acd_manager_check_address(NMAcdManager *self, in_addr_t address) -{ - AddressInfo *info; - - g_return_val_if_fail(self, FALSE); - g_return_val_if_fail(NM_IN_SET(self->state, STATE_INIT, STATE_PROBE_DONE), FALSE); - - info = g_hash_table_lookup(self->addresses, GUINT_TO_POINTER(address)); - g_return_val_if_fail(info, FALSE); - - return !info->duplicate; -} - -/** - * nm_acd_manager_announce_addresses: - * @self: a #NMAcdManager - * - * Start announcing addresses. - * - * Returns: a negative NetworkManager error number or zero on success. - */ -int -nm_acd_manager_announce_addresses(NMAcdManager *self) -{ - GHashTableIter iter; - AddressInfo * info; - int r; - int fd; - gboolean success = TRUE; - char buf[ETH_ALEN * 3]; - - r = acd_init(self); - if (r) { - _LOGW("couldn't init ACD for announcing addresses on interface '%s': %s", - nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex), - acd_error_to_string(r)); - return acd_error_to_nmerr(r, TRUE); - } - - if (self->state == STATE_INIT) { - /* n-acd can't announce without probing, therefore let's - * start a fake probe with zero timeout and then perform - * the announcement. */ - g_hash_table_iter_init(&iter, self->addresses); - while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &info)) { - if (!acd_probe_add(self, info, 0)) - success = FALSE; - } - self->state = STATE_ANNOUNCING; - } else if (self->state == STATE_ANNOUNCING) { - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - - g_hash_table_iter_init(&iter, self->addresses); - while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &info)) { - if (info->duplicate) - continue; - r = n_acd_probe_announce(info->probe, N_ACD_DEFEND_ONCE); - if (r) { - _LOGW("couldn't announce address %s on interface '%s': %s", - _nm_utils_inet4_ntop(info->address, sbuf), - nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex), - acd_error_to_string(r)); - success = FALSE; - } else - _LOGD("announcing address %s (hw-addr %s)", - _nm_utils_inet4_ntop(info->address, sbuf), - _nm_utils_hwaddr_ntoa(self->hwaddr, ETH_ALEN, TRUE, buf, sizeof(buf))); - } - } - - if (!self->event_source) { - n_acd_get_fd(self->acd, &fd); - self->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, acd_event, self); - } - - return success ? 0 : -NME_UNSPEC; -} - -static void -destroy_address_info(gpointer data) -{ - AddressInfo *info = (AddressInfo *) data; - - n_acd_probe_free(info->probe); - - g_slice_free(AddressInfo, info); -} - -/*****************************************************************************/ - -NMAcdManager * -nm_acd_manager_new(int ifindex, - const guint8 * hwaddr, - guint hwaddr_len, - const NMAcdCallbacks *callbacks, - gpointer user_data) -{ - NMAcdManager *self; - - g_return_val_if_fail(ifindex > 0, NULL); - g_return_val_if_fail(hwaddr, NULL); - g_return_val_if_fail(hwaddr_len == ETH_ALEN, NULL); - - self = g_slice_new0(NMAcdManager); - - if (callbacks) - self->callbacks = *callbacks; - self->user_data = user_data; - - self->addresses = g_hash_table_new_full(nm_direct_hash, NULL, NULL, destroy_address_info); - self->state = STATE_INIT; - self->ifindex = ifindex; - memcpy(self->hwaddr, hwaddr, ETH_ALEN); - return self; -} - -void -nm_acd_manager_free(NMAcdManager *self) -{ - g_return_if_fail(self); - - if (self->callbacks.user_data_destroy) - self->callbacks.user_data_destroy(self->user_data); - - nm_clear_pointer(&self->addresses, g_hash_table_destroy); - nm_clear_g_source_inst(&self->event_source); - nm_clear_pointer(&self->acd, n_acd_unref); - - g_slice_free(NMAcdManager, self); -} diff --git a/src/core/devices/nm-acd-manager.h b/src/core/devices/nm-acd-manager.h deleted file mode 100644 index e8ef6f2b99..0000000000 --- a/src/core/devices/nm-acd-manager.h +++ /dev/null @@ -1,34 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2015 - 2018 Red Hat, Inc. - */ - -#ifndef __NM_ACD_MANAGER__ -#define __NM_ACD_MANAGER__ - -#include - -typedef struct _NMAcdManager NMAcdManager; - -typedef struct { - void (*probe_terminated_callback)(NMAcdManager *self, gpointer user_data); - GDestroyNotify user_data_destroy; -} NMAcdCallbacks; - -NMAcdManager *nm_acd_manager_new(int ifindex, - const guint8 * hwaddr, - guint hwaddr_len, - const NMAcdCallbacks *callbacks, - gpointer user_data); - -void nm_acd_manager_free(NMAcdManager *self); - -gboolean nm_acd_manager_add_address(NMAcdManager *self, in_addr_t address); -int nm_acd_manager_start_probe(NMAcdManager *self, guint timeout); -gboolean nm_acd_manager_check_address(NMAcdManager *self, in_addr_t address); -int nm_acd_manager_announce_addresses(NMAcdManager *self); - -NM_AUTO_DEFINE_FCN0(NMAcdManager *, _nm_auto_free_acdmgr, nm_acd_manager_free); -#define nm_auto_free_acdmgr nm_auto(_nm_auto_free_acdmgr) - -#endif /* __NM_ACD_MANAGER__ */ diff --git a/src/core/devices/nm-device-bond.c b/src/core/devices/nm-device-bond.c index f7d78f57b7..3e7fd0ee18 100644 --- a/src/core/devices/nm-device-bond.c +++ b/src/core/devices/nm-device-bond.c @@ -16,7 +16,6 @@ #include "nm-device-factory.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" -#include "nm-ip4-config.h" #include "nm-setting-bond-port.h" #define _NMLOG_DEVICE_TYPE NMDeviceBond diff --git a/src/core/devices/nm-device-dummy.c b/src/core/devices/nm-device-dummy.c index 4c12648fc1..60ac524988 100644 --- a/src/core/devices/nm-device-dummy.c +++ b/src/core/devices/nm-device-dummy.c @@ -12,7 +12,6 @@ #include "nm-act-request.h" #include "nm-device-private.h" -#include "nm-ip4-config.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-dummy.h" diff --git a/src/core/devices/nm-device-ethernet.c b/src/core/devices/nm-device-ethernet.c index 667ea9b927..52fce56943 100644 --- a/src/core/devices/nm-device-ethernet.c +++ b/src/core/devices/nm-device-ethernet.c @@ -14,38 +14,36 @@ #include #include -#include "libnm-glib-aux/nm-uuid.h" -#include "nm-device-private.h" -#include "nm-act-request.h" -#include "nm-ip4-config.h" #include "NetworkManagerUtils.h" -#include "supplicant/nm-supplicant-manager.h" -#include "supplicant/nm-supplicant-interface.h" -#include "supplicant/nm-supplicant-config.h" -#include "ppp/nm-ppp-manager.h" -#include "ppp/nm-ppp-manager-call.h" -#include "ppp/nm-ppp-status.h" -#include "libnm-platform/nm-platform.h" -#include "libnm-platform/nm-platform-utils.h" -#include "nm-dcb.h" -#include "settings/nm-settings-connection.h" -#include "nm-config.h" -#include "nm-device-ethernet-utils.h" -#include "settings/nm-settings.h" -#include "nm-device-factory.h" +#include "NetworkManagerUtils.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" -#include "NetworkManagerUtils.h" +#include "libnm-glib-aux/nm-uuid.h" +#include "libnm-platform/nm-platform-utils.h" +#include "libnm-platform/nm-platform.h" #include "libnm-udev-aux/nm-udev-utils.h" +#include "nm-act-request.h" +#include "nm-config.h" +#include "nm-dcb.h" +#include "nm-device-ethernet-utils.h" +#include "nm-device-factory.h" +#include "nm-device-private.h" #include "nm-device-veth.h" +#include "nm-manager.h" +#include "ppp/nm-ppp-mgr.h" +#include "settings/nm-settings-connection.h" +#include "settings/nm-settings.h" +#include "supplicant/nm-supplicant-config.h" +#include "supplicant/nm-supplicant-interface.h" +#include "supplicant/nm-supplicant-manager.h" #define _NMLOG_DEVICE_TYPE NMDeviceEthernet #include "nm-device-logging.h" /*****************************************************************************/ -#define PPPOE_RECONNECT_DELAY 7 -#define PPPOE_ENCAP_OVERHEAD 8 /* 2 bytes for PPP, 6 for PPPoE */ +#define PPPOE_RECONNECT_DELAY_MSEC 7000 +#define PPPOE_ENCAP_OVERHEAD 8 /* 2 bytes for PPP, 6 for PPPoE */ #define SUPPLICANT_LNK_TIMEOUT_SEC 15 @@ -91,14 +89,16 @@ typedef struct _NMDeviceEthernetPrivate { guint lnk_timeout_id; bool is_associated : 1; + bool ready : 1; } supplicant; NMActRequestGetSecretsCallId *wired_secrets_id; - /* PPPoE */ - NMPPPManager *ppp_manager; - gint32 last_pppoe_time; - guint pppoe_wait_id; + struct { + NMPppMgr *ppp_mgr; + GSource * wait_source; + gint64 last_pppoe_time_msec; + } ppp_data; /* DCB */ DcbWait dcb_wait; @@ -113,6 +113,8 @@ typedef struct _NMDeviceEthernetPrivate { bool ethtool_prev_set : 1; bool ethtool_prev_autoneg : 1; + bool stage2_ready_dcb : 1; + } NMDeviceEthernetPrivate; NM_GOBJECT_PROPERTIES_DEFINE(NMDeviceEthernet, PROP_SPEED, PROP_S390_SUBCHANNELS, ); @@ -428,6 +430,7 @@ supplicant_interface_release(NMDeviceEthernet *self) nm_clear_g_source(&priv->supplicant.con_timeout_id); nm_clear_g_signal_handler(priv->supplicant.iface, &priv->supplicant.iface_state_id); nm_clear_g_signal_handler(priv->supplicant.iface, &priv->supplicant.auth_state_id); + priv->supplicant.ready = FALSE; if (priv->supplicant.iface) { nm_supplicant_interface_disconnect(priv->supplicant.iface); @@ -468,27 +471,25 @@ wired_auth_cond_fail(NMDeviceEthernet *self, NMDeviceStateReason reason) NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); NMDevice * device = NM_DEVICE(self); - if (wired_auth_is_optional(self)) { - _LOGI( - LOGD_DEVICE | LOGD_ETHER, - "Activation: (ethernet) 802.1X authentication is optional, continuing after a failure"); - if (NM_IN_SET(nm_device_get_state(device), - NM_DEVICE_STATE_CONFIG, - NM_DEVICE_STATE_NEED_AUTH)) - nm_device_activate_schedule_stage3_ip_config_start(device); - - if (!priv->supplicant.auth_state_id) { - priv->supplicant.auth_state_id = - g_signal_connect(priv->supplicant.iface, - "notify::" NM_SUPPLICANT_INTERFACE_AUTH_STATE, - G_CALLBACK(supplicant_auth_state_changed), - self); - } + if (!wired_auth_is_optional(self)) { + supplicant_interface_release(self); + nm_device_state_changed(NM_DEVICE(self), NM_DEVICE_STATE_FAILED, reason); return; } - supplicant_interface_release(self); - nm_device_state_changed(NM_DEVICE(self), NM_DEVICE_STATE_FAILED, reason); + _LOGI(LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) 802.1X authentication is optional, continuing after a failure"); + + if (NM_IN_SET(nm_device_get_state(device), NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_NEED_AUTH)) + nm_device_activate_schedule_stage2_device_config(device, FALSE); + + if (!priv->supplicant.auth_state_id) { + priv->supplicant.auth_state_id = + g_signal_connect(priv->supplicant.iface, + "notify::" NM_SUPPLICANT_INTERFACE_AUTH_STATE, + G_CALLBACK(supplicant_auth_state_changed), + self); + } } static void @@ -644,14 +645,15 @@ supplicant_iface_state_is_completed(NMDeviceEthernet *self, NMSupplicantInterfac if (state == NM_SUPPLICANT_INTERFACE_STATE_COMPLETED) { nm_clear_g_source(&priv->supplicant.lnk_timeout_id); nm_clear_g_source(&priv->supplicant.con_timeout_id); + priv->supplicant.ready = TRUE; /* If this is the initial association during device activation, - * schedule the next activation stage. + * schedule the activation stage again to proceed. */ if (nm_device_get_state(NM_DEVICE(self)) == NM_DEVICE_STATE_CONFIG) { _LOGI(LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) Stage 2 of 5 (Device Configure) successful."); - nm_device_activate_schedule_stage3_ip_config_start(NM_DEVICE(self)); + nm_device_activate_schedule_stage2_device_config(NM_DEVICE(self), FALSE); } return; } @@ -969,11 +971,11 @@ pppoe_reconnect_delay(gpointer user_data) NMDeviceEthernet * self = NM_DEVICE_ETHERNET(user_data); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - priv->pppoe_wait_id = 0; - priv->last_pppoe_time = 0; + nm_clear_g_source_inst(&priv->ppp_data.wait_source); + priv->ppp_data.last_pppoe_time_msec = 0; _LOGI(LOGD_DEVICE, "PPPoE reconnect delay complete, resuming connection..."); nm_device_activate_schedule_stage1_device_prepare(NM_DEVICE(self), FALSE); - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } static NMActStageReturn @@ -1014,21 +1016,24 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) * at least for additional NM_SHUTDOWN_TIMEOUT_MS seconds because * otherwise after restart the device won't work for the first seconds. */ - if (priv->last_pppoe_time != 0) { - gint32 delay = nm_utils_get_monotonic_timestamp_sec() - priv->last_pppoe_time; + if (priv->ppp_data.last_pppoe_time_msec != 0) { + gint64 delay = + nm_utils_get_monotonic_timestamp_msec() - priv->ppp_data.last_pppoe_time_msec; - if (delay < PPPOE_RECONNECT_DELAY + if (delay < PPPOE_RECONNECT_DELAY_MSEC && nm_device_get_applied_setting(device, NM_TYPE_SETTING_PPPOE)) { - if (priv->pppoe_wait_id == 0) { + if (!priv->ppp_data.wait_source) { _LOGI(LOGD_DEVICE, - "delaying PPPoE reconnect for %d seconds to ensure peer is ready...", - delay); - priv->pppoe_wait_id = g_timeout_add_seconds(delay, pppoe_reconnect_delay, self); + "delaying PPPoE reconnect for %d.%03d seconds to ensure peer is ready...", + (int) (delay / 1000), + (int) (delay % 1000)); + priv->ppp_data.wait_source = + nm_g_timeout_add_source(delay, pppoe_reconnect_delay, self); } return NM_ACT_STAGE_RETURN_POSTPONE; } - nm_clear_g_source(&priv->pppoe_wait_id); - priv->last_pppoe_time = 0; + nm_clear_g_source_inst(&priv->ppp_data.wait_source); + priv->ppp_data.last_pppoe_time_msec = 0; } return NM_ACT_STAGE_RETURN_SUCCESS; @@ -1105,105 +1110,79 @@ carrier_changed(NMSupplicantInterface *iface, GParamSpec *pspec, NMDeviceEtherne } /*****************************************************************************/ -/* PPPoE */ static void -ppp_state_changed(NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_data) +_ppp_mgr_cleanup(NMDeviceEthernet *self) { - NMDevice *device = NM_DEVICE(user_data); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - switch (status) { - case NM_PPP_STATUS_DISCONNECT: - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_PPP_DISCONNECT); - break; - case NM_PPP_STATUS_DEAD: - nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED); - break; - default: - break; - } + nm_clear_pointer(&priv->ppp_data.ppp_mgr, nm_ppp_mgr_destroy); } static void -ppp_ifindex_set(NMPPPManager *ppp_manager, int ifindex, const char *iface, gpointer user_data) -{ - NMDevice *device = NM_DEVICE(user_data); - - if (!nm_device_set_ip_ifindex(device, ifindex)) { - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } -} - -static void -ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data) -{ - NMDevice *device = NM_DEVICE(user_data); - - /* Ignore PPP IP4 events that come in after initial configuration */ - if (nm_device_activate_ip4_state_in_conf(device)) - nm_device_activate_schedule_ip_config_result(device, AF_INET, NM_IP_CONFIG_CAST(config)); -} - -static NMActStageReturn -pppoe_stage3_ip4_config_start(NMDeviceEthernet *self, NMDeviceStateReason *out_failure_reason) +_ppp_mgr_stage3_maybe_ready(NMDeviceEthernet *self) { NMDevice * device = NM_DEVICE(self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMSettingPppoe * s_pppoe; - NMActRequest * req; - GError * err = NULL; + int IS_IPv4; - req = nm_device_get_act_request(device); + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + const int addr_family = IS_IPv4 ? AF_INET : AF_INET6; + const NMPppMgrIPData *ip_data; - g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); - - s_pppoe = nm_device_get_applied_setting(device, NM_TYPE_SETTING_PPPOE); - - g_return_val_if_fail(s_pppoe, NM_ACT_STAGE_RETURN_FAILURE); - - priv->ppp_manager = nm_ppp_manager_create(nm_device_get_iface(device), &err); - - if (priv->ppp_manager) { - nm_ppp_manager_set_route_parameters(priv->ppp_manager, - nm_device_get_route_table(device, AF_INET), - nm_device_get_route_metric(device, AF_INET), - nm_device_get_route_table(device, AF_INET6), - nm_device_get_route_metric(device, AF_INET6)); + ip_data = nm_ppp_mgr_get_ip_data(priv->ppp_data.ppp_mgr, addr_family); + if (ip_data->ip_received) + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, ip_data->l3cd); } - if (!priv->ppp_manager - || !nm_ppp_manager_start(priv->ppp_manager, - req, - nm_setting_pppoe_get_username(s_pppoe), - 30, - 0, - &err)) { - _LOGW(LOGD_DEVICE, "PPPoE failed to start: %s", err->message); - g_error_free(err); + if (nm_ppp_mgr_get_state(priv->ppp_data.ppp_mgr) >= NM_PPP_MGR_STATE_HAVE_IP_CONFIG) + nm_device_devip_set_state(device, AF_UNSPEC, NM_DEVICE_IP_STATE_READY, NULL); +} - g_clear_object(&priv->ppp_manager); +static void +_ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, gpointer user_data) +{ + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(user_data); + NMDevice * device = NM_DEVICE(self); + NMDeviceState device_state; - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED); - return NM_ACT_STAGE_RETURN_FAILURE; + if (callback_data->callback_type != NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED) + return; + + device_state = nm_device_get_state(device); + + if (callback_data->data.state >= _NM_PPP_MGR_STATE_FAILED_START) { + if (device_state <= NM_DEVICE_STATE_ACTIVATED) + nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, callback_data->data.reason); + return; } - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, - G_CALLBACK(ppp_state_changed), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IFINDEX_SET, - G_CALLBACK(ppp_ifindex_set), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, - G_CALLBACK(ppp_ip4_config), - self); - return NM_ACT_STAGE_RETURN_POSTPONE; + if (device_state < NM_DEVICE_STATE_IP_CONFIG) { + if (callback_data->data.state >= NM_PPP_MGR_STATE_HAVE_IFINDEX) { + gs_free char *old_name = NULL; + gs_free_error GError *error = NULL; + + if (!nm_device_take_over_link(device, callback_data->data.ifindex, &old_name, &error)) { + _LOGW(LOGD_DEVICE | LOGD_PPP, + "could not take control of link %d: %s", + callback_data->data.ifindex, + error->message); + _ppp_mgr_cleanup(self); + nm_device_state_changed(device, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_CONFIG_FAILED); + return; + } + + if (old_name) + nm_manager_remove_device(NM_MANAGER_GET, old_name, NM_DEVICE_TYPE_PPP); + + nm_device_activate_schedule_stage2_device_config(device, FALSE); + } + return; + } + + _ppp_mgr_stage3_maybe_ready(self); } /*****************************************************************************/ @@ -1351,7 +1330,7 @@ dcb_state(NMDevice *device, gboolean timeout) nm_clear_g_source(&priv->dcb_timeout_id); priv->dcb_handle_carrier_changes = FALSE; priv->dcb_wait = DCB_WAIT_UNKNOWN; - nm_device_activate_schedule_stage3_ip_config_start(device); + nm_device_activate_schedule_stage2_device_config(device, FALSE); } break; default: @@ -1407,31 +1386,98 @@ found: static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceEthernet * self = (NMDeviceEthernet *) device; + NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); + NMConnection * connection; NMSettingConnection * s_con; const char * connection_type; - gboolean do_postpone = FALSE; NMSettingDcb * s_dcb; + NMActRequest * req; - s_con = nm_device_get_applied_setting(device, NM_TYPE_SETTING_CONNECTION); + connection = nm_device_get_applied_connection(device); + g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); + s_con = _nm_connection_get_setting(connection, NM_TYPE_SETTING_CONNECTION); g_return_val_if_fail(s_con, NM_ACT_STAGE_RETURN_FAILURE); nm_clear_g_source(&priv->dcb_timeout_id); priv->dcb_handle_carrier_changes = FALSE; + connection_type = nm_setting_connection_get_connection_type(s_con); + + if (nm_streq(connection_type, NM_SETTING_PPPOE_SETTING_NAME)) { + if (!priv->ppp_data.ppp_mgr) { + gs_free_error GError *error = NULL; + NMSettingPppoe * s_pppoe; + NMSettingPpp * s_ppp; + + s_ppp = nm_device_get_applied_setting(device, NM_TYPE_SETTING_PPP); + if (s_ppp) { + guint32 mtu; + guint32 mru; + guint32 mxu; + + mtu = nm_setting_ppp_get_mtu(s_ppp); + mru = nm_setting_ppp_get_mru(s_ppp); + mxu = MAX(mru, mtu); + if (mxu) { + _LOGD(LOGD_PPP, + "set MTU to %u (PPP interface MRU %u, MTU %u)", + mxu + PPPOE_ENCAP_OVERHEAD, + mru, + mtu); + nm_platform_link_set_mtu(nm_device_get_platform(device), + nm_device_get_ifindex(device), + mxu + PPPOE_ENCAP_OVERHEAD); + } + } + + req = nm_device_get_act_request(device); + g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); + + s_pppoe = _nm_connection_get_setting(connection, NM_TYPE_SETTING_PPPOE); + g_return_val_if_fail(s_pppoe, NM_ACT_STAGE_RETURN_FAILURE); + + priv->ppp_data.ppp_mgr = + nm_ppp_mgr_start(&((const NMPppMgrConfig){ + .netns = nm_device_get_netns(device), + .parent_iface = nm_device_get_iface(device), + .callback = _ppp_mgr_callback, + .user_data = self, + .act_req = req, + .ppp_username = nm_setting_pppoe_get_username(s_pppoe), + .timeout_secs = 30, + .baud_override = 0, + }), + &error); + if (!priv->ppp_data.ppp_mgr) { + _LOGW(LOGD_DEVICE | LOGD_PPP, "PPPoE failed to start: %s", error->message); + *out_failure_reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; + return NM_ACT_STAGE_RETURN_FAILURE; + } + + return NM_ACT_STAGE_RETURN_POSTPONE; + } + + if (nm_ppp_mgr_get_state(priv->ppp_data.ppp_mgr) < NM_PPP_MGR_STATE_HAVE_IFINDEX) + return NM_ACT_STAGE_RETURN_POSTPONE; + } + /* 802.1x has to run before any IP configuration since the 802.1x auth * process opens the port up for normal traffic. */ - connection_type = nm_setting_connection_get_connection_type(s_con); if (nm_streq(connection_type, NM_SETTING_WIRED_SETTING_NAME)) { NMSetting8021x *security; security = nm_device_get_applied_setting(device, NM_TYPE_SETTING_802_1X); if (security) { - /* FIXME: for now 802.1x is mutually exclusive with DCB */ + /* FIXME: we always return from this. stage2 must be re-entrant, and + * process all the necessary steps. Just returning for 8021x is wrong. */ + + if (priv->supplicant.ready) + return NM_ACT_STAGE_RETURN_SUCCESS; + if (!nm_device_has_carrier(NM_DEVICE(self))) { _LOGD(LOGD_DEVICE | LOGD_ETHER, "delay supplicant initialization until carrier goes up"); @@ -1450,7 +1496,7 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) /* DCB and FCoE setup */ s_dcb = nm_device_get_applied_setting(device, NM_TYPE_SETTING_DCB); - if (s_dcb) { + if (!priv->stage2_ready_dcb && s_dcb) { /* lldpad really really wants the carrier to be up */ if (nm_platform_link_is_connected(nm_device_get_platform(device), nm_device_get_ifindex(device))) { @@ -1465,78 +1511,46 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) } priv->dcb_handle_carrier_changes = TRUE; - do_postpone = TRUE; + return NM_ACT_STAGE_RETURN_POSTPONE; } - /* PPPoE setup */ - if (nm_connection_is_type(nm_device_get_applied_connection(device), - NM_SETTING_PPPOE_SETTING_NAME)) { - NMSettingPpp *s_ppp; - - s_ppp = nm_device_get_applied_setting(device, NM_TYPE_SETTING_PPP); - if (s_ppp) { - guint32 mtu; - guint32 mru; - guint32 mxu; - - mtu = nm_setting_ppp_get_mtu(s_ppp); - mru = nm_setting_ppp_get_mru(s_ppp); - mxu = MAX(mru, mtu); - if (mxu) { - _LOGD(LOGD_PPP, - "set MTU to %u (PPP interface MRU %u, MTU %u)", - mxu + PPPOE_ENCAP_OVERHEAD, - mru, - mtu); - nm_platform_link_set_mtu(nm_device_get_platform(device), - nm_device_get_ifindex(device), - mxu + PPPOE_ENCAP_OVERHEAD); - } - } - } - - return do_postpone ? NM_ACT_STAGE_RETURN_POSTPONE : NM_ACT_STAGE_RETURN_SUCCESS; -} - -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) -{ - NMSettingConnection *s_con; - const char * connection_type; - int ifindex; - - ifindex = nm_device_get_ifindex(device); - - if (ifindex <= 0) - return NM_ACT_STAGE_RETURN_FAILURE; - - if (addr_family == AF_INET) { - s_con = nm_device_get_applied_setting(device, NM_TYPE_SETTING_CONNECTION); - - g_return_val_if_fail(s_con, NM_ACT_STAGE_RETURN_FAILURE); - - connection_type = nm_setting_connection_get_connection_type(s_con); - if (!strcmp(connection_type, NM_SETTING_PPPOE_SETTING_NAME)) - return pppoe_stage3_ip4_config_start(NM_DEVICE_ETHERNET(device), out_failure_reason); - } - - return NM_DEVICE_CLASS(nm_device_ethernet_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); + return NM_ACT_STAGE_RETURN_SUCCESS; } static guint32 get_configured_mtu(NMDevice *device, NMDeviceMtuSource *out_source, gboolean *out_force) { + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(device); + /* MTU only set for plain ethernet */ - if (NM_DEVICE_ETHERNET_GET_PRIVATE(device)->ppp_manager) + if (priv->ppp_data.ppp_mgr) return 0; return nm_device_get_configured_mtu_for_wired(device, out_source, out_force); } +static void +act_stage3_ip_config(NMDevice *device, int addr_family) +{ + NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); + NMPppMgrState ppp_state; + + if (!priv->ppp_data.ppp_mgr) + return; + + ppp_state = nm_ppp_mgr_get_state(priv->ppp_data.ppp_mgr); + + nm_assert(NM_IN_SET(ppp_state, NM_PPP_MGR_STATE_HAVE_IFINDEX, NM_PPP_MGR_STATE_HAVE_IP_CONFIG)); + + if (ppp_state < NM_PPP_MGR_STATE_HAVE_IP_CONFIG) { + nm_device_devip_set_state(device, AF_UNSPEC, NM_DEVICE_IP_STATE_PENDING, NULL); + return; + } + + _ppp_mgr_stage3_maybe_ready(self); +} + static void deactivate(NMDevice *device) { @@ -1546,19 +1560,17 @@ deactivate(NMDevice *device) GError * error = NULL; int ifindex; - nm_clear_g_source(&priv->pppoe_wait_id); + nm_clear_g_source_inst(&priv->ppp_data.wait_source); nm_clear_g_signal_handler(self, &priv->carrier_id); - if (priv->ppp_manager) { - nm_ppp_manager_stop(priv->ppp_manager, NULL, NULL, NULL); - g_clear_object(&priv->ppp_manager); - } + _ppp_mgr_cleanup(self); supplicant_interface_release(self); priv->dcb_wait = DCB_WAIT_UNKNOWN; nm_clear_g_source(&priv->dcb_timeout_id); priv->dcb_handle_carrier_changes = FALSE; + priv->stage2_ready_dcb = FALSE; /* Tear down DCB/FCoE if it was enabled */ s_dcb = nm_device_get_applied_setting(device, NM_TYPE_SETTING_DCB); @@ -1571,7 +1583,7 @@ deactivate(NMDevice *device) /* Set last PPPoE connection time */ if (nm_device_get_applied_setting(device, NM_TYPE_SETTING_PPPOE)) - priv->last_pppoe_time = nm_utils_get_monotonic_timestamp_sec(); + priv->ppp_data.last_pppoe_time_msec = nm_utils_get_monotonic_timestamp_msec(); ifindex = nm_device_get_ifindex(device); if (ifindex > 0 && priv->ethtool_prev_set) { @@ -1933,7 +1945,7 @@ dispose(GObject *object) supplicant_interface_release(self); - nm_clear_g_source(&priv->pppoe_wait_id); + nm_clear_g_source_inst(&priv->ppp_data.wait_source); nm_clear_g_source(&priv->dcb_timeout_id); @@ -2032,7 +2044,7 @@ nm_device_ethernet_class_init(NMDeviceEthernetClass *klass) device_class->act_stage1_prepare = act_stage1_prepare; device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE; device_class->act_stage2_config = act_stage2_config; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->act_stage3_ip_config = act_stage3_ip_config; device_class->get_configured_mtu = get_configured_mtu; device_class->deactivate = deactivate; device_class->get_s390_subchannels = get_s390_subchannels; diff --git a/src/core/devices/nm-device-infiniband.c b/src/core/devices/nm-device-infiniband.c index df14dfa838..57b7698cb3 100644 --- a/src/core/devices/nm-device-infiniband.c +++ b/src/core/devices/nm-device-infiniband.c @@ -13,7 +13,6 @@ #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-act-request.h" -#include "nm-ip4-config.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" diff --git a/src/core/devices/nm-device-ip-tunnel.c b/src/core/devices/nm-device-ip-tunnel.c index fe2e20239a..59653a685d 100644 --- a/src/core/devices/nm-device-ip-tunnel.c +++ b/src/core/devices/nm-device-ip-tunnel.c @@ -22,7 +22,6 @@ #include "libnm-core-intern/nm-core-internal.h" #include "settings/nm-settings.h" #include "nm-act-request.h" -#include "nm-ip4-config.h" #define _NMLOG_DEVICE_TYPE NMDeviceIPTunnel #include "nm-device-logging.h" diff --git a/src/core/devices/nm-device-macsec.c b/src/core/devices/nm-device-macsec.c index 51b7225bbf..7fa0779b52 100644 --- a/src/core/devices/nm-device-macsec.c +++ b/src/core/devices/nm-device-macsec.c @@ -409,7 +409,7 @@ supplicant_iface_state_is_completed(NMDeviceMacsec *self, NMSupplicantInterfaceS */ if (nm_device_get_state(NM_DEVICE(self)) == NM_DEVICE_STATE_CONFIG) { _LOGI(LOGD_DEVICE, "Activation: Stage 2 of 5 (Device Configure) successful."); - nm_device_activate_schedule_stage3_ip_config_start(NM_DEVICE(self)); + nm_device_activate_schedule_stage3_ip_config(NM_DEVICE(self), FALSE); } return; } diff --git a/src/core/devices/nm-device-macvlan.c b/src/core/devices/nm-device-macvlan.c index 937ba9e4e4..27be9f0023 100644 --- a/src/core/devices/nm-device-macvlan.c +++ b/src/core/devices/nm-device-macvlan.c @@ -19,7 +19,6 @@ #include "nm-setting-macvlan.h" #include "nm-setting-wired.h" #include "nm-active-connection.h" -#include "nm-ip4-config.h" #include "nm-utils.h" #define _NMLOG_DEVICE_TYPE NMDeviceMacvlan diff --git a/src/core/devices/nm-device-ppp.c b/src/core/devices/nm-device-ppp.c index 04051bece5..855916397b 100644 --- a/src/core/devices/nm-device-ppp.c +++ b/src/core/devices/nm-device-ppp.c @@ -7,16 +7,14 @@ #include "nm-device-ppp.h" -#include "nm-ip4-config.h" +#include "nm-l3-config-data.h" #include "nm-act-request.h" #include "nm-device-factory.h" #include "nm-device-private.h" #include "nm-manager.h" #include "nm-setting-pppoe.h" #include "libnm-platform/nm-platform.h" -#include "ppp/nm-ppp-manager.h" -#include "ppp/nm-ppp-manager-call.h" -#include "ppp/nm-ppp-status.h" +#include "ppp/nm-ppp-mgr.h" #define _NMLOG_DEVICE_TYPE NMDevicePpp #include "nm-device-logging.h" @@ -24,8 +22,7 @@ /*****************************************************************************/ typedef struct _NMDevicePppPrivate { - NMPPPManager *ppp_manager; - NMIP4Config * ip4_config; + NMPppMgr *ppp_mgr; } NMDevicePppPrivate; struct _NMDevicePpp { @@ -42,86 +39,92 @@ G_DEFINE_TYPE(NMDevicePpp, nm_device_ppp, NM_TYPE_DEVICE) #define NM_DEVICE_PPP_GET_PRIVATE(self) \ _NM_GET_PRIVATE(self, NMDevicePpp, NM_IS_DEVICE_PPP, NMDevice) +/*****************************************************************************/ + static NMDeviceCapabilities get_generic_capabilities(NMDevice *device) { return NM_DEVICE_CAP_IS_SOFTWARE; } -static void -ppp_state_changed(NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_data) -{ - NMDevice *device = NM_DEVICE(user_data); +/*****************************************************************************/ - switch (status) { - case NM_PPP_STATUS_DISCONNECT: - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_PPP_DISCONNECT); - break; - case NM_PPP_STATUS_DEAD: - nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED); - break; - default: - break; - } +static void +_ppp_mgr_cleanup(NMDevicePpp *self) +{ + NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); + + nm_clear_pointer(&priv->ppp_mgr, nm_ppp_mgr_destroy); } static void -ppp_ifindex_set(NMPPPManager *ppp_manager, int ifindex, const char *iface, gpointer user_data) -{ - NMDevice * device = NM_DEVICE(user_data); - NMDevicePpp * self = NM_DEVICE_PPP(device); - gs_free char *old_name = NULL; - gs_free_error GError *error = NULL; - - if (!nm_device_take_over_link(device, ifindex, &old_name, &error)) { - _LOGW(LOGD_DEVICE | LOGD_PPP, - "could not take control of link %d: %s", - ifindex, - error->message); - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - return; - } - - if (old_name) - nm_manager_remove_device(NM_MANAGER_GET, old_name, NM_DEVICE_TYPE_PPP); - - nm_device_activate_schedule_stage3_ip_config_start(device); -} - -static void -_ppp_ip4_config_handle(NMDevicePpp *self) +_ppp_mgr_stage3_maybe_ready(NMDevicePpp *self) { NMDevice * device = NM_DEVICE(self); NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); + int IS_IPv4; - if (!priv->ip4_config) - return; + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + const int addr_family = IS_IPv4 ? AF_INET : AF_INET6; + const NMPppMgrIPData *ip_data; - if (nm_device_get_state(device) == NM_DEVICE_STATE_IP_CONFIG - && nm_device_activate_ip4_state_in_conf(device)) { - nm_device_activate_schedule_ip_config_result( - device, - AF_INET, - NM_IP_CONFIG_CAST(g_steal_pointer(&priv->ip4_config))); - return; + ip_data = nm_ppp_mgr_get_ip_data(priv->ppp_mgr, addr_family); + if (ip_data->ip_received) + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, ip_data->l3cd); } + + if (nm_ppp_mgr_get_state(priv->ppp_mgr) >= NM_PPP_MGR_STATE_HAVE_IP_CONFIG) + nm_device_devip_set_state(device, AF_UNSPEC, NM_DEVICE_IP_STATE_READY, NULL); } static void -ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data) +_ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, gpointer user_data) { - NMDevicePpp * self = NM_DEVICE_PPP(user_data); - NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); + NMDevicePpp * self = NM_DEVICE_PPP(user_data); + NMDevice * device = NM_DEVICE(self); + NMDeviceState device_state; - _LOGT(LOGD_DEVICE | LOGD_PPP, "received IPv4 config from pppd"); - nm_g_object_ref_set(&priv->ip4_config, config); - _ppp_ip4_config_handle(self); + if (callback_data->callback_type != NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED) + return; + + device_state = nm_device_get_state(device); + + if (callback_data->data.state >= _NM_PPP_MGR_STATE_FAILED_START) { + if (device_state <= NM_DEVICE_STATE_ACTIVATED) + nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, callback_data->data.reason); + return; + } + + if (device_state < NM_DEVICE_STATE_IP_CONFIG) { + if (callback_data->data.state >= NM_PPP_MGR_STATE_HAVE_IFINDEX) { + gs_free char *old_name = NULL; + gs_free_error GError *error = NULL; + + if (!nm_device_take_over_link(device, callback_data->data.ifindex, &old_name, &error)) { + _LOGW(LOGD_DEVICE | LOGD_PPP, + "could not take control of link %d: %s", + callback_data->data.ifindex, + error->message); + _ppp_mgr_cleanup(self); + nm_device_state_changed(device, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_CONFIG_FAILED); + return; + } + + if (old_name) + nm_manager_remove_device(NM_MANAGER_GET, old_name, NM_DEVICE_TYPE_PPP); + + nm_device_activate_schedule_stage2_device_config(device, FALSE); + } + return; + } + + _ppp_mgr_stage3_maybe_ready(self); } +/*****************************************************************************/ + static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { @@ -149,85 +152,80 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); NMSettingPppoe * s_pppoe; NMActRequest * req; - GError * error = NULL; - req = nm_device_get_act_request(device); - g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); + if (!priv->ppp_mgr) { + gs_free_error GError *error = NULL; - s_pppoe = nm_device_get_applied_setting(device, NM_TYPE_SETTING_PPPOE); - g_return_val_if_fail(s_pppoe, NM_ACT_STAGE_RETURN_FAILURE); + req = nm_device_get_act_request(device); + g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); - g_clear_object(&priv->ip4_config); + s_pppoe = nm_device_get_applied_setting(device, NM_TYPE_SETTING_PPPOE); + g_return_val_if_fail(s_pppoe, NM_ACT_STAGE_RETURN_FAILURE); - priv->ppp_manager = nm_ppp_manager_create(nm_setting_pppoe_get_parent(s_pppoe), &error); + priv->ppp_mgr = nm_ppp_mgr_start(&((const NMPppMgrConfig){ + .netns = nm_device_get_netns(device), + .parent_iface = nm_setting_pppoe_get_parent(s_pppoe), + .callback = _ppp_mgr_callback, + .user_data = self, + .act_req = req, + .ppp_username = nm_setting_pppoe_get_username(s_pppoe), + .timeout_secs = 30, + .baud_override = 0, + }), + &error); + if (!priv->ppp_mgr) { + _LOGW(LOGD_DEVICE | LOGD_PPP, "PPPoE failed to start: %s", error->message); + *out_failure_reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; + return NM_ACT_STAGE_RETURN_FAILURE; + } - if (priv->ppp_manager) { - nm_ppp_manager_set_route_parameters(priv->ppp_manager, - nm_device_get_route_table(device, AF_INET), - nm_device_get_route_metric(device, AF_INET), - nm_device_get_route_table(device, AF_INET6), - nm_device_get_route_metric(device, AF_INET6)); - } - - if (!priv->ppp_manager - || !nm_ppp_manager_start(priv->ppp_manager, - req, - nm_setting_pppoe_get_username(s_pppoe), - 30, - 0, - &error)) { - _LOGW(LOGD_DEVICE | LOGD_PPP, "PPPoE failed to start: %s", error->message); - g_error_free(error); - - g_clear_object(&priv->ppp_manager); - - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, - G_CALLBACK(ppp_state_changed), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IFINDEX_SET, - G_CALLBACK(ppp_ifindex_set), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, - G_CALLBACK(ppp_ip4_config), - self); - return NM_ACT_STAGE_RETURN_POSTPONE; -} - -static gboolean -_schedule_ip_config_result(gpointer user_data) -{ - gs_unref_object NMDevicePpp *self = user_data; - - _ppp_ip4_config_handle(self); - return G_SOURCE_REMOVE; -} - -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) -{ - if (addr_family == AF_INET) { - NMDevicePpp * self = NM_DEVICE_PPP(device); - NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); - - if (priv->ip4_config) - nm_g_idle_add(_schedule_ip_config_result, g_object_ref(self)); - - /* Wait IPCP termination */ return NM_ACT_STAGE_RETURN_POSTPONE; } - return NM_DEVICE_CLASS(nm_device_ppp_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); + if (nm_ppp_mgr_get_state(priv->ppp_mgr) < NM_PPP_MGR_STATE_HAVE_IFINDEX) + return NM_ACT_STAGE_RETURN_POSTPONE; + + return NM_ACT_STAGE_RETURN_SUCCESS; +} + +static void +act_stage3_ip_config(NMDevice *device, int addr_family) +{ + NMDevicePpp * self = NM_DEVICE_PPP(device); + NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); + NMPppMgrState ppp_state; + + if (!priv->ppp_mgr) { + nm_assert_not_reached(); + return; + } + + ppp_state = nm_ppp_mgr_get_state(priv->ppp_mgr); + + nm_assert(NM_IN_SET(ppp_state, NM_PPP_MGR_STATE_HAVE_IFINDEX, NM_PPP_MGR_STATE_HAVE_IP_CONFIG)); + + if (ppp_state < NM_PPP_MGR_STATE_HAVE_IP_CONFIG) { + nm_device_devip_set_state(device, AF_UNSPEC, NM_DEVICE_IP_STATE_PENDING, NULL); + return; + } + + _ppp_mgr_stage3_maybe_ready(self); +} + +static const char * +get_ip_method_auto(NMDevice *device, int addr_family) +{ + if (NM_IS_IPv4(addr_family)) { + /* We cannot do DHCPv4 on a PPP link, instead we get "auto" IP addresses + * by pppd. Return "manual" here, which has the suitable effect to a + * (zero) manual addresses in addition. */ + return NM_SETTING_IP6_CONFIG_METHOD_MANUAL; + } + + /* We can do autoconf6 on an PPP link, but we should already get an IPv6 + * address from pppd. Use that instead. We however do want to generate our + * (own) IPv6 link local address, so return "link-local". */ + return NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL; } static gboolean @@ -260,17 +258,13 @@ create_and_realize(NMDevice * device, static void deactivate(NMDevice *device) { - NMDevicePpp * self = NM_DEVICE_PPP(device); - NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); + NMDevicePpp *self = NM_DEVICE_PPP(device); - if (priv->ppp_manager) { - nm_ppp_manager_stop(priv->ppp_manager, NULL, NULL, NULL); - g_clear_object(&priv->ppp_manager); - } - - g_clear_object(&priv->ip4_config); + _ppp_mgr_cleanup(self); } +/*****************************************************************************/ + static void nm_device_ppp_init(NMDevicePpp *self) {} @@ -278,10 +272,9 @@ nm_device_ppp_init(NMDevicePpp *self) static void dispose(GObject *object) { - NMDevicePpp * self = NM_DEVICE_PPP(object); - NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); + NMDevicePpp *self = NM_DEVICE_PPP(object); - g_clear_object(&priv->ip4_config); + _ppp_mgr_cleanup(self); G_OBJECT_CLASS(nm_device_ppp_parent_class)->dispose(object); } @@ -306,7 +299,8 @@ nm_device_ppp_class_init(NMDevicePppClass *klass) device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_PPP); device_class->act_stage2_config = act_stage2_config; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->get_ip_method_auto = get_ip_method_auto; device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->deactivate = deactivate; diff --git a/src/core/devices/nm-device-private.h b/src/core/devices/nm-device-private.h index b55e8b4380..ae89848307 100644 --- a/src/core/devices/nm-device-private.h +++ b/src/core/devices/nm-device-private.h @@ -8,6 +8,7 @@ #define __NETWORKMANAGER_DEVICE_PRIVATE_H__ #include "nm-device.h" +#include "nm-l3-config-data.h" /* This file should only be used by subclasses of NMDevice */ @@ -21,12 +22,6 @@ enum NMActStageReturn { NM_ACT_STAGE_RETURN_FAILURE = 0, /* Hard failure of activation */ NM_ACT_STAGE_RETURN_SUCCESS, /* Activation stage done */ NM_ACT_STAGE_RETURN_POSTPONE, /* Long-running operation in progress */ - NM_ACT_STAGE_RETURN_IP_WAIT, /* IP config stage is waiting (state IP_WAIT) */ - NM_ACT_STAGE_RETURN_IP_DONE, /* IP config stage is done (state IP_DONE), - * For the ip-config stage, this is similar to - * NM_ACT_STAGE_RETURN_SUCCESS, except that no - * IP config should be committed. */ - NM_ACT_STAGE_RETURN_IP_FAIL, /* IP config stage failed (state IP_FAIL), activation may proceed */ }; #define NM_DEVICE_CAP_NONSTANDARD_CARRIER 0x80000000 @@ -34,8 +29,6 @@ enum NMActStageReturn { #define NM_DEVICE_CAP_INTERNAL_MASK 0xc0000000 -void nm_device_arp_announce(NMDevice *self); - NMSettings *nm_device_get_settings(NMDevice *self); NMManager *nm_device_get_manager(NMDevice *self); @@ -44,10 +37,6 @@ gboolean nm_device_set_ip_ifindex(NMDevice *self, int ifindex); gboolean nm_device_set_ip_iface(NMDevice *self, const char *iface); -void nm_device_activate_schedule_stage3_ip_config_start(NMDevice *device); - -gboolean nm_device_activate_stage3_ip_start(NMDevice *self, int addr_family); - gboolean nm_device_bring_up(NMDevice *self, gboolean wait, gboolean *no_firmware); void nm_device_take_down(NMDevice *self, gboolean block); @@ -65,52 +54,7 @@ void nm_device_set_firmware_missing(NMDevice *self, gboolean missing); void nm_device_activate_schedule_stage1_device_prepare(NMDevice *device, gboolean do_sync); void nm_device_activate_schedule_stage2_device_config(NMDevice *device, gboolean do_sync); - -void -nm_device_activate_schedule_ip_config_result(NMDevice *device, int addr_family, NMIPConfig *config); - -void nm_device_activate_schedule_ip_config_timeout(NMDevice *device, int addr_family); - -NMDeviceIPState nm_device_activate_get_ip_state(NMDevice *self, int addr_family); - -static inline gboolean -nm_device_activate_ip4_state_in_conf(NMDevice *self) -{ - return nm_device_activate_get_ip_state(self, AF_INET) == NM_DEVICE_IP_STATE_CONF; -} - -static inline gboolean -nm_device_activate_ip4_state_in_wait(NMDevice *self) -{ - return nm_device_activate_get_ip_state(self, AF_INET) == NM_DEVICE_IP_STATE_WAIT; -} - -static inline gboolean -nm_device_activate_ip4_state_done(NMDevice *self) -{ - return nm_device_activate_get_ip_state(self, AF_INET) == NM_DEVICE_IP_STATE_DONE; -} - -static inline gboolean -nm_device_activate_ip6_state_in_conf(NMDevice *self) -{ - return nm_device_activate_get_ip_state(self, AF_INET6) == NM_DEVICE_IP_STATE_CONF; -} - -static inline gboolean -nm_device_activate_ip6_state_in_wait(NMDevice *self) -{ - return nm_device_activate_get_ip_state(self, AF_INET6) == NM_DEVICE_IP_STATE_WAIT; -} - -static inline gboolean -nm_device_activate_ip6_state_done(NMDevice *self) -{ - return nm_device_activate_get_ip_state(self, AF_INET6) == NM_DEVICE_IP_STATE_DONE; -} - -gboolean nm_device_dhcp4_renew(NMDevice *device, gboolean release); -gboolean nm_device_dhcp6_renew(NMDevice *device, gboolean release); +void nm_device_activate_schedule_stage3_ip_config(NMDevice *device, gboolean do_sync); void nm_device_recheck_available_connections(NMDevice *device); @@ -126,25 +70,54 @@ void nm_device_queue_recheck_available(NMDevice * device, NMDeviceStateReason available_reason, NMDeviceStateReason unavailable_reason); -void nm_device_set_dev2_ip_config(NMDevice *device, int addr_family, NMIPConfig *config); - gboolean nm_device_hw_addr_is_explict(NMDevice *device); -void nm_device_ip_method_failed(NMDevice *self, int addr_family, NMDeviceStateReason reason); +NMDeviceIPState nm_device_devip_get_state(NMDevice *self, int addr_family); + +void nm_device_devip_set_state_full(NMDevice * self, + int addr_family, + NMDeviceIPState ip_state, + const NML3ConfigData *l3cd, + NMDeviceStateReason failed_reason); + +static inline void +nm_device_devip_set_state(NMDevice * self, + int addr_family, + NMDeviceIPState ip_state, + const NML3ConfigData *l3cd) +{ + nm_assert(NM_IS_DEVICE(self)); + nm_assert_addr_family_or_unspec(addr_family); + nm_assert(!l3cd || NM_IS_L3_CONFIG_DATA(l3cd)); + nm_assert(NM_IN_SET(ip_state, NM_DEVICE_IP_STATE_PENDING, NM_DEVICE_IP_STATE_READY)); + + nm_device_devip_set_state_full(self, addr_family, ip_state, l3cd, NM_DEVICE_STATE_REASON_NONE); +} + +static inline void +nm_device_devip_set_failed(NMDevice *self, int addr_family, NMDeviceStateReason reason) +{ + nm_assert(NM_IS_DEVICE(self)); + nm_assert_addr_family_or_unspec(addr_family); + nm_assert(reason != NM_DEVICE_STATE_REASON_NONE); + + nm_device_devip_set_state_full(self, addr_family, NM_DEVICE_IP_STATE_FAILED, NULL, reason); +} gboolean nm_device_sysctl_ip_conf_set(NMDevice * self, int addr_family, const char *property, const char *value); -NMIP4Config *nm_device_ip4_config_new(NMDevice *self); - -NMIP6Config *nm_device_ip6_config_new(NMDevice *self); - -NMIPConfig *nm_device_ip_config_new(NMDevice *self, int addr_family); - NML3ConfigData *nm_device_create_l3_config_data(NMDevice *self, NMIPConfigSource source); +const NML3ConfigData *nm_device_create_l3_config_data_from_connection(NMDevice * self, + NMConnection *connection); + +void nm_device_ip_method_dhcp4_start(NMDevice *self); + +void nm_device_ip_method_autoconf6_start(NMDevice *self); + /*****************************************************************************/ gint64 nm_device_get_configured_mtu_from_connection_default(NMDevice * self, diff --git a/src/core/devices/nm-device-tun.c b/src/core/devices/nm-device-tun.c index 0ab08f65b5..1f6a427636 100644 --- a/src/core/devices/nm-device-tun.c +++ b/src/core/devices/nm-device-tun.c @@ -13,7 +13,6 @@ #include "nm-act-request.h" #include "nm-device-private.h" -#include "nm-ip4-config.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-tun.h" diff --git a/src/core/devices/nm-device-utils.c b/src/core/devices/nm-device-utils.c index 2a6ab04e24..9e56d0b2b9 100644 --- a/src/core/devices/nm-device-utils.c +++ b/src/core/devices/nm-device-utils.c @@ -151,10 +151,9 @@ NM_UTILS_LOOKUP_STR_DEFINE(nm_device_ip_state_to_string, NMDeviceIPState, NM_UTILS_LOOKUP_DEFAULT_WARN("unknown"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_NONE, "none"), - NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_WAIT, "wait"), - NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_CONF, "conf"), - NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_DONE, "done"), - NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_FAIL, "fail"), ); + NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_PENDING, "pending"), + NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_READY, "done"), + NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_FAILED, "fail"), ); /*****************************************************************************/ diff --git a/src/core/devices/nm-device-utils.h b/src/core/devices/nm-device-utils.h index 7200b0ea2c..759e610568 100644 --- a/src/core/devices/nm-device-utils.h +++ b/src/core/devices/nm-device-utils.h @@ -73,20 +73,17 @@ const char *nm_device_sys_iface_state_to_string(NMDeviceSysIfaceState sys_iface_ /*****************************************************************************/ -typedef enum { +typedef enum _nm_packed { NM_DEVICE_IP_STATE_NONE, - NM_DEVICE_IP_STATE_WAIT, - NM_DEVICE_IP_STATE_CONF, - NM_DEVICE_IP_STATE_DONE, - NM_DEVICE_IP_STATE_FAIL, + NM_DEVICE_IP_STATE_PENDING, + NM_DEVICE_IP_STATE_READY, + NM_DEVICE_IP_STATE_FAILED, } NMDeviceIPState; const char *nm_device_ip_state_to_string(NMDeviceIPState ip_state); /*****************************************************************************/ -/*****************************************************************************/ - void nm_device_resolve_address(int addr_family, gconstpointer address, GCancellable * cancellable, diff --git a/src/core/devices/nm-device-vlan.c b/src/core/devices/nm-device-vlan.c index d1e5741170..c1902d5eea 100644 --- a/src/core/devices/nm-device-vlan.c +++ b/src/core/devices/nm-device-vlan.c @@ -15,7 +15,6 @@ #include "nm-device-private.h" #include "settings/nm-settings.h" #include "nm-act-request.h" -#include "nm-ip4-config.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-manager.h" @@ -85,11 +84,11 @@ parent_mtu_maybe_changed(NMDevice *parent, GParamSpec *pspec, gpointer user_data static void parent_hwaddr_maybe_changed(NMDevice *parent, GParamSpec *pspec, gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); - NMDeviceVlan * self = NM_DEVICE_VLAN(device); - NMConnection * connection; - const char * new_mac, *old_mac; - NMSettingIPConfig *s_ip6; + NMDevice * device = NM_DEVICE(user_data); + NMDeviceVlan *self = NM_DEVICE_VLAN(device); + NMConnection *connection; + const char * old_mac; + const char * new_mac; /* Never touch assumed devices */ if (nm_device_sys_iface_state_is_external_or_assume(device)) @@ -113,13 +112,10 @@ parent_hwaddr_maybe_changed(NMDevice *parent, GParamSpec *pspec, gpointer user_d NM_PRINT_FMT_QUOTE_STRING(new_mac)); if (new_mac) { nm_device_hw_addr_set(device, new_mac, "vlan-parent", TRUE); - nm_device_arp_announce(device); /* When changing the hw address the interface is taken down, * removing the IPv6 configuration; reapply it. */ - s_ip6 = nm_connection_get_setting_ip6_config(connection); - if (s_ip6) - nm_device_reactivate_ip_config(device, AF_INET6, s_ip6, s_ip6); + nm_device_l3cfg_commit(device, NM_L3_CFG_COMMIT_TYPE_REAPPLY, FALSE); } } diff --git a/src/core/devices/nm-device-vxlan.c b/src/core/devices/nm-device-vxlan.c index fcd6950b88..329cc3febb 100644 --- a/src/core/devices/nm-device-vxlan.c +++ b/src/core/devices/nm-device-vxlan.c @@ -16,7 +16,6 @@ #include "nm-setting-wired.h" #include "settings/nm-settings.h" #include "nm-act-request.h" -#include "nm-ip4-config.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" diff --git a/src/core/devices/nm-device-wireguard.c b/src/core/devices/nm-device-wireguard.c index f129478f7f..de715264ce 100644 --- a/src/core/devices/nm-device-wireguard.c +++ b/src/core/devices/nm-device-wireguard.c @@ -12,6 +12,7 @@ #include "nm-setting-wireguard.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" +#include "nm-l3-config-data.h" #include "libnm-core-intern/nm-core-internal.h" #include "libnm-glib-aux/nm-secret-utils.h" #include "nm-device-private.h" @@ -1625,19 +1626,19 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) return ret; } -static NMIPConfig * +static const NML3ConfigData * _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family) { - NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - gs_unref_object NMIPConfig *ip_config = NULL; - NMConnection * connection; - NMSettingWireGuard * s_wg; - guint n_peers; - guint i; - int ip_ifindex; - guint32 route_metric; - guint32 route_table_coerced; - gboolean auto_default_route_enabled; + NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + NMConnection * connection; + NMSettingWireGuard * s_wg; + guint n_peers; + guint i; + int ip_ifindex; + guint32 route_metric; + guint32 route_table_coerced; + gboolean auto_default_route_enabled; _auto_default_route_init(self); @@ -1715,11 +1716,10 @@ _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family) continue; } - if (!ip_config) { - ip_config = nm_device_ip_config_new(NM_DEVICE(self), addr_family); - nm_ip_config_set_config_flags(ip_config, - NM_IP_CONFIG_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES, - 0); + if (!l3cd) { + l3cd = nm_device_create_l3_config_data(NM_DEVICE(self), NM_IP_CONFIG_SOURCE_USER); + nm_l3_config_data_set_flags(l3cd, + NM_L3_CONFIG_DAT_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES); } nm_utils_ipx_address_clear_host_address(addr_family, &addrbin, NULL, prefix); @@ -1754,27 +1754,23 @@ _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family) }; } - nm_ip_config_add_route(ip_config, &rt.rx, NULL); + nm_l3_config_data_add_route(l3cd, addr_family, NULL, &rt.rx); } } - return g_steal_pointer(&ip_config); + if (!l3cd) + return NULL; + + return nm_l3_config_data_seal(g_steal_pointer(&l3cd)); } -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) +static void +act_stage3_ip_config(NMDevice *device, int addr_family) { - gs_unref_object NMIPConfig *ip_config = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - ip_config = _get_dev2_ip_config(NM_DEVICE_WIREGUARD(device), addr_family); - - nm_device_set_dev2_ip_config(device, addr_family, ip_config); - - return NM_DEVICE_CLASS(nm_device_wireguard_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); + l3cd = _get_dev2_ip_config(NM_DEVICE_WIREGUARD(device), addr_family); + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, l3cd); } static guint32 @@ -1864,11 +1860,9 @@ can_reapply_change(NMDevice * device, static void reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_new) { - NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(device); - NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - gs_unref_object NMIPConfig *ip4_config = NULL; - gs_unref_object NMIPConfig *ip6_config = NULL; - NMDeviceState state = nm_device_get_state(device); + NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(device); + NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); + NMDeviceState state = nm_device_get_state(device); NM_DEVICE_CLASS(nm_device_wireguard_parent_class)->reapply_connection(device, con_old, con_new); @@ -1878,11 +1872,14 @@ reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_ne } if (state >= NM_DEVICE_STATE_IP_CONFIG) { - ip4_config = _get_dev2_ip_config(self, AF_INET); - ip6_config = _get_dev2_ip_config(self, AF_INET6); + nm_auto_unref_l3cd const NML3ConfigData *l3cd_4 = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd_6 = NULL; - nm_device_set_dev2_ip_config(device, AF_INET, ip4_config); - nm_device_set_dev2_ip_config(device, AF_INET6, ip6_config); + l3cd_4 = _get_dev2_ip_config(self, AF_INET); + l3cd_6 = _get_dev2_ip_config(self, AF_INET6); + + nm_device_devip_set_state(device, AF_INET, NM_DEVICE_IP_STATE_READY, l3cd_4); + nm_device_devip_set_state(device, AF_INET6, NM_DEVICE_IP_STATE_READY, l3cd_6); } } @@ -2025,7 +2022,7 @@ nm_device_wireguard_class_init(NMDeviceWireGuardClass *klass) device_class->create_and_realize = create_and_realize; device_class->act_stage2_config = act_stage2_config; device_class->act_stage2_config_also_for_external_or_assume = TRUE; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->act_stage3_ip_config = act_stage3_ip_config; device_class->get_generic_capabilities = get_generic_capabilities; device_class->link_changed = link_changed; device_class->update_connection = update_connection; diff --git a/src/core/devices/nm-device-wpan.c b/src/core/devices/nm-device-wpan.c index 9bc43a850d..ed5bcbde4d 100644 --- a/src/core/devices/nm-device-wpan.c +++ b/src/core/devices/nm-device-wpan.c @@ -14,7 +14,6 @@ #include "nm-act-request.h" #include "nm-device-private.h" -#include "nm-ip4-config.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-wpan.h" diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index fc11e458ed..627066d94a 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -34,6 +34,8 @@ #include "nm-device-private.h" #include "nm-l3cfg.h" #include "nm-l3-config-data.h" +#include "nm-l3-ipv4ll.h" +#include "nm-l3-ipv6ll.h" #include "NetworkManagerUtils.h" #include "nm-manager.h" #include "libnm-platform/nm-platform.h" @@ -42,14 +44,13 @@ #include "libnm-platform/nmp-rules-manager.h" #include "ndisc/nm-ndisc.h" #include "ndisc/nm-lndp-ndisc.h" + #include "dhcp/nm-dhcp-manager.h" #include "dhcp/nm-dhcp-utils.h" #include "nm-act-request.h" -#include "nm-proxy-config.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" #include "nm-pacrunner-manager.h" #include "dnsmasq/nm-dnsmasq-manager.h" +#include "nm-ip-config.h" #include "nm-dhcp-config.h" #include "nm-rfkill-manager.h" #include "nm-firewall-utils.h" @@ -66,7 +67,6 @@ #include "nm-config.h" #include "c-list/src/c-list.h" #include "dns/nm-dns-manager.h" -#include "nm-acd-manager.h" #include "libnm-core-intern/nm-core-internal.h" #include "libnm-systemd-core/nm-sd.h" #include "nm-lldp-listener.h" @@ -86,19 +86,7 @@ #define DEFAULT_AUTOCONNECT TRUE -static guint32 -dhcp_grace_period_from_timeout(guint32 timeout) -{ -#define DHCP_GRACE_PERIOD_MULTIPLIER 2U - - nm_assert(timeout > 0); - nm_assert(timeout < G_MAXINT32); - - if (timeout < G_MAXUINT32 / DHCP_GRACE_PERIOD_MULTIPLIER) - return timeout * DHCP_GRACE_PERIOD_MULTIPLIER; - - return G_MAXUINT32; -} +#define GRACE_PERIOD_MULTIPLIER 2U #define CARRIER_WAIT_TIME_MS 6000 #define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000 @@ -117,6 +105,13 @@ typedef enum { CLEANUP_TYPE_DECONFIGURE, } CleanupType; +typedef enum _nm_packed { + ADDR_METHOD_STATE_DISABLED, + ADDR_METHOD_STATE_PENDING, + ADDR_METHOD_STATE_GOOD, + ADDR_METHOD_STATE_FAILED, +} AddrMethodState; + typedef struct { CList lst_slave; NMDevice *slave; @@ -139,28 +134,61 @@ typedef struct { NMOptionBool autoprobe; } SriovOp; -typedef void (*AcdCallback)(NMDevice *, NMIP4Config **, gboolean); - typedef enum { /* The various NML3ConfigData types that we track explicitly. Note that * their relative order matters: higher numbers in this enum means more * important (and during merge overwrites other settings). */ + L3_CONFIG_DATA_TYPE_LL_4, + L3_CONFIG_DATA_TYPE_LL_6, + +#define L3_CONFIG_DATA_TYPE_LL_X(IS_IPv4) \ + ((IS_IPv4) ? L3_CONFIG_DATA_TYPE_LL_4 : L3_CONFIG_DATA_TYPE_LL_6) + L3_CONFIG_DATA_TYPE_AC_6, + L3_CONFIG_DATA_TYPE_PD_6, + L3_CONFIG_DATA_TYPE_DHCP_4, L3_CONFIG_DATA_TYPE_DHCP_6, - L3_CONFIG_DATA_TYPE_DEV_4, - L3_CONFIG_DATA_TYPE_DEV_6, - L3_CONFIG_DATA_TYPE_SETTING, + +#define L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4) \ + ((IS_IPv4) ? L3_CONFIG_DATA_TYPE_DHCP_4 : L3_CONFIG_DATA_TYPE_DHCP_6) + + L3_CONFIG_DATA_TYPE_SHARED_4, + L3_CONFIG_DATA_TYPE_DEVIP_UNSPEC, + L3_CONFIG_DATA_TYPE_DEVIP_4, + L3_CONFIG_DATA_TYPE_DEVIP_6, + +#define L3_CONFIG_DATA_TYPE_DEVIP(addr_family) \ + ({ \ + L3ConfigDataType _t; \ + \ + switch (addr_family) { \ + case AF_INET: \ + _t = L3_CONFIG_DATA_TYPE_DEVIP_4; \ + break; \ + case AF_INET6: \ + _t = L3_CONFIG_DATA_TYPE_DEVIP_6; \ + break; \ + default: \ + nm_assert_not_reached(); \ + /* fall-through */ \ + case AF_UNSPEC: \ + _t = L3_CONFIG_DATA_TYPE_DEVIP_UNSPEC; \ + break; \ + } \ + \ + _t; \ + }) + + L3_CONFIG_DATA_TYPE_MANUALIP, + _L3_CONFIG_DATA_TYPE_NUM, _L3_CONFIG_DATA_TYPE_NONE, + _L3_CONFIG_DATA_TYPE_ACD_ONLY, } L3ConfigDataType; -typedef struct { - AcdCallback callback; - NMDevice * device; - NMIP4Config **configs; -} AcdData; +G_STATIC_ASSERT(NM_L3CFG_CONFIG_PRIORITY_IPV4LL == L3_CONFIG_DATA_TYPE_LL_4); typedef enum { HW_ADDR_TYPE_UNSET = 0, @@ -177,19 +205,74 @@ typedef enum { } FirewallState; typedef struct { - NMIPConfig *orig; /* the original configuration applied to the device */ - NMIPConfig *current; /* configuration after external changes. NULL means - * that the original configuration didn't change. */ -} AppliedConfig; + NMIPConfig *ip_config; +} L3IPData; typedef struct { - NMDhcpClient *client; - NMDhcpConfig *config; - gulong notify_sigid; - guint grace_id; - bool grace_pending : 1; - bool was_active : 1; -} DhcpData; + GSource *check_async_source; + GSource *req_timeout_source; + union { + const NMDeviceIPState state; + NMDeviceIPState state_; + }; + bool wait_for_carrier : 1; + bool wait_for_ports : 1; + bool is_disabled : 1; + bool is_ignore : 1; + bool do_reapply : 1; +} IPStateData; + +typedef struct { + NMDhcpClient * client; + NMDhcpConfig * config; + gulong notify_sigid; + NMDeviceIPState state; + union { + struct { + } v4; + struct { + guint needed_prefixes; + NMNDiscDHCPLevel mode; + } v6; + }; +} IPDhcpStateData; + +typedef struct { + NMDeviceIPState state; + NMDeviceStateReason failed_reason; +} IPDevStateData; + +typedef struct { + NMDeviceIPState state; + union { + struct { + NMDnsMasqManager * dnsmasq_manager; + NMNetnsSharedIPHandle *shared_ip_handle; + NMFirewallConfig * firewall_config; + gulong dnsmasq_state_id; + const NML3ConfigData * l3cd; + } v4; + struct { + } v6; + }; +} IPSharedStateData; + +typedef struct { + NMDeviceIPState state; + union { + struct { + NML3IPv4LL * ipv4ll; + NML3IPv4LLRegistration *ipv4ll_registation; + GSource * timeout_source; + } v4; + struct { + NML3IPv6LL * ipv6ll; + GSource * retry_source; + NML3IPv6LLState llstate; + struct in6_addr lladdr; + } v6; + }; +} IPLLStateData; struct _NMDeviceConnectivityHandle { CList concheck_lst; @@ -234,8 +317,7 @@ typedef struct { enum { STATE_CHANGED, AUTOCONNECT_ALLOWED, - IP4_CONFIG_CHANGED, - IP6_CONFIG_CHANGED, + L3CD_CHANGED, IP6_PREFIX_DELEGATED, IP6_SUBNET_NEEDED, REMOVED, @@ -260,6 +342,9 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDevice, PROP_IP4_ADDRESS, PROP_IP4_CONFIG, PROP_DHCP4_CONFIG, + +#define PROP_DHCPX_CONFIG(IS_IPv4) ((IS_IPv4) ? PROP_DHCP4_CONFIG : PROP_DHCP6_CONFIG) + PROP_IP6_CONFIG, PROP_DHCP6_CONFIG, PROP_STATE, @@ -294,8 +379,6 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDevice, PROP_PORTS, ); typedef struct _NMDevicePrivate { - bool in_state_changed; - guint device_link_changed_id; guint device_ip_link_changed_id; @@ -309,22 +392,12 @@ typedef struct _NMDevicePrivate { NMDeviceStateReason reason; } queued_state; - union { - struct { - guint queued_ip_config_id_6; - guint queued_ip_config_id_4; - }; - guint queued_ip_config_id_x[2]; - }; - struct { const char **arr; guint len; guint alloc; } pending_actions; - GSList *dad6_failed_addrs; - NMDBusTrackObjPath parent_device; char *udi; @@ -339,16 +412,34 @@ typedef struct _NMDevicePrivate { char * ip_iface_; }; + union { + NML3Cfg *const l3cfg; + NML3Cfg * l3cfg_; + }; + + union { + struct { + L3IPData l3ipdata_6; + L3IPData l3ipdata_4; + }; + L3IPData l3ipdata_x[2]; + }; + + NML3CfgCommitTypeHandle *l3cfg_commit_type; + union { const int ifindex; int ifindex_; }; + union { const int ip_ifindex; int ip_ifindex_; }; - NMNetnsSharedIPHandle *shared_ip_handle; + union { + const NML3ConfigData *d; + } l3cds[_L3_CONFIG_DATA_TYPE_NUM]; int parent_ifindex; @@ -371,9 +462,6 @@ typedef struct _NMDevicePrivate { bool real : 1; - bool update_ip_config_completed_v4 : 1; - bool update_ip_config_completed_v6 : 1; - NMDeviceType type; char * type_desc; NMLinkType link_type; @@ -387,6 +475,8 @@ typedef struct _NMDevicePrivate { bool hw_addr_perm_fake : 1; /* whether the permanent HW address could not be read and is a fake */ + guint8 in_state_changed : 4; + NMUtilsStableType current_stable_id_type : 3; bool nm_owned : 1; /* whether the device is a device owned and created by NM */ @@ -414,21 +504,8 @@ typedef struct _NMDevicePrivate { bool queued_act_request_is_waiting_for_carrier : 1; NMDBusTrackObjPath act_request; - union { - struct { - guint activation_source_id_6; - guint activation_source_id_4; /* for layer2 and IPv4. */ - }; - guint activation_source_id_x[2]; - }; - - union { - struct { - ActivationHandleFunc activation_source_func_6; - ActivationHandleFunc activation_source_func_4; /* for layer2 and IPv4. */ - }; - ActivationHandleFunc activation_source_func_x[2]; - }; + GSource * activation_idle_source; + ActivationHandleFunc activation_func; guint recheck_assume_id; @@ -452,7 +529,7 @@ typedef struct _NMDevicePrivate { gulong config_changed_id; gulong ifindex_changed_id; guint32 mtu; - guint32 ip6_mtu; + guint32 ip6_mtu; /* FIXME(l3cfg) */ guint32 mtu_initial; guint32 ip6_mtu_initial; NMDeviceMtuSource mtu_source; @@ -468,6 +545,14 @@ typedef struct _NMDevicePrivate { * in the future. This is used to extend the grace period in this particular case. */ gint64 carrier_wait_until_ms; + union { + struct { + NML3ConfigMergeFlags l3config_merge_flags_6; + NML3ConfigMergeFlags l3config_merge_flags_4; + }; + NML3ConfigMergeFlags l3config_merge_flags_x[2]; + }; + union { const NMDeviceSysIfaceState sys_iface_state; NMDeviceSysIfaceState sys_iface_state_; @@ -478,9 +563,6 @@ typedef struct _NMDevicePrivate { bool up : 1; /* IFF_UP */ - bool v4_commit_first_time : 1; - bool v6_commit_first_time : 1; - bool default_route_metric_penalty_ip4_has : 1; bool default_route_metric_penalty_ip6_has : 1; @@ -496,103 +578,95 @@ typedef struct _NMDevicePrivate { bool is_enslaved : 1; - bool ipv6ll_handle : 1; /* TRUE if NM handles the device's IPv6LL address */ - bool ipv6ll_has : 1; - bool ndisc_started : 1; bool device_link_changed_down : 1; bool concheck_rp_filter_checked : 1; - NMDeviceStageState stage1_sriov_state : 3; - - bool ip_config_started : 1; bool tc_committed : 1; + NMDeviceStageState stage1_sriov_state : 3; + char *current_stable_id; - union { - struct { - GSource *ip_req_timeout_source_6; - GSource *ip_req_timeout_source_4; - }; - GSource *ip_req_timeout_source_x[2]; - }; - - /* Proxy Configuration */ - NMProxyConfig * proxy_config; NMPacrunnerConfId *pacrunner_conf_id; - /* IP configuration info. Combined config from VPN, settings, and device */ - union { - struct { - NMIP6Config *ip_config_6; - NMIP4Config *ip_config_4; - }; - NMIPConfig *ip_config_x[2]; - }; - - /* Config from DHCP, PPP, LLv4, etc */ - AppliedConfig dev_ip_config_4; - - /* config from the setting */ - union { - struct { - NMIP6Config *con_ip_config_6; - NMIP4Config *con_ip_config_4; - }; - NMIPConfig *con_ip_config_x[2]; - }; - - /* Stuff added outside NM */ - union { - struct { - NMIP6Config *ext_ip_config_6; - NMIP4Config *ext_ip_config_4; - }; - NMIPConfig *ext_ip_config_x[2]; - }; - - /* VPNs which use this device */ - union { - struct { - GSList *vpn_configs_6; - GSList *vpn_configs_4; - }; - GSList *vpn_configs_x[2]; - }; - - /* Extra device configuration, injected by the subclass of NMDevice. - * This is used for example by NMDeviceModem for WWAN configuration. */ - union { - struct { - AppliedConfig dev2_ip_config_6; - AppliedConfig dev2_ip_config_4; - }; - AppliedConfig dev2_ip_config_x[2]; - }; - - /* DHCPv4 tracking */ struct { - char *pac_url; - } dhcp4; + union { + const NMDeviceIPState state; + NMDeviceIPState state_; + }; + } ip_data; + + union { + struct { + IPStateData ip_data_6; + IPStateData ip_data_4; + }; + IPStateData ip_data_x[2]; + }; struct { - /* IP6 config from DHCP */ - AppliedConfig ip6_config; - /* Event ID of the current IP6 config from DHCP */ - char * event_id; - NMNDiscDHCPLevel mode; - guint needed_prefixes; - } dhcp6; + GSource *carrier_timeout; + union { + struct { + NMDeviceIPState state_6; + NMDeviceIPState state_4; + }; + NMDeviceIPState state_x[2]; + }; + bool carrier_timeout_expired; + } ipmanual_data; union { struct { - DhcpData dhcp_data_6; - DhcpData dhcp_data_4; + IPDhcpStateData ipdhcp_data_6; + IPDhcpStateData ipdhcp_data_4; }; - DhcpData dhcp_data_x[2]; + IPDhcpStateData ipdhcp_data_x[2]; }; + struct { + NMNDisc * ndisc; + GSource * ndisc_grace_source; + gulong ndisc_changed_id; + gulong ndisc_timeout_id; + NMDeviceIPState state; + } ipac6_data; + + union { + struct { + IPLLStateData ipll_data_6; + IPLLStateData ipll_data_4; + }; + IPLLStateData ipll_data_x[2]; + }; + + union { + struct { + IPSharedStateData ipshared_data_6; + IPSharedStateData ipshared_data_4; + }; + IPSharedStateData ipshared_data_x[2]; + }; + + union { + struct { + IPDevStateData ipdev_data_6; + IPDevStateData ipdev_data_4; + }; + IPDevStateData ipdev_data_x[2]; + }; + + IPDevStateData ipdev_data_unspec; + + struct { + /* If we set the addrgenmode6, this records the previously set value. */ + guint8 previous_mode_val; + + /* whether @previous_mode_val is set. */ + bool previous_mode_has : 1; + } addrgenmode6_data; + struct { NMLogDomain log_domain; guint timeout; @@ -603,58 +677,15 @@ typedef struct _NMDevicePrivate { guint deadline; } gw_ping; - /* dnsmasq stuff for shared connections */ - NMDnsMasqManager *dnsmasq_manager; - gulong dnsmasq_state_id; - /* Firewall */ FirewallState fw_state : 4; NMFirewalldManager * fw_mgr; NMFirewalldManagerCallId *fw_call; - /* IPv4LL stuff */ - sd_ipv4ll *ipv4ll; - guint ipv4ll_timeout; - guint rt6_temporary_not_available_id; - - /* IPv4 DAD stuff */ - struct { - GSList * dad_list; - NMAcdManager *announcing; - } acd; - - union { - struct { - const NMDeviceIPState ip_state_6; - const NMDeviceIPState ip_state_4; - }; - union { - const NMDeviceIPState ip_state_x[2]; - NMDeviceIPState ip_state_x_[2]; - }; - }; - - AppliedConfig ac_ip6_config; /* config from IPv6 autoconfiguration */ - NMIP6Config * ext_ip6_config_captured; /* Configuration captured from platform. */ - NMIP6Config * dad6_ip6_config; - struct in6_addr ipv6ll_addr; - - GHashTable *rt6_temporary_not_available; - - NMNDisc * ndisc; - gulong ndisc_changed_id; - gulong ndisc_timeout_id; - NMSettingIP6ConfigPrivacy ndisc_use_tempaddr; - - guint linklocal6_timeout_id; - guint8 linklocal6_dad_counter; - GHashTable *ip6_saved_properties; EthtoolState *ethtool_state; - gboolean needs_ip6_subnet; - /* master interface for bridge/bond/team slave */ NMDevice *master; gulong master_ready_id; @@ -710,6 +741,8 @@ typedef struct _NMDevicePrivate { bool mtu_force_set_done : 1; + bool needs_ip6_subnet : 1; + NMOptionBool promisc_reset; GVariant *ports_variant; /* Array of port devices D-Bus path */ @@ -724,56 +757,79 @@ G_DEFINE_ABSTRACT_TYPE(NMDevice, nm_device, NM_TYPE_DBUS_OBJECT) static const NMDBusInterfaceInfoExtended interface_info_device; static const GDBusSignalInfo signal_info_state_changed; -static void nm_device_set_proxy_config(NMDevice *self, const char *pac_url); +static void _dev_l3_cfg_commit(NMDevice *self, gboolean do_sync); -static gboolean update_ext_ip_config(NMDevice *self, int addr_family, gboolean intersect_configs); - -static gboolean nm_device_set_ip_config(NMDevice * self, - int addr_family, - NMIPConfig *config, - gboolean commit, - GPtrArray * ip4_dev_route_blacklist); - -static gboolean ip_config_merge_and_apply(NMDevice *self, int addr_family, gboolean commit); +static void _dev_l3_cfg_commit_type_reset(NMDevice *self); static gboolean nm_device_master_add_slave(NMDevice *self, NMDevice *slave, gboolean configure); static void nm_device_slave_notify_enslave(NMDevice *self, gboolean success); static void nm_device_slave_notify_release(NMDevice *self, NMDeviceStateReason reason); -static void addrconf6_start_with_link_ready(NMDevice *self); -static gboolean linklocal6_start(NMDevice *self); +static void _dev_ipll6_start(NMDevice *self); -static guint32 default_route_metric_penalty_get(NMDevice *self, int addr_family); +static void _dev_ipac6_start_continue(NMDevice *self); +static void _dev_ipac6_ndisc_set_router_config(NMDevice *self); -static guint _prop_get_ipv4_dad_timeout(NMDevice *self); +static guint32 _dev_default_route_metric_penalty_get(NMDevice *self, int addr_family); -static NMIP6Config *dad6_get_pending_addresses(NMDevice *self); +static guint32 _prop_get_ipv4_dad_timeout(NMDevice *self); static void _carrier_wait_check_queued_act_request(NMDevice *self); static gint64 _get_carrier_wait_ms(NMDevice *self); +static GBytes *_prop_get_ipv6_dhcp_duid(NMDevice * self, + NMConnection *connection, + GBytes * hwaddr, + gboolean * out_enforce); + static const char *_activation_func_to_string(ActivationHandleFunc func); static void _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, gboolean quitting); -static void queued_state_clear(NMDevice *device); -static gboolean queued_ip4_config_change(gpointer user_data); -static gboolean queued_ip6_config_change(gpointer user_data); -static void ip_check_ping_watch_cb(GPid pid, int status, gpointer user_data); -static gboolean ip_config_valid(NMDeviceState state); -static NMActStageReturn dhcp4_start(NMDevice *self); -static gboolean dhcp6_start(NMDevice *self, gboolean wait_for_ll); -static void nm_device_start_ip_check(NMDevice *self); -static void realize_start_setup(NMDevice * self, - const NMPlatformLink *plink, - gboolean assume_state_guess_assume, - const char * assume_state_connection_uuid, - gboolean set_nm_owned, - NMUnmanFlagOp unmanaged_user_explicit, - gboolean force_platform_init); -static void _set_mtu(NMDevice *self, guint32 mtu); -static void _commit_mtu(NMDevice *self, const NMIP4Config *config); -static void _cancel_activation(NMDevice *self); +static void queued_state_clear(NMDevice *device); +static void ip_check_ping_watch_cb(GPid pid, int status, gpointer user_data); +static void nm_device_start_ip_check(NMDevice *self); +static void realize_start_setup(NMDevice * self, + const NMPlatformLink *plink, + gboolean assume_state_guess_assume, + const char * assume_state_connection_uuid, + gboolean set_nm_owned, + NMUnmanFlagOp unmanaged_user_explicit, + gboolean force_platform_init); +static void _set_mtu(NMDevice *self, guint32 mtu); +static void _commit_mtu(NMDevice *self); +static void _cancel_activation(NMDevice *self); + +static void _dev_ipll4_notify_event(NMDevice *self); + +static void _dev_ip_state_check(NMDevice *self, int addr_family); + +static void _dev_ipmanual_check_ready(NMDevice *self); + +static void +_dev_ipdhcpx_cleanup(NMDevice *self, int addr_family, gboolean reset_dhcp_config, gboolean release); + +static void _dev_ip_state_check_async(NMDevice *self, int addr_family); + +static void _dev_ipdhcpx_set_state(NMDevice *self, int addr_family, NMDeviceIPState state); + +static void _dev_ipdhcpx_restart(NMDevice *self, int addr_family, gboolean release); + +static void _dev_ipdhcpx_handle_accept(NMDevice *self, int addr_family, const NML3ConfigData *l3cd); + +static gboolean +_dev_ipac6_grace_period_start(NMDevice *self, guint32 timeout_sec, gboolean force_restart); + +static void _dev_ipac6_start(NMDevice *self); + +static void _dev_unamanged_check_external_down(NMDevice *self, gboolean only_if_unmanaged); + +static void _dev_ipshared4_start(NMDevice *self); +static void _dev_ipshared4_spawn_dnsmasq(NMDevice *self); + +static void _dev_ipshared6_start(NMDevice *self); + +static void _cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type); static void concheck_update_state(NMDevice * self, int addr_family, @@ -783,8 +839,80 @@ static void concheck_update_state(NMDevice * self, static void sriov_op_cb(GError *error, gpointer user_data); static void device_ifindex_changed_cb(NMManager *manager, NMDevice *device_changed, NMDevice *self); -static gboolean device_link_changed(NMDevice *self); -static void check_ip_state(NMDevice *self, gboolean may_fail, gboolean full_state_update); +static gboolean device_link_changed(gpointer user_data); +static gboolean _get_maybe_ipv6_disabled(NMDevice *self); + +/*****************************************************************************/ + +#define _NMLOG_addr_family(level, prefix, addr_family, fmt, ...) \ + G_STMT_START \ + { \ + const int _addr_family2 = (addr_family); \ + \ + _NMLOG(level, \ + (_addr_family2 == AF_UNSPEC ? LOGD_IP : LOGD_IPX(NM_IS_IPv4(_addr_family2))), \ + "" prefix "%s: " fmt, \ + nm_utils_addr_family_to_str(_addr_family2), \ + ##__VA_ARGS__); \ + } \ + G_STMT_END + +#define _NMLOG_ip(level, ...) _NMLOG_addr_family(level, "ip", __VA_ARGS__) +#define _LOGT_ip(...) _NMLOG_ip(LOGL_TRACE, __VA_ARGS__) +#define _LOGD_ip(...) _NMLOG_ip(LOGL_DEBUG, __VA_ARGS__) +#define _LOGI_ip(...) _NMLOG_ip(LOGL_INFO, __VA_ARGS__) +#define _LOGW_ip(...) _NMLOG_ip(LOGL_WARN, __VA_ARGS__) + +#define _NMLOG_ipll(level, ...) _NMLOG_addr_family(level, "ip:ll", __VA_ARGS__) +#define _LOGT_ipll(...) _NMLOG_ipll(LOGL_TRACE, __VA_ARGS__) +#define _LOGD_ipll(...) _NMLOG_ipll(LOGL_DEBUG, __VA_ARGS__) +#define _LOGI_ipll(...) _NMLOG_ipll(LOGL_INFO, __VA_ARGS__) +#define _LOGW_ipll(...) _NMLOG_ipll(LOGL_WARN, __VA_ARGS__) + +#define _NMLOG_ipdev(level, ...) _NMLOG_addr_family(level, "ip:dev", __VA_ARGS__) +#define _LOGT_ipdev(...) _NMLOG_ipdev(LOGL_TRACE, __VA_ARGS__) +#define _LOGD_ipdev(...) _NMLOG_ipdev(LOGL_DEBUG, __VA_ARGS__) +#define _LOGI_ipdev(...) _NMLOG_ipdev(LOGL_INFO, __VA_ARGS__) +#define _LOGW_ipdev(...) _NMLOG_ipdev(LOGL_WARN, __VA_ARGS__) + +#define _NMLOG_ipdhcp(level, ...) _NMLOG_addr_family(level, "ip:dhcp", __VA_ARGS__) +#define _LOGT_ipdhcp(...) _NMLOG_ipdhcp(LOGL_TRACE, __VA_ARGS__) +#define _LOGD_ipdhcp(...) _NMLOG_ipdhcp(LOGL_DEBUG, __VA_ARGS__) +#define _LOGI_ipdhcp(...) _NMLOG_ipdhcp(LOGL_INFO, __VA_ARGS__) +#define _LOGW_ipdhcp(...) _NMLOG_ipdhcp(LOGL_WARN, __VA_ARGS__) + +#define _NMLOG_ipshared(level, ...) _NMLOG_addr_family(level, "ip:shared", __VA_ARGS__) +#define _LOGT_ipshared(...) _NMLOG_ipshared(LOGL_TRACE, __VA_ARGS__) +#define _LOGD_ipshared(...) _NMLOG_ipshared(LOGL_DEBUG, __VA_ARGS__) +#define _LOGI_ipshared(...) _NMLOG_ipshared(LOGL_INFO, __VA_ARGS__) +#define _LOGW_ipshared(...) _NMLOG_ipshared(LOGL_WARN, __VA_ARGS__) + +#define _NMLOG_ipac6(level, ...) _NMLOG_addr_family(level, "ip:ac6", AF_UNSPEC, __VA_ARGS__) +#define _LOGT_ipac6(...) _NMLOG_ipac6(LOGL_TRACE, __VA_ARGS__) +#define _LOGD_ipac6(...) _NMLOG_ipac6(LOGL_DEBUG, __VA_ARGS__) +#define _LOGI_ipac6(...) _NMLOG_ipac6(LOGL_INFO, __VA_ARGS__) +#define _LOGW_ipac6(...) _NMLOG_ipac6(LOGL_WARN, __VA_ARGS__) + +#define _NMLOG_ipmanual(level, ...) _NMLOG_addr_family(level, "ip:manual", __VA_ARGS__) +#define _LOGT_ipmanual(...) _NMLOG_ipmanual(LOGL_TRACE, __VA_ARGS__) +#define _LOGD_ipmanual(...) _NMLOG_ipmanual(LOGL_DEBUG, __VA_ARGS__) +#define _LOGI_ipmanual(...) _NMLOG_ipmanual(LOGL_INFO, __VA_ARGS__) +#define _LOGW_ipmanual(...) _NMLOG_ipmanual(LOGL_WARN, __VA_ARGS__) + +/*****************************************************************************/ + +#define _CACHED_BOOL(cached_value, cmd) \ + ({ \ + NMTernary *const _cached_value = (cached_value); \ + \ + nm_assert(_cached_value); \ + nm_assert_is_ternary(*_cached_value); \ + \ + if (*_cached_value == NM_TERNARY_DEFAULT) \ + *_cached_value = !!(cmd); \ + \ + !!(*_cached_value); \ + }) /*****************************************************************************/ @@ -1335,7 +1463,7 @@ _prop_get_connection_lldp(NMDevice *self) return lldp == NM_SETTING_CONNECTION_LLDP_ENABLE_RX; } -static guint +static guint32 _prop_get_ipv4_dad_timeout(NMDevice *self) { NMConnection * connection; @@ -1347,6 +1475,9 @@ _prop_get_ipv4_dad_timeout(NMDevice *self) s_ip4 = nm_connection_get_setting_ip4_config(connection); if (s_ip4) timeout = nm_setting_ip_config_get_dad_timeout(s_ip4); + + nm_assert(timeout >= -1 && timeout <= NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX); + if (timeout >= 0) return timeout; @@ -1363,8 +1494,8 @@ _prop_get_ipvx_dhcp_timeout(NMDevice *self, int addr_family) { NMDeviceClass *klass; NMConnection * connection; - int timeout_i; guint32 timeout; + int timeout_i; nm_assert(NM_IS_DEVICE(self)); nm_assert_addr_family(addr_family); @@ -1406,6 +1537,37 @@ out: return timeout; } +static guint32 +_prop_get_ipvx_dns_priority(NMDevice *self, int addr_family) +{ + NMConnection * connection; + NMSettingIPConfig *s_ip; + int prio = 0; + + connection = nm_device_get_applied_connection(self); + s_ip = nm_connection_get_setting_ip_config(connection, addr_family); + if (s_ip) + prio = nm_setting_ip_config_get_dns_priority(s_ip); + + if (prio == 0) { + prio = nm_config_data_get_connection_default_int64( + NM_CONFIG_GET_DATA, + NM_IS_IPv4(addr_family) ? NM_CON_DEFAULT("ipv4.dns-priority") + : NM_CON_DEFAULT("ipv6.dns-priority"), + self, + G_MININT32, + G_MAXINT32, + 0); + if (prio == 0) { + prio = nm_device_is_vpn(self) ? NM_DNS_PRIORITY_DEFAULT_VPN + : NM_DNS_PRIORITY_DEFAULT_NORMAL; + } + } + + nm_assert(prio != 0); + return prio; +} + static guint32 _prop_get_ipvx_required_timeout(NMDevice *self, int addr_family) { @@ -1440,6 +1602,25 @@ _prop_get_ipvx_required_timeout(NMDevice *self, int addr_family) 0); } +static gboolean +_prop_get_ipvx_may_fail(NMDevice *self, int addr_family) +{ + NMConnection * connection; + NMSettingIPConfig *s_ip = NULL; + + connection = nm_device_get_applied_connection(self); + if (connection) + s_ip = nm_connection_get_setting_ip_config(connection, addr_family); + + return !s_ip || nm_setting_ip_config_get_may_fail(s_ip); +} + +static gboolean +_prop_get_ipvx_may_fail_cached(NMDevice *self, int addr_family, NMTernary *cache) +{ + return _CACHED_BOOL(cache, _prop_get_ipvx_may_fail(self, addr_family)); +} + /** * _prop_get_ipvx_dhcp_iaid: * @self: the #NMDevice @@ -2416,27 +2597,6 @@ concheck_get_mgr(NMDevice *self) return priv->concheck_mgr; } -NMIP4Config * -nm_device_ip4_config_new(NMDevice *self) -{ - return nm_ip4_config_new(nm_device_get_multi_index(self), nm_device_get_ip_ifindex(self)); -} - -NMIP6Config * -nm_device_ip6_config_new(NMDevice *self) -{ - return nm_ip6_config_new(nm_device_get_multi_index(self), nm_device_get_ip_ifindex(self)); -} - -NMIPConfig * -nm_device_ip_config_new(NMDevice *self, int addr_family) -{ - nm_assert_addr_family(addr_family); - - return NM_IS_IPv4(addr_family) ? (gpointer) nm_device_ip4_config_new(self) - : (gpointer) nm_device_ip6_config_new(self); -} - NML3ConfigData * nm_device_create_l3_config_data(NMDevice *self, NMIPConfigSource source) { @@ -2451,98 +2611,28 @@ nm_device_create_l3_config_data(NMDevice *self, NMIPConfigSource source) return nm_l3_config_data_new(nm_device_get_multi_index(self), ifindex, source); } -static void -applied_config_clear(AppliedConfig *config) +const NML3ConfigData * +nm_device_create_l3_config_data_from_connection(NMDevice *self, NMConnection *connection) { - g_clear_object(&config->current); - g_clear_object(&config->orig); -} + NML3ConfigData *l3cd; + int ifindex; -static void -applied_config_init(AppliedConfig *config, gpointer ip_config) -{ - nm_assert(!ip_config || (!config->orig && !config->current) - || nm_ip_config_get_addr_family(ip_config) - == nm_ip_config_get_addr_family(config->orig ?: config->current)); - nm_assert(!ip_config || NM_IS_IP_CONFIG(ip_config)); + nm_assert(NM_IS_DEVICE(self)); + nm_assert(!connection || NM_IS_CONNECTION(connection)); - nm_g_object_ref(ip_config); - applied_config_clear(config); - config->orig = ip_config; -} + if (!connection) + return NULL; -static void -applied_config_init_new(AppliedConfig *config, NMDevice *self, int addr_family) -{ - gs_unref_object NMIPConfig *c = nm_device_ip_config_new(self, addr_family); + ifindex = nm_device_get_ip_ifindex(self); + if (ifindex <= 0) + g_return_val_if_reached(NULL); - applied_config_init(config, c); -} - -static NMIPConfig * -applied_config_get_current(AppliedConfig *config) -{ - return config->current ?: config->orig; -} - -static void -applied_config_add_address(AppliedConfig *config, const NMPlatformIPAddress *address) -{ - if (config->orig) - nm_ip_config_add_address(config->orig, address); - else - nm_assert(!config->current); - - if (config->current) - nm_ip_config_add_address(config->current, address); -} - -static void -applied_config_add_nameserver(AppliedConfig *config, const NMIPAddr *ns) -{ - if (config->orig) - nm_ip_config_add_nameserver(config->orig, ns); - else - nm_assert(!config->current); - - if (config->current) - nm_ip_config_add_nameserver(config->current, ns); -} - -static void -applied_config_add_search(AppliedConfig *config, const char *new) -{ - if (config->orig) - nm_ip_config_add_search(config->orig, new); - else - nm_assert(!config->current); - - if (config->current) - nm_ip_config_add_search(config->current, new); -} - -static void -applied_config_reset_searches(AppliedConfig *config) -{ - if (config->orig) - nm_ip_config_reset_searches(config->orig); - else - nm_assert(!config->current); - - if (config->current) - nm_ip_config_reset_searches(config->current); -} - -static void -applied_config_reset_nameservers(AppliedConfig *config) -{ - if (config->orig) - nm_ip_config_reset_nameservers(config->orig); - else - nm_assert(!config->current); - - if (config->current) - nm_ip_config_reset_nameservers(config->current); + l3cd = + nm_l3_config_data_new_from_connection(nm_device_get_multi_index(self), ifindex, connection); + nm_l3_config_data_set_mdns(l3cd, _prop_get_connection_mdns(self)); + nm_l3_config_data_set_llmnr(l3cd, _prop_get_connection_llmnr(self)); + nm_l3_config_data_set_dns_over_tls(l3cd, _prop_get_connection_dns_over_tls(self)); + return l3cd; } /*****************************************************************************/ @@ -2588,6 +2678,7 @@ nm_device_sys_iface_state_set(NMDevice *self, NMDeviceSysIfaceState sys_iface_st nm_device_sys_iface_state_to_string(priv->sys_iface_state), nm_device_sys_iface_state_to_string(sys_iface_state)); priv->sys_iface_state_ = sys_iface_state; + _dev_l3_cfg_commit_type_reset(self); } /* this function only sets a flag, no immediate actions are initiated. @@ -2700,33 +2791,6 @@ nm_device_assume_state_reset(NMDevice *self) /*****************************************************************************/ -static void -init_ip_config_dns_priority(NMDevice *self, NMIPConfig *config) -{ - const char *property; - int priority; - - property = (nm_ip_config_get_addr_family(config) == AF_INET) - ? NM_CON_DEFAULT("ipv4.dns-priority") - : NM_CON_DEFAULT("ipv6.dns-priority"); - - priority = nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA, - property, - self, - G_MININT, - G_MAXINT, - 0); - - if (priority == 0) { - priority = - nm_device_is_vpn(self) ? NM_DNS_PRIORITY_DEFAULT_VPN : NM_DNS_PRIORITY_DEFAULT_NORMAL; - } - - nm_ip_config_set_dns_priority(config, priority); -} - -/*****************************************************************************/ - static char * nm_device_sysctl_ip_conf_get(NMDevice *self, int addr_family, const char *property) { @@ -2863,95 +2927,1005 @@ _add_capabilities(NMDevice *self, NMDeviceCapabilities capabilities) /*****************************************************************************/ -static gboolean -ip_required_timeout_x(NMDevice *self, int addr_family) +static void +_dev_ip_state_req_timeout_cancel(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - _LOGD(LOGD_CORE, - "required-timeout expired for IPv%c", - nm_utils_addr_family_to_char(addr_family)); - nm_clear_g_source_inst(&priv->ip_req_timeout_source_x[NM_IS_IPv4(addr_family)]); - check_ip_state(self, FALSE, TRUE); + if (addr_family == AF_UNSPEC) { + _dev_ip_state_req_timeout_cancel(self, AF_INET); + _dev_ip_state_req_timeout_cancel(self, AF_INET6); + return; + } + + if (nm_clear_g_source_inst(&priv->ip_data_x[NM_IS_IPv4(addr_family)].req_timeout_source)) + _LOGD_ip(addr_family, "required-timeout: cancelled"); +} + +static gboolean +_dev_ip_state_req_timeout_cb_x(NMDevice *self, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + _LOGD_ip(addr_family, "required-timeout: expired"); + nm_clear_g_source_inst(&priv->ip_data_x[NM_IS_IPv4(addr_family)].req_timeout_source); + _dev_ip_state_check(self, addr_family); return G_SOURCE_CONTINUE; } static gboolean -ip_required_timeout_4(gpointer data) +_dev_ip_state_req_timeout_cb_4(gpointer user_data) { - return ip_required_timeout_x(data, AF_INET); + return _dev_ip_state_req_timeout_cb_x(user_data, AF_INET); } static gboolean -ip_required_timeout_6(gpointer data) +_dev_ip_state_req_timeout_cb_6(gpointer user_data) { - return ip_required_timeout_x(data, AF_INET6); + return _dev_ip_state_req_timeout_cb_x(user_data, AF_INET6); } static void -_set_ip_state(NMDevice *self, int addr_family, NMDeviceIPState new_state) +_dev_ip_state_req_timeout_schedule(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const int IS_IPv4 = NM_IS_IPv4(addr_family); - guint timeout_msec; - int v4; + guint32 timeout_msec; + char buf[32]; - nm_assert_addr_family(addr_family); + nm_assert(!priv->ip_data_x[IS_IPv4].req_timeout_source); - if (new_state == NM_DEVICE_IP_STATE_CONF && !priv->ip_config_started) { - /* Start the required-timeout timers when one of IPv4/IPv6 - * enters the CONF state. This means that if there is no carrier and - * ipv4.method=auto,ipv6.method=manual, the timeout for IPv4 will - * start as soon as connection is activated, even if DHCPv4 did not - * start yet. - */ - priv->ip_config_started = TRUE; + timeout_msec = _prop_get_ipvx_required_timeout(self, addr_family); + if (timeout_msec == 0) { + _LOGD_ip(addr_family, "required-timeout: disabled"); + return; + } - for (v4 = 1; v4 >= 0; v4--) { - char buf[32]; + _LOGD_ip(addr_family, + "required-timeout: started (%s msec)", + timeout_msec == G_MAXINT32 ? "∞" : nm_sprintf_buf(buf, "%u", timeout_msec)); - nm_assert(!priv->ip_req_timeout_source_x[v4]); - if ((timeout_msec = _prop_get_ipvx_required_timeout(self, v4 ? AF_INET : AF_INET6))) { - _LOGD(LOGD_CORE, - "required-timeout in %s msec for IPv%c", - timeout_msec == G_MAXINT32 ? "∞" : nm_sprintf_buf(buf, "%u", timeout_msec), - v4 ? '4' : '6'); + if (timeout_msec == G_MAXINT32) { + priv->ip_data_x[IS_IPv4].req_timeout_source = g_source_ref(nm_g_source_sentinel_get(0)); + } else { + priv->ip_data_x[IS_IPv4].req_timeout_source = nm_g_timeout_add_source( + timeout_msec, + IS_IPv4 ? _dev_ip_state_req_timeout_cb_4 : _dev_ip_state_req_timeout_cb_6, + self); + } +} - if (timeout_msec == G_MAXINT32) { - priv->ip_req_timeout_source_x[v4] = g_source_ref(nm_g_source_sentinel_get(0)); - } else { - priv->ip_req_timeout_source_x[v4] = - nm_g_timeout_add_source(timeout_msec, - v4 ? ip_required_timeout_4 : ip_required_timeout_6, - self); +static gboolean +_dev_ip_state_set_state(NMDevice * self, + int addr_family, + NMDeviceIPState ip_state, + const char * reason) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + int IS_IPv4; + + if (addr_family == AF_UNSPEC) { + if (priv->ip_data.state == ip_state) + return FALSE; + _LOGD_ip(addr_family, + "set (combined) state %s (was %s, reason: %s)", + nm_device_ip_state_to_string(ip_state), + nm_device_ip_state_to_string(priv->ip_data.state), + reason); + priv->ip_data.state_ = ip_state; + return TRUE; + } + + IS_IPv4 = NM_IS_IPv4(addr_family); + + if (priv->ip_data_x[IS_IPv4].state_ == ip_state) + return FALSE; + + _LOGD_ip(addr_family, + "set state %s (was %s, reason: %s)", + nm_device_ip_state_to_string(ip_state), + nm_device_ip_state_to_string(priv->ip_data_x[IS_IPv4].state), + reason); + priv->ip_data_x[IS_IPv4].state_ = ip_state; + return TRUE; +} + +static void +_device_ip_state_accumulate(NMDeviceIPState state, + gboolean * out_is_started, + gboolean * out_is_pending, + gboolean * out_is_failed) +{ + switch (state) { + case NM_DEVICE_IP_STATE_NONE: + return; + case NM_DEVICE_IP_STATE_PENDING: + *out_is_started = TRUE; + *out_is_pending = TRUE; + return; + case NM_DEVICE_IP_STATE_READY: + *out_is_started = TRUE; + return; + case NM_DEVICE_IP_STATE_FAILED: + *out_is_started = TRUE; + *out_is_failed = TRUE; + return; + } + nm_assert_not_reached(); + return; +} + +static void +_dev_ip_state_check(NMDevice *self, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + gboolean s_is_started = FALSE; + gboolean s_is_failed = FALSE; + gboolean s_is_pending = FALSE; + gboolean v_bool; + NMDeviceIPState ip_state; + NMDeviceIPState ip_state_other; + NMDeviceIPState combinedip_state; + NMTernary may_fail = NM_TERNARY_DEFAULT; + NMTernary may_fail_other = NM_TERNARY_DEFAULT; + + /* State handling in NMDevice: + * + * NMDevice manages a lot of state, that is for the various IP addressing methods, the state + * of the interface (controller/port), and a overall nm_device_get_state(). + * + * The idea is to compartmentalize these states into smaller units, and combine them as appropriate. + * + * For example, NMDhcpClient already provides an API that hides most of the complexity. But it still + * needs to expose some state, like whether we are still trying to get a lease (PENDING), whether there + * was a critical failure (FAILED) or we have a lease (READY). This state is grouped in NMDevice + * under priv->ipdhcp_data_x. Most important is priv->ipdhcp_data_x[].state, which distills all of this + * into 4 values of type NMDeviceIPState. This state is cached, so whenever something changes (e.g. + * an event from NMDhcpClient), we determine the new state and compare it with what is cached. If + * the cached state is as the new state, we are done. Otherwise, the change gets escalated (which + * means to call _dev_ip_state_check_async()). + * + * Then, the various sub-states escalate their changes to this function (_dev_ip_state_check). This + * function first takes the sub-states related to one IP address family, and combines them into + * priv->ip_data_x[] (and in particular priv->ip_data_x[].state). The same repeats. The current + * state is cached in priv->ip_data_x[].state, and _dev_ip_state_check() determines the new state. + * If there is no change, it ends here. Otherwise, it gets escalated. In this case, the escaplation + * happens in _dev_ip_state_check() below by combining the combined per-address-family into + * priv->ip_data. In particular this step needs to take into account settings like "may-fail" + * and "required-timeout". + * + * The escalation and compartmentalization priv->ip_data repeats. This time it escalates + * to the overall device state (nm_device_state_changed() and nm_device_get_state()), which then + * triggers larger state changes (e.g. the activation might fail). + */ + + if (priv->l3cfg && nm_l3cfg_commit_on_idle_is_scheduled(priv->l3cfg)) { + /* we have an update on NML3Cfg scheduled. We first process that, before + * progressing the IP state. When that's done, we will be called again. */ + _dev_ip_state_check_async(self, addr_family); + return; + } + + if (priv->ip_data_x[IS_IPv4].state == NM_DEVICE_IP_STATE_NONE) { + ip_state = NM_DEVICE_IP_STATE_NONE; + goto got_ip_state; + } + + if (nm_device_sys_iface_state_is_external(self)) { + ip_state = NM_DEVICE_IP_STATE_READY; + goto got_ip_state; + } + + if (priv->ip_data_x[IS_IPv4].state == NM_DEVICE_IP_STATE_PENDING + && (priv->state < NM_DEVICE_STATE_IP_CONFIG || priv->state > NM_DEVICE_STATE_ACTIVATED)) { + /* we can only leave pending state, if we are between (including) IP_CONFIG and ACTIVATED states. */ + ip_state = NM_DEVICE_IP_STATE_PENDING; + goto got_ip_state; + } + + if (priv->ip_data_x[IS_IPv4].state == NM_DEVICE_IP_STATE_PENDING + && nm_active_connection_get_master(NM_ACTIVE_CONNECTION(priv->act_request.obj)) + && !priv->is_enslaved) { + /* Don't progress into IP_CHECK or SECONDARIES if we're waiting for the + * master to enslave us. */ + ip_state = NM_DEVICE_IP_STATE_PENDING; + goto got_ip_state; + } + + if (priv->ip_data_x[IS_IPv4].wait_for_carrier || priv->ip_data_x[IS_IPv4].wait_for_ports) { + ip_state = NM_DEVICE_IP_STATE_PENDING; + goto got_ip_state; + } + + if (priv->ip_data_x[IS_IPv4].is_disabled || priv->ip_data_x[IS_IPv4].is_ignore) { + ip_state = NM_DEVICE_IP_STATE_READY; + goto got_ip_state; + } + + _device_ip_state_accumulate(priv->ipmanual_data.state_x[IS_IPv4], + &s_is_started, + &s_is_pending, + &s_is_failed); + + _device_ip_state_accumulate(priv->ipll_data_x[IS_IPv4].state, + &s_is_started, + &s_is_pending, + &s_is_failed); + + if (!IS_IPv4) { + _device_ip_state_accumulate(priv->ipac6_data.state, + &s_is_started, + &s_is_pending, + &s_is_failed); + } + + v_bool = FALSE; + _device_ip_state_accumulate(priv->ipdhcp_data_x[IS_IPv4].state, + &s_is_started, + &s_is_pending, + &v_bool); + if (v_bool) { + if (!IS_IPv4 && priv->ipdhcp_data_6.v6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) { + /* DHCPv6 is best-effort and not required. */ + } else + s_is_failed = TRUE; + } + + _device_ip_state_accumulate(priv->ipshared_data_x[IS_IPv4].state, + &s_is_started, + &s_is_pending, + &s_is_failed); + + _device_ip_state_accumulate(priv->ipdev_data_x[IS_IPv4].state, + &s_is_started, + &s_is_pending, + &s_is_failed); + + _device_ip_state_accumulate(priv->ipdev_data_unspec.state, + &s_is_started, + &s_is_pending, + &s_is_failed); + + if (s_is_failed) + ip_state = NM_DEVICE_IP_STATE_FAILED; + else if (s_is_pending) + ip_state = NM_DEVICE_IP_STATE_PENDING; + else if (s_is_started) + ip_state = NM_DEVICE_IP_STATE_READY; + else + ip_state = NM_DEVICE_IP_STATE_PENDING; + +got_ip_state: + +#define _state_str_a(state, name) \ + ({ \ + const NMDeviceIPState _state = (state); \ + char * _s = ""; \ + \ + if (_state != NM_DEVICE_IP_STATE_NONE) { \ + _s = nm_sprintf_bufa(NM_STRLEN(name) + 11, \ + " " name "=%s", \ + nm_device_ip_state_to_string(_state)); \ + } \ + _s; \ + }) + + nm_assert(!priv->ip_data_4.is_ignore); + + _LOGT_ip(addr_family, + "check-state: state %s => %s, is_failed=%d, is_pending=%d, is_started=%d, " + "may-fail-4=%d, may-fail-6=%d;" + "%s;%s%s%s%s%s%s;%s%s%s%s%s%s%s%s", + nm_device_ip_state_to_string(priv->ip_data_x[IS_IPv4].state), + nm_device_ip_state_to_string(ip_state), + s_is_failed, + s_is_pending, + s_is_started, + _prop_get_ipvx_may_fail_cached(self, AF_INET, IS_IPv4 ? &may_fail : &may_fail_other), + _prop_get_ipvx_may_fail_cached(self, AF_INET6, !IS_IPv4 ? &may_fail : &may_fail_other), + priv->ip_data_4.is_disabled ? " disabled4" : "", + _state_str_a(priv->ipmanual_data.state_4, "manualip4"), + _state_str_a(priv->ipdev_data_unspec.state, "dev"), + _state_str_a(priv->ipll_data_4.state, "ll4"), + _state_str_a(priv->ipdhcp_data_4.state, "dhcp4"), + _state_str_a(priv->ipdev_data_4.state, "dev4"), + _state_str_a(priv->ipshared_data_4.state, "shared4"), + priv->ip_data_6.is_disabled ? " disabled6" : "", + priv->ip_data_6.is_ignore ? " ignore6" : "", + _state_str_a(priv->ipmanual_data.state_6, "manualip6"), + _state_str_a(priv->ipll_data_6.state, "ll6"), + _state_str_a(priv->ipac6_data.state, "ac6"), + _state_str_a(priv->ipdhcp_data_6.state, "dhcp6"), + _state_str_a(priv->ipdev_data_6.state, "dev6"), + _state_str_a(priv->ipshared_data_6.state, "shared6")); + + if (priv->ip_data_x[IS_IPv4].state == ip_state) { + /* no change. We can stop here. However, we also cancel the pending check, if any, + * because we just determined that there is no change. */ + } else { + _dev_ip_state_set_state(self, addr_family, ip_state, "check-ip-state"); + } + + if (ip_state == NM_DEVICE_IP_STATE_NONE) { + /* Nothing to do. This almost cannot happen, and there is probably nothing + * to do about this case. */ + goto out_done; + } + + ip_state_other = priv->ip_data_x[!IS_IPv4].state; + + if (ip_state == NM_DEVICE_IP_STATE_READY) { + /* we only set NM_ACTIVATION_STATE_FLAG_IP_READY_X() flag once we reach NM_DEVICE_IP_STATE_READY state. + * We don't ever clear it, even if we later enter NM_DEVICE_IP_STATE_FAILED state. + * + * This is not documented/guaranteed behavior, but seems to make sense for now. */ + _active_connection_set_state_flags(self, NM_ACTIVATION_STATE_FLAG_IP_READY_X(IS_IPv4)); + } + + if (ip_state == NM_DEVICE_IP_STATE_READY && ip_state_other == NM_DEVICE_IP_STATE_READY) + combinedip_state = NM_DEVICE_IP_STATE_READY; + else if (ip_state == NM_DEVICE_IP_STATE_READY && ip_state_other == NM_DEVICE_IP_STATE_PENDING + && (priv->ip_data_x[IS_IPv4].is_disabled || priv->ip_data_x[IS_IPv4].is_ignore)) { + /* This IP method is disabled/ignore, but the other family is still pending. + * Regardless of ipvx.may-fail, this means that we always require the other IP family + * to get ready too. */ + combinedip_state = NM_DEVICE_IP_STATE_PENDING; + } else if (ip_state == NM_DEVICE_IP_STATE_READY && ip_state_other == NM_DEVICE_IP_STATE_PENDING + && (priv->ip_data_x[!IS_IPv4].req_timeout_source + || !_prop_get_ipvx_may_fail_cached(self, + nm_utils_addr_family_other(addr_family), + &may_fail_other))) + combinedip_state = NM_DEVICE_IP_STATE_PENDING; + else if (ip_state == NM_DEVICE_IP_STATE_READY + && NM_IN_SET(ip_state_other, + NM_DEVICE_IP_STATE_PENDING, + NM_DEVICE_IP_STATE_READY, + NM_DEVICE_IP_STATE_FAILED) + && _prop_get_ipvx_may_fail_cached(self, + nm_utils_addr_family_other(addr_family), + &may_fail_other)) + combinedip_state = NM_DEVICE_IP_STATE_READY; + else if (ip_state == NM_DEVICE_IP_STATE_FAILED + && !_prop_get_ipvx_may_fail_cached(self, addr_family, &may_fail)) + combinedip_state = NM_DEVICE_IP_STATE_FAILED; + else if (ip_state == NM_DEVICE_IP_STATE_FAILED && ip_state_other == NM_DEVICE_IP_STATE_FAILED) { + /* If both IP states fail, then it's a failure for good. may-fail does not mean that + * both families may fail, instead it means that at least one family must succeed. */ + combinedip_state = NM_DEVICE_IP_STATE_FAILED; + } else { + if (priv->ip_data.state == NM_DEVICE_IP_STATE_NONE) + combinedip_state = NM_DEVICE_IP_STATE_PENDING; + else + combinedip_state = priv->ip_data.state; + } + + _LOGT_ip(AF_UNSPEC, + "check-state: (combined) state %s => %s", + nm_device_ip_state_to_string(priv->ip_data.state), + nm_device_ip_state_to_string(combinedip_state)); + + if (!_dev_ip_state_set_state(self, AF_UNSPEC, combinedip_state, "check-ip-state")) + goto out_done; + + switch (combinedip_state) { + case NM_DEVICE_IP_STATE_PENDING: + break; + case NM_DEVICE_IP_STATE_READY: + _dev_ip_state_req_timeout_cancel(self, AF_UNSPEC); + if (priv->state == NM_DEVICE_STATE_IP_CONFIG) { + nm_device_state_changed(self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE); + } + break; + case NM_DEVICE_IP_STATE_FAILED: + nm_device_state_changed(self, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + break; + case NM_DEVICE_IP_STATE_NONE: + default: + nm_assert_not_reached(); + } + +out_done: + /* we just checked the state. We can cancel the pending async check. */ + nm_clear_g_source_inst(&priv->ip_data_x[IS_IPv4].check_async_source); +} + +static gboolean +_dev_ip_state_check_async_cb(NMDevice *self, int addr_family) +{ + _dev_ip_state_check(self, addr_family); + return G_SOURCE_CONTINUE; +} + +static gboolean +_dev_ip_state_check_async_cb_4(gpointer user_data) +{ + return _dev_ip_state_check_async_cb(user_data, AF_INET); +} + +static gboolean +_dev_ip_state_check_async_cb_6(gpointer user_data) +{ + return _dev_ip_state_check_async_cb(user_data, AF_INET6); +} + +static void +_dev_ip_state_check_async(NMDevice *self, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + int IS_IPv4; + + if (addr_family == AF_UNSPEC) { + _dev_ip_state_check_async(self, AF_INET); + _dev_ip_state_check_async(self, AF_INET6); + return; + } + + IS_IPv4 = NM_IS_IPv4(addr_family); + if (!priv->ip_data_x[IS_IPv4].check_async_source) { + priv->ip_data_x[IS_IPv4].check_async_source = nm_g_idle_add_source( + (IS_IPv4 ? _dev_ip_state_check_async_cb_4 : _dev_ip_state_check_async_cb_6), + self); + } +} + +static void +_dev_ip_state_cleanup(NMDevice *self, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + int IS_IPv4; + + if (addr_family == AF_UNSPEC) { + _dev_ip_state_set_state(self, addr_family, NM_DEVICE_IP_STATE_NONE, "ip-state-clear"); + return; + } + + IS_IPv4 = NM_IS_IPv4(addr_family); + + nm_clear_g_source_inst(&priv->ip_data_x[IS_IPv4].check_async_source); + nm_clear_g_source_inst(&priv->ip_data_x[IS_IPv4].req_timeout_source); + _dev_ip_state_set_state(self, addr_family, NM_DEVICE_IP_STATE_NONE, "ip-state-clear"); + priv->ip_data_x[IS_IPv4].wait_for_carrier = FALSE; + priv->ip_data_x[IS_IPv4].wait_for_ports = FALSE; + priv->ip_data_x[IS_IPv4].is_disabled = FALSE; + priv->ip_data_x[IS_IPv4].is_ignore = FALSE; + priv->ip_data_x[IS_IPv4].do_reapply = FALSE; +} + +/*****************************************************************************/ + +static gpointer +_dev_l3_config_data_tag_get(NMDevicePrivate *priv, L3ConfigDataType l3cd_type) +{ + nm_assert(_NM_INT_NOT_NEGATIVE(l3cd_type) && l3cd_type < G_N_ELEMENTS(priv->l3cds)); + + return &priv->l3cds[l3cd_type]; +} + +static L3ConfigDataType +_dev_l3_config_data_tag_to_type(NMDevice *self, gconstpointer tag) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + int d; + + /* In C it is undefined behavior to compare unrelated pointers. + * Work around that by using nm_ptr_to_uintptr(), which casts the pointers + * to integers. + * + * I guess, theoretically it's still a problem to assume that if tag pointers + * somewhere inside priv->l3cds, that the uintptr_t case would also yield + * a value in that range. In practice, I couldn't imaging this not not work + * reliably. */ + + if (nm_ptr_to_uintptr(tag) < nm_ptr_to_uintptr(&priv->l3cds[0]) + || nm_ptr_to_uintptr(tag) >= nm_ptr_to_uintptr(&priv->l3cds[G_N_ELEMENTS(priv->l3cds)])) + return _L3_CONFIG_DATA_TYPE_NONE; + + d = ((typeof(priv->l3cds[0]) *) tag) - (&priv->l3cds[0]); + + nm_assert(d >= 0); + nm_assert(d < _L3_CONFIG_DATA_TYPE_NUM); + nm_assert(tag == &priv->l3cds[d]); + nm_assert(tag == _dev_l3_config_data_tag_get(priv, d)); + return d; +} + +static L3ConfigDataType +_dev_l3_config_data_acd_addr_info_to_type(NMDevice * self, + const NML3AcdAddrInfo *addr_info, + guint i_track_infos) +{ + nm_assert(NM_IS_DEVICE(self)); + nm_assert(addr_info); + nm_assert(i_track_infos < addr_info->n_track_infos); + + return _dev_l3_config_data_tag_to_type(self, addr_info->track_infos[i_track_infos].tag); +} + +// FIXME(l3cfg): unused function?? +_nm_unused static const NML3AcdAddrTrackInfo * +_dev_l3_config_data_acd_addr_info_has_by_type(NMDevice * self, + const NML3AcdAddrInfo *addr_info, + L3ConfigDataType l3cd_type) +{ + guint i; + + nm_assert(NM_IS_DEVICE(self)); + nm_assert(addr_info); + nm_assert(_NM_INT_NOT_NEGATIVE(l3cd_type) && l3cd_type < _L3_CONFIG_DATA_TYPE_NUM); + + for (i = 0; i < addr_info->n_track_infos; i++) { + if (l3cd_type == _dev_l3_config_data_acd_addr_info_to_type(self, addr_info, i)) + return &addr_info->track_infos[i]; + } + return NULL; +} + +static void +_dev_l3_get_config_settings(NMDevice * self, + L3ConfigDataType type, + NML3ConfigMergeFlags *out_merge_flags, + NML3AcdDefendType * out_acd_defend_type, + guint32 * out_acd_timeout_msec) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NML3ConfigMergeFlags flags; + NMConnection * connection; + NMSettingIPConfig * s_ip; + + nm_assert(_NM_INT_NOT_NEGATIVE(type) && type < _L3_CONFIG_DATA_TYPE_NUM); + + if (G_UNLIKELY(!priv->l3config_merge_flags_has)) { + int IS_IPv4; + + connection = nm_device_get_applied_connection(self); + + for (IS_IPv4 = 0; IS_IPv4 < 2; IS_IPv4++) { + flags = NM_L3_CONFIG_MERGE_FLAGS_NONE; + + if (connection + && (s_ip = nm_connection_get_setting_ip_config(connection, + IS_IPv4 ? AF_INET : AF_INET6))) { + if (nm_setting_ip_config_get_ignore_auto_routes(s_ip)) + flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_ROUTES; + + if (nm_setting_ip_config_get_ignore_auto_dns(s_ip)) + flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_DNS; + + if (nm_setting_ip_config_get_never_default(s_ip) + || nm_setting_ip_config_get_gateway(s_ip)) { + /* if the connection has an explicit gateway, we also ignore + * the default routes from other sources. */ + flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_DEFAULT_ROUTES; } } + + priv->l3config_merge_flags_x[IS_IPv4] = flags; + } + priv->l3config_merge_flags_has = TRUE; + } + + switch (type) { + case L3_CONFIG_DATA_TYPE_DEVIP_UNSPEC: + case L3_CONFIG_DATA_TYPE_MANUALIP: + case L3_CONFIG_DATA_TYPE_LL_4: + case L3_CONFIG_DATA_TYPE_LL_6: + case L3_CONFIG_DATA_TYPE_PD_6: + case L3_CONFIG_DATA_TYPE_SHARED_4: + case L3_CONFIG_DATA_TYPE_DEVIP_4: + case L3_CONFIG_DATA_TYPE_AC_6: + case L3_CONFIG_DATA_TYPE_DHCP_6: + case L3_CONFIG_DATA_TYPE_DEVIP_6: + *out_acd_timeout_msec = _prop_get_ipv4_dad_timeout(self); + goto after_acd_timeout; + + case L3_CONFIG_DATA_TYPE_DHCP_4: + /* For DHCP, we perform ACD separately, because we want to decline the + * lease in case of a conflict. */ + *out_acd_timeout_msec = 0; + goto after_acd_timeout; + + case _L3_CONFIG_DATA_TYPE_NUM: + case _L3_CONFIG_DATA_TYPE_NONE: + case _L3_CONFIG_DATA_TYPE_ACD_ONLY: + break; + } + *out_acd_timeout_msec = nm_assert_unreachable_val(0); + +after_acd_timeout: + switch (type) { + case L3_CONFIG_DATA_TYPE_LL_4: + *out_acd_defend_type = NM_L3_ACD_DEFEND_TYPE_ONCE; + goto after_acd_defend_type; + + case L3_CONFIG_DATA_TYPE_DEVIP_UNSPEC: + case L3_CONFIG_DATA_TYPE_MANUALIP: + case L3_CONFIG_DATA_TYPE_LL_6: + case L3_CONFIG_DATA_TYPE_PD_6: + case L3_CONFIG_DATA_TYPE_SHARED_4: + case L3_CONFIG_DATA_TYPE_DHCP_4: + case L3_CONFIG_DATA_TYPE_DEVIP_4: + case L3_CONFIG_DATA_TYPE_AC_6: + case L3_CONFIG_DATA_TYPE_DHCP_6: + case L3_CONFIG_DATA_TYPE_DEVIP_6: + *out_acd_defend_type = NM_L3_ACD_DEFEND_TYPE_ALWAYS; + goto after_acd_defend_type; + + case _L3_CONFIG_DATA_TYPE_NUM: + case _L3_CONFIG_DATA_TYPE_NONE: + case _L3_CONFIG_DATA_TYPE_ACD_ONLY: + break; + } + *out_acd_defend_type = nm_assert_unreachable_val(NM_L3_ACD_DEFEND_TYPE_ALWAYS); + +after_acd_defend_type: + switch (type) { + case L3_CONFIG_DATA_TYPE_DEVIP_UNSPEC: + case L3_CONFIG_DATA_TYPE_MANUALIP: + case L3_CONFIG_DATA_TYPE_LL_4: + case L3_CONFIG_DATA_TYPE_LL_6: + case L3_CONFIG_DATA_TYPE_PD_6: + case L3_CONFIG_DATA_TYPE_SHARED_4: + *out_merge_flags = NM_L3_CONFIG_MERGE_FLAGS_NONE; + goto after_merge_flags; + + case L3_CONFIG_DATA_TYPE_DHCP_4: + case L3_CONFIG_DATA_TYPE_DEVIP_4: + *out_merge_flags = priv->l3config_merge_flags_4; + goto after_merge_flags; + + case L3_CONFIG_DATA_TYPE_AC_6: + case L3_CONFIG_DATA_TYPE_DHCP_6: + case L3_CONFIG_DATA_TYPE_DEVIP_6: + *out_merge_flags = priv->l3config_merge_flags_6; + goto after_merge_flags; + + case _L3_CONFIG_DATA_TYPE_NUM: + case _L3_CONFIG_DATA_TYPE_NONE: + case _L3_CONFIG_DATA_TYPE_ACD_ONLY: + break; + } + *out_merge_flags = nm_assert_unreachable_val(NM_L3_CONFIG_MERGE_FLAGS_NONE); + +after_merge_flags: + return; +} + +static gboolean +_dev_l3_register_l3cds_add_config(NMDevice *self, L3ConfigDataType l3cd_type) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NML3ConfigMergeFlags merge_flags; + NML3AcdDefendType acd_defend_type; + guint32 acd_timeout_msec; + + _dev_l3_get_config_settings(self, l3cd_type, &merge_flags, &acd_defend_type, &acd_timeout_msec); + return nm_l3cfg_add_config(priv->l3cfg, + _dev_l3_config_data_tag_get(priv, l3cd_type), + FALSE, + priv->l3cds[l3cd_type].d, + l3cd_type, + nm_device_get_route_table(self, AF_INET), + nm_device_get_route_table(self, AF_INET6), + nm_device_get_route_metric(self, AF_INET), + nm_device_get_route_metric(self, AF_INET6), + _dev_default_route_metric_penalty_get(self, AF_INET), + _dev_default_route_metric_penalty_get(self, AF_INET6), + _prop_get_ipvx_dns_priority(self, AF_INET), + _prop_get_ipvx_dns_priority(self, AF_INET6), + acd_defend_type, + acd_timeout_msec, + NM_L3CFG_CONFIG_FLAGS_NONE, + merge_flags); +} + +static gboolean +_dev_l3_register_l3cds_set_one(NMDevice * self, + L3ConfigDataType l3cd_type, + const NML3ConfigData *l3cd, + NMTernary commit_sync) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; + gboolean changed = FALSE; + + if (priv->l3cds[l3cd_type].d != l3cd) { + if (nm_l3_config_data_equal(priv->l3cds[l3cd_type].d, l3cd)) { + /* we would set to a different instance, but the same content! + * We keep the previous one and ignore the new @l3cd. + * + * Warning: this means, that after calling this function, + * priv->l3cds[l3cd_type].d still might point to a different + * (though semantically equal) l3cd instance. */ + } else { + l3cd_old = g_steal_pointer(&priv->l3cds[l3cd_type].d); + if (l3cd) + priv->l3cds[l3cd_type].d = nm_l3_config_data_ref_and_seal(l3cd); } } - if (priv->ip_state_x[IS_IPv4] == new_state) + if (priv->l3cfg) { + if (priv->l3cds[l3cd_type].d) { + if (_dev_l3_register_l3cds_add_config(self, l3cd_type)) + changed = TRUE; + } + + if (l3cd_old) { + if (nm_l3cfg_remove_config(priv->l3cfg, + _dev_l3_config_data_tag_get(priv, l3cd_type), + l3cd_old)) + changed = TRUE; + } + } + + if (changed && commit_sync != NM_TERNARY_DEFAULT) + _dev_l3_cfg_commit(self, !!commit_sync); + + return changed; +} + +static void +_dev_l3_update_l3cds_ifindex(NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + int ip_ifindex; + int i; + + ip_ifindex = nm_device_get_ip_ifindex(self); + if (ip_ifindex <= 0) return; - _LOGT(LOGD_DEVICE, - "ip%c-state: set to %d (%s)", - nm_utils_addr_family_to_char(addr_family), - (int) new_state, - nm_device_ip_state_to_string(new_state)); + for (i = 0; i < (int) G_N_ELEMENTS(priv->l3cds); i++) { + if (priv->l3cds[i].d && nm_l3_config_data_get_ifindex(priv->l3cds[i].d) != ip_ifindex) { + nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; - priv->ip_state_x_[IS_IPv4] = new_state; + l3cd_old = g_steal_pointer(&priv->l3cds[i].d); - if (new_state == NM_DEVICE_IP_STATE_DONE) { - /* we only set the IPx_READY flag once we reach NM_DEVICE_IP_STATE_DONE state. We don't - * ever clear it, even if we later enter NM_DEVICE_IP_STATE_FAIL state. - * - * This is not documented/guaranteed behavior, but seems to make sense for now. */ - _active_connection_set_state_flags(self, - NM_IS_IPv4(addr_family) - ? NM_ACTIVATION_STATE_FLAG_IP4_READY - : NM_ACTIVATION_STATE_FLAG_IP6_READY); + priv->l3cds[i].d = + nm_l3_config_data_seal(nm_l3_config_data_new_clone(l3cd_old, ip_ifindex)); + } } } +static gboolean +_dev_l3_register_l3cds(NMDevice *self, + NML3Cfg * l3cfg, + gboolean do_add /* else remove */, + NMTernary do_commit) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gboolean is_external; + gboolean changed; + int i; + + if (!l3cfg) + return FALSE; + + is_external = nm_device_sys_iface_state_is_external(self); + + changed = FALSE; + for (i = 0; i < (int) G_N_ELEMENTS(priv->l3cds); i++) { + if (!priv->l3cds[i].d) + continue; + if (!do_add) { + if (nm_l3cfg_remove_config(l3cfg, + _dev_l3_config_data_tag_get(priv, i), + priv->l3cds[i].d)) + changed = TRUE; + continue; + } + if (is_external) + continue; + if (_dev_l3_register_l3cds_add_config(self, i)) + changed = TRUE; + } + + if (do_commit == NM_TERNARY_DEFAULT) + do_commit = changed; + if (do_commit) + _dev_l3_cfg_commit(self, TRUE); + + return changed; +} + +/*****************************************************************************/ + +void +nm_device_l3cfg_commit(NMDevice *self, NML3CfgCommitType commit_type, gboolean commit_sync) +{ + NMDevicePrivate *priv; + + g_return_if_fail(NM_IS_DEVICE(self)); + + priv = NM_DEVICE_GET_PRIVATE(self); + + if (!priv->l3cfg) + return; + + /* FIXME(l3cfg): commit_sync should go away and not be used. The reason is that + * a commit does *a lot* of things which are outside the control of the caller, + * which makes it unsuitable to call in most cases. */ + if (!commit_sync) { + nm_l3cfg_commit_on_idle_schedule(priv->l3cfg, commit_type); + return; + } + + nm_l3cfg_commit(priv->l3cfg, commit_type); +} + +static void +_dev_l3_cfg_commit(NMDevice *self, gboolean commit_sync) +{ + nm_device_l3cfg_commit(self, NM_L3_CFG_COMMIT_TYPE_AUTO, commit_sync); +} + +static void +update_external_connection(NMDevice *self) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMSettingsConnection *settings_connection; + gs_unref_object NMConnection *connection_new = NULL; + NMConnection * connection_old; + gs_unref_object NMSetting *s_ip4_new = NULL; + gs_unref_object NMSetting *s_ip6_new = NULL; + NMSetting * s_ip4_old; + NMSetting * s_ip6_old; + + /* Update external connections with configuration from platform */ + + if (!nm_device_sys_iface_state_is_external(self)) + return; + + settings_connection = nm_device_get_settings_connection(self); + if (!settings_connection) + return; + + if (!NM_FLAGS_HAS(nm_settings_connection_get_flags(settings_connection), + NM_SETTINGS_CONNECTION_INT_FLAGS_EXTERNAL)) + return; + + if (nm_active_connection_get_activation_type(NM_ACTIVE_CONNECTION(priv->act_request.obj)) + != NM_ACTIVATION_TYPE_EXTERNAL) + return; + + connection_old = nm_settings_connection_get_connection(settings_connection); + s_ip4_old = nm_connection_get_setting(connection_old, NM_TYPE_SETTING_IP4_CONFIG); + s_ip6_old = nm_connection_get_setting(connection_old, NM_TYPE_SETTING_IP6_CONFIG); + + s_ip4_new = nm_utils_platform_capture_ip_setting(nm_device_get_platform(self), + AF_INET, + nm_device_get_ip_ifindex(self), + FALSE); + s_ip6_new = nm_utils_platform_capture_ip_setting(nm_device_get_platform(self), + AF_INET6, + nm_device_get_ip_ifindex(self), + _get_maybe_ipv6_disabled(self)); + + if (!s_ip4_old || !nm_setting_compare(s_ip4_new, s_ip4_old, NM_SETTING_COMPARE_FLAG_EXACT)) { + connection_new = nm_simple_connection_new_clone(connection_old); + nm_connection_add_setting(connection_new, g_steal_pointer(&s_ip4_new)); + } + + if (!s_ip6_old || !nm_setting_compare(s_ip6_new, s_ip6_old, NM_SETTING_COMPARE_FLAG_EXACT)) { + if (!connection_new) + connection_new = nm_simple_connection_new_clone(connection_old); + nm_connection_add_setting(connection_new, g_steal_pointer(&s_ip6_new)); + } + + if (connection_new) { + nm_settings_connection_update(settings_connection, + connection_new, + NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY, + NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, + NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, + NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET, + "update-external", + NULL); + } +} + +static void +_dev_l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + nm_assert(l3cfg == priv->l3cfg); + + switch (notify_data->notify_type) { + case NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED: + if (notify_data->l3cd_changed.commited) { + g_signal_emit(self, + signals[L3CD_CHANGED], + 0, + notify_data->l3cd_changed.l3cd_old, + notify_data->l3cd_changed.l3cd_new); + } + return; + case NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT: + { + const NML3AcdAddrInfo *addr_info = ¬ify_data->acd_event.info; + + if (addr_info->state > NM_L3_ACD_ADDR_STATE_PROBING) + _dev_ipmanual_check_ready(self); + return; + } + case NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT: + { + const NML3ConfigData *l3cd; + + /* FIXME(l3cfg): MTU handling should be moved to l3cfg. */ + l3cd = nm_l3cfg_get_combined_l3cd(l3cfg, TRUE); + if (l3cd) + priv->ip6_mtu = nm_l3_config_data_get_ip6_mtu(l3cd); + _commit_mtu(self); + return; + } + case NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT: + if (priv->ipshared_data_4.state == NM_DEVICE_IP_STATE_PENDING + && !priv->ipshared_data_4.v4.dnsmasq_manager && priv->ipshared_data_4.v4.l3cd) { + _dev_ipshared4_spawn_dnsmasq(self); + nm_clear_l3cd(&priv->ipshared_data_4.v4.l3cd); + } + _dev_ipmanual_check_ready(self); + return; + case NM_L3_CONFIG_NOTIFY_TYPE_IPV4LL_EVENT: + nm_assert(NM_IS_L3_IPV4LL(notify_data->ipv4ll_event.ipv4ll)); + if (priv->ipll_data_4.v4.ipv4ll == notify_data->ipv4ll_event.ipv4ll) + _dev_ipll4_notify_event(self); + return; + case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE: + return; + case NM_L3_CONFIG_NOTIFY_TYPE_ROUTES_TEMPORARY_NOT_AVAILABLE_EXPIRED: + /* we commit again. This way we try to configure the routes.*/ + _dev_l3_cfg_commit(self, FALSE); + return; + case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE: + if (NM_FLAGS_ANY(notify_data->platform_change_on_idle.obj_type_flags, + nmp_object_type_to_flags(NMP_OBJECT_TYPE_LINK) + | nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP4_ADDRESS) + | nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP6_ADDRESS))) + _dev_unamanged_check_external_down(self, TRUE); + _dev_ipmanual_check_ready(self); + update_external_connection(self); + return; + + case _NM_L3_CONFIG_NOTIFY_TYPE_NUM: + break; + } + nm_assert_not_reached(); +} + +static void +_dev_l3_cfg_commit_type_reset(NMDevice *self) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NML3CfgCommitType commit_type; + + if (!priv->l3cfg) + return; + + switch (priv->sys_iface_state) { + case NM_DEVICE_SYS_IFACE_STATE_EXTERNAL: + case NM_DEVICE_SYS_IFACE_STATE_REMOVED: + commit_type = NM_L3_CFG_COMMIT_TYPE_NONE; + goto do_set; + case NM_DEVICE_SYS_IFACE_STATE_ASSUME: + commit_type = NM_L3_CFG_COMMIT_TYPE_ASSUME; + goto do_set; + case NM_DEVICE_SYS_IFACE_STATE_MANAGED: + commit_type = NM_L3_CFG_COMMIT_TYPE_UPDATE; + goto do_set; + } + nm_assert_not_reached(); + return; + +do_set: + priv->l3cfg_commit_type = + nm_l3cfg_commit_type_register(priv->l3cfg, commit_type, priv->l3cfg_commit_type, "device"); +} + /*****************************************************************************/ const char * @@ -2973,11 +3947,18 @@ nm_device_get_iface(NMDevice *self) static gboolean _set_ifindex(NMDevice *self, int ifindex, gboolean is_ip_ifindex) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - int * p_ifindex; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gs_unref_object NML3Cfg *l3cfg_old = NULL; + NML3CfgCommitTypeHandle *l3cfg_commit_type_old = NULL; + gboolean l3_changed; + int ip_ifindex_new; + int * p_ifindex; + gboolean l3cfg_was_reset = FALSE; - if (ifindex < 0) + if (ifindex < 0) { + nm_assert_not_reached(); ifindex = 0; + } p_ifindex = is_ip_ifindex ? &priv->ip_ifindex_ : &priv->ifindex_; @@ -2986,13 +3967,90 @@ _set_ifindex(NMDevice *self, int ifindex, gboolean is_ip_ifindex) *p_ifindex = ifindex; - _LOGD(LOGD_DEVICE, "ifindex: set %sifindex %d", is_ip_ifindex ? "ip-" : "", ifindex); + ip_ifindex_new = nm_device_get_ip_ifindex(self); + + if (priv->l3cfg) { + if (ip_ifindex_new <= 0 || ip_ifindex_new != nm_l3cfg_get_ifindex(priv->l3cfg)) { + g_signal_handlers_disconnect_by_func(priv->l3cfg, + G_CALLBACK(_dev_l3_cfg_notify_cb), + self); + l3cfg_old = g_steal_pointer(&priv->l3cfg_); + l3cfg_commit_type_old = g_steal_pointer(&priv->l3cfg_commit_type); + l3cfg_was_reset = TRUE; + } + } + if (!priv->l3cfg && ip_ifindex_new > 0) { + priv->l3cfg_ = nm_netns_l3cfg_acquire(priv->netns, ip_ifindex_new); + + g_signal_connect(priv->l3cfg, + NM_L3CFG_SIGNAL_NOTIFY, + G_CALLBACK(_dev_l3_cfg_notify_cb), + self); + + _dev_l3_cfg_commit_type_reset(self); + l3cfg_was_reset = TRUE; + } + + _LOGD(LOGD_DEVICE, + "ifindex: set %sifindex %d%s%s%s%s%s%s", + is_ip_ifindex ? "ip-" : "", + ifindex, + NM_PRINT_FMT_QUOTED(l3cfg_old && l3cfg_old != priv->l3cfg, + " (old-l3cfg: ", + nm_hash_obfuscated_ptr_str_a(l3cfg_old), + ")", + ""), + NM_PRINT_FMT_QUOTED(priv->l3cfg && l3cfg_old != priv->l3cfg, + " (l3cfg: ", + nm_hash_obfuscated_ptr_str_a(priv->l3cfg), + ")", + "")); + + if (priv->manager) + nm_manager_emit_device_ifindex_changed(priv->manager, self); if (!is_ip_ifindex) _notify(self, PROP_IFINDEX); - if (priv->manager) - nm_manager_emit_device_ifindex_changed(priv->manager, self); + if (l3cfg_was_reset) { + gs_unref_object NMIPConfig *ipconf_old_4 = NULL; + gs_unref_object NMIPConfig *ipconf_old_6 = NULL; + + ipconf_old_4 = g_steal_pointer(&priv->l3ipdata_4.ip_config); + ipconf_old_6 = g_steal_pointer(&priv->l3ipdata_6.ip_config); + if (priv->l3cfg) { + priv->l3ipdata_4.ip_config = nm_l3cfg_ipconfig_acquire(priv->l3cfg, AF_INET); + priv->l3ipdata_6.ip_config = nm_l3cfg_ipconfig_acquire(priv->l3cfg, AF_INET6); + } + _notify(self, PROP_IP4_CONFIG); + _notify(self, PROP_IP6_CONFIG); + } + + if (l3cfg_old != priv->l3cfg) { + l3_changed = FALSE; + if (_dev_l3_register_l3cds(self, l3cfg_old, FALSE, FALSE)) + l3_changed = TRUE; + + /* Now it gets ugly. We changed the ip-ifindex, which determines the NML3Cfg instance. + * But all the NML3ConfigData we currently track are still for the old ifindex. We + * need to update them. + * + * This should be all handled entirely different, where an NMDevice is strictly + * associated with one ifindex (and not the ifindex/ip-ifindex split). Or it + * is not at all associated with an ifindex, but only a controlling device for + * a real NMDevice (that has the ifindex). */ + _dev_l3_update_l3cds_ifindex(self); + + if (_dev_l3_register_l3cds(self, priv->l3cfg, TRUE, FALSE)) + l3_changed = TRUE; + + if (l3_changed) + _dev_l3_cfg_commit(self, TRUE); + } + + if (l3cfg_commit_type_old) + nm_l3cfg_commit_type_unregister(l3cfg_old, l3cfg_commit_type_old); + return TRUE; } @@ -3159,13 +4217,12 @@ _set_ip_ifindex(NMDevice *self, int ifindex, const char *ifname) NM_PRINT_FMT_QUOTE_STRING(ifname), ifindex); - _set_ifindex(self, ifindex, TRUE); - if (!eq_name) { g_free(priv->ip_iface_); priv->ip_iface_ = g_strdup(ifname); _notify(self, PROP_IP_IFACE); } + _set_ifindex(self, ifindex, TRUE); if (priv->ip_ifindex > 0) { platform = nm_device_get_platform(self); @@ -3729,8 +4786,10 @@ nm_device_get_route_metric_default(NMDeviceType device_type) return 11000; } -static gboolean -default_route_metric_penalty_detect(NMDevice *self, int addr_family) +/* FIXME(l3cfg): we currently never call this function. We need to react + * to changes and re-commit the IP configuration with updated penalty. */ +_nm_unused static gboolean +_dev_default_route_metric_penalty_detect(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const int IS_IPv4 = NM_IS_IPv4(addr_family); @@ -3745,7 +4804,7 @@ default_route_metric_penalty_detect(NMDevice *self, int addr_family) } static guint32 -default_route_metric_penalty_get(NMDevice *self, int addr_family) +_dev_default_route_metric_penalty_get(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); @@ -3813,28 +4872,23 @@ nm_device_get_route_table(NMDevice *self, int addr_family) return route_table ?: (guint32) RT_TABLE_MAIN; } -static NMIPRouteTableSyncMode +/* FIXME(l3cfg): need to properly handle the route-table sync mode and + * use it during commit. */ +_nm_unused static NMIPRouteTableSyncMode _get_route_table_sync_mode_stateful(NMDevice *self, int addr_family) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMDedupMultiIter ipconf_iter; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean all_sync_now; gboolean all_sync_eff; all_sync_now = _prop_get_ipvx_route_table(self, addr_family) != 0u; if (!all_sync_now) { - const NMPlatformIPRoute *route; + const NML3ConfigData *l3cd = priv->l3cds[L3_CONFIG_DATA_TYPE_MANUALIP].d; /* If there's a local route switch to all-sync in order * to properly manage the local table */ - nm_ip_config_iter_ip_route_for_each (&ipconf_iter, priv->con_ip_config_x[IS_IPv4], &route) { - if (nm_platform_route_type_uncoerce(route->type_coerced) == RTN_LOCAL) { - all_sync_now = TRUE; - break; - } - } + all_sync_now = l3cd && nm_l3_config_data_has_routes_with_type_local(l3cd, addr_family); } if (all_sync_now) @@ -3866,18 +4920,20 @@ nm_device_get_best_default_route(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - switch (addr_family) { - case AF_INET: - return priv->ip_config_4 ? nm_ip4_config_best_default_route_get(priv->ip_config_4) : NULL; - case AF_INET6: - return priv->ip_config_6 ? nm_ip6_config_best_default_route_get(priv->ip_config_6) : NULL; - case AF_UNSPEC: - return (priv->ip_config_4 ? nm_ip4_config_best_default_route_get(priv->ip_config_4) : NULL) - ?: (priv->ip_config_6 ? nm_ip6_config_best_default_route_get(priv->ip_config_6) - : NULL); - default: - g_return_val_if_reached(NULL); - } + if (!priv->l3cfg) + return NULL; + + /* FIXME(l3cfg): this function returns the best default route that we + * *want* to configure. What is the meaning of that? Possibly the caller + * cares whether there *is* a default route configured, for which they + * should ask platform. + * + * Check callers why they call this. Quite possibly this whole notion of + * "has a default route" is wrong to being with, regardless whether we + * look at the desired or actual configuration. That is, because "has a default route" + * does not do justice to the complexity of routing (with policy routing, + * etc.). */ + return nm_l3cfg_get_best_default_route(priv->l3cfg, addr_family, TRUE); } const char * @@ -4432,14 +5488,8 @@ concheck_update_state(NMDevice * self, _notify(self, IS_IPv4 ? PROP_IP4_CONNECTIVITY : PROP_IP6_CONNECTIVITY); - if (priv->state == NM_DEVICE_STATE_ACTIVATED && !nm_device_sys_iface_state_is_external(self)) { - if (nm_device_get_best_default_route(self, AF_INET) - && !ip_config_merge_and_apply(self, AF_INET, TRUE)) - _LOGW(LOGD_IP4, "Failed to update IPv4 route metric"); - if (nm_device_get_best_default_route(self, AF_INET6) - && !ip_config_merge_and_apply(self, AF_INET6, TRUE)) - _LOGW(LOGD_IP6, "Failed to update IPv6 route metric"); - } + if (priv->state == NM_DEVICE_STATE_ACTIVATED && !nm_device_sys_iface_state_is_external(self)) + _dev_l3_register_l3cds(self, priv->l3cfg, TRUE, NM_TERNARY_DEFAULT); } static const char * @@ -4774,16 +5824,14 @@ find_slave_info(NMDevice *self, NMDevice *slave) static gboolean nm_device_master_enslave_slave(NMDevice *self, NMDevice *slave, NMConnection *connection) { - NMDevicePrivate *priv; - SlaveInfo * info; - gboolean success = FALSE; - gboolean configure; + SlaveInfo *info; + gboolean success = FALSE; + gboolean configure; g_return_val_if_fail(self != NULL, FALSE); g_return_val_if_fail(slave != NULL, FALSE); g_return_val_if_fail(NM_DEVICE_GET_CLASS(self)->enslave_slave != NULL, FALSE); - priv = NM_DEVICE_GET_PRIVATE(self); info = find_slave_info(self, slave); if (!info) return FALSE; @@ -4806,22 +5854,17 @@ nm_device_master_enslave_slave(NMDevice *self, NMDevice *slave, NMConnection *co */ nm_device_update_hw_address(self); + /* Since slave devices don't have their own IP configuration, + * set the MTU here. + */ + _commit_mtu(slave); + /* Restart IP configuration if we're waiting for slaves. Do this * after updating the hardware address as IP config may need the * new address. */ - if (success) { - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_WAIT) - nm_device_activate_stage3_ip_start(self, AF_INET); - - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_WAIT) - nm_device_activate_stage3_ip_start(self, AF_INET6); - } - - /* Since slave devices don't have their own IP configuration, - * set the MTU here. - */ - _commit_mtu(slave, NM_DEVICE_GET_PRIVATE(slave)->ip_config_4); + if (success) + nm_device_activate_schedule_stage3_ip_config(self, FALSE); return success; } @@ -4908,6 +5951,8 @@ nm_device_master_release_one_slave(NMDevice * self, NM_DEVICE_STATE_REASON_REMOVED); } +/*****************************************************************************/ + /** * can_unmanaged_external_down: * @self: the device @@ -4922,7 +5967,7 @@ can_unmanaged_external_down(NMDevice *self) } static NMUnmanFlagOp -is_unmanaged_external_down(NMDevice *self, gboolean consider_can) +_dev_unmanaged_is_external_down(NMDevice *self, gboolean consider_can) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); @@ -4939,7 +5984,7 @@ is_unmanaged_external_down(NMDevice *self, gboolean consider_can) } static void -set_unmanaged_external_down(NMDevice *self, gboolean only_if_unmanaged) +_dev_unamanged_check_external_down(NMDevice *self, gboolean only_if_unmanaged) { NMUnmanFlagOp ext_flags; @@ -4951,7 +5996,7 @@ set_unmanaged_external_down(NMDevice *self, gboolean only_if_unmanaged) return; } - ext_flags = is_unmanaged_external_down(self, FALSE); + ext_flags = _dev_unmanaged_is_external_down(self, FALSE); if (ext_flags != NM_UNMAN_FLAG_OP_SET_UNMANAGED) { /* Ensure the assume check is queued before any queued state changes * from the transition to UNAVAILABLE. @@ -4979,26 +6024,15 @@ nm_device_update_dynamic_ip_setup(NMDevice *self) g_hash_table_remove_all(priv->ip6_saved_properties); - if (priv->dhcp_data_4.client) { - if (!nm_device_dhcp4_renew(self, FALSE)) { - nm_device_state_changed(self, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_DHCP_FAILED); - return; - } - } - if (priv->dhcp_data_6.client) { - if (!nm_device_dhcp6_renew(self, FALSE)) { - nm_device_state_changed(self, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_DHCP_FAILED); - return; - } - } - if (priv->ndisc) { + if (priv->ipdhcp_data_4.state != NM_DEVICE_IP_STATE_NONE) + _dev_ipdhcpx_restart(self, AF_INET, FALSE); + if (priv->ipdhcp_data_6.state != NM_DEVICE_IP_STATE_NONE) + _dev_ipdhcpx_restart(self, AF_INET6, FALSE); + + if (priv->ipac6_data.ndisc) { /* FIXME: todo */ } - if (priv->dnsmasq_manager) { + if (priv->ipshared_data_4.v4.dnsmasq_manager) { /* FIXME: todo */ } } @@ -5033,10 +6067,7 @@ carrier_changed(NMDevice *self, gboolean carrier) nm_device_update_dynamic_ip_setup(self); /* If needed, also resume IP configuration that is * waiting for carrier. */ - if (nm_device_activate_ip4_state_in_wait(self)) - nm_device_activate_stage3_ip_start(self, AF_INET); - if (nm_device_activate_ip6_state_in_wait(self)) - nm_device_activate_stage3_ip_start(self, AF_INET6); + nm_device_activate_schedule_stage3_ip_config(self, FALSE); return; } /* fall-through and change state of device */ @@ -5134,10 +6165,6 @@ nm_device_set_carrier(NMDevice *self, gboolean carrier) nm_device_remove_pending_action(self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE); _carrier_wait_check_queued_act_request(self); } - - /* Send ARP announcements if did not yet and have carrier. */ - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE && !priv->acd.announcing) - nm_device_arp_announce(self); } else { if (priv->carrier_wait_id) nm_device_add_pending_action(self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE); @@ -5268,85 +6295,6 @@ device_ifindex_changed_cb(NMManager *manager, NMDevice *device_changed, NMDevice priv->device_link_changed_id = g_idle_add((GSourceFunc) device_link_changed, self); } -static void -ndisc_set_router_config(NMNDisc *ndisc, NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - gs_unref_array GArray *addresses = NULL; - gs_unref_array GArray *dns_servers = NULL; - gs_unref_array GArray * dns_domains = NULL; - guint len; - guint i; - const NMDedupMultiHeadEntry *head_entry; - NMDedupMultiIter ipconf_iter; - - if (nm_ndisc_get_node_type(ndisc) != NM_NDISC_NODE_TYPE_ROUTER) - return; - - head_entry = nm_ip6_config_lookup_addresses(priv->ip_config_6); - addresses = - g_array_sized_new(FALSE, TRUE, sizeof(NMNDiscAddress), head_entry ? head_entry->len : 0); - nm_dedup_multi_iter_for_each (&ipconf_iter, head_entry) { - const NMPlatformIP6Address *addr = NMP_OBJECT_CAST_IP6_ADDRESS(ipconf_iter.current->obj); - NMNDiscAddress * ndisc_addr; - guint32 lifetime; - guint32 preferred; - - if (IN6_IS_ADDR_UNSPECIFIED(&addr->address) || IN6_IS_ADDR_LINKLOCAL(&addr->address)) - continue; - - if (addr->n_ifa_flags & IFA_F_TENTATIVE || addr->n_ifa_flags & IFA_F_DADFAILED) - continue; - - if (addr->plen != 64) - continue; - - lifetime = nmp_utils_lifetime_get(addr->timestamp, - addr->lifetime, - addr->preferred, - NM_NDISC_EXPIRY_BASE_TIMESTAMP / 1000, - &preferred); - if (!lifetime) - continue; - - g_array_set_size(addresses, addresses->len + 1); - ndisc_addr = &g_array_index(addresses, NMNDiscAddress, addresses->len - 1); - ndisc_addr->address = addr->address; - ndisc_addr->expiry_msec = - _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, lifetime); - ndisc_addr->expiry_preferred_msec = - _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, preferred); - } - - len = nm_ip6_config_get_num_nameservers(priv->ip_config_6); - dns_servers = g_array_sized_new(FALSE, TRUE, sizeof(NMNDiscDNSServer), len); - g_array_set_size(dns_servers, len); - for (i = 0; i < len; i++) { - const struct in6_addr *nameserver = nm_ip6_config_get_nameserver(priv->ip_config_6, i); - NMNDiscDNSServer * ndisc_nameserver; - - ndisc_nameserver = &g_array_index(dns_servers, NMNDiscDNSServer, i); - ndisc_nameserver->address = *nameserver; - ndisc_nameserver->expiry_msec = - _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, NM_NDISC_ROUTER_LIFETIME); - } - - len = nm_ip6_config_get_num_searches(priv->ip_config_6); - dns_domains = g_array_sized_new(FALSE, TRUE, sizeof(NMNDiscDNSDomain), len); - g_array_set_size(dns_domains, len); - for (i = 0; i < len; i++) { - const char * search = nm_ip6_config_get_search(priv->ip_config_6, i); - NMNDiscDNSDomain *ndisc_search; - - ndisc_search = &g_array_index(dns_domains, NMNDiscDNSDomain, i); - ndisc_search->domain = (char *) search; - ndisc_search->expiry_msec = - _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, NM_NDISC_ROUTER_LIFETIME); - } - - nm_ndisc_set_config(ndisc, addresses, dns_servers, dns_domains); -} - static void device_update_interface_flags(NMDevice *self, const NMPlatformLink *plink) { @@ -5378,8 +6326,9 @@ device_update_interface_flags(NMDevice *self, const NMPlatformLink *plink) } static gboolean -device_link_changed(NMDevice *self) +device_link_changed(gpointer user_data) { + NMDevice * self = user_data; NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); gboolean ip_ifname_changed = FALSE; @@ -5464,8 +6413,8 @@ device_link_changed(NMDevice *self) nm_device_emit_recheck_auto_activate(self); } - if (priv->ndisc && pllink->inet6_token.id) { - if (nm_ndisc_set_iid(priv->ndisc, pllink->inet6_token)) + if (priv->ipac6_data.ndisc && pllink->inet6_token.id) { + if (nm_ndisc_set_iid(priv->ipac6_data.ndisc, pllink->inet6_token)) _LOGD(LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface); } @@ -5512,23 +6461,22 @@ device_link_changed(NMDevice *self) nm_device_set_unmanaged_by_flags(self, NM_UNMANAGED_PLATFORM_INIT, FALSE, reason); } - set_unmanaged_external_down(self, FALSE); + _dev_unamanged_check_external_down(self, FALSE); device_recheck_slave_status(self, pllink); if (priv->up && (!was_up || seen_down)) { /* the link was down and just came up. That happens for example, while changing MTU. - * We must restore IP configuration. */ - if (NM_IN_SET(priv->ip_state_4, NM_DEVICE_IP_STATE_CONF, NM_DEVICE_IP_STATE_DONE)) { - if (!ip_config_merge_and_apply(self, AF_INET, TRUE)) - _LOGW(LOGD_IP4, "failed applying IP4 config after link comes up again"); - } - - priv->linklocal6_dad_counter = 0; - if (NM_IN_SET(priv->ip_state_6, NM_DEVICE_IP_STATE_CONF, NM_DEVICE_IP_STATE_DONE)) { - if (!ip_config_merge_and_apply(self, AF_INET6, TRUE)) - _LOGW(LOGD_IP6, "failed applying IP6 config after link comes up again"); - } + * We must restore IP configuration. + * + * FIXME(l3cfg): when NML3Cfg notices that the device goes down and up, then + * it should automatically schedule a REAPPLY commit -- provided that the current + * commit-type is >= UPDATE. The idea is to move logic away from NMDevice + * so that it theoretically would also work for NMVpnConnection (although, + * NMVpnConnection should become like a regular device, akin to NMDevicePpp). + */ + if (!nm_device_sys_iface_state_is_external(self)) + nm_device_l3cfg_commit(self, NM_L3_CFG_COMMIT_TYPE_REAPPLY, FALSE); } if (update_unmanaged_specs) @@ -5550,8 +6498,9 @@ device_link_changed(NMDevice *self) } static gboolean -device_ip_link_changed(NMDevice *self) +device_ip_link_changed(gpointer user_data) { + NMDevice * self = user_data; NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); const NMPlatformLink *pllink; const char * ip_iface; @@ -5614,13 +6563,12 @@ link_changed_cb(NMPlatform * platform, if (!(info->n_ifi_flags & IFF_UP)) priv->device_link_changed_down = TRUE; if (!priv->device_link_changed_id) { - priv->device_link_changed_id = g_idle_add((GSourceFunc) device_link_changed, self); + priv->device_link_changed_id = g_idle_add(device_link_changed, self); _LOGD(LOGD_DEVICE, "queued link change for ifindex %d", ifindex); } } else if (ifindex == nm_device_get_ip_ifindex(self)) { if (!priv->device_ip_link_changed_id) { - priv->device_ip_link_changed_id = - g_idle_add((GSourceFunc) device_ip_link_changed, self); + priv->device_ip_link_changed_id = g_idle_add(device_ip_link_changed, self); _LOGD(LOGD_DEVICE, "queued link change for ip-ifindex %d", ifindex); } } @@ -6072,8 +7020,6 @@ realize_start_setup(NMDevice * self, g_return_if_fail(nm_device_get_unmanaged_flags(self, NM_UNMANAGED_PLATFORM_INIT)); g_return_if_fail(priv->ip_ifindex <= 0); g_return_if_fail(priv->ip_iface == NULL); - g_return_if_fail(!priv->queued_ip_config_id_4); - g_return_if_fail(!priv->queued_ip_config_id_6); _LOGD(LOGD_DEVICE, "start setup of %s, kernel ifindex %d", @@ -6120,9 +7066,6 @@ realize_start_setup(NMDevice * self, if (priv->firmware_version) _notify(self, PROP_FIRMWARE_VERSION); - priv->ipv6ll_handle = (nm_platform_link_get_inet6_addr_gen_mode(platform, priv->ifindex) - == NM_IN6_ADDR_GEN_MODE_NONE); - if (nm_platform_link_supports_sriov(platform, priv->ifindex)) capabilities |= NM_DEVICE_CAP_SRIOV; } @@ -6180,7 +7123,7 @@ realize_start_setup(NMDevice * self, * or have IP addressing */ nm_device_set_unmanaged_flags(self, NM_UNMANAGED_EXTERNAL_DOWN, - is_unmanaged_external_down(self, TRUE)); + _dev_unmanaged_is_external_down(self, TRUE)); /* Unmanaged the loopback device with an explicit NM_UNMANAGED_BY_TYPE flag. * Later we might want to manage 'lo' too. Currently, that doesn't work because @@ -6219,9 +7162,6 @@ nm_device_realize_finish(NMDevice *self, const NMPlatformLink *plink) if (plink) device_recheck_slave_status(self, plink); - priv->update_ip_config_completed_v4 = FALSE; - priv->update_ip_config_completed_v6 = FALSE; - priv->real = TRUE; _notify(self, PROP_REAL); @@ -6317,9 +7257,6 @@ nm_device_unrealize(NMDevice *self, gboolean remove_resources, GError **error) } } - nm_clear_g_source(&priv->queued_ip_config_id_4); - nm_clear_g_source(&priv->queued_ip_config_id_6); - g_object_freeze_notify(G_OBJECT(self)); NM_DEVICE_GET_CLASS(self)->unrealize_notify(self); @@ -6683,117 +7620,6 @@ nm_device_get_master(NMDevice *self) return NULL; } -static gboolean -get_ip_config_may_fail(NMDevice *self, int addr_family) -{ - NMConnection * connection; - NMSettingIPConfig *s_ip; - - connection = nm_device_get_applied_connection(self); - - s_ip = nm_connection_get_setting_ip_config(connection, addr_family); - - return !s_ip || nm_setting_ip_config_get_may_fail(s_ip); -} - -/* - * check_ip_state - * - * When @full_state_update is TRUE, transition the device from IP_CONFIG to the - * next state according to the outcome of IPv4 and IPv6 configuration. @may_fail - * indicates that we are called just after the initial configuration and thus - * IPv4/IPv6 are allowed to fail if the ipvx.may-fail properties say so, because - * the IP methods couldn't even be started. - * If @full_state_update is FALSE, just check if the connection should be failed - * due to the state of both ip families and the ipvx.may-fail settings. - */ -static void -check_ip_state(NMDevice *self, gboolean may_fail, gboolean full_state_update) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - gboolean ip4_disabled = FALSE, ip6_disabled = FALSE; - NMSettingIPConfig *s_ip4, *s_ip6; - NMDeviceState state; - int IS_IPv4; - - if (full_state_update && nm_device_get_state(self) != NM_DEVICE_STATE_IP_CONFIG) - return; - - /* Don't progress into IP_CHECK or SECONDARIES if we're waiting for the - * master to enslave us. */ - if (nm_active_connection_get_master(NM_ACTIVE_CONNECTION(priv->act_request.obj)) - && !priv->is_enslaved) - return; - - s_ip4 = nm_device_get_applied_setting(self, NM_TYPE_SETTING_IP4_CONFIG); - if (s_ip4 - && nm_streq0(nm_setting_ip_config_get_method(s_ip4), NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) - ip4_disabled = TRUE; - - s_ip6 = nm_device_get_applied_setting(self, NM_TYPE_SETTING_IP6_CONFIG); - if (s_ip6 - && NM_IN_STRSET(nm_setting_ip_config_get_method(s_ip6), - NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) - ip6_disabled = TRUE; - - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE - && priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE) { - /* Both method completed (or disabled), proceed with activation */ - nm_device_state_changed(self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE); - return; - } - - for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { - if (priv->ip_state_x[IS_IPv4] == NM_DEVICE_IP_STATE_CONF - && priv->ip_req_timeout_source_x[IS_IPv4]) { - return; - } - } - - if ((priv->ip_state_4 == NM_DEVICE_IP_STATE_FAIL - || (ip4_disabled && priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE)) - && (priv->ip_state_6 == NM_DEVICE_IP_STATE_FAIL - || (ip6_disabled && priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE))) { - /* Either both methods failed, or only one failed and the other is - * disabled */ - if (nm_device_sys_iface_state_is_external_or_assume(self)) { - /* We have assumed configuration, but couldn't redo it. No problem, - * move to check state. */ - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_DONE); - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_DONE); - state = NM_DEVICE_STATE_IP_CHECK; - } else if (may_fail && get_ip_config_may_fail(self, AF_INET) - && get_ip_config_may_fail(self, AF_INET6)) { - /* Couldn't start either IPv6 and IPv4 autoconfiguration, - * but both are allowed to fail. */ - state = NM_DEVICE_STATE_SECONDARIES; - } else { - /* Autoconfiguration attempted without success. */ - state = NM_DEVICE_STATE_FAILED; - } - - if (full_state_update || state == NM_DEVICE_STATE_FAILED) { - nm_device_state_changed(self, state, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } - return; - } - - /* If a method is still pending but required, wait */ - if (priv->ip_state_4 != NM_DEVICE_IP_STATE_DONE && !get_ip_config_may_fail(self, AF_INET)) - return; - if (priv->ip_state_6 != NM_DEVICE_IP_STATE_DONE && !get_ip_config_may_fail(self, AF_INET6)) - return; - - /* If at least a method has completed, proceed with activation */ - if ((priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE && !ip4_disabled) - || (priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE && !ip6_disabled)) { - if (full_state_update) - nm_device_state_changed(self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE); - return; - } -} - /** * nm_device_slave_notify_enslave: * @self: the slave device @@ -6833,13 +7659,17 @@ nm_device_slave_notify_enslave(NMDevice *self, gboolean success) } } - if (activating) { - if (success) - check_ip_state(self, FALSE, TRUE); - else - nm_device_queue_state(self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_UNKNOWN); - } else + if (!activating) { nm_device_queue_recheck_assume(self); + return; + } + + if (!success) { + nm_device_queue_state(self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_UNKNOWN); + return; + } + + nm_device_activate_schedule_stage3_ip_config(self, FALSE); } /** @@ -6913,6 +7743,9 @@ nm_device_removed(NMDevice *self, gboolean unconfigure_ip_config) g_return_if_fail(NM_IS_DEVICE(self)); + _dev_ipdhcpx_cleanup(self, AF_INET, TRUE, FALSE); + _dev_ipdhcpx_cleanup(self, AF_INET6, TRUE, FALSE); + priv = NM_DEVICE_GET_PRIVATE(self); if (priv->master) { /* this is called when something externally messes with the slave or during shut-down. @@ -6924,15 +7757,7 @@ nm_device_removed(NMDevice *self, gboolean unconfigure_ip_config) NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); } - if (unconfigure_ip_config) { - nm_device_set_ip_config(self, AF_INET, NULL, FALSE, NULL); - nm_device_set_ip_config(self, AF_INET6, NULL, FALSE, NULL); - } else { - if (priv->dhcp_data_4.client) - nm_dhcp_client_stop(priv->dhcp_data_4.client, FALSE); - if (priv->dhcp_data_6.client) - nm_dhcp_client_stop(priv->dhcp_data_6.client, FALSE); - } + _dev_l3_register_l3cds(self, priv->l3cfg, FALSE, unconfigure_ip_config); } static gboolean @@ -7190,22 +8015,36 @@ nm_device_can_auto_connect(NMDevice *self, NMSettingsConnection *sett_conn, char static gboolean device_has_config(NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + const NMDedupMultiHeadEntry *head_entry; + const NMPlatformLink * pllink; + NMPLookup lookup; - /* Check for IP configuration. */ - if (priv->ip_config_4 && nm_ip4_config_get_num_addresses(priv->ip_config_4)) + pllink = nm_l3cfg_get_pllink(priv->l3cfg, TRUE); + if (!pllink) + return FALSE; + + if (pllink->master > 0) { + /* Master-slave relationship is also a configuration */ return TRUE; - if (priv->ip_config_6 && nm_ip6_config_get_num_addresses(priv->ip_config_6)) + } + + head_entry = nm_platform_lookup( + nm_device_get_platform(self), + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP4_ADDRESS, pllink->ifindex)); + if (head_entry) return TRUE; - /* The existence of a software device is good enough. */ - if (nm_device_is_software(self) && nm_device_is_real(self)) + head_entry = nm_platform_lookup( + nm_device_get_platform(self), + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP6_ADDRESS, pllink->ifindex)); + if (head_entry) return TRUE; - /* Master-slave relationship is also a configuration */ - if (!c_list_is_empty(&priv->slaves) - || nm_platform_link_get_master(nm_device_get_platform(self), priv->ifindex) > 0) + if (nm_device_is_software(self) && nm_device_is_real(self)) { + /* The existence of a software device is good enough. */ return TRUE; + } return FALSE; } @@ -7363,10 +8202,16 @@ nm_device_generate_connection(NMDevice *self, } } else { /* Only regular and master devices get IP configuration; slaves do not */ - s_ip4 = nm_ip4_config_create_setting(priv->ip_config_4); + s_ip4 = nm_utils_platform_capture_ip_setting(nm_device_get_platform(self), + AF_INET, + nm_device_get_ip_ifindex(self), + FALSE); nm_connection_add_setting(connection, s_ip4); - s_ip6 = nm_ip6_config_create_setting(priv->ip_config_6, _get_maybe_ipv6_disabled(self)); + s_ip6 = nm_utils_platform_capture_ip_setting(nm_device_get_platform(self), + AF_INET6, + nm_device_get_ip_ifindex(self), + _get_maybe_ipv6_disabled(self)); nm_connection_add_setting(connection, s_ip6); nm_connection_add_setting(connection, nm_setting_proxy_new()); @@ -7832,20 +8677,6 @@ nm_device_emit_recheck_auto_activate(NMDevice *self) g_signal_emit(self, signals[RECHECK_AUTO_ACTIVATE], 0); } -static void -dnsmasq_state_changed_cb(NMDnsMasqManager *manager, guint32 status, gpointer user_data) -{ - NMDevice *self = NM_DEVICE(user_data); - - switch (status) { - case NM_DNSMASQ_STATUS_DEAD: - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_SHARED_START_FAILED); - break; - default: - break; - } -} - void nm_device_auth_request(NMDevice * self, GDBusMethodInvocation * context, @@ -7870,148 +8701,112 @@ nm_device_auth_request(NMDevice * self, /*****************************************************************************/ static void -activation_source_clear(NMDevice *self, int addr_family) +activation_source_clear(NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (priv->activation_source_id_x[IS_IPv4] != 0) { + if (nm_clear_g_source_inst(&priv->activation_idle_source)) { _LOGD(LOGD_DEVICE, - "activation-stage: clear %s,v%c (id %u)", - _activation_func_to_string(priv->activation_source_func_x[IS_IPv4]), - nm_utils_addr_family_to_char(addr_family), - priv->activation_source_id_x[IS_IPv4]); - nm_clear_g_source(&priv->activation_source_id_x[IS_IPv4]); - priv->activation_source_func_x[IS_IPv4] = NULL; + "activation-stage: clear %s", + _activation_func_to_string(priv->activation_func)); + priv->activation_func = NULL; } } static gboolean -activation_source_handle_cb(NMDevice *self, int addr_family) +activation_source_handle_cb(gpointer user_data) { + NMDevice * self = user_data; NMDevicePrivate * priv; - const int IS_IPv4 = NM_IS_IPv4(addr_family); - ActivationHandleFunc activation_source_func; - guint activation_source_id; + ActivationHandleFunc activation_func; g_return_val_if_fail(NM_IS_DEVICE(self), G_SOURCE_REMOVE); priv = NM_DEVICE_GET_PRIVATE(self); - activation_source_func = priv->activation_source_func_x[IS_IPv4]; - activation_source_id = priv->activation_source_id_x[IS_IPv4]; + g_return_val_if_fail(priv->activation_idle_source, G_SOURCE_REMOVE); - g_return_val_if_fail(activation_source_id != 0, G_SOURCE_REMOVE); - nm_assert(activation_source_func); + nm_assert(priv->activation_func); - priv->activation_source_func_x[IS_IPv4] = NULL; - priv->activation_source_id_x[IS_IPv4] = 0; + activation_func = priv->activation_func; + priv->activation_func = NULL; - _LOGD(LOGD_DEVICE, - "activation-stage: invoke %s,v%c (id %u)", - _activation_func_to_string(activation_source_func), - nm_utils_addr_family_to_char(addr_family), - activation_source_id); + nm_clear_g_source_inst(&priv->activation_idle_source); - activation_source_func(self); + _LOGD(LOGD_DEVICE, "activation-stage: invoke %s", _activation_func_to_string(activation_func)); - _LOGT(LOGD_DEVICE, - "activation-stage: complete %s,v%c (id %u)", - _activation_func_to_string(activation_source_func), - nm_utils_addr_family_to_char(addr_family), - activation_source_id); + activation_func(self); - return G_SOURCE_REMOVE; -} - -static gboolean -activation_source_handle_cb_4(gpointer user_data) -{ - return activation_source_handle_cb(user_data, AF_INET); -} - -static gboolean -activation_source_handle_cb_6(gpointer user_data) -{ - return activation_source_handle_cb(user_data, AF_INET6); + return G_SOURCE_CONTINUE; } static void -activation_source_schedule(NMDevice *self, ActivationHandleFunc func, int addr_family) +activation_source_schedule(NMDevice *self, ActivationHandleFunc func) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); - guint new_id = 0; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (priv->activation_source_id_x[IS_IPv4] != 0 - && priv->activation_source_func_x[IS_IPv4] == func) { + if (priv->activation_idle_source && priv->activation_func == func) { /* Scheduling the same stage multiple times is fine. */ _LOGT(LOGD_DEVICE, - "activation-stage: already scheduled %s,v%c (id %u)", - _activation_func_to_string(func), - nm_utils_addr_family_to_char(addr_family), - priv->activation_source_id_x[IS_IPv4]); + "activation-stage: already scheduled %s", + _activation_func_to_string(func)); return; } - new_id = - g_idle_add(IS_IPv4 ? activation_source_handle_cb_4 : activation_source_handle_cb_6, self); - - if (priv->activation_source_id_x[IS_IPv4] != 0) { + if (priv->activation_idle_source) { _LOGD(LOGD_DEVICE, - "activation-stage: schedule %s,v%c which replaces %s,v%c (id %u -> %u)", + "activation-stage: schedule %s (which replaces %s)", _activation_func_to_string(func), - nm_utils_addr_family_to_char(addr_family), - _activation_func_to_string(priv->activation_source_func_x[IS_IPv4]), - nm_utils_addr_family_to_char(addr_family), - priv->activation_source_id_x[IS_IPv4], - new_id); - nm_clear_g_source(&priv->activation_source_id_x[IS_IPv4]); + _activation_func_to_string(priv->activation_func)); + nm_clear_g_source_inst(&priv->activation_idle_source); } else { - _LOGD(LOGD_DEVICE, - "activation-stage: schedule %s,v%c (id %u)", - _activation_func_to_string(func), - nm_utils_addr_family_to_char(addr_family), - new_id); + _LOGD(LOGD_DEVICE, "activation-stage: schedule %s", _activation_func_to_string(func)); } - priv->activation_source_func_x[IS_IPv4] = func; - priv->activation_source_id_x[IS_IPv4] = new_id; + priv->activation_idle_source = nm_g_idle_add_source(activation_source_handle_cb, self); + priv->activation_func = func; } static void -activation_source_invoke_sync(NMDevice *self, ActivationHandleFunc func, int addr_family) +activation_source_invoke_sync(NMDevice *self, ActivationHandleFunc func) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (priv->activation_source_id_x[IS_IPv4] == 0) { + if (!priv->activation_idle_source) { _LOGD(LOGD_DEVICE, - "activation-stage: synchronously invoke %s,v%c", - _activation_func_to_string(func), - nm_utils_addr_family_to_char(addr_family)); - } else if (priv->activation_source_func_x[IS_IPv4] == func) { + "activation-stage: synchronously invoke %s", + _activation_func_to_string(func)); + } else if (priv->activation_func == func) { _LOGD(LOGD_DEVICE, - "activation-stage: synchronously invoke %s,v%c which was already scheduled (id %u)", - _activation_func_to_string(func), - nm_utils_addr_family_to_char(addr_family), - priv->activation_source_id_x[IS_IPv4]); + "activation-stage: synchronously invoke %s (which was already scheduled)", + _activation_func_to_string(func)); } else { _LOGD(LOGD_DEVICE, - "activation-stage: synchronously invoke %s,v%c which replaces %s,v%c (id %u)", + "activation-stage: synchronously invoke %s (which replaces %s)", _activation_func_to_string(func), - nm_utils_addr_family_to_char(addr_family), - _activation_func_to_string(priv->activation_source_func_x[IS_IPv4]), - nm_utils_addr_family_to_char(addr_family), - priv->activation_source_id_x[IS_IPv4]); + _activation_func_to_string(priv->activation_func)); } - nm_clear_g_source(&priv->activation_source_id_x[IS_IPv4]); - priv->activation_source_func_x[IS_IPv4] = NULL; + nm_clear_g_source_inst(&priv->activation_idle_source); + priv->activation_func = NULL; func(self); } +static void +activation_source_invoke_or_schedule(NMDevice *self, ActivationHandleFunc func, gboolean do_sync) +{ + nm_assert(NM_IS_DEVICE(self)); + nm_assert(NM_DEVICE_GET_PRIVATE(self)->act_request.obj); + nm_assert(func); + + if (do_sync) { + activation_source_invoke_sync(self, func); + return; + } + activation_source_schedule(self, func); +} + /*****************************************************************************/ static void @@ -8180,14 +8975,20 @@ activate_stage1_device_prepare(NMDevice *self) NMActiveConnection *master; NMDeviceClass * klass; - priv->v4_route_table_initialized = FALSE; - priv->v6_route_table_initialized = FALSE; + nm_assert((priv->ip_data_4.state == NM_DEVICE_IP_STATE_NONE) + == (priv->ip_data_6.state == NM_DEVICE_IP_STATE_NONE)); - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_NONE); - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_NONE); + if (priv->ip_data_4.state == NM_DEVICE_IP_STATE_NONE) { + _dev_ip_state_set_state(self, AF_INET, NM_DEVICE_IP_STATE_PENDING, "stage1"); + _dev_ip_state_set_state(self, AF_INET6, NM_DEVICE_IP_STATE_PENDING, "stage1"); - /* Notify the new ActiveConnection along with the state change */ - nm_dbus_track_obj_path_set(&priv->act_request, priv->act_request.obj, TRUE); + /* Notify the new ActiveConnection along with the state change */ + nm_dbus_track_obj_path_set(&priv->act_request, priv->act_request.obj, TRUE); + + priv->v4_route_table_initialized = FALSE; + priv->v6_route_table_initialized = FALSE; + priv->l3config_merge_flags_has = FALSE; + } nm_device_state_changed(self, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE); @@ -8248,6 +9049,7 @@ activate_stage1_device_prepare(NMDevice *self) priv->stage1_sriov_state = NM_DEVICE_STAGE_STATE_PENDING; return; } + priv->stage1_sriov_state = NM_DEVICE_STAGE_STATE_COMPLETED; } @@ -8323,15 +9125,7 @@ activate_stage1_device_prepare(NMDevice *self) void nm_device_activate_schedule_stage1_device_prepare(NMDevice *self, gboolean do_sync) { - g_return_if_fail(NM_IS_DEVICE(self)); - g_return_if_fail(NM_DEVICE_GET_PRIVATE(self)->act_request.obj); - - if (!do_sync) { - activation_source_schedule(self, activate_stage1_device_prepare, AF_INET); - return; - } - - activation_source_invoke_sync(self, activate_stage1_device_prepare, AF_INET); + activation_source_invoke_or_schedule(self, activate_stage1_device_prepare, do_sync); } static NMActStageReturn @@ -8623,420 +9417,115 @@ activate_stage2_device_config(NMDevice *self) lldp_setup(self, NM_TERNARY_DEFAULT); - _commit_mtu(self, NULL); + _commit_mtu(self); - nm_device_activate_schedule_stage3_ip_config_start(self); + nm_device_activate_schedule_stage3_ip_config(self, TRUE); } void nm_device_activate_schedule_stage2_device_config(NMDevice *self, gboolean do_sync) { - g_return_if_fail(NM_IS_DEVICE(self)); - - if (!do_sync) { - activation_source_schedule(self, activate_stage2_device_config, AF_INET); - return; - } - - activation_source_invoke_sync(self, activate_stage2_device_config, AF_INET); -} - -void -nm_device_ip_method_failed(NMDevice *self, int addr_family, NMDeviceStateReason reason) -{ - g_return_if_fail(NM_IS_DEVICE(self)); - g_return_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6)); - - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_FAIL); - - if (get_ip_config_may_fail(self, addr_family)) - check_ip_state(self, FALSE, (nm_device_get_state(self) == NM_DEVICE_STATE_IP_CONFIG)); - else - nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, reason); + activation_source_invoke_or_schedule(self, activate_stage2_device_config, do_sync); } /*****************************************************************************/ static void -acd_data_destroy(gpointer ptr) +_dev_ipllx_set_state(NMDevice *self, int addr_family, NMDeviceIPState state) { - AcdData *data = ptr; - int i; - - for (i = 0; data->configs && data->configs[i]; i++) - g_object_unref(data->configs[i]); - g_free(data->configs); - g_slice_free(AcdData, data); -} - -static void -ipv4_manual_method_apply(NMDevice *self, NMIP4Config **configs, gboolean success) -{ - NMConnection *connection; - const char * method; - - connection = nm_device_get_applied_connection(self); - nm_assert(connection); - method = nm_utils_get_ip_config_method(connection, AF_INET); - nm_assert(NM_IN_STRSET(method, - NM_SETTING_IP4_CONFIG_METHOD_MANUAL, - NM_SETTING_IP4_CONFIG_METHOD_AUTO)); - - if (!success) { - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE); - return; - } - - if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) - nm_device_activate_schedule_ip_config_result(self, AF_INET, NULL); - else { - if (NM_DEVICE_GET_PRIVATE(self)->ip_state_4 != NM_DEVICE_IP_STATE_DONE) - ip_config_merge_and_apply(self, AF_INET, TRUE); - } -} - -static void -acd_manager_probe_terminated(NMAcdManager *acd_manager, gpointer user_data) -{ - AcdData * data = user_data; - NMDevice * self; - NMDevicePrivate * priv; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP4Address *address; - gboolean result, success = TRUE; - int i; - - g_assert(data); - self = data->device; - priv = NM_DEVICE_GET_PRIVATE(self); - - for (i = 0; data->configs && data->configs[i]; i++) { - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, data->configs[i], &address) { - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - - result = nm_acd_manager_check_address(acd_manager, address->address); - success &= result; - - _NMLOG(result ? LOGL_DEBUG : LOGL_WARN, - LOGD_DEVICE, - "IPv4 DAD result: address %s is %s", - _nm_utils_inet4_ntop(address->address, sbuf), - result ? "unique" : "duplicate"); - } - } - - data->callback(self, data->configs, success); - - priv->acd.dad_list = g_slist_remove(priv->acd.dad_list, acd_manager); - nm_acd_manager_free(acd_manager); -} - -/** - * ipv4_dad_start: - * @self: device instance - * @configs: NULL-terminated array of IPv4 configurations - * @cb: callback function - * - * Start IPv4 DAD on device @self, check addresses in @configs and call @cb - * when the procedure ends. @cb will be called in any case, even if DAD can't - * be started. @configs will be unreferenced after @cb has been called. - */ -static void -ipv4_dad_start(NMDevice *self, NMIP4Config **configs, AcdCallback cb) -{ - static const NMAcdCallbacks acd_callbacks = { - .probe_terminated_callback = acd_manager_probe_terminated, - .user_data_destroy = acd_data_destroy, - }; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMAcdManager * acd_manager; - const NMPlatformIP4Address *address; - NMDedupMultiIter ipconf_iter; - AcdData * data; - guint timeout; - gboolean addr_found; - int r; - const guint8 * hwaddr_arr; - size_t length; - guint i; - - g_return_if_fail(NM_IS_DEVICE(self)); - g_return_if_fail(configs); - g_return_if_fail(cb); - - for (i = 0, addr_found = FALSE; configs[i]; i++) { - if (nm_ip4_config_get_num_addresses(configs[i]) > 0) { - addr_found = TRUE; - break; - } - } - - timeout = _prop_get_ipv4_dad_timeout(self); - hwaddr_arr = nm_platform_link_get_address(nm_device_get_platform(self), - nm_device_get_ip_ifindex(self), - &length); - - if (!timeout || !hwaddr_arr || !addr_found || length != ETH_ALEN - || nm_device_sys_iface_state_is_external_or_assume(self)) { - /* DAD not needed, signal success */ - cb(self, configs, TRUE); - - for (i = 0; configs[i]; i++) - g_object_unref(configs[i]); - g_free(configs); - - return; - } - - data = g_slice_new0(AcdData); - data->configs = configs; - data->callback = cb; - data->device = self; - - acd_manager = nm_acd_manager_new(nm_device_get_ip_ifindex(self), - hwaddr_arr, - length, - &acd_callbacks, - data); - priv->acd.dad_list = g_slist_append(priv->acd.dad_list, acd_manager); - - for (i = 0; configs[i]; i++) { - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, configs[i], &address) - nm_acd_manager_add_address(acd_manager, address->address); - } - - r = nm_acd_manager_start_probe(acd_manager, timeout); - if (r < 0) { - _LOGW(LOGD_DEVICE, "acd probe failed"); - - /* DAD could not be started, signal success */ - cb(self, configs, TRUE); - - priv->acd.dad_list = g_slist_remove(priv->acd.dad_list, acd_manager); - nm_acd_manager_free(acd_manager); - } -} - -/*****************************************************************************/ -/* IPv4LL stuff */ - -static void -ipv4ll_cleanup(NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - if (priv->ipv4ll) { - sd_ipv4ll_set_callback(priv->ipv4ll, NULL, NULL); - sd_ipv4ll_stop(priv->ipv4ll); - priv->ipv4ll = sd_ipv4ll_unref(priv->ipv4ll); - } - - nm_clear_g_source(&priv->ipv4ll_timeout); -} - -static NMIP4Config * -ipv4ll_get_ip4_config(NMDevice *self, guint32 lla) -{ - NMIP4Config * config = NULL; - NMPlatformIP4Address address; - NMPlatformIP4Route route; - - config = nm_device_ip4_config_new(self); - g_assert(config); - - memset(&address, 0, sizeof(address)); - nm_platform_ip4_address_set_addr(&address, lla, 16); - address.addr_source = NM_IP_CONFIG_SOURCE_IP4LL; - nm_ip4_config_add_address(config, &address); - - /* Add a multicast route for link-local connections: destination= 224.0.0.0, netmask=240.0.0.0 */ - memset(&route, 0, sizeof(route)); - route.network = htonl(0xE0000000L); - route.plen = 4; - route.rt_source = NM_IP_CONFIG_SOURCE_IP4LL; - route.table_coerced = nm_platform_route_table_coerce(nm_device_get_route_table(self, AF_INET)); - route.metric = nm_device_get_route_metric(self, AF_INET); - nm_ip4_config_add_route(config, &route, NULL); - - return config; -} - -static void -nm_device_handle_ipv4ll_event(sd_ipv4ll *ll, int event, void *data) -{ - NMDevice * self = data; - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - struct in_addr address; - NMIP4Config * config; - int r; - - if (priv->act_request.obj == NULL) - return; - - nm_assert(nm_streq(nm_device_get_effective_ip_config_method(self, AF_INET), - NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)); - - switch (event) { - case SD_IPV4LL_EVENT_BIND: - r = sd_ipv4ll_get_address(ll, &address); - if (r < 0) { - _LOGE(LOGD_AUTOIP4, "invalid IPv4 link-local address received, error %d.", r); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED); - return; - } - - if (!nm_utils_ip4_address_is_link_local(address.s_addr)) { - _LOGE(LOGD_AUTOIP4, "invalid address %08x received (not link-local).", address.s_addr); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_AUTOIP_ERROR); - return; - } - - config = ipv4ll_get_ip4_config(self, address.s_addr); - if (config == NULL) { - _LOGE(LOGD_AUTOIP4, "failed to get IPv4LL config"); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_AUTOIP_FAILED); - return; - } - - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF) { - nm_clear_g_source(&priv->ipv4ll_timeout); - nm_device_activate_schedule_ip_config_result(self, AF_INET, NM_IP_CONFIG_CAST(config)); - } else if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE) { - applied_config_init(&priv->dev_ip_config_4, config); - if (!ip_config_merge_and_apply(self, AF_INET, TRUE)) { - _LOGE(LOGD_AUTOIP4, "failed to update IP4 config for autoip change."); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_AUTOIP_FAILED); - } - } else - g_assert_not_reached(); - - g_object_unref(config); - break; - default: - _LOGW(LOGD_AUTOIP4, "IPv4LL address no longer valid after event %d.", event); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_AUTOIP_FAILED); - } -} - -static gboolean -ipv4ll_timeout_cb(gpointer user_data) -{ - NMDevice * self = NM_DEVICE(user_data); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - if (priv->ipv4ll_timeout) { - _LOGI(LOGD_AUTOIP4, "IPv4LL configuration timed out."); - priv->ipv4ll_timeout = 0; - ipv4ll_cleanup(self); - - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF) - nm_device_activate_schedule_ip_config_timeout(self, AF_INET); - } - - return FALSE; -} - -static NMActStageReturn -ipv4ll_start(NMDevice *self) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - const struct ether_addr *addr; - int ifindex, r; - size_t addr_len; - - ipv4ll_cleanup(self); - - r = sd_ipv4ll_new(&priv->ipv4ll); - if (r < 0) { - _LOGE(LOGD_AUTOIP4, "IPv4LL: new() failed with error %d", r); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - r = sd_ipv4ll_attach_event(priv->ipv4ll, NULL, 0); - if (r < 0) { - _LOGE(LOGD_AUTOIP4, "IPv4LL: attach_event() failed with error %d", r); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - ifindex = nm_device_get_ip_ifindex(self); - addr = nm_platform_link_get_address(nm_device_get_platform(self), ifindex, &addr_len); - if (!addr || addr_len != ETH_ALEN) { - _LOGE(LOGD_AUTOIP4, "IPv4LL: can't retrieve hardware address"); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - r = sd_ipv4ll_set_mac(priv->ipv4ll, addr); - if (r < 0) { - _LOGE(LOGD_AUTOIP4, "IPv4LL: set_mac() failed with error %d", r); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - r = sd_ipv4ll_set_ifindex(priv->ipv4ll, ifindex); - if (r < 0) { - _LOGE(LOGD_AUTOIP4, "IPv4LL: set_ifindex() failed with error %d", r); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - r = sd_ipv4ll_set_callback(priv->ipv4ll, nm_device_handle_ipv4ll_event, self); - if (r < 0) { - _LOGE(LOGD_AUTOIP4, "IPv4LL: set_callback() failed with error %d", r); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - r = sd_ipv4ll_start(priv->ipv4ll); - if (r < 0) { - _LOGE(LOGD_AUTOIP4, "IPv4LL: start() failed with error %d", r); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - _LOGI(LOGD_DEVICE | LOGD_AUTOIP4, "IPv4LL: started"); - - /* Start a timeout to bound the address attempt */ - priv->ipv4ll_timeout = g_timeout_add_seconds(20, ipv4ll_timeout_cb, self); - return NM_ACT_STAGE_RETURN_POSTPONE; -} - -/*****************************************************************************/ - -static void -ensure_con_ip_config(NMDevice *self, int addr_family) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMIPConfig * con_ip_config; - if (priv->con_ip_config_x[IS_IPv4]) - return; + if (priv->ipll_data_x[IS_IPv4].state != state) { + _LOGD_ipll(addr_family, + "set state %s (was %s)", + nm_device_ip_state_to_string(state), + nm_device_ip_state_to_string(priv->ipll_data_x[IS_IPv4].state)); + priv->ipll_data_x[IS_IPv4].state = state; + } +} - connection = nm_device_get_applied_connection(self); - if (!connection) - return; - - con_ip_config = nm_device_ip_config_new(self, addr_family); +static void +_dev_ipllx_cleanup(NMDevice *self, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); if (IS_IPv4) { - nm_ip4_config_merge_setting(NM_IP4_CONFIG(con_ip_config), - nm_connection_get_setting_ip4_config(connection), - _prop_get_connection_mdns(self), - _prop_get_connection_llmnr(self), - _prop_get_connection_dns_over_tls(self), - nm_device_get_route_table(self, addr_family), - nm_device_get_route_metric(self, addr_family)); + if (nm_clear_pointer(&priv->ipll_data_4.v4.ipv4ll, nm_l3_ipv4ll_unref)) + nm_clear_pointer(&priv->ipll_data_4.v4.ipv4ll_registation, + nm_l3_ipv4ll_register_remove); + else + nm_assert(!priv->ipll_data_4.v4.ipv4ll_registation); + + nm_clear_g_source_inst(&priv->ipll_data_4.v4.timeout_source); } else { - nm_ip6_config_merge_setting(NM_IP6_CONFIG(con_ip_config), - nm_connection_get_setting_ip6_config(connection), - nm_device_get_route_table(self, addr_family), - nm_device_get_route_metric(self, addr_family)); + nm_clear_pointer(&priv->ipll_data_6.v6.ipv6ll, nm_l3_ipv6ll_destroy); + priv->ipll_data_6.v6.llstate = NM_L3_IPV6LL_STATE_NONE; + priv->ipll_data_6.v6.lladdr = nm_ip_addr_zero.addr6; + nm_clear_g_source_inst(&priv->ipll_data_6.v6.retry_source); } - if (nm_device_sys_iface_state_is_external_or_assume(self)) { - /* For assumed connections ignore all addresses and routes. */ - nm_ip_config_reset_addresses(con_ip_config); - nm_ip_config_reset_routes(con_ip_config); + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_LL_X(IS_IPv4), NULL, FALSE); + + _dev_ipllx_set_state(self, addr_family, NM_DEVICE_IP_STATE_NONE); +} + +/*****************************************************************************/ + +static void +_dev_ipll4_notify_event(NMDevice *self) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NML3IPv4LLState ipv4ll_state; + const NML3ConfigData *l3cd; + NMDeviceIPState state; + + nm_assert(NM_IS_L3_IPV4LL(priv->ipll_data_4.v4.ipv4ll)); + nm_assert(priv->ipll_data_4.state >= NM_DEVICE_IP_STATE_PENDING); + + ipv4ll_state = nm_l3_ipv4ll_get_state(priv->ipll_data_4.v4.ipv4ll); + + if (nm_l3_ipv4ll_state_is_good(ipv4ll_state)) { + l3cd = nm_l3_ipv4ll_get_l3cd(priv->ipll_data_4.v4.ipv4ll); + nm_assert(NM_IS_L3_CONFIG_DATA(l3cd)); + nm_assert(!nm_l3_ipv4ll_is_timed_out(priv->ipll_data_4.v4.ipv4ll)); + state = NM_DEVICE_IP_STATE_READY; + } else if (priv->ipll_data_4.v4.ipv4ll + && nm_l3_ipv4ll_is_timed_out(priv->ipll_data_4.v4.ipv4ll)) { + l3cd = NULL; + state = NM_DEVICE_IP_STATE_FAILED; + } else { + l3cd = NULL; + state = (priv->ipll_data_4.state == NM_DEVICE_IP_STATE_PENDING) ? NM_DEVICE_IP_STATE_PENDING + : NM_DEVICE_IP_STATE_FAILED; } - priv->con_ip_config_x[IS_IPv4] = con_ip_config; + _dev_ipllx_set_state(self, AF_INET, state); + + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_LL_4, l3cd, FALSE); + + _dev_ip_state_check_async(self, AF_INET); +} + +static void +_dev_ipll4_start(NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + guint32 timeout_msec; + + if (priv->ipll_data_4.state >= NM_DEVICE_IP_STATE_PENDING) + return; + + _dev_ipllx_set_state(self, AF_INET, NM_DEVICE_IP_STATE_PENDING); + + timeout_msec = _prop_get_ipv4_dad_timeout(self); + if (timeout_msec == 0) + timeout_msec = NM_ACD_TIMEOUT_RFC5227_MSEC; + + priv->ipll_data_4.v4.ipv4ll = nm_l3cfg_access_ipv4ll(priv->l3cfg); + priv->ipll_data_4.v4.ipv4ll_registation = + nm_l3_ipv4ll_register_new(priv->ipll_data_4.v4.ipv4ll, timeout_msec); } /*****************************************************************************/ @@ -9056,545 +9545,488 @@ _device_get_dhcp_anycast_address(NMDevice *self) return NULL; } +/*****************************************************************************/ + +static IPDevStateData * +_dev_ipdev_data(NMDevice *self, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + switch (addr_family) { + case AF_INET: + return &priv->ipdev_data_4; + case AF_INET6: + return &priv->ipdev_data_6; + default: + nm_assert_not_reached(); + /* fall-through */ + case AF_UNSPEC: + return &priv->ipdev_data_unspec; + } +} + static void -dhcp4_cleanup(NMDevice *self, CleanupType cleanup_type, gboolean release) +_dev_ipdev_cleanup(NMDevice *self, int addr_family) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + IPDevStateData *p; - priv->dhcp_data_4.was_active = FALSE; - nm_clear_g_source(&priv->dhcp_data_4.grace_id); - priv->dhcp_data_4.grace_pending = FALSE; - nm_clear_g_free(&priv->dhcp4.pac_url); - - if (priv->dhcp_data_4.client) { - /* Stop any ongoing DHCP transaction on this device */ - nm_clear_g_signal_handler(priv->dhcp_data_4.client, &priv->dhcp_data_4.notify_sigid); - - if (cleanup_type == CLEANUP_TYPE_DECONFIGURE || cleanup_type == CLEANUP_TYPE_REMOVED) - nm_dhcp_client_stop(priv->dhcp_data_4.client, release); - - g_clear_object(&priv->dhcp_data_4.client); + p = _dev_ipdev_data(self, addr_family); + if (p->state != NM_DEVICE_IP_STATE_NONE) { + _LOGD_ipdev(addr_family, "reset state"); + p->state = NM_DEVICE_IP_STATE_NONE; + p->failed_reason = NM_DEVICE_STATE_REASON_NONE; } - if (priv->dhcp_data_4.config) { - nm_dbus_object_clear_and_unexport(&priv->dhcp_data_4.config); - _notify(self, PROP_DHCP4_CONFIG); - } + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_DEVIP(addr_family), NULL, FALSE); } -static gboolean -ip_config_merge_and_apply(NMDevice *self, int addr_family, gboolean commit) +NMDeviceIPState +nm_device_devip_get_state(NMDevice *self, int addr_family) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - gboolean success; - gs_unref_object NMIPConfig *composite = NULL; - NMIPConfig * config; - gs_unref_ptrarray GPtrArray *ip4_dev_route_blacklist = NULL; - NMConnection * connection; - gboolean ignore_auto_routes = FALSE; - gboolean ignore_auto_dns = FALSE; - gboolean ignore_default_routes = FALSE; - GSList * iter; - const char * ip6_addr_gen_token = NULL; - const int IS_IPv4 = NM_IS_IPv4(addr_family); + g_return_val_if_fail(NM_IS_DEVICE(self), NM_DEVICE_IP_STATE_NONE); - if (nm_device_sys_iface_state_is_external(self)) - commit = FALSE; - - connection = nm_device_get_applied_connection(self); - - /* Apply ignore-auto-routes and ignore-auto-dns settings */ - if (connection) { - NMSettingIPConfig *s_ip; - - s_ip = nm_connection_get_setting_ip_config(connection, addr_family); - if (s_ip) { - ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes(s_ip); - ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns(s_ip); - - /* if the connection has an explicit gateway, we also ignore - * the default routes from other sources. */ - ignore_default_routes = nm_setting_ip_config_get_never_default(s_ip) - || nm_setting_ip_config_get_gateway(s_ip); - - if (!IS_IPv4) { - NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG(s_ip); - - if (nm_setting_ip6_config_get_addr_gen_mode(s_ip6) - == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64) - ip6_addr_gen_token = nm_setting_ip6_config_get_token(s_ip6); - } - } - } - - composite = nm_device_ip_config_new(self, addr_family); - - if (!IS_IPv4) { - nm_ip6_config_set_privacy(NM_IP6_CONFIG(composite), - priv->ndisc ? priv->ndisc_use_tempaddr - : NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); - } - - init_ip_config_dns_priority(self, composite); - - if (commit) { - if (priv->queued_ip_config_id_x[IS_IPv4]) - update_ext_ip_config(self, addr_family, FALSE); - ensure_con_ip_config(self, addr_family); - } - - if (!IS_IPv4) { - if (commit && priv->ipv6ll_has) { - const NMPlatformIP6Address ll_a = { - .address = priv->ipv6ll_addr, - .plen = 64, - .addr_source = NM_IP_CONFIG_SOURCE_IP6LL, - }; - const NMPlatformIP6Route ll_r = { - .network.s6_addr16[0] = htons(0xfe80u), - .plen = 64, - .metric = nm_device_get_route_metric(self, addr_family), - .rt_source = NM_IP_CONFIG_SOURCE_IP6LL, - }; - - nm_assert(IN6_IS_ADDR_LINKLOCAL(&priv->ipv6ll_addr)); - - nm_ip6_config_add_address(NM_IP6_CONFIG(composite), &ll_a); - nm_ip6_config_add_route(NM_IP6_CONFIG(composite), &ll_r, NULL); - } - } - - if (commit) { - gboolean v; - - v = default_route_metric_penalty_detect(self, addr_family); - if (IS_IPv4) - priv->default_route_metric_penalty_ip4_has = v; - else - priv->default_route_metric_penalty_ip6_has = v; - } - - /* Merge all the IP configs into the composite config */ - - if (IS_IPv4) { - config = applied_config_get_current(&priv->dev_ip_config_4); - if (config) { - nm_ip4_config_merge( - NM_IP4_CONFIG(composite), - NM_IP4_CONFIG(config), - (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) - | (ignore_default_routes ? NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES : 0) - | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0), - default_route_metric_penalty_get(self, addr_family)); - } - } - - if (!IS_IPv4) { - config = applied_config_get_current(&priv->ac_ip6_config); - if (config) { - nm_ip6_config_merge( - NM_IP6_CONFIG(composite), - NM_IP6_CONFIG(config), - (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) - | (ignore_default_routes ? NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES : 0) - | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0), - default_route_metric_penalty_get(self, addr_family)); - } - } - - if (!IS_IPv4) { - config = applied_config_get_current(&priv->dhcp6.ip6_config); - if (config) { - nm_ip6_config_merge( - NM_IP6_CONFIG(composite), - NM_IP6_CONFIG(config), - (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) - | (ignore_default_routes ? NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES : 0) - | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0), - default_route_metric_penalty_get(self, addr_family)); - } - } - - for (iter = priv->vpn_configs_x[IS_IPv4]; iter; iter = iter->next) - nm_ip_config_merge(composite, iter->data, NM_IP_CONFIG_MERGE_DEFAULT, 0); - - if (priv->ext_ip_config_x[IS_IPv4]) - nm_ip_config_merge(composite, - priv->ext_ip_config_x[IS_IPv4], - NM_IP_CONFIG_MERGE_EXTERNAL, - 0); - - /* Merge WWAN config *last* to ensure modem-given settings overwrite - * any external stuff set by pppd or other scripts. - */ - config = applied_config_get_current(&priv->dev2_ip_config_x[IS_IPv4]); - if (config) { - nm_ip_config_merge(composite, - config, - (ignore_auto_routes ? NM_IP_CONFIG_MERGE_NO_ROUTES : 0) - | (ignore_default_routes ? NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES : 0) - | (ignore_auto_dns ? NM_IP_CONFIG_MERGE_NO_DNS : 0), - default_route_metric_penalty_get(self, addr_family)); - } - - if (!IS_IPv4) { - if (priv->rt6_temporary_not_available) { - const NMPObject *o; - GHashTableIter hiter; - - g_hash_table_iter_init(&hiter, priv->rt6_temporary_not_available); - while (g_hash_table_iter_next(&hiter, (gpointer *) &o, NULL)) { - nm_ip6_config_add_route(NM_IP6_CONFIG(composite), - NMP_OBJECT_CAST_IP6_ROUTE(o), - NULL); - } - } - } - - /* Merge user overrides into the composite config. For assumed connections, - * con_ip_config_x is empty. */ - if (priv->con_ip_config_x[IS_IPv4]) { - nm_ip_config_merge(composite, - priv->con_ip_config_x[IS_IPv4], - NM_IP_CONFIG_MERGE_DEFAULT, - default_route_metric_penalty_get(self, addr_family)); - } - - if (commit) { - gboolean is_vrf; - - is_vrf = priv->master && nm_device_get_device_type(priv->master) == NM_DEVICE_TYPE_VRF; - - if (IS_IPv4) { - nm_ip4_config_add_dependent_routes(NM_IP4_CONFIG(composite), - nm_device_get_route_table(self, addr_family), - nm_device_get_route_metric(self, addr_family), - is_vrf, - &ip4_dev_route_blacklist); - } else { - nm_ip6_config_add_dependent_routes(NM_IP6_CONFIG(composite), - nm_device_get_route_table(self, addr_family), - nm_device_get_route_metric(self, addr_family), - is_vrf); - } - } - - if (IS_IPv4) { - if (commit) { - if (NM_DEVICE_GET_CLASS(self)->ip4_config_pre_commit) - NM_DEVICE_GET_CLASS(self)->ip4_config_pre_commit(self, NM_IP4_CONFIG(composite)); - } - } - - if (!IS_IPv4) { - NMUtilsIPv6IfaceId iid; - - if (commit && priv->ndisc_started && ip6_addr_gen_token - && nm_utils_ipv6_interface_identifier_get_from_token(&iid, ip6_addr_gen_token)) { - set_ipv6_token(self, &iid, ip6_addr_gen_token); - } - } - - success = - nm_device_set_ip_config(self, addr_family, composite, commit, ip4_dev_route_blacklist); - if (commit) { - if (IS_IPv4) - priv->v4_commit_first_time = FALSE; - else - priv->v6_commit_first_time = FALSE; - } - - return success; + return _dev_ipdev_data(self, addr_family)->state; } -static gboolean -dhcp4_lease_change(NMDevice *self, NMIP4Config *config, gboolean bound) +void +nm_device_devip_set_state_full(NMDevice * self, + int addr_family, + NMDeviceIPState ip_state, + const NML3ConfigData *l3cd, + NMDeviceStateReason failed_reason) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - gs_free_error GError *error = NULL; + NMDevicePrivate *priv; + IPDevStateData * p; - g_return_val_if_fail(config, FALSE); + g_return_if_fail(NM_IS_DEVICE(self)); - applied_config_init(&priv->dev_ip_config_4, config); + priv = NM_DEVICE_GET_PRIVATE(self); - if (!ip_config_merge_and_apply(self, AF_INET, TRUE)) { - _LOGW(LOGD_DHCP4, "failed to update IPv4 config for DHCP change."); - return FALSE; + nm_assert_addr_family_or_unspec(addr_family); + nm_assert(NM_IN_SET(ip_state, + NM_DEVICE_IP_STATE_PENDING, + NM_DEVICE_IP_STATE_READY, + NM_DEVICE_IP_STATE_FAILED)); + nm_assert(!l3cd || NM_IS_L3_CONFIG_DATA(l3cd)); + + nm_assert((ip_state != NM_DEVICE_IP_STATE_FAILED) + == (failed_reason == NM_DEVICE_STATE_REASON_NONE)); + nm_assert((ip_state != NM_DEVICE_IP_STATE_FAILED) || !l3cd); + + p = _dev_ipdev_data(self, addr_family); + + if (p->state == ip_state && p->failed_reason == failed_reason + && priv->l3cds[L3_CONFIG_DATA_TYPE_DEVIP(addr_family)].d == l3cd) + return; + + if (ip_state == NM_DEVICE_IP_STATE_FAILED) { + _LOGD_ipdev(addr_family, + "set state=failed (reason %s)", + nm_device_state_reason_to_string_a(failed_reason)); + } else { + _LOGD_ipdev(addr_family, + "set state=%s%s", + nm_device_ip_state_to_string(ip_state), + l3cd ? " (has extra IP configuration)" : ""); } - - /* TODO: we should perform DAD again whenever we obtain a - * new lease after an expiry. But what should we do if - * a duplicate address is detected? Fail the connection; - * restart DHCP; continue without an address? */ - if (bound && !nm_dhcp_client_accept(priv->dhcp_data_4.client, &error)) { - _LOGW(LOGD_DHCP4, "error accepting lease: %s", error->message); - return FALSE; - } - - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_4, self, NULL, NULL, NULL, NULL); - - return TRUE; + p->state = ip_state; + p->failed_reason = failed_reason; + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_DEVIP(addr_family), l3cd, FALSE); + _dev_ip_state_check_async(self, addr_family); } -static gboolean -dhcp_grace_period_expired(NMDevice *self, int addr_family) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); +/*****************************************************************************/ - priv->dhcp_data_x[IS_IPv4].grace_id = 0; - priv->dhcp_data_x[IS_IPv4].grace_pending = FALSE; - - _LOGI(LOGD_DHCPX(IS_IPv4), - "DHCPv%c: grace period expired", - nm_utils_addr_family_to_char(addr_family)); - - nm_device_ip_method_failed(self, addr_family, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED); - /* If the device didn't fail, the DHCP client will continue */ - - return G_SOURCE_REMOVE; -} - -static gboolean -dhcp_grace_period_expired_4(gpointer user_data) -{ - return dhcp_grace_period_expired(user_data, AF_INET); -} - -static gboolean -dhcp_grace_period_expired_6(gpointer user_data) -{ - return dhcp_grace_period_expired(user_data, AF_INET6); -} - -static gboolean -dhcp_grace_period_start(NMDevice *self, int addr_family) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); - guint32 timeout; - - /* In any other case (expired lease, assumed connection, etc.), - * wait for some time before failing the IP method. - */ - if (priv->dhcp_data_x[IS_IPv4].grace_pending) { - /* already pending. */ - return FALSE; - } - - /* Start a grace period equal to the DHCP timeout multiplied - * by a constant factor. */ - timeout = _prop_get_ipvx_dhcp_timeout(self, addr_family); - if (timeout == NM_DHCP_TIMEOUT_INFINITY) - _LOGI(LOGD_DHCPX(IS_IPv4), - "DHCPv%c: trying to acquire a new lease", - nm_utils_addr_family_to_char(addr_family)); - else { - timeout = dhcp_grace_period_from_timeout(timeout); - _LOGI(LOGD_DHCPX(IS_IPv4), - "DHCPv%c: trying to acquire a new lease within %u seconds", - nm_utils_addr_family_to_char(addr_family), - timeout); - nm_assert(!priv->dhcp_data_x[IS_IPv4].grace_id); - priv->dhcp_data_x[IS_IPv4].grace_id = g_timeout_add_seconds( - timeout, - IS_IPv4 ? dhcp_grace_period_expired_4 : dhcp_grace_period_expired_6, - self); - } - - priv->dhcp_data_x[IS_IPv4].grace_pending = TRUE; - - return TRUE; -} static void -dhcp4_fail(NMDevice *self, NMDhcpState dhcp_state) +_dev_ipmanual_set_state(NMDevice *self, int addr_family, NMDeviceIPState state) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + int IS_IPv4; - _LOGD(LOGD_DHCP4, - "DHCPv4 failed (ip_state %s, was_active %d)", - nm_device_ip_state_to_string(priv->ip_state_4), - priv->dhcp_data_4.was_active); - - /* The client is always left running after a failure. */ - - /* Nothing to do if we failed before... */ - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_FAIL) - goto clear_config; - - /* ... and also if there are static addresses configured - * on the interface. - */ - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE && priv->con_ip_config_4 - && nm_ip4_config_get_num_addresses(priv->con_ip_config_4) > 0) - goto clear_config; - - /* Fail the method when one of the following is true: - * 1) the DHCP client terminated: it does not make sense to start a grace - * period without a client running; - * 2) we failed to get an initial lease AND the client was - * not active before. - */ - if (dhcp_state == NM_DHCP_STATE_TERMINATED - || (!priv->dhcp_data_4.was_active && priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF)) { - nm_device_activate_schedule_ip_config_timeout(self, AF_INET); + if (addr_family == AF_UNSPEC) { + _dev_ipmanual_set_state(self, AF_INET, state); + _dev_ipmanual_set_state(self, AF_INET6, state); return; } - if (dhcp_grace_period_start(self, AF_INET)) - goto clear_config; - - return; - -clear_config: - /* The previous configuration is no longer valid */ - if (priv->dhcp_data_4.config) { - nm_dbus_object_clear_and_unexport(&priv->dhcp_data_4.config); - priv->dhcp_data_4.config = nm_dhcp_config_new(AF_INET); - _notify(self, PROP_DHCP4_CONFIG); + IS_IPv4 = NM_IS_IPv4(addr_family); + if (priv->ipmanual_data.state_x[IS_IPv4] != state) { + _LOGD_ipmanual(addr_family, "set state %s", nm_device_ip_state_to_string(state)); + priv->ipmanual_data.state_x[IS_IPv4] = state; } } static void -dhcp4_dad_cb(NMDevice *self, NMIP4Config **configs, gboolean success) +_dev_ipmanual_cleanup(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (success) { - nm_device_activate_schedule_ip_config_result(self, AF_INET, NM_IP_CONFIG_CAST(configs[1])); + if (priv->ipmanual_data.state_4 == NM_DEVICE_IP_STATE_NONE + && priv->ipmanual_data.state_6 == NM_DEVICE_IP_STATE_NONE) { + nm_assert(!priv->l3cds[L3_CONFIG_DATA_TYPE_MANUALIP].d); + return; + } + + _dev_ipmanual_set_state(self, AF_UNSPEC, NM_DEVICE_IP_STATE_NONE); + nm_clear_g_source_inst(&priv->ipmanual_data.carrier_timeout); + priv->ipmanual_data.carrier_timeout_expired = FALSE; + + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_MANUALIP, NULL, FALSE); + + _dev_ip_state_check_async(self, AF_INET); + _dev_ip_state_check_async(self, AF_INET6); +} + +static gboolean +_dev_ipmanual_carrier_timeout(NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + priv->ipmanual_data.carrier_timeout_expired = TRUE; + nm_clear_g_source_inst(&priv->ipmanual_data.carrier_timeout); + _dev_ipmanual_check_ready(self); + + return G_SOURCE_CONTINUE; +} + +static void +_dev_ipmanual_check_ready(NMDevice *self) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + const NMPlatformLink * plink; + gboolean has_carrier; + NML3CfgCheckReadyFlags flags; + gboolean ready; + gboolean acd_used = FALSE; + int IS_IPv4; + + if (priv->ipmanual_data.state_4 != NM_DEVICE_IP_STATE_PENDING + && priv->ipmanual_data.state_6 != NM_DEVICE_IP_STATE_PENDING) { + /* we only care about PENDING to get it READY. Currently not other + * conditions are implemented. That is, we cannot get to FAILED + * (maybe we should, if DAD fails) and we cannot get from anything + * once we are READY. */ + return; + } + + plink = nm_l3cfg_get_pllink(priv->l3cfg, TRUE); + has_carrier = plink && NM_FLAGS_HAS(plink->n_ifi_flags, IFF_LOWER_UP); + + if (has_carrier) { + nm_clear_g_source_inst(&priv->ipmanual_data.carrier_timeout); } else { - nm_dhcp_client_decline(priv->dhcp_data_4.client, "Address conflict detected", NULL); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE); + if (priv->ipmanual_data.carrier_timeout_expired) { + /* go on */ + } else if (priv->ipmanual_data.carrier_timeout) { + /* wait a bit more until timer expires */ + return; + } else { + priv->ipmanual_data.carrier_timeout = + nm_g_timeout_add_source(2000, G_SOURCE_FUNC(_dev_ipmanual_carrier_timeout), self); + return; + } + } + + flags = NM_L3CFG_CHECK_READY_FLAGS_NONE; + if (has_carrier) { + flags |= NM_L3CFG_CHECK_READY_FLAGS_IP4_ACD_READY; + flags |= NM_L3CFG_CHECK_READY_FLAGS_IP6_DAD_READY; + } + + for (IS_IPv4 = 0; IS_IPv4 < 2; IS_IPv4++) { + const int addr_family = IS_IPv4 ? AF_INET : AF_INET6; + + ready = nm_l3cfg_check_ready(priv->l3cfg, + priv->l3cds[L3_CONFIG_DATA_TYPE_MANUALIP].d, + addr_family, + flags, + &acd_used); + if (acd_used) { + _dev_ipmanual_set_state(self, addr_family, NM_DEVICE_IP_STATE_FAILED); + _dev_ip_state_check_async(self, AF_UNSPEC); + } else if (ready) { + _dev_ipmanual_set_state(self, addr_family, NM_DEVICE_IP_STATE_READY); + _dev_ip_state_check_async(self, AF_UNSPEC); + } } } static void -dhcp4_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_data, NMDevice *self) +_dev_ipmanual_start(NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMIP4Config * manual; - NMIP4Config ** configs; - NMConnection * connection; - NMDhcpState state; - NMIP4Config * ip4_config; - GHashTable * options; + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - nm_assert(nm_dhcp_client_get_addr_family(client) == AF_INET); - nm_assert(notify_data); - nm_assert(notify_data->notify_type == NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED); + if (priv->ipmanual_data.state_4 != NM_DEVICE_IP_STATE_NONE + || priv->ipmanual_data.state_6 != NM_DEVICE_IP_STATE_NONE) + return; - state = notify_data->state_changed.dhcp_state; - ip4_config = NM_IP4_CONFIG(notify_data->state_changed.ip_config); - options = notify_data->state_changed.options; + if (nm_device_get_ip_ifindex(self) > 0) { + l3cd = + nm_device_create_l3_config_data_from_connection(self, + nm_device_get_applied_connection(self)); + } - nm_assert(!ip4_config || NM_IS_IP4_CONFIG(ip4_config)); + if (!l3cd) { + _dev_ipmanual_cleanup(self); + return; + } - _LOGD(LOGD_DHCP4, "new DHCPv4 client state %d", (int) state); + /* Initially we set the state to pending, because we (maybe) have to perform ACD first. */ + _dev_ipmanual_set_state(self, AF_UNSPEC, NM_DEVICE_IP_STATE_PENDING); - switch (state) { - case NM_DHCP_STATE_BOUND: - case NM_DHCP_STATE_EXTENDED: - if (!ip4_config) { - _LOGW(LOGD_DHCP4, "failed to get IPv4 config in response to DHCP event."); - dhcp4_fail(self, state); - break; - } + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_MANUALIP, l3cd, FALSE); - nm_clear_g_source(&priv->dhcp_data_4.grace_id); - priv->dhcp_data_4.grace_pending = FALSE; + _dev_ip_state_check_async(self, AF_UNSPEC); +} - /* After some failures, we have been able to renew the lease: - * update the ip state - */ - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_FAIL) - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_CONF); +/*****************************************************************************/ - g_free(priv->dhcp4.pac_url); - priv->dhcp4.pac_url = g_strdup(g_hash_table_lookup(options, "wpad")); - nm_device_set_proxy_config(self, priv->dhcp4.pac_url); +static void +_dev_ipdhcpx_set_state(NMDevice *self, int addr_family, NMDeviceIPState state) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); - nm_dhcp_config_set_options(priv->dhcp_data_4.config, options); - _notify(self, PROP_DHCP4_CONFIG); - - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF) { - connection = nm_device_get_applied_connection(self); - g_assert(connection); - - manual = nm_device_ip4_config_new(self); - nm_ip4_config_merge_setting(manual, - nm_connection_get_setting_ip4_config(connection), - NM_SETTING_CONNECTION_MDNS_DEFAULT, - NM_SETTING_CONNECTION_LLMNR_DEFAULT, - NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT, - nm_device_get_route_table(self, AF_INET), - nm_device_get_route_metric(self, AF_INET)); - - configs = g_new0(NMIP4Config *, 3); - configs[0] = manual; - configs[1] = g_object_ref(ip4_config); - - ipv4_dad_start(self, configs, dhcp4_dad_cb); - } else if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE) { - if (dhcp4_lease_change(self, ip4_config, state == NM_DHCP_STATE_BOUND)) - nm_device_update_metered(self); - else - dhcp4_fail(self, state); - } - break; - case NM_DHCP_STATE_TIMEOUT: - dhcp4_fail(self, state); - break; - case NM_DHCP_STATE_EXPIRE: - /* Ignore expiry before we even have a lease (NAK, old lease, etc) */ - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF) - break; - /* fall-through */ - case NM_DHCP_STATE_DONE: - case NM_DHCP_STATE_FAIL: - case NM_DHCP_STATE_TERMINATED: - dhcp4_fail(self, state); - break; - default: - break; + if (priv->ipdhcp_data_x[IS_IPv4].state != state) { + _LOGD_ipdhcp(addr_family, + "set state %s (was %s)", + nm_device_ip_state_to_string(state), + nm_device_ip_state_to_string(priv->ipdhcp_data_x[IS_IPv4].state)); + priv->ipdhcp_data_x[IS_IPv4].state = state; } } -static NMActStageReturn -dhcp4_start(NMDevice *self) +static void +_dev_ipdhcpx_cleanup(NMDevice *self, int addr_family, gboolean full_cleanup, gboolean release) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMSettingIPConfig *s_ip4; - gs_unref_bytes GBytes *vendor_class_identifier = NULL; - gs_unref_bytes GBytes *hwaddr = NULL; - gs_unref_bytes GBytes *bcast_hwaddr = NULL; - gs_unref_bytes GBytes *client_id = NULL; - NMConnection * connection; - NMSettingConnection * s_con; - GError * error = NULL; - const NMPlatformLink * pllink; - const char *const * reject_servers; - gboolean request_broadcast; - const char * str; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + + _dev_ipdhcpx_set_state(self, addr_family, NM_DEVICE_IP_STATE_NONE); + + if (full_cleanup && !IS_IPv4) { + priv->ipdhcp_data_6.v6.mode = NM_NDISC_DHCP_LEVEL_NONE; + priv->ipdhcp_data_6.v6.needed_prefixes = 0; + } + + if (full_cleanup) + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4), NULL, FALSE); + + if (priv->ipdhcp_data_x[IS_IPv4].client) { + nm_clear_g_signal_handler(priv->ipdhcp_data_x[IS_IPv4].client, + &priv->ipdhcp_data_x[IS_IPv4].notify_sigid); + nm_dhcp_client_stop(priv->ipdhcp_data_x[IS_IPv4].client, release); + g_clear_object(&priv->ipdhcp_data_x[IS_IPv4].client); + } + + if (full_cleanup && priv->ipdhcp_data_x[IS_IPv4].config) { + gs_unref_object NMDhcpConfig *config = + g_steal_pointer(&priv->ipdhcp_data_x[IS_IPv4].config); + + _notify(self, PROP_DHCPX_CONFIG(IS_IPv4)); + nm_dbus_object_unexport_on_idle(g_steal_pointer(&config)); + } + + _dev_ip_state_check_async(self, addr_family); +} + +static void +_dev_ipdhcpx_handle_fail(NMDevice *self, int addr_family, const char *reason) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + + if (priv->ipdhcp_data_x[IS_IPv4].state == NM_DEVICE_IP_STATE_FAILED) + return; + + _LOGT_ipdhcp(addr_family, "DHCP failing: %s", reason ?: "unknown reason"); + + _dev_ipdhcpx_set_state(self, addr_family, NM_DEVICE_IP_STATE_FAILED); + + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4), NULL, FALSE); + + if (priv->ipdhcp_data_x[IS_IPv4].config) + nm_dhcp_config_set_lease(priv->ipdhcp_data_x[IS_IPv4].config, NULL); + + _dev_ip_state_check_async(self, addr_family); +} + +static void +_dev_ipdhcpx_handle_accept(NMDevice *self, int addr_family, const NML3ConfigData *l3cd) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + gs_free_error GError *error = NULL; + + nm_assert(NM_IS_L3_CONFIG_DATA(l3cd)); + + nm_dhcp_config_set_lease(priv->ipdhcp_data_x[IS_IPv4].config, l3cd); + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4), l3cd, TRUE); + + /* FIXME(l3cfg:dhcp): accept also should be handled by NMDhcpClient transparently. + * NMDhcpClient should do ACD (if enabled), and only after that passes, it exposes + * the lease to the user (NMDevice). NMDevice then may choose to configure the address. + * NMDhcpClient then checks in NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT whether the requested + * address is to be configured by NML3Cfg (here, the intent is what matters, not + * whether the address is actually visible in NMPlatform -- that is because while NML3Cfg + * configures the address (in platform), the user might delete it right away. Also, + * depending on the commit type, NML3Cfg may even choose not to configure it right now + * (which arguably will be odd). Anyway, what matters is whether the user configured + * the address in NML3Cfg (by checking the ObjStateData). + * + * If yes, then NMDhcpClient needs to accept automatically. + * + * Doing it here is wrong for two reasons: + * + * - NMDevice already has enough to do, it should not be concerned with telling + * NMDhcpClient to accept the lease, it should only configure the address. + * + * - we should only accept the lease *after* configuring the address (see n_dhcp4_client_lease_accept(). + * Currently this only works by passing commit_sync=TRUE to _dev_l3_register_l3cds_set_one(), but + * doing that is wrong (see FIXME why commit_sync needs to go away). */ + if (priv->ipdhcp_data_x[IS_IPv4].state != NM_DEVICE_IP_STATE_READY + && !nm_dhcp_client_accept(priv->ipdhcp_data_x[IS_IPv4].client, &error)) { + _LOGW(LOGD_DHCPX(IS_IPv4), "error accepting lease: %s", error->message); + _dev_ipdhcpx_set_state(self, addr_family, NM_DEVICE_IP_STATE_FAILED); + _dev_ip_state_check_async(self, addr_family); + return; + } + + _dev_ipdhcpx_set_state(self, addr_family, NM_DEVICE_IP_STATE_READY); + + nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_X(IS_IPv4), + self, + NULL, + NULL, + NULL, + NULL); + + _dev_ip_state_check_async(self, addr_family); +} + +static void +_dev_ipdhcpx_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_data, NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int addr_family = nm_dhcp_client_get_addr_family(client); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + + nm_assert(notify_data); + nm_assert(priv->ipdhcp_data_x[IS_IPv4].state > NM_DEVICE_IP_STATE_NONE); + nm_assert(client && priv->ipdhcp_data_x[IS_IPv4].client == client); + + switch (notify_data->notify_type) { + case NM_DHCP_CLIENT_NOTIFY_TYPE_PREFIX_DELEGATED: + nm_assert(!IS_IPv4); + /* Just re-emit. The device just contributes the prefix to the + * pool in NMPolicy, which decides about subnet allocation + * on the shared devices. */ + g_signal_emit(self, signals[IP6_PREFIX_DELEGATED], 0, notify_data->prefix_delegated.prefix); + return; + + case NM_DHCP_CLIENT_NOTIFY_TYPE_NO_LEASE_TIMEOUT: + /* Here we also fail if we had a lease and it expired. Maybe, + * ipv[46].dhcp-timeout should only cover the time until we get + * a lease for the first time. How it is here, it means that a + * connection can fail after being connected successfully for a + * longer time. */ + _dev_ipdhcpx_handle_fail(self, addr_family, "timeout getting lease"); + return; + + case NM_DHCP_CLIENT_NOTIFY_TYPE_IT_LOOKS_BAD: + /* Like NM_DHCP_CLIENT_NOTIFY_TYPE_NO_LEASE_TIMEOUT, this does not + * apply only if we never got a lease, but also after being fully + * connected. We can also fail then. */ + _dev_ipdhcpx_handle_fail(self, addr_family, notify_data->it_looks_bad.reason); + return; + + case NM_DHCP_CLIENT_NOTIFY_TYPE_LEASE_UPDATE: + + if (!notify_data->lease_update.l3cd) { + _LOGT_ipdhcp(addr_family, "lease lost"); + _dev_ipdhcpx_handle_fail(self, addr_family, "lease lost"); + return; + } + + _LOGT_ipdhcp(addr_family, "lease update"); + _dev_ipdhcpx_handle_accept(self, addr_family, notify_data->lease_update.l3cd); + return; + } + + nm_assert_not_reached(); +} + +/*****************************************************************************/ + +static void +_dev_ipdhcpx_start(NMDevice *self, int addr_family) +{ + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMConnection * connection; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip; + const NML3ConfigData *previous_lease; + gs_unref_bytes GBytes *hwaddr = NULL; + gboolean enforce_duid = FALSE; + gs_free_error GError *error = NULL; + const NMPlatformLink *pllink; + guint no_lease_timeout_sec; + int ifindex; + const char * str; + gboolean request_broadcast; + const char * fail_reason; + + if (priv->ipdhcp_data_x[IS_IPv4].state == NM_DEVICE_IP_STATE_NONE) + _dev_ipdhcpx_set_state(self, addr_family, NM_DEVICE_IP_STATE_PENDING); + else if (priv->ipdhcp_data_x[IS_IPv4].state > NM_DEVICE_IP_STATE_PENDING) { + /* already succeeded or failed */ + return; + } else if (priv->ipdhcp_data_x[IS_IPv4].client) { + /* DHCP client already started */ + return; + } + + if (nm_device_sys_iface_state_is_external(self)) { + fail_reason = nm_assert_unreachable_val("cannot run DHCP on external interface"); + goto out_fail; + } connection = nm_device_get_applied_connection(self); - g_return_val_if_fail(connection, FALSE); - - s_ip4 = nm_connection_get_setting_ip4_config(connection); + if (!connection) { + fail_reason = nm_assert_unreachable_val("no applied connection for starting DHCP"); + goto out_fail; + } s_con = nm_connection_get_setting_connection(connection); + s_ip = nm_connection_get_setting_ip_config(connection, addr_family); nm_assert(s_con); + nm_assert(s_ip); - /* Clear old exported DHCP options */ - nm_dbus_object_clear_and_unexport(&priv->dhcp_data_4.config); - priv->dhcp_data_4.config = nm_dhcp_config_new(AF_INET); + ifindex = 0; + pllink = nm_l3cfg_get_pllink(priv->l3cfg, TRUE); + if (pllink) { + ifindex = pllink->ifindex; + nm_assert(ifindex > 0); + nm_assert(ifindex == nm_device_get_ip_ifindex(self)); + } + if (ifindex <= 0) { + fail_reason = "cannot start DHCP without interface"; + goto out_fail; + } + + hwaddr = nmp_link_address_get_as_bytes(&pllink->l_address); + + if (!IS_IPv4) { + if (!hwaddr) { + fail_reason = "interface has no MAC address to start DHCPv6"; + goto out_fail; + } + } request_broadcast = FALSE; - - pllink = nm_platform_link_get(nm_device_get_platform(self), nm_device_get_ip_ifindex(self)); if (pllink) { - hwaddr = nmp_link_address_get_as_bytes(&pllink->l_address); - bcast_hwaddr = nmp_link_address_get_as_bytes(&pllink->l_broadcast); - str = nmp_object_link_udev_device_get_property_value(NMP_OBJECT_UP_CAST(pllink), "ID_NET_DHCP_BROADCAST"); if (str && _nm_utils_ascii_str_to_bool(str, FALSE)) { @@ -9606,103 +10038,205 @@ dhcp4_start(NMDevice *self) } } - client_id = _prop_get_ipv4_dhcp_client_id(self, connection, hwaddr); - vendor_class_identifier = - _prop_get_ipv4_dhcp_vendor_class_identifier(self, NM_SETTING_IP4_CONFIG(s_ip4)); - reject_servers = nm_setting_ip_config_get_dhcp_reject_servers(s_ip4, NULL); - - g_warn_if_fail(priv->dhcp_data_4.client == NULL); - priv->dhcp_data_4.client = nm_dhcp_manager_start_ip4( - nm_dhcp_manager_get(), - nm_netns_get_multi_idx(nm_device_get_netns(self)), - nm_device_get_ip_iface(self), - nm_device_get_ip_ifindex(self), - hwaddr, - bcast_hwaddr, - nm_connection_get_uuid(connection), - nm_device_get_route_table(self, AF_INET), - nm_device_get_route_metric(self, AF_INET), - request_broadcast ? NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST : NM_DHCP_CLIENT_FLAGS_NONE, - nm_setting_ip_config_get_dhcp_send_hostname(s_ip4), - nm_setting_ip_config_get_dhcp_hostname(s_ip4), - nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip4)), - _prop_get_ipvx_dhcp_hostname_flags(self, AF_INET), - _prop_get_connection_mud_url(self, s_con), - client_id, - _prop_get_ipvx_dhcp_timeout(self, AF_INET), - _device_get_dhcp_anycast_address(self), - NULL, - vendor_class_identifier, - reject_servers, - &error); - if (!priv->dhcp_data_4.client) { - _LOGW(LOGD_DHCP4, "failure to start DHCP: %s", error->message); - g_clear_error(&error); - return NM_ACT_STAGE_RETURN_FAILURE; + if (!IS_IPv4 + && NM_IN_SET(priv->ipll_data_6.state, + NM_DEVICE_IP_STATE_NONE, + NM_DEVICE_IP_STATE_PENDING)) { + _dev_ipll6_start(self); + return; } - priv->dhcp_data_4.notify_sigid = g_signal_connect(priv->dhcp_data_4.client, - NM_DHCP_CLIENT_NOTIFY, - G_CALLBACK(dhcp4_notify), - self); + no_lease_timeout_sec = _prop_get_ipvx_dhcp_timeout(self, addr_family); - if (nm_device_sys_iface_state_is_external_or_assume(self)) - priv->dhcp_data_4.was_active = TRUE; + if (IS_IPv4) { + NMDhcpClientConfig config; + gs_unref_bytes GBytes *bcast_hwaddr = NULL; + gs_unref_bytes GBytes *client_id = NULL; + gs_unref_bytes GBytes *vendor_class_identifier = NULL; + const char *const * reject_servers; + const char * hostname; + gboolean hostname_is_fqdn; - /* DHCP devices will be notified by the DHCP manager when stuff happens */ - return NM_ACT_STAGE_RETURN_POSTPONE; + client_id = _prop_get_ipv4_dhcp_client_id(self, connection, hwaddr); + vendor_class_identifier = + _prop_get_ipv4_dhcp_vendor_class_identifier(self, NM_SETTING_IP4_CONFIG(s_ip)); + reject_servers = nm_setting_ip_config_get_dhcp_reject_servers(s_ip, NULL); + + bcast_hwaddr = nmp_link_address_get_as_bytes(&pllink->l_broadcast); + + hostname = nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip)); + if (hostname) { + hostname_is_fqdn = TRUE; + } else { + hostname_is_fqdn = FALSE; + hostname = nm_setting_ip_config_get_dhcp_hostname(s_ip); + } + + config = (NMDhcpClientConfig){ + .addr_family = AF_INET, + .l3cfg = nm_device_get_l3cfg(self), + .iface = nm_device_get_ip_iface(self), + .uuid = nm_connection_get_uuid(connection), + .hwaddr = hwaddr, + .bcast_hwaddr = bcast_hwaddr, + .send_hostname = nm_setting_ip_config_get_dhcp_send_hostname(s_ip), + .hostname = hostname, + .hostname_flags = _prop_get_ipvx_dhcp_hostname_flags(self, AF_INET), + .client_id = client_id, + .mud_url = _prop_get_connection_mud_url(self, s_con), + .timeout = no_lease_timeout_sec, + .anycast_address = _device_get_dhcp_anycast_address(self), + .vendor_class_identifier = vendor_class_identifier, + .use_fqdn = hostname_is_fqdn, + .reject_servers = reject_servers, + .v4.request_broadcast = request_broadcast, + }; + + priv->ipdhcp_data_4.client = + nm_dhcp_manager_start_client(nm_dhcp_manager_get(), &config, &error); + } else { + gs_unref_bytes GBytes *duid = NULL; + gboolean iaid_explicit; + guint32 iaid; + NMDhcpClientConfig config; + + iaid = _prop_get_ipvx_dhcp_iaid(self, AF_INET6, connection, FALSE, &iaid_explicit); + duid = _prop_get_ipv6_dhcp_duid(self, connection, hwaddr, &enforce_duid); + + config = (NMDhcpClientConfig){ + .addr_family = AF_INET6, + .l3cfg = nm_device_get_l3cfg(self), + .iface = nm_device_get_ip_iface(self), + .uuid = nm_connection_get_uuid(connection), + .send_hostname = nm_setting_ip_config_get_dhcp_send_hostname(s_ip), + .hostname = nm_setting_ip_config_get_dhcp_hostname(s_ip), + .hostname_flags = _prop_get_ipvx_dhcp_hostname_flags(self, AF_INET6), + .client_id = duid, + .mud_url = _prop_get_connection_mud_url(self, s_con), + .timeout = no_lease_timeout_sec, + .anycast_address = _device_get_dhcp_anycast_address(self), + .v6.enforce_duid = enforce_duid, + .v6.iaid = iaid, + .v6.iaid_explicit = iaid_explicit, + .v6.info_only = (priv->ipdhcp_data_6.v6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF), + .v6.needed_prefixes = priv->ipdhcp_data_6.v6.needed_prefixes, + }; + + priv->ipdhcp_data_6.client = + nm_dhcp_manager_start_client(nm_dhcp_manager_get(), &config, &error); + } + + if (!priv->ipdhcp_data_x[IS_IPv4].client) { + fail_reason = error->message; + goto out_fail; + } + + priv->ipdhcp_data_x[IS_IPv4].notify_sigid = + g_signal_connect(priv->ipdhcp_data_x[IS_IPv4].client, + NM_DHCP_CLIENT_NOTIFY, + G_CALLBACK(_dev_ipdhcpx_notify), + self); + + /* FIXME(l3cfg:dhcp:previous-lease): take the NML3ConfigData from the previous lease (if any) + * and pass it on to NMDhcpClient. This is a fake lease that we use initially (until + * NMDhcpClient got a real lease). Note that NMDhcpClient needs to check whether the + * lease already expired. */ + + previous_lease = nm_dhcp_client_get_lease(priv->ipdhcp_data_x[IS_IPv4].client); + if (!priv->ipdhcp_data_x[IS_IPv4].config) { + priv->ipdhcp_data_x[IS_IPv4].config = nm_dhcp_config_new(addr_family, previous_lease); + _notify(self, PROP_DHCPX_CONFIG(IS_IPv4)); + } + if (previous_lease) + _dev_ipdhcpx_handle_accept(self, addr_family, previous_lease); + + return; + +out_fail: + _dev_ipdhcpx_handle_fail(self, addr_family, fail_reason); } -gboolean -nm_device_dhcp4_renew(NMDevice *self, gboolean release) +static void +_dev_ipdhcpx_start_continue(NMDevice *self, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + + if (priv->ipdhcp_data_x[IS_IPv4].state != NM_DEVICE_IP_STATE_NONE) + _dev_ipdhcpx_start(self, addr_family); +} + +static void +_dev_ipdhcpx_restart(NMDevice *self, int addr_family, gboolean release) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + + if (priv->ipdhcp_data_x[IS_IPv4].state != NM_DEVICE_IP_STATE_NONE) { + _LOGI_ipdhcp(addr_family, "restarting%s", release ? " (release lease)" : ""); + _dev_ipdhcpx_cleanup(self, addr_family, FALSE, release); + } + + _dev_ipdhcpx_start(self, addr_family); +} + +void +nm_device_ip_method_dhcp4_start(NMDevice *self) +{ + _dev_ipdhcpx_start(self, AF_INET); +} + +static void +_dev_ipdhcp6_set_dhcp_level(NMDevice *self, NMNDiscDHCPLevel dhcp_level) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - g_return_val_if_fail(priv->dhcp_data_4.client != NULL, FALSE); + nm_assert(NM_IN_SET(dhcp_level, + NM_NDISC_DHCP_LEVEL_NONE, + NM_NDISC_DHCP_LEVEL_OTHERCONF, + NM_NDISC_DHCP_LEVEL_MANAGED)); - _LOGI(LOGD_DHCP4, "DHCPv4 lease renewal requested"); + if (dhcp_level == NM_NDISC_DHCP_LEVEL_NONE && priv->ipdhcp_data_6.v6.needed_prefixes > 0) + dhcp_level = NM_NDISC_DHCP_LEVEL_OTHERCONF; - /* Terminate old DHCP instance and release the old lease */ - dhcp4_cleanup(self, CLEANUP_TYPE_DECONFIGURE, release); + if (priv->ipdhcp_data_6.v6.mode == dhcp_level) + return; - /* Start DHCP again on the interface */ - return dhcp4_start(self) != NM_ACT_STAGE_RETURN_FAILURE; -} + _LOGD_ipdhcp(AF_INET6, "level: set to %s", nm_ndisc_dhcp_level_to_string(dhcp_level)); -/*****************************************************************************/ - -static NMIP4Config * -shared4_new_config(NMDevice *self, NMConnection *connection) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMIP4Config * config; - NMSettingIPConfig * s_ip4; - NMPlatformIP4Address address = { - .addr_source = NM_IP_CONFIG_SOURCE_SHARED, - }; - - g_return_val_if_fail(self, NULL); - g_return_val_if_fail(connection, NULL); - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - if (s_ip4 && nm_setting_ip_config_get_num_addresses(s_ip4) > 0) { - /* Use the first user-supplied address */ - NMIPAddress *user = nm_setting_ip_config_get_address(s_ip4, 0); - in_addr_t a; - - nm_ip_address_get_address_binary(user, &a); - nm_platform_ip4_address_set_addr(&address, a, nm_ip_address_get_prefix(user)); - nm_clear_pointer(&priv->shared_ip_handle, nm_netns_shared_ip_release); - } else { - if (!priv->shared_ip_handle) - priv->shared_ip_handle = nm_netns_shared_ip_reserve(nm_device_get_netns(self)); - nm_platform_ip4_address_set_addr(&address, priv->shared_ip_handle->addr, 24); + if (dhcp_level == NM_NDISC_DHCP_LEVEL_NONE) { + _dev_ipdhcpx_cleanup(self, AF_INET6, TRUE, TRUE); + return; } - config = nm_device_ip4_config_new(self); - nm_ip4_config_add_address(config, &address); + priv->ipdhcp_data_6.v6.mode = dhcp_level; + _dev_ipdhcpx_restart(self, AF_INET6, TRUE); +} - return config; +/* + * Called on the requesting interface when a subnet can't be obtained + * from known prefixes for a newly active shared connection. + */ +void +nm_device_request_ip6_prefixes(NMDevice *self, guint needed_prefixes) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + if (priv->ipdhcp_data_6.v6.needed_prefixes == needed_prefixes) + return; + + _LOGD(LOGD_IP6, "ipv6-pd: asking DHCPv6 for %u prefixes", needed_prefixes); + + priv->ipdhcp_data_6.v6.needed_prefixes = needed_prefixes; + + if (priv->ipdhcp_data_6.v6.mode == NM_NDISC_DHCP_LEVEL_NONE) { + priv->ipdhcp_data_6.v6.mode = NM_NDISC_DHCP_LEVEL_OTHERCONF; + _LOGD_ipdhcp(AF_INET6, + "level: set to %s", + nm_ndisc_dhcp_level_to_string(NM_NDISC_DHCP_LEVEL_OTHERCONF)); + } + + _dev_ipdhcpx_restart(self, AF_INET6, TRUE); } /*****************************************************************************/ @@ -9800,392 +10334,6 @@ have_any_ready_slaves(NMDevice *self) } /*****************************************************************************/ -/* DHCPv6 stuff */ - -static void -dhcp6_cleanup(NMDevice *self, CleanupType cleanup_type, gboolean release) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - priv->dhcp_data_6.was_active = FALSE; - priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_NONE; - applied_config_clear(&priv->dhcp6.ip6_config); - nm_clear_g_free(&priv->dhcp6.event_id); - nm_clear_g_source(&priv->dhcp_data_6.grace_id); - priv->dhcp_data_6.grace_pending = FALSE; - - if (priv->dhcp_data_6.client) { - nm_clear_g_signal_handler(priv->dhcp_data_6.client, &priv->dhcp_data_6.notify_sigid); - - if (cleanup_type == CLEANUP_TYPE_DECONFIGURE || cleanup_type == CLEANUP_TYPE_REMOVED) - nm_dhcp_client_stop(priv->dhcp_data_6.client, release); - - g_clear_object(&priv->dhcp_data_6.client); - } - - if (priv->dhcp_data_6.config) { - nm_dbus_object_clear_and_unexport(&priv->dhcp_data_6.config); - _notify(self, PROP_DHCP6_CONFIG); - } -} - -static gboolean -dhcp6_lease_change(NMDevice *self) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMSettingsConnection *settings_connection; - - if (!applied_config_get_current(&priv->dhcp6.ip6_config)) { - _LOGW(LOGD_DHCP6, "failed to get DHCPv6 config for rebind"); - return FALSE; - } - - g_assert(priv->dhcp_data_6.client); /* sanity check */ - - settings_connection = nm_device_get_settings_connection(self); - g_assert(settings_connection); - - /* Apply the updated config */ - if (!ip_config_merge_and_apply(self, AF_INET6, TRUE)) { - _LOGW(LOGD_DHCP6, "failed to update IPv6 config in response to DHCP event"); - return FALSE; - } - - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_6, self, NULL, NULL, NULL, NULL); - - return TRUE; -} - -static void -dhcp6_fail(NMDevice *self, NMDhcpState dhcp_state) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - gboolean is_dhcp_managed; - - _LOGD(LOGD_DHCP6, - "DHCPv6 failed (ip_state %s, was_active %d)", - nm_device_ip_state_to_string(priv->ip_state_6), - priv->dhcp_data_6.was_active); - - /* The client is always left running after a failure. */ - - /* Nothing to do if we failed before... */ - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_FAIL) - goto clear_config; - - is_dhcp_managed = (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED); - - if (is_dhcp_managed) { - /* ... and also if there are static addresses configured - * on the interface. - */ - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE && priv->con_ip_config_6 - && nm_ip6_config_get_num_addresses(priv->con_ip_config_6)) - goto clear_config; - - /* Fail the method when one of the following is true: - * 1) the DHCP client terminated: it does not make sense to start a grace - * period without a client running; - * 2) we failed to get an initial lease AND the client was - * not active before. - */ - if (dhcp_state == NM_DHCP_STATE_TERMINATED - || (!priv->dhcp_data_6.was_active && priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF)) { - nm_device_activate_schedule_ip_config_timeout(self, AF_INET6); - return; - } - - if (dhcp_grace_period_start(self, AF_INET6)) - goto clear_config; - } else { - /* not a hard failure; just live with the RA info */ - dhcp6_cleanup(self, CLEANUP_TYPE_DECONFIGURE, FALSE); - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF) - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - } - return; - -clear_config: - /* The previous configuration is no longer valid */ - if (priv->dhcp_data_6.config) { - nm_dbus_object_clear_and_unexport(&priv->dhcp_data_6.config); - priv->dhcp_data_6.config = nm_dhcp_config_new(AF_INET6); - _notify(self, PROP_DHCP6_CONFIG); - } -} - -static void -dhcp6_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_data, NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - gs_free char * event_id = NULL; - NMDhcpState state; - NMIP6Config * ip6_config; - GHashTable * options; - - nm_assert(nm_dhcp_client_get_addr_family(client) == AF_INET6); - nm_assert(notify_data); - - if (notify_data->notify_type == NM_DHCP_CLIENT_NOTIFY_TYPE_PREFIX_DELEGATED) { - /* Just re-emit. The device just contributes the prefix to the - * pool in NMPolicy, which decides about subnet allocation - * on the shared devices. */ - g_signal_emit(self, signals[IP6_PREFIX_DELEGATED], 0, notify_data->prefix_delegated.prefix); - return; - } - - nm_assert(notify_data->notify_type == NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED); - - state = notify_data->state_changed.dhcp_state; - ip6_config = NM_IP6_CONFIG(notify_data->state_changed.ip_config); - options = notify_data->state_changed.options; - - nm_assert(!ip6_config || NM_IS_IP6_CONFIG(ip6_config)); - - _LOGD(LOGD_DHCP6, "new DHCPv6 client state %d", (int) state); - - switch (state) { - case NM_DHCP_STATE_BOUND: - case NM_DHCP_STATE_EXTENDED: - nm_clear_g_source(&priv->dhcp_data_6.grace_id); - priv->dhcp_data_6.grace_pending = FALSE; - /* If the server sends multiple IPv6 addresses, we receive a state - * changed event for each of them. Use the event ID to merge IPv6 - * addresses from the same transaction into a single configuration. - */ - - event_id = nm_dhcp_utils_get_dhcp6_event_id(options); - - if (ip6_config && event_id && priv->dhcp6.event_id - && nm_streq(event_id, priv->dhcp6.event_id)) { - NMDedupMultiIter ipconf_iter; - const NMPlatformIP6Address *a; - - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, ip6_config, &a) - applied_config_add_address(&priv->dhcp6.ip6_config, NM_PLATFORM_IP_ADDRESS_CAST(a)); - } else { - nm_clear_g_free(&priv->dhcp6.event_id); - if (ip6_config) { - applied_config_init(&priv->dhcp6.ip6_config, ip6_config); - priv->dhcp6.event_id = g_strdup(event_id); - nm_dhcp_config_set_options(priv->dhcp_data_6.config, options); - _notify(self, PROP_DHCP6_CONFIG); - } else - applied_config_clear(&priv->dhcp6.ip6_config); - } - - /* After long time we have been able to renew the lease: - * update the ip state - */ - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_FAIL) - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_CONF); - - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF) { - if (!applied_config_get_current(&priv->dhcp6.ip6_config)) { - nm_device_ip_method_failed(self, AF_INET6, NM_DEVICE_STATE_REASON_DHCP_FAILED); - break; - } - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - } else if (priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE) - if (!dhcp6_lease_change(self)) - dhcp6_fail(self, state); - break; - case NM_DHCP_STATE_TIMEOUT: - if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED) - dhcp6_fail(self, state); - else { - /* not a hard failure; just live with the RA info */ - dhcp6_cleanup(self, CLEANUP_TYPE_DECONFIGURE, FALSE); - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF) - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - } - break; - case NM_DHCP_STATE_EXPIRE: - /* Ignore expiry before we even have a lease (NAK, old lease, etc) */ - if (priv->ip_state_6 != NM_DEVICE_IP_STATE_CONF) - dhcp6_fail(self, state); - break; - case NM_DHCP_STATE_TERMINATED: - /* In IPv6 info-only mode, the client doesn't handle leases so it - * may exit right after getting a response from the server. That's - * normal. In that case we just ignore the exit. - */ - if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) - break; - /* fall-through */ - case NM_DHCP_STATE_DONE: - case NM_DHCP_STATE_FAIL: - dhcp6_fail(self, state); - break; - default: - break; - } -} - -/*****************************************************************************/ - -static gboolean -dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMSettingIPConfig *s_ip6; - gs_unref_bytes GBytes *hwaddr = NULL; - gs_unref_bytes GBytes * duid = NULL; - gboolean enforce_duid = FALSE; - const NMPlatformLink * pllink; - GError * error = NULL; - guint32 iaid; - gboolean iaid_explicit; - NMSettingConnection * s_con; - const NMPlatformIP6Address *ll_addr = NULL; - int ip_ifindex; - - g_return_val_if_fail(connection, FALSE); - - s_ip6 = nm_connection_get_setting_ip6_config(connection); - nm_assert(s_ip6); - s_con = nm_connection_get_setting_connection(connection); - nm_assert(s_con); - - if (priv->ext_ip6_config_captured) { - ll_addr = nm_ip_config_find_first_address(NM_IP_CONFIG(priv->ext_ip6_config_captured), - NM_PLATFORM_MATCH_WITH_ADDRTYPE_LINKLOCAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE_NORMAL); - } - - if (!ll_addr) { - _LOGW(LOGD_DHCP6, "can't start DHCPv6: no link-local address"); - return FALSE; - } - - ip_ifindex = nm_device_get_ip_ifindex(self); - if (ip_ifindex <= 0) { - _LOGD(LOGD_DHCP6, "can't start DHCPv6: interface is gone"); - return FALSE; - } - - pllink = nm_platform_link_get(nm_device_get_platform(self), ip_ifindex); - if (pllink) - hwaddr = nmp_link_address_get_as_bytes(&pllink->l_address); - - iaid = _prop_get_ipvx_dhcp_iaid(self, AF_INET6, connection, TRUE, &iaid_explicit); - duid = _prop_get_ipv6_dhcp_duid(self, connection, hwaddr, &enforce_duid); - - priv->dhcp_data_6.client = nm_dhcp_manager_start_ip6( - nm_dhcp_manager_get(), - nm_device_get_multi_index(self), - nm_device_get_ip_iface(self), - ip_ifindex, - &ll_addr->address, - nm_connection_get_uuid(connection), - nm_device_get_route_table(self, AF_INET6), - nm_device_get_route_metric(self, AF_INET6), - (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) ? NM_DHCP_CLIENT_FLAGS_INFO_ONLY - : NM_DHCP_CLIENT_FLAGS_NONE, - nm_setting_ip_config_get_dhcp_send_hostname(s_ip6), - nm_setting_ip_config_get_dhcp_hostname(s_ip6), - _prop_get_ipvx_dhcp_hostname_flags(self, AF_INET6), - _prop_get_connection_mud_url(self, s_con), - duid, - enforce_duid, - iaid, - iaid_explicit, - _prop_get_ipvx_dhcp_timeout(self, AF_INET6), - _device_get_dhcp_anycast_address(self), - nm_setting_ip6_config_get_ip6_privacy(NM_SETTING_IP6_CONFIG(s_ip6)), - priv->dhcp6.needed_prefixes, - &error); - if (!priv->dhcp_data_6.client) { - _LOGW(LOGD_DHCP6, "failure to start DHCPv6: %s", error->message); - g_clear_error(&error); - if (nm_device_sys_iface_state_is_external_or_assume(self)) - priv->dhcp_data_6.was_active = TRUE; - return FALSE; - } - - priv->dhcp_data_6.notify_sigid = g_signal_connect(priv->dhcp_data_6.client, - NM_DHCP_CLIENT_NOTIFY, - G_CALLBACK(dhcp6_notify), - self); - - if (nm_device_sys_iface_state_is_external_or_assume(self)) - priv->dhcp_data_6.was_active = TRUE; - - return TRUE; -} - -static gboolean -dhcp6_start(NMDevice *self, gboolean wait_for_ll) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; - - nm_dbus_object_clear_and_unexport(&priv->dhcp_data_6.config); - priv->dhcp_data_6.config = nm_dhcp_config_new(AF_INET6); - - nm_assert(!applied_config_get_current(&priv->dhcp6.ip6_config)); - applied_config_clear(&priv->dhcp6.ip6_config); - nm_clear_g_free(&priv->dhcp6.event_id); - - connection = nm_device_get_applied_connection(self); - g_return_val_if_fail(connection, FALSE); - - if (wait_for_ll) { - /* ensure link local is ready... */ - if (!linklocal6_start(self)) { - /* wait for the LL address to show up */ - return TRUE; - } - /* already have the LL address; kick off DHCP */ - } - - if (!dhcp6_start_with_link_ready(self, connection)) - return FALSE; - - return TRUE; -} - -gboolean -nm_device_dhcp6_renew(NMDevice *self, gboolean release) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMNDiscDHCPLevel mode; - - g_return_val_if_fail(priv->dhcp_data_6.client != NULL, FALSE); - - _LOGI(LOGD_DHCP6, "DHCPv6 lease renewal requested"); - - /* Terminate old DHCP instance and release the old lease */ - mode = priv->dhcp6.mode; - dhcp6_cleanup(self, CLEANUP_TYPE_DECONFIGURE, release); - priv->dhcp6.mode = mode; - - /* Start DHCP again on the interface */ - return dhcp6_start(self, FALSE); -} - -/*****************************************************************************/ - -/* - * Called on the requesting interface when a subnet can't be obtained - * from known prefixes for a newly active shared connection. - */ -void -nm_device_request_ip6_prefixes(NMDevice *self, int needed_prefixes) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - priv->dhcp6.needed_prefixes = needed_prefixes; - - if (priv->dhcp_data_6.client) { - _LOGD(LOGD_IP6, "ipv6-pd: asking DHCPv6 for %d prefixes", needed_prefixes); - nm_device_dhcp6_renew(self, FALSE); - } else { - priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_OTHERCONF; - _LOGD(LOGD_DEVICE | LOGD_DHCP6, "ipv6-pd: starting DHCPv6 to request a prefix"); - dhcp6_start(self, FALSE); - } -} gboolean nm_device_needs_ip6_subnet(NMDevice *self) @@ -10200,25 +10348,25 @@ nm_device_needs_ip6_subnet(NMDevice *self) void nm_device_use_ip6_subnet(NMDevice *self, const NMPlatformIP6Address *subnet) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMPlatformIP6Address address = *subnet; - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + char sbuf[sizeof(_nm_utils_to_string_buffer)]; + NMPlatformIP6Address address; - if (!applied_config_get_current(&priv->ac_ip6_config)) - applied_config_init_new(&priv->ac_ip6_config, self, AF_INET6); + l3cd = nm_device_create_l3_config_data(self, NM_IP_CONFIG_SOURCE_SHARED); /* Assign a ::1 address in the subnet for us. */ + address = *subnet; address.address.s6_addr32[3] |= htonl(1); - applied_config_add_address(&priv->ac_ip6_config, NM_PLATFORM_IP_ADDRESS_CAST(&address)); + + nm_l3_config_data_add_address_6(l3cd, &address); _LOGD(LOGD_IP6, - "ipv6-pd: using %s address (preferred for %u seconds)", - _nm_utils_inet6_ntop(&address.address, sbuf), - subnet->preferred); + "ipv6-pd: using %s", + nm_platform_ip6_address_to_string(&address, sbuf, sizeof(sbuf))); - /* This also updates the ndisc if there are actual changes. */ - if (!ip_config_merge_and_apply(self, AF_INET6, TRUE)) - _LOGW(LOGD_IP6, "ipv6-pd: failed applying IP6 config for connection sharing"); + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_PD_6, l3cd, FALSE); + _dev_l3_cfg_commit(self, TRUE); + _dev_ipac6_ndisc_set_router_config(self); } /* @@ -10228,137 +10376,186 @@ nm_device_use_ip6_subnet(NMDevice *self, const NMPlatformIP6Address *subnet) void nm_device_copy_ip6_dns_config(NMDevice *self, NMDevice *from_device) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMIP6Config * from_config = NULL; - guint i, len; + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate * priv_src; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + const NML3ConfigData * l3cd_src = NULL; - if (applied_config_get_current(&priv->ac_ip6_config)) { - applied_config_reset_nameservers(&priv->ac_ip6_config); - applied_config_reset_searches(&priv->ac_ip6_config); + /* FIXME(l3cfg): this entire code an approach seems flawed. It's flawed, because the + * very next RA will reset the changes. */ + + if (priv->l3cds[L3_CONFIG_DATA_TYPE_AC_6].d) { + l3cd = nm_l3_config_data_new_clone(priv->l3cds[L3_CONFIG_DATA_TYPE_AC_6].d, 0); + nm_l3_config_data_clear_nameservers(l3cd, AF_INET6); + nm_l3_config_data_clear_searches(l3cd, AF_INET6); } else - applied_config_init_new(&priv->ac_ip6_config, self, AF_INET6); + l3cd = nm_device_create_l3_config_data(self, NM_IP_CONFIG_SOURCE_SHARED); - if (from_device) - from_config = nm_device_get_ip6_config(from_device); - if (!from_config) - return; + if (from_device) { + priv_src = NM_DEVICE_GET_PRIVATE(from_device); + l3cd_src = priv_src->l3cds[L3_CONFIG_DATA_TYPE_AC_6].d; + } + if (l3cd_src) { + const char *const * strvarr; + const struct in6_addr *const *addrs; + guint n; + guint i; - len = nm_ip6_config_get_num_nameservers(from_config); - for (i = 0; i < len; i++) { - applied_config_add_nameserver( - &priv->ac_ip6_config, - (const NMIPAddr *) nm_ip6_config_get_nameserver(from_config, i)); + addrs = nm_l3_config_data_get_nameservers(l3cd_src, AF_INET6, &n); + for (i = 0; i < n; i++) + nm_l3_config_data_add_nameserver(l3cd, AF_INET6, addrs[i]); + + strvarr = nm_l3_config_data_get_searches(l3cd_src, AF_INET6, &n); + for (i = 0; i < n; i++) + nm_l3_config_data_add_search(l3cd, AF_INET6, strvarr[i]); } - len = nm_ip6_config_get_num_searches(from_config); - for (i = 0; i < len; i++) { - applied_config_add_search(&priv->ac_ip6_config, nm_ip6_config_get_search(from_config, i)); - } + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_AC_6, l3cd, FALSE); - if (!ip_config_merge_and_apply(self, AF_INET6, TRUE)) - _LOGW(LOGD_IP6, "ipv6-pd: failed applying DNS config for connection sharing"); + _dev_l3_cfg_commit(self, TRUE); } /*****************************************************************************/ -static void -linklocal6_failed(NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - nm_clear_g_source(&priv->linklocal6_timeout_id); - nm_device_activate_schedule_ip_config_timeout(self, AF_INET6); -} - static gboolean -linklocal6_timeout_cb(gpointer user_data) -{ - NMDevice *self = user_data; - - _LOGD(LOGD_DEVICE, "linklocal6: waiting for link-local addresses failed due to timeout"); - linklocal6_failed(self); - return G_SOURCE_REMOVE; -} - -static void -linklocal6_check_complete(NMDevice *self) +_dev_ipll6_state_retry_cb(gpointer user_data) { + NMDevice * self = user_data; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; - const char * method; - if (!priv->linklocal6_timeout_id) { - /* we are not waiting for linklocal to complete. Nothing to do. */ - return; - } - - if (!priv->ext_ip6_config_captured - || !nm_ip_config_find_first_address(NM_IP_CONFIG(priv->ext_ip6_config_captured), - NM_PLATFORM_MATCH_WITH_ADDRTYPE_LINKLOCAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE_NORMAL)) { - /* we don't have a non-tentative link local address yet. Wait longer. */ - return; - } - - nm_clear_g_source(&priv->linklocal6_timeout_id); - - connection = nm_device_get_applied_connection(self); - g_assert(connection); - - method = nm_device_get_effective_ip_config_method(self, AF_INET6); - - _LOGD(LOGD_DEVICE, - "linklocal6: waiting for link-local addresses successful, continue with method %s", - method); - - if (NM_IN_STRSET(method, - NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NM_SETTING_IP6_CONFIG_METHOD_SHARED)) - addrconf6_start_with_link_ready(self); - else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) { - if (!dhcp6_start_with_link_ready(self, connection)) { - /* Time out IPv6 instead of failing the entire activation */ - nm_device_activate_schedule_ip_config_timeout(self, AF_INET6); - } - } else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - else - g_return_if_fail(FALSE); + nm_clear_g_source_inst(&priv->ipll_data_6.v6.retry_source); + _dev_ipll6_start(self); + return G_SOURCE_CONTINUE; } static void -check_and_add_ipv6ll_addr(NMDevice *self) +_dev_ipll6_set_llstate(NMDevice *self, NML3IPv6LLState llstate, const struct in6_addr *lladdr) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - struct in6_addr lladdr; - NMConnection * connection; - NMSettingIP6Config *s_ip6 = NULL; - GError * error = NULL; - const char * addr_type; - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gboolean changed = FALSE; + NMDeviceIPState state; + NMDeviceIPState old_state; - if (!priv->ipv6ll_handle) - return; + if (!lladdr) + lladdr = &nm_ip_addr_zero.addr6; - if (priv->ext_ip6_config_captured - && nm_ip_config_find_first_address(NM_IP_CONFIG(priv->ext_ip6_config_captured), - NM_PLATFORM_MATCH_WITH_ADDRTYPE_LINKLOCAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE_NORMAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE_TENTATIVE)) { - /* Already have an LL address, nothing to do */ - return; + if (priv->ipll_data_6.v6.llstate != llstate + || !IN6_ARE_ADDR_EQUAL(&priv->ipll_data_6.v6.lladdr, lladdr)) { + changed = TRUE; + priv->ipll_data_6.v6.llstate = llstate; + priv->ipll_data_6.v6.lladdr = *lladdr; } - priv->ipv6ll_has = FALSE; - memset(&priv->ipv6ll_addr, 0, sizeof(priv->ipv6ll_addr)); + nm_assert((priv->ipll_data_6.v6.ipv6ll + && NM_IN_SET(priv->ipll_data_6.v6.llstate, + NM_L3_IPV6LL_STATE_STARTING, + NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, + NM_L3_IPV6LL_STATE_READY, + NM_L3_IPV6LL_STATE_DAD_FAILED)) + || (!priv->ipll_data_6.v6.ipv6ll + && NM_IN_SET(priv->ipll_data_6.v6.llstate, + NM_L3_IPV6LL_STATE_NONE, + NM_L3_IPV6LL_STATE_DEFUNCT))); - memset(&lladdr, 0, sizeof(lladdr)); - lladdr.s6_addr16[0] = htons(0xfe80); + switch (priv->ipll_data_6.v6.llstate) { + case NM_L3_IPV6LL_STATE_NONE: + state = NM_DEVICE_IP_STATE_NONE; + break; + case NM_L3_IPV6LL_STATE_DEFUNCT: + case NM_L3_IPV6LL_STATE_DAD_FAILED: + state = NM_DEVICE_IP_STATE_FAILED; + break; + case NM_L3_IPV6LL_STATE_READY: + state = NM_DEVICE_IP_STATE_READY; + break; + case NM_L3_IPV6LL_STATE_STARTING: + case NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS: + state = NM_DEVICE_IP_STATE_PENDING; + break; + default: + state = nm_assert_unreachable_val(NM_DEVICE_IP_STATE_FAILED); + break; + } + + old_state = priv->ipll_data_6.state; + if (priv->ipll_data_6.state != state) { + priv->ipll_data_6.state = state; + changed = TRUE; + } + + if (priv->ipll_data_6.v6.llstate != NM_L3_IPV6LL_STATE_DEFUNCT) + nm_clear_g_source_inst(&priv->ipll_data_6.v6.retry_source); + else if (!priv->ipll_data_6.v6.retry_source) { + /* we schedule a timer to try to recover from this... Possibly some higher layer + * will however fail the activation... */ + priv->ipll_data_6.v6.retry_source = + nm_g_timeout_add_source(10000, _dev_ipll6_state_retry_cb, self); + } + + if (changed) { + char sbuf[NM_UTILS_INET_ADDRSTRLEN]; + + _LOGT_ipll(AF_INET6, + "set state %s (was %s, llstate=%s, lladdr=%s)", + nm_device_ip_state_to_string(priv->ipll_data_6.state), + nm_device_ip_state_to_string(old_state), + nm_l3_ipv6ll_state_to_string(priv->ipll_data_6.v6.llstate), + nm_ip_addr_is_null(AF_INET6, &priv->ipll_data_6.v6.lladdr) + ? "(none)" + : _nm_utils_inet6_ntop(&priv->ipll_data_6.v6.lladdr, sbuf)); + } + + if (changed) + _dev_ip_state_check_async(self, AF_INET6); + + if (priv->ipll_data_6.v6.llstate == NM_L3_IPV6LL_STATE_READY) { + /* if we got an IPv6LL address, we might poke some other methods + * to progress... */ + _dev_ipac6_start_continue(self); + _dev_ipdhcpx_start_continue(self, AF_INET6); + } +} + +static void +_dev_ipll6_state_change_cb(NML3IPv6LL * ipv6ll, + NML3IPv6LLState llstate, + const struct in6_addr *lladdr, + gpointer user_data) +{ + _dev_ipll6_set_llstate(user_data, llstate, lladdr); +} + +static void +_dev_ipll6_start(NMDevice *self) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMConnection * connection; + NMSettingIP6Config * s_ip6 = NULL; + gboolean assume; + const char * ifname; + NML3IPv6LLState llstate; + const struct in6_addr *lladdr; + + if (priv->ipll_data_6.v6.ipv6ll) + return; + + if (!priv->l3cfg) { + _LOGD(LOGD_IP6, "linklocal6: no IP link for IPv6"); + goto out_fail; + } + + ifname = nm_device_get_ip_iface(self); + if (!ifname) { + _LOGD(LOGD_IP6, "linklocal6: no interface name for IPv6"); + goto out_fail; + } connection = nm_device_get_applied_connection(self); if (connection) s_ip6 = NM_SETTING_IP6_CONFIG(nm_connection_get_setting_ip6_config(connection)); + assume = nm_device_sys_iface_state_is_external_or_assume(self); + if (s_ip6 && nm_setting_ip6_config_get_addr_gen_mode(s_ip6) == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) { @@ -10366,73 +10563,31 @@ check_and_add_ipv6ll_addr(NMDevice *self) const char * stable_id; stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); - if (!nm_utils_ipv6_addr_set_stable_privacy_may_fail(stable_type, - &lladdr, - nm_device_get_iface(self), - stable_id, - priv->linklocal6_dad_counter++, - &error)) { - _LOGW(LOGD_IP6, "linklocal6: failed to generate an address: %s", error->message); - g_clear_error(&error); - linklocal6_failed(self); - return; - } - addr_type = "stable-privacy"; + priv->ipll_data_6.v6.ipv6ll = nm_l3_ipv6ll_new_stable_privacy(priv->l3cfg, + assume, + stable_type, + ifname, + stable_id, + _dev_ipll6_state_change_cb, + self); } else { NMUtilsIPv6IfaceId iid; - if (priv->linklocal6_timeout_id) { - /* We already started and attempt to add a LL address. For the EUI-64 - * mode we can't pick a new one, we'll just fail. */ - _LOGW(LOGD_IP6, "linklocal6: DAD failed for an EUI-64 address"); - linklocal6_failed(self); - return; - } - if (!nm_device_get_ip_iface_identifier(self, &iid, TRUE)) { _LOGW(LOGD_IP6, "linklocal6: failed to get interface identifier; IPv6 cannot continue"); - return; + goto out_fail; } - nm_utils_ipv6_addr_set_interface_identifier(&lladdr, &iid); - addr_type = "EUI-64"; + + priv->ipll_data_6.v6.ipv6ll = + nm_l3_ipv6ll_new_token(priv->l3cfg, assume, &iid, _dev_ipll6_state_change_cb, self); } - _LOGD(LOGD_IP6, - "linklocal6: generated %s IPv6LL address %s", - addr_type, - _nm_utils_inet6_ntop(&lladdr, sbuf)); - priv->ipv6ll_has = TRUE; - priv->ipv6ll_addr = lladdr; - ip_config_merge_and_apply(self, AF_INET6, TRUE); -} + llstate = nm_l3_ipv6ll_get_state(priv->ipll_data_6.v6.ipv6ll, &lladdr); + _dev_ipll6_set_llstate(self, llstate, lladdr); + return; -static gboolean -linklocal6_start(NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - nm_clear_g_source(&priv->linklocal6_timeout_id); - - if (priv->ext_ip6_config_captured - && nm_ip_config_find_first_address(NM_IP_CONFIG(priv->ext_ip6_config_captured), - NM_PLATFORM_MATCH_WITH_ADDRTYPE_LINKLOCAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE_NORMAL)) - return TRUE; - - _LOGD(LOGD_DEVICE, - "linklocal6: starting IPv6 with method '%s', but the device has no link-local addresses " - "configured. Wait.", - nm_device_get_effective_ip_config_method(self, AF_INET6)); - - check_and_add_ipv6ll_addr(self); - - /* Depending on the network and what the 'dad_transmits' and 'retrans_time_ms' - * sysctl values are, DAD for the IPv6LL address may take quite a while. - * FIXME: use dad/retrans sysctl values if they are higher than a minimum time. - * (rh #1101809) - */ - priv->linklocal6_timeout_id = g_timeout_add_seconds(15, linklocal6_timeout_cb, self); - return FALSE; +out_fail: + _dev_ipll6_set_llstate(self, NM_L3_IPV6LL_STATE_DEFUNCT, NULL); } /*****************************************************************************/ @@ -10595,13 +10750,16 @@ set_platform_mtu(NMDevice *self, guint32 mtu) } static void -_commit_mtu(NMDevice *self, const NMIP4Config *config) +_commit_mtu(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMDeviceMtuSource source = NM_DEVICE_MTU_SOURCE_NONE; - guint32 ip6_mtu, ip6_mtu_orig; - guint32 mtu_desired, mtu_desired_orig; - guint32 mtu_plat; + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDeviceMtuSource source = NM_DEVICE_MTU_SOURCE_NONE; + const NML3ConfigData *l3cd; + guint32 ip6_mtu_orig; + guint32 ip6_mtu; + guint32 mtu_desired_orig; + guint32 mtu_desired; + guint32 mtu_plat; struct { gboolean initialized; guint32 value; @@ -10609,7 +10767,9 @@ _commit_mtu(NMDevice *self, const NMIP4Config *config) 0, }; int ifindex; - char sbuf[64], sbuf1[64], sbuf2[64]; + char sbuf[64]; + char sbuf1[64]; + char sbuf2[64]; gboolean success = TRUE; ifindex = nm_device_get_ip_ifindex(self); @@ -10623,8 +10783,11 @@ _commit_mtu(NMDevice *self, const NMIP4Config *config) return; } + l3cd = nm_l3cfg_get_combined_l3cd(priv->l3cfg, FALSE); + { - guint32 mtu = 0; + guint32 mtu = 0; + guint32 mtu2; gboolean force = FALSE; /* We take the MTU from various sources: (in order of increasing @@ -10651,9 +10814,9 @@ _commit_mtu(NMDevice *self, const NMIP4Config *config) if (NM_DEVICE_GET_CLASS(self)->get_configured_mtu) mtu = NM_DEVICE_GET_CLASS(self)->get_configured_mtu(self, &source, &force); - if (config && !force && source < NM_DEVICE_MTU_SOURCE_IP_CONFIG - && nm_ip4_config_get_mtu(config)) { - mtu = nm_ip4_config_get_mtu(config); + if (l3cd && !force && source < NM_DEVICE_MTU_SOURCE_IP_CONFIG + && (mtu2 = nm_l3_config_data_get_mtu(l3cd)) > 0) { + mtu = mtu2; source = NM_DEVICE_MTU_SOURCE_IP_CONFIG; } @@ -10842,239 +11005,181 @@ nm_device_commit_mtu(NMDevice *self) state = nm_device_get_state(self); if (state >= NM_DEVICE_STATE_CONFIG && state < NM_DEVICE_STATE_DEACTIVATING) { _LOGT(LOGD_DEVICE, "mtu: commit-mtu..."); - _commit_mtu(self, NM_DEVICE_GET_PRIVATE(self)->ip_config_4); + _commit_mtu(self); } else _LOGT(LOGD_DEVICE, "mtu: commit-mtu... skip due to state %s", nm_device_state_to_string(state)); } +/*****************************************************************************/ + static void -ndisc_config_changed(NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, NMDevice *self) +_dev_ipac6_ndisc_set_router_config(NMDevice *self) { - NMNDiscConfigMap changed = changed_int; - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - guint i; + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + const NML3ConfigData *l3cd; - g_return_if_fail(priv->act_request.obj); + if (!priv->ipac6_data.ndisc) + return; - if (!applied_config_get_current(&priv->ac_ip6_config)) - applied_config_init_new(&priv->ac_ip6_config, self, AF_INET6); + if (nm_ndisc_get_node_type(priv->ipac6_data.ndisc) != NM_NDISC_NODE_TYPE_ROUTER) + return; - if (changed & NM_NDISC_CONFIG_ADDRESSES) { - guint32 ifa_flags; - - /* Check, whether kernel is recent enough to help user space handling RA. - * If it's not supported, we have no ipv6-privacy and must add autoconf - * addresses as /128. The reason for the /128 is to prevent the kernel - * from adding a prefix route for this address. */ - ifa_flags = IFA_F_NOPREFIXROUTE; - if (NM_IN_SET(priv->ndisc_use_tempaddr, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)) - ifa_flags |= IFA_F_MANAGETEMPADDR; - - nm_ip6_config_reset_addresses_ndisc((NMIP6Config *) priv->ac_ip6_config.orig, - rdata->addresses, - rdata->addresses_n, - 64, - ifa_flags); - if (priv->ac_ip6_config.current) { - nm_ip6_config_reset_addresses_ndisc((NMIP6Config *) priv->ac_ip6_config.current, - rdata->addresses, - rdata->addresses_n, - 64, - ifa_flags); - } - } - - if (NM_FLAGS_ANY(changed, NM_NDISC_CONFIG_ROUTES | NM_NDISC_CONFIG_GATEWAYS)) { - nm_ip6_config_reset_routes_ndisc((NMIP6Config *) priv->ac_ip6_config.orig, - rdata->gateways, - rdata->gateways_n, - rdata->routes, - rdata->routes_n, - nm_device_get_route_table(self, AF_INET6), - nm_device_get_route_metric(self, AF_INET6)); - if (priv->ac_ip6_config.current) { - nm_ip6_config_reset_routes_ndisc((NMIP6Config *) priv->ac_ip6_config.current, - rdata->gateways, - rdata->gateways_n, - rdata->routes, - rdata->routes_n, - nm_device_get_route_table(self, AF_INET6), - nm_device_get_route_metric(self, AF_INET6)); - } - } - - if (changed & NM_NDISC_CONFIG_DNS_SERVERS) { - /* Rebuild DNS server list from neighbor discovery cache. */ - applied_config_reset_nameservers(&priv->ac_ip6_config); - - for (i = 0; i < rdata->dns_servers_n; i++) - applied_config_add_nameserver(&priv->ac_ip6_config, - (const NMIPAddr *) &rdata->dns_servers[i].address); - } - - if (changed & NM_NDISC_CONFIG_DNS_DOMAINS) { - /* Rebuild domain list from neighbor discovery cache. */ - applied_config_reset_searches(&priv->ac_ip6_config); - - for (i = 0; i < rdata->dns_domains_n; i++) - applied_config_add_search(&priv->ac_ip6_config, rdata->dns_domains[i].domain); - } - - if (changed & NM_NDISC_CONFIG_DHCP_LEVEL) { - dhcp6_cleanup(self, CLEANUP_TYPE_DECONFIGURE, TRUE); - - priv->dhcp6.mode = rdata->dhcp_level; - if (priv->dhcp6.mode != NM_NDISC_DHCP_LEVEL_NONE) { - _LOGD(LOGD_DEVICE | LOGD_DHCP6, - "Activation: Stage 3 of 5 (IP Configure Start) starting DHCPv6" - " as requested by IPv6 router..."); - if (!dhcp6_start(self, FALSE)) { - if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED) { - nm_device_state_changed(self, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_DHCP_START_FAILED); - return; - } - } - } - } - - if (changed & NM_NDISC_CONFIG_HOP_LIMIT) - nm_platform_sysctl_ip_conf_set_ipv6_hop_limit_safe(nm_device_get_platform(self), - nm_device_get_ip_iface(self), - rdata->hop_limit); - - if (changed & NM_NDISC_CONFIG_REACHABLE_TIME) { - nm_platform_sysctl_ip_neigh_set_ipv6_reachable_time(nm_device_get_platform(self), - nm_device_get_ip_iface(self), - rdata->reachable_time_ms); - } - - if (changed & NM_NDISC_CONFIG_RETRANS_TIMER) { - nm_platform_sysctl_ip_neigh_set_ipv6_retrans_time(nm_device_get_platform(self), - nm_device_get_ip_iface(self), - rdata->retrans_timer_ms); - } - - if (changed & NM_NDISC_CONFIG_MTU) { - if (priv->ip6_mtu != rdata->mtu) { - _LOGD(LOGD_DEVICE, "mtu: set IPv6 MTU to %u", (guint) rdata->mtu); - priv->ip6_mtu = rdata->mtu; - } - } - - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); + /* FIXME(l3cfg): this doesn't seem right. What is the meaning of the l3cd at this + * point? Also, when do we need to reset the config (and call this function again?). */ + l3cd = nm_l3cfg_get_combined_l3cd(priv->l3cfg, FALSE); + if (l3cd) + nm_ndisc_set_config(priv->ipac6_data.ndisc, l3cd); } static void -ndisc_ra_timeout(NMNDisc *ndisc, NMDevice *self) +_dev_ipac6_set_state(NMDevice *self, NMDeviceIPState state) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - /* We don't want to stop listening for router advertisements completely, - * but instead let device activation continue activating. If an RA - * shows up later, we'll use it as long as the device is not disconnected. - */ - - _LOGD(LOGD_IP6, "timed out waiting for IPv6 router advertisement"); - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF) { - /* If RA is our only source of addressing information and we don't - * ever receive one, then time out IPv6. But if there is other - * IPv6 configuration, like manual IPv6 addresses or external IPv6 - * config, consider that sufficient for IPv6 success. - * - * FIXME: it doesn't seem correct to determine this based on which - * addresses we find inside priv->ip_config_6. - */ - if (priv->ip_config_6 - && nm_ip_config_find_first_address(NM_IP_CONFIG(priv->ip_config_6), - NM_PLATFORM_MATCH_WITH_ADDRTYPE_NORMAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE__ANY)) - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - else - nm_device_activate_schedule_ip_config_timeout(self, AF_INET6); + if (priv->ipac6_data.state != state) { + _LOGD_ipac6("set state: %s (was %s)", + nm_device_ip_state_to_string(state), + nm_device_ip_state_to_string(priv->ipac6_data.state)); + priv->ipac6_data.state = state; } } static void -addrconf6_start_with_link_ready(NMDevice *self) +_dev_ipac6_ndisc_config_changed(NMNDisc * ndisc, + const NMNDiscData * rdata, + guint changed_i, + const NML3ConfigData *l3cd, + NMDevice * self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMUtilsIPv6IfaceId iid; + _dev_ipac6_grace_period_start(self, 0, TRUE); - g_assert(priv->ndisc); + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_AC_6, l3cd, FALSE); - if (nm_device_get_ip_iface_identifier(self, &iid, FALSE)) { - _LOGD(LOGD_IP6, "addrconf6: using the device EUI-64 identifier"); - nm_ndisc_set_iid(priv->ndisc, iid); - } else { - /* Don't abort the addrconf at this point -- if ndisc needs the iid - * it will notice this itself. */ - _LOGI(LOGD_IP6, "addrconf6: no interface identifier; IPv6 address creation may fail"); - } + _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_READY); - /* Apply any manual configuration before starting RA */ - if (!ip_config_merge_and_apply(self, AF_INET6, TRUE)) - _LOGW(LOGD_IP6, "failed to apply manual IPv6 configuration"); + _dev_ipdhcp6_set_dhcp_level(self, rdata->dhcp_level); - if (nm_ndisc_get_node_type(priv->ndisc) == NM_NDISC_NODE_TYPE_ROUTER) { - nm_device_sysctl_ip_conf_set(self, AF_INET6, "forwarding", "1"); - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - priv->needs_ip6_subnet = TRUE; - g_signal_emit(self, signals[IP6_SUBNET_NEEDED], 0); - } + _dev_l3_cfg_commit(self, FALSE); - priv->ndisc_changed_id = g_signal_connect(priv->ndisc, - NM_NDISC_CONFIG_RECEIVED, - G_CALLBACK(ndisc_config_changed), - self); - priv->ndisc_timeout_id = g_signal_connect(priv->ndisc, - NM_NDISC_RA_TIMEOUT_SIGNAL, - G_CALLBACK(ndisc_ra_timeout), - self); + _dev_ip_state_check_async(self, AF_INET6); +} - ndisc_set_router_config(priv->ndisc, self); - nm_ndisc_start(priv->ndisc); - priv->ndisc_started = TRUE; - return; +static void +_dev_ipac6_handle_timeout(NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + _LOGD_ipac6("timeout for autoconf (IPv6 router advertisement) reached"); + + nm_clear_g_source_inst(&priv->ipac6_data.ndisc_grace_source); + + _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_FAILED); + + _dev_ip_state_check_async(self, AF_INET6); +} + +static void +_dev_ipac6_ndisc_ra_timeout(NMNDisc *ndisc, NMDevice *self) +{ + _dev_ipac6_handle_timeout(self); } static gboolean -addrconf6_start(NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr) +_dev_ipac6_grace_period_expired(gpointer user_data) +{ + _dev_ipac6_handle_timeout(user_data); + return G_SOURCE_REMOVE; +} + +static gboolean +_dev_ipac6_grace_period_start(NMDevice *self, guint32 timeout_sec, gboolean force_restart) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gboolean stopped; + + /* In any other case (expired lease, assumed connection, etc.), + * wait for some time before failing the IP method. + */ + if (!force_restart && priv->ipac6_data.ndisc_grace_source) { + /* already pending. */ + return FALSE; + } + + /* Start a grace period equal to the RA timeout multiplied + * by a constant factor. */ + + stopped = nm_clear_g_source_inst(&priv->ipac6_data.ndisc_grace_source); + + if (timeout_sec == 0) { + if (stopped) + _LOGD_ipac6("grace period stopped"); + return FALSE; + } + + nm_assert(timeout_sec <= G_MAXINT32); + + if (timeout_sec >= G_MAXUINT / (GRACE_PERIOD_MULTIPLIER * 1000u)) + timeout_sec = NM_RA_TIMEOUT_INFINITY; + + if (timeout_sec == NM_RA_TIMEOUT_INFINITY) { + _LOGD_ipac6("grace period starts with infinity timeout"); + priv->ipac6_data.ndisc_grace_source = g_source_ref(nm_g_source_sentinel_get(0)); + } else { + _LOGD_ipac6("grace period starts with %u seconds", timeout_sec); + priv->ipac6_data.ndisc_grace_source = + nm_g_timeout_add_source(timeout_sec * (GRACE_PERIOD_MULTIPLIER * 1000u), + _dev_ipac6_grace_period_expired, + self); + } + + return TRUE; +} + +static void +_dev_ipac6_start(NMDevice *self) { NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); NMConnection * connection; - NMSettingIP6Config *s_ip6 = NULL; - GError * error = NULL; + NMSettingIP6Config *s_ip = NULL; + NMNDiscNodeType node_type; NMUtilsStableType stable_type; const char * stable_id; - NMNDiscNodeType node_type; int max_addresses; int router_solicitations; int router_solicitation_interval; guint32 ra_timeout; guint32 default_ra_timeout; + NMUtilsIPv6IfaceId iid; - if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR)) { - _LOGI(LOGD_IP6, "addrconf6: kernel does not support IPv6"); - return FALSE; + if (priv->ipac6_data.state == NM_DEVICE_IP_STATE_NONE) { + if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR)) { + _LOGI_ipac6("addrconf6: kernel does not support IPv6"); + _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_FAILED); + _dev_ip_state_check_async(self, AF_INET6); + return; + } + + _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_PENDING); + } + + if (NM_IN_SET(priv->ipll_data_6.state, NM_DEVICE_IP_STATE_NONE, NM_DEVICE_IP_STATE_PENDING)) { + _dev_ipac6_grace_period_start(self, 30, TRUE); + _dev_ipll6_start(self); + return; + } + + if (priv->ipac6_data.ndisc) { + /* we already started. Nothing to do. */ + return; } connection = nm_device_get_applied_connection(self); - g_assert(connection); + if (connection) + s_ip = NM_SETTING_IP6_CONFIG(nm_connection_get_setting_ip6_config(connection)); - nm_assert(!applied_config_get_current(&priv->ac_ip6_config)); - applied_config_clear(&priv->ac_ip6_config); - - nm_clear_pointer(&priv->rt6_temporary_not_available, g_hash_table_unref); - nm_clear_g_source(&priv->rt6_temporary_not_available_id); - - s_ip6 = NM_SETTING_IP6_CONFIG(nm_connection_get_setting_ip6_config(connection)); - g_assert(s_ip6); + g_return_if_fail(s_ip); if (nm_streq(nm_device_get_effective_ip_config_method(self, AF_INET6), NM_SETTING_IP6_CONFIG_METHOD_SHARED)) @@ -11097,60 +11202,101 @@ addrconf6_start(NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr) ra_timeout = default_ra_timeout; } - stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); - priv->ndisc = nm_lndp_ndisc_new(nm_device_get_platform(self), - nm_device_get_ip_ifindex(self), - nm_device_get_ip_iface(self), - stable_type, - stable_id, - nm_setting_ip6_config_get_addr_gen_mode(s_ip6), - node_type, - max_addresses, - router_solicitations, - router_solicitation_interval, - ra_timeout, - &error); - if (!priv->ndisc) { - _LOGE(LOGD_IP6, "addrconf6: failed to start neighbor discovery: %s", error->message); - g_error_free(error); - return FALSE; + stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); + + { + const NMNDiscConfig config = { + .l3cfg = nm_device_get_l3cfg(self), + .ifname = nm_device_get_ip_iface(self), + .stable_type = stable_type, + .network_id = stable_id, + .addr_gen_mode = nm_setting_ip6_config_get_addr_gen_mode(s_ip), + .node_type = node_type, + .max_addresses = max_addresses, + .router_solicitations = router_solicitations, + .router_solicitation_interval = router_solicitation_interval, + .ra_timeout = ra_timeout, + .ip6_privacy = _prop_get_ipv6_ip6_privacy(self), + }; + + priv->ipac6_data.ndisc = nm_lndp_ndisc_new(&config); + + priv->ipac6_data.ndisc_changed_id = + g_signal_connect(priv->ipac6_data.ndisc, + NM_NDISC_CONFIG_RECEIVED, + G_CALLBACK(_dev_ipac6_ndisc_config_changed), + self); + priv->ipac6_data.ndisc_timeout_id = + g_signal_connect(priv->ipac6_data.ndisc, + NM_NDISC_RA_TIMEOUT_SIGNAL, + G_CALLBACK(_dev_ipac6_ndisc_ra_timeout), + self); } - priv->ndisc_use_tempaddr = use_tempaddr; - - /* ensure link local is ready... */ - if (!linklocal6_start(self)) { - /* wait for the LL address to show up */ - return TRUE; + if (nm_device_get_ip_iface_identifier(self, &iid, FALSE)) { + _LOGD_ipac6("using the device EUI-64 identifier"); + nm_ndisc_set_iid(priv->ipac6_data.ndisc, iid); + } else { + /* Don't abort the addrconf at this point -- if ndisc needs the iid + * it will notice this itself. */ + _LOGD_ipac6("no interface identifier; IPv6 address creation may fail"); } - /* already have the LL address; kick off neighbor discovery */ - addrconf6_start_with_link_ready(self); - return TRUE; + if (nm_ndisc_get_node_type(priv->ipac6_data.ndisc) == NM_NDISC_NODE_TYPE_ROUTER) { + nm_device_sysctl_ip_conf_set(self, AF_INET6, "forwarding", "1"); + priv->needs_ip6_subnet = TRUE; + g_signal_emit(self, signals[IP6_SUBNET_NEEDED], 0); + } + + _dev_ipac6_ndisc_set_router_config(self); + + if (node_type == NM_NDISC_NODE_TYPE_ROUTER) + _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_READY); + else + _dev_ipac6_grace_period_start(self, ra_timeout, TRUE); + + nm_ndisc_start(priv->ipac6_data.ndisc); +} + +void +nm_device_ip_method_autoconf6_start(NMDevice *self) +{ + _dev_ipac6_start(self); } static void -addrconf6_cleanup(NMDevice *self) +_dev_ipac6_start_continue(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - priv->ndisc_started = FALSE; - nm_clear_g_signal_handler(priv->ndisc, &priv->ndisc_changed_id); - nm_clear_g_signal_handler(priv->ndisc, &priv->ndisc_timeout_id); + if (priv->ipac6_data.state != NM_DEVICE_IP_STATE_NONE) + _dev_ipac6_start(self); +} - applied_config_clear(&priv->ac_ip6_config); - nm_clear_pointer(&priv->rt6_temporary_not_available, g_hash_table_unref); - nm_clear_g_source(&priv->rt6_temporary_not_available_id); - if (priv->ndisc) { - nm_ndisc_stop(priv->ndisc); - g_clear_object(&priv->ndisc); +static void +_dev_ipac6_cleanup(NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + nm_clear_g_source_inst(&priv->ipac6_data.ndisc_grace_source); + + nm_clear_g_signal_handler(priv->ipac6_data.ndisc, &priv->ipac6_data.ndisc_changed_id); + nm_clear_g_signal_handler(priv->ipac6_data.ndisc, &priv->ipac6_data.ndisc_timeout_id); + + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_AC_6, NULL, FALSE); + + if (priv->ipac6_data.ndisc) { + nm_ndisc_stop(priv->ipac6_data.ndisc); + g_clear_object(&priv->ipac6_data.ndisc); } + + _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_NONE); } /*****************************************************************************/ static void -save_ip6_properties(NMDevice *self) +_dev_sysctl_save_ip6_properties(NMDevice *self) { static const char *const ip6_properties_to_save[] = { "accept_ra", @@ -11183,61 +11329,80 @@ save_ip6_properties(NMDevice *self) } static void -restore_ip6_properties(NMDevice *self) +_dev_sysctl_restore_ip6_properties(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; g_hash_table_iter_init(&iter, priv->ip6_saved_properties); - while (g_hash_table_iter_next(&iter, &key, &value)) { - /* Don't touch "disable_ipv6" if we're doing userland IPv6LL */ - if (priv->ipv6ll_handle && nm_streq(key, "disable_ipv6")) - continue; + while (g_hash_table_iter_next(&iter, &key, &value)) nm_device_sysctl_ip_conf_set(self, AF_INET6, key, value); +} + +static void +_dev_sysctl_set_disable_ipv6(NMDevice *self, gboolean do_disable) +{ + nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", do_disable ? "1" : "0"); +} + +/*****************************************************************************/ + +static void +_dev_addrgenmode6_set(NMDevice *self, guint8 addr_gen_mode) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + int ifindex = nm_device_get_ip_ifindex(self); + const NMPlatformLink *plink; + int r; + int cur_addr_gen_mode; + char sbuf[100]; + + if (ifindex <= 0) + return; + + plink = nm_platform_link_get(nm_device_get_platform(self), ifindex); + if (!plink) + return; + + cur_addr_gen_mode = _nm_platform_link_get_inet6_addr_gen_mode(plink); + nm_assert(cur_addr_gen_mode >= 0 && cur_addr_gen_mode <= 255); + + if (!priv->addrgenmode6_data.previous_mode_has) { + priv->addrgenmode6_data.previous_mode_has = TRUE; + priv->addrgenmode6_data.previous_mode_val = cur_addr_gen_mode; + nm_assert(priv->addrgenmode6_data.previous_mode_val == cur_addr_gen_mode); } -} -static void -set_disable_ipv6(NMDevice *self, const char *value) -{ - /* We only touch disable_ipv6 when NM is not managing the IPv6LL address */ - if (!NM_DEVICE_GET_PRIVATE(self)->ipv6ll_handle) - nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", value); -} + _LOGD_ip(AF_INET6, + "addrgenmode6: set %s%s", + nm_platform_link_inet6_addrgenmode2str(addr_gen_mode, sbuf, sizeof(sbuf)), + (cur_addr_gen_mode == addr_gen_mode) ? " (already set)" : ""); -static void -set_nm_ipv6ll(NMDevice *self, gboolean enable) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - int ifindex = nm_device_get_ip_ifindex(self); + if (cur_addr_gen_mode == addr_gen_mode) + return; - priv->ipv6ll_handle = enable; - if (ifindex > 0) { - int r; + r = nm_platform_link_set_inet6_addr_gen_mode(nm_device_get_platform(self), + ifindex, + addr_gen_mode); + if (r < 0) { + _NMLOG_ip(NM_IN_SET(r, -NME_PL_NOT_FOUND, -NME_PL_OPNOTSUPP) ? LOGL_DEBUG : LOGL_WARN, + AF_INET6, + "addrgenmode6: failed to set %s: (%s)", + nm_platform_link_inet6_addrgenmode2str(addr_gen_mode, sbuf, sizeof(sbuf)), + nm_strerror(r)); + } - _LOGD(LOGD_IP6, "will %s userland IPv6LL", enable ? "enable" : "disable"); - r = nm_platform_link_set_inet6_addr_gen_mode(nm_device_get_platform(self), - ifindex, - enable ? NM_IN6_ADDR_GEN_MODE_NONE - : NM_IN6_ADDR_GEN_MODE_EUI64); - if (r < 0) { - _NMLOG(NM_IN_SET(r, -NME_PL_NOT_FOUND, -NME_PL_OPNOTSUPP) ? LOGL_DEBUG : LOGL_WARN, - LOGD_IP6, - "failed to %s userspace IPv6LL address handling (%s)", - enable ? "enable" : "disable", - nm_strerror(r)); - } + if (addr_gen_mode == NM_IN6_ADDR_GEN_MODE_NONE) { + gs_free char *value = NULL; - if (enable) { - gs_free char *value = NULL; - - /* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */ - value = nm_device_sysctl_ip_conf_get(self, AF_INET6, "disable_ipv6"); - if (nm_streq0(value, "0")) - nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", "1"); - - /* Ensure IPv6 is enabled */ + /* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */ + _LOGD_ip(AF_INET6, + "addrgenmode6: toggle disable_ipv6 sysctl after disabling addr-gen-mode"); + value = nm_device_sysctl_ip_conf_get(self, AF_INET6, "disable_ipv6"); + if (nm_streq0(value, "0")) { + nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", "1"); nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", "0"); } } @@ -11263,30 +11428,51 @@ ip_requires_slaves(NMDevice *self, int addr_family) NM_SETTING_IP6_CONFIG_METHOD_DHCP); } -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * self, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) +static const char * +get_ip_method_auto(NMDevice *self, int addr_family) +{ + return NM_IS_IPv4(addr_family) ? NM_SETTING_IP4_CONFIG_METHOD_AUTO + : NM_SETTING_IP6_CONFIG_METHOD_AUTO; +} + +static void +activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family) { const int IS_IPv4 = NM_IS_IPv4(addr_family); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); NMConnection * connection; - NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; + int ip_ifindex; const char * method; - nm_assert_addr_family(addr_family); + if (nm_device_sys_iface_state_is_external(self)) + goto out; connection = nm_device_get_applied_connection(self); + g_return_if_fail(connection); - g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); + ip_ifindex = nm_device_get_ip_ifindex(self); + + if (ip_ifindex > 0 && !nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex) + && !nm_device_sys_iface_state_is_external(self)) { + nm_platform_link_change_flags(nm_device_get_platform(self), ip_ifindex, IFF_UP, TRUE); + if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex)) + _LOGW(LOGD_DEVICE, + "interface %s not up for IP configuration", + nm_device_get_ip_iface(self)); + } if (connection_ip_method_requires_carrier(connection, addr_family, NULL) && nm_device_is_master(self) && !priv->carrier) { - _LOGI(LOGD_IP | LOGD_DEVICE, - "IPv%c config waiting until carrier is on", - nm_utils_addr_family_to_char(addr_family)); - return NM_ACT_STAGE_RETURN_IP_WAIT; + if (!priv->ip_data_x[IS_IPv4].wait_for_carrier) { + _LOGT_ip(addr_family, "waiting until carrier is on"); + priv->ip_data_x[IS_IPv4].wait_for_carrier = TRUE; + } + goto out; + } + if (priv->ip_data_x[IS_IPv4].wait_for_carrier) { + _LOGT_ip(addr_family, "waiting until carrier completed"); + priv->ip_data_x[IS_IPv4].wait_for_carrier = FALSE; } if (nm_device_is_master(self) && ip_requires_slaves(self, addr_family)) { @@ -11294,94 +11480,56 @@ act_stage3_ip_config_start(NMDevice * self, * a successful IP configuration attempt, then postpone IP addressing. */ if (!have_any_ready_slaves(self)) { - _LOGI(LOGD_DEVICE | LOGD_IP, - "IPv%c config waiting until slaves are ready", - nm_utils_addr_family_to_char(addr_family)); - return NM_ACT_STAGE_RETURN_IP_WAIT; + if (!priv->ip_data_x[IS_IPv4].wait_for_ports) { + _LOGT_ip(addr_family, "waiting for ports"); + priv->ip_data_x[IS_IPv4].wait_for_ports = TRUE; + } + goto out; } } - - if (!IS_IPv4) - priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_NONE; + if (priv->ip_data_x[IS_IPv4].wait_for_ports) { + _LOGT_ip(addr_family, "waiting until ports completed"); + priv->ip_data_x[IS_IPv4].wait_for_ports = FALSE; + } method = nm_device_get_effective_ip_config_method(self, addr_family); - _LOGD(LOGD_IP | LOGD_DEVICE, - "IPv%c config method is %s", - nm_utils_addr_family_to_char(addr_family), - method); + if (nm_streq(method, + IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_AUTO : NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { + /* "auto" usually means DHCPv6 or autoconf6, but it doesn't have to be. Subclasses + * can overwrite it. For example, you cannot run DHCPv4 on PPP/WireGuard links. */ + method = klass->get_ip_method_auto(self, addr_family); + } + + if (klass->ready_for_ip_config && !klass->ready_for_ip_config(self)) + goto out_devip; + + _dev_ipmanual_start(self); if (IS_IPv4) { - if (NM_IN_STRSET(method, - NM_SETTING_IP4_CONFIG_METHOD_AUTO, - NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { - NMSettingIPConfig *s_ip4; - NMIP4Config ** configs, *config; - guint num_addresses; - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_return_val_if_fail(s_ip4, NM_ACT_STAGE_RETURN_FAILURE); - num_addresses = nm_setting_ip_config_get_num_addresses(s_ip4); - - if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { - ret = dhcp4_start(self); - if (ret == NM_ACT_STAGE_RETURN_FAILURE) { - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_DHCP_START_FAILED); - return ret; - } - } else { - g_return_val_if_fail(num_addresses != 0, NM_ACT_STAGE_RETURN_FAILURE); - ret = NM_ACT_STAGE_RETURN_POSTPONE; - } - - if (num_addresses) { - config = nm_device_ip4_config_new(self); - nm_ip4_config_merge_setting(config, - nm_connection_get_setting_ip4_config(connection), - NM_SETTING_CONNECTION_MDNS_DEFAULT, - NM_SETTING_CONNECTION_LLMNR_DEFAULT, - NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT, - nm_device_get_route_table(self, AF_INET), - nm_device_get_route_metric(self, AF_INET)); - configs = g_new0(NMIP4Config *, 2); - configs[0] = config; - ipv4_dad_start(self, configs, ipv4_manual_method_apply); - } - } else if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) { - ret = ipv4ll_start(self); - if (ret == NM_ACT_STAGE_RETURN_FAILURE) - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED); - } else if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) { - if (out_config) { - *out_config = shared4_new_config(self, connection); - if (*out_config) { - priv->dnsmasq_manager = nm_dnsmasq_manager_new(nm_device_get_ip_iface(self)); - ret = NM_ACT_STAGE_RETURN_SUCCESS; - } else { - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - ret = NM_ACT_STAGE_RETURN_FAILURE; - } - } else - g_return_val_if_reached(NM_ACT_STAGE_RETURN_FAILURE); - } else if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) - ret = NM_ACT_STAGE_RETURN_SUCCESS; - else - _LOGW(LOGD_IP4, "unhandled IPv4 config method '%s'; will fail", method); - - return ret; - } else { - NMSettingIP6ConfigPrivacy ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; - const char * ip6_privacy_str = "0"; - NMPlatform * platform; - int ifindex; + if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) + _dev_ipdhcpx_start(self, AF_INET); + else if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) + _dev_ipll4_start(self); + else if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) + _dev_ipshared4_start(self); + else if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) + priv->ip_data_x[IS_IPv4].is_disabled = TRUE; + else if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { + /* pass */ + } else + nm_assert_not_reached(); + } + if (!IS_IPv4) { if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) { - nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", "1"); - return NM_ACT_STAGE_RETURN_IP_DONE; - } - - if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { - if (!nm_device_sys_iface_state_is_external(self)) { + if (!priv->ip_data_x[IS_IPv4].is_disabled) { + priv->ip_data_x[IS_IPv4].is_disabled = TRUE; + nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", "1"); + } + } else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { + if (!priv->ip_data_x[IS_IPv4].is_ignore) { + priv->ip_data_x[IS_IPv4].is_ignore = TRUE; if (priv->master) { /* If a device only has an IPv6 link-local address, * we don't generate an assumed connection. Therefore, @@ -11391,165 +11539,62 @@ act_stage3_ip_config_start(NMDevice * self, * slave should not depend on the previous state. Flush * addresses and routes on activation. */ - ifindex = nm_device_get_ip_ifindex(self); - platform = nm_device_get_platform(self); - - if (ifindex > 0) { - gs_unref_object NMIP6Config *config = nm_device_ip6_config_new(self); - - nm_platform_ip_route_flush(platform, AF_INET6, ifindex); - nm_platform_ip_address_flush(platform, AF_INET6, ifindex); - nm_device_set_ip_config(self, AF_INET6, (NMIPConfig *) config, FALSE, NULL); + if (ip_ifindex > 0) { + nm_platform_ip_route_flush(nm_device_get_platform(self), + AF_INET6, + ip_ifindex); + nm_platform_ip_address_flush(nm_device_get_platform(self), + AF_INET6, + ip_ifindex); } } else { - gboolean ipv6ll_handle_old = priv->ipv6ll_handle; - /* When activating an IPv6 'ignore' connection we need to revert back * to kernel IPv6LL, but the kernel won't actually assign an address * to the interface until disable_ipv6 is bounced. */ - set_nm_ipv6ll(self, FALSE); - if (ipv6ll_handle_old) - nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", "1"); - restore_ip6_properties(self); + _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_EUI64); + _dev_sysctl_set_disable_ipv6(self, TRUE); + _dev_sysctl_restore_ip6_properties(self); } } - return NM_ACT_STAGE_RETURN_IP_DONE; - } + } else { + /* Ensure the MTU makes sense. If it was below 1280 the kernel would not + * expose any ipv6 sysctls or allow presence of any addresses on the interface, + * including LL, which * would make it impossible to autoconfigure MTU to a + * correct value. */ + _commit_mtu(self); - /* Ensure the MTU makes sense. If it was below 1280 the kernel would not - * expose any ipv6 sysctls or allow presence of any addresses on the interface, - * including LL, which * would make it impossible to autoconfigure MTU to a - * correct value. */ - _commit_mtu(self, priv->ip_config_4); + /* Any method past this point requires an IPv6LL address. Use NM-controlled + * IPv6LL if this is not an assumed connection, since assumed connections + * will already have IPv6 set up. + */ + _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); - /* Any method past this point requires an IPv6LL address. Use NM-controlled - * IPv6LL if this is not an assumed connection, since assumed connections - * will already have IPv6 set up. - */ - if (!nm_device_sys_iface_state_is_external_or_assume(self)) - set_nm_ipv6ll(self, TRUE); + /* Re-enable IPv6 on the interface */ + nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "0"); + _dev_sysctl_set_disable_ipv6(self, FALSE); + _dev_ipll6_start(self); - /* Re-enable IPv6 on the interface */ - nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "0"); - set_disable_ipv6(self, "0"); - - /* Synchronize external IPv6 configuration with kernel, since - * linklocal6_start() uses the information there to determine if we can - * proceed with the selected method (SLAAC, DHCP, link-local). - */ - nm_platform_process_events(nm_device_get_platform(self)); - g_clear_object(&priv->ext_ip6_config_captured); - priv->ext_ip6_config_captured = - nm_ip6_config_capture(nm_device_get_multi_index(self), - nm_device_get_platform(self), - nm_device_get_ip_ifindex(self), - NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); - - ip6_privacy = _prop_get_ipv6_ip6_privacy(self); - - if (NM_IN_STRSET(method, - NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { - if (!addrconf6_start(self, ip6_privacy)) { - /* IPv6 might be disabled; allow IPv4 to proceed */ - ret = NM_ACT_STAGE_RETURN_IP_FAIL; + if (NM_IN_STRSET(method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) + _dev_ipac6_start(self); + else if (NM_IN_STRSET(method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) + _dev_ipshared6_start(self); + else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) { + priv->ipdhcp_data_6.v6.mode = NM_NDISC_DHCP_LEVEL_MANAGED; + _dev_ipdhcpx_start(self, AF_INET6); } else - ret = NM_ACT_STAGE_RETURN_POSTPONE; - } else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) { - ret = - linklocal6_start(self) ? NM_ACT_STAGE_RETURN_SUCCESS : NM_ACT_STAGE_RETURN_POSTPONE; - } else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) { - priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_MANAGED; - if (!dhcp6_start(self, TRUE)) { - /* IPv6 might be disabled; allow IPv4 to proceed */ - ret = NM_ACT_STAGE_RETURN_IP_FAIL; - } else - ret = NM_ACT_STAGE_RETURN_POSTPONE; - } else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) - ret = NM_ACT_STAGE_RETURN_SUCCESS; - else - _LOGW(LOGD_IP6, "unhandled IPv6 config method '%s'; will fail", method); - - if (ret != NM_ACT_STAGE_RETURN_FAILURE - && !nm_device_sys_iface_state_is_external_or_assume(self)) { - switch (ip6_privacy) { - case NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN: - case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: - ip6_privacy_str = "0"; - break; - case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: - ip6_privacy_str = "1"; - break; - case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: - ip6_privacy_str = "2"; - break; - } - nm_device_sysctl_ip_conf_set(self, AF_INET6, "use_tempaddr", ip6_privacy_str); + nm_assert(NM_IN_STRSET(method, + NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)); } - - return ret; - } -} - -gboolean -nm_device_activate_stage3_ip_start(NMDevice *self, int addr_family) -{ - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMActStageReturn ret; - NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; - gs_unref_object NMIPConfig *ip_config = NULL; - - g_assert(priv->ip_state_x[IS_IPv4] == NM_DEVICE_IP_STATE_WAIT); - - if (nm_device_sys_iface_state_is_external(self)) { - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); - return TRUE; } - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_CONF); +out_devip: + if (klass->act_stage3_ip_config) + klass->act_stage3_ip_config(self, addr_family); - ret = NM_DEVICE_GET_CLASS(self)->act_stage3_ip_config_start(self, - addr_family, - (gpointer *) &ip_config, - &failure_reason); - - switch (ret) { - case NM_ACT_STAGE_RETURN_SUCCESS: - if (!IS_IPv4) { - /* Here we get a static IPv6 config, like for Shared where it's - * autogenerated or from modems where it comes from ModemManager. - */ - if (!ip_config) - ip_config = nm_device_ip_config_new(self, addr_family); - nm_assert(!applied_config_get_current(&priv->ac_ip6_config)); - applied_config_init(&priv->ac_ip6_config, ip_config); - ip_config = NULL; - } - nm_device_activate_schedule_ip_config_result(self, addr_family, ip_config); - break; - case NM_ACT_STAGE_RETURN_IP_DONE: - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); - break; - case NM_ACT_STAGE_RETURN_FAILURE: - nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, failure_reason); - return FALSE; - case NM_ACT_STAGE_RETURN_IP_FAIL: - /* Activation not wanted */ - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_FAIL); - break; - case NM_ACT_STAGE_RETURN_IP_WAIT: - /* Wait for something to try IP config again */ - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_WAIT); - break; - default: - g_assert(ret == NM_ACT_STAGE_RETURN_POSTPONE); - } - - return TRUE; +out: + _dev_ip_state_check_async(self, addr_family); } static void @@ -11576,12 +11621,12 @@ fw_change_zone_cb(NMFirewalldManager * firewalld_manager, switch (priv->fw_state) { case FIREWALL_STATE_WAIT_STAGE_3: priv->fw_state = FIREWALL_STATE_INITIALIZED; - nm_device_activate_schedule_stage3_ip_config_start(self); + nm_device_activate_schedule_stage3_ip_config(self, TRUE); break; case FIREWALL_STATE_WAIT_IP_CONFIG: priv->fw_state = FIREWALL_STATE_INITIALIZED; - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE - || priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE) + if (priv->ip_data_4.state == NM_DEVICE_IP_STATE_READY + || priv->ip_data_6.state == NM_DEVICE_IP_STATE_READY) nm_device_start_ip_check(self); break; case FIREWALL_STATE_INITIALIZED: @@ -11633,24 +11678,48 @@ fw_change_zone(NMDevice *self) self); } -/* - * activate_stage3_ip_config_start - * - * Begin automatic/manual IP configuration - * - */ static void -activate_stage3_ip_config_start(NMDevice *self) +activate_stage3_ip_config(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); int ifindex; + /* stage3 is different from stage1+2. + * + * What is true in all cases is that when we start a stage, we call the corresponding + * nm_device_activate_schedule_stage*() function. But usually the stage cannot complete + * right away but needs to wait for some things to happen. So the activate_stage*() function + * returns, and will be later proceeded by calling *the same* stage again. That means, + * activate_stage*() must be re-entrant and be called repeatedly until we can proceed + * to the next stage. Only when the stage is completed, we schedule the next one. + * + * stage3 is different. It does IP configuration and as such (the stage handling itself) + * cannot fail. If a failure happens (for example for DHCP), we remember that (in priv->ipdhcp_data_x) + * and issue _dev_ip_state_check_async(). That one combines the DHCP state to determine the + * overall per-address-family state (priv->ip_data_x). Those states are then combined + * further into priv->combinedip_state, which then leads to nm_device_state_changed() + * (which for example can make the device fully ACTIVATED or FAILED). + * + * The difference between stage1+2 and stage3 is that IP configuration is running continuously + * while the device is active. As such the activate_stage3_ip_config() does not fail directly, + * unlike the other stages which can abort via NM_ACT_STAGE_RETURN_FAILURE. */ + g_return_if_fail(priv->act_request.obj); ifindex = nm_device_get_ip_ifindex(self); + if (priv->ip_data_4.do_reapply) { + _LOGD_ip(AF_INET, "reapply..."); + _cleanup_ip_pre(self, AF_INET, CLEANUP_TYPE_DECONFIGURE); + } + if (priv->ip_data_6.do_reapply) { + _LOGD_ip(AF_INET6, "reapply..."); + _cleanup_ip_pre(self, AF_INET6, CLEANUP_TYPE_DECONFIGURE); + } + /* Add the interface to the specified firewall zone */ - if (priv->fw_state == FIREWALL_STATE_UNMANAGED) { + switch (priv->fw_state) { + case FIREWALL_STATE_UNMANAGED: if (nm_device_sys_iface_state_is_external(self)) { /* fake success */ priv->fw_state = FIREWALL_STATE_INITIALIZED; @@ -11660,143 +11729,141 @@ activate_stage3_ip_config_start(NMDevice *self) return; } /* no ifindex, nothing to do for now */ - } else if (priv->fw_state == FIREWALL_STATE_WAIT_STAGE_3) { + break; + case FIREWALL_STATE_WAIT_STAGE_3: /* a firewall call for stage3 is pending. Return and wait. */ return; + default: + nm_assert(NM_IN_SET((FirewallState) priv->fw_state, + FIREWALL_STATE_INITIALIZED, + FIREWALL_STATE_WAIT_IP_CONFIG)); + break; } - nm_assert(ifindex <= 0 || priv->fw_state == FIREWALL_STATE_INITIALIZED); - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_WAIT); - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_WAIT); + if (priv->state < NM_DEVICE_STATE_IP_CONFIG) { + _dev_ip_state_req_timeout_schedule(self, AF_INET); + _dev_ip_state_req_timeout_schedule(self, AF_INET6); - _active_connection_set_state_flags(self, NM_ACTIVATION_STATE_FLAG_LAYER2_READY); + _active_connection_set_state_flags(self, NM_ACTIVATION_STATE_FLAG_LAYER2_READY); - nm_device_state_changed(self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); + nm_device_state_changed(self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); - /* Device should be up before we can do anything with it */ - if (!nm_device_sys_iface_state_is_external(self) - && (ifindex = nm_device_get_ip_ifindex(self)) > 0 - && !nm_platform_link_is_up(nm_device_get_platform(self), ifindex)) - _LOGW(LOGD_DEVICE, - "interface %s not up for IP configuration", - nm_device_get_ip_iface(self)); - - if (nm_device_activate_ip4_state_in_wait(self) - && !nm_device_activate_stage3_ip_start(self, AF_INET)) - return; - - if (nm_device_activate_ip6_state_in_wait(self) - && !nm_device_activate_stage3_ip_start(self, AF_INET6)) - return; - - /* Proxy */ - nm_device_set_proxy_config(self, NULL); - - check_ip_state(self, TRUE, TRUE); -} - -/* - * nm_device_activate_schedule_stage3_ip_config_start - * - * Schedule IP configuration start - */ -void -nm_device_activate_schedule_stage3_ip_config_start(NMDevice *self) -{ - NMDevicePrivate *priv; - - g_return_if_fail(NM_IS_DEVICE(self)); - - priv = NM_DEVICE_GET_PRIVATE(self); - - g_return_if_fail(priv->act_request.obj); - - activation_source_schedule(self, activate_stage3_ip_config_start, AF_INET); -} - -static NMActStageReturn -act_stage4_ip_config_timeout(NMDevice * self, - int addr_family, - NMDeviceStateReason *out_failure_reason) -{ - nm_assert_addr_family(addr_family); - - if (!get_ip_config_may_fail(self, addr_family)) { - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - return NM_ACT_STAGE_RETURN_FAILURE; + /* Device should be up before we can do anything with it */ + if (!nm_device_sys_iface_state_is_external(self) && ifindex > 0 + && !nm_platform_link_is_up(nm_device_get_platform(self), ifindex)) + _LOGW(LOGD_DEVICE, + "interface %s not up for IP configuration", + nm_device_get_ip_iface(self)); } - return NM_ACT_STAGE_RETURN_SUCCESS; + activate_stage3_ip_config_for_addr_family(self, AF_INET); + activate_stage3_ip_config_for_addr_family(self, AF_INET6); } -static void -activate_stage4_ip_config_timeout_x(NMDevice *self, int addr_family) -{ - NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; - NMActStageReturn ret; - - ret = - NM_DEVICE_GET_CLASS(self)->act_stage4_ip_config_timeout(self, addr_family, &failure_reason); - - if (ret == NM_ACT_STAGE_RETURN_POSTPONE) - return; - - if (ret == NM_ACT_STAGE_RETURN_FAILURE) { - nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, failure_reason); - return; - } - g_assert(ret == NM_ACT_STAGE_RETURN_SUCCESS); - - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_FAIL); - check_ip_state(self, FALSE, TRUE); -} - -static void -activate_stage4_ip_config_timeout_4(NMDevice *self) -{ - activate_stage4_ip_config_timeout_x(self, AF_INET); -} - -static void -activate_stage4_ip_config_timeout_6(NMDevice *self) -{ - activate_stage4_ip_config_timeout_x(self, AF_INET6); -} - -#define activate_stage4_ip_config_timeout_x_fcn(addr_family) \ - (NM_IS_IPv4(addr_family) ? activate_stage4_ip_config_timeout_4 \ - : activate_stage4_ip_config_timeout_6) - void -nm_device_activate_schedule_ip_config_timeout(NMDevice *self, int addr_family) +nm_device_activate_schedule_stage3_ip_config(NMDevice *self, gboolean do_sync) { - NMDevicePrivate *priv; + activation_source_invoke_or_schedule(self, activate_stage3_ip_config, do_sync); +} - g_return_if_fail(NM_IS_DEVICE(self)); +/*****************************************************************************/ - priv = NM_DEVICE_GET_PRIVATE(self); +static void +_dev_ipsharedx_set_state(NMDevice *self, int addr_family, NMDeviceIPState state) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); - g_return_if_fail(priv->act_request.obj); + if (priv->ipshared_data_x[IS_IPv4].state != state) { + _LOGD_ipshared(addr_family, + "set state %s (was %s)", + nm_device_ip_state_to_string(state), + nm_device_ip_state_to_string(priv->ipshared_data_x[IS_IPv4].state)); + priv->ipshared_data_x[IS_IPv4].state = state; + } +} - activation_source_schedule(self, - activate_stage4_ip_config_timeout_x_fcn(addr_family), - addr_family); +static void +_dev_ipsharedx_cleanup(NMDevice *self, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + + if (IS_IPv4) { + if (priv->ipshared_data_4.v4.dnsmasq_manager) { + nm_clear_g_signal_handler(priv->ipshared_data_4.v4.dnsmasq_manager, + &priv->ipshared_data_4.v4.dnsmasq_state_id); + nm_dnsmasq_manager_stop(priv->ipshared_data_4.v4.dnsmasq_manager); + g_clear_object(&priv->ipshared_data_4.v4.dnsmasq_manager); + } + + if (priv->ipshared_data_4.v4.firewall_config) { + nm_firewall_config_apply(priv->ipshared_data_4.v4.firewall_config, FALSE); + nm_clear_pointer(&priv->ipshared_data_4.v4.firewall_config, nm_firewall_config_free); + } + + nm_clear_pointer(&priv->ipshared_data_4.v4.shared_ip_handle, nm_netns_shared_ip_release); + nm_clear_l3cd(&priv->ipshared_data_4.v4.l3cd); + } + + _dev_ipsharedx_set_state(self, addr_family, NM_DEVICE_IP_STATE_NONE); +} + +/*****************************************************************************/ + +static const NML3ConfigData * +_dev_ipshared4_new_l3cd(NMDevice *self, NMConnection *connection, NMPlatformIP4Address *out_addr4) +{ + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + NMSettingIPConfig * s_ip4; + NMPlatformIP4Address address = { + .addr_source = NM_IP_CONFIG_SOURCE_SHARED, + }; + + g_return_val_if_fail(self, NULL); + g_return_val_if_fail(connection, NULL); + + s_ip4 = nm_connection_get_setting_ip4_config(connection); + if (s_ip4 && nm_setting_ip_config_get_num_addresses(s_ip4) > 0) { + /* Use the first user-supplied address */ + NMIPAddress *user = nm_setting_ip_config_get_address(s_ip4, 0); + in_addr_t a; + + nm_ip_address_get_address_binary(user, &a); + nm_platform_ip4_address_set_addr(&address, a, nm_ip_address_get_prefix(user)); + nm_clear_pointer(&priv->ipshared_data_4.v4.shared_ip_handle, nm_netns_shared_ip_release); + } else { + if (!priv->ipshared_data_4.v4.shared_ip_handle) + priv->ipshared_data_4.v4.shared_ip_handle = + nm_netns_shared_ip_reserve(nm_device_get_netns(self)); + nm_platform_ip4_address_set_addr(&address, + priv->ipshared_data_4.v4.shared_ip_handle->addr, + 24); + } + + l3cd = nm_device_create_l3_config_data(self, NM_IP_CONFIG_SOURCE_SHARED); + nm_l3_config_data_add_address_4(l3cd, &address); + + NM_SET_OUT(out_addr4, address); + + return nm_l3_config_data_seal(g_steal_pointer(&l3cd)); } static gboolean -share_init(NMDevice *self, GError **error) +_dev_ipshared4_init(NMDevice *self) { - const char *const modules[] = {"ip_tables", - "iptable_nat", - "nf_nat_ftp", - "nf_nat_irc", - "nf_nat_sip", - "nf_nat_tftp", - "nf_nat_pptp", - "nf_nat_h323"}; - guint i; - int errsv; + static const char *const modules[] = {"ip_tables", + "iptable_nat", + "nf_nat_ftp", + "nf_nat_irc", + "nf_nat_sip", + "nf_nat_tftp", + "nf_nat_pptp", + "nf_nat_h323"}; + int errsv; + guint i; if (nm_platform_sysctl_get_int32(nm_device_get_platform(self), NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv4/ip_forward"), @@ -11807,15 +11874,7 @@ share_init(NMDevice *self, GError **error) NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv4/ip_forward"), "1")) { errsv = errno; - _LOGD(LOGD_SHARING, - "share: error enabling IPv4 forwarding: (%d) %s", - errsv, - nm_strerror_native(errsv)); - g_set_error(error, - NM_UTILS_ERROR, - NM_UTILS_ERROR_UNKNOWN, - "cannot set ipv4/ip_forward: %s", - nm_strerror_native(errsv)); + _LOGW_ipshared(AF_INET, "error enabling IPv4 forwarding: %s", nm_strerror_native(errsv)); return FALSE; } @@ -11828,10 +11887,9 @@ share_init(NMDevice *self, GError **error) NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv4/ip_dynaddr"), "1")) { errsv = errno; - _LOGD(LOGD_SHARING, - "share: error enabling dynamic addresses: (%d) %s", - errsv, - nm_strerror_native(errsv)); + _LOGD_ipshared(AF_INET, + "share: error enabling dynamic addresses: %s", + nm_strerror_native(errsv)); } for (i = 0; i < G_N_ELEMENTS(modules); i++) @@ -11840,48 +11898,87 @@ share_init(NMDevice *self, GError **error) return TRUE; } -static gboolean -start_sharing(NMDevice *self, NMIP4Config *config, GError **error) +static void +_dev_ipshared4_dnsmasq_state_changed_cb(NMDnsMasqManager *manager, guint status, gpointer user_data) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMActRequest * req; - const NMPlatformIP4Address *ip4_addr = NULL; - const char * ip_iface; - GError * local = NULL; - NMConnection * conn; - NMSettingConnection * s_con; - gboolean announce_android_metered; - NMFirewallConfig * firewall_config; + NMDevice *self = NM_DEVICE(user_data); - g_return_val_if_fail(config, FALSE); + if (status != NM_DNSMASQ_STATUS_DEAD) + return; + + _dev_ipsharedx_set_state(self, AF_INET, NM_DEVICE_IP_STATE_FAILED); + _dev_ip_state_check_async(self, AF_INET); +} + +static void +_dev_ipshared4_start(NMDevice *self) +{ + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + NMPlatformIP4Address ip4_addr; + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + const char * ip_iface; + gs_free_error GError *error = NULL; + NMConnection * applied; + + if (priv->ipshared_data_4.state != NM_DEVICE_IP_STATE_NONE) + return; + + nm_assert(!priv->ipshared_data_4.v4.firewall_config); + nm_assert(!priv->ipshared_data_4.v4.dnsmasq_manager); + nm_assert(priv->ipshared_data_4.v4.dnsmasq_state_id == 0); ip_iface = nm_device_get_ip_iface(self); - if (!ip_iface) { - g_set_error(error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, "device has no ip interface"); - return FALSE; + g_return_if_fail(ip_iface); + + applied = nm_device_get_applied_connection(self); + g_return_if_fail(applied); + + _dev_ipsharedx_set_state(self, AF_INET, NM_DEVICE_IP_STATE_PENDING); + + l3cd = _dev_ipshared4_new_l3cd(self, applied, &ip4_addr); + if (!l3cd) { + nm_assert_not_reached(); + goto out_fail; } - ip4_addr = nm_ip4_config_get_first_address(config); - if (!ip4_addr || !ip4_addr->address) { - g_set_error(error, - NM_UTILS_ERROR, - NM_UTILS_ERROR_UNKNOWN, - "could not determine IPv4 address"); - return FALSE; - } + if (!_dev_ipshared4_init(self)) + goto out_fail; - if (!share_init(self, error)) - return FALSE; + priv->ipshared_data_4.v4.firewall_config = + nm_firewall_config_new(ip_iface, ip4_addr.address, ip4_addr.plen); + nm_firewall_config_apply(priv->ipshared_data_4.v4.firewall_config, TRUE); - req = nm_device_get_act_request(self); - g_return_val_if_fail(req, FALSE); + priv->ipshared_data_4.v4.l3cd = nm_l3_config_data_ref(l3cd); + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_SHARED_4, l3cd, FALSE); - firewall_config = nm_firewall_config_new(ip_iface, ip4_addr->address, ip4_addr->plen); + /* Wait that the address gets committed before spawning dnsmasq */ + return; +out_fail: + _dev_ipsharedx_set_state(self, AF_INET, NM_DEVICE_IP_STATE_FAILED); + _dev_ip_state_check_async(self, AF_INET); +} - nm_act_request_set_shared(req, firewall_config); +static void +_dev_ipshared4_spawn_dnsmasq(NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const char * ip_iface; + gs_free_error GError *error = NULL; + NMSettingConnection * s_con; + gboolean announce_android_metered; + NMConnection * applied; - conn = nm_act_request_get_applied_connection(req); - s_con = nm_connection_get_setting_connection(conn); + nm_assert(priv->ipshared_data_4.v4.firewall_config); + nm_assert(priv->ipshared_data_4.v4.dnsmasq_state_id == 0); + nm_assert(!priv->ipshared_data_4.v4.dnsmasq_manager); + nm_assert(priv->ipshared_data_4.v4.l3cd); + + ip_iface = nm_device_get_ip_iface(self); + g_return_if_fail(ip_iface); + + applied = nm_device_get_applied_connection(self); + g_return_if_fail(applied); + s_con = nm_connection_get_setting_connection(applied); switch (nm_setting_connection_get_metered(s_con)) { case NM_METERED_YES: @@ -11903,353 +12000,54 @@ start_sharing(NMDevice *self, NMIP4Config *config, GError **error) break; } - if (!nm_dnsmasq_manager_start(priv->dnsmasq_manager, - config, + priv->ipshared_data_4.v4.dnsmasq_manager = nm_dnsmasq_manager_new(ip_iface); + if (!nm_dnsmasq_manager_start(priv->ipshared_data_4.v4.dnsmasq_manager, + priv->ipshared_data_4.v4.l3cd, announce_android_metered, - &local)) { - g_set_error(error, - NM_UTILS_ERROR, - NM_UTILS_ERROR_UNKNOWN, - "could not start dnsmasq due to %s", - local->message); - g_error_free(local); - nm_act_request_set_shared(req, NULL); - return FALSE; + &error)) { + _LOGW_ipshared(AF_INET, "could not start dnsmasq: %s", error->message); + goto out_fail; } - priv->dnsmasq_state_id = g_signal_connect(priv->dnsmasq_manager, - NM_DNS_MASQ_MANAGER_STATE_CHANGED, - G_CALLBACK(dnsmasq_state_changed_cb), - self); - return TRUE; + priv->ipshared_data_4.v4.dnsmasq_state_id = + g_signal_connect(priv->ipshared_data_4.v4.dnsmasq_manager, + NM_DNS_MASQ_MANAGER_STATE_CHANGED, + G_CALLBACK(_dev_ipshared4_dnsmasq_state_changed_cb), + self); + + _dev_ipsharedx_set_state(self, AF_INET, NM_DEVICE_IP_STATE_READY); + _dev_ip_state_check_async(self, AF_INET); + return; + +out_fail: + _dev_ipsharedx_set_state(self, AF_INET, NM_DEVICE_IP_STATE_FAILED); + _dev_ip_state_check_async(self, AF_INET); } +/*****************************************************************************/ + static void -arp_cleanup(NMDevice *self) +_dev_ipshared6_start(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - nm_clear_pointer(&priv->acd.announcing, nm_acd_manager_free); -} + _dev_ipac6_start(self); -void -nm_device_arp_announce(NMDevice *self) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; - NMSettingIPConfig *s_ip4; - guint num, i; - const guint8 * hw_addr; - size_t hw_addr_len = 0; - - arp_cleanup(self); - - hw_addr = nm_platform_link_get_address(nm_device_get_platform(self), - nm_device_get_ip_ifindex(self), - &hw_addr_len); - - if (!hw_addr || hw_addr_len != ETH_ALEN) + if (priv->ipshared_data_6.state != NM_DEVICE_IP_STATE_NONE) return; - /* We only care about manually-configured addresses; DHCP- and autoip-configured - * ones should already have been seen on the network at this point. - */ - connection = nm_device_get_applied_connection(self); - if (!connection) - return; - s_ip4 = nm_connection_get_setting_ip4_config(connection); - if (!s_ip4) - return; - num = nm_setting_ip_config_get_num_addresses(s_ip4); - if (num == 0) - return; - - priv->acd.announcing = - nm_acd_manager_new(nm_device_get_ip_ifindex(self), hw_addr, hw_addr_len, NULL, NULL); - - for (i = 0; i < num; i++) { - NMIPAddress *ip = nm_setting_ip_config_get_address(s_ip4, i); - in_addr_t addr; - - if (inet_pton(AF_INET, nm_ip_address_get_address(ip), &addr) == 1) - nm_acd_manager_add_address(priv->acd.announcing, addr); - else - g_warn_if_reached(); - } - - nm_acd_manager_announce_addresses(priv->acd.announcing); -} - -static void -activate_stage5_ip_config_result_x(NMDevice *self, int addr_family) -{ - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMActRequest * req; - const char * method; - int ip_ifindex; - int errsv; - - req = nm_device_get_act_request(self); - g_assert(req); - - nm_clear_g_source_inst(&priv->ip_req_timeout_source_x[IS_IPv4]); - - /* Interface must be IFF_UP before IP config can be applied */ - ip_ifindex = nm_device_get_ip_ifindex(self); - g_return_if_fail(ip_ifindex); - - if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex) - && !nm_device_sys_iface_state_is_external(self)) { - nm_platform_link_change_flags(nm_device_get_platform(self), ip_ifindex, IFF_UP, TRUE); - if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex)) - _LOGW(LOGD_DEVICE, - "interface %s not up for IP configuration", - nm_device_get_ip_iface(self)); - } - - if (!ip_config_merge_and_apply(self, addr_family, TRUE)) { - _LOGD(LOGD_DEVICE | LOGD_IPX(IS_IPv4), - "Activation: Stage 5 of 5 (IPv%c Commit) failed", - nm_utils_addr_family_to_char(addr_family)); - nm_device_ip_method_failed(self, addr_family, NM_DEVICE_STATE_REASON_CONFIG_FAILED); + if (!nm_platform_sysctl_set( + nm_device_get_platform(self), + NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv6/conf/all/forwarding"), + "1")) { + _LOGW_ipshared(AF_INET6, "failure to enable ipv6 forwarding"); + _dev_ipsharedx_set_state(self, AF_INET6, NM_DEVICE_IP_STATE_FAILED); + _dev_ip_state_check_async(self, AF_INET6); return; } - if (!IS_IPv4) { - if (priv->dhcp6.mode != NM_NDISC_DHCP_LEVEL_NONE - && priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF) { - if (applied_config_get_current(&priv->dhcp6.ip6_config)) { - /* If IPv6 wasn't the first IP to complete, and DHCP was used, - * then ensure dispatcher scripts get the DHCP lease information. - */ - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_6, - self, - NULL, - NULL, - NULL, - NULL); - } else { - /* still waiting for first dhcp6 lease. */ - return; - } - } - } - - /* Start IPv4 sharing/IPv6 forwarding if we need it */ - method = nm_device_get_effective_ip_config_method(self, addr_family); - if (IS_IPv4) { - if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) { - gs_free_error GError *error = NULL; - - if (!start_sharing(self, priv->ip_config_4, &error)) { - _LOGW(LOGD_SHARING, - "Activation: Stage 5 of 5 (IPv4 Commit) start sharing failed: %s", - error->message); - nm_device_ip_method_failed(self, - AF_INET, - NM_DEVICE_STATE_REASON_SHARED_START_FAILED); - return; - } - } - } else { - if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { - if (!nm_platform_sysctl_set( - nm_device_get_platform(self), - NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv6/conf/all/forwarding"), - "1")) { - errsv = errno; - _LOGE(LOGD_SHARING, - "share: error enabling IPv6 forwarding: (%d) %s", - errsv, - nm_strerror_native(errsv)); - nm_device_ip_method_failed(self, - AF_INET6, - NM_DEVICE_STATE_REASON_SHARED_START_FAILED); - return; - } - } - } - - if (IS_IPv4) { - if (priv->dhcp_data_4.client) { - gs_free_error GError *error = NULL; - - if (!nm_dhcp_client_accept(priv->dhcp_data_4.client, &error)) { - _LOGW(LOGD_DHCP4, - "Activation: Stage 5 of 5 (IPv4 Commit) error accepting lease: %s", - error->message); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_DHCP_ERROR); - return; - } - } - - /* If IPv4 wasn't the first to complete, and DHCP was used, then ensure - * dispatcher scripts get the DHCP lease information. - */ - if (priv->dhcp_data_4.client && nm_device_activate_ip4_state_in_conf(self) - && (nm_device_get_state(self) > NM_DEVICE_STATE_IP_CONFIG)) { - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_4, - self, - NULL, - NULL, - NULL, - NULL); - } - } - - if (!IS_IPv4) { - /* Check if we have to wait for DAD */ - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF && !priv->dad6_ip6_config) { - if (!priv->carrier && priv->ignore_carrier && get_ip_config_may_fail(self, AF_INET6)) - _LOGI(LOGD_DEVICE | LOGD_IP6, - "IPv6 DAD: carrier missing and ignored, not delaying activation"); - else - priv->dad6_ip6_config = dad6_get_pending_addresses(self); - - if (priv->dad6_ip6_config) { - _LOGD(LOGD_DEVICE | LOGD_IP6, "IPv6 DAD: awaiting termination"); - } else { - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); - } - } - } - - if (IS_IPv4 && priv->carrier) { - /* We send ARP announcements only when the link gets carrier, - * otherwise the announcements would be lost. Furthermore, for - * controllers having carrier implies that there is at least one - * port and therefore the MAC address is the correct one. - */ - nm_device_arp_announce(self); - } - - if (IS_IPv4) { - /* Enter the IP_CHECK state if this is the first method to complete */ - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); - } -} - -static void -activate_stage5_ip_config_result_4(NMDevice *self) -{ - activate_stage5_ip_config_result_x(self, AF_INET); -} - -static void -activate_stage5_ip_config_result_6(NMDevice *self) -{ - activate_stage5_ip_config_result_x(self, AF_INET6); -} - -#define activate_stage5_ip_config_result_x_fcn(addr_family) \ - (NM_IS_IPv4(addr_family) ? activate_stage5_ip_config_result_4 \ - : activate_stage5_ip_config_result_6) - -void -nm_device_activate_schedule_ip_config_result(NMDevice *self, int addr_family, NMIPConfig *config) -{ - NMDevicePrivate *priv; - const int IS_IPv4 = NM_IS_IPv4(addr_family); - - g_return_if_fail(NM_IS_DEVICE(self)); - g_return_if_fail(!config || (IS_IPv4 && nm_ip_config_get_addr_family(config) == AF_INET)); - - priv = NM_DEVICE_GET_PRIVATE(self); - - if (IS_IPv4) { - applied_config_init(&priv->dev_ip_config_4, config); - } else { - /* If IP had previously failed, move it back to NM_DEVICE_IP_STATE_CONF since we - * clearly now have configuration. - */ - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_FAIL) - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_CONF); - } - - activation_source_schedule(self, - activate_stage5_ip_config_result_x_fcn(addr_family), - addr_family); -} - -NMDeviceIPState -nm_device_activate_get_ip_state(NMDevice *self, int addr_family) -{ - const int IS_IPv4 = NM_IS_IPv4(addr_family); - - g_return_val_if_fail(NM_IS_DEVICE(self), NM_DEVICE_IP_STATE_NONE); - g_return_val_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6), NM_DEVICE_IP_STATE_NONE); - - return NM_DEVICE_GET_PRIVATE(self)->ip_state_x[IS_IPv4]; -} - -static void -dad6_add_pending_address(NMDevice * self, - NMPlatform * platform, - int ifindex, - const struct in6_addr *address, - NMIP6Config ** dad6_config) -{ - const NMPlatformIP6Address *pl_addr; - - pl_addr = nm_platform_ip6_address_get(platform, ifindex, address); - if (pl_addr && NM_FLAGS_HAS(pl_addr->n_ifa_flags, IFA_F_TENTATIVE) - && !NM_FLAGS_HAS(pl_addr->n_ifa_flags, IFA_F_DADFAILED) - && !NM_FLAGS_HAS(pl_addr->n_ifa_flags, IFA_F_OPTIMISTIC)) { - _LOGt(LOGD_DEVICE, - "IPv6 DAD: pending address %s", - nm_platform_ip6_address_to_string(pl_addr, NULL, 0)); - - if (!*dad6_config) - *dad6_config = nm_device_ip6_config_new(self); - - nm_ip6_config_add_address(*dad6_config, pl_addr); - } -} - -/* - * Returns a NMIP6Config containing NM-configured addresses which - * have the tentative flag, or NULL if none is present. - */ -static NMIP6Config * -dad6_get_pending_addresses(NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMIP6Config * confs[] = {(NMIP6Config *) applied_config_get_current(&priv->ac_ip6_config), - (NMIP6Config *) applied_config_get_current(&priv->dhcp6.ip6_config), - priv->con_ip_config_6, - (NMIP6Config *) applied_config_get_current(&priv->dev2_ip_config_6)}; - const NMPlatformIP6Address *addr; - NMIP6Config * dad6_config = NULL; - NMDedupMultiIter ipconf_iter; - guint i; - int ifindex; - NMPlatform * platform; - - ifindex = nm_device_get_ip_ifindex(self); - g_return_val_if_fail(ifindex > 0, NULL); - - platform = nm_device_get_platform(self); - - if (priv->ipv6ll_has) { - dad6_add_pending_address(self, platform, ifindex, &priv->ipv6ll_addr, &dad6_config); - } - - /* We are interested only in addresses that we have explicitly configured, - * not in externally added ones. - */ - for (i = 0; i < G_N_ELEMENTS(confs); i++) { - if (!confs[i]) - continue; - - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, confs[i], &addr) { - dad6_add_pending_address(self, platform, ifindex, &addr->address, &dad6_config); - } - } - - return dad6_config; + _dev_ipsharedx_set_state(self, AF_INET6, NM_DEVICE_IP_STATE_READY); + _dev_ip_state_check_async(self, AF_INET6); } /*****************************************************************************/ @@ -12290,21 +12088,6 @@ act_request_set(NMDevice *self, NMActRequest *act_request) } } -static void -dnsmasq_cleanup(NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - if (!priv->dnsmasq_manager) - return; - - nm_clear_g_signal_handler(priv->dnsmasq_manager, &priv->dnsmasq_state_id); - - nm_dnsmasq_manager_stop(priv->dnsmasq_manager); - g_object_unref(priv->dnsmasq_manager); - priv->dnsmasq_manager = NULL; -} - gboolean nm_device_is_nm_owned(NMDevice *self) { @@ -12391,32 +12174,24 @@ delete_on_deactivate_check_and_schedule(NMDevice *self) static void _cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_NONE); + _dev_ipsharedx_cleanup(self, addr_family); - if (nm_clear_g_source(&priv->queued_ip_config_id_x[IS_IPv4])) { - _LOGD(LOGD_DEVICE, - "clearing queued IP%c config change", - nm_utils_addr_family_to_char(addr_family)); - } + _dev_ipdev_cleanup(self, AF_UNSPEC); + _dev_ipdev_cleanup(self, addr_family); - if (IS_IPv4) { - dhcp4_cleanup(self, cleanup_type, FALSE); - arp_cleanup(self); - dnsmasq_cleanup(self); - ipv4ll_cleanup(self); - g_slist_free_full(priv->acd.dad_list, (GDestroyNotify) nm_acd_manager_free); - priv->acd.dad_list = NULL; - } else { - g_slist_free_full(priv->dad6_failed_addrs, (GDestroyNotify) nmp_object_unref); - priv->dad6_failed_addrs = NULL; - g_clear_object(&priv->dad6_ip6_config); - dhcp6_cleanup(self, cleanup_type, FALSE); - nm_clear_g_source(&priv->linklocal6_timeout_id); - addrconf6_cleanup(self); - } + _dev_ipdhcpx_cleanup(self, addr_family, TRUE, FALSE); + + if (!IS_IPv4) + _dev_ipac6_cleanup(self); + + _dev_ipllx_cleanup(self, addr_family); + + _dev_ipmanual_cleanup(self); + + _dev_ip_state_cleanup(self, AF_UNSPEC); + _dev_ip_state_cleanup(self, addr_family); } gboolean @@ -12487,128 +12262,6 @@ _nm_device_hash_check_invalid_keys(GHashTable * hash, return FALSE; } -void -nm_device_reactivate_ip_config(NMDevice * self, - int addr_family, - NMSettingIPConfig *s_ip_old, - NMSettingIPConfig *s_ip_new) -{ - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMDevicePrivate *priv; - const char * method_old; - const char * method_new; - - g_return_if_fail(NM_IS_DEVICE(self)); - - priv = NM_DEVICE_GET_PRIVATE(self); - - if (priv->ip_state_x[IS_IPv4] == NM_DEVICE_IP_STATE_NONE) - return; - - g_clear_object(&priv->con_ip_config_x[IS_IPv4]); - g_clear_object(&priv->ext_ip_config_x[IS_IPv4]); - if (IS_IPv4) { - g_clear_object(&priv->dev_ip_config_4.current); - } else { - g_clear_object(&priv->ac_ip6_config.current); - g_clear_object(&priv->dhcp6.ip6_config.current); - } - g_clear_object(&priv->dev2_ip_config_x[IS_IPv4].current); - - if (!IS_IPv4) { - if (priv->ipv6ll_handle && !IN6_IS_ADDR_UNSPECIFIED(&priv->ipv6ll_addr)) - priv->ipv6ll_has = TRUE; - } - - priv->con_ip_config_x[IS_IPv4] = nm_device_ip_config_new(self, addr_family); - - if (IS_IPv4) { - nm_ip4_config_merge_setting(priv->con_ip_config_4, - s_ip_new, - _prop_get_connection_mdns(self), - _prop_get_connection_llmnr(self), - _prop_get_connection_dns_over_tls(self), - nm_device_get_route_table(self, AF_INET), - nm_device_get_route_metric(self, AF_INET)); - } else { - nm_ip6_config_merge_setting(priv->con_ip_config_6, - s_ip_new, - nm_device_get_route_table(self, AF_INET6), - nm_device_get_route_metric(self, AF_INET6)); - } - - method_old = (s_ip_old ? nm_setting_ip_config_get_method(s_ip_old) : NULL) - ?: (IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_DISABLED - : NM_SETTING_IP6_CONFIG_METHOD_IGNORE); - method_new = (s_ip_new ? nm_setting_ip_config_get_method(s_ip_new) : NULL) - ?: (IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_DISABLED - : NM_SETTING_IP6_CONFIG_METHOD_IGNORE); - - if (!nm_streq0(method_old, method_new)) { - _cleanup_ip_pre(self, addr_family, CLEANUP_TYPE_DECONFIGURE); - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_WAIT); - if (!nm_device_activate_stage3_ip_start(self, addr_family)) { - _LOGW(LOGD_IP4, - "Failed to apply IPv%c configuration", - nm_utils_addr_family_to_char(addr_family)); - } - return; - } - - if (s_ip_old && s_ip_new) { - gint64 metric_old, metric_new; - - /* For dynamic IP methods (DHCP, IPv4LL, WWAN) the route metric is - * set at activation/renewal time using the value from static - * configuration. To support runtime change we need to update the - * dynamic configuration in place and tell the DHCP client the new - * value to use for future renewals. - */ - metric_old = nm_setting_ip_config_get_route_metric(s_ip_old); - metric_new = nm_setting_ip_config_get_route_metric(s_ip_new); - - if (metric_old != metric_new) { - if (IS_IPv4) { - if (priv->dev_ip_config_4.orig) { - nm_ip4_config_update_routes_metric((NMIP4Config *) priv->dev_ip_config_4.orig, - nm_device_get_route_metric(self, AF_INET)); - } - if (priv->dev2_ip_config_4.orig) { - nm_ip4_config_update_routes_metric((NMIP4Config *) priv->dev2_ip_config_4.orig, - nm_device_get_route_metric(self, AF_INET)); - } - if (priv->dhcp_data_4.client) { - nm_dhcp_client_set_route_metric(priv->dhcp_data_4.client, - nm_device_get_route_metric(self, AF_INET)); - } - } else { - if (priv->ac_ip6_config.orig) { - nm_ip6_config_update_routes_metric((NMIP6Config *) priv->ac_ip6_config.orig, - nm_device_get_route_metric(self, AF_INET6)); - } - if (priv->dhcp6.ip6_config.orig) { - nm_ip6_config_update_routes_metric((NMIP6Config *) priv->dhcp6.ip6_config.orig, - nm_device_get_route_metric(self, AF_INET6)); - } - if (priv->dev2_ip_config_6.orig) { - nm_ip6_config_update_routes_metric((NMIP6Config *) priv->dev2_ip_config_6.orig, - nm_device_get_route_metric(self, AF_INET6)); - } - if (priv->dhcp_data_6.client) { - nm_dhcp_client_set_route_metric(priv->dhcp_data_6.client, - nm_device_get_route_metric(self, AF_INET6)); - } - } - } - } - - if (nm_device_get_ip_ifindex(self) > 0 && !ip_config_merge_and_apply(self, addr_family, TRUE)) { - _LOGW(LOGD_IPX(IS_IPv4), - "Failed to reapply IPv%c configuration", - nm_utils_addr_family_to_char(addr_family)); - } -} - static void _pacrunner_manager_add(NMDevice *self) { @@ -12617,10 +12270,8 @@ _pacrunner_manager_add(NMDevice *self) nm_pacrunner_manager_remove_clear(&priv->pacrunner_conf_id); priv->pacrunner_conf_id = nm_pacrunner_manager_add(nm_pacrunner_manager_get(), - priv->proxy_config, nm_device_get_ip_iface(self), - NULL, - NULL); + nm_device_get_l3cd(self, TRUE)); } static void @@ -12628,12 +12279,12 @@ reactivate_proxy_config(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (!priv->pacrunner_conf_id) - return; - nm_device_set_proxy_config(self, priv->dhcp4.pac_url); - _pacrunner_manager_add(self); + if (priv->pacrunner_conf_id) + _pacrunner_manager_add(self); } +/*****************************************************************************/ + static gboolean can_reapply_change(NMDevice * self, const char *setting_name, @@ -12729,9 +12380,8 @@ check_and_reapply_connection(NMDevice * self, NMConnection * applied = nm_device_get_applied_connection(self); gs_unref_object NMConnection *applied_clone = NULL; gs_unref_hashtable GHashTable *diffs = NULL; - NMConnection * con_old, *con_new; - NMSettingIPConfig * s_ip4_old, *s_ip4_new; - NMSettingIPConfig * s_ip6_old, *s_ip6_new; + NMConnection * con_old; + NMConnection * con_new; GHashTableIter iter; if (priv->state < NM_DEVICE_STATE_PREPARE || priv->state > NM_DEVICE_STATE_ACTIVATED) { @@ -12780,11 +12430,11 @@ check_and_reapply_connection(NMDevice * self, && version_id != nm_active_connection_version_id_get( (NMActiveConnection *) priv->act_request.obj)) { - g_set_error_literal( - error, - NM_DEVICE_ERROR, - NM_DEVICE_ERROR_VERSION_ID_MISMATCH, - "Reapply failed because device changed in the meantime and the version-id mismatches"); + g_set_error_literal(error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_VERSION_ID_MISMATCH, + "Reapply failed because device changed in the meantime and the " + "version-id mismatches"); return FALSE; } @@ -12847,11 +12497,9 @@ check_and_reapply_connection(NMDevice * self, } else con_old = con_new = applied; - priv->v4_commit_first_time = TRUE; - priv->v6_commit_first_time = TRUE; - priv->v4_route_table_initialized = FALSE; priv->v6_route_table_initialized = FALSE; + priv->l3config_merge_flags_has = FALSE; /************************************************************************** * Reapply changes @@ -12868,20 +12516,21 @@ check_and_reapply_connection(NMDevice * self, lldp_setup(self, NM_TERNARY_DEFAULT); if (priv->state >= NM_DEVICE_STATE_IP_CONFIG) { - s_ip4_old = nm_connection_get_setting_ip4_config(con_old); - s_ip4_new = nm_connection_get_setting_ip4_config(con_new); - s_ip6_old = nm_connection_get_setting_ip6_config(con_old); - s_ip6_new = nm_connection_get_setting_ip6_config(con_new); - /* Allow reapply of MTU */ priv->mtu_source = NM_DEVICE_MTU_SOURCE_NONE; - nm_device_reactivate_ip_config(self, AF_INET, s_ip4_old, s_ip4_new); - nm_device_reactivate_ip_config(self, AF_INET6, s_ip6_old, s_ip6_new); + if (nm_g_hash_table_lookup(diffs, NM_SETTING_IP4_CONFIG_SETTING_NAME)) + priv->ip_data_4.do_reapply = TRUE; + if (nm_g_hash_table_lookup(diffs, NM_SETTING_IP6_CONFIG_SETTING_NAME)) + priv->ip_data_6.do_reapply = TRUE; + + nm_device_activate_schedule_stage3_ip_config(self, FALSE); _routing_rules_sync(self, NM_TERNARY_TRUE); reactivate_proxy_config(self); + + nm_device_l3cfg_commit(self, NM_L3_CFG_COMMIT_TYPE_REAPPLY, FALSE); } if (priv->state >= NM_DEVICE_STATE_IP_CHECK) @@ -13111,96 +12760,6 @@ impl_device_get_applied_connection(NMDBusObject * obj, /*****************************************************************************/ -typedef struct { - gint64 timestamp_ms; - bool dirty; -} IP6RoutesTemporaryNotAvailableData; - -static gboolean -_rt6_temporary_not_available_timeout(gpointer user_data) -{ - NMDevice * self = NM_DEVICE(user_data); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - priv->rt6_temporary_not_available_id = 0; - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - - return G_SOURCE_REMOVE; -} - -static gboolean -_rt6_temporary_not_available_set(NMDevice *self, GPtrArray *temporary_not_available) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - IP6RoutesTemporaryNotAvailableData *data; - GHashTableIter iter; - gint64 now_ms, oldest_ms; - const gint64 MAX_AGE_MS = 20000; - guint i; - gboolean success = TRUE; - - if (!temporary_not_available || !temporary_not_available->len) { - /* nothing outstanding. Clear tracking the routes. */ - nm_clear_pointer(&priv->rt6_temporary_not_available, g_hash_table_unref); - nm_clear_g_source(&priv->rt6_temporary_not_available_id); - return success; - } - - if (priv->rt6_temporary_not_available) { - g_hash_table_iter_init(&iter, priv->rt6_temporary_not_available); - while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &data)) - data->dirty = TRUE; - } else { - priv->rt6_temporary_not_available = - g_hash_table_new_full((GHashFunc) nmp_object_id_hash, - (GEqualFunc) nmp_object_id_equal, - (GDestroyNotify) nmp_object_unref, - nm_g_slice_free_fcn(IP6RoutesTemporaryNotAvailableData)); - } - - now_ms = nm_utils_get_monotonic_timestamp_msec(); - oldest_ms = now_ms; - - for (i = 0; i < temporary_not_available->len; i++) { - const NMPObject *o = temporary_not_available->pdata[i]; - - data = g_hash_table_lookup(priv->rt6_temporary_not_available, o); - if (data) { - if (!data->dirty) - continue; - data->dirty = FALSE; - nm_assert(data->timestamp_ms > 0 && data->timestamp_ms <= now_ms); - if (now_ms > data->timestamp_ms + MAX_AGE_MS) { - /* timeout. Could not add this address. */ - _LOGW(LOGD_DEVICE, - "failure to add IPv6 route: %s", - nmp_object_to_string(o, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0)); - success = FALSE; - } else - oldest_ms = MIN(data->timestamp_ms, oldest_ms); - continue; - } - - data = g_slice_new0(IP6RoutesTemporaryNotAvailableData); - data->timestamp_ms = now_ms; - g_hash_table_insert(priv->rt6_temporary_not_available, (gpointer) nmp_object_ref(o), data); - } - - g_hash_table_iter_init(&iter, priv->rt6_temporary_not_available); - while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &data)) { - if (data->dirty) - g_hash_table_iter_remove(&iter); - } - - nm_clear_g_source(&priv->rt6_temporary_not_available_id); - priv->rt6_temporary_not_available_id = - g_timeout_add(oldest_ms + MAX_AGE_MS - now_ms, _rt6_temporary_not_available_timeout, self); - - return success; -} - -/*****************************************************************************/ - static void disconnect_cb(NMDevice * self, GDBusMethodInvocation *context, @@ -13580,324 +13139,44 @@ nm_device_is_activating(NMDevice *self) * handler is actually run. If there's an activation handler scheduled * we're activating anyway. */ - return priv->activation_source_id_4 != 0; + return !!priv->activation_idle_source; } -NMProxyConfig * -nm_device_get_proxy_config(NMDevice *self) -{ - g_return_val_if_fail(NM_IS_DEVICE(self), NULL); - - return NM_DEVICE_GET_PRIVATE(self)->proxy_config; -} - -static void -nm_device_set_proxy_config(NMDevice *self, const char *pac_url) -{ - NMDevicePrivate *priv; - NMConnection * connection; - NMSettingProxy * s_proxy = NULL; - - g_return_if_fail(NM_IS_DEVICE(self)); - - priv = NM_DEVICE_GET_PRIVATE(self); - - g_clear_object(&priv->proxy_config); - priv->proxy_config = nm_proxy_config_new(); - - if (pac_url) { - nm_proxy_config_set_method(priv->proxy_config, NM_PROXY_CONFIG_METHOD_AUTO); - nm_proxy_config_set_pac_url(priv->proxy_config, pac_url); - _LOGD(LOGD_PROXY, "proxy: PAC url \"%s\"", pac_url); - } else - nm_proxy_config_set_method(priv->proxy_config, NM_PROXY_CONFIG_METHOD_NONE); - - connection = nm_device_get_applied_connection(self); - if (connection) - s_proxy = nm_connection_get_setting_proxy(connection); - - if (s_proxy) - nm_proxy_config_merge_setting(priv->proxy_config, s_proxy); -} - -/* IP Configuration stuff */ NMDhcpConfig * nm_device_get_dhcp_config(NMDevice *self, int addr_family) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - g_return_val_if_fail(NM_IS_DEVICE(self), NULL); - nm_assert_addr_family(addr_family); - - return NM_DEVICE_GET_PRIVATE(self)->dhcp_data_x[IS_IPv4].config; + return NM_DEVICE_GET_PRIVATE(self)->ipdhcp_data_x[NM_IS_IPv4(addr_family)].config; } -NMIP4Config * -nm_device_get_ip4_config(NMDevice *self) +NML3Cfg * +nm_device_get_l3cfg(NMDevice *self) { g_return_val_if_fail(NM_IS_DEVICE(self), NULL); - return NM_DEVICE_GET_PRIVATE(self)->ip_config_4; + return NM_DEVICE_GET_PRIVATE(self)->l3cfg; } -static gboolean -nm_device_set_ip_config(NMDevice * self, - int addr_family, - NMIPConfig *new_config, - gboolean commit, - GPtrArray * ip4_dev_route_blacklist) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMIPConfig * old_config; - gboolean has_changes = FALSE; - gboolean success = TRUE; - NMSettingsConnection * settings_connection; - NMIPRouteTableSyncMode route_table_sync_mode; - - nm_assert_addr_family(addr_family); - nm_assert(!new_config || nm_ip_config_get_addr_family(new_config) == addr_family); - nm_assert(!new_config - || (new_config && ({ - int ip_ifindex = nm_device_get_ip_ifindex(self); - - (ip_ifindex > 0 && ip_ifindex == nm_ip_config_get_ifindex(new_config)); - }))); - nm_assert(IS_IPv4 || !ip4_dev_route_blacklist); - - if (commit && new_config) - route_table_sync_mode = _get_route_table_sync_mode_stateful(self, addr_family); - else - route_table_sync_mode = NM_IP_ROUTE_TABLE_SYNC_MODE_NONE; - - _LOGD(LOGD_IPX(IS_IPv4), - "ip%c-config: update (commit=%d, new-config=" NM_HASH_OBFUSCATE_PTR_FMT - ", route-table-sync-mode=%d)", - nm_utils_addr_family_to_char(addr_family), - commit, - NM_HASH_OBFUSCATE_PTR(new_config), - (int) route_table_sync_mode); - - /* Always commit to nm-platform to update lifetimes */ - if (commit && new_config) { - _commit_mtu(self, IS_IPv4 ? NM_IP4_CONFIG(new_config) : priv->ip_config_4); - - if (IS_IPv4) { - success = nm_ip4_config_commit(NM_IP4_CONFIG(new_config), - nm_device_get_platform(self), - route_table_sync_mode); - nm_platform_ip4_dev_route_blacklist_set(nm_device_get_platform(self), - nm_ip_config_get_ifindex(new_config), - ip4_dev_route_blacklist); - } else { - gs_unref_ptrarray GPtrArray *temporary_not_available = NULL; - - success = nm_ip6_config_commit(NM_IP6_CONFIG(new_config), - nm_device_get_platform(self), - route_table_sync_mode, - &temporary_not_available); - - if (!_rt6_temporary_not_available_set(self, temporary_not_available)) - success = FALSE; - } - } - - old_config = priv->ip_config_x[IS_IPv4]; - - if (new_config && old_config) { - /* has_changes is set only on relevant changes, because when the configuration changes, - * this causes a re-read and reset. This should only happen for relevant changes */ - nm_ip_config_replace(old_config, new_config, &has_changes); - if (has_changes) { - _LOGD(LOGD_IPX(IS_IPv4), - "ip%c-config: update IP Config instance (%s)", - nm_utils_addr_family_to_char(addr_family), - nm_dbus_object_get_path(NM_DBUS_OBJECT(old_config))); - } - } else if (new_config /*&& !old_config*/) { - has_changes = TRUE; - priv->ip_config_x[IS_IPv4] = g_object_ref(new_config); - if (!nm_dbus_object_is_exported(NM_DBUS_OBJECT(new_config))) - nm_dbus_object_export(NM_DBUS_OBJECT(new_config)); - - _LOGD(LOGD_IPX(IS_IPv4), - "ip%c-config: set IP Config instance (%s)", - nm_utils_addr_family_to_char(addr_family), - nm_dbus_object_get_path(NM_DBUS_OBJECT(new_config))); - } else if (old_config /*&& !new_config*/) { - has_changes = TRUE; - priv->ip_config_x[IS_IPv4] = NULL; - _LOGD(LOGD_IPX(IS_IPv4), - "ip%c-config: clear IP Config instance (%s)", - nm_utils_addr_family_to_char(addr_family), - nm_dbus_object_get_path(NM_DBUS_OBJECT(old_config))); - if (IS_IPv4) { - /* Device config is invalid if combined config is invalid */ - applied_config_clear(&priv->dev_ip_config_4); - } else - priv->needs_ip6_subnet = FALSE; - } - - if (has_changes) { - if (old_config != priv->ip_config_x[IS_IPv4]) - _notify(self, IS_IPv4 ? PROP_IP4_CONFIG : PROP_IP6_CONFIG); - - g_signal_emit(self, - signals[IS_IPv4 ? IP4_CONFIG_CHANGED : IP6_CONFIG_CHANGED], - 0, - priv->ip_config_x[IS_IPv4], - old_config); - - if (old_config != priv->ip_config_x[IS_IPv4]) - nm_dbus_object_clear_and_unexport(&old_config); - - if (nm_device_sys_iface_state_is_external(self) - && (settings_connection = nm_device_get_settings_connection(self)) - && NM_FLAGS_HAS(nm_settings_connection_get_flags(settings_connection), - NM_SETTINGS_CONNECTION_INT_FLAGS_EXTERNAL) - && nm_active_connection_get_activation_type(NM_ACTIVE_CONNECTION(priv->act_request.obj)) - == NM_ACTIVATION_TYPE_EXTERNAL) { - gs_unref_object NMConnection *new_connection = NULL; - - new_connection = nm_simple_connection_new_clone( - nm_settings_connection_get_connection(settings_connection)); - - nm_connection_add_setting( - new_connection, - IS_IPv4 ? nm_ip4_config_create_setting(priv->ip_config_4) - : nm_ip6_config_create_setting(priv->ip_config_6, - _get_maybe_ipv6_disabled(self))); - - nm_settings_connection_update(settings_connection, - new_connection, - NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY, - NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, - NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, - NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET, - "update-external", - NULL); - } - - nm_device_queue_recheck_assume(self); - - if (!IS_IPv4) { - if (priv->ndisc) - ndisc_set_router_config(priv->ndisc, self); - } - } - - nm_assert(!old_config || old_config == priv->ip_config_x[IS_IPv4]); - - return success; -} - -static gboolean -_replace_vpn_config_in_list(GSList **plist, GObject *old, GObject *new) -{ - GSList *old_link; - - /* Below, assert that @new is not yet tracked, but still behave - * correctly in any case. Don't complain for missing @old since - * it could have been removed when the parent device became - * unmanaged. */ - - if (old && (old_link = g_slist_find(*plist, old))) { - if (old != new) { - if (new) - old_link->data = g_object_ref(new); - else - *plist = g_slist_delete_link(*plist, old_link); - g_object_unref(old); - } - return TRUE; - } - - if (new) { - if (!g_slist_find(*plist, new)) - *plist = g_slist_append(*plist, g_object_ref(new)); - else - g_return_val_if_reached(TRUE); - return TRUE; - } - - return FALSE; -} - -void -nm_device_replace_vpn4_config(NMDevice *self, NMIP4Config *old, NMIP4Config *config) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - nm_assert(!old || NM_IS_IP4_CONFIG(old)); - nm_assert(!config || NM_IS_IP4_CONFIG(config)); - nm_assert(!old || nm_ip4_config_get_ifindex(old) == nm_device_get_ip_ifindex(self)); - nm_assert(!config || nm_ip4_config_get_ifindex(config) == nm_device_get_ip_ifindex(self)); - - if (!_replace_vpn_config_in_list(&priv->vpn_configs_4, (GObject *) old, (GObject *) config)) - return; - - /* NULL to use existing configs */ - if (!ip_config_merge_and_apply(self, AF_INET, TRUE)) - _LOGW(LOGD_IP4, "failed to set VPN routes for device"); -} - -void -nm_device_set_dev2_ip_config(NMDevice *self, int addr_family, NMIPConfig *config) +const NML3ConfigData * +nm_device_get_l3cd(NMDevice *self, gboolean get_commited) { NMDevicePrivate *priv; - const int IS_IPv4 = NM_IS_IPv4(addr_family); - g_return_if_fail(NM_IS_DEVICE(self)); - g_return_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6)); - g_return_if_fail(!config || nm_ip_config_get_addr_family(config) == addr_family); + g_return_val_if_fail(NM_IS_DEVICE(self), NULL); priv = NM_DEVICE_GET_PRIVATE(self); - applied_config_init(&priv->dev2_ip_config_x[IS_IPv4], config); - if (!ip_config_merge_and_apply(self, addr_family, TRUE)) { - _LOGW(LOGD_IP, - "failed to set extra device IPv%c configuration", - nm_utils_addr_family_to_char(addr_family)); - } -} + if (!priv->l3cfg) + return NULL; -void -nm_device_replace_vpn6_config(NMDevice *self, NMIP6Config *old, NMIP6Config *config) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMDeviceState state; - - nm_assert(!old || NM_IS_IP6_CONFIG(old)); - nm_assert(!old || nm_ip6_config_get_ifindex(old) > 0); - nm_assert(!old || nm_device_get_ip_ifindex(self) == 0 - || nm_device_get_ip_ifindex(self) == nm_ip6_config_get_ifindex(old)); - nm_assert(!config || NM_IS_IP6_CONFIG(config)); - nm_assert(!config || nm_ip6_config_get_ifindex(config) > 0); - nm_assert(!config || nm_device_get_ip_ifindex(self) == nm_ip6_config_get_ifindex(config)); - - if (!_replace_vpn_config_in_list(&priv->vpn_configs_6, (GObject *) old, (GObject *) config)) - return; - - state = nm_device_get_state(self); - if (state >= NM_DEVICE_STATE_IP_CONFIG && state <= NM_DEVICE_STATE_ACTIVATED) { - if (!ip_config_merge_and_apply(self, AF_INET6, TRUE)) - _LOGW(LOGD_IP6, "failed to set VPN routes for device"); - } -} - -NMIP6Config * -nm_device_get_ip6_config(NMDevice *self) -{ - g_return_val_if_fail(NM_IS_DEVICE(self), NULL); - - return NM_DEVICE_GET_PRIVATE(self)->ip_config_6; + return nm_l3cfg_get_combined_l3cd(priv->l3cfg, get_commited); } /*****************************************************************************/ static gboolean -dispatcher_cleanup(NMDevice *self) +_dispatcher_cleanup(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); @@ -13911,7 +13190,7 @@ dispatcher_cleanup(NMDevice *self) } static void -dispatcher_complete_proceed_state(NMDispatcherCallId *call_id, gpointer user_data) +_dispatcher_complete_proceed_state(NMDispatcherCallId *call_id, gpointer user_data) { NMDevice * self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); @@ -13931,7 +13210,7 @@ ip_check_pre_up(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (dispatcher_cleanup(self)) + if (_dispatcher_cleanup(self)) nm_assert_not_reached(); priv->dispatcher.post_state = NM_DEVICE_STATE_SECONDARIES; @@ -13939,11 +13218,11 @@ ip_check_pre_up(NMDevice *self) if (!nm_dispatcher_call_device(NM_DISPATCHER_ACTION_PRE_UP, self, NULL, - dispatcher_complete_proceed_state, + _dispatcher_complete_proceed_state, self, &priv->dispatcher.call_id)) { /* Just proceed on errors */ - dispatcher_complete_proceed_state(0, self); + _dispatcher_complete_proceed_state(0, self); } } @@ -14123,8 +13402,8 @@ nm_device_start_ip_check(NMDevice *self) g_return_if_fail(!priv->gw_ping.watch); g_return_if_fail(!priv->gw_ping.timeout); g_return_if_fail(!priv->gw_ping.pid); - g_return_if_fail(priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE - || priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE); + g_return_if_fail(priv->ip_data_4.state == NM_DEVICE_IP_STATE_READY + || priv->ip_data_6.state == NM_DEVICE_IP_STATE_READY); connection = nm_device_get_applied_connection(self); g_assert(connection); @@ -14135,17 +13414,21 @@ nm_device_start_ip_check(NMDevice *self) buf[0] = '\0'; if (timeout) { - const NMPObject *gw; + const NMPObject * gw; + const NML3ConfigData *l3cd; - if (priv->ip_config_4 && priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE) { - gw = nm_ip4_config_best_default_route_get(priv->ip_config_4); + l3cd = priv->l3cfg ? nm_l3cfg_get_combined_l3cd(priv->l3cfg, TRUE) : NULL; + if (!l3cd) { + /* pass */ + } else if (priv->ip_data_4.state == NM_DEVICE_IP_STATE_READY) { + gw = nm_l3_config_data_get_best_default_route(l3cd, AF_INET); if (gw) { _nm_utils_inet4_ntop(NMP_OBJECT_CAST_IP4_ROUTE(gw)->gateway, buf); ping_binary = nm_utils_find_helper("ping", "/usr/bin/ping", NULL); log_domain = LOGD_IP4; } - } else if (priv->ip_config_6 && priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE) { - gw = nm_ip6_config_best_default_route_get(priv->ip_config_6); + } else if (priv->ip_data_6.state == NM_DEVICE_IP_STATE_READY) { + gw = nm_l3_config_data_get_best_default_route(l3cd, AF_INET6); if (gw) { _nm_utils_inet6_ntop(&NMP_OBJECT_CAST_IP6_ROUTE(gw)->gateway, buf); ping_binary = nm_utils_find_helper("ping6", "/usr/bin/ping6", NULL); @@ -14285,15 +13568,7 @@ nm_device_bring_up(NMDevice *self, gboolean block, gboolean *no_firmware) /* Can only get HW address of some devices when they are up */ nm_device_update_hw_address(self); - /* when the link comes up, we must restore IP configuration if necessary. */ - if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE) { - if (!ip_config_merge_and_apply(self, AF_INET, TRUE)) - _LOGW(LOGD_IP4, "failed applying IP4 config after bringing link up"); - } - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE) { - if (!ip_config_merge_and_apply(self, AF_INET6, TRUE)) - _LOGW(LOGD_IP6, "failed applying IP6 config after bringing link up"); - } + _dev_l3_cfg_commit(self, TRUE); return TRUE; } @@ -14356,381 +13631,6 @@ nm_device_get_firmware_missing(NMDevice *self) return NM_DEVICE_GET_PRIVATE(self)->firmware_missing; } -static void -intersect_ext_config(NMDevice * self, - AppliedConfig *config, - gboolean intersect_addresses, - gboolean intersect_routes) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMIPConfig * ext; - guint32 penalty; - int family; - - if (!config->orig) - return; - - family = nm_ip_config_get_addr_family(config->orig); - penalty = default_route_metric_penalty_get(self, family); - ext = family == AF_INET ? (NMIPConfig *) priv->ext_ip_config_4 - : (NMIPConfig *) priv->ext_ip_config_6; - - if (config->current) { - nm_ip_config_intersect(config->current, - ext, - intersect_addresses, - intersect_routes, - penalty); - } else { - config->current = nm_ip_config_intersect_alloc(config->orig, - ext, - intersect_addresses, - intersect_routes, - penalty); - } -} - -static gboolean -update_ext_ip_config(NMDevice *self, int addr_family, gboolean intersect_configs) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - int ifindex; - GSList * iter; - gboolean is_up; - - nm_assert_addr_family(addr_family); - - ifindex = nm_device_get_ip_ifindex(self); - if (!ifindex) - return FALSE; - - is_up = nm_platform_link_is_up(nm_device_get_platform(self), ifindex); - - if (NM_IS_IPv4(addr_family)) { - g_clear_object(&priv->ext_ip_config_4); - priv->ext_ip_config_4 = nm_ip4_config_capture(nm_device_get_multi_index(self), - nm_device_get_platform(self), - ifindex); - if (priv->ext_ip_config_4) { - if (intersect_configs) { - /* This function was called upon external changes. Remove the configuration - * (addresses,routes) that is no longer present externally from the internal - * config. This way, we don't re-add addresses that were manually removed - * by the user. */ - if (priv->con_ip_config_4) { - nm_ip4_config_intersect(priv->con_ip_config_4, - priv->ext_ip_config_4, - TRUE, - is_up, - default_route_metric_penalty_get(self, AF_INET)); - } - - intersect_ext_config(self, &priv->dev_ip_config_4, TRUE, is_up); - intersect_ext_config(self, &priv->dev2_ip_config_4, TRUE, is_up); - - for (iter = priv->vpn_configs_4; iter; iter = iter->next) - nm_ip4_config_intersect(iter->data, priv->ext_ip_config_4, TRUE, is_up, 0); - } - - /* Remove parts from ext_ip_config_4 to only contain the information that - * was configured externally -- we already have the same configuration from - * internal origins. */ - if (priv->con_ip_config_4) { - nm_ip4_config_subtract(priv->ext_ip_config_4, - priv->con_ip_config_4, - default_route_metric_penalty_get(self, AF_INET)); - } - if (applied_config_get_current(&priv->dev_ip_config_4)) { - nm_ip_config_subtract((NMIPConfig *) priv->ext_ip_config_4, - applied_config_get_current(&priv->dev_ip_config_4), - default_route_metric_penalty_get(self, AF_INET)); - } - if (applied_config_get_current(&priv->dev2_ip_config_4)) { - nm_ip_config_subtract((NMIPConfig *) priv->ext_ip_config_4, - applied_config_get_current(&priv->dev2_ip_config_4), - default_route_metric_penalty_get(self, AF_INET)); - } - for (iter = priv->vpn_configs_4; iter; iter = iter->next) - nm_ip4_config_subtract(priv->ext_ip_config_4, iter->data, 0); - } - - } else { - nm_assert(!NM_IS_IPv4(addr_family)); - - g_clear_object(&priv->ext_ip_config_6); - g_clear_object(&priv->ext_ip6_config_captured); - priv->ext_ip6_config_captured = - nm_ip6_config_capture(nm_device_get_multi_index(self), - nm_device_get_platform(self), - ifindex, - NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); - if (priv->ext_ip6_config_captured) { - priv->ext_ip_config_6 = nm_ip6_config_new_cloned(priv->ext_ip6_config_captured); - - if (intersect_configs) { - /* This function was called upon external changes. Remove the configuration - * (addresses,routes) that is no longer present externally from the internal - * config. This way, we don't re-add addresses that were manually removed - * by the user. */ - if (priv->con_ip_config_6) { - nm_ip6_config_intersect(priv->con_ip_config_6, - priv->ext_ip_config_6, - is_up, - is_up, - default_route_metric_penalty_get(self, AF_INET6)); - } - - intersect_ext_config(self, &priv->ac_ip6_config, is_up, is_up); - intersect_ext_config(self, &priv->dhcp6.ip6_config, is_up, is_up); - intersect_ext_config(self, &priv->dev2_ip_config_6, is_up, is_up); - - for (iter = priv->vpn_configs_6; iter; iter = iter->next) - nm_ip6_config_intersect(iter->data, priv->ext_ip_config_6, is_up, is_up, 0); - - if (is_up && priv->ipv6ll_has - && !nm_ip6_config_lookup_address(priv->ext_ip_config_6, &priv->ipv6ll_addr)) - priv->ipv6ll_has = FALSE; - } - - /* Remove parts from ext_ip_config_6 to only contain the information that - * was configured externally -- we already have the same configuration from - * internal origins. */ - if (priv->con_ip_config_6) { - nm_ip6_config_subtract(priv->ext_ip_config_6, - priv->con_ip_config_6, - default_route_metric_penalty_get(self, AF_INET6)); - } - if (applied_config_get_current(&priv->ac_ip6_config)) { - nm_ip_config_subtract((NMIPConfig *) priv->ext_ip_config_6, - applied_config_get_current(&priv->ac_ip6_config), - default_route_metric_penalty_get(self, AF_INET6)); - } - if (applied_config_get_current(&priv->dhcp6.ip6_config)) { - nm_ip_config_subtract((NMIPConfig *) priv->ext_ip_config_6, - applied_config_get_current(&priv->dhcp6.ip6_config), - default_route_metric_penalty_get(self, AF_INET6)); - } - if (applied_config_get_current(&priv->dev2_ip_config_6)) { - nm_ip_config_subtract((NMIPConfig *) priv->ext_ip_config_6, - applied_config_get_current(&priv->dev2_ip_config_6), - default_route_metric_penalty_get(self, AF_INET6)); - } - for (iter = priv->vpn_configs_6; iter; iter = iter->next) - nm_ip6_config_subtract(priv->ext_ip_config_6, iter->data, 0); - } - } - - return TRUE; -} - -static void -update_ip_config(NMDevice *self, int addr_family) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - nm_assert_addr_family(addr_family); - - if (NM_IS_IPv4(addr_family)) - priv->update_ip_config_completed_v4 = TRUE; - else - priv->update_ip_config_completed_v6 = TRUE; - - if (update_ext_ip_config(self, addr_family, TRUE)) { - if (NM_IS_IPv4(addr_family)) { - if (priv->ext_ip_config_4) - ip_config_merge_and_apply(self, AF_INET, FALSE); - } else { - if (priv->ext_ip6_config_captured) - ip_config_merge_and_apply(self, AF_INET6, FALSE); - } - } -} - -void -nm_device_capture_initial_config(NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - if (!priv->update_ip_config_completed_v4) - update_ip_config(self, AF_INET); - if (!priv->update_ip_config_completed_v6) - update_ip_config(self, AF_INET6); -} - -static gboolean -queued_ip_config_change(NMDevice *self, int addr_family) -{ - NMDevicePrivate *priv; - const int IS_IPv4 = NM_IS_IPv4(addr_family); - - g_return_val_if_fail(NM_IS_DEVICE(self), G_SOURCE_REMOVE); - - priv = NM_DEVICE_GET_PRIVATE(self); - - /* Wait for any queued state changes */ - if (priv->queued_state.id) - return G_SOURCE_CONTINUE; - - /* If a commit is scheduled, this function would potentially interfere with - * it changing IP configurations before they are applied. Postpone the - * update in such case. - */ - if (priv->activation_source_id_x[IS_IPv4] != 0 - && priv->activation_source_func_x[IS_IPv4] - == activate_stage5_ip_config_result_x_fcn(addr_family)) - return G_SOURCE_CONTINUE; - - priv->queued_ip_config_id_x[IS_IPv4] = 0; - - update_ip_config(self, addr_family); - - if (!IS_IPv4) { - /* Check whether we need to complete waiting for link-local. - * We are also called from an idle handler, so no problem doing state transitions - * now. */ - linklocal6_check_complete(self); - } - - if (!IS_IPv4) { - NMPlatform * platform; - GSList * dad6_failed_addrs, *iter; - const NMPlatformLink *pllink; - - dad6_failed_addrs = g_steal_pointer(&priv->dad6_failed_addrs); - - if (priv->state > NM_DEVICE_STATE_DISCONNECTED && priv->state < NM_DEVICE_STATE_DEACTIVATING - && priv->ifindex > 0 && !nm_device_sys_iface_state_is_external(self) - && (platform = nm_device_get_platform(self)) - && (pllink = nm_platform_link_get(platform, priv->ifindex)) - && (pllink->n_ifi_flags & IFF_UP)) { - gboolean need_ipv6ll = FALSE; - NMNDiscConfigMap ndisc_config_changed = NM_NDISC_CONFIG_NONE; - - /* Handle DAD failures */ - for (iter = dad6_failed_addrs; iter; iter = iter->next) { - const NMPObject * obj = iter->data; - const NMPlatformIP6Address *addr; - - if (!nm_ndisc_dad_addr_is_fail_candidate(platform, obj)) - continue; - - addr = NMP_OBJECT_CAST_IP6_ADDRESS(obj); - - _LOGI(LOGD_IP6, - "ipv6: duplicate address check failed for the %s address", - nm_platform_ip6_address_to_string(addr, NULL, 0)); - - if (IN6_IS_ADDR_LINKLOCAL(&addr->address)) - need_ipv6ll = TRUE; - else if (priv->ndisc) - ndisc_config_changed |= nm_ndisc_dad_failed(priv->ndisc, &addr->address, FALSE); - } - - if (ndisc_config_changed != NM_NDISC_CONFIG_NONE) - nm_ndisc_emit_config_change(priv->ndisc, ndisc_config_changed); - - /* If no IPv6 link-local address exists but other addresses do then we - * must add the LL address to remain conformant with RFC 3513 chapter 2.1 - * ("Addressing Model"): "All interfaces are required to have at least - * one link-local unicast address". - */ - if (priv->ip_config_6 && nm_ip6_config_get_num_addresses(priv->ip_config_6)) - need_ipv6ll = TRUE; - if (need_ipv6ll) - check_and_add_ipv6ll_addr(self); - } - - g_slist_free_full(dad6_failed_addrs, (GDestroyNotify) nmp_object_unref); - } - - if (!IS_IPv4) { - /* Check if DAD is still pending */ - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF && priv->dad6_ip6_config - && priv->ext_ip6_config_captured - && !nm_ip6_config_has_any_dad_pending(priv->ext_ip6_config_captured, - priv->dad6_ip6_config)) { - _LOGD(LOGD_DEVICE | LOGD_IP6, "IPv6 DAD terminated"); - g_clear_object(&priv->dad6_ip6_config); - _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); - if (priv->rt6_temporary_not_available) - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - } - } - - set_unmanaged_external_down(self, TRUE); - - return G_SOURCE_REMOVE; -} - -static gboolean -queued_ip4_config_change(gpointer user_data) -{ - return queued_ip_config_change(user_data, AF_INET); -} - -static gboolean -queued_ip6_config_change(gpointer user_data) -{ - return queued_ip_config_change(user_data, AF_INET6); -} - -static void -device_ipx_changed(NMPlatform * platform, - int obj_type_i, - int ifindex, - gconstpointer platform_object, - int change_type_i, - NMDevice * self) -{ - const NMPObjectType obj_type = obj_type_i; - const NMPlatformSignalChangeType change_type = change_type_i; - NMDevicePrivate * priv; - const NMPlatformIP6Address * addr; - - if (nm_device_get_ip_ifindex(self) != ifindex) - return; - - if (!nm_device_is_real(self)) - return; - - if (nm_device_get_unmanaged_flags(self, NM_UNMANAGED_PLATFORM_INIT)) { - /* ignore all platform signals until the link is initialized in platform. */ - return; - } - - priv = NM_DEVICE_GET_PRIVATE(self); - - switch (obj_type) { - case NMP_OBJECT_TYPE_IP4_ADDRESS: - case NMP_OBJECT_TYPE_IP4_ROUTE: - if (!priv->queued_ip_config_id_4) { - priv->queued_ip_config_id_4 = g_idle_add(queued_ip4_config_change, self); - _LOGD(LOGD_DEVICE, "queued IP4 config change"); - } - break; - case NMP_OBJECT_TYPE_IP6_ADDRESS: - addr = platform_object; - - if (priv->state > NM_DEVICE_STATE_DISCONNECTED && priv->state < NM_DEVICE_STATE_DEACTIVATING - && nm_ndisc_dad_addr_is_fail_candidate_event(change_type, addr)) { - priv->dad6_failed_addrs = - g_slist_prepend(priv->dad6_failed_addrs, - (gpointer) nmp_object_ref(NMP_OBJECT_UP_CAST(addr))); - } - - /* fall-through */ - case NMP_OBJECT_TYPE_IP6_ROUTE: - if (!priv->queued_ip_config_id_6) { - priv->queued_ip_config_id_6 = g_idle_add(queued_ip6_config_change, self); - _LOGD(LOGD_DEVICE, "queued IP6 config change"); - } - break; - default: - g_return_if_reached(); - } -} - /*****************************************************************************/ NM_UTILS_FLAGS2STR_DEFINE(nm_unmanaged_flags2str, @@ -14983,12 +13883,6 @@ _set_unmanaged_flags(NMDevice * self, nm_device_set_unmanaged_flags(self, NM_UNMANAGED_USER_SETTINGS, !!unmanaged); } - /* trigger an initial update of IP configuration. */ - nm_assert_se(!nm_clear_g_source(&priv->queued_ip_config_id_4)); - nm_assert_se(!nm_clear_g_source(&priv->queued_ip_config_id_6)); - priv->queued_ip_config_id_4 = g_idle_add(queued_ip4_config_change, self); - priv->queued_ip_config_id_6 = g_idle_add(queued_ip6_config_change, self); - if (priv->pending_actions.len == 0) { do_notify_has_pending_actions = TRUE; had_pending_actions = nm_device_has_pending_action(self); @@ -15340,9 +14234,13 @@ nm_device_update_metered(NMDevice *self) /* Try to guess a value using the metered flag in IP configuration */ if (value == NM_METERED_INVALID) { - if (priv->ip_config_4 && priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE - && nm_ip4_config_get_metered(priv->ip_config_4)) - value = NM_METERED_GUESS_YES; + if (priv->l3cfg) { + const NML3ConfigData *l3cd; + + l3cd = nm_l3cfg_get_combined_l3cd(priv->l3cfg, TRUE); + if (l3cd && nm_l3_config_data_get_metered(l3cd) == NM_TERNARY_TRUE) + value = NM_METERED_GUESS_YES; + } } /* Otherwise, look at connection type. For Bluetooth, we look at the type of @@ -15913,12 +14811,11 @@ _cancel_activation(NMDevice *self) priv->fw_state = FIREWALL_STATE_INITIALIZED; } - dispatcher_cleanup(self); + _dispatcher_cleanup(self); ip_check_gw_ping_cleanup(self); /* Break the activation chain */ - activation_source_clear(self, AF_INET); - activation_source_clear(self, AF_INET6); + activation_source_clear(self); } static void @@ -15948,17 +14845,13 @@ _cleanup_generic_pre(NMDevice *self, CleanupType cleanup_type) queued_state_clear(self); - nm_clear_pointer(&priv->shared_ip_handle, nm_netns_shared_ip_release); - for (i = 0; i < 2; i++) nm_clear_pointer(&priv->hostname_resolver_x[i], _hostname_resolver_free); _cleanup_ip_pre(self, AF_INET, cleanup_type); _cleanup_ip_pre(self, AF_INET6, cleanup_type); - priv->ip_config_started = FALSE; - nm_clear_g_source_inst(&priv->ip_req_timeout_source_4); - nm_clear_g_source_inst(&priv->ip_req_timeout_source_6); + _dev_ip_state_req_timeout_cancel(self, AF_UNSPEC); } static void @@ -15966,11 +14859,9 @@ _cleanup_generic_post(NMDevice *self, CleanupType cleanup_type) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - priv->v4_commit_first_time = TRUE; - priv->v6_commit_first_time = TRUE; - priv->v4_route_table_initialized = FALSE; priv->v6_route_table_initialized = FALSE; + priv->l3config_merge_flags_has = FALSE; priv->v4_route_table_all_sync_before = FALSE; priv->v6_route_table_all_sync_before = FALSE; @@ -15978,42 +14869,9 @@ _cleanup_generic_post(NMDevice *self, CleanupType cleanup_type) priv->default_route_metric_penalty_ip4_has = FALSE; priv->default_route_metric_penalty_ip6_has = FALSE; - priv->linklocal6_dad_counter = 0; - priv->mtu_force_set_done = FALSE; - /* Clean up IP configs; this does not actually deconfigure the - * interface; the caller must flush routes and addresses explicitly. - */ - nm_device_set_ip_config(self, AF_INET, NULL, TRUE, NULL); - nm_device_set_ip_config(self, AF_INET6, NULL, TRUE, NULL); - g_clear_object(&priv->proxy_config); - g_clear_object(&priv->con_ip_config_4); - applied_config_clear(&priv->dev_ip_config_4); - applied_config_clear(&priv->dev2_ip_config_4); - g_clear_object(&priv->ext_ip_config_4); - g_clear_object(&priv->ip_config_4); - g_clear_object(&priv->con_ip_config_6); - applied_config_clear(&priv->ac_ip6_config); - g_clear_object(&priv->ext_ip_config_6); - g_clear_object(&priv->ext_ip6_config_captured); - applied_config_clear(&priv->dev2_ip_config_6); - g_clear_object(&priv->ip_config_6); - g_clear_object(&priv->dad6_ip6_config); - priv->ipv6ll_has = FALSE; - memset(&priv->ipv6ll_addr, 0, sizeof(priv->ipv6ll_addr)); - - nm_clear_pointer(&priv->rt6_temporary_not_available, g_hash_table_unref); - nm_clear_g_source(&priv->rt6_temporary_not_available_id); - - g_slist_free_full(priv->vpn_configs_4, g_object_unref); - priv->vpn_configs_4 = NULL; - g_slist_free_full(priv->vpn_configs_6, g_object_unref); - priv->vpn_configs_6 = NULL; - - /* We no longer accept the delegations. nm_device_set_ip_config(NULL) - * above disables them. */ - nm_assert(priv->needs_ip6_subnet == FALSE); + priv->needs_ip6_subnet = FALSE; if (priv->act_request.obj) { nm_active_connection_set_default(NM_ACTIVE_CONNECTION(priv->act_request.obj), @@ -16035,6 +14893,9 @@ _cleanup_generic_post(NMDevice *self, CleanupType cleanup_type) * or ATM device). */ _set_ip_ifindex(self, 0, NULL); + + nm_clear_g_source_inst(&priv->ip_data_4.check_async_source); + nm_clear_g_source_inst(&priv->ip_data_6.check_async_source); } /* @@ -16066,7 +14927,7 @@ nm_device_cleanup(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanu /* Turn off kernel IPv6 */ if (cleanup_type == CLEANUP_TYPE_DECONFIGURE) { - set_disable_ipv6(self, "1"); + _dev_sysctl_set_disable_ipv6(self, TRUE); nm_device_sysctl_ip_conf_set(self, AF_INET6, "use_tempaddr", "0"); } @@ -16180,213 +15041,13 @@ deactivate_reset_hw_addr(NMDevice *self) nm_device_hw_addr_reset(self, "deactivate"); } -static char * -find_dhcp4_address(NMDevice *self) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - const NMPlatformIP4Address *a; - NMDedupMultiIter ipconf_iter; - - if (!priv->ip_config_4) - return NULL; - - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, priv->ip_config_4, &a) { - if (a->addr_source == NM_IP_CONFIG_SOURCE_DHCP) - return nm_utils_inet4_ntop_dup(a->address); - } - return NULL; -} - -void -nm_device_spawn_iface_helper(NMDevice *self) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - gboolean configured = FALSE; - NMConnection * connection; - GError * error = NULL; - const char * method; - GPtrArray * argv; - gs_free char * dhcp4_address = NULL; - char * logging_backend; - NMUtilsStableType stable_type; - const char * stable_id; - - if (priv->state != NM_DEVICE_STATE_ACTIVATED) - return; - if (!nm_device_can_assume_connections(self)) - return; - - connection = nm_device_get_applied_connection(self); - - g_return_if_fail(connection); - - argv = g_ptr_array_sized_new(10); - g_ptr_array_set_free_func(argv, g_free); - - g_ptr_array_add(argv, g_strdup(LIBEXECDIR "/nm-iface-helper")); - g_ptr_array_add(argv, g_strdup("--ifname")); - g_ptr_array_add(argv, g_strdup(nm_device_get_ip_iface(self))); - g_ptr_array_add(argv, g_strdup("--uuid")); - g_ptr_array_add(argv, g_strdup(nm_connection_get_uuid(connection))); - - stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); - if (stable_type != NM_UTILS_STABLE_TYPE_UUID) { - g_ptr_array_add(argv, g_strdup("--stable-id")); - g_ptr_array_add(argv, g_strdup_printf("%d %s", (int) stable_type, stable_id)); - } - - logging_backend = - nm_config_data_get_value(NM_CONFIG_GET_DATA_ORIG, - NM_CONFIG_KEYFILE_GROUP_LOGGING, - NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND, - NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); - if (logging_backend) { - g_ptr_array_add(argv, g_strdup("--logging-backend")); - g_ptr_array_add(argv, logging_backend); - } - - g_ptr_array_add(argv, g_strdup("--log-level")); - g_ptr_array_add(argv, g_strdup(nm_logging_level_to_string())); - - g_ptr_array_add(argv, g_strdup("--log-domains")); - g_ptr_array_add(argv, g_strdup(nm_logging_domains_to_string())); - - dhcp4_address = find_dhcp4_address(self); - - method = nm_device_get_effective_ip_config_method(self, AF_INET); - if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { - NMSettingIPConfig *s_ip4; - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - nm_assert(s_ip4); - - g_ptr_array_add(argv, g_strdup("--priority4")); - g_ptr_array_add(argv, g_strdup_printf("%u", nm_device_get_route_metric(self, AF_INET))); - - g_ptr_array_add(argv, g_strdup("--dhcp4")); - g_ptr_array_add(argv, g_strdup(dhcp4_address)); - if (nm_setting_ip_config_get_may_fail(s_ip4) == FALSE) - g_ptr_array_add(argv, g_strdup("--dhcp4-required")); - - if (priv->dhcp_data_4.client) { - const char *hostname; - GBytes * client_id; - - client_id = nm_dhcp_client_get_client_id(priv->dhcp_data_4.client); - if (client_id) { - g_ptr_array_add(argv, g_strdup("--dhcp4-clientid")); - g_ptr_array_add(argv, - nm_utils_bin2hexstr_full(g_bytes_get_data(client_id, NULL), - g_bytes_get_size(client_id), - ':', - FALSE, - NULL)); - } - - hostname = nm_dhcp_client_get_hostname(priv->dhcp_data_4.client); - if (hostname) { - if (NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(priv->dhcp_data_4.client), - NM_DHCP_CLIENT_FLAGS_USE_FQDN)) - g_ptr_array_add(argv, g_strdup("--dhcp4-fqdn")); - else - g_ptr_array_add(argv, g_strdup("--dhcp4-hostname")); - g_ptr_array_add(argv, g_strdup(hostname)); - } - } - - configured = TRUE; - } - - method = nm_utils_get_ip_config_method(connection, AF_INET6); - if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - NMSettingIPConfig *s_ip6; - NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT; - - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); - - g_ptr_array_add(argv, g_strdup("--priority6")); - g_ptr_array_add(argv, g_strdup_printf("%u", nm_device_get_route_metric(self, AF_INET6))); - - g_ptr_array_add(argv, g_strdup("--slaac")); - - if (nm_setting_ip_config_get_may_fail(s_ip6) == FALSE) - g_ptr_array_add(argv, g_strdup("--slaac-required")); - - g_ptr_array_add(argv, g_strdup("--slaac-tempaddr")); - g_ptr_array_add(argv, g_strdup_printf("%d", priv->ndisc_use_tempaddr)); - - if (nm_device_get_ip_iface_identifier(self, &iid, FALSE)) { - g_ptr_array_add(argv, g_strdup("--iid")); - g_ptr_array_add( - argv, - nm_utils_bin2hexstr_full(iid.id_u8, sizeof(NMUtilsIPv6IfaceId), ':', FALSE, NULL)); - } - - g_ptr_array_add(argv, g_strdup("--addr-gen-mode")); - g_ptr_array_add( - argv, - g_strdup_printf("%d", - nm_setting_ip6_config_get_addr_gen_mode(NM_SETTING_IP6_CONFIG(s_ip6)))); - - configured = TRUE; - } - - if (configured) { - GPid pid; - - g_ptr_array_add(argv, NULL); - - if (nm_logging_enabled(LOGL_DEBUG, LOGD_DEVICE)) { - char *tmp; - - tmp = g_strjoinv(" ", (char **) argv->pdata); - _LOGD(LOGD_DEVICE, "running '%s'", tmp); - g_free(tmp); - } - - if (g_spawn_async(NULL, - (char **) argv->pdata, - NULL, - G_SPAWN_DO_NOT_REAP_CHILD, - NULL, - NULL, - &pid, - &error)) { - _LOGI(LOGD_DEVICE, "spawned helper PID %u", (guint) pid); - } else { - _LOGW(LOGD_DEVICE, "failed to spawn helper: %s", error->message); - g_error_free(error); - } - } - - g_ptr_array_unref(argv); -} - /*****************************************************************************/ -static gboolean -ip_config_valid(NMDeviceState state) -{ - return (state == NM_DEVICE_STATE_UNMANAGED) - || (state >= NM_DEVICE_STATE_IP_CHECK && state <= NM_DEVICE_STATE_DEACTIVATING); -} - -static void -notify_ip_properties(NMDevice *self) -{ - _notify(self, PROP_IP_IFACE); - _notify(self, PROP_IP4_CONFIG); - _notify(self, PROP_DHCP4_CONFIG); - _notify(self, PROP_IP6_CONFIG); - _notify(self, PROP_DHCP6_CONFIG); -} - static void ip6_managed_setup(NMDevice *self) { - set_nm_ipv6ll(self, TRUE); - set_disable_ipv6(self, "1"); + _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); + _dev_sysctl_set_disable_ipv6(self, TRUE); nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "0"); nm_device_sysctl_ip_conf_set(self, AF_INET6, "use_tempaddr", "0"); nm_device_sysctl_ip_conf_set(self, AF_INET6, "forwarding", "0"); @@ -16520,9 +15181,9 @@ deactivate_dispatcher_complete(NMDispatcherCallId *call_id, gpointer user_data) static void _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, gboolean quitting) { - NMDevicePrivate *priv; - NMDeviceState old_state; - gs_unref_object NMActRequest *req = NULL; + gs_unref_object NMActRequest *req = NULL; + NMDevicePrivate * priv; + NMDeviceState old_state; gboolean no_firmware = FALSE; NMSettingsConnection * sett_conn; NMSettingSriov * s_sriov; @@ -16532,8 +15193,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, priv = NM_DEVICE_GET_PRIVATE(self); - /* Track re-entry */ - g_warn_if_fail(priv->in_state_changed == FALSE); + g_return_if_fail(priv->in_state_changed == 0); old_state = priv->state; @@ -16570,14 +15230,14 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, * by the device not having any pending action anymore * we add one here that gets removed at the end of the function */ nm_device_add_pending_action(self, NM_PENDING_ACTION_IN_STATE_CHANGE, TRUE); - priv->in_state_changed = TRUE; + priv->in_state_changed++; priv->state = state; priv->state_reason = reason; queued_state_clear(self); - dispatcher_cleanup(self); + _dispatcher_cleanup(self); nm_clear_g_cancellable(&priv->deactivating_cancellable); @@ -16634,15 +15294,15 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE); nm_device_take_down(self, TRUE); nm_device_hw_addr_reset(self, "unmanage"); - set_nm_ipv6ll(self, FALSE); - restore_ip6_properties(self); + _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_EUI64); + _dev_sysctl_restore_ip6_properties(self); } } nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); break; case NM_DEVICE_STATE_UNAVAILABLE: if (old_state == NM_DEVICE_STATE_UNMANAGED) { - save_ip6_properties(self); + _dev_sysctl_save_ip6_properties(self); if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED) ip6_managed_setup(self); device_init_static_sriov_num_vfs(self); @@ -16671,7 +15331,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, /* Ensure devices that previously assumed a connection now have * userspace IPv6LL enabled. */ - set_nm_ipv6ll(self, TRUE); + _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE); } else if (old_state < NM_DEVICE_STATE_DISCONNECTED) { @@ -16784,9 +15444,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, _LOGI(LOGD_DEVICE, "Activation: successful, device activated."); nm_device_update_metered(self); nm_dispatcher_call_device(NM_DISPATCHER_ACTION_UP, self, req, NULL, NULL, NULL); - - if (priv->proxy_config) - _pacrunner_manager_add(self); + _pacrunner_manager_add(self); break; case NM_DEVICE_STATE_FAILED: /* Usually upon failure the activation chain is interrupted in @@ -16846,11 +15504,6 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, fw_change_zone(self); } else nm_device_start_ip_check(self); - - /* IP-related properties are only valid when the device has IP configuration; - * now that it does, ensure their change notifications are emitted. - */ - notify_ip_properties(self); break; } case NM_DEVICE_STATE_SECONDARIES: @@ -16873,18 +15526,13 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, } } - /* IP-related properties are only valid when the device has IP configuration. - * If it no longer does, ensure their change notifications are emitted. - */ - if (ip_config_valid(old_state) && !ip_config_valid(state)) - notify_ip_properties(self); - concheck_now = NM_IN_SET(state, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_DISCONNECTED) || old_state >= NM_DEVICE_STATE_ACTIVATED; concheck_update_interval(self, AF_INET, concheck_now); concheck_update_interval(self, AF_INET6, concheck_now); - priv->in_state_changed = FALSE; + priv->in_state_changed--; + nm_device_remove_pending_action(self, NM_PENDING_ACTION_IN_STATE_CHANGE, TRUE); if ((old_state > NM_DEVICE_STATE_UNMANAGED) != (state > NM_DEVICE_STATE_UNMANAGED)) @@ -17906,15 +16554,16 @@ nm_device_clear_dns_lookup_data(NMDevice *self) const char * nm_device_get_hostname_from_dns_lookup(NMDevice *self, int addr_family, gboolean *out_wait) { - NMDevicePrivate * priv; const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDevicePrivate * priv; HostnameResolver *resolver; - NMIPConfig * ip_config; const char * method; + int ifindex; gboolean address_changed = FALSE; gs_unref_object GInetAddress *new_address = NULL; g_return_val_if_fail(NM_IS_DEVICE(self), NULL); + priv = NM_DEVICE_GET_PRIVATE(self); /* If the device is not supposed to have addresses, @@ -17954,38 +16603,28 @@ nm_device_get_hostname_from_dns_lookup(NMDevice *self, int addr_family, gboolean /* Determine the most suitable address of the interface * and whether it changed from the previous lookup */ - ip_config = priv->ip_config_x[IS_IPv4]; - if (ip_config) { - const NMPlatformIPAddress *addr = NULL; + ifindex = nm_device_get_ip_ifindex(self); + if (ifindex > 0) { + NMPLookup lookup; + const NMDedupMultiHeadEntry *head_entry; + const NMDedupMultiEntry * iter; - if (IS_IPv4) { - addr = nm_ip_config_get_first_address(ip_config); - } else { - /* For IPv6 prefer, in order: - * - !link-local, !deprecated - * - !link-local, deprecated - * - link-local - */ - addr = nm_ip_config_find_first_address(ip_config, - NM_PLATFORM_MATCH_WITH_ADDRTYPE_NORMAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE_NORMAL); - if (!addr) { - addr = nm_ip_config_find_first_address( - ip_config, - NM_PLATFORM_MATCH_WITH_ADDRTYPE_NORMAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE_DEPRECATED); - } - if (!addr) { - addr = nm_ip_config_find_first_address(ip_config, - NM_PLATFORM_MATCH_WITH_ADDRTYPE_LINKLOCAL - | NM_PLATFORM_MATCH_WITH_ADDRSTATE__ANY); - } - } + /* FIXME(l3cfg): now we lookup the address from platform. Should we instead look + * it up from NML3Cfg? That is, take an address that we want to configure as + * opposed to an address that is configured? */ + head_entry = nm_platform_lookup( + nm_device_get_platform(self), + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex)); - if (addr) { - new_address = g_inet_address_new_from_bytes(addr->address_ptr, - IS_IPv4 ? G_SOCKET_FAMILY_IPV4 - : G_SOCKET_FAMILY_IPV6); + if (head_entry) { + c_list_for_each_entry (iter, &head_entry->lst_entries_head, lst_entries) { + const NMPlatformIPAddress *addr = NMP_OBJECT_CAST_IP_ADDRESS(iter->obj); + + new_address = g_inet_address_new_from_bytes(addr->address_ptr, + IS_IPv4 ? G_SOCKET_FAMILY_IPV4 + : G_SOCKET_FAMILY_IPV6); + break; + } } } @@ -18060,11 +16699,7 @@ _activation_func_to_string(ActivationHandleFunc func) G_STMT_END FUNC_TO_STRING_CHECK_AND_RETURN(func, activate_stage1_device_prepare); FUNC_TO_STRING_CHECK_AND_RETURN(func, activate_stage2_device_config); - FUNC_TO_STRING_CHECK_AND_RETURN(func, activate_stage3_ip_config_start); - FUNC_TO_STRING_CHECK_AND_RETURN(func, activate_stage4_ip_config_timeout_4); - FUNC_TO_STRING_CHECK_AND_RETURN(func, activate_stage4_ip_config_timeout_6); - FUNC_TO_STRING_CHECK_AND_RETURN(func, activate_stage5_ip_config_result_4); - FUNC_TO_STRING_CHECK_AND_RETURN(func, activate_stage5_ip_config_result_6); + FUNC_TO_STRING_CHECK_AND_RETURN(func, activate_stage3_ip_config); g_return_val_if_reached("unknown"); } @@ -18127,13 +16762,10 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) nm_utils_str_utf8safe_escape_cp(priv->iface, NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL)); break; case PROP_IP_IFACE: - if (ip_config_valid(priv->state)) { - g_value_take_string( - value, - nm_utils_str_utf8safe_escape_cp(nm_device_get_ip_iface(self), - NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL)); - } else - g_value_set_string(value, NULL); + g_value_take_string( + value, + nm_utils_str_utf8safe_escape_cp(nm_device_get_ip_iface(self), + NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL)); break; case PROP_IFINDEX: g_value_set_int(value, priv->ifindex); @@ -18168,24 +16800,16 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_set_uint(value, priv->mtu); break; case PROP_IP4_CONFIG: - nm_dbus_utils_g_value_set_object_path(value, - ip_config_valid(priv->state) ? priv->ip_config_4 - : NULL); + nm_dbus_utils_g_value_set_object_path(value, priv->l3ipdata_4.ip_config); break; case PROP_DHCP4_CONFIG: - nm_dbus_utils_g_value_set_object_path( - value, - ip_config_valid(priv->state) ? priv->dhcp_data_4.config : NULL); + nm_dbus_utils_g_value_set_object_path(value, priv->ipdhcp_data_4.config); break; case PROP_IP6_CONFIG: - nm_dbus_utils_g_value_set_object_path(value, - ip_config_valid(priv->state) ? priv->ip_config_6 - : NULL); + nm_dbus_utils_g_value_set_object_path(value, priv->l3ipdata_6.ip_config); break; case PROP_DHCP6_CONFIG: - nm_dbus_utils_g_value_set_object_path( - value, - ip_config_valid(priv->state) ? priv->dhcp_data_6.config : NULL); + nm_dbus_utils_g_value_set_object_path(value, priv->ipdhcp_data_6.config); break; case PROP_STATE: g_value_set_uint(value, priv->state); @@ -18392,6 +17016,8 @@ nm_device_init(NMDevice *self) c_list_init(&self->devices_lst); c_list_init(&priv->slaves); + priv->ipdhcp_data_6.v6.mode = NM_NDISC_DHCP_LEVEL_NONE; + priv->concheck_x[0].state = NM_CONNECTIVITY_UNKNOWN; priv->concheck_x[1].state = NM_CONNECTIVITY_UNKNOWN; @@ -18417,9 +17043,6 @@ nm_device_init(NMDevice *self) priv->ip6_saved_properties = g_hash_table_new_full(nm_str_hash, g_str_equal, NULL, g_free); priv->sys_iface_state_ = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL; - priv->v4_commit_first_time = TRUE; - priv->v6_commit_first_time = TRUE; - priv->promisc_reset = NM_OPTION_BOOL_DEFAULT; } @@ -18476,24 +17099,7 @@ constructed(GObject *object) if (NM_DEVICE_GET_CLASS(self)->get_generic_capabilities) priv->capabilities |= NM_DEVICE_GET_CLASS(self)->get_generic_capabilities(self); - /* Watch for external IP config changes */ platform = nm_device_get_platform(self); - g_signal_connect(platform, - NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, - G_CALLBACK(device_ipx_changed), - self); - g_signal_connect(platform, - NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, - G_CALLBACK(device_ipx_changed), - self); - g_signal_connect(platform, - NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, - G_CALLBACK(device_ipx_changed), - self); - g_signal_connect(platform, - NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, - G_CALLBACK(device_ipx_changed), - self); g_signal_connect(platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, G_CALLBACK(link_changed_cb), self); priv->manager = g_object_ref(NM_MANAGER_GET); @@ -18545,15 +17151,12 @@ dispose(GObject *object) _parent_set_ifindex(self, 0, FALSE); platform = nm_device_get_platform(self); - g_signal_handlers_disconnect_by_func(platform, G_CALLBACK(device_ipx_changed), self); g_signal_handlers_disconnect_by_func(platform, G_CALLBACK(link_changed_cb), self); - arp_cleanup(self); - nm_clear_g_signal_handler(nm_config_get(), &priv->config_changed_id); nm_clear_g_signal_handler(priv->manager, &priv->ifindex_changed_id); - dispatcher_cleanup(self); + _dispatcher_cleanup(self); nm_pacrunner_manager_remove_clear(&priv->pacrunner_conf_id); @@ -18562,7 +17165,7 @@ dispose(GObject *object) nm_assert(c_list_is_empty(&priv->slaves)); /* Let the kernel manage IPv6LL again */ - set_nm_ipv6ll(self, FALSE); + _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_EUI64); _cleanup_generic_post(self, CLEANUP_TYPE_KEEP); @@ -18609,6 +17212,10 @@ dispose(GObject *object) priv->sriov.next = NULL; } + g_clear_object(&priv->l3cfg); + g_clear_object(&priv->l3ipdata_4.ip_config); + g_clear_object(&priv->l3ipdata_6.ip_config); + G_OBJECT_CLASS(nm_device_parent_class)->dispose(object); if (nm_clear_g_source(&priv->queued_state.id)) { @@ -18631,7 +17238,6 @@ finalize(GObject *object) g_free(priv->hw_addr_perm); g_free(priv->hw_addr_initial); g_free(priv->pending_actions.arr); - g_slist_free_full(priv->dad6_failed_addrs, (GDestroyNotify) nmp_object_unref); nm_clear_g_free(&priv->physical_port_id); g_free(priv->udi); g_free(priv->path); @@ -18812,10 +17418,9 @@ nm_device_class_init(NMDeviceClass *klass) klass->link_changed = link_changed; - klass->is_available = is_available; - klass->act_stage2_config = act_stage2_config; - klass->act_stage3_ip_config_start = act_stage3_ip_config_start; - klass->act_stage4_ip_config_timeout = act_stage4_ip_config_timeout; + klass->is_available = is_available; + klass->act_stage2_config = act_stage2_config; + klass->get_ip_method_auto = get_ip_method_auto; klass->get_type_description = get_type_description; klass->can_auto_connect = can_auto_connect; @@ -19154,29 +17759,17 @@ nm_device_class_init(NMDeviceClass *klass) G_TYPE_BOOLEAN, 0); - signals[IP4_CONFIG_CHANGED] = g_signal_new(NM_DEVICE_IP4_CONFIG_CHANGED, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 2, - G_TYPE_OBJECT, - G_TYPE_OBJECT); - - signals[IP6_CONFIG_CHANGED] = g_signal_new(NM_DEVICE_IP6_CONFIG_CHANGED, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 2, - G_TYPE_OBJECT, - G_TYPE_OBJECT); + signals[L3CD_CHANGED] = g_signal_new(NM_DEVICE_L3CD_CHANGED, + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 2, + G_TYPE_POINTER, /* (const NML3ConfigData *l3cd_old) */ + G_TYPE_POINTER /* (const NML3ConfigData *l3cd_new) */); signals[IP6_PREFIX_DELEGATED] = g_signal_new(NM_DEVICE_IP6_PREFIX_DELEGATED, diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index d967bcb212..9bd8aa7bee 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -9,13 +9,14 @@ #include -#include "nm-setting-connection.h" -#include "nm-dbus-object.h" -#include "nm-dbus-interface.h" -#include "nm-connection.h" -#include "nm-rfkill-manager.h" #include "NetworkManagerUtils.h" +#include "nm-connection.h" +#include "nm-dbus-interface.h" +#include "nm-dbus-object.h" #include "nm-device-utils.h" +#include "nm-l3cfg.h" +#include "nm-rfkill-manager.h" +#include "nm-setting-connection.h" /* Properties */ #define NM_DEVICE_UDI "udi" @@ -71,8 +72,7 @@ /* Internal signals */ #define NM_DEVICE_DNS_LOOKUP_DONE "dns-lookup-done" -#define NM_DEVICE_IP4_CONFIG_CHANGED "ip4-config-changed" -#define NM_DEVICE_IP6_CONFIG_CHANGED "ip6-config-changed" +#define NM_DEVICE_L3CD_CHANGED "l3cd-changed" #define NM_DEVICE_IP6_PREFIX_DELEGATED "ip6-prefix-delegated" #define NM_DEVICE_IP6_SUBNET_NEEDED "ip6-subnet-needed" #define NM_DEVICE_REMOVED "removed" @@ -344,15 +344,10 @@ typedef struct _NMDeviceClass { NMActStageReturn (*act_stage1_prepare)(NMDevice *self, NMDeviceStateReason *out_failure_reason); NMActStageReturn (*act_stage2_config)(NMDevice *self, NMDeviceStateReason *out_failure_reason); - NMActStageReturn (*act_stage3_ip_config_start)(NMDevice * self, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason); - NMActStageReturn (*act_stage4_ip_config_timeout)(NMDevice * self, - int addr_family, - NMDeviceStateReason *out_failure_reason); + void (*act_stage3_ip_config)(NMDevice *self, int addr_family); + gboolean (*ready_for_ip_config)(NMDevice *self); - void (*ip4_config_pre_commit)(NMDevice *self, NMIP4Config *config); + const char *(*get_ip_method_auto)(NMDevice *self, int addr_family); /* Async deactivating (in the DEACTIVATING phase) */ void (*deactivate_async)(NMDevice * self, @@ -460,16 +455,13 @@ const char *nm_device_get_permanent_hw_address_full(NMDevice *self, gboolean *out_is_fake); const char *nm_device_get_initial_hw_address(NMDevice *dev); -NMProxyConfig *nm_device_get_proxy_config(NMDevice *dev); - NMDhcpConfig *nm_device_get_dhcp_config(NMDevice *dev, int addr_family); -NMIP4Config * nm_device_get_ip4_config(NMDevice *dev); -void nm_device_replace_vpn4_config(NMDevice *dev, NMIP4Config *old, NMIP4Config *config); -NMIP6Config *nm_device_get_ip6_config(NMDevice *dev); -void nm_device_replace_vpn6_config(NMDevice *dev, NMIP6Config *old, NMIP6Config *config); +NML3Cfg *nm_device_get_l3cfg(NMDevice *self); -void nm_device_capture_initial_config(NMDevice *dev); +const NML3ConfigData *nm_device_get_l3cd(NMDevice *self, gboolean get_commited); + +void nm_device_l3cfg_commit(NMDevice *self, NML3CfgCommitType commit_type, gboolean commit_sync); int nm_device_parent_get_ifindex(NMDevice *dev); NMDevice *nm_device_parent_get_device(NMDevice *dev); @@ -547,7 +539,7 @@ RfKillType nm_device_get_rfkill_type(NMDevice *device); /* IPv6 prefix delegation */ -void nm_device_request_ip6_prefixes(NMDevice *self, int needed_prefixes); +void nm_device_request_ip6_prefixes(NMDevice *self, guint needed_prefixes); gboolean nm_device_needs_ip6_subnet(NMDevice *self); @@ -754,17 +746,11 @@ NMConnection *nm_device_new_default_connection(NMDevice *self); const NMPObject *nm_device_get_best_default_route(NMDevice *self, int addr_family); -void nm_device_spawn_iface_helper(NMDevice *self); - gboolean nm_device_reapply(NMDevice *self, NMConnection *connection, GError **error); void nm_device_reapply_settings_immediately(NMDevice *self); void nm_device_update_firewall_zone(NMDevice *self); void nm_device_update_metered(NMDevice *self); -void nm_device_reactivate_ip_config(NMDevice * device, - int addr_family, - NMSettingIPConfig *s_ip_old, - NMSettingIPConfig *s_ip_new); gboolean nm_device_update_hw_address(NMDevice *self); void nm_device_update_initial_hw_address(NMDevice *self); diff --git a/src/core/devices/ovs/nm-device-ovs-bridge.c b/src/core/devices/ovs/nm-device-ovs-bridge.c index 26a5ba002c..1fe298cfa1 100644 --- a/src/core/devices/ovs/nm-device-ovs-bridge.c +++ b/src/core/devices/ovs/nm-device-ovs-bridge.c @@ -66,13 +66,16 @@ get_generic_capabilities(NMDevice *device) return NM_DEVICE_CAP_IS_SOFTWARE; } -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) +static gboolean +ready_for_ip_config(NMDevice *device) { - return NM_ACT_STAGE_RETURN_IP_FAIL; + return FALSE; +} + +static void +act_stage3_ip_config(NMDevice *device, int addr_family) +{ + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, NULL); } static gboolean @@ -154,7 +157,8 @@ nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass) device_class->create_and_realize = create_and_realize; device_class->unrealize = unrealize; device_class->get_generic_capabilities = get_generic_capabilities; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->ready_for_ip_config = ready_for_ip_config; device_class->enslave_slave = enslave_slave; device_class->release_slave = release_slave; device_class->can_reapply_change_ovs_external_ids = TRUE; diff --git a/src/core/devices/ovs/nm-device-ovs-interface.c b/src/core/devices/ovs/nm-device-ovs-interface.c index 46a612aca7..672e95f18b 100644 --- a/src/core/devices/ovs/nm-device-ovs-interface.c +++ b/src/core/devices/ovs/nm-device-ovs-interface.c @@ -124,14 +124,19 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) if (!nm_device_hw_addr_set_cloned(device, nm_device_get_applied_connection(device), FALSE)) { - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_CONFIG_FAILED); + nm_device_devip_set_failed(device, AF_INET, NM_DEVICE_STATE_REASON_CONFIG_FAILED); + nm_device_devip_set_failed(device, AF_INET6, NM_DEVICE_STATE_REASON_CONFIG_FAILED); return; } nm_device_bring_up(device, TRUE, NULL); - nm_device_activate_schedule_stage3_ip_config_start(device); + + nm_device_devip_set_state(device, AF_INET, NM_DEVICE_IP_STATE_PENDING, NULL); + nm_device_devip_set_state(device, AF_INET6, NM_DEVICE_IP_STATE_PENDING, NULL); + nm_device_activate_schedule_stage3_ip_config(device, FALSE); + return; } + + nm_device_activate_schedule_stage2_device_config(device, FALSE); } static gboolean @@ -188,31 +193,43 @@ set_platform_mtu(NMDevice *device, guint32 mtu) return NM_DEVICE_CLASS(nm_device_ovs_interface_parent_class)->set_platform_mtu(device, mtu); } -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) +static gboolean +ready_for_ip_config(NMDevice *device) +{ + return nm_device_get_ip_ifindex(device) > 0; +} + +static void +act_stage3_ip_config(NMDevice *device, int addr_family) { NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device); - NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(device); + NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); - if (!_is_internal_interface(device)) - return NM_ACT_STAGE_RETURN_IP_FAIL; + if (!_is_internal_interface(device)) { + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, NULL); + return; + } + /* FIXME(l3cfg): we should create the IP ifindex before stage3 start. + * + * For now it's here because when the ovs-interface enters stage3, then it's added to the + * controller (ovs-port) and the entry is create in the ovsdb. Only after that the kernel + * link appears. + * + * This should change. */ if (nm_device_get_ip_ifindex(device) <= 0) { _LOGT(LOGD_DEVICE, "waiting for link to appear"); priv->waiting_for_interface = TRUE; - return NM_ACT_STAGE_RETURN_POSTPONE; + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_PENDING, NULL); + return; } if (!nm_device_hw_addr_set_cloned(device, nm_device_get_applied_connection(device), FALSE)) { - *out_failure_reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED; - return NM_ACT_STAGE_RETURN_FAILURE; + nm_device_devip_set_failed(device, addr_family, NM_DEVICE_STATE_REASON_CONFIG_FAILED); + return; } - return NM_DEVICE_CLASS(nm_device_ovs_interface_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, NULL); } static gboolean @@ -443,7 +460,8 @@ nm_device_ovs_interface_class_init(NMDeviceOvsInterfaceClass *klass) device_class->is_available = is_available; device_class->check_connection_compatible = check_connection_compatible; device_class->link_changed = link_changed; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->ready_for_ip_config = ready_for_ip_config; device_class->can_unmanaged_external_down = can_unmanaged_external_down; device_class->set_platform_mtu = set_platform_mtu; device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; diff --git a/src/core/devices/ovs/nm-device-ovs-port.c b/src/core/devices/ovs/nm-device-ovs-port.c index f11c585235..9ed03b3d43 100644 --- a/src/core/devices/ovs/nm-device-ovs-port.c +++ b/src/core/devices/ovs/nm-device-ovs-port.c @@ -59,13 +59,16 @@ get_generic_capabilities(NMDevice *device) return NM_DEVICE_CAP_IS_SOFTWARE; } -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) +static gboolean +ready_for_ip_config(NMDevice *device) { - return NM_ACT_STAGE_RETURN_IP_FAIL; + return FALSE; +} + +static void +act_stage3_ip_config(NMDevice *device, int addr_family) +{ + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, NULL); } static void @@ -186,7 +189,8 @@ nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass) device_class->get_type_description = get_type_description; device_class->create_and_realize = create_and_realize; device_class->get_generic_capabilities = get_generic_capabilities; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->ready_for_ip_config = ready_for_ip_config; device_class->enslave_slave = enslave_slave; device_class->release_slave = release_slave; device_class->can_reapply_change_ovs_external_ids = TRUE; diff --git a/src/core/devices/team/nm-device-team.c b/src/core/devices/team/nm-device-team.c index 3398e467e5..7ec7305118 100644 --- a/src/core/devices/team/nm-device-team.c +++ b/src/core/devices/team/nm-device-team.c @@ -23,7 +23,6 @@ #include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "nm-dbus-manager.h" -#include "nm-ip4-config.h" #include "libnm-std-aux/nm-dbus-compat.h" #define _NMLOG_DEVICE_TYPE NMDeviceTeam diff --git a/src/core/devices/tests/meson.build b/src/core/devices/tests/meson.build index 1bc883706e..871c320629 100644 --- a/src/core/devices/tests/meson.build +++ b/src/core/devices/tests/meson.build @@ -1,7 +1,6 @@ # SPDX-License-Identifier: LGPL-2.1-or-later test_units = [ - 'test-acd', 'test-lldp', ] diff --git a/src/core/devices/tests/test-acd.c b/src/core/devices/tests/test-acd.c deleted file mode 100644 index b4b6516549..0000000000 --- a/src/core/devices/tests/test-acd.c +++ /dev/null @@ -1,259 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2015 Red Hat, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include "n-acd/src/n-acd.h" - -#include - -#include "devices/nm-acd-manager.h" -#include "platform/tests/test-common.h" - -#define IFACE_VETH0 "nm-test-veth0" -#define IFACE_VETH1 "nm-test-veth1" - -#define ADDR1 0x01010101 -#define ADDR2 0x02020202 -#define ADDR3 0x03030303 -#define ADDR4 0x04040404 - -/*****************************************************************************/ - -static gboolean -_skip_acd_test_check(void) -{ - NAcd * acd; - NAcdConfig * config; - const guint8 hwaddr[ETH_ALEN] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; - int r; - static int skip = -1; - - if (skip == -1) { - r = n_acd_config_new(&config); - g_assert(r == 0); - - n_acd_config_set_ifindex(config, 1); - n_acd_config_set_transport(config, N_ACD_TRANSPORT_ETHERNET); - n_acd_config_set_mac(config, hwaddr, sizeof(hwaddr)); - - r = n_acd_new(&acd, config); - n_acd_config_free(config); - if (r == 0) - n_acd_unref(acd); - - skip = (r != 0); - } - return skip; -} - -#define _skip_acd_test() \ - ({ \ - gboolean _skip = _skip_acd_test_check(); \ - \ - if (_skip) \ - g_test_skip("Cannot create NAcd. Running under valgind?"); \ - _skip; \ - }) - -/*****************************************************************************/ - -typedef struct { - int ifindex0; - int ifindex1; - const guint8 *hwaddr0; - const guint8 *hwaddr1; - size_t hwaddr0_len; - size_t hwaddr1_len; -} test_fixture; - -static void -fixture_setup(test_fixture *fixture, gconstpointer user_data) -{ - /* create veth pair. */ - fixture->ifindex0 = - nmtstp_link_veth_add(NM_PLATFORM_GET, -1, IFACE_VETH0, IFACE_VETH1)->ifindex; - fixture->ifindex1 = - nmtstp_link_get_typed(NM_PLATFORM_GET, -1, IFACE_VETH1, NM_LINK_TYPE_VETH)->ifindex; - - g_assert(nm_platform_link_change_flags(NM_PLATFORM_GET, fixture->ifindex0, IFF_UP, TRUE) >= 0); - g_assert(nm_platform_link_change_flags(NM_PLATFORM_GET, fixture->ifindex1, IFF_UP, TRUE) >= 0); - - fixture->hwaddr0 = - nm_platform_link_get_address(NM_PLATFORM_GET, fixture->ifindex0, &fixture->hwaddr0_len); - fixture->hwaddr1 = - nm_platform_link_get_address(NM_PLATFORM_GET, fixture->ifindex1, &fixture->hwaddr1_len); -} - -typedef struct { - in_addr_t addresses[8]; - in_addr_t peer_addresses[8]; - gboolean expected_result[8]; -} TestInfo; - -static void -acd_manager_probe_terminated(NMAcdManager *acd_manager, gpointer user_data) -{ - g_main_loop_quit(user_data); -} - -static void -test_acd_common(test_fixture *fixture, TestInfo *info) -{ - nm_auto_free_acdmgr NMAcdManager *manager = NULL; - nm_auto_unref_gmainloop GMainLoop *loop = NULL; - int i; - const guint WAIT_TIME_OPTIMISTIC = 50; - guint wait_time; - static const NMAcdCallbacks callbacks = { - .probe_terminated_callback = acd_manager_probe_terminated, - .user_data_destroy = (GDestroyNotify) g_main_loop_unref, - }; - int r; - - if (_skip_acd_test()) - return; - - /* first, try with a short waittime. We hope that this is long enough - * to successfully complete the test. Only if that's not the case, we - * assume the computer is currently busy (high load) and we retry with - * a longer timeout. */ - wait_time = WAIT_TIME_OPTIMISTIC; -again: - - nm_clear_pointer(&loop, g_main_loop_unref); - loop = g_main_loop_new(NULL, FALSE); - - nm_clear_pointer(&manager, nm_acd_manager_free); - manager = nm_acd_manager_new(fixture->ifindex0, - fixture->hwaddr0, - fixture->hwaddr0_len, - &callbacks, - g_main_loop_ref(loop)); - g_assert(manager != NULL); - - for (i = 0; info->addresses[i]; i++) - g_assert(nm_acd_manager_add_address(manager, info->addresses[i])); - - for (i = 0; info->peer_addresses[i]; i++) { - nmtstp_ip4_address_add(NULL, - FALSE, - fixture->ifindex1, - info->peer_addresses[i], - 24, - 0, - 3600, - 1800, - 0, - NULL); - } - - r = nm_acd_manager_start_probe(manager, wait_time); - g_assert_cmpint(r, ==, 0); - - g_assert(nmtst_main_loop_run(loop, 2000)); - - for (i = 0; info->addresses[i]; i++) { - gboolean val; - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - - val = nm_acd_manager_check_address(manager, info->addresses[i]); - if (val == info->expected_result[i]) - continue; - - if (wait_time == WAIT_TIME_OPTIMISTIC) { - /* probably we just had a glitch and the system took longer than - * expected. Re-verify with a large timeout this time. */ - wait_time = 1000; - goto again; - } - - g_error("expected check for address #%d (%s) to %s, but it didn't", - i, - _nm_utils_inet4_ntop(info->addresses[i], sbuf), - info->expected_result[i] ? "detect no duplicated" : "detect a duplicate"); - } -} - -static void -test_acd_probe_1(test_fixture *fixture, gconstpointer user_data) -{ - TestInfo info = {.addresses = {ADDR1, ADDR2, ADDR3}, - .peer_addresses = {ADDR4}, - .expected_result = {TRUE, TRUE, TRUE}}; - - test_acd_common(fixture, &info); -} - -static void -test_acd_probe_2(test_fixture *fixture, gconstpointer user_data) -{ - TestInfo info = {.addresses = {ADDR1, ADDR2, ADDR3, ADDR4}, - .peer_addresses = {ADDR3, ADDR2}, - .expected_result = {TRUE, FALSE, FALSE, TRUE}}; - - test_acd_common(fixture, &info); -} - -static void -test_acd_announce(test_fixture *fixture, gconstpointer user_data) -{ - nm_auto_free_acdmgr NMAcdManager *manager = NULL; - nm_auto_unref_gmainloop GMainLoop *loop = NULL; - int r; - - if (_skip_acd_test()) - return; - - manager = - nm_acd_manager_new(fixture->ifindex0, fixture->hwaddr0, fixture->hwaddr0_len, NULL, NULL); - g_assert(manager != NULL); - - g_assert(nm_acd_manager_add_address(manager, ADDR1)); - g_assert(nm_acd_manager_add_address(manager, ADDR2)); - - loop = g_main_loop_new(NULL, FALSE); - r = nm_acd_manager_announce_addresses(manager); - g_assert_cmpint(r, ==, 0); - g_assert(!nmtst_main_loop_run(loop, 200)); -} - -static void -fixture_teardown(test_fixture *fixture, gconstpointer user_data) -{ - nm_platform_link_delete(NM_PLATFORM_GET, fixture->ifindex0); - nm_platform_link_delete(NM_PLATFORM_GET, fixture->ifindex1); -} - -NMTstpSetupFunc const _nmtstp_setup_platform_func = nm_linux_platform_setup; - -void -_nmtstp_init_tests(int *argc, char ***argv) -{ - nmtst_init_with_logging(argc, argv, NULL, "ALL"); -} - -void -_nmtstp_setup_tests(void) -{ - g_test_add("/acd/probe/1", - test_fixture, - NULL, - fixture_setup, - test_acd_probe_1, - fixture_teardown); - g_test_add("/acd/probe/2", - test_fixture, - NULL, - fixture_setup, - test_acd_probe_2, - fixture_teardown); - g_test_add("/acd/announce", - test_fixture, - NULL, - fixture_setup, - test_acd_announce, - fixture_teardown); -} diff --git a/src/core/devices/wifi/nm-device-iwd.c b/src/core/devices/wifi/nm-device-iwd.c index 27a3188b0d..9a1ac8a162 100644 --- a/src/core/devices/wifi/nm-device-iwd.c +++ b/src/core/devices/wifi/nm-device-iwd.c @@ -1642,7 +1642,7 @@ network_connect_cb(GObject *source, GAsyncResult *res, gpointer user_data) _LOGI(LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Connected to '%s'.", ssid); - nm_device_activate_schedule_stage3_ip_config_start(device); + nm_device_activate_schedule_stage3_ip_config(device, FALSE); return; @@ -1721,7 +1721,7 @@ act_start_cb(GObject *source, GAsyncResult *res, gpointer user_data) _LOGI(LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Started '%s'.", ssid); - nm_device_activate_schedule_stage3_ip_config_start(device); + nm_device_activate_schedule_stage3_ip_config(device, FALSE); return; @@ -2127,7 +2127,7 @@ assumed_connection_progress_to_ip_config(NMDeviceIwd *self, gboolean was_postpon * that stage2 is done. */ if (was_postponed) - nm_device_activate_schedule_stage3_ip_config_start(NM_DEVICE(self)); + nm_device_activate_schedule_stage3_ip_config(NM_DEVICE(self), FALSE); } static void diff --git a/src/core/devices/wifi/nm-device-wifi-p2p.c b/src/core/devices/wifi/nm-device-wifi-p2p.c index 67202a6778..ed74d30ec5 100644 --- a/src/core/devices/wifi/nm-device-wifi-p2p.c +++ b/src/core/devices/wifi/nm-device-wifi-p2p.c @@ -14,18 +14,18 @@ #include "NetworkManagerUtils.h" #include "devices/nm-device-private.h" -#include "nm-act-request.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "libnm-glib-aux/nm-ref-string.h" -#include "nm-ip4-config.h" +#include "libnm-platform/nm-platform.h" +#include "libnm-platform/nmp-object.h" +#include "nm-act-request.h" +#include "nm-l3-config-data.h" #include "nm-manager.h" #include "nm-manager.h" #include "nm-setting-wifi-p2p.h" #include "nm-utils.h" #include "nm-wifi-p2p-peer.h" -#include "libnm-platform/nm-platform.h" -#include "libnm-platform/nmp-object.h" #include "settings/nm-settings.h" #define _NMLOG_DEVICE_TYPE NMDeviceWifiP2P @@ -552,13 +552,11 @@ remove_all_peers(NMDeviceWifiP2P *self) /*****************************************************************************/ -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) +static void +act_stage3_ip_config(NMDevice *device, int addr_family) { - NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(device); + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(device); + const int IS_IPv4 = NM_IS_IPv4(addr_family); gboolean indicate_addressing_running; NMConnection * connection; const char * method; @@ -568,30 +566,30 @@ act_stage3_ip_config_start(NMDevice * device, method = nm_utils_get_ip_config_method(connection, addr_family); /* We may have an address assigned by the group owner */ - if (NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) && priv->group_iface + if (IS_IPv4 && NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) && priv->group_iface && !nm_supplicant_interface_get_p2p_group_owner(priv->group_iface)) { in_addr_t addr; guint8 plen; if (nm_supplicant_interface_get_p2p_assigned_addr(priv->group_iface, &addr, &plen)) { - NMPlatformIP4Address address = { + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + NMPlatformIP4Address address = { .addr_source = NM_IP_CONFIG_SOURCE_DHCP, }; - gs_unref_object NMIP4Config *ip4_config = NULL; nm_platform_ip4_address_set_addr(&address, addr, plen); - ip4_config = nm_device_ip4_config_new(device); - nm_ip4_config_add_address(ip4_config, &address); + l3cd = nm_device_create_l3_config_data(device, NM_IP_CONFIG_SOURCE_DHCP); + nm_l3_config_data_add_address_4(l3cd, &address); - nm_device_set_dev2_ip_config(device, AF_INET, NM_IP_CONFIG(ip4_config)); + nm_device_devip_set_state(device, AF_INET, NM_DEVICE_IP_STATE_READY, l3cd); /* This just disables the addressing indicator. */ method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; } } - if (addr_family == AF_INET) + if (IS_IPv4) indicate_addressing_running = NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO); else { indicate_addressing_running = NM_IN_STRSET(method, @@ -603,9 +601,6 @@ act_stage3_ip_config_start(NMDevice * device, nm_platform_wifi_indicate_addressing_running(nm_device_get_platform(device), nm_device_get_ip_ifindex(device), TRUE); - - return NM_DEVICE_CLASS(nm_device_wifi_p2p_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); } static void @@ -757,7 +752,7 @@ check_group_iface_ready(NMDeviceWifiP2P *self) nm_clear_g_source(&priv->sup_timeout_id); update_disconnect_on_connection_peer_missing(self); - nm_device_activate_schedule_stage3_ip_config_start(NM_DEVICE(self)); + nm_device_activate_schedule_stage3_ip_config(NM_DEVICE(self), FALSE); } static void @@ -1286,11 +1281,11 @@ nm_device_wifi_p2p_class_init(NMDeviceWifiP2PClass *klass) device_class->check_connection_compatible = check_connection_compatible; device_class->complete_connection = complete_connection; - device_class->act_stage1_prepare = act_stage1_prepare; - device_class->act_stage2_config = act_stage2_config; - device_class->get_configured_mtu = get_configured_mtu; - device_class->get_auto_ip_config_method = get_auto_ip_config_method; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->act_stage1_prepare = act_stage1_prepare; + device_class->act_stage2_config = act_stage2_config; + device_class->get_configured_mtu = get_configured_mtu; + device_class->get_auto_ip_config_method = get_auto_ip_config_method; + device_class->act_stage3_ip_config = act_stage3_ip_config; device_class->deactivate = deactivate; device_class->unmanaged_on_quit = unmanaged_on_quit; diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index 82896c778e..4c5ec3e3ce 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -32,7 +32,6 @@ #include "nm-setting-wireless-security.h" #include "nm-setting-8021x.h" #include "nm-setting-ip4-config.h" -#include "nm-ip4-config.h" #include "nm-setting-ip6-config.h" #include "libnm-platform/nm-platform.h" #include "nm-auth-utils.h" @@ -136,6 +135,8 @@ typedef struct { bool ssid_found : 1; bool hidden_probe_scan_warn : 1; + bool addressing_running_indicated : 1; + } NMDeviceWifiPrivate; struct _NMDeviceWifi { @@ -393,6 +394,22 @@ nm_device_wifi_scanning_prohibited_track(NMDeviceWifi *self, /*****************************************************************************/ +static void +_indicate_addressing_running_reset(NMDeviceWifi *self) +{ + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + + if (!priv->addressing_running_indicated) + return; + + priv->addressing_running_indicated = FALSE; + nm_platform_wifi_indicate_addressing_running(nm_device_get_platform(NM_DEVICE(self)), + nm_device_get_ifindex(NM_DEVICE(self)), + FALSE); +} + +/*****************************************************************************/ + static void _ap_dump(NMDeviceWifi * self, NMLogLevel log_level, @@ -932,8 +949,7 @@ deactivate(NMDevice *device) if (!wake_on_wlan_restore(self)) _LOGW(LOGD_DEVICE | LOGD_WIFI, "Cannot unconfigure WoWLAN."); - /* Clear any critical protocol notification in the Wi-Fi stack */ - nm_platform_wifi_indicate_addressing_running(nm_device_get_platform(device), ifindex, FALSE); + _indicate_addressing_running_reset(self); /* Ensure we're in infrastructure mode after deactivation; some devices * (usually older ones) don't scan well in adhoc mode. @@ -2478,7 +2494,7 @@ supplicant_iface_state(NMDeviceWifi * self, priv->mode == _NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot" : "Connected to wireless network", (ssid_str = _nm_utils_ssid_to_string_gbytes(ssid))); - nm_device_activate_schedule_stage3_ip_config_start(device); + nm_device_activate_schedule_stage3_ip_config(device, FALSE); } else if (devstate == NM_DEVICE_STATE_ACTIVATED) periodic_update(self); break; @@ -3263,20 +3279,24 @@ out_fail: return NM_ACT_STAGE_RETURN_FAILURE; } -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) +static void +act_stage3_ip_config(NMDevice *device, int addr_family) { - gboolean indicate_addressing_running; - NMConnection *connection; - const char * method; + NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + const char * method; + gboolean indicate_addressing_running; - connection = nm_device_get_applied_connection(device); + if (priv->addressing_running_indicated) + return; - method = nm_utils_get_ip_config_method(connection, addr_family); - if (addr_family == AF_INET) + /* we always set the flag, even if we don't indicate it below. The reason + * is that we always want to *clear* the flag after we are done (as we don't + * know whether it isn't already set on the interface). */ + priv->addressing_running_indicated = TRUE; + + method = nm_utils_get_ip_config_method(nm_device_get_applied_connection(device), addr_family); + if (NM_IS_IPv4(addr_family)) indicate_addressing_running = NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO); else { indicate_addressing_running = NM_IN_STRSET(method, @@ -3284,13 +3304,11 @@ act_stage3_ip_config_start(NMDevice * device, NM_SETTING_IP6_CONFIG_METHOD_DHCP); } - if (indicate_addressing_running) + if (indicate_addressing_running) { nm_platform_wifi_indicate_addressing_running(nm_device_get_platform(device), nm_device_get_ip_ifindex(device), TRUE); - - return NM_DEVICE_CLASS(nm_device_wifi_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); + } } static guint32 @@ -3301,77 +3319,6 @@ get_configured_mtu(NMDevice *device, NMDeviceMtuSource *out_source, gboolean *ou out_source); } -static gboolean -is_static_wep(NMConnection *connection) -{ - NMSettingWirelessSecurity *s_wsec; - const char * str; - - g_return_val_if_fail(connection != NULL, FALSE); - - s_wsec = nm_connection_get_setting_wireless_security(connection); - if (!s_wsec) - return FALSE; - - str = nm_setting_wireless_security_get_key_mgmt(s_wsec); - if (g_strcmp0(str, "none") != 0) - return FALSE; - - str = nm_setting_wireless_security_get_auth_alg(s_wsec); - if (g_strcmp0(str, "leap") == 0) - return FALSE; - - return TRUE; -} - -static NMActStageReturn -act_stage4_ip_config_timeout(NMDevice * device, - int addr_family, - NMDeviceStateReason *out_failure_reason) -{ - NMDeviceWifi * self = NM_DEVICE_WIFI(device); - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMConnection * connection; - NMSettingIPConfig * s_ip; - gboolean may_fail; - - connection = nm_device_get_applied_connection(device); - s_ip = nm_connection_get_setting_ip_config(connection, addr_family); - may_fail = nm_setting_ip_config_get_may_fail(s_ip); - - if (priv->mode == _NM_802_11_MODE_AP) - goto call_parent; - - if (may_fail || !is_static_wep(connection)) { - /* Not static WEP or failure allowed; let superclass handle it */ - goto call_parent; - } - - /* If IP configuration times out and it's a static WEP connection, that - * usually means the WEP key is wrong. WEP's Open System auth mode has - * no provision for figuring out if the WEP key is wrong, so you just have - * to wait for DHCP to fail to figure it out. For all other Wi-Fi security - * types (open, WPA, 802.1x, etc) if the secrets/certs were wrong the - * connection would have failed before IP configuration. - * - * Activation failed, we must have bad encryption key */ - _LOGW(LOGD_DEVICE | LOGD_WIFI, - "Activation: (wifi) could not get IP configuration for connection '%s'.", - nm_connection_get_id(connection)); - - if (!handle_auth_or_fail(self, NULL, TRUE)) { - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_NO_SECRETS); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - _LOGI(LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) asking for new secrets"); - return NM_ACT_STAGE_RETURN_POSTPONE; - -call_parent: - return NM_DEVICE_CLASS(nm_device_wifi_parent_class) - ->act_stage4_ip_config_timeout(device, addr_family, out_failure_reason); -} - static void activation_success_handler(NMDevice *device) { @@ -3383,8 +3330,7 @@ activation_success_handler(NMDevice *device) req = nm_device_get_act_request(device); g_assert(req); - /* Clear any critical protocol notification in the wifi stack */ - nm_platform_wifi_indicate_addressing_running(nm_device_get_platform(device), ifindex, FALSE); + _indicate_addressing_running_reset(self); /* There should always be a current AP, either a fake one because we haven't * seen a scan result for the activated AP yet, or a real one from the @@ -3484,19 +3430,13 @@ device_state_changed(NMDevice * device, nm_supplicant_interface_disconnect(priv->sup_iface); break; case NM_DEVICE_STATE_IP_CHECK: - /* Clear any critical protocol notification in the wifi stack */ - nm_platform_wifi_indicate_addressing_running(nm_device_get_platform(device), - nm_device_get_ifindex(device), - FALSE); + _indicate_addressing_running_reset(self); break; case NM_DEVICE_STATE_ACTIVATED: activation_success_handler(device); break; case NM_DEVICE_STATE_FAILED: - /* Clear any critical protocol notification in the wifi stack */ - nm_platform_wifi_indicate_addressing_running(nm_device_get_platform(device), - nm_device_get_ifindex(device), - FALSE); + _indicate_addressing_running_reset(self); break; case NM_DEVICE_STATE_DISCONNECTED: break; @@ -3803,17 +3743,16 @@ nm_device_wifi_class_init(NMDeviceWifiClass *klass) device_class->get_guessed_metered = get_guessed_metered; device_class->set_enabled = set_enabled; - device_class->act_stage1_prepare = act_stage1_prepare; - device_class->act_stage2_config = act_stage2_config; - device_class->get_configured_mtu = get_configured_mtu; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; - device_class->act_stage4_ip_config_timeout = act_stage4_ip_config_timeout; - device_class->deactivate_async = deactivate_async; - device_class->deactivate = deactivate; - device_class->deactivate_reset_hw_addr = deactivate_reset_hw_addr; - device_class->unmanaged_on_quit = unmanaged_on_quit; - device_class->can_reapply_change = can_reapply_change; - device_class->reapply_connection = reapply_connection; + device_class->act_stage1_prepare = act_stage1_prepare; + device_class->act_stage2_config = act_stage2_config; + device_class->get_configured_mtu = get_configured_mtu; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->deactivate_async = deactivate_async; + device_class->deactivate = deactivate; + device_class->deactivate_reset_hw_addr = deactivate_reset_hw_addr; + device_class->unmanaged_on_quit = unmanaged_on_quit; + device_class->can_reapply_change = can_reapply_change; + device_class->reapply_connection = reapply_connection; device_class->state_changed = device_state_changed; diff --git a/src/core/devices/wwan/libnm-wwan.ver b/src/core/devices/wwan/libnm-wwan.ver index c368a5907d..640df36dd8 100644 --- a/src/core/devices/wwan/libnm-wwan.ver +++ b/src/core/devices/wwan/libnm-wwan.ver @@ -14,7 +14,6 @@ global: nm_modem_get_control_port; nm_modem_get_device_id; nm_modem_get_driver; - nm_modem_get_iid; nm_modem_get_ip_ifindex; nm_modem_get_operator_code; nm_modem_get_path; @@ -22,7 +21,6 @@ global: nm_modem_get_state; nm_modem_get_type; nm_modem_get_uid; - nm_modem_ip4_pre_commit; nm_modem_is_claimed; nm_modem_manager_get; nm_modem_manager_get_modems; @@ -32,8 +30,7 @@ global: nm_modem_manager_name_owner_unref; nm_modem_owns_port; nm_modem_set_mm_enabled; - nm_modem_stage3_ip4_config_start; - nm_modem_stage3_ip6_config_start; + nm_modem_stage3_ip_config_start; nm_modem_state_to_string; nm_modem_unclaim; local: diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index 1b28546937..97fc1b6d29 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -8,7 +8,7 @@ #include "nm-device-modem.h" #include "nm-modem.h" -#include "nm-ip4-config.h" +#include "nm-l3-config-data.h" #include "devices/nm-device-private.h" #include "nm-rfkill-manager.h" #include "settings/nm-settings-connection.h" @@ -33,6 +33,7 @@ typedef struct { NMModem * modem; NMDeviceModemCapabilities caps; NMDeviceModemCapabilities current_caps; + NMUtilsIPv6IfaceId iid; char * device_id; char * operator_code; char * apn; @@ -60,43 +61,9 @@ static void ppp_failed(NMModem *modem, guint i_reason, gpointer user_data) { NMDevice * device = NM_DEVICE(user_data); - NMDeviceModem * self = NM_DEVICE_MODEM(user_data); NMDeviceStateReason reason = i_reason; - switch (nm_device_get_state(device)) { - case NM_DEVICE_STATE_PREPARE: - case NM_DEVICE_STATE_CONFIG: - case NM_DEVICE_STATE_NEED_AUTH: - nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, reason); - break; - case NM_DEVICE_STATE_IP_CONFIG: - case NM_DEVICE_STATE_IP_CHECK: - case NM_DEVICE_STATE_SECONDARIES: - case NM_DEVICE_STATE_ACTIVATED: - if (nm_device_activate_ip4_state_in_conf(device)) - nm_device_activate_schedule_ip_config_timeout(device, AF_INET); - else if (nm_device_activate_ip6_state_in_conf(device)) - nm_device_activate_schedule_ip_config_timeout(device, AF_INET6); - else if (nm_device_activate_ip4_state_done(device)) { - nm_device_ip_method_failed(device, - AF_INET, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } else if (nm_device_activate_ip6_state_done(device)) { - nm_device_ip_method_failed(device, - AF_INET6, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } else { - _LOGW(LOGD_MB, - "PPP failure in unexpected state %u", - (guint) nm_device_get_state(device)); - nm_device_state_changed(device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } - break; - default: - break; - } + nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, reason); } static void @@ -188,96 +155,39 @@ modem_auth_result(NMModem *modem, GError *error, gpointer user_data) } static void -modem_ip4_config_result(NMModem *modem, NMIP4Config *config, GError *error, gpointer user_data) +modem_new_config(NMModem * modem, + int addr_family, + const NML3ConfigData * l3cd, + gboolean do_auto, + const NMUtilsIPv6IfaceId *iid, + int failure_reason_i, + GError * error, + gpointer user_data) { - NMDeviceModem *self = NM_DEVICE_MODEM(user_data); - NMDevice * device = NM_DEVICE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDeviceModem * self = NM_DEVICE_MODEM(user_data); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); + NMDevice * device = NM_DEVICE(self); - if (!nm_device_activate_ip4_state_in_conf(device)) { - _LOGD(LOGD_MB | LOGD_IP4, - "retrieving IPv4 configuration while no longer in state IPv4 conf"); - return; - } + g_return_if_fail(nm_device_devip_get_state(device, addr_family) == NM_DEVICE_IP_STATE_PENDING); if (error) { - _LOGW(LOGD_MB | LOGD_IP4, "retrieving IPv4 configuration failed: %s", error->message); - nm_device_ip_method_failed(device, AF_INET, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + _LOGW(LOGD_MB | LOGD_IP4, "retrieving IP configuration failed: %s", error->message); + nm_device_devip_set_failed(device, addr_family, failure_reason_i); return; } - nm_device_set_dev2_ip_config(device, AF_INET, NM_IP_CONFIG_CAST(config)); - nm_device_activate_schedule_ip_config_result(device, AF_INET, NULL); -} + if (!IS_IPv4) + priv->iid = iid ? *iid : ((NMUtilsIPv6IfaceId) NM_UTILS_IPV6_IFACE_ID_INIT); -static void -modem_ip6_config_result(NMModem * modem, - NMIP6Config *config, - gboolean do_slaac, - GError * error, - gpointer user_data) -{ - NMDeviceModem * self = NM_DEVICE_MODEM(user_data); - NMDevice * device = NM_DEVICE(self); - NMActStageReturn ret; - NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; - gs_unref_object NMIP6Config *ignored = NULL; - gboolean got_config = !!config; - - if (!nm_device_activate_ip6_state_in_conf(device)) { - _LOGD(LOGD_MB | LOGD_IP6, - "retrieving IPv6 configuration while no longer in state IPv6 conf"); - return; + if (do_auto) { + if (IS_IPv4) + nm_device_ip_method_dhcp4_start(device); + else + nm_device_ip_method_autoconf6_start(device); } - if (error) { - _LOGW(LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: %s", error->message); - nm_device_ip_method_failed(device, AF_INET6, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - return; - } - - /* Re-enable IPv6 on the interface */ - nm_device_sysctl_ip_conf_set(device, AF_INET6, "disable_ipv6", "0"); - - if (config) - nm_device_set_dev2_ip_config(device, AF_INET6, NM_IP_CONFIG_CAST(config)); - - if (do_slaac == FALSE) { - if (got_config) - nm_device_activate_schedule_ip_config_result(device, AF_INET6, NULL); - else { - _LOGW(LOGD_MB | LOGD_IP6, - "retrieving IPv6 configuration failed: SLAAC not requested and no addresses"); - nm_device_ip_method_failed(device, - AF_INET6, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } - return; - } - - /* Start SLAAC now that we have a link-local address from the modem */ - ret = - NM_DEVICE_CLASS(nm_device_modem_parent_class) - ->act_stage3_ip_config_start(device, AF_INET6, (gpointer *) &ignored, &failure_reason); - - nm_assert(ignored == NULL); - - switch (ret) { - case NM_ACT_STAGE_RETURN_FAILURE: - nm_device_ip_method_failed(device, AF_INET6, failure_reason); - break; - case NM_ACT_STAGE_RETURN_IP_FAIL: - /* all done */ - nm_device_activate_schedule_ip_config_result(device, AF_INET6, NULL); - break; - case NM_ACT_STAGE_RETURN_POSTPONE: - /* let SLAAC run */ - break; - default: - /* Should never get here since we've assured that the IPv6 method - * will either be "auto" or "ignored" when starting IPv6 configuration. - */ - nm_assert_not_reached(); - } + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, l3cd); } static void @@ -606,36 +516,18 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - nm_modem_act_stage2_config(NM_DEVICE_MODEM_GET_PRIVATE(device)->modem); - return NM_ACT_STAGE_RETURN_SUCCESS; -} - -static NMActStageReturn -act_stage3_ip_config_start(NMDevice * device, - int addr_family, - gpointer * out_config, - NMDeviceStateReason *out_failure_reason) -{ - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); - gboolean autoip4 = FALSE; - NMActStageReturn ret; - - if (!NM_IS_IPv4(addr_family)) - return nm_modem_stage3_ip6_config_start(priv->modem, device, out_failure_reason); - - ret = nm_modem_stage3_ip4_config_start(priv->modem, device, &autoip4, out_failure_reason); - - if (ret != NM_ACT_STAGE_RETURN_SUCCESS || !autoip4) - return ret; - - return NM_DEVICE_CLASS(nm_device_modem_parent_class) - ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); + return nm_modem_act_stage2_config(NM_DEVICE_MODEM_GET_PRIVATE(device)->modem, + device, + out_failure_reason); } static void -ip4_config_pre_commit(NMDevice *device, NMIP4Config *config) +act_stage3_ip_config(NMDevice *device, int addr_family) { - nm_modem_ip4_pre_commit(NM_DEVICE_MODEM_GET_PRIVATE(device)->modem, device, config); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); + + if (nm_modem_stage3_ip_config_start(priv->modem, addr_family, device)) + nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_PENDING, NULL); } static gboolean @@ -643,14 +535,15 @@ get_ip_iface_identifier(NMDevice *device, NMUtilsIPv6IfaceId *out_iid) { NMDeviceModem * self = NM_DEVICE_MODEM(device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); - gboolean success; g_return_val_if_fail(priv->modem, FALSE); - success = nm_modem_get_iid(priv->modem, out_iid); - if (!success) - success = - NM_DEVICE_CLASS(nm_device_modem_parent_class)->get_ip_iface_identifier(device, out_iid); - return success; + + if (priv->iid.id != 0) { + *out_iid = priv->iid; + return TRUE; + } + + return NM_DEVICE_CLASS(nm_device_modem_parent_class)->get_ip_iface_identifier(device, out_iid); } /*****************************************************************************/ @@ -716,8 +609,7 @@ set_modem(NMDeviceModem *self, NMModem *modem) g_signal_connect(modem, NM_MODEM_PPP_FAILED, G_CALLBACK(ppp_failed), self); g_signal_connect(modem, NM_MODEM_PREPARE_RESULT, G_CALLBACK(modem_prepare_result), self); - g_signal_connect(modem, NM_MODEM_IP4_CONFIG_RESULT, G_CALLBACK(modem_ip4_config_result), self); - g_signal_connect(modem, NM_MODEM_IP6_CONFIG_RESULT, G_CALLBACK(modem_ip6_config_result), self); + g_signal_connect(modem, NM_MODEM_NEW_CONFIG, G_CALLBACK(modem_new_config), self); g_signal_connect(modem, NM_MODEM_AUTH_REQUESTED, G_CALLBACK(modem_auth_requested), self); g_signal_connect(modem, NM_MODEM_AUTH_RESULT, G_CALLBACK(modem_auth_result), self); g_signal_connect(modem, NM_MODEM_STATE_CHANGED, G_CALLBACK(modem_state_cb), self); @@ -904,8 +796,7 @@ nm_device_modem_class_init(NMDeviceModemClass *klass) device_class->deactivate = deactivate; device_class->act_stage1_prepare = act_stage1_prepare; device_class->act_stage2_config = act_stage2_config; - device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; - device_class->ip4_config_pre_commit = ip4_config_pre_commit; + device_class->act_stage3_ip_config = act_stage3_ip_config; device_class->get_enabled = get_enabled; device_class->set_enabled = set_enabled; device_class->owns_iface = owns_iface; diff --git a/src/core/devices/wwan/nm-modem-broadband.c b/src/core/devices/wwan/nm-modem-broadband.c index a5139f0833..483314ff21 100644 --- a/src/core/devices/wwan/nm-modem-broadband.c +++ b/src/core/devices/wwan/nm-modem-broadband.c @@ -16,8 +16,7 @@ #include "NetworkManagerUtils.h" #include "devices/nm-device-private.h" #include "libnm-platform/nm-platform.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" +#include "nm-l3-config-data.h" #define NM_MODEM_BROADBAND_MODEM "modem" @@ -91,9 +90,6 @@ typedef struct { MMBearerIpConfig *ipv4_config; MMBearerIpConfig *ipv6_config; - guint idle_id_ip4; - guint idle_id_ip6; - guint32 pin_tries; } NMModemBroadbandPrivate; @@ -958,249 +954,247 @@ set_mm_enabled(NMModem *_self, gboolean enabled) } /*****************************************************************************/ -/* IPv4 method static */ -static gboolean -static_stage3_ip4_done(NMModemBroadband *self) +static void +stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_method) { - GError * error = NULL; - gs_unref_object NMIP4Config *config = NULL; - const char * data_port; - const char * address_string; - const char * gw_string; - guint32 address_network; - guint32 gw = 0; - NMPlatformIP4Address address; - const char ** dns; - guint i; - guint32 ip4_route_table, ip4_route_metric; - NMPlatformIP4Route * r; - guint32 mtu_n; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMModemBroadband * self = NM_MODEM_BROADBAND(modem); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + char sbuf[sizeof(_nm_utils_to_string_buffer)]; + gs_free_error GError * error = NULL; + const char * data_port; + const char * address_string; + const char ** dns; + guint i; + gboolean do_auto = FALSE; + int ifindex; + NMUtilsIPv6IfaceId iid_data; + const NMUtilsIPv6IfaceId *iid = NULL; - g_return_val_if_fail(self->_priv.ipv4_config, FALSE); - g_return_val_if_fail(self->_priv.bearer, FALSE); + if (IS_IPv4) { + g_return_if_fail(self->_priv.ipv4_config); + g_return_if_fail(self->_priv.bearer); - self->_priv.idle_id_ip4 = 0; + if (ip_method == NM_MODEM_IP_METHOD_AUTO) { + do_auto = TRUE; + goto out; + } + } else { + g_return_if_fail(self->_priv.ipv6_config); + } - _LOGI("IPv4 static configuration:"); + if (IS_IPv4) { + guint32 address_network; + guint32 gw = 0; + NMPlatformIP4Address address; + NMPlatformIP4Route route; + guint32 mtu_n; + const char * gw_string; - /* Fully fail if invalid IP address retrieved */ - address_string = mm_bearer_ip_config_get_address(self->_priv.ipv4_config); - if (!address_string - || !nm_utils_parse_inaddr_bin(AF_INET, address_string, NULL, &address_network)) { - error = - g_error_new(NM_DEVICE_ERROR, + _LOGI("IPv4 static configuration:"); + + /* Fully fail if invalid IP address retrieved */ + address_string = mm_bearer_ip_config_get_address(self->_priv.ipv4_config); + if (!address_string + || !nm_utils_parse_inaddr_bin(AF_INET, address_string, NULL, &address_network)) { + g_set_error(&error, + NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IP4 configuration failed: invalid address given %s%s%s", nm_modem_get_uid(NM_MODEM(self)), NM_PRINT_FMT_QUOTE_STRING(address_string)); - goto out; - } + goto out; + } - /* Missing gateway not a hard failure */ - gw_string = mm_bearer_ip_config_get_gateway(self->_priv.ipv4_config); - if (gw_string && !nm_utils_parse_inaddr_bin(AF_INET, gw_string, NULL, &gw)) { - error = - g_error_new(NM_DEVICE_ERROR, + /* Missing gateway not a hard failure */ + gw_string = mm_bearer_ip_config_get_gateway(self->_priv.ipv4_config); + if (gw_string && !nm_utils_parse_inaddr_bin(AF_INET, gw_string, NULL, &gw)) { + g_set_error(&error, + NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IP4 configuration failed: invalid gateway address \"%s\"", nm_modem_get_uid(NM_MODEM(self)), gw_string); - goto out; - } - - data_port = mm_bearer_get_interface(self->_priv.bearer); - g_return_val_if_fail(data_port, FALSE); - config = nm_ip4_config_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), - nm_platform_link_get_ifindex(NM_PLATFORM_GET, data_port)); - - memset(&address, 0, sizeof(address)); - address.address = address_network; - address.peer_address = address_network; - address.plen = mm_bearer_ip_config_get_prefix(self->_priv.ipv4_config); - address.addr_source = NM_IP_CONFIG_SOURCE_WWAN; - if (address.plen <= 32) - nm_ip4_config_add_address(config, &address); - - _LOGI(" address %s/%d", address_string, address.plen); - - nm_modem_get_route_parameters(NM_MODEM(self), &ip4_route_table, &ip4_route_metric, NULL, NULL); - r = &(NMPlatformIP4Route){ - .rt_source = NM_IP_CONFIG_SOURCE_WWAN, - .gateway = gw, - .table_coerced = nm_platform_route_table_coerce(ip4_route_table), - .metric = ip4_route_metric, - }; - nm_ip4_config_add_route(config, r, NULL); - _LOGI(" gateway %s", gw_string); - - /* DNS servers */ - dns = mm_bearer_ip_config_get_dns(self->_priv.ipv4_config); - for (i = 0; dns && dns[i]; i++) { - if (nm_utils_parse_inaddr_bin(AF_INET, dns[i], NULL, &address_network) - && address_network > 0) { - nm_ip4_config_add_nameserver(config, address_network); - _LOGI(" DNS %s", dns[i]); + goto out; + } + + data_port = mm_bearer_get_interface(self->_priv.bearer); + g_return_if_fail(data_port); + + ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, data_port); + if (ifindex <= 0) { + g_set_error(&error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, + "(%s) data port %s not found", + nm_modem_get_uid(NM_MODEM(self)), + data_port); + goto out; + } + + l3cd = nm_l3_config_data_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), + ifindex, + NM_IP_CONFIG_SOURCE_WWAN); + + address = (NMPlatformIP4Address){ + .address = address_network, + .peer_address = address_network, + .plen = mm_bearer_ip_config_get_prefix(self->_priv.ipv4_config), + .addr_source = NM_IP_CONFIG_SOURCE_WWAN, + }; + if (address.plen <= 32) + nm_l3_config_data_add_address_4(l3cd, &address); + + _LOGI(" address %s", nm_platform_ip4_address_to_string(&address, sbuf, sizeof(sbuf))); + + route = (NMPlatformIP4Route){ + .rt_source = NM_IP_CONFIG_SOURCE_WWAN, + .gateway = gw, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, + }; + nm_l3_config_data_add_route_4(l3cd, &route); + _LOGI(" gateway %s", gw_string); + + dns = mm_bearer_ip_config_get_dns(self->_priv.ipv4_config); + for (i = 0; dns && dns[i]; i++) { + if (nm_utils_parse_inaddr_bin(AF_INET, dns[i], NULL, &address_network) + && address_network > 0) { + nm_l3_config_data_add_nameserver(l3cd, AF_INET, &address_network); + _LOGI(" DNS %s", dns[i]); + } } - } #if MM_CHECK_VERSION(1, 4, 0) - mtu_n = mm_bearer_ip_config_get_mtu(self->_priv.ipv4_config); - if (mtu_n) { - nm_ip4_config_set_mtu(config, mtu_n, NM_IP_CONFIG_SOURCE_WWAN); - _LOGI(" MTU %u", mtu_n); - } -#endif - -out: - g_signal_emit_by_name(self, NM_MODEM_IP4_CONFIG_RESULT, config, error); - g_clear_error(&error); - return FALSE; -} - -static NMActStageReturn -static_stage3_ip4_config_start(NMModem * modem, - NMActRequest * req, - NMDeviceStateReason *out_failure_reason) -{ - NMModemBroadband * self = NM_MODEM_BROADBAND(modem); - NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE(self); - - /* We schedule it in an idle just to follow the same logic as in the - * generic modem implementation. */ - nm_clear_g_source(&priv->idle_id_ip4); - priv->idle_id_ip4 = g_idle_add((GSourceFunc) static_stage3_ip4_done, self); - - return NM_ACT_STAGE_RETURN_POSTPONE; -} - -/*****************************************************************************/ -/* IPv6 method static */ - -static gboolean -stage3_ip6_done(NMModemBroadband *self) -{ - GError * error = NULL; - NMIP6Config * config = NULL; - const char * data_port; - const char * address_string; - NMPlatformIP6Address address; - NMModemIPMethod ip_method; - const char ** dns; - guint i; - - g_return_val_if_fail(self->_priv.ipv6_config, FALSE); - - self->_priv.idle_id_ip6 = 0; - memset(&address, 0, sizeof(address)); - - ip_method = get_bearer_ip_method(self->_priv.ipv6_config); - - address_string = mm_bearer_ip_config_get_address(self->_priv.ipv6_config); - if (!address_string) { - /* DHCP/SLAAC is allowed to skip addresses; other methods require it */ - if (ip_method != NM_MODEM_IP_METHOD_AUTO) { - error = g_error_new(NM_DEVICE_ERROR, - NM_DEVICE_ERROR_INVALID_CONNECTION, - "(%s) retrieving IPv6 configuration failed: no address given", - nm_modem_get_uid(NM_MODEM(self))); + mtu_n = mm_bearer_ip_config_get_mtu(self->_priv.ipv4_config); + if (mtu_n) { + nm_l3_config_data_set_mtu(l3cd, mtu_n); + _LOGI(" MTU %u", mtu_n); } - goto out; - } +#endif + } else { + NMPlatformIP6Address address; - /* Fail if invalid IP address retrieved */ - if (!inet_pton(AF_INET6, address_string, (void *) &(address.address))) { - error = g_error_new(NM_DEVICE_ERROR, + address_string = mm_bearer_ip_config_get_address(self->_priv.ipv6_config); + if (!address_string) { + /* DHCP/SLAAC is allowed to skip addresses; other methods require it */ + if (ip_method != NM_MODEM_IP_METHOD_AUTO) { + g_set_error(&error, + NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, - "(%s) retrieving IPv6 configuration failed: invalid address given '%s'", - nm_modem_get_uid(NM_MODEM(self)), - address_string); - goto out; - } + "(%s) retrieving IPv6 configuration failed: no address given", + nm_modem_get_uid(NM_MODEM(self))); + } + goto out; + } - _LOGI("IPv6 base configuration:"); + address = (NMPlatformIP6Address){}; - data_port = mm_bearer_get_interface(self->_priv.bearer); - g_return_val_if_fail(data_port, FALSE); + if (!inet_pton(AF_INET6, address_string, &address.address)) { + g_set_error(&error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, + "(%s) retrieving IPv6 configuration failed: invalid address given '%s'", + nm_modem_get_uid(NM_MODEM(self)), + address_string); + goto out; + } - config = nm_ip6_config_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), - nm_platform_link_get_ifindex(NM_PLATFORM_GET, data_port)); + data_port = mm_bearer_get_interface(self->_priv.bearer); + g_return_if_fail(data_port); - address.plen = mm_bearer_ip_config_get_prefix(self->_priv.ipv6_config); - if (address.plen <= 128) - nm_ip6_config_add_address(config, &address); + ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, data_port); + if (ifindex <= 0) { + g_set_error(&error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, + "(%s) data port %s not found", + nm_modem_get_uid(NM_MODEM(self)), + data_port); + goto out; + } - _LOGI(" address %s/%d", address_string, address.plen); + _LOGI("IPv6 base configuration:"); - address_string = mm_bearer_ip_config_get_gateway(self->_priv.ipv6_config); - if (address_string) { - guint32 ip6_route_table, ip6_route_metric; + l3cd = nm_l3_config_data_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), + ifindex, + NM_IP_CONFIG_SOURCE_WWAN); - if (inet_pton(AF_INET6, address_string, &address.address) != 1) { - error = - g_error_new(NM_DEVICE_ERROR, + do_auto = TRUE; + + address.plen = mm_bearer_ip_config_get_prefix(self->_priv.ipv6_config); + if (address.plen <= 128) { + if (IN6_IS_ADDR_LINKLOCAL(&address.address)) { + iid_data.id = ((guint64 *) (&address.address.s6_addr))[1]; + iid = &iid_data; + } else + do_auto = FALSE; + nm_l3_config_data_add_address_6(l3cd, &address); + } + + _LOGI(" address %s (slaac %s)", + nm_platform_ip6_address_to_string(&address, sbuf, sizeof(sbuf)), + do_auto ? "enabled" : "disabled"); + + address_string = mm_bearer_ip_config_get_gateway(self->_priv.ipv6_config); + if (address_string) { + if (inet_pton(AF_INET6, address_string, &address.address) != 1) { + g_set_error(&error, + NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IPv6 configuration failed: invalid gateway given '%s'", nm_modem_get_uid(NM_MODEM(self)), address_string); + goto out; + } + + { + const NMPlatformIP6Route r = { + .rt_source = NM_IP_CONFIG_SOURCE_WWAN, + .gateway = address.address, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, + }; + + _LOGI(" gateway %s", address_string); + nm_l3_config_data_add_route_6(l3cd, &r); + } + } else if (ip_method == NM_MODEM_IP_METHOD_STATIC) { + /* Gateway required for the 'static' method */ + g_set_error(&error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, + "(%s) retrieving IPv6 configuration failed: missing gateway", + nm_modem_get_uid(NM_MODEM(self))); goto out; } - nm_modem_get_route_parameters(NM_MODEM(self), - NULL, - NULL, - &ip6_route_table, - &ip6_route_metric); - { - const NMPlatformIP6Route r = { - .rt_source = NM_IP_CONFIG_SOURCE_WWAN, - .gateway = address.address, - .table_coerced = nm_platform_route_table_coerce(ip6_route_table), - .metric = ip6_route_metric, - }; + dns = mm_bearer_ip_config_get_dns(self->_priv.ipv6_config); + for (i = 0; dns && dns[i]; i++) { + struct in6_addr addr; - _LOGI(" gateway %s", address_string); - nm_ip6_config_add_route(config, &r, NULL); - } - } else if (ip_method == NM_MODEM_IP_METHOD_STATIC) { - /* Gateway required for the 'static' method */ - error = g_error_new(NM_DEVICE_ERROR, - NM_DEVICE_ERROR_INVALID_CONNECTION, - "(%s) retrieving IPv6 configuration failed: missing gateway", - nm_modem_get_uid(NM_MODEM(self))); - goto out; - } - - /* DNS servers */ - dns = mm_bearer_ip_config_get_dns(self->_priv.ipv6_config); - for (i = 0; dns && dns[i]; i++) { - struct in6_addr addr; - - if (inet_pton(AF_INET6, dns[i], &addr)) { - nm_ip6_config_add_nameserver(config, &addr); - _LOGI(" DNS %s", dns[i]); + if (inet_pton(AF_INET6, dns[i], &addr)) { + nm_l3_config_data_add_nameserver(l3cd, AF_INET6, &addr); + _LOGI(" DNS %s", dns[i]); + } } } out: - nm_modem_emit_ip6_config_result(NM_MODEM(self), config, error); - g_clear_object(&config); - g_clear_error(&error); - return FALSE; -} + if (error) { + nm_modem_emit_signal_new_config_failure(modem, + addr_family, + NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE, + error); + return; + } -static NMActStageReturn -stage3_ip6_config_request(NMModem *modem, NMDeviceStateReason *out_failure_reason) -{ - NMModemBroadband * self = NM_MODEM_BROADBAND(modem); - NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE(self); - - /* We schedule it in an idle just to follow the same logic as in the - * generic modem implementation. */ - nm_clear_g_source(&priv->idle_id_ip6); - priv->idle_id_ip6 = g_idle_add((GSourceFunc) stage3_ip6_done, self); - - return NM_ACT_STAGE_RETURN_POSTPONE; + nm_modem_emit_signal_new_config_success(modem, addr_family, l3cd, do_auto, iid); } /*****************************************************************************/ @@ -1564,27 +1558,24 @@ dispose(GObject *object) NMModemBroadband * self = NM_MODEM_BROADBAND(object); NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE(self); - nm_clear_g_source(&priv->idle_id_ip4); - nm_clear_g_source(&priv->idle_id_ip6); - connect_context_clear(self); - g_clear_object(&self->_priv.ipv4_config); - g_clear_object(&self->_priv.ipv6_config); - g_clear_object(&self->_priv.bearer); + g_clear_object(&priv->ipv4_config); + g_clear_object(&priv->ipv6_config); + g_clear_object(&priv->bearer); - if (self->_priv.modem_iface) { - g_signal_handlers_disconnect_by_data(self->_priv.modem_iface, self); - g_clear_object(&self->_priv.modem_iface); + if (priv->modem_iface) { + g_signal_handlers_disconnect_by_data(priv->modem_iface, self); + g_clear_object(&priv->modem_iface); } - if (self->_priv.modem_3gpp_iface) { - g_signal_handlers_disconnect_by_data(self->_priv.modem_3gpp_iface, self); - g_clear_object(&self->_priv.modem_3gpp_iface); + if (priv->modem_3gpp_iface) { + g_signal_handlers_disconnect_by_data(priv->modem_3gpp_iface, self); + g_clear_object(&priv->modem_3gpp_iface); } - g_clear_object(&self->_priv.simple_iface); - g_clear_object(&self->_priv.sim_iface); - g_clear_object(&self->_priv.modem_object); + g_clear_object(&priv->simple_iface); + g_clear_object(&priv->sim_iface); + g_clear_object(&priv->modem_object); G_OBJECT_CLASS(nm_modem_broadband_parent_class)->dispose(object); } @@ -1600,8 +1591,7 @@ nm_modem_broadband_class_init(NMModemBroadbandClass *klass) object_class->set_property = set_property; modem_class->get_capabilities = get_capabilities; - modem_class->static_stage3_ip4_config_start = static_stage3_ip4_config_start; - modem_class->stage3_ip6_config_request = stage3_ip6_config_request; + modem_class->stage3_ip_config_start = stage3_ip_config_start; modem_class->disconnect = disconnect; modem_class->deactivate_cleanup = deactivate_cleanup; modem_class->set_mm_enabled = set_mm_enabled; diff --git a/src/core/devices/wwan/nm-modem-ofono.c b/src/core/devices/wwan/nm-modem-ofono.c index 78ad7b6820..47dc1e3b6d 100644 --- a/src/core/devices/wwan/nm-modem-ofono.c +++ b/src/core/devices/wwan/nm-modem-ofono.c @@ -11,7 +11,7 @@ #include "devices/nm-device-private.h" #include "nm-modem.h" #include "libnm-platform/nm-platform.h" -#include "nm-ip4-config.h" +#include "nm-l3-config-data.h" #define VARIANT_IS_OF_TYPE_BOOLEAN(v) \ ((v) != NULL && (g_variant_is_of_type((v), G_VARIANT_TYPE_BOOLEAN))) @@ -47,7 +47,7 @@ typedef struct { gboolean modem_online; gboolean gprs_attached; - NMIP4Config *ip4_config; + NML3ConfigData *l3cd_4; } NMModemOfonoPrivate; struct _NMModemOfono { @@ -240,7 +240,7 @@ deactivate_cleanup(NMModem *modem, NMDevice *device, gboolean stop_ppp_manager) /* TODO: cancel SimpleConnect() if any */ - g_clear_object(&priv->ip4_config); + nm_clear_l3cd(&priv->l3cd_4); NM_MODEM_CLASS(nm_modem_ofono_parent_class) ->deactivate_cleanup(modem, device, stop_ppp_manager); @@ -734,13 +734,13 @@ handle_settings(GVariant *v_dict, gpointer user_data) { NMModemOfono * self = NM_MODEM_OFONO(user_data); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); - NMPlatformIP4Address addr; + char sbuf[sizeof(_nm_utils_to_string_buffer)]; + NMPlatformIP4Address address; gboolean ret = FALSE; const char * interface; const char * s; - const char ** array, **iter; + const char ** array; guint32 address_network, gateway_network; - guint32 ip4_route_table, ip4_route_metric; int ifindex; GError * error = NULL; @@ -773,12 +773,14 @@ handle_settings(GVariant *v_dict, gpointer user_data) } ifindex = nm_modem_get_ip_ifindex(NM_MODEM(self)); - nm_assert(ifindex > 0); + g_return_if_fail(ifindex > 0); - /* TODO: verify handling of ip4_config; check other places it's used... */ - g_clear_object(&priv->ip4_config); + /* TODO: verify handling of l3cd_4; check other places it's used... */ + nm_clear_l3cd(&priv->l3cd_4); - priv->ip4_config = nm_ip4_config_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), ifindex); + priv->l3cd_4 = nm_l3_config_data_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), + ifindex, + NM_IP_CONFIG_SOURCE_WWAN); if (!g_variant_lookup(v_dict, "Address", "&s", &s)) { _LOGW("Settings 'Address' missing"); @@ -788,10 +790,12 @@ handle_settings(GVariant *v_dict, gpointer user_data) _LOGW("can't convert 'Address' %s to addr", s ?: ""); goto out; } - memset(&addr, 0, sizeof(addr)); - addr.ifindex = ifindex; - addr.address = address_network; - addr.addr_source = NM_IP_CONFIG_SOURCE_WWAN; + + address = (NMPlatformIP4Address){ + .ifindex = ifindex, + .address = address_network, + .addr_source = NM_IP_CONFIG_SOURCE_WWAN, + }; if (!g_variant_lookup(v_dict, "Netmask", "&s", &s)) { _LOGW("Settings 'Netmask' missing"); @@ -801,10 +805,10 @@ handle_settings(GVariant *v_dict, gpointer user_data) _LOGW("invalid 'Netmask': %s", s ?: ""); goto out; } - addr.plen = nm_utils_ip4_netmask_to_prefix(address_network); + address.plen = nm_utils_ip4_netmask_to_prefix(address_network); - _LOGI("Address: %s", nm_platform_ip4_address_to_string(&addr, NULL, 0)); - nm_ip4_config_add_address(priv->ip4_config, &addr); + _LOGI("Address: %s", nm_platform_ip4_address_to_string(&address, sbuf, sizeof(sbuf))); + nm_l3_config_data_add_address_4(priv->l3cd_4, &address); if (!g_variant_lookup(v_dict, "Gateway", "&s", &s) || !s) { _LOGW("Settings 'Gateway' missing"); @@ -814,17 +818,18 @@ handle_settings(GVariant *v_dict, gpointer user_data) _LOGW("invalid 'Gateway': %s", s); goto out; } - nm_modem_get_route_parameters(NM_MODEM(self), &ip4_route_table, &ip4_route_metric, NULL, NULL); { const NMPlatformIP4Route r = { .rt_source = NM_IP_CONFIG_SOURCE_WWAN, .gateway = gateway_network, - .table_coerced = nm_platform_route_table_coerce(ip4_route_table), - .metric = ip4_route_metric, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, }; _LOGI("Gateway: %s", s); - nm_ip4_config_add_route(priv->ip4_config, &r, NULL); + nm_l3_config_data_add_route_4(priv->l3cd_4, &r); } if (!g_variant_lookup(v_dict, "DomainNameServers", "^a&s", &array)) { @@ -832,52 +837,48 @@ handle_settings(GVariant *v_dict, gpointer user_data) goto out; } if (array) { - for (iter = array; *iter; iter++) { - if (nm_utils_parse_inaddr_bin(AF_INET, *iter, NULL, &address_network) - && address_network) { - _LOGI("DNS: %s", *iter); - nm_ip4_config_add_nameserver(priv->ip4_config, address_network); - } else { - _LOGW("invalid NameServer: %s", *iter); - } - } + gboolean any_good = FALSE; - if (iter == array) { + for (; array[0]; array++) { + if (!nm_utils_parse_inaddr_bin(AF_INET, *array, NULL, &address_network) + || !address_network) { + _LOGW("invalid NameServer: %s", *array); + continue; + } + any_good = TRUE; + _LOGI("DNS: %s", *array); + nm_l3_config_data_add_nameserver(priv->l3cd_4, AF_INET, &address_network); + } + if (!any_good) { _LOGW("Settings: 'DomainNameServers': none specified"); - g_free(array); goto out; } - g_free(array); } if (g_variant_lookup(v_dict, "MessageProxy", "&s", &s)) { _LOGI("MessageProxy: %s", s); if (s && nm_utils_parse_inaddr_bin(AF_INET, s, NULL, &address_network)) { - nm_modem_get_route_parameters(NM_MODEM(self), - &ip4_route_table, - &ip4_route_metric, - NULL, - NULL); + const NMPlatformIP4Route mms_route = { + .network = address_network, + .plen = 32, + .gateway = gateway_network, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, + }; - { - const NMPlatformIP4Route mms_route = { - .network = address_network, - .plen = 32, - .gateway = gateway_network, - .table_coerced = nm_platform_route_table_coerce(ip4_route_table), - .metric = ip4_route_metric, - }; - - nm_ip4_config_add_route(priv->ip4_config, &mms_route, NULL); - } - } else { + nm_l3_config_data_add_route_4(priv->l3cd_4, &mms_route); + } else _LOGW("invalid MessageProxy: %s", s); - } } ret = TRUE; out: + if (priv->l3cd_4) + nm_l3_config_data_seal(priv->l3cd_4); + if (nm_modem_get_state(NM_MODEM(self)) != NM_MODEM_STATE_CONNECTED) { _LOGI("emitting PREPARE_RESULT: %s", ret ? "TRUE" : "FALSE"); nm_modem_emit_prepare_result(NM_MODEM(self), @@ -912,30 +913,35 @@ context_property_changed(GDBusProxy *proxy, const char *property, GVariant *v, g handle_settings(v_dict, user_data); } -static NMActStageReturn -static_stage3_ip4_config_start(NMModem * modem, - NMActRequest * req, - NMDeviceStateReason *out_failure_reason) +static void +stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_method) { - NMModemOfono * self = NM_MODEM_OFONO(modem); - NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); - GError * error = NULL; - - if (!priv->ip4_config) { - _LOGD("IP4 config not ready(?)"); - return NM_ACT_STAGE_RETURN_FAILURE; - } + NMModemOfono * self = NM_MODEM_OFONO(modem); + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); + gs_free_error GError *error = NULL; _LOGD("IP4 config is done; setting modem_state -> CONNECTED"); - g_signal_emit_by_name(self, NM_MODEM_IP4_CONFIG_RESULT, priv->ip4_config, error); - /* Signal listener takes ownership of the IP4Config */ - priv->ip4_config = NULL; + if (!NM_IS_IPv4(addr_family) || ip_method == NM_MODEM_IP_METHOD_AUTO) { + nm_modem_emit_signal_new_config_success(modem, addr_family, NULL, TRUE, NULL); + goto out; + } + if (!priv->l3cd_4) { + nm_utils_error_set(&error, NM_UTILS_ERROR_UNKNOWN, "IP config not received"); + nm_modem_emit_signal_new_config_failure(modem, + addr_family, + NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE, + error); + goto out; + } + + nm_modem_emit_signal_new_config_success(modem, addr_family, priv->l3cd_4, FALSE, NULL); + +out: nm_modem_set_state(NM_MODEM(self), NM_MODEM_STATE_CONNECTED, nm_modem_state_to_string(NM_MODEM_STATE_CONNECTED)); - return NM_ACT_STAGE_RETURN_POSTPONE; } static void @@ -1040,7 +1046,7 @@ context_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data) * clear it so that we can gate getting the IP config from oFono * on whether or not we have already received them */ - g_clear_object(&priv->ip4_config); + nm_clear_l3cd(&priv->l3cd_4); /* We need to directly query ConnectionContextinteface to get the current * property values */ @@ -1258,7 +1264,7 @@ dispose(GObject *object) priv->connect_properties = NULL; } - g_clear_object(&priv->ip4_config); + nm_clear_l3cd(&priv->l3cd_4); if (priv->modem_proxy) { g_signal_handlers_disconnect_by_data(priv->modem_proxy, self); @@ -1300,6 +1306,6 @@ nm_modem_ofono_class_init(NMModemOfonoClass *klass) modem_class->deactivate_cleanup = deactivate_cleanup; modem_class->check_connection_compatible_with_modem = check_connection_compatible_with_modem; - modem_class->modem_act_stage1_prepare = modem_act_stage1_prepare; - modem_class->static_stage3_ip4_config_start = static_stage3_ip4_config_start; + modem_class->modem_act_stage1_prepare = modem_act_stage1_prepare; + modem_class->stage3_ip_config_start = stage3_ip_config_start; } diff --git a/src/core/devices/wwan/nm-modem.c b/src/core/devices/wwan/nm-modem.c index ccea69db16..579f366c17 100644 --- a/src/core/devices/wwan/nm-modem.c +++ b/src/core/devices/wwan/nm-modem.c @@ -13,16 +13,16 @@ #include #include -#include "libnm-core-intern/nm-core-internal.h" -#include "libnm-platform/nm-platform.h" -#include "nm-setting-connection.h" #include "NetworkManagerUtils.h" #include "devices/nm-device-private.h" -#include "nm-netns.h" +#include "libnm-core-intern/nm-core-internal.h" +#include "libnm-platform/nm-platform.h" #include "nm-act-request.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" +#include "nm-l3-config-data.h" +#include "nm-netns.h" +#include "nm-setting-connection.h" #include "ppp/nm-ppp-manager-call.h" +#include "ppp/nm-ppp-mgr.h" #include "ppp/nm-ppp-status.h" /*****************************************************************************/ @@ -45,8 +45,7 @@ enum { PPP_STATS, PPP_FAILED, PREPARE_RESULT, - IP4_CONFIG_RESULT, - IP6_CONFIG_RESULT, + NEW_CONFIG, AUTH_REQUESTED, AUTH_RESULT, REMOVED, @@ -56,6 +55,11 @@ enum { static guint signals[LAST_SIGNAL] = {0}; +typedef struct { + GSource *stage3_on_idle_source; + bool stage3_started : 1; +} IPData; + typedef struct _NMModemPrivate { char *uid; char *path; @@ -63,41 +67,38 @@ typedef struct _NMModemPrivate { char *control_port; char *data_port; - /* TODO: ip_iface is solely used for nm_modem_owns_port(). - * We should rework the code that it's not necessary */ - char *ip_iface; - - int ip_ifindex; - NMModemIPMethod ip4_method; - NMModemIPMethod ip6_method; - NMUtilsIPv6IfaceId iid; - NMModemState state; - NMModemState prev_state; /* revert to this state if enable/disable fails */ - char * device_id; - char * sim_id; - NMModemIPType ip_types; - char * sim_operator_id; - char * operator_code; - char * apn; + int ip_ifindex; + NMModemIPMethod ip4_method; + NMModemIPMethod ip6_method; + NMModemState state; + NMModemState prev_state; /* revert to this state if enable/disable fails */ + char * device_id; + char * sim_id; + NMModemIPType ip_types; + char * sim_operator_id; + char * operator_code; + char * apn; NMPPPManager *ppp_manager; + NMPppMgr * ppp_mgr; - NMActRequest * act_request; + NMActRequest * act_req; + NMDevice * device; guint32 secrets_tries; NMActRequestGetSecretsCallId *secrets_id; guint mm_ip_timeout; - guint32 ip4_route_table; - guint32 ip4_route_metric; - guint32 ip6_route_table; - guint32 ip6_route_metric; - - /* PPP stats */ - guint32 in_bytes; - guint32 out_bytes; - bool claimed : 1; + + union { + struct { + IPData ip_data_6; + IPData ip_data_4; + }; + IPData ip_data_x[2]; + }; + } NMModemPrivate; G_DEFINE_TYPE(NMModem, nm_modem, G_TYPE_OBJECT) @@ -149,7 +150,7 @@ _nmlog_prefix(char *prefix, NMModem *self) /*****************************************************************************/ -static void _set_ip_ifindex(NMModem *self, int ifindex, const char *ifname); +static void _set_ip_ifindex(NMModem *self, int ifindex); /*****************************************************************************/ /* State/enabled/connected */ @@ -180,6 +181,91 @@ nm_modem_state_to_string(NMModemState state) /*****************************************************************************/ +static NMPlatform * +_get_platform(NMModem *self) +{ + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); + + if (!priv->device) + return NULL; + + return nm_device_get_platform(priv->device); +} + +/*****************************************************************************/ + +void +nm_modem_emit_signal_new_config(NMModem * self, + int addr_family, + const NML3ConfigData * l3cd, + gboolean do_auto, + const NMUtilsIPv6IfaceId *iid, + NMDeviceStateReason failure_reason, + GError * error) +{ + nm_assert(NM_IS_MODEM(self)); + nm_assert_addr_family(addr_family); + nm_assert(!l3cd || NM_IS_L3_CONFIG_DATA(l3cd)); + nm_assert(!do_auto || addr_family == AF_INET6); + nm_assert(!iid || addr_family == AF_INET6); + nm_assert(!error || (!l3cd && !do_auto && !iid)); + + if (error) { + _LOGD("signal: new-config: IPv%c, failed '%s', %s", + nm_utils_addr_family_to_char(addr_family), + nm_device_state_reason_to_string_a(failure_reason), + error->message); + } else { + gs_free char *str_to_free = NULL; + + _LOGD( + "signal: new-config: IPv%c%s%s%s%s", + nm_utils_addr_family_to_char(addr_family), + l3cd ? ", has-l3cd" : "", + do_auto ? ", do-auto" : "", + NM_PRINT_FMT_QUOTED2(iid, + ", iid=", + nm_utils_bin2hexstr_a(iid, sizeof(*iid), ':', FALSE, &str_to_free), + "")); + } + + g_signal_emit(self, + signals[NEW_CONFIG], + 0, + addr_family, + nm_l3_config_data_seal(l3cd), + do_auto, + iid, + (int) failure_reason, + error); +} + +void +nm_modem_emit_signal_new_config_success(NMModem * self, + int addr_family, + const NML3ConfigData * l3cd, + gboolean do_auto, + const NMUtilsIPv6IfaceId *iid) +{ + nm_modem_emit_signal_new_config(self, + addr_family, + l3cd, + do_auto, + iid, + NM_DEVICE_STATE_REASON_NONE, + NULL); +} + +void +nm_modem_emit_signal_new_config_failure(NMModem * self, + int addr_family, + NMDeviceStateReason failure_reason, + GError * error) +{ + nm_assert(error); + nm_modem_emit_signal_new_config(self, addr_family, NULL, FALSE, NULL, failure_reason, error); +} + gboolean nm_modem_is_claimed(NMModem *self) { @@ -240,10 +326,10 @@ nm_modem_set_state(NMModem *self, NMModemState new_state, const char *reason) priv->prev_state = NM_MODEM_STATE_UNKNOWN; if (new_state != old_state) { - _LOGI("modem state changed, '%s' --> '%s' (reason: %s)", + _LOGD("signal: modem state changed, '%s' --> '%s' (reason: %s%s%s)", nm_modem_state_to_string(old_state), nm_modem_state_to_string(new_state), - reason ?: "none"); + NM_PRINT_FMT_QUOTE_STRING(reason)); priv->state = new_state; _notify(self, PROP_STATE); @@ -285,7 +371,7 @@ nm_modem_set_mm_enabled(NMModem *self, gboolean enabled) /* Try to unlock the modem if it's being enabled */ if (enabled) - g_signal_emit(self, signals[AUTH_REQUESTED], 0); + nm_modem_emit_auth_requested(self); return; } @@ -303,14 +389,25 @@ nm_modem_set_mm_enabled(NMModem *self, gboolean enabled) void nm_modem_emit_removed(NMModem *self) { + _LOGD("signal: removed"); g_signal_emit(self, signals[REMOVED], 0); } +void +nm_modem_emit_auth_requested(NMModem *self) +{ + _LOGD("signal: auth-requested"); + g_signal_emit(self, signals[AUTH_REQUESTED], 0); +} + void nm_modem_emit_prepare_result(NMModem *self, gboolean success, NMDeviceStateReason reason) { nm_assert(NM_IS_MODEM(self)); + _LOGD("signal: prepare-result: %s (%s)", + success ? "success" : "failure", + nm_device_state_reason_to_string_a(reason)); g_signal_emit(self, signals[PREPARE_RESULT], 0, success, (guint) reason); } @@ -319,6 +416,7 @@ nm_modem_emit_ppp_failed(NMModem *self, NMDeviceStateReason reason) { nm_assert(NM_IS_MODEM(self)); + _LOGD("signal: ppp-failed (%s)", nm_device_state_reason_to_string_a(reason)); g_signal_emit(self, signals[PPP_FAILED], 0, (guint) reason); } @@ -372,7 +470,7 @@ nm_modem_get_connection_ip_type(NMModem *self, NMConnection *connection, GError s_ip4 = nm_connection_get_setting_ip4_config(connection); if (s_ip4) { method = nm_setting_ip_config_get_method(s_ip4); - if (g_strcmp0(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) + if (nm_streq0(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) ip4 = FALSE; ip4_may_fail = nm_setting_ip_config_get_may_fail(s_ip4); } @@ -487,76 +585,90 @@ nm_modem_get_apn(NMModem *self) } /*****************************************************************************/ -/* IP method PPP */ static void -ppp_state_changed(NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_data) +_ppp_mgr_cleanup(NMModem *self) { - switch (status) { - case NM_PPP_STATUS_DISCONNECT: - nm_modem_emit_ppp_failed(user_data, NM_DEVICE_STATE_REASON_PPP_DISCONNECT); - break; - case NM_PPP_STATUS_DEAD: - nm_modem_emit_ppp_failed(user_data, NM_DEVICE_STATE_REASON_PPP_FAILED); - break; - default: - break; + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); + + nm_clear_pointer(&priv->ppp_mgr, nm_ppp_mgr_destroy); +} + +static void +_ppp_maybe_emit_new_config(NMModem *self, int addr_family) +{ + NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + const NMPppMgrIPData *ip_data; + gboolean do_auto; + + ip_data = nm_ppp_mgr_get_ip_data(priv->ppp_mgr, addr_family); + + if (!ip_data->ip_received) + return; + + if (IS_IPv4) + do_auto = FALSE; + else { + do_auto = !ip_data->l3cd + || (!nm_l3_config_data_get_first_obj(ip_data->l3cd, + NMP_OBJECT_TYPE_IP6_ADDRESS, + nmp_object_ip6_address_is_not_link_local)); } + + nm_assert(!IS_IPv4 || !ip_data->ipv6_iid); + + nm_modem_emit_signal_new_config_success(self, + addr_family, + ip_data->l3cd, + do_auto, + ip_data->ipv6_iid); } static void -ppp_ifindex_set(NMPPPManager *ppp_manager, int ifindex, const char *iface, gpointer user_data) +_ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, gpointer user_data) { - NMModem *self = NM_MODEM(user_data); + NMModem * self = NM_MODEM(user_data); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); + int IS_IPv4; - nm_assert(ifindex >= 0); - nm_assert(NM_MODEM_GET_PRIVATE(self)->ppp_manager == ppp_manager); + switch (callback_data->callback_type) { + case NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED: - if (ifindex <= 0 && iface) { - /* this might happen, if the ifname was already deleted - * and we failed to resolve ifindex. - * - * Forget about the name. */ - iface = NULL; + if (callback_data->data.state >= _NM_PPP_MGR_STATE_FAILED_START) { + nm_modem_emit_ppp_failed(self, callback_data->data.reason); + return; + } + + if (callback_data->data.state >= NM_PPP_MGR_STATE_HAVE_IFINDEX) + _set_ip_ifindex(self, callback_data->data.ifindex); + + if (callback_data->data.state >= NM_PPP_MGR_STATE_HAVE_IP_CONFIG) { + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + if (!priv->ip_data_x[IS_IPv4].stage3_started) { + /* stage3 didn't yet start. We don't emit the IP signal yet. + * We will emit it together with stage3. */ + continue; + } + if (callback_data->data.ip_changed_x[IS_IPv4]) + _ppp_maybe_emit_new_config(self, IS_IPv4 ? AF_INET : AF_INET6); + } + } + return; + + case NM_PPP_MGR_CALLBACK_TYPE_STATS_CHANGED: + g_signal_emit(self, + signals[PPP_STATS], + 0, + (guint) callback_data->data.stats_data->in_bytes, + (guint) callback_data->data.stats_data->out_bytes); + return; } - _set_ip_ifindex(self, ifindex, iface); + + nm_assert_not_reached(); } -static void -ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data) -{ - NMModem *self = NM_MODEM(user_data); - - g_signal_emit(self, signals[IP4_CONFIG_RESULT], 0, config, NULL); -} - -static void -ppp_ip6_config(NMPPPManager * ppp_manager, - const NMUtilsIPv6IfaceId *iid, - NMIP6Config * config, - gpointer user_data) -{ - NMModem *self = NM_MODEM(user_data); - - NM_MODEM_GET_PRIVATE(self)->iid = *iid; - - nm_modem_emit_ip6_config_result(self, config, NULL); -} - -static void -ppp_stats(NMPPPManager *ppp_manager, guint i_in_bytes, guint i_out_bytes, gpointer user_data) -{ - NMModem * self = NM_MODEM(user_data); - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); - guint32 in_bytes = i_in_bytes; - guint32 out_bytes = i_out_bytes; - - if (priv->in_bytes != in_bytes || priv->out_bytes != out_bytes) { - priv->in_bytes = in_bytes; - priv->out_bytes = out_bytes; - g_signal_emit(self, signals[PPP_STATS], 0, (guint) in_bytes, (guint) out_bytes); - } -} +/*****************************************************************************/ static gboolean port_speed_is_zero(const char *port) @@ -585,283 +697,108 @@ port_speed_is_zero(const char *port) return cfgetospeed(&options) == B0; } -static NMActStageReturn -ppp_stage3_ip_config_start(NMModem * self, - NMActRequest * req, - NMDeviceStateReason *out_failure_reason) +/*****************************************************************************/ + +static gboolean +_stage3_ip_config_start_on_idle(NMModem *self, int addr_family) { - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); - const char * ppp_name = NULL; - GError * error = NULL; - guint ip_timeout = 30; - guint baud_override = 0; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); + NMModemIPMethod ip_method; + NMConnection * connection; + const char * method; + gs_free_error GError *error = NULL; + NMDeviceStateReason failure_reason; - g_return_val_if_fail(NM_IS_MODEM(self), NM_ACT_STAGE_RETURN_FAILURE); - g_return_val_if_fail(NM_IS_ACT_REQUEST(req), NM_ACT_STAGE_RETURN_FAILURE); + nm_clear_g_source_inst(&priv->ip_data_x[IS_IPv4].stage3_on_idle_source); - /* If we're already running PPP don't restart it; for example, if both - * IPv4 and IPv6 are requested, IPv4 gets started first, but we use the - * same pppd for both v4 and v6. - */ - if (priv->ppp_manager) - return NM_ACT_STAGE_RETURN_POSTPONE; + connection = nm_act_request_get_applied_connection(priv->act_req); + g_return_val_if_fail(connection, G_SOURCE_CONTINUE); - if (NM_MODEM_GET_CLASS(self)->get_user_pass) { - NMConnection *connection = nm_act_request_get_applied_connection(req); + method = nm_utils_get_ip_config_method(connection, addr_family); - g_assert(connection); - if (!NM_MODEM_GET_CLASS(self)->get_user_pass(self, connection, &ppp_name, NULL)) - return NM_ACT_STAGE_RETURN_FAILURE; + if (IS_IPv4 ? NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) + : NM_IN_STRSET(method, + NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) { + nm_modem_emit_signal_new_config_success(self, addr_family, NULL, FALSE, NULL); + return G_SOURCE_CONTINUE; } - if (!priv->data_port) { - _LOGE("error starting PPP (no data port)"); - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED); - return NM_ACT_STAGE_RETURN_FAILURE; + if (!nm_streq(method, + IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_AUTO + : NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { + failure_reason = NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED; + nm_utils_error_set(&error, NM_UTILS_ERROR_UNKNOWN, "ip method unsupported by modem"); + goto out_failure; } - /* Check if ModemManager requested a specific IP timeout to be used. If 0 reported, - * use the default one (30s) */ - if (priv->mm_ip_timeout > 0) { - _LOGI("using modem-specified IP timeout: %u seconds", priv->mm_ip_timeout); - ip_timeout = priv->mm_ip_timeout; + ip_method = IS_IPv4 ? priv->ip4_method : priv->ip6_method; + + switch (ip_method) { + case NM_MODEM_IP_METHOD_PPP: + _ppp_maybe_emit_new_config(self, addr_family); + return G_SOURCE_CONTINUE; + case NM_MODEM_IP_METHOD_STATIC: + case NM_MODEM_IP_METHOD_AUTO: + NM_MODEM_GET_CLASS(self)->stage3_ip_config_start(self, addr_family, ip_method); + return G_SOURCE_CONTINUE; + default: + failure_reason = NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED; + nm_utils_error_set(&error, NM_UTILS_ERROR_UNKNOWN, "modem IP method unsupported"); + goto out_failure; } - /* Some tty drivers and modems ignore port speed, but pppd requires the - * port speed to be > 0 or it exits. If the port speed is 0 pass an - * explicit speed to pppd to prevent the exit. - * https://bugzilla.redhat.com/show_bug.cgi?id=1281731 - */ - if (port_speed_is_zero(priv->data_port)) - baud_override = 57600; + nm_assert_not_reached(); - priv->ppp_manager = nm_ppp_manager_create(priv->data_port, &error); +out_failure: + nm_modem_emit_signal_new_config_failure(self, addr_family, failure_reason, error); + return G_SOURCE_CONTINUE; +} - if (priv->ppp_manager) { - nm_ppp_manager_set_route_parameters(priv->ppp_manager, - priv->ip4_route_table, - priv->ip4_route_metric, - priv->ip6_route_table, - priv->ip6_route_metric); +static gboolean +_stage3_ip_config_start_on_idle_4(gpointer user_data) +{ + return _stage3_ip_config_start_on_idle(user_data, AF_INET); +} + +static gboolean +_stage3_ip_config_start_on_idle_6(gpointer user_data) +{ + return _stage3_ip_config_start_on_idle(user_data, AF_INET6); +} + +gboolean +nm_modem_stage3_ip_config_start(NMModem *self, int addr_family, NMDevice *device) +{ + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMModemPrivate *priv; + + g_return_val_if_fail(NM_IS_MODEM(self), FALSE); + g_return_val_if_fail(NM_IS_DEVICE(device), FALSE); + + priv = NM_MODEM_GET_PRIVATE(self); + + g_return_val_if_fail(priv->device == device, FALSE); + + if (priv->ip_data_x[IS_IPv4].stage3_started) { + /* we already started. Nothing to do. */ + return FALSE; } - if (!priv->ppp_manager - || !nm_ppp_manager_start(priv->ppp_manager, - req, - ppp_name, - ip_timeout, - baud_override, - &error)) { - _LOGE("error starting PPP: %s", error->message); - g_error_free(error); - g_clear_object(&priv->ppp_manager); - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED); - return NM_ACT_STAGE_RETURN_FAILURE; - } + nm_assert(!priv->ppp_mgr + || nm_ppp_mgr_get_state(priv->ppp_mgr) >= NM_PPP_MGR_STATE_HAVE_IFINDEX); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, - G_CALLBACK(ppp_state_changed), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IFINDEX_SET, - G_CALLBACK(ppp_ifindex_set), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, - G_CALLBACK(ppp_ip4_config), - self); - g_signal_connect(priv->ppp_manager, - NM_PPP_MANAGER_SIGNAL_IP6_CONFIG, - G_CALLBACK(ppp_ip6_config), - self); - g_signal_connect(priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATS, G_CALLBACK(ppp_stats), self); + priv->ip_data_x[IS_IPv4].stage3_started = TRUE; - return NM_ACT_STAGE_RETURN_POSTPONE; + priv->ip_data_x[IS_IPv4].stage3_on_idle_source = nm_g_idle_add_source( + IS_IPv4 ? _stage3_ip_config_start_on_idle_4 : _stage3_ip_config_start_on_idle_6, + self); + return TRUE; } /*****************************************************************************/ -NMActStageReturn -nm_modem_stage3_ip4_config_start(NMModem * self, - NMDevice * device, - gboolean * out_autoip4, - NMDeviceStateReason *out_failure_reason) -{ - NMModemPrivate * priv; - NMActRequest * req; - NMConnection * connection; - const char * method; - NMActStageReturn ret; - - _LOGD("ip4_config_start"); - - g_return_val_if_fail(NM_IS_MODEM(self), NM_ACT_STAGE_RETURN_FAILURE); - g_return_val_if_fail(NM_IS_DEVICE(device), NM_ACT_STAGE_RETURN_FAILURE); - nm_assert(out_autoip4 && !*out_autoip4); - - req = nm_device_get_act_request(device); - g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); - - connection = nm_act_request_get_applied_connection(req); - g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); - - nm_modem_set_route_parameters_from_device(self, device); - - method = nm_utils_get_ip_config_method(connection, AF_INET); - - /* Only Disabled and Auto methods make sense for WWAN */ - if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) - return NM_ACT_STAGE_RETURN_SUCCESS; - - if (!nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { - _LOGE("unhandled WWAN IPv4 method '%s'; will fail", method); - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - priv = NM_MODEM_GET_PRIVATE(self); - switch (priv->ip4_method) { - case NM_MODEM_IP_METHOD_PPP: - ret = ppp_stage3_ip_config_start(self, req, out_failure_reason); - break; - case NM_MODEM_IP_METHOD_STATIC: - _LOGD("MODEM_IP_METHOD_STATIC"); - ret = - NM_MODEM_GET_CLASS(self)->static_stage3_ip4_config_start(self, req, out_failure_reason); - break; - case NM_MODEM_IP_METHOD_AUTO: - _LOGD("MODEM_IP_METHOD_AUTO"); - *out_autoip4 = TRUE; - ret = NM_ACT_STAGE_RETURN_SUCCESS; - break; - default: - _LOGI("IPv4 configuration disabled"); - ret = NM_ACT_STAGE_RETURN_IP_FAIL; - break; - } - - return ret; -} - -void -nm_modem_ip4_pre_commit(NMModem *modem, NMDevice *device, NMIP4Config *config) -{ - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(modem); - - /* If the modem has an ethernet-type data interface (ie, not PPP and thus - * not point-to-point) and IP config has a /32 prefix, then we assume that - * ARP will be pointless and we turn it off. - */ - if (priv->ip4_method == NM_MODEM_IP_METHOD_STATIC - || priv->ip4_method == NM_MODEM_IP_METHOD_AUTO) { - const NMPlatformIP4Address *address = nm_ip4_config_get_first_address(config); - - g_assert(address); - if (address->plen == 32) - nm_platform_link_change_flags(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - IFF_NOARP, - TRUE); - } -} - -/*****************************************************************************/ - -void -nm_modem_emit_ip6_config_result(NMModem *self, NMIP6Config *config, GError *error) -{ - NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); - NMDedupMultiIter ipconf_iter; - const NMPlatformIP6Address *addr; - gboolean do_slaac = TRUE; - - if (error) { - g_signal_emit(self, signals[IP6_CONFIG_RESULT], 0, NULL, FALSE, error); - return; - } - - if (config) { - /* If the IPv6 configuration only included a Link-Local address, then - * we have to run SLAAC to get the full IPv6 configuration. - */ - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, config, &addr) { - if (IN6_IS_ADDR_LINKLOCAL(&addr->address)) { - if (!priv->iid.id) - priv->iid.id = ((guint64 *) (&addr->address.s6_addr))[1]; - } else - do_slaac = FALSE; - } - } - g_assert(config || do_slaac); - - g_signal_emit(self, signals[IP6_CONFIG_RESULT], 0, config, do_slaac, NULL); -} - -static NMActStageReturn -stage3_ip6_config_request(NMModem *self, NMDeviceStateReason *out_failure_reason) -{ - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - return NM_ACT_STAGE_RETURN_FAILURE; -} - -NMActStageReturn -nm_modem_stage3_ip6_config_start(NMModem * self, - NMDevice * device, - NMDeviceStateReason *out_failure_reason) -{ - NMModemPrivate * priv; - NMActRequest * req; - NMActStageReturn ret; - NMConnection * connection; - const char * method; - - g_return_val_if_fail(NM_IS_MODEM(self), NM_ACT_STAGE_RETURN_FAILURE); - - req = nm_device_get_act_request(device); - g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); - - connection = nm_act_request_get_applied_connection(req); - g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); - - nm_modem_set_route_parameters_from_device(self, device); - - method = nm_utils_get_ip_config_method(connection, AF_INET6); - - /* Only Ignore, Disabled and Auto methods make sense for WWAN */ - if (NM_IN_STRSET(method, - NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) - return NM_ACT_STAGE_RETURN_IP_DONE; - - if (!nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - _LOGW("unhandled WWAN IPv6 method '%s'; will fail", method); - NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - return NM_ACT_STAGE_RETURN_FAILURE; - } - - priv = NM_MODEM_GET_PRIVATE(self); - switch (priv->ip6_method) { - case NM_MODEM_IP_METHOD_PPP: - ret = ppp_stage3_ip_config_start(self, req, out_failure_reason); - break; - case NM_MODEM_IP_METHOD_STATIC: - case NM_MODEM_IP_METHOD_AUTO: - /* Both static and DHCP/Auto retrieve a base IP config from the modem - * which in the static case is the full config, and the DHCP/Auto case - * is just the IPv6LL address to use for SLAAC. - */ - ret = NM_MODEM_GET_CLASS(self)->stage3_ip6_config_request(self, out_failure_reason); - break; - default: - _LOGI("IPv6 configuration disabled"); - ret = NM_ACT_STAGE_RETURN_IP_FAIL; - break; - } - - return ret; -} - guint32 nm_modem_get_configured_mtu(NMDevice *self, NMDeviceMtuSource *out_source, gboolean *out_force) { @@ -910,7 +847,7 @@ cancel_get_secrets(NMModem *self) NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); if (priv->secrets_id) - nm_act_request_cancel_secrets(priv->act_request, priv->secrets_id); + nm_act_request_cancel_secrets(priv->act_req, priv->secrets_id); } static void @@ -934,6 +871,8 @@ modem_secrets_cb(NMActRequest * req, if (error) _LOGW("modem-secrets: %s", error->message); + _LOGD("signal: auth-result: %s%s", + NM_PRINT_FMT_QUOTED2(error, "failed: ", error->message, "success")); g_signal_emit(self, signals[AUTH_RESULT], 0, error); } @@ -950,7 +889,7 @@ nm_modem_get_secrets(NMModem * self, if (request_new) flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW; - priv->secrets_id = nm_act_request_get_secrets(priv->act_request, + priv->secrets_id = nm_act_request_get_secrets(priv->act_req, FALSE, setting_name, flags, @@ -958,7 +897,7 @@ nm_modem_get_secrets(NMModem * self, modem_secrets_cb, self); g_return_if_fail(priv->secrets_id); - g_signal_emit(self, signals[AUTH_REQUESTED], 0); + nm_modem_emit_auth_requested(self); } /*****************************************************************************/ @@ -982,16 +921,19 @@ nm_modem_act_stage1_prepare(NMModem * self, const char * setting_name = NULL; NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; NMConnection * connection; + NMDevice * device; g_return_val_if_fail(NM_IS_ACT_REQUEST(req), NM_ACT_STAGE_RETURN_FAILURE); - if (priv->act_request) - g_object_unref(priv->act_request); - priv->act_request = g_object_ref(req); + nm_g_object_ref_set(&priv->act_req, req); + device = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(priv->act_req)); + g_return_val_if_fail(NM_IS_DEVICE(device), NM_ACT_STAGE_RETURN_FAILURE); connection = nm_act_request_get_applied_connection(req); g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); + nm_g_object_ref_set(&priv->device, device); + setting_name = nm_connection_need_secrets(connection, &hints); if (!setting_name) { nm_assert(!hints); @@ -1015,24 +957,99 @@ nm_modem_act_stage1_prepare(NMModem * self, modem_secrets_cb, self); g_return_val_if_fail(priv->secrets_id, NM_ACT_STAGE_RETURN_FAILURE); - g_signal_emit(self, signals[AUTH_REQUESTED], 0); + nm_modem_emit_auth_requested(self); return NM_ACT_STAGE_RETURN_POSTPONE; } /*****************************************************************************/ -void -nm_modem_act_stage2_config(NMModem *self) +NMActStageReturn +nm_modem_act_stage2_config(NMModem *self, NMDevice *device, NMDeviceStateReason *out_failure_reason) { NMModemPrivate *priv; + gboolean needs_ppp; - g_return_if_fail(NM_IS_MODEM(self)); + g_return_val_if_fail(NM_IS_MODEM(self), NM_ACT_STAGE_RETURN_FAILURE); + g_return_val_if_fail(NM_IS_DEVICE(device), NM_ACT_STAGE_RETURN_FAILURE); priv = NM_MODEM_GET_PRIVATE(self); + + g_return_val_if_fail(priv->device == device, NM_ACT_STAGE_RETURN_FAILURE); + /* Clear secrets tries counter since secrets were successfully used * already if we get here. */ priv->secrets_tries = 0; + + needs_ppp = + (priv->ip4_method == NM_MODEM_IP_METHOD_PPP || priv->ip6_method == NM_MODEM_IP_METHOD_PPP); + + if (needs_ppp && !priv->ppp_mgr) { + const char * ppp_name = NULL; + gs_free_error GError *error = NULL; + guint ip_timeout; + guint baud_override; + NMActRequest * req; + + req = nm_device_get_act_request(device); + g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); + + if (NM_MODEM_GET_CLASS(self)->get_user_pass) { + NMConnection *connection = nm_act_request_get_applied_connection(req); + + g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); + if (!NM_MODEM_GET_CLASS(self)->get_user_pass(self, connection, &ppp_name, NULL)) + return NM_ACT_STAGE_RETURN_FAILURE; + } + + if (!priv->data_port) { + _LOGW("error starting PPP (no data port)"); + NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_PPP_START_FAILED); + return NM_ACT_STAGE_RETURN_FAILURE; + } + + /* Check if ModemManager requested a specific IP timeout to be used. If 0 reported, + * use the default one (30s) */ + if (priv->mm_ip_timeout > 0) { + _LOGI("using modem-specified IP timeout: %u seconds", priv->mm_ip_timeout); + ip_timeout = priv->mm_ip_timeout; + } else + ip_timeout = 30; + + /* Some tty drivers and modems ignore port speed, but pppd requires the + * port speed to be > 0 or it exits. If the port speed is 0 pass an + * explicit speed to pppd to prevent the exit. + * https://bugzilla.redhat.com/show_bug.cgi?id=1281731 + */ + if (port_speed_is_zero(priv->data_port)) + baud_override = 57600; + else + baud_override = 0; + + priv->ppp_mgr = nm_ppp_mgr_start(&((const NMPppMgrConfig){ + .netns = nm_device_get_netns(device), + .parent_iface = priv->data_port, + .callback = _ppp_mgr_callback, + .user_data = self, + .act_req = req, + .ppp_username = ppp_name, + .timeout_secs = ip_timeout, + .baud_override = baud_override, + }), + &error); + if (!priv->ppp_mgr) { + _LOGW("PPP failed to start: %s", error->message); + *out_failure_reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; + return NM_ACT_STAGE_RETURN_FAILURE; + } + + return NM_ACT_STAGE_RETURN_POSTPONE; + } + + if (needs_ppp && nm_ppp_mgr_get_state(priv->ppp_mgr) < NM_PPP_MGR_STATE_HAVE_IFINDEX) + return NM_ACT_STAGE_RETURN_POSTPONE; + + return NM_ACT_STAGE_RETURN_SUCCESS; } /*****************************************************************************/ @@ -1126,27 +1143,26 @@ deactivate_cleanup(NMModem *self, NMDevice *device, gboolean stop_ppp_manager) { NMModemPrivate *priv; int ifindex; + int IS_IPv4; g_return_if_fail(NM_IS_MODEM(self)); priv = NM_MODEM_GET_PRIVATE(self); + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + priv->ip_data_x[IS_IPv4].stage3_started = FALSE; + nm_clear_g_source_inst(&priv->ip_data_x[IS_IPv4].stage3_on_idle_source); + } + priv->secrets_tries = 0; - if (priv->act_request) { + if (priv->act_req) { cancel_get_secrets(self); - g_object_unref(priv->act_request); - priv->act_request = NULL; + g_clear_object(&priv->act_req); } + g_clear_object(&priv->device); - priv->in_bytes = priv->out_bytes = 0; - - if (priv->ppp_manager) { - g_signal_handlers_disconnect_by_data(priv->ppp_manager, self); - if (stop_ppp_manager) - nm_ppp_manager_stop(priv->ppp_manager, NULL, NULL, NULL); - g_clear_object(&priv->ppp_manager); - } + _ppp_mgr_cleanup(self); if (device) { g_return_if_fail(NM_IS_DEVICE(device)); @@ -1170,7 +1186,7 @@ deactivate_cleanup(NMModem *self, NMDevice *device, gboolean stop_ppp_manager) priv->mm_ip_timeout = 0; priv->ip4_method = NM_MODEM_IP_METHOD_UNKNOWN; priv->ip6_method = NM_MODEM_IP_METHOD_UNKNOWN; - _set_ip_ifindex(self, -1, NULL); + _set_ip_ifindex(self, -1); } /*****************************************************************************/ @@ -1307,11 +1323,11 @@ nm_modem_device_state_changed(NMModem *self, NMDeviceState new_state, NMDeviceSt case NM_DEVICE_STATE_UNAVAILABLE: case NM_DEVICE_STATE_FAILED: case NM_DEVICE_STATE_DISCONNECTED: - if (priv->act_request) { + if (priv->act_req) { cancel_get_secrets(self); - g_object_unref(priv->act_request); - priv->act_request = NULL; + g_clear_object(&priv->act_req); } + g_clear_object(&priv->device); if (was_connected) { /* Don't bother warning on FAILED since the modem is already gone */ @@ -1377,19 +1393,14 @@ nm_modem_get_ip_ifindex(NMModem *self) } static void -_set_ip_ifindex(NMModem *self, int ifindex, const char *ifname) +_set_ip_ifindex(NMModem *self, int ifindex) { NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); nm_assert(ifindex >= -1); - nm_assert((ifindex > 0) == !!ifname); - - if (!nm_streq0(priv->ip_iface, ifname)) { - g_free(priv->ip_iface); - priv->ip_iface = g_strdup(ifname); - } if (priv->ip_ifindex != ifindex) { + _LOGD("signal: ifindex changed: %d", ifindex); priv->ip_ifindex = ifindex; _notify(self, PROP_IP_IFINDEX); } @@ -1477,10 +1488,10 @@ nm_modem_set_data_port(NMModem * self, priv->ip6_method = ip6_method; if (is_ppp) { priv->data_port = g_strdup(data_port); - _set_ip_ifindex(self, -1, NULL); + _set_ip_ifindex(self, -1); } else { priv->data_port = NULL; - _set_ip_ifindex(self, ifindex, data_port); + _set_ip_ifindex(self, ifindex); } return TRUE; } @@ -1488,90 +1499,28 @@ nm_modem_set_data_port(NMModem * self, gboolean nm_modem_owns_port(NMModem *self, const char *iface) { - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); + NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); + NMPlatform * platform; + const NMPlatformLink *plink; g_return_val_if_fail(iface != NULL, FALSE); if (NM_MODEM_GET_CLASS(self)->owns_port) return NM_MODEM_GET_CLASS(self)->owns_port(self, iface); - return NM_IN_STRSET(iface, priv->ip_iface, priv->data_port, priv->control_port); -} + if (NM_IN_STRSET(iface, priv->data_port, priv->control_port)) + return TRUE; -gboolean -nm_modem_get_iid(NMModem *self, NMUtilsIPv6IfaceId *out_iid) -{ - g_return_val_if_fail(NM_IS_MODEM(self), FALSE); + /* FIXME(parent-child-relationship): the whole notion of "owns-port" is wrong. + * When we have a name (iface) it must be always clear what this name is (which + * domain). Mixing data_port, control_port and devlink names is wrong. Looking + * up devlinks by name is also wrong (use ifindex). */ + if (priv->ip_ifindex > 0 && (platform = _get_platform(self)) + && (plink = nm_platform_link_get(platform, priv->ip_ifindex)) + && nm_streq(iface, plink->name)) + return TRUE; - *out_iid = NM_MODEM_GET_PRIVATE(self)->iid; - return TRUE; -} - -/*****************************************************************************/ - -void -nm_modem_get_route_parameters(NMModem *self, - guint32 *out_ip4_route_table, - guint32 *out_ip4_route_metric, - guint32 *out_ip6_route_table, - guint32 *out_ip6_route_metric) -{ - NMModemPrivate *priv; - - g_return_if_fail(NM_IS_MODEM(self)); - - priv = NM_MODEM_GET_PRIVATE(self); - NM_SET_OUT(out_ip4_route_table, priv->ip4_route_table); - NM_SET_OUT(out_ip4_route_metric, priv->ip4_route_metric); - NM_SET_OUT(out_ip6_route_table, priv->ip6_route_table); - NM_SET_OUT(out_ip6_route_metric, priv->ip6_route_metric); -} - -void -nm_modem_set_route_parameters(NMModem *self, - guint32 ip4_route_table, - guint32 ip4_route_metric, - guint32 ip6_route_table, - guint32 ip6_route_metric) -{ - NMModemPrivate *priv; - - g_return_if_fail(NM_IS_MODEM(self)); - - priv = NM_MODEM_GET_PRIVATE(self); - if (priv->ip4_route_table != ip4_route_table || priv->ip4_route_metric != ip4_route_metric - || priv->ip6_route_table != ip6_route_table || priv->ip6_route_metric != ip6_route_metric) { - priv->ip4_route_table = ip4_route_table; - priv->ip4_route_metric = ip4_route_metric; - priv->ip6_route_table = ip6_route_table; - priv->ip6_route_metric = ip6_route_metric; - - _LOGT("route-parameters: table-v4: %u, metric-v4: %u, table-v6: %u, metric-v6: %u", - priv->ip4_route_table, - priv->ip4_route_metric, - priv->ip6_route_table, - priv->ip6_route_metric); - } - - if (priv->ppp_manager) { - nm_ppp_manager_set_route_parameters(priv->ppp_manager, - priv->ip4_route_table, - priv->ip4_route_metric, - priv->ip6_route_table, - priv->ip6_route_metric); - } -} - -void -nm_modem_set_route_parameters_from_device(NMModem *self, NMDevice *device) -{ - g_return_if_fail(NM_IS_DEVICE(device)); - - nm_modem_set_route_parameters(self, - nm_device_get_route_table(device, AF_INET), - nm_device_get_route_metric(device, AF_INET), - nm_device_get_route_table(device, AF_INET6), - nm_device_get_route_metric(device, AF_INET6)); + return FALSE; } /*****************************************************************************/ @@ -1593,9 +1542,10 @@ _nm_modem_set_operator_code(NMModem *self, const char *operator_code) { NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); - if (g_strcmp0(priv->operator_code, operator_code) != 0) { + if (!nm_streq0(priv->operator_code, operator_code)) { g_free(priv->operator_code); priv->operator_code = g_strdup(operator_code); + _LOGD("signal: operator-code changed: %s%s%s", NM_PRINT_FMT_QUOTE_STRING(operator_code)); _notify(self, PROP_OPERATOR_CODE); } } @@ -1605,9 +1555,10 @@ _nm_modem_set_apn(NMModem *self, const char *apn) { NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); - if (g_strcmp0(priv->apn, apn) != 0) { + if (!nm_streq0(priv->apn, apn)) { g_free(priv->apn); priv->apn = g_strdup(apn); + _LOGD("signal: apn changed: %s%s%s", NM_PRINT_FMT_QUOTE_STRING(apn)); _notify(self, PROP_APN); } } @@ -1726,11 +1677,7 @@ nm_modem_init(NMModem *self) self->_priv = G_TYPE_INSTANCE_GET_PRIVATE(self, NM_TYPE_MODEM, NMModemPrivate); priv = self->_priv; - priv->ip_ifindex = -1; - priv->ip4_route_table = RT_TABLE_MAIN; - priv->ip4_route_metric = 700; - priv->ip6_route_table = RT_TABLE_MAIN; - priv->ip6_route_metric = 700; + priv->ip_ifindex = -1; } static void @@ -1752,7 +1699,8 @@ dispose(GObject *object) { NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(object); - g_clear_object(&priv->act_request); + g_clear_object(&priv->act_req); + g_clear_object(&priv->device); G_OBJECT_CLASS(nm_modem_parent_class)->dispose(object); } @@ -1767,7 +1715,6 @@ finalize(GObject *object) g_free(priv->driver); g_free(priv->control_port); g_free(priv->data_port); - g_free(priv->ip_iface); g_free(priv->device_id); g_free(priv->sim_id); g_free(priv->sim_operator_id); @@ -1790,9 +1737,8 @@ nm_modem_class_init(NMModemClass *klass) object_class->dispose = dispose; object_class->finalize = finalize; - klass->modem_act_stage1_prepare = modem_act_stage1_prepare; - klass->stage3_ip6_config_request = stage3_ip6_config_request; - klass->deactivate_cleanup = deactivate_cleanup; + klass->modem_act_stage1_prepare = modem_act_stage1_prepare; + klass->deactivate_cleanup = deactivate_cleanup; obj_properties[PROP_UID] = g_param_spec_string(NM_MODEM_UID, @@ -1904,43 +1850,28 @@ nm_modem_class_init(NMModemClass *klass) 1, G_TYPE_UINT); - signals[IP4_CONFIG_RESULT] = g_signal_new(NM_MODEM_IP4_CONFIG_RESULT, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 2, - G_TYPE_OBJECT, - G_TYPE_POINTER); - - /** - * NMModem::ip6-config-result: - * @modem: the #NMModem on which the signal is emitted - * @config: the #NMIP6Config to apply to the modem's data port - * @do_slaac: %TRUE if IPv6 SLAAC should be started - * @error: a #GError if any error occurred during IP configuration - * - * This signal is emitted when IPv6 configuration has completed or failed. - * If @error is set the configuration failed. If @config is set, then + /* + * This signal is emitted when IP configuration has completed or failed. + * If @error is set the configuration failed. If @l3cd is set, then * the details should be applied to the data port before any further - * configuration (like SLAAC) is done. @do_slaac indicates whether SLAAC - * should be started after applying @config to the data port. + * configuration (like SLAAC) is done. @do_auto indicates whether DHCPv4/SLAAC + * should be started after applying @l3cd to the data port. */ - signals[IP6_CONFIG_RESULT] = g_signal_new(NM_MODEM_IP6_CONFIG_RESULT, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 3, - G_TYPE_OBJECT, - G_TYPE_BOOLEAN, - G_TYPE_POINTER); + signals[NEW_CONFIG] = g_signal_new(NM_MODEM_NEW_CONFIG, + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 3, + G_TYPE_INT, /* int addr_family */ + G_TYPE_POINTER, /* const NML3ConfigData *l3cd */ + G_TYPE_BOOLEAN, /* gboolean do_auto */ + G_TYPE_POINTER, /* const NMUtilsIPv6IfaceId *iid */ + G_TYPE_INT, /* NMDeviceStateReason failure_reason */ + G_TYPE_POINTER); /* GError *error */ signals[PREPARE_RESULT] = g_signal_new(NM_MODEM_PREPARE_RESULT, G_OBJECT_CLASS_TYPE(object_class), diff --git a/src/core/devices/wwan/nm-modem.h b/src/core/devices/wwan/nm-modem.h index 4bc81ff8dd..31df805671 100644 --- a/src/core/devices/wwan/nm-modem.h +++ b/src/core/devices/wwan/nm-modem.h @@ -32,15 +32,14 @@ #define NM_MODEM_APN "apn" /* Signals */ -#define NM_MODEM_PPP_STATS "ppp-stats" -#define NM_MODEM_PPP_FAILED "ppp-failed" -#define NM_MODEM_PREPARE_RESULT "prepare-result" -#define NM_MODEM_IP4_CONFIG_RESULT "ip4-config-result" -#define NM_MODEM_IP6_CONFIG_RESULT "ip6-config-result" -#define NM_MODEM_AUTH_REQUESTED "auth-requested" -#define NM_MODEM_AUTH_RESULT "auth-result" -#define NM_MODEM_REMOVED "removed" -#define NM_MODEM_STATE_CHANGED "state-changed" +#define NM_MODEM_PPP_STATS "ppp-stats" +#define NM_MODEM_PPP_FAILED "ppp-failed" +#define NM_MODEM_PREPARE_RESULT "prepare-result" +#define NM_MODEM_NEW_CONFIG "new-config" +#define NM_MODEM_AUTH_REQUESTED "auth-requested" +#define NM_MODEM_AUTH_RESULT "auth-result" +#define NM_MODEM_REMOVED "removed" +#define NM_MODEM_STATE_CHANGED "state-changed" typedef enum { NM_MODEM_IP_METHOD_UNKNOWN = 0, @@ -124,15 +123,7 @@ typedef struct { NMConnection * connection, NMDeviceStateReason *out_failure_reason); - NMActStageReturn (*static_stage3_ip4_config_start)(NMModem * self, - NMActRequest * req, - NMDeviceStateReason *out_failure_reason); - - /* Request the IP6 config; when the config returns the modem - * subclass should emit the ip6_config_result signal. - */ - NMActStageReturn (*stage3_ip6_config_request)(NMModem * self, - NMDeviceStateReason *out_failure_reason); + void (*stage3_ip_config_start)(NMModem *self, int addr_family, NMModemIPMethod method); void (*set_mm_enabled)(NMModem *self, gboolean enabled); @@ -161,7 +152,6 @@ const char *nm_modem_get_driver(NMModem *modem); const char *nm_modem_get_device_id(NMModem *modem); const char *nm_modem_get_sim_id(NMModem *modem); const char *nm_modem_get_sim_operator_id(NMModem *modem); -gboolean nm_modem_get_iid(NMModem *modem, NMUtilsIPv6IfaceId *out_iid); const char *nm_modem_get_operator_code(NMModem *modem); const char *nm_modem_get_apn(NMModem *modem); @@ -188,36 +178,15 @@ gboolean nm_modem_complete_connection(NMModem * self, NMConnection *const *existing_connections, GError ** error); -void nm_modem_get_route_parameters(NMModem *self, - guint32 *out_ip4_route_table, - guint32 *out_ip4_route_metric, - guint32 *out_ip6_route_table, - guint32 *out_ip6_route_metric); - -void nm_modem_set_route_parameters(NMModem *self, - guint32 ip4_route_table, - guint32 ip4_route_metric, - guint32 ip6_route_table, - guint32 ip6_route_metric); - -void nm_modem_set_route_parameters_from_device(NMModem *modem, NMDevice *device); - NMActStageReturn nm_modem_act_stage1_prepare(NMModem * modem, NMActRequest * req, NMDeviceStateReason *out_failure_reason); -void nm_modem_act_stage2_config(NMModem *modem); +NMActStageReturn nm_modem_act_stage2_config(NMModem * self, + NMDevice * device, + NMDeviceStateReason *out_failure_reason); -NMActStageReturn nm_modem_stage3_ip4_config_start(NMModem * modem, - NMDevice * device, - gboolean * out_autoip4, - NMDeviceStateReason *out_failure_reason); - -NMActStageReturn nm_modem_stage3_ip6_config_start(NMModem * modem, - NMDevice * device, - NMDeviceStateReason *out_failure_reason); - -void nm_modem_ip4_pre_commit(NMModem *modem, NMDevice *device, NMIP4Config *config); +gboolean nm_modem_stage3_ip_config_start(NMModem *self, int addr_family, NMDevice *device); void nm_modem_get_secrets(NMModem * modem, const char *setting_name, @@ -249,6 +218,8 @@ NMModemIPType nm_modem_get_supported_ip_types(NMModem *self); /* For the modem-manager only */ void nm_modem_emit_removed(NMModem *self); +void nm_modem_emit_auth_requested(NMModem *self); + void nm_modem_emit_prepare_result(NMModem *self, gboolean success, NMDeviceStateReason reason); void nm_modem_emit_ppp_failed(NMModem *self, NMDeviceStateReason reason); @@ -256,7 +227,23 @@ void nm_modem_emit_ppp_failed(NMModem *self, NMDeviceStateReason reason); GArray *nm_modem_get_connection_ip_type(NMModem *self, NMConnection *connection, GError **error); /* For subclasses */ -void nm_modem_emit_ip6_config_result(NMModem *self, NMIP6Config *config, GError *error); + +void nm_modem_emit_signal_new_config(NMModem * self, + int addr_family, + const NML3ConfigData * l3cd, + gboolean do_slaac, + const NMUtilsIPv6IfaceId *iid, + NMDeviceStateReason failure_reason, + GError * error); +void nm_modem_emit_signal_new_config_success(NMModem * self, + int addr_family, + const NML3ConfigData * l3cd, + gboolean do_auto, + const NMUtilsIPv6IfaceId *iid); +void nm_modem_emit_signal_new_config_failure(NMModem * self, + int addr_family, + NMDeviceStateReason failure_reason, + GError * error); const char *nm_modem_ip_type_to_string(NMModemIPType ip_type); diff --git a/src/core/dhcp/README.next.md b/src/core/dhcp/README.next.md new file mode 100644 index 0000000000..88fa6683c7 --- /dev/null +++ b/src/core/dhcp/README.next.md @@ -0,0 +1,103 @@ +`NMDhcpClient` +============== + +Using `NMDhcpClient` still requires a lot of logic in `NMDevice`. The main goal +is to simplify `NMDevice`, so `NMDhcpClient` must become more complicated to +provide a simpler (but robust) API. + +NMDevice has basically two timeouts (talking about IPv4, but it applies +similarly to IPv6): `ipv4.dhcp-timeout` and `ipv4.required-timeout`. They +control how long NMDevice is willing to try, before failing the activation +altogether. Note that with `ipv4.may-fail=yes`, we may very well never want to +fail the activation entirely, regardless how DHCP is doing. In that case we +want to stay up, but also constantly retrying whether we cannot get a lease and +recover. + +Currently, if `NMDhcpClient` signals a failure, then it's basically up to +`NMDevice` to schedule and retry. That is complicated, and we should move the +complexity out of `NMDevice`. + +`NMDhcpClient` should have a simpler API: + +- `nm_dhcp_manager_start_ip[46]()`: creates (and starts) a `NMDhcpClient` + instance. The difference is, this function tries really hard not to fail + to create an `NMDhcpClient`. There is no explicit `start()`, but note that the + instance must not emit any signals before the next maincontext iteration. That is, + it only will call back the user after a timeout/idle or some other IO event, which + happens during a future iteration of the maincontext. + +- `nm_dhcp_client_stop()`: when `NMDevice` is done with the `NMDhcpClient` + instance, it will stop it and throw it away. This method exists because + `NMDhcpClient` is a `GObject` and ref-counted. Thus, we don't want to rely on + the last unref to stop the instance, but have an explicit stop. After stop, the + instance is defunct and won't emit any signals anymore. The class does not need + to support restarting a stopped instance. If `NMDevice` wants to restart DHCP, it + should create a new one. `NMDevice` would only want to do that, if the parameters + change, hence a new instance is in order (and no need for the complexity of + restart in `NMDhcpClient`). + +- as already now, `NMDhcpClient` is not very configurable. You provide most + (all) parameters during `nm_dhcp_manager_start_ip[46]()`, and then it keeps + running until stop. + +- `NMDhcpClient` exposes a simple state to the user: + + 1. "no lease, but good". When starting, there is no lease, but we are + optimistic to get one. This is the inital state, but we can also get back to + this state after we had a lease (which might expire). + + 1. "has a lease". Here there is no need to distinguish whether the current + lease was the first we received, or whether this was an update. In this state, + the instance has a lease and we are good. + + 1. "no lease, but bad". `NMDhcpClient` tries really hard, and "bad" does not + mean that it gave up. It will keep retrying, it's just that there is little + hope of getting a new lease. This happens, when you try to run DHCP on a Layer3 + link (WireGuard). There is little hope to succeed, but `NMDhcpClient` + (theoretically) will retry and may recover from this. Another example is when + we fail to start dhclient because it's not installed. In that case, we are not + optimistic to recover, however `NMDhcpDhclient` will retry (with backoff + timeout) and might still recover from this. For most cases, `NMDevice` will + treat the no-lease cases the same, but in case of "bad" it might give up + earlier. + +When a lease expires, that does not necessarily mean that we are now in a bad +state. It might mean that the DHCP server is temporarily down, but we might +recover from that easily. "bad" really means, something is wrong on our side +which prevents us from getting a lease. Also, imagine `dhclient` dies (we would +try to restart, but assume that fails too), but we still have a valid lease, +then possibly `NMDhcpClient` should still pretend all is good and we still have +a lease until it expires. It may be we can recover before that happens. The +point of all of this, is to hide errors as much as possibly and automatically +recover. `NMDevice` will decide to tear down, if we didn't get a lease after +`ipv4.dhcp-timeout`. That's the main criteria, and it might not even +distinguish between "no lease, but good" and "no lease, but bad". + +- `NMDhcpClient` will also take care of the `ipv4.dhcp-timeout` grace period. + That timeout is provided during start, and starts ticking whenever there is + no lease. When it expires, a timeout signal gets emitted. That's it. This is + independent from the 3 states above, and only saves `NMDevice` from scheduling + this timer themselves. + This is NM_DHCP_CLIENT_NOTIFY_TYPE_NO_LEASE_TIMEOUT notification. + +- for nettools, `nm_dhcp_client_can_accept()` indicates that when we receive a + lease, we need to accept/decline it first. In that case, `NMDevice` +optionally does ACD first, then configures the IP address first and calls +`nm_dhcp_client_accept()`. In case of ACD conflict, it will call +`nm_dhcp_client_decline()` (which optimally causes `NMDhcpClient` to get a +different lease). With this, the above state "has a lease" has actually three +flavors: "has a lease but not yet ACD probed" and "has a lease but +accepted/declined" (but `NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED` gets only emitted +when we get the lease, not when we accept/decline it). With `dhclient`, when we +receive a lease, it means "has a lease but accepted" right away. + +- for IPv6 prefix delegation, there is also `needed_prefixes` and + `NM_DHCP_CLIENT_NOTIFY_TYPE_PREFIX_DELEGATED`. Currently `needed_prefixes` needs + to be specified during start (which simplifies things). Maybe `needed_prefixes` + should be changable at runtime. Otherwise, whether we have prefixes is similar + to whether we have a lease, and the simple 3 states apply. + +When NetworkManager quits, it may want to leave the interface up. In that case, +we still always want to stop the DHCP client, but possibly not deconfiguring +the interface. I don't think that this concerns `NMDhcpClient`, because `NMDhcpClient` +only provides the lease information and `NMDevice` is responsible to configure it. diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index f88c79c0be..8b9e724968 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -20,9 +20,13 @@ #include "NetworkManagerUtils.h" #include "nm-utils.h" +#include "nm-l3cfg.h" +#include "nm-l3-config-data.h" #include "nm-dhcp-utils.h" #include "nm-dhcp-options.h" #include "libnm-platform/nm-platform.h" +#include "nm-hostname-manager.h" +#include "libnm-systemd-shared/nm-sd-utils-shared.h" #include "nm-dhcp-client-logging.h" @@ -32,53 +36,20 @@ enum { SIGNAL_NOTIFY, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = {0}; -NM_GOBJECT_PROPERTIES_DEFINE(NMDhcpClient, - PROP_ADDR_FAMILY, - PROP_ANYCAST_ADDRESS, - PROP_FLAGS, - PROP_HWADDR, - PROP_BROADCAST_HWADDR, - PROP_IFACE, - PROP_IFINDEX, - PROP_MULTI_IDX, - PROP_ROUTE_METRIC, - PROP_ROUTE_TABLE, - PROP_TIMEOUT, - PROP_UUID, - PROP_IAID, - PROP_IAID_EXPLICIT, - PROP_HOSTNAME, - PROP_HOSTNAME_FLAGS, - PROP_MUD_URL, - PROP_VENDOR_CLASS_IDENTIFIER, - PROP_REJECT_SERVERS, ); +NM_GOBJECT_PROPERTIES_DEFINE(NMDhcpClient, PROP_CONFIG, ); typedef struct _NMDhcpClientPrivate { - NMDedupMultiIndex * multi_idx; - char * iface; - GBytes * hwaddr; - GBytes * bcast_hwaddr; - char * uuid; - GBytes * client_id; - char * hostname; - const char ** reject_servers; - char * mud_url; - char * anycast_address; - GBytes * vendor_class_identifier; - pid_t pid; - guint timeout_id; - guint watch_id; - int addr_family; - int ifindex; - guint32 route_table; - guint32 route_metric; - guint32 timeout; - guint32 iaid; - NMDhcpState state; - NMDhcpHostnameFlags hostname_flags; - NMDhcpClientFlags client_flags; - bool iaid_explicit : 1; - bool is_stopped : 1; + NMDhcpClientConfig config; + const NML3ConfigData *l3cd; + GSource * no_lease_timeout_source; + GSource * ipv6_lladdr_timeout_source; + pid_t pid; + guint timeout_id; + guint watch_id; + NMDhcpState state; + bool iaid_explicit : 1; + bool is_stopped : 1; + GBytes * effective_client_id; } NMDhcpClientPrivate; G_DEFINE_ABSTRACT_TYPE(NMDhcpClient, nm_dhcp_client, G_TYPE_OBJECT) @@ -98,25 +69,6 @@ _emit_notify(NMDhcpClient *self, const NMDhcpClientNotifyData *notify_data) g_signal_emit(G_OBJECT(self), signals[SIGNAL_NOTIFY], 0, notify_data); } -static void -_emit_notify_state_changed(NMDhcpClient *self, - NMDhcpState dhcp_state, - NMIPConfig * ip_config, - GHashTable * options) -{ - const NMDhcpClientNotifyData notify_data = { - .notify_type = NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED, - .state_changed = - { - .dhcp_state = dhcp_state, - .ip_config = ip_config, - .options = options, - }, - }; - - _emit_notify(self, ¬ify_data); -} - /*****************************************************************************/ pid_t @@ -127,149 +79,24 @@ nm_dhcp_client_get_pid(NMDhcpClient *self) return NM_DHCP_CLIENT_GET_PRIVATE(self)->pid; } -NMDedupMultiIndex * -nm_dhcp_client_get_multi_idx(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->multi_idx; -} - -const char * -nm_dhcp_client_get_iface(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->iface; -} - -int -nm_dhcp_client_get_ifindex(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), -1); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->ifindex; -} - -int -nm_dhcp_client_get_addr_family(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), AF_UNSPEC); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->addr_family; -} - -const char * -nm_dhcp_client_get_uuid(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->uuid; -} - -GBytes * -nm_dhcp_client_get_hw_addr(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->hwaddr; -} - -GBytes * -nm_dhcp_client_get_broadcast_hw_addr(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->bcast_hwaddr; -} - -guint32 -nm_dhcp_client_get_route_table(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), RT_TABLE_MAIN); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->route_table; -} - -void -nm_dhcp_client_set_route_table(NMDhcpClient *self, guint32 route_table) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - - if (route_table != priv->route_table) { - priv->route_table = route_table; - _notify(self, PROP_ROUTE_TABLE); - } -} - -guint32 -nm_dhcp_client_get_route_metric(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), G_MAXUINT32); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->route_metric; -} - -void -nm_dhcp_client_set_route_metric(NMDhcpClient *self, guint32 route_metric) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - - if (route_metric != priv->route_metric) { - priv->route_metric = route_metric; - _notify(self, PROP_ROUTE_METRIC); - } -} - -guint32 -nm_dhcp_client_get_timeout(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), 0); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->timeout; -} - -guint32 -nm_dhcp_client_get_iaid(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), 0); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->iaid; -} - -gboolean -nm_dhcp_client_get_iaid_explicit(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->iaid_explicit; -} - -GBytes * -nm_dhcp_client_get_client_id(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->client_id; -} - static void -_set_client_id(NMDhcpClient *self, GBytes *client_id, gboolean take) +_set_effective_client_id(NMDhcpClient *self, GBytes *client_id, gboolean take) { NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); nm_assert(!client_id || g_bytes_get_size(client_id) >= 2); - if (priv->client_id == client_id - || (priv->client_id && client_id && g_bytes_equal(priv->client_id, client_id))) { + if (priv->effective_client_id == client_id + || (priv->effective_client_id && client_id + && g_bytes_equal(priv->effective_client_id, client_id))) { if (take && client_id) g_bytes_unref(client_id); return; } - if (priv->client_id) - g_bytes_unref(priv->client_id); - priv->client_id = client_id; + if (priv->effective_client_id) + g_bytes_unref(priv->effective_client_id); + priv->effective_client_id = client_id; if (!take && client_id) g_bytes_ref(client_id); @@ -277,94 +104,20 @@ _set_client_id(NMDhcpClient *self, GBytes *client_id, gboolean take) gs_free char *s = NULL; _LOGT("%s: set %s", - nm_dhcp_client_get_addr_family(self) == AF_INET6 ? "duid" : "client-id", - priv->client_id ? (s = nm_dhcp_utils_duid_to_string(priv->client_id)) : "default"); + priv->config.addr_family == AF_INET6 ? "duid" : "client-id", + priv->effective_client_id + ? (s = nm_dhcp_utils_duid_to_string(priv->effective_client_id)) + : "default"); } } void -nm_dhcp_client_set_client_id(NMDhcpClient *self, GBytes *client_id) +nm_dhcp_client_set_effective_client_id(NMDhcpClient *self, GBytes *client_id) { g_return_if_fail(NM_IS_DHCP_CLIENT(self)); g_return_if_fail(!client_id || g_bytes_get_size(client_id) >= 2); - _set_client_id(self, client_id, FALSE); -} - -void -nm_dhcp_client_set_client_id_bin(NMDhcpClient *self, - guint8 type, - const guint8 *client_id, - gsize len) -{ - guint8 *buf; - GBytes *b; - - g_return_if_fail(NM_IS_DHCP_CLIENT(self)); - g_return_if_fail(client_id); - g_return_if_fail(len > 0); - - buf = g_malloc(len + 1); - buf[0] = type; - memcpy(buf + 1, client_id, len); - b = g_bytes_new_take(buf, len + 1); - _set_client_id(self, b, TRUE); -} - -const char * -nm_dhcp_client_get_anycast_address(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->anycast_address; -} - -const char * -nm_dhcp_client_get_hostname(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->hostname; -} - -NMDhcpHostnameFlags -nm_dhcp_client_get_hostname_flags(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NM_DHCP_HOSTNAME_FLAG_NONE); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->hostname_flags; -} - -NMDhcpClientFlags -nm_dhcp_client_get_client_flags(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NM_DHCP_CLIENT_FLAGS_NONE); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->client_flags; -} - -const char * -nm_dhcp_client_get_mud_url(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->mud_url; -} - -GBytes * -nm_dhcp_client_get_vendor_class_identifier(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE(self)->vendor_class_identifier; -} - -const char *const * -nm_dhcp_client_get_reject_servers(NMDhcpClient *self) -{ - g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NULL); - - return (const char *const *) NM_DHCP_CLIENT_GET_PRIVATE(self)->reject_servers; + _set_effective_client_id(self, client_id, FALSE); } /*****************************************************************************/ @@ -457,78 +210,159 @@ stop(NMDhcpClient *self, gboolean release) if (priv->pid > 0) { /* Clean up the watch handler since we're explicitly killing the daemon */ watch_cleanup(self); - nm_dhcp_client_stop_pid(priv->pid, priv->iface); + nm_dhcp_client_stop_pid(priv->pid, priv->config.iface); } priv->pid = -1; } -void -nm_dhcp_client_set_state(NMDhcpClient *self, - NMDhcpState new_state, - NMIPConfig * ip_config, - GHashTable * options) +static gboolean +_no_lease_timeout(gpointer user_data) +{ + NMDhcpClient * self = user_data; + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + nm_clear_g_source_inst(&priv->no_lease_timeout_source); + + _emit_notify(self, + &((NMDhcpClientNotifyData){ + .notify_type = NM_DHCP_CLIENT_NOTIFY_TYPE_NO_LEASE_TIMEOUT, + })); + return G_SOURCE_CONTINUE; +} + +const NMDhcpClientConfig * +nm_dhcp_client_get_config(NMDhcpClient *self) { NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + return &priv->config; +} + +void +nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3ConfigData *l3cd) +{ + NMDhcpClientPrivate * priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + GHashTable * options; + const int IS_IPv4 = NM_IS_IPv4(priv->config.addr_family); + nm_auto_unref_l3cd const NML3ConfigData *l3cd_merged = NULL; + + g_return_if_fail(NM_IS_DHCP_CLIENT(self)); + if (NM_IN_SET(new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) { - g_return_if_fail(NM_IS_IP_CONFIG_ADDR_FAMILY(ip_config, priv->addr_family)); - g_return_if_fail(options); - } else { - g_return_if_fail(!ip_config); - g_return_if_fail(!options); - } + g_return_if_fail(NM_IS_L3_CONFIG_DATA(l3cd)); + g_return_if_fail(nm_l3_config_data_get_dhcp_lease(l3cd, priv->config.addr_family)); + } else + g_return_if_fail(!l3cd); + + if (l3cd) + nm_l3_config_data_seal(l3cd); if (new_state >= NM_DHCP_STATE_BOUND) timeout_cleanup(self); if (new_state >= NM_DHCP_STATE_TIMEOUT) watch_cleanup(self); - /* The client may send same-state transitions for RENEW/REBIND events and - * the lease may have changed, so handle same-state transitions for the - * EXTENDED and BOUND states. Ignore same-state transitions for other - * events since the lease won't have changed and the state was already handled. - */ - if ((priv->state == new_state) - && !NM_IN_SET(new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) - return; - - if (_LOGD_ENABLED()) { - gs_free const char **keys = NULL; - guint i, nkeys; - - keys = nm_strdict_get_keys(options, TRUE, &nkeys); - for (i = 0; i < nkeys; i++) { - _LOGD("option %-20s => '%s'", keys[i], (char *) g_hash_table_lookup(options, keys[i])); + if (!IS_IPv4 && l3cd) { + if (nm_dhcp_utils_merge_new_dhcp6_lease(priv->l3cd, l3cd, &l3cd_merged)) { + l3cd = nm_l3_config_data_seal(l3cd_merged); } } - if (_LOGT_ENABLED() && priv->addr_family == AF_INET6) { - gs_free char *event_id = NULL; + if (priv->l3cd == l3cd) + return; - event_id = nm_dhcp_utils_get_dhcp6_event_id(options); - if (event_id) - _LOGT("event-id: \"%s\"", event_id); + if (l3cd) + nm_clear_g_source_inst(&priv->no_lease_timeout_source); + else { + /* FIXME(l3cfg:dhcp): we also need to start no_lease_timeout initially, if the + * instance starts without a previous_lease. */ + if (!priv->no_lease_timeout_source && priv->l3cd) { + if (priv->config.timeout == NM_DHCP_TIMEOUT_INFINITY) + priv->no_lease_timeout_source = g_source_ref(nm_g_source_sentinel_get(0)); + else { + priv->no_lease_timeout_source = + nm_g_timeout_add_seconds_source(priv->config.timeout, _no_lease_timeout, self); + } + } + } + + /* FIXME(l3cfg:dhcp): the API of NMDhcpClient is changing to expose a simpler API. + * The internals like NMDhcpState should not be exposed (or possibly dropped in large + * parts). */ + + nm_l3_config_data_reset(&priv->l3cd, l3cd); + + options = l3cd ? nm_dhcp_lease_get_options( + nm_l3_config_data_get_dhcp_lease(l3cd, priv->config.addr_family)) + : NULL; + + if (_LOGD_ENABLED()) { + if (options) { + gs_free const char **keys = NULL; + guint nkeys; + guint i; + + keys = nm_strdict_get_keys(options, TRUE, &nkeys); + for (i = 0; i < nkeys; i++) { + _LOGD("option %-20s => '%s'", + keys[i], + (char *) g_hash_table_lookup(options, keys[i])); + } + + if (priv->config.addr_family == AF_INET6) { + gs_free char *event_id = NULL; + + event_id = nm_dhcp_utils_get_dhcp6_event_id(options); + if (event_id) + _LOGT("event-id: \"%s\"", event_id); + } + } } if (_LOGI_ENABLED()) { const char *req_str = - NM_IS_IPv4(priv->addr_family) - ? nm_dhcp_option_request_string(AF_INET, NM_DHCP_OPTION_DHCP4_NM_IP_ADDRESS) - : nm_dhcp_option_request_string(AF_INET6, NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS); + IS_IPv4 ? nm_dhcp_option_request_string(AF_INET, NM_DHCP_OPTION_DHCP4_NM_IP_ADDRESS) + : nm_dhcp_option_request_string(AF_INET6, NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS); const char *addr = nm_g_hash_table_lookup(options, req_str); - _LOGI("state changed %s -> %s%s%s%s", - nm_dhcp_state_to_string(priv->state), - nm_dhcp_state_to_string(new_state), + _LOGI("state changed %s%s%s%s", + priv->l3cd ? "new lease" : "no lease", NM_PRINT_FMT_QUOTED(addr, ", address=", addr, "", "")); } - priv->state = new_state; + /* FIXME(l3cfg:dhcp:acd): NMDhcpClient must also do ACD. It needs acd_timeout_msec + * as a configuration parameter (in NMDhcpClientConfig). When ACD is enabled, + * when a new lease gets announced, it must first use NML3Cfg to run ACD on the + * interface (the previous lease -- if any -- will still be used at that point). + * If ACD fails, we call nm_dhcp_client_decline() and try to get a different + * lease. + * If ACD passes, we need to notify the new lease, and the user (NMDevice) may + * then configure the address. We need to watch the configured addresses (in NML3Cfg), + * and if the address appears there, we need to accept the lease. That is complicated + * but necessary, because we can only accept the lease after we configured the + * address. + * + * As a whole, ACD is transparent for the user (NMDevice). It's entirely managed + * by NMDhcpClient. Note that we do ACD through NML3Cfg, which centralizes IP handling + * for one interface, so for example if the same address happens to be configured + * as a static address (bypassing ACD), then NML3Cfg is aware of that and signals + * immediate success. */ - _emit_notify_state_changed(self, new_state, ip_config, options); + { + const NMDhcpClientNotifyData notify_data = { + .notify_type = NM_DHCP_CLIENT_NOTIFY_TYPE_LEASE_UPDATE, + .lease_update = + { + .l3cd = priv->l3cd, + }, + }; + + _emit_notify(self, ¬ify_data); + } } -static gboolean +/* FIXME(l3cfg:dhcp) */ +_nm_unused static gboolean transaction_timeout(gpointer user_data) { NMDhcpClient * self = NM_DHCP_CLIENT(user_data); @@ -536,7 +370,7 @@ transaction_timeout(gpointer user_data) priv->timeout_id = 0; _LOGW("request timed out"); - nm_dhcp_client_set_state(self, NM_DHCP_STATE_TIMEOUT, NULL, NULL); + nm_dhcp_client_set_state(self, NM_DHCP_STATE_TIMEOUT, NULL); return G_SOURCE_REMOVE; } @@ -554,7 +388,7 @@ daemon_watch_cb(GPid pid, int status, gpointer user_data) priv->pid = -1; - nm_dhcp_client_set_state(self, NM_DHCP_STATE_TERMINATED, NULL, NULL); + nm_dhcp_client_set_state(self, NM_DHCP_STATE_TERMINATED, NULL); } void @@ -566,10 +400,10 @@ nm_dhcp_client_start_timeout(NMDhcpClient *self) /* Set up a timeout on the transaction to kill it after the timeout */ - if (priv->timeout == NM_DHCP_TIMEOUT_INFINITY) - return; - - priv->timeout_id = g_timeout_add_seconds(priv->timeout, transaction_timeout, self); + /* FIXME(l3cfg:dhcp): no-lease-timeout is only for convenience for the user (NMDevice). + * Whatever the purpose of nm_dhcp_client_start_timeout() is, it is not the same timer. */ + return; + //priv->timeout_id = g_timeout_add_seconds(priv->no_lease_timeout, transaction_timeout, self); } void @@ -599,10 +433,7 @@ nm_dhcp_client_stop_watch_child(NMDhcpClient *self, pid_t pid) } gboolean -nm_dhcp_client_start_ip4(NMDhcpClient *self, - GBytes * client_id, - const char * last_ip4_address, - GError ** error) +nm_dhcp_client_start_ip4(NMDhcpClient *self, GError **error) { NMDhcpClientPrivate *priv; @@ -610,24 +441,29 @@ nm_dhcp_client_start_ip4(NMDhcpClient *self, priv = NM_DHCP_CLIENT_GET_PRIVATE(self); g_return_val_if_fail(priv->pid == -1, FALSE); - g_return_val_if_fail(priv->addr_family == AF_INET, FALSE); - g_return_val_if_fail(priv->uuid != NULL, FALSE); + g_return_val_if_fail(priv->config.addr_family == AF_INET, FALSE); + g_return_val_if_fail(priv->config.uuid, FALSE); - if (priv->timeout == NM_DHCP_TIMEOUT_INFINITY) + if (priv->config.timeout == NM_DHCP_TIMEOUT_INFINITY) _LOGI("activation: beginning transaction (no timeout)"); else - _LOGI("activation: beginning transaction (timeout in %u seconds)", (guint) priv->timeout); + _LOGI("activation: beginning transaction (timeout in %u seconds)", + (guint) priv->config.timeout); - nm_dhcp_client_set_client_id(self, client_id); - - return NM_DHCP_CLIENT_GET_CLASS(self)->ip4_start(self, last_ip4_address, error); + return NM_DHCP_CLIENT_GET_CLASS(self)->ip4_start(self, error); } gboolean nm_dhcp_client_accept(NMDhcpClient *self, GError **error) { + NMDhcpClientPrivate *priv; + g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE); + priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + g_return_val_if_fail(priv->l3cd, FALSE); + if (NM_DHCP_CLIENT_GET_CLASS(self)->accept) { return NM_DHCP_CLIENT_GET_CLASS(self)->accept(self, error); } @@ -652,8 +488,14 @@ nm_dhcp_client_can_accept(NMDhcpClient *self) gboolean nm_dhcp_client_decline(NMDhcpClient *self, const char *error_message, GError **error) { + NMDhcpClientPrivate *priv; + g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE); + priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + g_return_val_if_fail(priv->l3cd, FALSE); + if (NM_DHCP_CLIENT_GET_CLASS(self)->decline) { return NM_DHCP_CLIENT_GET_CLASS(self)->decline(self, error_message, error); } @@ -667,43 +509,115 @@ get_duid(NMDhcpClient *self) return NULL; } +static gboolean +ipv6_lladdr_timeout(gpointer user_data) +{ + NMDhcpClient * self = user_data; + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + nm_clear_g_source_inst(&priv->ipv6_lladdr_timeout_source); + + _emit_notify( + self, + &((NMDhcpClientNotifyData){ + .notify_type = NM_DHCP_CLIENT_NOTIFY_TYPE_IT_LOOKS_BAD, + .it_looks_bad.reason = "timeout reached while waiting for an IPv6 link-local address", + })); + return G_SOURCE_CONTINUE; +} + +static const NMPlatformIP6Address * +ipv6_lladdr_find(NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + NML3Cfg * l3cfg; + NMPLookup lookup; + NMDedupMultiIter iter; + const NMPObject * obj; + + l3cfg = priv->config.l3cfg; + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP6_ADDRESS, nm_l3cfg_get_ifindex(l3cfg)); + + nm_platform_iter_obj_for_each (&iter, nm_l3cfg_get_platform(l3cfg), &lookup, &obj) { + const NMPlatformIP6Address *pladdr = NMP_OBJECT_CAST_IP6_ADDRESS(obj); + + if (!IN6_IS_ADDR_LINKLOCAL(&pladdr->address)) + continue; + if (NM_FLAGS_HAS(pladdr->n_ifa_flags, IFA_F_TENTATIVE) + && !NM_FLAGS_HAS(pladdr->n_ifa_flags, IFA_F_OPTIMISTIC)) + continue; + return pladdr; + } + return NULL; +} + +static void +l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + nm_assert(l3cfg == priv->config.l3cfg); + + if (notify_data->notify_type == NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE) { + const NMPlatformIP6Address *addr; + gs_free_error GError *error = NULL; + + addr = ipv6_lladdr_find(self); + if (addr) { + _LOGD("got IPv6LL address, starting transaction"); + g_signal_handlers_disconnect_by_func(l3cfg, l3_cfg_notify_cb, self); + nm_clear_g_source_inst(&priv->ipv6_lladdr_timeout_source); + + if (!NM_DHCP_CLIENT_GET_CLASS(self)->ip6_start(self, &addr->address, &error)) { + _emit_notify(self, + &((NMDhcpClientNotifyData){ + .notify_type = NM_DHCP_CLIENT_NOTIFY_TYPE_IT_LOOKS_BAD, + .it_looks_bad.reason = error->message, + })); + } + } + } +} + gboolean -nm_dhcp_client_start_ip6(NMDhcpClient * self, - GBytes * client_id, - gboolean enforce_duid, - const struct in6_addr * ll_addr, - NMSettingIP6ConfigPrivacy privacy, - guint needed_prefixes, - GError ** error) +nm_dhcp_client_start_ip6(NMDhcpClient *self, GError **error) { NMDhcpClientPrivate *priv; - gs_unref_bytes GBytes *own_client_id = NULL; + gs_unref_bytes GBytes * own_client_id = NULL; + const NMPlatformIP6Address *addr; g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE); - g_return_val_if_fail(client_id, FALSE); - priv = NM_DHCP_CLIENT_GET_PRIVATE(self); g_return_val_if_fail(priv->pid == -1, FALSE); - g_return_val_if_fail(priv->addr_family == AF_INET6, FALSE); - g_return_val_if_fail(priv->uuid != NULL, FALSE); - g_return_val_if_fail(!priv->client_id, FALSE); + g_return_val_if_fail(priv->config.addr_family == AF_INET6, FALSE); + g_return_val_if_fail(priv->config.uuid, FALSE); + g_return_val_if_fail(!priv->effective_client_id, FALSE); - if (!enforce_duid) + if (!priv->config.v6.enforce_duid) own_client_id = NM_DHCP_CLIENT_GET_CLASS(self)->get_duid(self); - _set_client_id(self, own_client_id ?: client_id, FALSE); + _set_effective_client_id(self, own_client_id ?: priv->config.client_id, FALSE); - if (priv->timeout == NM_DHCP_TIMEOUT_INFINITY) + if (priv->config.timeout == NM_DHCP_TIMEOUT_INFINITY) _LOGI("activation: beginning transaction (no timeout)"); else - _LOGI("activation: beginning transaction (timeout in %u seconds)", (guint) priv->timeout); + _LOGI("activation: beginning transaction (timeout in %u seconds)", + (guint) priv->config.timeout); - return NM_DHCP_CLIENT_GET_CLASS(self)->ip6_start(self, - ll_addr, - privacy, - needed_prefixes, - error); + addr = ipv6_lladdr_find(self); + if (!addr) { + _LOGD("waiting for IPv6LL address"); + g_signal_connect(priv->config.l3cfg, + NM_L3CFG_SIGNAL_NOTIFY, + G_CALLBACK(l3_cfg_notify_cb), + self); + priv->ipv6_lladdr_timeout_source = + nm_g_timeout_add_seconds_source(10, ipv6_lladdr_timeout, self); + return TRUE; + } + + return NM_DHCP_CLIENT_GET_CLASS(self)->ip6_start(self, &addr->address, error); } void @@ -780,6 +694,8 @@ nm_dhcp_client_stop(NMDhcpClient *self, gboolean release) priv->is_stopped = TRUE; + g_signal_handlers_disconnect_by_func(priv->config.l3cfg, l3_cfg_notify_cb, self); + /* Kill the DHCP client */ old_pid = priv->pid; NM_DHCP_CLIENT_GET_CLASS(self)->stop(self, release); @@ -789,7 +705,7 @@ nm_dhcp_client_stop(NMDhcpClient *self, gboolean release) _LOGI("canceled DHCP transaction"); nm_assert(priv->pid == -1); - nm_dhcp_client_set_state(self, NM_DHCP_STATE_TERMINATED, NULL, NULL); + nm_dhcp_client_set_state(self, NM_DHCP_STATE_TERMINATED, NULL); } /*****************************************************************************/ @@ -921,12 +837,10 @@ nm_dhcp_client_handle_event(gpointer unused, const char * reason, NMDhcpClient *self) { - NMDhcpClientPrivate *priv; - guint32 old_state; - guint32 new_state; - gs_unref_hashtable GHashTable *str_options = NULL; - gs_unref_object NMIPConfig *ip_config = NULL; - NMPlatformIP6Address prefix = { + NMDhcpClientPrivate * priv; + guint32 new_state; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + NMPlatformIP6Address prefix = { 0, }; @@ -938,25 +852,26 @@ nm_dhcp_client_handle_event(gpointer unused, priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - if (g_strcmp0(priv->iface, iface) != 0) + if (!nm_streq0(priv->config.iface, iface)) return FALSE; if (priv->pid != pid) return FALSE; - old_state = priv->state; - new_state = reason_to_state(self, priv->iface, reason); - _LOGD("DHCP state '%s' -> '%s' (reason: '%s')", - nm_dhcp_state_to_string(old_state), - nm_dhcp_state_to_string(new_state), - reason); - + new_state = reason_to_state(self, priv->config.iface, reason); if (new_state == NM_DHCP_STATE_NOOP) return TRUE; + _LOGD("DHCP state '%s' -> '%s' (reason: '%s')", + nm_dhcp_state_to_string(priv->state), + nm_dhcp_state_to_string(new_state), + reason); + priv->state = new_state; + if (NM_IN_SET(new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) { - GVariantIter iter; - const char * name; - GVariant * value; + gs_unref_hashtable GHashTable *str_options = NULL; + GVariantIter iter; + const char * name; + GVariant * value; /* Copy options */ str_options = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); @@ -968,25 +883,29 @@ nm_dhcp_client_handle_event(gpointer unused, /* Create the IP config */ if (g_hash_table_size(str_options) > 0) { - if (priv->addr_family == AF_INET) { - ip_config = NM_IP_CONFIG_CAST( - nm_dhcp_utils_ip4_config_from_options(nm_dhcp_client_get_multi_idx(self), - priv->ifindex, - priv->iface, - str_options, - priv->route_table, - priv->route_metric)); + if (priv->config.addr_family == AF_INET) { + l3cd = nm_dhcp_utils_ip4_config_from_options( + nm_l3cfg_get_multi_idx(priv->config.l3cfg), + nm_l3cfg_get_ifindex(priv->config.l3cfg), + priv->config.iface, + str_options); } else { - prefix = nm_dhcp_utils_ip6_prefix_from_options(str_options); - ip_config = NM_IP_CONFIG_CAST(nm_dhcp_utils_ip6_config_from_options( - nm_dhcp_client_get_multi_idx(self), - priv->ifindex, - priv->iface, + prefix = nm_dhcp_utils_ip6_prefix_from_options(str_options); + l3cd = nm_dhcp_utils_ip6_config_from_options( + nm_l3cfg_get_multi_idx(priv->config.l3cfg), + nm_l3cfg_get_ifindex(priv->config.l3cfg), + priv->config.iface, str_options, - NM_FLAGS_HAS(priv->client_flags, NM_DHCP_CLIENT_FLAGS_INFO_ONLY))); + priv->config.v6.info_only); } } else g_warn_if_reached(); + + if (l3cd) { + nm_l3_config_data_set_dhcp_lease_from_options(l3cd, + priv->config.addr_family, + g_steal_pointer(&str_options)); + } } if (!IN6_IS_ADDR_UNSPECIFIED(&prefix.address)) { @@ -994,17 +913,16 @@ nm_dhcp_client_handle_event(gpointer unused, * of the DHCP client instance. Instead, we just signal the prefix * to the device. */ nm_dhcp_client_emit_ipv6_prefix_delegated(self, &prefix); - } else { - /* Fail if no valid IP config was received */ - if (NM_IN_SET(new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED) && !ip_config) { - _LOGW("client bound but IP config not received"); - new_state = NM_DHCP_STATE_FAIL; - nm_clear_pointer(&str_options, g_hash_table_unref); - } - - nm_dhcp_client_set_state(self, new_state, ip_config, str_options); + return TRUE; } + /* Fail if no valid IP config was received */ + if (NM_IN_SET(new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED) && !l3cd) { + _LOGW("client bound but IP config not received"); + new_state = NM_DHCP_STATE_FAIL; + } + + nm_dhcp_client_set_state(self, new_state, l3cd); return TRUE; } @@ -1016,18 +934,18 @@ nm_dhcp_client_server_id_is_rejected(NMDhcpClient *self, gconstpointer addr) guint i; /* IPv6 not implemented yet */ - nm_assert(priv->addr_family == AF_INET); + nm_assert(priv->config.addr_family == AF_INET); - if (!priv->reject_servers || !priv->reject_servers[0]) + if (!priv->config.reject_servers || !priv->config.reject_servers[0]) return FALSE; - for (i = 0; priv->reject_servers[i]; i++) { + for (i = 0; priv->config.reject_servers[i]; i++) { in_addr_t r_addr; in_addr_t mask; int r_prefix; if (!nm_utils_parse_inaddr_prefix_bin(AF_INET, - priv->reject_servers[i], + priv->config.reject_servers[i], NULL, &r_addr, &r_prefix)) @@ -1040,146 +958,146 @@ nm_dhcp_client_server_id_is_rejected(NMDhcpClient *self, gconstpointer addr) return FALSE; } -/*****************************************************************************/ - static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +config_init(NMDhcpClientConfig *config, const NMDhcpClientConfig *src) { - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(object); + *config = *src; - switch (prop_id) { - case PROP_IFACE: - g_value_set_string(value, priv->iface); - break; - case PROP_IFINDEX: - g_value_set_int(value, priv->ifindex); - break; - case PROP_HWADDR: - g_value_set_boxed(value, priv->hwaddr); - break; - case PROP_BROADCAST_HWADDR: - g_value_set_boxed(value, priv->bcast_hwaddr); - break; - case PROP_ADDR_FAMILY: - g_value_set_int(value, priv->addr_family); - break; - case PROP_UUID: - g_value_set_string(value, priv->uuid); - break; - case PROP_IAID: - g_value_set_uint(value, priv->iaid); - break; - case PROP_IAID_EXPLICIT: - g_value_set_boolean(value, priv->iaid_explicit); - break; - case PROP_HOSTNAME: - g_value_set_string(value, priv->hostname); - break; - case PROP_ROUTE_METRIC: - g_value_set_uint(value, priv->route_metric); - break; - case PROP_ROUTE_TABLE: - g_value_set_uint(value, priv->route_table); - break; - case PROP_TIMEOUT: - g_value_set_uint(value, priv->timeout); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + g_object_ref(config->l3cfg); + + if (config->hwaddr) + g_bytes_ref(config->hwaddr); + if (config->bcast_hwaddr) + g_bytes_ref(config->bcast_hwaddr); + if (config->vendor_class_identifier) + g_bytes_ref(config->vendor_class_identifier); + if (config->client_id) + g_bytes_ref(config->client_id); + + config->iface = g_strdup(config->iface); + config->uuid = g_strdup(config->uuid); + config->anycast_address = g_strdup(config->anycast_address); + config->hostname = g_strdup(config->hostname); + config->mud_url = g_strdup(config->mud_url); + + config->reject_servers = (const char *const *) nm_strv_dup(config->reject_servers, -1, TRUE); + + if (config->addr_family == AF_INET) { + config->v4.last_address = g_strdup(config->v4.last_address); + } else if (config->addr_family == AF_INET6) { + config->hwaddr = NULL; + config->bcast_hwaddr = NULL; + config->use_fqdn = TRUE; + } else { + nm_assert_not_reached(); + } + + if (!config->hostname && config->send_hostname) { + const char * hostname; + gs_free char *hostname_tmp = NULL; + + hostname = nm_hostname_manager_get_hostname(nm_hostname_manager_get()); + + if (nm_utils_is_specific_hostname(hostname)) { + if (config->addr_family == AF_INET) { + char *dot; + + hostname_tmp = g_strdup(hostname); + dot = strchr(hostname_tmp, '.'); + if (dot) + *dot = '\0'; + } + config->hostname = hostname_tmp ? g_steal_pointer(&hostname_tmp) : g_strdup(hostname); + } + } + + if (config->hostname) { + if ((config->use_fqdn && !nm_sd_dns_name_is_valid(config->hostname)) + || (!config->use_fqdn && !nm_sd_hostname_is_valid(config->hostname, FALSE))) { + nm_log_warn(LOGD_DHCP, + "dhcp%c: %s '%s' is invalid, will be ignored", + nm_utils_addr_family_to_char(config->addr_family), + config->use_fqdn ? "FQDN" : "hostname", + config->hostname); + nm_clear_g_free((gpointer *) &config->hostname); + } } } +static void +config_clear(NMDhcpClientConfig *config) +{ + g_object_unref(config->l3cfg); + + nm_clear_pointer(&config->hwaddr, g_bytes_unref); + nm_clear_pointer(&config->bcast_hwaddr, g_bytes_unref); + nm_clear_pointer(&config->vendor_class_identifier, g_bytes_unref); + nm_clear_pointer(&config->client_id, g_bytes_unref); + + nm_clear_g_free((gpointer *) &config->iface); + nm_clear_g_free((gpointer *) &config->uuid); + nm_clear_g_free((gpointer *) &config->anycast_address); + nm_clear_g_free((gpointer *) &config->hostname); + nm_clear_g_free((gpointer *) &config->mud_url); + + nm_clear_pointer((gpointer *) &config->reject_servers, g_strfreev); + + if (config->addr_family == AF_INET) { + nm_clear_g_free((gpointer *) &config->v4.last_address); + } +} + +int +nm_dhcp_client_get_addr_family(NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + return priv->config.addr_family; +} + +const char * +nm_dhcp_client_get_iface(NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + return priv->config.iface; +} + +NMDedupMultiIndex * +nm_dhcp_client_get_multi_idx(NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + return nm_l3cfg_get_multi_idx(priv->config.l3cfg); +} + +int +nm_dhcp_client_get_ifindex(NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + return nm_l3cfg_get_ifindex(priv->config.l3cfg); +} + +GBytes * +nm_dhcp_client_get_effective_client_id(NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + return priv->effective_client_id; +} + +/*****************************************************************************/ + static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(object); - guint flags; switch (prop_id) { - case PROP_FLAGS: + case PROP_CONFIG: /* construct-only */ - flags = g_value_get_uint(value); - nm_assert(!NM_FLAGS_ANY(flags, ~((guint) NM_DHCP_CLIENT_FLAGS_ALL))); - priv->client_flags = flags; - break; - case PROP_MULTI_IDX: - /* construct-only */ - priv->multi_idx = g_value_get_pointer(value); - if (!priv->multi_idx) - g_return_if_reached(); - nm_dedup_multi_index_ref(priv->multi_idx); - break; - case PROP_IFACE: - /* construct-only */ - priv->iface = g_value_dup_string(value); - g_return_if_fail(priv->iface); - nm_assert(nm_utils_ifname_valid_kernel(priv->iface, NULL)); - break; - case PROP_IFINDEX: - /* construct-only */ - priv->ifindex = g_value_get_int(value); - g_return_if_fail(priv->ifindex > 0); - break; - case PROP_HWADDR: - /* construct-only */ - priv->hwaddr = g_value_dup_boxed(value); - break; - case PROP_ANYCAST_ADDRESS: - /* construct-only */ - priv->anycast_address = g_value_dup_string(value); - break; - case PROP_BROADCAST_HWADDR: - /* construct-only */ - priv->bcast_hwaddr = g_value_dup_boxed(value); - break; - case PROP_ADDR_FAMILY: - /* construct-only */ - priv->addr_family = g_value_get_int(value); - if (!NM_IN_SET(priv->addr_family, AF_INET, AF_INET6)) - g_return_if_reached(); - break; - case PROP_UUID: - /* construct-only */ - priv->uuid = g_value_dup_string(value); - break; - case PROP_IAID: - /* construct-only */ - priv->iaid = g_value_get_uint(value); - break; - case PROP_IAID_EXPLICIT: - /* construct-only */ - priv->iaid_explicit = g_value_get_boolean(value); - break; - case PROP_HOSTNAME: - /* construct-only */ - priv->hostname = g_value_dup_string(value); - break; - case PROP_HOSTNAME_FLAGS: - /* construct-only */ - priv->hostname_flags = g_value_get_uint(value); - break; - case PROP_MUD_URL: - /* construct-only */ - priv->mud_url = g_value_dup_string(value); - break; - case PROP_ROUTE_TABLE: - priv->route_table = g_value_get_uint(value); - break; - case PROP_ROUTE_METRIC: - priv->route_metric = g_value_get_uint(value); - break; - case PROP_TIMEOUT: - /* construct-only */ - priv->timeout = g_value_get_uint(value); - break; - case PROP_VENDOR_CLASS_IDENTIFIER: - /* construct-only */ - priv->vendor_class_identifier = g_value_dup_boxed(value); - break; - case PROP_REJECT_SERVERS: - /* construct-only */ - priv->reject_servers = nm_strv_dup_packed(g_value_get_boxed(value), -1); + config_init(&priv->config, g_value_get_pointer(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -1200,28 +1118,6 @@ nm_dhcp_client_init(NMDhcpClient *self) priv->pid = -1; } -#if NM_MORE_ASSERTS -static void -constructed(GObject *object) -{ - NMDhcpClient * self = NM_DHCP_CLIENT(object); - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - - /* certain flags only make sense with certain address family. Assert - * for that. */ - if (NM_IS_IPv4(priv->addr_family)) - nm_assert(!NM_FLAGS_ANY(priv->client_flags, NM_DHCP_CLIENT_FLAGS_INFO_ONLY)); - else { - nm_assert(NM_FLAGS_HAS(priv->client_flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN)); - nm_assert(!NM_FLAGS_ANY(priv->client_flags, NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST)); - } - - nm_assert(!priv->anycast_address || nm_utils_hwaddr_valid(priv->anycast_address, ETH_ALEN)); - - G_OBJECT_CLASS(nm_dhcp_client_parent_class)->constructed(object); -} -#endif - static void dispose(GObject *object) { @@ -1233,20 +1129,21 @@ dispose(GObject *object) watch_cleanup(self); timeout_cleanup(self); - nm_clear_g_free(&priv->iface); - nm_clear_g_free(&priv->hostname); - nm_clear_g_free(&priv->uuid); - nm_clear_g_free(&priv->anycast_address); - nm_clear_g_free(&priv->mud_url); - nm_clear_g_free(&priv->reject_servers); - nm_clear_pointer(&priv->client_id, g_bytes_unref); - nm_clear_pointer(&priv->hwaddr, g_bytes_unref); - nm_clear_pointer(&priv->bcast_hwaddr, g_bytes_unref); - nm_clear_pointer(&priv->vendor_class_identifier, g_bytes_unref); + nm_clear_g_source_inst(&priv->no_lease_timeout_source); + nm_clear_g_source_inst(&priv->ipv6_lladdr_timeout_source); G_OBJECT_CLASS(nm_dhcp_client_parent_class)->dispose(object); +} - priv->multi_idx = nm_dedup_multi_index_unref(priv->multi_idx); +static void +finalize(GObject *object) +{ + NMDhcpClient * self = NM_DHCP_CLIENT(object); + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + config_clear(&priv->config); + + G_OBJECT_CLASS(nm_dhcp_client_parent_class)->finalize(object); } static void @@ -1256,165 +1153,19 @@ nm_dhcp_client_class_init(NMDhcpClientClass *client_class) g_type_class_add_private(client_class, sizeof(NMDhcpClientPrivate)); -#if NM_MORE_ASSERTS - object_class->constructed = constructed; -#endif object_class->dispose = dispose; - object_class->get_property = get_property; + object_class->finalize = finalize; object_class->set_property = set_property; client_class->stop = stop; client_class->get_duid = get_duid; - obj_properties[PROP_MULTI_IDX] = - g_param_spec_pointer(NM_DHCP_CLIENT_MULTI_IDX, + obj_properties[PROP_CONFIG] = + g_param_spec_pointer(NM_DHCP_CLIENT_CONFIG, "", "", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IFACE] = - g_param_spec_string(NM_DHCP_CLIENT_INTERFACE, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_IFINDEX] = - g_param_spec_int(NM_DHCP_CLIENT_IFINDEX, - "", - "", - -1, - G_MAXINT, - -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_HWADDR] = - g_param_spec_boxed(NM_DHCP_CLIENT_HWADDR, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_BROADCAST_HWADDR] = - g_param_spec_boxed(NM_DHCP_CLIENT_BROADCAST_HWADDR, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_ADDR_FAMILY] = - g_param_spec_int(NM_DHCP_CLIENT_ADDR_FAMILY, - "", - "", - 0, - G_MAXINT, - AF_UNSPEC, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_ANYCAST_ADDRESS] = - g_param_spec_string(NM_DHCP_CLIENT_ANYCAST_ADDRESS, - "", - "", - NULL, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_UUID] = - g_param_spec_string(NM_DHCP_CLIENT_UUID, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_IAID] = - g_param_spec_uint(NM_DHCP_CLIENT_IAID, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_IAID_EXPLICIT] = - g_param_spec_boolean(NM_DHCP_CLIENT_IAID_EXPLICIT, - "", - "", - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_HOSTNAME] = - g_param_spec_string(NM_DHCP_CLIENT_HOSTNAME, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_HOSTNAME_FLAGS] = - g_param_spec_uint(NM_DHCP_CLIENT_HOSTNAME_FLAGS, - "", - "", - 0, - G_MAXUINT32, - NM_DHCP_HOSTNAME_FLAG_NONE, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_MUD_URL] = - g_param_spec_string(NM_DHCP_CLIENT_MUD_URL, - "", - "", - NULL, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_ROUTE_TABLE] = - g_param_spec_uint(NM_DHCP_CLIENT_ROUTE_TABLE, - "", - "", - 0, - G_MAXUINT32, - RT_TABLE_MAIN, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_ROUTE_METRIC] = - g_param_spec_uint(NM_DHCP_CLIENT_ROUTE_METRIC, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - G_STATIC_ASSERT_EXPR(G_MAXINT32 == NM_DHCP_TIMEOUT_INFINITY); - obj_properties[PROP_TIMEOUT] = - g_param_spec_uint(NM_DHCP_CLIENT_TIMEOUT, - "", - "", - 1, - G_MAXINT32, - NM_DHCP_TIMEOUT_DEFAULT, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_FLAGS] = - g_param_spec_uint(NM_DHCP_CLIENT_FLAGS, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_VENDOR_CLASS_IDENTIFIER] = - g_param_spec_boxed(NM_DHCP_CLIENT_VENDOR_CLASS_IDENTIFIER, - "", - "", - G_TYPE_BYTES, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_REJECT_SERVERS] = - g_param_spec_boxed(NM_DHCP_CLIENT_REJECT_SERVERS, - "", - "", - G_TYPE_STRV, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[SIGNAL_NOTIFY] = diff --git a/src/core/dhcp/nm-dhcp-client.h b/src/core/dhcp/nm-dhcp-client.h index 2e7e021650..fac4b0f7df 100644 --- a/src/core/dhcp/nm-dhcp-client.h +++ b/src/core/dhcp/nm-dhcp-client.h @@ -8,8 +8,6 @@ #include "nm-setting-ip4-config.h" #include "nm-setting-ip6-config.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" #include "nm-dhcp-utils.h" #define NM_DHCP_TIMEOUT_DEFAULT ((guint32) 45) /* default DHCP timeout, in seconds */ @@ -24,25 +22,7 @@ #define NM_DHCP_CLIENT_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClientClass)) -#define NM_DHCP_CLIENT_ADDR_FAMILY "addr-family" -#define NM_DHCP_CLIENT_ANYCAST_ADDRESS "anycast-address" -#define NM_DHCP_CLIENT_FLAGS "flags" -#define NM_DHCP_CLIENT_HWADDR "hwaddr" -#define NM_DHCP_CLIENT_BROADCAST_HWADDR "broadcast-hwaddr" -#define NM_DHCP_CLIENT_IFINDEX "ifindex" -#define NM_DHCP_CLIENT_INTERFACE "iface" -#define NM_DHCP_CLIENT_MULTI_IDX "multi-idx" -#define NM_DHCP_CLIENT_HOSTNAME "hostname" -#define NM_DHCP_CLIENT_MUD_URL "mud-url" -#define NM_DHCP_CLIENT_ROUTE_METRIC "route-metric" -#define NM_DHCP_CLIENT_ROUTE_TABLE "route-table" -#define NM_DHCP_CLIENT_TIMEOUT "timeout" -#define NM_DHCP_CLIENT_UUID "uuid" -#define NM_DHCP_CLIENT_IAID "iaid" -#define NM_DHCP_CLIENT_IAID_EXPLICIT "iaid-explicit" -#define NM_DHCP_CLIENT_HOSTNAME_FLAGS "hostname-flags" -#define NM_DHCP_CLIENT_VENDOR_CLASS_IDENTIFIER "vendor-class-identifier" -#define NM_DHCP_CLIENT_REJECT_SERVERS "reject-servers" +#define NM_DHCP_CLIENT_CONFIG "config" #define NM_DHCP_CLIENT_NOTIFY "dhcp-notify" @@ -59,7 +39,27 @@ typedef enum { } NMDhcpState; typedef enum _nm_packed { - NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED, + NM_DHCP_CLIENT_NOTIFY_TYPE_LEASE_UPDATE, + + /* When NM_DHCP_CLIENT_NO_LEASE_TIMEOUT expired and the state + * switched from NM_DHCP_CLIENT_STATE_NO_LEASE to + * NM_DHCP_CLIENT_STATE_NO_LEASE_WITH_TIMEOUT. */ + NM_DHCP_CLIENT_NOTIFY_TYPE_NO_LEASE_TIMEOUT, + + /* NMDhcpClient will indefinitely try to get/renew the lease. + * As such, it's never officially in a non-recoverable state. + * However, there are cases when it really looks like we won't + * be able to get a lease. For example, if the underlying interface + * is layer 3 only, if we have no IPv6 link local address for a prolonged + * time, or if dhclient is not installed. + * But even these cases are potentially recoverable. This is only + * a hint to the user (which they might ignore). + * + * In particular, NM_DHCP_CLIENT_NOTIFY_TYPE_NO_LEASE_TIMEOUT might mean + * that the DHCP is currently not running, but that could change + * at any moment and from client's side, it does not look bad. */ + NM_DHCP_CLIENT_NOTIFY_TYPE_IT_LOOKS_BAD, + NM_DHCP_CLIENT_NOTIFY_TYPE_PREFIX_DELEGATED, } NMDhcpClientNotifyType; @@ -67,18 +67,123 @@ typedef struct { NMDhcpClientNotifyType notify_type; union { struct { - NMIPConfig *ip_config; - GHashTable *options; - NMDhcpState dhcp_state; - } state_changed; + /* This is either the new lease information we just received, + * or NULL (if a previous lease timed out). It can also be the + * previous lease, that was injected. */ + const NML3ConfigData *l3cd; + } lease_update; struct { const NMPlatformIP6Address *prefix; } prefix_delegated; + struct { + const char *reason; + } it_looks_bad; }; } NMDhcpClientNotifyData; const char *nm_dhcp_state_to_string(NMDhcpState state); +/* FIXME(l3cfg:dhcp:config): nm_dhcp_manager_start_ip[46]() has a gazillion of parameters, + * those get passed on as CONSTRUCT_ONLY properties to the NMDhcpClient. Drop + * all these parameters, and let the caller provide one NMDhcpClientConfig + * instance. There will be only one GObject property (NM_DHCP_CLIENT_CONFIG), + * which is CONSTRUCT_ONLY and takes a (mandatory) G_TYPE_POINTER for the + * configuration. + * + * Since NMDhcpClientConfig has an addr_family, we also don't need separate + * nm_dhcp_manager_start_ip[46]() methods. */ +typedef struct { + int addr_family; + + /* The NML3Cfg instance is the manager object for the ifindex on which + * NMDhcpClient is supposed to run. */ + NML3Cfg *l3cfg; + + /* FIXME(l3cfg:dhcp:previous-lease): most parameters of NMDhcpClient are immutable, + * so to change them (during reapply), we need to create and start + * a new NMDhcpClient instance. + * + * However, while the restart happens, we want to stick to the previous + * lease (if any). Allow the caller to provide such a previous lease, + * and if present, the instance starts by pretending that it just received + * this lease, before really starting. */ + const NML3ConfigData *previous_lease; + + const char *iface; + + /* The hardware address */ + GBytes *hwaddr; + + /* The broadcast hardware address */ + GBytes *bcast_hwaddr; + + /* Timeout in seconds before reporting failure */ + guint32 timeout; + + /* Flags for the hostname and FQDN DHCP options */ + NMDhcpHostnameFlags hostname_flags; + + /* The UUID of the connection. Used mainly to build + * lease file names. */ + const char *uuid; + + /* Set to reduce the number of broadcast packets when the + * anycast hardware address of the DHCP service is known. */ + const char *anycast_address; + + /* The hostname or FQDN to send. */ + const char *hostname; + + /* The Manufacturer Usage Description (RFC 8520) URL to send */ + const char *mud_url; + + /* The value for the Vendor Class Identifier option */ + GBytes *vendor_class_identifier; + + /* A list of servers from which offers should be rejected */ + const char *const *reject_servers; + + /* The client identifier (DHCPv4) or DUID (DHCPv6) to send */ + GBytes *client_id; + + /* Whether to send the hostname or FQDN option */ + bool send_hostname : 1; + + /* Whether to send the hostname as HOSTNAME option or FQDN. + * For DHCPv6 this is always TRUE. */ + bool use_fqdn : 1; + + union { + struct { + /* Set BOOTP broadcast flag in request packets, so that servers + * will always broadcast replies. */ + bool request_broadcast : 1; + + /* The address from the previous lease */ + const char *last_address; + } v4; + struct { + /* If set, the DUID from the connection is used; otherwise + * the one from an existing lease is used. */ + gboolean enforce_duid; + + /* The IAID to use */ + guint32 iaid; + + /* Whether the IAID was explicitly set in the connection or + * as global default */ + gboolean iaid_explicit; + + /* Number to prefixes (IA_PD) to request */ + guint needed_prefixes; + + /* Use Information-request to get stateless configuration + * parameters (don't request a IA_NA) */ + bool info_only : 1; + } v6; + }; +} NMDhcpClientConfig; + struct _NMDhcpClientPrivate; typedef struct { @@ -100,17 +205,13 @@ typedef enum _nm_packed { typedef struct { GObjectClass parent; - gboolean (*ip4_start)(NMDhcpClient *self, const char *last_ip4_address, GError **error); + gboolean (*ip4_start)(NMDhcpClient *self, GError **error); gboolean (*accept)(NMDhcpClient *self, GError **error); gboolean (*decline)(NMDhcpClient *self, const char *error_message, GError **error); - gboolean (*ip6_start)(NMDhcpClient * self, - const struct in6_addr * ll_addr, - NMSettingIP6ConfigPrivacy privacy, - guint needed_prefixes, - GError ** error); + gboolean (*ip6_start)(NMDhcpClient *self, const struct in6_addr *ll_addr, GError **error); void (*stop)(NMDhcpClient *self, gboolean release); @@ -128,64 +229,25 @@ typedef struct { GType nm_dhcp_client_get_type(void); -struct _NMDedupMultiIndex *nm_dhcp_client_get_multi_idx(NMDhcpClient *self); +gboolean nm_dhcp_client_start_ip4(NMDhcpClient *self, GError **error); +gboolean nm_dhcp_client_start_ip6(NMDhcpClient *self, GError **error); + +const NMDhcpClientConfig *nm_dhcp_client_get_config(NMDhcpClient *self); pid_t nm_dhcp_client_get_pid(NMDhcpClient *self); -int nm_dhcp_client_get_addr_family(NMDhcpClient *self); - -const char *nm_dhcp_client_get_iface(NMDhcpClient *self); - -int nm_dhcp_client_get_ifindex(NMDhcpClient *self); - -const char *nm_dhcp_client_get_uuid(NMDhcpClient *self); - -GBytes *nm_dhcp_client_get_duid(NMDhcpClient *self); - -GBytes *nm_dhcp_client_get_hw_addr(NMDhcpClient *self); - -GBytes *nm_dhcp_client_get_broadcast_hw_addr(NMDhcpClient *self); - -const char *nm_dhcp_client_get_anycast_address(NMDhcpClient *self); - -guint32 nm_dhcp_client_get_route_table(NMDhcpClient *self); - -void nm_dhcp_client_set_route_table(NMDhcpClient *self, guint32 route_table); - -guint32 nm_dhcp_client_get_route_metric(NMDhcpClient *self); - -void nm_dhcp_client_set_route_metric(NMDhcpClient *self, guint32 route_metric); - -guint32 nm_dhcp_client_get_timeout(NMDhcpClient *self); - -guint32 nm_dhcp_client_get_iaid(NMDhcpClient *self); - -gboolean nm_dhcp_client_get_iaid_explicit(NMDhcpClient *self); - -GBytes *nm_dhcp_client_get_client_id(NMDhcpClient *self); - -const char * nm_dhcp_client_get_hostname(NMDhcpClient *self); -const char * nm_dhcp_client_get_mud_url(NMDhcpClient *self); -const char *const *nm_dhcp_client_get_reject_servers(NMDhcpClient *self); - -NMDhcpHostnameFlags nm_dhcp_client_get_hostname_flags(NMDhcpClient *self); - -NMDhcpClientFlags nm_dhcp_client_get_client_flags(NMDhcpClient *self); - -GBytes *nm_dhcp_client_get_vendor_class_identifier(NMDhcpClient *self); - -gboolean nm_dhcp_client_start_ip4(NMDhcpClient *self, - GBytes * client_id, - const char * last_ip4_address, - GError ** error); - -gboolean nm_dhcp_client_start_ip6(NMDhcpClient * self, - GBytes * client_id, - gboolean enforce_duid, - const struct in6_addr * ll_addr, - NMSettingIP6ConfigPrivacy privacy, - guint needed_prefixes, - GError ** error); +static inline const NML3ConfigData * +nm_dhcp_client_get_lease(NMDhcpClient *self) +{ + /* FIXME(l3cfg:dhcp:previous-lease): this function returns the currently + * valid, exposed lease. + * + * Note that NMDhcpClient should accept as construct argument a *previous* lease, + * and (if that lease is still valid), pretend that it's good to use. The point is + * so that during reapply we keep using the current address, until a new lease + * was received. */ + return NULL; +} gboolean nm_dhcp_client_accept(NMDhcpClient *self, GError **error); gboolean nm_dhcp_client_can_accept(NMDhcpClient *self); @@ -205,10 +267,8 @@ void nm_dhcp_client_watch_child(NMDhcpClient *self, pid_t pid); void nm_dhcp_client_stop_watch_child(NMDhcpClient *self, pid_t pid); -void nm_dhcp_client_set_state(NMDhcpClient *self, - NMDhcpState new_state, - NMIPConfig * ip_config, - GHashTable * options); /* str:str hash */ +void +nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3ConfigData *l3cd); gboolean nm_dhcp_client_handle_event(gpointer unused, const char * iface, @@ -217,17 +277,19 @@ gboolean nm_dhcp_client_handle_event(gpointer unused, const char * reason, NMDhcpClient *self); -void nm_dhcp_client_set_client_id(NMDhcpClient *self, GBytes *client_id); -void nm_dhcp_client_set_client_id_bin(NMDhcpClient *self, - guint8 type, - const guint8 *client_id, - gsize len); - void nm_dhcp_client_emit_ipv6_prefix_delegated(NMDhcpClient * self, const NMPlatformIP6Address *prefix); gboolean nm_dhcp_client_server_id_is_rejected(NMDhcpClient *self, gconstpointer addr); +int nm_dhcp_client_get_addr_family(NMDhcpClient *self); +const char * nm_dhcp_client_get_iface(NMDhcpClient *self); +NMDedupMultiIndex *nm_dhcp_client_get_multi_idx(NMDhcpClient *self); +int nm_dhcp_client_get_ifindex(NMDhcpClient *self); + +void nm_dhcp_client_set_effective_client_id(NMDhcpClient *self, GBytes *client_id); +GBytes *nm_dhcp_client_get_effective_client_id(NMDhcpClient *self); + /***************************************************************************** * Client data *****************************************************************************/ diff --git a/src/core/dhcp/nm-dhcp-dhclient-utils.c b/src/core/dhcp/nm-dhcp-dhclient-utils.c index 341ac7b2fa..60cb46e507 100644 --- a/src/core/dhcp/nm-dhcp-dhclient-utils.c +++ b/src/core/dhcp/nm-dhcp-dhclient-utils.c @@ -15,7 +15,6 @@ #include "libnm-glib-aux/nm-dedup-multi.h" #include "nm-dhcp-utils.h" -#include "nm-ip4-config.h" #include "nm-utils.h" #include "libnm-platform/nm-platform.h" #include "NetworkManagerUtils.h" diff --git a/src/core/dhcp/nm-dhcp-dhclient.c b/src/core/dhcp/nm-dhcp-dhclient.c index 970a51f5dd..9c5d05bcf4 100644 --- a/src/core/dhcp/nm-dhcp-dhclient.c +++ b/src/core/dhcp/nm-dhcp-dhclient.c @@ -333,26 +333,28 @@ dhclient_start(NMDhcpClient *client, const char * mode_opt, gboolean release, pid_t * out_pid, - int prefixes, GError ** error) { NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *argv = NULL; pid_t pid; - gs_free_error GError *local = NULL; - const char * iface; - const char * uuid; - const char * system_bus_address; - const char * dhclient_path; - char * binary_name; - gs_free char * cmd_str = NULL; - gs_free char * pid_file = NULL; - gs_free char * system_bus_address_env = NULL; - gs_free char * preferred_leasefile_path = NULL; - const int addr_family = nm_dhcp_client_get_addr_family(client); + gs_free_error GError * local = NULL; + const char * iface; + const char * uuid; + const char * system_bus_address; + const char * dhclient_path; + char * binary_name; + gs_free char * cmd_str = NULL; + gs_free char * pid_file = NULL; + gs_free char * system_bus_address_env = NULL; + gs_free char * preferred_leasefile_path = NULL; + int addr_family; + const NMDhcpClientConfig *client_config; g_return_val_if_fail(!priv->pid_file, FALSE); + client_config = nm_dhcp_client_get_config(client); + addr_family = client_config->addr_family; NM_SET_OUT(out_pid, 0); @@ -362,8 +364,8 @@ dhclient_start(NMDhcpClient *client, return FALSE; } - iface = nm_dhcp_client_get_iface(client); - uuid = nm_dhcp_client_get_uuid(client); + iface = client_config->iface; + uuid = client_config->uuid; pid_file = g_strdup_printf(NMRUNDIR "/dhclient%s-%s.pid", _addr_family_to_path_part(addr_family), @@ -409,9 +411,7 @@ dhclient_start(NMDhcpClient *client, /* Save the DUID to the leasefile dhclient will actually use */ if (addr_family == AF_INET6) { - if (!nm_dhcp_dhclient_save_duid(priv->lease_file, - nm_dhcp_client_get_client_id(client), - &local)) { + if (!nm_dhcp_dhclient_save_duid(priv->lease_file, client_config->client_id, &local)) { nm_utils_error_set(error, NM_UTILS_ERROR_UNKNOWN, "failed to save DUID to '%s': %s", @@ -434,13 +434,13 @@ dhclient_start(NMDhcpClient *client, if (release) g_ptr_array_add(argv, (gpointer) "-r"); - if (!release - && NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(NM_DHCP_CLIENT(self)), - NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST)) { + if (!release && client_config->addr_family == AF_INET && client_config->v4.request_broadcast) { g_ptr_array_add(argv, (gpointer) "-B"); } if (addr_family == AF_INET6) { + guint prefixes = client_config->v6.needed_prefixes; + g_ptr_array_add(argv, (gpointer) "-6"); if (prefixes > 0 && nm_streq0(mode_opt, "-S")) { @@ -513,29 +513,28 @@ dhclient_start(NMDhcpClient *client, } static gboolean -ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) +ip4_start(NMDhcpClient *client, GError **error) { - NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); - GBytes * client_id; - gs_unref_bytes GBytes *new_client_id = NULL; + NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); + gs_unref_bytes GBytes * new_client_id = NULL; + const NMDhcpClientConfig *client_config; - client_id = nm_dhcp_client_get_client_id(client); + client_config = nm_dhcp_client_get_config(client); - priv->conf_file = create_dhclient_config( - self, - AF_INET, - nm_dhcp_client_get_iface(client), - nm_dhcp_client_get_uuid(client), - client_id, - nm_dhcp_client_get_anycast_address(client), - nm_dhcp_client_get_hostname(client), - nm_dhcp_client_get_timeout(client), - NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), NM_DHCP_CLIENT_FLAGS_USE_FQDN), - nm_dhcp_client_get_hostname_flags(client), - nm_dhcp_client_get_mud_url(client), - nm_dhcp_client_get_reject_servers(client), - &new_client_id); + priv->conf_file = create_dhclient_config(self, + AF_INET, + client_config->iface, + client_config->uuid, + client_config->client_id, + client_config->anycast_address, + client_config->hostname, + client_config->timeout, + client_config->use_fqdn, + client_config->hostname_flags, + client_config->mud_url, + client_config->reject_servers, + &new_client_id); if (!priv->conf_file) { nm_utils_error_set_literal(error, NM_UTILS_ERROR_UNKNOWN, @@ -544,36 +543,35 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } if (new_client_id) { - nm_assert(!client_id); - nm_dhcp_client_set_client_id(client, new_client_id); + nm_assert(!client_config->client_id); + nm_dhcp_client_set_effective_client_id(client, new_client_id); } - return dhclient_start(client, NULL, FALSE, NULL, 0, error); + return dhclient_start(client, NULL, FALSE, NULL, error); } static gboolean -ip6_start(NMDhcpClient * client, - const struct in6_addr * ll_addr, - NMSettingIP6ConfigPrivacy privacy, - guint needed_prefixes, - GError ** error) +ip6_start(NMDhcpClient *client, const struct in6_addr *ll_addr, GError **error) { - NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); + NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); + NMDhcpDhclientPrivate * priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); + const NMDhcpClientConfig *config; - if (nm_dhcp_client_get_iaid_explicit(client)) + config = nm_dhcp_client_get_config(client); + + if (config->v6.iaid_explicit) _LOGW("dhclient does not support specifying an IAID for DHCPv6, it will be ignored"); priv->conf_file = create_dhclient_config(self, AF_INET6, - nm_dhcp_client_get_iface(client), - nm_dhcp_client_get_uuid(client), + config->iface, + config->uuid, NULL, - nm_dhcp_client_get_anycast_address(client), - nm_dhcp_client_get_hostname(client), - nm_dhcp_client_get_timeout(client), + config->anycast_address, + config->hostname, + config->timeout, TRUE, - nm_dhcp_client_get_hostname_flags(client), - nm_dhcp_client_get_mud_url(client), + config->hostname_flags, + config->mud_url, NULL, NULL); if (!priv->conf_file) { @@ -583,15 +581,7 @@ ip6_start(NMDhcpClient * client, return FALSE; } - return dhclient_start(client, - NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(NM_DHCP_CLIENT(self)), - NM_DHCP_CLIENT_FLAGS_INFO_ONLY) - ? "-S" - : "-N", - FALSE, - NULL, - needed_prefixes, - error); + return dhclient_start(client, config->v6.needed_prefixes ? "-S" : "-N", FALSE, NULL, error); } static void @@ -625,7 +615,7 @@ stop(NMDhcpClient *client, gboolean release) if (release) { pid_t rpid = -1; - if (dhclient_start(client, NULL, TRUE, &rpid, 0, NULL)) { + if (dhclient_start(client, NULL, TRUE, &rpid, NULL)) { /* Wait a few seconds for the release to happen */ nm_dhcp_client_stop_pid(rpid, nm_dhcp_client_get_iface(client)); } @@ -635,16 +625,19 @@ stop(NMDhcpClient *client, gboolean release) static GBytes * get_duid(NMDhcpClient *client) { - NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); - GBytes * duid = NULL; - gs_free char * leasefile = NULL; - GError * error = NULL; + NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); + NMDhcpDhclientPrivate * priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); + const NMDhcpClientConfig *client_config; + GBytes * duid = NULL; + gs_free char * leasefile = NULL; + GError * error = NULL; + + client_config = nm_dhcp_client_get_config(client); /* Look in interface-specific leasefile first for backwards compat */ leasefile = get_dhclient_leasefile(AF_INET6, nm_dhcp_client_get_iface(client), - nm_dhcp_client_get_uuid(client), + client_config->uuid, NULL); if (leasefile) { _LOGD("looking for DUID in '%s'", leasefile); diff --git a/src/core/dhcp/nm-dhcp-dhcpcanon.c b/src/core/dhcp/nm-dhcp-dhcpcanon.c index f993ffb940..ed29b85cd0 100644 --- a/src/core/dhcp/nm-dhcp-dhcpcanon.c +++ b/src/core/dhcp/nm-dhcp-dhcpcanon.c @@ -160,7 +160,7 @@ dhcpcanon_start(NMDhcpClient *client, } static gboolean -ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) +ip4_start(NMDhcpClient *client, GError **error) { return dhcpcanon_start(client, NULL, NULL, FALSE, NULL, 0, error); } diff --git a/src/core/dhcp/nm-dhcp-dhcpcd.c b/src/core/dhcp/nm-dhcp-dhcpcd.c index 7522156bef..0a6a91b743 100644 --- a/src/core/dhcp/nm-dhcp-dhcpcd.c +++ b/src/core/dhcp/nm-dhcp-dhcpcd.c @@ -64,21 +64,19 @@ nm_dhcp_dhcpcd_get_path(void) } static gboolean -ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) +ip4_start(NMDhcpClient *client, GError **error) { - NMDhcpDhcpcd * self = NM_DHCP_DHCPCD(client); + NMDhcpDhcpcd * self = NM_DHCP_DHCPCD(client); + const NMDhcpClientConfig *client_config; gs_unref_ptrarray GPtrArray *argv = NULL; pid_t pid; GError * local; gs_free char * cmd_str = NULL; - const char * iface; const char * dhcpcd_path; - const char * hostname; pid = nm_dhcp_client_get_pid(client); g_return_val_if_fail(pid == -1, FALSE); - - iface = nm_dhcp_client_get_iface(client); + client_config = nm_dhcp_client_get_config(client); dhcpcd_path = nm_dhcp_dhcpcd_get_path(); if (!dhcpcd_path) { @@ -115,21 +113,19 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) */ g_ptr_array_add(argv, (gpointer) "-4"); - hostname = nm_dhcp_client_get_hostname(client); - - if (hostname) { - if (NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), NM_DHCP_CLIENT_FLAGS_USE_FQDN)) { + if (client_config->hostname) { + if (client_config->use_fqdn) { g_ptr_array_add(argv, (gpointer) "-h"); - g_ptr_array_add(argv, (gpointer) hostname); + g_ptr_array_add(argv, (gpointer) client_config->hostname); g_ptr_array_add(argv, (gpointer) "-F"); g_ptr_array_add(argv, (gpointer) "both"); } else { g_ptr_array_add(argv, (gpointer) "-h"); - g_ptr_array_add(argv, (gpointer) hostname); + g_ptr_array_add(argv, (gpointer) client_config->hostname); } } - g_ptr_array_add(argv, (gpointer) iface); + g_ptr_array_add(argv, (gpointer) client_config->iface); g_ptr_array_add(argv, NULL); _LOGD("running: %s", (cmd_str = g_strjoinv(" ", (char **) argv->pdata))); diff --git a/src/core/dhcp/nm-dhcp-manager.c b/src/core/dhcp/nm-dhcp-manager.c index 3cb893932d..8fe7478c39 100644 --- a/src/core/dhcp/nm-dhcp-manager.c +++ b/src/core/dhcp/nm-dhcp-manager.c @@ -17,7 +17,6 @@ #include #include "libnm-glib-aux/nm-dedup-multi.h" -#include "libnm-systemd-shared/nm-sd-utils-shared.h" #include "nm-config.h" #include "NetworkManagerUtils.h" @@ -26,7 +25,6 @@ typedef struct { const NMDhcpClientFactory *client_factory; - char * default_hostname; } NMDhcpManagerPrivate; struct _NMDhcpManager { @@ -129,34 +127,8 @@ _client_factory_get_gtype(const NMDhcpClientFactory *client_factory, int addr_fa /*****************************************************************************/ -static NMDhcpClient * -client_start(NMDhcpManager * self, - int addr_family, - NMDedupMultiIndex * multi_idx, - const char * iface, - int ifindex, - GBytes * hwaddr, - GBytes * bcast_hwaddr, - const char * uuid, - guint32 route_table, - guint32 route_metric, - const struct in6_addr * ipv6_ll_addr, - GBytes * dhcp_client_id, - gboolean enforce_duid, - guint32 iaid, - gboolean iaid_explicit, - guint32 timeout, - NMDhcpClientFlags client_flags, - const char * anycast_address, - const char * hostname, - NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - NMSettingIP6ConfigPrivacy privacy, - const char * last_ip4_address, - guint needed_prefixes, - GBytes * vendor_class_identifier, - const char *const * reject_servers, - GError ** error) +NMDhcpClient * +nm_dhcp_manager_start_client(NMDhcpManager *self, NMDhcpClientConfig *config, GError **error) { NMDhcpManagerPrivate *priv; gs_unref_object NMDhcpClient *client = NULL; @@ -165,100 +137,44 @@ client_start(NMDhcpManager * self, GType gtype; g_return_val_if_fail(NM_IS_DHCP_MANAGER(self), NULL); - g_return_val_if_fail(iface, NULL); - g_return_val_if_fail(ifindex > 0, NULL); - g_return_val_if_fail(uuid != NULL, NULL); - g_return_val_if_fail(!dhcp_client_id || g_bytes_get_size(dhcp_client_id) >= 2, NULL); - g_return_val_if_fail(!vendor_class_identifier - || g_bytes_get_size(vendor_class_identifier) <= 255, + g_return_val_if_fail(config, NULL); + g_return_val_if_fail(config->iface, NULL); + g_return_val_if_fail(config->l3cfg, NULL); + g_return_val_if_fail(config->uuid != NULL, NULL); + g_return_val_if_fail(!config->client_id || g_bytes_get_size(config->client_id) >= 2, NULL); + g_return_val_if_fail(!config->vendor_class_identifier + || g_bytes_get_size(config->vendor_class_identifier) <= 255, NULL); g_return_val_if_fail(!error || !*error, NULL); - nm_assert(!NM_FLAGS_ANY(client_flags, ~NM_DHCP_CLIENT_FLAGS_ALL)); - if (addr_family == AF_INET) { - if (!hwaddr || !bcast_hwaddr) { + if (config->addr_family == AF_INET) { + if (!config->hwaddr || !config->bcast_hwaddr) { nm_utils_error_set(error, NM_UTILS_ERROR_UNKNOWN, "missing %s address", - hwaddr ? "broadcast" : "MAC"); + config->hwaddr ? "broadcast" : "MAC"); return NULL; } - hwaddr_len = g_bytes_get_size(hwaddr); + hwaddr_len = g_bytes_get_size(config->hwaddr); if (hwaddr_len == 0 || hwaddr_len > _NM_UTILS_HWADDR_LEN_MAX) { nm_utils_error_set(error, NM_UTILS_ERROR_UNKNOWN, "invalid MAC address"); g_return_val_if_reached(NULL); } - nm_assert(g_bytes_get_size(hwaddr) == g_bytes_get_size(bcast_hwaddr)); - } else { - hwaddr = NULL; - bcast_hwaddr = NULL; - } - - if (hostname) { - gboolean use_fqdn = NM_FLAGS_HAS(client_flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN); - - if ((use_fqdn && !nm_sd_dns_name_is_valid(hostname)) - || (!use_fqdn && !nm_sd_hostname_is_valid(hostname, FALSE))) { - nm_log_warn(LOGD_DHCP, - "dhcp%c: %s '%s' is invalid, will be ignored", - nm_utils_addr_family_to_char(addr_family), - use_fqdn ? "FQDN" : "hostname", - hostname); - hostname = NULL; - } + nm_assert(g_bytes_get_size(config->hwaddr) == g_bytes_get_size(config->bcast_hwaddr)); } priv = NM_DHCP_MANAGER_GET_PRIVATE(self); - gtype = _client_factory_get_gtype(priv->client_factory, addr_family); + gtype = _client_factory_get_gtype(priv->client_factory, config->addr_family); nm_log_trace(LOGD_DHCP, "dhcp%c: creating IPv%c DHCP client of type %s", - nm_utils_addr_family_to_char(addr_family), - nm_utils_addr_family_to_char(addr_family), + nm_utils_addr_family_to_char(config->addr_family), + nm_utils_addr_family_to_char(config->addr_family), g_type_name(gtype)); - client = g_object_new(gtype, - NM_DHCP_CLIENT_MULTI_IDX, - multi_idx, - NM_DHCP_CLIENT_ADDR_FAMILY, - addr_family, - NM_DHCP_CLIENT_INTERFACE, - iface, - NM_DHCP_CLIENT_IFINDEX, - ifindex, - NM_DHCP_CLIENT_HWADDR, - hwaddr, - NM_DHCP_CLIENT_BROADCAST_HWADDR, - bcast_hwaddr, - NM_DHCP_CLIENT_UUID, - uuid, - NM_DHCP_CLIENT_IAID, - (guint) iaid, - NM_DHCP_CLIENT_IAID_EXPLICIT, - iaid_explicit, - NM_DHCP_CLIENT_HOSTNAME, - hostname, - NM_DHCP_CLIENT_MUD_URL, - mud_url, - NM_DHCP_CLIENT_ROUTE_TABLE, - (guint) route_table, - NM_DHCP_CLIENT_ROUTE_METRIC, - (guint) route_metric, - NM_DHCP_CLIENT_TIMEOUT, - (guint) timeout, - NM_DHCP_CLIENT_HOSTNAME_FLAGS, - (guint) hostname_flags, - NM_DHCP_CLIENT_VENDOR_CLASS_IDENTIFIER, - vendor_class_identifier, - NM_DHCP_CLIENT_REJECT_SERVERS, - reject_servers, - NM_DHCP_CLIENT_FLAGS, - (guint) client_flags, - NM_DHCP_CLIENT_ANYCAST_ADDRESS, - anycast_address, - NULL); + client = g_object_new(gtype, NM_DHCP_CLIENT_CONFIG, config, NULL); /* unfortunately, our implementations work differently per address-family regarding client-id/DUID. * @@ -286,16 +202,10 @@ client_start(NMDhcpManager * self, * default outside of NetworkManager API. */ - if (addr_family == AF_INET) { - success = nm_dhcp_client_start_ip4(client, dhcp_client_id, last_ip4_address, error); + if (config->addr_family == AF_INET) { + success = nm_dhcp_client_start_ip4(client, error); } else { - success = nm_dhcp_client_start_ip6(client, - dhcp_client_id, - enforce_duid, - ipv6_ll_addr, - privacy, - needed_prefixes, - error); + success = nm_dhcp_client_start_ip6(client, error); } if (!success) @@ -304,178 +214,6 @@ client_start(NMDhcpManager * self, return g_steal_pointer(&client); } -/* Caller owns a reference to the NMDhcpClient on return */ -NMDhcpClient * -nm_dhcp_manager_start_ip4(NMDhcpManager * self, - NMDedupMultiIndex * multi_idx, - const char * iface, - int ifindex, - GBytes * hwaddr, - GBytes * bcast_hwaddr, - const char * uuid, - guint32 route_table, - guint32 route_metric, - NMDhcpClientFlags client_flags, - gboolean send_hostname, - const char * dhcp_hostname, - const char * dhcp_fqdn, - NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - GBytes * dhcp_client_id, - guint32 timeout, - const char * anycast_address, - const char * last_ip_address, - GBytes * vendor_class_identifier, - const char *const * reject_servers, - GError ** error) -{ - NMDhcpManagerPrivate *priv; - const char * hostname = NULL; - gs_free char * hostname_tmp = NULL; - gboolean use_fqdn = FALSE; - char * dot; - - /* these flags are set automatically/prohibited, and not free to set to the caller. */ - nm_assert(!NM_FLAGS_ANY(client_flags, - NM_DHCP_CLIENT_FLAGS_USE_FQDN | NM_DHCP_CLIENT_FLAGS_INFO_ONLY)); - - g_return_val_if_fail(NM_IS_DHCP_MANAGER(self), NULL); - priv = NM_DHCP_MANAGER_GET_PRIVATE(self); - - if (send_hostname) { - /* Use, in order of preference: - * 1. FQDN from configuration - * 2. hostname from configuration - * 3. system hostname (only host part) - */ - if (dhcp_fqdn) { - hostname = dhcp_fqdn; - use_fqdn = TRUE; - } else if (dhcp_hostname) - hostname = dhcp_hostname; - else { - hostname = priv->default_hostname; - if (hostname) { - hostname_tmp = g_strdup(hostname); - dot = strchr(hostname_tmp, '.'); - if (dot) - *dot = '\0'; - hostname = hostname_tmp; - } - } - } - - return client_start( - self, - AF_INET, - multi_idx, - iface, - ifindex, - hwaddr, - bcast_hwaddr, - uuid, - route_table, - route_metric, - NULL, - dhcp_client_id, - FALSE, - 0, - FALSE, - timeout, - client_flags | (use_fqdn ? NM_DHCP_CLIENT_FLAGS_USE_FQDN : NM_DHCP_CLIENT_FLAGS_NONE), - anycast_address, - hostname, - hostname_flags, - mud_url, - 0, - last_ip_address, - 0, - vendor_class_identifier, - reject_servers, - error); -} - -/* Caller owns a reference to the NMDhcpClient on return */ -NMDhcpClient * -nm_dhcp_manager_start_ip6(NMDhcpManager * self, - NMDedupMultiIndex * multi_idx, - const char * iface, - int ifindex, - const struct in6_addr * ll_addr, - const char * uuid, - guint32 route_table, - guint32 route_metric, - NMDhcpClientFlags client_flags, - gboolean send_hostname, - const char * dhcp_hostname, - NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - GBytes * duid, - gboolean enforce_duid, - guint32 iaid, - gboolean iaid_explicit, - guint32 timeout, - const char * anycast_address, - NMSettingIP6ConfigPrivacy privacy, - guint needed_prefixes, - GError ** error) -{ - NMDhcpManagerPrivate *priv; - const char * hostname = NULL; - - /* this flag is set automatically, and not free to set to the caller. */ - nm_assert(!NM_FLAGS_ANY(client_flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN)); - - g_return_val_if_fail(NM_IS_DHCP_MANAGER(self), NULL); - priv = NM_DHCP_MANAGER_GET_PRIVATE(self); - - if (send_hostname) { - /* Always prefer the explicit dhcp-hostname if given */ - hostname = dhcp_hostname ?: priv->default_hostname; - } - return client_start(self, - AF_INET6, - multi_idx, - iface, - ifindex, - NULL, - NULL, - uuid, - route_table, - route_metric, - ll_addr, - duid, - enforce_duid, - iaid, - iaid_explicit, - timeout, - client_flags | NM_DHCP_CLIENT_FLAGS_USE_FQDN, - anycast_address, - hostname, - hostname_flags, - mud_url, - privacy, - NULL, - needed_prefixes, - NULL, - NULL, - error); -} - -void -nm_dhcp_manager_set_default_hostname(NMDhcpManager *manager, const char *hostname) -{ - NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE(manager); - - nm_clear_g_free(&priv->default_hostname); - - /* Never send 'localhost'-type names to the DHCP server */ - if (!nm_utils_is_specific_hostname(hostname)) - return; - - priv->default_hostname = g_strdup(hostname); -} - const char * nm_dhcp_manager_get_config(NMDhcpManager *self) { @@ -527,37 +265,30 @@ nm_dhcp_manager_init(NMDhcpManager *self) NM_CONFIG_KEYFILE_KEY_MAIN_DHCP, NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); client = client_free; - if (nm_config_get_configure_and_quit(config) == NM_CONFIG_CONFIGURE_AND_QUIT_ENABLED) { - client_factory = &_nm_dhcp_client_factory_internal; - if (client && !nm_streq(client, client_factory->name)) - nm_log_info(LOGD_DHCP, - "dhcp-init: Using internal DHCP client since configure-and-quit is set."); - } else { - if (client) { - client_factory = _client_factory_available(_client_factory_find_by_name(client)); + if (client) { + client_factory = _client_factory_available(_client_factory_find_by_name(client)); + if (!client_factory) + nm_log_warn(LOGD_DHCP, "dhcp-init: DHCP client '%s' not available", client); + } + if (!client_factory) { + client_factory = _client_factory_find_by_name("" NM_CONFIG_DEFAULT_MAIN_DHCP); + if (!client_factory) + nm_log_err(LOGD_DHCP, + "dhcp-init: default DHCP client '%s' is not installed", + NM_CONFIG_DEFAULT_MAIN_DHCP); + else { + client_factory = _client_factory_available(client_factory); if (!client_factory) - nm_log_warn(LOGD_DHCP, "dhcp-init: DHCP client '%s' not available", client); + nm_log_info(LOGD_DHCP, + "dhcp-init: default DHCP client '%s' is not available", + NM_CONFIG_DEFAULT_MAIN_DHCP); } - if (!client_factory) { - client_factory = _client_factory_find_by_name("" NM_CONFIG_DEFAULT_MAIN_DHCP); - if (!client_factory) - nm_log_err(LOGD_DHCP, - "dhcp-init: default DHCP client '%s' is not installed", - NM_CONFIG_DEFAULT_MAIN_DHCP); - else { - client_factory = _client_factory_available(client_factory); - if (!client_factory) - nm_log_info(LOGD_DHCP, - "dhcp-init: default DHCP client '%s' is not available", - NM_CONFIG_DEFAULT_MAIN_DHCP); - } - } - if (!client_factory) { - for (i = 0; i < (int) G_N_ELEMENTS(_nm_dhcp_manager_factories); i++) { - client_factory = _client_factory_available(_nm_dhcp_manager_factories[i]); - if (client_factory) - break; - } + } + if (!client_factory) { + for (i = 0; i < (int) G_N_ELEMENTS(_nm_dhcp_manager_factories); i++) { + client_factory = _client_factory_available(_nm_dhcp_manager_factories[i]); + if (client_factory) + break; } } @@ -572,21 +303,6 @@ nm_dhcp_manager_init(NMDhcpManager *self) priv->client_factory = client_factory; } -static void -dispose(GObject *object) -{ - NMDhcpManager * self = NM_DHCP_MANAGER(object); - NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE(self); - - G_OBJECT_CLASS(nm_dhcp_manager_parent_class)->dispose(object); - - nm_clear_g_free(&priv->default_hostname); -} - static void nm_dhcp_manager_class_init(NMDhcpManagerClass *manager_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS(manager_class); - - object_class->dispose = dispose; -} +{} diff --git a/src/core/dhcp/nm-dhcp-manager.h b/src/core/dhcp/nm-dhcp-manager.h index ce160437a5..bbd68236a3 100644 --- a/src/core/dhcp/nm-dhcp-manager.h +++ b/src/core/dhcp/nm-dhcp-manager.h @@ -8,7 +8,6 @@ #define __NETWORKMANAGER_DHCP_MANAGER_H__ #include "nm-dhcp-client.h" -#include "nm-ip4-config.h" #include "nm-dhcp-config.h" #define NM_TYPE_DHCP_MANAGER (nm_dhcp_manager_get_type()) @@ -32,51 +31,8 @@ const char *nm_dhcp_manager_get_config(NMDhcpManager *self); void nm_dhcp_manager_set_default_hostname(NMDhcpManager *manager, const char *hostname); -NMDhcpClient *nm_dhcp_manager_start_ip4(NMDhcpManager * manager, - struct _NMDedupMultiIndex *multi_idx, - const char * iface, - int ifindex, - GBytes * hwaddr, - GBytes * bcast_hwaddr, - const char * uuid, - guint32 route_table, - guint32 route_metric, - NMDhcpClientFlags client_flags, - gboolean send_hostname, - const char * dhcp_hostname, - const char * dhcp_fqdn, - NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - GBytes * dhcp_client_id, - guint32 timeout, - const char * anycast_address, - const char * last_ip_address, - GBytes * vendor_class_identifier, - const char *const * reject_servers, - GError ** error); - -NMDhcpClient *nm_dhcp_manager_start_ip6(NMDhcpManager * manager, - struct _NMDedupMultiIndex *multi_idx, - const char * iface, - int ifindex, - const struct in6_addr * ll_addr, - const char * uuid, - guint32 route_table, - guint32 route_metric, - NMDhcpClientFlags client_flags, - gboolean send_hostname, - const char * dhcp_hostname, - NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - GBytes * duid, - gboolean enforce_duid, - guint32 iaid, - gboolean iaid_explicit, - guint32 timeout, - const char * anycast_address, - NMSettingIP6ConfigPrivacy privacy, - guint needed_prefixes, - GError ** error); +NMDhcpClient * +nm_dhcp_manager_start_client(NMDhcpManager *manager, NMDhcpClientConfig *config, GError **error); /* For testing only */ extern const char *nm_dhcp_helper_path; diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c index 56b485dd25..6ab7f8c18d 100644 --- a/src/core/dhcp/nm-dhcp-nettools.c +++ b/src/core/dhcp/nm-dhcp-nettools.c @@ -17,6 +17,7 @@ #include "libnm-std-aux/unaligned.h" #include "libnm-glib-aux/nm-str-buf.h" +#include "nm-l3-config-data.h" #include "nm-utils.h" #include "nm-config.h" #include "nm-dhcp-utils.h" @@ -151,7 +152,7 @@ lease_option_consume_route(const uint8_t **datap, static gboolean lease_parse_address(NDhcp4ClientLease *lease, - NMIP4Config * ip4_config, + NML3ConfigData * l3cd, GHashTable * options, GError ** error) { @@ -256,23 +257,23 @@ lease_parse_address(NDhcp4ClientLease *lease, a_next_server.s_addr); } - nm_ip4_config_add_address(ip4_config, - &((const NMPlatformIP4Address){ - .address = a_address.s_addr, - .peer_address = a_address.s_addr, - .plen = a_plen, - .addr_source = NM_IP_CONFIG_SOURCE_DHCP, - .timestamp = a_timestamp, - .lifetime = a_lifetime, - .preferred = a_lifetime, - })); + nm_l3_config_data_add_address_4(l3cd, + &((const NMPlatformIP4Address){ + .address = a_address.s_addr, + .peer_address = a_address.s_addr, + .plen = a_plen, + .addr_source = NM_IP_CONFIG_SOURCE_DHCP, + .timestamp = a_timestamp, + .lifetime = a_lifetime, + .preferred = a_lifetime, + })); return TRUE; } static void lease_parse_address_list(NDhcp4ClientLease * lease, - NMIP4Config * ip4_config, + NML3ConfigData * l3cd, NMDhcpOptionDhcp4Options option, GHashTable * options, NMStrBuf * sbuf) @@ -304,13 +305,13 @@ lease_parse_address_list(NDhcp4ClientLease * lease, * See https://github.com/systemd/systemd/issues/4524. */ continue; } - nm_ip4_config_add_nameserver(ip4_config, addr); + nm_l3_config_data_add_nameserver(l3cd, AF_INET, &addr); break; case NM_DHCP_OPTION_DHCP4_NIS_SERVERS: - nm_ip4_config_add_nis_server(ip4_config, addr); + nm_l3_config_data_add_nis_server(l3cd, addr); break; case NM_DHCP_OPTION_DHCP4_NETBIOS_NAMESERVER: - nm_ip4_config_add_wins(ip4_config, addr); + nm_l3_config_data_add_wins(l3cd, addr); break; case NM_DHCP_OPTION_DHCP4_NTP_SERVER: break; @@ -324,10 +325,8 @@ lease_parse_address_list(NDhcp4ClientLease * lease, static void lease_parse_routes(NDhcp4ClientLease *lease, - NMIP4Config * ip4_config, + NML3ConfigData * l3cd, GHashTable * options, - guint32 route_table, - guint32 route_metric, NMStrBuf * sbuf) { char dest_str[NM_UTILS_INET_ADDRSTRLEN]; @@ -336,9 +335,9 @@ lease_parse_routes(NDhcp4ClientLease *lease, in_addr_t gateway; uint8_t plen; guint32 m; - gboolean has_router_from_classless = FALSE; - gboolean has_classless = FALSE; - guint32 default_route_metric = route_metric; + gboolean has_router_from_classless = FALSE; + gboolean has_classless = FALSE; + guint32 default_route_metric_offset = 0; const guint8 *l_data; gsize l_data_len; int r; @@ -367,26 +366,22 @@ lease_parse_routes(NDhcp4ClientLease *lease, if (plen == 0) { /* if there are multiple default routes, we add them with differing * metrics. */ - m = default_route_metric; - if (default_route_metric < G_MAXUINT32) - default_route_metric++; - + m = default_route_metric_offset++; has_router_from_classless = TRUE; - } else { - m = route_metric; - } + } else + m = 0; - nm_ip4_config_add_route( - ip4_config, - &((const NMPlatformIP4Route){ - .network = dest, - .plen = plen, - .gateway = gateway, - .rt_source = NM_IP_CONFIG_SOURCE_DHCP, - .metric = m, - .table_coerced = nm_platform_route_table_coerce(route_table), - }), - NULL); + nm_l3_config_data_add_route_4(l3cd, + &((const NMPlatformIP4Route){ + .network = dest, + .plen = plen, + .gateway = gateway, + .rt_source = NM_IP_CONFIG_SOURCE_DHCP, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = m, + })); } has_classless = TRUE; @@ -419,17 +414,17 @@ lease_parse_routes(NDhcp4ClientLease *lease, continue; } - nm_ip4_config_add_route( - ip4_config, - &((const NMPlatformIP4Route){ - .network = dest, - .plen = plen, - .gateway = gateway, - .rt_source = NM_IP_CONFIG_SOURCE_DHCP, - .metric = route_metric, - .table_coerced = nm_platform_route_table_coerce(route_table), - }), - NULL); + nm_l3_config_data_add_route_4(l3cd, + &((const NMPlatformIP4Route){ + .network = dest, + .plen = plen, + .gateway = gateway, + .rt_source = NM_IP_CONFIG_SOURCE_DHCP, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, + })); } nm_dhcp_option_add_option(options, @@ -463,19 +458,17 @@ lease_parse_routes(NDhcp4ClientLease *lease, /* if there are multiple default routes, we add them with differing * metrics. */ - m = default_route_metric; - if (default_route_metric < G_MAXUINT32) - default_route_metric++; + m = default_route_metric_offset++; - nm_ip4_config_add_route( - ip4_config, - &((const NMPlatformIP4Route){ - .rt_source = NM_IP_CONFIG_SOURCE_DHCP, - .gateway = gateway, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = m, - }), - NULL); + nm_l3_config_data_add_route_4(l3cd, + &((const NMPlatformIP4Route){ + .rt_source = NM_IP_CONFIG_SOURCE_DHCP, + .gateway = gateway, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = m, + })); } nm_dhcp_option_add_option(options, @@ -486,7 +479,7 @@ lease_parse_routes(NDhcp4ClientLease *lease, } static void -lease_parse_search_domains(NDhcp4ClientLease *lease, NMIP4Config *ip4_config, GHashTable *options) +lease_parse_search_domains(NDhcp4ClientLease *lease, NML3ConfigData *l3cd, GHashTable *options) { gs_strfreev char **domains = NULL; const guint8 * l_data; @@ -504,7 +497,7 @@ lease_parse_search_domains(NDhcp4ClientLease *lease, NMIP4Config *ip4_config, GH return; for (i = 0; domains[i]; i++) - nm_ip4_config_add_search(ip4_config, domains[i]); + nm_l3_config_data_add_search(l3cd, AF_INET, domains[i]); nm_dhcp_option_take_option(options, AF_INET, @@ -539,34 +532,31 @@ lease_parse_private_options(NDhcp4ClientLease *lease, GHashTable *options) } } -static NMIP4Config * +static NML3ConfigData * lease_to_ip4_config(NMDedupMultiIndex *multi_idx, const char * iface, int ifindex, NDhcp4ClientLease *lease, - guint32 route_table, - guint32 route_metric, - GHashTable ** out_options, GError ** error) { - nm_auto_str_buf NMStrBuf sbuf = NM_STR_BUF_INIT(0, FALSE); - gs_unref_object NMIP4Config *ip4_config = NULL; - gs_unref_hashtable GHashTable *options = NULL; + nm_auto_str_buf NMStrBuf sbuf = NM_STR_BUF_INIT(0, FALSE); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_unref_hashtable GHashTable *options = NULL; const guint8 * l_data; gsize l_data_len; const char * v_str; guint16 v_u16; - gboolean v_bool; in_addr_t v_inaddr; struct in_addr v_inaddr_s; int r; g_return_val_if_fail(lease != NULL, NULL); - ip4_config = nm_ip4_config_new(multi_idx, ifindex); - options = nm_dhcp_option_create_options_dict(); + l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_DHCP); - if (!lease_parse_address(lease, ip4_config, options, error)) + options = nm_dhcp_option_create_options_dict(); + + if (!lease_parse_address(lease, l3cd, options, error)) return NULL; r = n_dhcp4_client_lease_get_server_identifier(lease, &v_inaddr_s); @@ -585,13 +575,9 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, v_inaddr); } - lease_parse_routes(lease, ip4_config, options, route_table, route_metric, &sbuf); + lease_parse_routes(lease, l3cd, options, &sbuf); - lease_parse_address_list(lease, - ip4_config, - NM_DHCP_OPTION_DHCP4_DOMAIN_NAME_SERVER, - options, - &sbuf); + lease_parse_address_list(lease, l3cd, NM_DHCP_OPTION_DHCP4_DOMAIN_NAME_SERVER, options, &sbuf); r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_DOMAIN_NAME, &l_data, &l_data_len); if (r == 0 && nm_dhcp_lease_data_parse_cstr(l_data, l_data_len, &l_data_len)) { @@ -616,7 +602,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, nm_str_buf_append_required_delimiter(&sbuf, ' '); nm_str_buf_append(&sbuf, s); - nm_ip4_config_add_domain(ip4_config, s); + nm_l3_config_data_add_domain(l3cd, AF_INET, s); } } @@ -628,18 +614,17 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, } } - lease_parse_search_domains(lease, ip4_config, options); + lease_parse_search_domains(lease, l3cd, options); r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_INTERFACE_MTU, &l_data, &l_data_len); if (r == 0 && nm_dhcp_lease_data_parse_mtu(l_data, l_data_len, &v_u16)) { nm_dhcp_option_add_option_u64(options, AF_INET, NM_DHCP_OPTION_DHCP4_INTERFACE_MTU, v_u16); - nm_ip4_config_set_mtu(ip4_config, v_u16, NM_IP_CONFIG_SOURCE_DHCP); + nm_l3_config_data_set_mtu(l3cd, v_u16); } r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_VENDOR_SPECIFIC, &l_data, &l_data_len); - v_bool = - (r == 0) && memmem(l_data, l_data_len, "ANDROID_METERED", NM_STRLEN("ANDROID_METERED")); - nm_ip4_config_set_metered(ip4_config, v_bool); + if ((r == 0) && memmem(l_data, l_data_len, "ANDROID_METERED", NM_STRLEN("ANDROID_METERED"))) + nm_l3_config_data_set_metered(l3cd, TRUE); r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_HOST_NAME, &l_data, &l_data_len); if (r == 0) { @@ -650,7 +635,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, } } - lease_parse_address_list(lease, ip4_config, NM_DHCP_OPTION_DHCP4_NTP_SERVER, options, &sbuf); + lease_parse_address_list(lease, l3cd, NM_DHCP_OPTION_DHCP4_NTP_SERVER, options, &sbuf); r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_ROOT_PATH, &l_data, &l_data_len); if (r == 0 && nm_dhcp_lease_data_parse_cstr(l_data, l_data_len, &l_data_len)) { @@ -681,11 +666,17 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, * We reject NUL characters inside the string (except trailing NULs). * Otherwise, we allow any encoding and backslash-escape the result to * UTF-8. */ - nm_dhcp_option_add_option_utf8safe_escape(options, - AF_INET, - NM_DHCP_OPTION_DHCP4_PRIVATE_PROXY_AUTODISCOVERY, - l_data, - l_data_len); + gs_free char *to_free = NULL; + const char * escaped; + + escaped = nm_utils_buf_utf8safe_escape((char *) l_data, l_data_len, 0, &to_free); + nm_dhcp_option_add_option(options, + AF_INET, + NM_DHCP_OPTION_DHCP4_PRIVATE_PROXY_AUTODISCOVERY, + escaped ?: ""); + + nm_l3_config_data_set_proxy_method(l3cd, NM_PROXY_CONFIG_METHOD_AUTO); + nm_l3_config_data_set_proxy_pac_url(l3cd, escaped ?: ""); } r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_NIS_DOMAIN, &l_data, &l_data_len); @@ -700,7 +691,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, &to_free); nm_dhcp_option_add_option(options, AF_INET, NM_DHCP_OPTION_DHCP4_NIS_DOMAIN, v_str ?: ""); - nm_ip4_config_set_nis_domain(ip4_config, v_str ?: ""); + nm_l3_config_data_set_nis_domain(l3cd, v_str ?: ""); } r = n_dhcp4_client_lease_get_file(lease, &v_str); @@ -728,18 +719,17 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, v_str ?: ""); } - lease_parse_address_list(lease, ip4_config, NM_DHCP_OPTION_DHCP4_NIS_SERVERS, options, &sbuf); + lease_parse_address_list(lease, l3cd, NM_DHCP_OPTION_DHCP4_NIS_SERVERS, options, &sbuf); - lease_parse_address_list(lease, - ip4_config, - NM_DHCP_OPTION_DHCP4_NETBIOS_NAMESERVER, - options, - &sbuf); + lease_parse_address_list(lease, l3cd, NM_DHCP_OPTION_DHCP4_NETBIOS_NAMESERVER, options, &sbuf); lease_parse_private_options(lease, options); - NM_SET_OUT(out_options, g_steal_pointer(&options)); - return g_steal_pointer(&ip4_config); + nm_dhcp_option_add_requests_to_options(options, AF_INET); + + nm_l3_config_data_set_dhcp_lease_from_options(l3cd, AF_INET, g_steal_pointer(&options)); + + return g_steal_pointer(&l3cd); } /*****************************************************************************/ @@ -771,47 +761,44 @@ lease_save(NMDhcpNettools *self, NDhcp4ClientLease *lease, const char *lease_fil static void bound4_handle(NMDhcpNettools *self, NDhcp4ClientLease *lease, gboolean extended) { - NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); - const char * iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); - gs_unref_object NMIP4Config *ip4_config = NULL; - gs_unref_hashtable GHashTable *options = NULL; - GError * error = NULL; + NMDhcpNettoolsPrivate * priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); + NMDhcpClient * client = NM_DHCP_CLIENT(self); + const NMDhcpClientConfig *client_config; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + GError * error = NULL; _LOGT("lease available (%s)", extended ? "extended" : "new"); - - ip4_config = lease_to_ip4_config(nm_dhcp_client_get_multi_idx(NM_DHCP_CLIENT(self)), - iface, - nm_dhcp_client_get_ifindex(NM_DHCP_CLIENT(self)), - lease, - nm_dhcp_client_get_route_table(NM_DHCP_CLIENT(self)), - nm_dhcp_client_get_route_metric(NM_DHCP_CLIENT(self)), - &options, - &error); - if (!ip4_config) { - _LOGW("%s", error->message); + client_config = nm_dhcp_client_get_config(client); + l3cd = lease_to_ip4_config(nm_dhcp_client_get_multi_idx(client), + client_config->iface, + nm_dhcp_client_get_ifindex(client), + lease, + &error); + if (!l3cd) { + _LOGW("failure to parse lease: %s", error->message); g_clear_error(&error); - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL); return; } - nm_dhcp_option_add_requests_to_options(options, AF_INET); lease_save(self, lease, priv->lease_file); nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), extended ? NM_DHCP_STATE_EXTENDED : NM_DHCP_STATE_BOUND, - NM_IP_CONFIG_CAST(ip4_config), - options); + l3cd); } static void dhcp4_event_handle(NMDhcpNettools *self, NDhcp4ClientEvent *event) { - NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); - struct in_addr server_id; - char addr_str[INET_ADDRSTRLEN]; - int r; + NMDhcpNettoolsPrivate * priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); + const NMDhcpClientConfig *client_config; + struct in_addr server_id; + char addr_str[INET_ADDRSTRLEN]; + int r; _LOGT("client event %d", event->event); + client_config = nm_dhcp_client_get_config(NM_DHCP_CLIENT(self)); switch (event->event) { case N_DHCP4_CLIENT_EVENT_OFFER: @@ -835,10 +822,10 @@ dhcp4_event_handle(NMDhcpNettools *self, NDhcp4ClientEvent *event) break; case N_DHCP4_CLIENT_EVENT_RETRACTED: case N_DHCP4_CLIENT_EVENT_EXPIRED: - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_EXPIRE, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_EXPIRE, NULL); break; case N_DHCP4_CLIENT_EVENT_CANCELLED: - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL); break; case N_DHCP4_CLIENT_EVENT_GRANTED: priv->lease = n_dhcp4_client_lease_ref(event->granted.lease); @@ -861,7 +848,7 @@ dhcp4_event_handle(NMDhcpNettools *self, NDhcp4ClientEvent *event) NULL, NULL, "dhcp4 (%s): %s", - nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)), + client_config->iface, event->log.message); } } break; @@ -890,13 +877,12 @@ dhcp4_event_cb(int fd, GIOCondition condition, gpointer user_data) */ _LOGE("error %d dispatching events", r); nm_clear_g_source_inst(&priv->event_source); - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL); return G_SOURCE_REMOVE; } - while (!n_dhcp4_client_pop_event(priv->client, &event) && event) { + while (!n_dhcp4_client_pop_event(priv->client, &event) && event) dhcp4_event_handle(self, event); - } return G_SOURCE_CONTINUE; } @@ -914,23 +900,26 @@ nettools_create(NMDhcpNettools *self, GError **error) gsize hwaddr_len; gsize bcast_hwaddr_len; GBytes * client_id; - gs_unref_bytes GBytes *client_id_new = NULL; - const uint8_t * client_id_arr; - size_t client_id_len; - int r, fd, arp_type, transport; + gs_unref_bytes GBytes * client_id_new = NULL; + const uint8_t * client_id_arr; + size_t client_id_len; + int r, fd, arp_type, transport; + const NMDhcpClientConfig *client_config; + + client_config = nm_dhcp_client_get_config(NM_DHCP_CLIENT(self)); g_return_val_if_fail(!priv->client, FALSE); /* TODO: honor nm_dhcp_client_get_anycast_address() */ - hwaddr = nm_dhcp_client_get_hw_addr(NM_DHCP_CLIENT(self)); + hwaddr = client_config->hwaddr; if (!hwaddr || !(hwaddr_arr = g_bytes_get_data(hwaddr, &hwaddr_len)) || (arp_type = nm_utils_arp_type_detect_from_hwaddrlen(hwaddr_len)) < 0) { nm_utils_error_set_literal(error, NM_UTILS_ERROR_UNKNOWN, "invalid MAC address"); return FALSE; } - bcast_hwaddr = nm_dhcp_client_get_broadcast_hw_addr(NM_DHCP_CLIENT(self)); + bcast_hwaddr = client_config->bcast_hwaddr; bcast_hwaddr_arr = g_bytes_get_data(bcast_hwaddr, &bcast_hwaddr_len); switch (arp_type) { @@ -947,7 +936,7 @@ nettools_create(NMDhcpNettools *self, GError **error) /* Note that we always set a client-id. In particular for infiniband that is necessary, * see https://tools.ietf.org/html/rfc4390#section-2.1 . */ - client_id = nm_dhcp_client_get_client_id(NM_DHCP_CLIENT(self)); + client_id = client_config->client_id; if (!client_id) { client_id_new = nm_utils_dhcp_client_id_mac(arp_type, hwaddr_arr, hwaddr_len); client_id = client_id_new; @@ -971,10 +960,7 @@ nettools_create(NMDhcpNettools *self, GError **error) n_dhcp4_client_config_set_transport(config, transport); n_dhcp4_client_config_set_mac(config, hwaddr_arr, hwaddr_len); n_dhcp4_client_config_set_broadcast_mac(config, bcast_hwaddr_arr, bcast_hwaddr_len); - n_dhcp4_client_config_set_request_broadcast( - config, - NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(NM_DHCP_CLIENT(self)), - NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST)); + n_dhcp4_client_config_set_request_broadcast(config, client_config->v4.request_broadcast); r = n_dhcp4_client_config_set_client_id(config, client_id_arr, NM_MIN(client_id_len, 1 + _NM_MAX_CLIENT_ID_LEN)); @@ -1033,7 +1019,7 @@ decline(NMDhcpClient *client, const char *error_message, GError **error) g_return_val_if_fail(priv->lease, FALSE); - _LOGT("dhcp4-client: decline"); + _LOGT("dhcp4-client: decline (%s)", error_message); r = n_dhcp4_client_lease_decline(priv->lease, error_message); if (r) { @@ -1063,19 +1049,20 @@ fqdn_flags_to_wire(NMDhcpHostnameFlags flags) } static gboolean -ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) +ip4_start(NMDhcpClient *client, GError **error) { nm_auto(n_dhcp4_client_probe_config_freep) NDhcp4ClientProbeConfig *config = NULL; - NMDhcpNettools * self = NM_DHCP_NETTOOLS(client); - NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); - gs_free char * lease_file = NULL; - struct in_addr last_addr = {0}; - const char * hostname; - const char * mud_url; - GBytes * vendor_class_identifier; - int r, i; + NMDhcpNettools * self = NM_DHCP_NETTOOLS(client); + NMDhcpNettoolsPrivate * priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); + const NMDhcpClientConfig *client_config; + gs_free char * lease_file = NULL; + struct in_addr last_addr = {0}; + int r, i; + + client_config = nm_dhcp_client_get_config(client); g_return_val_if_fail(!priv->probe, FALSE); + g_return_val_if_fail(client_config, FALSE); if (!nettools_create(self, error)) return FALSE; @@ -1094,12 +1081,12 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) nm_dhcp_utils_get_leasefile_path(AF_INET, "internal", - nm_dhcp_client_get_iface(client), - nm_dhcp_client_get_uuid(client), + client_config->iface, + client_config->uuid, &lease_file); - if (last_ip4_address) - inet_pton(AF_INET, last_ip4_address, &last_addr); + if (client_config->v4.last_address) + inet_pton(AF_INET, client_config->v4.last_address, &last_addr); else { /* * TODO: we stick to the systemd-networkd lease file format. Quite easy for now to @@ -1129,31 +1116,33 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } } - mud_url = nm_dhcp_client_get_mud_url(client); - if (mud_url) { + if (client_config->mud_url) { r = n_dhcp4_client_probe_config_append_option(config, NM_DHCP_OPTION_DHCP4_MUD_URL, - mud_url, - strlen(mud_url)); + client_config->mud_url, + strlen(client_config->mud_url)); if (r) { set_error_nettools(error, r, "failed to set MUD URL"); return FALSE; } } - hostname = nm_dhcp_client_get_hostname(client); - if (hostname) { - if (NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), NM_DHCP_CLIENT_FLAGS_USE_FQDN)) { + + if (client_config->hostname) { + if (client_config->use_fqdn) { uint8_t buffer[255]; NMDhcpHostnameFlags flags; size_t fqdn_len; - flags = nm_dhcp_client_get_hostname_flags(client); + flags = client_config->hostname_flags; buffer[0] = fqdn_flags_to_wire(flags); buffer[1] = 0; /* RCODE1 (deprecated) */ buffer[2] = 0; /* RCODE2 (deprecated) */ if (flags & NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED) { - r = nm_sd_dns_name_to_wire_format(hostname, buffer + 3, sizeof(buffer) - 3, FALSE); + r = nm_sd_dns_name_to_wire_format(client_config->hostname, + buffer + 3, + sizeof(buffer) - 3, + FALSE); if (r <= 0) { if (r < 0) nm_utils_error_set_errno(error, r, "failed to convert DHCP FQDN: %s"); @@ -1163,12 +1152,12 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } fqdn_len = r; } else { - fqdn_len = strlen(hostname); + fqdn_len = strlen(client_config->hostname); if (fqdn_len > sizeof(buffer) - 3) { nm_utils_error_set(error, r, "failed to set DHCP FQDN: name too long"); return FALSE; } - memcpy(buffer + 3, hostname, fqdn_len); + memcpy(buffer + 3, client_config->hostname, fqdn_len); } r = n_dhcp4_client_probe_config_append_option(config, @@ -1182,8 +1171,8 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } else { r = n_dhcp4_client_probe_config_append_option(config, NM_DHCP_OPTION_DHCP4_HOST_NAME, - hostname, - strlen(hostname)); + client_config->hostname, + strlen(client_config->hostname)); if (r) { set_error_nettools(error, r, "failed to set DHCP hostname"); return FALSE; @@ -1191,12 +1180,11 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } } - vendor_class_identifier = nm_dhcp_client_get_vendor_class_identifier(client); - if (vendor_class_identifier) { + if (client_config->vendor_class_identifier) { const void *option_data; gsize option_size; - option_data = g_bytes_get_data(vendor_class_identifier, &option_size); + option_data = g_bytes_get_data(client_config->vendor_class_identifier, &option_size); nm_assert(option_data); nm_assert(option_size <= 255); diff --git a/src/core/dhcp/nm-dhcp-systemd.c b/src/core/dhcp/nm-dhcp-systemd.c index af1d2238b4..f5b75b50de 100644 --- a/src/core/dhcp/nm-dhcp-systemd.c +++ b/src/core/dhcp/nm-dhcp-systemd.c @@ -17,6 +17,7 @@ #include "libnm-std-aux/unaligned.h" #include "nm-utils.h" +#include "nm-l3-config-data.h" #include "nm-dhcp-utils.h" #include "nm-dhcp-options.h" #include "nm-core-utils.h" @@ -51,8 +52,6 @@ typedef struct { char * lease_file; guint request_count; - - bool privacy : 1; } NMDhcpSystemdPrivate; struct _NMDhcpSystemd { @@ -70,18 +69,15 @@ G_DEFINE_TYPE(NMDhcpSystemd, nm_dhcp_systemd, NM_TYPE_DHCP_CLIENT) /*****************************************************************************/ -static NMIP4Config * +static NML3ConfigData * lease_to_ip4_config(NMDedupMultiIndex *multi_idx, const char * iface, int ifindex, sd_dhcp_lease * lease, - guint32 route_table, - guint32 route_metric, - GHashTable ** out_options, GError ** error) { - gs_unref_object NMIP4Config *ip4_config = NULL; - gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_unref_hashtable GHashTable *options = NULL; const struct in_addr * addr_list; char addr_str[NM_UTILS_INET_ADDRSTRLEN]; const char * s; @@ -92,7 +88,6 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, int i, num; const void * data; gsize data_len; - gboolean metered = FALSE; gboolean has_router_from_classless = FALSE; gboolean has_classless_route = FALSE; gboolean has_static_route = FALSE; @@ -133,9 +128,9 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, return NULL; } - ip4_config = nm_ip4_config_new(multi_idx, ifindex); + l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_DHCP); - options = out_options ? nm_dhcp_option_create_options_dict() : NULL; + options = nm_dhcp_option_create_options_dict(); _nm_utils_inet4_ntop(a_address.s_addr, addr_str); nm_dhcp_option_add_option(options, AF_INET, NM_DHCP_OPTION_DHCP4_NM_IP_ADDRESS, addr_str); @@ -160,16 +155,16 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, nm_dhcp_option_add_option(options, AF_INET, NM_DHCP_OPTION_DHCP4_NM_NEXT_SERVER, addr_str); } - nm_ip4_config_add_address(ip4_config, - &((const NMPlatformIP4Address){ - .address = a_address.s_addr, - .peer_address = a_address.s_addr, - .plen = a_plen, - .addr_source = NM_IP_CONFIG_SOURCE_DHCP, - .timestamp = ts, - .lifetime = a_lifetime, - .preferred = a_lifetime, - })); + nm_l3_config_data_add_address_4(l3cd, + &((const NMPlatformIP4Address){ + .address = a_address.s_addr, + .peer_address = a_address.s_addr, + .plen = a_plen, + .addr_source = NM_IP_CONFIG_SOURCE_DHCP, + .timestamp = ts, + .lifetime = a_lifetime, + .preferred = a_lifetime, + })); if (sd_dhcp_lease_get_server_identifier(lease, &server_id) >= 0) { _nm_utils_inet4_ntop(server_id.s_addr, addr_str); @@ -193,7 +188,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, * See https://github.com/systemd/systemd/issues/4524. */ continue; } - nm_ip4_config_add_nameserver(ip4_config, addr_list[i].s_addr); + nm_l3_config_data_add_nameserver(l3cd, AF_INET, &addr_list[i].s_addr); } nm_dhcp_option_add_option(options, AF_INET, @@ -206,7 +201,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, nm_gstring_prepare(&str); for (i = 0; i < num; i++) { g_string_append(nm_gstring_add_space_delimiter(str), search_domains[i]); - nm_ip4_config_add_search(ip4_config, search_domains[i]); + nm_l3_config_data_add_search(l3cd, AF_INET, search_domains[i]); } nm_dhcp_option_add_option(options, AF_INET, @@ -224,7 +219,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, * As systemd escapes such characters, split them at \\032. */ domains = g_strsplit(s, "\\032", 0); for (d = domains; *d; d++) - nm_ip4_config_add_domain(ip4_config, *d); + nm_l3_config_data_add_domain(l3cd, AF_INET, *d); } if (sd_dhcp_lease_get_hostname(lease, &s) >= 0) { @@ -233,9 +228,9 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, num = sd_dhcp_lease_get_routes(lease, &routes); if (num > 0) { - nm_auto_free_gstring GString *str_classless = NULL; - nm_auto_free_gstring GString *str_static = NULL; - guint32 default_route_metric = route_metric; + nm_auto_free_gstring GString *str_classless = NULL; + nm_auto_free_gstring GString *str_static = NULL; + guint32 default_route_metric_offset = 0; for (i = 0; i < num; i++) { switch (sd_dhcp_route_get_option(routes[i])) { @@ -307,25 +302,22 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, if (r_plen == 0) { /* if there are multiple default routes, we add them with differing * metrics. */ - m = default_route_metric; - if (default_route_metric < G_MAXUINT32) - default_route_metric++; - + m = default_route_metric_offset++; has_router_from_classless = TRUE; } else - m = route_metric; + m = 0; - nm_ip4_config_add_route( - ip4_config, - &((const NMPlatformIP4Route){ - .network = network_net, - .plen = r_plen, - .gateway = r_gateway.s_addr, - .rt_source = NM_IP_CONFIG_SOURCE_DHCP, - .metric = m, - .table_coerced = nm_platform_route_table_coerce(route_table), - }), - NULL); + nm_l3_config_data_add_route_4(l3cd, + &((const NMPlatformIP4Route){ + .network = network_net, + .plen = r_plen, + .gateway = r_gateway.s_addr, + .rt_source = NM_IP_CONFIG_SOURCE_DHCP, + .metric_any = TRUE, + .metric = m, + .table_any = TRUE, + .table_coerced = 0, + })); } if (str_classless && str_classless->len > 0) @@ -342,7 +334,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, num = sd_dhcp_lease_get_router(lease, &a_router); if (num > 0) { - guint32 default_route_metric = route_metric; + guint32 default_route_metric_offset = 0; nm_gstring_prepare(&str); for (i = 0; i < num; i++) { @@ -368,26 +360,24 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, /* if there are multiple default routes, we add them with differing * metrics. */ - m = default_route_metric; - if (default_route_metric < G_MAXUINT32) - default_route_metric++; + m = default_route_metric_offset++; - nm_ip4_config_add_route( - ip4_config, - &((const NMPlatformIP4Route){ - .rt_source = NM_IP_CONFIG_SOURCE_DHCP, - .gateway = a_router[i].s_addr, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = m, - }), - NULL); + nm_l3_config_data_add_route_4(l3cd, + &((const NMPlatformIP4Route){ + .rt_source = NM_IP_CONFIG_SOURCE_DHCP, + .gateway = a_router[i].s_addr, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = m, + })); } nm_dhcp_option_add_option(options, AF_INET, NM_DHCP_OPTION_DHCP4_ROUTER, str->str); } if (sd_dhcp_lease_get_mtu(lease, &mtu) >= 0 && mtu) { nm_dhcp_option_add_option_u64(options, AF_INET, NM_DHCP_OPTION_DHCP4_INTERFACE_MTU, mtu); - nm_ip4_config_set_mtu(ip4_config, mtu, NM_IP_CONFIG_SOURCE_DHCP); + nm_l3_config_data_set_mtu(l3cd, mtu); } num = sd_dhcp_lease_get_ntp(lease, &addr_list); @@ -422,9 +412,10 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, nm_dhcp_option_add_option(options, AF_INET, NM_DHCP_OPTION_DHCP4_NEW_TZDB_TIMEZONE, s); } - if (sd_dhcp_lease_get_vendor_specific(lease, &data, &data_len) >= 0) - metered = !!memmem(data, data_len, "ANDROID_METERED", NM_STRLEN("ANDROID_METERED")); - nm_ip4_config_set_metered(ip4_config, metered); + if (sd_dhcp_lease_get_vendor_specific(lease, &data, &data_len) >= 0) { + if (!!memmem(data, data_len, "ANDROID_METERED", NM_STRLEN("ANDROID_METERED"))) + nm_l3_config_data_set_metered(l3cd, TRUE); + } num = nm_sd_dhcp_lease_get_private_options(lease, &private_options); if (num > 0) { @@ -436,12 +427,18 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, if (code == NM_DHCP_OPTION_DHCP4_PRIVATE_PROXY_AUTODISCOVERY) { if (nm_dhcp_lease_data_parse_cstr(l_data, l_data_len, &l_data_len)) { - nm_dhcp_option_add_option_utf8safe_escape( - options, - AF_INET, - NM_DHCP_OPTION_DHCP4_PRIVATE_PROXY_AUTODISCOVERY, - l_data, - l_data_len); + gs_free char *to_free = NULL; + const char * escaped; + + escaped = + nm_utils_buf_utf8safe_escape((char *) l_data, l_data_len, 0, &to_free); + nm_dhcp_option_add_option(options, + AF_INET, + NM_DHCP_OPTION_DHCP4_PRIVATE_PROXY_AUTODISCOVERY, + escaped ?: ""); + + nm_l3_config_data_set_proxy_method(l3cd, NM_PROXY_CONFIG_METHOD_AUTO); + nm_l3_config_data_set_proxy_pac_url(l3cd, escaped ?: ""); } continue; } @@ -458,8 +455,12 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, nm_dhcp_option_take_option(options, AF_INET, code, option_string); } } - NM_SET_OUT(out_options, g_steal_pointer(&options)); - return g_steal_pointer(&ip4_config); + + nm_dhcp_option_add_requests_to_options(options, AF_INET); + + nm_l3_config_data_set_dhcp_lease_from_options(l3cd, AF_INET, g_steal_pointer(&options)); + + return g_steal_pointer(&l3cd); } /*****************************************************************************/ @@ -467,43 +468,37 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, static void bound4_handle(NMDhcpSystemd *self, gboolean extended) { - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); - const char * iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); - gs_unref_object NMIP4Config *ip4_config = NULL; - gs_unref_hashtable GHashTable *options = NULL; - sd_dhcp_lease * lease = NULL; - GError * error = NULL; + NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); + const char * iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + sd_dhcp_lease * lease = NULL; + GError * error = NULL; if (sd_dhcp_client_get_lease(priv->client4, &lease) < 0 || !lease) { _LOGW("no lease!"); - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL); return; } _LOGD("lease available"); - ip4_config = lease_to_ip4_config(nm_dhcp_client_get_multi_idx(NM_DHCP_CLIENT(self)), - iface, - nm_dhcp_client_get_ifindex(NM_DHCP_CLIENT(self)), - lease, - nm_dhcp_client_get_route_table(NM_DHCP_CLIENT(self)), - nm_dhcp_client_get_route_metric(NM_DHCP_CLIENT(self)), - &options, - &error); - if (!ip4_config) { + l3cd = lease_to_ip4_config(nm_dhcp_client_get_multi_idx(NM_DHCP_CLIENT(self)), + iface, + nm_dhcp_client_get_ifindex(NM_DHCP_CLIENT(self)), + lease, + &error); + if (!l3cd) { _LOGW("%s", error->message); g_clear_error(&error); - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL); return; } - nm_dhcp_option_add_requests_to_options(options, AF_INET); dhcp_lease_save(lease, priv->lease_file); nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), extended ? NM_DHCP_STATE_EXTENDED : NM_DHCP_STATE_BOUND, - NM_IP_CONFIG_CAST(ip4_config), - options); + l3cd); } static int @@ -522,10 +517,10 @@ dhcp_event_cb(sd_dhcp_client *client, int event, gpointer user_data) switch (event) { case SD_DHCP_CLIENT_EVENT_EXPIRED: - nm_dhcp_client_set_state(NM_DHCP_CLIENT(user_data), NM_DHCP_STATE_EXPIRE, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(user_data), NM_DHCP_STATE_EXPIRE, NULL); break; case SD_DHCP_CLIENT_EVENT_STOP: - nm_dhcp_client_set_state(NM_DHCP_CLIENT(user_data), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(user_data), NM_DHCP_STATE_FAIL, NULL); break; case SD_DHCP_CLIENT_EVENT_RENEW: case SD_DHCP_CLIENT_EVENT_IP_CHANGE: @@ -558,11 +553,12 @@ dhcp_event_cb(sd_dhcp_client *client, int event, gpointer user_data) } static gboolean -ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) +ip4_start(NMDhcpClient *client, GError **error) { - nm_auto(sd_dhcp_client_unrefp) sd_dhcp_client *sd_client = NULL; - NMDhcpSystemd * self = NM_DHCP_SYSTEMD(client); - NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); + nm_auto(sd_dhcp_client_unrefp) sd_dhcp_client *sd_client = NULL; + NMDhcpSystemd * self = NM_DHCP_SYSTEMD(client); + NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); + const NMDhcpClientConfig * client_config; gs_free char * lease_file = NULL; GBytes * hwaddr; const uint8_t * hwaddr_arr; @@ -584,6 +580,8 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) g_return_val_if_fail(!priv->client4, FALSE); g_return_val_if_fail(!priv->client6, FALSE); + client_config = nm_dhcp_client_get_config(client); + /* TODO: honor nm_dhcp_client_get_anycast_address() */ r = sd_dhcp_client_new(&sd_client, FALSE); @@ -600,7 +598,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) return FALSE; } - hwaddr = nm_dhcp_client_get_hw_addr(client); + hwaddr = client_config->hwaddr; if (!hwaddr || !(hwaddr_arr = g_bytes_get_data(hwaddr, &hwaddr_len)) || (arp_type = nm_utils_arp_type_detect_from_hwaddrlen(hwaddr_len)) < 0) { nm_utils_error_set_literal(error, NM_UTILS_ERROR_UNKNOWN, "invalid MAC address"); @@ -608,7 +606,8 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } bcast_hwaddr_arr = NULL; - if ((bcast_hwaddr = nm_dhcp_client_get_broadcast_hw_addr(NM_DHCP_CLIENT(self)))) { + bcast_hwaddr = client_config->bcast_hwaddr; + if (bcast_hwaddr) { bcast_hwaddr_arr = g_bytes_get_data(bcast_hwaddr, &bcast_hwaddr_len); if (bcast_hwaddr_len != hwaddr_len) bcast_hwaddr_arr = NULL; @@ -632,12 +631,12 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) nm_dhcp_utils_get_leasefile_path(AF_INET, "internal", - nm_dhcp_client_get_iface(client), - nm_dhcp_client_get_uuid(client), + client_config->iface, + client_config->uuid, &lease_file); - if (last_ip4_address) - inet_pton(AF_INET, last_ip4_address, &last_addr); + if (client_config->v4.last_address) + inet_pton(AF_INET, client_config->v4.last_address, &last_addr); else { nm_auto(sd_dhcp_lease_unrefp) sd_dhcp_lease *lease = NULL; @@ -646,9 +645,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) sd_dhcp_lease_get_address(lease, &last_addr); } - r = sd_dhcp_client_set_request_broadcast(sd_client, - NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), - NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST)); + r = sd_dhcp_client_set_request_broadcast(sd_client, client_config->v4.request_broadcast); nm_assert(r >= 0); if (last_addr.s_addr) { @@ -659,7 +656,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } } - client_id = nm_dhcp_client_get_client_id(client); + client_id = client_config->client_id; if (!client_id) { client_id_new = nm_utils_dhcp_client_id_mac(arp_type, hwaddr_arr, hwaddr_len); client_id = client_id_new; @@ -694,7 +691,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } } - hostname = nm_dhcp_client_get_hostname(client); + hostname = client_config->hostname; if (hostname) { /* FIXME: sd-dhcp decides which hostname/FQDN option to send (12 or 81) * only based on whether the hostname has a domain part or not. At the @@ -707,7 +704,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } } - mud_url = nm_dhcp_client_get_mud_url(client); + mud_url = client_config->mud_url; if (mud_url) { r = sd_dhcp_client_set_mud_url(sd_client, mud_url); if (r < 0) { @@ -716,7 +713,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) } } - vendor_class_identifier = nm_dhcp_client_get_vendor_class_identifier(client); + vendor_class_identifier = client_config->vendor_class_identifier; if (vendor_class_identifier) { const char *option_data; gsize len; @@ -745,7 +742,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) g_free(priv->lease_file); priv->lease_file = g_steal_pointer(&lease_file); - nm_dhcp_client_set_client_id(client, client_id); + nm_dhcp_client_set_effective_client_id(client, client_id); r = sd_dhcp_client_start(priv->client4); if (r < 0) { @@ -759,32 +756,32 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) return TRUE; } -static NMIP6Config * +static NML3ConfigData * lease_to_ip6_config(NMDedupMultiIndex *multi_idx, const char * iface, int ifindex, sd_dhcp6_lease * lease, gboolean info_only, - GHashTable ** out_options, gint32 ts, GError ** error) { - gs_unref_object NMIP6Config *ip6_config = NULL; - gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_unref_hashtable GHashTable *options = NULL; struct in6_addr tmp_addr; const struct in6_addr * dns; uint32_t lft_pref, lft_valid; char addr_str[NM_UTILS_INET_ADDRSTRLEN]; char ** domains; const char * s; - nm_auto_free_gstring GString *str = NULL; + nm_auto_free_gstring GString *str = NULL; + gboolean has_any_addresses = FALSE; int num, i; nm_assert(lease); - ip6_config = nm_ip6_config_new(multi_idx, ifindex); + l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_DHCP); - options = out_options ? nm_dhcp_option_create_options_dict() : NULL; + options = nm_dhcp_option_create_options_dict(); sd_dhcp6_lease_reset_address_iter(lease); nm_gstring_prepare(&str); @@ -798,15 +795,19 @@ lease_to_ip6_config(NMDedupMultiIndex *multi_idx, .addr_source = NM_IP_CONFIG_SOURCE_DHCP, }; - nm_ip6_config_add_address(ip6_config, &address); + nm_l3_config_data_add_address_6(l3cd, &address); _nm_utils_inet6_ntop(&tmp_addr, addr_str); g_string_append(nm_gstring_add_space_delimiter(str), addr_str); - }; - if (str->len) - nm_dhcp_option_add_option(options, AF_INET6, NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS, str->str); - if (!info_only && nm_ip6_config_get_num_addresses(ip6_config) == 0) { + has_any_addresses = TRUE; + } + + if (str->len) { + nm_dhcp_option_add_option(options, AF_INET6, NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS, str->str); + } + + if (!info_only && !has_any_addresses) { g_set_error_literal(error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, @@ -820,7 +821,7 @@ lease_to_ip6_config(NMDedupMultiIndex *multi_idx, for (i = 0; i < num; i++) { _nm_utils_inet6_ntop(&dns[i], addr_str); g_string_append(nm_gstring_add_space_delimiter(str), addr_str); - nm_ip6_config_add_nameserver(ip6_config, &dns[i]); + nm_l3_config_data_add_nameserver(l3cd, AF_INET6, &dns[i]); } nm_dhcp_option_add_option(options, AF_INET6, NM_DHCP_OPTION_DHCP6_DNS_SERVERS, str->str); } @@ -830,7 +831,7 @@ lease_to_ip6_config(NMDedupMultiIndex *multi_idx, nm_gstring_prepare(&str); for (i = 0; i < num; i++) { g_string_append(nm_gstring_add_space_delimiter(str), domains[i]); - nm_ip6_config_add_search(ip6_config, domains[i]); + nm_l3_config_data_add_search(l3cd, AF_INET6, domains[i]); } nm_dhcp_option_add_option(options, AF_INET6, NM_DHCP_OPTION_DHCP6_DOMAIN_LIST, str->str); } @@ -839,51 +840,48 @@ lease_to_ip6_config(NMDedupMultiIndex *multi_idx, nm_dhcp_option_add_option(options, AF_INET6, NM_DHCP_OPTION_DHCP6_FQDN, s); } - NM_SET_OUT(out_options, g_steal_pointer(&options)); - return g_steal_pointer(&ip6_config); + nm_l3_config_data_set_dhcp_lease_from_options(l3cd, AF_INET6, g_steal_pointer(&options)); + + return g_steal_pointer(&l3cd); } static void bound6_handle(NMDhcpSystemd *self) { - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); - const gint32 ts = nm_utils_get_monotonic_timestamp_sec(); - const char * iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); - gs_unref_object NMIP6Config *ip6_config = NULL; - gs_unref_hashtable GHashTable *options = NULL; - gs_free_error GError *error = NULL; - NMPlatformIP6Address prefix = {0}; - sd_dhcp6_lease * lease = NULL; + NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); + const gint32 ts = nm_utils_get_monotonic_timestamp_sec(); + const char * iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); + const NMDhcpClientConfig *client_config; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_free_error GError *error = NULL; + NMPlatformIP6Address prefix = {0}; + sd_dhcp6_lease * lease = NULL; + + client_config = nm_dhcp_client_get_config(NM_DHCP_CLIENT(self)); if (sd_dhcp6_client_get_lease(priv->client6, &lease) < 0 || !lease) { _LOGW(" no lease!"); - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL); return; } _LOGD("lease available"); - ip6_config = - lease_to_ip6_config(nm_dhcp_client_get_multi_idx(NM_DHCP_CLIENT(self)), - iface, - nm_dhcp_client_get_ifindex(NM_DHCP_CLIENT(self)), - lease, - NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(NM_DHCP_CLIENT(self)), - NM_DHCP_CLIENT_FLAGS_INFO_ONLY), - &options, - ts, - &error); + l3cd = lease_to_ip6_config(nm_dhcp_client_get_multi_idx(NM_DHCP_CLIENT(self)), + iface, + nm_dhcp_client_get_ifindex(NM_DHCP_CLIENT(self)), + lease, + client_config->v6.info_only, + ts, + &error); - if (!ip6_config) { + if (!l3cd) { _LOGW("%s", error->message); - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_FAIL, NULL); return; } - nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), - NM_DHCP_STATE_BOUND, - NM_IP_CONFIG_CAST(ip6_config), - options); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(self), NM_DHCP_STATE_BOUND, l3cd); sd_dhcp6_lease_reset_pd_prefix_iter(lease); while (!sd_dhcp6_lease_get_pd(lease, @@ -908,11 +906,11 @@ dhcp6_event_cb(sd_dhcp6_client *client, int event, gpointer user_data) switch (event) { case SD_DHCP6_CLIENT_EVENT_RETRANS_MAX: - nm_dhcp_client_set_state(NM_DHCP_CLIENT(user_data), NM_DHCP_STATE_TIMEOUT, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(user_data), NM_DHCP_STATE_TIMEOUT, NULL); break; case SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE: case SD_DHCP6_CLIENT_EVENT_STOP: - nm_dhcp_client_set_state(NM_DHCP_CLIENT(user_data), NM_DHCP_STATE_FAIL, NULL, NULL); + nm_dhcp_client_set_state(NM_DHCP_CLIENT(user_data), NM_DHCP_STATE_FAIL, NULL); break; case SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE: case SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST: @@ -925,15 +923,12 @@ dhcp6_event_cb(sd_dhcp6_client *client, int event, gpointer user_data) } static gboolean -ip6_start(NMDhcpClient * client, - const struct in6_addr * ll_addr, - NMSettingIP6ConfigPrivacy privacy, - guint needed_prefixes, - GError ** error) +ip6_start(NMDhcpClient *client, const struct in6_addr *ll_addr, GError **error) { NMDhcpSystemd * self = NM_DHCP_SYSTEMD(client); NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); nm_auto(sd_dhcp6_client_unrefp) sd_dhcp6_client *sd_client = NULL; + const NMDhcpClientConfig * client_config; const char * hostname; const char * mud_url; int r, i; @@ -944,10 +939,12 @@ ip6_start(NMDhcpClient * client, g_return_val_if_fail(!priv->client4, FALSE); g_return_val_if_fail(!priv->client6, FALSE); + client_config = nm_dhcp_client_get_config(client); + /* TODO: honor nm_dhcp_client_get_anycast_address() */ - if (!(duid = nm_dhcp_client_get_client_id(client)) - || !(duid_arr = g_bytes_get_data(duid, &duid_len)) || duid_len < 2) { + duid = nm_dhcp_client_get_effective_client_id(client); + if (!duid || !(duid_arr = g_bytes_get_data(duid, &duid_len)) || duid_len < 2) { nm_utils_error_set_literal(error, NM_UTILS_ERROR_UNKNOWN, "missing DUID"); g_return_val_if_reached(FALSE); } @@ -960,13 +957,13 @@ ip6_start(NMDhcpClient * client, _LOGT("dhcp-client6: set %p", sd_client); - if (NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), NM_DHCP_CLIENT_FLAGS_INFO_ONLY)) { + if (client_config->v6.info_only) { sd_dhcp6_client_set_address_request(sd_client, 0); - if (needed_prefixes == 0) + if (client_config->v6.needed_prefixes == 0) sd_dhcp6_client_set_information_request(sd_client, 1); } - r = sd_dhcp6_client_set_iaid(sd_client, nm_dhcp_client_get_iaid(client)); + r = sd_dhcp6_client_set_iaid(sd_client, client_config->v6.iaid); if (r < 0) { nm_utils_error_set_errno(error, r, "failed to set IAID: %s"); return FALSE; @@ -1002,7 +999,7 @@ ip6_start(NMDhcpClient * client, } } - mud_url = nm_dhcp_client_get_mud_url(client); + mud_url = client_config->mud_url; if (mud_url) { r = sd_dhcp6_client_set_request_mud_url(sd_client, mud_url); if (r < 0) { @@ -1011,8 +1008,8 @@ ip6_start(NMDhcpClient * client, } } - if (needed_prefixes > 0) { - if (needed_prefixes > 1) + if (client_config->v6.needed_prefixes > 0) { + if (client_config->v6.needed_prefixes > 1) _LOGW("dhcp-client6: only one prefix request is supported"); /* FIXME: systemd-networkd API only allows to request a * single prefix */ @@ -1029,7 +1026,7 @@ ip6_start(NMDhcpClient * client, return FALSE; } - hostname = nm_dhcp_client_get_hostname(client); + hostname = client_config->hostname; r = sd_dhcp6_client_set_fqdn(sd_client, hostname); if (r < 0) { nm_utils_error_set_errno(error, r, "failed to set DHCP hostname: %s"); diff --git a/src/core/dhcp/nm-dhcp-utils.c b/src/core/dhcp/nm-dhcp-utils.c index 3cc6987ada..b1ff1b97a9 100644 --- a/src/core/dhcp/nm-dhcp-utils.c +++ b/src/core/dhcp/nm-dhcp-utils.c @@ -14,6 +14,7 @@ #include "libnm-systemd-shared/nm-sd-utils-shared.h" #include "nm-dhcp-utils.h" +#include "nm-l3-config-data.h" #include "nm-utils.h" #include "nm-config.h" #include "NetworkManagerUtils.h" @@ -24,12 +25,10 @@ /*****************************************************************************/ static gboolean -ip4_process_dhcpcd_rfc3442_routes(const char * iface, - const char * str, - guint32 route_table, - guint32 route_metric, - NMIP4Config *ip4_config, - guint32 * gwaddr) +ip4_process_dhcpcd_rfc3442_routes(const char * iface, + const char * str, + NML3ConfigData *l3cd, + guint32 * gwaddr) { gs_free const char **routes = NULL; const char ** r; @@ -45,10 +44,9 @@ ip4_process_dhcpcd_rfc3442_routes(const char * iface, } for (r = routes; *r; r += 2) { - char * slash; - NMPlatformIP4Route route; - int rt_cidr = 32; - guint32 rt_addr, rt_route; + char * slash; + int rt_cidr = 32; + guint32 rt_addr, rt_route; slash = strchr(*r, '/'); if (slash) { @@ -89,14 +87,18 @@ ip4_process_dhcpcd_rfc3442_routes(const char * iface, *r, rt_cidr, *(r + 1)); - memset(&route, 0, sizeof(route)); - route.network = nm_utils_ip4_address_clear_host_address(rt_addr, rt_cidr); - route.plen = rt_cidr; - route.gateway = rt_route; - route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = route_metric; - route.table_coerced = nm_platform_route_table_coerce(route_table); - nm_ip4_config_add_route(ip4_config, &route, NULL); + + nm_l3_config_data_add_route_4( + l3cd, + &((const NMPlatformIP4Route){ + .network = nm_utils_ip4_address_clear_host_address(rt_addr, rt_cidr), + .plen = rt_cidr, + .gateway = rt_route, + .rt_source = NM_IP_CONFIG_SOURCE_DHCP, + .metric_any = TRUE, + .table_any = TRUE, + + })); } } @@ -153,12 +155,10 @@ process_dhclient_rfc3442_route(const char *const **p_octets, NMPlatformIP4Route } static gboolean -ip4_process_dhclient_rfc3442_routes(const char * iface, - const char * str, - guint32 route_table, - guint32 route_metric, - NMIP4Config *ip4_config, - guint32 * gwaddr) +ip4_process_dhclient_rfc3442_routes(const char * iface, + const char * str, + NML3ConfigData *l3cd, + guint32 * gwaddr) { gs_free const char **octets = NULL; const char *const * o; @@ -189,9 +189,12 @@ ip4_process_dhclient_rfc3442_routes(const char * iface, /* normal route */ route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = route_metric; - route.table_coerced = nm_platform_route_table_coerce(route_table); - nm_ip4_config_add_route(ip4_config, &route, NULL); + route.table_any = TRUE; + route.table_coerced = 0; + route.metric_any = TRUE; + route.metric = 0; + + nm_l3_config_data_add_route_4(l3cd, &route); _LOG2I(LOGD_DHCP4, iface, @@ -206,17 +209,15 @@ ip4_process_dhclient_rfc3442_routes(const char * iface, } static gboolean -ip4_process_classless_routes(const char * iface, - GHashTable * options, - guint32 route_table, - guint32 route_metric, - NMIP4Config *ip4_config, - guint32 * gwaddr) +ip4_process_classless_routes(const char * iface, + GHashTable * options, + NML3ConfigData *l3cd, + guint32 * gwaddr) { const char *str, *p; g_return_val_if_fail(options != NULL, FALSE); - g_return_val_if_fail(ip4_config != NULL, FALSE); + g_return_val_if_fail(l3cd != NULL, FALSE); *gwaddr = 0; @@ -265,28 +266,14 @@ ip4_process_classless_routes(const char * iface, if (strchr(str, '/')) { /* dhcpcd format */ - return ip4_process_dhcpcd_rfc3442_routes(iface, - str, - route_table, - route_metric, - ip4_config, - gwaddr); + return ip4_process_dhcpcd_rfc3442_routes(iface, str, l3cd, gwaddr); } - return ip4_process_dhclient_rfc3442_routes(iface, - str, - route_table, - route_metric, - ip4_config, - gwaddr); + return ip4_process_dhclient_rfc3442_routes(iface, str, l3cd, gwaddr); } static void -process_classful_routes(const char * iface, - GHashTable * options, - guint32 route_table, - guint32 route_metric, - NMIP4Config *ip4_config) +process_classful_routes(const char *iface, GHashTable *options, NML3ConfigData *l3cd) { gs_free const char **searches = NULL; const char ** s; @@ -320,8 +307,10 @@ process_classful_routes(const char * iface, // FIXME: ensure the IP address and route are sane - memset(&route, 0, sizeof(route)); - route.network = rt_addr; + route = (NMPlatformIP4Route){ + .network = rt_addr, + }; + /* RFC 2132, updated by RFC 3442: * The Static Routes option (option 33) does not provide a subnet mask * for each route - it is assumed that the subnet mask is implicit in @@ -333,12 +322,15 @@ process_classful_routes(const char * iface, } route.gateway = rt_route; route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = route_metric; - route.table_coerced = nm_platform_route_table_coerce(route_table); + route.table_any = TRUE; + route.table_coerced = 0; + route.metric_any = TRUE; + route.metric = 0; route.network = nm_utils_ip4_address_clear_host_address(route.network, route.plen); - nm_ip4_config_add_route(ip4_config, &route, NULL); + nm_l3_config_data_add_route_4(l3cd, &route); + _LOG2I(LOGD_DHCP, iface, " static route %s", @@ -347,7 +339,7 @@ process_classful_routes(const char * iface, } static void -process_domain_search(const char *iface, const char *str, GFunc add_func, gpointer user_data) +process_domain_search(int addr_family, const char *iface, const char *str, NML3ConfigData *l3cd) { gs_free const char **searches = NULL; gs_free char * unescaped = NULL; @@ -356,7 +348,7 @@ process_domain_search(const char *iface, const char *str, GFunc add_func, gpoint int i; g_return_if_fail(str != NULL); - g_return_if_fail(add_func != NULL); + nm_assert(l3cd); unescaped = g_strdup(str); @@ -379,46 +371,43 @@ process_domain_search(const char *iface, const char *str, GFunc add_func, gpoint searches = nm_strsplit_set(unescaped, " "); for (s = searches; searches && *s; s++) { _LOG2I(LOGD_DHCP, iface, " domain search '%s'", *s); - add_func((gpointer) *s, user_data); + nm_l3_config_data_add_search(l3cd, addr_family, *s); } } -static void -ip4_add_domain_search(gpointer data, gpointer user_data) -{ - nm_ip4_config_add_search(NM_IP4_CONFIG(user_data), (const char *) data); -} - -NMIP4Config * +NML3ConfigData * nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, int ifindex, const char * iface, - GHashTable * options, - guint32 route_table, - guint32 route_metric) + GHashTable * options) { - gs_unref_object NMIP4Config *ip4_config = NULL; - guint32 tmp_addr; - in_addr_t addr; - NMPlatformIP4Address address; - char * str = NULL; - gboolean gateway_has = FALSE; - guint32 gateway = 0; - guint8 plen = 0; - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + guint32 tmp_addr; + in_addr_t addr; + NMPlatformIP4Address address; + char * str = NULL; + gboolean gateway_has = FALSE; + guint32 gateway = 0; + guint8 plen = 0; + char sbuf[NM_UTILS_INET_ADDRSTRLEN]; + guint32 now; g_return_val_if_fail(options != NULL, NULL); - ip4_config = nm_ip4_config_new(multi_idx, ifindex); - memset(&address, 0, sizeof(address)); - address.timestamp = nm_utils_get_monotonic_timestamp_sec(); + l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_DHCP); + + now = nm_utils_get_monotonic_timestamp_sec(); + + address = (NMPlatformIP4Address){ + .timestamp = now, + }; str = g_hash_table_lookup(options, "ip_address"); - if (str && (inet_pton(AF_INET, str, &addr) > 0)) - _LOG2I(LOGD_DHCP4, iface, " address %s", str); - else + if (!str || !nm_utils_parse_inaddr_bin(AF_INET, str, NULL, &addr)) return NULL; + _LOG2I(LOGD_DHCP4, iface, " address %s", str); + str = g_hash_table_lookup(options, "subnet_mask"); if (str && (inet_pton(AF_INET, str, &tmp_addr) > 0)) { plen = nm_utils_ip4_netmask_to_prefix(tmp_addr); @@ -433,13 +422,8 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, /* Routes: if the server returns classless static routes, we MUST ignore * the 'static_routes' option. */ - if (!ip4_process_classless_routes(iface, - options, - route_table, - route_metric, - ip4_config, - &gateway)) - process_classful_routes(iface, options, route_table, route_metric, ip4_config); + if (!ip4_process_classless_routes(iface, options, l3cd, &gateway)) + process_classful_routes(iface, options, l3cd); if (gateway) { _LOG2I(LOGD_DHCP4, iface, " gateway %s", _nm_utils_inet4_ntop(gateway, sbuf)); @@ -453,7 +437,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, gs_free const char **routers = nm_strsplit_set(str, " "); const char ** s; - for (s = routers; routers && *s; s++) { + for (s = routers; *s; s++) { /* FIXME: how to handle multiple routers? */ if (inet_pton(AF_INET, *s, &gateway) > 0) { _LOG2I(LOGD_DHCP4, iface, " gateway %s", *s); @@ -469,11 +453,13 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, const NMPlatformIP4Route r = { .rt_source = NM_IP_CONFIG_SOURCE_DHCP, .gateway = gateway, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, }; - nm_ip4_config_add_route(ip4_config, &r, NULL); + nm_l3_config_data_add_route_4(l3cd, &r); } str = g_hash_table_lookup(options, "dhcp_lease_time"); @@ -483,7 +469,8 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, } address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; - nm_ip4_config_add_address(ip4_config, &address); + + nm_l3_config_data_add_address_4(l3cd, &address); str = g_hash_table_lookup(options, "host_name"); if (str) @@ -497,7 +484,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, for (s = dns; dns && *s; s++) { if (inet_pton(AF_INET, *s, &tmp_addr) > 0) { if (tmp_addr) { - nm_ip4_config_add_nameserver(ip4_config, tmp_addr); + nm_l3_config_data_add_nameserver(l3cd, AF_INET, &tmp_addr); _LOG2I(LOGD_DHCP4, iface, " nameserver '%s'", *s); } } else @@ -512,13 +499,13 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, for (s = domains; domains && *s; s++) { _LOG2I(LOGD_DHCP4, iface, " domain name '%s'", *s); - nm_ip4_config_add_domain(ip4_config, *s); + nm_l3_config_data_add_domain(l3cd, AF_INET, *s); } } str = g_hash_table_lookup(options, "domain_search"); if (str) - process_domain_search(iface, str, ip4_add_domain_search, ip4_config); + process_domain_search(AF_INET, iface, str, l3cd); str = g_hash_table_lookup(options, "netbios_name_servers"); if (str) { @@ -528,7 +515,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, for (s = nbns; nbns && *s; s++) { if (inet_pton(AF_INET, *s, &tmp_addr) > 0) { if (tmp_addr) { - nm_ip4_config_add_wins(ip4_config, tmp_addr); + nm_l3_config_data_add_wins(l3cd, tmp_addr); _LOG2I(LOGD_DHCP4, iface, " wins '%s'", *s); } } else @@ -546,13 +533,13 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, return NULL; if (int_mtu > 576) - nm_ip4_config_set_mtu(ip4_config, int_mtu, NM_IP_CONFIG_SOURCE_DHCP); + nm_l3_config_data_set_mtu(l3cd, int_mtu); } str = g_hash_table_lookup(options, "nis_domain"); if (str) { _LOG2I(LOGD_DHCP4, iface, " NIS domain '%s'", str); - nm_ip4_config_set_nis_domain(ip4_config, str); + nm_l3_config_data_add_domain(l3cd, AF_INET, str); } str = g_hash_table_lookup(options, "nis_servers"); @@ -563,7 +550,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, for (s = nis; nis && *s; s++) { if (inet_pton(AF_INET, *s, &tmp_addr) > 0) { if (tmp_addr) { - nm_ip4_config_add_nis_server(ip4_config, tmp_addr); + nm_l3_config_data_add_nis_server(l3cd, tmp_addr); _LOG2I(LOGD_DHCP4, iface, " nis '%s'", *s); } } else @@ -572,19 +559,20 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, } str = g_hash_table_lookup(options, "vendor_encapsulated_options"); - nm_ip4_config_set_metered(ip4_config, str && strstr(str, "ANDROID_METERED")); + if (str && strstr(str, "ANDROID_METERED")) + nm_l3_config_data_set_metered(l3cd, TRUE); - return g_steal_pointer(&ip4_config); + str = g_hash_table_lookup(options, "wpad"); + if (str) { + nm_l3_config_data_set_proxy_method(l3cd, NM_PROXY_CONFIG_METHOD_AUTO); + nm_l3_config_data_set_proxy_pac_url(l3cd, str); + } + + return g_steal_pointer(&l3cd); } /*****************************************************************************/ -static void -ip6_add_domain_search(gpointer data, gpointer user_data) -{ - nm_ip6_config_add_search(NM_IP6_CONFIG(user_data), (const char *) data); -} - NMPlatformIP6Address nm_dhcp_utils_ip6_prefix_from_options(GHashTable *options) { @@ -635,25 +623,29 @@ nm_dhcp_utils_ip6_prefix_from_options(GHashTable *options) return address; } -NMIP6Config * +NML3ConfigData * nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx, int ifindex, const char * iface, GHashTable * options, gboolean info_only) { - gs_unref_object NMIP6Config *ip6_config = NULL; - struct in6_addr tmp_addr; - NMPlatformIP6Address address; - char * str = NULL; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + struct in6_addr tmp_addr; + NMPlatformIP6Address address; + char * str = NULL; + guint32 now; g_return_val_if_fail(options != NULL, NULL); - memset(&address, 0, sizeof(address)); - address.plen = 128; - address.timestamp = nm_utils_get_monotonic_timestamp_sec(); + now = nm_utils_get_monotonic_timestamp_sec(); - ip6_config = nm_ip6_config_new(multi_idx, ifindex); + address = (NMPlatformIP6Address){ + .plen = 128, + .timestamp = now, + }; + + l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_DHCP); str = g_hash_table_lookup(options, "max_life"); if (str) { @@ -676,7 +668,7 @@ nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx, address.address = tmp_addr; address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; - nm_ip6_config_add_address(ip6_config, &address); + nm_l3_config_data_add_address_6(l3cd, &address); _LOG2I(LOGD_DHCP6, iface, " address %s", str); } else if (info_only == FALSE) { /* No address in Managed mode is a hard error */ @@ -695,7 +687,7 @@ nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx, for (s = dns; dns && *s; s++) { if (inet_pton(AF_INET6, *s, &tmp_addr) > 0) { if (!IN6_IS_ADDR_UNSPECIFIED(&tmp_addr)) { - nm_ip6_config_add_nameserver(ip6_config, &tmp_addr); + nm_l3_config_data_add_nameserver(l3cd, AF_INET6, &tmp_addr); _LOG2I(LOGD_DHCP6, iface, " nameserver '%s'", *s); } } else @@ -705,9 +697,9 @@ nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "dhcp6_domain_search"); if (str) - process_domain_search(iface, str, ip6_add_domain_search, ip6_config); + process_domain_search(AF_INET6, iface, str, l3cd); - return g_steal_pointer(&ip6_config); + return g_steal_pointer(&l3cd); } char * @@ -838,6 +830,65 @@ nm_dhcp_utils_get_dhcp6_event_id(GHashTable *lease) return g_strdup_printf("%s|%s", iaid, start); } +gboolean +nm_dhcp_utils_merge_new_dhcp6_lease(const NML3ConfigData * l3cd_old, + const NML3ConfigData * l3cd_new, + const NML3ConfigData **out_l3cd_merged) +{ + nm_auto_unref_l3cd_init NML3ConfigData *l3cd_merged = NULL; + const NMPlatformIP6Address * addr; + NMDhcpLease * lease_old; + NMDhcpLease * lease_new; + NMDedupMultiIter iter; + const char * start; + const char * iaid; + + nm_assert(out_l3cd_merged); + nm_assert(!*out_l3cd_merged); + + if (!l3cd_old) + return FALSE; + if (!l3cd_new) + return FALSE; + + lease_new = nm_l3_config_data_get_dhcp_lease(l3cd_new, AF_INET6); + if (!lease_new) + return FALSE; + + lease_old = nm_l3_config_data_get_dhcp_lease(l3cd_old, AF_INET6); + if (!lease_old) + return FALSE; + + start = nm_dhcp_lease_lookup_option(lease_new, "life_starts"); + if (!start) + return FALSE; + iaid = nm_dhcp_lease_lookup_option(lease_new, "iaid"); + if (!iaid) + return FALSE; + + if (!nm_streq0(start, nm_dhcp_lease_lookup_option(lease_old, "life_starts"))) + return FALSE; + if (!nm_streq0(iaid, nm_dhcp_lease_lookup_option(lease_old, "iaid"))) + return FALSE; + + /* If the server sends multiple IPv6 addresses, we receive a state + * changed event for each of them. Use the event ID to merge IPv6 + * addresses from the same transaction into a single configuration. + **/ + + l3cd_merged = nm_l3_config_data_new_clone(l3cd_old, -1); + + nm_l3_config_data_iter_ip6_address_for_each (&iter, l3cd_new, &addr) + nm_l3_config_data_add_address_6(l3cd_merged, addr); + + /* FIXME(l3cfg): Note that we keep the original NMDhcpLease. All we take from the new lease are the + * addresses. Maybe this is not right and we should merge the leases too?? */ + nm_l3_config_data_set_dhcp_lease(l3cd_merged, AF_INET6, lease_old); + + *out_l3cd_merged = nm_l3_config_data_ref_and_seal(g_steal_pointer(&l3cd_merged)); + return TRUE; +} + /*****************************************************************************/ gboolean diff --git a/src/core/dhcp/nm-dhcp-utils.h b/src/core/dhcp/nm-dhcp-utils.h index 69715f90fe..bee10de3f6 100644 --- a/src/core/dhcp/nm-dhcp-utils.h +++ b/src/core/dhcp/nm-dhcp-utils.h @@ -8,21 +8,18 @@ #include -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" +#include "nm-l3-config-data.h" -NMIP4Config *nm_dhcp_utils_ip4_config_from_options(struct _NMDedupMultiIndex *multi_idx, - int ifindex, - const char * iface, - GHashTable * options, - guint32 route_table, - guint32 route_metric); +NML3ConfigData *nm_dhcp_utils_ip4_config_from_options(struct _NMDedupMultiIndex *multi_idx, + int ifindex, + const char * iface, + GHashTable * options); -NMIP6Config *nm_dhcp_utils_ip6_config_from_options(struct _NMDedupMultiIndex *multi_idx, - int ifindex, - const char * iface, - GHashTable * options, - gboolean info_only); +NML3ConfigData *nm_dhcp_utils_ip6_config_from_options(struct _NMDedupMultiIndex *multi_idx, + int ifindex, + const char * iface, + GHashTable * options, + gboolean info_only); NMPlatformIP6Address nm_dhcp_utils_ip6_prefix_from_options(GHashTable *options); @@ -38,6 +35,10 @@ gboolean nm_dhcp_utils_get_leasefile_path(int addr_family, char *nm_dhcp_utils_get_dhcp6_event_id(GHashTable *lease); +gboolean nm_dhcp_utils_merge_new_dhcp6_lease(const NML3ConfigData * l3cd_old, + const NML3ConfigData * l3cd_new, + const NML3ConfigData **out_l3cd_merged); + /*****************************************************************************/ static inline gboolean diff --git a/src/core/dhcp/tests/test-dhcp-dhclient.c b/src/core/dhcp/tests/test-dhcp-dhclient.c index 9c6865cc8c..92e4548fbe 100644 --- a/src/core/dhcp/tests/test-dhcp-dhclient.c +++ b/src/core/dhcp/tests/test-dhcp-dhclient.c @@ -15,7 +15,6 @@ #include "dhcp/nm-dhcp-dhclient-utils.h" #include "dhcp/nm-dhcp-utils.h" #include "nm-utils.h" -#include "nm-ip4-config.h" #include "libnm-platform/nm-platform.h" #include "nm-test-utils-core.h" diff --git a/src/core/dhcp/tests/test-dhcp-utils.c b/src/core/dhcp/tests/test-dhcp-utils.c index 4d47e7e283..0fab5c15ad 100644 --- a/src/core/dhcp/tests/test-dhcp-utils.c +++ b/src/core/dhcp/tests/test-dhcp-utils.c @@ -20,20 +20,18 @@ /*****************************************************************************/ -static NMIP4Config * -_ip4_config_from_options(int ifindex, const char *iface, GHashTable *options, guint32 route_metric) +static const NML3ConfigData * +_ip4_config_from_options(int ifindex, const char *iface, GHashTable *options) { nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = nm_dedup_multi_index_new(); - NMIP4Config * config; + NML3ConfigData * l3cd; - config = nm_dhcp_utils_ip4_config_from_options(multi_idx, - ifindex, - iface, - options, - RT_TABLE_MAIN, - route_metric); - g_assert(config); - return config; + l3cd = nm_dhcp_utils_ip4_config_from_options(multi_idx, ifindex, iface, options); + g_assert(NM_IS_L3_CONFIG_DATA(l3cd)); + g_assert(!nm_l3_config_data_is_sealed(l3cd)); + if (nmtst_get_rand_bool()) + nm_l3_config_data_seal(l3cd); + return l3cd; } typedef struct { @@ -74,58 +72,57 @@ static const Option generic_options[] = { static void test_generic_options(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const NMPlatformIP4Address * address; - const NMPlatformIP4Route * route; - guint32 tmp; - const char * expected_addr = "192.168.1.106"; - const char * expected_gw = "192.168.1.1"; - const char * expected_dns1 = "216.254.95.2"; - const char * expected_dns2 = "216.231.41.2"; - const char * expected_search1 = "foobar.com"; - const char * expected_search2 = "blah.foobar.com"; - const char * expected_route1_dest = "10.1.1.5"; - const char * expected_route1_gw = "10.1.1.1"; - const char * expected_route2_dest = "100.99.88.56"; - const char * expected_route2_gw = "10.1.1.1"; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMPlatformIP4Address * address; + const NMPlatformIP4Route * route; + guint32 tmp; + const char * expected_addr = "192.168.1.106"; + const char * expected_gw = "192.168.1.1"; + const char * expected_dns1 = "216.254.95.2"; + const char * expected_dns2 = "216.231.41.2"; + const char * expected_search1 = "foobar.com"; + const char * expected_search2 = "blah.foobar.com"; + const char * expected_route1_dest = "10.1.1.5"; + const char * expected_route1_gw = "10.1.1.1"; + const char * expected_route2_dest = "100.99.88.56"; + const char * expected_route2_gw = "10.1.1.1"; + const char *const * strarr; + const in_addr_t * ia_arr; + guint u; - options = fill_table(generic_options, NULL); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + options = fill_table(generic_options, NULL); + l3cd = _ip4_config_from_options(1, "eth0", options); - /* IP4 address */ - g_assert_cmpint(nm_ip4_config_get_num_addresses(ip4_config), ==, 1); - address = _nmtst_ip4_config_get_address(ip4_config, 0); + g_assert_cmpint(nm_l3_config_data_get_num_addresses(l3cd, AF_INET), ==, 1); + address = nmtst_l3_config_data_get_address_at_4(l3cd, 0); g_assert(inet_pton(AF_INET, expected_addr, &tmp) > 0); g_assert(address->address == tmp); g_assert(address->peer_address == tmp); g_assert_cmpint(address->plen, ==, 24); - /* Gateway */ - g_assert(inet_pton(AF_INET, expected_gw, &tmp) > 0); - g_assert(nmtst_ip4_config_get_gateway(ip4_config) == tmp); + nmtst_assert_ip_address(AF_INET, + nmtst_l3_config_data_get_best_gateway(l3cd, AF_INET), + expected_gw); - g_assert_cmpint(nm_ip4_config_get_num_wins(ip4_config), ==, 0); + g_assert(!nm_l3_config_data_get_wins(l3cd, &u)); + g_assert_cmpint(u, ==, 0); - g_assert_cmpint(nm_ip4_config_get_mtu(ip4_config), ==, 987); + g_assert_cmpint(nm_l3_config_data_get_mtu(l3cd), ==, 987); - /* Domain searches */ - g_assert_cmpint(nm_ip4_config_get_num_searches(ip4_config), ==, 2); - g_assert_cmpstr(nm_ip4_config_get_search(ip4_config, 0), ==, expected_search1); - g_assert_cmpstr(nm_ip4_config_get_search(ip4_config, 1), ==, expected_search2); + strarr = nm_l3_config_data_get_searches(l3cd, AF_INET, &u); + g_assert_cmpint(u, ==, 2); + g_assert_cmpstr(strarr[0], ==, expected_search1); + g_assert_cmpstr(strarr[1], ==, expected_search2); - /* DNS servers */ - g_assert_cmpint(nm_ip4_config_get_num_nameservers(ip4_config), ==, 2); - g_assert(inet_pton(AF_INET, expected_dns1, &tmp) > 0); - g_assert(nm_ip4_config_get_nameserver(ip4_config, 0) == tmp); - g_assert(inet_pton(AF_INET, expected_dns2, &tmp) > 0); - g_assert(nm_ip4_config_get_nameserver(ip4_config, 1) == tmp); + ia_arr = nm_l3_config_data_get_nameservers(l3cd, AF_INET, &u); + g_assert_cmpint(u, ==, 2); + nmtst_assert_ip4_address(ia_arr[0], expected_dns1); + nmtst_assert_ip4_address(ia_arr[1], expected_dns2); - /* Routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 3); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3); - /* Route #1 */ - route = _nmtst_ip4_config_get_route(ip4_config, 0); + route = nmtst_l3_config_data_get_route_at_4(l3cd, 0); g_assert(inet_pton(AF_INET, expected_route1_dest, &tmp) > 0); g_assert(route->network == tmp); g_assert(inet_pton(AF_INET, expected_route1_gw, &tmp) > 0); @@ -133,69 +130,63 @@ test_generic_options(void) g_assert_cmpint(route->plen, ==, 32); g_assert_cmpint(route->metric, ==, 0); - /* Route #2 */ - route = _nmtst_ip4_config_get_route(ip4_config, 1); + route = nmtst_l3_config_data_get_route_at_4(l3cd, 1); g_assert(route->network == nmtst_inet4_from_string(expected_route2_dest)); g_assert(route->gateway == nmtst_inet4_from_string(expected_route2_gw)); g_assert_cmpint(route->plen, ==, 32); g_assert_cmpint(route->metric, ==, 0); - route = _nmtst_ip4_config_get_route(ip4_config, 2); + route = nmtst_l3_config_data_get_route_at_4(l3cd, 2); g_assert(route->network == nmtst_inet4_from_string("0.0.0.0")); g_assert(route->gateway == nmtst_inet4_from_string("192.168.1.1")); g_assert_cmpint(route->plen, ==, 0); g_assert_cmpint(route->metric, ==, 0); - - g_hash_table_destroy(options); } static void test_wins_options(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const NMPlatformIP4Address * address; - guint32 tmp; - const char * expected_wins1 = "63.12.199.5"; - const char * expected_wins2 = "150.4.88.120"; - static const Option data[] = {{"netbios_name_servers", "63.12.199.5 150.4.88.120"}, + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMPlatformIP4Address * address; + const char * expected_wins1 = "63.12.199.5"; + const char * expected_wins2 = "150.4.88.120"; + static const Option data[] = {{"netbios_name_servers", "63.12.199.5 150.4.88.120"}, {NULL, NULL}}; + const in_addr_t * ia_arr; + guint u; - options = fill_table(generic_options, NULL); - options = fill_table(data, options); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + options = fill_table(generic_options, NULL); + options = fill_table(data, options); + l3cd = _ip4_config_from_options(1, "eth0", options); - /* IP4 address */ - g_assert_cmpint(nm_ip4_config_get_num_addresses(ip4_config), ==, 1); - address = _nmtst_ip4_config_get_address(ip4_config, 0); + g_assert_cmpint(nm_l3_config_data_get_num_addresses(l3cd, AF_INET), ==, 1); + address = nmtst_l3_config_data_get_address_at_4(l3cd, 0); g_assert(address); - g_assert_cmpint(nm_ip4_config_get_num_wins(ip4_config), ==, 2); - g_assert(inet_pton(AF_INET, expected_wins1, &tmp) > 0); - g_assert(nm_ip4_config_get_wins(ip4_config, 0) == tmp); - g_assert(inet_pton(AF_INET, expected_wins2, &tmp) > 0); - g_assert(nm_ip4_config_get_wins(ip4_config, 1) == tmp); - g_hash_table_destroy(options); + ia_arr = nm_l3_config_data_get_wins(l3cd, &u); + g_assert_cmpint(u, ==, 2); + nmtst_assert_ip4_address(ia_arr[0], expected_wins1); + nmtst_assert_ip4_address(ia_arr[1], expected_wins2); } static void test_vendor_option_metered(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; static const Option data[] = {{"vendor_encapsulated_options", "ANDROID_METERED"}, {NULL, NULL}}; - options = fill_table(generic_options, NULL); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); - g_assert(nm_ip4_config_get_metered(ip4_config) == FALSE); - g_hash_table_destroy(options); - g_clear_object(&ip4_config); + options = fill_table(generic_options, NULL); + l3cd = _ip4_config_from_options(1, "eth0", options); + g_assert(nm_l3_config_data_get_metered(l3cd) == NM_TERNARY_DEFAULT); + nm_clear_pointer(&options, g_hash_table_destroy); + nm_clear_l3cd(&l3cd); - options = fill_table(generic_options, NULL); - options = fill_table(data, options); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); - g_assert(nm_ip4_config_get_metered(ip4_config) == TRUE); - g_hash_table_destroy(options); + options = fill_table(generic_options, NULL); + options = fill_table(data, options); + l3cd = _ip4_config_from_options(1, "eth0", options); + g_assert(nm_l3_config_data_get_metered(l3cd) == TRUE); } static void @@ -252,18 +243,18 @@ test_parse_search_list(void) } static void -ip4_test_route(NMIP4Config *ip4_config, - guint route_num, - const char * expected_dest, - const char * expected_gw, - guint expected_prefix) +ip4_test_route(const NML3ConfigData *l3cd, + guint route_num, + const char * expected_dest, + const char * expected_gw, + guint expected_prefix) { const NMPlatformIP4Route *route; guint32 tmp; g_assert(expected_prefix <= 32); - route = _nmtst_ip4_config_get_route(ip4_config, route_num); + route = nmtst_l3_config_data_get_route_at_4(l3cd, route_num); g_assert(inet_pton(AF_INET, expected_dest, &tmp) > 0); g_assert(route->network == tmp); g_assert(inet_pton(AF_INET, expected_gw, &tmp) > 0); @@ -272,110 +263,105 @@ ip4_test_route(NMIP4Config *ip4_config, g_assert_cmpint(route->metric, ==, 0); } -static void -ip4_test_gateway(NMIP4Config *ip4_config, const char *expected_gw) -{ - guint32 tmp; - - g_assert_cmpint(nm_ip4_config_get_num_addresses(ip4_config), ==, 1); - g_assert(inet_pton(AF_INET, expected_gw, &tmp) > 0); - g_assert(nmtst_ip4_config_get_gateway(ip4_config) == tmp); -} +#define ip4_test_gateway(l3cd, expected_gw) \ + G_STMT_START \ + { \ + const NML3ConfigData *_l3cd = (l3cd); \ + \ + g_assert_cmpint(nm_l3_config_data_get_num_addresses(_l3cd, AF_INET), ==, 1); \ + nmtst_assert_ip_address(AF_INET, \ + nmtst_l3_config_data_get_best_gateway(_l3cd, AF_INET), \ + expected_gw); \ + } \ + G_STMT_END static void test_classless_static_routes_1(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - const char * expected_route2_dest = "10.0.0.0"; - const char * expected_route2_gw = "10.17.66.41"; - static const Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "192.168.10.0"; + const char * expected_route1_gw = "192.168.1.1"; + const char * expected_route2_dest = "10.0.0.0"; + const char * expected_route2_gw = "10.17.66.41"; + static const Option data[] = { /* dhclient custom format */ {"rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 8 10 10 17 66 41"}, {NULL, NULL}}; - options = fill_table(generic_options, NULL); - options = fill_table(data, options); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + options = fill_table(generic_options, NULL); + options = fill_table(data, options); + l3cd = _ip4_config_from_options(1, "eth0", options); /* IP4 routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 3); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route(ip4_config, 1, expected_route2_dest, expected_route2_gw, 8); - ip4_test_route(ip4_config, 2, "0.0.0.0", "192.168.1.1", 0); - - g_hash_table_destroy(options); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route(l3cd, 1, expected_route2_dest, expected_route2_gw, 8); + ip4_test_route(l3cd, 2, "0.0.0.0", "192.168.1.1", 0); } static void test_classless_static_routes_2(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - const char * expected_route2_dest = "10.0.0.0"; - const char * expected_route2_gw = "10.17.66.41"; - static const Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "192.168.10.0"; + const char * expected_route1_gw = "192.168.1.1"; + const char * expected_route2_dest = "10.0.0.0"; + const char * expected_route2_gw = "10.17.66.41"; + static const Option data[] = { /* dhcpcd format */ {"classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41"}, {NULL, NULL}}; - options = fill_table(generic_options, NULL); - options = fill_table(data, options); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + options = fill_table(generic_options, NULL); + options = fill_table(data, options); + l3cd = _ip4_config_from_options(1, "eth0", options); /* IP4 routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 3); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route(ip4_config, 1, expected_route2_dest, expected_route2_gw, 8); - ip4_test_route(ip4_config, 2, "0.0.0.0", expected_route1_gw, 0); - - g_hash_table_destroy(options); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route(l3cd, 1, expected_route2_dest, expected_route2_gw, 8); + ip4_test_route(l3cd, 2, "0.0.0.0", expected_route1_gw, 0); } static void test_fedora_dhclient_classless_static_routes(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "129.210.177.128"; - const char * expected_route1_gw = "192.168.0.113"; - const char * expected_route2_dest = "2.0.0.0"; - const char * expected_route2_gw = "10.34.255.6"; - const char * expected_gateway = "192.168.0.113"; - static const Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "129.210.177.128"; + const char * expected_route1_gw = "192.168.0.113"; + const char * expected_route2_dest = "2.0.0.0"; + const char * expected_route2_gw = "10.34.255.6"; + const char * expected_gateway = "192.168.0.113"; + static const Option data[] = { /* Fedora dhclient format */ {"classless_static_routes", "0 192.168.0.113 25.129.210.177.132 192.168.0.113 7.2 10.34.255.6"}, {NULL, NULL}}; - options = fill_table(generic_options, NULL); - options = fill_table(data, options); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + options = fill_table(generic_options, NULL); + options = fill_table(data, options); + l3cd = _ip4_config_from_options(1, "eth0", options); /* IP4 routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 3); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 25); - ip4_test_route(ip4_config, 1, expected_route2_dest, expected_route2_gw, 7); - ip4_test_route(ip4_config, 2, "0.0.0.0", expected_route1_gw, 0); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 25); + ip4_test_route(l3cd, 1, expected_route2_dest, expected_route2_gw, 7); + ip4_test_route(l3cd, 2, "0.0.0.0", expected_route1_gw, 0); - /* Gateway */ - ip4_test_gateway(ip4_config, expected_gateway); - - g_hash_table_destroy(options); + ip4_test_gateway(l3cd, expected_gateway); } static void test_dhclient_invalid_classless_routes_1(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - static const Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "192.168.10.0"; + const char * expected_route1_gw = "192.168.1.1"; + static const Option data[] = { /* dhclient format */ {"rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 45 10 17 66 41"}, {NULL, NULL}}; @@ -384,27 +370,25 @@ test_dhclient_invalid_classless_routes_1(void) options = fill_table(data, options); NMTST_EXPECT_NM_WARN("*ignoring invalid classless static routes*"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); g_test_assert_expected_messages(); /* IP4 routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 2); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route(ip4_config, 1, "0.0.0.0", expected_route1_gw, 0); - - g_hash_table_destroy(options); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 2); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route(l3cd, 1, "0.0.0.0", expected_route1_gw, 0); } static void test_dhcpcd_invalid_classless_routes_1(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "10.1.1.5"; - const char * expected_route1_gw = "10.1.1.1"; - const char * expected_route2_dest = "100.99.88.56"; - const char * expected_route2_gw = "10.1.1.1"; - static const Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "10.1.1.5"; + const char * expected_route1_gw = "10.1.1.1"; + const char * expected_route2_dest = "100.99.88.56"; + const char * expected_route2_gw = "10.1.1.1"; + static const Option data[] = { /* dhcpcd format */ {"classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.adfadf/44 10.17.66.41"}, {NULL, NULL}}; @@ -413,30 +397,28 @@ test_dhcpcd_invalid_classless_routes_1(void) options = fill_table(data, options); NMTST_EXPECT_NM_WARN("*ignoring invalid classless static routes*"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); g_test_assert_expected_messages(); /* Test falling back to old-style static routes if the classless static * routes are invalid. */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 3); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); - ip4_test_route(ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); - ip4_test_route(ip4_config, 2, "0.0.0.0", "192.168.1.1", 0); - - g_hash_table_destroy(options); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 32); + ip4_test_route(l3cd, 1, expected_route2_dest, expected_route2_gw, 32); + ip4_test_route(l3cd, 2, "0.0.0.0", "192.168.1.1", 0); } static void test_dhclient_invalid_classless_routes_2(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "10.1.1.5"; - const char * expected_route1_gw = "10.1.1.1"; - const char * expected_route2_dest = "100.99.88.56"; - const char * expected_route2_gw = "10.1.1.1"; - static const Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "10.1.1.5"; + const char * expected_route1_gw = "10.1.1.1"; + const char * expected_route2_dest = "100.99.88.56"; + const char * expected_route2_gw = "10.1.1.1"; + static const Option data[] = { {"rfc3442_classless_static_routes", "45 10 17 66 41 24 192 168 10 192 168 1 1"}, {NULL, NULL}}; @@ -444,30 +426,28 @@ test_dhclient_invalid_classless_routes_2(void) options = fill_table(data, options); NMTST_EXPECT_NM_WARN("*ignoring invalid classless static routes*"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); g_test_assert_expected_messages(); /* Test falling back to old-style static routes if the classless static * routes are invalid. */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 3); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); - ip4_test_route(ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); - ip4_test_route(ip4_config, 2, "0.0.0.0", "192.168.1.1", 0); - - g_hash_table_destroy(options); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 32); + ip4_test_route(l3cd, 1, expected_route2_dest, expected_route2_gw, 32); + ip4_test_route(l3cd, 2, "0.0.0.0", "192.168.1.1", 0); } static void test_dhcpcd_invalid_classless_routes_2(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "10.1.1.5"; - const char * expected_route1_gw = "10.1.1.1"; - const char * expected_route2_dest = "100.99.88.56"; - const char * expected_route2_gw = "10.1.1.1"; - static const Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "10.1.1.5"; + const char * expected_route1_gw = "10.1.1.1"; + const char * expected_route2_dest = "100.99.88.56"; + const char * expected_route2_gw = "10.1.1.1"; + static const Option data[] = { {"classless_static_routes", "10.0.adfadf/44 10.17.66.41 192.168.10.0/24 192.168.1.1"}, {NULL, NULL}}; @@ -475,7 +455,7 @@ test_dhcpcd_invalid_classless_routes_2(void) options = fill_table(data, options); NMTST_EXPECT_NM_WARN("*ignoring invalid classless static routes*"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); g_test_assert_expected_messages(); /* Test falling back to old-style static routes if the classless static @@ -483,22 +463,20 @@ test_dhcpcd_invalid_classless_routes_2(void) */ /* Routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 3); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); - ip4_test_route(ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); - ip4_test_route(ip4_config, 2, "0.0.0.0", "192.168.1.1", 0); - - g_hash_table_destroy(options); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 32); + ip4_test_route(l3cd, 1, expected_route2_dest, expected_route2_gw, 32); + ip4_test_route(l3cd, 2, "0.0.0.0", "192.168.1.1", 0); } static void test_dhclient_invalid_classless_routes_3(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - static const Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "192.168.10.0"; + const char * expected_route1_gw = "192.168.1.1"; + static const Option data[] = { {"rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 32 128 10 17 66 41"}, {NULL, NULL}}; @@ -506,25 +484,23 @@ test_dhclient_invalid_classless_routes_3(void) options = fill_table(data, options); NMTST_EXPECT_NM_WARN("*ignoring invalid classless static routes*"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); g_test_assert_expected_messages(); /* IP4 routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 2); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route(ip4_config, 1, "0.0.0.0", expected_route1_gw, 0); - - g_hash_table_destroy(options); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 2); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route(l3cd, 1, "0.0.0.0", expected_route1_gw, 0); } static void test_dhcpcd_invalid_classless_routes_3(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - static Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "192.168.10.0"; + const char * expected_route1_gw = "192.168.1.1"; + static Option data[] = { {"classless_static_routes", "192.168.10.0/24 192.168.1.1 128/32 10.17.66.41"}, {NULL, NULL}}; @@ -532,133 +508,124 @@ test_dhcpcd_invalid_classless_routes_3(void) options = fill_table(data, options); NMTST_EXPECT_NM_WARN("*DHCP provided invalid classless static route*"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); g_test_assert_expected_messages(); /* IP4 routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 2); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route(ip4_config, 1, "0.0.0.0", expected_route1_gw, 0); - - g_hash_table_destroy(options); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 2); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route(l3cd, 1, "0.0.0.0", expected_route1_gw, 0); } static void test_dhclient_gw_in_classless_routes(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - const char * expected_gateway = "192.2.3.4"; - static Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "192.168.10.0"; + const char * expected_route1_gw = "192.168.1.1"; + const char * expected_gateway = "192.2.3.4"; + static Option data[] = { {"rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 0 192 2 3 4"}, {NULL, NULL}}; - options = fill_table(generic_options, NULL); - options = fill_table(data, options); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + options = fill_table(generic_options, NULL); + options = fill_table(data, options); + l3cd = _ip4_config_from_options(1, "eth0", options); /* IP4 routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 2); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route(ip4_config, 1, "0.0.0.0", "192.2.3.4", 0); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 2); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route(l3cd, 1, "0.0.0.0", "192.2.3.4", 0); - /* Gateway */ - ip4_test_gateway(ip4_config, expected_gateway); - - g_hash_table_destroy(options); + ip4_test_gateway(l3cd, expected_gateway); } static void test_dhcpcd_gw_in_classless_routes(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - const char * expected_gateway = "192.2.3.4"; - static Option data[] = { + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_route1_dest = "192.168.10.0"; + const char * expected_route1_gw = "192.168.1.1"; + const char * expected_gateway = "192.2.3.4"; + static Option data[] = { {"classless_static_routes", "192.168.10.0/24 192.168.1.1 0.0.0.0/0 192.2.3.4"}, {NULL, NULL}}; - options = fill_table(generic_options, NULL); - options = fill_table(data, options); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + options = fill_table(generic_options, NULL); + options = fill_table(data, options); + l3cd = _ip4_config_from_options(1, "eth0", options); /* IP4 routes */ - g_assert_cmpint(nm_ip4_config_get_num_routes(ip4_config), ==, 2); - ip4_test_route(ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route(ip4_config, 1, "0.0.0.0", "192.2.3.4", 0); + g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 2); + ip4_test_route(l3cd, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route(l3cd, 1, "0.0.0.0", "192.2.3.4", 0); - /* Gateway */ - ip4_test_gateway(ip4_config, expected_gateway); - - g_hash_table_destroy(options); + ip4_test_gateway(l3cd, expected_gateway); } static void test_escaped_domain_searches(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char * expected_search0 = "host1"; - const char * expected_search1 = "host2"; - const char * expected_search2 = "host3"; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const char * expected_search0 = "host1"; + const char * expected_search1 = "host2"; + const char * expected_search2 = "host3"; static const Option data[] = {{"domain_search", "host1\\032host2\\032host3"}, {NULL, NULL}}; + const char *const * strarr; + guint u; - options = fill_table(generic_options, NULL); - options = fill_table(data, options); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + options = fill_table(generic_options, NULL); + options = fill_table(data, options); + l3cd = _ip4_config_from_options(1, "eth0", options); - /* domain searches */ - g_assert_cmpint(nm_ip4_config_get_num_searches(ip4_config), ==, 3); - g_assert_cmpstr(nm_ip4_config_get_search(ip4_config, 0), ==, expected_search0); - g_assert_cmpstr(nm_ip4_config_get_search(ip4_config, 1), ==, expected_search1); - g_assert_cmpstr(nm_ip4_config_get_search(ip4_config, 2), ==, expected_search2); - - g_hash_table_destroy(options); + strarr = nm_l3_config_data_get_searches(l3cd, AF_INET, &u); + g_assert_cmpint(u, ==, 3); + g_assert_cmpstr(strarr[0], ==, expected_search0); + g_assert_cmpstr(strarr[1], ==, expected_search1); + g_assert_cmpstr(strarr[2], ==, expected_search2); } static void test_invalid_escaped_domain_searches(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; static const Option data[] = {{"domain_search", "host1\\aahost2\\032host3"}, {NULL, NULL}}; + const char *const * strarr; + guint u; options = fill_table(generic_options, NULL); options = fill_table(data, options); NMTST_EXPECT_NM_WARN("*invalid domain search*"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); g_test_assert_expected_messages(); - /* domain searches */ - g_assert_cmpint(nm_ip4_config_get_num_searches(ip4_config), ==, 0); - - g_hash_table_destroy(options); + strarr = nm_l3_config_data_get_searches(l3cd, AF_INET, &u); + g_assert_cmpint(u, ==, 0); + g_assert(!strarr); } static void test_ip4_missing_prefix(const char *ip, guint32 expected_prefix) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const NMPlatformIP4Address * address; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMPlatformIP4Address * address; options = fill_table(generic_options, NULL); g_hash_table_insert(options, "ip_address", (gpointer) ip); g_hash_table_remove(options, "subnet_mask"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); - g_assert_cmpint(nm_ip4_config_get_num_addresses(ip4_config), ==, 1); - address = _nmtst_ip4_config_get_address(ip4_config, 0); + g_assert_cmpint(nm_l3_config_data_get_num_addresses(l3cd, AF_INET), ==, 1); + address = nmtst_l3_config_data_get_address_at_4(l3cd, 0); g_assert(address); g_assert_cmpint(address->plen, ==, expected_prefix); - - g_hash_table_destroy(options); } static void @@ -682,9 +649,9 @@ test_ip4_missing_prefix_8(void) static void test_ip4_prefix_classless(void) { - GHashTable * options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const NMPlatformIP4Address * address; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMPlatformIP4Address * address; /* Ensure that the missing-subnet-mask handler doesn't mangle classless * subnet masks at all. The handler should trigger only if the server @@ -695,14 +662,12 @@ test_ip4_prefix_classless(void) g_hash_table_insert(options, "ip_address", "172.16.54.22"); g_hash_table_insert(options, "subnet_mask", "255.255.252.0"); - ip4_config = _ip4_config_from_options(1, "eth0", options, 0); + l3cd = _ip4_config_from_options(1, "eth0", options); - g_assert_cmpint(nm_ip4_config_get_num_addresses(ip4_config), ==, 1); - address = _nmtst_ip4_config_get_address(ip4_config, 0); + g_assert_cmpint(nm_l3_config_data_get_num_addresses(l3cd, AF_INET), ==, 1); + address = nmtst_l3_config_data_get_address_at_4(l3cd, 0); g_assert(address); g_assert_cmpint(address->plen, ==, 22); - - g_hash_table_destroy(options); } #define COMPARE_ID(src, is_str, expected, expected_len) \ diff --git a/src/core/dns/nm-dns-dnsmasq.c b/src/core/dns/nm-dns-dnsmasq.c index 126e0a217a..b40521a32b 100644 --- a/src/core/dns/nm-dns-dnsmasq.c +++ b/src/core/dns/nm-dns-dnsmasq.c @@ -19,10 +19,9 @@ #include "libnm-core-intern/nm-core-internal.h" #include "libnm-platform/nm-platform.h" #include "nm-utils.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" #include "nm-dbus-manager.h" #include "NetworkManagerUtils.h" +#include "nm-l3-config-data.h" #define PIDFILE NMRUNDIR "/dnsmasq.pid" #define CONFDIR NMCONFDIR "/dnsmasq.d" @@ -806,20 +805,22 @@ add_global_config(NMDnsDnsmasq * self, static void add_ip_config(NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsConfigIPData *ip_data) { - NMIPConfig * ip_config = ip_data->ip_config; - gconstpointer addr; - const char * iface, *domain; + const char * iface; + const char * domain; char ip_addr_to_string_buf[IP_ADDR_TO_STRING_BUFLEN]; - int addr_family; - guint i, j, num; + gconstpointer nameservers; + guint num; + guint i; + guint j; - iface = nm_platform_link_get_name(NM_PLATFORM_GET, ip_data->data->ifindex); - addr_family = nm_ip_config_get_addr_family(ip_config); + iface = nm_platform_link_get_name(NM_PLATFORM_GET, ip_data->data->ifindex); - num = nm_ip_config_get_num_nameservers(ip_config); + nameservers = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num); for (i = 0; i < num; i++) { - addr = nm_ip_config_get_nameserver(ip_config, i); - ip_addr_to_string(addr_family, addr, iface, ip_addr_to_string_buf); + gconstpointer addr; + + addr = nm_ip_addr_from_packed_array(ip_data->addr_family, nameservers, i); + ip_addr_to_string(ip_data->addr_family, addr, iface, ip_addr_to_string_buf); if (!ip_data->domains.has_default_route_explicit && ip_data->domains.has_default_route) add_dnsmasq_nameserver(self, servers, ip_addr_to_string_buf, NULL); @@ -846,7 +847,7 @@ add_ip_config(NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsConfigIPD static GVariant * create_update_args(NMDnsDnsmasq * self, const NMGlobalDnsConfig *global_config, - const CList * ip_config_lst_head, + const CList * ip_data_lst_head, const char * hostname) { GVariantBuilder servers; @@ -857,7 +858,7 @@ create_update_args(NMDnsDnsmasq * self, if (global_config) add_global_config(self, &servers, global_config); else { - c_list_for_each_entry (ip_data, ip_config_lst_head, ip_config_lst) + c_list_for_each_entry (ip_data, ip_data_lst_head, ip_data_lst) add_ip_config(self, &servers, ip_data); } @@ -1122,7 +1123,7 @@ start_dnsmasq(NMDnsDnsmasq *self, gboolean force_start, GError **error) static gboolean update(NMDnsPlugin * plugin, const NMGlobalDnsConfig *global_config, - const CList * ip_config_lst_head, + const CList * ip_data_lst_head, const char * hostname, GError ** error) { @@ -1134,7 +1135,7 @@ update(NMDnsPlugin * plugin, nm_clear_pointer(&priv->set_server_ex_args, g_variant_unref); priv->set_server_ex_args = - g_variant_ref_sink(create_update_args(self, global_config, ip_config_lst_head, hostname)); + g_variant_ref_sink(create_update_args(self, global_config, ip_data_lst_head, hostname)); send_dnsmasq_update(self); return TRUE; diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c index f0ec0c8921..1ca33e46ac 100644 --- a/src/core/dns/nm-dns-manager.c +++ b/src/core/dns/nm-dns-manager.c @@ -7,6 +7,8 @@ #include "src/core/nm-default-daemon.h" +#include "nm-dns-manager.h" + #include #include #include @@ -22,22 +24,20 @@ #include #endif -#include "libnm-glib-aux/nm-str-buf.h" -#include "nm-utils.h" #include "libnm-core-intern/nm-core-internal.h" -#include "nm-dns-manager.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" +#include "libnm-glib-aux/nm-str-buf.h" + #include "NetworkManagerUtils.h" +#include "devices/nm-device.h" #include "nm-config.h" #include "nm-dbus-object.h" -#include "devices/nm-device.h" -#include "nm-manager.h" - -#include "nm-dns-plugin.h" #include "nm-dns-dnsmasq.h" +#include "nm-dns-plugin.h" #include "nm-dns-systemd-resolved.h" #include "nm-dns-unbound.h" +#include "nm-l3-config-data.h" +#include "nm-manager.h" +#include "nm-utils.h" #define HASH_LEN NM_UTILS_CHECKSUM_LENGTH_SHA1 @@ -84,22 +84,21 @@ typedef struct { GHashTable *configs_dict; CList configs_lst_head; - CList ip_config_lst_head; + CList ip_data_lst_head; GVariant *config_variant; - bool ip_config_lst_need_sort : 1; + bool ip_data_lst_need_sort : 1; bool configs_lst_need_sort : 1; bool dns_touched : 1; bool is_stopped : 1; + bool config_changed : 1; + char *hostname; guint updates_queue; - guint8 hash[HASH_LEN]; /* SHA1 hash of current DNS config */ - guint8 prev_hash[HASH_LEN]; /* Hash when begin_updates() was called */ - NMDnsManagerResolvConfManager rc_manager; char * mode; NMDnsPlugin * sd_resolve_plugin; @@ -159,11 +158,6 @@ NM_DEFINE_SINGLETON_GETTER(NMDnsManager, nm_dns_manager_get, NM_TYPE_DNS_MANAGER /*****************************************************************************/ -static void -_ip_config_dns_priority_changed(gpointer config, GParamSpec *pspec, NMDnsConfigIPData *ip_data); - -/*****************************************************************************/ - static gboolean domain_is_valid(const char *domain, gboolean check_public_suffix) { @@ -208,6 +202,24 @@ static NM_UTILS_LOOKUP_STR_DEFINE( /*****************************************************************************/ +static int +_dns_config_ip_data_get_dns_priority1(const NML3ConfigData *l3cd, int addr_family) +{ + int prio; + + if (!nm_l3_config_data_get_dns_priority(l3cd, addr_family, &prio)) + return 0; + + nm_assert(prio != 0); + return prio; +} + +static int +_dns_config_ip_data_get_dns_priority(const NMDnsConfigIPData *ip_data) +{ + return _dns_config_ip_data_get_dns_priority1(ip_data->l3cd, ip_data->addr_family); +} + static void _ASSERT_dns_config_data(const NMDnsConfigData *data) { @@ -221,9 +233,9 @@ _ASSERT_dns_config_ip_data(const NMDnsConfigIPData *ip_data) { nm_assert(ip_data); _ASSERT_dns_config_data(ip_data->data); - nm_assert(NM_IS_IP_CONFIG(ip_data->ip_config)); + nm_assert(NM_IS_L3_CONFIG_DATA(ip_data->l3cd)); nm_assert(c_list_contains(&ip_data->data->data_lst_head, &ip_data->data_lst)); - nm_assert(ip_data->data->ifindex == nm_ip_config_get_ifindex(ip_data->ip_config)); + nm_assert(ip_data->data->ifindex == nm_l3_config_data_get_ifindex(ip_data->l3cd)); #if NM_MORE_ASSERTS > 5 { gboolean has_default = FALSE; @@ -243,37 +255,36 @@ _ASSERT_dns_config_ip_data(const NMDnsConfigIPData *ip_data) if (ip_data->domains.has_default_route_exclusive) nm_assert(ip_data->domains.has_default_route); } + nm_assert(_dns_config_ip_data_get_dns_priority(ip_data) != 0); #endif } static NMDnsConfigIPData * -_dns_config_ip_data_new(NMDnsConfigData * data, - NMIPConfig * ip_config, - NMDnsIPConfigType ip_config_type) +_dns_config_ip_data_new(NMDnsConfigData * data, + int addr_family, + gconstpointer source_tag, + const NML3ConfigData *l3cd, + NMDnsIPConfigType ip_config_type) { NMDnsConfigIPData *ip_data; _ASSERT_dns_config_data(data); - nm_assert(NM_IS_IP_CONFIG(ip_config)); + nm_assert(NM_IS_L3_CONFIG_DATA(l3cd)); nm_assert(ip_config_type != NM_DNS_IP_CONFIG_TYPE_REMOVED); ip_data = g_slice_new(NMDnsConfigIPData); *ip_data = (NMDnsConfigIPData){ .data = data, - .ip_config = g_object_ref(ip_config), + .source_tag = source_tag, + .l3cd = nm_l3_config_data_ref_and_seal(l3cd), .ip_config_type = ip_config_type, + .addr_family = addr_family, }; c_list_link_tail(&data->data_lst_head, &ip_data->data_lst); - c_list_link_tail(&NM_DNS_MANAGER_GET_PRIVATE(data->self)->ip_config_lst_head, - &ip_data->ip_config_lst); + c_list_link_tail(&NM_DNS_MANAGER_GET_PRIVATE(data->self)->ip_data_lst_head, + &ip_data->ip_data_lst); - /* We also need to set priv->ip_config_lst_need_sort, but the caller will do that! */ - - g_signal_connect(ip_config, - NM_IS_IP4_CONFIG(ip_config) ? "notify::" NM_IP4_CONFIG_DNS_PRIORITY - : "notify::" NM_IP6_CONFIG_DNS_PRIORITY, - G_CALLBACK(_ip_config_dns_priority_changed), - ip_data); + /* We also need to set priv->ip_data_lst_need_sort, but the caller will do that! */ _ASSERT_dns_config_ip_data(ip_data); return ip_data; @@ -285,35 +296,15 @@ _dns_config_ip_data_free(NMDnsConfigIPData *ip_data) _ASSERT_dns_config_ip_data(ip_data); c_list_unlink_stale(&ip_data->data_lst); - c_list_unlink_stale(&ip_data->ip_config_lst); + c_list_unlink_stale(&ip_data->ip_data_lst); g_free(ip_data->domains.search); g_strfreev(ip_data->domains.reverse); - g_signal_handlers_disconnect_by_func(ip_data->ip_config, - _ip_config_dns_priority_changed, - ip_data); - - g_object_unref(ip_data->ip_config); + nm_l3_config_data_unref(ip_data->l3cd); nm_g_slice_free(ip_data); } -static NMDnsConfigIPData * -_dns_config_data_find_ip_config(NMDnsConfigData *data, NMIPConfig *ip_config) -{ - NMDnsConfigIPData *ip_data; - - _ASSERT_dns_config_data(data); - - c_list_for_each_entry (ip_data, &data->data_lst_head, data_lst) { - _ASSERT_dns_config_ip_data(ip_data); - - if (ip_data->ip_config == ip_config) - return ip_data; - } - return NULL; -} - static void _dns_config_data_free(NMDnsConfigData *data) { @@ -325,14 +316,13 @@ _dns_config_data_free(NMDnsConfigData *data) } static int -_mgr_get_ip_config_lst_cmp(const CList *a_lst, const CList *b_lst, const void *user_data) +_mgr_get_ip_data_lst_cmp(const CList *a_lst, const CList *b_lst, const void *user_data) { - const NMDnsConfigIPData *a = c_list_entry(a_lst, NMDnsConfigIPData, ip_config_lst); - const NMDnsConfigIPData *b = c_list_entry(b_lst, NMDnsConfigIPData, ip_config_lst); + const NMDnsConfigIPData *a = c_list_entry(a_lst, NMDnsConfigIPData, ip_data_lst); + const NMDnsConfigIPData *b = c_list_entry(b_lst, NMDnsConfigIPData, ip_data_lst); /* Configurations with lower priority value first */ - NM_CMP_DIRECT(nm_ip_config_get_dns_priority(a->ip_config), - nm_ip_config_get_dns_priority(b->ip_config)); + NM_CMP_DIRECT(_dns_config_ip_data_get_dns_priority(a), _dns_config_ip_data_get_dns_priority(b)); /* Sort according to type (descendingly) */ NM_CMP_FIELD(b, a, ip_config_type); @@ -341,16 +331,16 @@ _mgr_get_ip_config_lst_cmp(const CList *a_lst, const CList *b_lst, const void *u } static CList * -_mgr_get_ip_config_lst_head(NMDnsManager *self) +_mgr_get_ip_data_lst_head(NMDnsManager *self) { NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); - if (G_UNLIKELY(priv->ip_config_lst_need_sort)) { - priv->ip_config_lst_need_sort = FALSE; - c_list_sort(&priv->ip_config_lst_head, _mgr_get_ip_config_lst_cmp, NULL); + if (G_UNLIKELY(priv->ip_data_lst_need_sort)) { + priv->ip_data_lst_need_sort = FALSE; + c_list_sort(&priv->ip_data_lst_head, _mgr_get_ip_data_lst_cmp, NULL); } - return &priv->ip_config_lst_head; + return &priv->ip_data_lst_head; } static int @@ -430,28 +420,33 @@ add_dns_option_item(GPtrArray *array, const char *str) } static void -add_dns_domains(GPtrArray * array, - const NMIPConfig *ip_config, - gboolean include_routing, - gboolean dup) +add_dns_domains(GPtrArray * array, + int addr_family, + const NML3ConfigData *l3cd, + gboolean include_routing, + gboolean dup) { - guint num_domains, num_searches, i; - const char *str; + const char *const *domains; + const char *const *searches; + guint num_domains; + guint num_searches; + guint i; + const char * str; - num_domains = nm_ip_config_get_num_domains(ip_config); - num_searches = nm_ip_config_get_num_searches(ip_config); + domains = nm_l3_config_data_get_domains(l3cd, addr_family, &num_domains); + searches = nm_l3_config_data_get_searches(l3cd, addr_family, &num_searches); for (i = 0; i < num_searches; i++) { - str = nm_ip_config_get_search(ip_config, i); + str = searches[i]; if (!include_routing && domain_is_routing(str)) continue; if (!domain_is_valid(nm_utils_parse_dns_domain(str, NULL), FALSE)) continue; add_string_item(array, str, dup); } - if (num_domains > 1 || !num_searches) { + if (num_domains > 1 || num_searches == 0) { for (i = 0; i < num_domains; i++) { - str = nm_ip_config_get_domain(ip_config, i); + str = domains[i]; if (!include_routing && domain_is_routing(str)) continue; if (!domain_is_valid(nm_utils_parse_dns_domain(str, NULL), FALSE)) @@ -462,26 +457,24 @@ add_dns_domains(GPtrArray * array, } static void -merge_one_ip_config(NMResolvConfData *rc, int ifindex, const NMIPConfig *ip_config) +merge_one_l3cd(NMResolvConfData *rc, int addr_family, int ifindex, const NML3ConfigData *l3cd) { - int addr_family; - char buf[NM_UTILS_INET_ADDRSTRLEN + 50]; - gboolean has_trust_ad; - guint num_nameservers; - guint num; - guint i; + char buf[NM_UTILS_INET_ADDRSTRLEN + 50]; + gboolean has_trust_ad; + guint num_nameservers; + guint num; + guint i; + gconstpointer nameservers; + const char *const *strv; - addr_family = nm_ip_config_get_addr_family(ip_config); + nm_assert(ifindex == nm_l3_config_data_get_ifindex(l3cd)); - nm_assert_addr_family(addr_family); - nm_assert(ifindex > 0); - nm_assert(ifindex == nm_ip_config_get_ifindex(ip_config)); - - num_nameservers = nm_ip_config_get_num_nameservers(ip_config); + nameservers = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num_nameservers); for (i = 0; i < num_nameservers; i++) { const NMIPAddr *addr; - addr = nm_ip_config_get_nameserver(ip_config, i); + addr = nm_ip_addr_from_packed_array(addr_family, nameservers, i); + if (addr_family == AF_INET) nm_utils_inet_ntop(addr_family, addr, buf); else if (IN6_IS_ADDR_V4MAPPED(addr)) @@ -502,22 +495,23 @@ merge_one_ip_config(NMResolvConfData *rc, int ifindex, const NMIPConfig *ip_conf add_string_item(rc->nameservers, buf, TRUE); } - add_dns_domains(rc->searches, ip_config, FALSE, TRUE); + add_dns_domains(rc->searches, addr_family, l3cd, FALSE, TRUE); has_trust_ad = FALSE; - num = nm_ip_config_get_num_dns_options(ip_config); + strv = nm_l3_config_data_get_dns_options(l3cd, addr_family, &num); for (i = 0; i < num; i++) { - const char *option = nm_ip_config_get_dns_option(ip_config, i); + const char *option = strv[i]; if (nm_streq(option, NM_SETTING_DNS_OPTION_TRUST_AD)) { has_trust_ad = TRUE; continue; } - add_dns_option_item(rc->options, nm_ip_config_get_dns_option(ip_config, i)); + add_dns_option_item(rc->options, option); } + if (num_nameservers == 0) { - /* If the @ip_config contributes no DNS servers, ignore whether trust-ad is set or unset - * for this @ip_config. */ + /* If the @l3cd contributes no DNS servers, ignore whether trust-ad is set or unset + * for this @l3cd. */ } else if (has_trust_ad) { /* We only set has_trust_ad to TRUE, if all IP configs agree (or don't contribute). * Once set to FALSE, it doesn't get reset. */ @@ -527,20 +521,17 @@ merge_one_ip_config(NMResolvConfData *rc, int ifindex, const NMIPConfig *ip_conf rc->has_trust_ad = NM_TERNARY_FALSE; if (addr_family == AF_INET) { - const NMIP4Config *ip4_config = (const NMIP4Config *) ip_config; + const in_addr_t *nis_servers; + const char * nis_domain; - /* NIS stuff */ - num = nm_ip4_config_get_num_nis_servers(ip4_config); - for (i = 0; i < num; i++) { - add_string_item(rc->nis_servers, - _nm_utils_inet4_ntop(nm_ip4_config_get_nis_server(ip4_config, i), buf), - TRUE); - } + nis_servers = nm_l3_config_data_get_nis_servers(l3cd, &num); + for (i = 0; i < num; i++) + add_string_item(rc->nis_servers, _nm_utils_inet4_ntop(nis_servers[i], buf), TRUE); - if (nm_ip4_config_get_nis_domain(ip4_config)) { + if ((nis_domain = nm_l3_config_data_get_nis_domain(l3cd))) { /* FIXME: handle multiple domains */ if (!rc->nis_domain) - rc->nis_domain = nm_ip4_config_get_nis_domain(ip4_config); + rc->nis_domain = nis_domain; } } } @@ -1106,30 +1097,6 @@ update_resolv_conf(NMDnsManager * self, return write_file_result; } -static void -compute_hash(NMDnsManager *self, const NMGlobalDnsConfig *global, guint8 buffer[static HASH_LEN]) -{ - nm_auto_free_checksum GChecksum *sum = NULL; - NMDnsConfigIPData * ip_data; - - sum = g_checksum_new(G_CHECKSUM_SHA1); - nm_assert(HASH_LEN == g_checksum_type_get_length(G_CHECKSUM_SHA1)); - - if (global) - nm_global_dns_config_update_checksum(global, sum); - else { - const CList *head; - - /* FIXME(ip-config-checksum): this relies on the fact that an IP - * configuration without DNS parameters gives a zero checksum. */ - head = _mgr_get_ip_config_lst_head(self); - c_list_for_each_entry (ip_data, head, ip_config_lst) - nm_ip_config_hash(ip_data->ip_config, sum, TRUE); - } - - nm_utils_checksum_get_digest_len(sum, buffer, HASH_LEN); -} - static gboolean merge_global_dns_config(NMResolvConfData *rc, NMGlobalDnsConfig *global_conf) { @@ -1172,19 +1139,21 @@ merge_global_dns_config(NMResolvConfData *rc, NMGlobalDnsConfig *global_conf) } static const char * -get_nameserver_list(const NMIPConfig *config, NMStrBuf *tmp_strbuf) +get_nameserver_list(int addr_family, const NML3ConfigData *l3cd, NMStrBuf *tmp_strbuf) { - char buf[NM_UTILS_INET_ADDRSTRLEN]; - int addr_family; - guint num; - guint i; + char buf[NM_UTILS_INET_ADDRSTRLEN]; + guint num; + guint i; + gconstpointer nameservers; nm_str_buf_reset(tmp_strbuf); - addr_family = nm_ip_config_get_addr_family(config); - num = nm_ip_config_get_num_nameservers(config); + nameservers = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num); for (i = 0; i < num; i++) { - nm_utils_inet_ntop(addr_family, nm_ip_config_get_nameserver(config, i), buf); + const NMIPAddr *addr; + + addr = nm_ip_addr_from_packed_array(addr_family, nameservers, i); + nm_utils_inet_ntop(addr_family, addr->addr_ptr, buf); if (i > 0) nm_str_buf_append_c(tmp_strbuf, ' '); nm_str_buf_append(tmp_strbuf, buf); @@ -1227,36 +1196,39 @@ _collect_resolv_conf_data(NMDnsManager * self, merge_global_dns_config(&rc, global_config); else { nm_auto_str_buf NMStrBuf tmp_strbuf = NM_STR_BUF_INIT(0, FALSE); - int prio; int first_prio = 0; const NMDnsConfigIPData *ip_data; const CList * head; gboolean is_first = TRUE; - head = _mgr_get_ip_config_lst_head(self); - c_list_for_each_entry (ip_data, head, ip_config_lst) { + head = _mgr_get_ip_data_lst_head(self); + c_list_for_each_entry (ip_data, head, ip_data_lst) { gboolean skip = FALSE; + int dns_priority; _ASSERT_dns_config_ip_data(ip_data); - prio = nm_ip_config_get_dns_priority(ip_data->ip_config); + if (!nm_l3_config_data_get_dns_priority(ip_data->l3cd, + ip_data->addr_family, + &dns_priority)) + nm_assert_not_reached(); if (is_first) { is_first = FALSE; - first_prio = prio; - } else if (first_prio < 0 && first_prio != prio) + first_prio = dns_priority; + } else if (first_prio < 0 && first_prio != dns_priority) skip = TRUE; _LOGT("config: %8d %-7s v%c %-5d %s: %s", - prio, + dns_priority, _config_type_to_string(ip_data->ip_config_type), - nm_utils_addr_family_to_char(nm_ip_config_get_addr_family(ip_data->ip_config)), + nm_utils_addr_family_to_char(ip_data->addr_family), ip_data->data->ifindex, skip ? "" : "", - get_nameserver_list(ip_data->ip_config, &tmp_strbuf)); + get_nameserver_list(ip_data->addr_family, ip_data->l3cd, &tmp_strbuf)); if (!skip) - merge_one_ip_config(&rc, ip_data->data->ifindex, ip_data->ip_config); + merge_one_l3cd(&rc, ip_data->addr_family, ip_data->data->ifindex, ip_data->l3cd); } } @@ -1292,27 +1264,32 @@ _collect_resolv_conf_data(NMDnsManager * self, /*****************************************************************************/ static char ** -get_ip_rdns_domains(NMIPConfig *ip_config) +get_ip_rdns_domains(int addr_family, const NML3ConfigData *l3cd) { - int addr_family = nm_ip_config_get_addr_family(ip_config); - char ** strv; - GPtrArray * domains; - NMDedupMultiIter ipconf_iter; - const NMPlatformIPAddress *address; - const NMPlatformIPRoute * route; - - nm_assert_addr_family(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + char ** strv; + GPtrArray * domains; + NMDedupMultiIter ipconf_iter; + const NMPObject *obj; domains = g_ptr_array_sized_new(5); - nm_ip_config_iter_ip_address_for_each (&ipconf_iter, ip_config, &address) { + nm_l3_config_data_iter_obj_for_each (&ipconf_iter, + l3cd, + &obj, + NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)) { nm_utils_get_reverse_dns_domains_ip(addr_family, - address->address_ptr, - address->plen, + NMP_OBJECT_CAST_IP_ADDRESS(obj)->address_ptr, + NMP_OBJECT_CAST_IP_ADDRESS(obj)->plen, domains); } - nm_ip_config_iter_ip_route_for_each (&ipconf_iter, ip_config, &route) { + nm_l3_config_data_iter_obj_for_each (&ipconf_iter, + l3cd, + &obj, + NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { + const NMPlatformIPRoute *route = NMP_OBJECT_CAST_IP_ROUTE(obj); + if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route)) { nm_utils_get_reverse_dns_domains_ip(addr_family, route->network_ptr, @@ -1394,12 +1371,12 @@ _mgr_configs_data_construct(NMDnsManager *self) CList * head; int prev_priority = G_MININT; - head = _mgr_get_ip_config_lst_head(self); + head = _mgr_get_ip_data_lst_head(self); #if NM_MORE_ASSERTS /* we call _mgr_configs_data_clear() at the end of update. We * don't expect any domain settings here. */ - c_list_for_each_entry (ip_data, head, ip_config_lst) { + c_list_for_each_entry (ip_data, head, ip_data_lst) { nm_assert(!ip_data->domains.search); nm_assert(!ip_data->domains.reverse); nm_assert(!ip_data->domains.has_default_route_explicit); @@ -1408,15 +1385,17 @@ _mgr_configs_data_construct(NMDnsManager *self) } #endif - c_list_for_each_entry (ip_data, head, ip_config_lst) { - NMIPConfig *ip_config = ip_data->ip_config; - gboolean add_wildcard = FALSE; + c_list_for_each_entry (ip_data, head, ip_data_lst) { + gboolean add_wildcard = FALSE; + guint num; - if (!nm_ip_config_get_num_nameservers(ip_config)) + nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num); + if (num == 0) continue; - if (nm_ip_config_best_default_route_get(ip_config)) + if (nm_l3_config_data_get_best_default_route(ip_data->l3cd, ip_data->addr_family)) { + /* FIXME(l3cfg): the best-default route of a l3cd is not significant! */ add_wildcard = TRUE; - else { + } else { /* If a VPN has never-default=no but doesn't get a default * route (this can happen for example when the server * pushes routes with openconnect), and there are no @@ -1424,9 +1403,10 @@ _mgr_configs_data_construct(NMDnsManager *self) * by the server would be unused. It is preferable in this * case to use the VPN DNS server for all queries. */ if (ip_data->ip_config_type == NM_DNS_IP_CONFIG_TYPE_VPN - && !nm_ip_config_get_never_default(ip_data->ip_config) - && nm_ip_config_get_num_searches(ip_data->ip_config) == 0 - && nm_ip_config_get_num_domains(ip_data->ip_config) == 0) + && nm_l3_config_data_get_never_default(ip_data->l3cd, ip_data->addr_family) + == NM_TERNARY_FALSE + && !nm_l3_config_data_get_searches(ip_data->l3cd, ip_data->addr_family, NULL) + && !nm_l3_config_data_get_domains(ip_data->l3cd, ip_data->addr_family, NULL)) add_wildcard = TRUE; } @@ -1437,29 +1417,33 @@ _mgr_configs_data_construct(NMDnsManager *self) } } - c_list_for_each_entry (ip_data, head, ip_config_lst) { - NMIPConfig * ip_config = ip_data->ip_config; - int priority; - const char **domains; - guint n_searches; - guint n_domains; - guint num_dom1; - guint num_dom2; - guint n_domains_allocated; - guint i; - gboolean has_default_route_maybe = FALSE; - gboolean has_default_route_explicit = FALSE; - gboolean has_default_route_auto = FALSE; + c_list_for_each_entry (ip_data, head, ip_data_lst) { + int priority; + const char ** domains; + const char *const *strv_searches; + const char *const *strv_domains; + guint n_searches; + guint n_domains; + guint num_dom1; + guint num_dom2; + guint n_domains_allocated; + guint i; + gboolean has_default_route_maybe = FALSE; + gboolean has_default_route_explicit = FALSE; + gboolean has_default_route_auto = FALSE; + guint num; - if (!nm_ip_config_get_num_nameservers(ip_config)) + nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num); + if (num == 0) continue; - n_searches = nm_ip_config_get_num_searches(ip_config); - n_domains = nm_ip_config_get_num_domains(ip_config); + strv_searches = + nm_l3_config_data_get_searches(ip_data->l3cd, ip_data->addr_family, &n_searches); + strv_domains = + nm_l3_config_data_get_domains(ip_data->l3cd, ip_data->addr_family, &n_domains); - priority = nm_ip_config_get_dns_priority(ip_config); + priority = _dns_config_ip_data_get_dns_priority(ip_data); - nm_assert(priority != 0); nm_assert(prev_priority <= priority); prev_priority = priority; @@ -1487,10 +1471,10 @@ _mgr_configs_data_construct(NMDnsManager *self) /* searches are preferred over domains */ if (n_searches > 0) { for (i = 0; i < n_searches; i++) - domains[num_dom1++] = nm_ip_config_get_search(ip_config, i); + domains[num_dom1++] = strv_searches[i]; } else { for (i = 0; i < n_domains; i++) - domains[num_dom1++] = nm_ip_config_get_domain(ip_config, i); + domains[num_dom1++] = strv_domains[i]; } nm_assert(num_dom1 < n_domains_allocated); @@ -1578,8 +1562,8 @@ _mgr_configs_data_construct(NMDnsManager *self) nm_assert(!ip_data->domains.search); nm_assert(!ip_data->domains.reverse); - ip_data->domains.search = domains; - ip_data->domains.reverse = get_ip_rdns_domains(ip_config); + ip_data->domains.search = domains; + ip_data->domains.reverse = get_ip_rdns_domains(ip_data->addr_family, ip_data->l3cd); ip_data->domains.has_default_route_explicit = has_default_route_explicit; ip_data->domains.has_default_route_exclusive = has_default_route_explicit || (priority < 0 && has_default_route_auto); @@ -1611,8 +1595,8 @@ _mgr_configs_data_clear(NMDnsManager *self) NMDnsConfigIPData *ip_data; CList * head; - head = _mgr_get_ip_config_lst_head(self); - c_list_for_each_entry (ip_data, head, ip_config_lst) { + head = _mgr_get_ip_data_lst_head(self); + c_list_for_each_entry (ip_data, head, ip_data_lst) { nm_clear_g_free(&ip_data->domains.search); nm_clear_pointer(&ip_data->domains.reverse, g_strfreev); ip_data->domains.has_default_route_explicit = FALSE; @@ -1643,6 +1627,8 @@ update_dns(NMDnsManager *self, gboolean no_caching, gboolean force_emit, GError nm_assert(!error || !*error); + priv->config_changed = FALSE; + if (priv->is_stopped) { _LOGD("update-dns: not updating resolv.conf (is stopped)"); return TRUE; @@ -1663,9 +1649,6 @@ update_dns(NMDnsManager *self, gboolean no_caching, gboolean force_emit, GError data = nm_config_get_data(priv->config); global_config = nm_config_data_get_global_dns_config(data); - /* Update hash with config we're applying */ - compute_hash(self, global_config, priv->hash); - _collect_resolv_conf_data(self, global_config, &searches, @@ -1680,7 +1663,7 @@ update_dns(NMDnsManager *self, gboolean no_caching, gboolean force_emit, GError if (priv->sd_resolve_plugin) { nm_dns_plugin_update(priv->sd_resolve_plugin, global_config, - _mgr_get_ip_config_lst_head(self), + _mgr_get_ip_data_lst_head(self), priv->hostname, NULL); } @@ -1702,7 +1685,7 @@ update_dns(NMDnsManager *self, gboolean no_caching, gboolean force_emit, GError _LOGD("update-dns: updating plugin %s", plugin_name); if (!nm_dns_plugin_update(plugin, global_config, - _mgr_get_ip_config_lst_head(self), + _mgr_get_ip_data_lst_head(self), priv->hostname, &plugin_error)) { _LOGW("update-dns: plugin %s update failed: %s", plugin_name, plugin_error->message); @@ -1834,53 +1817,101 @@ plugin_skip:; /*****************************************************************************/ -static void -_ip_config_dns_priority_changed(gpointer config, GParamSpec *pspec, NMDnsConfigIPData *ip_data) -{ - _ASSERT_dns_config_ip_data(ip_data); - - NM_DNS_MANAGER_GET_PRIVATE(ip_data->data->self)->ip_config_lst_need_sort = TRUE; -} - gboolean -nm_dns_manager_set_ip_config(NMDnsManager * self, - NMIPConfig * ip_config, - NMDnsIPConfigType ip_config_type) +nm_dns_manager_set_ip_config(NMDnsManager * self, + int addr_family, + gconstpointer source_tag, + const NML3ConfigData *l3cd, + NMDnsIPConfigType ip_config_type, + gboolean replace_all) { NMDnsManagerPrivate *priv; - NMDnsConfigIPData * ip_data; NMDnsConfigData * data; int ifindex; + gboolean changed = FALSE; + NMDnsConfigIPData * ip_data = NULL; + int dns_priority; g_return_val_if_fail(NM_IS_DNS_MANAGER(self), FALSE); - g_return_val_if_fail(NM_IS_IP_CONFIG(ip_config), FALSE); + g_return_val_if_fail(!l3cd || NM_IS_L3_CONFIG_DATA(l3cd), FALSE); + g_return_val_if_fail(source_tag, FALSE); - ifindex = nm_ip_config_get_ifindex(ip_config); - g_return_val_if_fail(ifindex > 0, FALSE); + if (addr_family == AF_UNSPEC) { + /* Setting AF_UNSPEC is a shortcut for calling this function twice for AF_INET and + * AF_INET6. */ + if (nm_dns_manager_set_ip_config(self, + AF_INET, + source_tag, + l3cd, + ip_config_type, + replace_all)) + changed = TRUE; + if (nm_dns_manager_set_ip_config(self, + AF_INET6, + source_tag, + l3cd, + ip_config_type, + replace_all)) + changed = TRUE; + return changed; + } + + nm_assert_addr_family(addr_family); priv = NM_DNS_MANAGER_GET_PRIVATE(self); - data = g_hash_table_lookup(priv->configs_dict, &ifindex); - if (!data) - ip_data = NULL; - else - ip_data = _dns_config_data_find_ip_config(data, ip_config); - - if (ip_config_type == NM_DNS_IP_CONFIG_TYPE_REMOVED) { - if (!ip_data) - return FALSE; - /* deleting a config doesn't invalidate the configs' sort order. */ - _dns_config_ip_data_free(ip_data); - if (c_list_is_empty(&data->data_lst_head)) - g_hash_table_remove(priv->configs_dict, &ifindex); - goto changed; + data = NULL; + if (l3cd) { + ifindex = nm_l3_config_data_get_ifindex(l3cd); + nm_assert(ifindex > 0); + data = g_hash_table_lookup(priv->configs_dict, &ifindex); } + if (data) { + NMDnsConfigIPData *ip_data_iter; + NMDnsConfigIPData *ip_data_safe; + + c_list_for_each_entry_safe (ip_data_iter, ip_data_safe, &data->data_lst_head, data_lst) { + _ASSERT_dns_config_ip_data(ip_data_iter); + + if (ip_data_iter->source_tag != source_tag) + continue; + if (ip_data_iter->addr_family != addr_family) + continue; + + if (ip_config_type != NM_DNS_IP_CONFIG_TYPE_REMOVED && ip_data_iter->l3cd == l3cd) { + nm_assert(!ip_data); + ip_data = ip_data_iter; + continue; + } + + if (!replace_all && l3cd && ip_data_iter->l3cd != l3cd) + continue; + + changed = TRUE; + _dns_config_ip_data_free(ip_data_iter); + } + } + + if (ip_config_type == NM_DNS_IP_CONFIG_TYPE_REMOVED) + goto done; + + if (!l3cd) + goto done; + if (ip_data && ip_data->ip_config_type == ip_config_type) { /* nothing to do. */ - return FALSE; + goto done; } + dns_priority = _dns_config_ip_data_get_dns_priority1(l3cd, addr_family); + if (dns_priority == 0) { + /* no DNS priority for this address family. Skip it! */ + goto done; + } + + changed = TRUE; + if (!data) { data = g_slice_new(NMDnsConfigData); *data = (NMDnsConfigData){ @@ -1895,13 +1926,28 @@ nm_dns_manager_set_ip_config(NMDnsManager * self, } if (!ip_data) - ip_data = _dns_config_ip_data_new(data, ip_config, ip_config_type); + ip_data = _dns_config_ip_data_new(data, addr_family, source_tag, l3cd, ip_config_type); else ip_data->ip_config_type = ip_config_type; - priv->ip_config_lst_need_sort = TRUE; + priv->ip_data_lst_need_sort = TRUE; + + nm_assert(l3cd); + nm_assert(ip_config_type != NM_DNS_IP_CONFIG_TYPE_REMOVED); + nm_assert(ip_data->addr_family == addr_family); + nm_assert(ip_data->source_tag == source_tag); + nm_assert(ip_data->l3cd == l3cd); + nm_assert(ip_data->ip_config_type == ip_config_type); + +done: + if (!changed) + return FALSE; + + priv->config_changed = TRUE; + + if (data && c_list_is_empty(&data->data_lst_head)) + g_hash_table_remove(priv->configs_dict, data); -changed: if (!priv->updates_queue) { gs_free_error GError *error = NULL; @@ -1957,11 +2003,8 @@ nm_dns_manager_begin_updates(NMDnsManager *self, const char *func) NMDnsManagerPrivate *priv; g_return_if_fail(self != NULL); - priv = NM_DNS_MANAGER_GET_PRIVATE(self); - /* Save current hash when starting a new batch */ - if (priv->updates_queue == 0) - memcpy(priv->prev_hash, priv->hash, sizeof(priv->hash)); + priv = NM_DNS_MANAGER_GET_PRIVATE(self); priv->updates_queue++; @@ -1973,20 +2016,16 @@ nm_dns_manager_end_updates(NMDnsManager *self, const char *func) { NMDnsManagerPrivate *priv; gs_free_error GError *error = NULL; - gboolean changed; - guint8 new[HASH_LEN]; g_return_if_fail(self != NULL); priv = NM_DNS_MANAGER_GET_PRIVATE(self); g_return_if_fail(priv->updates_queue > 0); - compute_hash(self, nm_config_data_get_global_dns_config(nm_config_get_data(priv->config)), new); - changed = (memcmp(new, priv->prev_hash, sizeof(new)) != 0) ? TRUE : FALSE; - _LOGD("(%s): DNS configuration %s", func, changed ? "changed" : "did not change"); + _LOGD("(%s): DNS configuration %s", func, priv->config_changed ? "changed" : "did not change"); priv->updates_queue--; - if ((priv->updates_queue > 0) || (changed == FALSE)) { + if ((priv->updates_queue > 0) || !priv->config_changed) { _LOGD("(%s): no DNS changes to commit (%d)", func, priv->updates_queue); return; } @@ -1995,8 +2034,6 @@ nm_dns_manager_end_updates(NMDnsManager *self, const char *func) _LOGD("(%s): committing DNS changes (%d)", func, priv->updates_queue); if (!update_dns(self, FALSE, FALSE, &error)) _LOGW("could not commit DNS changes: %s", error->message); - - memset(priv->prev_hash, 0, sizeof(priv->prev_hash)); } void @@ -2319,6 +2356,8 @@ config_changed_cb(NMConfig * config, NMConfigData * old_data, NMDnsManager * self) { + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); + if (NM_FLAGS_ANY(changes, NM_CONFIG_CHANGE_DNS_MODE | NM_CONFIG_CHANGE_RC_MANAGER | NM_CONFIG_CHANGE_CAUSE_SIGHUP | NM_CONFIG_CHANGE_CAUSE_DNS_FULL)) { @@ -2338,6 +2377,7 @@ config_changed_cb(NMConfig * config, | NM_CONFIG_CHANGE_GLOBAL_DNS_CONFIG)) { gs_free_error GError *error = NULL; + priv->config_changed = TRUE; if (!update_dns(self, FALSE, TRUE, &error)) _LOGW("could not commit DNS changes: %s", error->message); } @@ -2415,51 +2455,54 @@ _get_config_variant(NMDnsManager *self) g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); - head = _mgr_get_ip_config_lst_head(self); - c_list_for_each_entry (ip_data, head, ip_config_lst) { - const NMIPConfig *ip_config = ip_data->ip_config; - GVariantBuilder entry_builder; - GVariantBuilder strv_builder; - guint i, num; - const int addr_family = nm_ip_config_get_addr_family(ip_config); - char buf[NM_UTILS_INET_ADDRSTRLEN]; - const NMIPAddr * addr; - const char * ifname; + head = _mgr_get_ip_data_lst_head(self); + c_list_for_each_entry (ip_data, head, ip_data_lst) { + GVariantBuilder entry_builder; + GVariantBuilder strv_builder; + guint num; + guint num_domains; + guint num_searches; + guint i; + char buf[NM_UTILS_INET_ADDRSTRLEN]; + const char * ifname; + gconstpointer nameservers; - num = nm_ip_config_get_num_nameservers(ip_config); - if (!num) + nameservers = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num); + if (num == 0) continue; g_variant_builder_init(&entry_builder, G_VARIANT_TYPE("a{sv}")); g_variant_builder_init(&strv_builder, G_VARIANT_TYPE("as")); for (i = 0; i < num; i++) { - addr = nm_ip_config_get_nameserver(ip_config, i); - g_variant_builder_add(&strv_builder, "s", nm_utils_inet_ntop(addr_family, addr, buf)); + const NMIPAddr *addr; + + addr = nm_ip_addr_from_packed_array(ip_data->addr_family, nameservers, i); + g_variant_builder_add(&strv_builder, + "s", + nm_utils_inet_ntop(ip_data->addr_family, addr, buf)); } g_variant_builder_add(&entry_builder, "{sv}", "nameservers", g_variant_builder_end(&strv_builder)); - num = nm_ip_config_get_num_domains(ip_config); - num += nm_ip_config_get_num_searches(ip_config); + nm_l3_config_data_get_domains(ip_data->l3cd, ip_data->addr_family, &num_domains); + nm_l3_config_data_get_searches(ip_data->l3cd, ip_data->addr_family, &num_searches); + num = num_domains + num_searches; if (num > 0) { if (!array_domains) array_domains = g_ptr_array_sized_new(num); else g_ptr_array_set_size(array_domains, 0); - add_dns_domains(array_domains, ip_config, TRUE, FALSE); + add_dns_domains(array_domains, ip_data->addr_family, ip_data->l3cd, TRUE, FALSE); if (array_domains->len) { - g_variant_builder_init(&strv_builder, G_VARIANT_TYPE("as")); - for (i = 0; i < array_domains->len; i++) { - g_variant_builder_add(&strv_builder, "s", array_domains->pdata[i]); - } g_variant_builder_add(&entry_builder, "{sv}", "domains", - g_variant_builder_end(&strv_builder)); + g_variant_new_strv((const char *const *) array_domains->pdata, + array_domains->len)); } } @@ -2474,7 +2517,7 @@ _get_config_variant(NMDnsManager *self) g_variant_builder_add(&entry_builder, "{sv}", "priority", - g_variant_new_int32(nm_ip_config_get_dns_priority(ip_config))); + g_variant_new_int32(_dns_config_ip_data_get_dns_priority(ip_data))); g_variant_builder_add( &entry_builder, @@ -2521,7 +2564,7 @@ nm_dns_manager_init(NMDnsManager *self) _LOGT("creating..."); c_list_init(&priv->configs_lst_head); - c_list_init(&priv->ip_config_lst_head); + c_list_init(&priv->ip_data_lst_head); priv->config = g_object_ref(nm_config_get()); @@ -2531,9 +2574,6 @@ nm_dns_manager_init(NMDnsManager *self) (GDestroyNotify) _dns_config_data_free, NULL); - /* Set the initial hash */ - compute_hash(self, NULL, NM_DNS_MANAGER_GET_PRIVATE(self)->hash); - g_signal_connect(G_OBJECT(priv->config), NM_CONFIG_SIGNAL_CONFIG_CHANGED, G_CALLBACK(config_changed_cb), @@ -2559,7 +2599,7 @@ dispose(GObject *object) g_clear_object(&priv->sd_resolve_plugin); _clear_plugin(self); - c_list_for_each_entry_safe (ip_data, ip_data_safe, &priv->ip_config_lst_head, ip_config_lst) + c_list_for_each_entry_safe (ip_data, ip_data_safe, &priv->ip_data_lst_head, ip_data_lst) _dns_config_ip_data_free(ip_data); nm_clear_pointer(&priv->configs_dict, g_hash_table_destroy); diff --git a/src/core/dns/nm-dns-manager.h b/src/core/dns/nm-dns-manager.h index 1972a5dd7a..2b5ca634b1 100644 --- a/src/core/dns/nm-dns-manager.h +++ b/src/core/dns/nm-dns-manager.h @@ -8,8 +8,7 @@ #ifndef __NETWORKMANAGER_DNS_MANAGER_H__ #define __NETWORKMANAGER_DNS_MANAGER_H__ -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" +#include "c-list/src/c-list.h" #include "nm-setting-connection.h" #include "nm-dns-plugin.h" @@ -28,10 +27,12 @@ struct _NMDnsManager; typedef struct { struct _NMDnsConfigData *data; - NMIPConfig * ip_config; + gconstpointer source_tag; + const NML3ConfigData * l3cd; CList data_lst; - CList ip_config_lst; + CList ip_data_lst; NMDnsIPConfigType ip_config_type; + int addr_family; struct { const char **search; char ** reverse; @@ -97,9 +98,12 @@ NMDnsManager *nm_dns_manager_get(void); void nm_dns_manager_begin_updates(NMDnsManager *self, const char *func); void nm_dns_manager_end_updates(NMDnsManager *self, const char *func); -gboolean nm_dns_manager_set_ip_config(NMDnsManager * self, - NMIPConfig * ip_config, - NMDnsIPConfigType ip_config_type); +gboolean nm_dns_manager_set_ip_config(NMDnsManager * self, + int addr_family, + gconstpointer source_tag, + const NML3ConfigData *l3cd, + NMDnsIPConfigType ip_config_type, + gboolean replace_all); void nm_dns_manager_set_initial_hostname(NMDnsManager *self, const char *hostname); void nm_dns_manager_set_hostname(NMDnsManager *self, const char *hostname, gboolean skip_update); diff --git a/src/core/dns/nm-dns-systemd-resolved.c b/src/core/dns/nm-dns-systemd-resolved.c index 445f8498a7..c9d6cc5fea 100644 --- a/src/core/dns/nm-dns-systemd-resolved.c +++ b/src/core/dns/nm-dns-systemd-resolved.c @@ -21,10 +21,9 @@ #include "libnm-core-intern/nm-core-internal.h" #include "libnm-platform/nm-platform.h" #include "nm-utils.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" #include "nm-dbus-manager.h" #include "nm-manager.h" +#include "nm-l3-config-data.h" #include "nm-setting-connection.h" #include "devices/nm-device.h" #include "NetworkManagerUtils.h" @@ -246,40 +245,42 @@ static gboolean update_add_ip_config(NMDnsSystemdResolved *self, GVariantBuilder * dns, GVariantBuilder * domains, - NMDnsConfigIPData * data) + NMDnsConfigIPData * ip_data) { - int addr_family; - gsize addr_size; - guint i, n; - gboolean is_routing; - const char *domain; - gboolean has_config = FALSE; + gsize addr_size; + guint n; + guint i; + gboolean is_routing; + const char * domain; + gboolean has_config = FALSE; + gconstpointer nameservers; - addr_family = nm_ip_config_get_addr_family(data->ip_config); - addr_size = nm_utils_addr_family_to_size(addr_family); + addr_size = nm_utils_addr_family_to_size(ip_data->addr_family); - if ((!data->domains.search || !data->domains.search[0]) - && !data->domains.has_default_route_exclusive && !data->domains.has_default_route) + if ((!ip_data->domains.search || !ip_data->domains.search[0]) + && !ip_data->domains.has_default_route_exclusive && !ip_data->domains.has_default_route) return FALSE; - n = nm_ip_config_get_num_nameservers(data->ip_config); + nameservers = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &n); for (i = 0; i < n; i++) { g_variant_builder_open(dns, G_VARIANT_TYPE("(iay)")); - g_variant_builder_add(dns, "i", addr_family); + g_variant_builder_add(dns, "i", ip_data->addr_family); g_variant_builder_add_value( dns, - nm_g_variant_new_ay(nm_ip_config_get_nameserver(data->ip_config, i), addr_size)); + nm_g_variant_new_ay(nm_ip_addr_from_packed_array(ip_data->addr_family, nameservers, i), + addr_size)); g_variant_builder_close(dns); has_config = TRUE; } - if (!data->domains.has_default_route_explicit && data->domains.has_default_route_exclusive) { + if (!ip_data->domains.has_default_route_explicit + && ip_data->domains.has_default_route_exclusive) { g_variant_builder_add(domains, "(sb)", ".", TRUE); has_config = TRUE; } - if (data->domains.search) { - for (i = 0; data->domains.search[i]; i++) { - domain = nm_utils_parse_dns_domain(data->domains.search[i], &is_routing); + if (ip_data->domains.search) { + for (i = 0; ip_data->domains.search[i]; i++) { + domain = nm_utils_parse_dns_domain(ip_data->domains.search[i], &is_routing); g_variant_builder_add(domains, "(sb)", domain[0] ? domain : ".", is_routing); has_config = TRUE; } @@ -321,19 +322,17 @@ prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic) g_variant_builder_open(&domains, G_VARIANT_TYPE("a(sb)")); c_list_for_each_entry (elem, &ic->configs_lst_head, lst) { - NMDnsConfigIPData *data = elem->data; - NMIPConfig * ip_config = data->ip_config; + NMDnsConfigIPData *ip_data = elem->data; - has_config |= update_add_ip_config(self, &dns, &domains, data); + has_config |= update_add_ip_config(self, &dns, &domains, ip_data); - if (data->domains.has_default_route) + if (ip_data->domains.has_default_route) has_default_route = TRUE; - if (NM_IS_IP4_CONFIG(ip_config)) { - mdns = NM_MAX(mdns, nm_ip4_config_mdns_get(NM_IP4_CONFIG(ip_config))); - llmnr = NM_MAX(llmnr, nm_ip4_config_llmnr_get(NM_IP4_CONFIG(ip_config))); - dns_over_tls = - NM_MAX(dns_over_tls, nm_ip4_config_dns_over_tls_get(NM_IP4_CONFIG(ip_config))); + if (NM_IS_IPv4(ip_data->addr_family)) { + mdns = NM_MAX(mdns, nm_l3_config_data_get_mdns(ip_data->l3cd)); + llmnr = NM_MAX(llmnr, nm_l3_config_data_get_llmnr(ip_data->l3cd)); + dns_over_tls = NM_MAX(dns_over_tls, nm_l3_config_data_get_dns_over_tls(ip_data->l3cd)); } } @@ -551,7 +550,7 @@ start_resolve: static gboolean update(NMDnsPlugin * plugin, const NMGlobalDnsConfig *global_config, - const CList * ip_config_lst_head, + const CList * ip_data_lst_head, const char * hostname, GError ** error) { @@ -569,11 +568,11 @@ update(NMDnsPlugin * plugin, interfaces = g_hash_table_new_full(nm_direct_hash, NULL, NULL, (GDestroyNotify) _interface_config_free); - c_list_for_each_entry (ip_data, ip_config_lst_head, ip_config_lst) { + c_list_for_each_entry (ip_data, ip_data_lst_head, ip_data_lst) { InterfaceConfig *ic = NULL; ifindex = ip_data->data->ifindex; - nm_assert(ifindex == nm_ip_config_get_ifindex(ip_data->ip_config)); + nm_assert(ifindex == nm_l3_config_data_get_ifindex(ip_data->l3cd)); ic = g_hash_table_lookup(interfaces, GINT_TO_POINTER(ifindex)); if (!ic) { diff --git a/src/core/dnsmasq/nm-dnsmasq-manager.c b/src/core/dnsmasq/nm-dnsmasq-manager.c index e8697e817e..f4eea33a13 100644 --- a/src/core/dnsmasq/nm-dnsmasq-manager.c +++ b/src/core/dnsmasq/nm-dnsmasq-manager.c @@ -17,6 +17,7 @@ #include "nm-dnsmasq-utils.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" +#include "nm-l3-config-data.h" #include "libnm-core-intern/nm-core-internal.h" #define CONFDIR NMCONFDIR "/dnsmasq-shared.d" @@ -85,24 +86,28 @@ dm_watch_cb(GPid pid, int status, gpointer user_data) } static GPtrArray * -create_dm_cmd_line(const char * iface, - const NMIP4Config *ip4_config, - const char * pidfile, - gboolean announce_android_metered, - GError ** error) +create_dm_cmd_line(const char * iface, + const NML3ConfigData *l3cd, + const char * pidfile, + gboolean announce_android_metered, + GError ** error) { gs_unref_ptrarray GPtrArray *cmd = NULL; nm_auto_free_gstring GString *s = NULL; char first[INET_ADDRSTRLEN]; char last[INET_ADDRSTRLEN]; char listen_address_s[INET_ADDRSTRLEN]; - char tmpaddr[INET_ADDRSTRLEN]; + char sbuf_addr[INET_ADDRSTRLEN]; gs_free char * error_desc = NULL; const char * dm_binary; const NMPlatformIP4Address * listen_address; - guint i, n; + const in_addr_t * ipv4arr; + const char *const * strarr; + guint n; + guint i; - listen_address = nm_ip4_config_get_first_address(ip4_config); + listen_address = NMP_OBJECT_CAST_IP4_ADDRESS( + nm_l3_config_data_get_first_obj(l3cd, NMP_OBJECT_TYPE_IP4_ADDRESS, NULL)); g_return_val_if_fail(listen_address, NULL); @@ -151,28 +156,28 @@ create_dm_cmd_line(const char * iface, nm_strv_ptrarray_add_string_printf(cmd, "--dhcp-range=%s,%s,60m", first, last); - if (nm_ip4_config_best_default_route_get(ip4_config)) { + if (nm_l3_config_data_get_best_default_route(l3cd, AF_INET)) { nm_strv_ptrarray_add_string_concat(cmd, "--dhcp-option=option:router,", listen_address_s); } - if ((n = nm_ip4_config_get_num_nameservers(ip4_config))) { + ipv4arr = nm_l3_config_data_get_nameservers(l3cd, AF_INET, &n); + if (n > 0) { nm_gstring_prepare(&s); g_string_append(s, "--dhcp-option=option:dns-server"); for (i = 0; i < n; i++) { g_string_append_c(s, ','); - g_string_append( - s, - _nm_utils_inet4_ntop(nm_ip4_config_get_nameserver(ip4_config, i), tmpaddr)); + g_string_append(s, _nm_utils_inet4_ntop(ipv4arr[i], sbuf_addr)); } nm_strv_ptrarray_take_gstring(cmd, &s); } - if ((n = nm_ip4_config_get_num_searches(ip4_config))) { + strarr = nm_l3_config_data_get_searches(l3cd, AF_INET, &n); + if (n > 0) { nm_gstring_prepare(&s); g_string_append(s, "--dhcp-option=option:domain-search"); for (i = 0; i < n; i++) { g_string_append_c(s, ','); - g_string_append(s, nm_ip4_config_get_search(ip4_config, i)); + g_string_append(s, strarr[i]); } nm_strv_ptrarray_take_gstring(cmd, &s); } @@ -237,25 +242,25 @@ out: } gboolean -nm_dnsmasq_manager_start(NMDnsMasqManager *manager, - NMIP4Config * ip4_config, - gboolean announce_android_metered, - GError ** error) +nm_dnsmasq_manager_start(NMDnsMasqManager * manager, + const NML3ConfigData *l3cd, + gboolean announce_android_metered, + GError ** error) { - NMDnsMasqManagerPrivate *priv; gs_unref_ptrarray GPtrArray *dm_cmd = NULL; gs_free char * cmd_str = NULL; + NMDnsMasqManagerPrivate * priv; g_return_val_if_fail(NM_IS_DNSMASQ_MANAGER(manager), FALSE); g_return_val_if_fail(!error || !*error, FALSE); - g_return_val_if_fail(nm_ip4_config_get_num_addresses(ip4_config) > 0, FALSE); + g_return_val_if_fail(NM_IS_L3_CONFIG_DATA(l3cd), FALSE); + g_return_val_if_fail(nm_l3_config_data_get_num_addresses(l3cd, AF_INET) > 0, FALSE); priv = NM_DNSMASQ_MANAGER_GET_PRIVATE(manager); kill_existing_by_pidfile(priv->pidfile); - dm_cmd = - create_dm_cmd_line(priv->iface, ip4_config, priv->pidfile, announce_android_metered, error); + dm_cmd = create_dm_cmd_line(priv->iface, l3cd, priv->pidfile, announce_android_metered, error); if (!dm_cmd) return FALSE; diff --git a/src/core/dnsmasq/nm-dnsmasq-manager.h b/src/core/dnsmasq/nm-dnsmasq-manager.h index 272d1cead1..78ca37251e 100644 --- a/src/core/dnsmasq/nm-dnsmasq-manager.h +++ b/src/core/dnsmasq/nm-dnsmasq-manager.h @@ -6,8 +6,6 @@ #ifndef __NETWORKMANAGER_DNSMASQ_MANAGER_H__ #define __NETWORKMANAGER_DNSMASQ_MANAGER_H__ -#include "nm-ip4-config.h" - #define NM_TYPE_DNSMASQ_MANAGER (nm_dnsmasq_manager_get_type()) #define NM_DNSMASQ_MANAGER(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DNSMASQ_MANAGER, NMDnsMasqManager)) @@ -35,10 +33,10 @@ GType nm_dnsmasq_manager_get_type(void); NMDnsMasqManager *nm_dnsmasq_manager_new(const char *iface); -gboolean nm_dnsmasq_manager_start(NMDnsMasqManager *manager, - NMIP4Config * ip4_config, - gboolean announce_android_metered, - GError ** error); +gboolean nm_dnsmasq_manager_start(NMDnsMasqManager * manager, + const NML3ConfigData *l3cd, + gboolean announce_android_metered, + GError ** error); void nm_dnsmasq_manager_stop(NMDnsMasqManager *manager); diff --git a/src/core/main-utils.h b/src/core/main-utils.h index 2eb731a1a6..9be2433e31 100644 --- a/src/core/main-utils.h +++ b/src/core/main-utils.h @@ -26,9 +26,6 @@ gboolean nm_main_utils_early_setup(const char * progname, gpointer option_context_hook_data, const char *summary); -/* The following functions are not implemented inside nm-main-utils.c, instead - * main.c and nm-iface-helper.c */ - void nm_main_config_reload(int signal); #endif /* __MAIN_UTILS_H__ */ diff --git a/src/core/main.c b/src/core/main.c index 7d448a5976..14d499f29f 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -269,16 +269,6 @@ _dbus_manager_init(NMConfig *config) if (c_a_q_type == NM_CONFIG_CONFIGURE_AND_QUIT_DISABLED) return nm_dbus_manager_acquire_bus(busmgr, TRUE); - if (c_a_q_type == NM_CONFIG_CONFIGURE_AND_QUIT_ENABLED) { - /* D-Bus is useless in configure and quit mode -- we're eventually dropping - * off and potential clients would have no way of knowing whether we're - * finished already or didn't start yet. - * - * But we still create a nm_dbus_manager_get_dbus_connection() D-Bus connection - * so that we can talk to other services like firewalld. */ - return nm_dbus_manager_acquire_bus(busmgr, FALSE); - } - nm_assert(c_a_q_type == NM_CONFIG_CONFIGURE_AND_QUIT_INITRD); /* in initrd we don't have D-Bus at all. Don't even try to get the G_BUS_TYPE_SYSTEM * connection. And of course don't claim the D-Bus name. */ diff --git a/src/core/meson.build b/src/core/meson.build index 46b636817d..5bd10dba0b 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -54,8 +54,6 @@ libNetworkManagerBase = static_library( 'nm-l3-ipv6ll.c', 'nm-l3cfg.c', 'nm-ip-config.c', - 'nm-ip4-config.c', - 'nm-ip6-config.c', ), dependencies: [ core_default_dep, @@ -93,7 +91,6 @@ endif libNetworkManager = static_library( 'NetworkManager', sources: files( - 'devices/nm-acd-manager.c', 'devices/nm-device-6lowpan.c', 'devices/nm-device-bond.c', 'devices/nm-device-bridge.c', @@ -130,9 +127,10 @@ libNetworkManager = static_library( 'dnsmasq/nm-dnsmasq-manager.c', 'dnsmasq/nm-dnsmasq-utils.c', 'ppp/nm-ppp-manager-call.c', - 'settings/plugins/keyfile/nms-keyfile-storage.c', + 'ppp/nm-ppp-mgr.c', 'settings/plugins/keyfile/nms-keyfile-plugin.c', 'settings/plugins/keyfile/nms-keyfile-reader.c', + 'settings/plugins/keyfile/nms-keyfile-storage.c', 'settings/plugins/keyfile/nms-keyfile-utils.c', 'settings/plugins/keyfile/nms-keyfile-writer.c', 'settings/nm-agent-manager.c', @@ -169,7 +167,6 @@ libNetworkManager = static_library( 'nm-manager.c', 'nm-pacrunner-manager.c', 'nm-policy.c', - 'nm-proxy-config.c', 'nm-rfkill-manager.c', 'nm-session-monitor.c', 'nm-sleep-monitor.c', @@ -183,40 +180,6 @@ libNetworkManager = static_library( ], ) -executable( - 'nm-iface-helper', - 'nm-iface-helper.c', - dependencies: [ - core_default_dep, - glib_dep, - libudev_dep, - libndp_dep, - dl_dep, - ], - link_with: [ - libNetworkManagerBase, - libnm_core_aux_intern, - libnm_core_impl, - libnm_crypto, - libnm_systemd_core, - libnm_platform, - libnm_systemd_shared, - libnm_base, - libnm_udev_aux, - libnm_log_core, - libnm_glib_aux, - libnm_std_aux, - libn_acd, - libn_dhcp4, - libc_rbtree, - libc_siphash, - ], - link_args: ldflags_linker_script_binary, - link_depends: linker_script_binary, - install: true, - install_dir: nm_libexecdir, -) - if enable_tests test_c_flags = [] if require_root_tests diff --git a/src/core/ndisc/nm-fake-ndisc.c b/src/core/ndisc/nm-fake-ndisc.c index ffe07ab6b7..2794e286da 100644 --- a/src/core/ndisc/nm-fake-ndisc.c +++ b/src/core/ndisc/nm-fake-ndisc.c @@ -10,6 +10,7 @@ #include #include "nm-ndisc-private.h" +#include "nm-l3cfg.h" #define _NMLOG_PREFIX_NAME "ndisc-fake" @@ -354,28 +355,23 @@ nm_fake_ndisc_init(NMFakeNDisc *fake_ndisc) {} NMNDisc * -nm_fake_ndisc_new(int ifindex, const char *ifname) +nm_fake_ndisc_new(NML3Cfg *l3cfg) { - return g_object_new(NM_TYPE_FAKE_NDISC, - NM_NDISC_IFINDEX, - ifindex, - NM_NDISC_IFNAME, - ifname, - NM_NDISC_NODE_TYPE, - (int) NM_NDISC_NODE_TYPE_HOST, - NM_NDISC_STABLE_TYPE, - (int) NM_UTILS_STABLE_TYPE_UUID, - NM_NDISC_NETWORK_ID, - "fake", - NM_NDISC_MAX_ADDRESSES, - NM_NDISC_MAX_ADDRESSES_DEFAULT, - NM_NDISC_ROUTER_SOLICITATIONS, - NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT, - NM_NDISC_ROUTER_SOLICITATION_INTERVAL, - NM_NDISC_RFC4861_RTR_SOLICITATION_INTERVAL, - NM_NDISC_RA_TIMEOUT, - 30u, - NULL); + const NMNDiscConfig config = { + .l3cfg = g_object_ref(NM_L3CFG(l3cfg)), + .ifname = nm_l3cfg_get_ifname(l3cfg, TRUE), + .node_type = NM_NDISC_NODE_TYPE_HOST, + .stable_type = NM_UTILS_STABLE_TYPE_UUID, + .network_id = "fake", + .max_addresses = NM_NDISC_MAX_ADDRESSES_DEFAULT, + .router_solicitations = NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT, + .router_solicitation_interval = NM_NDISC_RFC4861_RTR_SOLICITATION_INTERVAL, + .ra_timeout = 30u, + .addr_gen_mode = NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, + .ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, + }; + + return g_object_new(NM_TYPE_FAKE_NDISC, NM_NDISC_CONFIG, &config, NULL); } static void diff --git a/src/core/ndisc/nm-fake-ndisc.h b/src/core/ndisc/nm-fake-ndisc.h index 677f15fcac..ba0a7acb78 100644 --- a/src/core/ndisc/nm-fake-ndisc.h +++ b/src/core/ndisc/nm-fake-ndisc.h @@ -24,7 +24,7 @@ typedef struct _NMFakeRNDiscClass NMFakeNDiscClass; GType nm_fake_ndisc_get_type(void); -NMNDisc *nm_fake_ndisc_new(int ifindex, const char *ifname); +NMNDisc *nm_fake_ndisc_new(NML3Cfg *l3cfg); guint nm_fake_ndisc_add_ra(NMFakeNDisc * self, guint seconds, diff --git a/src/core/ndisc/nm-lndp-ndisc.c b/src/core/ndisc/nm-lndp-ndisc.c index 552b0e4b59..ee040be157 100644 --- a/src/core/ndisc/nm-lndp-ndisc.c +++ b/src/core/ndisc/nm-lndp-ndisc.c @@ -9,16 +9,16 @@ #include #include -/* stdarg.h included because of a bug in ndp.h */ #include #include -#include "libnm-glib-aux/nm-str-buf.h" -#include "libnm-systemd-shared/nm-sd-utils-shared.h" -#include "nm-ndisc-private.h" #include "NetworkManagerUtils.h" +#include "libnm-glib-aux/nm-str-buf.h" #include "libnm-platform/nm-platform.h" #include "libnm-platform/nmp-netns.h" +#include "libnm-systemd-shared/nm-sd-utils-shared.h" +#include "nm-l3cfg.h" +#include "nm-ndisc-private.h" #define _NMLOG_PREFIX_NAME "ndisc-lndp" @@ -669,72 +669,39 @@ nm_lndp_ndisc_init(NMLndpNDisc *lndp_ndisc) {} NMNDisc * -nm_lndp_ndisc_new(NMPlatform * platform, - int ifindex, - const char * ifname, - NMUtilsStableType stable_type, - const char * network_id, - NMSettingIP6ConfigAddrGenMode addr_gen_mode, - NMNDiscNodeType node_type, - int max_addresses, - int router_solicitations, - int router_solicitation_interval, - guint32 ra_timeout, - GError ** error) +nm_lndp_ndisc_new(const NMNDiscConfig *config) { nm_auto_pop_netns NMPNetns *netns = NULL; - NMNDisc * ndisc; - NMLndpNDiscPrivate * priv; - int errsv; + gs_unref_object NMNDisc *ndisc = NULL; + NMLndpNDiscPrivate * priv; + int errsv; - g_return_val_if_fail(NM_IS_PLATFORM(platform), NULL); - g_return_val_if_fail(!error || !*error, NULL); - g_return_val_if_fail(network_id, NULL); + g_return_val_if_fail(config, NULL); + g_return_val_if_fail(NM_IS_L3CFG(config->l3cfg), NULL); + g_return_val_if_fail(config->network_id, NULL); - if (!nm_platform_netns_push(platform, &netns)) - return NULL; + if (!nm_platform_netns_push(nm_l3cfg_get_platform(config->l3cfg), &netns)) { + /* The inability to change the name space is also considered + * a fatal error. We have a FD open to the file descriptor, and + * it's unclear how to handle (or recover from) a failure to setns(). */ + g_return_val_if_reached(NULL); + } - ndisc = g_object_new(NM_TYPE_LNDP_NDISC, - NM_NDISC_PLATFORM, - platform, - NM_NDISC_STABLE_TYPE, - (int) stable_type, - NM_NDISC_IFINDEX, - ifindex, - NM_NDISC_IFNAME, - ifname, - NM_NDISC_NETWORK_ID, - network_id, - NM_NDISC_ADDR_GEN_MODE, - (int) addr_gen_mode, - NM_NDISC_NODE_TYPE, - (int) node_type, - NM_NDISC_MAX_ADDRESSES, - max_addresses, - NM_NDISC_ROUTER_SOLICITATIONS, - router_solicitations, - NM_NDISC_ROUTER_SOLICITATION_INTERVAL, - router_solicitation_interval, - NM_NDISC_RA_TIMEOUT, - (guint) ra_timeout, - NULL); + ndisc = g_object_new(NM_TYPE_LNDP_NDISC, NM_NDISC_CONFIG, config, NULL); priv = NM_LNDP_NDISC_GET_PRIVATE(ndisc); errsv = ndp_open(&priv->ndp); if (errsv != 0) { - errsv = nm_errno_native(errsv); - g_set_error(error, - NM_UTILS_ERROR, - NM_UTILS_ERROR_UNKNOWN, - "failure creating libndp socket: %s (%d)", - nm_strerror_native(errsv), - errsv); - g_object_unref(ndisc); - return NULL; + /* This is serious. It might be ENOMEM or the inability to open (or modify) + * a file descriptor. In all cases there is not much reason trying to recover + * from that. File descriptors are a basic resource, that we just require (just + * like memory). */ + g_return_val_if_reached(NULL); } - return ndisc; + + return g_steal_pointer(&ndisc); } static void @@ -754,8 +721,9 @@ nm_lndp_ndisc_class_init(NMLndpNDiscClass *klass) NMNDiscClass *ndisc_class = NM_NDISC_CLASS(klass); object_class->dispose = dispose; - ndisc_class->start = start; - ndisc_class->stop = stop; - ndisc_class->send_rs = send_rs; - ndisc_class->send_ra = send_ra; + + ndisc_class->start = start; + ndisc_class->stop = stop; + ndisc_class->send_rs = send_rs; + ndisc_class->send_ra = send_ra; } diff --git a/src/core/ndisc/nm-lndp-ndisc.h b/src/core/ndisc/nm-lndp-ndisc.h index 151f4bf7ae..711a95e177 100644 --- a/src/core/ndisc/nm-lndp-ndisc.h +++ b/src/core/ndisc/nm-lndp-ndisc.h @@ -23,17 +23,6 @@ typedef struct _NMLndpNDiscClass NMLndpNDiscClass; GType nm_lndp_ndisc_get_type(void); -NMNDisc *nm_lndp_ndisc_new(NMPlatform * platform, - int ifindex, - const char * ifname, - NMUtilsStableType stable_type, - const char * network_id, - NMSettingIP6ConfigAddrGenMode addr_gen_mode, - NMNDiscNodeType node_type, - int max_addresses, - int router_solicitations, - int router_solicitation_interval, - guint32 ra_timeout, - GError ** error); +NMNDisc *nm_lndp_ndisc_new(const NMNDiscConfig *config); #endif /* __NETWORKMANAGER_LNDP_NDISC_H__ */ diff --git a/src/core/ndisc/nm-ndisc.c b/src/core/ndisc/nm-ndisc.c index d7b1a2e154..d870f5f119 100644 --- a/src/core/ndisc/nm-ndisc.c +++ b/src/core/ndisc/nm-ndisc.c @@ -7,16 +7,17 @@ #include "nm-ndisc.h" -#include #include +#include -#include "nm-setting-ip6-config.h" - -#include "nm-ndisc-private.h" -#include "nm-utils.h" +#include "libnm-platform/nm-platform-utils.h" #include "libnm-platform/nm-platform.h" #include "libnm-platform/nmp-netns.h" #include "nm-l3-config-data.h" +#include "nm-l3cfg.h" +#include "nm-ndisc-private.h" +#include "nm-setting-ip6-config.h" +#include "nm-utils.h" #define _NMLOG_PREFIX_NAME "ndisc" @@ -38,6 +39,8 @@ struct _NMNDiscPrivate { /* this *must* be the first field. */ NMNDiscDataInternal rdata; + const NML3ConfigData *l3cd; + char *last_error; GSource *ra_timeout_source; @@ -55,37 +58,25 @@ struct _NMNDiscPrivate { NMUtilsIPv6IfaceId iid; - /* immutable values: */ - int ifindex; - char * ifname; - char * network_id; - guint max_addresses; - NMSettingIP6ConfigAddrGenMode addr_gen_mode; - NMUtilsStableType stable_type; - guint32 ra_timeout; - gint32 router_solicitations; - gint32 router_solicitation_interval; - NMNDiscNodeType node_type; + /* immutable values from here on: */ - NMPlatform *platform; - NMPNetns * netns; + union { + const NMNDiscConfig config; + NMNDiscConfig config_; + }; + + NMPNetns *netns; }; typedef struct _NMNDiscPrivate NMNDiscPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PLATFORM, - PROP_IFINDEX, - PROP_IFNAME, - PROP_STABLE_TYPE, - PROP_NETWORK_ID, - PROP_ADDR_GEN_MODE, - PROP_MAX_ADDRESSES, - PROP_RA_TIMEOUT, - PROP_ROUTER_SOLICITATIONS, - PROP_ROUTER_SOLICITATION_INTERVAL, - PROP_NODE_TYPE, ); +NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CONFIG, ); -enum { CONFIG_RECEIVED, RA_TIMEOUT_SIGNAL, LAST_SIGNAL }; +enum { + CONFIG_RECEIVED, + RA_TIMEOUT_SIGNAL, + LAST_SIGNAL, +}; static guint signals[LAST_SIGNAL] = {0}; @@ -114,15 +105,10 @@ NML3ConfigData * nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, int ifindex, const NMNDiscData * rdata, - NMSettingIP6ConfigPrivacy ip6_privacy, - guint32 route_table, - guint32 route_metric, - gboolean kernel_support_rta_pref, - gboolean kernel_support_extended_ifa_flags) + NMSettingIP6ConfigPrivacy ip6_privacy) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; guint32 ifa_flags; - guint8 plen; guint i; const gint32 now_sec = nm_utils_get_monotonic_timestamp_sec(); @@ -130,20 +116,11 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, nm_l3_config_data_set_ip6_privacy(l3cd, ip6_privacy); - /* Check, whether kernel is recent enough to help user space handling RA. - * If it's not supported, we have no ipv6-privacy and must add autoconf - * addresses as /128. The reason for the /128 is to prevent the kernel - * from adding a prefix route for this address. */ - ifa_flags = 0; - if (kernel_support_extended_ifa_flags) { - ifa_flags |= IFA_F_NOPREFIXROUTE; - if (NM_IN_SET(ip6_privacy, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)) - ifa_flags |= IFA_F_MANAGETEMPADDR; - plen = 64; - } else - plen = 128; + ifa_flags = IFA_F_NOPREFIXROUTE; + if (NM_IN_SET(ip6_privacy, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)) + ifa_flags |= IFA_F_MANAGETEMPADDR; for (i = 0; i < rdata->addresses_n; i++) { const NMNDiscAddress *ndisc_addr = &rdata->addresses[i]; @@ -152,7 +129,7 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, a = (NMPlatformIP6Address){ .ifindex = ifindex, .address = ndisc_addr->address, - .plen = plen, + .plen = 64, .timestamp = now_sec, .lifetime = _nm_ndisc_lifetime_from_expiry(((gint64) now_sec) * 1000, ndisc_addr->expiry_msec, @@ -178,8 +155,10 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, .plen = ndisc_route->plen, .gateway = ndisc_route->gateway, .rt_source = NM_IP_CONFIG_SOURCE_NDISC, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, .rt_pref = ndisc_route->preference, }; nm_assert((NMIcmpv6RouterPref) r.rt_pref == ndisc_route->preference); @@ -188,12 +167,13 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, } if (rdata->gateways_n > 0) { - const NMIcmpv6RouterPref first_pref = rdata->gateways[0].preference; - NMPlatformIP6Route r = { + NMPlatformIP6Route r = { .rt_source = NM_IP_CONFIG_SOURCE_NDISC, .ifindex = ifindex, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, }; for (i = 0; i < rdata->gateways_n; i++) { @@ -201,13 +181,6 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, r.rt_pref = rdata->gateways[i].preference; nm_assert((NMIcmpv6RouterPref) r.rt_pref == rdata->gateways[i].preference); nm_l3_config_data_add_route_6(l3cd, &r); - - if (first_pref != rdata->gateways[i].preference && !kernel_support_rta_pref) { - /* We are unable to configure a router preference. Hence, we skip all gateways - * with a different preference from the first gateway. Note, that the gateways - * are sorted in order of highest to lowest preference. */ - break; - } } } @@ -315,7 +288,7 @@ nm_ndisc_get_ifindex(NMNDisc *self) { g_return_val_if_fail(NM_IS_NDISC(self), 0); - return NM_NDISC_GET_PRIVATE(self)->ifindex; + return nm_l3cfg_get_ifindex(NM_NDISC_GET_PRIVATE(self)->config.l3cfg); } const char * @@ -323,7 +296,7 @@ nm_ndisc_get_ifname(NMNDisc *self) { g_return_val_if_fail(NM_IS_NDISC(self), NULL); - return NM_NDISC_GET_PRIVATE(self)->ifname; + return NM_NDISC_GET_PRIVATE(self)->config.ifname; } NMNDiscNodeType @@ -331,7 +304,7 @@ nm_ndisc_get_node_type(NMNDisc *self) { g_return_val_if_fail(NM_IS_NDISC(self), NM_NDISC_NODE_TYPE_INVALID); - return NM_NDISC_GET_PRIVATE(self)->node_type; + return NM_NDISC_GET_PRIVATE(self)->config.node_type; } /*****************************************************************************/ @@ -391,15 +364,26 @@ _data_complete(NMNDiscDataInternal *data) return &data->public; } -void +static void nm_ndisc_emit_config_change(NMNDisc *self, NMNDiscConfigMap changed) { + NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(self); + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMNDiscData * rdata; + _config_changed_log(self, changed); - g_signal_emit(self, - signals[CONFIG_RECEIVED], - 0, - _data_complete(&NM_NDISC_GET_PRIVATE(self)->rdata), - (guint) changed); + + rdata = _data_complete(&NM_NDISC_GET_PRIVATE(self)->rdata), + + l3cd = nm_l3_config_data_seal(nm_ndisc_data_to_l3cd(nm_l3cfg_get_multi_idx(priv->config.l3cfg), + nm_l3cfg_get_ifindex(priv->config.l3cfg), + rdata, + priv->config.ip6_privacy)); + + if (!nm_l3_config_data_equal(priv->l3cd, l3cd)) + NM_SWAP(&priv->l3cd, &l3cd); + + g_signal_emit(self, signals[CONFIG_RECEIVED], 0, rdata, (guint) changed, priv->l3cd); } /*****************************************************************************/ @@ -479,11 +463,11 @@ complete_address(NMNDisc *ndisc, NMNDiscAddress *addr) g_return_val_if_fail(NM_IS_NDISC(ndisc), FALSE); priv = NM_NDISC_GET_PRIVATE(ndisc); - if (priv->addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) { - if (!nm_utils_ipv6_addr_set_stable_privacy_may_fail(priv->stable_type, + if (priv->config.addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) { + if (!nm_utils_ipv6_addr_set_stable_privacy_may_fail(priv->config.stable_type, &addr->address, - priv->ifname, - priv->network_id, + priv->config.ifname, + priv->config.network_id, addr->dad_counter++, &error)) { _LOGW("complete-address: failed to generate an stable-privacy address: %s", @@ -608,7 +592,7 @@ nm_ndisc_add_address(NMNDisc * ndisc, * what the kernel does, because it considers *all* addresses (including * static and other temporary addresses). **/ - if (rdata->addresses->len >= priv->max_addresses) + if (rdata->addresses->len >= priv->config.max_addresses) return FALSE; if (new_item->expiry_msec <= now_msec) @@ -899,7 +883,7 @@ solicit_timer_start(NMNDisc *ndisc) g_random_int() % ((guint32) (NM_NDISC_RFC4861_MAX_RTR_SOLICITATION_DELAY * 1000 / 4)); _LOGD("solicit: schedule sending first solicitation (of %d) in %.3f seconds", - priv->router_solicitations, + priv->config.router_solicitations, ((double) delay_msec) / 1000); priv->solicit_retransmit_time_msec = 0; @@ -997,30 +981,82 @@ announce_router_solicited(NMNDisc *ndisc) /*****************************************************************************/ void -nm_ndisc_set_config(NMNDisc * ndisc, - const GArray *addresses, - const GArray *dns_servers, - const GArray *dns_domains) +nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd) { - gboolean changed = FALSE; - guint i; + gboolean changed = FALSE; + const struct in6_addr *in6arr; + const char *const * strvarr; + NMDedupMultiIter iter; + const NMPObject * obj; + guint len; + guint i; - for (i = 0; i < addresses->len; i++) { - if (nm_ndisc_add_address(ndisc, &g_array_index(addresses, NMNDiscAddress, i), 0, FALSE)) + nm_assert(NM_IS_NDISC(ndisc)); + nm_assert(nm_ndisc_get_node_type(ndisc) == NM_NDISC_NODE_TYPE_ROUTER); + + nm_l3_config_data_iter_obj_for_each (&iter, l3cd, &obj, NMP_OBJECT_TYPE_IP6_ADDRESS) { + const NMPlatformIP6Address *addr = NMP_OBJECT_CAST_IP6_ADDRESS(obj); + guint32 preferred; + guint32 lifetime; + NMNDiscAddress a; + + if (IN6_IS_ADDR_UNSPECIFIED(&addr->address) || IN6_IS_ADDR_LINKLOCAL(&addr->address)) + continue; + + if (addr->n_ifa_flags & IFA_F_TENTATIVE || addr->n_ifa_flags & IFA_F_DADFAILED) + continue; + + if (addr->plen != 64) + continue; + + lifetime = nmp_utils_lifetime_get(addr->timestamp, + addr->lifetime, + addr->preferred, + NM_NDISC_EXPIRY_BASE_TIMESTAMP / 1000, + &preferred); + if (!lifetime) + continue; + + a = (NMNDiscAddress){ + .address = addr->address, + .expiry_msec = _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, lifetime), + .expiry_preferred_msec = + _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, preferred), + }; + + if (nm_ndisc_add_address(ndisc, &a, 0, FALSE)) changed = TRUE; } - for (i = 0; i < dns_servers->len; i++) { - if (nm_ndisc_add_dns_server(ndisc, - &g_array_index(dns_servers, NMNDiscDNSServer, i), - G_MININT64)) + in6arr = NULL; + len = 0; + if (l3cd) + in6arr = nm_l3_config_data_get_nameservers(l3cd, AF_INET6, &len); + for (i = 0; i < len; i++) { + NMNDiscDNSServer n; + + n = (NMNDiscDNSServer){ + .address = in6arr[i], + .expiry_msec = _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, + NM_NDISC_ROUTER_LIFETIME), + }; + if (nm_ndisc_add_dns_server(ndisc, &n, G_MININT64)) changed = TRUE; } - for (i = 0; i < dns_domains->len; i++) { - if (nm_ndisc_add_dns_domain(ndisc, - &g_array_index(dns_domains, NMNDiscDNSDomain, i), - G_MININT64)) + strvarr = NULL; + len = 0; + if (l3cd) + strvarr = nm_l3_config_data_get_searches(l3cd, AF_INET6, &len); + for (i = 0; i < len; i++) { + NMNDiscDNSDomain n; + + n = (NMNDiscDNSDomain){ + .domain = (char *) strvarr[i], + .expiry_msec = _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, + NM_NDISC_ROUTER_LIFETIME), + }; + if (nm_ndisc_add_dns_domain(ndisc, &n, G_MININT64)) changed = TRUE; } @@ -1061,7 +1097,7 @@ nm_ndisc_set_iid(NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid) if (priv->iid.id != iid.id) { priv->iid = iid; - if (priv->addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) + if (priv->config.addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) return FALSE; if (rdata->addresses->len) { @@ -1100,26 +1136,26 @@ nm_ndisc_start(NMNDisc *ndisc) nm_assert(!priv->ra_timeout_source); _LOGD("starting neighbor discovery for ifindex %d%s", - priv->ifindex, - priv->node_type == NM_NDISC_NODE_TYPE_HOST ? " (solicit)" : " (announce)"); + nm_l3cfg_get_ifindex(priv->config.l3cfg), + priv->config.node_type == NM_NDISC_NODE_TYPE_HOST ? " (solicit)" : " (announce)"); if (!nm_ndisc_netns_push(ndisc, &netns)) return; NM_NDISC_GET_CLASS(ndisc)->start(ndisc); - if (priv->node_type == NM_NDISC_NODE_TYPE_HOST) { + if (priv->config.node_type == NM_NDISC_NODE_TYPE_HOST) { G_STATIC_ASSERT_EXPR(NM_RA_TIMEOUT_DEFAULT == 0); G_STATIC_ASSERT_EXPR(NM_RA_TIMEOUT_INFINITY == G_MAXINT32); - nm_assert(priv->ra_timeout > 0u); - nm_assert(priv->ra_timeout <= NM_RA_TIMEOUT_INFINITY); + nm_assert(priv->config.ra_timeout > 0u); + nm_assert(priv->config.ra_timeout <= NM_RA_TIMEOUT_INFINITY); - if (priv->ra_timeout < NM_RA_TIMEOUT_INFINITY) { + if (priv->config.ra_timeout < NM_RA_TIMEOUT_INFINITY) { guint timeout_msec; - _LOGD("scheduling RA timeout in %u seconds", priv->ra_timeout); - if (priv->ra_timeout < G_MAXUINT / 1000u) - timeout_msec = priv->ra_timeout * 1000u; + _LOGD("scheduling RA timeout in %u seconds", priv->config.ra_timeout); + if (priv->config.ra_timeout < G_MAXUINT / 1000u) + timeout_msec = priv->config.ra_timeout * 1000u; else timeout_msec = G_MAXUINT; priv->ra_timeout_source = nm_g_timeout_add_source(timeout_msec, ra_timeout_cb, ndisc); @@ -1129,8 +1165,8 @@ nm_ndisc_start(NMNDisc *ndisc) return; } - nm_assert(priv->ra_timeout == 0u); - nm_assert(priv->node_type == NM_NDISC_NODE_TYPE_ROUTER); + nm_assert(priv->config.ra_timeout == 0u); + nm_assert(priv->config.node_type == NM_NDISC_NODE_TYPE_ROUTER); announce_router_initial(ndisc); } @@ -1147,7 +1183,7 @@ nm_ndisc_stop(NMNDisc *ndisc) nm_assert(NM_NDISC_GET_CLASS(ndisc)->stop); - _LOGD("stopping neighbor discovery for ifindex %d", priv->ifindex); + _LOGD("stopping neighbor discovery for ifindex %d", nm_l3cfg_get_ifindex(priv->config.l3cfg)); if (!nm_ndisc_netns_push(ndisc, &netns)) return; @@ -1374,7 +1410,7 @@ clean_addresses(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint g_array_set_size(rdata->addresses, j); } - if (_array_set_size_max(rdata->gateways, priv->max_addresses)) + if (_array_set_size_max(rdata->gateways, priv->config.max_addresses)) *changed |= NM_NDISC_CONFIG_ADDRESSES; } @@ -1699,86 +1735,88 @@ nm_ndisc_get_sysctl(NMPlatform *platform, /*****************************************************************************/ +static void +_config_clear(NMNDiscConfig *config) +{ + g_clear_object(&config->l3cfg); + nm_clear_g_free((gpointer *) &config->ifname); + nm_clear_g_free((gpointer *) &config->network_id); +} + +static void +_config_init(NMNDiscConfig *config, const NMNDiscConfig *src) +{ + nm_assert(config); + g_return_if_fail(src); + + /* we only allow to set @config if it was cleared (or is not yet initialized). */ + nm_assert(!config->l3cfg); + nm_assert(!config->ifname); + nm_assert(!config->network_id); + + g_return_if_fail(NM_IS_L3CFG(src->l3cfg)); + + *config = *src; + + g_object_ref(config->l3cfg); + config->ifname = g_strdup(config->ifname); + config->network_id = g_strdup(config->network_id); + + if (config->max_addresses <= 0) + config->max_addresses = _SIZE_MAX_ADDRESSES; + else if (config->max_addresses > 3u * _SIZE_MAX_ADDRESSES) + config->max_addresses = 3u * _SIZE_MAX_ADDRESSES; + + /* This setter is only used in specific circumstances, and in this case, + * we expect that @src only contains valid settings. We thus assert that to + * be the case.*/ + g_return_if_fail(config->ifname && config->ifname[0]); + g_return_if_fail(config->network_id); + g_return_if_fail(config->stable_type >= NM_UTILS_STABLE_TYPE_UUID + && config->stable_type <= NM_UTILS_STABLE_TYPE_RANDOM); + g_return_if_fail(config->addr_gen_mode >= NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64 + && config->addr_gen_mode + <= NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY); + nm_assert(config->max_addresses >= 0 && config->max_addresses <= G_MAXINT32); + G_STATIC_ASSERT_EXPR(G_MAXINT32 == NM_RA_TIMEOUT_INFINITY); + g_return_if_fail(config->ra_timeout <= NM_RA_TIMEOUT_INFINITY); + g_return_if_fail(config->router_solicitations > 0 + && config->router_solicitations <= G_MAXINT32); + g_return_if_fail(config->router_solicitation_interval > 0 + && config->router_solicitation_interval <= G_MAXINT32); + g_return_if_fail( + NM_IN_SET(config->node_type, NM_NDISC_NODE_TYPE_HOST, NM_NDISC_NODE_TYPE_ROUTER)); + g_return_if_fail(NM_IN_SET(config->ip6_privacy, + NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR)); +} + +/*****************************************************************************/ + static void dns_domain_free(gpointer data) { g_free(((NMNDiscDNSDomain *) (data))->domain); } +/*****************************************************************************/ + static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMNDisc * self = NM_NDISC(object); NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(self); - int i; switch (prop_id) { - case PROP_PLATFORM: + case PROP_CONFIG: /* construct-only */ - priv->platform = g_value_get_object(value) ?: NM_PLATFORM_GET; - if (!priv->platform) - g_return_if_reached(); - - g_object_ref(priv->platform); - - priv->netns = nm_platform_netns_get(priv->platform); - if (priv->netns) - g_object_ref(priv->netns); + _config_init(&priv->config_, g_value_get_pointer(value)); + priv->netns = + nm_g_object_ref(nm_platform_netns_get(nm_l3cfg_get_platform(priv->config.l3cfg))); g_return_if_fail(!priv->netns || priv->netns == nmp_netns_get_current()); break; - case PROP_IFINDEX: - /* construct-only */ - priv->ifindex = g_value_get_int(value); - g_return_if_fail(priv->ifindex > 0); - break; - case PROP_IFNAME: - /* construct-only */ - priv->ifname = g_value_dup_string(value); - g_return_if_fail(priv->ifname && priv->ifname[0]); - break; - case PROP_STABLE_TYPE: - /* construct-only */ - priv->stable_type = g_value_get_int(value); - break; - case PROP_NETWORK_ID: - /* construct-only */ - priv->network_id = g_value_dup_string(value); - g_return_if_fail(priv->network_id); - break; - case PROP_ADDR_GEN_MODE: - /* construct-only */ - priv->addr_gen_mode = g_value_get_int(value); - break; - case PROP_MAX_ADDRESSES: - /* construct-only */ - i = g_value_get_int(value); - nm_assert(i >= 0); - priv->max_addresses = i; - - if (priv->max_addresses <= 0) - priv->max_addresses = _SIZE_MAX_ADDRESSES; - else if (priv->max_addresses > 3u * _SIZE_MAX_ADDRESSES) - priv->max_addresses = 3u * _SIZE_MAX_ADDRESSES; - break; - case PROP_RA_TIMEOUT: - /* construct-only */ - priv->ra_timeout = g_value_get_uint(value); - nm_assert(priv->ra_timeout <= NM_RA_TIMEOUT_INFINITY); - break; - case PROP_ROUTER_SOLICITATIONS: - /* construct-only */ - priv->router_solicitations = g_value_get_int(value); - break; - case PROP_ROUTER_SOLICITATION_INTERVAL: - /* construct-only */ - priv->router_solicitation_interval = g_value_get_int(value); - break; - case PROP_NODE_TYPE: - /* construct-only */ - priv->node_type = g_value_get_int(value); - nm_assert(NM_IN_SET(priv->node_type, NM_NDISC_NODE_TYPE_HOST, NM_NDISC_NODE_TYPE_ROUTER)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1828,9 +1866,6 @@ finalize(GObject *object) NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(ndisc); NMNDiscDataInternal *rdata = &priv->rdata; - g_free(priv->ifname); - g_free(priv->network_id); - g_array_unref(rdata->gateways); g_array_unref(rdata->addresses); g_array_unref(rdata->routes); @@ -1838,7 +1873,10 @@ finalize(GObject *object) g_array_unref(rdata->dns_domains); g_clear_object(&priv->netns); - g_clear_object(&priv->platform); + + _config_clear(&priv->config_); + + nm_clear_l3cd(&priv->l3cd); G_OBJECT_CLASS(nm_ndisc_parent_class)->finalize(object); } @@ -1854,89 +1892,12 @@ nm_ndisc_class_init(NMNDiscClass *klass) object_class->dispose = dispose; object_class->finalize = finalize; - obj_properties[PROP_PLATFORM] = - g_param_spec_object(NM_NDISC_PLATFORM, - "", - "", - NM_TYPE_PLATFORM, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IFINDEX] = - g_param_spec_int(NM_NDISC_IFINDEX, - "", - "", - 0, - G_MAXINT, - 0, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IFNAME] = - g_param_spec_string(NM_NDISC_IFNAME, - "", - "", - NULL, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_STABLE_TYPE] = - g_param_spec_int(NM_NDISC_STABLE_TYPE, - "", - "", - NM_UTILS_STABLE_TYPE_UUID, - NM_UTILS_STABLE_TYPE_RANDOM, - NM_UTILS_STABLE_TYPE_UUID, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_NETWORK_ID] = - g_param_spec_string(NM_NDISC_NETWORK_ID, - "", - "", - NULL, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ADDR_GEN_MODE] = - g_param_spec_int(NM_NDISC_ADDR_GEN_MODE, - "", - "", - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY, - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_MAX_ADDRESSES] = - g_param_spec_int(NM_NDISC_MAX_ADDRESSES, - "", - "", - 0, - G_MAXINT32, - NM_NDISC_MAX_ADDRESSES_DEFAULT, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - G_STATIC_ASSERT_EXPR(G_MAXINT32 == NM_RA_TIMEOUT_INFINITY); - obj_properties[PROP_RA_TIMEOUT] = - g_param_spec_uint(NM_NDISC_RA_TIMEOUT, - "", - "", - 0, - G_MAXINT32, - 0, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ROUTER_SOLICITATIONS] = - g_param_spec_int(NM_NDISC_ROUTER_SOLICITATIONS, - "", - "", - 1, - G_MAXINT32, - NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ROUTER_SOLICITATION_INTERVAL] = - g_param_spec_int(NM_NDISC_ROUTER_SOLICITATION_INTERVAL, - "", - "", - 1, - G_MAXINT32, - NM_NDISC_RFC4861_RTR_SOLICITATION_INTERVAL, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_NODE_TYPE] = - g_param_spec_int(NM_NDISC_NODE_TYPE, - "", - "", - NM_NDISC_NODE_TYPE_INVALID, - NM_NDISC_NODE_TYPE_ROUTER, - NM_NDISC_NODE_TYPE_INVALID, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_CONFIG] = + g_param_spec_pointer(NM_NDISC_CONFIG, + "", + "", + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[CONFIG_RECEIVED] = g_signal_new(NM_NDISC_CONFIG_RECEIVED, @@ -1947,9 +1908,14 @@ nm_ndisc_class_init(NMNDiscClass *klass) NULL, NULL, G_TYPE_NONE, - 2, - G_TYPE_POINTER, - G_TYPE_UINT); + 3, + G_TYPE_POINTER + /* (const NMNDiscData *)rdata */, + G_TYPE_UINT + /* (guint) changed_i */, + G_TYPE_POINTER + /* (const NML3ConfigData *) l3cd */ + ); signals[RA_TIMEOUT_SIGNAL] = g_signal_new(NM_NDISC_RA_TIMEOUT_SIGNAL, G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, diff --git a/src/core/ndisc/nm-ndisc.h b/src/core/ndisc/nm-ndisc.h index 5b82752815..90f574a90b 100644 --- a/src/core/ndisc/nm-ndisc.h +++ b/src/core/ndisc/nm-ndisc.h @@ -26,17 +26,7 @@ #define NM_IS_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_NDISC)) #define NM_NDISC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_NDISC, NMNDiscClass)) -#define NM_NDISC_PLATFORM "platform" -#define NM_NDISC_IFINDEX "ifindex" -#define NM_NDISC_IFNAME "ifname" -#define NM_NDISC_NETWORK_ID "network-id" -#define NM_NDISC_ADDR_GEN_MODE "addr-gen-mode" -#define NM_NDISC_STABLE_TYPE "stable-type" -#define NM_NDISC_NODE_TYPE "node-type" -#define NM_NDISC_MAX_ADDRESSES "max-addresses" -#define NM_NDISC_RA_TIMEOUT "ra-timeout" -#define NM_NDISC_ROUTER_SOLICITATIONS "router-solicitations" -#define NM_NDISC_ROUTER_SOLICITATION_INTERVAL "router-solicitation-interval" +#define NM_NDISC_CONFIG "config" #define NM_NDISC_CONFIG_RECEIVED "config-received" #define NM_NDISC_RA_TIMEOUT_SIGNAL "ra-timeout-signal" @@ -169,6 +159,20 @@ typedef enum { #define NM_NDISC_ROUTER_ADVERT_MAX_INTERVAL 600 /* RFC4861, MaxRtrAdvInterval default */ #define NM_NDISC_ROUTER_LIFETIME 900 /* 1.5 * NM_NDISC_ROUTER_ADVERT_MAX_INTERVAL */ +typedef struct { + NML3Cfg * l3cfg; + const char * ifname; + const char * network_id; + int max_addresses; + int router_solicitations; + int router_solicitation_interval; + guint32 ra_timeout; + NMUtilsStableType stable_type; + NMSettingIP6ConfigAddrGenMode addr_gen_mode; + NMNDiscNodeType node_type; + NMSettingIP6ConfigPrivacy ip6_privacy; +} NMNDiscConfig; + struct _NMNDiscPrivate; struct _NMNDiscDataInternal; @@ -217,8 +221,6 @@ typedef struct { GType nm_ndisc_get_type(void); -void nm_ndisc_emit_config_change(NMNDisc *self, NMNDiscConfigMap changed); - int nm_ndisc_get_ifindex(NMNDisc *self); const char * nm_ndisc_get_ifname(NMNDisc *self); NMNDiscNodeType nm_ndisc_get_node_type(NMNDisc *self); @@ -228,10 +230,7 @@ void nm_ndisc_start(NMNDisc *ndisc); void nm_ndisc_stop(NMNDisc *ndisc); NMNDiscConfigMap nm_ndisc_dad_failed(NMNDisc *ndisc, const struct in6_addr *address, gboolean emit_changed_signal); -void nm_ndisc_set_config(NMNDisc * ndisc, - const GArray *addresses, - const GArray *dns_servers, - const GArray *dns_domains); +void nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd); NMPlatform *nm_ndisc_get_platform(NMNDisc *self); NMPNetns * nm_ndisc_netns_get(NMNDisc *self); @@ -280,10 +279,6 @@ struct _NML3ConfigData; struct _NML3ConfigData *nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, int ifindex, const NMNDiscData * rdata, - NMSettingIP6ConfigPrivacy ip6_privacy, - guint32 route_table, - guint32 route_metric, - gboolean kernel_support_rta_pref, - gboolean kernel_support_extended_ifa_flags); + NMSettingIP6ConfigPrivacy ip6_privacy); #endif /* __NETWORKMANAGER_NDISC_H__ */ diff --git a/src/core/ndisc/tests/test-ndisc-fake.c b/src/core/ndisc/tests/test-ndisc-fake.c index f201bc5641..8cfb9ddc16 100644 --- a/src/core/ndisc/tests/test-ndisc-fake.c +++ b/src/core/ndisc/tests/test-ndisc-fake.c @@ -11,23 +11,28 @@ #include "ndisc/nm-fake-ndisc.h" #include "platform/nm-fake-platform.h" +#include "nm-netns.h" -#include "nm-test-utils-core.h" +#include "platform/tests/test-common.h" /*****************************************************************************/ static NMFakeNDisc * ndisc_new(void) { - NMNDisc * ndisc; - const int ifindex = 1; - const char * ifname = nm_platform_link_get_name(NM_PLATFORM_GET, ifindex); - NMUtilsIPv6IfaceId iid = {}; + gs_unref_object NML3Cfg *l3cfg = NULL; + NMNDisc * ndisc; + const int ifindex = 1; + NMUtilsIPv6IfaceId iid; - ndisc = nm_fake_ndisc_new(ifindex, ifname); + l3cfg = nm_netns_l3cfg_acquire(NM_NETNS_GET, ifindex); + + ndisc = nm_fake_ndisc_new(l3cfg); + g_assert(ndisc); + + memset(&iid, 0, sizeof(iid)); iid.id_u8[7] = 1; nm_ndisc_set_iid(ndisc, iid); - g_assert(ndisc); return NM_FAKE_NDISC(ndisc); } @@ -140,9 +145,15 @@ typedef struct { /*****************************************************************************/ static void -test_simple_changed(NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, TestData *data) +test_simple_changed(NMNDisc * ndisc, + const NMNDiscData * rdata, + guint changed_i, + const NML3ConfigData *l3cd, + TestData * data) { - NMNDiscConfigMap changed = changed_int; + NMNDiscConfigMap changed = changed_i; + + _LOGT("test_simple: callback (counter=%u)", data->counter); switch (data->counter++) { case 0: @@ -206,9 +217,11 @@ test_simple(void) g_signal_connect(ndisc, NM_NDISC_CONFIG_RECEIVED, G_CALLBACK(test_simple_changed), &data); + _LOGT("test_simple: start"); nm_ndisc_start(NM_NDISC(ndisc)); nmtst_main_loop_run_assert(data.loop, 15000); g_assert_cmpint(data.counter, ==, 2); + _LOGT("test_simple: done"); } /*****************************************************************************/ @@ -221,9 +234,13 @@ test_everything_rs_sent(NMNDisc *ndisc, TestData *data) } static void -test_everything_changed(NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, TestData *data) +test_everything_changed(NMNDisc * ndisc, + const NMNDiscData * rdata, + guint changed_i, + const NML3ConfigData *l3cd, + TestData * data) { - NMNDiscConfigMap changed = changed_int; + NMNDiscConfigMap changed = changed_i; if (data->counter == 0) { g_assert_cmpint(data->rs_counter, ==, 1); @@ -342,12 +359,13 @@ test_everything(void) } static void -test_preference_order_cb(NMNDisc * ndisc, - const NMNDiscData *rdata, - guint changed_int, - TestData * data) +test_preference_order_cb(NMNDisc * ndisc, + const NMNDiscData * rdata, + guint changed_i, + const NML3ConfigData *l3cd, + TestData * data) { - NMNDiscConfigMap changed = changed_int; + NMNDiscConfigMap changed = changed_i; if (data->counter == 1) { g_assert_cmpint(changed, @@ -434,12 +452,13 @@ test_preference_order(void) } static void -test_preference_changed_cb(NMNDisc * ndisc, - const NMNDiscData *rdata, - guint changed_int, - TestData * data) +test_preference_changed_cb(NMNDisc * ndisc, + const NMNDiscData * rdata, + guint changed_i, + const NML3ConfigData *l3cd, + TestData * data) { - NMNDiscConfigMap changed = changed_int; + NMNDiscConfigMap changed = changed_i; if (data->counter == 1) { g_assert_cmpint(changed, @@ -576,10 +595,11 @@ test_preference_changed(void) /*****************************************************************************/ static void -_test_dns_solicit_loop_changed(NMNDisc * ndisc, - const NMNDiscData *rdata, - guint changed_int, - TestData * data) +_test_dns_solicit_loop_changed(NMNDisc * ndisc, + const NMNDiscData * rdata, + guint changed_i, + const NML3ConfigData *l3cd, + TestData * data) { data->counter++; } diff --git a/src/core/ndisc/tests/test-ndisc-linux.c b/src/core/ndisc/tests/test-ndisc-linux.c index 57021606d3..a4db5efaa5 100644 --- a/src/core/ndisc/tests/test-ndisc-linux.c +++ b/src/core/ndisc/tests/test-ndisc-linux.c @@ -11,6 +11,8 @@ #include "ndisc/nm-lndp-ndisc.h" #include "libnm-platform/nm-linux-platform.h" +#include "nm-netns.h" +#include "nm-l3cfg.h" #include "nm-test-utils-core.h" @@ -19,16 +21,18 @@ NMTST_DEFINE(); int main(int argc, char **argv) { - GMainLoop * loop; - NMNDisc * ndisc; - int ifindex = 1; - const char * ifname; - NMUtilsIPv6IfaceId iid = {}; - GError * error = NULL; - int max_addresses; - int router_solicitations; - int router_solicitation_interval; - guint32 ra_timeout; + gs_unref_object NML3Cfg *l3cfg = NULL; + NMNDiscConfig config; + GMainLoop * loop; + NMNDisc * ndisc; + int ifindex = 1; + const char * ifname; + NMUtilsIPv6IfaceId iid = {}; + GError * error = NULL; + int max_addresses; + int router_solicitations; + int router_solicitation_interval; + guint32 ra_timeout; nmtst_init_with_logging(&argc, &argv, NULL, "DEFAULT"); @@ -56,18 +60,23 @@ main(int argc, char **argv) &router_solicitation_interval, &ra_timeout); - ndisc = nm_lndp_ndisc_new(NM_PLATFORM_GET, - ifindex, - ifname, - NM_UTILS_STABLE_TYPE_UUID, - "8ce666e8-d34d-4fb1-b858-f15a7al28086", - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, - NM_NDISC_NODE_TYPE_HOST, - max_addresses, - router_solicitations, - router_solicitation_interval, - ra_timeout, - &error); + l3cfg = nm_netns_l3cfg_acquire(NM_NETNS_GET, ifindex); + + config = (NMNDiscConfig){ + .l3cfg = l3cfg, + .ifname = nm_l3cfg_get_ifname(l3cfg, TRUE), + .stable_type = NM_UTILS_STABLE_TYPE_UUID, + .network_id = "8ce666e8-d34d-4fb1-b858-f15a7al28086", + .addr_gen_mode = NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, + .node_type = NM_NDISC_NODE_TYPE_HOST, + .max_addresses = max_addresses, + .router_solicitations = router_solicitations, + .router_solicitation_interval = router_solicitation_interval, + .ra_timeout = ra_timeout, + .ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, + }; + + ndisc = nm_lndp_ndisc_new(&config); if (!ndisc) { g_print("Failed to create NMNDisc instance: %s\n", error->message); g_error_free(error); diff --git a/src/core/nm-act-request.c b/src/core/nm-act-request.c index d0a2e0c783..58dd4a87f8 100644 --- a/src/core/nm-act-request.c +++ b/src/core/nm-act-request.c @@ -24,8 +24,7 @@ #include "settings/nm-settings-connection.h" typedef struct { - CList call_ids_lst_head; - NMFirewallConfig *firewall_config; + CList call_ids_lst_head; } NMActRequestPrivate; struct _NMActRequest { @@ -250,36 +249,6 @@ nm_act_request_clear_secrets(NMActRequest *self) /*****************************************************************************/ -NMFirewallConfig * -nm_act_request_get_shared(NMActRequest *req) -{ - g_return_val_if_fail(NM_IS_ACT_REQUEST(req), FALSE); - - return NM_ACT_REQUEST_GET_PRIVATE(req)->firewall_config; -} - -void -nm_act_request_set_shared(NMActRequest *req, NMFirewallConfig *rules) -{ - NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE(req); - - g_return_if_fail(NM_IS_ACT_REQUEST(req)); - - if (priv->firewall_config == rules) - return; - - if (priv->firewall_config) { - nm_firewall_config_apply(priv->firewall_config, FALSE); - priv->firewall_config = NULL; - } - if (rules) { - priv->firewall_config = rules; - nm_firewall_config_apply(priv->firewall_config, TRUE); - } -} - -/*****************************************************************************/ - static void device_notify(GObject *object, GParamSpec *pspec, gpointer self) { @@ -508,11 +477,6 @@ dispose(GObject *object) c_list_for_each_entry_safe (call_id, call_id_safe, &priv->call_ids_lst_head, call_ids_lst) _do_cancel_secrets(self, call_id, TRUE); - if (priv->firewall_config) { - nm_firewall_config_apply(priv->firewall_config, FALSE); - nm_clear_pointer(&priv->firewall_config, nm_firewall_config_free); - } - G_OBJECT_CLASS(nm_act_request_parent_class)->dispose(object); } diff --git a/src/core/nm-act-request.h b/src/core/nm-act-request.h index 9c702d31eb..698a9985a4 100644 --- a/src/core/nm-act-request.h +++ b/src/core/nm-act-request.h @@ -38,14 +38,6 @@ NMConnection *nm_act_request_get_applied_connection(NMActRequest *req); /*****************************************************************************/ -struct _NMFirewallConfig; - -struct _NMFirewallConfig *nm_act_request_get_shared(NMActRequest *req); - -void nm_act_request_set_shared(NMActRequest *req, struct _NMFirewallConfig *rules); - -/*****************************************************************************/ - /* Secrets handling */ typedef void (*NMActRequestSecretsFunc)(NMActRequest * req, diff --git a/src/core/nm-active-connection.h b/src/core/nm-active-connection.h index 15c68e6e7e..1c2c8116ba 100644 --- a/src/core/nm-active-connection.h +++ b/src/core/nm-active-connection.h @@ -138,6 +138,9 @@ void nm_active_connection_set_state_fail(NMActiveConnection * active, NMActiveConnectionStateReason reason, const char * error_desc); +#define NM_ACTIVATION_STATE_FLAG_IP_READY_X(IS_IPv4) \ + ((IS_IPv4) ? NM_ACTIVATION_STATE_FLAG_IP4_READY : NM_ACTIVATION_STATE_FLAG_IP6_READY) + NMActivationStateFlags nm_active_connection_get_state_flags(NMActiveConnection *self); void nm_active_connection_set_state_flags_full(NMActiveConnection * self, diff --git a/src/core/nm-config-data.c b/src/core/nm-config-data.c index 1cb8a43c32..0c4f8099de 100644 --- a/src/core/nm-config-data.c +++ b/src/core/nm-config-data.c @@ -929,59 +929,57 @@ nm_global_dns_config_is_empty(const NMGlobalDnsConfig *dns_config) return !dns_config->searches && !dns_config->options && !dns_config->domain_list; } -void -nm_global_dns_config_update_checksum(const NMGlobalDnsConfig *dns_config, GChecksum *sum) +int +nm_global_dns_config_cmp(const NMGlobalDnsConfig *a, + const NMGlobalDnsConfig *b, + gboolean check_internal) { - NMGlobalDnsDomain *domain; - guint i, j; - guint8 v8; + guint i; - g_return_if_fail(dns_config); - g_return_if_fail(sum); + NM_CMP_SELF(a, b); - v8 = NM_HASH_COMBINE_BOOLS(guint8, - !dns_config->searches, - !dns_config->options, - !dns_config->domain_list); - g_checksum_update(sum, (guchar *) &v8, 1); + NM_CMP_RETURN( + nm_strv_cmp_n(a->searches ?: NM_STRV_EMPTY(), -1, b->searches ?: NM_STRV_EMPTY(), -1)); - if (dns_config->searches) { - for (i = 0; dns_config->searches[i]; i++) - g_checksum_update(sum, - (guchar *) dns_config->searches[i], - strlen(dns_config->searches[i]) + 1); - } - if (dns_config->options) { - for (i = 0; dns_config->options[i]; i++) - g_checksum_update(sum, - (guchar *) dns_config->options[i], - strlen(dns_config->options[i]) + 1); - } + NM_CMP_RETURN( + nm_strv_cmp_n(a->options ?: NM_STRV_EMPTY(), -1, b->options ?: NM_STRV_EMPTY(), -1)); - if (dns_config->domain_list) { - for (i = 0; dns_config->domain_list[i]; i++) { - domain = g_hash_table_lookup(dns_config->domains, dns_config->domain_list[i]); - nm_assert(domain); + NM_CMP_RETURN(nm_strv_cmp_n(a->domain_list ?: NM_STRV_EMPTY_CC(), + -1, + b->domain_list ?: NM_STRV_EMPTY_CC(), + -1)); - v8 = NM_HASH_COMBINE_BOOLS(guint8, !domain->servers, !domain->options); - g_checksum_update(sum, (guchar *) &v8, 1); + if (a->domain_list) { + for (i = 0; a->domain_list[i]; i++) { + const NMGlobalDnsDomain *domain_a; + const NMGlobalDnsDomain *domain_b; - g_checksum_update(sum, (guchar *) domain->name, strlen(domain->name) + 1); + nm_assert(nm_streq(a->domain_list[i], b->domain_list[i])); - if (domain->servers) { - for (j = 0; domain->servers[j]; j++) - g_checksum_update(sum, - (guchar *) domain->servers[j], - strlen(domain->servers[j]) + 1); - } - if (domain->options) { - for (j = 0; domain->options[j]; j++) - g_checksum_update(sum, - (guchar *) domain->options[j], - strlen(domain->options[j]) + 1); - } + domain_a = g_hash_table_lookup(a->domains, a->domain_list[i]); + nm_assert(domain_a); + + domain_b = g_hash_table_lookup(b->domains, b->domain_list[i]); + nm_assert(domain_b); + + NM_CMP_FIELD_STR0(domain_a, domain_b, name); + + NM_CMP_RETURN(nm_strv_cmp_n(domain_a->servers ?: NM_STRV_EMPTY(), + -1, + domain_b->servers ?: NM_STRV_EMPTY(), + -1)); + + NM_CMP_RETURN(nm_strv_cmp_n(domain_a->options ?: NM_STRV_EMPTY(), + -1, + domain_b->options ?: NM_STRV_EMPTY(), + -1)); } } + + if (check_internal) + NM_CMP_FIELD(a, b, internal); + + return 0; } static void diff --git a/src/core/nm-config-data.h b/src/core/nm-config-data.h index 92a7cb5c6f..89c69e2877 100644 --- a/src/core/nm-config-data.h +++ b/src/core/nm-config-data.h @@ -264,8 +264,10 @@ const char *const *nm_global_dns_domain_get_servers(const NMGlobalDnsDomain *dom const char *const *nm_global_dns_domain_get_options(const NMGlobalDnsDomain *domain); gboolean nm_global_dns_config_is_internal(const NMGlobalDnsConfig *dns_config); gboolean nm_global_dns_config_is_empty(const NMGlobalDnsConfig *dns_config); -void nm_global_dns_config_update_checksum(const NMGlobalDnsConfig *dns_config, GChecksum *sum); -void nm_global_dns_config_free(NMGlobalDnsConfig *dns_config); +int nm_global_dns_config_cmp(const NMGlobalDnsConfig *a, + const NMGlobalDnsConfig *b, + gboolean check_internal); +void nm_global_dns_config_free(NMGlobalDnsConfig *dns_config); NMGlobalDnsConfig *nm_global_dns_config_from_dbus(const GValue *value, GError **error); void nm_global_dns_config_to_dbus(const NMGlobalDnsConfig *dns_config, GValue *value); diff --git a/src/core/nm-config.c b/src/core/nm-config.c index c41f582329..f431365c59 100644 --- a/src/core/nm-config.c +++ b/src/core/nm-config.c @@ -529,7 +529,7 @@ nm_config_cmd_line_options_free(NMConfigCmdLineOptions *cli) static NMConfigConfigureAndQuitType string_to_configure_and_quit(const char *value, GError **error) { - NMConfigConfigureAndQuitType ret; + int v_bool; if (value == NULL) return NM_CONFIG_CONFIGURE_AND_QUIT_DISABLED; @@ -537,11 +537,18 @@ string_to_configure_and_quit(const char *value, GError **error) if (nm_streq(value, "initrd")) return NM_CONFIG_CONFIGURE_AND_QUIT_INITRD; - ret = nm_config_parse_boolean(value, NM_CONFIG_CONFIGURE_AND_QUIT_INVALID); - if (ret == NM_CONFIG_CONFIGURE_AND_QUIT_INVALID) - g_set_error(error, 1, 0, N_("'%s' is not valid"), value); + v_bool = nm_config_parse_boolean(value, -1); + if (v_bool == -1) { + nm_utils_error_set(error, NM_UTILS_ERROR_UNKNOWN, N_("'%s' is not valid"), value); + return NM_CONFIG_CONFIGURE_AND_QUIT_INVALID; + } - return ret; + if (v_bool) { + _LOGW("'[main].configure-and-quit=1' in \"NetworkManager.conf\" is no longer implemented " + "and has no effect"); + } + + return NM_CONFIG_CONFIGURE_AND_QUIT_DISABLED; } static gboolean @@ -552,11 +559,7 @@ parse_configure_and_quit(const char *option_name, { NMConfigCmdLineOptions *cli = user_data; - if (value == NULL) - cli->configure_and_quit = NM_CONFIG_CONFIGURE_AND_QUIT_ENABLED; - else - cli->configure_and_quit = string_to_configure_and_quit(value, error); - + cli->configure_and_quit = string_to_configure_and_quit(value, error); if (cli->configure_and_quit == NM_CONFIG_CONFIGURE_AND_QUIT_INVALID) { g_prefix_error(error, N_("Bad '%s' option: "), option_name); return FALSE; @@ -1383,16 +1386,13 @@ read_entire_config(const NMConfigCmdLineOptions *cli, switch (cli->configure_and_quit) { case NM_CONFIG_CONFIGURE_AND_QUIT_INVALID: - g_assert_not_reached(); + nm_assert_not_reached(); break; case NM_CONFIG_CONFIGURE_AND_QUIT_DISABLED: - /* do nothing */ - break; - case NM_CONFIG_CONFIGURE_AND_QUIT_ENABLED: - g_key_file_set_boolean(keyfile, - NM_CONFIG_KEYFILE_GROUP_MAIN, - "configure-and-quit", - TRUE); + g_key_file_set_string(keyfile, + NM_CONFIG_KEYFILE_GROUP_MAIN, + "configure-and-quit", + "no"); break; case NM_CONFIG_CONFIGURE_AND_QUIT_INITRD: g_key_file_set_string(keyfile, diff --git a/src/core/nm-config.h b/src/core/nm-config.h index 8279f4d264..04e159bf5e 100644 --- a/src/core/nm-config.h +++ b/src/core/nm-config.h @@ -42,8 +42,7 @@ typedef enum { typedef enum { NM_CONFIG_CONFIGURE_AND_QUIT_INVALID = -1, NM_CONFIG_CONFIGURE_AND_QUIT_DISABLED = FALSE, - NM_CONFIG_CONFIGURE_AND_QUIT_ENABLED = TRUE, - NM_CONFIG_CONFIGURE_AND_QUIT_INITRD, + NM_CONFIG_CONFIGURE_AND_QUIT_INITRD = 2, } NMConfigConfigureAndQuitType; typedef struct { diff --git a/src/core/nm-connectivity.c b/src/core/nm-connectivity.c index 13fb026514..230c4afe53 100644 --- a/src/core/nm-connectivity.c +++ b/src/core/nm-connectivity.c @@ -15,6 +15,7 @@ #include #include "c-list/src/c-list.h" +#include "libnm-platform/nmp-object.h" #include "libnm-core-intern/nm-core-internal.h" #include "nm-config.h" #include "NetworkManagerUtils.h" diff --git a/src/core/nm-dhcp-config.c b/src/core/nm-dhcp-config.c index 8a02911942..8a89173c0f 100644 --- a/src/core/nm-dhcp-config.c +++ b/src/core/nm-dhcp-config.c @@ -8,9 +8,11 @@ #include "nm-dhcp-config.h" #include "nm-dbus-interface.h" +#include "NetworkManagerUtils.h" #include "nm-utils.h" #include "nm-dbus-object.h" #include "nm-core-utils.h" +#include "nm-l3-config-data.h" /*****************************************************************************/ @@ -46,10 +48,11 @@ static GType nm_dhcp6_config_get_type(void); /*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE(NMDhcpConfig, PROP_OPTIONS, ); +NM_GOBJECT_PROPERTIES_DEFINE(NMDhcpConfig, PROP_L3CD, PROP_OPTIONS, ); typedef struct { - GVariant *options; + const NML3ConfigData *l3cd; + GVariant * options; } NMDhcpConfigPrivate; struct _NMDhcpConfig { @@ -76,18 +79,49 @@ nm_dhcp_config_get_addr_family(NMDhcpConfig *self) /*****************************************************************************/ -void -nm_dhcp_config_set_options(NMDhcpConfig *self, GHashTable *options) +static GVariant * +_l3cd_to_options(const NML3ConfigData *l3cd, int addr_family) { - NMDhcpConfigPrivate *priv; + GVariant *options; + + options = NULL; + if (l3cd) { + NMDhcpLease *lease; + + lease = nm_l3_config_data_get_dhcp_lease(l3cd, addr_family); + if (lease) + options = nm_strdict_to_variant_asv(nm_dhcp_lease_get_options(lease)); + } + if (!options) + options = nm_g_variant_singleton_aLsvI(); + return g_variant_ref_sink(options); +} + +void +nm_dhcp_config_set_lease(NMDhcpConfig *self, const NML3ConfigData *l3cd) +{ + nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; + gs_unref_variant GVariant *options2 = NULL; + NMDhcpConfigPrivate * priv; g_return_if_fail(NM_IS_DHCP_CONFIG(self)); - g_return_if_fail(options); priv = NM_DHCP_CONFIG_GET_PRIVATE(self); - nm_g_variant_unref(priv->options); - priv->options = g_variant_ref_sink(nm_strdict_to_variant_asv(options)); + if (priv->l3cd == l3cd) + return; + + l3cd_old = g_steal_pointer(&priv->l3cd); + if (l3cd) + priv->l3cd = nm_l3_config_data_ref_and_seal(l3cd); + + options2 = _l3cd_to_options(priv->l3cd, nm_dhcp_config_get_addr_family(self)); + + if (g_variant_equal(priv->options, options2)) + return; + + NM_SWAP(&priv->options, &options2); + _notify(self, PROP_OPTIONS); } @@ -95,19 +129,22 @@ const char * nm_dhcp_config_get_option(NMDhcpConfig *self, const char *key) { NMDhcpConfigPrivate *priv; - const char * value; + NMDhcpLease * lease; g_return_val_if_fail(NM_IS_DHCP_CONFIG(self), NULL); g_return_val_if_fail(key, NULL); priv = NM_DHCP_CONFIG_GET_PRIVATE(self); - if (priv->options && g_variant_lookup(priv->options, key, "&s", &value)) - return value; - else + if (!priv->l3cd) return NULL; + + lease = nm_l3_config_data_get_dhcp_lease(priv->l3cd, nm_dhcp_config_get_addr_family(self)); + return nm_dhcp_lease_lookup_option(lease, key); } +/*****************************************************************************/ + GVariant * nm_dhcp_config_get_options(NMDhcpConfig *self) { @@ -125,7 +162,25 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_OPTIONS: - g_value_set_variant(value, priv->options ?: nm_g_variant_singleton_aLsvI()); + g_value_set_variant(value, priv->options); + 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) +{ + NMDhcpConfig * self = NM_DHCP_CONFIG(object); + NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE(self); + + switch (prop_id) { + case PROP_L3CD: + /* construct-only */ + priv->l3cd = nm_l3_config_data_ref_and_seal(g_value_get_pointer(value)); + priv->options = _l3cd_to_options(priv->l3cd, nm_dhcp_config_get_addr_family(self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -140,11 +195,12 @@ nm_dhcp_config_init(NMDhcpConfig *self) {} NMDhcpConfig * -nm_dhcp_config_new(int addr_family) +nm_dhcp_config_new(int addr_family, const NML3ConfigData *l3cd) { - nm_assert_addr_family(addr_family); - - return g_object_new(addr_family != AF_INET ? NM_TYPE_DHCP6_CONFIG : NM_TYPE_DHCP4_CONFIG, NULL); + return g_object_new(NM_IS_IPv4(addr_family) ? NM_TYPE_DHCP4_CONFIG : NM_TYPE_DHCP6_CONFIG, + NM_DHCP_CONFIG_L3CD, + l3cd, + NULL); } static void @@ -152,7 +208,9 @@ finalize(GObject *object) { NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE(object); - nm_g_variant_unref(priv->options); + g_variant_unref(priv->options); + + nm_l3_config_data_unref(priv->l3cd); G_OBJECT_CLASS(nm_dhcp_config_parent_class)->finalize(object); } @@ -163,8 +221,15 @@ nm_dhcp_config_class_init(NMDhcpConfigClass *config_class) GObjectClass *object_class = G_OBJECT_CLASS(config_class); object_class->get_property = get_property; + object_class->set_property = set_property; object_class->finalize = finalize; + obj_properties[PROP_L3CD] = + g_param_spec_pointer(NM_DHCP_CONFIG_L3CD, + "", + "", + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_OPTIONS] = g_param_spec_variant(NM_DHCP_CONFIG_OPTIONS, "", "", diff --git a/src/core/nm-dhcp-config.h b/src/core/nm-dhcp-config.h index 9e68f2fb3a..cae0e11aa2 100644 --- a/src/core/nm-dhcp-config.h +++ b/src/core/nm-dhcp-config.h @@ -18,16 +18,17 @@ (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_CONFIG, NMDhcpConfigClass)) #define NM_DHCP_CONFIG_OPTIONS "options" +#define NM_DHCP_CONFIG_L3CD "l3cd" typedef struct _NMDhcpConfigClass NMDhcpConfigClass; GType nm_dhcp_config_get_type(void); -NMDhcpConfig *nm_dhcp_config_new(int addr_family); +NMDhcpConfig *nm_dhcp_config_new(int addr_family, const NML3ConfigData *l3cd); int nm_dhcp_config_get_addr_family(NMDhcpConfig *self); -void nm_dhcp_config_set_options(NMDhcpConfig *self, GHashTable *options); +void nm_dhcp_config_set_lease(NMDhcpConfig *self, const NML3ConfigData *l3cd); const char *nm_dhcp_config_get_option(NMDhcpConfig *self, const char *option); diff --git a/src/core/nm-dispatcher.c b/src/core/nm-dispatcher.c index b77197863b..d68dab5b22 100644 --- a/src/core/nm-dispatcher.c +++ b/src/core/nm-dispatcher.c @@ -15,9 +15,7 @@ #include "nm-act-request.h" #include "devices/nm-device.h" #include "nm-dhcp-config.h" -#include "nm-proxy-config.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" +#include "nm-l3-config-data.h" #include "nm-manager.h" #include "settings/nm-settings-connection.h" #include "libnm-platform/nm-platform.h" @@ -148,50 +146,47 @@ _init_dispatcher(void) /*****************************************************************************/ static void -dump_proxy_to_props(NMProxyConfig *proxy, GVariantBuilder *builder) +dump_proxy_to_props(const NML3ConfigData *l3cd, GVariantBuilder *builder) { - const char *pac_url = NULL, *pac_script = NULL; + const char *s; - if (nm_proxy_config_get_method(proxy) == NM_PROXY_CONFIG_METHOD_NONE) + if (nm_l3_config_data_get_proxy_method(l3cd) != NM_PROXY_CONFIG_METHOD_AUTO) return; - pac_url = nm_proxy_config_get_pac_url(proxy); - if (pac_url) { - g_variant_builder_add(builder, "{sv}", "pac-url", g_variant_new_string(pac_url)); - } + s = nm_l3_config_data_get_proxy_pac_url(l3cd); + if (s) + g_variant_builder_add(builder, "{sv}", "pac-url", g_variant_new_string(s)); - pac_script = nm_proxy_config_get_pac_script(proxy); - if (pac_script) { - g_variant_builder_add(builder, "{sv}", "pac-script", g_variant_new_string(pac_script)); - } + s = nm_l3_config_data_get_proxy_pac_script(l3cd); + if (s) + g_variant_builder_add(builder, "{sv}", "pac-script", g_variant_new_string(s)); } static void -dump_ip_to_props(NMIPConfig *ip, GVariantBuilder *builder) +dump_ip_to_props(const NML3ConfigData *l3cd, int addr_family, GVariantBuilder *builder) { - const int addr_family = nm_ip_config_get_addr_family(ip); - const int IS_IPv4 = NM_IS_IPv4(addr_family); - const NMPObject *obj; - GVariantBuilder int_builder; - NMDedupMultiIter ipconf_iter; - GVariant * var1; - GVariant * var2; - guint n; - guint i; - const NMPObject *default_route; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + const NMPObject * obj; + GVariantBuilder int_builder; + NMDedupMultiIter ipconf_iter; + GVariant * var1; + GVariant * var2; + guint n; + guint i; + const NMPObject * default_route; + const char *const *strarr; + const in_addr_t * ip4arr; + gconstpointer iparr; if (IS_IPv4) g_variant_builder_init(&int_builder, G_VARIANT_TYPE("aau")); else g_variant_builder_init(&int_builder, G_VARIANT_TYPE("a(ayuay)")); - default_route = nm_ip_config_best_default_route_get(ip); - if (IS_IPv4) - nm_ip_config_iter_ip4_address_init(&ipconf_iter, NM_IP4_CONFIG(ip)); - else - nm_ip_config_iter_ip6_address_init(&ipconf_iter, NM_IP6_CONFIG(ip)); - while (nm_platform_dedup_multi_iter_next_obj(&ipconf_iter, - &obj, - NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4))) { + default_route = nm_l3_config_data_get_best_default_route(l3cd, addr_family); + nm_l3_config_data_iter_obj_for_each (&ipconf_iter, + l3cd, + &obj, + NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)) { const NMPlatformIPXAddress *addr = NMP_OBJECT_CAST_IPX_ADDRESS(obj); if (IS_IPv4) { @@ -225,30 +220,28 @@ dump_ip_to_props(NMIPConfig *ip, GVariantBuilder *builder) g_variant_builder_init(&int_builder, G_VARIANT_TYPE("au")); else g_variant_builder_init(&int_builder, G_VARIANT_TYPE("aay")); - n = nm_ip_config_get_num_nameservers(ip); + iparr = nm_l3_config_data_get_nameservers(l3cd, addr_family, &n); for (i = 0; i < n; i++) { - if (IS_IPv4) { - g_variant_builder_add(&int_builder, - "u", - nm_ip4_config_get_nameserver(NM_IP4_CONFIG(ip), i)); - } else { - var1 = nm_g_variant_new_ay_in6addr(nm_ip6_config_get_nameserver(NM_IP6_CONFIG(ip), i)); + if (IS_IPv4) + g_variant_builder_add(&int_builder, "u", ((const in_addr_t *) iparr)[i]); + else { + var1 = nm_g_variant_new_ay_in6addr(&(((const struct in6_addr *) iparr)[i])); g_variant_builder_add(&int_builder, "@ay", var1); } } g_variant_builder_add(builder, "{sv}", "nameservers", g_variant_builder_end(&int_builder)); g_variant_builder_init(&int_builder, G_VARIANT_TYPE("as")); - n = nm_ip_config_get_num_domains(ip); + strarr = nm_l3_config_data_get_domains(l3cd, addr_family, &n); for (i = 0; i < n; i++) - g_variant_builder_add(&int_builder, "s", nm_ip_config_get_domain(ip, i)); + g_variant_builder_add(&int_builder, "s", strarr[i]); g_variant_builder_add(builder, "{sv}", "domains", g_variant_builder_end(&int_builder)); if (IS_IPv4) { g_variant_builder_init(&int_builder, G_VARIANT_TYPE("au")); - n = nm_ip4_config_get_num_wins(NM_IP4_CONFIG(ip)); + ip4arr = nm_l3_config_data_get_wins(l3cd, &n); for (i = 0; i < n; i++) - g_variant_builder_add(&int_builder, "u", nm_ip4_config_get_wins(NM_IP4_CONFIG(ip), i)); + g_variant_builder_add(&int_builder, "u", ip4arr[i]); g_variant_builder_add(builder, "{sv}", "wins-servers", g_variant_builder_end(&int_builder)); } @@ -256,13 +249,10 @@ dump_ip_to_props(NMIPConfig *ip, GVariantBuilder *builder) g_variant_builder_init(&int_builder, G_VARIANT_TYPE("aau")); else g_variant_builder_init(&int_builder, G_VARIANT_TYPE("a(ayuayu)")); - if (IS_IPv4) - nm_ip_config_iter_ip4_route_init(&ipconf_iter, NM_IP4_CONFIG(ip)); - else - nm_ip_config_iter_ip6_route_init(&ipconf_iter, NM_IP6_CONFIG(ip)); - while (nm_platform_dedup_multi_iter_next_obj(&ipconf_iter, - &obj, - NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4))) { + nm_l3_config_data_iter_obj_for_each (&ipconf_iter, + l3cd, + &obj, + NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { const NMPlatformIPXRoute *route = NMP_OBJECT_CAST_IPX_ROUTE(obj); if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route)) @@ -299,10 +289,8 @@ fill_device_props(NMDevice * device, GVariant ** dhcp4_props, GVariant ** dhcp6_props) { - NMProxyConfig *proxy_config; - NMIP4Config * ip4_config; - NMIP6Config * ip6_config; - NMDhcpConfig * dhcp_config; + const NML3ConfigData *l3cd; + NMDhcpConfig * dhcp_config; /* If the action is for a VPN, send the VPN's IP interface instead of the device's */ g_variant_builder_add(dev_builder, @@ -329,17 +317,12 @@ fill_device_props(NMDevice * device, g_variant_new_object_path(nm_dbus_object_get_path(NM_DBUS_OBJECT(device)))); } - proxy_config = nm_device_get_proxy_config(device); - if (proxy_config) - dump_proxy_to_props(proxy_config, proxy_builder); - - ip4_config = nm_device_get_ip4_config(device); - if (ip4_config) - dump_ip_to_props(NM_IP_CONFIG(ip4_config), ip4_builder); - - ip6_config = nm_device_get_ip6_config(device); - if (ip6_config) - dump_ip_to_props(NM_IP_CONFIG(ip6_config), ip6_builder); + l3cd = nm_device_get_l3cd(device, TRUE); + if (l3cd) { + dump_ip_to_props(l3cd, AF_INET, ip4_builder); + dump_ip_to_props(l3cd, AF_INET6, ip6_builder); + dump_proxy_to_props(l3cd, proxy_builder); + } dhcp_config = nm_device_get_dhcp_config(device, AF_INET); if (dhcp_config) @@ -351,19 +334,16 @@ fill_device_props(NMDevice * device, } static void -fill_vpn_props(NMProxyConfig * proxy_config, - NMIP4Config * ip4_config, - NMIP6Config * ip6_config, - GVariantBuilder *proxy_builder, - GVariantBuilder *ip4_builder, - GVariantBuilder *ip6_builder) +fill_vpn_props(const NML3ConfigData *l3cd, + GVariantBuilder * proxy_builder, + GVariantBuilder * ip4_builder, + GVariantBuilder * ip6_builder) { - if (proxy_config) - dump_proxy_to_props(proxy_config, proxy_builder); - if (ip4_config) - dump_ip_to_props(NM_IP_CONFIG(ip4_config), ip4_builder); - if (ip6_config) - dump_ip_to_props(NM_IP_CONFIG(ip6_config), ip6_builder); + if (l3cd) { + dump_ip_to_props(l3cd, AF_INET, ip4_builder); + dump_ip_to_props(l3cd, AF_INET6, ip6_builder); + dump_proxy_to_props(l3cd, proxy_builder); + } } static const char * @@ -479,9 +459,7 @@ _dispatcher_call(NMDispatcherAction action, gboolean activation_type_external, NMConnectivityState connectivity_state, const char * vpn_iface, - NMProxyConfig * vpn_proxy_config, - NMIP4Config * vpn_ip4_config, - NMIP6Config * vpn_ip6_config, + const NML3ConfigData *l3cd, NMDispatcherFunc callback, gpointer user_data, NMDispatcherCallId ** out_call_id) @@ -593,13 +571,8 @@ _dispatcher_call(NMDispatcherAction action, &device_ip6_props, &device_dhcp4_props, &device_dhcp6_props); - if (vpn_ip4_config || vpn_ip6_config) { - fill_vpn_props(vpn_proxy_config, - vpn_ip4_config, - vpn_ip6_config, - &vpn_proxy_props, - &vpn_ip4_props, - &vpn_ip6_props); + if (l3cd) { + fill_vpn_props(l3cd, &vpn_proxy_props, &vpn_ip4_props, &vpn_ip6_props); } } @@ -693,8 +666,6 @@ nm_dispatcher_call_hostname(NMDispatcherFunc callback, NM_CONNECTIVITY_UNKNOWN, NULL, NULL, - NULL, - NULL, callback, user_data, out_call_id); @@ -744,8 +715,6 @@ nm_dispatcher_call_device(NMDispatcherAction action, NM_CONNECTIVITY_UNKNOWN, NULL, NULL, - NULL, - NULL, callback, user_data, out_call_id); @@ -790,8 +759,6 @@ nm_dispatcher_call_device_sync(NMDispatcherAction action, NULL, NULL, NULL, - NULL, - NULL, NULL); } @@ -802,9 +769,7 @@ nm_dispatcher_call_device_sync(NMDispatcherAction action, * @applied_connection: the currently applied connection * @parent_device: the parent #NMDevice of the VPN connection * @vpn_iface: the IP interface of the VPN tunnel, if any - * @vpn_proxy_config: the #NMProxyConfig of the VPN connection - * @vpn_ip4_config: the #NMIP4Config of the VPN connection - * @vpn_ip6_config: the #NMIP6Config of the VPN connection + * @vpn_l3cd: the #NML3ConfigData of the VPN connection * @callback: a caller-supplied callback to execute when done * @user_data: caller-supplied pointer passed to @callback * @out_call_id: on success, a call identifier which can be passed to @@ -821,9 +786,7 @@ nm_dispatcher_call_vpn(NMDispatcherAction action, NMConnection * applied_connection, NMDevice * parent_device, const char * vpn_iface, - NMProxyConfig * vpn_proxy_config, - NMIP4Config * vpn_ip4_config, - NMIP6Config * vpn_ip6_config, + const NML3ConfigData *l3cd, NMDispatcherFunc callback, gpointer user_data, NMDispatcherCallId ** out_call_id) @@ -836,9 +799,7 @@ nm_dispatcher_call_vpn(NMDispatcherAction action, FALSE, NM_CONNECTIVITY_UNKNOWN, vpn_iface, - vpn_proxy_config, - vpn_ip4_config, - vpn_ip6_config, + l3cd, callback, user_data, out_call_id); @@ -851,9 +812,7 @@ nm_dispatcher_call_vpn(NMDispatcherAction action, * @applied_connection: the currently applied connection * @parent_device: the parent #NMDevice of the VPN connection * @vpn_iface: the IP interface of the VPN tunnel, if any - * @vpn_proxy_config: the #NMProxyConfig of the VPN connection - * @vpn_ip4_config: the #NMIP4Config of the VPN connection - * @vpn_ip6_config: the #NMIP6Config of the VPN connection + * @vpn_l3cd: the #NML3ConfigData of the VPN connection * * This method always invokes the dispatcher action synchronously and it may * take a long time to return. @@ -866,9 +825,7 @@ nm_dispatcher_call_vpn_sync(NMDispatcherAction action, NMConnection * applied_connection, NMDevice * parent_device, const char * vpn_iface, - NMProxyConfig * vpn_proxy_config, - NMIP4Config * vpn_ip4_config, - NMIP6Config * vpn_ip6_config) + const NML3ConfigData *l3cd) { return _dispatcher_call(action, TRUE, @@ -878,9 +835,7 @@ nm_dispatcher_call_vpn_sync(NMDispatcherAction action, FALSE, NM_CONNECTIVITY_UNKNOWN, vpn_iface, - vpn_proxy_config, - vpn_ip4_config, - vpn_ip6_config, + l3cd, NULL, NULL, NULL); @@ -913,8 +868,6 @@ nm_dispatcher_call_connectivity(NMConnectivityState connectivity_state, connectivity_state, NULL, NULL, - NULL, - NULL, callback, user_data, out_call_id); diff --git a/src/core/nm-dispatcher.h b/src/core/nm-dispatcher.h index 8e4f01cb62..c347352a2d 100644 --- a/src/core/nm-dispatcher.h +++ b/src/core/nm-dispatcher.h @@ -51,9 +51,7 @@ gboolean nm_dispatcher_call_vpn(NMDispatcherAction action, NMConnection * applied_connection, NMDevice * parent_device, const char * vpn_iface, - NMProxyConfig * vpn_proxy_config, - NMIP4Config * vpn_ip4_config, - NMIP6Config * vpn_ip6_config, + const NML3ConfigData *l3cd, NMDispatcherFunc callback, gpointer user_data, NMDispatcherCallId ** out_call_id); @@ -63,9 +61,7 @@ gboolean nm_dispatcher_call_vpn_sync(NMDispatcherAction action, NMConnection * applied_connection, NMDevice * parent_device, const char * vpn_iface, - NMProxyConfig * vpn_proxy_config, - NMIP4Config * vpn_ip4_config, - NMIP6Config * vpn_ip6_config); + const NML3ConfigData *l3cd); gboolean nm_dispatcher_call_connectivity(NMConnectivityState state, NMDispatcherFunc callback, diff --git a/src/core/nm-iface-helper.c b/src/core/nm-iface-helper.c deleted file mode 100644 index 83ae1b5466..0000000000 --- a/src/core/nm-iface-helper.c +++ /dev/null @@ -1,857 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2014 Red Hat, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libnm-glib-aux/nm-c-list.h" - -#include "main-utils.h" -#include "NetworkManagerUtils.h" -#include "libnm-platform/nm-linux-platform.h" -#include "libnm-platform/nm-platform-utils.h" -#include "dhcp/nm-dhcp-manager.h" -#include "ndisc/nm-ndisc.h" -#include "ndisc/nm-lndp-ndisc.h" -#include "nm-utils.h" -#include "libnm-core-intern/nm-core-internal.h" -#include "nm-setting-ip6-config.h" -#include "libnm-systemd-core/nm-sd.h" - -#if !defined(NM_DIST_VERSION) -#define NM_DIST_VERSION VERSION -#endif - -#define NMIH_PID_FILE_FMT NMRUNDIR "/nm-iface-helper-%d.pid" - -/*****************************************************************************/ - -static struct { - GMainLoop *main_loop; - int ifindex; - gboolean is_vrf_device; - - guint dad_failed_id; - CList dad_failed_lst_head; -} gl /*obal*/ = { - .ifindex = -1, - .is_vrf_device = FALSE, -}; - -static struct { - gboolean slaac; - gboolean show_version; - gboolean become_daemon; - gboolean debug; - gboolean g_fatal_warnings; - gboolean slaac_required; - gboolean dhcp4_required; - int tempaddr; - char * ifname; - char * uuid; - char * stable_id; - char * dhcp4_address; - char * dhcp4_clientid; - char * dhcp4_hostname; - char * dhcp4_fqdn; - char * mud_url; - char * iid_str; - NMSettingIP6ConfigAddrGenMode addr_gen_mode; - char * logging_backend; - char * opt_log_level; - char * opt_log_domains; - guint32 priority_v4; - guint32 priority_v6; -} global_opt = { - .tempaddr = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, - .priority_v4 = NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4, - .priority_v6 = NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, -}; - -/*****************************************************************************/ - -#define _NMLOG_PREFIX_NAME "nm-iface-helper" -#define _NMLOG(level, domain, ...) \ - nm_log((level), \ - (domain), \ - global_opt.ifname, \ - NULL, \ - "iface-helper: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__) _NM_UTILS_MACRO_REST(__VA_ARGS__)) - -/*****************************************************************************/ - -static void -_dhcp_client_notify_cb(NMDhcpClient * client, - const NMDhcpClientNotifyData *notify_data, - gpointer user_data) -{ - static NMIP4Config *last_config = NULL; - NMIP4Config * existing; - gs_unref_ptrarray GPtrArray *ip4_dev_route_blacklist = NULL; - gs_free_error GError *error = NULL; - NMIP4Config * ip4_config; - - if (!notify_data || notify_data->notify_type != NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED) - g_return_if_reached(); - - nm_assert(!notify_data->state_changed.ip_config - || NM_IS_IP4_CONFIG(notify_data->state_changed.ip_config)); - - _LOGD(LOGD_DHCP4, "new DHCPv4 client state %d", (int) notify_data->state_changed.dhcp_state); - - switch (notify_data->state_changed.dhcp_state) { - case NM_DHCP_STATE_BOUND: - case NM_DHCP_STATE_EXTENDED: - ip4_config = NM_IP4_CONFIG(notify_data->state_changed.ip_config); - - g_assert(ip4_config); - g_assert(nm_ip4_config_get_ifindex(ip4_config) == gl.ifindex); - - existing = nm_ip4_config_capture(nm_platform_get_multi_idx(NM_PLATFORM_GET), - NM_PLATFORM_GET, - gl.ifindex); - if (last_config) - nm_ip4_config_subtract(existing, last_config, 0); - - nm_ip4_config_merge(existing, ip4_config, NM_IP_CONFIG_MERGE_DEFAULT, 0); - nm_ip4_config_add_dependent_routes(existing, - RT_TABLE_MAIN, - global_opt.priority_v4, - gl.is_vrf_device, - &ip4_dev_route_blacklist); - if (!nm_ip4_config_commit(existing, NM_PLATFORM_GET, NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN)) - _LOGW(LOGD_DHCP4, "failed to apply DHCPv4 config"); - - if (!last_config && !nm_dhcp_client_accept(client, &error)) - _LOGW(LOGD_DHCP4, "failed to accept lease: %s", error->message); - - nm_platform_ip4_dev_route_blacklist_set(NM_PLATFORM_GET, - gl.ifindex, - ip4_dev_route_blacklist); - - if (last_config) - g_object_unref(last_config); - last_config = nm_ip4_config_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), - nm_dhcp_client_get_ifindex(client)); - nm_ip4_config_replace(last_config, ip4_config, NULL); - break; - case NM_DHCP_STATE_TIMEOUT: - case NM_DHCP_STATE_DONE: - case NM_DHCP_STATE_FAIL: - if (global_opt.dhcp4_required) { - _LOGW(LOGD_DHCP4, "DHCPv4 timed out or failed, quitting..."); - g_main_loop_quit(gl.main_loop); - } else - _LOGW(LOGD_DHCP4, "DHCPv4 timed out or failed"); - break; - default: - break; - } -} - -static void -ndisc_config_changed(NMNDisc * ndisc, - const NMNDiscData *rdata, - guint changed_int, - gpointer user_data) -{ - NMNDiscConfigMap changed = changed_int; - static NMIP6Config *ndisc_config = NULL; - NMIP6Config * existing; - - existing = nm_ip6_config_capture(nm_platform_get_multi_idx(NM_PLATFORM_GET), - NM_PLATFORM_GET, - gl.ifindex, - global_opt.tempaddr); - if (ndisc_config) - nm_ip6_config_subtract(existing, ndisc_config, 0); - else { - ndisc_config = nm_ip6_config_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), gl.ifindex); - } - - if (changed & NM_NDISC_CONFIG_ADDRESSES) { - guint32 ifa_flags; - - /* Check, whether kernel is recent enough to help user space handling RA. - * If it's not supported, we have no ipv6-privacy and must add autoconf - * addresses as /128. The reason for the /128 is to prevent the kernel - * from adding a prefix route for this address. */ - ifa_flags = IFA_F_NOPREFIXROUTE; - if (NM_IN_SET(global_opt.tempaddr, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)) - ifa_flags |= IFA_F_MANAGETEMPADDR; - - nm_ip6_config_reset_addresses_ndisc(ndisc_config, - rdata->addresses, - rdata->addresses_n, - 64, - ifa_flags); - } - - if (NM_FLAGS_ANY(changed, NM_NDISC_CONFIG_ROUTES | NM_NDISC_CONFIG_GATEWAYS)) { - nm_ip6_config_reset_routes_ndisc(ndisc_config, - rdata->gateways, - rdata->gateways_n, - rdata->routes, - rdata->routes_n, - RT_TABLE_MAIN, - global_opt.priority_v6); - } - - if (changed & NM_NDISC_CONFIG_DHCP_LEVEL) { - /* Unsupported until systemd DHCPv6 is ready */ - } - - if (changed & NM_NDISC_CONFIG_HOP_LIMIT) - nm_platform_sysctl_ip_conf_set_ipv6_hop_limit_safe(NM_PLATFORM_GET, - global_opt.ifname, - rdata->hop_limit); - - if (changed & NM_NDISC_CONFIG_REACHABLE_TIME) { - nm_platform_sysctl_ip_neigh_set_ipv6_reachable_time(NM_PLATFORM_GET, - global_opt.ifname, - rdata->reachable_time_ms); - } - - if (changed & NM_NDISC_CONFIG_RETRANS_TIMER) { - nm_platform_sysctl_ip_neigh_set_ipv6_retrans_time(NM_PLATFORM_GET, - global_opt.ifname, - rdata->retrans_timer_ms); - } - - if (changed & NM_NDISC_CONFIG_MTU) { - nm_platform_sysctl_ip_conf_set_int64(NM_PLATFORM_GET, - AF_INET6, - global_opt.ifname, - "mtu", - rdata->mtu); - } - - nm_ip6_config_merge(existing, ndisc_config, NM_IP_CONFIG_MERGE_DEFAULT, 0); - nm_ip6_config_add_dependent_routes(existing, - RT_TABLE_MAIN, - global_opt.priority_v6, - gl.is_vrf_device); - if (!nm_ip6_config_commit(existing, NM_PLATFORM_GET, NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN, NULL)) - _LOGW(LOGD_IP6, "failed to apply IPv6 config"); -} - -static void -ndisc_ra_timeout(NMNDisc *ndisc, gpointer user_data) -{ - if (global_opt.slaac_required) { - _LOGW(LOGD_IP6, "IPv6 timed out or failed, quitting..."); - g_main_loop_quit(gl.main_loop); - } else - _LOGW(LOGD_IP6, "IPv6 timed out or failed"); -} - -static gboolean -quit_handler(gpointer user_data) -{ - g_main_loop_quit(gl.main_loop); - return G_SOURCE_REMOVE; -} - -static void -setup_signals(void) -{ - signal(SIGPIPE, SIG_IGN); - g_unix_signal_add(SIGINT, quit_handler, NULL); - g_unix_signal_add(SIGTERM, quit_handler, NULL); -} - -static gboolean -do_early_setup(int *argc, char **argv[]) -{ - gint64 priority64_v4 = -1; - gint64 priority64_v6 = -1; - GOptionEntry options[] = { - /* Interface/IP config */ - {"ifname", - 'i', - 0, - G_OPTION_ARG_STRING, - &global_opt.ifname, - N_("The interface to manage"), - "eth0"}, - {"uuid", - 'u', - 0, - G_OPTION_ARG_STRING, - &global_opt.uuid, - N_("Connection UUID"), - "661e8cd0-b618-46b8-9dc9-31a52baaa16b"}, - {"stable-id", - '\0', - 0, - G_OPTION_ARG_STRING, - &global_opt.stable_id, - N_("Connection Token for Stable IDs"), - "eth"}, - {"slaac", - 's', - 0, - G_OPTION_ARG_NONE, - &global_opt.slaac, - N_("Whether to manage IPv6 SLAAC"), - NULL}, - {"slaac-required", - '6', - 0, - G_OPTION_ARG_NONE, - &global_opt.slaac_required, - N_("Whether SLAAC must be successful"), - NULL}, - {"slaac-tempaddr", - 't', - 0, - G_OPTION_ARG_INT, - &global_opt.tempaddr, - N_("Use an IPv6 temporary privacy address"), - NULL}, - {"dhcp4", - 'd', - 0, - G_OPTION_ARG_STRING, - &global_opt.dhcp4_address, - N_("Current DHCPv4 address"), - NULL}, - {"dhcp4-required", - '4', - 0, - G_OPTION_ARG_NONE, - &global_opt.dhcp4_required, - N_("Whether DHCPv4 must be successful"), - NULL}, - {"dhcp4-clientid", - 'c', - 0, - G_OPTION_ARG_STRING, - &global_opt.dhcp4_clientid, - N_("Hex-encoded DHCPv4 client ID"), - NULL}, - {"dhcp4-hostname", - 'h', - 0, - G_OPTION_ARG_STRING, - &global_opt.dhcp4_hostname, - N_("Hostname to send to DHCP server"), - N_("barbar")}, - {"dhcp4-fqdn", - 'F', - 0, - G_OPTION_ARG_STRING, - &global_opt.dhcp4_fqdn, - N_("FQDN to send to DHCP server"), - N_("host.domain.org")}, - {"priority4", - '\0', - 0, - G_OPTION_ARG_INT64, - &priority64_v4, - N_("Route priority for IPv4"), - N_("0")}, - {"priority6", - '\0', - 0, - G_OPTION_ARG_INT64, - &priority64_v6, - N_("Route priority for IPv6"), - N_("1024")}, - {"iid", - 'e', - 0, - G_OPTION_ARG_STRING, - &global_opt.iid_str, - N_("Hex-encoded Interface Identifier"), - ""}, - {"addr-gen-mode", - 'e', - 0, - G_OPTION_ARG_INT, - &global_opt.addr_gen_mode, - N_("IPv6 SLAAC address generation mode"), - "eui64"}, - {"logging-backend", - '\0', - 0, - G_OPTION_ARG_STRING, - &global_opt.logging_backend, - N_("The logging backend configuration value. See logging.backend in NetworkManager.conf"), - NULL}, - - /* Logging/debugging */ - {"version", - 'V', - 0, - G_OPTION_ARG_NONE, - &global_opt.show_version, - N_("Print NetworkManager version and exit"), - NULL}, - {"no-daemon", - 'n', - G_OPTION_FLAG_REVERSE, - G_OPTION_ARG_NONE, - &global_opt.become_daemon, - N_("Don't become a daemon"), - NULL}, - {"debug", - 'b', - 0, - G_OPTION_ARG_NONE, - &global_opt.debug, - N_("Don't become a daemon, and log to stderr"), - NULL}, - {"log-level", - 0, - 0, - G_OPTION_ARG_STRING, - &global_opt.opt_log_level, - N_("Log level: one of [%s]"), - "INFO"}, - {"log-domains", - 0, - 0, - G_OPTION_ARG_STRING, - &global_opt.opt_log_domains, - N_("Log domains separated by ',': any combination of [%s]"), - "PLATFORM,RFKILL,WIFI"}, - {"g-fatal-warnings", - 0, - 0, - G_OPTION_ARG_NONE, - &global_opt.g_fatal_warnings, - N_("Make all warnings fatal"), - NULL}, - {NULL}}; - - if (!nm_main_utils_early_setup("nm-iface-helper", - argc, - argv, - options, - NULL, - NULL, - _("nm-iface-helper is a small, standalone process that manages " - "a single network interface."))) - return FALSE; - - if (priority64_v4 >= 0 && priority64_v4 <= G_MAXUINT32) - global_opt.priority_v4 = (guint32) priority64_v4; - if (priority64_v6 >= 0 && priority64_v6 <= G_MAXUINT32) - global_opt.priority_v6 = (guint32) priority64_v6; - return TRUE; -} - -typedef struct { - NMPlatform *platform; - NMNDisc * ndisc; -} DadFailedHandleData; - -static gboolean -dad_failed_handle_idle(gpointer user_data) -{ - DadFailedHandleData *data = user_data; - NMCListElem * elem; - - while ((elem = c_list_first_entry(&gl.dad_failed_lst_head, NMCListElem, lst))) { - nm_auto_nmpobj const NMPObject *obj = elem->data; - - nm_c_list_elem_free(elem); - - if (nm_ndisc_dad_addr_is_fail_candidate(data->platform, obj)) { - nm_ndisc_dad_failed(data->ndisc, &NMP_OBJECT_CAST_IP6_ADDRESS(obj)->address, TRUE); - } - } - - gl.dad_failed_id = 0; - return G_SOURCE_REMOVE; -} - -static void -ip6_address_changed(NMPlatform * platform, - int obj_type_i, - int iface, - const NMPlatformIP6Address *addr, - int change_type_i, - NMNDisc * ndisc) -{ - const NMPlatformSignalChangeType change_type = change_type_i; - DadFailedHandleData * data; - - if (!nm_ndisc_dad_addr_is_fail_candidate_event(change_type, addr)) - return; - - c_list_link_tail( - &gl.dad_failed_lst_head, - &nm_c_list_elem_new_stale((gpointer) nmp_object_ref(NMP_OBJECT_UP_CAST(addr)))->lst); - if (gl.dad_failed_id) - return; - - data = g_slice_new(DadFailedHandleData); - data->platform = platform; - data->ndisc = ndisc; - gl.dad_failed_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, - dad_failed_handle_idle, - data, - nm_g_slice_free_fcn(DadFailedHandleData)); -} - -int -main(int argc, char *argv[]) -{ - char * bad_domains = NULL; - gs_free_error GError *error = NULL; - gboolean wrote_pidfile = FALSE; - gs_free char * pidfile = NULL; - gs_unref_object NMDhcpClient *dhcp4_client = NULL; - gs_unref_object NMNDisc *ndisc = NULL; - gs_unref_bytes GBytes *hwaddr = NULL; - gs_unref_bytes GBytes *bcast_hwaddr = NULL; - gs_unref_bytes GBytes *client_id = NULL; - gs_free NMUtilsIPv6IfaceId *iid = NULL; - const NMPlatformLink * pllink; - guint sd_id; - int errsv; - - c_list_init(&gl.dad_failed_lst_head); - - setpgid(getpid(), getpid()); - - if (!do_early_setup(&argc, &argv)) - return 1; - - nm_logging_init_pre("nm-iface-helper", - g_strdup_printf("%s[%ld] (%s): ", - _NMLOG_PREFIX_NAME, - (long) getpid(), - global_opt.ifname ?: "???")); - - if (global_opt.g_fatal_warnings) { - GLogLevelFlags fatal_mask; - - fatal_mask = g_log_set_always_fatal(G_LOG_FATAL_MASK); - fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; - g_log_set_always_fatal(fatal_mask); - } - - if (global_opt.show_version) { - fprintf(stdout, NM_DIST_VERSION "\n"); - return 0; - } - - nm_main_utils_ensure_root(); - - if (!global_opt.ifname || !global_opt.uuid) { - fprintf(stderr, _("An interface name and UUID are required\n")); - return 1; - } - - gl.ifindex = nmp_utils_if_nametoindex(global_opt.ifname); - if (gl.ifindex <= 0) { - errsv = errno; - fprintf(stderr, - _("Failed to find interface index for %s (%s)\n"), - global_opt.ifname, - nm_strerror_native(errsv)); - return 1; - } - pidfile = g_strdup_printf(NMIH_PID_FILE_FMT, gl.ifindex); - nm_main_utils_ensure_not_running_pidfile(pidfile); - - nm_main_utils_ensure_rundir(); - - if (!nm_logging_setup(global_opt.opt_log_level, - global_opt.opt_log_domains, - &bad_domains, - &error)) { - fprintf(stderr, - _("%s. Please use --help to see a list of valid options.\n"), - error->message); - return 1; - } else if (bad_domains) { - fprintf(stderr, - _("Ignoring unrecognized log domain(s) '%s' passed on command line.\n"), - bad_domains); - nm_clear_g_free(&bad_domains); - } - - if (global_opt.become_daemon && !global_opt.debug) { - if (daemon(0, 0) < 0) { - errsv = errno; - fprintf(stderr, - _("Could not daemonize: %s [error %u]\n"), - nm_strerror_native(errsv), - errsv); - return 1; - } - if (nm_main_utils_write_pidfile(pidfile)) - wrote_pidfile = TRUE; - } - - /* Set up unix signal handling - before creating threads, but after daemonizing! */ - gl.main_loop = g_main_loop_new(NULL, FALSE); - setup_signals(); - - nm_logging_init(global_opt.logging_backend, global_opt.debug); - - _LOGI(LOGD_CORE, "nm-iface-helper (version " NM_DIST_VERSION ") is starting..."); - - /* Set up platform interaction layer */ - nm_linux_platform_setup(); - - pllink = nm_platform_link_get(NM_PLATFORM_GET, gl.ifindex); - if (pllink) { - hwaddr = nmp_link_address_get_as_bytes(&pllink->l_address); - bcast_hwaddr = nmp_link_address_get_as_bytes(&pllink->l_broadcast); - - if (pllink->master > 0) { - gl.is_vrf_device = - nm_platform_link_get_type(NM_PLATFORM_GET, pllink->master) == NM_LINK_TYPE_VRF; - } - } - - if (global_opt.iid_str) { - GBytes *bytes; - gsize ignored = 0; - - bytes = nm_utils_hexstr2bin(global_opt.iid_str); - if (!bytes || g_bytes_get_size(bytes) != sizeof(*iid)) { - fprintf(stderr, _("(%s): Invalid IID %s\n"), global_opt.ifname, global_opt.iid_str); - return 1; - } - iid = g_bytes_unref_to_data(bytes, &ignored); - } - - if (global_opt.dhcp4_clientid) { - /* this string is just a plain hex-string. Unlike ipv4.dhcp-client-id, which - * is parsed via nm_dhcp_utils_client_id_string_to_bytes(). */ - client_id = nm_utils_hexstr2bin(global_opt.dhcp4_clientid); - if (!client_id || g_bytes_get_size(client_id) < 2) { - fprintf(stderr, - _("(%s): Invalid DHCP client-id %s\n"), - global_opt.ifname, - global_opt.dhcp4_clientid); - return 1; - } - } - - if (global_opt.dhcp4_address) { - nm_platform_sysctl_ip_conf_set(NM_PLATFORM_GET, - AF_INET, - global_opt.ifname, - "promote_secondaries", - "1"); - - dhcp4_client = nm_dhcp_manager_start_ip4(nm_dhcp_manager_get(), - nm_platform_get_multi_idx(NM_PLATFORM_GET), - global_opt.ifname, - gl.ifindex, - hwaddr, - bcast_hwaddr, - global_opt.uuid, - RT_TABLE_MAIN, - global_opt.priority_v4, - NM_DHCP_CLIENT_FLAGS_NONE, - !!global_opt.dhcp4_hostname, - global_opt.dhcp4_hostname, - global_opt.dhcp4_fqdn, - NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4, - global_opt.mud_url, - client_id, - NM_DHCP_TIMEOUT_DEFAULT, - NULL, - global_opt.dhcp4_address, - NULL, - NULL, - &error); - if (!dhcp4_client) - g_error("failure to start DHCP: %s", error->message); - - g_signal_connect(dhcp4_client, - NM_DHCP_CLIENT_NOTIFY, - G_CALLBACK(_dhcp_client_notify_cb), - NULL); - } - - if (global_opt.slaac) { - NMUtilsStableType stable_type = NM_UTILS_STABLE_TYPE_UUID; - const char * stable_id = global_opt.uuid; - int router_solicitation_interval; - int router_solicitations; - guint32 default_ra_timeout; - int max_addresses; - - nm_platform_link_set_inet6_addr_gen_mode(NM_PLATFORM_GET, - gl.ifindex, - NM_IN6_ADDR_GEN_MODE_NONE); - - if (global_opt.stable_id - && (global_opt.stable_id[0] >= '0' && global_opt.stable_id[0] <= '9') - && global_opt.stable_id[1] == ' ') { - /* strict parsing of --stable-id, which is the numeric stable-type - * and the ID, joined with one space. For now, only support stable-types - * from 0 to 9. */ - stable_type = (global_opt.stable_id[0] - '0'); - stable_id = &global_opt.stable_id[2]; - } - - nm_ndisc_get_sysctl(NM_PLATFORM_GET, - global_opt.ifname, - &max_addresses, - &router_solicitations, - &router_solicitation_interval, - &default_ra_timeout); - - ndisc = nm_lndp_ndisc_new(NM_PLATFORM_GET, - gl.ifindex, - global_opt.ifname, - stable_type, - stable_id, - global_opt.addr_gen_mode, - NM_NDISC_NODE_TYPE_HOST, - max_addresses, - router_solicitations, - router_solicitation_interval, - default_ra_timeout, - NULL); - g_assert(ndisc); - - if (iid) - nm_ndisc_set_iid(ndisc, *iid); - - nm_platform_sysctl_ip_conf_set(NM_PLATFORM_GET, - AF_INET6, - global_opt.ifname, - "accept_ra", - "0"); - - g_signal_connect(NM_PLATFORM_GET, - NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, - G_CALLBACK(ip6_address_changed), - ndisc); - g_signal_connect(ndisc, NM_NDISC_CONFIG_RECEIVED, G_CALLBACK(ndisc_config_changed), NULL); - g_signal_connect(ndisc, NM_NDISC_RA_TIMEOUT_SIGNAL, G_CALLBACK(ndisc_ra_timeout), NULL); - nm_ndisc_start(ndisc); - } - - sd_id = nm_sd_event_attach_default(); - - g_main_loop_run(gl.main_loop); - - nm_clear_g_source(&gl.dad_failed_id); - nm_c_list_elem_free_all(&gl.dad_failed_lst_head, (GDestroyNotify) nmp_object_unref); - - if (pidfile && wrote_pidfile) - unlink(pidfile); - - _LOGI(LOGD_CORE, "exiting"); - - nm_clear_g_source(&sd_id); - nm_clear_pointer(&gl.main_loop, g_main_loop_unref); - return 0; -} - -/*****************************************************************************/ - -const NMDhcpClientFactory *const _nm_dhcp_manager_factories[6] = { - /* For nm-iface-helper there is no option to choose a DHCP plugin. - * It just uses the "internal" one. */ - &_nm_dhcp_client_factory_internal, -}; - -/*****************************************************************************/ -/* Stub functions */ - -#include "nm-config.h" -#include "devices/nm-device.h" -#include "nm-active-connection.h" -#include "nm-dbus-manager.h" - -void -nm_main_config_reload(int signal) -{ - _LOGI(LOGD_CORE, "reloading configuration not supported"); -} - -NMConfig * -nm_config_get(void) -{ - return GUINT_TO_POINTER(1); -} - -NMConfigData * -nm_config_get_data_orig(NMConfig *config) -{ - return GUINT_TO_POINTER(1); -} - -char * -nm_config_data_get_value(const NMConfigData * config_data, - const char * group, - const char * key, - NMConfigGetValueFlags flags) -{ - return NULL; -} - -NMConfigConfigureAndQuitType -nm_config_get_configure_and_quit(NMConfig *config) -{ - return NM_CONFIG_CONFIGURE_AND_QUIT_ENABLED; -} - -NMDBusManager * -nm_dbus_manager_get(void) -{ - return NULL; -} - -gboolean -nm_dbus_manager_is_stopping(NMDBusManager *self) -{ - return FALSE; -} - -void -_nm_dbus_manager_obj_export(NMDBusObject *obj) -{} - -void -_nm_dbus_manager_obj_unexport(NMDBusObject *obj) -{} - -void -_nm_dbus_manager_obj_notify(NMDBusObject *obj, guint n_pspecs, const GParamSpec *const *pspecs) -{} - -void -_nm_dbus_manager_obj_emit_signal(NMDBusObject * obj, - const NMDBusInterfaceInfoExtended *interface_info, - const GDBusSignalInfo * signal_info, - GVariant * args) -{} - -GType -nm_device_get_type(void) -{ - g_return_val_if_reached(0); -} - -GType -nm_active_connection_get_type(void) -{ - g_return_val_if_reached(0); -} diff --git a/src/core/nm-ip-config.c b/src/core/nm-ip-config.c index 2426eb4941..196cf35a98 100644 --- a/src/core/nm-ip-config.c +++ b/src/core/nm-ip-config.c @@ -8,31 +8,125 @@ #include "nm-ip-config.h" +#include + #include "nm-l3cfg.h" +#include "NetworkManagerUtils.h" /*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE(NMIPConfig, PROP_L3CFG, PROP_IS_VPN, ); +GType nm_ip4_config_get_type(void); +GType nm_ip6_config_get_type(void); -typedef struct _NMIPConfigPrivate { - NML3Cfg *l3cfg; - bool is_vpn : 1; -} NMIPConfigPrivate; +/*****************************************************************************/ + +#define NM_IP_CONFIG_ADDRESS_DATA "address-data" +#define NM_IP_CONFIG_DNS_OPTIONS "dns-options" +#define NM_IP_CONFIG_DNS_PRIORITY "dns-priority" +#define NM_IP_CONFIG_DOMAINS "domains" +#define NM_IP_CONFIG_GATEWAY "gateway" +#define NM_IP_CONFIG_ROUTE_DATA "route-data" +#define NM_IP_CONFIG_SEARCHES "searches" + +/*****************************************************************************/ + +typedef struct _NMIPConfigPrivate NMIPConfigPrivate; + +NM_GOBJECT_PROPERTIES_DEFINE_FULL(_ip, + NMIPConfig, + PROP_IP_L3CFG, + PROP_IP_ADDRESS_DATA, + PROP_IP_GATEWAY, + PROP_IP_ROUTE_DATA, + PROP_IP_DOMAINS, + PROP_IP_SEARCHES, + PROP_IP_DNS_PRIORITY, + PROP_IP_DNS_OPTIONS, ); G_DEFINE_ABSTRACT_TYPE(NMIPConfig, nm_ip_config, NM_TYPE_DBUS_OBJECT) -#define NM_IP_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMIPConfig, NM_IS_IP_CONFIG) +#define NM_IP_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIPConfig, NM_IS_IP_CONFIG) + +/*****************************************************************************/ + +static void _handle_platform_change(NMIPConfig *self, guint32 obj_type_flags, gboolean is_init); +static void _handle_l3cd_changed(NMIPConfig *self, const NML3ConfigData *l3cd); /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +_value_set_variant_as(GValue *value, const char *const *strv, guint len) { - NMIPConfig * self = NM_IP_CONFIG(object); - NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + if (len > 0) { + nm_assert(strv && strv[0]); + g_value_set_variant(value, g_variant_new_strv((const char *const *) strv, len)); + } else + g_value_set_variant(value, nm_g_variant_singleton_as()); +} + +/*****************************************************************************/ + +static void +_l3cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMIPConfig *self) +{ + switch (notify_data->notify_type) { + case NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED: + if (notify_data->l3cd_changed.commited) + _handle_l3cd_changed(self, notify_data->l3cd_changed.l3cd_new); + break; + case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE: + _handle_platform_change(self, notify_data->platform_change_on_idle.obj_type_flags, FALSE); + break; + default: + break; + } +} + +/*****************************************************************************/ + +static void +get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + const int addr_family = nm_ip_config_get_addr_family(self); + char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; + const char *const *strv; + guint len; + int v_i; - (void) priv; switch (prop_id) { + case PROP_IP_ADDRESS_DATA: + g_value_set_variant(value, priv->v_address_data); + break; + case PROP_IP_GATEWAY: + g_value_set_variant( + value, + nm_ip_addr_is_null(addr_family, &priv->v_gateway.addr) + ? nm_g_variant_singleton_s_empty() + : g_variant_new_string( + nm_utils_inet_ntop(addr_family, &priv->v_gateway.addr, sbuf_addr))); + break; + case PROP_IP_ROUTE_DATA: + g_value_set_variant(value, priv->v_route_data); + break; + case PROP_IP_DOMAINS: + strv = nm_l3_config_data_get_domains(priv->l3cd, addr_family, &len); + _value_set_variant_as(value, strv, len); + break; + case PROP_IP_SEARCHES: + strv = nm_l3_config_data_get_searches(priv->l3cd, addr_family, &len); + _value_set_variant_as(value, strv, len); + break; + case PROP_IP_DNS_PRIORITY: + v_i = nm_l3_config_data_get_dns_priority_or_default(priv->l3cd, addr_family); + g_value_set_variant(value, + (v_i == 0) ? nm_g_variant_singleton_i_0() : g_variant_new_int32(v_i)); + break; + case PROP_IP_DNS_OPTIONS: + strv = nm_l3_config_data_get_dns_options(priv->l3cd, addr_family, &len); + _value_set_variant_as(value, strv, len); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -44,16 +138,14 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps { NMIPConfig * self = NM_IP_CONFIG(object); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + gpointer ptr; switch (prop_id) { - case PROP_L3CFG: + case PROP_IP_L3CFG: /* construct-only */ - priv->l3cfg = nm_g_object_ref(g_value_get_pointer(value)); - nm_assert(!priv->l3cfg || NM_IS_L3CFG(priv->l3cfg)); - break; - case PROP_IS_VPN: - /* construct-only */ - priv->is_vpn = g_value_get_boolean(value); + ptr = g_value_get_pointer(value); + nm_assert(NM_IS_L3CFG(ptr)); + priv->l3cfg = g_object_ref(ptr); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -65,16 +157,10 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps static void nm_ip_config_init(NMIPConfig *self) -{ - NMIPConfigPrivate *priv; - - priv = G_TYPE_INSTANCE_GET_PRIVATE(self, NM_TYPE_IP_CONFIG, NMIPConfigPrivate); - - self->_priv = priv; -} +{} NMIPConfig * -nm_ip_config_new(int addr_family, NML3Cfg *l3cfg, gboolean is_vpn) +nm_ip_config_new(int addr_family, NML3Cfg *l3cfg) { nm_assert_addr_family(addr_family); nm_assert(NM_L3CFG(l3cfg)); @@ -83,18 +169,50 @@ nm_ip_config_new(int addr_family, NML3Cfg *l3cfg, gboolean is_vpn) : nm_ip6_config_get_type(), NM_IP_CONFIG_L3CFG, l3cfg, - NM_IP_CONFIG_IS_VPN, - is_vpn, NULL); } +static void +constructed(GObject *object) +{ + NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + + priv->l3cfg_notify_id = + g_signal_connect(priv->l3cfg, NM_L3CFG_SIGNAL_NOTIFY, G_CALLBACK(_l3cfg_notify_cb), self); + + priv->l3cd = nm_l3_config_data_ref(nm_l3cfg_get_combined_l3cd(priv->l3cfg, TRUE)); + + _handle_platform_change(self, ~((guint32) 0u), TRUE); + + G_OBJECT_CLASS(nm_ip_config_parent_class)->constructed(object); +} + +void +nm_ip_config_take_and_unexport_on_idle(NMIPConfig *self_take) +{ + if (self_take) + nm_dbus_object_unexport_on_idle(g_steal_pointer(&self_take)); +} + static void finalize(GObject *object) { NMIPConfig * self = NM_IP_CONFIG(object); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); - nm_g_object_unref(priv->l3cfg); + nm_clear_g_signal_handler(priv->l3cfg, &priv->l3cfg_notify_id); + + g_object_unref(priv->l3cfg); + + nm_g_variant_unref(priv->v_address_data); + nm_g_variant_unref(priv->v_addresses); + nm_g_variant_unref(priv->v_route_data); + nm_g_variant_unref(priv->v_routes); + + nmp_object_unref(priv->v_gateway.best_default_route); + + nm_l3_config_data_unref(priv->l3cd); G_OBJECT_CLASS(nm_ip_config_parent_class)->finalize(object); } @@ -102,26 +220,610 @@ finalize(GObject *object) static void nm_ip_config_class_init(NMIPConfigClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - g_type_class_add_private(object_class, sizeof(NMIPConfigPrivate)); - - object_class->get_property = get_property; + object_class->get_property = get_property_ip; object_class->set_property = set_property; + object_class->constructed = constructed; object_class->finalize = finalize; - obj_properties[PROP_L3CFG] = + dbus_object_class->export_on_construction = TRUE; + + obj_properties_ip[PROP_IP_L3CFG] = g_param_spec_pointer(NM_IP_CONFIG_L3CFG, "", "", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IS_VPN] = - g_param_spec_boolean(NM_IP_CONFIG_IS_VPN, + obj_properties_ip[PROP_IP_ADDRESS_DATA] = + g_param_spec_variant(NM_IP_CONFIG_ADDRESS_DATA, "", "", - FALSE, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + G_VARIANT_TYPE("aa{sv}"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip[PROP_IP_GATEWAY] = + g_param_spec_variant(NM_IP_CONFIG_GATEWAY, + "", + "", + G_VARIANT_TYPE("s"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip[PROP_IP_ROUTE_DATA] = + g_param_spec_variant(NM_IP_CONFIG_ROUTE_DATA, + "", + "", + G_VARIANT_TYPE("aa{sv}"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip[PROP_IP_DOMAINS] = + g_param_spec_variant(NM_IP_CONFIG_DOMAINS, + "", + "", + G_VARIANT_TYPE("as"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip[PROP_IP_SEARCHES] = + g_param_spec_variant(NM_IP_CONFIG_SEARCHES, + "", + "", + G_VARIANT_TYPE("as"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip[PROP_IP_DNS_PRIORITY] = + g_param_spec_variant(NM_IP_CONFIG_DNS_PRIORITY, + "", + "", + G_VARIANT_TYPE("i"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip[PROP_IP_DNS_OPTIONS] = + g_param_spec_variant(NM_IP_CONFIG_DNS_OPTIONS, + "", + "", + G_VARIANT_TYPE("as"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST_ip, obj_properties_ip); +} + +/*****************************************************************************/ + +/* public */ +#define NM_IP4_CONFIG_NAMESERVER_DATA "nameserver-data" +#define NM_IP4_CONFIG_WINS_SERVER_DATA "wins-server-data" + +/* deprecated */ +#define NM_IP4_CONFIG_ADDRESSES "addresses" +#define NM_IP4_CONFIG_NAMESERVERS "nameservers" +#define NM_IP4_CONFIG_ROUTES "routes" +#define NM_IP4_CONFIG_WINS_SERVERS "wins-servers" + +typedef struct _NMIP4Config NMIP4Config; +typedef struct _NMIP4ConfigClass NMIP4ConfigClass; + +NM_GOBJECT_PROPERTIES_DEFINE_FULL(_ip4, + NMIP4Config, + PROP_IP4_ADDRESSES, + PROP_IP4_NAMESERVERS, + PROP_IP4_NAMESERVER_DATA, + PROP_IP4_ROUTES, + PROP_IP4_WINS_SERVERS, + PROP_IP4_WINS_SERVER_DATA, ); + +struct _NMIP4Config { + NMIPConfig parent; +}; + +struct _NMIP4ConfigClass { + NMIPConfigClass parent; +}; + +G_DEFINE_TYPE(NMIP4Config, nm_ip4_config, NM_TYPE_IP_CONFIG) + +static void +get_property_ip4(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + char addr_str[NM_UTILS_INET_ADDRSTRLEN]; + GVariantBuilder builder; + const in_addr_t * addrs; + guint len; + guint i; + + switch (prop_id) { + case PROP_IP4_ADDRESSES: + g_value_set_variant(value, priv->v_addresses); + break; + case PROP_IP4_ROUTES: + g_value_set_variant(value, priv->v_routes); + break; + case PROP_IP4_NAMESERVERS: + addrs = nm_l3_config_data_get_nameservers(priv->l3cd, AF_INET, &len); + g_value_set_variant(value, + (len == 0) ? nm_g_variant_singleton_au() + : nm_g_variant_new_au(addrs, len)); + break; + case PROP_IP4_NAMESERVER_DATA: + addrs = nm_l3_config_data_get_nameservers(priv->l3cd, AF_INET, &len); + if (len == 0) + g_value_set_variant(value, nm_g_variant_singleton_aaLsvI()); + else { + g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; i < len; i++) { + GVariantBuilder nested_builder; + + _nm_utils_inet4_ntop(addrs[i], addr_str); + + g_variant_builder_init(&nested_builder, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&nested_builder, + "{sv}", + "address", + g_variant_new_string(addr_str)); + g_variant_builder_add(&builder, "a{sv}", &nested_builder); + } + + g_value_take_variant(value, g_variant_builder_end(&builder)); + } + break; + case PROP_IP4_WINS_SERVERS: + addrs = nm_l3_config_data_get_wins(priv->l3cd, &len); + g_value_set_variant(value, + (len == 0) ? nm_g_variant_singleton_au() + : nm_g_variant_new_au(addrs, len)); + break; + case PROP_IP4_WINS_SERVER_DATA: + addrs = nm_l3_config_data_get_wins(priv->l3cd, &len); + if (len == 0) + g_value_set_variant(value, nm_g_variant_singleton_as()); + else { + g_variant_builder_init(&builder, G_VARIANT_TYPE("as")); + for (i = 0; i < len; i++) + g_variant_builder_add(&builder, "s", _nm_utils_inet4_ntop(addrs[i], addr_str)); + g_value_take_variant(value, g_variant_builder_end(&builder)); + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static const NMDBusInterfaceInfoExtended interface_info_ip4_config = { + .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT( + NM_DBUS_INTERFACE_IP4_CONFIG, + .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS( + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Addresses", + "aau", + NM_IP4_CONFIG_ADDRESSES), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("AddressData", + "aa{sv}", + NM_IP_CONFIG_ADDRESS_DATA), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Gateway", "s", NM_IP_CONFIG_GATEWAY), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Routes", "aau", NM_IP4_CONFIG_ROUTES), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("RouteData", + "aa{sv}", + NM_IP_CONFIG_ROUTE_DATA), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("NameserverData", + "aa{sv}", + NM_IP4_CONFIG_NAMESERVER_DATA), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Nameservers", + "au", + NM_IP4_CONFIG_NAMESERVERS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Domains", "as", NM_IP_CONFIG_DOMAINS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Searches", "as", NM_IP_CONFIG_SEARCHES), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("DnsOptions", + "as", + NM_IP_CONFIG_DNS_OPTIONS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("DnsPriority", + "i", + NM_IP_CONFIG_DNS_PRIORITY), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("WinsServerData", + "as", + NM_IP4_CONFIG_WINS_SERVER_DATA), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("WinsServers", + "au", + NM_IP4_CONFIG_WINS_SERVERS), ), ), +}; + +static void +nm_ip4_config_init(NMIP4Config *self) +{} + +static void +nm_ip4_config_class_init(NMIP4ConfigClass *klass) +{ + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); + NMIPConfigClass * ip_config_class = NM_IP_CONFIG_CLASS(klass); + + ip_config_class->addr_family = AF_INET; + + dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED(NM_DBUS_PATH "/IP4Config"); + dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_ip4_config); + + object_class->get_property = get_property_ip4; + + obj_properties_ip4[PROP_IP4_ADDRESSES] = + g_param_spec_variant(NM_IP4_CONFIG_ADDRESSES, + "", + "", + G_VARIANT_TYPE("aau"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip4[PROP_IP4_ROUTES] = + g_param_spec_variant(NM_IP4_CONFIG_ROUTES, + "", + "", + G_VARIANT_TYPE("aau"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip4[PROP_IP4_NAMESERVER_DATA] = + g_param_spec_variant(NM_IP4_CONFIG_NAMESERVER_DATA, + "", + "", + G_VARIANT_TYPE("aa{sv}"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip4[PROP_IP4_NAMESERVERS] = + g_param_spec_variant(NM_IP4_CONFIG_NAMESERVERS, + "", + "", + G_VARIANT_TYPE("au"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip4[PROP_IP4_WINS_SERVER_DATA] = + g_param_spec_variant(NM_IP4_CONFIG_WINS_SERVER_DATA, + "", + "", + G_VARIANT_TYPE("as"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip4[PROP_IP4_WINS_SERVERS] = + g_param_spec_variant(NM_IP4_CONFIG_WINS_SERVERS, + "", + "", + G_VARIANT_TYPE("au"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST_ip4, obj_properties_ip4); +} + +/*****************************************************************************/ + +/* public */ +#define NM_IP6_CONFIG_NAMESERVERS "nameservers" + +/* deprecated */ +#define NM_IP6_CONFIG_ADDRESSES "addresses" +#define NM_IP6_CONFIG_ROUTES "routes" + +typedef struct _NMIP6Config NMIP6Config; +typedef struct _NMIP6ConfigClass NMIP6ConfigClass; + +NM_GOBJECT_PROPERTIES_DEFINE_FULL(_ip6, + NMIP6Config, + PROP_IP6_NAMESERVERS, + PROP_IP6_ADDRESSES, + PROP_IP6_ROUTES, ); + +struct _NMIP6Config { + NMIPConfig parent; +}; + +struct _NMIP6ConfigClass { + NMIPConfigClass parent; +}; + +G_DEFINE_TYPE(NMIP6Config, nm_ip6_config, NM_TYPE_IP_CONFIG) + +static const NMDBusInterfaceInfoExtended interface_info_ip6_config = { + .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT( + NM_DBUS_INTERFACE_IP6_CONFIG, + .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS( + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Addresses", + "a(ayuay)", + NM_IP6_CONFIG_ADDRESSES), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("AddressData", + "aa{sv}", + NM_IP_CONFIG_ADDRESS_DATA), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Gateway", "s", NM_IP_CONFIG_GATEWAY), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Routes", + "a(ayuayu)", + NM_IP6_CONFIG_ROUTES), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("RouteData", + "aa{sv}", + NM_IP_CONFIG_ROUTE_DATA), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Nameservers", + "aay", + NM_IP6_CONFIG_NAMESERVERS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Domains", "as", NM_IP_CONFIG_DOMAINS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Searches", "as", NM_IP_CONFIG_SEARCHES), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("DnsOptions", + "as", + NM_IP_CONFIG_DNS_OPTIONS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("DnsPriority", + "i", + NM_IP_CONFIG_DNS_PRIORITY), ), ), +}; + +static void +get_property_ip6(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfigPrivate * priv = NM_IP_CONFIG_GET_PRIVATE(self); + GVariantBuilder builder; + guint len; + guint i; + const struct in6_addr *addrs; + + switch (prop_id) { + case PROP_IP6_ADDRESSES: + g_value_set_variant(value, priv->v_addresses); + break; + case PROP_IP6_ROUTES: + g_value_set_variant(value, priv->v_routes); + break; + case PROP_IP6_NAMESERVERS: + addrs = nm_l3_config_data_get_nameservers(priv->l3cd, AF_INET6, &len); + if (len == 0) + g_value_set_variant(value, nm_g_variant_singleton_aay()); + else { + g_variant_builder_init(&builder, G_VARIANT_TYPE("aay")); + for (i = 0; i < len; i++) + g_variant_builder_add(&builder, "@ay", nm_g_variant_new_ay_in6addr(&addrs[i])); + g_value_take_variant(value, g_variant_builder_end(&builder)); + } + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +nm_ip6_config_init(NMIP6Config *self) +{} + +static void +nm_ip6_config_class_init(NMIP6ConfigClass *klass) +{ + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); + NMIPConfigClass * ip_config_class = NM_IP_CONFIG_CLASS(klass); + + ip_config_class->addr_family = AF_INET6; + + dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED(NM_DBUS_PATH "/IP6Config"); + dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_ip6_config); + + object_class->get_property = get_property_ip6; + + obj_properties_ip6[PROP_IP6_ADDRESSES] = + g_param_spec_variant(NM_IP6_CONFIG_ADDRESSES, + "", + "", + G_VARIANT_TYPE("a(ayuay)"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip6[PROP_IP6_ROUTES] = + g_param_spec_variant(NM_IP6_CONFIG_ROUTES, + "", + "", + G_VARIANT_TYPE("a(ayuayu)"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties_ip6[PROP_IP6_NAMESERVERS] = + g_param_spec_variant(NM_IP6_CONFIG_NAMESERVERS, + "", + "", + G_VARIANT_TYPE("aay"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST_ip6, obj_properties_ip6); +} + +/*****************************************************************************/ + +#define _notify_all(self, changed_params, n_changed_params) \ + G_STMT_START \ + { \ + NMIPConfig *const _self = (self); \ + const guint _n_changed_params = (n_changed_params); \ + GParamSpec *const *const _changed_params = (changed_params); \ + guint _i; \ + \ + if (_n_changed_params > 0) { \ + nm_assert(_n_changed_params <= G_N_ELEMENTS(changed_params)); \ + if (_n_changed_params > 1) \ + g_object_freeze_notify(G_OBJECT(_self)); \ + for (_i = 0; _i < _n_changed_params; _i++) \ + g_object_notify_by_pspec(G_OBJECT(_self), _changed_params[_i]); \ + if (_n_changed_params > 1) \ + g_object_thaw_notify(G_OBJECT(_self)); \ + } \ + } \ + G_STMT_END + +static void +_handle_l3cd_changed(NMIPConfig *self, const NML3ConfigData *l3cd) +{ + const int addr_family = nm_ip_config_get_addr_family(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMIPConfigPrivate * priv = NM_IP_CONFIG_GET_PRIVATE(self); + nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; + GParamSpec * changed_params[8]; + guint n_changed_params = 0; + const char *const * strv; + const char *const * strv_old; + gconstpointer addrs; + gconstpointer addrs_old; + guint len; + guint len_old; + int v_i; + int v_i_old; + + l3cd_old = g_steal_pointer(&priv->l3cd); + priv->l3cd = nm_l3_config_data_ref(l3cd); + + addrs_old = nm_l3_config_data_get_nameservers(l3cd_old, addr_family, &len_old); + addrs = nm_l3_config_data_get_nameservers(priv->l3cd, addr_family, &len); + if (!nm_memeq_n(addrs_old, len_old, addrs, len, nm_utils_addr_family_to_size(addr_family))) { + if (IS_IPv4) { + changed_params[n_changed_params++] = obj_properties_ip4[PROP_IP4_NAMESERVER_DATA]; + changed_params[n_changed_params++] = obj_properties_ip4[PROP_IP4_NAMESERVERS]; + } else + changed_params[n_changed_params++] = obj_properties_ip6[PROP_IP6_NAMESERVERS]; + } + + strv_old = nm_l3_config_data_get_domains(l3cd_old, addr_family, &len_old); + strv = nm_l3_config_data_get_domains(priv->l3cd, addr_family, &len); + if (!nm_strv_equal_n(strv, len, strv_old, len_old)) + changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DOMAINS]; + + strv_old = nm_l3_config_data_get_searches(l3cd_old, addr_family, &len_old); + strv = nm_l3_config_data_get_searches(priv->l3cd, addr_family, &len); + if (!nm_strv_equal_n(strv, len, strv_old, len_old)) + changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_SEARCHES]; + + v_i_old = nm_l3_config_data_get_dns_priority_or_default(l3cd_old, addr_family); + v_i = nm_l3_config_data_get_dns_priority_or_default(priv->l3cd, addr_family); + if (v_i != v_i_old) + changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DNS_PRIORITY]; + + strv_old = nm_l3_config_data_get_dns_options(l3cd_old, addr_family, &len); + strv = nm_l3_config_data_get_dns_options(priv->l3cd, addr_family, &len); + if (!nm_strv_equal_n(strv, len, strv_old, len_old)) + changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DNS_OPTIONS]; + + if (IS_IPv4) { + addrs_old = nm_l3_config_data_get_wins(l3cd_old, &len_old); + addrs = nm_l3_config_data_get_wins(priv->l3cd, &len); + if (!nm_memeq_n(addrs_old, len_old, addrs, len, sizeof(in_addr_t))) { + changed_params[n_changed_params++] = obj_properties_ip4[PROP_IP4_WINS_SERVER_DATA]; + changed_params[n_changed_params++] = obj_properties_ip4[PROP_IP4_WINS_SERVERS]; + } + } + + _notify_all(self, changed_params, n_changed_params); +} + +static void +_handle_platform_change(NMIPConfig *self, guint32 obj_type_flags, gboolean is_init) +{ + const int addr_family = nm_ip_config_get_addr_family(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMIPConfigPrivate * priv = NM_IP_CONFIG_GET_PRIVATE(self); + GParamSpec * changed_params[5]; + guint n_changed_params = 0; + const NMDedupMultiHeadEntry *head_entry_routes = NULL; + gboolean best_default_route_changed = FALSE; + + if (NM_FLAGS_ANY(obj_type_flags, + (nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)) + | nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4))))) { + const NMPObject *best_default_route = NULL; + + head_entry_routes = nm_platform_lookup_object(nm_l3cfg_get_platform(priv->l3cfg), + NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4), + nm_l3cfg_get_ifindex(priv->l3cfg)); + if (head_entry_routes) { + NMDedupMultiIter iter; + const NMPObject *obj; + + nm_dedup_multi_iter_init(&iter, head_entry_routes); + while (nm_platform_dedup_multi_iter_next_obj(&iter, + &obj, + NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4))) { + const NMPlatformIPXRoute *r = NMP_OBJECT_CAST_IPX_ROUTE(obj); + + /* Determine the gateway. That is the next hop of a route + * - 0.0.0.0/0 or ::/0 + * - type=unicast + * - table=main + */ + if (r->rx.plen != 0 + || r->rx.type_coerced != nm_platform_route_type_coerce(RTN_UNICAST) + || r->rx.table_coerced != nm_platform_route_table_coerce(RT_TABLE_MAIN) + || !nm_ip_addr_is_null(addr_family, r->rx.network_ptr)) + continue; + + if (!best_default_route + || NMP_OBJECT_CAST_IP_ROUTE(best_default_route)->metric > r->rx.metric) + best_default_route = obj; + } + } + + if (nmp_object_ref_set(&priv->v_gateway.best_default_route, best_default_route)) { + gconstpointer gateway_next_hop; + + gateway_next_hop = priv->v_gateway.best_default_route + ? nm_platform_ip_route_get_gateway( + addr_family, + NMP_OBJECT_CAST_IP_ROUTE(priv->v_gateway.best_default_route)) + : &nm_ip_addr_zero; + if (!nm_ip_addr_equal(addr_family, &priv->v_gateway.addr, gateway_next_hop)) { + nm_ip_addr_set(addr_family, &priv->v_gateway.addr, gateway_next_hop); + best_default_route_changed = TRUE; + } + } + } + + if (best_default_route_changed + || NM_FLAGS_ANY(obj_type_flags, + nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)))) { + gs_unref_variant GVariant *x_address_data = NULL; + gs_unref_variant GVariant *x_addresses = NULL; + + nm_utils_ip_addresses_to_dbus(addr_family, + nm_platform_lookup_object(nm_l3cfg_get_platform(priv->l3cfg), + NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), + nm_l3cfg_get_ifindex(priv->l3cfg)), + priv->v_gateway.best_default_route, + &x_address_data, + &x_addresses); + + if (!nm_g_variant_equal(priv->v_address_data, x_address_data)) { + changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_ADDRESS_DATA]; + g_variant_ref_sink(x_address_data); + NM_SWAP(&priv->v_address_data, &x_address_data); + } + if (!nm_g_variant_equal(priv->v_addresses, x_addresses)) { + changed_params[n_changed_params++] = IS_IPv4 ? obj_properties_ip4[PROP_IP4_ADDRESSES] + : obj_properties_ip6[PROP_IP6_ADDRESSES]; + g_variant_ref_sink(x_addresses); + NM_SWAP(&priv->v_addresses, &x_addresses); + } + } + + if (best_default_route_changed) + changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_GATEWAY]; + + if (NM_FLAGS_ANY(obj_type_flags, nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)))) { + gs_unref_variant GVariant *x_route_data = NULL; + gs_unref_variant GVariant *x_routes = NULL; + + nm_utils_ip_routes_to_dbus(addr_family, head_entry_routes, &x_route_data, &x_routes); + + if (!nm_g_variant_equal(priv->v_route_data, x_route_data)) { + changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_ROUTE_DATA]; + g_variant_ref_sink(x_route_data); + NM_SWAP(&priv->v_route_data, &x_route_data); + } + if (!nm_g_variant_equal(priv->v_routes, x_routes)) { + changed_params[n_changed_params++] = + IS_IPv4 ? obj_properties_ip4[PROP_IP4_ROUTES] : obj_properties_ip6[PROP_IP6_ROUTES]; + g_variant_ref_sink(x_routes); + NM_SWAP(&priv->v_routes, &x_routes); + } + } + + if (!is_init) + _notify_all(self, changed_params, n_changed_params); } diff --git a/src/core/nm-ip-config.h b/src/core/nm-ip-config.h index 8e1a593412..e3c3b30a96 100644 --- a/src/core/nm-ip-config.h +++ b/src/core/nm-ip-config.h @@ -7,6 +7,7 @@ #define __NM_IP_CONFIG_H__ #include "nm-dbus-object.h" +#include "nm-l3cfg.h" /*****************************************************************************/ @@ -19,26 +20,66 @@ #define NM_IP_CONFIG_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_IP_CONFIG, NMIPConfigClass)) -#define NM_IP_CONFIG_L3CFG "l3cfg" -#define NM_IP_CONFIG_IS_VPN "is-vpn" +#define NM_IP_CONFIG_L3CFG "l3cfg" -struct _NMIPConfigPrivate; +struct _NMIPConfigPrivate { + NML3Cfg * l3cfg; + const NML3ConfigData *l3cd; + GVariant * v_address_data; + GVariant * v_addresses; + GVariant * v_route_data; + GVariant * v_routes; + struct { + const NMPObject *best_default_route; + NMIPAddr addr; + } v_gateway; + gulong l3cfg_notify_id; +}; struct _NMIPConfig { - NMDBusObject parent; - struct _NMIPConfigPrivate *_priv; + NMDBusObject parent; + struct _NMIPConfigPrivate _priv; }; typedef struct { NMDBusObjectClass parent; - gboolean is_ipv4; int addr_family; } NMIPConfigClass; GType nm_ip_config_get_type(void); -GType nm_ip4_config_get_type(void); -GType nm_ip6_config_get_type(void); -NMIPConfig *nm_ip_config_new(int addr_family, NML3Cfg *l3cfg, gboolean is_vpn); +NMIPConfig *nm_ip_config_new(int addr_family, NML3Cfg *l3cfg); + +void nm_ip_config_take_and_unexport_on_idle(NMIPConfig *self_take); + +/*****************************************************************************/ + +static inline NML3Cfg * +nm_ip_config_get_l3cfg(NMIPConfig *self) +{ + g_return_val_if_fail(NM_IS_IP_CONFIG(self), NULL); + + return self->_priv.l3cfg; +} + +static inline struct _NMDedupMultiIndex * +nm_ip_config_get_multi_index(NMIPConfig *self) +{ + return nm_l3cfg_get_multi_idx(nm_ip_config_get_l3cfg(self)); +} + +static inline int +nm_ip_config_get_ifindex(NMIPConfig *self) +{ + return nm_l3cfg_get_ifindex(nm_ip_config_get_l3cfg(self)); +} + +static inline int +nm_ip_config_get_addr_family(NMIPConfig *self) +{ + g_return_val_if_fail(NM_IS_IP_CONFIG(self), AF_UNSPEC); + + return NM_IP_CONFIG_GET_CLASS(self)->addr_family; +} #endif /* __NM_IP_CONFIG_H__ */ diff --git a/src/core/nm-ip4-config.c b/src/core/nm-ip4-config.c deleted file mode 100644 index 90398dcc07..0000000000 --- a/src/core/nm-ip4-config.c +++ /dev/null @@ -1,3337 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2005 - 2017 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include "nm-ip4-config.h" - -#include -#include -#include - -#include "libnm-glib-aux/nm-dedup-multi.h" - -#include "nm-utils.h" -#include "libnm-platform/nmp-object.h" -#include "libnm-platform/nm-platform.h" -#include "libnm-platform/nm-platform-utils.h" -#include "NetworkManagerUtils.h" -#include "libnm-core-intern/nm-core-internal.h" -#include "nm-dbus-object.h" - -/*****************************************************************************/ - -/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */ -G_STATIC_ASSERT(sizeof(uint) >= sizeof(guint32)); -G_STATIC_ASSERT(G_MAXUINT >= 0xFFFFFFFF); - -/*****************************************************************************/ - -static gboolean -_route_valid(const NMPlatformIP4Route *r) -{ - return r && r->plen <= 32 - && r->network == nm_utils_ip4_address_clear_host_address(r->network, r->plen); -} - -/*****************************************************************************/ - -static void -_idx_obj_id_hash_update(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - NMHashState * h) -{ - nmp_object_id_hash_update((NMPObject *) obj, h); -} - -static gboolean -_idx_obj_id_equal(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b) -{ - return nmp_object_id_equal((NMPObject *) obj_a, (NMPObject *) obj_b); -} - -void -nm_ip_config_dedup_multi_idx_type_init(NMIPConfigDedupMultiIdxType *idx_type, - NMPObjectType obj_type) -{ - static const NMDedupMultiIdxTypeClass idx_type_class = { - .idx_obj_id_hash_update = _idx_obj_id_hash_update, - .idx_obj_id_equal = _idx_obj_id_equal, - }; - - nm_dedup_multi_idx_type_init((NMDedupMultiIdxType *) idx_type, &idx_type_class); - idx_type->obj_type = obj_type; -} - -/*****************************************************************************/ - -gboolean -_nm_ip_config_add_obj(NMDedupMultiIndex * multi_idx, - NMIPConfigDedupMultiIdxType *idx_type, - int ifindex, - const NMPObject * obj_new, - const NMPlatformObject * pl_new, - gboolean merge, - gboolean append_force, - const NMPObject ** out_obj_old /* returns a reference! */, - const NMPObject ** out_obj_new /* does not return a reference */) -{ - NMPObject obj_new_stackinit; - const NMDedupMultiEntry *entry_old; - const NMDedupMultiEntry *entry_new; - - nm_assert(multi_idx); - nm_assert(idx_type); - nm_assert(NM_IN_SET(idx_type->obj_type, - NMP_OBJECT_TYPE_IP4_ADDRESS, - NMP_OBJECT_TYPE_IP4_ROUTE, - NMP_OBJECT_TYPE_IP6_ADDRESS, - NMP_OBJECT_TYPE_IP6_ROUTE)); - nm_assert(ifindex > 0); - - /* we go through extra lengths to accept a full obj_new object. That one, - * can be reused by increasing the ref-count. */ - if (!obj_new) { - nm_assert(pl_new); - obj_new = nmp_object_stackinit(&obj_new_stackinit, idx_type->obj_type, pl_new); - NMP_OBJECT_CAST_OBJ_WITH_IFINDEX(&obj_new_stackinit)->ifindex = ifindex; - } else { - nm_assert(!pl_new); - nm_assert(NMP_OBJECT_GET_TYPE(obj_new) == idx_type->obj_type); - if (NMP_OBJECT_CAST_OBJ_WITH_IFINDEX(obj_new)->ifindex != ifindex) { - obj_new = nmp_object_stackinit_obj(&obj_new_stackinit, obj_new); - NMP_OBJECT_CAST_OBJ_WITH_IFINDEX(&obj_new_stackinit)->ifindex = ifindex; - } - } - nm_assert(NMP_OBJECT_GET_TYPE(obj_new) == idx_type->obj_type); - nm_assert(nmp_object_is_alive(obj_new)); - - entry_old = nm_dedup_multi_index_lookup_obj(multi_idx, &idx_type->parent, obj_new); - - if (entry_old) { - gboolean modified = FALSE; - const NMPObject *obj_old = entry_old->obj; - - if (nmp_object_equal(obj_new, obj_old)) { - nm_dedup_multi_entry_set_dirty(entry_old, FALSE); - goto append_force_and_out; - } - - /* if @merge, we merge the new object with the existing one. - * Otherwise, we replace it entirely. */ - if (merge) { - switch (idx_type->obj_type) { - case NMP_OBJECT_TYPE_IP4_ADDRESS: - case NMP_OBJECT_TYPE_IP6_ADDRESS: - /* for addresses that we read from the kernel, we keep the timestamps as defined - * by the previous source (item_old). The reason is, that the other source configured the lifetimes - * with "what should be" and the kernel values are "what turned out after configuring it". - * - * For other sources, the longer lifetime wins. */ - if ((obj_new->ip_address.addr_source == NM_IP_CONFIG_SOURCE_KERNEL - && obj_old->ip_address.addr_source != NM_IP_CONFIG_SOURCE_KERNEL) - || nm_platform_ip_address_cmp_expiry(NMP_OBJECT_CAST_IP_ADDRESS(obj_old), - NMP_OBJECT_CAST_IP_ADDRESS(obj_new)) - > 0) { - obj_new = nmp_object_stackinit_obj(&obj_new_stackinit, obj_new); - obj_new_stackinit.ip_address.timestamp = - NMP_OBJECT_CAST_IP_ADDRESS(obj_old)->timestamp; - obj_new_stackinit.ip_address.lifetime = - NMP_OBJECT_CAST_IP_ADDRESS(obj_old)->lifetime; - obj_new_stackinit.ip_address.preferred = - NMP_OBJECT_CAST_IP_ADDRESS(obj_old)->preferred; - modified = TRUE; - } - - /* keep the maximum addr_source. */ - if (obj_new->ip_address.addr_source < obj_old->ip_address.addr_source) { - obj_new = nmp_object_stackinit_obj(&obj_new_stackinit, obj_new); - obj_new_stackinit.ip_address.addr_source = obj_old->ip_address.addr_source; - modified = TRUE; - } - break; - case NMP_OBJECT_TYPE_IP4_ROUTE: - case NMP_OBJECT_TYPE_IP6_ROUTE: - /* keep the maximum rt_source. */ - if (obj_new->ip_route.rt_source < obj_old->ip_route.rt_source) { - obj_new = nmp_object_stackinit_obj(&obj_new_stackinit, obj_new); - obj_new_stackinit.ip_route.rt_source = obj_old->ip_route.rt_source; - modified = TRUE; - } - if (!obj_new->ip_route.is_external && obj_old->ip_route.is_external) { - obj_new = nmp_object_stackinit_obj(&obj_new_stackinit, obj_new); - obj_new_stackinit.ip_route.is_external = FALSE; - modified = TRUE; - } - break; - default: - nm_assert_not_reached(); - break; - } - - if (modified && nmp_object_equal(obj_new, obj_old)) { - nm_dedup_multi_entry_set_dirty(entry_old, FALSE); - goto append_force_and_out; - } - } - } - - if (!nm_dedup_multi_index_add_full(multi_idx, - &idx_type->parent, - obj_new, - append_force ? NM_DEDUP_MULTI_IDX_MODE_APPEND_FORCE - : NM_DEDUP_MULTI_IDX_MODE_APPEND, - NULL, - entry_old ?: NM_DEDUP_MULTI_ENTRY_MISSING, - NULL, - &entry_new, - out_obj_old)) { - nm_assert_not_reached(); - NM_SET_OUT(out_obj_new, NULL); - return FALSE; - } - - NM_SET_OUT(out_obj_new, entry_new->obj); - return TRUE; - -append_force_and_out: - NM_SET_OUT(out_obj_old, nmp_object_ref(entry_old->obj)); - NM_SET_OUT(out_obj_new, entry_old->obj); - if (append_force) { - if (nm_dedup_multi_entry_reorder(entry_old, NULL, TRUE)) - return TRUE; - } - return FALSE; -} - -/** - * _nm_ip_config_lookup_ip_route: - * @multi_idx: - * @idx_type: - * @needle: - * @cmp_type: after lookup, filter the result by comparing with @cmp_type. Only - * return the result, if it compares equal to @needle according to this @cmp_type. - * Note that the index uses %NM_PLATFORM_IP_ROUTE_CMP_TYPE_DST type, so passing - * that compare-type means not to filter any further. - * - * Returns: the found entry or %NULL. - */ -const NMDedupMultiEntry * -_nm_ip_config_lookup_ip_route(const NMDedupMultiIndex * multi_idx, - const NMIPConfigDedupMultiIdxType *idx_type, - const NMPObject * needle, - NMPlatformIPRouteCmpType cmp_type) -{ - const NMDedupMultiEntry *entry; - - nm_assert(multi_idx); - nm_assert(idx_type); - nm_assert(NM_IN_SET(idx_type->obj_type, NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE)); - nm_assert(NMP_OBJECT_GET_TYPE(needle) == idx_type->obj_type); - - entry = nm_dedup_multi_index_lookup_obj(multi_idx, &idx_type->parent, needle); - if (!entry) - return NULL; - - if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) { - nm_assert((NMP_OBJECT_GET_TYPE(needle) == NMP_OBJECT_TYPE_IP4_ROUTE - && nm_platform_ip4_route_cmp(NMP_OBJECT_CAST_IP4_ROUTE(entry->obj), - NMP_OBJECT_CAST_IP4_ROUTE(needle), - cmp_type) - == 0) - || (NMP_OBJECT_GET_TYPE(needle) == NMP_OBJECT_TYPE_IP6_ROUTE - && nm_platform_ip6_route_cmp(NMP_OBJECT_CAST_IP6_ROUTE(entry->obj), - NMP_OBJECT_CAST_IP6_ROUTE(needle), - cmp_type) - == 0)); - } else { - if (NMP_OBJECT_GET_TYPE(needle) == NMP_OBJECT_TYPE_IP4_ROUTE) { - if (nm_platform_ip4_route_cmp(NMP_OBJECT_CAST_IP4_ROUTE(entry->obj), - NMP_OBJECT_CAST_IP4_ROUTE(needle), - cmp_type) - != 0) - return NULL; - } else { - if (nm_platform_ip6_route_cmp(NMP_OBJECT_CAST_IP6_ROUTE(entry->obj), - NMP_OBJECT_CAST_IP6_ROUTE(needle), - cmp_type) - != 0) - return NULL; - } - } - return entry; -} - -/*****************************************************************************/ - -NM_GOBJECT_PROPERTIES_DEFINE(NMIP4Config, - PROP_MULTI_IDX, - PROP_IFINDEX, - PROP_ADDRESS_DATA, - PROP_ADDRESSES, - PROP_ROUTE_DATA, - PROP_ROUTES, - PROP_GATEWAY, - PROP_NAMESERVER_DATA, - PROP_NAMESERVERS, - PROP_DOMAINS, - PROP_SEARCHES, - PROP_DNS_OPTIONS, - PROP_WINS_SERVER_DATA, - PROP_WINS_SERVERS, - PROP_DNS_PRIORITY, ); - -typedef struct { - bool metered : 1; - bool never_default : 1; - guint32 mtu; - int ifindex; - NMIPConfigSource mtu_source; - int dns_priority; - NMSettingConnectionMdns mdns; - NMSettingConnectionLlmnr llmnr; - NMSettingConnectionDnsOverTls dns_over_tls; - GArray * nameservers; - GPtrArray * domains; - GPtrArray * searches; - GPtrArray * dns_options; - GArray * nis; - char * nis_domain; - GArray * wins; - GVariant * address_data_variant; - GVariant * addresses_variant; - GVariant * route_data_variant; - GVariant * routes_variant; - NMDedupMultiIndex * multi_idx; - const NMPObject * best_default_route; - union { - NMIPConfigDedupMultiIdxType idx_ip4_addresses_; - NMDedupMultiIdxType idx_ip4_addresses; - }; - union { - NMIPConfigDedupMultiIdxType idx_ip4_routes_; - NMDedupMultiIdxType idx_ip4_routes; - }; - NMIPConfigFlags config_flags; -} NMIP4ConfigPrivate; - -struct _NMIP4Config { - NMIPConfig parent; - NMIP4ConfigPrivate _priv; -}; - -struct _NMIP4ConfigClass { - NMIPConfigClass parent; -}; - -G_DEFINE_TYPE(NMIP4Config, nm_ip4_config, NM_TYPE_IP_CONFIG) - -#define NM_IP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP4Config, NM_IS_IP4_CONFIG) - -/*****************************************************************************/ - -static void -_add_address(NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Address *new); -static void _add_route(NMIP4Config * self, - const NMPObject *obj_new, - const NMPlatformIP4Route *new, - const NMPObject **out_obj_new); -static const NMDedupMultiEntry * -_lookup_route(const NMIP4Config *self, const NMPObject *needle, NMPlatformIPRouteCmpType cmp_type); - -/*****************************************************************************/ - -int -nm_ip4_config_get_ifindex(const NMIP4Config *self) -{ - return NM_IP4_CONFIG_GET_PRIVATE(self)->ifindex; -} - -NMDedupMultiIndex * -nm_ip4_config_get_multi_idx(const NMIP4Config *self) -{ - return NM_IP4_CONFIG_GET_PRIVATE(self)->multi_idx; -} - -/*****************************************************************************/ - -const NMDedupMultiHeadEntry * -nm_ip4_config_lookup_addresses(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return nm_dedup_multi_index_lookup_head(priv->multi_idx, &priv->idx_ip4_addresses, NULL); -} - -void -nm_ip_config_iter_ip4_address_init(NMDedupMultiIter *ipconf_iter, const NMIP4Config *self) -{ - nm_assert(NM_IS_IP4_CONFIG(self)); - - nm_dedup_multi_iter_init(ipconf_iter, nm_ip4_config_lookup_addresses(self)); -} - -/*****************************************************************************/ - -const NMDedupMultiHeadEntry * -nm_ip4_config_lookup_routes(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return nm_dedup_multi_index_lookup_head(priv->multi_idx, &priv->idx_ip4_routes, NULL); -} - -void -nm_ip_config_iter_ip4_route_init(NMDedupMultiIter *ipconf_iter, const NMIP4Config *self) -{ - nm_assert(NM_IS_IP4_CONFIG(self)); - - nm_dedup_multi_iter_init(ipconf_iter, nm_ip4_config_lookup_routes(self)); -} - -/*****************************************************************************/ - -const NMPObject * -_nm_ip_config_best_default_route_find_better(const NMPObject *obj_cur, const NMPObject *obj_cmp) -{ - nm_assert(!obj_cur - || NM_IN_SET(NMP_OBJECT_GET_TYPE(obj_cur), - NMP_OBJECT_TYPE_IP4_ROUTE, - NMP_OBJECT_TYPE_IP6_ROUTE)); - nm_assert(!obj_cmp - || (!obj_cur - && NM_IN_SET(NMP_OBJECT_GET_TYPE(obj_cmp), - NMP_OBJECT_TYPE_IP4_ROUTE, - NMP_OBJECT_TYPE_IP6_ROUTE)) - || NMP_OBJECT_GET_TYPE(obj_cur) == NMP_OBJECT_GET_TYPE(obj_cmp)); - nm_assert(!obj_cur || nmp_object_ip_route_is_best_default_route(obj_cur)); - - /* assumes that @obj_cur is already the best default route (or NULL). It checks whether - * @obj_cmp is also a default route and returns the best of both. */ - if (obj_cmp && nmp_object_ip_route_is_best_default_route(obj_cmp)) { - guint32 metric_cur, metric_cmp; - - if (!obj_cur) - return obj_cmp; - - metric_cur = NMP_OBJECT_CAST_IP_ROUTE(obj_cur)->metric; - metric_cmp = NMP_OBJECT_CAST_IP_ROUTE(obj_cmp)->metric; - - if (metric_cmp < metric_cur) - return obj_cmp; - - if (metric_cmp == metric_cur) { - int c; - - /* Routes have the same metric. We still want to deterministically - * prefer one or the other. It's important to consistently choose one - * or the other, so that the order doesn't matter how routes are added - * (and merged). */ - c = nmp_object_cmp(obj_cur, obj_cmp); - if (c != 0) - return c < 0 ? obj_cur : obj_cmp; - - /* as last resort, compare pointers. */ - if (obj_cmp < obj_cur) - return obj_cmp; - } - } - return obj_cur; -} - -gboolean -_nm_ip_config_best_default_route_merge(const NMPObject **best_default_route, - const NMPObject * new_candidate) -{ - new_candidate = - _nm_ip_config_best_default_route_find_better(*best_default_route, new_candidate); - return nmp_object_ref_set(best_default_route, new_candidate); -} - -const NMPObject * -nm_ip4_config_best_default_route_get(const NMIP4Config *self) -{ - g_return_val_if_fail(NM_IS_IP4_CONFIG(self), NULL); - - return NM_IP4_CONFIG_GET_PRIVATE(self)->best_default_route; -} - -const NMPObject * -_nm_ip4_config_best_default_route_find(const NMIP4Config *self) -{ - NMDedupMultiIter ipconf_iter; - const NMPObject *new_best_default_route = NULL; - - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, self, NULL) { - new_best_default_route = - _nm_ip_config_best_default_route_find_better(new_best_default_route, - ipconf_iter.current->obj); - } - return new_best_default_route; -} - -in_addr_t -nmtst_ip4_config_get_gateway(NMIP4Config *config) -{ - const NMPObject *rt; - - g_assert(NM_IS_IP4_CONFIG(config)); - - rt = nm_ip4_config_best_default_route_get(config); - if (!rt) - return 0; - return NMP_OBJECT_CAST_IP4_ROUTE(rt)->gateway; -} - -/*****************************************************************************/ - -static void -_notify_addresses(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - nm_clear_g_variant(&priv->address_data_variant); - nm_clear_g_variant(&priv->addresses_variant); - nm_gobject_notify_together(self, PROP_ADDRESS_DATA, PROP_ADDRESSES); -} - -static void -_notify_routes(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - nm_assert(priv->best_default_route == _nm_ip4_config_best_default_route_find(self)); - nm_clear_g_variant(&priv->route_data_variant); - nm_clear_g_variant(&priv->routes_variant); - nm_gobject_notify_together(self, PROP_ROUTE_DATA, PROP_ROUTES); -} - -/*****************************************************************************/ - -NMIP4Config * -nm_ip4_config_clone(const NMIP4Config *self) -{ - NMIP4Config *copy; - - copy = nm_ip4_config_new(nm_ip4_config_get_multi_idx(self), -1); - nm_ip4_config_replace(copy, self, NULL); - - return copy; -} - -NMIP4Config * -nm_ip4_config_capture(NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex) -{ - NMIP4Config * self; - NMIP4ConfigPrivate * priv; - const NMDedupMultiHeadEntry *head_entry; - NMDedupMultiIter iter; - const NMPObject * plobj = NULL; - - nm_assert(ifindex > 0); - - /* Slaves have no IP configuration */ - if (nm_platform_link_get_master(platform, ifindex) > 0) - return NULL; - - self = nm_ip4_config_new(multi_idx, ifindex); - priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - head_entry = nm_platform_lookup_object(platform, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex); - if (head_entry) { - nmp_cache_iter_for_each (&iter, head_entry, &plobj) { - if (!_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip4_addresses_, - ifindex, - plobj, - NULL, - FALSE, - TRUE, - NULL, - NULL)) - nm_assert_not_reached(); - } - _notify_addresses(self); - } - - head_entry = nm_platform_lookup_object(platform, NMP_OBJECT_TYPE_IP4_ROUTE, ifindex); - - /* Extract gateway from default route */ - nmp_cache_iter_for_each (&iter, head_entry, &plobj) - _add_route(self, plobj, NULL, NULL); - - return self; -} - -void -nm_ip4_config_update_routes_metric(NMIP4Config *self, gint64 metric) -{ - gs_free NMPlatformIP4Route *routes = NULL; - gboolean need_update = FALSE; - const NMPlatformIP4Route * r; - NMDedupMultiIter iter; - guint num = 0, i = 0; - - nm_ip_config_iter_ip4_route_for_each (&iter, self, &r) { - if (r->metric != metric) - need_update = TRUE; - num++; - } - if (!need_update) - return; - - routes = g_new(NMPlatformIP4Route, num); - nm_ip_config_iter_ip4_route_for_each (&iter, self, &r) { - routes[i] = *r; - routes[i].metric = metric; - i++; - } - - g_object_freeze_notify(G_OBJECT(self)); - nm_ip4_config_reset_routes(self); - for (i = 0; i < num; i++) - nm_ip4_config_add_route(self, &routes[i], NULL); - g_object_thaw_notify(G_OBJECT(self)); -} - -void -nm_ip4_config_add_dependent_routes(NMIP4Config *self, - guint32 route_table, - guint32 route_metric, - gboolean is_vrf, - GPtrArray ** out_ip4_dev_route_blacklist) -{ - GPtrArray * ip4_dev_route_blacklist = NULL; - const NMPlatformIP4Address *my_addr; - const NMPlatformIP4Route * my_route; - int ifindex; - NMDedupMultiIter iter; - - g_return_if_fail(NM_IS_IP4_CONFIG(self)); - - ifindex = nm_ip4_config_get_ifindex(self); - g_return_if_fail(ifindex > 0); - - /* For IPv6 slaac, we explicitly add the device-routes (onlink) to NMIP6Config. - * As we don't do that for IPv4 (and manual IPv6 addresses), add them explicitly. */ - - nm_ip_config_iter_ip4_address_for_each (&iter, self, &my_addr) { - nm_auto_nmpobj NMPObject *r = NULL; - NMPlatformIP4Route * route; - in_addr_t network; - - if (my_addr->plen == 0) - continue; - - nm_assert(my_addr->plen <= 32); - - /* The destination network depends on the peer-address. */ - network = nm_utils_ip4_address_clear_host_address(my_addr->peer_address, my_addr->plen); - - if (my_addr->external) - continue; - - if (nm_utils_ip4_address_is_zeronet(network)) { - /* Kernel doesn't add device-routes for destinations that - * start with 0.x.y.z. Skip them. */ - continue; - } - - if (my_addr->plen == 32 && my_addr->address == my_addr->peer_address) { - /* Kernel doesn't add device-routes for /32 addresses unless - * they have a peer. */ - continue; - } - - r = nmp_object_new(NMP_OBJECT_TYPE_IP4_ROUTE, NULL); - route = NMP_OBJECT_CAST_IP4_ROUTE(r); - - route->ifindex = ifindex; - route->rt_source = NM_IP_CONFIG_SOURCE_KERNEL; - route->network = network; - route->plen = my_addr->plen; - route->pref_src = my_addr->address; - route->table_coerced = nm_platform_route_table_coerce(route_table); - route->metric = route_metric; - route->scope_inv = nm_platform_route_scope_inv(NM_RT_SCOPE_LINK); - - nm_platform_ip_route_normalize(AF_INET, (NMPlatformIPRoute *) route); - - if (_lookup_route(self, r, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID)) { - /* we already track this route. Don't add it again. */ - } else - _add_route(self, r, NULL, NULL); - - if (out_ip4_dev_route_blacklist - && (route_table != RT_TABLE_MAIN - || route_metric != NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE)) { - nm_auto_nmpobj NMPObject *r_dev = NULL; - - r_dev = nmp_object_clone(r, FALSE); - route = NMP_OBJECT_CAST_IP4_ROUTE(r_dev); - route->table_coerced = nm_platform_route_table_coerce(RT_TABLE_MAIN); - route->metric = NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE; - - nm_platform_ip_route_normalize(AF_INET, (NMPlatformIPRoute *) route); - - if (_lookup_route(self, r_dev, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID)) { - /* we track such a route explicitly. Don't blacklist it. */ - } else { - if (!ip4_dev_route_blacklist) - ip4_dev_route_blacklist = - g_ptr_array_new_with_free_func((GDestroyNotify) nmp_object_unref); - - g_ptr_array_add(ip4_dev_route_blacklist, g_steal_pointer(&r_dev)); - } - } - } - -again: - nm_ip_config_iter_ip4_route_for_each (&iter, self, &my_route) { - NMPlatformIP4Route rt; - - if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(my_route) || my_route->gateway == 0 - || NM_IS_IP_CONFIG_SOURCE_RTPROT(my_route->rt_source) - || nm_ip4_config_get_direct_route_for_host( - self, - my_route->gateway, - nm_platform_route_table_uncoerce(my_route->table_coerced, TRUE))) - continue; - - rt = *my_route; - rt.network = my_route->gateway; - rt.plen = 32; - rt.gateway = 0; - _add_route(self, NULL, &rt, NULL); - /* adding the route might have invalidated the iteration. Start again. */ - goto again; - } - - NM_SET_OUT(out_ip4_dev_route_blacklist, ip4_dev_route_blacklist); -} - -gboolean -nm_ip4_config_commit(const NMIP4Config * self, - NMPlatform * platform, - NMIPRouteTableSyncMode route_table_sync) -{ - gs_unref_ptrarray GPtrArray *addresses = NULL; - gs_unref_ptrarray GPtrArray *routes = NULL; - gs_unref_ptrarray GPtrArray *routes_prune = NULL; - int ifindex; - gboolean success = TRUE; - - g_return_val_if_fail(NM_IS_IP4_CONFIG(self), FALSE); - - ifindex = nm_ip4_config_get_ifindex(self); - g_return_val_if_fail(ifindex > 0, FALSE); - - addresses = - nm_dedup_multi_objs_to_ptr_array_head(nm_ip4_config_lookup_addresses(self), NULL, NULL); - - routes = nm_dedup_multi_objs_to_ptr_array_head(nm_ip4_config_lookup_routes(self), NULL, NULL); - - routes_prune = - nm_platform_ip_route_get_prune_list(platform, AF_INET, ifindex, route_table_sync); - - nm_platform_ip4_address_sync(platform, ifindex, addresses); - - if (!nm_platform_ip_route_sync(platform, AF_INET, ifindex, routes, routes_prune, NULL)) - success = FALSE; - - return success; -} - -void -nm_ip4_config_merge_setting(NMIP4Config * self, - NMSettingIPConfig * setting, - NMSettingConnectionMdns mdns, - NMSettingConnectionLlmnr llmnr, - NMSettingConnectionDnsOverTls dns_over_tls, - guint32 route_table, - guint32 route_metric) -{ - guint naddresses, nroutes, nnameservers, nsearches; - int i, priority; - const char *gateway_str; - guint32 gateway_bin; - - if (!setting) - return; - - g_return_if_fail(NM_IS_SETTING_IP4_CONFIG(setting)); - - g_object_freeze_notify(G_OBJECT(self)); - - naddresses = nm_setting_ip_config_get_num_addresses(setting); - nroutes = nm_setting_ip_config_get_num_routes(setting); - nnameservers = nm_setting_ip_config_get_num_dns(setting); - nsearches = nm_setting_ip_config_get_num_dns_searches(setting); - - /* Gateway */ - if (!nm_setting_ip_config_get_never_default(setting) - && (gateway_str = nm_setting_ip_config_get_gateway(setting)) - && inet_pton(AF_INET, gateway_str, &gateway_bin) == 1 && gateway_bin) { - const NMPlatformIP4Route r = { - .rt_source = NM_IP_CONFIG_SOURCE_USER, - .gateway = gateway_bin, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, - }; - - _add_route(self, NULL, &r, NULL); - } - - /* Addresses */ - for (i = 0; i < naddresses; i++) { - NMIPAddress * s_addr = nm_setting_ip_config_get_address(setting, i); - GVariant * label; - NMPlatformIP4Address address; - - memset(&address, 0, sizeof(address)); - nm_ip_address_get_address_binary(s_addr, &address.address); - address.peer_address = address.address; - address.plen = nm_ip_address_get_prefix(s_addr); - nm_assert(address.plen <= 32); - address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT; - address.preferred = NM_PLATFORM_LIFETIME_PERMANENT; - address.addr_source = NM_IP_CONFIG_SOURCE_USER; - - label = nm_ip_address_get_attribute(s_addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); - if (label) - g_strlcpy(address.label, g_variant_get_string(label, NULL), sizeof(address.label)); - - _add_address(self, NULL, &address); - } - - /* Routes */ - for (i = 0; i < nroutes; i++) { - NMIPRoute * s_route = nm_setting_ip_config_get_route(setting, i); - NMPlatformIP4Route route; - gint64 m; - - if (nm_ip_route_get_family(s_route) != AF_INET) { - nm_assert_not_reached(); - continue; - } - - memset(&route, 0, sizeof(route)); - nm_ip_route_get_dest_binary(s_route, &route.network); - - route.plen = nm_ip_route_get_prefix(s_route); - nm_assert(route.plen <= 32); - - nm_ip_route_get_next_hop_binary(s_route, &route.gateway); - m = nm_ip_route_get_metric(s_route); - if (m < 0) - route.metric = route_metric; - else - route.metric = m; - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - - route.network = nm_utils_ip4_address_clear_host_address(route.network, route.plen); - - nm_utils_ip_route_attribute_to_platform(AF_INET, - s_route, - NM_PLATFORM_IP_ROUTE_CAST(&route), - route_table); - _add_route(self, NULL, &route, NULL); - } - - /* DNS */ - if (nm_setting_ip_config_get_ignore_auto_dns(setting)) { - nm_ip4_config_reset_nameservers(self); - nm_ip4_config_reset_domains(self); - nm_ip4_config_reset_searches(self); - } - for (i = 0; i < nnameservers; i++) { - guint32 ip; - - if (inet_pton(AF_INET, nm_setting_ip_config_get_dns(setting, i), &ip) == 1) - nm_ip4_config_add_nameserver(self, ip); - } - for (i = 0; i < nsearches; i++) - nm_ip4_config_add_search(self, nm_setting_ip_config_get_dns_search(setting, i)); - - i = 0; - while ((i = nm_setting_ip_config_next_valid_dns_option(setting, i)) >= 0) { - nm_ip4_config_add_dns_option(self, nm_setting_ip_config_get_dns_option(setting, i)); - i++; - } - - priority = nm_setting_ip_config_get_dns_priority(setting); - if (priority) - nm_ip4_config_set_dns_priority(self, priority); - - nm_ip4_config_mdns_set(self, mdns); - nm_ip4_config_llmnr_set(self, llmnr); - nm_ip4_config_dns_over_tls_set(self, dns_over_tls); - - nm_ip4_config_set_never_default(self, nm_setting_ip_config_get_never_default(setting)); - - g_object_thaw_notify(G_OBJECT(self)); -} - -NMSetting * -nm_ip4_config_create_setting(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate * priv; - NMSettingIPConfig * s_ip4; - guint nnameservers, nsearches, noptions; - const char * method = NULL; - int i; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP4Address *address; - const NMPlatformIP4Route * route; - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - - s_ip4 = NM_SETTING_IP_CONFIG(nm_setting_ip4_config_new()); - - if (!self) { - g_object_set(s_ip4, - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP4_CONFIG_METHOD_DISABLED, - NULL); - return NM_SETTING(s_ip4); - } - - priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - nnameservers = nm_ip4_config_get_num_nameservers(self); - nsearches = nm_ip4_config_get_num_searches(self); - noptions = nm_ip4_config_get_num_dns_options(self); - - /* Addresses */ - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, self, &address) { - NMIPAddress *s_addr; - - /* Detect dynamic address */ - if (address->lifetime != NM_PLATFORM_LIFETIME_PERMANENT) { - method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; - continue; - } - - /* Static address found. */ - if (!method) - method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; - - s_addr = nm_ip_address_new_binary(AF_INET, &address->address, address->plen, NULL); - if (*address->label) - nm_ip_address_set_attribute(s_addr, - NM_IP_ADDRESS_ATTRIBUTE_LABEL, - g_variant_new_string(address->label)); - - nm_setting_ip_config_add_address(s_ip4, s_addr); - nm_ip_address_unref(s_addr); - } - - /* Gateway */ - if (priv->best_default_route && nm_setting_ip_config_get_num_addresses(s_ip4) > 0) { - g_object_set( - s_ip4, - NM_SETTING_IP_CONFIG_GATEWAY, - _nm_utils_inet4_ntop(NMP_OBJECT_CAST_IP4_ROUTE(priv->best_default_route)->gateway, - sbuf), - NULL); - } - - /* Use 'disabled' if the method wasn't previously set */ - if (!method) - method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; - - g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, method, NULL); - - /* Routes */ - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, self, &route) { - NMIPRoute *s_route; - - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route)) - continue; - - /* Ignore routes provided by external sources */ - if (route->rt_source - != nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER)) - continue; - - s_route = nm_ip_route_new_binary(AF_INET, - &route->network, - route->plen, - &route->gateway, - route->metric, - NULL); - nm_setting_ip_config_add_route(s_ip4, s_route); - nm_ip_route_unref(s_route); - } - - /* DNS */ - for (i = 0; i < nnameservers; i++) { - guint32 nameserver = nm_ip4_config_get_nameserver(self, i); - - nm_setting_ip_config_add_dns(s_ip4, _nm_utils_inet4_ntop(nameserver, sbuf)); - } - for (i = 0; i < nsearches; i++) { - const char *search = nm_ip4_config_get_search(self, i); - - nm_setting_ip_config_add_dns_search(s_ip4, search); - } - - for (i = 0; i < noptions; i++) { - const char *option = nm_ip4_config_get_dns_option(self, i); - - nm_setting_ip_config_add_dns_option(s_ip4, option); - } - - g_object_set(s_ip4, - NM_SETTING_IP_CONFIG_DNS_PRIORITY, - nm_ip4_config_get_dns_priority(self), - NULL); - - return NM_SETTING(s_ip4); -} - -/*****************************************************************************/ - -void -nm_ip4_config_merge(NMIP4Config * dst, - const NMIP4Config * src, - NMIPConfigMergeFlags merge_flags, - guint32 default_route_metric_penalty) -{ - NMIP4ConfigPrivate * dst_priv; - const NMIP4ConfigPrivate * src_priv; - guint32 i; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP4Address *address = NULL; - - g_return_if_fail(src != NULL); - g_return_if_fail(dst != NULL); - - dst_priv = NM_IP4_CONFIG_GET_PRIVATE(dst); - src_priv = NM_IP4_CONFIG_GET_PRIVATE(src); - - g_object_freeze_notify(G_OBJECT(dst)); - - /* addresses */ - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, src, &address) { - if (NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_EXTERNAL) && !address->external) { - NMPlatformIP4Address a; - - a = *address; - a.external = TRUE; - _add_address(dst, NULL, &a); - } else - _add_address(dst, NMP_OBJECT_UP_CAST(address), NULL); - } - - /* nameservers */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip4_config_get_num_nameservers(src); i++) - nm_ip4_config_add_nameserver(dst, nm_ip4_config_get_nameserver(src, i)); - } - - /* routes */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_ROUTES)) { - const NMPlatformIP4Route *r_src; - - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, src, &r_src) { - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(r_src)) { - if (NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES) - && !NM_FLAGS_HAS(src_priv->config_flags, - NM_IP_CONFIG_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES)) - continue; - if (default_route_metric_penalty) { - NMPlatformIP4Route r = *r_src; - - r.metric = - nm_utils_ip_route_metric_penalize(r.metric, default_route_metric_penalty); - _add_route(dst, NULL, &r, NULL); - continue; - } - } - _add_route(dst, ipconf_iter.current->obj, NULL, NULL); - } - } - - /* domains */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip4_config_get_num_domains(src); i++) - nm_ip4_config_add_domain(dst, nm_ip4_config_get_domain(src, i)); - } - - /* dns searches */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip4_config_get_num_searches(src); i++) - nm_ip4_config_add_search(dst, nm_ip4_config_get_search(src, i)); - } - - /* dns options */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip4_config_get_num_dns_options(src); i++) - nm_ip4_config_add_dns_option(dst, nm_ip4_config_get_dns_option(src, i)); - } - - /* MTU */ - if (src_priv->mtu_source > dst_priv->mtu_source - || (src_priv->mtu_source == dst_priv->mtu_source - && ((!dst_priv->mtu && src_priv->mtu) - || (dst_priv->mtu && src_priv->mtu < dst_priv->mtu)))) - nm_ip4_config_set_mtu(dst, src_priv->mtu, src_priv->mtu_source); - - /* NIS */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip4_config_get_num_nis_servers(src); i++) - nm_ip4_config_add_nis_server(dst, nm_ip4_config_get_nis_server(src, i)); - - if (nm_ip4_config_get_nis_domain(src)) - nm_ip4_config_set_nis_domain(dst, nm_ip4_config_get_nis_domain(src)); - } - - /* WINS */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip4_config_get_num_wins(src); i++) - nm_ip4_config_add_wins(dst, nm_ip4_config_get_wins(src, i)); - } - - /* metered flag */ - nm_ip4_config_set_metered(dst, - nm_ip4_config_get_metered(dst) || nm_ip4_config_get_metered(src)); - - /* never default */ - nm_ip4_config_set_never_default(dst, - nm_ip4_config_get_never_default(dst) - || nm_ip4_config_get_never_default(src)); - - /* DNS priority */ - if (nm_ip4_config_get_dns_priority(src)) - nm_ip4_config_set_dns_priority(dst, nm_ip4_config_get_dns_priority(src)); - - /* mdns */ - nm_ip4_config_mdns_set(dst, NM_MAX(nm_ip4_config_mdns_get(src), nm_ip4_config_mdns_get(dst))); - /* LLMNR */ - nm_ip4_config_llmnr_set(dst, - NM_MAX(nm_ip4_config_llmnr_get(src), nm_ip4_config_llmnr_get(dst))); - /* dns_over_tls */ - nm_ip4_config_dns_over_tls_set( - dst, - NM_MAX(nm_ip4_config_dns_over_tls_get(src), nm_ip4_config_dns_over_tls_get(dst))); - - g_object_thaw_notify(G_OBJECT(dst)); -} - -/*****************************************************************************/ - -static int -_nameservers_get_index(const NMIP4Config *self, guint32 ns) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->nameservers->len; i++) { - guint32 n = g_array_index(priv->nameservers, guint32, i); - - if (ns == n) - return (int) i; - } - return -1; -} - -static int -_domains_get_index(const NMIP4Config *self, const char *domain) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->domains->len; i++) { - const char *d = g_ptr_array_index(priv->domains, i); - - if (g_strcmp0(domain, d) == 0) - return (int) i; - } - return -1; -} - -static int -_searches_get_index(const NMIP4Config *self, const char *search) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->searches->len; i++) { - const char *s = g_ptr_array_index(priv->searches, i); - - if (g_strcmp0(search, s) == 0) - return (int) i; - } - return -1; -} - -static int -_dns_options_get_index(const NMIP4Config *self, const char *option) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->dns_options->len; i++) { - const char *s = g_ptr_array_index(priv->dns_options, i); - - if (g_strcmp0(option, s) == 0) - return (int) i; - } - return -1; -} - -static int -_nis_servers_get_index(const NMIP4Config *self, guint32 nis_server) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->nis->len; i++) { - guint32 n = g_array_index(priv->nis, guint32, i); - - if (n == nis_server) - return (int) i; - } - return -1; -} - -static int -_wins_get_index(const NMIP4Config *self, guint32 wins_server) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->wins->len; i++) { - guint32 n = g_array_index(priv->wins, guint32, i); - - if (n == wins_server) - return (int) i; - } - return -1; -} - -/*****************************************************************************/ - -/** - * nm_ip4_config_subtract: - * @dst: config from which to remove everything in @src - * @src: config to remove from @dst - * @default_route_metric_penalty: pretend that on source we applied - * a route penalty on the default-route. It means, for default routes - * we don't remove routes that match exactly, but those with a lower - * metric (with the penalty removed). - * - * Removes everything in @src from @dst. - */ -void -nm_ip4_config_subtract(NMIP4Config * dst, - const NMIP4Config *src, - guint32 default_route_metric_penalty) -{ - NMIP4ConfigPrivate * dst_priv; - guint i; - int idx; - const NMPlatformIP4Address *a; - const NMPlatformIP4Route * r; - NMDedupMultiIter ipconf_iter; - gboolean changed; - gboolean changed_default_route; - - g_return_if_fail(src != NULL); - g_return_if_fail(dst != NULL); - - dst_priv = NM_IP4_CONFIG_GET_PRIVATE(dst); - - g_object_freeze_notify(G_OBJECT(dst)); - - /* addresses */ - changed = FALSE; - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, src, &a) { - if (nm_dedup_multi_index_remove_obj(dst_priv->multi_idx, - &dst_priv->idx_ip4_addresses, - NMP_OBJECT_UP_CAST(a), - NULL)) - changed = TRUE; - } - if (changed) - _notify_addresses(dst); - - /* nameservers */ - for (i = 0; i < nm_ip4_config_get_num_nameservers(src); i++) { - idx = _nameservers_get_index(dst, nm_ip4_config_get_nameserver(src, i)); - if (idx >= 0) - nm_ip4_config_del_nameserver(dst, idx); - } - - /* routes */ - changed = FALSE; - changed_default_route = FALSE; - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, src, &r) { - const NMPObject * o_src = NMP_OBJECT_UP_CAST(r); - NMPObject o_lookup_copy; - const NMPObject * o_lookup; - nm_auto_nmpobj const NMPObject *obj_old = NULL; - - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(r) && default_route_metric_penalty) { - NMPlatformIP4Route *rr; - - /* the default route was penalized when merging it to the combined ip-config. - * When subtracting the routes, we must re-do that process when comparing - * the routes. */ - o_lookup = nmp_object_stackinit_obj(&o_lookup_copy, o_src); - rr = NMP_OBJECT_CAST_IP4_ROUTE(&o_lookup_copy); - rr->metric = - nm_utils_ip_route_metric_penalize(rr->metric, default_route_metric_penalty); - } else - o_lookup = o_src; - - if (nm_dedup_multi_index_remove_obj(dst_priv->multi_idx, - &dst_priv->idx_ip4_routes, - o_lookup, - (gconstpointer *) &obj_old)) { - if (dst_priv->best_default_route == obj_old) { - nm_clear_nmp_object(&dst_priv->best_default_route); - changed_default_route = TRUE; - } - changed = TRUE; - } - } - if (changed_default_route) { - nmp_object_ref_set(&dst_priv->best_default_route, - _nm_ip4_config_best_default_route_find(dst)); - _notify(dst, PROP_GATEWAY); - } - if (changed) - _notify_routes(dst); - - /* domains */ - for (i = 0; i < nm_ip4_config_get_num_domains(src); i++) { - idx = _domains_get_index(dst, nm_ip4_config_get_domain(src, i)); - if (idx >= 0) - nm_ip4_config_del_domain(dst, idx); - } - - /* dns searches */ - for (i = 0; i < nm_ip4_config_get_num_searches(src); i++) { - idx = _searches_get_index(dst, nm_ip4_config_get_search(src, i)); - if (idx >= 0) - nm_ip4_config_del_search(dst, idx); - } - - /* dns options */ - for (i = 0; i < nm_ip4_config_get_num_dns_options(src); i++) { - idx = _dns_options_get_index(dst, nm_ip4_config_get_dns_option(src, i)); - if (idx >= 0) - nm_ip4_config_del_dns_option(dst, idx); - } - - /* MTU */ - if (nm_ip4_config_get_mtu(src) == nm_ip4_config_get_mtu(dst) - && nm_ip4_config_get_mtu_source(src) == nm_ip4_config_get_mtu_source(dst)) - nm_ip4_config_set_mtu(dst, 0, NM_IP_CONFIG_SOURCE_UNKNOWN); - - /* NIS */ - for (i = 0; i < nm_ip4_config_get_num_nis_servers(src); i++) { - idx = _nis_servers_get_index(dst, nm_ip4_config_get_nis_server(src, i)); - if (idx >= 0) - nm_ip4_config_del_nis_server(dst, idx); - } - - if (g_strcmp0(nm_ip4_config_get_nis_domain(src), nm_ip4_config_get_nis_domain(dst)) == 0) - nm_ip4_config_set_nis_domain(dst, NULL); - - /* WINS */ - for (i = 0; i < nm_ip4_config_get_num_wins(src); i++) { - idx = _wins_get_index(dst, nm_ip4_config_get_wins(src, i)); - if (idx >= 0) - nm_ip4_config_del_wins(dst, idx); - } - - /* DNS priority */ - if (nm_ip4_config_get_dns_priority(src) == nm_ip4_config_get_dns_priority(dst)) - nm_ip4_config_set_dns_priority(dst, 0); - - /* mdns */ - if (nm_ip4_config_mdns_get(src) == nm_ip4_config_mdns_get(dst)) - nm_ip4_config_mdns_set(dst, NM_SETTING_CONNECTION_MDNS_DEFAULT); - - /* LLMNR */ - if (nm_ip4_config_llmnr_get(src) == nm_ip4_config_llmnr_get(dst)) - nm_ip4_config_llmnr_set(dst, NM_SETTING_CONNECTION_LLMNR_DEFAULT); - - /* dns_over_tls */ - if (nm_ip4_config_dns_over_tls_get(src) == nm_ip4_config_dns_over_tls_get(dst)) - nm_ip4_config_dns_over_tls_set(dst, NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT); - - g_object_thaw_notify(G_OBJECT(dst)); -} - -static gboolean -_nm_ip4_config_intersect_helper(NMIP4Config * dst, - const NMIP4Config *src, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty, - gboolean update_dst) -{ - NMIP4ConfigPrivate * dst_priv; - const NMIP4ConfigPrivate * src_priv; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP4Address *a; - const NMPlatformIP4Route * r; - const NMPObject * new_best_default_route; - gboolean changed, result = FALSE; - - g_return_val_if_fail(src, FALSE); - g_return_val_if_fail(dst, FALSE); - - dst_priv = NM_IP4_CONFIG_GET_PRIVATE(dst); - src_priv = NM_IP4_CONFIG_GET_PRIVATE(src); - - if (update_dst) - g_object_freeze_notify(G_OBJECT(dst)); - - /* addresses */ - if (intersect_addresses) { - changed = FALSE; - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, dst, &a) { - if (nm_dedup_multi_index_lookup_obj(src_priv->multi_idx, - &src_priv->idx_ip4_addresses, - NMP_OBJECT_UP_CAST(a))) - continue; - - if (!update_dst) - return TRUE; - - if (nm_dedup_multi_index_remove_entry(dst_priv->multi_idx, ipconf_iter.current) != 1) - nm_assert_not_reached(); - changed = TRUE; - } - if (changed) { - _notify_addresses(dst); - result = TRUE; - } - } - - /* ignore nameservers */ - - /* routes */ - if (!intersect_routes) - goto skip_routes; - - changed = FALSE; - new_best_default_route = NULL; - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, dst, &r) { - const NMPObject *o_dst = NMP_OBJECT_UP_CAST(r); - const NMPObject *o_lookup; - NMPObject o_lookup_copy; - - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(r) && default_route_metric_penalty) { - NMPlatformIP4Route *rr; - - /* the default route was penalized when merging it to the combined ip-config. - * When intersecting the routes, we must re-do that process when comparing - * the routes. */ - o_lookup = nmp_object_stackinit_obj(&o_lookup_copy, o_dst); - rr = NMP_OBJECT_CAST_IP4_ROUTE(&o_lookup_copy); - rr->metric = - nm_utils_ip_route_metric_penalize(rr->metric, default_route_metric_penalty); - } else - o_lookup = o_dst; - - if (nm_dedup_multi_index_lookup_obj(src_priv->multi_idx, - &src_priv->idx_ip4_routes, - o_lookup)) { - new_best_default_route = - _nm_ip_config_best_default_route_find_better(new_best_default_route, o_dst); - continue; - } - - if (!update_dst) - return TRUE; - - if (nm_dedup_multi_index_remove_entry(dst_priv->multi_idx, ipconf_iter.current) != 1) - nm_assert_not_reached(); - changed = TRUE; - } - if (nmp_object_ref_set(&dst_priv->best_default_route, new_best_default_route)) { - nm_assert(changed); - _notify(dst, PROP_GATEWAY); - } - - if (changed) { - _notify_routes(dst); - result = TRUE; - } - -skip_routes: - /* ignore domains */ - /* ignore dns searches */ - /* ignore dns options */ - /* ignore NIS */ - /* ignore WINS */ - /* ignore mdns */ - /* ignore LLMNR */ - /* ignore dns_over_tls */ - - if (update_dst) - g_object_thaw_notify(G_OBJECT(dst)); - return result; -} - -/** - * nm_ip4_config_intersect: - * @dst: a configuration to be updated - * @src: another configuration - * @intersect_addresses: whether addresses should be intersected - * @intersect_routes: whether routes should be intersected - * @default_route_metric_penalty: the default route metric penalty - * - * Computes the intersection between @src and @dst and updates @dst in place - * with the result. - */ -void -nm_ip4_config_intersect(NMIP4Config * dst, - const NMIP4Config *src, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty) -{ - _nm_ip4_config_intersect_helper(dst, - src, - intersect_addresses, - intersect_routes, - default_route_metric_penalty, - TRUE); -} - -/** - * nm_ip4_config_intersect_alloc: - * @a: a configuration - * @b: another configuration - * @intersect_addresses: whether addresses should be intersected - * @intersect_routes: whether routes should be intersected - * @default_route_metric_penalty: the default route metric penalty - * - * Computes the intersection between @a and @b and returns the result in a newly - * allocated configuration. As a special case, if @a and @b are identical (with - * respect to the only properties considered - addresses and routes) the - * functions returns NULL so that one of existing configuration can be reused - * without allocation. - * - * Returns: the intersection between @a and @b, or %NULL if the result is equal - * to @a and @b. - */ -NMIP4Config * -nm_ip4_config_intersect_alloc(const NMIP4Config *a, - const NMIP4Config *b, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty) -{ - NMIP4Config *a_copy; - - if (_nm_ip4_config_intersect_helper((NMIP4Config *) a, - b, - intersect_addresses, - intersect_routes, - default_route_metric_penalty, - FALSE)) { - a_copy = nm_ip4_config_clone(a); - _nm_ip4_config_intersect_helper(a_copy, - b, - intersect_addresses, - intersect_routes, - default_route_metric_penalty, - TRUE); - return a_copy; - } else - return NULL; -} - -/** - * nm_ip4_config_replace: - * @dst: config to replace with @src content - * @src: source config to copy - * @relevant_changes: return whether there are changes to the - * destination object that are relevant. This is equal to - * nm_ip4_config_equal() showing any difference. - * - * Replaces everything in @dst with @src so that the two configurations - * contain the same content -- with the exception of the dbus path. - * - * Returns: whether the @dst instance changed in any way (including minor changes, - * that are not signaled by the output parameter @relevant_changes). - */ -gboolean -nm_ip4_config_replace(NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes) -{ -#if NM_MORE_ASSERTS - gboolean config_equal; -#endif - gboolean has_minor_changes = FALSE, has_relevant_changes = FALSE, are_equal; - guint i, num; - NMIP4ConfigPrivate * dst_priv; - const NMIP4ConfigPrivate * src_priv; - NMDedupMultiIter ipconf_iter_src, ipconf_iter_dst; - const NMDedupMultiHeadEntry *head_entry_src; - const NMPObject * new_best_default_route; - - g_return_val_if_fail(src != NULL, FALSE); - g_return_val_if_fail(dst != NULL, FALSE); - g_return_val_if_fail(src != dst, FALSE); - -#if NM_MORE_ASSERTS - config_equal = nm_ip4_config_equal(dst, src); -#endif - - dst_priv = NM_IP4_CONFIG_GET_PRIVATE(dst); - src_priv = NM_IP4_CONFIG_GET_PRIVATE(src); - - g_object_freeze_notify(G_OBJECT(dst)); - - /* ifindex */ - if (src_priv->ifindex != dst_priv->ifindex) { - dst_priv->ifindex = src_priv->ifindex; - has_minor_changes = TRUE; - } - - /* addresses */ - head_entry_src = nm_ip4_config_lookup_addresses(src); - nm_dedup_multi_iter_init(&ipconf_iter_src, head_entry_src); - nm_ip_config_iter_ip4_address_init(&ipconf_iter_dst, dst); - are_equal = TRUE; - while (TRUE) { - gboolean has; - const NMPlatformIP4Address *r_src = NULL; - const NMPlatformIP4Address *r_dst = NULL; - - has = nm_platform_dedup_multi_iter_next_ip4_address(&ipconf_iter_src, &r_src); - if (has != nm_platform_dedup_multi_iter_next_ip4_address(&ipconf_iter_dst, &r_dst)) { - are_equal = FALSE; - has_relevant_changes = TRUE; - break; - } - if (!has) - break; - - if (nm_platform_ip4_address_cmp(r_src, r_dst) != 0) { - are_equal = FALSE; - if (r_src->address != r_dst->address || r_src->plen != r_dst->plen - || r_src->peer_address != r_dst->peer_address) { - has_relevant_changes = TRUE; - break; - } - } - } - if (!are_equal) { - has_minor_changes = TRUE; - nm_dedup_multi_index_dirty_set_idx(dst_priv->multi_idx, &dst_priv->idx_ip4_addresses); - nm_dedup_multi_iter_for_each (&ipconf_iter_src, head_entry_src) { - _nm_ip_config_add_obj(dst_priv->multi_idx, - &dst_priv->idx_ip4_addresses_, - dst_priv->ifindex, - ipconf_iter_src.current->obj, - NULL, - FALSE, - TRUE, - NULL, - NULL); - } - nm_dedup_multi_index_dirty_remove_idx(dst_priv->multi_idx, - &dst_priv->idx_ip4_addresses, - FALSE); - _notify_addresses(dst); - } - - /* routes */ - head_entry_src = nm_ip4_config_lookup_routes(src); - nm_dedup_multi_iter_init(&ipconf_iter_src, head_entry_src); - nm_ip_config_iter_ip4_route_init(&ipconf_iter_dst, dst); - are_equal = TRUE; - while (TRUE) { - gboolean has; - const NMPlatformIP4Route *r_src = NULL; - const NMPlatformIP4Route *r_dst = NULL; - - has = nm_platform_dedup_multi_iter_next_ip4_route(&ipconf_iter_src, &r_src); - if (has != nm_platform_dedup_multi_iter_next_ip4_route(&ipconf_iter_dst, &r_dst)) { - are_equal = FALSE; - has_relevant_changes = TRUE; - break; - } - if (!has) - break; - - if (nm_platform_ip4_route_cmp_full(r_src, r_dst) != 0) { - are_equal = FALSE; - if (r_src->plen != r_dst->plen - || !nm_utils_ip4_address_same_prefix(r_src->network, r_dst->network, r_src->plen) - || r_src->gateway != r_dst->gateway || r_src->metric != r_dst->metric) { - has_relevant_changes = TRUE; - break; - } - } - } - if (!are_equal) { - has_minor_changes = TRUE; - new_best_default_route = NULL; - nm_dedup_multi_index_dirty_set_idx(dst_priv->multi_idx, &dst_priv->idx_ip4_routes); - nm_dedup_multi_iter_for_each (&ipconf_iter_src, head_entry_src) { - const NMPObject *o = ipconf_iter_src.current->obj; - const NMPObject *obj_new; - - _nm_ip_config_add_obj(dst_priv->multi_idx, - &dst_priv->idx_ip4_routes_, - dst_priv->ifindex, - o, - NULL, - FALSE, - TRUE, - NULL, - &obj_new); - new_best_default_route = - _nm_ip_config_best_default_route_find_better(new_best_default_route, obj_new); - } - nm_dedup_multi_index_dirty_remove_idx(dst_priv->multi_idx, - &dst_priv->idx_ip4_routes, - FALSE); - if (nmp_object_ref_set(&dst_priv->best_default_route, new_best_default_route)) - _notify(dst, PROP_GATEWAY); - _notify_routes(dst); - } - - /* nameservers */ - num = nm_ip4_config_get_num_nameservers(src); - are_equal = num == nm_ip4_config_get_num_nameservers(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (nm_ip4_config_get_nameserver(src, i) != nm_ip4_config_get_nameserver(dst, i)) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip4_config_reset_nameservers(dst); - for (i = 0; i < num; i++) - nm_ip4_config_add_nameserver(dst, nm_ip4_config_get_nameserver(src, i)); - has_relevant_changes = TRUE; - } - - /* domains */ - num = nm_ip4_config_get_num_domains(src); - are_equal = num == nm_ip4_config_get_num_domains(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (g_strcmp0(nm_ip4_config_get_domain(src, i), nm_ip4_config_get_domain(dst, i))) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip4_config_reset_domains(dst); - for (i = 0; i < num; i++) - nm_ip4_config_add_domain(dst, nm_ip4_config_get_domain(src, i)); - has_relevant_changes = TRUE; - } - - /* dns searches */ - num = nm_ip4_config_get_num_searches(src); - are_equal = num == nm_ip4_config_get_num_searches(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (g_strcmp0(nm_ip4_config_get_search(src, i), nm_ip4_config_get_search(dst, i))) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip4_config_reset_searches(dst); - for (i = 0; i < num; i++) - nm_ip4_config_add_search(dst, nm_ip4_config_get_search(src, i)); - has_relevant_changes = TRUE; - } - - /* dns options */ - num = nm_ip4_config_get_num_dns_options(src); - are_equal = num == nm_ip4_config_get_num_dns_options(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (g_strcmp0(nm_ip4_config_get_dns_option(src, i), - nm_ip4_config_get_dns_option(dst, i))) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip4_config_reset_dns_options(dst); - for (i = 0; i < num; i++) - nm_ip4_config_add_dns_option(dst, nm_ip4_config_get_dns_option(src, i)); - has_relevant_changes = TRUE; - } - - if (src_priv->mdns != dst_priv->mdns) { - dst_priv->mdns = src_priv->mdns; - has_relevant_changes = TRUE; - } - - if (src_priv->llmnr != dst_priv->llmnr) { - dst_priv->llmnr = src_priv->llmnr; - has_relevant_changes = TRUE; - } - - if (src_priv->dns_over_tls != dst_priv->dns_over_tls) { - dst_priv->dns_over_tls = src_priv->dns_over_tls; - has_relevant_changes = TRUE; - } - - /* DNS priority */ - if (src_priv->dns_priority != dst_priv->dns_priority) { - nm_ip4_config_set_dns_priority(dst, src_priv->dns_priority); - has_minor_changes = TRUE; - } - - /* nis */ - num = nm_ip4_config_get_num_nis_servers(src); - are_equal = num == nm_ip4_config_get_num_nis_servers(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (nm_ip4_config_get_nis_server(src, i) != nm_ip4_config_get_nis_server(dst, i)) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip4_config_reset_nis_servers(dst); - for (i = 0; i < num; i++) - nm_ip4_config_add_nis_server(dst, nm_ip4_config_get_nis_server(src, i)); - has_relevant_changes = TRUE; - } - - /* nis_domain */ - if (g_strcmp0(src_priv->nis_domain, dst_priv->nis_domain)) { - nm_ip4_config_set_nis_domain(dst, src_priv->nis_domain); - has_relevant_changes = TRUE; - } - - /* wins */ - num = nm_ip4_config_get_num_wins(src); - are_equal = num == nm_ip4_config_get_num_wins(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (nm_ip4_config_get_wins(src, i) != nm_ip4_config_get_wins(dst, i)) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip4_config_reset_wins(dst); - for (i = 0; i < num; i++) - nm_ip4_config_add_wins(dst, nm_ip4_config_get_wins(src, i)); - has_relevant_changes = TRUE; - } - - /* mtu */ - if (src_priv->mtu != dst_priv->mtu || src_priv->mtu_source != dst_priv->mtu_source) { - nm_ip4_config_set_mtu(dst, src_priv->mtu, src_priv->mtu_source); - has_minor_changes = TRUE; - } - - /* metered */ - if (src_priv->metered != dst_priv->metered) { - dst_priv->metered = src_priv->metered; - has_minor_changes = TRUE; - } - - /* never default */ - if (src_priv->never_default != dst_priv->never_default) { - dst_priv->never_default = src_priv->never_default; - has_minor_changes = TRUE; - } - -#if NM_MORE_ASSERTS - /* config_equal does not compare *all* the fields, therefore, we might have has_minor_changes - * regardless of config_equal. But config_equal must correspond to has_relevant_changes. */ - nm_assert(config_equal == !has_relevant_changes); -#endif - - g_object_thaw_notify(G_OBJECT(dst)); - - if (relevant_changes) - *relevant_changes = has_relevant_changes; - - return has_relevant_changes || has_minor_changes; -} - -void -nm_ip_config_dump(const NMIPConfig *self, const char *detail, NMLogLevel level, NMLogDomain domain) -{ - NMDedupMultiIter ipconf_iter; - const NMPlatformIP4Address *addr4; - const NMPlatformIP6Address *addr6; - const NMPlatformIP4Route * route4; - const NMPlatformIP6Route * route6; - const NMIP4Config * ip4; - const NMIP6Config * ip6; - int addr_family = AF_UNSPEC; - char addr_family_char = '?'; - const char * path; - gconstpointer ptr; - guint i; - - if (self) { - addr_family = nm_ip_config_get_addr_family(self); - addr_family_char = nm_utils_addr_family_to_char(addr_family); - } - - nm_log(level, domain, NULL, NULL, "---- NMIP%cConfig %p (%s)", addr_family_char, self, detail); - - if (!self) - return; - - path = nm_dbus_object_get_path(NM_DBUS_OBJECT(self)); - if (path) - nm_log(level, domain, NULL, NULL, " path : %s", path); - - if (addr_family == AF_INET) { - ip4 = NM_IP4_CONFIG(self); - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, ip4, &addr4) { - nm_log(level, - domain, - NULL, - NULL, - " address : %s", - nm_platform_ip4_address_to_string(addr4, NULL, 0)); - } - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, ip4, &route4) { - nm_log(level, - domain, - NULL, - NULL, - " route : %s", - nm_platform_ip4_route_to_string(route4, NULL, 0)); - } - } else { - ip6 = NM_IP6_CONFIG(self); - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, ip6, &addr6) { - nm_log(level, - domain, - NULL, - NULL, - " address : %s", - nm_platform_ip6_address_to_string(addr6, NULL, 0)); - } - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, ip6, &route6) { - nm_log(level, - domain, - NULL, - NULL, - " route : %s", - nm_platform_ip6_route_to_string(route6, NULL, 0)); - } - } - - for (i = 0; i < nm_ip_config_get_num_nameservers(self); i++) { - char buf[NM_UTILS_INET_ADDRSTRLEN]; - - ptr = nm_ip_config_get_nameserver(self, i); - nm_log(level, - domain, - NULL, - NULL, - " dns : %s", - nm_utils_inet_ntop(addr_family, ptr, buf)); - } - - for (i = 0; i < nm_ip_config_get_num_domains(self); i++) - nm_log(level, domain, NULL, NULL, " domain : %s", nm_ip_config_get_domain(self, i)); - - for (i = 0; i < nm_ip_config_get_num_searches(self); i++) - nm_log(level, domain, NULL, NULL, " search : %s", nm_ip_config_get_search(self, i)); - - for (i = 0; i < nm_ip_config_get_num_dns_options(self); i++) - nm_log(level, domain, NULL, NULL, "dns-option: %s", nm_ip_config_get_dns_option(self, i)); - - nm_log(level, domain, NULL, NULL, " dns-prio : %d", nm_ip_config_get_dns_priority(self)); - - if (addr_family == AF_INET) { - ip4 = NM_IP4_CONFIG(self); - nm_log(level, - domain, - NULL, - NULL, - " mtu : %" G_GUINT32_FORMAT " (source: %d)", - nm_ip4_config_get_mtu(ip4), - (int) nm_ip4_config_get_mtu_source(ip4)); - nm_log(level, domain, NULL, NULL, " metered : %d", (int) nm_ip4_config_get_metered(ip4)); - } -} - -/*****************************************************************************/ - -gconstpointer -nm_ip_config_find_first_address(const NMIPConfig *self, NMPlatformMatchFlags match_flag) -{ - NMDedupMultiIter iter; - const NMPlatformIPAddress *address; - - g_return_val_if_fail(NM_IS_IP_CONFIG(self), NULL); - - nm_assert(!NM_FLAGS_ANY( - match_flag, - ~(NM_PLATFORM_MATCH_WITH_ADDRTYPE__ANY | NM_PLATFORM_MATCH_WITH_ADDRSTATE__ANY))); - - nm_ip_config_iter_ip_address_for_each (&iter, self, &address) { - if (nm_platform_ip_address_match(nm_ip_config_get_addr_family(self), address, match_flag)) - return address; - } - - return NULL; -} - -void -nm_ip4_config_reset_addresses(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (nm_dedup_multi_index_remove_idx(priv->multi_idx, &priv->idx_ip4_addresses) > 0) - _notify_addresses(self); -} - -static void -_add_address(NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Address *new) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip4_addresses_, - priv->ifindex, - obj_new, - (const NMPlatformObject *) new, - TRUE, - FALSE, - NULL, - NULL)) - _notify_addresses(self); -} - -/** - * nm_ip4_config_add_address: - * @self: the #NMIP4Config - * @new: the new address to add to @self - * - * Adds the new address to @self. If an address with the same basic properties - * (address, prefix) already exists in @self, it is overwritten with the - * lifetime and preferred of @new. The source is also overwritten by the source - * from @new if that source is higher priority. - */ -void -nm_ip4_config_add_address(NMIP4Config *self, const NMPlatformIP4Address *new) -{ - g_return_if_fail(self); - g_return_if_fail(new); - g_return_if_fail(new->plen <= 32); - g_return_if_fail(NM_IP4_CONFIG_GET_PRIVATE(self)->ifindex > 0); - - _add_address(self, NULL, new); -} - -void -_nmtst_ip4_config_del_address(NMIP4Config *self, guint i) -{ - const NMPlatformIP4Address *a; - - a = _nmtst_ip4_config_get_address(self, i); - if (!nm_ip4_config_nmpobj_remove(self, NMP_OBJECT_UP_CAST(a))) - g_assert_not_reached(); -} - -guint -nm_ip4_config_get_num_addresses(const NMIP4Config *self) -{ - const NMDedupMultiHeadEntry *head_entry; - - head_entry = nm_ip4_config_lookup_addresses(self); - return head_entry ? head_entry->len : 0; -} - -const NMPlatformIP4Address * -nm_ip4_config_get_first_address(const NMIP4Config *self) -{ - NMDedupMultiIter iter; - const NMPlatformIP4Address *a = NULL; - - nm_ip_config_iter_ip4_address_for_each (&iter, self, &a) - return a; - return NULL; -} - -const NMPlatformIP4Address * -_nmtst_ip4_config_get_address(const NMIP4Config *self, guint i) -{ - NMDedupMultiIter iter = {}; - const NMPlatformIP4Address *a = NULL; - guint j; - - j = 0; - nm_ip_config_iter_ip4_address_for_each (&iter, self, &a) { - if (i == j) - return a; - j++; - } - g_return_val_if_reached(NULL); -} - -gboolean -nm_ip4_config_address_exists(const NMIP4Config *self, const NMPlatformIP4Address *needle) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - NMPObject obj_stack; - - nmp_object_stackinit_id_ip4_address(&obj_stack, - priv->ifindex, - needle->address, - needle->plen, - needle->peer_address); - return !!nm_dedup_multi_index_lookup_obj(priv->multi_idx, &priv->idx_ip4_addresses, &obj_stack); -} - -/*****************************************************************************/ - -static const NMDedupMultiEntry * -_lookup_route(const NMIP4Config *self, const NMPObject *needle, NMPlatformIPRouteCmpType cmp_type) -{ - const NMIP4ConfigPrivate *priv; - - nm_assert(NM_IS_IP4_CONFIG(self)); - nm_assert(NMP_OBJECT_GET_TYPE(needle) == NMP_OBJECT_TYPE_IP4_ROUTE); - - priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return _nm_ip_config_lookup_ip_route(priv->multi_idx, &priv->idx_ip4_routes_, needle, cmp_type); -} - -void -nm_ip4_config_reset_routes(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (nm_dedup_multi_index_remove_idx(priv->multi_idx, &priv->idx_ip4_routes) > 0) { - if (nm_clear_nmp_object(&priv->best_default_route)) - _notify(self, PROP_GATEWAY); - _notify_routes(self); - } -} - -static void -_add_route(NMIP4Config * self, - const NMPObject *obj_new, - const NMPlatformIP4Route *new, - const NMPObject **out_obj_new) -{ - NMIP4ConfigPrivate * priv = NM_IP4_CONFIG_GET_PRIVATE(self); - nm_auto_nmpobj const NMPObject *obj_old = NULL; - const NMPObject * obj_new_2; - - nm_assert((!new) != (!obj_new)); - nm_assert(!new || _route_valid(new)); - nm_assert(!obj_new || _route_valid(NMP_OBJECT_CAST_IP4_ROUTE(obj_new))); - - if (_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip4_routes_, - priv->ifindex, - obj_new, - (const NMPlatformObject *) new, - TRUE, - FALSE, - &obj_old, - &obj_new_2)) { - gboolean changed_default_route = FALSE; - - if (priv->best_default_route == obj_old && obj_old != obj_new_2) { - changed_default_route = TRUE; - nm_clear_nmp_object(&priv->best_default_route); - } - NM_SET_OUT(out_obj_new, nmp_object_ref(obj_new_2)); - if (_nm_ip_config_best_default_route_merge(&priv->best_default_route, obj_new_2)) - changed_default_route = TRUE; - - if (changed_default_route) - _notify(self, PROP_GATEWAY); - _notify_routes(self); - } else - NM_SET_OUT(out_obj_new, nmp_object_ref(obj_new_2)); -} - -/** - * nm_ip4_config_add_route: - * @self: the #NMIP4Config - * @new: the new route to add to @self - * @out_obj_new: (allow-none) (out): the added route object. Must be unrefed - * by caller. - * - * Adds the new route to @self. If a route with the same basic properties - * (network, prefix) already exists in @self, it is overwritten including the - * gateway and metric of @new. The source is also overwritten by the source - * from @new if that source is higher priority. - */ -void -nm_ip4_config_add_route(NMIP4Config *self, - const NMPlatformIP4Route *new, - const NMPObject **out_obj_new) -{ - g_return_if_fail(self); - g_return_if_fail(new); - g_return_if_fail(new->plen <= 32); - g_return_if_fail(NM_IP4_CONFIG_GET_PRIVATE(self)->ifindex > 0); - - _add_route(self, NULL, new, out_obj_new); -} - -void -_nmtst_ip4_config_del_route(NMIP4Config *self, guint i) -{ - const NMPlatformIP4Route *r; - - r = _nmtst_ip4_config_get_route(self, i); - if (!nm_ip4_config_nmpobj_remove(self, NMP_OBJECT_UP_CAST(r))) - g_assert_not_reached(); -} - -guint -nm_ip4_config_get_num_routes(const NMIP4Config *self) -{ - const NMDedupMultiHeadEntry *head_entry; - - head_entry = nm_ip4_config_lookup_routes(self); - nm_assert(!head_entry || head_entry->len == c_list_length(&head_entry->lst_entries_head)); - return head_entry ? head_entry->len : 0; -} - -const NMPlatformIP4Route * -_nmtst_ip4_config_get_route(const NMIP4Config *self, guint i) -{ - NMDedupMultiIter iter; - const NMPlatformIP4Route *r = NULL; - guint j; - - j = 0; - nm_ip_config_iter_ip4_route_for_each (&iter, self, &r) { - if (i == j) - return r; - j++; - } - g_return_val_if_reached(NULL); -} - -const NMPlatformIP4Route * -nm_ip4_config_get_direct_route_for_host(const NMIP4Config *self, - in_addr_t host, - guint32 route_table) -{ - const NMPlatformIP4Route *best_route = NULL; - const NMPlatformIP4Route *item; - NMDedupMultiIter ipconf_iter; - - g_return_val_if_fail(host, NULL); - - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, self, &item) { - if (item->gateway != 0) - continue; - - if (best_route && best_route->plen > item->plen) - continue; - - if (nm_platform_route_table_uncoerce(item->table_coerced, TRUE) != route_table) - continue; - - if (nm_utils_ip4_address_clear_host_address(host, item->plen) - != nm_utils_ip4_address_clear_host_address(item->network, item->plen)) - continue; - - if (best_route && best_route->metric <= item->metric) - continue; - - best_route = item; - } - return best_route; -} - -/*****************************************************************************/ - -void -nm_ip4_config_reset_nameservers(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (priv->nameservers->len != 0) { - g_array_set_size(priv->nameservers, 0); - nm_gobject_notify_together(self, PROP_NAMESERVER_DATA, PROP_NAMESERVERS); - } -} - -void -nm_ip4_config_add_nameserver(NMIP4Config *self, guint32 new) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - int i; - - g_return_if_fail(new != 0); - - for (i = 0; i < priv->nameservers->len; i++) - if (new == g_array_index(priv->nameservers, guint32, i)) - return; - - g_array_append_val(priv->nameservers, new); - nm_gobject_notify_together(self, PROP_NAMESERVER_DATA, PROP_NAMESERVERS); -} - -void -nm_ip4_config_del_nameserver(NMIP4Config *self, guint i) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->nameservers->len); - - g_array_remove_index(priv->nameservers, i); - nm_gobject_notify_together(self, PROP_NAMESERVER_DATA, PROP_NAMESERVERS); -} - -guint -nm_ip4_config_get_num_nameservers(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->nameservers->len; -} - -guint32 -nm_ip4_config_get_nameserver(const NMIP4Config *self, guint i) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return g_array_index(priv->nameservers, guint32, i); -} - -const in_addr_t * -_nm_ip4_config_get_nameserver(const NMIP4Config *self, guint i) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return &g_array_index(priv->nameservers, guint32, i); -} - -/*****************************************************************************/ - -gboolean -_nm_ip_config_check_and_add_domain(GPtrArray *array, const char *domain) -{ - char * copy = NULL; - size_t len; - - g_return_val_if_fail(domain, FALSE); - g_return_val_if_fail(domain[0] != '\0', FALSE); - - if (domain[0] == '.' || strstr(domain, "..")) - return FALSE; - - len = strlen(domain); - if (domain[len - 1] == '.') - domain = copy = g_strndup(domain, len - 1); - - if (nm_strv_ptrarray_find_first(array, domain) >= 0) { - g_free(copy); - return FALSE; - } - - g_ptr_array_add(array, copy ?: g_strdup(domain)); - return TRUE; -} - -void -nm_ip4_config_reset_domains(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (priv->domains->len != 0) { - g_ptr_array_set_size(priv->domains, 0); - _notify(self, PROP_DOMAINS); - } -} - -void -nm_ip4_config_add_domain(NMIP4Config *self, const char *domain) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (_nm_ip_config_check_and_add_domain(priv->domains, domain)) - _notify(self, PROP_DOMAINS); -} - -void -nm_ip4_config_del_domain(NMIP4Config *self, guint i) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->domains->len); - - g_ptr_array_remove_index(priv->domains, i); - _notify(self, PROP_DOMAINS); -} - -guint -nm_ip4_config_get_num_domains(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->domains->len; -} - -const char * -nm_ip4_config_get_domain(const NMIP4Config *self, guint i) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return g_ptr_array_index(priv->domains, i); -} - -/*****************************************************************************/ - -void -nm_ip4_config_reset_searches(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (priv->searches->len != 0) { - g_ptr_array_set_size(priv->searches, 0); - _notify(self, PROP_SEARCHES); - } -} - -void -nm_ip4_config_add_search(NMIP4Config *self, const char *search) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (_nm_ip_config_check_and_add_domain(priv->searches, search)) - _notify(self, PROP_SEARCHES); -} - -void -nm_ip4_config_del_search(NMIP4Config *self, guint i) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->searches->len); - - g_ptr_array_remove_index(priv->searches, i); - _notify(self, PROP_SEARCHES); -} - -guint -nm_ip4_config_get_num_searches(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->searches->len; -} - -const char * -nm_ip4_config_get_search(const NMIP4Config *self, guint i) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return g_ptr_array_index(priv->searches, i); -} - -/*****************************************************************************/ - -void -nm_ip4_config_reset_dns_options(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (priv->dns_options->len != 0) { - g_ptr_array_set_size(priv->dns_options, 0); - _notify(self, PROP_DNS_OPTIONS); - } -} - -void -nm_ip4_config_add_dns_option(NMIP4Config *self, const char *new) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - int i; - - g_return_if_fail(new != NULL); - g_return_if_fail(new[0] != '\0'); - - for (i = 0; i < priv->dns_options->len; i++) - if (!g_strcmp0(g_ptr_array_index(priv->dns_options, i), new)) - return; - - g_ptr_array_add(priv->dns_options, g_strdup(new)); - _notify(self, PROP_DNS_OPTIONS); -} - -void -nm_ip4_config_del_dns_option(NMIP4Config *self, guint i) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->dns_options->len); - - g_ptr_array_remove_index(priv->dns_options, i); - _notify(self, PROP_DNS_OPTIONS); -} - -guint -nm_ip4_config_get_num_dns_options(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->dns_options->len; -} - -const char * -nm_ip4_config_get_dns_option(const NMIP4Config *self, guint i) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return g_ptr_array_index(priv->dns_options, i); -} - -/*****************************************************************************/ - -NMSettingConnectionMdns -nm_ip4_config_mdns_get(const NMIP4Config *self) -{ - return NM_IP4_CONFIG_GET_PRIVATE(self)->mdns; -} - -void -nm_ip4_config_mdns_set(NMIP4Config *self, NMSettingConnectionMdns mdns) -{ - NM_IP4_CONFIG_GET_PRIVATE(self)->mdns = mdns; -} - -NMSettingConnectionLlmnr -nm_ip4_config_llmnr_get(const NMIP4Config *self) -{ - return NM_IP4_CONFIG_GET_PRIVATE(self)->llmnr; -} - -void -nm_ip4_config_llmnr_set(NMIP4Config *self, NMSettingConnectionLlmnr llmnr) -{ - NM_IP4_CONFIG_GET_PRIVATE(self)->llmnr = llmnr; -} - -NMSettingConnectionDnsOverTls -nm_ip4_config_dns_over_tls_get(const NMIP4Config *self) -{ - return NM_IP4_CONFIG_GET_PRIVATE(self)->dns_over_tls; -} - -void -nm_ip4_config_dns_over_tls_set(NMIP4Config *self, NMSettingConnectionDnsOverTls dns_over_tls) -{ - NM_IP4_CONFIG_GET_PRIVATE(self)->dns_over_tls = dns_over_tls; -} - -/*****************************************************************************/ - -NMIPConfigFlags -nm_ip4_config_get_config_flags(const NMIP4Config *self) -{ - return NM_IP4_CONFIG_GET_PRIVATE(self)->config_flags; -} - -void -nm_ip4_config_set_config_flags(NMIP4Config *self, NMIPConfigFlags flags, NMIPConfigFlags mask) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (mask == 0) { - /* for convenience, accept 0 mask to set any flags. */ - mask = flags; - } - - nm_assert(!NM_FLAGS_ANY(flags, ~mask)); - priv->config_flags = (flags & mask) | (priv->config_flags & ~mask); -} - -/*****************************************************************************/ - -void -nm_ip4_config_set_dns_priority(NMIP4Config *self, int priority) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (priority != priv->dns_priority) { - priv->dns_priority = priority; - _notify(self, PROP_DNS_PRIORITY); - } -} - -int -nm_ip4_config_get_dns_priority(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->dns_priority; -} - -/*****************************************************************************/ - -void -nm_ip4_config_reset_nis_servers(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - g_array_set_size(priv->nis, 0); -} - -void -nm_ip4_config_add_nis_server(NMIP4Config *self, guint32 nis) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - int i; - - for (i = 0; i < priv->nis->len; i++) - if (nis == g_array_index(priv->nis, guint32, i)) - return; - - g_array_append_val(priv->nis, nis); -} - -void -nm_ip4_config_del_nis_server(NMIP4Config *self, guint i) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->nis->len); - - g_array_remove_index(priv->nis, i); -} - -guint -nm_ip4_config_get_num_nis_servers(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->nis->len; -} - -guint32 -nm_ip4_config_get_nis_server(const NMIP4Config *self, guint i) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return g_array_index(priv->nis, guint32, i); -} - -void -nm_ip4_config_set_nis_domain(NMIP4Config *self, const char *domain) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - g_free(priv->nis_domain); - priv->nis_domain = g_strdup(domain); -} - -const char * -nm_ip4_config_get_nis_domain(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->nis_domain; -} - -/*****************************************************************************/ - -void -nm_ip4_config_reset_wins(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (priv->wins->len != 0) { - g_array_set_size(priv->wins, 0); - nm_gobject_notify_together(self, PROP_WINS_SERVER_DATA, PROP_WINS_SERVERS); - } -} - -void -nm_ip4_config_add_wins(NMIP4Config *self, guint32 wins) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - int i; - - g_return_if_fail(wins != 0); - - for (i = 0; i < priv->wins->len; i++) - if (wins == g_array_index(priv->wins, guint32, i)) - return; - - g_array_append_val(priv->wins, wins); - nm_gobject_notify_together(self, PROP_WINS_SERVER_DATA, PROP_WINS_SERVERS); -} - -void -nm_ip4_config_del_wins(NMIP4Config *self, guint i) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->wins->len); - - g_array_remove_index(priv->wins, i); - nm_gobject_notify_together(self, PROP_WINS_SERVER_DATA, PROP_WINS_SERVERS); -} - -guint -nm_ip4_config_get_num_wins(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->wins->len; -} - -guint32 -nm_ip4_config_get_wins(const NMIP4Config *self, guint i) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return g_array_index(priv->wins, guint32, i); -} - -/*****************************************************************************/ - -void -nm_ip4_config_set_mtu(NMIP4Config *self, guint32 mtu, NMIPConfigSource source) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - if (!mtu) - source = NM_IP_CONFIG_SOURCE_UNKNOWN; - - priv->mtu = mtu; - priv->mtu_source = source; -} - -guint32 -nm_ip4_config_get_mtu(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->mtu; -} - -NMIPConfigSource -nm_ip4_config_get_mtu_source(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->mtu_source; -} - -/*****************************************************************************/ - -void -nm_ip4_config_set_metered(NMIP4Config *self, gboolean metered) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - priv->metered = metered; -} - -gboolean -nm_ip4_config_get_metered(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->metered; -} - -/*****************************************************************************/ - -void -nm_ip4_config_set_never_default(NMIP4Config *self, gboolean never_default) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - priv->never_default = never_default; -} - -gboolean -nm_ip4_config_get_never_default(const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - return priv->never_default; -} - -/*****************************************************************************/ - -const NMPObject * -nm_ip4_config_nmpobj_lookup(const NMIP4Config *self, const NMPObject *needle) -{ - const NMIP4ConfigPrivate * priv; - const NMDedupMultiIdxType *idx_type; - - g_return_val_if_fail(NM_IS_IP4_CONFIG(self), NULL); - - priv = NM_IP4_CONFIG_GET_PRIVATE(self); - switch (NMP_OBJECT_GET_TYPE(needle)) { - case NMP_OBJECT_TYPE_IP4_ADDRESS: - idx_type = &priv->idx_ip4_addresses; - break; - case NMP_OBJECT_TYPE_IP4_ROUTE: - idx_type = &priv->idx_ip4_routes; - break; - default: - g_return_val_if_reached(NULL); - } - - return nm_dedup_multi_entry_get_obj( - nm_dedup_multi_index_lookup_obj(priv->multi_idx, idx_type, needle)); -} - -gboolean -nm_ip4_config_nmpobj_remove(NMIP4Config *self, const NMPObject *needle) -{ - NMIP4ConfigPrivate * priv; - NMDedupMultiIdxType *idx_type; - nm_auto_nmpobj const NMPObject *obj_old = NULL; - guint n; - - g_return_val_if_fail(NM_IS_IP4_CONFIG(self), FALSE); - - priv = NM_IP4_CONFIG_GET_PRIVATE(self); - switch (NMP_OBJECT_GET_TYPE(needle)) { - case NMP_OBJECT_TYPE_IP4_ADDRESS: - idx_type = &priv->idx_ip4_addresses; - break; - case NMP_OBJECT_TYPE_IP4_ROUTE: - idx_type = &priv->idx_ip4_routes; - break; - default: - g_return_val_if_reached(FALSE); - } - - n = nm_dedup_multi_index_remove_obj(priv->multi_idx, - idx_type, - needle, - (gconstpointer *) &obj_old); - if (n != 1) { - nm_assert(n == 0); - return FALSE; - } - - nm_assert(NMP_OBJECT_GET_TYPE(obj_old) == NMP_OBJECT_GET_TYPE(needle)); - - switch (NMP_OBJECT_GET_TYPE(obj_old)) { - case NMP_OBJECT_TYPE_IP4_ADDRESS: - _notify_addresses(self); - break; - case NMP_OBJECT_TYPE_IP4_ROUTE: - if (priv->best_default_route == obj_old) { - if (nmp_object_ref_set(&priv->best_default_route, - _nm_ip4_config_best_default_route_find(self))) - _notify(self, PROP_GATEWAY); - } - _notify_routes(self); - break; - default: - nm_assert_not_reached(); - } - return TRUE; -} - -/*****************************************************************************/ - -static void -hash_u32(GChecksum *sum, guint32 n) -{ - g_checksum_update(sum, (const guint8 *) &n, sizeof(n)); -} - -void -nm_ip4_config_hash(const NMIP4Config *self, GChecksum *sum, gboolean dns_only) -{ - guint i; - const char * s; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP4Address *address; - const NMPlatformIP4Route * route; - int val; - - g_return_if_fail(self); - g_return_if_fail(sum); - - if (!dns_only) { - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, self, &address) { - hash_u32(sum, address->address); - hash_u32(sum, address->plen); - hash_u32(sum, address->peer_address & _nm_utils_ip4_prefix_to_netmask(address->plen)); - } - - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, self, &route) { - hash_u32(sum, route->network); - hash_u32(sum, route->plen); - hash_u32(sum, route->gateway); - hash_u32(sum, route->metric); - } - - for (i = 0; i < nm_ip4_config_get_num_nis_servers(self); i++) - hash_u32(sum, nm_ip4_config_get_nis_server(self, i)); - - s = nm_ip4_config_get_nis_domain(self); - if (s) - g_checksum_update(sum, (const guint8 *) s, strlen(s)); - } - - for (i = 0; i < nm_ip4_config_get_num_nameservers(self); i++) - hash_u32(sum, nm_ip4_config_get_nameserver(self, i)); - - for (i = 0; i < nm_ip4_config_get_num_wins(self); i++) - hash_u32(sum, nm_ip4_config_get_wins(self, i)); - - for (i = 0; i < nm_ip4_config_get_num_domains(self); i++) { - s = nm_ip4_config_get_domain(self, i); - g_checksum_update(sum, (const guint8 *) s, strlen(s)); - } - - for (i = 0; i < nm_ip4_config_get_num_searches(self); i++) { - s = nm_ip4_config_get_search(self, i); - g_checksum_update(sum, (const guint8 *) s, strlen(s)); - } - - for (i = 0; i < nm_ip4_config_get_num_dns_options(self); i++) { - s = nm_ip4_config_get_dns_option(self, i); - g_checksum_update(sum, (const guint8 *) s, strlen(s)); - } - - val = nm_ip4_config_mdns_get(self); - if (val != NM_SETTING_CONNECTION_MDNS_DEFAULT) - g_checksum_update(sum, (const guint8 *) &val, sizeof(val)); - - val = nm_ip4_config_llmnr_get(self); - if (val != NM_SETTING_CONNECTION_LLMNR_DEFAULT) - g_checksum_update(sum, (const guint8 *) &val, sizeof(val)); - - val = nm_ip4_config_dns_over_tls_get(self); - if (val != NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT) - g_checksum_update(sum, (const guint8 *) &val, sizeof(val)); - - /* FIXME(ip-config-checksum): the DNS priority should be considered relevant - * and added into the checksum as well, but this can't be done right now - * because in the DNS manager we rely on the fact that an empty - * configuration (i.e. just created) has a zero checksum. This is needed to - * avoid rewriting resolv.conf when there is no change. - * - * The DNS priority initial value depends on the connection type (VPN or - * not), so it's a bit difficult to add it to checksum maintaining the - * assumption of checksum(empty)=0 - */ -} - -/** - * nm_ip4_config_equal: - * @a: first config to compare - * @b: second config to compare - * - * Compares two #NMIP4Configs for basic equality. This means that all - * attributes must exist in the same order in both configs (addresses, routes, - * domains, DNS servers, etc) but some attributes (address lifetimes, and address - * and route sources) are ignored. - * - * Returns: %TRUE if the configurations are basically equal to each other, - * %FALSE if not - */ -gboolean -nm_ip4_config_equal(const NMIP4Config *a, const NMIP4Config *b) -{ - nm_auto_free_checksum GChecksum *a_checksum = g_checksum_new(G_CHECKSUM_SHA1); - nm_auto_free_checksum GChecksum *b_checksum = g_checksum_new(G_CHECKSUM_SHA1); - guint8 a_data[NM_UTILS_CHECKSUM_LENGTH_SHA1]; - guint8 b_data[NM_UTILS_CHECKSUM_LENGTH_SHA1]; - - if (a) - nm_ip4_config_hash(a, a_checksum, FALSE); - if (b) - nm_ip4_config_hash(b, b_checksum, FALSE); - - nm_utils_checksum_get_digest(a_checksum, a_data); - nm_utils_checksum_get_digest(b_checksum, b_data); - return !memcmp(a_data, b_data, sizeof(a_data)); -} - -/*****************************************************************************/ - -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMIP4Config * self = NM_IP4_CONFIG(object); - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - char addr_str[NM_UTILS_INET_ADDRSTRLEN]; - GVariantBuilder builder_data; - guint i; - - switch (prop_id) { - case PROP_IFINDEX: - g_value_set_int(value, priv->ifindex); - break; - case PROP_ADDRESS_DATA: - case PROP_ADDRESSES: - nm_assert(!!priv->address_data_variant == !!priv->addresses_variant); - - if (!priv->address_data_variant) { - nm_utils_ip_addresses_to_dbus(AF_INET, - nm_ip4_config_lookup_addresses(self), - priv->best_default_route, - NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, - &priv->address_data_variant, - &priv->addresses_variant); - g_variant_ref_sink(priv->address_data_variant); - g_variant_ref_sink(priv->addresses_variant); - } - - g_value_set_variant(value, - prop_id == PROP_ADDRESS_DATA ? priv->address_data_variant - : priv->addresses_variant); - break; - case PROP_ROUTE_DATA: - case PROP_ROUTES: - nm_assert(!!priv->route_data_variant == !!priv->routes_variant); - - if (!priv->route_data_variant) { - nm_utils_ip_routes_to_dbus(AF_INET, - nm_ip4_config_lookup_routes(self), - &priv->route_data_variant, - &priv->routes_variant); - g_variant_ref_sink(priv->route_data_variant); - g_variant_ref_sink(priv->routes_variant); - } - - g_value_set_variant(value, - prop_id == PROP_ROUTE_DATA ? priv->route_data_variant - : priv->routes_variant); - break; - case PROP_GATEWAY: - if (priv->best_default_route) { - g_value_take_string(value, - nm_utils_inet4_ntop_dup( - NMP_OBJECT_CAST_IP4_ROUTE(priv->best_default_route)->gateway)); - } else - g_value_set_string(value, NULL); - break; - case PROP_NAMESERVER_DATA: - g_variant_builder_init(&builder_data, G_VARIANT_TYPE("aa{sv}")); - - for (i = 0; i < priv->nameservers->len; i++) { - GVariantBuilder nested_builder; - - _nm_utils_inet4_ntop(g_array_index(priv->nameservers, in_addr_t, i), addr_str); - - g_variant_builder_init(&nested_builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&nested_builder, - "{sv}", - "address", - g_variant_new_string(addr_str)); - g_variant_builder_add(&builder_data, "a{sv}", &nested_builder); - } - - g_value_take_variant(value, g_variant_builder_end(&builder_data)); - break; - case PROP_NAMESERVERS: - g_value_take_variant( - value, - nm_g_variant_new_au((const guint32 *) priv->nameservers->data, priv->nameservers->len)); - break; - case PROP_DOMAINS: - nm_utils_g_value_set_strv(value, priv->domains); - break; - case PROP_SEARCHES: - nm_utils_g_value_set_strv(value, priv->searches); - break; - case PROP_DNS_OPTIONS: - nm_utils_g_value_set_strv(value, priv->dns_options); - break; - case PROP_DNS_PRIORITY: - g_value_set_int(value, priv->dns_priority); - break; - case PROP_WINS_SERVER_DATA: - g_variant_builder_init(&builder_data, G_VARIANT_TYPE("as")); - for (i = 0; i < priv->wins->len; i++) { - g_variant_builder_add( - &builder_data, - "s", - _nm_utils_inet4_ntop(g_array_index(priv->wins, in_addr_t, i), addr_str)); - } - g_value_take_variant(value, g_variant_builder_end(&builder_data)); - break; - case PROP_WINS_SERVERS: - g_value_take_variant( - value, - nm_g_variant_new_au((const guint32 *) priv->wins->data, priv->wins->len)); - 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) -{ - NMIP4Config * self = NM_IP4_CONFIG(object); - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - switch (prop_id) { - case PROP_MULTI_IDX: - /* construct-only */ - priv->multi_idx = g_value_get_pointer(value); - if (!priv->multi_idx) - g_return_if_reached(); - nm_dedup_multi_index_ref(priv->multi_idx); - break; - case PROP_IFINDEX: - /* construct-only */ - priv->ifindex = g_value_get_int(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void -nm_ip4_config_init(NMIP4Config *self) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - nm_ip_config_dedup_multi_idx_type_init((NMIPConfigDedupMultiIdxType *) &priv->idx_ip4_addresses, - NMP_OBJECT_TYPE_IP4_ADDRESS); - nm_ip_config_dedup_multi_idx_type_init((NMIPConfigDedupMultiIdxType *) &priv->idx_ip4_routes, - NMP_OBJECT_TYPE_IP4_ROUTE); - - priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT; - priv->llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT; - priv->dns_over_tls = NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT; - priv->nameservers = g_array_new(FALSE, FALSE, sizeof(guint32)); - priv->domains = g_ptr_array_new_with_free_func(g_free); - priv->searches = g_ptr_array_new_with_free_func(g_free); - priv->dns_options = g_ptr_array_new_with_free_func(g_free); - priv->nis = g_array_new(FALSE, TRUE, sizeof(guint32)); - priv->wins = g_array_new(FALSE, TRUE, sizeof(guint32)); -} - -NMIP4Config * -nm_ip4_config_new(NMDedupMultiIndex *multi_idx, int ifindex) -{ - g_return_val_if_fail(ifindex >= -1, NULL); - return g_object_new(NM_TYPE_IP4_CONFIG, - NM_IP4_CONFIG_MULTI_IDX, - multi_idx, - NM_IP4_CONFIG_IFINDEX, - ifindex, - NULL); -} - -static void -finalize(GObject *object) -{ - NMIP4Config * self = NM_IP4_CONFIG(object); - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); - - nm_clear_nmp_object(&priv->best_default_route); - - nm_dedup_multi_index_remove_idx(priv->multi_idx, &priv->idx_ip4_addresses); - nm_dedup_multi_index_remove_idx(priv->multi_idx, &priv->idx_ip4_routes); - - nm_clear_g_variant(&priv->address_data_variant); - nm_clear_g_variant(&priv->addresses_variant); - nm_clear_g_variant(&priv->route_data_variant); - nm_clear_g_variant(&priv->routes_variant); - - g_array_unref(priv->nameservers); - g_ptr_array_unref(priv->domains); - g_ptr_array_unref(priv->searches); - g_ptr_array_unref(priv->dns_options); - g_array_unref(priv->nis); - g_free(priv->nis_domain); - g_array_unref(priv->wins); - - G_OBJECT_CLASS(nm_ip4_config_parent_class)->finalize(object); - - nm_dedup_multi_index_unref(priv->multi_idx); -} - -static const NMDBusInterfaceInfoExtended interface_info_ip4_config = { - .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT( - NM_DBUS_INTERFACE_IP4_CONFIG, - .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS( - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Addresses", - "aau", - NM_IP4_CONFIG_ADDRESSES), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("AddressData", - "aa{sv}", - NM_IP4_CONFIG_ADDRESS_DATA), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Gateway", "s", NM_IP4_CONFIG_GATEWAY), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Routes", "aau", NM_IP4_CONFIG_ROUTES), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("RouteData", - "aa{sv}", - NM_IP4_CONFIG_ROUTE_DATA), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("NameserverData", - "aa{sv}", - NM_IP4_CONFIG_NAMESERVER_DATA), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Nameservers", - "au", - NM_IP4_CONFIG_NAMESERVERS), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Domains", "as", NM_IP4_CONFIG_DOMAINS), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Searches", - "as", - NM_IP4_CONFIG_SEARCHES), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("DnsOptions", - "as", - NM_IP4_CONFIG_DNS_OPTIONS), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("DnsPriority", - "i", - NM_IP4_CONFIG_DNS_PRIORITY), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("WinsServerData", - "as", - NM_IP4_CONFIG_WINS_SERVER_DATA), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("WinsServers", - "au", - NM_IP4_CONFIG_WINS_SERVERS), ), ), -}; - -static void -nm_ip4_config_class_init(NMIP4ConfigClass *klass) -{ - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMIPConfigClass * ip_config_class = NM_IP_CONFIG_CLASS(klass); - - ip_config_class->is_ipv4 = TRUE; - ip_config_class->addr_family = AF_INET; - - dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED(NM_DBUS_PATH "/IP4Config"); - dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_ip4_config); - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; - - obj_properties[PROP_MULTI_IDX] = - g_param_spec_pointer(NM_IP4_CONFIG_MULTI_IDX, - "", - "", - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IFINDEX] = - g_param_spec_int(NM_IP4_CONFIG_IFINDEX, - "", - "", - -1, - G_MAXINT, - -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ADDRESS_DATA] = - g_param_spec_variant(NM_IP4_CONFIG_ADDRESS_DATA, - "", - "", - G_VARIANT_TYPE("aa{sv}"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ADDRESSES] = - g_param_spec_variant(NM_IP4_CONFIG_ADDRESSES, - "", - "", - G_VARIANT_TYPE("aau"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ROUTE_DATA] = - g_param_spec_variant(NM_IP4_CONFIG_ROUTE_DATA, - "", - "", - G_VARIANT_TYPE("aa{sv}"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ROUTES] = g_param_spec_variant(NM_IP4_CONFIG_ROUTES, - "", - "", - G_VARIANT_TYPE("aau"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_GATEWAY] = g_param_spec_string(NM_IP4_CONFIG_GATEWAY, - "", - "", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_NAMESERVER_DATA] = - g_param_spec_variant(NM_IP4_CONFIG_NAMESERVER_DATA, - "", - "", - G_VARIANT_TYPE("aa{sv}"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_NAMESERVERS] = - g_param_spec_variant(NM_IP4_CONFIG_NAMESERVERS, - "", - "", - G_VARIANT_TYPE("au"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_DOMAINS] = g_param_spec_boxed(NM_IP4_CONFIG_DOMAINS, - "", - "", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_SEARCHES] = g_param_spec_boxed(NM_IP4_CONFIG_SEARCHES, - "", - "", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_DNS_OPTIONS] = - g_param_spec_boxed(NM_IP4_CONFIG_DNS_OPTIONS, - "", - "", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_DNS_PRIORITY] = g_param_spec_int(NM_IP4_CONFIG_DNS_PRIORITY, - "", - "", - G_MININT32, - G_MAXINT32, - 0, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_WINS_SERVER_DATA] = - g_param_spec_variant(NM_IP4_CONFIG_WINS_SERVER_DATA, - "", - "", - G_VARIANT_TYPE("as"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_WINS_SERVERS] = - g_param_spec_variant(NM_IP4_CONFIG_WINS_SERVERS, - "", - "", - G_VARIANT_TYPE("au"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); -} diff --git a/src/core/nm-ip4-config.h b/src/core/nm-ip4-config.h deleted file mode 100644 index 2eb193b2be..0000000000 --- a/src/core/nm-ip4-config.h +++ /dev/null @@ -1,673 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2008 - 2013 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_IP4_CONFIG_H__ -#define __NETWORKMANAGER_IP4_CONFIG_H__ - -#include "nm-setting-connection.h" - -#include "nm-setting-ip4-config.h" - -#include "libnm-glib-aux/nm-dedup-multi.h" -#include "libnm-platform/nmp-object.h" -#include "nm-ip-config.h" - -/*****************************************************************************/ - -typedef enum _NMIPConfigFlags { - NM_IP_CONFIG_FLAG_NONE = 0, - - /* if set, then the merge flag NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES gets - * ignored during merge. */ - NM_IP_CONFIG_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES = (1ull << 0), -} NMIPConfigFlags; - -typedef struct { - NMDedupMultiIdxType parent; - NMPObjectType obj_type; -} NMIPConfigDedupMultiIdxType; - -void nm_ip_config_dedup_multi_idx_type_init(NMIPConfigDedupMultiIdxType *idx_type, - NMPObjectType obj_type); - -/*****************************************************************************/ - -void nm_ip_config_iter_ip4_address_init(NMDedupMultiIter *iter, const NMIP4Config *self); -void nm_ip_config_iter_ip4_route_init(NMDedupMultiIter *iter, const NMIP4Config *self); - -#define nm_ip_config_iter_ip4_address_for_each(iter, self, address) \ - for (nm_ip_config_iter_ip4_address_init((iter), (self)); \ - nm_platform_dedup_multi_iter_next_ip4_address((iter), (address));) - -#define nm_ip_config_iter_ip4_route_for_each(iter, self, route) \ - for (nm_ip_config_iter_ip4_route_init((iter), (self)); \ - nm_platform_dedup_multi_iter_next_ip4_route((iter), (route));) - -/*****************************************************************************/ - -const NMPObject *_nm_ip_config_best_default_route_find_better(const NMPObject *obj_cur, - const NMPObject *obj_cmp); -gboolean _nm_ip_config_best_default_route_merge(const NMPObject **best_default_route, - const NMPObject * new_candidate); - -/*****************************************************************************/ - -gboolean _nm_ip_config_add_obj(NMDedupMultiIndex * multi_idx, - NMIPConfigDedupMultiIdxType *idx_type, - int ifindex, - const NMPObject * obj_new, - const NMPlatformObject * pl_new, - gboolean merge, - gboolean append_force, - const NMPObject ** out_obj_old, - const NMPObject ** out_obj_new); - -const NMDedupMultiEntry *_nm_ip_config_lookup_ip_route(const NMDedupMultiIndex * multi_idx, - const NMIPConfigDedupMultiIdxType *idx_type, - const NMPObject * needle, - NMPlatformIPRouteCmpType cmp_type); - -/*****************************************************************************/ - -#define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type()) -#define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_IP4_CONFIG, NMIP4Config)) -#define NM_IP4_CONFIG_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass)) -#define NM_IS_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_IP4_CONFIG)) -#define NM_IS_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_IP4_CONFIG)) -#define NM_IP4_CONFIG_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass)) - -typedef struct _NMIP4ConfigClass NMIP4ConfigClass; - -/* internal */ -#define NM_IP4_CONFIG_MULTI_IDX "multi-idx" -#define NM_IP4_CONFIG_IFINDEX "ifindex" - -/* public*/ -#define NM_IP4_CONFIG_ADDRESS_DATA "address-data" -#define NM_IP4_CONFIG_ROUTE_DATA "route-data" -#define NM_IP4_CONFIG_GATEWAY "gateway" -#define NM_IP4_CONFIG_NAMESERVER_DATA "nameserver-data" -#define NM_IP4_CONFIG_DOMAINS "domains" -#define NM_IP4_CONFIG_SEARCHES "searches" -#define NM_IP4_CONFIG_DNS_OPTIONS "dns-options" -#define NM_IP4_CONFIG_DNS_PRIORITY "dns-priority" -#define NM_IP4_CONFIG_WINS_SERVER_DATA "wins-server-data" - -/* deprecated */ -#define NM_IP4_CONFIG_ADDRESSES "addresses" -#define NM_IP4_CONFIG_ROUTES "routes" -#define NM_IP4_CONFIG_NAMESERVERS "nameservers" -#define NM_IP4_CONFIG_WINS_SERVERS "wins-servers" - -GType nm_ip4_config_get_type(void); - -NMIP4Config *nm_ip4_config_new(NMDedupMultiIndex *multi_idx, int ifindex); - -NMIP4Config *nm_ip4_config_clone(const NMIP4Config *self); -int nm_ip4_config_get_ifindex(const NMIP4Config *self); - -NMDedupMultiIndex *nm_ip4_config_get_multi_idx(const NMIP4Config *self); - -NMIP4Config *nm_ip4_config_capture(NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex); - -void nm_ip4_config_add_dependent_routes(NMIP4Config *self, - guint32 route_table, - guint32 route_metric, - gboolean is_vrf, - GPtrArray ** out_ip4_dev_route_blacklist); - -gboolean nm_ip4_config_commit(const NMIP4Config * self, - NMPlatform * platform, - NMIPRouteTableSyncMode route_table_sync); - -void nm_ip4_config_merge_setting(NMIP4Config * self, - NMSettingIPConfig * setting, - NMSettingConnectionMdns mdns, - NMSettingConnectionLlmnr llmnr, - NMSettingConnectionDnsOverTls dns_over_tls, - guint32 route_table, - guint32 route_metric); -NMSetting *nm_ip4_config_create_setting(const NMIP4Config *self); - -void nm_ip4_config_merge(NMIP4Config * dst, - const NMIP4Config * src, - NMIPConfigMergeFlags merge_flags, - guint32 default_route_metric_penalty); -void nm_ip4_config_subtract(NMIP4Config * dst, - const NMIP4Config *src, - guint32 default_route_metric_penalty); -void nm_ip4_config_intersect(NMIP4Config * dst, - const NMIP4Config *src, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty); -NMIP4Config *nm_ip4_config_intersect_alloc(const NMIP4Config *a, - const NMIP4Config *b, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty); -gboolean -nm_ip4_config_replace(NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes); - -const NMPObject *nm_ip4_config_best_default_route_get(const NMIP4Config *self); -const NMPObject *_nm_ip4_config_best_default_route_find(const NMIP4Config *self); - -in_addr_t nmtst_ip4_config_get_gateway(NMIP4Config *config); - -NMSettingConnectionMdns nm_ip4_config_mdns_get(const NMIP4Config *self); -void nm_ip4_config_mdns_set(NMIP4Config *self, NMSettingConnectionMdns mdns); -NMSettingConnectionLlmnr nm_ip4_config_llmnr_get(const NMIP4Config *self); -void nm_ip4_config_llmnr_set(NMIP4Config *self, NMSettingConnectionLlmnr llmnr); -NMSettingConnectionDnsOverTls nm_ip4_config_dns_over_tls_get(const NMIP4Config *self); -void nm_ip4_config_dns_over_tls_set(NMIP4Config *self, NMSettingConnectionDnsOverTls dns_over_tls); - -void nm_ip4_config_set_config_flags(NMIP4Config *self, NMIPConfigFlags flags, NMIPConfigFlags mask); -NMIPConfigFlags nm_ip4_config_get_config_flags(const NMIP4Config *self); - -const NMDedupMultiHeadEntry *nm_ip4_config_lookup_addresses(const NMIP4Config *self); -void nm_ip4_config_reset_addresses(NMIP4Config *self); -void nm_ip4_config_add_address(NMIP4Config *self, const NMPlatformIP4Address *address); -void _nmtst_ip4_config_del_address(NMIP4Config *self, guint i); -guint nm_ip4_config_get_num_addresses(const NMIP4Config *self); -const NMPlatformIP4Address *nm_ip4_config_get_first_address(const NMIP4Config *self); -const NMPlatformIP4Address *_nmtst_ip4_config_get_address(const NMIP4Config *self, guint i); -gboolean nm_ip4_config_address_exists(const NMIP4Config *self, const NMPlatformIP4Address *address); - -const NMDedupMultiHeadEntry *nm_ip4_config_lookup_routes(const NMIP4Config *self); -void nm_ip4_config_reset_routes(NMIP4Config *self); -void nm_ip4_config_add_route(NMIP4Config * self, - const NMPlatformIP4Route *route, - const NMPObject ** out_obj_new); -void _nmtst_ip4_config_del_route(NMIP4Config *self, guint i); -guint nm_ip4_config_get_num_routes(const NMIP4Config *self); -const NMPlatformIP4Route * _nmtst_ip4_config_get_route(const NMIP4Config *self, guint i); - -const NMPlatformIP4Route *nm_ip4_config_get_direct_route_for_host(const NMIP4Config *self, - in_addr_t host, - guint32 route_table); -void nm_ip4_config_update_routes_metric(NMIP4Config *self, gint64 metric); - -void nm_ip4_config_reset_nameservers(NMIP4Config *self); -void nm_ip4_config_add_nameserver(NMIP4Config *self, guint32 nameserver); - -static inline void -_nm_ip4_config_add_nameserver(NMIP4Config *self, const guint32 *nameserver) -{ - nm_ip4_config_add_nameserver(self, *nameserver); -} - -void nm_ip4_config_del_nameserver(NMIP4Config *self, guint i); -guint nm_ip4_config_get_num_nameservers(const NMIP4Config *self); -guint32 nm_ip4_config_get_nameserver(const NMIP4Config *self, guint i); -const in_addr_t *_nm_ip4_config_get_nameserver(const NMIP4Config *self, guint i); - -void nm_ip4_config_reset_domains(NMIP4Config *self); -void nm_ip4_config_add_domain(NMIP4Config *self, const char *domain); -void nm_ip4_config_del_domain(NMIP4Config *self, guint i); -guint nm_ip4_config_get_num_domains(const NMIP4Config *self); -const char *nm_ip4_config_get_domain(const NMIP4Config *self, guint i); - -void nm_ip4_config_reset_searches(NMIP4Config *self); -void nm_ip4_config_add_search(NMIP4Config *self, const char *search); -void nm_ip4_config_del_search(NMIP4Config *self, guint i); -guint nm_ip4_config_get_num_searches(const NMIP4Config *self); -const char *nm_ip4_config_get_search(const NMIP4Config *self, guint i); - -void nm_ip4_config_reset_dns_options(NMIP4Config *self); -void nm_ip4_config_add_dns_option(NMIP4Config *self, const char *option); -void nm_ip4_config_del_dns_option(NMIP4Config *self, guint i); -guint nm_ip4_config_get_num_dns_options(const NMIP4Config *self); -const char *nm_ip4_config_get_dns_option(const NMIP4Config *self, guint i); - -void nm_ip4_config_set_dns_priority(NMIP4Config *self, int priority); -int nm_ip4_config_get_dns_priority(const NMIP4Config *self); - -void nm_ip4_config_reset_nis_servers(NMIP4Config *self); -void nm_ip4_config_add_nis_server(NMIP4Config *self, guint32 nis); -void nm_ip4_config_del_nis_server(NMIP4Config *self, guint i); -guint nm_ip4_config_get_num_nis_servers(const NMIP4Config *self); -guint32 nm_ip4_config_get_nis_server(const NMIP4Config *self, guint i); -void nm_ip4_config_set_nis_domain(NMIP4Config *self, const char *domain); -const char *nm_ip4_config_get_nis_domain(const NMIP4Config *self); - -void nm_ip4_config_reset_wins(NMIP4Config *self); -void nm_ip4_config_add_wins(NMIP4Config *self, guint32 wins); -void nm_ip4_config_del_wins(NMIP4Config *self, guint i); -guint nm_ip4_config_get_num_wins(const NMIP4Config *self); -guint32 nm_ip4_config_get_wins(const NMIP4Config *self, guint i); - -void nm_ip4_config_set_mtu(NMIP4Config *self, guint32 mtu, NMIPConfigSource source); -guint32 nm_ip4_config_get_mtu(const NMIP4Config *self); -NMIPConfigSource nm_ip4_config_get_mtu_source(const NMIP4Config *self); - -void nm_ip4_config_set_metered(NMIP4Config *self, gboolean metered); -gboolean nm_ip4_config_get_metered(const NMIP4Config *self); - -void nm_ip4_config_set_never_default(NMIP4Config *self, gboolean never_default); -gboolean nm_ip4_config_get_never_default(const NMIP4Config *self); - -const NMPObject *nm_ip4_config_nmpobj_lookup(const NMIP4Config *self, const NMPObject *needle); -gboolean nm_ip4_config_nmpobj_remove(NMIP4Config *self, const NMPObject *needle); - -void nm_ip4_config_hash(const NMIP4Config *self, GChecksum *sum, gboolean dns_only); -gboolean nm_ip4_config_equal(const NMIP4Config *a, const NMIP4Config *b); - -gboolean _nm_ip_config_check_and_add_domain(GPtrArray *array, const char *domain); - -void -nm_ip_config_dump(const NMIPConfig *self, const char *detail, NMLogLevel level, NMLogDomain domain); - -/*****************************************************************************/ - -#include "nm-ip6-config.h" - -static inline gboolean -NM_IS_IP_CONFIG_ADDR_FAMILY(gconstpointer config, int addr_family) -{ - if (addr_family == AF_UNSPEC) - return NM_IS_IP4_CONFIG(config) || NM_IS_IP6_CONFIG(config); - if (addr_family == AF_INET) - return NM_IS_IP4_CONFIG(config); - if (addr_family == AF_INET6) - return NM_IS_IP6_CONFIG(config); - g_return_val_if_reached(FALSE); -} - -#if _NM_CC_SUPPORT_GENERIC -/* _NM_IS_IP_CONFIG() is a bit unusual. If _Generic() is supported, - * it checks whether @config is either NM_IS_IP4_CONFIG() or NM_IS_IP6_CONFIG(), - * depending on the pointer type of @config. - * - * For example, with _Generic() support, the following assertions would fail: - * NMIP6Config *ptr = (NMIP6Config *) nm_ip4_config_new(...); - * g_assert (_NM_IS_IP_CONFIG (ptr, ptr)); - * but the following would pass: - * NMIP4Config *ptr = nm_ip4_config_new(...); - * g_assert (_NM_IS_IP_CONFIG (ptr, ptr)); - */ -#define _NM_IS_IP_CONFIG(typeexpr, config) \ - ({ \ - const void *const _config = (config); \ - _Generic ((typeexpr), \ - const void *const: (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ - const void * : (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ - void *const: (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ - void * : (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ - const NMIPConfig *const: (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ - const NMIPConfig * : (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ - NMIPConfig *const: (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ - NMIPConfig * : (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ - const NMIP4Config *const: (NM_IS_IP4_CONFIG (_config)), \ - const NMIP4Config * : (NM_IS_IP4_CONFIG (_config)), \ - NMIP4Config *const: (NM_IS_IP4_CONFIG (_config)), \ - NMIP4Config * : (NM_IS_IP4_CONFIG (_config)), \ - const NMIP6Config *const: (NM_IS_IP6_CONFIG (_config)), \ - const NMIP6Config * : (NM_IS_IP6_CONFIG (_config)), \ - NMIP6Config *const: (NM_IS_IP6_CONFIG (_config)), \ - NMIP6Config * : (NM_IS_IP6_CONFIG (_config))); \ - }) -#else -#define _NM_IS_IP_CONFIG(typeexpr, config) NM_IS_IP_CONFIG(config) -#endif - -#define NM_IP_CONFIG_CAST(config) \ - ({ \ - const void *const _configx = (config); \ - \ - nm_assert(!_configx || _NM_IS_IP_CONFIG((config), _configx)); \ - NM_CONSTCAST_FULL(NMIPConfig, (config), _configx, NMIP4Config, NMIP6Config); \ - }) - -static inline gboolean -nm_ip_config_is_ipv4(const NMIPConfig *config) -{ - if (NM_IP_CONFIG_GET_CLASS(config)->is_ipv4) { - nm_assert(NM_IS_IP4_CONFIG(config)); - return TRUE; - } - nm_assert(NM_IS_IP6_CONFIG(config)); - return FALSE; -} - -static inline int -nm_ip_config_get_addr_family(const NMIPConfig *config) -{ - return nm_ip_config_is_ipv4(config) ? AF_INET : AF_INET6; -} - -#define _NM_IP_CONFIG_DISPATCH(config, v4_func, v6_func, ...) \ - G_STMT_START \ - { \ - gconstpointer _config = (config); \ - \ - if (nm_ip_config_is_ipv4(_config)) { \ - return v4_func((NMIP4Config *) _config, ##__VA_ARGS__); \ - } else { \ - return v6_func((NMIP6Config *) _config, ##__VA_ARGS__); \ - } \ - } \ - G_STMT_END - -#define _NM_IP_CONFIG_DISPATCH_VOID(config, v4_func, v6_func, ...) \ - G_STMT_START \ - { \ - gconstpointer _config = (config); \ - \ - if (nm_ip_config_is_ipv4(_config)) { \ - v4_func((NMIP4Config *) _config, ##__VA_ARGS__); \ - } else { \ - v6_func((NMIP6Config *) _config, ##__VA_ARGS__); \ - } \ - } \ - G_STMT_END - -static inline int -nm_ip_config_get_ifindex(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_ifindex, nm_ip6_config_get_ifindex); -} - -static inline void -nm_ip_config_hash(const NMIPConfig *self, GChecksum *sum, gboolean dns_only) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, nm_ip4_config_hash, nm_ip6_config_hash, sum, dns_only); -} - -static inline gconstpointer -nm_ip_config_get_first_address(NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_first_address, nm_ip6_config_get_first_address); -} - -static inline void -nm_ip_config_iter_ip_address_init(NMDedupMultiIter *iter, const NMIPConfig *self) -{ - if (nm_ip_config_is_ipv4(self)) - nm_ip_config_iter_ip4_address_init(iter, (const NMIP4Config *) self); - else - nm_ip_config_iter_ip6_address_init(iter, (const NMIP6Config *) self); -} - -#define nm_ip_config_iter_ip_address_for_each(iter, self, address) \ - for (nm_ip_config_iter_ip_address_init((iter), (self)); \ - nm_platform_dedup_multi_iter_next_ip_address((iter), (address));) - -static inline void -nm_ip_config_iter_ip_route_init(NMDedupMultiIter *iter, const NMIPConfig *self) -{ - if (nm_ip_config_is_ipv4(self)) - nm_ip_config_iter_ip4_route_init(iter, (const NMIP4Config *) self); - else - nm_ip_config_iter_ip6_route_init(iter, (const NMIP6Config *) self); -} - -#define nm_ip_config_iter_ip_route_for_each(iter, self, route) \ - for (nm_ip_config_iter_ip_route_init((iter), (self)); \ - nm_platform_dedup_multi_iter_next_ip_route((iter), (route));) - -static inline void -nm_ip_config_add_address(NMIPConfig *self, const NMPlatformIPAddress *address) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, - nm_ip4_config_add_address, - nm_ip6_config_add_address, - (gconstpointer) address); -} - -static inline void -nm_ip_config_reset_addresses(NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, nm_ip4_config_reset_addresses, nm_ip6_config_reset_addresses); -} - -static inline void -nm_ip_config_add_route(NMIPConfig *self, - const NMPlatformIPRoute *new, - const NMPObject **out_obj_new) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, - nm_ip4_config_add_route, - nm_ip6_config_add_route, - (gpointer) new, - out_obj_new); -} - -static inline void -nm_ip_config_reset_routes(NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, nm_ip4_config_reset_routes, nm_ip6_config_reset_routes); -} - -static inline int -nm_ip_config_get_dns_priority(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_dns_priority, nm_ip6_config_get_dns_priority); -} - -static inline void -nm_ip_config_set_dns_priority(NMIPConfig *self, int priority) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, - nm_ip4_config_set_dns_priority, - nm_ip6_config_set_dns_priority, - priority); -} - -static inline void -nm_ip_config_add_nameserver(NMIPConfig *self, const NMIPAddr *ns) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, - _nm_ip4_config_add_nameserver, - nm_ip6_config_add_nameserver, - (gconstpointer) ns); -} - -static inline void -nm_ip_config_reset_nameservers(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, - nm_ip4_config_reset_nameservers, - nm_ip6_config_reset_nameservers); -} - -static inline guint -nm_ip_config_get_num_nameservers(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, - nm_ip4_config_get_num_nameservers, - nm_ip6_config_get_num_nameservers); -} - -static inline gconstpointer -nm_ip_config_get_nameserver(const NMIPConfig *self, guint i) -{ - _NM_IP_CONFIG_DISPATCH(self, _nm_ip4_config_get_nameserver, nm_ip6_config_get_nameserver, i); -} - -static inline guint -nm_ip_config_get_num_domains(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_num_domains, nm_ip6_config_get_num_domains); -} - -static inline const char * -nm_ip_config_get_domain(const NMIPConfig *self, guint i) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_domain, nm_ip6_config_get_domain, i); -} - -static inline void -nm_ip_config_reset_searches(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, nm_ip4_config_reset_searches, nm_ip6_config_reset_searches); -} - -static inline void -nm_ip_config_add_search(const NMIPConfig *self, const char *new) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, nm_ip4_config_add_search, nm_ip6_config_add_search, new); -} - -static inline guint -nm_ip_config_get_num_searches(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_num_searches, nm_ip6_config_get_num_searches); -} - -static inline const char * -nm_ip_config_get_search(const NMIPConfig *self, guint i) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_search, nm_ip6_config_get_search, i); -} - -static inline guint -nm_ip_config_get_num_dns_options(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, - nm_ip4_config_get_num_dns_options, - nm_ip6_config_get_num_dns_options); -} - -static inline const char * -nm_ip_config_get_dns_option(const NMIPConfig *self, guint i) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_dns_option, nm_ip6_config_get_dns_option, i); -} - -static inline const NMPObject * -nm_ip_config_best_default_route_get(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, - nm_ip4_config_best_default_route_get, - nm_ip6_config_best_default_route_get); -} - -static inline NMIPConfigFlags -nm_ip_config_get_config_flags(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_config_flags, nm_ip6_config_get_config_flags); -} - -static inline void -nm_ip_config_set_config_flags(NMIPConfig *self, NMIPConfigFlags flags, NMIPConfigFlags mask) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, - nm_ip4_config_set_config_flags, - nm_ip6_config_set_config_flags, - flags, - mask); -} - -static inline gboolean -nm_ip_config_get_never_default(const NMIPConfig *self) -{ - _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_never_default, nm_ip6_config_get_never_default); -} - -static inline void -nm_ip_config_set_never_default(NMIPConfig *self, gboolean never_default) -{ - _NM_IP_CONFIG_DISPATCH_VOID(self, - nm_ip4_config_set_never_default, - nm_ip6_config_set_never_default, - never_default); -} - -#define _NM_IP_CONFIG_DISPATCH_SET_OP(_return, dst, src, v4_func, v6_func, ...) \ - G_STMT_START \ - { \ - gpointer _dst = (dst); \ - gconstpointer _src = (src); \ - \ - if (nm_ip_config_is_ipv4(_dst)) { \ - _return v4_func((NMIP4Config *) _dst, (const NMIP4Config *) _src, ##__VA_ARGS__); \ - } else { \ - _return v6_func((NMIP6Config *) _dst, (const NMIP6Config *) _src, ##__VA_ARGS__); \ - } \ - } \ - G_STMT_END - -static inline void -nm_ip_config_intersect(NMIPConfig * dst, - const NMIPConfig *src, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty) -{ - _NM_IP_CONFIG_DISPATCH_SET_OP(, - dst, - src, - nm_ip4_config_intersect, - nm_ip6_config_intersect, - intersect_addresses, - intersect_routes, - default_route_metric_penalty); -} - -static inline void -nm_ip_config_subtract(NMIPConfig *dst, const NMIPConfig *src, guint32 default_route_metric_penalty) -{ - _NM_IP_CONFIG_DISPATCH_SET_OP(, - dst, - src, - nm_ip4_config_subtract, - nm_ip6_config_subtract, - default_route_metric_penalty); -} - -static inline void -nm_ip_config_merge(NMIPConfig * dst, - const NMIPConfig * src, - NMIPConfigMergeFlags merge_flags, - guint32 default_route_metric_penalty) -{ - _NM_IP_CONFIG_DISPATCH_SET_OP(, - dst, - src, - nm_ip4_config_merge, - nm_ip6_config_merge, - merge_flags, - default_route_metric_penalty); -} - -static inline gboolean -nm_ip_config_replace(NMIPConfig *dst, const NMIPConfig *src, gboolean *relevant_changes) -{ - _NM_IP_CONFIG_DISPATCH_SET_OP( - return, dst, src, nm_ip4_config_replace, nm_ip6_config_replace, relevant_changes); -} - -static inline NMIPConfig * -nm_ip_config_intersect_alloc(const NMIPConfig *a, - const NMIPConfig *b, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty) -{ - if (nm_ip_config_is_ipv4(a)) { - nm_assert(NM_IS_IP4_CONFIG(a)); - nm_assert(NM_IS_IP4_CONFIG(b)); - return (NMIPConfig *) nm_ip4_config_intersect_alloc((const NMIP4Config *) a, - (const NMIP4Config *) b, - intersect_addresses, - intersect_routes, - default_route_metric_penalty); - } else { - nm_assert(NM_IS_IP6_CONFIG(a)); - nm_assert(NM_IS_IP6_CONFIG(b)); - return (NMIPConfig *) nm_ip6_config_intersect_alloc((const NMIP6Config *) a, - (const NMIP6Config *) b, - intersect_addresses, - intersect_routes, - default_route_metric_penalty); - } -} - -gconstpointer nm_ip_config_find_first_address(const NMIPConfig * self, - NMPlatformMatchFlags match_flag); - -#endif /* __NETWORKMANAGER_IP4_CONFIG_H__ */ diff --git a/src/core/nm-ip6-config.c b/src/core/nm-ip6-config.c deleted file mode 100644 index 5ec68bd28c..0000000000 --- a/src/core/nm-ip6-config.c +++ /dev/null @@ -1,2675 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2005 - 2017 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include "nm-ip6-config.h" - -#include -#include -#include -#include - -#include "libnm-glib-aux/nm-dedup-multi.h" - -#include "nm-utils.h" -#include "libnm-platform/nmp-object.h" -#include "libnm-platform/nm-platform.h" -#include "libnm-platform/nm-platform-utils.h" -#include "libnm-core-intern/nm-core-internal.h" -#include "NetworkManagerUtils.h" -#include "nm-ip4-config.h" -#include "ndisc/nm-ndisc.h" -#include "nm-dbus-object.h" - -/*****************************************************************************/ - -static gboolean -_route_valid(const NMPlatformIP6Route *r) -{ - struct in6_addr n; - - return r && r->plen <= 128 - && (memcmp(&r->network, - nm_utils_ip6_address_clear_host_address(&n, &r->network, r->plen), - sizeof(n)) - == 0); -} - -/*****************************************************************************/ - -typedef struct { - int ifindex; - int dns_priority; - NMSettingIP6ConfigPrivacy privacy; - GArray * nameservers; - GPtrArray * domains; - GPtrArray * searches; - GPtrArray * dns_options; - GVariant * address_data_variant; - GVariant * addresses_variant; - GVariant * route_data_variant; - GVariant * routes_variant; - NMDedupMultiIndex * multi_idx; - const NMPObject * best_default_route; - union { - NMIPConfigDedupMultiIdxType idx_ip6_addresses_; - NMDedupMultiIdxType idx_ip6_addresses; - }; - union { - NMIPConfigDedupMultiIdxType idx_ip6_routes_; - NMDedupMultiIdxType idx_ip6_routes; - }; - NMIPConfigFlags config_flags; - bool never_default : 1; -} NMIP6ConfigPrivate; - -struct _NMIP6Config { - NMIPConfig parent; - NMIP6ConfigPrivate _priv; -}; - -struct _NMIP6ConfigClass { - NMIPConfigClass parent; -}; - -G_DEFINE_TYPE(NMIP6Config, nm_ip6_config, NM_TYPE_IP_CONFIG) - -#define NM_IP6_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP6Config, NM_IS_IP6_CONFIG) - -NM_GOBJECT_PROPERTIES_DEFINE(NMIP6Config, - PROP_MULTI_IDX, - PROP_IFINDEX, - PROP_ADDRESS_DATA, - PROP_ADDRESSES, - PROP_ROUTE_DATA, - PROP_ROUTES, - PROP_GATEWAY, - PROP_NAMESERVERS, - PROP_DOMAINS, - PROP_SEARCHES, - PROP_DNS_OPTIONS, - PROP_DNS_PRIORITY, ); - -/*****************************************************************************/ - -static void -_add_address(NMIP6Config *self, const NMPObject *obj_new, const NMPlatformIP6Address *new); -static void _add_route(NMIP6Config * self, - const NMPObject *obj_new, - const NMPlatformIP6Route *new, - const NMPObject **out_obj_new); -static const NMDedupMultiEntry * -_lookup_route(const NMIP6Config *self, const NMPObject *needle, NMPlatformIPRouteCmpType cmp_type); - -/*****************************************************************************/ - -int -nm_ip6_config_get_ifindex(const NMIP6Config *self) -{ - return NM_IP6_CONFIG_GET_PRIVATE(self)->ifindex; -} - -NMDedupMultiIndex * -nm_ip6_config_get_multi_idx(const NMIP6Config *self) -{ - return NM_IP6_CONFIG_GET_PRIVATE(self)->multi_idx; -} - -void -nm_ip6_config_set_privacy(NMIP6Config *self, NMSettingIP6ConfigPrivacy privacy) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - priv->privacy = privacy; -} - -/*****************************************************************************/ - -void -nm_ip6_config_set_never_default(NMIP6Config *self, gboolean never_default) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - priv->never_default = never_default; -} - -gboolean -nm_ip6_config_get_never_default(const NMIP6Config *self) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return priv->never_default; -} - -/*****************************************************************************/ - -const NMDedupMultiHeadEntry * -nm_ip6_config_lookup_addresses(const NMIP6Config *self) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return nm_dedup_multi_index_lookup_head(priv->multi_idx, &priv->idx_ip6_addresses, NULL); -} - -void -nm_ip_config_iter_ip6_address_init(NMDedupMultiIter *ipconf_iter, const NMIP6Config *self) -{ - nm_assert(NM_IS_IP6_CONFIG(self)); - - nm_dedup_multi_iter_init(ipconf_iter, nm_ip6_config_lookup_addresses(self)); -} - -/*****************************************************************************/ - -const NMDedupMultiHeadEntry * -nm_ip6_config_lookup_routes(const NMIP6Config *self) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return nm_dedup_multi_index_lookup_head(priv->multi_idx, &priv->idx_ip6_routes, NULL); -} - -void -nm_ip_config_iter_ip6_route_init(NMDedupMultiIter *ipconf_iter, const NMIP6Config *self) -{ - nm_assert(NM_IS_IP6_CONFIG(self)); - - nm_dedup_multi_iter_init(ipconf_iter, nm_ip6_config_lookup_routes(self)); -} - -/*****************************************************************************/ - -const NMPObject * -nm_ip6_config_best_default_route_get(const NMIP6Config *self) -{ - g_return_val_if_fail(NM_IS_IP6_CONFIG(self), NULL); - - return NM_IP6_CONFIG_GET_PRIVATE(self)->best_default_route; -} - -const NMPObject * -_nm_ip6_config_best_default_route_find(const NMIP6Config *self) -{ - NMDedupMultiIter ipconf_iter; - const NMPObject *new_best_default_route = NULL; - - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, self, NULL) { - new_best_default_route = - _nm_ip_config_best_default_route_find_better(new_best_default_route, - ipconf_iter.current->obj); - } - return new_best_default_route; -} - -/*****************************************************************************/ - -static void -_notify_addresses(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - nm_clear_g_variant(&priv->address_data_variant); - nm_clear_g_variant(&priv->addresses_variant); - nm_gobject_notify_together(self, PROP_ADDRESS_DATA, PROP_ADDRESSES); -} - -static void -_notify_routes(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - nm_assert(priv->best_default_route == _nm_ip6_config_best_default_route_find(self)); - nm_clear_g_variant(&priv->route_data_variant); - nm_clear_g_variant(&priv->routes_variant); - nm_gobject_notify_together(self, PROP_ROUTE_DATA, PROP_ROUTES); -} - -/*****************************************************************************/ - -static int -sort_captured_addresses(const CList *lst_a, const CList *lst_b, gconstpointer user_data) -{ - return nm_platform_ip6_address_pretty_sort_cmp( - NMP_OBJECT_CAST_IP6_ADDRESS(c_list_entry(lst_a, NMDedupMultiEntry, lst_entries)->obj), - NMP_OBJECT_CAST_IP6_ADDRESS(c_list_entry(lst_b, NMDedupMultiEntry, lst_entries)->obj), - (((NMSettingIP6ConfigPrivacy) GPOINTER_TO_INT(user_data)) - == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR)); -} - -gboolean -_nmtst_ip6_config_addresses_sort(NMIP6Config *self) -{ - NMIP6ConfigPrivate * priv; - const NMDedupMultiHeadEntry *head_entry; - - g_return_val_if_fail(NM_IS_IP6_CONFIG(self), FALSE); - - head_entry = nm_ip6_config_lookup_addresses(self); - if (head_entry && head_entry->len > 1) { - gboolean changed; - gs_free gconstpointer *addresses_old = NULL; - guint naddr, j; - NMDedupMultiIter iter; - - priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - addresses_old = nm_dedup_multi_objs_to_array_head(head_entry, NULL, NULL, &naddr); - nm_assert(addresses_old); - nm_assert(naddr > 0 && naddr == head_entry->len); - - nm_dedup_multi_head_entry_sort(head_entry, - sort_captured_addresses, - GINT_TO_POINTER(priv->privacy)); - - changed = FALSE; - j = 0; - nm_dedup_multi_iter_for_each (&iter, head_entry) { - nm_assert(j < naddr); - if (iter.current->obj != addresses_old[j++]) - changed = TRUE; - } - nm_assert(j == naddr); - - if (changed) { - _notify_addresses(self); - return TRUE; - } - } - return FALSE; -} - -NMIP6Config * -nm_ip6_config_clone(const NMIP6Config *self) -{ - NMIP6Config *copy; - - copy = nm_ip6_config_new(nm_ip6_config_get_multi_idx(self), -1); - nm_ip6_config_replace(copy, self, NULL); - - return copy; -} - -NMIP6Config * -nm_ip6_config_capture(NMDedupMultiIndex * multi_idx, - NMPlatform * platform, - int ifindex, - NMSettingIP6ConfigPrivacy use_temporary) -{ - NMIP6Config * self; - NMIP6ConfigPrivate * priv; - const NMDedupMultiHeadEntry *head_entry; - NMDedupMultiIter iter; - const NMPObject * plobj = NULL; - - nm_assert(ifindex > 0); - - /* Slaves have no IP configuration */ - if (nm_platform_link_get_master(platform, ifindex) > 0) - return NULL; - - self = nm_ip6_config_new(multi_idx, ifindex); - priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - head_entry = nm_platform_lookup_object(platform, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex); - if (head_entry) { - nmp_cache_iter_for_each_reverse (&iter, head_entry, &plobj) { - if (!_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip6_addresses_, - ifindex, - plobj, - NULL, - FALSE, - TRUE, - NULL, - NULL)) - nm_assert_not_reached(); - } - _notify_addresses(self); - } - - head_entry = nm_platform_lookup_object(platform, NMP_OBJECT_TYPE_IP6_ROUTE, ifindex); - - nmp_cache_iter_for_each (&iter, head_entry, &plobj) - _add_route(self, plobj, NULL, NULL); - - return self; -} - -void -nm_ip6_config_update_routes_metric(NMIP6Config *self, gint64 metric) -{ - gs_free NMPlatformIP6Route *routes = NULL; - gboolean need_update = FALSE; - const NMPlatformIP6Route * r; - NMDedupMultiIter iter; - guint num = 0, i = 0; - - nm_ip_config_iter_ip6_route_for_each (&iter, self, &r) { - if (r->metric != metric) - need_update = TRUE; - num++; - } - if (!need_update) - return; - - routes = g_new(NMPlatformIP6Route, num); - nm_ip_config_iter_ip6_route_for_each (&iter, self, &r) { - routes[i] = *r; - routes[i].metric = metric; - i++; - } - - g_object_freeze_notify(G_OBJECT(self)); - nm_ip6_config_reset_routes(self); - for (i = 0; i < num; i++) - nm_ip6_config_add_route(self, &routes[i], NULL); - g_object_thaw_notify(G_OBJECT(self)); -} - -void -nm_ip6_config_add_dependent_routes(NMIP6Config *self, - guint32 route_table, - guint32 route_metric, - gboolean is_vrf) -{ - const NMPlatformIP6Address *my_addr; - const NMPlatformIP6Route * my_route; - int ifindex; - NMDedupMultiIter iter; - - g_return_if_fail(NM_IS_IP6_CONFIG(self)); - - ifindex = nm_ip6_config_get_ifindex(self); - g_return_if_fail(ifindex > 0); - - /* For IPv6 addresses received via SLAAC/autoconf, we explicitly add the - * device-routes (onlink) to NMIP6Config. - * - * For manually added IPv6 routes, add the device routes explicitly. */ - - nm_ip_config_iter_ip6_address_for_each (&iter, self, &my_addr) { - NMPlatformIP6Route *route; - gboolean has_peer; - int routes_n, routes_i; - - if (my_addr->external) - continue; - - if (NM_FLAGS_HAS(my_addr->n_ifa_flags, IFA_F_NOPREFIXROUTE)) - continue; - if (my_addr->plen == 0) - continue; - - has_peer = !IN6_IS_ADDR_UNSPECIFIED(&my_addr->peer_address); - - /* If we have an IPv6 peer, we add two /128 routes - * (unless, both addresses are identical). */ - routes_n = - (has_peer && !IN6_ARE_ADDR_EQUAL(&my_addr->address, &my_addr->peer_address)) ? 2 : 1; - - for (routes_i = 0; routes_i < routes_n; routes_i++) { - nm_auto_nmpobj NMPObject *r = NULL; - - r = nmp_object_new(NMP_OBJECT_TYPE_IP6_ROUTE, NULL); - route = NMP_OBJECT_CAST_IP6_ROUTE(r); - - route->ifindex = ifindex; - route->rt_source = NM_IP_CONFIG_SOURCE_KERNEL; - route->table_coerced = nm_platform_route_table_coerce(route_table); - route->metric = route_metric; - - if (has_peer) { - if (routes_i == 0) - route->network = my_addr->address; - else - route->network = my_addr->peer_address; - route->plen = 128; - } else { - nm_utils_ip6_address_clear_host_address(&route->network, - &my_addr->address, - my_addr->plen); - route->plen = my_addr->plen; - } - - nm_platform_ip_route_normalize(AF_INET6, (NMPlatformIPRoute *) route); - - if (_lookup_route(self, r, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID)) { - /* we already track this route. Don't add it again. */ - } else - _add_route(self, r, NULL, NULL); - } - } - -again: - nm_ip_config_iter_ip6_route_for_each (&iter, self, &my_route) { - NMPlatformIP6Route rt; - - if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(my_route) - || IN6_IS_ADDR_UNSPECIFIED(&my_route->gateway) - || NM_IS_IP_CONFIG_SOURCE_RTPROT(my_route->rt_source) - || nm_ip6_config_get_direct_route_for_host( - self, - &my_route->gateway, - nm_platform_route_table_uncoerce(my_route->table_coerced, TRUE))) - continue; - - rt = *my_route; - rt.network = my_route->gateway; - rt.plen = 128; - rt.gateway = in6addr_any; - _add_route(self, NULL, &rt, NULL); - /* adding the route might have invalidated the iteration. Start again. */ - goto again; - } -} - -gboolean -nm_ip6_config_commit(const NMIP6Config * self, - NMPlatform * platform, - NMIPRouteTableSyncMode route_table_sync, - GPtrArray ** out_temporary_not_available) -{ - gs_unref_ptrarray GPtrArray *addresses = NULL; - gs_unref_ptrarray GPtrArray *routes = NULL; - gs_unref_ptrarray GPtrArray *routes_prune = NULL; - int ifindex; - gboolean success = TRUE; - - g_return_val_if_fail(NM_IS_IP6_CONFIG(self), FALSE); - - ifindex = nm_ip6_config_get_ifindex(self); - g_return_val_if_fail(ifindex > 0, FALSE); - - addresses = - nm_dedup_multi_objs_to_ptr_array_head(nm_ip6_config_lookup_addresses(self), NULL, NULL); - - routes = nm_dedup_multi_objs_to_ptr_array_head(nm_ip6_config_lookup_routes(self), NULL, NULL); - - routes_prune = - nm_platform_ip_route_get_prune_list(platform, AF_INET6, ifindex, route_table_sync); - - nm_platform_ip6_address_sync(platform, ifindex, addresses, FALSE); - - if (!nm_platform_ip_route_sync(platform, - AF_INET6, - ifindex, - routes, - routes_prune, - out_temporary_not_available)) - success = FALSE; - - return success; -} - -void -nm_ip6_config_merge_setting(NMIP6Config * self, - NMSettingIPConfig *setting, - guint32 route_table, - guint32 route_metric) -{ - guint naddresses, nroutes, nnameservers, nsearches; - const char * gateway_str; - struct in6_addr gateway_bin; - int i, priority; - - if (!setting) - return; - - g_return_if_fail(NM_IS_SETTING_IP6_CONFIG(setting)); - - naddresses = nm_setting_ip_config_get_num_addresses(setting); - nroutes = nm_setting_ip_config_get_num_routes(setting); - nnameservers = nm_setting_ip_config_get_num_dns(setting); - nsearches = nm_setting_ip_config_get_num_dns_searches(setting); - - g_object_freeze_notify(G_OBJECT(self)); - - /* Gateway */ - if (!nm_setting_ip_config_get_never_default(setting) - && (gateway_str = nm_setting_ip_config_get_gateway(setting)) - && inet_pton(AF_INET6, gateway_str, &gateway_bin) == 1 - && !IN6_IS_ADDR_UNSPECIFIED(&gateway_bin)) { - const NMPlatformIP6Route r = { - .rt_source = NM_IP_CONFIG_SOURCE_USER, - .gateway = gateway_bin, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, - }; - - _add_route(self, NULL, &r, NULL); - } - - /* Addresses */ - for (i = 0; i < naddresses; i++) { - NMIPAddress * s_addr = nm_setting_ip_config_get_address(setting, i); - NMPlatformIP6Address address; - - memset(&address, 0, sizeof(address)); - nm_ip_address_get_address_binary(s_addr, &address.address); - address.plen = nm_ip_address_get_prefix(s_addr); - nm_assert(address.plen <= 128); - address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT; - address.preferred = NM_PLATFORM_LIFETIME_PERMANENT; - address.addr_source = NM_IP_CONFIG_SOURCE_USER; - - _add_address(self, NULL, &address); - } - - /* Routes */ - for (i = 0; i < nroutes; i++) { - NMIPRoute * s_route = nm_setting_ip_config_get_route(setting, i); - NMPlatformIP6Route route; - gint64 m; - - if (nm_ip_route_get_family(s_route) != AF_INET6) { - nm_assert_not_reached(); - continue; - } - - memset(&route, 0, sizeof(route)); - nm_ip_route_get_dest_binary(s_route, &route.network); - - route.plen = nm_ip_route_get_prefix(s_route); - nm_assert(route.plen <= 128); - - nm_ip_route_get_next_hop_binary(s_route, &route.gateway); - m = nm_ip_route_get_metric(s_route); - if (m < 0) - route.metric = route_metric; - else - route.metric = nm_utils_ip6_route_metric_normalize(m); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - - nm_utils_ip6_address_clear_host_address(&route.network, &route.network, route.plen); - - nm_utils_ip_route_attribute_to_platform(AF_INET6, - s_route, - NM_PLATFORM_IP_ROUTE_CAST(&route), - route_table); - _add_route(self, NULL, &route, NULL); - } - - /* DNS */ - if (nm_setting_ip_config_get_ignore_auto_dns(setting)) { - nm_ip6_config_reset_nameservers(self); - nm_ip6_config_reset_domains(self); - nm_ip6_config_reset_searches(self); - } - for (i = 0; i < nnameservers; i++) { - struct in6_addr ip; - - if (inet_pton(AF_INET6, nm_setting_ip_config_get_dns(setting, i), &ip) == 1) - nm_ip6_config_add_nameserver(self, &ip); - } - for (i = 0; i < nsearches; i++) - nm_ip6_config_add_search(self, nm_setting_ip_config_get_dns_search(setting, i)); - - i = 0; - while ((i = nm_setting_ip_config_next_valid_dns_option(setting, i)) >= 0) { - nm_ip6_config_add_dns_option(self, nm_setting_ip_config_get_dns_option(setting, i)); - i++; - } - - priority = nm_setting_ip_config_get_dns_priority(setting); - if (priority) - nm_ip6_config_set_dns_priority(self, priority); - - nm_ip6_config_set_never_default(self, nm_setting_ip_config_get_never_default(setting)); - - g_object_thaw_notify(G_OBJECT(self)); -} - -NMSetting * -nm_ip6_config_create_setting(const NMIP6Config *self, gboolean maybe_ipv6_disabled) -{ - const NMIP6ConfigPrivate * priv; - NMSettingIPConfig * s_ip6; - guint nnameservers, nsearches, noptions; - const char * method = NULL; - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - int i; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP6Address *address; - const NMPlatformIP6Route * route; - - s_ip6 = NM_SETTING_IP_CONFIG(nm_setting_ip6_config_new()); - - if (!self) { - g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - return NM_SETTING(s_ip6); - } - - priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - nnameservers = nm_ip6_config_get_num_nameservers(self); - nsearches = nm_ip6_config_get_num_searches(self); - noptions = nm_ip6_config_get_num_dns_options(self); - - /* Addresses */ - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, self, &address) { - NMIPAddress *s_addr; - - /* Ignore link-local address. */ - if (IN6_IS_ADDR_LINKLOCAL(&address->address)) { - if (!method) - method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL; - continue; - } - - /* Detect dynamic address */ - if (address->lifetime != NM_PLATFORM_LIFETIME_PERMANENT) { - method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; - continue; - } - - /* Static address found. */ - if (!method || strcmp(method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0) - method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; - - s_addr = nm_ip_address_new_binary(AF_INET6, &address->address, address->plen, NULL); - nm_setting_ip_config_add_address(s_ip6, s_addr); - nm_ip_address_unref(s_addr); - } - - /* Gateway */ - if (priv->best_default_route && nm_setting_ip_config_get_num_addresses(s_ip6) > 0) { - g_object_set( - s_ip6, - NM_SETTING_IP_CONFIG_GATEWAY, - _nm_utils_inet6_ntop(&NMP_OBJECT_CAST_IP6_ROUTE(priv->best_default_route)->gateway, - sbuf), - NULL); - } - - /* Use 'ignore' if the method wasn't previously set */ - if (!method) { - method = maybe_ipv6_disabled ? NM_SETTING_IP6_CONFIG_METHOD_DISABLED - : NM_SETTING_IP6_CONFIG_METHOD_IGNORE; - } - - g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, method, NULL); - - /* Routes */ - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, self, &route) { - NMIPRoute *s_route; - - /* Ignore link-local route. */ - if (IN6_IS_ADDR_LINKLOCAL(&route->network)) - continue; - - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route)) - continue; - - /* Ignore routes provided by external sources */ - if (route->rt_source - != nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER)) - continue; - - s_route = nm_ip_route_new_binary(AF_INET6, - &route->network, - route->plen, - &route->gateway, - route->metric, - NULL); - nm_setting_ip_config_add_route(s_ip6, s_route); - nm_ip_route_unref(s_route); - } - - /* DNS */ - for (i = 0; i < nnameservers; i++) { - const struct in6_addr *nameserver = nm_ip6_config_get_nameserver(self, i); - - nm_setting_ip_config_add_dns(s_ip6, _nm_utils_inet6_ntop(nameserver, sbuf)); - } - for (i = 0; i < nsearches; i++) { - const char *search = nm_ip6_config_get_search(self, i); - - nm_setting_ip_config_add_dns_search(s_ip6, search); - } - for (i = 0; i < noptions; i++) { - const char *option = nm_ip6_config_get_dns_option(self, i); - - nm_setting_ip_config_add_dns_option(s_ip6, option); - } - - g_object_set(s_ip6, - NM_SETTING_IP_CONFIG_DNS_PRIORITY, - nm_ip6_config_get_dns_priority(self), - NULL); - - return NM_SETTING(s_ip6); -} - -/*****************************************************************************/ - -void -nm_ip6_config_merge(NMIP6Config * dst, - const NMIP6Config * src, - NMIPConfigMergeFlags merge_flags, - guint32 default_route_metric_penalty) -{ - guint32 i; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP6Address *address = NULL; - const NMIP6ConfigPrivate * src_priv; - - g_return_if_fail(src != NULL); - g_return_if_fail(dst != NULL); - - src_priv = NM_IP6_CONFIG_GET_PRIVATE(src); - - g_object_freeze_notify(G_OBJECT(dst)); - - /* addresses */ - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, src, &address) { - if (NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_EXTERNAL) && !address->external) { - NMPlatformIP6Address a; - - a = *address; - a.external = TRUE; - _add_address(dst, NULL, &a); - } else - _add_address(dst, NMP_OBJECT_UP_CAST(address), NULL); - } - - /* nameservers */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip6_config_get_num_nameservers(src); i++) - nm_ip6_config_add_nameserver(dst, nm_ip6_config_get_nameserver(src, i)); - } - - /* routes */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_ROUTES)) { - const NMPlatformIP6Route *r_src; - - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, src, &r_src) { - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(r_src)) { - if (NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES) - && !NM_FLAGS_HAS(src_priv->config_flags, - NM_IP_CONFIG_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES)) - continue; - if (default_route_metric_penalty) { - NMPlatformIP6Route r = *r_src; - - r.metric = - nm_utils_ip_route_metric_penalize(r.metric, default_route_metric_penalty); - _add_route(dst, NULL, &r, NULL); - continue; - } - } - _add_route(dst, ipconf_iter.current->obj, NULL, NULL); - } - } - - /* domains */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip6_config_get_num_domains(src); i++) - nm_ip6_config_add_domain(dst, nm_ip6_config_get_domain(src, i)); - } - - /* dns searches */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip6_config_get_num_searches(src); i++) - nm_ip6_config_add_search(dst, nm_ip6_config_get_search(src, i)); - } - - /* dns options */ - if (!NM_FLAGS_HAS(merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { - for (i = 0; i < nm_ip6_config_get_num_dns_options(src); i++) - nm_ip6_config_add_dns_option(dst, nm_ip6_config_get_dns_option(src, i)); - } - - /* DNS priority */ - if (nm_ip6_config_get_dns_priority(src)) - nm_ip6_config_set_dns_priority(dst, nm_ip6_config_get_dns_priority(src)); - - g_object_thaw_notify(G_OBJECT(dst)); -} - -/*****************************************************************************/ - -static int -_nameservers_get_index(const NMIP6Config *self, const struct in6_addr *ns) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->nameservers->len; i++) { - const struct in6_addr *n = &g_array_index(priv->nameservers, struct in6_addr, i); - - if (IN6_ARE_ADDR_EQUAL(ns, n)) - return (int) i; - } - return -1; -} - -static int -_domains_get_index(const NMIP6Config *self, const char *domain) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->domains->len; i++) { - const char *d = g_ptr_array_index(priv->domains, i); - - if (g_strcmp0(domain, d) == 0) - return (int) i; - } - return -1; -} - -static int -_searches_get_index(const NMIP6Config *self, const char *search) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->searches->len; i++) { - const char *s = g_ptr_array_index(priv->searches, i); - - if (g_strcmp0(search, s) == 0) - return (int) i; - } - return -1; -} - -static int -_dns_options_get_index(const NMIP6Config *self, const char *option) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - guint i; - - for (i = 0; i < priv->dns_options->len; i++) { - const char *s = g_ptr_array_index(priv->dns_options, i); - - if (g_strcmp0(option, s) == 0) - return (int) i; - } - return -1; -} - -/*****************************************************************************/ - -/** - * nm_ip6_config_subtract: - * @dst: config from which to remove everything in @src - * @src: config to remove from @dst - * @default_route_metric_penalty: pretend that on source we applied - * a route penalty on the default-route. It means, for default routes - * we don't remove routes that match exactly, but those with a lower - * metric (with the penalty removed). -* - * Removes everything in @src from @dst. - */ -void -nm_ip6_config_subtract(NMIP6Config * dst, - const NMIP6Config *src, - guint32 default_route_metric_penalty) -{ - NMIP6ConfigPrivate * dst_priv; - guint i; - int idx; - const NMPlatformIP6Address *a; - const NMPlatformIP6Route * r; - NMDedupMultiIter ipconf_iter; - gboolean changed; - gboolean changed_default_route; - - g_return_if_fail(src != NULL); - g_return_if_fail(dst != NULL); - - dst_priv = NM_IP6_CONFIG_GET_PRIVATE(dst); - - g_object_freeze_notify(G_OBJECT(dst)); - - /* addresses */ - changed = FALSE; - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, src, &a) { - if (nm_dedup_multi_index_remove_obj(dst_priv->multi_idx, - &dst_priv->idx_ip6_addresses, - NMP_OBJECT_UP_CAST(a), - NULL)) - changed = TRUE; - } - if (changed) - _notify_addresses(dst); - - /* nameservers */ - for (i = 0; i < nm_ip6_config_get_num_nameservers(src); i++) { - idx = _nameservers_get_index(dst, nm_ip6_config_get_nameserver(src, i)); - if (idx >= 0) - nm_ip6_config_del_nameserver(dst, idx); - } - - /* routes */ - changed = FALSE; - changed_default_route = FALSE; - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, src, &r) { - const NMPObject * o_src = NMP_OBJECT_UP_CAST(r); - NMPObject o_lookup_copy; - const NMPObject * o_lookup; - nm_auto_nmpobj const NMPObject *obj_old = NULL; - - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(r) && default_route_metric_penalty) { - NMPlatformIP6Route *rr; - - /* the default route was penalized when merging it to the combined ip-config. - * When subtracting the routes, we must re-do that process when comparing - * the routes. */ - o_lookup = nmp_object_stackinit_obj(&o_lookup_copy, o_src); - rr = NMP_OBJECT_CAST_IP6_ROUTE(&o_lookup_copy); - rr->metric = - nm_utils_ip_route_metric_penalize(rr->metric, default_route_metric_penalty); - } else - o_lookup = o_src; - - if (nm_dedup_multi_index_remove_obj(dst_priv->multi_idx, - &dst_priv->idx_ip6_routes, - o_lookup, - (gconstpointer *) &obj_old)) { - if (dst_priv->best_default_route == obj_old) { - nm_clear_nmp_object(&dst_priv->best_default_route); - changed_default_route = TRUE; - } - changed = TRUE; - } - } - if (changed_default_route) { - nmp_object_ref_set(&dst_priv->best_default_route, - _nm_ip6_config_best_default_route_find(dst)); - _notify(dst, PROP_GATEWAY); - } - if (changed) - _notify_routes(dst); - - /* domains */ - for (i = 0; i < nm_ip6_config_get_num_domains(src); i++) { - idx = _domains_get_index(dst, nm_ip6_config_get_domain(src, i)); - if (idx >= 0) - nm_ip6_config_del_domain(dst, idx); - } - - /* dns searches */ - for (i = 0; i < nm_ip6_config_get_num_searches(src); i++) { - idx = _searches_get_index(dst, nm_ip6_config_get_search(src, i)); - if (idx >= 0) - nm_ip6_config_del_search(dst, idx); - } - - /* dns options */ - for (i = 0; i < nm_ip6_config_get_num_dns_options(src); i++) { - idx = _dns_options_get_index(dst, nm_ip6_config_get_dns_option(src, i)); - if (idx >= 0) - nm_ip6_config_del_dns_option(dst, idx); - } - - /* DNS priority */ - if (nm_ip6_config_get_dns_priority(src) == nm_ip6_config_get_dns_priority(dst)) - nm_ip6_config_set_dns_priority(dst, 0); - - g_object_thaw_notify(G_OBJECT(dst)); -} - -static gboolean -_nm_ip6_config_intersect_helper(NMIP6Config * dst, - const NMIP6Config *src, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty, - gboolean update_dst) -{ - NMIP6ConfigPrivate * dst_priv; - const NMIP6ConfigPrivate * src_priv; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP6Address *a; - const NMPlatformIP6Route * r; - gboolean changed, result = FALSE; - const NMPObject * new_best_default_route; - - g_return_val_if_fail(src, FALSE); - g_return_val_if_fail(dst, FALSE); - - dst_priv = NM_IP6_CONFIG_GET_PRIVATE(dst); - src_priv = NM_IP6_CONFIG_GET_PRIVATE(src); - - if (update_dst) - g_object_freeze_notify(G_OBJECT(dst)); - - /* addresses */ - if (intersect_addresses) { - changed = FALSE; - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, dst, &a) { - if (nm_dedup_multi_index_lookup_obj(src_priv->multi_idx, - &src_priv->idx_ip6_addresses, - NMP_OBJECT_UP_CAST(a))) - continue; - - if (!update_dst) - return TRUE; - - if (nm_dedup_multi_index_remove_entry(dst_priv->multi_idx, ipconf_iter.current) != 1) - nm_assert_not_reached(); - changed = TRUE; - } - if (changed) { - _notify_addresses(dst); - result = TRUE; - } - } - - /* ignore nameservers */ - - /* routes */ - if (!intersect_routes) - goto skip_routes; - - changed = FALSE; - new_best_default_route = NULL; - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, dst, &r) { - const NMPObject *o_dst = NMP_OBJECT_UP_CAST(r); - const NMPObject *o_lookup; - NMPObject o_lookup_copy; - - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(r) && default_route_metric_penalty) { - NMPlatformIP6Route *rr; - - /* the default route was penalized when merging it to the combined ip-config. - * When intersecting the routes, we must re-do that process when comparing - * the routes. */ - o_lookup = nmp_object_stackinit_obj(&o_lookup_copy, o_dst); - rr = NMP_OBJECT_CAST_IP6_ROUTE(&o_lookup_copy); - rr->metric = - nm_utils_ip_route_metric_penalize(rr->metric, default_route_metric_penalty); - } else - o_lookup = o_dst; - - if (nm_dedup_multi_index_lookup_obj(src_priv->multi_idx, - &src_priv->idx_ip6_routes, - o_lookup)) { - new_best_default_route = - _nm_ip_config_best_default_route_find_better(new_best_default_route, o_dst); - continue; - } - - if (!update_dst) - return TRUE; - - if (nm_dedup_multi_index_remove_entry(dst_priv->multi_idx, ipconf_iter.current) != 1) - nm_assert_not_reached(); - changed = TRUE; - } - if (nmp_object_ref_set(&dst_priv->best_default_route, new_best_default_route)) { - nm_assert(changed); - _notify(dst, PROP_GATEWAY); - } - if (changed) { - _notify_routes(dst); - result = TRUE; - } - -skip_routes: - /* ignore domains */ - /* ignore dns searches */ - /* ignore dns options */ - - if (update_dst) - g_object_thaw_notify(G_OBJECT(dst)); - - return result; -} - -/** - * nm_ip6_config_intersect: - * @dst: a configuration to be updated - * @src: another configuration - * @intersect_addresses: whether addresses should be intersected - * @intersect_routes: whether routes should be intersected - * @default_route_metric_penalty: the default route metric penalty - * - * Computes the intersection between @src and @dst and updates @dst in place - * with the result. - */ -void -nm_ip6_config_intersect(NMIP6Config * dst, - const NMIP6Config *src, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty) -{ - _nm_ip6_config_intersect_helper(dst, - src, - intersect_addresses, - intersect_routes, - default_route_metric_penalty, - TRUE); -} - -/** - * nm_ip6_config_intersect_alloc: - * @a: a configuration - * @b: another configuration - * @intersect_addresses: whether addresses should be intersected - * @intersect_routes: whether routes should be intersected - * @default_route_metric_penalty: the default route metric penalty - * - * Computes the intersection between @a and @b and returns the result in a newly - * allocated configuration. As a special case, if @a and @b are identical (with - * respect to the only properties considered - addresses and routes) the - * functions returns NULL so that one of existing configuration can be reused - * without allocation. - * - * Returns: the intersection between @a and @b, or %NULL if the result is equal - * to @a and @b. - */ -NMIP6Config * -nm_ip6_config_intersect_alloc(const NMIP6Config *a, - const NMIP6Config *b, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty) -{ - NMIP6Config *a_copy; - - if (_nm_ip6_config_intersect_helper((NMIP6Config *) a, - b, - intersect_addresses, - intersect_routes, - default_route_metric_penalty, - FALSE)) { - a_copy = nm_ip6_config_clone(a); - _nm_ip6_config_intersect_helper(a_copy, - b, - intersect_addresses, - intersect_routes, - default_route_metric_penalty, - TRUE); - return a_copy; - } else - return NULL; -} - -/** - * nm_ip6_config_replace: - * @dst: config which will be replaced with everything in @src - * @src: config to copy over to @dst - * @relevant_changes: return whether there are changes to the - * destination object that are relevant. This is equal to - * nm_ip6_config_equal() showing any difference. - * - * Replaces everything in @dst with @src so that the two configurations - * contain the same content -- with the exception of the dbus path. - * - * Returns: whether the @dst instance changed in any way (including minor changes, - * that are not signaled by the output parameter @relevant_changes). - */ -gboolean -nm_ip6_config_replace(NMIP6Config *dst, const NMIP6Config *src, gboolean *relevant_changes) -{ -#if NM_MORE_ASSERTS - gboolean config_equal; -#endif - gboolean has_minor_changes = FALSE, has_relevant_changes = FALSE, are_equal; - guint i, num; - NMIP6ConfigPrivate * dst_priv; - const NMIP6ConfigPrivate * src_priv; - NMDedupMultiIter ipconf_iter_src, ipconf_iter_dst; - const NMDedupMultiHeadEntry *head_entry_src; - const NMPObject * new_best_default_route; - - g_return_val_if_fail(NM_IS_IP6_CONFIG(src), FALSE); - g_return_val_if_fail(NM_IS_IP6_CONFIG(dst), FALSE); - g_return_val_if_fail(src != dst, FALSE); - -#if NM_MORE_ASSERTS - config_equal = nm_ip6_config_equal(dst, src); -#endif - - dst_priv = NM_IP6_CONFIG_GET_PRIVATE(dst); - src_priv = NM_IP6_CONFIG_GET_PRIVATE(src); - - g_return_val_if_fail(src_priv->ifindex > 0, FALSE); - - g_object_freeze_notify(G_OBJECT(dst)); - - /* ifindex */ - if (src_priv->ifindex != dst_priv->ifindex) { - dst_priv->ifindex = src_priv->ifindex; - has_minor_changes = TRUE; - } - - /* addresses */ - head_entry_src = nm_ip6_config_lookup_addresses(src); - nm_dedup_multi_iter_init(&ipconf_iter_src, head_entry_src); - nm_ip_config_iter_ip6_address_init(&ipconf_iter_dst, dst); - are_equal = TRUE; - while (TRUE) { - gboolean has; - const NMPlatformIP6Address *r_src = NULL; - const NMPlatformIP6Address *r_dst = NULL; - - has = nm_platform_dedup_multi_iter_next_ip6_address(&ipconf_iter_src, &r_src); - if (has != nm_platform_dedup_multi_iter_next_ip6_address(&ipconf_iter_dst, &r_dst)) { - are_equal = FALSE; - has_relevant_changes = TRUE; - break; - } - if (!has) - break; - - if (nm_platform_ip6_address_cmp(r_src, r_dst) != 0) { - are_equal = FALSE; - if (!IN6_ARE_ADDR_EQUAL(&r_src->address, &r_dst->address) || r_src->plen != r_dst->plen - || !IN6_ARE_ADDR_EQUAL(nm_platform_ip6_address_get_peer(r_src), - nm_platform_ip6_address_get_peer(r_dst))) { - has_relevant_changes = TRUE; - break; - } - } - } - if (!are_equal) { - has_minor_changes = TRUE; - nm_dedup_multi_index_dirty_set_idx(dst_priv->multi_idx, &dst_priv->idx_ip6_addresses); - nm_dedup_multi_iter_for_each (&ipconf_iter_src, head_entry_src) { - _nm_ip_config_add_obj(dst_priv->multi_idx, - &dst_priv->idx_ip6_addresses_, - dst_priv->ifindex, - ipconf_iter_src.current->obj, - NULL, - FALSE, - TRUE, - NULL, - NULL); - } - nm_dedup_multi_index_dirty_remove_idx(dst_priv->multi_idx, - &dst_priv->idx_ip6_addresses, - FALSE); - _notify_addresses(dst); - } - - /* routes */ - head_entry_src = nm_ip6_config_lookup_routes(src); - nm_dedup_multi_iter_init(&ipconf_iter_src, head_entry_src); - nm_ip_config_iter_ip6_route_init(&ipconf_iter_dst, dst); - are_equal = TRUE; - while (TRUE) { - gboolean has; - const NMPlatformIP6Route *r_src = NULL; - const NMPlatformIP6Route *r_dst = NULL; - - has = nm_platform_dedup_multi_iter_next_ip6_route(&ipconf_iter_src, &r_src); - if (has != nm_platform_dedup_multi_iter_next_ip6_route(&ipconf_iter_dst, &r_dst)) { - are_equal = FALSE; - has_relevant_changes = TRUE; - break; - } - if (!has) - break; - - if (nm_platform_ip6_route_cmp_full(r_src, r_dst) != 0) { - are_equal = FALSE; - if (r_src->plen != r_dst->plen - || !nm_utils_ip6_address_same_prefix(&r_src->network, &r_dst->network, r_src->plen) - || r_src->metric != r_dst->metric - || !IN6_ARE_ADDR_EQUAL(&r_src->gateway, &r_dst->gateway)) { - has_relevant_changes = TRUE; - break; - } - } - } - if (!are_equal) { - has_minor_changes = TRUE; - new_best_default_route = NULL; - nm_dedup_multi_index_dirty_set_idx(dst_priv->multi_idx, &dst_priv->idx_ip6_routes); - nm_dedup_multi_iter_for_each (&ipconf_iter_src, head_entry_src) { - const NMPObject *o = ipconf_iter_src.current->obj; - const NMPObject *obj_new; - - _nm_ip_config_add_obj(dst_priv->multi_idx, - &dst_priv->idx_ip6_routes_, - dst_priv->ifindex, - o, - NULL, - FALSE, - TRUE, - NULL, - &obj_new); - new_best_default_route = - _nm_ip_config_best_default_route_find_better(new_best_default_route, obj_new); - } - nm_dedup_multi_index_dirty_remove_idx(dst_priv->multi_idx, - &dst_priv->idx_ip6_routes, - FALSE); - if (nmp_object_ref_set(&dst_priv->best_default_route, new_best_default_route)) - _notify(dst, PROP_GATEWAY); - _notify_routes(dst); - } - - /* nameservers */ - num = nm_ip6_config_get_num_nameservers(src); - are_equal = num == nm_ip6_config_get_num_nameservers(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (!IN6_ARE_ADDR_EQUAL(nm_ip6_config_get_nameserver(src, i), - nm_ip6_config_get_nameserver(dst, i))) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip6_config_reset_nameservers(dst); - for (i = 0; i < num; i++) - nm_ip6_config_add_nameserver(dst, nm_ip6_config_get_nameserver(src, i)); - has_relevant_changes = TRUE; - } - - /* domains */ - num = nm_ip6_config_get_num_domains(src); - are_equal = num == nm_ip6_config_get_num_domains(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (g_strcmp0(nm_ip6_config_get_domain(src, i), nm_ip6_config_get_domain(dst, i))) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip6_config_reset_domains(dst); - for (i = 0; i < num; i++) - nm_ip6_config_add_domain(dst, nm_ip6_config_get_domain(src, i)); - has_relevant_changes = TRUE; - } - - /* dns searches */ - num = nm_ip6_config_get_num_searches(src); - are_equal = num == nm_ip6_config_get_num_searches(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (g_strcmp0(nm_ip6_config_get_search(src, i), nm_ip6_config_get_search(dst, i))) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip6_config_reset_searches(dst); - for (i = 0; i < num; i++) - nm_ip6_config_add_search(dst, nm_ip6_config_get_search(src, i)); - has_relevant_changes = TRUE; - } - - /* dns options */ - num = nm_ip6_config_get_num_dns_options(src); - are_equal = num == nm_ip6_config_get_num_dns_options(dst); - if (are_equal) { - for (i = 0; i < num; i++) { - if (g_strcmp0(nm_ip6_config_get_dns_option(src, i), - nm_ip6_config_get_dns_option(dst, i))) { - are_equal = FALSE; - break; - } - } - } - if (!are_equal) { - nm_ip6_config_reset_dns_options(dst); - for (i = 0; i < num; i++) - nm_ip6_config_add_dns_option(dst, nm_ip6_config_get_dns_option(src, i)); - has_relevant_changes = TRUE; - } - - /* DNS priority */ - if (src_priv->dns_priority != dst_priv->dns_priority) { - nm_ip6_config_set_dns_priority(dst, src_priv->dns_priority); - has_minor_changes = TRUE; - } - - if (src_priv->privacy != dst_priv->privacy) { - nm_ip6_config_set_privacy(dst, src_priv->privacy); - has_minor_changes = TRUE; - } - -#if NM_MORE_ASSERTS - /* config_equal does not compare *all* the fields, therefore, we might have has_minor_changes - * regardless of config_equal. But config_equal must correspond to has_relevant_changes. */ - nm_assert(config_equal == !has_relevant_changes); -#endif - - g_object_thaw_notify(G_OBJECT(dst)); - - if (relevant_changes) - *relevant_changes = has_relevant_changes; - - return has_relevant_changes || has_minor_changes; -} - -/*****************************************************************************/ - -void -nm_ip6_config_reset_addresses_ndisc(NMIP6Config * self, - const NMNDiscAddress *addresses, - guint addresses_n, - guint8 plen, - guint32 ifa_flags) -{ - NMIP6ConfigPrivate *priv; - guint i; - gboolean changed = FALSE; - gint32 base_time_sec; - - g_return_if_fail(NM_IS_IP6_CONFIG(self)); - - priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(priv->ifindex > 0); - - /* the base-timestamp doesn't matter it's only an anchor for the - * expiry. However, try to re-use the same base-time for a while - * by rounding it to 10000 seconds. - * - * That is because we deduplicate and NMPlatformIP6Address instances - * so using the same timestamps is preferable. */ - base_time_sec = nm_utils_get_monotonic_timestamp_sec(); - base_time_sec = (base_time_sec / 10000) * 10000; - base_time_sec = NM_MAX(1, base_time_sec); - - nm_dedup_multi_index_dirty_set_idx(priv->multi_idx, &priv->idx_ip6_addresses); - - for (i = 0; i < addresses_n; i++) { - const NMNDiscAddress *ndisc_addr = &addresses[i]; - NMPObject obj; - NMPlatformIP6Address *a; - - nmp_object_stackinit(&obj, NMP_OBJECT_TYPE_IP6_ADDRESS, NULL); - a = NMP_OBJECT_CAST_IP6_ADDRESS(&obj); - a->ifindex = priv->ifindex; - a->address = ndisc_addr->address; - a->plen = plen; - a->timestamp = base_time_sec, - a->lifetime = _nm_ndisc_lifetime_from_expiry(((gint64) base_time_sec) * 1000, - ndisc_addr->expiry_msec, - TRUE), - a->preferred = _nm_ndisc_lifetime_from_expiry(((gint64) base_time_sec) * 1000, - ndisc_addr->expiry_preferred_msec, - TRUE), - a->addr_source = NM_IP_CONFIG_SOURCE_NDISC; - a->n_ifa_flags = ifa_flags; - - if (_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip6_addresses_, - priv->ifindex, - &obj, - NULL, - FALSE, - TRUE, - NULL, - NULL)) - changed = TRUE; - } - - if (nm_dedup_multi_index_dirty_remove_idx(priv->multi_idx, &priv->idx_ip6_addresses, FALSE) > 0) - changed = TRUE; - - if (changed) - _notify_addresses(self); -} - -void -nm_ip6_config_reset_addresses(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (nm_dedup_multi_index_remove_idx(priv->multi_idx, &priv->idx_ip6_addresses) > 0) - _notify_addresses(self); -} - -static void -_add_address(NMIP6Config *self, const NMPObject *obj_new, const NMPlatformIP6Address *new) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip6_addresses_, - priv->ifindex, - obj_new, - (const NMPlatformObject *) new, - TRUE, - FALSE, - NULL, - NULL)) - _notify_addresses(self); -} - -/** - * nm_ip6_config_add_address: - * @self: the #NMIP6Config - * @new: the new address to add to @self - * - * Adds the new address to @self. If an address with the same basic properties - * (address, prefix) already exists in @self, it is overwritten with the - * lifetime and preferred of @new. The source is also overwritten by the source - * from @new if that source is higher priority. - */ -void -nm_ip6_config_add_address(NMIP6Config *self, const NMPlatformIP6Address *new) -{ - g_return_if_fail(self); - g_return_if_fail(new); - g_return_if_fail(new->plen <= 128); - g_return_if_fail(NM_IP6_CONFIG_GET_PRIVATE(self)->ifindex > 0); - - _add_address(self, NULL, new); -} - -void -_nmtst_ip6_config_del_address(NMIP6Config *self, guint i) -{ - const NMPlatformIP6Address *a; - - a = _nmtst_ip6_config_get_address(self, i); - if (!nm_ip6_config_nmpobj_remove(self, NMP_OBJECT_UP_CAST(a))) - g_assert_not_reached(); -} - -guint -nm_ip6_config_get_num_addresses(const NMIP6Config *self) -{ - const NMDedupMultiHeadEntry *head_entry; - - head_entry = nm_ip6_config_lookup_addresses(self); - return head_entry ? head_entry->len : 0; -} - -const NMPlatformIP6Address * -nm_ip6_config_get_first_address(const NMIP6Config *self) -{ - NMDedupMultiIter iter; - const NMPlatformIP6Address *a = NULL; - - nm_ip_config_iter_ip6_address_for_each (&iter, self, &a) - return a; - return NULL; -} - -const NMPlatformIP6Address * -_nmtst_ip6_config_get_address(const NMIP6Config *self, guint i) -{ - NMDedupMultiIter iter; - const NMPlatformIP6Address *a = NULL; - guint j; - - j = 0; - nm_ip_config_iter_ip6_address_for_each (&iter, self, &a) { - if (i == j) - return a; - j++; - } - g_return_val_if_reached(NULL); -} - -const NMPlatformIP6Address * -nm_ip6_config_lookup_address(const NMIP6Config *self, const struct in6_addr *addr) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - NMPObject obj_stack; - const NMDedupMultiEntry * entry; - - nmp_object_stackinit_id_ip6_address(&obj_stack, priv->ifindex, addr); - entry = nm_dedup_multi_index_lookup_obj(priv->multi_idx, &priv->idx_ip6_addresses, &obj_stack); - return entry ? NMP_OBJECT_CAST_IP6_ADDRESS(entry->obj) : NULL; -} - -/** - * nm_ip6_config_has_dad_pending_addresses - * @self: configuration containing the addresses to check - * @candidates: configuration with the list of addresses we are - * interested in - * - * Check whether there are addresses with DAD pending in @self, that - * are also contained in @candidates. - * - * Returns: %TRUE if at least one matching address was found, %FALSE - * otherwise - */ -gboolean -nm_ip6_config_has_any_dad_pending(const NMIP6Config *self, const NMIP6Config *candidates) -{ - NMDedupMultiIter ipconf_iter; - const NMPlatformIP6Address *addr, *addr_c; - - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, self, &addr) { - if (NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_TENTATIVE) - && !NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_DADFAILED) - && !NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_OPTIMISTIC)) { - addr_c = nm_ip6_config_lookup_address(candidates, &addr->address); - if (addr_c) { - if (addr->plen == addr_c->plen) - return TRUE; - } - } - } - - return FALSE; -} - -/*****************************************************************************/ - -static const NMDedupMultiEntry * -_lookup_route(const NMIP6Config *self, const NMPObject *needle, NMPlatformIPRouteCmpType cmp_type) -{ - const NMIP6ConfigPrivate *priv; - - nm_assert(NM_IS_IP6_CONFIG(self)); - nm_assert(NMP_OBJECT_GET_TYPE(needle) == NMP_OBJECT_TYPE_IP6_ROUTE); - - priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return _nm_ip_config_lookup_ip_route(priv->multi_idx, &priv->idx_ip6_routes_, needle, cmp_type); -} - -void -nm_ip6_config_reset_routes_ndisc(NMIP6Config * self, - const NMNDiscGateway *gateways, - guint gateways_n, - const NMNDiscRoute * routes, - guint routes_n, - guint32 route_table, - guint32 route_metric) -{ - NMIP6ConfigPrivate *priv; - guint i; - gboolean changed = FALSE; - const NMPObject * new_best_default_route; - - g_return_if_fail(NM_IS_IP6_CONFIG(self)); - - priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(priv->ifindex > 0); - - nm_dedup_multi_index_dirty_set_idx(priv->multi_idx, &priv->idx_ip6_routes); - - new_best_default_route = NULL; - for (i = 0; i < routes_n; i++) { - const NMNDiscRoute *ndisc_route = &routes[i]; - NMPObject obj; - const NMPObject * obj_new; - NMPlatformIP6Route *r; - - nmp_object_stackinit(&obj, NMP_OBJECT_TYPE_IP6_ROUTE, NULL); - r = NMP_OBJECT_CAST_IP6_ROUTE(&obj); - r->ifindex = priv->ifindex; - r->network = ndisc_route->network; - r->plen = ndisc_route->plen; - r->gateway = ndisc_route->gateway; - r->rt_source = NM_IP_CONFIG_SOURCE_NDISC; - r->table_coerced = nm_platform_route_table_coerce(route_table); - r->metric = route_metric; - r->rt_pref = ndisc_route->preference; - nm_assert((NMIcmpv6RouterPref) r->rt_pref == ndisc_route->preference); - - if (_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip6_routes_, - priv->ifindex, - &obj, - NULL, - FALSE, - TRUE, - NULL, - &obj_new)) - changed = TRUE; - new_best_default_route = - _nm_ip_config_best_default_route_find_better(new_best_default_route, obj_new); - } - - if (gateways_n) { - const NMPObject * obj_new; - NMPlatformIP6Route r = { - .rt_source = NM_IP_CONFIG_SOURCE_NDISC, - .ifindex = priv->ifindex, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, - }; - - for (i = 0; i < gateways_n; i++) { - r.gateway = gateways[i].address; - r.rt_pref = gateways[i].preference; - nm_assert((NMIcmpv6RouterPref) r.rt_pref == gateways[i].preference); - if (_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip6_routes_, - priv->ifindex, - NULL, - (const NMPlatformObject *) &r, - FALSE, - TRUE, - NULL, - &obj_new)) - changed = TRUE; - new_best_default_route = - _nm_ip_config_best_default_route_find_better(new_best_default_route, obj_new); - } - } - - if (nm_dedup_multi_index_dirty_remove_idx(priv->multi_idx, &priv->idx_ip6_routes, FALSE) > 0) - changed = TRUE; - - if (nmp_object_ref_set(&priv->best_default_route, new_best_default_route)) { - changed = TRUE; - _notify(self, PROP_GATEWAY); - } - - if (changed) - _notify_routes(self); -} - -void -nm_ip6_config_reset_routes(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (nm_dedup_multi_index_remove_idx(priv->multi_idx, &priv->idx_ip6_routes) > 0) { - if (nm_clear_nmp_object(&priv->best_default_route)) - _notify(self, PROP_GATEWAY); - _notify_routes(self); - } -} - -static void -_add_route(NMIP6Config * self, - const NMPObject *obj_new, - const NMPlatformIP6Route *new, - const NMPObject **out_obj_new) -{ - NMIP6ConfigPrivate * priv = NM_IP6_CONFIG_GET_PRIVATE(self); - nm_auto_nmpobj const NMPObject *obj_old = NULL; - const NMPObject * obj_new_2; - - nm_assert((!new) != (!obj_new)); - nm_assert(!new || _route_valid(new)); - nm_assert(!obj_new || _route_valid(NMP_OBJECT_CAST_IP6_ROUTE(obj_new))); - - if (_nm_ip_config_add_obj(priv->multi_idx, - &priv->idx_ip6_routes_, - priv->ifindex, - obj_new, - (const NMPlatformObject *) new, - TRUE, - FALSE, - &obj_old, - &obj_new_2)) { - gboolean changed_default_route = FALSE; - - if (priv->best_default_route == obj_old && obj_old != obj_new_2) { - changed_default_route = TRUE; - nm_clear_nmp_object(&priv->best_default_route); - } - NM_SET_OUT(out_obj_new, nmp_object_ref(obj_new_2)); - if (_nm_ip_config_best_default_route_merge(&priv->best_default_route, obj_new_2)) - changed_default_route = TRUE; - - if (changed_default_route) - _notify(self, PROP_GATEWAY); - _notify_routes(self); - } else - NM_SET_OUT(out_obj_new, nmp_object_ref(obj_new_2)); -} - -/** - * nm_ip6_config_add_route: - * @self: the #NMIP6Config - * @new: the new route to add to @self - * @out_obj_new: (allow-none) (out): the added route object. Must be unrefed - * by caller. - * - * Adds the new route to @self. If a route with the same basic properties - * (network, prefix) already exists in @self, it is overwritten including the - * gateway and metric of @new. The source is also overwritten by the source - * from @new if that source is higher priority. - */ -void -nm_ip6_config_add_route(NMIP6Config *self, - const NMPlatformIP6Route *new, - const NMPObject **out_obj_new) -{ - g_return_if_fail(self); - g_return_if_fail(new); - g_return_if_fail(new->plen <= 128); - g_return_if_fail(NM_IP6_CONFIG_GET_PRIVATE(self)->ifindex > 0); - - _add_route(self, NULL, new, out_obj_new); -} - -void -_nmtst_ip6_config_del_route(NMIP6Config *self, guint i) -{ - const NMPlatformIP6Route *r; - - r = _nmtst_ip6_config_get_route(self, i); - if (!nm_ip6_config_nmpobj_remove(self, NMP_OBJECT_UP_CAST(r))) - g_assert_not_reached(); -} - -guint -nm_ip6_config_get_num_routes(const NMIP6Config *self) -{ - const NMDedupMultiHeadEntry *head_entry; - - head_entry = nm_ip6_config_lookup_routes(self); - nm_assert(!head_entry || head_entry->len == c_list_length(&head_entry->lst_entries_head)); - return head_entry ? head_entry->len : 0; -} - -const NMPlatformIP6Route * -_nmtst_ip6_config_get_route(const NMIP6Config *self, guint i) -{ - NMDedupMultiIter iter; - const NMPlatformIP6Route *r = NULL; - guint j; - - j = 0; - nm_ip_config_iter_ip6_route_for_each (&iter, self, &r) { - if (i == j) - return r; - j++; - } - g_return_val_if_reached(NULL); -} - -const NMPlatformIP6Route * -nm_ip6_config_get_direct_route_for_host(const NMIP6Config * self, - const struct in6_addr *host, - guint32 route_table) -{ - const NMPlatformIP6Route *best_route = NULL; - const NMPlatformIP6Route *item; - NMDedupMultiIter ipconf_iter; - - g_return_val_if_fail(host && !IN6_IS_ADDR_UNSPECIFIED(host), NULL); - - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, self, &item) { - if (!IN6_IS_ADDR_UNSPECIFIED(&item->gateway)) - continue; - - if (best_route && best_route->plen > item->plen) - continue; - - if (nm_platform_route_table_uncoerce(item->table_coerced, TRUE) != route_table) - continue; - - if (!nm_utils_ip6_address_same_prefix(host, &item->network, item->plen)) - continue; - - if (best_route && best_route->metric <= item->metric) - continue; - - best_route = item; - } - return best_route; -} - -const NMPlatformIP6Address * -nm_ip6_config_get_subnet_for_host(const NMIP6Config *self, const struct in6_addr *host) -{ - NMDedupMultiIter iter; - const NMPlatformIP6Address *item; - const NMPlatformIP6Address *subnet = NULL; - struct in6_addr subnet2, host2; - - g_return_val_if_fail(host && !IN6_IS_ADDR_UNSPECIFIED(host), NULL); - - nm_ip_config_iter_ip6_address_for_each (&iter, self, &item) { - if (subnet && subnet->plen >= item->plen) - continue; - - nm_utils_ip6_address_clear_host_address(&host2, host, item->plen); - nm_utils_ip6_address_clear_host_address(&subnet2, &item->address, item->plen); - - if (IN6_ARE_ADDR_EQUAL(&subnet2, &host2)) - subnet = item; - } - - return subnet; -} - -/*****************************************************************************/ - -void -nm_ip6_config_reset_nameservers(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (priv->nameservers->len != 0) { - g_array_set_size(priv->nameservers, 0); - _notify(self, PROP_NAMESERVERS); - } -} - -void -nm_ip6_config_add_nameserver(NMIP6Config *self, const struct in6_addr *new) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - int i; - - g_return_if_fail(new != NULL); - - for (i = 0; i < priv->nameservers->len; i++) - if (IN6_ARE_ADDR_EQUAL(new, &g_array_index(priv->nameservers, struct in6_addr, i))) - return; - - g_array_append_val(priv->nameservers, *new); - _notify(self, PROP_NAMESERVERS); -} - -void -nm_ip6_config_del_nameserver(NMIP6Config *self, guint i) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->nameservers->len); - - g_array_remove_index(priv->nameservers, i); - _notify(self, PROP_NAMESERVERS); -} - -guint -nm_ip6_config_get_num_nameservers(const NMIP6Config *self) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return priv->nameservers->len; -} - -const struct in6_addr * -nm_ip6_config_get_nameserver(const NMIP6Config *self, guint i) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return &g_array_index(priv->nameservers, struct in6_addr, i); -} - -/*****************************************************************************/ - -void -nm_ip6_config_reset_domains(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (priv->domains->len != 0) { - g_ptr_array_set_size(priv->domains, 0); - _notify(self, PROP_DOMAINS); - } -} - -void -nm_ip6_config_add_domain(NMIP6Config *self, const char *domain) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (_nm_ip_config_check_and_add_domain(priv->domains, domain)) - _notify(self, PROP_DOMAINS); -} - -void -nm_ip6_config_del_domain(NMIP6Config *self, guint i) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->domains->len); - - g_ptr_array_remove_index(priv->domains, i); - _notify(self, PROP_DOMAINS); -} - -guint -nm_ip6_config_get_num_domains(const NMIP6Config *self) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return priv->domains->len; -} - -const char * -nm_ip6_config_get_domain(const NMIP6Config *self, guint i) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return g_ptr_array_index(priv->domains, i); -} - -/*****************************************************************************/ - -void -nm_ip6_config_reset_searches(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (priv->searches->len != 0) { - g_ptr_array_set_size(priv->searches, 0); - _notify(self, PROP_SEARCHES); - } -} - -void -nm_ip6_config_add_search(NMIP6Config *self, const char *search) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (_nm_ip_config_check_and_add_domain(priv->searches, search)) - _notify(self, PROP_SEARCHES); -} - -void -nm_ip6_config_del_search(NMIP6Config *self, guint i) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->searches->len); - - g_ptr_array_remove_index(priv->searches, i); - _notify(self, PROP_SEARCHES); -} - -guint -nm_ip6_config_get_num_searches(const NMIP6Config *self) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return priv->searches->len; -} - -const char * -nm_ip6_config_get_search(const NMIP6Config *self, guint i) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return g_ptr_array_index(priv->searches, i); -} - -/*****************************************************************************/ - -void -nm_ip6_config_reset_dns_options(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (priv->dns_options->len != 0) { - g_ptr_array_set_size(priv->dns_options, 0); - _notify(self, PROP_DNS_OPTIONS); - } -} - -void -nm_ip6_config_add_dns_option(NMIP6Config *self, const char *new) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - int i; - - g_return_if_fail(new != NULL); - g_return_if_fail(new[0] != '\0'); - - for (i = 0; i < priv->dns_options->len; i++) - if (!g_strcmp0(g_ptr_array_index(priv->dns_options, i), new)) - return; - - g_ptr_array_add(priv->dns_options, g_strdup(new)); - _notify(self, PROP_DNS_OPTIONS); -} - -void -nm_ip6_config_del_dns_option(NMIP6Config *self, guint i) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - g_return_if_fail(i < priv->dns_options->len); - - g_ptr_array_remove_index(priv->dns_options, i); - _notify(self, PROP_DNS_OPTIONS); -} - -guint -nm_ip6_config_get_num_dns_options(const NMIP6Config *self) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return priv->dns_options->len; -} - -const char * -nm_ip6_config_get_dns_option(const NMIP6Config *self, guint i) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return g_ptr_array_index(priv->dns_options, i); -} - -/*****************************************************************************/ - -NMIPConfigFlags -nm_ip6_config_get_config_flags(const NMIP6Config *self) -{ - return NM_IP6_CONFIG_GET_PRIVATE(self)->config_flags; -} - -void -nm_ip6_config_set_config_flags(NMIP6Config *self, NMIPConfigFlags flags, NMIPConfigFlags mask) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (mask == 0) { - /* for convenience, accept 0 mask to set any flags. */ - mask = flags; - } - - nm_assert(!NM_FLAGS_ANY(flags, ~mask)); - priv->config_flags = (flags & mask) | (priv->config_flags & ~mask); -} - -/*****************************************************************************/ - -void -nm_ip6_config_set_dns_priority(NMIP6Config *self, int priority) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - if (priority != priv->dns_priority) { - priv->dns_priority = priority; - _notify(self, PROP_DNS_PRIORITY); - } -} - -int -nm_ip6_config_get_dns_priority(const NMIP6Config *self) -{ - const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - return priv->dns_priority; -} - -/*****************************************************************************/ - -const NMPObject * -nm_ip6_config_nmpobj_lookup(const NMIP6Config *self, const NMPObject *needle) -{ - const NMIP6ConfigPrivate * priv; - const NMDedupMultiIdxType *idx_type; - - g_return_val_if_fail(NM_IS_IP6_CONFIG(self), NULL); - - priv = NM_IP6_CONFIG_GET_PRIVATE(self); - switch (NMP_OBJECT_GET_TYPE(needle)) { - case NMP_OBJECT_TYPE_IP6_ADDRESS: - idx_type = &priv->idx_ip6_addresses; - break; - case NMP_OBJECT_TYPE_IP6_ROUTE: - idx_type = &priv->idx_ip6_routes; - break; - default: - g_return_val_if_reached(NULL); - } - - return nm_dedup_multi_entry_get_obj( - nm_dedup_multi_index_lookup_obj(priv->multi_idx, idx_type, needle)); -} - -gboolean -nm_ip6_config_nmpobj_remove(NMIP6Config *self, const NMPObject *needle) -{ - NMIP6ConfigPrivate * priv; - NMDedupMultiIdxType *idx_type; - nm_auto_nmpobj const NMPObject *obj_old = NULL; - guint n; - - g_return_val_if_fail(NM_IS_IP6_CONFIG(self), FALSE); - - priv = NM_IP6_CONFIG_GET_PRIVATE(self); - switch (NMP_OBJECT_GET_TYPE(needle)) { - case NMP_OBJECT_TYPE_IP6_ADDRESS: - idx_type = &priv->idx_ip6_addresses; - break; - case NMP_OBJECT_TYPE_IP6_ROUTE: - idx_type = &priv->idx_ip6_routes; - break; - default: - g_return_val_if_reached(FALSE); - } - - n = nm_dedup_multi_index_remove_obj(priv->multi_idx, - idx_type, - needle, - (gconstpointer *) &obj_old); - if (n != 1) { - nm_assert(n == 0); - return FALSE; - } - - nm_assert(NMP_OBJECT_GET_TYPE(obj_old) == NMP_OBJECT_GET_TYPE(needle)); - - switch (NMP_OBJECT_GET_TYPE(obj_old)) { - case NMP_OBJECT_TYPE_IP6_ADDRESS: - _notify_addresses(self); - break; - case NMP_OBJECT_TYPE_IP6_ROUTE: - if (priv->best_default_route == obj_old) { - if (nmp_object_ref_set(&priv->best_default_route, - _nm_ip6_config_best_default_route_find(self))) - _notify(self, PROP_GATEWAY); - } - _notify_routes(self); - break; - default: - nm_assert_not_reached(); - } - return TRUE; -} - -/*****************************************************************************/ - -static void -hash_u32(GChecksum *sum, guint32 n) -{ - g_checksum_update(sum, (const guint8 *) &n, sizeof(n)); -} - -static void -hash_in6addr(GChecksum *sum, const struct in6_addr *a) -{ - if (a) - g_checksum_update(sum, (const guint8 *) a, sizeof(*a)); - else - g_checksum_update(sum, (const guint8 *) &in6addr_any, sizeof(in6addr_any)); -} - -void -nm_ip6_config_hash(const NMIP6Config *self, GChecksum *sum, gboolean dns_only) -{ - guint32 i; - const char * s; - NMDedupMultiIter ipconf_iter; - const NMPlatformIP6Address *address; - const NMPlatformIP6Route * route; - - g_return_if_fail(self); - g_return_if_fail(sum); - - if (dns_only == FALSE) { - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, self, &address) { - hash_in6addr(sum, &address->address); - hash_u32(sum, address->plen); - } - - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, self, &route) { - hash_in6addr(sum, &route->network); - hash_u32(sum, route->plen); - hash_in6addr(sum, &route->gateway); - hash_u32(sum, route->metric); - } - } - - for (i = 0; i < nm_ip6_config_get_num_nameservers(self); i++) - hash_in6addr(sum, nm_ip6_config_get_nameserver(self, i)); - - for (i = 0; i < nm_ip6_config_get_num_domains(self); i++) { - s = nm_ip6_config_get_domain(self, i); - g_checksum_update(sum, (const guint8 *) s, strlen(s)); - } - - for (i = 0; i < nm_ip6_config_get_num_searches(self); i++) { - s = nm_ip6_config_get_search(self, i); - g_checksum_update(sum, (const guint8 *) s, strlen(s)); - } - - for (i = 0; i < nm_ip6_config_get_num_dns_options(self); i++) { - s = nm_ip6_config_get_dns_option(self, i); - g_checksum_update(sum, (const guint8 *) s, strlen(s)); - } -} - -/** - * nm_ip6_config_equal: - * @a: first config to compare - * @b: second config to compare - * - * Compares two #NMIP6Configs for basic equality. This means that all - * attributes must exist in the same order in both configs (addresses, routes, - * domains, DNS servers, etc) but some attributes (address lifetimes, and address - * and route sources) are ignored. - * - * Returns: %TRUE if the configurations are basically equal to each other, - * %FALSE if not - */ -gboolean -nm_ip6_config_equal(const NMIP6Config *a, const NMIP6Config *b) -{ - nm_auto_free_checksum GChecksum *a_checksum = g_checksum_new(G_CHECKSUM_SHA1); - nm_auto_free_checksum GChecksum *b_checksum = g_checksum_new(G_CHECKSUM_SHA1); - guint8 a_data[NM_UTILS_CHECKSUM_LENGTH_SHA1]; - guint8 b_data[NM_UTILS_CHECKSUM_LENGTH_SHA1]; - - if (a) - nm_ip6_config_hash(a, a_checksum, FALSE); - if (b) - nm_ip6_config_hash(b, b_checksum, FALSE); - - nm_utils_checksum_get_digest(a_checksum, a_data); - nm_utils_checksum_get_digest(b_checksum, b_data); - return !memcmp(a_data, b_data, sizeof(a_data)); -} - -/*****************************************************************************/ - -static void -nameservers_to_gvalue(GArray *array, GValue *value) -{ - GVariantBuilder builder; - guint i = 0; - - g_variant_builder_init(&builder, G_VARIANT_TYPE("aay")); - - while (array && (i < array->len)) { - struct in6_addr *addr; - - addr = &g_array_index(array, struct in6_addr, i++); - g_variant_builder_add(&builder, "@ay", nm_g_variant_new_ay_in6addr(addr)); - } - - g_value_take_variant(value, g_variant_builder_end(&builder)); -} - -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMIP6Config * self = NM_IP6_CONFIG(object); - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - switch (prop_id) { - case PROP_IFINDEX: - g_value_set_int(value, priv->ifindex); - break; - case PROP_ADDRESS_DATA: - case PROP_ADDRESSES: - nm_assert(!!priv->address_data_variant == !!priv->addresses_variant); - - if (!priv->address_data_variant) { - nm_utils_ip_addresses_to_dbus(AF_INET6, - nm_ip6_config_lookup_addresses(self), - priv->best_default_route, - priv->privacy, - &priv->address_data_variant, - &priv->addresses_variant); - g_variant_ref_sink(priv->address_data_variant); - g_variant_ref_sink(priv->addresses_variant); - } - g_value_set_variant(value, - prop_id == PROP_ADDRESS_DATA ? priv->address_data_variant - : priv->addresses_variant); - break; - - case PROP_ROUTE_DATA: - case PROP_ROUTES: - nm_assert(!!priv->route_data_variant == !!priv->routes_variant); - - if (!priv->route_data_variant) { - nm_utils_ip_routes_to_dbus(AF_INET6, - nm_ip6_config_lookup_routes(self), - &priv->route_data_variant, - &priv->routes_variant); - g_variant_ref_sink(priv->route_data_variant); - g_variant_ref_sink(priv->routes_variant); - } - - g_value_set_variant(value, - prop_id == PROP_ROUTE_DATA ? priv->route_data_variant - : priv->routes_variant); - break; - case PROP_GATEWAY: - if (priv->best_default_route) { - g_value_take_string(value, - nm_utils_inet6_ntop_dup( - &NMP_OBJECT_CAST_IP6_ROUTE(priv->best_default_route)->gateway)); - } else - g_value_set_string(value, NULL); - break; - case PROP_NAMESERVERS: - nameservers_to_gvalue(priv->nameservers, value); - break; - case PROP_DOMAINS: - nm_utils_g_value_set_strv(value, priv->domains); - break; - case PROP_SEARCHES: - nm_utils_g_value_set_strv(value, priv->searches); - break; - case PROP_DNS_OPTIONS: - nm_utils_g_value_set_strv(value, priv->dns_options); - break; - case PROP_DNS_PRIORITY: - g_value_set_int(value, priv->dns_priority); - 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) -{ - NMIP6Config * self = NM_IP6_CONFIG(object); - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - switch (prop_id) { - case PROP_MULTI_IDX: - /* construct-only */ - priv->multi_idx = g_value_get_pointer(value); - if (!priv->multi_idx) - g_return_if_reached(); - nm_dedup_multi_index_ref(priv->multi_idx); - break; - case PROP_IFINDEX: - /* construct-only */ - priv->ifindex = g_value_get_int(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void -nm_ip6_config_init(NMIP6Config *self) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - nm_ip_config_dedup_multi_idx_type_init((NMIPConfigDedupMultiIdxType *) &priv->idx_ip6_addresses, - NMP_OBJECT_TYPE_IP6_ADDRESS); - nm_ip_config_dedup_multi_idx_type_init((NMIPConfigDedupMultiIdxType *) &priv->idx_ip6_routes, - NMP_OBJECT_TYPE_IP6_ROUTE); - - priv->nameservers = g_array_new(FALSE, TRUE, sizeof(struct in6_addr)); - priv->domains = g_ptr_array_new_with_free_func(g_free); - priv->searches = g_ptr_array_new_with_free_func(g_free); - priv->dns_options = g_ptr_array_new_with_free_func(g_free); -} - -NMIP6Config * -nm_ip6_config_new(NMDedupMultiIndex *multi_idx, int ifindex) -{ - g_return_val_if_fail(ifindex >= -1, NULL); - return g_object_new(NM_TYPE_IP6_CONFIG, - NM_IP6_CONFIG_MULTI_IDX, - multi_idx, - NM_IP6_CONFIG_IFINDEX, - ifindex, - NULL); -} - -NMIP6Config * -nm_ip6_config_new_cloned(const NMIP6Config *src) -{ - NMIP6Config *new; - - g_return_val_if_fail(NM_IS_IP6_CONFIG(src), NULL); - - new = nm_ip6_config_new(nm_ip6_config_get_multi_idx(src), nm_ip6_config_get_ifindex(src)); - nm_ip6_config_replace(new, src, NULL); - return new; -} - -static void -finalize(GObject *object) -{ - NMIP6Config * self = NM_IP6_CONFIG(object); - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); - - nm_clear_nmp_object(&priv->best_default_route); - - nm_dedup_multi_index_remove_idx(priv->multi_idx, &priv->idx_ip6_addresses); - nm_dedup_multi_index_remove_idx(priv->multi_idx, &priv->idx_ip6_routes); - - nm_clear_g_variant(&priv->address_data_variant); - nm_clear_g_variant(&priv->addresses_variant); - nm_clear_g_variant(&priv->route_data_variant); - nm_clear_g_variant(&priv->routes_variant); - - g_array_unref(priv->nameservers); - g_ptr_array_unref(priv->domains); - g_ptr_array_unref(priv->searches); - g_ptr_array_unref(priv->dns_options); - - G_OBJECT_CLASS(nm_ip6_config_parent_class)->finalize(object); - - nm_dedup_multi_index_unref(priv->multi_idx); -} - -static const NMDBusInterfaceInfoExtended interface_info_ip6_config = { - .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT( - NM_DBUS_INTERFACE_IP6_CONFIG, - .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS( - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Addresses", - "a(ayuay)", - NM_IP6_CONFIG_ADDRESSES), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("AddressData", - "aa{sv}", - NM_IP6_CONFIG_ADDRESS_DATA), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Gateway", "s", NM_IP6_CONFIG_GATEWAY), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Routes", - "a(ayuayu)", - NM_IP6_CONFIG_ROUTES), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("RouteData", - "aa{sv}", - NM_IP6_CONFIG_ROUTE_DATA), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Nameservers", - "aay", - NM_IP6_CONFIG_NAMESERVERS), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Domains", "as", NM_IP6_CONFIG_DOMAINS), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Searches", - "as", - NM_IP6_CONFIG_SEARCHES), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("DnsOptions", - "as", - NM_IP6_CONFIG_DNS_OPTIONS), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("DnsPriority", - "i", - NM_IP6_CONFIG_DNS_PRIORITY), ), ), -}; - -static void -nm_ip6_config_class_init(NMIP6ConfigClass *klass) -{ - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMIPConfigClass * ip_config_class = NM_IP_CONFIG_CLASS(klass); - - ip_config_class->is_ipv4 = FALSE; - ip_config_class->addr_family = AF_INET6; - - dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED(NM_DBUS_PATH "/IP6Config"); - dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_ip6_config); - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; - - obj_properties[PROP_MULTI_IDX] = - g_param_spec_pointer(NM_IP6_CONFIG_MULTI_IDX, - "", - "", - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IFINDEX] = - g_param_spec_int(NM_IP6_CONFIG_IFINDEX, - "", - "", - -1, - G_MAXINT, - -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ADDRESS_DATA] = - g_param_spec_variant(NM_IP6_CONFIG_ADDRESS_DATA, - "", - "", - G_VARIANT_TYPE("aa{sv}"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ADDRESSES] = - g_param_spec_variant(NM_IP6_CONFIG_ADDRESSES, - "", - "", - G_VARIANT_TYPE("a(ayuay)"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ROUTE_DATA] = - g_param_spec_variant(NM_IP6_CONFIG_ROUTE_DATA, - "", - "", - G_VARIANT_TYPE("aa{sv}"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ROUTES] = g_param_spec_variant(NM_IP6_CONFIG_ROUTES, - "", - "", - G_VARIANT_TYPE("a(ayuayu)"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_GATEWAY] = g_param_spec_string(NM_IP6_CONFIG_GATEWAY, - "", - "", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_NAMESERVERS] = - g_param_spec_variant(NM_IP6_CONFIG_NAMESERVERS, - "", - "", - G_VARIANT_TYPE("aay"), - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_DOMAINS] = g_param_spec_boxed(NM_IP6_CONFIG_DOMAINS, - "", - "", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_SEARCHES] = g_param_spec_boxed(NM_IP6_CONFIG_SEARCHES, - "", - "", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_DNS_OPTIONS] = - g_param_spec_boxed(NM_IP6_CONFIG_DNS_OPTIONS, - "", - "", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_DNS_PRIORITY] = g_param_spec_int(NM_IP6_CONFIG_DNS_PRIORITY, - "", - "", - G_MININT32, - G_MAXINT32, - 0, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); -} diff --git a/src/core/nm-ip6-config.h b/src/core/nm-ip6-config.h deleted file mode 100644 index a54040fc59..0000000000 --- a/src/core/nm-ip6-config.h +++ /dev/null @@ -1,205 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2008 - 2013 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_IP6_CONFIG_H__ -#define __NETWORKMANAGER_IP6_CONFIG_H__ - -#include - -#include "nm-setting-ip6-config.h" - -#include "libnm-glib-aux/nm-dedup-multi.h" -#include "libnm-platform/nmp-object.h" -#include "nm-ip-config.h" - -/*****************************************************************************/ - -void nm_ip_config_iter_ip6_address_init(NMDedupMultiIter *iter, const NMIP6Config *self); -void nm_ip_config_iter_ip6_route_init(NMDedupMultiIter *iter, const NMIP6Config *self); - -#define nm_ip_config_iter_ip6_address_for_each(iter, self, address) \ - for (nm_ip_config_iter_ip6_address_init((iter), (self)); \ - nm_platform_dedup_multi_iter_next_ip6_address((iter), (address));) - -#define nm_ip_config_iter_ip6_route_for_each(iter, self, route) \ - for (nm_ip_config_iter_ip6_route_init((iter), (self)); \ - nm_platform_dedup_multi_iter_next_ip6_route((iter), (route));) - -/*****************************************************************************/ - -#define NM_TYPE_IP6_CONFIG (nm_ip6_config_get_type()) -#define NM_IP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_IP6_CONFIG, NMIP6Config)) -#define NM_IP6_CONFIG_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_IP6_CONFIG, NMIP6ConfigClass)) -#define NM_IS_IP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_IP6_CONFIG)) -#define NM_IS_IP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_IP6_CONFIG)) -#define NM_IP6_CONFIG_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_IP6_CONFIG, NMIP6ConfigClass)) - -typedef struct _NMIP6ConfigClass NMIP6ConfigClass; - -/* internal */ -#define NM_IP6_CONFIG_MULTI_IDX "multi-idx" -#define NM_IP6_CONFIG_IFINDEX "ifindex" - -/* public */ -#define NM_IP6_CONFIG_ADDRESS_DATA "address-data" -#define NM_IP6_CONFIG_ROUTE_DATA "route-data" -#define NM_IP6_CONFIG_GATEWAY "gateway" -#define NM_IP6_CONFIG_NAMESERVERS "nameservers" -#define NM_IP6_CONFIG_DOMAINS "domains" -#define NM_IP6_CONFIG_SEARCHES "searches" -#define NM_IP6_CONFIG_DNS_OPTIONS "dns-options" -#define NM_IP6_CONFIG_DNS_PRIORITY "dns-priority" - -/* deprecated */ -#define NM_IP6_CONFIG_ADDRESSES "addresses" -#define NM_IP6_CONFIG_ROUTES "routes" - -GType nm_ip6_config_get_type(void); - -NMIP6Config *nm_ip6_config_new(struct _NMDedupMultiIndex *multi_idx, int ifindex); -NMIP6Config *nm_ip6_config_new_cloned(const NMIP6Config *src); - -NMIP6Config *nm_ip6_config_clone(const NMIP6Config *self); -int nm_ip6_config_get_ifindex(const NMIP6Config *self); - -struct _NMDedupMultiIndex *nm_ip6_config_get_multi_idx(const NMIP6Config *self); - -NMIP6Config *nm_ip6_config_capture(struct _NMDedupMultiIndex *multi_idx, - NMPlatform * platform, - int ifindex, - NMSettingIP6ConfigPrivacy use_temporary); - -void nm_ip6_config_add_dependent_routes(NMIP6Config *self, - guint32 route_table, - guint32 route_metric, - gboolean is_vrf); - -gboolean nm_ip6_config_commit(const NMIP6Config * self, - NMPlatform * platform, - NMIPRouteTableSyncMode route_table_sync, - GPtrArray ** out_temporary_not_available); -void nm_ip6_config_merge_setting(NMIP6Config * self, - NMSettingIPConfig *setting, - guint32 route_table, - guint32 route_metric); -NMSetting *nm_ip6_config_create_setting(const NMIP6Config *self, gboolean maybe_ipv6_disabled); - -void nm_ip6_config_merge(NMIP6Config * dst, - const NMIP6Config * src, - NMIPConfigMergeFlags merge_flags, - guint32 default_route_metric_penalty); -void nm_ip6_config_subtract(NMIP6Config * dst, - const NMIP6Config *src, - guint32 default_route_metric_penalty); -void nm_ip6_config_intersect(NMIP6Config * dst, - const NMIP6Config *src, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty); -NMIP6Config *nm_ip6_config_intersect_alloc(const NMIP6Config *a, - const NMIP6Config *b, - gboolean intersect_addresses, - gboolean intersect_routes, - guint32 default_route_metric_penalty); -gboolean -nm_ip6_config_replace(NMIP6Config *dst, const NMIP6Config *src, gboolean *relevant_changes); - -const NMPObject *nm_ip6_config_best_default_route_get(const NMIP6Config *self); -const NMPObject *_nm_ip6_config_best_default_route_find(const NMIP6Config *self); - -enum _NMIPConfigFlags; - -void nm_ip6_config_set_config_flags(NMIP6Config * self, - enum _NMIPConfigFlags flags, - enum _NMIPConfigFlags mask); -enum _NMIPConfigFlags nm_ip6_config_get_config_flags(const NMIP6Config *self); - -const NMDedupMultiHeadEntry *nm_ip6_config_lookup_addresses(const NMIP6Config *self); -void nm_ip6_config_reset_addresses(NMIP6Config *self); -void nm_ip6_config_add_address(NMIP6Config *self, const NMPlatformIP6Address *address); -void _nmtst_ip6_config_del_address(NMIP6Config *self, guint i); -guint nm_ip6_config_get_num_addresses(const NMIP6Config *self); -const NMPlatformIP6Address *nm_ip6_config_get_first_address(const NMIP6Config *self); -const NMPlatformIP6Address *_nmtst_ip6_config_get_address(const NMIP6Config *self, guint i); -gboolean nm_ip6_config_address_exists(const NMIP6Config *self, const NMPlatformIP6Address *address); -const NMPlatformIP6Address *nm_ip6_config_lookup_address(const NMIP6Config * self, - const struct in6_addr *addr); -gboolean _nmtst_ip6_config_addresses_sort(NMIP6Config *self); -gboolean nm_ip6_config_has_any_dad_pending(const NMIP6Config *self, const NMIP6Config *candidates); - -const NMDedupMultiHeadEntry *nm_ip6_config_lookup_routes(const NMIP6Config *self); -void nm_ip6_config_reset_routes(NMIP6Config *self); -void nm_ip6_config_add_route(NMIP6Config * self, - const NMPlatformIP6Route *route, - const NMPObject ** out_obj_new); -void _nmtst_ip6_config_del_route(NMIP6Config *self, guint i); -guint nm_ip6_config_get_num_routes(const NMIP6Config *self); -const NMPlatformIP6Route * _nmtst_ip6_config_get_route(const NMIP6Config *self, guint i); - -const NMPlatformIP6Route * nm_ip6_config_get_direct_route_for_host(const NMIP6Config * self, - const struct in6_addr *host, - guint32 route_table); -const NMPlatformIP6Address *nm_ip6_config_get_subnet_for_host(const NMIP6Config * self, - const struct in6_addr *host); - -void nm_ip6_config_reset_nameservers(NMIP6Config *self); -void nm_ip6_config_add_nameserver(NMIP6Config *self, const struct in6_addr *nameserver); -void nm_ip6_config_del_nameserver(NMIP6Config *self, guint i); -guint nm_ip6_config_get_num_nameservers(const NMIP6Config *self); -const struct in6_addr *nm_ip6_config_get_nameserver(const NMIP6Config *self, guint i); - -void nm_ip6_config_reset_domains(NMIP6Config *self); -void nm_ip6_config_add_domain(NMIP6Config *self, const char *domain); -void nm_ip6_config_del_domain(NMIP6Config *self, guint i); -guint nm_ip6_config_get_num_domains(const NMIP6Config *self); -const char *nm_ip6_config_get_domain(const NMIP6Config *self, guint i); - -void nm_ip6_config_reset_searches(NMIP6Config *self); -void nm_ip6_config_add_search(NMIP6Config *self, const char *search); -void nm_ip6_config_del_search(NMIP6Config *self, guint i); -guint nm_ip6_config_get_num_searches(const NMIP6Config *self); -const char *nm_ip6_config_get_search(const NMIP6Config *self, guint i); - -void nm_ip6_config_reset_dns_options(NMIP6Config *self); -void nm_ip6_config_add_dns_option(NMIP6Config *self, const char *option); -void nm_ip6_config_del_dns_option(NMIP6Config *self, guint i); -guint nm_ip6_config_get_num_dns_options(const NMIP6Config *self); -const char *nm_ip6_config_get_dns_option(const NMIP6Config *self, guint i); - -void nm_ip6_config_set_dns_priority(NMIP6Config *self, int priority); -int nm_ip6_config_get_dns_priority(const NMIP6Config *self); - -void nm_ip6_config_set_never_default(NMIP6Config *self, gboolean never_default); -gboolean nm_ip6_config_get_never_default(const NMIP6Config *self); - -const NMPObject *nm_ip6_config_nmpobj_lookup(const NMIP6Config *self, const NMPObject *needle); -gboolean nm_ip6_config_nmpobj_remove(NMIP6Config *self, const NMPObject *needle); - -void nm_ip6_config_hash(const NMIP6Config *self, GChecksum *sum, gboolean dns_only); -gboolean nm_ip6_config_equal(const NMIP6Config *a, const NMIP6Config *b); - -void nm_ip6_config_set_privacy(NMIP6Config *self, NMSettingIP6ConfigPrivacy privacy); - -struct _NMNDiscAddress; -void nm_ip6_config_reset_addresses_ndisc(NMIP6Config * self, - const struct _NMNDiscAddress *addresses, - guint addresses_n, - guint8 plen, - guint32 ifa_flags); -struct _NMNDiscRoute; -struct _NMNDiscGateway; -void nm_ip6_config_reset_routes_ndisc(NMIP6Config * self, - const struct _NMNDiscGateway *gateways, - guint gateways_n, - const struct _NMNDiscRoute * routes, - guint routes_n, - guint32 route_table, - guint32 route_metric); - -void nm_ip6_config_update_routes_metric(NMIP6Config *self, gint64 metric); - -#endif /* __NETWORKMANAGER_IP6_CONFIG_H__ */ diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index 033c8942c2..deec665d1d 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -117,8 +117,9 @@ struct _NML3ConfigData { NMIPRouteTableSyncMode route_table_sync_x[2]; }; - NMSettingConnectionMdns mdns; - NMSettingConnectionLlmnr llmnr; + NMSettingConnectionMdns mdns; + NMSettingConnectionLlmnr llmnr; + NMSettingConnectionDnsOverTls dns_over_tls; NML3ConfigDatFlags flags; @@ -570,6 +571,16 @@ nm_l3_config_data_log(const NML3ConfigData *self, NULL))); } + if (self->dns_over_tls != NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT) { + gs_free char *s = NULL; + + _L("dns-over-tls: %s", + (s = _nm_utils_enum_to_str_full(nm_setting_connection_dns_over_tls_get_type(), + self->dns_over_tls, + " ", + NULL))); + } + if (self->metered != NM_TERNARY_DEFAULT) _L("metered: %s", self->metered ? "yes" : "no"); @@ -666,6 +677,7 @@ nm_l3_config_data_new(NMDedupMultiIndex *multi_idx, int ifindex, NMIPConfigSourc .multi_idx = nm_dedup_multi_index_ref(multi_idx), .mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT, .llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT, + .dns_over_tls = NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT, .flags = NM_L3_CONFIG_DAT_FLAGS_NONE, .metered = NM_TERNARY_DEFAULT, .proxy_browser_only = NM_TERNARY_DEFAULT, @@ -1679,6 +1691,26 @@ nm_l3_config_data_set_llmnr(NML3ConfigData *self, NMSettingConnectionLlmnr llmnr return TRUE; } +NMSettingConnectionDnsOverTls +nm_l3_config_data_get_dns_over_tls(const NML3ConfigData *self) +{ + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + + return self->dns_over_tls; +} + +gboolean +nm_l3_config_data_set_dns_over_tls(NML3ConfigData *self, NMSettingConnectionDnsOverTls dns_over_tls) +{ + nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + + if (self->dns_over_tls == dns_over_tls) + return FALSE; + + self->dns_over_tls = dns_over_tls; + return TRUE; +} + NMIPRouteTableSyncMode nm_l3_config_data_get_route_table_sync(const NML3ConfigData *self, int addr_family) { @@ -2125,6 +2157,7 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a, NM_CMP_DIRECT_REF_STRING(a->nis_domain, b->nis_domain); NM_CMP_DIRECT(a->mdns, b->mdns); NM_CMP_DIRECT(a->llmnr, b->llmnr); + NM_CMP_DIRECT(a->dns_over_tls, b->dns_over_tls); NM_CMP_DIRECT(a->mtu, b->mtu); NM_CMP_DIRECT(a->ip6_mtu, b->ip6_mtu); NM_CMP_DIRECT_UNSAFE(a->metered, b->metered); @@ -3019,6 +3052,9 @@ nm_l3_config_data_merge(NML3ConfigData * self, if (self->llmnr == NM_SETTING_CONNECTION_LLMNR_DEFAULT) self->llmnr = src->llmnr; + if (self->dns_over_tls == NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT) + self->dns_over_tls = src->dns_over_tls; + self->metered = NM_MAX((NMTernary) self->metered, (NMTernary) src->metered); if (self->proxy_method == NM_PROXY_CONFIG_METHOD_UNKNOWN) diff --git a/src/core/nm-l3-config-data.h b/src/core/nm-l3-config-data.h index 1ad23c3251..2f9cfbbab8 100644 --- a/src/core/nm-l3-config-data.h +++ b/src/core/nm-l3-config-data.h @@ -446,6 +446,11 @@ NMSettingConnectionLlmnr nm_l3_config_data_get_llmnr(const NML3ConfigData *self) gboolean nm_l3_config_data_set_llmnr(NML3ConfigData *self, NMSettingConnectionLlmnr llmnr); +NMSettingConnectionDnsOverTls nm_l3_config_data_get_dns_over_tls(const NML3ConfigData *self); + +gboolean nm_l3_config_data_set_dns_over_tls(NML3ConfigData * self, + NMSettingConnectionDnsOverTls dns_over_tls); + NMIPRouteTableSyncMode nm_l3_config_data_get_route_table_sync(const NML3ConfigData *self, int addr_family); diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index aa56c13f87..24f139b7d4 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -15,6 +15,7 @@ #include "nm-netns.h" #include "n-acd/src/n-acd.h" #include "nm-l3-ipv4ll.h" +#include "nm-ip-config.h" /*****************************************************************************/ @@ -246,6 +247,14 @@ typedef struct _NML3CfgPrivate { GSource *nacd_event_down_source; gint64 nacd_event_down_ratelimited_until_msec; + union { + struct { + NMIPConfig *ipconfig_6; + NMIPConfig *ipconfig_4; + }; + NMIPConfig *ipconfig_x[2]; + }; + /* This is for rate-limiting the creation of nacd instance. */ GSource *nacd_instance_ensure_retry; @@ -402,6 +411,73 @@ static NM_UTILS_LOOKUP_DEFINE(_l3_acd_addr_state_to_string, /*****************************************************************************/ +NMIPConfig * +nm_l3cfg_ipconfig_get(NML3Cfg *self, int addr_family) +{ + g_return_val_if_fail(NM_IS_L3CFG(self), NULL); + nm_assert_addr_family(addr_family); + + return self->priv.p->ipconfig_x[NM_IS_IPv4(addr_family)]; +} + +static void +_ipconfig_toggle_notify(gpointer data, GObject *object, gboolean is_last_ref) +{ + NML3Cfg * self = NM_L3CFG(data); + NMIPConfig *ipconfig = NM_IP_CONFIG(object); + + if (!is_last_ref) { + /* This happens while we take another ref below. Ignore the signal. */ + nm_assert(!NM_IN_SET(ipconfig, self->priv.p->ipconfig_4, self->priv.p->ipconfig_6)); + return; + } + + if (ipconfig == self->priv.p->ipconfig_4) + self->priv.p->ipconfig_4 = NULL; + else { + nm_assert(ipconfig == self->priv.p->ipconfig_6); + self->priv.p->ipconfig_6 = NULL; + } + + /* We take a second reference to keep the instance alive, while also removing the + * toggle ref. This will notify the function again, but we will ignore that. */ + g_object_ref(ipconfig); + + g_object_remove_toggle_ref(G_OBJECT(ipconfig), _ipconfig_toggle_notify, self); + + /* pass on the reference, and unexport on idle. */ + nm_ip_config_take_and_unexport_on_idle(g_steal_pointer(&ipconfig)); +} + +NMIPConfig * +nm_l3cfg_ipconfig_acquire(NML3Cfg *self, int addr_family) +{ + NMIPConfig *ipconfig; + + g_return_val_if_fail(NM_IS_L3CFG(self), NULL); + nm_assert_addr_family(addr_family); + + ipconfig = self->priv.p->ipconfig_x[NM_IS_IPv4(addr_family)]; + + if (ipconfig) + return g_object_ref(ipconfig); + + ipconfig = nm_ip_config_new(addr_family, self); + + self->priv.p->ipconfig_x[NM_IS_IPv4(addr_family)] = ipconfig; + + /* The ipconfig keeps self alive. We use a toggle reference + * to avoid a cycle. But we anyway wouldn't want a strong reference, + * because the user releases the instance by unrefing it, and we + * notice that via the weak reference. */ + g_object_add_toggle_ref(G_OBJECT(ipconfig), _ipconfig_toggle_notify, self); + + /* We keep the toggle reference, and return the other reference to the caller. */ + return g_steal_pointer(&ipconfig); +} + +/*****************************************************************************/ + gboolean nm_l3cfg_is_vrf(const NML3Cfg *self) { @@ -4376,6 +4452,9 @@ finalize(GObject *object) { NML3Cfg *self = NM_L3CFG(object); + nm_assert(!self->priv.p->ipconfig_4); + nm_assert(!self->priv.p->ipconfig_6); + nm_assert(!self->priv.p->l3_config_datas); nm_assert(!self->priv.p->ipv4ll); diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h index 19dec11839..5eca683a90 100644 --- a/src/core/nm-l3cfg.h +++ b/src/core/nm-l3cfg.h @@ -447,4 +447,10 @@ void _nm_l3cfg_unregister_ipv4ll(NML3Cfg *self); /*****************************************************************************/ +struct _NMIPConfig; +struct _NMIPConfig *nm_l3cfg_ipconfig_get(NML3Cfg *self, int addr_family); +struct _NMIPConfig *nm_l3cfg_ipconfig_acquire(NML3Cfg *self, int addr_family); + +/*****************************************************************************/ + #endif /* __NM_L3CFG_H__ */ diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 49c56bf68f..ebd68f7604 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -1733,10 +1733,6 @@ remove_device(NMManager *self, NMDevice *device, gboolean quitting) TRUE, NM_DEVICE_STATE_REASON_REMOVED); } - } else if (quitting - && nm_config_get_configure_and_quit(priv->config) - == NM_CONFIG_CONFIGURE_AND_QUIT_ENABLED) { - nm_device_spawn_iface_helper(device); } } @@ -2276,13 +2272,7 @@ system_unmanaged_devices_changed_cb(NMSettings *settings, GParamSpec *pspec, gpo static void hostname_changed_cb(NMHostnameManager *hostname_manager, GParamSpec *pspec, NMManager *self) { - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - const char * hostname; - - hostname = nm_hostname_manager_get_hostname(priv->hostname_manager); - nm_dispatcher_call_hostname(NULL, NULL, NULL); - nm_dhcp_manager_set_default_hostname(nm_dhcp_manager_get(), hostname); } /*****************************************************************************/ @@ -2599,8 +2589,6 @@ get_existing_connection(NMManager *self, NMDevice *device, gboolean *out_generat if (out_generated) *out_generated = FALSE; - nm_device_capture_initial_config(device); - if (!nm_device_can_assume_connections(device)) { nm_device_assume_state_reset(device); _LOG2D(LOGD_DEVICE, device, "assume: device cannot assume connection"); diff --git a/src/core/nm-netns.c b/src/core/nm-netns.c index 224070bee7..538b0e0c1f 100644 --- a/src/core/nm-netns.c +++ b/src/core/nm-netns.c @@ -126,7 +126,7 @@ _l3cfg_weak_notify(gpointer data, GObject *where_the_object_was) } NML3Cfg * -nm_netns_get_l3cfg(NMNetns *self, int ifindex) +nm_netns_l3cfg_get(NMNetns *self, int ifindex) { NMNetnsPrivate *priv; @@ -139,7 +139,7 @@ nm_netns_get_l3cfg(NMNetns *self, int ifindex) } NML3Cfg * -nm_netns_access_l3cfg(NMNetns *self, int ifindex) +nm_netns_l3cfg_acquire(NMNetns *self, int ifindex) { NMNetnsPrivate *priv; L3CfgData * l3cfg_data; diff --git a/src/core/nm-netns.h b/src/core/nm-netns.h index 78a9121a6c..36ed497288 100644 --- a/src/core/nm-netns.h +++ b/src/core/nm-netns.h @@ -35,9 +35,9 @@ struct _NMDedupMultiIndex *nm_netns_get_multi_idx(NMNetns *self); #define NM_NETNS_GET (nm_netns_get()) -NML3Cfg *nm_netns_get_l3cfg(NMNetns *self, int ifindex); +NML3Cfg *nm_netns_l3cfg_get(NMNetns *self, int ifindex); -NML3Cfg *nm_netns_access_l3cfg(NMNetns *netns, int ifindex); +NML3Cfg *nm_netns_l3cfg_acquire(NMNetns *netns, int ifindex); /*****************************************************************************/ diff --git a/src/core/nm-pacrunner-manager.c b/src/core/nm-pacrunner-manager.c index 67930dbae0..6eca4d9432 100644 --- a/src/core/nm-pacrunner-manager.c +++ b/src/core/nm-pacrunner-manager.c @@ -7,15 +7,14 @@ #include "nm-pacrunner-manager.h" -#include "nm-utils.h" -#include "NetworkManagerUtils.h" -#include "libnm-platform/nm-platform.h" -#include "nm-dbus-manager.h" -#include "nm-proxy-config.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" #include "c-list/src/c-list.h" #include "libnm-glib-aux/nm-dbus-aux.h" +#include "libnm-platform/nm-platform.h" + +#include "NetworkManagerUtils.h" +#include "nm-dbus-manager.h" +#include "nm-l3-config-data.h" +#include "nm-utils.h" #define PACRUNNER_DBUS_SERVICE "org.pacrunner" #define PACRUNNER_DBUS_INTERFACE "org.pacrunner.Manager" @@ -124,58 +123,48 @@ NM_AUTO_DEFINE_FCN0(NMPacrunnerConfId *, _nm_auto_unref_conf_id, conf_id_unref); /*****************************************************************************/ static void -get_ip_domains(GPtrArray *domains, NMIPConfig *ip_config) +get_ip_domains(GPtrArray *domains, const NML3ConfigData *l3cd, int addr_family) { NMDedupMultiIter ipconf_iter; char * cidr; - guint i, num; + guint num; + guint i; char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - int addr_family; const NMPlatformIPAddress *address; - const NMPlatformIPRoute * routes; + const NMPlatformIPRoute * route; + const char *const * strv; - if (!ip_config) - return; - - addr_family = nm_ip_config_get_addr_family(ip_config); - - num = nm_ip_config_get_num_searches(ip_config); + strv = nm_l3_config_data_get_searches(l3cd, addr_family, &num); for (i = 0; i < num; i++) - g_ptr_array_add(domains, g_strdup(nm_ip_config_get_search(ip_config, i))); + g_ptr_array_add(domains, g_strdup(strv[i])); - num = nm_ip_config_get_num_domains(ip_config); + strv = nm_l3_config_data_get_domains(l3cd, addr_family, &num); for (i = 0; i < num; i++) - g_ptr_array_add(domains, g_strdup(nm_ip_config_get_domain(ip_config, i))); + g_ptr_array_add(domains, g_strdup(strv[i])); - nm_ip_config_iter_ip_address_for_each (&ipconf_iter, ip_config, &address) { + nm_l3_config_data_iter_ip_address_for_each (&ipconf_iter, l3cd, addr_family, &address) { cidr = g_strdup_printf("%s/%u", nm_utils_inet_ntop(addr_family, address->address_ptr, sbuf), address->plen); g_ptr_array_add(domains, cidr); } - nm_ip_config_iter_ip_route_for_each (&ipconf_iter, ip_config, &routes) { - if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(routes)) + nm_l3_config_data_iter_ip_route_for_each (&ipconf_iter, l3cd, addr_family, &route) { + if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route)) continue; cidr = g_strdup_printf("%s/%u", - nm_utils_inet_ntop(addr_family, routes->network_ptr, sbuf), - routes->plen); + nm_utils_inet_ntop(addr_family, route->network_ptr, sbuf), + route->plen); g_ptr_array_add(domains, cidr); } } static GVariant * -_make_request_create_proxy_configuration(NMProxyConfig *proxy_config, - const char * iface, - NMIP4Config * ip4_config, - NMIP6Config * ip6_config) +_make_request_create_proxy_configuration(const char *iface, const NML3ConfigData *l3cd) { GVariantBuilder builder; NMProxyConfigMethod method; - const char * pac_url; - const char * pac_script; - - nm_assert(NM_IS_PROXY_CONFIG(proxy_config)); + const char * s; g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); @@ -183,20 +172,19 @@ _make_request_create_proxy_configuration(NMProxyConfig *proxy_config, g_variant_builder_add(&builder, "{sv}", "Interface", g_variant_new_string(iface)); } - method = nm_proxy_config_get_method(proxy_config); + method = l3cd ? nm_l3_config_data_get_proxy_method(l3cd) : NM_PROXY_CONFIG_METHOD_UNKNOWN; + switch (method) { case NM_PROXY_CONFIG_METHOD_AUTO: g_variant_builder_add(&builder, "{sv}", "Method", g_variant_new_string("auto")); - pac_url = nm_proxy_config_get_pac_url(proxy_config); - if (pac_url) { - g_variant_builder_add(&builder, "{sv}", "URL", g_variant_new_string(pac_url)); - } + s = nm_l3_config_data_get_proxy_pac_url(l3cd); + if (s) + g_variant_builder_add(&builder, "{sv}", "URL", g_variant_new_string(s)); - pac_script = nm_proxy_config_get_pac_script(proxy_config); - if (pac_script) { - g_variant_builder_add(&builder, "{sv}", "Script", g_variant_new_string(pac_script)); - } + s = nm_l3_config_data_get_proxy_pac_script(l3cd); + if (s) + g_variant_builder_add(&builder, "{sv}", "Script", g_variant_new_string(s)); break; case NM_PROXY_CONFIG_METHOD_UNKNOWN: case NM_PROXY_CONFIG_METHOD_NONE: @@ -204,18 +192,19 @@ _make_request_create_proxy_configuration(NMProxyConfig *proxy_config, break; } - g_variant_builder_add(&builder, - "{sv}", - "BrowserOnly", - g_variant_new_boolean(nm_proxy_config_get_browser_only(proxy_config))); + g_variant_builder_add( + &builder, + "{sv}", + "BrowserOnly", + g_variant_new_boolean(l3cd ? !!nm_l3_config_data_get_proxy_browser_only(l3cd) : FALSE)); - if (ip4_config || ip6_config) { + if (l3cd) { gs_unref_ptrarray GPtrArray *domains = NULL; domains = g_ptr_array_new_with_free_func(g_free); - get_ip_domains(domains, NM_IP_CONFIG_CAST(ip4_config)); - get_ip_domains(domains, NM_IP_CONFIG_CAST(ip6_config)); + get_ip_domains(domains, l3cd, AF_INET); + get_ip_domains(domains, l3cd, AF_INET6); if (domains->len > 0) { g_variant_builder_add( @@ -356,10 +345,8 @@ _try_start_service_by_name(NMPacrunnerManager *self) /** * nm_pacrunner_manager_add: * @self: the #NMPacrunnerManager - * @proxy_config: proxy config of the connection * @iface: the iface for the connection or %NULL - * @ip4_config: IP4 config of the connection to extract domain info from - * @ip6_config: IP6 config of the connection to extract domain info from + * @l3cd: the #NML3ConfigData of the connection to extract domain info from * * Returns: a #NMPacrunnerConfId id. The function cannot * fail and always returns a non NULL pointer. The conf-id may @@ -367,18 +354,13 @@ _try_start_service_by_name(NMPacrunnerManager *self) * Note that the conf-id keeps the @self instance alive. */ NMPacrunnerConfId * -nm_pacrunner_manager_add(NMPacrunnerManager *self, - NMProxyConfig * proxy_config, - const char * iface, - NMIP4Config * ip4_config, - NMIP6Config * ip6_config) +nm_pacrunner_manager_add(NMPacrunnerManager *self, const char *iface, const NML3ConfigData *l3cd) { NMPacrunnerManagerPrivate *priv; NMPacrunnerConfId * conf_id; gs_free char * log_msg = NULL; g_return_val_if_fail(NM_IS_PACRUNNER_MANAGER(self), NULL); - g_return_val_if_fail(proxy_config, NULL); priv = NM_PACRUNNER_MANAGER_GET_PRIVATE(self); @@ -387,8 +369,7 @@ nm_pacrunner_manager_add(NMPacrunnerManager *self, .log_id = ++priv->log_id_counter, .refcount = 1, .self = g_object_ref(self), - .parameters = g_variant_ref_sink( - _make_request_create_proxy_configuration(proxy_config, iface, ip4_config, ip6_config)), + .parameters = g_variant_ref_sink(_make_request_create_proxy_configuration(iface, l3cd)), }; c_list_link_tail(&priv->conf_id_lst_head, &conf_id->conf_id_lst); diff --git a/src/core/nm-pacrunner-manager.h b/src/core/nm-pacrunner-manager.h index fd40f1204d..3f16908f4e 100644 --- a/src/core/nm-pacrunner-manager.h +++ b/src/core/nm-pacrunner-manager.h @@ -26,11 +26,8 @@ GType nm_pacrunner_manager_get_type(void); NMPacrunnerManager *nm_pacrunner_manager_get(void); -NMPacrunnerConfId *nm_pacrunner_manager_add(NMPacrunnerManager *self, - NMProxyConfig * proxy_config, - const char * iface, - NMIP4Config * ip4_config, - NMIP6Config * ip6_config); +NMPacrunnerConfId * +nm_pacrunner_manager_add(NMPacrunnerManager *self, const char *iface, const NML3ConfigData *l3cd); void nm_pacrunner_manager_remove(NMPacrunnerConfId *conf_id); diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index 03e082f12f..f089f1cb5e 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -11,28 +11,31 @@ #include #include -#include "NetworkManagerUtils.h" -#include "nm-act-request.h" -#include "nm-keep-alive.h" -#include "devices/nm-device.h" -#include "nm-setting-ip4-config.h" -#include "nm-setting-connection.h" -#include "libnm-platform/nm-platform.h" -#include "dns/nm-dns-manager.h" -#include "vpn/nm-vpn-manager.h" -#include "nm-auth-utils.h" -#include "nm-firewalld-manager.h" -#include "nm-dispatcher.h" -#include "nm-utils.h" #include "libnm-core-intern/nm-core-internal.h" -#include "nm-manager.h" -#include "settings/nm-settings.h" -#include "settings/nm-settings-connection.h" -#include "settings/nm-agent-manager.h" -#include "nm-dhcp-config.h" +#include "libnm-platform/nm-platform.h" +#include "libnm-platform/nmp-object.h" + +#include "NetworkManagerUtils.h" +#include "devices/nm-device.h" +#include "dns/nm-dns-manager.h" +#include "nm-act-request.h" +#include "nm-auth-utils.h" #include "nm-config.h" -#include "nm-netns.h" +#include "nm-dhcp-config.h" +#include "nm-dispatcher.h" +#include "nm-firewalld-manager.h" #include "nm-hostname-manager.h" +#include "nm-keep-alive.h" +#include "nm-l3-config-data.h" +#include "nm-manager.h" +#include "nm-netns.h" +#include "nm-setting-connection.h" +#include "nm-setting-ip4-config.h" +#include "nm-utils.h" +#include "settings/nm-agent-manager.h" +#include "settings/nm-settings-connection.h" +#include "settings/nm-settings.h" +#include "vpn/nm-vpn-manager.h" /*****************************************************************************/ @@ -136,30 +139,6 @@ static NMDevice *get_default_device(NMPolicy *self, int addr_family); /*****************************************************************************/ -static void -_dns_manager_set_ip_config(NMDnsManager * dns_manager, - NMIPConfig * ip_config, - NMDnsIPConfigType ip_config_type, - NMDevice * device) -{ - if (device && nm_device_sys_iface_state_is_external(device)) { - nm_dns_manager_set_ip_config(dns_manager, ip_config, NM_DNS_IP_CONFIG_TYPE_REMOVED); - return; - } - - if (NM_IN_SET(ip_config_type, NM_DNS_IP_CONFIG_TYPE_DEFAULT, NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE) - && device - && nm_device_get_route_metric_default(nm_device_get_device_type(device)) - == NM_VPN_ROUTE_METRIC_DEFAULT) { - /* some device types are inherently VPN. */ - ip_config_type = NM_DNS_IP_CONFIG_TYPE_VPN; - } - - nm_dns_manager_set_ip_config(dns_manager, ip_config, ip_config_type); -} - -/*****************************************************************************/ - typedef struct { NMPlatformIP6Address prefix; NMDevice * device; /* The requesting ("uplink") device */ @@ -974,7 +953,7 @@ update_default_ac(NMPolicy *self, int addr_family, NMActiveConnection *best) nm_active_connection_set_default(best, addr_family, TRUE); } -static gpointer +static const NML3ConfigData * get_best_ip_config(NMPolicy * self, int addr_family, const char ** out_ip_iface, @@ -982,20 +961,21 @@ get_best_ip_config(NMPolicy * self, NMDevice ** out_device, NMVpnConnection ** out_vpn) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - gpointer conf, best_conf = NULL; - const CList * tmp_list; - NMActiveConnection *ac; - guint64 best_metric = G_MAXUINT64; - NMVpnConnection * best_vpn = NULL; + NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + const NML3ConfigData *l3cd_best = NULL; + const CList * tmp_list; + NMActiveConnection * ac; + guint64 best_metric = G_MAXUINT64; + NMVpnConnection * best_vpn = NULL; nm_assert(NM_IN_SET(addr_family, AF_INET, AF_INET6)); nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { - NMVpnConnection * candidate; - NMVpnConnectionState vpn_state; - const NMPObject * obj; - guint32 metric; + const NML3ConfigData *l3cd; + NMVpnConnection * candidate; + NMVpnConnectionState vpn_state; + const NMPObject * obj; + guint32 metric; if (!NM_IS_VPN_CONNECTION(ac)) continue; @@ -1006,24 +986,18 @@ get_best_ip_config(NMPolicy * self, if (vpn_state != NM_VPN_CONNECTION_STATE_ACTIVATED) continue; - if (addr_family == AF_INET) - conf = nm_vpn_connection_get_ip4_config(candidate); - else - conf = nm_vpn_connection_get_ip6_config(candidate); - if (!conf) + l3cd = nm_vpn_connection_get_l3cd(candidate); + if (!l3cd) continue; - if (addr_family == AF_INET) - obj = nm_ip4_config_best_default_route_get(conf); - else - obj = nm_ip6_config_best_default_route_get(conf); + obj = nm_l3_config_data_get_best_default_route(l3cd, addr_family); if (!obj) continue; metric = NMP_OBJECT_CAST_IPX_ROUTE(obj)->rx.metric; if (metric <= best_metric) { best_metric = metric; - best_conf = conf; + l3cd_best = l3cd; best_vpn = candidate; } } @@ -1033,25 +1007,20 @@ get_best_ip_config(NMPolicy * self, NM_SET_OUT(out_vpn, best_vpn); NM_SET_OUT(out_ac, NM_ACTIVE_CONNECTION(best_vpn)); NM_SET_OUT(out_ip_iface, nm_vpn_connection_get_ip_iface(best_vpn, TRUE)); - return best_conf; + return l3cd_best; } ac = get_best_active_connection(self, addr_family, TRUE); if (ac) { NMDevice *device = nm_active_connection_get_device(ac); - nm_assert(device); - - if (addr_family == AF_INET) - conf = nm_device_get_ip4_config(device); - else - conf = nm_device_get_ip6_config(device); + nm_assert(NM_IS_DEVICE(device)); NM_SET_OUT(out_device, device); NM_SET_OUT(out_vpn, NULL); NM_SET_OUT(out_ac, ac); NM_SET_OUT(out_ip_iface, nm_device_get_ip_iface(device)); - return conf; + return nm_device_get_l3cd(device, TRUE); } NM_SET_OUT(out_device, NULL); @@ -1069,8 +1038,6 @@ update_ip4_routing(NMPolicy *self, gboolean force_update) NMVpnConnection * vpn = NULL; NMActiveConnection *best_ac = NULL; const char * ip_iface = NULL; - const CList * tmp_list; - NMActiveConnection *ac; /* Note that we might have an IPv4 VPN tunneled over an IPv6-only device, * so we can get (vpn != NULL && best == NULL). @@ -1088,9 +1055,11 @@ update_ip4_routing(NMPolicy *self, gboolean force_update) return; if (best) { + const CList * tmp_list; + NMActiveConnection *ac; + nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { - if (NM_IS_VPN_CONNECTION(ac) && nm_vpn_connection_get_ip4_config(NM_VPN_CONNECTION(ac)) - && !nm_active_connection_get_device(ac)) + if (NM_IS_VPN_CONNECTION(ac) && !nm_active_connection_get_device(ac)) nm_active_connection_set_device(ac, best); } } @@ -1132,8 +1101,6 @@ update_ip6_routing(NMPolicy *self, gboolean force_update) NMVpnConnection * vpn = NULL; NMActiveConnection *best_ac = NULL; const char * ip_iface = NULL; - NMActiveConnection *ac; - const CList * tmp_list; /* Note that we might have an IPv6 VPN tunneled over an IPv4-only device, * so we can get (vpn != NULL && best == NULL). @@ -1151,9 +1118,11 @@ update_ip6_routing(NMPolicy *self, gboolean force_update) return; if (best) { + const CList * tmp_list; + NMActiveConnection *ac; + nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { - if (NM_IS_VPN_CONNECTION(ac) && nm_vpn_connection_get_ip6_config(NM_VPN_CONNECTION(ac)) - && !nm_active_connection_get_device(ac)) + if (NM_IS_VPN_CONNECTION(ac) && !nm_active_connection_get_device(ac)) nm_active_connection_set_device(ac, best); } } @@ -1176,25 +1145,38 @@ update_ip6_routing(NMPolicy *self, gboolean force_update) static void update_ip_dns(NMPolicy *self, int addr_family, NMDevice *changed_device) { - NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - gpointer ip_config; - const char * ip_iface = NULL; - NMVpnConnection *vpn = NULL; - NMDevice * device = NULL; + NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + const NML3ConfigData *l3cd; + const char * ip_iface = NULL; + NMVpnConnection * vpn = NULL; + NMDevice * device = NULL; nm_assert_addr_family(addr_family); - ip_config = get_best_ip_config(self, addr_family, &ip_iface, NULL, &device, &vpn); - if (ip_config) { + l3cd = get_best_ip_config(self, addr_family, &ip_iface, NULL, &device, &vpn); + if (l3cd) { + NMDnsIPConfigType ip_config_type; + + nm_assert(!device || NM_IS_DEVICE(device)); + nm_assert(!vpn || NM_IS_VPN_CONNECTION(vpn)); + nm_assert((!!device) != (!!vpn)); + /* Tell the DNS manager this config is preferred by re-adding it with * a different IP config type. */ - _dns_manager_set_ip_config(NM_POLICY_GET_PRIVATE(self)->dns_manager, - ip_config, - (vpn || (device && nm_device_is_vpn(device))) - ? NM_DNS_IP_CONFIG_TYPE_VPN - : NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE, - device); + if (device && nm_device_sys_iface_state_is_external(device)) + ip_config_type = NM_DNS_IP_CONFIG_TYPE_REMOVED; + else if (vpn || (device && nm_device_is_vpn(device))) + ip_config_type = NM_DNS_IP_CONFIG_TYPE_VPN; + else + ip_config_type = NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE; + + nm_dns_manager_set_ip_config(NM_POLICY_GET_PRIVATE(self)->dns_manager, + addr_family, + ((gconstpointer) device) ?: ((gconstpointer) vpn), + l3cd, + ip_config_type, + TRUE); } if (addr_family == AF_INET6) { @@ -1909,9 +1891,7 @@ device_state_changed(NMDevice * device, NMPolicy * self = _PRIV_TO_SELF(priv); NMActiveConnection * ac; NMSettingsConnection *sett_conn = nm_device_get_settings_connection(device); - NMIP4Config * ip4_config; - NMIP6Config * ip6_config; - NMSettingConnection * s_con = NULL; + NMSettingConnection * s_con = NULL; switch (nm_device_state_reason_check(reason)) { case NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED: @@ -2013,27 +1993,6 @@ device_state_changed(NMDevice * device, /* Reset auto retries back to default since connection was successful */ nm_settings_connection_autoconnect_retries_reset(sett_conn); } - - /* Add device's new IPv4 and IPv6 configs to DNS */ - - nm_dns_manager_begin_updates(priv->dns_manager, __func__); - - ip4_config = nm_device_get_ip4_config(device); - if (ip4_config) - _dns_manager_set_ip_config(priv->dns_manager, - NM_IP_CONFIG_CAST(ip4_config), - NM_DNS_IP_CONFIG_TYPE_DEFAULT, - device); - ip6_config = nm_device_get_ip6_config(device); - if (ip6_config) - _dns_manager_set_ip_config(priv->dns_manager, - NM_IP_CONFIG_CAST(ip6_config), - NM_DNS_IP_CONFIG_TYPE_DEFAULT, - device); - - update_routing_and_dns(self, FALSE, device); - - nm_dns_manager_end_updates(priv->dns_manager, __func__); break; case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNAVAILABLE: @@ -2135,58 +2094,51 @@ device_state_changed(NMDevice * device, } static void -device_ip_config_changed(NMDevice * device, - NMIPConfig *new_config, - NMIPConfig *old_config, - gpointer user_data) +device_l3cd_changed(NMDevice * device, + const NML3ConfigData *l3cd_old, + const NML3ConfigData *l3cd_new, + gpointer user_data) { NMPolicyPrivate *priv = user_data; NMPolicy * self = _PRIV_TO_SELF(priv); - int addr_family; NMDeviceState state; - nm_assert(new_config || old_config); - nm_assert(!new_config || NM_IS_IP_CONFIG(new_config)); - nm_assert(!old_config || NM_IS_IP_CONFIG(old_config)); - - if (new_config) { - addr_family = nm_ip_config_get_addr_family(new_config); - nm_assert(!old_config || addr_family == nm_ip_config_get_addr_family(old_config)); - } else - addr_family = nm_ip_config_get_addr_family(old_config); + nm_assert(!l3cd_new || NM_IS_L3_CONFIG_DATA(l3cd_new)); + nm_assert(!l3cd_old || NM_IS_L3_CONFIG_DATA(l3cd_old)); nm_dns_manager_begin_updates(priv->dns_manager, __func__); /* We catch already all the IP events registering on the device state changes but - * the ones where the IP changes but the device state keep stable (i.e., activated): + * the ones where the IP changes with a stable state (i.e., activated): * ignore IP config changes but when the device is in activated state. * Prevents unnecessary changes to DNS information. + * FIXME(l3cfg): check why ^^^ this is needed and implement it. Note that + * this function is not always called when the device becomes ACTIVATED. + * Previously, we would also update the DNS manager's IP config in + * device_state_change(ACTIVATED). There we would also special-case + * pseudo-VPNs like wireguard. I don't see the code where this is handled + * now. */ state = nm_device_get_state(device); - if (state > NM_DEVICE_STATE_IP_CONFIG && state <= NM_DEVICE_STATE_ACTIVATED) { - if (old_config != new_config) { - if (new_config) - _dns_manager_set_ip_config(priv->dns_manager, - new_config, - NM_DNS_IP_CONFIG_TYPE_DEFAULT, - device); - if (old_config) - nm_dns_manager_set_ip_config(priv->dns_manager, - old_config, - NM_DNS_IP_CONFIG_TYPE_REMOVED); - } - update_ip_dns(self, addr_family, device); - if (addr_family == AF_INET) - update_ip4_routing(self, TRUE); - else - update_ip6_routing(self, TRUE); - update_system_hostname(self, addr_family == AF_INET ? "ip4 conf" : "ip6 conf"); + if (state > NM_DEVICE_STATE_DISCONNECTED && state < NM_DEVICE_STATE_DEACTIVATING) { + nm_dns_manager_set_ip_config(priv->dns_manager, + AF_UNSPEC, + device, + l3cd_new, + NM_DNS_IP_CONFIG_TYPE_DEFAULT, + TRUE); + update_ip_dns(self, AF_INET, device); + update_ip_dns(self, AF_INET6, device); + update_ip4_routing(self, TRUE); + update_ip6_routing(self, TRUE); + update_system_hostname(self, "ip conf"); } else { - /* Old configs get removed immediately */ - if (old_config) - nm_dns_manager_set_ip_config(priv->dns_manager, - old_config, - NM_DNS_IP_CONFIG_TYPE_REMOVED); + nm_dns_manager_set_ip_config(priv->dns_manager, + AF_UNSPEC, + device, + l3cd_old, + NM_DNS_IP_CONFIG_TYPE_REMOVED, + TRUE); } nm_dns_manager_end_updates(priv->dns_manager, __func__); @@ -2227,14 +2179,7 @@ devices_list_register(NMPolicy *self, NMDevice *device) /* Connect state-changed with _after, so that the handler is invoked after other handlers. */ g_signal_connect_after(device, NM_DEVICE_STATE_CHANGED, G_CALLBACK(device_state_changed), priv); - g_signal_connect(device, - NM_DEVICE_IP4_CONFIG_CHANGED, - G_CALLBACK(device_ip_config_changed), - priv); - g_signal_connect(device, - NM_DEVICE_IP6_CONFIG_CHANGED, - G_CALLBACK(device_ip_config_changed), - priv); + g_signal_connect(device, NM_DEVICE_L3CD_CHANGED, G_CALLBACK(device_l3cd_changed), priv); g_signal_connect(device, NM_DEVICE_IP6_PREFIX_DELEGATED, G_CALLBACK(device_ip6_prefix_delegated), @@ -2296,51 +2241,26 @@ device_removed(NMManager *manager, NMDevice *device, gpointer user_data) /*****************************************************************************/ static void -vpn_connection_activated(NMPolicy *self, NMVpnConnection *vpn) +vpn_connection_update_dns(NMPolicy *self, NMVpnConnection *vpn, gboolean remove) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - NMIP4Config * ip4_config; - NMIP6Config * ip6_config; + int IS_IPv4; nm_dns_manager_begin_updates(priv->dns_manager, __func__); - ip4_config = nm_vpn_connection_get_ip4_config(vpn); - if (ip4_config) + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + int addr_family = IS_IPv4 ? AF_INET : AF_INET6; + const NML3ConfigData *l3cd; + + l3cd = nm_vpn_connection_get_l3cd(vpn); nm_dns_manager_set_ip_config(priv->dns_manager, - NM_IP_CONFIG_CAST(ip4_config), - NM_DNS_IP_CONFIG_TYPE_VPN); - - ip6_config = nm_vpn_connection_get_ip6_config(vpn); - if (ip6_config) - nm_dns_manager_set_ip_config(priv->dns_manager, - NM_IP_CONFIG_CAST(ip6_config), - NM_DNS_IP_CONFIG_TYPE_VPN); - - update_routing_and_dns(self, TRUE, NULL); - - nm_dns_manager_end_updates(priv->dns_manager, __func__); -} - -static void -vpn_connection_deactivated(NMPolicy *self, NMVpnConnection *vpn) -{ - NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - NMIP4Config * ip4_config; - NMIP6Config * ip6_config; - - nm_dns_manager_begin_updates(priv->dns_manager, __func__); - - ip4_config = nm_vpn_connection_get_ip4_config(vpn); - if (ip4_config) - nm_dns_manager_set_ip_config(priv->dns_manager, - NM_IP_CONFIG_CAST(ip4_config), - NM_DNS_IP_CONFIG_TYPE_REMOVED); - - ip6_config = nm_vpn_connection_get_ip6_config(vpn); - if (ip6_config) - nm_dns_manager_set_ip_config(priv->dns_manager, - NM_IP_CONFIG_CAST(ip6_config), - NM_DNS_IP_CONFIG_TYPE_REMOVED); + addr_family, + vpn, + l3cd, + remove ? NM_DNS_IP_CONFIG_TYPE_REMOVED + : NM_DNS_IP_CONFIG_TYPE_VPN, + TRUE); + } update_routing_and_dns(self, TRUE, NULL); @@ -2354,13 +2274,14 @@ vpn_connection_state_changed(NMVpnConnection * vpn, NMActiveConnectionStateReason reason, NMPolicy * self) { + /* FIXME(l3cfg): we need to track changes to nm_vpn_connection_get_l3cd(). */ if (new_state == NM_VPN_CONNECTION_STATE_ACTIVATED) - vpn_connection_activated(self, vpn); + vpn_connection_update_dns(self, vpn, FALSE); else if (new_state >= NM_VPN_CONNECTION_STATE_FAILED) { /* Only clean up IP/DNS if the connection ever got past IP_CONFIG */ if (old_state >= NM_VPN_CONNECTION_STATE_IP_CONFIG_GET && old_state <= NM_VPN_CONNECTION_STATE_ACTIVATED) - vpn_connection_deactivated(self, vpn); + vpn_connection_update_dns(self, vpn, TRUE); } } diff --git a/src/core/nm-proxy-config.c b/src/core/nm-proxy-config.c deleted file mode 100644 index 49156dfae0..0000000000 --- a/src/core/nm-proxy-config.c +++ /dev/null @@ -1,172 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2016 Atul Anand . - */ - -#include "src/core/nm-default-daemon.h" - -#include "nm-proxy-config.h" - -#include - -#include "libnm-core-intern/nm-core-internal.h" - -/*****************************************************************************/ - -typedef struct { - NMProxyConfigMethod method; - gboolean browser_only; - char * pac_url; - char * pac_script; -} NMProxyConfigPrivate; - -struct _NMProxyConfig { - GObject parent; - NMProxyConfigPrivate _priv; -}; - -struct _NMProxyConfigClass { - GObjectClass parent; -}; - -G_DEFINE_TYPE(NMProxyConfig, nm_proxy_config, G_TYPE_OBJECT) - -#define NM_PROXY_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMProxyConfig, NM_IS_PROXY_CONFIG) - -/*****************************************************************************/ - -void -nm_proxy_config_set_method(NMProxyConfig *config, NMProxyConfigMethod method) -{ - NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - priv->method = method; -} - -NMProxyConfigMethod -nm_proxy_config_get_method(const NMProxyConfig *config) -{ - const NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - return priv->method; -} - -void -nm_proxy_config_merge_setting(NMProxyConfig *config, NMSettingProxy *setting) -{ - const char * tmp = NULL; - NMProxyConfigPrivate *priv; - NMSettingProxyMethod method; - - if (!setting) - return; - - g_return_if_fail(NM_IS_SETTING_PROXY(setting)); - - priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - nm_clear_g_free(&priv->pac_script); - - method = nm_setting_proxy_get_method(setting); - switch (method) { - case NM_SETTING_PROXY_METHOD_AUTO: - priv->method = NM_PROXY_CONFIG_METHOD_AUTO; - - /* Free DHCP Obtained PAC Url (i.e Option 252) - * only when libnm overrides it. - */ - tmp = nm_setting_proxy_get_pac_url(setting); - if (tmp) { - g_free(priv->pac_url); - priv->pac_url = g_strdup(tmp); - } - - tmp = nm_setting_proxy_get_pac_script(setting); - priv->pac_script = g_strdup(tmp); - - break; - case NM_SETTING_PROXY_METHOD_NONE: - priv->method = NM_PROXY_CONFIG_METHOD_NONE; - break; - } - - priv->browser_only = nm_setting_proxy_get_browser_only(setting); -} - -gboolean -nm_proxy_config_get_browser_only(const NMProxyConfig *config) -{ - const NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - return priv->browser_only; -} - -void -nm_proxy_config_set_pac_url(NMProxyConfig *config, const char *url) -{ - NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - g_free(priv->pac_url); - priv->pac_url = g_strdup(url); -} - -const char * -nm_proxy_config_get_pac_url(const NMProxyConfig *config) -{ - const NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - return priv->pac_url; -} - -void -nm_proxy_config_set_pac_script(NMProxyConfig *config, const char *script) -{ - NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - g_free(priv->pac_script); - priv->pac_script = g_strdup(script); -} - -const char * -nm_proxy_config_get_pac_script(const NMProxyConfig *config) -{ - const NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - return priv->pac_script; -} - -/*****************************************************************************/ - -static void -nm_proxy_config_init(NMProxyConfig *config) -{ - NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(config); - - priv->method = NM_PROXY_CONFIG_METHOD_NONE; -} - -NMProxyConfig * -nm_proxy_config_new(void) -{ - return g_object_new(NM_TYPE_PROXY_CONFIG, NULL); -} - -static void -finalize(GObject *object) -{ - NMProxyConfig * self = NM_PROXY_CONFIG(object); - NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE(self); - - g_free(priv->pac_url); - g_free(priv->pac_script); - - G_OBJECT_CLASS(nm_proxy_config_parent_class)->finalize(object); -} - -static void -nm_proxy_config_class_init(NMProxyConfigClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - - object_class->finalize = finalize; -} diff --git a/src/core/nm-proxy-config.h b/src/core/nm-proxy-config.h deleted file mode 100644 index 7b6241f849..0000000000 --- a/src/core/nm-proxy-config.h +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2016 Atul Anand . - */ - -#ifndef __NETWORKMANAGER_PROXY_CONFIG_H__ -#define __NETWORKMANAGER_PROXY_CONFIG_H__ - -#include "nm-setting-proxy.h" -#include "nm-l3-config-data.h" - -#define NM_TYPE_PROXY_CONFIG (nm_proxy_config_get_type()) -#define NM_PROXY_CONFIG(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_PROXY_CONFIG, NMProxyConfig)) -#define NM_PROXY_CONFIG_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_PROXY_CONFIG, NMProxyConfigClass)) -#define NM_IS_PROXY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_PROXY_CONFIG)) -#define NM_IS_PROXY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_PROXY_CONFIG)) -#define NM_PROXY_CONFIG_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_PROXY_CONFIG, NMProxyConfigClass)) - -typedef struct _NMProxyConfigClass NMProxyConfigClass; - -GType nm_proxy_config_get_type(void); - -NMProxyConfig *nm_proxy_config_new(void); - -void nm_proxy_config_set_method(NMProxyConfig *config, NMProxyConfigMethod method); -NMProxyConfigMethod nm_proxy_config_get_method(const NMProxyConfig *config); - -void nm_proxy_config_merge_setting(NMProxyConfig *config, NMSettingProxy *setting); - -gboolean nm_proxy_config_get_browser_only(const NMProxyConfig *config); - -void nm_proxy_config_set_pac_url(NMProxyConfig *config, const char *url); -const char *nm_proxy_config_get_pac_url(const NMProxyConfig *config); - -void nm_proxy_config_set_pac_script(NMProxyConfig *config, const char *script); -const char *nm_proxy_config_get_pac_script(const NMProxyConfig *config); - -#endif /* __NETWORKMANAGER_PROXY_CONFIG_H__ */ diff --git a/src/core/nm-types.h b/src/core/nm-types.h index 294cf40936..76287e4dbf 100644 --- a/src/core/nm-types.h +++ b/src/core/nm-types.h @@ -25,10 +25,7 @@ typedef struct _NML3Cfg NML3Cfg; typedef struct _NML3ConfigData NML3ConfigData; typedef struct _NMDevice NMDevice; typedef struct _NMDhcpConfig NMDhcpConfig; -typedef struct _NMProxyConfig NMProxyConfig; typedef struct _NMIPConfig NMIPConfig; -typedef struct _NMIP4Config NMIP4Config; -typedef struct _NMIP6Config NMIP6Config; typedef struct _NMManager NMManager; typedef struct _NMNetns NMNetns; typedef struct _NMPolicy NMPolicy; diff --git a/src/core/platform/nm-fake-platform.c b/src/core/platform/nm-fake-platform.c index b773df9a43..870350c5ca 100644 --- a/src/core/platform/nm-fake-platform.c +++ b/src/core/platform/nm-fake-platform.c @@ -1118,8 +1118,6 @@ ip_route_add(NMPlatform * platform, (const NMPlatformObject *) route); r = NMP_OBJECT_CAST_IP_ROUTE(obj); - r->is_external = TRUE; - nm_platform_ip_route_normalize(addr_family, r); switch (addr_family) { diff --git a/src/core/platform/tests/test-route.c b/src/core/platform/tests/test-route.c index 4b1db7fad7..2b9b2f8f67 100644 --- a/src/core/platform/tests/test-route.c +++ b/src/core/platform/tests/test-route.c @@ -332,33 +332,30 @@ test_ip4_route(void) /* Test route listing */ routes = nmtstp_ip4_route_get_all(NM_PLATFORM_GET, ifindex); memset(rts, 0, sizeof(rts)); - rts[0].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); - rts[0].network = gateway; - rts[0].plen = 32; - rts[0].ifindex = ifindex; - rts[0].gateway = INADDR_ANY; - rts[0].metric = metric; - rts[0].mss = mss; - rts[0].is_external = TRUE; - rts[0].scope_inv = nm_platform_route_scope_inv(RT_SCOPE_LINK); - rts[1].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); - rts[1].network = network; - rts[1].plen = plen; - rts[1].ifindex = ifindex; - rts[1].gateway = gateway; - rts[1].metric = metric; - rts[1].mss = mss; - rts[1].scope_inv = nm_platform_route_scope_inv(RT_SCOPE_UNIVERSE); - rts[1].is_external = TRUE; - rts[2].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); - rts[2].network = 0; - rts[2].plen = 0; - rts[2].ifindex = ifindex; - rts[2].gateway = gateway; - rts[2].metric = metric; - rts[2].mss = mss; - rts[2].scope_inv = nm_platform_route_scope_inv(RT_SCOPE_UNIVERSE); - rts[2].is_external = TRUE; + rts[0].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); + rts[0].network = gateway; + rts[0].plen = 32; + rts[0].ifindex = ifindex; + rts[0].gateway = INADDR_ANY; + rts[0].metric = metric; + rts[0].mss = mss; + rts[0].scope_inv = nm_platform_route_scope_inv(RT_SCOPE_LINK); + rts[1].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); + rts[1].network = network; + rts[1].plen = plen; + rts[1].ifindex = ifindex; + rts[1].gateway = gateway; + rts[1].metric = metric; + rts[1].mss = mss; + rts[1].scope_inv = nm_platform_route_scope_inv(RT_SCOPE_UNIVERSE); + rts[2].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); + rts[2].network = 0; + rts[2].plen = 0; + rts[2].ifindex = ifindex; + rts[2].gateway = gateway; + rts[2].metric = metric; + rts[2].mss = mss; + rts[2].scope_inv = nm_platform_route_scope_inv(RT_SCOPE_UNIVERSE); g_assert_cmpint(routes->len, ==, 3); nmtst_platform_ip4_routes_equal_aptr((const NMPObject *const *) routes->pdata, rts, @@ -492,33 +489,30 @@ test_ip6_route(void) /* Test route listing */ routes = nmtstp_ip6_route_get_all(NM_PLATFORM_GET, ifindex); memset(rts, 0, sizeof(rts)); - rts[0].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); - rts[0].network = gateway; - rts[0].plen = 128; - rts[0].ifindex = ifindex; - rts[0].gateway = in6addr_any; - rts[0].pref_src = in6addr_any; - rts[0].metric = metric; - rts[0].mss = mss; - rts[0].is_external = TRUE; - rts[1].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); - rts[1].network = network; - rts[1].plen = plen; - rts[1].ifindex = ifindex; - rts[1].gateway = gateway; - rts[1].pref_src = pref_src; - rts[1].metric = metric; - rts[1].mss = mss; - rts[1].is_external = TRUE; - rts[2].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); - rts[2].network = in6addr_any; - rts[2].plen = 0; - rts[2].ifindex = ifindex; - rts[2].gateway = gateway; - rts[2].pref_src = in6addr_any; - rts[2].metric = metric; - rts[2].mss = mss; - rts[2].is_external = TRUE; + rts[0].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); + rts[0].network = gateway; + rts[0].plen = 128; + rts[0].ifindex = ifindex; + rts[0].gateway = in6addr_any; + rts[0].pref_src = in6addr_any; + rts[0].metric = metric; + rts[0].mss = mss; + rts[1].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); + rts[1].network = network; + rts[1].plen = plen; + rts[1].ifindex = ifindex; + rts[1].gateway = gateway; + rts[1].pref_src = pref_src; + rts[1].metric = metric; + rts[1].mss = mss; + rts[2].rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER); + rts[2].network = in6addr_any; + rts[2].plen = 0; + rts[2].ifindex = ifindex; + rts[2].gateway = gateway; + rts[2].pref_src = in6addr_any; + rts[2].metric = metric; + rts[2].mss = mss; g_assert_cmpint(routes->len, ==, 3); nmtst_platform_ip6_routes_equal_aptr((const NMPObject *const *) routes->pdata, rts, @@ -715,7 +709,6 @@ test_ip4_route_options(gconstpointer test_data) for (i = 0; i < rts_n; i++) { rts_cmp[i] = rts_add[i]; nm_platform_ip_route_normalize(AF_INET, NM_PLATFORM_IP_ROUTE_CAST(&rts_cmp[i])); - rts_cmp[i].is_external = TRUE; } routes = nmtstp_ip4_route_get_all(NM_PLATFORM_GET, IFINDEX); @@ -887,7 +880,6 @@ test_ip6_route_options(gconstpointer test_data) for (i = 0; i < rts_n; i++) { rts_cmp[i] = rts_add[i]; nm_platform_ip_route_normalize(AF_INET6, NM_PLATFORM_IP_ROUTE_CAST(&rts_cmp[i])); - rts_cmp[i].is_external = TRUE; } routes = nmtstp_ip6_route_get_all(NM_PLATFORM_GET, IFINDEX); diff --git a/src/core/ppp/nm-ppp-manager-call.c b/src/core/ppp/nm-ppp-manager-call.c index 5e84f59610..8adeb8adbe 100644 --- a/src/core/ppp/nm-ppp-manager-call.c +++ b/src/core/ppp/nm-ppp-manager-call.c @@ -94,24 +94,6 @@ again: return ret; } -void -nm_ppp_manager_set_route_parameters(NMPPPManager *self, - guint32 ip4_route_table, - guint32 ip4_route_metric, - guint32 ip6_route_table, - guint32 ip6_route_metric) -{ - const NMPPPOps *ppp_ops = ppp_ops_get(); - - g_return_if_fail(ppp_ops); - - ppp_ops->set_route_parameters(self, - ip4_route_table, - ip4_route_metric, - ip6_route_table, - ip6_route_metric); -} - gboolean nm_ppp_manager_start(NMPPPManager *self, NMActRequest *req, diff --git a/src/core/ppp/nm-ppp-manager-call.h b/src/core/ppp/nm-ppp-manager-call.h index c831cf0d61..87d2f93f55 100644 --- a/src/core/ppp/nm-ppp-manager-call.h +++ b/src/core/ppp/nm-ppp-manager-call.h @@ -10,12 +10,6 @@ NMPPPManager *nm_ppp_manager_create(const char *iface, GError **error); -void nm_ppp_manager_set_route_parameters(NMPPPManager *ppp_manager, - guint32 ip4_route_table, - guint32 ip4_route_metric, - guint32 ip6_route_table, - guint32 ip6_route_metric); - gboolean nm_ppp_manager_start(NMPPPManager *self, NMActRequest *req, const char * ppp_name, diff --git a/src/core/ppp/nm-ppp-manager.c b/src/core/ppp/nm-ppp-manager.c index e6790f2260..c347978ff0 100644 --- a/src/core/ppp/nm-ppp-manager.c +++ b/src/core/ppp/nm-ppp-manager.c @@ -32,8 +32,7 @@ #include "libnm-platform/nm-platform-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "nm-act-request.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" +#include "nm-l3-config-data.h" #include "nm-dbus-object.h" #include "nm-pppd-plugin.h" @@ -46,6 +45,26 @@ static NM_CACHED_QUARK_FCN("ppp-manager-secret-tries", ppp_manager_secret_tries_ /*****************************************************************************/ +/* FIXME(l3cfg:ppp): I think NMPPPManager's API should be improved to be easier + * usable (by the higher layers). That means to make the class more complex, to + * provide a simpler API. + * + * For example: + * + * - NM_PPP_MANAGER_SIGNAL_STATE_CHANGED just gets re-emitted when we receive + * the D-Bus call from the plugin. The emitted state is like NM_PPP_STATUS_SERIALCONN, + * but none of the users cares about this (what would it mean anyway)? The + * class should itself consume the state, and emit something more consumable + * (like: interface is ready (with ifindex), IPvX configuration done (with l3cd). + * + * - currently signals can be emitted in any order, and it's not clear which + * signals we can expect. For example, when we activate a device, we may want to wait + * for IPv4 and IPv6 configuration, but it's not clear whether this configuration + * is still to be received or whether we can stop waiting. + **/ + +/*****************************************************************************/ + #define NM_TYPE_PPP_MANAGER (nm_ppp_manager_get_type()) #define NM_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_PPP_MANAGER, NMPPPManager)) #define NM_PPP_MANAGER_CLASS(klass) \ @@ -62,8 +81,7 @@ GType nm_ppp_manager_get_type(void); enum { STATE_CHANGED, IFINDEX_SET, - IP4_CONFIG, - IP6_CONFIG, + NEW_CONFIG, STATS, LAST_SIGNAL @@ -91,11 +109,6 @@ typedef struct { /* Monitoring */ int monitor_fd; guint monitor_id; - - guint32 ip4_route_table; - guint32 ip4_route_metric; - guint32 ip6_route_table; - guint32 ip6_route_metric; } NMPPPManagerPrivate; struct _NMPPPManager { @@ -131,30 +144,19 @@ static void _ppp_manager_stop_cancel(NMPPPManagerStopHandle *handle); /*****************************************************************************/ static void -_ppp_manager_set_route_parameters(NMPPPManager *self, - guint32 ip4_route_table, - guint32 ip4_route_metric, - guint32 ip6_route_table, - guint32 ip6_route_metric) +_emit_signal_new_config(NMPPPManager * self, + int addr_family, + const NML3ConfigData * l3cd, + const NMUtilsIPv6IfaceId *iid) { - NMPPPManagerPrivate *priv; + nm_assert(NM_IS_PPP_MANAGER(self)); + nm_assert_addr_family(addr_family); + nm_assert(NM_IS_L3_CONFIG_DATA(l3cd)); + nm_assert((!!iid) == (addr_family == AF_INET6)); - g_return_if_fail(NM_IS_PPP_MANAGER(self)); + nm_l3_config_data_seal(l3cd); - priv = NM_PPP_MANAGER_GET_PRIVATE(self); - if (priv->ip4_route_table != ip4_route_table || priv->ip4_route_metric != ip4_route_metric - || priv->ip6_route_table != ip6_route_table || priv->ip6_route_metric != ip6_route_metric) { - priv->ip4_route_table = ip4_route_table; - priv->ip4_route_metric = ip4_route_metric; - priv->ip6_route_table = ip6_route_table; - priv->ip6_route_metric = ip6_route_metric; - - _LOGT("route-parameters: table-v4: %u, metric-v4: %u, table-v6: %u, metric-v6: %u", - priv->ip4_route_table, - priv->ip4_route_metric, - priv->ip6_route_table, - priv->ip6_route_metric); - } + g_signal_emit(self, signals[NEW_CONFIG], 0, addr_family, l3cd, iid); } /*****************************************************************************/ @@ -419,10 +421,16 @@ impl_ppp_manager_set_state(NMDBusObject * obj, GVariant * parameters) { NMPPPManager *self = NM_PPP_MANAGER(obj); - guint32 state; + guint32 ppp_state; - g_variant_get(parameters, "(u)", &state); - g_signal_emit(self, signals[STATE_CHANGED], 0, (guint) state); + g_variant_get(parameters, "(u)", &ppp_state); + + if (ppp_state >= NM_PPP_STATUS_INTERN_DEAD) { + /* we don't expect an intern state to be reported by the plugin. */ + ppp_state = NM_PPP_STATUS_UNKNOWN; + } + + g_signal_emit(self, signals[STATE_CHANGED], 0, (guint) ppp_state); g_dbus_method_invocation_return_value(invocation, NULL); } @@ -435,9 +443,10 @@ impl_ppp_manager_set_ifindex(NMDBusObject * obj, GDBusMethodInvocation * invocation, GVariant * parameters) { - NMPPPManager * self = NM_PPP_MANAGER(obj); - NMPPPManagerPrivate * priv = NM_PPP_MANAGER_GET_PRIVATE(self); - const NMPlatformLink *plink = NULL; + NMPPPManager * self = NM_PPP_MANAGER(obj); + gs_unref_object NMPPPManager *self_keep_alive = NULL; + NMPPPManagerPrivate * priv = NM_PPP_MANAGER_GET_PRIVATE(self); + const NMPlatformLink * plink = NULL; nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL; gint32 ifindex; @@ -456,6 +465,10 @@ impl_ppp_manager_set_ifindex(NMDBusObject * obj, if (ifindex > 0) { plink = nm_platform_link_get(NM_PLATFORM_GET, ifindex); if (!plink) { + /* processing events has side-effects. We need to keep self alive + * during that.*/ + self_keep_alive = g_object_ref(self); + nm_platform_process_events(NM_PLATFORM_GET); plink = nm_platform_link_get(NM_PLATFORM_GET, ifindex); } @@ -510,12 +523,12 @@ impl_ppp_manager_set_ip4_config(NMDBusObject * obj, GDBusMethodInvocation * invocation, GVariant * parameters) { - NMPPPManager * self = NM_PPP_MANAGER(obj); - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); - gs_unref_object NMIP4Config *config = NULL; - NMPlatformIP4Address address; - guint32 u32, mtu; - GVariantIter * iter; + NMPPPManager * self = NM_PPP_MANAGER(obj); + NMPPPManagerPrivate * priv = NM_PPP_MANAGER_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + NMPlatformIP4Address address; + guint32 u32, mtu; + GVariantIter * iter; gs_unref_variant GVariant *config_dict = NULL; _LOGI("(IPv4 Config Get) reply received."); @@ -527,37 +540,41 @@ impl_ppp_manager_set_ip4_config(NMDBusObject * obj, if (!set_ip_config_common(self, config_dict, &mtu)) goto out; - config = nm_ip4_config_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), priv->ifindex); + l3cd = nm_l3_config_data_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), + priv->ifindex, + NM_IP_CONFIG_SOURCE_PPP); - if (mtu) - nm_ip4_config_set_mtu(config, mtu, NM_IP_CONFIG_SOURCE_PPP); + nm_l3_config_data_set_mtu(l3cd, mtu); - memset(&address, 0, sizeof(address)); - address.plen = 32; + address = (NMPlatformIP4Address){ + .plen = 32, + }; if (g_variant_lookup(config_dict, NM_PPP_IP4_CONFIG_ADDRESS, "u", &u32)) address.address = u32; + if (g_variant_lookup(config_dict, NM_PPP_IP4_CONFIG_PREFIX, "u", &u32)) + address.plen = u32; + if (g_variant_lookup(config_dict, NM_PPP_IP4_CONFIG_GATEWAY, "u", &u32)) { const NMPlatformIP4Route r = { .ifindex = priv->ifindex, .rt_source = NM_IP_CONFIG_SOURCE_PPP, .gateway = u32, - .table_coerced = nm_platform_route_table_coerce(priv->ip4_route_table), - .metric = priv->ip4_route_metric, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, }; - nm_ip4_config_add_route(config, &r, NULL); + nm_l3_config_data_add_route_4(l3cd, &r); address.peer_address = u32; } else address.peer_address = address.address; - if (g_variant_lookup(config_dict, NM_PPP_IP4_CONFIG_PREFIX, "u", &u32)) - address.plen = u32; - - if (address.address && address.plen && address.plen <= 32) { + if (address.address && address.plen > 0 && address.plen <= 32) { address.addr_source = NM_IP_CONFIG_SOURCE_PPP; - nm_ip4_config_add_address(config, &address); + nm_l3_config_data_add_address_4(l3cd, &address); } else { _LOGE("invalid IPv4 address received!"); goto out; @@ -565,18 +582,17 @@ impl_ppp_manager_set_ip4_config(NMDBusObject * obj, if (g_variant_lookup(config_dict, NM_PPP_IP4_CONFIG_DNS, "au", &iter)) { while (g_variant_iter_next(iter, "u", &u32)) - nm_ip4_config_add_nameserver(config, u32); + nm_l3_config_data_add_nameserver(l3cd, AF_INET, &u32); g_variant_iter_free(iter); } if (g_variant_lookup(config_dict, NM_PPP_IP4_CONFIG_WINS, "au", &iter)) { while (g_variant_iter_next(iter, "u", &u32)) - nm_ip4_config_add_wins(config, u32); + nm_l3_config_data_add_wins(l3cd, u32); g_variant_iter_free(iter); } - /* Push the IP4 config up to the device */ - g_signal_emit(self, signals[IP4_CONFIG], 0, config); + _emit_signal_new_config(self, AF_INET, l3cd, NULL); out: g_dbus_method_invocation_return_value(invocation, NULL); @@ -620,14 +636,14 @@ impl_ppp_manager_set_ip6_config(NMDBusObject * obj, GDBusMethodInvocation * invocation, GVariant * parameters) { - NMPPPManager * self = NM_PPP_MANAGER(obj); - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); - gs_unref_object NMIP6Config *config = NULL; - NMPlatformIP6Address addr; - struct in6_addr a; - NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT; - gboolean has_peer = FALSE; - gs_unref_variant GVariant *config_dict = NULL; + NMPPPManager * self = NM_PPP_MANAGER(obj); + NMPPPManagerPrivate * priv = NM_PPP_MANAGER_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + NMPlatformIP6Address address; + struct in6_addr a; + NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT; + gboolean has_peer = FALSE; + gs_unref_variant GVariant *config_dict = NULL; _LOGI("(IPv6 Config Get) reply received."); @@ -638,32 +654,37 @@ impl_ppp_manager_set_ip6_config(NMDBusObject * obj, if (!set_ip_config_common(self, config_dict, NULL)) goto out; - config = nm_ip6_config_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), priv->ifindex); + l3cd = nm_l3_config_data_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), + priv->ifindex, + NM_IP_CONFIG_SOURCE_PPP); - memset(&addr, 0, sizeof(addr)); - addr.plen = 64; + address = (NMPlatformIP6Address){ + .plen = 64, + .addr_source = NM_IP_CONFIG_SOURCE_PPP, + }; if (iid_value_to_ll6_addr(config_dict, NM_PPP_IP6_CONFIG_PEER_IID, &a, NULL)) { const NMPlatformIP6Route r = { .ifindex = priv->ifindex, .rt_source = NM_IP_CONFIG_SOURCE_PPP, .gateway = a, - .table_coerced = nm_platform_route_table_coerce(priv->ip6_route_table), - .metric = priv->ip6_route_metric, + .table_any = TRUE, + .table_coerced = 0, + .metric_any = TRUE, + .metric = 0, }; - nm_ip6_config_add_route(config, &r, NULL); - addr.peer_address = a; - has_peer = TRUE; + nm_l3_config_data_add_route_6(l3cd, &r); + address.peer_address = a; + has_peer = TRUE; } - if (iid_value_to_ll6_addr(config_dict, NM_PPP_IP6_CONFIG_OUR_IID, &addr.address, &iid)) { + if (iid_value_to_ll6_addr(config_dict, NM_PPP_IP6_CONFIG_OUR_IID, &address.address, &iid)) { if (!has_peer) - addr.peer_address = addr.address; - nm_ip6_config_add_address(config, &addr); + address.peer_address = address.address; + nm_l3_config_data_add_address_6(l3cd, &address); - /* Push the IPv6 config and interface identifier up to the device */ - g_signal_emit(self, signals[IP6_CONFIG], 0, &iid, config); + _emit_signal_new_config(self, AF_INET6, l3cd, &iid); } else _LOGE("invalid IPv6 address received!"); @@ -726,7 +747,7 @@ ppp_watch_cb(GPid pid, int status, gpointer user_data) priv->pid = 0; priv->ppp_watch_id = 0; _ppp_cleanup(self); - g_signal_emit(self, signals[STATE_CHANGED], 0, (guint) NM_PPP_STATUS_DEAD); + g_signal_emit(self, signals[STATE_CHANGED], 0, (guint) NM_PPP_STATUS_INTERN_DEAD); } static gboolean @@ -734,10 +755,16 @@ pppd_timed_out(gpointer data) { NMPPPManager *self = NM_PPP_MANAGER(data); + /* FIXME(l3cfg): we should not use NMPPPManager directly, instead use + * NMPppMgr. That one already schedules a (better) timer. We don't need + * a timeout here anymore. + * + * At this moment, NMPPPManager is still used by NMModem. Once that changes, + * this timer needs to go. */ _LOGW("pppd timed out or didn't initialize our dbus module"); _ppp_manager_stop(self, NULL, NULL, NULL); - g_signal_emit(self, signals[STATE_CHANGED], 0, (guint) NM_PPP_STATUS_DEAD); + g_signal_emit(self, signals[STATE_CHANGED], 0, (guint) NM_PPP_STATUS_INTERN_DEAD); return FALSE; } @@ -975,9 +1002,8 @@ _ppp_manager_start(NMPPPManager *self, gs_unref_ptrarray GPtrArray *ppp_cmd = NULL; gs_free char * cmd_str = NULL; struct stat st; - const char * ip6_method, *ip4_method; - gboolean ip6_enabled = FALSE; - gboolean ip4_enabled = FALSE; + gboolean ip6_enabled; + gboolean ip4_enabled; g_return_val_if_fail(NM_IS_PPP_MANAGER(self), FALSE); g_return_val_if_fail(NM_IS_ACT_REQUEST(req), FALSE); @@ -1022,11 +1048,7 @@ _ppp_manager_start(NMPPPManager *self, adsl_setting = (NMSettingAdsl *) nm_connection_get_setting(connection, NM_TYPE_SETTING_ADSL); - /* Figure out what address methods should be enabled */ - ip4_method = nm_utils_get_ip_config_method(connection, AF_INET); - ip4_enabled = nm_streq(ip4_method, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - ip6_method = nm_utils_get_ip_config_method(connection, AF_INET6); - ip6_enabled = nm_streq(ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO); + nm_utils_ppp_ip_methods_enabled(connection, &ip4_enabled, &ip6_enabled); ppp_cmd = create_pppd_cmd_line(self, s_ppp, @@ -1059,9 +1081,10 @@ _ppp_manager_start(NMPPPManager *self, _LOGI("pppd started with pid %lld", (long long) priv->pid); - priv->ppp_watch_id = g_child_watch_add(priv->pid, (GChildWatchFunc) ppp_watch_cb, self); - priv->ppp_timeout_handler = g_timeout_add_seconds(timeout_secs, pppd_timed_out, self); - priv->act_req = g_object_ref(req); + priv->ppp_watch_id = g_child_watch_add(priv->pid, (GChildWatchFunc) ppp_watch_cb, self); + if (timeout_secs > 0) + priv->ppp_timeout_handler = g_timeout_add_seconds(timeout_secs, pppd_timed_out, self); + priv->act_req = g_object_ref(req); return TRUE; fail: @@ -1290,12 +1313,8 @@ nm_ppp_manager_init(NMPPPManager *self) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); - priv->ifindex = -1; - priv->monitor_fd = -1; - priv->ip4_route_table = RT_TABLE_MAIN; - priv->ip4_route_metric = 460; - priv->ip6_route_table = RT_TABLE_MAIN; - priv->ip6_route_metric = 460; + priv->ifindex = -1; + priv->monitor_fd = -1; } static NMPPPManager * @@ -1400,7 +1419,7 @@ nm_ppp_manager_class_init(NMPPPManagerClass *manager_class) NULL, G_TYPE_NONE, 1, - G_TYPE_UINT); + G_TYPE_UINT /* ppp_state */); signals[IFINDEX_SET] = g_signal_new(NM_PPP_MANAGER_SIGNAL_IFINDEX_SET, G_OBJECT_CLASS_TYPE(object_class), @@ -1411,10 +1430,10 @@ nm_ppp_manager_class_init(NMPPPManagerClass *manager_class) NULL, G_TYPE_NONE, 2, - G_TYPE_INT, - G_TYPE_STRING); + G_TYPE_INT /* ifindex */, + G_TYPE_STRING /* ifname */); - signals[IP4_CONFIG] = g_signal_new(NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, + signals[NEW_CONFIG] = g_signal_new(NM_PPP_MANAGER_SIGNAL_NEW_CONFIG, G_OBJECT_CLASS_TYPE(object_class), G_SIGNAL_RUN_FIRST, 0, @@ -1422,20 +1441,10 @@ nm_ppp_manager_class_init(NMPPPManagerClass *manager_class) NULL, NULL, G_TYPE_NONE, - 1, - G_TYPE_OBJECT); - - signals[IP6_CONFIG] = g_signal_new(NM_PPP_MANAGER_SIGNAL_IP6_CONFIG, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 2, - G_TYPE_POINTER, - G_TYPE_OBJECT); + 3, + G_TYPE_INT, /* addr_family */ + G_TYPE_POINTER, /* (const NML3ConfigData *) */ + G_TYPE_POINTER); /* (const NMUtilsIPv6IfaceId *) */ signals[STATS] = g_signal_new(NM_PPP_MANAGER_SIGNAL_STATS, G_OBJECT_CLASS_TYPE(object_class), @@ -1451,9 +1460,8 @@ nm_ppp_manager_class_init(NMPPPManagerClass *manager_class) } const NMPPPOps ppp_ops = { - .create = _ppp_manager_new, - .set_route_parameters = _ppp_manager_set_route_parameters, - .start = _ppp_manager_start, - .stop = _ppp_manager_stop, - .stop_cancel = _ppp_manager_stop_cancel, + .create = _ppp_manager_new, + .start = _ppp_manager_start, + .stop = _ppp_manager_stop, + .stop_cancel = _ppp_manager_stop_cancel, }; diff --git a/src/core/ppp/nm-ppp-manager.h b/src/core/ppp/nm-ppp-manager.h index c41dda2074..9cf465517c 100644 --- a/src/core/ppp/nm-ppp-manager.h +++ b/src/core/ppp/nm-ppp-manager.h @@ -11,8 +11,7 @@ #define NM_PPP_MANAGER_SIGNAL_STATE_CHANGED "state-changed" #define NM_PPP_MANAGER_SIGNAL_IFINDEX_SET "ifindex-set" -#define NM_PPP_MANAGER_SIGNAL_IP4_CONFIG "ip4-config" -#define NM_PPP_MANAGER_SIGNAL_IP6_CONFIG "ip6-config" +#define NM_PPP_MANAGER_SIGNAL_NEW_CONFIG "new-config" #define NM_PPP_MANAGER_SIGNAL_STATS "stats" typedef struct _NMPPPManager NMPPPManager; diff --git a/src/core/ppp/nm-ppp-mgr.c b/src/core/ppp/nm-ppp-mgr.c new file mode 100644 index 0000000000..82e511e995 --- /dev/null +++ b/src/core/ppp/nm-ppp-mgr.c @@ -0,0 +1,620 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "src/core/nm-default-daemon.h" + +#include "nm-ppp-mgr.h" + +#include + +#include "NetworkManagerUtils.h" +#include "devices/nm-device-utils.h" +#include "nm-act-request.h" +#include "nm-netns.h" +#include "nm-ppp-manager-call.h" +#include "nm-ppp-status.h" + +/*****************************************************************************/ + +struct _NMPppMgr { + NMPppMgrConfig config; + NMPPPManager * ppp_manager; + GSource * idle_start; + GSource * connect_timeout_source; + union { + struct { + NMPppMgrIPData ip_data_6; + NMPppMgrIPData ip_data_4; + }; + NMPppMgrIPData ip_data_x[2]; + }; + int ifindex; + NMPppMgrStatsData stats_data; + NMPppMgrState state; + NMUtilsIPv6IfaceId ipv6_iid; + bool ppp_started : 1; +}; + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_PPP +#define _NMLOG_PREFIX_NAME "ppp-mgr" +#define _NMLOG(level, ...) \ + __NMLOG_DEFAULT_WITH_ADDR(level, _NMLOG_DOMAIN, _NMLOG_PREFIX_NAME, __VA_ARGS__) + +/*****************************************************************************/ + +NM_UTILS_LOOKUP_STR_DEFINE( + nm_ppp_mgr_state_to_string, + NMPppMgrState, + NM_UTILS_LOOKUP_DEFAULT_WARN("???"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_STATE_STARTING, "starting"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX, "waiting-for-ifindex"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_STATE_HAVE_IFINDEX, "have-ifindex"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_STATE_HAVE_IP_CONFIG, "have-ip-config"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_STATE_FAILED_TO_START, "failed-to-start"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_STATE_FAILED_TO_IFINDEX, "failed-to-ifindex"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_STATE_FAILED, "failed")); + +NM_UTILS_LOOKUP_STR_DEFINE(nm_ppp_mgr_callback_type_to_string, + NMPppMgrCallbackType, + NM_UTILS_LOOKUP_DEFAULT_WARN("???"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + "state-changed"), + NM_UTILS_LOOKUP_STR_ITEM(NM_PPP_MGR_CALLBACK_TYPE_STATS_CHANGED, + "stats-changed")); + +/*****************************************************************************/ + +#define SELF_TO_USERDATA(self) (&(self)->idle_start) + +#define SELF_FROM_USERDATA(user_data) \ + ((NMPppMgr *) (((const char *) (user_data)) - G_STRUCT_OFFSET(NMPppMgr, idle_start))) + +/*****************************************************************************/ + +gboolean +_nm_assert_is_ppp_mgr(const NMPppMgr *self) +{ + nm_assert(G_IS_OBJECT(self->ppp_manager)); + nm_assert(NM_IS_NETNS(self->config.netns)); + nm_assert(self->config.parent_iface); + + return TRUE; +} + +/*****************************************************************************/ + +static void +_callback_emit_with_data(NMPppMgr *self, const NMPppMgrCallbackData *callback_data) +{ + char sbuf_int[30]; + + switch (callback_data->callback_type) { + case NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED: + _LOGT("emit signal: %s, state=%s%s%s%s%s, reason=%s", + nm_ppp_mgr_callback_type_to_string(callback_data->callback_type), + nm_ppp_mgr_state_to_string(callback_data->data.state), + NM_PRINT_FMT_QUOTED2(callback_data->data.state != callback_data->data.old_state, + ", old-state=", + nm_ppp_mgr_state_to_string(callback_data->data.old_state), + ""), + NM_PRINT_FMT_QUOTED2(callback_data->data.ifindex > 0, + ", ifindex=", + nm_sprintf_buf(sbuf_int, "%d", callback_data->data.ifindex), + ""), + callback_data->data.reason_msg); + break; + case NM_PPP_MGR_CALLBACK_TYPE_STATS_CHANGED: + /* This signal might be emitted every 5 seconds. It's too verbose for logging. + * Be silent. */ + break; + default: + nm_assert_not_reached(); + } + + self->config.callback(self, callback_data, self->config.user_data); +} + +static void +_callback_emit_state_change(NMPppMgr * self, + NMPppMgrCallbackType callback_type, + NMPppMgrState old_state, + gboolean ip_changed_4, + gboolean ip_changed_6, + NMDeviceStateReason reason, + const char * reason_msg) +{ + const NMPppMgrCallbackData callback_data = { + .callback_type = callback_type, + .data = + { + .old_state = old_state, + .state = self->state, + .ifindex = self->ifindex, + .reason = reason, + .reason_msg = reason_msg, + .ip_data_4 = &self->ip_data_4, + .ip_data_6 = &self->ip_data_6, + .stats_data = &self->stats_data, + .ip_changed_4 = ip_changed_4, + .ip_changed_6 = ip_changed_6, + }, + }; + + _callback_emit_with_data(self, &callback_data); +} + +/*****************************************************************************/ + +NMPppMgrState +nm_ppp_mgr_get_state(const NMPppMgr *self) +{ + g_return_val_if_fail(NM_IS_PPP_MGR(self), NM_PPP_MGR_STATE_FAILED); + + return self->state; +} + +int +nm_ppp_mgr_get_ifindex(const NMPppMgr *self) +{ + g_return_val_if_fail(NM_IS_PPP_MGR(self), 0); + + return self->ifindex; +} + +const NMPppMgrIPData * +nm_ppp_mgr_get_ip_data(const NMPppMgr *self, int addr_family) +{ + const int IS_IPv4 = NM_IS_IPv4(addr_family); + + g_return_val_if_fail(NM_IS_PPP_MGR(self), NULL); + + return &self->ip_data_x[IS_IPv4]; +} + +const NMPppMgrStatsData * +nm_ppp_mgr_get_stats(const NMPppMgr *self) +{ + g_return_val_if_fail(NM_IS_PPP_MGR(self), NULL); + + return &self->stats_data; +} + +/*****************************************************************************/ + +static void +_set_state(NMPppMgr *self, NMPppMgrState state, NMPppMgrState *out_old_state) +{ + if (state >= NM_PPP_MGR_STATE_HAVE_IP_CONFIG) + nm_clear_g_source_inst(&self->connect_timeout_source); + + NM_SET_OUT(out_old_state, self->state); + if (self->state != state) { + _LOGT("set state: %s (was %s)", + nm_ppp_mgr_state_to_string(state), + nm_ppp_mgr_state_to_string(self->state)); + self->state = state; + } +} + +static void +_set_state_failed(NMPppMgr *self, NMPppMgrState state, NMPppMgrState *out_old_state) +{ + nm_assert(state >= _NM_PPP_MGR_STATE_FAILED_START); + nm_assert(self->state < _NM_PPP_MGR_STATE_FAILED_START); + + _set_state(self, state, out_old_state); + + self->ifindex = 0; + nm_clear_l3cd(&self->ip_data_4.l3cd); + nm_clear_l3cd(&self->ip_data_6.l3cd); + self->ip_data_4 = (NMPppMgrIPData){ + .ip_received = FALSE, + .ip_enabled = FALSE, + }; + self->ip_data_6 = (NMPppMgrIPData){ + .ip_received = FALSE, + .ip_enabled = FALSE, + }; + + if (self->ppp_manager) { + g_signal_handlers_disconnect_by_data(self->ppp_manager, SELF_TO_USERDATA(self)); + if (self->ppp_started) { + self->ppp_started = FALSE; + nm_ppp_manager_stop(self->ppp_manager, NULL, NULL, NULL); + } + g_object_unref(self->ppp_manager); + } +} + +static gboolean +_state_ready_for_have_ifindex(NMPppMgr *self) +{ + if (self->ip_data_4.ip_received) { + /* once we receive an IPv4 config, we consider this as ready. + * + * The problem is that we don't know when we can expect an IPv6 config + * too, so we cannot just keep waiting. I don't know how to solve this, but + * it means IPv4+IPv6 together doesn't work well (because we would not + * wait for IPv6, once IPv4 config is received. */ + return TRUE; + } + + return ((!self->ip_data_4.ip_enabled || self->ip_data_4.ip_received) + && (!self->ip_data_6.ip_enabled || self->ip_data_6.ip_received)); +} + +/*****************************************************************************/ + +static void +_ppp_signal_state_changed(NMPPPManager *ppp_manager, guint ppp_state_u, gpointer user_data) +{ + NMPppMgr * self = SELF_FROM_USERDATA(user_data); + NMPPPStatus ppp_state = ppp_state_u; + NMPppMgrState state; + NMPppMgrState old_state; + NMDeviceStateReason reason; + const char * reason_msg; + + if ((guint) ppp_state != ppp_state_u) + ppp_state = NM_PPP_STATUS_UNKNOWN; + + switch (ppp_state) { + case NM_PPP_STATUS_DISCONNECT: + state = NM_PPP_MGR_STATE_FAILED; + reason = NM_DEVICE_STATE_REASON_PPP_DISCONNECT; + reason_msg = "ppp signals disconnect"; + break; + case NM_PPP_STATUS_DEAD: + case NM_PPP_STATUS_INTERN_DEAD: + state = NM_PPP_MGR_STATE_FAILED; + reason = NM_DEVICE_STATE_REASON_PPP_FAILED; + reason_msg = "ppp signals disconnect"; + break; + default: + _LOGT("ppp signal about state changed: #%u signal (ignored)", ppp_state_u); + return; + } + + _LOGT("ppp signal about state changed: #%u signal, new-state %s, state-reason=%s, %s", + ppp_state_u, + nm_ppp_mgr_state_to_string(state), + nm_device_state_reason_to_string(reason), + reason_msg); + + _set_state_failed(self, state, &old_state); + _callback_emit_state_change(self, + NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + old_state, + FALSE, + FALSE, + reason, + reason_msg); +} + +static void +_ppp_signal_ifindex_set(NMPPPManager *ppp_manager, + int ifindex, + const char * ifname, + gpointer user_data) +{ + NMPppMgr * self = SELF_FROM_USERDATA(user_data); + NMPppMgrState old_state; + NMPppMgrState new_state; + gboolean ip_changed_4; + gboolean ip_changed_6; + + if (ifindex <= 0) { + nm_assert(self->state == NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX); + _LOGT("ifindex set: invalid ifindex received"); + _set_state_failed(self, NM_PPP_MGR_STATE_FAILED_TO_IFINDEX, &old_state); + _callback_emit_state_change(self, + NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + old_state, + FALSE, + FALSE, + NM_DEVICE_STATE_REASON_PPP_FAILED, + "invalid ifindex provided by ppp plugin"); + return; + } + + if (self->ifindex > 0) { + nm_assert(self->state > NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX); + nm_assert(self->state < _NM_PPP_MGR_STATE_FAILED_START); + + _LOGT("ifindex set: ignore ifindex %d, already set to %d", ifindex, self->ifindex); + return; + } + + nm_assert(self->state == NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX); + self->ifindex = ifindex; + + if (_state_ready_for_have_ifindex(self)) { + new_state = NM_PPP_MGR_STATE_HAVE_IP_CONFIG; + ip_changed_4 = self->ip_data_4.ip_received; + ip_changed_6 = self->ip_data_6.ip_received; + } else { + new_state = NM_PPP_MGR_STATE_HAVE_IFINDEX; + ip_changed_4 = FALSE; + ip_changed_6 = FALSE; + } + + _LOGT("ifindex set: ifindex %d", ifindex); + + _set_state(self, new_state, &old_state); + _callback_emit_state_change(self, + NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + old_state, + ip_changed_4, + ip_changed_6, + NM_DEVICE_STATE_REASON_PPP_FAILED, + "invalid ifindex provided by ppp plugin"); +} + +static void +_ppp_signal_new_config(NMPPPManager * ppp_manager, + int addr_family, + const NML3ConfigData * l3cd, + const NMUtilsIPv6IfaceId *iid, + gpointer user_data) +{ + NMPppMgr * self = SELF_FROM_USERDATA(user_data); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMPppMgrState old_state; + gboolean ip_changed_4; + gboolean ip_changed_6; + + nm_assert(self->state >= NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX); + nm_assert(self->state < _NM_PPP_MGR_STATE_FAILED_START); + + if (nm_l3_config_data_equal(self->ip_data_x[IS_IPv4].l3cd, l3cd)) + l3cd = self->ip_data_x[IS_IPv4].l3cd; + + nm_l3_config_data_reset(&self->ip_data_x[IS_IPv4].l3cd, l3cd); + if (!IS_IPv4) { + if (iid) + self->ipv6_iid = *iid; + else + self->ipv6_iid = (NMUtilsIPv6IfaceId) NM_UTILS_IPV6_IFACE_ID_INIT; + self->ip_data_6.ipv6_iid = + nm_utils_memeqzero(&self->ipv6_iid, sizeof(self->ipv6_iid)) ? NULL : &self->ipv6_iid; + } + self->ip_data_x[IS_IPv4].ip_received = TRUE; + + if (self->state == NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX) { + /* we still wait for the ifindex. We just cache the IP configuration, + * but leave the state unchanged. */ + _LOGT("ip-config v%c received (still waiting for ifindex)", + nm_utils_addr_family_to_char(addr_family)); + old_state = NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX; + } else { + NMPppMgrState new_state; + + _LOGT("ip-config v%c received", nm_utils_addr_family_to_char(addr_family)); + new_state = _state_ready_for_have_ifindex(self) ? NM_PPP_MGR_STATE_HAVE_IP_CONFIG + : NM_PPP_MGR_STATE_HAVE_IFINDEX; + nm_assert((self->state == NM_PPP_MGR_STATE_HAVE_IFINDEX) + || (self->state == NM_PPP_MGR_STATE_HAVE_IP_CONFIG + && new_state == NM_PPP_MGR_STATE_HAVE_IP_CONFIG)); + _set_state(self, new_state, &old_state); + } + + ip_changed_4 = IS_IPv4; + ip_changed_6 = !IS_IPv4; + + _callback_emit_state_change(self, + NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + old_state, + ip_changed_4, + ip_changed_6, + NM_DEVICE_STATE_REASON_NONE, + "ip config received"); +} + +static void +_ppp_signal_stats(NMPPPManager *ppp_manager, guint in_bytes, guint out_bytes, gpointer user_data) +{ + NMPppMgr *self = SELF_FROM_USERDATA(user_data); + + if (self->stats_data.in_bytes == in_bytes && self->stats_data.out_bytes == out_bytes) + return; + + self->stats_data.in_bytes = in_bytes; + self->stats_data.out_bytes = out_bytes; + + _callback_emit_state_change(self, + NM_PPP_MGR_CALLBACK_TYPE_STATS_CHANGED, + self->state, + FALSE, + FALSE, + NM_DEVICE_STATE_REASON_NONE, + "stats update"); +} + +/*****************************************************************************/ + +static gboolean +_ifindex_timeout_cb(gpointer user_data) +{ + NMPppMgr * self = user_data; + NMPppMgrState old_state; + + nm_clear_g_source_inst(&self->connect_timeout_source); + + _set_state_failed(self, NM_PPP_MGR_STATE_FAILED_TO_IFINDEX, &old_state); + _callback_emit_state_change(self, + NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + old_state, + FALSE, + FALSE, + NM_DEVICE_STATE_REASON_PPP_FAILED, + "timeout connecting"); + return G_SOURCE_CONTINUE; +} + +/*****************************************************************************/ + +static gboolean +_idle_start_cb(gpointer user_data) +{ + NMPppMgr * self = user_data; + gs_free_error GError *error = NULL; + NMPppMgrState old_state; + gboolean ip4_enabled; + gboolean ip6_enabled; + NMPlatform * platform; + const NMPlatformLink *plink; + + nm_clear_g_source_inst(&self->idle_start); + + /* We only evaluate ipx_enabled here. That is because nm_ppp_manager_start() + * will evaluate it based on act_req's applied connection (like we do now), + * but as the applied connection can be reapplied, let's do it at the + * same time to be sure we agree. + * + * This should be nicer solved by NMPPPManager not accessing the NMConnection + * or make little/no use of NMActRequest. */ + nm_utils_ppp_ip_methods_enabled(nm_act_request_get_applied_connection(self->config.act_req), + &ip4_enabled, + &ip6_enabled); + self->ip_data_4.ip_enabled = !!ip4_enabled; + self->ip_data_6.ip_enabled = !!ip6_enabled; + + g_signal_connect(self->ppp_manager, + NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, + G_CALLBACK(_ppp_signal_state_changed), + SELF_TO_USERDATA(self)); + g_signal_connect(self->ppp_manager, + NM_PPP_MANAGER_SIGNAL_IFINDEX_SET, + G_CALLBACK(_ppp_signal_ifindex_set), + SELF_TO_USERDATA(self)); + g_signal_connect(self->ppp_manager, + NM_PPP_MANAGER_SIGNAL_NEW_CONFIG, + G_CALLBACK(_ppp_signal_new_config), + SELF_TO_USERDATA(self)); + g_signal_connect(self->ppp_manager, + NM_PPP_MANAGER_SIGNAL_STATS, + G_CALLBACK(_ppp_signal_stats), + SELF_TO_USERDATA(self)); + + platform = nm_netns_get_platform(self->config.netns); + plink = nm_platform_link_get_by_ifname(platform, self->config.parent_iface); + if (plink && !NM_FLAGS_HAS(plink->n_ifi_flags, IFF_UP)) { + nm_platform_link_change_flags(platform, plink->ifindex, IFF_UP, TRUE); + } + + self->ppp_started = TRUE; + if (!nm_ppp_manager_start(self->ppp_manager, + self->config.act_req, + self->config.ppp_username, + 0, + self->config.baud_override, + &error)) { + gs_free char *reason_msg = NULL; + + _set_state_failed(self, NM_PPP_MGR_STATE_FAILED_TO_START, &old_state); + reason_msg = g_strdup_printf("failed to start: %s", error->message); + _callback_emit_state_change(self, + NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + old_state, + FALSE, + FALSE, + NM_DEVICE_STATE_REASON_PPP_START_FAILED, + reason_msg); + return G_SOURCE_CONTINUE; + } + + nm_assert(self->state == NM_PPP_MGR_STATE_STARTING); + _set_state(self, NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX, &old_state); + + self->connect_timeout_source = + nm_g_timeout_add_seconds_source(self->config.timeout_secs, _ifindex_timeout_cb, self); + + _callback_emit_state_change(self, + NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + old_state, + FALSE, + FALSE, + NM_DEVICE_STATE_REASON_NONE, + "pppd is starting"); + + return G_SOURCE_CONTINUE; +} + +/*****************************************************************************/ + +NMPppMgr * +nm_ppp_mgr_start(const NMPppMgrConfig *config, GError **error) +{ + NMPppMgr * self; + NMPPPManager *ppp_manager; + + g_return_val_if_fail(config, NULL); + g_return_val_if_fail(NM_IS_NETNS(config->netns), NULL); + g_return_val_if_fail(config->parent_iface, NULL); + g_return_val_if_fail(NM_IS_ACT_REQUEST(config->act_req), NULL); + g_return_val_if_fail(config->callback, NULL); + g_return_val_if_fail(!error || !*error, NULL); + + ppp_manager = nm_ppp_manager_create(config->parent_iface, error); + + if (!ppp_manager) + return NULL; + + self = g_slice_new(NMPppMgr); + + *self = (NMPppMgr){ + .config = *config, + .ppp_manager = ppp_manager, + .idle_start = nm_g_idle_add_source(_idle_start_cb, self), + .state = NM_PPP_MGR_STATE_STARTING, + .ip_data_4 = + { + .ip_received = FALSE, + .ip_enabled = NM_OPTION_BOOL_DEFAULT, + }, + .ip_data_6 = + { + .ip_received = FALSE, + .ip_enabled = NM_OPTION_BOOL_DEFAULT, + }, + .stats_data = + { + .in_bytes = 0, + .out_bytes = 0, + }, + }; + + g_object_ref(self->config.act_req); + g_object_ref(self->config.netns); + self->config.parent_iface = g_strdup(self->config.parent_iface); + self->config.ppp_username = g_strdup(self->config.ppp_username); + + _LOGD("created"); + + return self; +} + +void +nm_ppp_mgr_destroy(NMPppMgr *self) +{ + if (!self) + return; + + _LOGD("destroying"); + + if (self->state < _NM_PPP_MGR_STATE_FAILED_START) + _set_state_failed(self, NM_PPP_MGR_STATE_FAILED, NULL); + + nm_clear_g_source_inst(&self->idle_start); + nm_clear_g_source_inst(&self->connect_timeout_source); + + g_object_unref(self->config.act_req); + + g_free((char *) self->config.parent_iface); + g_free((char *) self->config.ppp_username); + + g_object_unref(self->config.netns); + + nm_g_slice_free(self); +} diff --git a/src/core/ppp/nm-ppp-mgr.h b/src/core/ppp/nm-ppp-mgr.h new file mode 100644 index 0000000000..f1aca4ed7a --- /dev/null +++ b/src/core/ppp/nm-ppp-mgr.h @@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __NM_PPP_MGR_H__ +#define __NM_PPP_MGR_H__ + +#include "nm-l3cfg.h" + +typedef struct _NMPppMgr NMPppMgr; + +typedef enum _nm_packed { + /* NMPppMgr is starting. It will call nm_ppp_manager_start() on an idle + * handler. */ + NM_PPP_MGR_STATE_STARTING, + + /* NMPppMgr called nm_ppp_manager_start() and is now waiting to get + * an ifindex. At this time, we theoretically might already get IP configuration + * but that is cached and meaningless until we have the ifindex. */ + NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX, + + /* NMPppMgr received an ifindex from NMPPPManager. But no IP configuration + * is yet received. */ + NM_PPP_MGR_STATE_HAVE_IFINDEX, + + /* NMPppMgr received an ifindex and IP configuration from NMPPPManager. + * Whether we have IPv4 and/or IPv6 is unspecified. + * + * If we have only either IPv4 or IPv6, then it's also unclear unknown + * whether the other address family will still arrive or not. */ + NM_PPP_MGR_STATE_HAVE_IP_CONFIG, + + /* Meta enum value which is the first failed state. All states larger than + * this are final (dead) states. */ + _NM_PPP_MGR_STATE_FAILED_START, + + /* NMPPPManager failed to start. This is a final (dead) state. */ + NM_PPP_MGR_STATE_FAILED_TO_START = _NM_PPP_MGR_STATE_FAILED_START, + + /* NMPppMgr started, but it failed to get the ifindex (possibly after timeout). + * This is a final (dead) state. */ + NM_PPP_MGR_STATE_FAILED_TO_IFINDEX, + + /* An unspecified failed state. This is a final (dead) state. */ + NM_PPP_MGR_STATE_FAILED, +} NMPppMgrState; + +const char *nm_ppp_mgr_state_to_string(NMPppMgrState state); + +typedef enum { + NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED, + NM_PPP_MGR_CALLBACK_TYPE_STATS_CHANGED, +} NMPppMgrCallbackType; + +const char *nm_ppp_mgr_callback_type_to_string(NMPppMgrCallbackType callback_type); + +typedef struct { + guint32 in_bytes; + guint32 out_bytes; +} NMPppMgrStatsData; + +typedef struct { + const NML3ConfigData * l3cd; + const NMUtilsIPv6IfaceId *ipv6_iid; + NMOptionBool ip_enabled; + bool ip_received; +} NMPppMgrIPData; + +typedef struct { + NMPppMgrCallbackType callback_type; + union { + struct { + const char *reason_msg; + union { + struct { + const NMPppMgrIPData *ip_data_6; + const NMPppMgrIPData *ip_data_4; + }; + const NMPppMgrIPData *ip_data_x[2]; + }; + const NMPppMgrStatsData *stats_data; + int ifindex; + NMDeviceStateReason reason; + NMPppMgrState old_state; + NMPppMgrState state; + union { + struct { + bool ip_changed_6; + bool ip_changed_4; + }; + bool ip_changed_x[2]; + }; + } data; + }; +} NMPppMgrCallbackData; + +typedef void (*NMPppMgrCallback)(NMPppMgr * self, + const NMPppMgrCallbackData *callback_data, + gpointer user_data); + +typedef struct { + NMNetns * netns; + const char *parent_iface; + + NMPppMgrCallback callback; + gpointer user_data; + + NMActRequest *act_req; + const char * ppp_username; + guint32 timeout_secs; + guint baud_override; +} NMPppMgrConfig; + +gboolean _nm_assert_is_ppp_mgr(const NMPppMgr *self); + +#define NM_IS_PPP_MGR(self) \ + ({ \ + const NMPppMgr *_self = (self); \ + \ + nm_assert(_nm_assert_is_ppp_mgr(_self)); \ + !!_self; \ + }) + +NMPppMgr *nm_ppp_mgr_start(const NMPppMgrConfig *config, GError **error); + +NMPppMgrState nm_ppp_mgr_get_state(const NMPppMgr *self); +int nm_ppp_mgr_get_ifindex(const NMPppMgr *self); +const NMPppMgrIPData * nm_ppp_mgr_get_ip_data(const NMPppMgr *self, int addr_family); +const NMPppMgrStatsData *nm_ppp_mgr_get_stats(const NMPppMgr *self); + +void nm_ppp_mgr_destroy(NMPppMgr *self); + +#endif /* __NM_PPP_MGR_H__ */ diff --git a/src/core/ppp/nm-ppp-plugin-api.h b/src/core/ppp/nm-ppp-plugin-api.h index 647e1c240e..a867b94920 100644 --- a/src/core/ppp/nm-ppp-plugin-api.h +++ b/src/core/ppp/nm-ppp-plugin-api.h @@ -11,12 +11,6 @@ typedef const struct { NMPPPManager *(*create)(const char *iface); - void (*set_route_parameters)(NMPPPManager *manager, - guint32 route_table_v4, - guint32 route_metric_v4, - guint32 route_table_v6, - guint32 route_metric_v6); - gboolean (*start)(NMPPPManager *manager, NMActRequest *req, const char * ppp_name, diff --git a/src/core/ppp/nm-ppp-status.h b/src/core/ppp/nm-ppp-status.h index c346b119a2..df0ac10ba2 100644 --- a/src/core/ppp/nm-ppp-status.h +++ b/src/core/ppp/nm-ppp-status.h @@ -22,7 +22,10 @@ typedef enum { NM_PPP_STATUS_TERMINATE, NM_PPP_STATUS_DISCONNECT, NM_PPP_STATUS_HOLDOFF, - NM_PPP_STATUS_MASTER + NM_PPP_STATUS_MASTER, + + /* these states are internal and not announced by the pppd plugin. */ + NM_PPP_STATUS_INTERN_DEAD, } NMPPPStatus; #endif /* __NM_PPP_STATUS_H__ */ diff --git a/src/core/tests/meson.build b/src/core/tests/meson.build index 99fa0ae9a1..78c689f798 100644 --- a/src/core/tests/meson.build +++ b/src/core/tests/meson.build @@ -6,8 +6,6 @@ test_units = [ 'test-core', 'test-core-with-expect', 'test-dcb', - 'test-ip4-config', - 'test-ip6-config', 'test-l3cfg', 'test-utils', 'test-wired-defname', diff --git a/src/core/tests/test-ip4-config.c b/src/core/tests/test-ip4-config.c deleted file mode 100644 index 3a095d4ad9..0000000000 --- a/src/core/tests/test-ip4-config.c +++ /dev/null @@ -1,380 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2013 - 2014 Red Hat, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include - -#include "nm-ip4-config.h" -#include "libnm-platform/nm-platform.h" - -#include "nm-test-utils-core.h" - -static NMIP4Config * -build_test_config(void) -{ - NMIP4Config * config; - NMPlatformIP4Address addr; - NMPlatformIP4Route route; - - /* Build up the config to subtract */ - config = nmtst_ip4_config_new(1); - - nm_assert(NM_IP_CONFIG_CAST(config)); - - addr = *nmtst_platform_ip4_address("192.168.1.10", "1.2.3.4", 24); - nm_ip4_config_add_address(config, &addr); - - route = *nmtst_platform_ip4_route("10.0.0.0", 8, "192.168.1.1"); - nm_ip4_config_add_route(config, &route, NULL); - - route = *nmtst_platform_ip4_route("172.16.0.0", 16, "192.168.1.1"); - nm_ip4_config_add_route(config, &route, NULL); - - { - const NMPlatformIP4Route r = { - .rt_source = NM_IP_CONFIG_SOURCE_DHCP, - .gateway = nmtst_inet4_from_string("192.168.1.1"), - .table_coerced = 0, - .metric = 100, - }; - - nm_ip4_config_add_route(config, &r, NULL); - } - - nm_ip4_config_add_nameserver(config, nmtst_inet4_from_string("4.2.2.1")); - nm_ip4_config_add_nameserver(config, nmtst_inet4_from_string("4.2.2.2")); - nm_ip4_config_add_domain(config, "foobar.com"); - nm_ip4_config_add_domain(config, "baz.com"); - nm_ip4_config_add_search(config, "blahblah.com"); - nm_ip4_config_add_search(config, "beatbox.com"); - - nm_ip4_config_add_nis_server(config, nmtst_inet4_from_string("1.2.3.9")); - nm_ip4_config_add_nis_server(config, nmtst_inet4_from_string("1.2.3.10")); - - nm_ip4_config_add_wins(config, nmtst_inet4_from_string("4.2.3.9")); - nm_ip4_config_add_wins(config, nmtst_inet4_from_string("4.2.3.10")); - - return config; -} - -static void -test_replace(void) -{ - gs_unref_object NMIP4Config *config1 = NULL; - gs_unref_object NMIP4Config *config2 = NULL; - NMPlatformIP4Address addr; - gboolean relevant_changes; - - config1 = nmtst_ip4_config_new(1); - - addr = *nmtst_platform_ip4_address("172.16.0.1", NULL, 24); - addr.timestamp = 10; - addr.preferred = 3600; - addr.lifetime = 7200; - nm_ip4_config_add_address(config1, &addr); - - addr = *nmtst_platform_ip4_address("172.16.0.2", NULL, 24); - addr.timestamp = 10; - addr.preferred = 3600; - addr.lifetime = 7200; - nm_ip4_config_add_address(config1, &addr); - - config2 = nmtst_ip4_config_new(1); - - addr = *nmtst_platform_ip4_address("192.168.1.1", NULL, 24); - addr.timestamp = 40; - addr.preferred = 60; - addr.lifetime = 120; - nm_ip4_config_add_address(config2, &addr); - - addr = *nmtst_platform_ip4_address("172.16.0.2", NULL, 24); - addr.timestamp = 40; - addr.preferred = 60; - addr.lifetime = 120; - nm_ip4_config_add_address(config2, &addr); - - g_assert(nm_ip4_config_replace(config2, config1, &relevant_changes)); - g_assert(relevant_changes); - g_assert(nm_ip4_config_equal(config1, config2)); -} - -static void -test_subtract(void) -{ - NMIP4Config * src, *dst; - NMPlatformIP4Address addr; - NMPlatformIP4Route route; - const NMPlatformIP4Address *test_addr; - const NMPlatformIP4Route * test_route; - const char * expected_addr = "192.168.1.12"; - guint32 expected_addr_plen = 24; - const char * expected_route_dest = "8.0.0.0"; - guint32 expected_route_plen = 8; - const char * expected_route_next_hop = "192.168.1.1"; - guint32 expected_ns1 = nmtst_inet4_from_string("8.8.8.8"); - guint32 expected_ns2 = nmtst_inet4_from_string("8.8.8.9"); - const char * expected_domain = "wonderfalls.com"; - const char * expected_search = "somewhere.com"; - guint32 expected_nis = nmtst_inet4_from_string("1.2.3.13"); - guint32 expected_wins = nmtst_inet4_from_string("2.3.4.5"); - guint32 expected_mtu = 1492; - - src = build_test_config(); - - /* add a couple more things to the test config */ - dst = build_test_config(); - addr = *nmtst_platform_ip4_address(expected_addr, NULL, expected_addr_plen); - nm_ip4_config_add_address(dst, &addr); - - route = *nmtst_platform_ip4_route(expected_route_dest, - expected_route_plen, - expected_route_next_hop); - nm_ip4_config_add_route(dst, &route, NULL); - - nm_ip4_config_add_nameserver(dst, expected_ns1); - nm_ip4_config_add_nameserver(dst, expected_ns2); - nm_ip4_config_add_domain(dst, expected_domain); - nm_ip4_config_add_search(dst, expected_search); - - nm_ip4_config_add_nis_server(dst, expected_nis); - nm_ip4_config_add_wins(dst, expected_wins); - - nm_ip4_config_set_mtu(dst, expected_mtu, NM_IP_CONFIG_SOURCE_UNKNOWN); - - nm_ip4_config_subtract(dst, src, 0); - - /* ensure what's left is what we expect */ - g_assert_cmpuint(nm_ip4_config_get_num_addresses(dst), ==, 1); - test_addr = _nmtst_ip4_config_get_address(dst, 0); - g_assert(test_addr != NULL); - g_assert_cmpuint(test_addr->address, ==, nmtst_inet4_from_string(expected_addr)); - g_assert_cmpuint(test_addr->peer_address, ==, test_addr->address); - g_assert_cmpuint(test_addr->plen, ==, expected_addr_plen); - - g_assert(!nm_ip4_config_best_default_route_get(dst)); - g_assert_cmpuint(nmtst_ip4_config_get_gateway(dst), ==, 0); - - g_assert_cmpuint(nm_ip4_config_get_num_routes(dst), ==, 1); - test_route = _nmtst_ip4_config_get_route(dst, 0); - g_assert(test_route != NULL); - g_assert_cmpuint(test_route->network, ==, nmtst_inet4_from_string(expected_route_dest)); - g_assert_cmpuint(test_route->plen, ==, expected_route_plen); - g_assert_cmpuint(test_route->gateway, ==, nmtst_inet4_from_string(expected_route_next_hop)); - - g_assert_cmpuint(nm_ip4_config_get_num_nameservers(dst), ==, 2); - g_assert_cmpuint(nm_ip4_config_get_nameserver(dst, 0), ==, expected_ns1); - g_assert_cmpuint(nm_ip4_config_get_nameserver(dst, 1), ==, expected_ns2); - - g_assert_cmpuint(nm_ip4_config_get_num_domains(dst), ==, 1); - g_assert_cmpstr(nm_ip4_config_get_domain(dst, 0), ==, expected_domain); - g_assert_cmpuint(nm_ip4_config_get_num_searches(dst), ==, 1); - g_assert_cmpstr(nm_ip4_config_get_search(dst, 0), ==, expected_search); - - g_assert_cmpuint(nm_ip4_config_get_num_nis_servers(dst), ==, 1); - g_assert_cmpuint(nm_ip4_config_get_nis_server(dst, 0), ==, expected_nis); - - g_assert_cmpuint(nm_ip4_config_get_num_wins(dst), ==, 1); - g_assert_cmpuint(nm_ip4_config_get_wins(dst, 0), ==, expected_wins); - - g_assert_cmpuint(nm_ip4_config_get_mtu(dst), ==, expected_mtu); - - g_object_unref(src); - g_object_unref(dst); -} - -static void -test_compare_with_source(void) -{ - NMIP4Config * a, *b; - NMPlatformIP4Address addr; - NMPlatformIP4Route route; - - a = nmtst_ip4_config_new(1); - b = nmtst_ip4_config_new(2); - - /* Address */ - addr = *nmtst_platform_ip4_address("1.2.3.4", NULL, 24); - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_address(a, &addr); - - addr.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_address(b, &addr); - - /* Route */ - route = *nmtst_platform_ip4_route("10.0.0.0", 8, "192.168.1.1"); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_route(a, &route, NULL); - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_route(b, &route, NULL); - - /* Assert that the configs are basically the same, eg that the source is ignored */ - g_assert(nm_ip4_config_equal(a, b)); - - g_object_unref(a); - g_object_unref(b); -} - -static void -test_add_address_with_source(void) -{ - NMIP4Config * a; - NMPlatformIP4Address addr; - const NMPlatformIP4Address *test_addr; - - a = nmtst_ip4_config_new(1); - - /* Test that a higher priority source is not overwritten */ - addr = *nmtst_platform_ip4_address("1.2.3.4", NULL, 24); - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_address(a, &addr); - - test_addr = _nmtst_ip4_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - addr.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_address(a, &addr); - - test_addr = _nmtst_ip4_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - /* Test that a lower priority address source is overwritten */ - _nmtst_ip4_config_del_address(a, 0); - addr.addr_source = NM_IP_CONFIG_SOURCE_KERNEL; - nm_ip4_config_add_address(a, &addr); - - test_addr = _nmtst_ip4_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_address(a, &addr); - - test_addr = _nmtst_ip4_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - g_object_unref(a); -} - -static void -test_add_route_with_source(void) -{ - gs_unref_object NMIP4Config *a = NULL; - NMPlatformIP4Route route; - const NMPlatformIP4Route * test_route; - - a = nmtst_ip4_config_new(1); - - /* Test that a higher priority source is not overwritten */ - route = *nmtst_platform_ip4_route("1.2.3.0", 24, "1.2.3.1"); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip4_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip4_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - _nmtst_ip4_config_del_route(a, 0); - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 0); - - /* Test that a lower priority address source is overwritten */ - route.rt_source = NM_IP_CONFIG_SOURCE_RTPROT_KERNEL; - nm_ip4_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip4_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_RTPROT_KERNEL); - - route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL; - nm_ip4_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip4_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); -} - -static void -test_merge_subtract_mtu(void) -{ - NMIP4Config *cfg1, *cfg2, *cfg3; - guint32 expected_mtu2 = 1492; - guint32 expected_mtu3 = 666; - - cfg1 = build_test_config(); - cfg2 = build_test_config(); - cfg3 = build_test_config(); - - /* add MSS, MTU to configs to test them */ - nm_ip4_config_set_mtu(cfg2, expected_mtu2, NM_IP_CONFIG_SOURCE_UNKNOWN); - nm_ip4_config_set_mtu(cfg3, expected_mtu3, NM_IP_CONFIG_SOURCE_UNKNOWN); - - nm_ip4_config_merge(cfg1, cfg2, NM_IP_CONFIG_MERGE_DEFAULT, 0); - /* ensure MSS and MTU are in cfg1 */ - g_assert_cmpuint(nm_ip4_config_get_mtu(cfg1), ==, expected_mtu2); - - nm_ip4_config_merge(cfg1, cfg3, NM_IP_CONFIG_MERGE_DEFAULT, 0); - /* ensure again the MSS and MTU in cfg1 got overridden */ - g_assert_cmpuint(nm_ip4_config_get_mtu(cfg1), ==, expected_mtu3); - - nm_ip4_config_subtract(cfg1, cfg3, 0); - /* ensure MSS and MTU are zero in cfg1 */ - g_assert_cmpuint(nm_ip4_config_get_mtu(cfg1), ==, 0); - - g_object_unref(cfg1); - g_object_unref(cfg2); - g_object_unref(cfg3); -} - -static void -test_strip_search_trailing_dot(void) -{ - NMIP4Config *config; - - config = nmtst_ip4_config_new(1); - - nm_ip4_config_add_search(config, "."); - nm_ip4_config_add_search(config, "foo"); - nm_ip4_config_add_search(config, "bar."); - nm_ip4_config_add_search(config, "baz.com"); - nm_ip4_config_add_search(config, "baz.com."); - nm_ip4_config_add_search(config, "foobar.."); - nm_ip4_config_add_search(config, ".foobar"); - nm_ip4_config_add_search(config, "~."); - - g_assert_cmpuint(nm_ip4_config_get_num_searches(config), ==, 4); - g_assert_cmpstr(nm_ip4_config_get_search(config, 0), ==, "foo"); - g_assert_cmpstr(nm_ip4_config_get_search(config, 1), ==, "bar"); - g_assert_cmpstr(nm_ip4_config_get_search(config, 2), ==, "baz.com"); - g_assert_cmpstr(nm_ip4_config_get_search(config, 3), ==, "~"); - - g_object_unref(config); -} - -/*****************************************************************************/ - -NMTST_DEFINE(); - -int -main(int argc, char **argv) -{ - nmtst_init_with_logging(&argc, &argv, NULL, "DEFAULT"); - - g_test_add_func("/ip4-config/replace", test_replace); - g_test_add_func("/ip4-config/subtract", test_subtract); - g_test_add_func("/ip4-config/compare-with-source", test_compare_with_source); - g_test_add_func("/ip4-config/add-address-with-source", test_add_address_with_source); - g_test_add_func("/ip4-config/add-route-with-source", test_add_route_with_source); - g_test_add_func("/ip4-config/merge-subtract-mtu", test_merge_subtract_mtu); - g_test_add_func("/ip4-config/strip-search-trailing-dot", test_strip_search_trailing_dot); - - return g_test_run(); -} diff --git a/src/core/tests/test-ip6-config.c b/src/core/tests/test-ip6-config.c deleted file mode 100644 index 2e6d8aaa19..0000000000 --- a/src/core/tests/test-ip6-config.c +++ /dev/null @@ -1,538 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2013 Red Hat, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include -#include - -#include "nm-ip6-config.h" - -#include "libnm-platform/nm-platform.h" -#include "nm-test-utils-core.h" - -static NMIP6Config * -build_test_config(void) -{ - NMIP6Config *config; - - /* Build up the config to subtract */ - config = nmtst_ip6_config_new(1); - - nm_ip6_config_add_address(config, - nmtst_platform_ip6_address("abcd:1234:4321::cdde", "1:2:3:4::5", 64)); - nm_ip6_config_add_route( - config, - nmtst_platform_ip6_route("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL), - NULL); - nm_ip6_config_add_route(config, - nmtst_platform_ip6_route("2001::", 16, "2001:abba::2234", NULL), - NULL); - - nm_ip6_config_add_route(config, - nmtst_platform_ip6_route("::", 0, "3001:abba::3234", NULL), - NULL); - - nm_ip6_config_add_nameserver(config, nmtst_inet6_from_string("1:2:3:4::1")); - nm_ip6_config_add_nameserver(config, nmtst_inet6_from_string("1:2:3:4::2")); - nm_ip6_config_add_domain(config, "foobar.com"); - nm_ip6_config_add_domain(config, "baz.com"); - nm_ip6_config_add_search(config, "blahblah.com"); - nm_ip6_config_add_search(config, "beatbox.com"); - - return config; -} - -static void -test_subtract(void) -{ - NMIP6Config * src, *dst; - const NMPlatformIP6Address *test_addr; - const NMPlatformIP6Route * test_route; - const char * expected_addr = "1122:3344:5566::7788"; - guint32 expected_addr_plen = 96; - const char * expected_route_dest = "9991:8800::"; - guint32 expected_route_plen = 24; - const char * expected_route_next_hop = "1119:2228:3337:4446::5555"; - struct in6_addr expected_ns1; - struct in6_addr expected_ns2; - const char * expected_domain = "wonderfalls.com"; - const char * expected_search = "somewhere.com"; - struct in6_addr tmp; - - src = build_test_config(); - - /* add a couple more things to the test config */ - dst = build_test_config(); - nm_ip6_config_add_address(dst, - nmtst_platform_ip6_address(expected_addr, NULL, expected_addr_plen)); - nm_ip6_config_add_route(dst, - nmtst_platform_ip6_route(expected_route_dest, - expected_route_plen, - expected_route_next_hop, - NULL), - NULL); - - expected_ns1 = *nmtst_inet6_from_string("2222:3333:4444::5555"); - nm_ip6_config_add_nameserver(dst, &expected_ns1); - expected_ns2 = *nmtst_inet6_from_string("2222:3333:4444::5556"); - nm_ip6_config_add_nameserver(dst, &expected_ns2); - - nm_ip6_config_add_domain(dst, expected_domain); - nm_ip6_config_add_search(dst, expected_search); - - nm_ip6_config_subtract(dst, src, 0); - - /* ensure what's left is what we expect */ - g_assert_cmpuint(nm_ip6_config_get_num_addresses(dst), ==, 1); - test_addr = _nmtst_ip6_config_get_address(dst, 0); - g_assert(test_addr != NULL); - tmp = *nmtst_inet6_from_string(expected_addr); - g_assert(memcmp(&test_addr->address, &tmp, sizeof(tmp)) == 0); - g_assert(memcmp(&test_addr->peer_address, &in6addr_any, sizeof(tmp)) == 0); - g_assert_cmpuint(test_addr->plen, ==, expected_addr_plen); - - g_assert(nm_ip6_config_best_default_route_get(dst) == NULL); - - g_assert_cmpuint(nm_ip6_config_get_num_routes(dst), ==, 1); - test_route = _nmtst_ip6_config_get_route(dst, 0); - g_assert(test_route != NULL); - - tmp = *nmtst_inet6_from_string(expected_route_dest); - g_assert(memcmp(&test_route->network, &tmp, sizeof(tmp)) == 0); - g_assert_cmpuint(test_route->plen, ==, expected_route_plen); - tmp = *nmtst_inet6_from_string(expected_route_next_hop); - g_assert(memcmp(&test_route->gateway, &tmp, sizeof(tmp)) == 0); - - g_assert_cmpuint(nm_ip6_config_get_num_nameservers(dst), ==, 2); - g_assert(memcmp(nm_ip6_config_get_nameserver(dst, 0), &expected_ns1, sizeof(expected_ns1)) - == 0); - g_assert(memcmp(nm_ip6_config_get_nameserver(dst, 1), &expected_ns2, sizeof(expected_ns2)) - == 0); - - g_assert_cmpuint(nm_ip6_config_get_num_domains(dst), ==, 1); - g_assert_cmpstr(nm_ip6_config_get_domain(dst, 0), ==, expected_domain); - g_assert_cmpuint(nm_ip6_config_get_num_searches(dst), ==, 1); - g_assert_cmpstr(nm_ip6_config_get_search(dst, 0), ==, expected_search); - - g_object_unref(src); - g_object_unref(dst); -} - -static void -test_compare_with_source(void) -{ - NMIP6Config * a, *b; - NMPlatformIP6Address addr; - NMPlatformIP6Route route; - - a = nmtst_ip6_config_new(1); - b = nmtst_ip6_config_new(2); - - /* Address */ - addr = *nmtst_platform_ip6_address("1122:3344:5566::7788", NULL, 64); - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_address(a, &addr); - - addr.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_address(b, &addr); - - /* Route */ - route = *nmtst_platform_ip6_route("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_route(a, &route, NULL); - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_route(b, &route, NULL); - - /* Assert that the configs are basically the same, eg that the source is ignored */ - g_assert(nm_ip6_config_equal(a, b)); - - g_object_unref(a); - g_object_unref(b); -} - -static void -test_add_address_with_source(void) -{ - NMIP6Config * a; - NMPlatformIP6Address addr; - const NMPlatformIP6Address *test_addr; - - a = nmtst_ip6_config_new(1); - - /* Test that a higher priority source is not overwritten */ - addr = *nmtst_platform_ip6_address("1122:3344:5566::7788", NULL, 64); - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_address(a, &addr); - - test_addr = _nmtst_ip6_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - addr.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_address(a, &addr); - - test_addr = _nmtst_ip6_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - /* Test that a lower priority address source is overwritten */ - _nmtst_ip6_config_del_address(a, 0); - addr.addr_source = NM_IP_CONFIG_SOURCE_KERNEL; - nm_ip6_config_add_address(a, &addr); - - test_addr = _nmtst_ip6_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_address(a, &addr); - - test_addr = _nmtst_ip6_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - g_object_unref(a); -} - -static void -test_add_route_with_source(void) -{ - gs_unref_object NMIP6Config *a = NULL; - NMPlatformIP6Route route; - const NMPlatformIP6Route * test_route; - - a = nmtst_ip6_config_new(1); - - /* Test that a higher priority source is not overwritten */ - route = *nmtst_platform_ip6_route("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip6_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip6_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - _nmtst_ip6_config_del_route(a, 0); - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 0); - - /* Test that a lower priority address source is overwritten */ - route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL; - nm_ip6_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip6_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip6_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); -} - -static void -test_nm_ip6_config_addresses_sort_check(NMIP6Config * config, - NMSettingIP6ConfigPrivacy use_tempaddr, - int repeat) -{ - int addr_count = nm_ip6_config_get_num_addresses(config); - int i, irepeat; - NMIP6Config *copy, *copy2; - int * idx = g_new(int, addr_count); - - nm_ip6_config_set_privacy(config, use_tempaddr); - copy = nm_ip6_config_clone(config); - g_assert(copy); - copy2 = nm_ip6_config_clone(config); - g_assert(copy2); - - /* initialize the array of indices, and keep shuffling them for every @repeat iteration. */ - for (i = 0; i < addr_count; i++) - idx[i] = i; - - for (irepeat = 0; irepeat < repeat; irepeat++) { - /* randomly shuffle the addresses. */ - nm_ip6_config_reset_addresses(copy); - for (i = 0; i < addr_count; i++) { - int j = g_rand_int_range(nmtst_get_rand(), i, addr_count); - - NM_SWAP(&idx[i], &idx[j]); - nm_ip6_config_add_address(copy, _nmtst_ip6_config_get_address(config, idx[i])); - } - - /* reorder them again */ - _nmtst_ip6_config_addresses_sort(copy); - - /* check equality using nm_ip6_config_equal() */ - if (!nm_ip6_config_equal(copy, config)) { - g_message("%s", "SORTING yields unexpected output:"); - for (i = 0; i < addr_count; i++) { - g_message( - " >> [%d] = %s", - i, - nm_platform_ip6_address_to_string(_nmtst_ip6_config_get_address(config, i), - NULL, - 0)); - g_message(" << [%d] = %s", - i, - nm_platform_ip6_address_to_string(_nmtst_ip6_config_get_address(copy, i), - NULL, - 0)); - } - g_assert_not_reached(); - } - - /* also check equality using nm_ip6_config_replace() */ - g_assert(nm_ip6_config_replace(copy2, copy, NULL) == FALSE); - } - - g_free(idx); - g_object_unref(copy); - g_object_unref(copy2); -} - -static void -test_nm_ip6_config_addresses_sort(void) -{ - NMIP6Config *config = build_test_config(); - -#define ADDR_ADD(...) \ - nm_ip6_config_add_address(config, nmtst_platform_ip6_address_full(__VA_ARGS__)) - - nm_ip6_config_reset_addresses(config); - ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::6", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_NDISC, - 0, - 0, - 0, - IFA_F_MANAGETEMPADDR); - ADDR_ADD("2607:f0d0:1002:51::3", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::8", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::0", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_KERNEL, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("fec0::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::2", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_TENTATIVE); - test_nm_ip6_config_addresses_sort_check(config, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, 8); - test_nm_ip6_config_addresses_sort_check(config, NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED, 8); - test_nm_ip6_config_addresses_sort_check(config, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR, - 8); - - nm_ip6_config_reset_addresses(config); - ADDR_ADD("2607:f0d0:1002:51::3", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::8", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::0", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_KERNEL, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::6", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_NDISC, - 0, - 0, - 0, - IFA_F_MANAGETEMPADDR); - ADDR_ADD("fec0::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::2", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_TENTATIVE); - test_nm_ip6_config_addresses_sort_check(config, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, - 8); - -#undef ADDR_ADD - g_object_unref(config); -} - -static void -test_strip_search_trailing_dot(void) -{ - NMIP6Config *config; - - config = nmtst_ip6_config_new(1); - - nm_ip6_config_add_search(config, "."); - nm_ip6_config_add_search(config, "foo"); - nm_ip6_config_add_search(config, "bar."); - nm_ip6_config_add_search(config, "baz.com"); - nm_ip6_config_add_search(config, "baz.com."); - nm_ip6_config_add_search(config, "foobar.."); - nm_ip6_config_add_search(config, ".foobar"); - nm_ip6_config_add_search(config, "~."); - - g_assert_cmpuint(nm_ip6_config_get_num_searches(config), ==, 4); - g_assert_cmpstr(nm_ip6_config_get_search(config, 0), ==, "foo"); - g_assert_cmpstr(nm_ip6_config_get_search(config, 1), ==, "bar"); - g_assert_cmpstr(nm_ip6_config_get_search(config, 2), ==, "baz.com"); - g_assert_cmpstr(nm_ip6_config_get_search(config, 3), ==, "~"); - - g_object_unref(config); -} - -/*****************************************************************************/ - -static void -test_replace(gconstpointer user_data) -{ - nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = nm_dedup_multi_index_new(); - const int TEST_IDX = GPOINTER_TO_INT(user_data); - const int IFINDEX = 1; - gs_unref_object NMIP6Config *src_conf = NULL; - gs_unref_object NMIP6Config *dst_conf = NULL; - NMPlatformIP6Address * addr; - NMPlatformIP6Address addrs[5] = {}; - guint addrs_n = 0; - guint i; - - dst_conf = nm_ip6_config_new(multi_idx, IFINDEX); - src_conf = nm_ip6_config_new(multi_idx, IFINDEX); - - switch (TEST_IDX) { - case 1: - addr = &addrs[addrs_n++]; - addr->ifindex = IFINDEX; - addr->address = *nmtst_inet6_from_string("fe80::78ec:7a6d:602d:20f2"); - addr->plen = 64; - addr->n_ifa_flags = IFA_F_PERMANENT; - addr->addr_source = NM_IP_CONFIG_SOURCE_KERNEL; - break; - case 2: - addr = &addrs[addrs_n++]; - addr->ifindex = IFINDEX; - addr->address = *nmtst_inet6_from_string("fe80::78ec:7a6d:602d:20f2"); - addr->plen = 64; - addr->n_ifa_flags = IFA_F_PERMANENT; - addr->addr_source = NM_IP_CONFIG_SOURCE_KERNEL; - - addr = &addrs[addrs_n++]; - addr->ifindex = IFINDEX; - addr->address = *nmtst_inet6_from_string("1::1"); - addr->plen = 64; - addr->addr_source = NM_IP_CONFIG_SOURCE_USER; - - nm_ip6_config_add_address(dst_conf, addr); - break; - default: - g_assert_not_reached(); - } - - g_assert(addrs_n < G_N_ELEMENTS(addrs)); - - for (i = 0; i < addrs_n; i++) - nm_ip6_config_add_address(src_conf, &addrs[i]); - - nm_ip6_config_replace(dst_conf, src_conf, NULL); - - for (i = 0; i < addrs_n; i++) { - const NMPlatformIP6Address *a = _nmtst_ip6_config_get_address(dst_conf, i); - const NMPlatformIP6Address *b = _nmtst_ip6_config_get_address(src_conf, i); - - g_assert(nm_platform_ip6_address_cmp(&addrs[i], a) == 0); - g_assert(nm_platform_ip6_address_cmp(&addrs[i], b) == 0); - } - g_assert(addrs_n == nm_ip6_config_get_num_addresses(dst_conf)); - g_assert(addrs_n == nm_ip6_config_get_num_addresses(src_conf)); -} - -/*****************************************************************************/ - -NMTST_DEFINE(); - -int -main(int argc, char **argv) -{ - nmtst_init_with_logging(&argc, &argv, NULL, "ALL"); - - g_test_add_func("/ip6-config/subtract", test_subtract); - g_test_add_func("/ip6-config/compare-with-source", test_compare_with_source); - g_test_add_func("/ip6-config/add-address-with-source", test_add_address_with_source); - g_test_add_func("/ip6-config/add-route-with-source", test_add_route_with_source); - g_test_add_func("/ip6-config/test_nm_ip6_config_addresses_sort", - test_nm_ip6_config_addresses_sort); - g_test_add_func("/ip6-config/strip-search-trailing-dot", test_strip_search_trailing_dot); - g_test_add_data_func("/ip6-config/replace/1", GINT_TO_POINTER(1), test_replace); - g_test_add_data_func("/ip6-config/replace/2", GINT_TO_POINTER(2), test_replace); - - return g_test_run(); -} diff --git a/src/core/tests/test-l3cfg.c b/src/core/tests/test-l3cfg.c index 100c24967a..b5c85b8224 100644 --- a/src/core/tests/test-l3cfg.c +++ b/src/core/tests/test-l3cfg.c @@ -22,9 +22,9 @@ _netns_access_l3cfg(NMNetns *netns, int ifindex) g_assert(NM_IS_NETNS(netns)); g_assert(ifindex > 0); - g_assert(!nm_netns_get_l3cfg(netns, ifindex)); + g_assert(!nm_netns_l3cfg_get(netns, ifindex)); - l3cfg = nm_netns_access_l3cfg(netns, ifindex); + l3cfg = nm_netns_l3cfg_acquire(netns, ifindex); g_assert(NM_IS_L3CFG(l3cfg)); return l3cfg; } diff --git a/src/core/vpn/nm-vpn-connection.c b/src/core/vpn/nm-vpn-connection.c index d2034278c0..5e0990ff62 100644 --- a/src/core/vpn/nm-vpn-connection.c +++ b/src/core/vpn/nm-vpn-connection.c @@ -8,32 +8,55 @@ #include "nm-vpn-connection.h" -#include -#include #include -#include -#include -#include #include #include +#include +#include +#include +#include +#include -#include "nm-proxy-config.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" -#include "libnm-platform/nm-platform.h" -#include "nm-active-connection.h" #include "NetworkManagerUtils.h" -#include "settings/nm-settings-connection.h" -#include "nm-dispatcher.h" -#include "nm-netns.h" -#include "settings/nm-agent-manager.h" -#include "libnm-core-intern/nm-core-internal.h" -#include "nm-pacrunner-manager.h" -#include "nm-firewalld-manager.h" -#include "nm-config.h" -#include "nm-vpn-plugin-info.h" -#include "nm-vpn-manager.h" #include "dns/nm-dns-manager.h" +#include "libnm-core-intern/nm-core-internal.h" +#include "libnm-glib-aux/nm-dbus-aux.h" +#include "libnm-platform/nm-platform.h" +#include "libnm-std-aux/unaligned.h" +#include "nm-active-connection.h" +#include "nm-config.h" +#include "nm-dbus-manager.h" +#include "nm-dispatcher.h" +#include "nm-firewalld-manager.h" +#include "nm-ip-config.h" +#include "nm-l3-config-data.h" +#include "nm-netns.h" +#include "nm-pacrunner-manager.h" +#include "nm-vpn-manager.h" +#include "nm-vpn-plugin-info.h" +#include "settings/nm-agent-manager.h" +#include "settings/nm-settings-connection.h" + +/* FIXME(l3cfg): Check that we handle it correctly if the parent device is VRF type. */ + +/* FIXME(l3cfg): Proxy settings are no longer configured. That needs to be handled by NML3Cfg. */ + +/*****************************************************************************/ + +#define DBUS_DEFAULT_TIMEOUT_MSEC 10000 + +typedef enum { + L3CD_TYPE_GW_EXTERN, + + L3CD_TYPE_STATIC, + L3CD_TYPE_GENERIC, + L3CD_TYPE_IP_4, + L3CD_TYPE_IP_6, + +#define L3CD_TYPE_IP_X(IS_IPv4) ((IS_IPv4) ? L3CD_TYPE_IP_4 : L3CD_TYPE_IP_6) + + _L3CD_TYPE_NUM, +} L3CDType; typedef enum { /* Only system secrets */ @@ -78,6 +101,22 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMVpnConnection, PROP_VPN_STATE, PROP_BANNER, #define PROP_MASTER 2002 ); +typedef struct { + NMIPConfig *ip_config; + + NMIPAddr gw_internal; + NMIPAddr gw_external; + + /* Whether this address family is enabled. If not, then we won't have a l3cd instance, + * but the activation for this address family is still complete. */ + bool enabled : 1; + + /* Whether this address family is ready. This means we received the IP configuration. + * Usually this implies we also have a corresponding l3cd, but that might not be the + * case if this address family is disabled. */ + bool conf_ready : 1; +} IPData; + typedef struct { gboolean service_can_persist; gboolean connection_can_persist; @@ -91,42 +130,65 @@ typedef struct { NMActiveConnectionStateReason failure_reason; NMVpnServiceState service_state; - guint start_timeout; - gboolean service_running; + GSource * start_timeout_source; NMVpnPluginInfo * plugin_info; - char * bus_name; - - NMFirewalldManagerCallId *fw_call; NMNetns *netns; - GPtrArray *ip4_dev_route_blacklist; + NML3Cfg * l3cfg_if; + NML3CfgCommitTypeHandle *l3cfg_commit_type_if; - GDBusProxy * proxy; - GCancellable * cancellable; + NML3Cfg * l3cfg_dev; + NML3CfgCommitTypeHandle *l3cfg_commit_type_dev; + + struct { + GDBusConnection *connection; + char * bus_name; + char * owner; + guint signal_id_vpn; + guint signal_id_name_changed; + bool name_owner_initialized : 1; + } dbus; + + NMFirewalldManagerCallId *fw_call; + + union { + const NML3ConfigData *const l3cds[_L3CD_TYPE_NUM]; + const NML3ConfigData * l3cds_[_L3CD_TYPE_NUM]; + }; + + /* This combines the l3cds of the VPN (basically, excluding l3cd_gw_extern which + * is only about configuration for the parent device). This is used to configure + * DNS. */ + const NML3ConfigData *l3cd_combined; + + union { + struct { + IPData ip_data_6; + IPData ip_data_4; + }; + IPData ip_data_x[2]; + }; + + GSource * init_fail_on_idle_source; + GSource * connect_timeout_source; + GCancellable * main_cancellable; GVariant * connect_hash; - guint connect_timeout; - NMProxyConfig * proxy_config; + char * banner; NMPacrunnerConfId *pacrunner_conf_id; - gboolean has_ip4; - NMIP4Config * ip4_config; - guint32 ip4_internal_gw; - guint32 ip4_external_gw; - gboolean has_ip6; - NMIP6Config * ip6_config; - /* These config instances are passed on to NMDevice and modified by NMDevice. - * This pointer is only useful for nm_device_replace_vpn4_config() to clear the - * previous configuration. Consider these instances to be owned by NMDevice. */ - NMIP4Config *last_device_ip4_config; - NMIP6Config *last_device_ip6_config; + int ifindex_if; + int ifindex_dev; - struct in6_addr *ip6_internal_gw; - struct in6_addr *ip6_external_gw; - char * ip_iface; - int ip_ifindex; - char * banner; - guint32 mtu; + guint32 mtu; + + bool wait_for_pre_up_state : 1; + + bool dbus_service_started : 1; + + bool generic_config_received : 1; + + bool l3cds_changed : 1; } NMVpnConnectionPrivate; struct _NMVpnConnection { @@ -151,23 +213,22 @@ static const GDBusSignalInfo signal_info_vpn_state_changed; static NMSettingsConnection *_get_settings_connection(NMVpnConnection *self, gboolean allow_missing); -static void get_secrets(NMVpnConnection *self, SecretsReq secrets_idx, const char *const *hints); +static void _secrets_get(NMVpnConnection *self, SecretsReq secrets_idx, const char *const *hints); static guint32 get_route_table(NMVpnConnection *self, int addr_family, gboolean fallback_main); -static void plugin_interactive_secrets_required(NMVpnConnection * self, - const char * message, - const char *const *secrets); - static void _set_vpn_state(NMVpnConnection * self, VpnState vpn_state, NMActiveConnectionStateReason reason, gboolean quitting); +static void +_l3cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMVpnConnection *self); + /*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_VPN -#define _NMLOG_PREFIX_NAME "vpn-connection" +#define _NMLOG_PREFIX_NAME "vpn" #define __NMLOG_prefix_buf_len 128 @@ -176,6 +237,9 @@ __LOG_create_prefix(char *buf, NMVpnConnection *self, NMSettingsConnection *con) { NMVpnConnectionPrivate *priv; const char * id; + const char * iface; + char buf1[100]; + char buf2[100]; if (!self) return _NMLOG_PREFIX_NAME; @@ -183,13 +247,16 @@ __LOG_create_prefix(char *buf, NMVpnConnection *self, NMSettingsConnection *con) priv = NM_VPN_CONNECTION_GET_PRIVATE(self); id = con ? nm_settings_connection_get_id(con) : NULL; + iface = nm_vpn_connection_get_ip_iface(self, FALSE); + g_snprintf(buf, __NMLOG_prefix_buf_len, "%s[" "%p" /*self*/ "%s%s" /*con-uuid*/ "%s%s%s%s" /*con-id*/ - ",%d" /*ifindex*/ + "%s" /*ifindex_if*/ + "%s" /*ifindex_dev*/ "%s%s%s" /*iface*/ "]", _NMLOG_PREFIX_NAME, @@ -198,8 +265,9 @@ __LOG_create_prefix(char *buf, NMVpnConnection *self, NMSettingsConnection *con) con ? (nm_settings_connection_get_uuid(con) ?: "??") : "", con ? "," : "", NM_PRINT_FMT_QUOTED(id, "\"", id, "\"", con ? "??" : ""), - priv->ip_ifindex, - NM_PRINT_FMT_QUOTED(priv->ip_iface, ":(", priv->ip_iface, ")", "")); + priv->ifindex_if > 0 ? nm_sprintf_buf(buf1, ",if:%d", priv->ifindex_if) : "", + priv->ifindex_dev > 0 ? nm_sprintf_buf(buf2, ",dev:%d", priv->ifindex_dev) : "", + NM_PRINT_FMT_QUOTED(iface, ":(", iface, ")", "")); return buf; } @@ -216,7 +284,7 @@ __LOG_create_prefix(char *buf, NMVpnConnection *self, NMSettingsConnection *con) _nm_log(_level, \ _NMLOG_DOMAIN, \ 0, \ - (self) ? NM_VPN_CONNECTION_GET_PRIVATE(self)->ip_iface : NULL, \ + (self) ? nm_vpn_connection_get_ip_iface(self, FALSE) : NULL, \ (_con) ? nm_settings_connection_get_uuid(_con) : NULL, \ "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ __LOG_create_prefix(__prefix, (self), _con) \ @@ -227,18 +295,58 @@ __LOG_create_prefix(char *buf, NMVpnConnection *self, NMSettingsConnection *con) /*****************************************************************************/ -static void -cancel_get_secrets(NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); +static NM_UTILS_LOOKUP_STR_DEFINE(_l3cd_type_to_string, + L3CDType, + NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT(NULL), + NM_UTILS_LOOKUP_ITEM_IGNORE_OTHER(), + NM_UTILS_LOOKUP_STR_ITEM(L3CD_TYPE_GW_EXTERN, "gw-extern"), + NM_UTILS_LOOKUP_STR_ITEM(L3CD_TYPE_STATIC, "static"), + NM_UTILS_LOOKUP_STR_ITEM(L3CD_TYPE_GENERIC, "generic"), + NM_UTILS_LOOKUP_STR_ITEM(L3CD_TYPE_IP_4, "ip-4"), + NM_UTILS_LOOKUP_STR_ITEM(L3CD_TYPE_IP_6, "ip-6"), ); - if (priv->secrets_id) { - nm_settings_connection_cancel_secrets(_get_settings_connection(self, FALSE), - priv->secrets_id); - g_warn_if_fail(!priv->secrets_id); - priv->secrets_id = NULL; - } -} +static NM_UTILS_LOOKUP_STR_DEFINE( + _vpn_service_state_to_string, + NMVpnServiceState, + NM_UTILS_LOOKUP_DEFAULT(NULL), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_INIT, "init"), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_SHUTDOWN, "shutdown"), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_STARTING, "starting"), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_STARTED, "started"), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_STOPPING, "stopping"), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_STOPPED, "stopped"), ); + +#define vpn_service_state_to_string_a(state) \ + NM_UTILS_LOOKUP_STR_A(_vpn_service_state_to_string, state) + +static NM_UTILS_LOOKUP_STR_DEFINE(_vpn_state_to_string, + VpnState, + NM_UTILS_LOOKUP_DEFAULT(NULL), + NM_UTILS_LOOKUP_STR_ITEM(STATE_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_WAITING, "waiting"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_PREPARE, "prepare"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_NEED_AUTH, "need-auth"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_CONNECT, "connect"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_IP_CONFIG_GET, "ip-config-get"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_PRE_UP, "pre-up"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_ACTIVATED, "activated"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_DEACTIVATING, "deactivating"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_DISCONNECTED, "disconnected"), + NM_UTILS_LOOKUP_STR_ITEM(STATE_FAILED, "failed"), ); + +#define vpn_state_to_string_a(state) NM_UTILS_LOOKUP_STR_A(_vpn_state_to_string, state) + +static NM_UTILS_LOOKUP_STR_DEFINE( + _vpn_plugin_failure_to_string, + NMVpnPluginFailure, + NM_UTILS_LOOKUP_DEFAULT(NULL), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED, "login-failed"), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED, "connect-failed"), + NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG, "bad-ip-config"), ); + +#define vpn_plugin_failure_to_string_a(failure) \ + NM_UTILS_LOOKUP_STR_A(_vpn_plugin_failure_to_string, failure) static NMVpnConnectionState _state_to_nm_vpn_state(VpnState state) @@ -300,6 +408,8 @@ _state_to_ac_state(VpnState vpn_state) return NM_ACTIVE_CONNECTION_STATE_UNKNOWN; } +/*****************************************************************************/ + static NMSettingsConnection * _get_settings_connection(NMVpnConnection *self, gboolean allow_missing) { @@ -325,15 +435,460 @@ _get_applied_connection(NMVpnConnection *connection) return con; } -static void -disconnect_cb(GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - GVariant *variant; +/*****************************************************************************/ - variant = g_dbus_proxy_call_finish(proxy, result, NULL); - if (variant) - g_variant_unref(variant); - g_object_unref(user_data); +static void +_dbus_connection_call(NMVpnConnection * self, + const char * method_name, + GVariant * parameters, + const GVariantType *reply_type, + GAsyncReadyCallback callback) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + g_return_if_fail(priv->dbus.bus_name); + + _LOGT("dbus: call %s on %s", method_name, priv->dbus.bus_name); + g_dbus_connection_call(priv->dbus.connection, + priv->dbus.bus_name, + NM_VPN_DBUS_PLUGIN_PATH, + NM_VPN_DBUS_PLUGIN_INTERFACE, + method_name, + parameters, + reply_type, + G_DBUS_CALL_FLAGS_NONE, + DBUS_DEFAULT_TIMEOUT_MSEC, + priv->main_cancellable, + callback, + self); +} + +static NML3ConfigMergeFlags +_l3cfg_get_merge_flags(NMVpnConnection *self, L3CDType l3cd_type) +{ + NMConnection * applied; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + NML3ConfigMergeFlags merge_flags; + + merge_flags = NM_L3_CONFIG_MERGE_FLAGS_NONE; + + if (l3cd_type == L3CD_TYPE_IP_4) { + applied = _get_applied_connection(self); + s_ip4 = applied ? nm_connection_get_setting_ip_config(applied, AF_INET) : NULL; + + if (s_ip4 && nm_setting_ip_config_get_ignore_auto_routes(s_ip4)) + merge_flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_ROUTES; + if (s_ip4 && nm_setting_ip_config_get_never_default(s_ip4)) + merge_flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_DEFAULT_ROUTES; + if (s_ip4 && nm_setting_ip_config_get_ignore_auto_dns(s_ip4)) + merge_flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_DNS; + } else if (l3cd_type == L3CD_TYPE_IP_6) { + applied = _get_applied_connection(self); + s_ip6 = applied ? nm_connection_get_setting_ip_config(applied, AF_INET6) : NULL; + + if (s_ip6 && nm_setting_ip_config_get_ignore_auto_routes(s_ip6)) + merge_flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_ROUTES; + if (s_ip6 && nm_setting_ip_config_get_never_default(s_ip6)) + merge_flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_DEFAULT_ROUTES; + if (s_ip6 && nm_setting_ip_config_get_ignore_auto_dns(s_ip6)) + merge_flags |= NM_L3_CONFIG_MERGE_FLAGS_NO_DNS; + } + + return merge_flags; +} + +static NML3ConfigData * +_l3cfg_l3cd_new(NMVpnConnection *self, int ifindex) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + return nm_l3_config_data_new(nm_netns_get_multi_idx(priv->netns), + ifindex, + NM_IP_CONFIG_SOURCE_VPN); +} + +/*****************************************************************************/ + +guint32 +nm_vpn_connection_get_ip4_internal_gateway(NMVpnConnection *self) +{ + g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), 0); + + return NM_VPN_CONNECTION_GET_PRIVATE(self)->ip_data_4.gw_internal.addr4; +} + +struct in6_addr * +nm_vpn_connection_get_ip6_internal_gateway(NMVpnConnection *self) +{ + g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), 0); + + return &NM_VPN_CONNECTION_GET_PRIVATE(self)->ip_data_6.gw_internal.addr6; +} + +NMVpnConnectionState +nm_vpn_connection_get_vpn_state(NMVpnConnection *self) +{ + g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NM_VPN_CONNECTION_STATE_UNKNOWN); + + return _state_to_nm_vpn_state(NM_VPN_CONNECTION_GET_PRIVATE(self)->vpn_state); +} + +const char * +nm_vpn_connection_get_banner(NMVpnConnection *self) +{ + g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NULL); + + return NM_VPN_CONNECTION_GET_PRIVATE(self)->banner; +} + +const NML3ConfigData * +nm_vpn_connection_get_l3cd(NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv; + + g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NULL); + + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (priv->l3cds_changed) { + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + L3CDType l3cd_type; + int ifindex; + + priv->l3cds_changed = FALSE; + + ifindex = nm_vpn_connection_get_ip_ifindex(self, TRUE); + + if (ifindex > 0) { + const int default_dns_priority_x[2] = { + NM_DNS_PRIORITY_DEFAULT_VPN, + NM_DNS_PRIORITY_DEFAULT_VPN, + }; + guint32 default_route_table_x[2]; + guint32 default_route_metric_x[2]; + + for (l3cd_type = 0; l3cd_type < _L3CD_TYPE_NUM; l3cd_type++) { + if (l3cd_type == L3CD_TYPE_GW_EXTERN) + continue; + if (!priv->l3cds[l3cd_type]) + continue; + + if (!l3cd) { + default_route_table_x[0] = get_route_table(self, AF_INET6, TRUE); + default_route_table_x[1] = get_route_table(self, AF_INET, TRUE); + default_route_metric_x[0] = + nm_vpn_connection_get_ip_route_metric(self, AF_INET6); + default_route_metric_x[1] = + nm_vpn_connection_get_ip_route_metric(self, AF_INET); + l3cd = _l3cfg_l3cd_new(self, ifindex); + } + + nm_l3_config_data_merge(l3cd, + priv->l3cds[l3cd_type], + _l3cfg_get_merge_flags(self, l3cd_type), + default_route_table_x, + default_route_metric_x, + NULL, + default_dns_priority_x, + NULL, + NULL); + } + } + + nm_l3_config_data_reset(&priv->l3cd_combined, l3cd); + } + + return priv->l3cd_combined; +} + +static int +_get_ifindex_for_device(NMVpnConnection *self) +{ + NMDevice *parent_dev; + int ifindex; + + nm_assert(NM_IS_VPN_CONNECTION(self)); + + parent_dev = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self)); + if (!parent_dev) + return 0; + ifindex = nm_device_get_ip_ifindex(parent_dev); + if (ifindex <= 0) + return 0; + + return ifindex; +} + +const char * +nm_vpn_connection_get_ip_iface(NMVpnConnection *self, gboolean fallback_device) +{ + NMVpnConnectionPrivate *priv; + + g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NULL); + + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (priv->l3cfg_if) + return nm_l3cfg_get_ifname(priv->l3cfg_if, TRUE); + if (fallback_device && priv->l3cfg_dev) + return nm_l3cfg_get_ifname(priv->l3cfg_dev, TRUE); + return NULL; +} + +int +nm_vpn_connection_get_ip_ifindex(NMVpnConnection *self, gboolean fallback_device) +{ + NMVpnConnectionPrivate *priv; + + g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), 0); + + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (priv->ifindex_if > 0) + return priv->ifindex_if; + if (fallback_device && priv->ifindex_dev > 0) + return priv->ifindex_dev; + return 0; +} + +static guint32 +_get_vpn_timeout(NMVpnConnection *self) +{ + guint32 timeout; + NMSettingVpn *s_vpn; + + s_vpn = nm_connection_get_setting_vpn(_get_applied_connection(self)); + g_return_val_if_fail(s_vpn, 60); + + /* Timeout waiting for IP config signal from VPN service + * It is a configured value or 60 seconds */ + timeout = nm_setting_vpn_get_timeout(s_vpn); + if (timeout == 0) { + timeout = nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA, + NM_CON_DEFAULT("vpn.timeout"), + NULL, + 1, + G_MAXUINT32, + 60); + } + return timeout; +} + +/*****************************************************************************/ + +static gboolean +_l3cfg_l3cd_set(NMVpnConnection *self, L3CDType l3cd_type, const NML3ConfigData *l3cd) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (nm_l3_config_data_equal(l3cd, priv->l3cds[l3cd_type])) + return FALSE; + + if (_LOGT_ENABLED()) { + if (l3cd) { + char s_name[150]; + + /* Seal hear, so that we don't log about an unsealed instance. + * nm_l3_config_data_reset() anyway seals the instance too. */ + nm_l3_config_data_seal(l3cd); + + _LOGT("l3cd[%s]: set " NM_HASH_OBFUSCATE_PTR_FMT, + _l3cd_type_to_string(l3cd_type), + NM_HASH_OBFUSCATE_PTR(l3cd)); + nm_l3_config_data_log( + l3cd, + nm_sprintf_buf(s_name, "l3cd[%s]", _l3cd_type_to_string(l3cd_type)), + "vpn-config: ", + LOGL_TRACE, + _NMLOG_DOMAIN); + } else + _LOGT("l3cd[%s]: unset", _l3cd_type_to_string(l3cd_type)); + } + + nm_l3_config_data_reset(&priv->l3cds_[l3cd_type], l3cd); + priv->l3cds_changed = TRUE; + return TRUE; +} + +static void +_l3cfg_l3cd_update(NMVpnConnection *self, L3CDType l3cd_type) +{ + NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NML3Cfg * l3cfg; + int priority; + const NML3ConfigData *const *p_l3cd; + + if (NM_IN_SET(l3cd_type, L3CD_TYPE_IP_4, L3CD_TYPE_IP_6, L3CD_TYPE_GENERIC, L3CD_TYPE_STATIC)) { + l3cfg = priv->l3cfg_if; + if (!l3cfg) { + l3cfg = priv->l3cfg_dev; + } + } else { + nm_assert(NM_IN_SET(l3cd_type, L3CD_TYPE_GW_EXTERN)); + l3cfg = priv->l3cfg_dev; + } + + p_l3cd = &priv->l3cds[l3cd_type]; + + if (!l3cfg) + return; + + if (!*p_l3cd) { + if (!nm_l3cfg_remove_config_all(l3cfg, p_l3cd)) + return; + _LOGT("l3cd[%s]: remove-config " NM_HASH_OBFUSCATE_PTR_FMT, + _l3cd_type_to_string(l3cd_type), + NM_HASH_OBFUSCATE_PTR(*p_l3cd)); + goto handle_changed; + } + + priority = 0; + + if (!nm_l3cfg_add_config(l3cfg, + p_l3cd, + TRUE, + *p_l3cd, + priority, + get_route_table(self, AF_INET, TRUE), + get_route_table(self, AF_INET6, TRUE), + nm_vpn_connection_get_ip_route_metric(self, AF_INET), + nm_vpn_connection_get_ip_route_metric(self, AF_INET6), + 0, + 0, + NM_DNS_PRIORITY_DEFAULT_VPN, + NM_DNS_PRIORITY_DEFAULT_VPN, + NM_L3_ACD_DEFEND_TYPE_ONCE, + 0, + NM_L3CFG_CONFIG_FLAGS_NONE, + _l3cfg_get_merge_flags(self, l3cd_type))) + return; + + _LOGT("l3cd[%s]: add-config " NM_HASH_OBFUSCATE_PTR_FMT, + _l3cd_type_to_string(l3cd_type), + NM_HASH_OBFUSCATE_PTR(*p_l3cd)); + +handle_changed: + nm_l3cfg_commit_on_idle_schedule(l3cfg, NM_L3_CFG_COMMIT_TYPE_AUTO); +} + +static void +_l3cfg_l3cd_update_all(NMVpnConnection *self) +{ + L3CDType l3cd_type; + + for (l3cd_type = 0; l3cd_type < _L3CD_TYPE_NUM; l3cd_type++) + _l3cfg_l3cd_update(self, l3cd_type); +} + +static void +_l3cfg_l3cd_clear_all(NMVpnConnection *self) +{ + L3CDType l3cd_type; + + for (l3cd_type = 0; l3cd_type < _L3CD_TYPE_NUM; l3cd_type++) + _l3cfg_l3cd_set(self, l3cd_type, NULL); + + _l3cfg_l3cd_update_all(self); +} + +static void +_l3cfg_clear(NMVpnConnection *self, NML3Cfg *l3cfg) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + L3CDType l3cd_type; + gboolean changed = FALSE; + + if (!l3cfg) + return; + + g_signal_handlers_disconnect_by_func(l3cfg, G_CALLBACK(_l3cfg_notify_cb), self); + + for (l3cd_type = 0; l3cd_type < _L3CD_TYPE_NUM; l3cd_type++) { + if (nm_l3cfg_remove_config_all(l3cfg, &priv->l3cds[l3cd_type])) + changed = TRUE; + } + + if (changed) + nm_l3cfg_commit_on_idle_schedule(l3cfg, NM_L3_CFG_COMMIT_TYPE_AUTO); +} + +/*****************************************************************************/ + +static void +cancel_get_secrets(NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (priv->secrets_id) { + _LOGT("secrets: cancel request"); + nm_settings_connection_cancel_secrets(_get_settings_connection(self, FALSE), + priv->secrets_id); + nm_assert(!priv->secrets_id); + } +} + +static void +_l3cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (notify_data->notify_type == NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT) { + if (l3cfg == (priv->l3cfg_if ?: priv->l3cfg_dev) && priv->wait_for_pre_up_state + && priv->vpn_state < STATE_PRE_UP) + _set_vpn_state(self, STATE_PRE_UP, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); + } +} + +static gboolean +_set_ip_ifindex(NMVpnConnection *self, int ifindex, gboolean is_if) +{ + NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + int * p_ifindex = is_if ? &priv->ifindex_if : &priv->ifindex_dev; + NML3Cfg ** p_l3cfg = is_if ? &priv->l3cfg_if : &priv->l3cfg_dev; + NML3CfgCommitTypeHandle **p_l3cfg_commit_type = + is_if ? &priv->l3cfg_commit_type_if : &priv->l3cfg_commit_type_dev; + gs_unref_object NML3Cfg *l3cfg_old = NULL; + + if (ifindex < 0) + ifindex = nm_assert_unreachable_val(0); + + if (*p_ifindex == ifindex) + return FALSE; + + _LOGD("set ip-ifindex-%s %d", is_if ? "if" : "dev", ifindex); + + *p_ifindex = ifindex; + + l3cfg_old = g_steal_pointer(p_l3cfg); + nm_l3cfg_commit_type_clear(l3cfg_old, p_l3cfg_commit_type); + _l3cfg_clear(self, l3cfg_old); + + if (ifindex > 0) { + *p_l3cfg = nm_netns_l3cfg_acquire(priv->netns, ifindex); + g_signal_connect(*p_l3cfg, NM_L3CFG_SIGNAL_NOTIFY, G_CALLBACK(_l3cfg_notify_cb), self); + *p_l3cfg_commit_type = + nm_l3cfg_commit_type_register(*p_l3cfg, NM_L3_CFG_COMMIT_TYPE_UPDATE, NULL, "vpn"); + } + + return TRUE; +} + +static void +disconnect_cb(GObject *source, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection *self; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + + res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); + if (nm_utils_error_is_cancelled(error)) + return; + + self = NM_VPN_CONNECTION(user_data); + + _LOGT("dbus: disconnected%s%s", + NM_PRINT_FMT_QUOTED2(error, " failed: ", error->message, " with success")); } static void @@ -348,57 +903,21 @@ fw_call_cleanup(NMVpnConnection *self) } } -static void -remove_parent_device_config(NMVpnConnection *connection, NMDevice *device) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(connection); - - if (priv->last_device_ip4_config) { - nm_device_replace_vpn4_config(device, priv->last_device_ip4_config, NULL); - g_clear_object(&priv->last_device_ip4_config); - } - - if (priv->last_device_ip6_config) { - nm_device_replace_vpn6_config(device, priv->last_device_ip6_config, NULL); - g_clear_object(&priv->last_device_ip6_config); - } -} - static void vpn_cleanup(NMVpnConnection *self, NMDevice *parent_dev) { - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - - if (priv->ip_ifindex) { - NMPlatform *platform = nm_netns_get_platform(priv->netns); - - nm_platform_link_change_flags(platform, priv->ip_ifindex, IFF_UP, FALSE); - nm_platform_ip_route_flush(platform, AF_UNSPEC, priv->ip_ifindex); - nm_platform_ip_address_flush(platform, AF_UNSPEC, priv->ip_ifindex); - } - - remove_parent_device_config(self, parent_dev); + const char *iface; /* Remove zone from firewall */ - if (priv->ip_iface) { - nm_firewalld_manager_remove_from_zone(nm_firewalld_manager_get(), - priv->ip_iface, - NULL, - NULL, - NULL); + iface = nm_vpn_connection_get_ip_iface(self, FALSE); + if (iface) { + nm_firewalld_manager_remove_from_zone(nm_firewalld_manager_get(), iface, NULL, NULL, NULL); } + /* Cancel pending firewall call */ fw_call_cleanup(self); - g_free(priv->banner); - priv->banner = NULL; - - g_free(priv->ip_iface); - priv->ip_iface = NULL; - priv->ip_ifindex = 0; - - g_free(priv->bus_name); - priv->bus_name = NULL; + _l3cfg_l3cd_clear_all(self); } static void @@ -445,27 +964,27 @@ _set_vpn_state(NMVpnConnection * self, NMActiveConnectionStateReason reason, gboolean quitting) { - NMVpnConnectionPrivate *priv; + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); VpnState old_vpn_state; - NMVpnConnectionState new_external_state, old_external_state; + NMVpnConnectionState new_external_state; + NMVpnConnectionState old_external_state; NMDevice * parent_dev = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self)); NMConnection *applied; - g_return_if_fail(NM_IS_VPN_CONNECTION(self)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - if (vpn_state == priv->vpn_state) return; old_vpn_state = priv->vpn_state; priv->vpn_state = vpn_state; + _LOGD("set state: %s (was %s)", + vpn_state_to_string_a(priv->vpn_state), + vpn_state_to_string_a(old_vpn_state)); + /* The device gets destroyed by active connection when it enters * the deactivated state, so we need to ref it for usage below. */ - if (parent_dev) - g_object_ref(parent_dev); + nm_g_object_ref(parent_dev); /* Update active connection base class state */ nm_active_connection_set_state(NM_ACTIVE_CONNECTION(self), @@ -495,9 +1014,9 @@ _set_vpn_state(NMVpnConnection * self, g_signal_emit(self, signals[INTERNAL_STATE_CHANGED], 0, - new_external_state, - old_external_state, - reason); + (guint) new_external_state, + (guint) old_external_state, + (guint) reason); _notify(self, PROP_VPN_STATE); } @@ -513,10 +1032,8 @@ _set_vpn_state(NMVpnConnection * self, _get_settings_connection(self, FALSE), _get_applied_connection(self), parent_dev, - priv->ip_iface, - priv->proxy_config, - priv->ip4_config, - priv->ip6_config, + nm_vpn_connection_get_ip_iface(self, FALSE), + nm_vpn_connection_get_l3cd(self), dispatcher_pre_up_done, self, &priv->dispatcher_id)) { @@ -525,6 +1042,9 @@ _set_vpn_state(NMVpnConnection * self, } break; case STATE_ACTIVATED: + + nm_clear_g_source_inst(&priv->start_timeout_source); + applied = _get_applied_connection(self); /* Secrets no longer needed now that we're connected */ @@ -535,22 +1055,11 @@ _set_vpn_state(NMVpnConnection * self, _get_settings_connection(self, FALSE), applied, parent_dev, - priv->ip_iface, - priv->proxy_config, - priv->ip4_config, - priv->ip6_config, + nm_vpn_connection_get_ip_iface(self, FALSE), + nm_vpn_connection_get_l3cd(self), NULL, NULL, NULL); - - if (priv->proxy_config) { - nm_pacrunner_manager_remove_clear(&priv->pacrunner_conf_id); - priv->pacrunner_conf_id = nm_pacrunner_manager_add(nm_pacrunner_manager_get(), - priv->proxy_config, - priv->ip_iface, - priv->ip4_config, - priv->ip6_config); - } break; case STATE_DEACTIVATING: applied = _get_applied_connection(self); @@ -559,19 +1068,15 @@ _set_vpn_state(NMVpnConnection * self, _get_settings_connection(self, FALSE), applied, parent_dev, - priv->ip_iface, - priv->proxy_config, - priv->ip4_config, - priv->ip6_config); + nm_vpn_connection_get_ip_iface(self, FALSE), + nm_vpn_connection_get_l3cd(self)); } else { if (!nm_dispatcher_call_vpn(NM_DISPATCHER_ACTION_VPN_PRE_DOWN, _get_settings_connection(self, FALSE), applied, parent_dev, - priv->ip_iface, - priv->proxy_config, - priv->ip4_config, - priv->ip6_config, + nm_vpn_connection_get_ip_iface(self, FALSE), + nm_vpn_connection_get_l3cd(self), dispatcher_pre_down_done, self, &priv->dispatcher_id)) { @@ -591,18 +1096,14 @@ _set_vpn_state(NMVpnConnection * self, _get_settings_connection(self, FALSE), _get_applied_connection(self), parent_dev, - priv->ip_iface, - NULL, - NULL, + nm_vpn_connection_get_ip_iface(self, FALSE), NULL); } else { nm_dispatcher_call_vpn(NM_DISPATCHER_ACTION_VPN_DOWN, _get_settings_connection(self, FALSE), _get_applied_connection(self), parent_dev, - priv->ip_iface, - NULL, - NULL, + nm_vpn_connection_get_ip_iface(self, FALSE), NULL, NULL, NULL, @@ -610,17 +1111,8 @@ _set_vpn_state(NMVpnConnection * self, } } - /* Tear down and clean up the connection */ - if (priv->proxy) { - g_dbus_proxy_call(priv->proxy, - "Disconnect", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) disconnect_cb, - g_object_ref(self)); - } + if (priv->dbus.bus_name) + _dbus_connection_call(self, "Disconnect", NULL, G_VARIANT_TYPE("()"), disconnect_cb); vpn_cleanup(self, parent_dev); /* fall-through */ @@ -678,202 +1170,151 @@ device_state_changed(NMActiveConnection *active, */ } -static void -add_ip4_vpn_gateway_route(NMIP4Config *config, - NMDevice * parent_device, - in_addr_t vpn_gw, - NMPlatform * platform) +static gboolean +_parent_device_l3cd_add_gateway_route(NML3ConfigData *l3cd, + int addr_family, + NMDevice * parent_device, + const NMIPAddr *vpn_gw, + NMPlatform * platform) { - guint32 parent_gw = 0; - gboolean has_parent_gw = FALSE; - NMPlatformIP4Route route; - int ifindex; - guint32 route_metric; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMIPAddr parent_gw = NM_IP_ADDR_INIT; + gboolean has_parent_gw = FALSE; nm_auto_nmpobj const NMPObject *route_resolved = NULL; + int ifindex; + NMPlatformIPXRoute route; + int r; - g_return_if_fail(NM_IS_IP4_CONFIG(config)); - g_return_if_fail(NM_IS_DEVICE(parent_device)); - g_return_if_fail(vpn_gw != 0); + nm_assert(NM_IS_L3_CONFIG_DATA(l3cd)); + g_return_val_if_fail(vpn_gw, FALSE); - ifindex = nm_ip4_config_get_ifindex(config); + if (nm_ip_addr_is_null(addr_family, vpn_gw)) + return FALSE; + + ifindex = nm_l3_config_data_get_ifindex(l3cd); nm_assert(ifindex > 0); - nm_assert(ifindex == nm_device_get_ip_ifindex(parent_device)); + + if (parent_device && ifindex != nm_device_get_ip_ifindex(parent_device)) + parent_device = 0; /* Ask kernel how to reach @vpn_gw. We can only inject the route in * @parent_device, so whatever we resolve, it can only be on @ifindex. */ - if (nm_platform_ip_route_get(platform, - AF_INET, - &vpn_gw, + r = nm_platform_ip_route_get(platform, + addr_family, + vpn_gw, ifindex, - (NMPObject **) &route_resolved) - >= 0) { - const NMPlatformIP4Route *r = NMP_OBJECT_CAST_IP4_ROUTE(route_resolved); + (NMPObject **) &route_resolved); + if (r >= 0) { + const NMPlatformIPXRoute *rx = NMP_OBJECT_CAST_IPX_ROUTE(route_resolved); + const NMPObject * obj; - if (r->ifindex == ifindex) { - const NMPObject *obj; + if (rx->rx.ifindex == ifindex && nm_platform_route_table_is_main(rx->rx.table_coerced)) { + gconstpointer gw = nm_platform_ip_route_get_gateway(addr_family, &rx->rx); /* `ip route get` always resolves the route, even if the destination is unreachable. * In which case, it pretends the destination is directly reachable. * * So, only accept direct routes if @vpn_gw is a private network * or if the parent device also has a direct default route */ - if (nm_platform_route_table_is_main(r->table_coerced)) { - if (r->gateway) { - parent_gw = r->gateway; - has_parent_gw = TRUE; - } else if (nm_utils_ip_is_site_local(AF_INET, &vpn_gw)) { - has_parent_gw = TRUE; - } else if ((obj = nm_device_get_best_default_route(parent_device, AF_INET)) - && !NMP_OBJECT_CAST_IP4_ROUTE(obj)->gateway) { - has_parent_gw = TRUE; - } - } + if (!nm_ip_addr_is_null(addr_family, gw)) { + nm_ip_addr_set(addr_family, &parent_gw, gw); + has_parent_gw = TRUE; + } else if (nm_utils_ip_is_site_local(addr_family, vpn_gw)) + has_parent_gw = TRUE; + else if ((obj = nm_device_get_best_default_route(parent_device, addr_family)) + && nm_ip_addr_is_null( + addr_family, + nm_platform_ip_route_get_gateway(addr_family, + NMP_OBJECT_CAST_IP_ROUTE(obj)))) + has_parent_gw = TRUE; } } if (!has_parent_gw) - return; + return FALSE; - route_metric = nm_device_get_route_metric(parent_device, AF_INET); + if (IS_IPv4) { + route.r4 = (NMPlatformIP4Route){ + .ifindex = ifindex, + .network = vpn_gw->addr4, + .plen = 32, + .gateway = parent_gw.addr4, + .rt_source = NM_IP_CONFIG_SOURCE_VPN, + .metric_any = TRUE, + }; + } else { + route.r6 = (NMPlatformIP6Route){ + .ifindex = ifindex, + .network = vpn_gw->addr6, + .plen = 128, + .gateway = parent_gw.addr6, + .rt_source = NM_IP_CONFIG_SOURCE_VPN, + .metric_any = TRUE, + }; + } + nm_l3_config_data_add_route(l3cd, addr_family, NULL, &route.rx); - memset(&route, 0, sizeof(route)); - route.ifindex = ifindex; - route.network = vpn_gw; - route.plen = 32; - route.gateway = parent_gw; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - route.metric = route_metric; - nm_ip4_config_add_route(config, &route, NULL); - - if (parent_gw) { + if (!nm_ip_addr_is_null(addr_family, &parent_gw)) { /* Ensure there's a route to the parent device's gateway through the * parent device, since if the VPN claims the default route and the VPN * routes include a subnet that matches the parent device's subnet, * the parent device's gateway would get routed through the VPN and fail. */ - memset(&route, 0, sizeof(route)); - route.network = parent_gw; - route.plen = 32; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - route.metric = route_metric; - nm_ip4_config_add_route(config, &route, NULL); - } -} - -static void -add_ip6_vpn_gateway_route(NMIP6Config * config, - NMDevice * parent_device, - const struct in6_addr *vpn_gw, - NMPlatform * platform) -{ - const struct in6_addr *parent_gw = NULL; - gboolean has_parent_gw = FALSE; - NMPlatformIP6Route route; - int ifindex; - guint32 route_metric; - nm_auto_nmpobj const NMPObject *route_resolved = NULL; - - g_return_if_fail(NM_IS_IP6_CONFIG(config)); - g_return_if_fail(NM_IS_DEVICE(parent_device)); - g_return_if_fail(vpn_gw != NULL); - - ifindex = nm_ip6_config_get_ifindex(config); - - nm_assert(ifindex > 0); - nm_assert(ifindex == nm_device_get_ip_ifindex(parent_device)); - - /* Ask kernel how to reach @vpn_gw. We can only inject the route in - * @parent_device, so whatever we resolve, it can only be on @ifindex. */ - if (nm_platform_ip_route_get(platform, - AF_INET6, - vpn_gw, - ifindex, - (NMPObject **) &route_resolved) - >= 0) { - const NMPlatformIP6Route *r = NMP_OBJECT_CAST_IP6_ROUTE(route_resolved); - - if (r->ifindex == ifindex) { - const NMPObject *obj; - - /* `ip route get` always resolves the route, even if the destination is unreachable. - * In which case, it pretends the destination is directly reachable. - * - * So, only accept direct routes if @vpn_gw is a private network - * or if the parent device also has a direct default route */ - if (nm_platform_route_table_is_main(r->table_coerced)) { - if (!IN6_IS_ADDR_UNSPECIFIED(&r->gateway)) { - parent_gw = &r->gateway; - has_parent_gw = TRUE; - } else if (nm_utils_ip_is_site_local(AF_INET6, &vpn_gw)) { - has_parent_gw = TRUE; - } else if ((obj = nm_device_get_best_default_route(parent_device, AF_INET6)) - && IN6_IS_ADDR_UNSPECIFIED(&NMP_OBJECT_CAST_IP6_ROUTE(obj)->gateway)) { - has_parent_gw = TRUE; - } - } + if (IS_IPv4) { + route.r4 = (NMPlatformIP4Route){ + .network = parent_gw.addr4, + .plen = 32, + .rt_source = NM_IP_CONFIG_SOURCE_VPN, + .metric_any = TRUE, + }; + } else { + route.r6 = (NMPlatformIP6Route){ + .network = parent_gw.addr6, + .plen = 128, + .rt_source = NM_IP_CONFIG_SOURCE_VPN, + .metric_any = TRUE, + }; } + nm_l3_config_data_add_route(l3cd, addr_family, NULL, &route.rx); } - if (!has_parent_gw) - return; - - route_metric = nm_device_get_route_metric(parent_device, AF_INET6); - - memset(&route, 0, sizeof(route)); - route.ifindex = ifindex; - route.network = *vpn_gw; - route.plen = 128; - if (parent_gw) - route.gateway = *parent_gw; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - route.metric = route_metric; - nm_ip6_config_add_route(config, &route, NULL); - - /* Ensure there's a route to the parent device's gateway through the - * parent device, since if the VPN claims the default route and the VPN - * routes include a subnet that matches the parent device's subnet, - * the parent device's gateway would get routed through the VPN and fail. - */ - if (parent_gw && !IN6_IS_ADDR_UNSPECIFIED(parent_gw)) { - memset(&route, 0, sizeof(route)); - route.network = *parent_gw; - route.plen = 128; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - route.metric = route_metric; - nm_ip6_config_add_route(config, &route, NULL); - } + return TRUE; } -NMVpnConnection * -nm_vpn_connection_new(NMSettingsConnection * settings_connection, - NMDevice * parent_device, - const char * specific_object, - NMActivationReason activation_reason, - NMActivationStateFlags initial_state_flags, - NMAuthSubject * subject) +static gboolean +_l3cfg_l3cd_gw_extern_update(NMVpnConnection *self) { - g_return_val_if_fail(!settings_connection || NM_IS_SETTINGS_CONNECTION(settings_connection), - NULL); - g_return_val_if_fail(NM_IS_DEVICE(parent_device), NULL); - g_return_val_if_fail(specific_object, NULL); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + int ifindex; + gboolean changed; + int IS_IPv4; - return g_object_new(NM_TYPE_VPN_CONNECTION, - NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, - settings_connection, - NM_ACTIVE_CONNECTION_INT_DEVICE, - parent_device, - NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, - specific_object, - NM_ACTIVE_CONNECTION_INT_SUBJECT, - subject, - NM_ACTIVE_CONNECTION_INT_ACTIVATION_REASON, - activation_reason, - NM_ACTIVE_CONNECTION_VPN, - TRUE, - NM_ACTIVE_CONNECTION_STATE_FLAGS, - (guint) initial_state_flags, - NULL); + ifindex = priv->ifindex_dev; + if (ifindex <= 0) + goto set; + + l3cd = _l3cfg_l3cd_new(self, ifindex); + + changed = FALSE; + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + if (_parent_device_l3cd_add_gateway_route( + l3cd, + IS_IPv4 ? AF_INET : AF_INET6, + nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self)), + &priv->ip_data_x[IS_IPv4].gw_external, + nm_netns_get_platform(priv->netns))) + changed = TRUE; + } + if (!changed) + nm_clear_pointer(&l3cd, nm_l3_config_data_unref); + +set: + if (!_l3cfg_l3cd_set(self, L3CD_TYPE_GW_EXTERN, l3cd)) + return FALSE; + + return TRUE; } const char * @@ -885,23 +1326,370 @@ nm_vpn_connection_get_service(NMVpnConnection *self) return nm_setting_vpn_get_service_type(s_vpn); } -static NM_UTILS_LOOKUP_STR_DEFINE( - _vpn_plugin_failure_to_string, - NMVpnPluginFailure, - NM_UTILS_LOOKUP_DEFAULT(NULL), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED, "login-failed"), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED, "connect-failed"), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG, "bad-ip-config"), ); - -#define vpn_plugin_failure_to_string_a(failure) \ - NM_UTILS_LOOKUP_STR_A(_vpn_plugin_failure_to_string, failure) - static void -plugin_failed(NMVpnConnection *self, guint reason) +_apply_config(NMVpnConnection *self) { NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - _LOGW("VPN plugin: failed: %s (%d)", vpn_plugin_failure_to_string_a(reason), reason); + _LOGT("apply-config"); + + if (priv->ifindex_if > 0) { + nm_platform_link_change_flags(nm_netns_get_platform(priv->netns), + priv->ifindex_if, + IFF_UP, + TRUE); + } + + if (priv->ifindex_dev > 0) { + nm_platform_link_change_flags(nm_netns_get_platform(priv->netns), + priv->ifindex_dev, + IFF_UP, + TRUE); + } + + if (priv->ifindex_if > 0 && priv->ifindex_if != priv->ifindex_dev) { + if (priv->mtu + && priv->mtu + != nm_platform_link_get_mtu(nm_netns_get_platform(priv->netns), + priv->ifindex_if)) + nm_platform_link_set_mtu(nm_netns_get_platform(priv->netns), + priv->ifindex_if, + priv->mtu); + } + + priv->wait_for_pre_up_state = TRUE; + + _l3cfg_l3cd_update_all(self); +} + +static void +fw_change_zone_cb(NMFirewalldManager * firewalld_manager, + NMFirewalldManagerCallId *call_id, + GError * error, + gpointer user_data) +{ + NMVpnConnection * self = user_data; + NMVpnConnectionPrivate *priv; + + g_return_if_fail(NM_IS_VPN_CONNECTION(self)); + + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + g_return_if_fail(priv->fw_call == call_id); + + priv->fw_call = NULL; + + if (nm_utils_error_is_cancelled(error)) + return; + + _apply_config(self); +} + +static void +_check_complete(NMVpnConnection *self, gboolean success) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + NMConnection * connection; + NMSettingConnection * s_con; + const char * zone; + const char * iface; + + if (priv->vpn_state < STATE_IP_CONFIG_GET || priv->vpn_state > STATE_ACTIVATED) + return; + + if (success) { + if (!priv->generic_config_received + || (priv->ip_data_4.enabled && !priv->l3cds[L3CD_TYPE_IP_4]) + || (priv->ip_data_6.enabled && !priv->l3cds[L3CD_TYPE_IP_6])) { + /* Need to wait more config. */ + return; + } + } + + nm_clear_g_source_inst(&priv->connect_timeout_source); + + if (!success) { + _LOGW("did not receive valid IP config information"); + _set_vpn_state(self, + STATE_FAILED, + NM_ACTIVE_CONNECTION_STATE_REASON_IP_CONFIG_INVALID, + FALSE); + return; + } + + connection = _get_applied_connection(self); + + l3cd = nm_l3_config_data_new_from_connection(nm_netns_get_multi_idx(priv->netns), + nm_vpn_connection_get_ip_ifindex(self, TRUE), + connection); + _l3cfg_l3cd_set(self, L3CD_TYPE_STATIC, l3cd); + + _l3cfg_l3cd_gw_extern_update(self); + + iface = nm_vpn_connection_get_ip_iface(self, FALSE); + + /* Add the tunnel interface to the specified firewall zone */ + if (iface) { + s_con = nm_connection_get_setting_connection(connection); + zone = nm_setting_connection_get_zone(s_con); + + fw_call_cleanup(self); + priv->fw_call = nm_firewalld_manager_add_or_change_zone(nm_firewalld_manager_get(), + iface, + zone, + FALSE, + fw_change_zone_cb, + self); + return; + } + + _apply_config(self); +} + +static gboolean +_vardict_to_addr(int addr_family, GVariant *dict, const char *key, gpointer dst) +{ + guint32 u32; + + if (!NM_IS_IPv4(addr_family)) { + gs_unref_variant GVariant *v = NULL; + + if (g_variant_lookup(dict, key, "@ay", &v)) { + if (nm_ip_addr_set_from_variant(AF_INET6, dst, v, NULL)) + return TRUE; + } + nm_ip_addr_set(AF_INET6, dst, &nm_ip_addr_zero.addr6); + return FALSE; + } + + /* The way we encode IPv4 addresses is not endianness safe. It works well enough + * on the same host and as we know that the VPN plugin sends the address in the + * same endianness that we expect. + * + * But we read a u32 (natively), and that happens to be already in the right + * endianness to be used directly as IPv4 address. */ + if (g_variant_lookup(dict, key, "u", &u32)) { + unaligned_write_ne32(dst, u32); + return TRUE; + } + unaligned_write_ne32(dst, 0); + return FALSE; +} + +guint32 +nm_vpn_connection_get_ip_route_metric(NMVpnConnection *self, int addr_family) +{ + gint64 route_metric = -1; + NMConnection *applied; + + applied = _get_applied_connection(self); + if (!applied) + g_return_val_if_reached(NM_VPN_ROUTE_METRIC_DEFAULT); + + route_metric = nm_setting_ip_config_get_route_metric( + nm_connection_get_setting_ip_config(applied, addr_family)); + return (route_metric >= 0) ? route_metric : NM_VPN_ROUTE_METRIC_DEFAULT; +} + +static guint32 +get_route_table(NMVpnConnection *self, int addr_family, gboolean fallback_main) +{ + NMConnection * connection; + NMSettingIPConfig *s_ip; + guint32 route_table = 0; + + nm_assert(NM_IN_SET(addr_family, AF_INET, AF_INET6)); + + connection = _get_applied_connection(self); + if (connection) { + s_ip = nm_connection_get_setting_ip_config(connection, addr_family); + if (s_ip) + route_table = nm_setting_ip_config_get_route_table(s_ip); + } + + return route_table ?: (fallback_main ? RT_TABLE_MAIN : 0); +} + +static gboolean +connect_timeout_cb(gpointer user_data) +{ + NMVpnConnection * self = NM_VPN_CONNECTION(user_data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + nm_clear_g_source_inst(&priv->connect_timeout_source); + + /* Cancel activation if it's taken too long */ + if (priv->vpn_state == STATE_CONNECT || priv->vpn_state == STATE_IP_CONFIG_GET) { + _LOGW("connect timeout exceeded"); + _set_vpn_state(self, + STATE_FAILED, + NM_ACTIVE_CONNECTION_STATE_REASON_CONNECT_TIMEOUT, + FALSE); + } + + return G_SOURCE_CONTINUE; +} + +static void +connect_success(NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + priv->connect_timeout_source = + nm_g_timeout_add_seconds_source(_get_vpn_timeout(self), connect_timeout_cb, self); + + nm_clear_pointer(&priv->connect_hash, g_variant_unref); +} + +static void +connect_cb(GObject *source, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection *self; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + + res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); + if (nm_utils_error_is_cancelled(error)) + return; + + self = NM_VPN_CONNECTION(user_data); + + if (error) { + g_dbus_error_strip_remote_error(error); + _LOGW("failed to connect: '%s'", error->message); + _set_vpn_state(self, + STATE_FAILED, + NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_FAILED, + FALSE); + } else + connect_success(self); +} + +static void +connect_interactive_cb(GObject *source, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection * self; + NMVpnConnectionPrivate *priv; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + + res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); + if (nm_utils_error_is_cancelled(error)) + return; + + self = NM_VPN_CONNECTION(user_data); + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (g_error_matches(error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED) + && priv->dbus.bus_name) { + _LOGD("connect: falling back to non-interactive connect"); + _dbus_connection_call(self, + "Connect", + g_variant_new("(@a{sa{sv}})", priv->connect_hash), + G_VARIANT_TYPE("()"), + connect_cb); + return; + } + + if (error) { + _LOGW("connect: failed to connect interactively: '%s'", error->message); + _set_vpn_state(self, + STATE_FAILED, + NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_FAILED, + FALSE); + return; + } + + _LOGD("connect: success from ConnectInteractive"); + connect_success(self); +} + +/* Add a username to a hashed connection */ +static GVariant * +_hash_with_username(NMConnection *connection, const char *username) +{ + gs_unref_object NMConnection *dup = NULL; + NMSettingVpn * s_vpn; + + /* Shortcut if we weren't given a username or if there already was one in + * the VPN setting; don't bother duplicating the connection and everything. + */ + s_vpn = nm_connection_get_setting_vpn(connection); + g_return_val_if_fail(s_vpn, NULL); + + if (!username || nm_setting_vpn_get_user_name(s_vpn)) + return nm_connection_to_dbus(connection, NM_CONNECTION_SERIALIZE_ALL); + + dup = nm_simple_connection_new_clone(connection); + nm_assert(dup); + + s_vpn = nm_connection_get_setting_vpn(dup); + g_return_val_if_fail(s_vpn, NULL); + + g_object_set(s_vpn, NM_SETTING_VPN_USER_NAME, username, NULL); + + return nm_connection_to_dbus(dup, NM_CONNECTION_SERIALIZE_ALL); +} + +static void +really_activate(NMVpnConnection *self, const char *username) +{ + NMVpnConnectionPrivate *priv; + GVariantBuilder details; + + g_return_if_fail(NM_IS_VPN_CONNECTION(self)); + + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + g_return_if_fail(priv->vpn_state == STATE_NEED_AUTH); + + nm_clear_pointer(&priv->connect_hash, g_variant_unref); + priv->connect_hash = _hash_with_username(_get_applied_connection(self), username); + g_variant_ref_sink(priv->connect_hash); + + if (!priv->dbus.bus_name) { + _set_vpn_state(self, + STATE_FAILED, + NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_STOPPED, + FALSE); + return; + } + + /* If at least one agent doesn't support VPN hints, then we can't use + * ConnectInteractive(), because that agent won't be able to pass hints + * from the VPN plugin's interactive secrets requests to the VPN authentication + * dialog and we won't get the secrets we need. In this case fall back to + * the old Connect() call. + */ + if (nm_agent_manager_all_agents_have_capability( + nm_agent_manager_get(), + nm_active_connection_get_subject(NM_ACTIVE_CONNECTION(self)), + NM_SECRET_AGENT_CAPABILITY_VPN_HINTS)) { + _LOGD("connect: allowing interactive secrets as all agents have that capability"); + g_variant_builder_init(&details, G_VARIANT_TYPE_VARDICT); + _dbus_connection_call(self, + "ConnectInteractive", + g_variant_new("(@a{sa{sv}}a{sv})", priv->connect_hash, &details), + G_VARIANT_TYPE("()"), + connect_interactive_cb); + } else { + _LOGD( + "connect: calling old Connect function as not all agents support interactive secrets"); + _dbus_connection_call(self, + "Connect", + g_variant_new("(@a{sa{sv}})", priv->connect_hash), + G_VARIANT_TYPE("()"), + connect_cb); + } + + _set_vpn_state(self, STATE_CONNECT, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); +} + +static void +_dbus_signal_failure_cb(NMVpnConnection *self, guint32 reason) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + _LOGW("dbus: failure: %s (%d)", vpn_plugin_failure_to_string_a(reason), reason); switch (reason) { case NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED: @@ -916,45 +1704,13 @@ plugin_failed(NMVpnConnection *self, guint reason) } } -static NM_UTILS_LOOKUP_STR_DEFINE( - _vpn_service_state_to_string, - NMVpnServiceState, - NM_UTILS_LOOKUP_DEFAULT(NULL), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_UNKNOWN, "unknown"), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_INIT, "init"), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_SHUTDOWN, "shutdown"), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_STARTING, "starting"), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_STARTED, "started"), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_STOPPING, "stopping"), - NM_UTILS_LOOKUP_STR_ITEM(NM_VPN_SERVICE_STATE_STOPPED, "stopped"), ); - -#define vpn_service_state_to_string_a(state) \ - NM_UTILS_LOOKUP_STR_A(_vpn_service_state_to_string, state) - -static NM_UTILS_LOOKUP_STR_DEFINE(_vpn_state_to_string, - VpnState, - NM_UTILS_LOOKUP_DEFAULT(NULL), - NM_UTILS_LOOKUP_STR_ITEM(STATE_UNKNOWN, "unknown"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_WAITING, "waiting"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_PREPARE, "prepare"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_NEED_AUTH, "need-auth"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_CONNECT, "connect"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_IP_CONFIG_GET, "ip-config-get"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_PRE_UP, "pre-up"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_ACTIVATED, "activated"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_DEACTIVATING, "deactivating"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_DISCONNECTED, "disconnected"), - NM_UTILS_LOOKUP_STR_ITEM(STATE_FAILED, "failed"), ); - -#define vpn_state_to_string_a(state) NM_UTILS_LOOKUP_STR_A(_vpn_state_to_string, state) - static void -plugin_state_changed(NMVpnConnection *self, NMVpnServiceState new_service_state) +_dbus_signal_state_changed_cb(NMVpnConnection *self, guint32 new_service_state) { NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); NMVpnServiceState old_service_state = priv->service_state; - _LOGI("VPN plugin: state changed: %s (%d)", + _LOGD("dbus: state changed: %s (%d)", vpn_service_state_to_string_a(new_service_state), new_service_state); priv->service_state = new_service_state; @@ -985,1233 +1741,713 @@ plugin_state_changed(NMVpnConnection *self, NMVpnServiceState new_service_state) } } -static void -print_vpn_config(NMVpnConnection *self) -{ - NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - const NMPlatformIP4Address *address4; - const NMPlatformIP6Address *address6; - char * dns_domain = NULL; - guint32 num, i; - char b1[NM_UTILS_INET_ADDRSTRLEN]; - char b2[NM_UTILS_INET_ADDRSTRLEN]; - NMDedupMultiIter ipconf_iter; - - if (priv->ip4_external_gw) { - _LOGI("Data: VPN Gateway: %s", _nm_utils_inet4_ntop(priv->ip4_external_gw, b1)); - } else if (priv->ip6_external_gw) { - _LOGI("Data: VPN Gateway: %s", _nm_utils_inet6_ntop(priv->ip6_external_gw, b1)); - } - - _LOGI("Data: Tunnel Device: %s%s%s", NM_PRINT_FMT_QUOTE_STRING(priv->ip_iface)); - - if (priv->ip4_config) { - const NMPlatformIP4Route *route; - - _LOGI("Data: IPv4 configuration:"); - - address4 = nm_ip4_config_get_first_address(priv->ip4_config); - nm_assert(address4); - - if (priv->ip4_internal_gw) - _LOGI("Data: Internal Gateway: %s", _nm_utils_inet4_ntop(priv->ip4_internal_gw, b1)); - _LOGI("Data: Internal Address: %s", - address4 ? _nm_utils_inet4_ntop(address4->address, b1) : "??"); - _LOGI("Data: Internal Prefix: %d", address4 ? (int) address4->plen : -1); - _LOGI("Data: Internal Point-to-Point Address: %s", - _nm_utils_inet4_ntop(address4->peer_address, b1)); - - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, priv->ip4_config, &route) { - _LOGI("Data: Static Route: %s/%d Next Hop: %s", - _nm_utils_inet4_ntop(route->network, b1), - route->plen, - _nm_utils_inet4_ntop(route->gateway, b2)); - } - - num = nm_ip4_config_get_num_nameservers(priv->ip4_config); - for (i = 0; i < num; i++) { - _LOGI("Data: Internal DNS: %s", - _nm_utils_inet4_ntop(nm_ip4_config_get_nameserver(priv->ip4_config, i), b1)); - } - - if (nm_ip4_config_get_num_domains(priv->ip4_config) > 0) - dns_domain = (char *) nm_ip4_config_get_domain(priv->ip4_config, 0); - - _LOGI("Data: DNS Domain: '%s'", dns_domain ?: "(none)"); - } else - _LOGI("Data: No IPv4 configuration"); - - if (priv->ip6_config) { - const NMPlatformIP6Route *route; - - _LOGI("Data: IPv6 configuration:"); - - address6 = nm_ip6_config_get_first_address(priv->ip6_config); - nm_assert(address6); - - if (priv->ip6_internal_gw) - _LOGI("Data: Internal Gateway: %s", _nm_utils_inet6_ntop(priv->ip6_internal_gw, b1)); - _LOGI("Data: Internal Address: %s", _nm_utils_inet6_ntop(&address6->address, b1)); - _LOGI("Data: Internal Prefix: %d", address6->plen); - _LOGI("Data: Internal Point-to-Point Address: %s", - _nm_utils_inet6_ntop(&address6->peer_address, b1)); - - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, priv->ip6_config, &route) { - _LOGI("Data: Static Route: %s/%d Next Hop: %s", - _nm_utils_inet6_ntop(&route->network, b1), - route->plen, - _nm_utils_inet6_ntop(&route->gateway, b2)); - } - - num = nm_ip6_config_get_num_nameservers(priv->ip6_config); - for (i = 0; i < num; i++) { - _LOGI("Data: Internal DNS: %s", - _nm_utils_inet6_ntop(nm_ip6_config_get_nameserver(priv->ip6_config, i), b1)); - } - - if (nm_ip6_config_get_num_domains(priv->ip6_config) > 0) - dns_domain = (char *) nm_ip6_config_get_domain(priv->ip6_config, 0); - - _LOGI("Data: DNS Domain: '%s'", dns_domain ?: "(none)"); - } else - _LOGI("Data: No IPv6 configuration"); - - if (priv->banner && strlen(priv->banner)) { - _LOGI("Data: Login Banner:"); - _LOGI("Data: -----------------------------------------"); - _LOGI("Data: %s", priv->banner); - _LOGI("Data: -----------------------------------------"); - } -} - -static void -apply_parent_device_config(NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - NMDevice * parent_dev = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self)); - int ifindex; - NMIP4Config *vpn4_parent_config = NULL; - NMIP6Config *vpn6_parent_config = NULL; - - ifindex = nm_device_get_ip_ifindex(parent_dev); - if (ifindex > 0) { - /* If the VPN didn't return a network interface, it is a route-based - * VPN (like kernel IPSec) and all IP addressing and routing should - * be done on the parent interface instead. - */ - if (priv->ip4_config) { - vpn4_parent_config = nm_ip4_config_new(nm_netns_get_multi_idx(priv->netns), ifindex); - if (priv->ip_ifindex <= 0) - nm_ip4_config_merge(vpn4_parent_config, - priv->ip4_config, - NM_IP_CONFIG_MERGE_NO_DNS, - 0); - } - if (priv->ip6_config) { - vpn6_parent_config = nm_ip6_config_new(nm_netns_get_multi_idx(priv->netns), ifindex); - if (priv->ip_ifindex <= 0) - nm_ip6_config_merge(vpn6_parent_config, - priv->ip6_config, - NM_IP_CONFIG_MERGE_NO_DNS, - 0); - } - } - - /* Add any explicit route to the VPN gateway through the parent device */ - if (vpn4_parent_config && priv->ip4_external_gw) { - add_ip4_vpn_gateway_route(vpn4_parent_config, - parent_dev, - priv->ip4_external_gw, - nm_netns_get_platform(priv->netns)); - } - if (vpn6_parent_config && priv->ip6_external_gw) { - add_ip6_vpn_gateway_route(vpn6_parent_config, - parent_dev, - priv->ip6_external_gw, - nm_netns_get_platform(priv->netns)); - } - - nm_device_replace_vpn4_config(parent_dev, priv->last_device_ip4_config, vpn4_parent_config); - g_clear_object(&priv->last_device_ip4_config); - priv->last_device_ip4_config = vpn4_parent_config; - - nm_device_replace_vpn6_config(parent_dev, priv->last_device_ip6_config, vpn6_parent_config); - g_clear_object(&priv->last_device_ip6_config); - priv->last_device_ip6_config = vpn6_parent_config; -} - static gboolean -nm_vpn_connection_apply_config(NMVpnConnection *self) +_config_process_generic(NMVpnConnection *self, GVariant *dict) { - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + nm_auto_g_object_thaw_notify GObject *self_thaw = NULL; + NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + int IS_IPv4; + int ip_ifindex = 0; + const char * v_str; + guint32 v_u32; + gboolean v_b; - apply_parent_device_config(self); + if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_TUNDEV, "&s", &v_str)) { + const char *iface = NULL; - if (priv->ip_ifindex > 0) { - nm_platform_link_change_flags(nm_netns_get_platform(priv->netns), - priv->ip_ifindex, - IFF_UP, - TRUE); + /* Backwards compat with NM-openswan/libreswan */ + if (!NM_IN_STRSET(v_str, "", "_none_")) + iface = v_str; - if (priv->ip4_config) { - nm_assert(priv->ip_ifindex == nm_ip4_config_get_ifindex(priv->ip4_config)); - if (!nm_ip4_config_commit(priv->ip4_config, - nm_netns_get_platform(priv->netns), - get_route_table(self, AF_INET, FALSE) - ? NM_IP_ROUTE_TABLE_SYNC_MODE_FULL - : NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN)) + if (iface) { + NMPlatform *platform = nm_netns_get_platform(priv->netns); + + ip_ifindex = nm_platform_link_get_ifindex(platform, iface); + if (ip_ifindex <= 0) { + nm_platform_process_events(platform); + ip_ifindex = nm_platform_link_get_ifindex(platform, iface); + } + if (ip_ifindex <= 0) { + _LOGW("config: failed to look up VPN interface index for \"%s\"", iface); return FALSE; - nm_platform_ip4_dev_route_blacklist_set(nm_netns_get_platform(priv->netns), - priv->ip_ifindex, - priv->ip4_dev_route_blacklist); - } - - if (priv->ip6_config) { - nm_assert(priv->ip_ifindex == nm_ip6_config_get_ifindex(priv->ip6_config)); - if (!nm_ip6_config_commit(priv->ip6_config, - nm_netns_get_platform(priv->netns), - get_route_table(self, AF_INET6, FALSE) - ? NM_IP_ROUTE_TABLE_SYNC_MODE_FULL - : NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN, - NULL)) - return FALSE; - } - - if (priv->mtu - && priv->mtu - != nm_platform_link_get_mtu(nm_netns_get_platform(priv->netns), - priv->ip_ifindex)) - nm_platform_link_set_mtu(nm_netns_get_platform(priv->netns), - priv->ip_ifindex, - priv->mtu); - } - - _LOGI("VPN connection: (IP Config Get) complete"); - if (priv->vpn_state < STATE_PRE_UP) - _set_vpn_state(self, STATE_PRE_UP, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); - return TRUE; -} - -static void -_cleanup_failed_config(NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - - nm_dbus_object_clear_and_unexport(&priv->ip4_config); - nm_dbus_object_clear_and_unexport(&priv->ip6_config); - - _LOGW("VPN connection: did not receive valid IP config information"); - _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_IP_CONFIG_INVALID, FALSE); -} - -static void -fw_change_zone_cb(NMFirewalldManager * firewalld_manager, - NMFirewalldManagerCallId *call_id, - GError * error, - gpointer user_data) -{ - NMVpnConnection * self = user_data; - NMVpnConnectionPrivate *priv; - - g_return_if_fail(NM_IS_VPN_CONNECTION(self)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - g_return_if_fail(priv->fw_call == call_id); - - priv->fw_call = NULL; - - if (nm_utils_error_is_cancelled(error)) - return; - - if (error) { - // FIXME: fail the activation? - } - - if (!nm_vpn_connection_apply_config(self)) - _cleanup_failed_config(self); -} - -static void -nm_vpn_connection_config_maybe_complete(NMVpnConnection *self, gboolean success) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - NMConnection * base_con; - NMSettingConnection * s_con; - const char * zone; - - if (priv->vpn_state < STATE_IP_CONFIG_GET || priv->vpn_state > STATE_ACTIVATED) - return; - - if (success) { - if ((priv->has_ip4 && !priv->ip4_config) || (priv->has_ip6 && !priv->ip6_config)) { - /* Need to wait for other config */ - return; + } } } - nm_clear_g_source(&priv->connect_timeout); + self_thaw = nm_g_object_freeze_notify(self); - if (success) { - print_vpn_config(self); + _set_ip_ifindex(self, ip_ifindex, TRUE); + _set_ip_ifindex(self, _get_ifindex_for_device(self), FALSE); - /* Add the tunnel interface to the specified firewall zone */ - if (priv->ip_iface) { - base_con = _get_applied_connection(self); - s_con = nm_connection_get_setting_connection(base_con); - zone = nm_setting_connection_get_zone(s_con); - - _LOGD("setting firewall zone %s%s%s for '%s'", - NM_PRINT_FMT_QUOTED(zone, "'", zone, "'", "(default)"), - priv->ip_iface); - fw_call_cleanup(self); - priv->fw_call = nm_firewalld_manager_add_or_change_zone(nm_firewalld_manager_get(), - priv->ip_iface, - zone, - FALSE, - fw_change_zone_cb, - self); - return; - } else if (nm_vpn_connection_apply_config(self)) - return; + ip_ifindex = nm_vpn_connection_get_ip_ifindex(self, TRUE); + if (ip_ifindex <= 0) { + _LOGW("config: no ip-ifindex for the VPN"); + return FALSE; } - _cleanup_failed_config(self); -} + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + NML3Cfg * l3cfg = priv->l3cfg_if ?: priv->l3cfg_dev; + gs_unref_object NMIPConfig *ipconfig_old = NULL; -static gboolean -ip6_addr_from_variant(GVariant *v, struct in6_addr *addr) -{ - const guint8 *bytes; - gsize len; - - g_return_val_if_fail(v, FALSE); - g_return_val_if_fail(addr, FALSE); - - if (g_variant_is_of_type(v, G_VARIANT_TYPE("ay"))) { - bytes = g_variant_get_fixed_array(v, &len, sizeof(guint8)); - if (len == sizeof(struct in6_addr) && !IN6_IS_ADDR_UNSPECIFIED(bytes)) { - memcpy(addr, bytes, len); - return TRUE; + ipconfig_old = g_steal_pointer(&priv->ip_data_x[IS_IPv4].ip_config); + if (l3cfg) { + priv->ip_data_x[IS_IPv4].ip_config = + nm_l3cfg_ipconfig_acquire(l3cfg, IS_IPv4 ? AF_INET : AF_INET6); } + g_object_notify(G_OBJECT(self), + IS_IPv4 ? NM_ACTIVE_CONNECTION_IP4_CONFIG + : NM_ACTIVE_CONNECTION_IP6_CONFIG); } - return FALSE; -} -static struct in6_addr * -ip6_addr_dup_from_variant(GVariant *v) -{ - struct in6_addr *addr; - - addr = g_malloc0(sizeof(*addr)); - if (ip6_addr_from_variant(v, addr)) - return addr; - g_free(addr); - return NULL; -} - -static gboolean -process_generic_config(NMVpnConnection *self, GVariant *dict) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - const char * str; - GVariant * v; - guint32 u32; - gboolean b; - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_CAN_PERSIST, "b", &b) && b) { + if (g_variant_lookup(dict, NM_VPN_PLUGIN_CAN_PERSIST, "b", &v_b) && v_b) { /* Defaults to FALSE, so only let service indicate TRUE */ priv->service_can_persist = TRUE; } - nm_clear_g_free(&priv->ip_iface); - priv->ip_ifindex = 0; - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_TUNDEV, "&s", &str)) { - /* Backwards compat with NM-openswan */ - if (g_strcmp0(str, "_none_") != 0) - priv->ip_iface = g_strdup(str); - } - - if (priv->ip_iface) { - /* Grab the interface index for address/routing operations */ - priv->ip_ifindex = - nm_platform_link_get_ifindex(nm_netns_get_platform(priv->netns), priv->ip_iface); - if (priv->ip_ifindex <= 0) { - nm_platform_process_events(nm_netns_get_platform(priv->netns)); - priv->ip_ifindex = - nm_platform_link_get_ifindex(nm_netns_get_platform(priv->netns), priv->ip_iface); - } - if (priv->ip_ifindex <= 0) { - _LOGE("failed to look up VPN interface index for \"%s\"", priv->ip_iface); - nm_clear_g_free(&priv->ip_iface); - priv->ip_ifindex = 0; - nm_vpn_connection_config_maybe_complete(self, FALSE); - return FALSE; - } - } - - nm_clear_g_free(&priv->banner); - if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_BANNER, "&s", &str)) { - priv->banner = g_strdup(str); + if (!g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_BANNER, "&s", &v_str)) + v_str = NULL; + if (nm_strdup_reset(&priv->banner, v_str)) _notify(self, PROP_BANNER); + + _vardict_to_addr(AF_INET, dict, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, &priv->ip_data_4.gw_external); + _vardict_to_addr(AF_INET6, + dict, + NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, + &priv->ip_data_6.gw_external); + + if (nm_ip_addr_is_null(AF_INET, &priv->ip_data_4.gw_external) + && nm_ip_addr_is_null(AF_INET6, &priv->ip_data_6.gw_external)) { + _LOGW("config: no VPN gateway address received"); + return FALSE; } - /* Proxy Config */ - g_clear_object(&priv->proxy_config); - priv->proxy_config = nm_proxy_config_new(); + l3cd = _l3cfg_l3cd_new(self, ip_ifindex); - if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_PROXY_PAC, "&s", &str)) { - nm_proxy_config_set_method(priv->proxy_config, NM_PROXY_CONFIG_METHOD_AUTO); - nm_proxy_config_set_pac_url(priv->proxy_config, str); + if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_PROXY_PAC, "&s", &v_str)) { + nm_l3_config_data_set_proxy_method(l3cd, NM_PROXY_CONFIG_METHOD_AUTO); + nm_l3_config_data_set_proxy_pac_url(l3cd, v_str); } else - nm_proxy_config_set_method(priv->proxy_config, NM_PROXY_CONFIG_METHOD_NONE); + nm_l3_config_data_set_proxy_method(l3cd, NM_PROXY_CONFIG_METHOD_NONE); - /* User overrides if any from the NMConnection's Proxy settings */ - nm_proxy_config_merge_setting(priv->proxy_config, - nm_connection_get_setting_proxy(_get_applied_connection(self))); + if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_MTU, "u", &v_u32)) + priv->mtu = v_u32; + else + priv->mtu = 0; - /* External world-visible address of the VPN server */ - priv->ip4_external_gw = 0; - nm_clear_g_free(&priv->ip6_external_gw); + priv->generic_config_received = TRUE; - if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, "u", &u32)) { - priv->ip4_external_gw = u32; - } else if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, "@ay", &v)) { - priv->ip6_external_gw = ip6_addr_dup_from_variant(v); - g_variant_unref(v); + nm_g_object_thaw_notify_clear(&self_thaw); - if (!priv->ip6_external_gw) { - _LOGE("Invalid IPv6 VPN gateway address received"); - nm_vpn_connection_config_maybe_complete(self, FALSE); - return FALSE; - } - } - - priv->mtu = 0; - if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_MTU, "u", &u32)) - priv->mtu = u32; + _l3cfg_l3cd_set(self, L3CD_TYPE_GENERIC, l3cd); return TRUE; } static void -nm_vpn_connection_config_get(NMVpnConnection *self, GVariant *dict) +_dbus_signal_config_cb(NMVpnConnection *self, GVariant *dict) { NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - gboolean b; + gboolean v_b; - g_return_if_fail(dict && g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT)); + g_return_if_fail(dict); - _LOGI("VPN connection: (IP Config Get) reply received."); + if (!g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT)) { + _LOGD("config: ignore invalid configuration type"); + return; + } + + if (priv->vpn_state < STATE_NEED_AUTH) { + /* Only list to this signals during and after connection */ + _LOGD("config: ignore configuration before need-auth state"); + return; + } + + if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_HAS_IP4, "b", &v_b)) + priv->ip_data_4.enabled = v_b; + else + priv->ip_data_4.enabled = FALSE; + + if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_HAS_IP6, "b", &v_b)) + priv->ip_data_6.enabled = v_b; + else + priv->ip_data_6.enabled = FALSE; + + _LOGD("config: reply received (IPv4:%s, IPv6:%s)", + priv->ip_data_4.enabled ? "on" : "off", + priv->ip_data_6.enabled ? "on" : "off"); if (priv->vpn_state == STATE_CONNECT) _set_vpn_state(self, STATE_IP_CONFIG_GET, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); - if (!process_generic_config(self, dict)) + if (!_config_process_generic(self, dict)) { + _check_complete(self, FALSE); return; - - /* Note whether to expect IPv4 and IPv6 configs */ - priv->has_ip4 = FALSE; - if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_HAS_IP4, "b", &b)) - priv->has_ip4 = b; - nm_dbus_object_clear_and_unexport(&priv->ip4_config); - - priv->has_ip6 = FALSE; - if (g_variant_lookup(dict, NM_VPN_PLUGIN_CONFIG_HAS_IP6, "b", &b)) - priv->has_ip6 = b; - nm_dbus_object_clear_and_unexport(&priv->ip6_config); - - nm_vpn_connection_config_maybe_complete(self, TRUE); -} - -guint32 -nm_vpn_connection_get_ip4_route_metric(NMVpnConnection *self) -{ - gint64 route_metric; - NMConnection *applied; - - applied = _get_applied_connection(self); - route_metric = - nm_setting_ip_config_get_route_metric(nm_connection_get_setting_ip4_config(applied)); - - return (route_metric >= 0) ? route_metric : NM_VPN_ROUTE_METRIC_DEFAULT; -} - -guint32 -nm_vpn_connection_get_ip6_route_metric(NMVpnConnection *self) -{ - gint64 route_metric; - NMConnection *applied; - - applied = _get_applied_connection(self); - route_metric = - nm_setting_ip_config_get_route_metric(nm_connection_get_setting_ip6_config(applied)); - - return (route_metric >= 0) ? route_metric : NM_VPN_ROUTE_METRIC_DEFAULT; -} - -static guint32 -get_route_table(NMVpnConnection *self, int addr_family, gboolean fallback_main) -{ - NMConnection * connection; - NMSettingIPConfig *s_ip; - guint32 route_table = 0; - - nm_assert(NM_IN_SET(addr_family, AF_INET, AF_INET6)); - - connection = _get_applied_connection(self); - if (connection) { - s_ip = nm_connection_get_setting_ip_config(connection, addr_family); - if (s_ip) - route_table = nm_setting_ip_config_get_route_table(s_ip); } - return route_table ?: (fallback_main ? RT_TABLE_MAIN : 0); -} - -static gboolean -_is_device_vrf(NMVpnConnection *self) -{ - NMDevice *parent; - NMDevice *master; - - parent = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self)); - if (!parent) - return FALSE; - - master = nm_device_get_master(parent); - return master && nm_device_get_link_type(master) == NM_LINK_TYPE_VRF; + _check_complete(self, TRUE); } static void -nm_vpn_connection_ip4_config_get(NMVpnConnection *self, GVariant *dict) +_dbus_signal_ip_config_cb(NMVpnConnection *self, int addr_family, GVariant *dict) { - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - NMPlatformIP4Address address; - guint32 u32, route_metric; - NMSettingIPConfig * s_ip; - NMSettingConnection * s_con; - guint32 route_table; - NMIP4Config * config; - GVariantIter * iter; - const char * str; - GVariant * v; - gboolean b; - int ip_ifindex; - guint32 mss = 0; - gboolean never_default = FALSE; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + GVariantIter * var_iter; + guint32 u32; + const char * v_str; + NMIPAddr v_addr; + GVariant * v; + gboolean v_b; + int ip_ifindex; + guint32 mss = 0; + gboolean never_default; + NMPlatformIPXAddress address; g_return_if_fail(dict && g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT)); - if (priv->vpn_state == STATE_CONNECT) - _set_vpn_state(self, STATE_IP_CONFIG_GET, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); - - if (priv->vpn_state > STATE_ACTIVATED) { - _LOGI("VPN connection: (IP4 Config Get) ignoring, the connection is no longer active"); + if (priv->vpn_state < STATE_NEED_AUTH) { + _LOGD("config%c: ignoring, the connection is not in need-auth state", + nm_utils_addr_family_to_char(addr_family)); return; } - if (priv->has_ip4) { - _LOGI("VPN connection: (IP4 Config Get) reply received"); + if (priv->vpn_state > STATE_ACTIVATED) { + _LOGD("config%c: ignoring, the connection is no longer active", + nm_utils_addr_family_to_char(addr_family)); + return; + } + + if (IS_IPv4) { + if (priv->generic_config_received) { + _LOGD("config4: reply received"); + + if (g_variant_n_children(dict) == 0) { + priv->ip_data_4.enabled = FALSE; + _check_complete(self, TRUE); + return; + } + } else { + _LOGD("config4: reply received (old style)"); + + /* In the old API, the generic and IPv4 configuration items + * were mixed together. + */ + if (!_config_process_generic(self, dict)) { + _check_complete(self, FALSE); + return; + } + + priv->ip_data_4.enabled = TRUE; + priv->ip_data_6.enabled = FALSE; + } + } else { + _LOGD("config6: reply received"); if (g_variant_n_children(dict) == 0) { - priv->has_ip4 = FALSE; - nm_vpn_connection_config_maybe_complete(self, TRUE); + priv->ip_data_6.enabled = FALSE; + _check_complete(self, TRUE); return; } - } else { - _LOGI("VPN connection: (IP4 Config Get) reply received from old-style plugin"); + } - /* In the old API, the generic and IPv4 configuration items - * were mixed together. - */ - if (!process_generic_config(self, dict)) - return; - - priv->has_ip4 = TRUE; - priv->has_ip6 = FALSE; + if (priv->vpn_state == STATE_CONNECT) { + _set_vpn_state(self, STATE_IP_CONFIG_GET, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); } ip_ifindex = nm_vpn_connection_get_ip_ifindex(self, TRUE); if (ip_ifindex <= 0) g_return_if_reached(); - config = nm_ip4_config_new(nm_netns_get_multi_idx(priv->netns), ip_ifindex); - nm_ip4_config_set_dns_priority(config, NM_DNS_PRIORITY_DEFAULT_VPN); + l3cd = _l3cfg_l3cd_new(self, ip_ifindex); - memset(&address, 0, sizeof(address)); - address.plen = 24; + nm_l3_config_data_set_dns_priority(l3cd, AF_INET, NM_DNS_PRIORITY_DEFAULT_VPN); - /* Internal address of the VPN subnet's gateway */ - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY, "u", &u32)) - priv->ip4_internal_gw = u32; - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, "u", &u32)) - address.address = u32; - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_PTP, "u", &u32)) - address.peer_address = u32; - else - address.peer_address = address.address; - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, "u", &u32)) - address.plen = u32; - - if (address.address && address.plen && address.plen <= 32) { - address.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_address(config, &address); + if (IS_IPv4) { + address.a4 = (NMPlatformIP4Address){ + .plen = 24, + }; } else { - _LOGW("invalid IP4 config received!"); - g_object_unref(config); - nm_vpn_connection_config_maybe_complete(self, FALSE); + address.a6 = (NMPlatformIP6Address){ + .plen = 128, + }; + } + + _vardict_to_addr(addr_family, + dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY + : NM_VPN_PLUGIN_IP6_CONFIG_INT_GATEWAY, + &priv->ip_data_x[IS_IPv4].gw_internal); + + _vardict_to_addr(addr_family, + dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS : NM_VPN_PLUGIN_IP6_CONFIG_ADDRESS, + address.ax.address_ptr); + + if (!_vardict_to_addr(addr_family, + dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_PTP : NM_VPN_PLUGIN_IP6_CONFIG_PTP, + nm_platform_ip_address_get_peer_address(addr_family, &address.ax))) { + if (IS_IPv4) + address.a4.peer_address = address.a4.address; + } + + if (g_variant_lookup(dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_PREFIX + : NM_VPN_PLUGIN_IP6_CONFIG_PREFIX, + "u", + &u32)) + address.ax.plen = u32; + + if (address.ax.plen > 0 && address.ax.plen <= (IS_IPv4 ? 32 : 128) + && !nm_ip_addr_is_null(addr_family, &address.ax.address_ptr)) { + address.ax.addr_source = NM_IP_CONFIG_SOURCE_VPN; + nm_l3_config_data_add_address(l3cd, addr_family, NULL, &address.ax); + } else { + _LOGW("invalid IP%c config received: no valid IP address/prefix", + nm_utils_addr_family_to_char(addr_family)); + _check_complete(self, FALSE); return; } - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_DNS, "au", &iter)) { - while (g_variant_iter_next(iter, "u", &u32)) - nm_ip4_config_add_nameserver(config, u32); - g_variant_iter_free(iter); + if (IS_IPv4) { + if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_DNS, "au", &var_iter)) { + while (g_variant_iter_next(var_iter, "u", &u32)) + nm_l3_config_data_add_nameserver(l3cd, addr_family, &u32); + g_variant_iter_free(var_iter); + } + } else { + if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_DNS, "aay", &var_iter)) { + while (g_variant_iter_next(var_iter, "@ay", &v)) { + if (nm_ip_addr_set_from_variant(AF_INET6, &v_addr, v, NULL)) + nm_l3_config_data_add_nameserver(l3cd, addr_family, &v_addr); + g_variant_unref(v); + } + g_variant_iter_free(var_iter); + } } - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_NBNS, "au", &iter)) { - while (g_variant_iter_next(iter, "u", &u32)) - nm_ip4_config_add_wins(config, u32); - g_variant_iter_free(iter); + if (IS_IPv4) { + if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_NBNS, "au", &var_iter)) { + while (g_variant_iter_next(var_iter, "u", &u32)) + nm_l3_config_data_add_wins(l3cd, u32); + g_variant_iter_free(var_iter); + } } - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_MSS, "u", &u32)) + if (g_variant_lookup(dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_MSS : NM_VPN_PLUGIN_IP6_CONFIG_MSS, + "u", + &u32)) mss = u32; - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_DOMAIN, "&s", &str)) - nm_ip4_config_add_domain(config, str); + if (g_variant_lookup(dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_DOMAIN + : NM_VPN_PLUGIN_IP6_CONFIG_DOMAIN, + "&s", + &v_str)) + nm_l3_config_data_add_domain(l3cd, addr_family, v_str); - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_DOMAINS, "as", &iter)) { - while (g_variant_iter_next(iter, "&s", &str)) - nm_ip4_config_add_domain(config, str); - g_variant_iter_free(iter); + if (g_variant_lookup(dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_DOMAINS + : NM_VPN_PLUGIN_IP6_CONFIG_DOMAINS, + "as", + &var_iter)) { + while (g_variant_iter_next(var_iter, "&s", &v_str)) + nm_l3_config_data_add_domain(l3cd, addr_family, v_str); + g_variant_iter_free(var_iter); } - route_table = get_route_table(self, AF_INET, TRUE); - route_metric = nm_vpn_connection_get_ip4_route_metric(self); - s_ip = nm_connection_get_setting_ip4_config(_get_applied_connection(self)); - s_con = nm_connection_get_setting_connection(_get_applied_connection(self)); + if (g_variant_lookup(dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_PRESERVE_ROUTES + : NM_VPN_PLUGIN_IP6_CONFIG_PRESERVE_ROUTES, + "b", + &v_b) + && v_b) { + if (priv->l3cds[L3CD_TYPE_IP_X(IS_IPv4)]) { + NMDedupMultiIter ipconf_iter; + const NMPObject *route; - if (nm_setting_ip_config_get_ignore_auto_routes(s_ip)) { - /* ignore VPN routes */ - } else if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_PRESERVE_ROUTES, "b", &b) && b) { - if (priv->ip4_config) { - NMDedupMultiIter ipconf_iter; - const NMPlatformIP4Route *route; - - nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, priv->ip4_config, &route) - nm_ip4_config_add_route(config, route, NULL); + nm_l3_config_data_iter_obj_for_each (&ipconf_iter, + priv->l3cds[L3CD_TYPE_IP_X(IS_IPv4)], + &route, + NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) + nm_l3_config_data_add_route(l3cd, addr_family, route, NULL); } - } else if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_ROUTES, "aau", &iter)) { - while (g_variant_iter_next(iter, "@au", &v)) { - NMPlatformIP4Route route = { - 0, - }; - guint32 plen; + } else if (IS_IPv4 ? g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_ROUTES, "aau", &var_iter) + : g_variant_lookup(dict, + NM_VPN_PLUGIN_IP6_CONFIG_ROUTES, + "a(ayuayu)", + &var_iter)) { + _nm_unused nm_auto_free_variant_iter GVariantIter *var_iter_ref_owner = var_iter; + NMPlatformIPXRoute route = {}; + guint32 plen; + GVariant * next_hop; + GVariant * dest; + guint32 prefix; + guint32 metric; - switch (g_variant_n_children(v)) { - case 5: - g_variant_get_child(v, 4, "u", &route.pref_src); - /* fall-through */ - case 4: - g_variant_get_child(v, 0, "u", &route.network); - g_variant_get_child(v, 1, "u", &plen); - g_variant_get_child(v, 2, "u", &route.gateway); - /* 4th item is unused route metric */ - route.table_coerced = nm_platform_route_table_coerce(route_table); - route.metric = route_metric; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; + if (IS_IPv4) { + while (g_variant_iter_next(var_iter, "@au", &v)) { + _nm_unused gs_unref_variant GVariant *v_ref_owner = v; - if (plen > 32) + switch (g_variant_n_children(v)) { + case 5: + g_variant_get_child(v, 4, "u", &route.r4.pref_src); + /* fall-through */ + case 4: + g_variant_get_child(v, 0, "u", &route.r4.network); + g_variant_get_child(v, 1, "u", &plen); + g_variant_get_child(v, 2, "u", &route.r4.gateway); + /* 4th item is unused route metric */ + route.r4.table_any = TRUE; + route.r4.metric_any = TRUE; + route.r4.rt_source = NM_IP_CONFIG_SOURCE_VPN; + + if (plen > 32) + break; + route.r4.plen = plen; + route.r4.network = + nm_utils_ip4_address_clear_host_address(route.r4.network, plen); + + if (priv->ip_data_4.gw_external.addr4 + && route.r4.network == priv->ip_data_4.gw_external.addr4 + && route.r4.plen == 32) { + /* Ignore host routes to the VPN gateway since NM adds one itself + * below. Since NM knows more about the routing situation than + * the VPN server, we want to use the NM created route instead of + * whatever the server provides. + */ + break; + } + + nm_l3_config_data_add_route_4(l3cd, &route.r4); break; - route.plen = plen; - route.network = nm_utils_ip4_address_clear_host_address(route.network, plen); - - if (priv->ip4_external_gw && route.network == priv->ip4_external_gw - && route.plen == 32) { - /* Ignore host routes to the VPN gateway since NM adds one itself - * below. Since NM knows more about the routing situation than - * the VPN server, we want to use the NM created route instead of - * whatever the server provides. - */ + default: break; } - - nm_ip4_config_add_route(config, &route, NULL); - break; - default: - break; } - g_variant_unref(v); - } - g_variant_iter_free(iter); - } + } else { + while ( + g_variant_iter_next(var_iter, "(@ayu@ayu)", &dest, &prefix, &next_hop, &metric)) { + _nm_unused gs_unref_variant GVariant *next_hop_ref_owner = next_hop; + _nm_unused gs_unref_variant GVariant *dest_ref_owner = dest; - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT, "b", &b)) - never_default = b; + if (prefix > 128) + continue; - /* Merge in user overrides from the NMConnection's IPv4 setting */ - nm_ip4_config_merge_setting(config, - s_ip, - nm_setting_connection_get_mdns(s_con), - nm_setting_connection_get_llmnr(s_con), - nm_setting_connection_get_dns_over_tls(s_con), - route_table, - route_metric); + route.r6 = (NMPlatformIP6Route){ + .plen = prefix, + .table_any = TRUE, + .metric_any = TRUE, + .rt_source = NM_IP_CONFIG_SOURCE_VPN, + }; - if (!never_default && !nm_setting_ip_config_get_never_default(s_ip)) { - const NMPlatformIP4Route r = { - .ifindex = ip_ifindex, - .rt_source = NM_IP_CONFIG_SOURCE_VPN, - .gateway = priv->ip4_internal_gw, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, - .mss = mss, - }; + if (!nm_ip_addr_set_from_variant(AF_INET6, &route.r6.network, dest, NULL)) + continue; - nm_ip4_config_add_route(config, &r, NULL); - } + nm_ip_addr_set_from_variant(AF_INET6, &route.r6.gateway, next_hop, NULL); - nm_clear_pointer(&priv->ip4_dev_route_blacklist, g_ptr_array_unref); + nm_utils_ip6_address_clear_host_address(&route.r6.network, + &route.r6.network, + route.r6.plen); - nm_ip4_config_add_dependent_routes(config, - route_table, - nm_vpn_connection_get_ip4_route_metric(self), - _is_device_vrf(self), - &priv->ip4_dev_route_blacklist); + if (!IN6_IS_ADDR_UNSPECIFIED(&priv->ip_data_6.gw_external.addr6) + && IN6_ARE_ADDR_EQUAL(&route.r6.network, &priv->ip_data_6.gw_external.addr6) + && route.r6.plen == 128) { + /* Ignore host routes to the VPN gateway since NM adds one itself. + * Since NM knows more about the routing situation than the VPN + * server, we want to use the NM created route instead of whatever + * the server provides. + */ + continue; + } - if (priv->ip4_config) { - nm_ip4_config_replace(priv->ip4_config, config, NULL); - g_object_unref(config); - } else { - priv->ip4_config = config; - nm_dbus_object_export(NM_DBUS_OBJECT(config)); - g_object_notify((GObject *) self, NM_ACTIVE_CONNECTION_IP4_CONFIG); - } - - nm_vpn_connection_config_maybe_complete(self, TRUE); -} - -static void -nm_vpn_connection_ip6_config_get(NMVpnConnection *self, GVariant *dict) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - NMPlatformIP6Address address; - guint32 u32, route_metric; - NMSettingIPConfig * s_ip; - guint32 route_table; - NMIP6Config * config; - GVariantIter * iter; - const char * str; - GVariant * v; - gboolean b; - int ip_ifindex; - guint32 mss = 0; - gboolean never_default = FALSE; - - g_return_if_fail(dict && g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT)); - - _LOGI("VPN connection: (IP6 Config Get) reply received"); - - if (priv->vpn_state == STATE_CONNECT) - _set_vpn_state(self, STATE_IP_CONFIG_GET, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); - - if (priv->vpn_state > STATE_ACTIVATED) { - _LOGI("VPN connection: (IP6 Config Get) ignoring, the connection is no longer active"); - return; - } - - if (g_variant_n_children(dict) == 0) { - priv->has_ip6 = FALSE; - nm_vpn_connection_config_maybe_complete(self, TRUE); - return; - } - - ip_ifindex = nm_vpn_connection_get_ip_ifindex(self, TRUE); - if (ip_ifindex <= 0) - g_return_if_reached(); - - config = nm_ip6_config_new(nm_netns_get_multi_idx(priv->netns), ip_ifindex); - nm_ip6_config_set_dns_priority(config, NM_DNS_PRIORITY_DEFAULT_VPN); - - memset(&address, 0, sizeof(address)); - address.plen = 128; - - /* Internal address of the VPN subnet's gateway */ - nm_clear_g_free(&priv->ip6_internal_gw); - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_INT_GATEWAY, "@ay", &v)) { - priv->ip6_internal_gw = ip6_addr_dup_from_variant(v); - g_variant_unref(v); - } - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_ADDRESS, "@ay", &v)) { - ip6_addr_from_variant(v, &address.address); - g_variant_unref(v); - } - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_PTP, "@ay", &v)) { - ip6_addr_from_variant(v, &address.peer_address); - g_variant_unref(v); - } - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_PREFIX, "u", &u32)) - address.plen = u32; - - if (!IN6_IS_ADDR_UNSPECIFIED(&address.address) && address.plen && address.plen <= 128) { - address.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_address(config, &address); - } else { - _LOGW("invalid IP6 config received!"); - g_object_unref(config); - nm_vpn_connection_config_maybe_complete(self, FALSE); - return; - } - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_DNS, "aay", &iter)) { - while (g_variant_iter_next(iter, "@ay", &v)) { - struct in6_addr dns; - - if (ip6_addr_from_variant(v, &dns)) - nm_ip6_config_add_nameserver(config, &dns); - g_variant_unref(v); - } - g_variant_iter_free(iter); - } - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_MSS, "u", &u32)) - mss = u32; - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_DOMAIN, "&s", &str)) - nm_ip6_config_add_domain(config, str); - - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_DOMAINS, "as", &iter)) { - while (g_variant_iter_next(iter, "&s", &str)) - nm_ip6_config_add_domain(config, str); - g_variant_iter_free(iter); - } - - route_table = get_route_table(self, AF_INET6, TRUE); - route_metric = nm_vpn_connection_get_ip6_route_metric(self); - s_ip = nm_connection_get_setting_ip6_config(_get_applied_connection(self)); - - if (nm_setting_ip_config_get_ignore_auto_routes(s_ip)) { - /* Ignore VPN routes */ - } else if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_PRESERVE_ROUTES, "b", &b) && b) { - if (priv->ip6_config) { - NMDedupMultiIter ipconf_iter; - const NMPlatformIP6Route *route; - - nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, priv->ip6_config, &route) - nm_ip6_config_add_route(config, route, NULL); - } - } else if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_ROUTES, "a(ayuayu)", &iter)) { - GVariant *dest, *next_hop; - guint32 prefix, metric; - - while (g_variant_iter_next(iter, "(@ayu@ayu)", &dest, &prefix, &next_hop, &metric)) { - NMPlatformIP6Route route; - - memset(&route, 0, sizeof(route)); - - if (!ip6_addr_from_variant(dest, &route.network)) - goto next; - - if (prefix > 128) - goto next; - - route.plen = prefix; - ip6_addr_from_variant(next_hop, &route.gateway); - route.table_coerced = nm_platform_route_table_coerce(route_table); - route.metric = route_metric; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - - nm_utils_ip6_address_clear_host_address(&route.network, &route.network, route.plen); - - if (priv->ip6_external_gw && IN6_ARE_ADDR_EQUAL(&route.network, priv->ip6_external_gw) - && route.plen == 128) { - /* Ignore host routes to the VPN gateway since NM adds one itself. - * Since NM knows more about the routing situation than the VPN - * server, we want to use the NM created route instead of whatever - * the server provides. - */ - goto next; + nm_l3_config_data_add_route_6(l3cd, &route.r6); } - - nm_ip6_config_add_route(config, &route, NULL); - -next: - g_variant_unref(dest); - g_variant_unref(next_hop); } - g_variant_iter_free(iter); } - if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_NEVER_DEFAULT, "b", &b)) - never_default = b; + if (g_variant_lookup(dict, + IS_IPv4 ? NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT + : NM_VPN_PLUGIN_IP6_CONFIG_NEVER_DEFAULT, + "b", + &v_b)) + never_default = v_b; + else + never_default = FALSE; - /* Merge in user overrides from the NMConnection's IPv6 setting */ - nm_ip6_config_merge_setting(config, s_ip, route_table, route_metric); + if (!never_default) { + NMPlatformIPXRoute route; - if (!never_default && !nm_setting_ip_config_get_never_default(s_ip)) { - const NMPlatformIP6Route r = { - .ifindex = ip_ifindex, - .rt_source = NM_IP_CONFIG_SOURCE_VPN, - .gateway = *(priv->ip6_internal_gw ?: &in6addr_any), - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, - .mss = mss, - }; - - nm_ip6_config_add_route(config, &r, NULL); + if (IS_IPv4) { + route.r4 = (NMPlatformIP4Route){ + .ifindex = ip_ifindex, + .rt_source = NM_IP_CONFIG_SOURCE_VPN, + .gateway = priv->ip_data_4.gw_internal.addr4, + .table_any = TRUE, + .metric_any = TRUE, + .mss = mss, + }; + } else { + route.r6 = (NMPlatformIP6Route){ + .ifindex = ip_ifindex, + .rt_source = NM_IP_CONFIG_SOURCE_VPN, + .gateway = priv->ip_data_6.gw_internal.addr6, + .table_any = TRUE, + .metric_any = TRUE, + .mss = mss, + }; + } + nm_l3_config_data_add_route(l3cd, addr_family, NULL, &route.rx); } - nm_ip6_config_add_dependent_routes(config, route_table, route_metric, _is_device_vrf(self)); + _l3cfg_l3cd_set(self, L3CD_TYPE_IP_X(IS_IPv4), l3cd); - if (priv->ip6_config) { - nm_ip6_config_replace(priv->ip6_config, config, NULL); - g_object_unref(config); - } else { - priv->ip6_config = config; - nm_dbus_object_export(NM_DBUS_OBJECT(config)); - g_object_notify((GObject *) self, NM_ACTIVE_CONNECTION_IP6_CONFIG); - } - - nm_vpn_connection_config_maybe_complete(self, TRUE); + _check_complete(self, TRUE); } -static gboolean -connect_timeout_cb(gpointer user_data) +void +nm_vpn_connection_disconnect(NMVpnConnection * self, + NMActiveConnectionStateReason reason, + gboolean quitting) { - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + g_return_if_fail(NM_IS_VPN_CONNECTION(self)); - priv->connect_timeout = 0; + _set_vpn_state(self, STATE_DISCONNECTED, reason, quitting); +} - /* Cancel activation if it's taken too long */ - if (priv->vpn_state == STATE_CONNECT || priv->vpn_state == STATE_IP_CONFIG_GET) { - _LOGW("VPN connection: connect timeout exceeded."); - _set_vpn_state(self, - STATE_FAILED, - NM_ACTIVE_CONNECTION_STATE_REASON_CONNECT_TIMEOUT, - FALSE); +gboolean +nm_vpn_connection_deactivate(NMVpnConnection * self, + NMActiveConnectionStateReason reason, + gboolean quitting) +{ + NMVpnConnectionPrivate *priv; + + g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), FALSE); + + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (priv->vpn_state <= STATE_UNKNOWN || priv->vpn_state > STATE_DEACTIVATING) + return FALSE; + + _set_vpn_state(self, STATE_DEACTIVATING, reason, quitting); + return TRUE; +} + +/*****************************************************************************/ + +static void +_secrets_dbus_need_secrets_cb(GObject *source, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection * self; + NMVpnConnectionPrivate *priv; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + const char * setting_name; + + res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); + if (nm_utils_error_is_cancelled(error)) + return; + + self = NM_VPN_CONNECTION(user_data); + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + if (error) { + _LOGW("plugin NeedSecrets request #%d failed: %s", priv->secrets_idx + 1, error->message); + _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); + return; } - return FALSE; + g_variant_get(res, "(&s)", &setting_name); + if (nm_str_is_empty(setting_name)) { + /* No secrets required; we can start the VPN */ + _LOGD("service indicated no additional secrets required"); + really_activate(self, priv->username); + return; + } + + /* More secrets required */ + if (priv->secrets_idx == SECRETS_REQ_NEW) { + _LOGW("final secrets request failed to provide sufficient secrets"); + _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); + return; + } + + _LOGD("service indicated additional secrets required"); + _secrets_get(self, priv->secrets_idx + 1, NULL); } static void -connect_success(NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - NMSettingVpn * s_vpn; - guint32 timeout; - - s_vpn = nm_connection_get_setting_vpn(_get_applied_connection(self)); - g_assert(s_vpn); - - /* Timeout waiting for IP config signal from VPN service - * It is a configured value or 60 seconds */ - timeout = nm_setting_vpn_get_timeout(s_vpn); - if (timeout == 0) { - timeout = nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA, - NM_CON_DEFAULT("vpn.timeout"), - NULL, - 1, - G_MAXUINT32, - 60); - } - priv->connect_timeout = g_timeout_add_seconds(timeout, connect_timeout_cb, self); - - nm_clear_pointer(&priv->connect_hash, g_variant_unref); -} - -static void -connect_cb(GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +_secrets_dbus_new_secrets_cb(GObject *source, GAsyncResult *result, gpointer user_data) { NMVpnConnection *self; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; - reply = g_dbus_proxy_call_finish(proxy, result, &error); - if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); + if (nm_utils_error_is_cancelled(error)) return; self = NM_VPN_CONNECTION(user_data); if (error) { - g_dbus_error_strip_remote_error(error); - _LOGW("VPN connection: failed to connect: '%s'", error->message); - _set_vpn_state(self, - STATE_FAILED, - NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_FAILED, - FALSE); - } else - connect_success(self); -} - -static void -connect_interactive_cb(GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMVpnConnection * self; - NMVpnConnectionPrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish(proxy, result, &error); - if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + _LOGW("sending new secrets to the plugin failed: %s", error->message); + _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); return; - - self = NM_VPN_CONNECTION(user_data); - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - - _LOGI("VPN connection: (ConnectInteractive) reply received"); - - if (g_error_matches(error, - NM_VPN_PLUGIN_ERROR, - NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED)) { - _LOGD("VPN connection: falling back to non-interactive connect"); - - /* Fall back to Connect() */ - g_dbus_proxy_call(priv->proxy, - "Connect", - g_variant_new("(@a{sa{sv}})", priv->connect_hash), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) connect_cb, - self); - } else if (error) { - g_dbus_error_strip_remote_error(error); - _LOGW("VPN connection: failed to connect interactively: '%s'", error->message); - _set_vpn_state(self, - STATE_FAILED, - NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_FAILED, - FALSE); - } else - connect_success(self); -} - -/* Add a username to a hashed connection */ -static GVariant * -_hash_with_username(NMConnection *connection, const char *username) -{ - gs_unref_object NMConnection *dup = NULL; - NMSettingVpn * s_vpn; - - /* Shortcut if we weren't given a username or if there already was one in - * the VPN setting; don't bother duplicating the connection and everything. - */ - s_vpn = nm_connection_get_setting_vpn(connection); - g_assert(s_vpn); - if (username == NULL || nm_setting_vpn_get_user_name(s_vpn)) - return nm_connection_to_dbus(connection, NM_CONNECTION_SERIALIZE_ALL); - - dup = nm_simple_connection_new_clone(connection); - g_assert(dup); - s_vpn = nm_connection_get_setting_vpn(dup); - g_assert(s_vpn); - g_object_set(s_vpn, NM_SETTING_VPN_USER_NAME, username, NULL); - return nm_connection_to_dbus(dup, NM_CONNECTION_SERIALIZE_ALL); -} - -static void -really_activate(NMVpnConnection *self, const char *username) -{ - NMVpnConnectionPrivate *priv; - GVariantBuilder details; - - g_return_if_fail(NM_IS_VPN_CONNECTION(self)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - g_return_if_fail(priv->vpn_state == STATE_NEED_AUTH); - - nm_clear_pointer(&priv->connect_hash, g_variant_unref); - priv->connect_hash = _hash_with_username(_get_applied_connection(self), username); - g_variant_ref_sink(priv->connect_hash); - - /* If at least one agent doesn't support VPN hints, then we can't use - * ConnectInteractive(), because that agent won't be able to pass hints - * from the VPN plugin's interactive secrets requests to the VPN authentication - * dialog and we won't get the secrets we need. In this case fall back to - * the old Connect() call. - */ - if (nm_agent_manager_all_agents_have_capability( - nm_agent_manager_get(), - nm_active_connection_get_subject(NM_ACTIVE_CONNECTION(self)), - NM_SECRET_AGENT_CAPABILITY_VPN_HINTS)) { - _LOGD("Allowing interactive secrets as all agents have that capability"); - - g_variant_builder_init(&details, G_VARIANT_TYPE_VARDICT); - g_dbus_proxy_call(priv->proxy, - "ConnectInteractive", - g_variant_new("(@a{sa{sv}}a{sv})", priv->connect_hash, &details), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) connect_interactive_cb, - self); - } else { - _LOGD("Calling old Connect function as not all agents support interactive secrets"); - g_dbus_proxy_call(priv->proxy, - "Connect", - g_variant_new("(@a{sa{sv}})", priv->connect_hash), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) connect_cb, - self); } _set_vpn_state(self, STATE_CONNECT, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); } static void -failure_cb(GDBusProxy *proxy, guint32 reason, gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION(user_data); - - plugin_failed(self, reason); -} - -static void -state_changed_cb(GDBusProxy *proxy, guint32 new_service_state, gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION(user_data); - - plugin_state_changed(self, new_service_state); -} - -static void -secrets_required_cb(GDBusProxy * proxy, - const char * message, - const char *const *secrets, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION(user_data); - - plugin_interactive_secrets_required(self, message, secrets); -} - -static void -config_cb(GDBusProxy *proxy, GVariant *dict, gpointer user_data) +_secrets_get_secrets_cb(NMSettingsConnection * connection, + NMSettingsConnectionCallId *call_id, + const char * agent_username, + const char * setting_name, + GError * error, + gpointer user_data) { NMVpnConnection * self = NM_VPN_CONNECTION(user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NMVpnConnectionPrivate *priv; + GVariant * dict; - /* Only list to this signals during and after connection */ - if (priv->vpn_state >= STATE_NEED_AUTH) - nm_vpn_connection_config_get(self, dict); -} + g_return_if_fail(NM_IS_VPN_CONNECTION(self)); -static void -ip4_config_cb(GDBusProxy *proxy, GVariant *dict, gpointer user_data) -{ - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - /* Only list to this signals during and after connection */ - if (priv->vpn_state >= STATE_NEED_AUTH) - nm_vpn_connection_ip4_config_get(self, dict); -} + g_return_if_fail(connection && connection == _get_settings_connection(self, FALSE)); + g_return_if_fail(call_id == priv->secrets_id); -static void -ip6_config_cb(GDBusProxy *proxy, GVariant *dict, gpointer user_data) -{ - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + priv->secrets_id = NULL; - /* Only list to this signals during and after connection */ - if (priv->vpn_state >= STATE_NEED_AUTH) - nm_vpn_connection_ip6_config_get(self, dict); -} + if (nm_utils_error_is_cancelled(error)) + return; -static void -_name_owner_changed(GObject *object, GParamSpec *pspec, gpointer user_data) -{ - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - char * owner; - - owner = g_dbus_proxy_get_name_owner(G_DBUS_PROXY(object)); - - if (owner && !priv->service_running) { - /* service appeared */ - priv->service_running = TRUE; - _LOGI("Saw the service appear; activating connection"); - - /* No need to wait for the timeout any longer */ - nm_clear_g_source(&priv->start_timeout); - - /* Expect success because the VPN service has already appeared */ - _nm_dbus_signal_connect(priv->proxy, - "Failure", - G_VARIANT_TYPE("(u)"), - G_CALLBACK(failure_cb), - self); - _nm_dbus_signal_connect(priv->proxy, - "StateChanged", - G_VARIANT_TYPE("(u)"), - G_CALLBACK(state_changed_cb), - self); - _nm_dbus_signal_connect(priv->proxy, - "SecretsRequired", - G_VARIANT_TYPE("(sas)"), - G_CALLBACK(secrets_required_cb), - self); - _nm_dbus_signal_connect(priv->proxy, - "Config", - G_VARIANT_TYPE("(a{sv})"), - G_CALLBACK(config_cb), - self); - _nm_dbus_signal_connect(priv->proxy, - "Ip4Config", - G_VARIANT_TYPE("(a{sv})"), - G_CALLBACK(ip4_config_cb), - self); - _nm_dbus_signal_connect(priv->proxy, - "Ip6Config", - G_VARIANT_TYPE("(a{sv})"), - G_CALLBACK(ip6_config_cb), - self); - - _set_vpn_state(self, STATE_NEED_AUTH, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); - - /* Kick off the secrets requests; first we get existing system secrets - * and ask the plugin if these are sufficient, next we get all existing - * secrets from system and from user agents and ask the plugin again, - * and last we ask the user for new secrets if required. - */ - get_secrets(self, SECRETS_REQ_SYSTEM, NULL); - } else if (!owner && priv->service_running) { - /* service went away */ - priv->service_running = FALSE; - _LOGI("VPN service disappeared"); - nm_vpn_connection_disconnect(self, - NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_STOPPED, - FALSE); + if (error && priv->secrets_idx >= SECRETS_REQ_NEW) { + _LOGW("secrets: failed to request VPN secrets #%d: %s", + priv->secrets_idx + 1, + error->message); + _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); + return; } - g_free(owner); + if (!priv->dbus.bus_name) { + _set_vpn_state(self, + STATE_FAILED, + NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_STOPPED, + FALSE); + return; + } + + /* Cache the username for later */ + if (agent_username) + nm_strdup_reset(&priv->username, agent_username); + + dict = _hash_with_username(_get_applied_connection(self), priv->username); + + if (priv->secrets_idx == SECRETS_REQ_INTERACTIVE) { + _LOGD("secrets: sending secrets to the plugin"); + _dbus_connection_call(self, + "NewSecrets", + g_variant_new("(@a{sa{sv}})", dict), + G_VARIANT_TYPE("()"), + _secrets_dbus_new_secrets_cb); + return; + } + + _LOGD("secrets: asking service if additional secrets are required"); + _dbus_connection_call(self, + "NeedSecrets", + g_variant_new("(@a{sa{sv}})", dict), + G_VARIANT_TYPE("(s)"), + _secrets_dbus_need_secrets_cb); } -static gboolean -_daemon_exec_timeout(gpointer data) +static void +_secrets_get(NMVpnConnection *self, SecretsReq secrets_idx, const char *const *hints) { - NMVpnConnection * self = NM_VPN_CONNECTION(data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; - _LOGW("Timed out waiting for the service to start"); - priv->start_timeout = 0; - nm_vpn_connection_disconnect(self, - NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT, - FALSE); - return G_SOURCE_REMOVE; + g_return_if_fail(secrets_idx < SECRETS_REQ_LAST); + + priv->secrets_idx = secrets_idx; + + cancel_get_secrets(self); + + _LOGD("secrets: requesting VPN secrets pass #%d", priv->secrets_idx + 1); + + switch (priv->secrets_idx) { + case SECRETS_REQ_SYSTEM: + flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM; + break; + case SECRETS_REQ_EXISTING: + flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; + break; + case SECRETS_REQ_NEW: + case SECRETS_REQ_INTERACTIVE: + flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; + break; + default: + g_return_if_reached(); + } + + if (nm_active_connection_get_user_requested(NM_ACTIVE_CONNECTION(self))) + flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED; + + priv->secrets_id = nm_settings_connection_get_secrets( + _get_settings_connection(self, FALSE), + _get_applied_connection(self), + nm_active_connection_get_subject(NM_ACTIVE_CONNECTION(self)), + NM_SETTING_VPN_SETTING_NAME, + flags, + hints, + _secrets_get_secrets_cb, + self); + + g_return_if_fail(priv->secrets_id); } +static void +_dbus_signal_secrets_required_cb(NMVpnConnection * self, + const char * message, + const char *const *secrets) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + const gsize secrets_len = NM_PTRARRAY_LEN(secrets); + gsize i; + gs_free const char ** hints = NULL; + gs_free char * message_hint = NULL; + + if (!NM_IN_SET(priv->vpn_state, STATE_CONNECT, STATE_NEED_AUTH)) { + _LOGD("secrets: request ignored in current state %s", + vpn_state_to_string_a(priv->vpn_state)); + return; + } + + _LOGD("secrets: request (state %s)", vpn_state_to_string_a(priv->vpn_state)); + + priv->secrets_idx = SECRETS_REQ_INTERACTIVE; + _set_vpn_state(self, STATE_NEED_AUTH, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); + + /* Copy hints and add message to the end */ + hints = g_new(const char *, secrets_len + 2); + for (i = 0; i < secrets_len; i++) + hints[i] = secrets[i]; + if (message) { + message_hint = g_strdup_printf("x-vpn-message:%s", message); + hints[i++] = message_hint; + } + hints[i] = NULL; + nm_assert(i < secrets_len + 2); + + _secrets_get(self, SECRETS_REQ_INTERACTIVE, hints); +} + +/*****************************************************************************/ + static int _get_log_level(void) { @@ -2253,14 +2489,14 @@ nm_vpn_service_daemon_exec(NMVpnConnection *self, GError **error) NMVpnConnectionPrivate *priv; GPid pid; char * vpn_argv[4]; - gboolean success = FALSE; - GError * spawn_error = NULL; - guint i, j, n_environ; gs_free char ** envp = NULL; char env_log_level[NM_STRLEN("NM_VPN_LOG_LEVEL=") + 100]; char env_log_syslog[NM_STRLEN("NM_VPN_LOG_SYSLOG=") + 10]; - const int N_ENVIRON_EXTRA = 3; + const gsize N_ENVIRON_EXTRA = 3; char ** p_environ; + gsize n_environ; + gsize i; + gsize j; g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), FALSE); @@ -2271,17 +2507,17 @@ nm_vpn_service_daemon_exec(NMVpnConnection *self, GError **error) g_return_val_if_fail(vpn_argv[0], FALSE); if (nm_vpn_plugin_info_supports_multiple(priv->plugin_info)) { vpn_argv[i++] = "--bus-name"; - vpn_argv[i++] = priv->bus_name; + vpn_argv[i++] = priv->dbus.bus_name; } vpn_argv[i++] = NULL; /* we include and "config.h" defines _GNU_SOURCE for us. So, we have @environ. */ p_environ = environ; - n_environ = p_environ ? g_strv_length(p_environ) : 0; + n_environ = NM_PTRARRAY_LEN(p_environ); envp = g_new(char *, n_environ + N_ENVIRON_EXTRA); for (i = 0, j = 0; j < n_environ; j++) { - if (g_str_has_prefix(p_environ[j], "NM_VPN_LOG_LEVEL=") - || g_str_has_prefix(p_environ[j], "NM_VPN_LOG_SYSLOG=")) + if (NM_STR_HAS_PREFIX(p_environ[j], "NM_VPN_LOG_LEVEL=") + || NM_STR_HAS_PREFIX(p_environ[j], "NM_VPN_LOG_SYSLOG=")) continue; envp[i++] = p_environ[j]; } @@ -2300,70 +2536,203 @@ nm_vpn_service_daemon_exec(NMVpnConnection *self, GError **error) envp[i++] = NULL; nm_assert(i <= n_environ + N_ENVIRON_EXTRA); - success = g_spawn_async(NULL, vpn_argv, envp, 0, nm_utils_setpgid, NULL, &pid, &spawn_error); + if (!g_spawn_async(NULL, vpn_argv, envp, 0, nm_utils_setpgid, NULL, &pid, error)) + return FALSE; - if (success) { - _LOGI("Started the VPN service, PID %ld", (long int) pid); - priv->start_timeout = g_timeout_add_seconds(5, _daemon_exec_timeout, self); - } else { - g_set_error(error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "%s", - spawn_error ? spawn_error->message : "unknown g_spawn_async() error"); + _LOGD("starting: VPN service has PID %lld", (long long) pid); + return TRUE; +} - if (spawn_error) - g_error_free(spawn_error); +/*****************************************************************************/ + +static gboolean +_start_timeout_cb(gpointer data) +{ + NMVpnConnection * self = NM_VPN_CONNECTION(data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + nm_clear_g_source_inst(&priv->start_timeout_source); + + if (priv->dbus_service_started) + _LOGW("starting: timed out waiting for the service to start"); + else + _LOGW("starting: timed out waiting for the VPN to activate"); + nm_vpn_connection_disconnect(self, + NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT, + FALSE); + return G_SOURCE_CONTINUE; +} + +/*****************************************************************************/ + +static void +_dbus_dispatch_cb(GDBusConnection *connection, + const char * sender_name, + const char * object_path, + const char * interface_name, + const char * signal_name, + GVariant * parameters, + gpointer user_data) +{ + NMVpnConnection * self = user_data; + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + guint32 v_u; + + nm_assert(nm_streq0(object_path, NM_VPN_DBUS_PLUGIN_PATH)); + nm_assert(nm_streq0(interface_name, NM_VPN_DBUS_PLUGIN_INTERFACE)); + nm_assert(signal_name); + + if (!nm_streq0(priv->dbus.owner, sender_name)) + return; + + if (nm_streq(signal_name, "Failure")) { + if (nm_g_variant_tuple_get_u(parameters, &v_u)) + _dbus_signal_failure_cb(self, v_u); + } else if (nm_streq(signal_name, "StateChanged")) { + if (nm_g_variant_tuple_get_u(parameters, &v_u)) + _dbus_signal_state_changed_cb(self, v_u); + } else if (nm_streq(signal_name, "SecretsRequired")) { + if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sas)"))) { + const char * v_s; + gs_free const char **v_strv = NULL; + + g_variant_get(parameters, "(&s^a&s)", &v_s, &v_strv); + _dbus_signal_secrets_required_cb(self, v_s, v_strv); + } + } else if (NM_IN_STRSET(signal_name, "Config", "Ip4Config", "Ip6Config")) { + if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(a{sv})"))) { + gs_unref_variant GVariant *v_var = NULL; + + g_variant_get(parameters, "(@a{sv})", &v_var); + if (signal_name[0] == 'C') + _dbus_signal_config_cb(self, v_var); + else if (signal_name[2] == '4') + _dbus_signal_ip_config_cb(self, AF_INET, v_var); + else + _dbus_signal_ip_config_cb(self, AF_INET6, v_var); + } } - - return success; } static void -on_proxy_acquired(GObject *object, GAsyncResult *result, gpointer user_data) +_name_owner_changed(NMVpnConnection *self, const char *owner, gboolean initializing) +{ + _nm_unused gs_unref_object NMVpnConnection *self_keep_alive = g_object_ref(self); + NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + owner = nm_str_not_empty(owner); + + if (!owner && initializing) { + gs_free_error GError *error = NULL; + + nm_assert(!priv->dbus.owner); + _LOGT("dbus: no name owner for %s (start VPN service)", priv->dbus.bus_name); + + if (!nm_vpn_service_daemon_exec(self, &error)) { + _LOGW("starting: failure to start VPN service: %s", error->message); + nm_vpn_connection_disconnect(self, + NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_FAILED, + FALSE); + } + priv->start_timeout_source = nm_g_timeout_add_seconds_source(5, _start_timeout_cb, self); + return; + } + + if (!nm_strdup_reset(&priv->dbus.owner, owner)) + return; + + if (!priv->dbus.owner) { + _LOGT("dbus: name owner for %s disappeared", priv->dbus.bus_name); + + /* We don't want to restart if the service re-appears. Disconnect the signal + * so that cannot happen and we don't disconnect the VPN again. */ + nm_clear_g_dbus_connection_signal(priv->dbus.connection, + &priv->dbus.signal_id_name_changed); + + nm_vpn_connection_disconnect(self, + NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_STOPPED, + FALSE); + return; + } + + _LOGT("dbus: name owner %s for %s", priv->dbus.owner, priv->dbus.bus_name); + + priv->dbus_service_started = TRUE; + nm_clear_g_source_inst(&priv->start_timeout_source); + priv->start_timeout_source = + nm_g_timeout_add_seconds_source(_get_vpn_timeout(self) + 180, _start_timeout_cb, self); + + _set_vpn_state(self, STATE_NEED_AUTH, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); + + /* Kick off the secrets requests; first we get existing system secrets + * and ask the plugin if these are sufficient, next we get all existing + * secrets from system and from user agents and ask the plugin again, + * and last we ask the user for new secrets if required. + */ + _secrets_get(self, SECRETS_REQ_SYSTEM, NULL); +} + +static void +_name_owner_changed_cb(GDBusConnection *connection, + const char * sender_name, + const char * object_path, + const char * interface_name, + const char * signal_name, + GVariant * parameters, + gpointer user_data) +{ + NMVpnConnection * self = user_data; + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + const char * new_owner; + + if (!priv->dbus.name_owner_initialized) + return; + + if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) + return; + + g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_owner); + + _name_owner_changed(self, new_owner, FALSE); +} + +static void +_name_owner_get_cb(const char *name_owner, GError *error, gpointer user_data) { NMVpnConnection * self; NMVpnConnectionPrivate *priv; - gs_free_error GError *error = NULL; - GDBusProxy * proxy; - proxy = g_dbus_proxy_new_for_bus_finish(result, &error); - if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (nm_utils_error_is_cancelled(error)) return; - self = NM_VPN_CONNECTION(user_data); + self = user_data; priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - if (error) { - _LOGE("failed to acquire dbus proxy for VPN service: %s", error->message); - _set_vpn_state(self, - STATE_FAILED, - NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_FAILED, - FALSE); - return; - } - - priv->proxy = proxy; - - g_signal_connect(priv->proxy, "notify::g-name-owner", G_CALLBACK(_name_owner_changed), self); - _name_owner_changed(G_OBJECT(priv->proxy), NULL, self); - - if (priv->service_running) - return; - - if (!nm_vpn_service_daemon_exec(self, &error)) { - _LOGW("Could not launch the VPN service. error: %s.", error->message); - - nm_vpn_connection_disconnect(self, - NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_FAILED, - FALSE); - } + priv->dbus.name_owner_initialized = TRUE; + _name_owner_changed(self, name_owner, TRUE); } +static gboolean +_init_fail_on_idle_cb(gpointer user_data) +{ + NMVpnConnection * self = user_data; + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + nm_clear_g_source_inst(&priv->init_fail_on_idle_source); + _set_vpn_state(self, + STATE_FAILED, + NM_ACTIVE_CONNECTION_STATE_REASON_SERVICE_START_FAILED, + FALSE); + return G_SOURCE_CONTINUE; +} + +/*****************************************************************************/ + void nm_vpn_connection_activate(NMVpnConnection *self, NMVpnPluginInfo *plugin_info) { NMVpnConnectionPrivate *priv; + NMConnection * connection; NMSettingVpn * s_vpn; const char * service; @@ -2373,7 +2742,9 @@ nm_vpn_connection_activate(NMVpnConnection *self, NMVpnPluginInfo *plugin_info) priv = NM_VPN_CONNECTION_GET_PRIVATE(self); g_return_if_fail(!priv->plugin_info); - s_vpn = nm_connection_get_setting_vpn(_get_applied_connection(self)); + connection = _get_applied_connection(self); + + s_vpn = nm_connection_get_setting_vpn(connection); g_return_if_fail(s_vpn); service = nm_vpn_plugin_info_get_service(plugin_info); @@ -2387,413 +2758,138 @@ nm_vpn_connection_activate(NMVpnConnection *self, NMVpnPluginInfo *plugin_info) path = strrchr(path, '/'); g_return_if_fail(path); - priv->bus_name = g_strdup_printf("%s.Connection_%s", service, &path[1]); + priv->dbus.bus_name = g_strdup_printf("%s.Connection_%s", service, &path[1]); } else - priv->bus_name = g_strdup(service); + priv->dbus.bus_name = g_strdup(service); + + _LOGI("starting %s", nm_vpn_plugin_info_get_name(plugin_info)); priv->connection_can_persist = nm_setting_vpn_get_persistent(s_vpn); priv->plugin_info = g_object_ref(plugin_info); - priv->cancellable = g_cancellable_new(); - g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, - NULL, - priv->bus_name, - NM_VPN_DBUS_PLUGIN_PATH, - NM_VPN_DBUS_PLUGIN_INTERFACE, - priv->cancellable, - (GAsyncReadyCallback) on_proxy_acquired, - self); + priv->main_cancellable = g_cancellable_new(); + priv->dbus.connection = nm_g_object_ref(NM_MAIN_DBUS_CONNECTION_GET); + + if (!priv->dbus.connection) { + _LOGD("starting: no D-Bus connection (will fail)"); + priv->init_fail_on_idle_source = nm_g_idle_add_source(_init_fail_on_idle_cb, self); + goto out; + } + + _LOGD("starting: watch D-Bus service %s", priv->dbus.bus_name); + priv->dbus.signal_id_name_changed = + nm_dbus_connection_signal_subscribe_name_owner_changed(priv->dbus.connection, + priv->dbus.bus_name, + _name_owner_changed_cb, + self, + NULL); + + priv->dbus.signal_id_vpn = g_dbus_connection_signal_subscribe(priv->dbus.connection, + priv->dbus.bus_name, + NM_VPN_DBUS_PLUGIN_INTERFACE, + NULL, + NM_VPN_DBUS_PLUGIN_PATH, + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + _dbus_dispatch_cb, + self, + NULL); + + nm_dbus_connection_call_get_name_owner(priv->dbus.connection, + priv->dbus.bus_name, + 3000, + priv->main_cancellable, + _name_owner_get_cb, + self); + +out: _set_vpn_state(self, STATE_PREPARE, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); } -NMVpnConnectionState -nm_vpn_connection_get_vpn_state(NMVpnConnection *self) -{ - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NM_VPN_CONNECTION_STATE_UNKNOWN); - - return _state_to_nm_vpn_state(NM_VPN_CONNECTION_GET_PRIVATE(self)->vpn_state); -} - -const char * -nm_vpn_connection_get_banner(NMVpnConnection *self) -{ - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NULL); - - return NM_VPN_CONNECTION_GET_PRIVATE(self)->banner; -} - -NMProxyConfig * -nm_vpn_connection_get_proxy_config(NMVpnConnection *self) -{ - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NULL); - - return NM_VPN_CONNECTION_GET_PRIVATE(self)->proxy_config; -} - -NMIP4Config * -nm_vpn_connection_get_ip4_config(NMVpnConnection *self) -{ - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NULL); - - return NM_VPN_CONNECTION_GET_PRIVATE(self)->ip4_config; -} - -NMIP6Config * -nm_vpn_connection_get_ip6_config(NMVpnConnection *self) -{ - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NULL); - - return NM_VPN_CONNECTION_GET_PRIVATE(self)->ip6_config; -} - -static int -_get_ip_iface_for_device(NMVpnConnection *self, const char **out_iface) -{ - NMDevice * parent_dev; - int ifindex; - const char *iface; - - nm_assert(NM_IS_VPN_CONNECTION(self)); - - /* the ifindex and the ifname in this case should come together. - * They either must be both set, or none. */ - - parent_dev = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self)); - if (!parent_dev) - goto none; - ifindex = nm_device_get_ip_ifindex(parent_dev); - if (ifindex <= 0) - goto none; - iface = nm_device_get_ip_iface(parent_dev); - if (!iface) - goto none; - - NM_SET_OUT(out_iface, iface); - return ifindex; -none: - NM_SET_OUT(out_iface, NULL); - return 0; -} - -const char * -nm_vpn_connection_get_ip_iface(NMVpnConnection *self, gboolean fallback_device) -{ - NMVpnConnectionPrivate *priv; - const char * iface; - - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), NULL); - - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - - if (priv->ip_iface || !fallback_device) - return priv->ip_iface; - - _get_ip_iface_for_device(self, &iface); - return iface; -} - -int -nm_vpn_connection_get_ip_ifindex(NMVpnConnection *self, gboolean fallback_device) -{ - NMVpnConnectionPrivate *priv; - - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), 0); - - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - - if (priv->ip_ifindex > 0) - return priv->ip_ifindex; - if (!fallback_device) - return 0; - - return _get_ip_iface_for_device(self, NULL); -} - -guint32 -nm_vpn_connection_get_ip4_internal_gateway(NMVpnConnection *self) -{ - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), 0); - - return NM_VPN_CONNECTION_GET_PRIVATE(self)->ip4_internal_gw; -} - -struct in6_addr * -nm_vpn_connection_get_ip6_internal_gateway(NMVpnConnection *self) -{ - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), 0); - - return NM_VPN_CONNECTION_GET_PRIVATE(self)->ip6_internal_gw; -} - -void -nm_vpn_connection_disconnect(NMVpnConnection * self, - NMActiveConnectionStateReason reason, - gboolean quitting) -{ - g_return_if_fail(NM_IS_VPN_CONNECTION(self)); - - _set_vpn_state(self, STATE_DISCONNECTED, reason, quitting); -} - -gboolean -nm_vpn_connection_deactivate(NMVpnConnection * self, - NMActiveConnectionStateReason reason, - gboolean quitting) -{ - NMVpnConnectionPrivate *priv; - gboolean success = FALSE; - - g_return_val_if_fail(NM_IS_VPN_CONNECTION(self), FALSE); - - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - if (priv->vpn_state > STATE_UNKNOWN && priv->vpn_state <= STATE_DEACTIVATING) { - _set_vpn_state(self, STATE_DEACTIVATING, reason, quitting); - success = TRUE; - } - return success; -} - -/*****************************************************************************/ - -static void -plugin_need_secrets_cb(GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMVpnConnection * self; - NMVpnConnectionPrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - const char * setting_name; - - reply = _nm_dbus_proxy_call_finish(proxy, result, G_VARIANT_TYPE("(s)"), &error); - if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_VPN_CONNECTION(user_data); - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - - if (error) { - g_dbus_error_strip_remote_error(error); - _LOGE("plugin NeedSecrets request #%d failed: %s", priv->secrets_idx + 1, error->message); - _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); - return; - } - - g_variant_get(reply, "(&s)", &setting_name); - if (!strlen(setting_name)) { - _LOGD("service indicated no additional secrets required"); - - /* No secrets required; we can start the VPN */ - really_activate(self, priv->username); - return; - } - - /* More secrets required */ - if (priv->secrets_idx == SECRETS_REQ_NEW) { - _LOGE("final secrets request failed to provide sufficient secrets"); - _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); - } else { - _LOGD("service indicated additional secrets required"); - get_secrets(self, priv->secrets_idx + 1, NULL); - } -} - -static void -plugin_new_secrets_cb(GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMVpnConnection *self; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish(proxy, result, &error); - if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_VPN_CONNECTION(user_data); - - if (error) { - g_dbus_error_strip_remote_error(error); - _LOGE("sending new secrets to the plugin failed: %s", error->message); - _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); - } else - _set_vpn_state(self, STATE_CONNECT, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); -} - -static void -get_secrets_cb(NMSettingsConnection * connection, - NMSettingsConnectionCallId *call_id, - const char * agent_username, - const char * setting_name, - GError * error, - gpointer user_data) -{ - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); - NMVpnConnectionPrivate *priv; - GVariant * dict; - - g_return_if_fail(NM_IS_VPN_CONNECTION(self)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - - g_return_if_fail(connection && connection == _get_settings_connection(self, FALSE)); - g_return_if_fail(call_id == priv->secrets_id); - - priv->secrets_id = NULL; - - if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - if (error && priv->secrets_idx >= SECRETS_REQ_NEW) { - _LOGE("Failed to request VPN secrets #%d: %s", priv->secrets_idx + 1, error->message); - _set_vpn_state(self, STATE_FAILED, NM_ACTIVE_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); - return; - } - - /* Cache the username for later */ - if (agent_username) { - g_free(priv->username); - priv->username = g_strdup(agent_username); - } - - dict = _hash_with_username(_get_applied_connection(self), priv->username); - - if (priv->secrets_idx == SECRETS_REQ_INTERACTIVE) { - _LOGD("sending secrets to the plugin"); - - /* Send the secrets back to the plugin */ - g_dbus_proxy_call(priv->proxy, - "NewSecrets", - g_variant_new("(@a{sa{sv}})", dict), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) plugin_new_secrets_cb, - self); - } else { - _LOGD("asking service if additional secrets are required"); - - /* Ask the VPN service if more secrets are required */ - g_dbus_proxy_call(priv->proxy, - "NeedSecrets", - g_variant_new("(@a{sa{sv}})", dict), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) plugin_need_secrets_cb, - self); - } -} - -static void -get_secrets(NMVpnConnection *self, SecretsReq secrets_idx, const char *const *hints) -{ - NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; - - g_return_if_fail(secrets_idx < SECRETS_REQ_LAST); - priv->secrets_idx = secrets_idx; - - cancel_get_secrets(self); - - _LOGD("requesting VPN secrets pass #%d", priv->secrets_idx + 1); - - switch (priv->secrets_idx) { - case SECRETS_REQ_SYSTEM: - flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM; - break; - case SECRETS_REQ_EXISTING: - flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; - break; - case SECRETS_REQ_NEW: - case SECRETS_REQ_INTERACTIVE: - flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; - break; - default: - g_assert_not_reached(); - } - - if (nm_active_connection_get_user_requested(NM_ACTIVE_CONNECTION(self))) - flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED; - - priv->secrets_id = nm_settings_connection_get_secrets( - _get_settings_connection(self, FALSE), - _get_applied_connection(self), - nm_active_connection_get_subject(NM_ACTIVE_CONNECTION(self)), - NM_SETTING_VPN_SETTING_NAME, - flags, - hints, - get_secrets_cb, - self); - g_return_if_fail(priv->secrets_id); -} - -static void -plugin_interactive_secrets_required(NMVpnConnection * self, - const char * message, - const char *const *secrets) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - const gsize secrets_len = NM_PTRARRAY_LEN(secrets); - gsize i; - gs_free const char ** hints = NULL; - gs_free char * message_hint = NULL; - - if (!NM_IN_SET(priv->vpn_state, STATE_CONNECT, STATE_NEED_AUTH)) { - _LOGD("VPN plugin: requested secrets; state %s (%d); ignore request in current state", - vpn_state_to_string_a(priv->vpn_state), - priv->vpn_state); - return; - } - - _LOGI("VPN plugin: requested secrets; state %s (%d)", - vpn_state_to_string_a(priv->vpn_state), - priv->vpn_state); - - priv->secrets_idx = SECRETS_REQ_INTERACTIVE; - _set_vpn_state(self, STATE_NEED_AUTH, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); - - /* Copy hints and add message to the end */ - hints = g_new(const char *, secrets_len + 2); - for (i = 0; i < secrets_len; i++) - hints[i] = secrets[i]; - if (message) { - message_hint = g_strdup_printf("x-vpn-message:%s", message); - hints[i++] = message_hint; - } - hints[i] = NULL; - nm_assert(i < secrets_len + 2); - - get_secrets(self, SECRETS_REQ_INTERACTIVE, hints); -} - /*****************************************************************************/ static void device_changed(NMActiveConnection *active, NMDevice *new_device, NMDevice *old_device) { - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(active); + NMVpnConnection * self = NM_VPN_CONNECTION(active); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(active); + gs_unref_object NML3Cfg *l3cfg_old = NULL; + int ifindex; - if (!_service_and_connection_can_persist(NM_VPN_CONNECTION(active))) + if (!priv->generic_config_received) return; - if (priv->vpn_state < STATE_CONNECT || priv->vpn_state > STATE_ACTIVATED) + if (priv->vpn_state > STATE_ACTIVATED) + return; + if (!_service_and_connection_can_persist(self)) return; - /* Route-based VPNs must update their routing and send a new IP config - * since all their routes need to be adjusted for new_device. - */ - if (priv->ip_ifindex <= 0) + if (priv->ifindex_if <= 0) { + /* Route-based VPNs must updvate their routing and send a new IP config + * since all their routes need to be adjusted for new_device. + */ + return; + } + + ifindex = _get_ifindex_for_device(self); + if (ifindex <= 0) + return; + if (priv->ifindex_dev == ifindex) return; - /* Device changed underneath the VPN connection. Let the plugin figure - * out that connectivity is down and start its reconnect attempt if it - * needs to. - */ - if (old_device) - remove_parent_device_config(NM_VPN_CONNECTION(active), old_device); + _LOGD("set ip-ifindex-dev %d (was %d)", ifindex, priv->ifindex_dev); - if (new_device) - apply_parent_device_config(NM_VPN_CONNECTION(active)); + l3cfg_old = g_steal_pointer(&priv->l3cfg_dev); + nm_l3cfg_commit_type_clear(l3cfg_old, &priv->l3cfg_commit_type_dev); + _l3cfg_clear(self, l3cfg_old); + + priv->ifindex_dev = ifindex; + if (ifindex > 0) { + priv->l3cfg_dev = nm_netns_l3cfg_acquire(priv->netns, ifindex); + g_signal_connect(priv->l3cfg_dev, + NM_L3CFG_SIGNAL_NOTIFY, + G_CALLBACK(_l3cfg_notify_cb), + self); + priv->l3cfg_commit_type_dev = nm_l3cfg_commit_type_register(priv->l3cfg_dev, + NM_L3_CFG_COMMIT_TYPE_UPDATE, + NULL, + "vpn"); + } + + if (_l3cfg_l3cd_gw_extern_update(self)) + nm_l3cfg_commit_on_idle_schedule(priv->l3cfg_dev, NM_L3_CFG_COMMIT_TYPE_AUTO); +} + +/*****************************************************************************/ + +static void +get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + NMVpnConnection * self = NM_VPN_CONNECTION(object); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + + switch (prop_id) { + case PROP_VPN_STATE: + g_value_set_uint(value, _state_to_nm_vpn_state(priv->vpn_state)); + break; + case PROP_BANNER: + g_value_set_string(value, priv->banner ?: ""); + break; + case PROP_IP4_CONFIG: + nm_dbus_utils_g_value_set_object_path(value, priv->ip_data_4.ip_config); + break; + case PROP_IP6_CONFIG: + nm_dbus_utils_g_value_set_object_path(value, priv->ip_data_6.ip_config); + break; + case PROP_MASTER: + nm_dbus_utils_g_value_set_object_path( + value, + nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self))); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } } /*****************************************************************************/ @@ -2808,35 +2904,69 @@ nm_vpn_connection_init(NMVpnConnection *self) priv->netns = g_object_ref(nm_netns_get()); } +NMVpnConnection * +nm_vpn_connection_new(NMSettingsConnection * settings_connection, + NMDevice * parent_device, + const char * specific_object, + NMActivationReason activation_reason, + NMActivationStateFlags initial_state_flags, + NMAuthSubject * subject) +{ + g_return_val_if_fail(!settings_connection || NM_IS_SETTINGS_CONNECTION(settings_connection), + NULL); + g_return_val_if_fail(NM_IS_DEVICE(parent_device), NULL); + g_return_val_if_fail(specific_object, NULL); + + return g_object_new(NM_TYPE_VPN_CONNECTION, + NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, + settings_connection, + NM_ACTIVE_CONNECTION_INT_DEVICE, + parent_device, + NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, + specific_object, + NM_ACTIVE_CONNECTION_INT_SUBJECT, + subject, + NM_ACTIVE_CONNECTION_INT_ACTIVATION_REASON, + activation_reason, + NM_ACTIVE_CONNECTION_VPN, + TRUE, + NM_ACTIVE_CONNECTION_STATE_FLAGS, + (guint) initial_state_flags, + NULL); +} + static void dispose(GObject *object) { NMVpnConnection * self = NM_VPN_CONNECTION(object); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - if (priv->proxy) - g_signal_handlers_disconnect_by_data(priv->proxy, self); + nm_clear_g_dbus_connection_signal(priv->dbus.connection, &priv->dbus.signal_id_vpn); + nm_clear_g_dbus_connection_signal(priv->dbus.connection, &priv->dbus.signal_id_name_changed); - nm_clear_g_source(&priv->start_timeout); + nm_clear_g_source_inst(&priv->init_fail_on_idle_source); + + nm_clear_g_cancellable(&priv->main_cancellable); + + nm_clear_g_source_inst(&priv->start_timeout_source); nm_clear_pointer(&priv->connect_hash, g_variant_unref); - nm_clear_pointer(&priv->ip4_dev_route_blacklist, g_ptr_array_unref); + nm_clear_g_source_inst(&priv->connect_timeout_source); - nm_clear_g_source(&priv->connect_timeout); + if (nm_l3cfg_commit_type_clear(priv->l3cfg_if, &priv->l3cfg_commit_type_if)) + nm_l3cfg_commit_on_idle_schedule(priv->l3cfg_if, NM_L3_CFG_COMMIT_TYPE_AUTO); + + if (nm_l3cfg_commit_type_clear(priv->l3cfg_dev, &priv->l3cfg_commit_type_dev)) + nm_l3cfg_commit_on_idle_schedule(priv->l3cfg_dev, NM_L3_CFG_COMMIT_TYPE_AUTO); + + g_clear_object(&priv->ip_data_4.ip_config); + g_clear_object(&priv->ip_data_6.ip_config); dispatcher_cleanup(self); cancel_get_secrets(self); - nm_clear_g_cancellable(&priv->cancellable); - - g_clear_object(&priv->proxy_config); - nm_dbus_object_clear_and_unexport(&priv->ip4_config); - nm_dbus_object_clear_and_unexport(&priv->ip6_config); - g_clear_object(&priv->proxy); - g_clear_object(&priv->plugin_info); - fw_call_cleanup(self); nm_pacrunner_manager_remove_clear(&priv->pacrunner_conf_id); @@ -2847,56 +2977,24 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(object); - - g_free(priv->banner); - g_free(priv->ip_iface); - g_free(priv->username); - g_free(priv->ip6_internal_gw); - g_free(priv->ip6_external_gw); + NMVpnConnection * self = NM_VPN_CONNECTION(object); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); G_OBJECT_CLASS(nm_vpn_connection_parent_class)->finalize(object); + g_free(priv->banner); + g_free(priv->username); + g_free(priv->dbus.bus_name); + + _l3cfg_l3cd_clear_all(self); + _l3cfg_clear(self, priv->l3cfg_if); + _l3cfg_clear(self, priv->l3cfg_dev); + + g_clear_object(&priv->plugin_info); + g_clear_object(&priv->l3cfg_if); + g_clear_object(&priv->l3cfg_dev); g_clear_object(&priv->netns); -} - -static gboolean -ip_config_valid(VpnState state) -{ - return (state == STATE_PRE_UP || state == STATE_ACTIVATED); -} - -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(object); - NMDevice * parent_dev; - - switch (prop_id) { - case PROP_VPN_STATE: - g_value_set_uint(value, _state_to_nm_vpn_state(priv->vpn_state)); - break; - case PROP_BANNER: - g_value_set_string(value, priv->banner ?: ""); - break; - case PROP_IP4_CONFIG: - nm_dbus_utils_g_value_set_object_path(value, - ip_config_valid(priv->vpn_state) ? priv->ip4_config - : NULL); - break; - case PROP_IP6_CONFIG: - nm_dbus_utils_g_value_set_object_path(value, - ip_config_valid(priv->vpn_state) ? priv->ip6_config - : NULL); - break; - case PROP_MASTER: - parent_dev = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(object)); - nm_dbus_utils_g_value_set_object_path(value, parent_dev); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } + g_clear_object(&priv->dbus.connection); } static const GDBusSignalInfo signal_info_vpn_state_changed = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT( @@ -2918,11 +3016,11 @@ static const NMDBusInterfaceInfoExtended interface_info_vpn_connection = { }; static void -nm_vpn_connection_class_init(NMVpnConnectionClass *connection_class) +nm_vpn_connection_class_init(NMVpnConnectionClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(connection_class); - NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS(connection_class); - NMDBusObjectClass * dbus_object_class = NM_DBUS_OBJECT_CLASS(connection_class); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS(klass); + NMDBusObjectClass * dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_vpn_connection); @@ -2957,18 +3055,19 @@ nm_vpn_connection_class_init(NMVpnConnectionClass *connection_class) PROP_IP6_CONFIG, NM_ACTIVE_CONNECTION_IP6_CONFIG); - signals[INTERNAL_STATE_CHANGED] = g_signal_new(NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 3, - G_TYPE_UINT, - G_TYPE_UINT, - G_TYPE_UINT); + signals[INTERNAL_STATE_CHANGED] = + g_signal_new(NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED, + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 3, + G_TYPE_UINT, /* NMVpnConnectionState new_external_state */ + G_TYPE_UINT, /* NMVpnConnectionState old_external_state */ + G_TYPE_UINT /* NMActiveConnectionStateReason reason */); signals[INTERNAL_RETRY_AFTER_FAILURE] = g_signal_new(NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE, diff --git a/src/core/vpn/nm-vpn-connection.h b/src/core/vpn/nm-vpn-connection.h index 0209ea3d60..df575c47f4 100644 --- a/src/core/vpn/nm-vpn-connection.h +++ b/src/core/vpn/nm-vpn-connection.h @@ -54,16 +54,13 @@ void nm_vpn_connection_disconnect(NMVpnConnection * self, NMActiveConnectionStateReason reason, gboolean quitting); -NMProxyConfig *nm_vpn_connection_get_proxy_config(NMVpnConnection *self); +const NML3ConfigData *nm_vpn_connection_get_l3cd(NMVpnConnection *self); -NMIP4Config * nm_vpn_connection_get_ip4_config(NMVpnConnection *self); -NMIP6Config * nm_vpn_connection_get_ip6_config(NMVpnConnection *self); const char * nm_vpn_connection_get_ip_iface(NMVpnConnection *self, gboolean fallback_device); int nm_vpn_connection_get_ip_ifindex(NMVpnConnection *self, gboolean fallback_device); guint32 nm_vpn_connection_get_ip4_internal_gateway(NMVpnConnection *self); struct in6_addr *nm_vpn_connection_get_ip6_internal_gateway(NMVpnConnection *self); -guint32 nm_vpn_connection_get_ip4_route_metric(NMVpnConnection *self); -guint32 nm_vpn_connection_get_ip6_route_metric(NMVpnConnection *self); +guint32 nm_vpn_connection_get_ip_route_metric(NMVpnConnection *self, int addr_family); #endif /* __NM_VPN_CONNECTION_H__ */ diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 4ea545a434..867ef7b501 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -3530,7 +3530,6 @@ rta_multipath_done:; obj = nmp_object_new(is_v4 ? NMP_OBJECT_TYPE_IP4_ROUTE : NMP_OBJECT_TYPE_IP6_ROUTE, NULL); - obj->ip_route.is_external = TRUE; obj->ip_route.type_coerced = nm_platform_route_type_coerce(rtm->rtm_type); obj->ip_route.table_coerced = nm_platform_route_table_coerce( tb[RTA_TABLE] ? nla_get_u32(tb[RTA_TABLE]) : (guint32) rtm->rtm_table); diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index 5d4ec037ec..ee8748c631 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -4520,12 +4520,6 @@ nm_platform_ip_route_sync(NMPlatform *self, conf_o = routes->pdata[i]; - if (NMP_OBJECT_CAST_IP_ROUTE(conf_o)->is_external) { - /* This route is added externally. We don't have our own agenda to - * add it, so skip. */ - continue; - } - /* User space cannot add IPv6 routes with metric 0. However, kernel can, and we might track such * routes in @route as they are present external. As we already skipped external routes above, * we don't expect a user's choice to add such a route (it won't work anyway). */ @@ -4721,24 +4715,6 @@ sync_route_add: } if (routes_prune) { - if (routes) { - for (i = 0; i < routes->len; i++) { - conf_o = routes->pdata[i]; - - if (NMP_OBJECT_CAST_IP_ROUTE(conf_o)->is_external) { - /* this is only to catch the case where an external route is - * both in @routes and @routes_prune list. In that case, - * @routes should win and we should not remove the address. */ - if (!routes_idx) { - routes_idx = g_hash_table_new((GHashFunc) nmp_object_id_hash, - (GEqualFunc) nmp_object_id_equal); - } - g_hash_table_add(routes_idx, (gpointer) conf_o); - continue; - } - } - } - for (i = 0; i < routes_prune->len; i++) { const NMPObject *prune_o; @@ -6273,7 +6249,6 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf "%s" /* flags */ "%s" /* label */ " src %s" - "%s" /* external */ "%s" /* a_acd_not_ready */ "%s" /* a_assume_config_once */ "", @@ -6293,7 +6268,6 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf _to_string_ifa_flags(address->n_ifa_flags, s_flags, sizeof(s_flags)), str_label, nmp_utils_ip_config_source_to_string(address->addr_source, s_source, sizeof(s_source)), - address->external ? " ext" : "", address->a_acd_not_ready ? " ip4acd-not-ready" : "", address->a_assume_config_once ? " assume-config-once" : ""); g_free(str_peer); @@ -6415,7 +6389,6 @@ nm_platform_ip6_address_to_string(const NMPlatformIP6Address *address, char *buf buf, len, "%s/%d lft %s pref %s%s%s%s%s src %s" - "%s" /* external */ "%s" /* a_assume_config_once */ "", s_address, @@ -6427,7 +6400,6 @@ nm_platform_ip6_address_to_string(const NMPlatformIP6Address *address, char *buf str_dev, _to_string_ifa_flags(address->n_ifa_flags, s_flags, sizeof(s_flags)), nmp_utils_ip_config_source_to_string(address->addr_source, s_source, sizeof(s_source)), - address->external ? " external" : "", address->a_assume_config_once ? " assume-config-once" : ""); g_free(str_peer); return buf; @@ -6519,7 +6491,6 @@ nm_platform_ip4_route_to_string(const NMPlatformIP4Route *route, char *buf, gsiz "%s" /* initcwnd */ "%s" /* initrwnd */ "%s" /* mtu */ - "%s" /* is_external */ "%s" /* r_assume_config_once */ "", nm_net_aux_rtnl_rtntype_n2a_maybe_buf(nm_platform_route_type_uncoerce(route->type_coerced), @@ -6577,7 +6548,6 @@ nm_platform_ip4_route_to_string(const NMPlatformIP4Route *route, char *buf, gsiz route->lock_mtu ? "lock " : "", route->mtu) : "", - route->is_external ? " is-external" : "", route->r_assume_config_once ? " assume-config-once" : ""); return buf; } @@ -6648,7 +6618,6 @@ nm_platform_ip6_route_to_string(const NMPlatformIP6Route *route, char *buf, gsiz "%s" /* initrwnd */ "%s" /* mtu */ "%s" /* pref */ - "%s" /* is_external */ "%s" /* r_assume_config_once */ "", nm_net_aux_rtnl_rtntype_n2a_maybe_buf(nm_platform_route_type_uncoerce(route->type_coerced), @@ -6710,7 +6679,6 @@ nm_platform_ip6_route_to_string(const NMPlatformIP6Route *route, char *buf, gsiz " pref %s", nm_icmpv6_router_pref_to_string(route->rt_pref, str_pref2, sizeof(str_pref2))) : "", - route->is_external ? " is-external" : "", route->r_assume_config_once ? " assume-config-once" : ""); return buf; @@ -7845,7 +7813,6 @@ nm_platform_ip4_address_hash_update(const NMPlatformIP4Address *obj, NMHashState obj->address, obj->peer_address, NM_HASH_COMBINE_BOOLS(guint8, - obj->external, obj->use_ip4_broadcast_address, obj->a_acd_not_ready, obj->a_assume_config_once)); @@ -7869,7 +7836,6 @@ nm_platform_ip4_address_cmp(const NMPlatformIP4Address *a, const NMPlatformIP4Ad NM_CMP_FIELD(a, b, preferred); NM_CMP_FIELD(a, b, n_ifa_flags); NM_CMP_FIELD_STR(a, b, label); - NM_CMP_FIELD_UNSAFE(a, b, external); NM_CMP_FIELD_UNSAFE(a, b, a_acd_not_ready); NM_CMP_FIELD_UNSAFE(a, b, a_assume_config_once); return 0; @@ -7888,7 +7854,7 @@ nm_platform_ip6_address_hash_update(const NMPlatformIP6Address *obj, NMHashState obj->plen, obj->address, obj->peer_address, - NM_HASH_COMBINE_BOOLS(guint8, obj->external, obj->a_assume_config_once)); + NM_HASH_COMBINE_BOOLS(guint8, obj->a_assume_config_once)); } int @@ -7908,7 +7874,6 @@ nm_platform_ip6_address_cmp(const NMPlatformIP6Address *a, const NMPlatformIP6Ad NM_CMP_FIELD(a, b, lifetime); NM_CMP_FIELD(a, b, preferred); NM_CMP_FIELD(a, b, n_ifa_flags); - NM_CMP_FIELD_UNSAFE(a, b, external); NM_CMP_FIELD_UNSAFE(a, b, a_assume_config_once); return 0; } @@ -8018,7 +7983,6 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj, obj->lock_initcwnd, obj->lock_initrwnd, obj->lock_mtu, - obj->is_external, obj->r_assume_config_once)); break; } @@ -8110,7 +8074,6 @@ nm_platform_ip4_route_cmp(const NMPlatformIP4Route *a, NM_CMP_FIELD(a, b, initrwnd); NM_CMP_FIELD(a, b, mtu); if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) { - NM_CMP_FIELD_UNSAFE(a, b, is_external); NM_CMP_FIELD_UNSAFE(a, b, r_assume_config_once); } break; @@ -8205,7 +8168,6 @@ nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj, obj->lock_initcwnd, obj->lock_initrwnd, obj->lock_mtu, - obj->is_external, obj->r_assume_config_once), obj->window, obj->cwnd, @@ -8290,7 +8252,6 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a, else NM_CMP_FIELD(a, b, rt_pref); if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) { - NM_CMP_FIELD_UNSAFE(a, b, is_external); NM_CMP_FIELD_UNSAFE(a, b, r_assume_config_once); } break; diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 7101b48c4f..d3d8ae3070 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -318,10 +318,6 @@ typedef enum { * IFA_FLAGS attribute. */ \ guint32 n_ifa_flags; \ \ - /* FIXME(l3cfg): the external marker won't be necessary anymore, because we only - * merge addresses we care about, and ignore (don't remove) external addresses. */ \ - bool external : 1; \ - \ bool use_ip4_broadcast_address : 1; \ \ /* Whether the address is should be configured once during assume. This is a meta flag @@ -471,14 +467,6 @@ typedef union { * the "table_coerced" field is ignored (unlike for the metric). */ \ bool table_any : 1; \ \ - /* This route is tracked as external route, that is not a route that NetworkManager - * actively wants to add, but a route that was added externally. In some cases, such - * a route should be ignored. - * - * Note that unlike most other fields here, this flag only exists inside NetworkManager - * and is not reflected on netlink. */ \ - bool is_external : 1; \ - \ /* Whether the route is should be configured once during assume. This is a meta flag * that is not honored by NMPlatform (netlink code). Instead, it can be used by the upper * layers which use NMPlatformIPRoute to track routes that should be configured. */ \ diff --git a/src/libnm-systemd-core/meson.build b/src/libnm-systemd-core/meson.build index fb472a7654..1fa9448645 100644 --- a/src/libnm-systemd-core/meson.build +++ b/src/libnm-systemd-core/meson.build @@ -18,8 +18,6 @@ libnm_systemd_core = static_library( 'src/libsystemd-network/sd-dhcp-lease.c', 'src/libsystemd-network/sd-dhcp6-client.c', 'src/libsystemd-network/sd-dhcp6-lease.c', - 'src/libsystemd-network/sd-ipv4acd.c', - 'src/libsystemd-network/sd-ipv4ll.c', 'src/libsystemd-network/sd-lldp-rx.c', 'src/libsystemd/sd-event/event-util.c', 'src/libsystemd/sd-event/sd-event.c', diff --git a/src/libnm-systemd-core/nm-sd.h b/src/libnm-systemd-core/nm-sd.h index 0ec2f16e5d..421f53729b 100644 --- a/src/libnm-systemd-core/nm-sd.h +++ b/src/libnm-systemd-core/nm-sd.h @@ -8,9 +8,7 @@ #include "src/systemd/sd-dhcp-client.h" #include "src/systemd/sd-dhcp6-client.h" -#include "src/systemd/sd-ipv4ll.h" #include "src/systemd/sd-lldp-rx.h" -#include "src/systemd/sd-lldp.h" /*****************************************************************************/ diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c b/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c deleted file mode 100644 index f0612ed583..0000000000 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c +++ /dev/null @@ -1,616 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/*** - Copyright © 2014 Axis Communications AB. All rights reserved. -***/ - -#include "nm-sd-adapt-core.h" - -#include -#include -#include -#include -#include - -#include "sd-ipv4acd.h" - -#include "alloc-util.h" -#include "arp-util.h" -#include "ether-addr-util.h" -#include "event-util.h" -#include "fd-util.h" -#include "in-addr-util.h" -#include "memory-util.h" -#include "network-common.h" -#include "random-util.h" -#include "siphash24.h" -#include "string-table.h" -#include "string-util.h" -#include "time-util.h" - -/* Constants from the RFC */ -#define PROBE_WAIT_USEC (1U * USEC_PER_SEC) -#define PROBE_NUM 3U -#define PROBE_MIN_USEC (1U * USEC_PER_SEC) -#define PROBE_MAX_USEC (2U * USEC_PER_SEC) -#define ANNOUNCE_WAIT_USEC (2U * USEC_PER_SEC) -#define ANNOUNCE_NUM 2U -#define ANNOUNCE_INTERVAL_USEC (2U * USEC_PER_SEC) -#define MAX_CONFLICTS 10U -#define RATE_LIMIT_INTERVAL_USEC (60U * USEC_PER_SEC) -#define DEFEND_INTERVAL_USEC (10U * USEC_PER_SEC) - -typedef enum IPv4ACDState { - IPV4ACD_STATE_INIT, - IPV4ACD_STATE_STARTED, - IPV4ACD_STATE_WAITING_PROBE, - IPV4ACD_STATE_PROBING, - IPV4ACD_STATE_WAITING_ANNOUNCE, - IPV4ACD_STATE_ANNOUNCING, - IPV4ACD_STATE_RUNNING, - _IPV4ACD_STATE_MAX, - _IPV4ACD_STATE_INVALID = -EINVAL, -} IPv4ACDState; - -struct sd_ipv4acd { - unsigned n_ref; - - IPv4ACDState state; - int ifindex; - int fd; - - char *ifname; - unsigned n_iteration; - unsigned n_conflict; - - sd_event_source *receive_message_event_source; - sd_event_source *timer_event_source; - - usec_t defend_window; - struct in_addr address; - - /* External */ - struct ether_addr mac_addr; - - sd_event *event; - int event_priority; - sd_ipv4acd_callback_t callback; - void *userdata; - sd_ipv4acd_check_mac_callback_t check_mac_callback; - void *check_mac_userdata; -}; - -#define log_ipv4acd_errno(acd, error, fmt, ...) \ - log_interface_prefix_full_errno( \ - "IPv4ACD: ", \ - sd_ipv4acd, acd, \ - error, fmt, ##__VA_ARGS__) -#define log_ipv4acd(acd, fmt, ...) \ - log_interface_prefix_full_errno_zerook( \ - "IPv4ACD: ", \ - sd_ipv4acd, acd, \ - 0, fmt, ##__VA_ARGS__) - -static const char * const ipv4acd_state_table[_IPV4ACD_STATE_MAX] = { - [IPV4ACD_STATE_INIT] = "init", - [IPV4ACD_STATE_STARTED] = "started", - [IPV4ACD_STATE_WAITING_PROBE] = "waiting-probe", - [IPV4ACD_STATE_PROBING] = "probing", - [IPV4ACD_STATE_WAITING_ANNOUNCE] = "waiting-announce", - [IPV4ACD_STATE_ANNOUNCING] = "announcing", - [IPV4ACD_STATE_RUNNING] = "running", -}; - -DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(ipv4acd_state, IPv4ACDState); - -static void ipv4acd_set_state(sd_ipv4acd *acd, IPv4ACDState st, bool reset_counter) { - assert(acd); - assert(st < _IPV4ACD_STATE_MAX); - - if (st != acd->state) - log_ipv4acd(acd, "%s -> %s", ipv4acd_state_to_string(acd->state), ipv4acd_state_to_string(st)); - - if (st == acd->state && !reset_counter) - acd->n_iteration++; - else { - acd->state = st; - acd->n_iteration = 0; - } -} - -static void ipv4acd_reset(sd_ipv4acd *acd) { - assert(acd); - - (void) event_source_disable(acd->timer_event_source); - acd->receive_message_event_source = sd_event_source_disable_unref(acd->receive_message_event_source); - - acd->fd = safe_close(acd->fd); - - ipv4acd_set_state(acd, IPV4ACD_STATE_INIT, true); -} - -static sd_ipv4acd *ipv4acd_free(sd_ipv4acd *acd) { - assert(acd); - - ipv4acd_reset(acd); - sd_event_source_unref(acd->timer_event_source); - sd_ipv4acd_detach_event(acd); - free(acd->ifname); - return mfree(acd); -} - -DEFINE_TRIVIAL_REF_UNREF_FUNC(sd_ipv4acd, sd_ipv4acd, ipv4acd_free); - -int sd_ipv4acd_new(sd_ipv4acd **ret) { - _cleanup_(sd_ipv4acd_unrefp) sd_ipv4acd *acd = NULL; - - assert_return(ret, -EINVAL); - - acd = new(sd_ipv4acd, 1); - if (!acd) - return -ENOMEM; - - *acd = (sd_ipv4acd) { - .n_ref = 1, - .state = IPV4ACD_STATE_INIT, - .ifindex = -1, - .fd = -1, - }; - - *ret = TAKE_PTR(acd); - - return 0; -} - -static void ipv4acd_client_notify(sd_ipv4acd *acd, int event) { - assert(acd); - - if (!acd->callback) - return; - - acd->callback(acd, event, acd->userdata); -} - -int sd_ipv4acd_stop(sd_ipv4acd *acd) { - IPv4ACDState old_state; - - if (!acd) - return 0; - - old_state = acd->state; - - ipv4acd_reset(acd); - - if (old_state == IPV4ACD_STATE_INIT) - return 0; - - log_ipv4acd(acd, "STOPPED"); - - ipv4acd_client_notify(acd, SD_IPV4ACD_EVENT_STOP); - - return 0; -} - -static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata); - -static int ipv4acd_set_next_wakeup(sd_ipv4acd *acd, usec_t usec, usec_t random_usec) { - usec_t next_timeout, time_now; - - assert(acd); - - next_timeout = usec; - - if (random_usec > 0) - next_timeout += (usec_t) random_u64() % random_usec; - - assert_se(sd_event_now(acd->event, clock_boottime_or_monotonic(), &time_now) >= 0); - - return event_reset_time(acd->event, &acd->timer_event_source, - clock_boottime_or_monotonic(), - time_now + next_timeout, 0, - ipv4acd_on_timeout, acd, - acd->event_priority, "ipv4acd-timer", true); -} - -static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata) { - sd_ipv4acd *acd = userdata; - int r = 0; - - assert(acd); - - switch (acd->state) { - - case IPV4ACD_STATE_STARTED: - acd->defend_window = 0; - - ipv4acd_set_state(acd, IPV4ACD_STATE_WAITING_PROBE, true); - - if (acd->n_conflict >= MAX_CONFLICTS) { - log_ipv4acd(acd, "Max conflicts reached, delaying by %s", - FORMAT_TIMESPAN(RATE_LIMIT_INTERVAL_USEC, 0)); - r = ipv4acd_set_next_wakeup(acd, RATE_LIMIT_INTERVAL_USEC, PROBE_WAIT_USEC); - } else - r = ipv4acd_set_next_wakeup(acd, 0, PROBE_WAIT_USEC); - if (r < 0) - goto fail; - - break; - - case IPV4ACD_STATE_WAITING_PROBE: - case IPV4ACD_STATE_PROBING: - /* Send a probe */ - r = arp_send_probe(acd->fd, acd->ifindex, &acd->address, &acd->mac_addr); - if (r < 0) { - log_ipv4acd_errno(acd, r, "Failed to send ARP probe: %m"); - goto fail; - } - - log_ipv4acd(acd, "Probing "IPV4_ADDRESS_FMT_STR, IPV4_ADDRESS_FMT_VAL(acd->address)); - - if (acd->n_iteration < PROBE_NUM - 2) { - ipv4acd_set_state(acd, IPV4ACD_STATE_PROBING, false); - - r = ipv4acd_set_next_wakeup(acd, PROBE_MIN_USEC, (PROBE_MAX_USEC-PROBE_MIN_USEC)); - if (r < 0) - goto fail; - } else { - ipv4acd_set_state(acd, IPV4ACD_STATE_WAITING_ANNOUNCE, true); - - r = ipv4acd_set_next_wakeup(acd, ANNOUNCE_WAIT_USEC, 0); - if (r < 0) - goto fail; - } - - break; - - case IPV4ACD_STATE_ANNOUNCING: - if (acd->n_iteration >= ANNOUNCE_NUM - 1) { - ipv4acd_set_state(acd, IPV4ACD_STATE_RUNNING, false); - break; - } - - _fallthrough_; - case IPV4ACD_STATE_WAITING_ANNOUNCE: - /* Send announcement packet */ - r = arp_send_announcement(acd->fd, acd->ifindex, &acd->address, &acd->mac_addr); - if (r < 0) { - log_ipv4acd_errno(acd, r, "Failed to send ARP announcement: %m"); - goto fail; - } - - log_ipv4acd(acd, "Announcing "IPV4_ADDRESS_FMT_STR, IPV4_ADDRESS_FMT_VAL(acd->address)); - - ipv4acd_set_state(acd, IPV4ACD_STATE_ANNOUNCING, false); - - r = ipv4acd_set_next_wakeup(acd, ANNOUNCE_INTERVAL_USEC, 0); - if (r < 0) - goto fail; - - if (acd->n_iteration == 0) { - acd->n_conflict = 0; - ipv4acd_client_notify(acd, SD_IPV4ACD_EVENT_BIND); - } - - break; - - default: - assert_not_reached(); - } - - return 0; - -fail: - sd_ipv4acd_stop(acd); - return 0; -} - -static bool ipv4acd_arp_conflict(sd_ipv4acd *acd, const struct ether_arp *arp, bool announced) { - assert(acd); - assert(arp); - - /* RFC 5227 section 2.1.1. - * "the host receives any ARP packet (Request *or* Reply) on the interface where the probe is - * being performed, where the packet's 'sender IP address' is the address being probed for, - * then the host MUST treat this address as being in use by some other host" */ - if (memcmp(arp->arp_spa, &acd->address, sizeof(struct in_addr)) == 0) - return true; - - if (announced) - /* the TPA matched instead of SPA, this is not a conflict */ - return false; - - /* "any ARP Probe where the packet's 'target IP address' is the address being probed for, and - * the packet's 'sender hardware address' is not the hardware address of any of the host's - * interfaces, then the host SHOULD similarly treat this as an address conflict" */ - if (arp->ea_hdr.ar_op != htobe16(ARPOP_REQUEST)) - return false; /* not ARP Request, ignoring. */ - if (memeqzero(arp->arp_spa, sizeof(struct in_addr)) == 0) - return false; /* not ARP Probe, ignoring. */ - if (memcmp(arp->arp_tpa, &acd->address, sizeof(struct in_addr)) != 0) - return false; /* target IP address does not match, BPF code is broken? */ - - if (acd->check_mac_callback && - acd->check_mac_callback(acd, (const struct ether_addr*) arp->arp_sha, acd->check_mac_userdata) > 0) - /* sender hardware is one of the host's interfaces, ignoring. */ - return true; - - return true; /* conflict! */ -} - -static void ipv4acd_on_conflict(sd_ipv4acd *acd) { - assert(acd); - - acd->n_conflict++; - - log_ipv4acd(acd, "Conflict on "IPV4_ADDRESS_FMT_STR" (%u)", IPV4_ADDRESS_FMT_VAL(acd->address), acd->n_conflict); - - ipv4acd_reset(acd); - ipv4acd_client_notify(acd, SD_IPV4ACD_EVENT_CONFLICT); -} - -static int ipv4acd_on_packet( - sd_event_source *s, - int fd, - uint32_t revents, - void *userdata) { - - sd_ipv4acd *acd = userdata; - struct ether_arp packet; - ssize_t n; - int r; - - assert(s); - assert(acd); - assert(fd >= 0); - - n = recv(fd, &packet, sizeof(struct ether_arp), 0); - if (n < 0) { - if (IN_SET(errno, EAGAIN, EINTR)) - return 0; - - log_ipv4acd_errno(acd, errno, "Failed to read ARP packet: %m"); - goto fail; - } - if ((size_t) n != sizeof(struct ether_arp)) { - log_ipv4acd(acd, "Ignoring too short ARP packet."); - return 0; - } - - switch (acd->state) { - - case IPV4ACD_STATE_ANNOUNCING: - case IPV4ACD_STATE_RUNNING: - - if (ipv4acd_arp_conflict(acd, &packet, true)) { - usec_t ts; - - assert_se(sd_event_now(acd->event, clock_boottime_or_monotonic(), &ts) >= 0); - - /* Defend address */ - if (ts > acd->defend_window) { - acd->defend_window = ts + DEFEND_INTERVAL_USEC; - r = arp_send_announcement(acd->fd, acd->ifindex, &acd->address, &acd->mac_addr); - if (r < 0) { - log_ipv4acd_errno(acd, r, "Failed to send ARP announcement: %m"); - goto fail; - } - - log_ipv4acd(acd, "Defending "IPV4_ADDRESS_FMT_STR, IPV4_ADDRESS_FMT_VAL(acd->address)); - - } else - ipv4acd_on_conflict(acd); - } - break; - - case IPV4ACD_STATE_WAITING_PROBE: - case IPV4ACD_STATE_PROBING: - case IPV4ACD_STATE_WAITING_ANNOUNCE: - if (ipv4acd_arp_conflict(acd, &packet, false)) - ipv4acd_on_conflict(acd); - break; - - default: - assert_not_reached(); - } - - return 0; - -fail: - sd_ipv4acd_stop(acd); - return 0; -} - -int sd_ipv4acd_set_ifindex(sd_ipv4acd *acd, int ifindex) { - assert_return(acd, -EINVAL); - assert_return(ifindex > 0, -EINVAL); - assert_return(acd->state == IPV4ACD_STATE_INIT, -EBUSY); - - acd->ifindex = ifindex; - - return 0; -} - -int sd_ipv4acd_get_ifindex(sd_ipv4acd *acd) { - if (!acd) - return -EINVAL; - - return acd->ifindex; -} - -int sd_ipv4acd_set_ifname(sd_ipv4acd *acd, const char *ifname) { - assert_return(acd, -EINVAL); - assert_return(ifname, -EINVAL); - - if (!ifname_valid_full(ifname, IFNAME_VALID_ALTERNATIVE)) - return -EINVAL; - - return free_and_strdup(&acd->ifname, ifname); -} - -int sd_ipv4acd_get_ifname(sd_ipv4acd *acd, const char **ret) { - int r; - - assert_return(acd, -EINVAL); - - r = get_ifname(acd->ifindex, &acd->ifname); - if (r < 0) - return r; - - if (ret) - *ret = acd->ifname; - - return 0; -} - -int sd_ipv4acd_set_mac(sd_ipv4acd *acd, const struct ether_addr *addr) { - int r; - - assert_return(acd, -EINVAL); - assert_return(addr, -EINVAL); - assert_return(!ether_addr_is_null(addr), -EINVAL); - - acd->mac_addr = *addr; - - if (!sd_ipv4acd_is_running(acd)) - return 0; - - assert(acd->fd >= 0); - r = arp_update_filter(acd->fd, &acd->address, &acd->mac_addr); - if (r < 0) { - ipv4acd_reset(acd); - return r; - } - - return 0; -} - -int sd_ipv4acd_detach_event(sd_ipv4acd *acd) { - assert_return(acd, -EINVAL); - - acd->event = sd_event_unref(acd->event); - - return 0; -} - -int sd_ipv4acd_attach_event(sd_ipv4acd *acd, sd_event *event, int64_t priority) { - int r; - - assert_return(acd, -EINVAL); - assert_return(!acd->event, -EBUSY); - - if (event) - acd->event = sd_event_ref(event); - else { - r = sd_event_default(&acd->event); - if (r < 0) - return r; - } - - acd->event_priority = priority; - - return 0; -} - -int sd_ipv4acd_set_callback(sd_ipv4acd *acd, sd_ipv4acd_callback_t cb, void *userdata) { - assert_return(acd, -EINVAL); - - acd->callback = cb; - acd->userdata = userdata; - - return 0; -} - -int sd_ipv4acd_set_check_mac_callback(sd_ipv4acd *acd, sd_ipv4acd_check_mac_callback_t cb, void *userdata) { - assert_return(acd, -EINVAL); - - acd->check_mac_callback = cb; - acd->check_mac_userdata = userdata; - return 0; -} - -int sd_ipv4acd_set_address(sd_ipv4acd *acd, const struct in_addr *address) { - int r; - - assert_return(acd, -EINVAL); - assert_return(address, -EINVAL); - assert_return(in4_addr_is_set(address), -EINVAL); - - if (in4_addr_equal(&acd->address, address)) - return 0; - - acd->address = *address; - - if (!sd_ipv4acd_is_running(acd)) - return 0; - - assert(acd->fd >= 0); - r = arp_update_filter(acd->fd, &acd->address, &acd->mac_addr); - if (r < 0) - goto fail; - - r = ipv4acd_set_next_wakeup(acd, 0, 0); - if (r < 0) - goto fail; - - ipv4acd_set_state(acd, IPV4ACD_STATE_STARTED, true); - return 0; - -fail: - ipv4acd_reset(acd); - return r; -} - -int sd_ipv4acd_get_address(sd_ipv4acd *acd, struct in_addr *address) { - assert_return(acd, -EINVAL); - assert_return(address, -EINVAL); - - *address = acd->address; - - return 0; -} - -int sd_ipv4acd_is_running(sd_ipv4acd *acd) { - assert_return(acd, false); - - return acd->state != IPV4ACD_STATE_INIT; -} - -int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts) { - int r; - - assert_return(acd, -EINVAL); - assert_return(acd->event, -EINVAL); - assert_return(acd->ifindex > 0, -EINVAL); - assert_return(in4_addr_is_set(&acd->address), -EINVAL); - assert_return(!ether_addr_is_null(&acd->mac_addr), -EINVAL); - assert_return(acd->state == IPV4ACD_STATE_INIT, -EBUSY); - - r = arp_network_bind_raw_socket(acd->ifindex, &acd->address, &acd->mac_addr); - if (r < 0) - return r; - - CLOSE_AND_REPLACE(acd->fd, r); - - if (reset_conflicts) - acd->n_conflict = 0; - - r = sd_event_add_io(acd->event, &acd->receive_message_event_source, acd->fd, EPOLLIN, ipv4acd_on_packet, acd); - if (r < 0) - goto fail; - - r = sd_event_source_set_priority(acd->receive_message_event_source, acd->event_priority); - if (r < 0) - goto fail; - - (void) sd_event_source_set_description(acd->receive_message_event_source, "ipv4acd-receive-message"); - - r = ipv4acd_set_next_wakeup(acd, 0, 0); - if (r < 0) - goto fail; - - ipv4acd_set_state(acd, IPV4ACD_STATE_STARTED, true); - return 0; - -fail: - ipv4acd_reset(acd); - return r; -} diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c b/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c deleted file mode 100644 index 4a500dfc2a..0000000000 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c +++ /dev/null @@ -1,382 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/*** - Copyright © 2014 Axis Communications AB. All rights reserved. -***/ - -#include "nm-sd-adapt-core.h" - -#include -#include -#include -#include - -#include "sd-id128.h" -#include "sd-ipv4acd.h" -#include "sd-ipv4ll.h" - -#include "alloc-util.h" -#include "ether-addr-util.h" -#include "in-addr-util.h" -#include "network-common.h" -#include "random-util.h" -#include "siphash24.h" -#include "sparse-endian.h" -#include "string-util.h" -#include "util.h" - -#define IPV4LL_NETWORK UINT32_C(0xA9FE0000) -#define IPV4LL_NETMASK UINT32_C(0xFFFF0000) - -#define IPV4LL_DONT_DESTROY(ll) \ - _cleanup_(sd_ipv4ll_unrefp) _unused_ sd_ipv4ll *_dont_destroy_##ll = sd_ipv4ll_ref(ll) - -struct sd_ipv4ll { - unsigned n_ref; - - sd_ipv4acd *acd; - - be32_t address; /* the address pushed to ACD */ - struct ether_addr mac; - - struct { - le64_t value; - le64_t generation; - } seed; - bool seed_set; - - /* External */ - be32_t claimed_address; - - sd_ipv4ll_callback_t callback; - void *userdata; - - sd_ipv4ll_check_mac_callback_t check_mac_callback; - void *check_mac_userdata; -}; - -#define log_ipv4ll_errno(ll, error, fmt, ...) \ - log_interface_prefix_full_errno( \ - "IPv4LL: ", \ - sd_ipv4ll, ll, \ - error, fmt, ##__VA_ARGS__) -#define log_ipv4ll(ll, fmt, ...) \ - log_interface_prefix_full_errno_zerook( \ - "IPv4LL: ", \ - sd_ipv4ll, ll, \ - 0, fmt, ##__VA_ARGS__) - -static void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata); -static int ipv4ll_check_mac(sd_ipv4acd *acd, const struct ether_addr *mac, void *userdata); - -static sd_ipv4ll *ipv4ll_free(sd_ipv4ll *ll) { - assert(ll); - - sd_ipv4acd_unref(ll->acd); - return mfree(ll); -} - -DEFINE_TRIVIAL_REF_UNREF_FUNC(sd_ipv4ll, sd_ipv4ll, ipv4ll_free); - -int sd_ipv4ll_new(sd_ipv4ll **ret) { - _cleanup_(sd_ipv4ll_unrefp) sd_ipv4ll *ll = NULL; - int r; - - assert_return(ret, -EINVAL); - - ll = new0(sd_ipv4ll, 1); - if (!ll) - return -ENOMEM; - - ll->n_ref = 1; - - r = sd_ipv4acd_new(&ll->acd); - if (r < 0) - return r; - - r = sd_ipv4acd_set_callback(ll->acd, ipv4ll_on_acd, ll); - if (r < 0) - return r; - - r = sd_ipv4acd_set_check_mac_callback(ll->acd, ipv4ll_check_mac, ll); - if (r < 0) - return r; - - *ret = TAKE_PTR(ll); - - return 0; -} - -int sd_ipv4ll_stop(sd_ipv4ll *ll) { - if (!ll) - return 0; - - return sd_ipv4acd_stop(ll->acd); -} - -int sd_ipv4ll_set_ifindex(sd_ipv4ll *ll, int ifindex) { - assert_return(ll, -EINVAL); - assert_return(ifindex > 0, -EINVAL); - assert_return(sd_ipv4ll_is_running(ll) == 0, -EBUSY); - - return sd_ipv4acd_set_ifindex(ll->acd, ifindex); -} - -int sd_ipv4ll_get_ifindex(sd_ipv4ll *ll) { - if (!ll) - return -EINVAL; - - return sd_ipv4acd_get_ifindex(ll->acd); -} - -int sd_ipv4ll_set_ifname(sd_ipv4ll *ll, const char *ifname) { - assert_return(ll, -EINVAL); - assert_return(ifname, -EINVAL); - - return sd_ipv4acd_set_ifname(ll->acd, ifname); -} - -int sd_ipv4ll_get_ifname(sd_ipv4ll *ll, const char **ret) { - assert_return(ll, -EINVAL); - - return sd_ipv4acd_get_ifname(ll->acd, ret); -} - -int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr) { - int r; - - assert_return(ll, -EINVAL); - assert_return(addr, -EINVAL); - assert_return(!ether_addr_is_null(addr), -EINVAL); - - r = sd_ipv4acd_set_mac(ll->acd, addr); - if (r < 0) - return r; - - ll->mac = *addr; - return 0; -} - -int sd_ipv4ll_detach_event(sd_ipv4ll *ll) { - assert_return(ll, -EINVAL); - - return sd_ipv4acd_detach_event(ll->acd); -} - -int sd_ipv4ll_attach_event(sd_ipv4ll *ll, sd_event *event, int64_t priority) { - assert_return(ll, -EINVAL); - - return sd_ipv4acd_attach_event(ll->acd, event, priority); -} - -int sd_ipv4ll_set_callback(sd_ipv4ll *ll, sd_ipv4ll_callback_t cb, void *userdata) { - assert_return(ll, -EINVAL); - - ll->callback = cb; - ll->userdata = userdata; - - return 0; -} - -int sd_ipv4ll_set_check_mac_callback(sd_ipv4ll *ll, sd_ipv4ll_check_mac_callback_t cb, void *userdata) { - assert_return(ll, -EINVAL); - - ll->check_mac_callback = cb; - ll->check_mac_userdata = userdata; - - return 0; -} - -int sd_ipv4ll_get_address(sd_ipv4ll *ll, struct in_addr *address) { - assert_return(ll, -EINVAL); - assert_return(address, -EINVAL); - - if (ll->claimed_address == 0) - return -ENOENT; - - address->s_addr = ll->claimed_address; - - return 0; -} - -int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, uint64_t seed) { - assert_return(ll, -EINVAL); - assert_return(sd_ipv4ll_is_running(ll) == 0, -EBUSY); - - ll->seed.value = htole64(seed); - ll->seed_set = true; - - return 0; -} - -int sd_ipv4ll_is_running(sd_ipv4ll *ll) { - assert_return(ll, false); - - return sd_ipv4acd_is_running(ll->acd); -} - -static bool ipv4ll_address_is_valid(const struct in_addr *address) { - assert(address); - - if (!in4_addr_is_link_local(address)) - return false; - - return !IN_SET(be32toh(address->s_addr) & 0x0000FF00U, 0x0000U, 0xFF00U); -} - -int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address) { - int r; - - assert_return(ll, -EINVAL); - assert_return(address, -EINVAL); - assert_return(ipv4ll_address_is_valid(address), -EINVAL); - - r = sd_ipv4acd_set_address(ll->acd, address); - if (r < 0) - return r; - - ll->address = address->s_addr; - - return 0; -} - -#define PICK_HASH_KEY SD_ID128_MAKE(15,ac,82,a6,d6,3f,49,78,98,77,5d,0c,69,02,94,0b) - -static int ipv4ll_pick_address(sd_ipv4ll *ll) { - _cleanup_free_ char *address = NULL; - be32_t addr; - - assert(ll); - - do { - uint64_t h; - - h = siphash24(&ll->seed, sizeof(ll->seed), PICK_HASH_KEY.bytes); - - /* Increase the generation counter by one */ - ll->seed.generation = htole64(le64toh(ll->seed.generation) + 1); - - addr = htobe32((h & UINT32_C(0x0000FFFF)) | IPV4LL_NETWORK); - } while (addr == ll->address || - IN_SET(be32toh(addr) & 0x0000FF00U, 0x0000U, 0xFF00U)); - - (void) in_addr_to_string(AF_INET, &(union in_addr_union) { .in.s_addr = addr }, &address); - log_ipv4ll(ll, "Picked new IP address %s.", strna(address)); - - return sd_ipv4ll_set_address(ll, &(struct in_addr) { addr }); -} - -#define MAC_HASH_KEY SD_ID128_MAKE(df,04,22,98,3f,ad,14,52,f9,87,2e,d1,9c,70,e2,f2) - -static int ipv4ll_start_internal(sd_ipv4ll *ll, bool reset_generation) { - int r; - bool picked_address = false; - - assert_return(ll, -EINVAL); - assert_return(!ether_addr_is_null(&ll->mac), -EINVAL); - - /* If no random seed is set, generate some from the MAC address */ - if (!ll->seed_set) - ll->seed.value = htole64(siphash24(ll->mac.ether_addr_octet, ETH_ALEN, MAC_HASH_KEY.bytes)); - - if (reset_generation) - ll->seed.generation = 0; - - if (ll->address == 0) { - r = ipv4ll_pick_address(ll); - if (r < 0) - return r; - - picked_address = true; - } - - r = sd_ipv4acd_start(ll->acd, reset_generation); - if (r < 0) { - - /* We couldn't start? If so, let's forget the picked address again, the user might make a change and - * retry, and we want the new data to take effect when picking an address. */ - if (picked_address) - ll->address = 0; - - return r; - } - - return 1; -} - -int sd_ipv4ll_start(sd_ipv4ll *ll) { - assert_return(ll, -EINVAL); - - if (sd_ipv4ll_is_running(ll)) - return 0; - - return ipv4ll_start_internal(ll, true); -} - -int sd_ipv4ll_restart(sd_ipv4ll *ll) { - ll->address = 0; - - return ipv4ll_start_internal(ll, false); -} - -static void ipv4ll_client_notify(sd_ipv4ll *ll, int event) { - assert(ll); - - if (ll->callback) - ll->callback(ll, event, ll->userdata); -} - -void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata) { - sd_ipv4ll *ll = userdata; - IPV4LL_DONT_DESTROY(ll); - int r; - - assert(acd); - assert(ll); - - switch (event) { - - case SD_IPV4ACD_EVENT_STOP: - ipv4ll_client_notify(ll, SD_IPV4LL_EVENT_STOP); - ll->claimed_address = 0; - break; - - case SD_IPV4ACD_EVENT_BIND: - ll->claimed_address = ll->address; - ipv4ll_client_notify(ll, SD_IPV4LL_EVENT_BIND); - break; - - case SD_IPV4ACD_EVENT_CONFLICT: - /* if an address was already bound we must call up to the - user to handle this, otherwise we just try again */ - if (ll->claimed_address != 0) { - ipv4ll_client_notify(ll, SD_IPV4LL_EVENT_CONFLICT); - - ll->claimed_address = 0; - } else { - r = sd_ipv4ll_restart(ll); - if (r < 0) - goto error; - } - - break; - - default: - assert_not_reached(); - } - - return; - -error: - ipv4ll_client_notify(ll, SD_IPV4LL_EVENT_STOP); -} - -static int ipv4ll_check_mac(sd_ipv4acd *acd, const struct ether_addr *mac, void *userdata) { - sd_ipv4ll *ll = userdata; - - assert(ll); - - if (ll->check_mac_callback) - return ll->check_mac_callback(ll, mac, ll->check_mac_userdata); - - return 0; -} diff --git a/src/libnm-systemd-core/src/systemd/sd-ipv4acd.h b/src/libnm-systemd-core/src/systemd/sd-ipv4acd.h deleted file mode 100644 index 90d3f0a0d1..0000000000 --- a/src/libnm-systemd-core/src/systemd/sd-ipv4acd.h +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef foosdipv4acdfoo -#define foosdipv4acdfoo - -/*** - Copyright © 2014 Axis Communications AB. All rights reserved. - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see . -***/ - -#include -#include -#include - -#include "sd-event.h" - -#include "_sd-common.h" - -_SD_BEGIN_DECLARATIONS; - -enum { - SD_IPV4ACD_EVENT_STOP = 0, - SD_IPV4ACD_EVENT_BIND = 1, - SD_IPV4ACD_EVENT_CONFLICT = 2, -}; - -typedef struct sd_ipv4acd sd_ipv4acd; -typedef void (*sd_ipv4acd_callback_t)(sd_ipv4acd *acd, int event, void *userdata); -typedef int (*sd_ipv4acd_check_mac_callback_t)(sd_ipv4acd *acd, const struct ether_addr *mac, void *userdata); - -int sd_ipv4acd_detach_event(sd_ipv4acd *acd); -int sd_ipv4acd_attach_event(sd_ipv4acd *acd, sd_event *event, int64_t priority); -int sd_ipv4acd_get_address(sd_ipv4acd *acd, struct in_addr *address); -int sd_ipv4acd_set_callback(sd_ipv4acd *acd, sd_ipv4acd_callback_t cb, void *userdata); -int sd_ipv4acd_set_check_mac_callback(sd_ipv4acd *acd, sd_ipv4acd_check_mac_callback_t cb, void *userdata); -int sd_ipv4acd_set_mac(sd_ipv4acd *acd, const struct ether_addr *addr); -int sd_ipv4acd_set_ifindex(sd_ipv4acd *acd, int interface_index); -int sd_ipv4acd_get_ifindex(sd_ipv4acd *acd); -int sd_ipv4acd_set_ifname(sd_ipv4acd *acd, const char *interface_name); -int sd_ipv4acd_get_ifname(sd_ipv4acd *acd, const char **ret); -int sd_ipv4acd_set_address(sd_ipv4acd *acd, const struct in_addr *address); -int sd_ipv4acd_is_running(sd_ipv4acd *acd); -int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts); -int sd_ipv4acd_stop(sd_ipv4acd *acd); -sd_ipv4acd *sd_ipv4acd_ref(sd_ipv4acd *acd); -sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *acd); -int sd_ipv4acd_new(sd_ipv4acd **ret); - -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ipv4acd, sd_ipv4acd_unref); - -_SD_END_DECLARATIONS; - -#endif diff --git a/src/libnm-systemd-core/src/systemd/sd-ipv4ll.h b/src/libnm-systemd-core/src/systemd/sd-ipv4ll.h deleted file mode 100644 index ed014b53f2..0000000000 --- a/src/libnm-systemd-core/src/systemd/sd-ipv4ll.h +++ /dev/null @@ -1,65 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef foosdipv4llfoo -#define foosdipv4llfoo - -/*** - Copyright © 2014 Axis Communications AB. All rights reserved. - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see . -***/ - -#include -#include - -#include "sd-event.h" - -#include "_sd-common.h" - -_SD_BEGIN_DECLARATIONS; - -enum { - SD_IPV4LL_EVENT_STOP = 0, - SD_IPV4LL_EVENT_BIND = 1, - SD_IPV4LL_EVENT_CONFLICT = 2, -}; - -typedef struct sd_ipv4ll sd_ipv4ll; -typedef void (*sd_ipv4ll_callback_t)(sd_ipv4ll *ll, int event, void *userdata); -typedef int (*sd_ipv4ll_check_mac_callback_t)(sd_ipv4ll *ll, const struct ether_addr *mac, void *userdata); - -int sd_ipv4ll_detach_event(sd_ipv4ll *ll); -int sd_ipv4ll_attach_event(sd_ipv4ll *ll, sd_event *event, int64_t priority); -int sd_ipv4ll_get_address(sd_ipv4ll *ll, struct in_addr *address); -int sd_ipv4ll_set_callback(sd_ipv4ll *ll, sd_ipv4ll_callback_t cb, void *userdata); -int sd_ipv4ll_set_check_mac_callback(sd_ipv4ll *ll, sd_ipv4ll_check_mac_callback_t cb, void *userdata); -int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr); -int sd_ipv4ll_set_ifindex(sd_ipv4ll *ll, int interface_index); -int sd_ipv4ll_get_ifindex(sd_ipv4ll *ll); -int sd_ipv4ll_set_ifname(sd_ipv4ll *ll, const char *interface_name); -int sd_ipv4ll_get_ifname(sd_ipv4ll *ll, const char **ret); -int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address); -int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, uint64_t seed); -int sd_ipv4ll_is_running(sd_ipv4ll *ll); -int sd_ipv4ll_restart(sd_ipv4ll *ll); -int sd_ipv4ll_start(sd_ipv4ll *ll); -int sd_ipv4ll_stop(sd_ipv4ll *ll); -sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll); -sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll); -int sd_ipv4ll_new(sd_ipv4ll **ret); - -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ipv4ll, sd_ipv4ll_unref); - -_SD_END_DECLARATIONS; - -#endif diff --git a/tools/test-build.sh b/tools/test-build.sh index cb5199c856..04d33b6ae4 100755 --- a/tools/test-build.sh +++ b/tools/test-build.sh @@ -35,7 +35,6 @@ if [ "${#TARGETS}" -lt 1 ]; then src/core/NetworkManager src/core/dhcp/nm-dhcp-helper src/core/ndisc/tests/test-ndisc-linux - src/core/nm-iface-helper src/core/platform/tests/monitor src/nm-online/nm-online src/nmcli/nmcli From e732cb9a70af513e14ad03464de357f0d656a175 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 18 Oct 2021 15:23:40 +0200 Subject: [PATCH 003/110] device: clear shared4 l3cd on disconnect Fixes-test: @vlan_connection_down_with_autoconnect Fixes-test: @vlan_disconnect_device_with_autoconnect --- src/core/devices/nm-device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 627066d94a..7343c9cf5f 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -11805,6 +11805,8 @@ _dev_ipsharedx_cleanup(NMDevice *self, int addr_family) nm_clear_pointer(&priv->ipshared_data_4.v4.shared_ip_handle, nm_netns_shared_ip_release); nm_clear_l3cd(&priv->ipshared_data_4.v4.l3cd); + + _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_SHARED_4, NULL, FALSE); } _dev_ipsharedx_set_state(self, addr_family, NM_DEVICE_IP_STATE_NONE); From 23d61367b3648a151b8b6ef16b0ec9f7ffd493fa Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 18 Oct 2021 17:45:52 +0200 Subject: [PATCH 004/110] core: set the route table for the ipv6 link-local method Previously the prefix route fe80::/64 was always added to the main table. Fixes-test: @ipv6_route_set_route_with_tables --- src/core/devices/nm-device.c | 23 +++++++++++++++-------- src/core/nm-l3-config-data.c | 1 + src/core/nm-l3-ipv6ll.c | 6 +++++- src/core/nm-l3-ipv6ll.h | 5 +++++ src/core/tests/test-l3cfg.c | 1 + 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 7343c9cf5f..d8f33cfb86 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -10563,13 +10563,15 @@ _dev_ipll6_start(NMDevice *self) const char * stable_id; stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); - priv->ipll_data_6.v6.ipv6ll = nm_l3_ipv6ll_new_stable_privacy(priv->l3cfg, - assume, - stable_type, - ifname, - stable_id, - _dev_ipll6_state_change_cb, - self); + priv->ipll_data_6.v6.ipv6ll = + nm_l3_ipv6ll_new_stable_privacy(priv->l3cfg, + assume, + stable_type, + ifname, + stable_id, + nm_device_get_route_table(self, AF_INET6), + _dev_ipll6_state_change_cb, + self); } else { NMUtilsIPv6IfaceId iid; @@ -10579,7 +10581,12 @@ _dev_ipll6_start(NMDevice *self) } priv->ipll_data_6.v6.ipv6ll = - nm_l3_ipv6ll_new_token(priv->l3cfg, assume, &iid, _dev_ipll6_state_change_cb, self); + nm_l3_ipv6ll_new_token(priv->l3cfg, + assume, + &iid, + nm_device_get_route_table(self, AF_INET6), + _dev_ipll6_state_change_cb, + self); } llstate = nm_l3_ipv6ll_get_state(priv->ipll_data_6.v6.ipv6ll, &lladdr); diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index deec665d1d..da933d5d04 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -2489,6 +2489,7 @@ nm_l3_config_data_add_dependent_device_routes(NML3ConfigData * self, .network = *a6, .plen = plen, }; + nm_platform_ip_route_normalize(addr_family, &rx.rx); nm_l3_config_data_add_route(self, addr_family, NULL, &rx.rx); } diff --git a/src/core/nm-l3-ipv6ll.c b/src/core/nm-l3-ipv6ll.c index 143873213d..17008c7ead 100644 --- a/src/core/nm-l3-ipv6ll.c +++ b/src/core/nm-l3-ipv6ll.c @@ -51,6 +51,8 @@ struct _NML3IPv6LL { * with the configuration. */ const NML3ConfigData *l3cd; + guint32 route_table; + /* "assume" means that we first look whether there is any suitable * IPv6 address on the device, and in that case, try to use that * instead of generating a new one. Otherwise, we always try to @@ -410,7 +412,7 @@ _lladdr_handle_changed(NML3IPv6LL *self) l3cd, NM_L3CFG_CONFIG_PRIORITY_IPV6LL, 0, - 0, + self->route_table, NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4, NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, 0, @@ -624,6 +626,7 @@ _nm_l3_ipv6ll_new(NML3Cfg * l3cfg, const char * ifname, const char * network_id, const NMUtilsIPv6IfaceId *token_iid, + guint32 route_table, NML3IPv6LLNotifyFcn notify_fcn, gpointer user_data) { @@ -647,6 +650,7 @@ _nm_l3_ipv6ll_new(NML3Cfg * l3cfg, .cur_lladdr_obj = NULL, .cur_lladdr = IN6ADDR_ANY_INIT, .assume = assume, + .route_table = route_table, .addrgen = { .stable_type = stable_type, diff --git a/src/core/nm-l3-ipv6ll.h b/src/core/nm-l3-ipv6ll.h index 770a4268a3..3a4f4b4376 100644 --- a/src/core/nm-l3-ipv6ll.h +++ b/src/core/nm-l3-ipv6ll.h @@ -48,6 +48,7 @@ NML3IPv6LL *_nm_l3_ipv6ll_new(NML3Cfg * l3cfg, const char * ifname, const char * network_id, const NMUtilsIPv6IfaceId *token_iid, + guint32 route_table, NML3IPv6LLNotifyFcn notify_fcn, gpointer user_data); @@ -57,6 +58,7 @@ nm_l3_ipv6ll_new_stable_privacy(NML3Cfg * l3cfg, NMUtilsStableType stable_type, const char * ifname, const char * network_id, + guint32 route_table, NML3IPv6LLNotifyFcn notify_fcn, gpointer user_data) { @@ -67,6 +69,7 @@ nm_l3_ipv6ll_new_stable_privacy(NML3Cfg * l3cfg, ifname, network_id, NULL, + route_table, notify_fcn, user_data); } @@ -75,6 +78,7 @@ static inline NML3IPv6LL * nm_l3_ipv6ll_new_token(NML3Cfg * l3cfg, gboolean assume, const NMUtilsIPv6IfaceId *token_iid, + guint32 route_table, NML3IPv6LLNotifyFcn notify_fcn, gpointer user_data) { @@ -84,6 +88,7 @@ nm_l3_ipv6ll_new_token(NML3Cfg * l3cfg, NULL, NULL, token_iid, + route_table, notify_fcn, user_data); } diff --git a/src/core/tests/test-l3cfg.c b/src/core/tests/test-l3cfg.c index b5c85b8224..f02b0f037c 100644 --- a/src/core/tests/test-l3cfg.c +++ b/src/core/tests/test-l3cfg.c @@ -1025,6 +1025,7 @@ test_l3_ipv6ll(gconstpointer test_data) NM_UTILS_STABLE_TYPE_UUID, tdata->f->ifname0, "b6a5b934-c649-43dc-a524-3dfdb74f9419", + 0, _test_l3_ipv6ll_callback_changed, tdata); From e9c17fcc9b33ac300c2bf082e3ce0543bee99492 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 18 Oct 2021 18:07:30 +0200 Subject: [PATCH 005/110] l3cfg: default to 'main' route table sync mode If no l3cd specifies a route table sync mode, use 'main' as default. Fixes-test: @ipv6_route_set_route_with_tables_reapply --- src/core/nm-l3cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 24f139b7d4..72d3bbc7b5 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -3997,7 +3997,7 @@ _l3_commit_one(NML3Cfg * self, } if (route_table_sync == NM_IP_ROUTE_TABLE_SYNC_MODE_NONE) - route_table_sync = NM_IP_ROUTE_TABLE_SYNC_MODE_ALL; + route_table_sync = NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN; if (commit_type == NM_L3_CFG_COMMIT_TYPE_REAPPLY) { addresses_prune = nm_platform_ip_address_get_prune_list(self->priv.platform, From 32443ef3b5b7d2a398bab2afca61537a16344068 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 18 Oct 2021 18:30:50 +0200 Subject: [PATCH 006/110] dns: fix assertion failure nm_l3_config_data_get_searches() and nm_l3_config_data_get_domains() require an 'out_len' argument. --- src/core/dns/nm-dns-manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c index 1ca33e46ac..15072f799d 100644 --- a/src/core/dns/nm-dns-manager.c +++ b/src/core/dns/nm-dns-manager.c @@ -1405,8 +1405,8 @@ _mgr_configs_data_construct(NMDnsManager *self) if (ip_data->ip_config_type == NM_DNS_IP_CONFIG_TYPE_VPN && nm_l3_config_data_get_never_default(ip_data->l3cd, ip_data->addr_family) == NM_TERNARY_FALSE - && !nm_l3_config_data_get_searches(ip_data->l3cd, ip_data->addr_family, NULL) - && !nm_l3_config_data_get_domains(ip_data->l3cd, ip_data->addr_family, NULL)) + && !nm_l3_config_data_get_searches(ip_data->l3cd, ip_data->addr_family, &num) + && !nm_l3_config_data_get_domains(ip_data->l3cd, ip_data->addr_family, &num)) add_wildcard = TRUE; } From 8d40d03a2c1fc1b2fcfd7453c0ea91e476a82ee1 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 19 Oct 2021 20:34:47 +0200 Subject: [PATCH 007/110] dhcp: honor the send_hostname property --- src/core/dhcp/nm-dhcp-client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index 8b9e724968..484ec34e72 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -1012,8 +1012,10 @@ config_init(NMDhcpClientConfig *config, const NMDhcpClientConfig *src) } if (config->hostname) { - if ((config->use_fqdn && !nm_sd_dns_name_is_valid(config->hostname)) - || (!config->use_fqdn && !nm_sd_hostname_is_valid(config->hostname, FALSE))) { + if (!config->send_hostname) { + nm_clear_g_free((gpointer *) &config->hostname); + } else if ((config->use_fqdn && !nm_sd_dns_name_is_valid(config->hostname)) + || (!config->use_fqdn && !nm_sd_hostname_is_valid(config->hostname, FALSE))) { nm_log_warn(LOGD_DHCP, "dhcp%c: %s '%s' is invalid, will be ignored", nm_utils_addr_family_to_char(config->addr_family), From 63ae9cd0351350e1c51793490878333942d33fa7 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 20 Oct 2021 10:40:55 +0200 Subject: [PATCH 008/110] wwan: schedule stage2 when ppp-mgr gets an ifindex --- src/core/devices/wwan/nm-device-modem.c | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index 97fc1b6d29..c916eb47f9 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -39,6 +39,7 @@ typedef struct { char * apn; bool rf_enabled : 1; NMDeviceStageState stage1_state : 3; + NMDeviceStageState stage2_state : 3; } NMDeviceModemPrivate; struct _NMDeviceModem { @@ -193,7 +194,9 @@ modem_new_config(NMModem * modem, static void ip_ifindex_changed_cb(NMModem *modem, GParamSpec *pspec, gpointer user_data) { - NMDevice *device = NM_DEVICE(user_data); + NMDevice * device = NM_DEVICE(user_data); + NMDeviceModem * self = NM_DEVICE_MODEM(device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); if (!nm_device_is_activating(device)) return; @@ -210,6 +213,11 @@ ip_ifindex_changed_cb(NMModem *modem, GParamSpec *pspec, gpointer user_data) * RA handling code to run before NM is ready. */ nm_device_sysctl_ip_conf_set(device, AF_INET6, "disable_ipv6", "1"); + + if (priv->stage2_state == NM_DEVICE_STAGE_STATE_PENDING) { + priv->stage2_state = NM_DEVICE_STAGE_STATE_COMPLETED; + nm_device_activate_schedule_stage2_device_config(device, FALSE); + } } static void @@ -457,6 +465,7 @@ deactivate(NMDevice *device) nm_modem_deactivate(priv->modem, device); priv->stage1_state = NM_DEVICE_STAGE_STATE_INIT; + priv->stage2_state = NM_DEVICE_STAGE_STATE_INIT; } /*****************************************************************************/ @@ -516,9 +525,19 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - return nm_modem_act_stage2_config(NM_DEVICE_MODEM_GET_PRIVATE(device)->modem, - device, - out_failure_reason); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); + + if (priv->stage2_state == NM_DEVICE_STAGE_STATE_INIT) { + priv->stage2_state = NM_DEVICE_STAGE_STATE_PENDING; + return nm_modem_act_stage2_config(NM_DEVICE_MODEM_GET_PRIVATE(device)->modem, + device, + out_failure_reason); + } + if (priv->stage2_state == NM_DEVICE_STAGE_STATE_PENDING) + return NM_ACT_STAGE_RETURN_POSTPONE; + + nm_assert(priv->stage2_state == NM_DEVICE_STAGE_STATE_COMPLETED); + return NM_ACT_STAGE_RETURN_SUCCESS; } static void From 92e1b6650c08d901ed1991d3483039d948c6bc22 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 20 Oct 2021 10:41:45 +0200 Subject: [PATCH 009/110] wwan: fix signal definition --- src/core/devices/wwan/nm-modem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/devices/wwan/nm-modem.c b/src/core/devices/wwan/nm-modem.c index 579f366c17..fe1b99f72d 100644 --- a/src/core/devices/wwan/nm-modem.c +++ b/src/core/devices/wwan/nm-modem.c @@ -1865,7 +1865,7 @@ nm_modem_class_init(NMModemClass *klass) NULL, NULL, G_TYPE_NONE, - 3, + 6, G_TYPE_INT, /* int addr_family */ G_TYPE_POINTER, /* const NML3ConfigData *l3cd */ G_TYPE_BOOLEAN, /* gboolean do_auto */ From e5d28be02242d16a9b83d2f6356e4e31c9add5ed Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 20 Oct 2021 11:29:02 +0200 Subject: [PATCH 010/110] wwan: don't start generic IP configuration methods for NMDeviceModem --- src/core/devices/wwan/nm-device-modem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index c916eb47f9..176614783d 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -615,6 +615,16 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) return TRUE; } +static gboolean +ready_for_ip_config(NMDevice *device) +{ + /* Tell NMDevice to only run device-specific IP + * configuration (devip) and skip other methods + * (manual, dhcp, etc). + */ + return FALSE; +} + /*****************************************************************************/ static void @@ -823,6 +833,7 @@ nm_device_modem_class_init(NMDeviceModemClass *klass) device_class->get_ip_iface_identifier = get_ip_iface_identifier; device_class->get_configured_mtu = nm_modem_get_configured_mtu; device_class->get_dhcp_timeout_for_device = get_dhcp_timeout_for_device; + device_class->ready_for_ip_config = ready_for_ip_config; device_class->state_changed = device_state_changed; From 36a97ad9ecf9e36ed176f0ee762263ac8635f120 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 21 Oct 2021 17:51:33 +0200 Subject: [PATCH 011/110] device: set up IPv6 before start manual method --- src/core/devices/nm-device.c | 85 +++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index d8f33cfb86..5a2d1c19ce 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -11443,14 +11443,13 @@ get_ip_method_auto(NMDevice *self, int addr_family) } static void -activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family) +activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family, const char *method) { const int IS_IPv4 = NM_IS_IPv4(addr_family); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); NMConnection * connection; int ip_ifindex; - const char * method; if (nm_device_sys_iface_state_is_external(self)) goto out; @@ -11460,15 +11459,6 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family) ip_ifindex = nm_device_get_ip_ifindex(self); - if (ip_ifindex > 0 && !nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex) - && !nm_device_sys_iface_state_is_external(self)) { - nm_platform_link_change_flags(nm_device_get_platform(self), ip_ifindex, IFF_UP, TRUE); - if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex)) - _LOGW(LOGD_DEVICE, - "interface %s not up for IP configuration", - nm_device_get_ip_iface(self)); - } - if (connection_ip_method_requires_carrier(connection, addr_family, NULL) && nm_device_is_master(self) && !priv->carrier) { if (!priv->ip_data_x[IS_IPv4].wait_for_carrier) { @@ -11499,20 +11489,9 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family) priv->ip_data_x[IS_IPv4].wait_for_ports = FALSE; } - method = nm_device_get_effective_ip_config_method(self, addr_family); - - if (nm_streq(method, - IS_IPv4 ? NM_SETTING_IP4_CONFIG_METHOD_AUTO : NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - /* "auto" usually means DHCPv6 or autoconf6, but it doesn't have to be. Subclasses - * can overwrite it. For example, you cannot run DHCPv4 on PPP/WireGuard links. */ - method = klass->get_ip_method_auto(self, addr_family); - } - if (klass->ready_for_ip_config && !klass->ready_for_ip_config(self)) goto out_devip; - _dev_ipmanual_start(self); - if (IS_IPv4) { if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) _dev_ipdhcpx_start(self, AF_INET); @@ -11565,21 +11544,6 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family) } } } else { - /* Ensure the MTU makes sense. If it was below 1280 the kernel would not - * expose any ipv6 sysctls or allow presence of any addresses on the interface, - * including LL, which * would make it impossible to autoconfigure MTU to a - * correct value. */ - _commit_mtu(self); - - /* Any method past this point requires an IPv6LL address. Use NM-controlled - * IPv6LL if this is not an assumed connection, since assumed connections - * will already have IPv6 set up. - */ - _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); - - /* Re-enable IPv6 on the interface */ - nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "0"); - _dev_sysctl_set_disable_ipv6(self, FALSE); _dev_ipll6_start(self); if (NM_IN_STRSET(method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) @@ -11688,8 +11652,11 @@ fw_change_zone(NMDevice *self) static void activate_stage3_ip_config(NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); int ifindex; + const char * ipv4_method; + const char * ipv6_method; /* stage3 is different from stage1+2. * @@ -11764,8 +11731,46 @@ activate_stage3_ip_config(NMDevice *self) nm_device_get_ip_iface(self)); } - activate_stage3_ip_config_for_addr_family(self, AF_INET); - activate_stage3_ip_config_for_addr_family(self, AF_INET6); + ipv4_method = nm_device_get_effective_ip_config_method(self, AF_INET); + if (nm_streq(ipv4_method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { + /* "auto" usually means DHCPv4 or autoconf6, but it doesn't have to be. Subclasses + * can overwrite it. For example, you cannot run DHCPv4 on PPP/WireGuard links. */ + ipv4_method = klass->get_ip_method_auto(self, AF_INET); + } + + ipv6_method = nm_device_get_effective_ip_config_method(self, AF_INET6); + if (nm_streq(ipv6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { + ipv6_method = klass->get_ip_method_auto(self, AF_INET6); + } + + if (!nm_device_sys_iface_state_is_external(self) + && (!klass->ready_for_ip_config || klass->ready_for_ip_config(self))) { + if (priv->ipmanual_data.state_6 == NM_DEVICE_IP_STATE_NONE + && !NM_IN_STRSET(ipv6_method, + NM_SETTING_IP6_CONFIG_METHOD_DISABLED, + NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { + /* Ensure the MTU makes sense. If it was below 1280 the kernel would not + * expose any ipv6 sysctls or allow presence of any addresses on the interface, + * including LL, which * would make it impossible to autoconfigure MTU to a + * correct value. */ + _commit_mtu(self); + + /* Any method past this point requires an IPv6LL address. Use NM-controlled + * IPv6LL if this is not an assumed connection, since assumed connections + * will already have IPv6 set up. + */ + _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); + + /* Re-enable IPv6 on the interface */ + nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "0"); + _dev_sysctl_set_disable_ipv6(self, FALSE); + } + + _dev_ipmanual_start(self); + } + + activate_stage3_ip_config_for_addr_family(self, AF_INET, ipv4_method); + activate_stage3_ip_config_for_addr_family(self, AF_INET6, ipv6_method); } void From a1de041184a4b95225e25514a5ba7b11df343912 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 21 Oct 2021 18:28:56 +0200 Subject: [PATCH 012/110] device: reschedule a assume check after platform changes --- src/core/devices/nm-device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 5a2d1c19ce..179ccc4503 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -3889,6 +3889,7 @@ _dev_l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, N _dev_unamanged_check_external_down(self, TRUE); _dev_ipmanual_check_ready(self); update_external_connection(self); + nm_device_queue_recheck_assume(self); return; case _NM_L3_CONFIG_NOTIFY_TYPE_NUM: From c7ecaeb103a0232b413494b1f951d89885950b9e Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 25 Oct 2021 11:45:42 +0200 Subject: [PATCH 013/110] device: prefer non-LL and non-deprecated IPv6 address for hostname --- src/core/devices/nm-device.c | 82 ++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 179ccc4503..260e7f8eca 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -16565,6 +16565,60 @@ nm_device_clear_dns_lookup_data(NMDevice *self) nm_clear_pointer(&priv->hostname_resolver_x[i], _hostname_resolver_free); } +static GInetAddress * +get_address_for_hostname_dns_lookup(NMDevice *self, int addr_family) +{ + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMPLookup lookup; + const NMDedupMultiHeadEntry *head_entry; + const NMDedupMultiEntry * iter; + const guint8 * addr6_ll = NULL; + const guint8 * addr6_nonll = NULL; + int ifindex; + + ifindex = nm_device_get_ip_ifindex(self); + if (ifindex <= 0) + return NULL; + + /* FIXME(l3cfg): now we lookup the address from platform. Should we instead look + * it up from NML3Cfg? That is, take an address that we want to configure as + * opposed to an address that is configured? */ + head_entry = nm_platform_lookup( + nm_device_get_platform(self), + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex)); + + if (head_entry) { + c_list_for_each_entry (iter, &head_entry->lst_entries_head, lst_entries) { + const NMPlatformIPAddress *addr = NMP_OBJECT_CAST_IP_ADDRESS(iter->obj); + + if (IS_IPv4) { + return g_inet_address_new_from_bytes(addr->address_ptr, G_SOCKET_FAMILY_IPV4); + } + + /* For IPv6 prefer, in order: + * - !link-local, !deprecated + * - !link-local, deprecated + * - link-local + */ + + if (!IN6_IS_ADDR_LINKLOCAL(addr->address_ptr)) { + if (!(addr->n_ifa_flags & IFA_F_DEPRECATED)) { + return g_inet_address_new_from_bytes(addr->address_ptr, G_SOCKET_FAMILY_IPV6); + } + addr6_nonll = addr->address_ptr; + continue; + } + + addr6_ll = addr->address_ptr; + } + + if (addr6_nonll || addr6_ll) + return g_inet_address_new_from_bytes(addr6_nonll ?: addr6_ll, G_SOCKET_FAMILY_IPV6); + } + + return NULL; +} + /* return value is valid only immediately */ const char * nm_device_get_hostname_from_dns_lookup(NMDevice *self, int addr_family, gboolean *out_wait) @@ -16573,12 +16627,10 @@ nm_device_get_hostname_from_dns_lookup(NMDevice *self, int addr_family, gboolean NMDevicePrivate * priv; HostnameResolver *resolver; const char * method; - int ifindex; gboolean address_changed = FALSE; gs_unref_object GInetAddress *new_address = NULL; g_return_val_if_fail(NM_IS_DEVICE(self), NULL); - priv = NM_DEVICE_GET_PRIVATE(self); /* If the device is not supposed to have addresses, @@ -16618,31 +16670,7 @@ nm_device_get_hostname_from_dns_lookup(NMDevice *self, int addr_family, gboolean /* Determine the most suitable address of the interface * and whether it changed from the previous lookup */ - ifindex = nm_device_get_ip_ifindex(self); - if (ifindex > 0) { - NMPLookup lookup; - const NMDedupMultiHeadEntry *head_entry; - const NMDedupMultiEntry * iter; - - /* FIXME(l3cfg): now we lookup the address from platform. Should we instead look - * it up from NML3Cfg? That is, take an address that we want to configure as - * opposed to an address that is configured? */ - head_entry = nm_platform_lookup( - nm_device_get_platform(self), - nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex)); - - if (head_entry) { - c_list_for_each_entry (iter, &head_entry->lst_entries_head, lst_entries) { - const NMPlatformIPAddress *addr = NMP_OBJECT_CAST_IP_ADDRESS(iter->obj); - - new_address = g_inet_address_new_from_bytes(addr->address_ptr, - IS_IPv4 ? G_SOCKET_FAMILY_IPV4 - : G_SOCKET_FAMILY_IPV6); - break; - } - } - } - + new_address = get_address_for_hostname_dns_lookup(self, addr_family); if (new_address && resolver->address) { if (!g_inet_address_equal(new_address, resolver->address)) address_changed = TRUE; From 443c380f29f6dad860a7665eb7fa63f5a9be2f82 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 25 Oct 2021 11:47:26 +0200 Subject: [PATCH 014/110] core: update hostname when addresses on platform change --- src/core/devices/nm-device.c | 18 ++++++++++++++++++ src/core/devices/nm-device.h | 21 +++++++++++---------- src/core/nm-policy.c | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 260e7f8eca..4435b550e0 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -324,6 +324,7 @@ enum { RECHECK_AUTO_ACTIVATE, RECHECK_ASSUME, DNS_LOOKUP_DONE, + PLATFORM_ADDRESS_CHANGED, LAST_SIGNAL, }; static guint signals[LAST_SIGNAL] = {0}; @@ -3887,6 +3888,13 @@ _dev_l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, N | nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP4_ADDRESS) | nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP6_ADDRESS))) _dev_unamanged_check_external_down(self, TRUE); + + if (NM_FLAGS_ANY(notify_data->platform_change_on_idle.obj_type_flags, + nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP4_ADDRESS) + | nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP6_ADDRESS))) { + g_signal_emit(self, signals[PLATFORM_ADDRESS_CHANGED], 0); + } + _dev_ipmanual_check_ready(self); update_external_connection(self); nm_device_queue_recheck_assume(self); @@ -17875,6 +17883,16 @@ nm_device_class_init(NMDeviceClass *klass) NULL, G_TYPE_NONE, 0); + + signals[PLATFORM_ADDRESS_CHANGED] = g_signal_new(NM_DEVICE_PLATFORM_ADDRESS_CHANGED, + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 0); } /* Connection defaults from plugins */ diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 9bd8aa7bee..93e9d51b14 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -71,16 +71,17 @@ #define NM_DEVICE_HAS_PENDING_ACTION "has-pending-action" /* Internal only */ /* Internal signals */ -#define NM_DEVICE_DNS_LOOKUP_DONE "dns-lookup-done" -#define NM_DEVICE_L3CD_CHANGED "l3cd-changed" -#define NM_DEVICE_IP6_PREFIX_DELEGATED "ip6-prefix-delegated" -#define NM_DEVICE_IP6_SUBNET_NEEDED "ip6-subnet-needed" -#define NM_DEVICE_REMOVED "removed" -#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate" -#define NM_DEVICE_RECHECK_ASSUME "recheck-assume" -#define NM_DEVICE_STATE_CHANGED "state-changed" -#define NM_DEVICE_LINK_INITIALIZED "link-initialized" -#define NM_DEVICE_AUTOCONNECT_ALLOWED "autoconnect-allowed" +#define NM_DEVICE_DNS_LOOKUP_DONE "dns-lookup-done" +#define NM_DEVICE_L3CD_CHANGED "l3cd-changed" +#define NM_DEVICE_IP6_PREFIX_DELEGATED "ip6-prefix-delegated" +#define NM_DEVICE_IP6_SUBNET_NEEDED "ip6-subnet-needed" +#define NM_DEVICE_REMOVED "removed" +#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate" +#define NM_DEVICE_RECHECK_ASSUME "recheck-assume" +#define NM_DEVICE_STATE_CHANGED "state-changed" +#define NM_DEVICE_LINK_INITIALIZED "link-initialized" +#define NM_DEVICE_AUTOCONNECT_ALLOWED "autoconnect-allowed" +#define NM_DEVICE_PLATFORM_ADDRESS_CHANGED "platform-address-changed" #define NM_DEVICE_STATISTICS_REFRESH_RATE_MS "refresh-rate-ms" #define NM_DEVICE_STATISTICS_TX_BYTES "tx-bytes" diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index f089f1cb5e..2c3e80a325 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -2131,6 +2131,8 @@ device_l3cd_changed(NMDevice * device, update_ip_dns(self, AF_INET6, device); update_ip4_routing(self, TRUE); update_ip6_routing(self, TRUE); + /* FIXME: since we already monitor platform addresses changes, + * this is probably no longer necessary? */ update_system_hostname(self, "ip conf"); } else { nm_dns_manager_set_ip_config(priv->dns_manager, @@ -2144,6 +2146,19 @@ device_l3cd_changed(NMDevice * device, nm_dns_manager_end_updates(priv->dns_manager, __func__); } +static void +device_platform_address_changed(NMDevice *device, gpointer user_data) +{ + NMPolicyPrivate *priv = user_data; + NMPolicy * self = _PRIV_TO_SELF(priv); + NMDeviceState state; + + state = nm_device_get_state(device); + if (state > NM_DEVICE_STATE_DISCONNECTED && state < NM_DEVICE_STATE_DEACTIVATING) { + update_system_hostname(self, "address changed"); + } +} + /*****************************************************************************/ static void @@ -2180,6 +2195,10 @@ devices_list_register(NMPolicy *self, NMDevice *device) /* Connect state-changed with _after, so that the handler is invoked after other handlers. */ g_signal_connect_after(device, NM_DEVICE_STATE_CHANGED, G_CALLBACK(device_state_changed), priv); g_signal_connect(device, NM_DEVICE_L3CD_CHANGED, G_CALLBACK(device_l3cd_changed), priv); + g_signal_connect(device, + NM_DEVICE_PLATFORM_ADDRESS_CHANGED, + G_CALLBACK(device_platform_address_changed), + priv); g_signal_connect(device, NM_DEVICE_IP6_PREFIX_DELEGATED, G_CALLBACK(device_ip6_prefix_delegated), From b86388bef3758b46f9c4239230c57ee9b2787fd8 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 25 Oct 2021 15:58:25 +0200 Subject: [PATCH 015/110] core: avoid stale entries in the DNS manager When a virtual interface is removed externally, the device is unrealized and the ifindex is cleared; this also detaches the existing l3cfg from the device. At this point the l3cd entry for the device lingers forever in the DNS manager. Emit a last L3CD_CHANGED so that the old entry gets removed. Fixes-test: @disconnect_from_pppoe --- src/core/devices/nm-device.c | 12 ++++++++++++ src/core/nm-policy.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 4435b550e0..896b0dc63f 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -3980,6 +3980,18 @@ _set_ifindex(NMDevice *self, int ifindex, gboolean is_ip_ifindex) if (priv->l3cfg) { if (ip_ifindex_new <= 0 || ip_ifindex_new != nm_l3cfg_get_ifindex(priv->l3cfg)) { + const NML3ConfigData *l3cd_old; + + if (ip_ifindex_new <= 0) { + /* The ifindex was reset. Send a last L3CD_CHANGED + * signal with a NULL l3cd so that the old one can + * be removed from the DNS manager. + */ + l3cd_old = nm_l3cfg_get_combined_l3cd(priv->l3cfg, TRUE); + if (l3cd_old) + g_signal_emit(self, signals[L3CD_CHANGED], 0, l3cd_old, NULL); + } + g_signal_handlers_disconnect_by_func(priv->l3cfg, G_CALLBACK(_dev_l3_cfg_notify_cb), self); diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index 2c3e80a325..329d14d167 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -2120,7 +2120,7 @@ device_l3cd_changed(NMDevice * device, * now. */ state = nm_device_get_state(device); - if (state > NM_DEVICE_STATE_DISCONNECTED && state < NM_DEVICE_STATE_DEACTIVATING) { + if (l3cd_new && state > NM_DEVICE_STATE_DISCONNECTED && state < NM_DEVICE_STATE_DEACTIVATING) { nm_dns_manager_set_ip_config(priv->dns_manager, AF_UNSPEC, device, From 98da62642b6461c73ae34b0005660f4cdd594110 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 26 Oct 2021 17:17:03 +0200 Subject: [PATCH 016/110] device: enable IPv6 in ip6_managed_setup() IPv6 must be enabled when the device enters the DISCONNECTED state. --- src/core/devices/nm-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 896b0dc63f..d721bee74d 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -15082,7 +15082,7 @@ static void ip6_managed_setup(NMDevice *self) { _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); - _dev_sysctl_set_disable_ipv6(self, TRUE); + _dev_sysctl_set_disable_ipv6(self, FALSE); nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "0"); nm_device_sysctl_ip_conf_set(self, AF_INET6, "use_tempaddr", "0"); nm_device_sysctl_ip_conf_set(self, AF_INET6, "forwarding", "0"); From 8fb8e334b89124477fe14b4bd0df78c3a7b0017f Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 27 Oct 2021 09:49:28 +0200 Subject: [PATCH 017/110] device: wait that IPv6 autoconf addresses become non-tentative Fixes-test: @ipv6_preserve_cached_routes --- src/core/devices/nm-device.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index d721bee74d..1f27e4f328 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -627,11 +627,12 @@ typedef struct _NMDevicePrivate { }; struct { - NMNDisc * ndisc; - GSource * ndisc_grace_source; - gulong ndisc_changed_id; - gulong ndisc_timeout_id; - NMDeviceIPState state; + NMNDisc * ndisc; + GSource * ndisc_grace_source; + gulong ndisc_changed_id; + gulong ndisc_timeout_id; + NMDeviceIPState state; + const NML3ConfigData *l3cd; } ipac6_data; union { @@ -823,6 +824,8 @@ _dev_ipac6_grace_period_start(NMDevice *self, guint32 timeout_sec, gboolean forc static void _dev_ipac6_start(NMDevice *self); +static void _dev_ipac6_set_state(NMDevice *self, NMDeviceIPState state); + static void _dev_unamanged_check_external_down(NMDevice *self, gboolean only_if_unmanaged); static void _dev_ipshared4_start(NMDevice *self); @@ -3895,6 +3898,20 @@ _dev_l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, N g_signal_emit(self, signals[PLATFORM_ADDRESS_CHANGED], 0); } + /* Check if AC6 addresses completed DAD */ + if (NM_FLAGS_ANY(notify_data->platform_change_on_idle.obj_type_flags, + nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP6_ADDRESS)) + && priv->ipac6_data.state == NM_DEVICE_IP_STATE_PENDING && priv->ipac6_data.l3cd + && nm_l3cfg_check_ready(l3cfg, + priv->ipac6_data.l3cd, + AF_INET6, + NM_L3CFG_CHECK_READY_FLAGS_IP6_DAD_READY, + NULL)) { + nm_clear_l3cd(&priv->ipac6_data.l3cd); + _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_READY); + _dev_ip_state_check_async(self, AF_INET6); + } + _dev_ipmanual_check_ready(self); update_external_connection(self); nm_device_queue_recheck_assume(self); @@ -11081,17 +11098,23 @@ _dev_ipac6_ndisc_config_changed(NMNDisc * ndisc, const NML3ConfigData *l3cd, NMDevice * self) { + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + _dev_ipac6_grace_period_start(self, 0, TRUE); _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_AC_6, l3cd, FALSE); - _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_READY); + nm_l3_config_data_unref(priv->ipac6_data.l3cd); + priv->ipac6_data.l3cd = nm_l3_config_data_ref(l3cd); _dev_ipdhcp6_set_dhcp_level(self, rdata->dhcp_level); _dev_l3_cfg_commit(self, FALSE); _dev_ip_state_check_async(self, AF_INET6); + + /* wait that addresses are committed to platform and + * become non-tentative before declaring AC6 is ready.*/ } static void @@ -11307,6 +11330,7 @@ _dev_ipac6_cleanup(NMDevice *self) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->ipac6_data.ndisc_grace_source); + nm_clear_l3cd(&priv->ipac6_data.l3cd); nm_clear_g_signal_handler(priv->ipac6_data.ndisc, &priv->ipac6_data.ndisc_changed_id); nm_clear_g_signal_handler(priv->ipac6_data.ndisc, &priv->ipac6_data.ndisc_timeout_id); From d8d6ecf37a079e3e34c8960946b9a613896e245d Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 27 Oct 2021 10:19:47 +0200 Subject: [PATCH 018/110] l3cfg: remove event down source on finalize --- src/core/nm-l3cfg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 72d3bbc7b5..02456d5b95 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -1570,6 +1570,7 @@ _l3_acd_nacd_instance_reset(NML3Cfg *self, NMTernary start_timer, gboolean acd_d } nm_clear_g_source_inst(&self->priv.p->nacd_source); nm_clear_g_source_inst(&self->priv.p->nacd_instance_ensure_retry); + nm_clear_g_source_inst(&self->priv.p->nacd_event_down_source); if (c_list_is_empty(&self->priv.p->acd_lst_head)) start_timer = NM_TERNARY_DEFAULT; @@ -4472,6 +4473,7 @@ finalize(GObject *object) nm_clear_pointer(&self->priv.p->nacd, n_acd_unref); nm_clear_g_source_inst(&self->priv.p->nacd_source); nm_clear_g_source_inst(&self->priv.p->nacd_instance_ensure_retry); + nm_clear_g_source_inst(&self->priv.p->nacd_event_down_source); nm_clear_g_source_inst(&self->priv.p->obj_state_temporary_not_available_timeout_source); From 96850933bbbacb3a07d875a80bad13f79068a7d6 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 27 Oct 2021 11:09:52 +0200 Subject: [PATCH 019/110] core: ignore external routes when generating connections --- src/core/NetworkManagerUtils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/NetworkManagerUtils.c b/src/core/NetworkManagerUtils.c index fdb2b40443..e057f5534b 100644 --- a/src/core/NetworkManagerUtils.c +++ b/src/core/NetworkManagerUtils.c @@ -28,6 +28,7 @@ #include "libnm-platform/nm-platform.h" #include "libnm-platform/nm-linux-platform.h" +#include "libnm-platform/nm-platform-utils.h" #include "nm-auth-utils.h" #include "libnm-systemd-shared/nm-sd-utils-shared.h" @@ -1750,6 +1751,12 @@ nm_utils_platform_capture_ip_setting(NMPlatform *platform, continue; } + if (route->rx.rt_source + != nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER)) { + /* Ignore routes provided by external sources */ + continue; + } + s_route = nm_ip_route_new_binary(addr_family, route->rx.network_ptr, route->rx.plen, From a2d96a5c2eba93061747b2aa57dd93e0f88321bc Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 27 Oct 2021 13:38:44 +0200 Subject: [PATCH 020/110] vlan: preserve external IP changes on parent MAC update When the parent MAC is updated, a VLAN device also updates its MAC and then performs a new commit to restore IP configuration. This should not remove addresses added externally. Change the commit type to UPDATE. Fixes-test: @static_route_persists_mac_change --- src/core/devices/nm-device-vlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/devices/nm-device-vlan.c b/src/core/devices/nm-device-vlan.c index c1902d5eea..5709ad7b18 100644 --- a/src/core/devices/nm-device-vlan.c +++ b/src/core/devices/nm-device-vlan.c @@ -115,7 +115,7 @@ parent_hwaddr_maybe_changed(NMDevice *parent, GParamSpec *pspec, gpointer user_d /* When changing the hw address the interface is taken down, * removing the IPv6 configuration; reapply it. */ - nm_device_l3cfg_commit(device, NM_L3_CFG_COMMIT_TYPE_REAPPLY, FALSE); + nm_device_l3cfg_commit(device, NM_L3_CFG_COMMIT_TYPE_UPDATE, FALSE); } } From 9380d3c71578a04bb01042231df68492c0eb8684 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 28 Oct 2021 10:52:47 +0200 Subject: [PATCH 021/110] device: fix waiting for IPv6 autoconf addresses When NM is restarted and the previous connection gets assumed, addresses are already configured; in such case we don't need to wait. --- src/core/devices/nm-device.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 1f27e4f328..ac83a1749a 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -11098,23 +11098,43 @@ _dev_ipac6_ndisc_config_changed(NMNDisc * ndisc, const NML3ConfigData *l3cd, NMDevice * self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gboolean ready = TRUE; + NMDedupMultiIter iter; + const NMPObject *obj; _dev_ipac6_grace_period_start(self, 0, TRUE); _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_AC_6, l3cd, FALSE); - nm_l3_config_data_unref(priv->ipac6_data.l3cd); - priv->ipac6_data.l3cd = nm_l3_config_data_ref(l3cd); + nm_clear_l3cd(&priv->ipac6_data.l3cd); + + /* wait that addresses are committed to platform and + * become non-tentative before declaring AC6 is ready.*/ + nm_l3_config_data_iter_obj_for_each (&iter, l3cd, &obj, NMP_OBJECT_TYPE_IP6_ADDRESS) { + const NMPlatformIP6Address *addr = NMP_OBJECT_CAST_IP6_ADDRESS(obj); + const NMPlatformIP6Address *plat_addr; + + plat_addr = nm_platform_ip6_address_get(nm_device_get_platform(self), + nm_device_get_ip_ifindex(self), + &addr->address); + if (!plat_addr || (plat_addr->n_ifa_flags & IFA_F_TENTATIVE)) { + ready = FALSE; + break; + } + } + + if (ready) { + _dev_ipac6_set_state(self, NM_DEVICE_IP_STATE_READY); + } else { + priv->ipac6_data.l3cd = nm_l3_config_data_ref(l3cd); + } _dev_ipdhcp6_set_dhcp_level(self, rdata->dhcp_level); _dev_l3_cfg_commit(self, FALSE); _dev_ip_state_check_async(self, AF_INET6); - - /* wait that addresses are committed to platform and - * become non-tentative before declaring AC6 is ready.*/ } static void From c4238620d3e61c38e1a877af9ec77e5a61295966 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 29 Oct 2021 09:51:25 +0200 Subject: [PATCH 022/110] glib-aux: accept NULL addresses in nm_ip_addr_equal() nm_ether_addr_equal() already accepts NULL addresses and makes a distinction between NULL and a zero address. Introduce a similar behavior for nm_ip_addr_equal(), as it's useful in some cases. --- src/libnm-glib-aux/nm-shared-utils.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index 8dd53dcf29..e6e470b4cc 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -248,10 +248,9 @@ extern const NMIPAddr nm_ip_addr_zero; static inline int nm_ip_addr_cmp(int addr_family, gconstpointer a, gconstpointer b) { - nm_assert(a); - nm_assert(b); - - return memcmp(a, b, nm_utils_addr_family_to_size(addr_family)); + NM_CMP_SELF(a, b); + NM_CMP_DIRECT_MEMCMP(a, b, nm_utils_addr_family_to_size(addr_family)); + return 0; } static inline gboolean From 8f8e912e3b9e3c9df4fa4118a212b33efc36e401 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 29 Oct 2021 09:54:13 +0200 Subject: [PATCH 023/110] core: also export 0.0.0.0 as gateway in IP configuration The IP configuration exported over D-Bus for a device has a "gateway" property. If the device has a default route without a gateway, before the L3 rework the gateway used to be exported as "0.0.0.0". That seems useful to indicate that the device has a default route, but without a next hop. Restore that behavior. Fixes-test: @preserve_route_to_generic_device --- src/core/nm-ip-config.c | 24 +++++++++++++++--------- src/core/nm-ip-config.h | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/core/nm-ip-config.c b/src/core/nm-ip-config.c index 196cf35a98..4bbe1e1a4a 100644 --- a/src/core/nm-ip-config.c +++ b/src/core/nm-ip-config.c @@ -100,12 +100,14 @@ get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec g_value_set_variant(value, priv->v_address_data); break; case PROP_IP_GATEWAY: - g_value_set_variant( - value, - nm_ip_addr_is_null(addr_family, &priv->v_gateway.addr) - ? nm_g_variant_singleton_s_empty() - : g_variant_new_string( - nm_utils_inet_ntop(addr_family, &priv->v_gateway.addr, sbuf_addr))); + if (priv->v_gateway.addr) { + g_value_set_variant( + value, + g_variant_new_string( + nm_utils_inet_ntop(addr_family, priv->v_gateway.addr, sbuf_addr))); + } else { + g_value_set_variant(value, nm_g_variant_singleton_s_empty()); + } break; case PROP_IP_ROUTE_DATA: g_value_set_variant(value, priv->v_route_data); @@ -210,6 +212,7 @@ finalize(GObject *object) nm_g_variant_unref(priv->v_route_data); nm_g_variant_unref(priv->v_routes); + g_free(priv->v_gateway.addr); nmp_object_unref(priv->v_gateway.best_default_route); nm_l3_config_data_unref(priv->l3cd); @@ -767,9 +770,12 @@ _handle_platform_change(NMIPConfig *self, guint32 obj_type_flags, gboolean is_in ? nm_platform_ip_route_get_gateway( addr_family, NMP_OBJECT_CAST_IP_ROUTE(priv->v_gateway.best_default_route)) - : &nm_ip_addr_zero; - if (!nm_ip_addr_equal(addr_family, &priv->v_gateway.addr, gateway_next_hop)) { - nm_ip_addr_set(addr_family, &priv->v_gateway.addr, gateway_next_hop); + : NULL; + + if (!nm_ip_addr_equal(addr_family, priv->v_gateway.addr, gateway_next_hop)) { + g_free(priv->v_gateway.addr); + priv->v_gateway.addr = + g_memdup(gateway_next_hop, nm_utils_addr_family_to_size(addr_family)); best_default_route_changed = TRUE; } } diff --git a/src/core/nm-ip-config.h b/src/core/nm-ip-config.h index e3c3b30a96..cfe964d0ee 100644 --- a/src/core/nm-ip-config.h +++ b/src/core/nm-ip-config.h @@ -31,7 +31,7 @@ struct _NMIPConfigPrivate { GVariant * v_routes; struct { const NMPObject *best_default_route; - NMIPAddr addr; + NMIPAddr * addr; } v_gateway; gulong l3cfg_notify_id; }; From cc3ec405131d6371bbbcead81669b65e1c5adfc0 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 30 Oct 2021 11:33:51 +0200 Subject: [PATCH 024/110] device: fail when a addr family fails and the other is disabled Fixes-test: @ipv4_method_shared_with_already_running_dnsmasq --- src/core/devices/nm-device.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index ac83a1749a..b70df02db1 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -3071,8 +3071,15 @@ _dev_ip_state_check(NMDevice *self, int addr_family) NMDeviceIPState ip_state; NMDeviceIPState ip_state_other; NMDeviceIPState combinedip_state; - NMTernary may_fail = NM_TERNARY_DEFAULT; - NMTernary may_fail_other = NM_TERNARY_DEFAULT; + NMTernary may_fail = NM_TERNARY_DEFAULT; + NMTernary may_fail_other = NM_TERNARY_DEFAULT; + gboolean disabled_or_ignore = FALSE; + gboolean disabled_or_ignore_other = FALSE; + + if (priv->ip_data_x[IS_IPv4].is_disabled || priv->ip_data_x[IS_IPv4].is_ignore) + disabled_or_ignore = TRUE; + if (priv->ip_data_x[!IS_IPv4].is_disabled || priv->ip_data_x[!IS_IPv4].is_ignore) + disabled_or_ignore_other = TRUE; /* State handling in NMDevice: * @@ -3142,7 +3149,7 @@ _dev_ip_state_check(NMDevice *self, int addr_family) goto got_ip_state; } - if (priv->ip_data_x[IS_IPv4].is_disabled || priv->ip_data_x[IS_IPv4].is_ignore) { + if (disabled_or_ignore) { ip_state = NM_DEVICE_IP_STATE_READY; goto got_ip_state; } @@ -3270,7 +3277,7 @@ got_ip_state: if (ip_state == NM_DEVICE_IP_STATE_READY && ip_state_other == NM_DEVICE_IP_STATE_READY) combinedip_state = NM_DEVICE_IP_STATE_READY; else if (ip_state == NM_DEVICE_IP_STATE_READY && ip_state_other == NM_DEVICE_IP_STATE_PENDING - && (priv->ip_data_x[IS_IPv4].is_disabled || priv->ip_data_x[IS_IPv4].is_ignore)) { + && disabled_or_ignore) { /* This IP method is disabled/ignore, but the other family is still pending. * Regardless of ipvx.may-fail, this means that we always require the other IP family * to get ready too. */ @@ -3293,10 +3300,20 @@ got_ip_state: else if (ip_state == NM_DEVICE_IP_STATE_FAILED && !_prop_get_ipvx_may_fail_cached(self, addr_family, &may_fail)) combinedip_state = NM_DEVICE_IP_STATE_FAILED; - else if (ip_state == NM_DEVICE_IP_STATE_FAILED && ip_state_other == NM_DEVICE_IP_STATE_FAILED) { - /* If both IP states fail, then it's a failure for good. may-fail does not mean that - * both families may fail, instead it means that at least one family must succeed. */ - combinedip_state = NM_DEVICE_IP_STATE_FAILED; + else if ((ip_state == NM_DEVICE_IP_STATE_FAILED + || (ip_state == NM_DEVICE_IP_STATE_READY && disabled_or_ignore)) + && (ip_state_other == NM_DEVICE_IP_STATE_FAILED + || (ip_state_other = NM_DEVICE_IP_STATE_READY && disabled_or_ignore_other))) { + /* If both IP states failed, or one failed and the other is disabled + * then it's a failure. may-fail does not mean that both families may + * fail, instead it means that at least one family must succeed. */ + if (nm_device_sys_iface_state_is_external_or_assume(self)) { + _dev_ip_state_set_state(self, AF_INET, NM_DEVICE_IP_STATE_READY, "assumed"); + _dev_ip_state_set_state(self, AF_INET6, NM_DEVICE_IP_STATE_READY, "assumed"); + combinedip_state = NM_DEVICE_IP_STATE_READY; + } else { + combinedip_state = NM_DEVICE_IP_STATE_FAILED; + } } else { if (priv->ip_data.state == NM_DEVICE_IP_STATE_NONE) combinedip_state = NM_DEVICE_IP_STATE_PENDING; From bcf31a9b299b153b1cc5fb48f57c342edad1708d Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 30 Oct 2021 15:15:04 +0200 Subject: [PATCH 025/110] device: fix assertion failure on master carrier change Fix the following assertion failure: "nm_assert(NM_DEVICE_GET_PRIVATE(self)->act_request.obj);" 0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 1 __GI_abort () at abort.c:79 2 g_assertion_message () at gtestutils.c:2533 3 g_assertion_message_expr () at gtestutils.c:2556 4 activation_source_invoke_or_schedule (self=0x55b543884610 [NMDeviceBridge], func=0x55b542e8c940 , do_sync=0) at src/core/devices/nm-device.c:8854 5 nm_device_set_carrier (self=0x55b543884610 [NMDeviceBridge], carrier=1) at src/core/devices/nm-device.c:6217 6 device_link_changed (user_data=user_data@entry=0x55b543884610) at src/core/devices/nm-device.c:6479 7 g_idle_dispatch (source=0x55b5438577d0, callback=0x55b542e95980 , user_data=0x55b543884610) at gmain.c:5579 8 g_main_dispatch (context=0x55b543719bc0) at gmain.c:3193 9 g_main_context_dispatch (context=context@entry=0x55b543719bc0) at gmain.c:3873 10 g_main_context_iterate (context=0x55b543719bc0, block=block@entry=1, dispatch=dispatch@entry=1, self=) at gmain.c:3946 --- src/core/devices/nm-device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index b70df02db1..f96efc6504 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -6122,7 +6122,8 @@ carrier_changed(NMDevice *self, gboolean carrier) nm_device_update_dynamic_ip_setup(self); /* If needed, also resume IP configuration that is * waiting for carrier. */ - nm_device_activate_schedule_stage3_ip_config(self, FALSE); + if (priv->state == NM_DEVICE_STATE_IP_CONFIG) + nm_device_activate_schedule_stage3_ip_config(self, FALSE); return; } /* fall-through and change state of device */ From 7faeda83517341121b60ade2362767d62104c420 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Oct 2021 09:44:32 +0200 Subject: [PATCH 026/110] platform: accept %NULL route as parameter to nm_platform_ip_route_get_gateway() It's sometimes convenient to accept %NULL and have a "maybe type" like behavior to propagate the %NULL input of the getter. --- src/libnm-platform/nm-platform.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index d3d8ae3070..4667125f24 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -2176,7 +2176,9 @@ static inline gconstpointer nm_platform_ip_route_get_gateway(int addr_family, const NMPlatformIPRoute *route) { nm_assert_addr_family(addr_family); - nm_assert(route); + + if (!route) + return NULL; if (NM_IS_IPv4(addr_family)) return &((NMPlatformIP4Route *) route)->gateway; From 682d2c842adaa7e27bc20bf028c81ca5a6842c23 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Oct 2021 11:56:18 +0200 Subject: [PATCH 027/110] core: drop redundant "gateway" variable for NMIPConfig The "gateway" variable was redundant to best_default_route. It was somewhat convenient to have, because the best_default_route pointer might change, but the next hop might still be the same. So it was easy to track whether it changes. But it's also redundant information. By relying on best_default_route alone we have all the information we need. --- src/core/nm-ip-config.c | 38 ++++++++++++++++++-------------------- src/core/nm-ip-config.h | 1 - 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/core/nm-ip-config.c b/src/core/nm-ip-config.c index 4bbe1e1a4a..b3e599400e 100644 --- a/src/core/nm-ip-config.c +++ b/src/core/nm-ip-config.c @@ -100,14 +100,17 @@ get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec g_value_set_variant(value, priv->v_address_data); break; case PROP_IP_GATEWAY: - if (priv->v_gateway.addr) { + if (priv->v_gateway.best_default_route) { + const NMIPAddr *gateway; + + gateway = nm_platform_ip_route_get_gateway( + addr_family, + NMP_OBJECT_CAST_IP_ROUTE(priv->v_gateway.best_default_route)); g_value_set_variant( value, - g_variant_new_string( - nm_utils_inet_ntop(addr_family, priv->v_gateway.addr, sbuf_addr))); - } else { + g_variant_new_string(nm_utils_inet_ntop(addr_family, gateway, sbuf_addr))); + } else g_value_set_variant(value, nm_g_variant_singleton_s_empty()); - } break; case PROP_IP_ROUTE_DATA: g_value_set_variant(value, priv->v_route_data); @@ -212,7 +215,6 @@ finalize(GObject *object) nm_g_variant_unref(priv->v_route_data); nm_g_variant_unref(priv->v_routes); - g_free(priv->v_gateway.addr); nmp_object_unref(priv->v_gateway.best_default_route); nm_l3_config_data_unref(priv->l3cd); @@ -763,21 +765,17 @@ _handle_platform_change(NMIPConfig *self, guint32 obj_type_flags, gboolean is_in } } - if (nmp_object_ref_set(&priv->v_gateway.best_default_route, best_default_route)) { - gconstpointer gateway_next_hop; - - gateway_next_hop = priv->v_gateway.best_default_route - ? nm_platform_ip_route_get_gateway( - addr_family, - NMP_OBJECT_CAST_IP_ROUTE(priv->v_gateway.best_default_route)) - : NULL; - - if (!nm_ip_addr_equal(addr_family, priv->v_gateway.addr, gateway_next_hop)) { - g_free(priv->v_gateway.addr); - priv->v_gateway.addr = - g_memdup(gateway_next_hop, nm_utils_addr_family_to_size(addr_family)); + if (priv->v_gateway.best_default_route != best_default_route) { + if (!nm_ip_addr_equal( + addr_family, + nm_platform_ip_route_get_gateway( + addr_family, + NMP_OBJECT_CAST_IP_ROUTE(priv->v_gateway.best_default_route)), + nm_platform_ip_route_get_gateway(addr_family, + NMP_OBJECT_CAST_IP_ROUTE(best_default_route)))) best_default_route_changed = TRUE; - } + + nmp_object_ref_set(&priv->v_gateway.best_default_route, best_default_route); } } diff --git a/src/core/nm-ip-config.h b/src/core/nm-ip-config.h index cfe964d0ee..5b2552e3a3 100644 --- a/src/core/nm-ip-config.h +++ b/src/core/nm-ip-config.h @@ -31,7 +31,6 @@ struct _NMIPConfigPrivate { GVariant * v_routes; struct { const NMPObject *best_default_route; - NMIPAddr * addr; } v_gateway; gulong l3cfg_notify_id; }; From d2fc0984a1a6a06531a956a35daf8f25e3a41235 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 30 Oct 2021 16:41:30 +0200 Subject: [PATCH 028/110] l3cd: add ipv6 token --- src/core/nm-l3-config-data.c | 30 ++++++++++++++++++++++++++++++ src/core/nm-l3-config-data.h | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index da933d5d04..02f9142a3c 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -120,6 +120,7 @@ struct _NML3ConfigData { NMSettingConnectionMdns mdns; NMSettingConnectionLlmnr llmnr; NMSettingConnectionDnsOverTls dns_over_tls; + NMUtilsIPv6IfaceId ip6_token; NML3ConfigDatFlags flags; @@ -581,6 +582,11 @@ nm_l3_config_data_log(const NML3ConfigData *self, NULL))); } + if (self->ip6_token.id != 0) { + _L("ipv6-token: %s", + nm_utils_inet6_interface_identifier_to_token(&self->ip6_token, sbuf_addr)); + } + if (self->metered != NM_TERNARY_DEFAULT) _L("metered: %s", self->metered ? "yes" : "no"); @@ -1849,6 +1855,26 @@ nm_l3_config_data_set_ip6_privacy(NML3ConfigData *self, NMSettingIP6ConfigPrivac return TRUE; } +NMUtilsIPv6IfaceId +nm_l3_config_data_get_ip6_token(const NML3ConfigData *self) +{ + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + + return self->ip6_token; +} + +gboolean +nm_l3_config_data_set_ip6_token(NML3ConfigData *self, NMUtilsIPv6IfaceId ipv6_token) +{ + nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + + if (self->ip6_token.id == ipv6_token.id) + return FALSE; + + self->ip6_token.id = ipv6_token.id; + return TRUE; +} + NMProxyConfigMethod nm_l3_config_data_get_proxy_method(const NML3ConfigData *self) { @@ -2158,6 +2184,7 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a, NM_CMP_DIRECT(a->mdns, b->mdns); NM_CMP_DIRECT(a->llmnr, b->llmnr); NM_CMP_DIRECT(a->dns_over_tls, b->dns_over_tls); + NM_CMP_DIRECT(a->ip6_token.id, b->ip6_token.id); NM_CMP_DIRECT(a->mtu, b->mtu); NM_CMP_DIRECT(a->ip6_mtu, b->ip6_mtu); NM_CMP_DIRECT_UNSAFE(a->metered, b->metered); @@ -3056,6 +3083,9 @@ nm_l3_config_data_merge(NML3ConfigData * self, if (self->dns_over_tls == NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT) self->dns_over_tls = src->dns_over_tls; + if (self->ip6_token.id == 0) + self->ip6_token.id = src->ip6_token.id; + self->metered = NM_MAX((NMTernary) self->metered, (NMTernary) src->metered); if (self->proxy_method == NM_PROXY_CONFIG_METHOD_UNKNOWN) diff --git a/src/core/nm-l3-config-data.h b/src/core/nm-l3-config-data.h index 2f9cfbbab8..1b3fa3cc16 100644 --- a/src/core/nm-l3-config-data.h +++ b/src/core/nm-l3-config-data.h @@ -451,6 +451,7 @@ NMSettingConnectionDnsOverTls nm_l3_config_data_get_dns_over_tls(const NML3Confi gboolean nm_l3_config_data_set_dns_over_tls(NML3ConfigData * self, NMSettingConnectionDnsOverTls dns_over_tls); + NMIPRouteTableSyncMode nm_l3_config_data_get_route_table_sync(const NML3ConfigData *self, int addr_family); @@ -475,6 +476,10 @@ guint32 nm_l3_config_data_get_ip6_mtu(const NML3ConfigData *self); gboolean nm_l3_config_data_set_ip6_mtu(NML3ConfigData *self, guint32 ip6_mtu); +NMUtilsIPv6IfaceId nm_l3_config_data_get_ip6_token(const NML3ConfigData *self); + +gboolean nm_l3_config_data_set_ip6_token(NML3ConfigData *self, NMUtilsIPv6IfaceId ipv6_token); + const in_addr_t *nm_l3_config_data_get_wins(const NML3ConfigData *self, guint *out_len); gboolean nm_l3_config_data_add_wins(NML3ConfigData *self, in_addr_t wins); From 70676b3d0a65901b3a07ea0d2926c888dafd0242 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sun, 31 Oct 2021 15:10:53 +0100 Subject: [PATCH 029/110] l3cfg: set ipv6 token Fixes-test: @ipv6_token --- src/core/devices/nm-device.c | 67 ++++++------------------- src/core/ndisc/nm-ndisc.c | 23 ++++++--- src/core/ndisc/nm-ndisc.h | 5 +- src/core/ndisc/tests/test-ndisc-fake.c | 2 +- src/core/ndisc/tests/test-ndisc-linux.c | 2 +- src/core/nm-l3-config-data.h | 1 - src/core/nm-l3cfg.c | 63 +++++++++++++++++++++++ 7 files changed, 98 insertions(+), 65 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index f96efc6504..b8495c0f0c 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -2839,50 +2839,6 @@ nm_device_sysctl_ip_conf_get_int_checked(NMDevice * self, fallback); } -static void -set_ipv6_token(NMDevice *self, const NMUtilsIPv6IfaceId *iid, const char *token_str) -{ - NMPlatform * platform; - int ifindex; - const NMPlatformLink *link; - char buf[32]; - gint64 val; - - /* Setting the kernel token is not strictly necessary as the - * IPv6 address is generated in userspace. However it is - * convenient so that users can see the token with iproute - * ('ip token'). */ - platform = nm_device_get_platform(self); - ifindex = nm_device_get_ip_ifindex(self); - link = nm_platform_link_get(platform, ifindex); - - if (link && link->inet6_token.id == iid->id) { - _LOGT(LOGD_DEVICE | LOGD_IP6, "token %s already set", token_str); - return; - } - - /* The kernel allows setting a token only when 'accept_ra' - * is 1: temporarily flip it if necessary; unfortunately - * this will also generate an additional Router Solicitation - * from kernel. */ - val = nm_device_sysctl_ip_conf_get_int_checked(self, - AF_INET6, - "accept_ra", - 10, - G_MININT32, - G_MAXINT32, - 1); - if (val != 1) - nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "1"); - - nm_platform_link_set_ipv6_token(platform, ifindex, iid); - - if (val != 1) { - nm_sprintf_buf(buf, "%d", (int) val); - nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", buf); - } -} - gboolean nm_device_sysctl_ip_conf_set(NMDevice * self, int addr_family, @@ -4672,6 +4628,7 @@ get_ip_iface_identifier(NMDevice *self, NMUtilsIPv6IfaceId *out_iid) * @self: an #NMDevice * @iid: where to place the interface identifier * @ignore_token: force creation of a non-tokenized address + * @out_is_token: on return, whether the identifier is tokenized * * Return the interface's identifier for the EUI64 address generation mode. * It's either a manually set token or and identifier generated in a @@ -4683,19 +4640,26 @@ get_ip_iface_identifier(NMDevice *self, NMUtilsIPv6IfaceId *out_iid) * Returns: #TRUE if the @iid could be set */ static gboolean -nm_device_get_ip_iface_identifier(NMDevice *self, NMUtilsIPv6IfaceId *iid, gboolean ignore_token) +nm_device_get_ip_iface_identifier(NMDevice * self, + NMUtilsIPv6IfaceId *iid, + gboolean ignore_token, + gboolean * out_is_token) { NMSettingIP6Config *s_ip6; const char * token = NULL; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); + NM_SET_OUT(out_is_token, FALSE); + if (!ignore_token) { s_ip6 = nm_device_get_applied_setting(self, NM_TYPE_SETTING_IP6_CONFIG); g_return_val_if_fail(s_ip6, FALSE); token = nm_setting_ip6_config_get_token(s_ip6); + if (token) + NM_SET_OUT(out_is_token, TRUE); } if (token) return nm_utils_ipv6_interface_identifier_get_from_token(iid, token); @@ -6470,7 +6434,7 @@ device_link_changed(gpointer user_data) } if (priv->ipac6_data.ndisc && pllink->inet6_token.id) { - if (nm_ndisc_set_iid(priv->ipac6_data.ndisc, pllink->inet6_token)) + if (nm_ndisc_set_iid(priv->ipac6_data.ndisc, pllink->inet6_token, TRUE)) _LOGD(LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface); } @@ -10631,7 +10595,7 @@ _dev_ipll6_start(NMDevice *self) } else { NMUtilsIPv6IfaceId iid; - if (!nm_device_get_ip_iface_identifier(self, &iid, TRUE)) { + if (!nm_device_get_ip_iface_identifier(self, &iid, TRUE, NULL)) { _LOGW(LOGD_IP6, "linklocal6: failed to get interface identifier; IPv6 cannot continue"); goto out_fail; } @@ -11241,6 +11205,7 @@ _dev_ipac6_start(NMDevice *self) guint32 ra_timeout; guint32 default_ra_timeout; NMUtilsIPv6IfaceId iid; + gboolean is_token; if (priv->ipac6_data.state == NM_DEVICE_IP_STATE_NONE) { if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR)) { @@ -11322,9 +11287,9 @@ _dev_ipac6_start(NMDevice *self) self); } - if (nm_device_get_ip_iface_identifier(self, &iid, FALSE)) { + if (nm_device_get_ip_iface_identifier(self, &iid, FALSE, &is_token)) { _LOGD_ipac6("using the device EUI-64 identifier"); - nm_ndisc_set_iid(priv->ipac6_data.ndisc, iid); + nm_ndisc_set_iid(priv->ipac6_data.ndisc, iid, is_token); } else { /* Don't abort the addrconf at this point -- if ndisc needs the iid * it will notice this itself. */ @@ -15040,12 +15005,10 @@ nm_device_cleanup(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanu /* Take out any entries in the routing table and any IP address the device had. */ if (ifindex > 0) { - NMPlatform * platform = nm_device_get_platform(self); - NMUtilsIPv6IfaceId iid = {}; + NMPlatform *platform = nm_device_get_platform(self); nm_platform_ip_route_flush(platform, AF_UNSPEC, ifindex); nm_platform_ip_address_flush(platform, AF_UNSPEC, ifindex); - set_ipv6_token(self, &iid, "::"); if (nm_device_get_applied_setting(self, NM_TYPE_SETTING_TC_CONFIG)) { nm_platform_tc_sync(platform, ifindex, NULL, NULL); diff --git a/src/core/ndisc/nm-ndisc.c b/src/core/ndisc/nm-ndisc.c index d870f5f119..670b0f39ce 100644 --- a/src/core/ndisc/nm-ndisc.c +++ b/src/core/ndisc/nm-ndisc.c @@ -57,6 +57,7 @@ struct _NMNDiscPrivate { GSource *timeout_expire_source; NMUtilsIPv6IfaceId iid; + gboolean iid_is_token; /* immutable values from here on: */ @@ -105,7 +106,8 @@ NML3ConfigData * nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, int ifindex, const NMNDiscData * rdata, - NMSettingIP6ConfigPrivacy ip6_privacy) + NMSettingIP6ConfigPrivacy ip6_privacy, + NMUtilsIPv6IfaceId * token) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; guint32 ifa_flags; @@ -195,6 +197,8 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, nm_l3_config_data_set_ndisc_retrans_timer_msec(l3cd, rdata->retrans_timer_ms); nm_l3_config_data_set_ip6_mtu(l3cd, rdata->mtu); + if (token) + nm_l3_config_data_set_ip6_token(l3cd, *token); return g_steal_pointer(&l3cd); } @@ -375,10 +379,12 @@ nm_ndisc_emit_config_change(NMNDisc *self, NMNDiscConfigMap changed) rdata = _data_complete(&NM_NDISC_GET_PRIVATE(self)->rdata), - l3cd = nm_l3_config_data_seal(nm_ndisc_data_to_l3cd(nm_l3cfg_get_multi_idx(priv->config.l3cfg), - nm_l3cfg_get_ifindex(priv->config.l3cfg), - rdata, - priv->config.ip6_privacy)); + l3cd = nm_ndisc_data_to_l3cd(nm_l3cfg_get_multi_idx(priv->config.l3cfg), + nm_l3cfg_get_ifindex(priv->config.l3cfg), + rdata, + priv->config.ip6_privacy, + priv->iid_is_token ? &priv->iid : NULL); + l3cd = nm_l3_config_data_seal(l3cd); if (!nm_l3_config_data_equal(priv->l3cd, l3cd)) NM_SWAP(&priv->l3cd, &l3cd); @@ -1084,15 +1090,16 @@ nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd) * Returns: %TRUE if addresses need to be regenerated, %FALSE otherwise. **/ gboolean -nm_ndisc_set_iid(NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid) +nm_ndisc_set_iid(NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid, gboolean is_token) { NMNDiscPrivate * priv; NMNDiscDataInternal *rdata; g_return_val_if_fail(NM_IS_NDISC(ndisc), FALSE); - priv = NM_NDISC_GET_PRIVATE(ndisc); - rdata = &priv->rdata; + priv = NM_NDISC_GET_PRIVATE(ndisc); + priv->iid_is_token = is_token; + rdata = &priv->rdata; if (priv->iid.id != iid.id) { priv->iid = iid; diff --git a/src/core/ndisc/nm-ndisc.h b/src/core/ndisc/nm-ndisc.h index 90f574a90b..dc6ab078bf 100644 --- a/src/core/ndisc/nm-ndisc.h +++ b/src/core/ndisc/nm-ndisc.h @@ -225,7 +225,7 @@ int nm_ndisc_get_ifindex(NMNDisc *self); const char * nm_ndisc_get_ifname(NMNDisc *self); NMNDiscNodeType nm_ndisc_get_node_type(NMNDisc *self); -gboolean nm_ndisc_set_iid(NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid); +gboolean nm_ndisc_set_iid(NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid, gboolean is_token); void nm_ndisc_start(NMNDisc *ndisc); void nm_ndisc_stop(NMNDisc *ndisc); NMNDiscConfigMap @@ -279,6 +279,7 @@ struct _NML3ConfigData; struct _NML3ConfigData *nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, int ifindex, const NMNDiscData * rdata, - NMSettingIP6ConfigPrivacy ip6_privacy); + NMSettingIP6ConfigPrivacy ip6_privacy, + NMUtilsIPv6IfaceId * token); #endif /* __NETWORKMANAGER_NDISC_H__ */ diff --git a/src/core/ndisc/tests/test-ndisc-fake.c b/src/core/ndisc/tests/test-ndisc-fake.c index 8cfb9ddc16..e98e158c1c 100644 --- a/src/core/ndisc/tests/test-ndisc-fake.c +++ b/src/core/ndisc/tests/test-ndisc-fake.c @@ -32,7 +32,7 @@ ndisc_new(void) memset(&iid, 0, sizeof(iid)); iid.id_u8[7] = 1; - nm_ndisc_set_iid(ndisc, iid); + nm_ndisc_set_iid(ndisc, iid, FALSE); return NM_FAKE_NDISC(ndisc); } diff --git a/src/core/ndisc/tests/test-ndisc-linux.c b/src/core/ndisc/tests/test-ndisc-linux.c index a4db5efaa5..4c2848088d 100644 --- a/src/core/ndisc/tests/test-ndisc-linux.c +++ b/src/core/ndisc/tests/test-ndisc-linux.c @@ -84,7 +84,7 @@ main(int argc, char **argv) } iid.id_u8[7] = 1; - nm_ndisc_set_iid(ndisc, iid); + nm_ndisc_set_iid(ndisc, iid, FALSE); nm_ndisc_start(ndisc); g_main_loop_run(loop); diff --git a/src/core/nm-l3-config-data.h b/src/core/nm-l3-config-data.h index 1b3fa3cc16..dfaf18549a 100644 --- a/src/core/nm-l3-config-data.h +++ b/src/core/nm-l3-config-data.h @@ -451,7 +451,6 @@ NMSettingConnectionDnsOverTls nm_l3_config_data_get_dns_over_tls(const NML3Confi gboolean nm_l3_config_data_set_dns_over_tls(NML3ConfigData * self, NMSettingConnectionDnsOverTls dns_over_tls); - NMIPRouteTableSyncMode nm_l3_config_data_get_route_table_sync(const NML3ConfigData *self, int addr_family); diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 02456d5b95..e84c0ef75f 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -3938,6 +3938,68 @@ set: ip6_privacy_to_str(ip6_privacy)); } +static void +_l3_commit_ip6_token(NML3Cfg *self, NML3CfgCommitType commit_type) +{ + NMUtilsIPv6IfaceId token; + const NMPlatformLink *pllink; + int val; + + if (commit_type < NM_L3_CFG_COMMIT_TYPE_UPDATE || !self->priv.p->combined_l3cd_commited) + token.id = 0; + else + token = nm_l3_config_data_get_ip6_token(self->priv.p->combined_l3cd_commited); + + pllink = nm_l3cfg_get_pllink(self, TRUE); + if (!pllink || pllink->inet6_token.id == token.id) + return; + + if (_LOGT_ENABLED()) { + struct in6_addr addr = {}; + struct in6_addr addr_old = {}; + char addr_str[INET6_ADDRSTRLEN]; + char addr_str_old[INET6_ADDRSTRLEN]; + + nm_utils_ipv6_addr_set_interface_identifier(&addr, &token); + nm_utils_ipv6_addr_set_interface_identifier(&addr_old, &pllink->inet6_token); + + _LOGT("commit-ip6-token: set value %s (was %s)", + inet_ntop(AF_INET6, &addr, addr_str, INET6_ADDRSTRLEN), + inet_ntop(AF_INET6, &addr_old, addr_str_old, INET6_ADDRSTRLEN)); + } + + /* The kernel allows setting a token only when 'accept_ra' + * is 1: temporarily flip it if necessary; unfortunately + * this will also generate an additional Router Solicitation + * from kernel. */ + val = nm_platform_sysctl_ip_conf_get_int_checked(self->priv.platform, + AF_INET6, + pllink->name, + "accept_ra", + 10, + G_MININT32, + G_MAXINT32, + 1); + + if (val != 1) { + nm_platform_sysctl_ip_conf_set(self->priv.platform, + AF_INET6, + pllink->name, + "accept_ra", + "1"); + } + + nm_platform_link_set_ipv6_token(self->priv.platform, self->priv.ifindex, &token); + + if (val != 1) { + nm_platform_sysctl_ip_conf_set_int64(self->priv.platform, + AF_INET6, + pllink->name, + "accept_ra", + val); + } +} + static gboolean _l3_commit_one(NML3Cfg * self, int addr_family, @@ -3995,6 +4057,7 @@ _l3_commit_one(NML3Cfg * self, if (!IS_IPv4) { _l3_commit_ip6_privacy(self, commit_type); _l3_commit_ndisc_params(self, commit_type); + _l3_commit_ip6_token(self, commit_type); } if (route_table_sync == NM_IP_ROUTE_TABLE_SYNC_MODE_NONE) From e9bd8b3dacdd60267029f5d6295096ecb88193b1 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Fri, 5 Nov 2021 17:47:07 +0100 Subject: [PATCH 030/110] device: fix wrong assignment in ip_state_other comparison Fixes: 0b05c5adb4b0 ('device: fail when a addr family fails and the other is disabled') --- src/core/devices/nm-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index b8495c0f0c..2348f017ef 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -3259,7 +3259,7 @@ got_ip_state: else if ((ip_state == NM_DEVICE_IP_STATE_FAILED || (ip_state == NM_DEVICE_IP_STATE_READY && disabled_or_ignore)) && (ip_state_other == NM_DEVICE_IP_STATE_FAILED - || (ip_state_other = NM_DEVICE_IP_STATE_READY && disabled_or_ignore_other))) { + || (ip_state_other == NM_DEVICE_IP_STATE_READY && disabled_or_ignore_other))) { /* If both IP states failed, or one failed and the other is disabled * then it's a failure. may-fail does not mean that both families may * fail, instead it means that at least one family must succeed. */ From de5e1eb9e5d2d47b01dc18c895b7cafce0832ca2 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 4 Nov 2021 17:17:16 +0100 Subject: [PATCH 031/110] device: don't fail immediately on DHCP expiry If we had a lease and it expired, don't fail immediately. The client will try to obtain a new lease and it will send a NO_LEASE_TIMEOUT event once it fails. Only at that time we should fail. --- src/core/devices/nm-device.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 2348f017ef..19796cf62b 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -9965,7 +9965,6 @@ _dev_ipdhcpx_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_d if (!notify_data->lease_update.l3cd) { _LOGT_ipdhcp(addr_family, "lease lost"); - _dev_ipdhcpx_handle_fail(self, addr_family, "lease lost"); return; } From a31919333321a9fbda2044044529abe62b90547a Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 4 Nov 2021 17:19:02 +0100 Subject: [PATCH 032/110] device: fix optional 802.1X authentication If the authentication is optional, we are going to re-enter stage2. Set the "ready" variable so that we can return success immediately and skip to stage3. --- src/core/devices/nm-device-ethernet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/devices/nm-device-ethernet.c b/src/core/devices/nm-device-ethernet.c index 52fce56943..d89bd7371c 100644 --- a/src/core/devices/nm-device-ethernet.c +++ b/src/core/devices/nm-device-ethernet.c @@ -479,6 +479,7 @@ wired_auth_cond_fail(NMDeviceEthernet *self, NMDeviceStateReason reason) _LOGI(LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) 802.1X authentication is optional, continuing after a failure"); + priv->supplicant.ready = TRUE; if (NM_IN_SET(nm_device_get_state(device), NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_NEED_AUTH)) nm_device_activate_schedule_stage2_device_config(device, FALSE); From bd7b5aa707d19f090a9a8d386f076480e6abe04c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 5 Nov 2021 15:17:33 +0100 Subject: [PATCH 033/110] device: don't disable IPv6 when NM is managing IPv6 If NM set addrgenmode=none, it's because it manages the IPv6 in user space. In such case it should never disable IPv6. --- src/core/devices/nm-device.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 19796cf62b..8314a9771a 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -11398,6 +11398,14 @@ _dev_sysctl_restore_ip6_properties(NMDevice *self) static void _dev_sysctl_set_disable_ipv6(NMDevice *self, gboolean do_disable) { + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + /* If we previously set addrgenmode=none, we are managing + * IPv6 in user space and we should not disable it. */ + if (do_disable && priv->addrgenmode6_data.previous_mode_has + && priv->addrgenmode6_data.previous_mode_val == NM_IN6_ADDR_GEN_MODE_NONE) + return; + nm_device_sysctl_ip_conf_set(self, AF_INET6, "disable_ipv6", do_disable ? "1" : "0"); } From cd65351d29c41755c96349ec1435a85f9e56148e Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 5 Nov 2021 15:19:09 +0100 Subject: [PATCH 034/110] device: fix _dev_addrgenmode6_set() If addrgenmode=0 is already set, the function should still toggle disable_ipv6 if needed, to stop the generation of temporary addresses. Also, it should store the last set value into 'previous_mode_val'. Fixes-test: @ipv6_keep_external_routes --- src/core/devices/nm-device.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 8314a9771a..0392d54b6a 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -11442,24 +11442,26 @@ _dev_addrgenmode6_set(NMDevice *self, guint8 addr_gen_mode) nm_platform_link_inet6_addrgenmode2str(addr_gen_mode, sbuf, sizeof(sbuf)), (cur_addr_gen_mode == addr_gen_mode) ? " (already set)" : ""); - if (cur_addr_gen_mode == addr_gen_mode) - return; - - r = nm_platform_link_set_inet6_addr_gen_mode(nm_device_get_platform(self), - ifindex, - addr_gen_mode); - if (r < 0) { - _NMLOG_ip(NM_IN_SET(r, -NME_PL_NOT_FOUND, -NME_PL_OPNOTSUPP) ? LOGL_DEBUG : LOGL_WARN, - AF_INET6, - "addrgenmode6: failed to set %s: (%s)", - nm_platform_link_inet6_addrgenmode2str(addr_gen_mode, sbuf, sizeof(sbuf)), - nm_strerror(r)); + if (cur_addr_gen_mode != addr_gen_mode) { + r = nm_platform_link_set_inet6_addr_gen_mode(nm_device_get_platform(self), + ifindex, + addr_gen_mode); + if (r < 0) { + _NMLOG_ip(NM_IN_SET(r, -NME_PL_NOT_FOUND, -NME_PL_OPNOTSUPP) ? LOGL_DEBUG : LOGL_WARN, + AF_INET6, + "addrgenmode6: failed to set %s: (%s)", + nm_platform_link_inet6_addrgenmode2str(addr_gen_mode, sbuf, sizeof(sbuf)), + nm_strerror(r)); + } else { + priv->addrgenmode6_data.previous_mode_val = addr_gen_mode; + } } if (addr_gen_mode == NM_IN6_ADDR_GEN_MODE_NONE) { gs_free char *value = NULL; - /* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */ + /* Bounce IPv6 to ensure the kernel stops IPv6LL address and temporary + * address generation */ _LOGD_ip(AF_INET6, "addrgenmode6: toggle disable_ipv6 sysctl after disabling addr-gen-mode"); value = nm_device_sysctl_ip_conf_get(self, AF_INET6, "disable_ipv6"); From 3a0eb586b8e1544bf68c27d08aefd9e9f62f76d7 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 8 Nov 2021 14:26:27 +0100 Subject: [PATCH 035/110] device: don't reset addrgenmode for assumed devices If we reset the addrgenmode, IPv6 addresses are lost. --- src/core/devices/nm-device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 0392d54b6a..204cb5c407 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -11816,7 +11816,8 @@ activate_stage3_ip_config(NMDevice *self) * IPv6LL if this is not an assumed connection, since assumed connections * will already have IPv6 set up. */ - _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); + if (!nm_device_sys_iface_state_is_external_or_assume(self)) + _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); /* Re-enable IPv6 on the interface */ nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "0"); From 655896f75b03243f86f226e2e3bf2b1525e9b503 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 9 Nov 2021 19:45:07 +0100 Subject: [PATCH 036/110] device: set ipv6 privacy in the the ipmanual l3cd In this way, the ipv6 privacy setting is committed as soon as the connection goes up. Fixes-test: @ipv6_ip6-default_privacy --- src/core/devices/nm-device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 204cb5c407..159f2abd6e 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -2636,6 +2636,7 @@ nm_device_create_l3_config_data_from_connection(NMDevice *self, NMConnection *co nm_l3_config_data_set_mdns(l3cd, _prop_get_connection_mdns(self)); nm_l3_config_data_set_llmnr(l3cd, _prop_get_connection_llmnr(self)); nm_l3_config_data_set_dns_over_tls(l3cd, _prop_get_connection_dns_over_tls(self)); + nm_l3_config_data_set_ip6_privacy(l3cd, _prop_get_ipv6_ip6_privacy(self)); return l3cd; } From 81ac02ae75e7f2d370d86cdd939f6694c6796f24 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Sun, 7 Nov 2021 17:06:03 -0500 Subject: [PATCH 037/110] core: clear sticky update flag when unmanaging a device Sticky update flag forces a commit at UPDATE level after unmanaging a device. As a result, all the link local addresses will be removed. To prevent the commit after unmanaging a device, clear sticky update flag. Signed-off-by: Wen Liang --- src/core/devices/nm-device.c | 2 ++ src/core/nm-l3cfg.c | 14 ++++++++++++++ src/core/nm-l3cfg.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 159f2abd6e..3711459820 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -3924,6 +3924,8 @@ _dev_l3_cfg_commit_type_reset(NMDevice *self) do_set: priv->l3cfg_commit_type = nm_l3cfg_commit_type_register(priv->l3cfg, commit_type, priv->l3cfg_commit_type, "device"); + if (commit_type == NM_L3_CFG_COMMIT_TYPE_NONE) + nm_l3cfg_commit_type_reset_update(priv->l3cfg); } /*****************************************************************************/ diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index e84c0ef75f..9c92f5cd53 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -4310,6 +4310,20 @@ nm_l3cfg_commit_type_unregister(NML3Cfg *self, NML3CfgCommitTypeHandle *handle) nm_g_slice_free(handle); } +void +nm_l3cfg_commit_type_reset_update(NML3Cfg *self) +{ + NML3CfgCommitTypeHandle *h; + + c_list_for_each_entry (h, &self->priv.p->commit_type_lst_head, commit_type_lst) { + if (h->commit_type >= NM_L3_CFG_COMMIT_TYPE_UPDATE) { + return; + } + } + + self->priv.p->commit_type_update_sticky = FALSE; +} + /*****************************************************************************/ const NML3ConfigData * diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h index 5eca683a90..35560142be 100644 --- a/src/core/nm-l3cfg.h +++ b/src/core/nm-l3cfg.h @@ -426,6 +426,8 @@ nm_l3cfg_commit_type_clear(NML3Cfg *self, NML3CfgCommitTypeHandle **handle) return TRUE; } +void nm_l3cfg_commit_type_reset_update(NML3Cfg *self); + /*****************************************************************************/ const NML3ConfigData *nm_l3cfg_get_combined_l3cd(NML3Cfg *self, gboolean get_commited); From 6b4123db1ce7aff16254976f7bc558b2fe4a9b69 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Wed, 10 Nov 2021 11:02:17 +0100 Subject: [PATCH 038/110] l3cfg: do not add dependent routes for non-default routes When the route is not a default route 0.0.0.0/0, NetworkManager should not add dependent routes. Signed-off-by: Fernando Fernandez Mancera --- src/core/nm-l3-config-data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index 02f9142a3c..bf0f976252 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -2385,7 +2385,8 @@ nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_fam if (nm_ip_addr_is_null(addr_family, p_gateway)) continue; - if (_data_get_direct_route_for_host( + if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route_src) + || _data_get_direct_route_for_host( self, addr_family, p_gateway, From bce13b0b2f98864fda03925e5d8a93023a937453 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 12 Nov 2021 15:41:18 +0100 Subject: [PATCH 039/110] dhcp: schedule a timeout when starting the client 'no_lease_timeout' is the timeout to get the initial lease and to renew it once it was lost. It should be scheduled when the client is started. Fixes-test: @dhcp4_outages_in_various_situation --- src/core/dhcp/nm-dhcp-client.c | 45 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index 484ec34e72..71da40b707 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -238,6 +238,25 @@ nm_dhcp_client_get_config(NMDhcpClient *self) return &priv->config; } +static void +schedule_no_lease_timeout(NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + + if (priv->no_lease_timeout_source) + return; + + if (priv->config.timeout == NM_DHCP_TIMEOUT_INFINITY) { + _LOGI("activation: beginning transaction (no timeout)"); + priv->no_lease_timeout_source = g_source_ref(nm_g_source_sentinel_get(0)); + } else { + _LOGI("activation: beginning transaction (timeout in %u seconds)", + (guint) priv->config.timeout); + priv->no_lease_timeout_source = + nm_g_timeout_add_seconds_source(priv->config.timeout, _no_lease_timeout, self); + } +} + void nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3ConfigData *l3cd) { @@ -271,19 +290,11 @@ nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3Co if (priv->l3cd == l3cd) return; - if (l3cd) + if (l3cd) { nm_clear_g_source_inst(&priv->no_lease_timeout_source); - else { - /* FIXME(l3cfg:dhcp): we also need to start no_lease_timeout initially, if the - * instance starts without a previous_lease. */ - if (!priv->no_lease_timeout_source && priv->l3cd) { - if (priv->config.timeout == NM_DHCP_TIMEOUT_INFINITY) - priv->no_lease_timeout_source = g_source_ref(nm_g_source_sentinel_get(0)); - else { - priv->no_lease_timeout_source = - nm_g_timeout_add_seconds_source(priv->config.timeout, _no_lease_timeout, self); - } - } + } else { + if (priv->l3cd) + schedule_no_lease_timeout(self); } /* FIXME(l3cfg:dhcp): the API of NMDhcpClient is changing to expose a simpler API. @@ -444,11 +455,7 @@ nm_dhcp_client_start_ip4(NMDhcpClient *self, GError **error) g_return_val_if_fail(priv->config.addr_family == AF_INET, FALSE); g_return_val_if_fail(priv->config.uuid, FALSE); - if (priv->config.timeout == NM_DHCP_TIMEOUT_INFINITY) - _LOGI("activation: beginning transaction (no timeout)"); - else - _LOGI("activation: beginning transaction (timeout in %u seconds)", - (guint) priv->config.timeout); + schedule_no_lease_timeout(self); return NM_DHCP_CLIENT_GET_CLASS(self)->ip4_start(self, error); } @@ -568,6 +575,8 @@ l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMDhcp g_signal_handlers_disconnect_by_func(l3cfg, l3_cfg_notify_cb, self); nm_clear_g_source_inst(&priv->ipv6_lladdr_timeout_source); + schedule_no_lease_timeout(self); + if (!NM_DHCP_CLIENT_GET_CLASS(self)->ip6_start(self, &addr->address, &error)) { _emit_notify(self, &((NMDhcpClientNotifyData){ @@ -617,6 +626,8 @@ nm_dhcp_client_start_ip6(NMDhcpClient *self, GError **error) return TRUE; } + schedule_no_lease_timeout(self); + return NM_DHCP_CLIENT_GET_CLASS(self)->ip6_start(self, &addr->address, error); } From 6ac95047caf65edfb0c2005e46e5e207346a3a07 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 12 Nov 2021 15:49:34 +0100 Subject: [PATCH 040/110] dhcp: remove old timeout code There is already the 'no_lease_timeout'. --- src/core/dhcp/nm-dhcp-client.c | 49 -------------------------------- src/core/dhcp/nm-dhcp-nettools.c | 2 -- src/core/dhcp/nm-dhcp-systemd.c | 2 -- 3 files changed, 53 deletions(-) diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index 71da40b707..dede18e540 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -44,7 +44,6 @@ typedef struct _NMDhcpClientPrivate { GSource * no_lease_timeout_source; GSource * ipv6_lladdr_timeout_source; pid_t pid; - guint timeout_id; guint watch_id; NMDhcpState state; bool iaid_explicit : 1; @@ -165,14 +164,6 @@ reason_to_state(NMDhcpClient *self, const char *iface, const char *reason) /*****************************************************************************/ -static void -timeout_cleanup(NMDhcpClient *self) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - - nm_clear_g_source(&priv->timeout_id); -} - static void watch_cleanup(NMDhcpClient *self) { @@ -276,8 +267,6 @@ nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3Co if (l3cd) nm_l3_config_data_seal(l3cd); - if (new_state >= NM_DHCP_STATE_BOUND) - timeout_cleanup(self); if (new_state >= NM_DHCP_STATE_TIMEOUT) watch_cleanup(self); @@ -372,19 +361,6 @@ nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3Co } } -/* FIXME(l3cfg:dhcp) */ -_nm_unused static gboolean -transaction_timeout(gpointer user_data) -{ - NMDhcpClient * self = NM_DHCP_CLIENT(user_data); - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - - priv->timeout_id = 0; - _LOGW("request timed out"); - nm_dhcp_client_set_state(self, NM_DHCP_STATE_TIMEOUT, NULL); - return G_SOURCE_REMOVE; -} - static void daemon_watch_cb(GPid pid, int status, gpointer user_data) { @@ -402,21 +378,6 @@ daemon_watch_cb(GPid pid, int status, gpointer user_data) nm_dhcp_client_set_state(self, NM_DHCP_STATE_TERMINATED, NULL); } -void -nm_dhcp_client_start_timeout(NMDhcpClient *self) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - - g_return_if_fail(priv->timeout_id == 0); - - /* Set up a timeout on the transaction to kill it after the timeout */ - - /* FIXME(l3cfg:dhcp): no-lease-timeout is only for convenience for the user (NMDevice). - * Whatever the purpose of nm_dhcp_client_start_timeout() is, it is not the same timer. */ - return; - //priv->timeout_id = g_timeout_add_seconds(priv->no_lease_timeout, transaction_timeout, self); -} - void nm_dhcp_client_watch_child(NMDhcpClient *self, pid_t pid) { @@ -425,8 +386,6 @@ nm_dhcp_client_watch_child(NMDhcpClient *self, pid_t pid) g_return_if_fail(priv->pid == -1); priv->pid = pid; - nm_dhcp_client_start_timeout(self); - g_return_if_fail(priv->watch_id == 0); priv->watch_id = g_child_watch_add(pid, daemon_watch_cb, self); } @@ -440,7 +399,6 @@ nm_dhcp_client_stop_watch_child(NMDhcpClient *self, pid_t pid) priv->pid = -1; watch_cleanup(self); - timeout_cleanup(self); } gboolean @@ -608,12 +566,6 @@ nm_dhcp_client_start_ip6(NMDhcpClient *self, GError **error) _set_effective_client_id(self, own_client_id ?: priv->config.client_id, FALSE); - if (priv->config.timeout == NM_DHCP_TIMEOUT_INFINITY) - _LOGI("activation: beginning transaction (no timeout)"); - else - _LOGI("activation: beginning transaction (timeout in %u seconds)", - (guint) priv->config.timeout); - addr = ipv6_lladdr_find(self); if (!addr) { _LOGD("waiting for IPv6LL address"); @@ -1140,7 +1092,6 @@ dispose(GObject *object) nm_dhcp_client_stop(self, FALSE); watch_cleanup(self); - timeout_cleanup(self); nm_clear_g_source_inst(&priv->no_lease_timeout_source); nm_clear_g_source_inst(&priv->ipv6_lladdr_timeout_source); diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c index 6ab7f8c18d..e8e3a2f1e4 100644 --- a/src/core/dhcp/nm-dhcp-nettools.c +++ b/src/core/dhcp/nm-dhcp-nettools.c @@ -1208,8 +1208,6 @@ ip4_start(NMDhcpClient *client, GError **error) } _LOGT("dhcp-client4: start " NM_HASH_OBFUSCATE_PTR_FMT, NM_HASH_OBFUSCATE_PTR(priv->client)); - - nm_dhcp_client_start_timeout(client); return TRUE; } diff --git a/src/core/dhcp/nm-dhcp-systemd.c b/src/core/dhcp/nm-dhcp-systemd.c index f5b75b50de..7c3c289996 100644 --- a/src/core/dhcp/nm-dhcp-systemd.c +++ b/src/core/dhcp/nm-dhcp-systemd.c @@ -752,7 +752,6 @@ ip4_start(NMDhcpClient *client, GError **error) return FALSE; } - nm_dhcp_client_start_timeout(client); return TRUE; } @@ -1049,7 +1048,6 @@ ip6_start(NMDhcpClient *client, const struct in6_addr *ll_addr, GError **error) return FALSE; } - nm_dhcp_client_start_timeout(client); return TRUE; } From b85a9cd9df540e9ee7adc40fcdef56a8bf314d1f Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Tue, 9 Nov 2021 12:07:45 +0100 Subject: [PATCH 041/110] device: set ip_state to PENDING when cleaning up from reapply When doing a reapply the ip_state must be set as PENDING, if not the ipdhcp_state won't be extended to ip_state. In addition, if one of the IP configuration is ready and the other may fail, then we should consider it ready. The other ip state does not matter at all, it can be none too. Fixes-test: @nmcli_device_reapply_routes --- src/core/devices/nm-device.c | 37 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 3711459820..078dc16a5d 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -833,7 +833,8 @@ static void _dev_ipshared4_spawn_dnsmasq(NMDevice *self); static void _dev_ipshared6_start(NMDevice *self); -static void _cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type); +static void +_cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type, gboolean from_reapply); static void concheck_update_state(NMDevice * self, int addr_family, @@ -3246,10 +3247,6 @@ got_ip_state: &may_fail_other))) combinedip_state = NM_DEVICE_IP_STATE_PENDING; else if (ip_state == NM_DEVICE_IP_STATE_READY - && NM_IN_SET(ip_state_other, - NM_DEVICE_IP_STATE_PENDING, - NM_DEVICE_IP_STATE_READY, - NM_DEVICE_IP_STATE_FAILED) && _prop_get_ipvx_may_fail_cached(self, nm_utils_addr_family_other(addr_family), &may_fail_other)) @@ -3350,13 +3347,16 @@ _dev_ip_state_check_async(NMDevice *self, int addr_family) } static void -_dev_ip_state_cleanup(NMDevice *self, int addr_family) +_dev_ip_state_cleanup(NMDevice *self, int addr_family, gboolean from_reapply) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); int IS_IPv4; if (addr_family == AF_UNSPEC) { - _dev_ip_state_set_state(self, addr_family, NM_DEVICE_IP_STATE_NONE, "ip-state-clear"); + _dev_ip_state_set_state(self, + addr_family, + from_reapply ? NM_DEVICE_IP_STATE_PENDING : NM_DEVICE_IP_STATE_NONE, + "ip-state-clear"); return; } @@ -3364,7 +3364,10 @@ _dev_ip_state_cleanup(NMDevice *self, int addr_family) nm_clear_g_source_inst(&priv->ip_data_x[IS_IPv4].check_async_source); nm_clear_g_source_inst(&priv->ip_data_x[IS_IPv4].req_timeout_source); - _dev_ip_state_set_state(self, addr_family, NM_DEVICE_IP_STATE_NONE, "ip-state-clear"); + _dev_ip_state_set_state(self, + addr_family, + from_reapply ? NM_DEVICE_IP_STATE_PENDING : NM_DEVICE_IP_STATE_NONE, + "ip-state-clear"); priv->ip_data_x[IS_IPv4].wait_for_carrier = FALSE; priv->ip_data_x[IS_IPv4].wait_for_ports = FALSE; priv->ip_data_x[IS_IPv4].is_disabled = FALSE; @@ -11744,11 +11747,11 @@ activate_stage3_ip_config(NMDevice *self) if (priv->ip_data_4.do_reapply) { _LOGD_ip(AF_INET, "reapply..."); - _cleanup_ip_pre(self, AF_INET, CLEANUP_TYPE_DECONFIGURE); + _cleanup_ip_pre(self, AF_INET, CLEANUP_TYPE_DECONFIGURE, TRUE); } if (priv->ip_data_6.do_reapply) { _LOGD_ip(AF_INET6, "reapply..."); - _cleanup_ip_pre(self, AF_INET6, CLEANUP_TYPE_DECONFIGURE); + _cleanup_ip_pre(self, AF_INET6, CLEANUP_TYPE_DECONFIGURE, TRUE); } /* Add the interface to the specified firewall zone */ @@ -12247,7 +12250,7 @@ delete_on_deactivate_check_and_schedule(NMDevice *self) } static void -_cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type) +_cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type, gboolean from_reapply) { const int IS_IPv4 = NM_IS_IPv4(addr_family); @@ -12265,8 +12268,8 @@ _cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type) _dev_ipmanual_cleanup(self); - _dev_ip_state_cleanup(self, AF_UNSPEC); - _dev_ip_state_cleanup(self, addr_family); + _dev_ip_state_cleanup(self, AF_UNSPEC, from_reapply); + _dev_ip_state_cleanup(self, addr_family, from_reapply); } gboolean @@ -14923,8 +14926,8 @@ _cleanup_generic_pre(NMDevice *self, CleanupType cleanup_type) for (i = 0; i < 2; i++) nm_clear_pointer(&priv->hostname_resolver_x[i], _hostname_resolver_free); - _cleanup_ip_pre(self, AF_INET, cleanup_type); - _cleanup_ip_pre(self, AF_INET6, cleanup_type); + _cleanup_ip_pre(self, AF_INET, cleanup_type, FALSE); + _cleanup_ip_pre(self, AF_INET6, cleanup_type, FALSE); _dev_ip_state_req_timeout_cancel(self, AF_UNSPEC); } @@ -15424,8 +15427,8 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, /* Clean up any half-done IP operations if the device's layer2 * finds out it needs authentication during IP config. */ - _cleanup_ip_pre(self, AF_INET, CLEANUP_TYPE_DECONFIGURE); - _cleanup_ip_pre(self, AF_INET6, CLEANUP_TYPE_DECONFIGURE); + _cleanup_ip_pre(self, AF_INET, CLEANUP_TYPE_DECONFIGURE, FALSE); + _cleanup_ip_pre(self, AF_INET6, CLEANUP_TYPE_DECONFIGURE, FALSE); } break; default: From 8995d44a0bae51c8bb41bc0a9d4e7b2ec9cb92af Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Wed, 10 Nov 2021 21:13:38 -0500 Subject: [PATCH 042/110] core: compare the DNS configurations before updating DNS DNS manager always sets `priv->config_changed = TRUE` and overwrites the "resolv.conf" file. To fix it, compare the new configuration with the old configuration, if there is no change, skipping the update. Fixes-test: @ipv4_ignore_resolveconf_with_ignore_auto_dns Fixes-test: @ipv4_ignore_resolveconf_with_ignore_auto_dns_var1 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1023 --- src/core/dns/nm-dns-manager.c | 39 +++++++++++++++++++ src/core/nm-config-data.c | 55 +++++++++++++++++++++++++++ src/core/nm-config-data.h | 3 +- src/core/nm-ip-config.c | 71 +++++++++++++++++++++++++++++++++++ src/core/nm-ip-config.h | 2 + 5 files changed, 169 insertions(+), 1 deletion(-) diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c index 15072f799d..4fe7945033 100644 --- a/src/core/dns/nm-dns-manager.c +++ b/src/core/dns/nm-dns-manager.c @@ -35,6 +35,7 @@ #include "nm-dns-plugin.h" #include "nm-dns-systemd-resolved.h" #include "nm-dns-unbound.h" +#include "nm-ip-config.h" #include "nm-l3-config-data.h" #include "nm-manager.h" #include "nm-utils.h" @@ -99,6 +100,9 @@ typedef struct { char *hostname; guint updates_queue; + guint8 hash[HASH_LEN]; /* SHA1 hash of current DNS config */ + guint8 prev_hash[HASH_LEN]; /* Hash when begin_updates() was called */ + NMDnsManagerResolvConfManager rc_manager; char * mode; NMDnsPlugin * sd_resolve_plugin; @@ -1097,6 +1101,30 @@ update_resolv_conf(NMDnsManager * self, return write_file_result; } +static void +compute_hash(NMDnsManager *self, const NMGlobalDnsConfig *global, guint8 buffer[static HASH_LEN]) +{ + nm_auto_free_checksum GChecksum *sum = NULL; + NMDnsConfigIPData * ip_data; + + sum = g_checksum_new(G_CHECKSUM_SHA1); + nm_assert(HASH_LEN == g_checksum_type_get_length(G_CHECKSUM_SHA1)); + + if (global) + nm_global_dns_config_update_checksum(global, sum); + else { + const CList *head; + + /* FIXME(ip-config-checksum): this relies on the fact that an IP + * configuration without DNS parameters gives a zero checksum. */ + head = _mgr_get_ip_data_lst_head(self); + c_list_for_each_entry (ip_data, head, ip_data_lst) + nm_ip_config_dns_hash(ip_data->l3cd, sum, ip_data->addr_family); + } + + nm_utils_checksum_get_digest_len(sum, buffer, HASH_LEN); +} + static gboolean merge_global_dns_config(NMResolvConfData *rc, NMGlobalDnsConfig *global_conf) { @@ -1649,6 +1677,9 @@ update_dns(NMDnsManager *self, gboolean no_caching, gboolean force_emit, GError data = nm_config_get_data(priv->config); global_config = nm_config_data_get_global_dns_config(data); + /* Update hash with config we're applying */ + compute_hash(self, global_config, priv->hash); + _collect_resolv_conf_data(self, global_config, &searches, @@ -2006,6 +2037,10 @@ nm_dns_manager_begin_updates(NMDnsManager *self, const char *func) priv = NM_DNS_MANAGER_GET_PRIVATE(self); + /* Save current hash when starting a new batch */ + if (priv->updates_queue == 0) + memcpy(priv->prev_hash, priv->hash, sizeof(priv->hash)); + priv->updates_queue++; _LOGD("(%s): queueing DNS updates (%d)", func, priv->updates_queue); @@ -2016,12 +2051,15 @@ nm_dns_manager_end_updates(NMDnsManager *self, const char *func) { NMDnsManagerPrivate *priv; gs_free_error GError *error = NULL; + guint8 new[HASH_LEN]; g_return_if_fail(self != NULL); priv = NM_DNS_MANAGER_GET_PRIVATE(self); g_return_if_fail(priv->updates_queue > 0); + compute_hash(self, nm_config_data_get_global_dns_config(nm_config_get_data(priv->config)), new); + priv->config_changed = (memcmp(new, priv->prev_hash, sizeof(new)) != 0) ? TRUE : FALSE; _LOGD("(%s): DNS configuration %s", func, priv->config_changed ? "changed" : "did not change"); priv->updates_queue--; @@ -2574,6 +2612,7 @@ nm_dns_manager_init(NMDnsManager *self) (GDestroyNotify) _dns_config_data_free, NULL); + compute_hash(self, NULL, NM_DNS_MANAGER_GET_PRIVATE(self)->hash); g_signal_connect(G_OBJECT(priv->config), NM_CONFIG_SIGNAL_CONFIG_CHANGED, G_CALLBACK(config_changed_cb), diff --git a/src/core/nm-config-data.c b/src/core/nm-config-data.c index 0c4f8099de..e86e993c17 100644 --- a/src/core/nm-config-data.c +++ b/src/core/nm-config-data.c @@ -982,6 +982,61 @@ nm_global_dns_config_cmp(const NMGlobalDnsConfig *a, return 0; } +void +nm_global_dns_config_update_checksum(const NMGlobalDnsConfig *dns_config, GChecksum *sum) +{ + NMGlobalDnsDomain *domain; + guint i, j; + guint8 v8; + + g_return_if_fail(dns_config); + g_return_if_fail(sum); + + v8 = NM_HASH_COMBINE_BOOLS(guint8, + !dns_config->searches, + !dns_config->options, + !dns_config->domain_list); + g_checksum_update(sum, (guchar *) &v8, 1); + + if (dns_config->searches) { + for (i = 0; dns_config->searches[i]; i++) + g_checksum_update(sum, + (guchar *) dns_config->searches[i], + strlen(dns_config->searches[i]) + 1); + } + if (dns_config->options) { + for (i = 0; dns_config->options[i]; i++) + g_checksum_update(sum, + (guchar *) dns_config->options[i], + strlen(dns_config->options[i]) + 1); + } + + if (dns_config->domain_list) { + for (i = 0; dns_config->domain_list[i]; i++) { + domain = g_hash_table_lookup(dns_config->domains, dns_config->domain_list[i]); + nm_assert(domain); + + v8 = NM_HASH_COMBINE_BOOLS(guint8, !domain->servers, !domain->options); + g_checksum_update(sum, (guchar *) &v8, 1); + + g_checksum_update(sum, (guchar *) domain->name, strlen(domain->name) + 1); + + if (domain->servers) { + for (j = 0; domain->servers[j]; j++) + g_checksum_update(sum, + (guchar *) domain->servers[j], + strlen(domain->servers[j]) + 1); + } + if (domain->options) { + for (j = 0; domain->options[j]; j++) + g_checksum_update(sum, + (guchar *) domain->options[j], + strlen(domain->options[j]) + 1); + } + } + } +} + static void global_dns_domain_free(NMGlobalDnsDomain *domain) { diff --git a/src/core/nm-config-data.h b/src/core/nm-config-data.h index 89c69e2877..1923dc49c4 100644 --- a/src/core/nm-config-data.h +++ b/src/core/nm-config-data.h @@ -267,7 +267,8 @@ gboolean nm_global_dns_config_is_empty(const NMGlobalDnsConfig *dns_co int nm_global_dns_config_cmp(const NMGlobalDnsConfig *a, const NMGlobalDnsConfig *b, gboolean check_internal); -void nm_global_dns_config_free(NMGlobalDnsConfig *dns_config); +void nm_global_dns_config_update_checksum(const NMGlobalDnsConfig *dns_config, GChecksum *sum); +void nm_global_dns_config_free(NMGlobalDnsConfig *dns_config); NMGlobalDnsConfig *nm_global_dns_config_from_dbus(const GValue *value, GError **error); void nm_global_dns_config_to_dbus(const NMGlobalDnsConfig *dns_config, GValue *value); diff --git a/src/core/nm-ip-config.c b/src/core/nm-ip-config.c index b3e599400e..2470e40e2b 100644 --- a/src/core/nm-ip-config.c +++ b/src/core/nm-ip-config.c @@ -498,6 +498,77 @@ nm_ip4_config_class_init(NMIP4ConfigClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST_ip4, obj_properties_ip4); } +void +nm_ip_config_dns_hash(const NML3ConfigData *l3cd, GChecksum *sum, int addr_family) +{ + guint i; + int val; + const char *const *nameservers; + const in_addr_t * wins; + const char *const *domains; + const char *const *searches; + const char *const *options; + guint num_nameservers; + guint num_wins; + guint num_domains; + guint num_searches; + guint num_options; + + g_return_if_fail(l3cd); + g_return_if_fail(sum); + + nameservers = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num_nameservers); + for (i = 0; i < num_nameservers; i++) { + g_checksum_update(sum, + nm_ip_addr_from_packed_array(addr_family, nameservers, i), + nm_utils_addr_family_to_size(addr_family)); + } + + if (addr_family == AF_INET) { + wins = nm_l3_config_data_get_wins(l3cd, &num_wins); + for (i = 0; i < num_wins; i++) + g_checksum_update(sum, (guint8 *) &wins[i], 4); + } + + domains = nm_l3_config_data_get_domains(l3cd, addr_family, &num_domains); + for (i = 0; i < num_domains; i++) { + g_checksum_update(sum, (const guint8 *) domains[i], strlen(domains[i])); + } + + searches = nm_l3_config_data_get_searches(l3cd, addr_family, &num_searches); + for (i = 0; i < num_searches; i++) { + g_checksum_update(sum, (const guint8 *) searches[i], strlen(searches[i])); + } + + options = nm_l3_config_data_get_dns_options(l3cd, addr_family, &num_options); + for (i = 0; i < num_options; i++) { + g_checksum_update(sum, (const guint8 *) options[i], strlen(options[i])); + } + + val = nm_l3_config_data_get_mdns(l3cd); + if (val != NM_SETTING_CONNECTION_MDNS_DEFAULT) + g_checksum_update(sum, (const guint8 *) &val, sizeof(val)); + + val = nm_l3_config_data_get_llmnr(l3cd); + if (val != NM_SETTING_CONNECTION_LLMNR_DEFAULT) + g_checksum_update(sum, (const guint8 *) &val, sizeof(val)); + + val = nm_l3_config_data_get_dns_over_tls(l3cd); + if (val != NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT) + g_checksum_update(sum, (const guint8 *) &val, sizeof(val)); + + /* FIXME(ip-config-checksum): the DNS priority should be considered relevant + * and added into the checksum as well, but this can't be done right now + * because in the DNS manager we rely on the fact that an empty + * configuration (i.e. just created) has a zero checksum. This is needed to + * avoid rewriting resolv.conf when there is no change. + * + * The DNS priority initial value depends on the connection type (VPN or + * not), so it's a bit difficult to add it to checksum maintaining the + * assumption of checksum(empty)=0 + */ +} + /*****************************************************************************/ /* public */ diff --git a/src/core/nm-ip-config.h b/src/core/nm-ip-config.h index 5b2552e3a3..9bc1ff45c6 100644 --- a/src/core/nm-ip-config.h +++ b/src/core/nm-ip-config.h @@ -51,6 +51,8 @@ NMIPConfig *nm_ip_config_new(int addr_family, NML3Cfg *l3cfg); void nm_ip_config_take_and_unexport_on_idle(NMIPConfig *self_take); +void nm_ip_config_dns_hash(const NML3ConfigData *l3cd, GChecksum *sum, int addr_family); + /*****************************************************************************/ static inline NML3Cfg * From fcfa598fc20ec68c9bbdb93364e5011531db7983 Mon Sep 17 00:00:00 2001 From: Ana Cabral Date: Tue, 16 Nov 2021 21:35:32 +0100 Subject: [PATCH 043/110] device: fix route metric penalty assignment When a route has the connectivity check enabled and does not have full connectivity, it should have its route metric penalized, this way this route will not be preferred over others. Fixes-test: @per_device_connectivity_check --- src/core/devices/nm-device.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 078dc16a5d..598d3fcd26 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -564,9 +564,6 @@ typedef struct _NMDevicePrivate { bool up : 1; /* IFF_UP */ - bool default_route_metric_penalty_ip4_has : 1; - bool default_route_metric_penalty_ip6_has : 1; - bool v4_route_table_initialized : 1; bool v6_route_table_initialized : 1; @@ -4811,31 +4808,16 @@ nm_device_get_route_metric_default(NMDeviceType device_type) return 11000; } -/* FIXME(l3cfg): we currently never call this function. We need to react - * to changes and re-commit the IP configuration with updated penalty. */ -_nm_unused static gboolean -_dev_default_route_metric_penalty_detect(NMDevice *self, int addr_family) +static guint32 +_dev_default_route_metric_penalty_get(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const int IS_IPv4 = NM_IS_IPv4(addr_family); - /* currently we don't differentiate between IPv4 and IPv6 when detecting - * connectivity. */ if (priv->concheck_x[IS_IPv4].state != NM_CONNECTIVITY_FULL && nm_connectivity_check_enabled(concheck_get_mgr(self))) - return TRUE; - - return FALSE; -} - -static guint32 -_dev_default_route_metric_penalty_get(NMDevice *self, int addr_family) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - if (NM_IS_IPv4(addr_family) ? priv->default_route_metric_penalty_ip4_has - : priv->default_route_metric_penalty_ip6_has) return 20000; + return 0; } @@ -14944,9 +14926,6 @@ _cleanup_generic_post(NMDevice *self, CleanupType cleanup_type) priv->v4_route_table_all_sync_before = FALSE; priv->v6_route_table_all_sync_before = FALSE; - priv->default_route_metric_penalty_ip4_has = FALSE; - priv->default_route_metric_penalty_ip6_has = FALSE; - priv->mtu_force_set_done = FALSE; priv->needs_ip6_subnet = FALSE; From c5f26a546b4e146b925efd7665ebab226f7634ef Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 10 Nov 2021 16:45:40 +0100 Subject: [PATCH 044/110] l3cfg: fix handling of removed addresses If the address appears after being removed, start defending it instead of throwing an assertion. --- src/core/nm-l3cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 9c92f5cd53..b5a948b889 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -2723,10 +2723,10 @@ handle_probing_done: goto handle_start_defending; case NM_L3_ACD_ADDR_STATE_READY: case NM_L3_ACD_ADDR_STATE_DEFENDING: + case NM_L3_ACD_ADDR_STATE_EXTERNAL_REMOVED: goto handle_start_defending; case NM_L3_ACD_ADDR_STATE_CONFLICT: return; - case NM_L3_ACD_ADDR_STATE_EXTERNAL_REMOVED: nm_assert_not_reached(); return; } From 7f03b0c9ef0f061a893b3a741c225309eb779107 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 10 Nov 2021 17:08:59 +0100 Subject: [PATCH 045/110] l3cfg: consider a externally-removed address as ACD-ready If an address is removed externally, it should be considered ready from ACD point of view. In this way it can be commit again (for example, if the DHCP lease is renewed). --- src/core/nm-l3cfg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index b5a948b889..4c1f8dc029 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -3404,7 +3404,8 @@ _l3_hook_add_obj_cb(const NML3ConfigData * l3cd, if (!NM_IN_SET(acd_data->info.state, NM_L3_ACD_ADDR_STATE_READY, - NM_L3_ACD_ADDR_STATE_DEFENDING)) { + NM_L3_ACD_ADDR_STATE_DEFENDING, + NM_L3_ACD_ADDR_STATE_EXTERNAL_REMOVED)) { acd_bad = TRUE; goto out_ip4_address; } From 2838b1c5e893f5e22b23f18bc44f81560a1f65fa Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 11 Nov 2021 22:16:14 +0100 Subject: [PATCH 046/110] core: track force-commit flag for l3cd and platform objects Problem: if l3cfg commits an address and routes from DHCP, when the address expires those objects are removed automatically. NM tracks the objects as missing as if the user removed them. This is to prevent l3cfg to committing them again. If the lease if renewed, l3cfg should be allowed to commit those objects again. Introduce a l3cd flag to indicate that it should be force-committed once, and propagate this flag to platform objects. In this way, l3cfg can avoid committing again objects that are removed externally, but it can commit them when the l3cd changes. Fixes-test: @bridge_down_to_l2_only --- src/core/devices/nm-device.c | 44 +++++++++++++++++++++------ src/core/nm-l3-config-data.c | 14 +++++++++ src/core/nm-l3-config-data.h | 1 + src/core/nm-l3cfg.c | 26 +++++++++++++--- src/core/nm-l3cfg.h | 4 +++ src/libnm-platform/nm-platform.c | 52 +++++++++++++++++++++----------- src/libnm-platform/nm-platform.h | 17 +++++++---- src/libnm-platform/nmp-object.h | 15 +++++++++ 8 files changed, 134 insertions(+), 39 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 598d3fcd26..4cba253c85 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -3572,7 +3572,9 @@ after_merge_flags: } static gboolean -_dev_l3_register_l3cds_add_config(NMDevice *self, L3ConfigDataType l3cd_type) +_dev_l3_register_l3cds_add_config(NMDevice * self, + L3ConfigDataType l3cd_type, + NML3CfgConfigFlags flags) { NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); NML3ConfigMergeFlags merge_flags; @@ -3595,15 +3597,16 @@ _dev_l3_register_l3cds_add_config(NMDevice *self, L3ConfigDataType l3cd_type) _prop_get_ipvx_dns_priority(self, AF_INET6), acd_defend_type, acd_timeout_msec, - NM_L3CFG_CONFIG_FLAGS_NONE, + flags, merge_flags); } static gboolean -_dev_l3_register_l3cds_set_one(NMDevice * self, - L3ConfigDataType l3cd_type, - const NML3ConfigData *l3cd, - NMTernary commit_sync) +_dev_l3_register_l3cds_set_one_full(NMDevice * self, + L3ConfigDataType l3cd_type, + const NML3ConfigData *l3cd, + NML3CfgConfigFlags flags, + NMTernary commit_sync) { NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; @@ -3626,7 +3629,7 @@ _dev_l3_register_l3cds_set_one(NMDevice * self, if (priv->l3cfg) { if (priv->l3cds[l3cd_type].d) { - if (_dev_l3_register_l3cds_add_config(self, l3cd_type)) + if (_dev_l3_register_l3cds_add_config(self, l3cd_type, flags)) changed = TRUE; } @@ -3644,6 +3647,19 @@ _dev_l3_register_l3cds_set_one(NMDevice * self, return changed; } +static gboolean +_dev_l3_register_l3cds_set_one(NMDevice * self, + L3ConfigDataType l3cd_type, + const NML3ConfigData *l3cd, + NMTernary commit_sync) +{ + return _dev_l3_register_l3cds_set_one_full(self, + l3cd_type, + l3cd, + NM_L3CFG_CONFIG_FLAGS_NONE, + commit_sync); +} + static void _dev_l3_update_l3cds_ifindex(NMDevice *self) { @@ -3696,7 +3712,7 @@ _dev_l3_register_l3cds(NMDevice *self, } if (is_external) continue; - if (_dev_l3_register_l3cds_add_config(self, i)) + if (_dev_l3_register_l3cds_add_config(self, i, NM_L3CFG_CONFIG_FLAGS_NONE)) changed = TRUE; } @@ -9870,7 +9886,11 @@ _dev_ipdhcpx_handle_accept(NMDevice *self, int addr_family, const NML3ConfigData nm_assert(NM_IS_L3_CONFIG_DATA(l3cd)); nm_dhcp_config_set_lease(priv->ipdhcp_data_x[IS_IPv4].config, l3cd); - _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4), l3cd, TRUE); + _dev_l3_register_l3cds_set_one_full(self, + L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4), + l3cd, + NM_L3CFG_CONFIG_FLAGS_FORCE_ONCE, + TRUE); /* FIXME(l3cfg:dhcp): accept also should be handled by NMDhcpClient transparently. * NMDhcpClient should do ACD (if enabled), and only after that passes, it exposes @@ -11074,7 +11094,11 @@ _dev_ipac6_ndisc_config_changed(NMNDisc * ndisc, _dev_ipac6_grace_period_start(self, 0, TRUE); - _dev_l3_register_l3cds_set_one(self, L3_CONFIG_DATA_TYPE_AC_6, l3cd, FALSE); + _dev_l3_register_l3cds_set_one_full(self, + L3_CONFIG_DATA_TYPE_AC_6, + l3cd, + NM_L3CFG_CONFIG_FLAGS_FORCE_ONCE, + FALSE); nm_clear_l3cd(&priv->ipac6_data.l3cd); diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index bf0f976252..c2afec8b7d 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -2906,6 +2906,7 @@ nm_l3_config_data_merge(NML3ConfigData * self, NML3ConfigMergeHookResult hook_result = { .ip4acd_not_ready = NM_OPTION_BOOL_DEFAULT, .assume_config_once = NM_OPTION_BOOL_DEFAULT, + .force_commit = NM_OPTION_BOOL_DEFAULT, }; #define _ensure_a() \ @@ -2944,6 +2945,12 @@ nm_l3_config_data_merge(NML3ConfigData * self, a.ax.a_assume_config_once = (!!hook_result.assume_config_once); } + if (hook_result.force_commit != NM_OPTION_BOOL_DEFAULT + && (!!hook_result.force_commit) != a_src->a_force_commit) { + _ensure_a(); + a.ax.a_force_commit = (!!hook_result.force_commit); + } + nm_l3_config_data_add_address_full(self, addr_family, a_src == &a.ax ? NULL : obj, @@ -2964,6 +2971,7 @@ nm_l3_config_data_merge(NML3ConfigData * self, NML3ConfigMergeHookResult hook_result = { .ip4acd_not_ready = NM_OPTION_BOOL_DEFAULT, .assume_config_once = NM_OPTION_BOOL_DEFAULT, + .force_commit = NM_OPTION_BOOL_DEFAULT, }; #define _ensure_r() \ @@ -2995,6 +3003,12 @@ nm_l3_config_data_merge(NML3ConfigData * self, r.rx.r_assume_config_once = (!!hook_result.assume_config_once); } + if (hook_result.force_commit != NM_OPTION_BOOL_DEFAULT + && (!!hook_result.force_commit) != r_src->r_force_commit) { + _ensure_r(); + r.rx.r_force_commit = (!!hook_result.force_commit); + } + if (!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_CLONE)) { if (r_src->table_any) { _ensure_r(); diff --git a/src/core/nm-l3-config-data.h b/src/core/nm-l3-config-data.h index dfaf18549a..b96317a89c 100644 --- a/src/core/nm-l3-config-data.h +++ b/src/core/nm-l3-config-data.h @@ -138,6 +138,7 @@ NML3ConfigData *nm_l3_config_data_new_from_platform(NMDedupMultiIndex * mu typedef struct { NMOptionBool ip4acd_not_ready; NMOptionBool assume_config_once; + NMOptionBool force_commit; } NML3ConfigMergeHookResult; typedef gboolean (*NML3ConfigMergeHookAddObj)(const NML3ConfigData * l3cd, diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 4c1f8dc029..3c8b13ddba 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -204,6 +204,7 @@ typedef struct { guint32 acd_timeout_msec_confdata; NML3AcdDefendType acd_defend_type_confdata : 3; bool dirty_confdata : 1; + gboolean force_commit_once : 1; } L3ConfigData; /*****************************************************************************/ @@ -1014,9 +1015,11 @@ _obj_states_sync_filter(/* const NMDedupMultiObj * */ gconstpointer o, gpointer const ObjStatesSyncFilterData *sync_filter_data = user_data; NMPObjectType obj_type; ObjStateData * obj_state; + NML3Cfg * self; nm_assert(sync_filter_data); nm_assert(NM_IS_L3CFG(sync_filter_data->self)); + self = sync_filter_data->self; obj_type = NMP_OBJECT_GET_TYPE(obj); @@ -1031,15 +1034,12 @@ _obj_states_sync_filter(/* const NMDedupMultiObj * */ gconstpointer o, gpointer nm_assert(c_list_is_empty(&obj_state->os_zombie_lst)); if (!obj_state->os_nm_configured) { - NML3Cfg *self; - if (sync_filter_data->commit_type == NM_L3_CFG_COMMIT_TYPE_ASSUME && !_obj_state_data_get_assume_config_once(obj_state)) return FALSE; obj_state->os_nm_configured = TRUE; - self = sync_filter_data->self; _LOGD("obj-state: configure-first-time: %s", _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); return TRUE; @@ -1051,7 +1051,8 @@ _obj_states_sync_filter(/* const NMDedupMultiObj * */ gconstpointer o, gpointer return TRUE; } - if (!obj_state->os_plobj && sync_filter_data->commit_type != NM_L3_CFG_COMMIT_TYPE_REAPPLY) + if (!obj_state->os_plobj && sync_filter_data->commit_type != NM_L3_CFG_COMMIT_TYPE_REAPPLY + && !nmp_object_get_force_commit(obj)) return FALSE; return TRUE; @@ -3200,7 +3201,8 @@ nm_l3cfg_add_config(NML3Cfg * self, .acd_timeout_msec_confdata = acd_timeout_msec, .priority_confdata = priority, .pseudo_timestamp_confdata = ++self->priv.p->pseudo_timestamp_counter, - .dirty_confdata = FALSE, + .force_commit_once = NM_FLAGS_HAS(config_flags, NM_L3CFG_CONFIG_FLAGS_FORCE_ONCE), + .dirty_confdata = FALSE, }; changed = TRUE; } else { @@ -3345,6 +3347,7 @@ typedef struct { gconstpointer tag; bool assume_config_once; bool to_commit; + bool force_commit_once; } L3ConfigMergeHookAddObjData; static gboolean @@ -3363,8 +3366,10 @@ _l3_hook_add_obj_cb(const NML3ConfigData * l3cd, nm_assert(hook_result); nm_assert(hook_result->ip4acd_not_ready == NM_OPTION_BOOL_DEFAULT); nm_assert(hook_result->assume_config_once == NM_OPTION_BOOL_DEFAULT); + nm_assert(hook_result->force_commit == NM_OPTION_BOOL_DEFAULT); hook_result->assume_config_once = hook_data->assume_config_once; + hook_result->force_commit = hook_data->force_commit_once; switch (NMP_OBJECT_GET_TYPE(obj)) { case NMP_OBJECT_TYPE_IP4_ADDRESS: @@ -3501,6 +3506,7 @@ _l3cfg_update_combined_config(NML3Cfg * self, hook_data.tag = l3cd_data->tag_confdata; hook_data.assume_config_once = NM_FLAGS_HAS(l3cd_data->config_flags, NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE); + hook_data.force_commit_once = l3cd_data->force_commit_once; nm_l3_config_data_merge(l3cd, l3cd_data->l3cd, @@ -4116,6 +4122,7 @@ _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle) gboolean is_sticky_update = FALSE; char sbuf_ct[30]; gboolean changed_combined_l3cd; + guint i; g_return_if_fail(NM_IS_L3CFG(self)); nm_assert(NM_IN_SET(commit_type, @@ -4179,6 +4186,15 @@ _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle) _l3_acd_data_process_changes(self); + if (self->priv.p->l3_config_datas) { + for (i = 0; i < self->priv.p->l3_config_datas->len; i++) { + L3ConfigData *l3_config_data = _l3_config_datas_at(self->priv.p->l3_config_datas, i); + + if (l3_config_data->force_commit_once) + l3_config_data->force_commit_once = FALSE; + } + } + nm_assert(self->priv.p->commit_reentrant_count == 1); self->priv.p->commit_reentrant_count--; diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h index 35560142be..768794389c 100644 --- a/src/core/nm-l3cfg.h +++ b/src/core/nm-l3cfg.h @@ -53,11 +53,15 @@ typedef enum _nm_packed { * "don't change" behavior. At least once. If the address/route * is still not (no longer) configured on the subsequent * commit, it's not getting added again. + * @NM_L3CFG_CONFIG_FLAGS_FORCE_ONCE: if set, objects in the + * NML3ConfigData are committed to platform even if they were + * removed externally. */ typedef enum _nm_packed { NM_L3CFG_CONFIG_FLAGS_NONE = 0, NM_L3CFG_CONFIG_FLAGS_ONLY_FOR_ACD = (1LL << 0), NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE = (1LL << 1), + NM_L3CFG_CONFIG_FLAGS_FORCE_ONCE = (1LL << 2), } NML3CfgConfigFlags; typedef enum _nm_packed { diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index ee8748c631..e9403c6189 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -6251,6 +6251,7 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf " src %s" "%s" /* a_acd_not_ready */ "%s" /* a_assume_config_once */ + "%s" /* a_force_commit */ "", s_address, address->plen, @@ -6269,7 +6270,8 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf str_label, nmp_utils_ip_config_source_to_string(address->addr_source, s_source, sizeof(s_source)), address->a_acd_not_ready ? " ip4acd-not-ready" : "", - address->a_assume_config_once ? " assume-config-once" : ""); + address->a_assume_config_once ? " assume-config-once" : "", + address->a_force_commit ? " force-commit" : ""); g_free(str_peer); return buf; } @@ -6390,6 +6392,7 @@ nm_platform_ip6_address_to_string(const NMPlatformIP6Address *address, char *buf len, "%s/%d lft %s pref %s%s%s%s%s src %s" "%s" /* a_assume_config_once */ + "%s" /* a_force_commit */ "", s_address, address->plen, @@ -6400,7 +6403,8 @@ nm_platform_ip6_address_to_string(const NMPlatformIP6Address *address, char *buf str_dev, _to_string_ifa_flags(address->n_ifa_flags, s_flags, sizeof(s_flags)), nmp_utils_ip_config_source_to_string(address->addr_source, s_source, sizeof(s_source)), - address->a_assume_config_once ? " assume-config-once" : ""); + address->a_assume_config_once ? " assume-config-once" : "", + address->a_force_commit ? " force-commit" : ""); g_free(str_peer); return buf; } @@ -6492,6 +6496,7 @@ nm_platform_ip4_route_to_string(const NMPlatformIP4Route *route, char *buf, gsiz "%s" /* initrwnd */ "%s" /* mtu */ "%s" /* r_assume_config_once */ + "%s" /* r_force_commit */ "", nm_net_aux_rtnl_rtntype_n2a_maybe_buf(nm_platform_route_type_uncoerce(route->type_coerced), str_type), @@ -6548,7 +6553,8 @@ nm_platform_ip4_route_to_string(const NMPlatformIP4Route *route, char *buf, gsiz route->lock_mtu ? "lock " : "", route->mtu) : "", - route->r_assume_config_once ? " assume-config-once" : ""); + route->r_assume_config_once ? " assume-config-once" : "", + route->r_force_commit ? " force-commit" : ""); return buf; } @@ -6619,6 +6625,7 @@ nm_platform_ip6_route_to_string(const NMPlatformIP6Route *route, char *buf, gsiz "%s" /* mtu */ "%s" /* pref */ "%s" /* r_assume_config_once */ + "%s" /* r_force_commit */ "", nm_net_aux_rtnl_rtntype_n2a_maybe_buf(nm_platform_route_type_uncoerce(route->type_coerced), str_type), @@ -6679,7 +6686,8 @@ nm_platform_ip6_route_to_string(const NMPlatformIP6Route *route, char *buf, gsiz " pref %s", nm_icmpv6_router_pref_to_string(route->rt_pref, str_pref2, sizeof(str_pref2))) : "", - route->r_assume_config_once ? " assume-config-once" : ""); + route->r_assume_config_once ? " assume-config-once" : "", + route->r_force_commit ? " force-commit" : ""); return buf; } @@ -7815,7 +7823,8 @@ nm_platform_ip4_address_hash_update(const NMPlatformIP4Address *obj, NMHashState NM_HASH_COMBINE_BOOLS(guint8, obj->use_ip4_broadcast_address, obj->a_acd_not_ready, - obj->a_assume_config_once)); + obj->a_assume_config_once, + obj->a_force_commit)); nm_hash_update_strarr(h, obj->label); } @@ -7838,23 +7847,25 @@ nm_platform_ip4_address_cmp(const NMPlatformIP4Address *a, const NMPlatformIP4Ad NM_CMP_FIELD_STR(a, b, label); NM_CMP_FIELD_UNSAFE(a, b, a_acd_not_ready); NM_CMP_FIELD_UNSAFE(a, b, a_assume_config_once); + NM_CMP_FIELD_UNSAFE(a, b, a_force_commit); return 0; } void nm_platform_ip6_address_hash_update(const NMPlatformIP6Address *obj, NMHashState *h) { - nm_hash_update_vals(h, - obj->ifindex, - obj->addr_source, - obj->timestamp, - obj->lifetime, - obj->preferred, - obj->n_ifa_flags, - obj->plen, - obj->address, - obj->peer_address, - NM_HASH_COMBINE_BOOLS(guint8, obj->a_assume_config_once)); + nm_hash_update_vals( + h, + obj->ifindex, + obj->addr_source, + obj->timestamp, + obj->lifetime, + obj->preferred, + obj->n_ifa_flags, + obj->plen, + obj->address, + obj->peer_address, + NM_HASH_COMBINE_BOOLS(guint8, obj->a_assume_config_once, obj->a_force_commit)); } int @@ -7875,6 +7886,7 @@ nm_platform_ip6_address_cmp(const NMPlatformIP6Address *a, const NMPlatformIP6Ad NM_CMP_FIELD(a, b, preferred); NM_CMP_FIELD(a, b, n_ifa_flags); NM_CMP_FIELD_UNSAFE(a, b, a_assume_config_once); + NM_CMP_FIELD_UNSAFE(a, b, a_force_commit); return 0; } @@ -7983,7 +7995,8 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj, obj->lock_initcwnd, obj->lock_initrwnd, obj->lock_mtu, - obj->r_assume_config_once)); + obj->r_assume_config_once, + obj->r_force_commit)); break; } } @@ -8075,6 +8088,7 @@ nm_platform_ip4_route_cmp(const NMPlatformIP4Route *a, NM_CMP_FIELD(a, b, mtu); if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) { NM_CMP_FIELD_UNSAFE(a, b, r_assume_config_once); + NM_CMP_FIELD_UNSAFE(a, b, r_force_commit); } break; } @@ -8168,7 +8182,8 @@ nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj, obj->lock_initcwnd, obj->lock_initrwnd, obj->lock_mtu, - obj->r_assume_config_once), + obj->r_assume_config_once, + obj->r_force_commit), obj->window, obj->cwnd, obj->initcwnd, @@ -8253,6 +8268,7 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a, NM_CMP_FIELD(a, b, rt_pref); if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) { NM_CMP_FIELD_UNSAFE(a, b, r_assume_config_once); + NM_CMP_FIELD_UNSAFE(a, b, r_force_commit); } break; } diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 4667125f24..f3a4534ce7 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -320,10 +320,12 @@ typedef enum { \ bool use_ip4_broadcast_address : 1; \ \ - /* Whether the address is should be configured once during assume. This is a meta flag - * that is not honored by NMPlatform (netlink code). Instead, it can be used by the upper - * layers which use NMPlatformIPAddress to track addresses that should be configured. */ \ + /* Meta flags not honored by NMPlatform (netlink code). Instead, they can be + * used by the upper layers which use NMPlatformIPRoute to track addresses that + * should be configured. */ \ + /* Whether the address is should be configured once during assume. */ \ bool a_assume_config_once : 1; \ + bool a_force_commit : 1; \ \ guint8 plen; \ ; @@ -467,10 +469,13 @@ typedef union { * the "table_coerced" field is ignored (unlike for the metric). */ \ bool table_any : 1; \ \ - /* Whether the route is should be configured once during assume. This is a meta flag - * that is not honored by NMPlatform (netlink code). Instead, it can be used by the upper - * layers which use NMPlatformIPRoute to track routes that should be configured. */ \ + /* Meta flags not honored by NMPlatform (netlink code). Instead, they can be + * used by the upper layers which use NMPlatformIPRoute to track routes that + * should be configured. */ \ + /* Whether the route is should be configured once during assume. */ \ bool r_assume_config_once : 1; \ + /* Whether the route should be committed even if it was removed externally. */ \ + bool r_force_commit : 1; \ \ /* rtnh_flags * diff --git a/src/libnm-platform/nmp-object.h b/src/libnm-platform/nmp-object.h index bf140d7838..9a35014fbb 100644 --- a/src/libnm-platform/nmp-object.h +++ b/src/libnm-platform/nmp-object.h @@ -1112,6 +1112,21 @@ nmp_object_get_assume_config_once(const NMPObject *obj) } } +static inline gboolean +nmp_object_get_force_commit(const NMPObject *obj) +{ + switch (NMP_OBJECT_GET_TYPE(obj)) { + case NMP_OBJECT_TYPE_IP4_ADDRESS: + case NMP_OBJECT_TYPE_IP6_ADDRESS: + return NMP_OBJECT_CAST_IP_ADDRESS(obj)->a_force_commit; + case NMP_OBJECT_TYPE_IP4_ROUTE: + case NMP_OBJECT_TYPE_IP6_ROUTE: + return NMP_OBJECT_CAST_IP_ROUTE(obj)->r_force_commit; + default: + return nm_assert_unreachable_val(FALSE); + } +} + static inline const char * nmp_object_link_get_ifname(const NMPObject *obj) { From 4f52907beb470c7d075f90d09d7ef4462a4a3f8f Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 18 Nov 2021 16:51:19 +0100 Subject: [PATCH 047/110] NEWS: update --- NEWS | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 58afab73e3..1f44dd68e9 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,18 @@ ============================================= -NetworkManager-1.34-rc1 +NetworkManager-1.36 +Overview of changes since NetworkManager-1.34 +============================================= + +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! + +* rework IP configuration code to make it more independent from + NMDevice. + +============================================= +NetworkManager-1.34 Overview of changes since NetworkManager-1.32 ============================================= From 4495aa7a4dccaec86b51eb5318827772a97090b6 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 18 Nov 2021 16:54:27 +0100 Subject: [PATCH 048/110] device: remove an unused variable Fixes: 58287cbcc0c8 ('core: rework IP configuration in NetworkManager using layer 3 configuration') --- src/core/devices/nm-device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 4cba253c85..6f31ba6038 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -12001,8 +12001,7 @@ _dev_ipshared4_start(NMDevice *self) NMPlatformIP4Address ip4_addr; NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); const char * ip_iface; - gs_free_error GError *error = NULL; - NMConnection * applied; + NMConnection * applied; if (priv->ipshared_data_4.state != NM_DEVICE_IP_STATE_NONE) return; From 77d7b8287c43fdc25cbea6d976d3867459bfd314 Mon Sep 17 00:00:00 2001 From: Ana Cabral Date: Thu, 18 Nov 2021 18:01:49 +0100 Subject: [PATCH 049/110] release: bump version to 1.35.1 (development) --- configure.ac | 2 +- meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index f9baf12428..e3cd184332 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ dnl "shared/nm-version-macros.h.in" dnl - update number in meson.build m4_define([nm_major_version], [1]) m4_define([nm_minor_version], [35]) -m4_define([nm_micro_version], [0]) +m4_define([nm_micro_version], [1]) m4_define([nm_version], [nm_major_version.nm_minor_version.nm_micro_version]) diff --git a/meson.build b/meson.build index 36b6e6db4e..23809f93ae 100644 --- a/meson.build +++ b/meson.build @@ -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.35.0', + version: '1.35.1', license: 'GPL2+', default_options: [ 'buildtype=debugoptimized', From b0ac01a06e297984aa9aaf843e2c454411d3f87f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Nov 2021 11:11:37 +0100 Subject: [PATCH 050/110] NEWS: fix trailing whitespace and use full stop for news entries --- NEWS | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 1f44dd68e9..2bc42c36a5 100644 --- a/NEWS +++ b/NEWS @@ -16,17 +16,17 @@ NetworkManager-1.34 Overview of changes since NetworkManager-1.32 ============================================= -This is a release candidate. The API is subject to change +This is a release candidate. 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! -* initrd: wait for both IPv4 and IPv6 with "ip=dhcp,dhcp6" -* core: better handle sd-resolved errors when resolving hostnames +* initrd: wait for both IPv4 and IPv6 with "ip=dhcp,dhcp6". +* core: better handle sd-resolved errors when resolving hostnames. * nmcli: fix import WireGuard profile with DNS domain and address - family disabled -* ndisc: send router solicitations before expiry -* policy: send earlier the ip configs to the DNS manager -* core: support linking with LLD 13 + family disabled. +* ndisc: send router solicitations before expiry. +* policy: send earlier the ip configs to the DNS manager. +* core: support linking with LLD 13. * wireguard: importing wg-quick configuration files with nmcli no longer sets a negative, exclusive "dns-priority". This plays better with common split DNS setups that use systemd-resolved. From 2cd1a22a781ddf67bd7327611eb5e902261e4251 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Nov 2021 11:12:50 +0100 Subject: [PATCH 051/110] NEWS: drop unstable warning for 1.34 --- NEWS | 4 ---- 1 file changed, 4 deletions(-) diff --git a/NEWS b/NEWS index 2bc42c36a5..21693d33a0 100644 --- a/NEWS +++ b/NEWS @@ -16,10 +16,6 @@ NetworkManager-1.34 Overview of changes since NetworkManager-1.32 ============================================= -This is a release candidate. 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! - * initrd: wait for both IPv4 and IPv6 with "ip=dhcp,dhcp6". * core: better handle sd-resolved errors when resolving hostnames. * nmcli: fix import WireGuard profile with DNS domain and address From a2b26e26d9bbb7eb3bc9f9188e50c38bcb7cc22d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Nov 2021 11:16:01 +0100 Subject: [PATCH 052/110] NEWS: update --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 21693d33a0..ad80554757 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE! * rework IP configuration code to make it more independent from NMDevice. +* Drop "configure-and-quit" mode and nm-iface-helper. ============================================= NetworkManager-1.34 From 867bef5fe74278d463f5b9b3762635eabc5db07f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Nov 2021 11:21:04 +0100 Subject: [PATCH 053/110] man: clarify "configure-and-quit" option in NetworkManager.conf --- man/NetworkManager.conf.xml | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml index 617b94bdf7..545ac68dc9 100644 --- a/man/NetworkManager.conf.xml +++ b/man/NetworkManager.conf.xml @@ -254,22 +254,25 @@ no-auto-default=* configure-and-quit - When set to 'true', NetworkManager quits after - performing initial network configuration but spawns small helpers - to preserve DHCP leases and IPv6 addresses. This is useful in - environments where network setup is more or less static or it is - desirable to save process time but still handle some dynamic - configurations. When this option is true, - network configuration for Wi-Fi, WWAN, Bluetooth, ADSL, and PPPoE - interfaces cannot be preserved due to their use of external - services, and these devices will be deconfigured when NetworkManager - quits even though other interface's configuration may be preserved. - Also, to preserve DHCP addresses the 'dhcp' option - must be set to 'internal'. The default value of - the 'configure-and-quit' option is - 'false', meaning that NetworkManager will continue - running after initial network configuration and continue responding - to system and hardware events, D-Bus requests, and user commands. + This option is no longer useful to configure in NetworkManager.conf file. + It can however also be configured on the command line with the same + values, where it has some use. + + + When set to 'initrd', NetworkManager does not connect + to D-Bus and quits after configuring the network. This is an implementation + detail how the NetworkManager module of dracut can run NetworkManager. + An alternative to this is having NetworkManager as a systemd service + with D-Bus in initrd. + + + The value 'true' is unsupported since version 1.36. + Previously this was a mode where NetworkManager would quit after configuring + the network and run helper processes for DHCP and SLAAC. + + + Otherwise, NetworkManager runs a system service with D-Bus and does not + quit during normal operation. From 5e0764cf8e7b3cdc1a8bd5b088b3ea95c394f106 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Nov 2021 11:41:55 +0100 Subject: [PATCH 054/110] nm-sudo: reorder sections in nm-sudo.service unit file https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/938#note_1163013 --- data/nm-sudo.service.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data/nm-sudo.service.in b/data/nm-sudo.service.in index 22abdd236b..5f8701009b 100644 --- a/data/nm-sudo.service.in +++ b/data/nm-sudo.service.in @@ -33,10 +33,7 @@ NotifyAccess=main # or set to 2147483647 for infinity. #Environment=NM_SUDO_IDLE_TIMEOUT_MSEC=10000 -[Install] -Alias=dbus-org.freedesktop.nm.sudo.service -[Service] # Restrict: AmbientCapabilities= CapabilityBoundingSet= @@ -72,3 +69,7 @@ CapabilityBoundingSet=CAP_DAC_OVERRIDE PrivateUsers=no RestrictAddressFamilies=AF_UNIX SystemCallFilter=@resources + + +[Install] +Alias=dbus-org.freedesktop.nm.sudo.service From 454999505241117b0ac293e426fc01dc76c6e70f Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Tue, 23 Nov 2021 14:27:22 +0100 Subject: [PATCH 055/110] bridge: allow ageing_time option to be zero If the user wants to disable MAC ageing on the bridge, they need to set ageing_time to zero. https://bugzilla.redhat.com/show_bug.cgi?id=1871950 --- src/core/devices/nm-device-bridge.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/devices/nm-device-bridge.c b/src/core/devices/nm-device-bridge.c index 36a73978bc..718264fa19 100644 --- a/src/core/devices/nm-device-bridge.c +++ b/src/core/devices/nm-device-bridge.c @@ -339,7 +339,6 @@ static const Option master_options[] = { OPTION_TYPE_INT(NM_BRIDGE_AGEING_TIME_MIN, NM_BRIDGE_AGEING_TIME_MAX, NM_BRIDGE_AGEING_TIME_DEF), - .default_if_zero = TRUE, .user_hz_compensate = TRUE, ), OPTION(NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, "group_fwd_mask", OPTION_TYPE_INT(0, 0xFFFF, 0), ), OPTION(NM_SETTING_BRIDGE_MULTICAST_HASH_MAX, @@ -1062,8 +1061,7 @@ create_and_realize(NMDevice * device, NM_BRIDGE_HELLO_TIME_DEF_SYS), .max_age = _DEFAULT_IF_ZERO(nm_setting_bridge_get_max_age(s_bridge) * 100u, NM_BRIDGE_MAX_AGE_DEF_SYS), - .ageing_time = _DEFAULT_IF_ZERO(nm_setting_bridge_get_ageing_time(s_bridge) * 100u, - NM_BRIDGE_AGEING_TIME_DEF_SYS), + .ageing_time = nm_setting_bridge_get_ageing_time(s_bridge) * 100u, .stp_state = nm_setting_bridge_get_stp(s_bridge), .priority = nm_setting_bridge_get_priority(s_bridge), .vlan_protocol = to_sysfs_vlan_protocol_sys(nm_setting_bridge_get_vlan_protocol(s_bridge)), From e44cdc79812d82dcf24e915f440497bc503bffe4 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Tue, 23 Nov 2021 11:31:40 +0100 Subject: [PATCH 056/110] ovsdb: deactivate removed device if does not have a master When using OVS link aggregation ports, NetworkManager ovsdb is removing the ports when cleaning it up. If that happens, it should deactivate the device even if it does not have controller or the state is not assume/external. An interface that is port of the OVS bonding can be activated before the ovsdb clean up, if it is not deactivated then NetworkManager will finish with a wrong configuration. The 'ovsdb_device_removed()' is already checking that the device is "ovs-interface" with subtype "system". --- src/core/devices/ovs/nm-ovs-factory.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/core/devices/ovs/nm-ovs-factory.c b/src/core/devices/ovs/nm-ovs-factory.c index 6f5d88326b..14f8526387 100644 --- a/src/core/devices/ovs/nm-ovs-factory.c +++ b/src/core/devices/ovs/nm-ovs-factory.c @@ -165,15 +165,6 @@ ovsdb_device_removed(NMOvsdb * ovsdb, continue; if (!nm_streq0(nm_setting_ovs_interface_get_interface_type(s_ovs_int), "system")) continue; - /* Failing the system interface device is almost always the right - * thing to do when the ovsdb entry is removed. However, to avoid - * that a late device-removed signal tears down a different, - * newly-activated connection, let's also check that we have a master. - * Or in alternative, that the device is assumed/external: in such - * case it's always fine to fail the device. - */ - if (!nm_device_get_master(d) && !nm_device_sys_iface_state_is_external_or_assume(d)) - continue; device = d; } From 615221a99cdd5059b2632cba923bc04c92165dbc Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 9 Nov 2021 13:28:54 +0100 Subject: [PATCH 057/110] format: reformat source tree with clang-format 13.0 We use clang-format for automatic formatting of our source files. Since clang-format is actively maintained software, the actual formatting depends on the used version of clang-format. That is unfortunate and painful, but really unavoidable unless clang-format would be strictly bug-compatible. So the version that we must use is from the current Fedora release, which is also tested by our gitlab-ci. Previously, we were using Fedora 34 with clang-tools-extra-12.0.1-1.fc34.x86_64. As Fedora 35 comes along, we need to update our formatting as Fedora 35 comes with version "13.0.0~rc1-1.fc35". An alternative would be to freeze on version 12, but that has different problems (like, it's cumbersome to rebuild clang 12 on Fedora 35 and it would be cumbersome for our developers which are on Fedora 35 to use a clang that they cannot easily install). The (differently painful) solution is to reformat from time to time, as we switch to a new Fedora (and thus clang) version. Usually we would expect that such a reformatting brings minor changes. But this time, the changes are huge. That is mentioned in the release notes [1] as Makes PointerAligment: Right working with AlignConsecutiveDeclarations. (Fixes https://llvm.org/PR27353) [1] https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#clang-format --- examples/C/glib/add-connection-gdbus.c | 12 +- examples/C/glib/add-connection-libnm.c | 16 +- .../C/glib/get-active-connections-gdbus.c | 26 +- examples/C/glib/get-ap-info-libnm.c | 20 +- examples/C/glib/list-connections-gdbus.c | 4 +- examples/C/glib/list-connections-libnm.c | 8 +- examples/C/glib/monitor-nm-running-gdbus.c | 6 +- examples/C/glib/monitor-nm-state-gdbus.c | 12 +- examples/C/glib/vpn-import-libnm.c | 22 +- src/contrib/nm-compat.c | 2 +- src/contrib/nm-vpn-editor-plugin-call.h | 64 +- src/contrib/nm-vpn-plugin-utils.c | 20 +- src/contrib/nm-vpn-plugin-utils.h | 14 +- src/core/NetworkManagerUtils.c | 154 +- src/core/NetworkManagerUtils.h | 60 +- src/core/devices/adsl/nm-atm-manager.c | 38 +- src/core/devices/adsl/nm-device-adsl.c | 60 +- src/core/devices/bluetooth/nm-bluez-manager.c | 318 ++-- src/core/devices/bluetooth/nm-bluez-manager.h | 12 +- src/core/devices/bluetooth/nm-bluez5-dun.c | 48 +- src/core/devices/bluetooth/nm-bluez5-dun.h | 12 +- src/core/devices/bluetooth/nm-device-bt.c | 130 +- src/core/devices/bluetooth/nm-device-bt.h | 14 +- src/core/devices/bluetooth/tests/nm-bt-test.c | 18 +- src/core/devices/nm-device-6lowpan.c | 34 +- src/core/devices/nm-device-bond.c | 76 +- src/core/devices/nm-device-bridge.c | 116 +- src/core/devices/nm-device-dummy.c | 28 +- src/core/devices/nm-device-ethernet.c | 240 +-- src/core/devices/nm-device-factory.c | 50 +- src/core/devices/nm-device-factory.h | 40 +- src/core/devices/nm-device-generic.c | 12 +- src/core/devices/nm-device-infiniband.c | 40 +- src/core/devices/nm-device-ip-tunnel.c | 74 +- src/core/devices/nm-device-macsec.c | 120 +- src/core/devices/nm-device-macvlan.c | 56 +- src/core/devices/nm-device-ppp.c | 38 +- src/core/devices/nm-device-private.h | 42 +- src/core/devices/nm-device-tun.c | 50 +- src/core/devices/nm-device-utils.c | 18 +- src/core/devices/nm-device-utils.h | 2 +- src/core/devices/nm-device-veth.c | 24 +- src/core/devices/nm-device-vlan.c | 74 +- src/core/devices/nm-device-vrf.c | 42 +- src/core/devices/nm-device-vxlan.c | 48 +- src/core/devices/nm-device-wireguard.c | 190 +- src/core/devices/nm-device-wpan.c | 30 +- src/core/devices/nm-device.c | 1210 ++++++------ src/core/devices/nm-device.h | 166 +- src/core/devices/nm-lldp-listener.c | 70 +- src/core/devices/nm-lldp-listener.h | 2 +- src/core/devices/ovs/nm-device-ovs-bridge.c | 10 +- .../devices/ovs/nm-device-ovs-interface.c | 46 +- src/core/devices/ovs/nm-device-ovs-port.c | 14 +- src/core/devices/ovs/nm-ovs-factory.c | 48 +- src/core/devices/ovs/nm-ovsdb.c | 312 +-- src/core/devices/ovs/nm-ovsdb.h | 26 +- src/core/devices/team/nm-device-team.c | 144 +- src/core/devices/team/nm-team-factory.c | 10 +- src/core/devices/tests/test-lldp.c | 32 +- src/core/devices/wifi/nm-device-iwd.c | 454 ++--- src/core/devices/wifi/nm-device-iwd.h | 4 +- src/core/devices/wifi/nm-device-olpc-mesh.c | 46 +- src/core/devices/wifi/nm-device-wifi-p2p.c | 156 +- src/core/devices/wifi/nm-device-wifi.c | 402 ++-- src/core/devices/wifi/nm-device-wifi.h | 4 +- src/core/devices/wifi/nm-iwd-manager.c | 252 +-- src/core/devices/wifi/nm-iwd-manager.h | 4 +- src/core/devices/wifi/nm-wifi-ap.c | 48 +- src/core/devices/wifi/nm-wifi-ap.h | 14 +- src/core/devices/wifi/nm-wifi-common.c | 44 +- src/core/devices/wifi/nm-wifi-factory.c | 14 +- src/core/devices/wifi/nm-wifi-p2p-peer.c | 20 +- src/core/devices/wifi/nm-wifi-p2p-peer.h | 12 +- src/core/devices/wifi/nm-wifi-utils.c | 108 +- src/core/devices/wifi/nm-wifi-utils.h | 12 +- .../devices/wifi/tests/test-devices-wifi.c | 122 +- src/core/devices/wwan/nm-device-modem.c | 80 +- src/core/devices/wwan/nm-modem-broadband.c | 148 +- src/core/devices/wwan/nm-modem-manager.c | 92 +- src/core/devices/wwan/nm-modem-ofono.c | 138 +- src/core/devices/wwan/nm-modem.c | 136 +- src/core/devices/wwan/nm-modem.h | 78 +- src/core/devices/wwan/nm-service-providers.c | 82 +- src/core/devices/wwan/nm-service-providers.h | 18 +- src/core/devices/wwan/nm-wwan-factory.c | 20 +- .../wwan/tests/test-service-providers.c | 36 +- src/core/dhcp/nm-dhcp-client-logging.h | 4 +- src/core/dhcp/nm-dhcp-client.c | 58 +- src/core/dhcp/nm-dhcp-client.h | 10 +- src/core/dhcp/nm-dhcp-dhclient-utils.c | 60 +- src/core/dhcp/nm-dhcp-dhclient-utils.h | 18 +- src/core/dhcp/nm-dhcp-dhclient.c | 108 +- src/core/dhcp/nm-dhcp-dhcpcanon.c | 40 +- src/core/dhcp/nm-dhcp-dhcpcd.c | 12 +- src/core/dhcp/nm-dhcp-helper.c | 20 +- src/core/dhcp/nm-dhcp-listener.c | 32 +- src/core/dhcp/nm-dhcp-manager.c | 10 +- src/core/dhcp/nm-dhcp-nettools.c | 120 +- src/core/dhcp/nm-dhcp-options.c | 4 +- src/core/dhcp/nm-dhcp-options.h | 2 +- src/core/dhcp/nm-dhcp-systemd.c | 184 +- src/core/dhcp/nm-dhcp-utils.c | 100 +- src/core/dhcp/nm-dhcp-utils.h | 16 +- src/core/dhcp/tests/test-dhcp-dhclient.c | 44 +- src/core/dhcp/tests/test-dhcp-utils.c | 192 +- src/core/dns/nm-dns-dnsmasq.c | 84 +- src/core/dns/nm-dns-manager.c | 210 +-- src/core/dns/nm-dns-manager.h | 6 +- src/core/dns/nm-dns-plugin.c | 8 +- src/core/dns/nm-dns-plugin.h | 16 +- src/core/dns/nm-dns-systemd-resolved.c | 132 +- src/core/dns/nm-dns-systemd-resolved.h | 10 +- src/core/dns/nm-dns-unbound.c | 12 +- src/core/dnsmasq/nm-dnsmasq-manager.c | 36 +- src/core/dnsmasq/nm-dnsmasq-manager.h | 4 +- src/core/dnsmasq/nm-dnsmasq-utils.c | 6 +- src/core/dnsmasq/nm-dnsmasq-utils.h | 6 +- src/core/main-utils.c | 16 +- src/core/main-utils.h | 6 +- src/core/main.c | 28 +- src/core/ndisc/nm-fake-ndisc.c | 52 +- src/core/ndisc/nm-fake-ndisc.h | 16 +- src/core/ndisc/nm-lndp-ndisc.c | 28 +- src/core/ndisc/nm-ndisc-private.h | 2 +- src/core/ndisc/nm-ndisc.c | 94 +- src/core/ndisc/nm-ndisc.h | 34 +- src/core/ndisc/tests/test-ndisc-fake.c | 98 +- src/core/ndisc/tests/test-ndisc-linux.c | 8 +- src/core/nm-act-request.c | 50 +- src/core/nm-act-request.h | 22 +- src/core/nm-active-connection.c | 84 +- src/core/nm-active-connection.h | 30 +- src/core/nm-audit-manager.c | 86 +- src/core/nm-audit-manager.h | 34 +- src/core/nm-auth-manager.c | 80 +- src/core/nm-auth-manager.h | 10 +- src/core/nm-auth-utils.c | 36 +- src/core/nm-auth-utils.h | 20 +- src/core/nm-checkpoint-manager.c | 30 +- src/core/nm-checkpoint-manager.h | 18 +- src/core/nm-checkpoint.c | 76 +- src/core/nm-checkpoint.h | 6 +- src/core/nm-config-data.c | 194 +- src/core/nm-config-data.h | 92 +- src/core/nm-config.c | 288 +-- src/core/nm-config.h | 46 +- src/core/nm-connectivity.c | 80 +- src/core/nm-connectivity.h | 8 +- src/core/nm-core-utils.c | 232 +-- src/core/nm-core-utils.h | 127 +- src/core/nm-dbus-manager.c | 222 +-- src/core/nm-dbus-manager.h | 42 +- src/core/nm-dbus-object.c | 14 +- src/core/nm-dbus-object.h | 14 +- src/core/nm-dbus-utils.c | 20 +- src/core/nm-dbus-utils.h | 26 +- src/core/nm-dcb.c | 18 +- src/core/nm-dcb.h | 12 +- src/core/nm-dhcp-config.c | 10 +- src/core/nm-dispatcher.c | 100 +- src/core/nm-dispatcher.h | 22 +- src/core/nm-firewall-utils.c | 40 +- src/core/nm-firewalld-manager.c | 76 +- src/core/nm-firewalld-manager.h | 16 +- src/core/nm-hostname-manager.c | 78 +- src/core/nm-hostname-manager.h | 4 +- src/core/nm-ip-config.c | 46 +- src/core/nm-ip-config.h | 10 +- src/core/nm-keep-alive.c | 30 +- src/core/nm-keep-alive.h | 6 +- src/core/nm-l3-config-data.c | 128 +- src/core/nm-l3-config-data.h | 66 +- src/core/nm-l3-ipv4ll.c | 26 +- src/core/nm-l3-ipv6ll.c | 18 +- src/core/nm-l3-ipv6ll.h | 16 +- src/core/nm-l3cfg.c | 202 +- src/core/nm-l3cfg.h | 34 +- src/core/nm-manager.c | 1212 ++++++------ src/core/nm-manager.h | 52 +- src/core/nm-netns.c | 42 +- src/core/nm-netns.h | 4 +- src/core/nm-pacrunner-manager.c | 54 +- src/core/nm-policy.c | 326 ++-- src/core/nm-rfkill-manager.c | 34 +- src/core/nm-session-monitor.c | 16 +- src/core/nm-sleep-monitor.c | 14 +- src/core/nm-sudo-call.c | 14 +- src/core/nm-sudo-call.h | 2 +- src/core/nm-test-utils-core.h | 32 +- src/core/nm-types.h | 6 +- src/core/platform/nm-fake-platform.c | 118 +- src/core/platform/tests/test-address.c | 26 +- src/core/platform/tests/test-cleanup.c | 12 +- src/core/platform/tests/test-common.c | 128 +- src/core/platform/tests/test-common.h | 88 +- src/core/platform/tests/test-link.c | 136 +- src/core/platform/tests/test-nmp-object.c | 52 +- .../platform/tests/test-platform-general.c | 16 +- src/core/platform/tests/test-route.c | 156 +- src/core/platform/tests/test-tc.c | 24 +- src/core/ppp/nm-ppp-manager-call.c | 14 +- src/core/ppp/nm-ppp-manager-call.h | 8 +- src/core/ppp/nm-ppp-manager.c | 216 +-- src/core/ppp/nm-ppp-manager.h | 2 +- src/core/ppp/nm-ppp-mgr.c | 32 +- src/core/ppp/nm-ppp-mgr.h | 10 +- src/core/ppp/nm-ppp-plugin-api.h | 8 +- src/core/ppp/nm-pppd-plugin.c | 12 +- src/core/settings/nm-agent-manager.c | 202 +- src/core/settings/nm-agent-manager.h | 44 +- src/core/settings/nm-secret-agent.c | 116 +- src/core/settings/nm-secret-agent.h | 36 +- src/core/settings/nm-settings-connection.c | 392 ++-- src/core/settings/nm-settings-connection.h | 62 +- src/core/settings/nm-settings-plugin.c | 30 +- src/core/settings/nm-settings-plugin.h | 64 +- src/core/settings/nm-settings-storage.h | 6 +- src/core/settings/nm-settings-utils.c | 8 +- src/core/settings/nm-settings.c | 542 +++--- src/core/settings/nm-settings.h | 42 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c | 208 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 754 ++++---- .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.h | 10 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-storage.c | 14 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-storage.h | 12 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-utils.c | 14 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-utils.h | 8 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 364 ++-- .../plugins/ifcfg-rh/nms-ifcfg-rh-writer.h | 12 +- src/core/settings/plugins/ifcfg-rh/shvar.c | 46 +- src/core/settings/plugins/ifcfg-rh/shvar.h | 4 +- .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 1668 ++++++++--------- .../ifupdown/nms-ifupdown-interface-parser.c | 10 +- .../ifupdown/nms-ifupdown-interface-parser.h | 4 +- .../plugins/ifupdown/nms-ifupdown-parser.c | 70 +- .../plugins/ifupdown/nms-ifupdown-plugin.c | 40 +- .../plugins/ifupdown/tests/test-ifupdown.c | 100 +- .../plugins/keyfile/nms-keyfile-plugin.c | 258 +-- .../plugins/keyfile/nms-keyfile-plugin.h | 30 +- .../plugins/keyfile/nms-keyfile-reader.c | 40 +- .../plugins/keyfile/nms-keyfile-reader.h | 20 +- .../plugins/keyfile/nms-keyfile-storage.c | 28 +- .../plugins/keyfile/nms-keyfile-storage.h | 18 +- .../plugins/keyfile/nms-keyfile-utils.c | 40 +- .../plugins/keyfile/nms-keyfile-utils.h | 32 +- .../plugins/keyfile/nms-keyfile-writer.c | 94 +- .../plugins/keyfile/nms-keyfile-writer.h | 28 +- .../keyfile/tests/test-keyfile-settings.c | 534 +++--- src/core/supplicant/nm-supplicant-config.c | 172 +- src/core/supplicant/nm-supplicant-config.h | 20 +- src/core/supplicant/nm-supplicant-interface.c | 418 ++--- src/core/supplicant/nm-supplicant-interface.h | 38 +- src/core/supplicant/nm-supplicant-manager.c | 170 +- src/core/supplicant/nm-supplicant-manager.h | 16 +- .../nm-supplicant-settings-verify.c | 4 +- src/core/supplicant/nm-supplicant-types.h | 4 +- .../supplicant/tests/test-supplicant-config.c | 196 +- src/core/tests/config/nm-test-device.c | 2 +- src/core/tests/config/test-config.c | 192 +- src/core/tests/test-core-with-expect.c | 12 +- src/core/tests/test-core.c | 142 +- src/core/tests/test-dcb.c | 20 +- src/core/tests/test-l3cfg.c | 82 +- src/core/tests/test-systemd.c | 14 +- src/core/tests/test-utils.c | 12 +- src/core/tests/test-wired-defname.c | 8 +- src/core/vpn/nm-vpn-connection.c | 260 +-- src/core/vpn/nm-vpn-connection.h | 18 +- src/core/vpn/nm-vpn-manager.c | 36 +- src/libnm-base/nm-ethtool-base.c | 2 +- src/libnm-client-aux-extern/nm-libnm-aux.c | 20 +- src/libnm-client-aux-extern/nm-libnm-aux.h | 14 +- .../tests/test-libnm-client-aux.c | 8 +- src/libnm-client-impl/nm-access-point.c | 26 +- src/libnm-client-impl/nm-active-connection.c | 14 +- src/libnm-client-impl/nm-checkpoint.c | 4 +- src/libnm-client-impl/nm-client.c | 838 ++++----- src/libnm-client-impl/nm-dbus-helpers.c | 10 +- src/libnm-client-impl/nm-device-6lowpan.c | 2 +- src/libnm-client-impl/nm-device-adsl.c | 2 +- src/libnm-client-impl/nm-device-bond.c | 2 +- src/libnm-client-impl/nm-device-bridge.c | 2 +- src/libnm-client-impl/nm-device-bt.c | 10 +- src/libnm-client-impl/nm-device-ethernet.c | 12 +- src/libnm-client-impl/nm-device-generic.c | 2 +- src/libnm-client-impl/nm-device-infiniband.c | 4 +- src/libnm-client-impl/nm-device-ip-tunnel.c | 10 +- src/libnm-client-impl/nm-device-macsec.c | 4 +- src/libnm-client-impl/nm-device-macvlan.c | 6 +- src/libnm-client-impl/nm-device-modem.c | 12 +- src/libnm-client-impl/nm-device-olpc-mesh.c | 2 +- src/libnm-client-impl/nm-device-ovs-bridge.c | 2 +- src/libnm-client-impl/nm-device-ovs-port.c | 2 +- src/libnm-client-impl/nm-device-team.c | 2 +- src/libnm-client-impl/nm-device-tun.c | 6 +- src/libnm-client-impl/nm-device-veth.c | 2 +- src/libnm-client-impl/nm-device-vlan.c | 8 +- src/libnm-client-impl/nm-device-vrf.c | 2 +- src/libnm-client-impl/nm-device-vxlan.c | 6 +- src/libnm-client-impl/nm-device-wifi-p2p.c | 18 +- src/libnm-client-impl/nm-device-wifi.c | 34 +- src/libnm-client-impl/nm-device.c | 164 +- src/libnm-client-impl/nm-dhcp-config.c | 12 +- src/libnm-client-impl/nm-dns-manager.c | 8 +- src/libnm-client-impl/nm-dns-manager.h | 2 +- src/libnm-client-impl/nm-ip-config.c | 52 +- src/libnm-client-impl/nm-libnm-utils.c | 22 +- src/libnm-client-impl/nm-libnm-utils.h | 140 +- src/libnm-client-impl/nm-object.c | 16 +- src/libnm-client-impl/nm-remote-connection.c | 64 +- src/libnm-client-impl/nm-secret-agent-old.c | 238 +-- src/libnm-client-impl/nm-vpn-connection.c | 6 +- src/libnm-client-impl/nm-vpn-plugin-old.c | 90 +- src/libnm-client-impl/nm-vpn-service-plugin.c | 112 +- src/libnm-client-impl/nm-wifi-p2p-peer.c | 20 +- src/libnm-client-impl/tests/test-libnm.c | 28 +- src/libnm-client-impl/tests/test-nm-client.c | 174 +- .../tests/test-remote-settings-client.c | 44 +- .../tests/test-secret-agent.c | 128 +- src/libnm-client-public/nm-access-point.h | 4 +- .../nm-active-connection.h | 20 +- src/libnm-client-public/nm-client.h | 174 +- src/libnm-client-public/nm-device-wifi-p2p.h | 10 +- src/libnm-client-public/nm-device-wifi.h | 18 +- src/libnm-client-public/nm-device.h | 64 +- src/libnm-client-public/nm-ip-config.h | 6 +- .../nm-remote-connection.h | 56 +- src/libnm-client-public/nm-secret-agent-old.h | 64 +- src/libnm-client-public/nm-vpn-connection.h | 2 +- src/libnm-client-public/nm-vpn-plugin-old.h | 16 +- .../nm-vpn-service-plugin.h | 20 +- src/libnm-client-test/nm-test-libnm-utils.h | 32 +- src/libnm-client-test/nm-test-utils-impl.c | 104 +- src/libnm-core-aux-extern/nm-libnm-core-aux.c | 20 +- src/libnm-core-aux-intern/nm-auth-subject.c | 6 +- .../nm-libnm-core-utils.c | 12 +- .../nm-libnm-core-utils.h | 12 +- src/libnm-core-impl/nm-connection-private.h | 20 +- src/libnm-core-impl/nm-connection.c | 180 +- src/libnm-core-impl/nm-crypto-gnutls.c | 24 +- src/libnm-core-impl/nm-crypto-impl.h | 24 +- src/libnm-core-impl/nm-crypto-nss.c | 44 +- src/libnm-core-impl/nm-crypto.c | 128 +- src/libnm-core-impl/nm-crypto.h | 44 +- src/libnm-core-impl/nm-dbus-utils.c | 30 +- src/libnm-core-impl/nm-keyfile-utils.c | 60 +- src/libnm-core-impl/nm-keyfile.c | 614 +++--- .../nm-meta-setting-base-impl.c | 4 +- src/libnm-core-impl/nm-property-compare.c | 6 +- src/libnm-core-impl/nm-setting-6lowpan.c | 6 +- src/libnm-core-impl/nm-setting-8021x.c | 188 +- src/libnm-core-impl/nm-setting-adsl.c | 14 +- src/libnm-core-impl/nm-setting-bluetooth.c | 6 +- src/libnm-core-impl/nm-setting-bond-port.c | 6 +- src/libnm-core-impl/nm-setting-bond.c | 26 +- src/libnm-core-impl/nm-setting-bridge-port.c | 6 +- src/libnm-core-impl/nm-setting-bridge.c | 18 +- src/libnm-core-impl/nm-setting-cdma.c | 12 +- src/libnm-core-impl/nm-setting-connection.c | 92 +- src/libnm-core-impl/nm-setting-dcb.c | 16 +- src/libnm-core-impl/nm-setting-ethtool.c | 14 +- src/libnm-core-impl/nm-setting-gsm.c | 26 +- src/libnm-core-impl/nm-setting-hostname.c | 4 +- src/libnm-core-impl/nm-setting-infiniband.c | 14 +- src/libnm-core-impl/nm-setting-ip-config.c | 144 +- src/libnm-core-impl/nm-setting-ip-tunnel.c | 18 +- src/libnm-core-impl/nm-setting-ip4-config.c | 22 +- src/libnm-core-impl/nm-setting-ip6-config.c | 16 +- src/libnm-core-impl/nm-setting-macsec.c | 24 +- src/libnm-core-impl/nm-setting-macvlan.c | 14 +- src/libnm-core-impl/nm-setting-match.c | 12 +- src/libnm-core-impl/nm-setting-olpc-mesh.c | 6 +- src/libnm-core-impl/nm-setting-ovs-bridge.c | 4 +- src/libnm-core-impl/nm-setting-ovs-dpdk.c | 2 +- .../nm-setting-ovs-external-ids.c | 44 +- .../nm-setting-ovs-interface.c | 14 +- src/libnm-core-impl/nm-setting-ovs-patch.c | 2 +- src/libnm-core-impl/nm-setting-ovs-port.c | 12 +- src/libnm-core-impl/nm-setting-ppp.c | 4 +- src/libnm-core-impl/nm-setting-pppoe.c | 10 +- src/libnm-core-impl/nm-setting-private.h | 100 +- src/libnm-core-impl/nm-setting-proxy.c | 8 +- src/libnm-core-impl/nm-setting-serial.c | 4 +- src/libnm-core-impl/nm-setting-sriov.c | 50 +- src/libnm-core-impl/nm-setting-tc-config.c | 76 +- src/libnm-core-impl/nm-setting-team-port.c | 22 +- src/libnm-core-impl/nm-setting-team.c | 54 +- src/libnm-core-impl/nm-setting-tun.c | 8 +- src/libnm-core-impl/nm-setting-user.c | 32 +- src/libnm-core-impl/nm-setting-veth.c | 8 +- src/libnm-core-impl/nm-setting-vlan.c | 56 +- src/libnm-core-impl/nm-setting-vpn.c | 78 +- src/libnm-core-impl/nm-setting-vrf.c | 4 +- src/libnm-core-impl/nm-setting-vxlan.c | 10 +- src/libnm-core-impl/nm-setting-wifi-p2p.c | 6 +- src/libnm-core-impl/nm-setting-wimax.c | 4 +- src/libnm-core-impl/nm-setting-wired.c | 44 +- src/libnm-core-impl/nm-setting-wireguard.c | 148 +- .../nm-setting-wireless-security.c | 100 +- src/libnm-core-impl/nm-setting-wireless.c | 46 +- src/libnm-core-impl/nm-setting-wpan.c | 6 +- src/libnm-core-impl/nm-setting.c | 320 ++-- src/libnm-core-impl/nm-simple-connection.c | 2 +- src/libnm-core-impl/nm-team-utils.c | 144 +- src/libnm-core-impl/nm-team-utils.h | 32 +- src/libnm-core-impl/nm-utils-private.h | 16 +- src/libnm-core-impl/nm-utils.c | 276 +-- src/libnm-core-impl/nm-vpn-editor-plugin.c | 38 +- src/libnm-core-impl/nm-vpn-plugin-info.c | 60 +- src/libnm-core-impl/tests/test-compare.c | 8 +- src/libnm-core-impl/tests/test-crypto.c | 28 +- src/libnm-core-impl/tests/test-general.c | 662 +++---- src/libnm-core-impl/tests/test-keyfile.c | 130 +- src/libnm-core-impl/tests/test-secrets.c | 108 +- src/libnm-core-impl/tests/test-setting.c | 398 ++-- .../tests/test-settings-defaults.c | 4 +- src/libnm-core-intern/nm-core-internal.h | 130 +- src/libnm-core-intern/nm-keyfile-internal.h | 12 +- src/libnm-core-intern/nm-keyfile-utils.h | 36 +- .../nm-meta-setting-base-impl.h | 16 +- src/libnm-core-public/nm-connection.h | 70 +- src/libnm-core-public/nm-keyfile.h | 38 +- src/libnm-core-public/nm-setting-8021x.h | 82 +- src/libnm-core-public/nm-setting-adsl.h | 10 +- src/libnm-core-public/nm-setting-bluetooth.h | 2 +- src/libnm-core-public/nm-setting-bond.h | 6 +- src/libnm-core-public/nm-setting-cdma.h | 8 +- src/libnm-core-public/nm-setting-connection.h | 24 +- src/libnm-core-public/nm-setting-dcb.h | 2 +- src/libnm-core-public/nm-setting-infiniband.h | 2 +- src/libnm-core-public/nm-setting-ip-config.h | 40 +- src/libnm-core-public/nm-setting-match.h | 8 +- src/libnm-core-public/nm-setting-olpc-mesh.h | 4 +- .../nm-setting-ovs-external-ids.h | 6 +- src/libnm-core-public/nm-setting-pppoe.h | 8 +- src/libnm-core-public/nm-setting-serial.h | 2 +- src/libnm-core-public/nm-setting-tc-config.h | 2 +- src/libnm-core-public/nm-setting-team.h | 16 +- src/libnm-core-public/nm-setting-vlan.h | 14 +- src/libnm-core-public/nm-setting-vpn.h | 2 +- src/libnm-core-public/nm-setting-wired.h | 14 +- src/libnm-core-public/nm-setting-wireguard.h | 14 +- .../nm-setting-wireless-security.h | 16 +- src/libnm-core-public/nm-setting-wireless.h | 6 +- src/libnm-core-public/nm-setting.h | 28 +- src/libnm-core-public/nm-utils.h | 44 +- src/libnm-core-public/nm-vpn-editor-plugin.h | 30 +- src/libnm-core-public/nm-vpn-plugin-info.h | 2 +- src/libnm-glib-aux/nm-c-list.h | 2 +- src/libnm-glib-aux/nm-dbus-aux.c | 120 +- src/libnm-glib-aux/nm-dbus-aux.h | 92 +- src/libnm-glib-aux/nm-dedup-multi.c | 112 +- src/libnm-glib-aux/nm-dedup-multi.h | 78 +- src/libnm-glib-aux/nm-enum-utils.c | 18 +- src/libnm-glib-aux/nm-enum-utils.h | 10 +- src/libnm-glib-aux/nm-errno.c | 2 +- src/libnm-glib-aux/nm-glib.h | 12 +- src/libnm-glib-aux/nm-hash-utils.c | 2 +- src/libnm-glib-aux/nm-io-utils.c | 50 +- src/libnm-glib-aux/nm-io-utils.h | 26 +- src/libnm-glib-aux/nm-json-aux.c | 6 +- src/libnm-glib-aux/nm-json-aux.h | 2 +- src/libnm-glib-aux/nm-keyfile-aux.c | 32 +- src/libnm-glib-aux/nm-keyfile-aux.h | 10 +- src/libnm-glib-aux/nm-logging-base.c | 4 +- src/libnm-glib-aux/nm-macros-internal.h | 24 +- src/libnm-glib-aux/nm-random-utils.c | 6 +- src/libnm-glib-aux/nm-secret-utils.h | 4 +- src/libnm-glib-aux/nm-shared-utils.c | 298 +-- src/libnm-glib-aux/nm-shared-utils.h | 184 +- src/libnm-glib-aux/nm-str-buf.h | 2 +- src/libnm-glib-aux/nm-test-utils.h | 236 +-- src/libnm-glib-aux/nm-uuid.c | 14 +- src/libnm-glib-aux/nm-uuid.h | 10 +- src/libnm-glib-aux/nm-value-type.h | 6 +- src/libnm-glib-aux/tests/test-json-aux.c | 2 +- .../tests/test-shared-general.c | 40 +- src/libnm-log-core/nm-logging.c | 28 +- src/libnm-platform/nm-linux-platform.c | 610 +++--- src/libnm-platform/nm-netlink.c | 46 +- src/libnm-platform/nm-netlink.h | 42 +- src/libnm-platform/nm-platform-private.h | 2 +- src/libnm-platform/nm-platform-utils.c | 64 +- src/libnm-platform/nm-platform-utils.h | 8 +- src/libnm-platform/nm-platform.c | 334 ++-- src/libnm-platform/nm-platform.h | 304 +-- src/libnm-platform/nmp-netns.c | 24 +- src/libnm-platform/nmp-object.c | 160 +- src/libnm-platform/nmp-object.h | 78 +- src/libnm-platform/nmp-rules-manager.c | 34 +- src/libnm-platform/nmp-rules-manager.h | 6 +- .../wifi/nm-wifi-utils-nl80211.c | 86 +- .../wifi/nm-wifi-utils-private.h | 4 +- src/libnm-platform/wifi/nm-wifi-utils-wext.c | 14 +- src/libnm-platform/wifi/nm-wifi-utils.c | 4 +- src/libnm-platform/wifi/nm-wifi-utils.h | 4 +- src/libnm-platform/wpan/nm-wpan-utils.c | 22 +- src/libnm-std-aux/c-list-util.h | 2 +- src/libnm-systemd-core/nm-sd-utils-dhcp.h | 2 +- src/libnm-udev-aux/nm-udev-utils.c | 24 +- src/libnm-udev-aux/nm-udev-utils.h | 4 +- src/libnmc-base/nm-client-utils.c | 38 +- src/libnmc-base/nm-client-utils.h | 12 +- src/libnmc-base/nm-polkit-listener.c | 104 +- src/libnmc-base/nm-secret-agent-simple.c | 206 +- src/libnmc-base/nm-secret-agent-simple.h | 12 +- src/libnmc-base/nm-vpn-helpers.c | 94 +- src/libnmc-base/nm-vpn-helpers.h | 10 +- src/libnmc-base/qrcodegen.c | 2 +- src/libnmc-base/qrcodegen.h | 2 +- src/libnmc-setting/nm-meta-setting-access.c | 74 +- src/libnmc-setting/nm-meta-setting-access.h | 40 +- .../nm-meta-setting-base-impl.c | 4 +- .../nm-meta-setting-base-impl.h | 16 +- src/libnmc-setting/nm-meta-setting-desc.c | 593 +++--- src/libnmc-setting/nm-meta-setting-desc.h | 94 +- .../tests/test-libnmc-setting.c | 96 +- src/libnmt-newt/nmt-newt-button-box.c | 16 +- src/libnmt-newt/nmt-newt-button.c | 6 +- src/libnmt-newt/nmt-newt-checkbox.c | 10 +- src/libnmt-newt/nmt-newt-component.c | 8 +- src/libnmt-newt/nmt-newt-container.c | 8 +- src/libnmt-newt/nmt-newt-entry-numeric.c | 10 +- src/libnmt-newt/nmt-newt-entry.c | 16 +- src/libnmt-newt/nmt-newt-entry.h | 2 +- src/libnmt-newt/nmt-newt-form.c | 18 +- src/libnmt-newt/nmt-newt-grid.c | 32 +- src/libnmt-newt/nmt-newt-hacks.c | 10 +- src/libnmt-newt/nmt-newt-label.c | 6 +- src/libnmt-newt/nmt-newt-listbox.c | 12 +- src/libnmt-newt/nmt-newt-popup.c | 18 +- src/libnmt-newt/nmt-newt-section.c | 20 +- src/libnmt-newt/nmt-newt-stack.c | 8 +- src/libnmt-newt/nmt-newt-textbox.c | 14 +- src/libnmt-newt/nmt-newt-toggle-button.c | 12 +- src/libnmt-newt/nmt-newt-utils.c | 24 +- src/nm-cloud-setup/main.c | 122 +- src/nm-cloud-setup/nm-cloud-setup-utils.c | 54 +- src/nm-cloud-setup/nm-cloud-setup-utils.h | 28 +- src/nm-cloud-setup/nm-http-client.c | 104 +- src/nm-cloud-setup/nm-http-client.h | 30 +- src/nm-cloud-setup/nmcs-provider-aliyun.c | 48 +- src/nm-cloud-setup/nmcs-provider-azure.c | 78 +- src/nm-cloud-setup/nmcs-provider-ec2.c | 42 +- src/nm-cloud-setup/nmcs-provider-gcp.c | 64 +- src/nm-cloud-setup/nmcs-provider.c | 20 +- src/nm-cloud-setup/nmcs-provider.h | 16 +- .../tests/test-cloud-setup-general.c | 8 +- src/nm-dispatcher/nm-dispatcher-utils.c | 68 +- src/nm-dispatcher/nm-dispatcher-utils.h | 30 +- src/nm-dispatcher/nm-dispatcher.c | 82 +- .../tests/test-dispatcher-envp.c | 146 +- src/nm-initrd-generator/nm-initrd-generator.c | 36 +- src/nm-initrd-generator/nm-initrd-generator.h | 6 +- src/nm-initrd-generator/nmi-cmdline-reader.c | 224 +-- src/nm-initrd-generator/nmi-dt-reader.c | 46 +- src/nm-initrd-generator/nmi-ibft-reader.c | 52 +- .../tests/test-cmdline-reader.c | 398 ++-- .../tests/test-dt-reader.c | 20 +- .../tests/test-ibft-reader.c | 62 +- src/nm-online/nm-online.c | 8 +- src/nm-sudo/nm-sudo.c | 42 +- src/nmcli/agent.c | 23 +- src/nmcli/common.c | 152 +- src/nmcli/common.h | 32 +- src/nmcli/connections.c | 1117 +++++------ src/nmcli/connections.h | 8 +- src/nmcli/devices.c | 524 +++--- src/nmcli/general.c | 93 +- src/nmcli/generate-docs-nm-settings-nmcli.c | 10 +- src/nmcli/nmcli.c | 26 +- src/nmcli/nmcli.h | 14 +- src/nmcli/polkit-agent.c | 2 +- src/nmcli/settings.c | 78 +- src/nmcli/settings.h | 18 +- src/nmcli/utils.c | 174 +- src/nmcli/utils.h | 54 +- src/nmtui/nm-editor-bindings.c | 200 +- src/nmtui/nm-editor-bindings.h | 68 +- src/nmtui/nm-editor-utils.c | 44 +- src/nmtui/nm-editor-utils.h | 2 +- src/nmtui/nmt-address-list.c | 20 +- src/nmtui/nmt-connect-connection-list.c | 86 +- src/nmtui/nmt-connect-connection-list.h | 18 +- src/nmtui/nmt-device-entry.c | 48 +- src/nmtui/nmt-device-entry.h | 4 +- src/nmtui/nmt-edit-connection-list.c | 42 +- src/nmtui/nmt-edit-connection-list.h | 2 +- src/nmtui/nmt-editor-grid.c | 50 +- src/nmtui/nmt-editor-grid.h | 6 +- src/nmtui/nmt-editor-page-device.c | 8 +- src/nmtui/nmt-editor-page.c | 2 +- src/nmtui/nmt-editor-section.c | 8 +- src/nmtui/nmt-editor-section.h | 2 +- src/nmtui/nmt-editor.c | 44 +- src/nmtui/nmt-ip-entry.c | 2 +- src/nmtui/nmt-mac-entry.c | 2 +- src/nmtui/nmt-mtu-entry.c | 8 +- src/nmtui/nmt-page-bond-port.c | 10 +- src/nmtui/nmt-page-bond.c | 58 +- src/nmtui/nmt-page-bridge-port.c | 10 +- src/nmtui/nmt-page-bridge.c | 14 +- src/nmtui/nmt-page-dsl.c | 16 +- src/nmtui/nmt-page-ethernet.c | 12 +- src/nmtui/nmt-page-infiniband.c | 12 +- src/nmtui/nmt-page-ip-tunnel.c | 18 +- src/nmtui/nmt-page-ip4.c | 18 +- src/nmtui/nmt-page-ip6.c | 18 +- src/nmtui/nmt-page-ppp.c | 32 +- src/nmtui/nmt-page-team-port.c | 18 +- src/nmtui/nmt-page-team.c | 26 +- src/nmtui/nmt-page-vlan.c | 12 +- src/nmtui/nmt-page-wifi.c | 44 +- src/nmtui/nmt-page-wireguard.c | 12 +- src/nmtui/nmt-password-dialog.c | 18 +- src/nmtui/nmt-password-dialog.h | 4 +- src/nmtui/nmt-password-fields.c | 12 +- src/nmtui/nmt-route-editor.c | 12 +- src/nmtui/nmt-route-entry.c | 10 +- src/nmtui/nmt-route-table.c | 32 +- src/nmtui/nmt-slave-list.c | 12 +- src/nmtui/nmt-slave-list.h | 2 +- src/nmtui/nmt-utils.c | 2 +- src/nmtui/nmt-widget-list.c | 8 +- src/nmtui/nmt-widget-list.h | 2 +- src/nmtui/nmt-wireguard-peer-editor.c | 22 +- src/nmtui/nmt-wireguard-peer-list.c | 34 +- src/nmtui/nmtui-connect.c | 64 +- src/nmtui/nmtui-edit.c | 48 +- src/nmtui/nmtui-edit.h | 6 +- src/nmtui/nmtui-hostname.c | 14 +- src/nmtui/nmtui.c | 26 +- 633 files changed, 21047 insertions(+), 20964 deletions(-) diff --git a/examples/C/glib/add-connection-gdbus.c b/examples/C/glib/add-connection-gdbus.c index 6dc3b8d471..96006689ef 100644 --- a/examples/C/glib/add-connection-gdbus.c +++ b/examples/C/glib/add-connection-gdbus.c @@ -27,7 +27,7 @@ char * nm_utils_uuid_generate(void) { uuid_t uuid; - char * buf; + char *buf; buf = g_malloc0(37); uuid_generate_random(uuid); @@ -40,10 +40,10 @@ add_connection(GDBusProxy *proxy, const char *con_name) { GVariantBuilder connection_builder; GVariantBuilder setting_builder; - char * uuid; - const char * new_con_path; - GVariant * ret; - GError * error = NULL; + char *uuid; + const char *new_con_path; + GVariant *ret; + GError *error = NULL; /* Initialize connection GVariantBuilder */ g_variant_builder_init(&connection_builder, G_VARIANT_TYPE("a{sa{sv}}")); @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) { GDBusProxy *proxy; - GError * error = NULL; + GError *error = NULL; /* Create a D-Bus proxy; NM_DBUS_* defined in nm-dbus-interface.h */ proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, diff --git a/examples/C/glib/add-connection-libnm.c b/examples/C/glib/add-connection-libnm.c index 6e4cd6b8ae..a1b48003d7 100644 --- a/examples/C/glib/add-connection-libnm.c +++ b/examples/C/glib/add-connection-libnm.c @@ -19,9 +19,9 @@ static void added_cb(GObject *client, GAsyncResult *result, gpointer user_data) { - GMainLoop * loop = user_data; + GMainLoop *loop = user_data; NMRemoteConnection *remote; - GError * error = NULL; + GError *error = NULL; /* NM responded to our request; either handle the resulting error or * print out the object path of the connection we just added. @@ -43,11 +43,11 @@ added_cb(GObject *client, GAsyncResult *result, gpointer user_data) static void add_connection(NMClient *client, GMainLoop *loop, const char *con_name) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIP4Config * s_ip4; - char * uuid; + NMSettingWired *s_wired; + NMSettingIP4Config *s_ip4; + char *uuid; /* Create a new connection object */ connection = nm_simple_connection_new(); @@ -88,9 +88,9 @@ add_connection(NMClient *client, GMainLoop *loop, const char *con_name) int main(int argc, char *argv[]) { - NMClient * client; + NMClient *client; GMainLoop *loop; - GError * error = NULL; + GError *error = NULL; loop = g_main_loop_new(NULL, FALSE); diff --git a/examples/C/glib/get-active-connections-gdbus.c b/examples/C/glib/get-active-connections-gdbus.c index c07b0f15f7..8118d76982 100644 --- a/examples/C/glib/get-active-connections-gdbus.c +++ b/examples/C/glib/get-active-connections-gdbus.c @@ -25,9 +25,9 @@ static void print_setting(const char *setting_name, GVariant *setting) { GVariantIter iter; - const char * property_name; - GVariant * value; - char * printed_value; + const char *property_name; + GVariant *value; + char *printed_value; g_print(" %s:\n", setting_name); g_variant_iter_init(&iter, setting); @@ -43,14 +43,14 @@ print_setting(const char *setting_name, GVariant *setting) static void print_connection(const char *path) { - GDBusProxy * proxy; - GError * error = NULL; - GVariant * ret, *connection = NULL, *s_con = NULL; - const char * id, *type; + GDBusProxy *proxy; + GError *error = NULL; + GVariant *ret, *connection = NULL, *s_con = NULL; + const char *id, *type; gboolean found; GVariantIter iter; - const char * setting_name; - GVariant * setting; + const char *setting_name; + GVariant *setting; /* This function asks NetworkManager for the details of the connection */ @@ -125,9 +125,9 @@ static void get_active_connection_details(const char *obj_path) { GDBusProxy *props_proxy; - GVariant * ret = NULL, *path_value = NULL; + GVariant *ret = NULL, *path_value = NULL; const char *path = NULL; - GError * error = NULL; + GError *error = NULL; /* This function gets the backing Connection object that describes the * network configuration that the ActiveConnection object is actually using. @@ -185,9 +185,9 @@ out: static void get_active_connections(GDBusProxy *proxy) { - GError * error = NULL; + GError *error = NULL; GVariant *ret = NULL, *value = NULL; - char ** paths; + char **paths; int i; /* Get the ActiveConnections property from the NM Manager object */ diff --git a/examples/C/glib/get-ap-info-libnm.c b/examples/C/glib/get-ap-info-libnm.c index 247ab8f191..ebde7d4809 100644 --- a/examples/C/glib/get-ap-info-libnm.c +++ b/examples/C/glib/get-ap-info-libnm.c @@ -65,11 +65,11 @@ show_access_point_info(NMAccessPoint *ap) { guint32 flags, wpa_flags, rsn_flags, freq, bitrate; guint8 strength; - GBytes * ssid; + GBytes *ssid; const char *hwaddr; NM80211Mode mode; - char * freq_str, *ssid_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str; - GString * security_str; + char *freq_str, *ssid_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str; + GString *security_str; /* Get AP properties */ flags = nm_access_point_get_flags(ap); @@ -138,13 +138,13 @@ show_access_point_info(NMAccessPoint *ap) static void show_wifi_device_info(NMDevice *device) { - NMAccessPoint * active_ap = NULL; + NMAccessPoint *active_ap = NULL; const GPtrArray *aps; - const char * iface; - const char * driver; + const char *iface; + const char *driver; guint32 speed; - GBytes * active_ssid; - char * active_ssid_str = NULL; + GBytes *active_ssid; + char *active_ssid_str = NULL; int i; /* Get active AP */ @@ -185,10 +185,10 @@ show_wifi_device_info(NMDevice *device) int main(int argc, char *argv[]) { - NMClient * client; + NMClient *client; const GPtrArray *devices; int i; - GError * error = NULL; + GError *error = NULL; /* Get NMClient object */ client = nm_client_new(NULL, &error); diff --git a/examples/C/glib/list-connections-gdbus.c b/examples/C/glib/list-connections-gdbus.c index babf6f14ae..19c4dbbf8f 100644 --- a/examples/C/glib/list-connections-gdbus.c +++ b/examples/C/glib/list-connections-gdbus.c @@ -21,9 +21,9 @@ static void list_connections(GDBusProxy *proxy) { int i; - GError * error = NULL; + GError *error = NULL; GVariant *ret; - char ** paths; + char **paths; /* Call ListConnections D-Bus method */ ret = g_dbus_proxy_call_sync(proxy, diff --git a/examples/C/glib/list-connections-libnm.c b/examples/C/glib/list-connections-libnm.c index 0cee2f7b24..03c147518c 100644 --- a/examples/C/glib/list-connections-libnm.c +++ b/examples/C/glib/list-connections-libnm.c @@ -24,9 +24,9 @@ show_connection(NMConnection *connection) { NMSettingConnection *s_con; guint64 timestamp; - char * timestamp_str; + char *timestamp_str; char timestamp_real_str[64]; - const char * val1, *val2, *val3, *val4, *val5; + const char *val1, *val2, *val3, *val4, *val5; s_con = nm_connection_get_setting_connection(connection); if (s_con) { @@ -55,8 +55,8 @@ show_connection(NMConnection *connection) int main(int argc, char *argv[]) { - NMClient * client; - GError * error = NULL; + NMClient *client; + GError *error = NULL; const GPtrArray *connections; int i; diff --git a/examples/C/glib/monitor-nm-running-gdbus.c b/examples/C/glib/monitor-nm-running-gdbus.c index 11eddce8b4..f25b2e8544 100644 --- a/examples/C/glib/monitor-nm-running-gdbus.c +++ b/examples/C/glib/monitor-nm-running-gdbus.c @@ -18,8 +18,8 @@ static void on_name_appeared(GDBusConnection *connection, - const char * name, - const char * name_owner, + const char *name, + const char *name_owner, gpointer user_data) { g_print("Name '%s' on the system bus is owned by %s => NM is running\n", name, name_owner); @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { guint watcher_id; - GMainLoop * loop; + GMainLoop *loop; GBusNameWatcherFlags flags; g_print("Monitor 'org.freedesktop.NetworkManager' D-Bus name\n"); diff --git a/examples/C/glib/monitor-nm-state-gdbus.c b/examples/C/glib/monitor-nm-state-gdbus.c index 5e938f2ba4..927c966cc8 100644 --- a/examples/C/glib/monitor-nm-state-gdbus.c +++ b/examples/C/glib/monitor-nm-state-gdbus.c @@ -45,9 +45,9 @@ nm_state_to_string(NMState state) static void on_signal(GDBusProxy *proxy, - char * sender_name, - char * signal_name, - GVariant * parameters, + char *sender_name, + char *signal_name, + GVariant *parameters, gpointer user_data) { guint32 new_state; @@ -72,10 +72,10 @@ on_signal(GDBusProxy *proxy, int main(int argc, char *argv[]) { - GMainLoop * loop; - GError * error = NULL; + GMainLoop *loop; + GError *error = NULL; GDBusProxyFlags flags; - GDBusProxy * proxy; + GDBusProxy *proxy; /* Monitor 'StateChanged' signal on 'org.freedesktop.NetworkManager' interface */ g_print("Monitor NetworkManager's state\n"); diff --git a/examples/C/glib/vpn-import-libnm.c b/examples/C/glib/vpn-import-libnm.c index 55ed5175c1..61a33a761d 100644 --- a/examples/C/glib/vpn-import-libnm.c +++ b/examples/C/glib/vpn-import-libnm.c @@ -17,18 +17,18 @@ static NMConnection * vpn_connection_import(const char *filename) { NMConnection *conn = NULL; - GSList * plugins; - GSList * iter; + GSList *plugins; + GSList *iter; g_print("Try to import file \"%s\"...\n", filename); plugins = nm_vpn_plugin_info_list_load(); for (iter = plugins; iter; iter = iter->next) { - GError * error = NULL; - NMVpnPluginInfo * plugin = iter->data; + GError *error = NULL; + NMVpnPluginInfo *plugin = iter->data; NMVpnEditorPlugin *editor; - const char * plugin_name = nm_vpn_plugin_info_get_name(plugin); + const char *plugin_name = nm_vpn_plugin_info_get_name(plugin); g_print("plugin[%s]: trying import...\n", plugin_name); @@ -72,8 +72,8 @@ vpn_connection_import(const char *filename) /*****************************************************************************/ typedef struct { - GMainLoop * loop; - GError * error; + GMainLoop *loop; + GError *error; NMRemoteConnection *rconn; } RequestData; @@ -89,8 +89,8 @@ add_cb(GObject *source, GAsyncResult *result, gpointer user_data) static NMRemoteConnection * connection_add(NMConnection *conn) { - GError * error = NULL; - NMClient * client; + GError *error = NULL; + NMClient *client; RequestData rdata; g_print("Adding connection \"%s\" (%s)\n", @@ -137,8 +137,8 @@ int main(int argc, char **argv) { NMRemoteConnection *rconn; - NMConnection * conn; - const char * filename; + NMConnection *conn; + const char *filename; gboolean success; if (argc < 2) { diff --git a/src/contrib/nm-compat.c b/src/contrib/nm-compat.c index f15c29c9e6..d322cb1f23 100644 --- a/src/contrib/nm-compat.c +++ b/src/contrib/nm-compat.c @@ -22,7 +22,7 @@ _get_keys(NMSettingVpn *setting, gboolean is_secrets, guint *out_length) { guint len; const char **keys = NULL; - GPtrArray * a; + GPtrArray *a; nm_assert(NM_IS_SETTING_VPN(setting)); diff --git a/src/contrib/nm-vpn-editor-plugin-call.h b/src/contrib/nm-vpn-editor-plugin-call.h index be0a6772e2..713ddf082e 100644 --- a/src/contrib/nm-vpn-editor-plugin-call.h +++ b/src/contrib/nm-vpn-editor-plugin-call.h @@ -33,21 +33,21 @@ typedef enum { /*< skip >*/ } NMVpnEditorPluginServiceFlags; struct _NMVpnEditorPluginVT { - gboolean (*fcn_get_service_info)(NMVpnEditorPlugin * plugin, - const char * service_type, - char ** out_short_name, - char ** out_pretty_name, - char ** out_description, + gboolean (*fcn_get_service_info)(NMVpnEditorPlugin *plugin, + const char *service_type, + char **out_short_name, + char **out_pretty_name, + char **out_description, NMVpnEditorPluginServiceFlags *out_flags); char **(*fcn_get_service_add_details)(NMVpnEditorPlugin *plugin, const char *service_name); gboolean (*fcn_get_service_add_detail)(NMVpnEditorPlugin *plugin, - const char * service_type, - const char * add_detail, - char ** out_pretty_name, - char ** out_description, - char ** out_add_detail_key, - char ** out_add_detail_val, - guint * out_flags); + const char *service_type, + const char *add_detail, + char **out_pretty_name, + char **out_description, + char **out_add_detail_key, + char **out_add_detail_val, + guint *out_flags); }; /***************************************************************************** @@ -58,17 +58,17 @@ struct _NMVpnEditorPluginVT { *****************************************************************************/ static inline gboolean -nm_vpn_editor_plugin_get_service_info(NMVpnEditorPlugin * plugin, - const char * service_type, - char ** out_short_name, - char ** out_pretty_name, - char ** out_description, +nm_vpn_editor_plugin_get_service_info(NMVpnEditorPlugin *plugin, + const char *service_type, + char **out_short_name, + char **out_pretty_name, + char **out_description, NMVpnEditorPluginServiceFlags *out_flags) { NMVpnEditorPluginVT vt; - gs_free char * short_name_local = NULL; - gs_free char * pretty_name_local = NULL; - gs_free char * description_local = NULL; + gs_free char *short_name_local = NULL; + gs_free char *pretty_name_local = NULL; + gs_free char *description_local = NULL; guint flags_local = 0; g_return_val_if_fail(NM_IS_VPN_EDITOR_PLUGIN(plugin), FALSE); @@ -94,7 +94,7 @@ static inline char ** nm_vpn_editor_plugin_get_service_add_details(NMVpnEditorPlugin *plugin, const char *service_name) { NMVpnEditorPluginVT vt; - char ** details = NULL; + char **details = NULL; g_return_val_if_fail(NM_IS_VPN_EDITOR_PLUGIN(plugin), NULL); g_return_val_if_fail(service_name, NULL); @@ -109,19 +109,19 @@ nm_vpn_editor_plugin_get_service_add_details(NMVpnEditorPlugin *plugin, const ch static inline gboolean nm_vpn_editor_plugin_get_service_add_detail(NMVpnEditorPlugin *plugin, - const char * service_type, - const char * add_detail, - char ** out_pretty_name, - char ** out_description, - char ** out_add_detail_key, - char ** out_add_detail_val, - guint * out_flags) + const char *service_type, + const char *add_detail, + char **out_pretty_name, + char **out_description, + char **out_add_detail_key, + char **out_add_detail_val, + guint *out_flags) { NMVpnEditorPluginVT vt; - gs_free char * pretty_name_local = NULL; - gs_free char * description_local = NULL; - gs_free char * add_detail_key_local = NULL; - gs_free char * add_detail_val_local = NULL; + gs_free char *pretty_name_local = NULL; + gs_free char *description_local = NULL; + gs_free char *add_detail_key_local = NULL; + gs_free char *add_detail_val_local = NULL; guint flags_local = 0; g_return_val_if_fail(NM_IS_VPN_EDITOR_PLUGIN(plugin), FALSE); diff --git a/src/contrib/nm-vpn-plugin-utils.c b/src/contrib/nm-vpn-plugin-utils.c index b10695b74d..32af40cf12 100644 --- a/src/contrib/nm-vpn-plugin-utils.c +++ b/src/contrib/nm-vpn-plugin-utils.c @@ -12,22 +12,22 @@ /*****************************************************************************/ NMVpnEditor * -nm_vpn_plugin_utils_load_editor(const char * module_name, - const char * factory_name, +nm_vpn_plugin_utils_load_editor(const char *module_name, + const char *factory_name, NMVpnPluginUtilsEditorFactory editor_factory, - NMVpnEditorPlugin * editor_plugin, - NMConnection * connection, + NMVpnEditorPlugin *editor_plugin, + NMConnection *connection, gpointer user_data, - GError ** error) + GError **error) { static struct { gpointer factory; - void * dl_module; - char * module_name; - char * factory_name; + void *dl_module; + char *module_name; + char *factory_name; } cached = {0}; - NMVpnEditor * editor; + NMVpnEditor *editor; gs_free char *module_path = NULL; gs_free char *dirname = NULL; Dl_info plugin_info; @@ -79,7 +79,7 @@ nm_vpn_plugin_utils_load_editor(const char * module_name, NULL); } else { gpointer factory; - void * dl_module; + void *dl_module; dl_module = dlopen(module_path, RTLD_LAZY | RTLD_LOCAL); if (!dl_module) { diff --git a/src/contrib/nm-vpn-plugin-utils.h b/src/contrib/nm-vpn-plugin-utils.h index 288143efb5..b27b75134c 100644 --- a/src/contrib/nm-vpn-plugin-utils.h +++ b/src/contrib/nm-vpn-plugin-utils.h @@ -10,16 +10,16 @@ typedef NMVpnEditor *(NMVpnPluginUtilsEditorFactory) (gpointer factory, NMVpnEditorPlugin *editor_plugin, - NMConnection * connection, + NMConnection *connection, gpointer user_data, - GError ** error); + GError **error); -NMVpnEditor *nm_vpn_plugin_utils_load_editor(const char * module_name, - const char * factory_name, +NMVpnEditor *nm_vpn_plugin_utils_load_editor(const char *module_name, + const char *factory_name, NMVpnPluginUtilsEditorFactory editor_factory, - NMVpnEditorPlugin * editor_plugin, - NMConnection * connection, + NMVpnEditorPlugin *editor_plugin, + NMConnection *connection, gpointer user_data, - GError ** error); + GError **error); #endif /* __NM_VPN_PLUGIN_UTILS_H__ */ diff --git a/src/core/NetworkManagerUtils.c b/src/core/NetworkManagerUtils.c index e057f5534b..0d08efbb9c 100644 --- a/src/core/NetworkManagerUtils.c +++ b/src/core/NetworkManagerUtils.c @@ -43,9 +43,9 @@ const char * nm_utils_get_shared_wifi_permission(NMConnection *connection) { - NMSettingWireless * s_wifi; + NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - const char * method; + const char *method; method = nm_utils_get_ip_config_method(connection, AF_INET); if (!nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) @@ -67,8 +67,8 @@ nm_utils_get_shared_wifi_permission(NMConnection *connection) static char * get_new_connection_name(NMConnection *const *existing_connections, - const char * preferred, - const char * fallback_prefix) + const char *preferred, + const char *fallback_prefix) { gs_free const char **existing_names = NULL; guint i, existing_len = 0; @@ -80,7 +80,7 @@ get_new_connection_name(NMConnection *const *existing_connections, existing_names = g_new(const char *, existing_len); for (i = 0; i < existing_len; i++) { NMConnection *candidate; - const char * id; + const char *id; candidate = existing_connections[i]; nm_assert(NM_IS_CONNECTION(candidate)); @@ -122,9 +122,9 @@ get_new_connection_name(NMConnection *const *existing_connections, } static char * -get_new_connection_ifname(NMPlatform * platform, +get_new_connection_ifname(NMPlatform *platform, NMConnection *const *existing_connections, - const char * prefix) + const char *prefix) { guint i, j; @@ -154,8 +154,8 @@ const char * nm_utils_get_ip_config_method(NMConnection *connection, int addr_family) { NMSettingConnection *s_con; - NMSettingIPConfig * s_ip; - const char * method; + NMSettingIPConfig *s_ip; + const char *method; s_con = nm_connection_get_setting_connection(connection); @@ -185,9 +185,9 @@ nm_utils_get_ip_config_method(NMConnection *connection, int addr_family) gboolean nm_utils_connection_has_default_route(NMConnection *connection, int addr_family, - gboolean * out_is_never_default) + gboolean *out_is_never_default) { - const char * method; + const char *method; NMSettingIPConfig *s_ip; gboolean is_never_default = FALSE; gboolean has_default_route = FALSE; @@ -230,8 +230,8 @@ out: void nm_utils_ppp_ip_methods_enabled(NMConnection *connection, - gboolean * out_ip4_enabled, - gboolean * out_ip6_enabled) + gboolean *out_ip4_enabled, + gboolean *out_ip6_enabled) { NM_SET_OUT(out_ip4_enabled, nm_streq0(nm_utils_get_ip_config_method(connection, AF_INET), @@ -244,23 +244,23 @@ nm_utils_ppp_ip_methods_enabled(NMConnection *connection, /*****************************************************************************/ void -_nm_utils_complete_generic_with_params(NMPlatform * platform, - NMConnection * connection, - const char * ctype, +_nm_utils_complete_generic_with_params(NMPlatform *platform, + NMConnection *connection, + const char *ctype, NMConnection *const *existing_connections, - const char * preferred_id, - const char * fallback_id_prefix, - const char * ifname_prefix, - const char * ifname, + const char *preferred_id, + const char *fallback_id_prefix, + const char *ifname_prefix, + const char *ifname, ...) { - NMSettingConnection *s_con; - char * id; - char * generated_ifname; + NMSettingConnection *s_con; + char *id; + char *generated_ifname; gs_unref_hashtable GHashTable *parameters = NULL; va_list ap; - const char * p_val; - const char * p_key; + const char *p_val; + const char *p_key; g_assert(fallback_id_prefix); g_return_if_fail(ifname_prefix == NULL || ifname == NULL); @@ -340,8 +340,8 @@ remove_from_hash(GHashTable *s_hash, GHashTable *p_hash, const char *s_name, con static gboolean check_ip6_method(NMConnection *orig, NMConnection *candidate, GHashTable *settings) { - GHashTable * props; - const char * orig_ip6_method, *candidate_ip6_method; + GHashTable *props; + const char *orig_ip6_method, *candidate_ip6_method; NMSettingIPConfig *candidate_ip6; gboolean allow = FALSE; @@ -431,16 +431,16 @@ route_ptr_compare(const void *a, const void *b, gpointer metric) static gboolean check_ip_routes(NMConnection *orig, NMConnection *candidate, - GHashTable * settings, + GHashTable *settings, gint64 default_metric, gboolean v4) { gs_free NMIPRoute **routes1 = NULL; - NMIPRoute ** routes2; - NMSettingIPConfig * s_ip1, *s_ip2; + NMIPRoute **routes2; + NMSettingIPConfig *s_ip1, *s_ip2; gint64 m; - const char * s_name; - GHashTable * props; + const char *s_name; + GHashTable *props; guint i, i1, i2, num1, num2; const guint8 PLEN = v4 ? 32 : 128; @@ -509,11 +509,11 @@ check_ip_routes(NMConnection *orig, static gboolean check_ip4_method(NMConnection *orig, NMConnection *candidate, - GHashTable * settings, + GHashTable *settings, gboolean device_has_carrier) { - GHashTable * props; - const char * orig_ip4_method, *candidate_ip4_method; + GHashTable *props; + const char *orig_ip4_method, *candidate_ip4_method; NMSettingIPConfig *candidate_ip4; props = check_property_in_hash(settings, @@ -547,8 +547,8 @@ check_ip4_method(NMConnection *orig, static gboolean check_connection_interface_name(NMConnection *orig, NMConnection *candidate, GHashTable *settings) { - GHashTable * props; - const char * orig_ifname, *cand_ifname; + GHashTable *props; + const char *orig_ifname, *cand_ifname; NMSettingConnection *s_con_orig, *s_con_cand; props = check_property_in_hash(settings, @@ -576,8 +576,8 @@ check_connection_interface_name(NMConnection *orig, NMConnection *candidate, GHa static gboolean check_connection_mac_address(NMConnection *orig, NMConnection *candidate, GHashTable *settings) { - GHashTable * props; - const char * orig_mac = NULL, *cand_mac = NULL; + GHashTable *props; + const char *orig_mac = NULL, *cand_mac = NULL; NMSettingWired *s_wired_orig, *s_wired_cand; props = check_property_in_hash(settings, @@ -608,10 +608,10 @@ check_connection_mac_address(NMConnection *orig, NMConnection *candidate, GHashT static gboolean check_connection_infiniband_mac_address(NMConnection *orig, NMConnection *candidate, - GHashTable * settings) + GHashTable *settings) { - GHashTable * props; - const char * orig_mac = NULL, *cand_mac = NULL; + GHashTable *props; + const char *orig_mac = NULL, *cand_mac = NULL; NMSettingInfiniband *s_infiniband_orig, *s_infiniband_cand; props = check_property_in_hash(settings, @@ -642,10 +642,10 @@ check_connection_infiniband_mac_address(NMConnection *orig, static gboolean check_connection_cloned_mac_address(NMConnection *orig, NMConnection *candidate, - GHashTable * settings) + GHashTable *settings) { - GHashTable * props; - const char * orig_mac = NULL, *cand_mac = NULL; + GHashTable *props; + const char *orig_mac = NULL, *cand_mac = NULL; NMSettingWired *s_wired_orig, *s_wired_cand; props = check_property_in_hash(settings, @@ -682,7 +682,7 @@ check_connection_cloned_mac_address(NMConnection *orig, static gboolean check_connection_s390_props(NMConnection *orig, NMConnection *candidate, GHashTable *settings) { - GHashTable * props1, *props2, *props3; + GHashTable *props1, *props2, *props3; NMSettingWired *s_wired_orig, *s_wired_cand; props1 = check_property_in_hash(settings, @@ -704,7 +704,7 @@ check_connection_s390_props(NMConnection *orig, NMConnection *candidate, GHashTa s_wired_cand = nm_connection_get_setting_wired(candidate); if (!s_wired_orig && s_wired_cand) { const char *const *subchans = nm_setting_wired_get_s390_subchannels(s_wired_cand); - const char * nettype = nm_setting_wired_get_s390_nettype(s_wired_cand); + const char *nettype = nm_setting_wired_get_s390_nettype(s_wired_cand); guint32 num_options = nm_setting_wired_get_num_s390_options(s_wired_cand); if ((!subchans || !*subchans) && !nettype && num_options == 0) { @@ -729,7 +729,7 @@ check_connection_s390_props(NMConnection *orig, NMConnection *candidate, GHashTa static NMConnection * check_possible_match(NMConnection *orig, NMConnection *candidate, - GHashTable * settings, + GHashTable *settings, gboolean device_has_carrier, gint64 default_v4_metric, gint64 default_v6_metric) @@ -795,8 +795,8 @@ check_possible_match(NMConnection *orig, * matches well enough. */ NMConnection * -nm_utils_match_connection(NMConnection *const * connections, - NMConnection * original, +nm_utils_match_connection(NMConnection *const *connections, + NMConnection *original, gboolean indicated, gboolean device_has_carrier, gint64 default_v4_metric, @@ -811,7 +811,7 @@ nm_utils_match_connection(NMConnection *const * connections, for (; *connections; connections++) { NMConnection *candidate = *connections; - GHashTable * diffs = NULL; + GHashTable *diffs = NULL; nm_assert(NM_IS_CONNECTION(candidate)); @@ -851,7 +851,7 @@ nm_utils_match_connection(NMConnection *const * connections, } if (!best_match && nm_logging_enabled(LOGL_DEBUG, LOGD_CORE)) { - GString * diff_string; + GString *diff_string; GHashTableIter s_iter, p_iter; gpointer setting_name, setting; gpointer property_name, value; @@ -894,9 +894,9 @@ nm_utils_match_connection(NMConnection *const * connections, int nm_match_spec_device_by_pllink(const NMPlatformLink *pllink, - const char * match_device_type, - const char * match_dhcp_plugin, - const GSList * specs, + const char *match_device_type, + const char *match_dhcp_plugin, + const GSList *specs, int no_match_value) { NMMatchSpecMatchType m; @@ -987,7 +987,7 @@ nm_ip_routing_rule_to_platform(const NMIPRoutingRule *rule, NMPlatformRoutingRul struct _NMShutdownWaitObjHandle { CList lst; gpointer watched_obj; - char * msg_reason; + char *msg_reason; bool free_msg_reason : 1; bool is_cancellable : 1; }; @@ -1060,7 +1060,7 @@ _shutdown_waitobj_cb(gpointer user_data, GObject *where_the_object_was) NMShutdownWaitObjHandle * nm_shutdown_wait_obj_register_full(gpointer watched_obj, NMShutdownWaitType wait_type, - char * msg_reason, + char *msg_reason, gboolean free_msg_reason) { NMShutdownWaitObjHandle *handle; @@ -1180,8 +1180,8 @@ nm_utils_qdiscs_from_tc_setting(NMPlatform *platform, NMSettingTCConfig *s_tc, i qdiscs = g_ptr_array_new_full(nqdiscs, (GDestroyNotify) nmp_object_unref); for (i = 0; i < nqdiscs; i++) { - NMTCQdisc * s_qdisc = nm_setting_tc_config_get_qdisc(s_tc, i); - NMPObject * q = nmp_object_new(NMP_OBJECT_TYPE_QDISC, NULL); + NMTCQdisc *s_qdisc = nm_setting_tc_config_get_qdisc(s_tc, i); + NMPObject *q = nmp_object_new(NMP_OBJECT_TYPE_QDISC, NULL); NMPlatformQdisc *qdisc = NMP_OBJECT_CAST_QDISC(q); qdisc->ifindex = ip_ifindex; @@ -1254,9 +1254,9 @@ nm_utils_tfilters_from_tc_setting(NMPlatform *platform, NMSettingTCConfig *s_tc, tfilters = g_ptr_array_new_full(ntfilters, (GDestroyNotify) nmp_object_unref); for (i = 0; i < ntfilters; i++) { - NMTCTfilter * s_tfilter = nm_setting_tc_config_get_tfilter(s_tc, i); - NMTCAction * action; - NMPObject * t = nmp_object_new(NMP_OBJECT_TYPE_TFILTER, NULL); + NMTCTfilter *s_tfilter = nm_setting_tc_config_get_tfilter(s_tc, i); + NMTCAction *action; + NMPObject *t = nmp_object_new(NMP_OBJECT_TYPE_TFILTER, NULL); NMPlatformTfilter *tfilter = NMP_OBJECT_CAST_TFILTER(t); tfilter->ifindex = ip_ifindex; @@ -1312,11 +1312,11 @@ nm_utils_tfilters_from_tc_setting(NMPlatform *platform, NMSettingTCConfig *s_tc, void nm_utils_ip_route_attribute_to_platform(int addr_family, - NMIPRoute * s_route, + NMIPRoute *s_route, NMPlatformIPRoute *r, gint64 route_table) { - GVariant * variant; + GVariant *variant; guint32 table; NMIPAddr addr; NMPlatformIP4Route *r4 = (NMPlatformIP4Route *) r; @@ -1422,9 +1422,9 @@ nm_utils_ip_route_attribute_to_platform(int addr_family, void nm_utils_ip_addresses_to_dbus(int addr_family, const NMDedupMultiHeadEntry *head_entry, - const NMPObject * best_default_route, - GVariant ** out_address_data, - GVariant ** out_addresses) + const NMPObject *best_default_route, + GVariant **out_address_data, + GVariant **out_addresses) { const int IS_IPv4 = NM_IS_IPv4(addr_family); GVariantBuilder builder_data; @@ -1536,8 +1536,8 @@ out: void nm_utils_ip_routes_to_dbus(int addr_family, const NMDedupMultiHeadEntry *head_entry, - GVariant ** out_route_data, - GVariant ** out_routes) + GVariant **out_route_data, + GVariant **out_routes) { const int IS_IPv4 = NM_IS_IPv4(addr_family); NMDedupMultiIter iter; @@ -1659,14 +1659,14 @@ nm_utils_platform_capture_ip_setting(NMPlatform *platform, int ifindex, gboolean maybe_ipv6_disabled) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - gs_unref_object NMSettingIPConfig *s_ip = NULL; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + gs_unref_object NMSettingIPConfig *s_ip = NULL; NMPLookup lookup; NMDedupMultiIter iter; - const NMPObject * obj; - const char * method = NULL; + const NMPObject *obj; + const char *method = NULL; char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - const NMPlatformIPXRoute * best_default_route = NULL; + const NMPlatformIPXRoute *best_default_route = NULL; s_ip = NM_SETTING_IP_CONFIG(IS_IPv4 ? nm_setting_ip4_config_new() : nm_setting_ip6_config_new()); @@ -1682,8 +1682,8 @@ nm_utils_platform_capture_ip_setting(NMPlatform *platform, nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex); nm_platform_iter_obj_for_each (&iter, platform, &lookup, &obj) { - const NMPlatformIPXAddress *address = NMP_OBJECT_CAST_IPX_ADDRESS(obj); - nm_auto_unref_ip_address NMIPAddress *s_addr = NULL; + const NMPlatformIPXAddress *address = NMP_OBJECT_CAST_IPX_ADDRESS(obj); + nm_auto_unref_ip_address NMIPAddress *s_addr = NULL; if (!IS_IPv4) { /* Ignore link-local address. */ @@ -1736,7 +1736,7 @@ nm_utils_platform_capture_ip_setting(NMPlatform *platform, nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4), ifindex); nm_platform_iter_obj_for_each (&iter, platform, &lookup, &obj) { - const NMPlatformIPXRoute *route = NMP_OBJECT_CAST_IPX_ROUTE(obj); + const NMPlatformIPXRoute *route = NMP_OBJECT_CAST_IPX_ROUTE(obj); nm_auto_unref_ip_route NMIPRoute *s_route = NULL; if (!IS_IPv4) { diff --git a/src/core/NetworkManagerUtils.h b/src/core/NetworkManagerUtils.h index 0f68a3f6ef..c9210ba8c5 100644 --- a/src/core/NetworkManagerUtils.h +++ b/src/core/NetworkManagerUtils.h @@ -20,17 +20,17 @@ const char *nm_utils_get_ip_config_method(NMConnection *connection, int addr_fam const char *nm_utils_get_shared_wifi_permission(NMConnection *connection); void nm_utils_ppp_ip_methods_enabled(NMConnection *connection, - gboolean * out_ip4_enabled, - gboolean * out_ip6_enabled); + gboolean *out_ip4_enabled, + gboolean *out_ip6_enabled); -void _nm_utils_complete_generic_with_params(NMPlatform * platform, - NMConnection * connection, - const char * ctype, +void _nm_utils_complete_generic_with_params(NMPlatform *platform, + NMConnection *connection, + const char *ctype, NMConnection *const *existing_connections, - const char * preferred_id, - const char * fallback_id_prefix, - const char * ifname_prefix, - const char * ifname, + const char *preferred_id, + const char *fallback_id_prefix, + const char *ifname_prefix, + const char *ifname, ...) G_GNUC_NULL_TERMINATED; #define nm_utils_complete_generic_with_params(platform, \ @@ -54,14 +54,14 @@ void _nm_utils_complete_generic_with_params(NMPlatform * platform, NULL) static inline void -nm_utils_complete_generic(NMPlatform * platform, - NMConnection * connection, - const char * ctype, +nm_utils_complete_generic(NMPlatform *platform, + NMConnection *connection, + const char *ctype, NMConnection *const *existing_connections, - const char * preferred_id, - const char * fallback_id_prefix, - const char * ifname_prefix, - const char * ifname, + const char *preferred_id, + const char *fallback_id_prefix, + const char *ifname_prefix, + const char *ifname, gboolean default_enable_ipv6) { nm_utils_complete_generic_with_params(platform, @@ -80,8 +80,8 @@ nm_utils_complete_generic(NMPlatform * platform, typedef gboolean(NMUtilsMatchFilterFunc)(NMConnection *connection, gpointer user_data); -NMConnection *nm_utils_match_connection(NMConnection *const * connections, - NMConnection * original, +NMConnection *nm_utils_match_connection(NMConnection *const *connections, + NMConnection *original, gboolean indicated, gboolean device_has_carrier, gint64 default_v4_metric, @@ -90,9 +90,9 @@ NMConnection *nm_utils_match_connection(NMConnection *const * connections, gpointer match_filter_data); int nm_match_spec_device_by_pllink(const NMPlatformLink *pllink, - const char * match_device_type, - const char * match_dhcp_plugin, - const GSList * specs, + const char *match_device_type, + const char *match_dhcp_plugin, + const GSList *specs, int no_match_value); /*****************************************************************************/ @@ -140,12 +140,12 @@ typedef struct _NMShutdownWaitObjHandle NMShutdownWaitObjHandle; NMShutdownWaitObjHandle *nm_shutdown_wait_obj_register_full(gpointer watched_obj, NMShutdownWaitType wait_type, - char * msg_reason, + char *msg_reason, gboolean free_msg_reason); static inline NMShutdownWaitObjHandle * nm_shutdown_wait_obj_register_object_full(gpointer watched_obj, - char * msg_reason, + char *msg_reason, gboolean free_msg_reason) { return nm_shutdown_wait_obj_register_full(watched_obj, @@ -171,7 +171,7 @@ nm_shutdown_wait_obj_register_handle_full(char *msg_reason, gboolean free_msg_re static inline NMShutdownWaitObjHandle * nm_shutdown_wait_obj_register_cancellable_full(GCancellable *watched_obj, - char * msg_reason, + char *msg_reason, gboolean free_msg_reason) { return nm_shutdown_wait_obj_register_full(watched_obj, @@ -197,20 +197,20 @@ GPtrArray * nm_utils_tfilters_from_tc_setting(NMPlatform *platform, NMSettingTCConfig *s_tc, int ip_ifindex); void nm_utils_ip_route_attribute_to_platform(int addr_family, - NMIPRoute * s_route, + NMIPRoute *s_route, NMPlatformIPRoute *r, gint64 route_table); void nm_utils_ip_addresses_to_dbus(int addr_family, const NMDedupMultiHeadEntry *head_entry, - const NMPObject * best_default_route, - GVariant ** out_address_data, - GVariant ** out_addresses); + const NMPObject *best_default_route, + GVariant **out_address_data, + GVariant **out_addresses); void nm_utils_ip_routes_to_dbus(int addr_family, const NMDedupMultiHeadEntry *head_entry, - GVariant ** out_route_data, - GVariant ** out_routes); + GVariant **out_route_data, + GVariant **out_routes); /*****************************************************************************/ diff --git a/src/core/devices/adsl/nm-atm-manager.c b/src/core/devices/adsl/nm-atm-manager.c index bd9ed8cc23..cc8d37e6c3 100644 --- a/src/core/devices/adsl/nm-atm-manager.c +++ b/src/core/devices/adsl/nm-atm-manager.c @@ -27,7 +27,7 @@ typedef struct { NMUdevClient *udev_client; - GSList * devices; + GSList *devices; } NMAtmManagerPrivate; typedef struct { @@ -51,7 +51,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES( NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_ADSL_SETTING_NAME)); G_MODULE_EXPORT NMDeviceFactory * - nm_device_factory_create(GError **error) +nm_device_factory_create(GError **error) { return g_object_new(NM_TYPE_ATM_MANAGER, NULL); } @@ -62,7 +62,7 @@ static gboolean dev_get_attrs(struct udev_device *udev_device, const char **out_path, char **out_driver) { struct udev_device *parent = NULL; - const char * driver, *path; + const char *driver, *path; g_return_val_if_fail(udev_device != NULL, FALSE); g_return_val_if_fail(out_path != NULL, FALSE); @@ -91,7 +91,7 @@ dev_get_attrs(struct udev_device *udev_device, const char **out_path, char **out static void device_destroyed(gpointer user_data, GObject *dead) { - NMAtmManager * self = NM_ATM_MANAGER(user_data); + NMAtmManager *self = NM_ATM_MANAGER(user_data); NMAtmManagerPrivate *priv = NM_ATM_MANAGER_GET_PRIVATE(self); priv->devices = g_slist_remove(priv->devices, dead); @@ -101,11 +101,11 @@ static void adsl_add(NMAtmManager *self, struct udev_device *udev_device) { NMAtmManagerPrivate *priv = NM_ATM_MANAGER_GET_PRIVATE(self); - const char * ifname, *sysfs_path = NULL; - char * driver = NULL; - gs_free char * atm_index_path = NULL; + const char *ifname, *sysfs_path = NULL; + char *driver = NULL; + gs_free char *atm_index_path = NULL; int atm_index; - NMDevice * device; + NMDevice *device; g_return_if_fail(udev_device != NULL); @@ -153,8 +153,8 @@ static void adsl_remove(NMAtmManager *self, struct udev_device *udev_device) { NMAtmManagerPrivate *priv = NM_ATM_MANAGER_GET_PRIVATE(self); - const char * iface = udev_device_get_sysname(udev_device); - GSList * iter; + const char *iface = udev_device_get_sysname(udev_device); + GSList *iter; nm_log_dbg(LOGD_PLATFORM, "(%s): removing ATM device", iface); @@ -177,9 +177,9 @@ adsl_remove(NMAtmManager *self, struct udev_device *udev_device) static void start(NMDeviceFactory *factory) { - NMAtmManager * self = NM_ATM_MANAGER(factory); - NMAtmManagerPrivate * priv = NM_ATM_MANAGER_GET_PRIVATE(self); - struct udev_enumerate * enumerate; + NMAtmManager *self = NM_ATM_MANAGER(factory); + NMAtmManagerPrivate *priv = NM_ATM_MANAGER_GET_PRIVATE(self); + struct udev_enumerate *enumerate; struct udev_list_entry *devices; enumerate = nm_udev_client_enumerate_new(priv->udev_client); @@ -203,10 +203,10 @@ static void handle_uevent(NMUdevClient *client, struct udev_device *device, gpointer user_data) { NMAtmManager *self = NM_ATM_MANAGER(user_data); - const char * subsys; - const char * ifindex; + const char *subsys; + const char *ifindex; guint64 seqnum; - const char * action; + const char *action; action = udev_device_get_action(device); @@ -245,9 +245,9 @@ nm_atm_manager_init(NMAtmManager *self) static void dispose(GObject *object) { - NMAtmManager * self = NM_ATM_MANAGER(object); + NMAtmManager *self = NM_ATM_MANAGER(object); NMAtmManagerPrivate *priv = NM_ATM_MANAGER_GET_PRIVATE(self); - GSList * iter; + GSList *iter; for (iter = priv->devices; iter; iter = iter->next) g_object_weak_unref(G_OBJECT(iter->data), device_destroyed, self); @@ -261,7 +261,7 @@ dispose(GObject *object) static void nm_atm_manager_class_init(NMAtmManagerClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS(klass); object_class->dispose = dispose; diff --git a/src/core/devices/adsl/nm-device-adsl.c b/src/core/devices/adsl/nm-device-adsl.c index 6133a3d056..79705c28f0 100644 --- a/src/core/devices/adsl/nm-device-adsl.c +++ b/src/core/devices/adsl/nm-device-adsl.c @@ -38,7 +38,7 @@ typedef struct { /* RFC 2684 bridging (PPPoE over ATM) */ int brfd; int nas_ifindex; - char * nas_ifname; + char *nas_ifname; GSource *nas_update_source; guint nas_update_count; } NMDeviceAdslPrivate; @@ -70,7 +70,7 @@ static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMSettingAdsl *s_adsl; - const char * protocol; + const char *protocol; if (!NM_DEVICE_CLASS(nm_device_adsl_parent_class) ->check_connection_compatible(device, connection, error)) @@ -91,11 +91,11 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingAdsl *s_adsl; @@ -124,12 +124,12 @@ complete_connection(NMDevice * device, static gboolean br2684_assign_vcc(NMDeviceAdsl *self, NMSettingAdsl *s_adsl) { - NMDeviceAdslPrivate * priv = NM_DEVICE_ADSL_GET_PRIVATE(self); + NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); struct sockaddr_atmpvc addr; struct atm_backend_br2684 be; struct atm_qos qos; int errsv, err, bufsize = 8192; - const char * encapsulation; + const char *encapsulation; gboolean is_llc; g_return_val_if_fail(priv->brfd == -1, FALSE); @@ -214,18 +214,18 @@ error: } static void -link_changed_cb(NMPlatform * platform, +link_changed_cb(NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *info, int change_type_i, - NMDeviceAdsl * self) + NMDeviceAdsl *self) { const NMPlatformSignalChangeType change_type = change_type_i; if (change_type == NM_PLATFORM_SIGNAL_REMOVED) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); /* This only gets called for PPPoE connections and "nas" interfaces */ @@ -243,8 +243,8 @@ static gboolean pppoe_vcc_config(NMDeviceAdsl *self) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); - NMSettingAdsl * s_adsl; + NMDevice *device = NM_DEVICE(self); + NMSettingAdsl *s_adsl; s_adsl = nm_device_get_applied_setting(device, NM_TYPE_SETTING_ADSL); @@ -271,9 +271,9 @@ pppoe_vcc_config(NMDeviceAdsl *self) static gboolean nas_update_timeout_cb(gpointer user_data) { - NMDeviceAdsl * self = NM_DEVICE_ADSL(user_data); + NMDeviceAdsl *self = NM_DEVICE_ADSL(user_data); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); nm_assert(priv->nas_ifname); @@ -316,7 +316,7 @@ nas_update_timeout_cb(gpointer user_data) static gboolean br2684_create_iface(NMDeviceAdsl *self) { - NMDeviceAdslPrivate * priv = NM_DEVICE_ADSL_GET_PRIVATE(self); + NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); struct atm_newif_br2684 ni; nm_auto_close int fd = -1; int err; @@ -377,7 +377,7 @@ _ppp_mgr_cleanup(NMDeviceAdsl *self) static void _ppp_mgr_stage3_maybe_ready(NMDeviceAdsl *self) { - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); int IS_IPv4; @@ -398,7 +398,7 @@ static void _ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, gpointer user_data) { NMDeviceAdsl *self = NM_DEVICE_ADSL(user_data); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceState device_state; if (callback_data->callback_type != NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED) @@ -414,8 +414,8 @@ _ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, if (device_state < NM_DEVICE_STATE_IP_CONFIG) { if (callback_data->data.state >= NM_PPP_MGR_STATE_HAVE_IFINDEX) { - gs_free char *old_name = NULL; - gs_free_error GError *error = NULL; + gs_free char *old_name = NULL; + gs_free_error GError *error = NULL; if (!nm_device_take_over_link(device, callback_data->data.ifindex, &old_name, &error)) { _LOGW(LOGD_DEVICE | LOGD_PPP, @@ -445,15 +445,15 @@ _ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceAdsl * self = NM_DEVICE_ADSL(device); + NMDeviceAdsl *self = NM_DEVICE_ADSL(device); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); if (!priv->ppp_mgr) { gs_free_error GError *error = NULL; - NMSettingAdsl * s_adsl; - const char * protocol; - NMActRequest * req; - const char * ppp_iface; + NMSettingAdsl *s_adsl; + const char *protocol; + NMActRequest *req; + const char *ppp_iface; req = nm_device_get_act_request(device); g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); @@ -520,7 +520,7 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) static void act_stage3_ip_config(NMDevice *device, int addr_family) { - NMDeviceAdsl * self = NM_DEVICE_ADSL(device); + NMDeviceAdsl *self = NM_DEVICE_ADSL(device); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); NMPppMgrState ppp_state; @@ -577,7 +577,7 @@ carrier_update_cb(gpointer user_data) { NMDeviceAdsl *self = NM_DEVICE_ADSL(user_data); int carrier; - char * path; + char *path; path = g_strdup_printf("/sys/class/atm/%s/carrier", NM_ASSERT_VALID_PATH_COMPONENT(nm_device_get_iface(NM_DEVICE(self)))); @@ -632,7 +632,7 @@ nm_device_adsl_init(NMDeviceAdsl *self) static void constructed(GObject *object) { - NMDeviceAdsl * self = NM_DEVICE_ADSL(object); + NMDeviceAdsl *self = NM_DEVICE_ADSL(object); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE(self); G_OBJECT_CLASS(nm_device_adsl_parent_class)->constructed(object); @@ -686,9 +686,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_adsl = { static void nm_device_adsl_class_init(NMDeviceAdslClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; object_class->dispose = dispose; diff --git a/src/core/devices/bluetooth/nm-bluez-manager.c b/src/core/devices/bluetooth/nm-bluez-manager.c index 5713d42714..5852d4c13b 100644 --- a/src/core/devices/bluetooth/nm-bluez-manager.c +++ b/src/core/devices/bluetooth/nm-bluez-manager.c @@ -38,7 +38,7 @@ #define _NM_BT_CAPABILITY_SUPPORTED (NM_BT_CAPABILITY_NAP | _NM_BT_CAPABILITY_SUPPORTED_DUN) typedef struct { - const char * bdaddr; + const char *bdaddr; CList lst_head; NMBluetoothCapabilities bt_type : 8; char bdaddr_data[]; @@ -46,24 +46,24 @@ typedef struct { typedef struct { NMSettingsConnection *sett_conn; - ConnDataHead * cdata_hd; + ConnDataHead *cdata_hd; CList lst; } ConnDataElem; typedef struct { - GCancellable * ext_cancellable; - GCancellable * int_cancellable; + GCancellable *ext_cancellable; + GCancellable *int_cancellable; NMBtVTableRegisterCallback callback; gpointer callback_user_data; gulong ext_cancelled_id; } NetworkServerRegisterReqData; typedef struct { - GCancellable * ext_cancellable; - GCancellable * int_cancellable; + GCancellable *ext_cancellable; + GCancellable *int_cancellable; NMBluezManagerConnectCb callback; gpointer callback_user_data; - char * device_name; + char *device_name; gulong ext_cancelled_id; guint timeout_id; guint timeout_wait_connect_id; @@ -97,16 +97,16 @@ typedef struct { struct { CList lst; - char * adapter_address; - NMDevice * device_br; + char *adapter_address; + NMDevice *device_br; NetworkServerRegisterReqData *r_req_data; } x_network_server; struct { NMSettingsConnection *panu_connection; - NMDeviceBt * device_bt; + NMDeviceBt *device_bt; DeviceConnectReqData *c_req_data; - NMBluez5DunContext * connect_dun_context; + NMBluez5DunContext *connect_dun_context; gulong device_bt_signal_id; } x_device; @@ -142,7 +142,7 @@ typedef struct { } BzDBusObj; typedef struct { - NMManager * manager; + NMManager *manager; NMSettings *settings; GDBusConnection *dbus_connection; @@ -194,7 +194,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES(NM_DEVICE_FACTORY_DECLARE_LINK_TYPES( NM_LINK_TYPE_BNEP) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_BLUETOOTH_SETTING_NAME)) G_MODULE_EXPORT NMDeviceFactory * - nm_device_factory_create(GError **error) +nm_device_factory_create(GError **error) { return g_object_new(NM_TYPE_BLUEZ_MANAGER, NULL); } @@ -214,8 +214,8 @@ convert_uuids_to_capabilities(const char *const *strv) if (strv) { for (; strv[0]; strv++) { gs_free char *s_part1 = NULL; - const char * str = strv[0]; - const char * s; + const char *str = strv[0]; + const char *s; s = strchr(str, '-'); if (!s) @@ -245,8 +245,8 @@ static void _connect_disconnect(NMBluezManager *self, BzDBusObj *bzobj, cons static gboolean _bzobjs_network_server_is_usable(const BzDBusObj *bzobj, gboolean require_powered); static gboolean _bzobjs_is_dead(const BzDBusObj *bzobj); static gboolean _bzobjs_device_is_usable(const BzDBusObj *bzobj, - BzDBusObj ** out_adapter_bzobj, - gboolean * out_create_panu_connection); + BzDBusObj **out_adapter_bzobj, + gboolean *out_create_panu_connection); static gboolean _bzobjs_adapter_is_usable_for_device(const BzDBusObj *bzobj); static ConnDataHead * _conn_track_find_head(NMBluezManager *self, NMBluetoothCapabilities bt_type, const char *bdaddr); @@ -293,9 +293,9 @@ _network_server_register_req_data_complete(NetworkServerRegisterReqData *r_req_d static void _device_connect_req_data_complete(DeviceConnectReqData *c_req_data, - NMBluezManager * self, - const char * device_name, - GError * error) + NMBluezManager *self, + const char *device_name, + GError *error) { nm_assert((!!device_name) != (!!error)); @@ -371,7 +371,7 @@ _bz_dbus_obj_free(BzDBusObj *bzobj) static const char * _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len) { - char * buf0 = buf; + char *buf0 = buf; const char *prefix = ""; gboolean device_is_usable; gboolean create_panu_connection = FALSE; @@ -591,7 +591,7 @@ static BzDBusObj * _bzobjs_add(NMBluezManager *self, const char *object_path) { NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); - BzDBusObj * bzobj; + BzDBusObj *bzobj; bzobj = _bz_dbus_obj_new(self, object_path); if (!g_hash_table_add(priv->bzobjs, bzobj)) @@ -642,14 +642,14 @@ _bzobjs_adapter_is_usable_for_device(const BzDBusObj *bzobj) static gboolean _bzobjs_device_is_usable(const BzDBusObj *bzobj, - BzDBusObj ** out_adapter_bzobj, - gboolean * out_create_panu_connection) + BzDBusObj **out_adapter_bzobj, + gboolean *out_create_panu_connection) { - NMBluezManager * self; + NMBluezManager *self; NMBluezManagerPrivate *priv; gboolean usable_dun = FALSE; gboolean usable_nap = FALSE; - BzDBusObj * bzobj_adapter; + BzDBusObj *bzobj_adapter; gboolean create_panu_connection = FALSE; if (!bzobj->d_has_device_iface @@ -805,14 +805,14 @@ _conn_track_find_elem(NMBluezManager *self, NMSettingsConnection *sett_conn) } static gboolean -_conn_track_is_relevant_connection(NMConnection * connection, +_conn_track_is_relevant_connection(NMConnection *connection, NMBluetoothCapabilities *out_bt_type, - const char ** out_bdaddr) + const char **out_bdaddr) { - NMSettingBluetooth * s_bt; + NMSettingBluetooth *s_bt; NMBluetoothCapabilities bt_type; - const char * bdaddr; - const char * b_type; + const char *bdaddr; + const char *b_type; s_bt = nm_connection_get_setting_bluetooth(connection); if (!s_bt) @@ -840,9 +840,9 @@ _conn_track_is_relevant_connection(NMConnection * connection, } static gboolean -_conn_track_is_relevant_sett_conn(NMSettingsConnection * sett_conn, +_conn_track_is_relevant_sett_conn(NMSettingsConnection *sett_conn, NMBluetoothCapabilities *out_bt_type, - const char ** out_bdaddr) + const char **out_bdaddr) { NMConnection *connection; @@ -854,25 +854,25 @@ _conn_track_is_relevant_sett_conn(NMSettingsConnection * sett_conn, } static gboolean -_conn_track_is_relevant_for_sett_conn(NMSettingsConnection * sett_conn, +_conn_track_is_relevant_for_sett_conn(NMSettingsConnection *sett_conn, NMBluetoothCapabilities bt_type, - const char * bdaddr) + const char *bdaddr) { NMBluetoothCapabilities x_bt_type; - const char * x_bdaddr; + const char *x_bdaddr; return bdaddr && _conn_track_is_relevant_sett_conn(sett_conn, &x_bt_type, &x_bdaddr) && x_bt_type == bt_type && nm_streq(x_bdaddr, bdaddr); } static void -_conn_track_schedule_notify(NMBluezManager * self, +_conn_track_schedule_notify(NMBluezManager *self, NMBluetoothCapabilities bt_type, - const char * bdaddr) + const char *bdaddr) { NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); GHashTableIter iter; - BzDBusObj * bzobj; + BzDBusObj *bzobj; g_hash_table_iter_init(&iter, priv->bzobjs); while (g_hash_table_iter_next(&iter, (gpointer *) &bzobj, NULL)) { @@ -885,19 +885,19 @@ _conn_track_schedule_notify(NMBluezManager * self, } static void -_conn_track_update(NMBluezManager * self, +_conn_track_update(NMBluezManager *self, NMSettingsConnection *sett_conn, gboolean track, - gboolean * out_changed, - gboolean * out_changed_usable, - ConnDataElem ** out_conn_data_elem) + gboolean *out_changed, + gboolean *out_changed_usable, + ConnDataElem **out_conn_data_elem) { - NMBluezManagerPrivate * priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); - ConnDataHead * cdata_hd; - ConnDataElem * cdata_el; - ConnDataElem * cdata_el_remove = NULL; + NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); + ConnDataHead *cdata_hd; + ConnDataElem *cdata_el; + ConnDataElem *cdata_el_remove = NULL; NMBluetoothCapabilities bt_type; - const char * bdaddr; + const char *bdaddr; gboolean changed = FALSE; gboolean changed_usable = FALSE; char sbuf_cap[100]; @@ -946,7 +946,7 @@ _conn_track_update(NMBluezManager * self, out_remove: if (cdata_el_remove) { GHashTableIter iter; - BzDBusObj * bzobj; + BzDBusObj *bzobj; _LOGT("connection: untrack for %s, %s: %s (%s)", nm_bluetooth_capability_to_string(cdata_el_remove->cdata_hd->bt_type, @@ -989,10 +989,10 @@ cp_connection_added(NMSettings *settings, NMSettingsConnection *sett_conn, NMBlu } static void -cp_connection_updated(NMSettings * settings, +cp_connection_updated(NMSettings *settings, NMSettingsConnection *sett_conn, guint update_reason_u, - NMBluezManager * self) + NMBluezManager *self) { _conn_track_update(self, sett_conn, TRUE, NULL, NULL, NULL); } @@ -1032,8 +1032,8 @@ _network_server_find_has_device(NMBluezManagerPrivate *priv, NMDevice *device) static BzDBusObj * _network_server_find_available(NMBluezManagerPrivate *priv, - const char * addr, - NMDevice * device_accept_busy) + const char *addr, + NMDevice *device_accept_busy) { BzDBusObj *bzobj; @@ -1052,10 +1052,10 @@ _network_server_find_available(NMBluezManagerPrivate *priv, static gboolean _network_server_vt_is_available(const NMBtVTableNetworkServer *vtable, - const char * addr, - NMDevice * device_accept_busy) + const char *addr, + NMDevice *device_accept_busy) { - NMBluezManager * self = _network_server_get_bluez_manager(vtable); + NMBluezManager *self = _network_server_get_bluez_manager(vtable); NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); return !!_network_server_find_available(priv, addr, device_accept_busy); @@ -1064,9 +1064,9 @@ _network_server_vt_is_available(const NMBtVTableNetworkServer *vtable, static void _network_server_register_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; - BzDBusObj * bzobj; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + BzDBusObj *bzobj; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source_object), res, &error); if (!ret && nm_utils_error_is_cancelled(error)) @@ -1092,18 +1092,18 @@ _network_server_register_cancelled_cb(GCancellable *cancellable, BzDBusObj *bzob static gboolean _network_server_vt_register_bridge(const NMBtVTableNetworkServer *vtable, - const char * addr, - NMDevice * device, - GCancellable * cancellable, + const char *addr, + NMDevice *device, + GCancellable *cancellable, NMBtVTableRegisterCallback callback, gpointer callback_user_data, - GError ** error) + GError **error) { - NMBluezManager * self = _network_server_get_bluez_manager(vtable); - NMBluezManagerPrivate * priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); + NMBluezManager *self = _network_server_get_bluez_manager(vtable); + NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); NetworkServerRegisterReqData *r_req_data; - BzDBusObj * bzobj; - const char * ifname; + BzDBusObj *bzobj; + const char *ifname; g_return_val_if_fail(NM_IS_DEVICE(device), FALSE); g_return_val_if_fail(G_IS_CANCELLABLE(cancellable), FALSE); @@ -1174,8 +1174,8 @@ _network_server_vt_register_bridge(const NMBtVTableNetworkServer *vtable, static void _network_server_unregister_bridge_complete_on_idle_cb(gpointer user_data, GCancellable *cancellable) { - gs_free_error GError * error = NULL; - gs_free char * reason = NULL; + gs_free_error GError *error = NULL; + gs_free char *reason = NULL; NetworkServerRegisterReqData *r_req_data; nm_utils_user_data_unpack(user_data, &r_req_data, &reason); @@ -1190,9 +1190,9 @@ _network_server_unregister_bridge_complete_on_idle_cb(gpointer user_data, GCance static void _network_server_unregister_bridge(NMBluezManager *self, BzDBusObj *bzobj, const char *reason) { - NMBluezManagerPrivate * priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); + NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); _nm_unused gs_unref_object NMDevice *device = NULL; - NetworkServerRegisterReqData * r_req_data; + NetworkServerRegisterReqData *r_req_data; nm_assert(NM_IS_DEVICE(bzobj->x_network_server.device_br)); @@ -1242,9 +1242,9 @@ _network_server_unregister_bridge(NMBluezManager *self, BzDBusObj *bzobj, const static gboolean _network_server_vt_unregister_bridge(const NMBtVTableNetworkServer *vtable, NMDevice *device) { - NMBluezManager * self = _network_server_get_bluez_manager(vtable); + NMBluezManager *self = _network_server_get_bluez_manager(vtable); NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); - BzDBusObj * bzobj; + BzDBusObj *bzobj; g_return_val_if_fail(NM_IS_DEVICE(device), FALSE); @@ -1258,7 +1258,7 @@ _network_server_vt_unregister_bridge(const NMBtVTableNetworkServer *vtable, NMDe static void _network_server_process_change(BzDBusObj *bzobj, gboolean *out_emit_device_availability_changed) { - NMBluezManager * self = bzobj->self; + NMBluezManager *self = bzobj->self; NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); gboolean network_server_is_usable; gboolean emit_device_availability_changed = FALSE; @@ -1303,13 +1303,13 @@ _network_server_process_change(BzDBusObj *bzobj, gboolean *out_emit_device_avail static void _conn_create_panu_connection(NMBluezManager *self, BzDBusObj *bzobj) { - NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); + NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); gs_unref_object NMConnection *connection = NULL; - NMSettingsConnection * added; - NMSetting * setting; - gs_free char * id = NULL; + NMSettingsConnection *added; + NMSetting *setting; + gs_free char *id = NULL; char uuid[37]; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; nm_uuid_generate_random_str_arr(uuid); id = g_strdup_printf(_("%s Network"), bzobj->d_device.name); @@ -1398,7 +1398,7 @@ _device_state_changed_cb(NMDevice *device, static void _device_process_change(BzDBusObj *bzobj) { - NMBluezManager *self = bzobj->self; + NMBluezManager *self = bzobj->self; gs_unref_object NMDeviceBt *device_added = NULL; gs_unref_object NMDeviceBt *device_deleted = NULL; gboolean device_is_usable; @@ -1513,7 +1513,7 @@ static void _process_change_idle_all(NMBluezManager *self, gboolean *out_emit_device_availability_changed) { NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); - BzDBusObj * bzobj; + BzDBusObj *bzobj; while ( (bzobj = @@ -1537,7 +1537,7 @@ _process_change_idle_all(NMBluezManager *self, gboolean *out_emit_device_availab static gboolean _process_change_idle_cb(gpointer user_data) { - NMBluezManager * self = user_data; + NMBluezManager *self = user_data; NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); gboolean emit_device_availability_changed = FALSE; @@ -1622,7 +1622,7 @@ _dbus_process_changes(NMBluezManager *self, BzDBusObj *bzobj, const char *log_re if (recheck_devices_for_adapter) { GHashTableIter iter; - BzDBusObj * bzobj2; + BzDBusObj *bzobj2; /* we got a change to the availability of an adapter. We might need to recheck * all devices that use this adapter... */ @@ -1651,17 +1651,17 @@ _dbus_process_changes(NMBluezManager *self, BzDBusObj *bzobj, const char *log_re NM_BLUEZ5_NETWORK_SERVER_INTERFACE) static gboolean -_dbus_handle_properties_changed(NMBluezManager * self, - const char * object_path, - const char * interface_name, - GVariant * changed_properties, +_dbus_handle_properties_changed(NMBluezManager *self, + const char *object_path, + const char *interface_name, + GVariant *changed_properties, const char *const *invalidated_properties, - BzDBusObj ** inout_bzobj) + BzDBusObj **inout_bzobj) { - BzDBusObj * bzobj = NULL; + BzDBusObj *bzobj = NULL; gboolean changed = FALSE; - const char * property_name; - GVariant * property_value; + const char *property_name; + GVariant *property_value; GVariantIter iter_prop; gsize i; @@ -1933,14 +1933,14 @@ _dbus_handle_properties_changed(NMBluezManager * self, static void _dbus_handle_interface_added(NMBluezManager *self, - const char * object_path, - GVariant * ifaces, + const char *object_path, + GVariant *ifaces, gboolean initial_get_managed_objects) { - BzDBusObj * bzobj = NULL; + BzDBusObj *bzobj = NULL; gboolean changed = FALSE; - const char * interface_name; - GVariant * changed_properties; + const char *interface_name; + GVariant *changed_properties; GVariantIter iter_ifaces; nm_assert(g_variant_is_of_type(ifaces, G_VARIANT_TYPE("a{sa{sv}}"))); @@ -1966,9 +1966,9 @@ _dbus_handle_interface_added(NMBluezManager *self, } static gboolean -_dbus_handle_interface_removed(NMBluezManager * self, - const char * object_path, - BzDBusObj ** inout_bzobj, +_dbus_handle_interface_removed(NMBluezManager *self, + const char *object_path, + BzDBusObj **inout_bzobj, const char *const *removed_interfaces) { gboolean changed = FALSE; @@ -2056,16 +2056,16 @@ _dbus_handle_interface_removed(NMBluezManager * self, static void _dbus_managed_objects_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * arg_object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *arg_object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMBluezManager * self = user_data; + NMBluezManager *self = user_data; NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); - BzDBusObj * bzobj = NULL; + BzDBusObj *bzobj = NULL; gboolean changed; nm_assert(nm_streq0(interface_name, DBUS_INTERFACE_OBJECT_MANAGER)); @@ -2077,7 +2077,7 @@ _dbus_managed_objects_changed_cb(GDBusConnection *connection, if (nm_streq(signal_name, "InterfacesAdded")) { gs_unref_variant GVariant *interfaces_and_properties = NULL; - const char * object_path; + const char *object_path; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(oa{sa{sv}})"))) return; @@ -2090,7 +2090,7 @@ _dbus_managed_objects_changed_cb(GDBusConnection *connection, if (nm_streq(signal_name, "InterfacesRemoved")) { gs_free const char **interfaces = NULL; - const char * object_path; + const char *object_path; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(oas)"))) return; @@ -2106,19 +2106,19 @@ _dbus_managed_objects_changed_cb(GDBusConnection *connection, static void _dbus_properties_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMBluezManager * self = user_data; - NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); - const char * interface_name; + NMBluezManager *self = user_data; + NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); + const char *interface_name; gs_unref_variant GVariant *changed_properties = NULL; - gs_free const char ** invalidated_properties = NULL; - BzDBusObj * bzobj = NULL; + gs_free const char **invalidated_properties = NULL; + BzDBusObj *bzobj = NULL; if (priv->get_managed_objects_cancellable) { /* we still wait for the initial GetManagedObjects(). Ignore the event. */ @@ -2146,11 +2146,11 @@ _dbus_properties_changed_cb(GDBusConnection *connection, static void _dbus_get_managed_objects_cb(GVariant *result, GError *error, gpointer user_data) { - NMBluezManager * self; + NMBluezManager *self; NMBluezManagerPrivate *priv; GVariantIter iter; - const char * object_path; - GVariant * ifaces; + const char *object_path; + GVariant *ifaces; if (!result && nm_utils_error_is_cancelled(error)) return; @@ -2184,7 +2184,7 @@ _cleanup_for_name_owner(NMBluezManager *self) NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); gboolean emit_device_availability_changed = FALSE; GHashTableIter iter; - BzDBusObj * bzobj; + BzDBusObj *bzobj; gboolean first = TRUE; nm_clear_g_cancellable(&priv->get_managed_objects_cancellable); @@ -2217,7 +2217,7 @@ static void name_owner_changed(NMBluezManager *self, const char *owner) { _nm_unused gs_unref_object NMBluezManager *self_keep_alive = g_object_ref(self); - NMBluezManagerPrivate * priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); + NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); owner = nm_str_not_empty(owner); @@ -2270,15 +2270,15 @@ name_owner_changed(NMBluezManager *self, const char *owner) static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { NMBluezManager *self = user_data; - const char * new_owner; + const char *new_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) return; @@ -2321,8 +2321,8 @@ _cleanup_all(NMBluezManager *self) static void start(NMDeviceFactory *factory) { - NMBluezManager * self; - NMBluezManagerPrivate * priv; + NMBluezManager *self; + NMBluezManagerPrivate *priv; NMSettingsConnection *const *sett_conns; guint n_sett_conns; guint i; @@ -2378,12 +2378,12 @@ start(NMDeviceFactory *factory) /*****************************************************************************/ static void -_connect_returned(NMBluezManager * self, - BzDBusObj * bzobj, +_connect_returned(NMBluezManager *self, + BzDBusObj *bzobj, NMBluetoothCapabilities bt_type, - const char * device_name, - NMBluez5DunContext * dun_context, - GError * error) + const char *device_name, + NMBluez5DunContext *dun_context, + GError *error) { char sbuf_cap[100]; @@ -2449,8 +2449,8 @@ _connect_dun_notify_tty_hangup_cb(NMBluez5DunContext *context, gpointer user_dat static void _connect_dun_step2_cb(NMBluez5DunContext *context, - const char * rfcomm_dev, - GError * error, + const char *rfcomm_dev, + GError *error, gpointer user_data) { BzDBusObj *bzobj; @@ -2491,10 +2491,10 @@ _connect_dun_step2_cb(NMBluez5DunContext *context, static void _connect_dun_step1_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; - BzDBusObj * bzobj_adapter; - BzDBusObj * bzobj; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + BzDBusObj *bzobj_adapter; + BzDBusObj *bzobj; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source_object), res, &error); @@ -2537,9 +2537,9 @@ static void _connect_nap_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { gs_unref_variant GVariant *ret = NULL; - const char * network_iface_name = NULL; - gs_free_error GError *error = NULL; - BzDBusObj * bzobj; + const char *network_iface_name = NULL; + gs_free_error GError *error = NULL; + BzDBusObj *bzobj; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source_object), res, &error); @@ -2584,7 +2584,7 @@ static void _connect_disconnect(NMBluezManager *self, BzDBusObj *bzobj, const char *reason) { NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); - DeviceConnectReqData * c_req_data; + DeviceConnectReqData *c_req_data; char sbuf_cap[100]; gboolean bt_type; @@ -2655,19 +2655,19 @@ _connect_disconnect(NMBluezManager *self, BzDBusObj *bzobj, const char *reason) } gboolean -nm_bluez_manager_connect(NMBluezManager * self, - const char * object_path, +nm_bluez_manager_connect(NMBluezManager *self, + const char *object_path, NMBluetoothCapabilities connection_bt_type, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMBluezManagerConnectCb callback, gpointer callback_user_data, - GError ** error) + GError **error) { gs_unref_object GCancellable *int_cancellable = NULL; - DeviceConnectReqData * c_req_data; - NMBluezManagerPrivate * priv; - BzDBusObj * bzobj; + DeviceConnectReqData *c_req_data; + NMBluezManagerPrivate *priv; + BzDBusObj *bzobj; char sbuf_cap[100]; g_return_val_if_fail(NM_IS_BLUEZ_MANAGER(self), FALSE); @@ -2781,11 +2781,11 @@ nm_bluez_manager_disconnect(NMBluezManager *self, const char *object_path) /*****************************************************************************/ static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { *out_ignore = TRUE; g_return_val_if_fail(plink->type == NM_LINK_TYPE_BNEP, NULL); @@ -2845,7 +2845,7 @@ nm_bluez_manager_init(NMBluezManager *self) static void dispose(GObject *object) { - NMBluezManager * self = NM_BLUEZ_MANAGER(object); + NMBluezManager *self = NM_BLUEZ_MANAGER(object); NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE(self); /* FIXME(shutdown): we need a nm_device_factory_stop() hook to first unregister all @@ -2876,7 +2876,7 @@ dispose(GObject *object) static void nm_bluez_manager_class_init(NMBluezManagerClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS(klass); object_class->dispose = dispose; diff --git a/src/core/devices/bluetooth/nm-bluez-manager.h b/src/core/devices/bluetooth/nm-bluez-manager.h index 04bfea7daf..299f5c3bc0 100644 --- a/src/core/devices/bluetooth/nm-bluez-manager.h +++ b/src/core/devices/bluetooth/nm-bluez-manager.h @@ -24,18 +24,18 @@ GType nm_bluez_manager_get_type(void); typedef void (*NMBluezManagerConnectCb)( NMBluezManager *self, gboolean is_completed /* or else is early notification with DUN path */, - const char * device_name, - GError * error, + const char *device_name, + GError *error, gpointer user_data); -gboolean nm_bluez_manager_connect(NMBluezManager * self, - const char * object_path, +gboolean nm_bluez_manager_connect(NMBluezManager *self, + const char *object_path, NMBluetoothCapabilities connection_bt_type, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMBluezManagerConnectCb callback, gpointer callback_user_data, - GError ** error); + GError **error); void nm_bluez_manager_disconnect(NMBluezManager *self, const char *object_path); diff --git a/src/core/devices/bluetooth/nm-bluez5-dun.c b/src/core/devices/bluetooth/nm-bluez5-dun.c index 7efbfaf4c6..426bab0cdd 100644 --- a/src/core/devices/bluetooth/nm-bluez5-dun.c +++ b/src/core/devices/bluetooth/nm-bluez5-dun.c @@ -23,7 +23,7 @@ /*****************************************************************************/ typedef struct { - GCancellable * cancellable; + GCancellable *cancellable; NMBluez5DunConnectCb callback; gpointer callback_user_data; @@ -265,10 +265,10 @@ _connect_create_rfcomm(NMBluez5DunContext *context) static gboolean _connect_socket_connect_cb(int fd, GIOCondition condition, gpointer user_data) { - NMBluez5DunContext *context = user_data; - gs_free_error GError *error = NULL; - int errsv = 0; - socklen_t slen = sizeof(errsv); + NMBluez5DunContext *context = user_data; + gs_free_error GError *error = NULL; + int errsv = 0; + socklen_t slen = sizeof(errsv); int r; nm_clear_g_source_inst(&context->cdat->source); @@ -415,7 +415,7 @@ _connect_sdp_search_cb(uint8_t type, uint16_t status, uint8_t *rsp, size_t size, do { sdp_record_t *rec; int recsize = 0; - sdp_list_t * protos; + sdp_list_t *protos; rec = sdp_extract_pdu(rsp, bytesleft, &recsize); if (!rec) @@ -454,8 +454,8 @@ _connect_sdp_search_cb(uint8_t type, uint16_t status, uint8_t *rsp, size_t size, static gboolean _connect_sdp_search_io_cb(int fd, GIOCondition condition, gpointer user_data) { - NMBluez5DunContext *context = user_data; - gs_free_error GError *error = NULL; + NMBluez5DunContext *context = user_data; + gs_free_error GError *error = NULL; int errsv; if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) { @@ -505,8 +505,8 @@ _connect_sdp_search_io_cb(int fd, GIOCondition condition, gpointer user_data) static gboolean _connect_sdp_session_start_on_idle_cb(gpointer user_data) { - NMBluez5DunContext *context = user_data; - gs_free_error GError *error = NULL; + NMBluez5DunContext *context = user_data; + gs_free_error GError *error = NULL; nm_clear_g_source_inst(&context->cdat->source); @@ -521,15 +521,15 @@ _connect_sdp_session_start_on_idle_cb(gpointer user_data) static gboolean _connect_sdp_io_cb(int fd, GIOCondition condition, gpointer user_data) { - NMBluez5DunContext *context = user_data; - sdp_list_t * search; - sdp_list_t * attrs; - uuid_t svclass; - uint16_t attr; - int errsv; - int fd_err = 0; - int r; - socklen_t len = sizeof(fd_err); + NMBluez5DunContext *context = user_data; + sdp_list_t *search; + sdp_list_t *attrs; + uuid_t svclass; + uint16_t attr; + int errsv; + int fd_err = 0; + int r; + socklen_t len = sizeof(fd_err); gs_free_error GError *error = NULL; nm_clear_g_source_inst(&context->cdat->source); @@ -657,17 +657,17 @@ _connect_sdp_session_start(NMBluez5DunContext *context, GError **error) /*****************************************************************************/ gboolean -nm_bluez5_dun_connect(const char * adapter, - const char * remote, - GCancellable * cancellable, +nm_bluez5_dun_connect(const char *adapter, + const char *remote, + GCancellable *cancellable, NMBluez5DunConnectCb callback, gpointer callback_user_data, NMBluez5DunNotifyTtyHangupCb notify_tty_hangup_cb, gpointer notify_tty_hangup_user_data, - GError ** error) + GError **error) { nm_auto_free_context NMBluez5DunContext *context = NULL; - ConnectData * cdat; + ConnectData *cdat; gsize src_l; gsize dst_l; diff --git a/src/core/devices/bluetooth/nm-bluez5-dun.h b/src/core/devices/bluetooth/nm-bluez5-dun.h index 020d41197d..72ca13800f 100644 --- a/src/core/devices/bluetooth/nm-bluez5-dun.h +++ b/src/core/devices/bluetooth/nm-bluez5-dun.h @@ -11,20 +11,20 @@ typedef struct _NMBluez5DunContext NMBluez5DunContext; #if WITH_BLUEZ5_DUN typedef void (*NMBluez5DunConnectCb)(NMBluez5DunContext *context, - const char * rfcomm_dev, - GError * error, + const char *rfcomm_dev, + GError *error, gpointer user_data); typedef void (*NMBluez5DunNotifyTtyHangupCb)(NMBluez5DunContext *context, gpointer user_data); -gboolean nm_bluez5_dun_connect(const char * adapter, - const char * remote, - GCancellable * cancellable, +gboolean nm_bluez5_dun_connect(const char *adapter, + const char *remote, + GCancellable *cancellable, NMBluez5DunConnectCb callback, gpointer callback_user_data, NMBluez5DunNotifyTtyHangupCb notify_tty_hangup_cb, gpointer notify_tty_hangup_user_data, - GError ** error); + GError **error); void nm_bluez5_dun_disconnect(NMBluez5DunContext *context); diff --git a/src/core/devices/bluetooth/nm-device-bt.c b/src/core/devices/bluetooth/nm-device-bt.c index 5346aaed62..39b5c4eccc 100644 --- a/src/core/devices/bluetooth/nm-device-bt.c +++ b/src/core/devices/bluetooth/nm-device-bt.c @@ -114,7 +114,7 @@ static NMBluetoothCapabilities get_connection_bt_type(NMConnection *connection) { NMSettingBluetooth *s_bt; - const char * bt_type; + const char *bt_type; s_bt = nm_connection_get_setting_bluetooth(connection); @@ -132,10 +132,10 @@ get_connection_bt_type(NMConnection *connection) } static gboolean -get_connection_bt_type_check(NMDeviceBt * self, - NMConnection * connection, +get_connection_bt_type_check(NMDeviceBt *self, + NMConnection *connection, NMBluetoothCapabilities *out_bt_type, - GError ** error) + GError **error) { NMBluetoothCapabilities bt_type; @@ -169,8 +169,8 @@ get_generic_capabilities(NMDevice *device) static gboolean can_auto_connect(NMDevice *device, NMSettingsConnection *sett_conn, char **specific_object) { - NMDeviceBt * self = NM_DEVICE_BT(device); - NMDeviceBtPrivate * priv = NM_DEVICE_BT_GET_PRIVATE(self); + NMDeviceBt *self = NM_DEVICE_BT(device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); NMBluetoothCapabilities bt_type; nm_assert(!specific_object || !*specific_object); @@ -194,10 +194,10 @@ can_auto_connect(NMDevice *device, NMSettingsConnection *sett_conn, char **speci static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMDeviceBt * self = NM_DEVICE_BT(device); - NMDeviceBtPrivate * priv = NM_DEVICE_BT_GET_PRIVATE(self); + NMDeviceBt *self = NM_DEVICE_BT(device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); NMSettingBluetooth *s_bt; - const char * bdaddr; + const char *bdaddr; if (!NM_DEVICE_CLASS(nm_device_bt_parent_class) ->check_connection_compatible(device, connection, error)) @@ -226,14 +226,14 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -check_connection_available(NMDevice * device, - NMConnection * connection, +check_connection_available(NMDevice *device, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { - NMDeviceBt * self = NM_DEVICE_BT(device); - NMDeviceBtPrivate * priv = NM_DEVICE_BT_GET_PRIVATE(self); + NMDeviceBt *self = NM_DEVICE_BT(device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); NMBluetoothCapabilities bt_type; if (!get_connection_bt_type_check(self, connection, &bt_type, error)) @@ -250,23 +250,23 @@ check_connection_available(NMDevice * device, } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { - NMDeviceBtPrivate * priv = NM_DEVICE_BT_GET_PRIVATE(device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(device); NMSettingBluetooth *s_bt; - const char * setting_bdaddr; - const char * ctype; + const char *setting_bdaddr; + const char *ctype; gboolean is_dun = FALSE; gboolean is_pan = FALSE; - NMSettingGsm * s_gsm; - NMSettingCdma * s_cdma; - NMSettingSerial * s_serial; - NMSettingPpp * s_ppp; - const char * fallback_prefix = NULL, *preferred = NULL; + NMSettingGsm *s_gsm; + NMSettingCdma *s_cdma; + NMSettingSerial *s_serial; + NMSettingPpp *s_ppp; + const char *fallback_prefix = NULL, *preferred = NULL; s_gsm = nm_connection_get_setting_gsm(connection); s_cdma = nm_connection_get_setting_cdma(connection); @@ -423,7 +423,7 @@ ppp_stats(NMModem *modem, guint i_in_bytes, guint i_out_bytes, gpointer user_dat static void ppp_failed(NMModem *modem, guint i_reason, gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); + NMDevice *device = NM_DEVICE(user_data); NMDeviceStateReason reason = i_reason; nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, reason); @@ -446,7 +446,7 @@ modem_auth_requested(NMModem *modem, gpointer user_data) static void modem_auth_result(NMModem *modem, GError *error, gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); + NMDevice *device = NM_DEVICE(user_data); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(device); g_return_if_fail(nm_device_get_state(device) == NM_DEVICE_STATE_NEED_AUTH); @@ -463,8 +463,8 @@ modem_auth_result(NMModem *modem, GError *error, gpointer user_data) static void modem_prepare_result(NMModem *modem, gboolean success, guint i_reason, gpointer user_data) { - NMDeviceBt * self = user_data; - NMDeviceBtPrivate * priv = NM_DEVICE_BT_GET_PRIVATE(self); + NMDeviceBt *self = user_data; + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); NMDeviceStateReason reason = i_reason; NMDeviceState state; @@ -493,7 +493,7 @@ modem_prepare_result(NMModem *modem, gboolean success, guint i_reason, gpointer } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) @@ -512,18 +512,18 @@ device_state_changed(NMDevice * device, } static void -modem_new_config(NMModem * modem, +modem_new_config(NMModem *modem, int addr_family, - const NML3ConfigData * l3cd, + const NML3ConfigData *l3cd, gboolean do_auto, const NMUtilsIPv6IfaceId *iid, int failure_reason_i, - GError * error, + GError *error, gpointer user_data) { const int IS_IPv4 = NM_IS_IPv4(addr_family); NMDeviceBt *self = NM_DEVICE_BT(user_data); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); g_return_if_fail(nm_device_devip_get_state(device, addr_family) == NM_DEVICE_IP_STATE_PENDING); @@ -582,7 +582,7 @@ modem_state_cb(NMModem *modem, int new_state_i, int old_state_i, gpointer user_d { NMModemState new_state = new_state_i; NMModemState old_state = old_state_i; - NMDevice * device = NM_DEVICE(user_data); + NMDevice *device = NM_DEVICE(user_data); NMDeviceState dev_state = nm_device_get_state(device); if (new_state <= NM_MODEM_STATE_DISABLING && old_state > NM_MODEM_STATE_DISABLING) { @@ -611,7 +611,7 @@ modem_state_cb(NMModem *modem, int new_state_i, int old_state_i, gpointer user_d static void modem_removed_cb(NMModem *modem, gpointer user_data) { - NMDeviceBt * self = NM_DEVICE_BT(user_data); + NMDeviceBt *self = NM_DEVICE_BT(user_data); NMDeviceState state; state = nm_device_get_state(NM_DEVICE(self)); @@ -629,7 +629,7 @@ static gboolean modem_try_claim(NMDeviceBt *self, NMModem *modem) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); - gs_free char * rfcomm_base_name = NULL; + gs_free char *rfcomm_base_name = NULL; NMDeviceState state; if (priv->modem) { @@ -683,7 +683,7 @@ modem_try_claim(NMDeviceBt *self, NMModem *modem) static void mm_modem_added_cb(NMModemManager *manager, NMModem *modem, gpointer user_data) { - NMDeviceBt * self = user_data; + NMDeviceBt *self = user_data; NMDeviceBtPrivate *priv; if (!modem_try_claim(user_data, modem)) @@ -723,7 +723,7 @@ _nm_device_bt_notify_set_connected(NMDeviceBt *self, gboolean connected) static gboolean connect_watch_link_idle_cb(gpointer user_data) { - NMDeviceBt * self = user_data; + NMDeviceBt *self = user_data; NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); int ifindex; @@ -744,15 +744,15 @@ connect_watch_link_idle_cb(gpointer user_data) } static void -connect_watch_link_cb(NMPlatform * platform, +connect_watch_link_cb(NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *info, int change_type_i, - NMDevice * self) + NMDevice *self) { const NMPlatformSignalChangeType change_type = change_type_i; - NMDeviceBtPrivate * priv; + NMDeviceBtPrivate *priv; /* bluez doesn't notify us when the connection disconnects. * Neither does NMManager (or NMDevice) tell us when the ip-ifindex goes away. @@ -768,7 +768,7 @@ connect_watch_link_cb(NMPlatform * platform, static gboolean connect_wait_modem_timeout(gpointer user_data) { - NMDeviceBt * self = NM_DEVICE_BT(user_data); + NMDeviceBt *self = NM_DEVICE_BT(user_data); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); /* since this timeout is longer than the connect timeout, we must have already @@ -792,11 +792,11 @@ connect_wait_modem_timeout(gpointer user_data) static void connect_bz_cb(NMBluezManager *bz_mgr, gboolean is_complete, - const char * device_name, - GError * error, + const char *device_name, + GError *error, gpointer user_data) { - NMDeviceBt * self; + NMDeviceBt *self; NMDeviceBtPrivate *priv; char sbuf[100]; @@ -884,10 +884,10 @@ connect_bz_cb(NMBluezManager *bz_mgr, static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceBt * self = NM_DEVICE_BT(device); - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); + NMDeviceBt *self = NM_DEVICE_BT(device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); gs_free_error GError *error = NULL; - NMConnection * connection; + NMConnection *connection; connection = nm_device_get_applied_connection(device); g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); @@ -967,7 +967,7 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceBt * self = NM_DEVICE_BT(device); + NMDeviceBt *self = NM_DEVICE_BT(device); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); if (priv->connect_bt_type != NM_BT_CAPABILITY_DUN) @@ -1035,10 +1035,10 @@ _nm_device_bt_notify_removed(NMDeviceBt *self) /*****************************************************************************/ gboolean -_nm_device_bt_for_same_device(NMDeviceBt * self, - const char * dbus_path, - const char * bdaddr, - const char * name, +_nm_device_bt_for_same_device(NMDeviceBt *self, + const char *dbus_path, + const char *bdaddr, + const char *name, NMBluetoothCapabilities capabilities) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); @@ -1067,7 +1067,7 @@ _nm_device_bt_notify_set_name(NMDeviceBt *self, const char *name) static gboolean is_available(NMDevice *dev, NMDeviceCheckDevAvailableFlags flags) { - NMDeviceBt * self = NM_DEVICE_BT(dev); + NMDeviceBt *self = NM_DEVICE_BT(dev); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); /* PAN doesn't need ModemManager, so devices that support it are always available */ @@ -1171,7 +1171,7 @@ nm_device_bt_init(NMDeviceBt *self) static void constructed(GObject *object) { - NMDeviceBt * self = NM_DEVICE_BT(object); + NMDeviceBt *self = NM_DEVICE_BT(object); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); G_OBJECT_CLASS(nm_device_bt_parent_class)->constructed(object); @@ -1194,10 +1194,10 @@ constructed(GObject *object) } NMDeviceBt * -nm_device_bt_new(NMBluezManager * bz_mgr, - const char * dbus_path, - const char * bdaddr, - const char * name, +nm_device_bt_new(NMBluezManager *bz_mgr, + const char *dbus_path, + const char *bdaddr, + const char *name, NMBluetoothCapabilities capabilities) { g_return_val_if_fail(NM_IS_BLUEZ_MANAGER(bz_mgr), NULL); @@ -1235,7 +1235,7 @@ nm_device_bt_new(NMBluezManager * bz_mgr, static void dispose(GObject *object) { - NMDeviceBt * self = NM_DEVICE_BT(object); + NMDeviceBt *self = NM_DEVICE_BT(object); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(self); nm_clear_g_signal_handler(nm_device_get_platform(NM_DEVICE(self)), @@ -1290,9 +1290,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_bluetooth = { static void nm_device_bt_class_init(NMDeviceBtClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; object_class->get_property = get_property; diff --git a/src/core/devices/bluetooth/nm-device-bt.h b/src/core/devices/bluetooth/nm-device-bt.h index c2d3bc1823..59457fba27 100644 --- a/src/core/devices/bluetooth/nm-device-bt.h +++ b/src/core/devices/bluetooth/nm-device-bt.h @@ -33,15 +33,15 @@ GType nm_device_bt_get_type(void); struct _NMBluezManager; NMDeviceBt *nm_device_bt_new(struct _NMBluezManager *bz_mgr, - const char * dbus_path, - const char * bdaddr, - const char * name, + const char *dbus_path, + const char *bdaddr, + const char *name, NMBluetoothCapabilities capabilities); -gboolean _nm_device_bt_for_same_device(NMDeviceBt * device, - const char * dbus_path, - const char * bdaddr, - const char * name, +gboolean _nm_device_bt_for_same_device(NMDeviceBt *device, + const char *dbus_path, + const char *bdaddr, + const char *name, NMBluetoothCapabilities capabilities); NMBluetoothCapabilities nm_device_bt_get_capabilities(NMDeviceBt *device); diff --git a/src/core/devices/bluetooth/tests/nm-bt-test.c b/src/core/devices/bluetooth/tests/nm-bt-test.c index 548e7249a9..5aab48a5aa 100644 --- a/src/core/devices/bluetooth/tests/nm-bt-test.c +++ b/src/core/devices/bluetooth/tests/nm-bt-test.c @@ -23,8 +23,8 @@ struct { int argc; const char *const *argv; - const char * argv_cmd; - GMainLoop * loop; + const char *argv_cmd; + GMainLoop *loop; } gl; typedef struct _MainCmdInfo { @@ -38,7 +38,7 @@ typedef struct _MainCmdInfo { typedef struct { NMBluez5DunContext *dun_context; - GCancellable * cancellable; + GCancellable *cancellable; guint timeout_id; guint sig_term_id; guint sig_int_id; @@ -46,8 +46,8 @@ typedef struct { static void _dun_connect_cb(NMBluez5DunContext *context, - const char * rfcomm_dev, - GError * error, + const char *rfcomm_dev, + GError *error, gpointer user_data) { DunConnectData *dun_connect_data = user_data; @@ -118,10 +118,10 @@ do_dun_connect(const MainCmdInfo *main_cmd_info) { #if WITH_BLUEZ5_DUN gs_unref_object GCancellable *cancellable = NULL; - gs_free_error GError *error = NULL; - const char * adapter; - const char * remote; - DunConnectData dun_connect_data = {}; + gs_free_error GError *error = NULL; + const char *adapter; + const char *remote; + DunConnectData dun_connect_data = {}; if (gl.argc < 4) { _LOGE("missing arguments \"adapter\" and \"remote\""); diff --git a/src/core/devices/nm-device-6lowpan.c b/src/core/devices/nm-device-6lowpan.c index 8b77c22c9e..d654335614 100644 --- a/src/core/devices/nm-device-6lowpan.c +++ b/src/core/devices/nm-device-6lowpan.c @@ -41,7 +41,7 @@ G_DEFINE_TYPE(NMDevice6Lowpan, nm_device_6lowpan, NM_TYPE_DEVICE) /*****************************************************************************/ static void -parent_state_changed(NMDevice * parent, +parent_state_changed(NMDevice *parent, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, @@ -62,7 +62,7 @@ parent_changed_notify(NMDevice *device, int new_ifindex, NMDevice *new_parent) { - NMDevice6Lowpan * self = NM_DEVICE_6LOWPAN(device); + NMDevice6Lowpan *self = NM_DEVICE_6LOWPAN(device); NMDevice6LowpanPrivate *priv = NM_DEVICE_6LOWPAN_GET_PRIVATE(self); NM_DEVICE_CLASS(nm_device_6lowpan_parent_class) @@ -95,13 +95,13 @@ parent_changed_notify(NMDevice *device, } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); + const char *iface = nm_device_get_iface(device); NMSetting6Lowpan *s_6lowpan; int parent_ifindex; int r; @@ -175,11 +175,11 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSetting6Lowpan *s_6lowpan; @@ -249,7 +249,7 @@ static void nm_device_6lowpan_class_init(NMDevice6LowpanClass *klass) { NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_6lowpan); @@ -275,11 +275,11 @@ nm_device_6lowpan_class_init(NMDevice6LowpanClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_6LOWPAN_DEVICE_FACTORY, NM6LowpanDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_6LOWPAN, NM_DEVICE_IFACE, @@ -310,7 +310,7 @@ static char * get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface) { NMSetting6Lowpan *s_6lowpan; - const char * ifname; + const char *ifname; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_6LOWPAN_SETTING_NAME), NULL); diff --git a/src/core/devices/nm-device-bond.c b/src/core/devices/nm-device-bond.c index 3e7fd0ee18..56b729e961 100644 --- a/src/core/devices/nm-device-bond.c +++ b/src/core/devices/nm-device-bond.c @@ -74,11 +74,11 @@ get_generic_capabilities(NMDevice *dev) } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { nm_utils_complete_generic(nm_device_get_platform(device), connection, @@ -162,18 +162,18 @@ ignore_option(NMSettingBond *s_bond, const char *option, const char *value) static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceBond * self = NM_DEVICE_BOND(device); + NMDeviceBond *self = NM_DEVICE_BOND(device); NMSettingBond *s_bond = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BOND); int ifindex = nm_device_get_ifindex(device); NMBondMode mode = NM_BOND_MODE_UNKNOWN; - const char ** options; + const char **options; /* Read bond options from sysfs and update the Bond setting to match */ options = nm_setting_bond_get_valid_options(NULL); for (; options[0]; options++) { - const char * option = options[0]; + const char *option = options[0]; gs_free char *value = NULL; - char * p; + char *p; if (NM_IN_STRSET(option, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE)) continue; @@ -215,15 +215,15 @@ update_connection(NMDevice *device, NMConnection *connection) } static gboolean -controller_update_port_connection(NMDevice * self, - NMDevice * port, +controller_update_port_connection(NMDevice *self, + NMDevice *port, NMConnection *connection, - GError ** error) + GError **error) { NMSettingBondPort *s_port; int ifindex_port = nm_device_get_ifindex(port); uint queue_id = NM_BOND_PORT_QUEUE_ID_DEF; - gs_free char * queue_id_str = NULL; + gs_free char *queue_id_str = NULL; g_return_val_if_fail(ifindex_port > 0, FALSE); @@ -251,8 +251,8 @@ static void set_arp_targets(NMDevice *device, const char *cur_arp_ip_target, const char *new_arp_ip_target) { gs_unref_ptrarray GPtrArray *free_list = NULL; - gs_free const char ** cur_strv = NULL; - gs_free const char ** new_strv = NULL; + gs_free const char **cur_strv = NULL; + gs_free const char **new_strv = NULL; gsize cur_len; gsize new_len; gsize i; @@ -310,7 +310,7 @@ static void set_bond_attr_or_default(NMDevice *device, NMSettingBond *s_bond, const char *opt) { NMDeviceBond *self = NM_DEVICE_BOND(device); - const char * value; + const char *value; value = nm_setting_bond_get_option_or_default(s_bond, opt); if (!value) { @@ -352,11 +352,11 @@ set_bond_arp_ip_targets(NMDevice *device, NMSettingBond *s_bond) static gboolean apply_bonding_config(NMDeviceBond *self) { - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMSettingBond *s_bond; NMBondMode mode; - const char * mode_str; - gs_free char * device_bond_mode = NULL; + const char *mode_str; + gs_free char *device_bond_mode = NULL; s_bond = nm_device_get_applied_setting(device, NM_TYPE_SETTING_BOND); g_return_val_if_fail(s_bond, FALSE); @@ -386,7 +386,7 @@ apply_bonding_config(NMDeviceBond *self) static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceBond * self = NM_DEVICE_BOND(device); + NMDeviceBond *self = NM_DEVICE_BOND(device); NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; /* Interface must be down to set bond options */ @@ -427,7 +427,7 @@ commit_port_options(NMDevice *bond_device, NMDevice *port, NMSettingBondPort *s_ static gboolean enslave_slave(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure) { - NMDeviceBond * self = NM_DEVICE_BOND(device); + NMDeviceBond *self = NM_DEVICE_BOND(device); NMSettingBondPort *s_port; nm_device_master_check_slave_physical_port(device, port, LOGD_BOND); @@ -478,9 +478,9 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure) _LOGD(LOGD_BOND, "bond slave %s is already released", nm_device_get_ip_iface(slave)); if (configure) { - NMConnection * applied; + NMConnection *applied; NMSettingWired *s_wired; - const char * cloned_mac; + const char *cloned_mac; address = g_strdup(nm_device_get_hw_address(device)); @@ -523,11 +523,11 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { const char *iface = nm_device_get_iface(device); int r; @@ -549,12 +549,12 @@ create_and_realize(NMDevice * device, } static gboolean -can_reapply_change(NMDevice * device, +can_reapply_change(NMDevice *device, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error) + GError **error) { NMDeviceClass *device_class; @@ -562,7 +562,7 @@ can_reapply_change(NMDevice * device, if (nm_streq(setting_name, NM_SETTING_BOND_SETTING_NAME)) { NMSettingBond *s_a = NM_SETTING_BOND(s_old); NMSettingBond *s_b = NM_SETTING_BOND(s_new); - const char ** option_list; + const char **option_list; if (!nm_device_hash_check_invalid_keys(diffs, NM_SETTING_BOND_SETTING_NAME, @@ -601,9 +601,9 @@ can_reapply_change(NMDevice * device, static void reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_new) { - NMDeviceBond * self = NM_DEVICE_BOND(device); + NMDeviceBond *self = NM_DEVICE_BOND(device); NMSettingBond *s_bond; - const char * value; + const char *value; NMBondMode mode; NM_DEVICE_CLASS(nm_device_bond_parent_class)->reapply_connection(device, con_old, con_new); @@ -645,7 +645,7 @@ static void nm_device_bond_class_init(NMDeviceBondClass *klass) { NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_bond); @@ -676,11 +676,11 @@ nm_device_bond_class_init(NMDeviceBondClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_BOND_DEVICE_FACTORY, NMBondDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_BOND, NM_DEVICE_IFACE, diff --git a/src/core/devices/nm-device-bridge.c b/src/core/devices/nm-device-bridge.c index 718264fa19..4e4c263717 100644 --- a/src/core/devices/nm-device-bridge.c +++ b/src/core/devices/nm-device-bridge.c @@ -48,13 +48,13 @@ get_generic_capabilities(NMDevice *dev) } static gboolean -check_connection_available(NMDevice * device, - NMConnection * connection, +check_connection_available(NMDevice *device, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { - NMDeviceBridge * self = NM_DEVICE_BRIDGE(device); + NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); NMSettingBluetooth *s_bt; if (!NM_DEVICE_CLASS(nm_device_bridge_parent_class) @@ -97,7 +97,7 @@ static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMSettingBridge *s_bridge; - const char * mac_address; + const char *mac_address; if (!NM_DEVICE_CLASS(nm_device_bridge_parent_class) ->check_connection_compatible(device, connection, error)) @@ -140,11 +140,11 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { nm_utils_complete_generic(nm_device_get_platform(device), connection, @@ -290,8 +290,8 @@ typedef struct { #define OPTION(_name, _sysname, ...) \ { \ - .name = ""_name \ - "", \ + .name = ""_name \ + "", \ .sysname = ""_sysname \ "", \ __VA_ARGS__ \ @@ -432,8 +432,8 @@ commit_option(NMDevice *device, NMSetting *setting, const Option *option, gboole { int ifindex = nm_device_get_ifindex(device); nm_auto_unset_gvalue GValue val = G_VALUE_INIT; - GParamSpec * pspec; - const char * value; + GParamSpec *pspec; + const char *value; char value_buf[100]; if (slave) @@ -521,7 +521,7 @@ static const NMPlatformBridgeVlan ** setting_vlans_to_platform(GPtrArray *array) { NMPlatformBridgeVlan **arr; - NMPlatformBridgeVlan * p_data; + NMPlatformBridgeVlan *p_data; guint i; if (!array || !array->len) @@ -553,8 +553,8 @@ setting_vlans_to_platform(GPtrArray *array) static void commit_slave_options(NMDevice *device, NMSettingBridgePort *setting) { - const Option * option; - NMSetting * s; + const Option *option; + NMSetting *s; gs_unref_object NMSetting *s_clear = NULL; if (setting) @@ -569,11 +569,11 @@ commit_slave_options(NMDevice *device, NMSettingBridgePort *setting) static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceBridge * self = NM_DEVICE_BRIDGE(device); + NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); NMSettingBridge *s_bridge = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BRIDGE); int ifindex = nm_device_get_ifindex(device); - const Option * option; - gs_free char * stp = NULL; + const Option *option; + gs_free char *stp = NULL; int stp_value; option = master_options; @@ -589,8 +589,8 @@ update_connection(NMDevice *device, NMConnection *connection) for (; option->name; option++) { nm_auto_unset_gvalue GValue value = G_VALUE_INIT; - gs_free char * str = NULL; - GParamSpec * pspec; + gs_free char *str = NULL; + GParamSpec *pspec; str = nm_platform_sysctl_master_get_option(nm_device_get_platform(device), ifindex, @@ -664,17 +664,17 @@ out: } static gboolean -master_update_slave_connection(NMDevice * device, - NMDevice * slave, +master_update_slave_connection(NMDevice *device, + NMDevice *slave, NMConnection *connection, - GError ** error) + GError **error) { - NMDeviceBridge * self = NM_DEVICE_BRIDGE(device); + NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); NMSettingConnection *s_con; NMSettingBridgePort *s_port; int ifindex_slave = nm_device_get_ifindex(slave); - const char * iface = nm_device_get_iface(device); - const Option * option; + const char *iface = nm_device_get_iface(device); + const Option *option; g_return_val_if_fail(ifindex_slave > 0, FALSE); @@ -720,14 +720,14 @@ master_update_slave_connection(NMDevice * device, static gboolean bridge_set_vlan_options(NMDevice *device, NMSettingBridge *s_bridge) { - NMDeviceBridge * self = NM_DEVICE_BRIDGE(device); - gconstpointer hwaddr; - size_t length; - gboolean enabled; - guint16 pvid; - NMPlatform * plat; - int ifindex; - gs_unref_ptrarray GPtrArray *vlans = NULL; + NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); + gconstpointer hwaddr; + size_t length; + gboolean enabled; + guint16 pvid; + NMPlatform *plat; + int ifindex; + gs_unref_ptrarray GPtrArray *vlans = NULL; gs_free const NMPlatformBridgeVlan **plat_vlans = NULL; if (self->vlan_configured) @@ -795,7 +795,7 @@ static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { NMConnection *connection; - NMSetting * s_bridge; + NMSetting *s_bridge; const Option *option; connection = nm_device_get_applied_connection(device); @@ -859,9 +859,9 @@ _nm_device_bridge_notify_unregister_bt_nap(NMDevice *device, const char *reason) static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceBridge * self = NM_DEVICE_BRIDGE(device); - NMConnection * connection; - NMSettingBluetooth *s_bt; + NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); + NMConnection *connection; + NMSettingBluetooth *s_bt; gs_free_error GError *error = NULL; connection = nm_device_get_applied_connection(device); @@ -921,9 +921,9 @@ deactivate(NMDevice *device) static gboolean enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure) { - NMDeviceBridge * self = NM_DEVICE_BRIDGE(device); - NMConnection * master_connection; - NMSettingBridge * s_bridge; + NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); + NMConnection *master_connection; + NMSettingBridge *s_bridge; NMSettingBridgePort *s_port; if (configure) { @@ -942,7 +942,7 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool if (nm_setting_bridge_get_vlan_filtering(s_bridge)) { gs_free const NMPlatformBridgeVlan **plat_vlans = NULL; - gs_unref_ptrarray GPtrArray *vlans = NULL; + gs_unref_ptrarray GPtrArray *vlans = NULL; if (s_port) g_object_get(s_port, NM_SETTING_BRIDGE_PORT_VLANS, &vlans, NULL); @@ -1007,17 +1007,17 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - NMSettingWired * s_wired; - NMSettingBridge * s_bridge; - const char * iface = nm_device_get_iface(device); - const char * hwaddr; - gs_free char * hwaddr_cloned = NULL; + NMSettingWired *s_wired; + NMSettingBridge *s_bridge; + const char *iface = nm_device_get_iface(device); + const char *hwaddr; + gs_free char *hwaddr_cloned = NULL; guint8 mac_address[_NM_UTILS_HWADDR_LEN_MAX]; NMPlatformLnkBridge props; int r; @@ -1136,7 +1136,7 @@ static void nm_device_bridge_class_init(NMDeviceBridgeClass *klass) { NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_bridge); @@ -1170,11 +1170,11 @@ nm_device_bridge_class_init(NMDeviceBridgeClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_BRIDGE_DEVICE_FACTORY, NMBridgeDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_BRIDGE, NM_DEVICE_IFACE, diff --git a/src/core/devices/nm-device-dummy.c b/src/core/devices/nm-device-dummy.c index 60ac524988..de701a0da8 100644 --- a/src/core/devices/nm-device-dummy.c +++ b/src/core/devices/nm-device-dummy.c @@ -42,11 +42,11 @@ get_generic_capabilities(NMDevice *dev) } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { nm_utils_complete_generic_with_params(nm_device_get_platform(device), connection, @@ -69,13 +69,13 @@ update_connection(NMDevice *device, NMConnection *connection) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); + const char *iface = nm_device_get_iface(device); NMSettingDummy *s_dummy; int r; @@ -116,7 +116,7 @@ static void nm_device_dummy_class_init(NMDeviceDummyClass *klass) { NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_dummy); @@ -139,11 +139,11 @@ nm_device_dummy_class_init(NMDeviceDummyClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DUMMY_DEVICE_FACTORY, NMDummyDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_DUMMY, NM_DEVICE_IFACE, diff --git a/src/core/devices/nm-device-ethernet.c b/src/core/devices/nm-device-ethernet.c index d89bd7371c..6e18d119d0 100644 --- a/src/core/devices/nm-device-ethernet.c +++ b/src/core/devices/nm-device-ethernet.c @@ -65,21 +65,21 @@ typedef enum { typedef struct _NMDeviceEthernetPrivate { /* s390 */ - char * subchan1; - char * subchan2; - char * subchan3; - char * subchannels; /* Composite used for checking unmanaged specs */ - char ** subchannels_dbus; /* Array exported on D-Bus */ - char * s390_nettype; + char *subchan1; + char *subchan2; + char *subchan3; + char *subchannels; /* Composite used for checking unmanaged specs */ + char **subchannels_dbus; /* Array exported on D-Bus */ + char *s390_nettype; GHashTable *s390_options; guint32 speed; gulong carrier_id; struct { - NMSupplicantManager * mgr; + NMSupplicantManager *mgr; NMSupplMgrCreateIfaceHandle *create_handle; - NMSupplicantInterface * iface; + NMSupplicantInterface *iface; gulong iface_state_id; gulong auth_state_id; @@ -96,7 +96,7 @@ typedef struct _NMDeviceEthernetPrivate { struct { NMPppMgr *ppp_mgr; - GSource * wait_source; + GSource *wait_source; gint64 last_pppoe_time_msec; } ppp_data; @@ -152,12 +152,12 @@ static void _update_s390_subchannels(NMDeviceEthernet *self) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - struct udev_device * dev = NULL; - struct udev_device * parent = NULL; - const char * parent_path, *item; + struct udev_device *dev = NULL; + struct udev_device *parent = NULL; + const char *parent_path, *item; int ifindex; - GDir * dir; - GError * error = NULL; + GDir *dir; + GError *error = NULL; if (priv->subchannels) { /* only read the subchannels once. For one, we don't expect them to change @@ -253,7 +253,7 @@ _update_s390_subchannels(NMDeviceEthernet *self) } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) @@ -308,7 +308,7 @@ static gboolean match_subchans(NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_mac) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - const char *const * subchans; + const char *const *subchans; guint32 num1, num2; int i; @@ -347,7 +347,7 @@ static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); - NMSettingWired * s_wired; + NMSettingWired *s_wired; if (!NM_DEVICE_CLASS(nm_device_ethernet_parent_class) ->check_connection_compatible(device, connection, error)) @@ -365,7 +365,7 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } if (s_wired) { - const char * mac, *perm_hw_addr; + const char *mac, *perm_hw_addr; gboolean try_mac = TRUE; const char *const *mac_blacklist; int i; @@ -440,8 +440,8 @@ supplicant_interface_release(NMDeviceEthernet *self) static void supplicant_auth_state_changed(NMSupplicantInterface *iface, - GParamSpec * pspec, - NMDeviceEthernet * self) + GParamSpec *pspec, + NMDeviceEthernet *self) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); NMSupplicantAuthState state; @@ -469,7 +469,7 @@ static void wired_auth_cond_fail(NMDeviceEthernet *self, NMDeviceStateReason reason) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); if (!wired_auth_is_optional(self)) { supplicant_interface_release(self); @@ -494,14 +494,14 @@ wired_auth_cond_fail(NMDeviceEthernet *self, NMDeviceStateReason reason) } static void -wired_secrets_cb(NMActRequest * req, +wired_secrets_cb(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * connection, - GError * error, + NMSettingsConnection *connection, + GError *error, gpointer user_data) { - NMDeviceEthernet * self = user_data; - NMDevice * device = user_data; + NMDeviceEthernet *self = user_data; + NMDevice *device = user_data; NMDeviceEthernetPrivate *priv; g_return_if_fail(NM_IS_DEVICE_ETHERNET(self)); @@ -541,12 +541,12 @@ wired_secrets_cancel(NMDeviceEthernet *self) } static void -wired_secrets_get_secrets(NMDeviceEthernet * self, - const char * setting_name, +wired_secrets_get_secrets(NMDeviceEthernet *self, + const char *setting_name, NMSecretAgentGetSecretsFlags flags) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMActRequest * req; + NMActRequest *req; wired_secrets_cancel(self); @@ -561,12 +561,12 @@ wired_secrets_get_secrets(NMDeviceEthernet * self, static gboolean supplicant_lnk_timeout_cb(gpointer user_data) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(user_data); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(user_data); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); - NMActRequest * req; - NMConnection * applied_connection; - const char * setting_name; + NMDevice *device = NM_DEVICE(self); + NMActRequest *req; + NMConnection *applied_connection; + const char *setting_name; priv->supplicant.lnk_timeout_id = 0; @@ -613,10 +613,10 @@ time_out: static NMSupplicantConfig * build_supplicant_config(NMDeviceEthernet *self, GError **error) { - const char * con_uuid; + const char *con_uuid; NMSupplicantConfig *config = NULL; - NMSetting8021x * security; - NMConnection * connection; + NMSetting8021x *security; + NMConnection *connection; guint32 mtu; connection = nm_device_get_applied_connection(NM_DEVICE(self)); @@ -667,7 +667,7 @@ supplicant_iface_state_is_completed(NMDeviceEthernet *self, NMSupplicantInterfac static void supplicant_iface_assoc_cb(NMSupplicantInterface *iface, GError *error, gpointer user_data) { - NMDeviceEthernet * self; + NMDeviceEthernet *self; NMDeviceEthernetPrivate *priv; if (nm_utils_error_is_cancelled_or_disposing(error)) @@ -695,9 +695,9 @@ supplicant_iface_assoc_cb(NMSupplicantInterface *iface, GError *error, gpointer static gboolean supplicant_iface_start(NMDeviceEthernet *self) { - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); gs_unref_object NMSupplicantConfig *config = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; config = build_supplicant_config(self, &error); if (!config) { @@ -723,8 +723,8 @@ supplicant_iface_state_cb(NMSupplicantInterface *iface, int disconnect_reason, gpointer user_data) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(user_data); - NMDeviceEthernetPrivate * priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(user_data); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); NMSupplicantInterfaceState new_state = new_state_i; NMSupplicantInterfaceState old_state = old_state_i; @@ -753,7 +753,7 @@ supplicant_iface_state_cb(NMSupplicantInterface *iface, static gboolean handle_auth_or_fail(NMDeviceEthernet *self, NMActRequest *req, gboolean new_secrets) { - const char * setting_name; + const char *setting_name; NMConnection *applied_connection; if (!nm_device_auth_retries_try_next(NM_DEVICE(self))) @@ -792,11 +792,11 @@ handle_auth_or_fail(NMDeviceEthernet *self, NMActRequest *req, gboolean new_secr static gboolean supplicant_connection_timeout_cb(gpointer user_data) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(user_data); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(user_data); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); - NMActRequest * req; - NMSettingsConnection * connection; + NMDevice *device = NM_DEVICE(self); + NMActRequest *req; + NMSettingsConnection *connection; guint64 timestamp = 0; gboolean new_secrets = TRUE; @@ -836,13 +836,13 @@ supplicant_connection_timeout_cb(gpointer user_data) } static void -supplicant_interface_create_cb(NMSupplicantManager * supplicant_manager, +supplicant_interface_create_cb(NMSupplicantManager *supplicant_manager, NMSupplMgrCreateIfaceHandle *handle, - NMSupplicantInterface * iface, - GError * error, + NMSupplicantInterface *iface, + GError *error, gpointer user_data) { - NMDeviceEthernet * self; + NMDeviceEthernet *self; NMDeviceEthernetPrivate *priv; guint timeout; @@ -897,9 +897,9 @@ link_duplex_to_platform(const char *duplex) static void link_negotiation_set(NMDevice *device) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMSettingWired * s_wired; + NMSettingWired *s_wired; gboolean autoneg = TRUE; gboolean link_autoneg; NMPlatformLinkDuplexType duplex = NM_PLATFORM_LINK_DUPLEX_UNKNOWN; @@ -969,7 +969,7 @@ link_negotiation_set(NMDevice *device) static gboolean pppoe_reconnect_delay(gpointer user_data) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(user_data); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(user_data); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->ppp_data.wait_source); @@ -982,7 +982,7 @@ pppoe_reconnect_delay(gpointer user_data) static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); if (nm_device_sys_iface_state_is_external_or_assume(device)) { @@ -1044,9 +1044,9 @@ static NMActStageReturn supplicant_check_secrets_needed(NMDeviceEthernet *self, NMDeviceStateReason *out_failure_reason) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMConnection * connection; - NMSetting8021x * security; - const char * setting_name; + NMConnection *connection; + NMSetting8021x *security; + const char *setting_name; connection = nm_device_get_applied_connection(NM_DEVICE(self)); g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); @@ -1123,7 +1123,7 @@ _ppp_mgr_cleanup(NMDeviceEthernet *self) static void _ppp_mgr_stage3_maybe_ready(NMDeviceEthernet *self) { - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); int IS_IPv4; @@ -1144,7 +1144,7 @@ static void _ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, gpointer user_data) { NMDeviceEthernet *self = NM_DEVICE_ETHERNET(user_data); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceState device_state; if (callback_data->callback_type != NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED) @@ -1160,8 +1160,8 @@ _ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, if (device_state < NM_DEVICE_STATE_IP_CONFIG) { if (callback_data->data.state >= NM_PPP_MGR_STATE_HAVE_IFINDEX) { - gs_free char *old_name = NULL; - gs_free_error GError *error = NULL; + gs_free char *old_name = NULL; + gs_free_error GError *error = NULL; if (!nm_device_take_over_link(device, callback_data->data.ifindex, &old_name, &error)) { _LOGW(LOGD_DEVICE | LOGD_PPP, @@ -1193,9 +1193,9 @@ static void dcb_state(NMDevice *device, gboolean timeout); static gboolean dcb_carrier_timeout(gpointer user_data) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(user_data); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(user_data); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(user_data); + NMDevice *device = NM_DEVICE(user_data); g_return_val_if_fail(nm_device_get_state(device) == NM_DEVICE_STATE_CONFIG, G_SOURCE_REMOVE); @@ -1210,10 +1210,10 @@ dcb_carrier_timeout(gpointer user_data) static gboolean dcb_configure(NMDevice *device) { - NMDeviceEthernet * self = (NMDeviceEthernet *) device; + NMDeviceEthernet *self = (NMDeviceEthernet *) device; NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMSettingDcb * s_dcb; - GError * error = NULL; + NMSettingDcb *s_dcb; + GError *error = NULL; nm_clear_g_source(&priv->dcb_timeout_id); @@ -1239,9 +1239,9 @@ dcb_configure(NMDevice *device) static gboolean dcb_enable(NMDevice *device) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - GError * error = NULL; + GError *error = NULL; nm_clear_g_source(&priv->dcb_timeout_id); if (!nm_dcb_enable(nm_device_get_iface(device), TRUE, &error)) { @@ -1266,7 +1266,7 @@ dcb_enable(NMDevice *device) static void dcb_state(NMDevice *device, gboolean timeout) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); gboolean carrier; @@ -1345,8 +1345,8 @@ static gboolean wake_on_lan_enable(NMDevice *device) { NMSettingWiredWakeOnLan wol; - NMSettingWired * s_wired; - const char * password = NULL; + NMSettingWired *s_wired; + const char *password = NULL; s_wired = nm_device_get_applied_setting(device, NM_TYPE_SETTING_WIRED); @@ -1387,13 +1387,13 @@ found: static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMConnection * connection; - NMSettingConnection * s_con; - const char * connection_type; - NMSettingDcb * s_dcb; - NMActRequest * req; + NMConnection *connection; + NMSettingConnection *s_con; + const char *connection_type; + NMSettingDcb *s_dcb; + NMActRequest *req; connection = nm_device_get_applied_connection(device); g_return_val_if_fail(connection, NM_ACT_STAGE_RETURN_FAILURE); @@ -1409,8 +1409,8 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) if (nm_streq(connection_type, NM_SETTING_PPPOE_SETTING_NAME)) { if (!priv->ppp_data.ppp_mgr) { gs_free_error GError *error = NULL; - NMSettingPppoe * s_pppoe; - NMSettingPpp * s_ppp; + NMSettingPppoe *s_pppoe; + NMSettingPpp *s_ppp; s_ppp = nm_device_get_applied_setting(device, NM_TYPE_SETTING_PPP); if (s_ppp) { @@ -1533,7 +1533,7 @@ get_configured_mtu(NMDevice *device, NMDeviceMtuSource *out_source, gboolean *ou static void act_stage3_ip_config(NMDevice *device, int addr_family) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); NMPppMgrState ppp_state; @@ -1555,10 +1555,10 @@ act_stage3_ip_config(NMDevice *device, int addr_family) static void deactivate(NMDevice *device) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - NMSettingDcb * s_dcb; - GError * error = NULL; + NMSettingDcb *s_dcb; + GError *error = NULL; int ifindex; nm_clear_g_source_inst(&priv->ppp_data.wait_source); @@ -1607,19 +1607,19 @@ deactivate(NMDevice *device) } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingWired *s_wired; NMSettingPppoe *s_pppoe; if (nm_streq0(nm_connection_get_connection_type(connection), NM_SETTING_VETH_SETTING_NAME)) { NMSettingVeth *s_veth; - const char * peer_name = NULL; - const char * con_peer_name = NULL; + const char *peer_name = NULL; + const char *con_peer_name = NULL; int ifindex; nm_utils_complete_generic(nm_device_get_platform(device), @@ -1696,16 +1696,16 @@ complete_connection(NMDevice * device, static NMConnection * new_default_connection(NMDevice *self) { - NMConnection * connection; - NMSettingsConnection *const *connections; - NMSetting * setting; + NMConnection *connection; + NMSettingsConnection *const *connections; + NMSetting *setting; gs_unref_hashtable GHashTable *existing_ids = NULL; - struct udev_device * dev; - const char * perm_hw_addr; - const char * iface; - const char * uprop = "0"; - gs_free char * defname = NULL; - gs_free char * uuid = NULL; + struct udev_device *dev; + const char *perm_hw_addr; + const char *iface; + const char *uprop = "0"; + gs_free char *defname = NULL; + gs_free char *uuid = NULL; guint i, n_connections; perm_hw_addr = nm_device_get_permanent_hw_address(self); @@ -1791,12 +1791,12 @@ update_connection(NMDevice *device, NMConnection *connection) NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(device); NMSettingWired *s_wired = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIRED); gboolean perm_hw_addr_is_fake; - const char * perm_hw_addr; - const char * mac = nm_device_get_hw_address(device); - const char * mac_prop = NM_SETTING_WIRED_MAC_ADDRESS; + const char *perm_hw_addr; + const char *mac = nm_device_get_hw_address(device); + const char *mac_prop = NM_SETTING_WIRED_MAC_ADDRESS; GHashTableIter iter; - const char * key; - const char * value; + const char *key; + const char *value; g_object_set(nm_connection_get_setting_connection(connection), NM_SETTING_CONNECTION_TYPE, @@ -1836,7 +1836,7 @@ update_connection(NMDevice *device, NMConnection *connection) static void link_speed_update(NMDevice *device) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); guint32 speed; @@ -1857,7 +1857,7 @@ link_speed_update(NMDevice *device) static void carrier_changed_notify(NMDevice *device, gboolean carrier) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); if (priv->dcb_handle_carrier_changes) { @@ -1893,12 +1893,12 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) } static gboolean -can_reapply_change(NMDevice * device, +can_reapply_change(NMDevice *device, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error) + GError **error) { NMDeviceClass *device_class; @@ -1939,7 +1939,7 @@ reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_ne static void dispose(GObject *object) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(object); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(object); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); wired_secrets_cancel(self); @@ -1958,7 +1958,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(object); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(object); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); g_clear_object(&priv->supplicant.mgr); @@ -1976,7 +1976,7 @@ finalize(GObject *object) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceEthernet * self = NM_DEVICE_ETHERNET(object); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET(object); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); switch (prop_id) { @@ -2020,9 +2020,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_wired = { static void nm_device_ethernet_class_init(NMDeviceEthernetClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); g_type_class_add_private(object_class, sizeof(NMDeviceEthernetPrivate)); @@ -2083,11 +2083,11 @@ nm_device_ethernet_class_init(NMDeviceEthernetClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_ETHERNET_DEVICE_FACTORY, NMEthernetDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_ETHERNET, NM_DEVICE_IFACE, @@ -2104,7 +2104,7 @@ create_device(NMDeviceFactory * factory, static gboolean match_connection(NMDeviceFactory *factory, NMConnection *connection) { - const char * type = nm_connection_get_connection_type(connection); + const char *type = nm_connection_get_connection_type(connection); NMSettingPppoe *s_pppoe; if (nm_streq(type, NM_SETTING_WIRED_SETTING_NAME)) diff --git a/src/core/devices/nm-device-factory.c b/src/core/devices/nm-device-factory.c index bdc64135d9..41e9480fe5 100644 --- a/src/core/devices/nm-device-factory.c +++ b/src/core/devices/nm-device-factory.c @@ -29,8 +29,8 @@ G_DEFINE_ABSTRACT_TYPE(NMDeviceFactory, nm_device_factory, G_TYPE_OBJECT) /*****************************************************************************/ static void -nm_device_factory_get_supported_types(NMDeviceFactory * factory, - const NMLinkType ** out_link_types, +nm_device_factory_get_supported_types(NMDeviceFactory *factory, + const NMLinkType **out_link_types, const char *const **out_setting_types) { g_return_if_fail(NM_IS_DEVICE_FACTORY(factory)); @@ -50,15 +50,15 @@ nm_device_factory_start(NMDeviceFactory *factory) } NMDevice * -nm_device_factory_create_device(NMDeviceFactory * factory, - const char * iface, +nm_device_factory_create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore, - GError ** error) + NMConnection *connection, + gboolean *out_ignore, + GError **error) { NMDeviceFactoryClass *klass; - NMDevice * device; + NMDevice *device; gboolean ignore = FALSE; g_return_val_if_fail(factory, NULL); @@ -121,12 +121,12 @@ nm_device_factory_get_connection_parent(NMDeviceFactory *factory, NMConnection * char * nm_device_factory_get_connection_iface(NMDeviceFactory *factory, - NMConnection * connection, - const char * parent_iface, - GError ** error) + NMConnection *connection, + const char *parent_iface, + GError **error) { NMDeviceFactoryClass *klass; - char * ifname; + char *ifname; g_return_val_if_fail(factory != NULL, NULL); g_return_val_if_fail(connection != NULL, NULL); @@ -196,9 +196,9 @@ NMDeviceFactory * nm_device_factory_manager_find_factory_for_connection(NMConnection *connection) { NMDeviceFactoryClass *klass; - NMDeviceFactory * factory; - const char * type; - GSList * list; + NMDeviceFactory *factory; + const char *type; + GSList *list; g_return_val_if_fail(factories_by_setting, NULL); @@ -221,7 +221,7 @@ nm_device_factory_manager_for_each_factory(NMDeviceFactoryManagerFactoryFunc cal { GHashTableIter iter; NMDeviceFactory *factory; - GSList * list_iter, *list = NULL; + GSList *list_iter, *list = NULL; if (factories_by_link) { g_hash_table_iter_init(&iter, factories_by_link); @@ -248,14 +248,14 @@ nm_device_factory_manager_for_each_factory(NMDeviceFactoryManagerFactoryFunc cal } static gboolean -_add_factory(NMDeviceFactory * factory, - const char * path, +_add_factory(NMDeviceFactory *factory, + const char *path, NMDeviceFactoryManagerFactoryFunc callback, gpointer user_data) { - const NMLinkType * link_types = NULL; + const NMLinkType *link_types = NULL; const char *const *setting_types = NULL; - GSList * list, *list2; + GSList *list, *list2; int i; g_return_val_if_fail(factories_by_link, FALSE); @@ -312,22 +312,22 @@ factories_list_unref(GSList *list) } static void -load_factories_from_dir(const char * dirname, +load_factories_from_dir(const char *dirname, NMDeviceFactoryManagerFactoryFunc callback, gpointer user_data) { NMDeviceFactory *factory; - GError * error = NULL; - char ** path, **paths; + GError *error = NULL; + char **path, **paths; paths = nm_utils_read_plugin_paths(dirname, PLUGIN_PREFIX); if (!paths) return; for (path = paths; *path; path++) { - GModule * plugin; + GModule *plugin; NMDeviceFactoryCreateFunc create_func; - const char * item; + const char *item; item = strrchr(*path, '/'); g_assert(item); diff --git a/src/core/devices/nm-device-factory.h b/src/core/devices/nm-device-factory.h index d9b505638b..51d6476700 100644 --- a/src/core/devices/nm-device-factory.h +++ b/src/core/devices/nm-device-factory.h @@ -45,8 +45,8 @@ typedef struct { * Returns the #NMLinkType and #NMSetting names that this plugin * supports. This function MUST be implemented. */ - void (*get_supported_types)(NMDeviceFactory * factory, - const NMLinkType ** out_link_types, + void (*get_supported_types)(NMDeviceFactory *factory, + const NMLinkType **out_link_types, const char *const **out_setting_types); /** @@ -91,8 +91,8 @@ typedef struct { * Returns: the interface name, or %NULL */ char *(*get_connection_iface)(NMDeviceFactory *factory, - NMConnection * connection, - const char * parent_iface); + NMConnection *connection, + const char *parent_iface); /** * create_device: @@ -112,11 +112,11 @@ typedef struct { * * Returns: the new unrealized #NMDevice, or %NULL */ - NMDevice *(*create_device)(NMDeviceFactory * factory, - const char * iface, + NMDevice *(*create_device)(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore); + NMConnection *connection, + gboolean *out_ignore); } NMDeviceFactoryClass; @@ -143,21 +143,21 @@ typedef NMDeviceFactory *(*NMDeviceFactoryCreateFunc)(GError **error); /*****************************************************************************/ const char *nm_device_factory_get_connection_parent(NMDeviceFactory *factory, - NMConnection * connection); + NMConnection *connection); char *nm_device_factory_get_connection_iface(NMDeviceFactory *factory, - NMConnection * connection, - const char * parent_iface, - GError ** error); + NMConnection *connection, + const char *parent_iface, + GError **error); void nm_device_factory_start(NMDeviceFactory *factory); -NMDevice *nm_device_factory_create_device(NMDeviceFactory * factory, - const char * iface, +NMDevice *nm_device_factory_create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore, - GError ** error); + NMConnection *connection, + gboolean *out_ignore, + GError **error); #define NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(...) \ { \ @@ -171,14 +171,14 @@ NMDevice *nm_device_factory_create_device(NMDeviceFactory * factory, } #define NM_DEVICE_FACTORY_DECLARE_TYPES(...) \ - static void get_supported_types(NMDeviceFactory * factory, \ - const NMLinkType ** out_link_types, \ + static void get_supported_types(NMDeviceFactory *factory, \ + const NMLinkType **out_link_types, \ const char *const **out_setting_types) \ { \ static NMLinkType const _link_types_null[1] = {NM_LINK_TYPE_NONE}; \ static const char *const _setting_types_null[1] = {NULL}; \ \ - const NMLinkType * _link_types = _link_types_null; \ + const NMLinkType *_link_types = _link_types_null; \ const char *const *_setting_types = _setting_types_null; \ \ { \ diff --git a/src/core/devices/nm-device-generic.c b/src/core/devices/nm-device-generic.c index 08ea5ac588..9f85925bbe 100644 --- a/src/core/devices/nm-device-generic.c +++ b/src/core/devices/nm-device-generic.c @@ -58,7 +58,7 @@ get_type_description(NMDevice *device) static void realize_start_notify(NMDevice *device, const NMPlatformLink *plink) { - NMDeviceGeneric * self = NM_DEVICE_GENERIC(device); + NMDeviceGeneric *self = NM_DEVICE_GENERIC(device); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE(self); int ifindex; @@ -112,7 +112,7 @@ update_connection(NMDevice *device, NMConnection *connection) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceGeneric * self = NM_DEVICE_GENERIC(object); + NMDeviceGeneric *self = NM_DEVICE_GENERIC(object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE(self); switch (prop_id) { @@ -128,7 +128,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMDeviceGeneric * self = NM_DEVICE_GENERIC(object); + NMDeviceGeneric *self = NM_DEVICE_GENERIC(object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE(self); switch (prop_id) { @@ -180,7 +180,7 @@ nm_device_generic_new(const NMPlatformLink *plink, gboolean nm_plugin_missing) static void dispose(GObject *object) { - NMDeviceGeneric * self = NM_DEVICE_GENERIC(object); + NMDeviceGeneric *self = NM_DEVICE_GENERIC(object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE(self); nm_clear_g_free(&priv->type_description); @@ -202,9 +202,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_generic = { static void nm_device_generic_class_init(NMDeviceGenericClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructor = constructor; object_class->dispose = dispose; diff --git a/src/core/devices/nm-device-infiniband.c b/src/core/devices/nm-device-infiniband.c index 57b7698cb3..aef6122297 100644 --- a/src/core/devices/nm-device-infiniband.c +++ b/src/core/devices/nm-device-infiniband.c @@ -63,7 +63,7 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) nm_auto_close int dirfd = -1; NMSettingInfiniband *s_infiniband; char ifname_verified[IFNAMSIZ]; - const char * transport_mode; + const char *transport_mode; gboolean ok; s_infiniband = nm_device_get_applied_setting(device, NM_TYPE_SETTING_INFINIBAND); @@ -138,11 +138,11 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingInfiniband *s_infiniband; @@ -196,12 +196,12 @@ update_connection(NMDevice *device, NMConnection *connection) } static gboolean -can_reapply_change(NMDevice * device, +can_reapply_change(NMDevice *device, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error) + GError **error) { NMDeviceClass *device_class; @@ -218,14 +218,14 @@ can_reapply_change(NMDevice * device, } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE(device); - NMSettingInfiniband * s_infiniband; + NMSettingInfiniband *s_infiniband; int r; s_infiniband = nm_connection_get_setting_infiniband(connection); @@ -366,9 +366,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_infiniband = { static void nm_device_infiniband_class_init(NMDeviceInfinibandClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; object_class->set_property = set_property; @@ -409,11 +409,11 @@ nm_device_infiniband_class_init(NMDeviceInfinibandClass *klass) NMInfinibandDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { gboolean is_partition = FALSE; diff --git a/src/core/devices/nm-device-ip-tunnel.c b/src/core/devices/nm-device-ip-tunnel.c index 59653a685d..02680dd7a5 100644 --- a/src/core/devices/nm-device-ip-tunnel.c +++ b/src/core/devices/nm-device-ip-tunnel.c @@ -43,14 +43,14 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDeviceIPTunnel, typedef struct { NMIPTunnelMode mode; - char * local; - char * remote; + char *local; + char *remote; guint8 ttl; guint8 tos; gboolean path_mtu_discovery; int addr_family; - char * input_key; - char * output_key; + char *input_key; + char *output_key; guint8 encap_limit; guint32 flow_label; NMIPTunnelFlags flags; @@ -152,7 +152,7 @@ address_set(int addr_family, char **p_addr, const NMIPAddr *addr_new) static void update_properties_from_ifindex(NMDevice *device, int ifindex) { - NMDeviceIPTunnel * self = NM_DEVICE_IP_TUNNEL(device); + NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL(device); NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self); int parent_ifindex = 0; NMIPAddr local = NM_IP_ADDR_INIT; @@ -163,7 +163,7 @@ update_properties_from_ifindex(NMDevice *device, int ifindex) gboolean pmtud = FALSE; guint32 flow_label = 0; NMIPTunnelFlags flags = NM_IP_TUNNEL_FLAG_NONE; - char * key; + char *key; if (ifindex <= 0) { clear: @@ -272,7 +272,7 @@ clear: NM_IP_TUNNEL_MODE_IP6GRE, NM_IP_TUNNEL_MODE_IP6GRETAP)) { const NMPlatformLnkIp6Tnl *lnk; - NMPlatform * plat = nm_device_get_platform(device); + NMPlatform *plat = nm_device_get_platform(device); if (priv->mode == NM_IP_TUNNEL_MODE_IP6GRE) lnk = nm_platform_link_get_lnk_ip6gre(plat, ifindex, NULL); @@ -383,11 +383,11 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingIPTunnel *s_ip_tunnel; @@ -416,9 +416,9 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceIPTunnel * self = NM_DEVICE_IP_TUNNEL(device); + NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL(device); NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self); - NMSettingIPTunnel * s_ip_tunnel = + NMSettingIPTunnel *s_ip_tunnel = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_IP_TUNNEL); if (nm_setting_ip_tunnel_get_mode(s_ip_tunnel) != priv->mode) @@ -490,10 +490,10 @@ update_connection(NMDevice *device, NMConnection *connection) static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMDeviceIPTunnel * self = NM_DEVICE_IP_TUNNEL(device); + NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL(device); NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self); - NMSettingIPTunnel * s_ip_tunnel; - const char * parent; + NMSettingIPTunnel *s_ip_tunnel; + const char *parent; if (!NM_DEVICE_CLASS(nm_device_ip_tunnel_parent_class) ->check_connection_compatible(device, connection, error)) @@ -642,23 +642,23 @@ tunnel_mode_to_link_type(NMIPTunnelMode tunnel_mode) /*****************************************************************************/ static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); - NMSettingIPTunnel * s_ip_tunnel; + const char *iface = nm_device_get_iface(device); + NMSettingIPTunnel *s_ip_tunnel; NMPlatformLnkGre lnk_gre = {}; NMPlatformLnkSit lnk_sit = {}; NMPlatformLnkIpIp lnk_ipip = {}; NMPlatformLnkIp6Tnl lnk_ip6tnl = {}; - const char * str; + const char *str; gint64 val; NMIPTunnelMode mode; int r; - gs_free char * hwaddr = NULL; + gs_free char *hwaddr = NULL; guint8 mac_address[ETH_ALEN]; gboolean mac_address_valid = FALSE; @@ -908,12 +908,12 @@ unrealize_notify(NMDevice *device) } static gboolean -can_reapply_change(NMDevice * device, +can_reapply_change(NMDevice *device, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error) + GError **error) { NMDeviceClass *device_class; @@ -933,7 +933,7 @@ can_reapply_change(NMDevice * device, static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceIPTunnel * self = NM_DEVICE_IP_TUNNEL(device); + NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL(device); NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self); if (_nm_ip_tunnel_mode_is_layer2(priv->mode) @@ -1032,7 +1032,7 @@ constructed(GObject *object) static void dispose(GObject *object) { - NMDeviceIPTunnel * self = NM_DEVICE_IP_TUNNEL(object); + NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL(object); NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self); nm_clear_g_free(&priv->local); @@ -1078,9 +1078,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_ip_tunnel = { static void nm_device_ip_tunnel_class_init(NMDeviceIPTunnelClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; object_class->dispose = dispose; @@ -1202,11 +1202,11 @@ nm_device_ip_tunnel_class_init(NMDeviceIPTunnelClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_IP_TUNNEL_DEVICE_FACTORY, NMIPTunnelDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { NMSettingIPTunnel *s_ip_tunnel; NMIPTunnelMode mode; @@ -1255,7 +1255,7 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection) static char * get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface) { - const char * ifname; + const char *ifname; NMSettingIPTunnel *s_ip_tunnel; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_IP_TUNNEL_SETTING_NAME), diff --git a/src/core/devices/nm-device-macsec.c b/src/core/devices/nm-device-macsec.c index 7fa0779b52..5cc0b8da89 100644 --- a/src/core/devices/nm-device-macsec.c +++ b/src/core/devices/nm-device-macsec.c @@ -49,9 +49,9 @@ typedef struct { gulong parent_mtu_id; struct { - NMSupplicantManager * mgr; + NMSupplicantManager *mgr; NMSupplMgrCreateIfaceHandle *create_handle; - NMSupplicantInterface * iface; + NMSupplicantInterface *iface; gulong iface_state_id; @@ -92,7 +92,7 @@ static NM_UTILS_LOOKUP_STR_DEFINE(validation_mode_to_string, NM_UTILS_LOOKUP_STR_ITEM(2, "strict"), ); static void -parent_state_changed(NMDevice * parent, +parent_state_changed(NMDevice *parent, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, @@ -126,7 +126,7 @@ parent_changed_notify(NMDevice *device, int new_ifindex, NMDevice *new_parent) { - NMDeviceMacsec * self = NM_DEVICE_MACSEC(device); + NMDeviceMacsec *self = NM_DEVICE_MACSEC(device); NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); NM_DEVICE_CLASS(nm_device_macsec_parent_class) @@ -166,9 +166,9 @@ parent_changed_notify(NMDevice *device, static void update_properties(NMDevice *device) { - NMDeviceMacsec * self; - NMDeviceMacsecPrivate * priv; - const NMPlatformLink * plink = NULL; + NMDeviceMacsec *self; + NMDeviceMacsecPrivate *priv; + const NMPlatformLink *plink = NULL; const NMPlatformLnkMacsec *props = NULL; int ifindex; @@ -220,10 +220,10 @@ static NMSupplicantConfig * build_supplicant_config(NMDeviceMacsec *self, GError **error) { gs_unref_object NMSupplicantConfig *config = NULL; - NMSettingMacsec * s_macsec; - NMSetting8021x * s_8021x; - NMConnection * connection; - const char * con_uuid; + NMSettingMacsec *s_macsec; + NMSetting8021x *s_8021x; + NMConnection *connection; + const char *con_uuid; guint32 mtu; connection = nm_device_get_applied_connection(NM_DEVICE(self)); @@ -275,14 +275,14 @@ supplicant_interface_release(NMDeviceMacsec *self) } static void -macsec_secrets_cb(NMActRequest * req, +macsec_secrets_cb(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * connection, - GError * error, + NMSettingsConnection *connection, + GError *error, gpointer user_data) { - NMDeviceMacsec * self = NM_DEVICE_MACSEC(user_data); - NMDevice * device = NM_DEVICE(self); + NMDeviceMacsec *self = NM_DEVICE_MACSEC(user_data); + NMDevice *device = NM_DEVICE(self); NMDeviceMacsecPrivate *priv; g_return_if_fail(NM_IS_DEVICE_MACSEC(self)); @@ -321,12 +321,12 @@ macsec_secrets_cancel(NMDeviceMacsec *self) } static void -macsec_secrets_get_secrets(NMDeviceMacsec * self, - const char * setting_name, +macsec_secrets_get_secrets(NMDeviceMacsec *self, + const char *setting_name, NMSecretAgentGetSecretsFlags flags) { NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); - NMActRequest * req; + NMActRequest *req; macsec_secrets_cancel(self); @@ -341,12 +341,12 @@ macsec_secrets_get_secrets(NMDeviceMacsec * self, static gboolean supplicant_lnk_timeout_cb(gpointer user_data) { - NMDeviceMacsec * self = NM_DEVICE_MACSEC(user_data); + NMDeviceMacsec *self = NM_DEVICE_MACSEC(user_data); NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); - NMDevice * dev = NM_DEVICE(self); - NMActRequest * req; - NMConnection * applied_connection; - const char * setting_name; + NMDevice *dev = NM_DEVICE(self); + NMActRequest *req; + NMConnection *applied_connection; + const char *setting_name; priv->supplicant.lnk_timeout_id = 0; @@ -422,7 +422,7 @@ supplicant_iface_state_is_completed(NMDeviceMacsec *self, NMSupplicantInterfaceS static void supplicant_iface_assoc_cb(NMSupplicantInterface *iface, GError *error, gpointer user_data) { - NMDeviceMacsec * self; + NMDeviceMacsec *self; NMDeviceMacsecPrivate *priv; if (nm_utils_error_is_cancelled_or_disposing(error)) @@ -450,9 +450,9 @@ supplicant_iface_assoc_cb(NMSupplicantInterface *iface, GError *error, gpointer static gboolean supplicant_iface_start(NMDeviceMacsec *self) { - NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); gs_unref_object NMSupplicantConfig *config = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; config = build_supplicant_config(self, &error); if (!config) { @@ -476,8 +476,8 @@ supplicant_iface_state_cb(NMSupplicantInterface *iface, int disconnect_reason, gpointer user_data) { - NMDeviceMacsec * self = NM_DEVICE_MACSEC(user_data); - NMDeviceMacsecPrivate * priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); + NMDeviceMacsec *self = NM_DEVICE_MACSEC(user_data); + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); NMSupplicantInterfaceState new_state = new_state_i; NMSupplicantInterfaceState old_state = old_state_i; @@ -506,7 +506,7 @@ supplicant_iface_state_cb(NMSupplicantInterface *iface, static gboolean handle_auth_or_fail(NMDeviceMacsec *self, NMActRequest *req, gboolean new_secrets) { - const char * setting_name; + const char *setting_name; NMConnection *applied_connection; if (!nm_device_auth_retries_try_next(NM_DEVICE(self))) @@ -536,11 +536,11 @@ handle_auth_or_fail(NMDeviceMacsec *self, NMActRequest *req, gboolean new_secret static gboolean supplicant_connection_timeout_cb(gpointer user_data) { - NMDeviceMacsec * self = NM_DEVICE_MACSEC(user_data); + NMDeviceMacsec *self = NM_DEVICE_MACSEC(user_data); NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); - NMActRequest * req; - NMSettingsConnection * connection; + NMDevice *device = NM_DEVICE(self); + NMActRequest *req; + NMSettingsConnection *connection; guint64 timestamp = 0; gboolean new_secrets = TRUE; @@ -585,13 +585,13 @@ supplicant_connection_timeout_cb(gpointer user_data) } static void -supplicant_interface_create_cb(NMSupplicantManager * supplicant_manager, +supplicant_interface_create_cb(NMSupplicantManager *supplicant_manager, NMSupplMgrCreateIfaceHandle *handle, - NMSupplicantInterface * iface, - GError * error, + NMSupplicantInterface *iface, + GError *error, gpointer user_data) { - NMDeviceMacsec * self; + NMDeviceMacsec *self; NMDeviceMacsecPrivate *priv; guint timeout; @@ -633,11 +633,11 @@ supplicant_interface_create_cb(NMSupplicantManager * supplicant_manager, static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceMacsec * self = NM_DEVICE_MACSEC(device); + NMDeviceMacsec *self = NM_DEVICE_MACSEC(device); NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); - NMConnection * connection; - NMDevice * parent; - const char * setting_name; + NMConnection *connection; + NMDevice *parent; + const char *setting_name; int ifindex; connection = nm_device_get_applied_connection(NM_DEVICE(self)); @@ -712,17 +712,17 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); - NMSettingMacsec * s_macsec; + const char *iface = nm_device_get_iface(device); + NMSettingMacsec *s_macsec; NMPlatformLnkMacsec lnk = {}; int parent_ifindex; - const char * hw_addr; + const char *hw_addr; union { struct { guint8 mac[6]; @@ -789,7 +789,7 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) @@ -803,7 +803,7 @@ device_state_changed(NMDevice * device, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceMacsec * self = NM_DEVICE_MACSEC(object); + NMDeviceMacsec *self = NM_DEVICE_MACSEC(object); NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(self); switch (prop_id) { @@ -905,9 +905,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_macsec = { static void nm_device_macsec_class_init(NMDeviceMacsecClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; object_class->dispose = dispose; @@ -1015,11 +1015,11 @@ nm_device_macsec_class_init(NMDeviceMacsecClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_MACSEC_DEVICE_FACTORY, NMMacsecDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_MACSEC, NM_DEVICE_IFACE, @@ -1037,8 +1037,8 @@ static const char * get_connection_parent(NMDeviceFactory *factory, NMConnection *connection) { NMSettingMacsec *s_macsec; - NMSettingWired * s_wired; - const char * parent = NULL; + NMSettingWired *s_wired; + const char *parent = NULL; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_MACSEC_SETTING_NAME), NULL); @@ -1061,7 +1061,7 @@ static char * get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface) { NMSettingMacsec *s_macsec; - const char * ifname; + const char *ifname; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_MACSEC_SETTING_NAME), NULL); diff --git a/src/core/devices/nm-device-macvlan.c b/src/core/devices/nm-device-macvlan.c index 27be9f0023..40ecc5fd70 100644 --- a/src/core/devices/nm-device-macvlan.c +++ b/src/core/devices/nm-device-macvlan.c @@ -103,7 +103,7 @@ platform_mode_to_string(guint mode) /*****************************************************************************/ static void -parent_state_changed(NMDevice * parent, +parent_state_changed(NMDevice *parent, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, @@ -137,7 +137,7 @@ parent_changed_notify(NMDevice *device, int new_ifindex, NMDevice *new_parent) { - NMDeviceMacvlan * self = NM_DEVICE_MACVLAN(device); + NMDeviceMacvlan *self = NM_DEVICE_MACVLAN(device); NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE(self); NM_DEVICE_CLASS(nm_device_macvlan_parent_class) @@ -177,11 +177,11 @@ parent_changed_notify(NMDevice *device, static void update_properties(NMDevice *device) { - NMDeviceMacvlan * self = NM_DEVICE_MACVLAN(device); - NMDeviceMacvlanPrivate * priv = NM_DEVICE_MACVLAN_GET_PRIVATE(self); - GObject * object = G_OBJECT(device); + NMDeviceMacvlan *self = NM_DEVICE_MACVLAN(device); + NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE(self); + GObject *object = G_OBJECT(device); const NMPlatformLnkMacvlan *props; - const NMPlatformLink * plink; + const NMPlatformLink *plink; if (priv->props.tap) props = nm_platform_link_get_lnk_macvtap(nm_device_get_platform(device), @@ -227,14 +227,14 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); - NMSettingMacvlan * s_macvlan; + const char *iface = nm_device_get_iface(device); + NMSettingMacvlan *s_macvlan; NMPlatformLnkMacvlan lnk = {}; int parent_ifindex; int r; @@ -311,8 +311,8 @@ static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE(device); - NMSettingMacvlan * s_macvlan; - const char * parent = NULL; + NMSettingMacvlan *s_macvlan; + const char *parent = NULL; if (!NM_DEVICE_CLASS(nm_device_macvlan_parent_class) ->check_connection_compatible(device, connection, error)) @@ -373,11 +373,11 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingMacvlan *s_macvlan; @@ -420,7 +420,7 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE(device); - NMSettingMacvlan * s_macvlan = + NMSettingMacvlan *s_macvlan = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_MACVLAN); int new_mode; @@ -510,9 +510,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_macvlan = { static void nm_device_macvlan_class_init(NMDeviceMacvlanClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); #if NM_MORE_ASSERTS object_class->dispose = dispose; @@ -569,11 +569,11 @@ nm_device_macvlan_class_init(NMDeviceMacvlanClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_MACVLAN_DEVICE_FACTORY, NMMacvlanDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { NMSettingMacvlan *s_macvlan; NMLinkType link_type; @@ -608,8 +608,8 @@ static const char * get_connection_parent(NMDeviceFactory *factory, NMConnection *connection) { NMSettingMacvlan *s_macvlan; - NMSettingWired * s_wired; - const char * parent = NULL; + NMSettingWired *s_wired; + const char *parent = NULL; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_MACVLAN_SETTING_NAME), NULL); @@ -632,7 +632,7 @@ static char * get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface) { NMSettingMacvlan *s_macvlan; - const char * ifname; + const char *ifname; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_MACVLAN_SETTING_NAME), NULL); diff --git a/src/core/devices/nm-device-ppp.c b/src/core/devices/nm-device-ppp.c index 855916397b..5ff3240107 100644 --- a/src/core/devices/nm-device-ppp.c +++ b/src/core/devices/nm-device-ppp.c @@ -60,7 +60,7 @@ _ppp_mgr_cleanup(NMDevicePpp *self) static void _ppp_mgr_stage3_maybe_ready(NMDevicePpp *self) { - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); int IS_IPv4; @@ -80,8 +80,8 @@ _ppp_mgr_stage3_maybe_ready(NMDevicePpp *self) static void _ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, gpointer user_data) { - NMDevicePpp * self = NM_DEVICE_PPP(user_data); - NMDevice * device = NM_DEVICE(self); + NMDevicePpp *self = NM_DEVICE_PPP(user_data); + NMDevice *device = NM_DEVICE(self); NMDeviceState device_state; if (callback_data->callback_type != NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED) @@ -97,8 +97,8 @@ _ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, if (device_state < NM_DEVICE_STATE_IP_CONFIG) { if (callback_data->data.state >= NM_PPP_MGR_STATE_HAVE_IFINDEX) { - gs_free char *old_name = NULL; - gs_free_error GError *error = NULL; + gs_free char *old_name = NULL; + gs_free_error GError *error = NULL; if (!nm_device_take_over_link(device, callback_data->data.ifindex, &old_name, &error)) { _LOGW(LOGD_DEVICE | LOGD_PPP, @@ -148,10 +148,10 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDevicePpp * self = NM_DEVICE_PPP(device); + NMDevicePpp *self = NM_DEVICE_PPP(device); NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); - NMSettingPppoe * s_pppoe; - NMActRequest * req; + NMSettingPppoe *s_pppoe; + NMActRequest *req; if (!priv->ppp_mgr) { gs_free_error GError *error = NULL; @@ -191,7 +191,7 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) static void act_stage3_ip_config(NMDevice *device, int addr_family) { - NMDevicePpp * self = NM_DEVICE_PPP(device); + NMDevicePpp *self = NM_DEVICE_PPP(device); NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); NMPppMgrState ppp_state; @@ -229,11 +229,11 @@ get_ip_method_auto(NMDevice *device, int addr_family) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { int parent_ifindex; @@ -286,9 +286,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_ppp = { static void nm_device_ppp_class_init(NMDevicePppClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->dispose = dispose; @@ -314,11 +314,11 @@ nm_device_ppp_class_init(NMDevicePppClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_PPP_DEVICE_FACTORY, NMPppDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_PPP, NM_DEVICE_IFACE, diff --git a/src/core/devices/nm-device-private.h b/src/core/devices/nm-device-private.h index ae89848307..790bb8238b 100644 --- a/src/core/devices/nm-device-private.h +++ b/src/core/devices/nm-device-private.h @@ -43,7 +43,7 @@ void nm_device_take_down(NMDevice *self, gboolean block); gboolean nm_device_take_over_link(NMDevice *self, int ifindex, char **old_name, GError **error); -gboolean nm_device_hw_addr_set(NMDevice * device, +gboolean nm_device_hw_addr_set(NMDevice *device, const char *addr, const char *detail, gboolean set_permanent); @@ -66,7 +66,7 @@ void nm_device_master_release_slaves(NMDevice *self); void nm_device_set_carrier(NMDevice *self, gboolean carrier); void nm_device_queue_recheck_assume(NMDevice *device); -void nm_device_queue_recheck_available(NMDevice * device, +void nm_device_queue_recheck_available(NMDevice *device, NMDeviceStateReason available_reason, NMDeviceStateReason unavailable_reason); @@ -74,14 +74,14 @@ gboolean nm_device_hw_addr_is_explict(NMDevice *device); NMDeviceIPState nm_device_devip_get_state(NMDevice *self, int addr_family); -void nm_device_devip_set_state_full(NMDevice * self, +void nm_device_devip_set_state_full(NMDevice *self, int addr_family, NMDeviceIPState ip_state, const NML3ConfigData *l3cd, NMDeviceStateReason failed_reason); static inline void -nm_device_devip_set_state(NMDevice * self, +nm_device_devip_set_state(NMDevice *self, int addr_family, NMDeviceIPState ip_state, const NML3ConfigData *l3cd) @@ -104,14 +104,14 @@ nm_device_devip_set_failed(NMDevice *self, int addr_family, NMDeviceStateReason nm_device_devip_set_state_full(self, addr_family, NM_DEVICE_IP_STATE_FAILED, NULL, reason); } -gboolean nm_device_sysctl_ip_conf_set(NMDevice * self, +gboolean nm_device_sysctl_ip_conf_set(NMDevice *self, int addr_family, const char *property, const char *value); NML3ConfigData *nm_device_create_l3_config_data(NMDevice *self, NMIPConfigSource source); -const NML3ConfigData *nm_device_create_l3_config_data_from_connection(NMDevice * self, +const NML3ConfigData *nm_device_create_l3_config_data_from_connection(NMDevice *self, NMConnection *connection); void nm_device_ip_method_dhcp4_start(NMDevice *self); @@ -120,21 +120,21 @@ void nm_device_ip_method_autoconf6_start(NMDevice *self); /*****************************************************************************/ -gint64 nm_device_get_configured_mtu_from_connection_default(NMDevice * self, +gint64 nm_device_get_configured_mtu_from_connection_default(NMDevice *self, const char *property_name, guint32 max_mtu); -guint32 nm_device_get_configured_mtu_from_connection(NMDevice * device, +guint32 nm_device_get_configured_mtu_from_connection(NMDevice *device, GType setting_type, NMDeviceMtuSource *out_source); -guint32 nm_device_get_configured_mtu_for_wired(NMDevice * self, +guint32 nm_device_get_configured_mtu_for_wired(NMDevice *self, NMDeviceMtuSource *out_source, - gboolean * out_force); + gboolean *out_force); -guint32 nm_device_get_configured_mtu_wired_parent(NMDevice * self, +guint32 nm_device_get_configured_mtu_wired_parent(NMDevice *self, NMDeviceMtuSource *out_source, - gboolean * out_force); + gboolean *out_force); void nm_device_commit_mtu(NMDevice *self); @@ -150,26 +150,26 @@ void nm_device_commit_mtu(NMDevice *self); _types; \ })) -gboolean _nm_device_hash_check_invalid_keys(GHashTable * hash, - const char * setting_name, - GError ** error, +gboolean _nm_device_hash_check_invalid_keys(GHashTable *hash, + const char *setting_name, + GError **error, const char *const *whitelist); #define nm_device_hash_check_invalid_keys(hash, setting_name, error, ...) \ _nm_device_hash_check_invalid_keys(hash, setting_name, error, NM_MAKE_STRV(__VA_ARGS__)) gboolean nm_device_match_parent(NMDevice *device, const char *parent); -gboolean nm_device_match_parent_hwaddr(NMDevice * device, +gboolean nm_device_match_parent_hwaddr(NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr); /*****************************************************************************/ -void nm_device_auth_request(NMDevice * self, - GDBusMethodInvocation * context, - NMConnection * connection, - const char * permission, +void nm_device_auth_request(NMDevice *self, + GDBusMethodInvocation *context, + NMConnection *connection, + const char *permission, gboolean allow_interaction, - GCancellable * cancellable, + GCancellable *cancellable, NMManagerDeviceAuthRequestFunc callback, gpointer user_data); diff --git a/src/core/devices/nm-device-tun.c b/src/core/devices/nm-device-tun.c index 1f6a427636..b6c4f88b6c 100644 --- a/src/core/devices/nm-device-tun.c +++ b/src/core/devices/nm-device-tun.c @@ -55,7 +55,7 @@ G_DEFINE_TYPE(NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE) static void update_properties_from_struct(NMDeviceTun *self, const NMPlatformLnkTun *props) { - NMDeviceTunPrivate * priv = NM_DEVICE_TUN_GET_PRIVATE(self); + NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE(self); const NMPlatformLnkTun props0 = {}; if (!props) { @@ -128,11 +128,11 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingTun *s_tun; @@ -161,12 +161,12 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceTun * self = NM_DEVICE_TUN(device); + NMDeviceTun *self = NM_DEVICE_TUN(device); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE(self); - NMSettingTun * s_tun; + NMSettingTun *s_tun; NMSettingTunMode mode; char s_buf[100]; - const char * str; + const char *str; /* Note: since we read tun properties from sysctl for older kernels, * we don't get proper change notifications. Make sure that all our @@ -216,15 +216,15 @@ update_connection(NMDevice *device, NMConnection *connection) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); + const char *iface = nm_device_get_iface(device); NMPlatformLnkTun props = {}; - NMSettingTun * s_tun; + NMSettingTun *s_tun; gint64 owner; gint64 group; int r; @@ -286,10 +286,10 @@ _same_og(const char *str, gboolean og_valid, guint32 og_num) static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMDeviceTun * self = NM_DEVICE_TUN(device); + NMDeviceTun *self = NM_DEVICE_TUN(device); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE(self); NMSettingTunMode mode; - NMSettingTun * s_tun; + NMSettingTun *s_tun; if (!NM_DEVICE_CLASS(nm_device_tun_parent_class) ->check_connection_compatible(device, connection, error)) @@ -360,7 +360,7 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceTun * self = NM_DEVICE_TUN(device); + NMDeviceTun *self = NM_DEVICE_TUN(device); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE(self); if (priv->props.type == IFF_TUN) { @@ -389,9 +389,9 @@ unrealize_notify(NMDevice *device) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceTun * self = NM_DEVICE_TUN(object); + NMDeviceTun *self = NM_DEVICE_TUN(object); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE(self); - const char * s; + const char *s; switch (prop_id) { case PROP_OWNER: @@ -457,9 +457,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_tun = { static void nm_device_tun_class_init(NMDeviceTunClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; @@ -530,11 +530,11 @@ nm_device_tun_class_init(NMDeviceTunClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_TUN_DEVICE_FACTORY, NMTunDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { g_return_val_if_fail(!plink || plink->type == NM_LINK_TYPE_TUN, NULL); g_return_val_if_fail(!connection diff --git a/src/core/devices/nm-device-utils.c b/src/core/devices/nm-device-utils.c index 9e56d0b2b9..170922eba0 100644 --- a/src/core/devices/nm-device-utils.c +++ b/src/core/devices/nm-device-utils.c @@ -165,7 +165,7 @@ typedef struct { int addr_family; NMIPAddr address; gulong cancellable_id; - GTask * task; + GTask *task; NMDnsSystemdResolvedResolveHandle *resolved_handle; } ResolveAddrInfo; @@ -218,9 +218,9 @@ resolve_addr_complete(ResolveAddrInfo *info, char *hostname_take, GError *error_ static void resolve_addr_helper_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - ResolveAddrInfo *info = user_data; + ResolveAddrInfo *info = user_data; gs_free_error GError *error = NULL; - gs_free char * output = NULL; + gs_free char *output = NULL; output = nm_utils_spawn_helper_finish(result, &error); if (nm_utils_error_is_cancelled(error)) @@ -245,12 +245,12 @@ resolve_addr_spawn_helper(ResolveAddrInfo *info) } static void -resolve_addr_resolved_cb(NMDnsSystemdResolved * resolved, - NMDnsSystemdResolvedResolveHandle * handle, +resolve_addr_resolved_cb(NMDnsSystemdResolved *resolved, + NMDnsSystemdResolvedResolveHandle *handle, const NMDnsSystemdResolvedAddressResult *names, guint names_len, guint64 flags, - GError * error, + GError *error, gpointer user_data) { ResolveAddrInfo *info = user_data; @@ -300,7 +300,7 @@ static void resolve_addr_cancelled(GObject *object, gpointer user_data) { ResolveAddrInfo *info = user_data; - GError * error = NULL; + GError *error = NULL; nm_clear_g_signal_handler(g_task_get_cancellable(info->task), &info->cancellable_id); nm_clear_pointer(&info->resolved_handle, nm_dns_systemd_resolved_resolve_cancel); @@ -311,11 +311,11 @@ resolve_addr_cancelled(GObject *object, gpointer user_data) void nm_device_resolve_address(int addr_family, gconstpointer address, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer cb_data) { - ResolveAddrInfo * info; + ResolveAddrInfo *info; NMDnsSystemdResolved *resolved; info = g_new(ResolveAddrInfo, 1); diff --git a/src/core/devices/nm-device-utils.h b/src/core/devices/nm-device-utils.h index 759e610568..7b879c9074 100644 --- a/src/core/devices/nm-device-utils.h +++ b/src/core/devices/nm-device-utils.h @@ -86,7 +86,7 @@ const char *nm_device_ip_state_to_string(NMDeviceIPState ip_state); void nm_device_resolve_address(int addr_family, gconstpointer address, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer cb_data); diff --git a/src/core/devices/nm-device-veth.c b/src/core/devices/nm-device-veth.c index 28831b75bc..8c95a293d4 100644 --- a/src/core/devices/nm-device-veth.c +++ b/src/core/devices/nm-device-veth.c @@ -75,13 +75,13 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); + const char *iface = nm_device_get_iface(device); NMSettingVeth *s_veth; int r; @@ -143,7 +143,7 @@ static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMDeviceVeth *self = NM_DEVICE_VETH(object); - NMDevice * peer; + NMDevice *peer; switch (prop_id) { case PROP_PEER: @@ -168,9 +168,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_veth = { static void nm_device_veth_class_init(NMDeviceVethClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; @@ -201,11 +201,11 @@ nm_device_veth_class_init(NMDeviceVethClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_VETH_DEVICE_FACTORY, NMVethDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_VETH, NM_DEVICE_IFACE, diff --git a/src/core/devices/nm-device-vlan.c b/src/core/devices/nm-device-vlan.c index 5709ad7b18..0c101c70b5 100644 --- a/src/core/devices/nm-device-vlan.c +++ b/src/core/devices/nm-device-vlan.c @@ -54,7 +54,7 @@ G_DEFINE_TYPE(NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) /*****************************************************************************/ static void -parent_state_changed(NMDevice * parent, +parent_state_changed(NMDevice *parent, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, @@ -84,11 +84,11 @@ parent_mtu_maybe_changed(NMDevice *parent, GParamSpec *pspec, gpointer user_data static void parent_hwaddr_maybe_changed(NMDevice *parent, GParamSpec *pspec, gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); + NMDevice *device = NM_DEVICE(user_data); NMDeviceVlan *self = NM_DEVICE_VLAN(device); NMConnection *connection; - const char * old_mac; - const char * new_mac; + const char *old_mac; + const char *new_mac; /* Never touch assumed devices */ if (nm_device_sys_iface_state_is_external_or_assume(device)) @@ -126,7 +126,7 @@ parent_changed_notify(NMDevice *device, int new_ifindex, NMDevice *new_parent) { - NMDeviceVlan * self = NM_DEVICE_VLAN(device); + NMDeviceVlan *self = NM_DEVICE_VLAN(device); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE(self); NM_DEVICE_CLASS(nm_device_vlan_parent_class) @@ -175,8 +175,8 @@ parent_changed_notify(NMDevice *device, static void update_properties(NMDevice *device) { - NMDeviceVlanPrivate * priv; - const NMPlatformLink * plink = NULL; + NMDeviceVlanPrivate *priv; + const NMPlatformLink *plink = NULL; const NMPlatformLnkVlan *plnk = NULL; int ifindex; int parent_ifindex = 0; @@ -215,15 +215,15 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE(device); - const char * iface = nm_device_get_iface(device); - NMSettingVlan * s_vlan; + const char *iface = nm_device_get_iface(device); + NMSettingVlan *s_vlan; int parent_ifindex; guint vlan_id; int r; @@ -291,7 +291,7 @@ create_and_realize(NMDevice * device, static void unrealize_notify(NMDevice *device) { - NMDeviceVlan * self = NM_DEVICE_VLAN(device); + NMDeviceVlan *self = NM_DEVICE_VLAN(device); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE(self); NM_DEVICE_CLASS(nm_device_vlan_parent_class)->unrealize_notify(device); @@ -327,8 +327,8 @@ static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE(device); - NMSettingVlan * s_vlan; - const char * parent; + NMSettingVlan *s_vlan; + const char *parent; if (!NM_DEVICE_CLASS(nm_device_vlan_parent_class) ->check_connection_compatible(device, connection, error)) @@ -368,11 +368,11 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -check_connection_available(NMDevice * device, - NMConnection * connection, +check_connection_available(NMDevice *device, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { if (!nm_device_is_real(device)) return TRUE; @@ -382,11 +382,11 @@ check_connection_available(NMDevice * device, } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingVlan *s_vlan; @@ -428,11 +428,11 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceVlanPrivate * priv = NM_DEVICE_VLAN_GET_PRIVATE(device); - NMSettingVlan * s_vlan = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VLAN); + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE(device); + NMSettingVlan *s_vlan = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VLAN); int ifindex = nm_device_get_ifindex(device); const NMPlatformLink *plink; - const NMPObject * polnk; + const NMPObject *polnk; guint vlan_id; _NMVlanFlags vlan_flags; @@ -478,7 +478,7 @@ update_connection(NMDevice *device, NMConnection *connection) static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDevice * parent_device; + NMDevice *parent_device; NMSettingVlan *s_vlan; /* Change MAC address to parent's one if needed */ @@ -549,9 +549,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_vlan = { static void nm_device_vlan_class_init(NMDeviceVlanClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; @@ -595,11 +595,11 @@ nm_device_vlan_class_init(NMDeviceVlanClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_VLAN_DEVICE_FACTORY, NMVlanDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_VLAN, NM_DEVICE_IFACE, @@ -618,9 +618,9 @@ create_device(NMDeviceFactory * factory, static const char * get_connection_parent(NMDeviceFactory *factory, NMConnection *connection) { - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; NMSettingWired *s_wired; - const char * parent = NULL; + const char *parent = NULL; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_VLAN_SETTING_NAME), NULL); @@ -642,7 +642,7 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection) static char * get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface) { - const char * ifname; + const char *ifname; NMSettingVlan *s_vlan; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_VLAN_SETTING_NAME), NULL); diff --git a/src/core/devices/nm-device-vrf.c b/src/core/devices/nm-device-vrf.c index c752fa0a0b..ae80e1d462 100644 --- a/src/core/devices/nm-device-vrf.c +++ b/src/core/devices/nm-device-vrf.c @@ -44,7 +44,7 @@ static void do_update_properties(NMDeviceVrf *self, const NMPlatformLnkVrf *props) { NMDeviceVrfPrivate *priv = NM_DEVICE_VRF_GET_PRIVATE(self); - GObject * object = G_OBJECT(self); + GObject *object = G_OBJECT(self); NMPlatformLnkVrf props_null; if (!props) { @@ -72,7 +72,7 @@ do_update_properties(NMDeviceVrf *self, const NMPlatformLnkVrf *props) static void update_properties(NMDevice *device) { - NMDeviceVrf * self = NM_DEVICE_VRF(device); + NMDeviceVrf *self = NM_DEVICE_VRF(device); const NMPlatformLnkVrf *props; props = nm_platform_link_get_lnk_vrf(nm_device_get_platform(device), @@ -110,15 +110,15 @@ unrealize_notify(NMDevice *device) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); + const char *iface = nm_device_get_iface(device); NMPlatformLnkVrf props = {}; - NMSettingVrf * s_vrf; + NMSettingVrf *s_vrf; int r; s_vrf = _nm_connection_get_setting(connection, NM_TYPE_SETTING_VRF); @@ -145,7 +145,7 @@ static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMDeviceVrfPrivate *priv = NM_DEVICE_VRF_GET_PRIVATE(device); - NMSettingVrf * s_vrf; + NMSettingVrf *s_vrf; if (!NM_DEVICE_CLASS(nm_device_vrf_parent_class) ->check_connection_compatible(device, connection, error)) @@ -166,11 +166,11 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingVrf *s_vrf; @@ -200,7 +200,7 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMDeviceVrfPrivate *priv = NM_DEVICE_VRF_GET_PRIVATE(device); - NMSettingVrf * s_vrf = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VRF); + NMSettingVrf *s_vrf = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VRF); if (priv->props.table != nm_setting_vrf_get_table(s_vrf)) g_object_set(G_OBJECT(s_vrf), NM_SETTING_VRF_TABLE, priv->props.table, NULL); @@ -211,7 +211,7 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool { NMDeviceVrf *self = NM_DEVICE_VRF(device); gboolean success = TRUE; - const char * slave_iface = nm_device_get_ip_iface(slave); + const char *slave_iface = nm_device_get_ip_iface(slave); nm_device_master_check_slave_physical_port(device, slave, LOGD_DEVICE); @@ -303,9 +303,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_vrf = { static void nm_device_vrf_class_init(NMDeviceVrfClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; @@ -344,11 +344,11 @@ nm_device_vrf_class_init(NMDeviceVrfClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_VRF_DEVICE_FACTORY, NMVrfDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_VRF, NM_DEVICE_IFACE, diff --git a/src/core/devices/nm-device-vxlan.c b/src/core/devices/nm-device-vxlan.c index 329cc3febb..bf7c94c006 100644 --- a/src/core/devices/nm-device-vxlan.c +++ b/src/core/devices/nm-device-vxlan.c @@ -64,9 +64,9 @@ G_DEFINE_TYPE(NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE) static void update_properties(NMDevice *device) { - NMDeviceVxlan * self = NM_DEVICE_VXLAN(device); - NMDeviceVxlanPrivate * priv = NM_DEVICE_VXLAN_GET_PRIVATE(self); - GObject * object = G_OBJECT(device); + NMDeviceVxlan *self = NM_DEVICE_VXLAN(device); + NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE(self); + GObject *object = G_OBJECT(device); const NMPlatformLnkVxlan *props; props = nm_platform_link_get_lnk_vxlan(nm_device_get_platform(device), @@ -139,7 +139,7 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) static void unrealize_notify(NMDevice *device) { - NMDeviceVxlan * self = NM_DEVICE_VXLAN(device); + NMDeviceVxlan *self = NM_DEVICE_VXLAN(device); NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE(self); guint i; @@ -152,16 +152,16 @@ unrealize_notify(NMDevice *device) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { - const char * iface = nm_device_get_iface(device); + const char *iface = nm_device_get_iface(device); NMPlatformLnkVxlan props = {}; - NMSettingVxlan * s_vxlan; - const char * str; + NMSettingVxlan *s_vxlan; + const char *str; int r; s_vxlan = nm_connection_get_setting_vxlan(connection); @@ -241,8 +241,8 @@ static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE(device); - NMSettingVxlan * s_vxlan; - const char * parent; + NMSettingVxlan *s_vxlan; + const char *parent; if (!NM_DEVICE_CLASS(nm_device_vxlan_parent_class) ->check_connection_compatible(device, connection, error)) @@ -366,11 +366,11 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingVxlan *s_vxlan; @@ -604,9 +604,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_vxlan = { static void nm_device_vxlan_class_init(NMDeviceVxlanClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; @@ -744,11 +744,11 @@ nm_device_vxlan_class_init(NMDeviceVxlanClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_VXLAN_DEVICE_FACTORY, NMVxlanDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_VXLAN, NM_DEVICE_IFACE, @@ -778,7 +778,7 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection) static char * get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface) { - const char * ifname; + const char *ifname; NMSettingVxlan *s_vxlan; g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_VXLAN_SETTING_NAME), NULL); diff --git a/src/core/devices/nm-device-wireguard.c b/src/core/devices/nm-device-wireguard.c index de715264ce..4399e83478 100644 --- a/src/core/devices/nm-device-wireguard.c +++ b/src/core/devices/nm-device-wireguard.c @@ -179,9 +179,9 @@ static NM_UTILS_LOOKUP_STR_DEFINE(_link_config_mode_to_string, static void _auto_default_route_get_enabled(NMSettingWireGuard *s_wg, - NMConnection * connection, - gboolean * out_enabled_v4, - gboolean * out_enabled_v6) + NMConnection *connection, + gboolean *out_enabled_v4, + gboolean *out_enabled_v6) { NMTernary enabled_v4; NMTernary enabled_v6; @@ -327,7 +327,7 @@ static void _auto_default_route_init(NMDeviceWireGuard *self) { NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - NMConnection * connection; + NMConnection *connection; gboolean enabled_v4 = FALSE; gboolean enabled_v6 = FALSE; gboolean refreshing_only; @@ -380,12 +380,12 @@ _auto_default_route_init(NMDeviceWireGuard *self) static GPtrArray * get_extra_rules(NMDevice *device) { - NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(device); - NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); + NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(device); + NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *extra_rules = NULL; guint32 priority = 0; int is_ipv4; - NMConnection * connection; + NMConnection *connection; _auto_default_route_init(self); @@ -457,7 +457,7 @@ get_extra_rules(NMDevice *device) static guint32 coerce_route_table(NMDevice *device, int addr_family, guint32 route_table, gboolean is_user_config) { - NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(device); + NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(device); NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); gboolean auto_default_route_enabled; @@ -581,7 +581,7 @@ static PeerData * _peers_add(NMDeviceWireGuard *self, NMWireGuardPeer *peer) { NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - PeerData * peer_data; + PeerData *peer_data; nm_assert(peer); nm_assert(nm_wireguard_peer_is_sealed(peer)); @@ -606,9 +606,9 @@ _peers_add(NMDeviceWireGuard *self, NMWireGuardPeer *peer) static gboolean _peers_resolve_retry_timeout(gpointer user_data) { - NMDeviceWireGuard * self = user_data; + NMDeviceWireGuard *self = user_data; NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - PeerData * peer_data; + PeerData *peer_data; gint64 now; gint64 next; @@ -684,7 +684,7 @@ _peers_resolve_retry_reschedule(NMDeviceWireGuard *self, gint64 new_next_try_at_ static void _peers_resolve_retry_reschedule_for_peer(NMDeviceWireGuard *self, - PeerData * peer_data, + PeerData *peer_data, gint64 retry_in_msec) { nm_assert(retry_in_msec >= 0); @@ -726,16 +726,16 @@ _peers_retry_in_msec(PeerData *peer_data, gboolean after_failure) static void _peers_resolve_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMDeviceWireGuard * self; + NMDeviceWireGuard *self; NMDeviceWireGuardPrivate *priv; - PeerData * peer_data; - gs_free_error GError *resolv_error = NULL; - GList * list; - gboolean changed; - NMSockAddrUnion sockaddr; - gint64 retry_in_msec; - char s_sockaddr[100]; - char s_retry[100]; + PeerData *peer_data; + gs_free_error GError *resolv_error = NULL; + GList *list; + gboolean changed; + NMSockAddrUnion sockaddr; + gint64 retry_in_msec; + char s_sockaddr[100]; + char s_retry[100]; list = g_resolver_lookup_by_name_finish(G_RESOLVER(source_object), res, &resolv_error); @@ -783,7 +783,7 @@ _peers_resolve_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) GList *iter; for (iter = list; iter; iter = iter->next) { - GInetAddress * a = iter->data; + GInetAddress *a = iter->data; NMSockAddrUnion sockaddr_tmp; NMSockAddrUnion *s; @@ -875,9 +875,9 @@ _peers_resolve_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) static void _peers_resolve_start(NMDeviceWireGuard *self, PeerData *peer_data) { - NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); + NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); gs_unref_object GResolver *resolver = NULL; - const char * host; + const char *host; resolver = g_resolver_get_default(); @@ -914,7 +914,7 @@ static void _peers_resolve_reresolve_all(NMDeviceWireGuard *self) { NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - PeerData * peer_data; + PeerData *peer_data; c_list_for_each_entry (peer_data, &priv->lst_peers_head, lst_peers) { if (peer_data->ep_resolv.cancellable) { @@ -932,13 +932,13 @@ _peers_resolve_reresolve_all(NMDeviceWireGuard *self) static gboolean _peers_update(NMDeviceWireGuard *self, - PeerData * peer_data, - NMWireGuardPeer * peer, + PeerData *peer_data, + NMWireGuardPeer *peer, gboolean force_update) { nm_auto_unref_wgpeer NMWireGuardPeer *old_peer = NULL; - NMSockAddrEndpoint * old_endpoint; - NMSockAddrEndpoint * endpoint; + NMSockAddrEndpoint *old_endpoint; + NMSockAddrEndpoint *endpoint; gboolean endpoint_changed = FALSE; gboolean changed; NMSockAddrUnion sockaddr; @@ -1019,7 +1019,7 @@ static void _peers_remove_all(NMDeviceWireGuard *self) { NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - PeerData * peer_data; + PeerData *peer_data; while ((peer_data = c_list_first_entry(&priv->lst_peers_head, PeerData, lst_peers))) _peers_remove(self, peer_data); @@ -1029,8 +1029,8 @@ static void _peers_update_all(NMDeviceWireGuard *self, NMSettingWireGuard *s_wg, gboolean *out_peers_removed) { NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - PeerData * peer_data_safe; - PeerData * peer_data; + PeerData *peer_data_safe; + PeerData *peer_data; guint i, n; gboolean peers_removed = FALSE; @@ -1062,22 +1062,22 @@ _peers_update_all(NMDeviceWireGuard *self, NMSettingWireGuard *s_wg, gboolean *o } static void -_peers_get_platform_list(NMDeviceWireGuardPrivate * priv, +_peers_get_platform_list(NMDeviceWireGuardPrivate *priv, LinkConfigMode config_mode, - NMPWireGuardPeer ** out_peers, + NMPWireGuardPeer **out_peers, NMPlatformWireGuardChangePeerFlags **out_peer_flags, - guint * out_len, - GArray ** out_allowed_ips_data) + guint *out_len, + GArray **out_allowed_ips_data) { - gs_free NMPWireGuardPeer *plpeers = NULL; + gs_free NMPWireGuardPeer *plpeers = NULL; gs_free NMPlatformWireGuardChangePeerFlags *plpeer_flags = NULL; - gs_unref_array GArray *allowed_ips = NULL; - PeerData * peer_data; - guint i_good; - guint n_aip; - guint i_aip; - guint len; - guint i; + gs_unref_array GArray *allowed_ips = NULL; + PeerData *peer_data; + guint i_good; + guint n_aip; + guint i_aip; + guint len; + guint i; nm_assert(out_peers && !*out_peers); nm_assert(out_peer_flags && !*out_peer_flags); @@ -1097,7 +1097,7 @@ _peers_get_platform_list(NMDeviceWireGuardPrivate * priv, i_good = 0; c_list_for_each_entry (peer_data, &priv->lst_peers_head, lst_peers) { NMPlatformWireGuardChangePeerFlags *plf = &plpeer_flags[i_good]; - NMPWireGuardPeer * plp = &plpeers[i_good]; + NMPWireGuardPeer *plp = &plpeers[i_good]; NMSettingSecretFlags psk_secret_flags; if (!nm_utils_base64secret_decode(nm_wireguard_peer_get_public_key(peer_data->peer), @@ -1212,9 +1212,9 @@ skip: static void update_properties(NMDevice *device) { - NMDeviceWireGuard * self; - NMDeviceWireGuardPrivate * priv; - const NMPlatformLink * plink; + NMDeviceWireGuard *self; + NMDeviceWireGuardPrivate *priv; + const NMPlatformLink *plink; const NMPlatformLnkWireGuard *props = NULL; int ifindex; @@ -1274,11 +1274,11 @@ get_generic_capabilities(NMDevice *dev) /*****************************************************************************/ static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { const char *iface = nm_device_get_iface(device); int r; @@ -1313,14 +1313,14 @@ _secrets_cancel(NMDeviceWireGuard *self) } static void -_secrets_cb(NMActRequest * req, +_secrets_cb(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * connection, - GError * error, + NMSettingsConnection *connection, + GError *error, gpointer user_data) { - NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(user_data); - NMDevice * device = NM_DEVICE(self); + NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(user_data); + NMDevice *device = NM_DEVICE(self); NMDeviceWireGuardPrivate *priv; g_return_if_fail(NM_IS_DEVICE_WIREGUARD(self)); @@ -1349,13 +1349,13 @@ _secrets_cb(NMActRequest * req, } static void -_secrets_get_secrets(NMDeviceWireGuard * self, - const char * setting_name, +_secrets_get_secrets(NMDeviceWireGuard *self, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char *const * hints) + const char *const *hints) { NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - NMActRequest * req; + NMActRequest *req; _secrets_cancel(self); @@ -1370,8 +1370,8 @@ _secrets_get_secrets(NMDeviceWireGuard * self, static NMActStageReturn _secrets_handle_auth_or_fail(NMDeviceWireGuard *self, NMActRequest *req, gboolean new_secrets) { - NMConnection * applied_connection; - const char * setting_name; + NMConnection *applied_connection; + const char *setting_name; gs_unref_ptrarray GPtrArray *hints = NULL; if (!nm_device_auth_retries_try_next(NM_DEVICE(self))) @@ -1416,22 +1416,22 @@ _dns_config_changed(NMDnsManager *dns_manager, NMDeviceWireGuard *self) /*****************************************************************************/ static NMActStageReturn -link_config(NMDeviceWireGuard * self, - const char * reason, +link_config(NMDeviceWireGuard *self, + const char *reason, LinkConfigMode config_mode, NMDeviceStateReason *out_failure_reason) { - NMDeviceWireGuardPrivate * priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - nm_auto_bzero_secret_ptr NMSecretPtr wg_lnk_clear_private_key = NM_SECRET_PTR_INIT(); - NMSettingWireGuard * s_wg; - NMConnection * connection; - NMActStageReturn ret; - gs_unref_array GArray *allowed_ips_data = NULL; - NMPlatformLnkWireGuard wg_lnk; - gs_free NMPWireGuardPeer *plpeers = NULL; + NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); + nm_auto_bzero_secret_ptr NMSecretPtr wg_lnk_clear_private_key = NM_SECRET_PTR_INIT(); + NMSettingWireGuard *s_wg; + NMConnection *connection; + NMActStageReturn ret; + gs_unref_array GArray *allowed_ips_data = NULL; + NMPlatformLnkWireGuard wg_lnk; + gs_free NMPWireGuardPeer *plpeers = NULL; gs_free NMPlatformWireGuardChangePeerFlags *plpeer_flags = NULL; guint plpeers_len = 0; - const char * setting_name; + const char *setting_name; gboolean peers_removed; NMPlatformWireGuardChangeFlags wg_change_flags; int ifindex; @@ -1584,7 +1584,7 @@ link_config_delayed_resolver_cb(gpointer user_data) static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(device); + NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(device); NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); NMDeviceSysIfaceState sys_iface_state; NMDeviceStateReason failure_reason; @@ -1629,10 +1629,10 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) static const NML3ConfigData * _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family) { - NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); + NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - NMConnection * connection; - NMSettingWireGuard * s_wg; + NMConnection *connection; + NMSettingWireGuard *s_wg; guint n_peers; guint i; int ip_ifindex; @@ -1694,7 +1694,7 @@ _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family) for (j = 0; j < n_aips; j++) { NMPlatformIPXRoute rt; NMIPAddr addrbin; - const char * aip; + const char *aip; gboolean valid; int prefix; guint32 rtable_coerced; @@ -1815,7 +1815,7 @@ _device_cleanup(NMDeviceWireGuard *self) } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) @@ -1829,12 +1829,12 @@ device_state_changed(NMDevice * device, /*****************************************************************************/ static gboolean -can_reapply_change(NMDevice * device, +can_reapply_change(NMDevice *device, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error) + GError **error) { if (nm_streq(setting_name, NM_SETTING_WIREGUARD_SETTING_NAME)) { /* Most, but not all WireGuard settings can be reapplied. Whitelist. @@ -1860,7 +1860,7 @@ can_reapply_change(NMDevice * device, static void reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_new) { - NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(device); + NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(device); NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); NMDeviceState state = nm_device_get_state(device); @@ -1890,7 +1890,7 @@ update_connection(NMDevice *device, NMConnection *connection) { NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(device); NMSettingWireGuard *s_wg = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIREGUARD); - const NMPObject * obj_wg; + const NMPObject *obj_wg; const NMPObjectLnkWireGuard *olnk_wg; guint i; @@ -1911,7 +1911,7 @@ update_connection(NMDevice *device, NMConnection *connection) for (i = 0; i < olnk_wg->peers_len; i++) { nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; - const NMPWireGuardPeer * ppeer = &olnk_wg->peers[i]; + const NMPWireGuardPeer *ppeer = &olnk_wg->peers[i]; peer = nm_wireguard_peer_new(); @@ -1926,7 +1926,7 @@ update_connection(NMDevice *device, NMConnection *connection) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(object); + NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(object); NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); switch (prop_id) { @@ -1971,7 +1971,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMDeviceWireGuard * self = NM_DEVICE_WIREGUARD(object); + NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(object); NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); nm_explicit_bzero(priv->lnk_curr.private_key, sizeof(priv->lnk_curr.private_key)); @@ -2004,9 +2004,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_wireguard = { static void nm_device_wireguard_class_init(NMDeviceWireGuardClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; object_class->dispose = dispose; @@ -2066,11 +2066,11 @@ nm_device_wireguard_class_init(NMDeviceWireGuardClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_WIREGUARD_DEVICE_FACTORY, NMWireGuardDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_WIREGUARD, NM_DEVICE_IFACE, diff --git a/src/core/devices/nm-device-wpan.c b/src/core/devices/nm-device-wpan.c index ed5bcbde4d..f7b712ea85 100644 --- a/src/core/devices/nm-device-wpan.c +++ b/src/core/devices/nm-device-wpan.c @@ -38,11 +38,11 @@ G_DEFINE_TYPE(NMDeviceWpan, nm_device_wpan, NM_TYPE_DEVICE) /*****************************************************************************/ static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingWpan *s_wpan; @@ -78,7 +78,7 @@ static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMSettingWpan *s_wpan; - const char * mac, *hw_addr; + const char *mac, *hw_addr; if (!NM_DEVICE_CLASS(nm_device_wpan_parent_class) ->check_connection_compatible(device, connection, error)) @@ -103,17 +103,17 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceWpan * self = NM_DEVICE_WPAN(device); - NMSettingWpan * s_wpan; - NMPlatform * platform; + NMDeviceWpan *self = NM_DEVICE_WPAN(device); + NMSettingWpan *s_wpan; + NMPlatform *platform; guint16 pan_id; guint16 short_address; gint16 page, channel; int ifindex; - const guint8 * hwaddr; + const guint8 *hwaddr; gsize hwaddr_len = 0; const NMPlatformLink *lowpan_plink; - NMDevice * lowpan_device = NULL; + NMDevice *lowpan_device = NULL; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; platform = nm_device_get_platform(device); @@ -202,7 +202,7 @@ static const NMDBusInterfaceInfoExtended interface_info_device_wpan = { static void nm_device_wpan_class_init(NMDeviceWpanClass *klass) { - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_wpan); @@ -224,11 +224,11 @@ nm_device_wpan_class_init(NMDeviceWpanClass *klass) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_WPAN_DEVICE_FACTORY, NMWpanDeviceFactory)) static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return g_object_new(NM_TYPE_DEVICE_WPAN, NM_DEVICE_IFACE, diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 6f31ba6038..6f104b5b8d 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -126,8 +126,8 @@ typedef struct { } DeleteOnDeactivateData; typedef struct { - NMDevice * device; - GCancellable * cancellable; + NMDevice *device; + GCancellable *cancellable; NMPlatformAsyncCallback callback; gpointer callback_data; guint num_vfs; @@ -223,8 +223,8 @@ typedef struct { } IPStateData; typedef struct { - NMDhcpClient * client; - NMDhcpConfig * config; + NMDhcpClient *client; + NMDhcpConfig *config; gulong notify_sigid; NMDeviceIPState state; union { @@ -246,11 +246,11 @@ typedef struct { NMDeviceIPState state; union { struct { - NMDnsMasqManager * dnsmasq_manager; + NMDnsMasqManager *dnsmasq_manager; NMNetnsSharedIPHandle *shared_ip_handle; - NMFirewallConfig * firewall_config; + NMFirewallConfig *firewall_config; gulong dnsmasq_state_id; - const NML3ConfigData * l3cd; + const NML3ConfigData *l3cd; } v4; struct { } v6; @@ -261,13 +261,13 @@ typedef struct { NMDeviceIPState state; union { struct { - NML3IPv4LL * ipv4ll; + NML3IPv4LL *ipv4ll; NML3IPv4LLRegistration *ipv4ll_registation; - GSource * timeout_source; + GSource *timeout_source; } v4; struct { - NML3IPv6LL * ipv6ll; - GSource * retry_source; + NML3IPv6LL *ipv6ll; + GSource *retry_source; NML3IPv6LLState llstate; struct in6_addr lladdr; } v6; @@ -276,10 +276,10 @@ typedef struct { struct _NMDeviceConnectivityHandle { CList concheck_lst; - NMDevice * self; + NMDevice *self; NMDeviceConnectivityCallback callback; gpointer user_data; - NMConnectivityCheckHandle * c_handle; + NMConnectivityCheckHandle *c_handle; guint64 seq; bool is_periodic : 1; bool is_periodic_bump : 1; @@ -292,8 +292,8 @@ typedef struct { NMEthtoolFeatureStates *features; NMOptionBool requested[_NM_ETHTOOL_ID_FEATURE_NUM]; NMEthtoolCoalesceState *coalesce; - NMEthtoolRingState * ring; - NMEthtoolPauseState * pause; + NMEthtoolRingState *ring; + NMEthtoolPauseState *pause; } EthtoolState; typedef enum { @@ -306,8 +306,8 @@ typedef struct { ResolverState state; GInetAddress *address; GCancellable *cancellable; - char * hostname; - NMDevice * device; + char *hostname; + NMDevice *device; guint timeout_id; /* Used when waiting for the address */ int addr_family; } HostnameResolver; @@ -406,16 +406,16 @@ typedef struct _NMDevicePrivate { union { const char *const iface; - char * iface_; + char *iface_; }; union { const char *const ip_iface; - char * ip_iface_; + char *ip_iface_; }; union { NML3Cfg *const l3cfg; - NML3Cfg * l3cfg_; + NML3Cfg *l3cfg_; }; union { @@ -464,12 +464,12 @@ typedef struct _NMDevicePrivate { bool real : 1; NMDeviceType type; - char * type_desc; + char *type_desc; NMLinkType link_type; NMDeviceCapabilities capabilities; - char * driver; - char * driver_version; - char * firmware_version; + char *driver; + char *driver_version; + char *firmware_version; RfKillType rfkill_type; bool firmware_missing : 1; bool nm_plugin_missing : 1; @@ -488,10 +488,10 @@ typedef struct _NMDevicePrivate { guint64 udi_id; GHashTable *available_connections; - char * hw_addr; - char * hw_addr_perm; - char * hw_addr_initial; - char * physical_port_id; + char *hw_addr; + char *hw_addr_perm; + char *hw_addr_initial; + char *physical_port_id; guint dev_id; NMUnmanagedFlags unmanaged_mask; @@ -501,11 +501,11 @@ typedef struct _NMDevicePrivate { GCancellable *deactivating_cancellable; - NMActRequest * queued_act_request; + NMActRequest *queued_act_request; bool queued_act_request_is_waiting_for_carrier : 1; NMDBusTrackObjPath act_request; - GSource * activation_idle_source; + GSource *activation_idle_source; ActivationHandleFunc activation_func; guint recheck_assume_id; @@ -624,8 +624,8 @@ typedef struct _NMDevicePrivate { }; struct { - NMNDisc * ndisc; - GSource * ndisc_grace_source; + NMNDisc *ndisc; + GSource *ndisc_grace_source; gulong ndisc_changed_id; gulong ndisc_timeout_id; NMDeviceIPState state; @@ -671,14 +671,14 @@ typedef struct _NMDevicePrivate { guint timeout; guint watch; GPid pid; - char * binary; - char * address; + char *binary; + char *address; guint deadline; } gw_ping; /* Firewall */ FirewallState fw_state : 4; - NMFirewalldManager * fw_mgr; + NMFirewalldManager *fw_mgr; NMFirewalldManagerCallId *fw_call; GHashTable *ip6_saved_properties; @@ -696,7 +696,7 @@ typedef struct _NMDevicePrivate { NMMetered metered; NMSettings *settings; - NMManager * manager; + NMManager *manager; NMNetns *netns; @@ -776,10 +776,10 @@ static guint32 _prop_get_ipv4_dad_timeout(NMDevice *self); static void _carrier_wait_check_queued_act_request(NMDevice *self); static gint64 _get_carrier_wait_ms(NMDevice *self); -static GBytes *_prop_get_ipv6_dhcp_duid(NMDevice * self, +static GBytes *_prop_get_ipv6_dhcp_duid(NMDevice *self, NMConnection *connection, - GBytes * hwaddr, - gboolean * out_enforce); + GBytes *hwaddr, + gboolean *out_enforce); static const char *_activation_func_to_string(ActivationHandleFunc func); @@ -788,10 +788,10 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, static void queued_state_clear(NMDevice *device); static void ip_check_ping_watch_cb(GPid pid, int status, gpointer user_data); static void nm_device_start_ip_check(NMDevice *self); -static void realize_start_setup(NMDevice * self, +static void realize_start_setup(NMDevice *self, const NMPlatformLink *plink, gboolean assume_state_guess_assume, - const char * assume_state_connection_uuid, + const char *assume_state_connection_uuid, gboolean set_nm_owned, NMUnmanFlagOp unmanaged_user_explicit, gboolean force_platform_init); @@ -833,7 +833,7 @@ static void _dev_ipshared6_start(NMDevice *self); static void _cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type, gboolean from_reapply); -static void concheck_update_state(NMDevice * self, +static void concheck_update_state(NMDevice *self, int addr_family, NMConnectivityState state, gboolean is_periodic); @@ -949,8 +949,8 @@ _ip6_privacy_clamp(NMSettingIP6ConfigPrivacy use_tempaddr) /*****************************************************************************/ static const char * -_prop_get_connection_stable_id(NMDevice * self, - NMConnection * connection, +_prop_get_connection_stable_id(NMDevice *self, + NMConnection *connection, NMUtilsStableType *out_stable_type) { NMDevicePrivate *priv; @@ -969,13 +969,13 @@ _prop_get_connection_stable_id(NMDevice * self, * Especially with ${RANDOM} stable-id we want to generate *one* configuration * for each activation. */ if (G_UNLIKELY(!priv->current_stable_id)) { - gs_free char * generated = NULL; + gs_free char *generated = NULL; NMUtilsStableType stable_type; NMSettingConnection *s_con; gboolean hwaddr_is_fake; - const char * hwaddr; - const char * stable_id; - const char * uuid; + const char *hwaddr; + const char *stable_id; + const char *uuid; s_con = nm_connection_get_setting_connection(connection); @@ -1037,18 +1037,18 @@ _prop_get_connection_stable_id(NMDevice * self, } static GBytes * -_prop_get_ipv6_dhcp_duid(NMDevice * self, +_prop_get_ipv6_dhcp_duid(NMDevice *self, NMConnection *connection, - GBytes * hwaddr, - gboolean * out_enforce) + GBytes *hwaddr, + gboolean *out_enforce) { NMSettingIPConfig *s_ip6; - const char * duid; - const char * duid_error; - GBytes * duid_out; + const char *duid; + const char *duid_error; + GBytes *duid_out; gboolean duid_enforce = TRUE; - gs_free char * logstr1 = NULL; - const guint8 * hwaddr_bin; + gs_free char *logstr1 = NULL; + const guint8 *hwaddr_bin; gsize hwaddr_len; int arp_type; @@ -1109,12 +1109,12 @@ _prop_get_ipv6_dhcp_duid(NMDevice * self, * * Implementations that are added later, should use a distinct salt instead, * like "stable-ll"/"stable-llt" with ARPHRD_INFINIBAND below. */ - const guint32 DEFAULT_SALT = 670531087u; - nm_auto_free_checksum GChecksum *sum = NULL; + const guint32 DEFAULT_SALT = 670531087u; + nm_auto_free_checksum GChecksum *sum = NULL; NMUtilsStableType stable_type; - const char * stable_id = NULL; + const char *stable_id = NULL; guint32 salted_header; - const guint8 * host_id; + const guint8 *host_id; gsize host_id_len; union { guint8 sha256[NM_UTILS_CHECKSUM_LENGTH_SHA256]; @@ -1287,7 +1287,7 @@ _prop_get_ipv6_ra_timeout(NMDevice *self) static NMSettingConnectionMdns _prop_get_connection_mdns(NMDevice *self) { - NMConnection * connection; + NMConnection *connection; NMSettingConnectionMdns mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT; g_return_val_if_fail(NM_IS_DEVICE(self), NM_SETTING_CONNECTION_MDNS_DEFAULT); @@ -1309,7 +1309,7 @@ _prop_get_connection_mdns(NMDevice *self) static NMSettingConnectionLlmnr _prop_get_connection_llmnr(NMDevice *self) { - NMConnection * connection; + NMConnection *connection; NMSettingConnectionLlmnr llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT; g_return_val_if_fail(NM_IS_DEVICE(self), NM_SETTING_CONNECTION_LLMNR_DEFAULT); @@ -1331,7 +1331,7 @@ _prop_get_connection_llmnr(NMDevice *self) static NMSettingConnectionDnsOverTls _prop_get_connection_dns_over_tls(NMDevice *self) { - NMConnection * connection; + NMConnection *connection; NMSettingConnectionDnsOverTls dns_over_tls = NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT; g_return_val_if_fail(NM_IS_DEVICE(self), NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT); @@ -1354,14 +1354,14 @@ _prop_get_connection_dns_over_tls(NMDevice *self) static guint32 _prop_get_ipvx_route_table(NMDevice *self, int addr_family) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMDeviceClass * klass; - NMConnection * connection; - NMSettingIPConfig * s_ip; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDeviceClass *klass; + NMConnection *connection; + NMSettingIPConfig *s_ip; guint32 route_table = 0; gboolean is_user_config = TRUE; NMSettingConnection *s_con; - NMSettingVrf * s_vrf; + NMSettingVrf *s_vrf; nm_assert_addr_family(addr_family); @@ -1441,8 +1441,8 @@ _prop_get_ipvx_route_table(NMDevice *self, int addr_family) static gboolean _prop_get_connection_lldp(NMDevice *self) { - NMConnection * connection; - NMSettingConnection * s_con; + NMConnection *connection; + NMSettingConnection *s_con; NMSettingConnectionLldp lldp = NM_SETTING_CONNECTION_LLDP_DEFAULT; connection = nm_device_get_applied_connection(self); @@ -1468,7 +1468,7 @@ _prop_get_connection_lldp(NMDevice *self) static guint32 _prop_get_ipv4_dad_timeout(NMDevice *self) { - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip4 = NULL; int timeout = -1; @@ -1495,7 +1495,7 @@ static guint32 _prop_get_ipvx_dhcp_timeout(NMDevice *self, int addr_family) { NMDeviceClass *klass; - NMConnection * connection; + NMConnection *connection; guint32 timeout; int timeout_i; @@ -1542,7 +1542,7 @@ out: static guint32 _prop_get_ipvx_dns_priority(NMDevice *self, int addr_family) { - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip; int prio = 0; @@ -1573,7 +1573,7 @@ _prop_get_ipvx_dns_priority(NMDevice *self, int addr_family) static guint32 _prop_get_ipvx_required_timeout(NMDevice *self, int addr_family) { - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip; int timeout; @@ -1607,7 +1607,7 @@ _prop_get_ipvx_required_timeout(NMDevice *self, int addr_family) static gboolean _prop_get_ipvx_may_fail(NMDevice *self, int addr_family) { - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip = NULL; connection = nm_device_get_applied_connection(self); @@ -1636,18 +1636,18 @@ _prop_get_ipvx_may_fail_cached(NMDevice *self, int addr_family, NMTernary *cache * Returns: a IAID value for this device and the given connection. */ static guint32 -_prop_get_ipvx_dhcp_iaid(NMDevice * self, +_prop_get_ipvx_dhcp_iaid(NMDevice *self, int addr_family, NMConnection *connection, gboolean log_silent, - gboolean * out_is_explicit) + gboolean *out_is_explicit) { const int IS_IPv4 = NM_IS_IPv4(addr_family); NMSettingIPConfig *s_ip; - const char * iaid_str; + const char *iaid_str; guint32 iaid; - const char * iface; - const char * fail_reason; + const char *iface; + const char *fail_reason; gboolean is_explicit = TRUE; s_ip = nm_connection_get_setting_ip_config(connection, addr_family); @@ -1711,9 +1711,9 @@ _prop_get_ipvx_dhcp_iaid(NMDevice * self, nm_auto_free_checksum GChecksum *sum = NULL; guint8 digest[NM_UTILS_CHECKSUM_LENGTH_SHA1]; NMUtilsStableType stable_type; - const char * stable_id; + const char *stable_id; guint32 salted_header; - const guint8 * host_id; + const guint8 *host_id; gsize host_id_len; stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); @@ -1766,9 +1766,9 @@ out_good: static NMDhcpHostnameFlags _prop_get_ipvx_dhcp_hostname_flags(NMDevice *self, int addr_family) { - NMConnection * connection; - NMSettingIPConfig * s_ip; - NMDhcpHostnameFlags flags; + NMConnection *connection; + NMSettingIPConfig *s_ip; + NMDhcpHostnameFlags flags; gs_free_error GError *error = NULL; g_return_val_if_fail(NM_IS_DEVICE(self), NM_DHCP_HOSTNAME_FLAG_NONE); @@ -1843,15 +1843,15 @@ static GBytes * _prop_get_ipv4_dhcp_client_id(NMDevice *self, NMConnection *connection, GBytes *hwaddr) { NMSettingIPConfig *s_ip4; - const char * client_id; - guint8 * client_id_buf; - const char * fail_reason; + const char *client_id; + guint8 *client_id_buf; + const char *fail_reason; guint8 hwaddr_bin_buf[_NM_UTILS_HWADDR_LEN_MAX]; - const guint8 * hwaddr_bin; + const guint8 *hwaddr_bin; int arp_type; gsize hwaddr_len; - GBytes * result; - gs_free char * logstr1 = NULL; + GBytes *result; + gs_free char *logstr1 = NULL; s_ip4 = nm_connection_get_setting_ip4_config(connection); client_id = nm_setting_ip4_config_get_dhcp_client_id(NM_SETTING_IP4_CONFIG(s_ip4)); @@ -1922,7 +1922,7 @@ _prop_get_ipv4_dhcp_client_id(NMDevice *self, NMConnection *connection, GBytes * gs_unref_bytes GBytes *duid = NULL; gboolean iaid_is_explicit; guint32 iaid; - const guint8 * duid_arr; + const guint8 *duid_arr; gsize duid_len; iaid = _prop_get_ipvx_dhcp_iaid(self, AF_INET, connection, FALSE, &iaid_is_explicit); @@ -1947,9 +1947,9 @@ _prop_get_ipv4_dhcp_client_id(NMDevice *self, NMConnection *connection, GBytes * nm_auto_free_checksum GChecksum *sum = NULL; guint8 digest[NM_UTILS_CHECKSUM_LENGTH_SHA1]; NMUtilsStableType stable_type; - const char * stable_id; + const char *stable_id; guint32 salted_header; - const guint8 * host_id; + const guint8 *host_id; gsize host_id_len; stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); @@ -1995,9 +1995,9 @@ static GBytes * _prop_get_ipv4_dhcp_vendor_class_identifier(NMDevice *self, NMSettingIP4Config *s_ip4) { gs_free char *to_free = NULL; - const char * conn_prop; - GBytes * bytes = NULL; - const char * bin; + const char *conn_prop; + GBytes *bytes = NULL; + const char *bin; gsize len; conn_prop = nm_setting_ip4_config_get_dhcp_vendor_class_identifier(s_ip4); @@ -2031,7 +2031,7 @@ static NMSettingIP6ConfigPrivacy _prop_get_ipv6_ip6_privacy(NMDevice *self) { NMSettingIP6ConfigPrivacy ip6_privacy; - NMConnection * connection; + NMConnection *connection; g_return_val_if_fail(self, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); @@ -2078,7 +2078,7 @@ _prop_get_ipv6_ip6_privacy(NMDevice *self) static const char * _prop_get_x_cloned_mac_address(NMDevice *self, NMConnection *connection, gboolean is_wifi) { - NMSetting * setting; + NMSetting *setting; const char *addr = NULL; setting = nm_connection_get_setting(connection, @@ -2124,7 +2124,7 @@ _prop_get_x_cloned_mac_address(NMDevice *self, NMConnection *connection, gboolea static const char * _prop_get_x_generate_mac_address_mask(NMDevice *self, NMConnection *connection, gboolean is_wifi) { - NMSetting * setting; + NMSetting *setting; const char *value; setting = nm_connection_get_setting(connection, @@ -2165,9 +2165,9 @@ _ethtool_features_reset(NMDevice *self, NMPlatform *platform, EthtoolState *etht } static void -_ethtool_features_set(NMDevice * self, - NMPlatform * platform, - EthtoolState * ethtool_state, +_ethtool_features_set(NMDevice *self, + NMPlatform *platform, + EthtoolState *ethtool_state, NMSettingEthtool *s_ethtool) { gs_free NMEthtoolFeatureStates *features = NULL; @@ -2216,18 +2216,18 @@ _ethtool_coalesce_reset(NMDevice *self, NMPlatform *platform, EthtoolState *etht } static void -_ethtool_coalesce_set(NMDevice * self, - NMPlatform * platform, - EthtoolState * ethtool_state, +_ethtool_coalesce_set(NMDevice *self, + NMPlatform *platform, + EthtoolState *ethtool_state, NMSettingEthtool *s_ethtool) { NMEthtoolCoalesceState coalesce_old; NMEthtoolCoalesceState coalesce_new; gboolean has_old = FALSE; - GHashTable * hash; + GHashTable *hash; GHashTableIter iter; - const char * name; - GVariant * variant; + const char *name; + GVariant *variant; nm_assert(NM_IS_DEVICE(self)); nm_assert(NM_IS_PLATFORM(platform)); @@ -2294,17 +2294,17 @@ _ethtool_ring_reset(NMDevice *self, NMPlatform *platform, EthtoolState *ethtool_ } static void -_ethtool_ring_set(NMDevice * self, - NMPlatform * platform, - EthtoolState * ethtool_state, +_ethtool_ring_set(NMDevice *self, + NMPlatform *platform, + EthtoolState *ethtool_state, NMSettingEthtool *s_ethtool) { NMEthtoolRingState ring_old; NMEthtoolRingState ring_new; - GHashTable * hash; + GHashTable *hash; GHashTableIter iter; - const char * name; - GVariant * variant; + const char *name; + GVariant *variant; gboolean has_old = FALSE; nm_assert(NM_IS_DEVICE(self)); @@ -2390,17 +2390,17 @@ _ethtool_pause_reset(NMDevice *self, NMPlatform *platform, EthtoolState *ethtool } static void -_ethtool_pause_set(NMDevice * self, - NMPlatform * platform, - EthtoolState * ethtool_state, +_ethtool_pause_set(NMDevice *self, + NMPlatform *platform, + EthtoolState *ethtool_state, NMSettingEthtool *s_ethtool) { NMEthtoolPauseState pause_old; NMEthtoolPauseState pause_new; - GHashTable * hash; + GHashTable *hash; GHashTableIter iter; - const char * name; - GVariant * variant; + const char *name; + GVariant *variant; gboolean has_old = FALSE; NMTernary pause_autoneg = NM_TERNARY_DEFAULT; NMTernary pause_rx = NM_TERNARY_DEFAULT; @@ -2480,8 +2480,8 @@ _ethtool_pause_set(NMDevice * self, static void _ethtool_state_reset(NMDevice *self) { - NMPlatform * platform = nm_device_get_platform(self); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMPlatform *platform = nm_device_get_platform(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gs_free EthtoolState *ethtool_state = g_steal_pointer(&priv->ethtool_state); if (!ethtool_state) @@ -2500,12 +2500,12 @@ _ethtool_state_reset(NMDevice *self) static void _ethtool_state_set(NMDevice *self) { - int ifindex; - NMPlatform * platform; - NMConnection * connection; - NMSettingEthtool *s_ethtool; + int ifindex; + NMPlatform *platform; + NMConnection *connection; + NMSettingEthtool *s_ethtool; gs_free EthtoolState *ethtool_state = NULL; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); ifindex = nm_device_get_ip_ifindex(self); if (ifindex <= 0) @@ -2692,7 +2692,7 @@ nm_device_sys_iface_state_set(NMDevice *self, NMDeviceSysIfaceState sys_iface_st } static void -_active_connection_set_state_flags_full(NMDevice * self, +_active_connection_set_state_flags_full(NMDevice *self, NMActivationStateFlags flags, NMActivationStateFlags mask) { @@ -2712,12 +2712,12 @@ _active_connection_set_state_flags(NMDevice *self, NMActivationStateFlags flags) /*****************************************************************************/ static gboolean -set_interface_flags_full(NMDevice * self, +set_interface_flags_full(NMDevice *self, NMDeviceInterfaceFlags mask, NMDeviceInterfaceFlags interface_flags, gboolean notify) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceInterfaceFlags f; nm_assert(!!mask); @@ -2736,7 +2736,7 @@ set_interface_flags_full(NMDevice * self, } static gboolean -set_interface_flags(NMDevice * self, +set_interface_flags(NMDevice *self, NMDeviceInterfaceFlags interface_flags, gboolean set, gboolean notify) @@ -2748,8 +2748,8 @@ set_interface_flags(NMDevice * self, } void -nm_device_assume_state_get(NMDevice * self, - gboolean * out_assume_state_guess_assume, +nm_device_assume_state_get(NMDevice *self, + gboolean *out_assume_state_guess_assume, const char **out_assume_state_connection_uuid) { NMDevicePrivate *priv; @@ -2762,7 +2762,7 @@ nm_device_assume_state_get(NMDevice * self, } static void -_assume_state_set(NMDevice * self, +_assume_state_set(NMDevice *self, gboolean assume_state_guess_assume, const char *assume_state_connection_uuid) { @@ -2811,7 +2811,7 @@ nm_device_sysctl_ip_conf_get(NMDevice *self, int addr_family, const char *proper } static gint64 -nm_device_sysctl_ip_conf_get_int_checked(NMDevice * self, +nm_device_sysctl_ip_conf_get_int_checked(NMDevice *self, int addr_family, const char *property, guint base, @@ -2839,14 +2839,14 @@ nm_device_sysctl_ip_conf_get_int_checked(NMDevice * self, } gboolean -nm_device_sysctl_ip_conf_set(NMDevice * self, +nm_device_sysctl_ip_conf_set(NMDevice *self, int addr_family, const char *property, const char *value) { - NMPlatform * platform = nm_device_get_platform(self); + NMPlatform *platform = nm_device_get_platform(self); gs_free char *value_to_free = NULL; - const char * ifname; + const char *ifname; nm_assert_addr_family(addr_family); @@ -2955,10 +2955,10 @@ _dev_ip_state_req_timeout_schedule(NMDevice *self, int addr_family) } static gboolean -_dev_ip_state_set_state(NMDevice * self, +_dev_ip_state_set_state(NMDevice *self, int addr_family, NMDeviceIPState ip_state, - const char * reason) + const char *reason) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); int IS_IPv4; @@ -2991,9 +2991,9 @@ _dev_ip_state_set_state(NMDevice * self, static void _device_ip_state_accumulate(NMDeviceIPState state, - gboolean * out_is_started, - gboolean * out_is_pending, - gboolean * out_is_failed) + gboolean *out_is_started, + gboolean *out_is_pending, + gboolean *out_is_failed) { switch (state) { case NM_DEVICE_IP_STATE_NONE: @@ -3167,7 +3167,7 @@ got_ip_state: #define _state_str_a(state, name) \ ({ \ const NMDeviceIPState _state = (state); \ - char * _s = ""; \ + char *_s = ""; \ \ if (_state != NM_DEVICE_IP_STATE_NONE) { \ _s = nm_sprintf_bufa(NM_STRLEN(name) + 11, \ @@ -3411,7 +3411,7 @@ _dev_l3_config_data_tag_to_type(NMDevice *self, gconstpointer tag) } static L3ConfigDataType -_dev_l3_config_data_acd_addr_info_to_type(NMDevice * self, +_dev_l3_config_data_acd_addr_info_to_type(NMDevice *self, const NML3AcdAddrInfo *addr_info, guint i_track_infos) { @@ -3424,7 +3424,7 @@ _dev_l3_config_data_acd_addr_info_to_type(NMDevice * self, // FIXME(l3cfg): unused function?? _nm_unused static const NML3AcdAddrTrackInfo * -_dev_l3_config_data_acd_addr_info_has_by_type(NMDevice * self, +_dev_l3_config_data_acd_addr_info_has_by_type(NMDevice *self, const NML3AcdAddrInfo *addr_info, L3ConfigDataType l3cd_type) { @@ -3442,16 +3442,16 @@ _dev_l3_config_data_acd_addr_info_has_by_type(NMDevice * self, } static void -_dev_l3_get_config_settings(NMDevice * self, +_dev_l3_get_config_settings(NMDevice *self, L3ConfigDataType type, NML3ConfigMergeFlags *out_merge_flags, - NML3AcdDefendType * out_acd_defend_type, - guint32 * out_acd_timeout_msec) + NML3AcdDefendType *out_acd_defend_type, + guint32 *out_acd_timeout_msec) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NML3ConfigMergeFlags flags; - NMConnection * connection; - NMSettingIPConfig * s_ip; + NMConnection *connection; + NMSettingIPConfig *s_ip; nm_assert(_NM_INT_NOT_NEGATIVE(type) && type < _L3_CONFIG_DATA_TYPE_NUM); @@ -3572,11 +3572,11 @@ after_merge_flags: } static gboolean -_dev_l3_register_l3cds_add_config(NMDevice * self, +_dev_l3_register_l3cds_add_config(NMDevice *self, L3ConfigDataType l3cd_type, NML3CfgConfigFlags flags) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NML3ConfigMergeFlags merge_flags; NML3AcdDefendType acd_defend_type; guint32 acd_timeout_msec; @@ -3602,13 +3602,13 @@ _dev_l3_register_l3cds_add_config(NMDevice * self, } static gboolean -_dev_l3_register_l3cds_set_one_full(NMDevice * self, +_dev_l3_register_l3cds_set_one_full(NMDevice *self, L3ConfigDataType l3cd_type, const NML3ConfigData *l3cd, NML3CfgConfigFlags flags, NMTernary commit_sync) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; gboolean changed = FALSE; @@ -3648,7 +3648,7 @@ _dev_l3_register_l3cds_set_one_full(NMDevice * self, } static gboolean -_dev_l3_register_l3cds_set_one(NMDevice * self, +_dev_l3_register_l3cds_set_one(NMDevice *self, L3ConfigDataType l3cd_type, const NML3ConfigData *l3cd, NMTernary commit_sync) @@ -3685,7 +3685,7 @@ _dev_l3_update_l3cds_ifindex(NMDevice *self) static gboolean _dev_l3_register_l3cds(NMDevice *self, - NML3Cfg * l3cfg, + NML3Cfg *l3cfg, gboolean do_add /* else remove */, NMTernary do_commit) { @@ -3758,14 +3758,14 @@ _dev_l3_cfg_commit(NMDevice *self, gboolean commit_sync) static void update_external_connection(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMSettingsConnection *settings_connection; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMSettingsConnection *settings_connection; gs_unref_object NMConnection *connection_new = NULL; - NMConnection * connection_old; - gs_unref_object NMSetting *s_ip4_new = NULL; - gs_unref_object NMSetting *s_ip6_new = NULL; - NMSetting * s_ip4_old; - NMSetting * s_ip6_old; + NMConnection *connection_old; + gs_unref_object NMSetting *s_ip4_new = NULL; + gs_unref_object NMSetting *s_ip6_new = NULL; + NMSetting *s_ip4_old; + NMSetting *s_ip6_old; /* Update external connections with configuration from platform */ @@ -3916,7 +3916,7 @@ _dev_l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, N static void _dev_l3_cfg_commit_type_reset(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NML3CfgCommitType commit_type; if (!priv->l3cfg) @@ -3965,12 +3965,12 @@ nm_device_get_iface(NMDevice *self) static gboolean _set_ifindex(NMDevice *self, int ifindex, gboolean is_ip_ifindex) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gs_unref_object NML3Cfg *l3cfg_old = NULL; NML3CfgCommitTypeHandle *l3cfg_commit_type_old = NULL; gboolean l3_changed; int ip_ifindex_new; - int * p_ifindex; + int *p_ifindex; gboolean l3cfg_was_reset = FALSE; if (ifindex < 0) { @@ -4101,9 +4101,9 @@ _set_ifindex(NMDevice *self, int ifindex, gboolean is_ip_ifindex) gboolean nm_device_take_over_link(NMDevice *self, int ifindex, char **old_name, GError **error) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const NMPlatformLink *plink; - NMPlatform * platform; + NMPlatform *platform; nm_assert(ifindex > 0); NM_SET_OUT(old_name, NULL); @@ -4228,7 +4228,7 @@ static void _set_ip_ifindex(NMDevice *self, int ifindex, const char *ifname) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMPlatform * platform; + NMPlatform *platform; gboolean eq_name; /* normalize arguments */ @@ -4352,10 +4352,10 @@ parent_changed_notify(NMDevice *self, static gboolean _parent_set_ifindex(NMDevice *self, int parent_ifindex, gboolean force_check) { - NMDevicePrivate *priv; - NMDevice * parent_device; - gboolean changed = FALSE; - int old_ifindex; + NMDevicePrivate *priv; + NMDevice *parent_device; + gboolean changed = FALSE; + int old_ifindex; gs_unref_object NMDevice *old_device = NULL; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); @@ -4446,7 +4446,7 @@ const char * nm_device_parent_find_for_connection(NMDevice *self, const char *current_setting_parent) { const char *new_parent; - NMDevice * parent_device; + NMDevice *parent_device; parent_device = nm_device_parent_get_device(self); if (!parent_device) @@ -4583,10 +4583,10 @@ _stats_set_refresh_rate(NMDevice *self, guint refresh_rate_ms) static gboolean get_ip_iface_identifier(NMDevice *self, NMUtilsIPv6IfaceId *out_iid) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMPlatform * platform = nm_device_get_platform(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMPlatform *platform = nm_device_get_platform(self); const NMPlatformLink *pllink; - const guint8 * hwaddr; + const guint8 *hwaddr; guint8 pseudo_hwaddr[ETH_ALEN]; gsize hwaddr_len; int ifindex; @@ -4659,13 +4659,13 @@ get_ip_iface_identifier(NMDevice *self, NMUtilsIPv6IfaceId *out_iid) * Returns: #TRUE if the @iid could be set */ static gboolean -nm_device_get_ip_iface_identifier(NMDevice * self, +nm_device_get_ip_iface_identifier(NMDevice *self, NMUtilsIPv6IfaceId *iid, gboolean ignore_token, - gboolean * out_is_token) + gboolean *out_is_token) { NMSettingIP6Config *s_ip6; - const char * token = NULL; + const char *token = NULL; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); @@ -4842,8 +4842,8 @@ nm_device_get_route_metric(NMDevice *self, int addr_family) { gint64 route_metric; NMSettingIPConfig *s_ip; - NMConnection * connection; - const char * property; + NMConnection *connection; + const char *property; g_return_val_if_fail(NM_IS_DEVICE(self), G_MAXUINT32); g_return_val_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6), G_MAXUINT32); @@ -5061,7 +5061,7 @@ NMConnection * nm_device_get_settings_connection_get_connection(NMDevice *self) { NMSettingsConnection *sett_con; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); if (!priv->act_request.obj) return NULL; @@ -5134,7 +5134,7 @@ typedef enum { CONCHECK_SCHEDULE_RETURNED_MAX, } ConcheckScheduleMode; -static NMDeviceConnectivityHandle *concheck_start(NMDevice * self, +static NMDeviceConnectivityHandle *concheck_start(NMDevice *self, int addr_family, NMDeviceConnectivityCallback callback, gpointer user_data, @@ -5440,7 +5440,7 @@ nm_device_check_connectivity_update_interval(NMDevice *self) } static void -concheck_update_state(NMDevice * self, +concheck_update_state(NMDevice *self, int addr_family, NMConnectivityState state, gboolean allow_periodic_bump) @@ -5519,8 +5519,8 @@ static const char * nm_device_get_effective_ip_config_method(NMDevice *self, int addr_family) { NMDeviceClass *klass; - NMConnection * connection = nm_device_get_applied_connection(self); - const char * method; + NMConnection *connection = nm_device_get_applied_connection(self); + const char *method; const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_val_if_fail(NM_IS_CONNECTION(connection), "" /* bogus */); @@ -5567,16 +5567,16 @@ concheck_handle_complete(NMDeviceConnectivityHandle *handle, GError *error) } static void -concheck_cb(NMConnectivity * connectivity, +concheck_cb(NMConnectivity *connectivity, NMConnectivityCheckHandle *c_handle, NMConnectivityState state, gpointer user_data) { _nm_unused gs_unref_object NMDevice *self_keep_alive = NULL; - NMDevice * self; - NMDevicePrivate * priv; - NMDeviceConnectivityHandle * handle; - NMDeviceConnectivityHandle * other_handle; + NMDevice *self; + NMDevicePrivate *priv; + NMDeviceConnectivityHandle *handle; + NMDeviceConnectivityHandle *other_handle; gboolean handle_is_alive; gboolean allow_periodic_bump; gboolean any_periodic_before; @@ -5700,16 +5700,16 @@ check_handles: } static NMDeviceConnectivityHandle * -concheck_start(NMDevice * self, +concheck_start(NMDevice *self, int addr_family, NMDeviceConnectivityCallback callback, gpointer user_data, gboolean is_periodic) { static guint64 seq_counter = 0; - NMDevicePrivate * priv; + NMDevicePrivate *priv; NMDeviceConnectivityHandle *handle; - const char * ifname; + const char *ifname; g_return_val_if_fail(NM_IS_DEVICE(self), NULL); @@ -5765,7 +5765,7 @@ concheck_start(NMDevice * self, } NMDeviceConnectivityHandle * -nm_device_check_connectivity(NMDevice * self, +nm_device_check_connectivity(NMDevice *self, int addr_family, NMDeviceConnectivityCallback callback, gpointer user_data) @@ -5821,8 +5821,8 @@ static SlaveInfo * find_slave_info(NMDevice *self, NMDevice *slave) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - CList * iter; - SlaveInfo * info; + CList *iter; + SlaveInfo *info; c_list_for_each (iter, &priv->slaves) { info = c_list_entry(iter, SlaveInfo, lst_slave); @@ -5906,15 +5906,15 @@ nm_device_master_enslave_slave(NMDevice *self, NMDevice *slave, NMConnection *co * updates the state of @self and @slave to reflect its release. */ static void -nm_device_master_release_one_slave(NMDevice * self, - NMDevice * slave, +nm_device_master_release_one_slave(NMDevice *self, + NMDevice *slave, gboolean configure, gboolean force, NMDeviceStateReason reason) { - NMDevicePrivate *priv; - NMDevicePrivate *slave_priv; - SlaveInfo * info; + NMDevicePrivate *priv; + NMDevicePrivate *slave_priv; + SlaveInfo *info; gs_unref_object NMDevice *self_free = NULL; g_return_if_fail(NM_DEVICE(self)); @@ -6137,7 +6137,7 @@ carrier_changed(NMDevice *self, gboolean carrier) static gboolean carrier_disconnected_action_cb(gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); + NMDevice *self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); _LOGD(LOGD_DEVICE, @@ -6239,10 +6239,10 @@ nm_device_set_carrier_from_platform(NMDevice *self) static void device_recheck_slave_status(NMDevice *self, const NMPlatformLink *plink) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMDevice * master; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDevice *master; nm_auto_nmpobj const NMPObject *plink_master_keep_alive = NULL; - const NMPlatformLink * plink_master; + const NMPlatformLink *plink_master; g_return_if_fail(plink); @@ -6322,7 +6322,7 @@ device_ifindex_changed_cb(NMManager *manager, NMDevice *device_changed, NMDevice static void device_update_interface_flags(NMDevice *self, const NMPlatformLink *plink) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceInterfaceFlags flags = NM_DEVICE_INTERFACE_FLAG_NONE; if (plink && NM_FLAGS_HAS(plink->n_ifi_flags, IFF_UP)) @@ -6352,13 +6352,13 @@ device_update_interface_flags(NMDevice *self, const NMPlatformLink *plink) static gboolean device_link_changed(gpointer user_data) { - NMDevice * self = user_data; - NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - gboolean ip_ifname_changed = FALSE; + NMDevice *self = user_data; + NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gboolean ip_ifname_changed = FALSE; nm_auto_nmpobj const NMPObject *pllink_keep_alive = NULL; - const NMPlatformLink * pllink; - const char * str; + const NMPlatformLink *pllink; + const char *str; int ifindex; gboolean was_up; gboolean update_unmanaged_specs = FALSE; @@ -6524,10 +6524,10 @@ device_link_changed(gpointer user_data) static gboolean device_ip_link_changed(gpointer user_data) { - NMDevice * self = user_data; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevice *self = user_data; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const NMPlatformLink *pllink; - const char * ip_iface; + const char *ip_iface; priv->device_ip_link_changed_id = 0; @@ -6568,15 +6568,15 @@ device_ip_link_changed(gpointer user_data) } static void -link_changed_cb(NMPlatform * platform, +link_changed_cb(NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *info, int change_type_i, - NMDevice * self) + NMDevice *self) { const NMPlatformSignalChangeType change_type = change_type_i; - NMDevicePrivate * priv; + NMDevicePrivate *priv; if (change_type != NM_PLATFORM_SIGNAL_CHANGED) return; @@ -6675,14 +6675,14 @@ link_type_compatible(NMDevice *self, NMLinkType link_type, gboolean *out_compati * Returns: %TRUE on success, %FALSE on error */ gboolean -nm_device_realize_start(NMDevice * self, +nm_device_realize_start(NMDevice *self, const NMPlatformLink *plink, gboolean assume_state_guess_assume, - const char * assume_state_connection_uuid, + const char *assume_state_connection_uuid, gboolean set_nm_owned, NMUnmanFlagOp unmanaged_user_explicit, - gboolean * out_compatible, - GError ** error) + gboolean *out_compatible, + GError **error) { nm_auto_nmpobj const NMPObject *plink_keep_alive = NULL; @@ -6729,14 +6729,14 @@ nm_device_realize_start(NMDevice * self, * Returns: %TRUE on success, %FALSE on error */ gboolean -nm_device_create_and_realize(NMDevice * self, +nm_device_create_and_realize(NMDevice *self, NMConnection *connection, - NMDevice * parent, - GError ** error) + NMDevice *parent, + GError **error) { nm_auto_nmpobj const NMPObject *plink_keep_alive = NULL; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - const NMPlatformLink * plink; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const NMPlatformLink *plink; gboolean nm_owned; /* Must be set before device is realized */ @@ -6784,7 +6784,7 @@ void nm_device_update_from_platform_link(NMDevice *self, const NMPlatformLink *plink) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const char * str; + const char *str; gboolean ifindex_changed; guint32 mtu; @@ -6861,9 +6861,9 @@ sriov_op_start(NMDevice *self, SriovOp *op) static void sriov_op_cb(GError *error, gpointer user_data) { - SriovOp * op = user_data; + SriovOp *op = user_data; gs_unref_object NMDevice *self = op->device; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); nm_assert(op == priv->sriov.pending); @@ -6913,7 +6913,7 @@ sriov_op_queue_op(NMDevice *self, SriovOp *op) } static void -sriov_op_queue(NMDevice * self, +sriov_op_queue(NMDevice *self, guint num_vfs, NMOptionBool autoprobe, NMPlatformAsyncCallback callback, @@ -6972,11 +6972,11 @@ device_init_static_sriov_num_vfs(NMDevice *self) } static void -config_changed(NMConfig * config, - NMConfigData * config_data, +config_changed(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, - NMDevice * self) + NMConfigData *old_data, + NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); @@ -7015,19 +7015,19 @@ realize_start_notify(NMDevice *self, const NMPlatformLink *pllink) * stuff). */ static void -realize_start_setup(NMDevice * self, +realize_start_setup(NMDevice *self, const NMPlatformLink *plink, gboolean assume_state_guess_assume, - const char * assume_state_connection_uuid, + const char *assume_state_connection_uuid, gboolean set_nm_owned, NMUnmanFlagOp unmanaged_user_explicit, gboolean force_platform_init) { - NMDevicePrivate * priv; - NMDeviceClass * klass; - NMPlatform * platform; + NMDevicePrivate *priv; + NMDeviceClass *klass; + NMPlatform *platform; NMDeviceCapabilities capabilities = 0; - NMConfig * config; + NMConfig *config; guint refresh_rate_ms; gboolean unmanaged; @@ -7206,7 +7206,7 @@ unrealize_notify(NMDevice *self) static gboolean available_connections_check_delete_unrealized_on_idle(gpointer user_data) { - NMDevice * self = user_data; + NMDevice *self = user_data; NMDevicePrivate *priv; g_return_val_if_fail(NM_IS_DEVICE(self), G_SOURCE_REMOVE); @@ -7405,7 +7405,7 @@ NMConnection * nm_device_new_default_connection(NMDevice *self) { NMConnection *connection; - GError * error = NULL; + GError *error = NULL; if (!NM_DEVICE_GET_CLASS(self)->new_default_connection) return NULL; @@ -7424,11 +7424,11 @@ nm_device_new_default_connection(NMDevice *self) } static void -slave_state_changed(NMDevice * slave, +slave_state_changed(NMDevice *slave, NMDeviceState slave_new_state, NMDeviceState slave_old_state, NMDeviceStateReason reason, - NMDevice * self) + NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean release = FALSE; @@ -7485,7 +7485,7 @@ nm_device_master_add_slave(NMDevice *self, NMDevice *slave, gboolean configure) { NMDevicePrivate *priv; NMDevicePrivate *slave_priv; - SlaveInfo * info; + SlaveInfo *info; gboolean changed = FALSE; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); @@ -7555,9 +7555,9 @@ void nm_device_master_check_slave_physical_port(NMDevice *self, NMDevice *slave, NMLogDomain log_domain) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const char * slave_physical_port_id, *existing_physical_port_id; - SlaveInfo * info; - CList * iter; + const char *slave_physical_port_id, *existing_physical_port_id; + SlaveInfo *info; + CList *iter; slave_physical_port_id = nm_device_get_physical_port_id(slave); if (!slave_physical_port_id) @@ -7588,9 +7588,9 @@ nm_device_master_check_slave_physical_port(NMDevice *self, NMDevice *slave, NMLo void nm_device_master_release_slaves(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceStateReason reason; - CList * iter, *safe; + CList *iter, *safe; /* Don't release the slaves if this connection doesn't belong to NM. */ if (nm_device_sys_iface_state_is_external(self)) @@ -7656,7 +7656,7 @@ static void nm_device_slave_notify_enslave(NMDevice *self, gboolean success) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection = nm_device_get_applied_connection(self); + NMConnection *connection = nm_device_get_applied_connection(self); gboolean activating = (priv->state == NM_DEVICE_STATE_IP_CONFIG); g_return_if_fail(priv->master); @@ -7707,8 +7707,8 @@ static void nm_device_slave_notify_release(NMDevice *self, NMDeviceStateReason reason) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection = nm_device_get_applied_connection(self); - const char * master_status; + NMConnection *connection = nm_device_get_applied_connection(self); + const char *master_status; g_return_if_fail(priv->master); @@ -7882,7 +7882,7 @@ nm_device_autoconnect_blocked_get(NMDevice *self, NMDeviceAutoconnectBlockedFlag } void -nm_device_autoconnect_blocked_set_full(NMDevice * self, +nm_device_autoconnect_blocked_set_full(NMDevice *self, NMDeviceAutoconnectBlockedFlags mask, NMDeviceAutoconnectBlockedFlags value) { @@ -7917,8 +7917,8 @@ nm_device_autoconnect_blocked_set_full(NMDevice * self, static gboolean autoconnect_allowed_accumulator(GSignalInvocationHint *ihint, - GValue * return_accu, - const GValue * handler_return, + GValue *return_accu, + const GValue *handler_return, gpointer data) { if (!g_value_get_boolean(handler_return)) @@ -7938,7 +7938,7 @@ gboolean nm_device_autoconnect_allowed(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); + NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self); GValue instance = G_VALUE_INIT; GValue retval = G_VALUE_INIT; @@ -8039,9 +8039,9 @@ nm_device_can_auto_connect(NMDevice *self, NMSettingsConnection *sett_conn, char static gboolean device_has_config(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const NMDedupMultiHeadEntry *head_entry; - const NMPlatformLink * pllink; + const NMPlatformLink *pllink; NMPLookup lookup; pllink = nm_l3cfg_get_pllink(priv->l3cfg, TRUE); @@ -8087,10 +8087,10 @@ device_has_config(NMDevice *self) * %FALSE on failure. */ gboolean -nm_device_master_update_slave_connection(NMDevice * self, - NMDevice * slave, +nm_device_master_update_slave_connection(NMDevice *self, + NMDevice *slave, NMConnection *connection, - GError ** error) + GError **error) { NMDeviceClass *klass; gboolean success; @@ -8156,19 +8156,19 @@ NMConnection * nm_device_generate_connection(NMDevice *self, NMDevice *master, gboolean *out_maybe_later, - GError ** error) + GError **error) { - NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const char * ifname = nm_device_get_iface(self); + NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const char *ifname = nm_device_get_iface(self); gs_unref_object NMConnection *connection = NULL; - NMSetting * s_con; - NMSetting * s_ip4; - NMSetting * s_ip6; + NMSetting *s_con; + NMSetting *s_ip4; + NMSetting *s_ip6; char uuid[37]; - const char * ip4_method, *ip6_method; - GError * local = NULL; - const NMPlatformLink * pllink; + const char *ip4_method, *ip6_method; + GError *local = NULL; + const NMPlatformLink *pllink; NM_SET_OUT(out_maybe_later, FALSE); @@ -8318,11 +8318,11 @@ nm_device_generate_connection(NMDevice *self, * Returns: success or failure. */ gboolean -nm_device_complete_connection(NMDevice * self, - NMConnection * connection, - const char * specific_object, +nm_device_complete_connection(NMDevice *self, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMDeviceClass *klass; @@ -8380,14 +8380,14 @@ nm_device_match_parent(NMDevice *self, const char *parent) } gboolean -nm_device_match_parent_hwaddr(NMDevice * device, +nm_device_match_parent_hwaddr(NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr) { NMSettingWired *s_wired; - NMDevice * parent_device; - const char * setting_mac; - const char * parent_mac; + NMDevice *parent_device; + const char *setting_mac; + const char *parent_mac; s_wired = nm_connection_get_setting_wired(connection); if (!s_wired) @@ -8408,13 +8408,13 @@ nm_device_match_parent_hwaddr(NMDevice * device, static gboolean check_connection_compatible(NMDevice *self, NMConnection *connection, GError **error) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const char * device_iface = nm_device_get_iface(self); - gs_free_error GError *local = NULL; - gs_free char * conn_iface = NULL; - NMDeviceClass * klass; - NMSettingMatch * s_match; - const GSList * specs; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const char *device_iface = nm_device_get_iface(self); + gs_free_error GError *local = NULL; + gs_free char *conn_iface = NULL; + NMDeviceClass *klass; + NMSettingMatch *s_match; + const GSList *specs; gboolean has_match = FALSE; klass = NM_DEVICE_GET_CLASS(self); @@ -8537,7 +8537,7 @@ gboolean nm_device_check_slave_connection_compatible(NMDevice *self, NMConnection *slave) { NMSettingConnection *s_con; - const char * connection_type, *slave_type; + const char *connection_type, *slave_type; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); g_return_val_if_fail(NM_IS_CONNECTION(slave), FALSE); @@ -8615,7 +8615,7 @@ nm_device_unmanage_on_quit(NMDevice *self) static gboolean nm_device_emit_recheck_assume(gpointer user_data) { - NMDevice * self = user_data; + NMDevice *self = user_data; NMDevicePrivate *priv; g_return_val_if_fail(NM_IS_DEVICE(self), G_SOURCE_REMOVE); @@ -8641,7 +8641,7 @@ nm_device_queue_recheck_assume(NMDevice *self) static gboolean recheck_available(gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); + NMDevice *self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean now_available; NMDeviceState state = nm_device_get_state(self); @@ -8679,7 +8679,7 @@ recheck_available(gpointer user_data) } void -nm_device_queue_recheck_available(NMDevice * self, +nm_device_queue_recheck_available(NMDevice *self, NMDeviceStateReason available_reason, NMDeviceStateReason unavailable_reason) { @@ -8702,12 +8702,12 @@ nm_device_emit_recheck_auto_activate(NMDevice *self) } void -nm_device_auth_request(NMDevice * self, - GDBusMethodInvocation * context, - NMConnection * connection, - const char * permission, +nm_device_auth_request(NMDevice *self, + GDBusMethodInvocation *context, + NMConnection *connection, + const char *permission, gboolean allow_interaction, - GCancellable * cancellable, + GCancellable *cancellable, NMManagerDeviceAuthRequestFunc callback, gpointer user_data) { @@ -8740,8 +8740,8 @@ activation_source_clear(NMDevice *self) static gboolean activation_source_handle_cb(gpointer user_data) { - NMDevice * self = user_data; - NMDevicePrivate * priv; + NMDevice *self = user_data; + NMDevicePrivate *priv; ActivationHandleFunc activation_func; g_return_val_if_fail(NM_IS_DEVICE(self), G_SOURCE_REMOVE); @@ -8836,9 +8836,9 @@ activation_source_invoke_or_schedule(NMDevice *self, ActivationHandleFunc func, static void master_ready(NMDevice *self, NMActiveConnection *active) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMActiveConnection *master_connection; - NMDevice * master; + NMDevice *master; /* Notify a master device that it has a new slave */ nm_assert(nm_active_connection_get_master_ready(active)); @@ -8876,10 +8876,10 @@ master_ready_cb(NMActiveConnection *active, GParamSpec *pspec, NMDevice *self) static NMPlatformVF * sriov_vf_config_to_platform(NMDevice *self, NMSriovVF *vf, GError **error) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gs_free NMPlatformVF *plat_vf = NULL; - const guint * vlan_ids; - GVariant * variant; + const guint *vlan_ids; + GVariant *variant; guint i, num_vlans; gsize length; @@ -8950,8 +8950,8 @@ sriov_vf_config_to_platform(NMDevice *self, NMSriovVF *vf, GError **error) static void sriov_params_cb(GError *error, gpointer user_data) { - NMDevice * self; - NMDevicePrivate *priv; + NMDevice *self; + NMDevicePrivate *priv; nm_auto_freev NMPlatformVF **plat_vfs = NULL; nm_utils_user_data_unpack(user_data, &self, &plat_vfs); @@ -8993,11 +8993,11 @@ sriov_params_cb(GError *error, gpointer user_data) static void activate_stage1_device_prepare(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMActiveConnection *active; NMActiveConnection *master; - NMDeviceClass * klass; + NMDeviceClass *klass; nm_assert((priv->ip_data_4.state == NM_DEVICE_IP_STATE_NONE) == (priv->ip_data_6.state == NM_DEVICE_IP_STATE_NONE)); @@ -9026,11 +9026,11 @@ activate_stage1_device_prepare(NMDevice *self) else if (priv->ifindex > 0 && nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV) && (s_sriov = nm_device_get_applied_setting(self, NM_TYPE_SETTING_SRIOV))) { nm_auto_freev NMPlatformVF **plat_vfs = NULL; - gs_free_error GError *error = NULL; - NMSriovVF * vf; - NMTernary autoprobe; - guint num; - guint i; + gs_free_error GError *error = NULL; + NMSriovVF *vf; + NMTernary autoprobe; + guint num; + guint i; autoprobe = nm_setting_sriov_get_autoprobe_drivers(s_sriov); if (autoprobe == NM_TERNARY_DEFAULT) { @@ -9227,7 +9227,7 @@ _routing_rules_sync(NMDevice *self, NMTernary set_mode) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMPRulesManager *rules_manager = nm_netns_get_rules_manager(nm_device_get_netns(self)); - NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); + NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self); gboolean untrack_only_dirty = FALSE; gboolean keep_deleted_rules; gpointer user_tag_1; @@ -9238,7 +9238,7 @@ _routing_rules_sync(NMDevice *self, NMTernary set_mode) user_tag_2 = &priv->v6_route_table; if (set_mode == NM_TERNARY_TRUE) { - NMConnection * applied_connection; + NMConnection *applied_connection; NMSettingIPConfig *s_ip; guint i, num; int is_ipv4; @@ -9260,7 +9260,7 @@ _routing_rules_sync(NMDevice *self, NMTernary set_mode) num = nm_setting_ip_config_get_num_routing_rules(s_ip); for (i = 0; i < num; i++) { NMPlatformRoutingRule plrule; - NMIPRoutingRule * rule; + NMIPRoutingRule *rule; rule = nm_setting_ip_config_get_routing_rule(s_ip, i); nm_ip_routing_rule_to_platform(rule, &plrule); @@ -9321,8 +9321,8 @@ tc_commit(NMDevice *self) { gs_unref_ptrarray GPtrArray *qdiscs = NULL; gs_unref_ptrarray GPtrArray *tfilters = NULL; - NMSettingTCConfig * s_tc; - NMPlatform * platform; + NMSettingTCConfig *s_tc; + NMPlatform *platform; int ip_ifindex; s_tc = nm_device_get_applied_setting(self, NM_TYPE_SETTING_TC_CONFIG); @@ -9354,11 +9354,11 @@ static void activate_stage2_device_config(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMDeviceClass * klass; + NMDeviceClass *klass; NMActStageReturn ret; - NMSettingWired * s_wired; + NMSettingWired *s_wired; gboolean no_firmware = FALSE; - CList * iter; + CList *iter; NMTernary accept_all_mac_addresses; nm_device_state_changed(self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE); @@ -9406,7 +9406,7 @@ activate_stage2_device_config(NMDevice *self) /* If we have slaves that aren't yet enslaved, do that now */ c_list_for_each (iter, &priv->slaves) { - SlaveInfo * info = c_list_entry(iter, SlaveInfo, lst_slave); + SlaveInfo *info = c_list_entry(iter, SlaveInfo, lst_slave); NMDeviceState slave_state = nm_device_get_state(info->slave); if (slave_state == NM_DEVICE_STATE_IP_CONFIG) @@ -9500,7 +9500,7 @@ _dev_ipllx_cleanup(NMDevice *self, int addr_family) static void _dev_ipll4_notify_event(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NML3IPv4LLState ipv4ll_state; const NML3ConfigData *l3cd; NMDeviceIPState state; @@ -9613,14 +9613,14 @@ nm_device_devip_get_state(NMDevice *self, int addr_family) } void -nm_device_devip_set_state_full(NMDevice * self, +nm_device_devip_set_state_full(NMDevice *self, int addr_family, NMDeviceIPState ip_state, const NML3ConfigData *l3cd, NMDeviceStateReason failed_reason) { NMDevicePrivate *priv; - IPDevStateData * p; + IPDevStateData *p; g_return_if_fail(NM_IS_DEVICE(self)); @@ -9716,8 +9716,8 @@ _dev_ipmanual_carrier_timeout(NMDevice *self) static void _dev_ipmanual_check_ready(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - const NMPlatformLink * plink; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const NMPlatformLink *plink; gboolean has_carrier; NML3CfgCheckReadyFlags flags; gboolean ready; @@ -9778,7 +9778,7 @@ _dev_ipmanual_check_ready(NMDevice *self) static void _dev_ipmanual_start(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; if (priv->ipmanual_data.state_4 != NM_DEVICE_IP_STATE_NONE @@ -9879,9 +9879,9 @@ _dev_ipdhcpx_handle_fail(NMDevice *self, int addr_family, const char *reason) static void _dev_ipdhcpx_handle_accept(NMDevice *self, int addr_family, const NML3ConfigData *l3cd) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); - gs_free_error GError *error = NULL; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + gs_free_error GError *error = NULL; nm_assert(NM_IS_L3_CONFIG_DATA(l3cd)); @@ -9989,21 +9989,21 @@ _dev_ipdhcpx_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_d static void _dev_ipdhcpx_start(NMDevice *self, int addr_family) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip; - const NML3ConfigData *previous_lease; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip; + const NML3ConfigData *previous_lease; gs_unref_bytes GBytes *hwaddr = NULL; gboolean enforce_duid = FALSE; - gs_free_error GError *error = NULL; - const NMPlatformLink *pllink; - guint no_lease_timeout_sec; - int ifindex; - const char * str; - gboolean request_broadcast; - const char * fail_reason; + gs_free_error GError *error = NULL; + const NMPlatformLink *pllink; + guint no_lease_timeout_sec; + int ifindex; + const char *str; + gboolean request_broadcast; + const char *fail_reason; if (priv->ipdhcp_data_x[IS_IPv4].state == NM_DEVICE_IP_STATE_NONE) _dev_ipdhcpx_set_state(self, addr_family, NM_DEVICE_IP_STATE_PENDING); @@ -10076,12 +10076,12 @@ _dev_ipdhcpx_start(NMDevice *self, int addr_family) no_lease_timeout_sec = _prop_get_ipvx_dhcp_timeout(self, addr_family); if (IS_IPv4) { - NMDhcpClientConfig config; + NMDhcpClientConfig config; gs_unref_bytes GBytes *bcast_hwaddr = NULL; gs_unref_bytes GBytes *client_id = NULL; gs_unref_bytes GBytes *vendor_class_identifier = NULL; - const char *const * reject_servers; - const char * hostname; + const char *const *reject_servers; + const char *hostname; gboolean hostname_is_fqdn; client_id = _prop_get_ipv4_dhcp_client_id(self, connection, hwaddr); @@ -10271,7 +10271,7 @@ nm_device_request_ip6_prefixes(NMDevice *self, guint needed_prefixes) static gboolean connection_ip_method_requires_carrier(NMConnection *connection, int addr_family, - gboolean * out_ip_enabled) + gboolean *out_ip_enabled) { const char *method; @@ -10298,7 +10298,7 @@ connection_ip_method_requires_carrier(NMConnection *connection, static gboolean connection_requires_carrier(NMConnection *connection) { - NMSettingIPConfig * s_ip4, *s_ip6; + NMSettingIPConfig *s_ip4, *s_ip6; NMSettingConnection *s_con; gboolean ip4_carrier_wanted, ip6_carrier_wanted; gboolean ip4_used = FALSE, ip6_used = FALSE; @@ -10345,8 +10345,8 @@ static gboolean have_any_ready_slaves(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - SlaveInfo * info; - CList * iter; + SlaveInfo *info; + CList *iter; /* Any enslaved slave is "ready" in the generic case as it's * at least >= NM_DEVCIE_STATE_IP_CONFIG and has had Layer 2 @@ -10403,10 +10403,10 @@ nm_device_use_ip6_subnet(NMDevice *self, const NMPlatformIP6Address *subnet) void nm_device_copy_ip6_dns_config(NMDevice *self, NMDevice *from_device) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMDevicePrivate * priv_src; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv_src; nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - const NML3ConfigData * l3cd_src = NULL; + const NML3ConfigData *l3cd_src = NULL; /* FIXME(l3cfg): this entire code an approach seems flawed. It's flawed, because the * very next RA will reset the changes. */ @@ -10423,7 +10423,7 @@ nm_device_copy_ip6_dns_config(NMDevice *self, NMDevice *from_device) l3cd_src = priv_src->l3cds[L3_CONFIG_DATA_TYPE_AC_6].d; } if (l3cd_src) { - const char *const * strvarr; + const char *const *strvarr; const struct in6_addr *const *addrs; guint n; guint i; @@ -10447,7 +10447,7 @@ nm_device_copy_ip6_dns_config(NMDevice *self, NMDevice *from_device) static gboolean _dev_ipll6_state_retry_cb(gpointer user_data) { - NMDevice * self = user_data; + NMDevice *self = user_data; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->ipll_data_6.v6.retry_source); @@ -10544,7 +10544,7 @@ _dev_ipll6_set_llstate(NMDevice *self, NML3IPv6LLState llstate, const struct in6 } static void -_dev_ipll6_state_change_cb(NML3IPv6LL * ipv6ll, +_dev_ipll6_state_change_cb(NML3IPv6LL *ipv6ll, NML3IPv6LLState llstate, const struct in6_addr *lladdr, gpointer user_data) @@ -10555,11 +10555,11 @@ _dev_ipll6_state_change_cb(NML3IPv6LL * ipv6ll, static void _dev_ipll6_start(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; - NMSettingIP6Config * s_ip6 = NULL; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMConnection *connection; + NMSettingIP6Config *s_ip6 = NULL; gboolean assume; - const char * ifname; + const char *ifname; NML3IPv6LLState llstate; const struct in6_addr *lladdr; @@ -10587,7 +10587,7 @@ _dev_ipll6_start(NMDevice *self) && nm_setting_ip6_config_get_addr_gen_mode(s_ip6) == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) { NMUtilsStableType stable_type; - const char * stable_id; + const char *stable_id; stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); priv->ipll_data_6.v6.ipv6ll = @@ -10627,7 +10627,7 @@ out_fail: /*****************************************************************************/ gint64 -nm_device_get_configured_mtu_from_connection_default(NMDevice * self, +nm_device_get_configured_mtu_from_connection_default(NMDevice *self, const char *property_name, guint32 max_mtu) { @@ -10640,13 +10640,13 @@ nm_device_get_configured_mtu_from_connection_default(NMDevice * self, } guint32 -nm_device_get_configured_mtu_from_connection(NMDevice * self, +nm_device_get_configured_mtu_from_connection(NMDevice *self, GType setting_type, NMDeviceMtuSource *out_source) { - const char * global_property_name; + const char *global_property_name; NMConnection *connection; - NMSetting * setting; + NMSetting *setting; gint64 mtu_default; guint32 mtu = 0; guint32 max_mtu = G_MAXUINT32; @@ -10701,17 +10701,17 @@ nm_device_get_configured_mtu_from_connection(NMDevice * self, } guint32 -nm_device_get_configured_mtu_for_wired(NMDevice * self, +nm_device_get_configured_mtu_for_wired(NMDevice *self, NMDeviceMtuSource *out_source, - gboolean * out_force) + gboolean *out_force) { return nm_device_get_configured_mtu_from_connection(self, NM_TYPE_SETTING_WIRED, out_source); } guint32 -nm_device_get_configured_mtu_wired_parent(NMDevice * self, +nm_device_get_configured_mtu_wired_parent(NMDevice *self, NMDeviceMtuSource *out_source, - gboolean * out_force) + gboolean *out_force) { guint32 mtu = 0; guint32 parent_mtu = 0; @@ -10786,7 +10786,7 @@ set_platform_mtu(NMDevice *self, guint32 mtu) static void _commit_mtu(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceMtuSource source = NM_DEVICE_MTU_SOURCE_NONE; const NML3ConfigData *l3cd; guint32 ip6_mtu_orig; @@ -11051,7 +11051,7 @@ nm_device_commit_mtu(NMDevice *self) static void _dev_ipac6_ndisc_set_router_config(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const NML3ConfigData *l3cd; if (!priv->ipac6_data.ndisc) @@ -11081,11 +11081,11 @@ _dev_ipac6_set_state(NMDevice *self, NMDeviceIPState state) } static void -_dev_ipac6_ndisc_config_changed(NMNDisc * ndisc, - const NMNDiscData * rdata, +_dev_ipac6_ndisc_config_changed(NMNDisc *ndisc, + const NMNDiscData *rdata, guint changed_i, const NML3ConfigData *l3cd, - NMDevice * self) + NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean ready = TRUE; @@ -11204,12 +11204,12 @@ _dev_ipac6_grace_period_start(NMDevice *self, guint32 timeout_sec, gboolean forc static void _dev_ipac6_start(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMConnection *connection; NMSettingIP6Config *s_ip = NULL; NMNDiscNodeType node_type; NMUtilsStableType stable_type; - const char * stable_id; + const char *stable_id; int max_addresses; int router_solicitations; int router_solicitation_interval; @@ -11372,9 +11372,9 @@ _dev_sysctl_save_ip6_properties(NMDevice *self) "use_tempaddr", }; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMPlatform * platform = nm_device_get_platform(self); - const char * ifname; - char * value; + NMPlatform *platform = nm_device_get_platform(self); + const char *ifname; + char *value; int i; g_hash_table_remove_all(priv->ip6_saved_properties); @@ -11426,7 +11426,7 @@ _dev_sysctl_set_disable_ipv6(NMDevice *self, gboolean do_disable) static void _dev_addrgenmode6_set(NMDevice *self, guint8 addr_gen_mode) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); int ifindex = nm_device_get_ip_ifindex(self); const NMPlatformLink *plink; int r; @@ -11516,8 +11516,8 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family, const { const int IS_IPv4 = NM_IS_IPv4(addr_family); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); - NMConnection * connection; + NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self); + NMConnection *connection; int ip_ifindex; if (nm_device_sys_iface_state_is_external(self)) @@ -11638,12 +11638,12 @@ out: } static void -fw_change_zone_cb(NMFirewalldManager * firewalld_manager, +fw_change_zone_cb(NMFirewalldManager *firewalld_manager, NMFirewalldManagerCallId *call_id, - GError * error, + GError *error, gpointer user_data) { - NMDevice * self = user_data; + NMDevice *self = user_data; NMDevicePrivate *priv; g_return_if_fail(NM_IS_DEVICE(self)); @@ -11679,10 +11679,10 @@ fw_change_zone_cb(NMFirewalldManager * firewalld_manager, static void fw_change_zone(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * applied_connection; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMConnection *applied_connection; NMSettingConnection *s_con; - const char * zone; + const char *zone; nm_assert(priv->fw_state >= FIREWALL_STATE_INITIALIZED); @@ -11722,10 +11722,10 @@ static void activate_stage3_ip_config(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); + NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self); int ifindex; - const char * ipv4_method; - const char * ipv6_method; + const char *ipv4_method; + const char *ipv6_method; /* stage3 is different from stage1+2. * @@ -11899,11 +11899,11 @@ _dev_ipsharedx_cleanup(NMDevice *self, int addr_family) static const NML3ConfigData * _dev_ipshared4_new_l3cd(NMDevice *self, NMConnection *connection, NMPlatformIP4Address *out_addr4) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - NMSettingIPConfig * s_ip4; + NMSettingIPConfig *s_ip4; NMPlatformIP4Address address = { - .addr_source = NM_IP_CONFIG_SOURCE_SHARED, + .addr_source = NM_IP_CONFIG_SOURCE_SHARED, }; g_return_val_if_fail(self, NULL); @@ -11999,9 +11999,9 @@ _dev_ipshared4_start(NMDevice *self) { nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; NMPlatformIP4Address ip4_addr; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - const char * ip_iface; - NMConnection * applied; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const char *ip_iface; + NMConnection *applied; if (priv->ipshared_data_4.state != NM_DEVICE_IP_STATE_NONE) return; @@ -12044,12 +12044,12 @@ out_fail: static void _dev_ipshared4_spawn_dnsmasq(NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const char * ip_iface; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const char *ip_iface; gs_free_error GError *error = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; gboolean announce_android_metered; - NMConnection * applied; + NMConnection *applied; nm_assert(priv->ipshared_data_4.v4.firewall_config); nm_assert(priv->ipshared_data_4.v4.dnsmasq_state_id == 0); @@ -12187,10 +12187,10 @@ nm_device_is_nm_owned(NMDevice *self) static gboolean delete_on_deactivate_link_delete(gpointer user_data) { - DeleteOnDeactivateData *data = user_data; - nm_auto_unref_object NMDevice *self = data->device; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - gs_free_error GError *error = NULL; + DeleteOnDeactivateData *data = user_data; + nm_auto_unref_object NMDevice *self = data->device; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gs_free_error GError *error = NULL; _LOGD(LOGD_DEVICE, "delete_on_deactivate: cleanup and delete virtual link (id=%u)", @@ -12229,7 +12229,7 @@ delete_on_deactivate_unschedule(NMDevice *self) static void delete_on_deactivate_check_and_schedule(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); DeleteOnDeactivateData *data; if (!priv->nm_owned) @@ -12278,9 +12278,9 @@ _cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type, gbool } gboolean -_nm_device_hash_check_invalid_keys(GHashTable * hash, - const char * setting_name, - GError ** error, +_nm_device_hash_check_invalid_keys(GHashTable *hash, + const char *setting_name, + GError **error, const char *const *whitelist) { guint found_whitelisted_keys = 0; @@ -12315,8 +12315,8 @@ _nm_device_hash_check_invalid_keys(GHashTable * hash, if (error) { GHashTableIter iter; - const char * k = NULL; - const char * first_invalid_key = NULL; + const char *k = NULL; + const char *first_invalid_key = NULL; g_hash_table_iter_init(&iter, hash); while (g_hash_table_iter_next(&iter, (gpointer *) &k, NULL)) { @@ -12369,12 +12369,12 @@ reactivate_proxy_config(NMDevice *self) /*****************************************************************************/ static gboolean -can_reapply_change(NMDevice * self, +can_reapply_change(NMDevice *self, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error) + GError **error) { if (nm_streq(setting_name, NM_SETTING_CONNECTION_SETTING_NAME)) { /* Whitelist allowed properties from "connection" setting which are @@ -12452,19 +12452,19 @@ reapply_connection(NMDevice *self, NMConnection *con_old, NMConnection *con_new) * Return: %FALSE if the new configuration can not be reapplied. */ static gboolean -check_and_reapply_connection(NMDevice * self, +check_and_reapply_connection(NMDevice *self, NMConnection *connection, guint64 version_id, - char ** audit_args, - GError ** error) + char **audit_args, + GError **error) { - NMDeviceClass * klass = NM_DEVICE_GET_CLASS(self); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * applied = nm_device_get_applied_connection(self); - gs_unref_object NMConnection *applied_clone = NULL; - gs_unref_hashtable GHashTable *diffs = NULL; - NMConnection * con_old; - NMConnection * con_new; + NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMConnection *applied = nm_device_get_applied_connection(self); + gs_unref_object NMConnection *applied_clone = NULL; + gs_unref_hashtable GHashTable *diffs = NULL; + NMConnection *con_old; + NMConnection *con_new; GHashTableIter iter; if (priv->state < NM_DEVICE_STATE_PREPARE || priv->state > NM_DEVICE_STATE_ACTIVATED) { @@ -12492,7 +12492,7 @@ check_and_reapply_connection(NMDevice * self, * check for unsupported changes and reject to reapply *************************************************************************/ if (diffs) { - char * setting_name; + char *setting_name; GHashTable *setting_diff; g_hash_table_iter_init(&iter, diffs); @@ -12535,7 +12535,7 @@ check_and_reapply_connection(NMDevice * self, diffs ? "" : " (unmodified)"); if (diffs) { - NMConnection * connection_clean = connection; + NMConnection *connection_clean = connection; gs_unref_object NMConnection *connection_clean_free = NULL; { @@ -12639,17 +12639,17 @@ typedef struct { } ReapplyData; static void -reapply_cb(NMDevice * self, +reapply_cb(NMDevice *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer user_data) { - ReapplyData * reapply_data = user_data; - guint64 version_id = 0; - gs_unref_object NMConnection *connection = NULL; - GError * local = NULL; - gs_free char * audit_args = NULL; + ReapplyData *reapply_data = user_data; + guint64 version_id = 0; + gs_unref_object NMConnection *connection = NULL; + GError *local = NULL; + gs_free char *audit_args = NULL; if (reapply_data) { connection = reapply_data->connection; @@ -12692,20 +12692,20 @@ reapply_cb(NMDevice * self, } static void -impl_device_reapply(NMDBusObject * obj, +impl_device_reapply(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * dbus_connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *dbus_connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMDevice * self = NM_DEVICE(obj); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMSettingsConnection *settings_connection; - NMConnection * connection = NULL; - GError * error = NULL; - ReapplyData * reapply_data; + NMDevice *self = NM_DEVICE(obj); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMSettingsConnection *settings_connection; + NMConnection *connection = NULL; + GError *error = NULL; + ReapplyData *reapply_data; gs_unref_variant GVariant *settings = NULL; guint64 version_id; guint32 flags; @@ -12783,20 +12783,20 @@ impl_device_reapply(NMDBusObject * obj, /*****************************************************************************/ static void -impl_device_get_applied_connection(NMDBusObject * obj, +impl_device_get_applied_connection(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMDevice * self = NM_DEVICE(obj); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDevice *self = NM_DEVICE(obj); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gs_free_error GError *error = NULL; - NMConnection * applied_connection; + NMConnection *applied_connection; guint32 flags; - GVariant * var_settings; + GVariant *var_settings; g_variant_get(parameters, "(u)", &flags); @@ -12844,14 +12844,14 @@ impl_device_get_applied_connection(NMDBusObject * obj, /*****************************************************************************/ static void -disconnect_cb(NMDevice * self, +disconnect_cb(NMDevice *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer user_data) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - GError * local = NULL; + GError *local = NULL; if (error) { g_dbus_method_invocation_return_gerror(context, error); @@ -12899,17 +12899,17 @@ _clear_queued_act_request(NMDevicePrivate *priv, NMActiveConnectionStateReason a } static void -impl_device_disconnect(NMDBusObject * obj, +impl_device_disconnect(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * dbus_connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *dbus_connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMDevice * self = NM_DEVICE(obj); + NMDevice *self = NM_DEVICE(obj); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; + NMConnection *connection; if (!priv->act_request.obj) { g_dbus_method_invocation_return_error_literal(invocation, @@ -12933,10 +12933,10 @@ impl_device_disconnect(NMDBusObject * obj, } static void -delete_cb(NMDevice * self, +delete_cb(NMDevice *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer user_data) { GError *local = NULL; @@ -12961,13 +12961,13 @@ delete_cb(NMDevice * self, } static void -impl_device_delete(NMDBusObject * obj, +impl_device_delete(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { NMDevice *self = NM_DEVICE(obj); @@ -13058,7 +13058,7 @@ static gboolean _carrier_wait_check_act_request_must_queue(NMDevice *self, NMActRequest *req) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; + NMConnection *connection; /* If we have carrier or if we are not waiting for it, the activation * request is not blocked waiting for carrier. */ @@ -13107,11 +13107,11 @@ _carrier_wait_check_act_request_must_queue(NMDevice *self, NMActRequest *req) } void -nm_device_disconnect_active_connection(NMActiveConnection * active, +nm_device_disconnect_active_connection(NMActiveConnection *active, NMDeviceStateReason device_reason, NMActiveConnectionStateReason active_reason) { - NMDevice * self; + NMDevice *self; NMDevicePrivate *priv; g_return_if_fail(NM_IS_ACTIVE_CONNECTION(active)); @@ -13275,7 +13275,7 @@ _dispatcher_cleanup(NMDevice *self) static void _dispatcher_complete_proceed_state(NMDispatcherCallId *call_id, gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); + NMDevice *self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); g_return_if_fail(call_id == priv->dispatcher.call_id); @@ -13335,10 +13335,10 @@ ip_check_gw_ping_cleanup(NMDevice *self) static gboolean spawn_ping(NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - gs_free char * str_timeout = NULL; - gs_free char * tmp_str = NULL; - const char * args[] = {priv->gw_ping.binary, + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gs_free char *str_timeout = NULL; + gs_free char *tmp_str = NULL; + const char *args[] = {priv->gw_ping.binary, "-I", nm_device_get_ip_iface(self), "-c", @@ -13347,7 +13347,7 @@ spawn_ping(NMDevice *self) NULL, priv->gw_ping.address, NULL}; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; gboolean ret; args[6] = str_timeout = g_strdup_printf("%u", priv->gw_ping.deadline); @@ -13376,7 +13376,7 @@ spawn_ping(NMDevice *self) static gboolean respawn_ping_cb(gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); + NMDevice *self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); priv->gw_ping.watch = 0; @@ -13394,7 +13394,7 @@ respawn_ping_cb(gpointer user_data) static void ip_check_ping_watch_cb(GPid pid, int status, gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); + NMDevice *self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMLogDomain log_domain = priv->gw_ping.log_domain; gboolean success = FALSE; @@ -13428,7 +13428,7 @@ ip_check_ping_watch_cb(GPid pid, int status, gpointer user_data) static gboolean ip_check_ping_timeout_cb(gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); + NMDevice *self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); priv->gw_ping.timeout = 0; @@ -13441,7 +13441,7 @@ ip_check_ping_timeout_cb(gpointer user_data) } static gboolean -start_ping(NMDevice * self, +start_ping(NMDevice *self, NMLogDomain log_domain, const char *binary, const char *address, @@ -13470,11 +13470,11 @@ start_ping(NMDevice * self, static void nm_device_start_ip_check(NMDevice *self) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMConnection * connection; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMConnection *connection; NMSettingConnection *s_con; guint timeout = 0; - const char * ping_binary = NULL; + const char *ping_binary = NULL; char buf[NM_UTILS_INET_ADDRSTRLEN]; NMLogDomain log_domain = LOGD_IP4; @@ -13497,7 +13497,7 @@ nm_device_start_ip_check(NMDevice *self) buf[0] = '\0'; if (timeout) { - const NMPObject * gw; + const NMPObject *gw; const NML3ConfigData *l3cd; l3cd = priv->l3cfg ? nm_l3cfg_get_combined_l3cd(priv->l3cfg, TRUE) : NULL; @@ -13533,7 +13533,7 @@ nm_device_start_ip_check(NMDevice *self) static gboolean carrier_wait_timeout(gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); + NMDevice *self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); priv->carrier_wait_id = 0; @@ -13570,7 +13570,7 @@ _get_carrier_wait_ms(NMDevice *self) gboolean nm_device_bring_up(NMDevice *self, gboolean block, gboolean *no_firmware) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean device_is_up = FALSE; NMDeviceCapabilities capabilities; int ifindex; @@ -13927,7 +13927,7 @@ nm_device_get_unmanaged_flags(NMDevice *self, NMUnmanagedFlags flag) * Set the unmanaged flags of the device. **/ static void -_set_unmanaged_flags(NMDevice * self, +_set_unmanaged_flags(NMDevice *self, NMUnmanagedFlags flags, NMUnmanFlagOp set_op, gboolean allow_state_transition, @@ -13938,7 +13938,7 @@ _set_unmanaged_flags(NMDevice * self, gboolean was_managed, transition_state; NMUnmanagedFlags old_flags, old_mask; NMDeviceState new_state; - const char * operation = NULL; + const char *operation = NULL; char str1[512]; char str2[512]; gboolean do_notify_has_pending_actions = FALSE; @@ -14064,7 +14064,7 @@ nm_device_set_unmanaged_flags(NMDevice *self, NMUnmanagedFlags flags, NMUnmanFla * Set the unmanaged flags of the device and possibly trigger a state change. **/ void -nm_device_set_unmanaged_by_flags(NMDevice * self, +nm_device_set_unmanaged_by_flags(NMDevice *self, NMUnmanagedFlags flags, NMUnmanFlagOp set_op, NMDeviceStateReason reason) @@ -14073,7 +14073,7 @@ nm_device_set_unmanaged_by_flags(NMDevice * self, } void -nm_device_set_unmanaged_by_flags_queue(NMDevice * self, +nm_device_set_unmanaged_by_flags_queue(NMDevice *self, NMUnmanagedFlags flags, NMUnmanFlagOp set_op, NMDeviceStateReason reason) @@ -14212,12 +14212,12 @@ nm_device_set_unmanaged_by_quitting(NMDevice *self) void nm_device_reapply_settings_immediately(NMDevice *self) { - NMConnection * applied_connection; + NMConnection *applied_connection; NMSettingsConnection *settings_connection; NMDeviceState state; - NMSettingConnection * s_con_settings; - NMSettingConnection * s_con_applied; - const char * zone; + NMSettingConnection *s_con_settings; + NMSettingConnection *s_con_applied; + const char *zone; NMMetered metered; guint64 version_id; @@ -14287,10 +14287,10 @@ void nm_device_update_metered(NMDevice *self) { #define NM_METERED_INVALID ((NMMetered) -1) - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMSettingConnection *setting; NMMetered conn_value, value = NM_METERED_INVALID; - NMConnection * connection = NULL; + NMConnection *connection = NULL; NMDeviceState state; g_return_if_fail(NM_IS_DEVICE(self)); @@ -14369,14 +14369,14 @@ _device_check_dev_available_flags_from_con(NMDeviceCheckConAvailableFlags con_fl } static gboolean -_nm_device_check_connection_available(NMDevice * self, - NMConnection * connection, +_nm_device_check_connection_available(NMDevice *self, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { NMDeviceState state; - GError * local = NULL; + GError *local = NULL; /* an unrealized software device is always available, hardware devices never. */ if (!nm_device_is_real(self)) { @@ -14480,11 +14480,11 @@ _nm_device_check_connection_available(NMDevice * self, * Returns: %TRUE if @connection can be activated on @self */ gboolean -nm_device_check_connection_available(NMDevice * self, - NMConnection * connection, +nm_device_check_connection_available(NMDevice *self, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { gboolean available; @@ -14538,11 +14538,11 @@ available_connections_del(NMDevice *self, NMSettingsConnection *sett_conn) } static gboolean -check_connection_available(NMDevice * self, - NMConnection * connection, +check_connection_available(NMDevice *self, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); @@ -14585,12 +14585,12 @@ check_connection_available(NMDevice * self, void nm_device_recheck_available_connections(NMDevice *self) { - NMDevicePrivate * priv; - NMSettingsConnection *const *connections; - gboolean changed = FALSE; - GHashTableIter h_iter; - NMSettingsConnection * sett_conn; - guint i; + NMDevicePrivate *priv; + NMSettingsConnection *const *connections; + gboolean changed = FALSE; + GHashTableIter h_iter; + NMSettingsConnection *sett_conn; + guint i; gs_unref_hashtable GHashTable *prune_list = NULL; g_return_if_fail(NM_IS_DEVICE(self)); @@ -14647,7 +14647,7 @@ nm_device_recheck_available_connections(NMDevice *self) NMSettingsConnection * nm_device_get_best_connection(NMDevice *self, const char *specific_object, GError **error) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMSettingsConnection *sett_conn = NULL; NMSettingsConnection *candidate; guint64 best_timestamp = 0; @@ -14717,7 +14717,7 @@ cp_connection_added(NMSettings *settings, NMSettingsConnection *sett_conn, gpoin } static void -cp_connection_updated(NMSettings * settings, +cp_connection_updated(NMSettings *settings, NMSettingsConnection *sett_conn, guint update_reason_u, gpointer user_data) @@ -15149,7 +15149,7 @@ deactivate_ready(NMDevice *self, NMDeviceStateReason reason) static void sriov_reset_on_deactivate_cb(GError *error, gpointer user_data) { - NMDevice * self; + NMDevice *self; NMDevicePrivate *priv; gpointer reason; @@ -15167,7 +15167,7 @@ sriov_reset_on_deactivate_cb(GError *error, gpointer user_data) static void sriov_reset_on_failure_cb(GError *error, gpointer user_data) { - NMDevice * self = user_data; + NMDevice *self = user_data; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); nm_assert(priv->sriov_reset_pending > 0); @@ -15184,7 +15184,7 @@ sriov_reset_on_failure_cb(GError *error, gpointer user_data) static void deactivate_async_ready(NMDevice *self, GError *error, gpointer user_data) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceStateReason reason = GPOINTER_TO_UINT(user_data); if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { @@ -15205,8 +15205,8 @@ deactivate_async_ready(NMDevice *self, GError *error, gpointer user_data) static void deactivate_dispatcher_complete(NMDispatcherCallId *call_id, gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevice *self = NM_DEVICE(user_data); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceStateReason reason; g_return_if_fail(call_id == priv->dispatcher.call_id); @@ -15260,11 +15260,11 @@ static void _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, gboolean quitting) { gs_unref_object NMActRequest *req = NULL; - NMDevicePrivate * priv; + NMDevicePrivate *priv; NMDeviceState old_state; gboolean no_firmware = FALSE; - NMSettingsConnection * sett_conn; - NMSettingSriov * s_sriov; + NMSettingsConnection *sett_conn; + NMSettingSriov *s_sriov; gboolean concheck_now; g_return_if_fail(NM_IS_DEVICE(self)); @@ -15626,8 +15626,8 @@ nm_device_state_changed(NMDevice *self, NMDeviceState state, NMDeviceStateReason static gboolean queued_state_set(gpointer user_data) { - NMDevice * self = NM_DEVICE(user_data); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevice *self = NM_DEVICE(user_data); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceState new_state; NMDeviceStateReason new_reason; @@ -15762,7 +15762,7 @@ gboolean nm_device_update_hw_address(NMDevice *self) { NMDevicePrivate *priv; - const guint8 * hwaddr; + const guint8 *hwaddr; gsize hwaddrlen = 0; priv = NM_DEVICE_GET_PRIVATE(self); @@ -15837,11 +15837,11 @@ nm_device_update_initial_hw_address(NMDevice *self) void nm_device_update_permanent_hw_address(NMDevice *self, gboolean force_freeze) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); guint8 buf[_NM_UTILS_HWADDR_LEN_MAX]; gboolean success_read; int ifindex; - const NMPlatformLink * pllink; + const NMPlatformLink *pllink; const NMConfigDeviceStateData *dev_state; NMPLinkAddress cached_hw_addr_perm; @@ -15950,7 +15950,7 @@ _hw_addr_matches(NMDevice *self, const guint8 *addr, gsize addr_len) } static gboolean -_hw_addr_set(NMDevice * self, +_hw_addr_set(NMDevice *self, const char *const addr, const char *const operation, const char *const detail) @@ -16153,20 +16153,20 @@ nm_device_hw_addr_set(NMDevice *self, const char *addr, const char *detail, gboo * %TRUE otherwise */ static gboolean -_hw_addr_get_cloned(NMDevice * self, +_hw_addr_get_cloned(NMDevice *self, NMConnection *connection, gboolean is_wifi, - gboolean * preserve, - char ** hwaddr, - HwAddrType * hwaddr_type, - const char ** hwaddr_detail, - GError ** error) + gboolean *preserve, + char **hwaddr, + HwAddrType *hwaddr_type, + const char **hwaddr_detail, + GError **error) { NMDevicePrivate *priv; - gs_free char * hw_addr_generated = NULL; - const char * addr; - const char * addr_setting; - char * addr_out; + gs_free char *hw_addr_generated = NULL; + const char *addr; + const char *addr_setting; + char *addr_out; HwAddrType type_out; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); @@ -16234,7 +16234,7 @@ _hw_addr_get_cloned(NMDevice * self, type_out = HW_ADDR_TYPE_GENERATED; } else if (NM_IN_STRSET(addr, NM_CLONED_MAC_STABLE)) { NMUtilsStableType stable_type; - const char * stable_id; + const char *stable_id; if (priv->hw_addr_type == HW_ADDR_TYPE_GENERATED) { /* hm, we already use a generate MAC address. Most certainly, that is from the same @@ -16283,12 +16283,12 @@ out_no_action: } gboolean -nm_device_hw_addr_get_cloned(NMDevice * self, +nm_device_hw_addr_get_cloned(NMDevice *self, NMConnection *connection, gboolean is_wifi, - char ** hwaddr, - gboolean * preserve, - GError ** error) + char **hwaddr, + gboolean *preserve, + GError **error) { if (!_hw_addr_get_cloned(self, connection, is_wifi, preserve, hwaddr, NULL, NULL, error)) return FALSE; @@ -16299,12 +16299,12 @@ nm_device_hw_addr_get_cloned(NMDevice * self, gboolean nm_device_hw_addr_set_cloned(NMDevice *self, NMConnection *connection, gboolean is_wifi) { - NMDevicePrivate *priv; - gboolean preserve = FALSE; - gs_free char * hwaddr = NULL; - const char * detail = NULL; - HwAddrType type = HW_ADDR_TYPE_UNSET; - gs_free_error GError *error = NULL; + NMDevicePrivate *priv; + gboolean preserve = FALSE; + gs_free char *hwaddr = NULL; + const char *detail = NULL; + HwAddrType type = HW_ADDR_TYPE_UNSET; + gs_free_error GError *error = NULL; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); priv = NM_DEVICE_GET_PRIVATE(self); @@ -16336,7 +16336,7 @@ gboolean nm_device_hw_addr_reset(NMDevice *self, const char *detail) { NMDevicePrivate *priv; - const char * addr; + const char *addr; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); @@ -16425,9 +16425,9 @@ nm_device_spec_match_list(NMDevice *self, const GSList *specs) int nm_device_spec_match_list_full(NMDevice *self, const GSList *specs, int no_match_value) { - NMDeviceClass * klass; + NMDeviceClass *klass; NMMatchSpecMatchType m; - const char * hw_address = NULL; + const char *hw_address = NULL; gboolean is_fake; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); @@ -16462,7 +16462,7 @@ nm_device_spec_match_list_full(NMDevice *self, const GSList *specs, int no_match guint nm_device_get_supplicant_timeout(NMDevice *self) { - NMConnection * connection; + NMConnection *connection; NMSetting8021x *s_8021x; int timeout; #define SUPPLICANT_DEFAULT_TIMEOUT 25 @@ -16491,7 +16491,7 @@ nm_device_get_supplicant_timeout(NMDevice *self) gboolean nm_device_auth_retries_try_next(NMDevice *self) { - NMDevicePrivate * priv; + NMDevicePrivate *priv; NMSettingConnection *s_con; int auth_retries; @@ -16540,11 +16540,11 @@ nm_device_auth_retries_try_next(NMDevice *self) static void hostname_dns_lookup_callback(GObject *source, GAsyncResult *result, gpointer user_data) { - HostnameResolver *resolver; - NMDevice * self; - gs_free char * addr_str = NULL; - gs_free char * output = NULL; - gs_free_error GError *error = NULL; + HostnameResolver *resolver; + NMDevice *self; + gs_free char *addr_str = NULL; + gs_free char *output = NULL; + gs_free_error GError *error = NULL; output = nm_device_resolve_address_finish(result, &error); if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -16583,7 +16583,7 @@ static gboolean hostname_dns_address_timeout(gpointer user_data) { HostnameResolver *resolver = user_data; - NMDevice * self = resolver->device; + NMDevice *self = resolver->device; g_return_val_if_fail(NM_IS_DEVICE(self), G_SOURCE_REMOVE); @@ -16634,9 +16634,9 @@ get_address_for_hostname_dns_lookup(NMDevice *self, int addr_family) const int IS_IPv4 = NM_IS_IPv4(addr_family); NMPLookup lookup; const NMDedupMultiHeadEntry *head_entry; - const NMDedupMultiEntry * iter; - const guint8 * addr6_ll = NULL; - const guint8 * addr6_nonll = NULL; + const NMDedupMultiEntry *iter; + const guint8 *addr6_ll = NULL; + const guint8 *addr6_nonll = NULL; int ifindex; ifindex = nm_device_get_ip_ifindex(self); @@ -16686,12 +16686,12 @@ get_address_for_hostname_dns_lookup(NMDevice *self, int addr_family) const char * nm_device_get_hostname_from_dns_lookup(NMDevice *self, int addr_family, gboolean *out_wait) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMDevicePrivate * priv; - HostnameResolver *resolver; - const char * method; - gboolean address_changed = FALSE; - gs_unref_object GInetAddress *new_address = NULL; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDevicePrivate *priv; + HostnameResolver *resolver; + const char *method; + gboolean address_changed = FALSE; + gs_unref_object GInetAddress *new_address = NULL; g_return_val_if_fail(NM_IS_DEVICE(self), NULL); priv = NM_DEVICE_GET_PRIVATE(self); @@ -16813,7 +16813,7 @@ static GVariant * _device_get_ports_variant(NMDevice *device) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(device); - SlaveInfo * info; + SlaveInfo *info; GVariantBuilder builder; gboolean any = FALSE; @@ -16845,7 +16845,7 @@ _device_get_ports_variant(NMDevice *device) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDevice * self = NM_DEVICE(object); + NMDevice *self = NM_DEVICE(object); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); switch (prop_id) { @@ -17025,7 +17025,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMDevice * self = (NMDevice *) object; + NMDevice *self = (NMDevice *) object; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); switch (prop_id) { @@ -17155,10 +17155,10 @@ nm_device_init(NMDevice *self) static GObject * constructor(GType type, guint n_construct_params, GObjectConstructParam *construct_params) { - GObject * object; - GObjectClass * klass; - NMDevice * self; - NMDevicePrivate * priv; + GObject *object; + GObjectClass *klass; + NMDevice *self; + NMDevicePrivate *priv; const NMPlatformLink *pllink; klass = G_OBJECT_CLASS(nm_device_parent_class); @@ -17198,9 +17198,9 @@ constructor(GType type, guint n_construct_params, GObjectConstructParam *constru static void constructed(GObject *object) { - NMDevice * self = NM_DEVICE(object); + NMDevice *self = NM_DEVICE(object); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMPlatform * platform; + NMPlatform *platform; if (NM_DEVICE_GET_CLASS(self)->get_generic_capabilities) priv->capabilities |= NM_DEVICE_GET_CLASS(self)->get_generic_capabilities(self); @@ -17232,11 +17232,11 @@ constructed(GObject *object) static void dispose(GObject *object) { - NMDevice * self = NM_DEVICE(object); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMPlatform * platform; + NMDevice *self = NM_DEVICE(object); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMPlatform *platform; NMDeviceConnectivityHandle *con_handle; - gs_free_error GError *cancelled_error = NULL; + gs_free_error GError *cancelled_error = NULL; _LOGD(LOGD_DEVICE, "disposing"); @@ -17335,7 +17335,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMDevice * self = NM_DEVICE(object); + NMDevice *self = NM_DEVICE(object); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); _LOGD(LOGD_DEVICE, "finalize(): %s", G_OBJECT_TYPE_NAME(self)); @@ -17506,7 +17506,7 @@ static const NMDBusInterfaceInfoExtended interface_info_device_statistics = { static void nm_device_class_init(NMDeviceClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); g_type_class_add_private(object_class, sizeof(NMDevicePrivate)); diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 93e9d51b14..3acd0cd214 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -170,7 +170,7 @@ typedef struct _NMDeviceClass { NMDBusObjectClass parent; struct _NMDeviceClass *default_type_description_klass; - const char * default_type_description; + const char *default_type_description; const char *connection_type_supported; @@ -209,7 +209,7 @@ typedef struct _NMDeviceClass { bool can_reapply_change_ovs_external_ids : 1; - void (*state_changed)(NMDevice * device, + void (*state_changed)(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason); @@ -233,11 +233,11 @@ typedef struct _NMDeviceClass { * * Returns: %TRUE on success, %FALSE on error */ - gboolean (*create_and_realize)(NMDevice * self, - NMConnection * connection, - NMDevice * parent, + gboolean (*create_and_realize)(NMDevice *self, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error); + GError **error); /** * realize_start_notify(): @@ -295,13 +295,13 @@ typedef struct _NMDeviceClass { * which emits NM_DEVICE_RECHECK_AUTO_ACTIVATE signal. */ gboolean (*get_autoconnect_allowed)(NMDevice *self); - gboolean (*can_auto_connect)(NMDevice * self, + gboolean (*can_auto_connect)(NMDevice *self, NMSettingsConnection *sett_conn, - char ** specific_object); + char **specific_object); - guint32 (*get_configured_mtu)(NMDevice * self, + guint32 (*get_configured_mtu)(NMDevice *self, NMDeviceMtuSource *out_source, - gboolean * out_force); + gboolean *out_force); /* allow the subclass to overwrite the routing table. This is mainly useful * to change from partial mode (route-table=0) to full-sync mode (route-table=254). */ @@ -316,9 +316,9 @@ typedef struct _NMDeviceClass { * only the devices type and characteristics. Does not use any live * network information like Wi-Fi scan lists etc. */ - gboolean (*check_connection_compatible)(NMDevice * self, + gboolean (*check_connection_compatible)(NMDevice *self, NMConnection *connection, - GError ** error); + GError **error); /* Checks whether the connection is likely available to be activated, * including any live network information like scan lists. The connection @@ -331,17 +331,17 @@ typedef struct _NMDeviceClass { * * Specifying @specific_object can only reduce the availability of a connection. */ - gboolean (*check_connection_available)(NMDevice * self, - NMConnection * connection, + gboolean (*check_connection_available)(NMDevice *self, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error); + const char *specific_object, + GError **error); - gboolean (*complete_connection)(NMDevice * self, - NMConnection * connection, - const char * specific_object, + gboolean (*complete_connection)(NMDevice *self, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error); + GError **error); NMActStageReturn (*act_stage1_prepare)(NMDevice *self, NMDeviceStateReason *out_failure_reason); NMActStageReturn (*act_stage2_config)(NMDevice *self, NMDeviceStateReason *out_failure_reason); @@ -351,8 +351,8 @@ typedef struct _NMDeviceClass { const char *(*get_ip_method_auto)(NMDevice *self, int addr_family); /* Async deactivating (in the DEACTIVATING phase) */ - void (*deactivate_async)(NMDevice * self, - GCancellable * cancellable, + void (*deactivate_async)(NMDevice *self, + GCancellable *cancellable, NMDeviceDeactivateCallback callback, gpointer user_data); @@ -368,13 +368,13 @@ typedef struct _NMDeviceClass { /* Update the connection with currently configured L2 settings */ void (*update_connection)(NMDevice *device, NMConnection *connection); - gboolean (*master_update_slave_connection)(NMDevice * self, - NMDevice * slave, + gboolean (*master_update_slave_connection)(NMDevice *self, + NMDevice *slave, NMConnection *connection, - GError ** error); + GError **error); - gboolean (*enslave_slave)(NMDevice * self, - NMDevice * slave, + gboolean (*enslave_slave)(NMDevice *self, + NMDevice *slave, NMConnection *connection, gboolean configure); @@ -392,12 +392,12 @@ typedef struct _NMDeviceClass { gboolean (*unmanaged_on_quit)(NMDevice *self); - gboolean (*can_reapply_change)(NMDevice * self, + gboolean (*can_reapply_change)(NMDevice *self, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error); + GError **error); void (*reapply_connection)(NMDevice *self, NMConnection *con_old, NMConnection *con_new); @@ -416,8 +416,8 @@ typedef struct _NMDeviceClass { GType nm_device_get_type(void); struct _NMDedupMultiIndex *nm_device_get_multi_index(NMDevice *self); -NMNetns * nm_device_get_netns(NMDevice *self); -NMPlatform * nm_device_get_platform(NMDevice *self); +NMNetns *nm_device_get_netns(NMDevice *self); +NMPlatform *nm_device_get_platform(NMDevice *self); const char *nm_device_get_udi(NMDevice *dev); const char *nm_device_get_iface(NMDevice *dev); @@ -433,13 +433,13 @@ _nm_device_get_iface(NMDevice *device) int nm_device_get_ifindex(NMDevice *dev); gboolean nm_device_is_software(NMDevice *dev); gboolean nm_device_is_real(NMDevice *dev); -const char * nm_device_get_ip_iface(NMDevice *dev); -const char * nm_device_get_ip_iface_from_platform(NMDevice *dev); +const char *nm_device_get_ip_iface(NMDevice *dev); +const char *nm_device_get_ip_iface_from_platform(NMDevice *dev); int nm_device_get_ip_ifindex(const NMDevice *dev); -const char * nm_device_get_driver(NMDevice *dev); -const char * nm_device_get_driver_version(NMDevice *dev); -const char * nm_device_get_type_desc(NMDevice *dev); -const char * nm_device_get_type_description(NMDevice *dev); +const char *nm_device_get_driver(NMDevice *dev); +const char *nm_device_get_driver_version(NMDevice *dev); +const char *nm_device_get_type_desc(NMDevice *dev); +const char *nm_device_get_type_description(NMDevice *dev); NMDeviceType nm_device_get_device_type(NMDevice *dev); NMLinkType nm_device_get_link_type(NMDevice *dev); NMMetered nm_device_get_metered(NMDevice *dev); @@ -471,7 +471,7 @@ gboolean nm_device_parent_notify_changed(NMDevice *self, NMDevice *change_candidate, gboolean device_removed); -const char *nm_device_parent_find_for_connection(NMDevice * self, +const char *nm_device_parent_find_for_connection(NMDevice *self, const char *current_setting_parent); /* Master */ @@ -480,11 +480,11 @@ gboolean nm_device_is_master(NMDevice *dev); /* Slave */ NMDevice *nm_device_get_master(NMDevice *dev); -NMActRequest * nm_device_get_act_request(NMDevice *dev); -NMSettingsConnection * nm_device_get_settings_connection(NMDevice *dev); -NMConnection * nm_device_get_settings_connection_get_connection(NMDevice *self); -NMConnection * nm_device_get_applied_connection(NMDevice *dev); -gboolean nm_device_has_unmodified_applied_connection(NMDevice * self, +NMActRequest *nm_device_get_act_request(NMDevice *dev); +NMSettingsConnection *nm_device_get_settings_connection(NMDevice *dev); +NMConnection *nm_device_get_settings_connection_get_connection(NMDevice *self); +NMConnection *nm_device_get_applied_connection(NMDevice *dev); +gboolean nm_device_has_unmodified_applied_connection(NMDevice *self, NMSettingCompareFlags compare_flags); NMActivationStateFlags nm_device_get_activation_state_flags(NMDevice *self); @@ -500,21 +500,21 @@ gboolean nm_device_has_carrier(NMDevice *dev); NMConnection *nm_device_generate_connection(NMDevice *self, NMDevice *master, gboolean *out_maybe_later, - GError ** error); + GError **error); -gboolean nm_device_master_update_slave_connection(NMDevice * master, - NMDevice * slave, +gboolean nm_device_master_update_slave_connection(NMDevice *master, + NMDevice *slave, NMConnection *connection, - GError ** error); + GError **error); gboolean nm_device_can_auto_connect(NMDevice *self, NMSettingsConnection *sett_conn, char **specific_object); -gboolean nm_device_complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +gboolean nm_device_complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error); + GError **error); gboolean nm_device_check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error); @@ -613,11 +613,11 @@ gboolean nm_device_get_managed(NMDevice *device, gboolean for_user_reque NMUnmanagedFlags nm_device_get_unmanaged_mask(NMDevice *device, NMUnmanagedFlags flag); NMUnmanagedFlags nm_device_get_unmanaged_flags(NMDevice *device, NMUnmanagedFlags flag); void nm_device_set_unmanaged_flags(NMDevice *device, NMUnmanagedFlags flags, NMUnmanFlagOp set_op); -void nm_device_set_unmanaged_by_flags(NMDevice * device, +void nm_device_set_unmanaged_by_flags(NMDevice *device, NMUnmanagedFlags flags, NMUnmanFlagOp set_op, NMDeviceStateReason reason); -void nm_device_set_unmanaged_by_flags_queue(NMDevice * self, +void nm_device_set_unmanaged_by_flags_queue(NMDevice *self, NMUnmanagedFlags flags, NMUnmanFlagOp set_op, NMDeviceStateReason reason); @@ -634,26 +634,26 @@ gboolean nm_device_has_capability(NMDevice *self, NMDeviceCapabilities caps); /*****************************************************************************/ -void nm_device_assume_state_get(NMDevice * self, - gboolean * out_assume_state_guess_assume, +void nm_device_assume_state_get(NMDevice *self, + gboolean *out_assume_state_guess_assume, const char **out_assume_state_connection_uuid); void nm_device_assume_state_reset(NMDevice *self); /*****************************************************************************/ -gboolean nm_device_realize_start(NMDevice * device, +gboolean nm_device_realize_start(NMDevice *device, const NMPlatformLink *plink, gboolean assume_state_guess_assume, - const char * assume_state_connection_uuid, + const char *assume_state_connection_uuid, gboolean set_nm_owned, NMUnmanFlagOp unmanaged_user_explicit, - gboolean * out_compatible, - GError ** error); + gboolean *out_compatible, + GError **error); void nm_device_realize_finish(NMDevice *self, const NMPlatformLink *plink); -gboolean nm_device_create_and_realize(NMDevice * self, +gboolean nm_device_create_and_realize(NMDevice *self, NMConnection *connection, - NMDevice * parent, - GError ** error); + NMDevice *parent, + GError **error); gboolean nm_device_unrealize(NMDevice *device, gboolean remove_resources, GError **error); void nm_device_update_from_platform_link(NMDevice *self, const NMPlatformLink *plink); @@ -679,7 +679,7 @@ typedef enum { NMDeviceAutoconnectBlockedFlags nm_device_autoconnect_blocked_get(NMDevice *device, NMDeviceAutoconnectBlockedFlags mask); -void nm_device_autoconnect_blocked_set_full(NMDevice * device, +void nm_device_autoconnect_blocked_set_full(NMDevice *device, NMDeviceAutoconnectBlockedFlags mask, NMDeviceAutoconnectBlockedFlags values); @@ -710,7 +710,7 @@ void nm_device_queue_state(NMDevice *self, NMDeviceState state, NMDeviceStateRea gboolean nm_device_get_firmware_missing(NMDevice *self); -void nm_device_disconnect_active_connection(NMActiveConnection * active, +void nm_device_disconnect_active_connection(NMActiveConnection *active, NMDeviceStateReason device_reason, NMActiveConnectionStateReason active_reason); @@ -733,11 +733,11 @@ nm_device_has_pending_action(NMDevice *device) NMSettingsConnection * nm_device_get_best_connection(NMDevice *device, const char *specific_object, GError **error); -gboolean nm_device_check_connection_available(NMDevice * device, - NMConnection * connection, +gboolean nm_device_check_connection_available(NMDevice *device, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error); + const char *specific_object, + GError **error); void nm_device_notify_availability_maybe_changed(NMDevice *self); @@ -761,24 +761,24 @@ guint nm_device_get_supplicant_timeout(NMDevice *self); gboolean nm_device_auth_retries_try_next(NMDevice *self); -gboolean nm_device_hw_addr_get_cloned(NMDevice * self, +gboolean nm_device_hw_addr_get_cloned(NMDevice *self, NMConnection *connection, gboolean is_wifi, - char ** hwaddr, - gboolean * preserve, - GError ** error); + char **hwaddr, + gboolean *preserve, + GError **error); typedef struct _NMDeviceConnectivityHandle NMDeviceConnectivityHandle; -typedef void (*NMDeviceConnectivityCallback)(NMDevice * self, +typedef void (*NMDeviceConnectivityCallback)(NMDevice *self, NMDeviceConnectivityHandle *handle, NMConnectivityState state, - GError * error, + GError *error, gpointer user_data); void nm_device_check_connectivity_update_interval(NMDevice *self); -NMDeviceConnectivityHandle *nm_device_check_connectivity(NMDevice * self, +NMDeviceConnectivityHandle *nm_device_check_connectivity(NMDevice *self, int addr_family, NMDeviceConnectivityCallback callback, gpointer user_data); @@ -793,16 +793,16 @@ typedef void (*NMBtVTableRegisterCallback)(GError *error, gpointer user_data); struct _NMBtVTableNetworkServer { gboolean (*is_available)(const NMBtVTableNetworkServer *vtable, - const char * addr, - NMDevice * device_accept_busy); + const char *addr, + NMDevice *device_accept_busy); gboolean (*register_bridge)(const NMBtVTableNetworkServer *vtable, - const char * addr, - NMDevice * device, - GCancellable * cancellable, + const char *addr, + NMDevice *device, + GCancellable *cancellable, NMBtVTableRegisterCallback callback, gpointer callback_user_data, - GError ** error); + GError **error); gboolean (*unregister_bridge)(const NMBtVTableNetworkServer *vtable, NMDevice *device); }; diff --git a/src/core/devices/nm-lldp-listener.c b/src/core/devices/nm-lldp-listener.c index 4e178491f7..137bf8fbfe 100644 --- a/src/core/devices/nm-lldp-listener.c +++ b/src/core/devices/nm-lldp-listener.c @@ -34,7 +34,7 @@ struct _NMLldpListener { sd_lldp_rx *lldp_handle; GHashTable *lldp_neighbors; - GVariant * variant; + GVariant *variant; NMLldpListenerNotify notify_callback; gpointer notify_user_data; @@ -49,10 +49,10 @@ struct _NMLldpListener { /*****************************************************************************/ typedef struct { - GVariant * variant; + GVariant *variant; sd_lldp_neighbor *neighbor_sd; - char * chassis_id; - char * port_id; + char *chassis_id; + char *port_id; guint8 chassis_id_type; guint8 port_id_type; } LldpNeighbor; @@ -112,12 +112,12 @@ lldp_neighbor_get_raw(LldpNeighbor *neigh, const guint8 **out_raw_data, gsize *o static gboolean lldp_neighbor_id_get(struct sd_lldp_neighbor *neighbor_sd, - guint8 * out_chassis_id_type, - const guint8 ** out_chassis_id, - gsize * out_chassis_id_len, - guint8 * out_port_id_type, - const guint8 ** out_port_id, - gsize * out_port_id_len) + guint8 *out_chassis_id_type, + const guint8 **out_chassis_id, + gsize *out_chassis_id_len, + guint8 *out_port_id_type, + const guint8 **out_port_id, + gsize *out_port_id_len) { int r; @@ -144,8 +144,8 @@ lldp_neighbor_id_hash(gconstpointer ptr) const LldpNeighbor *neigh = ptr; guint8 chassis_id_type; guint8 port_id_type; - const guint8 * chassis_id; - const guint8 * port_id; + const guint8 *chassis_id; + const guint8 *port_id; gsize chassis_id_len; gsize port_id_len; NMHashState h; @@ -270,9 +270,9 @@ parse_management_address_tlv(const uint8_t *data, gsize len) { GVariantBuilder builder; gsize addr_len; - const guint8 * v_object_id_arr; + const guint8 *v_object_id_arr; gsize v_object_id_len; - const guint8 * v_address_arr; + const guint8 *v_address_arr; gsize v_address_len; guint32 v_interface_number; guint32 v_interface_number_subtype; @@ -393,7 +393,7 @@ format_string(const guint8 *data, gsize len, gboolean allow_trim, char **out_to_ static char * format_string_cp(const guint8 *data, gsize len, gboolean allow_trim) { - char * s_free = NULL; + char *s_free = NULL; const char *s; s = format_string(data, len, allow_trim, &s_free); @@ -482,11 +482,11 @@ lldp_neighbor_to_variant(LldpNeighbor *neigh) { struct ether_addr destination_address; GVariantBuilder builder; - const char * str; - const guint8 * raw_data; + const char *str; + const guint8 *raw_data; gsize raw_len; uint16_t u16; - uint8_t * data8; + uint8_t *data8; gsize len; int r; @@ -537,19 +537,19 @@ lldp_neighbor_to_variant(LldpNeighbor *neigh) else { gboolean v_management_addresses_has = FALSE; GVariantBuilder v_management_addresses; - GVariant * v_ieee_802_1_pvid = NULL; - GVariant * v_ieee_802_1_ppvid = NULL; - GVariant * v_ieee_802_1_ppvid_flags = NULL; + GVariant *v_ieee_802_1_pvid = NULL; + GVariant *v_ieee_802_1_ppvid = NULL; + GVariant *v_ieee_802_1_ppvid_flags = NULL; GVariantBuilder v_ieee_802_1_ppvids; - GVariant * v_ieee_802_1_vid = NULL; - GVariant * v_ieee_802_1_vlan_name = NULL; + GVariant *v_ieee_802_1_vid = NULL; + GVariant *v_ieee_802_1_vlan_name = NULL; GVariantBuilder v_ieee_802_1_vlans; - GVariant * v_ieee_802_3_mac_phy_conf = NULL; - GVariant * v_ieee_802_3_power_via_mdi = NULL; - GVariant * v_ieee_802_3_max_frame_size = NULL; - GVariant * v_mud_url = NULL; + GVariant *v_ieee_802_3_mac_phy_conf = NULL; + GVariant *v_ieee_802_3_power_via_mdi = NULL; + GVariant *v_ieee_802_3_max_frame_size = NULL; + GVariant *v_mud_url = NULL; GVariantBuilder tmp_builder; - GVariant * tmp_variant; + GVariant *tmp_variant; do { guint8 oui[3]; @@ -636,7 +636,7 @@ lldp_neighbor_to_variant(LldpNeighbor *neigh) case SD_LLDP_OUI_802_1_SUBTYPE_VLAN_NAME: { gs_free char *name_to_free = NULL; - const char * name; + const char *name; guint32 vid; gsize l; @@ -716,7 +716,7 @@ lldp_neighbor_to_variant(LldpNeighbor *neigh) case SD_LLDP_OUI_IANA_SUBTYPE_MUD: if (!v_mud_url) { gs_free char *s_free = NULL; - const char * s; + const char *s; s = format_string(data8, len, TRUE, &s_free); if (s) @@ -778,8 +778,8 @@ GVariant * nmtst_lldp_parse_from_raw(const guint8 *raw_data, gsize raw_len) { nm_auto(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *neighbor_sd = NULL; - nm_auto(lldp_neighbor_freep) LldpNeighbor * neigh = NULL; - GVariant * variant; + nm_auto(lldp_neighbor_freep) LldpNeighbor *neigh = NULL; + GVariant *variant; int r; g_assert(raw_data); @@ -846,7 +846,7 @@ static void process_lldp_neighbor(NMLldpListener *self, sd_lldp_neighbor *neighbor_sd, gboolean remove) { nm_auto(lldp_neighbor_freep) LldpNeighbor *neigh = NULL; - LldpNeighbor * neigh_old; + LldpNeighbor *neigh_old; nm_assert(self); nm_assert(self->lldp_handle); @@ -933,10 +933,10 @@ NMLldpListener * nm_lldp_listener_new(int ifindex, NMLldpListenerNotify notify_callback, gpointer notify_user_data, - GError ** error) + GError **error) { NMLldpListener *self = NULL; - sd_lldp_rx * lldp_handle; + sd_lldp_rx *lldp_handle; int r; g_return_val_if_fail(ifindex > 0, FALSE); diff --git a/src/core/devices/nm-lldp-listener.h b/src/core/devices/nm-lldp-listener.h index 762eb3d21a..f2e9bcd203 100644 --- a/src/core/devices/nm-lldp-listener.h +++ b/src/core/devices/nm-lldp-listener.h @@ -13,7 +13,7 @@ typedef void (*NMLldpListenerNotify)(NMLldpListener *self, gpointer user_data); NMLldpListener *nm_lldp_listener_new(int ifindex, NMLldpListenerNotify notify_callback, gpointer notify_user_data, - GError ** error); + GError **error); void nm_lldp_listener_destroy(NMLldpListener *self); int nm_lldp_listener_get_ifindex(NMLldpListener *self); diff --git a/src/core/devices/ovs/nm-device-ovs-bridge.c b/src/core/devices/ovs/nm-device-ovs-bridge.c index 1fe298cfa1..683ada1339 100644 --- a/src/core/devices/ovs/nm-device-ovs-bridge.c +++ b/src/core/devices/ovs/nm-device-ovs-bridge.c @@ -42,11 +42,11 @@ get_type_description(NMDevice *device) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { /* The actual backing resources will be created on enslavement by the port * when it can identify the port and the bridge. */ @@ -144,7 +144,7 @@ static void nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass) { NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_ovs_bridge); diff --git a/src/core/devices/ovs/nm-device-ovs-interface.c b/src/core/devices/ovs/nm-device-ovs-interface.c index 672e95f18b..74707d2482 100644 --- a/src/core/devices/ovs/nm-device-ovs-interface.c +++ b/src/core/devices/ovs/nm-device-ovs-interface.c @@ -49,11 +49,11 @@ get_type_description(NMDevice *device) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { /* The actual backing resources will be created once an interface is * added to a port of ours, since there can be neither an empty port nor @@ -71,7 +71,7 @@ get_generic_capabilities(NMDevice *device) static gboolean is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { - NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device); + NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); return nm_ovsdb_is_ready(priv->ovsdb); @@ -80,7 +80,7 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) static gboolean can_auto_connect(NMDevice *device, NMSettingsConnection *sett_conn, char **specific_object) { - NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device); + NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); return nm_ovsdb_is_ready(priv->ovsdb); @@ -154,7 +154,7 @@ _is_internal_interface(NMDevice *device) static void set_platform_mtu_cb(GError *error, gpointer user_data) { - NMDevice * device = user_data; + NMDevice *device = user_data; NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device); if (error && !g_error_matches(error, NM_UTILS_ERROR, NM_UTILS_ERROR_CANCELLED_DISPOSING)) { @@ -170,7 +170,7 @@ set_platform_mtu_cb(GError *error, gpointer user_data) static gboolean set_platform_mtu(NMDevice *device, guint32 mtu) { - NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device); + NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); /* @@ -202,7 +202,7 @@ ready_for_ip_config(NMDevice *device) static void act_stage3_ip_config(NMDevice *device, int addr_family) { - NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device); + NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); if (!_is_internal_interface(device)) { @@ -241,15 +241,15 @@ can_unmanaged_external_down(NMDevice *self) static void deactivate(NMDevice *device) { - NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device); + NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); priv->waiting_for_interface = FALSE; } typedef struct { - NMDeviceOvsInterface * self; - GCancellable * cancellable; + NMDeviceOvsInterface *self; + GCancellable *cancellable; NMDeviceDeactivateCallback callback; gpointer callback_user_data; gulong link_changed_id; @@ -275,14 +275,14 @@ deactivate_invoke_cb(DeactivateData *data, GError *error) } static void -deactivate_link_changed_cb(NMPlatform * platform, +deactivate_link_changed_cb(NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *info, int change_type_i, DeactivateData *data) { - NMDeviceOvsInterface * self = data->self; + NMDeviceOvsInterface *self = data->self; const NMPlatformSignalChangeType change_type = change_type_i; if (change_type == NM_PLATFORM_SIGNAL_REMOVED @@ -297,7 +297,7 @@ deactivate_link_changed_cb(NMPlatform * platform, static gboolean deactivate_link_timeout(gpointer user_data) { - DeactivateData * data = user_data; + DeactivateData *data = user_data; NMDeviceOvsInterface *self = data->self; _LOGT(LOGD_DEVICE, "deactivate: timeout waiting link removal"); @@ -317,7 +317,7 @@ deactivate_cancelled_cb(GCancellable *cancellable, gpointer user_data) static void deactivate_cb_on_idle(gpointer user_data, GCancellable *cancellable) { - DeactivateData *data = user_data; + DeactivateData *data = user_data; gs_free_error GError *cancelled_error = NULL; g_cancellable_set_error_if_cancelled(data->cancellable, &cancelled_error); @@ -325,14 +325,14 @@ deactivate_cb_on_idle(gpointer user_data, GCancellable *cancellable) } static void -deactivate_async(NMDevice * device, - GCancellable * cancellable, +deactivate_async(NMDevice *device, + GCancellable *cancellable, NMDeviceDeactivateCallback callback, gpointer callback_user_data) { - NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device); + NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); - DeactivateData * data; + DeactivateData *data; _LOGT(LOGD_CORE, "deactivate: start async"); @@ -419,7 +419,7 @@ nm_device_ovs_interface_init(NMDeviceOvsInterface *self) static void dispose(GObject *object) { - NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(object); + NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(object); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); if (priv->ovsdb) { @@ -437,9 +437,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_ovs_interface = { static void nm_device_ovs_interface_class_init(NMDeviceOvsInterfaceClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->dispose = dispose; diff --git a/src/core/devices/ovs/nm-device-ovs-port.c b/src/core/devices/ovs/nm-device-ovs-port.c index 9ed03b3d43..b0a32b4771 100644 --- a/src/core/devices/ovs/nm-device-ovs-port.c +++ b/src/core/devices/ovs/nm-device-ovs-port.c @@ -41,11 +41,11 @@ get_type_description(NMDevice *device) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { /* The port will be added to ovsdb when an interface is enslaved, * because there's no such thing like an empty port. */ @@ -90,10 +90,10 @@ add_iface_cb(GError *error, gpointer user_data) static gboolean enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure) { - NMDeviceOvsPort * self = NM_DEVICE_OVS_PORT(device); + NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device); NMActiveConnection *ac_port = NULL; NMActiveConnection *ac_bridge = NULL; - NMDevice * bridge_device; + NMDevice *bridge_device; if (!configure) return TRUE; @@ -177,7 +177,7 @@ static void nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass) { NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_ovs_port); diff --git a/src/core/devices/ovs/nm-ovs-factory.c b/src/core/devices/ovs/nm-ovs-factory.c index 14f8526387..795435968d 100644 --- a/src/core/devices/ovs/nm-ovs-factory.c +++ b/src/core/devices/ovs/nm-ovs-factory.c @@ -61,7 +61,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES( NM_SETTING_OVS_PORT_SETTING_NAME)) G_MODULE_EXPORT NMDeviceFactory * - nm_device_factory_create(GError **error) +nm_device_factory_create(GError **error) { nm_manager_set_capability(NM_MANAGER_GET, NM_CAPABILITY_OVS); return g_object_new(NM_TYPE_OVS_FACTORY, NULL); @@ -106,14 +106,14 @@ new_device_from_type(const char *name, NMDeviceType device_type) } static void -ovsdb_device_added(NMOvsdb * ovsdb, - const char * name, +ovsdb_device_added(NMOvsdb *ovsdb, + const char *name, guint device_type_i, - const char * subtype, + const char *subtype, NMDeviceFactory *self) { const NMDeviceType device_type = device_type_i; - NMDevice * device; + NMDevice *device; if (device_type == NM_DEVICE_TYPE_OVS_INTERFACE && !NM_IN_STRSET(subtype, "internal", "patch")) { @@ -133,14 +133,14 @@ ovsdb_device_added(NMOvsdb * ovsdb, } static void -ovsdb_device_removed(NMOvsdb * ovsdb, - const char * name, +ovsdb_device_removed(NMOvsdb *ovsdb, + const char *name, guint device_type_i, - const char * subtype, + const char *subtype, NMDeviceFactory *self) { const NMDeviceType device_type = device_type_i; - NMDevice * device = NULL; + NMDevice *device = NULL; NMDeviceState device_state; gboolean is_system_interface = FALSE; @@ -149,8 +149,8 @@ ovsdb_device_removed(NMOvsdb * ovsdb, return; if (device_type == NM_DEVICE_TYPE_OVS_INTERFACE && nm_streq0(subtype, "system")) { - NMDevice * d; - const CList * list; + NMDevice *d; + const CList *list; NMSettingOvsInterface *s_ovs_int; /* The device associated to an OVS system interface can be of @@ -192,16 +192,16 @@ ovsdb_device_removed(NMOvsdb * ovsdb, } static void -ovsdb_interface_failed(NMOvsdb * ovsdb, - const char * name, - const char * connection_uuid, - const char * error, +ovsdb_interface_failed(NMOvsdb *ovsdb, + const char *name, + const char *connection_uuid, + const char *error, NMDeviceFactory *self) { - NMDevice * device = NULL; - NMSettingsConnection * connection = NULL; - NMConnection * c; - const char * type; + NMDevice *device = NULL; + NMSettingsConnection *connection = NULL; + NMConnection *c; + const char *type; NMSettingOvsInterface *s_ovs_int; gboolean is_patch = FALSE; gboolean ignore; @@ -271,14 +271,14 @@ start(NMDeviceFactory *self) } static NMDevice * -create_device(NMDeviceFactory * self, - const char * iface, +create_device(NMDeviceFactory *self, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { NMDeviceType device_type = NM_DEVICE_TYPE_UNKNOWN; - const char * connection_type = NULL; + const char *connection_type = NULL; if (g_strcmp0(iface, "ovs-system") == 0) { *out_ignore = TRUE; diff --git a/src/core/devices/ovs/nm-ovsdb.c b/src/core/devices/ovs/nm-ovsdb.c index f4fe14f1b1..dfc0b2be82 100644 --- a/src/core/devices/ovs/nm-ovsdb.c +++ b/src/core/devices/ovs/nm-ovsdb.c @@ -30,34 +30,34 @@ #endif typedef struct { - char * port_uuid; - char * name; - char * connection_uuid; + char *port_uuid; + char *name; + char *connection_uuid; GPtrArray *interfaces; /* interface uuids */ - GArray * external_ids; + GArray *external_ids; } OpenvswitchPort; typedef struct { - char * bridge_uuid; - char * name; - char * connection_uuid; + char *bridge_uuid; + char *name; + char *connection_uuid; GPtrArray *ports; /* port uuids */ - GArray * external_ids; + GArray *external_ids; } OpenvswitchBridge; typedef struct { - char * interface_uuid; - char * name; - char * type; - char * connection_uuid; + char *interface_uuid; + char *name; + char *type; + char *connection_uuid; GArray *external_ids; } OpenvswitchInterface; /*****************************************************************************/ typedef void (*OvsdbMethodCallback)(NMOvsdb *self, - json_t * response, - GError * error, + json_t *response, + GError *error, gpointer user_data); typedef enum { @@ -77,27 +77,27 @@ typedef union { NMConnection *bridge; NMConnection *port; NMConnection *interface; - NMDevice * bridge_device; - NMDevice * interface_device; + NMDevice *bridge_device; + NMDevice *interface_device; } add_interface; struct { char *ifname; } del_interface; struct { - char * ifname; + char *ifname; guint32 mtu; } set_interface_mtu; struct { NMDeviceType device_type; - char * ifname; - char * connection_uuid; - GHashTable * exid_old; - GHashTable * exid_new; + char *ifname; + char *connection_uuid; + GHashTable *exid_old; + GHashTable *exid_new; } set_external_ids; } OvsdbMethodPayload; typedef struct { - NMOvsdb * self; + NMOvsdb *self; CList calls_lst; guint64 call_id; OvsdbCommand command; @@ -120,11 +120,11 @@ static guint signals[LAST_SIGNAL] = {0}; typedef struct { GSocketConnection *conn; - GCancellable * conn_cancellable; + GCancellable *conn_cancellable; char buf[4096]; /* Input buffer */ size_t bufp; /* Last decoded byte in the input buffer. */ - GString * input; /* JSON stream waiting for decoding. */ - GString * output; /* JSON stream to be sent. */ + GString *input; /* JSON stream waiting for decoding. */ + GString *output; /* JSON stream to be sent. */ guint64 call_id_counter; CList calls_lst_head; @@ -132,7 +132,7 @@ typedef struct { GHashTable *interfaces; /* interface uuid => OpenvswitchInterface */ GHashTable *ports; /* port uuid => OpenvswitchPort */ GHashTable *bridges; /* bridge uuid => OpenvswitchBridge */ - char * db_uuid; + char *db_uuid; guint num_failures; guint num_pending_deletions; bool ready : 1; @@ -328,25 +328,25 @@ _free_interface(OpenvswitchInterface *ovs_interface) /*****************************************************************************/ static void -_signal_emit_device_added(NMOvsdb * self, - const char * name, +_signal_emit_device_added(NMOvsdb *self, + const char *name, NMDeviceType device_type, - const char * device_subtype) + const char *device_subtype) { g_signal_emit(self, signals[DEVICE_ADDED], 0, name, (guint) device_type, device_subtype); } static void -_signal_emit_device_removed(NMOvsdb * self, - const char * name, +_signal_emit_device_removed(NMOvsdb *self, + const char *name, NMDeviceType device_type, - const char * device_subtype) + const char *device_subtype) { g_signal_emit(self, signals[DEVICE_REMOVED], 0, name, (guint) device_type, device_subtype); } static void -_signal_emit_interface_failed(NMOvsdb * self, +_signal_emit_interface_failed(NMOvsdb *self, const char *name, const char *connection_uuid, const char *error) @@ -363,14 +363,14 @@ _signal_emit_interface_failed(NMOvsdb * self, * there's no command pending completion. */ static void -ovsdb_call_method(NMOvsdb * self, +ovsdb_call_method(NMOvsdb *self, OvsdbMethodCallback callback, gpointer user_data, gboolean add_first, OvsdbCommand command, const OvsdbMethodPayload *payload) { - NMOvsdbPrivate * priv = NM_OVSDB_GET_PRIVATE(self); + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); OvsdbMethodCall *call; /* Ensure we're not unsynchronized before we queue the method call. */ @@ -653,11 +653,11 @@ _set_port_interfaces(json_t *params, const char *ifname, json_t *new_interfaces) static json_t * _j_create_external_ids_array_new(NMConnection *connection) { - json_t * array; - const char *const * external_ids = NULL; + json_t *array; + const char *const *external_ids = NULL; guint n_external_ids = 0; guint i; - const char * uuid; + const char *uuid; NMSettingOvsExternalIDs *s_exid; nm_assert(NM_IS_CONNECTION(connection)); @@ -688,10 +688,10 @@ _j_create_external_ids_array_update(const char *connection_uuid, GHashTable *exid_new) { GHashTableIter iter; - json_t * mutations; - json_t * array; - const char * key; - const char * val; + json_t *mutations; + json_t *array; + const char *key; + const char *val; nm_assert(connection_uuid); @@ -744,17 +744,17 @@ _j_create_external_ids_array_update(const char *connection_uuid, * Returns an commands that adds new interface from a given connection. */ static void -_insert_interface(json_t * params, +_insert_interface(json_t *params, NMConnection *interface, - NMDevice * interface_device, - const char * cloned_mac) + NMDevice *interface_device, + const char *cloned_mac) { - const char * type = NULL; + const char *type = NULL; NMSettingOvsInterface *s_ovs_iface; - NMSettingOvsDpdk * s_ovs_dpdk; - NMSettingOvsPatch * s_ovs_patch; - json_t * options = json_array(); - json_t * row; + NMSettingOvsDpdk *s_ovs_dpdk; + NMSettingOvsPatch *s_ovs_patch; + json_t *options = json_array(); + json_t *row; guint32 mtu = 0; s_ovs_iface = nm_connection_get_setting_ovs_interface(interface); @@ -825,13 +825,13 @@ static void _insert_port(json_t *params, NMConnection *port, json_t *new_interfaces) { NMSettingOvsPort *s_ovs_port; - const char * vlan_mode = NULL; + const char *vlan_mode = NULL; guint tag = 0; - const char * lacp = NULL; - const char * bond_mode = NULL; + const char *lacp = NULL; + const char *bond_mode = NULL; guint bond_updelay = 0; guint bond_downdelay = 0; - json_t * row; + json_t *row; s_ovs_port = nm_connection_get_setting_ovs_port(port); @@ -882,19 +882,19 @@ _insert_port(json_t *params, NMConnection *port, json_t *new_interfaces) * Returns an commands that adds new bridge from a given connection. */ static void -_insert_bridge(json_t * params, +_insert_bridge(json_t *params, NMConnection *bridge, - NMDevice * bridge_device, - json_t * new_ports, - const char * cloned_mac) + NMDevice *bridge_device, + json_t *new_ports, + const char *cloned_mac) { NMSettingOvsBridge *s_ovs_bridge; - const char * fail_mode = NULL; + const char *fail_mode = NULL; gboolean mcast_snooping_enable = FALSE; gboolean rstp_enable = FALSE; gboolean stp_enable = FALSE; - const char * datapath_type = NULL; - json_t * row; + const char *datapath_type = NULL; + json_t *row; s_ovs_bridge = nm_connection_get_setting_ovs_bridge(bridge); @@ -974,24 +974,24 @@ _inc_next_cfg(const char *db_uuid) * a parent @port and @bridge if needed. */ static void -_add_interface(NMOvsdb * self, - json_t * params, +_add_interface(NMOvsdb *self, + json_t *params, NMConnection *bridge, NMConnection *port, NMConnection *interface, - NMDevice * bridge_device, - NMDevice * interface_device) + NMDevice *bridge_device, + NMDevice *interface_device) { - NMOvsdbPrivate * priv = NM_OVSDB_GET_PRIVATE(self); - GHashTableIter iter; - const char * port_uuid; - const char * interface_uuid; - const char * bridge_name; - const char * port_name; - const char * interface_name; - OpenvswitchBridge * ovs_bridge = NULL; - OpenvswitchPort * ovs_port = NULL; - OpenvswitchInterface *ovs_interface = NULL; + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); + GHashTableIter iter; + const char *port_uuid; + const char *interface_uuid; + const char *bridge_name; + const char *port_name; + const char *interface_name; + OpenvswitchBridge *ovs_bridge = NULL; + OpenvswitchPort *ovs_port = NULL; + OpenvswitchInterface *ovs_interface = NULL; nm_auto_decref_json json_t *bridges = NULL; nm_auto_decref_json json_t *new_bridges = NULL; nm_auto_decref_json json_t *ports = NULL; @@ -1000,9 +1000,9 @@ _add_interface(NMOvsdb * self, nm_auto_decref_json json_t *new_interfaces = NULL; gboolean has_interface = FALSE; gboolean interface_is_local; - gs_free char * bridge_cloned_mac = NULL; - gs_free char * interface_cloned_mac = NULL; - GError * error = NULL; + gs_free char *bridge_cloned_mac = NULL; + gs_free char *interface_cloned_mac = NULL; + GError *error = NULL; int pi; int ii; @@ -1159,13 +1159,13 @@ _add_interface(NMOvsdb * self, static void _delete_interface(NMOvsdb *self, json_t *params, const char *ifname) { - NMOvsdbPrivate * priv = NM_OVSDB_GET_PRIVATE(self); - GHashTableIter iter; - char * port_uuid; - char * interface_uuid; - OpenvswitchBridge * ovs_bridge; - OpenvswitchPort * ovs_port; - OpenvswitchInterface *ovs_interface; + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); + GHashTableIter iter; + char *port_uuid; + char *interface_uuid; + OpenvswitchBridge *ovs_bridge; + OpenvswitchPort *ovs_port; + OpenvswitchInterface *ovs_interface; nm_auto_decref_json json_t *bridges = NULL; nm_auto_decref_json json_t *new_bridges = NULL; gboolean bridges_changed; @@ -1269,9 +1269,9 @@ _delete_interface(NMOvsdb *self, json_t *params, const char *ifname) static void ovsdb_next_command(NMOvsdb *self) { - NMOvsdbPrivate * priv = NM_OVSDB_GET_PRIVATE(self); - OvsdbMethodCall * call; - char * cmd; + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); + OvsdbMethodCall *call; + char *cmd; nm_auto_decref_json json_t *msg = NULL; if (!priv->conn) @@ -1417,9 +1417,9 @@ static void _uuids_to_array_inplace(GPtrArray *array, const json_t *items) { const char *key; - json_t * value; + json_t *value; size_t index = 0; - json_t * set_value; + json_t *set_value; size_t set_index; while (index < json_array_size(items)) { @@ -1472,8 +1472,8 @@ _external_ids_extract(json_t *external_ids, GArray **out_array, const char **out array = json_array_get(external_ids, 1); json_array_foreach (array, index, value) { - const char * key = json_string_value(json_array_get(value, 0)); - const char * val = json_string_value(json_array_get(value, 1)); + const char *key = json_string_value(json_array_get(value, 0)); + const char *val = json_string_value(json_array_get(value, 1)); NMUtilsNamedValue *v; if (!key || !val) @@ -1556,20 +1556,20 @@ static void ovsdb_got_update(NMOvsdb *self, json_t *msg) { NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); - json_t * ovs = NULL; - json_t * bridge = NULL; - json_t * port = NULL; - json_t * interface = NULL; - json_t * items; - json_t * external_ids; + json_t *ovs = NULL; + json_t *bridge = NULL; + json_t *port = NULL; + json_t *interface = NULL; + json_t *items; + json_t *external_ids; json_error_t json_error = { 0, }; - void * iter; + void *iter; const char *name; const char *key; const char *type; - json_t * value; + json_t *value; if (json_unpack_ex(msg, &json_error, @@ -1599,10 +1599,10 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) } json_object_foreach (interface, key, value) { - OpenvswitchInterface *ovs_interface; + OpenvswitchInterface *ovs_interface; gs_unref_array GArray *external_ids_arr = NULL; - const char * connection_uuid = NULL; - json_t * error = NULL; + const char *connection_uuid = NULL; + json_t *error = NULL; int r; r = json_unpack(value, @@ -1723,10 +1723,10 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) json_object_foreach (port, key, value) { gs_unref_ptrarray GPtrArray *interfaces = NULL; - OpenvswitchPort * ovs_port; - gs_unref_array GArray *external_ids_arr = NULL; - const char * connection_uuid = NULL; - int r; + OpenvswitchPort *ovs_port; + gs_unref_array GArray *external_ids_arr = NULL; + const char *connection_uuid = NULL; + int r; r = json_unpack(value, "{s:{s:s, s:o, s:o}}", @@ -1824,10 +1824,10 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) json_object_foreach (bridge, key, value) { gs_unref_ptrarray GPtrArray *ports = NULL; - OpenvswitchBridge * ovs_bridge; - gs_unref_array GArray *external_ids_arr = NULL; - const char * connection_uuid = NULL; - int r; + OpenvswitchBridge *ovs_bridge; + gs_unref_array GArray *external_ids_arr = NULL; + const char *connection_uuid = NULL; + int r; r = json_unpack(value, "{s:{s:s, s:o, s:o}}", @@ -1937,9 +1937,9 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) static void ovsdb_got_echo(NMOvsdb *self, json_int_t id, json_t *data) { - NMOvsdbPrivate * priv = NM_OVSDB_GET_PRIVATE(self); - nm_auto_decref_json json_t *msg = NULL; - char * reply; + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); + nm_auto_decref_json json_t *msg = NULL; + char *reply; gboolean output_was_empty; output_was_empty = priv->output->len == 0; @@ -1966,12 +1966,12 @@ ovsdb_got_msg(NMOvsdb *self, json_t *msg) json_error_t json_error = { 0, }; - json_t * json_id = NULL; + json_t *json_id = NULL; json_int_t id = (json_int_t) -1; const char *method = NULL; - json_t * params = NULL; - json_t * result = NULL; - json_t * error = NULL; + json_t *params = NULL; + json_t *result = NULL; + json_t *error = NULL; if (json_unpack_ex(msg, &json_error, @@ -2017,9 +2017,9 @@ ovsdb_got_msg(NMOvsdb *self, json_t *msg) } if (id >= 0) { - OvsdbMethodCall *call; + OvsdbMethodCall *call; gs_free_error GError *local = NULL; - gs_free char * msg_as_str = NULL; + gs_free char *msg_as_str = NULL; /* This is a response to a method call. */ if (c_list_is_empty(&priv->calls_lst_head)) { @@ -2075,7 +2075,7 @@ ovsdb_got_msg(NMOvsdb *self, json_t *msg) static size_t _json_callback(void *buffer, size_t buflen, void *user_data) { - NMOvsdb * self = NM_OVSDB(user_data); + NMOvsdb *self = NM_OVSDB(user_data); NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); if (priv->bufp == priv->input->len) { @@ -2099,12 +2099,12 @@ _json_callback(void *buffer, size_t buflen, void *user_data) static void ovsdb_read_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMOvsdb * self = NM_OVSDB(user_data); + NMOvsdb *self = NM_OVSDB(user_data); NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); - GInputStream * stream = G_INPUT_STREAM(source_object); - GError * error = NULL; + GInputStream *stream = G_INPUT_STREAM(source_object); + GError *error = NULL; gssize size; - json_t * msg; + json_t *msg; json_error_t json_error = { 0, }; @@ -2157,10 +2157,10 @@ ovsdb_read(NMOvsdb *self) static void ovsdb_write_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - GOutputStream * stream = G_OUTPUT_STREAM(source_object); - NMOvsdb * self = NM_OVSDB(user_data); + GOutputStream *stream = G_OUTPUT_STREAM(source_object); + NMOvsdb *self = NM_OVSDB(user_data); NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); - GError * error = NULL; + GError *error = NULL; gssize size; size = g_output_stream_write_finish(stream, res, &error); @@ -2185,7 +2185,7 @@ static void ovsdb_write(NMOvsdb *self) { NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); - GOutputStream * stream; + GOutputStream *stream; if (!priv->output->len) return; @@ -2218,7 +2218,7 @@ ovsdb_write(NMOvsdb *self) static void ovsdb_disconnect(NMOvsdb *self, gboolean retry, gboolean is_disposing) { - NMOvsdbPrivate * priv = NM_OVSDB_GET_PRIVATE(self); + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); OvsdbMethodCall *call; nm_assert(!retry || !is_disposing); @@ -2275,8 +2275,8 @@ _check_ready(NMOvsdb *self) static void _del_initial_iface_cb(GError *error, gpointer user_data) { - NMOvsdb * self; - gs_free char * ifname = NULL; + NMOvsdb *self; + gs_free char *ifname = NULL; NMOvsdbPrivate *priv; nm_utils_user_data_unpack(user_data, &self, &ifname); @@ -2302,9 +2302,9 @@ _del_initial_iface_cb(GError *error, gpointer user_data) static void ovsdb_cleanup_initial_interfaces(NMOvsdb *self) { - NMOvsdbPrivate * priv = NM_OVSDB_GET_PRIVATE(self); + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); const OpenvswitchInterface *interface; - NMUtilsUserData * data; + NMUtilsUserData *data; GHashTableIter iter; if (priv->ready || priv->num_pending_deletions != 0) @@ -2349,9 +2349,9 @@ _monitor_bridges_cb(NMOvsdb *self, json_t *result, GError *error, gpointer user_ static void _ovsdb_connect_complete_with_fd(NMOvsdb *self, int fd_take) { - NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); gs_unref_object GSocket *socket = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; socket = g_socket_new_from_fd(nm_steal_fd(&fd_take), &error); if (!socket) { @@ -2371,7 +2371,7 @@ static void _ovsdb_connect_sudo_cb(int fd_take, GError *error, gpointer user_data) { nm_auto_close int fd = fd_take; - NMOvsdb * self; + NMOvsdb *self; if (nm_utils_error_is_cancelled(error)) return; @@ -2391,9 +2391,9 @@ _ovsdb_connect_sudo_cb(int fd_take, GError *error, gpointer user_data) static void _ovsdb_connect_idle(gpointer user_data, GCancellable *cancellable) { - NMOvsdb * self; - NMOvsdbPrivate * priv; - nm_auto_close int fd = -1; + NMOvsdb *self; + NMOvsdbPrivate *priv; + nm_auto_close int fd = -1; gs_free_error GError *error = NULL; if (g_cancellable_is_cancelled(cancellable)) @@ -2465,11 +2465,11 @@ typedef struct { static void _transact_cb(NMOvsdb *self, json_t *result, GError *error, gpointer user_data) { - OvsdbCall * call = user_data; + OvsdbCall *call = user_data; const char *err; const char *err_details; size_t index; - json_t * value; + json_t *value; if (error) goto out; @@ -2513,12 +2513,12 @@ nm_ovsdb_is_ready(NMOvsdb *self) } void -nm_ovsdb_add_interface(NMOvsdb * self, - NMConnection * bridge, - NMConnection * port, - NMConnection * interface, - NMDevice * bridge_device, - NMDevice * interface_device, +nm_ovsdb_add_interface(NMOvsdb *self, + NMConnection *bridge, + NMConnection *port, + NMConnection *interface, + NMDevice *bridge_device, + NMDevice *interface_device, NMOvsdbCallback callback, gpointer user_data) { @@ -2535,8 +2535,8 @@ nm_ovsdb_add_interface(NMOvsdb * self, } void -nm_ovsdb_del_interface(NMOvsdb * self, - const char * ifname, +nm_ovsdb_del_interface(NMOvsdb *self, + const char *ifname, NMOvsdbCallback callback, gpointer user_data) { @@ -2549,8 +2549,8 @@ nm_ovsdb_del_interface(NMOvsdb * self, } void -nm_ovsdb_set_interface_mtu(NMOvsdb * self, - const char * ifname, +nm_ovsdb_set_interface_mtu(NMOvsdb *self, + const char *ifname, guint32 mtu, NMOvsdbCallback callback, gpointer user_data) @@ -2564,10 +2564,10 @@ nm_ovsdb_set_interface_mtu(NMOvsdb * self, } void -nm_ovsdb_set_external_ids(NMOvsdb * self, +nm_ovsdb_set_external_ids(NMOvsdb *self, NMDeviceType device_type, - const char * ifname, - const char * connection_uuid, + const char *ifname, + const char *connection_uuid, NMSettingOvsExternalIDs *s_exid_old, NMSettingOvsExternalIDs *s_exid_new) { @@ -2615,7 +2615,7 @@ nm_ovsdb_init(NMOvsdb *self) static void dispose(GObject *object) { - NMOvsdb * self = NM_OVSDB(object); + NMOvsdb *self = NM_OVSDB(object); NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); ovsdb_disconnect(self, FALSE, TRUE); diff --git a/src/core/devices/ovs/nm-ovsdb.h b/src/core/devices/ovs/nm-ovsdb.h index d0b4d19d45..a50db45a28 100644 --- a/src/core/devices/ovs/nm-ovsdb.h +++ b/src/core/devices/ovs/nm-ovsdb.h @@ -27,32 +27,32 @@ NMOvsdb *nm_ovsdb_get(void); GType nm_ovsdb_get_type(void); -void nm_ovsdb_add_interface(NMOvsdb * self, - NMConnection * bridge, - NMConnection * port, - NMConnection * interface, - NMDevice * bridge_device, - NMDevice * interface_device, +void nm_ovsdb_add_interface(NMOvsdb *self, + NMConnection *bridge, + NMConnection *port, + NMConnection *interface, + NMDevice *bridge_device, + NMDevice *interface_device, NMOvsdbCallback callback, gpointer user_data); -void nm_ovsdb_del_interface(NMOvsdb * self, - const char * ifname, +void nm_ovsdb_del_interface(NMOvsdb *self, + const char *ifname, NMOvsdbCallback callback, gpointer user_data); -void nm_ovsdb_set_interface_mtu(NMOvsdb * self, - const char * ifname, +void nm_ovsdb_set_interface_mtu(NMOvsdb *self, + const char *ifname, guint32 mtu, NMOvsdbCallback callback, gpointer user_data); struct _NMSettingOvsExternalIDs; -void nm_ovsdb_set_external_ids(NMOvsdb * self, +void nm_ovsdb_set_external_ids(NMOvsdb *self, NMDeviceType device_type, - const char * ifname, - const char * connection_uuid, + const char *ifname, + const char *connection_uuid, struct _NMSettingOvsExternalIDs *s_exid_old, struct _NMSettingOvsExternalIDs *s_exid_new); diff --git a/src/core/devices/team/nm-device-team.c b/src/core/devices/team/nm-device-team.c index 7ec7305118..16cd2e8715 100644 --- a/src/core/devices/team/nm-device-team.c +++ b/src/core/devices/team/nm-device-team.c @@ -33,15 +33,15 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDeviceTeam, PROP_CONFIG, ); typedef struct { - struct teamdctl * tdc; - char * config; + struct teamdctl *tdc; + char *config; GPid teamd_pid; guint teamd_process_watch; guint teamd_timeout; guint teamd_read_timeout; guint teamd_dbus_watch; bool kill_in_progress : 1; - GFileMonitor * usock_monitor; + GFileMonitor *usock_monitor; NMDeviceStageState stage1_state : 3; } NMDeviceTeamPrivate; @@ -72,11 +72,11 @@ get_generic_capabilities(NMDevice *device) } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { nm_utils_complete_generic(nm_device_get_platform(device), connection, @@ -96,7 +96,7 @@ complete_connection(NMDevice * device, static gboolean ensure_teamd_connection(NMDevice *device) { - NMDeviceTeam * self = NM_DEVICE_TEAM(device); + NMDeviceTeam *self = NM_DEVICE_TEAM(device); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); int err; @@ -125,7 +125,7 @@ static gboolean teamd_read_config(NMDeviceTeam *self) { NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); - const char * config = NULL; + const char *config = NULL; int err; if (priv->tdc) { @@ -150,7 +150,7 @@ teamd_read_config(NMDeviceTeam *self) static gboolean teamd_read_timeout_cb(gpointer user_data) { - NMDeviceTeam * self = user_data; + NMDeviceTeam *self = user_data; NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); priv->teamd_read_timeout = 0; @@ -161,10 +161,10 @@ teamd_read_timeout_cb(gpointer user_data) static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceTeam * self = NM_DEVICE_TEAM(device); - NMSettingTeam * s_team = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_TEAM); + NMDeviceTeam *self = NM_DEVICE_TEAM(device); + NMSettingTeam *s_team = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_TEAM); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); - struct teamdctl * tdc = priv->tdc; + struct teamdctl *tdc = priv->tdc; /* Read the configuration only if not already set */ if (!priv->config && ensure_teamd_connection(device)) @@ -183,18 +183,18 @@ update_connection(NMDevice *device, NMConnection *connection) /*****************************************************************************/ static gboolean -master_update_slave_connection(NMDevice * self, - NMDevice * slave, +master_update_slave_connection(NMDevice *self, + NMDevice *slave, NMConnection *connection, - GError ** error) + GError **error) { NMSettingTeamPort *s_port; - char * port_config = NULL; + char *port_config = NULL; int err = 0; - struct teamdctl * tdc; - const char * team_port_config = NULL; - const char * iface = nm_device_get_iface(self); - const char * iface_slave = nm_device_get_iface(slave); + struct teamdctl *tdc; + const char *team_port_config = NULL; + const char *iface = nm_device_get_iface(self); + const char *iface_slave = nm_device_get_iface(slave); tdc = teamdctl_alloc(); if (!tdc) { @@ -259,7 +259,7 @@ static void teamd_kill_cb(pid_t pid, gboolean success, int child_status, void *user_data) { gs_unref_object NMDeviceTeam *self = user_data; - NMDeviceTeamPrivate * priv = NM_DEVICE_TEAM_GET_PRIVATE(self); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); priv->kill_in_progress = FALSE; @@ -307,8 +307,8 @@ teamd_cleanup(NMDeviceTeam *self, gboolean free_tdc) static gboolean teamd_timeout_cb(gpointer user_data) { - NMDeviceTeam * self = NM_DEVICE_TEAM(user_data); - NMDevice * device = NM_DEVICE(self); + NMDeviceTeam *self = NM_DEVICE_TEAM(user_data); + NMDevice *device = NM_DEVICE(self); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); g_return_val_if_fail(priv->teamd_timeout, FALSE); @@ -342,7 +342,7 @@ static void teamd_ready(NMDeviceTeam *self) { NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); gboolean success; if (priv->kill_in_progress) { @@ -381,7 +381,7 @@ teamd_ready(NMDeviceTeam *self) static void teamd_gone(NMDeviceTeam *self) { - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceState state; teamd_cleanup(self, TRUE); @@ -399,11 +399,11 @@ teamd_gone(NMDeviceTeam *self) static void teamd_dbus_appeared(GDBusConnection *connection, - const char * name, - const char * name_owner, + const char *name, + const char *name_owner, gpointer user_data) { - NMDeviceTeam * self = NM_DEVICE_TEAM(user_data); + NMDeviceTeam *self = NM_DEVICE_TEAM(user_data); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); g_return_if_fail(priv->teamd_dbus_watch); @@ -451,7 +451,7 @@ teamd_dbus_appeared(GDBusConnection *connection, static void teamd_dbus_vanished(GDBusConnection *dbus_connection, const char *name, gpointer user_data) { - NMDeviceTeam * self = NM_DEVICE_TEAM(user_data); + NMDeviceTeam *self = NM_DEVICE_TEAM(user_data); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); g_return_if_fail(priv->teamd_dbus_watch); @@ -471,9 +471,9 @@ teamd_dbus_vanished(GDBusConnection *dbus_connection, const char *name, gpointer } static void -monitor_changed_cb(GFileMonitor * monitor, - GFile * file, - GFile * other_file, +monitor_changed_cb(GFileMonitor *monitor, + GFile *file, + GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { @@ -495,9 +495,9 @@ monitor_changed_cb(GFileMonitor * monitor, static void teamd_process_watch_cb(GPid pid, int status, gpointer user_data) { - NMDeviceTeam * self = NM_DEVICE_TEAM(user_data); + NMDeviceTeam *self = NM_DEVICE_TEAM(user_data); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceState state = nm_device_get_state(device); g_return_if_fail(priv->teamd_process_watch); @@ -545,8 +545,8 @@ static gboolean teamd_kill(NMDeviceTeam *self, const char *teamd_binary, GError **error) { gs_unref_ptrarray GPtrArray *argv = NULL; - gs_free char * tmp_str = NULL; - gs_free const char ** envp = NULL; + gs_free char *tmp_str = NULL; + gs_free const char **envp = NULL; if (!teamd_binary) { teamd_binary = nm_utils_find_helper("teamd", NULL, error); @@ -581,18 +581,18 @@ teamd_kill(NMDeviceTeam *self, const char *teamd_binary, GError **error) static gboolean teamd_start(NMDeviceTeam *self) { - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); - const char * iface = nm_device_get_ip_iface(NM_DEVICE(self)); - NMConnection * connection; - gs_unref_ptrarray GPtrArray *argv = NULL; - gs_free_error GError * error = NULL; - gs_free char * tmp_str = NULL; - const char * teamd_binary; - const char * config; - nm_auto_free const char *config_free = NULL; - NMSettingTeam * s_team; - gs_free char * cloned_mac = NULL; - gs_free const char ** envp = NULL; + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); + const char *iface = nm_device_get_ip_iface(NM_DEVICE(self)); + NMConnection *connection; + gs_unref_ptrarray GPtrArray *argv = NULL; + gs_free_error GError *error = NULL; + gs_free char *tmp_str = NULL; + const char *teamd_binary; + const char *config; + nm_auto_free const char *config_free = NULL; + NMSettingTeam *s_team; + gs_free char *cloned_mac = NULL; + gs_free const char **envp = NULL; connection = nm_device_get_applied_connection(NM_DEVICE(self)); @@ -639,7 +639,7 @@ teamd_start(NMDeviceTeam *self) } if (cloned_mac) { - json_t * json, *hwaddr; + json_t *json, *hwaddr; json_error_t jerror; /* Inject the hwaddr property into the JSON configuration. @@ -706,11 +706,11 @@ teamd_start(NMDeviceTeam *self) static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceTeam * self = NM_DEVICE_TEAM(device); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); + NMDeviceTeam *self = NM_DEVICE_TEAM(device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); gs_free_error GError *error = NULL; - NMSettingTeam * s_team; - const char * cfg; + NMSettingTeam *s_team; + const char *cfg; if (nm_device_sys_iface_state_is_external(device)) return NM_ACT_STAGE_RETURN_SUCCESS; @@ -773,7 +773,7 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) static void deactivate(NMDevice *device) { - NMDeviceTeam * self = NM_DEVICE_TEAM(device); + NMDeviceTeam *self = NM_DEVICE_TEAM(device); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); priv->stage1_state = NM_DEVICE_STAGE_STATE_INIT; @@ -793,11 +793,11 @@ deactivate(NMDevice *device) static gboolean enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure) { - NMDeviceTeam * self = NM_DEVICE_TEAM(device); + NMDeviceTeam *self = NM_DEVICE_TEAM(device); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); gboolean success = TRUE; - const char * slave_iface = nm_device_get_ip_iface(slave); - NMSettingTeamPort * s_team_port; + const char *slave_iface = nm_device_get_ip_iface(slave); + NMSettingTeamPort *s_team_port; nm_device_master_check_slave_physical_port(device, slave, LOGD_TEAM); @@ -851,10 +851,10 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool static void release_slave(NMDevice *device, NMDevice *slave, gboolean configure) { - NMDeviceTeam * self = NM_DEVICE_TEAM(device); + NMDeviceTeam *self = NM_DEVICE_TEAM(device); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); gboolean do_release, success; - NMSettingTeamPort * s_port; + NMSettingTeamPort *s_port; int ifindex_slave; int ifindex; @@ -901,11 +901,11 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure) } static gboolean -create_and_realize(NMDevice * device, - NMConnection * connection, - NMDevice * parent, +create_and_realize(NMDevice *device, + NMConnection *connection, + NMDevice *parent, const NMPlatformLink **out_plink, - GError ** error) + GError **error) { const char *iface = nm_device_get_iface(device); int r; @@ -953,11 +953,11 @@ nm_device_team_init(NMDeviceTeam *self) static void constructed(GObject *object) { - NMDevice * device = NM_DEVICE(object); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(device); - gs_free char * tmp_str = NULL; - gs_unref_object GFile *file = NULL; - GError * error; + NMDevice *device = NM_DEVICE(object); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(device); + gs_free char *tmp_str = NULL; + gs_unref_object GFile *file = NULL; + GError *error; G_OBJECT_CLASS(nm_device_team_parent_class)->constructed(object); @@ -1005,7 +1005,7 @@ nm_device_team_new(const char *iface) static void dispose(GObject *object) { - NMDeviceTeam * self = NM_DEVICE_TEAM(object); + NMDeviceTeam *self = NM_DEVICE_TEAM(object); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); if (priv->teamd_dbus_watch) { @@ -1039,9 +1039,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_team = { static void nm_device_team_class_init(NMDeviceTeamClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; object_class->dispose = dispose; diff --git a/src/core/devices/team/nm-team-factory.c b/src/core/devices/team/nm-team-factory.c index e2040d19fd..b446cbd089 100644 --- a/src/core/devices/team/nm-team-factory.c +++ b/src/core/devices/team/nm-team-factory.c @@ -43,7 +43,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES(NM_DEVICE_FACTORY_DECLARE_LINK_TYPES( NM_LINK_TYPE_TEAM) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_TEAM_SETTING_NAME)) G_MODULE_EXPORT NMDeviceFactory * - nm_device_factory_create(GError **error) +nm_device_factory_create(GError **error) { nm_manager_set_capability(NM_MANAGER_GET, NM_CAPABILITY_TEAM); return g_object_new(NM_TYPE_TEAM_FACTORY, NULL); @@ -52,11 +52,11 @@ G_MODULE_EXPORT NMDeviceFactory * /*****************************************************************************/ static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { return nm_device_team_new(iface); } diff --git a/src/core/devices/tests/test-lldp.c b/src/core/devices/tests/test-lldp.c index c64c7c1140..048410c14a 100644 --- a/src/core/devices/tests/test-lldp.c +++ b/src/core/devices/tests/test-lldp.c @@ -22,15 +22,15 @@ /*****************************************************************************/ static GVariant * -get_lldp_neighbor(GVariant * neighbors, +get_lldp_neighbor(GVariant *neighbors, int chassis_id_type, const char *chassis_id, int port_id_type, const char *port_id) { GVariantIter iter; - GVariant * variant; - GVariant * result = NULL; + GVariant *variant; + GVariant *result = NULL; nmtst_assert_variant_is_of_type(neighbors, G_VARIANT_TYPE("aa{sv}")); @@ -81,15 +81,15 @@ typedef struct { typedef struct { gsize frame_len; const uint8_t *frame; - const char * as_variant; + const char *as_variant; } TestRecvFrame; #define TEST_RECV_FRAME_DEFINE(name, _as_variant, ...) \ static const guint8 _##name##_v[] = {__VA_ARGS__}; \ static const TestRecvFrame name = { \ - .as_variant = _as_variant, \ - .frame_len = sizeof(_##name##_v), \ - .frame = _##name##_v, \ + .as_variant = _as_variant, \ + .frame_len = sizeof(_##name##_v), \ + .frame = _##name##_v, \ } typedef struct { @@ -183,7 +183,7 @@ TEST_RECV_FRAME_DEFINE( static void _test_recv_data0_check_do(GMainLoop *loop, NMLldpListener *listener, const TestRecvFrame *frame) { - GVariant * neighbors, *attr; + GVariant *neighbors, *attr; gs_unref_variant GVariant *neighbor = NULL; neighbors = nm_lldp_listener_get_neighbors(listener); @@ -537,10 +537,10 @@ TEST_RECV_FRAME_DEFINE( static void _test_recv_data1_check(GMainLoop *loop, NMLldpListener *listener, TestRecvCallbackInfo *info) { - GVariant * neighbors, *attr, *child; + GVariant *neighbors, *attr, *child; gs_unref_variant GVariant *neighbor = NULL; guint v_uint = 0; - const char * v_str = NULL; + const char *v_str = NULL; neighbors = nm_lldp_listener_get_neighbors(listener); nmtst_assert_variant_is_of_type(neighbors, G_VARIANT_TYPE("aa{sv}")); @@ -868,12 +868,12 @@ lldp_neighbors_changed(NMLldpListener *lldp_listener, gpointer user_data) static void test_recv(TestRecvFixture *fixture, gconstpointer user_data) { - const TestRecvData * data = user_data; - NMLldpListener * listener; - GMainLoop * loop; + const TestRecvData *data = user_data; + NMLldpListener *listener; + GMainLoop *loop; TestRecvCallbackInfo info = {}; gsize i_frames; - GError * error = NULL; + GError *error = NULL; guint sd_id; if (fixture->ifindex == 0) { @@ -918,10 +918,10 @@ _test_recv_fixture_teardown(TestRecvFixture *fixture, gconstpointer user_data) static void test_parse_frames(gconstpointer test_data) { - const TestRecvFrame *frame = test_data; + const TestRecvFrame *frame = test_data; gs_unref_variant GVariant *v_neighbor = NULL; gs_unref_variant GVariant *attr = NULL; - gs_free char * as_variant = NULL; + gs_free char *as_variant = NULL; v_neighbor = nmtst_lldp_parse_from_raw(frame->frame, frame->frame_len); g_assert(v_neighbor); diff --git a/src/core/devices/wifi/nm-device-iwd.c b/src/core/devices/wifi/nm-device-iwd.c index 9a1ac8a162..7543d9daf8 100644 --- a/src/core/devices/wifi/nm-device-iwd.c +++ b/src/core/devices/wifi/nm-device-iwd.c @@ -48,14 +48,14 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDeviceIwd, PROP_LAST_SCAN, ); typedef struct { - GDBusObject * dbus_obj; - GDBusProxy * dbus_device_proxy; - GDBusProxy * dbus_station_proxy; - GDBusProxy * dbus_ap_proxy; - GDBusProxy * dbus_adhoc_proxy; + GDBusObject *dbus_obj; + GDBusProxy *dbus_device_proxy; + GDBusProxy *dbus_station_proxy; + GDBusProxy *dbus_ap_proxy; + GDBusProxy *dbus_adhoc_proxy; CList aps_lst_head; - NMWifiAP * current_ap; - GCancellable * cancellable; + NMWifiAP *current_ap; + GCancellable *cancellable; _NMDeviceWifiCapabilities capabilities; NMActRequestGetSecretsCallId *wifi_secrets_id; guint periodic_scan_id; @@ -74,8 +74,8 @@ typedef struct { uint32_t ap_id; guint32 rate; NMEtherAddr current_ap_bssid; - GDBusMethodInvocation * pending_agent_request; - NMActiveConnection * assumed_ac; + GDBusMethodInvocation *pending_agent_request; + NMActiveConnection *assumed_ac; guint assumed_ac_timeout; } NMDeviceIwdPrivate; @@ -120,7 +120,7 @@ _ap_dump(NMDeviceIwd *self, NMLogLevel log_level, const NMWifiAP *ap, const char static void ap_add_remove(NMDeviceIwd *self, gboolean is_adding, /* or else is removing */ - NMWifiAP * ap, + NMWifiAP *ap, gboolean recheck_available_connections) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); @@ -156,7 +156,7 @@ static void set_current_ap(NMDeviceIwd *self, NMWifiAP *new_ap, gboolean recheck_available_connections) { NMDeviceIwdPrivate *priv; - NMWifiAP * old_ap; + NMWifiAP *old_ap; g_return_if_fail(NM_IS_DEVICE_IWD(self)); @@ -186,7 +186,7 @@ static void remove_all_aps(NMDeviceIwd *self) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMWifiAP * ap, *ap_safe; + NMWifiAP *ap, *ap_safe; if (c_list_is_empty(&priv->aps_lst_head)) return; @@ -219,20 +219,20 @@ ap_security_flags_from_network_type(const char *type) static NMWifiAP * ap_from_network(NMDeviceIwd *self, - GDBusProxy * network, + GDBusProxy *network, NMRefString *bss_path, gint64 last_seen_msec, int16_t signal) { - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); gs_unref_variant GVariant *name_value = NULL; gs_unref_variant GVariant *type_value = NULL; - const char * name; - const char * type; + const char *name; + const char *type; uint32_t ap_id; - gs_unref_bytes GBytes *ssid = NULL; - NMWifiAP * ap; - NMSupplicantBssInfo bss_info; + gs_unref_bytes GBytes *ssid = NULL; + NMWifiAP *ap; + NMSupplicantBssInfo bss_info; g_return_val_if_fail(network, NULL); @@ -284,14 +284,14 @@ ap_from_network(NMDeviceIwd *self, static void insert_ap_from_network(NMDeviceIwd *self, - GHashTable * aps, - const char * path, + GHashTable *aps, + const char *path, gint64 last_seen_msec, int16_t signal) { - gs_unref_object GDBusProxy *network_proxy = NULL; - nm_auto_ref_string NMRefString *bss_path = nm_ref_string_new(path); - NMWifiAP * ap; + gs_unref_object GDBusProxy *network_proxy = NULL; + nm_auto_ref_string NMRefString *bss_path = nm_ref_string_new(path); + NMWifiAP *ap; if (g_hash_table_lookup(aps, bss_path)) { _LOGD(LOGD_WIFI, "Duplicate network at %s", path); @@ -311,16 +311,16 @@ insert_ap_from_network(NMDeviceIwd *self, static void get_ordered_networks_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMDeviceIwd * self = user_data; - NMDeviceIwdPrivate *priv; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *variant = NULL; - GVariantIter * networks; - const char * path; - int16_t signal; - NMWifiAP * ap, *ap_safe, *new_ap; - gboolean changed; - GHashTableIter ap_iter; + NMDeviceIwd *self = user_data; + NMDeviceIwdPrivate *priv; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *variant = NULL; + GVariantIter *networks; + const char *path; + int16_t signal; + NMWifiAP *ap, *ap_safe, *new_ap; + gboolean changed; + GHashTableIter ap_iter; gs_unref_hashtable GHashTable *new_aps = NULL; gint64 last_seen_msec; @@ -421,7 +421,7 @@ periodic_update(NMDeviceIwd *self) int percent; NMEtherAddr bssid; gboolean ap_changed = FALSE; - NMPlatform * platform; + NMPlatform *platform; ifindex = nm_device_get_ifindex(NM_DEVICE(self)); if (ifindex <= 0) @@ -528,8 +528,8 @@ cleanup_association_attempt(NMDeviceIwd *self, gboolean disconnect) } static void -reset_mode(NMDeviceIwd * self, - GCancellable * cancellable, +reset_mode(NMDeviceIwd *self, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -575,7 +575,7 @@ get_variant_state(GVariant *v) static void deactivate(NMDevice *device) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); + NMDeviceIwd *self = NM_DEVICE_IWD(device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); if (!priv->dbus_obj) @@ -608,8 +608,8 @@ disconnect_cb(GObject *source, GAsyncResult *res, gpointer user_data) gs_unref_object NMDeviceIwd *self = NULL; NMDeviceDeactivateCallback callback; gpointer callback_user_data; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_utils_user_data_unpack(user_data, &self, &callback, &callback_user_data); @@ -623,7 +623,7 @@ disconnect_cb_on_idle(gpointer user_data, GCancellable *cancellable) gs_unref_object NMDeviceIwd *self = NULL; NMDeviceDeactivateCallback callback; gpointer callback_user_data; - gs_free_error GError *cancelled_error = NULL; + gs_free_error GError *cancelled_error = NULL; nm_utils_user_data_unpack(user_data, &self, &callback, &callback_user_data); @@ -632,12 +632,12 @@ disconnect_cb_on_idle(gpointer user_data, GCancellable *cancellable) } static void -deactivate_async(NMDevice * device, - GCancellable * cancellable, +deactivate_async(NMDevice *device, + GCancellable *cancellable, NMDeviceDeactivateCallback callback, gpointer callback_user_data) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); + NMDeviceIwd *self = NM_DEVICE_IWD(device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); gpointer user_data; @@ -676,7 +676,7 @@ static gboolean is_connection_known_network(NMConnection *connection) { NMIwdNetworkSecurity security; - gs_free char * ssid = NULL; + gs_free char *ssid = NULL; if (!nm_wifi_connection_get_iwd_ssid_and_security(connection, &ssid, &security)) return FALSE; @@ -688,7 +688,7 @@ static gboolean is_ap_known_network(NMWifiAP *ap) { gs_unref_object GDBusProxy *network_proxy = NULL; - gs_unref_variant GVariant *known_network = NULL; + gs_unref_variant GVariant *known_network = NULL; network_proxy = nm_iwd_manager_get_dbus_interface(nm_iwd_manager_get(), @@ -704,17 +704,17 @@ is_ap_known_network(NMWifiAP *ap) static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); - NMDeviceIwdPrivate * priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMSettingWireless * s_wireless; - const char * mac; - const char *const * mac_blacklist; + NMDeviceIwd *self = NM_DEVICE_IWD(device); + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMSettingWireless *s_wireless; + const char *mac; + const char *const *mac_blacklist; int i; - const char * perm_hw_addr; - const char * mode; + const char *perm_hw_addr; + const char *mode; NMIwdNetworkSecurity security; - GBytes * ssid; - const guint8 * ssid_bytes; + GBytes *ssid; + const guint8 *ssid_bytes; gsize ssid_len; if (!NM_DEVICE_CLASS(nm_device_iwd_parent_class) @@ -860,17 +860,17 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -check_connection_available(NMDevice * device, - NMConnection * connection, +check_connection_available(NMDevice *device, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); - NMDeviceIwdPrivate * priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMSettingWireless * s_wifi; - const char * mode; - NMWifiAP * ap = NULL; + NMDeviceIwd *self = NM_DEVICE_IWD(device); + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMSettingWireless *s_wifi; + const char *mode; + NMWifiAP *ap = NULL; NMIwdNetworkSecurity security; s_wifi = nm_connection_get_setting_wireless(connection); @@ -952,20 +952,20 @@ iwd_ssid_to_str(const GBytes *ssid) } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); + NMDeviceIwd *self = NM_DEVICE_IWD(device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMSettingWireless * s_wifi; - gs_free char * ssid_utf8 = NULL; - NMWifiAP * ap; - GBytes * ssid = NULL; + NMSettingWireless *s_wifi; + gs_free char *ssid_utf8 = NULL; + NMWifiAP *ap; + GBytes *ssid = NULL; gboolean hidden = FALSE; - const char * mode; + const char *mode; s_wifi = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIRELESS); @@ -1059,7 +1059,7 @@ complete_connection(NMDevice * device, static gboolean is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); + NMDeviceIwd *self = NM_DEVICE_IWD(device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); NMDeviceState state = nm_device_get_state(device); @@ -1088,12 +1088,12 @@ get_autoconnect_allowed(NMDevice *device) static gboolean can_auto_connect(NMDevice *device, NMSettingsConnection *sett_conn, char **specific_object) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); + NMDeviceIwd *self = NM_DEVICE_IWD(device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMConnection * connection; - NMSettingWireless * s_wifi; - NMWifiAP * ap; - const char * mode; + NMConnection *connection; + NMSettingWireless *s_wifi; + NMWifiAP *ap; + const char *mode; guint64 timestamp = 0; nm_assert(!specific_object || !*specific_object); @@ -1141,10 +1141,10 @@ _nm_device_iwd_get_aps(NMDeviceIwd *self) static void scan_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMDeviceIwd * self = user_data; - NMDeviceIwdPrivate *priv; + NMDeviceIwd *self = user_data; + NMDeviceIwdPrivate *priv; gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; variant = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error); if (!variant && nm_utils_error_is_cancelled(error)) @@ -1165,14 +1165,14 @@ scan_cb(GObject *source, GAsyncResult *res, gpointer user_data) } static void -dbus_request_scan_cb(NMDevice * device, +dbus_request_scan_cb(NMDevice *device, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer user_data) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); - NMDeviceIwdPrivate *priv; + NMDeviceIwd *self = NM_DEVICE_IWD(device); + NMDeviceIwdPrivate *priv; gs_unref_variant GVariant *scan_options = user_data; if (error) { @@ -1229,7 +1229,7 @@ void _nm_device_iwd_request_scan(NMDeviceIwd *self, GVariant *options, GDBusMethodInvocation *invocation) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); if (!priv->can_scan) { g_dbus_method_invocation_return_error_literal(invocation, @@ -1283,7 +1283,7 @@ static const char * get_agent_request_network_path(GDBusMethodInvocation *invocation) { const char *method_name = g_dbus_method_invocation_get_method_name(invocation); - GVariant * params = g_dbus_method_invocation_get_parameters(invocation); + GVariant *params = g_dbus_method_invocation_get_parameters(invocation); const char *network_path = NULL; if (nm_streq(method_name, "RequestPassphrase")) @@ -1308,17 +1308,17 @@ get_agent_request_network_path(GDBusMethodInvocation *invocation) * Return TRUE in either case, return FALSE if an error is detected. */ static gboolean -try_reply_agent_request(NMDeviceIwd * self, - NMConnection * connection, +try_reply_agent_request(NMDeviceIwd *self, + NMConnection *connection, GDBusMethodInvocation *invocation, gboolean allow_existing, - const char ** setting_name, - const char ** setting_key, - gboolean * replied) + const char **setting_name, + const char **setting_key, + gboolean *replied) { - const char * method_name = g_dbus_method_invocation_get_method_name(invocation); + const char *method_name = g_dbus_method_invocation_get_method_name(invocation); NMSettingWirelessSecurity *s_wireless_sec; - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; s_wireless_sec = nm_connection_get_setting_wireless_security(connection); s_8021x = nm_connection_get_setting_802_1x(connection); @@ -1418,7 +1418,7 @@ try_reply_agent_request(NMDeviceIwd * self, static gboolean assumed_ac_timeout_cb(gpointer user_data) { - NMDeviceIwd * self = user_data; + NMDeviceIwd *self = user_data; NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); nm_assert(priv->assumed_ac); @@ -1434,30 +1434,30 @@ assumed_ac_timeout_cb(gpointer user_data) return G_SOURCE_REMOVE; } -static void wifi_secrets_get_one(NMDeviceIwd * self, - const char * setting_name, +static void wifi_secrets_get_one(NMDeviceIwd *self, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char * setting_key, - GDBusMethodInvocation * invocation); + const char *setting_key, + GDBusMethodInvocation *invocation); static void -wifi_secrets_cb(NMActRequest * req, +wifi_secrets_cb(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * s_connection, - GError * error, + NMSettingsConnection *s_connection, + GError *error, gpointer user_data) { - NMDeviceIwd * self; - NMDeviceIwdPrivate * priv; - NMDevice * device; - GDBusMethodInvocation * invocation; - const char * setting_name; - const char * setting_key; + NMDeviceIwd *self; + NMDeviceIwdPrivate *priv; + NMDevice *device; + GDBusMethodInvocation *invocation; + const char *setting_name; + const char *setting_key; gboolean replied; NMSecretAgentGetSecretsFlags get_secret_flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; NMIwdNetworkSecurity security; - NMConnection * connection; + NMConnection *connection; nm_utils_user_data_unpack(user_data, &self, &invocation); @@ -1550,14 +1550,14 @@ secrets_error: } static void -wifi_secrets_get_one(NMDeviceIwd * self, - const char * setting_name, +wifi_secrets_get_one(NMDeviceIwd *self, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char * setting_key, - GDBusMethodInvocation * invocation) + const char *setting_key, + GDBusMethodInvocation *invocation) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMActRequest * req; + NMActRequest *req; wifi_secrets_cancel(self); @@ -1576,16 +1576,16 @@ wifi_secrets_get_one(NMDeviceIwd * self, static void network_connect_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMDeviceIwd * self = user_data; - NMDevice * device = NM_DEVICE(self); - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMDeviceIwd *self = user_data; + NMDevice *device = NM_DEVICE(self); + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; - NMConnection * connection; - gs_free char * ssid = NULL; - NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED; - GVariant * value; - gboolean disconnect; + gs_free_error GError *error = NULL; + NMConnection *connection; + gs_free char *ssid = NULL; + NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED; + GVariant *value; + gboolean disconnect; disconnect = !priv->iwd_autoconnect || nm_device_autoconnect_blocked_get(device, NM_DEVICE_AUTOCONNECT_BLOCKED_ALL); @@ -1667,10 +1667,10 @@ failed: static void act_failed_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMDeviceIwd * self = user_data; - NMDevice * device = NM_DEVICE(self); + NMDeviceIwd *self = user_data; + NMDevice *device = NM_DEVICE(self); gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; variant = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error); if (!variant && nm_utils_error_is_cancelled(error)) @@ -1689,12 +1689,12 @@ act_failed_cb(GObject *source, GAsyncResult *res, gpointer user_data) static void act_start_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMDeviceIwd * self = user_data; - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDeviceIwd *self = user_data; + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMDevice *device = NM_DEVICE(self); gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; - gs_free char * ssid = NULL; + gs_free_error GError *error = NULL; + gs_free char *ssid = NULL; variant = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error); if (!variant) { @@ -1736,12 +1736,12 @@ error: static void act_check_interface(NMDeviceIwd *self) { - NMDeviceIwdPrivate * priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); - NMSettingWireless * s_wireless; - GDBusProxy * proxy = NULL; - gs_free char * ssid = NULL; - const char * mode; + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMDevice *device = NM_DEVICE(self); + NMSettingWireless *s_wireless; + GDBusProxy *proxy = NULL; + gs_free char *ssid = NULL; + const char *mode; NMIwdNetworkSecurity security; if (!priv->act_mode_switch) @@ -1780,7 +1780,7 @@ act_check_interface(NMDeviceIwd *self) self); } else if (security == NM_IWD_NETWORK_SECURITY_PSK) { NMSettingWirelessSecurity *s_wireless_sec; - const char * psk; + const char *psk; s_wireless_sec = (NMSettingWirelessSecurity *) nm_device_get_applied_setting( device, @@ -1813,11 +1813,11 @@ failed: static void act_set_mode_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMDeviceIwd * self = user_data; - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDeviceIwd *self = user_data; + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMDevice *device = NM_DEVICE(self); gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; variant = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error); if (!variant) { @@ -1848,10 +1848,10 @@ static void act_set_mode(NMDeviceIwd *self) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); - const char * iwd_mode; - const char * mode; - NMSettingWireless * s_wireless; + NMDevice *device = NM_DEVICE(self); + const char *iwd_mode; + const char *mode; + NMSettingWireless *s_wireless; s_wireless = (NMSettingWireless *) nm_device_get_applied_setting(device, NM_TYPE_SETTING_WIRELESS); @@ -1880,15 +1880,15 @@ act_set_mode(NMDeviceIwd *self) } static void -act_psk_cb(NMActRequest * req, +act_psk_cb(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * s_connection, - GError * error, + NMSettingsConnection *s_connection, + GError *error, gpointer user_data) { - NMDeviceIwd * self = user_data; + NMDeviceIwd *self = user_data; NMDeviceIwdPrivate *priv; - NMDevice * device; + NMDevice *device; if (nm_utils_error_is_cancelled(error)) return; @@ -1944,7 +1944,7 @@ static NMWifiAP * find_ap_by_supplicant_path(NMDeviceIwd *self, const NMRefString *path) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMWifiAP * tmp; + NMWifiAP *tmp; c_list_for_each_entry (tmp, &priv->aps_lst_head, aps_lst) if (nm_wifi_ap_get_supplicant_path(tmp) == path) @@ -1956,7 +1956,7 @@ find_ap_by_supplicant_path(NMDeviceIwd *self, const NMRefString *path) static void assumed_connection_state_changed(NMActiveConnection *active, GParamSpec *pspec, NMDeviceIwd *self) { - NMSettingsConnection * sett_conn = nm_active_connection_get_settings_connection(active); + NMSettingsConnection *sett_conn = nm_active_connection_get_settings_connection(active); NMActiveConnectionState state = nm_active_connection_get_state(active); /* Delete the temporary connection created for an external IWD connection @@ -1983,10 +1983,10 @@ assumed_connection_state_changed(NMActiveConnection *active, GParamSpec *pspec, static void assumed_connection_state_changed_before_managed(NMActiveConnection *active, - GParamSpec * pspec, - NMDeviceIwd * self) + GParamSpec *pspec, + NMDeviceIwd *self) { - NMDeviceIwdPrivate * priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); NMActiveConnectionState state = nm_active_connection_get_state(active); gboolean disconnect; @@ -2020,11 +2020,11 @@ assumed_connection_state_changed_before_managed(NMActiveConnection *active, static void assume_connection(NMDeviceIwd *self, NMWifiAP *ap) { - NMDeviceIwdPrivate * priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMSettingsConnection *sett_conn; + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMSettingsConnection *sett_conn; gs_unref_object NMAuthSubject *subject = NULL; - NMActiveConnection * ac; - gs_free_error GError *error = NULL; + NMActiveConnection *ac; + gs_free_error GError *error = NULL; /* We can use the .update_connection / nm_device_emit_recheck_assume * API but we can also pass an assumed/external activation type @@ -2104,7 +2104,7 @@ static void assumed_connection_progress_to_ip_config(NMDeviceIwd *self, gboolean was_postponed) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceState dev_state = nm_device_get_state(device); wifi_secrets_cancel(self); @@ -2133,11 +2133,11 @@ assumed_connection_progress_to_ip_config(NMDeviceIwd *self, gboolean was_postpon static void initial_check_assume(NMDeviceIwd *self) { - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - const char * network_path_str; + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + const char *network_path_str; nm_auto_ref_string NMRefString *network_path = NULL; - NMWifiAP * ap = NULL; - gs_unref_variant GVariant *state_value = + NMWifiAP *ap = NULL; + gs_unref_variant GVariant *state_value = g_dbus_proxy_get_cached_property(priv->dbus_station_proxy, "State"); gs_unref_variant GVariant *cn_value = g_dbus_proxy_get_cached_property(priv->dbus_station_proxy, "ConnectedNetwork"); @@ -2174,15 +2174,15 @@ initial_check_assume(NMDeviceIwd *self) static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMWifiAP * ap = NULL; + NMDeviceIwd *self = NM_DEVICE_IWD(device); + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMWifiAP *ap = NULL; gs_unref_object NMWifiAP *ap_fake = NULL; - NMActRequest * req; - NMConnection * connection; - NMSettingWireless * s_wireless; - const char * mode; - const char * ap_path; + NMActRequest *req; + NMConnection *connection; + NMSettingWireless *s_wireless; + const char *mode; + const char *ap_path; req = nm_device_get_act_request(device); g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); @@ -2246,12 +2246,12 @@ add_new: static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); + NMDeviceIwd *self = NM_DEVICE_IWD(device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMActRequest * req; - NMConnection * connection; - NMSettingWireless * s_wireless; - const char * mode; + NMActRequest *req; + NMConnection *connection; + NMSettingWireless *s_wireless; + const char *mode; req = nm_device_get_act_request(device); connection = nm_act_request_get_applied_connection(req); @@ -2262,8 +2262,8 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) if (NM_IN_STRSET(mode, NULL, NM_SETTING_WIRELESS_MODE_INFRA)) { gs_unref_object GDBusProxy *network_proxy = NULL; - NMWifiAP * ap = priv->current_ap; - NMSettingWirelessSecurity * s_wireless_sec; + NMWifiAP *ap = priv->current_ap; + NMSettingWirelessSecurity *s_wireless_sec; if (!ap) { NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); @@ -2432,7 +2432,7 @@ get_configured_mtu(NMDevice *device, NMDeviceMtuSource *out_source, gboolean *ou static gboolean periodic_scan_timeout_cb(gpointer user_data) { - NMDeviceIwd * self = user_data; + NMDeviceIwd *self = user_data; NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); priv->periodic_scan_id = 0; @@ -2503,15 +2503,15 @@ set_can_scan(NMDeviceIwd *self, gboolean can_scan) } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); + NMDeviceIwd *self = NM_DEVICE_IWD(device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMSettingWireless * s_wireless; - const char * mode; + NMSettingWireless *s_wireless; + const char *mode; switch (new_state) { case NM_DEVICE_STATE_UNMANAGED: @@ -2559,7 +2559,7 @@ get_enabled(NMDevice *device) static void set_enabled(NMDevice *device, gboolean enabled) { - NMDeviceIwd * self = NM_DEVICE_IWD(device); + NMDeviceIwd *self = NM_DEVICE_IWD(device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); NMDeviceState state; @@ -2596,12 +2596,12 @@ set_enabled(NMDevice *device, gboolean enabled) } static gboolean -can_reapply_change(NMDevice * device, +can_reapply_change(NMDevice *device, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error) + GError **error) { NMDeviceClass *device_class; @@ -2624,9 +2624,9 @@ can_reapply_change(NMDevice * device, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceIwd * self = NM_DEVICE_IWD(object); + NMDeviceIwd *self = NM_DEVICE_IWD(object); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - const char ** list; + const char **list; switch (prop_id) { case PROP_MODE: @@ -2673,18 +2673,18 @@ static void state_changed(NMDeviceIwd *self, const char *new_state) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceState dev_state = nm_device_get_state(device); gboolean nm_connection = priv->current_ap || priv->assumed_ac; gboolean iwd_connection = FALSE; - NMWifiAP * ap = NULL; + NMWifiAP *ap = NULL; gboolean can_connect = priv->nm_autoconnect; _LOGI(LOGD_DEVICE | LOGD_WIFI, "new IWD device state is %s", new_state); if (NM_IN_STRSET(new_state, "connecting", "connected", "roaming")) { - gs_unref_variant GVariant *value = NULL; - const char * network_path_str; + gs_unref_variant GVariant *value = NULL; + const char *network_path_str; nm_auto_ref_string NMRefString *network_path = NULL; value = g_dbus_proxy_get_cached_property(priv->dbus_station_proxy, "ConnectedNetwork"); @@ -2855,12 +2855,12 @@ scanning_changed(NMDeviceIwd *self, gboolean new_scanning) static void station_properties_changed(GDBusProxy *proxy, - GVariant * changed_properties, + GVariant *changed_properties, GStrv invalidate_properties, gpointer user_data) { NMDeviceIwd *self = user_data; - const char * new_str; + const char *new_str; gboolean new_bool; if (g_variant_lookup(changed_properties, "State", "&s", &new_str)) @@ -2872,7 +2872,7 @@ station_properties_changed(GDBusProxy *proxy, static void ap_adhoc_properties_changed(GDBusProxy *proxy, - GVariant * changed_properties, + GVariant *changed_properties, GStrv invalidate_properties, gpointer user_data) { @@ -2889,7 +2889,7 @@ static void powered_changed(NMDeviceIwd *self, gboolean new_powered) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - GDBusInterface * interface; + GDBusInterface *interface; nm_device_queue_recheck_available(NM_DEVICE(self), NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE, @@ -3004,7 +3004,7 @@ powered_changed(NMDeviceIwd *self, gboolean new_powered) static void device_properties_changed(GDBusProxy *proxy, - GVariant * changed_properties, + GVariant *changed_properties, GStrv invalidate_properties, gpointer user_data) { @@ -3016,11 +3016,11 @@ device_properties_changed(GDBusProxy *proxy, } static void -config_changed(NMConfig * config, - NMConfigData * config_data, +config_changed(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, - NMDeviceIwd * self) + NMConfigData *old_data, + NMDeviceIwd *self) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); gboolean old_iwd_ac = priv->iwd_autoconnect; @@ -3048,12 +3048,12 @@ config_changed(NMConfig * config, void nm_device_iwd_set_dbus_object(NMDeviceIwd *self, GDBusObject *object) { - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - GDBusInterface * interface; - gs_unref_variant GVariant *value = NULL; + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + GDBusInterface *interface; + gs_unref_variant GVariant *value = NULL; gs_unref_object GDBusProxy *adapter_proxy = NULL; - GVariantIter * iter; - const char * mode; + GVariantIter *iter; + const char *mode; gboolean powered; _NMDeviceWifiCapabilities capabilities; @@ -3159,18 +3159,18 @@ error: gboolean nm_device_iwd_agent_query(NMDeviceIwd *self, GDBusMethodInvocation *invocation) { - NMDevice * device = NM_DEVICE(self); - NMDeviceIwdPrivate * priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMDevice *device = NM_DEVICE(self); + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); NMDeviceState state = nm_device_get_state(device); - const char * setting_name; - const char * setting_key; + const char *setting_name; + const char *setting_key; gboolean replied; - NMWifiAP * ap; + NMWifiAP *ap; gboolean allow_existing = FALSE; NMSecretAgentGetSecretsFlags get_secret_flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; - NMIwdNetworkSecurity security; - NMConnection * connection; + NMIwdNetworkSecurity security; + NMConnection *connection; nm_auto_ref_string NMRefString *network_path = NULL; if (!invocation) { @@ -3324,9 +3324,9 @@ nm_device_iwd_agent_query(NMDeviceIwd *self, GDBusMethodInvocation *invocation) void nm_device_iwd_network_add_remove(NMDeviceIwd *self, GDBusProxy *network, bool add) { - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - NMWifiAP * ap = NULL; - bool recheck; + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMWifiAP *ap = NULL; + bool recheck; nm_auto_ref_string NMRefString *bss_path = NULL; bss_path = nm_ref_string_new(g_dbus_proxy_get_object_path(network)); @@ -3371,7 +3371,7 @@ nm_device_iwd_network_add_remove(NMDeviceIwd *self, GDBusProxy *network, bool ad static void autoconnect_changed(NMDevice *device, GParamSpec *pspec, NMDeviceIwd *self) { - NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); + NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); gs_unref_variant GVariant *value = NULL; /* Note IWD normally remains in "disconnected" during a secret request @@ -3434,7 +3434,7 @@ nm_device_iwd_new(const char *iface) static void dispose(GObject *object) { - NMDeviceIwd * self = NM_DEVICE_IWD(object); + NMDeviceIwd *self = NM_DEVICE_IWD(object); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); nm_clear_g_cancellable(&priv->cancellable); @@ -3450,9 +3450,9 @@ dispose(GObject *object) static void nm_device_iwd_class_init(NMDeviceIwdClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; object_class->dispose = dispose; diff --git a/src/core/devices/wifi/nm-device-iwd.h b/src/core/devices/wifi/nm-device-iwd.h index ce94c9ea75..bb136bf690 100644 --- a/src/core/devices/wifi/nm-device-iwd.h +++ b/src/core/devices/wifi/nm-device-iwd.h @@ -40,8 +40,8 @@ gboolean nm_device_iwd_agent_query(NMDeviceIwd *device, GDBusMethodInvocation *i const CList *_nm_device_iwd_get_aps(NMDeviceIwd *self); -void _nm_device_iwd_request_scan(NMDeviceIwd * self, - GVariant * options, +void _nm_device_iwd_request_scan(NMDeviceIwd *self, + GVariant *options, GDBusMethodInvocation *invocation); void nm_device_iwd_network_add_remove(NMDeviceIwd *device, GDBusProxy *network, bool add); diff --git a/src/core/devices/wifi/nm-device-olpc-mesh.c b/src/core/devices/wifi/nm-device-olpc-mesh.c index d829f9ae9d..fd851ebc6a 100644 --- a/src/core/devices/wifi/nm-device-olpc-mesh.c +++ b/src/core/devices/wifi/nm-device-olpc-mesh.c @@ -39,7 +39,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDeviceOlpcMesh, PROP_COMPANION, PROP_ACTIVE_CHANNEL, ); typedef struct { - NMDevice * companion; + NMDevice *companion; NMManager *manager; bool stage1_waiting : 1; } NMDeviceOlpcMeshPrivate; @@ -63,7 +63,7 @@ G_DEFINE_TYPE(NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) static gboolean get_autoconnect_allowed(NMDevice *device) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(device); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(device); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); /* We can't even connect if we don't have a companion yet. */ @@ -81,11 +81,11 @@ get_autoconnect_allowed(NMDevice *device) #define DEFAULT_SSID "olpc-mesh" static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMSettingOlpcMesh *s_mesh; @@ -133,7 +133,7 @@ get_dhcp_anycast_address(NMDevice *device) static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(device); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(device); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); /* disconnect companion device, if it is connected */ @@ -183,9 +183,9 @@ _mesh_set_channel(NMDeviceOlpcMesh *self, guint32 channel) static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(device); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(device); NMSettingOlpcMesh *s_mesh; - GBytes * ssid; + GBytes *ssid; gboolean success; s_mesh = nm_device_get_applied_setting(device, NM_TYPE_SETTING_OLPC_MESH); @@ -243,7 +243,7 @@ companion_cleanup(NMDeviceOlpcMesh *self) static void companion_notify_cb(NMDeviceWifi *companion, GParamSpec *pspec, gpointer user_data) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(user_data); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(user_data); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); nm_assert(NM_IS_DEVICE_WIFI(companion)); @@ -260,7 +260,7 @@ companion_notify_cb(NMDeviceWifi *companion, GParamSpec *pspec, gpointer user_da /* disconnect from mesh if someone starts using the companion */ static void -companion_state_changed_cb(NMDeviceWifi * companion, +companion_state_changed_cb(NMDeviceWifi *companion, NMDeviceState state, NMDeviceState old_state, NMDeviceStateReason reason, @@ -299,7 +299,7 @@ static gboolean check_companion(NMDeviceOlpcMesh *self, NMDevice *other) { NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); - const char * my_addr, *their_addr; + const char *my_addr, *their_addr; if (!NM_IS_DEVICE_WIFI(other)) return FALSE; @@ -337,7 +337,7 @@ check_companion(NMDeviceOlpcMesh *self, NMDevice *other) static void device_added_cb(NMManager *manager, NMDevice *other, gpointer user_data) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(user_data); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(user_data); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); if (!priv->companion && check_companion(self, other)) { @@ -363,8 +363,8 @@ static void find_companion(NMDeviceOlpcMesh *self) { NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); - const CList * tmp_lst; - NMDevice * candidate; + const CList *tmp_lst; + NMDevice *candidate; if (priv->companion) return; @@ -386,12 +386,12 @@ find_companion(NMDeviceOlpcMesh *self) } static void -state_changed(NMDevice * device, +state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(device); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(device); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); if (new_state == NM_DEVICE_STATE_UNAVAILABLE) @@ -422,8 +422,8 @@ get_dhcp_timeout_for_device(NMDevice *device, int addr_family) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(object); - NMDevice * device = NM_DEVICE(self); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(object); + NMDevice *device = NM_DEVICE(self); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); switch (prop_id) { @@ -450,7 +450,7 @@ nm_device_olpc_mesh_init(NMDeviceOlpcMesh *self) static void constructed(GObject *object) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(object); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(object); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); G_OBJECT_CLASS(nm_device_olpc_mesh_parent_class)->constructed(object); @@ -479,7 +479,7 @@ nm_device_olpc_mesh_new(const char *iface) static void dispose(GObject *object) { - NMDeviceOlpcMesh * self = NM_DEVICE_OLPC_MESH(object); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH(object); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE(self); companion_cleanup(self); @@ -510,9 +510,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_olpc_mesh = { static void nm_device_olpc_mesh_class_init(NMDeviceOlpcMeshClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; object_class->get_property = get_property; diff --git a/src/core/devices/wifi/nm-device-wifi-p2p.c b/src/core/devices/wifi/nm-device-wifi-p2p.c index ed74d30ec5..4cb76e45e7 100644 --- a/src/core/devices/wifi/nm-device-wifi-p2p.c +++ b/src/core/devices/wifi/nm-device-wifi-p2p.c @@ -82,10 +82,10 @@ static void supplicant_interfaces_release(NMDeviceWifiP2P *self, gboolean set_is /*****************************************************************************/ static void -_peer_dump(NMDeviceWifiP2P * self, +_peer_dump(NMDeviceWifiP2P *self, NMLogLevel log_level, const NMWifiP2PPeer *peer, - const char * prefix, + const char *prefix, gint32 now_s) { char buf[1024]; @@ -100,7 +100,7 @@ _peer_dump(NMDeviceWifiP2P * self, static gboolean peer_list_dump(gpointer user_data) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(user_data); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(user_data); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); priv->peer_dump_id = 0; @@ -153,10 +153,10 @@ static gboolean check_connection_peer_joined(NMDeviceWifiP2P *device) { NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(device); - NMConnection * conn = nm_device_get_applied_connection(NM_DEVICE(device)); - NMWifiP2PPeer * peer; - const char * group; - const char *const * groups; + NMConnection *conn = nm_device_get_applied_connection(NM_DEVICE(device)); + NMWifiP2PPeer *peer; + const char *group; + const char *const *groups; if (!conn || !priv->group_iface) return FALSE; @@ -182,8 +182,8 @@ check_connection_peer_joined(NMDeviceWifiP2P *device) static gboolean disconnect_on_connection_peer_missing_cb(gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); + NMDevice *device = NM_DEVICE(user_data); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); _LOGW(LOGD_WIFI, "Peer requested in connection is missing for too long, failing connection."); @@ -222,8 +222,8 @@ update_disconnect_on_connection_peer_missing(NMDeviceWifiP2P *self) static gboolean is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); - NMDeviceWifiP2PPrivate * priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); NMSupplicantInterfaceState supplicant_state; if (!priv->mgmt_iface) @@ -251,17 +251,17 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); - gs_free char * setting_name = NULL; + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); + gs_free char *setting_name = NULL; NMSettingWifiP2P *s_wifi_p2p; - NMWifiP2PPeer * peer; - const char * setting_peer; + NMWifiP2PPeer *peer; + const char *setting_peer; s_wifi_p2p = NM_SETTING_WIFI_P2P(nm_connection_get_setting(connection, NM_TYPE_SETTING_WIFI_P2P)); @@ -329,8 +329,8 @@ complete_connection(NMDevice * device, static gboolean supplicant_find_timeout_cb(gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(user_data); + NMDevice *device = NM_DEVICE(user_data); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(user_data); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); priv->find_peer_timeout_id = 0; @@ -351,11 +351,11 @@ supplicant_find_timeout_cb(gpointer user_data) static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); - NMConnection * connection; - NMSettingWifiP2P * s_wifi_p2p; - NMWifiP2PPeer * peer; + NMConnection *connection; + NMSettingWifiP2P *s_wifi_p2p; + NMWifiP2PPeer *peer; if (!priv->mgmt_iface) { NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); @@ -393,8 +393,8 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) static gboolean supplicant_connection_timeout_cb(gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(user_data); + NMDevice *device = NM_DEVICE(user_data); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(user_data); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); priv->sup_timeout_id = 0; @@ -415,12 +415,12 @@ supplicant_connection_timeout_cb(gpointer user_data) static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); - NMConnection * connection; - NMSettingWifiP2P * s_wifi_p2p; - NMWifiP2PPeer * peer; - GBytes * wfd_ies; + NMConnection *connection; + NMSettingWifiP2P *s_wifi_p2p; + NMWifiP2PPeer *peer; + GBytes *wfd_ies; if (nm_clear_g_source(&priv->find_peer_timeout_id)) nm_assert_not_reached(); @@ -469,7 +469,7 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) static void emit_signal_p2p_peer_add_remove(NMDeviceWifiP2P *device, - NMWifiP2PPeer * peer, + NMWifiP2PPeer *peer, gboolean is_added /* or else is_removed */) { nm_dbus_object_emit_signal(NM_DBUS_OBJECT(device), @@ -483,10 +483,10 @@ emit_signal_p2p_peer_add_remove(NMDeviceWifiP2P *device, static void peer_add_remove(NMDeviceWifiP2P *self, gboolean is_adding, /* or else removing */ - NMWifiP2PPeer * peer, + NMWifiP2PPeer *peer, gboolean recheck_available_connections) { - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); if (is_adding) { @@ -539,7 +539,7 @@ static void remove_all_peers(NMDeviceWifiP2P *self) { NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); - NMWifiP2PPeer * peer; + NMWifiP2PPeer *peer; if (c_list_is_empty(&priv->peers_lst_head)) return; @@ -558,8 +558,8 @@ act_stage3_ip_config(NMDevice *device, int addr_family) NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(device); const int IS_IPv4 = NM_IS_IPv4(addr_family); gboolean indicate_addressing_running; - NMConnection * connection; - const char * method; + NMConnection *connection; + const char *method; connection = nm_device_get_applied_connection(device); @@ -574,7 +574,7 @@ act_stage3_ip_config(NMDevice *device, int addr_family) if (nm_supplicant_interface_get_p2p_assigned_addr(priv->group_iface, &addr, &plen)) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; NMPlatformIP4Address address = { - .addr_source = NM_IP_CONFIG_SOURCE_DHCP, + .addr_source = NM_IP_CONFIG_SOURCE_DHCP, }; nm_platform_ip4_address_set_addr(&address, addr, plen); @@ -606,7 +606,7 @@ act_stage3_ip_config(NMDevice *device, int addr_family) static void deactivate(NMDevice *device) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); int ifindex = nm_device_get_ip_ifindex(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); @@ -637,7 +637,7 @@ get_configured_mtu(NMDevice *device, NMDeviceMtuSource *out_source, gboolean *ou static const char * get_auto_ip_config_method(NMDevice *device, int addr_family) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); if (addr_family == AF_INET && priv->group_iface @@ -670,8 +670,8 @@ supplicant_iface_state_cb(NMSupplicantInterface *iface, int disconnect_reason, gpointer user_data) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(user_data); - NMDevice * device = NM_DEVICE(self); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(user_data); + NMDevice *device = NM_DEVICE(self); NMSupplicantInterfaceState new_state = new_state_i; NMSupplicantInterfaceState old_state = old_state_i; @@ -699,12 +699,12 @@ supplicant_iface_state_cb(NMSupplicantInterface *iface, static void supplicant_iface_peer_changed_cb(NMSupplicantInterface *iface, - NMSupplicantPeerInfo * peer_info, + NMSupplicantPeerInfo *peer_info, gboolean is_present, - NMDeviceWifiP2P * self) + NMDeviceWifiP2P *self) { NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); - NMWifiP2PPeer * found_peer; + NMWifiP2PPeer *found_peer; found_peer = nm_wifi_p2p_peers_find_by_supplicant_path(&priv->peers_lst_head, peer_info->peer_path->str); @@ -781,7 +781,7 @@ supplicant_group_iface_state_cb(NMSupplicantInterface *iface, int disconnect_reason, gpointer user_data) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(user_data); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(user_data); NMSupplicantInterfaceState new_state = new_state_i; NMSupplicantInterfaceState old_state = old_state_i; @@ -807,8 +807,8 @@ supplicant_group_iface_state_cb(NMSupplicantInterface *iface, static void supplicant_group_iface_group_finished_cb(NMSupplicantInterface *iface, - const char * iface_path, - void * user_data) + const char *iface_path, + void *user_data) { NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(user_data); @@ -821,8 +821,8 @@ supplicant_group_iface_group_finished_cb(NMSupplicantInterface *iface, static void supplicant_iface_group_joined_updated_cb(NMSupplicantInterface *iface, - GParamSpec * pspec, - void * user_data) + GParamSpec *pspec, + void *user_data) { NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(user_data); @@ -832,9 +832,9 @@ supplicant_iface_group_joined_updated_cb(NMSupplicantInterface *iface, static void supplicant_iface_group_started_cb(NMSupplicantInterface *iface, NMSupplicantInterface *group_iface, - NMDeviceWifiP2P * self) + NMDeviceWifiP2P *self) { - NMDeviceWifiP2PPrivate * priv; + NMDeviceWifiP2PPrivate *priv; NMSupplicantInterfaceState state; g_return_if_fail(self); @@ -918,12 +918,12 @@ supplicant_interfaces_release(NMDeviceWifiP2P *self, gboolean set_is_waiting) } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); update_disconnect_on_connection_peer_missing(self); @@ -979,19 +979,19 @@ device_state_changed(NMDevice * device, } static void -impl_device_wifi_p2p_start_find(NMDBusObject * obj, +impl_device_wifi_p2p_start_find(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(obj); - NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(obj); + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); gs_unref_variant GVariant *options = NULL; - const char * opts_key; - GVariant * opts_val; + const char *opts_key; + GVariant *opts_val; GVariantIter iter; gint32 timeout = 30; @@ -1047,15 +1047,15 @@ impl_device_wifi_p2p_start_find(NMDBusObject * obj, } static void -impl_device_wifi_p2p_stop_find(NMDBusObject * obj, +impl_device_wifi_p2p_stop_find(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(obj); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(obj); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); if (!priv->mgmt_iface) { @@ -1179,9 +1179,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_wifi_p2p = { static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(object); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(object); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); - const char ** list; + const char **list; switch (prop_id) { case PROP_PEERS: @@ -1236,7 +1236,7 @@ nm_device_wifi_p2p_new(const char *iface) static void dispose(GObject *object) { - NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(object); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(object); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(object); g_clear_object(&priv->sup_mgr); @@ -1249,7 +1249,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMDeviceWifiP2P * peer = NM_DEVICE_WIFI_P2P(object); + NMDeviceWifiP2P *peer = NM_DEVICE_WIFI_P2P(object); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(peer); nm_assert(c_list_is_empty(&priv->peers_lst_head)); @@ -1260,9 +1260,9 @@ finalize(GObject *object) static void nm_device_wifi_p2p_class_init(NMDeviceWifiP2PClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; object_class->get_property = get_property; diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index 4c5ec3e3ce..010cee0834 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -94,9 +94,9 @@ typedef struct { NMActRequestGetSecretsCallId *wifi_secrets_id; - NMSupplicantManager * sup_mgr; + NMSupplicantManager *sup_mgr; NMSupplMgrCreateIfaceHandle *sup_create_handle; - NMSupplicantInterface * sup_iface; + NMSupplicantInterface *sup_iface; gint64 scan_last_complete_msec; gint64 scan_periodic_next_msec; @@ -161,7 +161,7 @@ static void supplicant_iface_state_down(NMDeviceWifi *self); static void cleanup_association_attempt(NMDeviceWifi *self, gboolean disconnect); -static void supplicant_iface_state(NMDeviceWifi * self, +static void supplicant_iface_state(NMDeviceWifi *self, NMSupplicantInterfaceState new_state, NMSupplicantInterfaceState old_state, int disconnect_reason, @@ -174,27 +174,27 @@ static void supplicant_iface_state_cb(NMSupplicantInterface *iface, gpointer user_data); static void supplicant_iface_bss_changed_cb(NMSupplicantInterface *iface, - NMSupplicantBssInfo * bss_info, + NMSupplicantBssInfo *bss_info, gboolean is_present, - NMDeviceWifi * self); + NMDeviceWifi *self); static void supplicant_iface_wps_credentials_cb(NMSupplicantInterface *iface, - GVariant * credentials, - NMDeviceWifi * self); + GVariant *credentials, + NMDeviceWifi *self); static void supplicant_iface_notify_current_bss(NMSupplicantInterface *iface, - GParamSpec * pspec, - NMDeviceWifi * self); + GParamSpec *pspec, + NMDeviceWifi *self); static void supplicant_iface_notify_p2p_available(NMSupplicantInterface *iface, - GParamSpec * pspec, - NMDeviceWifi * self); + GParamSpec *pspec, + NMDeviceWifi *self); static void periodic_update(NMDeviceWifi *self); static void ap_add_remove(NMDeviceWifi *self, gboolean is_adding, - NMWifiAP * ap, + NMWifiAP *ap, gboolean recheck_available_connections); static void _hw_addr_set_scanning(NMDeviceWifi *self, gboolean do_reset); @@ -291,7 +291,7 @@ static GPtrArray * _scan_request_ssids_fetch(NMDeviceWifiPrivate *priv, gint64 now_msec) { ScanRequestSsidData *srs_data; - GPtrArray * ssids; + GPtrArray *ssids; guint len; _scan_request_ssids_remove_all(priv, now_msec, G_MAXUINT); @@ -332,7 +332,7 @@ _scan_request_ssids_track(NMDeviceWifiPrivate *priv, const GPtrArray *ssids) c_list_splice(&old_lst_head, &priv->scan_request_ssids_lst_head); for (i = 0; i < ssids->len; i++) { - GBytes * ssid = ssids->pdata[i]; + GBytes *ssid = ssids->pdata[i]; ScanRequestSsidData *d; G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(ScanRequestSsidData, ssid) == 0); @@ -365,7 +365,7 @@ nm_device_wifi_scanning_prohibited_track(NMDeviceWifi *self, gboolean temporarily_prohibited) { NMDeviceWifiPrivate *priv; - NMCListElem * elem; + NMCListElem *elem; g_return_if_fail(NM_IS_DEVICE_WIFI(self)); nm_assert(tag); @@ -411,10 +411,10 @@ _indicate_addressing_running_reset(NMDeviceWifi *self) /*****************************************************************************/ static void -_ap_dump(NMDeviceWifi * self, +_ap_dump(NMDeviceWifi *self, NMLogLevel log_level, const NMWifiAP *ap, - const char * prefix, + const char *prefix, gint64 now_msec) { char buf[1024]; @@ -547,8 +547,8 @@ _scan_notify_allowed(NMDeviceWifi *self, NMTernary do_kickoff) static void supplicant_iface_notify_scanning_cb(NMSupplicantInterface *iface, - GParamSpec * pspec, - NMDeviceWifi * self) + GParamSpec *pspec, + NMDeviceWifi *self) { _scan_notify_is_scanning(self); } @@ -566,13 +566,13 @@ unmanaged_on_quit(NMDevice *self) } static void -supplicant_interface_acquire_cb(NMSupplicantManager * supplicant_manager, +supplicant_interface_acquire_cb(NMSupplicantManager *supplicant_manager, NMSupplMgrCreateIfaceHandle *handle, - NMSupplicantInterface * iface, - GError * error, + NMSupplicantInterface *iface, + GError *error, gpointer user_data) { - NMDeviceWifi * self = user_data; + NMDeviceWifi *self = user_data; NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); if (nm_utils_error_is_cancelled(error)) @@ -711,7 +711,7 @@ static void set_current_ap(NMDeviceWifi *self, NMWifiAP *new_ap, gboolean recheck_available_connections) { NMDeviceWifiPrivate *priv; - NMWifiAP * old_ap; + NMWifiAP *old_ap; g_return_if_fail(NM_IS_DEVICE_WIFI(self)); @@ -807,7 +807,7 @@ periodic_update_cb(gpointer user_data) static void ap_add_remove(NMDeviceWifi *self, gboolean is_adding, /* or else removing */ - NMWifiAP * ap, + NMWifiAP *ap, gboolean recheck_available_connections) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); @@ -848,7 +848,7 @@ static void remove_all_aps(NMDeviceWifi *self) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMWifiAP * ap; + NMWifiAP *ap; if (c_list_is_empty(&priv->aps_lst_head)) return; @@ -864,7 +864,7 @@ remove_all_aps(NMDeviceWifi *self) static gboolean wake_on_wlan_restore(NMDeviceWifi *self) { - NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); _NMSettingWirelessWakeOnWLan w; w = priv->wowlan_restore; @@ -896,7 +896,7 @@ disconnect_cb_on_idle(gpointer user_data, GCancellable *cancellable) gs_unref_object NMDeviceWifi *self = NULL; NMDeviceDeactivateCallback callback; gpointer callback_user_data; - gs_free_error GError *cancelled_error = NULL; + gs_free_error GError *cancelled_error = NULL; nm_utils_user_data_unpack(user_data, &self, &callback, &callback_user_data); @@ -905,12 +905,12 @@ disconnect_cb_on_idle(gpointer user_data, GCancellable *cancellable) } static void -deactivate_async(NMDevice * device, - GCancellable * cancellable, +deactivate_async(NMDevice *device, + GCancellable *cancellable, NMDeviceDeactivateCallback callback, gpointer callback_user_data) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); gpointer user_data; @@ -934,7 +934,7 @@ deactivate_async(NMDevice * device, static void deactivate(NMDevice *device) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); int ifindex = nm_device_get_ifindex(device); @@ -978,14 +978,14 @@ deactivate_reset_hw_addr(NMDevice *device) static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMSettingWireless * s_wireless; - const char * mac; - const char *const * mac_blacklist; + NMSettingWireless *s_wireless; + const char *mac; + const char *const *mac_blacklist; int i; - const char * mode; - const char * perm_hw_addr; + const char *mode; + const char *perm_hw_addr; if (!NM_DEVICE_CLASS(nm_device_wifi_parent_class) ->check_connection_compatible(device, connection, error)) @@ -1078,16 +1078,16 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -check_connection_available(NMDevice * device, - NMConnection * connection, +check_connection_available(NMDevice *device, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMSettingWireless * s_wifi; - const char * mode; + NMSettingWireless *s_wifi; + const char *mode; s_wifi = nm_connection_get_setting_wireless(connection); g_return_val_if_fail(s_wifi, FALSE); @@ -1146,21 +1146,21 @@ check_connection_available(NMDevice * device, } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMSettingWireless * s_wifi; - gs_free char * ssid_utf8 = NULL; - NMWifiAP * ap; - GBytes * ssid = NULL; - GBytes * setting_ssid = NULL; + NMSettingWireless *s_wifi; + gs_free char *ssid_utf8 = NULL; + NMWifiAP *ap; + GBytes *ssid = NULL; + GBytes *setting_ssid = NULL; gboolean hidden = FALSE; - const char * mode; + const char *mode; s_wifi = nm_connection_get_setting_wireless(connection); @@ -1281,8 +1281,8 @@ complete_connection(NMDevice * device, static gboolean is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); - NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); NMSupplicantInterfaceState supplicant_state; if (!priv->enabled) @@ -1308,12 +1308,12 @@ get_autoconnect_allowed(NMDevice *device) static gboolean can_auto_connect(NMDevice *device, NMSettingsConnection *sett_conn, char **specific_object) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMConnection * connection; - NMSettingWireless * s_wifi; - NMWifiAP * ap; - const char * method6, *mode; + NMConnection *connection; + NMSettingWireless *s_wifi; + NMWifiAP *ap; + const char *method6, *mode; gboolean auto4, auto6; nm_assert(!specific_object || !*specific_object); @@ -1361,7 +1361,7 @@ _nm_device_wifi_get_aps(NMDeviceWifi *self) static void _hw_addr_set_scanning(NMDeviceWifi *self, gboolean do_reset) { - NMDevice * device = (NMDevice *) self; + NMDevice *device = (NMDevice *) self; NMDeviceWifiPrivate *priv; guint32 now; gboolean randomize; @@ -1397,7 +1397,7 @@ _hw_addr_set_scanning(NMDeviceWifi *self, gboolean do_reset) if (now >= priv->hw_addr_scan_expire) { gs_free char *hw_addr_scan = NULL; - const char * generate_mac_address_mask; + const char *generate_mac_address_mask; /* the random MAC address for scanning expires after a while. * @@ -1444,7 +1444,7 @@ ssids_options_to_ptrarray(GVariant *value, GError **error) for (i = 0; i < num_ssids; i++) { gs_unref_variant GVariant *v = NULL; gsize len; - const guint8 * bytes; + const guint8 *bytes; v = g_variant_get_child_value(value, i); bytes = g_variant_get_fixed_array(v, &len, sizeof(guint8)); @@ -1471,14 +1471,14 @@ nmtst_ssids_options_to_ptrarray(GVariant *value, GError **error) } static void -dbus_request_scan_cb(NMDevice * device, +dbus_request_scan_cb(NMDevice *device, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer user_data) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *ssids = user_data; if (error) { @@ -1493,13 +1493,13 @@ dbus_request_scan_cb(NMDevice * device, } void -_nm_device_wifi_request_scan(NMDeviceWifi * self, - GVariant * options, +_nm_device_wifi_request_scan(NMDeviceWifi *self, + GVariant *options, GDBusMethodInvocation *invocation) { - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); - gs_unref_ptrarray GPtrArray *ssids = NULL; + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMDevice *device = NM_DEVICE(self); + gs_unref_ptrarray GPtrArray *ssids = NULL; if (options) { gs_unref_variant GVariant *val = g_variant_lookup_value(options, "ssids", NULL); @@ -1545,7 +1545,7 @@ _nm_device_wifi_request_scan(NMDeviceWifi * self, static gboolean hidden_filter_func(NMSettings *settings, NMSettingsConnection *set_con, gpointer user_data) { - NMConnection * connection = nm_settings_connection_get_connection(set_con); + NMConnection *connection = nm_settings_connection_get_connection(set_con); NMSettingWireless *s_wifi; if (!nm_connection_is_type(connection, NM_SETTING_WIRELESS_SETTING_NAME)) @@ -1561,12 +1561,12 @@ hidden_filter_func(NMSettings *settings, NMSettingsConnection *set_con, gpointer static GPtrArray * _scan_request_ssids_build_hidden(NMDeviceWifi *self, gint64 now_msec, - gboolean * out_has_hidden_profiles) + gboolean *out_has_hidden_profiles) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - guint max_scan_ssids = nm_supplicant_interface_get_max_scan_ssids(priv->sup_iface); + guint max_scan_ssids = nm_supplicant_interface_get_max_scan_ssids(priv->sup_iface); gs_free NMSettingsConnection **connections = NULL; - gs_unref_ptrarray GPtrArray *ssids = NULL; + gs_unref_ptrarray GPtrArray *ssids = NULL; gs_unref_hashtable GHashTable *unique_ssids = NULL; guint connections_len; guint n_hidden; @@ -1624,7 +1624,7 @@ _scan_request_ssids_build_hidden(NMDeviceWifi *self, n_hidden = 0; for (i = 0; i < connections_len; i++) { NMSettingWireless *s_wifi; - GBytes * ssid; + GBytes *ssid; if (ssids->len >= max_scan_ssids) break; @@ -1653,7 +1653,7 @@ _scan_request_ssids_build_hidden(NMDeviceWifi *self, static gboolean _scan_request_delay_cb(gpointer user_data) { - NMDeviceWifi * self = user_data; + NMDeviceWifi *self = user_data; NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->scan_request_delay_source); @@ -1666,10 +1666,10 @@ _scan_request_delay_cb(gpointer user_data) static void _scan_supplicant_request_scan_cb(NMSupplicantInterface *supp_iface, - GCancellable * cancellable, + GCancellable *cancellable, gpointer user_data) { - NMDeviceWifi * self; + NMDeviceWifi *self; NMDeviceWifiPrivate *priv; if (g_cancellable_is_cancelled(cancellable)) @@ -1696,7 +1696,7 @@ _scan_supplicant_request_scan_cb(NMSupplicantInterface *supp_iface, static gboolean _scan_kickoff_timeout_cb(gpointer user_data) { - NMDeviceWifi * self = user_data; + NMDeviceWifi *self = user_data; NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); priv->scan_kickoff_timeout_id = 0; @@ -1707,7 +1707,7 @@ _scan_kickoff_timeout_cb(gpointer user_data) static void _scan_kickoff(NMDeviceWifi *self) { - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *ssids = NULL; gboolean is_explict = FALSE; NMDeviceState device_state; @@ -1882,7 +1882,7 @@ _scan_kickoff(NMDeviceWifi *self) static gboolean ap_list_dump(gpointer user_data) { - NMDeviceWifi * self = NM_DEVICE_WIFI(user_data); + NMDeviceWifi *self = NM_DEVICE_WIFI(user_data); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); priv->ap_dump_id = 0; @@ -1920,7 +1920,7 @@ schedule_ap_list_dump(NMDeviceWifi *self) static void try_fill_ssid_for_hidden_ap(NMDeviceWifi *self, NMWifiAP *ap) { - const char * bssid; + const char *bssid; NMSettingsConnection *const *connections; guint i; @@ -1934,7 +1934,7 @@ try_fill_ssid_for_hidden_ap(NMDeviceWifi *self, NMWifiAP *ap) connections = nm_settings_get_connections(nm_device_get_settings((NMDevice *) self), NULL); for (i = 0; connections[i]; i++) { NMSettingsConnection *sett_conn = connections[i]; - NMSettingWireless * s_wifi; + NMSettingWireless *s_wifi; if (!nm_settings_connection_has_seen_bssid(sett_conn, bssid)) continue; @@ -1950,13 +1950,13 @@ try_fill_ssid_for_hidden_ap(NMDeviceWifi *self, NMWifiAP *ap) static void supplicant_iface_bss_changed_cb(NMSupplicantInterface *iface, - NMSupplicantBssInfo * bss_info, + NMSupplicantBssInfo *bss_info, gboolean is_present, - NMDeviceWifi * self) + NMDeviceWifi *self) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMWifiAP * found_ap; - GBytes * ssid; + NMWifiAP *found_ap; + GBytes *ssid; found_ap = g_hash_table_lookup(priv->aps_idx_by_supplicant_path, bss_info->bss_path); @@ -2049,14 +2049,14 @@ cleanup_supplicant_failures(NMDeviceWifi *self) } static void -wifi_secrets_cb(NMActRequest * req, +wifi_secrets_cb(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * connection, - GError * error, + NMSettingsConnection *connection, + GError *error, gpointer user_data) { - NMDevice * device = user_data; - NMDeviceWifi * self = user_data; + NMDevice *device = user_data; + NMDeviceWifi *self = user_data; NMDeviceWifiPrivate *priv; g_return_if_fail(NM_IS_DEVICE_WIFI(self)); @@ -2123,15 +2123,15 @@ wifi_secrets_cancel(NMDeviceWifi *self) static void supplicant_iface_wps_credentials_cb(NMSupplicantInterface *iface, - GVariant * credentials, - NMDeviceWifi * self) + GVariant *credentials, + NMDeviceWifi *self) { - NMActRequest * req; + NMActRequest *req; gs_unref_variant GVariant *val_key = NULL; gs_unref_variant GVariant *secrets = NULL; - gs_free_error GError *error = NULL; - const char * array; - gsize psk_len = 0; + gs_free_error GError *error = NULL; + const char *array; + gsize psk_len = 0; if (nm_device_get_state(NM_DEVICE(self)) != NM_DEVICE_STATE_NEED_AUTH) { _LOGI(LOGD_DEVICE | LOGD_WIFI, "WPS: The connection can't be updated with credentials"); @@ -2184,7 +2184,7 @@ supplicant_iface_wps_credentials_cb(NMSupplicantInterface *iface, static gboolean wps_timeout_cb(gpointer user_data) { - NMDeviceWifi * self = NM_DEVICE_WIFI(user_data); + NMDeviceWifi *self = NM_DEVICE_WIFI(user_data); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); priv->wps_timeout_id = 0; @@ -2199,12 +2199,12 @@ wps_timeout_cb(gpointer user_data) } static void -wifi_secrets_get_secrets(NMDeviceWifi * self, - const char * setting_name, +wifi_secrets_get_secrets(NMDeviceWifi *self, + const char *setting_name, NMSecretAgentGetSecretsFlags flags) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMActRequest * req; + NMActRequest *req; wifi_secrets_cancel(self); @@ -2225,8 +2225,8 @@ wifi_secrets_get_secrets(NMDeviceWifi * self, static gboolean link_timeout_cb(gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDevice *device = NM_DEVICE(user_data); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); _LOGW(LOGD_WIFI, "link timed out."); @@ -2250,14 +2250,14 @@ link_timeout_cb(gpointer user_data) } static gboolean -need_new_8021x_secrets(NMDeviceWifi * self, +need_new_8021x_secrets(NMDeviceWifi *self, NMSupplicantInterfaceState old_state, - const char ** setting_name) + const char **setting_name) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; NMSettingWirelessSecurity *s_wsec; NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; - NMConnection * connection; + NMConnection *connection; g_return_val_if_fail(setting_name, FALSE); @@ -2305,14 +2305,14 @@ need_new_8021x_secrets(NMDeviceWifi * self, } static gboolean -need_new_wpa_psk(NMDeviceWifi * self, +need_new_wpa_psk(NMDeviceWifi *self, NMSupplicantInterfaceState old_state, int disconnect_reason, - const char ** setting_name) + const char **setting_name) { NMSettingWirelessSecurity *s_wsec; - NMConnection * connection; - const char * key_mgmt = NULL; + NMConnection *connection; + const char *key_mgmt = NULL; g_return_val_if_fail(setting_name, FALSE); @@ -2347,14 +2347,14 @@ need_new_wpa_psk(NMDeviceWifi * self, } static gboolean -handle_8021x_or_psk_auth_fail(NMDeviceWifi * self, +handle_8021x_or_psk_auth_fail(NMDeviceWifi *self, NMSupplicantInterfaceState new_state, NMSupplicantInterfaceState old_state, int disconnect_reason) { - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMActRequest *req; - const char * setting_name = NULL; + const char *setting_name = NULL; gboolean handled = FALSE; g_return_val_if_fail(new_state == NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED, FALSE); @@ -2386,8 +2386,8 @@ handle_8021x_or_psk_auth_fail(NMDeviceWifi * self, static gboolean reacquire_interface_cb(gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDevice *device = NM_DEVICE(user_data); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); priv->reacquire_iface_id = 0; @@ -2405,7 +2405,7 @@ static void supplicant_iface_state_down(NMDeviceWifi *self) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); nm_device_queue_recheck_available(device, NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE, @@ -2425,14 +2425,14 @@ supplicant_iface_state_down(NMDeviceWifi *self) } static void -supplicant_iface_state(NMDeviceWifi * self, +supplicant_iface_state(NMDeviceWifi *self, NMSupplicantInterfaceState new_state, NMSupplicantInterfaceState old_state, int disconnect_reason, gboolean is_real_signal) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceState devstate; gboolean scanning; gboolean scan_changed; @@ -2479,8 +2479,8 @@ supplicant_iface_state(NMDeviceWifi * self, */ if (devstate == NM_DEVICE_STATE_CONFIG) { NMSettingWireless *s_wifi; - GBytes * ssid; - gs_free char * ssid_str = NULL; + GBytes *ssid; + gs_free char *ssid_str = NULL; s_wifi = nm_device_get_applied_setting(NM_DEVICE(self), NM_TYPE_SETTING_WIRELESS); @@ -2556,7 +2556,7 @@ static void supplicant_iface_assoc_cb(NMSupplicantInterface *iface, GError *error, gpointer user_data) { NMDeviceWifi *self = NM_DEVICE_WIFI(user_data); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); if (error && !nm_utils_error_is_cancelled_or_disposing(error) && nm_device_is_activating(device)) { @@ -2569,23 +2569,23 @@ supplicant_iface_assoc_cb(NMSupplicantInterface *iface, GError *error, gpointer static void supplicant_iface_notify_current_bss(NMSupplicantInterface *iface, - GParamSpec * pspec, - NMDeviceWifi * self) + GParamSpec *pspec, + NMDeviceWifi *self) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMRefString * current_bss; - NMWifiAP * new_ap = NULL; - NMActRequest * req; + NMRefString *current_bss; + NMWifiAP *new_ap = NULL; + NMActRequest *req; current_bss = nm_supplicant_interface_get_current_bss(iface); if (current_bss) new_ap = g_hash_table_lookup(priv->aps_idx_by_supplicant_path, current_bss); if (new_ap != priv->current_ap) { - const char * new_bssid = NULL; - GBytes * new_ssid = NULL; - const char * old_bssid = NULL; - GBytes * old_ssid = NULL; + const char *new_bssid = NULL; + GBytes *new_ssid = NULL; + const char *old_bssid = NULL; + GBytes *old_ssid = NULL; gs_free char *new_ssid_s = NULL; gs_free char *old_ssid_s = NULL; @@ -2682,8 +2682,8 @@ recheck_p2p_availability(NMDeviceWifi *self) static void supplicant_iface_notify_p2p_available(NMSupplicantInterface *iface, - GParamSpec * pspec, - NMDeviceWifi * self) + GParamSpec *pspec, + NMDeviceWifi *self) { if (nm_supplicant_interface_get_state(iface) > NM_SUPPLICANT_INTERFACE_STATE_STARTING) recheck_p2p_availability(self); @@ -2692,14 +2692,14 @@ supplicant_iface_notify_p2p_available(NMSupplicantInterface *iface, static gboolean handle_auth_or_fail(NMDeviceWifi *self, NMActRequest *req, gboolean new_secrets) { - NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - const char * setting_name; - NMConnection * applied_connection; - NMSettingWirelessSecurity * s_wsec; - const char * bssid = NULL; + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + const char *setting_name; + NMConnection *applied_connection; + NMSettingWirelessSecurity *s_wsec; + const char *bssid = NULL; NM80211ApFlags ap_flags; NMSettingWirelessSecurityWpsMethod wps_method; - const char * type; + const char *type; NMSecretAgentGetSecretsFlags get_secret_flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; @@ -2777,11 +2777,11 @@ handle_auth_or_fail(NMDeviceWifi *self, NMActRequest *req, gboolean new_secrets) static gboolean supplicant_connection_timeout_cb(gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); - NMDeviceWifi * self = NM_DEVICE_WIFI(user_data); + NMDevice *device = NM_DEVICE(user_data); + NMDeviceWifi *self = NM_DEVICE_WIFI(user_data); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMActRequest * req; - NMConnection * connection; + NMActRequest *req; + NMConnection *connection; cleanup_association_attempt(self, TRUE); @@ -2857,12 +2857,12 @@ static NMSupplicantConfig * build_supplicant_config(NMDeviceWifi *self, NMConnection *connection, guint32 fixed_freq, - GError ** error) + GError **error) { - NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMSupplicantConfig * config = NULL; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity * s_wireless_sec; + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMSupplicantConfig *config = NULL; + NMSettingWireless *s_wireless; + NMSettingWirelessSecurity *s_wireless_sec; NMSettingWirelessSecurityPmf pmf; NMSettingWirelessSecurityFils fils; NMTernary ap_isolation; @@ -2905,7 +2905,7 @@ build_supplicant_config(NMDeviceWifi *self, s_wireless_sec = nm_connection_get_setting_wireless_security(connection); if (s_wireless_sec) { NMSetting8021x *s_8021x; - const char * con_uuid = nm_connection_get_uuid(connection); + const char *con_uuid = nm_connection_get_uuid(connection); guint32 mtu = nm_platform_link_get_mtu(nm_device_get_platform(NM_DEVICE(self)), nm_device_get_ifindex(NM_DEVICE(self))); @@ -2966,10 +2966,10 @@ error: static gboolean wake_on_wlan_enable(NMDeviceWifi *self) { - NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); NMSettingWirelessWakeOnWLan wowl; _NMSettingWirelessWakeOnWLan wowl2; - NMSettingWireless * s_wireless; + NMSettingWireless *s_wireless; s_wireless = nm_device_get_applied_setting(NM_DEVICE(self), NM_TYPE_SETTING_WIRELESS); if (s_wireless) { @@ -3020,15 +3020,15 @@ found: static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - NMWifiAP * ap = NULL; + NMDeviceWifi *self = NM_DEVICE_WIFI(device); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMWifiAP *ap = NULL; gs_unref_object NMWifiAP *ap_fake = NULL; - NMActRequest * req; - NMConnection * connection; - NMSettingWireless * s_wireless; - const char * mode; - const char * ap_path; + NMActRequest *req; + NMConnection *connection; + NMSettingWireless *s_wireless; + const char *mode; + const char *ap_path; req = nm_device_get_act_request(NM_DEVICE(self)); g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); @@ -3103,8 +3103,8 @@ 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); + 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; @@ -3133,8 +3133,8 @@ ensure_hotspot_frequency(NMDeviceWifi *self, NMSettingWireless *s_wifi, NMWifiAP static void set_powersave(NMDevice *device) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); - NMSettingWireless * s_wireless; + NMDeviceWifi *self = NM_DEVICE_WIFI(device); + NMSettingWireless *s_wireless; NMSettingWirelessPowersave val; s_wireless = nm_device_get_applied_setting(device, NM_TYPE_SETTING_WIRELESS); @@ -3164,20 +3164,20 @@ set_powersave(NMDevice *device) static NMActStageReturn act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); gs_unref_object NMSupplicantConfig *config = NULL; _NM80211Mode ap_mode; - NMActRequest * req; - NMWifiAP * ap; - NMConnection * connection; - const char * setting_name; - NMSettingWireless * s_wireless; - GError * error = NULL; + NMActRequest *req; + NMWifiAP *ap; + NMConnection *connection; + const char *setting_name; + NMSettingWireless *s_wireless; + GError *error = NULL; guint timeout; - NMActRequest * request; - NMActiveConnection * master_ac; - NMDevice * master; + NMActRequest *request; + NMActiveConnection *master_ac; + NMDevice *master; nm_clear_g_source(&priv->sup_timeout_id); nm_clear_g_source(&priv->link_timeout_id); @@ -3282,9 +3282,9 @@ out_fail: static void act_stage3_ip_config(NMDevice *device, int addr_family) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - const char * method; + const char *method; gboolean indicate_addressing_running; if (priv->addressing_running_indicated) @@ -3322,10 +3322,10 @@ get_configured_mtu(NMDevice *device, NMDeviceMtuSource *out_source, gboolean *ou static void activation_success_handler(NMDevice *device) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); int ifindex = nm_device_get_ifindex(device); - NMActRequest * req; + NMActRequest *req; req = nm_device_get_act_request(device); g_assert(req); @@ -3385,12 +3385,12 @@ activation_success_handler(NMDevice *device) } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); gboolean clear_aps = FALSE; @@ -3459,7 +3459,7 @@ get_enabled(NMDevice *device) static void set_enabled(NMDevice *device, gboolean enabled) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); NMDeviceState state; @@ -3513,19 +3513,19 @@ set_enabled(NMDevice *device, gboolean enabled) static gboolean get_guessed_metered(NMDevice *device) { - NMDeviceWifi * self = NM_DEVICE_WIFI(device); + NMDeviceWifi *self = NM_DEVICE_WIFI(device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); return priv->current_ap && nm_wifi_ap_get_metered(priv->current_ap); } static gboolean -can_reapply_change(NMDevice * device, +can_reapply_change(NMDevice *device, const char *setting_name, - NMSetting * s_old, - NMSetting * s_new, + NMSetting *s_old, + NMSetting *s_new, GHashTable *diffs, - GError ** error) + GError **error) { NMDeviceClass *device_class; @@ -3563,9 +3563,9 @@ reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_ne static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceWifi * self = NM_DEVICE_WIFI(object); + NMDeviceWifi *self = NM_DEVICE_WIFI(object); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); - const char ** list; + const char **list; switch (prop_id) { case PROP_MODE: @@ -3604,7 +3604,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMDeviceWifi * device = NM_DEVICE_WIFI(object); + NMDeviceWifi *device = NM_DEVICE_WIFI(object); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(device); switch (prop_id) { @@ -3639,7 +3639,7 @@ nm_device_wifi_init(NMDeviceWifi *self) static void constructed(GObject *object) { - NMDeviceWifi * self = NM_DEVICE_WIFI(object); + NMDeviceWifi *self = NM_DEVICE_WIFI(object); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); G_OBJECT_CLASS(nm_device_wifi_parent_class)->constructed(object); @@ -3673,7 +3673,7 @@ nm_device_wifi_new(const char *iface, _NMDeviceWifiCapabilities capabilities) static void dispose(GObject *object) { - NMDeviceWifi * self = NM_DEVICE_WIFI(object); + NMDeviceWifi *self = NM_DEVICE_WIFI(object); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); nm_assert(c_list_is_empty(&priv->scanning_prohibited_lst_head)); @@ -3702,7 +3702,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMDeviceWifi * self = NM_DEVICE_WIFI(object); + NMDeviceWifi *self = NM_DEVICE_WIFI(object); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); nm_assert(c_list_is_empty(&priv->aps_lst_head)); @@ -3716,9 +3716,9 @@ finalize(GObject *object) static void nm_device_wifi_class_init(NMDeviceWifiClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; object_class->get_property = get_property; diff --git a/src/core/devices/wifi/nm-device-wifi.h b/src/core/devices/wifi/nm-device-wifi.h index c7ff1a140a..3a85192e12 100644 --- a/src/core/devices/wifi/nm-device-wifi.h +++ b/src/core/devices/wifi/nm-device-wifi.h @@ -37,8 +37,8 @@ NMDevice *nm_device_wifi_new(const char *iface, _NMDeviceWifiCapabilities capabi const CList *_nm_device_wifi_get_aps(NMDeviceWifi *self); -void _nm_device_wifi_request_scan(NMDeviceWifi * self, - GVariant * options, +void _nm_device_wifi_request_scan(NMDeviceWifi *self, + GVariant *options, GDBusMethodInvocation *invocation); GPtrArray *nmtst_ssids_options_to_ptrarray(GVariant *value, GError **error); diff --git a/src/core/devices/wifi/nm-iwd-manager.c b/src/core/devices/wifi/nm-iwd-manager.c index 56386c5708..e360b1c30a 100644 --- a/src/core/devices/wifi/nm-iwd-manager.c +++ b/src/core/devices/wifi/nm-iwd-manager.c @@ -26,29 +26,29 @@ /*****************************************************************************/ typedef struct { - const char * name; + const char *name; NMIwdNetworkSecurity security; char buf[0]; } KnownNetworkId; typedef struct { - GDBusProxy * known_network; + GDBusProxy *known_network; NMSettingsConnection *mirror_connection; const KnownNetworkId *id; } KnownNetworkData; typedef struct { - NMManager * manager; - NMSettings * settings; - GCancellable * cancellable; + NMManager *manager; + NMSettings *settings; + GCancellable *cancellable; gboolean running; GDBusObjectManager *object_manager; guint agent_id; - char * agent_path; - GHashTable * known_networks; - NMDeviceIwd * last_agent_call_device; - char * last_state_dir; - char * warned_state_dir; + char *agent_path; + GHashTable *known_networks; + NMDeviceIwd *last_agent_call_device; + char *last_state_dir; + char *warned_state_dir; } NMIwdManagerPrivate; struct _NMIwdManager { @@ -98,7 +98,7 @@ G_DEFINE_TYPE(NMIwdManager, nm_iwd_manager, G_TYPE_OBJECT) /*****************************************************************************/ static void mirror_connection_take_and_delete(NMSettingsConnection *sett_conn, - KnownNetworkData * data); + KnownNetworkData *data); /*****************************************************************************/ @@ -146,10 +146,10 @@ get_property_bool(GDBusProxy *proxy, const char *property, gboolean default_val) static NMDeviceIwd * get_device_from_network(NMIwdManager *self, GDBusProxy *network) { - NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - const char * ifname; - const char * device_path; - NMDevice * device; + NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); + const char *ifname; + const char *device_path; + NMDevice *device; gs_unref_object GDBusInterface *device_obj = NULL; /* Try not to rely on the path of the Device being a prefix of the @@ -182,21 +182,21 @@ get_device_from_network(NMIwdManager *self, GDBusProxy *network) } static void -agent_dbus_method_cb(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +agent_dbus_method_cb(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { - NMIwdManager * self = user_data; - NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - const char * network_path; - NMDeviceIwd * device; - gs_free char * name_owner = NULL; - gs_unref_object GDBusInterface *network = NULL; + NMIwdManager *self = user_data; + NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); + const char *network_path; + NMDeviceIwd *device; + gs_free char *name_owner = NULL; + gs_unref_object GDBusInterface *network = NULL; /* Be paranoid and check the sender address */ name_owner = g_dbus_object_manager_client_get_name_owner( @@ -315,7 +315,7 @@ static void register_agent(NMIwdManager *self) { NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - GDBusInterface * agent_manager; + GDBusInterface *agent_manager; agent_manager = g_dbus_object_manager_get_interface(priv->object_manager, "/net/connman/iwd", /* IWD 1.0+ */ @@ -388,9 +388,9 @@ static void set_device_dbus_object(NMIwdManager *self, GDBusProxy *proxy, GDBusObject *object) { NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - const char * ifname; + const char *ifname; int ifindex; - NMDevice * device; + NMDevice *device; int errsv; ifname = get_property_string_or_null(proxy, "Name"); @@ -423,7 +423,7 @@ static void known_network_update_cb(GObject *source, GAsyncResult *res, gpointer user_data) { gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; variant = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error); if (!variant) { @@ -436,13 +436,13 @@ known_network_update_cb(GObject *source, GAsyncResult *res, gpointer user_data) } static gboolean -iwd_config_write(GKeyFile * config, - const char * filepath, +iwd_config_write(GKeyFile *config, + const char *filepath, const struct timespec *mtime, - GError ** error) + GError **error) { gsize length; - gs_free char * data = g_key_file_to_data(config, &length, NULL); + gs_free char *data = g_key_file_to_data(config, &length, NULL); struct timespec times[2] = {{.tv_nsec = UTIME_OMIT}, *mtime}; /* Atomically write or replace the file with the right permission bits @@ -458,7 +458,7 @@ static const char * get_config_path(NMIwdManager *self) { NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - const char * path; + const char *path; path = nm_config_data_get_iwd_config_path(NM_CONFIG_GET_DATA); if (path && path[0] == '\0') { @@ -489,26 +489,26 @@ get_config_path(NMIwdManager *self) } static void -sett_conn_changed(NMSettingsConnection * sett_conn, +sett_conn_changed(NMSettingsConnection *sett_conn, guint update_reason, const KnownNetworkData *data) { - NMSettingsConnectionIntFlags flags; - NMConnection * conn = nm_settings_connection_get_connection(sett_conn); - NMSettingConnection * s_conn = nm_connection_get_setting_connection(conn); - NMSettingWireless * s_wifi = nm_connection_get_setting_wireless(conn); + NMSettingsConnectionIntFlags flags; + NMConnection *conn = nm_settings_connection_get_connection(sett_conn); + NMSettingConnection *s_conn = nm_connection_get_setting_connection(conn); + NMSettingWireless *s_wifi = nm_connection_get_setting_wireless(conn); nm_auto_unref_keyfile GKeyFile *iwd_config = NULL; - const char * iwd_dir; - gs_free char * filename = NULL; - gs_free char * full_path = NULL; - gs_free_error GError *error = NULL; - NMIwdNetworkSecurity security; - GBytes * ssid; - const guint8 * ssid_data; - gsize ssid_len; - gboolean removed; - GStatBuf statbuf; - gboolean have_mtime; + const char *iwd_dir; + gs_free char *filename = NULL; + gs_free char *full_path = NULL; + gs_free_error GError *error = NULL; + NMIwdNetworkSecurity security; + GBytes *ssid; + const guint8 *ssid_data; + gsize ssid_len; + gboolean removed; + GStatBuf statbuf; + gboolean have_mtime; nm_assert(sett_conn == data->mirror_connection); @@ -660,24 +660,24 @@ sett_conn_changed(NMSettingsConnection * sett_conn, * from the user. */ static NMSettingsConnection * -mirror_connection(NMIwdManager * self, +mirror_connection(NMIwdManager *self, const KnownNetworkId *id, gboolean create_new, - GDBusProxy * known_network) + GDBusProxy *known_network) { - NMIwdManagerPrivate * priv = NM_IWD_MANAGER_GET_PRIVATE(self); - NMSettingsConnection *const *iter; + NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); + NMSettingsConnection *const *iter; gs_unref_object NMConnection *connection = NULL; - NMSettingsConnection * settings_connection = NULL; + NMSettingsConnection *settings_connection = NULL; char uuid[37]; - NMSetting * setting; - gs_free_error GError *error = NULL; - gs_unref_bytes GBytes *new_ssid = NULL; - gsize ssid_len = strlen(id->name); - gboolean autoconnectable = TRUE; - gboolean hidden = FALSE; - gboolean exact_match = TRUE; - const char * key_mgmt = NULL; + NMSetting *setting; + gs_free_error GError *error = NULL; + gs_unref_bytes GBytes *new_ssid = NULL; + gsize ssid_len = strlen(id->name); + gboolean autoconnectable = TRUE; + gboolean hidden = FALSE; + gboolean exact_match = TRUE; + const char *key_mgmt = NULL; if (known_network) { autoconnectable = get_property_bool(known_network, "AutoConnect", TRUE); @@ -686,10 +686,10 @@ mirror_connection(NMIwdManager * self, for (iter = nm_settings_get_connections(priv->settings, NULL); *iter; iter++) { NMSettingsConnection *sett_conn = *iter; - NMConnection * conn = nm_settings_connection_get_connection(sett_conn); + NMConnection *conn = nm_settings_connection_get_connection(sett_conn); NMIwdNetworkSecurity security; - NMSettingWireless * s_wifi; - const guint8 * ssid_bytes; + NMSettingWireless *s_wifi; + const guint8 *ssid_bytes; gsize ssid_len2; if (!nm_wifi_connection_get_iwd_ssid_and_security(conn, NULL, &security)) @@ -770,7 +770,7 @@ mirror_connection(NMIwdManager * self, if (NM_FLAGS_HAS(flags, NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED)) { NMConnection *tmp_conn = nm_settings_connection_get_connection(settings_connection); NMSettingConnection *s_conn = nm_connection_get_setting_connection(tmp_conn); - NMSettingWireless * s_wifi = nm_connection_get_setting_wireless(tmp_conn); + NMSettingWireless *s_wifi = nm_connection_get_setting_wireless(tmp_conn); g_object_set(G_OBJECT(s_conn), NM_SETTING_CONNECTION_AUTOCONNECT, @@ -912,14 +912,14 @@ mirror_connection_take_and_delete(NMSettingsConnection *sett_conn, KnownNetworkD static void interface_added(GDBusObjectManager *object_manager, - GDBusObject * object, - GDBusInterface * interface, + GDBusObject *object, + GDBusInterface *interface, gpointer user_data) { - NMIwdManager * self = user_data; + NMIwdManager *self = user_data; NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - GDBusProxy * proxy; - const char * iface_name; + GDBusProxy *proxy; + const char *iface_name; if (!priv->running) return; @@ -935,11 +935,11 @@ interface_added(GDBusObjectManager *object_manager, } if (nm_streq(iface_name, NM_IWD_KNOWN_NETWORK_INTERFACE)) { - KnownNetworkId * id; - KnownNetworkId * orig_id; - KnownNetworkData * data; + KnownNetworkId *id; + KnownNetworkId *orig_id; + KnownNetworkData *data; NMIwdNetworkSecurity security; - const char * type_str, *name; + const char *type_str, *name; NMSettingsConnection *sett_conn = NULL; type_str = get_property_string_or_null(proxy, "Type"); @@ -1002,14 +1002,14 @@ interface_added(GDBusObjectManager *object_manager, static void interface_removed(GDBusObjectManager *object_manager, - GDBusObject * object, - GDBusInterface * interface, + GDBusObject *object, + GDBusInterface *interface, gpointer user_data) { - NMIwdManager * self = user_data; + NMIwdManager *self = user_data; NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - GDBusProxy * proxy; - const char * iface_name; + GDBusProxy *proxy; + const char *iface_name; g_return_if_fail(G_IS_DBUS_PROXY(interface)); @@ -1023,7 +1023,7 @@ interface_removed(GDBusObjectManager *object_manager, if (nm_streq(iface_name, NM_IWD_KNOWN_NETWORK_INTERFACE)) { KnownNetworkId id; - const char * type_str; + const char *type_str; type_str = get_property_string_or_null(proxy, "Type"); id.name = get_property_string_or_null(proxy, "Name"); @@ -1088,19 +1088,19 @@ object_removed(GDBusObjectManager *object_manager, GDBusObject *object, gpointer static void connection_removed(NMSettings *settings, NMSettingsConnection *sett_conn, gpointer user_data) { - NMIwdManager * self = user_data; - NMIwdManagerPrivate * priv = NM_IWD_MANAGER_GET_PRIVATE(self); - NMConnection * conn = nm_settings_connection_get_connection(sett_conn); - NMSettingWireless * s_wireless; - KnownNetworkData * data; + NMIwdManager *self = user_data; + NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); + NMConnection *conn = nm_settings_connection_get_connection(sett_conn); + NMSettingWireless *s_wireless; + KnownNetworkData *data; KnownNetworkId id; char ssid_buf[33]; - const guint8 * ssid_bytes; + const guint8 *ssid_bytes; gsize ssid_len; NMSettingsConnection *new_mirror_conn; - const char * iwd_dir; - gs_free char * filename = NULL; - gs_free char * full_path = NULL; + const char *iwd_dir; + gs_free char *filename = NULL; + gs_free char *full_path = NULL; if (!nm_wifi_connection_get_iwd_ssid_and_security(conn, NULL, &id.security)) return; @@ -1170,13 +1170,13 @@ try_delete_file: static void connection_added(NMSettings *settings, NMSettingsConnection *sett_conn, gpointer user_data) { - NMIwdManager * self = user_data; - NMConnection * conn = nm_settings_connection_get_connection(sett_conn); - NMSettingConnection *s_conn = nm_connection_get_setting_connection(conn); - const char * iwd_dir; - gs_free char * filename = NULL; - gs_free char * full_path = NULL; - gs_free_error GError *error = NULL; + NMIwdManager *self = user_data; + NMConnection *conn = nm_settings_connection_get_connection(sett_conn); + NMSettingConnection *s_conn = nm_connection_get_setting_connection(conn); + const char *iwd_dir; + gs_free char *filename = NULL; + gs_free char *full_path = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *iwd_config = NULL; NMSettingsConnectionIntFlags flags; @@ -1259,7 +1259,7 @@ release_object_manager(NMIwdManager *self) g_signal_handlers_disconnect_by_data(priv->object_manager, self); if (priv->agent_id) { - GDBusConnection * agent_connection; + GDBusConnection *agent_connection; GDBusObjectManagerClient *omc = G_DBUS_OBJECT_MANAGER_CLIENT(priv->object_manager); agent_connection = g_dbus_object_manager_client_get_connection(omc); @@ -1281,9 +1281,9 @@ static void prepare_object_manager(NMIwdManager *self); static void name_owner_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NMIwdManager * self = user_data; + NMIwdManager *self = user_data; NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - GDBusObjectManager * object_manager = G_DBUS_OBJECT_MANAGER(object); + GDBusObjectManager *object_manager = G_DBUS_OBJECT_MANAGER(object); nm_assert(object_manager == priv->object_manager); @@ -1292,7 +1292,7 @@ name_owner_changed(GObject *object, GParamSpec *pspec, gpointer user_data) prepare_object_manager(self); } else { const CList *tmp_lst; - NMDevice * device; + NMDevice *device; if (!priv->running) return; @@ -1310,9 +1310,9 @@ name_owner_changed(GObject *object, GParamSpec *pspec, gpointer user_data) static void device_added(NMManager *manager, NMDevice *device, gpointer user_data) { - NMIwdManager * self = user_data; + NMIwdManager *self = user_data; NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - GList * objects, *iter; + GList *objects, *iter; if (!NM_IS_DEVICE_IWD(device)) return; @@ -1331,7 +1331,7 @@ device_added(NMManager *manager, NMDevice *device, gpointer user_data) objects = g_dbus_object_manager_get_objects(priv->object_manager); for (iter = objects; iter; iter = iter->next) { - GDBusObject * object = G_DBUS_OBJECT(iter->data); + GDBusObject *object = G_DBUS_OBJECT(iter->data); gs_unref_object GDBusInterface *interface = NULL; interface = g_dbus_object_get_interface(object, NM_IWD_NETWORK_INTERFACE); @@ -1343,9 +1343,9 @@ device_added(NMManager *manager, NMDevice *device, gpointer user_data) } for (iter = objects; iter; iter = iter->next) { - GDBusObject * object = G_DBUS_OBJECT(iter->data); + GDBusObject *object = G_DBUS_OBJECT(iter->data); gs_unref_object GDBusInterface *interface = NULL; - const char * obj_ifname; + const char *obj_ifname; interface = g_dbus_object_get_interface(object, NM_IWD_DEVICE_INTERFACE); obj_ifname = get_property_string_or_null((GDBusProxy *) interface, "Name"); @@ -1363,7 +1363,7 @@ device_added(NMManager *manager, NMDevice *device, gpointer user_data) static void device_removed(NMManager *manager, NMDevice *device, gpointer user_data) { - NMIwdManager * self = user_data; + NMIwdManager *self = user_data; NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); if (!NM_IS_DEVICE_IWD(device)) @@ -1431,13 +1431,13 @@ object_compare_interfaces(gconstpointer a, gconstpointer b) static void get_daemon_info_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMIwdManager * self = user_data; - NMIwdManagerPrivate *priv; + NMIwdManager *self = user_data; + NMIwdManagerPrivate *priv; gs_unref_variant GVariant *properties = NULL; - gs_free_error GError *error = NULL; - GVariantIter * properties_iter; - const char * key; - GVariant * value; + gs_free_error GError *error = NULL; + GVariantIter *properties_iter; + const char *key; + GVariant *value; properties = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error); if (!properties) { @@ -1481,11 +1481,11 @@ next: static void got_object_manager(GObject *object, GAsyncResult *result, gpointer user_data) { - NMIwdManager * self = user_data; + NMIwdManager *self = user_data; NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - GError * error = NULL; - GDBusObjectManager * object_manager; - GDBusConnection * connection; + GError *error = NULL; + GDBusObjectManager *object_manager; + GDBusConnection *connection; object_manager = g_dbus_object_manager_client_new_for_bus_finish(result, &error); if (object_manager == NULL) { @@ -1515,7 +1515,7 @@ got_object_manager(GObject *object, GAsyncResult *result, gpointer user_data) } if (_om_has_name_owner(object_manager)) { - GList * objects, *iter; + GList *objects, *iter; gs_unref_object GDBusInterface *daemon = NULL; priv->running = true; @@ -1587,11 +1587,11 @@ nm_iwd_manager_is_known_network(NMIwdManager *self, const char *name, NMIwdNetwo NMSettingsConnection * nm_iwd_manager_get_ap_mirror_connection(NMIwdManager *self, NMWifiAP *ap) { - NMIwdManagerPrivate * priv = NM_IWD_MANAGER_GET_PRIVATE(self); - KnownNetworkData * data; + NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); + KnownNetworkData *data; char name_buf[33]; KnownNetworkId kn_id = {name_buf, NM_IWD_NETWORK_SECURITY_OPEN}; - const guint8 * ssid_bytes; + const guint8 *ssid_bytes; gsize ssid_len; NM80211ApFlags flags = nm_wifi_ap_get_flags(ap); NM80211ApSecurityFlags sec_flags = nm_wifi_ap_get_wpa_flags(ap) | nm_wifi_ap_get_rsn_flags(ap); @@ -1629,7 +1629,7 @@ GDBusProxy * nm_iwd_manager_get_dbus_interface(NMIwdManager *self, const char *path, const char *name) { NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); - GDBusInterface * interface; + GDBusInterface *interface; if (!priv->object_manager) return NULL; @@ -1691,7 +1691,7 @@ nm_iwd_manager_init(NMIwdManager *self) static void dispose(GObject *object) { - NMIwdManager * self = (NMIwdManager *) object; + NMIwdManager *self = (NMIwdManager *) object; NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE(self); release_object_manager(self); diff --git a/src/core/devices/wifi/nm-iwd-manager.h b/src/core/devices/wifi/nm-iwd-manager.h index e794e66127..b85d2e7149 100644 --- a/src/core/devices/wifi/nm-iwd-manager.h +++ b/src/core/devices/wifi/nm-iwd-manager.h @@ -42,8 +42,8 @@ GType nm_iwd_manager_get_type(void); NMIwdManager *nm_iwd_manager_get(void); -gboolean nm_iwd_manager_is_known_network(NMIwdManager * self, - const char * name, +gboolean nm_iwd_manager_is_known_network(NMIwdManager *self, + const char *name, NMIwdNetworkSecurity security); NMSettingsConnection *nm_iwd_manager_get_ap_mirror_connection(NMIwdManager *self, NMWifiAP *ap); diff --git a/src/core/devices/wifi/nm-wifi-ap.c b/src/core/devices/wifi/nm-wifi-ap.c index 72a6088504..ac0b748a51 100644 --- a/src/core/devices/wifi/nm-wifi-ap.c +++ b/src/core/devices/wifi/nm-wifi-ap.c @@ -41,8 +41,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMWifiAP, struct _NMWifiAPPrivate { /* Scanned or cached values */ - GBytes * ssid; - char * address; + GBytes *ssid; + char *address; _NM80211Mode mode; guint8 strength; guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */ @@ -430,7 +430,7 @@ has_proto(NMSettingWirelessSecurity *sec, const char *proto) static void add_pair_ciphers(NMWifiAP *ap, NMSettingWirelessSecurity *sec) { - NMWifiAPPrivate * priv = NM_WIFI_AP_GET_PRIVATE(ap); + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE(ap); guint32 num = nm_setting_wireless_security_get_num_pairwise(sec); NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE; guint32 i; @@ -458,7 +458,7 @@ add_pair_ciphers(NMWifiAP *ap, NMSettingWirelessSecurity *sec) static void add_group_ciphers(NMWifiAP *ap, NMSettingWirelessSecurity *sec) { - NMWifiAPPrivate * priv = NM_WIFI_AP_GET_PRIVATE(ap); + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE(ap); guint32 num = nm_setting_wireless_security_get_num_groups(sec); NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE; guint32 i; @@ -491,10 +491,10 @@ const char * nm_wifi_ap_to_string(const NMWifiAP *self, char *str_buf, gulong buf_len, gint64 now_msec) { const NMWifiAPPrivate *priv; - const char * supplicant_id = "-"; - const char * export_path; + const char *supplicant_id = "-"; + const char *export_path; guint32 chan; - gs_free char * ssid_to_free = NULL; + gs_free char *ssid_to_free = NULL; char str_buf_ts[100]; g_return_val_if_fail(NM_IS_WIFI_AP(self), NULL); @@ -558,13 +558,13 @@ freq_to_band(guint32 freq) gboolean nm_wifi_ap_check_compatible(NMWifiAP *self, NMConnection *connection) { - NMWifiAPPrivate * priv; - NMSettingWireless * s_wireless; + NMWifiAPPrivate *priv; + NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wireless_sec; - GBytes * ssid; - const char * mode; - const char * band; - const char * bssid; + GBytes *ssid; + const char *mode; + const char *band; + const char *bssid; guint32 channel; g_return_val_if_fail(NM_IS_WIFI_AP(self), FALSE); @@ -629,10 +629,10 @@ nm_wifi_ap_check_compatible(NMWifiAP *self, NMConnection *connection) } gboolean -nm_wifi_ap_complete_connection(NMWifiAP * self, +nm_wifi_ap_complete_connection(NMWifiAP *self, NMConnection *connection, gboolean lock_bssid, - GError ** error) + GError **error) { NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE(self); @@ -655,7 +655,7 @@ nm_wifi_ap_complete_connection(NMWifiAP * self, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMWifiAP * self = NM_WIFI_AP(object); + NMWifiAP *self = NM_WIFI_AP(object); NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE(self); switch (prop_id) { @@ -734,11 +734,11 @@ nm_wifi_ap_new_from_properties(const NMSupplicantBssInfo *bss_info) NMWifiAP * nm_wifi_ap_new_fake_from_connection(NMConnection *connection) { - NMWifiAP * ap; - NMWifiAPPrivate * priv; - NMSettingWireless * s_wireless; + NMWifiAP *ap; + NMWifiAPPrivate *priv; + NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wireless_sec; - const char * mode, *band, *key_mgmt; + const char *mode, *band, *key_mgmt; guint32 channel; NM80211ApSecurityFlags flags; gboolean psk = FALSE, eap = FALSE, adhoc = FALSE; @@ -845,7 +845,7 @@ error: static void finalize(GObject *object) { - NMWifiAP * self = NM_WIFI_AP(object); + NMWifiAP *self = NM_WIFI_AP(object); NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE(self); nm_assert(!self->wifi_device); @@ -890,7 +890,7 @@ nm_wifi_ap_class_init(NMWifiAPClass *ap_class) | NM_802_11_AP_SEC_KEY_MGMT_SAE | NM_802_11_AP_SEC_KEY_MGMT_OWE \ | NM_802_11_AP_SEC_KEY_MGMT_OWE_TM | NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192) - GObjectClass * object_class = G_OBJECT_CLASS(ap_class); + GObjectClass *object_class = G_OBJECT_CLASS(ap_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(ap_class); g_type_class_add_private(object_class, sizeof(NMWifiAPPrivate)); @@ -987,10 +987,10 @@ nm_wifi_ap_class_init(NMWifiAPClass *ap_class) const char ** nm_wifi_aps_get_paths(const CList *aps_lst_head, gboolean include_without_ssid) { - NMWifiAP * ap; + NMWifiAP *ap; gsize i, n; const char **list; - const char * path; + const char *path; n = c_list_length(aps_lst_head); list = g_new(const char *, n + 1); diff --git a/src/core/devices/wifi/nm-wifi-ap.h b/src/core/devices/wifi/nm-wifi-ap.h index bffd28a8d5..c0422900ae 100644 --- a/src/core/devices/wifi/nm-wifi-ap.h +++ b/src/core/devices/wifi/nm-wifi-ap.h @@ -32,9 +32,9 @@ typedef struct { NMDBusObject parent; - NMDevice * wifi_device; + NMDevice *wifi_device; CList aps_lst; - NMRefString * _supplicant_path; + NMRefString *_supplicant_path; struct _NMWifiAPPrivate *_priv; } NMWifiAP; @@ -47,15 +47,15 @@ GType nm_wifi_ap_get_type(void); NMWifiAP *nm_wifi_ap_new_from_properties(const struct _NMSupplicantBssInfo *bss_info); NMWifiAP *nm_wifi_ap_new_fake_from_connection(NMConnection *connection); -gboolean nm_wifi_ap_update_from_properties(NMWifiAP * ap, +gboolean nm_wifi_ap_update_from_properties(NMWifiAP *ap, const struct _NMSupplicantBssInfo *bss_info); gboolean nm_wifi_ap_check_compatible(NMWifiAP *self, NMConnection *connection); -gboolean nm_wifi_ap_complete_connection(NMWifiAP * self, +gboolean nm_wifi_ap_complete_connection(NMWifiAP *self, NMConnection *connection, gboolean lock_bssid, - GError ** error); + GError **error); static inline NMRefString * nm_wifi_ap_get_supplicant_path(NMWifiAP *ap) @@ -65,9 +65,9 @@ nm_wifi_ap_get_supplicant_path(NMWifiAP *ap) return ap->_supplicant_path; } -GBytes * nm_wifi_ap_get_ssid(const NMWifiAP *ap); +GBytes *nm_wifi_ap_get_ssid(const NMWifiAP *ap); gboolean nm_wifi_ap_set_ssid(NMWifiAP *ap, GBytes *ssid); -const char * nm_wifi_ap_get_address(const NMWifiAP *ap); +const char *nm_wifi_ap_get_address(const NMWifiAP *ap); gboolean nm_wifi_ap_set_address(NMWifiAP *ap, const char *addr); gboolean nm_wifi_ap_set_address_bin(NMWifiAP *ap, const NMEtherAddr *addr); _NM80211Mode nm_wifi_ap_get_mode(NMWifiAP *ap); diff --git a/src/core/devices/wifi/nm-wifi-common.c b/src/core/devices/wifi/nm-wifi-common.c index d029ce7f2a..681d9cb516 100644 --- a/src/core/devices/wifi/nm-wifi-common.c +++ b/src/core/devices/wifi/nm-wifi-common.c @@ -56,17 +56,17 @@ _dispatch_request_scan(NMDevice *device, GVariant *options, GDBusMethodInvocatio } static void -impl_device_wifi_get_access_points(NMDBusObject * obj, +impl_device_wifi_get_access_points(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { gs_free const char **list = NULL; - GVariant * v; - const CList * all_aps; + GVariant *v; + const CList *all_aps; /* NOTE: this handler is called both for NMDevicwWifi and NMDeviceIwd. */ @@ -77,17 +77,17 @@ impl_device_wifi_get_access_points(NMDBusObject * obj, } static void -impl_device_wifi_get_all_access_points(NMDBusObject * obj, +impl_device_wifi_get_all_access_points(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { gs_free const char **list = NULL; - GVariant * v; - const CList * all_aps; + GVariant *v; + const CList *all_aps; /* NOTE: this handler is called both for NMDevicwWifi and NMDeviceIwd. */ @@ -98,13 +98,13 @@ impl_device_wifi_get_all_access_points(NMDBusObject * obj, } static void -impl_device_wifi_request_scan(NMDBusObject * obj, +impl_device_wifi_request_scan(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { gs_unref_variant GVariant *options = NULL; diff --git a/src/core/devices/wifi/nm-wifi-factory.c b/src/core/devices/wifi/nm-wifi-factory.c index d2269c74ef..8f152413b8 100644 --- a/src/core/devices/wifi/nm-wifi-factory.c +++ b/src/core/devices/wifi/nm-wifi-factory.c @@ -50,7 +50,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES( NM_SETTING_OLPC_MESH_SETTING_NAME)) G_MODULE_EXPORT NMDeviceFactory * - nm_device_factory_create(GError **error) +nm_device_factory_create(GError **error) { return g_object_new(NM_TYPE_WIFI_FACTORY, NULL); } @@ -68,14 +68,14 @@ p2p_device_created(NMDeviceWifi *device, NMDeviceWifiP2P *p2p_device, NMDeviceFa } static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { gs_free char *backend_free = NULL; - const char * backend; + const char *backend; g_return_val_if_fail(iface != NULL, NULL); g_return_val_if_fail(plink != NULL, NULL); @@ -98,7 +98,7 @@ create_device(NMDeviceFactory * factory, NM_PRINT_FMT_QUOTE_STRING(backend), WITH_IWD ? " (iwd support enabled)" : ""); if (!backend || !g_ascii_strcasecmp(backend, "wpa_supplicant")) { - NMDevice * device; + NMDevice *device; _NMDeviceWifiCapabilities capabilities; _NM80211Mode mode; diff --git a/src/core/devices/wifi/nm-wifi-p2p-peer.c b/src/core/devices/wifi/nm-wifi-p2p-peer.c index ac13952db2..0c8f9ba776 100644 --- a/src/core/devices/wifi/nm-wifi-p2p-peer.c +++ b/src/core/devices/wifi/nm-wifi-p2p-peer.c @@ -77,8 +77,8 @@ const char ** nm_wifi_p2p_peers_get_paths(const CList *peers_lst_head) { NMWifiP2PPeer *peer; - const char ** list; - const char * path; + const char **list; + const char *path; gsize i, n; n = c_list_length(peers_lst_head); @@ -261,7 +261,7 @@ nm_wifi_p2p_peer_get_wfd_ies(const NMWifiP2PPeer *peer) gboolean nm_wifi_p2p_peer_set_wfd_ies(NMWifiP2PPeer *peer, GBytes *wfd_ies) { - NMWifiP2PPeerPrivate *priv; + NMWifiP2PPeerPrivate *priv; gs_unref_bytes GBytes *wfd_ies_old = NULL; g_return_val_if_fail(NM_IS_WIFI_P2P_PEER(peer), FALSE); @@ -423,8 +423,8 @@ const char * nm_wifi_p2p_peer_to_string(const NMWifiP2PPeer *self, char *str_buf, gsize buf_len, gint32 now_s) { const NMWifiP2PPeerPrivate *priv; - const char * supplicant_id = "-"; - const char * export_path; + const char *supplicant_id = "-"; + const char *export_path; g_return_val_if_fail(NM_IS_WIFI_P2P_PEER(self), NULL); @@ -461,8 +461,8 @@ gboolean nm_wifi_p2p_peer_check_compatible(NMWifiP2PPeer *self, NMConnection *connection) { NMWifiP2PPeerPrivate *priv; - NMSettingWifiP2P * s_wifi_p2p; - const char * hwaddr; + NMSettingWifiP2P *s_wifi_p2p; + const char *hwaddr; g_return_val_if_fail(NM_IS_WIFI_P2P_PEER(self), FALSE); g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE); @@ -486,7 +486,7 @@ nm_wifi_p2p_peer_check_compatible(NMWifiP2PPeer *self, NMConnection *connection) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMWifiP2PPeer * self = NM_WIFI_P2P_PEER(object); + NMWifiP2PPeer *self = NM_WIFI_P2P_PEER(object); NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(self); switch (prop_id) { @@ -562,7 +562,7 @@ nm_wifi_p2p_peer_new_from_properties(const NMSupplicantPeerInfo *peer_info) static void finalize(GObject *object) { - NMWifiP2PPeer * self = NM_WIFI_P2P_PEER(object); + NMWifiP2PPeer *self = NM_WIFI_P2P_PEER(object); NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(self); nm_assert(!self->wifi_device); @@ -613,7 +613,7 @@ static const NMDBusInterfaceInfoExtended interface_info_p2p_peer = { static void nm_wifi_p2p_peer_class_init(NMWifiP2PPeerClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); g_type_class_add_private(object_class, sizeof(NMWifiP2PPeerPrivate)); diff --git a/src/core/devices/wifi/nm-wifi-p2p-peer.h b/src/core/devices/wifi/nm-wifi-p2p-peer.h index ee4bfb53fe..f8a2890dff 100644 --- a/src/core/devices/wifi/nm-wifi-p2p-peer.h +++ b/src/core/devices/wifi/nm-wifi-p2p-peer.h @@ -33,7 +33,7 @@ typedef struct { NMDBusObject parent; - NMDevice * wifi_device; + NMDevice *wifi_device; CList peers_lst; struct _NMWifiP2PPeerPrivate *_priv; } NMWifiP2PPeer; @@ -46,7 +46,7 @@ GType nm_wifi_p2p_peer_get_type(void); NMWifiP2PPeer *nm_wifi_p2p_peer_new_from_properties(const struct _NMSupplicantPeerInfo *peer_info); -gboolean nm_wifi_p2p_peer_update_from_properties(NMWifiP2PPeer * peer, +gboolean nm_wifi_p2p_peer_update_from_properties(NMWifiP2PPeer *peer, const struct _NMSupplicantPeerInfo *peer_info); gboolean nm_wifi_p2p_peer_check_compatible(NMWifiP2PPeer *self, NMConnection *connection); @@ -64,12 +64,12 @@ gboolean nm_wifi_p2p_peer_set_model_number(NMWifiP2PPeer *peer, const char *n const char *nm_wifi_p2p_peer_get_serial(const NMWifiP2PPeer *peer); gboolean nm_wifi_p2p_peer_set_serial(NMWifiP2PPeer *peer, const char *serial); -GBytes * nm_wifi_p2p_peer_get_wfd_ies(const NMWifiP2PPeer *peer); +GBytes *nm_wifi_p2p_peer_get_wfd_ies(const NMWifiP2PPeer *peer); gboolean nm_wifi_p2p_peer_set_wfd_ies(NMWifiP2PPeer *peer, GBytes *bytes); const char *const *nm_wifi_p2p_peer_get_groups(const NMWifiP2PPeer *peer); -const char * nm_wifi_p2p_peer_get_address(const NMWifiP2PPeer *peer); +const char *nm_wifi_p2p_peer_get_address(const NMWifiP2PPeer *peer); gboolean nm_wifi_p2p_peer_set_address(NMWifiP2PPeer *peer, const char *addr); gint8 nm_wifi_p2p_peer_get_strength(NMWifiP2PPeer *peer); gboolean nm_wifi_p2p_peer_set_strength(NMWifiP2PPeer *peer, gint8 strength); @@ -80,11 +80,11 @@ nm_wifi_p2p_peer_to_string(const NMWifiP2PPeer *self, char *str_buf, gsize buf_l const char **nm_wifi_p2p_peers_get_paths(const CList *peers_lst_head); -NMWifiP2PPeer *nm_wifi_p2p_peers_find_first_compatible(const CList * peers_lst_head, +NMWifiP2PPeer *nm_wifi_p2p_peers_find_first_compatible(const CList *peers_lst_head, NMConnection *connection); NMWifiP2PPeer *nm_wifi_p2p_peers_find_by_supplicant_path(const CList *peers_lst_head, - const char * path); + const char *path); NMWifiP2PPeer *nm_wifi_p2p_peer_lookup_for_device(NMDevice *device, const char *exported_path); diff --git a/src/core/devices/wifi/nm-wifi-utils.c b/src/core/devices/wifi/nm-wifi-utils.c index 4939e78668..c3f3b1200f 100644 --- a/src/core/devices/wifi/nm-wifi-utils.c +++ b/src/core/devices/wifi/nm-wifi-utils.c @@ -41,9 +41,9 @@ verify_no_wep(NMSettingWirelessSecurity *s_wsec, const char *tag, GError **error static gboolean verify_leap(NMSettingWirelessSecurity *s_wsec, - NMSetting8021x * s_8021x, + NMSetting8021x *s_8021x, gboolean adhoc, - GError ** error) + GError **error) { const char *key_mgmt, *auth_alg, *leap_username; @@ -224,9 +224,9 @@ verify_no_wpa(NMSettingWirelessSecurity *s_wsec, const char *tag, GError **error static gboolean verify_dynamic_wep(NMSettingWirelessSecurity *s_wsec, - NMSetting8021x * s_8021x, + NMSetting8021x *s_8021x, gboolean adhoc, - GError ** error) + GError **error) { const char *key_mgmt, *auth_alg, *leap_username; @@ -303,11 +303,11 @@ verify_dynamic_wep(NMSettingWirelessSecurity *s_wsec, static gboolean verify_wpa_psk(NMSettingWirelessSecurity *s_wsec, - NMSetting8021x * s_8021x, + NMSetting8021x *s_8021x, gboolean adhoc, guint32 wpa_flags, guint32 rsn_flags, - GError ** error) + GError **error) { const char *key_mgmt, *auth_alg; @@ -400,10 +400,10 @@ verify_wpa_psk(NMSettingWirelessSecurity *s_wsec, static gboolean verify_wpa_eap(NMSettingWirelessSecurity *s_wsec, - NMSetting8021x * s_8021x, + NMSetting8021x *s_8021x, guint32 wpa_flags, guint32 rsn_flags, - GError ** error) + GError **error) { const char *key_mgmt, *auth_alg; gboolean is_wpa_eap = FALSE; @@ -465,9 +465,9 @@ verify_wpa_eap(NMSettingWirelessSecurity *s_wsec, static gboolean verify_adhoc(NMSettingWirelessSecurity *s_wsec, - NMSetting8021x * s_8021x, + NMSetting8021x *s_8021x, gboolean adhoc, - GError ** error) + GError **error) { const char *key_mgmt = NULL, *leap_username = NULL, *auth_alg = NULL; @@ -529,8 +529,8 @@ verify_adhoc(NMSettingWirelessSecurity *s_wsec, } gboolean -nm_wifi_utils_complete_connection(GBytes * ap_ssid, - const char * bssid, +nm_wifi_utils_complete_connection(GBytes *ap_ssid, + const char *bssid, _NM80211Mode ap_mode, guint32 ap_freq, guint32 ap_flags, @@ -538,13 +538,13 @@ nm_wifi_utils_complete_connection(GBytes * ap_ssid, guint32 ap_rsn_flags, NMConnection *connection, gboolean lock_bssid, - GError ** error) + GError **error) { - NMSettingWireless * s_wifi; + NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSetting8021x * s_8021x; - GBytes * ssid; - const char * mode, *key_mgmt, *auth_alg, *leap_username; + NMSetting8021x *s_8021x; + GBytes *ssid; + const char *mode, *key_mgmt, *auth_alg, *leap_username; gboolean adhoc = FALSE; gboolean mesh = FALSE; @@ -892,20 +892,20 @@ nm_wifi_utils_is_manf_default_ssid(GBytes *ssid) /* To be used for connections where the SSID has been validated before */ gboolean -nm_wifi_connection_get_iwd_ssid_and_security(NMConnection * connection, - char ** ssid, +nm_wifi_connection_get_iwd_ssid_and_security(NMConnection *connection, + char **ssid, NMIwdNetworkSecurity *security) { - NMSettingWireless * s_wireless; + NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wireless_sec; - const char * key_mgmt = NULL; + const char *key_mgmt = NULL; s_wireless = nm_connection_get_setting_wireless(connection); if (!s_wireless) return FALSE; if (ssid) { - GBytes * bytes = nm_setting_wireless_get_ssid(s_wireless); + GBytes *bytes = nm_setting_wireless_get_ssid(s_wireless); gsize ssid_len; const char *ssid_str = (const char *) g_bytes_get_data(bytes, &ssid_len); @@ -947,7 +947,7 @@ nm_wifi_connection_get_iwd_ssid_and_security(NMConnection * connection, * @ssid_len can be -1 instead of actual SSID length. */ char * -nm_wifi_utils_get_iwd_config_filename(const char * ssid, +nm_wifi_utils_get_iwd_config_filename(const char *ssid, gssize ssid_len, NMIwdNetworkSecurity security) { @@ -995,10 +995,10 @@ static gboolean psk_setting_to_iwd_config(GKeyFile *file, NMSettingWirelessSecurity *s_wsec, GError **error) { NMSettingSecretFlags psk_flags = nm_setting_wireless_security_get_psk_flags(s_wsec); - const char * psk = nm_setting_wireless_security_get_psk(s_wsec); + const char *psk = nm_setting_wireless_security_get_psk(s_wsec); gsize psk_len; guint8 buffer[32]; - const char * key_mgmt = nm_setting_wireless_security_get_key_mgmt(s_wsec); + const char *key_mgmt = nm_setting_wireless_security_get_key_mgmt(s_wsec); if (!psk || NM_FLAGS_ANY(psk_flags, SECRETS_DONT_STORE_FLAGS)) { if (NM_FLAGS_ANY(psk_flags, SECRETS_DONT_STORE_FLAGS)) { @@ -1029,11 +1029,11 @@ psk_setting_to_iwd_config(GKeyFile *file, NMSettingWirelessSecurity *s_wsec, GEr } static gboolean -eap_certs_to_iwd_config(GKeyFile * file, +eap_certs_to_iwd_config(GKeyFile *file, NMSetting8021x *s_8021x, bool phase2, - char * iwd_prefix, - GError ** error) + char *iwd_prefix, + GError **error) { NMSetting8021xCKScheme ca_cert_scheme = phase2 ? nm_setting_802_1x_get_phase2_ca_cert_scheme(s_8021x) @@ -1043,13 +1043,13 @@ eap_certs_to_iwd_config(GKeyFile * file, : nm_setting_802_1x_get_client_cert_scheme(s_8021x); NMSetting8021xCKScheme key_scheme; NMSettingSecretFlags key_password_flags; - const char * ca_path = phase2 ? nm_setting_802_1x_get_phase2_ca_path(s_8021x) + const char *ca_path = phase2 ? nm_setting_802_1x_get_phase2_ca_path(s_8021x) : nm_setting_802_1x_get_ca_path(s_8021x); - const char * cert_path; - const char * key_path = NULL; - const char * key_password; - const char * domain_suffix_match; - const char * domain_match; + const char *cert_path; + const char *key_path = NULL; + const char *key_password; + const char *domain_suffix_match; + const char *domain_match; char setting_buf[128]; /* TODO: should check that all certificates and the key are RSA */ @@ -1220,7 +1220,7 @@ private_key_done: : nm_setting_802_1x_get_domain_match(s_8021x); if (domain_suffix_match || domain_match) { - GString * s = g_string_sized_new(128); + GString *s = g_string_sized_new(128); const char *ptr; const char *end; @@ -1287,13 +1287,13 @@ eap_optional_identity_to_iwd_config(GKeyFile *file, const char *iwd_prefix, cons } static gboolean -eap_optional_password_to_iwd_config(GKeyFile * file, - const char * iwd_prefix, +eap_optional_password_to_iwd_config(GKeyFile *file, + const char *iwd_prefix, NMSetting8021x *s_8021x, - GError ** error) + GError **error) { char setting_buf[128]; - const char * password = nm_setting_802_1x_get_password(s_8021x); + const char *password = nm_setting_802_1x_get_password(s_8021x); NMSettingSecretFlags flags = nm_setting_802_1x_get_password_flags(s_8021x); if (!password && nm_setting_802_1x_get_password_raw(s_8021x)) { @@ -1347,12 +1347,12 @@ eap_phase1_identity_to_iwd_config(GKeyFile *file, const char *iwd_prefix, NMSett } static gboolean -eap_method_config_to_iwd_config(GKeyFile * file, +eap_method_config_to_iwd_config(GKeyFile *file, NMSetting8021x *s_8021x, gboolean phase2, - const char * method, - const char * iwd_prefix, - GError ** error) + const char *method, + const char *iwd_prefix, + GError **error) { char prefix_buf[128]; @@ -1677,18 +1677,18 @@ ip6_config_to_iwd_config(GKeyFile *file, NMSettingIPConfig *s_ip, GError **error GKeyFile * nm_wifi_utils_connection_to_iwd_config(NMConnection *connection, - char ** out_filename, - GError ** error) + char **out_filename, + GError **error) { - NMSettingConnection * s_conn = nm_connection_get_setting_connection(connection); - NMSettingWireless * s_wifi = nm_connection_get_setting_wireless(connection); - GBytes * ssid; - const guint8 * ssid_data; - gsize ssid_len; - NMIwdNetworkSecurity security; - const char * cloned_mac_addr; - gs_free char * comment = NULL; - nm_auto_unref_keyfile GKeyFile *file = NULL; + NMSettingConnection *s_conn = nm_connection_get_setting_connection(connection); + NMSettingWireless *s_wifi = nm_connection_get_setting_wireless(connection); + GBytes *ssid; + const guint8 *ssid_data; + gsize ssid_len; + NMIwdNetworkSecurity security; + const char *cloned_mac_addr; + gs_free char *comment = NULL; + nm_auto_unref_keyfile GKeyFile *file = NULL; if (!s_conn || !s_wifi || !nm_streq(nm_setting_connection_get_connection_type(s_conn), diff --git a/src/core/devices/wifi/nm-wifi-utils.h b/src/core/devices/wifi/nm-wifi-utils.h index 2664c03ea5..5085e99af7 100644 --- a/src/core/devices/wifi/nm-wifi-utils.h +++ b/src/core/devices/wifi/nm-wifi-utils.h @@ -20,8 +20,8 @@ typedef enum { NM_IWD_NETWORK_SECURITY_8021X, } NMIwdNetworkSecurity; -gboolean nm_wifi_utils_complete_connection(GBytes * ssid, - const char * bssid, +gboolean nm_wifi_utils_complete_connection(GBytes *ssid, + const char *bssid, _NM80211Mode mode, guint32 ap_freq, guint32 flags, @@ -29,14 +29,14 @@ gboolean nm_wifi_utils_complete_connection(GBytes * ssid, guint32 rsn_flags, NMConnection *connection, gboolean lock_bssid, - GError ** error); + GError **error); gboolean nm_wifi_utils_is_manf_default_ssid(GBytes *ssid); -gboolean nm_wifi_connection_get_iwd_ssid_and_security(NMConnection * connection, - char ** ssid, +gboolean nm_wifi_connection_get_iwd_ssid_and_security(NMConnection *connection, + char **ssid, NMIwdNetworkSecurity *security); -char * nm_wifi_utils_get_iwd_config_filename(const char * ssid, +char *nm_wifi_utils_get_iwd_config_filename(const char *ssid, gssize ssid_len, NMIwdNetworkSecurity security); diff --git a/src/core/devices/wifi/tests/test-devices-wifi.c b/src/core/devices/wifi/tests/test-devices-wifi.c index 5d1167cff9..69d365e3d3 100644 --- a/src/core/devices/wifi/tests/test-devices-wifi.c +++ b/src/core/devices/wifi/tests/test-devices-wifi.c @@ -47,18 +47,18 @@ } static gboolean -complete_connection(const char * ssid, - const char * bssid, +complete_connection(const char *ssid, + const char *bssid, _NM80211Mode mode, guint32 flags, guint32 wpa_flags, guint32 rsn_flags, gboolean lock_bssid, NMConnection *src, - GError ** error) + GError **error) { gs_unref_bytes GBytes *ssid_b = NULL; - NMSettingWireless * s_wifi; + NMSettingWireless *s_wifi; /* Add a wifi setting if one doesn't exist */ s_wifi = nm_connection_get_setting_wireless(src); @@ -91,8 +91,8 @@ static void set_items(NMSetting *setting, const KeyData *items) { const KeyData *item; - GParamSpec * pspec; - GBytes * tmp; + GParamSpec *pspec; + GBytes *tmp; for (item = items; item && item->key; item++) { g_assert(item->key); @@ -199,9 +199,9 @@ fill_8021x(NMConnection *connection, const KeyData items[]) static NMConnection * create_basic(const char *ssid, const char *bssid, _NM80211Mode mode) { - NMConnection * connection; + NMConnection *connection; NMSettingWireless *s_wifi = NULL; - GBytes * tmp; + GBytes *tmp; connection = nm_simple_connection_new(); @@ -233,10 +233,10 @@ static void test_lock_bssid(void) { NMConnection *src, *expected; - const char * bssid = "01:02:03:04:05:06"; - const char * ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; gboolean success; - GError * error = NULL; + GError *error = NULL; src = nm_simple_connection_new(); success = complete_connection(ssid, @@ -261,10 +261,10 @@ static void test_open_ap_empty_connection(void) { NMConnection *src, *expected; - const char * bssid = "01:02:03:04:05:06"; - const char * ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that an empty source connection is correctly filled with the * SSID and Infra modes of the given AP details. @@ -293,11 +293,11 @@ static void test_open_ap_leap_connection_1(gconstpointer add_wifi) { NMConnection *src; - const char * bssid = "01:02:03:04:05:06"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "Bill Smith", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that a basic connection filled with a LEAP username is * rejected when completion is attempted with an open AP. LEAP requires @@ -330,10 +330,10 @@ static void test_open_ap_leap_connection_2(void) { NMConnection *src; - const char * bssid = "01:02:03:04:05:06"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that a basic connection specifying IEEE8021x security (ie, Dynamic * WEP or LEAP) is rejected when completion is attempted with an open AP. @@ -364,14 +364,14 @@ static void test_open_ap_wep_connection(gconstpointer add_wifi) { NMConnection *src; - const char * bssid = "01:02:03:04:05:06"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = { {NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "11111111111111111111111111", 0}, {NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, NULL, 0}, {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that a static WEP connection is rejected when completion is * attempted with an open AP. @@ -399,8 +399,8 @@ test_open_ap_wep_connection(gconstpointer add_wifi) /*****************************************************************************/ static void -test_ap_wpa_psk_connection_base(const char * key_mgmt, - const char * auth_alg, +test_ap_wpa_psk_connection_base(const char *key_mgmt, + const char *auth_alg, guint32 flags, guint32 wpa_flags, guint32 rsn_flags, @@ -409,8 +409,8 @@ test_ap_wpa_psk_connection_base(const char * key_mgmt, NMConnection *expected) { NMConnection *src; - const char * ssid = "blahblah"; - const char * bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; const KeyData exp_wifi[] = {{NM_SETTING_WIRELESS_SSID, ssid, 0}, {NM_SETTING_WIRELESS_MODE, "infrastructure", 0}, {NULL}}; @@ -419,7 +419,7 @@ test_ap_wpa_psk_connection_base(const char * key_mgmt, {NM_SETTING_WIRELESS_SECURITY_PSK, "asdfasdfasdfasdfasdfafs", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; src = nm_simple_connection_new(); if (add_wifi) @@ -538,13 +538,13 @@ test_ap_wpa_eap_connection_base(const char *key_mgmt, guint error_code) { NMConnection *src; - const char * bssid = "01:02:03:04:05:06"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_empty[] = {{NULL}}; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0}, {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg, 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; src = nm_simple_connection_new(); if (add_wifi) @@ -738,11 +738,11 @@ static void test_priv_ap_empty_connection(void) { NMConnection *src, *expected; - const char * bssid = "01:02:03:04:05:06"; - const char * ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; const KeyData exp_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that an empty connection is completed to a valid Static WEP * connection when completed with an AP with the Privacy bit set. @@ -774,9 +774,9 @@ static void test_priv_ap_leap_connection_1(gconstpointer add_wifi) { NMConnection *src, *expected; - const char * ssid = "blahblah"; - const char * bssid = "01:02:03:04:05:06"; - const char * leap_username = "Bill Smith"; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const char *leap_username = "Bill Smith"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, {NULL}}; @@ -785,7 +785,7 @@ test_priv_ap_leap_connection_1(gconstpointer add_wifi) {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that an minimal LEAP connection specifying only key management and * the LEAP username is completed to a full LEAP connection when completed @@ -823,12 +823,12 @@ static void test_priv_ap_leap_connection_2(void) { NMConnection *src; - const char * bssid = "01:02:03:04:05:06"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that an minimal LEAP connection specifying only key management and * the LEAP auth alg is completed to a full LEAP connection when completed @@ -859,8 +859,8 @@ static void test_priv_ap_dynamic_wep_1(void) { NMConnection *src, *expected; - const char * ssid = "blahblah"; - const char * bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, {NULL}}; @@ -872,7 +872,7 @@ test_priv_ap_dynamic_wep_1(void) {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that an minimal Dynamic WEP connection specifying key management, * the auth algorithm, and valid 802.1x setting is completed to a valid @@ -909,8 +909,8 @@ static void test_priv_ap_dynamic_wep_2(void) { NMConnection *src, *expected; - const char * ssid = "blahblah"; - const char * bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, {NULL}}; const KeyData both_8021x[] = {{NM_SETTING_802_1X_EAP, "peap", 0}, {NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0}, @@ -920,7 +920,7 @@ test_priv_ap_dynamic_wep_2(void) {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that an minimal Dynamic WEP connection specifying only the auth * algorithm and a valid 802.1x setting is completed to a valid Dynamic @@ -957,14 +957,14 @@ static void test_priv_ap_dynamic_wep_3(void) { NMConnection *src; - const char * bssid = "01:02:03:04:05:06"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", 0}, {NULL}}; const KeyData src_8021x[] = {{NM_SETTING_802_1X_EAP, "peap", 0}, {NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0}, {NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Ensure that a basic connection specifying 'shared' auth and an 802.1x * setting is rejected, as 802.1x is incompatible with 'shared' auth. @@ -1086,13 +1086,13 @@ test_wpa_ap_empty_connection(gconstpointer data) { guint idx = GPOINTER_TO_UINT(data); NMConnection *src, *expected; - const char * bssid = "01:02:03:04:05:06"; - const char * ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; const KeyData exp_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0}, {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that a basic WPA-PSK connection specifying just key management and * the auth algorithm is completed successfully when given an AP with WPA @@ -1126,14 +1126,14 @@ test_wpa_ap_leap_connection_1(gconstpointer data) { guint idx = GPOINTER_TO_UINT(data); NMConnection *src; - const char * ssid = "blahblah"; - const char * bssid = "01:02:03:04:05:06"; - const char * leap_username = "Bill Smith"; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const char *leap_username = "Bill Smith"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that completion of a LEAP connection with a WPA-enabled AP is * rejected since WPA APs (usually) do not support LEAP. @@ -1164,12 +1164,12 @@ test_wpa_ap_leap_connection_2(gconstpointer data) { guint idx = GPOINTER_TO_UINT(data); NMConnection *src; - const char * bssid = "01:02:03:04:05:06"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that completion of a LEAP connection with a WPA-enabled AP is * rejected since WPA APs (usually) do not support LEAP. @@ -1200,10 +1200,10 @@ test_wpa_ap_dynamic_wep_connection(gconstpointer data) { guint idx = GPOINTER_TO_UINT(data); NMConnection *src; - const char * bssid = "01:02:03:04:05:06"; + const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, {NULL}}; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test that completion of a Dynamic WEP connection with a WPA-enabled AP is * rejected since WPA APs (usually) do not support Dynamic WEP. @@ -1409,12 +1409,12 @@ test_strength_all(void) static void do_test_ssids_options_to_ptrarray(const char *const *ssids) { - GVariantBuilder builder; - gs_unref_variant GVariant *variant = NULL; + GVariantBuilder builder; + gs_unref_variant GVariant *variant = NULL; gs_unref_ptrarray GPtrArray *ssids_arr = NULL; - gs_free_error GError *error = NULL; - gsize len; - gsize i; + gs_free_error GError *error = NULL; + gsize len; + gsize i; g_assert(ssids); @@ -1443,7 +1443,7 @@ do_test_ssids_options_to_ptrarray(const char *const *ssids) g_assert_cmpint(len, ==, ssids_arr->len); for (i = 0; i < len; i++) { const char *ssid = ssids[i]; - GBytes * bytes = ssids_arr->pdata[i]; + GBytes *bytes = ssids_arr->pdata[i]; g_assert(nm_g_bytes_equal_mem(bytes, ssid, strlen(ssid))); } diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index 176614783d..656fb82613 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -30,13 +30,13 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDeviceModem, PROP_APN, ); typedef struct { - NMModem * modem; + NMModem *modem; NMDeviceModemCapabilities caps; NMDeviceModemCapabilities current_caps; NMUtilsIPv6IfaceId iid; - char * device_id; - char * operator_code; - char * apn; + char *device_id; + char *operator_code; + char *apn; bool rf_enabled : 1; NMDeviceStageState stage1_state : 3; NMDeviceStageState stage2_state : 3; @@ -61,7 +61,7 @@ G_DEFINE_TYPE(NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) static void ppp_failed(NMModem *modem, guint i_reason, gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); + NMDevice *device = NM_DEVICE(user_data); NMDeviceStateReason reason = i_reason; nm_device_state_changed(device, NM_DEVICE_STATE_FAILED, reason); @@ -70,9 +70,9 @@ ppp_failed(NMModem *modem, guint i_reason, gpointer user_data) static void modem_prepare_result(NMModem *modem, gboolean success, guint i_reason, gpointer user_data) { - NMDeviceModem * self = NM_DEVICE_MODEM(user_data); + NMDeviceModem *self = NM_DEVICE_MODEM(user_data); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); NMDeviceStateReason reason = i_reason; if (nm_device_get_state(device) != NM_DEVICE_STATE_PREPARE @@ -141,7 +141,7 @@ modem_auth_requested(NMModem *modem, gpointer user_data) static void modem_auth_result(NMModem *modem, GError *error, gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); + NMDevice *device = NM_DEVICE(user_data); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); g_return_if_fail(nm_device_get_state(device) == NM_DEVICE_STATE_NEED_AUTH); @@ -156,19 +156,19 @@ modem_auth_result(NMModem *modem, GError *error, gpointer user_data) } static void -modem_new_config(NMModem * modem, +modem_new_config(NMModem *modem, int addr_family, - const NML3ConfigData * l3cd, + const NML3ConfigData *l3cd, gboolean do_auto, const NMUtilsIPv6IfaceId *iid, int failure_reason_i, - GError * error, + GError *error, gpointer user_data) { const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMDeviceModem * self = NM_DEVICE_MODEM(user_data); + NMDeviceModem *self = NM_DEVICE_MODEM(user_data); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); - NMDevice * device = NM_DEVICE(self); + NMDevice *device = NM_DEVICE(self); g_return_if_fail(nm_device_devip_get_state(device, addr_family) == NM_DEVICE_IP_STATE_PENDING); @@ -194,8 +194,8 @@ modem_new_config(NMModem * modem, static void ip_ifindex_changed_cb(NMModem *modem, GParamSpec *pspec, gpointer user_data) { - NMDevice * device = NM_DEVICE(user_data); - NMDeviceModem * self = NM_DEVICE_MODEM(device); + NMDevice *device = NM_DEVICE(user_data); + NMDeviceModem *self = NM_DEVICE_MODEM(device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); if (!nm_device_is_activating(device)) @@ -223,9 +223,9 @@ ip_ifindex_changed_cb(NMModem *modem, GParamSpec *pspec, gpointer user_data) static void operator_code_changed_cb(NMModem *modem, GParamSpec *pspec, gpointer user_data) { - NMDeviceModem * self = NM_DEVICE_MODEM(user_data); + NMDeviceModem *self = NM_DEVICE_MODEM(user_data); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); - const char * operator_code = nm_modem_get_operator_code(modem); + const char *operator_code = nm_modem_get_operator_code(modem); if (g_strcmp0(priv->operator_code, operator_code) != 0) { g_free(priv->operator_code); @@ -237,9 +237,9 @@ operator_code_changed_cb(NMModem *modem, GParamSpec *pspec, gpointer user_data) static void apn_changed_cb(NMModem *modem, GParamSpec *pspec, gpointer user_data) { - NMDeviceModem * self = NM_DEVICE_MODEM(user_data); + NMDeviceModem *self = NM_DEVICE_MODEM(user_data); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); - const char * apn = nm_modem_get_apn(modem); + const char *apn = nm_modem_get_apn(modem); if (g_strcmp0(priv->apn, apn) != 0) { g_free(priv->apn); @@ -259,7 +259,7 @@ modem_state_cb(NMModem *modem, int new_state_i, int old_state_i, gpointer user_d { NMModemState new_state = new_state_i; NMModemState old_state = old_state_i; - NMDevice * device = NM_DEVICE(user_data); + NMDevice *device = NM_DEVICE(user_data); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); NMDeviceState dev_state = nm_device_get_state(device); @@ -331,12 +331,12 @@ owns_iface(NMDevice *device, const char *iface) /*****************************************************************************/ static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) { - NMDeviceModem * self = NM_DEVICE_MODEM(device); + NMDeviceModem *self = NM_DEVICE_MODEM(device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); g_return_if_fail(priv->modem); @@ -398,13 +398,13 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError * } static gboolean -check_connection_available(NMDevice * device, - NMConnection * connection, +check_connection_available(NMDevice *device, + NMConnection *connection, NMDeviceCheckConAvailableFlags flags, - const char * specific_object, - GError ** error) + const char *specific_object, + GError **error) { - NMDeviceModem * self = NM_DEVICE_MODEM(device); + NMDeviceModem *self = NM_DEVICE_MODEM(device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); NMModemState state; @@ -443,11 +443,11 @@ check_connection_available(NMDevice * device, } static gboolean -complete_connection(NMDevice * device, - NMConnection * connection, - const char * specific_object, +complete_connection(NMDevice *device, + NMConnection *connection, + const char *specific_object, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); @@ -473,7 +473,7 @@ deactivate(NMDevice *device) static void modem_deactivate_async_cb(NMModem *modem, GError *error, gpointer user_data) { - gs_unref_object NMDevice * self = NULL; + gs_unref_object NMDevice *self = NULL; NMDeviceDeactivateCallback callback; gpointer callback_user_data; @@ -482,8 +482,8 @@ modem_deactivate_async_cb(NMModem *modem, GError *error, gpointer user_data) } static void -deactivate_async(NMDevice * self, - GCancellable * cancellable, +deactivate_async(NMDevice *self, + GCancellable *cancellable, NMDeviceDeactivateCallback callback, gpointer user_data) { @@ -503,7 +503,7 @@ static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); - NMActRequest * req; + NMActRequest *req; req = nm_device_get_act_request(device); g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); @@ -552,7 +552,7 @@ act_stage3_ip_config(NMDevice *device, int addr_family) static gboolean get_ip_iface_identifier(NMDevice *device, NMUtilsIPv6IfaceId *out_iid) { - NMDeviceModem * self = NM_DEVICE_MODEM(device); + NMDeviceModem *self = NM_DEVICE_MODEM(device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); g_return_val_if_fail(priv->modem, FALSE); @@ -579,7 +579,7 @@ get_enabled(NMDevice *device) static void set_enabled(NMDevice *device, gboolean enabled) { - NMDeviceModem * self = NM_DEVICE_MODEM(device); + NMDeviceModem *self = NM_DEVICE_MODEM(device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); /* Called only by the Manager in response to rfkill switch changes or @@ -600,7 +600,7 @@ set_enabled(NMDevice *device, gboolean enabled) static gboolean is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { - NMDeviceModem * self = NM_DEVICE_MODEM(device); + NMDeviceModem *self = NM_DEVICE_MODEM(device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); NMModemState modem_state; @@ -806,9 +806,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_modem = { static void nm_device_modem_class_init(NMDeviceModemClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMDeviceClass * device_class = NM_DEVICE_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->dispose = dispose; object_class->get_property = get_property; diff --git a/src/core/devices/wwan/nm-modem-broadband.c b/src/core/devices/wwan/nm-modem-broadband.c index 483314ff21..319d77a9b8 100644 --- a/src/core/devices/wwan/nm-modem-broadband.c +++ b/src/core/devices/wwan/nm-modem-broadband.c @@ -61,13 +61,13 @@ typedef struct { ConnectStep step; MMModemCapability caps; - NMConnection * connection; - GCancellable * cancellable; + NMConnection *connection; + GCancellable *cancellable; MMSimpleConnectProperties *connect_properties; - GArray * ip_types; + GArray *ip_types; guint ip_types_i; guint ip_type_tries; - GError * first_error; + GError *first_error; } ConnectContext; /*****************************************************************************/ @@ -78,15 +78,15 @@ typedef struct { /* The modem object from dbus */ MMObject *modem_object; /* Per-interface objects */ - MMModem * modem_iface; - MMModem3gpp * modem_3gpp_iface; + MMModem *modem_iface; + MMModem3gpp *modem_3gpp_iface; MMModemSimple *simple_iface; - MMSim * sim_iface; + MMSim *sim_iface; /* Connection setup */ ConnectContext *ctx; - MMBearer * bearer; + MMBearer *bearer; MMBearerIpConfig *ipv4_config; MMBearerIpConfig *ipv6_config; @@ -119,7 +119,7 @@ G_DEFINE_TYPE(NMModemBroadband, nm_modem_broadband, NM_TYPE_MODEM) if (nm_logging_enabled(_level, (_NMLOG_DOMAIN))) { \ NMModemBroadband *const __self = (self); \ char __prefix_name[128]; \ - const char * __uid; \ + const char *__uid; \ \ _nm_log(_level, \ (_NMLOG_DOMAIN), \ @@ -195,11 +195,11 @@ translate_mm_error(NMModemBroadband *self, GError *error) /*****************************************************************************/ static void -get_capabilities(NMModem * _self, +get_capabilities(NMModem *_self, NMDeviceModemCapabilities *modem_caps, NMDeviceModemCapabilities *current_caps) { - NMModemBroadband * self = NM_MODEM_BROADBAND(_self); + NMModemBroadband *self = NM_MODEM_BROADBAND(_self); MMModemCapability all_supported = MM_MODEM_CAPABILITY_NONE; MMModemCapability *supported; guint n_supported; @@ -223,7 +223,7 @@ get_capabilities(NMModem * _self, static gboolean owns_port(NMModem *_self, const char *iface) { - NMModemBroadband * self = NM_MODEM_BROADBAND(_self); + NMModemBroadband *self = NM_MODEM_BROADBAND(_self); const MMModemPortInfo *ports = NULL; guint n_ports = 0, i; @@ -274,7 +274,7 @@ create_cdma_connect_properties(NMConnection *connection) #if !MM_CHECK_VERSION(1, 9, 1) { NMSettingCdma *setting; - const char * str; + const char *str; setting = nm_connection_get_setting_cdma(connection); str = nm_setting_cdma_get_number(setting); @@ -288,14 +288,14 @@ create_cdma_connect_properties(NMConnection *connection) static MMSimpleConnectProperties * create_gsm_connect_properties(NMConnection *connection, - const char * apn, - const char * username, - const char * password) + const char *apn, + const char *username, + const char *password) { - NMSettingGsm * setting; - NMSettingPpp * s_ppp; + NMSettingGsm *setting; + NMSettingPpp *s_ppp; MMSimpleConnectProperties *properties; - const char * str; + const char *str; setting = nm_connection_get_setting_gsm(connection); @@ -365,11 +365,11 @@ static void connect_context_step(NMModemBroadband *self); static void connect_ready(MMModemSimple *simple_iface, GAsyncResult *res, NMModemBroadband *self) { - ConnectContext *ctx; - GError * error = NULL; - NMModemIPMethod ip4_method = NM_MODEM_IP_METHOD_UNKNOWN; - NMModemIPMethod ip6_method = NM_MODEM_IP_METHOD_UNKNOWN; - gs_unref_object MMBearer *bearer = NULL; + ConnectContext *ctx; + GError *error = NULL; + NMModemIPMethod ip4_method = NM_MODEM_IP_METHOD_UNKNOWN; + NMModemIPMethod ip6_method = NM_MODEM_IP_METHOD_UNKNOWN; + gs_unref_object MMBearer *bearer = NULL; bearer = mm_modem_simple_connect_finish(simple_iface, res, &error); @@ -476,18 +476,18 @@ send_pin_ready(MMSim *sim, GAsyncResult *result, NMModemBroadband *self) } static void -find_gsm_apn_cb(const char * apn, - const char * username, - const char * password, - const char * gateway, - const char * auth_method, +find_gsm_apn_cb(const char *apn, + const char *username, + const char *password, + const char *gateway, + const char *auth_method, const GSList *dns, - GError * error, + GError *error, gpointer user_data) { - NMModemBroadband * self = user_data; + NMModemBroadband *self = user_data; NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE(self); - ConnectContext * ctx = priv->ctx; + ConnectContext *ctx = priv->ctx; if (error) { _LOGW("failed to connect '%s': APN not found: %s", @@ -510,14 +510,14 @@ static gboolean try_create_connect_properties(NMModemBroadband *self) { NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE(self); - ConnectContext * ctx = priv->ctx; + ConnectContext *ctx = priv->ctx; if (MODEM_CAPS_3GPP(ctx->caps)) { NMSettingGsm *s_gsm = nm_connection_get_setting_gsm(ctx->connection); if (!s_gsm || nm_setting_gsm_get_auto_config(s_gsm)) { gs_unref_object MMModem3gpp *modem_3gpp = NULL; - const char * network_id = NULL; + const char *network_id = NULL; s_gsm = nm_connection_get_setting_gsm(ctx->connection); if (s_gsm) @@ -586,7 +586,7 @@ connect_context_step(NMModemBroadband *self) if (MODEM_CAPS_3GPP(ctx->caps) && mm_modem_get_unlock_required(self->_priv.modem_iface) == MM_MODEM_LOCK_SIM_PIN) { NMSettingGsm *s_gsm = nm_connection_get_setting_gsm(ctx->connection); - const char * pin = nm_setting_gsm_get_pin(s_gsm); + const char *pin = nm_setting_gsm_get_pin(s_gsm); /* If we have a PIN already, send it. If we don't, get it. */ if (pin) { @@ -694,8 +694,8 @@ connect_context_step(NMModemBroadband *self) } static NMActStageReturn -modem_act_stage1_prepare(NMModem * _self, - NMConnection * connection, +modem_act_stage1_prepare(NMModem *_self, + NMConnection *connection, NMDeviceStateReason *out_failure_reason) { NMModemBroadband *self = NM_MODEM_BROADBAND(_self); @@ -768,15 +768,15 @@ check_connection_compatible_with_modem(NMModem *_self, NMConnection *connection, /*****************************************************************************/ static gboolean -complete_connection(NMModem * modem, - const char * iface, - NMConnection * connection, +complete_connection(NMModem *modem, + const char *iface, + NMConnection *connection, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMModemBroadband *self = NM_MODEM_BROADBAND(modem); MMModemCapability modem_caps; - NMSettingPpp * s_ppp; + NMSettingPpp *s_ppp; modem_caps = mm_modem_get_current_capabilities(self->_priv.modem_iface); @@ -856,7 +856,7 @@ complete_connection(NMModem * modem, static gboolean get_user_pass(NMModem *modem, NMConnection *connection, const char **user, const char **pass) { - NMSettingGsm * s_gsm; + NMSettingGsm *s_gsm; NMSettingCdma *s_cdma; s_gsm = nm_connection_get_setting_gsm(connection); @@ -958,19 +958,19 @@ set_mm_enabled(NMModem *_self, gboolean enabled) static void stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_method) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMModemBroadband * self = NM_MODEM_BROADBAND(modem); - nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMModemBroadband *self = NM_MODEM_BROADBAND(modem); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; char sbuf[sizeof(_nm_utils_to_string_buffer)]; - gs_free_error GError * error = NULL; - const char * data_port; - const char * address_string; - const char ** dns; - guint i; - gboolean do_auto = FALSE; - int ifindex; - NMUtilsIPv6IfaceId iid_data; - const NMUtilsIPv6IfaceId *iid = NULL; + gs_free_error GError *error = NULL; + const char *data_port; + const char *address_string; + const char **dns; + guint i; + gboolean do_auto = FALSE; + int ifindex; + NMUtilsIPv6IfaceId iid_data; + const NMUtilsIPv6IfaceId *iid = NULL; if (IS_IPv4) { g_return_if_fail(self->_priv.ipv4_config); @@ -990,7 +990,7 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho NMPlatformIP4Address address; NMPlatformIP4Route route; guint32 mtu_n; - const char * gw_string; + const char *gw_string; _LOGI("IPv4 static configuration:"); @@ -1201,10 +1201,10 @@ out: /* Disconnect */ typedef struct { - NMModemBroadband * self; + NMModemBroadband *self; _NMModemDisconnectCallback callback; gpointer callback_user_data; - GCancellable * cancellable; + GCancellable *cancellable; gboolean warn; } DisconnectContext; @@ -1221,7 +1221,7 @@ disconnect_context_complete(DisconnectContext *ctx, GError *error) static void disconnect_context_complete_on_idle(gpointer user_data, GCancellable *cancellable) { - DisconnectContext *ctx = user_data; + DisconnectContext *ctx = user_data; gs_free_error GError *cancelled_error = NULL; g_cancellable_set_error_if_cancelled(cancellable, &cancelled_error); @@ -1231,9 +1231,9 @@ disconnect_context_complete_on_idle(gpointer user_data, GCancellable *cancellabl static void simple_disconnect_ready(GObject *source_object, GAsyncResult *res, gpointer user_data) { - MMModemSimple * modem_iface = MM_MODEM_SIMPLE(source_object); - DisconnectContext *ctx = user_data; - gs_free_error GError *error = NULL; + MMModemSimple *modem_iface = MM_MODEM_SIMPLE(source_object); + DisconnectContext *ctx = user_data; + gs_free_error GError *error = NULL; if (!mm_modem_simple_disconnect_finish(modem_iface, res, &error)) { if (ctx->warn && !g_error_matches(error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN)) { @@ -1247,13 +1247,13 @@ simple_disconnect_ready(GObject *source_object, GAsyncResult *res, gpointer user } static void -disconnect(NMModem * modem, +disconnect(NMModem *modem, gboolean warn, - GCancellable * cancellable, + GCancellable *cancellable, _NMModemDisconnectCallback callback, gpointer user_data) { - NMModemBroadband * self = NM_MODEM_BROADBAND(modem); + NMModemBroadband *self = NM_MODEM_BROADBAND(modem); DisconnectContext *ctx; connect_context_clear(self); @@ -1330,11 +1330,11 @@ mm_state_to_nm(MMModemState mm_state) } static void -modem_state_changed(MMModem * modem, +modem_state_changed(MMModem *modem, MMModemState old_state, MMModemState new_state, MMModemStateChangeReason reason, - NMModemBroadband * self) + NMModemBroadband *self) { /* After the SIM is unlocked MM1 will move the device to INITIALIZING which * is an unavailable state. That makes state handling confusing here, so @@ -1372,7 +1372,7 @@ static void get_sim_ready(MMModem *modem, GAsyncResult *res, NMModemBroadband *self) { GError *error = NULL; - MMSim * new_sim; + MMSim *new_sim; new_sim = mm_modem_get_sim_finish(modem, res, &error); if (new_sim != self->_priv.sim_iface) { @@ -1506,12 +1506,12 @@ nm_modem_broadband_init(NMModemBroadband *self) NMModem * nm_modem_broadband_new(GObject *object, GError **error) { - MMObject * modem_object; - MMModem * modem_iface; - MMModem3gpp * modem_3gpp_iface; + MMObject *modem_object; + MMModem *modem_iface; + MMModem3gpp *modem_3gpp_iface; const char *const *drivers; - const char * operator_code = NULL; - gs_free char * driver = NULL; + const char *operator_code = NULL; + gs_free char *driver = NULL; g_return_val_if_fail(MM_IS_OBJECT(object), NULL); modem_object = MM_OBJECT(object); @@ -1555,7 +1555,7 @@ nm_modem_broadband_new(GObject *object, GError **error) static void dispose(GObject *object) { - NMModemBroadband * self = NM_MODEM_BROADBAND(object); + NMModemBroadband *self = NM_MODEM_BROADBAND(object); NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE(self); connect_context_clear(self); diff --git a/src/core/devices/wwan/nm-modem-manager.c b/src/core/devices/wwan/nm-modem-manager.c index 8d087d1331..4a89f38efc 100644 --- a/src/core/devices/wwan/nm-modem-manager.c +++ b/src/core/devices/wwan/nm-modem-manager.c @@ -45,7 +45,7 @@ typedef struct { GCancellable *main_cancellable; struct { - MMManager * manager; + MMManager *manager; GCancellable *poke_cancellable; gulong handle_name_owner_changed_id; gulong handle_object_added_id; @@ -61,15 +61,15 @@ typedef struct { LOG_AVAILABLE_NO, } log_available : 3; - GDBusProxy * proxy; + GDBusProxy *proxy; GCancellable *proxy_cancellable; guint proxy_ref_count; - char * proxy_name_owner; + char *proxy_name_owner; } modm; #if WITH_OFONO struct { - GDBusProxy * proxy; + GDBusProxy *proxy; GCancellable *cancellable; } ofono; #endif @@ -111,7 +111,7 @@ static void handle_new_modem(NMModemManager *self, NMModem *modem) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - const char * path; + const char *path; path = nm_modem_get_path(modem); if (g_hash_table_lookup(priv->modems, path)) { @@ -163,10 +163,10 @@ static void modm_handle_object_added(MMManager *modem_manager, MMObject *modem_object, NMModemManager *self) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - const char * path; - MMModem * modem_iface; - NMModem * modem; - GError * error = NULL; + const char *path; + MMModem *modem_iface; + NMModem *modem; + GError *error = NULL; /* Ensure we don't have the same modem already */ path = mm_object_get_path(modem_object); @@ -201,8 +201,8 @@ static void modm_handle_object_removed(MMManager *manager, MMObject *modem_object, NMModemManager *self) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - NMModem * modem; - const char * path; + NMModem *modem; + const char *path; path = mm_object_get_path(modem_object); modem = (NMModem *) g_hash_table_lookup(priv->modems, path); @@ -217,7 +217,7 @@ static void modm_manager_available(NMModemManager *self) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - GList * modems, *l; + GList *modems, *l; if (priv->modm.log_available != LOG_AVAILABLE_YES) { _LOGI("ModemManager %savailable", priv->modm.log_available ? "now " : ""); @@ -235,7 +235,7 @@ static void modm_handle_name_owner_changed(MMManager *modem_manager, GParamSpec *pspec, NMModemManager *self) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - char * name_owner; + char *name_owner; /* Quit poking, if any */ nm_clear_g_source(&priv->modm.relaunch_id); @@ -273,9 +273,9 @@ modm_handle_name_owner_changed(MMManager *modem_manager, GParamSpec *pspec, NMMo static void modm_manager_poke_cb(GObject *connection, GAsyncResult *res, gpointer user_data) { - NMModemManager * self; - NMModemManagerPrivate *priv; - gs_free_error GError *error = NULL; + NMModemManager *self; + NMModemManagerPrivate *priv; + gs_free_error GError *error = NULL; gs_unref_variant GVariant *result = NULL; result = g_dbus_connection_call_finish(G_DBUS_CONNECTION(connection), res, &error); @@ -327,7 +327,7 @@ static void modm_manager_check_name_owner(NMModemManager *self) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - gs_free char * name_owner = NULL; + gs_free char *name_owner = NULL; name_owner = g_dbus_object_manager_client_get_name_owner( G_DBUS_OBJECT_MANAGER_CLIENT(priv->modm.manager)); @@ -344,10 +344,10 @@ modm_manager_check_name_owner(NMModemManager *self) static void modm_manager_new_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMModemManager * self; + NMModemManager *self; NMModemManagerPrivate *priv; - gs_free_error GError *error = NULL; - MMManager * modem_manager; + gs_free_error GError *error = NULL; + MMManager *modem_manager; modem_manager = mm_manager_new_finish(res, &error); if (!modem_manager && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -445,7 +445,7 @@ static void modm_proxy_name_owner_reset(NMModemManager *self) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - char * name = NULL; + char *name = NULL; if (priv->modm.proxy) name = g_dbus_proxy_get_name_owner(priv->modm.proxy); @@ -469,10 +469,10 @@ modm_proxy_name_owner_changed_cb(GObject *object, GParamSpec *pspec, gpointer us static void modm_proxy_new_cb(GObject *source_object, GAsyncResult *result, gpointer user_data) { - NMModemManager * self; + NMModemManager *self; NMModemManagerPrivate *priv; - GDBusProxy * proxy; - gs_free_error GError *error = NULL; + GDBusProxy *proxy; + gs_free_error GError *error = NULL; proxy = g_dbus_proxy_new_for_bus_finish(result, &error); if (!proxy && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -567,7 +567,7 @@ static void ofono_create_modem(NMModemManager *self, const char *path) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - NMModem * modem = NULL; + NMModem *modem = NULL; /* Ensure duplicate modems aren't created. Because we're not using the * ObjectManager interface there's a race during oFono startup where we @@ -585,15 +585,15 @@ ofono_create_modem(NMModemManager *self, const char *path) static void ofono_signal_cb(GDBusProxy *proxy, - char * sender_name, - char * signal_name, - GVariant * parameters, + char *sender_name, + char *signal_name, + GVariant *parameters, gpointer user_data) { - NMModemManager * self = NM_MODEM_MANAGER(user_data); + NMModemManager *self = NM_MODEM_MANAGER(user_data); NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - char * object_path; - NMModem * modem; + char *object_path; + NMModem *modem; if (g_strcmp0(signal_name, "ModemAdded") == 0) { g_variant_get(parameters, "(oa{sv})", &object_path, NULL); @@ -619,12 +619,12 @@ ofono_signal_cb(GDBusProxy *proxy, static void ofono_enumerate_devices_done(GObject *proxy, GAsyncResult *res, gpointer user_data) { - NMModemManager * self; + NMModemManager *self; NMModemManagerPrivate *priv; - gs_free_error GError *error = NULL; - GVariant * results; - GVariantIter * iter; - const char * path; + gs_free_error GError *error = NULL; + GVariant *results; + GVariantIter *iter; + const char *path; results = g_dbus_proxy_call_finish(G_DBUS_PROXY(proxy), res, &error); if (!results && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -651,7 +651,7 @@ static void ofono_check_name_owner(NMModemManager *self, gboolean first_invocation) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); - gs_free char * name_owner = NULL; + gs_free char *name_owner = NULL; name_owner = g_dbus_proxy_get_name_owner(G_DBUS_PROXY(priv->ofono.proxy)); if (name_owner) { @@ -670,7 +670,7 @@ ofono_check_name_owner(NMModemManager *self, gboolean first_invocation) self); } else { GHashTableIter iter; - NMModem * modem; + NMModem *modem; _LOGI("oFono is %savailable", first_invocation ? "not " : "no longer "); @@ -694,10 +694,10 @@ ofono_name_owner_changed(GDBusProxy *ofono_proxy, GParamSpec *pspec, NMModemMana static void ofono_proxy_new_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMModemManager * self; + NMModemManager *self; NMModemManagerPrivate *priv; - gs_free_error GError *error = NULL; - GDBusProxy * proxy; + gs_free_error GError *error = NULL; + GDBusProxy *proxy; proxy = g_dbus_proxy_new_finish(res, &error); if (!proxy && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -752,10 +752,10 @@ ofono_init_proxy(NMModemManager *self) static void bus_get_ready(GObject *source, GAsyncResult *res, gpointer user_data) { - NMModemManager * self; + NMModemManager *self; NMModemManagerPrivate *priv; - gs_free_error GError *error = NULL; - GDBusConnection * connection; + gs_free_error GError *error = NULL; + GDBusConnection *connection; connection = g_bus_get_finish(res, &error); if (!connection && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -782,7 +782,7 @@ bus_get_ready(GObject *source, GAsyncResult *res, gpointer user_data) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMModemManager * self = NM_MODEM_MANAGER(object); + NMModemManager *self = NM_MODEM_MANAGER(object); NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); switch (prop_id) { @@ -812,7 +812,7 @@ nm_modem_manager_init(NMModemManager *self) static void dispose(GObject *object) { - NMModemManager * self = NM_MODEM_MANAGER(object); + NMModemManager *self = NM_MODEM_MANAGER(object); NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE(self); nm_clear_g_cancellable(&priv->main_cancellable); diff --git a/src/core/devices/wwan/nm-modem-ofono.c b/src/core/devices/wwan/nm-modem-ofono.c index 47dc1e3b6d..cac90d3242 100644 --- a/src/core/devices/wwan/nm-modem-ofono.c +++ b/src/core/devices/wwan/nm-modem-ofono.c @@ -75,7 +75,7 @@ G_DEFINE_TYPE(NMModemOfono, nm_modem_ofono, NM_TYPE_MODEM) if (nm_logging_enabled(_level, (_NMLOG_DOMAIN))) { \ NMModemOfono *const __self = (self); \ char __prefix_name[128]; \ - const char * __uid; \ + const char *__uid; \ \ _nm_log(_level, \ (_NMLOG_DOMAIN), \ @@ -97,7 +97,7 @@ G_DEFINE_TYPE(NMModemOfono, nm_modem_ofono, NM_TYPE_MODEM) /*****************************************************************************/ static void -get_capabilities(NMModem * _self, +get_capabilities(NMModem *_self, NMDeviceModemCapabilities *modem_caps, NMDeviceModemCapabilities *current_caps) { @@ -112,7 +112,7 @@ update_modem_state(NMModemOfono *self) NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); NMModemState state = nm_modem_get_state(NM_MODEM(self)); NMModemState new_state = NM_MODEM_STATE_DISABLED; - const char * reason = NULL; + const char *reason = NULL; _LOGI("'Attached': %s 'Online': %s 'IMSI': %s", priv->gprs_attached ? "true" : "false", @@ -137,10 +137,10 @@ update_modem_state(NMModemOfono *self) /* Disconnect */ typedef struct { - NMModemOfono * self; + NMModemOfono *self; _NMModemDisconnectCallback callback; gpointer callback_user_data; - GCancellable * cancellable; + GCancellable *cancellable; gboolean warn; } DisconnectContext; @@ -157,7 +157,7 @@ disconnect_context_complete(DisconnectContext *ctx, GError *error) static void disconnect_context_complete_on_idle(gpointer user_data, GCancellable *cancellable) { - DisconnectContext *ctx = user_data; + DisconnectContext *ctx = user_data; gs_free_error GError *error = NULL; if (!g_cancellable_set_error_if_cancelled(cancellable, &error)) { @@ -172,10 +172,10 @@ disconnect_context_complete_on_idle(gpointer user_data, GCancellable *cancellabl static void disconnect_done(GObject *source, GAsyncResult *result, gpointer user_data) { - DisconnectContext *ctx = user_data; - NMModemOfono * self = ctx->self; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *v = NULL; + DisconnectContext *ctx = user_data; + NMModemOfono *self = ctx->self; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *v = NULL; v = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), result, &error); if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { @@ -193,15 +193,15 @@ disconnect_done(GObject *source, GAsyncResult *result, gpointer user_data) } static void -disconnect(NMModem * modem, +disconnect(NMModem *modem, gboolean warn, - GCancellable * cancellable, + GCancellable *cancellable, _NMModemDisconnectCallback callback, gpointer user_data) { - NMModemOfono * self = NM_MODEM_OFONO(modem); + NMModemOfono *self = NM_MODEM_OFONO(modem); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); - DisconnectContext * ctx; + DisconnectContext *ctx; NMModemState state = nm_modem_get_state(NM_MODEM(self)); _LOGD("warn: %s modem_state: %s", warn ? "TRUE" : "FALSE", nm_modem_state_to_string(state)); @@ -235,7 +235,7 @@ disconnect(NMModem * modem, static void deactivate_cleanup(NMModem *modem, NMDevice *device, gboolean stop_ppp_manager) { - NMModemOfono * self = NM_MODEM_OFONO(modem); + NMModemOfono *self = NM_MODEM_OFONO(modem); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); /* TODO: cancel SimpleConnect() if any */ @@ -249,9 +249,9 @@ deactivate_cleanup(NMModem *modem, NMDevice *device, gboolean stop_ppp_manager) static gboolean check_connection_compatible_with_modem(NMModem *modem, NMConnection *connection, GError **error) { - NMModemOfono * self = NM_MODEM_OFONO(modem); + NMModemOfono *self = NM_MODEM_OFONO(modem); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); - const char * id; + const char *id; if (!_nm_connection_check_main_setting(connection, NM_SETTING_GSM_SETTING_NAME, NULL)) { nm_utils_error_set(error, @@ -290,7 +290,7 @@ check_connection_compatible_with_modem(NMModem *modem, NMConnection *connection, static void handle_sim_property(GDBusProxy *proxy, const char *property, GVariant *v, gpointer user_data) { - NMModemOfono * self = NM_MODEM_OFONO(user_data); + NMModemOfono *self = NM_MODEM_OFONO(user_data); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); if (g_strcmp0(property, "SubscriberIdentity") == 0 && VARIANT_IS_OF_TYPE_STRING(v)) { @@ -324,14 +324,14 @@ sim_property_changed(GDBusProxy *proxy, const char *property, GVariant *v, gpoin static void sim_get_properties_done(GObject *source, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; - gs_free_error GError *error = NULL; + NMModemOfono *self; + NMModemOfonoPrivate *priv; + gs_free_error GError *error = NULL; gs_unref_variant GVariant *v_properties = NULL; gs_unref_variant GVariant *v_dict = NULL; gs_unref_variant GVariant *v = NULL; GVariantIter i; - const char * property; + const char *property; v_properties = _nm_dbus_proxy_call_finish(G_DBUS_PROXY(source), result, G_VARIANT_TYPE("(a{sv})"), &error); @@ -377,10 +377,10 @@ sim_get_properties_done(GObject *source, GAsyncResult *result, gpointer user_dat static void _sim_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; + NMModemOfono *self; + NMModemOfonoPrivate *priv; gs_free_error GError *error = NULL; - GDBusProxy * proxy; + GDBusProxy *proxy; proxy = g_dbus_proxy_new_for_bus_finish(result, &error); if (!proxy && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -451,7 +451,7 @@ handle_sim_iface(NMModemOfono *self, gboolean found) static void handle_connman_property(GDBusProxy *proxy, const char *property, GVariant *v, gpointer user_data) { - NMModemOfono * self = NM_MODEM_OFONO(user_data); + NMModemOfono *self = NM_MODEM_OFONO(user_data); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); if (g_strcmp0(property, "Attached") == 0 && VARIANT_IS_OF_TYPE_BOOLEAN(v)) { @@ -483,14 +483,14 @@ connman_property_changed(GDBusProxy *proxy, const char *property, GVariant *v, g static void connman_get_properties_done(GObject *source, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; - gs_free_error GError *error = NULL; + NMModemOfono *self; + NMModemOfonoPrivate *priv; + gs_free_error GError *error = NULL; gs_unref_variant GVariant *v_properties = NULL; gs_unref_variant GVariant *v_dict = NULL; gs_unref_variant GVariant *v = NULL; GVariantIter i; - const char * property; + const char *property; v_properties = _nm_dbus_proxy_call_finish(G_DBUS_PROXY(source), result, G_VARIANT_TYPE("(a{sv})"), &error); @@ -528,10 +528,10 @@ connman_get_properties_done(GObject *source, GAsyncResult *result, gpointer user static void _connman_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; + NMModemOfono *self; + NMModemOfonoPrivate *priv; gs_free_error GError *error = NULL; - GDBusProxy * proxy; + GDBusProxy *proxy; proxy = g_dbus_proxy_new_for_bus_finish(result, &error); if (!proxy && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -606,7 +606,7 @@ handle_connman_iface(NMModemOfono *self, gboolean found) static void handle_modem_property(GDBusProxy *proxy, const char *property, GVariant *v, gpointer user_data) { - NMModemOfono * self = NM_MODEM_OFONO(user_data); + NMModemOfono *self = NM_MODEM_OFONO(user_data); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); if ((g_strcmp0(property, "Online") == 0) && VARIANT_IS_OF_TYPE_BOOLEAN(v)) { @@ -655,14 +655,14 @@ modem_property_changed(GDBusProxy *proxy, const char *property, GVariant *v, gpo static void modem_get_properties_done(GObject *source, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; - gs_free_error GError *error = NULL; + NMModemOfono *self; + NMModemOfonoPrivate *priv; + gs_free_error GError *error = NULL; gs_unref_variant GVariant *v_properties = NULL; gs_unref_variant GVariant *v_dict = NULL; - GVariant * v; + GVariant *v; GVariantIter i; - const char * property; + const char *property; v_properties = _nm_dbus_proxy_call_finish(G_DBUS_PROXY(source), result, G_VARIANT_TYPE("(a{sv})"), &error); @@ -704,10 +704,10 @@ modem_get_properties_done(GObject *source, GAsyncResult *result, gpointer user_d static void stage1_prepare_done(GObject *source, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *v = NULL; + NMModemOfono *self; + NMModemOfonoPrivate *priv; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *v = NULL; v = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), result, &error); if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -732,17 +732,17 @@ stage1_prepare_done(GObject *source, GAsyncResult *result, gpointer user_data) static void handle_settings(GVariant *v_dict, gpointer user_data) { - NMModemOfono * self = NM_MODEM_OFONO(user_data); + NMModemOfono *self = NM_MODEM_OFONO(user_data); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); char sbuf[sizeof(_nm_utils_to_string_buffer)]; NMPlatformIP4Address address; gboolean ret = FALSE; - const char * interface; - const char * s; - const char ** array; + const char *interface; + const char *s; + const char **array; guint32 address_network, gateway_network; int ifindex; - GError * error = NULL; + GError *error = NULL; //_LOGD("PropertyChanged: %s", property); @@ -894,7 +894,7 @@ out: static void context_property_changed(GDBusProxy *proxy, const char *property, GVariant *v, gpointer user_data) { - NMModemOfono * self = NM_MODEM_OFONO(user_data); + NMModemOfono *self = NM_MODEM_OFONO(user_data); gs_unref_variant GVariant *v_dict = NULL; _LOGD("PropertyChanged: %s", property); @@ -916,8 +916,8 @@ context_property_changed(GDBusProxy *proxy, const char *property, GVariant *v, g static void stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_method) { - NMModemOfono * self = NM_MODEM_OFONO(modem); - NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); + NMModemOfono *self = NM_MODEM_OFONO(modem); + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); gs_free_error GError *error = NULL; _LOGD("IP4 config is done; setting modem_state -> CONNECTED"); @@ -947,9 +947,9 @@ out: static void context_properties_cb(GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; - gs_free_error GError *error = NULL; + NMModemOfono *self; + NMModemOfonoPrivate *priv; + gs_free_error GError *error = NULL; gs_unref_variant GVariant *properties = NULL; gs_unref_variant GVariant *settings = NULL; gs_unref_variant GVariant *v_dict = NULL; @@ -1013,10 +1013,10 @@ error: static void context_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; + NMModemOfono *self; + NMModemOfonoPrivate *priv; gs_free_error GError *error = NULL; - GDBusProxy * proxy; + GDBusProxy *proxy; proxy = g_dbus_proxy_new_for_bus_finish(result, &error); if (!proxy || g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -1087,8 +1087,8 @@ static GHashTable * create_connect_properties(NMConnection *connection) { NMSettingGsm *setting; - GHashTable * properties; - const char * str; + GHashTable *properties; + const char *str; setting = nm_connection_get_setting_gsm(connection); properties = g_hash_table_new(nm_str_hash, g_str_equal); @@ -1109,14 +1109,14 @@ create_connect_properties(NMConnection *connection) } static NMActStageReturn -modem_act_stage1_prepare(NMModem * modem, - NMConnection * connection, +modem_act_stage1_prepare(NMModem *modem, + NMConnection *connection, NMDeviceStateReason *out_failure_reason) { - NMModemOfono * self = NM_MODEM_OFONO(modem); + NMModemOfono *self = NM_MODEM_OFONO(modem); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); - const char * context_id; - char ** id = NULL; + const char *context_id; + char **id = NULL; context_id = nm_connection_get_id(connection); id = g_strsplit(context_id, "/", 0); @@ -1155,10 +1155,10 @@ modem_act_stage1_prepare(NMModem * modem, static void modem_proxy_new_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMModemOfono * self; - NMModemOfonoPrivate *priv; + NMModemOfono *self; + NMModemOfonoPrivate *priv; gs_free_error GError *error = NULL; - GDBusProxy * proxy; + GDBusProxy *proxy; proxy = g_dbus_proxy_new_for_bus_finish(result, &error); if (!proxy && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -1200,7 +1200,7 @@ nm_modem_ofono_init(NMModemOfono *self) static void constructed(GObject *object) { - NMModemOfono * self = NM_MODEM_OFONO(object); + NMModemOfono *self = NM_MODEM_OFONO(object); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); priv->modem_proxy_cancellable = g_cancellable_new(); @@ -1251,7 +1251,7 @@ nm_modem_ofono_new(const char *path) static void dispose(GObject *object) { - NMModemOfono * self = NM_MODEM_OFONO(object); + NMModemOfono *self = NM_MODEM_OFONO(object); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE(self); nm_clear_g_cancellable(&priv->modem_proxy_cancellable); diff --git a/src/core/devices/wwan/nm-modem.c b/src/core/devices/wwan/nm-modem.c index fe1b99f72d..225eaa6501 100644 --- a/src/core/devices/wwan/nm-modem.c +++ b/src/core/devices/wwan/nm-modem.c @@ -72,18 +72,18 @@ typedef struct _NMModemPrivate { NMModemIPMethod ip6_method; NMModemState state; NMModemState prev_state; /* revert to this state if enable/disable fails */ - char * device_id; - char * sim_id; + char *device_id; + char *sim_id; NMModemIPType ip_types; - char * sim_operator_id; - char * operator_code; - char * apn; + char *sim_operator_id; + char *operator_code; + char *apn; NMPPPManager *ppp_manager; - NMPppMgr * ppp_mgr; + NMPppMgr *ppp_mgr; - NMActRequest * act_req; - NMDevice * device; + NMActRequest *act_req; + NMDevice *device; guint32 secrets_tries; NMActRequestGetSecretsCallId *secrets_id; @@ -195,13 +195,13 @@ _get_platform(NMModem *self) /*****************************************************************************/ void -nm_modem_emit_signal_new_config(NMModem * self, +nm_modem_emit_signal_new_config(NMModem *self, int addr_family, - const NML3ConfigData * l3cd, + const NML3ConfigData *l3cd, gboolean do_auto, const NMUtilsIPv6IfaceId *iid, NMDeviceStateReason failure_reason, - GError * error) + GError *error) { nm_assert(NM_IS_MODEM(self)); nm_assert_addr_family(addr_family); @@ -241,9 +241,9 @@ nm_modem_emit_signal_new_config(NMModem * self, } void -nm_modem_emit_signal_new_config_success(NMModem * self, +nm_modem_emit_signal_new_config_success(NMModem *self, int addr_family, - const NML3ConfigData * l3cd, + const NML3ConfigData *l3cd, gboolean do_auto, const NMUtilsIPv6IfaceId *iid) { @@ -257,10 +257,10 @@ nm_modem_emit_signal_new_config_success(NMModem * self, } void -nm_modem_emit_signal_new_config_failure(NMModem * self, +nm_modem_emit_signal_new_config_failure(NMModem *self, int addr_family, NMDeviceStateReason failure_reason, - GError * error) + GError *error) { nm_assert(error); nm_modem_emit_signal_new_config(self, addr_family, NULL, FALSE, NULL, failure_reason, error); @@ -461,9 +461,9 @@ build_single_ip_type_array(NMModemIPType type) GArray * nm_modem_get_connection_ip_type(NMModem *self, NMConnection *connection, GError **error) { - NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); NMSettingIPConfig *s_ip4, *s_ip6; - const char * method; + const char *method; gboolean ip4 = TRUE, ip6 = TRUE; gboolean ip4_may_fail = TRUE, ip6_may_fail = TRUE; @@ -511,7 +511,7 @@ nm_modem_get_connection_ip_type(NMModem *self, NMConnection *connection, GError if (ip4 && ip6) { NMModemIPType type; - GArray * out; + GArray *out; out = g_array_sized_new(FALSE, FALSE, sizeof(NMModemIPType), 3); @@ -597,7 +597,7 @@ _ppp_mgr_cleanup(NMModem *self) static void _ppp_maybe_emit_new_config(NMModem *self, int addr_family) { - NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); const int IS_IPv4 = NM_IS_IPv4(addr_family); const NMPppMgrIPData *ip_data; gboolean do_auto; @@ -628,7 +628,7 @@ _ppp_maybe_emit_new_config(NMModem *self, int addr_family) static void _ppp_mgr_callback(NMPppMgr *ppp_mgr, const NMPppMgrCallbackData *callback_data, gpointer user_data) { - NMModem * self = NM_MODEM(user_data); + NMModem *self = NM_MODEM(user_data); NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); int IS_IPv4; @@ -675,7 +675,7 @@ port_speed_is_zero(const char *port) { struct termios options; nm_auto_close int fd = -1; - gs_free char * path = NULL; + gs_free char *path = NULL; nm_assert(port); @@ -702,11 +702,11 @@ port_speed_is_zero(const char *port) static gboolean _stage3_ip_config_start_on_idle(NMModem *self, int addr_family) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); - NMModemIPMethod ip_method; - NMConnection * connection; - const char * method; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); + NMModemIPMethod ip_method; + NMConnection *connection; + const char *method; gs_free_error GError *error = NULL; NMDeviceStateReason failure_reason; @@ -803,10 +803,10 @@ guint32 nm_modem_get_configured_mtu(NMDevice *self, NMDeviceMtuSource *out_source, gboolean *out_force) { NMConnection *connection; - NMSetting * setting; + NMSetting *setting; gint64 mtu_default; guint mtu = 0; - const char * property_name; + const char *property_name; nm_assert(NM_IS_DEVICE(self)); nm_assert(out_source); @@ -851,13 +851,13 @@ cancel_get_secrets(NMModem *self) } static void -modem_secrets_cb(NMActRequest * req, +modem_secrets_cb(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * connection, - GError * error, + NMSettingsConnection *connection, + GError *error, gpointer user_data) { - NMModem * self = NM_MODEM(user_data); + NMModem *self = NM_MODEM(user_data); NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); g_return_if_fail(call_id == priv->secrets_id); @@ -877,12 +877,12 @@ modem_secrets_cb(NMActRequest * req, } void -nm_modem_get_secrets(NMModem * self, +nm_modem_get_secrets(NMModem *self, const char *setting_name, gboolean request_new, const char *hint) { - NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; cancel_get_secrets(self); @@ -903,8 +903,8 @@ nm_modem_get_secrets(NMModem * self, /*****************************************************************************/ static NMActStageReturn -modem_act_stage1_prepare(NMModem * modem, - NMConnection * connection, +modem_act_stage1_prepare(NMModem *modem, + NMConnection *connection, NMDeviceStateReason *out_failure_reason) { NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_UNKNOWN); @@ -912,16 +912,16 @@ modem_act_stage1_prepare(NMModem * modem, } NMActStageReturn -nm_modem_act_stage1_prepare(NMModem * self, - NMActRequest * req, +nm_modem_act_stage1_prepare(NMModem *self, + NMActRequest *req, NMDeviceStateReason *out_failure_reason) { - NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *hints = NULL; - const char * setting_name = NULL; + const char *setting_name = NULL; NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; - NMConnection * connection; - NMDevice * device; + NMConnection *connection; + NMDevice *device; g_return_val_if_fail(NM_IS_ACT_REQUEST(req), NM_ACT_STAGE_RETURN_FAILURE); @@ -985,11 +985,11 @@ nm_modem_act_stage2_config(NMModem *self, NMDevice *device, NMDeviceStateReason (priv->ip4_method == NM_MODEM_IP_METHOD_PPP || priv->ip6_method == NM_MODEM_IP_METHOD_PPP); if (needs_ppp && !priv->ppp_mgr) { - const char * ppp_name = NULL; - gs_free_error GError *error = NULL; + const char *ppp_name = NULL; + gs_free_error GError *error = NULL; guint ip_timeout; guint baud_override; - NMActRequest * req; + NMActRequest *req; req = nm_device_get_act_request(device); g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); @@ -1061,7 +1061,7 @@ nm_modem_check_connection_compatible(NMModem *self, NMConnection *connection, GE if (nm_streq0(nm_connection_get_connection_type(connection), NM_SETTING_GSM_SETTING_NAME)) { NMSettingGsm *s_gsm; - const char * str; + const char *str; s_gsm = _nm_connection_check_main_setting(connection, NM_SETTING_GSM_SETTING_NAME, error); if (!s_gsm) @@ -1115,11 +1115,11 @@ nm_modem_check_connection_compatible(NMModem *self, NMConnection *connection, GE /*****************************************************************************/ gboolean -nm_modem_complete_connection(NMModem * self, - const char * iface, - NMConnection * connection, +nm_modem_complete_connection(NMModem *self, + const char *iface, + NMConnection *connection, NMConnection *const *existing_connections, - GError ** error) + GError **error) { NMModemClass *klass; @@ -1192,9 +1192,9 @@ deactivate_cleanup(NMModem *self, NMDevice *device, gboolean stop_ppp_manager) /*****************************************************************************/ typedef struct { - NMModem * self; - NMDevice * device; - GCancellable * cancellable; + NMModem *self; + NMDevice *device; + GCancellable *cancellable; NMModemDeactivateCallback callback; gpointer callback_user_data; } DeactivateContext; @@ -1232,7 +1232,7 @@ _deactivate_call_disconnect(DeactivateContext *ctx) } static void -_deactivate_ppp_manager_stop_cb(NMPPPManager * ppp_manager, +_deactivate_ppp_manager_stop_cb(NMPPPManager *ppp_manager, NMPPPManagerStopHandle *handle, gboolean was_cancelled, gpointer user_data) @@ -1255,15 +1255,15 @@ _deactivate_ppp_manager_stop_cb(NMPPPManager * ppp_manager, } void -nm_modem_deactivate_async(NMModem * self, - NMDevice * device, - GCancellable * cancellable, +nm_modem_deactivate_async(NMModem *self, + NMDevice *device, + GCancellable *cancellable, NMModemDeactivateCallback callback, gpointer user_data) { - NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); DeactivateContext *ctx; - NMPPPManager * ppp_manager; + NMPPPManager *ppp_manager; g_return_if_fail(NM_IS_MODEM(self)); g_return_if_fail(NM_IS_DEVICE(device)); @@ -1407,13 +1407,13 @@ _set_ip_ifindex(NMModem *self, int ifindex) } gboolean -nm_modem_set_data_port(NMModem * self, - NMPlatform * platform, - const char * data_port, +nm_modem_set_data_port(NMModem *self, + NMPlatform *platform, + const char *data_port, NMModemIPMethod ip4_method, NMModemIPMethod ip6_method, guint timeout, - GError ** error) + GError **error) { NMModemPrivate *priv; gboolean is_ppp; @@ -1499,8 +1499,8 @@ nm_modem_set_data_port(NMModem * self, gboolean nm_modem_owns_port(NMModem *self, const char *iface) { - NMModemPrivate * priv = NM_MODEM_GET_PRIVATE(self); - NMPlatform * platform; + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); + NMPlatform *platform; const NMPlatformLink *plink; g_return_val_if_fail(iface != NULL, FALSE); @@ -1526,7 +1526,7 @@ nm_modem_owns_port(NMModem *self, const char *iface) /*****************************************************************************/ void -nm_modem_get_capabilities(NMModem * self, +nm_modem_get_capabilities(NMModem *self, NMDeviceModemCapabilities *modem_caps, NMDeviceModemCapabilities *current_caps) { @@ -1566,7 +1566,7 @@ _nm_modem_set_apn(NMModem *self, const char *apn) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMModem * self = NM_MODEM(object); + NMModem *self = NM_MODEM(object); NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(self); switch (prop_id) { @@ -1616,7 +1616,7 @@ static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMModemPrivate *priv = NM_MODEM_GET_PRIVATE(object); - const char * s; + const char *s; switch (prop_id) { case PROP_PATH: diff --git a/src/core/devices/wwan/nm-modem.h b/src/core/devices/wwan/nm-modem.h index 31df805671..ca5410738c 100644 --- a/src/core/devices/wwan/nm-modem.h +++ b/src/core/devices/wwan/nm-modem.h @@ -100,36 +100,36 @@ typedef void (*_NMModemDisconnectCallback)(NMModem *modem, GError *error, gpoint typedef struct { GObjectClass parent; - void (*get_capabilities)(NMModem * self, + void (*get_capabilities)(NMModem *self, NMDeviceModemCapabilities *modem_caps, NMDeviceModemCapabilities *current_caps); - gboolean (*get_user_pass)(NMModem * modem, + gboolean (*get_user_pass)(NMModem *modem, NMConnection *connection, - const char ** user, - const char ** pass); + const char **user, + const char **pass); - gboolean (*check_connection_compatible_with_modem)(NMModem * modem, + gboolean (*check_connection_compatible_with_modem)(NMModem *modem, NMConnection *connection, - GError ** error); + GError **error); - gboolean (*complete_connection)(NMModem * modem, - const char * iface, - NMConnection * connection, + gboolean (*complete_connection)(NMModem *modem, + const char *iface, + NMConnection *connection, NMConnection *const *existing_connections, - GError ** error); + GError **error); - NMActStageReturn (*modem_act_stage1_prepare)(NMModem * modem, - NMConnection * connection, + NMActStageReturn (*modem_act_stage1_prepare)(NMModem *modem, + NMConnection *connection, NMDeviceStateReason *out_failure_reason); void (*stage3_ip_config_start)(NMModem *self, int addr_family, NMModemIPMethod method); void (*set_mm_enabled)(NMModem *self, gboolean enabled); - void (*disconnect)(NMModem * self, + void (*disconnect)(NMModem *self, gboolean warn, - GCancellable * cancellable, + GCancellable *cancellable, _NMModemDisconnectCallback callback, gpointer user_data); @@ -155,40 +155,40 @@ const char *nm_modem_get_sim_operator_id(NMModem *modem); const char *nm_modem_get_operator_code(NMModem *modem); const char *nm_modem_get_apn(NMModem *modem); -gboolean nm_modem_set_data_port(NMModem * self, - NMPlatform * platform, - const char * data_port, +gboolean nm_modem_set_data_port(NMModem *self, + NMPlatform *platform, + const char *data_port, NMModemIPMethod ip4_method, NMModemIPMethod ip6_method, guint timeout, - GError ** error); + GError **error); gboolean nm_modem_owns_port(NMModem *modem, const char *iface); -void nm_modem_get_capabilities(NMModem * self, +void nm_modem_get_capabilities(NMModem *self, NMDeviceModemCapabilities *modem_caps, NMDeviceModemCapabilities *current_caps); gboolean nm_modem_check_connection_compatible(NMModem *self, NMConnection *connection, GError **error); -gboolean nm_modem_complete_connection(NMModem * self, - const char * iface, - NMConnection * connection, +gboolean nm_modem_complete_connection(NMModem *self, + const char *iface, + NMConnection *connection, NMConnection *const *existing_connections, - GError ** error); + GError **error); -NMActStageReturn nm_modem_act_stage1_prepare(NMModem * modem, - NMActRequest * req, +NMActStageReturn nm_modem_act_stage1_prepare(NMModem *modem, + NMActRequest *req, NMDeviceStateReason *out_failure_reason); -NMActStageReturn nm_modem_act_stage2_config(NMModem * self, - NMDevice * device, +NMActStageReturn nm_modem_act_stage2_config(NMModem *self, + NMDevice *device, NMDeviceStateReason *out_failure_reason); gboolean nm_modem_stage3_ip_config_start(NMModem *self, int addr_family, NMDevice *device); -void nm_modem_get_secrets(NMModem * modem, +void nm_modem_get_secrets(NMModem *modem, const char *setting_name, gboolean request_new, const char *hint); @@ -197,9 +197,9 @@ void nm_modem_deactivate(NMModem *modem, NMDevice *device); typedef void (*NMModemDeactivateCallback)(NMModem *self, GError *error, gpointer user_data); -void nm_modem_deactivate_async(NMModem * self, - NMDevice * device, - GCancellable * cancellable, +void nm_modem_deactivate_async(NMModem *self, + NMDevice *device, + GCancellable *cancellable, NMModemDeactivateCallback callback, gpointer user_data); @@ -211,7 +211,7 @@ void nm_modem_set_mm_enabled(NMModem *self, gboolean enabled); NMModemState nm_modem_get_state(NMModem *self); void nm_modem_set_state(NMModem *self, NMModemState new_state, const char *reason); void nm_modem_set_prev_state(NMModem *self, const char *reason); -const char * nm_modem_state_to_string(NMModemState state); +const char *nm_modem_state_to_string(NMModemState state); NMModemIPType nm_modem_get_supported_ip_types(NMModem *self); @@ -228,22 +228,22 @@ GArray *nm_modem_get_connection_ip_type(NMModem *self, NMConnection *connection, /* For subclasses */ -void nm_modem_emit_signal_new_config(NMModem * self, +void nm_modem_emit_signal_new_config(NMModem *self, int addr_family, - const NML3ConfigData * l3cd, + const NML3ConfigData *l3cd, gboolean do_slaac, const NMUtilsIPv6IfaceId *iid, NMDeviceStateReason failure_reason, - GError * error); -void nm_modem_emit_signal_new_config_success(NMModem * self, + GError *error); +void nm_modem_emit_signal_new_config_success(NMModem *self, int addr_family, - const NML3ConfigData * l3cd, + const NML3ConfigData *l3cd, gboolean do_auto, const NMUtilsIPv6IfaceId *iid); -void nm_modem_emit_signal_new_config_failure(NMModem * self, +void nm_modem_emit_signal_new_config_failure(NMModem *self, int addr_family, NMDeviceStateReason failure_reason, - GError * error); + GError *error); const char *nm_modem_ip_type_to_string(NMModemIPType ip_type); diff --git a/src/core/devices/wwan/nm-service-providers.c b/src/core/devices/wwan/nm-service-providers.c index 89add6c51c..83f215655a 100644 --- a/src/core/devices/wwan/nm-service-providers.c +++ b/src/core/devices/wwan/nm-service-providers.c @@ -22,33 +22,33 @@ typedef enum { } ParseContextState; typedef struct { - char * mccmnc; + char *mccmnc; NMServiceProvidersGsmApnCallback callback; gpointer user_data; - GCancellable * cancellable; - GMarkupParseContext * ctx; + GCancellable *cancellable; + GMarkupParseContext *ctx; char buffer[4096]; - char * text_buffer; + char *text_buffer; ParseContextState state; gboolean mccmnc_matched; gboolean found_internet_apn; - char * apn; - char * username; - char * password; - char * gateway; - char * auth_method; - GSList * dns; + char *apn; + char *username; + char *password; + char *gateway; + char *auth_method; + GSList *dns; } ParseContext; /*****************************************************************************/ static void parser_toplevel_start(ParseContext *parse_context, - const char * name, - const char ** attribute_names, - const char ** attribute_values) + const char *name, + const char **attribute_names, + const char **attribute_values) { int i; @@ -72,9 +72,9 @@ parser_toplevel_start(ParseContext *parse_context, static void parser_country_start(ParseContext *parse_context, - const char * name, - const char ** attribute_names, - const char ** attribute_values) + const char *name, + const char **attribute_names, + const char **attribute_values) { if (strcmp(name, "provider") == 0) parse_context->state = PARSER_PROVIDER; @@ -82,9 +82,9 @@ parser_country_start(ParseContext *parse_context, static void parser_provider_start(ParseContext *parse_context, - const char * name, - const char ** attribute_names, - const char ** attribute_values) + const char *name, + const char **attribute_names, + const char **attribute_values) { parse_context->mccmnc_matched = FALSE; if (strcmp(name, "gsm") == 0) @@ -95,9 +95,9 @@ parser_provider_start(ParseContext *parse_context, static void parser_gsm_start(ParseContext *parse_context, - const char * name, - const char ** attribute_names, - const char ** attribute_values) + const char *name, + const char **attribute_names, + const char **attribute_values) { int i; @@ -140,9 +140,9 @@ parser_gsm_start(ParseContext *parse_context, static void parser_gsm_apn_start(ParseContext *parse_context, - const char * name, - const char ** attribute_names, - const char ** attribute_values) + const char *name, + const char **attribute_names, + const char **attribute_values) { int i; @@ -167,11 +167,11 @@ parser_gsm_apn_start(ParseContext *parse_context, static void parser_start_element(GMarkupParseContext *context, - const char * element_name, - const char ** attribute_names, - const char ** attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, gpointer user_data, - GError ** error) + GError **error) { ParseContext *parse_context = user_data; @@ -265,9 +265,9 @@ parser_cdma_end(ParseContext *parse_context, const char *name) static void parser_end_element(GMarkupParseContext *context, - const char * element_name, + const char *element_name, gpointer user_data, - GError ** error) + GError **error) { ParseContext *parse_context = user_data; @@ -298,10 +298,10 @@ parser_end_element(GMarkupParseContext *context, static void parser_text(GMarkupParseContext *context, - const char * text, + const char *text, gsize text_len, gpointer user_data, - GError ** error) + GError **error) { ParseContext *parse_context = user_data; @@ -360,7 +360,7 @@ stream_read_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) GInputStream *stream = G_INPUT_STREAM(source_object); ParseContext *parse_context = user_data; gssize len; - GError * error = NULL; + GError *error = NULL; len = g_input_stream_read_finish(stream, res, &error); if (len == -1) { @@ -411,9 +411,9 @@ read_next_chunk(GInputStream *stream, ParseContext *parse_context) static void file_read_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - GFile * file = G_FILE(source_object); - ParseContext * parse_context = user_data; - GFileInputStream *stream; + GFile *file = G_FILE(source_object); + ParseContext *parse_context = user_data; + GFileInputStream *stream; gs_free_error GError *error = NULL; stream = g_file_read_finish(file, res, &error); @@ -431,13 +431,13 @@ file_read_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) /*****************************************************************************/ void -nm_service_providers_find_gsm_apn(const char * service_providers, - const char * mccmnc, - GCancellable * cancellable, +nm_service_providers_find_gsm_apn(const char *service_providers, + const char *mccmnc, + GCancellable *cancellable, NMServiceProvidersGsmApnCallback callback, gpointer user_data) { - GFile * file; + GFile *file; ParseContext *parse_context; parse_context = g_slice_new0(ParseContext); diff --git a/src/core/devices/wwan/nm-service-providers.h b/src/core/devices/wwan/nm-service-providers.h index 959f660ae4..cf90ef1e41 100644 --- a/src/core/devices/wwan/nm-service-providers.h +++ b/src/core/devices/wwan/nm-service-providers.h @@ -6,18 +6,18 @@ #ifndef __NETWORKMANAGER_SERVICE_PROVIDERS_H__ #define __NETWORKMANAGER_SERVICE_PROVIDERS_H__ -typedef void (*NMServiceProvidersGsmApnCallback)(const char * apn, - const char * username, - const char * password, - const char * gateway, - const char * auth_method, +typedef void (*NMServiceProvidersGsmApnCallback)(const char *apn, + const char *username, + const char *password, + const char *gateway, + const char *auth_method, const GSList *dns, - GError * error, + GError *error, gpointer user_data); -void nm_service_providers_find_gsm_apn(const char * service_providers, - const char * mccmnc, - GCancellable * cancellable, +void nm_service_providers_find_gsm_apn(const char *service_providers, + const char *mccmnc, + GCancellable *cancellable, NMServiceProvidersGsmApnCallback callback, gpointer user_data); diff --git a/src/core/devices/wwan/nm-wwan-factory.c b/src/core/devices/wwan/nm-wwan-factory.c index 0d802ae1b4..169407c701 100644 --- a/src/core/devices/wwan/nm-wwan-factory.c +++ b/src/core/devices/wwan/nm-wwan-factory.c @@ -52,7 +52,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES(NM_DEVICE_FACTORY_DECLARE_LINK_TYPES( NM_SETTING_CDMA_SETTING_NAME)) G_MODULE_EXPORT NMDeviceFactory * - nm_device_factory_create(GError **error) +nm_device_factory_create(GError **error) { return g_object_new(NM_TYPE_WWAN_FACTORY, NULL); } @@ -62,9 +62,9 @@ G_MODULE_EXPORT NMDeviceFactory * static void modem_added_cb(NMModemManager *manager, NMModem *modem, gpointer user_data) { - NMWwanFactory * self = NM_WWAN_FACTORY(user_data); + NMWwanFactory *self = NM_WWAN_FACTORY(user_data); gs_unref_object NMDevice *device = NULL; - const char * driver; + const char *driver; if (nm_modem_is_claimed(modem)) return; @@ -89,11 +89,11 @@ modem_added_cb(NMModemManager *manager, NMModem *modem, gpointer user_data) } static NMDevice * -create_device(NMDeviceFactory * factory, - const char * iface, +create_device(NMDeviceFactory *factory, + const char *iface, const NMPlatformLink *plink, - NMConnection * connection, - gboolean * out_ignore) + NMConnection *connection, + gboolean *out_ignore) { g_return_val_if_fail(plink, NULL); g_return_val_if_fail(plink->type == NM_LINK_TYPE_WWAN_NET, NULL); @@ -104,7 +104,7 @@ create_device(NMDeviceFactory * factory, static void start(NMDeviceFactory *factory) { - NMWwanFactory * self = NM_WWAN_FACTORY(factory); + NMWwanFactory *self = NM_WWAN_FACTORY(factory); NMWwanFactoryPrivate *priv = NM_WWAN_FACTORY_GET_PRIVATE(self); priv->mm = g_object_ref(nm_modem_manager_get()); @@ -121,7 +121,7 @@ nm_wwan_factory_init(NMWwanFactory *self) static void dispose(GObject *object) { - NMWwanFactory * self = NM_WWAN_FACTORY(object); + NMWwanFactory *self = NM_WWAN_FACTORY(object); NMWwanFactoryPrivate *priv = NM_WWAN_FACTORY_GET_PRIVATE(self); if (priv->mm) @@ -135,7 +135,7 @@ dispose(GObject *object) static void nm_wwan_factory_class_init(NMWwanFactoryClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS(klass); object_class->dispose = dispose; diff --git a/src/core/devices/wwan/tests/test-service-providers.c b/src/core/devices/wwan/tests/test-service-providers.c index f95cccf8b0..e808b39135 100644 --- a/src/core/devices/wwan/tests/test-service-providers.c +++ b/src/core/devices/wwan/tests/test-service-providers.c @@ -10,13 +10,13 @@ #include "nm-test-utils-core.h" static void -test_positive_cb(const char * apn, - const char * username, - const char * password, - const char * gateway, - const char * auth_method, +test_positive_cb(const char *apn, + const char *username, + const char *password, + const char *gateway, + const char *auth_method, const GSList *dns, - GError * error, + GError *error, gpointer user_data) { GMainLoop *loop = user_data; @@ -55,13 +55,13 @@ test_positive(void) /*****************************************************************************/ static void -test_negative_cb(const char * apn, - const char * username, - const char * password, - const char * gateway, - const char * auth_method, +test_negative_cb(const char *apn, + const char *username, + const char *password, + const char *gateway, + const char *auth_method, const GSList *dns, - GError * error, + GError *error, gpointer user_data) { GMainLoop *loop = user_data; @@ -88,13 +88,13 @@ test_negative(void) /*****************************************************************************/ static void -test_nonexistent_cb(const char * apn, - const char * username, - const char * password, - const char * gateway, - const char * auth_method, +test_nonexistent_cb(const char *apn, + const char *username, + const char *password, + const char *gateway, + const char *auth_method, const GSList *dns, - GError * error, + GError *error, gpointer user_data) { GMainLoop *loop = user_data; diff --git a/src/core/dhcp/nm-dhcp-client-logging.h b/src/core/dhcp/nm-dhcp-client-logging.h index d69b3ebd72..2b0d8d06c0 100644 --- a/src/core/dhcp/nm-dhcp-client-logging.h +++ b/src/core/dhcp/nm-dhcp-client-logging.h @@ -39,8 +39,8 @@ _nm_dhcp_client_get_domain(NMDhcpClient *self) * expensive to determine the correct value then what we could * safe. */ \ if (nm_logging_enabled(_level, _NMLOG_DOMAIN)) { \ - NMDhcpClient * _self = (NMDhcpClient *) (self); \ - const char * __ifname = _self ? nm_dhcp_client_get_iface(_self) : NULL; \ + NMDhcpClient *_self = (NMDhcpClient *) (self); \ + const char *__ifname = _self ? nm_dhcp_client_get_iface(_self) : NULL; \ const NMLogDomain _domain = _nm_dhcp_client_get_domain(_self); \ \ nm_log(_level, \ diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index dede18e540..77f3f333ca 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -41,14 +41,14 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDhcpClient, PROP_CONFIG, ); typedef struct _NMDhcpClientPrivate { NMDhcpClientConfig config; const NML3ConfigData *l3cd; - GSource * no_lease_timeout_source; - GSource * ipv6_lladdr_timeout_source; + GSource *no_lease_timeout_source; + GSource *ipv6_lladdr_timeout_source; pid_t pid; guint watch_id; NMDhcpState state; bool iaid_explicit : 1; bool is_stopped : 1; - GBytes * effective_client_id; + GBytes *effective_client_id; } NMDhcpClientPrivate; G_DEFINE_ABSTRACT_TYPE(NMDhcpClient, nm_dhcp_client, G_TYPE_OBJECT) @@ -209,7 +209,7 @@ stop(NMDhcpClient *self, gboolean release) static gboolean _no_lease_timeout(gpointer user_data) { - NMDhcpClient * self = user_data; + NMDhcpClient *self = user_data; NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->no_lease_timeout_source); @@ -251,9 +251,9 @@ schedule_no_lease_timeout(NMDhcpClient *self) void nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3ConfigData *l3cd) { - NMDhcpClientPrivate * priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - GHashTable * options; - const int IS_IPv4 = NM_IS_IPv4(priv->config.addr_family); + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + GHashTable *options; + const int IS_IPv4 = NM_IS_IPv4(priv->config.addr_family); nm_auto_unref_l3cd const NML3ConfigData *l3cd_merged = NULL; g_return_if_fail(NM_IS_DHCP_CLIENT(self)); @@ -364,9 +364,9 @@ nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3Co static void daemon_watch_cb(GPid pid, int status, gpointer user_data) { - NMDhcpClient * self = NM_DHCP_CLIENT(user_data); + NMDhcpClient *self = NM_DHCP_CLIENT(user_data); NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - gs_free char * desc = NULL; + gs_free char *desc = NULL; g_return_if_fail(priv->watch_id); priv->watch_id = 0; @@ -477,7 +477,7 @@ get_duid(NMDhcpClient *self) static gboolean ipv6_lladdr_timeout(gpointer user_data) { - NMDhcpClient * self = user_data; + NMDhcpClient *self = user_data; NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->ipv6_lladdr_timeout_source); @@ -495,10 +495,10 @@ static const NMPlatformIP6Address * ipv6_lladdr_find(NMDhcpClient *self) { NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - NML3Cfg * l3cfg; + NML3Cfg *l3cfg; NMPLookup lookup; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; l3cfg = priv->config.l3cfg; nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP6_ADDRESS, nm_l3cfg_get_ifindex(l3cfg)); @@ -525,7 +525,7 @@ l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMDhcp if (notify_data->notify_type == NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE) { const NMPlatformIP6Address *addr; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; addr = ipv6_lladdr_find(self); if (addr) { @@ -549,8 +549,8 @@ l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMDhcp gboolean nm_dhcp_client_start_ip6(NMDhcpClient *self, GError **error) { - NMDhcpClientPrivate *priv; - gs_unref_bytes GBytes * own_client_id = NULL; + NMDhcpClientPrivate *priv; + gs_unref_bytes GBytes *own_client_id = NULL; const NMPlatformIP6Address *addr; g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE); @@ -588,7 +588,7 @@ nm_dhcp_client_stop_existing(const char *pid_file, const char *binary_name) { guint64 start_time; pid_t pid, ppid; - const char * exe; + const char *exe; char proc_path[NM_STRLEN("/proc/%lu/cmdline") + 100]; gs_free char *pid_contents = NULL, *proc_contents = NULL; @@ -678,10 +678,10 @@ bytearray_variant_to_string(NMDhcpClient *self, GVariant *value, const char *key { const guint8 *array; gsize length; - GString * str; + GString *str; int i; unsigned char c; - char * converted = NULL; + char *converted = NULL; g_return_val_if_fail(value != NULL, NULL); @@ -758,7 +758,7 @@ maybe_add_option(NMDhcpClient *self, GHashTable *hash, const char *key, GVariant */ if ((priv_opt_num = label_is_unknown_xyz(key)) > 0) { gs_free guint8 *check_val = NULL; - char * hex_str = NULL; + char *hex_str = NULL; gsize len; /* dhclient passes values from dhcp private options in its own "string" format: @@ -794,14 +794,14 @@ nm_dhcp_client_emit_ipv6_prefix_delegated(NMDhcpClient *self, const NMPlatformIP gboolean nm_dhcp_client_handle_event(gpointer unused, - const char * iface, + const char *iface, int pid, - GVariant * options, - const char * reason, + GVariant *options, + const char *reason, NMDhcpClient *self) { - NMDhcpClientPrivate * priv; - guint32 new_state; + NMDhcpClientPrivate *priv; + guint32 new_state; nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; NMPlatformIP6Address prefix = { 0, @@ -833,8 +833,8 @@ nm_dhcp_client_handle_event(gpointer unused, if (NM_IN_SET(new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) { gs_unref_hashtable GHashTable *str_options = NULL; GVariantIter iter; - const char * name; - GVariant * value; + const char *name; + GVariant *value; /* Copy options */ str_options = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); @@ -956,7 +956,7 @@ config_init(NMDhcpClientConfig *config, const NMDhcpClientConfig *src) } if (!config->hostname && config->send_hostname) { - const char * hostname; + const char *hostname; gs_free char *hostname_tmp = NULL; hostname = nm_hostname_manager_get_hostname(nm_hostname_manager_get()); @@ -1086,7 +1086,7 @@ nm_dhcp_client_init(NMDhcpClient *self) static void dispose(GObject *object) { - NMDhcpClient * self = NM_DHCP_CLIENT(object); + NMDhcpClient *self = NM_DHCP_CLIENT(object); NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); nm_dhcp_client_stop(self, FALSE); @@ -1102,7 +1102,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMDhcpClient * self = NM_DHCP_CLIENT(object); + NMDhcpClient *self = NM_DHCP_CLIENT(object); NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); config_clear(&priv->config); diff --git a/src/core/dhcp/nm-dhcp-client.h b/src/core/dhcp/nm-dhcp-client.h index fac4b0f7df..d8f659fa4a 100644 --- a/src/core/dhcp/nm-dhcp-client.h +++ b/src/core/dhcp/nm-dhcp-client.h @@ -271,19 +271,19 @@ void nm_dhcp_client_set_state(NMDhcpClient *self, NMDhcpState new_state, const NML3ConfigData *l3cd); gboolean nm_dhcp_client_handle_event(gpointer unused, - const char * iface, + const char *iface, int pid, - GVariant * options, - const char * reason, + GVariant *options, + const char *reason, NMDhcpClient *self); -void nm_dhcp_client_emit_ipv6_prefix_delegated(NMDhcpClient * self, +void nm_dhcp_client_emit_ipv6_prefix_delegated(NMDhcpClient *self, const NMPlatformIP6Address *prefix); gboolean nm_dhcp_client_server_id_is_rejected(NMDhcpClient *self, gconstpointer addr); int nm_dhcp_client_get_addr_family(NMDhcpClient *self); -const char * nm_dhcp_client_get_iface(NMDhcpClient *self); +const char *nm_dhcp_client_get_iface(NMDhcpClient *self); NMDedupMultiIndex *nm_dhcp_client_get_multi_idx(NMDhcpClient *self); int nm_dhcp_client_get_ifindex(NMDhcpClient *self); diff --git a/src/core/dhcp/nm-dhcp-dhclient-utils.c b/src/core/dhcp/nm-dhcp-dhclient-utils.c index 60cb46e507..cdc718dfc0 100644 --- a/src/core/dhcp/nm-dhcp-dhclient-utils.c +++ b/src/core/dhcp/nm-dhcp-dhclient-utils.c @@ -97,9 +97,9 @@ grab_request_options(GPtrArray *store, const char *line) } static void -add_ip4_config(GString * str, - GBytes * client_id, - const char * hostname, +add_ip4_config(GString *str, + GBytes *client_id, + const char *hostname, gboolean use_fqdn, NMDhcpHostnameFlags hostname_flags) { @@ -204,7 +204,7 @@ static GBytes * read_client_id(const char *str) { gs_free char *s = NULL; - char * p; + char *p; int i = 0, j = 0; nm_assert(!strncmp(str, CLIENTID_TAG, NM_STRLEN(CLIENTID_TAG))); @@ -258,7 +258,7 @@ static gboolean read_interface(const char *line, char *interface, guint size) { gs_free char *dup = g_strdup(line + NM_STRLEN("interface")); - char * ptr = dup, *end; + char *ptr = dup, *end; while (g_ascii_isspace(*ptr)) ptr++; @@ -287,25 +287,25 @@ read_interface(const char *line, char *interface, guint size) } char * -nm_dhcp_dhclient_create_config(const char * interface, +nm_dhcp_dhclient_create_config(const char *interface, int addr_family, - GBytes * client_id, - const char * anycast_address, - const char * hostname, + GBytes *client_id, + const char *anycast_address, + const char *hostname, guint32 timeout, gboolean use_fqdn, NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - const char *const * reject_servers, - const char * orig_path, - const char * orig_contents, - GBytes ** out_new_client_id) + const char *mud_url, + const char *const *reject_servers, + const char *orig_path, + const char *orig_contents, + GBytes **out_new_client_id) { - nm_auto_free_gstring GString *new_contents = NULL; - gs_unref_ptrarray GPtrArray *fqdn_opts = NULL; - gs_unref_ptrarray GPtrArray *reqs = NULL; - gboolean reset_reqlist = FALSE; - int i; + nm_auto_free_gstring GString *new_contents = NULL; + gs_unref_ptrarray GPtrArray *fqdn_opts = NULL; + gs_unref_ptrarray GPtrArray *reqs = NULL; + gboolean reset_reqlist = FALSE; + int i; g_return_val_if_fail(!anycast_address || nm_utils_hwaddr_valid(anycast_address, ETH_ALEN), NULL); @@ -317,8 +317,8 @@ nm_dhcp_dhclient_create_config(const char * interface, reqs = g_ptr_array_new_full(5, g_free); if (orig_contents) { - gs_free const char **lines = NULL; - gsize line_i; + gs_free const char **lines = NULL; + gsize line_i; nm_auto_free_gstring GString *blocks_stack = NULL; guint blocks_skip = 0; gboolean in_alsoreq = FALSE; @@ -525,10 +525,10 @@ nm_dhcp_dhclient_create_config(const char * interface, char * nm_dhcp_dhclient_escape_duid(GBytes *duid) { - char * escaped; + char *escaped; const guint8 *s, *s0; gsize len; - char * d; + char *d; g_return_val_if_fail(duid, NULL); @@ -562,7 +562,7 @@ isoctal(const guint8 *p) GBytes * nm_dhcp_dhclient_unescape_duid(const char *duid) { - GByteArray * unescaped; + GByteArray *unescaped; const guint8 *p = (const guint8 *) duid; guint i, len; guint8 octal; @@ -609,7 +609,7 @@ error: GBytes * nm_dhcp_dhclient_read_duid(const char *leasefile, GError **error) { - gs_free char * contents = NULL; + gs_free char *contents = NULL; gs_free const char **contents_v = NULL; gsize i; @@ -622,7 +622,7 @@ nm_dhcp_dhclient_read_duid(const char *leasefile, GError **error) contents_v = nm_strsplit_set(contents, "\n\r"); for (i = 0; contents_v && contents_v[i]; i++) { const char *p = nm_str_skip_leading_spaces(contents_v[i]); - GBytes * duid; + GBytes *duid; if (!NM_STR_HAS_PREFIX(p, DUID_PREFIX)) continue; @@ -647,10 +647,10 @@ nm_dhcp_dhclient_read_duid(const char *leasefile, GError **error) gboolean nm_dhcp_dhclient_save_duid(const char *leasefile, GBytes *duid, GError **error) { - gs_free char * escaped_duid = NULL; - gs_free const char **lines = NULL; - nm_auto_free_gstring GString *s = NULL; - const char *const * iter; + gs_free char *escaped_duid = NULL; + gs_free const char **lines = NULL; + nm_auto_free_gstring GString *s = NULL; + const char *const *iter; gsize len = 0; g_return_val_if_fail(leasefile != NULL, FALSE); diff --git a/src/core/dhcp/nm-dhcp-dhclient-utils.h b/src/core/dhcp/nm-dhcp-dhclient-utils.h index ed7c1c7c96..0ce7dd90f0 100644 --- a/src/core/dhcp/nm-dhcp-dhclient-utils.h +++ b/src/core/dhcp/nm-dhcp-dhclient-utils.h @@ -9,19 +9,19 @@ #include "nm-setting-ip4-config.h" #include "nm-setting-ip6-config.h" -char *nm_dhcp_dhclient_create_config(const char * interface, +char *nm_dhcp_dhclient_create_config(const char *interface, int addr_family, - GBytes * client_id, - const char * anycast_addr, - const char * hostname, + GBytes *client_id, + const char *anycast_addr, + const char *hostname, guint32 timeout, gboolean use_fqdn, NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - const char *const * reject_servers, - const char * orig_path, - const char * orig_contents, - GBytes ** out_new_client_id); + const char *mud_url, + const char *const *reject_servers, + const char *orig_path, + const char *orig_contents, + GBytes **out_new_client_id); char *nm_dhcp_dhclient_escape_duid(GBytes *duid); diff --git a/src/core/dhcp/nm-dhcp-dhclient.c b/src/core/dhcp/nm-dhcp-dhclient.c index 9c5d05bcf4..28d40c075b 100644 --- a/src/core/dhcp/nm-dhcp-dhclient.c +++ b/src/core/dhcp/nm-dhcp-dhclient.c @@ -59,10 +59,10 @@ static GType nm_dhcp_dhclient_get_type(void); /*****************************************************************************/ typedef struct { - char * conf_file; - const char * def_leasefile; - char * lease_file; - char * pid_file; + char *conf_file; + const char *def_leasefile; + char *lease_file; + char *pid_file; NMDhcpListener *dhcp_listener; } NMDhcpDhclientPrivate; @@ -105,7 +105,7 @@ static char * get_dhclient_leasefile(int addr_family, const char *iface, const char *uuid, - char ** out_preferred_path) + char **out_preferred_path) { gs_free char *path = NULL; @@ -145,21 +145,21 @@ get_dhclient_leasefile(int addr_family, } static gboolean -merge_dhclient_config(NMDhcpDhclient * self, +merge_dhclient_config(NMDhcpDhclient *self, int addr_family, - const char * iface, - const char * conf_file, - GBytes * client_id, - const char * anycast_address, - const char * hostname, + const char *iface, + const char *conf_file, + GBytes *client_id, + const char *anycast_address, + const char *hostname, guint32 timeout, gboolean use_fqdn, NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - const char *const * reject_servers, - const char * orig_path, - GBytes ** out_new_client_id, - GError ** error) + const char *mud_url, + const char *const *reject_servers, + const char *orig_path, + GBytes **out_new_client_id, + GError **error) { gs_free char *orig = NULL; gs_free char *new = NULL; @@ -274,19 +274,19 @@ find_existing_config(NMDhcpDhclient *self, int addr_family, const char *iface, c * config file along with the NM options. */ static char * -create_dhclient_config(NMDhcpDhclient * self, +create_dhclient_config(NMDhcpDhclient *self, int addr_family, - const char * iface, - const char * uuid, - GBytes * client_id, - const char * anycast_address, - const char * hostname, + const char *iface, + const char *uuid, + GBytes *client_id, + const char *anycast_address, + const char *hostname, guint32 timeout, gboolean use_fqdn, NMDhcpHostnameFlags hostname_flags, - const char * mud_url, - const char *const * reject_servers, - GBytes ** out_new_client_id) + const char *mud_url, + const char *const *reject_servers, + GBytes **out_new_client_id) { gs_free char *orig = NULL; char *new = NULL; @@ -330,27 +330,27 @@ create_dhclient_config(NMDhcpDhclient * self, static gboolean dhclient_start(NMDhcpClient *client, - const char * mode_opt, + const char *mode_opt, gboolean release, - pid_t * out_pid, - GError ** error) + pid_t *out_pid, + GError **error) { - NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); + NMDhcpDhclient *self = NM_DHCP_DHCLIENT(client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *argv = NULL; pid_t pid; - gs_free_error GError * local = NULL; - const char * iface; - const char * uuid; - const char * system_bus_address; - const char * dhclient_path; - char * binary_name; - gs_free char * cmd_str = NULL; - gs_free char * pid_file = NULL; - gs_free char * system_bus_address_env = NULL; - gs_free char * preferred_leasefile_path = NULL; - int addr_family; - const NMDhcpClientConfig *client_config; + gs_free_error GError *local = NULL; + const char *iface; + const char *uuid; + const char *system_bus_address; + const char *dhclient_path; + char *binary_name; + gs_free char *cmd_str = NULL; + gs_free char *pid_file = NULL; + gs_free char *system_bus_address_env = NULL; + gs_free char *preferred_leasefile_path = NULL; + int addr_family; + const NMDhcpClientConfig *client_config; g_return_val_if_fail(!priv->pid_file, FALSE); client_config = nm_dhcp_client_get_config(client); @@ -515,9 +515,9 @@ dhclient_start(NMDhcpClient *client, static gboolean ip4_start(NMDhcpClient *client, GError **error) { - NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); - gs_unref_bytes GBytes * new_client_id = NULL; + NMDhcpDhclient *self = NM_DHCP_DHCLIENT(client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); + gs_unref_bytes GBytes *new_client_id = NULL; const NMDhcpClientConfig *client_config; client_config = nm_dhcp_client_get_config(client); @@ -552,8 +552,8 @@ ip4_start(NMDhcpClient *client, GError **error) static gboolean ip6_start(NMDhcpClient *client, const struct in6_addr *ll_addr, GError **error) { - NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); - NMDhcpDhclientPrivate * priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); + NMDhcpDhclient *self = NM_DHCP_DHCLIENT(client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); const NMDhcpClientConfig *config; config = nm_dhcp_client_get_config(client); @@ -587,7 +587,7 @@ ip6_start(NMDhcpClient *client, const struct in6_addr *ll_addr, GError **error) static void stop(NMDhcpClient *client, gboolean release) { - NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); + NMDhcpDhclient *self = NM_DHCP_DHCLIENT(client); NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); int errsv; @@ -625,12 +625,12 @@ stop(NMDhcpClient *client, gboolean release) static GBytes * get_duid(NMDhcpClient *client) { - NMDhcpDhclient * self = NM_DHCP_DHCLIENT(client); - NMDhcpDhclientPrivate * priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); + NMDhcpDhclient *self = NM_DHCP_DHCLIENT(client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE(self); const NMDhcpClientConfig *client_config; - GBytes * duid = NULL; - gs_free char * leasefile = NULL; - GError * error = NULL; + GBytes *duid = NULL; + gs_free char *leasefile = NULL; + GError *error = NULL; client_config = nm_dhcp_client_get_config(client); @@ -712,7 +712,7 @@ static void nm_dhcp_dhclient_class_init(NMDhcpDhclientClass *dhclient_class) { NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS(dhclient_class); - GObjectClass * object_class = G_OBJECT_CLASS(dhclient_class); + GObjectClass *object_class = G_OBJECT_CLASS(dhclient_class); object_class->dispose = dispose; diff --git a/src/core/dhcp/nm-dhcp-dhcpcanon.c b/src/core/dhcp/nm-dhcp-dhcpcanon.c index ed29b85cd0..87e43fa88e 100644 --- a/src/core/dhcp/nm-dhcp-dhcpcanon.c +++ b/src/core/dhcp/nm-dhcp-dhcpcanon.c @@ -34,10 +34,10 @@ static GType nm_dhcp_dhcpcanon_get_type(void); /*****************************************************************************/ typedef struct { - char * conf_file; - const char * def_leasefile; - char * lease_file; - char * pid_file; + char *conf_file; + const char *def_leasefile; + char *lease_file; + char *pid_file; NMDhcpListener *dhcp_listener; } NMDhcpDhcpcanonPrivate; @@ -65,25 +65,25 @@ nm_dhcp_dhcpcanon_get_path(void) static gboolean dhcpcanon_start(NMDhcpClient *client, - const char * mode_opt, - GBytes * duid, + const char *mode_opt, + GBytes *duid, gboolean release, - pid_t * out_pid, + pid_t *out_pid, guint needed_prefixes, - GError ** error) + GError **error) { - NMDhcpDhcpcanon * self = NM_DHCP_DHCPCANON(client); - NMDhcpDhcpcanonPrivate *priv = NM_DHCP_DHCPCANON_GET_PRIVATE(self); + NMDhcpDhcpcanon *self = NM_DHCP_DHCPCANON(client); + NMDhcpDhcpcanonPrivate *priv = NM_DHCP_DHCPCANON_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *argv = NULL; pid_t pid; - gs_free_error GError *local = NULL; - const char * iface; - const char * system_bus_address; - const char * dhcpcanon_path; - gs_free char * binary_name = NULL; - gs_free char * pid_file = NULL; - gs_free char * system_bus_address_env = NULL; - int addr_family; + gs_free_error GError *local = NULL; + const char *iface; + const char *system_bus_address; + const char *dhcpcanon_path; + gs_free char *binary_name = NULL; + gs_free char *pid_file = NULL; + gs_free char *system_bus_address_env = NULL; + int addr_family; g_return_val_if_fail(!priv->pid_file, FALSE); @@ -168,7 +168,7 @@ ip4_start(NMDhcpClient *client, GError **error) static void stop(NMDhcpClient *client, gboolean release) { - NMDhcpDhcpcanon * self = NM_DHCP_DHCPCANON(client); + NMDhcpDhcpcanon *self = NM_DHCP_DHCPCANON(client); NMDhcpDhcpcanonPrivate *priv = NM_DHCP_DHCPCANON_GET_PRIVATE(self); int errsv; @@ -222,7 +222,7 @@ static void nm_dhcp_dhcpcanon_class_init(NMDhcpDhcpcanonClass *dhcpcanon_class) { NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS(dhcpcanon_class); - GObjectClass * object_class = G_OBJECT_CLASS(dhcpcanon_class); + GObjectClass *object_class = G_OBJECT_CLASS(dhcpcanon_class); object_class->dispose = dispose; diff --git a/src/core/dhcp/nm-dhcp-dhcpcd.c b/src/core/dhcp/nm-dhcp-dhcpcd.c index 0a6a91b743..45f96ec9d8 100644 --- a/src/core/dhcp/nm-dhcp-dhcpcd.c +++ b/src/core/dhcp/nm-dhcp-dhcpcd.c @@ -66,13 +66,13 @@ nm_dhcp_dhcpcd_get_path(void) static gboolean ip4_start(NMDhcpClient *client, GError **error) { - NMDhcpDhcpcd * self = NM_DHCP_DHCPCD(client); - const NMDhcpClientConfig *client_config; + NMDhcpDhcpcd *self = NM_DHCP_DHCPCD(client); + const NMDhcpClientConfig *client_config; gs_unref_ptrarray GPtrArray *argv = NULL; pid_t pid; - GError * local; - gs_free char * cmd_str = NULL; - const char * dhcpcd_path; + GError *local; + gs_free char *cmd_str = NULL; + const char *dhcpcd_path; pid = nm_dhcp_client_get_pid(client); g_return_val_if_fail(pid == -1, FALSE); @@ -219,7 +219,7 @@ static void nm_dhcp_dhcpcd_class_init(NMDhcpDhcpcdClass *dhcpcd_class) { NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS(dhcpcd_class); - GObjectClass * object_class = G_OBJECT_CLASS(dhcpcd_class); + GObjectClass *object_class = G_OBJECT_CLASS(dhcpcd_class); object_class->dispose = dispose; diff --git a/src/core/dhcp/nm-dhcp-helper.c b/src/core/dhcp/nm-dhcp-helper.c index fd66667651..41862f2b68 100644 --- a/src/core/dhcp/nm-dhcp-helper.c +++ b/src/core/dhcp/nm-dhcp-helper.c @@ -61,9 +61,9 @@ build_signal_parameters(void) for (environ_iter = (const char *const *) environ; *environ_iter; environ_iter++) { static const char *const ignore_with_prefix_list[] = {"PATH", "SHLVL", "_", "PWD", "dhc_dbus", NULL}; - const char * item = *environ_iter; - gs_free char * name = NULL; - const char * val; + const char *item = *environ_iter; + gs_free char *name = NULL; + const char *val; const char *const *p; val = strchr(item, '='); @@ -119,13 +119,13 @@ int main(int argc, char *argv[]) { gs_unref_object GDBusConnection *connection = NULL; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *parameters = NULL; - gs_unref_variant GVariant *result = NULL; - gboolean success = FALSE; - guint try_count; - gint64 time_start; - gint64 time_end; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *parameters = NULL; + gs_unref_variant GVariant *result = NULL; + gboolean success = FALSE; + guint try_count; + gint64 time_start; + gint64 time_end; /* Connecting to the unix socket can fail with EAGAIN if there are too * many pending connections and the server can't accept them in time diff --git a/src/core/dhcp/nm-dhcp-listener.c b/src/core/dhcp/nm-dhcp-listener.c index ae2c40f10f..2c567593b5 100644 --- a/src/core/dhcp/nm-dhcp-listener.c +++ b/src/core/dhcp/nm-dhcp-listener.c @@ -50,7 +50,7 @@ typedef struct { NMDBusManager *dbus_mgr; gulong new_conn_id; gulong dis_conn_id; - GHashTable * connections; + GHashTable *connections; } NMDhcpListenerPrivate; struct _NMDhcpListener { @@ -98,10 +98,10 @@ NM_DEFINE_SINGLETON_GETTER(NMDhcpListener, nm_dhcp_listener_get, NM_TYPE_DHCP_LI static char * get_option(GVariant *options, const char *key) { - GVariant * value; + GVariant *value; const guchar *bytes, *s; gsize len; - char * converted, *d; + char *converted, *d; if (!g_variant_lookup(options, key, "@ay", &value)) return NULL; @@ -130,9 +130,9 @@ get_option(GVariant *options, const char *key) static void _method_call_handle(NMDhcpListener *self, GVariant *parameters) { - gs_free char * iface = NULL; - gs_free char * pid_str = NULL; - gs_free char * reason = NULL; + gs_free char *iface = NULL; + gs_free char *pid_str = NULL; + gs_free char *reason = NULL; gs_unref_variant GVariant *options = NULL; int pid; gboolean handled = FALSE; @@ -169,12 +169,12 @@ _method_call_handle(NMDhcpListener *self, GVariant *parameters) } static void -_method_call(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_method_call(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -219,14 +219,14 @@ _dbus_connection_register_object(NMDhcpListener *self, GDBusConnection *connecti } static void -new_connection_cb(NMDBusManager * mgr, - GDBusConnection * connection, +new_connection_cb(NMDBusManager *mgr, + GDBusConnection *connection, GDBusObjectManager *manager, - NMDhcpListener * self) + NMDhcpListener *self) { NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE(self); guint registration_id; - GError * error = NULL; + GError *error = NULL; /* it is important to register the object during the new-connection signal, * as this avoids races with the connecting object. */ diff --git a/src/core/dhcp/nm-dhcp-manager.c b/src/core/dhcp/nm-dhcp-manager.c index 8fe7478c39..f353e63773 100644 --- a/src/core/dhcp/nm-dhcp-manager.c +++ b/src/core/dhcp/nm-dhcp-manager.c @@ -130,7 +130,7 @@ _client_factory_get_gtype(const NMDhcpClientFactory *client_factory, int addr_fa NMDhcpClient * nm_dhcp_manager_start_client(NMDhcpManager *self, NMDhcpClientConfig *config, GError **error) { - NMDhcpManagerPrivate *priv; + NMDhcpManagerPrivate *priv; gs_unref_object NMDhcpClient *client = NULL; gboolean success = FALSE; gsize hwaddr_len; @@ -238,10 +238,10 @@ nmtst_dhcp_manager_unget(gpointer self) static void nm_dhcp_manager_init(NMDhcpManager *self) { - NMDhcpManagerPrivate * priv = NM_DHCP_MANAGER_GET_PRIVATE(self); - NMConfig * config = nm_config_get(); - gs_free char * client_free = NULL; - const char * client; + NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE(self); + NMConfig *config = nm_config_get(); + gs_free char *client_free = NULL; + const char *client; int i; const NMDhcpClientFactory *client_factory = NULL; diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c index e8e3a2f1e4..d7fbe35615 100644 --- a/src/core/dhcp/nm-dhcp-nettools.c +++ b/src/core/dhcp/nm-dhcp-nettools.c @@ -48,11 +48,11 @@ typedef struct _NMDhcpNettoolsClass NMDhcpNettoolsClass; /*****************************************************************************/ typedef struct { - NDhcp4Client * client; + NDhcp4Client *client; NDhcp4ClientProbe *probe; NDhcp4ClientLease *lease; - GSource * event_source; - char * lease_file; + GSource *event_source; + char *lease_file; } NMDhcpNettoolsPrivate; struct _NMDhcpNettools { @@ -86,8 +86,8 @@ set_error_nettools(GError **error, int r, const char *message) static inline int _client_lease_query(NDhcp4ClientLease *lease, uint8_t option, - const uint8_t ** datap, - size_t * n_datap) + const uint8_t **datap, + size_t *n_datap) { return n_dhcp4_client_lease_query(lease, option, (guint8 **) datap, n_datap); } @@ -100,11 +100,11 @@ _client_lease_query(NDhcp4ClientLease *lease, static gboolean lease_option_consume_route(const uint8_t **datap, - size_t * n_datap, + size_t *n_datap, gboolean classless, - in_addr_t * destp, - uint8_t * plenp, - in_addr_t * gatewayp) + in_addr_t *destp, + uint8_t *plenp, + in_addr_t *gatewayp) { in_addr_t dest; in_addr_t gateway; @@ -152,9 +152,9 @@ lease_option_consume_route(const uint8_t **datap, static gboolean lease_parse_address(NDhcp4ClientLease *lease, - NML3ConfigData * l3cd, - GHashTable * options, - GError ** error) + NML3ConfigData *l3cd, + GHashTable *options, + GError **error) { struct in_addr a_address; in_addr_t a_netmask; @@ -164,7 +164,7 @@ lease_parse_address(NDhcp4ClientLease *lease, guint32 a_lifetime; guint32 a_timestamp; guint64 a_expiry; - const guint8 * l_data; + const guint8 *l_data; gsize l_data_len; int r; @@ -272,11 +272,11 @@ lease_parse_address(NDhcp4ClientLease *lease, } static void -lease_parse_address_list(NDhcp4ClientLease * lease, - NML3ConfigData * l3cd, +lease_parse_address_list(NDhcp4ClientLease *lease, + NML3ConfigData *l3cd, NMDhcpOptionDhcp4Options option, - GHashTable * options, - NMStrBuf * sbuf) + GHashTable *options, + NMStrBuf *sbuf) { const guint8 *l_data; gsize l_data_len; @@ -325,9 +325,9 @@ lease_parse_address_list(NDhcp4ClientLease * lease, static void lease_parse_routes(NDhcp4ClientLease *lease, - NML3ConfigData * l3cd, - GHashTable * options, - NMStrBuf * sbuf) + NML3ConfigData *l3cd, + GHashTable *options, + NMStrBuf *sbuf) { char dest_str[NM_UTILS_INET_ADDRSTRLEN]; char gateway_str[NM_UTILS_INET_ADDRSTRLEN]; @@ -482,7 +482,7 @@ static void lease_parse_search_domains(NDhcp4ClientLease *lease, NML3ConfigData *l3cd, GHashTable *options) { gs_strfreev char **domains = NULL; - const guint8 * l_data; + const guint8 *l_data; gsize l_data_len; guint i; int r; @@ -534,21 +534,21 @@ lease_parse_private_options(NDhcp4ClientLease *lease, GHashTable *options) static NML3ConfigData * lease_to_ip4_config(NMDedupMultiIndex *multi_idx, - const char * iface, + const char *iface, int ifindex, NDhcp4ClientLease *lease, - GError ** error) + GError **error) { - nm_auto_str_buf NMStrBuf sbuf = NM_STR_BUF_INIT(0, FALSE); - nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - gs_unref_hashtable GHashTable *options = NULL; - const guint8 * l_data; - gsize l_data_len; - const char * v_str; - guint16 v_u16; - in_addr_t v_inaddr; - struct in_addr v_inaddr_s; - int r; + nm_auto_str_buf NMStrBuf sbuf = NM_STR_BUF_INIT(0, FALSE); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_unref_hashtable GHashTable *options = NULL; + const guint8 *l_data; + gsize l_data_len; + const char *v_str; + guint16 v_u16; + in_addr_t v_inaddr; + struct in_addr v_inaddr_s; + int r; g_return_val_if_fail(lease != NULL, NULL); @@ -667,7 +667,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, * Otherwise, we allow any encoding and backslash-escape the result to * UTF-8. */ gs_free char *to_free = NULL; - const char * escaped; + const char *escaped; escaped = nm_utils_buf_utf8safe_escape((char *) l_data, l_data_len, 0, &to_free); nm_dhcp_option_add_option(options, @@ -740,7 +740,7 @@ lease_save(NMDhcpNettools *self, NDhcp4ClientLease *lease, const char *lease_fil struct in_addr a_address; nm_auto_str_buf NMStrBuf sbuf = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE); char addr_str[NM_UTILS_INET_ADDRSTRLEN]; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; nm_assert(lease); nm_assert(lease_file); @@ -761,11 +761,11 @@ lease_save(NMDhcpNettools *self, NDhcp4ClientLease *lease, const char *lease_fil static void bound4_handle(NMDhcpNettools *self, NDhcp4ClientLease *lease, gboolean extended) { - NMDhcpNettoolsPrivate * priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); - NMDhcpClient * client = NM_DHCP_CLIENT(self); - const NMDhcpClientConfig *client_config; + NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); + NMDhcpClient *client = NM_DHCP_CLIENT(self); + const NMDhcpClientConfig *client_config; nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - GError * error = NULL; + GError *error = NULL; _LOGT("lease available (%s)", extended ? "extended" : "new"); client_config = nm_dhcp_client_get_config(client); @@ -791,7 +791,7 @@ bound4_handle(NMDhcpNettools *self, NDhcp4ClientLease *lease, gboolean extended) static void dhcp4_event_handle(NMDhcpNettools *self, NDhcp4ClientEvent *event) { - NMDhcpNettoolsPrivate * priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); + NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); const NMDhcpClientConfig *client_config; struct in_addr server_id; char addr_str[INET_ADDRSTRLEN]; @@ -861,9 +861,9 @@ dhcp4_event_handle(NMDhcpNettools *self, NDhcp4ClientEvent *event) static gboolean dhcp4_event_cb(int fd, GIOCondition condition, gpointer user_data) { - NMDhcpNettools * self = user_data; + NMDhcpNettools *self = user_data; NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); - NDhcp4ClientEvent * event; + NDhcp4ClientEvent *event; int r; r = n_dhcp4_client_dispatch(priv->client); @@ -892,19 +892,19 @@ nettools_create(NMDhcpNettools *self, GError **error) { NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); nm_auto(n_dhcp4_client_config_freep) NDhcp4ClientConfig *config = NULL; - nm_auto(n_dhcp4_client_unrefp) NDhcp4Client * client = NULL; - GBytes * hwaddr; - GBytes * bcast_hwaddr; - const uint8_t * hwaddr_arr; - const uint8_t * bcast_hwaddr_arr; + nm_auto(n_dhcp4_client_unrefp) NDhcp4Client *client = NULL; + GBytes *hwaddr; + GBytes *bcast_hwaddr; + const uint8_t *hwaddr_arr; + const uint8_t *bcast_hwaddr_arr; gsize hwaddr_len; gsize bcast_hwaddr_len; - GBytes * client_id; - gs_unref_bytes GBytes * client_id_new = NULL; - const uint8_t * client_id_arr; - size_t client_id_len; - int r, fd, arp_type, transport; - const NMDhcpClientConfig *client_config; + GBytes *client_id; + gs_unref_bytes GBytes *client_id_new = NULL; + const uint8_t *client_id_arr; + size_t client_id_len; + int r, fd, arp_type, transport; + const NMDhcpClientConfig *client_config; client_config = nm_dhcp_client_get_config(NM_DHCP_CLIENT(self)); @@ -991,7 +991,7 @@ nettools_create(NMDhcpNettools *self, GError **error) static gboolean _accept(NMDhcpClient *client, GError **error) { - NMDhcpNettools * self = NM_DHCP_NETTOOLS(client); + NMDhcpNettools *self = NM_DHCP_NETTOOLS(client); NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); int r; @@ -1013,7 +1013,7 @@ _accept(NMDhcpClient *client, GError **error) static gboolean decline(NMDhcpClient *client, const char *error_message, GError **error) { - NMDhcpNettools * self = NM_DHCP_NETTOOLS(client); + NMDhcpNettools *self = NM_DHCP_NETTOOLS(client); NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); int r; @@ -1052,10 +1052,10 @@ static gboolean ip4_start(NMDhcpClient *client, GError **error) { nm_auto(n_dhcp4_client_probe_config_freep) NDhcp4ClientProbeConfig *config = NULL; - NMDhcpNettools * self = NM_DHCP_NETTOOLS(client); - NMDhcpNettoolsPrivate * priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); + NMDhcpNettools *self = NM_DHCP_NETTOOLS(client); + NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); const NMDhcpClientConfig *client_config; - gs_free char * lease_file = NULL; + gs_free char *lease_file = NULL; struct in_addr last_addr = {0}; int r, i; @@ -1214,7 +1214,7 @@ ip4_start(NMDhcpClient *client, GError **error) static void stop(NMDhcpClient *client, gboolean release) { - NMDhcpNettools * self = NM_DHCP_NETTOOLS(client); + NMDhcpNettools *self = NM_DHCP_NETTOOLS(client); NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE(self); NM_DHCP_CLIENT_CLASS(nm_dhcp_nettools_parent_class)->stop(client, release); @@ -1248,7 +1248,7 @@ static void nm_dhcp_nettools_class_init(NMDhcpNettoolsClass *class) { NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS(class); - GObjectClass * object_class = G_OBJECT_CLASS(class); + GObjectClass *object_class = G_OBJECT_CLASS(class); object_class->dispose = dispose; diff --git a/src/core/dhcp/nm-dhcp-options.c b/src/core/dhcp/nm-dhcp-options.c index 011f23e4e2..ab64a67c1c 100644 --- a/src/core/dhcp/nm-dhcp-options.c +++ b/src/core/dhcp/nm-dhcp-options.c @@ -396,14 +396,14 @@ nm_dhcp_option_add_option(GHashTable *options, int addr_family, guint option, co } void -nm_dhcp_option_add_option_utf8safe_escape(GHashTable * options, +nm_dhcp_option_add_option_utf8safe_escape(GHashTable *options, int addr_family, guint option, const guint8 *data, gsize n_data) { gs_free char *to_free = NULL; - const char * escaped; + const char *escaped; escaped = nm_utils_buf_utf8safe_escape((char *) data, n_data, diff --git a/src/core/dhcp/nm-dhcp-options.h b/src/core/dhcp/nm-dhcp-options.h index 8ed2039d40..1e26a5bfe3 100644 --- a/src/core/dhcp/nm-dhcp-options.h +++ b/src/core/dhcp/nm-dhcp-options.h @@ -210,7 +210,7 @@ nm_dhcp_option_request_string(int addr_family, guint option) void nm_dhcp_option_take_option(GHashTable *options, int addr_family, guint option, char *value); void nm_dhcp_option_add_option(GHashTable *options, int addr_family, guint option, const char *value); -void nm_dhcp_option_add_option_utf8safe_escape(GHashTable * options, +void nm_dhcp_option_add_option_utf8safe_escape(GHashTable *options, int addr_family, guint option, const guint8 *data, diff --git a/src/core/dhcp/nm-dhcp-systemd.c b/src/core/dhcp/nm-dhcp-systemd.c index 7c3c289996..b91cbcb1dc 100644 --- a/src/core/dhcp/nm-dhcp-systemd.c +++ b/src/core/dhcp/nm-dhcp-systemd.c @@ -47,9 +47,9 @@ static GType nm_dhcp_systemd_get_type(void); /*****************************************************************************/ typedef struct { - sd_dhcp_client * client4; + sd_dhcp_client *client4; sd_dhcp6_client *client6; - char * lease_file; + char *lease_file; guint request_count; } NMDhcpSystemdPrivate; @@ -71,39 +71,39 @@ G_DEFINE_TYPE(NMDhcpSystemd, nm_dhcp_systemd, NM_TYPE_DHCP_CLIENT) static NML3ConfigData * lease_to_ip4_config(NMDedupMultiIndex *multi_idx, - const char * iface, + const char *iface, int ifindex, - sd_dhcp_lease * lease, - GError ** error) + sd_dhcp_lease *lease, + GError **error) { - nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - gs_unref_hashtable GHashTable *options = NULL; - const struct in_addr * addr_list; - char addr_str[NM_UTILS_INET_ADDRSTRLEN]; - const char * s; - nm_auto_free_gstring GString *str = NULL; - nm_auto_free sd_dhcp_route **routes = NULL; - const char *const * search_domains = NULL; - guint16 mtu; - int i, num; - const void * data; - gsize data_len; - gboolean has_router_from_classless = FALSE; - gboolean has_classless_route = FALSE; - gboolean has_static_route = FALSE; - const gint32 ts = nm_utils_get_monotonic_timestamp_sec(); - gint64 ts_time = time(NULL); - struct in_addr a_address; - struct in_addr a_netmask; - struct in_addr a_next_server; - struct in_addr server_id; - struct in_addr broadcast; - const struct in_addr * a_router; - guint32 a_plen; - guint32 a_lifetime; - guint32 renewal; - guint32 rebinding; - gs_free nm_sd_dhcp_option *private_options = NULL; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_unref_hashtable GHashTable *options = NULL; + const struct in_addr *addr_list; + char addr_str[NM_UTILS_INET_ADDRSTRLEN]; + const char *s; + nm_auto_free_gstring GString *str = NULL; + nm_auto_free sd_dhcp_route **routes = NULL; + const char *const *search_domains = NULL; + guint16 mtu; + int i, num; + const void *data; + gsize data_len; + gboolean has_router_from_classless = FALSE; + gboolean has_classless_route = FALSE; + gboolean has_static_route = FALSE; + const gint32 ts = nm_utils_get_monotonic_timestamp_sec(); + gint64 ts_time = time(NULL); + struct in_addr a_address; + struct in_addr a_netmask; + struct in_addr a_next_server; + struct in_addr server_id; + struct in_addr broadcast; + const struct in_addr *a_router; + guint32 a_plen; + guint32 a_lifetime; + guint32 renewal; + guint32 rebinding; + gs_free nm_sd_dhcp_option *private_options = NULL; nm_assert(lease != NULL); @@ -211,7 +211,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, if (sd_dhcp_lease_get_domainname(lease, &s) >= 0) { gs_strfreev char **domains = NULL; - char ** d; + char **d; nm_dhcp_option_add_option(options, AF_INET, NM_DHCP_OPTION_DHCP4_DOMAIN_NAME, s); @@ -423,12 +423,12 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, guint8 code = private_options[i].code; const guint8 *l_data = private_options[i].data; gsize l_data_len = private_options[i].data_len; - char * option_string; + char *option_string; if (code == NM_DHCP_OPTION_DHCP4_PRIVATE_PROXY_AUTODISCOVERY) { if (nm_dhcp_lease_data_parse_cstr(l_data, l_data_len, &l_data_len)) { gs_free char *to_free = NULL; - const char * escaped; + const char *escaped; escaped = nm_utils_buf_utf8safe_escape((char *) l_data, l_data_len, 0, &to_free); @@ -468,11 +468,11 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, static void bound4_handle(NMDhcpSystemd *self, gboolean extended) { - NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); - const char * iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); + const char *iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - sd_dhcp_lease * lease = NULL; - GError * error = NULL; + sd_dhcp_lease *lease = NULL; + GError *error = NULL; if (sd_dhcp_client_get_lease(priv->client4, &lease) < 0 || !lease) { _LOGW("no lease!"); @@ -504,10 +504,10 @@ bound4_handle(NMDhcpSystemd *self, gboolean extended) static int dhcp_event_cb(sd_dhcp_client *client, int event, gpointer user_data) { - NMDhcpSystemd * self = NM_DHCP_SYSTEMD(user_data); + NMDhcpSystemd *self = NM_DHCP_SYSTEMD(user_data); NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); char addr_str[INET_ADDRSTRLEN]; - sd_dhcp_lease * lease = NULL; + sd_dhcp_lease *lease = NULL; struct in_addr addr; int r; @@ -556,26 +556,26 @@ static gboolean ip4_start(NMDhcpClient *client, GError **error) { nm_auto(sd_dhcp_client_unrefp) sd_dhcp_client *sd_client = NULL; - NMDhcpSystemd * self = NM_DHCP_SYSTEMD(client); - NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); - const NMDhcpClientConfig * client_config; - gs_free char * lease_file = NULL; - GBytes * hwaddr; - const uint8_t * hwaddr_arr; + NMDhcpSystemd *self = NM_DHCP_SYSTEMD(client); + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); + const NMDhcpClientConfig *client_config; + gs_free char *lease_file = NULL; + GBytes *hwaddr; + const uint8_t *hwaddr_arr; gsize hwaddr_len; int arp_type; - GBytes * client_id; - gs_unref_bytes GBytes *client_id_new = NULL; - GBytes * vendor_class_identifier; - const uint8_t * client_id_arr; - size_t client_id_len; - struct in_addr last_addr = {0}; - const char * hostname; - const char * mud_url; - int r, i; - GBytes * bcast_hwaddr; - const uint8_t * bcast_hwaddr_arr; - gsize bcast_hwaddr_len; + GBytes *client_id; + gs_unref_bytes GBytes *client_id_new = NULL; + GBytes *vendor_class_identifier; + const uint8_t *client_id_arr; + size_t client_id_len; + struct in_addr last_addr = {0}; + const char *hostname; + const char *mud_url; + int r, i; + GBytes *bcast_hwaddr; + const uint8_t *bcast_hwaddr_arr; + gsize bcast_hwaddr_len; g_return_val_if_fail(!priv->client4, FALSE); g_return_val_if_fail(!priv->client6, FALSE); @@ -757,24 +757,24 @@ ip4_start(NMDhcpClient *client, GError **error) static NML3ConfigData * lease_to_ip6_config(NMDedupMultiIndex *multi_idx, - const char * iface, + const char *iface, int ifindex, - sd_dhcp6_lease * lease, + sd_dhcp6_lease *lease, gboolean info_only, gint32 ts, - GError ** error) + GError **error) { - nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - gs_unref_hashtable GHashTable *options = NULL; - struct in6_addr tmp_addr; - const struct in6_addr * dns; - uint32_t lft_pref, lft_valid; - char addr_str[NM_UTILS_INET_ADDRSTRLEN]; - char ** domains; - const char * s; - nm_auto_free_gstring GString *str = NULL; - gboolean has_any_addresses = FALSE; - int num, i; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_unref_hashtable GHashTable *options = NULL; + struct in6_addr tmp_addr; + const struct in6_addr *dns; + uint32_t lft_pref, lft_valid; + char addr_str[NM_UTILS_INET_ADDRSTRLEN]; + char **domains; + const char *s; + nm_auto_free_gstring GString *str = NULL; + gboolean has_any_addresses = FALSE; + int num, i; nm_assert(lease); @@ -847,14 +847,14 @@ lease_to_ip6_config(NMDedupMultiIndex *multi_idx, static void bound6_handle(NMDhcpSystemd *self) { - NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); - const gint32 ts = nm_utils_get_monotonic_timestamp_sec(); - const char * iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); - const NMDhcpClientConfig *client_config; - nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - gs_free_error GError *error = NULL; - NMPlatformIP6Address prefix = {0}; - sd_dhcp6_lease * lease = NULL; + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); + const gint32 ts = nm_utils_get_monotonic_timestamp_sec(); + const char *iface = nm_dhcp_client_get_iface(NM_DHCP_CLIENT(self)); + const NMDhcpClientConfig *client_config; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_free_error GError *error = NULL; + NMPlatformIP6Address prefix = {0}; + sd_dhcp6_lease *lease = NULL; client_config = nm_dhcp_client_get_config(NM_DHCP_CLIENT(self)); @@ -896,7 +896,7 @@ bound6_handle(NMDhcpSystemd *self) static void dhcp6_event_cb(sd_dhcp6_client *client, int event, gpointer user_data) { - NMDhcpSystemd * self = NM_DHCP_SYSTEMD(user_data); + NMDhcpSystemd *self = NM_DHCP_SYSTEMD(user_data); NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); nm_assert(priv->client6 == client); @@ -924,16 +924,16 @@ dhcp6_event_cb(sd_dhcp6_client *client, int event, gpointer user_data) static gboolean ip6_start(NMDhcpClient *client, const struct in6_addr *ll_addr, GError **error) { - NMDhcpSystemd * self = NM_DHCP_SYSTEMD(client); - NMDhcpSystemdPrivate * priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); + NMDhcpSystemd *self = NM_DHCP_SYSTEMD(client); + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); nm_auto(sd_dhcp6_client_unrefp) sd_dhcp6_client *sd_client = NULL; - const NMDhcpClientConfig * client_config; - const char * hostname; - const char * mud_url; + const NMDhcpClientConfig *client_config; + const char *hostname; + const char *mud_url; int r, i; - const guint8 * duid_arr; + const guint8 *duid_arr; gsize duid_len; - GBytes * duid; + GBytes *duid; g_return_val_if_fail(!priv->client4, FALSE); g_return_val_if_fail(!priv->client6, FALSE); @@ -1054,7 +1054,7 @@ ip6_start(NMDhcpClient *client, const struct in6_addr *ll_addr, GError **error) static void stop(NMDhcpClient *client, gboolean release) { - NMDhcpSystemd * self = NM_DHCP_SYSTEMD(client); + NMDhcpSystemd *self = NM_DHCP_SYSTEMD(client); NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE(self); int r = 0; @@ -1108,7 +1108,7 @@ static void nm_dhcp_systemd_class_init(NMDhcpSystemdClass *sdhcp_class) { NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS(sdhcp_class); - GObjectClass * object_class = G_OBJECT_CLASS(sdhcp_class); + GObjectClass *object_class = G_OBJECT_CLASS(sdhcp_class); object_class->dispose = dispose; diff --git a/src/core/dhcp/nm-dhcp-utils.c b/src/core/dhcp/nm-dhcp-utils.c index b1ff1b97a9..a167673598 100644 --- a/src/core/dhcp/nm-dhcp-utils.c +++ b/src/core/dhcp/nm-dhcp-utils.c @@ -25,13 +25,13 @@ /*****************************************************************************/ static gboolean -ip4_process_dhcpcd_rfc3442_routes(const char * iface, - const char * str, +ip4_process_dhcpcd_rfc3442_routes(const char *iface, + const char *str, NML3ConfigData *l3cd, - guint32 * gwaddr) + guint32 *gwaddr) { gs_free const char **routes = NULL; - const char ** r; + const char **r; gboolean have_routes = FALSE; routes = nm_strsplit_set(str, " "); @@ -44,7 +44,7 @@ ip4_process_dhcpcd_rfc3442_routes(const char * iface, } for (r = routes; *r; r += 2) { - char * slash; + char *slash; int rt_cidr = 32; guint32 rt_addr, rt_route; @@ -109,7 +109,7 @@ static gboolean process_dhclient_rfc3442_route(const char *const **p_octets, NMPlatformIP4Route *route) { const char *const *o = *p_octets; - gs_free char * next_hop = NULL; + gs_free char *next_hop = NULL; int addr_len; int v_plen; in_addr_t tmp_addr; @@ -127,7 +127,7 @@ process_dhclient_rfc3442_route(const char *const **p_octets, NMPlatformIP4Route return FALSE; if (v_plen > 0) { - const char * addr[4] = {"0", "0", "0", "0"}; + const char *addr[4] = {"0", "0", "0", "0"}; gs_free char *str_addr = NULL; int i; @@ -155,13 +155,13 @@ process_dhclient_rfc3442_route(const char *const **p_octets, NMPlatformIP4Route } static gboolean -ip4_process_dhclient_rfc3442_routes(const char * iface, - const char * str, +ip4_process_dhclient_rfc3442_routes(const char *iface, + const char *str, NML3ConfigData *l3cd, - guint32 * gwaddr) + guint32 *gwaddr) { gs_free const char **octets = NULL; - const char *const * o; + const char *const *o; gboolean have_routes = FALSE; octets = nm_strsplit_set_with_empty(str, " ."); @@ -209,10 +209,10 @@ ip4_process_dhclient_rfc3442_routes(const char * iface, } static gboolean -ip4_process_classless_routes(const char * iface, - GHashTable * options, +ip4_process_classless_routes(const char *iface, + GHashTable *options, NML3ConfigData *l3cd, - guint32 * gwaddr) + guint32 *gwaddr) { const char *str, *p; @@ -276,8 +276,8 @@ static void process_classful_routes(const char *iface, GHashTable *options, NML3ConfigData *l3cd) { gs_free const char **searches = NULL; - const char ** s; - const char * str; + const char **s; + const char *str; str = g_hash_table_lookup(options, "static_routes"); if (!str) @@ -342,9 +342,9 @@ static void process_domain_search(int addr_family, const char *iface, const char *str, NML3ConfigData *l3cd) { gs_free const char **searches = NULL; - gs_free char * unescaped = NULL; - const char ** s; - char * p; + gs_free char *unescaped = NULL; + const char **s; + char *p; int i; g_return_if_fail(str != NULL); @@ -378,14 +378,14 @@ process_domain_search(int addr_family, const char *iface, const char *str, NML3C NML3ConfigData * nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, int ifindex, - const char * iface, - GHashTable * options) + const char *iface, + GHashTable *options) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; guint32 tmp_addr; in_addr_t addr; NMPlatformIP4Address address; - char * str = NULL; + char *str = NULL; gboolean gateway_has = FALSE; guint32 gateway = 0; guint8 plen = 0; @@ -435,7 +435,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "routers"); if (str) { gs_free const char **routers = nm_strsplit_set(str, " "); - const char ** s; + const char **s; for (s = routers; *s; s++) { /* FIXME: how to handle multiple routers? */ @@ -479,7 +479,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "domain_name_servers"); if (str) { gs_free const char **dns = nm_strsplit_set(str, " "); - const char ** s; + const char **s; for (s = dns; dns && *s; s++) { if (inet_pton(AF_INET, *s, &tmp_addr) > 0) { @@ -495,7 +495,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "domain_name"); if (str) { gs_free const char **domains = nm_strsplit_set(str, " "); - const char ** s; + const char **s; for (s = domains; domains && *s; s++) { _LOG2I(LOGD_DHCP4, iface, " domain name '%s'", *s); @@ -510,7 +510,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "netbios_name_servers"); if (str) { gs_free const char **nbns = nm_strsplit_set(str, " "); - const char ** s; + const char **s; for (s = nbns; nbns && *s; s++) { if (inet_pton(AF_INET, *s, &tmp_addr) > 0) { @@ -545,7 +545,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "nis_servers"); if (str) { gs_free const char **nis = nm_strsplit_set(str, " "); - const char ** s; + const char **s; for (s = nis; nis && *s; s++) { if (inet_pton(AF_INET, *s, &tmp_addr) > 0) { @@ -576,12 +576,12 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, NMPlatformIP6Address nm_dhcp_utils_ip6_prefix_from_options(GHashTable *options) { - gs_strfreev char ** split_addr = NULL; + gs_strfreev char **split_addr = NULL; NMPlatformIP6Address address = { 0, }; struct in6_addr tmp_addr; - char * str = NULL; + char *str = NULL; int prefix; g_return_val_if_fail(options != NULL, address); @@ -626,14 +626,14 @@ nm_dhcp_utils_ip6_prefix_from_options(GHashTable *options) NML3ConfigData * nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx, int ifindex, - const char * iface, - GHashTable * options, + const char *iface, + GHashTable *options, gboolean info_only) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; struct in6_addr tmp_addr; NMPlatformIP6Address address; - char * str = NULL; + char *str = NULL; guint32 now; g_return_val_if_fail(options != NULL, NULL); @@ -682,7 +682,7 @@ nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "dhcp6_name_servers"); if (str) { gs_free const char **dns = nm_strsplit_set(str, " "); - const char ** s; + const char **s; for (s = dns; dns && *s; s++) { if (inet_pton(AF_INET6, *s, &tmp_addr) > 0) { @@ -731,7 +731,7 @@ nm_dhcp_utils_client_id_string_to_bytes(const char *client_id) { GBytes *bytes = NULL; guint len; - char * c; + char *c; g_return_val_if_fail(client_id && client_id[0], NULL); @@ -776,7 +776,7 @@ nm_dhcp_utils_get_leasefile_path(int addr_family, const char *plugin_name, const char *iface, const char *uuid, - char ** out_leasefile_path) + char **out_leasefile_path) { gs_free char *rundir_path = NULL; gs_free char *statedir_path = NULL; @@ -831,17 +831,17 @@ nm_dhcp_utils_get_dhcp6_event_id(GHashTable *lease) } gboolean -nm_dhcp_utils_merge_new_dhcp6_lease(const NML3ConfigData * l3cd_old, - const NML3ConfigData * l3cd_new, +nm_dhcp_utils_merge_new_dhcp6_lease(const NML3ConfigData *l3cd_old, + const NML3ConfigData *l3cd_new, const NML3ConfigData **out_l3cd_merged) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd_merged = NULL; - const NMPlatformIP6Address * addr; - NMDhcpLease * lease_old; - NMDhcpLease * lease_new; + const NMPlatformIP6Address *addr; + NMDhcpLease *lease_old; + NMDhcpLease *lease_new; NMDedupMultiIter iter; - const char * start; - const char * iaid; + const char *start; + const char *iaid; nm_assert(out_l3cd_merged); nm_assert(!*out_l3cd_merged); @@ -973,7 +973,7 @@ gboolean nm_dhcp_lease_data_parse_domain(const guint8 *data, gsize n_data, char **out_val) { gs_free char *str1_free = NULL; - const char * str1; + const char *str1; gs_free char *s = NULL; /* this is mostly the same as systemd's lease_parse_domain(). */ @@ -1051,17 +1051,17 @@ lease_option_print_label(NMStrBuf *sbuf, size_t n_label, const uint8_t **datap, } static char * -lease_option_print_domain_name(const uint8_t * cache, - size_t * n_cachep, +lease_option_print_domain_name(const uint8_t *cache, + size_t *n_cachep, const uint8_t **datap, - size_t * n_datap) + size_t *n_datap) { nm_auto_str_buf NMStrBuf sbuf = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_40, FALSE); - const uint8_t * domain; + const uint8_t *domain; size_t n_domain; size_t n_cache = *n_cachep; - const uint8_t ** domainp = datap; - size_t * n_domainp = n_datap; + const uint8_t **domainp = datap; + size_t *n_domainp = n_datap; gboolean first = TRUE; uint8_t c; @@ -1147,7 +1147,7 @@ lease_option_print_domain_name(const uint8_t * cache, char ** nm_dhcp_lease_data_parse_search_list(const guint8 *data, gsize n_data) { - GPtrArray * array = NULL; + GPtrArray *array = NULL; const guint8 *cache = data; gsize n_cache = 0; diff --git a/src/core/dhcp/nm-dhcp-utils.h b/src/core/dhcp/nm-dhcp-utils.h index bee10de3f6..bef50c5261 100644 --- a/src/core/dhcp/nm-dhcp-utils.h +++ b/src/core/dhcp/nm-dhcp-utils.h @@ -12,13 +12,13 @@ NML3ConfigData *nm_dhcp_utils_ip4_config_from_options(struct _NMDedupMultiIndex *multi_idx, int ifindex, - const char * iface, - GHashTable * options); + const char *iface, + GHashTable *options); NML3ConfigData *nm_dhcp_utils_ip6_config_from_options(struct _NMDedupMultiIndex *multi_idx, int ifindex, - const char * iface, - GHashTable * options, + const char *iface, + GHashTable *options, gboolean info_only); NMPlatformIP6Address nm_dhcp_utils_ip6_prefix_from_options(GHashTable *options); @@ -31,12 +31,12 @@ gboolean nm_dhcp_utils_get_leasefile_path(int addr_family, const char *plugin_name, const char *iface, const char *uuid, - char ** out_leasefile_path); + char **out_leasefile_path); char *nm_dhcp_utils_get_dhcp6_event_id(GHashTable *lease); -gboolean nm_dhcp_utils_merge_new_dhcp6_lease(const NML3ConfigData * l3cd_old, - const NML3ConfigData * l3cd_new, +gboolean nm_dhcp_utils_merge_new_dhcp6_lease(const NML3ConfigData *l3cd_old, + const NML3ConfigData *l3cd_new, const NML3ConfigData **out_l3cd_merged); /*****************************************************************************/ @@ -66,6 +66,6 @@ gboolean nm_dhcp_lease_data_parse_mtu(const guint8 *data, gsize n_data, guint16 gboolean nm_dhcp_lease_data_parse_cstr(const guint8 *data, gsize n_data, gsize *out_new_len); gboolean nm_dhcp_lease_data_parse_domain(const guint8 *data, gsize n_data, char **out_val); gboolean nm_dhcp_lease_data_parse_in_addr(const guint8 *data, gsize n_data, in_addr_t *out_val); -char ** nm_dhcp_lease_data_parse_search_list(const guint8 *data, gsize n_data); +char **nm_dhcp_lease_data_parse_search_list(const guint8 *data, gsize n_data); #endif /* __NETWORKMANAGER_DHCP_UTILS_H__ */ diff --git a/src/core/dhcp/tests/test-dhcp-dhclient.c b/src/core/dhcp/tests/test-dhcp-dhclient.c index 92e4548fbe..aaa0dbc3e0 100644 --- a/src/core/dhcp/tests/test-dhcp-dhclient.c +++ b/src/core/dhcp/tests/test-dhcp-dhclient.c @@ -23,18 +23,18 @@ #define TEST_MUDURL "https://example.com/mud.json" static void -test_config(const char * orig, - const char * expected, +test_config(const char *orig, + const char *expected, int addr_family, - const char * hostname, + const char *hostname, guint32 timeout, gboolean use_fqdn, NMDhcpHostnameFlags hostname_flags, - const char * dhcp_client_id, - GBytes * expected_new_client_id, - const char * iface, - const char * anycast_addr, - const char * mud_url) + const char *dhcp_client_id, + GBytes *expected_new_client_id, + const char *iface, + const char *anycast_addr, + const char *mud_url) { gs_free char *new = NULL; gs_unref_bytes GBytes *client_id = NULL; @@ -825,7 +825,7 @@ test_one_duid(const char *escaped, const guint8 *unescaped, guint len) { gs_unref_bytes GBytes *t1 = NULL; gs_unref_bytes GBytes *t2 = NULL; - gs_free char * w = NULL; + gs_free char *w = NULL; t1 = nm_dhcp_dhclient_unescape_duid(escaped); g_assert(t1); @@ -873,7 +873,7 @@ test_read_duid_from_leasefile(void) const guint8 expected[] = {0x00, 0x01, 0x00, 0x01, 0x18, 0x79, 0xa6, 0x13, 0x60, 0x67, 0x20, 0xec, 0x4c, 0x70}; gs_unref_bytes GBytes *duid = NULL; - GError * error = NULL; + GError *error = NULL; duid = nm_dhcp_dhclient_read_duid(TEST_DIR "/test-dhclient-duid.leases", &error); nmtst_assert_success(duid, error); @@ -898,7 +898,7 @@ static void _save_duid(const char *path, const guint8 *duid_bin, gsize duid_len) { gs_unref_bytes GBytes *duid = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; g_assert(path); @@ -914,12 +914,12 @@ static void test_write_duid(void) { const guint8 duid[] = {000, 001, 000, 001, 027, 'X', 0350, 'X', 0, '#', 025, 010, '~', 0254}; - const char * expected_contents = + const char *expected_contents = "default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n"; - GError * error = NULL; + GError *error = NULL; gs_free char *contents = NULL; gboolean success; - const char * path = "test-dhclient-write-duid.leases"; + const char *path = "test-dhclient-write-duid.leases"; _save_duid(path, duid, G_N_ELEMENTS(duid)); @@ -940,10 +940,10 @@ test_write_existing_duid(void) "default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n"; const char *expected_contents = "default-duid \"\\000\\001\\000\\001\\023o\\023n\\000\\\"\\372\\214\\326\\302\";\n"; - GError * error = NULL; + GError *error = NULL; gs_free char *contents = NULL; gboolean success; - const char * path = "test-dhclient-write-existing-duid.leases"; + const char *path = "test-dhclient-write-existing-duid.leases"; success = g_file_set_contents(path, original_contents, -1, &error); nmtst_assert_success(success, error); @@ -967,11 +967,11 @@ static void test_write_existing_commented_duid(void) { #define ORIG_CONTENTS "#default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n" - const char * expected_contents = "default-duid \"" DUID "\";\n" ORIG_CONTENTS; - GError * error = NULL; + const char *expected_contents = "default-duid \"" DUID "\";\n" ORIG_CONTENTS; + GError *error = NULL; gs_free char *contents = NULL; gboolean success; - const char * path = "test-dhclient-write-existing-commented-duid.leases"; + const char *path = "test-dhclient-write-existing-commented-duid.leases"; success = g_file_set_contents(path, ORIG_CONTENTS, -1, &error); nmtst_assert_success(success, error); @@ -994,9 +994,9 @@ test_write_existing_multiline_duid(void) #define ORIG_CONTENTS \ "### Commented old DUID ###\n" \ "#default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n" - const char * expected_contents = "default-duid \"" DUID "\";\n" ORIG_CONTENTS; - GError * error = NULL; - gs_free char * contents = NULL; + const char *expected_contents = "default-duid \"" DUID "\";\n" ORIG_CONTENTS; + GError *error = NULL; + gs_free char *contents = NULL; gboolean success; nmtst_auto_unlinkfile char *path = g_strdup("test-dhclient-write-existing-multiline-duid.leases"); diff --git a/src/core/dhcp/tests/test-dhcp-utils.c b/src/core/dhcp/tests/test-dhcp-utils.c index 0fab5c15ad..f021b6423b 100644 --- a/src/core/dhcp/tests/test-dhcp-utils.c +++ b/src/core/dhcp/tests/test-dhcp-utils.c @@ -24,7 +24,7 @@ static const NML3ConfigData * _ip4_config_from_options(int ifindex, const char *iface, GHashTable *options) { nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = nm_dedup_multi_index_new(); - NML3ConfigData * l3cd; + NML3ConfigData *l3cd; l3cd = nm_dhcp_utils_ip4_config_from_options(multi_idx, ifindex, iface, options); g_assert(NM_IS_L3_CONFIG_DATA(l3cd)); @@ -72,23 +72,23 @@ static const Option generic_options[] = { static void test_generic_options(void) { - gs_unref_hashtable GHashTable *options = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const NMPlatformIP4Address * address; - const NMPlatformIP4Route * route; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMPlatformIP4Address *address; + const NMPlatformIP4Route *route; guint32 tmp; - const char * expected_addr = "192.168.1.106"; - const char * expected_gw = "192.168.1.1"; - const char * expected_dns1 = "216.254.95.2"; - const char * expected_dns2 = "216.231.41.2"; - const char * expected_search1 = "foobar.com"; - const char * expected_search2 = "blah.foobar.com"; - const char * expected_route1_dest = "10.1.1.5"; - const char * expected_route1_gw = "10.1.1.1"; - const char * expected_route2_dest = "100.99.88.56"; - const char * expected_route2_gw = "10.1.1.1"; - const char *const * strarr; - const in_addr_t * ia_arr; + const char *expected_addr = "192.168.1.106"; + const char *expected_gw = "192.168.1.1"; + const char *expected_dns1 = "216.254.95.2"; + const char *expected_dns2 = "216.231.41.2"; + const char *expected_search1 = "foobar.com"; + const char *expected_search2 = "blah.foobar.com"; + const char *expected_route1_dest = "10.1.1.5"; + const char *expected_route1_gw = "10.1.1.1"; + const char *expected_route2_dest = "100.99.88.56"; + const char *expected_route2_gw = "10.1.1.1"; + const char *const *strarr; + const in_addr_t *ia_arr; guint u; options = fill_table(generic_options, NULL); @@ -146,14 +146,14 @@ test_generic_options(void) static void test_wins_options(void) { - gs_unref_hashtable GHashTable *options = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const NMPlatformIP4Address * address; - const char * expected_wins1 = "63.12.199.5"; - const char * expected_wins2 = "150.4.88.120"; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMPlatformIP4Address *address; + const char *expected_wins1 = "63.12.199.5"; + const char *expected_wins2 = "150.4.88.120"; static const Option data[] = {{"netbios_name_servers", "63.12.199.5 150.4.88.120"}, {NULL, NULL}}; - const in_addr_t * ia_arr; + const in_addr_t *ia_arr; guint u; options = fill_table(generic_options, NULL); @@ -173,8 +173,8 @@ test_wins_options(void) static void test_vendor_option_metered(void) { - gs_unref_hashtable GHashTable *options = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; static const Option data[] = {{"vendor_encapsulated_options", "ANDROID_METERED"}, {NULL, NULL}}; options = fill_table(generic_options, NULL); @@ -193,7 +193,7 @@ static void test_parse_search_list(void) { guint8 *data; - char ** domains; + char **domains; data = (guint8[]){0x05, 'l', 'o', 'c', 'a', 'l', 0x00}; domains = nm_dhcp_lease_data_parse_search_list(data, 7); @@ -245,8 +245,8 @@ test_parse_search_list(void) static void ip4_test_route(const NML3ConfigData *l3cd, guint route_num, - const char * expected_dest, - const char * expected_gw, + const char *expected_dest, + const char *expected_gw, guint expected_prefix) { const NMPlatformIP4Route *route; @@ -278,12 +278,12 @@ ip4_test_route(const NML3ConfigData *l3cd, static void test_classless_static_routes_1(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - const char * expected_route2_dest = "10.0.0.0"; - const char * expected_route2_gw = "10.17.66.41"; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + const char *expected_route2_dest = "10.0.0.0"; + const char *expected_route2_gw = "10.17.66.41"; static const Option data[] = { /* dhclient custom format */ {"rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 8 10 10 17 66 41"}, @@ -303,12 +303,12 @@ test_classless_static_routes_1(void) static void test_classless_static_routes_2(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - const char * expected_route2_dest = "10.0.0.0"; - const char * expected_route2_gw = "10.17.66.41"; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + const char *expected_route2_dest = "10.0.0.0"; + const char *expected_route2_gw = "10.17.66.41"; static const Option data[] = { /* dhcpcd format */ {"classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41"}, @@ -328,13 +328,13 @@ test_classless_static_routes_2(void) static void test_fedora_dhclient_classless_static_routes(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "129.210.177.128"; - const char * expected_route1_gw = "192.168.0.113"; - const char * expected_route2_dest = "2.0.0.0"; - const char * expected_route2_gw = "10.34.255.6"; - const char * expected_gateway = "192.168.0.113"; + const char *expected_route1_dest = "129.210.177.128"; + const char *expected_route1_gw = "192.168.0.113"; + const char *expected_route2_dest = "2.0.0.0"; + const char *expected_route2_gw = "10.34.255.6"; + const char *expected_gateway = "192.168.0.113"; static const Option data[] = { /* Fedora dhclient format */ {"classless_static_routes", @@ -357,10 +357,10 @@ test_fedora_dhclient_classless_static_routes(void) static void test_dhclient_invalid_classless_routes_1(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; static const Option data[] = { /* dhclient format */ {"rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 45 10 17 66 41"}, @@ -382,12 +382,12 @@ test_dhclient_invalid_classless_routes_1(void) static void test_dhcpcd_invalid_classless_routes_1(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "10.1.1.5"; - const char * expected_route1_gw = "10.1.1.1"; - const char * expected_route2_dest = "100.99.88.56"; - const char * expected_route2_gw = "10.1.1.1"; + const char *expected_route1_dest = "10.1.1.5"; + const char *expected_route1_gw = "10.1.1.1"; + const char *expected_route2_dest = "100.99.88.56"; + const char *expected_route2_gw = "10.1.1.1"; static const Option data[] = { /* dhcpcd format */ {"classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.adfadf/44 10.17.66.41"}, @@ -412,12 +412,12 @@ test_dhcpcd_invalid_classless_routes_1(void) static void test_dhclient_invalid_classless_routes_2(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "10.1.1.5"; - const char * expected_route1_gw = "10.1.1.1"; - const char * expected_route2_dest = "100.99.88.56"; - const char * expected_route2_gw = "10.1.1.1"; + const char *expected_route1_dest = "10.1.1.5"; + const char *expected_route1_gw = "10.1.1.1"; + const char *expected_route2_dest = "100.99.88.56"; + const char *expected_route2_gw = "10.1.1.1"; static const Option data[] = { {"rfc3442_classless_static_routes", "45 10 17 66 41 24 192 168 10 192 168 1 1"}, {NULL, NULL}}; @@ -441,12 +441,12 @@ test_dhclient_invalid_classless_routes_2(void) static void test_dhcpcd_invalid_classless_routes_2(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "10.1.1.5"; - const char * expected_route1_gw = "10.1.1.1"; - const char * expected_route2_dest = "100.99.88.56"; - const char * expected_route2_gw = "10.1.1.1"; + const char *expected_route1_dest = "10.1.1.5"; + const char *expected_route1_gw = "10.1.1.1"; + const char *expected_route2_dest = "100.99.88.56"; + const char *expected_route2_gw = "10.1.1.1"; static const Option data[] = { {"classless_static_routes", "10.0.adfadf/44 10.17.66.41 192.168.10.0/24 192.168.1.1"}, {NULL, NULL}}; @@ -472,10 +472,10 @@ test_dhcpcd_invalid_classless_routes_2(void) static void test_dhclient_invalid_classless_routes_3(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; static const Option data[] = { {"rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 32 128 10 17 66 41"}, {NULL, NULL}}; @@ -496,10 +496,10 @@ test_dhclient_invalid_classless_routes_3(void) static void test_dhcpcd_invalid_classless_routes_3(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; static Option data[] = { {"classless_static_routes", "192.168.10.0/24 192.168.1.1 128/32 10.17.66.41"}, {NULL, NULL}}; @@ -520,11 +520,11 @@ test_dhcpcd_invalid_classless_routes_3(void) static void test_dhclient_gw_in_classless_routes(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - const char * expected_gateway = "192.2.3.4"; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + const char *expected_gateway = "192.2.3.4"; static Option data[] = { {"rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 0 192 2 3 4"}, {NULL, NULL}}; @@ -544,11 +544,11 @@ test_dhclient_gw_in_classless_routes(void) static void test_dhcpcd_gw_in_classless_routes(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_route1_dest = "192.168.10.0"; - const char * expected_route1_gw = "192.168.1.1"; - const char * expected_gateway = "192.2.3.4"; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + const char *expected_gateway = "192.2.3.4"; static Option data[] = { {"classless_static_routes", "192.168.10.0/24 192.168.1.1 0.0.0.0/0 192.2.3.4"}, {NULL, NULL}}; @@ -568,13 +568,13 @@ test_dhcpcd_gw_in_classless_routes(void) static void test_escaped_domain_searches(void) { - gs_unref_hashtable GHashTable *options = NULL; + gs_unref_hashtable GHashTable *options = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const char * expected_search0 = "host1"; - const char * expected_search1 = "host2"; - const char * expected_search2 = "host3"; + const char *expected_search0 = "host1"; + const char *expected_search1 = "host2"; + const char *expected_search2 = "host3"; static const Option data[] = {{"domain_search", "host1\\032host2\\032host3"}, {NULL, NULL}}; - const char *const * strarr; + const char *const *strarr; guint u; options = fill_table(generic_options, NULL); @@ -591,10 +591,10 @@ test_escaped_domain_searches(void) static void test_invalid_escaped_domain_searches(void) { - gs_unref_hashtable GHashTable *options = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; static const Option data[] = {{"domain_search", "host1\\aahost2\\032host3"}, {NULL, NULL}}; - const char *const * strarr; + const char *const *strarr; guint u; options = fill_table(generic_options, NULL); @@ -612,9 +612,9 @@ test_invalid_escaped_domain_searches(void) static void test_ip4_missing_prefix(const char *ip, guint32 expected_prefix) { - gs_unref_hashtable GHashTable *options = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const NMPlatformIP4Address * address; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMPlatformIP4Address *address; options = fill_table(generic_options, NULL); g_hash_table_insert(options, "ip_address", (gpointer) ip); @@ -649,9 +649,9 @@ test_ip4_missing_prefix_8(void) static void test_ip4_prefix_classless(void) { - gs_unref_hashtable GHashTable *options = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const NMPlatformIP4Address * address; + gs_unref_hashtable GHashTable *options = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; + const NMPlatformIP4Address *address; /* Ensure that the missing-subnet-mask handler doesn't mangle classless * subnet masks at all. The handler should trigger only if the server @@ -674,7 +674,7 @@ test_ip4_prefix_classless(void) G_STMT_START \ { \ gs_unref_bytes GBytes *b = NULL; \ - const char * p; \ + const char *p; \ gsize l; \ \ b = nm_dhcp_utils_client_id_string_to_bytes(src); \ @@ -694,12 +694,12 @@ test_ip4_prefix_classless(void) static void test_client_id_from_string(void) { - const char * nothex = "asdfasdfasdfasdfasdfasdfasdf"; - const char * allhex = "00:11:22:33:4:55:66:77:88"; + const char *nothex = "asdfasdfasdfasdfasdfasdfasdf"; + const char *allhex = "00:11:22:33:4:55:66:77:88"; const guint8 allhex_bin[] = {0x00, 0x11, 0x22, 0x33, 0x04, 0x55, 0x66, 0x77, 0x88}; - const char * somehex = "00:11:22:33:44:55:asdfasdfasdf:99:10"; - const char * nocolons = "0011223344559910"; - const char * endcolon = "00:11:22:33:44:55:"; + const char *somehex = "00:11:22:33:44:55:asdfasdfasdf:99:10"; + const char *nocolons = "0011223344559910"; + const char *endcolon = "00:11:22:33:44:55:"; COMPARE_ID(nothex, TRUE, nothex, strlen(nothex)); COMPARE_ID(allhex, FALSE, allhex_bin, sizeof(allhex_bin)); diff --git a/src/core/dns/nm-dns-dnsmasq.c b/src/core/dns/nm-dns-dnsmasq.c index b40521a32b..f0abf564cb 100644 --- a/src/core/dns/nm-dns-dnsmasq.c +++ b/src/core/dns/nm-dns-dnsmasq.c @@ -46,8 +46,8 @@ G_STATIC_ASSERT(WAIT_MSEC_AFTER_SIGKILL + 100 <= NM_SHUTDOWN_TIMEOUT_MS_WATCHDOG typedef void (*GlPidSpawnAsyncNotify)(GCancellable *cancellable, GPid pid, - const int * p_exit_code, - GError * error, + const int *p_exit_code, + GError *error, gpointer notify_user_data); typedef struct { @@ -59,10 +59,10 @@ typedef struct { } GlPidKillExternalData; typedef struct { - const char * dm_binary; + const char *dm_binary; GlPidSpawnAsyncNotify notify; gpointer notify_user_data; - GCancellable * cancellable; + GCancellable *cancellable; } GlPidSpawnAsyncData; static struct { @@ -166,9 +166,9 @@ process_gone: static gboolean _gl_pid_kill_external(void) { - gs_free char *contents = NULL; - gs_free char *cmdline_contents = NULL; - gs_free_error GError *error = NULL; + gs_free char *contents = NULL; + gs_free char *cmdline_contents = NULL; + gs_free_error GError *error = NULL; gint64 pid64; GPid pid = 0; guint64 p_start_time = 0; @@ -481,7 +481,7 @@ static void _gl_pid_spawn_next_step(void) { gs_free_error GError *error = NULL; - const char * argv[15]; + const char *argv[15]; GPid pid = 0; guint argv_idx; @@ -610,8 +610,8 @@ _gl_pid_spawn_next_step(void) * asynchronously. */ static void -_gl_pid_spawn(const char * dm_binary, - GCancellable * cancellable, +_gl_pid_spawn(const char *dm_binary, + GCancellable *cancellable, GlPidSpawnAsyncNotify notify, gpointer notify_user_data) { @@ -718,10 +718,10 @@ static gboolean start_dnsmasq(NMDnsDnsmasq *self, gboolean force_start, GError * /*****************************************************************************/ static void -add_dnsmasq_nameserver(NMDnsDnsmasq * self, +add_dnsmasq_nameserver(NMDnsDnsmasq *self, GVariantBuilder *servers, - const char * ip, - const char * domain) + const char *ip, + const char *domain) { g_return_if_fail(ip); @@ -778,8 +778,8 @@ ip_addr_to_string(int addr_family, gconstpointer addr, const char *iface, char * } static void -add_global_config(NMDnsDnsmasq * self, - GVariantBuilder * dnsmasq_servers, +add_global_config(NMDnsDnsmasq *self, + GVariantBuilder *dnsmasq_servers, const NMGlobalDnsConfig *config) { guint i, j; @@ -789,7 +789,7 @@ add_global_config(NMDnsDnsmasq * self, for (i = 0; i < nm_global_dns_config_get_num_domains(config); i++) { NMGlobalDnsDomain *domain = nm_global_dns_config_get_domain(config, i); const char *const *servers = nm_global_dns_domain_get_servers(domain); - const char * name = nm_global_dns_domain_get_name(domain); + const char *name = nm_global_dns_domain_get_name(domain); g_return_if_fail(name); @@ -805,8 +805,8 @@ add_global_config(NMDnsDnsmasq * self, static void add_ip_config(NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsConfigIPData *ip_data) { - const char * iface; - const char * domain; + const char *iface; + const char *domain; char ip_addr_to_string_buf[IP_ADDR_TO_STRING_BUFLEN]; gconstpointer nameservers; guint num; @@ -845,10 +845,10 @@ add_ip_config(NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsConfigIPD } static GVariant * -create_update_args(NMDnsDnsmasq * self, +create_update_args(NMDnsDnsmasq *self, const NMGlobalDnsConfig *global_config, - const CList * ip_data_lst_head, - const char * hostname) + const CList *ip_data_lst_head, + const char *hostname) { GVariantBuilder servers; const NMDnsConfigIPData *ip_data; @@ -870,8 +870,8 @@ create_update_args(NMDnsDnsmasq * self, static void dnsmasq_update_done(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMDnsDnsmasq *self; - gs_free_error GError *error = NULL; + NMDnsDnsmasq *self; + gs_free_error GError *error = NULL; gs_unref_variant GVariant *response = NULL; response = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source_object), res, &error); @@ -967,15 +967,15 @@ name_owner_changed(NMDnsDnsmasq *self, const char *name_owner) static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { NMDnsDnsmasq *self = user_data; - const char * new_owner; + const char *new_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) return; @@ -1007,11 +1007,11 @@ spawn_timeout_cb(gpointer user_data) static void spawn_notify(GCancellable *cancellable, GPid pid, - const int * p_exit_code, - GError * error, + const int *p_exit_code, + GError *error, gpointer notify_user_data) { - NMDnsDnsmasq * self; + NMDnsDnsmasq *self; NMDnsDnsmasqPrivate *priv; if (nm_utils_error_is_cancelled(error)) @@ -1044,7 +1044,7 @@ spawn_notify(GCancellable *cancellable, static gboolean _burst_retry_timeout_cb(gpointer user_data) { - NMDnsDnsmasq * self = user_data; + NMDnsDnsmasq *self = user_data; NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE(self); priv->burst_retry_timeout_id = 0; @@ -1058,7 +1058,7 @@ static gboolean start_dnsmasq(NMDnsDnsmasq *self, gboolean force_start, GError **error) { NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE(self); - const char * dm_binary; + const char *dm_binary; gint64 now; if (G_LIKELY(priv->main_cancellable)) { @@ -1121,13 +1121,13 @@ start_dnsmasq(NMDnsDnsmasq *self, gboolean force_start, GError **error) } static gboolean -update(NMDnsPlugin * plugin, +update(NMDnsPlugin *plugin, const NMGlobalDnsConfig *global_config, - const CList * ip_data_lst_head, - const char * hostname, - GError ** error) + const CList *ip_data_lst_head, + const char *hostname, + GError **error) { - NMDnsDnsmasq * self = NM_DNS_DNSMASQ(plugin); + NMDnsDnsmasq *self = NM_DNS_DNSMASQ(plugin); NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE(self); if (!start_dnsmasq(self, TRUE, error)) @@ -1146,7 +1146,7 @@ update(NMDnsPlugin * plugin, static void stop(NMDnsPlugin *plugin) { - NMDnsDnsmasq * self = NM_DNS_DNSMASQ(plugin); + NMDnsDnsmasq *self = NM_DNS_DNSMASQ(plugin); NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE(self); priv->is_stopped = TRUE; @@ -1173,7 +1173,7 @@ nm_dns_dnsmasq_new(void) static void dispose(GObject *object) { - NMDnsDnsmasq * self = NM_DNS_DNSMASQ(object); + NMDnsDnsmasq *self = NM_DNS_DNSMASQ(object); NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE(self); priv->is_stopped = TRUE; @@ -1193,7 +1193,7 @@ static void nm_dns_dnsmasq_class_init(NMDnsDnsmasqClass *dns_class) { NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS(dns_class); - GObjectClass * object_class = G_OBJECT_CLASS(dns_class); + GObjectClass *object_class = G_OBJECT_CLASS(dns_class); object_class->dispose = dispose; diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c index 4fe7945033..4e7a4a5424 100644 --- a/src/core/dns/nm-dns-manager.c +++ b/src/core/dns/nm-dns-manager.c @@ -61,11 +61,11 @@ typedef enum { SR_SUCCESS, SR_NOTFOUND, SR_ERROR } SpawnResult; typedef struct { - GPtrArray * nameservers; - GPtrArray * searches; - GPtrArray * options; + GPtrArray *nameservers; + GPtrArray *searches; + GPtrArray *options; const char *nis_domain; - GPtrArray * nis_servers; + GPtrArray *nis_servers; NMTernary has_trust_ad; } NMResolvConfData; @@ -104,9 +104,9 @@ typedef struct { guint8 prev_hash[HASH_LEN]; /* Hash when begin_updates() was called */ NMDnsManagerResolvConfManager rc_manager; - char * mode; - NMDnsPlugin * sd_resolve_plugin; - NMDnsPlugin * plugin; + char *mode; + NMDnsPlugin *sd_resolve_plugin; + NMDnsPlugin *plugin; NMConfig *config; @@ -264,7 +264,7 @@ _ASSERT_dns_config_ip_data(const NMDnsConfigIPData *ip_data) } static NMDnsConfigIPData * -_dns_config_ip_data_new(NMDnsConfigData * data, +_dns_config_ip_data_new(NMDnsConfigData *data, int addr_family, gconstpointer source_tag, const NML3ConfigData *l3cd, @@ -376,7 +376,7 @@ NMDnsPlugin * nm_dns_manager_get_systemd_resolved(NMDnsManager *self) { NMDnsManagerPrivate *priv; - NMDnsPlugin * plugin = NULL; + NMDnsPlugin *plugin = NULL; g_return_val_if_fail(NM_IS_DNS_MANAGER(self), FALSE); @@ -424,7 +424,7 @@ add_dns_option_item(GPtrArray *array, const char *str) } static void -add_dns_domains(GPtrArray * array, +add_dns_domains(GPtrArray *array, int addr_family, const NML3ConfigData *l3cd, gboolean include_routing, @@ -435,7 +435,7 @@ add_dns_domains(GPtrArray * array, guint num_domains; guint num_searches; guint i; - const char * str; + const char *str; domains = nm_l3_config_data_get_domains(l3cd, addr_family, &num_domains); searches = nm_l3_config_data_get_searches(l3cd, addr_family, &num_searches); @@ -526,7 +526,7 @@ merge_one_l3cd(NMResolvConfData *rc, int addr_family, int ifindex, const NML3Con if (addr_family == AF_INET) { const in_addr_t *nis_servers; - const char * nis_domain; + const char *nis_domain; nis_servers = nm_l3_config_data_get_nis_servers(l3cd, &num); for (i = 0; i < num; i++) @@ -543,7 +543,7 @@ merge_one_l3cd(NMResolvConfData *rc, int addr_family, int ifindex, const NML3Con static GPid run_netconfig(NMDnsManager *self, GError **error, int *stdin_fd) { - char * argv[5]; + char *argv[5]; gs_free char *tmp = NULL; GPid pid = -1; @@ -581,9 +581,9 @@ netconfig_construct_str(NMDnsManager *self, GString *str, const char *key, const } static void -netconfig_construct_strv(NMDnsManager * self, - GString * str, - const char * key, +netconfig_construct_strv(NMDnsManager *self, + GString *str, + const char *key, const char *const *values) { if (values) { @@ -595,18 +595,18 @@ netconfig_construct_strv(NMDnsManager * self, } static SpawnResult -dispatch_netconfig(NMDnsManager * self, +dispatch_netconfig(NMDnsManager *self, const char *const *searches, const char *const *nameservers, - const char * nis_domain, + const char *nis_domain, const char *const *nis_servers, - GError ** error) + GError **error) { - GPid pid; - int fd; - int errsv; - int status; - gssize l; + GPid pid; + int fd; + int errsv; + int status; + gssize l; nm_auto_free_gstring GString *str = NULL; pid = run_netconfig(self, error, &fd); @@ -763,11 +763,11 @@ write_resolv_conf_contents(FILE *f, const char *content, GError **error) } static gboolean -write_resolv_conf(FILE * f, +write_resolv_conf(FILE *f, const char *const *searches, const char *const *nameservers, const char *const *options, - GError ** error) + GError **error) { gs_free char *content = NULL; @@ -777,17 +777,17 @@ write_resolv_conf(FILE * f, static SpawnResult dispatch_resolvconf(NMDnsManager *self, - char ** searches, - char ** nameservers, - char ** options, - GError ** error) + char **searches, + char **nameservers, + char **options, + GError **error) { gs_free char *cmd = NULL; - FILE * f; + FILE *f; gboolean success = FALSE; int errsv; int err; - char * argv[] = {RESOLVCONF_PATH, "-d", "NetworkManager", NULL}; + char *argv[] = {RESOLVCONF_PATH, "-d", "NetworkManager", NULL}; int status; if (!g_file_test(RESOLVCONF_PATH, G_FILE_TEST_IS_EXECUTABLE)) { @@ -878,13 +878,13 @@ _read_link_cached(const char *path, gboolean *is_cached, char **cached) #define NO_STUB_RESOLV_CONF NMRUNDIR "/no-stub-resolv.conf" static void -update_resolv_conf_no_stub(NMDnsManager * self, +update_resolv_conf_no_stub(NMDnsManager *self, const char *const *searches, const char *const *nameservers, const char *const *options) { gs_free char *content = NULL; - GError * local = NULL; + GError *local = NULL; content = create_resolv_conf(searches, nameservers, options); @@ -898,14 +898,14 @@ update_resolv_conf_no_stub(NMDnsManager * self, } static SpawnResult -update_resolv_conf(NMDnsManager * self, - const char *const * searches, - const char *const * nameservers, - const char *const * options, - GError ** error, +update_resolv_conf(NMDnsManager *self, + const char *const *searches, + const char *const *nameservers, + const char *const *options, + GError **error, NMDnsManagerResolvConfManager rc_manager) { - FILE * f; + FILE *f; gboolean success; gs_free char *content = NULL; SpawnResult write_file_result = SR_SUCCESS; @@ -918,10 +918,10 @@ update_resolv_conf(NMDnsManager * self, if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE || (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK && !_read_link_cached(_PATH_RESCONF, &resconf_link_cached, &resconf_link))) { - gs_free char * rc_path_syml = NULL; + gs_free char *rc_path_syml = NULL; nm_auto_free char *rc_path_real = NULL; - const char * rc_path = _PATH_RESCONF; - GError * local = NULL; + const char *rc_path = _PATH_RESCONF; + GError *local = NULL; if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE) { rc_path_real = realpath(_PATH_RESCONF, NULL); @@ -1105,7 +1105,7 @@ static void compute_hash(NMDnsManager *self, const NMGlobalDnsConfig *global, guint8 buffer[static HASH_LEN]) { nm_auto_free_checksum GChecksum *sum = NULL; - NMDnsConfigIPData * ip_data; + NMDnsConfigIPData *ip_data; sum = g_checksum_new(G_CHECKSUM_SHA1); nm_assert(HASH_LEN == g_checksum_type_get_length(G_CHECKSUM_SHA1)); @@ -1200,22 +1200,22 @@ _ptrarray_to_strv(GPtrArray *parray) } static void -_collect_resolv_conf_data(NMDnsManager * self, +_collect_resolv_conf_data(NMDnsManager *self, NMGlobalDnsConfig *global_config, - char *** out_searches, - char *** out_options, - char *** out_nameservers, - char *** out_nis_servers, - const char ** out_nis_domain) + char ***out_searches, + char ***out_options, + char ***out_nameservers, + char ***out_nis_servers, + const char **out_nis_domain) { NMDnsManagerPrivate *priv; NMResolvConfData rc = { - .nameservers = g_ptr_array_new(), - .searches = g_ptr_array_new(), - .options = g_ptr_array_new(), - .nis_domain = NULL, - .nis_servers = g_ptr_array_new(), - .has_trust_ad = NM_TERNARY_DEFAULT, + .nameservers = g_ptr_array_new(), + .searches = g_ptr_array_new(), + .options = g_ptr_array_new(), + .nis_domain = NULL, + .nis_servers = g_ptr_array_new(), + .has_trust_ad = NM_TERNARY_DEFAULT, }; priv = NM_DNS_MANAGER_GET_PRIVATE(self); @@ -1226,7 +1226,7 @@ _collect_resolv_conf_data(NMDnsManager * self, nm_auto_str_buf NMStrBuf tmp_strbuf = NM_STR_BUF_INIT(0, FALSE); int first_prio = 0; const NMDnsConfigIPData *ip_data; - const CList * head; + const CList *head; gboolean is_first = TRUE; head = _mgr_get_ip_data_lst_head(self); @@ -1295,8 +1295,8 @@ static char ** get_ip_rdns_domains(int addr_family, const NML3ConfigData *l3cd) { const int IS_IPv4 = NM_IS_IPv4(addr_family); - char ** strv; - GPtrArray * domains; + char **strv; + GPtrArray *domains; NMDedupMultiIter ipconf_iter; const NMPObject *obj; @@ -1350,11 +1350,11 @@ _domain_track_get_priority(GHashTable *ht, const char *domain, int *out_priority /* Check if the domain is shadowed by a parent domain with more negative priority */ static gboolean -_domain_track_is_shadowed(GHashTable * ht, - const char * domain, +_domain_track_is_shadowed(GHashTable *ht, + const char *domain, int priority, const char **out_parent, - int * out_parent_priority) + int *out_parent_priority) { char *parent; int parent_priority; @@ -1393,10 +1393,10 @@ _domain_track_is_shadowed(GHashTable * ht, static void _mgr_configs_data_construct(NMDnsManager *self) { - NMDnsConfigIPData *ip_data; + NMDnsConfigIPData *ip_data; gs_unref_hashtable GHashTable *ht = NULL; gs_unref_hashtable GHashTable *wildcard_entries = NULL; - CList * head; + CList *head; int prev_priority = G_MININT; head = _mgr_get_ip_data_lst_head(self); @@ -1447,7 +1447,7 @@ _mgr_configs_data_construct(NMDnsManager *self) c_list_for_each_entry (ip_data, head, ip_data_lst) { int priority; - const char ** domains; + const char **domains; const char *const *strv_searches; const char *const *strv_domains; guint n_searches; @@ -1621,7 +1621,7 @@ static void _mgr_configs_data_clear(NMDnsManager *self) { NMDnsConfigIPData *ip_data; - CList * head; + CList *head; head = _mgr_get_ip_data_lst_head(self); c_list_for_each_entry (ip_data, head, ip_data_lst) { @@ -1638,18 +1638,18 @@ _mgr_configs_data_clear(NMDnsManager *self) static gboolean update_dns(NMDnsManager *self, gboolean no_caching, gboolean force_emit, GError **error) { - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); - const char * nis_domain = NULL; - gs_strfreev char ** searches = NULL; - gs_strfreev char ** options = NULL; - gs_strfreev char ** nameservers = NULL; - gs_strfreev char ** nis_servers = NULL; - gboolean caching = FALSE; - gboolean do_update = TRUE; - gboolean resolv_conf_updated = FALSE; - SpawnResult result = SR_SUCCESS; - NMConfigData * data; - NMGlobalDnsConfig * global_config; + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); + const char *nis_domain = NULL; + gs_strfreev char **searches = NULL; + gs_strfreev char **options = NULL; + gs_strfreev char **nameservers = NULL; + gs_strfreev char **nis_servers = NULL; + gboolean caching = FALSE; + gboolean do_update = TRUE; + gboolean resolv_conf_updated = FALSE; + SpawnResult result = SR_SUCCESS; + NMConfigData *data; + NMGlobalDnsConfig *global_config; gs_free_error GError *local_error = NULL; GError **const p_local_error = error ? &local_error : NULL; @@ -1701,8 +1701,8 @@ update_dns(NMDnsManager *self, gboolean no_caching, gboolean force_emit, GError /* Let any plugins do their thing first */ if (priv->plugin) { - NMDnsPlugin * plugin = priv->plugin; - const char * plugin_name = nm_dns_plugin_get_name(plugin); + NMDnsPlugin *plugin = priv->plugin; + const char *plugin_name = nm_dns_plugin_get_name(plugin); gs_free_error GError *plugin_error = NULL; if (nm_dns_plugin_is_caching(plugin)) { @@ -1849,7 +1849,7 @@ plugin_skip:; /*****************************************************************************/ gboolean -nm_dns_manager_set_ip_config(NMDnsManager * self, +nm_dns_manager_set_ip_config(NMDnsManager *self, int addr_family, gconstpointer source_tag, const NML3ConfigData *l3cd, @@ -1857,10 +1857,10 @@ nm_dns_manager_set_ip_config(NMDnsManager * self, gboolean replace_all) { NMDnsManagerPrivate *priv; - NMDnsConfigData * data; + NMDnsConfigData *data; int ifindex; gboolean changed = FALSE; - NMDnsConfigIPData * ip_data = NULL; + NMDnsConfigIPData *ip_data = NULL; int dns_priority; g_return_val_if_fail(NM_IS_DNS_MANAGER(self), FALSE); @@ -2002,7 +2002,7 @@ void nm_dns_manager_set_hostname(NMDnsManager *self, const char *hostname, gboolean skip_update) { NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); - const char * filtered = NULL; + const char *filtered = NULL; /* Certain hostnames we don't want to include in resolv.conf 'searches' */ if (hostname && nm_utils_is_specific_hostname(hostname) && !strstr(hostname, ".in-addr.arpa") @@ -2049,7 +2049,7 @@ nm_dns_manager_begin_updates(NMDnsManager *self, const char *func) void nm_dns_manager_end_updates(NMDnsManager *self, const char *func) { - NMDnsManagerPrivate *priv; + NMDnsManagerPrivate *priv; gs_free_error GError *error = NULL; guint8 new[HASH_LEN]; @@ -2191,7 +2191,7 @@ _resolvconf_resolved_managed(void) return FALSE; if (S_ISLNK(st.st_mode)) { - gs_free char * full_path = NULL; + gs_free char *full_path = NULL; nm_auto_free char *real_path = NULL; /* see if resolv.conf is a symlink with a target that is @@ -2243,9 +2243,9 @@ _resolvconf_resolved_managed(void) static void init_resolv_conf_mode(NMDnsManager *self, gboolean force_reload_plugin) { - NMDnsManagerPrivate * priv = NM_DNS_MANAGER_GET_PRIVATE(self); + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); NMDnsManagerResolvConfManager rc_manager; - const char * mode; + const char *mode; gboolean systemd_resolved; gboolean param_changed = FALSE; gboolean plugin_changed = FALSE; @@ -2388,11 +2388,11 @@ again: } static void -config_changed_cb(NMConfig * config, - NMConfigData * config_data, +config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, - NMDnsManager * self) + NMConfigData *old_data, + NMDnsManager *self) { NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); @@ -2433,7 +2433,7 @@ _get_global_config_variant(NMGlobalDnsConfig *global) for (i = 0; i < num; i++) { GVariantBuilder conf_builder; GVariantBuilder item_builder; - const char * domain_name; + const char *domain_name; const char *const *servers; g_variant_builder_init(&conf_builder, G_VARIANT_TYPE("a{sv}")); @@ -2473,12 +2473,12 @@ _get_global_config_variant(NMGlobalDnsConfig *global) static GVariant * _get_config_variant(NMDnsManager *self) { - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); - NMGlobalDnsConfig * global_config; - gs_free char * str = NULL; - GVariantBuilder builder; - NMDnsConfigIPData * ip_data; - const CList * head; + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); + NMGlobalDnsConfig *global_config; + gs_free char *str = NULL; + GVariantBuilder builder; + NMDnsConfigIPData *ip_data; + const CList *head; gs_unref_ptrarray GPtrArray *array_domains = NULL; if (priv->config_variant) @@ -2502,7 +2502,7 @@ _get_config_variant(NMDnsManager *self) guint num_searches; guint i; char buf[NM_UTILS_INET_ADDRSTRLEN]; - const char * ifname; + const char *ifname; gconstpointer nameservers; nameservers = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num); @@ -2575,7 +2575,7 @@ _get_config_variant(NMDnsManager *self) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDnsManager * self = NM_DNS_MANAGER(object); + NMDnsManager *self = NM_DNS_MANAGER(object); NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); switch (prop_id) { @@ -2623,9 +2623,9 @@ nm_dns_manager_init(NMDnsManager *self) static void dispose(GObject *object) { - NMDnsManager * self = NM_DNS_MANAGER(object); + NMDnsManager *self = NM_DNS_MANAGER(object); NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); - NMDnsConfigIPData * ip_data, *ip_data_safe; + NMDnsConfigIPData *ip_data, *ip_data_safe; _LOGT("disposing"); @@ -2656,7 +2656,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMDnsManager * self = NM_DNS_MANAGER(object); + NMDnsManager *self = NM_DNS_MANAGER(object); NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); g_free(priv->hostname); @@ -2681,7 +2681,7 @@ static const NMDBusInterfaceInfoExtended interface_info_dns_manager = { static void nm_dns_manager_class_init(NMDnsManagerClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); object_class->dispose = dispose; diff --git a/src/core/dns/nm-dns-manager.h b/src/core/dns/nm-dns-manager.h index 2b5ca634b1..84821ecef5 100644 --- a/src/core/dns/nm-dns-manager.h +++ b/src/core/dns/nm-dns-manager.h @@ -28,14 +28,14 @@ struct _NMDnsManager; typedef struct { struct _NMDnsConfigData *data; gconstpointer source_tag; - const NML3ConfigData * l3cd; + const NML3ConfigData *l3cd; CList data_lst; CList ip_data_lst; NMDnsIPConfigType ip_config_type; int addr_family; struct { const char **search; - char ** reverse; + char **reverse; /* Whether "search" explicitly contains a default route "~" * or "". It is redundant information, but for faster lookup. */ @@ -98,7 +98,7 @@ NMDnsManager *nm_dns_manager_get(void); void nm_dns_manager_begin_updates(NMDnsManager *self, const char *func); void nm_dns_manager_end_updates(NMDnsManager *self, const char *func); -gboolean nm_dns_manager_set_ip_config(NMDnsManager * self, +gboolean nm_dns_manager_set_ip_config(NMDnsManager *self, int addr_family, gconstpointer source_tag, const NML3ConfigData *l3cd, diff --git a/src/core/dns/nm-dns-plugin.c b/src/core/dns/nm-dns-plugin.c index e5035f061f..2126da775f 100644 --- a/src/core/dns/nm-dns-plugin.c +++ b/src/core/dns/nm-dns-plugin.c @@ -57,11 +57,11 @@ G_DEFINE_ABSTRACT_TYPE(NMDnsPlugin, nm_dns_plugin, G_TYPE_OBJECT) /*****************************************************************************/ gboolean -nm_dns_plugin_update(NMDnsPlugin * self, +nm_dns_plugin_update(NMDnsPlugin *self, const NMGlobalDnsConfig *global_config, - const CList * ip_config_lst_head, - const char * hostname, - GError ** error) + const CList *ip_config_lst_head, + const char *hostname, + GError **error) { g_return_val_if_fail(NM_DNS_PLUGIN_GET_CLASS(self)->update != NULL, FALSE); diff --git a/src/core/dns/nm-dns-plugin.h b/src/core/dns/nm-dns-plugin.h index 82ca7d6b37..bc854cceab 100644 --- a/src/core/dns/nm-dns-plugin.h +++ b/src/core/dns/nm-dns-plugin.h @@ -31,11 +31,11 @@ typedef struct { * 'global_config' is the optional global DNS * configuration. */ - gboolean (*update)(NMDnsPlugin * self, + gboolean (*update)(NMDnsPlugin *self, const NMGlobalDnsConfig *global_config, - const CList * ip_config_lst_head, - const char * hostname, - GError ** error); + const CList *ip_config_lst_head, + const char *hostname, + GError **error); void (*stop)(NMDnsPlugin *self); @@ -55,11 +55,11 @@ gboolean nm_dns_plugin_is_caching(NMDnsPlugin *self); const char *nm_dns_plugin_get_name(NMDnsPlugin *self); -gboolean nm_dns_plugin_update(NMDnsPlugin * self, +gboolean nm_dns_plugin_update(NMDnsPlugin *self, const NMGlobalDnsConfig *global_config, - const CList * ip_config_lst_head, - const char * hostname, - GError ** error); + const CList *ip_config_lst_head, + const char *hostname, + GError **error); void nm_dns_plugin_stop(NMDnsPlugin *self); diff --git a/src/core/dns/nm-dns-systemd-resolved.c b/src/core/dns/nm-dns-systemd-resolved.c index c9d6cc5fea..a043e8555d 100644 --- a/src/core/dns/nm-dns-systemd-resolved.c +++ b/src/core/dns/nm-dns-systemd-resolved.c @@ -46,8 +46,8 @@ typedef struct { typedef struct { CList request_queue_lst; - const char * operation; - GVariant * argument; + const char *operation; + GVariant *argument; NMDnsSystemdResolved *self; int ifindex; } RequestItem; @@ -55,8 +55,8 @@ typedef struct { struct _NMDnsSystemdResolvedResolveHandle { CList handle_lst; NMDnsSystemdResolved *self; - GSource * timeout_source; - GCancellable * handle_cancellable; + GSource *timeout_source; + GCancellable *handle_cancellable; gpointer callback_user_data; guint timeout_msec; bool is_failing_on_idle; @@ -75,11 +75,11 @@ struct _NMDnsSystemdResolvedResolveHandle { typedef struct { GDBusConnection *dbus_connection; - GHashTable * dirty_interfaces; - GCancellable * cancellable; - GSource * try_start_timeout_source; + GHashTable *dirty_interfaces; + GCancellable *cancellable; + GSource *try_start_timeout_source; CList request_queue_lst_head; - char * dbus_owner; + char *dbus_owner; CList handle_lst_head; guint name_owner_changed_id; bool send_updates_warn_ratelimited : 1; @@ -156,12 +156,12 @@ _request_item_free(RequestItem *request_item) static void _request_item_append(NMDnsSystemdResolved *self, - const char * operation, + const char *operation, int ifindex, - GVariant * argument) + GVariant *argument) { NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); - RequestItem * request_item; + RequestItem *request_item; request_item = g_slice_new(RequestItem); *request_item = (RequestItem){ @@ -185,11 +185,11 @@ _interface_config_free(InterfaceConfig *config) static void call_done(GObject *source, GAsyncResult *r, gpointer user_data) { - gs_unref_variant GVariant *v = NULL; - gs_free_error GError * error = NULL; - NMDnsSystemdResolved * self; + gs_unref_variant GVariant *v = NULL; + gs_free_error GError *error = NULL; + NMDnsSystemdResolved *self; NMDnsSystemdResolvedPrivate *priv; - RequestItem * request_item; + RequestItem *request_item; NMLogLevel log_level; v = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), r, &error); @@ -243,15 +243,15 @@ call_done(GObject *source, GAsyncResult *r, gpointer user_data) static gboolean update_add_ip_config(NMDnsSystemdResolved *self, - GVariantBuilder * dns, - GVariantBuilder * domains, - NMDnsConfigIPData * ip_data) + GVariantBuilder *dns, + GVariantBuilder *domains, + NMDnsConfigIPData *ip_data) { gsize addr_size; guint n; guint i; gboolean is_routing; - const char * domain; + const char *domain; gboolean has_config = FALSE; gconstpointer nameservers; @@ -293,7 +293,7 @@ static void free_pending_updates(NMDnsSystemdResolved *self) { NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); - RequestItem * request_item; + RequestItem *request_item; while ((request_item = c_list_first_entry(&priv->request_queue_lst_head, RequestItem, request_queue_lst))) @@ -305,11 +305,11 @@ prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic) { GVariantBuilder dns; GVariantBuilder domains; - NMCListElem * elem; + NMCListElem *elem; NMSettingConnectionMdns mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT; NMSettingConnectionLlmnr llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT; NMSettingConnectionDnsOverTls dns_over_tls = NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT; - const char * mdns_arg = NULL, *llmnr_arg = NULL, *dns_over_tls_arg = NULL; + const char *mdns_arg = NULL, *llmnr_arg = NULL, *dns_over_tls_arg = NULL; gboolean has_config = FALSE; gboolean has_default_route = FALSE; @@ -416,8 +416,8 @@ prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic) static gboolean _ensure_resolved_running_timeout(gpointer user_data) { - NMDnsSystemdResolved * self = user_data; - NMDnsSystemdResolvedPrivate * priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); + NMDnsSystemdResolved *self = user_data; + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); NMDnsSystemdResolvedResolveHandle *handle; nm_clear_g_source_inst(&priv->try_start_timeout_source); @@ -478,8 +478,8 @@ ensure_resolved_running(NMDnsSystemdResolved *self) static void send_updates(NMDnsSystemdResolved *self) { - NMDnsSystemdResolvedPrivate * priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); - RequestItem * request_item; + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); + RequestItem *request_item; NMDnsSystemdResolvedResolveHandle *handle; if (!priv->send_updates_waiting) { @@ -548,22 +548,22 @@ start_resolve: } static gboolean -update(NMDnsPlugin * plugin, +update(NMDnsPlugin *plugin, const NMGlobalDnsConfig *global_config, - const CList * ip_data_lst_head, - const char * hostname, - GError ** error) + const CList *ip_data_lst_head, + const char *hostname, + GError **error) { - NMDnsSystemdResolved * self = NM_DNS_SYSTEMD_RESOLVED(plugin); - NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); - gs_unref_hashtable GHashTable *interfaces = NULL; - gs_free gpointer * interfaces_keys = NULL; - guint interfaces_len; - int ifindex; - gpointer pointer; - NMDnsConfigIPData *ip_data; - GHashTableIter iter; - guint i; + NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED(plugin); + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); + gs_unref_hashtable GHashTable *interfaces = NULL; + gs_free gpointer *interfaces_keys = NULL; + guint interfaces_len; + int ifindex; + gpointer pointer; + NMDnsConfigIPData *ip_data; + GHashTableIter iter; + guint i; interfaces = g_hash_table_new_full(nm_direct_hash, NULL, NULL, (GDestroyNotify) _interface_config_free); @@ -653,16 +653,16 @@ name_owner_changed(NMDnsSystemdResolved *self, const char *owner) static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMDnsSystemdResolved * self = user_data; + NMDnsSystemdResolved *self = user_data; NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); - const char * new_owner; + const char *new_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) return; @@ -683,7 +683,7 @@ name_owner_changed_cb(GDBusConnection *connection, static void get_name_owner_cb(const char *name_owner, GError *error, gpointer user_data) { - NMDnsSystemdResolved * self; + NMDnsSystemdResolved *self; NMDnsSystemdResolvedPrivate *priv; if (!name_owner && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -717,13 +717,13 @@ nm_dns_systemd_resolved_is_running(NMDnsSystemdResolved *self) /*****************************************************************************/ static void -_resolve_complete(NMDnsSystemdResolvedResolveHandle * handle, +_resolve_complete(NMDnsSystemdResolvedResolveHandle *handle, const NMDnsSystemdResolvedAddressResult *names, guint names_len, guint64 flags, - GError * error) + GError *error) { - NMDnsSystemdResolved * self; + NMDnsSystemdResolved *self; NMDnsSystemdResolvedPrivate *priv; g_return_if_fail(handle && NM_IS_DNS_SYSTEMD_RESOLVED(handle->self)); @@ -759,16 +759,16 @@ _resolve_complete_error(NMDnsSystemdResolvedResolveHandle *handle, GError *error static void _resolve_handle_call_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_variant GVariant *v = NULL; - gs_free_error GError * error = NULL; + gs_unref_variant GVariant *v = NULL; + gs_free_error GError *error = NULL; NMDnsSystemdResolvedResolveHandle *handle; - NMDnsSystemdResolved * self; - GVariantIter * v_names_iter; + NMDnsSystemdResolved *self; + GVariantIter *v_names_iter; guint64 v_flags; int v_ifindex; - char * v_name; - gs_unref_array GArray *v_names = NULL; - gs_free char * ss = NULL; + char *v_name; + gs_unref_array GArray *v_names = NULL; + gs_free char *ss = NULL; v = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -823,7 +823,7 @@ static gboolean _resolve_failing_on_idle(gpointer user_data) { NMDnsSystemdResolvedResolveHandle *handle = user_data; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; nm_utils_error_set_literal(&error, NM_UTILS_ERROR_NOT_READY, @@ -836,7 +836,7 @@ static gboolean _resolve_handle_timeout(gpointer user_data) { NMDnsSystemdResolvedResolveHandle *handle = user_data; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; nm_utils_error_set_literal(&error, NM_UTILS_ERROR_UNKNOWN, "timeout for request"); _resolve_complete_error(handle, error); @@ -900,16 +900,16 @@ _resolve_start(NMDnsSystemdResolved *self, NMDnsSystemdResolvedResolveHandle *ha } NMDnsSystemdResolvedResolveHandle * -nm_dns_systemd_resolved_resolve_address(NMDnsSystemdResolved * self, +nm_dns_systemd_resolved_resolve_address(NMDnsSystemdResolved *self, int ifindex, int addr_family, - const NMIPAddr * addr, + const NMIPAddr *addr, guint64 flags, guint timeout_msec, NMDnsSystemdResolvedResolveAddressCallback callback, gpointer user_data) { - NMDnsSystemdResolvedPrivate * priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); NMDnsSystemdResolvedResolveHandle *handle; char addr_str[NM_UTILS_INET_ADDRSTRLEN]; @@ -998,8 +998,8 @@ nm_dns_systemd_resolved_new(void) static void dispose(GObject *object) { - NMDnsSystemdResolved * self = NM_DNS_SYSTEMD_RESOLVED(object); - NMDnsSystemdResolvedPrivate * priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); + NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED(object); + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); NMDnsSystemdResolvedResolveHandle *handle; while ((handle = c_list_first_entry(&priv->handle_lst_head, @@ -1031,7 +1031,7 @@ static void nm_dns_systemd_resolved_class_init(NMDnsSystemdResolvedClass *dns_class) { NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS(dns_class); - GObjectClass * object_class = G_OBJECT_CLASS(dns_class); + GObjectClass *object_class = G_OBJECT_CLASS(dns_class); object_class->dispose = dispose; diff --git a/src/core/dns/nm-dns-systemd-resolved.h b/src/core/dns/nm-dns-systemd-resolved.h index 9f9733184c..02bc524caa 100644 --- a/src/core/dns/nm-dns-systemd-resolved.h +++ b/src/core/dns/nm-dns-systemd-resolved.h @@ -41,19 +41,19 @@ typedef struct { } NMDnsSystemdResolvedAddressResult; typedef void (*NMDnsSystemdResolvedResolveAddressCallback)( - NMDnsSystemdResolved * self, - NMDnsSystemdResolvedResolveHandle * handle, + NMDnsSystemdResolved *self, + NMDnsSystemdResolvedResolveHandle *handle, const NMDnsSystemdResolvedAddressResult *names, guint names_len, guint64 flags, - GError * error, + GError *error, gpointer user_data); NMDnsSystemdResolvedResolveHandle * -nm_dns_systemd_resolved_resolve_address(NMDnsSystemdResolved * self, +nm_dns_systemd_resolved_resolve_address(NMDnsSystemdResolved *self, int ifindex, int addr_family, - const NMIPAddr * addr, + const NMIPAddr *addr, guint64 flags, guint timeout_msec, NMDnsSystemdResolvedResolveAddressCallback callback, diff --git a/src/core/dns/nm-dns-unbound.c b/src/core/dns/nm-dns-unbound.c index 15df3acf45..f5a533324f 100644 --- a/src/core/dns/nm-dns-unbound.c +++ b/src/core/dns/nm-dns-unbound.c @@ -25,14 +25,14 @@ G_DEFINE_TYPE(NMDnsUnbound, nm_dns_unbound, NM_TYPE_DNS_PLUGIN) /*****************************************************************************/ static gboolean -update(NMDnsPlugin * plugin, +update(NMDnsPlugin *plugin, const NMGlobalDnsConfig *global_config, - const CList * ip_config_lst_head, - const char * hostname, - GError ** error) + const CList *ip_config_lst_head, + const char *hostname, + GError **error) { - char * argv[] = {DNSSEC_TRIGGER_PATH, "--async", "--update", NULL}; - gs_free_error GError *local = NULL; + char *argv[] = {DNSSEC_TRIGGER_PATH, "--async", "--update", NULL}; + gs_free_error GError *local = NULL; int status; /* TODO: We currently call a script installed with the dnssec-trigger diff --git a/src/core/dnsmasq/nm-dnsmasq-manager.c b/src/core/dnsmasq/nm-dnsmasq-manager.c index f4eea33a13..4ab91e7e33 100644 --- a/src/core/dnsmasq/nm-dnsmasq-manager.c +++ b/src/core/dnsmasq/nm-dnsmasq-manager.c @@ -62,7 +62,7 @@ G_DEFINE_TYPE(NMDnsMasqManager, nm_dnsmasq_manager, G_TYPE_OBJECT) static void dm_watch_cb(GPid pid, int status, gpointer user_data) { - NMDnsMasqManager * manager = NM_DNSMASQ_MANAGER(user_data); + NMDnsMasqManager *manager = NM_DNSMASQ_MANAGER(user_data); NMDnsMasqManagerPrivate *priv = NM_DNSMASQ_MANAGER_GET_PRIVATE(manager); guint err; @@ -86,23 +86,23 @@ dm_watch_cb(GPid pid, int status, gpointer user_data) } static GPtrArray * -create_dm_cmd_line(const char * iface, +create_dm_cmd_line(const char *iface, const NML3ConfigData *l3cd, - const char * pidfile, + const char *pidfile, gboolean announce_android_metered, - GError ** error) + GError **error) { - gs_unref_ptrarray GPtrArray *cmd = NULL; - nm_auto_free_gstring GString *s = NULL; + gs_unref_ptrarray GPtrArray *cmd = NULL; + nm_auto_free_gstring GString *s = NULL; char first[INET_ADDRSTRLEN]; char last[INET_ADDRSTRLEN]; char listen_address_s[INET_ADDRSTRLEN]; char sbuf_addr[INET_ADDRSTRLEN]; - gs_free char * error_desc = NULL; - const char * dm_binary; - const NMPlatformIP4Address * listen_address; - const in_addr_t * ipv4arr; - const char *const * strarr; + gs_free char *error_desc = NULL; + const char *dm_binary; + const NMPlatformIP4Address *listen_address; + const in_addr_t *ipv4arr; + const char *const *strarr; guint n; guint i; @@ -208,10 +208,10 @@ create_dm_cmd_line(const char * iface, static void kill_existing_by_pidfile(const char *pidfile) { - char * contents = NULL; + char *contents = NULL; pid_t pid; char proc_path[250]; - char * cmdline_contents = NULL; + char *cmdline_contents = NULL; guint64 start_time; const char *exe; @@ -242,14 +242,14 @@ out: } gboolean -nm_dnsmasq_manager_start(NMDnsMasqManager * manager, +nm_dnsmasq_manager_start(NMDnsMasqManager *manager, const NML3ConfigData *l3cd, gboolean announce_android_metered, - GError ** error) + GError **error) { gs_unref_ptrarray GPtrArray *dm_cmd = NULL; - gs_free char * cmd_str = NULL; - NMDnsMasqManagerPrivate * priv; + gs_free char *cmd_str = NULL; + NMDnsMasqManagerPrivate *priv; g_return_val_if_fail(NM_IS_DNSMASQ_MANAGER(manager), FALSE); g_return_val_if_fail(!error || !*error, FALSE); @@ -315,7 +315,7 @@ nm_dnsmasq_manager_init(NMDnsMasqManager *manager) NMDnsMasqManager * nm_dnsmasq_manager_new(const char *iface) { - NMDnsMasqManager * manager; + NMDnsMasqManager *manager; NMDnsMasqManagerPrivate *priv; manager = g_object_new(NM_TYPE_DNSMASQ_MANAGER, NULL); diff --git a/src/core/dnsmasq/nm-dnsmasq-manager.h b/src/core/dnsmasq/nm-dnsmasq-manager.h index 78ca37251e..7fd4199e75 100644 --- a/src/core/dnsmasq/nm-dnsmasq-manager.h +++ b/src/core/dnsmasq/nm-dnsmasq-manager.h @@ -33,10 +33,10 @@ GType nm_dnsmasq_manager_get_type(void); NMDnsMasqManager *nm_dnsmasq_manager_new(const char *iface); -gboolean nm_dnsmasq_manager_start(NMDnsMasqManager * manager, +gboolean nm_dnsmasq_manager_start(NMDnsMasqManager *manager, const NML3ConfigData *l3cd, gboolean announce_android_metered, - GError ** error); + GError **error); void nm_dnsmasq_manager_stop(NMDnsMasqManager *manager); diff --git a/src/core/dnsmasq/nm-dnsmasq-utils.c b/src/core/dnsmasq/nm-dnsmasq-utils.c index c2791b9e6c..7f79987830 100644 --- a/src/core/dnsmasq/nm-dnsmasq-utils.c +++ b/src/core/dnsmasq/nm-dnsmasq-utils.c @@ -14,9 +14,9 @@ gboolean nm_dnsmasq_utils_get_range(const NMPlatformIP4Address *addr, - char * out_first, - char * out_last, - char ** out_error_desc) + char *out_first, + char *out_last, + char **out_error_desc) { guint32 host = addr->address; guint8 prefix = addr->plen; diff --git a/src/core/dnsmasq/nm-dnsmasq-utils.h b/src/core/dnsmasq/nm-dnsmasq-utils.h index 1fabc9bab2..1a2b8b6432 100644 --- a/src/core/dnsmasq/nm-dnsmasq-utils.h +++ b/src/core/dnsmasq/nm-dnsmasq-utils.h @@ -9,8 +9,8 @@ #include "libnm-platform/nm-platform.h" gboolean nm_dnsmasq_utils_get_range(const NMPlatformIP4Address *addr, - char * out_first, - char * out_last, - char ** out_error_desc); + char *out_first, + char *out_last, + char **out_error_desc); #endif /* __NETWORKMANAGER_DNSMASQ_UTILS_H__ */ diff --git a/src/core/main-utils.c b/src/core/main-utils.c index 48f143c3a8..7fcffcbc08 100644 --- a/src/core/main-utils.c +++ b/src/core/main-utils.c @@ -172,8 +172,8 @@ nm_main_utils_ensure_not_running_pidfile(const char *pidfile) gs_free char *proc_cmdline = NULL; gsize len = 0; long pid; - const char * process_name; - const char * prgname = g_get_prgname(); + const char *process_name; + const char *prgname = g_get_prgname(); g_return_if_fail(prgname); @@ -219,20 +219,20 @@ nm_main_utils_ensure_root() } gboolean -nm_main_utils_early_setup(const char * progname, - int * argc, - char ** argv[], +nm_main_utils_early_setup(const char *progname, + int *argc, + char **argv[], GOptionEntry *options, void (*option_context_hook)(gpointer user_data, GOptionContext *opt_ctx), gpointer option_context_hook_data, const char *summary) { GOptionContext *opt_ctx = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success = FALSE; int i; - const char * opt_fmt_log_level = NULL, *opt_fmt_log_domains = NULL; - const char ** opt_loc_log_level = NULL, **opt_loc_log_domains = NULL; + const char *opt_fmt_log_level = NULL, *opt_fmt_log_domains = NULL; + const char **opt_loc_log_level = NULL, **opt_loc_log_domains = NULL; /* Make GIO ignore the remote VFS service; otherwise it tries to use the * session bus to contact the remote service, and NM shouldn't ever be diff --git a/src/core/main-utils.h b/src/core/main-utils.h index 9be2433e31..e3a3b490a9 100644 --- a/src/core/main-utils.h +++ b/src/core/main-utils.h @@ -17,9 +17,9 @@ gboolean nm_main_utils_write_pidfile(const char *pidfile); void nm_main_utils_ensure_not_running_pidfile(const char *pidfile); -gboolean nm_main_utils_early_setup(const char * progname, - int * argc, - char ** argv[], +gboolean nm_main_utils_early_setup(const char *progname, + int *argc, + char **argv[], GOptionEntry *options, void (*option_context_hook)(gpointer user_data, GOptionContext *opt_ctx), diff --git a/src/core/main.c b/src/core/main.c index 14d499f29f..50f70a9923 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -54,9 +54,9 @@ static struct { gboolean become_daemon; gboolean g_fatal_warnings; gboolean run_from_build_dir; - char * opt_log_level; - char * opt_log_domains; - char * pidfile; + char *opt_log_level; + char *opt_log_domains; + char *pidfile; } global_opt = { .become_daemon = TRUE, }; @@ -153,9 +153,9 @@ static int print_config(NMConfigCmdLineOptions *config_cli) { gs_unref_object NMConfig *config = NULL; - gs_free_error GError *error = NULL; - NMConfigData * config_data; - const char *const * warnings; + gs_free_error GError *error = NULL; + NMConfigData *config_data; + const char *const *warnings; nm_logging_setup("OFF", "ALL", NULL, NULL); @@ -259,7 +259,7 @@ do_early_setup(int *argc, char **argv[], NMConfigCmdLineOptions *config_cli) static gboolean _dbus_manager_init(NMConfig *config) { - NMDBusManager * busmgr; + NMDBusManager *busmgr; NMConfigConfigureAndQuitType c_a_q_type; busmgr = nm_dbus_manager_get(); @@ -282,16 +282,16 @@ _dbus_manager_init(NMConfig *config) int main(int argc, char *argv[]) { - gboolean success = FALSE; - NMManager * manager = NULL; - NMConfig * config; - gs_free_error GError * error = NULL; + gboolean success = FALSE; + NMManager *manager = NULL; + NMConfig *config; + gs_free_error GError *error = NULL; gboolean wrote_pidfile = FALSE; - char * bad_domains = NULL; + char *bad_domains = NULL; NMConfigCmdLineOptions *config_cli; guint sd_id = 0; - GError * error_invalid_logging_config = NULL; - const char *const * warnings; + GError *error_invalid_logging_config = NULL; + const char *const *warnings; int errsv; _nm_utils_is_manager_process = TRUE; diff --git a/src/core/ndisc/nm-fake-ndisc.c b/src/core/ndisc/nm-fake-ndisc.c index 2794e286da..5aea273e24 100644 --- a/src/core/ndisc/nm-fake-ndisc.c +++ b/src/core/ndisc/nm-fake-ndisc.c @@ -21,10 +21,10 @@ typedef struct { guint when; NMNDiscDHCPLevel dhcp_level; - GArray * gateways; - GArray * prefixes; - GArray * dns_servers; - GArray * dns_domains; + GArray *gateways; + GArray *prefixes; + GArray *dns_servers; + GArray *dns_domains; int hop_limit; guint32 mtu; } FakeRa; @@ -98,7 +98,7 @@ find_ra(GSList *ras, guint id) } guint -nm_fake_ndisc_add_ra(NMFakeNDisc * self, +nm_fake_ndisc_add_ra(NMFakeNDisc *self, guint seconds_after_previous, NMNDiscDHCPLevel dhcp_level, int hop_limit, @@ -106,7 +106,7 @@ nm_fake_ndisc_add_ra(NMFakeNDisc * self, { NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE(self); static guint counter = 1; - FakeRa * ra; + FakeRa *ra; ra = g_malloc0(sizeof(*ra)); ra->id = counter++; @@ -125,15 +125,15 @@ nm_fake_ndisc_add_ra(NMFakeNDisc * self, } void -nm_fake_ndisc_add_gateway(NMFakeNDisc * self, +nm_fake_ndisc_add_gateway(NMFakeNDisc *self, guint ra_id, - const char * addr, + const char *addr, gint64 expiry_msec, NMIcmpv6RouterPref preference) { NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE(self); - FakeRa * ra = find_ra(priv->ras, ra_id); - NMNDiscGateway * gw; + FakeRa *ra = find_ra(priv->ras, ra_id); + NMNDiscGateway *gw; g_assert(ra); @@ -145,18 +145,18 @@ nm_fake_ndisc_add_gateway(NMFakeNDisc * self, } void -nm_fake_ndisc_add_prefix(NMFakeNDisc * self, +nm_fake_ndisc_add_prefix(NMFakeNDisc *self, guint ra_id, - const char * network, + const char *network, guint plen, - const char * gateway, + const char *gateway, gint64 expiry_msec, gint64 expiry_preferred_msec, NMIcmpv6RouterPref preference) { NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE(self); - FakeRa * ra = find_ra(priv->ras, ra_id); - FakePrefix * prefix; + FakeRa *ra = find_ra(priv->ras, ra_id); + FakePrefix *prefix; g_assert(ra); @@ -176,12 +176,12 @@ nm_fake_ndisc_add_prefix(NMFakeNDisc * self, void nm_fake_ndisc_add_dns_server(NMFakeNDisc *self, guint ra_id, - const char * address, + const char *address, gint64 expiry_msec) { NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE(self); - FakeRa * ra = find_ra(priv->ras, ra_id); - NMNDiscDNSServer * dns; + FakeRa *ra = find_ra(priv->ras, ra_id); + NMNDiscDNSServer *dns; g_assert(ra); @@ -196,8 +196,8 @@ void nm_fake_ndisc_add_dns_domain(NMFakeNDisc *self, guint ra_id, const char *domain, gint64 expiry_msec) { NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE(self); - FakeRa * ra = find_ra(priv->ras, ra_id); - NMNDiscDNSDomain * dns; + FakeRa *ra = find_ra(priv->ras, ra_id); + NMNDiscDNSDomain *dns; g_assert(ra); @@ -226,11 +226,11 @@ send_rs(NMNDisc *ndisc, GError **error) static gboolean receive_ra(gpointer user_data) { - NMFakeNDisc * self = user_data; - NMFakeNDiscPrivate * priv = NM_FAKE_NDISC_GET_PRIVATE(self); - NMNDisc * ndisc = NM_NDISC(self); + NMFakeNDisc *self = user_data; + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE(self); + NMNDisc *ndisc = NM_NDISC(self); NMNDiscDataInternal *rdata = ndisc->rdata; - FakeRa * ra = priv->ras->data; + FakeRa *ra = priv->ras->data; NMNDiscConfigMap changed = 0; const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); guint i; @@ -254,7 +254,7 @@ receive_ra(gpointer user_data) } for (i = 0; i < ra->prefixes->len; i++) { - FakePrefix * item = &g_array_index(ra->prefixes, FakePrefix, i); + FakePrefix *item = &g_array_index(ra->prefixes, FakePrefix, i); const NMNDiscRoute route = { .network = item->network, .plen = item->plen, @@ -323,7 +323,7 @@ static void start(NMNDisc *ndisc) { NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE(ndisc); - FakeRa * ra; + FakeRa *ra; /* Queue up the first fake RA */ g_assert(priv->ras); diff --git a/src/core/ndisc/nm-fake-ndisc.h b/src/core/ndisc/nm-fake-ndisc.h index ba0a7acb78..91c2c21ce6 100644 --- a/src/core/ndisc/nm-fake-ndisc.h +++ b/src/core/ndisc/nm-fake-ndisc.h @@ -26,35 +26,35 @@ GType nm_fake_ndisc_get_type(void); NMNDisc *nm_fake_ndisc_new(NML3Cfg *l3cfg); -guint nm_fake_ndisc_add_ra(NMFakeNDisc * self, +guint nm_fake_ndisc_add_ra(NMFakeNDisc *self, guint seconds, NMNDiscDHCPLevel dhcp_level, int hop_limit, guint32 mtu); -void nm_fake_ndisc_add_gateway(NMFakeNDisc * self, +void nm_fake_ndisc_add_gateway(NMFakeNDisc *self, guint ra_id, - const char * addr, + const char *addr, gint64 expiry_msec, NMIcmpv6RouterPref preference); -void nm_fake_ndisc_add_prefix(NMFakeNDisc * self, +void nm_fake_ndisc_add_prefix(NMFakeNDisc *self, guint ra_id, - const char * network, + const char *network, guint plen, - const char * gateway, + const char *gateway, gint64 expiry_msec, gint64 expiry_preferred_msec, NMIcmpv6RouterPref preference); void nm_fake_ndisc_add_dns_server(NMFakeNDisc *self, guint ra_id, - const char * address, + const char *address, gint64 expiry_msec); void nm_fake_ndisc_add_dns_domain(NMFakeNDisc *self, guint ra_id, - const char * domain, + const char *domain, gint64 expiry_msec); void nm_fake_ndisc_emit_new_ras(NMFakeNDisc *self); diff --git a/src/core/ndisc/nm-lndp-ndisc.c b/src/core/ndisc/nm-lndp-ndisc.c index ee040be157..313756a61a 100644 --- a/src/core/ndisc/nm-lndp-ndisc.c +++ b/src/core/ndisc/nm-lndp-ndisc.c @@ -26,7 +26,7 @@ typedef struct { struct ndp *ndp; - GSource * event_source; + GSource *event_source; } NMLndpNDiscPrivate; /*****************************************************************************/ @@ -53,7 +53,7 @@ static gboolean send_rs(NMNDisc *ndisc, GError **error) { NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE(ndisc); - struct ndp_msg * msg; + struct ndp_msg *msg; int errsv; errsv = ndp_msg_new(&msg, NDP_MSG_RS); @@ -112,10 +112,10 @@ _route_preference_coerce(enum ndp_route_preference pref) static int receive_ra(struct ndp *ndp, struct ndp_msg *msg, gpointer user_data) { - NMNDisc * ndisc = (NMNDisc *) user_data; + NMNDisc *ndisc = (NMNDisc *) user_data; NMNDiscDataInternal *rdata = ndisc->rdata; NMNDiscConfigMap changed = 0; - struct ndp_msgra * msgra = ndp_msgra(msg); + struct ndp_msgra *msgra = ndp_msgra(msg); struct in6_addr gateway_addr; const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); int offset; @@ -386,11 +386,11 @@ G_STATIC_ASSERT(sizeof(NMLndpDnsslOption) == 8u); static gboolean send_ra(NMNDisc *ndisc, GError **error) { - NMLndpNDiscPrivate * priv = NM_LNDP_NDISC_GET_PRIVATE(ndisc); - NMNDiscDataInternal * rdata = ndisc->rdata; + NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE(ndisc); + NMNDiscDataInternal *rdata = ndisc->rdata; int errsv; - struct in6_addr * addr; - struct ndp_msg * msg; + struct in6_addr *addr; + struct ndp_msg *msg; guint i; nm_auto_str_buf NMStrBuf sbuf = NM_STR_BUF_INIT(0, FALSE); @@ -417,7 +417,7 @@ send_ra(NMNDisc *ndisc, GError **error) /* The device let us know about all addresses that the device got * whose prefixes are suitable for delegating. Let's announce them. */ for (i = 0; i < rdata->addresses->len; i++) { - const NMNDiscAddress * address = &g_array_index(rdata->addresses, NMNDiscAddress, i); + const NMNDiscAddress *address = &g_array_index(rdata->addresses, NMNDiscAddress, i); struct nd_opt_prefix_info *prefix; prefix = _ndp_msg_add_option(msg, sizeof(*prefix)); @@ -573,9 +573,9 @@ receive_rs(struct ndp *ndp, struct ndp_msg *msg, gpointer user_data) static gboolean event_ready(int fd, GIOCondition condition, gpointer user_data) { - gs_unref_object NMNDisc *ndisc = g_object_ref(NM_NDISC(user_data)); + gs_unref_object NMNDisc *ndisc = g_object_ref(NM_NDISC(user_data)); nm_auto_pop_netns NMPNetns *netns = NULL; - NMLndpNDiscPrivate * priv = NM_LNDP_NDISC_GET_PRIVATE(ndisc); + NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE(ndisc); _LOGD("processing libndp events"); @@ -672,9 +672,9 @@ NMNDisc * nm_lndp_ndisc_new(const NMNDiscConfig *config) { nm_auto_pop_netns NMPNetns *netns = NULL; - gs_unref_object NMNDisc *ndisc = NULL; - NMLndpNDiscPrivate * priv; - int errsv; + gs_unref_object NMNDisc *ndisc = NULL; + NMLndpNDiscPrivate *priv; + int errsv; g_return_val_if_fail(config, NULL); g_return_val_if_fail(NM_IS_L3CFG(config->l3cfg), NULL); diff --git a/src/core/ndisc/nm-ndisc-private.h b/src/core/ndisc/nm-ndisc-private.h index 047391243b..1479e5666e 100644 --- a/src/core/ndisc/nm-ndisc-private.h +++ b/src/core/ndisc/nm-ndisc-private.h @@ -45,7 +45,7 @@ gboolean nm_ndisc_add_dns_domain(NMNDisc *ndisc, const NMNDiscDNSDomain *new_ite if (nm_logging_enabled(__level, __domain)) { \ NMNDisc *const __self = (self); \ char __prefix[64]; \ - const char * __ifname = __self ? nm_ndisc_get_ifname(__self) : NULL; \ + const char *__ifname = __self ? nm_ndisc_get_ifname(__self) : NULL; \ \ _nm_log(__level, \ __domain, \ diff --git a/src/core/ndisc/nm-ndisc.c b/src/core/ndisc/nm-ndisc.c index 670b0f39ce..969eacfaba 100644 --- a/src/core/ndisc/nm-ndisc.c +++ b/src/core/ndisc/nm-ndisc.c @@ -103,11 +103,11 @@ NM_UTILS_LOOKUP_STR_DEFINE(nm_ndisc_dhcp_level_to_string, /*****************************************************************************/ NML3ConfigData * -nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, +nm_ndisc_data_to_l3cd(NMDedupMultiIndex *multi_idx, int ifindex, - const NMNDiscData * rdata, + const NMNDiscData *rdata, NMSettingIP6ConfigPrivacy ip6_privacy, - NMUtilsIPv6IfaceId * token) + NMUtilsIPv6IfaceId *token) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; guint32 ifa_flags; @@ -371,9 +371,9 @@ _data_complete(NMNDiscDataInternal *data) static void nm_ndisc_emit_config_change(NMNDisc *self, NMNDiscConfigMap changed) { - NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(self); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(self); nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL; - const NMNDiscData * rdata; + const NMNDiscData *rdata; _config_changed_log(self, changed); @@ -464,7 +464,7 @@ static gboolean complete_address(NMNDisc *ndisc, NMNDiscAddress *addr) { NMNDiscPrivate *priv; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(NM_IS_NDISC(ndisc), FALSE); @@ -501,15 +501,15 @@ complete_address(NMNDisc *ndisc, NMNDiscAddress *addr) } static gboolean -nm_ndisc_add_address(NMNDisc * ndisc, +nm_ndisc_add_address(NMNDisc *ndisc, const NMNDiscAddress *new_item, gint64 now_msec, gboolean from_ra) { - NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(ndisc); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(ndisc); NMNDiscDataInternal *rdata = &priv->rdata; - NMNDiscAddress * new2; - NMNDiscAddress * existing = NULL; + NMNDiscAddress *new2; + NMNDiscAddress *existing = NULL; guint i; nm_assert(new_item); @@ -630,7 +630,7 @@ nm_ndisc_complete_and_add_address(NMNDisc *ndisc, const NMNDiscAddress *new_item gboolean nm_ndisc_add_route(NMNDisc *ndisc, const NMNDiscRoute *new_item, gint64 now_msec) { - NMNDiscPrivate * priv; + NMNDiscPrivate *priv; NMNDiscDataInternal *rdata; guint i; guint insert_idx = G_MAXUINT; @@ -699,7 +699,7 @@ nm_ndisc_add_route(NMNDisc *ndisc, const NMNDiscRoute *new_item, gint64 now_msec gboolean nm_ndisc_add_dns_server(NMNDisc *ndisc, const NMNDiscDNSServer *new_item, gint64 now_msec) { - NMNDiscPrivate * priv; + NMNDiscPrivate *priv; NMNDiscDataInternal *rdata; guint i; @@ -737,9 +737,9 @@ nm_ndisc_add_dns_server(NMNDisc *ndisc, const NMNDiscDNSServer *new_item, gint64 gboolean nm_ndisc_add_dns_domain(NMNDisc *ndisc, const NMNDiscDNSDomain *new_item, gint64 now_msec) { - NMNDiscPrivate * priv; + NMNDiscPrivate *priv; NMNDiscDataInternal *rdata; - NMNDiscDNSDomain * item; + NMNDiscDNSDomain *item; guint i; priv = NM_NDISC_GET_PRIVATE(ndisc); @@ -814,13 +814,13 @@ solicit_retransmit_time_jitter(gint32 solicit_retransmit_time_msec) static gboolean solicit_timer_cb(gpointer user_data) { - const gint32 TIMEOUT_APPROX_THRESHOLD_SEC = 10000; - nm_auto_pop_netns NMPNetns *netns = NULL; - NMNDisc * ndisc = user_data; - NMNDiscClass * klass = NM_NDISC_GET_CLASS(ndisc); - NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(ndisc); - gs_free_error GError *error = NULL; - gint32 timeout_msec; + const gint32 TIMEOUT_APPROX_THRESHOLD_SEC = 10000; + nm_auto_pop_netns NMPNetns *netns = NULL; + NMNDisc *ndisc = user_data; + NMNDiscClass *klass = NM_NDISC_GET_CLASS(ndisc); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(ndisc); + gs_free_error GError *error = NULL; + gint32 timeout_msec; if (!nm_ndisc_netns_push(ndisc, &netns)) { nm_utils_error_set(&error, @@ -903,9 +903,9 @@ static gboolean announce_router(NMNDisc *ndisc) { nm_auto_pop_netns NMPNetns *netns = NULL; - NMNDiscClass * klass = NM_NDISC_GET_CLASS(ndisc); - NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(ndisc); - GError * error = NULL; + NMNDiscClass *klass = NM_NDISC_GET_CLASS(ndisc); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(ndisc); + GError *error = NULL; if (!nm_ndisc_netns_push(ndisc, &netns)) return G_SOURCE_REMOVE; @@ -991,9 +991,9 @@ nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd) { gboolean changed = FALSE; const struct in6_addr *in6arr; - const char *const * strvarr; + const char *const *strvarr; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; guint len; guint i; @@ -1092,7 +1092,7 @@ nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd) gboolean nm_ndisc_set_iid(NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid, gboolean is_token) { - NMNDiscPrivate * priv; + NMNDiscPrivate *priv; NMNDiscDataInternal *rdata; g_return_val_if_fail(NM_IS_NDISC(ndisc), FALSE); @@ -1133,7 +1133,7 @@ void nm_ndisc_start(NMNDisc *ndisc) { nm_auto_pop_netns NMPNetns *netns = NULL; - NMNDiscPrivate * priv; + NMNDiscPrivate *priv; g_return_if_fail(NM_IS_NDISC(ndisc)); @@ -1181,8 +1181,8 @@ void nm_ndisc_stop(NMNDisc *ndisc) { nm_auto_pop_netns NMPNetns *netns = NULL; - NMNDiscDataInternal * rdata; - NMNDiscPrivate * priv; + NMNDiscDataInternal *rdata; + NMNDiscPrivate *priv; g_return_if_fail(NM_IS_NDISC(ndisc)); @@ -1273,7 +1273,7 @@ config_map_to_string(NMNDiscConfigMap map, char *p) static void _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed) { - NMNDiscPrivate * priv; + NMNDiscPrivate *priv; NMNDiscDataInternal *rdata; guint i; char changedstr[CONFIG_MAP_MAX_STR]; @@ -1362,7 +1362,7 @@ static void clean_gateways(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint64 *next_msec) { NMNDiscDataInternal *rdata = &NM_NDISC_GET_PRIVATE(ndisc)->rdata; - NMNDiscGateway * arr; + NMNDiscGateway *arr; guint i; guint j; @@ -1393,9 +1393,9 @@ clean_gateways(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint6 static void clean_addresses(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint64 *next_msec) { - NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(ndisc); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(ndisc); NMNDiscDataInternal *rdata = &NM_NDISC_GET_PRIVATE(ndisc)->rdata; - NMNDiscAddress * arr; + NMNDiscAddress *arr; guint i; guint j; @@ -1425,7 +1425,7 @@ static void clean_routes(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint64 *next_msec) { NMNDiscDataInternal *rdata = &NM_NDISC_GET_PRIVATE(ndisc)->rdata; - NMNDiscRoute * arr; + NMNDiscRoute *arr; guint i; guint j; @@ -1455,7 +1455,7 @@ static void clean_dns_servers(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint64 *next_msec) { NMNDiscDataInternal *rdata = &NM_NDISC_GET_PRIVATE(ndisc)->rdata; - NMNDiscDNSServer * arr; + NMNDiscDNSServer *arr; guint i; guint j; @@ -1485,7 +1485,7 @@ static void clean_dns_domains(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint64 *next_msec) { NMNDiscDataInternal *rdata = &NM_NDISC_GET_PRIVATE(ndisc)->rdata; - NMNDiscDNSDomain * arr; + NMNDiscDNSDomain *arr; guint i; guint j; @@ -1592,7 +1592,7 @@ _calc_pre_expiry_rs_msec_worker(gint64 *earliest_expiry_msec, static gint64 calc_pre_expiry_rs_msec(NMNDisc *ndisc) { - NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(ndisc); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(ndisc); NMNDiscDataInternal *rdata = &priv->rdata; gint64 expiry_msec = NM_NDISC_EXPIRY_INFINITY; guint i; @@ -1700,10 +1700,10 @@ ipv6_sysctl_get(NMPlatform *platform, void nm_ndisc_get_sysctl(NMPlatform *platform, const char *ifname, - int * out_max_addresses, - int * out_router_solicitations, - int * out_router_solicitation_interval, - guint32 * out_default_ra_timeout) + int *out_max_addresses, + int *out_router_solicitations, + int *out_router_solicitation_interval, + guint32 *out_default_ra_timeout) { int router_solicitation_interval = 0; int router_solicitations = 0; @@ -1812,7 +1812,7 @@ dns_domain_free(gpointer data) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMNDisc * self = NM_NDISC(object); + NMNDisc *self = NM_NDISC(object); NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(self); switch (prop_id) { @@ -1833,7 +1833,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps static void nm_ndisc_init(NMNDisc *ndisc) { - NMNDiscPrivate * priv; + NMNDiscPrivate *priv; NMNDiscDataInternal *rdata; priv = G_TYPE_INSTANCE_GET_PRIVATE(ndisc, NM_TYPE_NDISC, NMNDiscPrivate); @@ -1853,7 +1853,7 @@ nm_ndisc_init(NMNDisc *ndisc) static void dispose(GObject *object) { - NMNDisc * ndisc = NM_NDISC(object); + NMNDisc *ndisc = NM_NDISC(object); NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(ndisc); nm_clear_g_source_inst(&priv->ra_timeout_source); @@ -1869,8 +1869,8 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMNDisc * ndisc = NM_NDISC(object); - NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(ndisc); + NMNDisc *ndisc = NM_NDISC(object); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(ndisc); NMNDiscDataInternal *rdata = &priv->rdata; g_array_unref(rdata->gateways); diff --git a/src/core/ndisc/nm-ndisc.h b/src/core/ndisc/nm-ndisc.h index dc6ab078bf..079ec0373e 100644 --- a/src/core/ndisc/nm-ndisc.h +++ b/src/core/ndisc/nm-ndisc.h @@ -123,7 +123,7 @@ typedef struct { } NMNDiscDNSServer; typedef struct { - char * domain; + char *domain; gint64 expiry_msec; } NMNDiscDNSDomain; @@ -160,9 +160,9 @@ typedef enum { #define NM_NDISC_ROUTER_LIFETIME 900 /* 1.5 * NM_NDISC_ROUTER_ADVERT_MAX_INTERVAL */ typedef struct { - NML3Cfg * l3cfg; - const char * ifname; - const char * network_id; + NML3Cfg *l3cfg; + const char *ifname; + const char *network_id; int max_addresses; int router_solicitations; int router_solicitation_interval; @@ -189,9 +189,9 @@ typedef struct { guint dns_servers_n; guint dns_domains_n; - const NMNDiscGateway * gateways; - const NMNDiscAddress * addresses; - const NMNDiscRoute * routes; + const NMNDiscGateway *gateways; + const NMNDiscAddress *addresses; + const NMNDiscRoute *routes; const NMNDiscDNSServer *dns_servers; const NMNDiscDNSDomain *dns_domains; } NMNDiscData; @@ -205,7 +205,7 @@ typedef struct { typedef struct { GObject parent; union { - struct _NMNDiscPrivate * _priv; + struct _NMNDiscPrivate *_priv; struct _NMNDiscDataInternal *rdata; }; } NMNDisc; @@ -222,7 +222,7 @@ typedef struct { GType nm_ndisc_get_type(void); int nm_ndisc_get_ifindex(NMNDisc *self); -const char * nm_ndisc_get_ifname(NMNDisc *self); +const char *nm_ndisc_get_ifname(NMNDisc *self); NMNDiscNodeType nm_ndisc_get_node_type(NMNDisc *self); gboolean nm_ndisc_set_iid(NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid, gboolean is_token); @@ -233,7 +233,7 @@ nm_ndisc_dad_failed(NMNDisc *ndisc, const struct in6_addr *address, gboolean emi void nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd); NMPlatform *nm_ndisc_get_platform(NMNDisc *self); -NMPNetns * nm_ndisc_netns_get(NMNDisc *self); +NMPNetns *nm_ndisc_netns_get(NMNDisc *self); gboolean nm_ndisc_netns_push(NMNDisc *self, NMPNetns **netns); static inline gboolean @@ -267,19 +267,19 @@ nm_ndisc_dad_addr_is_fail_candidate(NMPlatform *platform, const NMPObject *obj) void nm_ndisc_get_sysctl(NMPlatform *platform, const char *ifname, - int * out_max_addresses, - int * out_router_solicitations, - int * out_router_solicitation_interval, - guint32 * out_default_ra_timeout); + int *out_max_addresses, + int *out_router_solicitations, + int *out_router_solicitation_interval, + guint32 *out_default_ra_timeout); /*****************************************************************************/ struct _NML3ConfigData; -struct _NML3ConfigData *nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, +struct _NML3ConfigData *nm_ndisc_data_to_l3cd(NMDedupMultiIndex *multi_idx, int ifindex, - const NMNDiscData * rdata, + const NMNDiscData *rdata, NMSettingIP6ConfigPrivacy ip6_privacy, - NMUtilsIPv6IfaceId * token); + NMUtilsIPv6IfaceId *token); #endif /* __NETWORKMANAGER_NDISC_H__ */ diff --git a/src/core/ndisc/tests/test-ndisc-fake.c b/src/core/ndisc/tests/test-ndisc-fake.c index e98e158c1c..0763b64e6b 100644 --- a/src/core/ndisc/tests/test-ndisc-fake.c +++ b/src/core/ndisc/tests/test-ndisc-fake.c @@ -21,7 +21,7 @@ static NMFakeNDisc * ndisc_new(void) { gs_unref_object NML3Cfg *l3cfg = NULL; - NMNDisc * ndisc; + NMNDisc *ndisc; const int ifindex = 1; NMUtilsIPv6IfaceId iid; @@ -42,7 +42,7 @@ ndisc_new(void) static void match_gateway(const NMNDiscData *rdata, guint idx, - const char * addr, + const char *addr, gint64 expiry_msec, NMIcmpv6RouterPref pref) { @@ -62,7 +62,7 @@ match_gateway(const NMNDiscData *rdata, #define match_address(rdata, idx, addr, _expiry_msec, _expiry_preferred_msec) \ G_STMT_START \ { \ - const NMNDiscData * _rdata = (rdata); \ + const NMNDiscData *_rdata = (rdata); \ guint _idx = (idx); \ const NMNDiscAddress *_a; \ \ @@ -81,7 +81,7 @@ match_gateway(const NMNDiscData *rdata, #define match_route(rdata, idx, nw, pl, gw, _expiry_msec, pref) \ G_STMT_START \ { \ - const NMNDiscData * _rdata = (rdata); \ + const NMNDiscData *_rdata = (rdata); \ guint _idx = (idx); \ const NMNDiscRoute *_r; \ int _plen = (pl); \ @@ -145,11 +145,11 @@ typedef struct { /*****************************************************************************/ static void -test_simple_changed(NMNDisc * ndisc, - const NMNDiscData * rdata, +test_simple_changed(NMNDisc *ndisc, + const NMNDiscData *rdata, guint changed_i, const NML3ConfigData *l3cd, - TestData * data) + TestData *data) { NMNDiscConfigMap changed = changed_i; @@ -191,12 +191,12 @@ test_simple_changed(NMNDisc * ndisc, static void test_simple(void) { - nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); - gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); - const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); - TestData data = { - .loop = loop, - .timestamp_msec_1 = now_msec, + nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); + gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); + const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); + TestData data = { + .loop = loop, + .timestamp_msec_1 = now_msec, }; guint id; @@ -234,11 +234,11 @@ test_everything_rs_sent(NMNDisc *ndisc, TestData *data) } static void -test_everything_changed(NMNDisc * ndisc, - const NMNDiscData * rdata, +test_everything_changed(NMNDisc *ndisc, + const NMNDiscData *rdata, guint changed_i, const NML3ConfigData *l3cd, - TestData * data) + TestData *data) { NMNDiscConfigMap changed = changed_i; @@ -305,12 +305,12 @@ test_everything_changed(NMNDisc * ndisc, static void test_everything(void) { - nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); - gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); - const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); - TestData data = { - .loop = loop, - .timestamp_msec_1 = now_msec, + nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); + gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); + const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); + TestData data = { + .loop = loop, + .timestamp_msec_1 = now_msec, }; guint id; @@ -359,11 +359,11 @@ test_everything(void) } static void -test_preference_order_cb(NMNDisc * ndisc, - const NMNDiscData * rdata, +test_preference_order_cb(NMNDisc *ndisc, + const NMNDiscData *rdata, guint changed_i, const NML3ConfigData *l3cd, - TestData * data) + TestData *data) { NMNDiscConfigMap changed = changed_i; @@ -409,12 +409,12 @@ test_preference_order_cb(NMNDisc * ndisc, static void test_preference_order(void) { - nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); - gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); - const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); - TestData data = { - .loop = loop, - .timestamp_msec_1 = now_msec, + nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); + gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); + const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); + TestData data = { + .loop = loop, + .timestamp_msec_1 = now_msec, }; guint id; @@ -452,11 +452,11 @@ test_preference_order(void) } static void -test_preference_changed_cb(NMNDisc * ndisc, - const NMNDiscData * rdata, +test_preference_changed_cb(NMNDisc *ndisc, + const NMNDiscData *rdata, guint changed_i, const NML3ConfigData *l3cd, - TestData * data) + TestData *data) { NMNDiscConfigMap changed = changed_i; @@ -532,12 +532,12 @@ test_preference_changed_cb(NMNDisc * ndisc, static void test_preference_changed(void) { - nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); - gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); - const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); - TestData data = { - .loop = loop, - .timestamp_msec_1 = now_msec, + nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); + gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); + const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); + TestData data = { + .loop = loop, + .timestamp_msec_1 = now_msec, }; guint id; @@ -595,11 +595,11 @@ test_preference_changed(void) /*****************************************************************************/ static void -_test_dns_solicit_loop_changed(NMNDisc * ndisc, - const NMNDiscData * rdata, +_test_dns_solicit_loop_changed(NMNDisc *ndisc, + const NMNDiscData *rdata, guint changed_i, const NML3ConfigData *l3cd, - TestData * data) + TestData *data) { data->counter++; } @@ -613,12 +613,12 @@ _test_dns_solicit_loop_rs_sent(NMFakeNDisc *ndisc, TestData *data) static void test_dns_solicit_loop(void) { - nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); - gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); - const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); - TestData data = { - .loop = loop, - .timestamp_msec_1 = now_msec, + nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(NULL, FALSE); + gs_unref_object NMFakeNDisc *ndisc = ndisc_new(); + const gint64 now_msec = nm_utils_get_monotonic_timestamp_msec(); + TestData data = { + .loop = loop, + .timestamp_msec_1 = now_msec, }; guint id; diff --git a/src/core/ndisc/tests/test-ndisc-linux.c b/src/core/ndisc/tests/test-ndisc-linux.c index 4c2848088d..66c7e15770 100644 --- a/src/core/ndisc/tests/test-ndisc-linux.c +++ b/src/core/ndisc/tests/test-ndisc-linux.c @@ -23,12 +23,12 @@ main(int argc, char **argv) { gs_unref_object NML3Cfg *l3cfg = NULL; NMNDiscConfig config; - GMainLoop * loop; - NMNDisc * ndisc; + GMainLoop *loop; + NMNDisc *ndisc; int ifindex = 1; - const char * ifname; + const char *ifname; NMUtilsIPv6IfaceId iid = {}; - GError * error = NULL; + GError *error = NULL; int max_addresses; int router_solicitations; int router_solicitation_interval; diff --git a/src/core/nm-act-request.c b/src/core/nm-act-request.c index 58dd4a87f8..55d1829e7a 100644 --- a/src/core/nm-act-request.c +++ b/src/core/nm-act-request.c @@ -72,7 +72,7 @@ nm_act_request_get_applied_connection(NMActRequest *req) struct _NMActRequestGetSecretsCallId { CList call_ids_lst; - NMActRequest * self; + NMActRequest *self; NMActRequestSecretsFunc callback; gpointer callback_data; NMSettingsConnectionCallId *call_id; @@ -91,15 +91,15 @@ _get_secrets_call_id_free(NMActRequestGetSecretsCallId *call_id) } static void -get_secrets_cb(NMSettingsConnection * connection, +get_secrets_cb(NMSettingsConnection *connection, NMSettingsConnectionCallId *call_id_s, - const char * agent_username, - const char * setting_name, - GError * error, + const char *agent_username, + const char *setting_name, + GError *error, gpointer user_data) { NMActRequestGetSecretsCallId *call_id = user_data; - NMActRequestPrivate * priv; + NMActRequestPrivate *priv; g_return_if_fail(call_id && call_id->call_id == call_id_s); g_return_if_fail(NM_IS_ACT_REQUEST(call_id->self)); @@ -141,19 +141,19 @@ get_secrets_cb(NMSettingsConnection * connection, * Returns: a call-id. */ NMActRequestGetSecretsCallId * -nm_act_request_get_secrets(NMActRequest * self, +nm_act_request_get_secrets(NMActRequest *self, gboolean ref_self, - const char * setting_name, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char *const * hints, + const char *const *hints, NMActRequestSecretsFunc callback, gpointer callback_data) { - NMActRequestPrivate * priv; + NMActRequestPrivate *priv; NMActRequestGetSecretsCallId *call_id; - NMSettingsConnectionCallId * call_id_s; - NMSettingsConnection * settings_connection; - NMConnection * applied_connection; + NMSettingsConnectionCallId *call_id_s; + NMSettingsConnection *settings_connection; + NMConnection *applied_connection; g_return_val_if_fail(NM_IS_ACT_REQUEST(self), NULL); @@ -257,7 +257,7 @@ device_notify(GObject *object, GParamSpec *pspec, gpointer self) static void device_state_changed(NMActiveConnection *active, - NMDevice * device, + NMDevice *device, NMDeviceState new_state, NMDeviceState old_state) { @@ -344,7 +344,7 @@ device_state_changed(NMActiveConnection *active, static void master_failed(NMActiveConnection *self) { - NMDevice * device; + NMDevice *device; NMDeviceState device_state; /* If the connection has an active device, fail it */ @@ -371,8 +371,8 @@ static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMActiveConnection *active; - NMDevice * device; - char * name; + NMDevice *device; + char *name; switch (prop_id) { case PROP_IP4_CONFIG: @@ -432,14 +432,14 @@ nm_act_request_init(NMActRequest *req) * Returns: the new activation request on success, %NULL on error. */ NMActRequest * -nm_act_request_new(NMSettingsConnection * settings_connection, - NMConnection * applied_connection, - const char * specific_object, - NMAuthSubject * subject, +nm_act_request_new(NMSettingsConnection *settings_connection, + NMConnection *applied_connection, + const char *specific_object, + NMAuthSubject *subject, NMActivationType activation_type, NMActivationReason activation_reason, NMActivationStateFlags initial_state_flags, - NMDevice * device) + NMDevice *device) { g_return_val_if_fail(!settings_connection || NM_IS_SETTINGS_CONNECTION(settings_connection), NULL); @@ -469,8 +469,8 @@ nm_act_request_new(NMSettingsConnection * settings_connection, static void dispose(GObject *object) { - NMActRequest * self = NM_ACT_REQUEST(object); - NMActRequestPrivate * priv = NM_ACT_REQUEST_GET_PRIVATE(self); + NMActRequest *self = NM_ACT_REQUEST(object); + NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE(self); NMActRequestGetSecretsCallId *call_id, *call_id_safe; /* Kill any in-progress secrets requests */ @@ -483,7 +483,7 @@ dispose(GObject *object) static void nm_act_request_class_init(NMActRequestClass *req_class) { - GObjectClass * object_class = G_OBJECT_CLASS(req_class); + GObjectClass *object_class = G_OBJECT_CLASS(req_class); NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS(req_class); /* virtual methods */ diff --git a/src/core/nm-act-request.h b/src/core/nm-act-request.h index 698a9985a4..9075d5b762 100644 --- a/src/core/nm-act-request.h +++ b/src/core/nm-act-request.h @@ -23,14 +23,14 @@ typedef struct _NMActRequestGetSecretsCallId NMActRequestGetSecretsCallId; GType nm_act_request_get_type(void); -NMActRequest *nm_act_request_new(NMSettingsConnection * settings_connection, - NMConnection * applied_connection, - const char * specific_object, - NMAuthSubject * subject, +NMActRequest *nm_act_request_new(NMSettingsConnection *settings_connection, + NMConnection *applied_connection, + const char *specific_object, + NMAuthSubject *subject, NMActivationType activation_type, NMActivationReason activation_reason, NMActivationStateFlags initial_state_flags, - NMDevice * device); + NMDevice *device); NMSettingsConnection *nm_act_request_get_settings_connection(NMActRequest *req); @@ -40,17 +40,17 @@ NMConnection *nm_act_request_get_applied_connection(NMActRequest *req); /* Secrets handling */ -typedef void (*NMActRequestSecretsFunc)(NMActRequest * req, +typedef void (*NMActRequestSecretsFunc)(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * connection, - GError * error, + NMSettingsConnection *connection, + GError *error, gpointer user_data); -NMActRequestGetSecretsCallId *nm_act_request_get_secrets(NMActRequest * req, +NMActRequestGetSecretsCallId *nm_act_request_get_secrets(NMActRequest *req, gboolean take_ref, - const char * setting_name, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char *const * hints, + const char *const *hints, NMActRequestSecretsFunc callback, gpointer callback_data); diff --git a/src/core/nm-active-connection.c b/src/core/nm-active-connection.c index 4cd6d4889e..49568f7c7a 100644 --- a/src/core/nm-active-connection.c +++ b/src/core/nm-active-connection.c @@ -23,9 +23,9 @@ typedef struct _NMActiveConnectionPrivate { NMDBusTrackObjPath settings_connection; - NMConnection * applied_connection; - char * specific_object; - NMDevice * device; + NMConnection *applied_connection; + char *specific_object; + NMDevice *device; guint64 version_id; @@ -48,7 +48,7 @@ typedef struct _NMActiveConnectionPrivate { * reason never changes. */ NMActivationReason activation_reason : 4; - NMAuthSubject * subject; + NMAuthSubject *subject; NMActiveConnection *master; NMActiveConnection *parent; @@ -107,7 +107,7 @@ static const GDBusSignalInfo signal_info_state_changed; static void check_master_ready(NMActiveConnection *self); static void _device_cleanup(NMActiveConnection *self); static void _settings_connection_flags_changed(NMSettingsConnection *settings_connection, - NMActiveConnection * self); + NMActiveConnection *self); static void _set_activation_type_managed(NMActiveConnection *self); static void auth_complete(NMActiveConnection *self, gboolean result, const char *message); @@ -239,7 +239,7 @@ emit_state_changed(NMActiveConnection *self, guint state, guint reason) } void -nm_active_connection_set_state(NMActiveConnection * self, +nm_active_connection_set_state(NMActiveConnection *self, NMActiveConnectionState new_state, NMActiveConnectionStateReason reason) { @@ -314,9 +314,9 @@ nm_active_connection_set_state(NMActiveConnection * self, } void -nm_active_connection_set_state_fail(NMActiveConnection * self, +nm_active_connection_set_state_fail(NMActiveConnection *self, NMActiveConnectionStateReason reason, - const char * error_desc) + const char *error_desc) { NMActiveConnectionState s; @@ -350,7 +350,7 @@ nm_active_connection_get_state_flags(NMActiveConnection *self) } void -nm_active_connection_set_state_flags_full(NMActiveConnection * self, +nm_active_connection_set_state_flags_full(NMActiveConnection *self, NMActivationStateFlags state_flags, NMActivationStateFlags mask) { @@ -432,7 +432,7 @@ static void _set_applied_connection_take(NMActiveConnection *self, NMConnection *applied_connection) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); - NMSettingConnection * s_con; + NMSettingConnection *s_con; NMActivationStateFlags flags_val = 0; nm_assert(NM_IS_CONNECTION(applied_connection)); @@ -458,7 +458,7 @@ _set_applied_connection_take(NMActiveConnection *self, NMConnection *applied_con } void -nm_active_connection_set_settings_connection(NMActiveConnection * self, +nm_active_connection_set_settings_connection(NMActiveConnection *self, NMSettingsConnection *sett_conn) { NMActiveConnectionPrivate *priv; @@ -489,7 +489,7 @@ nm_active_connection_set_settings_connection(NMActiveConnection * self, } gboolean -nm_active_connection_has_unmodified_applied_connection(NMActiveConnection * self, +nm_active_connection_has_unmodified_applied_connection(NMActiveConnection *self, NMSettingCompareFlags compare_flags) { NMActiveConnectionPrivate *priv; @@ -615,13 +615,13 @@ nm_active_connection_get_device(NMActiveConnection *self) } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, gpointer user_data) { - NMActiveConnection * self = NM_ACTIVE_CONNECTION(user_data); + NMActiveConnection *self = NM_ACTIVE_CONNECTION(user_data); NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); /* When already deactivated or before activation, device state changes are useless */ @@ -641,9 +641,9 @@ device_state_changed(NMDevice * device, static void device_master_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NMDevice * device = NM_DEVICE(object); - NMActiveConnection * self = NM_ACTIVE_CONNECTION(user_data); - NMActiveConnection * master; + NMDevice *device = NM_DEVICE(object); + NMActiveConnection *self = NM_ACTIVE_CONNECTION(user_data); + NMActiveConnection *master; NMActiveConnectionState master_state; if (NM_ACTIVE_CONNECTION(nm_device_get_act_request(device)) != self) @@ -667,7 +667,7 @@ static void device_metered_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { NMActiveConnection *self = (NMActiveConnection *) user_data; - NMDevice * device = NM_DEVICE(object); + NMDevice *device = NM_DEVICE(object); g_return_if_fail(NM_IS_ACTIVE_CONNECTION(self)); g_signal_emit(self, signals[DEVICE_METERED_CHANGED], 0, nm_device_get_metered(device)); @@ -677,8 +677,8 @@ gboolean nm_active_connection_set_device(NMActiveConnection *self, NMDevice *device) { NMActiveConnectionPrivate *priv; - gs_unref_object NMDevice *old_device = NULL; - NMMetered old_metered, new_metered; + gs_unref_object NMDevice *old_device = NULL; + NMMetered old_metered, new_metered; g_return_val_if_fail(NM_IS_ACTIVE_CONNECTION(self), FALSE); g_return_val_if_fail(!device || NM_IS_DEVICE(device), FALSE); @@ -810,7 +810,7 @@ check_master_ready(NMActiveConnection *self) static void master_state_cb(NMActiveConnection *master, GParamSpec *pspec, gpointer user_data) { - NMActiveConnection * self = NM_ACTIVE_CONNECTION(user_data); + NMActiveConnection *self = NM_ACTIVE_CONNECTION(user_data); NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); NMActiveConnectionState master_state = nm_active_connection_get_state(master); @@ -961,7 +961,7 @@ nm_active_connection_get_keep_alive(NMActiveConnection *self) static void _settings_connection_flags_changed(NMSettingsConnection *settings_connection, - NMActiveConnection * self) + NMActiveConnection *self) { NMDevice *device; @@ -1008,7 +1008,7 @@ parent_destroyed(gpointer user_data, GObject *parent) static void parent_state_cb(NMActiveConnection *parent_ac, GParamSpec *pspec, gpointer user_data) { - NMActiveConnection * self = user_data; + NMActiveConnection *self = user_data; NMActiveConnectionState parent_state = nm_active_connection_get_state(parent_ac); if (parent_state < NM_ACTIVE_CONNECTION_STATE_ACTIVATED) @@ -1059,7 +1059,7 @@ nm_active_connection_set_parent(NMActiveConnection *self, NMActiveConnection *pa static void auth_complete(NMActiveConnection *self, gboolean result, const char *message) { - NMActiveConnectionPrivate * priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); NMActiveConnectionAuthResultFunc result_func; gpointer user_data; @@ -1092,15 +1092,15 @@ auth_complete_keep_alive(NMActiveConnection *self, gboolean result, const char * } static void -auth_done(NMAuthManager * auth_mgr, +auth_done(NMAuthManager *auth_mgr, NMAuthManagerCallId *auth_call_id, gboolean is_authorized, gboolean is_challenge, - GError * error, + GError *error, gpointer user_data) { - NMActiveConnection * self = NM_ACTIVE_CONNECTION(user_data); + NMActiveConnection *self = NM_ACTIVE_CONNECTION(user_data); NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); NMAuthCallResult result; @@ -1163,14 +1163,14 @@ auth_done(NMAuthManager * auth_mgr, * activation request. */ void -nm_active_connection_authorize(NMActiveConnection * self, - NMConnection * initial_connection, +nm_active_connection_authorize(NMActiveConnection *self, + NMConnection *initial_connection, NMActiveConnectionAuthResultFunc result_func, gpointer user_data) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); - const char * wifi_permission = NULL; - NMConnection * connection; + const char *wifi_permission = NULL; + NMConnection *connection; g_return_if_fail(result_func); g_return_if_fail(!priv->auth.call_id_network_control); @@ -1270,10 +1270,10 @@ _device_cleanup(NMActiveConnection *self) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMActiveConnection * self = NM_ACTIVE_CONNECTION(object); + NMActiveConnection *self = NM_ACTIVE_CONNECTION(object); NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); - char ** strv; - NMDevice * master_device = NULL; + char **strv; + NMDevice *master_device = NULL; switch (prop_id) { /* note that while priv->settings_connection.obj might not be set initially, @@ -1363,11 +1363,11 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMActiveConnection * self = (NMActiveConnection *) object; + NMActiveConnection *self = (NMActiveConnection *) object; NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); - const char * tmp; - NMSettingsConnection * sett_conn; - NMConnection * acon; + const char *tmp; + NMSettingsConnection *sett_conn; + NMConnection *acon; int i; switch (prop_id) { @@ -1477,7 +1477,7 @@ nm_active_connection_init(NMActiveConnection *self) static void constructed(GObject *object) { - NMActiveConnection * self = (NMActiveConnection *) object; + NMActiveConnection *self = (NMActiveConnection *) object; NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); G_OBJECT_CLASS(nm_active_connection_parent_class)->constructed(object); @@ -1512,7 +1512,7 @@ constructed(GObject *object) static void dispose(GObject *object) { - NMActiveConnection * self = NM_ACTIVE_CONNECTION(object); + NMActiveConnection *self = NM_ACTIVE_CONNECTION(object); NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); nm_assert(!c_list_is_linked(&self->active_connections_lst)); @@ -1544,7 +1544,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMActiveConnection * self = NM_ACTIVE_CONNECTION(object); + NMActiveConnection *self = NM_ACTIVE_CONNECTION(object); NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); nm_dbus_track_obj_path_set(&priv->settings_connection, NULL, FALSE); @@ -1609,7 +1609,7 @@ static const NMDBusInterfaceInfoExtended interface_info_active_connection = { static void nm_active_connection_class_init(NMActiveConnectionClass *ac_class) { - GObjectClass * object_class = G_OBJECT_CLASS(ac_class); + GObjectClass *object_class = G_OBJECT_CLASS(ac_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(ac_class); g_type_class_add_private(ac_class, sizeof(NMActiveConnectionPrivate)); diff --git a/src/core/nm-active-connection.h b/src/core/nm-active-connection.h index 1c2c8116ba..28d4246eab 100644 --- a/src/core/nm-active-connection.h +++ b/src/core/nm-active-connection.h @@ -75,14 +75,14 @@ typedef struct { * device states >= DISCONNECTED. */ void (*device_state_changed)(NMActiveConnection *connection, - NMDevice * device, + NMDevice *device, NMDeviceState new_state, NMDeviceState old_state); void (*master_failed)(NMActiveConnection *connection); void (*device_changed)(NMActiveConnection *connection, - NMDevice * new_device, - NMDevice * old_device); + NMDevice *new_device, + NMDevice *old_device); void (*device_metered_changed)(NMActiveConnection *connection, NMMetered new_value); @@ -96,24 +96,24 @@ GType nm_active_connection_get_type(void); typedef void (*NMActiveConnectionAuthResultFunc)(NMActiveConnection *self, gboolean success, - const char * error_desc, + const char *error_desc, gpointer user_data); -void nm_active_connection_authorize(NMActiveConnection * self, - NMConnection * initial_connection, +void nm_active_connection_authorize(NMActiveConnection *self, + NMConnection *initial_connection, NMActiveConnectionAuthResultFunc result_func, gpointer user_data); NMSettingsConnection *nm_active_connection_get_settings_connection(NMActiveConnection *self); -NMConnection * nm_active_connection_get_applied_connection(NMActiveConnection *self); +NMConnection *nm_active_connection_get_applied_connection(NMActiveConnection *self); NMSettingsConnection *_nm_active_connection_get_settings_connection(NMActiveConnection *self); -void nm_active_connection_set_settings_connection(NMActiveConnection * self, +void nm_active_connection_set_settings_connection(NMActiveConnection *self, NMSettingsConnection *connection); gboolean -nm_active_connection_has_unmodified_applied_connection(NMActiveConnection * self, +nm_active_connection_has_unmodified_applied_connection(NMActiveConnection *self, NMSettingCompareFlags compare_flags); const char *nm_active_connection_get_settings_connection_id(NMActiveConnection *self); @@ -121,7 +121,7 @@ const char *nm_active_connection_get_settings_connection_id(NMActiveConnection * const char *nm_active_connection_get_specific_object(NMActiveConnection *self); void nm_active_connection_set_specific_object(NMActiveConnection *self, - const char * specific_object); + const char *specific_object); void nm_active_connection_set_default(NMActiveConnection *self, int addr_family, gboolean is_default); @@ -130,20 +130,20 @@ gboolean nm_active_connection_get_default(NMActiveConnection *self, int addr_fam NMActiveConnectionState nm_active_connection_get_state(NMActiveConnection *self); -void nm_active_connection_set_state(NMActiveConnection * self, +void nm_active_connection_set_state(NMActiveConnection *self, NMActiveConnectionState state, NMActiveConnectionStateReason reason); -void nm_active_connection_set_state_fail(NMActiveConnection * active, +void nm_active_connection_set_state_fail(NMActiveConnection *active, NMActiveConnectionStateReason reason, - const char * error_desc); + const char *error_desc); #define NM_ACTIVATION_STATE_FLAG_IP_READY_X(IS_IPv4) \ ((IS_IPv4) ? NM_ACTIVATION_STATE_FLAG_IP4_READY : NM_ACTIVATION_STATE_FLAG_IP6_READY) NMActivationStateFlags nm_active_connection_get_state_flags(NMActiveConnection *self); -void nm_active_connection_set_state_flags_full(NMActiveConnection * self, +void nm_active_connection_set_state_flags_full(NMActiveConnection *self, NMActivationStateFlags state_flags, NMActivationStateFlags mask); @@ -154,7 +154,7 @@ nm_active_connection_set_state_flags(NMActiveConnection *self, NMActivationState } static inline void -nm_active_connection_set_state_flags_clear(NMActiveConnection * self, +nm_active_connection_set_state_flags_clear(NMActiveConnection *self, NMActivationStateFlags state_flags) { nm_active_connection_set_state_flags_full(self, NM_ACTIVATION_STATE_FLAG_NONE, state_flags); diff --git a/src/core/nm-audit-manager.c b/src/core/nm-audit-manager.c index 477e17983a..dd96d834e5 100644 --- a/src/core/nm-audit-manager.c +++ b/src/core/nm-audit-manager.c @@ -30,7 +30,7 @@ typedef enum _nm_packed { } AuditBackend; typedef struct { - const char * name; + const char *name; AuditBackend backends; bool need_encoding; NMValueType value_type; @@ -84,9 +84,9 @@ NM_DEFINE_SINGLETON_GETTER(NMAuditManager, nm_audit_manager_get, NM_TYPE_AUDIT_M /*****************************************************************************/ static void -_audit_field_init_string(AuditField * field, - const char * name, - const char * str, +_audit_field_init_string(AuditField *field, + const char *name, + const char *str, gboolean need_encoding, AuditBackend backends) { @@ -165,10 +165,10 @@ build_message(NMStrBuf *strbuf, AuditBackend backend, GPtrArray *fields) static void nm_audit_log(NMAuditManager *self, - GPtrArray * fields, - const char * file, + GPtrArray *fields, + const char *file, guint line, - const char * func, + const char *func, gboolean success) { nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(0, FALSE); @@ -210,23 +210,23 @@ nm_audit_log(NMAuditManager *self, static void _audit_log_helper(NMAuditManager *self, - GPtrArray * fields, - const char * file, + GPtrArray *fields, + const char *file, guint line, - const char * func, - const char * op, + const char *func, + const char *op, gboolean result, gpointer subject_context, - const char * reason) + const char *reason) { - AuditField op_field; - AuditField pid_field; - AuditField uid_field; - AuditField result_field; - AuditField reason_field; - gulong pid; - gulong uid; - NMAuthSubject * subject = NULL; + AuditField op_field; + AuditField pid_field; + AuditField uid_field; + AuditField result_field; + AuditField reason_field; + gulong pid; + gulong uid; + NMAuthSubject *subject = NULL; gs_unref_object NMAuthSubject *subject_free = NULL; _audit_field_init_string(&op_field, "op", op, FALSE, BACKEND_ALL); @@ -284,16 +284,16 @@ nm_audit_manager_audit_enabled(NMAuditManager *self) } void -_nm_audit_manager_log_connection_op(NMAuditManager * self, - const char * file, +_nm_audit_manager_log_connection_op(NMAuditManager *self, + const char *file, guint line, - const char * func, - const char * op, + const char *func, + const char *op, NMSettingsConnection *connection, gboolean result, - const char * args, + const char *args, gpointer subject_context, - const char * reason) + const char *reason) { gs_unref_ptrarray GPtrArray *fields = NULL; AuditField uuid_field; @@ -330,14 +330,14 @@ _nm_audit_manager_log_connection_op(NMAuditManager * self, void _nm_audit_manager_log_generic_op(NMAuditManager *self, - const char * file, + const char *file, guint line, - const char * func, - const char * op, - const char * arg, + const char *func, + const char *op, + const char *arg, gboolean result, gpointer subject_context, - const char * reason) + const char *reason) { gs_unref_ptrarray GPtrArray *fields = NULL; AuditField arg_field; @@ -355,15 +355,15 @@ _nm_audit_manager_log_generic_op(NMAuditManager *self, void _nm_audit_manager_log_device_op(NMAuditManager *self, - const char * file, + const char *file, guint line, - const char * func, - const char * op, - NMDevice * device, + const char *func, + const char *op, + NMDevice *device, gboolean result, - const char * args, + const char *args, gpointer subject_context, - const char * reason) + const char *reason) { gs_unref_ptrarray GPtrArray *fields = NULL; AuditField interface_field; @@ -402,7 +402,7 @@ static void init_auditd(NMAuditManager *self) { NMAuditManagerPrivate *priv = NM_AUDIT_MANAGER_GET_PRIVATE(self); - NMConfigData * data = nm_config_get_data(priv->config); + NMConfigData *data = nm_config_get_data(priv->config); int errsv; if (nm_config_data_get_value_boolean(data, @@ -427,11 +427,11 @@ init_auditd(NMAuditManager *self) } static void -config_changed_cb(NMConfig * config, - NMConfigData * config_data, +config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, - NMAuditManager * self) + NMConfigData *old_data, + NMAuditManager *self) { if (NM_FLAGS_HAS(changes, NM_CONFIG_CHANGE_VALUES)) init_auditd(self); @@ -461,7 +461,7 @@ static void dispose(GObject *object) { #if HAVE_LIBAUDIT - NMAuditManager * self = NM_AUDIT_MANAGER(object); + NMAuditManager *self = NM_AUDIT_MANAGER(object); NMAuditManagerPrivate *priv = NM_AUDIT_MANAGER_GET_PRIVATE(self); if (priv->config) { diff --git a/src/core/nm-audit-manager.h b/src/core/nm-audit-manager.h index fdabbf2814..3a7ea7c032 100644 --- a/src/core/nm-audit-manager.h +++ b/src/core/nm-audit-manager.h @@ -133,36 +133,36 @@ gboolean nm_audit_manager_audit_enabled(NMAuditManager *self); } \ G_STMT_END -void _nm_audit_manager_log_connection_op(NMAuditManager * self, - const char * file, +void _nm_audit_manager_log_connection_op(NMAuditManager *self, + const char *file, guint line, - const char * func, - const char * op, + const char *func, + const char *op, NMSettingsConnection *connection, gboolean result, - const char * args, + const char *args, gpointer subject_context, - const char * reason); + const char *reason); void _nm_audit_manager_log_generic_op(NMAuditManager *self, - const char * file, + const char *file, guint line, - const char * func, - const char * op, - const char * arg, + const char *func, + const char *op, + const char *arg, gboolean result, gpointer subject_context, - const char * reason); + const char *reason); void _nm_audit_manager_log_device_op(NMAuditManager *self, - const char * file, + const char *file, guint line, - const char * func, - const char * op, - NMDevice * device, + const char *func, + const char *op, + NMDevice *device, gboolean result, - const char * args, + const char *args, gpointer subject_context, - const char * reason); + const char *reason); #endif /* __NM_AUDIT_MANAGER_H__ */ diff --git a/src/core/nm-auth-manager.c b/src/core/nm-auth-manager.c index 5c0e465aff..0f7e0c0dd8 100644 --- a/src/core/nm-auth-manager.c +++ b/src/core/nm-auth-manager.c @@ -35,8 +35,8 @@ static guint signals[LAST_SIGNAL] = {0}; typedef struct { CList calls_lst_head; GDBusConnection *dbus_connection; - GCancellable * main_cancellable; - char * name_owner; + GCancellable *main_cancellable; + char *name_owner; guint64 call_numid_counter; guint changed_id; guint name_owner_changed_id; @@ -138,8 +138,8 @@ typedef enum { struct _NMAuthManagerCallId { CList calls_lst; - NMAuthManager * self; - GCancellable * dbus_cancellable; + NMAuthManager *self; + GCancellable *dbus_cancellable; NMAuthManagerCheckAuthorizationCallback callback; gpointer user_data; guint64 call_numid; @@ -173,7 +173,7 @@ static void _call_id_invoke_callback(NMAuthManagerCallId *call_id, gboolean is_authorized, gboolean is_challenge, - GError * error) + GError *error) { c_list_unlink(&call_id->calls_lst); @@ -185,9 +185,9 @@ _call_id_invoke_callback(NMAuthManagerCallId *call_id, static void cancel_check_authorization_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMAuthManagerCallId *call_id = user_data; - gs_unref_variant GVariant *value = NULL; - gs_free_error GError *error = NULL; + NMAuthManagerCallId *call_id = user_data; + gs_unref_variant GVariant *value = NULL; + gs_free_error GError *error = NULL; value = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &error); if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -203,13 +203,13 @@ cancel_check_authorization_cb(GObject *source, GAsyncResult *res, gpointer user_ static void _call_check_authorize_cb(GObject *proxy, GAsyncResult *res, gpointer user_data) { - NMAuthManagerCallId * call_id = user_data; - NMAuthManager * self; - NMAuthManagerPrivate *priv; - gs_unref_variant GVariant *value = NULL; - gs_free_error GError *error = NULL; - gboolean is_authorized = FALSE; - gboolean is_challenge = FALSE; + NMAuthManagerCallId *call_id = user_data; + NMAuthManager *self; + NMAuthManagerPrivate *priv; + gs_unref_variant GVariant *value = NULL; + gs_free_error GError *error = NULL; + gboolean is_authorized = FALSE; + gboolean is_challenge = FALSE; /* we need to clear the cancelable, to signal for _call_id_free() that we * are not in a pending call. @@ -299,17 +299,17 @@ _call_on_idle(gpointer user_data) * which @self must be live long enough). */ NMAuthManagerCallId * -nm_auth_manager_check_authorization(NMAuthManager * self, - NMAuthSubject * subject, - const char * action_id, +nm_auth_manager_check_authorization(NMAuthManager *self, + NMAuthSubject *subject, + const char *action_id, gboolean allow_user_interaction, NMAuthManagerCheckAuthorizationCallback callback, gpointer user_data) { - NMAuthManagerPrivate * priv; + NMAuthManagerPrivate *priv; PolkitCheckAuthorizationFlags flags; char subject_buf[64]; - NMAuthManagerCallId * call_id; + NMAuthManagerCallId *call_id; g_return_val_if_fail(NM_IS_AUTH_MANAGER(self), NULL); g_return_val_if_fail(NM_IN_SET(nm_auth_subject_get_subject_type(subject), @@ -358,10 +358,10 @@ nm_auth_manager_check_authorization(NMAuthManager * self call_id->idle_is_authorized = (priv->auth_polkit_mode == NM_AUTH_POLKIT_MODE_ALLOW_ALL); call_id->idle_id = g_idle_add(_call_on_idle, call_id); } else { - GVariant * parameters; + GVariant *parameters; GVariantBuilder builder; - GVariant * subject_value; - GVariant * details_value; + GVariant *subject_value; + GVariant *details_value; subject_value = nm_auth_subject_unix_to_polkit_gvariant(subject); nm_assert(g_variant_is_floating(subject_value)); @@ -406,7 +406,7 @@ nm_auth_manager_check_authorization(NMAuthManager * self void nm_auth_manager_check_authorization_cancel(NMAuthManagerCallId *call_id) { - NMAuthManager *self; + NMAuthManager *self; gs_free_error GError *error = NULL; g_return_if_fail(call_id); @@ -428,14 +428,14 @@ nm_auth_manager_check_authorization_cancel(NMAuthManagerCallId *call_id) static void changed_signal_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMAuthManager * self = user_data; + NMAuthManager *self = user_data; NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE(self); gboolean valid_sender; @@ -454,7 +454,7 @@ _name_owner_changed(NMAuthManager *self, const char *name_owner, gboolean is_ini { NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE(self); gboolean is_changed; - gs_free char * old_name_owner = NULL; + gs_free char *old_name_owner = NULL; if (is_initial) priv->got_name_owner = TRUE; @@ -496,15 +496,15 @@ _name_owner_changed(NMAuthManager *self, const char *name_owner, gboolean is_ini static void _name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { NMAuthManager *self = user_data; - const char * new_owner; + const char *new_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) return; @@ -607,10 +607,10 @@ nm_auth_manager_init(NMAuthManager *self) static void constructed(GObject *object) { - NMAuthManager * self = NM_AUTH_MANAGER(object); + NMAuthManager *self = NM_AUTH_MANAGER(object); NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE(self); NMLogLevel logl = LOGL_DEBUG; - const char * create_message; + const char *create_message; G_OBJECT_CLASS(nm_auth_manager_parent_class)->constructed(object); @@ -697,7 +697,7 @@ nm_auth_manager_setup(NMAuthPolkitMode auth_polkit_mode) static void dispose(GObject *object) { - NMAuthManager * self = NM_AUTH_MANAGER(object); + NMAuthManager *self = NM_AUTH_MANAGER(object); NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE(self); _LOGD("dispose"); diff --git a/src/core/nm-auth-manager.h b/src/core/nm-auth-manager.h index 0586322fea..db6237d8c4 100644 --- a/src/core/nm-auth-manager.h +++ b/src/core/nm-auth-manager.h @@ -68,17 +68,17 @@ gboolean nm_auth_manager_get_polkit_enabled(NMAuthManager *self); typedef struct _NMAuthManagerCallId NMAuthManagerCallId; -typedef void (*NMAuthManagerCheckAuthorizationCallback)(NMAuthManager * self, +typedef void (*NMAuthManagerCheckAuthorizationCallback)(NMAuthManager *self, NMAuthManagerCallId *call_id, gboolean is_authorized, gboolean is_challenge, - GError * error, + GError *error, gpointer user_data); NMAuthManagerCallId * -nm_auth_manager_check_authorization(NMAuthManager * self, - NMAuthSubject * subject, - const char * action_id, +nm_auth_manager_check_authorization(NMAuthManager *self, + NMAuthSubject *subject, + const char *action_id, gboolean allow_user_interaction, NMAuthManagerCheckAuthorizationCallback callback, gpointer user_data); diff --git a/src/core/nm-auth-utils.c b/src/core/nm-auth-utils.c index da17b1a4cc..cef926fdf9 100644 --- a/src/core/nm-auth-utils.c +++ b/src/core/nm-auth-utils.c @@ -18,7 +18,7 @@ /*****************************************************************************/ typedef struct { - const char * tag; + const char *tag; gpointer data; GDestroyNotify destroy; } ChainData; @@ -33,7 +33,7 @@ struct _NMAuthChain { CList auth_call_lst_head; GDBusMethodInvocation *context; - NMAuthSubject * subject; + NMAuthSubject *subject; GCancellable *cancellable; @@ -56,9 +56,9 @@ G_STATIC_ASSERT(G_STRUCT_OFFSET(NMAuthChain, parent_lst) == 0); typedef struct { CList auth_call_lst; - NMAuthChain * chain; + NMAuthChain *chain; NMAuthManagerCallId *call_id; - const char * permission; + const char *permission; NMAuthCallResult result; } AuthCall; @@ -105,7 +105,7 @@ static gboolean _cancellable_idle_cb(gpointer user_data) { NMAuthChain *self = user_data; - AuthCall * call; + AuthCall *call; nm_assert(g_cancellable_is_cancelled(self->cancellable)); nm_assert(self->cancellable_idle_source); @@ -260,8 +260,8 @@ nm_auth_chain_steal_data(NMAuthChain *self, const char *tag) * It is a bug to add the same tag more than once. */ void -nm_auth_chain_set_data_unsafe(NMAuthChain * self, - const char * tag, +nm_auth_chain_set_data_unsafe(NMAuthChain *self, + const char *tag, gpointer data, GDestroyNotify data_destroy) { @@ -351,15 +351,15 @@ nm_auth_chain_get_context(NMAuthChain *self) /*****************************************************************************/ static void -pk_call_cb(NMAuthManager * auth_manager, +pk_call_cb(NMAuthManager *auth_manager, NMAuthManagerCallId *call_id, gboolean is_authorized, gboolean is_challenge, - GError * error, + GError *error, gpointer user_data) { NMAuthChain *self; - AuthCall * call; + AuthCall *call; nm_assert(call_id); @@ -490,7 +490,7 @@ nm_auth_chain_new_context(GDBusMethodInvocation *context, gpointer user_data) { NMAuthSubject *subject; - NMAuthChain * chain; + NMAuthChain *chain; g_return_val_if_fail(context, NULL); nm_assert(done_func); @@ -505,7 +505,7 @@ nm_auth_chain_new_context(GDBusMethodInvocation *context, } NMAuthChain * -nm_auth_chain_new_subject(NMAuthSubject * subject, +nm_auth_chain_new_subject(NMAuthSubject *subject, GDBusMethodInvocation *context, NMAuthChainResultFunc done_func, gpointer user_data) @@ -603,7 +603,7 @@ gboolean nm_auth_is_subject_in_acl(NMConnection *connection, NMAuthSubject *subject, char **out_error_desc) { NMSettingConnection *s_con; - gs_free char * user = NULL; + gs_free char *user = NULL; gulong uid; g_return_val_if_fail(connection, FALSE); @@ -647,11 +647,11 @@ nm_auth_is_subject_in_acl(NMConnection *connection, NMAuthSubject *subject, char } gboolean -nm_auth_is_subject_in_acl_set_error(NMConnection * connection, +nm_auth_is_subject_in_acl_set_error(NMConnection *connection, NMAuthSubject *subject, GQuark err_domain, int err_code, - GError ** error) + GError **error) { char *error_desc = NULL; @@ -666,12 +666,12 @@ nm_auth_is_subject_in_acl_set_error(NMConnection * connection, } gboolean -nm_auth_is_invocation_in_acl_set_error(NMConnection * connection, +nm_auth_is_invocation_in_acl_set_error(NMConnection *connection, GDBusMethodInvocation *invocation, GQuark err_domain, int err_code, - NMAuthSubject ** out_subject, - GError ** error) + NMAuthSubject **out_subject, + GError **error) { gs_unref_object NMAuthSubject *subject = NULL; gboolean success; diff --git a/src/core/nm-auth-utils.h b/src/core/nm-auth-utils.h index 999dacf579..cb65833cef 100644 --- a/src/core/nm-auth-utils.h +++ b/src/core/nm-auth-utils.h @@ -14,7 +14,7 @@ typedef struct _NMAuthChain NMAuthChain; -typedef void (*NMAuthChainResultFunc)(NMAuthChain * chain, +typedef void (*NMAuthChainResultFunc)(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data); @@ -22,7 +22,7 @@ NMAuthChain *nm_auth_chain_new_context(GDBusMethodInvocation *context, NMAuthChainResultFunc done_func, gpointer user_data); -NMAuthChain *nm_auth_chain_new_subject(NMAuthSubject * subject, +NMAuthChain *nm_auth_chain_new_subject(NMAuthSubject *subject, GDBusMethodInvocation *context, NMAuthChainResultFunc done_func, gpointer user_data); @@ -34,8 +34,8 @@ gpointer nm_auth_chain_get_data(NMAuthChain *chain, const char *tag); gpointer nm_auth_chain_steal_data(NMAuthChain *chain, const char *tag); -void nm_auth_chain_set_data_unsafe(NMAuthChain * chain, - const char * tag, +void nm_auth_chain_set_data_unsafe(NMAuthChain *chain, + const char *tag, gpointer data, GDestroyNotify data_destroy); @@ -45,7 +45,7 @@ void nm_auth_chain_set_data_unsafe(NMAuthChain * chain, NMAuthCallResult nm_auth_chain_get_result(NMAuthChain *chain, const char *permission); void nm_auth_chain_add_call_unsafe(NMAuthChain *chain, - const char * permission, + const char *permission, gboolean allow_interaction); #define nm_auth_chain_add_call(chain, permission, allow_interaction) \ @@ -79,17 +79,17 @@ nm_auth_chain_parent_lst_list(NMAuthChain *self) gboolean nm_auth_is_subject_in_acl(NMConnection *connection, NMAuthSubject *subject, char **out_error_desc); -gboolean nm_auth_is_subject_in_acl_set_error(NMConnection * connection, +gboolean nm_auth_is_subject_in_acl_set_error(NMConnection *connection, NMAuthSubject *subject, GQuark err_domain, int err_code, - GError ** error); + GError **error); -gboolean nm_auth_is_invocation_in_acl_set_error(NMConnection * connection, +gboolean nm_auth_is_invocation_in_acl_set_error(NMConnection *connection, GDBusMethodInvocation *invocation, GQuark err_domain, int err_code, - NMAuthSubject ** out_subject, - GError ** error); + NMAuthSubject **out_subject, + GError **error); #endif /* __NETWORKMANAGER_MANAGER_AUTH_H__ */ diff --git a/src/core/nm-checkpoint-manager.c b/src/core/nm-checkpoint-manager.c index b8c9101a6e..4a3e7aafba 100644 --- a/src/core/nm-checkpoint-manager.c +++ b/src/core/nm-checkpoint-manager.c @@ -18,7 +18,7 @@ /*****************************************************************************/ struct _NMCheckpointManager { - NMManager * _manager; + NMManager *_manager; GParamSpec *property_spec; CList checkpoints_lst_head; }; @@ -70,7 +70,7 @@ destroy_checkpoint(NMCheckpointManager *self, NMCheckpoint *checkpoint, gboolean static GVariant * rollback_checkpoint(NMCheckpointManager *self, NMCheckpoint *checkpoint) { - GVariant * result; + GVariant *result; const CList *iter; nm_assert(c_list_contains(&self->checkpoints_lst_head, &checkpoint->checkpoints_lst)); @@ -95,23 +95,23 @@ rollback_checkpoint(NMCheckpointManager *self, NMCheckpoint *checkpoint) static void rollback_timeout_cb(NMCheckpoint *checkpoint, gpointer user_data) { - NMCheckpointManager *self = user_data; + NMCheckpointManager *self = user_data; gs_unref_variant GVariant *result = NULL; result = rollback_checkpoint(self, checkpoint); } NMCheckpoint * -nm_checkpoint_manager_create(NMCheckpointManager * self, - const char *const * device_paths, +nm_checkpoint_manager_create(NMCheckpointManager *self, + const char *const *device_paths, guint32 rollback_timeout, NMCheckpointCreateFlags flags, - GError ** error) + GError **error) { - NMManager * manager; - NMCheckpoint * checkpoint; + NMManager *manager; + NMCheckpoint *checkpoint; gs_unref_ptrarray GPtrArray *devices = NULL; - NMDevice * device; + NMDevice *device; g_return_val_if_fail(self, FALSE); g_return_val_if_fail(!error || !*error, FALSE); @@ -233,9 +233,9 @@ nm_checkpoint_manager_destroy(NMCheckpointManager *self, const char *path, GErro gboolean nm_checkpoint_manager_rollback(NMCheckpointManager *self, - const char * path, - GVariant ** results, - GError ** error) + const char *path, + GVariant **results, + GError **error) { NMCheckpoint *checkpoint; @@ -279,7 +279,7 @@ const char ** nm_checkpoint_manager_get_checkpoint_paths(NMCheckpointManager *self, guint *out_length) { NMCheckpoint *checkpoint; - const char ** strv; + const char **strv; guint num, i = 0; num = c_list_length(&self->checkpoints_lst_head); @@ -297,9 +297,9 @@ nm_checkpoint_manager_get_checkpoint_paths(NMCheckpointManager *self, guint *out gboolean nm_checkpoint_manager_adjust_rollback_timeout(NMCheckpointManager *self, - const char * path, + const char *path, guint32 add_timeout, - GError ** error) + GError **error) { NMCheckpoint *checkpoint; diff --git a/src/core/nm-checkpoint-manager.h b/src/core/nm-checkpoint-manager.h index 7fe86d6040..e4e29f4870 100644 --- a/src/core/nm-checkpoint-manager.h +++ b/src/core/nm-checkpoint-manager.h @@ -19,26 +19,26 @@ void nm_checkpoint_manager_free(NMCheckpointManager *self); NMCheckpoint * nm_checkpoint_manager_lookup_by_path(NMCheckpointManager *self, const char *path, GError **error); -NMCheckpoint *nm_checkpoint_manager_create(NMCheckpointManager * self, - const char *const * device_names, +NMCheckpoint *nm_checkpoint_manager_create(NMCheckpointManager *self, + const char *const *device_names, guint32 rollback_timeout, NMCheckpointCreateFlags flags, - GError ** error); + GError **error); void nm_checkpoint_manager_destroy_all(NMCheckpointManager *self); gboolean nm_checkpoint_manager_destroy(NMCheckpointManager *self, const char *path, GError **error); gboolean nm_checkpoint_manager_rollback(NMCheckpointManager *self, - const char * path, - GVariant ** results, - GError ** error); + const char *path, + GVariant **results, + GError **error); gboolean nm_checkpoint_manager_adjust_rollback_timeout(NMCheckpointManager *self, - const char * path, + const char *path, guint32 add_timeout, - GError ** error); + GError **error); const char **nm_checkpoint_manager_get_checkpoint_paths(NMCheckpointManager *self, - guint * out_length); + guint *out_length); #endif /* __NM_CHECKPOINT_MANAGER_H__ */ diff --git a/src/core/nm-checkpoint.c b/src/core/nm-checkpoint.c index 164f4a868b..0153af970d 100644 --- a/src/core/nm-checkpoint.c +++ b/src/core/nm-checkpoint.c @@ -22,12 +22,12 @@ /*****************************************************************************/ typedef struct { - char * original_dev_path; - char * original_dev_name; + char *original_dev_path; + char *original_dev_name; NMDeviceType dev_type; - NMDevice * device; - NMConnection * applied_connection; - NMConnection * settings_connection; + NMDevice *device; + NMConnection *applied_connection; + NMConnection *settings_connection; guint64 ac_version_id; NMDeviceState state; bool is_software : 1; @@ -43,14 +43,14 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMCheckpoint, PROP_DEVICES, PROP_CREATED, PROP_ROLL struct _NMCheckpointPrivate { /* properties */ GHashTable *devices; - GPtrArray * removed_devices; + GPtrArray *removed_devices; gint64 created_at_ms; guint32 rollback_timeout_s; guint timeout_id; /* private members */ - NMManager * manager; + NMManager *manager; NMCheckpointCreateFlags flags; - GHashTable * connection_uuids; + GHashTable *connection_uuids; gulong dev_removed_id; NMCheckpointTimeoutCallback timeout_cb; @@ -105,7 +105,7 @@ nm_checkpoint_log_destroy(NMCheckpoint *self) } void -nm_checkpoint_set_timeout_callback(NMCheckpoint * self, +nm_checkpoint_set_timeout_callback(NMCheckpoint *self, NMCheckpointTimeoutCallback callback, gpointer user_data) { @@ -137,7 +137,7 @@ nm_checkpoint_includes_devices_of(NMCheckpoint *self, NMCheckpoint *cp_for_devic NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(self); NMCheckpointPrivate *priv2 = NM_CHECKPOINT_GET_PRIVATE(cp_for_devices); GHashTableIter iter; - NMDevice * device; + NMDevice *device; g_hash_table_iter_init(&iter, priv2->devices); while (g_hash_table_iter_next(&iter, (gpointer *) &device, NULL)) { @@ -148,16 +148,16 @@ nm_checkpoint_includes_devices_of(NMCheckpoint *self, NMCheckpoint *cp_for_devic } static NMSettingsConnection * -find_settings_connection(NMCheckpoint * self, +find_settings_connection(NMCheckpoint *self, DeviceCheckpoint *dev_checkpoint, - gboolean * need_update, - gboolean * need_activation) + gboolean *need_update, + gboolean *need_activation) { - NMCheckpointPrivate * priv = NM_CHECKPOINT_GET_PRIVATE(self); - NMActiveConnection * active; + NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(self); + NMActiveConnection *active; NMSettingsConnection *sett_conn; - const char * uuid, *ac_uuid; - const CList * tmp_clist; + const char *uuid, *ac_uuid; + const CList *tmp_clist; *need_activation = FALSE; *need_update = FALSE; @@ -205,10 +205,10 @@ find_settings_connection(NMCheckpoint * self, static gboolean restore_and_activate_connection(NMCheckpoint *self, DeviceCheckpoint *dev_checkpoint) { - NMCheckpointPrivate * priv = NM_CHECKPOINT_GET_PRIVATE(self); - NMSettingsConnection *connection; - gs_unref_object NMAuthSubject * subject = NULL; - GError * local_error = NULL; + NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(self); + NMSettingsConnection *connection; + gs_unref_object NMAuthSubject *subject = NULL; + GError *local_error = NULL; gboolean need_update, need_activation; NMSettingsConnectionPersistMode persist_mode; NMSettingsConnectionIntFlags sett_flags; @@ -315,9 +315,9 @@ GVariant * nm_checkpoint_rollback(NMCheckpoint *self) { NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(self); - DeviceCheckpoint * dev_checkpoint; + DeviceCheckpoint *dev_checkpoint; GHashTableIter iter; - NMDevice * device; + NMDevice *device; GVariantBuilder builder; uint i; @@ -424,7 +424,7 @@ next_dev: } if (NM_FLAGS_HAS(priv->flags, NM_CHECKPOINT_CREATE_FLAG_DELETE_NEW_CONNECTIONS)) { - NMSettingsConnection *con; + NMSettingsConnection *con; gs_free NMSettingsConnection **list = NULL; g_return_val_if_fail(priv->connection_uuids, NULL); @@ -447,7 +447,7 @@ next_dev: } if (NM_FLAGS_HAS(priv->flags, NM_CHECKPOINT_CREATE_FLAG_DISCONNECT_NEW_DEVICES)) { - const CList * tmp_lst; + const CList *tmp_lst; NMDeviceState state; nm_manager_for_each_device (priv->manager, device, tmp_lst) { @@ -485,7 +485,7 @@ static void _move_dev_to_removed_devices(NMDevice *device, NMCheckpoint *checkpoint) { NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(checkpoint); - DeviceCheckpoint * dev_checkpoint; + DeviceCheckpoint *dev_checkpoint; g_return_if_fail(device); @@ -514,11 +514,11 @@ _dev_exported_changed(NMDBusObject *obj, NMCheckpoint *checkpoint) static DeviceCheckpoint * device_checkpoint_create(NMCheckpoint *checkpoint, NMDevice *device) { - DeviceCheckpoint * dev_checkpoint; - NMConnection * applied_connection; + DeviceCheckpoint *dev_checkpoint; + NMConnection *applied_connection; NMSettingsConnection *settings_connection; - const char * path; - NMActRequest * act_request; + const char *path; + NMActRequest *act_request; nm_assert(NM_IS_DEVICE(device)); nm_assert(nm_device_is_real(device)); @@ -567,7 +567,7 @@ device_checkpoint_create(NMCheckpoint *checkpoint, NMDevice *device) static gboolean _timeout_cb(gpointer user_data) { - NMCheckpoint * self = user_data; + NMCheckpoint *self = user_data; NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(self); priv->timeout_id = 0; @@ -619,7 +619,7 @@ nm_checkpoint_adjust_rollback_timeout(NMCheckpoint *self, guint32 add_timeout) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMCheckpoint * self = NM_CHECKPOINT(object); + NMCheckpoint *self = NM_CHECKPOINT(object); NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(self); switch (prop_id) { @@ -663,13 +663,13 @@ _device_removed(NMManager *manager, NMDevice *device, gpointer user_data) } NMCheckpoint * -nm_checkpoint_new(NMManager * manager, - GPtrArray * devices, +nm_checkpoint_new(NMManager *manager, + GPtrArray *devices, guint32 rollback_timeout_s, NMCheckpointCreateFlags flags) { - NMCheckpoint * self; - NMCheckpointPrivate * priv; + NMCheckpoint *self; + NMCheckpointPrivate *priv; NMSettingsConnection *const *con; gint64 rollback_timeout_ms; guint i; @@ -719,7 +719,7 @@ nm_checkpoint_new(NMManager * manager, static void dispose(GObject *object) { - NMCheckpoint * self = NM_CHECKPOINT(object); + NMCheckpoint *self = NM_CHECKPOINT(object); NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(self); nm_assert(c_list_is_empty(&self->checkpoints_lst)); @@ -750,7 +750,7 @@ static const NMDBusInterfaceInfoExtended interface_info_checkpoint = { static void nm_checkpoint_class_init(NMCheckpointClass *checkpoint_class) { - GObjectClass * object_class = G_OBJECT_CLASS(checkpoint_class); + GObjectClass *object_class = G_OBJECT_CLASS(checkpoint_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(checkpoint_class); g_type_class_add_private(object_class, sizeof(NMCheckpointPrivate)); diff --git a/src/core/nm-checkpoint.h b/src/core/nm-checkpoint.h index 28c936fae5..db33b6e7a5 100644 --- a/src/core/nm-checkpoint.h +++ b/src/core/nm-checkpoint.h @@ -34,8 +34,8 @@ typedef struct _NMCheckpointClass NMCheckpointClass; GType nm_checkpoint_get_type(void); -NMCheckpoint *nm_checkpoint_new(NMManager * manager, - GPtrArray * devices, +NMCheckpoint *nm_checkpoint_new(NMManager *manager, + GPtrArray *devices, guint32 rollback_timeout, NMCheckpointCreateFlags flags); @@ -43,7 +43,7 @@ typedef void (*NMCheckpointTimeoutCallback)(NMCheckpoint *self, gpointer user_da void nm_checkpoint_log_destroy(NMCheckpoint *self); -void nm_checkpoint_set_timeout_callback(NMCheckpoint * self, +void nm_checkpoint_set_timeout_callback(NMCheckpoint *self, NMCheckpointTimeoutCallback callback, gpointer user_data); diff --git a/src/core/nm-config-data.c b/src/core/nm-config-data.c index e86e993c17..2b9094cbe2 100644 --- a/src/core/nm-config-data.c +++ b/src/core/nm-config-data.c @@ -17,18 +17,18 @@ /*****************************************************************************/ typedef struct { - char * group_name; + char *group_name; gboolean stop_match; struct { /* have a separate boolean field @has, because a @spec with * value %NULL does not necessarily mean, that the property * "match-device" was unspecified. */ gboolean has; - GSList * spec; + GSList *spec; } match_device; union { struct { - GSList * allowed_connections; + GSList *allowed_connections; gboolean allowed_connections_has; } device; }; @@ -40,15 +40,15 @@ typedef struct { } MatchSectionInfo; struct _NMGlobalDnsDomain { - char * name; + char *name; char **servers; char **options; }; struct _NMGlobalDnsConfig { - char ** searches; - char ** options; - GHashTable * domains; + char **searches; + char **options; + GHashTable *domains; const char **domain_list; gboolean internal; }; @@ -83,8 +83,8 @@ typedef struct { struct { gboolean enabled; - char * uri; - char * response; + char *uri; + char *response; guint interval; } connectivity; @@ -92,7 +92,7 @@ typedef struct { struct { /* from /var/lib/NetworkManager/no-auto-default.state */ - char ** arr; + char **arr; GSList *specs; /* from main.no-auto-default setting in NetworkManager.conf. */ @@ -158,9 +158,9 @@ nm_config_data_has_group(const NMConfigData *self, const char *group) } char * -nm_config_data_get_value(const NMConfigData * self, - const char * group, - const char * key, +nm_config_data_get_value(const NMConfigData *self, + const char *group, + const char *key, NMConfigGetValueFlags flags) { g_return_val_if_fail(NM_IS_CONFIG_DATA(self), NULL); @@ -174,9 +174,9 @@ nm_config_data_get_value(const NMConfigData * self, } gboolean -nm_config_data_has_value(const NMConfigData * self, - const char * group, - const char * key, +nm_config_data_has_value(const NMConfigData *self, + const char *group, + const char *key, NMConfigGetValueFlags flags) { gs_free char *value = NULL; @@ -192,8 +192,8 @@ nm_config_data_has_value(const NMConfigData * self, int nm_config_data_get_value_boolean(const NMConfigData *self, - const char * group, - const char * key, + const char *group, + const char *key, int default_value) { char *str; @@ -217,8 +217,8 @@ nm_config_data_get_value_boolean(const NMConfigData *self, gint64 nm_config_data_get_value_int64(const NMConfigData *self, - const char * group, - const char * key, + const char *group, + const char *key, guint base, gint64 min, gint64 max, @@ -226,7 +226,7 @@ nm_config_data_get_value_int64(const NMConfigData *self, { int errsv; gint64 val; - char * str; + char *str; g_return_val_if_fail(NM_IS_CONFIG_DATA(self), fallback); g_return_val_if_fail(group && *group, fallback); @@ -248,9 +248,9 @@ nm_config_data_get_value_int64(const NMConfigData *self, char ** nm_config_data_get_plugins(const NMConfigData *self, gboolean allow_default) { - gs_free_error GError * error = NULL; + gs_free_error GError *error = NULL; const NMConfigDataPrivate *priv; - char ** list; + char **list; g_return_val_if_fail(self, NULL); @@ -406,7 +406,7 @@ GKeyFile * nm_config_data_clone_keyfile_intern(const NMConfigData *self) { const NMConfigDataPrivate *priv; - GKeyFile * keyfile; + GKeyFile *keyfile; g_return_val_if_fail(NM_IS_CONFIG_DATA(self), FALSE); @@ -461,7 +461,7 @@ static NMAuthPolkitMode _config_data_get_main_auth_polkit(const NMConfigData *self, gboolean *out_invalid_config) { NMAuthPolkitMode auth_polkit_mode; - gs_free char * str = NULL; + gs_free char *str = NULL; str = nm_config_data_get_value(self, NM_CONFIG_KEYFILE_GROUP_MAIN, @@ -560,7 +560,7 @@ _merge_keyfiles(GKeyFile *keyfile_user, GKeyFile *keyfile_intern) { gs_strfreev char **groups = NULL; guint g, k; - GKeyFile * keyfile; + GKeyFile *keyfile; gsize ngroups; keyfile = nm_config_create_keyfile(); @@ -577,7 +577,7 @@ _merge_keyfiles(GKeyFile *keyfile_user, GKeyFile *keyfile_intern) * have lowest priority last. */ _nm_config_sort_groups(groups, ngroups); for (g = 0; groups[g]; g++) { - const char * group = groups[g]; + const char *group = groups[g]; gs_strfreev char **keys = NULL; gboolean is_intern, is_atomic = FALSE; @@ -597,7 +597,7 @@ _merge_keyfiles(GKeyFile *keyfile_user, GKeyFile *keyfile_intern) } for (k = 0; keys[k]; k++) { - const char * key = keys[k]; + const char *key = keys[k]; gs_free char *value = NULL; if (is_atomic && nm_streq(key, NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS)) @@ -714,17 +714,17 @@ static const struct { }; void -nm_config_data_log(const NMConfigData * self, - const char * prefix, - const char * key_prefix, - const char * no_auto_default_file, +nm_config_data_log(const NMConfigData *self, + const char *prefix, + const char *key_prefix, + const char *no_auto_default_file, /* FILE* */ gpointer print_stream) { - const NMConfigDataPrivate *priv; - gs_strfreev char ** groups = NULL; - gsize ngroups; - guint g, k, i; - FILE * stream = print_stream; + const NMConfigDataPrivate *priv; + gs_strfreev char **groups = NULL; + gsize ngroups; + guint g, k, i; + FILE *stream = print_stream; gs_unref_ptrarray GPtrArray *groups_full = NULL; gboolean print_default = !!stream; @@ -792,7 +792,7 @@ nm_config_data_log(const NMConfigData * self, _LOG(stream, prefix, "config-data[%p]: %u groups", self, groups_full->len); for (g = 0; g < groups_full->len; g++) { - const char * group = groups_full->pdata[g]; + const char *group = groups_full->pdata[g]; gs_strfreev char **keys = NULL; gboolean is_atomic; @@ -818,7 +818,7 @@ nm_config_data_log(const NMConfigData * self, keys = g_key_file_get_keys(priv->keyfile, group, NULL, NULL); for (k = 0; keys && keys[k]; k++) { - const char * key = keys[k]; + const char *key = keys[k]; gs_free char *value = NULL; value = g_key_file_get_value(priv->keyfile, group, key, NULL); @@ -1086,11 +1086,11 @@ static NMGlobalDnsConfig * load_global_dns(GKeyFile *keyfile, gboolean internal) { NMGlobalDnsConfig *dns_config; - char * group, *domain_prefix; + char *group, *domain_prefix; gs_strfreev char **groups = NULL; int g, i, j, domain_prefix_len; gboolean default_found = FALSE; - char ** strv; + char **strv; group = internal ? NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS : NM_CONFIG_KEYFILE_GROUP_GLOBAL_DNS; @@ -1143,8 +1143,8 @@ load_global_dns(GKeyFile *keyfile, gboolean internal) groups = g_key_file_get_groups(keyfile, NULL); for (g = 0; groups[g]; g++) { - char * name; - char ** servers = NULL, **options = NULL; + char *name; + char **servers = NULL, **options = NULL; NMGlobalDnsDomain *domain; if (!g_str_has_prefix(groups[g], domain_prefix) || !groups[g][domain_prefix_len]) @@ -1279,8 +1279,8 @@ global_dns_domain_from_dbus(char *name, GVariant *variant) { NMGlobalDnsDomain *domain; GVariantIter iter; - char ** strv, *key; - GVariant * val; + char **strv, *key; + GVariant *val; int i, j; if (!g_variant_is_of_type(variant, G_VARIANT_TYPE("a{sv}"))) @@ -1332,9 +1332,9 @@ NMGlobalDnsConfig * nm_global_dns_config_from_dbus(const GValue *value, GError **error) { NMGlobalDnsConfig *dns_config; - GVariant * variant, *val; + GVariant *variant, *val; GVariantIter iter; - char ** strv, *key; + char **strv, *key; int i, j; if (!G_VALUE_HOLDS_VARIANT(value)) { @@ -1379,8 +1379,8 @@ nm_global_dns_config_from_dbus(const GValue *value, GError **error) && g_variant_is_of_type(val, G_VARIANT_TYPE("a{sv}"))) { NMGlobalDnsDomain *domain; GVariantIter domain_iter; - GVariant * v; - char * k; + GVariant *v; + char *k; g_variant_iter_init(&domain_iter, val); while (g_variant_iter_next(&domain_iter, "{&sv}", &k, &v)) { @@ -1453,12 +1453,12 @@ global_dns_equal(NMGlobalDnsConfig *old, NMGlobalDnsConfig *new) static const MatchSectionInfo * _match_section_infos_lookup(const MatchSectionInfo *match_section_infos, - GKeyFile * keyfile, - const char * property, - NMDevice * device, - const NMPlatformLink * pllink, - const char * match_device_type, - const char ** out_value) + GKeyFile *keyfile, + const char *property, + NMDevice *device, + const NMPlatformLink *pllink, + const char *match_device_type, + const char **out_value) { const char *match_dhcp_plugin; @@ -1509,13 +1509,13 @@ out: const char * nm_config_data_get_device_config(const NMConfigData *self, - const char * property, - NMDevice * device, - gboolean * has_match) + const char *property, + NMDevice *device, + gboolean *has_match) { const NMConfigDataPrivate *priv; - const MatchSectionInfo * connection_info; - const char * value; + const MatchSectionInfo *connection_info; + const char *value; NM_SET_OUT(has_match, FALSE); @@ -1536,15 +1536,15 @@ nm_config_data_get_device_config(const NMConfigData *self, } const char * -nm_config_data_get_device_config_by_pllink(const NMConfigData * self, - const char * property, +nm_config_data_get_device_config_by_pllink(const NMConfigData *self, + const char *property, const NMPlatformLink *pllink, - const char * match_device_type, - gboolean * has_match) + const char *match_device_type, + gboolean *has_match) { const NMConfigDataPrivate *priv; - const MatchSectionInfo * connection_info; - const char * value; + const MatchSectionInfo *connection_info; + const char *value; g_return_val_if_fail(self, NULL); g_return_val_if_fail(property && *property, NULL); @@ -1564,8 +1564,8 @@ nm_config_data_get_device_config_by_pllink(const NMConfigData * self, gboolean nm_config_data_get_device_config_boolean(const NMConfigData *self, - const char * property, - NMDevice * device, + const char *property, + NMDevice *device, int val_no_match, int val_invalid) { @@ -1580,8 +1580,8 @@ nm_config_data_get_device_config_boolean(const NMConfigData *self, gint64 nm_config_data_get_device_config_int64(const NMConfigData *self, - const char * property, - NMDevice * device, + const char *property, + NMDevice *device, int base, gint64 min, gint64 max, @@ -1601,12 +1601,12 @@ nm_config_data_get_device_config_int64(const NMConfigData *self, const GSList * nm_config_data_get_device_allowed_connections_specs(const NMConfigData *self, - NMDevice * device, - gboolean * has_match) + NMDevice *device, + gboolean *has_match) { const NMConfigDataPrivate *priv; - const MatchSectionInfo * connection_info; - const GSList * ret = NULL; + const MatchSectionInfo *connection_info; + const GSList *ret = NULL; g_return_val_if_fail(self, NULL); @@ -1632,11 +1632,11 @@ nm_config_data_get_device_allowed_connections_specs(const NMConfigData *self, const char * nm_config_data_get_connection_default(const NMConfigData *self, - const char * property, - NMDevice * device) + const char *property, + NMDevice *device) { const NMConfigDataPrivate *priv; - const char * value; + const char *value; g_return_val_if_fail(self, NULL); g_return_val_if_fail(property && *property, NULL); @@ -1669,8 +1669,8 @@ nm_config_data_get_connection_default(const NMConfigData *self, gint64 nm_config_data_get_connection_default_int64(const NMConfigData *self, - const char * property, - NMDevice * device, + const char *property, + NMDevice *device, gint64 min, gint64 max, gint64 fallback) @@ -1703,11 +1703,11 @@ _match_section_info_get_str(const MatchSectionInfo *m, GKeyFile *keyfile, const static void _match_section_info_init(MatchSectionInfo *connection_info, - GKeyFile * keyfile, - char * group, + GKeyFile *keyfile, + char *group, gboolean is_device) { - char ** keys = NULL; + char **keys = NULL; gsize n_keys; gsize i; gsize j; @@ -1739,7 +1739,7 @@ _match_section_info_init(MatchSectionInfo *connection_info, for (i = 0, j = 0; i < n_keys; i++) { gs_free char *key = g_steal_pointer(&keys[i]); - char * value; + char *value; if (NM_IN_STRSET(key, NM_CONFIG_KEYFILE_KEY_STOP_MATCH, NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE)) continue; @@ -1802,11 +1802,11 @@ _match_section_infos_free(MatchSectionInfo *match_section_infos) static MatchSectionInfo * _match_section_infos_construct(GKeyFile *keyfile, gboolean is_device) { - char ** groups; + char **groups; gsize i, j, ngroups; - char * connection_tag = NULL; + char *connection_tag = NULL; MatchSectionInfo *match_section_infos = NULL; - const char * prefix; + const char *prefix; prefix = is_device ? NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE : NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION; @@ -1973,7 +1973,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMConfigData * self = NM_CONFIG_DATA(object); + NMConfigData *self = NM_CONFIG_DATA(object); NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE(self); switch (prop_id) { @@ -2004,9 +2004,9 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps case PROP_NO_AUTO_DEFAULT: /* construct-only */ { - const char *const * value_arr_orig = g_value_get_boxed(value); + const char *const *value_arr_orig = g_value_get_boxed(value); gs_free const char **value_arr = NULL; - GSList * specs = NULL; + GSList *specs = NULL; gsize i, j; gsize len; @@ -2023,7 +2023,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps for (i = 0; i < len; i++) { const char *s = value_arr[i]; gboolean is_mac; - char * spec; + char *spec; if (NM_STR_HAS_PREFIX(s, NM_MATCH_SPEC_INTERFACE_NAME_TAG "=")) is_mac = FALSE; @@ -2059,9 +2059,9 @@ nm_config_data_init(NMConfigData *self) static void constructed(GObject *object) { - NMConfigData * self = NM_CONFIG_DATA(object); + NMConfigData *self = NM_CONFIG_DATA(object); NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE(self); - char * str; + char *str; priv->keyfile = _merge_keyfiles(priv->keyfile_user, priv->keyfile_intern); @@ -2145,11 +2145,11 @@ constructed(GObject *object) } NMConfigData * -nm_config_data_new(const char * config_main_file, - const char * config_description, +nm_config_data_new(const char *config_main_file, + const char *config_description, const char *const *no_auto_default, - GKeyFile * keyfile_user, - GKeyFile * keyfile_intern) + GKeyFile *keyfile_user, + GKeyFile *keyfile_intern) { return g_object_new(NM_TYPE_CONFIG_DATA, NM_CONFIG_DATA_CONFIG_MAIN_FILE, @@ -2186,7 +2186,7 @@ nm_config_data_new_update_keyfile_intern(const NMConfigData *base, GKeyFile *key NMConfigData * nm_config_data_new_update_no_auto_default(const NMConfigData *base, - const char *const * no_auto_default) + const char *const *no_auto_default) { const NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE(base); diff --git a/src/core/nm-config-data.h b/src/core/nm-config-data.h index 1923dc49c4..fdc7e1fc3d 100644 --- a/src/core/nm-config-data.h +++ b/src/core/nm-config-data.h @@ -125,49 +125,49 @@ typedef struct _NMGlobalDnsDomain NMGlobalDnsDomain; GType nm_config_data_get_type(void); -NMConfigData *nm_config_data_new(const char * config_main_file, - const char * config_description, +NMConfigData *nm_config_data_new(const char *config_main_file, + const char *config_description, const char *const *no_auto_default, - GKeyFile * keyfile_user, - GKeyFile * keyfile_intern); + GKeyFile *keyfile_user, + GKeyFile *keyfile_intern); NMConfigData *nm_config_data_new_update_keyfile_intern(const NMConfigData *base, - GKeyFile * keyfile_intern); + GKeyFile *keyfile_intern); NMConfigData *nm_config_data_new_update_no_auto_default(const NMConfigData *base, - const char *const * no_auto_default); + const char *const *no_auto_default); NMConfigChangeFlags nm_config_data_diff(NMConfigData *old_data, NMConfigData *new_data); -void nm_config_data_log(const NMConfigData * self, - const char * prefix, - const char * key_prefix, - const char * no_auto_default_file, +void nm_config_data_log(const NMConfigData *self, + const char *prefix, + const char *key_prefix, + const char *no_auto_default_file, /* FILE* */ gpointer print_stream); const char *nm_config_data_get_config_main_file(const NMConfigData *config_data); const char *nm_config_data_get_config_description(const NMConfigData *config_data); gboolean nm_config_data_has_group(const NMConfigData *self, const char *group); -gboolean nm_config_data_has_value(const NMConfigData * self, - const char * group, - const char * key, +gboolean nm_config_data_has_value(const NMConfigData *self, + const char *group, + const char *key, NMConfigGetValueFlags flags); -char * nm_config_data_get_value(const NMConfigData * config_data, - const char * group, - const char * key, +char *nm_config_data_get_value(const NMConfigData *config_data, + const char *group, + const char *key, NMConfigGetValueFlags flags); int nm_config_data_get_value_boolean(const NMConfigData *self, - const char * group, - const char * key, + const char *group, + const char *key, int default_value); gint64 nm_config_data_get_value_int64(const NMConfigData *self, - const char * group, - const char * key, + const char *group, + const char *key, guint base, gint64 min, gint64 max, gint64 fallback); -char ** nm_config_data_get_plugins(const NMConfigData *config_data, gboolean allow_default); +char **nm_config_data_get_plugins(const NMConfigData *config_data, gboolean allow_default); gboolean nm_config_data_get_connectivity_enabled(const NMConfigData *config_data); const char *nm_config_data_get_connectivity_uri(const NMConfigData *config_data); guint nm_config_data_get_connectivity_interval(const NMConfigData *config_data); @@ -195,9 +195,9 @@ const char *nm_config_data_get_iwd_config_path(const NMConfigData *self); extern const char *__start_connection_defaults[]; extern const char *__stop_connection_defaults[]; -#define NM_CON_DEFAULT_NOP(name) \ - static const char * NM_UNIQ_T(connection_default, NM_UNIQ) \ - _nm_used _nm_retain _nm_section("connection_defaults") = "" name +#define NM_CON_DEFAULT_NOP(name) \ + static const char *NM_UNIQ_T(connection_default, NM_UNIQ) \ + _nm_used _nm_retain _nm_section("connection_defaults") = "" name #define NM_CON_DEFAULT(name) \ ({ \ @@ -208,35 +208,35 @@ extern const char *__stop_connection_defaults[]; }) const char *nm_config_data_get_connection_default(const NMConfigData *self, - const char * property, - NMDevice * device); + const char *property, + NMDevice *device); gint64 nm_config_data_get_connection_default_int64(const NMConfigData *self, - const char * property, - NMDevice * device, + const char *property, + NMDevice *device, gint64 min, gint64 max, gint64 fallback); const char *nm_config_data_get_device_config(const NMConfigData *self, - const char * property, - NMDevice * device, - gboolean * has_match); + const char *property, + NMDevice *device, + gboolean *has_match); -const char *nm_config_data_get_device_config_by_pllink(const NMConfigData * self, - const char * property, +const char *nm_config_data_get_device_config_by_pllink(const NMConfigData *self, + const char *property, const NMPlatformLink *pllink, - const char * match_device_type, - gboolean * has_match); + const char *match_device_type, + gboolean *has_match); gboolean nm_config_data_get_device_config_boolean(const NMConfigData *self, - const char * property, - NMDevice * device, + const char *property, + NMDevice *device, int val_no_match, int val_invalid); gint64 nm_config_data_get_device_config_int64(const NMConfigData *self, - const char * property, - NMDevice * device, + const char *property, + NMDevice *device, int base, gint64 min, gint64 max, @@ -244,11 +244,11 @@ gint64 nm_config_data_get_device_config_int64(const NMConfigData *self, gint64 val_invalid); const GSList *nm_config_data_get_device_allowed_connections_specs(const NMConfigData *self, - NMDevice * device, - gboolean * has_match); + NMDevice *device, + gboolean *has_match); -char ** nm_config_data_get_groups(const NMConfigData *self); -char ** nm_config_data_get_keys(const NMConfigData *self, const char *group); +char **nm_config_data_get_groups(const NMConfigData *self); +char **nm_config_data_get_keys(const NMConfigData *self, const char *group); gboolean nm_config_data_is_intern_atomic_group(const NMConfigData *self, const char *group); GKeyFile *nm_config_data_clone_keyfile_intern(const NMConfigData *self); @@ -258,8 +258,8 @@ const char *const *nm_global_dns_config_get_options(const NMGlobalDnsConfig *dns guint nm_global_dns_config_get_num_domains(const NMGlobalDnsConfig *dns_config); NMGlobalDnsDomain *nm_global_dns_config_get_domain(const NMGlobalDnsConfig *dns_config, guint i); NMGlobalDnsDomain *nm_global_dns_config_lookup_domain(const NMGlobalDnsConfig *dns_config, - const char * name); -const char * nm_global_dns_domain_get_name(const NMGlobalDnsDomain *domain); + const char *name); +const char *nm_global_dns_domain_get_name(const NMGlobalDnsDomain *domain); const char *const *nm_global_dns_domain_get_servers(const NMGlobalDnsDomain *domain); const char *const *nm_global_dns_domain_get_options(const NMGlobalDnsDomain *domain); gboolean nm_global_dns_config_is_internal(const NMGlobalDnsConfig *dns_config); @@ -287,6 +287,6 @@ GKeyFile *_nm_config_data_get_keyfile_intern(const NMConfigData *self); * including the header, forward declare the two functions that we need. */ struct _NMDhcpManager; struct _NMDhcpManager *nm_dhcp_manager_get(void); -const char * nm_dhcp_manager_get_config(struct _NMDhcpManager *self); +const char *nm_dhcp_manager_get_config(struct _NMDhcpManager *self); #endif /* NM_CONFIG_DATA_H */ diff --git a/src/core/nm-config.c b/src/core/nm-config.c index f431365c59..60a2f1df53 100644 --- a/src/core/nm-config.c +++ b/src/core/nm-config.c @@ -29,17 +29,17 @@ /*****************************************************************************/ struct NMConfigCmdLineOptions { - char * config_main_file; - char * intern_config_file; - char * config_dir; - char * system_config_dir; - char * state_file; - char * no_auto_default_file; - char * plugins; + char *config_main_file; + char *intern_config_file; + char *config_dir; + char *system_config_dir; + char *state_file; + char *no_auto_default_file; + char *plugins; NMConfigConfigureAndQuitType configure_and_quit; gboolean is_debug; - char * connectivity_uri; + char *connectivity_uri; /* We store interval as signed internally to track whether it's * set or not via GOptionEntry @@ -152,8 +152,8 @@ nm_config_parse_boolean(const char *str, int default_value) int nm_config_keyfile_get_boolean(const GKeyFile *keyfile, - const char * section, - const char * key, + const char *section, + const char *key, int default_value) { gs_free char *str = NULL; @@ -168,8 +168,8 @@ nm_config_keyfile_get_boolean(const GKeyFile *keyfile, gint64 nm_config_keyfile_get_int64(const GKeyFile *keyfile, - const char * section, - const char * key, + const char *section, + const char *key, guint base, gint64 min, gint64 max, @@ -177,7 +177,7 @@ nm_config_keyfile_get_int64(const GKeyFile *keyfile, { gint64 v; int errsv; - char * str; + char *str; g_return_val_if_fail(keyfile, fallback); g_return_val_if_fail(section, fallback); @@ -194,9 +194,9 @@ nm_config_keyfile_get_int64(const GKeyFile *keyfile, } char * -nm_config_keyfile_get_value(const GKeyFile * keyfile, - const char * section, - const char * key, +nm_config_keyfile_get_value(const GKeyFile *keyfile, + const char *section, + const char *key, NMConfigGetValueFlags flags) { char *value; @@ -221,9 +221,9 @@ nm_config_keyfile_get_value(const GKeyFile * keyfile, } void -nm_config_keyfile_set_string_list(GKeyFile * keyfile, - const char * group, - const char * key, +nm_config_keyfile_set_string_list(GKeyFile *keyfile, + const char *group, + const char *key, const char *const *strv, gssize len) { @@ -332,7 +332,7 @@ static char ** no_auto_default_from_file(const char *no_auto_default_file) { gs_free char *data = NULL; - const char ** list = NULL; + const char **list = NULL; gsize i; if (no_auto_default_file && g_file_get_contents(no_auto_default_file, &data, NULL, NULL)) @@ -350,9 +350,9 @@ no_auto_default_from_file(const char *no_auto_default_file) } static gboolean -no_auto_default_to_file(const char * no_auto_default_file, +no_auto_default_to_file(const char *no_auto_default_file, const char *const *no_auto_default, - GError ** error) + GError **error) { nm_auto_free_gstring GString *data = NULL; gsize i; @@ -360,7 +360,7 @@ no_auto_default_to_file(const char * no_auto_default_file, data = g_string_new(""); for (i = 0; no_auto_default && no_auto_default[i]; i++) { gs_free char *s_to_free = NULL; - const char * s = no_auto_default[i]; + const char *s = no_auto_default[i]; s = nm_utils_str_utf8safe_escape(s, NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL @@ -390,14 +390,14 @@ nm_config_get_no_auto_default_for_device(NMConfig *self, NMDevice *device) void nm_config_set_no_auto_default_for_device(NMConfig *self, NMDevice *device) { - NMConfigPrivate * priv; - GError * error = NULL; - NMConfigData * new_data = NULL; - gs_free char * spec_to_free = NULL; - const char * ifname; - const char * hw_address; - const char * spec; - const char *const * no_auto_default_current; + NMConfigPrivate *priv; + GError *error = NULL; + NMConfigData *new_data = NULL; + gs_free char *spec_to_free = NULL; + const char *ifname; + const char *hw_address; + const char *spec; + const char *const *no_auto_default_current; gs_free const char **no_auto_default_new = NULL; gboolean is_fake; gsize len; @@ -555,7 +555,7 @@ static gboolean parse_configure_and_quit(const char *option_name, const char *value, gpointer user_data, - GError ** error) + GError **error) { NMConfigCmdLineOptions *cli = user_data; @@ -695,7 +695,7 @@ char *_nm_config_match_env = NULL; static gboolean ignore_config_snippet(GKeyFile *keyfile, gboolean is_base_config) { - GSList * specs; + GSList *specs; gboolean as_bool; NMMatchSpecMatchType match_type; @@ -828,7 +828,7 @@ _setting_is_string_list(const char *group, const char *key) } typedef struct { - char * group; + char *group; const char *const *keys; bool is_prefix : 1; bool is_connection : 1; @@ -927,12 +927,12 @@ check_config_key(const char *group, const char *key) { const ConfigGroup *g; const char *const *k; - const char ** ptr; + const char **ptr; #if NM_MORE_ASSERTS > 10 { static gboolean checked = FALSE; - const char ** ptr1, **ptr2; + const char **ptr1, **ptr2; /* check for duplicate elements in the static list */ @@ -972,16 +972,16 @@ check_config_key(const char *group, const char *key) } static gboolean -read_config(GKeyFile * keyfile, +read_config(GKeyFile *keyfile, gboolean is_base_config, const char *dirname, const char *path, - GPtrArray * warnings, - GError ** error) + GPtrArray *warnings, + GError **error) { nm_auto_unref_keyfile GKeyFile *kf = NULL; - gs_strfreev char ** groups = NULL; - gs_free char * path_free = NULL; + gs_strfreev char **groups = NULL; + gs_free char *path_free = NULL; gsize ngroups; gsize nkeys; int g; @@ -1033,7 +1033,7 @@ read_config(GKeyFile * keyfile, _nm_config_sort_groups(groups, ngroups); for (g = 0; groups && groups[g]; g++) { - const char * group = groups[g]; + const char *group = groups[g]; gs_strfreev char **keys = NULL; if (NM_STR_HAS_PREFIX(group, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN)) { @@ -1045,7 +1045,7 @@ read_config(GKeyFile * keyfile, continue; for (k = 0; keys[k]; k++) { gs_free char *new_value = NULL; - const char * key; + const char *key; char last_char; gsize key_len; @@ -1074,10 +1074,10 @@ read_config(GKeyFile * keyfile, if (is_string_list || _setting_is_device_spec(group, base_key) || _setting_is_connection_spec(group, base_key)) { - gs_unref_ptrarray GPtrArray *new = g_ptr_array_new_with_free_func(g_free); - char ** iter_val; + gs_unref_ptrarray GPtrArray *new = g_ptr_array_new_with_free_func(g_free); + char **iter_val; gs_strfreev char **old_val = NULL; - gs_free char ** new_val = NULL; + gs_free char **new_val = NULL; if (is_string_list) { gs_free_error GError *old_error = NULL; @@ -1145,7 +1145,7 @@ read_config(GKeyFile * keyfile, new->len); else { nm_auto_free_slist GSList *specs = NULL; - gs_free char * specs_joined = NULL; + gs_free char *specs_joined = NULL; g_ptr_array_add(new, NULL); specs = nm_strv_to_gslist((char **) new->pdata, FALSE); @@ -1184,11 +1184,11 @@ read_config(GKeyFile * keyfile, } static gboolean -read_base_config(GKeyFile * keyfile, +read_base_config(GKeyFile *keyfile, const char *cli_config_main_file, - char ** out_config_main_file, - GPtrArray * warnings, - GError ** error) + char **out_config_main_file, + GPtrArray *warnings, + GError **error) { GError *my_error = NULL; @@ -1248,11 +1248,11 @@ read_base_config(GKeyFile * keyfile, static GPtrArray * _get_config_dir_files(const char *config_dir) { - GFile * dir; + GFile *dir; GFileEnumerator *direnum; - GFileInfo * info; - GPtrArray * confs; - const char * name; + GFileInfo *info; + GPtrArray *confs; + const char *name; g_return_val_if_fail(config_dir, NULL); @@ -1297,20 +1297,20 @@ _confs_to_description(GString *str, const GPtrArray *confs, const char *name) static GKeyFile * read_entire_config(const NMConfigCmdLineOptions *cli, - const char * config_dir, - const char * system_config_dir, - char ** out_config_main_file, - char ** out_config_description, - GPtrArray * warnings, - GError ** error) + const char *config_dir, + const char *system_config_dir, + char **out_config_main_file, + char **out_config_description, + GPtrArray *warnings, + GError **error) { - nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_ptrarray GPtrArray *system_confs = NULL; - gs_unref_ptrarray GPtrArray *confs = NULL; - gs_unref_ptrarray GPtrArray *run_confs = NULL; - guint i; - gs_free char * o_config_main_file = NULL; - const char * run_config_dir = ""; + nm_auto_unref_keyfile GKeyFile *keyfile = NULL; + gs_unref_ptrarray GPtrArray *system_confs = NULL; + gs_unref_ptrarray GPtrArray *confs = NULL; + gs_unref_ptrarray GPtrArray *run_confs = NULL; + guint i; + gs_free char *o_config_main_file = NULL; + const char *run_config_dir = ""; nm_assert(config_dir); nm_assert(system_config_dir); @@ -1472,7 +1472,7 @@ static char * _keyfile_serialize_section(GKeyFile *keyfile, const char *group) { gs_strfreev char **keys = NULL; - GString * str; + GString *str; guint k; if (keyfile) @@ -1484,7 +1484,7 @@ _keyfile_serialize_section(GKeyFile *keyfile, const char *group) str = g_string_new("1#"); for (k = 0; keys[k]; k++) { - const char * key = keys[k]; + const char *key = keys[k]; gs_free char *value = NULL; _string_append_val(str, key); @@ -1502,7 +1502,7 @@ nm_config_keyfile_has_global_dns_config(GKeyFile *keyfile, gboolean internal) { gs_strfreev char **groups = NULL; guint g; - const char * prefix; + const char *prefix; if (!keyfile) return FALSE; @@ -1543,13 +1543,13 @@ nm_config_keyfile_has_global_dns_config(GKeyFile *keyfile, gboolean internal) * Returns: a #GKeyFile instance with the internal configuration. */ static GKeyFile * -intern_config_read(const char * filename, - GKeyFile * keyfile_conf, +intern_config_read(const char *filename, + GKeyFile *keyfile_conf, const char *const *atomic_section_prefixes, - gboolean * out_needs_rewrite) + gboolean *out_needs_rewrite) { - GKeyFile * keyfile_intern; - GKeyFile * keyfile; + GKeyFile *keyfile_intern; + GKeyFile *keyfile; gboolean needs_rewrite = FALSE; gs_strfreev char **groups = NULL; guint g, k; @@ -1574,7 +1574,7 @@ intern_config_read(const char * filename, groups = g_key_file_get_groups(keyfile, NULL); for (g = 0; groups && groups[g]; g++) { gs_strfreev char **keys = NULL; - const char * group = groups[g]; + const char *group = groups[g]; gboolean is_intern, is_atomic; if (nm_streq(group, NM_CONFIG_KEYFILE_GROUP_CONFIG)) @@ -1613,7 +1613,7 @@ intern_config_read(const char * filename, for (k = 0; keys[k]; k++) { gs_free char *value_set = NULL; - const char * key = keys[k]; + const char *key = keys[k]; value_set = g_key_file_get_value(keyfile, group, key, NULL); @@ -1625,7 +1625,7 @@ intern_config_read(const char * filename, continue; g_key_file_set_value(keyfile_intern, group, key, value_set); } else if (NM_STR_HAS_PREFIX_WITH_MORE(key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) { - const char * key_base = &key[NM_STRLEN(NM_CONFIG_KEYFILE_KEYPREFIX_SET)]; + const char *key_base = &key[NM_STRLEN(NM_CONFIG_KEYFILE_KEYPREFIX_SET)]; gs_free char *value_was = NULL; gs_free char *value_conf = NULL; gs_free char *key_was = @@ -1646,7 +1646,7 @@ intern_config_read(const char * filename, has_intern = TRUE; g_key_file_set_value(keyfile_intern, group, key_base, value_set); } else if (NM_STR_HAS_PREFIX_WITH_MORE(key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) { - const char * key_base = &key[NM_STRLEN(NM_CONFIG_KEYFILE_KEYPREFIX_WAS)]; + const char *key_base = &key[NM_STRLEN(NM_CONFIG_KEYFILE_KEYPREFIX_WAS)]; gs_free char *key_set = g_strdup_printf(NM_CONFIG_KEYFILE_KEYPREFIX_SET "%s", key_base); gs_free char *value_was = NULL; @@ -1715,8 +1715,8 @@ out: } static int -_intern_config_write_sort_fcn(const char ** a, - const char ** b, +_intern_config_write_sort_fcn(const char **a, + const char **b, const char *const *atomic_section_prefixes) { const char *g_a = *a; @@ -1745,17 +1745,17 @@ _intern_config_write_sort_fcn(const char ** a, } static gboolean -intern_config_write(const char * filename, - GKeyFile * keyfile_intern, - GKeyFile * keyfile_conf, +intern_config_write(const char *filename, + GKeyFile *keyfile_intern, + GKeyFile *keyfile_conf, const char *const *atomic_section_prefixes, - GError ** error) + GError **error) { - GKeyFile * keyfile; + GKeyFile *keyfile; gs_strfreev char **groups = NULL; guint g, k; gboolean success = FALSE; - GError * local = NULL; + GError *local = NULL; g_return_val_if_fail(filename, FALSE); @@ -1781,7 +1781,7 @@ intern_config_write(const char * filename, } for (g = 0; groups && groups[g]; g++) { gs_strfreev char **keys = NULL; - const char * group = groups[g]; + const char *group = groups[g]; gboolean is_intern, is_atomic; keys = g_key_file_get_keys(keyfile_intern, group, NULL, NULL); @@ -1816,7 +1816,7 @@ intern_config_write(const char * filename, } for (k = 0; keys[k]; k++) { - const char * key = keys[k]; + const char *key = keys[k]; gs_free char *value_set = NULL; gs_free char *key_set = NULL; @@ -1932,9 +1932,9 @@ intern_config_write(const char * filename, GSList * nm_config_get_match_spec(const GKeyFile *keyfile, - const char * group, - const char * key, - gboolean * out_has_key) + const char *group, + const char *key, + gboolean *out_has_key) { gs_free char *value = NULL; @@ -1952,9 +1952,9 @@ nm_config_get_match_spec(const GKeyFile *keyfile, gboolean nm_config_set_global_dns(NMConfig *self, NMGlobalDnsConfig *global_dns, GError **error) { - NMConfigPrivate * priv; - GKeyFile * keyfile; - char ** groups; + NMConfigPrivate *priv; + GKeyFile *keyfile; + char **groups; const NMGlobalDnsConfig *old_global_dns; guint i; @@ -2002,7 +2002,7 @@ nm_config_set_global_dns(NMConfig *self, NMGlobalDnsConfig *global_dns, GError * for (i = 0; i < nm_global_dns_config_get_num_domains(global_dns); i++) { NMGlobalDnsDomain *domain = nm_global_dns_config_get_domain(global_dns, i); - gs_free char * group_name = NULL; + gs_free char *group_name = NULL; group_name = g_strdup_printf(NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN "%s", nm_global_dns_domain_get_name(domain)); @@ -2032,7 +2032,7 @@ void nm_config_set_connectivity_check_enabled(NMConfig *self, gboolean enabled) { NMConfigPrivate *priv; - GKeyFile * keyfile; + GKeyFile *keyfile; g_return_if_fail(NM_IS_CONFIG(self)); @@ -2090,12 +2090,12 @@ nm_config_set_values(NMConfig *self, gboolean allow_write, gboolean force_rewrite) { - NMConfigPrivate * priv; - GKeyFile * keyfile_intern_current; - GKeyFile * keyfile_user; - GKeyFile * keyfile_new; - GError * local = NULL; - NMConfigData * new_data = NULL; + NMConfigPrivate *priv; + GKeyFile *keyfile_intern_current; + GKeyFile *keyfile_user; + GKeyFile *keyfile_new; + GError *local = NULL; + NMConfigData *new_data = NULL; gs_strfreev char **groups = NULL; int g; @@ -2191,9 +2191,9 @@ state_free(State *state) static State * state_new_from_file(const char *filename) { - GKeyFile * keyfile; + GKeyFile *keyfile; gs_free_error GError *error = NULL; - State * state; + State *state; state = state_new(); @@ -2250,9 +2250,9 @@ static void state_write(NMConfig *self) { NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE(self); - const char * filename; - GString * str; - GError * error = NULL; + const char *filename; + GString *str; + GError *error = NULL; if (priv->configure_and_quit != NM_CONFIG_CONFIGURE_AND_QUIT_DISABLED) return; @@ -2294,7 +2294,7 @@ state_write(NMConfig *self) void _nm_config_state_set(NMConfig *self, gboolean allow_persist, gboolean force_persist, ...) { - NMConfigPrivate * priv; + NMConfigPrivate *priv; va_list ap; NMConfigRunStatePropertyType property_type; @@ -2366,14 +2366,14 @@ static NM_UTILS_LOOKUP_STR_DEFINE( static NMConfigDeviceStateData * _config_device_state_data_new(int ifindex, GKeyFile *kf) { - NMConfigDeviceStateData * device_state; + NMConfigDeviceStateData *device_state; NMConfigDeviceStateManagedType managed_type = NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN; - gs_free char * connection_uuid = NULL; - gs_free char * perm_hw_addr_fake = NULL; + gs_free char *connection_uuid = NULL; + gs_free char *perm_hw_addr_fake = NULL; gsize connection_uuid_len; gsize perm_hw_addr_fake_len; NMTernary nm_owned; - char * p; + char *p; guint32 route_metric_default_effective; guint32 route_metric_default_aspired; @@ -2484,7 +2484,7 @@ nm_config_device_state_load(int ifindex) NMConfigDeviceStateData *device_state; char path[NM_STRLEN(NM_CONFIG_DEVICE_STATE_DIR "/") + DEVICE_STATE_FILENAME_LEN_MAX + 1]; nm_auto_unref_keyfile GKeyFile *kf = NULL; - const char * nm_owned_str; + const char *nm_owned_str; g_return_val_if_fail(ifindex > 0, NULL); @@ -2536,7 +2536,7 @@ GHashTable * nm_config_device_state_load_all(void) { GHashTable *states; - GDir * dir; + GDir *dir; const char *fn; int ifindex; @@ -2568,14 +2568,14 @@ nm_config_device_state_load_all(void) gboolean nm_config_device_state_write(int ifindex, NMConfigDeviceStateManagedType managed, - const char * perm_hw_addr_fake, - const char * connection_uuid, + const char *perm_hw_addr_fake, + const char *connection_uuid, NMTernary nm_owned, guint32 route_metric_default_aspired, guint32 route_metric_default_effective, - const char * next_server, - const char * root_path, - const char * dhcp_bootfile) + const char *next_server, + const char *root_path, + const char *dhcp_bootfile) { char path[NM_STRLEN(NM_CONFIG_DEVICE_STATE_DIR "/") + DEVICE_STATE_FILENAME_LEN_MAX + 1]; GError *local = NULL; @@ -2674,7 +2674,7 @@ nm_config_device_state_write(int ifindex, void nm_config_device_state_prune_stale(GHashTable *preserve_ifindexes, NMPlatform *preserve_in_platform) { - GDir * dir; + GDir *dir; const char *fn; char buf[NM_STRLEN(NM_CONFIG_DEVICE_STATE_DIR "/") + DEVICE_STATE_FILENAME_LEN_MAX + 1] = NM_CONFIG_DEVICE_STATE_DIR "/"; @@ -2759,14 +2759,14 @@ nm_config_device_state_get(NMConfig *self, int ifindex) void nm_config_reload(NMConfig *self, NMConfigChangeFlags reload_flags, gboolean emit_warnings) { - NMConfigPrivate * priv; - GError * error = NULL; - GKeyFile * keyfile, *keyfile_intern; - NMConfigData * new_data = NULL; - char * config_main_file = NULL; - char * config_description = NULL; - gs_strfreev char **no_auto_default = NULL; - gboolean intern_config_needs_rewrite; + NMConfigPrivate *priv; + GError *error = NULL; + GKeyFile *keyfile, *keyfile_intern; + NMConfigData *new_data = NULL; + char *config_main_file = NULL; + char *config_description = NULL; + gs_strfreev char **no_auto_default = NULL; + gboolean intern_config_needs_rewrite; gs_unref_ptrarray GPtrArray *warnings = NULL; guint i; @@ -2866,8 +2866,8 @@ NM_UTILS_FLAGS2STR_DEFINE(nm_config_change_flags_to_string, static void _set_config_data(NMConfig *self, NMConfigData *new_data, NMConfigChangeFlags reload_flags) { - NMConfigPrivate * priv = NM_CONFIG_GET_PRIVATE(self); - NMConfigData * old_data = priv->config_data; + NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE(self); + NMConfigData *old_data = priv->config_data; NMConfigChangeFlags changes, changes_diff; gboolean had_new_data = !!new_data; @@ -2948,10 +2948,10 @@ nm_config_setup(const NMConfigCmdLineOptions *cli, char **atomic_section_prefixe static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMConfig * self = NM_CONFIG(object); - NMConfigPrivate * priv = NM_CONFIG_GET_PRIVATE(self); + NMConfig *self = NM_CONFIG(object); + NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE(self); NMConfigCmdLineOptions *cli; - char ** strv; + char **strv; switch (prop_id) { case PROP_CMD_LINE_OPTIONS: @@ -2980,17 +2980,17 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps static gboolean init_sync(GInitable *initable, GCancellable *cancellable, GError **error) { - NMConfig * self = NM_CONFIG(initable); - NMConfigPrivate * priv = NM_CONFIG_GET_PRIVATE(self); + NMConfig *self = NM_CONFIG(initable); + NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE(self); nm_auto_unref_keyfile GKeyFile *keyfile = NULL; nm_auto_unref_keyfile GKeyFile *keyfile_intern = NULL; - gs_free char * config_main_file = NULL; - gs_free char * config_description = NULL; - gs_strfreev char ** no_auto_default = NULL; - gs_unref_ptrarray GPtrArray *warnings = NULL; - gs_free char * configure_and_quit = NULL; - gboolean intern_config_needs_rewrite; - const char * s; + gs_free char *config_main_file = NULL; + gs_free char *config_description = NULL; + gs_strfreev char **no_auto_default = NULL; + gs_unref_ptrarray GPtrArray *warnings = NULL; + gs_free char *configure_and_quit = NULL; + gboolean intern_config_needs_rewrite; + const char *s; if (priv->config_dir) { /* Object is already initialized. */ diff --git a/src/core/nm-config.h b/src/core/nm-config.h index 04e159bf5e..2c23ff200e 100644 --- a/src/core/nm-config.h +++ b/src/core/nm-config.h @@ -68,8 +68,8 @@ NMConfigData *nm_config_get_data_orig(NMConfig *config); #define NM_CONFIG_GET_DATA (nm_config_get_data(nm_config_get())) #define NM_CONFIG_GET_DATA_ORIG (nm_config_get_data_orig(nm_config_get())) -const char * nm_config_get_log_level(NMConfig *config); -const char * nm_config_get_log_domains(NMConfig *config); +const char *nm_config_get_log_level(NMConfig *config); +const char *nm_config_get_log_domains(NMConfig *config); NMConfigConfigureAndQuitType nm_config_get_configure_and_quit(NMConfig *config); gboolean nm_config_get_is_debug(NMConfig *config); @@ -86,7 +86,7 @@ void nm_config_set_values(NMConfig *self, NMConfigCmdLineOptions *nm_config_cmd_line_options_new(gboolean first_start); void nm_config_cmd_line_options_free(NMConfigCmdLineOptions *cli); void nm_config_cmd_line_options_add_to_entries(NMConfigCmdLineOptions *cli, - GOptionContext * opt_ctx); + GOptionContext *opt_ctx); gboolean nm_config_get_no_auto_default_for_device(NMConfig *config, NMDevice *device); void nm_config_set_no_auto_default_for_device(NMConfig *config, NMDevice *device); @@ -107,31 +107,31 @@ int nm_config_parse_boolean(const char *str, int default_value); GKeyFile *nm_config_create_keyfile(void); int nm_config_keyfile_get_boolean(const GKeyFile *keyfile, - const char * section, - const char * key, + const char *section, + const char *key, int default_value); gint64 nm_config_keyfile_get_int64(const GKeyFile *keyfile, - const char * section, - const char * key, + const char *section, + const char *key, guint base, gint64 min, gint64 max, gint64 fallback); -char * nm_config_keyfile_get_value(const GKeyFile * keyfile, - const char * section, - const char * key, +char *nm_config_keyfile_get_value(const GKeyFile *keyfile, + const char *section, + const char *key, NMConfigGetValueFlags flags); -void nm_config_keyfile_set_string_list(GKeyFile * keyfile, - const char * group, - const char * key, +void nm_config_keyfile_set_string_list(GKeyFile *keyfile, + const char *group, + const char *key, const char *const *strv, gssize len); gboolean nm_config_keyfile_has_global_dns_config(GKeyFile *keyfile, gboolean internal); GSList *nm_config_get_match_spec(const GKeyFile *keyfile, - const char * group, - const char * key, - gboolean * out_has_key); + const char *group, + const char *key, + gboolean *out_has_key); void _nm_config_sort_groups(char **groups, gsize ngroups); @@ -175,22 +175,22 @@ struct _NMConfigDeviceStateData { }; NMConfigDeviceStateData *nm_config_device_state_load(int ifindex); -GHashTable * nm_config_device_state_load_all(void); +GHashTable *nm_config_device_state_load_all(void); gboolean nm_config_device_state_write(int ifindex, NMConfigDeviceStateManagedType managed, - const char * perm_hw_addr_fake, - const char * connection_uuid, + const char *perm_hw_addr_fake, + const char *connection_uuid, NMTernary nm_owned, guint32 route_metric_default_aspired, guint32 route_metric_default_effective, - const char * next_server, - const char * root_path, - const char * dhcp_bootfile); + const char *next_server, + const char *root_path, + const char *dhcp_bootfile); void nm_config_device_state_prune_stale(GHashTable *preserve_ifindexes, NMPlatform *preserve_in_platform); -const GHashTable * nm_config_device_state_get_all(NMConfig *self); +const GHashTable *nm_config_device_state_get_all(NMConfig *self); const NMConfigDeviceStateData *nm_config_device_state_get(NMConfig *self, int ifindex); const char *const *nm_config_get_warnings(NMConfig *config); diff --git a/src/core/nm-connectivity.c b/src/core/nm-connectivity.c index 230c4afe53..7199c9a242 100644 --- a/src/core/nm-connectivity.c +++ b/src/core/nm-connectivity.c @@ -59,22 +59,22 @@ typedef struct { struct _NMConnectivityCheckHandle { CList handles_lst; - NMConnectivity * self; + NMConnectivity *self; NMConnectivityCheckCallback callback; gpointer user_data; char *ifspec; const char *completed_log_message; - char * completed_log_message_free; + char *completed_log_message_free; #if WITH_CONCHECK struct { ConConfig *con_config; - GCancellable * resolve_cancellable; - CURLM * curl_mhandle; - CURL * curl_ehandle; + GCancellable *resolve_cancellable; + CURLM *curl_mhandle; + CURL *curl_ehandle; struct curl_slist *request_headers; struct curl_slist *hosts; @@ -92,7 +92,7 @@ struct _NMConnectivityCheckHandle { guint timeout_id; NMConnectivityState completed_state; - const char * completed_reason; + const char *completed_reason; }; enum { @@ -106,7 +106,7 @@ static guint signals[LAST_SIGNAL] = {0}; typedef struct { CList handles_lst_head; CList completed_handles_lst_head; - NMConfig * config; + NMConfig *config; ConConfig *con_config; guint interval; @@ -200,7 +200,7 @@ _con_config_get_response(const ConConfig *con_config) static void cb_data_complete(NMConnectivityCheckHandle *cb_data, NMConnectivityState state, - const char * log_message) + const char *log_message) { NMConnectivity *self; @@ -271,8 +271,8 @@ cb_data_complete(NMConnectivityCheckHandle *cb_data, static void cb_data_queue_completed(NMConnectivityCheckHandle *cb_data, NMConnectivityState state, - const char * log_message_static, - char * log_message_take /* take */) + const char *log_message_static, + char *log_message_take /* take */) { nm_assert(cb_data); nm_assert(NM_IS_CONNECTIVITY(cb_data->self)); @@ -295,8 +295,8 @@ cb_data_queue_completed(NMConnectivityCheckHandle *cb_data, static void _complete_queued(NMConnectivity *self) { - NMConnectivity * self_keep_alive = NULL; - NMConnectivityPrivate * priv = NM_CONNECTIVITY_GET_PRIVATE(self); + NMConnectivity *self_keep_alive = NULL; + NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE(self); NMConnectivityCheckHandle *cb_data; while ((cb_data = c_list_first_entry(&priv->completed_handles_lst_head, @@ -313,7 +313,7 @@ static gboolean _con_curl_check_connectivity(CURLM *mhandle, int sockfd, int ev_bitmask) { NMConnectivityCheckHandle *cb_data; - CURLMsg * msg; + CURLMsg *msg; int m_left; long response_code; CURLMcode ret; @@ -439,7 +439,7 @@ typedef struct { static gboolean _con_curl_socketevent_cb(int fd, GIOCondition condition, gpointer user_data) { - ConCurlSockData * fdp = user_data; + ConCurlSockData *fdp = user_data; NMConnectivityCheckHandle *cb_data = fdp->cb_data; int action = 0; gboolean fdp_destroyed = FALSE; @@ -476,7 +476,7 @@ static int multi_socket_cb(CURL *e_handle, curl_socket_t fd, int what, void *userdata, void *socketp) { NMConnectivityCheckHandle *cb_data = userdata; - ConCurlSockData * fdp = socketp; + ConCurlSockData *fdp = socketp; (void) _NM_ENSURE_TYPE(int, fd); @@ -543,7 +543,7 @@ easy_write_cb(void *buffer, size_t size, size_t nmemb, void *userdata) size_t len = size * nmemb; size_t response_len; size_t check_len; - const char * response; + const char *response; if (cb_data->completed_state != NM_CONNECTIVITY_UNKNOWN) { /* already completed. */ @@ -643,7 +643,7 @@ static void do_curl_request(NMConnectivityCheckHandle *cb_data) { CURLM *mhandle; - CURL * ehandle; + CURL *ehandle; long resolve; mhandle = curl_multi_init(); @@ -709,7 +709,7 @@ resolve_cb(GObject *object, GAsyncResult *res, gpointer user_data) int addr_family; gsize len = 0; gsize i; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; result = g_dbus_connection_call_finish(G_DBUS_CONNECTION(object), res, &error); if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -732,8 +732,8 @@ resolve_cb(GObject *object, GAsyncResult *res, gpointer user_data) for (i = 0; i < no_addresses; i++) { gs_unref_variant GVariant *address = NULL; char str_addr[NM_UTILS_INET_ADDRSTRLEN]; - gs_free char * host_entry = NULL; - const guchar * address_buf; + gs_free char *host_entry = NULL; + const guchar *address_buf; g_variant_get_child(addresses, i, "(ii@ay)", &ifindex, &addr_family, &address); @@ -761,10 +761,10 @@ resolve_cb(GObject *object, GAsyncResult *res, gpointer user_data) static NMConnectivityState check_platform_config(NMConnectivity *self, - NMPlatform * platform, + NMPlatform *platform, int ifindex, int addr_family, - const char ** reason) + const char **reason) { const NMDedupMultiHeadEntry *addresses; const NMDedupMultiHeadEntry *routes; @@ -798,7 +798,7 @@ check_platform_config(NMConnectivity *self, const NMPlatformIP4Route *route; gboolean found_global = FALSE; NMDedupMultiIter iter; - const NMPObject * plobj; + const NMPObject *plobj; /* For IPv4 also require a route with global scope. */ nmp_cache_iter_for_each (&iter, routes, &plobj) { @@ -827,15 +827,15 @@ check_platform_config(NMConnectivity *self, } NMConnectivityCheckHandle * -nm_connectivity_check_start(NMConnectivity * self, +nm_connectivity_check_start(NMConnectivity *self, int addr_family, - NMPlatform * platform, + NMPlatform *platform, int ifindex, - const char * iface, + const char *iface, NMConnectivityCheckCallback callback, gpointer user_data) { - NMConnectivityPrivate * priv; + NMConnectivityPrivate *priv; NMConnectivityCheckHandle *cb_data; static guint64 request_counter = 0; @@ -863,7 +863,7 @@ nm_connectivity_check_start(NMConnectivity * self, if (iface && ifindex > 0 && priv->enabled && priv->uri_valid) { gboolean has_systemd_resolved; NMConnectivityState state; - const char * reason; + const char *reason; cb_data->concheck.ch_ifindex = ifindex; @@ -1046,14 +1046,14 @@ update_config(NMConnectivity *self, NMConfigData *config_data) guint interval; gboolean enabled; gboolean changed = FALSE; - const char * cur_uri = priv->con_config ? priv->con_config->uri : NULL; - const char * cur_response = priv->con_config ? priv->con_config->response : NULL; - const char * new_response; - const char * new_uri; + const char *cur_uri = priv->con_config ? priv->con_config->uri : NULL; + const char *cur_response = priv->con_config ? priv->con_config->response : NULL; + const char *new_response; + const char *new_uri; gboolean new_uri_valid = priv->uri_valid; gboolean new_host_port = FALSE; - gs_free char * new_host = NULL; - gs_free char * new_port = NULL; + gs_free char *new_host = NULL; + gs_free char *new_port = NULL; new_uri = nm_config_data_get_connectivity_uri(config_data); if (!nm_streq0(new_uri, cur_uri)) { @@ -1135,11 +1135,11 @@ update_config(NMConnectivity *self, NMConfigData *config_data) } static void -config_changed_cb(NMConfig * config, - NMConfigData * config_data, +config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, - NMConnectivity * self) + NMConfigData *old_data, + NMConnectivity *self) { update_config(self, config_data); } @@ -1178,8 +1178,8 @@ nm_connectivity_init(NMConnectivity *self) static void dispose(GObject *object) { - NMConnectivity * self = NM_CONNECTIVITY(object); - NMConnectivityPrivate * priv = NM_CONNECTIVITY_GET_PRIVATE(self); + NMConnectivity *self = NM_CONNECTIVITY(object); + NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE(self); NMConnectivityCheckHandle *cb_data; nm_assert(c_list_is_empty(&priv->completed_handles_lst_head)); diff --git a/src/core/nm-connectivity.h b/src/core/nm-connectivity.h index 0985df9789..7b57a112f6 100644 --- a/src/core/nm-connectivity.h +++ b/src/core/nm-connectivity.h @@ -56,16 +56,16 @@ guint nm_connectivity_get_interval(NMConnectivity *self); typedef struct _NMConnectivityCheckHandle NMConnectivityCheckHandle; -typedef void (*NMConnectivityCheckCallback)(NMConnectivity * self, +typedef void (*NMConnectivityCheckCallback)(NMConnectivity *self, NMConnectivityCheckHandle *handle, NMConnectivityState state, gpointer user_data); -NMConnectivityCheckHandle *nm_connectivity_check_start(NMConnectivity * self, +NMConnectivityCheckHandle *nm_connectivity_check_start(NMConnectivity *self, int family, - NMPlatform * platform, + NMPlatform *platform, int ifindex, - const char * iface, + const char *iface, NMConnectivityCheckCallback callback, gpointer user_data); diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c index 747e1c0920..00d9f2e54e 100644 --- a/src/core/nm-core-utils.c +++ b/src/core/nm-core-utils.c @@ -110,7 +110,7 @@ _nm_utils_set_testing(NMUtilsTestFlags flags) /*****************************************************************************/ -static GSList * _singletons = NULL; +static GSList *_singletons = NULL; static gboolean _singletons_shutdown = FALSE; static void @@ -292,7 +292,7 @@ typedef struct { } sync; }; NMUtilsKillChildAsyncCb callback; - void * user_data; + void *user_data; char log_name[1]; /* variable-length object, must be last element!! */ } KillChildAsyncData; @@ -304,9 +304,9 @@ typedef struct { static KillChildAsyncData * _kc_async_data_alloc(pid_t pid, NMLogDomain log_domain, - const char * log_name, + const char *log_name, NMUtilsKillChildAsyncCb callback, - void * user_data) + void *user_data) { KillChildAsyncData *data; size_t log_name_len; @@ -443,9 +443,9 @@ _kc_invoke_callback_idle(gpointer user_data) static void _kc_invoke_callback(pid_t pid, NMLogDomain log_domain, - const char * log_name, + const char *log_name, NMUtilsKillChildAsyncCb callback, - void * user_data, + void *user_data, gboolean success, int child_status) { @@ -482,10 +482,10 @@ void nm_utils_kill_child_async(pid_t pid, int sig, NMLogDomain log_domain, - const char * log_name, + const char *log_name, guint32 wait_before_kill_msec, NMUtilsKillChildAsyncCb callback, - void * user_data) + void *user_data) { int status = 0, errsv; pid_t ret; @@ -620,7 +620,7 @@ nm_utils_kill_child_sync(pid_t pid, int sig, NMLogDomain log_domain, const char *log_name, - int * child_status, + int *child_status, guint32 wait_before_kill_msec, guint32 sleep_duration_msec) { @@ -1176,14 +1176,14 @@ typedef struct { static gboolean match_device_s390_subchannels_parse(const char *s390_subchannels, - guint32 * out_a, - guint32 * out_b, - guint32 * out_c) + guint32 *out_a, + guint32 *out_b, + guint32 *out_c) { char buf[30 + 1]; const int BUFSIZE = G_N_ELEMENTS(buf) - 1; guint i = 0; - char * pa = NULL, *pb = NULL, *pc = NULL; + char *pa = NULL, *pb = NULL, *pc = NULL; gint64 a, b, c; nm_assert(s390_subchannels); @@ -1417,20 +1417,20 @@ match_device_eval(const char *spec_str, gboolean allow_fuzzy, MatchDeviceData *m NMMatchSpecMatchType nm_match_spec_device(const GSList *specs, - const char * interface_name, - const char * device_type, - const char * driver, - const char * driver_version, - const char * hwaddr, - const char * s390_subchannels, - const char * dhcp_plugin) + const char *interface_name, + const char *device_type, + const char *driver, + const char *driver_version, + const char *hwaddr, + const char *s390_subchannels, + const char *dhcp_plugin) { - const GSList * iter; + const GSList *iter; gboolean has_match = FALSE; gboolean has_match_except = FALSE; gboolean has_except = FALSE; gboolean has_not_except = FALSE; - const char * spec_str; + const char *spec_str; MatchDeviceData match_data = { .interface_name = interface_name, .device_type = nm_str_not_empty(device_type), @@ -1511,12 +1511,12 @@ match_connection_eval(const char *spec_str, const MatchConnectionData *match_dat static NMMatchSpecMatchType match_spec_connection(const GSList *specs, const char *id, const char *uuid, const char *origin) { - const GSList * iter; + const GSList *iter; gboolean has_match = FALSE; gboolean has_match_except = FALSE; gboolean has_except = FALSE; gboolean has_not_except = FALSE; - const char * spec_str; + const char *spec_str; const MatchConnectionData match_data = { .id = nm_str_not_empty(id), .uuid = nm_str_not_empty(uuid), @@ -1564,8 +1564,8 @@ nm_utils_connection_match_spec_list(NMConnection *connection, int no_match_value) { NMMatchSpecMatchType m; - NMSettingUser * s_user; - const char * origin = NULL; + NMSettingUser *s_user; + const char *origin = NULL; if (!specs) return no_match_value; @@ -1593,7 +1593,7 @@ nm_utils_connection_match_spec_list(NMConnection *connection, static gboolean match_config_eval(const char *str, const char *tag, guint cur_nm_version) { - gs_free char * s_ver = NULL; + gs_free char *s_ver = NULL; gs_strfreev char **s_ver_tokens = NULL; int v_maj = -1, v_min = -1, v_mic = -1; guint c_maj = -1, c_min = -1, c_mic = -1; @@ -1735,7 +1735,7 @@ nm_match_spec_config(const GSList *specs, guint cur_nm_version, const char *env) GSList * nm_match_spec_split(const char *value) { - char * string_value, *p, *q0, *q; + char *string_value, *p, *q0, *q; GSList *pieces = NULL; int trailing_ws; @@ -1835,7 +1835,7 @@ char * nm_match_spec_join(GSList *specs) { const char *p; - GString * str; + GString *str; str = g_string_new(""); @@ -1898,10 +1898,10 @@ nm_match_spec_join(GSList *specs) } static void -_pattern_parse(const char * input, +_pattern_parse(const char *input, const char **out_pattern, - gboolean * out_is_inverted, - gboolean * out_is_mandatory) + gboolean *out_is_inverted, + gboolean *out_is_mandatory) { gboolean is_inverted = FALSE; gboolean is_mandatory = FALSE; @@ -2006,7 +2006,7 @@ gboolean nm_utils_kernel_cmdline_match_check(const char *const *proc_cmdline, const char *const *patterns, guint num_patterns, - GError ** error) + GError **error) { gboolean has_optional = FALSE; gboolean has_any_optional = FALSE; @@ -2109,13 +2109,13 @@ nm_utils_cmp_connection_by_autoconnect_priority(NMConnection *a, NMConnection *b typedef struct { const char *name; - NMSetting * setting; - NMSetting * diff_base_setting; + NMSetting *setting; + NMSetting *diff_base_setting; GHashTable *setting_diff; } LogConnectionSettingData; typedef struct { - const char * item_name; + const char *item_name; NMSettingDiffResult diff_result; } LogConnectionSettingItem; @@ -2125,7 +2125,7 @@ _log_connection_sort_hashes_fcn(gconstpointer a, gconstpointer b) const LogConnectionSettingData *v1 = a; const LogConnectionSettingData *v2 = b; NMSettingPriority p1, p2; - NMSetting * s1, *s2; + NMSetting *s1, *s2; s1 = v1->setting ?: v1->diff_base_setting; s2 = v2->setting ?: v2->diff_base_setting; @@ -2144,10 +2144,10 @@ _log_connection_sort_hashes_fcn(gconstpointer a, gconstpointer b) static GArray * _log_connection_sort_hashes(NMConnection *connection, NMConnection *diff_base, - GHashTable * connection_diff) + GHashTable *connection_diff) { GHashTableIter iter; - GArray * sorted_hashes; + GArray *sorted_hashes; LogConnectionSettingData setting_data; sorted_hashes = g_array_sized_new(TRUE, @@ -2192,7 +2192,7 @@ static char * _log_connection_get_property(NMSetting *setting, const char *name) { GValue val = G_VALUE_INIT; - char * s; + char *s; g_return_val_if_fail(setting, NULL); @@ -2253,18 +2253,18 @@ nm_utils_log_connection_diff(NMConnection *connection, NMConnection *diff_base, guint32 level, guint64 domain, - const char * name, - const char * prefix, - const char * dbus_path) + const char *name, + const char *prefix, + const char *dbus_path) { GHashTable *connection_diff = NULL; - GArray * sorted_hashes; - GArray * sorted_names = NULL; + GArray *sorted_hashes; + GArray *sorted_names = NULL; int i, j; gboolean connection_diff_are_same; gboolean print_header = TRUE; gboolean print_setting_header; - GString * str1; + GString *str1; g_return_if_fail(NM_IS_CONNECTION(connection)); g_return_if_fail(!diff_base || (NM_IS_CONNECTION(diff_base) && diff_base != connection)); @@ -2336,7 +2336,7 @@ nm_utils_log_connection_diff(NMConnection *connection, _log_connection_sort_names(setting_data, sorted_names); print_setting_header = TRUE; for (j = 0; j < sorted_names->len; j++) { - char * str_conn, *str_diff; + char *str_conn, *str_diff; LogConnectionSettingItem *item = &g_array_index(sorted_names, LogConnectionSettingItem, j); @@ -2349,7 +2349,7 @@ nm_utils_log_connection_diff(NMConnection *connection, : NULL; if (print_header) { - GError * err_verify = NULL; + GError *err_verify = NULL; const char *t1, *t2; t1 = nm_connection_get_connection_type(connection); @@ -2526,9 +2526,9 @@ again: if (G_UNLIKELY(!d)) { static gsize lock; static UuidData uuid_data; - gs_free char * content = NULL; + gs_free char *content = NULL; gboolean is_fake = TRUE; - const char * fake_type = NULL; + const char *fake_type = NULL; NMUuid uuid; /* Get the machine ID from /etc/machine-id; it's always in /etc no matter @@ -2666,7 +2666,7 @@ static gboolean _host_id_read_timestamp(gboolean use_secret_key_file, const guint8 *host_id, gsize host_id_len, - gint64 * out_timestamp_ns) + gint64 *out_timestamp_ns) { struct stat st; gint64 now; @@ -2708,10 +2708,10 @@ _host_id_read_timestamp(gboolean use_secret_key_file, static const guint8 * _host_id_hash_v2(const guint8 *seed_arr, gsize seed_len, - guint8 * out_digest /* 32 bytes (NM_UTILS_CHECKSUM_LENGTH_SHA256) */) + guint8 *out_digest /* 32 bytes (NM_UTILS_CHECKSUM_LENGTH_SHA256) */) { nm_auto_free_checksum GChecksum *sum = g_checksum_new(G_CHECKSUM_SHA256); - const UuidData * machine_id_data; + const UuidData *machine_id_data; char slen[100]; /* @@ -2740,9 +2740,9 @@ _host_id_read(guint8 **out_host_id, gsize *out_host_id_len) #define SECRET_KEY_LEN 32u guint8 sha256_digest[NM_UTILS_CHECKSUM_LENGTH_SHA256]; nm_auto_clear_secret_ptr NMSecretPtr file_content = {0}; - const guint8 * secret_arr; + const guint8 *secret_arr; gsize secret_len; - GError * error = NULL; + GError *error = NULL; gboolean success; if (!nm_utils_file_get_contents(-1, @@ -2942,7 +2942,7 @@ nm_utils_host_id_get_timestamp_ns(void) return _host_id_get()->timestamp_ns; } -static GArray * nmtst_host_id_stack = NULL; +static GArray *nmtst_host_id_stack = NULL; static GMutex nmtst_host_id_lock; const HostIdData *nmtst_host_id_static_0 = NULL; @@ -2954,7 +2954,7 @@ nmtst_utils_host_id_push(const guint8 *host_id, { NM_G_MUTEX_LOCKED(&nmtst_host_id_lock); gs_free char *str1_to_free = NULL; - HostIdData * h; + HostIdData *h; g_assert(host_id_len >= -1); @@ -3027,7 +3027,7 @@ again: if (G_UNLIKELY(!d)) { static gsize lock; static UuidData boot_id; - gs_free char * contents = NULL; + gs_free char *contents = NULL; NMUuid uuid; gboolean is_fake = FALSE; @@ -3231,7 +3231,7 @@ get_gre_eui64_u_bit(guint32 addr) */ gboolean nm_utils_get_ipv6_interface_identifier(NMLinkType link_type, - const guint8 * hwaddr, + const guint8 *hwaddr, guint hwaddr_len, guint dev_id, NMUtilsIPv6IfaceId *out_iid) @@ -3312,7 +3312,7 @@ nm_utils_stable_id_generated_complete(const char *stable_id_generated) { nm_auto_free_checksum GChecksum *sum = NULL; guint8 buf[NM_UTILS_CHECKSUM_LENGTH_SHA1]; - char * base64; + char *base64; /* for NM_UTILS_STABLE_TYPE_GENERATED we generate a possibly long string * by doing text-substitutions in nm_utils_stable_id_parse(). @@ -3351,7 +3351,7 @@ nm_utils_stable_id_parse(const char *stable_id, const char *hwaddr, const char *bootid, const char *uuid, - char ** out_generated) + char **out_generated) { gsize i, idx_start; GString *str = NULL; @@ -3501,11 +3501,11 @@ _is_reserved_ipv6_iid(const guint8 *iid) void nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, + struct in6_addr *addr, + const char *ifname, + const char *network_id, guint32 dad_counter, - const guint8 * host_id, + const guint8 *host_id, gsize host_id_len) { nm_auto_free_checksum GChecksum *sum = NULL; @@ -3559,9 +3559,9 @@ nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NMUtilsStableType stable_type void nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, + struct in6_addr *addr, + const char *ifname, + const char *network_id, guint32 dad_counter) { const guint8 *host_id; @@ -3588,11 +3588,11 @@ nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type, */ gboolean nm_utils_ipv6_addr_set_stable_privacy_may_fail(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, + struct in6_addr *addr, + const char *ifname, + const char *network_id, guint32 dad_counter, - GError ** error) + GError **error) { g_return_val_if_fail(network_id, FALSE); @@ -3612,8 +3612,8 @@ nm_utils_ipv6_addr_set_stable_privacy_may_fail(NMUtilsStableType stable_type, static void _hw_addr_eth_complete(struct ether_addr *addr, - const char * current_mac_address, - const char * generate_mac_address_mask) + const char *current_mac_address, + const char *generate_mac_address_mask) { struct ether_addr mask; struct ether_addr oui; @@ -3676,12 +3676,12 @@ nm_utils_hw_addr_gen_random_eth(const char *current_mac_address, static char * _hw_addr_gen_stable_eth(NMUtilsStableType stable_type, - const char * stable_id, - const guint8 * host_id, + const char *stable_id, + const guint8 *host_id, gsize host_id_len, - const char * ifname, - const char * current_mac_address, - const char * generate_mac_address_mask) + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask) { nm_auto_free_checksum GChecksum *sum = NULL; guint32 tmp; @@ -3715,12 +3715,12 @@ _hw_addr_gen_stable_eth(NMUtilsStableType stable_type, char * nm_utils_hw_addr_gen_stable_eth_impl(NMUtilsStableType stable_type, - const char * stable_id, - const guint8 * host_id, + const char *stable_id, + const guint8 *host_id, gsize host_id_len, - const char * ifname, - const char * current_mac_address, - const char * generate_mac_address_mask) + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask) { return _hw_addr_gen_stable_eth(stable_type, stable_id, @@ -3733,10 +3733,10 @@ nm_utils_hw_addr_gen_stable_eth_impl(NMUtilsStableType stable_type, char * nm_utils_hw_addr_gen_stable_eth(NMUtilsStableType stable_type, - const char * stable_id, - const char * ifname, - const char * current_mac_address, - const char * generate_mac_address_mask) + const char *stable_id, + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask) { const guint8 *host_id; gsize host_id_len; @@ -3759,7 +3759,7 @@ nm_utils_hw_addr_gen_stable_eth(NMUtilsStableType stable_type, GBytes * nm_utils_dhcp_client_id_mac(int arp_type, const guint8 *hwaddr, gsize hwaddr_len) { - guint8 * client_id_buf; + guint8 *client_id_buf; const guint8 hwaddr_type = arp_type; if (!nm_utils_arp_type_get_hwaddr_relevant_part(arp_type, &hwaddr, &hwaddr_len)) @@ -3921,7 +3921,7 @@ nm_utils_dhcp_client_id_systemd_node_specific(guint32 iaid) GBytes * nm_utils_generate_duid_llt(int arp_type, const guint8 *hwaddr, gsize hwaddr_len, gint64 time) { - guint8 * arr; + guint8 *arr; const guint16 duid_type = htons(1); const guint16 hw_type = htons(arp_type); const guint32 duid_time = htonl(NM_MAX(0, time - NM_UTILS_EPOCH_DATETIME_200001010000)); @@ -3942,7 +3942,7 @@ nm_utils_generate_duid_llt(int arp_type, const guint8 *hwaddr, gsize hwaddr_len, GBytes * nm_utils_generate_duid_ll(int arp_type, const guint8 *hwaddr, gsize hwaddr_len) { - guint8 * arr; + guint8 *arr; const guint16 duid_type = htons(3); const guint16 hw_type = htons(arp_type); @@ -3962,7 +3962,7 @@ GBytes * nm_utils_generate_duid_uuid(const NMUuid *uuid) { const guint16 duid_type = htons(4); - guint8 * duid_buffer; + guint8 *duid_buffer; nm_assert(uuid); @@ -3990,7 +3990,7 @@ again: p = g_atomic_pointer_get(&global_duid); if (G_UNLIKELY(!p)) { nm_auto_free_checksum GChecksum *sum = NULL; - const NMUuid * machine_id; + const NMUuid *machine_id; union { guint8 sha256[NM_UTILS_CHECKSUM_LENGTH_SHA256]; NMUuid uuid; @@ -4110,7 +4110,7 @@ nm_utils_get_reverse_dns_domains_ip_4(guint32 addr, guint8 plen, GPtrArray *doma guint octets; guint i; gsize len0, len; - char * str, *s; + char *str, *s; g_return_if_fail(domains); g_return_if_fail(plen <= 32); @@ -4157,7 +4157,7 @@ nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GP guint nibbles, bits, entries; int i, j; gsize len0, len; - char * str, *s; + char *str, *s; g_return_if_fail(domains); g_return_if_fail(plen <= 128); @@ -4196,7 +4196,7 @@ nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GP } struct plugin_info { - char * path; + char *path; struct stat st; }; @@ -4251,11 +4251,11 @@ nm_utils_validate_plugin(const char *path, struct stat *st, GError **error) char ** nm_utils_read_plugin_paths(const char *dirname, const char *prefix) { - GDir * dir; - GError * error = NULL; + GDir *dir; + GError *error = NULL; const char *item; - GArray * paths; - char ** result; + GArray *paths; + char **result; guint i; g_return_val_if_fail(dirname, NULL); @@ -4321,10 +4321,10 @@ skip: char * nm_utils_format_con_diff_for_audit(GHashTable *diff) { - GHashTable * setting_diff; - char * setting_name, *prop_name; + GHashTable *setting_diff; + char *setting_name, *prop_name; GHashTableIter iter, iter2; - GString * str; + GString *str; str = g_string_sized_new(32); g_hash_table_iter_init(&iter, diff); @@ -4739,9 +4739,9 @@ get_max_rate_vht(const guint8 *bytes, guint len, guint32 *out_maxrate) void nm_wifi_utils_parse_ies(const guint8 *bytes, gsize len, - guint32 * out_max_rate, - gboolean * out_metered, - gboolean * out_owe_transition_mode) + guint32 *out_max_rate, + gboolean *out_metered, + gboolean *out_owe_transition_mode) { guint8 id, elem_len; guint32 m; @@ -4828,7 +4828,7 @@ NM_UTILS_LOOKUP_STR_DEFINE(nm_activation_type_to_string, typedef struct { GPid pid; - GTask * task; + GTask *task; gulong cancellable_id; GSource *child_watch_source; GSource *timeout_source; @@ -4964,7 +4964,7 @@ helper_have_data(int fd, GIOCondition condition, gpointer user_data) { HelperInfo *info = user_data; gssize n_read; - GError * error = NULL; + GError *error = NULL; n_read = nm_utils_fd_read(fd, &info->in_buffer); _LOG2T(info, "read returns %ld", (long) n_read); @@ -4993,8 +4993,8 @@ helper_have_data(int fd, GIOCondition condition, gpointer user_data) static void helper_child_terminated(GPid pid, int status, gpointer user_data) { - HelperInfo * info = user_data; - GError * error = NULL; + HelperInfo *info = user_data; + GError *error = NULL; gs_free char *status_desc = NULL; _LOG2D(info, "process %s", (status_desc = nm_utils_get_process_exit_status_desc(status))); @@ -5027,7 +5027,7 @@ static void helper_cancelled(GObject *object, gpointer user_data) { HelperInfo *info = user_data; - GError * error = NULL; + GError *error = NULL; nm_clear_g_signal_handler(g_task_get_cancellable(info->task), &info->cancellable_id); nm_utils_error_set_cancelled(&error, FALSE, NULL); @@ -5035,16 +5035,16 @@ helper_cancelled(GObject *object, gpointer user_data) } void -nm_utils_spawn_helper(const char *const * args, - GCancellable * cancellable, +nm_utils_spawn_helper(const char *const *args, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer cb_data) { gs_free_error GError *error = NULL; - gs_free char * commands = NULL; - HelperInfo * info; + gs_free char *commands = NULL; + HelperInfo *info; int fd_flags; - const char *const * arg; + const char *const *arg; nm_assert(args && args[0]); diff --git a/src/core/nm-core-utils.h b/src/core/nm-core-utils.h index 38f56adc08..c3ce85fa04 100644 --- a/src/core/nm-core-utils.h +++ b/src/core/nm-core-utils.h @@ -47,7 +47,7 @@ void _nm_singleton_instance_register_destruction(GObject *instance); NM_DEFINE_SINGLETON_INSTANCE(TYPE); \ NM_DEFINE_SINGLETON_REGISTER(TYPE); \ static char _already_created_##GETTER = FALSE; \ - TYPE * GETTER(void) \ + TYPE *GETTER(void) \ { \ if (G_UNLIKELY(!singleton_instance)) { \ g_assert(!(_already_created_##GETTER) || (NM_DEFINE_SINGLETON_ALLOW_MULTIPLE)); \ @@ -162,19 +162,19 @@ void nm_utils_kill_process_sync(pid_t pid, typedef void (*NMUtilsKillChildAsyncCb)(pid_t pid, gboolean success, int child_status, - void * user_data); + void *user_data); void nm_utils_kill_child_async(pid_t pid, int sig, guint64 log_domain, - const char * log_name, + const char *log_name, guint32 wait_before_kill_msec, NMUtilsKillChildAsyncCb callback, - void * user_data); + void *user_data); gboolean nm_utils_kill_child_sync(pid_t pid, int sig, guint64 log_domain, const char *log_name, - int * child_status, + int *child_status, guint32 wait_before_kill_msec, guint32 sleep_duration_msec); @@ -193,23 +193,23 @@ typedef enum { } NMMatchSpecMatchType; NMMatchSpecMatchType nm_match_spec_device(const GSList *specs, - const char * interface_name, - const char * device_type, - const char * driver, - const char * driver_version, - const char * hwaddr, - const char * s390_subchannels, - const char * dhcp_plugin); + const char *interface_name, + const char *device_type, + const char *driver, + const char *driver_version, + const char *hwaddr, + const char *s390_subchannels, + const char *dhcp_plugin); NMMatchSpecMatchType nm_match_spec_config(const GSList *specs, guint nm_version, const char *env); -GSList * nm_match_spec_split(const char *value); -char * nm_match_spec_join(GSList *specs); +GSList *nm_match_spec_split(const char *value); +char *nm_match_spec_join(GSList *specs); gboolean nm_wildcard_match_check(const char *str, const char *const *patterns, guint num_patterns); gboolean nm_utils_kernel_cmdline_match_check(const char *const *proc_cmdline, const char *const *patterns, guint num_patterns, - GError ** error); + GError **error); int nm_utils_connection_match_spec_list(NMConnection *connection, const GSList *specs, @@ -219,7 +219,7 @@ int nm_utils_connection_match_spec_list(NMConnection *connection, gboolean nm_utils_connection_has_default_route(NMConnection *connection, int addr_family, - gboolean * out_is_never_default); + gboolean *out_is_never_default); int nm_utils_cmp_connection_by_autoconnect_priority(NMConnection *a, NMConnection *b); @@ -227,22 +227,22 @@ void nm_utils_log_connection_diff(NMConnection *connection, NMConnection *diff_base, guint32 level, guint64 domain, - const char * name, - const char * prefix, - const char * dbus_path); + const char *name, + const char *prefix, + const char *dbus_path); gboolean nm_utils_is_specific_hostname(const char *name); struct _NMUuid; -const char * nm_utils_machine_id_str(void); +const char *nm_utils_machine_id_str(void); const struct _NMUuid *nm_utils_machine_id_bin(void); gboolean nm_utils_machine_id_is_fake(void); -const char * nm_utils_boot_id_str(void); +const char *nm_utils_boot_id_str(void); const struct _NMUuid *nm_utils_boot_id_bin(void); -const char * nm_utils_proc_cmdline(void); -const char *const * nm_utils_proc_cmdline_split(void); +const char *nm_utils_proc_cmdline(void); +const char *const *nm_utils_proc_cmdline_split(void); gboolean nm_utils_host_id_get(const guint8 **out_host_id, gsize *out_host_id_len); gint64 nm_utils_host_id_get_timestamp_ns(void); @@ -260,17 +260,18 @@ _nmtst_auto_utils_host_id_context_pop(const char *const *unused) nmtst_utils_host_id_pop(); } -#define _NMTST_UTILS_HOST_ID_CONTEXT(uniq, host_id) \ - _nm_unused nm_auto(_nmtst_auto_utils_host_id_context_pop) \ - const char *const NM_UNIQ_T(_host_id_context_, uniq) = ({ \ - const gint64 _timestamp_ns = 1631000672; \ - \ - nmtst_utils_host_id_push((const guint8 *) "" host_id "", \ - NM_STRLEN(host_id), \ - TRUE, \ - &_timestamp_ns); \ - "" host_id ""; \ - }) +#define _NMTST_UTILS_HOST_ID_CONTEXT(uniq, host_id) \ + _nm_unused nm_auto(_nmtst_auto_utils_host_id_context_pop) const char *const NM_UNIQ_T( \ + _host_id_context_, \ + uniq) = ({ \ + const gint64 _timestamp_ns = 1631000672; \ + \ + nmtst_utils_host_id_push((const guint8 *) "" host_id "", \ + NM_STRLEN(host_id), \ + TRUE, \ + &_timestamp_ns); \ + "" host_id ""; \ + }) #define NMTST_UTILS_HOST_ID_CONTEXT(host_id) _NMTST_UTILS_HOST_ID_CONTEXT(NM_UNIQ, host_id) @@ -305,7 +306,7 @@ NMUtilsStableType nm_utils_stable_id_parse(const char *stable_id, const char *hwaddr, const char *bootid, const char *uuid, - char ** out_generated); + char **out_generated); char *nm_utils_stable_id_random(void); char *nm_utils_stable_id_generated_complete(const char *msg); @@ -313,40 +314,40 @@ char *nm_utils_stable_id_generated_complete(const char *msg); #define NM_STABLE_PRIVACY_RFC7217_IDGEN_RETRIES 3 void nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, + struct in6_addr *addr, + const char *ifname, + const char *network_id, guint32 dad_counter, - const guint8 * host_id, + const guint8 *host_id, gsize host_id_len); void nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, + struct in6_addr *addr, + const char *ifname, + const char *network_id, guint32 dad_counter); gboolean nm_utils_ipv6_addr_set_stable_privacy_may_fail(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, + struct in6_addr *addr, + const char *ifname, + const char *network_id, guint32 dad_counter, - GError ** error); + GError **error); char *nm_utils_hw_addr_gen_random_eth(const char *current_mac_address, const char *generate_mac_address_mask); char *nm_utils_hw_addr_gen_stable_eth_impl(NMUtilsStableType stable_type, - const char * stable_id, - const guint8 * host_id, + const char *stable_id, + const guint8 *host_id, gsize host_id_len, - const char * ifname, - const char * current_mac_address, - const char * generate_mac_address_mask); + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask); char *nm_utils_hw_addr_gen_stable_eth(NMUtilsStableType stable_type, - const char * stable_id, - const char * ifname, - const char * current_mac_address, - const char * generate_mac_address_mask); + const char *stable_id, + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask); /*****************************************************************************/ @@ -420,7 +421,7 @@ static inline void nm_utils_get_reverse_dns_domains_ip(int addr_family, gconstpointer addr, guint8 plen, - GPtrArray * domains) + GPtrArray *domains) { if (NM_IS_IPv4(addr_family)) nm_utils_get_reverse_dns_domains_ip_4(*((const in_addr_t *) addr), plen, domains); @@ -431,8 +432,8 @@ nm_utils_get_reverse_dns_domains_ip(int addr_family, struct stat; gboolean nm_utils_validate_plugin(const char *path, struct stat *stat, GError **error); -char ** nm_utils_read_plugin_paths(const char *dirname, const char *prefix); -char * nm_utils_format_con_diff_for_audit(GHashTable *diff); +char **nm_utils_read_plugin_paths(const char *dirname, const char *prefix); +char *nm_utils_format_con_diff_for_audit(GHashTable *diff); /*****************************************************************************/ @@ -446,9 +447,9 @@ const char *nm_utils_parse_dns_domain(const char *domain, gboolean *is_routing); void nm_wifi_utils_parse_ies(const guint8 *bytes, gsize len, - guint32 * out_max_rate, - gboolean * out_metered, - gboolean * out_owe_transition_mode); + guint32 *out_max_rate, + gboolean *out_metered, + gboolean *out_owe_transition_mode); guint8 nm_wifi_utils_level_to_quality(int val); @@ -462,8 +463,8 @@ guint8 nm_wifi_utils_level_to_quality(int val); /*****************************************************************************/ -void nm_utils_spawn_helper(const char *const * args, - GCancellable * cancellable, +void nm_utils_spawn_helper(const char *const *args, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer cb_data); diff --git a/src/core/nm-dbus-manager.c b/src/core/nm-dbus-manager.c index 323d0a19f1..2c5f7acee8 100644 --- a/src/core/nm-dbus-manager.c +++ b/src/core/nm-dbus-manager.c @@ -47,7 +47,7 @@ typedef struct { typedef struct { CList registration_lst; - NMDBusObject * obj; + NMDBusObject *obj; NMDBusObjectClass *klass; guint info_idx; guint registration_id; @@ -147,9 +147,9 @@ _objects_by_path_equal(gconstpointer user_data_a, gconstpointer user_data_b) typedef struct { CList private_servers_lst; - const char * tag; + const char *tag; GQuark detail; - char * address; + char *address; GDBusServer *server; /* With peer bus connections, we'll get a new connection for each @@ -168,12 +168,12 @@ typedef struct { typedef struct { CList object_mgr_lst; GDBusObjectManagerServer *manager; - char * fake_sender; + char *fake_sender; } ObjectMgrData; typedef struct { GDBusConnection *connection; - PrivateServer * server; + PrivateServer *server; gboolean remote_peer_vanished; } CloseConnectionInfo; @@ -204,8 +204,8 @@ static gboolean close_connection_in_idle(gpointer user_data) { CloseConnectionInfo *info = user_data; - PrivateServer * server = info->server; - ObjectMgrData * obj_mgr_data, *obj_mgr_data_safe; + PrivateServer *server = info->server; + ObjectMgrData *obj_mgr_data, *obj_mgr_data_safe; /* Emit this for the manager */ g_signal_emit(server->manager, @@ -242,10 +242,10 @@ close_connection_in_idle(gpointer user_data) static void private_server_closed_connection(GDBusConnection *conn, gboolean remote_peer_vanished, - GError * error, + GError *error, gpointer user_data) { - PrivateServer * s = user_data; + PrivateServer *s = user_data; CloseConnectionInfo *info; /* Clean up after the connection */ @@ -268,11 +268,11 @@ private_server_closed_connection(GDBusConnection *conn, static gboolean private_server_new_connection(GDBusServer *server, GDBusConnection *conn, gpointer user_data) { - PrivateServer * s = user_data; - ObjectMgrData * obj_mgr_data; + PrivateServer *s = user_data; + ObjectMgrData *obj_mgr_data; static guint32 counter = 0; GDBusObjectManagerServer *manager; - char * sender; + char *sender; g_signal_connect(conn, "closed", G_CALLBACK(private_server_closed_connection), s); @@ -302,8 +302,8 @@ private_server_new_connection(GDBusServer *server, GDBusConnection *conn, gpoint static gboolean private_server_authorize(GDBusAuthObserver *observer, - GIOStream * stream, - GCredentials * credentials, + GIOStream *stream, + GCredentials *credentials, gpointer user_data) { return g_credentials_get_unix_user(credentials, NULL) == 0; @@ -311,7 +311,7 @@ private_server_authorize(GDBusAuthObserver *observer, static gboolean private_server_allow_mechanism(GDBusAuthObserver *observer, - const char * mechanism, + const char *mechanism, gpointer user_data) { return NM_IN_STRSET(mechanism, "EXTERNAL"); @@ -346,13 +346,13 @@ private_server_free(gpointer ptr) void nm_dbus_manager_private_server_register(NMDBusManager *self, const char *path, const char *tag) { - NMDBusManagerPrivate *priv; - PrivateServer * s; + NMDBusManagerPrivate *priv; + PrivateServer *s; gs_unref_object GDBusAuthObserver *auth_observer = NULL; - GDBusServer * server; - GError * error = NULL; - gs_free char * address = NULL; - gs_free char * guid = NULL; + GDBusServer *server; + GError *error = NULL; + gs_free char *address = NULL; + gs_free char *guid = NULL; g_return_if_fail(NM_IS_DBUS_MANAGER(self)); g_return_if_fail(path); @@ -455,9 +455,9 @@ _caller_info_free(CallerInfo *caller_info) static gboolean _bus_get_unix_pid(NMDBusManager *self, const char *sender, gulong *out_pid) { - NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); - guint32 unix_pid = G_MAXUINT32; - gs_unref_variant GVariant *ret = NULL; + NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); + guint32 unix_pid = G_MAXUINT32; + gs_unref_variant GVariant *ret = NULL; if (!priv->main_dbus_connection) return FALSE; @@ -485,9 +485,9 @@ _bus_get_unix_pid(NMDBusManager *self, const char *sender, gulong *out_pid) static gboolean _bus_get_unix_user(NMDBusManager *self, const char *sender, gulong *out_user) { - NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); - guint32 unix_uid = G_MAXUINT32; - gs_unref_variant GVariant *ret = NULL; + NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); + guint32 unix_uid = G_MAXUINT32; + gs_unref_variant GVariant *ret = NULL; if (!priv->main_dbus_connection) return FALSE; @@ -514,13 +514,13 @@ _bus_get_unix_user(NMDBusManager *self, const char *sender, gulong *out_user) static const CallerInfo * _get_caller_info_ensure(NMDBusManager *self, - const char * sender, + const char *sender, gboolean ensure_uid, gboolean ensure_pid) { NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); - CallerInfo * caller_info; - CallerInfo * ci; + CallerInfo *caller_info; + CallerInfo *ci; gint64 now_ns; gsize num; @@ -584,17 +584,17 @@ _get_caller_info_ensure(NMDBusManager *self, } static gboolean -_get_caller_info(NMDBusManager * self, +_get_caller_info(NMDBusManager *self, GDBusMethodInvocation *context, - GDBusConnection * connection, - GDBusMessage * message, - const char ** out_sender, - gulong * out_uid, - gulong * out_pid) + GDBusConnection *connection, + GDBusMessage *message, + const char **out_sender, + gulong *out_uid, + gulong *out_pid) { NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); - const CallerInfo * caller_info; - const char * sender; + const CallerInfo *caller_info; + const char *sender; if (context) { nm_assert(G_IS_DBUS_METHOD_INVOCATION(context)); @@ -655,22 +655,22 @@ _get_caller_info(NMDBusManager * self, } gboolean -nm_dbus_manager_get_caller_info(NMDBusManager * self, +nm_dbus_manager_get_caller_info(NMDBusManager *self, GDBusMethodInvocation *context, - const char ** out_sender, - gulong * out_uid, - gulong * out_pid) + const char **out_sender, + gulong *out_uid, + gulong *out_pid) { return _get_caller_info(self, context, NULL, NULL, out_sender, out_uid, out_pid); } gboolean -nm_dbus_manager_get_caller_info_from_message(NMDBusManager * self, +nm_dbus_manager_get_caller_info_from_message(NMDBusManager *self, GDBusConnection *connection, - GDBusMessage * message, - const char ** out_sender, - gulong * out_uid, - gulong * out_pid) + GDBusMessage *message, + const char **out_sender, + gulong *out_uid, + gulong *out_pid) { return _get_caller_info(self, NULL, connection, message, out_sender, out_uid, out_pid); } @@ -692,7 +692,7 @@ nm_dbus_manager_get_caller_info_from_message(NMDBusManager * self, * Returns: %TRUE if the check succeeded, %FALSE otherwise */ gboolean -nm_dbus_manager_ensure_uid(NMDBusManager * self, +nm_dbus_manager_ensure_uid(NMDBusManager *self, GDBusMethodInvocation *context, gulong uid, GQuark error_domain, @@ -723,8 +723,8 @@ gboolean nm_dbus_manager_get_unix_user(NMDBusManager *self, const char *sender, gulong *out_uid) { NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); - const CallerInfo * caller_info; - PrivateServer * s; + const CallerInfo *caller_info; + PrivateServer *s; g_return_val_if_fail(sender != NULL, FALSE); g_return_val_if_fail(out_uid != NULL, FALSE); @@ -763,21 +763,21 @@ _reg_data_get_interface_info(RegistrationData *reg_data) /*****************************************************************************/ static void -dbus_vtable_method_call(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +dbus_vtable_method_call(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { - NMDBusManager * self; - NMDBusManagerPrivate * priv; - RegistrationData * reg_data = user_data; - NMDBusObject * obj = reg_data->obj; + NMDBusManager *self; + NMDBusManagerPrivate *priv; + RegistrationData *reg_data = user_data; + NMDBusObject *obj = reg_data->obj; const NMDBusInterfaceInfoExtended *interface_info = _reg_data_get_interface_info(reg_data); - const NMDBusMethodInfoExtended * method_info = NULL; + const NMDBusMethodInfoExtended *method_info = NULL; gboolean on_same_interface; on_same_interface = nm_streq(interface_info->parent.name, interface_name); @@ -786,9 +786,9 @@ dbus_vtable_method_call(GDBusConnection * connection, if (!on_same_interface && nm_streq(interface_name, DBUS_INTERFACE_PROPERTIES) && nm_streq(method_name, "Set")) { const NMDBusPropertyInfoExtended *property_info = NULL; - const char * property_interface; - const char * property_name; - gs_unref_variant GVariant *value = NULL; + const char *property_interface; + const char *property_name; + gs_unref_variant GVariant *value = NULL; self = nm_dbus_object_get_manager(obj); priv = NM_DBUS_MANAGER_GET_PRIVATE(self); @@ -863,8 +863,8 @@ static GVariant * _obj_get_property(RegistrationData *reg_data, guint property_idx, gboolean refetch) { const NMDBusInterfaceInfoExtended *interface_info = _reg_data_get_interface_info(reg_data); - const NMDBusPropertyInfoExtended * property_info; - GVariant * value; + const NMDBusPropertyInfoExtended *property_info; + GVariant *value; property_info = (const NMDBusPropertyInfoExtended *) (interface_info->parent.properties[property_idx]); @@ -887,14 +887,14 @@ out: static GVariant * dbus_vtable_get_property(GDBusConnection *connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * property_name, - GError ** error, + const char *sender, + const char *object_path, + const char *interface_name, + const char *property_name, + GError **error, gpointer user_data) { - RegistrationData * reg_data = user_data; + RegistrationData *reg_data = user_data; const NMDBusInterfaceInfoExtended *interface_info = _reg_data_get_interface_info(reg_data); guint property_idx; @@ -918,11 +918,11 @@ static const GDBusInterfaceVTable dbus_vtable = { static void _obj_register(NMDBusManager *self, NMDBusObject *obj) { - NMDBusManagerPrivate * priv = NM_DBUS_MANAGER_GET_PRIVATE(self); + NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); guint i, k; guint n_klasses; GType gtype; - NMDBusObjectClass * klasses[10]; + NMDBusObjectClass *klasses[10]; const NMDBusInterfaceInfoExtended *const *prev_interface_infos = NULL; GVariantBuilder builder; @@ -958,10 +958,10 @@ _obj_register(NMDBusManager *self, NMDBusObject *obj) for (i = 0; klass->interface_infos[i]; i++) { const NMDBusInterfaceInfoExtended *interface_info = klass->interface_infos[i]; - RegistrationData * reg_data; - gs_free_error GError *error = NULL; - guint registration_id; - guint prop_len = NM_PTRARRAY_LEN(interface_info->parent.properties); + RegistrationData *reg_data; + gs_free_error GError *error = NULL; + guint registration_id; + guint prop_len = NM_PTRARRAY_LEN(interface_info->parent.properties); reg_data = g_malloc0(sizeof(RegistrationData) + (sizeof(PropertyCacheData) * prop_len)); @@ -1020,7 +1020,7 @@ static void _obj_unregister(NMDBusManager *self, NMDBusObject *obj) { NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); - RegistrationData * reg_data; + RegistrationData *reg_data; GVariantBuilder builder; nm_assert(NM_IS_DBUS_OBJECT(obj)); @@ -1066,7 +1066,7 @@ nm_dbus_manager_lookup_object(NMDBusManager *self, const char *path) { NMDBusManagerPrivate *priv; gpointer ptr; - NMDBusObject * obj; + NMDBusObject *obj; g_return_val_if_fail(NM_IS_DBUS_MANAGER(self), NULL); g_return_val_if_fail(path, NULL); @@ -1085,7 +1085,7 @@ nm_dbus_manager_lookup_object(NMDBusManager *self, const char *path) void _nm_dbus_manager_obj_export(NMDBusObject *obj) { - NMDBusManager * self; + NMDBusManager *self; NMDBusManagerPrivate *priv; g_return_if_fail(NM_IS_DBUS_OBJECT(obj)); @@ -1108,7 +1108,7 @@ _nm_dbus_manager_obj_export(NMDBusObject *obj) void _nm_dbus_manager_obj_unexport(NMDBusObject *obj) { - NMDBusManager * self; + NMDBusManager *self; NMDBusManagerPrivate *priv; g_return_if_fail(NM_IS_DBUS_OBJECT(obj)); @@ -1135,9 +1135,9 @@ _nm_dbus_manager_obj_unexport(NMDBusObject *obj) void _nm_dbus_manager_obj_notify(NMDBusObject *obj, guint n_pspecs, const GParamSpec *const *pspecs) { - NMDBusManager * self; + NMDBusManager *self; NMDBusManagerPrivate *priv; - RegistrationData * reg_data; + RegistrationData *reg_data; guint i, p; nm_assert(NM_IS_DBUS_OBJECT(obj)); @@ -1167,7 +1167,7 @@ _nm_dbus_manager_obj_notify(NMDBusObject *obj, guint n_pspecs, const GParamSpec gboolean has_properties = FALSE; GVariantBuilder builder; GVariantBuilder invalidated_builder; - GVariant * args; + GVariant *args; if (!interface_info->parent.properties) continue; @@ -1177,7 +1177,7 @@ _nm_dbus_manager_obj_notify(NMDBusObject *obj, guint n_pspecs, const GParamSpec (const NMDBusPropertyInfoExtended *) interface_info->parent.properties[i]; for (p = 0; p < n_pspecs; p++) { - const GParamSpec *pspec = pspecs[p]; + const GParamSpec *pspec = pspecs[p]; gs_unref_variant GVariant *value = NULL; if (!nm_streq(property_info->property_name, pspec->name)) @@ -1211,12 +1211,12 @@ _nm_dbus_manager_obj_notify(NMDBusObject *obj, guint n_pspecs, const GParamSpec } void -_nm_dbus_manager_obj_emit_signal(NMDBusObject * obj, +_nm_dbus_manager_obj_emit_signal(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const GDBusSignalInfo * signal_info, - GVariant * args) + const GDBusSignalInfo *signal_info, + GVariant *args) { - NMDBusManager * self; + NMDBusManager *self; NMDBusManagerPrivate *priv; g_return_if_fail(NM_IS_DBUS_OBJECT(obj)); @@ -1244,9 +1244,9 @@ _nm_dbus_manager_obj_emit_signal(NMDBusObject * obj, /*****************************************************************************/ static GVariantBuilder * -_obj_collect_properties_per_interface(NMDBusObject * obj, +_obj_collect_properties_per_interface(NMDBusObject *obj, RegistrationData *reg_data, - GVariantBuilder * builder) + GVariantBuilder *builder) { const NMDBusInterfaceInfoExtended *interface_info = _reg_data_get_interface_info(reg_data); guint i; @@ -1286,19 +1286,19 @@ _obj_collect_properties_all(NMDBusObject *obj, GVariantBuilder *builder) } static void -dbus_vtable_objmgr_method_call(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +dbus_vtable_objmgr_method_call(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { - NMDBusManager * self = user_data; + NMDBusManager *self = user_data; NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); GVariantBuilder array_builder; - NMDBusObject * obj; + NMDBusObject *obj; nm_assert(nm_streq0(object_path, OBJECT_MANAGER_SERVER_BASE_PATH)); @@ -1368,12 +1368,12 @@ nm_dbus_manager_get_dbus_connection(NMDBusManager *self) } void -nm_dbus_manager_start(NMDBusManager * self, +nm_dbus_manager_start(NMDBusManager *self, NMDBusManagerSetPropertyHandler set_property_handler, gpointer set_property_handler_data) { NMDBusManagerPrivate *priv; - NMDBusObject * obj; + NMDBusObject *obj; g_return_if_fail(NM_IS_DBUS_MANAGER(self)); @@ -1397,9 +1397,9 @@ nm_dbus_manager_start(NMDBusManager * self, gboolean nm_dbus_manager_acquire_bus(NMDBusManager *self, gboolean request_name) { - NMDBusManagerPrivate *priv; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; + NMDBusManagerPrivate *priv; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; guint32 result; guint registration_id; @@ -1515,10 +1515,10 @@ nm_dbus_manager_init(NMDBusManager *self) static void dispose(GObject *object) { - NMDBusManager * self = NM_DBUS_MANAGER(object); + NMDBusManager *self = NM_DBUS_MANAGER(object); NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE(self); - PrivateServer * s, *s_safe; - CallerInfo * caller_info; + PrivateServer *s, *s_safe; + CallerInfo *caller_info; /* All exported NMDBusObject instances keep the manager alive, so we don't * expect any remaining objects. */ @@ -1578,11 +1578,11 @@ nm_dbus_manager_class_init(NMDBusManagerClass *klass) static NMAuthSubject * _new_unix_process(GDBusMethodInvocation *context, - GDBusConnection * connection, - GDBusMessage * message) + GDBusConnection *connection, + GDBusMessage *message) { NMAuthSubject *self; - const char * dbus_sender = NULL; + const char *dbus_sender = NULL; gulong uid = 0; gulong pid = 0; gboolean success; diff --git a/src/core/nm-dbus-manager.h b/src/core/nm-dbus-manager.h index 06876af010..d7ca78d174 100644 --- a/src/core/nm-dbus-manager.h +++ b/src/core/nm-dbus-manager.h @@ -27,13 +27,13 @@ GType nm_dbus_manager_get_type(void); NMDBusManager *nm_dbus_manager_get(void); -typedef void (*NMDBusManagerSetPropertyHandler)(NMDBusObject * obj, +typedef void (*NMDBusManagerSetPropertyHandler)(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusPropertyInfoExtended * property_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * value, + const NMDBusPropertyInfoExtended *property_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *value, gpointer user_data); gboolean nm_dbus_manager_acquire_bus(NMDBusManager *self, gboolean request_name); @@ -42,7 +42,7 @@ GDBusConnection *nm_dbus_manager_get_dbus_connection(NMDBusManager *self); #define NM_MAIN_DBUS_CONNECTION_GET (nm_dbus_manager_get_dbus_connection(nm_dbus_manager_get())) -void nm_dbus_manager_start(NMDBusManager * self, +void nm_dbus_manager_start(NMDBusManager *self, NMDBusManagerSetPropertyHandler set_property_handler, gpointer set_property_handler_data); @@ -56,18 +56,18 @@ void _nm_dbus_manager_obj_export(NMDBusObject *obj); void _nm_dbus_manager_obj_unexport(NMDBusObject *obj); void _nm_dbus_manager_obj_notify(NMDBusObject *obj, guint n_pspecs, const GParamSpec *const *pspecs); -void _nm_dbus_manager_obj_emit_signal(NMDBusObject * obj, +void _nm_dbus_manager_obj_emit_signal(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const GDBusSignalInfo * signal_info, - GVariant * args); + const GDBusSignalInfo *signal_info, + GVariant *args); -gboolean nm_dbus_manager_get_caller_info(NMDBusManager * self, +gboolean nm_dbus_manager_get_caller_info(NMDBusManager *self, GDBusMethodInvocation *context, - const char ** out_sender, - gulong * out_uid, - gulong * out_pid); + const char **out_sender, + gulong *out_uid, + gulong *out_pid); -gboolean nm_dbus_manager_ensure_uid(NMDBusManager * self, +gboolean nm_dbus_manager_ensure_uid(NMDBusManager *self, GDBusMethodInvocation *context, gulong uid, GQuark error_domain, @@ -75,12 +75,12 @@ gboolean nm_dbus_manager_ensure_uid(NMDBusManager * self, gboolean nm_dbus_manager_get_unix_user(NMDBusManager *self, const char *sender, gulong *out_uid); -gboolean nm_dbus_manager_get_caller_info_from_message(NMDBusManager * self, +gboolean nm_dbus_manager_get_caller_info_from_message(NMDBusManager *self, GDBusConnection *connection, - GDBusMessage * message, - const char ** out_sender, - gulong * out_uid, - gulong * out_pid); + GDBusMessage *message, + const char **out_sender, + gulong *out_uid, + gulong *out_pid); void nm_dbus_manager_private_server_register(NMDBusManager *self, const char *path, const char *tag); @@ -88,6 +88,6 @@ nm_dbus_manager_private_server_register(NMDBusManager *self, const char *path, c NMAuthSubject *nm_dbus_manager_new_auth_subject_from_context(GDBusMethodInvocation *context); NMAuthSubject *nm_dbus_manager_new_auth_subject_from_message(GDBusConnection *connection, - GDBusMessage * message); + GDBusMessage *message); #endif /* __NM_DBUS_MANAGER_H__ */ diff --git a/src/core/nm-dbus-object.c b/src/core/nm-dbus-object.c index 95077626f6..335b7e8be2 100644 --- a/src/core/nm-dbus-object.c +++ b/src/core/nm-dbus-object.c @@ -87,7 +87,7 @@ _create_export_path(NMDBusObjectClass *klass) const char * nm_dbus_object_export(gpointer /* (NMDBusObject *) */ self) { - NMDBusObject * self1 = self; + NMDBusObject *self1 = self; static guint64 id_counter = 0; g_return_val_if_fail(NM_IS_DBUS_OBJECT(self1), NULL); @@ -207,10 +207,10 @@ _nm_dbus_object_clear_and_unexport(NMDBusObject **location) /*****************************************************************************/ void -nm_dbus_object_emit_signal_variant(NMDBusObject * self, +nm_dbus_object_emit_signal_variant(NMDBusObject *self, const NMDBusInterfaceInfoExtended *interface_info, - const GDBusSignalInfo * signal_info, - GVariant * args) + const GDBusSignalInfo *signal_info, + GVariant *args) { if (!self->internal.path) { nm_g_variant_unref_floating(args); @@ -220,10 +220,10 @@ nm_dbus_object_emit_signal_variant(NMDBusObject * self, } void -nm_dbus_object_emit_signal(NMDBusObject * self, +nm_dbus_object_emit_signal(NMDBusObject *self, const NMDBusInterfaceInfoExtended *interface_info, - const GDBusSignalInfo * signal_info, - const char * format, + const GDBusSignalInfo *signal_info, + const char *format, ...) { va_list ap; diff --git a/src/core/nm-dbus-object.h b/src/core/nm-dbus-object.h index ae089dd30f..df22bd92aa 100644 --- a/src/core/nm-dbus-object.h +++ b/src/core/nm-dbus-object.h @@ -59,7 +59,7 @@ typedef struct { /* NMDBusObject and NMDBusManager cooperate strongly. Hence, there is an * internal data structure attached to the NMDBusObject accessible to both of them. */ struct _NMDBusObjectInternal { - char * path; + char *path; NMDBusManager *bus_manager; CList objects_lst; CList registration_lst_head; @@ -159,15 +159,15 @@ gboolean _nm_dbus_object_clear_and_unexport(NMDBusObject **location); #define nm_dbus_object_clear_and_unexport(location) \ _nm_dbus_object_clear_and_unexport(NM_CAST_PPTR(NMDBusObject, (location))) -void nm_dbus_object_emit_signal_variant(NMDBusObject * self, +void nm_dbus_object_emit_signal_variant(NMDBusObject *self, const NMDBusInterfaceInfoExtended *interface_info, - const GDBusSignalInfo * signal_info, - GVariant * args); + const GDBusSignalInfo *signal_info, + GVariant *args); -void nm_dbus_object_emit_signal(NMDBusObject * self, +void nm_dbus_object_emit_signal(NMDBusObject *self, const NMDBusInterfaceInfoExtended *interface_info, - const GDBusSignalInfo * signal_info, - const char * format, + const GDBusSignalInfo *signal_info, + const char *format, ...); #endif /* __NM_DBUS_OBJECT_H__ */ diff --git a/src/core/nm-dbus-utils.c b/src/core/nm-dbus-utils.c index 7f7b9fb94b..096b647b91 100644 --- a/src/core/nm-dbus-utils.c +++ b/src/core/nm-dbus-utils.c @@ -13,8 +13,8 @@ GDBusPropertyInfo * nm_dbus_utils_interface_info_lookup_property(const GDBusInterfaceInfo *interface_info, - const char * property_name, - guint * property_idx) + const char *property_name, + guint *property_idx) { guint i; @@ -39,7 +39,7 @@ nm_dbus_utils_interface_info_lookup_property(const GDBusInterfaceInfo *interface GDBusMethodInfo * nm_dbus_utils_interface_info_lookup_method(const GDBusInterfaceInfo *interface_info, - const char * method_name) + const char *method_name) { guint i; @@ -64,8 +64,8 @@ GVariant * nm_dbus_utils_get_property(GObject *obj, const char *signature, const char *property_name) { nm_auto_unset_gvalue GValue value = G_VALUE_INIT; - GParamSpec * pspec; - GVariant * variant; + GParamSpec *pspec; + GVariant *variant; nm_assert(G_IS_OBJECT(obj)); nm_assert(g_variant_type_string_is_valid(signature)); @@ -108,12 +108,12 @@ nm_dbus_utils_g_value_set_object_path_still_exported(GValue *value, gpointer obj void nm_dbus_utils_g_value_set_object_path_from_hash( - GValue * value, + GValue *value, GHashTable *hash /* has keys of NMDBusObject type. */, gboolean expect_all_exported) { - NMDBusObject * obj; - char ** strv; + NMDBusObject *obj; + char **strv; guint i, n; GHashTableIter iter; @@ -151,7 +151,7 @@ nm_dbus_utils_get_paths_for_clist(const CList *lst_head, { const CList *iter; const char **strv; - const char * path; + const char *path; gsize i, n; nm_assert(lst_head); @@ -243,7 +243,7 @@ void nm_dbus_track_obj_path_set(NMDBusTrackObjPath *track, gpointer obj, gboolean visible) { gs_unref_object NMDBusObject *old_obj = NULL; - const char * old_path; + const char *old_path; nm_assert(track); nm_assert(G_IS_OBJECT(track->_notify_target)); diff --git a/src/core/nm-dbus-utils.h b/src/core/nm-dbus-utils.h index 6585d43d76..54b506343e 100644 --- a/src/core/nm-dbus-utils.h +++ b/src/core/nm-dbus-utils.h @@ -13,7 +13,7 @@ struct _NMDBusMethodInfoExtended; struct _NMDBusPropertyInfoExtendedBase { GDBusPropertyInfo _parent; - const char * property_name; + const char *property_name; }; struct _NMDBusPropertyInfoExtendedReadWritable { @@ -37,7 +37,7 @@ typedef struct { * are accessible directly in the parent struct. */ struct { GDBusPropertyInfo parent; - const char * property_name; + const char *property_name; }; }; } NMDBusPropertyInfoExtended; @@ -81,13 +81,13 @@ G_STATIC_ASSERT(G_STRUCT_OFFSET(NMDBusPropertyInfoExtended, property_name) typedef struct _NMDBusMethodInfoExtended { GDBusMethodInfo parent; - void (*handle)(NMDBusObject * obj, + void (*handle)(NMDBusObject *obj, const struct _NMDBusInterfaceInfoExtended *interface_info, - const struct _NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters); + const struct _NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters); bool allow_during_shutdown; } NMDBusMethodInfoExtended; @@ -111,12 +111,12 @@ typedef struct _NMDBusInterfaceInfoExtended { GDBusPropertyInfo * nm_dbus_utils_interface_info_lookup_property(const GDBusInterfaceInfo *interface_info, - const char * property_name, - guint * property_idx); + const char *property_name, + guint *property_idx); GDBusMethodInfo * nm_dbus_utils_interface_info_lookup_method(const GDBusInterfaceInfo *interface_info, - const char * method_name); + const char *method_name); GVariant * nm_dbus_utils_get_property(GObject *obj, const char *signature, const char *property_name); @@ -134,7 +134,7 @@ void nm_dbus_utils_g_value_set_object_path(GValue *value, gpointer object); void nm_dbus_utils_g_value_set_object_path_still_exported(GValue *value, gpointer object); -void nm_dbus_utils_g_value_set_object_path_from_hash(GValue * value, +void nm_dbus_utils_g_value_set_object_path_from_hash(GValue *value, GHashTable *hash, gboolean expect_all_exported); @@ -145,7 +145,7 @@ typedef struct { gpointer const obj; gpointer _obj; }; - GObject * _notify_target; + GObject *_notify_target; const GParamSpec *_notify_pspec; gulong _notify_signal_id; union { diff --git a/src/core/nm-dcb.c b/src/core/nm-dcb.c index f048d99944..2b90cfa564 100644 --- a/src/core/nm-dcb.c +++ b/src/core/nm-dcb.c @@ -18,12 +18,12 @@ do_helper(const char *iface, guint which, DcbFunc run_func, gpointer user_data, - GError ** error, + GError **error, const char *fmt, ...) { gs_free const char **split = NULL; - gs_free char * cmdline = NULL; + gs_free char *cmdline = NULL; gs_free const char **argv = NULL; gsize i; gsize u; @@ -70,7 +70,7 @@ _dcb_enable(const char *iface, gboolean enable, DcbFunc run_func, gpointer user_data, - GError ** error) + GError **error) { if (enable) return do_helper(iface, DCBTOOL, run_func, user_data, error, "dcb on"); @@ -114,11 +114,11 @@ _dcb_enable(const char *iface, G_STMT_END gboolean -_dcb_setup(const char * iface, +_dcb_setup(const char *iface, NMSettingDcb *s_dcb, DcbFunc run_func, gpointer user_data, - GError ** error) + GError **error) { NMSettingDcbFlags flags; guint i; @@ -246,11 +246,11 @@ _dcb_cleanup(const char *iface, DcbFunc run_func, gpointer user_data, GError **e } gboolean -_fcoe_setup(const char * iface, +_fcoe_setup(const char *iface, NMSettingDcb *s_dcb, DcbFunc run_func, gpointer user_data, - GError ** error) + GError **error) { NMSettingDcbFlags flags; @@ -283,8 +283,8 @@ run_helper(char **argv, guint which, gpointer user_data, GError **error) const char *helper_path; int exit_status = 0; gboolean success; - char * errmsg = NULL, *outmsg = NULL; - char * cmdline; + char *errmsg = NULL, *outmsg = NULL; + char *cmdline; helper_path = nm_utils_find_helper((which == DCBTOOL) ? "dcbtool" : "fcoeadm", NULL, error); if (!helper_path) diff --git a/src/core/nm-dcb.h b/src/core/nm-dcb.h index 7cb5e7ef0c..78c2590d0a 100644 --- a/src/core/nm-dcb.h +++ b/src/core/nm-dcb.h @@ -22,7 +22,7 @@ gboolean do_helper(const char *iface, guint which, DcbFunc run_func, gpointer user_data, - GError ** error, + GError **error, const char *fmt, ...) G_GNUC_PRINTF(6, 7); @@ -30,21 +30,21 @@ gboolean _dcb_enable(const char *iface, gboolean enable, DcbFunc run_func, gpointer user_data, - GError ** error); + GError **error); -gboolean _dcb_setup(const char * iface, +gboolean _dcb_setup(const char *iface, NMSettingDcb *s_dcb, DcbFunc run_func, gpointer user_data, - GError ** error); + GError **error); gboolean _dcb_cleanup(const char *iface, DcbFunc run_func, gpointer user_data, GError **error); -gboolean _fcoe_setup(const char * iface, +gboolean _fcoe_setup(const char *iface, NMSettingDcb *s_dcb, DcbFunc run_func, gpointer user_data, - GError ** error); + GError **error); gboolean _fcoe_cleanup(const char *iface, DcbFunc run_func, gpointer user_data, GError **error); diff --git a/src/core/nm-dhcp-config.c b/src/core/nm-dhcp-config.c index 8a89173c0f..b32c9b7056 100644 --- a/src/core/nm-dhcp-config.c +++ b/src/core/nm-dhcp-config.c @@ -52,7 +52,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDhcpConfig, PROP_L3CD, PROP_OPTIONS, ); typedef struct { const NML3ConfigData *l3cd; - GVariant * options; + GVariant *options; } NMDhcpConfigPrivate; struct _NMDhcpConfig { @@ -101,8 +101,8 @@ void nm_dhcp_config_set_lease(NMDhcpConfig *self, const NML3ConfigData *l3cd) { nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; - gs_unref_variant GVariant *options2 = NULL; - NMDhcpConfigPrivate * priv; + gs_unref_variant GVariant *options2 = NULL; + NMDhcpConfigPrivate *priv; g_return_if_fail(NM_IS_DHCP_CONFIG(self)); @@ -129,7 +129,7 @@ const char * nm_dhcp_config_get_option(NMDhcpConfig *self, const char *key) { NMDhcpConfigPrivate *priv; - NMDhcpLease * lease; + NMDhcpLease *lease; g_return_val_if_fail(NM_IS_DHCP_CONFIG(self), NULL); g_return_val_if_fail(key, NULL); @@ -173,7 +173,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMDhcpConfig * self = NM_DHCP_CONFIG(object); + NMDhcpConfig *self = NM_DHCP_CONFIG(object); NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE(self); switch (prop_id) { diff --git a/src/core/nm-dispatcher.c b/src/core/nm-dispatcher.c index d68dab5b22..b6ff25ca45 100644 --- a/src/core/nm-dispatcher.c +++ b/src/core/nm-dispatcher.c @@ -54,8 +54,8 @@ struct NMDispatcherCallId { NMDispatcherFunc callback; gpointer user_data; - const char * log_ifname; - const char * log_con_uuid; + const char *log_ifname; + const char *log_con_uuid; NMDispatcherAction action; guint idle_id; guint32 request_id; @@ -74,7 +74,7 @@ struct NMDispatcherCallId { * Finally, cleanup the global structures. */ static struct { GDBusConnection *dbus_connection; - GHashTable * requests; + GHashTable *requests; guint request_id_counter; } gl; @@ -85,13 +85,13 @@ dispatcher_call_id_new(guint32 request_id, NMDispatcherAction action, NMDispatcherFunc callback, gpointer user_data, - const char * log_ifname, - const char * log_con_uuid) + const char *log_ifname, + const char *log_con_uuid) { NMDispatcherCallId *call_id; gsize l_log_ifname; gsize l_log_con_uuid; - char * extra_strings; + char *extra_strings; l_log_ifname = log_ifname ? (strlen(log_ifname) + 1) : 0u; l_log_con_uuid = log_con_uuid ? (strlen(log_con_uuid) + 1) : 0u; @@ -166,16 +166,16 @@ static void dump_ip_to_props(const NML3ConfigData *l3cd, int addr_family, GVariantBuilder *builder) { const int IS_IPv4 = NM_IS_IPv4(addr_family); - const NMPObject * obj; + const NMPObject *obj; GVariantBuilder int_builder; NMDedupMultiIter ipconf_iter; - GVariant * var1; - GVariant * var2; + GVariant *var1; + GVariant *var2; guint n; guint i; - const NMPObject * default_route; + const NMPObject *default_route; const char *const *strarr; - const in_addr_t * ip4arr; + const in_addr_t *ip4arr; gconstpointer iparr; if (IS_IPv4) @@ -281,16 +281,16 @@ dump_ip_to_props(const NML3ConfigData *l3cd, int addr_family, GVariantBuilder *b } static void -fill_device_props(NMDevice * device, +fill_device_props(NMDevice *device, GVariantBuilder *dev_builder, GVariantBuilder *proxy_builder, GVariantBuilder *ip4_builder, GVariantBuilder *ip6_builder, - GVariant ** dhcp4_props, - GVariant ** dhcp6_props) + GVariant **dhcp4_props, + GVariant **dhcp6_props) { const NML3ConfigData *l3cd; - NMDhcpConfig * dhcp_config; + NMDhcpConfig *dhcp_config; /* If the action is for a VPN, send the VPN's IP interface instead of the device's */ g_variant_builder_add(dev_builder, @@ -335,9 +335,9 @@ fill_device_props(NMDevice * device, static void fill_vpn_props(const NML3ConfigData *l3cd, - GVariantBuilder * proxy_builder, - GVariantBuilder * ip4_builder, - GVariantBuilder * ip6_builder) + GVariantBuilder *proxy_builder, + GVariantBuilder *ip4_builder, + GVariantBuilder *ip6_builder) { if (l3cd) { dump_ip_to_props(l3cd, AF_INET, ip4_builder); @@ -368,10 +368,10 @@ static void dispatcher_results_process(guint32 request_id, const char *log_ifname, const char *log_con_uuid, - GVariant * v_results) + GVariant *v_results) { nm_auto_free_variant_iter GVariantIter *results = NULL; - const char * script, *err; + const char *script, *err; guint32 result; g_variant_get(v_results, "(a(sus))", &results); @@ -399,9 +399,9 @@ dispatcher_results_process(guint32 request_id, static void dispatcher_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; - NMDispatcherCallId * call_id = user_data; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + NMDispatcherCallId *call_id = user_data; nm_assert((gpointer) source == gl.dbus_connection); @@ -453,34 +453,34 @@ action_to_string(NMDispatcherAction action) static gboolean _dispatcher_call(NMDispatcherAction action, gboolean blocking, - NMDevice * device, + NMDevice *device, NMSettingsConnection *settings_connection, - NMConnection * applied_connection, + NMConnection *applied_connection, gboolean activation_type_external, NMConnectivityState connectivity_state, - const char * vpn_iface, + const char *vpn_iface, const NML3ConfigData *l3cd, NMDispatcherFunc callback, gpointer user_data, - NMDispatcherCallId ** out_call_id) + NMDispatcherCallId **out_call_id) { - GVariant * connection_dict; - GVariantBuilder connection_props; - GVariantBuilder device_props; - GVariantBuilder device_proxy_props; - GVariantBuilder device_ip4_props; - GVariantBuilder device_ip6_props; + GVariant *connection_dict; + GVariantBuilder connection_props; + GVariantBuilder device_props; + GVariantBuilder device_proxy_props; + GVariantBuilder device_ip4_props; + GVariantBuilder device_ip6_props; gs_unref_variant GVariant *parameters_floating = NULL; gs_unref_variant GVariant *device_dhcp4_props = NULL; gs_unref_variant GVariant *device_dhcp6_props = NULL; GVariantBuilder vpn_proxy_props; GVariantBuilder vpn_ip4_props; GVariantBuilder vpn_ip6_props; - NMDispatcherCallId * call_id; + NMDispatcherCallId *call_id; guint request_id; - const char * connectivity_state_string = "UNKNOWN"; - const char * log_ifname; - const char * log_con_uuid; + const char *connectivity_state_string = "UNKNOWN"; + const char *log_ifname; + const char *log_con_uuid; g_return_val_if_fail(!blocking || (!callback && !user_data), FALSE); @@ -598,8 +598,8 @@ _dispatcher_call(NMDispatcherAction action, /* Send the action to the dispatcher */ if (blocking) { - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; ret = g_dbus_connection_call_sync(gl.dbus_connection, NM_DISPATCHER_DBUS_SERVICE, @@ -689,8 +689,8 @@ nm_dispatcher_call_hostname(NMDispatcherFunc callback, */ gboolean nm_dispatcher_call_device(NMDispatcherAction action, - NMDevice * device, - NMActRequest * act_request, + NMDevice *device, + NMActRequest *act_request, NMDispatcherFunc callback, gpointer user_data, NMDispatcherCallId **out_call_id) @@ -734,8 +734,8 @@ nm_dispatcher_call_device(NMDispatcherAction action, */ gboolean nm_dispatcher_call_device_sync(NMDispatcherAction action, - NMDevice * device, - NMActRequest * act_request) + NMDevice *device, + NMActRequest *act_request) { nm_assert(NM_IS_DEVICE(device)); if (!act_request) { @@ -783,13 +783,13 @@ nm_dispatcher_call_device_sync(NMDispatcherAction action, gboolean nm_dispatcher_call_vpn(NMDispatcherAction action, NMSettingsConnection *settings_connection, - NMConnection * applied_connection, - NMDevice * parent_device, - const char * vpn_iface, + NMConnection *applied_connection, + NMDevice *parent_device, + const char *vpn_iface, const NML3ConfigData *l3cd, NMDispatcherFunc callback, gpointer user_data, - NMDispatcherCallId ** out_call_id) + NMDispatcherCallId **out_call_id) { return _dispatcher_call(action, FALSE, @@ -822,9 +822,9 @@ nm_dispatcher_call_vpn(NMDispatcherAction action, gboolean nm_dispatcher_call_vpn_sync(NMDispatcherAction action, NMSettingsConnection *settings_connection, - NMConnection * applied_connection, - NMDevice * parent_device, - const char * vpn_iface, + NMConnection *applied_connection, + NMDevice *parent_device, + const char *vpn_iface, const NML3ConfigData *l3cd) { return _dispatcher_call(action, diff --git a/src/core/nm-dispatcher.h b/src/core/nm-dispatcher.h index c347352a2d..73e0599a75 100644 --- a/src/core/nm-dispatcher.h +++ b/src/core/nm-dispatcher.h @@ -36,31 +36,31 @@ gboolean nm_dispatcher_call_hostname(NMDispatcherFunc callback, NMDispatcherCallId **out_call_id); gboolean nm_dispatcher_call_device(NMDispatcherAction action, - NMDevice * device, - NMActRequest * act_request, + NMDevice *device, + NMActRequest *act_request, NMDispatcherFunc callback, gpointer user_data, NMDispatcherCallId **out_call_id); gboolean nm_dispatcher_call_device_sync(NMDispatcherAction action, - NMDevice * device, - NMActRequest * act_request); + NMDevice *device, + NMActRequest *act_request); gboolean nm_dispatcher_call_vpn(NMDispatcherAction action, NMSettingsConnection *settings_connection, - NMConnection * applied_connection, - NMDevice * parent_device, - const char * vpn_iface, + NMConnection *applied_connection, + NMDevice *parent_device, + const char *vpn_iface, const NML3ConfigData *l3cd, NMDispatcherFunc callback, gpointer user_data, - NMDispatcherCallId ** out_call_id); + NMDispatcherCallId **out_call_id); gboolean nm_dispatcher_call_vpn_sync(NMDispatcherAction action, NMSettingsConnection *settings_connection, - NMConnection * applied_connection, - NMDevice * parent_device, - const char * vpn_iface, + NMConnection *applied_connection, + NMDevice *parent_device, + const char *vpn_iface, const NML3ConfigData *l3cd); gboolean nm_dispatcher_call_connectivity(NMConnectivityState state, diff --git a/src/core/nm-firewall-utils.c b/src/core/nm-firewall-utils.c index a2446553b7..ddac1137bf 100644 --- a/src/core/nm-firewall-utils.c +++ b/src/core/nm-firewall-utils.c @@ -115,7 +115,7 @@ static gboolean _share_iptables_call_v(const char *const *argv) { gs_free_error GError *error = NULL; - gs_free char * argv_str = NULL; + gs_free char *argv_str = NULL; int status; nm_log_dbg(LOGD_SHARING, "iptables: %s", (argv_str = g_strjoinv(" ", (char **) argv))); @@ -356,11 +356,11 @@ _share_iptables_set_shared(gboolean add, const char *ip_iface, in_addr_t addr, g /*****************************************************************************/ typedef struct { - GTask * task; - GSubprocess * subprocess; - GSource * timeout_source; + GTask *task; + GSubprocess *subprocess; + GSource *timeout_source; GCancellable *intern_cancellable; - char * identifier; + char *identifier; gulong cancellable_id; } FwNftCallData; @@ -386,8 +386,8 @@ _fw_nft_call_data_free(FwNftCallData *call_data, GError *error_take) static void _fw_nft_call_communicate_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - FwNftCallData *call_data = user_data; - gs_free_error GError *error = NULL; + FwNftCallData *call_data = user_data; + gs_free_error GError *error = NULL; gs_unref_bytes GBytes *stdout_buf = NULL; gs_unref_bytes GBytes *stderr_buf = NULL; @@ -487,14 +487,14 @@ _fw_nft_call_timeout_cb(gpointer user_data) } static void -_fw_nft_call(GBytes * stdin_buf, - GCancellable * cancellable, +_fw_nft_call(GBytes *stdin_buf, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer callback_user_data) { gs_unref_object GSubprocessLauncher *subprocess_launcher = NULL; - gs_free_error GError *error = NULL; - FwNftCallData * call_data; + gs_free_error GError *error = NULL; + FwNftCallData *call_data; call_data = g_slice_new(FwNftCallData); *call_data = (FwNftCallData){ @@ -566,7 +566,7 @@ _fw_nft_call_finish(GAsyncResult *result, GError **error) typedef struct { GMainLoop *loop; - GError ** error; + GError **error; gboolean success; } FwNftCallSyncData; @@ -586,8 +586,8 @@ _fw_nft_call_sync(GBytes *stdin_buf, GError **error) nm_g_main_context_push_thread_default(g_main_context_new()); nm_auto_unref_gmainloop GMainLoop *main_loop = g_main_loop_new(main_context, FALSE); FwNftCallSyncData data = (FwNftCallSyncData){ - .loop = main_loop, - .error = error, + .loop = main_loop, + .error = error, }; _fw_nft_call(stdin_buf, NULL, _fw_nft_call_sync_done, &data); @@ -601,11 +601,11 @@ _fw_nft_call_sync(GBytes *stdin_buf, GError **error) static void _fw_nft_set(gboolean add, const char *ip_iface, in_addr_t addr, guint8 plen) { - nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_1000, FALSE); - gs_unref_bytes GBytes *stdin_buf = NULL; - gs_free char * table_name = NULL; - gs_free char * ss1 = NULL; - char str_subnet[_SHARE_IPTABLES_SUBNET_TO_STR_LEN]; + nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_1000, FALSE); + gs_unref_bytes GBytes *stdin_buf = NULL; + gs_free char *table_name = NULL; + gs_free char *ss1 = NULL; + char str_subnet[_SHARE_IPTABLES_SUBNET_TO_STR_LEN]; table_name = _share_iptables_get_name(FALSE, "nm-shared", ip_iface); @@ -687,7 +687,7 @@ _fw_nft_set(gboolean add, const char *ip_iface, in_addr_t addr, guint8 plen) /*****************************************************************************/ struct _NMFirewallConfig { - char * ip_iface; + char *ip_iface; in_addr_t addr; guint8 plen; }; diff --git a/src/core/nm-firewalld-manager.c b/src/core/nm-firewalld-manager.c index 43ab278ad8..24dd7fd187 100644 --- a/src/core/nm-firewalld-manager.c +++ b/src/core/nm-firewalld-manager.c @@ -78,7 +78,7 @@ struct _NMFirewalldManagerCallId { union { struct { GCancellable *cancellable; - GVariant * arg; + GVariant *arg; } dbus; struct { guint id; @@ -179,15 +179,15 @@ nm_firewalld_manager_get_running(NMFirewalldManager *self) /*****************************************************************************/ static NMFirewalldManagerCallId * -_cb_info_create(NMFirewalldManager * self, +_cb_info_create(NMFirewalldManager *self, OpsType ops_type, - const char * iface, - const char * zone, + const char *iface, + const char *zone, NMFirewalldManagerAddRemoveCallback callback, gpointer user_data) { NMFirewalldManagerPrivate *priv = NM_FIREWALLD_MANAGER_GET_PRIVATE(self); - NMFirewalldManagerCallId * call_id; + NMFirewalldManagerCallId *call_id; call_id = g_slice_new0(NMFirewalldManagerCallId); @@ -230,7 +230,7 @@ _cb_info_complete(NMFirewalldManagerCallId *call_id, GError *error) static gboolean _handle_idle_cb(gpointer user_data) { - NMFirewalldManager * self; + NMFirewalldManager *self; NMFirewalldManagerCallId *call_id = user_data; nm_assert(call_id); @@ -267,10 +267,10 @@ _handle_idle_start(NMFirewalldManager *self, NMFirewalldManagerCallId *call_id) static void _handle_dbus_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMFirewalldManager * self; - NMFirewalldManagerCallId *call_id; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; + NMFirewalldManager *self; + NMFirewalldManagerCallId *call_id; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); @@ -322,8 +322,8 @@ static void _handle_dbus_start(NMFirewalldManager *self, NMFirewalldManagerCallId *call_id) { NMFirewalldManagerPrivate *priv = NM_FIREWALLD_MANAGER_GET_PRIVATE(self); - const char * dbus_method = NULL; - GVariant * arg; + const char *dbus_method = NULL; + GVariant *arg; nm_assert(call_id); nm_assert(priv->name_owner); @@ -366,15 +366,15 @@ _handle_dbus_start(NMFirewalldManager *self, NMFirewalldManagerCallId *call_id) } static NMFirewalldManagerCallId * -_start_request(NMFirewalldManager * self, +_start_request(NMFirewalldManager *self, OpsType ops_type, - const char * iface, - const char * zone, + const char *iface, + const char *zone, NMFirewalldManagerAddRemoveCallback callback, gpointer user_data) { NMFirewalldManagerPrivate *priv; - NMFirewalldManagerCallId * call_id; + NMFirewalldManagerCallId *call_id; g_return_val_if_fail(NM_IS_FIREWALLD_MANAGER(self), NULL); g_return_val_if_fail(iface && *iface, NULL); @@ -417,8 +417,8 @@ _start_request(NMFirewalldManager * self, NMFirewalldManagerCallId * nm_firewalld_manager_add_or_change_zone(NMFirewalldManager *self, - const char * iface, - const char * zone, + const char *iface, + const char *zone, gboolean add, /* TRUE == add, FALSE == change */ NMFirewalldManagerAddRemoveCallback callback, gpointer user_data) @@ -432,9 +432,9 @@ nm_firewalld_manager_add_or_change_zone(NMFirewalldManager *self, } NMFirewalldManagerCallId * -nm_firewalld_manager_remove_from_zone(NMFirewalldManager * self, - const char * iface, - const char * zone, +nm_firewalld_manager_remove_from_zone(NMFirewalldManager *self, + const char *iface, + const char *zone, NMFirewalldManagerAddRemoveCallback callback, gpointer user_data) { @@ -444,9 +444,9 @@ nm_firewalld_manager_remove_from_zone(NMFirewalldManager * self, void nm_firewalld_manager_cancel_call(NMFirewalldManagerCallId *call_id) { - NMFirewalldManager * self; + NMFirewalldManager *self; NMFirewalldManagerPrivate *priv; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; g_return_if_fail(call_id); g_return_if_fail(NM_IS_FIREWALLD_MANAGER(call_id->self)); @@ -470,7 +470,7 @@ static void name_owner_changed(NMFirewalldManager *self, const char *owner) { _nm_unused gs_unref_object NMFirewalldManager *self_keep_alive = g_object_ref(self); - NMFirewalldManagerPrivate * priv = NM_FIREWALLD_MANAGER_GET_PRIVATE(self); + NMFirewalldManagerPrivate *priv = NM_FIREWALLD_MANAGER_GET_PRIVATE(self); gboolean was_running; gboolean now_running; gboolean just_initied; @@ -532,14 +532,14 @@ name_owner_changed(NMFirewalldManager *self, const char *owner) static void reloaded_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMFirewalldManager * self = user_data; + NMFirewalldManager *self = user_data; NMFirewalldManagerPrivate *priv = NM_FIREWALLD_MANAGER_GET_PRIVATE(self); if (!nm_streq0(sender_name, priv->name_owner)) @@ -551,15 +551,15 @@ reloaded_cb(GDBusConnection *connection, static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { NMFirewalldManager *self = user_data; - const char * new_owner; + const char *new_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) return; @@ -572,7 +572,7 @@ name_owner_changed_cb(GDBusConnection *connection, static void get_name_owner_cb(const char *name_owner, GError *error, gpointer user_data) { - NMFirewalldManager * self; + NMFirewalldManager *self; NMFirewalldManagerPrivate *priv; if (nm_utils_error_is_cancelled(error)) @@ -632,7 +632,7 @@ nm_firewalld_manager_init(NMFirewalldManager *self) static void dispose(GObject *object) { - NMFirewalldManager * self = NM_FIREWALLD_MANAGER(object); + NMFirewalldManager *self = NM_FIREWALLD_MANAGER(object); NMFirewalldManagerPrivate *priv = NM_FIREWALLD_MANAGER_GET_PRIVATE(self); /* as every pending operation takes a reference to the manager, diff --git a/src/core/nm-firewalld-manager.h b/src/core/nm-firewalld-manager.h index 1f76bebaa4..a7e71486ae 100644 --- a/src/core/nm-firewalld-manager.h +++ b/src/core/nm-firewalld-manager.h @@ -36,22 +36,22 @@ NMFirewalldManager *nm_firewalld_manager_get(void); gboolean nm_firewalld_manager_get_running(NMFirewalldManager *self); -typedef void (*NMFirewalldManagerAddRemoveCallback)(NMFirewalldManager * self, +typedef void (*NMFirewalldManagerAddRemoveCallback)(NMFirewalldManager *self, NMFirewalldManagerCallId *call_id, - GError * error, + GError *error, gpointer user_data); NMFirewalldManagerCallId * -nm_firewalld_manager_add_or_change_zone(NMFirewalldManager * mgr, - const char * iface, - const char * zone, +nm_firewalld_manager_add_or_change_zone(NMFirewalldManager *mgr, + const char *iface, + const char *zone, gboolean add, NMFirewalldManagerAddRemoveCallback callback, gpointer user_data); NMFirewalldManagerCallId * -nm_firewalld_manager_remove_from_zone(NMFirewalldManager * mgr, - const char * iface, - const char * zone, +nm_firewalld_manager_remove_from_zone(NMFirewalldManager *mgr, + const char *iface, + const char *zone, NMFirewalldManagerAddRemoveCallback callback, gpointer user_data); diff --git a/src/core/nm-hostname-manager.c b/src/core/nm-hostname-manager.c index 32dc2db994..59164edee3 100644 --- a/src/core/nm-hostname-manager.c +++ b/src/core/nm-hostname-manager.c @@ -55,12 +55,12 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMHostnameManager, PROP_HOSTNAME, ); typedef struct { - char * current_hostname; + char *current_hostname; GFileMonitor *monitor; GFileMonitor *dhcp_monitor; gulong monitor_id; gulong dhcp_monitor_id; - GDBusProxy * hostnamed_proxy; + GDBusProxy *hostnamed_proxy; } NMHostnameManagerPrivate; struct _NMHostnameManager { @@ -103,9 +103,9 @@ _file_monitor_new(const char *path) static char * read_hostname_gentoo(const char *path) { - gs_free char * contents = NULL; + gs_free char *contents = NULL; gs_strfreev char **all_lines = NULL; - const char * tmp; + const char *tmp; guint i; if (!g_file_get_contents(path, &contents, NULL, NULL)) @@ -129,7 +129,7 @@ read_hostname_gentoo(const char *path) static char * read_hostname_slackware(const char *path) { - gs_free char * contents = NULL; + gs_free char *contents = NULL; gs_strfreev char **all_lines = NULL; guint i = 0; @@ -152,7 +152,7 @@ static gboolean hostname_is_dynamic(void) { GIOChannel *channel; - char * str = NULL; + char *str = NULL; gboolean dynamic = FALSE; channel = g_io_channel_new_file(CONF_DHCP, "r", NULL); @@ -188,7 +188,7 @@ static void _set_hostname(NMHostnameManager *self, const char *hostname) { NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); - char * old_hostname; + char *old_hostname; hostname = nm_str_not_empty(hostname); @@ -210,7 +210,7 @@ static void _set_hostname_read_file(NMHostnameManager *self) { NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); - gs_free char * hostname = NULL; + gs_free char *hostname = NULL; if (priv->hostnamed_proxy) { /* read-hostname returns the current hostname with hostnamed. */ @@ -239,10 +239,10 @@ _set_hostname_read_file(NMHostnameManager *self) static void set_transient_hostname_done(GObject *object, GAsyncResult *res, gpointer user_data) { - GDBusProxy * proxy = G_DBUS_PROXY(object); - gs_unref_variant GVariant *result = NULL; - gs_free_error GError * error = NULL; - gs_free char * hostname = NULL; + GDBusProxy *proxy = G_DBUS_PROXY(object); + gs_unref_variant GVariant *result = NULL; + gs_free_error GError *error = NULL; + gs_free char *hostname = NULL; NMHostnameManagerSetHostnameCb cb; gpointer cb_user_data; @@ -260,8 +260,8 @@ set_transient_hostname_done(GObject *object, GAsyncResult *res, gpointer user_da } void -nm_hostname_manager_set_transient_hostname(NMHostnameManager * self, - const char * hostname, +nm_hostname_manager_set_transient_hostname(NMHostnameManager *self, + const char *hostname, NMHostnameManagerSetHostnameCb cb, gpointer user_data) { @@ -290,7 +290,7 @@ gboolean nm_hostname_manager_get_transient_hostname(NMHostnameManager *self, char **hostname) { NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); - GVariant * v_hostname; + GVariant *v_hostname; if (!priv->hostnamed_proxy) return FALSE; @@ -310,17 +310,17 @@ nm_hostname_manager_get_transient_hostname(NMHostnameManager *self, char **hostn gboolean nm_hostname_manager_write_hostname(NMHostnameManager *self, const char *hostname) { - NMHostnameManagerPrivate *priv; - char * hostname_eol; - gboolean ret; - gs_free_error GError *error = NULL; - const char * file = HOSTNAME_FILE; - gs_free char * link_path = NULL; - gs_unref_variant GVariant *var = NULL; + NMHostnameManagerPrivate *priv; + char *hostname_eol; + gboolean ret; + gs_free_error GError *error = NULL; + const char *file = HOSTNAME_FILE; + gs_free char *link_path = NULL; + gs_unref_variant GVariant *var = NULL; struct stat file_stat; #if HAVE_SELINUX gboolean fcon_was_set = FALSE; - char * fcon_prev = NULL; + char *fcon_prev = NULL; #endif g_return_val_if_fail(NM_IS_HOSTNAME_MANAGER(self), FALSE); @@ -365,7 +365,7 @@ nm_hostname_manager_write_hostname(NMHostnameManager *self, const char *hostname handle = selabel_open(SELABEL_CTX_FILE, NULL, 0); if (handle) { mode_t st_mode = 0; - char * fcon = NULL; + char *fcon = NULL; if (stat(file, &file_stat) == 0) st_mode = file_stat.st_mode; @@ -406,12 +406,12 @@ nm_hostname_manager_write_hostname(NMHostnameManager *self, const char *hostname static void hostnamed_properties_changed(GDBusProxy *proxy, - GVariant * changed_properties, - char ** invalidated_properties, + GVariant *changed_properties, + char **invalidated_properties, gpointer user_data) { - NMHostnameManager * self = user_data; - NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); + NMHostnameManager *self = user_data; + NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); gs_unref_variant GVariant *variant = NULL; variant = g_dbus_proxy_get_cached_property(priv->hostnamed_proxy, "StaticHostname"); @@ -422,9 +422,9 @@ hostnamed_properties_changed(GDBusProxy *proxy, /*****************************************************************************/ static void -_file_monitors_file_changed_cb(GFileMonitor * monitor, - GFile * file, - GFile * other_file, +_file_monitors_file_changed_cb(GFileMonitor *monitor, + GFile *file, + GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { @@ -453,9 +453,9 @@ static void _file_monitors_setup(NMHostnameManager *self) { NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); - GFileMonitor * monitor; - const char * path = HOSTNAME_FILE; - gs_free char * link_path = NULL; + GFileMonitor *monitor; + const char *path = HOSTNAME_FILE; + gs_free char *link_path = NULL; struct stat file_stat; _file_monitors_clear(self); @@ -517,11 +517,11 @@ nm_hostname_manager_init(NMHostnameManager *self) static void constructed(GObject *object) { - NMHostnameManager * self = NM_HOSTNAME_MANAGER(object); + NMHostnameManager *self = NM_HOSTNAME_MANAGER(object); NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); - GDBusProxy * proxy; - GVariant * variant; - gs_free_error GError *error = NULL; + GDBusProxy *proxy; + GVariant *variant; + gs_free_error GError *error = NULL; proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, 0, @@ -560,7 +560,7 @@ constructed(GObject *object) static void dispose(GObject *object) { - NMHostnameManager * self = NM_HOSTNAME_MANAGER(object); + NMHostnameManager *self = NM_HOSTNAME_MANAGER(object); NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); if (priv->hostnamed_proxy) { diff --git a/src/core/nm-hostname-manager.h b/src/core/nm-hostname-manager.h index ff109e7e89..3a2c0cd698 100644 --- a/src/core/nm-hostname-manager.h +++ b/src/core/nm-hostname-manager.h @@ -38,8 +38,8 @@ const char *nm_hostname_manager_get_hostname(NMHostnameManager *self); gboolean nm_hostname_manager_write_hostname(NMHostnameManager *self, const char *hostname); -void nm_hostname_manager_set_transient_hostname(NMHostnameManager * self, - const char * hostname, +void nm_hostname_manager_set_transient_hostname(NMHostnameManager *self, + const char *hostname, NMHostnameManagerSetHostnameCb cb, gpointer user_data); diff --git a/src/core/nm-ip-config.c b/src/core/nm-ip-config.c index 2470e40e2b..b191b54bb2 100644 --- a/src/core/nm-ip-config.c +++ b/src/core/nm-ip-config.c @@ -87,7 +87,7 @@ _l3cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMIPCo static void get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfig *self = NM_IP_CONFIG(object); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); const int addr_family = nm_ip_config_get_addr_family(self); char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; @@ -141,7 +141,7 @@ get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfig *self = NM_IP_CONFIG(object); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); gpointer ptr; @@ -180,7 +180,7 @@ nm_ip_config_new(int addr_family, NML3Cfg *l3cfg) static void constructed(GObject *object) { - NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfig *self = NM_IP_CONFIG(object); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); priv->l3cfg_notify_id = @@ -203,7 +203,7 @@ nm_ip_config_take_and_unexport_on_idle(NMIPConfig *self_take) static void finalize(GObject *object) { - NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfig *self = NM_IP_CONFIG(object); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); nm_clear_g_signal_handler(priv->l3cfg, &priv->l3cfg_notify_id); @@ -225,7 +225,7 @@ finalize(GObject *object) static void nm_ip_config_class_init(NMIPConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); object_class->get_property = get_property_ip; @@ -331,11 +331,11 @@ G_DEFINE_TYPE(NMIP4Config, nm_ip4_config, NM_TYPE_IP_CONFIG) static void get_property_ip4(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMIPConfig * self = NM_IP_CONFIG(object); + NMIPConfig *self = NM_IP_CONFIG(object); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); char addr_str[NM_UTILS_INET_ADDRSTRLEN]; GVariantBuilder builder; - const in_addr_t * addrs; + const in_addr_t *addrs; guint len; guint i; @@ -441,9 +441,9 @@ nm_ip4_config_init(NMIP4Config *self) static void nm_ip4_config_class_init(NMIP4ConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMIPConfigClass * ip_config_class = NM_IP_CONFIG_CLASS(klass); + NMIPConfigClass *ip_config_class = NM_IP_CONFIG_CLASS(klass); ip_config_class->addr_family = AF_INET; @@ -504,7 +504,7 @@ nm_ip_config_dns_hash(const NML3ConfigData *l3cd, GChecksum *sum, int addr_famil guint i; int val; const char *const *nameservers; - const in_addr_t * wins; + const in_addr_t *wins; const char *const *domains; const char *const *searches; const char *const *options; @@ -630,8 +630,8 @@ static const NMDBusInterfaceInfoExtended interface_info_ip6_config = { static void get_property_ip6(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMIPConfig * self = NM_IP_CONFIG(object); - NMIPConfigPrivate * priv = NM_IP_CONFIG_GET_PRIVATE(self); + NMIPConfig *self = NM_IP_CONFIG(object); + NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); GVariantBuilder builder; guint len; guint i; @@ -669,9 +669,9 @@ nm_ip6_config_init(NMIP6Config *self) static void nm_ip6_config_class_init(NMIP6ConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); - NMIPConfigClass * ip_config_class = NM_IP_CONFIG_CLASS(klass); + NMIPConfigClass *ip_config_class = NM_IP_CONFIG_CLASS(klass); ip_config_class->addr_family = AF_INET6; @@ -730,14 +730,14 @@ nm_ip6_config_class_init(NMIP6ConfigClass *klass) static void _handle_l3cd_changed(NMIPConfig *self, const NML3ConfigData *l3cd) { - const int addr_family = nm_ip_config_get_addr_family(self); - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMIPConfigPrivate * priv = NM_IP_CONFIG_GET_PRIVATE(self); - nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; - GParamSpec * changed_params[8]; + const int addr_family = nm_ip_config_get_addr_family(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; + GParamSpec *changed_params[8]; guint n_changed_params = 0; - const char *const * strv; - const char *const * strv_old; + const char *const *strv; + const char *const *strv_old; gconstpointer addrs; gconstpointer addrs_old; guint len; @@ -795,8 +795,8 @@ _handle_platform_change(NMIPConfig *self, guint32 obj_type_flags, gboolean is_in { const int addr_family = nm_ip_config_get_addr_family(self); const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMIPConfigPrivate * priv = NM_IP_CONFIG_GET_PRIVATE(self); - GParamSpec * changed_params[5]; + NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + GParamSpec *changed_params[5]; guint n_changed_params = 0; const NMDedupMultiHeadEntry *head_entry_routes = NULL; gboolean best_default_route_changed = FALSE; diff --git a/src/core/nm-ip-config.h b/src/core/nm-ip-config.h index 9bc1ff45c6..68103cf7c8 100644 --- a/src/core/nm-ip-config.h +++ b/src/core/nm-ip-config.h @@ -23,12 +23,12 @@ #define NM_IP_CONFIG_L3CFG "l3cfg" struct _NMIPConfigPrivate { - NML3Cfg * l3cfg; + NML3Cfg *l3cfg; const NML3ConfigData *l3cd; - GVariant * v_address_data; - GVariant * v_addresses; - GVariant * v_route_data; - GVariant * v_routes; + GVariant *v_address_data; + GVariant *v_addresses; + GVariant *v_route_data; + GVariant *v_routes; struct { const NMPObject *best_default_route; } v_gateway; diff --git a/src/core/nm-keep-alive.c b/src/core/nm-keep-alive.c index 6275544ca7..e147163c1e 100644 --- a/src/core/nm-keep-alive.c +++ b/src/core/nm-keep-alive.c @@ -18,8 +18,8 @@ typedef struct { GObject *owner; NMSettingsConnection *connection; - GDBusConnection * dbus_connection; - char * dbus_client; + GDBusConnection *dbus_connection; + char *dbus_client; GCancellable *dbus_client_confirm_cancellable; guint subscription_id; @@ -150,11 +150,11 @@ connection_flags_changed(NMSettingsConnection *connection, NMKeepAlive *self) } static void -_set_settings_connection_watch_visible(NMKeepAlive * self, +_set_settings_connection_watch_visible(NMKeepAlive *self, NMSettingsConnection *connection, gboolean emit_signal) { - NMKeepAlivePrivate *priv = NM_KEEP_ALIVE_GET_PRIVATE(self); + NMKeepAlivePrivate *priv = NM_KEEP_ALIVE_GET_PRIVATE(self); gs_unref_object NMSettingsConnection *old_connection = NULL; if (priv->connection == connection) @@ -183,7 +183,7 @@ _set_settings_connection_watch_visible(NMKeepAlive * self, } void -nm_keep_alive_set_settings_connection_watch_visible(NMKeepAlive * self, +nm_keep_alive_set_settings_connection_watch_visible(NMKeepAlive *self, NMSettingsConnection *connection) { _set_settings_connection_watch_visible(self, connection, TRUE); @@ -194,7 +194,7 @@ nm_keep_alive_set_settings_connection_watch_visible(NMKeepAlive * self, static void get_name_owner_cb(const char *name_owner, GError *error, gpointer user_data) { - NMKeepAlive * self; + NMKeepAlive *self; NMKeepAlivePrivate *priv; if (!name_owner && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -259,16 +259,16 @@ cleanup_dbus_watch(NMKeepAlive *self) static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { NMKeepAlive *self = NM_KEEP_ALIVE(user_data); - const char * old_owner; - const char * new_owner; + const char *old_owner; + const char *new_owner; g_variant_get(parameters, "(&s&s&s)", NULL, &old_owner, &new_owner); @@ -281,9 +281,9 @@ name_owner_changed_cb(GDBusConnection *connection, } void -nm_keep_alive_set_dbus_client_watch(NMKeepAlive * self, +nm_keep_alive_set_dbus_client_watch(NMKeepAlive *self, GDBusConnection *connection, - const char * client_address) + const char *client_address) { NMKeepAlivePrivate *priv = NM_KEEP_ALIVE_GET_PRIVATE(self); diff --git a/src/core/nm-keep-alive.h b/src/core/nm-keep-alive.h index 2c2b4faae7..7737c17a2f 100644 --- a/src/core/nm-keep-alive.h +++ b/src/core/nm-keep-alive.h @@ -29,12 +29,12 @@ void nm_keep_alive_disarm(NMKeepAlive *self); void nm_keep_alive_destroy(NMKeepAlive *self); -void nm_keep_alive_set_settings_connection_watch_visible(NMKeepAlive * self, +void nm_keep_alive_set_settings_connection_watch_visible(NMKeepAlive *self, NMSettingsConnection *connection); -void nm_keep_alive_set_dbus_client_watch(NMKeepAlive * self, +void nm_keep_alive_set_dbus_client_watch(NMKeepAlive *self, GDBusConnection *connection, - const char * client_address); + const char *client_address); gpointer /* GObject * */ nm_keep_alive_get_owner(NMKeepAlive *self); diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index c2afec8b7d..2ea358399e 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -179,7 +179,7 @@ static GArray * _garray_inaddr_clone(const GArray *src, int addr_family) { const gsize elt_size = nm_utils_addr_family_to_size(addr_family); - GArray * dst; + GArray *dst; nm_assert_addr_family(addr_family); @@ -228,7 +228,7 @@ next:; } static gssize -_garray_inaddr_find(GArray * arr, +_garray_inaddr_find(GArray *arr, int addr_family, gconstpointer needle, /* (const NMIPAddr **) */ gpointer out_addr) @@ -344,8 +344,8 @@ _strv_ptrarray_merge(GPtrArray **p_dst, const GPtrArray *src) void nm_l3_config_data_log(const NML3ConfigData *self, - const char * title, - const char * prefix, + const char *title, + const char *prefix, NMLogLevel log_level, NMLogDomain log_domain) { @@ -445,7 +445,7 @@ nm_l3_config_data_log(const NML3ConfigData *self, if (self->ndisc_hop_limit_set || self->ndisc_reachable_time_msec_set || self->ndisc_retrans_timer_msec_set) { gsize l = sizeof(sbuf); - char * p = sbuf; + char *p = sbuf; const char *s_prefix = "ndisc: "; if (self->ndisc_hop_limit_set) { @@ -526,7 +526,7 @@ nm_l3_config_data_log(const NML3ConfigData *self, if (self->dhcp_lease_x[IS_IPv4]) { gs_free NMUtilsNamedValue *options_free = NULL; NMUtilsNamedValue options_buffer[30]; - NMUtilsNamedValue * options; + NMUtilsNamedValue *options; guint options_len; options = nm_utils_named_values_from_strdict( @@ -640,16 +640,16 @@ _NM_IS_L3_CONFIG_DATA(const NML3ConfigData *self, gboolean allow_sealed) static void _idx_obj_id_hash_update(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - NMHashState * h) + const NMDedupMultiObj *obj, + NMHashState *h) { nmp_object_id_hash_update((NMPObject *) obj, h); } static gboolean _idx_obj_id_equal(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b) + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b) { return nmp_object_id_equal((NMPObject *) obj_a, (NMPObject *) obj_b); } @@ -806,7 +806,7 @@ nm_l3_config_data_unref(const NML3ConfigData *self) static const NMDedupMultiEntry * _lookup_route(const NMDedupMultiIndex *multi_idx, const DedupMultiIdxType *idx_type, - const NMPObject * needle) + const NMPObject *needle) { const NMDedupMultiEntry *entry; @@ -846,7 +846,7 @@ nm_l3_config_data_lookup_route_obj(const NML3ConfigData *self, const NMPObject * } const NMDedupMultiEntry * -nm_l3_config_data_lookup_route(const NML3ConfigData * self, +nm_l3_config_data_lookup_route(const NML3ConfigData *self, int addr_family, const NMPlatformIPRoute *needle) { @@ -970,7 +970,7 @@ gboolean nm_l3_config_data_has_routes_with_type_local(const NML3ConfigData *self, int addr_family) { const int IS_IPv4 = NM_IS_IPv4(addr_family); - NML3ConfigData * self_mutable; + NML3ConfigData *self_mutable; NMDedupMultiIter iter; const NMPObject *obj; gboolean val; @@ -1038,7 +1038,7 @@ nm_l3_config_data_get_flags(const NML3ConfigData *self) } void -nm_l3_config_data_set_flags_full(NML3ConfigData * self, +nm_l3_config_data_set_flags_full(NML3ConfigData *self, NML3ConfigDatFlags flags, NML3ConfigDatFlags mask) { @@ -1071,14 +1071,14 @@ nm_l3_config_data_get_first_obj(const NML3ConfigData *self, /*****************************************************************************/ static gboolean -_l3_config_data_add_obj(NMDedupMultiIndex * multi_idx, - DedupMultiIdxType * idx_type, +_l3_config_data_add_obj(NMDedupMultiIndex *multi_idx, + DedupMultiIdxType *idx_type, int ifindex, - const NMPObject * obj_new, + const NMPObject *obj_new, const NMPlatformObject *pl_new, NML3ConfigAddFlags add_flags, - const NMPObject ** out_obj_old /* returns a reference! */, - const NMPObject ** out_obj_new /* does not return a reference */) + const NMPObject **out_obj_old /* returns a reference! */, + const NMPObject **out_obj_new /* does not return a reference */) { NMPObject obj_new_stackinit; const NMDedupMultiEntry *entry_old; @@ -1276,12 +1276,12 @@ _l3_config_best_default_route_find_better(const NMPObject *obj_cur, const NMPObj } gboolean -nm_l3_config_data_add_address_full(NML3ConfigData * self, +nm_l3_config_data_add_address_full(NML3ConfigData *self, int addr_family, - const NMPObject * obj_new, + const NMPObject *obj_new, const NMPlatformIPAddress *pl_new, NML3ConfigAddFlags add_flags, - const NMPObject ** out_obj_new) + const NMPObject **out_obj_new) { const NMPObject *new; gboolean changed; @@ -1305,24 +1305,24 @@ nm_l3_config_data_add_address_full(NML3ConfigData * self, static gboolean _l3_config_best_default_route_merge(const NMPObject **best_default_route, - const NMPObject * new_candidate) + const NMPObject *new_candidate) { new_candidate = _l3_config_best_default_route_find_better(*best_default_route, new_candidate); return nmp_object_ref_set(best_default_route, new_candidate); } gboolean -nm_l3_config_data_add_route_full(NML3ConfigData * self, +nm_l3_config_data_add_route_full(NML3ConfigData *self, int addr_family, - const NMPObject * obj_new, + const NMPObject *obj_new, const NMPlatformIPRoute *pl_new, NML3ConfigAddFlags add_flags, - const NMPObject ** out_obj_new, - gboolean * out_changed_best_default_route) + const NMPObject **out_obj_new, + gboolean *out_changed_best_default_route) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); nm_auto_nmpobj const NMPObject *obj_old = NULL; - const NMPObject * obj_new_2; + const NMPObject *obj_new_2; gboolean changed = FALSE; gboolean changed_best_default_route = FALSE; @@ -1425,7 +1425,7 @@ nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, g } gboolean -nm_l3_config_data_add_nameserver(NML3ConfigData * self, +nm_l3_config_data_add_nameserver(NML3ConfigData *self, int addr_family, gconstpointer /* (const NMIPAddr *) */ nameserver) { @@ -1727,7 +1727,7 @@ nm_l3_config_data_get_route_table_sync(const NML3ConfigData *self, int addr_fami } gboolean -nm_l3_config_data_set_route_table_sync(NML3ConfigData * self, +nm_l3_config_data_set_route_table_sync(NML3ConfigData *self, int addr_family, NMIPRouteTableSyncMode route_table_sync) { @@ -2035,7 +2035,7 @@ gboolean nm_l3_config_data_set_dhcp_lease(NML3ConfigData *self, int addr_family, NMDhcpLease *lease) { nm_auto_unref_dhcplease NMDhcpLease *lease_old = NULL; - NMDhcpLease ** p_lease; + NMDhcpLease **p_lease; nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); @@ -2054,11 +2054,11 @@ nm_l3_config_data_set_dhcp_lease(NML3ConfigData *self, int addr_family, NMDhcpLe gboolean nm_l3_config_data_set_dhcp_lease_from_options(NML3ConfigData *self, int addr_family, - GHashTable * options_take) + GHashTable *options_take) { nm_auto_unref_dhcplease NMDhcpLease *lease = NULL; nm_auto_unref_dhcplease NMDhcpLease *lease_old = NULL; - NMDhcpLease ** p_lease; + NMDhcpLease **p_lease; nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); @@ -2227,9 +2227,9 @@ _data_get_direct_route_for_host(const NML3ConfigData *self, guint32 route_table) { const int IS_IPv4 = NM_IS_IPv4(addr_family); - const NMPObject * best_route_obj = NULL; + const NMPObject *best_route_obj = NULL; const NMPlatformIPXRoute *best_route = NULL; - const NMPObject * item_obj; + const NMPObject *item_obj; NMDedupMultiIter ipconf_iter; nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); @@ -2290,7 +2290,7 @@ GPtrArray * nm_l3_config_data_get_blacklisted_ip4_routes(const NML3ConfigData *self, gboolean is_vrf) { gs_unref_ptrarray GPtrArray *ip4_dev_route_blacklist = NULL; - const NMPObject * my_addr_obj; + const NMPObject *my_addr_obj; NMDedupMultiIter iter; nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); @@ -2355,7 +2355,7 @@ void nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_family) { gs_unref_ptrarray GPtrArray *extra_onlink_routes = NULL; - const NMPObject * obj_src; + const NMPObject *obj_src; NMDedupMultiIter iter; int IS_IPv4; guint i; @@ -2376,9 +2376,9 @@ nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_fam nm_l3_config_data_iter_obj_for_each (&iter, self, &obj_src, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { const NMPlatformIPXRoute *route_src = NMP_OBJECT_CAST_IPX_ROUTE(obj_src); - NMPObject * new_route; - NMPlatformIPXRoute * new_r; - const NMIPAddr * p_gateway; + NMPObject *new_route; + NMPlatformIPXRoute *new_r; + const NMIPAddr *p_gateway; p_gateway = nm_platform_ip_route_get_gateway(addr_family, &route_src->rx); @@ -2424,14 +2424,14 @@ nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_fam } void -nm_l3_config_data_add_dependent_device_routes(NML3ConfigData * self, +nm_l3_config_data_add_dependent_device_routes(NML3ConfigData *self, int addr_family, guint32 route_table, guint32 route_metric, const NML3ConfigData *source) { const int IS_IPv4 = NM_IS_IPv4(addr_family); - const NMPObject * obj_src; + const NMPObject *obj_src; NMPlatformIPXRoute rx; NMDedupMultiIter iter; @@ -2454,7 +2454,7 @@ nm_l3_config_data_add_dependent_device_routes(NML3ConfigData * self, &obj_src, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)) { const NMPlatformIPXAddress *const addr_src = NMP_OBJECT_CAST_IPX_ADDRESS(obj_src); - const NMPlatformIPXAddress * addr_dst; + const NMPlatformIPXAddress *addr_dst; addr_dst = NMP_OBJECT_CAST_IPX_ADDRESS( nm_dedup_multi_entry_get_obj(nm_l3_config_data_lookup_obj(self, obj_src))); @@ -2537,7 +2537,7 @@ _init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *co guint nroutes; guint nnameservers; guint nsearches; - const char * gateway_str; + const char *gateway_str; NMIPAddr gateway_bin; guint i; int idx; @@ -2583,10 +2583,10 @@ _init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *co naddresses = nm_setting_ip_config_get_num_addresses(s_ip); for (i = 0; i < naddresses; i++) { - NMIPAddress * s_addr = nm_setting_ip_config_get_address(s_ip, i); + NMIPAddress *s_addr = nm_setting_ip_config_get_address(s_ip, i); NMPlatformIPXAddress a; NMIPAddr addr_bin; - GVariant * label; + GVariant *label; nm_assert(nm_ip_address_get_family(s_addr) == addr_family); @@ -2623,7 +2623,7 @@ _init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *co nroutes = nm_setting_ip_config_get_num_routes(s_ip); for (i = 0; i < nroutes; i++) { - NMIPRoute * s_route = nm_setting_ip_config_get_route(s_ip, i); + NMIPRoute *s_route = nm_setting_ip_config_get_route(s_ip, i); NMPlatformIPXRoute r; NMIPAddr network_bin; NMIPAddr next_hop_bin; @@ -2718,7 +2718,7 @@ _init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *co NML3ConfigData * nm_l3_config_data_new_from_connection(NMDedupMultiIndex *multi_idx, int ifindex, - NMConnection * connection) + NMConnection *connection) { NML3ConfigData *self; NMSettingProxy *s_proxy; @@ -2778,14 +2778,14 @@ sort_captured_addresses_6(const CList *lst_a, const CList *lst_b, gconstpointer } static void -_init_from_platform(NML3ConfigData * self, +_init_from_platform(NML3ConfigData *self, int addr_family, - NMPlatform * platform, + NMPlatform *platform, NMSettingIP6ConfigPrivacy ipv6_privacy_rfc4941) { const int IS_IPv4 = NM_IS_IPv4(addr_family); const NMDedupMultiHeadEntry *head_entry; - const NMPObject * plobj = NULL; + const NMPObject *plobj = NULL; NMDedupMultiIter iter; nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); @@ -2828,9 +2828,9 @@ _init_from_platform(NML3ConfigData * self, } NML3ConfigData * -nm_l3_config_data_new_from_platform(NMDedupMultiIndex * multi_idx, +nm_l3_config_data_new_from_platform(NMDedupMultiIndex *multi_idx, int ifindex, - NMPlatform * platform, + NMPlatform *platform, NMSettingIP6ConfigPrivacy ipv6_privacy_rfc4941) { NML3ConfigData *self; @@ -2853,13 +2853,13 @@ nm_l3_config_data_new_from_platform(NMDedupMultiIndex * multi_idx, /*****************************************************************************/ void -nm_l3_config_data_merge(NML3ConfigData * self, +nm_l3_config_data_merge(NML3ConfigData *self, const NML3ConfigData *src, NML3ConfigMergeFlags merge_flags, - const guint32 * default_route_table_x /* length 2, for IS_IPv4 */, - const guint32 * default_route_metric_x /* length 2, for IS_IPv4 */, - const guint32 * default_route_penalty_x /* length 2, for IS_IPv4 */, - const int * default_dns_priority_x /* length 2, for IS_IPv4 */, + const guint32 *default_route_table_x /* length 2, for IS_IPv4 */, + const guint32 *default_route_metric_x /* length 2, for IS_IPv4 */, + const guint32 *default_route_penalty_x /* length 2, for IS_IPv4 */, + const int *default_dns_priority_x /* length 2, for IS_IPv4 */, NML3ConfigMergeHookAddObj hook_add_obj, gpointer hook_user_data) { @@ -2870,7 +2870,7 @@ nm_l3_config_data_merge(NML3ConfigData * self, static const int x_default_dns_priority_x[2] = {NM_DNS_PRIORITY_DEFAULT_NORMAL, NM_DNS_PRIORITY_DEFAULT_NORMAL}; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; int IS_IPv4; nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); @@ -2904,9 +2904,9 @@ nm_l3_config_data_merge(NML3ConfigData * self, const NMPlatformIPAddress *a_src = NMP_OBJECT_CAST_IP_ADDRESS(obj); NMPlatformIPXAddress a; NML3ConfigMergeHookResult hook_result = { - .ip4acd_not_ready = NM_OPTION_BOOL_DEFAULT, - .assume_config_once = NM_OPTION_BOOL_DEFAULT, - .force_commit = NM_OPTION_BOOL_DEFAULT, + .ip4acd_not_ready = NM_OPTION_BOOL_DEFAULT, + .assume_config_once = NM_OPTION_BOOL_DEFAULT, + .force_commit = NM_OPTION_BOOL_DEFAULT, }; #define _ensure_a() \ @@ -2966,7 +2966,7 @@ nm_l3_config_data_merge(NML3ConfigData * self, src, &obj, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { - const NMPlatformIPRoute * r_src = NMP_OBJECT_CAST_IP_ROUTE(obj); + const NMPlatformIPRoute *r_src = NMP_OBJECT_CAST_IP_ROUTE(obj); NMPlatformIPXRoute r; NML3ConfigMergeHookResult hook_result = { .ip4acd_not_ready = NM_OPTION_BOOL_DEFAULT, diff --git a/src/core/nm-l3-config-data.h b/src/core/nm-l3-config-data.h index b96317a89c..8df46ea758 100644 --- a/src/core/nm-l3-config-data.h +++ b/src/core/nm-l3-config-data.h @@ -128,11 +128,11 @@ NML3ConfigData *nm_l3_config_data_new_clone(const NML3ConfigData *src, int ifind NML3ConfigData *nm_l3_config_data_new_from_connection(NMDedupMultiIndex *multi_idx, int ifindex, - NMConnection * connection); + NMConnection *connection); -NML3ConfigData *nm_l3_config_data_new_from_platform(NMDedupMultiIndex * multi_idx, +NML3ConfigData *nm_l3_config_data_new_from_platform(NMDedupMultiIndex *multi_idx, int ifindex, - NMPlatform * platform, + NMPlatform *platform, NMSettingIP6ConfigPrivacy ipv6_privacy_rfc4941); typedef struct { @@ -141,18 +141,18 @@ typedef struct { NMOptionBool force_commit; } NML3ConfigMergeHookResult; -typedef gboolean (*NML3ConfigMergeHookAddObj)(const NML3ConfigData * l3cd, - const NMPObject * obj, +typedef gboolean (*NML3ConfigMergeHookAddObj)(const NML3ConfigData *l3cd, + const NMPObject *obj, NML3ConfigMergeHookResult *result, gpointer user_data); -void nm_l3_config_data_merge(NML3ConfigData * self, +void nm_l3_config_data_merge(NML3ConfigData *self, const NML3ConfigData *src, NML3ConfigMergeFlags merge_flags, const guint32 *default_route_table_x /* length 2, for IS_IPv4 */, const guint32 *default_route_metric_x /* length 2, for IS_IPv4 */, const guint32 *default_route_penalty_x /* length 2, for IS_IPv4 */, - const int * default_dns_priority_x /* length 2, for IS_IPv4 */, + const int *default_dns_priority_x /* length 2, for IS_IPv4 */, NML3ConfigMergeHookAddObj hook_add_obj, gpointer hook_user_data); @@ -161,7 +161,7 @@ GPtrArray *nm_l3_config_data_get_blacklisted_ip4_routes(const NML3ConfigData *se void nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_family); -void nm_l3_config_data_add_dependent_device_routes(NML3ConfigData * self, +void nm_l3_config_data_add_dependent_device_routes(NML3ConfigData *self, int addr_family, guint32 route_table, guint32 route_metric, @@ -170,8 +170,8 @@ void nm_l3_config_data_add_dependent_device_routes(NML3ConfigData * self, /*****************************************************************************/ void nm_l3_config_data_log(const NML3ConfigData *self, - const char * title, - const char * prefix, + const char *title, + const char *prefix, NMLogLevel log_level, NMLogDomain log_domain); @@ -223,20 +223,20 @@ const NMDedupMultiIdxType *nm_l3_config_data_lookup_index(const NML3ConfigData * NMPObjectType obj_type); const NMDedupMultiEntry *nm_l3_config_data_lookup_obj(const NML3ConfigData *self, - const NMPObject * obj); + const NMPObject *obj); const NMPlatformIP4Address *nm_l3_config_data_lookup_address_4(const NML3ConfigData *self, in_addr_t addr, guint8 plen, in_addr_t peer_addr); -const NMPlatformIP6Address *nm_l3_config_data_lookup_address_6(const NML3ConfigData * self, +const NMPlatformIP6Address *nm_l3_config_data_lookup_address_6(const NML3ConfigData *self, const struct in6_addr *addr); const NMDedupMultiEntry *nm_l3_config_data_lookup_route_obj(const NML3ConfigData *self, - const NMPObject * needle); + const NMPObject *needle); -const NMDedupMultiEntry *nm_l3_config_data_lookup_route(const NML3ConfigData * self, +const NMDedupMultiEntry *nm_l3_config_data_lookup_route(const NML3ConfigData *self, int addr_family, const NMPlatformIPRoute *needle); @@ -346,7 +346,7 @@ nmtst_l3_config_data_get_route_at_6(const NML3ConfigData *self, guint i) NML3ConfigDatFlags nm_l3_config_data_get_flags(const NML3ConfigData *self); -void nm_l3_config_data_set_flags_full(NML3ConfigData * self, +void nm_l3_config_data_set_flags_full(NML3ConfigData *self, NML3ConfigDatFlags flags, NML3ConfigDatFlags mask); @@ -368,17 +368,17 @@ const NMPObject *nm_l3_config_data_get_first_obj(const NML3ConfigData *self, NMPObjectType obj_type, gboolean (*predicate)(const NMPObject *obj)); -gboolean nm_l3_config_data_add_address_full(NML3ConfigData * self, +gboolean nm_l3_config_data_add_address_full(NML3ConfigData *self, int addr_family, - const NMPObject * obj_new, + const NMPObject *obj_new, const NMPlatformIPAddress *pl_new, NML3ConfigAddFlags add_flags, - const NMPObject ** out_obj_new); + const NMPObject **out_obj_new); static inline gboolean -nm_l3_config_data_add_address(NML3ConfigData * self, +nm_l3_config_data_add_address(NML3ConfigData *self, int addr_family, - const NMPObject * obj_new, + const NMPObject *obj_new, const NMPlatformIPAddress *pl_new) { return nm_l3_config_data_add_address_full(self, @@ -401,18 +401,18 @@ nm_l3_config_data_add_address_6(NML3ConfigData *self, const NMPlatformIP6Address return nm_l3_config_data_add_address(self, AF_INET6, NULL, NM_PLATFORM_IP_ADDRESS_CAST(addr)); } -gboolean nm_l3_config_data_add_route_full(NML3ConfigData * self, +gboolean nm_l3_config_data_add_route_full(NML3ConfigData *self, int addr_family, - const NMPObject * obj_new, + const NMPObject *obj_new, const NMPlatformIPRoute *pl_new, NML3ConfigAddFlags add_flags, - const NMPObject ** out_obj_new, - gboolean * out_changed_best_default_route); + const NMPObject **out_obj_new, + gboolean *out_changed_best_default_route); static inline gboolean -nm_l3_config_data_add_route(NML3ConfigData * self, +nm_l3_config_data_add_route(NML3ConfigData *self, int addr_family, - const NMPObject * obj_new, + const NMPObject *obj_new, const NMPlatformIPRoute *pl_new) { return nm_l3_config_data_add_route_full(self, @@ -449,13 +449,13 @@ gboolean nm_l3_config_data_set_llmnr(NML3ConfigData *self, NMSettingConnectionLl NMSettingConnectionDnsOverTls nm_l3_config_data_get_dns_over_tls(const NML3ConfigData *self); -gboolean nm_l3_config_data_set_dns_over_tls(NML3ConfigData * self, +gboolean nm_l3_config_data_set_dns_over_tls(NML3ConfigData *self, NMSettingConnectionDnsOverTls dns_over_tls); NMIPRouteTableSyncMode nm_l3_config_data_get_route_table_sync(const NML3ConfigData *self, int addr_family); -gboolean nm_l3_config_data_set_route_table_sync(NML3ConfigData * self, +gboolean nm_l3_config_data_set_route_table_sync(NML3ConfigData *self, int addr_family, NMIPRouteTableSyncMode route_table_sync); @@ -487,7 +487,7 @@ gboolean nm_l3_config_data_add_wins(NML3ConfigData *self, in_addr_t wins); gconstpointer nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, guint *out_len); -gboolean nm_l3_config_data_add_nameserver(NML3ConfigData * self, +gboolean nm_l3_config_data_add_nameserver(NML3ConfigData *self, int addr_family, gconstpointer /* (const NMIPAddr *) */ nameserver); @@ -538,7 +538,7 @@ nm_l3_config_data_set_dns_priority(NML3ConfigData *self, int addr_family, int dn NMSettingIP6ConfigPrivacy nm_l3_config_data_get_ip6_privacy(const NML3ConfigData *self); -gboolean nm_l3_config_data_set_ip6_privacy(NML3ConfigData * self, +gboolean nm_l3_config_data_set_ip6_privacy(NML3ConfigData *self, NMSettingIP6ConfigPrivacy ip6_privacy); NMProxyConfigMethod nm_l3_config_data_get_proxy_method(const NML3ConfigData *self); @@ -561,11 +561,11 @@ gboolean nm_l3_config_data_get_ndisc_hop_limit(const NML3ConfigData *self, int * gboolean nm_l3_config_data_set_ndisc_hop_limit(NML3ConfigData *self, int val); gboolean nm_l3_config_data_get_ndisc_reachable_time_msec(const NML3ConfigData *self, - guint32 * out_val); + guint32 *out_val); gboolean nm_l3_config_data_set_ndisc_reachable_time_msec(NML3ConfigData *self, guint32 val); gboolean nm_l3_config_data_get_ndisc_retrans_timer_msec(const NML3ConfigData *self, - guint32 * out_val); + guint32 *out_val); gboolean nm_l3_config_data_set_ndisc_retrans_timer_msec(NML3ConfigData *self, guint32 val); struct _NMDhcpLease *nm_l3_config_data_get_dhcp_lease(const NML3ConfigData *self, int addr_family); @@ -575,7 +575,7 @@ nm_l3_config_data_set_dhcp_lease(NML3ConfigData *self, int addr_family, struct _ gboolean nm_l3_config_data_set_dhcp_lease_from_options(NML3ConfigData *self, int addr_family, - GHashTable * options_take); + GHashTable *options_take); static inline const NMIPAddr * nmtst_l3_config_data_get_best_gateway(const NML3ConfigData *self, int addr_family) diff --git a/src/core/nm-l3-ipv4ll.c b/src/core/nm-l3-ipv4ll.c index eb9ceb9b85..e5d0e85767 100644 --- a/src/core/nm-l3-ipv4ll.c +++ b/src/core/nm-l3-ipv4ll.c @@ -31,16 +31,16 @@ struct _NML3IPv4LLRegistration { G_STATIC_ASSERT(G_STRUCT_OFFSET(NML3IPv4LLRegistration, self) == 0); struct _NML3IPv4LL { - NML3Cfg * l3cfg; + NML3Cfg *l3cfg; int ref_count; in_addr_t addr; guint reg_timeout_msec; CList reg_lst_head; NML3CfgCommitTypeHandle *l3cfg_commit_handle; - GSource * state_change_on_idle_source; - GSource * timed_out_source; - const NML3ConfigData * l3cd; - const NMPObject * plobj; + GSource *state_change_on_idle_source; + GSource *timed_out_source; + const NML3ConfigData *l3cd; + const NMPObject *plobj; struct { nm_le64_t value; nm_le64_t generation; @@ -202,7 +202,7 @@ _ipv4ll_emit_signal_notify(NML3IPv4LL *self) /*****************************************************************************/ static NML3IPv4LLRegistration * -_registration_update(NML3IPv4LL * self, +_registration_update(NML3IPv4LL *self, NML3IPv4LLRegistration *reg, gboolean add, guint timeout_msec) @@ -503,9 +503,9 @@ gen_addr: static void _ipv4ll_update_link(NML3IPv4LL *self, const NMPObject *plobj) { - char sbuf[ETH_ALEN * 3]; + char sbuf[ETH_ALEN * 3]; nm_auto_nmpobj const NMPObject *pllink_old = NULL; - const NMEtherAddr * mac_new; + const NMEtherAddr *mac_new; gboolean changed; if (self->plobj == plobj) @@ -668,8 +668,8 @@ _ipv4ll_platform_find_addr(NML3IPv4LL *self, const NML3AcdAddrInfo **out_acd_inf const NMPlatformIP4Address *addr_without_acd_info = NULL; NMDedupMultiIter iter; NMPLookup lookup; - const NMPObject * obj; - const NML3AcdAddrInfo * acd_info; + const NMPObject *obj; + const NML3AcdAddrInfo *acd_info; const NMPlatformIP4Address *addr; nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP4_ADDRESS, nm_l3_ipv4ll_get_ifindex(self)); @@ -785,12 +785,12 @@ static void _ipv4ll_state_change(NML3IPv4LL *self, gboolean is_on_idle_handler) { nm_auto_unref_l3ipv4ll NML3IPv4LL *self_keep_alive = NULL; - const NMPlatformIP4Address * pladdr; - const NML3AcdAddrInfo * acd_info; + const NMPlatformIP4Address *pladdr; + const NML3AcdAddrInfo *acd_info; gboolean generate_new_addr; NML3IPv4LLState new_state; in_addr_t addr0; - NML3IPv4LLRegistration * reg; + NML3IPv4LLRegistration *reg; _ASSERT(self); diff --git a/src/core/nm-l3-ipv6ll.c b/src/core/nm-l3-ipv6ll.c index 17008c7ead..60da4ee8d7 100644 --- a/src/core/nm-l3-ipv6ll.c +++ b/src/core/nm-l3-ipv6ll.c @@ -29,13 +29,13 @@ NM_UTILS_LOOKUP_STR_DEFINE(nm_l3_ipv6ll_state_to_string, /*****************************************************************************/ struct _NML3IPv6LL { - NML3Cfg * l3cfg; + NML3Cfg *l3cfg; NML3CfgCommitTypeHandle *l3cfg_commit_handle; NML3IPv6LLNotifyFcn notify_fcn; gpointer user_data; - GSource * starting_on_idle_source; - GSource * wait_for_addr_source; - GSource * emit_changed_idle_source; + GSource *starting_on_idle_source; + GSource *wait_for_addr_source; + GSource *emit_changed_idle_source; gulong l3cfg_signal_notify_id; NML3IPv6LLState state; @@ -204,7 +204,7 @@ nm_l3_ipv6ll_get_l3cd(NML3IPv6LL *self) static gboolean _emit_changed_on_idle_cb(gpointer user_data) { - NML3IPv6LL * self = user_data; + NML3IPv6LL *self = user_data; const struct in6_addr *lladdr; NML3IPv6LLState state; char sbuf[INET6_ADDRSTRLEN]; @@ -286,7 +286,7 @@ _pladdr_find_ll(NML3IPv6LL *self, gboolean *out_cur_addr_failed) NMDedupMultiIter iter; NMPLookup lookup; const NMPlatformIP6Address *pladdr1 = NULL; - const NMPObject * obj; + const NMPObject *obj; const NMPlatformIP6Address *pladdr_ready = NULL; const NMPlatformIP6Address *pladdr_tentative = NULL; gboolean cur_addr_check = TRUE; @@ -620,11 +620,11 @@ _starting_on_idle_cb(gpointer user_data) /*****************************************************************************/ NML3IPv6LL * -_nm_l3_ipv6ll_new(NML3Cfg * l3cfg, +_nm_l3_ipv6ll_new(NML3Cfg *l3cfg, gboolean assume, NMUtilsStableType stable_type, - const char * ifname, - const char * network_id, + const char *ifname, + const char *network_id, const NMUtilsIPv6IfaceId *token_iid, guint32 route_table, NML3IPv6LLNotifyFcn notify_fcn, diff --git a/src/core/nm-l3-ipv6ll.h b/src/core/nm-l3-ipv6ll.h index 3a4f4b4376..c81757edb6 100644 --- a/src/core/nm-l3-ipv6ll.h +++ b/src/core/nm-l3-ipv6ll.h @@ -30,7 +30,7 @@ typedef enum _nm_packed { const char *nm_l3_ipv6ll_state_to_string(NML3IPv6LLState state); -typedef void (*NML3IPv6LLNotifyFcn)(NML3IPv6LL * ipv6ll, +typedef void (*NML3IPv6LLNotifyFcn)(NML3IPv6LL *ipv6ll, NML3IPv6LLState state, const struct in6_addr *lladdr, gpointer user_data); @@ -42,22 +42,22 @@ NM_IS_L3_IPV6LL(const NML3IPv6LL *self) return !!self; } -NML3IPv6LL *_nm_l3_ipv6ll_new(NML3Cfg * l3cfg, +NML3IPv6LL *_nm_l3_ipv6ll_new(NML3Cfg *l3cfg, gboolean assume, NMUtilsStableType stable_type, - const char * ifname, - const char * network_id, + const char *ifname, + const char *network_id, const NMUtilsIPv6IfaceId *token_iid, guint32 route_table, NML3IPv6LLNotifyFcn notify_fcn, gpointer user_data); static inline NML3IPv6LL * -nm_l3_ipv6ll_new_stable_privacy(NML3Cfg * l3cfg, +nm_l3_ipv6ll_new_stable_privacy(NML3Cfg *l3cfg, gboolean assume, NMUtilsStableType stable_type, - const char * ifname, - const char * network_id, + const char *ifname, + const char *network_id, guint32 route_table, NML3IPv6LLNotifyFcn notify_fcn, gpointer user_data) @@ -75,7 +75,7 @@ nm_l3_ipv6ll_new_stable_privacy(NML3Cfg * l3cfg, } static inline NML3IPv6LL * -nm_l3_ipv6ll_new_token(NML3Cfg * l3cfg, +nm_l3_ipv6ll_new_token(NML3Cfg *l3cfg, gboolean assume, const NMUtilsIPv6IfaceId *token_iid, guint32 route_table, diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 3c8b13ddba..18d08f5986 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -242,7 +242,7 @@ typedef struct _NML3CfgPrivate { CList acd_event_notify_lst_head; - NAcd * nacd; + NAcd *nacd; GSource *nacd_source; GSource *nacd_event_down_source; @@ -342,17 +342,17 @@ static void _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is static void _nm_l3cfg_emit_signal_notify_acd_event_all(NML3Cfg *self); static gboolean _acd_has_valid_link(const NMPObject *obj, - const guint8 ** out_addr_bin, - gboolean * out_acd_not_supported); + const guint8 **out_addr_bin, + gboolean *out_acd_not_supported); static void _l3_acd_nacd_instance_reset(NML3Cfg *self, NMTernary start_timer, gboolean acd_data_notify); -static void _l3_acd_data_state_change(NML3Cfg * self, - AcdData * acd_data, +static void _l3_acd_data_state_change(NML3Cfg *self, + AcdData *acd_data, AcdStateChangeMode mode, const NMEtherAddr *sender, - gint64 * p_now_msec); + gint64 *p_now_msec); static AcdData *_l3_acd_data_find(NML3Cfg *self, in_addr_t addr); @@ -424,7 +424,7 @@ nm_l3cfg_ipconfig_get(NML3Cfg *self, int addr_family) static void _ipconfig_toggle_notify(gpointer data, GObject *object, gboolean is_last_ref) { - NML3Cfg * self = NM_L3CFG(data); + NML3Cfg *self = NM_L3CFG(data); NMIPConfig *ipconfig = NM_IP_CONFIG(object); if (!is_last_ref) { @@ -492,13 +492,13 @@ nm_l3cfg_is_vrf(const NML3Cfg *self) static const char * _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data, - char * sbuf, + char *sbuf, gsize sbuf_size) { char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; char sbuf100[100]; char sbufobf[NM_HASH_OBFUSCATE_PTR_STR_BUF_SIZE]; - char * s = sbuf; + char *s = sbuf; gsize l = sbuf_size; in_addr_t addr4; @@ -586,7 +586,7 @@ _nm_l3cfg_emit_signal_notify_simple(NML3Cfg *self, NML3ConfigNotifyType notify_t } static void -_nm_l3cfg_emit_signal_notify_l3cd_changed(NML3Cfg * self, +_nm_l3cfg_emit_signal_notify_l3cd_changed(NML3Cfg *self, const NML3ConfigData *l3cd_old, const NML3ConfigData *l3cd_new, gboolean commited) @@ -615,7 +615,7 @@ _l3_changed_configs_set_dirty(NML3Cfg *self) /*****************************************************************************/ static void -_l3_acd_ipv4_addresses_on_link_update(NML3Cfg * self, +_l3_acd_ipv4_addresses_on_link_update(NML3Cfg *self, in_addr_t addr, gboolean add /* or else remove */) { @@ -673,7 +673,7 @@ static NAcdProbe * _nm_n_acd_data_probe_new(NML3Cfg *self, in_addr_t addr, guint32 timeout_msec, gpointer user_data) { nm_auto(n_acd_probe_config_freep) NAcdProbeConfig *probe_config = NULL; - NAcdProbe * probe; + NAcdProbe *probe; int r; nm_assert(self); @@ -705,7 +705,7 @@ _nm_n_acd_data_probe_new(NML3Cfg *self, in_addr_t addr, guint32 timeout_msec, gp G_STMT_START \ { \ if (NM_MORE_ASSERTS > 0) { \ - const NML3Cfg * _self = (self); \ + const NML3Cfg *_self = (self); \ const ObjStateData *_obj_state = (obj_state); \ \ nm_assert(_obj_state); \ @@ -943,7 +943,7 @@ _obj_states_update_all(NML3Cfg *self) for (i = 0; i < (int) G_N_ELEMENTS(obj_types); i++) { const NMPObjectType obj_type = obj_types[i]; NMDedupMultiIter o_iter; - const NMPObject * obj; + const NMPObject *obj; if (!self->priv.p->combined_l3cd_commited) continue; @@ -1003,7 +1003,7 @@ _obj_states_update_all(NML3Cfg *self) } typedef struct { - NML3Cfg * self; + NML3Cfg *self; NML3CfgCommitType commit_type; } ObjStatesSyncFilterData; @@ -1011,11 +1011,11 @@ static gboolean _obj_states_sync_filter(/* const NMDedupMultiObj * */ gconstpointer o, gpointer user_data) { char sbuf[sizeof(_nm_utils_to_string_buffer)]; - const NMPObject * obj = o; + const NMPObject *obj = o; const ObjStatesSyncFilterData *sync_filter_data = user_data; NMPObjectType obj_type; - ObjStateData * obj_state; - NML3Cfg * self; + ObjStateData *obj_state; + NML3Cfg *self; nm_assert(sync_filter_data); nm_assert(NM_IS_L3CFG(sync_filter_data->self)); @@ -1059,7 +1059,7 @@ _obj_states_sync_filter(/* const NMDedupMultiObj * */ gconstpointer o, gpointer } static void -_obj_state_zombie_lst_get_prune_lists(NML3Cfg * self, +_obj_state_zombie_lst_get_prune_lists(NML3Cfg *self, int addr_family, GPtrArray **out_addresses_prune, GPtrArray **out_routes_prune) @@ -1068,8 +1068,8 @@ _obj_state_zombie_lst_get_prune_lists(NML3Cfg * self, const NMPObjectType obj_type_route = NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4); const NMPObjectType obj_type_address = NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4); char sbuf[sizeof(_nm_utils_to_string_buffer)]; - ObjStateData * obj_state; - ObjStateData * obj_state_safe; + ObjStateData *obj_state; + ObjStateData *obj_state_safe; nm_assert(NM_IS_L3CFG(self)); nm_assert(out_addresses_prune && !*out_addresses_prune); @@ -1080,7 +1080,7 @@ _obj_state_zombie_lst_get_prune_lists(NML3Cfg * self, &self->priv.p->obj_state_zombie_lst_head, os_zombie_lst) { NMPObjectType obj_type; - GPtrArray ** p_a; + GPtrArray **p_a; nm_assert_obj_state(self, obj_state); nm_assert(obj_state->os_zombie_count > 0); @@ -1150,16 +1150,16 @@ static void _load_link(NML3Cfg *self, gboolean initial) { nm_auto_nmpobj const NMPObject *obj_old = NULL; - const NMPObject * obj; - const char * ifname; - const char * ifname_old; + const NMPObject *obj; + const char *ifname; + const char *ifname_old; gboolean nacd_changed; gboolean nacd_new_valid; gboolean nacd_old_valid; - const guint8 * nacd_old_addr = NULL; - const guint8 * nacd_new_addr = NULL; + const guint8 *nacd_old_addr = NULL; + const guint8 *nacd_new_addr = NULL; gboolean nacd_link_now_up; - AcdData * acd_data; + AcdData *acd_data; if (initial) { obj = nm_platform_link_get_obj(self->priv.platform, self->priv.ifindex, TRUE); @@ -1249,9 +1249,9 @@ _nm_l3cfg_notify_platform_change_on_idle(NML3Cfg *self, guint32 obj_type_flags) } void -_nm_l3cfg_notify_platform_change(NML3Cfg * self, +_nm_l3cfg_notify_platform_change(NML3Cfg *self, NMPlatformSignalChangeType change_type, - const NMPObject * obj) + const NMPObject *obj) { NML3ConfigNotifyData notify_data; NMPObjectType obj_type; @@ -1324,9 +1324,9 @@ _acd_data_free(AcdData *acd_data) } static guint -_acd_data_collect_tracks_data(const AcdData * acd_data, +_acd_data_collect_tracks_data(const AcdData *acd_data, NMTernary dirty_selector, - guint32 * out_best_acd_timeout_msec, + guint32 *out_best_acd_timeout_msec, NML3AcdDefendType *out_best_acd_defend_type) { NML3AcdDefendType best_acd_defend_type = _NM_L3_ACD_DEFEND_TYPE_NONE; @@ -1357,9 +1357,9 @@ _acd_data_collect_tracks_data(const AcdData * acd_data, } static NML3AcdAddrTrackInfo * -_acd_data_find_track(const AcdData * acd_data, +_acd_data_find_track(const AcdData *acd_data, const NML3ConfigData *l3cd, - const NMPObject * obj, + const NMPObject *obj, gconstpointer tag) { guint i; @@ -1378,11 +1378,11 @@ _acd_data_find_track(const AcdData * acd_data, static gboolean _acd_has_valid_link(const NMPObject *obj, - const guint8 ** out_addr_bin, - gboolean * out_acd_not_supported) + const guint8 **out_addr_bin, + gboolean *out_acd_not_supported) { const NMPlatformLink *link; - const guint8 * addr_bin; + const guint8 *addr_bin; gsize addr_len; if (!obj) { @@ -1437,8 +1437,8 @@ _l3_acd_nacd_event(int fd, GIOCondition condition, gpointer user_data) while (TRUE) { NMEtherAddr sender_addr_data; const NMEtherAddr *sender_addr; - AcdData * acd_data; - NAcdEvent * event; + AcdData *acd_data; + NAcdEvent *event; if (!self->priv.p->nacd) { /* In the loop we emit signals, where *anything* might happen. @@ -1612,8 +1612,8 @@ static NAcd * _l3_acd_nacd_instance_ensure(NML3Cfg *self, gboolean *out_acd_not_supported) { nm_auto(n_acd_config_freep) NAcdConfig *config = NULL; - nm_auto(n_acd_unrefp) NAcd * nacd = NULL; - const guint8 * addr_bin; + nm_auto(n_acd_unrefp) NAcd *nacd = NULL; + const guint8 *addr_bin; gboolean acd_not_supported; gboolean valid; int fd; @@ -1677,11 +1677,11 @@ failed_create_acd: } static NAcdProbe * -_l3_acd_nacd_instance_create_probe(NML3Cfg * self, +_l3_acd_nacd_instance_create_probe(NML3Cfg *self, in_addr_t addr, guint32 timeout_msec, gpointer user_data, - gboolean * out_acd_not_supported, + gboolean *out_acd_not_supported, const char **out_failure_reason) { gboolean acd_not_supported; @@ -1777,17 +1777,17 @@ _l3_acd_data_defendconflict_warning_ratelimited(AcdData *acd_data, gint64 *p_now } static void -_l3_acd_data_add(NML3Cfg * self, +_l3_acd_data_add(NML3Cfg *self, const NML3ConfigData *l3cd, - const NMPObject * obj, + const NMPObject *obj, gconstpointer tag, NML3AcdDefendType acd_defend_type, guint32 acd_timeout_msec) { in_addr_t addr = NMP_OBJECT_CAST_IP4_ADDRESS(obj)->address; NML3AcdAddrTrackInfo *acd_track; - AcdData * acd_data; - const char * track_mode; + AcdData *acd_data; + const char *track_mode; char sbuf100[100]; if (ACD_ADDR_SKIP(addr)) @@ -1873,7 +1873,7 @@ _l3_acd_data_add(NML3Cfg * self, } static void -_l3_acd_data_add_all(NML3Cfg * self, +_l3_acd_data_add_all(NML3Cfg *self, const L3ConfigData *const *infos, guint infos_len, gboolean reapply) @@ -1895,7 +1895,7 @@ _l3_acd_data_add_all(NML3Cfg * self, for (i_info = 0; i_info < infos_len; i_info++) { const L3ConfigData *info = infos[i_info]; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; nm_l3_config_data_iter_obj_for_each (&iter, info->l3cd, &obj, NMP_OBJECT_TYPE_IP4_ADDRESS) { _l3_acd_data_add(self, @@ -1977,7 +1977,7 @@ _nm_l3cfg_emit_signal_notify_acd_event(NML3Cfg *self, AcdData *acd_data) { gs_free NML3AcdAddrTrackInfo *track_infos_clone = NULL; NML3ConfigNotifyData notify_data; - NML3AcdAddrInfo * info; + NML3AcdAddrInfo *info; guint i; nm_assert(acd_data); @@ -1986,7 +1986,7 @@ _nm_l3cfg_emit_signal_notify_acd_event(NML3Cfg *self, AcdData *acd_data) notify_data.notify_type = NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT; notify_data.acd_event = (typeof(notify_data.acd_event)){ - .info = acd_data->info, + .info = acd_data->info, }; /* we need to clone the track-data, because the callee is allowed to add/remove @@ -2030,7 +2030,7 @@ static void _nm_l3cfg_emit_signal_notify_acd_event_all(NML3Cfg *self) { gs_unref_object NML3Cfg *self_keep_alive = NULL; - AcdData * acd_data; + AcdData *acd_data; while ((acd_data = c_list_first_entry(&self->priv.p->acd_event_notify_lst_head, AcdData, @@ -2042,11 +2042,11 @@ _nm_l3cfg_emit_signal_notify_acd_event_all(NML3Cfg *self) } } -_nm_printf(5, 6) static void _l3_acd_data_state_set_full(NML3Cfg * self, - AcdData * acd_data, +_nm_printf(5, 6) static void _l3_acd_data_state_set_full(NML3Cfg *self, + AcdData *acd_data, NML3AcdAddrState state, gboolean allow_commit, - const char * format, + const char *format, ...) { NML3AcdAddrState old_state; @@ -2092,8 +2092,8 @@ _nm_printf(5, 6) static void _l3_acd_data_state_set_full(NML3Cfg * self, } static void -_l3_acd_data_state_set(NML3Cfg * self, - AcdData * acd_data, +_l3_acd_data_state_set(NML3Cfg *self, + AcdData *acd_data, NML3AcdAddrState state, gboolean allow_commit) { @@ -2101,17 +2101,17 @@ _l3_acd_data_state_set(NML3Cfg * self, } static void -_l3_acd_data_state_change(NML3Cfg * self, - AcdData * acd_data, +_l3_acd_data_state_change(NML3Cfg *self, + AcdData *acd_data, AcdStateChangeMode state_change_mode, const NMEtherAddr *sender_addr, - gint64 * p_now_msec) + gint64 *p_now_msec) { guint32 acd_timeout_msec; NML3AcdDefendType acd_defend_type; gint64 now_msec; - const char * log_reason; + const char *log_reason; char sbuf256[256]; char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; @@ -2647,7 +2647,7 @@ handle_start_probing: if (TRUE) { const NML3AcdAddrState orig_state = acd_data->info.state; nm_auto(n_acd_probe_freep) NAcdProbe *probe = NULL; - const char * failure_reason; + const char *failure_reason; gboolean acd_not_supported; nm_assert(NM_IN_SET(acd_data->info.state, @@ -2767,7 +2767,7 @@ handle_start_defending: if (!acd_data->nacd_probe) { const char *failure_reason; - NAcdProbe * probe; + NAcdProbe *probe; if (acd_data->acd_data_timeout_source) { /* we already failed to create a probe. We are ratelimited to retry, but @@ -2864,11 +2864,11 @@ nm_l3cfg_get_acd_addr_info(NML3Cfg *self, in_addr_t addr) /*****************************************************************************/ gboolean -nm_l3cfg_check_ready(NML3Cfg * self, - const NML3ConfigData * l3cd, +nm_l3cfg_check_ready(NML3Cfg *self, + const NML3ConfigData *l3cd, int addr_family, NML3CfgCheckReadyFlags flags, - gboolean * acd_used) + gboolean *acd_used) { NMDedupMultiIter iter; const NMPObject *obj; @@ -2947,7 +2947,7 @@ static gboolean _l3_commit_on_idle_cb(gpointer user_data) { _nm_unused gs_unref_object NML3Cfg *self_keep_alive = NULL; - NML3Cfg * self = user_data; + NML3Cfg *self = user_data; NML3CfgCommitType commit_type; commit_type = self->priv.p->commit_on_idle_type; @@ -3026,7 +3026,7 @@ nm_l3cfg_commit_on_idle_is_scheduled(NML3Cfg *self) (&g_array_index((l3_config_datas), L3ConfigData, (idx))) static gssize -_l3_config_datas_find_next(GArray * l3_config_datas, +_l3_config_datas_find_next(GArray *l3_config_datas, guint start_idx, gconstpointer needle_tag, const NML3ConfigData *needle_l3cd) @@ -3107,7 +3107,7 @@ nm_l3cfg_mark_config_dirty(NML3Cfg *self, gconstpointer tag, gboolean dirty) } gboolean -nm_l3cfg_add_config(NML3Cfg * self, +nm_l3cfg_add_config(NML3Cfg *self, gconstpointer tag, gboolean replace_same_tag, const NML3ConfigData *l3cd, @@ -3273,7 +3273,7 @@ nm_l3cfg_add_config(NML3Cfg * self, } static gboolean -_l3cfg_remove_config(NML3Cfg * self, +_l3cfg_remove_config(NML3Cfg *self, gconstpointer tag, gboolean only_dirty, const NML3ConfigData *l3cd) @@ -3343,7 +3343,7 @@ nm_l3cfg_remove_config_all_dirty(NML3Cfg *self, gconstpointer tag) /*****************************************************************************/ typedef struct { - NML3Cfg * self; + NML3Cfg *self; gconstpointer tag; bool assume_config_once; bool to_commit; @@ -3351,14 +3351,14 @@ typedef struct { } L3ConfigMergeHookAddObjData; static gboolean -_l3_hook_add_obj_cb(const NML3ConfigData * l3cd, - const NMPObject * obj, +_l3_hook_add_obj_cb(const NML3ConfigData *l3cd, + const NMPObject *obj, NML3ConfigMergeHookResult *hook_result, gpointer user_data) { const L3ConfigMergeHookAddObjData *hook_data = user_data; - NML3Cfg * self = hook_data->self; - AcdData * acd_data; + NML3Cfg *self = hook_data->self; + AcdData *acd_data; in_addr_t addr; gboolean acd_bad = FALSE; @@ -3430,21 +3430,21 @@ out_ip4_address: } static void -_l3cfg_update_combined_config(NML3Cfg * self, +_l3cfg_update_combined_config(NML3Cfg *self, gboolean to_commit, gboolean reapply, const NML3ConfigData **out_old /* transfer reference */, - gboolean * out_changed_combined_l3cd) + gboolean *out_changed_combined_l3cd) { - nm_auto_unref_l3cd const NML3ConfigData *l3cd_commited_old = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; - nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - gs_free const L3ConfigData **l3_config_datas_free = NULL; - const L3ConfigData ** l3_config_datas_arr; - guint l3_config_datas_len; - guint i; - gboolean merged_changed = FALSE; - gboolean commited_changed = FALSE; + nm_auto_unref_l3cd const NML3ConfigData *l3cd_commited_old = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + gs_free const L3ConfigData **l3_config_datas_free = NULL; + const L3ConfigData **l3_config_datas_arr; + guint l3_config_datas_len; + guint i; + gboolean merged_changed = FALSE; + gboolean commited_changed = FALSE; nm_assert(NM_IS_L3CFG(self)); nm_assert(!out_old || !*out_old); @@ -3608,7 +3608,7 @@ out: static gboolean _routes_temporary_not_available_timeout(gpointer user_data) { - NML3Cfg * self = NM_L3CFG(user_data); + NML3Cfg *self = NM_L3CFG(user_data); ObjStateData *obj_state; gint64 now_msec; gint64 expiry_msec; @@ -3647,12 +3647,12 @@ _routes_temporary_not_available_timeout(gpointer user_data) } static gboolean -_routes_temporary_not_available_update(NML3Cfg * self, +_routes_temporary_not_available_update(NML3Cfg *self, int addr_family, GPtrArray *routes_temporary_not_available_arr) { - ObjStateData * obj_state; - ObjStateData * obj_state_safe; + ObjStateData *obj_state; + ObjStateData *obj_state_safe; gint64 now_msec; gboolean prune_all = FALSE; gboolean success = TRUE; @@ -3783,7 +3783,7 @@ _l3_commit_ndisc_params(NML3Cfg *self, NML3CfgCommitType commit_type) guint32 reachable = 0; guint32 retrans = 0; int hop_limit = 0; - const char * ifname; + const char *ifname; if (commit_type < NM_L3_CFG_COMMIT_TYPE_UPDATE) { self->priv.p->ndisc_reachable_time_msec_set = FALSE; @@ -3841,7 +3841,7 @@ _l3_commit_ip6_privacy(NML3Cfg *self, NML3CfgCommitType commit_type) { NMSettingIP6ConfigPrivacy ip6_privacy; NMSettingIP6ConfigPrivacy ip6_privacy_set_before; - const char * ifname; + const char *ifname; if (commit_type < NM_L3_CFG_COMMIT_TYPE_UPDATE) ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; @@ -4008,13 +4008,13 @@ _l3_commit_ip6_token(NML3Cfg *self, NML3CfgCommitType commit_type) } static gboolean -_l3_commit_one(NML3Cfg * self, +_l3_commit_one(NML3Cfg *self, int addr_family, NML3CfgCommitType commit_type, gboolean changed_combined_l3cd, const NML3ConfigData *l3cd_old) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); gs_unref_ptrarray GPtrArray *addresses = NULL; gs_unref_ptrarray GPtrArray *routes = NULL; gs_unref_ptrarray GPtrArray *addresses_prune = NULL; @@ -4038,7 +4038,7 @@ _l3_commit_one(NML3Cfg * self, _l3_cfg_commit_type_to_string(commit_type, sbuf_commit_type, sizeof(sbuf_commit_type))); if (self->priv.p->combined_l3cd_commited) { - const NMDedupMultiHeadEntry * head_entry; + const NMDedupMultiHeadEntry *head_entry; const ObjStatesSyncFilterData sync_filter_data = { .self = self, .commit_type = commit_type, @@ -4115,8 +4115,8 @@ _l3_commit_one(NML3Cfg * self, static void _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle) { - _nm_unused gs_unref_object NML3Cfg *self_keep_alive = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; + _nm_unused gs_unref_object NML3Cfg *self_keep_alive = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; NML3CfgCommitType commit_type_auto; gboolean commit_type_from_auto = FALSE; gboolean is_sticky_update = FALSE; @@ -4240,10 +4240,10 @@ nm_l3cfg_commit_type_get(NML3Cfg *self) * is %NM_L3_CFG_COMMIT_TYPE_NONE. */ NML3CfgCommitTypeHandle * -nm_l3cfg_commit_type_register(NML3Cfg * self, +nm_l3cfg_commit_type_register(NML3Cfg *self, NML3CfgCommitType commit_type, NML3CfgCommitTypeHandle *existing_handle, - const char * source) + const char *source) { NML3CfgCommitTypeHandle *handle; NML3CfgCommitTypeHandle *h; @@ -4373,7 +4373,7 @@ gboolean nm_l3cfg_has_commited_ip6_addresses_pending_dad(NML3Cfg *self) { const NML3ConfigData *l3cd; - const NMPObject * plat_obj; + const NMPObject *plat_obj; NMPLookup plat_lookup; NMDedupMultiIter iter; @@ -4395,7 +4395,7 @@ nm_l3cfg_has_commited_ip6_addresses_pending_dad(NML3Cfg *self) nm_platform_iter_obj_for_each (&iter, self->priv.platform, &plat_lookup, &plat_obj) { const NMPlatformIP6Address *plat_addr = NMP_OBJECT_CAST_IP6_ADDRESS(plat_obj); - const NMDedupMultiEntry * l3cd_entry; + const NMDedupMultiEntry *l3cd_entry; if (!NM_FLAGS_HAS(plat_addr->n_ifa_flags, IFA_F_TENTATIVE) || NM_FLAGS_ANY(plat_addr->n_ifa_flags, IFA_F_DADFAILED | IFA_F_OPTIMISTIC)) diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h index 768794389c..a7d89a2618 100644 --- a/src/core/nm-l3cfg.h +++ b/src/core/nm-l3cfg.h @@ -75,7 +75,7 @@ typedef enum _nm_packed { } NML3AcdAddrState; typedef struct { - const NMPObject * obj; + const NMPObject *obj; const NML3ConfigData *l3cd; gconstpointer tag; @@ -92,15 +92,15 @@ typedef struct { in_addr_t addr; guint n_track_infos; NML3AcdAddrState state; - NML3Cfg * l3cfg; + NML3Cfg *l3cfg; const NML3AcdAddrTrackInfo *track_infos; } NML3AcdAddrInfo; static inline const NML3AcdAddrTrackInfo * nm_l3_acd_addr_info_find_track_info(const NML3AcdAddrInfo *addr_info, gconstpointer tag, - const NML3ConfigData * l3cd, - const NMPObject * obj) + const NML3ConfigData *l3cd, + const NMPObject *obj) { guint i; const NML3AcdAddrTrackInfo *ti; @@ -179,7 +179,7 @@ typedef struct { } acd_event; struct { - const NMPObject * obj; + const NMPObject *obj; NMPlatformSignalChangeType change_type; } platform_change; @@ -199,10 +199,10 @@ struct _NML3Cfg { GObject parent; struct { struct _NML3CfgPrivate *p; - NMNetns * netns; - NMPlatform * platform; - const NMPObject * plobj; - const NMPObject * plobj_next; + NMNetns *netns; + NMPlatform *platform; + const NMPObject *plobj; + const NMPObject *plobj_next; int ifindex; } priv; }; @@ -219,9 +219,9 @@ gboolean nm_l3cfg_is_ready(NML3Cfg *self); void _nm_l3cfg_notify_platform_change_on_idle(NML3Cfg *self, guint32 obj_type_flags); -void _nm_l3cfg_notify_platform_change(NML3Cfg * self, +void _nm_l3cfg_notify_platform_change(NML3Cfg *self, NMPlatformSignalChangeType change_type, - const NMPObject * obj); + const NMPObject *obj); /*****************************************************************************/ @@ -305,7 +305,7 @@ void _nm_l3cfg_emit_signal_notify(NML3Cfg *self, const NML3ConfigNotifyData *not void nm_l3cfg_mark_config_dirty(NML3Cfg *self, gconstpointer tag, gboolean dirty); -gboolean nm_l3cfg_add_config(NML3Cfg * self, +gboolean nm_l3cfg_add_config(NML3Cfg *self, gconstpointer tag, gboolean replace_same_tag, const NML3ConfigData *l3cd, @@ -401,11 +401,11 @@ typedef enum { NM_L3CFG_CHECK_READY_FLAGS_IP6_DAD_READY = (1ull << 1), } NML3CfgCheckReadyFlags; -gboolean nm_l3cfg_check_ready(NML3Cfg * self, - const NML3ConfigData * l3cd, +gboolean nm_l3cfg_check_ready(NML3Cfg *self, + const NML3ConfigData *l3cd, int addr_family, NML3CfgCheckReadyFlags flags, - gboolean * acd_used); + gboolean *acd_used); /*****************************************************************************/ @@ -413,10 +413,10 @@ NML3CfgCommitType nm_l3cfg_commit_type_get(NML3Cfg *self); typedef struct _NML3CfgCommitTypeHandle NML3CfgCommitTypeHandle; -NML3CfgCommitTypeHandle *nm_l3cfg_commit_type_register(NML3Cfg * self, +NML3CfgCommitTypeHandle *nm_l3cfg_commit_type_register(NML3Cfg *self, NML3CfgCommitType commit_type, NML3CfgCommitTypeHandle *existing_handle, - const char * source); + const char *source); void nm_l3cfg_commit_type_unregister(NML3Cfg *self, NML3CfgCommitTypeHandle *handle); diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index ebd68f7604..0066b8d45b 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -59,9 +59,9 @@ typedef struct { gboolean hw_enabled; RfKillType rtype; NMConfigRunStatePropertyType key; - const char * desc; - const char * prop; - const char * hw_prop; + const char *desc; + const char *prop; + const char *hw_prop; } RadioState; typedef enum { @@ -73,7 +73,7 @@ typedef enum { typedef struct { CList async_op_lst; - NMManager * self; + NMManager *self; AsyncOpType async_op_type; union { struct { @@ -83,8 +83,8 @@ typedef struct { GDBusMethodInvocation *invocation; } activate_user; struct { - GDBusMethodInvocation * invocation; - NMConnection * connection; + GDBusMethodInvocation *invocation; + NMConnection *connection; NMSettingsConnectionPersistMode persist_mode; bool is_volatile : 1; } add_and_activate; @@ -152,9 +152,9 @@ typedef struct { CList devices_lst_head; NMState state; - NMConfig * config; - NMConnectivity * concheck_mgr; - NMPolicy * policy; + NMConfig *config; + NMConnectivity *concheck_mgr; + NMPolicy *policy; NMHostnameManager *hostname_manager; struct { @@ -324,28 +324,28 @@ static gboolean add_device(NMManager *self, NMDevice *device, GError **error); static void _emit_device_added_removed(NMManager *self, NMDevice *device, gboolean is_added); -static NMActiveConnection *_new_active_connection(NMManager * self, +static NMActiveConnection *_new_active_connection(NMManager *self, gboolean is_vpn, - NMSettingsConnection * sett_conn, - NMConnection * incompl_conn, - NMConnection * applied, - const char * specific_object, - NMDevice * device, - NMAuthSubject * subject, + NMSettingsConnection *sett_conn, + NMConnection *incompl_conn, + NMConnection *applied, + const char *specific_object, + NMDevice *device, + NMAuthSubject *subject, NMActivationType activation_type, NMActivationReason activation_reason, NMActivationStateFlags initial_state_flags, - GError ** error); + GError **error); static void policy_activating_ac_changed(GObject *object, GParamSpec *pspec, gpointer user_data); -static gboolean find_master(NMManager * self, - NMConnection * connection, - NMDevice * device, +static gboolean find_master(NMManager *self, + NMConnection *connection, + NMDevice *device, NMSettingsConnection **out_master_connection, - NMDevice ** out_master_device, - NMActiveConnection ** out_master_ac, - GError ** error); + NMDevice **out_master_device, + NMActiveConnection **out_master_ac, + GError **error); static void nm_manager_update_state(NMManager *manager); @@ -363,35 +363,35 @@ static void active_connection_default_changed(NMActiveConnection *active, GParamSpec *pspec, NMManager *self); static void active_connection_parent_active(NMActiveConnection *active, NMActiveConnection *parent_ac, - NMManager * self); + NMManager *self); -static NMActiveConnection *active_connection_find(NMManager * self, - NMSettingsConnection * sett_conn, - const char * uuid, +static NMActiveConnection *active_connection_find(NMManager *self, + NMSettingsConnection *sett_conn, + const char *uuid, NMActiveConnectionState max_state, gboolean also_waiting_auth, - GPtrArray ** out_all_matching); + GPtrArray **out_all_matching); static NMConnectivity *concheck_get_mgr(NMManager *self); -static void _internal_activation_auth_done(NMManager * self, +static void _internal_activation_auth_done(NMManager *self, NMActiveConnection *active, gboolean success, - const char * error_desc); -static void _add_and_activate_auth_done(NMManager * self, + const char *error_desc); +static void _add_and_activate_auth_done(NMManager *self, AsyncOpType async_op_type, - NMActiveConnection * active, - NMConnection * connection, - GDBusMethodInvocation * invocation, + NMActiveConnection *active, + NMConnection *connection, + GDBusMethodInvocation *invocation, NMSettingsConnectionPersistMode persist_mode, gboolean is_volatile, gboolean success, - const char * error_desc); -static void _activation_auth_done(NMManager * self, - NMActiveConnection * active, + const char *error_desc); +static void _activation_auth_done(NMManager *self, + NMActiveConnection *active, GDBusMethodInvocation *invocation, gboolean success, - const char * error_desc); + const char *error_desc); /*****************************************************************************/ @@ -436,7 +436,7 @@ static void concheck_config_changed_cb(NMConnectivity *connectivity, NMManager *self) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; gboolean changed; concheck_enabled(self, &changed); @@ -479,8 +479,8 @@ _async_op_data_new_authorize_activate_internal(NMManager *self, NMActiveConnecti } static AsyncOpData * -_async_op_data_new_ac_auth_activate_user(NMManager * self, - NMActiveConnection * active_take, +_async_op_data_new_ac_auth_activate_user(NMManager *self, + NMActiveConnection *active_take, GDBusMethodInvocation *invocation_take) { AsyncOpData *async_op_data; @@ -496,11 +496,11 @@ _async_op_data_new_ac_auth_activate_user(NMManager * self, } static AsyncOpData * -_async_op_data_new_ac_auth_add_and_activate(NMManager * self, +_async_op_data_new_ac_auth_add_and_activate(NMManager *self, AsyncOpType async_op_type, - NMActiveConnection * active_take, - GDBusMethodInvocation * invocation_take, - NMConnection * connection_take, + NMActiveConnection *active_take, + GDBusMethodInvocation *invocation_take, + NMConnection *connection_take, NMSettingsConnectionPersistMode persist_mode, gboolean is_volatile) { @@ -526,7 +526,7 @@ _async_op_data_new_ac_auth_add_and_activate(NMManager * self static void _async_op_complete_ac_auth_cb(NMActiveConnection *active, gboolean success, - const char * error_desc, + const char *error_desc, gpointer user_data) { AsyncOpData *async_op_data = user_data; @@ -629,15 +629,15 @@ _device_route_metric_data_by_ifindex_equal(gconstpointer pa, gconstpointer pb) } static guint32 -_device_route_metric_get(NMManager * self, +_device_route_metric_get(NMManager *self, int ifindex, NMDeviceType device_type, gboolean lookup_only, - guint32 * out_aspired_metric) + guint32 *out_aspired_metric) { - NMManagerPrivate * priv; + NMManagerPrivate *priv; const DeviceRouteMetricData *d2; - DeviceRouteMetricData * data; + DeviceRouteMetricData *data; DeviceRouteMetricData data_lookup; const NMDedupMultiHeadEntry *all_links_head; NMPObject links_needle; @@ -664,7 +664,7 @@ _device_route_metric_get(NMManager * self, return 0; if (G_UNLIKELY(!priv->device_route_metrics)) { - const GHashTable * h; + const GHashTable *h; const NMConfigDeviceStateData *device_state; priv->device_route_metrics = @@ -810,7 +810,7 @@ nm_manager_device_route_metric_reserve(NMManager *self, int ifindex, NMDeviceTyp void nm_manager_device_route_metric_clear(NMManager *self, int ifindex) { - NMManagerPrivate * priv; + NMManagerPrivate *priv; DeviceRouteMetricData data_lookup; priv = NM_MANAGER_GET_PRIVATE(self); @@ -855,7 +855,7 @@ _delete_volatile_connection_do(NMManager *self, NMSettingsConnection *connection static gboolean active_connection_remove(NMManager *self, NMActiveConnection *active) { - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); gs_unref_object NMSettingsConnection *connection = NULL; gboolean notify; @@ -883,8 +883,8 @@ active_connection_remove(NMManager *self, NMActiveConnection *active) static gboolean _active_connection_cleanup(gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManager *self = NM_MANAGER(user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMActiveConnection *ac, *ac_safe; priv->ac_cleanup_id = 0; @@ -907,9 +907,9 @@ _active_connection_cleanup(gpointer user_data) static void active_connection_state_changed(NMActiveConnection *active, GParamSpec *pspec, NMManager *self) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMActiveConnectionState state; - NMSettingsConnection * con; + NMSettingsConnection *con; state = nm_active_connection_get_state(active); if (state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { @@ -982,17 +982,17 @@ nm_manager_get_active_connections(NMManager *manager) static NMActiveConnection * active_connection_find( - NMManager * self, - NMSettingsConnection * sett_conn, - const char * uuid, + NMManager *self, + NMSettingsConnection *sett_conn, + const char *uuid, NMActiveConnectionState max_state /* candidates in state @max_state will be found */, gboolean also_waiting_auth /* return also ACs waiting authorization */, - GPtrArray ** out_all_matching) + GPtrArray **out_all_matching) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMActiveConnection *ac; NMActiveConnection *best_ac = NULL; - GPtrArray * all = NULL; + GPtrArray *all = NULL; nm_assert(!sett_conn || NM_IS_SETTINGS_CONNECTION(sett_conn)); nm_assert(!out_all_matching || !*out_all_matching); @@ -1071,11 +1071,11 @@ active_connection_find( } static NMActiveConnection * -active_connection_find_by_connection(NMManager * self, - NMSettingsConnection * sett_conn, - NMConnection * connection, +active_connection_find_by_connection(NMManager *self, + NMSettingsConnection *sett_conn, + NMConnection *connection, NMActiveConnectionState max_state, - GPtrArray ** out_all_matching) + GPtrArray **out_all_matching) { nm_assert(NM_IS_MANAGER(self)); nm_assert(!sett_conn || NM_IS_SETTINGS_CONNECTION(sett_conn)); @@ -1100,7 +1100,7 @@ typedef struct { } GetActivatableConnectionsFilterData; static gboolean -_get_activatable_connections_filter(NMSettings * settings, +_get_activatable_connections_filter(NMSettings *settings, NMSettingsConnection *sett_conn, gpointer user_data) { @@ -1133,12 +1133,12 @@ NMSettingsConnection ** nm_manager_get_activatable_connections(NMManager *manager, gboolean for_auto_activation, gboolean sort, - guint * out_len) + guint *out_len) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(manager); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(manager); const GetActivatableConnectionsFilterData d = { - .self = manager, - .for_auto_activation = for_auto_activation, + .self = manager, + .for_auto_activation = for_auto_activation, }; return nm_settings_get_connections_clone( @@ -1153,7 +1153,7 @@ nm_manager_get_activatable_connections(NMManager *manager, static NMActiveConnection * active_connection_get_by_path(NMManager *self, const char *path) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMActiveConnection *ac; ac = nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)), path); @@ -1167,11 +1167,11 @@ active_connection_get_by_path(NMManager *self, const char *path) /*****************************************************************************/ static void -_config_changed_cb(NMConfig * config, - NMConfigData * config_data, +_config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, - NMManager * self) + NMConfigData *old_data, + NMManager *self) { g_object_freeze_notify(G_OBJECT(self)); @@ -1192,12 +1192,12 @@ _config_changed_cb(NMConfig * config, static void _reload_auth_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - GError * ret_error = NULL; + NMManager *self = NM_MANAGER(user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + GError *ret_error = NULL; NMAuthCallResult result; guint32 flags; - NMAuthSubject * subject; + NMAuthSubject *subject; char s_buf[60]; NMConfigChangeFlags reload_type = NM_CONFIG_CHANGE_NONE; @@ -1250,17 +1250,17 @@ _reload_auth_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer use } static void -impl_manager_reload(NMDBusObject * obj, +impl_manager_reload(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; + NMAuthChain *chain; guint32 flags; g_variant_get(parameters, "(u)", &flags); @@ -1285,7 +1285,7 @@ NMDevice * nm_manager_get_device_by_path(NMManager *self, const char *path) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; g_return_val_if_fail(path, NULL); @@ -1301,7 +1301,7 @@ NMDevice * nm_manager_get_device_by_ifindex(NMManager *self, int ifindex) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; if (ifindex > 0) { c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) { @@ -1317,8 +1317,8 @@ static NMDevice * find_device_by_permanent_hw_addr(NMManager *self, const char *hwaddr) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; - const char * device_addr; + NMDevice *device; + const char *device_addr; guint8 hwaddr_bin[_NM_UTILS_HWADDR_LEN_MAX]; gsize hwaddr_len; @@ -1339,7 +1339,7 @@ static NMDevice * find_device_by_ip_iface(NMManager *self, const char *iface) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; g_return_val_if_fail(iface, NULL); @@ -1366,14 +1366,14 @@ find_device_by_ip_iface(NMManager *self, const char *iface) * Returns: the matching #NMDevice */ static NMDevice * -find_device_by_iface(NMManager * self, - const char * iface, +find_device_by_iface(NMManager *self, + const char *iface, NMConnection *connection, NMConnection *slave) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * fallback = NULL; - NMDevice * candidate; + NMDevice *fallback = NULL; + NMDevice *candidate; g_return_val_if_fail(iface != NULL, NULL); @@ -1434,7 +1434,7 @@ _nm_state_to_string(NMState state) static NMState find_best_device_state(NMManager *manager) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(manager); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(manager); NMState best_state = NM_STATE_DISCONNECTED; NMActiveConnection *ac; @@ -1481,7 +1481,7 @@ static void nm_manager_update_metered(NMManager *self) { NMManagerPrivate *priv; - NMDevice * device; + NMDevice *device; NMMetered value = NM_METERED_UNKNOWN; g_return_if_fail(NM_IS_MANAGER(self)); @@ -1543,13 +1543,13 @@ nm_manager_update_state(NMManager *self) } static void -manager_device_state_changed(NMDevice * device, +manager_device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); + NMManager *self = NM_MANAGER(user_data); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); if (old_state == NM_DEVICE_STATE_UNMANAGED && new_state > NM_DEVICE_STATE_UNMANAGED) @@ -1593,8 +1593,8 @@ static void check_if_startup_complete(NMManager *self) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; - const char * reason; + NMDevice *device; + const char *reason; if (!priv->startup) return; @@ -1674,7 +1674,7 @@ static void _parent_notify_changed(NMManager *self, NMDevice *device, gboolean device_removed) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * candidate; + NMDevice *candidate; nm_assert(NM_IS_DEVICE(device)); @@ -1792,17 +1792,17 @@ nm_manager_get_state(NMManager *manager) /*****************************************************************************/ static NMDevice * -find_parent_device_for_connection(NMManager * self, - NMConnection * connection, +find_parent_device_for_connection(NMManager *self, + NMConnection *connection, NMDeviceFactory *cached_factory, - const char ** out_parent_spec) + const char **out_parent_spec) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - NMDeviceFactory * factory; - const char * parent_name = NULL; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMDeviceFactory *factory; + const char *parent_name = NULL; NMSettingsConnection *parent_connection; - NMDevice * parent, *first_compatible = NULL; - NMDevice * candidate; + NMDevice *parent, *first_compatible = NULL; + NMDevice *candidate; g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL); NM_SET_OUT(out_parent_spec, NULL); @@ -1875,15 +1875,15 @@ find_parent_device_for_connection(NMManager * self, * Returns: the expected interface name (caller takes ownership), or %NULL */ char * -nm_manager_get_connection_iface(NMManager * self, +nm_manager_get_connection_iface(NMManager *self, NMConnection *connection, - NMDevice ** out_parent, - const char ** out_parent_spec, - GError ** error) + NMDevice **out_parent, + const char **out_parent_spec, + GError **error) { NMDeviceFactory *factory; - char * iface = NULL; - NMDevice * parent = NULL; + char *iface = NULL; + NMDevice *parent = NULL; NM_SET_OUT(out_parent, NULL); NM_SET_OUT(out_parent_spec, NULL); @@ -1947,7 +1947,7 @@ return_ifname_fom_connection: const char * nm_manager_iface_for_uuid(NMManager *self, const char *uuid) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMSettingsConnection *sett_conn; sett_conn = nm_settings_get_connection_by_uuid(priv->settings, uuid); @@ -1961,7 +1961,7 @@ NMDevice * nm_manager_get_device(NMManager *self, const char *ifname, NMDeviceType device_type) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; g_return_val_if_fail(ifname, NULL); g_return_val_if_fail(device_type != NM_DEVICE_TYPE_UNKNOWN, NULL); @@ -2001,15 +2001,15 @@ nm_manager_remove_device(NMManager *self, const char *ifname, NMDeviceType devic static NMDevice * system_create_virtual_device(NMManager *self, NMConnection *connection) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - NMDeviceFactory * factory; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMDeviceFactory *factory; NMSettingsConnection *const *connections; guint i; - gs_free char * iface = NULL; - const char * parent_spec; - NMDevice * device = NULL, *parent = NULL; - NMDevice * dev_candidate; - GError * error = NULL; + gs_free char *iface = NULL; + const char *parent_spec; + NMDevice *device = NULL, *parent = NULL; + NMDevice *dev_candidate; + GError *error = NULL; NMLogLevel log_level; g_return_val_if_fail(NM_IS_MANAGER(self), NULL); @@ -2095,7 +2095,7 @@ system_create_virtual_device(NMManager *self, NMConnection *connection) /* Create backing resources if the device has any autoconnect connections */ connections = nm_settings_get_connections_sorted_by_autoconnect_priority(priv->settings, NULL); for (i = 0; connections[i]; i++) { - NMConnection * candidate = nm_settings_connection_get_connection(connections[i]); + NMConnection *candidate = nm_settings_connection_get_connection(connections[i]); NMSettingConnection *s_con; if (!nm_device_check_connection_compatible(device, candidate, NULL)) @@ -2132,7 +2132,7 @@ system_create_virtual_device(NMManager *self, NMConnection *connection) static void retry_connections_for_parent_device(NMManager *self, NMDevice *device) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMSettingsConnection *const *connections; guint i; @@ -2141,10 +2141,10 @@ retry_connections_for_parent_device(NMManager *self, NMDevice *device) connections = nm_settings_get_connections_sorted_by_autoconnect_priority(priv->settings, NULL); for (i = 0; connections[i]; i++) { NMSettingsConnection *sett_conn = connections[i]; - NMConnection * connection = nm_settings_connection_get_connection(sett_conn); + NMConnection *connection = nm_settings_connection_get_connection(sett_conn); gs_free_error GError *error = NULL; - gs_free char * ifname = NULL; - NMDevice * parent; + gs_free char *ifname = NULL; + NMDevice *parent; parent = find_parent_device_for_connection(self, connection, NULL, NULL); if (parent == device) { @@ -2162,7 +2162,7 @@ static void connection_changed(NMManager *self, NMSettingsConnection *sett_conn) { NMConnection *connection; - NMDevice * device; + NMDevice *device; if (NM_FLAGS_ANY(nm_settings_connection_get_flags(sett_conn), NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE @@ -2191,10 +2191,10 @@ connection_added_cb(NMSettings *settings, NMSettingsConnection *sett_conn, NMMan } static void -connection_updated_cb(NMSettings * settings, +connection_updated_cb(NMSettings *settings, NMSettingsConnection *sett_conn, guint update_reason_u, - NMManager * self) + NMManager *self) { connection_changed(self, sett_conn); } @@ -2205,7 +2205,7 @@ static void _delete_volatile_connection_all(NMManager *self, gboolean do_delete) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMCListElem * elem; + NMCListElem *elem; while ( (elem = c_list_first_entry(&priv->delete_volatile_connection_lst_head, NMCListElem, lst))) { @@ -2220,7 +2220,7 @@ _delete_volatile_connection_all(NMManager *self, gboolean do_delete) static gboolean _delete_volatile_connection_cb(gpointer user_data) { - NMManager * self = user_data; + NMManager *self = user_data; NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); priv->delete_volatile_connection_idle_id = 0; @@ -2231,7 +2231,7 @@ _delete_volatile_connection_cb(gpointer user_data) static void connection_flags_changed(NMSettings *settings, NMSettingsConnection *connection, gpointer user_data) { - NMManager * self = user_data; + NMManager *self = user_data; NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); if (!NM_FLAGS_ANY(nm_settings_connection_get_flags(connection), @@ -2261,9 +2261,9 @@ connection_flags_changed(NMSettings *settings, NMSettingsConnection *connection, static void system_unmanaged_devices_changed_cb(NMSettings *settings, GParamSpec *pspec, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); + NMManager *self = NM_MANAGER(user_data); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) nm_device_set_unmanaged_by_user_settings(device); @@ -2302,7 +2302,7 @@ static void manager_update_radio_enabled(NMManager *self, RadioState *rstate, gboolean enabled) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; /* Do nothing for radio types not yet implemented */ if (!rstate->prop) @@ -2413,14 +2413,14 @@ nm_manager_rfkill_update(NMManager *self, RfKillType rtype) static void device_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); - gs_free_error GError * error = NULL; + NMManager *self = NM_MANAGER(user_data); + gs_free_error GError *error = NULL; NMAuthCallResult result; - NMDevice * device; - GCancellable * cancellable; - const char * permission; + NMDevice *device; + GCancellable *cancellable; + const char *permission; NMManagerDeviceAuthRequestFunc callback; - NMAuthSubject * subject; + NMAuthSubject *subject; nm_assert(G_IS_DBUS_METHOD_INVOCATION(context)); @@ -2459,14 +2459,14 @@ device_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer static void _device_auth_done_fail_on_idle(gpointer user_data, GCancellable *cancellable) { - gs_unref_object NMManager *self = NULL; - gs_unref_object NMDevice *device = NULL; - gs_unref_object GDBusMethodInvocation *context = NULL; - gs_unref_object NMAuthSubject *subject = NULL; - gs_free_error GError *error_original = NULL; - gs_free_error GError * error_cancelled = NULL; - NMManagerDeviceAuthRequestFunc callback; - gpointer callback_user_data; + gs_unref_object NMManager *self = NULL; + gs_unref_object NMDevice *device = NULL; + gs_unref_object GDBusMethodInvocation *context = NULL; + gs_unref_object NMAuthSubject *subject = NULL; + gs_free_error GError *error_original = NULL; + gs_free_error GError *error_cancelled = NULL; + NMManagerDeviceAuthRequestFunc callback; + gpointer callback_user_data; nm_utils_user_data_unpack(user_data, &self, @@ -2483,21 +2483,21 @@ _device_auth_done_fail_on_idle(gpointer user_data, GCancellable *cancellable) } void -nm_manager_device_auth_request(NMManager * self, - NMDevice * device, - GDBusMethodInvocation * context, - NMConnection * connection, - const char * permission, +nm_manager_device_auth_request(NMManager *self, + NMDevice *device, + GDBusMethodInvocation *context, + NMConnection *connection, + const char *permission, gboolean allow_interaction, - GCancellable * cancellable, + GCancellable *cancellable, NMManagerDeviceAuthRequestFunc callback, gpointer user_data) { - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - gs_free_error GError *error = NULL; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + gs_free_error GError *error = NULL; gs_unref_object NMAuthSubject *subject = NULL; - NMAuthChain * chain; - char * permission_dup; + NMAuthChain *chain; + char *permission_dup; /* Validate the caller */ subject = nm_dbus_manager_new_auth_subject_from_context(context); @@ -2573,18 +2573,18 @@ new_activation_allowed_for_connection(NMManager *self, NMSettingsConnection *con static NMSettingsConnection * get_existing_connection(NMManager *self, NMDevice *device, gboolean *out_generated) { - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); gs_unref_object NMConnection *connection = NULL; - NMSettingsConnection * added; - GError * error = NULL; - gs_free_error GError *gen_error = NULL; - NMDevice * master = NULL; - int ifindex = nm_device_get_ifindex(device); - NMSettingsConnection *matched = NULL; - NMSettingsConnection *connection_checked = NULL; - gboolean assume_state_guess_assume = FALSE; - const char * assume_state_connection_uuid = NULL; - gboolean maybe_later, only_by_uuid = FALSE; + NMSettingsConnection *added; + GError *error = NULL; + gs_free_error GError *gen_error = NULL; + NMDevice *master = NULL; + int ifindex = nm_device_get_ifindex(device); + NMSettingsConnection *matched = NULL; + NMSettingsConnection *connection_checked = NULL; + gboolean assume_state_guess_assume = FALSE; + const char *assume_state_connection_uuid = NULL; + gboolean maybe_later, only_by_uuid = FALSE; if (out_generated) *out_generated = FALSE; @@ -2719,7 +2719,7 @@ get_existing_connection(NMManager *self, NMDevice *device, gboolean *out_generat len = j; if (len > 0) { gs_free NMConnection **conns = NULL; - NMConnection * con; + NMConnection *con; g_qsort_with_data(sett_conns, len, @@ -2937,10 +2937,10 @@ recheck_assume_connection(NMManager *self, NMDevice *device) g_return_val_if_fail(nm_device_get_state(device) >= NM_DEVICE_STATE_DISCONNECTED, FALSE); { - gs_unref_object NMActiveConnection *active = NULL; - gs_unref_object NMAuthSubject *subject = NULL; - NMActiveConnection * master_ac; - GError * error = NULL; + gs_unref_object NMActiveConnection *active = NULL; + gs_unref_object NMAuthSubject *subject = NULL; + NMActiveConnection *master_ac; + GError *error = NULL; subject = nm_auth_subject_new_internal(); @@ -3029,9 +3029,9 @@ static void device_ip_iface_changed(NMDevice *device, GParamSpec *pspec, NMManager *self) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - const char * ip_iface = nm_device_get_ip_iface(device); + const char *ip_iface = nm_device_get_ip_iface(device); NMDeviceType device_type = nm_device_get_device_type(device); - NMDevice * candidate; + NMDevice *candidate; /* Remove NMDevice objects that are actually child devices of others, * when the other device finally knows its IP interface name. For example, @@ -3078,9 +3078,9 @@ device_realized(NMDevice *device, GParamSpec *pspec, NMManager *self) static NMConnectivityState _get_best_connectivity(NMManager *self, int addr_family) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMConnectivityState best_state; - NMDevice * dev; + NMDevice *dev; gint64 best_metric; if (addr_family == AF_UNSPEC) { @@ -3100,7 +3100,7 @@ _get_best_connectivity(NMManager *self, int addr_family) best_state = NM_CONNECTIVITY_UNKNOWN; best_metric = G_MAXINT64; c_list_for_each_entry (dev, &priv->devices_lst_head, devices_lst) { - const NMPObject * r; + const NMPObject *r; NMConnectivityState state; gint64 metric; @@ -3146,7 +3146,7 @@ device_connectivity_changed(NMDevice *device, GParamSpec *pspec, NMManager *self static void update_connectivity_value(NMManager *self) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMConnectivityState best_state; best_state = _get_best_connectivity(self, AF_UNSPEC); @@ -3204,12 +3204,12 @@ static gboolean add_device(NMManager *self, NMDevice *device, GError **error) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - const char * iface, *type_desc; + const char *iface, *type_desc; RfKillType rtype; - GSList * iter, *remove = NULL; + GSList *iter, *remove = NULL; int ifindex; - const char * dbus_path; - NMDevice * candidate; + const char *dbus_path; + NMDevice *candidate; /* No duplicates */ ifindex = nm_device_get_ifindex(device); @@ -3324,7 +3324,7 @@ static void factory_device_added_cb(NMDeviceFactory *factory, NMDevice *device, gpointer user_data) { NMManager *self = user_data; - GError * error = NULL; + GError *error = NULL; g_return_if_fail(NM_IS_MANAGER(self)); @@ -3362,7 +3362,7 @@ void nm_manager_notify_device_availability_maybe_changed(NMManager *self) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) nm_device_notify_availability_maybe_changed(device); @@ -3371,16 +3371,16 @@ nm_manager_notify_device_availability_maybe_changed(NMManager *self) /*****************************************************************************/ static void -platform_link_added(NMManager * self, +platform_link_added(NMManager *self, int ifindex, - const NMPlatformLink * plink, + const NMPlatformLink *plink, gboolean guess_assume, const NMConfigDeviceStateData *dev_state) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDeviceFactory * factory; - NMDevice * device = NULL; - NMDevice * candidate; + NMDeviceFactory *factory; + NMDevice *device = NULL; + NMDevice *candidate; g_return_if_fail(ifindex > 0); @@ -3389,8 +3389,8 @@ platform_link_added(NMManager * self, /* Let unrealized devices try to realize themselves with the link */ c_list_for_each_entry (candidate, &priv->devices_lst_head, devices_lst) { - gboolean compatible = TRUE; - gs_free_error GError *error = NULL; + gboolean compatible = TRUE; + gs_free_error GError *error = NULL; if (nm_device_get_link_type(candidate) != plink->type) continue; @@ -3440,8 +3440,8 @@ add: /* Try registered device factories */ factory = nm_device_factory_manager_find_factory_for_link_type(plink->type); if (factory) { - gboolean ignore = FALSE; - gs_free_error GError *error = NULL; + gboolean ignore = FALSE; + gs_free_error GError *error = NULL; device = nm_device_factory_create_device(factory, plink->name, plink, NULL, &ignore, &error); @@ -3527,9 +3527,9 @@ typedef struct { static gboolean _check_remove_dev_on_link_deleted(NMManager *self, NMDevice *device) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMSettingsConnection *const *scons = NULL; - NMConnection * con; + NMConnection *con; guint i; nm_assert(nm_device_is_software(device)); @@ -3567,8 +3567,8 @@ static gboolean _platform_link_cb_idle(PlatformLinkCbData *data) { int ifindex = data->ifindex; - NMManager * self = data->self; - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManager *self = data->self; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); const NMPlatformLink *plink; c_list_unlink_stale(&data->lst); @@ -3582,7 +3582,7 @@ _platform_link_cb_idle(PlatformLinkCbData *data) nmp_object_unref(plink_keep_alive); } else { NMDevice *device; - GError * error = NULL; + GError *error = NULL; device = nm_manager_get_device_by_ifindex(self, ifindex); if (device) { @@ -3609,17 +3609,17 @@ _platform_link_cb_idle(PlatformLinkCbData *data) } static void -platform_link_cb(NMPlatform * platform, +platform_link_cb(NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *plink, int change_type_i, gpointer user_data) { - NMManager * self; - NMManagerPrivate * priv; + NMManager *self; + NMManagerPrivate *priv; const NMPlatformSignalChangeType change_type = change_type_i; - PlatformLinkCbData * data; + PlatformLinkCbData *data; switch (change_type) { case NM_PLATFORM_SIGNAL_ADDED: @@ -3641,11 +3641,11 @@ platform_link_cb(NMPlatform * platform, static void platform_query_devices(NMManager *self) { - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *links = NULL; int i; gboolean guess_assume; - gs_free char * order = NULL; + gs_free char *order = NULL; guess_assume = nm_config_get_first_start(nm_config_get()); order = nm_config_data_get_value(NM_CONFIG_GET_DATA, @@ -3656,7 +3656,7 @@ platform_query_devices(NMManager *self) if (!links) return; for (i = 0; i < links->len; i++) { - const NMPlatformLink * link = NMP_OBJECT_CAST_LINK(links->pdata[i]); + const NMPlatformLink *link = NMP_OBJECT_CAST_LINK(links->pdata[i]); const NMConfigDeviceStateData *dev_state; dev_state = nm_config_device_state_get(priv->config, link->ifindex); @@ -3729,29 +3729,29 @@ _device_get_activation_prio(NMDevice *device) } static NMDevice * -nm_manager_get_best_device_for_connection(NMManager * self, +nm_manager_get_best_device_for_connection(NMManager *self, NMSettingsConnection *sett_conn, - NMConnection * connection, + NMConnection *connection, gboolean for_user_request, - GHashTable * unavailable_devices, - GError ** error) + GHashTable *unavailable_devices, + GError **error) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMActiveConnectionState ac_state; - NMActiveConnection * ac; - NMDevice * ac_device; - NMDevice * device; + NMActiveConnection *ac; + NMDevice *ac_device; + NMDevice *device; struct { - NMDevice * device; + NMDevice *device; DeviceActivationPrio prio; } best = { .device = NULL, .prio = DEVICE_ACTIVATION_PRIO_NONE, }; NMDeviceCheckConAvailableFlags flags; - gs_unref_ptrarray GPtrArray *all_ac_arr = NULL; - gs_free_error GError * local_best = NULL; - NMConnectionMultiConnect multi_connect; + gs_unref_ptrarray GPtrArray *all_ac_arr = NULL; + gs_free_error GError *local_best = NULL; + NMConnectionMultiConnect multi_connect; nm_assert(!sett_conn || NM_IS_SETTINGS_CONNECTION(sett_conn)); nm_assert(!connection || NM_IS_CONNECTION(connection)); @@ -3828,8 +3828,8 @@ nm_manager_get_best_device_for_connection(NMManager * self, /* we found several active connections. See which one is the most suitable... */ nm_assert(ac == all_ac_arr->pdata[0]); for (i = 1; i < all_ac_arr->len; i++) { - NMActiveConnection * ac2 = all_ac_arr->pdata[i]; - NMDevice * ac_device2 = nm_active_connection_get_device(ac2); + NMActiveConnection *ac2 = all_ac_arr->pdata[i]; + NMDevice *ac_device2 = nm_active_connection_get_device(ac2); NMActiveConnectionState ac_state2; if (!ac_device2 @@ -3892,7 +3892,7 @@ found_better: /* Pick the first device that's compatible with the connection. */ c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) { - GError * local = NULL; + GError *local = NULL; DeviceActivationPrio prio; if (unavailable_devices && g_hash_table_contains(unavailable_devices, device)) @@ -3975,9 +3975,9 @@ static const char ** _get_devices_paths(NMManager *self, gboolean all_devices) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - const char ** paths = NULL; + const char **paths = NULL; guint i; - NMDevice * device; + NMDevice *device; paths = g_new(const char *, c_list_length(&priv->devices_lst_head) + 1); @@ -4000,15 +4000,15 @@ _get_devices_paths(NMManager *self, gboolean all_devices) } static void -impl_manager_get_devices(NMDBusObject * obj, +impl_manager_get_devices(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); gs_free const char **paths = NULL; paths = _get_devices_paths(self, FALSE); @@ -4016,15 +4016,15 @@ impl_manager_get_devices(NMDBusObject * obj, } static void -impl_manager_get_all_devices(NMDBusObject * obj, +impl_manager_get_all_devices(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); gs_free const char **paths = NULL; paths = _get_devices_paths(self, TRUE); @@ -4032,16 +4032,16 @@ impl_manager_get_all_devices(NMDBusObject * obj, } static void -impl_manager_get_device_by_ip_iface(NMDBusObject * obj, +impl_manager_get_device_by_ip_iface(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); - NMDevice * device; + NMManager *self = NM_MANAGER(obj); + NMDevice *device; const char *path = NULL; const char *iface; @@ -4119,18 +4119,18 @@ is_compatible_with_slave(NMConnection *master, NMConnection *slave) * the connection did not require a master, %FALSE otherwise **/ static gboolean -find_master(NMManager * self, - NMConnection * connection, - NMDevice * device, +find_master(NMManager *self, + NMConnection *connection, + NMDevice *device, NMSettingsConnection **out_master_connection, - NMDevice ** out_master_device, - NMActiveConnection ** out_master_ac, - GError ** error) + NMDevice **out_master_device, + NMActiveConnection **out_master_ac, + GError **error) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - NMSettingConnection * s_con; - const char * master; - NMDevice * master_device = NULL; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMSettingConnection *s_con; + const char *master; + NMDevice *master_device = NULL; NMSettingsConnection *master_connection; s_con = nm_connection_get_setting_connection(connection); @@ -4235,16 +4235,16 @@ find_master(NMManager * self, * %NULL if an error occurred */ static NMActiveConnection * -ensure_master_active_connection(NMManager * self, - NMAuthSubject * subject, - NMConnection * connection, - NMDevice * device, +ensure_master_active_connection(NMManager *self, + NMAuthSubject *subject, + NMConnection *connection, + NMDevice *device, NMSettingsConnection *master_connection, - NMDevice * master_device, + NMDevice *master_device, NMActivationReason activation_reason, - GError ** error) + GError **error) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMActiveConnection *ac; NMActiveConnection *master_ac = NULL; NMDeviceState master_state; @@ -4307,7 +4307,7 @@ ensure_master_active_connection(NMManager * self, connections = nm_manager_get_activatable_connections(self, FALSE, TRUE, NULL); for (i = 0; connections[i]; i++) { NMSettingsConnection *candidate = connections[i]; - NMConnection * cand_conn = nm_settings_connection_get_connection(candidate); + NMConnection *cand_conn = nm_settings_connection_get_connection(candidate); /* Ensure eg bond/team slave and the candidate master is a * bond/team master @@ -4402,7 +4402,7 @@ ensure_master_active_connection(NMManager * self, typedef struct { NMSettingsConnection *connection; - NMDevice * device; + NMDevice *device; } SlaveConnectionInfo; /** @@ -4418,19 +4418,19 @@ typedef struct { * Returns: an array of #SlaveConnectionInfo for given master @sett_conn, or %NULL **/ static SlaveConnectionInfo * -find_slaves(NMManager * manager, +find_slaves(NMManager *manager, NMSettingsConnection *sett_conn, - NMDevice * device, - guint * out_n_slaves, + NMDevice *device, + guint *out_n_slaves, gboolean for_user_request) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(manager); - NMSettingsConnection *const *all_connections = NULL; - guint n_all_connections; - guint i; - SlaveConnectionInfo * slaves = NULL; - guint n_slaves = 0; - NMSettingConnection * s_con; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(manager); + NMSettingsConnection *const *all_connections = NULL; + guint n_all_connections; + guint i; + SlaveConnectionInfo *slaves = NULL; + guint n_slaves = 0; + NMSettingConnection *s_con; gs_unref_hashtable GHashTable *devices = NULL; nm_assert(out_n_slaves); @@ -4449,7 +4449,7 @@ find_slaves(NMManager * manager, &n_all_connections); for (i = 0; i < n_all_connections; i++) { NMSettingsConnection *master_connection = NULL; - NMDevice * master_device = NULL, *slave_device; + NMDevice *master_device = NULL, *slave_device; NMSettingsConnection *candidate = all_connections[i]; find_master(manager, @@ -4492,7 +4492,7 @@ find_slaves(NMManager * manager, static gboolean should_connect_slaves(NMConnection *connection, NMDevice *device) { - NMSettingConnection * s_con; + NMSettingConnection *s_con; NMSettingConnectionAutoconnectSlaves val; s_con = nm_connection_get_setting_connection(connection); @@ -4538,10 +4538,10 @@ compare_slaves(gconstpointer a, gconstpointer b, gpointer sort_by_name) } static void -autoconnect_slaves(NMManager * self, +autoconnect_slaves(NMManager *self, NMSettingsConnection *master_connection, - NMDevice * master_device, - NMAuthSubject * subject, + NMDevice *master_device, + NMAuthSubject *subject, gboolean for_user_request) { GError *local_err = NULL; @@ -4574,7 +4574,7 @@ autoconnect_slaves(NMManager * self, for (i = 0; i < n_slaves; i++) { SlaveConnectionInfo *slave = &slaves[i]; - const char * uuid; + const char *uuid; /* To avoid loops when autoconnecting slaves, we propagate * the UUID of the initial connection down to slaves until @@ -4738,12 +4738,12 @@ _activation_bind_lifetime_to_profile_visibility(NMAuthSubject *subject) static void active_connection_parent_active(NMActiveConnection *active, NMActiveConnection *parent_ac, - NMManager * self) + NMManager *self) { - NMDevice * device = nm_active_connection_get_device(active); - GError * error = NULL; + NMDevice *device = nm_active_connection_get_device(active); + GError *error = NULL; NMSettingsConnection *sett_conn; - NMDevice * parent; + NMDevice *parent; g_signal_handlers_disconnect_by_func(active, G_CALLBACK(active_connection_parent_active), self); @@ -4781,16 +4781,16 @@ active_connection_parent_active(NMActiveConnection *active, static gboolean _internal_activate_device(NMManager *self, NMActiveConnection *active, GError **error) { - NMDevice * device, *master_device = NULL; - NMConnection * applied; - NMSettingsConnection * sett_conn; - NMSettingsConnection * master_connection = NULL; - NMConnection * existing_connection = NULL; - NMActiveConnection * master_ac = NULL; - NMAuthSubject * subject; - GError * local = NULL; + NMDevice *device, *master_device = NULL; + NMConnection *applied; + NMSettingsConnection *sett_conn; + NMSettingsConnection *master_connection = NULL; + NMConnection *existing_connection = NULL; + NMActiveConnection *master_ac = NULL; + NMAuthSubject *subject; + GError *local = NULL; NMConnectionMultiConnect multi_connect; - const char * parent_spec; + const char *parent_spec; g_return_val_if_fail(NM_IS_MANAGER(self), FALSE); g_return_val_if_fail(NM_IS_ACTIVE_CONNECTION(active), FALSE); @@ -4877,7 +4877,7 @@ _internal_activate_device(NMManager *self, NMActiveConnection *active, GError ** if (parent && !nm_device_is_real(parent)) { NMSettingsConnection *parent_con; - NMActiveConnection * parent_ac; + NMActiveConnection *parent_ac; parent_con = nm_device_get_best_connection(parent, NULL, error); if (!parent_con) { @@ -5029,7 +5029,7 @@ _internal_activate_device(NMManager *self, NMActiveConnection *active, GError ** /* the profile can be activated multiple times. Proceed. */ } else { gs_unref_ptrarray GPtrArray *all_ac_arr = NULL; - NMActiveConnection * ac; + NMActiveConnection *ac; guint i, n_all; /* Disconnect the connection if already connected or queued for activation. @@ -5108,21 +5108,21 @@ _internal_activate_generic(NMManager *self, NMActiveConnection *active, GError * } static NMActiveConnection * -_new_active_connection(NMManager * self, +_new_active_connection(NMManager *self, gboolean is_vpn, - NMSettingsConnection * sett_conn, - NMConnection * incompl_conn, - NMConnection * applied, - const char * specific_object, - NMDevice * device, - NMAuthSubject * subject, + NMSettingsConnection *sett_conn, + NMConnection *incompl_conn, + NMConnection *applied, + const char *specific_object, + NMDevice *device, + NMAuthSubject *subject, NMActivationType activation_type, NMActivationReason activation_reason, NMActivationStateFlags initial_state_flags, - GError ** error) + GError **error) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * parent_device; + NMDevice *parent_device; nm_assert(!sett_conn || NM_IS_SETTINGS_CONNECTION(sett_conn)); nm_assert(!incompl_conn || NM_IS_CONNECTION(incompl_conn)); @@ -5217,13 +5217,13 @@ _new_active_connection(NMManager * self, } static void -_internal_activation_auth_done(NMManager * self, +_internal_activation_auth_done(NMManager *self, NMActiveConnection *active, gboolean success, - const char * error_desc) + const char *error_desc) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - NMActiveConnection *ac; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMActiveConnection *ac; gs_free_error GError *error = NULL; nm_assert(NM_IS_ACTIVE_CONNECTION(active)); @@ -5291,20 +5291,20 @@ fail: * activation of @sett_conn on @device */ NMActiveConnection * -nm_manager_activate_connection(NMManager * self, - NMSettingsConnection * sett_conn, - NMConnection * applied, - const char * specific_object, - NMDevice * device, - NMAuthSubject * subject, +nm_manager_activate_connection(NMManager *self, + NMSettingsConnection *sett_conn, + NMConnection *applied, + const char *specific_object, + NMDevice *device, + NMAuthSubject *subject, NMActivationType activation_type, NMActivationReason activation_reason, NMActivationStateFlags initial_state_flags, - GError ** error) + GError **error) { - NMManagerPrivate * priv; + NMManagerPrivate *priv; NMActiveConnection *active; - AsyncOpData * async_op_data; + AsyncOpData *async_op_data; gboolean is_vpn; g_return_val_if_fail(NM_IS_MANAGER(self), NULL); @@ -5388,17 +5388,17 @@ nm_manager_activate_connection(NMManager * self, * %NULL on error */ static NMAuthSubject * -validate_activation_request(NMManager * self, +validate_activation_request(NMManager *self, GDBusMethodInvocation *context, - NMSettingsConnection * sett_conn, - NMConnection * connection, - const char * device_path, - NMDevice ** out_device, - gboolean * out_is_vpn, - GError ** error) + NMSettingsConnection *sett_conn, + NMConnection *connection, + const char *device_path, + NMDevice **out_device, + gboolean *out_is_vpn, + GError **error) { - NMDevice * device = NULL; - gboolean is_vpn = FALSE; + NMDevice *device = NULL; + gboolean is_vpn = FALSE; gs_unref_object NMAuthSubject *subject = NULL; nm_assert(!sett_conn || NM_IS_SETTINGS_CONNECTION(sett_conn)); @@ -5495,14 +5495,14 @@ validate_activation_request(NMManager * self, /*****************************************************************************/ static void -_activation_auth_done(NMManager * self, - NMActiveConnection * active, +_activation_auth_done(NMManager *self, + NMActiveConnection *active, GDBusMethodInvocation *invocation, gboolean success, - const char * error_desc) + const char *error_desc) { - GError * error = NULL; - NMAuthSubject * subject; + GError *error = NULL; + NMAuthSubject *subject; NMSettingsConnection *connection; subject = nm_active_connection_get_subject(active); @@ -5544,25 +5544,25 @@ fail: } static void -impl_manager_activate_connection(NMDBusObject * obj, +impl_manager_activate_connection(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * dbus_connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *dbus_connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - gs_unref_object NMActiveConnection *active = NULL; - gs_unref_object NMAuthSubject *subject = NULL; - NMSettingsConnection * sett_conn = NULL; - NMDevice * device = NULL; - gboolean is_vpn = FALSE; - GError * error = NULL; - const char * connection_path; - const char * device_path; - const char * specific_object_path; + NMManager *self = NM_MANAGER(obj); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + gs_unref_object NMActiveConnection *active = NULL; + gs_unref_object NMAuthSubject *subject = NULL; + NMSettingsConnection *sett_conn = NULL; + NMDevice *device = NULL; + gboolean is_vpn = FALSE; + GError *error = NULL; + const char *connection_path; + const char *device_path; + const char *specific_object_path; g_variant_get(parameters, "(&o&o&o)", &connection_path, &device_path, &specific_object_path); @@ -5658,19 +5658,19 @@ error: /*****************************************************************************/ static void -activation_add_done(NMSettings * settings, - NMSettingsConnection * new_connection, - GError * error, +activation_add_done(NMSettings *settings, + NMSettingsConnection *new_connection, + GError *error, GDBusMethodInvocation *context, - NMAuthSubject * subject, + NMAuthSubject *subject, gpointer user_data) { - NMManager * self; + NMManager *self; gs_unref_object NMActiveConnection *active = NULL; - gs_free_error GError *local = NULL; - gpointer async_op_type_ptr; - AsyncOpType async_op_type; - GVariant * result_floating; + gs_free_error GError *local = NULL; + gpointer async_op_type_ptr; + AsyncOpType async_op_type; + GVariant *result_floating; nm_utils_user_data_unpack(user_data, &self, &active, &async_op_type_ptr); async_op_type = GPOINTER_TO_INT(async_op_type_ptr); @@ -5725,18 +5725,18 @@ fail: } static void -_add_and_activate_auth_done(NMManager * self, +_add_and_activate_auth_done(NMManager *self, AsyncOpType async_op_type, - NMActiveConnection * active, - NMConnection * connection, - GDBusMethodInvocation * invocation, + NMActiveConnection *active, + NMConnection *connection, + GDBusMethodInvocation *invocation, NMSettingsConnectionPersistMode persist_mode, gboolean is_volatile, gboolean success, - const char * error_desc) + const char *error_desc) { NMManagerPrivate *priv; - GError * error = NULL; + GError *error = NULL; if (!success) { error = @@ -5770,31 +5770,31 @@ _add_and_activate_auth_done(NMManager * self, } static void -impl_manager_add_and_activate_connection(NMDBusObject * obj, +impl_manager_add_and_activate_connection(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * dbus_connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *dbus_connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - gs_unref_object NMConnection *incompl_conn = NULL; - gs_unref_object NMActiveConnection *active = NULL; - gs_unref_object NMAuthSubject *subject = NULL; - GError * error = NULL; - NMDevice * device = NULL; - gboolean is_vpn = FALSE; - gs_unref_variant GVariant *settings = NULL; - gs_unref_variant GVariant *options = NULL; - const char * device_path; - const char * specific_object_path; - gs_free NMConnection ** conns = NULL; - NMSettingsConnectionPersistMode persist_mode = NM_SETTINGS_CONNECTION_PERSIST_MODE_TO_DISK; - gboolean is_volatile = FALSE; - gboolean bind_dbus_client = FALSE; - AsyncOpType async_op_type; + NMManager *self = NM_MANAGER(obj); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + gs_unref_object NMConnection *incompl_conn = NULL; + gs_unref_object NMActiveConnection *active = NULL; + gs_unref_object NMAuthSubject *subject = NULL; + GError *error = NULL; + NMDevice *device = NULL; + gboolean is_vpn = FALSE; + gs_unref_variant GVariant *settings = NULL; + gs_unref_variant GVariant *options = NULL; + const char *device_path; + const char *specific_object_path; + gs_free NMConnection **conns = NULL; + NMSettingsConnectionPersistMode persist_mode = NM_SETTINGS_CONNECTION_PERSIST_MODE_TO_DISK; + gboolean is_volatile = FALSE; + gboolean bind_dbus_client = FALSE; + AsyncOpType async_op_type; if (nm_streq(method_info->parent.name, "AddAndActivateConnection2")) { async_op_type = ASYNC_OP_TYPE_AC_AUTH_ADD_AND_ACTIVATE2; @@ -5816,13 +5816,13 @@ impl_manager_add_and_activate_connection(NMDBusObject * obj, if (options) { GVariantIter iter; - const char * option_name; - GVariant * option_value; + const char *option_name; + GVariant *option_value; g_variant_iter_init(&iter, options); while (g_variant_iter_next(&iter, "{&sv}", &option_name, &option_value)) { gs_unref_variant GVariant *option_value_free = NULL; - const char * s; + const char *s; option_value_free = option_value; @@ -5989,10 +5989,10 @@ error: /*****************************************************************************/ gboolean -nm_manager_deactivate_connection(NMManager * manager, +nm_manager_deactivate_connection(NMManager *manager, NMActiveConnection *active, NMDeviceStateReason reason, - GError ** error) + GError **error) { if (NM_IS_VPN_CONNECTION(active)) { NMActiveConnectionStateReason vpn_reason = @@ -6022,11 +6022,11 @@ nm_manager_deactivate_connection(NMManager * manager, static void deactivate_net_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); - GError * error = NULL; + NMManager *self = NM_MANAGER(user_data); + GError *error = NULL; NMAuthCallResult result; NMActiveConnection *active; - char * path; + char *path; nm_assert(G_IS_DBUS_METHOD_INVOCATION(context)); @@ -6069,22 +6069,22 @@ deactivate_net_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, } static void -impl_manager_deactivate_connection(NMDBusObject * obj, +impl_manager_deactivate_connection(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * dbus_connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *dbus_connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - NMActiveConnection * ac; + NMManager *self = NM_MANAGER(obj); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMActiveConnection *ac; NMSettingsConnection *sett_conn = NULL; - GError * error = NULL; - NMAuthSubject * subject = NULL; - NMAuthChain * chain; - const char * active_path; + GError *error = NULL; + NMAuthSubject *subject = NULL; + NMAuthChain *chain; + const char *active_path; g_variant_get(parameters, "(&o)", &active_path); @@ -6139,7 +6139,7 @@ done: static gboolean sleep_devices_add(NMManager *self, NMDevice *device, gboolean suspending) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMSleepMonitorInhibitorHandle *handle = NULL; if (g_hash_table_lookup_extended(priv->sleep_devices, device, NULL, (gpointer *) &handle)) { @@ -6165,7 +6165,7 @@ sleep_devices_add(NMManager *self, NMDevice *device, gboolean suspending) static gboolean sleep_devices_remove(NMManager *self, NMDevice *device) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMSleepMonitorInhibitorHandle *handle; if (!g_hash_table_lookup_extended(priv->sleep_devices, device, NULL, (gpointer *) &handle)) @@ -6184,8 +6184,8 @@ sleep_devices_remove(NMManager *self, NMDevice *device) static void sleep_devices_clear(NMManager *self) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMDevice *device; NMSleepMonitorInhibitorHandle *handle; GHashTableIter iter; @@ -6230,7 +6230,7 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); gboolean suspending, waking_from_suspend; - NMDevice * device; + NMDevice *device; suspending = sleeping_changed && priv->sleeping; waking_from_suspend = sleeping_changed && !priv->sleeping; @@ -6381,17 +6381,17 @@ _internal_sleep(NMManager *self, gboolean do_sleep) } static void -impl_manager_sleep(NMDBusObject * obj, +impl_manager_sleep(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - GError * error = NULL; + NMManager *self = NM_MANAGER(obj); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + GError *error = NULL; gs_unref_object NMAuthSubject *subject = NULL; gboolean do_sleep; @@ -6467,10 +6467,10 @@ _internal_enable(NMManager *self, gboolean enable) static void enable_net_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); + NMManager *self = NM_MANAGER(user_data); NMAuthCallResult result; gboolean enable; - NMAuthSubject * subject; + NMAuthSubject *subject; nm_assert(G_IS_DBUS_METHOD_INVOCATION(context)); @@ -6500,18 +6500,18 @@ enable_net_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer } static void -impl_manager_enable(NMDBusObject * obj, +impl_manager_enable(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; - GError * error = NULL; + NMAuthChain *chain; + GError *error = NULL; gboolean enable; g_variant_get(parameters, "(b)", &enable); @@ -6558,7 +6558,7 @@ get_permissions_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpoi for (i = 0; i < (int) G_N_ELEMENTS(nm_auth_permission_sorted); i++) { const char *permission = nm_auth_permission_names_by_idx[nm_auth_permission_sorted[i] - 1]; NMAuthCallResult result; - const char * result_str; + const char *result_str; result = nm_auth_chain_get_result(chain, permission); result_str = nm_client_permission_result_to_string(nm_auth_call_result_to_client(result)); @@ -6569,17 +6569,17 @@ get_permissions_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpoi } static void -impl_manager_get_permissions(NMDBusObject * obj, +impl_manager_get_permissions(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; + NMAuthChain *chain; int i; chain = nm_auth_chain_new_context(invocation, get_permissions_done_cb, self); @@ -6601,13 +6601,13 @@ impl_manager_get_permissions(NMDBusObject * obj, } static void -impl_manager_state(NMDBusObject * obj, +impl_manager_state(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { NMManager *self = NM_MANAGER(obj); @@ -6618,16 +6618,16 @@ impl_manager_state(NMDBusObject * obj, } static void -impl_manager_set_logging(NMDBusObject * obj, +impl_manager_set_logging(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); - GError * error = NULL; + NMManager *self = NM_MANAGER(obj); + GError *error = NULL; const char *level; const char *domains; @@ -6658,13 +6658,13 @@ impl_manager_set_logging(NMDBusObject * obj, } static void -impl_manager_get_logging(NMDBusObject * obj, +impl_manager_get_logging(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { g_dbus_method_invocation_return_value( invocation, @@ -6672,21 +6672,21 @@ impl_manager_get_logging(NMDBusObject * obj, } typedef struct { - NMManager * self; + NMManager *self; GDBusMethodInvocation *context; guint remaining; } ConnectivityCheckData; static void -device_connectivity_done(NMDevice * device, +device_connectivity_done(NMDevice *device, NMDeviceConnectivityHandle *handle, NMConnectivityState state, - GError * error, + GError *error, gpointer user_data) { ConnectivityCheckData *data = user_data; - NMManager * self; - NMManagerPrivate * priv; + NMManager *self; + NMManagerPrivate *priv; nm_assert(data); nm_assert(data->remaining > 0); @@ -6723,16 +6723,16 @@ device_connectivity_done(NMDevice * device, } static void -check_connectivity_auth_done_cb(NMAuthChain * chain, +check_connectivity_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - GError * error = NULL; + NMManager *self = NM_MANAGER(user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + GError *error = NULL; NMAuthCallResult result; ConnectivityCheckData *data; - NMDevice * device; + NMDevice *device; c_list_unlink(nm_auth_chain_parent_lst_list(chain)); @@ -6769,17 +6769,17 @@ check_connectivity_auth_done_cb(NMAuthChain * chain, } static void -impl_manager_check_connectivity(NMDBusObject * obj, +impl_manager_check_connectivity(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; + NMAuthChain *chain; chain = nm_auth_chain_new_context(invocation, check_connectivity_auth_done_cb, self); if (!chain) { @@ -6803,20 +6803,20 @@ start_factory(NMDeviceFactory *factory, gpointer user_data) gboolean nm_manager_write_device_state(NMManager *self, NMDevice *device, int *out_ifindex) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); int ifindex; gboolean managed; NMConfigDeviceStateManagedType managed_type; - const char * uuid = NULL; - const char * perm_hw_addr_fake = NULL; + const char *uuid = NULL; + const char *perm_hw_addr_fake = NULL; gboolean perm_hw_addr_is_fake; guint32 route_metric_default_aspired; guint32 route_metric_default_effective; NMTernary nm_owned; - NMDhcpConfig * dhcp_config; - const char * next_server = NULL; - const char * root_path = NULL; - const char * dhcp_bootfile = NULL; + NMDhcpConfig *dhcp_config; + const char *next_server = NULL; + const char *root_path = NULL; + const char *dhcp_bootfile = NULL; NM_SET_OUT(out_ifindex, 0); @@ -6886,9 +6886,9 @@ nm_manager_write_device_state(NMManager *self, NMDevice *device, int *out_ifinde void nm_manager_write_device_state_all(NMManager *self) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); gs_unref_hashtable GHashTable *preserve_ifindexes = NULL; - NMDevice * device; + NMDevice *device; preserve_ifindexes = g_hash_table_new(nm_direct_hash, NULL); @@ -6906,7 +6906,7 @@ nm_manager_write_device_state_all(NMManager *self) static gboolean devices_inited_cb(gpointer user_data) { - NMManager * self = user_data; + NMManager *self = user_data; NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); priv->devices_inited_id = 0; @@ -6918,7 +6918,7 @@ devices_inited_cb(gpointer user_data) gboolean nm_manager_start(NMManager *self, GError **error) { - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMSettingsConnection *const *connections; guint i; @@ -6992,7 +6992,7 @@ void nm_manager_stop(NMManager *self) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; /* FIXME(shutdown): we don't do a proper shutdown yet: * - need to ensure that all pending async operations are cancelled @@ -7020,9 +7020,9 @@ nm_manager_stop(NMManager *self) static gboolean handle_firmware_changed(gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); + NMManager *self = NM_MANAGER(user_data); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMDevice * device; + NMDevice *device; priv->fw_changed_id = 0; @@ -7044,13 +7044,13 @@ handle_firmware_changed(gpointer user_data) } static void -firmware_dir_changed(GFileMonitor * monitor, - GFile * file, - GFile * other_file, +firmware_dir_changed(GFileMonitor *monitor, + GFile *file, + GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); + NMManager *self = NM_MANAGER(user_data); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); switch (event_type) { @@ -7078,8 +7078,8 @@ connection_metered_changed(GObject *object, NMMetered metered, gpointer user_dat static void policy_default_ac_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManager *self = NM_MANAGER(user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMActiveConnection *ac; /* Note: this assumes that it's not possible for the IP4 default @@ -7118,8 +7118,8 @@ policy_default_ac_changed(GObject *object, GParamSpec *pspec, gpointer user_data static void policy_activating_ac_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManager *self = NM_MANAGER(user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMActiveConnection *activating, *best; /* We only look at activating-ip6-ac if activating-ip4-ac @@ -7145,11 +7145,11 @@ policy_activating_ac_changed(GObject *object, GParamSpec *pspec, gpointer user_d /*****************************************************************************/ typedef struct { - NMManager * self; - NMDBusObject * obj; + NMManager *self; + NMDBusObject *obj; const NMDBusInterfaceInfoExtended *interface_info; - const NMDBusPropertyInfoExtended * property_info; - GVariant * value; + const NMDBusPropertyInfoExtended *property_info; + GVariant *value; guint64 export_version_id; } DBusSetPropertyHandle; @@ -7157,9 +7157,9 @@ typedef struct { static const char * _dbus_set_property_audit_log_get_args(NMDBusObject *obj, - const char * property_name, - GVariant * value, - char ** str_to_free) + const char *property_name, + GVariant *value, + char **str_to_free) { nm_assert(str_to_free && !*str_to_free); @@ -7209,7 +7209,7 @@ _dbus_set_property_audit_log_get_args(NMDBusObject *obj, const char *const _property_name = (property_name); \ GVariant *const _value = (value); \ const char *const _error_message = (error_message); \ - gs_free char * _args_to_free = NULL; \ + gs_free char *_args_to_free = NULL; \ \ if (NM_IS_DEVICE(_obj)) { \ nm_audit_log_device_op(_audit_op, \ @@ -7235,23 +7235,23 @@ _dbus_set_property_audit_log_get_args(NMDBusObject *obj, G_STMT_END static void -_dbus_set_property_auth_cb(NMAuthChain * chain, +_dbus_set_property_auth_cb(NMAuthChain *chain, GDBusMethodInvocation *invocation, gpointer user_data) { - DBusSetPropertyHandle *handle_data = user_data; - gs_unref_object NMDBusObject * obj = handle_data->obj; - const NMDBusInterfaceInfoExtended *interface_info = handle_data->interface_info; - const NMDBusPropertyInfoExtended * property_info = handle_data->property_info; - gs_unref_variant GVariant *value = handle_data->value; - guint64 export_version_id = handle_data->export_version_id; - gs_unref_object NMManager *self = handle_data->self; - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthCallResult result; - gs_free_error GError *local = NULL; - const char * error_name = NULL; - const char * error_message = NULL; - GValue gvalue; + DBusSetPropertyHandle *handle_data = user_data; + gs_unref_object NMDBusObject *obj = handle_data->obj; + const NMDBusInterfaceInfoExtended *interface_info = handle_data->interface_info; + const NMDBusPropertyInfoExtended *property_info = handle_data->property_info; + gs_unref_variant GVariant *value = handle_data->value; + guint64 export_version_id = handle_data->export_version_id; + gs_unref_object NMManager *self = handle_data->self; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMAuthCallResult result; + gs_free_error GError *local = NULL; + const char *error_name = NULL; + const char *error_message = NULL; + GValue gvalue; g_slice_free(DBusSetPropertyHandle, handle_data); @@ -7305,21 +7305,21 @@ out: } void -nm_manager_dbus_set_property_handle(NMDBusObject * obj, +nm_manager_dbus_set_property_handle(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusPropertyInfoExtended * property_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * value, + const NMDBusPropertyInfoExtended *property_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *value, gpointer user_data) { - NMManager * self = user_data; - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; - const char * error_message = NULL; - gs_unref_object NMAuthSubject *subject = NULL; - DBusSetPropertyHandle * handle_data; + NMManager *self = user_data; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMAuthChain *chain; + const char *error_message = NULL; + gs_unref_object NMAuthSubject *subject = NULL; + DBusSetPropertyHandle *handle_data; /* we only have writable properties on Device or Manager. In the future, * we probably should not add new API with writable properties. Add @@ -7372,16 +7372,16 @@ _checkpoint_mgr_get(NMManager *self, gboolean create_as_needed) static void checkpoint_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMManager * self = NM_MANAGER(user_data); - char * op; - char * checkpoint_path = NULL; - char ** devices; - NMCheckpoint * checkpoint; + NMManager *self = NM_MANAGER(user_data); + char *op; + char *checkpoint_path = NULL; + char **devices; + NMCheckpoint *checkpoint; NMAuthCallResult result; guint32 timeout, flags; - GVariant * variant = NULL; - GError * error = NULL; - const char * arg = NULL; + GVariant *variant = NULL; + GError *error = NULL; + const char *arg = NULL; guint32 add_timeout; op = nm_auth_chain_get_data(chain, "audit-op"); @@ -7443,18 +7443,18 @@ checkpoint_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpoi } static void -impl_manager_checkpoint_create(NMDBusObject * obj, +impl_manager_checkpoint_create(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; - char ** devices; + NMAuthChain *chain; + char **devices; guint32 rollback_timeout; guint32 flags; @@ -7480,18 +7480,18 @@ impl_manager_checkpoint_create(NMDBusObject * obj, } static void -impl_manager_checkpoint_destroy(NMDBusObject * obj, +impl_manager_checkpoint_destroy(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; - const char * checkpoint_path; + NMAuthChain *chain; + const char *checkpoint_path; chain = nm_auth_chain_new_context(invocation, checkpoint_auth_done_cb, self); if (!chain) { @@ -7511,18 +7511,18 @@ impl_manager_checkpoint_destroy(NMDBusObject * obj, } static void -impl_manager_checkpoint_rollback(NMDBusObject * obj, +impl_manager_checkpoint_rollback(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; - const char * checkpoint_path; + NMAuthChain *chain; + const char *checkpoint_path; chain = nm_auth_chain_new_context(invocation, checkpoint_auth_done_cb, self); if (!chain) { @@ -7542,18 +7542,18 @@ impl_manager_checkpoint_rollback(NMDBusObject * obj, } static void -impl_manager_checkpoint_adjust_rollback_timeout(NMDBusObject * obj, +impl_manager_checkpoint_adjust_rollback_timeout(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMManager * self = NM_MANAGER(obj); + NMManager *self = NM_MANAGER(obj); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - NMAuthChain * chain; - const char * checkpoint_path; + NMAuthChain *chain; + const char *checkpoint_path; guint32 add_timeout; chain = nm_auth_chain_new_context(invocation, checkpoint_auth_done_cb, self); @@ -7702,8 +7702,8 @@ manager_radio_user_toggled(NMManager *self, RadioState *rstate, gboolean enabled static gboolean periodic_update_active_connection_timestamps(gpointer user_data) { - NMManager * manager = NM_MANAGER(user_data); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(manager); + NMManager *manager = NM_MANAGER(user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(manager); NMActiveConnection *ac; gboolean has_time = FALSE; guint64 t = 0; @@ -7811,8 +7811,8 @@ nm_manager_setup(void) static void constructed(GObject *object) { - NMManager * self = NM_MANAGER(object); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManager *self = NM_MANAGER(object); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); const NMConfigState *state; G_OBJECT_CLASS(nm_manager_parent_class)->constructed(object); @@ -7903,7 +7903,7 @@ nm_manager_init(NMManager *self) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); guint i; - GFile * file; + GFile *file; c_list_init(&priv->auth_lst_head); c_list_init(&priv->link_cb_lst); @@ -7978,14 +7978,14 @@ nm_manager_init(NMManager *self) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMManager * self = NM_MANAGER(object); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); - NMConfigData * config_data; + NMManager *self = NM_MANAGER(object); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); + NMConfigData *config_data; const NMGlobalDnsConfig *dns_config; - const char * type; - const char * path; - NMActiveConnection * ac; - GPtrArray * ptrarr; + const char *type; + const char *path; + NMActiveConnection *ac; + GPtrArray *ptrarr; switch (prop_id) { case PROP_VERSION: @@ -8099,10 +8099,10 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMManager * self = NM_MANAGER(object); - NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); + NMManager *self = NM_MANAGER(object); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); NMGlobalDnsConfig *dns_config; - GError * error = NULL; + GError *error = NULL; switch (prop_id) { case PROP_WIRELESS_ENABLED: @@ -8154,9 +8154,9 @@ _deinit_device_factory(NMDeviceFactory *factory, gpointer user_data) static void dispose(GObject *object) { - NMManager * self = NM_MANAGER(object); + NMManager *self = NM_MANAGER(object); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self); - CList * iter; + CList *iter; nm_assert(c_list_is_empty(&priv->async_op_lst_head)); @@ -8521,7 +8521,7 @@ static const NMDBusInterfaceInfoExtended interface_info_manager = { static void nm_manager_class_init(NMManagerClass *manager_class) { - GObjectClass * object_class = G_OBJECT_CLASS(manager_class); + GObjectClass *object_class = G_OBJECT_CLASS(manager_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(manager_class); #if WITH_OPENVSWITCH diff --git a/src/core/nm-manager.h b/src/core/nm-manager.h index 7a8b3a1e03..385cdfe08f 100644 --- a/src/core/nm-manager.h +++ b/src/core/nm-manager.h @@ -117,7 +117,7 @@ const CList *nm_manager_get_active_connections(NMManager *manager); NMSettingsConnection **nm_manager_get_activatable_connections(NMManager *manager, gboolean for_auto_activation, gboolean sort, - guint * out_len); + guint *out_len); void nm_manager_write_device_state_all(NMManager *manager); gboolean nm_manager_write_device_state(NMManager *manager, NMDevice *device, int *out_ifindex); @@ -156,29 +156,29 @@ nm_manager_device_route_metric_reserve(NMManager *self, int ifindex, NMDeviceTyp void nm_manager_device_route_metric_clear(NMManager *self, int ifindex); -char *nm_manager_get_connection_iface(NMManager * self, +char *nm_manager_get_connection_iface(NMManager *self, NMConnection *connection, - NMDevice ** out_parent, - const char ** out_parent_spec, - GError ** error); + NMDevice **out_parent, + const char **out_parent_spec, + GError **error); const char *nm_manager_iface_for_uuid(NMManager *self, const char *uuid); -NMActiveConnection *nm_manager_activate_connection(NMManager * manager, - NMSettingsConnection * connection, - NMConnection * applied_connection, - const char * specific_object, - NMDevice * device, - NMAuthSubject * subject, +NMActiveConnection *nm_manager_activate_connection(NMManager *manager, + NMSettingsConnection *connection, + NMConnection *applied_connection, + const char *specific_object, + NMDevice *device, + NMAuthSubject *subject, NMActivationType activation_type, NMActivationReason activation_reason, NMActivationStateFlags initial_state_flags, - GError ** error); + GError **error); -gboolean nm_manager_deactivate_connection(NMManager * manager, +gboolean nm_manager_deactivate_connection(NMManager *manager, NMActiveConnection *active, NMDeviceStateReason reason, - GError ** error); + GError **error); void nm_manager_set_capability(NMManager *self, NMCapability cap); void nm_manager_emit_device_ifindex_changed(NMManager *self, NMDevice *device); @@ -186,13 +186,13 @@ void nm_manager_emit_device_ifindex_changed(NMManager *self, NMDevice *device); NMDevice *nm_manager_get_device(NMManager *self, const char *ifname, NMDeviceType device_type); gboolean nm_manager_remove_device(NMManager *self, const char *ifname, NMDeviceType device_type); -void nm_manager_dbus_set_property_handle(NMDBusObject * obj, +void nm_manager_dbus_set_property_handle(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusPropertyInfoExtended * property_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * value, + const NMDBusPropertyInfoExtended *property_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *value, gpointer user_data); NMMetered nm_manager_get_metered(NMManager *self); @@ -201,13 +201,13 @@ void nm_manager_notify_device_availability_maybe_changed(NMManager *self); /*****************************************************************************/ -void nm_manager_device_auth_request(NMManager * self, - NMDevice * device, - GDBusMethodInvocation * context, - NMConnection * connection, - const char * permission, +void nm_manager_device_auth_request(NMManager *self, + NMDevice *device, + GDBusMethodInvocation *context, + NMConnection *connection, + const char *permission, gboolean allow_interaction, - GCancellable * cancellable, + GCancellable *cancellable, NMManagerDeviceAuthRequestFunc callback, gpointer user_data); diff --git a/src/core/nm-netns.c b/src/core/nm-netns.c index 538b0e0c1f..4d3c3172ae 100644 --- a/src/core/nm-netns.c +++ b/src/core/nm-netns.c @@ -22,14 +22,14 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PLATFORM, ); typedef struct { - NMNetns * _self_signal_user_data; - NMPlatform * platform; - NMPNetns * platform_netns; + NMNetns *_self_signal_user_data; + NMPlatform *platform; + NMPNetns *platform_netns; NMPRulesManager *rules_manager; - GHashTable * l3cfgs; - GHashTable * shared_ips; + GHashTable *l3cfgs; + GHashTable *shared_ips; CList l3cfg_signal_pending_lst_head; - GSource * signal_pending_idle_source; + GSource *signal_pending_idle_source; } NMNetnsPrivate; struct _NMNetns { @@ -113,9 +113,9 @@ _l3cfg_data_free(gpointer ptr) static void _l3cfg_weak_notify(gpointer data, GObject *where_the_object_was) { - NMNetns * self = NM_NETNS(data); + NMNetns *self = NM_NETNS(data); NMNetnsPrivate *priv = NM_NETNS_GET_PRIVATE(data); - NML3Cfg * l3cfg = NM_L3CFG(where_the_object_was); + NML3Cfg *l3cfg = NM_L3CFG(where_the_object_was); int ifindex = nm_l3cfg_get_ifindex(l3cfg); if (!g_hash_table_remove(priv->l3cfgs, &ifindex)) @@ -142,7 +142,7 @@ NML3Cfg * nm_netns_l3cfg_acquire(NMNetns *self, int ifindex) { NMNetnsPrivate *priv; - L3CfgData * l3cfg_data; + L3CfgData *l3cfg_data; g_return_val_if_fail(NM_IS_NETNS(self), NULL); g_return_val_if_fail(ifindex > 0, NULL); @@ -185,8 +185,8 @@ static gboolean _platform_signal_on_idle_cb(gpointer user_data) { gs_unref_object NMNetns *self = g_object_ref(NM_NETNS(user_data)); - NMNetnsPrivate * priv = NM_NETNS_GET_PRIVATE(self); - L3CfgData * l3cfg_data; + NMNetnsPrivate *priv = NM_NETNS_GET_PRIVATE(self); + L3CfgData *l3cfg_data; CList work_list; nm_clear_g_source_inst(&priv->signal_pending_idle_source); @@ -214,18 +214,18 @@ _platform_signal_on_idle_cb(gpointer user_data) } static void -_platform_signal_cb(NMPlatform * platform, +_platform_signal_cb(NMPlatform *platform, int obj_type_i, int ifindex, gconstpointer platform_object, int change_type_i, - NMNetns ** p_self) + NMNetns **p_self) { - NMNetns * self = NM_NETNS(*p_self); - NMNetnsPrivate * priv = NM_NETNS_GET_PRIVATE(self); + NMNetns *self = NM_NETNS(*p_self); + NMNetnsPrivate *priv = NM_NETNS_GET_PRIVATE(self); const NMPObjectType obj_type = obj_type_i; const NMPlatformSignalChangeType change_type = change_type_i; - L3CfgData * l3cfg_data; + L3CfgData *l3cfg_data; l3cfg_data = g_hash_table_lookup(priv->l3cfgs, &ifindex); if (!l3cfg_data) @@ -250,7 +250,7 @@ _platform_signal_cb(NMPlatform * platform, NMNetnsSharedIPHandle * nm_netns_shared_ip_reserve(NMNetns *self) { - NMNetnsPrivate * priv; + NMNetnsPrivate *priv; NMNetnsSharedIPHandle *handle; const in_addr_t addr_start = ntohl(0x0a2a0001u); /* 10.42.0.1 */ in_addr_t addr; @@ -312,7 +312,7 @@ nm_netns_shared_ip_reserve(NMNetns *self) void nm_netns_shared_ip_release(NMNetnsSharedIPHandle *handle) { - NMNetns * self; + NMNetns *self; NMNetnsPrivate *priv; char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; @@ -356,7 +356,7 @@ nm_netns_shared_ip_release(NMNetnsSharedIPHandle *handle) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMNetns * self = NM_NETNS(object); + NMNetns *self = NM_NETNS(object); NMNetnsPrivate *priv = NM_NETNS_GET_PRIVATE(self); switch (prop_id) { @@ -387,7 +387,7 @@ nm_netns_init(NMNetns *self) static void constructed(GObject *object) { - NMNetns * self = NM_NETNS(object); + NMNetns *self = NM_NETNS(object); NMNetnsPrivate *priv = NM_NETNS_GET_PRIVATE(self); if (!priv->platform) @@ -454,7 +454,7 @@ nm_netns_new(NMPlatform *platform) static void dispose(GObject *object) { - NMNetns * self = NM_NETNS(object); + NMNetns *self = NM_NETNS(object); NMNetnsPrivate *priv = NM_NETNS_GET_PRIVATE(self); nm_assert(nm_g_hash_table_size(priv->l3cfgs) == 0); diff --git a/src/core/nm-netns.h b/src/core/nm-netns.h index 36ed497288..0cb5637544 100644 --- a/src/core/nm-netns.h +++ b/src/core/nm-netns.h @@ -27,7 +27,7 @@ NMNetns *nm_netns_get(void); NMNetns *nm_netns_new(struct _NMPlatform *platform); struct _NMPlatform *nm_netns_get_platform(NMNetns *self); -NMPNetns * nm_netns_get_platform_netns(NMNetns *self); +NMPNetns *nm_netns_get_platform_netns(NMNetns *self); struct _NMPRulesManager *nm_netns_get_rules_manager(NMNetns *self); @@ -44,7 +44,7 @@ NML3Cfg *nm_netns_l3cfg_acquire(NMNetns *netns, int ifindex); typedef struct { in_addr_t addr; int _ref_count; - NMNetns * _self; + NMNetns *_self; } NMNetnsSharedIPHandle; NMNetnsSharedIPHandle *nm_netns_shared_ip_reserve(NMNetns *self); diff --git a/src/core/nm-pacrunner-manager.c b/src/core/nm-pacrunner-manager.c index 6eca4d9432..5ef425bb97 100644 --- a/src/core/nm-pacrunner-manager.c +++ b/src/core/nm-pacrunner-manager.c @@ -29,14 +29,14 @@ struct _NMPacrunnerConfId { GVariant *parameters; - char * path; + char *path; guint64 log_id; guint refcount; }; typedef struct { GDBusConnection *dbus_connection; - GCancellable * cancellable; + GCancellable *cancellable; CList conf_id_lst_head; guint64 log_id_counter; guint name_owner_changed_id; @@ -85,8 +85,8 @@ NM_DEFINE_SINGLETON_GETTER(NMPacrunnerManager, nm_pacrunner_manager_get, NM_TYPE /*****************************************************************************/ static void _call_destroy_proxy_configuration(NMPacrunnerManager *self, - NMPacrunnerConfId * conf_id, - const char * path, + NMPacrunnerConfId *conf_id, + const char *path, gboolean verbose_log); /*****************************************************************************/ @@ -126,13 +126,13 @@ static void get_ip_domains(GPtrArray *domains, const NML3ConfigData *l3cd, int addr_family) { NMDedupMultiIter ipconf_iter; - char * cidr; + char *cidr; guint num; guint i; char sbuf[NM_UTILS_INET_ADDRSTRLEN]; const NMPlatformIPAddress *address; - const NMPlatformIPRoute * route; - const char *const * strv; + const NMPlatformIPRoute *route; + const char *const *strv; strv = nm_l3_config_data_get_searches(l3cd, addr_family, &num); for (i = 0; i < num; i++) @@ -164,7 +164,7 @@ _make_request_create_proxy_configuration(const char *iface, const NML3ConfigData { GVariantBuilder builder; NMProxyConfigMethod method; - const char * s; + const char *s; g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); @@ -224,8 +224,8 @@ static void _call_destroy_proxy_configuration_cb(GObject *source, GAsyncResult *res, gpointer user_data) { nm_auto_unref_conf_id NMPacrunnerConfId *conf_id = user_data; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &error); if (!ret) { @@ -242,10 +242,10 @@ static void _call_create_proxy_configuration_cb(GObject *source, GAsyncResult *res, gpointer user_data) { nm_auto_unref_conf_id NMPacrunnerConfId *conf_id = user_data; - NMPacrunnerManager * self = NM_PACRUNNER_MANAGER(conf_id->self); - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *variant = NULL; - const char * path = NULL; + NMPacrunnerManager *self = NM_PACRUNNER_MANAGER(conf_id->self); + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *variant = NULL; + const char *path = NULL; nm_assert(!conf_id->path); @@ -274,8 +274,8 @@ _call_create_proxy_configuration_cb(GObject *source, GAsyncResult *res, gpointer static void _call_destroy_proxy_configuration(NMPacrunnerManager *self, - NMPacrunnerConfId * conf_id, - const char * path, + NMPacrunnerConfId *conf_id, + const char *path, gboolean verbose_log) { NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE(self); @@ -299,7 +299,7 @@ _call_destroy_proxy_configuration(NMPacrunnerManager *self, static void _call_create_proxy_configuration(NMPacrunnerManager *self, - NMPacrunnerConfId * conf_id, + NMPacrunnerConfId *conf_id, gboolean verbose_log) { NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE(self); @@ -357,8 +357,8 @@ NMPacrunnerConfId * nm_pacrunner_manager_add(NMPacrunnerManager *self, const char *iface, const NML3ConfigData *l3cd) { NMPacrunnerManagerPrivate *priv; - NMPacrunnerConfId * conf_id; - gs_free char * log_msg = NULL; + NMPacrunnerConfId *conf_id; + gs_free char *log_msg = NULL; g_return_val_if_fail(NM_IS_PACRUNNER_MANAGER(self), NULL); @@ -398,8 +398,8 @@ void nm_pacrunner_manager_remove(NMPacrunnerConfId *conf_id) { _nm_unused nm_auto_unref_conf_id NMPacrunnerConfId *conf_id_free = conf_id; - NMPacrunnerManager * self; - NMPacrunnerManagerPrivate * priv; + NMPacrunnerManager *self; + NMPacrunnerManagerPrivate *priv; g_return_if_fail(conf_id); @@ -451,7 +451,7 @@ static void name_owner_changed(NMPacrunnerManager *self, const char *name_owner) { NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE(self); - NMPacrunnerConfId * conf_id; + NMPacrunnerConfId *conf_id; gboolean has_name_owner; has_name_owner = (name_owner && name_owner[0]); @@ -487,11 +487,11 @@ name_owner_changed(NMPacrunnerManager *self, const char *name_owner) static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { const char *new_owner; diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index 329d14d167..f9f2fc5d78 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -48,8 +48,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMPolicy, PROP_ACTIVATING_IP6_AC, ); typedef struct { - NMManager * manager; - NMNetns * netns; + NMManager *manager; + NMNetns *netns; NMFirewalldManager *firewalld_manager; CList pending_activation_checks; @@ -75,8 +75,8 @@ typedef struct { guint schedule_activate_all_id; /* idle handler for schedule_activate_all(). */ NMPolicyHostnameMode hostname_mode; - char * orig_hostname; /* hostname at NM start time */ - char * cur_hostname; /* hostname we want to assign */ + char *orig_hostname; /* hostname at NM start time */ + char *cur_hostname; /* hostname we want to assign */ char * last_hostname; /* last hostname NM set (to detect if someone else changed it in the meanwhile) */ @@ -141,10 +141,10 @@ static NMDevice *get_default_device(NMPolicy *self, int addr_family); typedef struct { NMPlatformIP6Address prefix; - NMDevice * device; /* The requesting ("uplink") device */ + NMDevice *device; /* The requesting ("uplink") device */ guint64 next_subnet; /* Cache of the next subnet number to be * assigned from this prefix */ - GHashTable * subnets; /* ifindex -> NMPlatformIP6Address */ + GHashTable *subnets; /* ifindex -> NMPlatformIP6Address */ } IP6PrefixDelegation; static void @@ -180,7 +180,7 @@ clear_ip6_prefix_delegation(gpointer data) static void expire_ip6_delegations(NMPolicy *self) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); guint32 now = nm_utils_get_monotonic_timestamp_sec(); IP6PrefixDelegation *delegation = NULL; guint i; @@ -257,7 +257,7 @@ ip6_subnet_from_delegation(IP6PrefixDelegation *delegation, NMDevice *device) static void ip6_subnet_from_device(NMPolicy *self, NMDevice *from_device, NMDevice *device) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); IP6PrefixDelegation *delegation = NULL; gboolean got_subnet = FALSE; guint have_prefixes = 0; @@ -289,7 +289,7 @@ ip6_subnet_from_device(NMPolicy *self, NMDevice *from_device, NMDevice *device) static void ip6_remove_device_prefix_delegations(NMPolicy *self, NMDevice *device) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); IP6PrefixDelegation *delegation = NULL; guint i; @@ -301,16 +301,16 @@ ip6_remove_device_prefix_delegations(NMPolicy *self, NMDevice *device) } static void -device_ip6_prefix_delegated(NMDevice * device, +device_ip6_prefix_delegated(NMDevice *device, const NMPlatformIP6Address *prefix, gpointer user_data) { - NMPolicyPrivate * priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicyPrivate *priv = user_data; + NMPolicy *self = _PRIV_TO_SELF(priv); IP6PrefixDelegation *delegation = NULL; guint i; - const CList * tmp_list; - NMActiveConnection * ac; + const CList *tmp_list; + NMActiveConnection *ac; char sbuf[NM_UTILS_INET_ADDRSTRLEN]; _LOGI(LOGD_IP6, @@ -356,7 +356,7 @@ static void device_ip6_subnet_needed(NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); _LOGD(LOGD_IP6, "ipv6-pd: %s needs a subnet", nm_device_get_iface(device)); @@ -376,7 +376,7 @@ device_ip6_subnet_needed(NMDevice *device, gpointer user_data) static NMDevice * get_default_device(NMPolicy *self, int addr_family) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); NMActiveConnection *ac; nm_assert_addr_family(addr_family); @@ -389,9 +389,9 @@ get_default_device(NMPolicy *self, int addr_family) static NMActiveConnection * get_best_active_connection(NMPolicy *self, int addr_family, gboolean fully_activated) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - const CList * tmp_lst; - NMDevice * device; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + const CList *tmp_lst; + NMDevice *device; guint32 best_metric = G_MAXUINT32; gboolean best_is_fully_activated = FALSE; NMActiveConnection *best_ac, *prev_ac; @@ -406,9 +406,9 @@ get_best_active_connection(NMPolicy *self, int addr_family, gboolean fully_activ nm_manager_for_each_device (priv->manager, device, tmp_lst) { NMDeviceState state; - const NMPObject * r; + const NMPObject *r; NMActiveConnection *ac; - NMConnection * connection; + NMConnection *connection; guint32 metric; gboolean is_fully_activated; @@ -460,8 +460,8 @@ static gboolean all_devices_not_active(NMPolicy *self) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - const CList * tmp_lst; - NMDevice * device; + const CList *tmp_lst; + NMDevice *device; nm_manager_for_each_device (priv->manager, device, tmp_lst) { NMDeviceState state; @@ -480,7 +480,7 @@ all_devices_not_active(NMPolicy *self) static void settings_set_hostname_cb(const char *hostname, gboolean result, gpointer user_data) { - NMPolicy * self = NM_POLICY(user_data); + NMPolicy *self = NM_POLICY(user_data); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); int ret = 0; int errsv; @@ -514,7 +514,7 @@ static char * _get_hostname(NMPolicy *self) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - char * hostname = NULL; + char *hostname = NULL; int errsv; /* If there is an in-progress hostname change, return @@ -559,8 +559,8 @@ static void _set_hostname(NMPolicy *self, const char *new_hostname, const char *msg) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - gs_free char * old_hostname = NULL; - const char * name; + gs_free char *old_hostname = NULL; + const char *name; /* The incoming hostname *can* be NULL, which will get translated to * 'localhost.localdomain' or such in the hostname policy code, but we @@ -700,14 +700,14 @@ device_get_hostname_priority(NMDevice *device) static GArray * build_device_hostname_infos(NMPolicy *self) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - const CList * tmp_clist; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + const CList *tmp_clist; NMActiveConnection *ac; - GArray * array = NULL; + GArray *array = NULL; nm_manager_for_each_active_connection (priv->manager, ac, tmp_clist) { DeviceHostnameInfo *info; - NMDevice * device; + NMDevice *device; gboolean only_from_default; gboolean is_default; int IS_IPv4; @@ -777,14 +777,14 @@ device_dns_lookup_done(NMDevice *device, gpointer user_data) static void update_system_hostname(NMPolicy *self, const char *msg) { - NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - const char * configured_hostname; - gs_free char * temp_hostname = NULL; - const char * dhcp_hostname, *p; - gboolean external_hostname = FALSE; - NMDhcpConfig * dhcp_config; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + const char *configured_hostname; + gs_free char *temp_hostname = NULL; + const char *dhcp_hostname, *p; + gboolean external_hostname = FALSE; + NMDhcpConfig *dhcp_config; gs_unref_array GArray *infos = NULL; - DeviceHostnameInfo * info; + DeviceHostnameInfo *info; guint i; int addr_family; @@ -935,8 +935,8 @@ update_system_hostname(NMPolicy *self, const char *msg) static void update_default_ac(NMPolicy *self, int addr_family, NMActiveConnection *best) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - const CList * tmp_list; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + const CList *tmp_list; NMActiveConnection *ac; /* Clear the 'default[6]' flag on all active connections that aren't the new @@ -954,27 +954,27 @@ update_default_ac(NMPolicy *self, int addr_family, NMActiveConnection *best) } static const NML3ConfigData * -get_best_ip_config(NMPolicy * self, +get_best_ip_config(NMPolicy *self, int addr_family, - const char ** out_ip_iface, + const char **out_ip_iface, NMActiveConnection **out_ac, - NMDevice ** out_device, - NMVpnConnection ** out_vpn) + NMDevice **out_device, + NMVpnConnection **out_vpn) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); const NML3ConfigData *l3cd_best = NULL; - const CList * tmp_list; - NMActiveConnection * ac; + const CList *tmp_list; + NMActiveConnection *ac; guint64 best_metric = G_MAXUINT64; - NMVpnConnection * best_vpn = NULL; + NMVpnConnection *best_vpn = NULL; nm_assert(NM_IN_SET(addr_family, AF_INET, AF_INET6)); nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { const NML3ConfigData *l3cd; - NMVpnConnection * candidate; + NMVpnConnection *candidate; NMVpnConnectionState vpn_state; - const NMPObject * obj; + const NMPObject *obj; guint32 metric; if (!NM_IS_VPN_CONNECTION(ac)) @@ -1033,11 +1033,11 @@ get_best_ip_config(NMPolicy * self, static void update_ip4_routing(NMPolicy *self, gboolean force_update) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - NMDevice * best = NULL; - NMVpnConnection * vpn = NULL; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + NMDevice *best = NULL; + NMVpnConnection *vpn = NULL; NMActiveConnection *best_ac = NULL; - const char * ip_iface = NULL; + const char *ip_iface = NULL; /* Note that we might have an IPv4 VPN tunneled over an IPv6-only device, * so we can get (vpn != NULL && best == NULL). @@ -1055,7 +1055,7 @@ update_ip4_routing(NMPolicy *self, gboolean force_update) return; if (best) { - const CList * tmp_list; + const CList *tmp_list; NMActiveConnection *ac; nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { @@ -1080,10 +1080,10 @@ update_ip4_routing(NMPolicy *self, gboolean force_update) static void update_ip6_prefix_delegation(NMPolicy *self) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - NMDevice * device; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + NMDevice *device; NMActiveConnection *ac; - const CList * tmp_list; + const CList *tmp_list; /* There's new default IPv6 connection, try to get a prefix for everyone. */ nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { @@ -1096,11 +1096,11 @@ update_ip6_prefix_delegation(NMPolicy *self) static void update_ip6_routing(NMPolicy *self, gboolean force_update) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - NMDevice * best = NULL; - NMVpnConnection * vpn = NULL; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + NMDevice *best = NULL; + NMVpnConnection *vpn = NULL; NMActiveConnection *best_ac = NULL; - const char * ip_iface = NULL; + const char *ip_iface = NULL; /* Note that we might have an IPv6 VPN tunneled over an IPv4-only device, * so we can get (vpn != NULL && best == NULL). @@ -1118,7 +1118,7 @@ update_ip6_routing(NMPolicy *self, gboolean force_update) return; if (best) { - const CList * tmp_list; + const CList *tmp_list; NMActiveConnection *ac; nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { @@ -1145,11 +1145,11 @@ update_ip6_routing(NMPolicy *self, gboolean force_update) static void update_ip_dns(NMPolicy *self, int addr_family, NMDevice *changed_device) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); const NML3ConfigData *l3cd; - const char * ip_iface = NULL; - NMVpnConnection * vpn = NULL; - NMDevice * device = NULL; + const char *ip_iface = NULL; + NMVpnConnection *vpn = NULL; + NMDevice *device = NULL; nm_assert_addr_family(addr_family); @@ -1181,7 +1181,7 @@ update_ip_dns(NMPolicy *self, int addr_family, NMDevice *changed_device) if (addr_family == AF_INET6) { NMActiveConnection *ac; - const CList * tmp_list; + const CList *tmp_list; /* Tell devices needing a subnet about the new DNS configuration */ nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { @@ -1214,7 +1214,7 @@ update_routing_and_dns(NMPolicy *self, gboolean force_update, NMDevice *changed_ static void check_activating_active_connections(NMPolicy *self) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); NMActiveConnection *best4, *best6 = NULL; best4 = get_best_active_connection(self, AF_INET, FALSE); @@ -1254,7 +1254,7 @@ activate_data_free(ActivateData *data) static void pending_ac_gone(gpointer data, GObject *where_the_object_was) { - NMPolicy * self = NM_POLICY(data); + NMPolicy *self = NM_POLICY(data); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); /* Active connections should reach the DEACTIVATED state @@ -1268,7 +1268,7 @@ pending_ac_gone(gpointer data, GObject *where_the_object_was) static void pending_ac_state_changed(NMActiveConnection *ac, guint state, guint reason, NMPolicy *self) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); NMSettingsConnection *con; if (state >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING) { @@ -1298,14 +1298,14 @@ pending_ac_state_changed(NMActiveConnection *ac, guint state, guint reason, NMPo static void auto_activate_device(NMPolicy *self, NMDevice *device) { - NMPolicyPrivate * priv; - NMSettingsConnection *best_connection; - gs_free char * specific_object = NULL; - gs_free NMSettingsConnection **connections = NULL; + NMPolicyPrivate *priv; + NMSettingsConnection *best_connection; + gs_free char *specific_object = NULL; + gs_free NMSettingsConnection **connections = NULL; guint i, len; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; gs_unref_object NMAuthSubject *subject = NULL; - NMActiveConnection * ac; + NMActiveConnection *ac; nm_assert(NM_IS_POLICY(self)); nm_assert(NM_IS_DEVICE(device)); @@ -1330,9 +1330,9 @@ auto_activate_device(NMPolicy *self, NMDevice *device) best_connection = NULL; for (i = 0; i < len; i++) { NMSettingsConnection *candidate = connections[i]; - NMConnection * cand_conn; - NMSettingConnection * s_con; - const char * permission; + NMConnection *cand_conn; + NMSettingConnection *s_con; + const char *permission; if (nm_settings_connection_autoconnect_is_blocked(candidate)) continue; @@ -1418,7 +1418,7 @@ static ActivateData * find_pending_activation(NMPolicy *self, NMDevice *device) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - ActivateData * data; + ActivateData *data; c_list_for_each_entry (data, &priv->pending_activation_checks, pending_lst) { if (data->device == device) @@ -1431,7 +1431,7 @@ find_pending_activation(NMPolicy *self, NMDevice *device) typedef struct { NMDevice *device; - GSList * secondaries; + GSList *secondaries; } PendingSecondaryData; static PendingSecondaryData * @@ -1457,12 +1457,12 @@ static void process_secondaries(NMPolicy *self, NMActiveConnection *active, gboolean connected) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - GSList * iter, *iter2, *next, *next2; + GSList *iter, *iter2, *next, *next2; /* Loop through devices waiting for secondary connections to activate */ for (iter = priv->pending_secondaries; iter; iter = next) { PendingSecondaryData *secondary_data = (PendingSecondaryData *) iter->data; - NMDevice * item_device = secondary_data->device; + NMDevice *item_device = secondary_data->device; next = g_slist_next(iter); @@ -1521,7 +1521,7 @@ static void hostname_changed(NMHostnameManager *hostname_manager, GParamSpec *pspec, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); update_system_hostname(self, "hostname changed"); } @@ -1529,7 +1529,7 @@ hostname_changed(NMHostnameManager *hostname_manager, GParamSpec *pspec, gpointe void nm_policy_unblock_failed_ovs_interfaces(NMPolicy *self) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); NMSettingsConnection *const *connections = NULL; guint i; @@ -1538,7 +1538,7 @@ nm_policy_unblock_failed_ovs_interfaces(NMPolicy *self) connections = nm_settings_get_connections(priv->settings, NULL); for (i = 0; connections[i]; i++) { NMSettingsConnection *sett_conn = connections[i]; - NMConnection * connection = nm_settings_connection_get_connection(sett_conn); + NMConnection *connection = nm_settings_connection_get_connection(sett_conn); if (nm_connection_get_setting_ovs_interface(connection)) { nm_settings_connection_autoconnect_retries_reset(sett_conn); @@ -1556,7 +1556,7 @@ reset_autoconnect_all( NMDevice *device, /* if present, only reset connections compatible with @device */ gboolean only_no_secrets) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); NMSettingsConnection *const *connections = NULL; guint i; gboolean changed = FALSE; @@ -1613,7 +1613,7 @@ static void sleeping_changed(NMManager *manager, GParamSpec *pspec, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); gboolean sleeping = FALSE, enabled = FALSE; g_object_get(G_OBJECT(manager), NM_MANAGER_SLEEPING, &sleeping, NULL); @@ -1627,10 +1627,10 @@ sleeping_changed(NMManager *manager, GParamSpec *pspec, gpointer user_data) static void schedule_activate_check(NMPolicy *self, NMDevice *device) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - ActivateData * data; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + ActivateData *data; NMActiveConnection *ac; - const CList * tmp_list; + const CList *tmp_list; if (nm_manager_get_state(priv->manager) == NM_STATE_ASLEEP) return; @@ -1658,8 +1658,8 @@ schedule_activate_check(NMPolicy *self, NMDevice *device) static gboolean reset_connections_retries(gpointer user_data) { - NMPolicy * self = (NMPolicy *) user_data; - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicy *self = (NMPolicy *) user_data; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); NMSettingsConnection *const *connections = NULL; guint i; gint32 con_stamp, min_stamp, now; @@ -1724,12 +1724,12 @@ _connection_autoconnect_retries_set(NMPolicy *self, NMSettingsConnection *connec static void activate_slave_connections(NMPolicy *self, NMDevice *device) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - const char * master_device; - const char * master_uuid_settings = NULL; - const char * master_uuid_applied = NULL; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + const char *master_device; + const char *master_uuid_settings = NULL; + const char *master_uuid_applied = NULL; guint i; - NMActRequest * req; + NMActRequest *req; gboolean internal_activation = FALSE; NMSettingsConnection *const *connections; gboolean changed; @@ -1739,9 +1739,9 @@ activate_slave_connections(NMPolicy *self, NMDevice *device) req = nm_device_get_act_request(device); if (req) { - NMConnection * connection; + NMConnection *connection; NMSettingsConnection *sett_conn; - NMAuthSubject * subject; + NMAuthSubject *subject; connection = nm_active_connection_get_applied_connection(NM_ACTIVE_CONNECTION(req)); if (connection) @@ -1763,8 +1763,8 @@ activate_slave_connections(NMPolicy *self, NMDevice *device) connections = nm_settings_get_connections(priv->settings, NULL); for (i = 0; connections[i]; i++) { NMSettingsConnection *sett_conn = connections[i]; - NMSettingConnection * s_slave_con; - const char * slave_master; + NMSettingConnection *s_slave_con; + const char *slave_master; s_slave_con = nm_connection_get_setting_connection(nm_settings_connection_get_connection(sett_conn)); @@ -1795,12 +1795,12 @@ activate_slave_connections(NMPolicy *self, NMDevice *device) static gboolean activate_secondary_connections(NMPolicy *self, NMConnection *connection, NMDevice *device) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - NMSettingConnection * s_con; - NMActiveConnection * ac; - PendingSecondaryData * secondary_data; - GSList * secondary_ac_list = NULL; - GError * error = NULL; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + NMSettingConnection *s_con; + NMActiveConnection *ac; + PendingSecondaryData *secondary_data; + GSList *secondary_ac_list = NULL; + GError *error = NULL; guint32 i; gboolean success = TRUE; NMActivationStateFlags initial_state_flags; @@ -1814,8 +1814,8 @@ activate_secondary_connections(NMPolicy *self, NMConnection *connection, NMDevic for (i = 0; i < nm_setting_connection_get_num_secondaries(s_con); i++) { NMSettingsConnection *sett_conn; - const char * sec_uuid = nm_setting_connection_get_secondary(s_con, i); - NMActRequest * req; + const char *sec_uuid = nm_setting_connection_get_secondary(s_con, i); + NMActRequest *req; sett_conn = nm_settings_get_connection_by_uuid(priv->settings, sec_uuid); if (!sett_conn) { @@ -1881,17 +1881,17 @@ activate_secondary_connections(NMPolicy *self, NMConnection *connection, NMDevic } static void -device_state_changed(NMDevice * device, +device_state_changed(NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, gpointer user_data) { - NMPolicyPrivate * priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); - NMActiveConnection * ac; + NMPolicyPrivate *priv = user_data; + NMPolicy *self = _PRIV_TO_SELF(priv); + NMActiveConnection *ac; NMSettingsConnection *sett_conn = nm_device_get_settings_connection(device); - NMSettingConnection * s_con = NULL; + NMSettingConnection *s_con = NULL; switch (nm_device_state_reason_check(reason)) { case NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED: @@ -2094,13 +2094,13 @@ device_state_changed(NMDevice * device, } static void -device_l3cd_changed(NMDevice * device, +device_l3cd_changed(NMDevice *device, const NML3ConfigData *l3cd_old, const NML3ConfigData *l3cd_new, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); NMDeviceState state; nm_assert(!l3cd_new || NM_IS_L3_CONFIG_DATA(l3cd_new)); @@ -2150,7 +2150,7 @@ static void device_platform_address_changed(NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); NMDeviceState state; state = nm_device_get_state(device); @@ -2165,7 +2165,7 @@ static void device_autoconnect_changed(NMDevice *device, GParamSpec *pspec, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); schedule_activate_check(self, device); } @@ -2174,7 +2174,7 @@ static void device_recheck_auto_activate(NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); schedule_activate_check(self, device); } @@ -2221,7 +2221,7 @@ static void device_added(NMManager *manager, NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); g_return_if_fail(NM_IS_POLICY(self)); @@ -2237,8 +2237,8 @@ static void device_removed(NMManager *manager, NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); - ActivateData * data; + NMPolicy *self = _PRIV_TO_SELF(priv); + ActivateData *data; /* TODO: is this needed? The delegations are cleaned up * on transition to deactivated too. */ @@ -2287,11 +2287,11 @@ vpn_connection_update_dns(NMPolicy *self, NMVpnConnection *vpn, gboolean remove) } static void -vpn_connection_state_changed(NMVpnConnection * vpn, +vpn_connection_state_changed(NMVpnConnection *vpn, NMVpnConnectionState new_state, NMVpnConnectionState old_state, NMActiveConnectionStateReason reason, - NMPolicy * self) + NMPolicy *self) { /* FIXME(l3cfg): we need to track changes to nm_vpn_connection_get_l3cd(). */ if (new_state == NM_VPN_CONNECTION_STATE_ACTIVATED) @@ -2307,10 +2307,10 @@ vpn_connection_state_changed(NMVpnConnection * vpn, static void vpn_connection_retry_after_failure(NMVpnConnection *vpn, NMPolicy *self) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - NMActiveConnection * ac = NM_ACTIVE_CONNECTION(vpn); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + NMActiveConnection *ac = NM_ACTIVE_CONNECTION(vpn); NMSettingsConnection *connection = nm_active_connection_get_settings_connection(ac); - GError * error = NULL; + GError *error = NULL; /* Attempt to reconnect VPN connections that failed after being connected */ if (!nm_manager_activate_connection( @@ -2347,9 +2347,9 @@ active_connection_state_changed(NMActiveConnection *active, GParamSpec *pspec, N static void active_connection_keep_alive_changed(NMKeepAlive *keep_alive, GParamSpec *pspec, NMPolicy *self) { - NMPolicyPrivate * priv; + NMPolicyPrivate *priv; NMActiveConnection *ac; - GError * error = NULL; + GError *error = NULL; nm_assert(NM_IS_POLICY(self)); nm_assert(NM_IS_KEEP_ALIVE(keep_alive)); @@ -2381,8 +2381,8 @@ static void active_connection_added(NMManager *manager, NMActiveConnection *active, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); - NMKeepAlive * keep_alive; + NMPolicy *self = _PRIV_TO_SELF(priv); + NMKeepAlive *keep_alive; if (NM_IS_VPN_CONNECTION(active)) { g_signal_connect(active, @@ -2414,7 +2414,7 @@ static void active_connection_removed(NMManager *manager, NMActiveConnection *active, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); g_signal_handlers_disconnect_by_func(active, vpn_connection_state_changed, self); g_signal_handlers_disconnect_by_func(active, vpn_connection_retry_after_failure, self); @@ -2429,10 +2429,10 @@ active_connection_removed(NMManager *manager, NMActiveConnection *active, gpoint static gboolean schedule_activate_all_cb(gpointer user_data) { - NMPolicy * self = user_data; + NMPolicy *self = user_data; NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - const CList * tmp_lst; - NMDevice * device; + const CList *tmp_lst; + NMDevice *device; priv->schedule_activate_all_id = 0; @@ -2457,7 +2457,7 @@ static void connection_added(NMSettings *settings, NMSettingsConnection *connection, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); schedule_activate_all(self); } @@ -2466,10 +2466,10 @@ static void firewall_state_changed(NMFirewalldManager *manager, int signal_type_i, gpointer user_data) { const NMFirewalldManagerStateChangedType signal_type = signal_type_i; - NMPolicy * self = user_data; - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); - const CList * tmp_lst; - NMDevice * device; + NMPolicy *self = user_data; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); + const CList *tmp_lst; + NMDevice *device; if (signal_type == NM_FIREWALLD_MANAGER_STATE_CHANGED_TYPE_INITIALIZED) { /* the firewall manager was initializing, but all requests @@ -2489,10 +2489,10 @@ firewall_state_changed(NMFirewalldManager *manager, int signal_type_i, gpointer static void dns_config_changed(NMDnsManager *dns_manager, gpointer user_data) { - NMPolicy * self = (NMPolicy *) user_data; + NMPolicy *self = (NMPolicy *) user_data; NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - NMDevice * device; - const CList * tmp_lst; + NMDevice *device; + const CList *tmp_lst; /* We are currently updating the hostname in the DNS manager. * This doesn't warrant a new DNS lookup.*/ @@ -2507,18 +2507,18 @@ dns_config_changed(NMDnsManager *dns_manager, gpointer user_data) } static void -connection_updated(NMSettings * settings, +connection_updated(NMSettings *settings, NMSettingsConnection *connection, guint update_reason_u, gpointer user_data) { - NMPolicyPrivate * priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicyPrivate *priv = user_data; + NMPolicy *self = _PRIV_TO_SELF(priv); NMSettingsConnectionUpdateReason update_reason = update_reason_u; if (NM_FLAGS_HAS(update_reason, NM_SETTINGS_CONNECTION_UPDATE_REASON_REAPPLY_PARTIAL)) { const CList *tmp_lst; - NMDevice * device; + NMDevice *device; /* find device with given connection */ nm_manager_for_each_device (priv->manager, device, tmp_lst) { @@ -2533,10 +2533,10 @@ connection_updated(NMSettings * settings, static void _deactivate_if_active(NMPolicy *self, NMSettingsConnection *connection) { - NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self); + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); NMActiveConnection *ac; - const CList * tmp_list, *tmp_safe; - GError * error = NULL; + const CList *tmp_list, *tmp_safe; + GError *error = NULL; nm_assert(NM_IS_SETTINGS_CONNECTION(connection)); @@ -2562,7 +2562,7 @@ static void connection_removed(NMSettings *settings, NMSettingsConnection *connection, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); _deactivate_if_active(self, connection); } @@ -2571,7 +2571,7 @@ static void connection_flags_changed(NMSettings *settings, NMSettingsConnection *connection, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy * self = _PRIV_TO_SELF(priv); + NMPolicy *self = _PRIV_TO_SELF(priv); if (NM_FLAGS_HAS(nm_settings_connection_get_flags(connection), NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE)) { @@ -2631,7 +2631,7 @@ static NM_UTILS_LOOKUP_STR_DEFINE(_hostname_mode_to_string, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMPolicy * self = NM_POLICY(object); + NMPolicy *self = NM_POLICY(object); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); switch (prop_id) { @@ -2656,7 +2656,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMPolicy * self = NM_POLICY(object); + NMPolicy *self = NM_POLICY(object); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); switch (prop_id) { @@ -2682,7 +2682,7 @@ static void nm_policy_init(NMPolicy *self) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - gs_free char * hostname_mode = NULL; + gs_free char *hostname_mode = NULL; c_list_init(&priv->pending_activation_checks); @@ -2711,9 +2711,9 @@ nm_policy_init(NMPolicy *self) static void constructed(GObject *object) { - NMPolicy * self = NM_POLICY(object); + NMPolicy *self = NM_POLICY(object); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); - char * hostname = NULL; + char *hostname = NULL; /* Grab hostname on startup and use that if nothing provides one */ if ((hostname = _get_hostname(self))) { @@ -2817,11 +2817,11 @@ nm_policy_new(NMManager *manager, NMSettings *settings) static void dispose(GObject *object) { - NMPolicy * self = NM_POLICY(object); + NMPolicy *self = NM_POLICY(object); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); GHashTableIter h_iter; - NMDevice * device; - ActivateData * data, *data_safe; + NMDevice *device; + ActivateData *data, *data_safe; nm_clear_g_object(&priv->default_ac4); nm_clear_g_object(&priv->default_ac6); @@ -2899,7 +2899,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMPolicy * self = NM_POLICY(object); + NMPolicy *self = NM_POLICY(object); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); g_hash_table_unref(priv->devices); diff --git a/src/core/nm-rfkill-manager.c b/src/core/nm-rfkill-manager.c index 7f0b772629..f3851e5ca6 100644 --- a/src/core/nm-rfkill-manager.c +++ b/src/core/nm-rfkill-manager.c @@ -25,7 +25,7 @@ typedef struct { /* Authoritative rfkill state (RFKILL_* enum) */ RfKillState rfkill_states[RFKILL_TYPE_MAX]; - GSList * killswitches; + GSList *killswitches; } NMRfkillManagerPrivate; struct _NMRfkillManager { @@ -45,10 +45,10 @@ G_DEFINE_TYPE(NMRfkillManager, nm_rfkill_manager, G_TYPE_OBJECT) /*****************************************************************************/ typedef struct { - char * name; + char *name; guint64 seqnum; - char * path; - char * driver; + char *path; + char *driver; RfKillType rtype; int state; gboolean platform; @@ -90,9 +90,9 @@ rfkill_state_to_desc(RfKillState rstate) static Killswitch * killswitch_new(struct udev_device *device, RfKillType rtype) { - Killswitch * ks; + Killswitch *ks; struct udev_device *parent = NULL, *grandparent = NULL; - const char * driver, *subsys, *parent_subsys = NULL; + const char *driver, *subsys, *parent_subsys = NULL; ks = g_malloc0(sizeof(Killswitch)); ks->name = g_strdup(udev_device_get_sysname(device)); @@ -161,7 +161,7 @@ static void recheck_killswitches(NMRfkillManager *self) { NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self); - GSList * iter; + GSList *iter; RfKillState poll_states[RFKILL_TYPE_MAX]; RfKillState platform_states[RFKILL_TYPE_MAX]; gboolean platform_checked[RFKILL_TYPE_MAX]; @@ -176,7 +176,7 @@ recheck_killswitches(NMRfkillManager *self) /* Poll the states of all killswitches */ for (iter = priv->killswitches; iter; iter = g_slist_next(iter)) { - Killswitch * ks = iter->data; + Killswitch *ks = iter->data; struct udev_device *device; RfKillState dev_state; int sysfs_state; @@ -239,7 +239,7 @@ static Killswitch * killswitch_find_by_name(NMRfkillManager *self, const char *name) { NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self); - GSList * iter; + GSList *iter; g_return_val_if_fail(name != NULL, NULL); @@ -269,9 +269,9 @@ static void add_one_killswitch(NMRfkillManager *self, struct udev_device *device) { NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self); - const char * str_type; + const char *str_type; RfKillType rtype; - Killswitch * ks; + Killswitch *ks; str_type = udev_device_get_property_value(device, "RFKILL_TYPE"); rtype = rfkill_type_to_enum(str_type); @@ -307,8 +307,8 @@ static void rfkill_remove(NMRfkillManager *self, struct udev_device *device) { NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self); - GSList * iter; - const char * name; + GSList *iter; + const char *name; g_return_if_fail(device != NULL); name = udev_device_get_sysname(device); @@ -330,8 +330,8 @@ static void handle_uevent(NMUdevClient *client, struct udev_device *device, gpointer user_data) { NMRfkillManager *self = NM_RFKILL_MANAGER(user_data); - const char * subsys; - const char * action; + const char *subsys; + const char *action; action = udev_device_get_action(device); @@ -360,7 +360,7 @@ static void nm_rfkill_manager_init(NMRfkillManager *self) { NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self); - struct udev_enumerate * enumerate; + struct udev_enumerate *enumerate; struct udev_list_entry *iter; guint i; @@ -397,7 +397,7 @@ nm_rfkill_manager_new(void) static void dispose(GObject *object) { - NMRfkillManager * self = NM_RFKILL_MANAGER(object); + NMRfkillManager *self = NM_RFKILL_MANAGER(object); NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self); if (priv->killswitches) { diff --git a/src/core/nm-session-monitor.c b/src/core/nm-session-monitor.c index 2cc99ab3b9..08bfedca6f 100644 --- a/src/core/nm-session-monitor.c +++ b/src/core/nm-session-monitor.c @@ -48,14 +48,14 @@ struct _NMSessionMonitor { #if SESSION_TRACKING_XLOGIND struct { sd_login_monitor *monitor; - GSource * watch; + GSource *watch; } sd; #endif #if SESSION_TRACKING_CONSOLEKIT struct { GFileMonitor *monitor; - GHashTable * cache; + GHashTable *cache; time_t timestamp; } ck; #endif @@ -145,8 +145,8 @@ static gboolean ck_load_cache(GHashTable *cache) { GKeyFile *keyfile = g_key_file_new(); - char ** groups = NULL; - GError * error = NULL; + char **groups = NULL; + GError *error = NULL; gsize i, len; gboolean finished = FALSE; @@ -235,9 +235,9 @@ ck_session_exists(NMSessionMonitor *monitor, uid_t uid, gboolean active) } static void -ck_changed(GFileMonitor * file_monitor, - GFile * file, - GFile * other_file, +ck_changed(GFileMonitor *file_monitor, + GFile *file, + GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { @@ -247,7 +247,7 @@ ck_changed(GFileMonitor * file_monitor, static void ck_init(NMSessionMonitor *monitor) { - GFile * file = g_file_new_for_path(CKDB_PATH); + GFile *file = g_file_new_for_path(CKDB_PATH); GError *error = NULL; if (g_file_query_exists(file, NULL)) { diff --git a/src/core/nm-sleep-monitor.c b/src/core/nm-sleep-monitor.c index 76f132033e..a7ea496de9 100644 --- a/src/core/nm-sleep-monitor.c +++ b/src/core/nm-sleep-monitor.c @@ -133,10 +133,10 @@ drop_inhibitor(NMSleepMonitor *self, gboolean force) static void inhibit_done(GObject *source, GAsyncResult *result, gpointer user_data) { - GDBusProxy * proxy = G_DBUS_PROXY(source); - NMSleepMonitor *self = user_data; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *res = NULL; + GDBusProxy *proxy = G_DBUS_PROXY(source); + NMSleepMonitor *self = user_data; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *res = NULL; gs_unref_object GUnixFDList *fd_list = NULL; res = g_dbus_proxy_call_with_unix_fd_list_finish(proxy, &fd_list, result, &error); @@ -193,9 +193,9 @@ prepare_for_sleep_cb(GDBusProxy *proxy, gboolean is_about_to_suspend, gpointer d static void name_owner_cb(GObject *object, GParamSpec *pspec, gpointer user_data) { - GDBusProxy * proxy = G_DBUS_PROXY(object); + GDBusProxy *proxy = G_DBUS_PROXY(object); NMSleepMonitor *self = NM_SLEEP_MONITOR(user_data); - char * owner; + char *owner; g_assert(proxy == self->proxy); @@ -280,7 +280,7 @@ nm_sleep_monitor_inhibit_release(NMSleepMonitor *self, NMSleepMonitorInhibitorHa static void on_proxy_acquired(GObject *object, GAsyncResult *res, NMSleepMonitor *self) { - GError * error = NULL; + GError *error = NULL; GDBusProxy *proxy; proxy = g_dbus_proxy_new_for_bus_finish(res, &error); diff --git a/src/core/nm-sudo-call.c b/src/core/nm-sudo-call.c index 6f9ca4f138..a08f2aef07 100644 --- a/src/core/nm-sudo-call.c +++ b/src/core/nm-sudo-call.c @@ -13,12 +13,12 @@ static void _nm_sudo_call_get_fd_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - NMSudoCallGetFDCallback callback; - gpointer callback_data; - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; + NMSudoCallGetFDCallback callback; + gpointer callback_data; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; gs_unref_object GUnixFDList *fd_list = NULL; - gs_free int * fd_arr = NULL; + gs_free int *fd_arr = NULL; nm_utils_user_data_unpack(user_data, &callback, &callback_data); @@ -52,7 +52,7 @@ _nm_sudo_call_get_fd_fail_on_idle(gpointer user_data) gs_unref_object GCancellable *cancellable = NULL; NMSudoCallGetFDCallback callback; gpointer callback_data; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; nm_utils_user_data_unpack(user_data, &cancellable, &callback, &callback_data); @@ -65,7 +65,7 @@ _nm_sudo_call_get_fd_fail_on_idle(gpointer user_data) void nm_sudo_call_get_fd(NMSudoGetFDType fd_type, - GCancellable * cancellable, + GCancellable *cancellable, NMSudoCallGetFDCallback callback, gpointer user_data) { diff --git a/src/core/nm-sudo-call.h b/src/core/nm-sudo-call.h index 741ae19b5b..feb2c25c24 100644 --- a/src/core/nm-sudo-call.h +++ b/src/core/nm-sudo-call.h @@ -8,7 +8,7 @@ typedef void (*NMSudoCallGetFDCallback)(int fd_take, GError *error, gpointer user_data); void nm_sudo_call_get_fd(NMSudoGetFDType fd_type, - GCancellable * cancellable, + GCancellable *cancellable, NMSudoCallGetFDCallback callback, gpointer user_data); diff --git a/src/core/nm-test-utils-core.h b/src/core/nm-test-utils-core.h index e037ba9229..6f571972b8 100644 --- a/src/core/nm-test-utils-core.h +++ b/src/core/nm-test-utils-core.h @@ -36,8 +36,8 @@ nmtst_platform_ip4_address(const char *address, const char *peer_address, guint } static inline NMPlatformIP4Address * -nmtst_platform_ip4_address_full(const char * address, - const char * peer_address, +nmtst_platform_ip4_address_full(const char *address, + const char *peer_address, guint plen, int ifindex, NMIPConfigSource source, @@ -45,7 +45,7 @@ nmtst_platform_ip4_address_full(const char * address, guint32 lifetime, guint32 preferred, guint32 flags, - const char * label) + const char *label) { NMPlatformIP4Address *addr = nmtst_platform_ip4_address(address, peer_address, plen); @@ -80,8 +80,8 @@ nmtst_platform_ip6_address(const char *address, const char *peer_address, guint } static inline NMPlatformIP6Address * -nmtst_platform_ip6_address_full(const char * address, - const char * peer_address, +nmtst_platform_ip6_address_full(const char *address, + const char *peer_address, guint plen, int ifindex, NMIPConfigSource source, @@ -118,15 +118,15 @@ nmtst_platform_ip4_route(const char *network, guint plen, const char *gateway) } static inline NMPlatformIP4Route * -nmtst_platform_ip4_route_full(const char * network, +nmtst_platform_ip4_route_full(const char *network, guint plen, - const char * gateway, + const char *gateway, int ifindex, NMIPConfigSource source, guint metric, guint mss, guint8 scope, - const char * pref_src) + const char *pref_src) { NMPlatformIP4Route *route = nmtst_platform_ip4_route(network, plen, gateway); @@ -157,9 +157,9 @@ nmtst_platform_ip6_route(const char *network, guint plen, const char *gateway, c } static inline NMPlatformIP6Route * -nmtst_platform_ip6_route_full(const char * network, +nmtst_platform_ip6_route_full(const char *network, guint plen, - const char * gateway, + const char *gateway, int ifindex, NMIPConfigSource source, guint metric, @@ -188,7 +188,7 @@ nmtst_platform_ip4_routes_equal(const NMPlatformIP4Route *a, gsize len, gboolean ignore_order) { - gsize i; + gsize i; gs_free const NMPlatformIP4Route *c_a = NULL, *c_b = NULL; g_assert(a); @@ -225,12 +225,12 @@ nmtst_platform_ip4_routes_equal(const NMPlatformIP4Route *a, #ifdef __NMP_OBJECT_H__ static inline void -nmtst_platform_ip4_routes_equal_aptr(const NMPObject *const * a, +nmtst_platform_ip4_routes_equal_aptr(const NMPObject *const *a, const NMPlatformIP4Route *b, gsize len, gboolean ignore_order) { - gsize i; + gsize i; gs_free NMPlatformIP4Route *c_a = NULL; g_assert(len > 0); @@ -257,7 +257,7 @@ nmtst_platform_ip6_routes_equal(const NMPlatformIP6Route *a, gsize len, gboolean ignore_order) { - gsize i; + gsize i; gs_free const NMPlatformIP6Route *c_a = NULL, *c_b = NULL; g_assert(a); @@ -294,12 +294,12 @@ nmtst_platform_ip6_routes_equal(const NMPlatformIP6Route *a, #ifdef __NMP_OBJECT_H__ static inline void -nmtst_platform_ip6_routes_equal_aptr(const NMPObject *const * a, +nmtst_platform_ip6_routes_equal_aptr(const NMPObject *const *a, const NMPlatformIP6Route *b, gsize len, gboolean ignore_order) { - gsize i; + gsize i; gs_free NMPlatformIP6Route *c_a = NULL; g_assert(len > 0); diff --git a/src/core/nm-types.h b/src/core/nm-types.h index 76287e4dbf..18f44ca94c 100644 --- a/src/core/nm-types.h +++ b/src/core/nm-types.h @@ -37,10 +37,10 @@ typedef struct _NMSleepMonitor NMSleepMonitor; typedef struct _NMLldpListener NMLldpListener; typedef struct _NMConfigDeviceStateData NMConfigDeviceStateData; -typedef void (*NMManagerDeviceAuthRequestFunc)(NMDevice * device, +typedef void (*NMManagerDeviceAuthRequestFunc)(NMDevice *device, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer user_data); struct _NMDedupMultiIndex; diff --git a/src/core/platform/nm-fake-platform.c b/src/core/platform/nm-fake-platform.c index 870350c5ca..ebb6a795b9 100644 --- a/src/core/platform/nm-fake-platform.c +++ b/src/core/platform/nm-fake-platform.c @@ -23,13 +23,13 @@ typedef struct { const NMPObject *obj; - char * udi; + char *udi; struct in6_addr ip6_lladdr; } NMFakePlatformLink; typedef struct { GHashTable *options; - GArray * links; + GArray *links; } NMFakePlatformPrivate; struct _NMFakePlatform { @@ -60,7 +60,7 @@ G_DEFINE_TYPE(NMFakePlatform, nm_fake_platform, NM_TYPE_PLATFORM) \ if (nm_logging_enabled(__level, __domain)) { \ char __prefix[32]; \ - const char * __p_prefix = _NMLOG_PREFIX_NAME; \ + const char *__p_prefix = _NMLOG_PREFIX_NAME; \ NMPlatform *const __self = (self); \ \ if (__self && nm_platform_get_log_with_ptr(self)) { \ @@ -80,12 +80,12 @@ G_DEFINE_TYPE(NMFakePlatform, nm_fake_platform, NM_TYPE_PLATFORM) /*****************************************************************************/ -static void link_changed(NMPlatform * platform, +static void link_changed(NMPlatform *platform, NMFakePlatformLink *device, NMPCacheOpsType cache_op, - const NMPObject * obj_old); + const NMPObject *obj_old); -static gboolean ipx_address_delete(NMPlatform * platform, +static gboolean ipx_address_delete(NMPlatform *platform, int addr_family, int ifindex, gconstpointer addr, @@ -95,7 +95,7 @@ static gboolean ipx_address_delete(NMPlatform * platform, static gboolean ipx_route_delete(NMPlatform *platform, int addr_family, int ifindex, const NMPObject *obj); -static gboolean ip6_address_add(NMPlatform * platform, +static gboolean ip6_address_add(NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen, @@ -143,7 +143,7 @@ static char * sysctl_get(NMPlatform *platform, const char *pathid, int dirfd, const char *path) { NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE(platform); - const char * v; + const char *v; ASSERT_SYSCTL_ARGS(pathid, dirfd, path); @@ -160,7 +160,7 @@ static NMFakePlatformLink * link_get(NMPlatform *platform, int ifindex) { NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE(platform); - NMFakePlatformLink * device; + NMFakePlatformLink *device; int idx; if (ifindex <= 0) @@ -226,11 +226,11 @@ link_add_pre(NMPlatform *platform, guint32 mtu) { NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE(platform); - NMFakePlatformLink * device; + NMFakePlatformLink *device; int ifindex; - NMPObject * o; - NMPlatformLink * link; - gs_free char * ip6_lladdr = NULL; + NMPObject *o; + NMPlatformLink *link; + gs_free char *ip6_lladdr = NULL; g_assert(!name || strlen(name) < IFNAMSIZ); @@ -278,27 +278,27 @@ link_add_pre(NMPlatform *platform, } static int -link_add(NMPlatform * platform, +link_add(NMPlatform *platform, NMLinkType type, - const char * name, + const char *name, int parent, - const void * address, + const void *address, size_t address_len, guint32 mtu, gconstpointer extra_data, const NMPlatformLink **out_link) { - NMFakePlatformLink * device; - NMFakePlatformLink * device_veth = NULL; + NMFakePlatformLink *device; + NMFakePlatformLink *device_veth = NULL; nm_auto_nmpobj const NMPObject *obj_old = NULL; nm_auto_nmpobj const NMPObject *obj_new = NULL; nm_auto_nmpobj const NMPObject *obj_old_veth = NULL; nm_auto_nmpobj const NMPObject *obj_new_veth = NULL; NMPCacheOpsType cache_op; NMPCacheOpsType cache_op_veth = NMP_CACHE_OPS_UNCHANGED; - const char * veth_peer = NULL; - NMPObject * dev_obj; - NMPObject * dev_lnk = NULL; + const char *veth_peer = NULL; + NMPObject *dev_obj; + NMPObject *dev_lnk = NULL; device = link_add_pre(platform, name, type, address, address_len, mtu); @@ -389,13 +389,13 @@ static NMFakePlatformLink * link_add_one(NMPlatform *platform, const char *name, NMLinkType link_type, - void (*prepare_fcn)(NMPlatform * platform, + void (*prepare_fcn)(NMPlatform *platform, NMFakePlatformLink *device, gconstpointer user_data), gconstpointer user_data, const NMPlatformLink **out_link) { - NMFakePlatformLink * device; + NMFakePlatformLink *device; nm_auto_nmpobj const NMPObject *obj_old = NULL; nm_auto_nmpobj const NMPObject *obj_new = NULL; NMPCacheOpsType cache_op; @@ -431,7 +431,7 @@ link_add_one(NMPlatform *platform, static gboolean link_delete(NMPlatform *platform, int ifindex) { - NMFakePlatformLink * device = link_get(platform, ifindex); + NMFakePlatformLink *device = link_get(platform, ifindex); nm_auto_nmpobj const NMPObject *obj_old = NULL; nm_auto_nmpobj const NMPObject *obj_old2 = NULL; NMPCacheOpsType cache_op; @@ -459,10 +459,10 @@ link_delete(NMPlatform *platform, int ifindex) static void link_set_obj(NMPlatform *platform, NMFakePlatformLink *device, NMPObject *obj_tmp) { - nm_auto_nmpobj const NMPObject *obj_new = NULL; - nm_auto_nmpobj const NMPObject *obj_old = NULL; - nm_auto_nmpobj NMPObject *obj_tmp_tmp = NULL; - NMPCacheOpsType cache_op; + nm_auto_nmpobj const NMPObject *obj_new = NULL; + nm_auto_nmpobj const NMPObject *obj_old = NULL; + nm_auto_nmpobj NMPObject *obj_tmp_tmp = NULL; + NMPCacheOpsType cache_op; g_assert(device); g_assert(NMP_OBJECT_GET_TYPE(device->obj) == NMP_OBJECT_TYPE_LINK); @@ -519,10 +519,10 @@ link_change_flags(NMPlatform *platform, int ifindex, unsigned flags_mask, unsign } static void -link_changed(NMPlatform * platform, +link_changed(NMPlatform *platform, NMFakePlatformLink *device, NMPCacheOpsType cache_op, - const NMPObject * obj_old) + const NMPObject *obj_old) { g_assert(device->obj); @@ -558,7 +558,7 @@ link_changed(NMPlatform * platform, static int link_set_address(NMPlatform *platform, int ifindex, gconstpointer addr, size_t len) { - NMFakePlatformLink *device = link_get(platform, ifindex); + NMFakePlatformLink *device = link_get(platform, ifindex); nm_auto_nmpobj NMPObject *obj_tmp = NULL; if (len == 0 || len > _NM_UTILS_HWADDR_LEN_MAX || !addr) @@ -579,7 +579,7 @@ link_set_address(NMPlatform *platform, int ifindex, gconstpointer addr, size_t l static int link_set_mtu(NMPlatform *platform, int ifindex, guint32 mtu) { - NMFakePlatformLink *device = link_get(platform, ifindex); + NMFakePlatformLink *device = link_get(platform, ifindex); nm_auto_nmpobj NMPObject *obj_tmp = NULL; if (!device) { @@ -596,9 +596,9 @@ link_set_mtu(NMPlatform *platform, int ifindex, guint32 mtu) static gboolean link_get_driver_info(NMPlatform *platform, int ifindex, - char ** out_driver_name, - char ** out_driver_version, - char ** out_fw_version) + char **out_driver_name, + char **out_driver_version, + char **out_fw_version) { if (out_driver_name) *out_driver_name = NULL; @@ -683,8 +683,8 @@ link_enslave(NMPlatform *platform, int master, int slave) static gboolean link_release(NMPlatform *platform, int master_idx, int slave_idx) { - NMFakePlatformLink *master = link_get(platform, master_idx); - NMFakePlatformLink *slave = link_get(platform, slave_idx); + NMFakePlatformLink *master = link_get(platform, master_idx); + NMFakePlatformLink *slave = link_get(platform, slave_idx); nm_auto_nmpobj NMPObject *obj_tmp = NULL; g_return_val_if_fail(master, FALSE); @@ -700,7 +700,7 @@ link_release(NMPlatform *platform, int master_idx, int slave_idx) } static gboolean -link_vlan_change(NMPlatform * platform, +link_vlan_change(NMPlatform *platform, int ifindex, _NMVlanFlags flags_mask, _NMVlanFlags flags_set, @@ -723,8 +723,8 @@ static void _infiniband_add_prepare(NMPlatform *platform, NMFakePlatformLink *device, gconstpointer user_data) { const struct infiniband_add_data *d = user_data; - NMPObject * obj_tmp; - NMPObject * lnk; + NMPObject *obj_tmp; + NMPObject *lnk; obj_tmp = (NMPObject *) device->obj; @@ -737,12 +737,12 @@ _infiniband_add_prepare(NMPlatform *platform, NMFakePlatformLink *device, gconst } static gboolean -infiniband_partition_add(NMPlatform * platform, +infiniband_partition_add(NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link) { - NMFakePlatformLink * parent_device; + NMFakePlatformLink *parent_device; char name[IFNAMSIZ]; const struct infiniband_add_data d = { .parent = parent, @@ -762,7 +762,7 @@ static gboolean infiniband_partition_delete(NMPlatform *platform, int parent, int p_key) { NMFakePlatformLink *parent_device; - gs_free char * name = NULL; + gs_free char *name = NULL; parent_device = link_get(platform, parent); g_return_val_if_fail(parent_device != NULL, FALSE); @@ -859,11 +859,11 @@ mesh_set_ssid(NMPlatform *platform, int ifindex, const guint8 *ssid, gsize len) static gboolean ipx_address_add(NMPlatform *platform, int addr_family, const NMPlatformObject *address) { - nm_auto_nmpobj NMPObject *obj = NULL; - NMPCacheOpsType cache_op; + nm_auto_nmpobj NMPObject *obj = NULL; + NMPCacheOpsType cache_op; nm_auto_nmpobj const NMPObject *obj_old = NULL; nm_auto_nmpobj const NMPObject *obj_new = NULL; - NMPCache * cache = nm_platform_get_cache(platform); + NMPCache *cache = nm_platform_get_cache(platform); g_assert(NM_IN_SET(addr_family, AF_INET, AF_INET6)); @@ -910,7 +910,7 @@ ip4_address_add(NMPlatform *platform, } static gboolean -ip6_address_add(NMPlatform * platform, +ip6_address_add(NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen, @@ -938,7 +938,7 @@ ip6_address_add(NMPlatform * platform, } static gboolean -ipx_address_delete(NMPlatform * platform, +ipx_address_delete(NMPlatform *platform, int addr_family, int ifindex, gconstpointer addr, @@ -1085,23 +1085,23 @@ object_delete(NMPlatform *platform, const NMPObject *obj) } static int -ip_route_add(NMPlatform * platform, +ip_route_add(NMPlatform *platform, NMPNlmFlags flags, int addr_family, const NMPlatformIPRoute *route) { - NMDedupMultiIter iter; - nm_auto_nmpobj NMPObject *obj = NULL; - NMPCacheOpsType cache_op; - const NMPObject * o = NULL; + NMDedupMultiIter iter; + nm_auto_nmpobj NMPObject *obj = NULL; + NMPCacheOpsType cache_op; + const NMPObject *o = NULL; nm_auto_nmpobj const NMPObject *obj_old = NULL; nm_auto_nmpobj const NMPObject *obj_new = NULL; nm_auto_nmpobj const NMPObject *obj_replace = NULL; - NMPCache * cache = nm_platform_get_cache(platform); + NMPCache *cache = nm_platform_get_cache(platform); gboolean has_gateway = FALSE; - NMPlatformIPRoute * r = NULL; - NMPlatformIP4Route * r4 = NULL; - NMPlatformIP6Route * r6 = NULL; + NMPlatformIPRoute *r = NULL; + NMPlatformIP4Route *r4 = NULL; + NMPlatformIP6Route *r6 = NULL; gboolean has_same_weak_id; gboolean only_dirty; guint16 nlmsgflags; @@ -1296,8 +1296,8 @@ finalize(GObject *object) static void nm_fake_platform_class_init(NMFakePlatformClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMPlatformClass * platform_class = NM_PLATFORM_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); + NMPlatformClass *platform_class = NM_PLATFORM_CLASS(klass); NMPlatformKernelSupportType kernel_support; for (kernel_support = 0; kernel_support < _NM_PLATFORM_KERNEL_SUPPORT_NUM; kernel_support++) diff --git a/src/core/platform/tests/test-address.c b/src/core/platform/tests/test-address.c index 4e1d1d6ee2..700891e88d 100644 --- a/src/core/platform/tests/test-address.c +++ b/src/core/platform/tests/test-address.c @@ -20,12 +20,12 @@ /*****************************************************************************/ static void -ip4_address_callback(NMPlatform * platform, +ip4_address_callback(NMPlatform *platform, NMPObjectType obj_type, int ifindex, - NMPlatformIP4Address * received, + NMPlatformIP4Address *received, NMPlatformSignalChangeType change_type, - SignalData * data) + SignalData *data) { g_assert(received); g_assert_cmpint(received->ifindex, ==, ifindex); @@ -45,12 +45,12 @@ ip4_address_callback(NMPlatform * platform, } static void -ip6_address_callback(NMPlatform * platform, +ip6_address_callback(NMPlatform *platform, NMPObjectType obj_type, int ifindex, - NMPlatformIP6Address * received, + NMPlatformIP6Address *received, NMPlatformSignalChangeType change_type, - SignalData * data) + SignalData *data) { g_assert(received); g_assert_cmpint(received->ifindex, ==, ifindex); @@ -87,7 +87,7 @@ test_ip4_address_general(void) NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback, ifindex); - GArray * addresses; + GArray *addresses; NMPlatformIP4Address *address; in_addr_t addr; guint32 lifetime = 2000; @@ -154,7 +154,7 @@ test_ip6_address_general(void) NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback, ifindex); - GArray * addresses; + GArray *addresses; NMPlatformIP6Address *address; struct in6_addr addr; guint32 lifetime = 2000; @@ -258,10 +258,10 @@ static void test_ip6_address_general_2(void) { const int ifindex = DEVICE_IFINDEX; - SignalData * address_added = add_signal(NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, + SignalData *address_added = add_signal(NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback); - SignalData * address_removed = add_signal(NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, + SignalData *address_removed = add_signal(NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback); struct in6_addr addr; @@ -307,10 +307,10 @@ static void test_ip4_address_peer(void) { const int ifindex = DEVICE_IFINDEX; - SignalData * address_added = add_signal(NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, + SignalData *address_added = add_signal(NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback); - SignalData * address_removed = add_signal(NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, + SignalData *address_removed = add_signal(NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback); in_addr_t addr, addr_peer, addr_peer2; @@ -387,7 +387,7 @@ test_ip4_address_peer_zero(void) const char *label = NULL; in_addr_t peers[3], r_peers[3]; int i; - GArray * addrs; + GArray *addrs; g_assert(ifindex > 0); diff --git a/src/core/platform/tests/test-cleanup.c b/src/core/platform/tests/test-cleanup.c index e13bb8c889..2198e92124 100644 --- a/src/core/platform/tests/test-cleanup.c +++ b/src/core/platform/tests/test-cleanup.c @@ -10,15 +10,15 @@ static void test_cleanup_internal(void) { - SignalData * link_added = add_signal_ifname(NM_PLATFORM_SIGNAL_LINK_CHANGED, + SignalData *link_added = add_signal_ifname(NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME); int ifindex; - GArray * addresses4; - GArray * addresses6; - GPtrArray * routes4; - GPtrArray * routes6; + GArray *addresses4; + GArray *addresses6; + GPtrArray *routes4; + GPtrArray *routes6; in_addr_t addr4; in_addr_t network4; int plen4 = 24; @@ -55,7 +55,7 @@ test_cleanup_internal(void) /* wait for kernel to add the IPv6 link local address... it takes a bit. */ NMTST_WAIT_ASSERT(300, { - gs_unref_array GArray * addrs = NULL; + gs_unref_array GArray *addrs = NULL; const NMPlatformIP6Address *a; if (nmtst_wait_iteration > 0) { diff --git a/src/core/platform/tests/test-common.c b/src/core/platform/tests/test-common.c index 4f56a3a776..24426a5414 100644 --- a/src/core/platform/tests/test-common.c +++ b/src/core/platform/tests/test-common.c @@ -94,7 +94,7 @@ nmtstp_platform_ip_address_find(NMPlatform *self, int ifindex, int addr_family, const int IS_IPv4 = NM_IS_IPv4(addr_family); const NMPlatformIPAddress *found = NULL; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; NMPLookup lookup; g_assert(NM_IS_PLATFORM(self)); @@ -132,9 +132,9 @@ typedef struct { } IPAddressesAssertData; void -_nmtstp_platform_ip_addresses_assert(const char * filename, +_nmtstp_platform_ip_addresses_assert(const char *filename, int lineno, - NMPlatform * self, + NMPlatform *self, int ifindex, gboolean force_exact_4, gboolean force_exact_6, @@ -176,8 +176,8 @@ _nmtstp_platform_ip_addresses_assert(const char * filename, } for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { - const int addr_family = IS_IPv4 ? AF_INET : AF_INET6; - gs_unref_ptrarray GPtrArray *plat_addrs = NULL; + const int addr_family = IS_IPv4 ? AF_INET : AF_INET6; + gs_unref_ptrarray GPtrArray *plat_addrs = NULL; NMPLookup lookup; guint j; @@ -282,7 +282,7 @@ nmtstp_platform_ip4_route_delete(NMPlatform *platform, } gboolean -nmtstp_platform_ip6_route_delete(NMPlatform * platform, +nmtstp_platform_ip6_route_delete(NMPlatform *platform, int ifindex, struct in6_addr network, guint8 plen, @@ -311,11 +311,11 @@ nmtstp_platform_ip6_route_delete(NMPlatform * platform, /*****************************************************************************/ SignalData * -add_signal_full(const char * name, +add_signal_full(const char *name, NMPlatformSignalChangeType change_type, GCallback callback, int ifindex, - const char * ifname) + const char *ifname) { SignalData *data = g_new0(SignalData, 1); @@ -448,18 +448,18 @@ _free_signal(const char *file, int line, const char *func, SignalData *data) } void -link_callback(NMPlatform * platform, +link_callback(NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *received, int change_type_i, - SignalData * data) + SignalData *data) { const NMPObjectType obj_type = obj_type_i; const NMPlatformSignalChangeType change_type = change_type_i; NMPLookup lookup; NMDedupMultiIter iter; - const NMPlatformLink * cached; + const NMPlatformLink *cached; g_assert_cmpint(obj_type, ==, NMP_OBJECT_TYPE_LINK); g_assert(received); @@ -522,11 +522,11 @@ _ip4_route_get(NMPlatform *platform, int plen, guint32 metric, guint8 tos, - guint * out_c_exists) + guint *out_c_exists) { NMDedupMultiIter iter; NMPLookup lookup; - const NMPObject * o = NULL; + const NMPObject *o = NULL; guint c; const NMPlatformIP4Route *r = NULL; @@ -606,18 +606,18 @@ nmtstp_ip4_route_get(NMPlatform *platform, /*****************************************************************************/ static const NMPlatformIP6Route * -_ip6_route_get(NMPlatform * platform, +_ip6_route_get(NMPlatform *platform, int ifindex, const struct in6_addr *network, guint plen, guint32 metric, const struct in6_addr *src, guint8 src_plen, - guint * out_c_exists) + guint *out_c_exists) { NMDedupMultiIter iter; NMPLookup lookup; - const NMPObject * o = NULL; + const NMPObject *o = NULL; guint c; const NMPlatformIP6Route *r = NULL; @@ -639,12 +639,12 @@ _ip6_route_get(NMPlatform * platform, } const NMPlatformIP6Route * -_nmtstp_assert_ip6_route_exists(const char * file, +_nmtstp_assert_ip6_route_exists(const char *file, guint line, - const char * func, - NMPlatform * platform, + const char *func, + NMPlatform *platform, int c_exists, - const char * ifname, + const char *ifname, const struct in6_addr *network, guint plen, guint32 metric, @@ -687,7 +687,7 @@ _nmtstp_assert_ip6_route_exists(const char * file, } const NMPlatformIP6Route * -nmtstp_ip6_route_get(NMPlatform * platform, +nmtstp_ip6_route_get(NMPlatform *platform, int ifindex, const struct in6_addr *network, guint plen, @@ -727,7 +727,7 @@ typedef struct { } WaitForSignalData; static void -_wait_for_signal_cb(NMPlatform * platform, +_wait_for_signal_cb(NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *plink, @@ -1016,7 +1016,7 @@ nmtstp_ip_address_assert_lifetime(const NMPlatformIPAddress *addr, /*****************************************************************************/ static void -_ip_address_add(NMPlatform * platform, +_ip_address_add(NMPlatform *platform, gboolean external_command, gboolean is_v4, int ifindex, @@ -1026,7 +1026,7 @@ _ip_address_add(NMPlatform * platform, guint32 lifetime, guint32 preferred, guint32 flags, - const char * label) + const char *label) { gint64 end_time; @@ -1035,7 +1035,7 @@ _ip_address_add(NMPlatform * platform, _init_platform(&platform, external_command); if (external_command) { - const char * ifname; + const char *ifname; gs_free char *s_valid = NULL; gs_free char *s_preferred = NULL; gs_free char *s_label = NULL; @@ -1193,7 +1193,7 @@ nmtstp_ip4_address_add(NMPlatform *platform, } void -nmtstp_ip6_address_add(NMPlatform * platform, +nmtstp_ip6_address_add(NMPlatform *platform, gboolean external_command, int ifindex, struct in6_addr address, @@ -1217,7 +1217,7 @@ nmtstp_ip6_address_add(NMPlatform * platform, } void -nmtstp_ip4_route_add(NMPlatform * platform, +nmtstp_ip4_route_add(NMPlatform *platform, int ifindex, NMIPConfigSource source, in_addr_t network, @@ -1243,7 +1243,7 @@ nmtstp_ip4_route_add(NMPlatform * platform, } void -nmtstp_ip6_route_add(NMPlatform * platform, +nmtstp_ip6_route_add(NMPlatform *platform, int ifindex, NMIPConfigSource source, struct in6_addr network, @@ -1271,7 +1271,7 @@ nmtstp_ip6_route_add(NMPlatform * platform, /*****************************************************************************/ static void -_ip_address_del(NMPlatform * platform, +_ip_address_del(NMPlatform *platform, gboolean external_command, gboolean is_v4, int ifindex, @@ -1388,7 +1388,7 @@ nmtstp_ip4_address_del(NMPlatform *platform, } void -nmtstp_ip6_address_del(NMPlatform * platform, +nmtstp_ip6_address_del(NMPlatform *platform, gboolean external_command, int ifindex, struct in6_addr address, @@ -1427,7 +1427,7 @@ nmtstp_ip6_address_del(NMPlatform * platform, const NMPlatformLnkBridge * nmtstp_link_bridge_normalize_jiffies_time(const NMPlatformLnkBridge *requested, const NMPlatformLnkBridge *kernel, - NMPlatformLnkBridge * dst) + NMPlatformLnkBridge *dst) { g_assert(requested); g_assert(dst); @@ -1458,12 +1458,12 @@ nmtstp_link_bridge_normalize_jiffies_time(const NMPlatformLnkBridge *requested, } const NMPlatformLink * -nmtstp_link_bridge_add(NMPlatform * platform, +nmtstp_link_bridge_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkBridge *lnk) { - const NMPlatformLink * pllink = NULL; + const NMPlatformLink *pllink = NULL; const NMPlatformLnkBridge *ll = NULL; NMPlatformLnkBridge lnk_normalized; int r = 0; @@ -1686,9 +1686,9 @@ nmtstp_link_dummy_add(NMPlatform *platform, gboolean external_command, const cha } const NMPlatformLink * -nmtstp_link_gre_add(NMPlatform * platform, +nmtstp_link_gre_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkGre *lnk) { const NMPlatformLink *pllink = NULL; @@ -1706,7 +1706,7 @@ nmtstp_link_gre_add(NMPlatform * platform, if (external_command) { gs_free char *dev = NULL; - char * obj, *type; + char *obj, *type; if (lnk->parent_ifindex) dev = @@ -1737,9 +1737,9 @@ nmtstp_link_gre_add(NMPlatform * platform, } const NMPlatformLink * -nmtstp_link_ip6tnl_add(NMPlatform * platform, +nmtstp_link_ip6tnl_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkIp6Tnl *lnk) { const NMPlatformLink *pllink = NULL; @@ -1760,7 +1760,7 @@ nmtstp_link_ip6tnl_add(NMPlatform * platform, if (external_command) { gs_free char *dev = NULL; - const char * mode; + const char *mode; if (lnk->parent_ifindex) dev = @@ -1803,9 +1803,9 @@ nmtstp_link_ip6tnl_add(NMPlatform * platform, } const NMPlatformLink * -nmtstp_link_ip6gre_add(NMPlatform * platform, +nmtstp_link_ip6gre_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkIp6Tnl *lnk) { const NMPlatformLink *pllink = NULL; @@ -1862,9 +1862,9 @@ nmtstp_link_ip6gre_add(NMPlatform * platform, } const NMPlatformLink * -nmtstp_link_ipip_add(NMPlatform * platform, +nmtstp_link_ipip_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkIpIp *lnk) { const NMPlatformLink *pllink = NULL; @@ -1905,9 +1905,9 @@ nmtstp_link_ipip_add(NMPlatform * platform, } const NMPlatformLink * -nmtstp_link_macvlan_add(NMPlatform * platform, +nmtstp_link_macvlan_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, int parent, const NMPlatformLnkMacvlan *lnk) { @@ -1925,7 +1925,7 @@ nmtstp_link_macvlan_add(NMPlatform * platform, if (external_command) { const char *dev; - char * modes[] = { + char *modes[] = { [MACVLAN_MODE_BRIDGE] = "bridge", [MACVLAN_MODE_VEPA] = "vepa", [MACVLAN_MODE_PRIVATE] = "private", @@ -1954,9 +1954,9 @@ nmtstp_link_macvlan_add(NMPlatform * platform, } const NMPlatformLink * -nmtstp_link_sit_add(NMPlatform * platform, +nmtstp_link_sit_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkSit *lnk) { const NMPlatformLink *pllink = NULL; @@ -2001,11 +2001,11 @@ nmtstp_link_sit_add(NMPlatform * platform, } const NMPlatformLink * -nmtstp_link_tun_add(NMPlatform * platform, +nmtstp_link_tun_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkTun *lnk, - int * out_fd) + int *out_fd) { const NMPlatformLink *pllink = NULL; int err; @@ -2066,11 +2066,11 @@ nmtstp_link_tun_add(NMPlatform * platform, } const NMPlatformLink * -nmtstp_link_vrf_add(NMPlatform * platform, +nmtstp_link_vrf_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkVrf *lnk, - gboolean * out_not_supported) + gboolean *out_not_supported) { const NMPlatformLink *pllink = NULL; int r = 0; @@ -2103,9 +2103,9 @@ nmtstp_link_vrf_add(NMPlatform * platform, } const NMPlatformLink * -nmtstp_link_vxlan_add(NMPlatform * platform, +nmtstp_link_vxlan_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkVxlan *lnk) { const NMPlatformLink *pllink = NULL; @@ -2228,7 +2228,7 @@ nmtstp_link_delete(NMPlatform *platform, gint64 end_time; const NMPlatformLink *pllink; gboolean success; - gs_free char * name_copy = NULL; + gs_free char *name_copy = NULL; external_command = nmtstp_run_command_check_external(external_command); @@ -2653,9 +2653,9 @@ main(int argc, char **argv) struct _NMTstpAcdDefender { int ifindex; in_addr_t ip_addr; - NAcd * nacd; + NAcd *nacd; NAcdProbe *probe; - GSource * source; + GSource *source; gint8 announce_started; }; @@ -2713,11 +2713,11 @@ _l3_acd_nacd_event(int fd, GIOCondition condition, gpointer user_data) NMTstpAcdDefender * nmtstp_acd_defender_new(int ifindex, in_addr_t ip_addr, const NMEtherAddr *mac_addr) { - NMTstpAcdDefender * defender; - nm_auto(n_acd_config_freep) NAcdConfig * config = NULL; - nm_auto(n_acd_unrefp) NAcd * nacd = NULL; + NMTstpAcdDefender *defender; + nm_auto(n_acd_config_freep) NAcdConfig *config = NULL; + nm_auto(n_acd_unrefp) NAcd *nacd = NULL; nm_auto(n_acd_probe_config_freep) NAcdProbeConfig *probe_config = NULL; - NAcdProbe * probe = NULL; + NAcdProbe *probe = NULL; int fd; int r; char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; diff --git a/src/core/platform/tests/test-common.h b/src/core/platform/tests/test-common.h index fc4149f0ee..77f2c50de0 100644 --- a/src/core/platform/tests/test-common.h +++ b/src/core/platform/tests/test-common.h @@ -90,19 +90,19 @@ void nmtstp_netns_select_random(NMPlatform **platforms, gsize n_platforms, NMPNe typedef struct { gulong handler_id; - const char * name; + const char *name; NMPlatformSignalChangeType change_type; int received_count; - GMainLoop * loop; + GMainLoop *loop; int ifindex; - const char * ifname; + const char *ifname; } SignalData; -SignalData *add_signal_full(const char * name, +SignalData *add_signal_full(const char *name, NMPlatformSignalChangeType change_type, GCallback callback, int ifindex, - const char * ifname); + const char *ifname); #define add_signal(name, change_type, callback) \ add_signal_full(name, change_type, G_CALLBACK(callback), 0, NULL) #define add_signal_ifindex(name, change_type, callback, ifindex) \ @@ -124,12 +124,12 @@ void _free_signal(const char *file, int line, const char *func, SignalData *data #define ensure_no_signal(data) _ensure_no_signal(__FILE__, __LINE__, G_STRFUNC, data) #define free_signal(data) _free_signal(__FILE__, __LINE__, G_STRFUNC, data) -void link_callback(NMPlatform * platform, +void link_callback(NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *received, int change_type_i, - SignalData * data); + SignalData *data); /*****************************************************************************/ @@ -210,12 +210,12 @@ const NMPlatformIP4Route *nmtstp_ip4_route_get(NMPlatform *platform, guint32 metric, guint8 tos); -const NMPlatformIP6Route *_nmtstp_assert_ip6_route_exists(const char * file, +const NMPlatformIP6Route *_nmtstp_assert_ip6_route_exists(const char *file, guint line, - const char * func, - NMPlatform * platform, + const char *func, + NMPlatform *platform, int c_exists, - const char * ifname, + const char *ifname, const struct in6_addr *network, guint plen, guint32 metric, @@ -241,7 +241,7 @@ const NMPlatformIP6Route *_nmtstp_assert_ip6_route_exists(const char * src, \ src_plen) -const NMPlatformIP6Route *nmtstp_ip6_route_get(NMPlatform * platform, +const NMPlatformIP6Route *nmtstp_ip6_route_get(NMPlatform *platform, int ifindex, const struct in6_addr *network, guint plen, @@ -270,7 +270,7 @@ void nmtstp_ip4_address_add(NMPlatform *platform, guint32 preferred, guint32 flags, const char *label); -void nmtstp_ip6_address_add(NMPlatform * platform, +void nmtstp_ip6_address_add(NMPlatform *platform, gboolean external_command, int ifindex, struct in6_addr address, @@ -285,13 +285,13 @@ void nmtstp_ip4_address_del(NMPlatform *platform, in_addr_t address, int plen, in_addr_t peer_address); -void nmtstp_ip6_address_del(NMPlatform * platform, +void nmtstp_ip6_address_del(NMPlatform *platform, gboolean external_command, int ifindex, struct in6_addr address, int plen); -void nmtstp_ip4_route_add(NMPlatform * platform, +void nmtstp_ip4_route_add(NMPlatform *platform, int ifindex, NMIPConfigSource source, in_addr_t network, @@ -301,7 +301,7 @@ void nmtstp_ip4_route_add(NMPlatform * platform, guint32 metric, guint32 mss); -void nmtstp_ip6_route_add(NMPlatform * platform, +void nmtstp_ip6_route_add(NMPlatform *platform, int ifindex, NMIPConfigSource source, struct in6_addr network, @@ -357,9 +357,9 @@ nmtstp_platform_ip6_address_find(NMPlatform *self, int ifindex, const struct in6 nmtstp_platform_ip_address_find(self, ifindex, AF_INET6, addr); } -void _nmtstp_platform_ip_addresses_assert(const char * filename, +void _nmtstp_platform_ip_addresses_assert(const char *filename, int lineno, - NMPlatform * self, + NMPlatform *self, int ifindex, gboolean force_exact_4, gboolean force_exact_6, @@ -417,7 +417,7 @@ nmtstp_platform_routing_rules_get_count(NMPlatform *platform, int addr_family) { const NMDedupMultiHeadEntry *head_entry; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; NMPLookup lookup; guint n; @@ -440,7 +440,7 @@ gboolean nmtstp_platform_ip4_route_delete(NMPlatform *platform, in_addr_t network, guint8 plen, guint32 metric); -gboolean nmtstp_platform_ip6_route_delete(NMPlatform * platform, +gboolean nmtstp_platform_ip6_route_delete(NMPlatform *platform, int ifindex, struct in6_addr network, guint8 plen, @@ -458,11 +458,11 @@ nmtstp_link_set_updown(NMPlatform *platform, gboolean external_command, int ifin const NMPlatformLnkBridge * nmtstp_link_bridge_normalize_jiffies_time(const NMPlatformLnkBridge *requested, const NMPlatformLnkBridge *kernel, - NMPlatformLnkBridge * dst); + NMPlatformLnkBridge *dst); -const NMPlatformLink *nmtstp_link_bridge_add(NMPlatform * platform, +const NMPlatformLink *nmtstp_link_bridge_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkBridge *lnk); const NMPlatformLink *nmtstp_link_veth_add(NMPlatform *platform, gboolean external_command, @@ -470,44 +470,44 @@ const NMPlatformLink *nmtstp_link_veth_add(NMPlatform *platform, const char *peer); const NMPlatformLink * nmtstp_link_dummy_add(NMPlatform *platform, gboolean external_command, const char *name); -const NMPlatformLink *nmtstp_link_gre_add(NMPlatform * platform, +const NMPlatformLink *nmtstp_link_gre_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkGre *lnk); -const NMPlatformLink *nmtstp_link_ip6tnl_add(NMPlatform * platform, +const NMPlatformLink *nmtstp_link_ip6tnl_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkIp6Tnl *lnk); -const NMPlatformLink *nmtstp_link_ip6gre_add(NMPlatform * platform, +const NMPlatformLink *nmtstp_link_ip6gre_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkIp6Tnl *lnk); -const NMPlatformLink *nmtstp_link_ipip_add(NMPlatform * platform, +const NMPlatformLink *nmtstp_link_ipip_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkIpIp *lnk); -const NMPlatformLink *nmtstp_link_macvlan_add(NMPlatform * platform, +const NMPlatformLink *nmtstp_link_macvlan_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, int parent, const NMPlatformLnkMacvlan *lnk); -const NMPlatformLink *nmtstp_link_sit_add(NMPlatform * platform, +const NMPlatformLink *nmtstp_link_sit_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkSit *lnk); -const NMPlatformLink *nmtstp_link_tun_add(NMPlatform * platform, +const NMPlatformLink *nmtstp_link_tun_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkTun *lnk, - int * out_fd); -const NMPlatformLink *nmtstp_link_vrf_add(NMPlatform * platform, + int *out_fd); +const NMPlatformLink *nmtstp_link_vrf_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkVrf *lnk, - gboolean * out_not_supported); -const NMPlatformLink *nmtstp_link_vxlan_add(NMPlatform * platform, + gboolean *out_not_supported); +const NMPlatformLink *nmtstp_link_vxlan_add(NMPlatform *platform, gboolean external_command, - const char * name, + const char *name, const NMPlatformLnkVxlan *lnk); void nmtstp_link_delete(NMPlatform *platform, @@ -524,7 +524,7 @@ extern int NMTSTP_ENV1_EX; static inline void _nmtstp_env1_wrapper_setup(const NmtstTestData *test_data) { - int * p_ifindex; + int *p_ifindex; gpointer p_ifup; nmtst_test_data_unpack(test_data, &p_ifindex, NULL, NULL, NULL, &p_ifup); diff --git a/src/core/platform/tests/test-link.c b/src/core/platform/tests/test-link.c index 24e3fd999d..48b321d2dd 100644 --- a/src/core/platform/tests/test-link.c +++ b/src/core/platform/tests/test-link.c @@ -169,12 +169,12 @@ software_add(NMLinkType link_type, const char *name) } static void -test_link_changed_signal_cb(NMPlatform * platform, +test_link_changed_signal_cb(NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformIP4Route *route, int change_type_i, - gboolean * p_test_link_changed_signal_arg) + gboolean *p_test_link_changed_signal_arg) { const NMPObjectType obj_type = obj_type_i; const NMPlatformSignalChangeType change_type = change_type_i; @@ -211,7 +211,7 @@ test_slave(int master, int type, SignalData *master_changed) link_callback, SLAVE_NAME); SignalData *link_changed, *link_removed; - char * value; + char *value; NMLinkType link_type = nm_platform_link_get_type(NM_PLATFORM_GET, master); gboolean test_link_changed_signal_arg1; gboolean test_link_changed_signal_arg2; @@ -422,7 +422,7 @@ test_software(NMLinkType link_type, const char *link_typename) link_callback, ifindex); if (link_type == NM_LINK_TYPE_VLAN) { - const NMPlatformLink * plink; + const NMPlatformLink *plink; const NMPlatformLnkVlan *plnk; plnk = nm_platform_link_get_lnk_vlan(NM_PLATFORM_GET, ifindex, &plink); @@ -754,7 +754,7 @@ test_external(void) { const NMPlatformLink *pllink; NMPLinkAddress hw_perm_addr; - SignalData * link_added, *link_changed, *link_removed; + SignalData *link_added, *link_changed, *link_removed; int ifindex; link_added = add_signal_ifname(NM_PLATFORM_SIGNAL_LINK_CHANGED, @@ -1157,10 +1157,10 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode) "wmjW2wDT2EzFkyaGui7YWNLTRu8Q4eD/GVKM2utZkEs="}, }; gs_unref_ptrarray GPtrArray *allowed_ips_keep_alive = NULL; - gs_unref_array GArray *peers = NULL; - NMPlatformLnkWireGuard lnk_wireguard; - int r; - guint i; + gs_unref_array GArray *peers = NULL; + NMPlatformLnkWireGuard lnk_wireguard; + int r; + guint i; allowed_ips_keep_alive = g_ptr_array_new_with_free_func(g_free); @@ -1270,8 +1270,8 @@ test_software_detect(gconstpointer user_data) { const TestAddSoftwareDetectData *test_data = user_data; int ifindex, ifindex_parent; - const NMPlatformLink * plink; - const NMPObject * lnk; + const NMPlatformLink *plink; + const NMPObject *lnk; int r; guint i_step; const gboolean ext = test_data->external_command; @@ -1991,7 +1991,7 @@ static void test_software_detect_add(const char *testpath, NMLinkType link_type, int test_mode) { TestAddSoftwareDetectData *test_data; - char * path; + char *path; test_data = g_new0(TestAddSoftwareDetectData, 1); test_data->link_type = link_type; @@ -2026,8 +2026,8 @@ test_software_detect_add(const char *testpath, NMLinkType link_type, int test_mo static void _assert_xgress_qos_mappings_impl(int ifindex, gboolean is_ingress_map, int n_entries, int n, ...) { - const NMPlatformLink * plink; - const NMPObject * lnk; + const NMPlatformLink *plink; + const NMPObject *lnk; guint n_map; const NMVlanQosMapping *map; va_list ap; @@ -2460,10 +2460,10 @@ test_vlan_set_xgress(void) static void test_create_many_links_do(guint n_devices) { - gint64 time, start_time = nm_utils_get_monotonic_timestamp_nsec(); - guint i; - char name[64]; - const NMPlatformLink *pllink; + gint64 time, start_time = nm_utils_get_monotonic_timestamp_nsec(); + guint i; + char name[64]; + const NMPlatformLink *pllink; gs_unref_array GArray *ifindexes = g_array_sized_new(FALSE, FALSE, sizeof(int), n_devices); const int EX = ((int) (nmtst_get_rand_uint32() % 4)) - 1; @@ -2540,12 +2540,12 @@ test_create_many_links(gconstpointer user_data) static void test_nl_bugs_veth(void) { - const char * IFACE_VETH0 = "nm-test-veth0"; - const char * IFACE_VETH1 = "nm-test-veth1"; - int ifindex_veth0, ifindex_veth1; - int i; - const NMPlatformLink *pllink_veth0, *pllink_veth1; - gs_free_error GError * error = NULL; + const char *IFACE_VETH0 = "nm-test-veth0"; + const char *IFACE_VETH1 = "nm-test-veth1"; + int ifindex_veth0, ifindex_veth1; + int i; + const NMPlatformLink *pllink_veth0, *pllink_veth1; + gs_free_error GError *error = NULL; NMTstpNamespaceHandle *ns_handle = NULL; NMPLinkAddress hw_perm_addr; @@ -2612,8 +2612,8 @@ out: static void test_nl_bugs_spuroius_newlink(void) { - const char * IFACE_BOND0 = "nm-test-bond0"; - const char * IFACE_DUMMY0 = "nm-test-dummy0"; + const char *IFACE_BOND0 = "nm-test-bond0"; + const char *IFACE_DUMMY0 = "nm-test-dummy0"; int ifindex_bond0, ifindex_dummy0; const NMPlatformLink *pllink; NMPLinkAddress hw_perm_addr; @@ -2668,8 +2668,8 @@ again: static void test_nl_bugs_spuroius_dellink(void) { - const char * IFACE_BRIDGE0 = "nm-test-bridge0"; - const char * IFACE_DUMMY0 = "nm-test-dummy0"; + const char *IFACE_BRIDGE0 = "nm-test-bridge0"; + const char *IFACE_DUMMY0 = "nm-test-dummy0"; int ifindex_bridge0, ifindex_dummy0; const NMPlatformLink *pllink; NMPLinkAddress hw_perm_addr; @@ -2745,7 +2745,7 @@ _test_netns_teardown(gpointer fixture, gconstpointer test_data) static NMPlatform * _test_netns_create_platform(void) { - NMPNetns * netns; + NMPNetns *netns; NMPlatform *platform; netns = nmp_netns_new(); @@ -2763,9 +2763,9 @@ _test_netns_create_platform(void) static gboolean _test_netns_check_skip(void) { - static int support = -1; - static int support_errsv = 0; - NMPNetns * netns; + static int support = -1; + static int support_errsv = 0; + NMPNetns *netns; gs_unref_object NMPNetns *netns2 = NULL; netns = nmp_netns_get_current(); @@ -2828,7 +2828,7 @@ test_netns_general(gpointer fixture, gconstpointer test_data) { gs_unref_object NMPlatform *platform_1 = NULL; gs_unref_object NMPlatform *platform_2 = NULL; - NMPNetns * netns_tmp; + NMPNetns *netns_tmp; char sbuf[100]; int i, j, k; gboolean ethtool_support; @@ -2959,7 +2959,7 @@ test_netns_general(gpointer fixture, gconstpointer test_data) static void test_netns_set_netns(gpointer fixture, gconstpointer test_data) { - NMPlatform * platforms[3]; + NMPlatform *platforms[3]; gs_unref_object NMPlatform *platform_0 = NULL; gs_unref_object NMPlatform *platform_1 = NULL; gs_unref_object NMPlatform *platform_2 = NULL; @@ -2997,8 +2997,8 @@ static char * _get_current_namespace_id(int ns_type) { const char *p; - GError * error = NULL; - char * id; + GError *error = NULL; + char *id; switch (ns_type) { case CLONE_NEWNET: @@ -3020,7 +3020,7 @@ _get_current_namespace_id(int ns_type) static char * _get_sysctl_value(const char *path) { - char * data = NULL; + char *data = NULL; gs_free_error GError *error = NULL; if (!g_file_get_contents(path, &data, NULL, &error)) { @@ -3037,10 +3037,10 @@ _get_sysctl_value(const char *path) static void test_netns_push(gpointer fixture, gconstpointer test_data) { - gs_unref_object NMPlatform *platform_0 = NULL; - gs_unref_object NMPlatform *platform_1 = NULL; - gs_unref_object NMPlatform *platform_2 = NULL; - nm_auto_pop_netns NMPNetns *netns_pop = NULL; + gs_unref_object NMPlatform *platform_0 = NULL; + gs_unref_object NMPlatform *platform_1 = NULL; + gs_unref_object NMPlatform *platform_2 = NULL; + nm_auto_pop_netns NMPNetns *netns_pop = NULL; gs_unref_ptrarray GPtrArray *device_names = g_ptr_array_new_with_free_func(g_free); int i, j; const int ns_types_list[] = {CLONE_NEWNET, CLONE_NEWNS, CLONE_NEWNET | CLONE_NEWNS}; @@ -3080,7 +3080,7 @@ test_netns_push(gpointer fixture, gconstpointer test_data) for (i = 0; i < G_N_ELEMENTS(pl); i++) { nm_auto_pop_netns NMPNetns *netns_free = NULL; - char * tmp; + char *tmp; g_assert(nm_platform_netns_push(pl[i].platform, &netns_free)); @@ -3207,8 +3207,8 @@ test_netns_bind_to_path(gpointer fixture, gconstpointer test_data) gs_unref_object NMPlatform *platform_1 = NULL; gs_unref_object NMPlatform *platform_2 = NULL; nm_auto_pop_netns NMPNetns *netns_pop = NULL; - NMPlatform * platforms[3]; - NMPNetns * netns; + NMPlatform *platforms[3]; + NMPNetns *netns; int i; if (_test_netns_check_skip()) @@ -3270,7 +3270,7 @@ test_sysctl_rename(void) nm_auto_close int dirfd = -1; int i; char ifname_buf[IFNAMSIZ]; - char * s; + char *s; const NMPlatformLink *pllink; ifindex[0] = nmtstp_link_dummy_add(PL, -1, IFNAME[0])->ifindex; @@ -3362,19 +3362,19 @@ test_sysctl_rename(void) static void test_sysctl_netns_switch(void) { - const char *const IFNAME = "nm-dummy-0"; - int ifindex, ifindex_tmp; - nm_auto_close int dirfd = -1; - char ifname_buf[IFNAMSIZ]; - char * s; + const char *const IFNAME = "nm-dummy-0"; + int ifindex, ifindex_tmp; + nm_auto_close int dirfd = -1; + char ifname_buf[IFNAMSIZ]; + char *s; gs_unref_object NMPlatform *platform_0 = NULL; gs_unref_object NMPlatform *platform_1 = NULL; gs_unref_object NMPlatform *platform_2 = NULL; nm_auto_pop_netns NMPNetns *netns_pop_1 = NULL; nm_auto_pop_netns NMPNetns *netns_pop_2 = NULL; nm_auto_pop_netns NMPNetns *netns_pop_3 = NULL; - NMPlatform * PL; - NMPlatform * platforms[3]; + NMPlatform *PL; + NMPlatform *platforms[3]; if (_test_netns_check_skip()) return; @@ -3432,7 +3432,7 @@ test_sysctl_netns_switch(void) { gint64 i64; int errsv; - char * v; + char *v; errno = ESRCH; v = nm_platform_sysctl_get( @@ -3501,7 +3501,7 @@ test_sysctl_netns_switch(void) } typedef struct { - GMainLoop * loop; + GMainLoop *loop; const char *path; gboolean expected_success; gint32 expected_value; @@ -3528,10 +3528,10 @@ sysctl_set_async_cb(GError *error, gpointer user_data) static void test_sysctl_set_async(void) { - NMPlatform *const PL = NM_PLATFORM_GET; - const char *const IFNAME = "nm-dummy-0"; - const char *const PATH = "/proc/sys/net/ipv4/conf/nm-dummy-0/rp_filter"; - GMainLoop * loop; + NMPlatform *const PL = NM_PLATFORM_GET; + const char *const IFNAME = "nm-dummy-0"; + const char *const PATH = "/proc/sys/net/ipv4/conf/nm-dummy-0/rp_filter"; + GMainLoop *loop; gs_unref_object GCancellable *cancellable = NULL; gboolean proc_writable; SetAsyncData data; @@ -3583,10 +3583,10 @@ test_sysctl_set_async(void) static void test_sysctl_set_async_fail(void) { - NMPlatform *const PL = NM_PLATFORM_GET; - const char *const IFNAME = "nm-dummy-0"; - const char *const PATH = "/proc/sys/net/ipv4/conf/nm-dummy-0/does-not-exist"; - GMainLoop * loop; + NMPlatform *const PL = NM_PLATFORM_GET; + const char *const IFNAME = "nm-dummy-0"; + const char *const PATH = "/proc/sys/net/ipv4/conf/nm-dummy-0/does-not-exist"; + GMainLoop *loop; gs_unref_object GCancellable *cancellable = NULL; SetAsyncData data; int ifindex; @@ -3620,10 +3620,10 @@ test_sysctl_set_async_fail(void) static gpointer _test_netns_mt_thread(gpointer data) { - NMPNetns * netns1 = data; + NMPNetns *netns1 = data; gs_unref_object NMPNetns *netns2 = NULL; - NMPNetns * netns_bottom; - NMPNetns * initial; + NMPNetns *netns_bottom; + NMPNetns *initial; netns_bottom = nmp_netns_get_initial(); g_assert(netns_bottom); @@ -3654,8 +3654,8 @@ static void test_netns_mt(void) { gs_unref_object NMPNetns *netns1 = NULL; - NMPNetns * initial_from_other_thread; - GThread * th; + NMPNetns *initial_from_other_thread; + GThread *th; if (_test_netns_check_skip()) return; @@ -3732,7 +3732,7 @@ test_ethtool_features_get(void) for (i_run = 0; i_run < 5; i_run++) { NMEthtoolFeatureStates *features; - NMOptionBool * requested; + NMOptionBool *requested; gboolean do_set = TRUE; requested = g_new(NMOptionBool, _NM_ETHTOOL_ID_FEATURE_NUM); diff --git a/src/core/platform/tests/test-nmp-object.c b/src/core/platform/tests/test-nmp-object.c index 6d2236ecb8..ddd5aa938b 100644 --- a/src/core/platform/tests/test-nmp-object.c +++ b/src/core/platform/tests/test-nmp-object.c @@ -30,14 +30,14 @@ test_obj_base(void) GTypeClass k; NMPClass c; } l = {}; - static const GObject * g = &x.g; + static const GObject *g = &x.g; static const GTypeClass *k = &l.k; - static const NMPObject * o = &x.k; - static const NMPClass * c = &l.c; + static const NMPObject *o = &x.k; + static const NMPClass *c = &l.c; - NMObjBaseInst * obj; + NMObjBaseInst *obj; gs_unref_object GCancellable *obj_cancellable = g_cancellable_new(); - nm_auto_nmpobj NMPObject *obj_link = nmp_object_new_link(10); + nm_auto_nmpobj NMPObject *obj_link = nmp_object_new_link(10); g_assert(&g->g_type_instance == (void *) &o->_class); g_assert(&g->g_type_instance.g_class == (void *) &o->_class); @@ -88,9 +88,9 @@ _nmp_object_equal(const NMPObject *a, const NMPObject *b) /*****************************************************************************/ static void -_assert_cache_multi_lookup_contains(const NMPCache * cache, +_assert_cache_multi_lookup_contains(const NMPCache *cache, const NMDedupMultiHeadEntry *head_entry, - const NMPObject * obj, + const NMPObject *obj, gboolean visible_only, gboolean contains) { @@ -126,7 +126,7 @@ _assert_cache_multi_lookup_contains(const NMPCache * cache, } static void -_assert_cache_multi_lookup_contains_link(const NMPCache * cache, +_assert_cache_multi_lookup_contains_link(const NMPCache *cache, gboolean visible_only, const NMPObject *obj, gboolean contains) @@ -144,7 +144,7 @@ _assert_cache_multi_lookup_contains_link(const NMPCache * cache, /*****************************************************************************/ static void -ops_post_check(NMPCache * cache, +ops_post_check(NMPCache *cache, NMPCacheOpsType ops_type, const NMPObject *obj_old, const NMPObject *obj_new, @@ -199,16 +199,16 @@ ops_post_check(NMPCache * cache, } static void -_nmp_cache_update_netlink(NMPCache * cache, - NMPObject * obj, +_nmp_cache_update_netlink(NMPCache *cache, + NMPObject *obj, const NMPObject **out_obj_old, const NMPObject **out_obj_new, NMPCacheOpsType expected_ops_type) { - NMPCacheOpsType ops_type; - const NMPObject *obj_prev; - const NMPObject *obj_old; - const NMPObject *obj_new; + NMPCacheOpsType ops_type; + const NMPObject *obj_prev; + const NMPObject *obj_old; + const NMPObject *obj_new; nm_auto_nmpobj NMPObject *obj_new_expected = NULL; g_assert(cache); @@ -253,13 +253,13 @@ static const NMPlatformLink pl_link_3 = { static void test_cache_link(void) { - NMPCache * cache; - NMPObject * objm1; - const NMPObject * obj_old, *obj_new; - NMPObject objs1; - struct udev_device * udev_device_2 = g_list_nth_data(global.udev_devices, 0); - struct udev_device * udev_device_3 = g_list_nth_data(global.udev_devices, 0); - NMPCacheOpsType ops_type; + NMPCache *cache; + NMPObject *objm1; + const NMPObject *obj_old, *obj_new; + NMPObject objs1; + struct udev_device *udev_device_2 = g_list_nth_data(global.udev_devices, 0); + struct udev_device *udev_device_3 = g_list_nth_data(global.udev_devices, 0); + NMPCacheOpsType ops_type; nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = NULL; gboolean use_udev = nmtst_get_rand_uint32() % 2; @@ -512,11 +512,11 @@ static const NMPlatformQdisc pl_qdisc_2 = { static void test_cache_qdisc(void) { - NMPCache * cache; + NMPCache *cache; nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = NULL; NMPLookup lookup; - const NMDedupMultiHeadEntry * head_entry; - nm_auto_nmpobj NMPObject *obj1a = + const NMDedupMultiHeadEntry *head_entry; + nm_auto_nmpobj NMPObject *obj1a = nmp_object_new(NMP_OBJECT_TYPE_QDISC, (NMPlatformObject *) &pl_qdisc_1a); nm_auto_nmpobj NMPObject *obj1b = nmp_object_new(NMP_OBJECT_TYPE_QDISC, (NMPlatformObject *) &pl_qdisc_1b); @@ -571,7 +571,7 @@ main(int argc, char **argv) udev_client = nm_udev_client_new(NM_MAKE_STRV("net"), NULL, NULL); { - struct udev_enumerate * enumerator; + struct udev_enumerate *enumerator; struct udev_list_entry *devices, *l; enumerator = nm_udev_client_enumerate_new(udev_client); diff --git a/src/core/platform/tests/test-platform-general.c b/src/core/platform/tests/test-platform-general.c index 8ffd92b5a5..7597f4f13e 100644 --- a/src/core/platform/tests/test-platform-general.c +++ b/src/core/platform/tests/test-platform-general.c @@ -39,8 +39,8 @@ test_init_linux_platform(void) static void test_link_get_all(void) { - gs_unref_object NMPlatform *platform = NULL; - gs_unref_ptrarray GPtrArray *links = NULL; + gs_unref_object NMPlatform *platform = NULL; + gs_unref_ptrarray GPtrArray *links = NULL; platform = nm_linux_platform_new(TRUE, NM_PLATFORM_NETNS_SUPPORT_DEFAULT, TRUE); @@ -548,11 +548,11 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data) const guint N_ADDRESSES = 100; const gsize ELM_SIZE = addr_family == AF_INET ? sizeof(NMPlatformIP4Address) : sizeof(NMPlatformIP6Address); - const gboolean DO_REGENERATE = FALSE; - const gboolean PRINT_RESULT = DO_REGENERATE; - const gboolean CHECK_RESULT = !DO_REGENERATE; - gs_free guint8 *addresses = NULL; - gs_free guint64 *rand_map = NULL; + const gboolean DO_REGENERATE = FALSE; + const gboolean PRINT_RESULT = DO_REGENERATE; + const gboolean CHECK_RESULT = !DO_REGENERATE; + gs_free guint8 *addresses = NULL; + gs_free guint64 *rand_map = NULL; gsize i, j; #if !defined(__amd64__) @@ -586,7 +586,7 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data) for (i = 0; i < N_ADDRESSES; i++) { NMPlatformIPXAddress *a = (gpointer) (&addresses[i * ELM_SIZE]); guint64 r = rand_map[i]; - struct in6_addr * a6; + struct in6_addr *a6; #define CONSUME_BITS(r, nbits) \ ({ \ diff --git a/src/core/platform/tests/test-route.c b/src/core/platform/tests/test-route.c index 2b9b2f8f67..37909d55ef 100644 --- a/src/core/platform/tests/test-route.c +++ b/src/core/platform/tests/test-route.c @@ -51,7 +51,7 @@ _wait_for_ipv4_addr_device_route(NMPlatform *platform, } static void -_wait_for_ipv6_addr_non_tentative(NMPlatform * platform, +_wait_for_ipv6_addr_non_tentative(NMPlatform *platform, gint64 timeout_msec, int ifindex, guint addr_n, @@ -83,17 +83,17 @@ _wait_for_ipv6_addr_non_tentative(NMPlatform * platform, } static void -ip4_route_callback(NMPlatform * platform, +ip4_route_callback(NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformIP4Route *received, int change_type_i, - SignalData * data) + SignalData *data) { const NMPObjectType obj_type = obj_type_i; const NMPlatformSignalChangeType change_type = change_type_i; NMPObject o_id; - nm_auto_nmpobj NMPObject *o_id_p = nmp_object_new(NMP_OBJECT_TYPE_IP4_ROUTE, NULL); + nm_auto_nmpobj NMPObject *o_id_p = nmp_object_new(NMP_OBJECT_TYPE_IP4_ROUTE, NULL); g_assert_cmpint(obj_type, ==, NMP_OBJECT_TYPE_IP4_ROUTE); g_assert(received); @@ -119,17 +119,17 @@ ip4_route_callback(NMPlatform * platform, } static void -ip6_route_callback(NMPlatform * platform, +ip6_route_callback(NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformIP6Route *received, int change_type_i, - SignalData * data) + SignalData *data) { const NMPObjectType obj_type = obj_type_i; const NMPlatformSignalChangeType change_type = change_type_i; NMPObject o_id; - nm_auto_nmpobj NMPObject *o_id_p = nmp_object_new(NMP_OBJECT_TYPE_IP6_ROUTE, NULL); + nm_auto_nmpobj NMPObject *o_id_p = nmp_object_new(NMP_OBJECT_TYPE_IP6_ROUTE, NULL); g_assert_cmpint(obj_type, ==, NMP_OBJECT_TYPE_IP6_ROUTE); g_assert(received); @@ -244,16 +244,16 @@ static void test_ip4_route(void) { int ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); - SignalData * route_added = add_signal(NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, + SignalData *route_added = add_signal(NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback); - SignalData * route_changed = add_signal(NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, + SignalData *route_changed = add_signal(NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback); - SignalData * route_removed = add_signal(NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, + SignalData *route_removed = add_signal(NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback); - GPtrArray * routes; + GPtrArray *routes; NMPlatformIP4Route rts[3]; in_addr_t network; guint8 plen = 24; @@ -388,16 +388,16 @@ static void test_ip6_route(void) { int ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); - SignalData * route_added = add_signal(NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, + SignalData *route_added = add_signal(NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_route_callback); - SignalData * route_changed = add_signal(NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, + SignalData *route_changed = add_signal(NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_route_callback); - SignalData * route_removed = add_signal(NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, + SignalData *route_removed = add_signal(NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_route_callback); - GPtrArray * routes; + GPtrArray *routes; NMPlatformIP6Route rts[3]; struct in6_addr network; guint8 plen = 64; @@ -546,9 +546,9 @@ test_ip6_route(void) static void test_ip4_route_get(void) { - int ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); - in_addr_t a; - int result; + int ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); + in_addr_t a; + int result; nm_auto_nmpobj NMPObject *route = NULL; const NMPlatformIP4Route *r; @@ -620,8 +620,8 @@ test_ip4_zero_gateway(void) static void test_ip4_route_options(gconstpointer test_data) { - const int TEST_IDX = GPOINTER_TO_INT(test_data); - const int IFINDEX = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); + const int TEST_IDX = GPOINTER_TO_INT(test_data); + const int IFINDEX = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); gs_unref_ptrarray GPtrArray *routes = NULL; #define RTS_MAX 3 NMPlatformIP4Route rts_add[RTS_MAX] = {}; @@ -650,13 +650,13 @@ test_ip4_route_options(gconstpointer test_data) break; case 2: addr[addr_n++] = ((NMPlatformIP4Address){ - .ifindex = IFINDEX, - .address = nmtst_inet4_from_string("172.16.1.5"), - .peer_address = nmtst_inet4_from_string("172.16.1.5"), - .plen = 24, - .lifetime = NM_PLATFORM_LIFETIME_PERMANENT, - .preferred = NM_PLATFORM_LIFETIME_PERMANENT, - .n_ifa_flags = 0, + .ifindex = IFINDEX, + .address = nmtst_inet4_from_string("172.16.1.5"), + .peer_address = nmtst_inet4_from_string("172.16.1.5"), + .plen = 24, + .lifetime = NM_PLATFORM_LIFETIME_PERMANENT, + .preferred = NM_PLATFORM_LIFETIME_PERMANENT, + .n_ifa_flags = 0, }); rts_add[rts_n++] = ((NMPlatformIP4Route){ .ifindex = IFINDEX, @@ -731,9 +731,9 @@ test_ip4_route_options(gconstpointer test_data) static void test_ip6_route_get(void) { - int ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); - const struct in6_addr *a; - int result; + int ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); + const struct in6_addr *a; + int result; nm_auto_nmpobj NMPObject *route = NULL; const NMPlatformIP6Route *r; @@ -776,8 +776,8 @@ test_ip6_route_get(void) static void test_ip6_route_options(gconstpointer test_data) { - const int TEST_IDX = GPOINTER_TO_INT(test_data); - const int IFINDEX = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); + const int TEST_IDX = GPOINTER_TO_INT(test_data); + const int IFINDEX = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); gs_unref_ptrarray GPtrArray *routes = NULL; #define RTS_MAX 3 NMPlatformIP6Route rts_add[RTS_MAX] = {}; @@ -807,13 +807,13 @@ test_ip6_route_options(gconstpointer test_data) break; case 2: addr[addr_n++] = ((NMPlatformIP6Address){ - .ifindex = IFINDEX, - .address = *nmtst_inet6_from_string("2000::2"), - .plen = 128, - .peer_address = in6addr_any, - .lifetime = NM_PLATFORM_LIFETIME_PERMANENT, - .preferred = NM_PLATFORM_LIFETIME_PERMANENT, - .n_ifa_flags = 0, + .ifindex = IFINDEX, + .address = *nmtst_inet6_from_string("2000::2"), + .plen = 128, + .peer_address = in6addr_any, + .lifetime = NM_PLATFORM_LIFETIME_PERMANENT, + .preferred = NM_PLATFORM_LIFETIME_PERMANENT, + .n_ifa_flags = 0, }); rts_add[rts_n++] = ((NMPlatformIP6Route){ .ifindex = IFINDEX, @@ -827,13 +827,13 @@ test_ip6_route_options(gconstpointer test_data) break; case 3: addr[addr_n++] = ((NMPlatformIP6Address){ - .ifindex = IFINDEX, - .address = *nmtst_inet6_from_string("2001:db8:8086::5"), - .plen = 128, - .peer_address = in6addr_any, - .lifetime = NM_PLATFORM_LIFETIME_PERMANENT, - .preferred = NM_PLATFORM_LIFETIME_PERMANENT, - .n_ifa_flags = 0, + .ifindex = IFINDEX, + .address = *nmtst_inet6_from_string("2001:db8:8086::5"), + .plen = 128, + .peer_address = in6addr_any, + .lifetime = NM_PLATFORM_LIFETIME_PERMANENT, + .preferred = NM_PLATFORM_LIFETIME_PERMANENT, + .n_ifa_flags = 0, }); rts_add[rts_n++] = ((NMPlatformIP6Route){ .ifindex = IFINDEX, @@ -915,7 +915,7 @@ test_ip(gconstpointer test_data) char ifname[IFNAMSIZ]; char ifname2[IFNAMSIZ]; char s1[NM_UTILS_INET_ADDRSTRLEN]; - NMPlatform * platform = NM_PLATFORM_GET; + NMPlatform *platform = NM_PLATFORM_GET; const int EX_ = -1; struct { int ifindex; @@ -957,7 +957,7 @@ test_ip(gconstpointer test_data) order_len = 0; for (try = 0; try < 5 * G_N_ELEMENTS(order_idx); try++) { NMPObject o; - NMPlatformIP4Route * r; + NMPlatformIP4Route *r; guint idx; const NMDedupMultiHeadEntry *head_entry; NMPLookup lookup; @@ -1044,8 +1044,8 @@ _rule_find_by_priority(NMPlatform *platform, guint32 priority) { const NMDedupMultiHeadEntry *head_entry; NMDedupMultiIter iter; - const NMPObject * o; - const NMPObject * obj = NULL; + const NMPObject *o; + const NMPObject *obj = NULL; NMPLookup lookup; nmp_lookup_init_obj_type(&lookup, NMP_OBJECT_TYPE_ROUTING_RULE); @@ -1120,9 +1120,9 @@ _rule_check_kernel_support(NMPlatform *platform, int attribute) { nm_auto_nmpobj const NMPObject *obj = NULL; const NMPlatformRoutingRule rr = { - .addr_family = AF_INET, - .priority = PROBE_PRORITY, - .suppress_ifgroup_inverse = ~((guint32) 1245), + .addr_family = AF_INET, + .priority = PROBE_PRORITY, + .suppress_ifgroup_inverse = ~((guint32) 1245), }; obj = _rule_check_kernel_support_one(platform, &rr); @@ -1135,9 +1135,9 @@ _rule_check_kernel_support(NMPlatform *platform, int attribute) { nm_auto_nmpobj const NMPObject *obj = NULL; const NMPlatformRoutingRule rr = { - .addr_family = AF_INET, - .priority = PROBE_PRORITY, - .suppress_prefixlen_inverse = ~((guint32) 1245), + .addr_family = AF_INET, + .priority = PROBE_PRORITY, + .suppress_prefixlen_inverse = ~((guint32) 1245), }; obj = _rule_check_kernel_support_one(platform, &rr); @@ -1150,9 +1150,9 @@ _rule_check_kernel_support(NMPlatform *platform, int attribute) { nm_auto_nmpobj const NMPObject *obj = NULL; const NMPlatformRoutingRule rr = { - .addr_family = AF_INET, - .priority = PROBE_PRORITY, - .l3mdev = TRUE, + .addr_family = AF_INET, + .priority = PROBE_PRORITY, + .l3mdev = TRUE, }; obj = _rule_check_kernel_support_one(platform, &rr); @@ -1164,14 +1164,14 @@ _rule_check_kernel_support(NMPlatform *platform, int attribute) { nm_auto_nmpobj const NMPObject *obj = NULL; const NMPlatformRoutingRule rr = { - .addr_family = AF_INET, - .priority = PROBE_PRORITY, - .uid_range = + .addr_family = AF_INET, + .priority = PROBE_PRORITY, + .uid_range = { - .start = 0, - .end = 0, + .start = 0, + .end = 0, }, - .uid_range_has = TRUE, + .uid_range_has = TRUE, }; obj = _rule_check_kernel_support_one(platform, &rr); @@ -1183,9 +1183,9 @@ _rule_check_kernel_support(NMPlatform *platform, int attribute) { nm_auto_nmpobj const NMPObject *obj = NULL; const NMPlatformRoutingRule rr = { - .addr_family = AF_INET, - .priority = PROBE_PRORITY, - .protocol = 30, + .addr_family = AF_INET, + .priority = PROBE_PRORITY, + .protocol = 30, }; obj = _rule_check_kernel_support_one(platform, &rr); @@ -1197,9 +1197,9 @@ _rule_check_kernel_support(NMPlatform *platform, int attribute) { nm_auto_nmpobj const NMPObject *obj = NULL; const NMPlatformRoutingRule rr = { - .addr_family = AF_INET, - .priority = PROBE_PRORITY, - .ip_proto = 30, + .addr_family = AF_INET, + .priority = PROBE_PRORITY, + .ip_proto = 30, }; obj = _rule_check_kernel_support_one(platform, &rr); @@ -1269,7 +1269,7 @@ _rr_rand_choose_u32(guint32 p) static const NMPObject * _rule_create_random(NMPlatform *platform) { - NMPObject * obj; + NMPObject *obj; NMPlatformRoutingRule *rr; guint32 p; int addr_size; @@ -1312,7 +1312,7 @@ _rule_create_random(NMPlatform *platform) for (i = 0; i < 2; i++) { NMIPAddr *p_addr = i ? &rr->src : &rr->dst; - guint8 * p_len = i ? &rr->src_len : &rr->dst_len; + guint8 *p_len = i ? &rr->src_len : &rr->dst_len; p = nmtst_get_rand_uint32(); if ((p % 1000u) < 100) { @@ -1535,11 +1535,11 @@ _rule_fuzzy_equal(const NMPObject *obj, const NMPObject *obj_comp, int op_type) static void test_rule(gconstpointer test_data) { - const int TEST_IDX = GPOINTER_TO_INT(test_data); - const gboolean TEST_SYNC = (TEST_IDX == 4); + const int TEST_IDX = GPOINTER_TO_INT(test_data); + const gboolean TEST_SYNC = (TEST_IDX == 4); gs_unref_ptrarray GPtrArray *objs = NULL; gs_unref_ptrarray GPtrArray *objs_initial = NULL; - NMPlatform * platform = NM_PLATFORM_GET; + NMPlatform *platform = NM_PLATFORM_GET; guint i, j, n; int r; gboolean had_an_issue_exist = FALSE; @@ -1555,7 +1555,7 @@ test_rule(gconstpointer test_data) for (i = 6; i > 0; i--) { gs_unref_ptrarray GPtrArray *objs_extern = NULL; - const NMPObject * obj; + const NMPObject *obj; objs_extern = nmtstp_platform_routing_rules_get_all(platform, AF_UNSPEC); @@ -1759,7 +1759,7 @@ again: NMPLookup lookup; const NMDedupMultiHeadEntry *head_entry; NMDedupMultiIter iter; - const NMPObject * o; + const NMPObject *o; g_print(">>> failing... errno=%d, rule=%s\n", r, diff --git a/src/core/platform/tests/test-tc.c b/src/core/platform/tests/test-tc.c index ee7b861ec7..db23a93214 100644 --- a/src/core/platform/tests/test-tc.c +++ b/src/core/platform/tests/test-tc.c @@ -39,11 +39,11 @@ qdiscs_lookup(int ifindex) static void test_qdisc1(void) { - int ifindex; + int ifindex; gs_unref_ptrarray GPtrArray *known = NULL; gs_unref_ptrarray GPtrArray *plat = NULL; - NMPObject * obj; - NMPlatformQdisc * qdisc; + NMPObject *obj; + NMPlatformQdisc *qdisc; ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint(ifindex, >, 0); @@ -76,11 +76,11 @@ test_qdisc1(void) static void test_qdisc_fq_codel(void) { - int ifindex; + int ifindex; gs_unref_ptrarray GPtrArray *known = NULL; gs_unref_ptrarray GPtrArray *plat = NULL; - NMPObject * obj; - NMPlatformQdisc * qdisc; + NMPObject *obj; + NMPlatformQdisc *qdisc; ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint(ifindex, >, 0); @@ -115,11 +115,11 @@ test_qdisc_fq_codel(void) static void test_qdisc_sfq(void) { - int ifindex; + int ifindex; gs_unref_ptrarray GPtrArray *known = NULL; gs_unref_ptrarray GPtrArray *plat = NULL; - NMPObject * obj; - NMPlatformQdisc * qdisc; + NMPObject *obj; + NMPlatformQdisc *qdisc; ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint(ifindex, >, 0); @@ -154,11 +154,11 @@ test_qdisc_sfq(void) static void test_qdisc_tbf(void) { - int ifindex; + int ifindex; gs_unref_ptrarray GPtrArray *known = NULL; gs_unref_ptrarray GPtrArray *plat = NULL; - NMPObject * obj; - NMPlatformQdisc * qdisc; + NMPObject *obj; + NMPlatformQdisc *qdisc; ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint(ifindex, >, 0); diff --git a/src/core/ppp/nm-ppp-manager-call.c b/src/core/ppp/nm-ppp-manager-call.c index 8adeb8adbe..8c788fadb3 100644 --- a/src/core/ppp/nm-ppp-manager-call.c +++ b/src/core/ppp/nm-ppp-manager-call.c @@ -25,9 +25,9 @@ static const NMPPPOps *_ppp_ops = NULL; NMPPPManager * nm_ppp_manager_create(const char *iface, GError **error) { - NMPPPManager * ret; - GModule * plugin; - GError * error_local = NULL; + NMPPPManager *ret; + GModule *plugin; + GError *error_local = NULL; struct stat st; const NMPPPOps *ppp_ops; @@ -97,10 +97,10 @@ again: gboolean nm_ppp_manager_start(NMPPPManager *self, NMActRequest *req, - const char * ppp_name, + const char *ppp_name, guint32 timeout_secs, guint baud_override, - GError ** err) + GError **err) { const NMPPPOps *ppp_ops = ppp_ops_get(); @@ -110,8 +110,8 @@ nm_ppp_manager_start(NMPPPManager *self, } NMPPPManagerStopHandle * -nm_ppp_manager_stop(NMPPPManager * self, - GCancellable * cancellable, +nm_ppp_manager_stop(NMPPPManager *self, + GCancellable *cancellable, NMPPPManagerStopCallback callback, gpointer user_data) { diff --git a/src/core/ppp/nm-ppp-manager-call.h b/src/core/ppp/nm-ppp-manager-call.h index 87d2f93f55..ef081200ee 100644 --- a/src/core/ppp/nm-ppp-manager-call.h +++ b/src/core/ppp/nm-ppp-manager-call.h @@ -12,13 +12,13 @@ NMPPPManager *nm_ppp_manager_create(const char *iface, GError **error); gboolean nm_ppp_manager_start(NMPPPManager *self, NMActRequest *req, - const char * ppp_name, + const char *ppp_name, guint32 timeout_secs, guint baud_override, - GError ** error); + GError **error); -NMPPPManagerStopHandle *nm_ppp_manager_stop(NMPPPManager * self, - GCancellable * cancellable, +NMPPPManagerStopHandle *nm_ppp_manager_stop(NMPPPManager *self, + GCancellable *cancellable, NMPPPManagerStopCallback callback, gpointer user_data); diff --git a/src/core/ppp/nm-ppp-manager.c b/src/core/ppp/nm-ppp-manager.c index c347978ff0..f1f1030575 100644 --- a/src/core/ppp/nm-ppp-manager.c +++ b/src/core/ppp/nm-ppp-manager.c @@ -98,10 +98,10 @@ typedef struct { char *ip_iface; int ifindex; - NMActRequest * act_req; - GDBusMethodInvocation * pending_secrets_context; + NMActRequest *act_req; + GDBusMethodInvocation *pending_secrets_context; NMActRequestGetSecretsCallId *secrets_id; - const char * secrets_setting_name; + const char *secrets_setting_name; guint ppp_watch_id; guint ppp_timeout_handler; @@ -134,8 +134,8 @@ G_DEFINE_TYPE(NMPPPManager, nm_ppp_manager, NM_TYPE_DBUS_OBJECT) static void _ppp_cleanup(NMPPPManager *self); -static NMPPPManagerStopHandle *_ppp_manager_stop(NMPPPManager * self, - GCancellable * cancellable, +static NMPPPManagerStopHandle *_ppp_manager_stop(NMPPPManager *self, + GCancellable *cancellable, NMPPPManagerStopCallback callback, gpointer user_data); @@ -144,9 +144,9 @@ static void _ppp_manager_stop_cancel(NMPPPManagerStopHandle *handle); /*****************************************************************************/ static void -_emit_signal_new_config(NMPPPManager * self, +_emit_signal_new_config(NMPPPManager *self, int addr_family, - const NML3ConfigData * l3cd, + const NML3ConfigData *l3cd, const NMUtilsIPv6IfaceId *iid) { nm_assert(NM_IS_PPP_MANAGER(self)); @@ -164,9 +164,9 @@ _emit_signal_new_config(NMPPPManager * self, static gboolean monitor_cb(gpointer user_data) { - NMPPPManager * self = NM_PPP_MANAGER(user_data); + NMPPPManager *self = NM_PPP_MANAGER(user_data); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); - const char * ifname; + const char *ifname; int errsv; ifname = nm_platform_link_get_name(NM_PLATFORM_GET, priv->ifindex); @@ -174,7 +174,7 @@ monitor_cb(gpointer user_data) if (ifname) { struct ppp_stats stats = {}; struct ifreq req = { - .ifr_data = (caddr_t) &stats, + .ifr_data = (caddr_t) &stats, }; nm_utils_ifname_cpy(req.ifr_name, ifname); @@ -232,14 +232,14 @@ cancel_get_secrets(NMPPPManager *self) static gboolean extract_details_from_connection(NMConnection *connection, - const char * secrets_setting_name, - const char ** username, - const char ** password, - GError ** error) + const char *secrets_setting_name, + const char **username, + const char **password, + GError **error) { NMSettingConnection *s_con; - NMSetting * setting; - const char * setting_name; + NMSetting *setting; + const char *setting_name; g_return_val_if_fail(connection != NULL, FALSE); g_return_val_if_fail(username != NULL, FALSE); @@ -292,18 +292,18 @@ extract_details_from_connection(NMConnection *connection, } static void -ppp_secrets_cb(NMActRequest * req, +ppp_secrets_cb(NMActRequest *req, NMActRequestGetSecretsCallId *call_id, - NMSettingsConnection * settings_connection, /* unused (we pass NULL here) */ - GError * error, + NMSettingsConnection *settings_connection, /* unused (we pass NULL here) */ + GError *error, gpointer user_data) { - NMPPPManager * self = NM_PPP_MANAGER(user_data); + NMPPPManager *self = NM_PPP_MANAGER(user_data); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); - const char * username = NULL; - const char * password = NULL; - GError * local = NULL; - NMConnection * applied_connection; + const char *username = NULL; + const char *password = NULL; + GError *local = NULL; + NMConnection *applied_connection; g_return_if_fail(priv->pending_secrets_context != NULL); g_return_if_fail(req == priv->act_req); @@ -346,22 +346,22 @@ out: } static void -impl_ppp_manager_need_secrets(NMDBusObject * obj, +impl_ppp_manager_need_secrets(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMPPPManager * self = NM_PPP_MANAGER(obj); - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); - NMConnection * applied_connection; - const char * username = NULL; - const char * password = NULL; - guint32 tries; + NMPPPManager *self = NM_PPP_MANAGER(obj); + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); + NMConnection *applied_connection; + const char *username = NULL; + const char *password = NULL; + guint32 tries; gs_unref_ptrarray GPtrArray *hints = NULL; - GError * error = NULL; + GError *error = NULL; NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; nm_active_connection_clear_secrets(NM_ACTIVE_CONNECTION(priv->act_req)); @@ -412,13 +412,13 @@ impl_ppp_manager_need_secrets(NMDBusObject * obj, } static void -impl_ppp_manager_set_state(NMDBusObject * obj, +impl_ppp_manager_set_state(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { NMPPPManager *self = NM_PPP_MANAGER(obj); guint32 ppp_state; @@ -435,19 +435,19 @@ impl_ppp_manager_set_state(NMDBusObject * obj, } static void -impl_ppp_manager_set_ifindex(NMDBusObject * obj, +impl_ppp_manager_set_ifindex(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMPPPManager * self = NM_PPP_MANAGER(obj); - gs_unref_object NMPPPManager *self_keep_alive = NULL; - NMPPPManagerPrivate * priv = NM_PPP_MANAGER_GET_PRIVATE(self); - const NMPlatformLink * plink = NULL; - nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL; + NMPPPManager *self = NM_PPP_MANAGER(obj); + gs_unref_object NMPPPManager *self_keep_alive = NULL; + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); + const NMPlatformLink *plink = NULL; + nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL; gint32 ifindex; g_variant_get(parameters, "(i)", &ifindex); @@ -494,8 +494,8 @@ static gboolean set_ip_config_common(NMPPPManager *self, GVariant *config_dict, guint32 *out_mtu) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); - NMConnection * applied_connection; - NMSettingPpp * s_ppp; + NMConnection *applied_connection; + NMSettingPpp *s_ppp; if (priv->ifindex <= 0) return FALSE; @@ -515,21 +515,21 @@ set_ip_config_common(NMPPPManager *self, GVariant *config_dict, guint32 *out_mtu } static void -impl_ppp_manager_set_ip4_config(NMDBusObject * obj, +impl_ppp_manager_set_ip4_config(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMPPPManager * self = NM_PPP_MANAGER(obj); - NMPPPManagerPrivate * priv = NM_PPP_MANAGER_GET_PRIVATE(self); + NMPPPManager *self = NM_PPP_MANAGER(obj); + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; NMPlatformIP4Address address; guint32 u32, mtu; - GVariantIter * iter; - gs_unref_variant GVariant *config_dict = NULL; + GVariantIter *iter; + gs_unref_variant GVariant *config_dict = NULL; _LOGI("(IPv4 Config Get) reply received."); @@ -602,9 +602,9 @@ out: * returns the IID. */ static gboolean -iid_value_to_ll6_addr(GVariant * dict, - const char * prop, - struct in6_addr * out_addr, +iid_value_to_ll6_addr(GVariant *dict, + const char *prop, + struct in6_addr *out_addr, NMUtilsIPv6IfaceId *out_iid) { guint64 iid; @@ -628,22 +628,22 @@ iid_value_to_ll6_addr(GVariant * dict, } static void -impl_ppp_manager_set_ip6_config(NMDBusObject * obj, +impl_ppp_manager_set_ip6_config(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMPPPManager * self = NM_PPP_MANAGER(obj); - NMPPPManagerPrivate * priv = NM_PPP_MANAGER_GET_PRIVATE(self); + NMPPPManager *self = NM_PPP_MANAGER(obj); + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; NMPlatformIP6Address address; struct in6_addr a; - NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT; - gboolean has_peer = FALSE; - gs_unref_variant GVariant *config_dict = NULL; + NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT; + gboolean has_peer = FALSE; + gs_unref_variant GVariant *config_dict = NULL; _LOGI("(IPv6 Config Get) reply received."); @@ -724,7 +724,7 @@ static NM_UTILS_LOOKUP_STR_DEFINE( static void ppp_watch_cb(GPid pid, int status, gpointer user_data) { - NMPPPManager * self = NM_PPP_MANAGER(user_data); + NMPPPManager *self = NM_PPP_MANAGER(user_data); NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); int err; const long long lpid = (long long) pid; @@ -770,19 +770,19 @@ pppd_timed_out(gpointer data) } static GPtrArray * -create_pppd_cmd_line(NMPPPManager * self, - NMSettingPpp * setting, +create_pppd_cmd_line(NMPPPManager *self, + NMSettingPpp *setting, NMSettingPppoe *pppoe, - NMSettingAdsl * adsl, - const char * ppp_name, + NMSettingAdsl *adsl, + const char *ppp_name, guint baud_override, gboolean ip4_enabled, gboolean ip6_enabled, - GError ** err) + GError **err) { - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); - const char * pppd_binary = NULL; - gs_unref_ptrarray GPtrArray *cmd = NULL; + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); + const char *pppd_binary = NULL; + gs_unref_ptrarray GPtrArray *cmd = NULL; gboolean ppp_debug; g_return_val_if_fail(setting != NULL, NULL); @@ -988,22 +988,22 @@ pppoe_fill_defaults(NMSettingPpp *setting) static gboolean _ppp_manager_start(NMPPPManager *self, NMActRequest *req, - const char * ppp_name, + const char *ppp_name, guint32 timeout_secs, guint baud_override, - GError ** err) + GError **err) { - NMPPPManagerPrivate *priv; - NMConnection * connection; - NMSettingPpp * s_ppp; + NMPPPManagerPrivate *priv; + NMConnection *connection; + NMSettingPpp *s_ppp; gs_unref_object NMSettingPpp *s_ppp_free = NULL; - NMSettingPppoe * pppoe_setting; - NMSettingAdsl * adsl_setting; - gs_unref_ptrarray GPtrArray *ppp_cmd = NULL; - gs_free char * cmd_str = NULL; - struct stat st; - gboolean ip6_enabled; - gboolean ip4_enabled; + NMSettingPppoe *pppoe_setting; + NMSettingAdsl *adsl_setting; + gs_unref_ptrarray GPtrArray *ppp_cmd = NULL; + gs_free char *cmd_str = NULL; + struct stat st; + gboolean ip6_enabled; + gboolean ip4_enabled; g_return_val_if_fail(NM_IS_PPP_MANAGER(self), FALSE); g_return_val_if_fail(NM_IS_ACT_REQUEST(req), FALSE); @@ -1119,7 +1119,7 @@ _ppp_cleanup(NMPPPManager *self) /*****************************************************************************/ struct _NMPPPManagerStopHandle { - NMPPPManager * self; + NMPPPManager *self; NMPPPManagerStopCallback callback; gpointer user_data; @@ -1193,13 +1193,13 @@ _stop_cancelled_cb(GCancellable *cancellable, gpointer user_data) } static NMPPPManagerStopHandle * -_ppp_manager_stop(NMPPPManager * self, - GCancellable * cancellable, +_ppp_manager_stop(NMPPPManager *self, + GCancellable *cancellable, NMPPPManagerStopCallback callback, gpointer user_data) { - NMPPPManagerPrivate * priv = NM_PPP_MANAGER_GET_PRIVATE(self); - NMDBusObject * dbus = NM_DBUS_OBJECT(self); + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); + NMDBusObject *dbus = NM_DBUS_OBJECT(self); NMPPPManagerStopHandle *handle; if (nm_dbus_object_is_exported(dbus)) @@ -1328,7 +1328,7 @@ _ppp_manager_new(const char *iface) static void dispose(GObject *object) { - NMPPPManager * self = (NMPPPManager *) object; + NMPPPManager *self = (NMPPPManager *) object; NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE(self); /* we expect the user to first stop the manager. As fallback, @@ -1390,7 +1390,7 @@ static const NMDBusInterfaceInfoExtended interface_info_ppp = { static void nm_ppp_manager_class_init(NMPPPManagerClass *manager_class) { - GObjectClass * object_class = G_OBJECT_CLASS(manager_class); + GObjectClass *object_class = G_OBJECT_CLASS(manager_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(manager_class); object_class->dispose = dispose; diff --git a/src/core/ppp/nm-ppp-manager.h b/src/core/ppp/nm-ppp-manager.h index 9cf465517c..21ea371529 100644 --- a/src/core/ppp/nm-ppp-manager.h +++ b/src/core/ppp/nm-ppp-manager.h @@ -18,7 +18,7 @@ typedef struct _NMPPPManager NMPPPManager; typedef struct _NMPPPManagerStopHandle NMPPPManagerStopHandle; -typedef void (*NMPPPManagerStopCallback)(NMPPPManager * manager, +typedef void (*NMPPPManagerStopCallback)(NMPPPManager *manager, NMPPPManagerStopHandle *handle, gboolean was_cancelled, gpointer user_data); diff --git a/src/core/ppp/nm-ppp-mgr.c b/src/core/ppp/nm-ppp-mgr.c index 82e511e995..31c173a353 100644 --- a/src/core/ppp/nm-ppp-mgr.c +++ b/src/core/ppp/nm-ppp-mgr.c @@ -17,9 +17,9 @@ struct _NMPppMgr { NMPppMgrConfig config; - NMPPPManager * ppp_manager; - GSource * idle_start; - GSource * connect_timeout_source; + NMPPPManager *ppp_manager; + GSource *idle_start; + GSource *connect_timeout_source; union { struct { NMPppMgrIPData ip_data_6; @@ -116,13 +116,13 @@ _callback_emit_with_data(NMPppMgr *self, const NMPppMgrCallbackData *callback_da } static void -_callback_emit_state_change(NMPppMgr * self, +_callback_emit_state_change(NMPppMgr *self, NMPppMgrCallbackType callback_type, NMPppMgrState old_state, gboolean ip_changed_4, gboolean ip_changed_6, NMDeviceStateReason reason, - const char * reason_msg) + const char *reason_msg) { const NMPppMgrCallbackData callback_data = { .callback_type = callback_type, @@ -249,12 +249,12 @@ _state_ready_for_have_ifindex(NMPppMgr *self) static void _ppp_signal_state_changed(NMPPPManager *ppp_manager, guint ppp_state_u, gpointer user_data) { - NMPppMgr * self = SELF_FROM_USERDATA(user_data); + NMPppMgr *self = SELF_FROM_USERDATA(user_data); NMPPPStatus ppp_state = ppp_state_u; NMPppMgrState state; NMPppMgrState old_state; NMDeviceStateReason reason; - const char * reason_msg; + const char *reason_msg; if ((guint) ppp_state != ppp_state_u) ppp_state = NM_PPP_STATUS_UNKNOWN; @@ -295,10 +295,10 @@ _ppp_signal_state_changed(NMPPPManager *ppp_manager, guint ppp_state_u, gpointer static void _ppp_signal_ifindex_set(NMPPPManager *ppp_manager, int ifindex, - const char * ifname, + const char *ifname, gpointer user_data) { - NMPppMgr * self = SELF_FROM_USERDATA(user_data); + NMPppMgr *self = SELF_FROM_USERDATA(user_data); NMPppMgrState old_state; NMPppMgrState new_state; gboolean ip_changed_4; @@ -352,13 +352,13 @@ _ppp_signal_ifindex_set(NMPPPManager *ppp_manager, } static void -_ppp_signal_new_config(NMPPPManager * ppp_manager, +_ppp_signal_new_config(NMPPPManager *ppp_manager, int addr_family, - const NML3ConfigData * l3cd, + const NML3ConfigData *l3cd, const NMUtilsIPv6IfaceId *iid, gpointer user_data) { - NMPppMgr * self = SELF_FROM_USERDATA(user_data); + NMPppMgr *self = SELF_FROM_USERDATA(user_data); const int IS_IPv4 = NM_IS_IPv4(addr_family); NMPppMgrState old_state; gboolean ip_changed_4; @@ -436,7 +436,7 @@ _ppp_signal_stats(NMPPPManager *ppp_manager, guint in_bytes, guint out_bytes, gp static gboolean _ifindex_timeout_cb(gpointer user_data) { - NMPppMgr * self = user_data; + NMPppMgr *self = user_data; NMPppMgrState old_state; nm_clear_g_source_inst(&self->connect_timeout_source); @@ -457,12 +457,12 @@ _ifindex_timeout_cb(gpointer user_data) static gboolean _idle_start_cb(gpointer user_data) { - NMPppMgr * self = user_data; + NMPppMgr *self = user_data; gs_free_error GError *error = NULL; NMPppMgrState old_state; gboolean ip4_enabled; gboolean ip6_enabled; - NMPlatform * platform; + NMPlatform *platform; const NMPlatformLink *plink; nm_clear_g_source_inst(&self->idle_start); @@ -546,7 +546,7 @@ _idle_start_cb(gpointer user_data) NMPppMgr * nm_ppp_mgr_start(const NMPppMgrConfig *config, GError **error) { - NMPppMgr * self; + NMPppMgr *self; NMPPPManager *ppp_manager; g_return_val_if_fail(config, NULL); diff --git a/src/core/ppp/nm-ppp-mgr.h b/src/core/ppp/nm-ppp-mgr.h index f1aca4ed7a..f6165411c8 100644 --- a/src/core/ppp/nm-ppp-mgr.h +++ b/src/core/ppp/nm-ppp-mgr.h @@ -58,7 +58,7 @@ typedef struct { } NMPppMgrStatsData; typedef struct { - const NML3ConfigData * l3cd; + const NML3ConfigData *l3cd; const NMUtilsIPv6IfaceId *ipv6_iid; NMOptionBool ip_enabled; bool ip_received; @@ -92,19 +92,19 @@ typedef struct { }; } NMPppMgrCallbackData; -typedef void (*NMPppMgrCallback)(NMPppMgr * self, +typedef void (*NMPppMgrCallback)(NMPppMgr *self, const NMPppMgrCallbackData *callback_data, gpointer user_data); typedef struct { - NMNetns * netns; + NMNetns *netns; const char *parent_iface; NMPppMgrCallback callback; gpointer user_data; NMActRequest *act_req; - const char * ppp_username; + const char *ppp_username; guint32 timeout_secs; guint baud_override; } NMPppMgrConfig; @@ -123,7 +123,7 @@ NMPppMgr *nm_ppp_mgr_start(const NMPppMgrConfig *config, GError **error); NMPppMgrState nm_ppp_mgr_get_state(const NMPppMgr *self); int nm_ppp_mgr_get_ifindex(const NMPppMgr *self); -const NMPppMgrIPData * nm_ppp_mgr_get_ip_data(const NMPppMgr *self, int addr_family); +const NMPppMgrIPData *nm_ppp_mgr_get_ip_data(const NMPppMgr *self, int addr_family); const NMPppMgrStatsData *nm_ppp_mgr_get_stats(const NMPppMgr *self); void nm_ppp_mgr_destroy(NMPppMgr *self); diff --git a/src/core/ppp/nm-ppp-plugin-api.h b/src/core/ppp/nm-ppp-plugin-api.h index a867b94920..de4cfae3a0 100644 --- a/src/core/ppp/nm-ppp-plugin-api.h +++ b/src/core/ppp/nm-ppp-plugin-api.h @@ -13,13 +13,13 @@ typedef const struct { gboolean (*start)(NMPPPManager *manager, NMActRequest *req, - const char * ppp_name, + const char *ppp_name, guint32 timeout_secs, guint baud_override, - GError ** err); + GError **err); - NMPPPManagerStopHandle *(*stop)(NMPPPManager * manager, - GCancellable * cancellable, + NMPPPManagerStopHandle *(*stop)(NMPPPManager *manager, + GCancellable *cancellable, NMPPPManagerStopCallback callback, gpointer user_data); diff --git a/src/core/ppp/nm-pppd-plugin.c b/src/core/ppp/nm-pppd-plugin.c index 5ffa7d17cc..e2e34d2aaf 100644 --- a/src/core/ppp/nm-pppd-plugin.c +++ b/src/core/ppp/nm-pppd-plugin.c @@ -33,14 +33,14 @@ char pppd_version[] = VERSION; static struct { GDBusConnection *dbus_connection; - char * ipparam; + char *ipparam; } gl; static void nm_phasechange(int arg) { NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN; - char * ppp_phase; + char *ppp_phase; g_return_if_fail(G_IS_DBUS_CONNECTION(gl.dbus_connection)); @@ -332,10 +332,10 @@ get_pap_check(void) static int get_credentials(char *username, char *password) { - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; - const char * my_username; - const char * my_password; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + const char *my_username; + const char *my_password; if (!password) { /* pppd is checking pap support; return 1 for supported */ diff --git a/src/core/settings/nm-agent-manager.c b/src/core/settings/nm-agent-manager.c index a1c2eb9c76..295378bc86 100644 --- a/src/core/settings/nm-agent-manager.c +++ b/src/core/settings/nm-agent-manager.c @@ -32,7 +32,7 @@ enum { static guint signals[LAST_SIGNAL] = {0}; typedef struct { - NMAuthManager * auth_mgr; + NMAuthManager *auth_mgr; NMSessionMonitor *session_monitor; CList agent_lst_head; @@ -186,7 +186,7 @@ struct _NMAgentManagerCallId { NMAuthSubject *subject; /* Current agent being asked for secrets */ - NMSecretAgent * current; + NMSecretAgent *current; NMSecretAgentCallId *current_call_id; /* Stores the sorted list of NMSecretAgents which will be asked for secrets */ @@ -196,7 +196,7 @@ struct _NMAgentManagerCallId { union { struct { - char * path; + char *path; NMConnection *connection; NMAuthChain *chain; @@ -209,8 +209,8 @@ struct _NMAgentManagerCallId { union { struct { NMSecretAgentGetSecretsFlags flags; - char * setting_name; - char ** hints; + char *setting_name; + char **hints; GVariant *existing_secrets; @@ -238,7 +238,7 @@ _agent_find_by_owner(NMAgentManagerPrivate *priv, const char *owner) static NMSecretAgent * _agent_find_by_identifier_and_uid(NMAgentManagerPrivate *priv, - const char * identifier, + const char *identifier, gulong sender_uid) { NMSecretAgent *agent; @@ -257,7 +257,7 @@ static void _agent_remove(NMAgentManager *self, NMSecretAgent *agent) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(self); - CList * iter, *safe; + CList *iter, *safe; nm_assert(NM_IS_SECRET_AGENT(agent)); nm_assert(c_list_contains(&priv->agent_lst_head, &agent->agent_lst)); @@ -349,14 +349,14 @@ validate_identifier(const char *identifier, GError **error) } static void -_agent_permissions_check_done(NMAuthChain * chain, +_agent_permissions_check_done(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMAgentManager * self = NM_AGENT_MANAGER(user_data); + NMAgentManager *self = NM_AGENT_MANAGER(user_data); NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(self); - NMSecretAgent * agent; - Request * request; + NMSecretAgent *agent; + Request *request; nm_assert(!context || G_IS_DBUS_METHOD_INVOCATION(context)); @@ -438,16 +438,16 @@ agent_disconnected_cb(NMSecretAgent *agent, gpointer user_data) } static void -agent_manager_register_with_capabilities(NMAgentManager * self, +agent_manager_register_with_capabilities(NMAgentManager *self, GDBusMethodInvocation *context, - const char * identifier, + const char *identifier, guint32 capabilities) { - NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(self); + NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(self); gs_unref_object NMAuthSubject *subject = NULL; gulong sender_uid = G_MAXULONG; - GError * error = NULL; - NMSecretAgent * agent; + GError *error = NULL; + NMSecretAgent *agent; subject = nm_dbus_manager_new_auth_subject_from_context(context); if (!subject) { @@ -484,13 +484,13 @@ agent_manager_register_with_capabilities(NMAgentManager * self, } static void -impl_agent_manager_register(NMDBusObject * obj, +impl_agent_manager_register(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { const char *identifier; @@ -499,13 +499,13 @@ impl_agent_manager_register(NMDBusObject * obj, } static void -impl_agent_manager_register_with_capabilities(NMDBusObject * obj, +impl_agent_manager_register_with_capabilities(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { const char *identifier; guint32 capabilities; @@ -518,17 +518,17 @@ impl_agent_manager_register_with_capabilities(NMDBusObject * } static void -impl_agent_manager_unregister(NMDBusObject * obj, +impl_agent_manager_unregister(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMAgentManager * self = NM_AGENT_MANAGER(obj); + NMAgentManager *self = NM_AGENT_MANAGER(obj); NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(self); - NMSecretAgent * agent; + NMSecretAgent *agent; agent = _agent_find_by_owner(priv, sender); if (!agent) { @@ -549,8 +549,8 @@ impl_agent_manager_unregister(NMDBusObject * obj, static Request * request_new(NMAgentManager *self, RequestType request_type, - const char * detail, - NMAuthSubject * subject) + const char *detail, + NMAuthSubject *subject) { Request *req; @@ -607,11 +607,11 @@ request_free(Request *req) } static void -req_complete_release(Request * req, - GVariant * secrets, +req_complete_release(Request *req, + GVariant *secrets, const char *agent_dbus_owner, const char *agent_username, - GError * error) + GError *error) { NMAgentManager *self = req->self; @@ -653,11 +653,11 @@ req_complete_cancel(Request *req, gboolean is_disposing) } static void -req_complete(Request * req, - GVariant * secrets, +req_complete(Request *req, + GVariant *secrets, const char *agent_dbus_owner, const char *agent_username, - GError * error) + GError *error) { NMAgentManager *self = req->self; @@ -678,9 +678,9 @@ req_complete_error(Request *req, GError *error) static int agent_compare_func(gconstpointer aa, gconstpointer bb, gpointer user_data) { - NMSecretAgent * a = (NMSecretAgent *) aa; - NMSecretAgent * b = (NMSecretAgent *) bb; - Request * req = user_data; + NMSecretAgent *a = (NMSecretAgent *) aa; + NMSecretAgent *b = (NMSecretAgent *) bb; + Request *req = user_data; NMSessionMonitor *sm; gboolean a_active, b_active; gulong a_pid, b_pid, requester; @@ -774,7 +774,7 @@ static void request_add_agents(NMAgentManager *self, Request *req) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(self); - NMSecretAgent * agent; + NMSecretAgent *agent; c_list_for_each_entry (agent, &priv->agent_lst_head, agent_lst) { if (agent->fully_registered) @@ -786,7 +786,7 @@ static void request_next_agent(Request *req) { NMAgentManager *self; - GError * error = NULL; + GError *error = NULL; self = req->self; @@ -887,17 +887,17 @@ out: /*****************************************************************************/ static void -_con_get_request_done(NMSecretAgent * agent, +_con_get_request_done(NMSecretAgent *agent, NMSecretAgentCallId *call_id, - GVariant * secrets, - GError * error, + GVariant *secrets, + GError *error, gpointer user_data) { NMAgentManager *self; - Request * req = user_data; - GVariant * setting_secrets; - const char * agent_dbus_owner; - gs_free char * agent_name = NULL; + Request *req = user_data; + GVariant *setting_secrets; + const char *agent_dbus_owner; + gs_free char *agent_name = NULL; g_return_if_fail(call_id == req->current_call_id); g_return_if_fail(agent == req->current); @@ -962,15 +962,15 @@ static void set_secrets_not_required(NMConnection *connection, GVariant *dict) { GVariantIter iter, setting_iter; - const char * setting_name = NULL; - GVariant * setting_dict = NULL; + const char *setting_name = NULL; + GVariant *setting_dict = NULL; /* Iterate through the settings dicts */ g_variant_iter_init(&iter, dict); while (g_variant_iter_next(&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) { const char *key_name = NULL; - NMSetting * setting; - GVariant * val; + NMSetting *setting; + GVariant *val; setting = nm_connection_get_setting_by_name(connection, setting_name); if (setting) { @@ -985,7 +985,7 @@ set_secrets_not_required(NMConnection *connection, GVariant *dict) && strcmp(key_name, NM_SETTING_VPN_SECRETS) == 0 && g_variant_is_of_type(val, G_VARIANT_TYPE("a{ss}"))) { GVariantIter vpn_secret_iter; - const char * secret_name, *secret; + const char *secret_name, *secret; g_variant_iter_init(&vpn_secret_iter, val); while (g_variant_iter_next(&vpn_secret_iter, "{&s&s}", &secret_name, &secret)) @@ -1046,13 +1046,13 @@ _con_get_request_start_proceed(Request *req, gboolean include_system_secrets) } static void -_con_get_request_start_validated(NMAuthChain * chain, +_con_get_request_start_validated(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { NMAgentManager *self; - Request * req = user_data; - const char * perm; + Request *req = user_data; + const char *perm; g_return_if_fail(req->request_type == REQUEST_TYPE_CON_GET); @@ -1080,9 +1080,9 @@ _con_get_request_start_validated(NMAuthChain * chain, static void _con_get_request_start(Request *req) { - NMAgentManager * self; + NMAgentManager *self; NMSettingConnection *s_con; - const char * agent_dbus_owner, *perm; + const char *agent_dbus_owner, *perm; self = req->self; @@ -1138,10 +1138,10 @@ _con_get_request_start(Request *req) static gboolean _con_get_try_complete_early(Request *req) { - NMAgentManager * self; - gs_unref_variant GVariant *setting_secrets = NULL; - gs_unref_object NMConnection *tmp = NULL; - GError * error = NULL; + NMAgentManager *self; + gs_unref_variant GVariant *setting_secrets = NULL; + gs_unref_object NMConnection *tmp = NULL; + GError *error = NULL; self = req->self; @@ -1223,14 +1223,14 @@ _con_get_try_complete_early(Request *req) * Returns: a call-id to cancel the call. */ NMAgentManagerCallId -nm_agent_manager_get_secrets(NMAgentManager * self, - const char * path, - NMConnection * connection, - NMAuthSubject * subject, - GVariant * existing_secrets, - const char * setting_name, +nm_agent_manager_get_secrets(NMAgentManager *self, + const char *path, + NMConnection *connection, + NMAuthSubject *subject, + GVariant *existing_secrets, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char *const * hints, + const char *const *hints, NMAgentSecretsResultFunc callback, gpointer callback_data) { @@ -1288,15 +1288,15 @@ nm_agent_manager_cancel_secrets(NMAgentManager *self, NMAgentManagerCallId reque /*****************************************************************************/ static void -_con_save_request_done(NMSecretAgent * agent, +_con_save_request_done(NMSecretAgent *agent, NMSecretAgentCallId *call_id, - GVariant * secrets, - GError * error, + GVariant *secrets, + GError *error, gpointer user_data) { NMAgentManager *self; - Request * req = user_data; - const char * agent_dbus_owner; + Request *req = user_data; + const char *agent_dbus_owner; g_return_if_fail(call_id == req->current_call_id); g_return_if_fail(agent == req->current); @@ -1344,9 +1344,9 @@ _con_save_request_start(Request *req) void nm_agent_manager_save_secrets(NMAgentManager *self, - const char * path, - NMConnection * connection, - NMAuthSubject * subject) + const char *path, + NMConnection *connection, + NMAuthSubject *subject) { Request *req; @@ -1370,14 +1370,14 @@ nm_agent_manager_save_secrets(NMAgentManager *self, /*****************************************************************************/ static void -_con_del_request_done(NMSecretAgent * agent, +_con_del_request_done(NMSecretAgent *agent, NMSecretAgentCallId *call_id, - GVariant * secrets, - GError * error, + GVariant *secrets, + GError *error, gpointer user_data) { NMAgentManager *self; - Request * req = user_data; + Request *req = user_data; g_return_if_fail(call_id == req->current_call_id); g_return_if_fail(agent == req->current); @@ -1425,7 +1425,7 @@ void nm_agent_manager_delete_secrets(NMAgentManager *self, const char *path, NMConnection *connection) { NMAuthSubject *subject; - Request * req; + Request *req; g_return_if_fail(self != NULL); g_return_if_fail(path && *path); @@ -1450,11 +1450,11 @@ nm_agent_manager_delete_secrets(NMAgentManager *self, const char *path, NMConnec gboolean nm_agent_manager_has_agent_with_permission(NMAgentManager *self, - const char * username, - const char * permission) + const char *username, + const char *permission) { NMAgentManagerPrivate *priv; - NMSecretAgent * agent; + NMSecretAgent *agent; g_return_val_if_fail(NM_IS_AGENT_MANAGER(self), FALSE); g_return_val_if_fail(username, FALSE); @@ -1477,12 +1477,12 @@ nm_agent_manager_has_agent_with_permission(NMAgentManager *self, /*****************************************************************************/ gboolean -nm_agent_manager_all_agents_have_capability(NMAgentManager * manager, - NMAuthSubject * subject, +nm_agent_manager_all_agents_have_capability(NMAgentManager *manager, + NMAuthSubject *subject, NMSecretAgentCapabilities capability) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(manager); - NMSecretAgent * agent; + NMSecretAgent *agent; gboolean subject_is_unix_process = (nm_auth_subject_get_subject_type(subject) == NM_AUTH_SUBJECT_TYPE_UNIX_PROCESS); gulong subject_uid = @@ -1506,7 +1506,7 @@ static void authority_changed_cb(NMAuthManager *auth_manager, NMAgentManager *self) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(self); - NMSecretAgent * agent; + NMSecretAgent *agent; c_list_for_each_entry (agent, &priv->agent_lst_head, agent_lst) _agent_create_auth_chain(self, agent, NULL); @@ -1545,10 +1545,10 @@ constructed(GObject *object) static void dispose(GObject *object) { - NMAgentManager * self = NM_AGENT_MANAGER(object); + NMAgentManager *self = NM_AGENT_MANAGER(object); NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE(self); - Request * request; - NMSecretAgent * agent; + Request *request; + NMSecretAgent *agent; while ((request = c_list_first_entry(&priv->request_lst_head, Request, request_lst))) { c_list_unlink(&request->request_lst); @@ -1596,7 +1596,7 @@ static const NMDBusInterfaceInfoExtended interface_info_agent_manager = { static void nm_agent_manager_class_init(NMAgentManagerClass *agent_manager_class) { - GObjectClass * object_class = G_OBJECT_CLASS(agent_manager_class); + GObjectClass *object_class = G_OBJECT_CLASS(agent_manager_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(agent_manager_class); dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_STATIC(NM_DBUS_PATH_AGENT_MANAGER); diff --git a/src/core/settings/nm-agent-manager.h b/src/core/settings/nm-agent-manager.h index b26af4ef7a..cae8e8e05e 100644 --- a/src/core/settings/nm-agent-manager.h +++ b/src/core/settings/nm-agent-manager.h @@ -34,45 +34,45 @@ NMAgentManager *nm_agent_manager_get(void); guint64 nm_agent_manager_get_agent_version_id(NMAgentManager *self); /* If no agent fulfilled the secrets request, agent_dbus_owner will be NULL */ -typedef void (*NMAgentSecretsResultFunc)(NMAgentManager * manager, +typedef void (*NMAgentSecretsResultFunc)(NMAgentManager *manager, NMAgentManagerCallId call_id, - const char * agent_dbus_owner, - const char * agent_uname, + const char *agent_dbus_owner, + const char *agent_uname, gboolean agent_has_modify, - const char * setting_name, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - GVariant * secrets, - GError * error, + GVariant *secrets, + GError *error, gpointer user_data); -NMAgentManagerCallId nm_agent_manager_get_secrets(NMAgentManager * manager, - const char * path, - NMConnection * connection, - NMAuthSubject * subject, - GVariant * existing_secrets, - const char * setting_name, +NMAgentManagerCallId nm_agent_manager_get_secrets(NMAgentManager *manager, + const char *path, + NMConnection *connection, + NMAuthSubject *subject, + GVariant *existing_secrets, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char *const * hints, + const char *const *hints, NMAgentSecretsResultFunc callback, gpointer callback_data); void nm_agent_manager_cancel_secrets(NMAgentManager *manager, NMAgentManagerCallId request_id); void nm_agent_manager_save_secrets(NMAgentManager *manager, - const char * path, - NMConnection * connection, - NMAuthSubject * subject); + const char *path, + NMConnection *connection, + NMAuthSubject *subject); void nm_agent_manager_delete_secrets(NMAgentManager *manager, - const char * path, - NMConnection * connection); + const char *path, + NMConnection *connection); gboolean nm_agent_manager_has_agent_with_permission(NMAgentManager *self, - const char * username, - const char * permission); + const char *username, + const char *permission); -gboolean nm_agent_manager_all_agents_have_capability(NMAgentManager * manager, - NMAuthSubject * subject, +gboolean nm_agent_manager_all_agents_have_capability(NMAgentManager *manager, + NMAuthSubject *subject, NMSecretAgentCapabilities capability); #endif /* __NETWORKMANAGER_AGENT_MANAGER_H__ */ diff --git a/src/core/settings/nm-secret-agent.c b/src/core/settings/nm-secret-agent.c index 45152c2778..b222bd5ced 100644 --- a/src/core/settings/nm-secret-agent.c +++ b/src/core/settings/nm-secret-agent.c @@ -37,13 +37,13 @@ static guint signals[LAST_SIGNAL] = {0}; typedef struct _NMSecretAgentPrivate { CList permissions; CList requests; - GDBusConnection * dbus_connection; - char * description; - NMAuthSubject * subject; - char * identifier; - char * owner_username; - char * dbus_owner; - GCancellable * name_owner_cancellable; + GDBusConnection *dbus_connection; + char *description; + NMAuthSubject *subject; + char *identifier; + char *owner_username; + char *dbus_owner; + GCancellable *name_owner_cancellable; guint name_owner_changed_id; NMSecretAgentCapabilities capabilities; bool shutdown_wait_obj_registered : 1; @@ -121,25 +121,25 @@ static NM_UTILS_FLAGS2STR_DEFINE(_capabilities_to_string, struct _NMSecretAgentCallId { CList lst; - NMSecretAgent * self; - GCancellable * cancellable; - char * path; - const char * method_name; - char * setting_name; + NMSecretAgent *self; + GCancellable *cancellable; + char *path; + const char *method_name; + char *setting_name; NMSecretAgentCallback callback; gpointer callback_data; }; static NMSecretAgentCallId * -_call_id_new(NMSecretAgent * self, - const char * method_name, /* this must be a static string. */ - const char * path, - const char * setting_name, +_call_id_new(NMSecretAgent *self, + const char *method_name, /* this must be a static string. */ + const char *path, + const char *setting_name, NMSecretAgentCallback callback, gpointer callback_data) { NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE(self); - NMSecretAgentCallId * call_id; + NMSecretAgentCallId *call_id; call_id = g_slice_new(NMSecretAgentCallId); *call_id = (NMSecretAgentCallId){ @@ -181,8 +181,8 @@ _call_id_free(NMSecretAgentCallId *call_id) static void _call_id_invoke_callback(NMSecretAgentCallId *call_id, - GVariant * secrets, - GError * error, + GVariant *secrets, + GError *error, gboolean cancelled, gboolean free_call_id) { @@ -314,7 +314,7 @@ void nm_secret_agent_add_permission(NMSecretAgent *agent, const char *permission, gboolean allowed) { NMSecretAgentPrivate *priv; - NMCListElem * elem; + NMCListElem *elem; g_return_if_fail(agent != NULL); g_return_if_fail(permission != NULL); @@ -361,10 +361,10 @@ nm_secret_agent_has_permission(NMSecretAgent *agent, const char *permission) static void _dbus_call_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSecretAgentCallId *call_id; + NMSecretAgentCallId *call_id; gs_unref_variant GVariant *ret = NULL; gs_unref_variant GVariant *secrets = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); @@ -387,18 +387,18 @@ _dbus_call_cb(GObject *source, GAsyncResult *result, gpointer user_data) /*****************************************************************************/ NMSecretAgentCallId * -nm_secret_agent_get_secrets(NMSecretAgent * self, - const char * path, - NMConnection * connection, - const char * setting_name, - const char ** hints, +nm_secret_agent_get_secrets(NMSecretAgent *self, + const char *path, + NMConnection *connection, + const char *setting_name, + const char **hints, NMSecretAgentGetSecretsFlags flags, NMSecretAgentCallback callback, gpointer callback_data) { NMSecretAgentPrivate *priv; - GVariant * dict; - NMSecretAgentCallId * call_id; + GVariant *dict; + NMSecretAgentCallId *call_id; g_return_val_if_fail(NM_IS_SECRET_AGENT(self), NULL); g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL); @@ -442,9 +442,9 @@ nm_secret_agent_get_secrets(NMSecretAgent * self, static void _call_cancel_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSecretAgentCallId *call_id = user_data; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; + NMSecretAgentCallId *call_id = user_data; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); @@ -526,15 +526,15 @@ nm_secret_agent_cancel_call(NMSecretAgent *self, NMSecretAgentCallId *call_id) /*****************************************************************************/ NMSecretAgentCallId * -nm_secret_agent_save_secrets(NMSecretAgent * self, - const char * path, - NMConnection * connection, +nm_secret_agent_save_secrets(NMSecretAgent *self, + const char *path, + NMConnection *connection, NMSecretAgentCallback callback, gpointer callback_data) { NMSecretAgentPrivate *priv; - GVariant * dict; - NMSecretAgentCallId * call_id; + GVariant *dict; + NMSecretAgentCallId *call_id; g_return_val_if_fail(NM_IS_SECRET_AGENT(self), NULL); g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL); @@ -566,15 +566,15 @@ nm_secret_agent_save_secrets(NMSecretAgent * self, /*****************************************************************************/ NMSecretAgentCallId * -nm_secret_agent_delete_secrets(NMSecretAgent * self, - const char * path, - NMConnection * connection, +nm_secret_agent_delete_secrets(NMSecretAgent *self, + const char *path, + NMConnection *connection, NMSecretAgentCallback callback, gpointer callback_data) { NMSecretAgentPrivate *priv; - GVariant * dict; - NMSecretAgentCallId * call_id; + GVariant *dict; + NMSecretAgentCallId *call_id; g_return_val_if_fail(NM_IS_SECRET_AGENT(self), NULL); g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL); @@ -626,15 +626,15 @@ name_owner_changed(NMSecretAgent *self, const char *owner) static void name_owner_changed_cb(GDBusConnection *dbus_connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { NMSecretAgent *self = NM_SECRET_AGENT(user_data); - const char * new_owner = NULL; + const char *new_owner = NULL; if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) { g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_owner); @@ -663,20 +663,20 @@ get_name_owner_cb(const char *name_owner, GError *error, gpointer user_data) /*****************************************************************************/ NMSecretAgent * -nm_secret_agent_new(GDBusMethodInvocation * context, - NMAuthSubject * subject, - const char * identifier, +nm_secret_agent_new(GDBusMethodInvocation *context, + NMAuthSubject *subject, + const char *identifier, NMSecretAgentCapabilities capabilities) { - NMSecretAgent * self; + NMSecretAgent *self; NMSecretAgentPrivate *priv; - const char * dbus_owner; - gs_free char * owner_username = NULL; - char * description = NULL; + const char *dbus_owner; + gs_free char *owner_username = NULL; + char *description = NULL; char buf_subject[64]; char buf_caps[150]; gulong uid; - GDBusConnection * dbus_connection; + GDBusConnection *dbus_connection; g_return_val_if_fail(context != NULL, NULL); g_return_val_if_fail(NM_IS_AUTH_SUBJECT(subject), NULL); @@ -750,7 +750,7 @@ nm_secret_agent_init(NMSecretAgent *self) static void dispose(GObject *object) { - NMSecretAgent * self = NM_SECRET_AGENT(object); + NMSecretAgent *self = NM_SECRET_AGENT(object); NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE(self); nm_assert(c_list_is_empty(&self->agent_lst)); @@ -767,7 +767,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMSecretAgent * self = NM_SECRET_AGENT(object); + NMSecretAgent *self = NM_SECRET_AGENT(object); NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE(self); g_free(priv->description); diff --git a/src/core/settings/nm-secret-agent.h b/src/core/settings/nm-secret-agent.h index ce591425b7..14458b38c4 100644 --- a/src/core/settings/nm-secret-agent.h +++ b/src/core/settings/nm-secret-agent.h @@ -31,16 +31,16 @@ struct _NMSecretAgentPrivate; struct _NMSecretAgent { GObject parent; CList agent_lst; - struct _NMAuthChain * auth_chain; + struct _NMAuthChain *auth_chain; struct _NMSecretAgentPrivate *_priv; bool fully_registered : 1; }; GType nm_secret_agent_get_type(void); -NMSecretAgent *nm_secret_agent_new(GDBusMethodInvocation * context, - NMAuthSubject * subject, - const char * identifier, +NMSecretAgent *nm_secret_agent_new(GDBusMethodInvocation *context, + NMAuthSubject *subject, + const char *identifier, NMSecretAgentCapabilities capabilities); const char *nm_secret_agent_get_description(NMSecretAgent *agent); @@ -63,30 +63,30 @@ void nm_secret_agent_add_permission(NMSecretAgent *agent, const char *permission gboolean nm_secret_agent_has_permission(NMSecretAgent *agent, const char *permission); -typedef void (*NMSecretAgentCallback)(NMSecretAgent * agent, +typedef void (*NMSecretAgentCallback)(NMSecretAgent *agent, NMSecretAgentCallId *call_id, - GVariant * new_secrets, /* NULL for save & delete */ - GError * error, + GVariant *new_secrets, /* NULL for save & delete */ + GError *error, gpointer user_data); -NMSecretAgentCallId *nm_secret_agent_get_secrets(NMSecretAgent * agent, - const char * path, - NMConnection * connection, - const char * setting_name, - const char ** hints, +NMSecretAgentCallId *nm_secret_agent_get_secrets(NMSecretAgent *agent, + const char *path, + NMConnection *connection, + const char *setting_name, + const char **hints, NMSecretAgentGetSecretsFlags flags, NMSecretAgentCallback callback, gpointer callback_data); -NMSecretAgentCallId *nm_secret_agent_save_secrets(NMSecretAgent * agent, - const char * path, - NMConnection * connection, +NMSecretAgentCallId *nm_secret_agent_save_secrets(NMSecretAgent *agent, + const char *path, + NMConnection *connection, NMSecretAgentCallback callback, gpointer callback_data); -NMSecretAgentCallId *nm_secret_agent_delete_secrets(NMSecretAgent * agent, - const char * path, - NMConnection * connection, +NMSecretAgentCallId *nm_secret_agent_delete_secrets(NMSecretAgent *agent, + const char *path, + NMConnection *connection, NMSecretAgentCallback callback, gpointer callback_data); diff --git a/src/core/settings/nm-settings-connection.c b/src/core/settings/nm-settings-connection.c index 71da97d0f7..55efaebe9f 100644 --- a/src/core/settings/nm-settings-connection.c +++ b/src/core/settings/nm-settings-connection.c @@ -135,7 +135,7 @@ typedef struct _NMSettingsConnectionPrivate { struct { NMConnectionSerializationOptions options; - GVariant * variant; + GVariant *variant; } getsettings_cached; NMSettingsStorage *storage; @@ -223,7 +223,7 @@ static const NMDBusInterfaceInfoExtended interface_info_settings_connection; static void update_agent_secrets_cache(NMSettingsConnection *self, NMConnection *new); static guint _get_seen_bssids(NMSettingsConnection *self, - const char * strv_buf[static(SEEN_BSSIDS_MAX + 1)]); + const char *strv_buf[static(SEEN_BSSIDS_MAX + 1)]); /*****************************************************************************/ @@ -264,7 +264,7 @@ void _nm_settings_connection_set_storage(NMSettingsConnection *self, NMSettingsStorage *storage) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - const char * filename; + const char *filename; nm_assert(NM_IS_SETTINGS_STORAGE(storage)); nm_assert(!priv->storage @@ -316,7 +316,7 @@ static GVariant * _getsettings_cached_get(NMSettingsConnection *self, const NMConnectionSerializationOptions *options) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - GVariant * variant; + GVariant *variant; if (priv->getsettings_cached.variant) { if (nm_connection_serialization_options_equal(&priv->getsettings_cached.options, options)) { @@ -362,12 +362,12 @@ nm_settings_connection_get_connection(NMSettingsConnection *self) } void -_nm_settings_connection_set_connection(NMSettingsConnection * self, - NMConnection * new_connection, - NMConnection ** out_connection_old, +_nm_settings_connection_set_connection(NMSettingsConnection *self, + NMConnection *new_connection, + NMConnection **out_connection_old, NMSettingsConnectionUpdateReason update_reason) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); gs_unref_object NMConnection *connection_old = NULL; nm_assert(NM_IS_CONNECTION(new_connection)); @@ -408,7 +408,7 @@ _nm_settings_connection_set_connection(NMSettingsConnection * self, gboolean nm_settings_connection_has_unmodified_applied_connection(NMSettingsConnection *self, - NMConnection * applied_connection, + NMConnection *applied_connection, NMSettingCompareFlags compare_flags) { g_return_val_if_fail(NM_IS_SETTINGS_CONNECTION(self), FALSE); @@ -437,7 +437,7 @@ nm_settings_connection_get_last_secret_agent_version_id(NMSettingsConnection *se gboolean nm_settings_connection_check_visibility(NMSettingsConnection *self, - NMSessionMonitor * session_monitor) + NMSessionMonitor *session_monitor) { NMSettingConnection *s_con; guint32 num, i; @@ -483,9 +483,9 @@ gboolean nm_settings_connection_check_permission(NMSettingsConnection *self, const char *permission) { NMSettingsConnectionPrivate *priv; - NMSettingConnection * s_con; + NMSettingConnection *s_con; guint32 num, i; - const char * puser; + const char *puser; g_return_val_if_fail(NM_IS_SETTINGS_CONNECTION(self), FALSE); @@ -531,8 +531,8 @@ nm_settings_connection_check_permission(NMSettingsConnection *self, const char * static void update_agent_secrets_cache(NMSettingsConnection *self, NMConnection *new) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - gs_unref_variant GVariant *old_secrets = NULL; + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); + gs_unref_variant GVariant *old_secrets = NULL; old_secrets = g_steal_pointer(&priv->agent_secrets); @@ -552,11 +552,11 @@ update_agent_secrets_cache(NMSettingsConnection *self, NMConnection *new) } static gboolean -_secrets_update(NMConnection * connection, - const char * setting_name, - GVariant * secrets, +_secrets_update(NMConnection *connection, + const char *setting_name, + GVariant *secrets, NMConnection **out_new_connection, - GError ** error) + GError **error) { gs_unref_variant GVariant *secrets_setting = NULL; @@ -605,14 +605,14 @@ _secrets_update(NMConnection * connection, } gboolean -nm_settings_connection_update(NMSettingsConnection * self, - NMConnection * new_connection, +nm_settings_connection_update(NMSettingsConnection *self, + NMConnection *new_connection, NMSettingsConnectionPersistMode persist_mode, NMSettingsConnectionIntFlags sett_flags, NMSettingsConnectionIntFlags sett_mask, NMSettingsConnectionUpdateReason update_reason, - const char * log_context_name, - GError ** error) + const char *log_context_name, + GError **error) { g_return_val_if_fail(NM_IS_SETTINGS_CONNECTION(self), FALSE); @@ -645,10 +645,10 @@ typedef enum { } CallIdType; struct _NMSettingsConnectionCallId { - NMSettingsConnection * self; + NMSettingsConnection *self; CList call_ids_lst; gboolean had_applied_connection; - NMConnection * applied_connection; + NMConnection *applied_connection; NMSettingsConnectionSecretsFunc callback; gpointer callback_data; @@ -666,9 +666,9 @@ struct _NMSettingsConnectionCallId { static void _get_secrets_info_callback(NMSettingsConnectionCallId *call_id, - const char * agent_username, - const char * setting_name, - GError * error) + const char *agent_username, + const char *setting_name, + GError *error) { if (call_id->callback) { call_id->callback(call_id->self, @@ -731,16 +731,16 @@ secret_is_system_owned(NMSettingSecretFlags flags, gpointer user_data) } static void -get_cmp_flags(NMSettingsConnection * self, /* only needed for logging */ - NMSettingsConnectionCallId * call_id, /* only needed for logging */ - NMConnection * connection, - const char * agent_dbus_owner, +get_cmp_flags(NMSettingsConnection *self, /* only needed for logging */ + NMSettingsConnectionCallId *call_id, /* only needed for logging */ + NMConnection *connection, + const char *agent_dbus_owner, gboolean agent_has_modify, - const char * setting_name, /* only needed for logging */ + const char *setting_name, /* only needed for logging */ NMSecretAgentGetSecretsFlags flags, - GVariant * secrets, - gboolean * agent_had_system, - ForEachSecretFlags * cmp_flags) + GVariant *secrets, + gboolean *agent_had_system, + ForEachSecretFlags *cmp_flags) { gboolean is_self = (nm_settings_connection_get_connection(self) == connection); @@ -810,13 +810,13 @@ get_cmp_flags(NMSettingsConnection * self, /* only needed for logging * gboolean nm_settings_connection_new_secrets(NMSettingsConnection *self, - NMConnection * applied_connection, - const char * setting_name, - GVariant * secrets, - GError ** error) + NMConnection *applied_connection, + const char *setting_name, + GVariant *secrets, + GError **error) { gs_unref_object NMConnection *new_connection = NULL; - NMConnection * connection; + NMConnection *connection; if (!nm_settings_connection_has_unmodified_applied_connection(self, applied_connection, @@ -849,8 +849,8 @@ nm_settings_connection_new_secrets(NMSettingsConnection *self, } static gboolean -match_secret_by_setting_name_and_flags_cb(NMSetting * setting, - const char * secret, +match_secret_by_setting_name_and_flags_cb(NMSetting *setting, + const char *secret, NMSettingSecretFlags flags, gpointer user_data) { @@ -861,22 +861,22 @@ match_secret_by_setting_name_and_flags_cb(NMSetting * setting, } static void -get_secrets_done_cb(NMAgentManager * manager, +get_secrets_done_cb(NMAgentManager *manager, NMAgentManagerCallId call_id_a, - const char * agent_dbus_owner, - const char * agent_username, + const char *agent_dbus_owner, + const char *agent_username, gboolean agent_has_modify, - const char * setting_name, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - GVariant * secrets, - GError * error, + GVariant *secrets, + GError *error, gpointer user_data) { - NMSettingsConnectionCallId * call_id = user_data; - NMSettingsConnection * self; - NMSettingsConnectionPrivate *priv; - NMConnection * applied_connection; - gs_free_error GError *local = NULL; + NMSettingsConnectionCallId *call_id = user_data; + NMSettingsConnection *self; + NMSettingsConnectionPrivate *priv; + NMConnection *applied_connection; + gs_free_error GError *local = NULL; gs_unref_object NMConnection *new_connection = NULL; gboolean agent_had_system = FALSE; ForEachSecretFlags cmp_flags = {NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_SECRET_FLAG_NONE}; @@ -1068,21 +1068,21 @@ get_secrets_idle_cb(NMSettingsConnectionCallId *call_id) * Returns: a call ID which may be used to cancel the ongoing secrets request. **/ NMSettingsConnectionCallId * -nm_settings_connection_get_secrets(NMSettingsConnection * self, - NMConnection * applied_connection, - NMAuthSubject * subject, - const char * setting_name, +nm_settings_connection_get_secrets(NMSettingsConnection *self, + NMConnection *applied_connection, + NMAuthSubject *subject, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char *const * hints, + const char *const *hints, NMSettingsConnectionSecretsFunc callback, gpointer callback_data) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); NMAgentManagerCallId call_id_a; - gs_free char * joined_hints = NULL; - NMSettingsConnectionCallId * call_id; - GError * local = NULL; - gs_unref_variant GVariant *system_secrets = NULL; + gs_free char *joined_hints = NULL; + NMSettingsConnectionCallId *call_id; + GError *local = NULL; + gs_unref_variant GVariant *system_secrets = NULL; g_return_val_if_fail(NM_IS_SETTINGS_CONNECTION(self), NULL); g_return_val_if_fail( @@ -1168,12 +1168,12 @@ schedule_dummy: } static void -_get_secrets_cancel(NMSettingsConnection * self, +_get_secrets_cancel(NMSettingsConnection *self, NMSettingsConnectionCallId *call_id, gboolean is_disposing) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - gs_free_error GError *error = NULL; + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); + gs_free_error GError *error = NULL; nm_assert(c_list_contains(&priv->call_ids_lst_head, &call_id->call_ids_lst)); @@ -1192,7 +1192,7 @@ _get_secrets_cancel(NMSettingsConnection * self, } void -nm_settings_connection_cancel_secrets(NMSettingsConnection * self, +nm_settings_connection_cancel_secrets(NMSettingsConnection *self, NMSettingsConnectionCallId *call_id) { _LOGD("(%p) secrets canceled", call_id); @@ -1202,31 +1202,31 @@ nm_settings_connection_cancel_secrets(NMSettingsConnection * self, /*****************************************************************************/ -typedef void (*AuthCallback)(NMSettingsConnection * self, +typedef void (*AuthCallback)(NMSettingsConnection *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer data); typedef struct { CList auth_lst; - NMAuthManagerCallId * call_id; - NMSettingsConnection * self; + NMAuthManagerCallId *call_id; + NMSettingsConnection *self; AuthCallback callback; gpointer callback_data; GDBusMethodInvocation *invocation; - NMAuthSubject * subject; + NMAuthSubject *subject; } AuthData; static void -pk_auth_cb(NMAuthManager * auth_manager, +pk_auth_cb(NMAuthManager *auth_manager, NMAuthManagerCallId *auth_call_id, gboolean is_authorized, gboolean is_challenge, - GError * auth_error, + GError *auth_error, gpointer user_data) { - AuthData * auth_data = user_data; + AuthData *auth_data = user_data; NMSettingsConnection *self; gs_free_error GError *error = NULL; @@ -1293,16 +1293,16 @@ _new_auth_subject(GDBusMethodInvocation *context, GError **error) /* may either invoke callback synchronously or asynchronously. */ static void -auth_start(NMSettingsConnection * self, +auth_start(NMSettingsConnection *self, GDBusMethodInvocation *invocation, - NMAuthSubject * subject, - const char * check_permission, + NMAuthSubject *subject, + const char *check_permission, AuthCallback callback, gpointer callback_data) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - AuthData * auth_data; - GError * error = NULL; + AuthData *auth_data; + GError *error = NULL; nm_assert(nm_dbus_object_is_exported(NM_DBUS_OBJECT(self))); nm_assert(G_IS_DBUS_METHOD_INVOCATION(invocation)); @@ -1342,13 +1342,13 @@ auth_start(NMSettingsConnection * self, /**** DBus method handlers ************************************/ static void -get_settings_auth_cb(NMSettingsConnection * self, +get_settings_auth_cb(NMSettingsConnection *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer data) { - const char * seen_bssids_strv[SEEN_BSSIDS_MAX + 1]; + const char *seen_bssids_strv[SEEN_BSSIDS_MAX + 1]; NMConnectionSerializationOptions options = {}; if (error) { @@ -1381,17 +1381,17 @@ get_settings_auth_cb(NMSettingsConnection * self, } static void -impl_settings_connection_get_settings(NMDBusObject * obj, +impl_settings_connection_get_settings(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); gs_unref_object NMAuthSubject *subject = NULL; - GError * error = NULL; + GError *error = NULL; subject = _new_auth_subject(invocation, &error); if (!subject) { @@ -1404,11 +1404,11 @@ impl_settings_connection_get_settings(NMDBusObject * obj, typedef struct { GDBusMethodInvocation *context; - NMAgentManager * agent_mgr; - NMAuthSubject * subject; - NMConnection * new_settings; + NMAgentManager *agent_mgr; + NMAuthSubject *subject; + NMConnection *new_settings; NMSettingsUpdate2Flags flags; - char * audit_args; + char *audit_args; bool is_update2 : 1; } UpdateInfo; @@ -1486,15 +1486,15 @@ _autoconnect_retries_set(NMSettingsConnection *self, int retries, gboolean is_re } static void -update_auth_cb(NMSettingsConnection * self, +update_auth_cb(NMSettingsConnection *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer data) { - NMSettingsConnectionPrivate *priv; - UpdateInfo * info = data; - gs_free_error GError * local = NULL; + NMSettingsConnectionPrivate *priv; + UpdateInfo *info = data; + gs_free_error GError *local = NULL; NMSettingsConnectionPersistMode persist_mode; if (error) { @@ -1638,18 +1638,18 @@ get_update_modify_permission(NMConnection *old, NMConnection *new) } static void -settings_connection_update(NMSettingsConnection * self, +settings_connection_update(NMSettingsConnection *self, gboolean is_update2, GDBusMethodInvocation *context, - GVariant * new_settings, + GVariant *new_settings, NMSettingsUpdate2Flags flags) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - NMAuthSubject * subject = NULL; - NMConnection * tmp = NULL; - GError * error = NULL; - UpdateInfo * info; - const char * permission; + NMAuthSubject *subject = NULL; + NMConnection *tmp = NULL; + GError *error = NULL; + UpdateInfo *info; + const char *permission; /* Check if the settings are valid first */ if (new_settings) { @@ -1712,15 +1712,15 @@ error: } static void -impl_settings_connection_update(NMDBusObject * obj, +impl_settings_connection_update(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); gs_unref_variant GVariant *settings = NULL; g_variant_get(parameters, "(@a{sa{sv}})", &settings); @@ -1728,15 +1728,15 @@ impl_settings_connection_update(NMDBusObject * obj, } static void -impl_settings_connection_update_unsaved(NMDBusObject * obj, +impl_settings_connection_update_unsaved(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); gs_unref_variant GVariant *settings = NULL; g_variant_get(parameters, "(@a{sa{sv}})", &settings); @@ -1748,13 +1748,13 @@ impl_settings_connection_update_unsaved(NMDBusObject * obj, } static void -impl_settings_connection_save(NMDBusObject * obj, +impl_settings_connection_save(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); @@ -1762,21 +1762,21 @@ impl_settings_connection_save(NMDBusObject * obj, } static void -impl_settings_connection_update2(NMDBusObject * obj, +impl_settings_connection_update2(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); gs_unref_variant GVariant *settings = NULL; gs_unref_variant GVariant *args = NULL; guint32 flags_u; - GError * error = NULL; + GError *error = NULL; GVariantIter iter; - const char * args_name; + const char *args_name; NMSettingsUpdate2Flags flags; g_variant_get(parameters, "(@a{sa{sv}}u@a{sv})", &settings, &flags_u, &args); @@ -1825,10 +1825,10 @@ impl_settings_connection_update2(NMDBusObject * obj, } static void -delete_auth_cb(NMSettingsConnection * self, +delete_auth_cb(NMSettingsConnection *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer data) { gs_unref_object NMSettingsConnection *self_keep_alive = NULL; @@ -1869,17 +1869,17 @@ get_modify_permission_basic(NMSettingsConnection *self) } static void -impl_settings_connection_delete(NMDBusObject * obj, +impl_settings_connection_delete(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); gs_unref_object NMAuthSubject *subject = NULL; - GError * error = NULL; + GError *error = NULL; nm_assert(nm_settings_connection_still_valid(self)); @@ -1897,15 +1897,15 @@ err: /*****************************************************************************/ static void -dbus_get_agent_secrets_cb(NMSettingsConnection * self, +dbus_get_agent_secrets_cb(NMSettingsConnection *self, NMSettingsConnectionCallId *call_id, - const char * agent_username, - const char * setting_name, - GError * error, + const char *agent_username, + const char *setting_name, + GError *error, gpointer user_data) { GDBusMethodInvocation *context = user_data; - GVariant * dict; + GVariant *dict; if (error) g_dbus_method_invocation_return_gerror(context, error); @@ -1924,10 +1924,10 @@ dbus_get_agent_secrets_cb(NMSettingsConnection * self, } static void -dbus_get_secrets_auth_cb(NMSettingsConnection * self, +dbus_get_secrets_auth_cb(NMSettingsConnection *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer user_data) { char *setting_name = user_data; @@ -1951,18 +1951,18 @@ dbus_get_secrets_auth_cb(NMSettingsConnection * self, } static void -impl_settings_connection_get_secrets(NMDBusObject * obj, +impl_settings_connection_get_secrets(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); gs_unref_object NMAuthSubject *subject = NULL; - GError * error = NULL; - const char * setting_name; + GError *error = NULL; + const char *setting_name; subject = _new_auth_subject(invocation, &error); if (!subject) { @@ -1981,14 +1981,14 @@ impl_settings_connection_get_secrets(NMDBusObject * obj, } static void -dbus_clear_secrets_auth_cb(NMSettingsConnection * self, +dbus_clear_secrets_auth_cb(NMSettingsConnection *self, GDBusMethodInvocation *context, - NMAuthSubject * subject, - GError * error, + NMAuthSubject *subject, + GError *error, gpointer user_data) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - gs_free_error GError *local = NULL; + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); + gs_free_error GError *local = NULL; gs_unref_object NMConnection *connection_cloned = NULL; if (error) { @@ -2040,17 +2040,17 @@ dbus_clear_secrets_auth_cb(NMSettingsConnection * self, } static void -impl_settings_connection_clear_secrets(NMDBusObject * obj, +impl_settings_connection_clear_secrets(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION(obj); gs_unref_object NMAuthSubject *subject = NULL; - GError * error = NULL; + GError *error = NULL; subject = _new_auth_subject(invocation, &error); if (!subject) { @@ -2092,7 +2092,7 @@ _nm_settings_connection_emit_dbus_signal_removed(NMSettingsConnection *self) } void -_nm_settings_connection_emit_signal_updated_internal(NMSettingsConnection * self, +_nm_settings_connection_emit_signal_updated_internal(NMSettingsConnection *self, NMSettingsConnectionUpdateReason update_reason) { g_signal_emit(self, signals[UPDATED_INTERNAL], 0, (guint) update_reason); @@ -2119,7 +2119,7 @@ nm_settings_connection_get_flags(NMSettingsConnection *self) } NMSettingsConnectionIntFlags -nm_settings_connection_set_flags_full(NMSettingsConnection * self, +nm_settings_connection_set_flags_full(NMSettingsConnection *self, NMSettingsConnectionIntFlags mask, NMSettingsConnectionIntFlags value) { @@ -2285,7 +2285,7 @@ void nm_settings_connection_update_timestamp(NMSettingsConnection *self, guint64 timestamp) { NMSettingsConnectionPrivate *priv; - const char * connection_uuid; + const char *connection_uuid; char sbuf[60]; g_return_if_fail(NM_IS_SETTINGS_CONNECTION(self)); @@ -2315,11 +2315,11 @@ nm_settings_connection_update_timestamp(NMSettingsConnection *self, guint64 time void _nm_settings_connection_register_kf_dbs(NMSettingsConnection *self, - NMKeyFileDB * kf_db_timestamps, - NMKeyFileDB * kf_db_seen_bssids) + NMKeyFileDB *kf_db_timestamps, + NMKeyFileDB *kf_db_seen_bssids) { NMSettingsConnectionPrivate *priv; - const char * connection_uuid; + const char *connection_uuid; g_return_if_fail(NM_IS_SETTINGS_CONNECTION(self)); g_return_if_fail(kf_db_timestamps); @@ -2402,7 +2402,7 @@ static guint _get_seen_bssids(NMSettingsConnection *self, const char *strv_buf[static(SEEN_BSSIDS_MAX + 1)]) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - SeenBssidEntry * entry; + SeenBssidEntry *entry; guint i; i = 0; @@ -2450,11 +2450,11 @@ void nm_settings_connection_add_seen_bssid(NMSettingsConnection *self, const char *seen_bssid) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - const char * seen_bssids_strv[SEEN_BSSIDS_MAX + 1]; + const char *seen_bssids_strv[SEEN_BSSIDS_MAX + 1]; NMEtherAddr addr_bin; - const char * connection_uuid; + const char *connection_uuid; SeenBssidEntry entry_stack; - SeenBssidEntry * entry; + SeenBssidEntry *entry; guint i; g_return_if_fail(seen_bssid); @@ -2562,12 +2562,12 @@ nm_settings_connection_autoconnect_blocked_reason_get(NMSettingsConnection *self } gboolean -nm_settings_connection_autoconnect_blocked_reason_set_full(NMSettingsConnection * self, +nm_settings_connection_autoconnect_blocked_reason_set_full(NMSettingsConnection *self, NMSettingsAutoconnectBlockedReason mask, NMSettingsAutoconnectBlockedReason value) { NMSettingsAutoconnectBlockedReason v; - NMSettingsConnectionPrivate * priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); char buf[100]; nm_assert(mask); @@ -2641,7 +2641,7 @@ const char * nm_settings_connection_get_uuid(NMSettingsConnection *self) { NMSettingsConnectionPrivate *priv; - const char * uuid; + const char *uuid; g_return_val_if_fail(NM_IS_SETTINGS_CONNECTION(self), NULL); @@ -2668,7 +2668,7 @@ void _nm_settings_connection_cleanup_after_remove(NMSettingsConnection *self) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - AuthData * auth_data; + AuthData *auth_data; while ((auth_data = c_list_first_entry(&priv->auth_lst_head, AuthData, auth_lst))) nm_auth_manager_check_authorization_cancel(auth_data->call_id); @@ -2730,9 +2730,9 @@ nm_settings_connection_new(void) static void dispose(GObject *object) { - NMSettingsConnection * self = NM_SETTINGS_CONNECTION(object); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION(object); NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self); - NMSettingsConnectionCallId * call_id, *call_id_safe; + NMSettingsConnectionCallId *call_id, *call_id_safe; _LOGD("disposing"); @@ -2837,7 +2837,7 @@ static const NMDBusInterfaceInfoExtended interface_info_settings_connection = { static void nm_settings_connection_class_init(NMSettingsConnectionClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); g_type_class_add_private(klass, sizeof(NMSettingsConnectionPrivate)); diff --git a/src/core/settings/nm-settings-connection.h b/src/core/settings/nm-settings-connection.h index fa3dbcfbcf..5f8a22e8a5 100644 --- a/src/core/settings/nm-settings-connection.h +++ b/src/core/settings/nm-settings-connection.h @@ -219,9 +219,9 @@ NMSettingsConnection *nm_settings_connection_new(void); NMConnection *nm_settings_connection_get_connection(NMSettingsConnection *self); -void _nm_settings_connection_set_connection(NMSettingsConnection * self, - NMConnection * new_connection, - NMConnection ** out_old_connection, +void _nm_settings_connection_set_connection(NMSettingsConnection *self, + NMConnection *new_connection, + NMConnection **out_old_connection, NMSettingsConnectionUpdateReason update_reason); NMSettingsStorage *nm_settings_connection_get_storage(NMSettingsConnection *self); @@ -236,52 +236,52 @@ guint64 nm_settings_connection_get_last_secret_agent_version_id(NMSettingsConnec gboolean nm_settings_connection_has_unmodified_applied_connection(NMSettingsConnection *self, - NMConnection * applied_connection, + NMConnection *applied_connection, NMSettingCompareFlags compare_flage); -gboolean nm_settings_connection_update(NMSettingsConnection * self, - NMConnection * new_connection, +gboolean nm_settings_connection_update(NMSettingsConnection *self, + NMConnection *new_connection, NMSettingsConnectionPersistMode persist_mode, NMSettingsConnectionIntFlags sett_flags, NMSettingsConnectionIntFlags sett_mask, NMSettingsConnectionUpdateReason update_reason, - const char * log_context_name, - GError ** error); + const char *log_context_name, + GError **error); void nm_settings_connection_delete(NMSettingsConnection *self, gboolean allow_add_to_no_auto_default); -typedef void (*NMSettingsConnectionSecretsFunc)(NMSettingsConnection * self, +typedef void (*NMSettingsConnectionSecretsFunc)(NMSettingsConnection *self, NMSettingsConnectionCallId *call_id, - const char * agent_username, - const char * setting_name, - GError * error, + const char *agent_username, + const char *setting_name, + GError *error, gpointer user_data); gboolean nm_settings_connection_new_secrets(NMSettingsConnection *self, - NMConnection * applied_connection, - const char * setting_name, - GVariant * secrets, - GError ** error); + NMConnection *applied_connection, + const char *setting_name, + GVariant *secrets, + GError **error); NMSettingsConnectionCallId * -nm_settings_connection_get_secrets(NMSettingsConnection * self, - NMConnection * applied_connection, - NMAuthSubject * subject, - const char * setting_name, +nm_settings_connection_get_secrets(NMSettingsConnection *self, + NMConnection *applied_connection, + NMAuthSubject *subject, + const char *setting_name, NMSecretAgentGetSecretsFlags flags, - const char *const * hints, + const char *const *hints, NMSettingsConnectionSecretsFunc callback, gpointer callback_data); -void nm_settings_connection_cancel_secrets(NMSettingsConnection * self, +void nm_settings_connection_cancel_secrets(NMSettingsConnection *self, NMSettingsConnectionCallId *call_id); gboolean nm_settings_connection_check_visibility(NMSettingsConnection *self, - NMSessionMonitor * session_monitor); + NMSessionMonitor *session_monitor); gboolean nm_settings_connection_check_permission(NMSettingsConnection *self, - const char * permission); + const char *permission); /*****************************************************************************/ @@ -300,12 +300,12 @@ nm_settings_connection_get_unsaved(NMSettingsConnection *self) } NMSettingsConnectionIntFlags -nm_settings_connection_set_flags_full(NMSettingsConnection * self, +nm_settings_connection_set_flags_full(NMSettingsConnection *self, NMSettingsConnectionIntFlags mask, NMSettingsConnectionIntFlags value); static inline NMSettingsConnectionIntFlags -nm_settings_connection_set_flags(NMSettingsConnection * self, +nm_settings_connection_set_flags(NMSettingsConnection *self, NMSettingsConnectionIntFlags flags, gboolean set) { @@ -333,8 +333,8 @@ int nm_settings_connection_cmp_autoconnect_priority_p_with_data(gconstpointer pa struct _NMKeyFileDB; void _nm_settings_connection_register_kf_dbs(NMSettingsConnection *self, - struct _NMKeyFileDB * kf_db_timestamps, - struct _NMKeyFileDB * kf_db_seen_bssids); + struct _NMKeyFileDB *kf_db_timestamps, + struct _NMKeyFileDB *kf_db_seen_bssids); gboolean nm_settings_connection_get_timestamp(NMSettingsConnection *self, guint64 *out_timestamp); @@ -353,12 +353,12 @@ gint32 nm_settings_connection_autoconnect_retries_blocked_until(NMSettingsConnec NMSettingsAutoconnectBlockedReason nm_settings_connection_autoconnect_blocked_reason_get(NMSettingsConnection *self); gboolean nm_settings_connection_autoconnect_blocked_reason_set_full( - NMSettingsConnection * self, + NMSettingsConnection *self, NMSettingsAutoconnectBlockedReason mask, NMSettingsAutoconnectBlockedReason value); static inline gboolean -nm_settings_connection_autoconnect_blocked_reason_set(NMSettingsConnection * self, +nm_settings_connection_autoconnect_blocked_reason_set(NMSettingsConnection *self, NMSettingsAutoconnectBlockedReason mask, gboolean set) { @@ -386,7 +386,7 @@ void _nm_settings_connection_emit_dbus_signal_updated(NMSettingsConnection *self void _nm_settings_connection_emit_dbus_signal_removed(NMSettingsConnection *self); void _nm_settings_connection_emit_signal_updated_internal( - NMSettingsConnection * self, + NMSettingsConnection *self, NMSettingsConnectionUpdateReason update_reason); void _nm_settings_connection_cleanup_after_remove(NMSettingsConnection *self); diff --git a/src/core/settings/nm-settings-plugin.c b/src/core/settings/nm-settings-plugin.c index 66cc19b656..60181759e4 100644 --- a/src/core/settings/nm-settings-plugin.c +++ b/src/core/settings/nm-settings-plugin.c @@ -31,7 +31,7 @@ G_DEFINE_TYPE(NMSettingsPlugin, nm_settings_plugin, G_TYPE_OBJECT) int nm_settings_plugin_cmp_by_priority(const NMSettingsPlugin *a, const NMSettingsPlugin *b, - const GSList * plugin_list) + const GSList *plugin_list) { nm_assert(NM_IS_SETTINGS_PLUGIN(a)); nm_assert(NM_IS_SETTINGS_PLUGIN(b)); @@ -81,7 +81,7 @@ nm_settings_plugin_get_unrecognized_specs(NMSettingsPlugin *self) } void -nm_settings_plugin_reload_connections(NMSettingsPlugin * self, +nm_settings_plugin_reload_connections(NMSettingsPlugin *self, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) { @@ -122,8 +122,8 @@ nm_settings_plugin_create_connection_load_entries(const char *const *filenames, } void -nm_settings_plugin_load_connections(NMSettingsPlugin * self, - NMSettingsPluginConnectionLoadEntry * entries, +nm_settings_plugin_load_connections(NMSettingsPlugin *self, + NMSettingsPluginConnectionLoadEntry *entries, gsize n_entries, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) @@ -150,11 +150,11 @@ nm_settings_plugin_load_connections_done(NMSettingsPlugin *self) } gboolean -nm_settings_plugin_add_connection(NMSettingsPlugin * self, - NMConnection * connection, +nm_settings_plugin_add_connection(NMSettingsPlugin *self, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error) + NMConnection **out_connection, + GError **error) { NMSettingsPluginClass *klass; @@ -180,12 +180,12 @@ nm_settings_plugin_add_connection(NMSettingsPlugin * self, } gboolean -nm_settings_plugin_update_connection(NMSettingsPlugin * self, - NMSettingsStorage * storage, - NMConnection * connection, +nm_settings_plugin_update_connection(NMSettingsPlugin *self, + NMSettingsStorage *storage, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error) + NMConnection **out_connection, + GError **error) { NMSettingsPluginClass *klass = NULL; @@ -215,9 +215,9 @@ nm_settings_plugin_update_connection(NMSettingsPlugin * self, } gboolean -nm_settings_plugin_delete_connection(NMSettingsPlugin * self, +nm_settings_plugin_delete_connection(NMSettingsPlugin *self, NMSettingsStorage *storage, - GError ** error) + GError **error) { NMSettingsPluginClass *klass = NULL; diff --git a/src/core/settings/nm-settings-plugin.h b/src/core/settings/nm-settings-plugin.h index a9b9b2aea2..198447c0e3 100644 --- a/src/core/settings/nm-settings-plugin.h +++ b/src/core/settings/nm-settings-plugin.h @@ -13,14 +13,14 @@ typedef struct _NMSettingsPlugin NMSettingsPlugin; -typedef void (*NMSettingsPluginConnectionLoadCallback)(NMSettingsPlugin * self, +typedef void (*NMSettingsPluginConnectionLoadCallback)(NMSettingsPlugin *self, NMSettingsStorage *storage, - NMConnection * connection, + NMConnection *connection, gpointer user_data); typedef struct { const char *filename; - GError * error; + GError *error; bool handled : 1; } NMSettingsPluginConnectionLoadEntry; @@ -70,8 +70,8 @@ typedef struct { /* Requests that the plugin load/reload a set of filenames. */ - void (*load_connections)(NMSettingsPlugin * self, - NMSettingsPluginConnectionLoadEntry * entries, + void (*load_connections)(NMSettingsPlugin *self, + NMSettingsPluginConnectionLoadEntry *entries, gsize n_entries, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data); @@ -79,28 +79,28 @@ typedef struct { /* Requests that the plugin reload all connection files from disk, * and emit signals reflecting new, changed, and removed connections. */ - void (*reload_connections)(NMSettingsPlugin * self, + void (*reload_connections)(NMSettingsPlugin *self, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data); void (*load_connections_done)(NMSettingsPlugin *self); - gboolean (*add_connection)(NMSettingsPlugin * self, - NMConnection * connection, + gboolean (*add_connection)(NMSettingsPlugin *self, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error); + NMConnection **out_connection, + GError **error); - gboolean (*update_connection)(NMSettingsPlugin * self, - NMSettingsStorage * storage, - NMConnection * connection, + gboolean (*update_connection)(NMSettingsPlugin *self, + NMSettingsStorage *storage, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error); + NMConnection **out_connection, + GError **error); - gboolean (*delete_connection)(NMSettingsPlugin * self, + gboolean (*delete_connection)(NMSettingsPlugin *self, NMSettingsStorage *storage, - GError ** error); + GError **error); const char *plugin_name; @@ -137,37 +137,37 @@ nm_settings_plugin_get_plugin_name(NMSettingsPlugin *self) GSList *nm_settings_plugin_get_unmanaged_specs(NMSettingsPlugin *self); GSList *nm_settings_plugin_get_unrecognized_specs(NMSettingsPlugin *self); -void nm_settings_plugin_reload_connections(NMSettingsPlugin * self, +void nm_settings_plugin_reload_connections(NMSettingsPlugin *self, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data); NMSettingsPluginConnectionLoadEntry * nm_settings_plugin_create_connection_load_entries(const char *const *filenames, gsize *out_len); -void nm_settings_plugin_load_connections(NMSettingsPlugin * self, - NMSettingsPluginConnectionLoadEntry * entries, +void nm_settings_plugin_load_connections(NMSettingsPlugin *self, + NMSettingsPluginConnectionLoadEntry *entries, gsize n_entries, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data); void nm_settings_plugin_load_connections_done(NMSettingsPlugin *self); -gboolean nm_settings_plugin_add_connection(NMSettingsPlugin * self, - NMConnection * connection, +gboolean nm_settings_plugin_add_connection(NMSettingsPlugin *self, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error); + NMConnection **out_connection, + GError **error); -gboolean nm_settings_plugin_update_connection(NMSettingsPlugin * self, - NMSettingsStorage * storage, - NMConnection * connection, +gboolean nm_settings_plugin_update_connection(NMSettingsPlugin *self, + NMSettingsStorage *storage, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error); + NMConnection **out_connection, + GError **error); -gboolean nm_settings_plugin_delete_connection(NMSettingsPlugin * self, +gboolean nm_settings_plugin_delete_connection(NMSettingsPlugin *self, NMSettingsStorage *storage, - GError ** error); + GError **error); /*****************************************************************************/ @@ -187,7 +187,7 @@ void _nm_settings_plugin_emit_signal_unrecognized_specs_changed(NMSettingsPlugin int nm_settings_plugin_cmp_by_priority(const NMSettingsPlugin *a, const NMSettingsPlugin *b, - const GSList * plugin_list); + const GSList *plugin_list); /*****************************************************************************/ diff --git a/src/core/settings/nm-settings-storage.h b/src/core/settings/nm-settings-storage.h index 2e5e1c5579..198b0e8bb3 100644 --- a/src/core/settings/nm-settings-storage.h +++ b/src/core/settings/nm-settings-storage.h @@ -30,8 +30,8 @@ struct _NMSettingsPlugin; typedef struct NMSettingsStorage { GObject parent; struct _NMSettingsPlugin *_plugin; - char * _uuid; - char * _filename; + char *_uuid; + char *_filename; CList _storage_lst; CList _storage_by_uuid_lst; } NMSettingsStorage; @@ -106,6 +106,6 @@ nm_settings_storage_get_filename(const NMSettingsStorage *self) int nm_settings_storage_cmp(NMSettingsStorage *sd_a, NMSettingsStorage *sd_b, - const GSList * plugin_list); + const GSList *plugin_list); #endif /* __NM_SETTINGS_STORAGE_H__ */ diff --git a/src/core/settings/nm-settings-utils.c b/src/core/settings/nm-settings-utils.c index 775d0396e6..4343a37688 100644 --- a/src/core/settings/nm-settings-utils.c +++ b/src/core/settings/nm-settings-utils.c @@ -88,9 +88,9 @@ void nm_sett_util_storages_add_take(NMSettUtilStorages *storages, gpointer storage_take_p /* NMSettingsStorage *, take reference */) { - NMSettingsStorage * storage_take = storage_take_p; + NMSettingsStorage *storage_take = storage_take_p; NMSettUtilStorageByUuidHead *sbuh; - const char * uuid; + const char *uuid; nm_assert(storage_take); nm_assert(c_list_is_empty(&storage_take->_storage_lst)); @@ -125,9 +125,9 @@ gpointer /* NMSettingsStorage * */ nm_sett_util_storages_steal(NMSettUtilStorages *storages, gpointer storage_p /* NMSettingsStorage **/) { - NMSettingsStorage * storage = storage_p; + NMSettingsStorage *storage = storage_p; NMSettUtilStorageByUuidHead *sbuh; - const char * uuid; + const char *uuid; nm_assert(storage); nm_assert(nm_sett_util_storages_lookup_by_filename(storages, diff --git a/src/core/settings/nm-settings.c b/src/core/settings/nm-settings.c index b71b9d189d..e69f6ac1b3 100644 --- a/src/core/settings/nm-settings.c +++ b/src/core/settings/nm-settings.c @@ -79,7 +79,7 @@ static NM_CACHED_QUARK_FCN("default-wired-connection-blocked", typedef struct _StorageData { CList sd_lst; NMSettingsStorage *storage; - NMConnection * connection; + NMConnection *connection; bool prioritize : 1; } StorageData; @@ -123,9 +123,9 @@ static void nm_assert_storage_data_lst(CList *head) { #if NM_MORE_ASSERTS > 5 - const char * uuid = NULL; + const char *uuid = NULL; StorageData *sd; - CList * iter; + CList *iter; nm_assert(head); @@ -166,9 +166,9 @@ _storage_data_is_alive(StorageData *sd) /*****************************************************************************/ typedef struct { - const char * uuid; + const char *uuid; NMSettingsConnection *sett_conn; - NMSettingsStorage * storage; + NMSettingsStorage *storage; CList sd_lst_head; CList dirty_sd_lst_head; @@ -239,10 +239,10 @@ _sett_conn_entry_get_conn(SettConnEntry *sett_conn_entry) * Returns: the conflicting storage or %NULL if there is none. */ static NMSettingsStorage * -_sett_conn_entry_storage_find_conflicting_storage(SettConnEntry * sett_conn_entry, - NMSettingsPlugin * target_plugin, +_sett_conn_entry_storage_find_conflicting_storage(SettConnEntry *sett_conn_entry, + NMSettingsPlugin *target_plugin, NMSettingsStorage *storage_check_including, - const GSList * plugins) + const GSList *plugins) { StorageData *sd; @@ -294,8 +294,8 @@ _sett_conn_entry_storage_find_conflicting_storage(SettConnEntry * sett_conn_e } static NMSettingsStorage * -_sett_conn_entry_find_shadowed_storage(SettConnEntry * sett_conn_entry, - const char * shadowed_storage_filename, +_sett_conn_entry_find_shadowed_storage(SettConnEntry *sett_conn_entry, + const char *shadowed_storage_filename, NMSettingsStorage *blacklisted_storage) { StorageData *sd; @@ -428,8 +428,8 @@ static const NMDBusInterfaceInfoExtended interface_info_settings; static const GDBusSignalInfo signal_info_new_connection; static const GDBusSignalInfo signal_info_connection_removed; -static void default_wired_clear_tag(NMSettings * self, - NMDevice * device, +static void default_wired_clear_tag(NMSettings *self, + NMDevice *device, NMSettingsConnection *sett_conn, gboolean add_to_no_auto_default); @@ -446,8 +446,8 @@ _emit_connection_added(NMSettings *self, NMSettingsConnection *sett_conn) } static void -_emit_connection_updated(NMSettings * self, - NMSettingsConnection * sett_conn, +_emit_connection_updated(NMSettings *self, + NMSettingsConnection *sett_conn, NMSettingsConnectionUpdateReason update_reason) { _nm_settings_connection_emit_signal_updated_internal(sett_conn, update_reason); @@ -483,14 +483,14 @@ _startup_complete_data_destroy(StartupCompleteData *scd) } static gboolean -_startup_complete_check_is_ready(NMSettings * self, +_startup_complete_check_is_ready(NMSettings *self, NMSettingsConnection *sett_conn, gboolean ignore_pending_actions) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - NMConnection * conn; - const CList * tmp_lst; - NMDevice * device; + NMConnection *conn; + const CList *tmp_lst; + NMDevice *device; if (!priv->manager) return TRUE; @@ -528,7 +528,7 @@ _startup_complete_check_is_ready(NMSettings * self, static gboolean _startup_complete_timeout_cb(gpointer user_data) { - NMSettings * self = user_data; + NMSettings *self = user_data; NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); priv->startup_complete_timeout_id = 0; @@ -539,7 +539,7 @@ _startup_complete_timeout_cb(gpointer user_data) static void _startup_complete_check(NMSettings *self, gint64 now_msec) { - NMSettingsPrivate * priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); StartupCompleteData *scd_not_ready; StartupCompleteData *scd_safe; StartupCompleteData *scd; @@ -632,11 +632,11 @@ ready: } static void -_startup_complete_notify_connection(NMSettings * self, +_startup_complete_notify_connection(NMSettings *self, NMSettingsConnection *sett_conn, gboolean forget) { - NMSettingsPrivate * priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); StartupCompleteData *scd; gint64 timeout_msec; gint64 now_msec = 0; @@ -697,9 +697,9 @@ check: const char * nm_settings_get_startup_complete_blocked_reason(NMSettings *self, gboolean force_reload) { - NMSettingsPrivate * priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); StartupCompleteData *scd; - const char * uuid; + const char *uuid; if (priv->startup_complete_start_timestamp_msec == 0) goto out_done; @@ -776,7 +776,7 @@ update_specs(NMSettings *self, GSList **specs_ptr, GSList *(*get_specs_func)(NMS static void _plugin_unmanaged_specs_changed(NMSettingsPlugin *config, gpointer user_data) { - NMSettings * self = NM_SETTINGS(user_data); + NMSettings *self = NM_SETTINGS(user_data); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); if (update_specs(self, &priv->unmanaged_specs, nm_settings_plugin_get_unmanaged_specs)) @@ -786,7 +786,7 @@ _plugin_unmanaged_specs_changed(NMSettingsPlugin *config, gpointer user_data) static void _plugin_unrecognized_specs_changed(NMSettingsPlugin *config, gpointer user_data) { - NMSettings * self = NM_SETTINGS(user_data); + NMSettings *self = NM_SETTINGS(user_data); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); update_specs(self, &priv->unrecognized_specs, nm_settings_plugin_get_unrecognized_specs); @@ -813,7 +813,7 @@ static SettConnEntry * _sett_conn_entries_create_and_add(NMSettings *self, const char *uuid) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - SettConnEntry * sett_conn_entry; + SettConnEntry *sett_conn_entry; sett_conn_entry = _sett_conn_entry_new(uuid); @@ -841,7 +841,7 @@ _sett_conn_entries_remove_and_destroy(NMSettings *self, SettConnEntry *sett_conn static int _sett_conn_entry_sds_update_cmp_ascending(const StorageData *sd_a, const StorageData *sd_b, - const GSList * plugins) + const GSList *plugins) { const NMSettingsMetaData *meta_data_a; const NMSettingsMetaData *meta_data_b; @@ -997,13 +997,13 @@ _sett_conn_entry_sds_update(NMSettings *self, SettConnEntry *sett_conn_entry) static NMConnection * _connection_changed_normalize_connection(NMSettingsStorage *storage, - NMConnection * connection, - GVariant * secrets_to_merge, - NMConnection ** out_connection_cloned) + NMConnection *connection, + GVariant *secrets_to_merge, + NMConnection **out_connection_cloned) { gs_unref_object NMConnection *connection_cloned = NULL; - gs_free_error GError *error = NULL; - const char * uuid; + gs_free_error GError *error = NULL; + const char *uuid; nm_assert(NM_IS_SETTINGS_STORAGE(storage)); nm_assert(out_connection_cloned && !*out_connection_cloned); @@ -1047,18 +1047,18 @@ _connection_changed_normalize_connection(NMSettingsStorage *storage, /*****************************************************************************/ static void -_connection_changed_update(NMSettings * self, - SettConnEntry * sett_conn_entry, - NMConnection * connection, +_connection_changed_update(NMSettings *self, + SettConnEntry *sett_conn_entry, + NMConnection *connection, NMSettingsConnectionIntFlags sett_flags, NMSettingsConnectionIntFlags sett_mask, NMSettingsConnectionUpdateReason update_reason) { - NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - gs_unref_object NMConnection *connection_old = NULL; - NMSettingsStorage * storage = sett_conn_entry->storage; - gs_unref_object NMSettingsConnection *sett_conn = g_object_ref(sett_conn_entry->sett_conn); - const char * path; + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); + gs_unref_object NMConnection *connection_old = NULL; + NMSettingsStorage *storage = sett_conn_entry->storage; + gs_unref_object NMSettingsConnection *sett_conn = g_object_ref(sett_conn_entry->sett_conn); + const char *path; gboolean is_new; nm_assert(!NM_FLAGS_ANY(sett_mask, ~_NM_SETTINGS_CONNECTION_INT_FLAGS_PERSISTENT_MASK)); @@ -1162,15 +1162,15 @@ _connection_changed_update(NMSettings * self, } static void -_connection_changed_delete(NMSettings * self, - NMSettingsStorage * storage, +_connection_changed_delete(NMSettings *self, + NMSettingsStorage *storage, NMSettingsConnection *sett_conn, gboolean allow_add_to_no_auto_default) { - NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); gs_unref_object NMConnection *connection_for_agents = NULL; - NMDevice * device; - const char * uuid; + NMDevice *device; + const char *uuid; nm_assert(NM_IS_SETTINGS_CONNECTION(sett_conn)); nm_assert(c_list_contains(&priv->connections_lst_head, &sett_conn->_connections_lst)); @@ -1235,8 +1235,8 @@ _connection_changed_delete(NMSettings * self, } static void -_connection_changed_process_one(NMSettings * self, - SettConnEntry * sett_conn_entry, +_connection_changed_process_one(NMSettings *self, + SettConnEntry *sett_conn_entry, gboolean allow_add_to_no_auto_default, NMSettingsConnectionIntFlags sett_flags, NMSettingsConnectionIntFlags sett_mask, @@ -1253,7 +1253,7 @@ _connection_changed_process_one(NMSettings * self, if (!sd_best || !sd_best->connection) { gs_unref_object NMSettingsConnection *sett_conn = NULL; - gs_unref_object NMSettingsStorage *storage = NULL; + gs_unref_object NMSettingsStorage *storage = NULL; if (!sett_conn_entry->sett_conn) { if (!sd_best) { @@ -1310,7 +1310,7 @@ _connection_changed_process_one(NMSettings * self, } static void -_connection_changed_process_all_dirty(NMSettings * self, +_connection_changed_process_all_dirty(NMSettings *self, gboolean allow_add_to_no_auto_default, NMSettingsConnectionIntFlags sett_flags, NMSettingsConnectionIntFlags sett_mask, @@ -1318,7 +1318,7 @@ _connection_changed_process_all_dirty(NMSettings * self, NMSettingsConnectionUpdateReason update_reason) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - SettConnEntry * sett_conn_entry; + SettConnEntry *sett_conn_entry; while ((sett_conn_entry = c_list_first_entry(&priv->sce_dirty_lst_head, SettConnEntry, sce_dirty_lst))) { @@ -1333,15 +1333,15 @@ _connection_changed_process_all_dirty(NMSettings * self, } static SettConnEntry * -_connection_changed_track(NMSettings * self, +_connection_changed_track(NMSettings *self, NMSettingsStorage *storage, - NMConnection * connection, + NMConnection *connection, gboolean prioritize) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - SettConnEntry * sett_conn_entry; - StorageData * sd; - const char * uuid; + SettConnEntry *sett_conn_entry; + StorageData *sd; + const char *uuid; nm_assert_valid_settings_storage(NULL, storage); @@ -1358,9 +1358,9 @@ _connection_changed_track(NMSettings * self, _sett_conn_entries_get(self, uuid) ?: _sett_conn_entries_create_and_add(self, uuid); if (_LOGT_ENABLED()) { - const char * filename; + const char *filename; const NMSettingsMetaData *meta_data; - const char * shadowed_storage; + const char *shadowed_storage; gboolean shadowed_owned; filename = nm_settings_storage_get_filename(storage); @@ -1427,9 +1427,9 @@ _connection_changed_track(NMSettings * self, /*****************************************************************************/ static void -_plugin_connections_reload_cb(NMSettingsPlugin * plugin, +_plugin_connections_reload_cb(NMSettingsPlugin *plugin, NMSettingsStorage *storage, - NMConnection * connection, + NMConnection *connection, gpointer user_data) { _connection_changed_track(user_data, storage, connection, FALSE); @@ -1439,7 +1439,7 @@ static void _plugin_connections_reload(NMSettings *self) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - GSList * iter; + GSList *iter; for (iter = priv->plugins; iter; iter = iter->next) { nm_settings_plugin_reload_connections(iter->data, _plugin_connections_reload_cb, self); @@ -1462,36 +1462,36 @@ _plugin_connections_reload(NMSettings *self) /*****************************************************************************/ static gboolean -_add_connection_to_first_plugin(NMSettings * self, - SettConnEntry * sett_conn_entry, - NMConnection * new_connection, +_add_connection_to_first_plugin(NMSettings *self, + SettConnEntry *sett_conn_entry, + NMConnection *new_connection, gboolean in_memory, NMSettingsConnectionIntFlags sett_flags, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, - NMSettingsStorage ** out_new_storage, - NMConnection ** out_new_connection, - GError ** error) + NMSettingsStorage **out_new_storage, + NMConnection **out_new_connection, + GError **error) { - NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); gs_free_error GError *first_error = NULL; - GSList * iter; - const char * uuid; + GSList *iter; + const char *uuid; uuid = nm_connection_get_uuid(new_connection); nm_assert(nm_uuid_is_normalized(uuid)); for (iter = priv->plugins; iter; iter = iter->next) { - NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN(iter->data); - gs_unref_object NMSettingsStorage *storage = NULL; - gs_unref_object NMConnection *connection_to_add = NULL; - gs_unref_object NMConnection *connection_to_add_cloned = NULL; - NMConnection * connection_to_add_real = NULL; - gs_unref_variant GVariant *agent_owned_secrets = NULL; - gs_free_error GError *add_error = NULL; - gboolean success; - const char * filename; + NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN(iter->data); + gs_unref_object NMSettingsStorage *storage = NULL; + gs_unref_object NMConnection *connection_to_add = NULL; + gs_unref_object NMConnection *connection_to_add_cloned = NULL; + NMConnection *connection_to_add_real = NULL; + gs_unref_variant GVariant *agent_owned_secrets = NULL; + gs_free_error GError *add_error = NULL; + gboolean success; + const char *filename; if (!in_memory) { NMSettingsStorage *conflicting_storage; @@ -1594,19 +1594,19 @@ _add_connection_to_first_plugin(NMSettings * self, } static gboolean -_update_connection_to_plugin(NMSettings * self, - NMSettingsStorage * storage, - NMConnection * connection, +_update_connection_to_plugin(NMSettings *self, + NMSettingsStorage *storage, + NMConnection *connection, NMSettingsConnectionIntFlags sett_flags, gboolean force_rename, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, - NMSettingsStorage ** out_new_storage, - NMConnection ** out_new_connection, - GError ** error) + NMSettingsStorage **out_new_storage, + NMConnection **out_new_connection, + GError **error) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - NMSettingsPlugin * plugin; + NMSettingsPlugin *plugin; gboolean success; plugin = nm_settings_storage_get_plugin(storage); @@ -1646,7 +1646,7 @@ _set_nmmeta_tombstone(NMSettings *self, gboolean tombstone_in_memory, const char *shadowed_storage) { - NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); gs_unref_object NMSettingsStorage *tombstone_1_storage = NULL; gs_unref_object NMSettingsStorage *tombstone_2_storage = NULL; @@ -1703,27 +1703,27 @@ _set_nmmeta_tombstone(NMSettings *self, * Returns: TRUE on success. */ gboolean -nm_settings_add_connection(NMSettings * self, - NMConnection * connection, +nm_settings_add_connection(NMSettings *self, + NMConnection *connection, NMSettingsConnectionPersistMode persist_mode, NMSettingsConnectionAddReason add_reason, NMSettingsConnectionIntFlags sett_flags, - NMSettingsConnection ** out_sett_conn, - GError ** error) + NMSettingsConnection **out_sett_conn, + GError **error) { - NMSettingsPrivate *priv; - gs_unref_object NMConnection *connection_cloned_1 = NULL; - gs_unref_object NMConnection *new_connection = NULL; - gs_unref_object NMSettingsStorage *new_storage = NULL; - gs_unref_object NMSettingsStorage *shadowed_storage = NULL; - NMSettingsStorage * update_storage = NULL; - gs_free_error GError *local = NULL; - SettConnEntry * sett_conn_entry; - const char * uuid; - StorageData * sd; - gboolean new_in_memory; - gboolean success; - const char * shadowed_storage_filename = NULL; + NMSettingsPrivate *priv; + gs_unref_object NMConnection *connection_cloned_1 = NULL; + gs_unref_object NMConnection *new_connection = NULL; + gs_unref_object NMSettingsStorage *new_storage = NULL; + gs_unref_object NMSettingsStorage *shadowed_storage = NULL; + NMSettingsStorage *update_storage = NULL; + gs_free_error GError *local = NULL; + SettConnEntry *sett_conn_entry; + const char *uuid; + StorageData *sd; + gboolean new_in_memory; + gboolean success; + const char *shadowed_storage_filename = NULL; priv = NM_SETTINGS_GET_PRIVATE(self); @@ -1882,7 +1882,7 @@ again_add_connection: sett_conn_entry = _connection_changed_track(self, new_storage, new_connection, TRUE); c_list_for_each_entry (sd, &sett_conn_entry->sd_lst_head, sd_lst) { - const NMSettingsMetaData *meta_data; + const NMSettingsMetaData *meta_data; gs_unref_object NMSettingsStorage *new_tombstone_storage = NULL; gboolean in_memory; gboolean simulate; @@ -1946,27 +1946,27 @@ again_delete_tombstone: /*****************************************************************************/ gboolean -nm_settings_update_connection(NMSettings * self, - NMSettingsConnection * sett_conn, - NMConnection * connection, +nm_settings_update_connection(NMSettings *self, + NMSettingsConnection *sett_conn, + NMConnection *connection, NMSettingsConnectionPersistMode persist_mode, NMSettingsConnectionIntFlags sett_flags, NMSettingsConnectionIntFlags sett_mask, NMSettingsConnectionUpdateReason update_reason, - const char * log_context_name, - GError ** error) + const char *log_context_name, + GError **error) { - gs_unref_object NMConnection *connection_cloned_1 = NULL; - gs_unref_object NMConnection *new_connection_cloned = NULL; - gs_unref_object NMConnection *new_connection = NULL; - NMConnection * new_connection_real; + gs_unref_object NMConnection *connection_cloned_1 = NULL; + gs_unref_object NMConnection *new_connection_cloned = NULL; + gs_unref_object NMConnection *new_connection = NULL; + NMConnection *new_connection_real; gs_unref_object NMSettingsStorage *cur_storage = NULL; gs_unref_object NMSettingsStorage *new_storage = NULL; - NMSettingsStorage * drop_storage = NULL; - SettConnEntry * sett_conn_entry; + NMSettingsStorage *drop_storage = NULL; + SettConnEntry *sett_conn_entry; gboolean cur_in_memory; gboolean new_in_memory; - const char * uuid; + const char *uuid; gboolean tombstone_in_memory = FALSE; gboolean tombstone_on_disk = FALSE; @@ -2112,13 +2112,13 @@ nm_settings_update_connection(NMSettings * self, log_context_name, nm_connection_get_id(connection)); } else { - NMSettingsStorage *shadowed_storage; - const char * cur_shadowed_storage_filename; - const char * new_shadowed_storage_filename = NULL; - gboolean cur_shadowed_owned; - gboolean new_shadowed_owned = FALSE; - NMSettingsStorage *update_storage = NULL; - gs_free_error GError *local = NULL; + NMSettingsStorage *shadowed_storage; + const char *cur_shadowed_storage_filename; + const char *new_shadowed_storage_filename = NULL; + gboolean cur_shadowed_owned; + gboolean new_shadowed_owned = FALSE; + NMSettingsStorage *update_storage = NULL; + gs_free_error GError *local = NULL; gboolean success; cur_shadowed_storage_filename = @@ -2287,20 +2287,20 @@ nm_settings_update_connection(NMSettings * self, } void -nm_settings_delete_connection(NMSettings * self, +nm_settings_delete_connection(NMSettings *self, NMSettingsConnection *sett_conn, gboolean allow_add_to_no_auto_default) { - NMSettingsStorage *cur_storage; - NMSettingsStorage *shadowed_storage; - NMSettingsStorage *shadowed_storage_unowned = NULL; - NMSettingsStorage *drop_storages[2] = {}; - gs_free_error GError *local = NULL; - SettConnEntry * sett_conn_entry; - const char * cur_shadowed_storage_filename; - const char * new_shadowed_storage_filename = NULL; + NMSettingsStorage *cur_storage; + NMSettingsStorage *shadowed_storage; + NMSettingsStorage *shadowed_storage_unowned = NULL; + NMSettingsStorage *drop_storages[2] = {}; + gs_free_error GError *local = NULL; + SettConnEntry *sett_conn_entry; + const char *cur_shadowed_storage_filename; + const char *new_shadowed_storage_filename = NULL; gboolean cur_shadowed_owned; - const char * uuid; + const char *uuid; gboolean tombstone_in_memory = FALSE; gboolean tombstone_on_disk = FALSE; int i; @@ -2346,7 +2346,7 @@ nm_settings_delete_connection(NMSettings * self, for (i = 0; i < (int) G_N_ELEMENTS(drop_storages); i++) { NMSettingsStorage *storage; - StorageData * sd; + StorageData *sd; storage = drop_storages[i]; if (!storage) @@ -2415,7 +2415,7 @@ nm_settings_delete_connection(NMSettings * self, static void send_agent_owned_secrets(NMSettings *self, NMSettingsConnection *sett_conn, NMAuthSubject *subject) { - NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); gs_unref_object NMConnection *for_agent = NULL; /* Dupe the connection so we can clear out non-agent-owned secrets, @@ -2433,15 +2433,15 @@ send_agent_owned_secrets(NMSettings *self, NMSettingsConnection *sett_conn, NMAu static void pk_add_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMSettings * self = NM_SETTINGS(user_data); - NMAuthCallResult result; - gs_free_error GError *error = NULL; - NMConnection * connection = NULL; - gs_unref_object NMSettingsConnection *added = NULL; + NMSettings *self = NM_SETTINGS(user_data); + NMAuthCallResult result; + gs_free_error GError *error = NULL; + NMConnection *connection = NULL; + gs_unref_object NMSettingsConnection *added = NULL; NMSettingsAddCallback callback; gpointer callback_data; - NMAuthSubject * subject; - const char * perm; + NMAuthSubject *subject; + const char *perm; nm_assert(G_IS_DBUS_METHOD_INVOCATION(context)); @@ -2488,21 +2488,21 @@ pk_add_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data } void -nm_settings_add_connection_dbus(NMSettings * self, - NMConnection * connection, +nm_settings_add_connection_dbus(NMSettings *self, + NMConnection *connection, NMSettingsConnectionPersistMode persist_mode, NMSettingsConnectionAddReason add_reason, NMSettingsConnectionIntFlags sett_flags, - NMAuthSubject * subject, - GDBusMethodInvocation * context, + NMAuthSubject *subject, + GDBusMethodInvocation *context, NMSettingsAddCallback callback, gpointer user_data) { - NMSettingsPrivate * priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); NMSettingConnection *s_con; - NMAuthChain * chain; - GError * error = NULL, *tmp_error = NULL; - const char * perm; + NMAuthChain *chain; + GError *error = NULL, *tmp_error = NULL; + const char *perm; g_return_if_fail(NM_IS_CONNECTION(connection)); g_return_if_fail(NM_IS_AUTH_SUBJECT(subject)); @@ -2559,11 +2559,11 @@ done: } static void -settings_add_connection_add_cb(NMSettings * self, - NMSettingsConnection * connection, - GError * error, +settings_add_connection_add_cb(NMSettings *self, + NMSettingsConnection *connection, + GError *error, GDBusMethodInvocation *context, - NMAuthSubject * subject, + NMAuthSubject *subject, gpointer user_data) { gboolean is_add_connection_2 = GPOINTER_TO_INT(user_data); @@ -2597,15 +2597,15 @@ settings_add_connection_add_cb(NMSettings * self, } static void -settings_add_connection_helper(NMSettings * self, - GDBusMethodInvocation * context, +settings_add_connection_helper(NMSettings *self, + GDBusMethodInvocation *context, gboolean is_add_connection_2, - GVariant * settings, + GVariant *settings, NMSettingsAddConnection2Flags flags) { - gs_unref_object NMConnection *connection = NULL; - GError * error = NULL; - gs_unref_object NMAuthSubject * subject = NULL; + gs_unref_object NMConnection *connection = NULL; + GError *error = NULL; + gs_unref_object NMAuthSubject *subject = NULL; NMSettingsConnectionPersistMode persist_mode; connection = _nm_simple_connection_new_from_dbus(settings, @@ -2649,15 +2649,15 @@ settings_add_connection_helper(NMSettings * self, } static void -impl_settings_add_connection(NMDBusObject * obj, +impl_settings_add_connection(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettings * self = NM_SETTINGS(obj); + NMSettings *self = NM_SETTINGS(obj); gs_unref_variant GVariant *settings = NULL; g_variant_get(parameters, "(@a{sa{sv}})", &settings); @@ -2669,15 +2669,15 @@ impl_settings_add_connection(NMDBusObject * obj, } static void -impl_settings_add_connection_unsaved(NMDBusObject * obj, +impl_settings_add_connection_unsaved(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettings * self = NM_SETTINGS(obj); + NMSettings *self = NM_SETTINGS(obj); gs_unref_variant GVariant *settings = NULL; g_variant_get(parameters, "(@a{sa{sv}})", &settings); @@ -2689,19 +2689,19 @@ impl_settings_add_connection_unsaved(NMDBusObject * obj, } static void -impl_settings_add_connection2(NMDBusObject * obj, +impl_settings_add_connection2(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettings * self = NM_SETTINGS(obj); - gs_unref_variant GVariant *settings = NULL; - gs_unref_variant GVariant * args = NULL; + NMSettings *self = NM_SETTINGS(obj); + gs_unref_variant GVariant *settings = NULL; + gs_unref_variant GVariant *args = NULL; NMSettingsAddConnection2Flags flags; - const char * args_name; + const char *args_name; GVariantIter iter; guint32 flags_u; @@ -2760,19 +2760,19 @@ impl_settings_add_connection2(NMDBusObject * obj, /*****************************************************************************/ static void -impl_settings_load_connections(NMDBusObject * obj, +impl_settings_load_connections(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * dbus_connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *dbus_connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettings * self = NM_SETTINGS(obj); - NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettings *self = NM_SETTINGS(obj); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *failures = NULL; - gs_free const char ** filenames = NULL; - gs_free char * op_result_str = NULL; + gs_free const char **filenames = NULL; + gs_free char *op_result_str = NULL; g_variant_get(parameters, "(^a&s)", &filenames); @@ -2791,7 +2791,7 @@ impl_settings_load_connections(NMDBusObject * obj, NMSettingsPluginConnectionLoadEntry *entries; gsize n_entries; gsize i; - GSList * iter; + GSList *iter; entries = nm_settings_plugin_create_connection_load_entries(filenames, &n_entries); @@ -2857,13 +2857,13 @@ impl_settings_load_connections(NMDBusObject * obj, } static void -impl_settings_reload_connections(NMDBusObject * obj, +impl_settings_reload_connections(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { NMSettings *self = NM_SETTINGS(obj); @@ -2933,16 +2933,16 @@ _clear_connections_cached_list(NMSettingsPrivate *priv) } static void -impl_settings_list_connections(NMDBusObject * obj, +impl_settings_list_connections(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * dbus_connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *dbus_connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettings * self = NM_SETTINGS(obj); - NMSettingsPrivate * priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettings *self = NM_SETTINGS(obj); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); gs_free const char **strv = NULL; strv = @@ -2976,19 +2976,19 @@ nm_settings_get_dbus_path_for_uuid(NMSettings *self, const char *uuid) } static void -impl_settings_get_connection_by_uuid(NMDBusObject * obj, +impl_settings_get_connection_by_uuid(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * dbus_connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *dbus_connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettings * self = NM_SETTINGS(obj); - NMSettingsConnection *sett_conn; + NMSettings *self = NM_SETTINGS(obj); + NMSettingsConnection *sett_conn; gs_unref_object NMAuthSubject *subject = NULL; - GError * error = NULL; - const char * uuid; + GError *error = NULL; + const char *uuid; g_variant_get(parameters, "(&s)", &uuid); @@ -3039,9 +3039,9 @@ error: NMSettingsConnection *const * nm_settings_get_connections(NMSettings *self, guint *out_len) { - NMSettingsPrivate * priv; + NMSettingsPrivate *priv; NMSettingsConnection **v; - NMSettingsConnection * con; + NMSettingsConnection *con; guint i; g_return_val_if_fail(NM_IS_SETTINGS(self), NULL); @@ -3145,15 +3145,15 @@ nm_settings_get_connections_sorted_by_autoconnect_priority(NMSettings *self, gui * the contained values do not need to be unrefed. */ NMSettingsConnection ** -nm_settings_get_connections_clone(NMSettings * self, - guint * out_len, +nm_settings_get_connections_clone(NMSettings *self, + guint *out_len, NMSettingsConnectionFilterFunc func, gpointer func_data, GCompareDataFunc sort_compare_func, gpointer sort_data) { NMSettingsConnection *const *list_cached; - NMSettingsConnection ** list; + NMSettingsConnection **list; guint len, i, j; g_return_val_if_fail(NM_IS_SETTINGS(self), NULL); @@ -3192,7 +3192,7 @@ nm_settings_get_connections_clone(NMSettings * self, NMSettingsConnection * nm_settings_get_connection_by_path(NMSettings *self, const char *path) { - NMSettingsPrivate * priv; + NMSettingsPrivate *priv; NMSettingsConnection *connection; g_return_val_if_fail(NM_IS_SETTINGS(self), NULL); @@ -3225,7 +3225,7 @@ nm_settings_has_connection(NMSettings *self, NMSettingsConnection *connection) _connections_lst)); nm_assert(({ NMSettingsConnection *candidate = NULL; - const char * path; + const char *path; path = nm_dbus_object_get_path(NM_DBUS_OBJECT(connection)); if (path) @@ -3268,10 +3268,10 @@ add_plugin(NMSettings *self, NMSettingsPlugin *plugin, const char *pname, const static gboolean add_plugin_load_file(NMSettings *self, const char *pname, GError **error) { - gs_free char * full_name = NULL; - gs_free char * path = NULL; - gs_unref_object NMSettingsPlugin *plugin = NULL; - GModule * module; + gs_free char *full_name = NULL; + gs_free char *path = NULL; + gs_unref_object NMSettingsPlugin *plugin = NULL; + GModule *module; NMSettingsPluginFactoryFunc factory_func; struct stat st; int errsv; @@ -3395,11 +3395,11 @@ load_plugins(NMSettings *self, const char *const *plugins, GError **error) static void pk_hostname_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { - NMSettings * self = NM_SETTINGS(user_data); + NMSettings *self = NM_SETTINGS(user_data); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); NMAuthCallResult result; - GError * error = NULL; - const char * hostname; + GError *error = NULL; + const char *hostname; nm_assert(G_IS_DBUS_METHOD_INVOCATION(context)); @@ -3434,19 +3434,19 @@ pk_hostname_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user } static void -impl_settings_save_hostname(NMDBusObject * obj, +impl_settings_save_hostname(NMDBusObject *obj, const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended * method_info, - GDBusConnection * connection, - const char * sender, - GDBusMethodInvocation * invocation, - GVariant * parameters) + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) { - NMSettings * self = NM_SETTINGS(obj); + NMSettings *self = NM_SETTINGS(obj); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - NMAuthChain * chain; - const char * hostname; - const char * error_reason; + NMAuthChain *chain; + const char *hostname; + const char *error_reason; int error_code; g_variant_get(parameters, "(&s)", &hostname); @@ -3490,7 +3490,7 @@ _hostname_changed_cb(NMHostnameManager *hostname_manager, GParamSpec *pspec, gpo static gboolean have_connection_for_device(NMSettings *self, NMDevice *device) { - NMSettingsPrivate * priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); NMSettingsConnection *sett_conn; g_return_val_if_fail(NM_IS_SETTINGS(self), FALSE); @@ -3521,8 +3521,8 @@ have_connection_for_device(NMSettings *self, NMDevice *device) } static void -default_wired_clear_tag(NMSettings * self, - NMDevice * device, +default_wired_clear_tag(NMSettings *self, + NMDevice *device, NMSettingsConnection *sett_conn, gboolean add_to_no_auto_default) { @@ -3550,9 +3550,9 @@ static void device_realized(NMDevice *device, GParamSpec *pspec, NMSettings *self) { gs_unref_object NMConnection *connection = NULL; - NMSettingsPrivate * priv; - NMSettingsConnection * added; - GError * error = NULL; + NMSettingsPrivate *priv; + NMSettingsConnection *added; + GError *error = NULL; if (!nm_device_is_real(device)) return; @@ -3664,7 +3664,7 @@ nm_settings_device_removed(NMSettings *self, NMDevice *device, gboolean quitting static void session_monitor_changed_cb(NMSessionMonitor *session_monitor, NMSettings *self) { - NMSettingsPrivate * priv = NM_SETTINGS_GET_PRIVATE(self); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); NMSettingsConnection *const *list; guint i, len; guint generation; @@ -3705,8 +3705,8 @@ static void _kf_db_to_file(NMSettings *self, gboolean is_timestamps, gboolean force_write) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - NMKeyFileDB * kf_db; - bool * p_kf_db_pruned; + NMKeyFileDB *kf_db; + bool *p_kf_db_pruned; if (is_timestamps) { kf_db = priv->kf_db_timestamps; @@ -3739,9 +3739,9 @@ _kf_db_log_fcn(NMKeyFileDB *kf_db, int syslog_level, gpointer user_data, const c if (_NMLOG_ENABLED(level)) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - gs_free char * msg = NULL; + gs_free char *msg = NULL; va_list ap; - const char * prefix; + const char *prefix; va_start(ap, fmt); msg = g_strdup_vprintf(fmt, ap); @@ -3764,8 +3764,8 @@ static gboolean _kf_db_got_dirty_flush(NMSettings *self, gboolean is_timestamps) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - const char * prefix; - NMKeyFileDB * kf_db; + const char *prefix; + NMKeyFileDB *kf_db; if (is_timestamps) { prefix = "timestamps"; @@ -3803,11 +3803,11 @@ _kf_db_got_dirty_flush_seen_bssids_cb(gpointer user_data) static void _kf_db_got_dirty_fcn(NMKeyFileDB *kf_db, gpointer user_data) { - NMSettings * self = user_data; + NMSettings *self = user_data; NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); GSourceFunc idle_func; - guint * p_id; - const char * prefix; + guint *p_id; + const char *prefix; if (priv->kf_db_timestamps == kf_db) { prefix = "timestamps"; @@ -3844,7 +3844,7 @@ nm_settings_start(NMSettings *self, GError **error) { NMSettingsPrivate *priv; gs_strfreev char **plugins = NULL; - GSList * iter; + GSList *iter; priv = NM_SETTINGS_GET_PRIVATE(self); @@ -3914,9 +3914,9 @@ nm_settings_start(NMSettings *self, GError **error) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettings * self = NM_SETTINGS(object); + NMSettings *self = NM_SETTINGS(object); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - const char ** strv; + const char **strv; switch (prop_id) { case PROP_UNMANAGED_SPECS: @@ -3952,7 +3952,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettings * self = NM_SETTINGS(object); + NMSettings *self = NM_SETTINGS(object); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); switch (prop_id) { @@ -4009,9 +4009,9 @@ nm_settings_new(NMManager *manager) static void dispose(GObject *object) { - NMSettings * self = NM_SETTINGS(object); + NMSettings *self = NM_SETTINGS(object); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - CList * iter; + CList *iter; nm_assert(c_list_is_empty(&priv->sce_dirty_lst_head)); nm_assert(g_hash_table_size(priv->sce_idx) == 0); @@ -4043,9 +4043,9 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMSettings * self = NM_SETTINGS(object); + NMSettings *self = NM_SETTINGS(object); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); - GSList * iter; + GSList *iter; _clear_connections_cached_list(priv); @@ -4176,7 +4176,7 @@ static const NMDBusInterfaceInfoExtended interface_info_settings = { static void nm_settings_class_init(NMSettingsClass *class) { - GObjectClass * object_class = G_OBJECT_CLASS(class); + GObjectClass *object_class = G_OBJECT_CLASS(class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(class); dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_STATIC(NM_DBUS_PATH_SETTINGS); diff --git a/src/core/settings/nm-settings.h b/src/core/settings/nm-settings.h index ce18fecccf..13e9441adf 100644 --- a/src/core/settings/nm-settings.h +++ b/src/core/settings/nm-settings.h @@ -43,7 +43,7 @@ * * Returns: %TRUE to allow the connection, %FALSE to ignore it */ -typedef gboolean (*NMSettingsConnectionFilterFunc)(NMSettings * settings, +typedef gboolean (*NMSettingsConnectionFilterFunc)(NMSettings *settings, NMSettingsConnection *connection, gpointer func_data); @@ -60,20 +60,20 @@ NMSettings *nm_settings_new(NMManager *manager); gboolean nm_settings_start(NMSettings *self, GError **error); -typedef void (*NMSettingsAddCallback)(NMSettings * settings, - NMSettingsConnection * connection, - GError * error, +typedef void (*NMSettingsAddCallback)(NMSettings *settings, + NMSettingsConnection *connection, + GError *error, GDBusMethodInvocation *context, - NMAuthSubject * subject, + NMAuthSubject *subject, gpointer user_data); -void nm_settings_add_connection_dbus(NMSettings * self, - NMConnection * connection, +void nm_settings_add_connection_dbus(NMSettings *self, + NMConnection *connection, NMSettingsConnectionPersistMode persist_mode, NMSettingsConnectionAddReason add_reason, NMSettingsConnectionIntFlags sett_flags, - NMAuthSubject * subject, - GDBusMethodInvocation * context, + NMAuthSubject *subject, + GDBusMethodInvocation *context, NMSettingsAddCallback callback, gpointer user_data); @@ -82,32 +82,32 @@ NMSettingsConnection *const *nm_settings_get_connections(NMSettings *settings, g NMSettingsConnection *const * nm_settings_get_connections_sorted_by_autoconnect_priority(NMSettings *self, guint *out_len); -NMSettingsConnection **nm_settings_get_connections_clone(NMSettings * self, - guint * out_len, +NMSettingsConnection **nm_settings_get_connections_clone(NMSettings *self, + guint *out_len, NMSettingsConnectionFilterFunc func, gpointer func_data, GCompareDataFunc sort_compare_func, gpointer sort_data); -gboolean nm_settings_add_connection(NMSettings * settings, - NMConnection * connection, +gboolean nm_settings_add_connection(NMSettings *settings, + NMConnection *connection, NMSettingsConnectionPersistMode persist_mode, NMSettingsConnectionAddReason add_reason, NMSettingsConnectionIntFlags sett_flags, - NMSettingsConnection ** out_sett_conn, - GError ** error); + NMSettingsConnection **out_sett_conn, + GError **error); -gboolean nm_settings_update_connection(NMSettings * self, - NMSettingsConnection * sett_conn, - NMConnection * new_connection, +gboolean nm_settings_update_connection(NMSettings *self, + NMSettingsConnection *sett_conn, + NMConnection *new_connection, NMSettingsConnectionPersistMode persist_mode, NMSettingsConnectionIntFlags sett_flags, NMSettingsConnectionIntFlags sett_mask, NMSettingsConnectionUpdateReason update_reason, - const char * log_context_name, - GError ** error); + const char *log_context_name, + GError **error); -void nm_settings_delete_connection(NMSettings * self, +void nm_settings_delete_connection(NMSettings *self, NMSettingsConnection *sett_conn, gboolean allow_add_to_no_auto_default); diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c index 8fdc01fb41..eb0d733df7 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c @@ -43,7 +43,7 @@ typedef struct { struct { GDBusConnection *connection; - GCancellable * cancellable; + GCancellable *cancellable; gulong signal_id; guint regist_id; } dbus; @@ -99,9 +99,9 @@ nm_assert_self(NMSIfcfgRHPlugin *self, gboolean unhandled_specs_consistent) #if NM_MORE_ASSERTS > 5 { - NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); - NMSIfcfgRHStorage * storage; - gsize n_uuid; + NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); + NMSIfcfgRHStorage *storage; + gsize n_uuid; gs_unref_hashtable GHashTable *h_unmanaged = NULL; gs_unref_hashtable GHashTable *h_unrecognized = NULL; @@ -177,11 +177,11 @@ nm_assert_self(NMSIfcfgRHPlugin *self, gboolean unhandled_specs_consistent) static NMSIfcfgRHStorage * _load_file(NMSIfcfgRHPlugin *self, const char *filename, GError **error) { - gs_unref_object NMConnection *connection = NULL; - gs_free_error GError *load_error = NULL; - gs_free char * unhandled_spec = NULL; - gboolean load_error_ignore; - struct stat st; + gs_unref_object NMConnection *connection = NULL; + gs_free_error GError *load_error = NULL; + gs_free char *unhandled_spec = NULL; + gboolean load_error_ignore; + struct stat st; if (stat(filename, &st) != 0) { int errsv = errno; @@ -240,9 +240,9 @@ static void _load_dir(NMSIfcfgRHPlugin *self, NMSettUtilStorages *storages) { gs_unref_hashtable GHashTable *dupl_filenames = NULL; - gs_free_error GError *local = NULL; - const char * f_filename; - GDir * dir; + gs_free_error GError *local = NULL; + const char *f_filename; + GDir *dir; dir = g_dir_open(IFCFG_DIR, 0, &local); if (!dir) { @@ -253,9 +253,9 @@ _load_dir(NMSIfcfgRHPlugin *self, NMSettUtilStorages *storages) dupl_filenames = g_hash_table_new_full(nm_str_hash, g_str_equal, NULL, g_free); while ((f_filename = g_dir_read_name(dir))) { - gs_free char * full_path = NULL; + gs_free char *full_path = NULL; NMSIfcfgRHStorage *storage; - char * full_filename; + char *full_filename; full_path = g_build_filename(IFCFG_DIR, f_filename, NULL); full_filename = utils_detect_ifcfg_path(full_path, TRUE); @@ -275,21 +275,21 @@ _load_dir(NMSIfcfgRHPlugin *self, NMSettUtilStorages *storages) } static void -_storages_consolidate(NMSIfcfgRHPlugin * self, - NMSettUtilStorages * storages_new, +_storages_consolidate(NMSIfcfgRHPlugin *self, + NMSettUtilStorages *storages_new, gboolean replace_all, - GHashTable * storages_replaced, + GHashTable *storages_replaced, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) { - NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); - CList lst_conn_info_deleted = C_LIST_INIT(lst_conn_info_deleted); - gs_unref_ptrarray GPtrArray *storages_modified = NULL; + NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); + CList lst_conn_info_deleted = C_LIST_INIT(lst_conn_info_deleted); + gs_unref_ptrarray GPtrArray *storages_modified = NULL; CList storages_deleted; - NMSIfcfgRHStorage * storage_safe; - NMSIfcfgRHStorage * storage_new; - NMSIfcfgRHStorage * storage_old; - NMSIfcfgRHStorage * storage; + NMSIfcfgRHStorage *storage_safe; + NMSIfcfgRHStorage *storage_new; + NMSIfcfgRHStorage *storage_old; + NMSIfcfgRHStorage *storage; guint i; /* when we reload all files, we must signal add/update/modify of profiles one-by-one. @@ -402,20 +402,20 @@ _storages_consolidate(NMSIfcfgRHPlugin * self, /*****************************************************************************/ static void -load_connections(NMSettingsPlugin * plugin, - NMSettingsPluginConnectionLoadEntry * entries, +load_connections(NMSettingsPlugin *plugin, + NMSettingsPluginConnectionLoadEntry *entries, gsize n_entries, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) { - NMSIfcfgRHPlugin * self = NMS_IFCFG_RH_PLUGIN(plugin); + NMSIfcfgRHPlugin *self = NMS_IFCFG_RH_PLUGIN(plugin); NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); nm_auto_clear_sett_util_storages NMSettUtilStorages storages_new = NM_SETT_UTIL_STORAGES_INIT(storages_new, nms_ifcfg_rh_storage_destroy); gs_unref_hashtable GHashTable *dupl_filenames = NULL; gs_unref_hashtable GHashTable *storages_replaced = NULL; gs_unref_hashtable GHashTable *loaded_uuids = NULL; - const char * loaded_uuid; + const char *loaded_uuid; GHashTableIter h_iter; gsize i; @@ -430,12 +430,12 @@ load_connections(NMSettingsPlugin * plugin, for (i = 0; i < n_entries; i++) { NMSettingsPluginConnectionLoadEntry *const entry = &entries[i]; - gs_free_error GError * local = NULL; - const char * full_filename; - const char * uuid; - gs_free char * full_filename_keep = NULL; - NMSettingsPluginConnectionLoadEntry *dupl_content_entry; - gs_unref_object NMSIfcfgRHStorage *storage = NULL; + gs_free_error GError *local = NULL; + const char *full_filename; + const char *uuid; + gs_free char *full_filename_keep = NULL; + NMSettingsPluginConnectionLoadEntry *dupl_content_entry; + gs_unref_object NMSIfcfgRHStorage *storage = NULL; if (entry->handled) continue; @@ -499,7 +499,7 @@ load_connections(NMSettingsPlugin * plugin, /* now we visit all UUIDs that are about to change... */ g_hash_table_iter_init(&h_iter, loaded_uuids); while (g_hash_table_iter_next(&h_iter, (gpointer *) &loaded_uuid, NULL)) { - NMSIfcfgRHStorage * storage; + NMSIfcfgRHStorage *storage; NMSettUtilStorageByUuidHead *sbuh; sbuh = nm_sett_util_storages_lookup_by_uuid(&priv->storages, loaded_uuid); @@ -509,9 +509,9 @@ load_connections(NMSettingsPlugin * plugin, c_list_for_each_entry (storage, &sbuh->_storage_by_uuid_lst_head, parent._storage_by_uuid_lst) { - const char * full_filename = nms_ifcfg_rh_storage_get_filename(storage); + const char *full_filename = nms_ifcfg_rh_storage_get_filename(storage); gs_unref_object NMSIfcfgRHStorage *storage_new = NULL; - gs_free_error GError *local = NULL; + gs_free_error GError *local = NULL; if (g_hash_table_contains(dupl_filenames, full_filename)) { /* already re-loaded. */ @@ -544,11 +544,11 @@ load_connections(NMSettingsPlugin * plugin, } static void -reload_connections(NMSettingsPlugin * plugin, +reload_connections(NMSettingsPlugin *plugin, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) { - NMSIfcfgRHPlugin * self = NMS_IFCFG_RH_PLUGIN(plugin); + NMSIfcfgRHPlugin *self = NMS_IFCFG_RH_PLUGIN(plugin); nm_auto_clear_sett_util_storages NMSettUtilStorages storages_new = NM_SETT_UTIL_STORAGES_INIT(storages_new, nms_ifcfg_rh_storage_destroy); @@ -581,20 +581,20 @@ load_connections_done(NMSettingsPlugin *plugin) /*****************************************************************************/ static gboolean -add_connection(NMSettingsPlugin * plugin, - NMConnection * connection, +add_connection(NMSettingsPlugin *plugin, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error) + NMConnection **out_connection, + GError **error) { - NMSIfcfgRHPlugin * self = NMS_IFCFG_RH_PLUGIN(plugin); - NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); - gs_unref_object NMSIfcfgRHStorage *storage = NULL; - gs_unref_object NMConnection *reread = NULL; - gs_free char * full_filename = NULL; - GError * local = NULL; - gboolean reread_same; - struct timespec mtime; + NMSIfcfgRHPlugin *self = NMS_IFCFG_RH_PLUGIN(plugin); + NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); + gs_unref_object NMSIfcfgRHStorage *storage = NULL; + gs_unref_object NMConnection *reread = NULL; + gs_free char *full_filename = NULL; + GError *local = NULL; + gboolean reread_same; + struct timespec mtime; nm_assert_self(self, TRUE); nm_assert(NM_IS_CONNECTION(connection)); @@ -646,19 +646,19 @@ add_connection(NMSettingsPlugin * plugin, } static gboolean -update_connection(NMSettingsPlugin * plugin, - NMSettingsStorage * storage_x, - NMConnection * connection, +update_connection(NMSettingsPlugin *plugin, + NMSettingsStorage *storage_x, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error) + NMConnection **out_connection, + GError **error) { - NMSIfcfgRHPlugin * self = NMS_IFCFG_RH_PLUGIN(plugin); - NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); - NMSIfcfgRHStorage * storage = NMS_IFCFG_RH_STORAGE(storage_x); - const char * full_filename; - const char * uuid; - GError * local = NULL; + NMSIfcfgRHPlugin *self = NMS_IFCFG_RH_PLUGIN(plugin); + NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); + NMSIfcfgRHStorage *storage = NMS_IFCFG_RH_STORAGE(storage_x); + const char *full_filename; + const char *uuid; + GError *local = NULL; gs_unref_object NMConnection *reread = NULL; gboolean reread_same; struct timespec mtime; @@ -718,11 +718,11 @@ update_connection(NMSettingsPlugin * plugin, static gboolean delete_connection(NMSettingsPlugin *plugin, NMSettingsStorage *storage_x, GError **error) { - NMSIfcfgRHPlugin * self = NMS_IFCFG_RH_PLUGIN(plugin); + NMSIfcfgRHPlugin *self = NMS_IFCFG_RH_PLUGIN(plugin); NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); - NMSIfcfgRHStorage * storage = NMS_IFCFG_RH_STORAGE(storage_x); - const char * operation_message; - const char * full_filename; + NMSIfcfgRHStorage *storage = NMS_IFCFG_RH_STORAGE(storage_x); + const char *operation_message; + const char *full_filename; nm_assert_self(self, TRUE); nm_assert(!error || !*error); @@ -736,9 +736,9 @@ delete_connection(NMSettingsPlugin *plugin, NMSettingsStorage *storage_x, GError nm_assert(storage == nm_sett_util_storages_lookup_by_filename(&priv->storages, full_filename)); { - gs_free char * keyfile = utils_get_keys_path(full_filename); - gs_free char * routefile = utils_get_route_path(full_filename); - gs_free char * route6file = utils_get_route6_path(full_filename); + gs_free char *keyfile = utils_get_keys_path(full_filename); + gs_free char *routefile = utils_get_route_path(full_filename); + gs_free char *route6file = utils_get_route6_path(full_filename); const char *const files[] = {full_filename, keyfile, routefile, route6file}; gboolean any_deleted = FALSE; gboolean any_failure = FALSE; @@ -784,10 +784,10 @@ delete_connection(NMSettingsPlugin *plugin, NMSettingsStorage *storage_x, GError static void _unhandled_specs_reset(NMSIfcfgRHPlugin *self) { - NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); + NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); gs_unref_hashtable GHashTable *unmanaged_specs = NULL; gs_unref_hashtable GHashTable *unrecognized_specs = NULL; - NMSIfcfgRHStorage * storage; + NMSIfcfgRHStorage *storage; unmanaged_specs = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, NULL); unrecognized_specs = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, NULL); @@ -820,7 +820,7 @@ _unhandled_specs_merge_storages(NMSIfcfgRHPlugin *self, NMSettUtilStorages *stor NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); gboolean unmanaged_changed = FALSE; gboolean unrecognized_changed = FALSE; - NMSIfcfgRHStorage * storage; + NMSIfcfgRHStorage *storage; c_list_for_each_entry (storage, &storages->_storage_lst_head, parent._storage_lst) { if (storage->unmanaged_spec @@ -845,7 +845,7 @@ static GSList * _unhandled_specs_from_hashtable(GHashTable *hash) { gs_free const char **keys = NULL; - GSList * list = NULL; + GSList *list = NULL; guint i, l; keys = nm_strdict_get_keys(hash, TRUE, &l); @@ -873,15 +873,15 @@ get_unrecognized_specs(NMSettingsPlugin *plugin) /*****************************************************************************/ static void -impl_ifcfgrh_get_ifcfg_details(NMSIfcfgRHPlugin * self, +impl_ifcfgrh_get_ifcfg_details(NMSIfcfgRHPlugin *self, GDBusMethodInvocation *context, - const char * in_ifcfg) + const char *in_ifcfg) { NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); - gs_free char * ifcfg_path = NULL; - NMSIfcfgRHStorage * storage; - const char * uuid; - const char * path; + gs_free char *ifcfg_path = NULL; + NMSIfcfgRHStorage *storage; + const char *uuid; + const char *path; if (in_ifcfg[0] != '/') { g_dbus_method_invocation_return_error(context, @@ -964,7 +964,7 @@ _dbus_clear(NMSIfcfgRHPlugin *self) static void _dbus_connection_closed(GDBusConnection *connection, gboolean remote_peer_vanished, - GError * error, + GError *error, gpointer user_data) { _LOGW("dbus: %s bus closed", IFCFGRH1_BUS_NAME); @@ -974,12 +974,12 @@ _dbus_connection_closed(GDBusConnection *connection, } static void -_method_call(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_method_call(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -1014,11 +1014,11 @@ static GDBusInterfaceInfo *const interface_info = NM_DEFINE_GDBUS_INTERFACE_INFO static void _dbus_request_name_done(GObject *source_object, GAsyncResult *res, gpointer user_data) { - GDBusConnection * connection = G_DBUS_CONNECTION(source_object); - NMSIfcfgRHPlugin * self; - NMSIfcfgRHPluginPrivate *priv; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; + GDBusConnection *connection = G_DBUS_CONNECTION(source_object); + NMSIfcfgRHPlugin *self; + NMSIfcfgRHPluginPrivate *priv; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; guint32 result; ret = g_dbus_connection_call_finish(connection, res, &error); @@ -1072,10 +1072,10 @@ _dbus_request_name_done(GObject *source_object, GAsyncResult *res, gpointer user static void _dbus_create_done(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMSIfcfgRHPlugin * self; + NMSIfcfgRHPlugin *self; NMSIfcfgRHPluginPrivate *priv; - gs_free_error GError *error = NULL; - GDBusConnection * connection; + gs_free_error GError *error = NULL; + GDBusConnection *connection; connection = g_dbus_connection_new_for_address_finish(res, &error); if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -1117,8 +1117,8 @@ static void _dbus_setup(NMSIfcfgRHPlugin *self) { NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); - gs_free char * address = NULL; - gs_free_error GError *error = NULL; + gs_free char *address = NULL; + gs_free_error GError *error = NULL; _dbus_clear(self); @@ -1147,11 +1147,11 @@ _dbus_setup(NMSIfcfgRHPlugin *self) } static void -config_changed_cb(NMConfig * config, - NMConfigData * config_data, +config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, - NMSIfcfgRHPlugin * self) + NMConfigData *old_data, + NMSIfcfgRHPlugin *self) { NMSIfcfgRHPluginPrivate *priv; @@ -1188,7 +1188,7 @@ nms_ifcfg_rh_plugin_init(NMSIfcfgRHPlugin *self) static void constructed(GObject *object) { - NMSIfcfgRHPlugin * self = NMS_IFCFG_RH_PLUGIN(object); + NMSIfcfgRHPlugin *self = NMS_IFCFG_RH_PLUGIN(object); NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); G_OBJECT_CLASS(nms_ifcfg_rh_plugin_parent_class)->constructed(object); @@ -1204,7 +1204,7 @@ constructed(GObject *object) static void dispose(GObject *object) { - NMSIfcfgRHPlugin * self = NMS_IFCFG_RH_PLUGIN(object); + NMSIfcfgRHPlugin *self = NMS_IFCFG_RH_PLUGIN(object); NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self); if (priv->config) @@ -1227,7 +1227,7 @@ dispose(GObject *object) static void nms_ifcfg_rh_plugin_class_init(NMSIfcfgRHPluginClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingsPluginClass *plugin_class = NM_SETTINGS_PLUGIN_CLASS(klass); object_class->constructed = constructed; @@ -1247,7 +1247,7 @@ nms_ifcfg_rh_plugin_class_init(NMSIfcfgRHPluginClass *klass) /*****************************************************************************/ G_MODULE_EXPORT NMSettingsPlugin * - nm_settings_plugin_factory(void) +nm_settings_plugin_factory(void) { return g_object_new(NMS_TYPE_IFCFG_RH_PLUGIN, NULL); } diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 6dd5ef0502..e62c02277f 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -75,9 +75,9 @@ static char * get_full_file_path(const char *ifcfg_path, const char *file_path) { - const char * base = file_path; + const char *base = file_path; gs_free char *dirname = NULL; - char * p; + char *p; g_return_val_if_fail(ifcfg_path != NULL, NULL); g_return_val_if_fail(file_path != NULL, NULL); @@ -99,8 +99,8 @@ static NMSettingSecretFlags _secret_read_ifcfg_flags(shvarFile *ifcfg, const char *flags_key) { NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - gs_free char * val_free = NULL; - const char * val; + gs_free char *val_free = NULL; + const char *val; nm_assert(flags_key); nm_assert(g_str_has_suffix(flags_key, "_FLAGS")); @@ -118,10 +118,10 @@ _secret_read_ifcfg_flags(shvarFile *ifcfg, const char *flags_key) } static void -_secret_read_ifcfg(shvarFile * ifcfg, - shvarFile * keys_ifcfg, - const char * name, - char ** value, +_secret_read_ifcfg(shvarFile *ifcfg, + shvarFile *keys_ifcfg, + const char *name, + char **value, NMSettingSecretFlags *flags) { char flags_key[250]; @@ -141,8 +141,8 @@ _secret_read_ifcfg(shvarFile * ifcfg, static void _secret_set_from_ifcfg(gpointer setting, - shvarFile * ifcfg, - shvarFile * keys_ifcfg, + shvarFile *ifcfg, + shvarFile *keys_ifcfg, const char *ifcfg_key, const char *property_name) { @@ -165,8 +165,8 @@ _secret_set_from_ifcfg(gpointer setting, static gboolean _secret_password_raw_to_bytes(const char *ifcfg_key, const char *password_raw, - GBytes ** out_bytes, - GError ** error) + GBytes **out_bytes, + GError **error) { nm_auto_free_secret_buf NMSecretBuf *secret = NULL; gsize len; @@ -222,17 +222,17 @@ _cert_get_cert_bytes(const char *ifcfg_path, const char *value, GError **error) } static gboolean -_cert_get_cert(shvarFile * ifcfg, - const char * ifcfg_key, - GBytes ** out_cert, +_cert_get_cert(shvarFile *ifcfg, + const char *ifcfg_key, + GBytes **out_cert, NMSetting8021xCKScheme *out_scheme, - GError ** error) + GError **error) { nm_auto_free_secret char *val_free = NULL; - const char * val; - gs_unref_bytes GBytes *cert = NULL; - GError * local = NULL; - NMSetting8021xCKScheme scheme; + const char *val; + gs_unref_bytes GBytes *cert = NULL; + GError *local = NULL; + NMSetting8021xCKScheme scheme; val = svGetValueStr(ifcfg, ifcfg_key, &val_free); if (!val) { @@ -266,11 +266,11 @@ err: static gboolean _cert_set_from_ifcfg(gpointer setting, - shvarFile * ifcfg, + shvarFile *ifcfg, const char *ifcfg_key, const char *property_name, - GBytes ** out_cert, - GError ** error) + GBytes **out_cert, + GError **error) { gs_unref_bytes GBytes *cert = NULL; @@ -289,8 +289,8 @@ static void check_if_bond_slave(shvarFile *ifcfg, NMSettingConnection *s_con) { gs_free char *value = NULL; - const char * v; - const char * master; + const char *v; + const char *master; v = svGetValueStr(ifcfg, "MASTER_UUID", &value); if (!v) @@ -322,8 +322,8 @@ static void check_if_team_slave(shvarFile *ifcfg, NMSettingConnection *s_con) { gs_free char *value = NULL; - const char * v; - const char * master; + const char *v; + const char *master; v = svGetValueStr(ifcfg, "TEAM_MASTER_UUID", &value); if (!v) @@ -348,7 +348,7 @@ check_if_team_slave(shvarFile *ifcfg, NMSettingConnection *s_con) } static char * -make_connection_name(shvarFile * ifcfg, +make_connection_name(shvarFile *ifcfg, const char *ifcfg_name, const char *suggested, const char *prefix) @@ -378,21 +378,21 @@ make_connection_name(shvarFile * ifcfg, static NMSetting * make_connection_setting(const char *file, - shvarFile * ifcfg, + shvarFile *ifcfg, const char *type, const char *suggested, const char *prefix) { - NMSettingConnection * s_con; + NMSettingConnection *s_con; NMSettingConnectionLldp lldp; - const char * ifcfg_name = NULL; - gs_free char * new_id = NULL; - const char * uuid; - gs_free char * uuid_free = NULL; - gs_free char * value = NULL; - const char * v; - gs_free char * stable_id = NULL; - const char *const * iter; + const char *ifcfg_name = NULL; + gs_free char *new_id = NULL; + const char *uuid; + gs_free char *uuid_free = NULL; + gs_free char *value = NULL; + const char *v; + gs_free char *stable_id = NULL; + const char *const *iter; int vint64, i_val; ifcfg_name = utils_get_ifcfg_name(file, TRUE); @@ -597,7 +597,7 @@ make_connection_setting(const char *file, if (vint64 != -1) vint64 *= 1000; else if (v[0] != '\0') { - char * endptr; + char *endptr; double d; d = nm_g_ascii_strtod(v, &endptr); @@ -647,14 +647,14 @@ make_connection_setting(const char *file, } static gboolean -read_ip4_address(shvarFile * ifcfg, +read_ip4_address(shvarFile *ifcfg, const char *tag, - gboolean * out_has_key, - guint32 * out_addr, - GError ** error) + gboolean *out_has_key, + guint32 *out_addr, + GError **error) { gs_free char *value_to_free = NULL; - const char * value; + const char *value; in_addr_t a; nm_assert(ifcfg); @@ -714,18 +714,18 @@ is_any_ip4_address_defined(shvarFile *ifcfg, int *idx) /* Returns TRUE on missing address or valid address */ static gboolean -read_full_ip4_address(shvarFile * ifcfg, +read_full_ip4_address(shvarFile *ifcfg, gint32 which, - NMIPAddress * base_addr, + NMIPAddress *base_addr, NMIPAddress **out_address, - char ** out_gateway, - GError ** error) + char **out_gateway, + GError **error) { char tag[256]; char prefix_tag[256]; guint32 ipaddr; gs_free char *value = NULL; - const char * v; + const char *v; int prefix = 0; gboolean has_key; guint32 a; @@ -918,9 +918,9 @@ enum { static int parse_route_line(const char *line, int addr_family, - NMIPRoute * options_route, + NMIPRoute *options_route, NMIPRoute **out_route, - GError ** error) + GError **error) { static const ParseLineInfo parse_infos[] = { [PARSE_LINE_ATTR_ROUTE_TYPE] = @@ -1016,9 +1016,9 @@ parse_route_line(const char *line, }, }; nm_auto_unref_ip_route NMIPRoute *route = NULL; - gs_free const char ** words_free = NULL; - const char *const * words; - const char * s; + gs_free const char **words_free = NULL; + const char *const *words; + const char *s; gsize i_words; guint i; char buf1[256]; @@ -1054,7 +1054,7 @@ parse_route_line(const char *line, const gsize i_words0 = i_words; const char *const w = words[i_words0]; const ParseLineInfo *p_info; - ParseLineData * p_data; + ParseLineData *p_data; gboolean unqualified_addr = FALSE; for (i = 0; i < G_N_ELEMENTS(parse_infos); i++) { @@ -1343,7 +1343,7 @@ next:; for (i = 0; i < G_N_ELEMENTS(parse_infos); i++) { const ParseLineInfo *p_info = &parse_infos[i]; - ParseLineData * p_data = &parse_datas[i]; + ParseLineData *p_data = &parse_datas[i]; if (!p_data->has) continue; @@ -1414,7 +1414,7 @@ read_one_ip4_route(shvarFile *ifcfg, guint32 which, NMIPRoute **out_route, GErro guint32 next_hop; guint32 netmask; gboolean has_key; - const char * v; + const char *v; gs_free char *value = NULL; gint64 prefix, metric; char inet_buf[NM_UTILS_INET_ADDRSTRLEN]; @@ -1499,11 +1499,11 @@ read_one_ip4_route(shvarFile *ifcfg, guint32 which, NMIPRoute **out_route, GErro static gboolean read_route_file_parse(int addr_family, - const char * filename, - const char * contents, + const char *filename, + const char *contents, gsize len, NMSettingIPConfig *s_ip, - GError ** error) + GError **error) { gsize line_num; @@ -1517,10 +1517,10 @@ read_route_file_parse(int addr_family, line_num = 0; while (TRUE) { nm_auto_unref_ip_route NMIPRoute *route = NULL; - gs_free_error GError *local = NULL; - const char * line = contents; - char * eol; - int e; + gs_free_error GError *local = NULL; + const char *line = contents; + char *eol; + int e; eol = strchr(contents, '\n'); if (eol) { @@ -1582,7 +1582,7 @@ static void parse_dns_options(NMSettingIPConfig *ip_config, const char *value) { gs_free const char **options = NULL; - const char *const * item; + const char *const *item; g_return_if_fail(ip_config); @@ -1602,11 +1602,11 @@ parse_dns_options(NMSettingIPConfig *ip_config, const char *value) } static gboolean -parse_full_ip6_address(shvarFile * ifcfg, - const char * addr_str, +parse_full_ip6_address(shvarFile *ifcfg, + const char *addr_str, int i, NMIPAddress **out_address, - GError ** error) + GError **error) { NMIPAddress *addr; NMIPAddr addr_bin; @@ -1639,12 +1639,12 @@ parse_full_ip6_address(shvarFile * ifcfg, static NMSetting * make_user_setting(shvarFile *ifcfg) { - gboolean has_user_data = FALSE; - gs_unref_object NMSettingUser *s_user = NULL; - gs_unref_hashtable GHashTable *keys = NULL; + gboolean has_user_data = FALSE; + gs_unref_object NMSettingUser *s_user = NULL; + gs_unref_hashtable GHashTable *keys = NULL; GHashTableIter iter; - const char * key; - nm_auto_free_gstring GString *str = NULL; + const char *key; + nm_auto_free_gstring GString *str = NULL; keys = svGetKeys(ifcfg, SV_KEY_TYPE_USER); if (!keys) @@ -1652,7 +1652,7 @@ make_user_setting(shvarFile *ifcfg) g_hash_table_iter_init(&iter, keys); while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) { - const char * value; + const char *value; gs_free char *value_to_free = NULL; value = svGetValue(ifcfg, key, &value_to_free); @@ -1679,7 +1679,7 @@ make_user_setting(shvarFile *ifcfg) } static void -make_match_setting_prop(const char * v, +make_match_setting_prop(const char *v, NMSettingMatch **s_match, void (*add_fcn)(NMSettingMatch *s_match, const char *value)) { @@ -1700,11 +1700,11 @@ static NMSetting * make_match_setting(shvarFile *ifcfg) { NMSettingMatch *s_match = NULL; - gs_free char * value_ifn = NULL; - gs_free char * value_kcl = NULL; - gs_free char * value_d = NULL; - gs_free char * value_p = NULL; - const char * v; + gs_free char *value_ifn = NULL; + gs_free char *value_kcl = NULL; + gs_free char *value_d = NULL; + gs_free char *value_p = NULL; + const char *v; v = svGetValueStr(ifcfg, "MATCH_INTERFACE_NAME", &value_ifn); make_match_setting_prop(v, &s_match, nm_setting_match_add_interface_name); @@ -1721,9 +1721,9 @@ make_match_setting(shvarFile *ifcfg) static NMSetting * make_proxy_setting(shvarFile *ifcfg) { - NMSettingProxy * s_proxy = NULL; - gs_free char * value = NULL; - const char * v; + NMSettingProxy *s_proxy = NULL; + gs_free char *value = NULL; + const char *v; NMSettingProxyMethod method; v = svGetValueStr(ifcfg, "PROXY_METHOD", &value); @@ -1767,24 +1767,24 @@ static NMSetting * make_ip4_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_read, - gboolean * out_has_defroute, - GError ** error) + gboolean *out_has_defroute, + GError **error) { gs_unref_object NMSettingIPConfig *s_ip4 = NULL; - gs_free char * route_path = NULL; - gs_free char * value = NULL; - const char * v; - char * method; - gs_free char * dns_options_free = NULL; - const char * dns_options = NULL; - gs_free char * gateway = NULL; + gs_free char *route_path = NULL; + gs_free char *value = NULL; + const char *v; + char *method; + gs_free char *dns_options_free = NULL; + const char *dns_options = NULL; + gs_free char *gateway = NULL; int i; guint32 a; gboolean has_key; gboolean never_default; gint64 i64; int priority; - const char *const * item; + const char *const *item; guint32 route_table; nm_assert(out_has_defroute && !*out_has_defroute); @@ -1807,7 +1807,7 @@ make_ip4_setting(shvarFile *ifcfg, /* Then check if GATEWAYDEV; it's global and overrides DEFROUTE */ if (network_ifcfg) { gs_free char *gatewaydev_value = NULL; - const char * gatewaydev; + const char *gatewaydev; /* Get the connection ifcfg device name and the global gateway device */ v = svGetValueStr(ifcfg, "DEVICE", &value); @@ -2115,11 +2115,11 @@ make_ip4_setting(shvarFile *ifcfg, static void read_aliases(NMSettingIPConfig *s_ip4, gboolean read_defroute, const char *filename) { - GDir * dir; + GDir *dir; gs_free char *dirname = NULL; gs_free char *base = NULL; - NMIPAddress * base_addr = NULL; - GError * err = NULL; + NMIPAddress *base_addr = NULL; + GError *err = NULL; g_return_if_fail(s_ip4 != NULL); g_return_if_fail(filename != NULL); @@ -2134,17 +2134,17 @@ read_aliases(NMSettingIPConfig *s_ip4, gboolean read_defroute, const char *filen dir = g_dir_open(dirname, 0, &err); if (dir) { - const char * item; + const char *item; NMIPAddress *addr; gboolean ok; while ((item = g_dir_read_name(dir))) { nm_auto_shvar_file_close shvarFile *parsed = NULL; - gs_free char * gateway = NULL; - gs_free char * device_value = NULL; - gs_free char * full_path = NULL; - const char * device; - const char * p; + gs_free char *gateway = NULL; + gs_free char *device_value = NULL; + gs_free char *full_path = NULL; + const char *device; + const char *p; if (!utils_is_ifcfg_alias_file(item, base)) continue; @@ -2239,22 +2239,22 @@ static NMSetting * make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_read, GError **error) { gs_unref_object NMSettingIPConfig *s_ip6 = NULL; - const char * v; - gs_free char * value = NULL; + const char *v; + gs_free char *value = NULL; gboolean ipv6init; gboolean ipv6forwarding; gboolean disabled; gboolean dhcp6 = FALSE; - char * method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; - const char * ipv6addr, *ipv6addr_secondaries; - gs_free char * ipv6addr_to_free = NULL; - gs_free char * ipv6addr_secondaries_to_free = NULL; - gs_free const char ** list = NULL; - const char *const * iter; + char *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; + const char *ipv6addr, *ipv6addr_secondaries; + gs_free char *ipv6addr_to_free = NULL; + gs_free char *ipv6addr_secondaries_to_free = NULL; + gs_free const char **list = NULL; + const char *const *iter; guint32 i; gint64 i64; int i_val; - GError * local = NULL; + GError *local = NULL; int priority; gboolean never_default = FALSE; gboolean ip6_privacy = FALSE, ip6_privacy_prefer_public_ip; @@ -2276,10 +2276,10 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea * When both are set, the device specified in IPV6_DEFAULTGW takes preference. */ if (network_ifcfg) { - const char * ipv6_defaultgw, *ipv6_defaultdev; + const char *ipv6_defaultgw, *ipv6_defaultdev; gs_free char *ipv6_defaultgw_to_free = NULL; gs_free char *ipv6_defaultdev_to_free = NULL; - const char * default_dev = NULL; + const char *default_dev = NULL; /* Get the connection ifcfg device name and the global default route device */ nm_clear_g_free(&value); @@ -2629,10 +2629,10 @@ static NMSetting * make_sriov_setting(shvarFile *ifcfg) { gs_unref_hashtable GHashTable *keys = NULL; - gs_unref_ptrarray GPtrArray *vfs = NULL; - int autoprobe_drivers; - NMSettingSriov * s_sriov; - gint64 total_vfs; + gs_unref_ptrarray GPtrArray *vfs = NULL; + int autoprobe_drivers; + NMSettingSriov *s_sriov; + gint64 total_vfs; total_vfs = svGetValueInt64(ifcfg, "SRIOV_TOTAL_VFS", 10, 0, G_MAXUINT32, -1); @@ -2646,14 +2646,14 @@ make_sriov_setting(shvarFile *ifcfg) keys = svGetKeys(ifcfg, SV_KEY_TYPE_SRIOV_VF); if (keys) { GHashTableIter iter; - const char * key; + const char *key; g_hash_table_iter_init(&iter, keys); while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) { gs_free_error GError *error = NULL; - gs_free char * value_to_free = NULL; - const char * value; - NMSriovVF * vf; + gs_free char *value_to_free = NULL; + const char *value; + NMSriovVF *vf; nm_assert(g_str_has_prefix(key, "SRIOV_VF")); @@ -2705,10 +2705,10 @@ make_tc_setting(shvarFile *ifcfg) s_tc = (NMSettingTCConfig *) nm_setting_tc_config_new(); for (i = 1;; i++) { - NMTCQdisc * qdisc = NULL; + NMTCQdisc *qdisc = NULL; gs_free char *value_to_free = NULL; - const char * value = NULL; - GError * local = NULL; + const char *value = NULL; + GError *local = NULL; value = svGetValueStr(ifcfg, numbered_tag(tag, "QDISC", i), &value_to_free); if (!value) @@ -2727,10 +2727,10 @@ make_tc_setting(shvarFile *ifcfg) } for (i = 1;; i++) { - NMTCTfilter * tfilter = NULL; - gs_free char *value_to_free = NULL; - const char * value = NULL; - gs_free_error GError *local = NULL; + NMTCTfilter *tfilter = NULL; + gs_free char *value_to_free = NULL; + const char *value = NULL; + gs_free_error GError *local = NULL; value = svGetValueStr(ifcfg, numbered_tag(tag, "FILTER", i), &value_to_free); if (!value) @@ -2812,16 +2812,16 @@ read_dcb_flags(shvarFile *ifcfg, DcbFlagsProperty *property) } static gboolean -read_dcb_app(shvarFile * ifcfg, - NMSettingDcb * s_dcb, - const char * app, +read_dcb_app(shvarFile *ifcfg, + NMSettingDcb *s_dcb, + const char *app, DcbFlagsProperty *flags_prop, - const char * priority_prop, - GError ** error) + const char *priority_prop, + GError **error) { NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; - gs_free char * value = NULL; - const char * v; + gs_free char *value = NULL; + const char *v; gboolean success = TRUE; int priority = -1; char key[255]; @@ -2862,16 +2862,16 @@ read_dcb_app(shvarFile * ifcfg, typedef void (*DcbSetBoolFunc)(NMSettingDcb *, guint, gboolean); static gboolean -read_dcb_bool_array(shvarFile * ifcfg, - NMSettingDcb * s_dcb, +read_dcb_bool_array(shvarFile *ifcfg, + NMSettingDcb *s_dcb, NMSettingDcbFlags flags, - const char * prop, - const char * desc, + const char *prop, + const char *desc, DcbSetBoolFunc set_func, - GError ** error) + GError **error) { gs_free char *value = NULL; - const char * v; + const char *v; guint i; v = svGetValueStr(ifcfg, prop, &value); @@ -2910,14 +2910,14 @@ read_dcb_bool_array(shvarFile * ifcfg, typedef void (*DcbSetUintFunc)(NMSettingDcb *, guint, guint); static gboolean -read_dcb_uint_array(shvarFile * ifcfg, - NMSettingDcb * s_dcb, +read_dcb_uint_array(shvarFile *ifcfg, + NMSettingDcb *s_dcb, NMSettingDcbFlags flags, - const char * prop, - const char * desc, + const char *prop, + const char *desc, gboolean f_allowed, DcbSetUintFunc set_func, - GError ** error) + GError **error) { gs_free char *val = NULL; guint i; @@ -2963,18 +2963,18 @@ read_dcb_uint_array(shvarFile * ifcfg, } static gboolean -read_dcb_percent_array(shvarFile * ifcfg, - NMSettingDcb * s_dcb, +read_dcb_percent_array(shvarFile *ifcfg, + NMSettingDcb *s_dcb, NMSettingDcbFlags flags, - const char * prop, - const char * desc, + const char *prop, + const char *desc, gboolean sum_pct, DcbSetUintFunc set_func, - GError ** error) + GError **error) { - gs_free char * val = NULL; + gs_free char *val = NULL; gs_free const char **split = NULL; - const char *const * iter; + const char *const *iter; guint i, sum = 0; val = svGetValueStr_cp(ifcfg, prop); @@ -3030,7 +3030,7 @@ make_dcb_setting(shvarFile *ifcfg, NMSetting **out_setting, GError **error) gs_unref_object NMSettingDcb *s_dcb = NULL; gboolean dcb_on; NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; - gs_free char * val = NULL; + gs_free char *val = NULL; g_return_val_if_fail(out_setting, FALSE); *out_setting = NULL; @@ -3165,16 +3165,16 @@ make_dcb_setting(shvarFile *ifcfg, NMSetting **out_setting, GError **error) } static gboolean -add_one_wep_key(shvarFile * ifcfg, - const char * shvar_key, +add_one_wep_key(shvarFile *ifcfg, + const char *shvar_key, guint8 key_idx, gboolean passphrase, NMSettingWirelessSecurity *s_wsec, - GError ** error) + GError **error) { gs_free char *value_free = NULL; - const char * value; - const char * key = NULL; + const char *value; + const char *key = NULL; g_return_val_if_fail(ifcfg != NULL, FALSE); g_return_val_if_fail(shvar_key != NULL, FALSE); @@ -3233,11 +3233,11 @@ add_one_wep_key(shvarFile * ifcfg, } static gboolean -read_wep_keys(shvarFile * ifcfg, +read_wep_keys(shvarFile *ifcfg, NMWepKeyType key_type, guint8 def_idx, NMSettingWirelessSecurity *s_wsec, - GError ** error) + GError **error) { if (key_type != NM_WEP_KEY_TYPE_PASSPHRASE) { if (!add_one_wep_key(ifcfg, "KEY1", 0, FALSE, s_wsec, error)) @@ -3270,8 +3270,8 @@ static NMSetting * make_wep_setting(shvarFile *ifcfg, const char *file, GError **error) { gs_unref_object NMSettingWirelessSecurity *s_wsec = NULL; - gs_free char * value = NULL; - shvarFile * keys_ifcfg = NULL; + gs_free char *value = NULL; + shvarFile *keys_ifcfg = NULL; int default_key_idx = 0; gboolean has_default_key = FALSE; NMSettingSecretFlags key_flags; @@ -3306,7 +3306,7 @@ make_wep_setting(shvarFile *ifcfg, const char *file, GError **error) /* Read keys in the ifcfg file if they are system-owned */ if (key_flags == NM_SETTING_SECRET_FLAG_NONE) { NMWepKeyType key_type; - const char * v; + const char *v; gs_free char *to_free = NULL; v = svGetValueStr(ifcfg, "KEY_TYPE", &to_free); @@ -3393,10 +3393,10 @@ make_wep_setting(shvarFile *ifcfg, const char *file, GError **error) static gboolean fill_wpa_ciphers(shvarFile *ifcfg, NMSettingWirelessSecurity *wsec, gboolean group, gboolean adhoc) { - gs_free char * value = NULL; - const char * p; + gs_free char *value = NULL; + const char *p; gs_free const char **list = NULL; - const char *const * iter; + const char *const *iter; int i = 0; p = svGetValueStr(ifcfg, group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE", &value); @@ -3434,7 +3434,7 @@ fill_wpa_ciphers(shvarFile *ifcfg, NMSettingWirelessSecurity *wsec, gboolean gro static char * parse_wpa_psk(shvarFile *ifcfg, const char *file, GBytes *ssid, GError **error) { - shvarFile * keys_ifcfg; + shvarFile *keys_ifcfg; gs_free char *psk = NULL; size_t plen; @@ -3484,17 +3484,17 @@ parse_wpa_psk(shvarFile *ifcfg, const char *file, GBytes *ssid, GError **error) } static gboolean -eap_simple_reader(const char * eap_method, - shvarFile * ifcfg, - shvarFile * keys_ifcfg, +eap_simple_reader(const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys_ifcfg, NMSetting8021x *s_8021x, gboolean phase2, - GError ** error) + GError **error) { NMSettingSecretFlags flags; - gs_free char * identity_free = NULL; - nm_auto_free_secret char *password_raw_str = NULL; - gs_unref_bytes GBytes *password_raw_bytes = NULL; + gs_free char *identity_free = NULL; + nm_auto_free_secret char *password_raw_str = NULL; + gs_unref_bytes GBytes *password_raw_bytes = NULL; g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, @@ -3525,19 +3525,19 @@ eap_simple_reader(const char * eap_method, } static gboolean -eap_tls_reader(const char * eap_method, - shvarFile * ifcfg, - shvarFile * keys_ifcfg, +eap_tls_reader(const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys_ifcfg, NMSetting8021x *s_8021x, gboolean phase2, - GError ** error) + GError **error) { gs_unref_bytes GBytes *privkey = NULL; gs_unref_bytes GBytes *client_cert = NULL; - gs_free char * identity_free = NULL; - gs_free char * value_to_free = NULL; - const char * client_cert_var; - const char * client_cert_prop; + gs_free char *identity_free = NULL; + gs_free char *value_to_free = NULL; + const char *client_cert_var; + const char *client_cert_prop; NMSetting8021xCKFormat format; g_object_set(s_8021x, @@ -3616,16 +3616,16 @@ eap_tls_reader(const char * eap_method, } static gboolean -parse_8021x_phase2_auth(shvarFile * ifcfg, - shvarFile * keys_ifcfg, +parse_8021x_phase2_auth(shvarFile *ifcfg, + shvarFile *keys_ifcfg, NMSetting8021x *s_8021x, - GError ** error) + GError **error) { - gs_free char * inner_auth = NULL; - gs_free char * v_free = NULL; - const char * v; + gs_free char *inner_auth = NULL; + gs_free char *v_free = NULL; + const char *v; gs_free const char **list = NULL; - const char *const * iter; + const char *const *iter; guint num_auth = 0; guint num_autheap = 0; @@ -3699,15 +3699,15 @@ parse_8021x_phase2_auth(shvarFile * ifcfg, } static gboolean -eap_peap_reader(const char * eap_method, - shvarFile * ifcfg, - shvarFile * keys_ifcfg, +eap_peap_reader(const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys_ifcfg, NMSetting8021x *s_8021x, gboolean phase2, - GError ** error) + GError **error) { gs_free char *value = NULL; - const char * v; + const char *v; if (!_cert_set_from_ifcfg(s_8021x, ifcfg, @@ -3754,15 +3754,15 @@ eap_peap_reader(const char * eap_method, } static gboolean -eap_ttls_reader(const char * eap_method, - shvarFile * ifcfg, - shvarFile * keys_ifcfg, +eap_ttls_reader(const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys_ifcfg, NMSetting8021x *s_8021x, gboolean phase2, - GError ** error) + GError **error) { gs_free char *value = NULL; - const char * v; + const char *v; if (!_cert_set_from_ifcfg(s_8021x, ifcfg, @@ -3789,19 +3789,19 @@ eap_ttls_reader(const char * eap_method, } static gboolean -eap_fast_reader(const char * eap_method, - shvarFile * ifcfg, - shvarFile * keys_ifcfg, +eap_fast_reader(const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys_ifcfg, NMSetting8021x *s_8021x, gboolean phase2, - GError ** error) + GError **error) { - gs_free char * anon_ident = NULL; - gs_free char * pac_file = NULL; - gs_free char * real_pac_path = NULL; - gs_free char * fast_provisioning = NULL; + gs_free char *anon_ident = NULL; + gs_free char *pac_file = NULL; + gs_free char *real_pac_path = NULL; + gs_free char *fast_provisioning = NULL; const char *const *iter; - const char * pac_prov_str; + const char *pac_prov_str; gboolean allow_unauth = FALSE, allow_auth = FALSE; pac_file = svGetValueStr_cp(ifcfg, "IEEE_8021X_PAC_FILE"); @@ -3852,12 +3852,12 @@ eap_fast_reader(const char * eap_method, typedef struct { const char *method; - gboolean (*reader)(const char * eap_method, - shvarFile * ifcfg, - shvarFile * keys_ifcfg, + gboolean (*reader)(const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys_ifcfg, NMSetting8021x *s_8021x, gboolean phase2, - GError ** error); + GError **error); gboolean wifi_phase2_only; } EAPReader; @@ -3875,14 +3875,14 @@ static EAPReader eap_readers[] = {{"md5", eap_simple_reader, TRUE}, {NULL, NULL}}; static void -read_8021x_list_value(shvarFile * ifcfg, - const char * ifcfg_var_name, +read_8021x_list_value(shvarFile *ifcfg, + const char *ifcfg_var_name, NMSetting8021x *setting, - const char * prop_name) + const char *prop_name) { - gs_free char * value = NULL; + gs_free char *value = NULL; gs_free const char **strv = NULL; - const char * v; + const char *v; g_return_if_fail(ifcfg != NULL); g_return_if_fail(ifcfg_var_name != NULL); @@ -3901,13 +3901,13 @@ static NMSetting8021x * fill_8021x(shvarFile *ifcfg, const char *file, const char *key_mgmt, gboolean wifi, GError **error) { nm_auto_shvar_file_close shvarFile *keys_ifcfg = NULL; - gs_unref_object NMSetting8021x *s_8021x = NULL; - gs_free char * value = NULL; - const char * v; - gs_free const char ** list = NULL; - const char *const * iter; - gint64 timeout; - int i_val; + gs_unref_object NMSetting8021x *s_8021x = NULL; + gs_free char *value = NULL; + const char *v; + gs_free const char **list = NULL; + const char *const *iter; + gint64 timeout; + int i_val; v = svGetValueStr(ifcfg, "IEEE_8021X_EAP_METHODS", &value); if (!v) { @@ -3928,7 +3928,7 @@ fill_8021x(shvarFile *ifcfg, const char *file, const char *key_mgmt, gboolean wi /* Validate and handle each EAP method */ for (iter = list; iter && *iter; iter++) { - EAPReader * eap = &eap_readers[0]; + EAPReader *eap = &eap_readers[0]; gboolean found = FALSE; gs_free char *lower = NULL; @@ -4040,16 +4040,16 @@ next: } static NMSetting * -make_wpa_setting(shvarFile * ifcfg, - const char * file, - GBytes * ssid, +make_wpa_setting(shvarFile *ifcfg, + const char *file, + GBytes *ssid, gboolean adhoc, NMSetting8021x **s_8021x, - GError ** error) + GError **error) { gs_unref_object NMSettingWirelessSecurity *wsec = NULL; - gs_free char * value = NULL; - const char * v; + gs_free char *value = NULL; + const char *v; gboolean wpa_psk = FALSE, wpa_sae = FALSE, wpa_owe = FALSE, wpa_eap = FALSE, ieee8021x = FALSE, wpa3_eap = FALSE; int i_val; @@ -4089,7 +4089,7 @@ make_wpa_setting(shvarFile * ifcfg, nm_setting_wireless_security_add_proto(wsec, "rsn"); } else { gs_free char *value2 = NULL; - const char * v2; + const char *v2; v2 = svGetValueStr(ifcfg, "WPA_ALLOW_WPA", &value2); if (v2 && svParseBoolean(v2, TRUE)) @@ -4175,8 +4175,8 @@ static NMSetting * make_leap_setting(shvarFile *ifcfg, const char *file, GError **error) { gs_unref_object NMSettingWirelessSecurity *wsec = NULL; - shvarFile * keys_ifcfg; - gs_free char * value = NULL; + shvarFile *keys_ifcfg; + gs_free char *value = NULL; NMSettingSecretFlags flags; wsec = NM_SETTING_WIRELESS_SECURITY(nm_setting_wireless_security_new()); @@ -4232,12 +4232,12 @@ make_leap_setting(shvarFile *ifcfg, const char *file, GError **error) } static NMSetting * -make_wireless_security_setting(shvarFile * ifcfg, - const char * file, - GBytes * ssid, +make_wireless_security_setting(shvarFile *ifcfg, + const char *file, + GBytes *ssid, gboolean adhoc, NMSetting8021x **s_8021x, - GError ** error) + GError **error) { NMSetting *wsec; @@ -4291,9 +4291,9 @@ transform_hwaddr_blacklist(const char *blacklist) static NMSetting * make_wireless_setting(shvarFile *ifcfg, GError **error) { - NMSettingWireless * s_wireless; - const char * cvalue; - char * value = NULL; + NMSettingWireless *s_wireless; + const char *cvalue; + char *value = NULL; gint64 chan = 0; NMSettingMacRandomization mac_randomization; NMSettingWirelessPowersave powersave = NM_SETTING_WIRELESS_POWERSAVE_DEFAULT; @@ -4360,7 +4360,7 @@ make_wireless_setting(shvarFile *ifcfg, GError **error) value = svGetValueStr_cp(ifcfg, "MODE"); if (value) { - char * lcase; + char *lcase; const char *mode = NULL; lcase = g_ascii_strdown(value, -1); @@ -4540,16 +4540,16 @@ error: static NMConnection * wireless_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) { - NMConnection * connection = NULL; - NMSetting * con_setting = NULL; - NMSetting * wireless_setting = NULL; + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *wireless_setting = NULL; NMSetting8021x *s_8021x = NULL; - GBytes * ssid; - NMSetting * security_setting = NULL; - gs_free char * ssid_utf8 = NULL; - const char * mode; + GBytes *ssid; + NMSetting *security_setting = NULL; + gs_free char *ssid_utf8 = NULL; + const char *mode; gboolean adhoc = FALSE; - GError * local = NULL; + GError *local = NULL; g_return_val_if_fail(file != NULL, NULL); g_return_val_if_fail(ifcfg != NULL, NULL); @@ -4619,12 +4619,12 @@ typedef struct { * pointing to the next unprocessed option or NULL * in case of failure */ static const char ** -_next_ethtool_options_nmternary(const char ** words, +_next_ethtool_options_nmternary(const char **words, NMEthtoolType ethtool_type, NMEthtoolIfcfgOption *out_value) { - const char * opt; - const char * opt_val; + const char *opt; + const char *opt_val; const NMEthtoolData *d = NULL; NMTernary onoff = NM_TERNARY_DEFAULT; @@ -4671,13 +4671,13 @@ _next_ethtool_options_nmternary(const char ** words, * pointing to the next unprocessed option or NULL * in case of failure */ static const char ** -_next_ethtool_options_uint32(const char ** words, +_next_ethtool_options_uint32(const char **words, NMEthtoolType ethtool_type, NMEthtoolIfcfgOption *out_value) { gint64 i64; - const char * opt; - const char * opt_val; + const char *opt; + const char *opt_val; const NMEthtoolData *d = NULL; nm_assert(out_value); @@ -4727,16 +4727,16 @@ static NM_UTILS_STRING_TABLE_LOOKUP_DEFINE( {"-K", NM_ETHTOOL_TYPE_FEATURE}, ); static void -parse_ethtool_option(const char * value, +parse_ethtool_option(const char *value, NMSettingWiredWakeOnLan *out_flags, - char ** out_password, - gboolean * out_autoneg, - guint32 * out_speed, - const char ** out_duplex, - NMSettingEthtool ** out_s_ethtool) + char **out_password, + gboolean *out_autoneg, + guint32 *out_speed, + const char **out_duplex, + NMSettingEthtool **out_s_ethtool) { guint i; - const char ** w_iter; + const char **w_iter; NMEthtoolIfcfgOption ifcfg_option; gs_free const char **words = NULL; NMEthtoolType ethtool_type = NM_ETHTOOL_TYPE_UNKNOWN; @@ -4904,7 +4904,7 @@ static GPtrArray * read_routing_rules_parse(shvarFile *ifcfg, gboolean routes_read) { gs_unref_ptrarray GPtrArray *arr = NULL; - gs_free const char ** keys = NULL; + gs_free const char **keys = NULL; guint i, len; keys = svGetKeysSorted(ifcfg, SV_KEY_TYPE_ROUTING_RULE4 | SV_KEY_TYPE_ROUTING_RULE6, &len); @@ -4919,12 +4919,12 @@ read_routing_rules_parse(shvarFile *ifcfg, gboolean routes_read) arr = g_ptr_array_new_full(len, (GDestroyNotify) nm_ip_routing_rule_unref); for (i = 0; i < len; i++) { - const char * key = keys[i]; - nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; - gs_free_error GError *local = NULL; - gs_free char * value_to_free = NULL; - const char * value; - gboolean key_is_ipv4; + const char *key = keys[i]; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; + gs_free_error GError *local = NULL; + gs_free char *value_to_free = NULL; + const char *value; + gboolean key_is_ipv4; key_is_ipv4 = (key[NM_STRLEN("ROUTING_RULE")] == '_'); nm_assert(key_is_ipv4 == NM_STR_HAS_PREFIX(key, "ROUTING_RULE_")); @@ -4956,7 +4956,7 @@ read_routing_rules_parse(shvarFile *ifcfg, gboolean routes_read) } static void -read_routing_rules(shvarFile * ifcfg, +read_routing_rules(shvarFile *ifcfg, gboolean routes_read, NMSettingIPConfig *s_ip4, NMSettingIPConfig *s_ip6) @@ -4980,17 +4980,17 @@ read_routing_rules(shvarFile * ifcfg, static void parse_ethtool_options(shvarFile *ifcfg, NMConnection *connection) { - NMSettingWired *s_wired; + NMSettingWired *s_wired; gs_unref_object NMSettingEthtool *s_ethtool = NULL; NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT; - gs_free char * ethtool_opts_free = NULL; - const char * ethtool_opts; - gs_free char * wol_password = NULL; - gs_free char * wol_value_free = NULL; - const char * tmp; + gs_free char *ethtool_opts_free = NULL; + const char *ethtool_opts; + gs_free char *wol_password = NULL; + gs_free char *wol_value_free = NULL; + const char *tmp; gboolean autoneg = FALSE; guint32 speed = 0; - const char * duplex = NULL; + const char *duplex = NULL; gboolean wired_found = FALSE; ethtool_opts = svGetValue(ifcfg, "ETHTOOL_OPTS", ðtool_opts_free); @@ -5001,7 +5001,7 @@ parse_ethtool_options(shvarFile *ifcfg, NMConnection *connection) wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; else { gs_free const char **opts = NULL; - const char *const * iter; + const char *const *iter; opts = nm_strsplit_set(ethtool_opts, ";"); for (iter = opts; iter && iter[0]; iter++) { @@ -5061,8 +5061,8 @@ static NMSetting * make_wired_setting(shvarFile *ifcfg, const char *file, NMSetting8021x **s_8021x, GError **error) { gs_unref_object NMSettingWired *s_wired = NULL; - const char * cvalue; - gs_free char * value = NULL; + const char *cvalue; + gs_free char *value = NULL; gboolean found = FALSE; NMTernary accept_all_mac_addresses; @@ -5246,11 +5246,11 @@ make_wired_setting(shvarFile *ifcfg, const char *file, NMSetting8021x **s_8021x, static NMConnection * wired_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) { - NMConnection * connection = NULL; - NMSetting * con_setting = NULL; - NMSetting * wired_setting = NULL; + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *wired_setting = NULL; NMSetting8021x *s_8021x = NULL; - GError * local = NULL; + GError *local = NULL; g_return_val_if_fail(file != NULL, NULL); g_return_val_if_fail(ifcfg != NULL, NULL); @@ -5288,8 +5288,8 @@ wired_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) static gboolean parse_infiniband_p_key(shvarFile *ifcfg, int *out_p_key, char **out_parent, GError **error) { - char * device = NULL, *physdev = NULL, *pkey_id = NULL; - char * ifname = NULL; + char *device = NULL, *physdev = NULL, *pkey_id = NULL; + char *ifname = NULL; int id; gboolean ret = FALSE; @@ -5347,7 +5347,7 @@ static NMSetting * make_infiniband_setting(shvarFile *ifcfg, const char *file, GError **error) { NMSettingInfiniband *s_infiniband; - char * value = NULL; + char *value = NULL; s_infiniband = NM_SETTING_INFINIBAND(nm_setting_infiniband_new()); @@ -5399,8 +5399,8 @@ static NMConnection * infiniband_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) { NMConnection *connection = NULL; - NMSetting * con_setting = NULL; - NMSetting * infiniband_setting = NULL; + NMSetting *con_setting = NULL; + NMSetting *infiniband_setting = NULL; g_return_val_if_fail(file != NULL, NULL); g_return_val_if_fail(ifcfg != NULL, NULL); @@ -5433,7 +5433,7 @@ static void handle_bond_option(NMSettingBond *s_bond, const char *key, const char *value) { gs_free char *sanitized = NULL; - const char * p = value; + const char *p = value; /* Remove any quotes or +/- from arp_ip_target */ if (nm_streq0(key, NM_SETTING_BOND_OPTION_ARP_IP_TARGET) && value && value[0]) { @@ -5463,8 +5463,8 @@ static NMSetting * make_bond_setting(shvarFile *ifcfg, const char *file, GError **error) { NMSettingBond *s_bond; - gs_free char * value = NULL; - const char * v; + gs_free char *value = NULL; + const char *v; v = svGetValueStr(ifcfg, "DEVICE", &value); if (!v) { @@ -5481,12 +5481,12 @@ make_bond_setting(shvarFile *ifcfg, const char *file, GError **error) v = svGetValueStr(ifcfg, "BONDING_OPTS", &value); if (v) { gs_free const char **items = NULL; - const char *const * iter; + const char *const *iter; items = nm_strsplit_set(v, " "); for (iter = items; iter && *iter; iter++) { gs_free char *key = NULL; - const char * val; + const char *val; val = strchr(*iter, '='); if (!val) @@ -5504,9 +5504,9 @@ make_bond_setting(shvarFile *ifcfg, const char *file, GError **error) static NMSetting * make_bond_port_setting(shvarFile *ifcfg) { - NMSetting * s_port = NULL; + NMSetting *s_port = NULL; gs_free char *value_to_free = NULL; - const char * value; + const char *value; guint queue_id; g_return_val_if_fail(ifcfg != NULL, FALSE); @@ -5529,12 +5529,12 @@ make_bond_port_setting(shvarFile *ifcfg) static NMConnection * bond_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) { - NMConnection * connection = NULL; - NMSetting * con_setting = NULL; - NMSetting * bond_setting = NULL; - NMSetting * wired_setting = NULL; + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *bond_setting = NULL; + NMSetting *wired_setting = NULL; NMSetting8021x *s_8021x = NULL; - GError * local = NULL; + GError *local = NULL; g_return_val_if_fail(file != NULL, NULL); g_return_val_if_fail(ifcfg != NULL, NULL); @@ -5580,7 +5580,7 @@ bond_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) static NMSetting * make_team_setting(shvarFile *ifcfg, const char *file, GError **error) { - NMSetting * s_team; + NMSetting *s_team; gs_free char *value_device = NULL; gs_free char *value = NULL; @@ -5600,12 +5600,12 @@ make_team_setting(shvarFile *ifcfg, const char *file, GError **error) static NMConnection * team_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) { - NMConnection * connection = NULL; - NMSetting * con_setting = NULL; - NMSetting * team_setting = NULL; - NMSetting * wired_setting = NULL; + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *team_setting = NULL; + NMSetting *wired_setting = NULL; NMSetting8021x *s_8021x = NULL; - GError * local = NULL; + GError *local = NULL; g_return_val_if_fail(file != NULL, NULL); g_return_val_if_fail(ifcfg != NULL, NULL); @@ -5655,22 +5655,22 @@ typedef enum { BRIDGE_OPT_TYPE_PORT_OPTION, } BridgeOptType; -typedef void (*BridgeOptFunc)(NMSetting * setting, +typedef void (*BridgeOptFunc)(NMSetting *setting, gboolean stp, - const char * key, - const char * value, + const char *key, + const char *value, BridgeOptType opt_type); static void -handle_bridge_option(NMSetting * setting, +handle_bridge_option(NMSetting *setting, gboolean stp, - const char * key, - const char * value, + const char *key, + const char *value, BridgeOptType opt_type) { static const struct { - const char * key; - const char * property_name; + const char *key; + const char *property_name; BridgeOptType opt_type; gboolean only_with_stp; gboolean extended_bool; @@ -5809,19 +5809,19 @@ warn: } static void -handle_bridging_opts(NMSetting * setting, +handle_bridging_opts(NMSetting *setting, gboolean stp, - const char * value, + const char *value, BridgeOptFunc func, BridgeOptType opt_type) { gs_free const char **items = NULL; - const char *const * iter; + const char *const *iter; items = nm_strsplit_set(value, " "); for (iter = items; iter && *iter; iter++) { gs_free char *key = NULL; - const char * val; + const char *val; val = strchr(*iter, '='); if (!val) @@ -5837,15 +5837,15 @@ static void read_bridge_vlans(shvarFile *ifcfg, const char *key, NMSetting *setting, const char *property) { gs_unref_ptrarray GPtrArray *array = NULL; - gs_free char * value_to_free = NULL; - const char * value; + gs_free char *value_to_free = NULL; + const char *value; value = svGetValueStr(ifcfg, key, &value_to_free); if (value) { gs_free const char **strv = NULL; - const char *const * iter; - GError * local = NULL; - NMBridgeVlan * vlan; + const char *const *iter; + GError *local = NULL; + NMBridgeVlan *vlan; array = g_ptr_array_new_with_free_func((GDestroyNotify) nm_bridge_vlan_unref); @@ -5871,8 +5871,8 @@ static NMSetting * make_bridge_setting(shvarFile *ifcfg, const char *file, GError **error) { gs_unref_object NMSettingBridge *s_bridge = NULL; - gs_free char * value_to_free = NULL; - const char * value; + gs_free char *value_to_free = NULL; + const char *value; gboolean stp = FALSE; gboolean stp_set = FALSE; @@ -5937,12 +5937,12 @@ make_bridge_setting(shvarFile *ifcfg, const char *file, GError **error) static NMConnection * bridge_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) { - NMConnection * connection = NULL; - NMSetting * con_setting = NULL; - NMSetting * bridge_setting = NULL; - NMSetting * wired_setting = NULL; + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *bridge_setting = NULL; + NMSetting *wired_setting = NULL; NMSetting8021x *s_8021x = NULL; - GError * local = NULL; + GError *local = NULL; g_return_val_if_fail(file != NULL, NULL); g_return_val_if_fail(ifcfg != NULL, NULL); @@ -5988,9 +5988,9 @@ bridge_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) static NMSetting * make_bridge_port_setting(shvarFile *ifcfg) { - NMSetting * s_port = NULL; + NMSetting *s_port = NULL; gs_free char *value_to_free = NULL; - const char * value; + const char *value; g_return_val_if_fail(ifcfg != NULL, FALSE); @@ -6020,7 +6020,7 @@ make_bridge_port_setting(shvarFile *ifcfg) static NMSetting * make_team_port_setting(shvarFile *ifcfg) { - NMSetting * s_port; + NMSetting *s_port; gs_free char *value = NULL; value = svGetValueStr_cp(ifcfg, "TEAM_PORT_CONFIG"); @@ -6071,10 +6071,10 @@ is_wifi_device(const char *name, shvarFile *parsed) static void parse_prio_map_list(NMSettingVlan *s_vlan, shvarFile *ifcfg, const char *key, NMVlanPriorityMap map) { - gs_free char * value = NULL; + gs_free char *value = NULL; gs_free const char **list = NULL; - const char *const * iter; - const char * v; + const char *const *iter; + const char *v; v = svGetValueStr(ifcfg, key, &value); if (!v) @@ -6093,10 +6093,10 @@ static NMSetting * make_vlan_setting(shvarFile *ifcfg, const char *file, GError **error) { gs_unref_object NMSettingVlan *s_vlan = NULL; - gs_free char * parent = NULL; - gs_free char * iface_name = NULL; - gs_free char * value = NULL; - const char * v = NULL; + gs_free char *parent = NULL; + gs_free char *iface_name = NULL; + gs_free char *value = NULL; + const char *v = NULL; int vlan_id = -1; guint32 vlan_flags = 0; int gvrp, reorder_hdr; @@ -6188,7 +6188,7 @@ make_vlan_setting(shvarFile *ifcfg, const char *file, GError **error) v = svGetValueStr(ifcfg, "VLAN_FLAGS", &value); if (v) { gs_free const char **strv = NULL; - const char *const * ptr; + const char *const *ptr; strv = nm_strsplit_set(v, ", "); for (ptr = strv; ptr && *ptr; ptr++) { @@ -6219,12 +6219,12 @@ make_vlan_setting(shvarFile *ifcfg, const char *file, GError **error) static NMConnection * vlan_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) { - NMConnection * connection = NULL; - NMSetting * con_setting = NULL; - NMSetting * wired_setting = NULL; - NMSetting * vlan_setting = NULL; + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *wired_setting = NULL; + NMSetting *vlan_setting = NULL; NMSetting8021x *s_8021x = NULL; - GError * local = NULL; + GError *local = NULL; g_return_val_if_fail(file != NULL, NULL); g_return_val_if_fail(ifcfg != NULL, NULL); @@ -6268,14 +6268,14 @@ vlan_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) static NMConnection * create_unhandled_connection(const char *filename, - shvarFile * ifcfg, + shvarFile *ifcfg, const char *type, - char ** out_spec) + char **out_spec) { NMConnection *connection; - NMSetting * s_con; + NMSetting *s_con; gs_free char *value = NULL; - const char * v; + const char *v; nm_assert(out_spec && !*out_spec); @@ -6329,12 +6329,12 @@ check_dns_search_domains(shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) if (!s_ip4 || nm_setting_ip_config_get_num_dns_searches(NM_SETTING_IP_CONFIG(s_ip4)) == 0) { /* DNS searches */ gs_free char *value = NULL; - const char * v; + const char *v; v = svGetValueStr(ifcfg, "DOMAIN", &value); if (v) { gs_free const char **searches = NULL; - const char *const * item; + const char *const *item; searches = nm_strsplit_set(v, " "); if (searches) { @@ -6351,23 +6351,23 @@ static NMConnection * connection_from_file_full(const char *filename, const char *network_file, /* for unit tests only */ const char *test_type, /* for unit tests only */ - char ** out_unhandled, - GError ** error, - gboolean * out_ignore_error) + char **out_unhandled, + GError **error, + gboolean *out_ignore_error) { nm_auto_shvar_file_close shvarFile *main_ifcfg = NULL; nm_auto_shvar_file_close shvarFile *network_ifcfg = NULL; - gs_unref_object NMConnection *connection = NULL; - gs_free char * type = NULL; - char * devtype, *bootproto; - NMSetting * setting; - NMSetting * s_ip4; - NMSetting * s_ip6; - const char * ifcfg_name = NULL; - gs_free char * s_tmp = NULL; - gboolean has_ip4_defroute = FALSE; - gboolean has_complex_routes_v4; - gboolean has_complex_routes_v6; + gs_unref_object NMConnection *connection = NULL; + gs_free char *type = NULL; + char *devtype, *bootproto; + NMSetting *setting; + NMSetting *s_ip4; + NMSetting *s_ip6; + const char *ifcfg_name = NULL; + gs_free char *s_tmp = NULL; + gboolean has_ip4_defroute = FALSE; + gboolean has_complex_routes_v4; + gboolean has_complex_routes_v6; g_return_val_if_fail(filename != NULL, NULL); g_return_val_if_fail(out_unhandled && !*out_unhandled, NULL); @@ -6463,7 +6463,7 @@ connection_from_file_full(const char *filename, if (!type) { gs_free char *tmp = NULL; - char * device; + char *device; if ((tmp = svGetValueStr_cp(main_ifcfg, "IPV6TUNNELIPV4"))) { NM_SET_OUT(out_ignore_error, TRUE); @@ -6503,7 +6503,7 @@ connection_from_file_full(const char *filename, type = g_strdup(TYPE_WIRELESS); else { gs_free char *p_path = NULL; - char * p_device; + char *p_device; gsize i; /* network-functions detects DEVICETYPE based on the ifcfg-* name and the existence @@ -6714,9 +6714,9 @@ connection_from_file_full(const char *filename, NMConnection * connection_from_file(const char *filename, - char ** out_unhandled, - GError ** error, - gboolean * out_ignore_error) + char **out_unhandled, + GError **error, + gboolean *out_ignore_error) { return connection_from_file_full(filename, NULL, NULL, out_unhandled, error, out_ignore_error); } @@ -6725,8 +6725,8 @@ NMConnection * nmtst_connection_from_file(const char *filename, const char *network_file, const char *test_type, - char ** out_unhandled, - GError ** error) + char **out_unhandled, + GError **error) { return connection_from_file_full(filename, network_file, test_type, out_unhandled, error, NULL); } diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h index c7dc2240af..c38432b7b7 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h @@ -9,14 +9,14 @@ #include "nm-connection.h" NMConnection *connection_from_file(const char *filename, - char ** out_unhandled, - GError ** error, - gboolean * out_ignore_error); + char **out_unhandled, + GError **error, + gboolean *out_ignore_error); NMConnection *nmtst_connection_from_file(const char *filename, const char *network_file, const char *test_type, - char ** out_unhandled, - GError ** error); + char **out_unhandled, + GError **error); #endif /* __NMS_IFCFG_RH_READER_H__ */ diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c index 3feb444026..16632861a3 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c @@ -103,9 +103,9 @@ _storage_new(NMSIfcfgRHPlugin *plugin, const char *uuid, const char *filename) } NMSIfcfgRHStorage * -nms_ifcfg_rh_storage_new_connection(NMSIfcfgRHPlugin * plugin, - const char * filename, - NMConnection * connection_take, +nms_ifcfg_rh_storage_new_connection(NMSIfcfgRHPlugin *plugin, + const char *filename, + NMConnection *connection_take, const struct timespec *mtime) { NMSIfcfgRHStorage *self; @@ -123,9 +123,9 @@ nms_ifcfg_rh_storage_new_connection(NMSIfcfgRHPlugin * plugin, NMSIfcfgRHStorage * nms_ifcfg_rh_storage_new_unhandled(NMSIfcfgRHPlugin *plugin, - const char * filename, - const char * unmanaged_spec, - const char * unrecognized_spec) + const char *filename, + const char *unmanaged_spec, + const char *unrecognized_spec) { NMSIfcfgRHStorage *self; @@ -167,7 +167,7 @@ nms_ifcfg_rh_storage_destroy(NMSIfcfgRHStorage *self) static void nms_ifcfg_rh_storage_class_init(NMSIfcfgRHStorageClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingsStorageClass *storage_class = NM_SETTINGS_STORAGE_CLASS(klass); object_class->dispose = dispose; diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.h b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.h index 6fb9838f92..2ab6beb66f 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.h +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.h @@ -45,14 +45,14 @@ GType nms_ifcfg_rh_storage_get_type(void); struct _NMSIfcfgRHPlugin; NMSIfcfgRHStorage *nms_ifcfg_rh_storage_new_connection(struct _NMSIfcfgRHPlugin *plugin, - const char * filename, - NMConnection * connection_take, - const struct timespec * mtime); + const char *filename, + NMConnection *connection_take, + const struct timespec *mtime); NMSIfcfgRHStorage *nms_ifcfg_rh_storage_new_unhandled(struct _NMSIfcfgRHPlugin *plugin, - const char * filename, - const char * unmanaged_spec, - const char * unrecognized_spec); + const char *filename, + const char *unmanaged_spec, + const char *unrecognized_spec); void nms_ifcfg_rh_storage_destroy(NMSIfcfgRHStorage *self); diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c index 1afdf8eeec..15e01ba99a 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c @@ -17,7 +17,7 @@ /*****************************************************************************/ gboolean -nms_ifcfg_rh_utils_parse_unhandled_spec(const char * unhandled_spec, +nms_ifcfg_rh_utils_parse_unhandled_spec(const char *unhandled_spec, const char **out_unmanaged_spec, const char **out_unrecognized_spec) { @@ -108,7 +108,7 @@ char * utils_cert_path(const char *parent, const char *suffix, const char *extension) { gs_free char *dir = NULL; - const char * name; + const char *name; g_return_val_if_fail(parent, NULL); g_return_val_if_fail(suffix, NULL); @@ -171,7 +171,7 @@ utils_get_ifcfg_name(const char *file, gboolean only_ifcfg) static char * utils_get_extra_path(const char *parent, const char *tag) { - char * item_path = NULL, *dirname; + char *item_path = NULL, *dirname; const char *name; g_return_val_if_fail(parent != NULL, NULL); @@ -221,7 +221,7 @@ shvarFile * utils_get_extra_ifcfg(const char *parent, const char *tag, gboolean should_create) { shvarFile *ifcfg = NULL; - char * path; + char *path; path = utils_get_extra_path(parent, tag); if (!path) @@ -275,7 +275,7 @@ utils_has_route_file_new_syntax_content(const char *contents, gsize len) while (TRUE) { const char *line = contents; - char * eol; + char *eol; gboolean found = FALSE; /* matches regex "^[[:space:]]*ADDRESS[0-9]+=" */ @@ -374,7 +374,7 @@ utils_detect_ifcfg_path(const char *path, gboolean only_ifcfg) return NULL; if (utils_is_ifcfg_alias_file(base, NULL)) { gs_free char *ifcfg = NULL; - char * ptr; + char *ptr; ifcfg = g_strdup(path); ptr = strrchr(ifcfg, ':'); @@ -773,7 +773,7 @@ gboolean nms_ifcfg_rh_utils_is_numbered_tag_impl(const char *key, const char *tag, gsize tag_len, - gint64 * out_idx) + gint64 *out_idx) { gint64 idx; diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h index 6b396a9adf..d7a1cfc6c1 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h @@ -29,7 +29,7 @@ typedef enum { } NMSIfcfgKeyTypeFlags; typedef struct { - const char * key_name; + const char *key_name; NMSIfcfgKeyTypeFlags key_flags; } NMSIfcfgKeyTypeInfo; @@ -50,7 +50,7 @@ nms_ifcfg_well_known_key_find_info_flags(const char *key) /*****************************************************************************/ -gboolean nms_ifcfg_rh_utils_parse_unhandled_spec(const char * unhandled_spec, +gboolean nms_ifcfg_rh_utils_parse_unhandled_spec(const char *unhandled_spec, const char **out_unmanaged_spec, const char **out_unrecognized_spec); @@ -127,7 +127,7 @@ _nms_ifcfg_rh_utils_numbered_tag(char *buf, gsize buf_len, const char *tag_name, gboolean nms_ifcfg_rh_utils_is_numbered_tag_impl(const char *key, const char *tag, gsize tag_len, - gint64 * out_idx); + gint64 *out_idx); static inline gboolean nms_ifcfg_rh_utils_is_numbered_tag(const char *key, const char *tag, gint64 *out_idx) @@ -158,7 +158,7 @@ nms_ifcfg_rh_utils_get_ethtool_name(NMEthtoolID ethtool_id) return _nm_ethtool_ifcfg_names[ethtool_id]; } -const NMEthtoolData *nms_ifcfg_rh_utils_get_ethtool_by_name(const char * name, +const NMEthtoolData *nms_ifcfg_rh_utils_get_ethtool_by_name(const char *name, NMEthtoolType ethtool_type); #endif /* _UTILS_H_ */ diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index 263c9253d8..b973816750 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -94,11 +94,11 @@ save_secret_flags(shvarFile *ifcfg, const char *key, NMSettingSecretFlags flags) } static void -set_secret(shvarFile * ifcfg, - GHashTable * secrets, - const char * key, - const char * value, - const char * flags_key, +set_secret(shvarFile *ifcfg, + GHashTable *secrets, + const char *key, + const char *value, + const char *flags_key, NMSettingSecretFlags flags) { /* Save secret flags */ @@ -114,14 +114,14 @@ set_secret(shvarFile * ifcfg, static gboolean write_secrets(shvarFile *ifcfg, GHashTable *secrets, GError **error) { - nm_auto_shvar_file_close shvarFile *keyfile = NULL; - gs_free NMUtilsNamedValue *secrets_arr_free = NULL; - NMUtilsNamedValue secrets_arr_static[30]; - const NMUtilsNamedValue * secrets_arr; - guint secrets_len; - GError * local = NULL; - gboolean any_secrets = FALSE; - guint i; + nm_auto_shvar_file_close shvarFile *keyfile = NULL; + gs_free NMUtilsNamedValue *secrets_arr_free = NULL; + NMUtilsNamedValue secrets_arr_static[30]; + const NMUtilsNamedValue *secrets_arr; + guint secrets_len; + GError *local = NULL; + gboolean any_secrets = FALSE; + guint i; keyfile = utils_get_keys_ifcfg(svFileGetName(ifcfg), TRUE); if (!keyfile) { @@ -164,7 +164,7 @@ write_secrets(shvarFile *ifcfg, GHashTable *secrets, GError **error) typedef struct { const NMSetting8021xSchemeVtable *vtable; - const char * ifcfg_rh_key; + const char *ifcfg_rh_key; } Setting8021xSchemeVtable; static const Setting8021xSchemeVtable setting_8021x_scheme_vtable[] = { @@ -184,23 +184,23 @@ static const Setting8021xSchemeVtable setting_8021x_scheme_vtable[] = { }; static gboolean -write_object(NMSetting8021x * s_8021x, - shvarFile * ifcfg, - GHashTable * secrets, - GHashTable * blobs, +write_object(NMSetting8021x *s_8021x, + shvarFile *ifcfg, + GHashTable *secrets, + GHashTable *blobs, const Setting8021xSchemeVtable *objtype, gboolean force_write, - GError ** error) + GError **error) { NMSetting8021xCKScheme scheme; - const char * value = NULL; - GBytes * blob = NULL; - const char * password = NULL; + const char *value = NULL; + GBytes *blob = NULL; + const char *password = NULL; NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; char secret_name[100]; char secret_flags[sizeof(secret_name) + NM_STRLEN("_FLAGS")]; - const char * extension; - char * standard_file; + const char *extension; + char *standard_file; g_return_val_if_fail(ifcfg != NULL, FALSE); g_return_val_if_fail(objtype != NULL, FALSE); @@ -277,8 +277,8 @@ static gboolean write_blobs(GHashTable *blobs, GError **error) { GHashTableIter iter; - const char * filename; - GBytes * blob; + const char *filename; + GBytes *blob; if (!blobs) return TRUE; @@ -318,14 +318,14 @@ write_blobs(GHashTable *blobs, GError **error) static gboolean write_8021x_certs(NMSetting8021x *s_8021x, - GHashTable * secrets, - GHashTable * blobs, + GHashTable *secrets, + GHashTable *blobs, gboolean phase2, - shvarFile * ifcfg, - GError ** error) + shvarFile *ifcfg, + GError **error) { const Setting8021xSchemeVtable *pk_otype = NULL; - gs_free char * value_to_free = NULL; + gs_free char *value_to_free = NULL; /* CA certificate */ if (!write_object( @@ -371,20 +371,20 @@ write_8021x_certs(NMSetting8021x *s_8021x, static gboolean write_8021x_setting(NMConnection *connection, - shvarFile * ifcfg, - GHashTable * secrets, - GHashTable * blobs, + shvarFile *ifcfg, + GHashTable *secrets, + GHashTable *blobs, gboolean wired, - GError ** error) + GError **error) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; NMSetting8021xAuthFlags auth_flags; - const char * value, *match; + const char *value, *match; gconstpointer ptr; - GBytes * bytes; - char * tmp = NULL; - GString * phase2_auth; - GString * str; + GBytes *bytes; + char *tmp = NULL; + GString *phase2_auth; + GString *str; guint32 i, num; gsize size; int vint; @@ -565,20 +565,20 @@ write_8021x_setting(NMConnection *connection, static gboolean write_wireless_security_setting(NMConnection *connection, - shvarFile * ifcfg, - GHashTable * secrets, + shvarFile *ifcfg, + GHashTable *secrets, gboolean adhoc, - gboolean * no_8021x, - GError ** error) + gboolean *no_8021x, + GError **error) { - NMSettingWirelessSecurity * s_wsec; - const char * key_mgmt, *auth_alg, *key, *proto, *cipher; - const char * psk = NULL; + NMSettingWirelessSecurity *s_wsec; + const char *key_mgmt, *auth_alg, *key, *proto, *cipher; + const char *psk = NULL; gboolean wep = FALSE, wpa = FALSE, dynamic_wep = FALSE; NMSettingWirelessSecurityWpsMethod wps_method; - char * tmp; + char *tmp; guint32 i, num; - GString * str; + GString *str; s_wsec = nm_connection_get_setting_wireless_security(connection); if (!s_wsec) { @@ -667,7 +667,7 @@ write_wireless_security_setting(NMConnection *connection, /* And write the new ones out */ if (wep) { NMWepKeyType key_type; - const char * key_type_str = NULL; + const char *key_type_str = NULL; /* Default WEP TX key index */ svSetValueInt64(ifcfg, @@ -809,17 +809,17 @@ write_wireless_security_setting(NMConnection *connection, static gboolean write_wireless_setting(NMConnection *connection, - shvarFile * ifcfg, - GHashTable * secrets, - gboolean * no_8021x, - GError ** error) + shvarFile *ifcfg, + GHashTable *secrets, + gboolean *no_8021x, + GError **error) { NMSettingWireless *s_wireless; - GBytes * ssid; - const guint8 * ssid_data; + GBytes *ssid; + const guint8 *ssid_data; gsize ssid_len; - const char * mode, *bssid; - const char * device_mac, *cloned_mac; + const char *mode, *bssid; + const char *device_mac, *cloned_mac; guint32 mtu, chan, i; gboolean adhoc = FALSE, hex_ssid = FALSE; const char *const *macaddr_blacklist; @@ -1018,7 +1018,7 @@ static gboolean write_infiniband_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) { NMSettingInfiniband *s_infiniband; - const char * mac, *transport_mode, *parent; + const char *mac, *transport_mode, *parent; guint32 mtu; int p_key; @@ -1223,14 +1223,14 @@ _ethtool_gstring_prepare(GString **str, gboolean *is_first, char cmdline_flag, c static gboolean write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) { - NMSettingWired * s_wired; - NMSettingEthtool * s_ethtool; - const char * duplex; + NMSettingWired *s_wired; + NMSettingEthtool *s_ethtool; + const char *duplex; guint32 speed; - GString * str = NULL; + GString *str = NULL; gboolean auto_negotiate; NMSettingWiredWakeOnLan wol; - const char * wol_password; + const char *wol_password; s_wired = nm_connection_get_setting_wired(connection); s_ethtool = NM_SETTING_ETHTOOL(nm_connection_get_setting(connection, NM_TYPE_SETTING_ETHTOOL)); @@ -1300,7 +1300,7 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error if (s_ethtool) { NMEthtoolID ethtool_id; NMSettingConnection *s_con; - const char * iface; + const char *iface; gboolean is_first; guint32 u32; gboolean b; @@ -1398,7 +1398,7 @@ static char * vlan_priority_maplist_to_stringlist(NMSettingVlan *s_vlan, NMVlanPriorityMap map) { char **strlist; - char * value; + char *value; if (map == NM_VLAN_INGRESS_MAP) g_object_get(G_OBJECT(s_vlan), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, &strlist, NULL); @@ -1420,7 +1420,7 @@ static gboolean write_vlan_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) { NMSettingVlan *s_vlan; - char * tmp; + char *tmp; guint32 vlan_flags = 0; gsize s_buf_len; char s_buf[50], *s_buf_ptr; @@ -1486,7 +1486,7 @@ write_bond_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired, num_opts = nm_setting_bond_get_num_options(s_bond); if (num_opts) { nm_auto_free_gstring GString *str = NULL; - const char * name, *value; + const char *name, *value; str = g_string_sized_new(64); for (i = 0; i < num_opts; i++) { @@ -1511,7 +1511,7 @@ static gboolean write_team_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) { NMSettingTeam *s_team; - const char * config; + const char *config; s_team = nm_connection_get_setting_team(connection); if (!s_team) { @@ -1562,14 +1562,14 @@ write_team_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired, }) static gboolean -write_bridge_vlans(NMSetting * setting, +write_bridge_vlans(NMSetting *setting, gboolean is_port, - shvarFile * ifcfg, + shvarFile *ifcfg, const char *key, - GError ** error) + GError **error) { - GPtrArray * vlans; - NMBridgeVlan * vlan; + GPtrArray *vlans; + NMBridgeVlan *vlan; nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(0, FALSE); guint i; @@ -1608,8 +1608,8 @@ write_bridge_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired guint64 u64; guint u; gboolean b; - const char * s; - GString * opts; + const char *s; + GString *opts; s_bridge = nm_connection_get_setting_bridge(connection); if (!s_bridge) { @@ -1847,7 +1847,7 @@ write_bridge_port_setting(NMConnection *connection, shvarFile *ifcfg, GError **e { NMSettingBridgePort *s_port; guint32 u32; - GString * string; + GString *string; s_port = nm_connection_get_setting_bridge_port(connection); if (!s_port) @@ -1903,7 +1903,7 @@ static gboolean write_team_port_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) { NMSettingTeamPort *s_port; - const char * config; + const char *config; s_port = nm_connection_get_setting_team_port(connection); if (!s_port) @@ -1946,9 +1946,9 @@ write_dcb_app(shvarFile *ifcfg, const char *tag, NMSettingDcbFlags flags, int pr typedef gboolean (*DcbGetBoolFunc)(NMSettingDcb *, guint); static void -write_dcb_bool_array(shvarFile * ifcfg, - const char * key, - NMSettingDcb * s_dcb, +write_dcb_bool_array(shvarFile *ifcfg, + const char *key, + NMSettingDcb *s_dcb, NMSettingDcbFlags flags, DcbGetBoolFunc get_func) { @@ -1967,9 +1967,9 @@ write_dcb_bool_array(shvarFile * ifcfg, typedef guint (*DcbGetUintFunc)(NMSettingDcb *, guint); static void -write_dcb_uint_array(shvarFile * ifcfg, - const char * key, - NMSettingDcb * s_dcb, +write_dcb_uint_array(shvarFile *ifcfg, + const char *key, + NMSettingDcb *s_dcb, NMSettingDcbFlags flags, DcbGetUintFunc get_func) { @@ -1993,9 +1993,9 @@ write_dcb_uint_array(shvarFile * ifcfg, } static void -write_dcb_percent_array(shvarFile * ifcfg, - const char * key, - NMSettingDcb * s_dcb, +write_dcb_percent_array(shvarFile *ifcfg, + const char *key, + NMSettingDcb *s_dcb, NMSettingDcbFlags flags, DcbGetUintFunc get_func) { @@ -2018,7 +2018,7 @@ write_dcb_percent_array(shvarFile * ifcfg, static gboolean write_dcb_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) { - NMSettingDcb * s_dcb; + NMSettingDcb *s_dcb; NMSettingDcbFlags flags; s_dcb = nm_connection_get_setting_dcb(connection); @@ -2079,16 +2079,16 @@ write_dcb_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) static void write_connection_setting(NMSettingConnection *s_con, shvarFile *ifcfg) { - guint32 n, i; + guint32 n, i; nm_auto_free_gstring GString *str = NULL; - const char * master, *master_iface = NULL, *type; + const char *master, *master_iface = NULL, *type; int vint; gint32 vint32; NMSettingConnectionMdns mdns; NMSettingConnectionLlmnr llmnr; NMSettingConnectionDnsOverTls dns_over_tls; guint32 vuint32; - const char * tmp, *mud_url; + const char *tmp, *mud_url; svSetValueStr(ifcfg, "NAME", nm_setting_connection_get_id(s_con)); svSetValueStr(ifcfg, "UUID", nm_setting_connection_get_uuid(s_con)); @@ -2284,8 +2284,8 @@ static char * get_route_attributes_string(NMIPRoute *route, int family) { gs_free const char **names = NULL; - GVariant * attr, *lock; - GString * str; + GVariant *attr, *lock; + GString *str; guint i, len; names = _nm_ip_route_get_attribute_names(route, TRUE, &len); @@ -2369,7 +2369,7 @@ write_route_file_svformat(const char *filename, NMSettingIPConfig *s_ip4) num = nm_setting_ip_config_get_num_routes(s_ip4); for (i = 0; i < num; i++) { char buf[INET_ADDRSTRLEN]; - NMIPRoute * route; + NMIPRoute *route; guint32 netmask; gint64 metric; char addr_key[64]; @@ -2409,7 +2409,7 @@ write_route_file_svformat(const char *filename, NMSettingIPConfig *s_ip4) static GString * write_route_file(NMSettingIPConfig *s_ip) { - GString * contents; + GString *contents; NMIPRoute *route; guint32 i, num; int addr_family; @@ -2424,7 +2424,7 @@ write_route_file(NMSettingIPConfig *s_ip) for (i = 0; i < num; i++) { gs_free char *options = NULL; - const char * next_hop; + const char *next_hop; gint64 metric; route = nm_setting_ip_config_get_route(s_ip, i); @@ -2454,9 +2454,9 @@ write_route_file(NMSettingIPConfig *s_ip) static gboolean write_proxy_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) { - NMSettingProxy * s_proxy; + NMSettingProxy *s_proxy; NMSettingProxyMethod method; - const char * pac_url, *pac_script; + const char *pac_url, *pac_script; s_proxy = nm_connection_get_setting_proxy(connection); if (!s_proxy) @@ -2489,7 +2489,7 @@ write_proxy_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) static gboolean write_user_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) { - NMSettingUser * s_user; + NMSettingUser *s_user; guint i, len; const char *const *keys; @@ -2521,9 +2521,9 @@ write_sriov_setting(NMConnection *connection, shvarFile *ifcfg) NMSettingSriov *s_sriov; guint i, num = 0; NMTernary b; - NMSriovVF * vf; + NMSriovVF *vf; char key[32]; - char * str; + char *str; s_sriov = NM_SETTING_SRIOV(nm_connection_get_setting(connection, NM_TYPE_SETTING_SRIOV)); if (!s_sriov) { @@ -2562,7 +2562,7 @@ write_tc_setting(NMConnection *connection, shvarFile *ifcfg) num_qdiscs = nm_setting_tc_config_get_num_qdiscs(s_tc); for (n = 1, i = 0; i < num_qdiscs; i++) { - NMTCQdisc * qdisc; + NMTCQdisc *qdisc; gs_free char *str = NULL; qdisc = nm_setting_tc_config_get_qdisc(s_tc, i); @@ -2574,7 +2574,7 @@ write_tc_setting(NMConnection *connection, shvarFile *ifcfg) num_filters = nm_setting_tc_config_get_num_tfilters(s_tc); for (n = 1, i = 0; i < num_filters; i++) { - NMTCTfilter * tfilter; + NMTCTfilter *tfilter; gs_free char *str = NULL; tfilter = nm_setting_tc_config_get_tfilter(s_tc, i); @@ -2592,9 +2592,9 @@ static void write_match_setting(NMConnection *connection, shvarFile *ifcfg) { nm_auto_free_gstring GString *str = NULL; - NMSettingMatch * s_match; + NMSettingMatch *s_match; guint i, num; - const char * name; + const char *name; s_match = (NMSettingMatch *) nm_connection_get_setting(connection, NM_TYPE_SETTING_MATCH); if (!s_match) @@ -2706,25 +2706,25 @@ write_dns_setting(shvarFile *ifcfg, NMConnection *connection, int addr_family) static void write_ip4_setting(NMConnection *connection, - shvarFile * ifcfg, - shvarFile ** out_route_content_svformat, - GString ** out_route_content) + shvarFile *ifcfg, + shvarFile **out_route_content_svformat, + GString **out_route_content) { - NMSettingIPConfig * s_ip4; - const char * value; - char * tmp; - char tag[64]; - int j; - guint i, num, n; - gint64 route_metric; - NMIPRouteTableSyncMode route_table; - int priority; - int timeout; + NMSettingIPConfig *s_ip4; + const char *value; + char *tmp; + char tag[64]; + int j; + guint i, num, n; + gint64 route_metric; + NMIPRouteTableSyncMode route_table; + int priority; + int timeout; nm_auto_free_gstring GString *str = NULL; - const char * method = NULL; + const char *method = NULL; gboolean has_netmask; NMDhcpHostnameFlags flags; - const char *const * strv; + const char *const *strv; NM_SET_OUT(out_route_content_svformat, NULL); NM_SET_OUT(out_route_content, NULL); @@ -2905,10 +2905,10 @@ static void write_ip4_aliases(NMConnection *connection, const char *base_ifcfg_path) { NMSettingIPConfig *s_ip4; - gs_free char * base_ifcfg_dir = NULL, *base_ifcfg_name = NULL; - const char * base_name; + gs_free char *base_ifcfg_dir = NULL, *base_ifcfg_name = NULL; + const char *base_name; int i, num, base_ifcfg_name_len, base_name_len; - GDir * dir; + GDir *dir; base_ifcfg_dir = g_path_get_dirname(base_ifcfg_path); base_ifcfg_name = g_path_get_basename(base_ifcfg_path); @@ -2946,11 +2946,11 @@ write_ip4_aliases(NMConnection *connection, const char *base_ifcfg_path) num = nm_setting_ip_config_get_num_addresses(s_ip4); for (i = 0; i < num; i++) { - GVariant * label_var; - const char * label, *p; - char * path; + GVariant *label_var; + const char *label, *p; + char *path; NMIPAddress *addr; - shvarFile * ifcfg; + shvarFile *ifcfg; addr = nm_setting_ip_config_get_address(s_ip4, i); @@ -2987,17 +2987,17 @@ write_ip4_aliases(NMConnection *connection, const char *base_ifcfg_path) static void write_ip6_setting(NMConnection *connection, shvarFile *ifcfg, GString **out_route6_content) { - NMSettingIPConfig * s_ip6; - const char * value; + NMSettingIPConfig *s_ip6; + const char *value; guint i, num; int priority; - NMIPAddress * addr; + NMIPAddress *addr; gint64 route_metric; NMIPRouteTableSyncMode route_table; - GString * ip_str1, *ip_str2, *ip_ptr; + GString *ip_str1, *ip_str2, *ip_ptr; NMSettingIP6ConfigAddrGenMode addr_gen_mode; NMDhcpHostnameFlags flags; - const char * hostname; + const char *hostname; int timeout; NM_SET_OUT(out_route6_content, NULL); @@ -3183,7 +3183,7 @@ write_ip_routing_rules(NMConnection *connection, shvarFile *ifcfg, gboolean rout num = nm_setting_ip_config_get_num_routing_rules(s_ip); for (i = 0; i < num; i++) { - NMIPRoutingRule * rule = nm_setting_ip_config_get_routing_rule(s_ip, i); + NMIPRoutingRule *rule = nm_setting_ip_config_get_routing_rule(s_ip, i); gs_free const char *s = NULL; char key[64]; @@ -3222,38 +3222,38 @@ escape_id(const char *id) } static gboolean -do_write_construct(NMConnection * connection, - const char * ifcfg_dir, - const char * filename, +do_write_construct(NMConnection *connection, + const char *ifcfg_dir, + const char *filename, NMSIfcfgRHWriterAllowFilenameCb allow_filename_cb, gpointer allow_filename_user_data, - shvarFile ** out_ifcfg, - GHashTable ** out_blobs, - GHashTable ** out_secrets, - gboolean * out_route_ignore, - shvarFile ** out_route_content_svformat, - GString ** out_route_content, - GString ** out_route6_content, - GError ** error) + shvarFile **out_ifcfg, + GHashTable **out_blobs, + GHashTable **out_secrets, + gboolean *out_route_ignore, + shvarFile **out_route_content_svformat, + GString **out_route_content, + GString **out_route6_content, + GError **error) { - NMSettingConnection * s_con; + NMSettingConnection *s_con; nm_auto_shvar_file_close shvarFile *ifcfg = NULL; - const char * ifcfg_name; - gs_free char * ifcfg_name_free = NULL; - gs_free char * route_path = NULL; - gs_free char * route6_path = NULL; - const char * type; - gs_unref_hashtable GHashTable *blobs = NULL; - gs_unref_hashtable GHashTable *secrets = NULL; - gboolean wired; - gboolean no_8021x; - gboolean route_path_is_svformat; - gboolean has_complex_routes_v4; - gboolean has_complex_routes_v6; - gboolean route_ignore; + const char *ifcfg_name; + gs_free char *ifcfg_name_free = NULL; + gs_free char *route_path = NULL; + gs_free char *route6_path = NULL; + const char *type; + gs_unref_hashtable GHashTable *blobs = NULL; + gs_unref_hashtable GHashTable *secrets = NULL; + gboolean wired; + gboolean no_8021x; + gboolean route_path_is_svformat; + gboolean has_complex_routes_v4; + gboolean has_complex_routes_v6; + gboolean route_ignore; nm_auto_shvar_file_close shvarFile *route_content_svformat = NULL; - nm_auto_free_gstring GString *route_content = NULL; - nm_auto_free_gstring GString *route6_content = NULL; + nm_auto_free_gstring GString *route_content = NULL; + nm_auto_free_gstring GString *route6_content = NULL; nm_assert(NM_IS_CONNECTION(connection)); nm_assert(_nm_connection_verify(connection, NULL) == NM_SETTING_VERIFY_SUCCESS); @@ -3478,14 +3478,14 @@ do_write_construct(NMConnection * connection, static gboolean do_write_to_disk(NMConnection *connection, - shvarFile * ifcfg, - GHashTable * blobs, - GHashTable * secrets, + shvarFile *ifcfg, + GHashTable *blobs, + GHashTable *secrets, gboolean route_ignore, - shvarFile * route_content_svformat, - GString * route_content, - GString * route6_content, - GError ** error) + shvarFile *route_content_svformat, + GString *route_content, + GString *route6_content, + GError **error) { /* From here on, we persist data to disk. Before, it was all in-memory * only. But we loaded the ifcfg files from disk, and managled our @@ -3549,23 +3549,23 @@ do_write_to_disk(NMConnection *connection, } gboolean -nms_ifcfg_rh_writer_write_connection(NMConnection * connection, - const char * ifcfg_dir, - const char * filename, +nms_ifcfg_rh_writer_write_connection(NMConnection *connection, + const char *ifcfg_dir, + const char *filename, NMSIfcfgRHWriterAllowFilenameCb allow_filename_cb, gpointer allow_filename_user_data, - char ** out_filename, - NMConnection ** out_reread, - gboolean * out_reread_same, - GError ** error) + char **out_filename, + NMConnection **out_reread, + gboolean *out_reread_same, + GError **error) { nm_auto_shvar_file_close shvarFile *ifcfg = NULL; - nm_auto_free_gstring GString *route_content = NULL; - gboolean route_ignore = FALSE; + nm_auto_free_gstring GString *route_content = NULL; + gboolean route_ignore = FALSE; nm_auto_shvar_file_close shvarFile *route_content_svformat = NULL; - nm_auto_free_gstring GString *route6_content = NULL; - gs_unref_hashtable GHashTable *secrets = NULL; - gs_unref_hashtable GHashTable *blobs = NULL; + nm_auto_free_gstring GString *route6_content = NULL; + gs_unref_hashtable GHashTable *secrets = NULL; + gs_unref_hashtable GHashTable *blobs = NULL; nm_assert(!out_reread || !*out_reread); @@ -3611,8 +3611,8 @@ nms_ifcfg_rh_writer_write_connection(NMConnection * connection, if (out_reread || out_reread_same) { gs_unref_object NMConnection *reread = NULL; gboolean reread_same = FALSE; - gs_free_error GError *local = NULL; - gs_free char * unhandled = NULL; + gs_free_error GError *local = NULL; + gs_free char *unhandled = NULL; reread = connection_from_file(svFileGetName(ifcfg), &unhandled, &local, NULL); nm_assert((NM_IS_CONNECTION(reread) && !local) || (!reread && local)); diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h index d0d8a4cd8f..9b5162f88a 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h @@ -13,14 +13,14 @@ typedef gboolean (*NMSIfcfgRHWriterAllowFilenameCb)(const char *check_filename, gboolean nms_ifcfg_rh_writer_can_write_connection(NMConnection *connection, GError **error); -gboolean nms_ifcfg_rh_writer_write_connection(NMConnection * connection, - const char * ifcfg_dir, - const char * filename, +gboolean nms_ifcfg_rh_writer_write_connection(NMConnection *connection, + const char *ifcfg_dir, + const char *filename, NMSIfcfgRHWriterAllowFilenameCb allow_filename_cb, gpointer allow_filename_user_data, - char ** out_filename, + char **out_filename, NMConnection **out_reread, - gboolean * out_reread_same, - GError ** error); + gboolean *out_reread_same, + GError **error); #endif /* __NMS_IFCFG_RH_WRITER_H__ */ diff --git a/src/core/settings/plugins/ifcfg-rh/shvar.c b/src/core/settings/plugins/ifcfg-rh/shvar.c index d82efb3cb9..2ca495588b 100644 --- a/src/core/settings/plugins/ifcfg-rh/shvar.c +++ b/src/core/settings/plugins/ifcfg-rh/shvar.c @@ -62,7 +62,7 @@ struct _shvarLine { typedef struct _shvarLine shvarLine; struct _shvarFile { - char * fileName; + char *fileName; CList lst_head; GHashTable *lst_idx; int fd; @@ -151,8 +151,8 @@ static char * _escape_ansic(const char *source) { const char *p; - char * dest; - char * q; + char *dest; + char *q; gsize n_alloc; nm_assert(source); @@ -705,7 +705,7 @@ out_error: shvarFile * svFile_new(const char *name, int fd, const char *content) { - shvarFile * s; + shvarFile *s; const char *p; const char *q; @@ -820,9 +820,9 @@ line_new_parse(const char *value, gsize len) static shvarLine * line_new_build(const char *key, const char *value) { - char * value_escaped = NULL; + char *value_escaped = NULL; shvarLine *line; - char * new_key; + char *new_key; value = svEscape(value, &value_escaped); @@ -841,7 +841,7 @@ line_new_build(const char *key, const char *value) static gboolean line_set(shvarLine *line, const char *value) { - char * value_escaped = NULL; + char *value_escaped = NULL; gboolean changed = FALSE; ASSERT_shvarLine(line); @@ -926,11 +926,11 @@ do_link: static shvarFile * svOpenFileInternal(const char *name, gboolean create, GError **error) { - gboolean closefd = FALSE; - int errsv = 0; - gs_free char *content = NULL; - gs_free_error GError *local = NULL; - nm_auto_close int fd = -1; + gboolean closefd = FALSE; + int errsv = 0; + gs_free char *content = NULL; + gs_free_error GError *local = NULL; + nm_auto_close int fd = -1; if (create) fd = open(name, O_RDWR | O_CLOEXEC); /* NOT O_CREAT */ @@ -1063,8 +1063,8 @@ svNumberedParseKey(const char *key) GHashTable * svGetKeys(shvarFile *s, SvKeyType match_key_type) { - GHashTable * keys = NULL; - CList * current; + GHashTable *keys = NULL; + CList *current; const shvarLine *line; nm_assert(s); @@ -1137,7 +1137,7 @@ static const char * _svGetValue(shvarFile *s, const char *key, char **to_free) { const shvarLine *line; - const char * v; + const char *v; nm_assert(s); nm_assert(_shell_is_name(key, -1)); @@ -1209,7 +1209,7 @@ svGetValueStr(shvarFile *s, const char *key, char **to_free) char * svGetValue_cp(shvarFile *s, const char *key) { - char * to_free; + char *to_free; const char *value; g_return_val_if_fail(s, NULL); @@ -1233,7 +1233,7 @@ svGetValue_cp(shvarFile *s, const char *key) char * svGetValueStr_cp(shvarFile *s, const char *key) { - char * to_free; + char *to_free; const char *value; g_return_val_if_fail(s, NULL); @@ -1260,7 +1260,7 @@ int svGetValueBoolean(shvarFile *s, const char *key, int fallback) { gs_free char *to_free = NULL; - const char * value; + const char *value; value = _svGetValue(s, key, &to_free); return svParseBoolean(value, fallback); @@ -1293,7 +1293,7 @@ svGetValueTernary(shvarFile *s, const char *key) gint64 svGetValueInt64(shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback) { - char * to_free; + char *to_free; const char *value; gint64 result; int errsv; @@ -1320,7 +1320,7 @@ gboolean svGetValueEnum(shvarFile *s, const char *key, GType gtype, int *out_value, GError **error) { gs_free char *to_free = NULL; - const char * svalue; + const char *svalue; gs_free char *err_token = NULL; int value; @@ -1618,7 +1618,7 @@ svWarnInvalid(shvarFile *s, const char *file_type, NMLogDomain log_domain) gboolean svWriteFile(shvarFile *s, int mode, GError **error) { - FILE * f; + FILE *f; int tmpfd; CList *current; int errsv; @@ -1672,8 +1672,8 @@ svWriteFile(shvarFile *s, int mode, GError **error) fseek(f, 0, SEEK_SET); c_list_for_each (current, &s->lst_head) { const shvarLine *line = c_list_entry(current, shvarLine, lst); - const char * str; - char * s_tmp; + const char *str; + char *s_tmp; gboolean valid_value; ASSERT_shvarLine(line); diff --git a/src/core/settings/plugins/ifcfg-rh/shvar.h b/src/core/settings/plugins/ifcfg-rh/shvar.h index cf91642fbc..4b838eea2e 100644 --- a/src/core/settings/plugins/ifcfg-rh/shvar.h +++ b/src/core/settings/plugins/ifcfg-rh/shvar.h @@ -43,10 +43,10 @@ const char *svFindFirstNumberedKey(shvarFile *s, const char *key_prefix); * be freed by the caller. */ const char *svGetValue(shvarFile *s, const char *key, char **to_free); -char * svGetValue_cp(shvarFile *s, const char *key); +char *svGetValue_cp(shvarFile *s, const char *key); const char *svGetValueStr(shvarFile *s, const char *key, char **to_free); -char * svGetValueStr_cp(shvarFile *s, const char *key); +char *svGetValueStr_cp(shvarFile *s, const char *key); int svParseBoolean(const char *value, int def); diff --git a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index b1cfdfec99..7960ea2a9c 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -61,8 +61,8 @@ #define _svOpenFile(testfile) \ ({ \ - shvarFile * _f; \ - GError * _error = NULL; \ + shvarFile *_f; \ + GError *_error = NULL; \ const char *_testfile = (testfile); \ \ g_assert(_testfile); \ @@ -74,9 +74,9 @@ #define _svGetValue_check(f, key, expected_value) \ G_STMT_START \ { \ - const char * _val; \ - gs_free char * _to_free = NULL; \ - gs_free char * _val_string = NULL; \ + const char *_val; \ + gs_free char *_to_free = NULL; \ + gs_free char *_val_string = NULL; \ shvarFile *const _f = (f); \ const char *const _key = (key); \ \ @@ -98,8 +98,8 @@ _assert_reread_same(NMConnection *connection, NMConnection *reread) static void _assert_reread_same_FIXME(NMConnection *connection, NMConnection *reread) { - gs_unref_object NMConnection *connection_normalized = NULL; - gs_unref_hashtable GHashTable *settings = NULL; + gs_unref_object NMConnection *connection_normalized = NULL; + gs_unref_hashtable GHashTable *settings = NULL; /* FIXME: these assertion failures should not happen as we expect * that re-reading a connection after write yields the same result. @@ -125,11 +125,11 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c { gs_free char *content_expectd = NULL; gs_free char *content_written = NULL; - GError * error = NULL; + GError *error = NULL; gsize len_expectd = 0; gsize len_written = 0; gboolean success; - const char * uuid = NULL; + const char *uuid = NULL; g_assert(NM_IS_CONNECTION(connection)); g_assert(filename); @@ -196,9 +196,9 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c if (rewrite > 0) { if (uuid) { gs_free char *search = g_strdup_printf("UUID=%s\n", uuid); - const char * s; + const char *s; gsize i; - GString * str; + GString *str; s = content_written; while (TRUE) { @@ -246,11 +246,11 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c gs_unref_object NMConnection *_connection = \ nmtst_connection_duplicate_and_normalize(connection); \ NMConnection **_out_reread = (out_reread); \ - gboolean * _out_reread_same = (out_reread_same); \ - const char * _ifcfg_dir = (ifcfg_dir); \ - const char * _filename = (filename); \ - const char * _expected = (expected); \ - GError * _error = NULL; \ + gboolean *_out_reread_same = (out_reread_same); \ + const char *_ifcfg_dir = (ifcfg_dir); \ + const char *_filename = (filename); \ + const char *_expected = (expected); \ + GError *_error = NULL; \ gboolean _success; \ \ g_assert(_ifcfg_dir &&_ifcfg_dir[0]); \ @@ -274,7 +274,7 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c G_STMT_START \ { \ gs_unref_object NMConnection *_reread = NULL; \ - NMConnection * _c = (connection); \ + NMConnection *_c = (connection); \ gboolean _reread_same = FALSE; \ \ _writer_update_connection_reread(_c, \ @@ -292,11 +292,11 @@ static NMConnection * _connection_from_file(const char *filename, const char *network_file, const char *test_type, - char ** out_unhandled) + char **out_unhandled) { NMConnection *connection; - GError * error = NULL; - char * unhandled_fallback = NULL; + GError *error = NULL; + char *unhandled_fallback = NULL; g_assert(!out_unhandled || !*out_unhandled); @@ -319,11 +319,11 @@ static void _connection_from_file_fail(const char *filename, const char *network_file, const char *test_type, - GError ** error) + GError **error) { NMConnection *connection; - GError * local = NULL; - char * unhandled = NULL; + GError *local = NULL; + char *unhandled = NULL; connection = nmtst_connection_from_file(filename, network_file, test_type, &unhandled, &local); @@ -334,16 +334,16 @@ _connection_from_file_fail(const char *filename, } static void -_writer_new_connection_reread(NMConnection * connection, - const char * ifcfg_dir, - char ** out_filename, - const char * expected, +_writer_new_connection_reread(NMConnection *connection, + const char *ifcfg_dir, + char **out_filename, + const char *expected, NMConnection **out_reread, - gboolean * out_reread_same) + gboolean *out_reread_same) { - gboolean success; - GError * error = NULL; - gs_free char * filename = NULL; + gboolean success; + GError *error = NULL; + gs_free char *filename = NULL; gs_unref_object NMConnection *con_verified = NULL; gs_unref_object NMConnection *reread_copy = NULL; NMConnection **reread = out_reread ?: ((nmtst_get_rand_uint32() % 2) ? &reread_copy : NULL); @@ -378,9 +378,9 @@ _writer_new_connection_reread(NMConnection * connection, static void _writer_new_connec_exp(NMConnection *connection, - const char * ifcfg_dir, - const char * expected, - char ** out_filename) + const char *ifcfg_dir, + const char *expected, + char **out_filename) { gs_unref_object NMConnection *reread = NULL; gboolean reread_same = FALSE; @@ -425,8 +425,8 @@ _writer_new_connection_fail(NMConnection *connection, const char *ifcfg_dir, GEr gs_unref_object NMConnection *connection_normalized = NULL; gs_unref_object NMConnection *reread = NULL; gboolean success; - GError * local = NULL; - char * filename = NULL; + GError *local = NULL; + char *filename = NULL; g_assert(NM_IS_CONNECTION(connection)); g_assert(ifcfg_dir); @@ -454,13 +454,13 @@ _writer_new_connection_fail(NMConnection *connection, const char *ifcfg_dir, GEr static void test_read_netmask_1(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; - gs_free char * content = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; - const char * FILENAME = TEST_IFCFG_DIR "/ifcfg-netmask-1"; + gs_free char *content = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMIPAddress *ip4_addr; + const char *FILENAME = TEST_IFCFG_DIR "/ifcfg-netmask-1"; connection = _connection_from_file(FILENAME, NULL, TYPE_ETHERNET, NULL); @@ -492,14 +492,14 @@ test_read_netmask_1(void) static gboolean verify_cert_or_key(NMSetting8021x *s_compare, - const char * file, - const char * privkey_password, - const char * property) + const char *file, + const char *privkey_password, + const char *property) { gs_unref_object NMSetting8021x *s_8021x = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success = FALSE; - const char * expected = NULL, *setting = NULL; + const char *expected = NULL, *setting = NULL; gboolean phase2 = FALSE; NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_UNKNOWN; @@ -617,11 +617,11 @@ static void test_read_basic(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - const char * mac; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; connection = @@ -662,10 +662,10 @@ static void test_read_miscellaneous_variables(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * expected_mac_blacklist[3] = {"00:16:41:11:22:88", + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + char *expected_mac_blacklist[3] = {"00:16:41:11:22:88", "00:16:41:11:22:99", "6a:5d:5a:fa:dd:f0"}; int mac_blacklist_num, i; @@ -705,10 +705,10 @@ static void test_read_variables_corner_cases(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - const char * mac; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; NMTST_EXPECT_NM_WARN("*key NAME is badly quoted and is treated as \"\"*"); @@ -745,8 +745,8 @@ static void test_read_unmanaged(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - gs_free char * unhandled_spec = NULL; + NMSettingConnection *s_con; + gs_free char *unhandled_spec = NULL; guint64 expected_timestamp = 0; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-nm-controlled", @@ -765,8 +765,8 @@ static void test_read_unmanaged_unrecognized(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - gs_free char * unhandled_spec = NULL; + NMSettingConnection *s_con; + gs_free char *unhandled_spec = NULL; guint64 expected_timestamp = 0; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-nm-controlled-unrecognized", @@ -784,8 +784,8 @@ static void test_read_unrecognized(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - gs_free char * unhandled_spec = NULL; + NMSettingConnection *s_con; + gs_free char *unhandled_spec = NULL; guint64 expected_timestamp = 0; NMTST_EXPECT_NM_WARN("*key NAME is badly quoted and is treated as \"\"*"); @@ -805,16 +805,16 @@ static void test_read_wired_static(gconstpointer test_data) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - const char * mac; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + char *unmanaged = NULL; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xee}; NMIPAddress *ip4_addr; NMIPAddress *ip6_addr; - const char * file, *expected_id; + const char *file, *expected_id; gpointer expect_ip6_p; nmtst_test_data_unpack(test_data, &file, &expected_id, &expect_ip6_p); @@ -895,13 +895,13 @@ test_read_wired_static(gconstpointer test_data) static void test_read_wired_static_no_prefix(gconstpointer user_data) { - guint32 expected_prefix = GPOINTER_TO_UINT(user_data); - gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; - gs_free char * file = NULL; - gs_free char * expected_id = NULL; + guint32 expected_prefix = GPOINTER_TO_UINT(user_data); + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMIPAddress *ip4_addr; + gs_free char *file = NULL; + gs_free char *expected_id = NULL; file = g_strdup_printf(TEST_IFCFG_DIR "/ifcfg-test-wired-static-no-prefix-%u", expected_prefix); expected_id = g_strdup_printf("System test-wired-static-no-prefix-%u", expected_prefix); @@ -931,11 +931,11 @@ static void test_read_wired_dhcp(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + char *unmanaged = NULL; char expected_mac_address[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xee}; const char *mac; @@ -983,10 +983,10 @@ static void test_read_wired_dhcp_plus_ip(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip4_addr; - NMIPAddress * ip6_addr; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip4_addr; + NMIPAddress *ip6_addr; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-dhcp-plus-ip", NULL, @@ -1048,8 +1048,8 @@ static void test_read_wired_shared_plus_ip(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; + NMSettingIPConfig *s_ip4; + NMIPAddress *ip4_addr; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-shared-plus-ip", NULL, @@ -1077,10 +1077,10 @@ static void test_read_wired_global_gateway(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; - char * unmanaged = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMIPAddress *ip4_addr; + char *unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-global-gateway", TEST_IFCFG_DIR "/network-test-wired-global-gateway", @@ -1113,9 +1113,9 @@ static void test_read_wired_global_gateway_ignore(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + char *unmanaged = NULL; NMTST_EXPECT_NM_WARN("*ignoring GATEWAY (/etc/sysconfig/network) for * because the connection " "has no static addresses"); @@ -1147,8 +1147,8 @@ static void test_read_wired_obsolete_gateway_n(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; + NMSettingIPConfig *s_ip4; + NMIPAddress *ip4_addr; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-obsolete-gateway-n", NULL, @@ -1174,10 +1174,10 @@ test_read_wired_obsolete_gateway_n(void) static void test_user_1(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingUser * s_user; + NMSettingUser *s_user; connection = nmtst_create_minimal_connection("Test User 1", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); @@ -1187,7 +1187,7 @@ test_user_1(void) #define _USER_SET_DATA(s_user, key, val) \ G_STMT_START \ { \ - GError * _error = NULL; \ + GError *_error = NULL; \ gboolean _success; \ \ _success = nm_setting_user_set_data((s_user), (key), (val), &_error); \ @@ -1232,8 +1232,8 @@ static void test_read_wired_never_default(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-never-default", TEST_IFCFG_DIR "/network-test-wired-never-default", @@ -1256,10 +1256,10 @@ static void test_read_wired_defroute_no(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + char *unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-defroute-no", NULL, @@ -1285,10 +1285,10 @@ static void test_read_wired_defroute_no_gatewaydev_yes(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + char *unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-defroute-no-gatewaydev-yes", @@ -1316,9 +1316,9 @@ static void test_read_wired_static_routes(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMIPRoute * ip4_route; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMIPRoute *ip4_route; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-static-routes", NULL, @@ -1391,10 +1391,10 @@ static void test_read_wired_static_routes_legacy(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; - NMIPRoute * ip4_route; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + char *unmanaged = NULL; + NMIPRoute *ip4_route; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-static-routes-legacy", NULL, @@ -1466,11 +1466,11 @@ static void test_read_wired_ipv4_manual(gconstpointer data) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; - NMIPAddress * ip4_addr; - const char * file, *expected_id; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + char *unmanaged = NULL; + NMIPAddress *ip4_addr; + const char *file, *expected_id; nmtst_test_data_unpack(data, &file, &expected_id); @@ -1516,12 +1516,12 @@ static void test_read_wired_ipv6_manual(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - NMIPAddress * ip6_addr; - NMIPRoute * ip6_route; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + char *unmanaged = NULL; + NMIPAddress *ip6_addr; + NMIPRoute *ip6_route; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-ipv6-manual", NULL, @@ -1621,13 +1621,13 @@ static void test_read_wired_ipv6_only(gconstpointer test_data) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - NMIPAddress * ip6_addr; - const char * method; - const char * file, *expected_id; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + char *unmanaged = NULL; + NMIPAddress *ip6_addr; + const char *method; + const char *file, *expected_id; nmtst_test_data_unpack(test_data, &file, &expected_id); @@ -1675,11 +1675,11 @@ static void test_read_wired_dhcp6_only(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - const char * method; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + char *unmanaged = NULL; + const char *method; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-dhcp6-only", NULL, @@ -1705,9 +1705,9 @@ static void test_read_wired_autoip(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + char *unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-autoip", NULL, @@ -1730,8 +1730,8 @@ static void test_read_onboot_no(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - char * unmanaged = NULL; + NMSettingConnection *s_con; + char *unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-onboot-no", NULL, @@ -1748,8 +1748,8 @@ static void test_read_noip(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-noip", NULL, TYPE_ETHERNET, NULL); @@ -1772,15 +1772,15 @@ test_read_noip(void) static void test_read_wired_8021x_peap_mschapv2(void) { - gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSetting8021x * s_8021x; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig *s_ip4; + NMSetting8021x *s_8021x; gs_unref_object NMSetting8021x *tmp_8021x = NULL; - char * unmanaged = NULL; - GError * error = NULL; + char *unmanaged = NULL; + GError *error = NULL; gboolean success = FALSE; - const char * expected_ca_cert_path; - const char * read_ca_cert_path; + const char *expected_ca_cert_path; + const char *read_ca_cert_path; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-8021x-peap-mschapv2", NULL, @@ -1827,11 +1827,11 @@ static void test_read_wired_8021x_tls_secret_flags(gconstpointer test_data) { gs_unref_object NMConnection *connection = NULL; - NMSetting8021x * s_8021x; - gs_free char * dirname = NULL; - gs_free char * tmp1 = NULL; - gs_free char * tmp2 = NULL; - const char * ifcfg; + NMSetting8021x *s_8021x; + gs_free char *dirname = NULL; + gs_free char *tmp1 = NULL; + gs_free char *tmp2 = NULL; + const char *ifcfg; gpointer expected_flags_p; nmtst_test_data_unpack(test_data, &ifcfg, &expected_flags_p); @@ -1861,10 +1861,10 @@ test_read_wired_8021x_tls_secret_flags(gconstpointer test_data) static void test_read_write_802_1X_subj_matches(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-802-1X-subj-matches", NULL, @@ -1926,7 +1926,7 @@ static void test_read_802_1x_ttls_eapgtc(void) { gs_unref_object NMConnection *connection = NULL; - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; /* Test that EAP-* inner methods are correctly read into the * NMSetting8021x::autheap property. @@ -1952,8 +1952,8 @@ static void test_read_802_1x_tls_p12_no_client_cert(void) { gs_unref_object NMConnection *connection = NULL; - NMSetting8021x * s_8021x; - const char * path; + NMSetting8021x *s_8021x; + const char *path; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-8021x-tls-p12-no-client-cert", @@ -1978,12 +1978,12 @@ test_read_802_1x_tls_p12_no_client_cert(void) static void test_read_write_802_1x_password_raw(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSetting8021x * s_8021x; - GBytes * bytes; + NMSetting8021x *s_8021x; + GBytes *bytes; gconstpointer data; gsize size; @@ -2019,18 +2019,18 @@ test_read_write_802_1x_password_raw(void) static void test_read_wired_aliases_good(gconstpointer test_data) { - const int N = GPOINTER_TO_INT(test_data); + const int N = GPOINTER_TO_INT(test_data); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; int expected_num_addresses; - const char * expected_address_0[] = {"192.168.1.5", + const char *expected_address_0[] = {"192.168.1.5", "192.168.1.6", "192.168.1.9", "192.168.1.99", NULL}; - const char * expected_address_3[] = {"192.168.1.5", "192.168.1.6", NULL}; - const char * expected_label_0[] = { + const char *expected_address_3[] = {"192.168.1.5", "192.168.1.6", NULL}; + const char *expected_label_0[] = { NULL, "aliasem0:1", "aliasem0:2", @@ -2070,8 +2070,8 @@ test_read_wired_aliases_good(gconstpointer test_data) /* Addresses */ for (i = 0; i < expected_num_addresses; i++) { NMIPAddress *ip4_addr; - const char * addr; - GVariant * label; + const char *addr; + GVariant *label; ip4_addr = nm_setting_ip_config_get_address(s_ip4, i); g_assert(ip4_addr != NULL); @@ -2108,9 +2108,9 @@ static void test_read_wired_aliases_bad(const char *base, const char *expected_id) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMIPAddress *ip4_addr; g_assert(expected_id); @@ -2156,12 +2156,12 @@ static void test_read_dns_options(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - const char * option; - const char * options4[] = {"ndots:3", "single-request-reopen"}; - const char * options6[] = {"inet6"}; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + char *unmanaged = NULL; + const char *option; + const char *options4[] = {"ndots:3", "single-request-reopen"}; + const char *options6[] = {"inet6"}; guint32 num; guint32 i; @@ -2195,12 +2195,12 @@ test_read_dns_options(void) static void test_clear_master(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - gs_free char * keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - char * unmanaged = NULL; - shvarFile * f; + NMSettingConnection *s_con; + char *unmanaged = NULL; + shvarFile *f; /* 1. load the bridge slave connection from disk */ connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bridge-component", @@ -2250,18 +2250,18 @@ test_clear_master(void) static void test_write_dns_options(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - static const char * mac = "31:33:33:37:be:cd"; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; - NMIPAddress * addr; - NMIPAddress * addr6; - GError * error = NULL; + NMIPAddress *addr; + NMIPAddress *addr6; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -2328,12 +2328,12 @@ static void test_read_wifi_open(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * mac; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + GBytes *ssid; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; const char *expected_ssid = "blahblah"; @@ -2385,8 +2385,8 @@ static void test_read_wifi_open_auto(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-open-auto", NULL, @@ -2406,10 +2406,10 @@ static void test_read_wifi_open_ssid_hex(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - GBytes * ssid; - const char * expected_ssid = "blahblah"; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + GBytes *ssid; + const char *expected_ssid = "blahblah"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-open-ssid-hex", NULL, @@ -2435,10 +2435,10 @@ static void test_read_wifi_open_ssid_hex_bad(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - GBytes * ssid; - const char * expected_ssid = "0x626cxx"; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + GBytes *ssid; + const char *expected_ssid = "0x626cxx"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-open-ssid-bad-hex", NULL, @@ -2470,10 +2470,10 @@ static void test_read_wifi_open_ssid_quoted(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - GBytes * ssid; - const char * expected_ssid = "foo\"bar\\"; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + GBytes *ssid; + const char *expected_ssid = "foo\"bar\\"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-open-ssid-quoted", NULL, @@ -2499,14 +2499,14 @@ static void test_read_wifi_wep(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - GBytes * ssid; - const char * mac; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + GBytes *ssid; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; - const char * expected_ssid = "blahblah"; + const char *expected_ssid = "blahblah"; NMWepKeyType key_type; connection = @@ -2566,12 +2566,12 @@ static void test_read_wifi_wep_adhoc(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - GBytes * ssid; - const char * expected_ssid = "blahblah"; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + GBytes *ssid; + const char *expected_ssid = "blahblah"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-adhoc", NULL, @@ -2631,7 +2631,7 @@ static void test_read_wifi_wep_passphrase(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWirelessSecurity * s_wsec; + NMSettingWirelessSecurity *s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-passphrase", NULL, @@ -2658,7 +2658,7 @@ static void test_read_wifi_wep_40_ascii(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWirelessSecurity * s_wsec; + NMSettingWirelessSecurity *s_wsec; NMWepKeyType key_type; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-40-ascii", @@ -2687,7 +2687,7 @@ static void test_read_wifi_wep_104_ascii(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWirelessSecurity * s_wsec; + NMSettingWirelessSecurity *s_wsec; NMWepKeyType key_type; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-104-ascii", @@ -2716,8 +2716,8 @@ static void test_read_wifi_leap(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWirelessSecurity * s_wsec; + NMSettingConnection *s_con; + NMSettingWirelessSecurity *s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-leap", NULL, TYPE_WIRELESS, NULL); @@ -2738,8 +2738,8 @@ static void test_read_wifi_leap_secret_flags(gconstpointer test_data) { gs_unref_object NMConnection *connection = NULL; - NMSettingWirelessSecurity * s_wsec; - const char * file; + NMSettingWirelessSecurity *s_wsec; + const char *file; gpointer expected_flags_p; nmtst_test_data_unpack(test_data, &file, &expected_flags_p); @@ -2773,12 +2773,12 @@ static void test_read_wifi_wpa_psk(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - GBytes * ssid; - const char * mac; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + GBytes *ssid; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; const char *expected_ssid = "blahblah"; guint32 n, i; @@ -2887,11 +2887,11 @@ static void test_read_wifi_sae(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - GBytes * ssid; - const char * expected_ssid = "blahblah"; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + GBytes *ssid; + const char *expected_ssid = "blahblah"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-sae", NULL, TYPE_WIRELESS, NULL); @@ -2926,11 +2926,11 @@ static void test_read_wifi_owe(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - GBytes * ssid; - const char * expected_ssid = "blahblah_owe"; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + GBytes *ssid; + const char *expected_ssid = "blahblah_owe"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-owe", NULL, TYPE_WIRELESS, NULL); @@ -2965,8 +2965,8 @@ static void test_read_wifi_wpa_psk_2(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWirelessSecurity * s_wsec; + NMSettingConnection *s_con; + NMSettingWirelessSecurity *s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk-2", NULL, @@ -2988,8 +2988,8 @@ static void test_read_wifi_wpa_psk_unquoted(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWirelessSecurity * s_wsec; + NMSettingConnection *s_con; + NMSettingWirelessSecurity *s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk-unquoted", NULL, @@ -3022,10 +3022,10 @@ static void test_read_wifi_wpa_psk_adhoc(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk-adhoc", NULL, @@ -3064,12 +3064,12 @@ static void test_read_wifi_wpa_psk_hex(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - GBytes * ssid; - const char * expected_ssid = "blahblah"; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + GBytes *ssid; + const char *expected_ssid = "blahblah"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk-hex", NULL, @@ -3105,10 +3105,10 @@ static void test_read_wifi_wpa_eap_tls(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSetting8021x * s_8021x; - char * unmanaged = NULL; - const char * expected_privkey_password = "test1"; + NMSettingIPConfig *s_ip4; + NMSetting8021x *s_8021x; + char *unmanaged = NULL; + const char *expected_privkey_password = "test1"; NMTST_EXPECT_NM_WARN("*key ONBOOT is duplicated and the early occurrence ignored*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-eap-tls", @@ -3158,10 +3158,10 @@ static void test_read_wifi_wpa_eap_ttls_tls(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSetting8021x * s_8021x; - char * unmanaged = NULL; - const char * expected_privkey_password = "test1"; + NMSettingIPConfig *s_ip4; + NMSetting8021x *s_8021x; + char *unmanaged = NULL; + const char *expected_privkey_password = "test1"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-eap-ttls-tls", NULL, @@ -3216,7 +3216,7 @@ static void test_read_wifi_wpa_eap_suite_b_192_tls(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWirelessSecurity * s_wsec; + NMSettingWirelessSecurity *s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-eap-suite-b-192-tls", NULL, @@ -3233,8 +3233,8 @@ static void test_read_wifi_dynamic_wep_leap(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWirelessSecurity * s_wsec; - NMSetting8021x * s_8021x; + NMSettingWirelessSecurity *s_wsec; + NMSetting8021x *s_8021x; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-dynamic-wep-leap", NULL, @@ -3272,10 +3272,10 @@ static void test_read_wifi_wep_eap_ttls_chap(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSetting8021x * s_8021x; - char * unmanaged = NULL; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSetting8021x *s_8021x; + char *unmanaged = NULL; NMTST_EXPECT_NM_WARN("*key ONBOOT is duplicated and the early occurrence ignored*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-eap-ttls-chap", @@ -3314,8 +3314,8 @@ static void test_read_wired_wake_on_lan(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; + NMSettingConnection *s_con; + NMSettingWired *s_wired; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-wake-on-lan", NULL, @@ -3340,8 +3340,8 @@ static void test_read_wired_auto_negotiate_off(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; + NMSettingConnection *s_con; + NMSettingWired *s_wired; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-wake-on-lan", NULL, @@ -3364,8 +3364,8 @@ static void test_read_wired_auto_negotiate_on(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; + NMSettingConnection *s_con; + NMSettingWired *s_wired; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-auto-negotiate-on", NULL, @@ -3388,8 +3388,8 @@ static void test_read_wired_unknown_ethtool_opt(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; + NMSettingConnection *s_con; + NMSettingWired *s_wired; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-unknown-ethtool-opt", NULL, @@ -3418,8 +3418,8 @@ static void test_roundtrip_ethtool(void) { gs_unref_object NMConnection *connection = NULL; - NMSetting * s_ethtool; - NMSetting * s_wired; + NMSetting *s_ethtool; + NMSetting *s_wired; connection = nmtst_create_minimal_connection("test_roundtrip_ethtool", NULL, @@ -3488,8 +3488,8 @@ static void test_read_wifi_hidden(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-hidden", NULL, TYPE_WIRELESS, NULL); @@ -3506,13 +3506,13 @@ test_read_wifi_hidden(void) static void test_write_wifi_hidden(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - shvarFile * f; - gs_unref_bytes GBytes *ssid = + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + shvarFile *f; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_arr(0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44); connection = nm_simple_connection_new(); @@ -3550,9 +3550,9 @@ static void test_read_wifi_mac_random(gconstpointer user_data) { gs_unref_object NMConnection *connection = NULL; - gs_free char * path = NULL; - NMSettingWireless * s_wifi; - const char * name; + gs_free char *path = NULL; + NMSettingWireless *s_wifi; + const char *name; gpointer value_p; NMSettingMacRandomization value; @@ -3569,16 +3569,16 @@ test_read_wifi_mac_random(gconstpointer user_data) static void test_write_wifi_mac_random(gconstpointer user_data) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - gs_free char * val = NULL; - shvarFile * f; - gs_unref_bytes GBytes *ssid = + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + gs_free char *val = NULL; + shvarFile *f; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_arr(0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44); - const char * name, *write_expected; + const char *name, *write_expected; gpointer value_p; NMSettingMacRandomization value; char cexpected[NM_STRLEN(TEST_IFCFG_DIR) + 100]; @@ -3632,13 +3632,13 @@ test_write_wifi_mac_random(gconstpointer user_data) static void test_write_wired_wake_on_lan(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - gs_free char * val = NULL; - shvarFile * f; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + gs_free char *val = NULL; + shvarFile *f; connection = nm_simple_connection_new(); @@ -3684,12 +3684,12 @@ test_write_wired_wake_on_lan(void) static void test_write_wired_auto_negotiate_off(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingWired * s_wired; - gs_free char * val = NULL; - shvarFile * f; + NMSettingWired *s_wired; + gs_free char *val = NULL; + shvarFile *f; connection = nmtst_create_minimal_connection("Test Write Wired Auto-Negotiate", NULL, @@ -3726,13 +3726,13 @@ test_write_wired_auto_negotiate_off(void) static void test_write_wired_auto_negotiate_on(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingWired * s_wired; - NMSettingEthtool * s_ethtool; - gs_free char * val = NULL; - shvarFile * f; + NMSettingWired *s_wired; + NMSettingEthtool *s_ethtool; + gs_free char *val = NULL; + shvarFile *f; connection = nmtst_create_minimal_connection("Test Write Wired Auto-Negotiate", NULL, @@ -3780,8 +3780,8 @@ static void test_read_wifi_band_a(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-band-a", NULL, TYPE_WIRELESS, NULL); @@ -3798,13 +3798,13 @@ test_read_wifi_band_a(void) static void test_write_wifi_band_a(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - shvarFile * f; - gs_unref_bytes GBytes *ssid = + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + shvarFile *f; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_arr(0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44); connection = nm_simple_connection_new(); @@ -3848,12 +3848,12 @@ test_write_wifi_band_a(void) static void test_write_wifi_ap_mode(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("MySSID"); + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("MySSID"); connection = nm_simple_connection_new(); @@ -3921,11 +3921,11 @@ static void test_read_wired_qeth_static(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; - const char *const * subchannels; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + char *unmanaged = NULL; + const char *const *subchannels; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-qeth-static", NULL, @@ -3964,10 +3964,10 @@ static void test_read_wired_ctc_static(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - char * unmanaged = NULL; - const char *const * subchannels; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + char *unmanaged = NULL; + const char *const *subchannels; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-ctc-static", NULL, @@ -3998,8 +3998,8 @@ static void test_read_wifi_wep_no_keys(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWirelessSecurity * s_wsec; + NMSettingConnection *s_con; + NMSettingWirelessSecurity *s_wsec; NMWepKeyType key_type; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-no-keys", @@ -4039,10 +4039,10 @@ static void test_read_permissions(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; gboolean success; guint32 num; - const char * tmp; + const char *tmp; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-permissions", NULL, TYPE_ETHERNET, NULL); @@ -4073,7 +4073,7 @@ static void test_read_wifi_wep_agent_keys(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWirelessSecurity * s_wsec; + NMSettingWirelessSecurity *s_wsec; NMWepKeyType key_type; NMSettingSecretFlags flags; @@ -4106,18 +4106,18 @@ test_read_wifi_wep_agent_keys(void) static void test_write_wired_static(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *route6file = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *route6file = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4, *reread_s_ip4; - NMSettingIPConfig * s_ip6, *reread_s_ip6; - NMIPAddress * addr; - NMIPAddress * addr6; - NMIPRoute * route6; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4, *reread_s_ip4; + NMSettingIPConfig *s_ip6, *reread_s_ip6; + NMIPAddress *addr; + NMIPAddress *addr6; + NMIPRoute *route6; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -4249,18 +4249,18 @@ test_write_wired_static(void) static void test_write_wired_static_with_generic(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *route6file = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *route6file = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4, *reread_s_ip4; - NMSettingIPConfig * s_ip6, *reread_s_ip6; - NMIPAddress * addr; - NMIPAddress * addr6; - NMIPRoute * route6; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4, *reread_s_ip4; + NMSettingIPConfig *s_ip6, *reread_s_ip6; + NMIPAddress *addr; + NMIPAddress *addr6; + NMIPRoute *route6; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -4411,12 +4411,12 @@ test_write_wired_static_with_generic(void) static void test_write_wired_dhcp(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = nm_simple_connection_new(); @@ -4477,8 +4477,8 @@ static NMIPRoutingRule * _ip_routing_rule_new(int addr_family, const char *str) { NMIPRoutingRuleAsStringFlags flags = NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE; - gs_free_error GError *local = NULL; - NMIPRoutingRule * rule; + gs_free_error GError *local = NULL; + NMIPRoutingRule *rule; if (addr_family != AF_UNSPEC) { if (addr_family == AF_INET) @@ -4512,12 +4512,12 @@ _ip_routing_rule_add_to_setting(NMSettingIPConfig *s_ip, const char *str) static void test_write_routing_rules(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = nm_simple_connection_new(); @@ -4560,13 +4560,13 @@ test_write_routing_rules(void) static void test_write_wired_match(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingMatch * s_match; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingMatch *s_match; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = nm_simple_connection_new(); @@ -4615,7 +4615,7 @@ test_write_wired_match(void) static void test_write_wired_dhcp_plus_ip(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; @@ -4634,12 +4634,12 @@ test_write_wired_dhcp_plus_ip(void) static void test_read_write_wired_dhcp_send_hostname(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - const char * dhcp_hostname = "kamil-patka"; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + const char *dhcp_hostname = "kamil-patka"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-dhcp-send-hostname", NULL, @@ -4676,7 +4676,7 @@ static void test_read_wired_dhcpv6_hostname_fallback(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip6; + NMSettingIPConfig *s_ip6; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-dhcpv6-hostname-fallback", NULL, @@ -4691,15 +4691,15 @@ test_read_wired_dhcpv6_hostname_fallback(void) static void test_write_wired_static_ip6_only(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * addr6; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *addr6; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -4745,12 +4745,12 @@ test_write_wired_static_ip6_only(void) static void test_write_ip6_disabled(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = nmtst_create_minimal_connection("Test Write Wired Disabled IP6", NULL, @@ -4792,19 +4792,19 @@ test_write_ip6_disabled(void) static void test_write_wired_static_ip6_only_gw(gconstpointer user_data) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * addr6; - GError * error = NULL; - gs_free char * id = NULL; - gs_free char * written_ifcfg_gateway = NULL; - const char * gateway6 = user_data; - shvarFile * ifcfg; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *addr6; + GError *error = NULL; + gs_free char *id = NULL; + gs_free char *written_ifcfg_gateway = NULL; + const char *gateway6 = user_data; + shvarFile *ifcfg; connection = nm_simple_connection_new(); @@ -4877,14 +4877,14 @@ test_write_wired_static_ip6_only_gw(gconstpointer user_data) static void test_read_write_static_routes_legacy(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *routefile = NULL; - gs_free char * route6file = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *routefile = NULL; + gs_free char *route6file = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - const char * tmp; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + const char *tmp; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-static-routes-legacy", NULL, @@ -4927,17 +4927,17 @@ test_read_write_static_routes_legacy(void) static void test_write_wired_static_routes(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *routefile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *routefile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * addr; - NMIPRoute * route; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *addr; + NMIPRoute *route; + GError *error = NULL; gboolean reread_same = FALSE; connection = nm_simple_connection_new(); @@ -5041,16 +5041,16 @@ test_write_wired_static_routes(void) static void test_write_wired_dhcp_8021x_peap_mschapv2(void) { - nmtst_auto_unlinkfile char *keyfile = NULL; - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSetting8021x * s_8021x; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSetting8021x *s_8021x; gboolean success; - GError * error = NULL; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -5119,21 +5119,21 @@ test_write_wired_dhcp_8021x_peap_mschapv2(void) static void test_write_wired_8021x_tls(gconstpointer test_data) { - nmtst_auto_unlinkfile char *testfile = NULL; - gs_free char * keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSetting8021x * s_8021x; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSetting8021x *s_8021x; gboolean success; - GError * error = NULL; + GError *error = NULL; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - const char * pw; - gs_free char * tmp1 = NULL; - gs_free char * tmp2 = NULL; - gs_free char * tmp3 = NULL; + const char *pw; + gs_free char *tmp1 = NULL; + gs_free char *tmp2 = NULL; + gs_free char *tmp3 = NULL; gpointer scheme_p, flags_p; NMSetting8021xCKScheme scheme; NMSettingSecretFlags flags; @@ -5277,17 +5277,17 @@ test_write_wired_8021x_tls(gconstpointer test_data) static void test_write_wired_aliases(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; int num_addresses = 4; - const char * ip[] = {"1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4"}; - const char * label[] = {NULL, "alias0:2", NULL, "alias0:3"}; - NMIPAddress * addr; - GError * error = NULL; - shvarFile * ifcfg; + const char *ip[] = {"1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4"}; + const char *label[] = {NULL, "alias0:2", NULL, "alias0:3"}; + NMIPAddress *addr; + GError *error = NULL; + shvarFile *ifcfg; int i, j; nmtst_file_unlink_if_exists(TEST_SCRATCH_ALIAS_BASE ":2"); @@ -5404,14 +5404,14 @@ test_write_wired_aliases(void) static void test_write_gateway(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - GError * error = NULL; - shvarFile * f; - NMIPAddress * addr; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + GError *error = NULL; + shvarFile *f; + NMIPAddress *addr; connection = nm_simple_connection_new(); @@ -5471,14 +5471,14 @@ test_write_gateway(void) static void test_write_wifi_open(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_arr(0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44); shvarFile *ifcfg; @@ -5543,14 +5543,14 @@ test_write_wifi_open(void) static void test_write_wifi_open_hex_ssid(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_arr(0x11, + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_arr(0x11, 0x22, 0x33, 0x44, @@ -5609,17 +5609,17 @@ test_write_wifi_open_hex_ssid(void) static void test_write_wifi_wep(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); - struct stat statbuf; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + struct stat statbuf; connection = nm_simple_connection_new(); @@ -5687,19 +5687,19 @@ test_write_wifi_wep(void) static void test_write_wifi_wep_adhoc(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - GError * error = NULL; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); - struct stat statbuf; - NMIPAddress * addr; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + GError *error = NULL; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + struct stat statbuf; + NMIPAddress *addr; connection = nm_simple_connection_new(); @@ -5763,17 +5763,17 @@ test_write_wifi_wep_adhoc(void) static void test_write_wifi_wep_passphrase(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); - struct stat statbuf; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + struct stat statbuf; connection = nm_simple_connection_new(); @@ -5838,17 +5838,17 @@ test_write_wifi_wep_passphrase(void) static void test_write_wifi_wep_40_ascii(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah40"); - struct stat statbuf; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah40"); + struct stat statbuf; connection = nm_simple_connection_new(); @@ -5916,17 +5916,17 @@ test_write_wifi_wep_40_ascii(void) static void test_write_wifi_wep_104_ascii(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah104"); - struct stat statbuf; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah104"); + struct stat statbuf; connection = nm_simple_connection_new(); @@ -5997,17 +5997,17 @@ test_write_wifi_wep_104_ascii(void) static void test_write_wifi_leap(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); - struct stat statbuf; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + struct stat statbuf; connection = nm_simple_connection_new(); @@ -6074,17 +6074,17 @@ test_write_wifi_leap(void) static void test_write_wifi_leap_secret_flags(gconstpointer data) { - nmtst_auto_unlinkfile char *testfile = NULL; - gs_free char * keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); - NMSettingSecretFlags flags = GPOINTER_TO_UINT(data); + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + NMSettingSecretFlags flags = GPOINTER_TO_UINT(data); connection = nm_simple_connection_new(); g_assert(connection); @@ -6152,16 +6152,16 @@ test_write_wifi_leap_secret_flags(gconstpointer data) static void test_write_wifi_wpa_psk(gconstpointer test_data) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); struct { const char *name, *psk; gpointer wep_group_p, wpa_p, wpa2_p; @@ -6248,18 +6248,18 @@ test_write_wifi_wpa_psk(gconstpointer test_data) static void test_write_wifi_wpa_psk_adhoc(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - GError * error = NULL; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); - NMIPAddress * addr; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + GError *error = NULL; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + NMIPAddress *addr; connection = nm_simple_connection_new(); @@ -6337,19 +6337,19 @@ test_write_wifi_wpa_psk_adhoc(void) static void test_write_wifi_wpa_eap_tls(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSetting8021x * s_8021x; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSetting8021x *s_8021x; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; gboolean success; - GError * error = NULL; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + GError *error = NULL; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); connection = nm_simple_connection_new(); @@ -6441,19 +6441,19 @@ test_write_wifi_wpa_eap_tls(void) static void test_write_wifi_wpa_eap_ttls_tls(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSetting8021x * s_8021x; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSetting8021x *s_8021x; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; gboolean success; - GError * error = NULL; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + GError *error = NULL; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); connection = nm_simple_connection_new(); @@ -6553,19 +6553,19 @@ test_write_wifi_wpa_eap_ttls_tls(void) static void test_write_wifi_wpa_eap_ttls_mschapv2(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSetting8021x * s_8021x; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSetting8021x *s_8021x; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; gboolean success; - GError * error = NULL; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + GError *error = NULL; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); connection = nm_simple_connection_new(); @@ -6643,17 +6643,17 @@ test_write_wifi_wpa_eap_ttls_mschapv2(void) static void test_write_wifi_wpa_then_open(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - gs_free char * keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread1 = NULL; gs_unref_object NMConnection *reread2 = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); /* Test that writing out a WPA config then changing that to an open * config doesn't leave various WPA-related keys lying around in the ifcfg. @@ -6739,18 +6739,18 @@ test_write_wifi_wpa_then_open(void) static void test_write_wifi_wpa_then_wep_with_perms(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread1 = NULL; gs_unref_object NMConnection *reread2 = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; gboolean success; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("SomeSSID"); + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("SomeSSID"); /* Test that writing out a WPA config then changing that to a WEP * config works and doesn't cause infinite loop or other issues. @@ -6848,18 +6848,18 @@ test_write_wifi_wpa_then_wep_with_perms(void) static void test_write_wifi_dynamic_wep_leap(void) { - nmtst_auto_unlinkfile char *testfile = NULL; - nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSetting8021x * s_8021x; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); - shvarFile * ifcfg; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSetting8021x *s_8021x; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + shvarFile *ifcfg; connection = nm_simple_connection_new(); @@ -6927,13 +6927,13 @@ test_write_wifi_dynamic_wep_leap(void) static void test_write_wired_qeth_dhcp(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = nm_simple_connection_new(); @@ -6985,14 +6985,14 @@ test_write_wired_qeth_dhcp(void) static void test_write_wired_ctc_dhcp(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - shvarFile * ifcfg; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + shvarFile *ifcfg; connection = nm_simple_connection_new(); @@ -7048,12 +7048,12 @@ test_write_wired_ctc_dhcp(void) static void test_write_permissions(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = nm_simple_connection_new(); @@ -7101,15 +7101,15 @@ test_write_permissions(void) static void test_write_wifi_wep_agent_keys(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("foobarbaz"); + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("foobarbaz"); connection = nm_simple_connection_new(); g_assert(connection != NULL); @@ -7177,9 +7177,9 @@ static void test_write_wired_pppoe(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingPppoe * s_pppoe; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingPppoe *s_pppoe; connection = nm_simple_connection_new(); @@ -7221,9 +7221,9 @@ static void test_write_vpn(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingVpn * s_vpn; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingVpn *s_vpn; connection = nm_simple_connection_new(); @@ -7262,10 +7262,10 @@ static void test_write_mobile_broadband(gconstpointer data) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingCdma * s_cdma; - NMSettingSerial * s_serial; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingCdma *s_cdma; + NMSettingSerial *s_serial; gboolean gsm = GPOINTER_TO_UINT(data); connection = nm_simple_connection_new(); @@ -7315,9 +7315,9 @@ static void test_read_bridge_main(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingBridge * s_bridge; - NMSettingWired * s_wired; - const char * mac; + NMSettingBridge *s_bridge; + NMSettingWired *s_wired; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; connection = @@ -7346,18 +7346,18 @@ test_read_bridge_main(void) static void test_write_bridge_main(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingBridge * s_bridge; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * addr; - static const char * mac = "31:33:33:37:be:cd"; - GError * error = NULL; - gs_unref_ptrarray GPtrArray *vlans = NULL; - NMBridgeVlan * vlan; + NMSettingConnection *s_con; + NMSettingBridge *s_bridge; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *addr; + static const char *mac = "31:33:33:37:be:cd"; + GError *error = NULL; + gs_unref_ptrarray GPtrArray *vlans = NULL; + NMBridgeVlan *vlan; connection = nm_simple_connection_new(); g_assert(connection); @@ -7437,8 +7437,8 @@ static void test_read_bridge_component(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingBridgePort * s_port; + NMSettingConnection *s_con; + NMSettingBridgePort *s_port; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bridge-component", NULL, @@ -7460,16 +7460,16 @@ test_read_bridge_component(void) static void test_write_bridge_component(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSetting * s_port; - static const char * mac = "31:33:33:37:be:cd"; - guint32 mtu = 1492; - gs_unref_ptrarray GPtrArray *vlans = NULL; - NMBridgeVlan * vlan; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSetting *s_port; + static const char *mac = "31:33:33:37:be:cd"; + guint32 mtu = 1492; + gs_unref_ptrarray GPtrArray *vlans = NULL; + NMBridgeVlan *vlan; connection = nm_simple_connection_new(); g_assert(connection); @@ -7531,7 +7531,7 @@ static void test_read_bridge_missing_stp(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingBridge * s_bridge; + NMSettingBridge *s_bridge; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bridge-missing-stp", NULL, @@ -7550,7 +7550,7 @@ static void test_read_vlan_interface(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; guint32 from = 0; guint32 to = 0; @@ -7599,7 +7599,7 @@ static void test_read_vlan_only_vlan_id(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = _connection_from_file(TEST_IFCFG_VLAN_ONLY_VLANID, NULL, TYPE_ETHERNET, NULL); @@ -7615,10 +7615,10 @@ test_read_vlan_only_vlan_id(void) static void test_read_vlan_vlanid_use(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-vlanid-use", NULL, @@ -7647,7 +7647,7 @@ static void test_read_vlan_only_device(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-only-device", NULL, @@ -7666,7 +7666,7 @@ static void test_read_vlan_physdev(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-physdev", NULL, TYPE_ETHERNET, NULL); @@ -7683,7 +7683,7 @@ static void test_read_vlan_reorder_hdr_1(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; NMTST_EXPECT_NM_WARN("*REORDER_HDR key is deprecated, use VLAN_FLAGS*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-reorder-hdr-1", @@ -7706,7 +7706,7 @@ static void test_read_vlan_reorder_hdr_2(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-reorder-hdr-2", NULL, @@ -7727,7 +7727,7 @@ static void test_read_vlan_flags_1(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-flags-1", NULL, TYPE_ETHERNET, NULL); @@ -7747,7 +7747,7 @@ static void test_read_vlan_flags_2(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-flags-2", NULL, TYPE_ETHERNET, NULL); @@ -7766,7 +7766,7 @@ test_read_vlan_flags_2(void) static void test_write_vlan(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; connection = _connection_from_file(TEST_IFCFG_VLAN_INTERFACE, NULL, TYPE_VLAN, NULL); @@ -7780,7 +7780,7 @@ test_write_vlan(void) static void test_write_vlan_flags(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; @@ -7797,7 +7797,7 @@ test_write_vlan_flags(void) static void test_write_vlan_only_vlanid(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; @@ -7813,11 +7813,11 @@ test_write_vlan_only_vlanid(void) static void test_write_vlan_reorder_hdr(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingVlan * s_vlan; + NMSettingConnection *s_con; + NMSettingVlan *s_vlan; connection = nm_simple_connection_new(); @@ -7858,11 +7858,11 @@ test_write_vlan_reorder_hdr(void) static void test_write_ethernet_missing_ipv6(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; connection = nm_simple_connection_new(); g_assert(connection); @@ -7921,7 +7921,7 @@ static void test_read_bond_main(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingBond * s_bond; + NMSettingBond *s_bond; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-main", NULL, TYPE_ETHERNET, NULL); @@ -7939,7 +7939,7 @@ static void test_read_bond_eth_type(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingBond * s_bond; + NMSettingBond *s_bond; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-eth-type", NULL, @@ -7961,15 +7961,15 @@ test_read_bond_eth_type(void) static void test_write_bond_main(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingBond * s_bond; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * addr; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingBond *s_bond; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *addr; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -8030,7 +8030,7 @@ static void test_read_bond_slave(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-slave", NULL, TYPE_ETHERNET, NULL); @@ -8046,12 +8046,12 @@ test_read_bond_slave(void) static void test_write_bond_slave(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - static const char * mac = "31:33:33:37:be:cd"; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; connection = nm_simple_connection_new(); @@ -8088,8 +8088,8 @@ static void test_read_bond_port(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con = NULL; - NMSettingBondPort * s_port = NULL; + NMSettingConnection *s_con = NULL; + NMSettingBondPort *s_port = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-port", NULL, TYPE_ETHERNET, NULL); @@ -8105,11 +8105,11 @@ test_read_bond_port(void) static void test_write_bond_port(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingBondPort * s_bond_port; + NMSettingConnection *s_con; + NMSettingBondPort *s_bond_port; connection = nm_simple_connection_new(); @@ -8147,9 +8147,9 @@ static void test_read_infiniband(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingInfiniband * s_infiniband; - char * unmanaged = NULL; - const char * mac; + NMSettingInfiniband *s_infiniband; + char *unmanaged = NULL; + const char *mac; char expected_mac_address[INFINIBAND_ALEN] = {0x80, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22}; @@ -8175,17 +8175,17 @@ test_read_infiniband(void) static void test_write_infiniband(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingInfiniband * s_infiniband; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - const char * mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; + NMSettingConnection *s_con; + NMSettingInfiniband *s_infiniband; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; guint32 mtu = 65520; NMIPAddress *addr; - GError * error = NULL; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -8242,7 +8242,7 @@ static void test_read_bond_slave_ib(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-slave-ib", NULL, NULL, NULL); @@ -8256,11 +8256,11 @@ test_read_bond_slave_ib(void) static void test_write_bond_slave_ib(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingInfiniband * s_infiniband; + NMSettingConnection *s_con; + NMSettingInfiniband *s_infiniband; static const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; connection = nm_simple_connection_new(); @@ -8304,8 +8304,8 @@ static void test_read_bond_opts_mode_numeric(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingBond * s_bond; + NMSettingConnection *s_con; + NMSettingBond *s_bond; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-mode-numeric", NULL, @@ -8332,7 +8332,7 @@ static void test_read_dcb_basic(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingDcb * s_dcb; + NMSettingDcb *s_dcb; guint i; guint expected_group_ids[8] = {0, 0, 0, 0, 1, 1, 1, 0xF}; guint expected_group_bandwidths[8] = {25, 0, 0, 75, 0, 0, 0, 0}; @@ -8394,13 +8394,13 @@ test_read_dcb_basic(void) static void test_write_dcb_basic(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingDcb * s_dcb; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingDcb *s_dcb; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; guint i; const guint group_ids[8] = {4, 0xF, 6, 0xF, 1, 7, 3, 0xF}; const guint group_bandwidths[8] = {10, 20, 15, 10, 2, 3, 35, 5}; @@ -8476,7 +8476,7 @@ static void test_read_dcb_default_app_priorities(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingDcb * s_dcb; + NMSettingDcb *s_dcb; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-dcb-default-app-priorities", NULL, @@ -8611,9 +8611,9 @@ static void test_read_fcoe_mode(gconstpointer user_data) { gs_unref_object NMConnection *connection = NULL; - gs_free char * file = NULL; - const char * expected_mode = user_data; - NMSettingDcb * s_dcb; + gs_free char *file = NULL; + const char *expected_mode = user_data; + NMSettingDcb *s_dcb; file = g_strdup_printf(TEST_IFCFG_DIR "/ifcfg-test-fcoe-%s", expected_mode); connection = _connection_from_file(file, NULL, TYPE_ETHERNET, NULL); @@ -8627,15 +8627,15 @@ test_read_fcoe_mode(gconstpointer user_data) static void test_write_fcoe_mode(gconstpointer user_data) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - const char * expected_mode = user_data; - NMSettingConnection * s_con; - NMSettingDcb * s_dcb; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - shvarFile * ifcfg; + const char *expected_mode = user_data; + NMSettingConnection *s_con; + NMSettingDcb *s_dcb; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + shvarFile *ifcfg; connection = nm_simple_connection_new(); @@ -8683,11 +8683,11 @@ test_write_fcoe_mode(gconstpointer user_data) static void test_read_team_master(gconstpointer user_data) { - const char *const PATH_NAME = user_data; + const char *const PATH_NAME = user_data; gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingTeam * s_team; - const char * expected_config = + NMSettingConnection *s_con; + NMSettingTeam *s_team; + const char *expected_config = "{\"device\": \"team0\", \"link_watch\": {\"name\": \"ethtool\"}}"; connection = _connection_from_file(PATH_NAME, NULL, TYPE_ETHERNET, NULL); @@ -8706,8 +8706,8 @@ test_read_team_master(gconstpointer user_data) static void test_read_team_master_invalid(gconstpointer user_data) { - const char *const PATH_NAME = user_data; - gs_free_error GError *error = NULL; + const char *const PATH_NAME = user_data; + gs_free_error GError *error = NULL; gs_unref_object NMConnection *connection = NULL; if (nm_json_vt()) { @@ -8722,14 +8722,14 @@ test_read_team_master_invalid(gconstpointer user_data) static void test_write_team_master(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingTeam * s_team; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - const char * expected_config = + NMSettingConnection *s_con; + NMSettingTeam *s_team; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + const char *expected_config = "{\"device\": \"team0\", \"link_watch\": {\"name\": \"ethtool\"}}"; shvarFile *f; @@ -8777,11 +8777,11 @@ test_write_team_master(void) static void test_read_team_port(gconstpointer user_data) { - const char *const PATH_NAME = user_data; + const char *const PATH_NAME = user_data; gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingTeamPort * s_team_port; - const char * expected_config = "{\"p4p1\": {\"prio\": -10, \"sticky\": true}}"; + NMSettingConnection *s_con; + NMSettingTeamPort *s_team_port; + const char *expected_config = "{\"p4p1\": {\"prio\": -10, \"sticky\": true}}"; connection = _connection_from_file(PATH_NAME, NULL, TYPE_ETHERNET, NULL); @@ -8798,13 +8798,13 @@ test_read_team_port(gconstpointer user_data) static void test_write_team_port(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingTeamPort * s_team_port; - const char * expected_config = "{\"p4p1\": {\"prio\": -10, \"sticky\": true}}"; - shvarFile * f; + NMSettingConnection *s_con; + NMSettingTeamPort *s_team_port; + const char *expected_config = "{\"p4p1\": {\"prio\": -10, \"sticky\": true}}"; + shvarFile *f; connection = nm_simple_connection_new(); @@ -8849,14 +8849,14 @@ test_write_team_port(void) static void test_write_team_infiniband_port(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingTeamPort * s_team_port; - NMSettingInfiniband * s_infiniband; - const char * expected_config = "{\"inf1\": {\"prio\": -10, \"sticky\": true}}"; - shvarFile * f; + NMSettingConnection *s_con; + NMSettingTeamPort *s_team_port; + NMSettingInfiniband *s_infiniband; + const char *expected_config = "{\"inf1\": {\"prio\": -10, \"sticky\": true}}"; + shvarFile *f; connection = nm_simple_connection_new(); @@ -8905,8 +8905,8 @@ static void test_read_team_port_empty_config(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingTeamPort * s_team_port; + NMSettingConnection *s_con; + NMSettingTeamPort *s_team_port; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-team-port-empty-config", NULL, @@ -8929,12 +8929,12 @@ test_read_team_port_empty_config(void) static void test_team_reread_slave(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection_1 = NULL; gs_unref_object NMConnection *connection_2 = NULL; gs_unref_object NMConnection *reread = NULL; gboolean reread_same = FALSE; - NMSettingConnection * s_con; + NMSettingConnection *s_con; connection_1 = nmtst_create_connection_from_keyfile("[connection]\n" @@ -9006,7 +9006,7 @@ static void test_read_proxy_basic(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingProxy * s_proxy; + NMSettingProxy *s_proxy; /* Test basic proxy configuration */ @@ -9027,13 +9027,13 @@ test_read_proxy_basic(void) static void test_write_proxy_basic(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingProxy * s_proxy; - const char * expected_url = "https://wpad.neverland.org/wpad.dat"; - shvarFile * f; + NMSettingConnection *s_con; + NMSettingProxy *s_proxy; + const char *expected_url = "https://wpad.neverland.org/wpad.dat"; + shvarFile *f; connection = nm_simple_connection_new(); @@ -9076,7 +9076,7 @@ test_write_proxy_basic(void) static const char * _svUnescape(const char *str, char **to_free) { - const char * s; + const char *s; gs_free char *str_free = NULL; g_assert(str); @@ -9097,7 +9097,7 @@ _svUnescape(const char *str, char **to_free) } { - const char * s2; + const char *s2; gs_free char *to_free2 = NULL; gboolean is_utf8 = s && g_utf8_validate(s, -1, NULL); @@ -9140,7 +9140,7 @@ static void do_svUnescape_assert(const char *str, const char *expected) { gs_free char *to_free = NULL; - const char * s; + const char *s; s = _svUnescape(str, &to_free); g_assert_cmpstr(s, ==, expected); @@ -9149,7 +9149,7 @@ do_svUnescape_assert(const char *str, const char *expected) if (expected) { gs_free char *s1_free = NULL; gs_free char *s2_free = NULL; - const char * s1, *s2; + const char *s1, *s2; s1 = svEscape(expected, &s1_free); g_assert(s1); @@ -9162,8 +9162,8 @@ do_svUnescape_assert(const char *str, const char *expected) } static void -do_svUnescape_combine_ansi_append(GString * str_val, - GString * str_exp, +do_svUnescape_combine_ansi_append(GString *str_val, + GString *str_exp, const UnescapeTestData *data, gboolean honor_needs_ascii_separator) { @@ -9180,8 +9180,8 @@ do_svUnescape_combine_ansi_append(GString * str_val, } static void -do_svUnescape_combine_ansi(GString * str_val, - GString * str_exp, +do_svUnescape_combine_ansi(GString *str_val, + GString *str_exp, const UnescapeTestData *data_ansi, gsize data_len, gssize idx) @@ -9401,7 +9401,7 @@ test_svUnescape(void) #undef V0 #undef V1 #undef V2 - gsize i; + gsize i; nm_auto_free_gstring GString *str_val = g_string_new(NULL); nm_auto_free_gstring GString *str_val2 = g_string_new(NULL); nm_auto_free_gstring GString *str_exp = g_string_new(NULL); @@ -9470,13 +9470,13 @@ static void test_write_unknown(gconstpointer test_data) { nmtst_auto_unlinkfile char *filename_tmp_1 = g_strdup(TEST_SCRATCH_DIR_TMP "/tmp-1"); - const char * testfile = test_data; - gs_free char * testfile_expected = g_strconcat(testfile, ".expected", NULL); - shvarFile * sv; - gs_free_error GError *error = NULL; - gboolean success; - gs_free char * file_contents_out = NULL; - gs_free char * file_contents_exp = NULL; + const char *testfile = test_data; + gs_free char *testfile_expected = g_strconcat(testfile, ".expected", NULL); + shvarFile *sv; + gs_free_error GError *error = NULL; + gboolean success; + gs_free char *file_contents_out = NULL; + gs_free char *file_contents_exp = NULL; sv = _svOpenFile(testfile); @@ -9519,12 +9519,12 @@ test_write_unknown(gconstpointer test_data) static void test_read_vlan_trailing_spaces(void) { - const char * testfile = TEST_IFCFG_DIR "/ifcfg-test-vlan-trailing-spaces"; + const char *testfile = TEST_IFCFG_DIR "/ifcfg-test-vlan-trailing-spaces"; gs_unref_object NMConnection *connection = NULL; gboolean success; - GError * error = NULL; - NMSettingVlan * s_vlan; - gs_free char * contents = NULL; + GError *error = NULL; + NMSettingVlan *s_vlan; + gs_free char *contents = NULL; /* Ensure there is whitespace at the end of the VLAN interface name, * to prevent the whitespace getting stripped off and committed mistakenly @@ -9681,12 +9681,12 @@ static void test_sriov_read(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingSriov * s_sriov; - NMSriovVF * vf; - GVariant * variant; - GError * error = NULL; - gs_free char * str1 = NULL; - gs_free char * str2 = NULL; + NMSettingSriov *s_sriov; + NMSriovVF *vf; + GVariant *variant; + GError *error = NULL; + gs_free char *str1 = NULL; + gs_free char *str2 = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-sriov", NULL, TYPE_ETHERNET, NULL); @@ -9730,17 +9730,17 @@ test_sriov_read(void) static void test_sriov_write(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingSriov * s_sriov; - NMSriovVF * vf; - gs_unref_ptrarray GPtrArray *vfs = NULL; - NMIPAddress * addr; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingSriov *s_sriov; + NMSriovVF *vf; + gs_unref_ptrarray GPtrArray *vfs = NULL; + NMIPAddress *addr; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -9819,10 +9819,10 @@ static void test_tc_read(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingTCConfig * s_tc; - NMTCQdisc * qdisc; - NMTCTfilter * filter; - gs_free char * str = NULL; + NMSettingTCConfig *s_tc; + NMTCQdisc *qdisc; + NMTCTfilter *filter; + gs_free char *str = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-tc", NULL, TYPE_ETHERNET, NULL); @@ -9847,14 +9847,14 @@ test_tc_read(void) static void test_tc_write_empty(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * addr; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *addr; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -9911,17 +9911,17 @@ test_tc_write_empty(void) static void test_tc_write(void) { - nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingTCConfig * s_tc; - NMTCQdisc * qdisc; - NMTCTfilter * tfilter; - NMIPAddress * addr; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingTCConfig *s_tc; + NMTCQdisc *qdisc; + NMTCTfilter *tfilter; + NMIPAddress *addr; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -10014,7 +10014,7 @@ test_well_known_keys(void) for (i = 0; i < G_N_ELEMENTS(nms_ifcfg_well_known_keys); i++) { const NMSIfcfgKeyTypeInfo *ti = &nms_ifcfg_well_known_keys[i]; - gs_free char * key_name = NULL; + gs_free char *key_name = NULL; gssize idx; g_assert(ti == nms_ifcfg_well_known_key_find_info(ti->key_name, &idx)); @@ -10029,7 +10029,7 @@ test_well_known_keys(void) G_STMT_START \ { \ const NMSIfcfgKeyTypeInfo *_ti; \ - const char * _expected = (expected); \ + const char *_expected = (expected); \ \ _ti = nms_ifcfg_rh_utils_is_well_known_key("" key ""); \ if (!_expected) { \ diff --git a/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c b/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c index 849868771c..af63a41077 100644 --- a/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c +++ b/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c @@ -55,8 +55,8 @@ static void add_data(if_parser *parser, const char *key, const char *data) { if_block *last_block; - if_data * ifd; - char * idx; + if_data *ifd; + char *idx; gsize l_key, l_data; last_block = c_list_last_entry(&parser->block_lst_head, if_block, block_lst); @@ -250,11 +250,11 @@ _recursive_ifparser(if_parser *parser, const char *eni_file, int quiet) static void _ifparser_source(if_parser *parser, const char *path, const char *en_dir, int quiet, int dir) { - char * abs_path; + char *abs_path; const char *item; wordexp_t we; - GDir * source_dir; - GError * error = NULL; + GDir *source_dir; + GError *error = NULL; uint i; if (g_path_is_absolute(path)) diff --git a/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h b/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h index dd0e15fbde..17f858c04c 100644 --- a/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h +++ b/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h @@ -32,8 +32,8 @@ void ifparser_destroy(if_parser *parser); NM_AUTO_DEFINE_FCN0(if_parser *, _nm_auto_ifparser, ifparser_destroy); #define nm_auto_ifparser nm_auto(_nm_auto_ifparser) -if_block * ifparser_getif(if_parser *parser, const char *iface); -if_block * ifparser_getfirst(if_parser *parser); +if_block *ifparser_getif(if_parser *parser, const char *iface); +if_block *ifparser_getfirst(if_parser *parser); const char *ifparser_getkey(if_block *iface, const char *key); gboolean ifparser_haskey(if_block *iface, const char *key); diff --git a/src/core/settings/plugins/ifupdown/nms-ifupdown-parser.c b/src/core/settings/plugins/ifupdown/nms-ifupdown-parser.c index 5bad2362fa..c079266e03 100644 --- a/src/core/settings/plugins/ifupdown/nms-ifupdown-parser.c +++ b/src/core/settings/plugins/ifupdown/nms-ifupdown-parser.c @@ -58,7 +58,7 @@ _ifupdownplugin_guess_connection_type(if_block *block) } struct _Mapping { - const char * domain; + const char *domain; const gpointer target; }; @@ -78,8 +78,8 @@ map_by_mapping(struct _Mapping *mapping, const char *key) static void update_wireless_setting_from_if_block(NMConnection *connection, if_block *block) { - if_data * curr; - const char * value = ifparser_getkey(block, "inet"); + if_data *curr; + const char *value = ifparser_getkey(block, "inet"); struct _Mapping mapping[] = {{"ssid", "ssid"}, {"essid", "ssid"}, {"mode", "mode"}, @@ -210,7 +210,7 @@ static gpointer string_to_glist_of_strings(const char *data) { GSList *ret = NULL; - char * string = (char *) data; + char *string = (char *) data; while (string) { char *next = NULL; if ((next = strchr(string, ' ')) || (next = strchr(string, '\t')) @@ -237,8 +237,8 @@ slist_free_all(gpointer slist) static void update_wireless_security_setting_from_if_block(NMConnection *connection, if_block *block) { - if_data * curr; - const char * value = ifparser_getkey(block, "inet"); + if_data *curr; + const char *value = ifparser_getkey(block, "inet"); struct _Mapping mapping[] = {{"psk", "psk"}, {"identity", "leap-username"}, {"password", "leap-password"}, @@ -283,7 +283,7 @@ update_wireless_security_setting_from_if_block(NMConnection *connection, if_bloc {NULL, NULL}}; NMSettingWirelessSecurity *wireless_security_setting; - NMSettingWireless * s_wireless; + NMSettingWireless *s_wireless; gboolean security = FALSE; if (nm_streq0(value, "ppp")) @@ -297,10 +297,10 @@ update_wireless_security_setting_from_if_block(NMConnection *connection, if_bloc c_list_for_each_entry (curr, &block->data_lst_head, data_lst) { if (NM_STR_HAS_PREFIX_WITH_MORE(curr->key, "wireless-")) { - const char * key = curr->key + NM_STRLEN("wireless-"); - char * property_value = NULL; + const char *key = curr->key + NM_STRLEN("wireless-"); + char *property_value = NULL; gpointer typed_property_value = NULL; - const char * newkey = map_by_mapping(mapping, key); + const char *newkey = map_by_mapping(mapping, key); IfupdownStrDupeFunc dupe_func = map_by_mapping(dupe_mapping, key); IfupdownStrToTypeFunc type_map_func = map_by_mapping(type_mapping, key); GFreeFunc free_func = map_by_mapping(free_type_mapping, key); @@ -329,10 +329,10 @@ wireless_next: (*free_func)(typed_property_value); } else if (NM_STR_HAS_PREFIX_WITH_MORE(curr->key, "wpa-")) { - const char * key = curr->key + NM_STRLEN("wpa-"); - char * property_value = NULL; + const char *key = curr->key + NM_STRLEN("wpa-"); + char *property_value = NULL; gpointer typed_property_value = NULL; - const char * newkey = map_by_mapping(mapping, key); + const char *newkey = map_by_mapping(mapping, key); IfupdownStrDupeFunc dupe_func = map_by_mapping(dupe_mapping, key); IfupdownStrToTypeFunc type_map_func = map_by_mapping(type_mapping, key); GFreeFunc free_func = map_by_mapping(free_type_mapping, key); @@ -391,7 +391,7 @@ static void ifupdown_ip4_add_dns(NMSettingIPConfig *s_ip4, const char *dns) { gs_free const char **list = NULL; - const char ** iter; + const char **iter; guint32 addr; if (dns == NULL) @@ -413,19 +413,19 @@ static gboolean update_ip4_setting_from_if_block(NMConnection *connection, if_block *block, GError **error) { gs_unref_object NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG(nm_setting_ip4_config_new()); - const char * type = ifparser_getkey(block, "inet"); + const char *type = ifparser_getkey(block, "inet"); if (!nm_streq0(type, "static")) { g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); } else { guint32 tmp_mask; NMIPAddress *addr; - const char * address_v; - const char * netmask_v; - const char * gateway_v; - const char * nameserver_v; - const char * nameservers_v; - const char * search_v; + const char *address_v; + const char *netmask_v; + const char *gateway_v; + const char *nameserver_v; + const char *nameservers_v; + const char *search_v; guint32 netmask_int = 32; /* Address */ @@ -495,7 +495,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, if_block *block, GErr search_v = ifparser_getkey(block, "dns-search"); if (search_v) { gs_free const char **list = NULL; - const char ** iter; + const char **iter; list = nm_strsplit_set(search_v, " \t"); for (iter = list; iter && *iter; iter++) { @@ -515,7 +515,7 @@ static void ifupdown_ip6_add_dns(NMSettingIPConfig *s_ip6, const char *dns) { gs_free const char **list = NULL; - const char ** iter; + const char **iter; struct in6_addr addr; if (dns == NULL) @@ -537,18 +537,18 @@ static gboolean update_ip6_setting_from_if_block(NMConnection *connection, if_block *block, GError **error) { gs_unref_object NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG(nm_setting_ip6_config_new()); - const char * type = ifparser_getkey(block, "inet6"); + const char *type = ifparser_getkey(block, "inet6"); if (!NM_IN_STRSET(type, "static", "v4tunnel")) { g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); } else { NMIPAddress *addr; - const char * address_v; - const char * prefix_v; - const char * gateway_v; - const char * nameserver_v; - const char * nameservers_v; - const char * search_v; + const char *address_v; + const char *prefix_v; + const char *gateway_v; + const char *nameserver_v; + const char *nameservers_v; + const char *search_v; guint prefix_int; address_v = ifparser_getkey(block, "address"); @@ -603,7 +603,7 @@ update_ip6_setting_from_if_block(NMConnection *connection, if_block *block, GErr search_v = ifparser_getkey(block, "dns-search"); if (search_v) { gs_free const char **list = NULL; - const char ** iter; + const char **iter; list = nm_strsplit_set(search_v, " \t"); for (iter = list; iter && *iter; iter++) { @@ -623,10 +623,10 @@ NMConnection * ifupdown_new_connection_from_if_block(if_block *block, gboolean autoconnect, GError **error) { gs_unref_object NMConnection *connection = NULL; - const char * type; - gs_free char * idstr = NULL; - gs_free char * uuid = NULL; - NMSettingConnection * s_con; + const char *type; + gs_free char *idstr = NULL; + gs_free char *uuid = NULL; + NMSettingConnection *s_con; connection = nm_simple_connection_new(); diff --git a/src/core/settings/plugins/ifupdown/nms-ifupdown-plugin.c b/src/core/settings/plugins/ifupdown/nms-ifupdown-plugin.c index 602a7327d2..14c82c55b0 100644 --- a/src/core/settings/plugins/ifupdown/nms-ifupdown-plugin.c +++ b/src/core/settings/plugins/ifupdown/nms-ifupdown-plugin.c @@ -25,7 +25,7 @@ /*****************************************************************************/ typedef struct { - NMConnection * connection; + NMConnection *connection; NMSettingsStorage *storage; } StorageData; @@ -107,17 +107,17 @@ initialize(NMSIfupdownPlugin *self) } static void -reload_connections(NMSettingsPlugin * plugin, +reload_connections(NMSettingsPlugin *plugin, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) { - NMSIfupdownPlugin * self = NMS_IFUPDOWN_PLUGIN(plugin); - NMSIfupdownPluginPrivate *priv = NMS_IFUPDOWN_PLUGIN_GET_PRIVATE(self); + NMSIfupdownPlugin *self = NMS_IFUPDOWN_PLUGIN(plugin); + NMSIfupdownPluginPrivate *priv = NMS_IFUPDOWN_PLUGIN_GET_PRIVATE(self); gs_unref_hashtable GHashTable *eni_ifaces_old = NULL; GHashTableIter iter; - StorageData * sd; - StorageData * sd2; - const char * block_name; + StorageData *sd; + StorageData *sd2; + const char *block_name; if (!priv->initialized) initialize(self); @@ -186,7 +186,7 @@ static GSList * _unmanaged_specs(GHashTable *eni_ifaces) { gs_free const char **keys = NULL; - GSList * specs = NULL; + GSList *specs = NULL; guint i, len; keys = nm_strdict_get_keys(eni_ifaces, TRUE, &len); @@ -201,7 +201,7 @@ _unmanaged_specs(GHashTable *eni_ifaces) static GSList * get_unmanaged_specs(NMSettingsPlugin *plugin) { - NMSIfupdownPlugin * self = NMS_IFUPDOWN_PLUGIN(plugin); + NMSIfupdownPlugin *self = NMS_IFUPDOWN_PLUGIN(plugin); NMSIfupdownPluginPrivate *priv = NMS_IFUPDOWN_PLUGIN_GET_PRIVATE(self); if (G_UNLIKELY(!priv->initialized)) @@ -222,9 +222,9 @@ load_eni_ifaces(NMSIfupdownPlugin *self) { gs_unref_hashtable GHashTable *eni_ifaces = NULL; gs_unref_hashtable GHashTable *auto_ifaces = NULL; - nm_auto_ifparser if_parser *parser = NULL; - if_block * block; - StorageData * sd; + nm_auto_ifparser if_parser *parser = NULL; + if_block *block; + StorageData *sd; eni_ifaces = g_hash_table_new_full(nm_str_hash, g_str_equal, @@ -246,11 +246,11 @@ load_eni_ifaces(NMSIfupdownPlugin *self) continue; if (nm_streq(block->type, "iface")) { - gs_free_error GError *local = NULL; - gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMSettingsStorage *storage = NULL; - const char * uuid = NULL; - StorageData * sd_repl; + gs_free_error GError *local = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMSettingsStorage *storage = NULL; + const char *uuid = NULL; + StorageData *sd_repl; /* Bridge configuration */ if (g_str_has_prefix(block->name, "br")) { @@ -369,7 +369,7 @@ nms_ifupdown_plugin_init(NMSIfupdownPlugin *self) static void dispose(GObject *object) { - NMSIfupdownPlugin * plugin = NMS_IFUPDOWN_PLUGIN(object); + NMSIfupdownPlugin *plugin = NMS_IFUPDOWN_PLUGIN(object); NMSIfupdownPluginPrivate *priv = NMS_IFUPDOWN_PLUGIN_GET_PRIVATE(plugin); nm_clear_pointer(&priv->eni_ifaces, g_hash_table_destroy); @@ -380,7 +380,7 @@ dispose(GObject *object) static void nms_ifupdown_plugin_class_init(NMSIfupdownPluginClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingsPluginClass *plugin_class = NM_SETTINGS_PLUGIN_CLASS(klass); object_class->dispose = dispose; @@ -393,7 +393,7 @@ nms_ifupdown_plugin_class_init(NMSIfupdownPluginClass *klass) /*****************************************************************************/ G_MODULE_EXPORT NMSettingsPlugin * - nm_settings_plugin_factory(void) +nm_settings_plugin_factory(void) { return g_object_new(NMS_TYPE_IFUPDOWN_PLUGIN, NULL); } diff --git a/src/core/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/core/settings/plugins/ifupdown/tests/test-ifupdown.c index 0e8db733eb..86b3619ce1 100644 --- a/src/core/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/core/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -19,8 +19,8 @@ #define _connection_from_if_block(block) \ ({ \ NMConnection *_con; \ - if_block * _block = (block); \ - GError * _local = NULL; \ + if_block *_block = (block); \ + GError *_local = NULL; \ \ g_assert(_block); \ _con = ifupdown_new_connection_from_if_block(_block, FALSE, &_local); \ @@ -45,8 +45,8 @@ typedef struct { } ExpectedKey; typedef struct { - char * type; - char * name; + char *type; + char *name; GSList *keys; } ExpectedBlock; @@ -142,13 +142,13 @@ static void compare_expected_to_ifparser(if_parser *parser, Expected *e) { if_block *n; - GSList * biter, *kiter; + GSList *biter, *kiter; g_assert_cmpint(g_slist_length(e->blocks), ==, ifparser_get_num_blocks(parser)); biter = e->blocks; c_list_for_each_entry (n, &parser->block_lst_head, block_lst) { - if_data * m; + if_data *m; ExpectedBlock *b = biter->data; g_assert(b->type && n->type); @@ -203,7 +203,7 @@ dump_blocks(if_parser *parser) static if_parser * init_ifparser_with_file(const char *file) { - if_parser * parser; + if_parser *parser; gs_free char *tmp = NULL; tmp = g_strdup_printf("%s/%s", TEST_DIR, file); @@ -216,8 +216,8 @@ static void test1_ignore_line_before_first_block(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test1"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test1"); e = expected_new(); b = expected_block_new("auto", "eth0"); @@ -233,8 +233,8 @@ static void test2_wrapped_line(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test2"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test2"); e = expected_new(); b = expected_block_new("auto", "lo"); @@ -247,8 +247,8 @@ static void test3_wrapped_multiline_multiarg(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test3"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test3"); e = expected_new(); b = expected_block_new("allow-hotplug", "eth0"); @@ -265,8 +265,8 @@ static void test4_allow_auto_is_auto(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test4"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test4"); e = expected_new(); b = expected_block_new("auto", "eth0"); @@ -279,8 +279,8 @@ static void test5_allow_auto_multiarg(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test5"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test5"); e = expected_new(); b = expected_block_new("allow-hotplug", "eth0"); @@ -295,8 +295,8 @@ static void test6_mixed_whitespace(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test6"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test6"); e = expected_new(); b = expected_block_new("iface", "lo"); @@ -326,8 +326,8 @@ static void test9_wrapped_lines_in_block(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test9"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test9"); e = expected_new(); b = expected_block_new("iface", "eth0"); @@ -345,8 +345,8 @@ static void test11_complex_wrap(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test11"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test11"); e = expected_new(); b = expected_block_new("iface", "pppoe"); @@ -361,8 +361,8 @@ static void test12_complex_wrap_split_word(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test12"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test12"); e = expected_new(); b = expected_block_new("iface", "pppoe"); @@ -377,8 +377,8 @@ static void test13_more_mixed_whitespace(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test13"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test13"); e = expected_new(); b = expected_block_new("iface", "dsl"); @@ -392,8 +392,8 @@ static void test14_mixed_whitespace_block_start(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test14"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test14"); e = expected_new(); b = expected_block_new("iface", "wlan0"); @@ -413,8 +413,8 @@ static void test15_trailing_space(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test15"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test15"); e = expected_new(); b = expected_block_new("iface", "bnep0"); @@ -427,8 +427,8 @@ test15_trailing_space(void) static void test16_missing_newline(void) { - nm_auto_free_expected Expected *e = NULL; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test16"); + nm_auto_free_expected Expected *e = NULL; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test16"); e = expected_new(); expected_add_block(e, expected_block_new("mapping", "eth0")); @@ -440,10 +440,10 @@ static void test17_read_static_ipv4(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingWired * s_wired; - NMIPAddress * ip4_addr; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingWired *s_wired; + NMIPAddress *ip4_addr; nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test17-wired-static-verify-ip4"); connection = _connection_first_from_parser(parser); @@ -483,10 +483,10 @@ static void test18_read_static_ipv6(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; - NMIPAddress * ip6_addr; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip6; + NMSettingWired *s_wired; + NMIPAddress *ip6_addr; nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test18-wired-static-verify-ip6"); connection = _connection_first_from_parser(parser); @@ -526,9 +526,9 @@ static void test19_read_static_ipv4_plen(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; - nm_auto_ifparser if_parser *parser = + NMSettingIPConfig *s_ip4; + NMIPAddress *ip4_addr; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test19-wired-static-verify-ip4-plen"); connection = _connection_first_from_parser(parser); @@ -548,8 +548,8 @@ static void test20_source_stanza(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test20-source-stanza"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test20-source-stanza"); e = expected_new(); @@ -572,8 +572,8 @@ static void test21_source_dir_stanza(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test21-source-dir-stanza"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test21-source-dir-stanza"); e = expected_new(); @@ -590,8 +590,8 @@ static void test22_duplicate_stanzas(void) { nm_auto_free_expected Expected *e = NULL; - ExpectedBlock * b; - nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test22-duplicate-stanzas"); + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file("test22-duplicate-stanzas"); e = expected_new(); diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/core/settings/plugins/keyfile/nms-keyfile-plugin.c index aa36ee8feb..efb9bfce4f 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-plugin.c +++ b/src/core/settings/plugins/keyfile/nms-keyfile-plugin.c @@ -92,7 +92,7 @@ G_DEFINE_TYPE(NMSKeyfilePlugin, nms_keyfile_plugin, NM_TYPE_SETTINGS_PLUGIN) /*****************************************************************************/ static const char * -_extra_flags_to_string(char * str, +_extra_flags_to_string(char *str, gsize str_len, gboolean is_nm_generated, gboolean is_volatile, @@ -147,19 +147,19 @@ _get_plugin_dir(NMSKeyfilePluginPrivate *priv) } static gboolean -_path_detect_storage_type(const char * full_filename, - const char *const * dirname_libs, - const char * dirname_etc, - const char * dirname_run, +_path_detect_storage_type(const char *full_filename, + const char *const *dirname_libs, + const char *dirname_etc, + const char *dirname_run, NMSKeyfileStorageType *out_storage_type, - const char ** out_dirname, - const char ** out_filename, - gboolean * out_is_nmmeta_file, - gboolean * out_failed_due_to_invalid_filename) + const char **out_dirname, + const char **out_filename, + gboolean *out_is_nmmeta_file, + gboolean *out_failed_due_to_invalid_filename) { NMSKeyfileStorageType storage_type; - const char * filename = NULL; - const char * dirname = NULL; + const char *filename = NULL; + const char *dirname = NULL; guint i; gboolean is_nmmeta_file = FALSE; @@ -208,15 +208,15 @@ _path_detect_storage_type(const char * full_filename, /*****************************************************************************/ static NMConnection * -_read_from_file(const char * full_filename, - const char * plugin_dir, +_read_from_file(const char *full_filename, + const char *plugin_dir, struct stat *out_stat, - NMTernary * out_is_nm_generated, - NMTernary * out_is_volatile, - NMTernary * out_is_external, - char ** out_shadowed_storage, - NMTernary * out_shadowed_owned, - GError ** error) + NMTernary *out_is_nm_generated, + NMTernary *out_is_volatile, + NMTernary *out_is_external, + char **out_shadowed_storage, + NMTernary *out_shadowed_owned, + GError **error) { NMConnection *connection; @@ -248,7 +248,7 @@ _nm_assert_storage(gpointer plugin /* NMSKeyfilePlugin */, { #if NM_MORE_ASSERTS NMSettUtilStorageByUuidHead *sbuh; - const char * uuid; + const char *uuid; nm_assert(!plugin || NMS_IS_KEYFILE_PLUGIN(plugin)); nm_assert(NMS_IS_KEYFILE_STORAGE(storage)); @@ -256,7 +256,7 @@ _nm_assert_storage(gpointer plugin /* NMSKeyfilePlugin */, nm_assert(({ const char *f = nms_keyfile_storage_get_filename(storage); - f && f[0] == '/'; + f &&f[0] == '/'; })); uuid = nms_keyfile_storage_get_uuid(storage); @@ -294,22 +294,22 @@ _nm_assert_storage(gpointer plugin /* NMSKeyfilePlugin */, /*****************************************************************************/ static NMSKeyfileStorage * -_load_file(NMSKeyfilePlugin * self, - const char * dirname, - const char * filename, +_load_file(NMSKeyfilePlugin *self, + const char *dirname, + const char *filename, NMSKeyfileStorageType storage_type, - GError ** error) + GError **error) { - NMSKeyfilePluginPrivate *priv; + NMSKeyfilePluginPrivate *priv; gs_unref_object NMConnection *connection = NULL; NMTernary is_nm_generated_opt; NMTernary is_volatile_opt; NMTernary is_external_opt; NMTernary shadowed_owned_opt; - gs_free char * shadowed_storage = NULL; - gs_free_error GError *local = NULL; - gs_free char * full_filename = NULL; - struct stat st; + gs_free char *shadowed_storage = NULL; + gs_free_error GError *local = NULL; + gs_free char *full_filename = NULL; + struct stat st; if (_ignore_filename(storage_type, filename)) { gs_free char *nmmeta = NULL; @@ -403,14 +403,14 @@ _load_file(NMSKeyfilePlugin * self, } static NMSKeyfileStorage * -_load_file_from_path(NMSKeyfilePlugin * self, - const char * full_filename, +_load_file_from_path(NMSKeyfilePlugin *self, + const char *full_filename, NMSKeyfileStorageType storage_type, - GError ** error) + GError **error) { gs_free char *f_dirname_free = NULL; - const char * f_filename; - const char * f_dirname; + const char *f_filename; + const char *f_dirname; nm_assert(full_filename && full_filename[0] == '/'); @@ -421,13 +421,13 @@ _load_file_from_path(NMSKeyfilePlugin * self, } static void -_load_dir(NMSKeyfilePlugin * self, +_load_dir(NMSKeyfilePlugin *self, NMSKeyfileStorageType storage_type, - const char * dirname, - NMSettUtilStorages * storages) + const char *dirname, + NMSettUtilStorages *storages) { - const char * filename; - GDir * dir; + const char *filename; + GDir *dir; gs_unref_hashtable GHashTable *dupl_filenames = NULL; dir = g_dir_open(dirname, 0, NULL); @@ -465,21 +465,21 @@ _load_dir(NMSKeyfilePlugin * self, /*****************************************************************************/ static void -_storages_consolidate(NMSKeyfilePlugin * self, - NMSettUtilStorages * storages_new, +_storages_consolidate(NMSKeyfilePlugin *self, + NMSettUtilStorages *storages_new, gboolean replace_all, - GHashTable * storages_replaced, + GHashTable *storages_replaced, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) { - NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); - CList lst_conn_info_deleted = C_LIST_INIT(lst_conn_info_deleted); - gs_unref_ptrarray GPtrArray *storages_modified = NULL; + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); + CList lst_conn_info_deleted = C_LIST_INIT(lst_conn_info_deleted); + gs_unref_ptrarray GPtrArray *storages_modified = NULL; CList storages_deleted; - NMSKeyfileStorage * storage_safe; - NMSKeyfileStorage * storage_new; - NMSKeyfileStorage * storage_old; - NMSKeyfileStorage * storage; + NMSKeyfileStorage *storage_safe; + NMSKeyfileStorage *storage_new; + NMSKeyfileStorage *storage_old; + NMSKeyfileStorage *storage; guint i; storages_modified = g_ptr_array_new_with_free_func(g_object_unref); @@ -576,12 +576,12 @@ _storages_consolidate(NMSKeyfilePlugin * self, } static void -reload_connections(NMSettingsPlugin * plugin, +reload_connections(NMSettingsPlugin *plugin, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) { - NMSKeyfilePlugin * self = NMS_KEYFILE_PLUGIN(plugin); - NMSKeyfilePluginPrivate * priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN(plugin); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); nm_auto_clear_sett_util_storages NMSettUtilStorages storages_new = NM_SETT_UTIL_STORAGES_INIT(storages_new, nms_keyfile_storage_destroy); int i; @@ -596,20 +596,20 @@ reload_connections(NMSettingsPlugin * plugin, } static void -load_connections(NMSettingsPlugin * plugin, - NMSettingsPluginConnectionLoadEntry * entries, +load_connections(NMSettingsPlugin *plugin, + NMSettingsPluginConnectionLoadEntry *entries, gsize n_entries, NMSettingsPluginConnectionLoadCallback callback, gpointer user_data) { - NMSKeyfilePlugin * self = NMS_KEYFILE_PLUGIN(plugin); - NMSKeyfilePluginPrivate * priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN(plugin); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); nm_auto_clear_sett_util_storages NMSettUtilStorages storages_new = NM_SETT_UTIL_STORAGES_INIT(storages_new, nms_keyfile_storage_destroy); gs_unref_hashtable GHashTable *dupl_filenames = NULL; gs_unref_hashtable GHashTable *storages_replaced = NULL; gs_unref_hashtable GHashTable *loaded_uuids = NULL; - const char * loaded_uuid; + const char *loaded_uuid; GHashTableIter h_iter; gsize i; @@ -625,15 +625,15 @@ load_connections(NMSettingsPlugin * plugin, for (i = 0; i < n_entries; i++) { NMSettingsPluginConnectionLoadEntry *const entry = &entries[i]; NMSKeyfileStorageType storage_type; - gs_free_error GError * local = NULL; - const char * f_filename; - const char * f_dirname; - const char * full_filename; - gs_free char * full_filename_keep = NULL; - gboolean is_nmmeta_file; - NMSettingsPluginConnectionLoadEntry *dupl_content_entry; - gboolean failed_due_to_invalid_filename; - gs_unref_object NMSKeyfileStorage *storage = NULL; + gs_free_error GError *local = NULL; + const char *f_filename; + const char *f_dirname; + const char *full_filename; + gs_free char *full_filename_keep = NULL; + gboolean is_nmmeta_file; + NMSettingsPluginConnectionLoadEntry *dupl_content_entry; + gboolean failed_due_to_invalid_filename; + gs_unref_object NMSKeyfileStorage *storage = NULL; if (entry->handled) continue; @@ -700,7 +700,7 @@ load_connections(NMSettingsPlugin * plugin, /* now we visit all UUIDs that are about to change... */ g_hash_table_iter_init(&h_iter, loaded_uuids); while (g_hash_table_iter_next(&h_iter, (gpointer *) &loaded_uuid, NULL)) { - NMSKeyfileStorage * storage; + NMSKeyfileStorage *storage; NMSettUtilStorageByUuidHead *sbuh; sbuh = nm_sett_util_storages_lookup_by_uuid(&priv->storages, loaded_uuid); @@ -710,9 +710,9 @@ load_connections(NMSettingsPlugin * plugin, c_list_for_each_entry (storage, &sbuh->_storage_by_uuid_lst_head, parent._storage_by_uuid_lst) { - const char * full_filename = nms_keyfile_storage_get_filename(storage); + const char *full_filename = nms_keyfile_storage_get_filename(storage); gs_unref_object NMSKeyfileStorage *storage_new = NULL; - gs_free_error GError *local = NULL; + gs_free_error GError *local = NULL; if (g_hash_table_contains(dupl_filenames, full_filename)) { /* already re-loaded. */ @@ -744,25 +744,25 @@ load_connections(NMSettingsPlugin * plugin, } gboolean -nms_keyfile_plugin_add_connection(NMSKeyfilePlugin * self, - NMConnection * connection, +nms_keyfile_plugin_add_connection(NMSKeyfilePlugin *self, + NMConnection *connection, gboolean in_memory, gboolean is_nm_generated, gboolean is_volatile, gboolean is_external, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error) + NMConnection **out_connection, + GError **error) { - NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); - gs_unref_object NMConnection *reread = NULL; - gs_free char * full_filename = NULL; - NMSKeyfileStorageType storage_type; + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); + gs_unref_object NMConnection *reread = NULL; + gs_free char *full_filename = NULL; + NMSKeyfileStorageType storage_type; gs_unref_object NMSKeyfileStorage *storage = NULL; - GError * local = NULL; - const char * uuid; + GError *local = NULL; + const char *uuid; gboolean reread_same; struct timespec mtime; char strbuf[100]; @@ -849,11 +849,11 @@ nms_keyfile_plugin_add_connection(NMSKeyfilePlugin * self, } static gboolean -add_connection(NMSettingsPlugin * plugin, - NMConnection * connection, +add_connection(NMSettingsPlugin *plugin, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error) + NMConnection **out_connection, + GError **error) { return nms_keyfile_plugin_add_connection(NMS_KEYFILE_PLUGIN(plugin), connection, @@ -869,30 +869,30 @@ add_connection(NMSettingsPlugin * plugin, } gboolean -nms_keyfile_plugin_update_connection(NMSKeyfilePlugin * self, - NMSettingsStorage * storage_x, - NMConnection * connection, +nms_keyfile_plugin_update_connection(NMSKeyfilePlugin *self, + NMSettingsStorage *storage_x, + NMConnection *connection, gboolean is_nm_generated, gboolean is_volatile, gboolean is_external, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, gboolean force_rename, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error) + NMConnection **out_connection, + GError **error) { - NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); - NMSKeyfileStorage * storage = NMS_KEYFILE_STORAGE(storage_x); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); + NMSKeyfileStorage *storage = NMS_KEYFILE_STORAGE(storage_x); gs_unref_object NMConnection *connection_clone = NULL; gs_unref_object NMConnection *reread = NULL; - gs_free char * full_filename = NULL; - gs_free_error GError *local = NULL; - struct timespec mtime; - const char * previous_filename; - gboolean reread_same; - const char * uuid; - char strbuf[100]; + gs_free char *full_filename = NULL; + gs_free_error GError *local = NULL; + struct timespec mtime; + const char *previous_filename; + gboolean reread_same; + const char *uuid; + char strbuf[100]; _nm_assert_storage(self, storage, TRUE); nm_assert(NM_IS_CONNECTION(connection)); @@ -971,12 +971,12 @@ nms_keyfile_plugin_update_connection(NMSKeyfilePlugin * self, } static gboolean -update_connection(NMSettingsPlugin * plugin, - NMSettingsStorage * storage, - NMConnection * connection, +update_connection(NMSettingsPlugin *plugin, + NMSettingsStorage *storage, + NMConnection *connection, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error) + NMConnection **out_connection, + GError **error) { return nms_keyfile_plugin_update_connection(NMS_KEYFILE_PLUGIN(plugin), storage, @@ -995,13 +995,13 @@ update_connection(NMSettingsPlugin * plugin, static gboolean delete_connection(NMSettingsPlugin *plugin, NMSettingsStorage *storage_x, GError **error) { - NMSKeyfilePlugin * self = NMS_KEYFILE_PLUGIN(plugin); - NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN(plugin); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); gs_unref_object NMSKeyfileStorage *storage = g_object_ref(NMS_KEYFILE_STORAGE(storage_x)); - const char * remove_from_disk_errmsg = NULL; - const char * operation_message; - const char * previous_filename; - const char * uuid; + const char *remove_from_disk_errmsg = NULL; + const char *operation_message; + const char *previous_filename; + const char *uuid; gboolean success = TRUE; _nm_assert_storage(self, storage, TRUE); @@ -1087,24 +1087,24 @@ delete_connection(NMSettingsPlugin *plugin, NMSettingsStorage *storage_x, GError * Returns: %TRUE on success. */ gboolean -nms_keyfile_plugin_set_nmmeta_tombstone(NMSKeyfilePlugin * self, +nms_keyfile_plugin_set_nmmeta_tombstone(NMSKeyfilePlugin *self, gboolean simulate, - const char * uuid, + const char *uuid, gboolean in_memory, gboolean set, - const char * shadowed_storage, + const char *shadowed_storage, NMSettingsStorage **out_storage, - gboolean * out_hard_failure) + gboolean *out_hard_failure) { - NMSKeyfilePluginPrivate *priv; - gboolean hard_failure = FALSE; - NMSKeyfileStorage * storage; + NMSKeyfilePluginPrivate *priv; + gboolean hard_failure = FALSE; + NMSKeyfileStorage *storage; gs_unref_object NMSKeyfileStorage *storage_result = NULL; gboolean nmmeta_errno; - gs_free char * nmmeta_filename = NULL; + gs_free char *nmmeta_filename = NULL; NMSKeyfileStorageType storage_type; - const char * loaded_path; - const char * dirname; + const char *loaded_path; + const char *dirname; nm_assert(NMS_IS_KEYFILE_PLUGIN(self)); nm_assert(nm_uuid_is_normalized(uuid)); @@ -1197,11 +1197,11 @@ out: /*****************************************************************************/ static void -config_changed_cb(NMConfig * config, - NMConfigData * config_data, +config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, - NMSKeyfilePlugin * self) + NMConfigData *old_data, + NMSKeyfilePlugin *self) { gs_free char *old_value = NULL; gs_free char *new_value = NULL; @@ -1223,7 +1223,7 @@ static GSList * get_unmanaged_specs(NMSettingsPlugin *config) { NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(config); - gs_free char * value = NULL; + gs_free char *value = NULL; value = nm_config_data_get_value(nm_config_get_data(priv->config), NM_CONFIG_KEYFILE_GROUP_KEYFILE, @@ -1280,7 +1280,7 @@ nms_keyfile_plugin_init(NMSKeyfilePlugin *plugin) static void constructed(GObject *object) { - NMSKeyfilePlugin * self = NMS_KEYFILE_PLUGIN(object); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN(object); NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); G_OBJECT_CLASS(nms_keyfile_plugin_parent_class)->constructed(object); @@ -1312,7 +1312,7 @@ nms_keyfile_plugin_new(void) static void dispose(GObject *object) { - NMSKeyfilePlugin * self = NMS_KEYFILE_PLUGIN(object); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN(object); NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE(self); if (priv->config) @@ -1332,7 +1332,7 @@ dispose(GObject *object) static void nms_keyfile_plugin_class_init(NMSKeyfilePluginClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingsPluginClass *plugin_class = NM_SETTINGS_PLUGIN_CLASS(klass); object_class->constructed = constructed; diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-plugin.h b/src/core/settings/plugins/keyfile/nms-keyfile-plugin.h index 5d9f2da313..19e4122d64 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-plugin.h +++ b/src/core/settings/plugins/keyfile/nms-keyfile-plugin.h @@ -30,38 +30,38 @@ GType nms_keyfile_plugin_get_type(void); NMSKeyfilePlugin *nms_keyfile_plugin_new(void); -gboolean nms_keyfile_plugin_add_connection(NMSKeyfilePlugin * self, - NMConnection * connection, +gboolean nms_keyfile_plugin_add_connection(NMSKeyfilePlugin *self, + NMConnection *connection, gboolean in_memory, gboolean is_nm_generated, gboolean is_volatile, gboolean is_external, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error); + NMConnection **out_connection, + GError **error); -gboolean nms_keyfile_plugin_update_connection(NMSKeyfilePlugin * self, - NMSettingsStorage * storage, - NMConnection * connection, +gboolean nms_keyfile_plugin_update_connection(NMSKeyfilePlugin *self, + NMSettingsStorage *storage, + NMConnection *connection, gboolean is_nm_generated, gboolean is_volatile, gboolean is_external, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, gboolean force_rename, NMSettingsStorage **out_storage, - NMConnection ** out_connection, - GError ** error); + NMConnection **out_connection, + GError **error); -gboolean nms_keyfile_plugin_set_nmmeta_tombstone(NMSKeyfilePlugin * self, +gboolean nms_keyfile_plugin_set_nmmeta_tombstone(NMSKeyfilePlugin *self, gboolean simulate, - const char * uuid, + const char *uuid, gboolean in_memory, gboolean set, - const char * shadowed_storage, + const char *shadowed_storage, NMSettingsStorage **out_storage, - gboolean * out_hard_failure); + gboolean *out_hard_failure); #endif /* __NMS_KEYFILE_PLUGIN_H__ */ diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-reader.c b/src/core/settings/plugins/keyfile/nms-keyfile-reader.c index 8b9d982fa5..81e3d633b1 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-reader.c +++ b/src/core/settings/plugins/keyfile/nms-keyfile-reader.c @@ -23,10 +23,10 @@ _fmt_warn(const NMKeyfileHandlerData *handler_data, char **out_message) const char *message = _nm_keyfile_handler_data_warn_get_message(handler_data); if (group) { - NMSetting * setting = handler_data->cur_setting; + NMSetting *setting = handler_data->cur_setting; const char *property_name = handler_data->cur_property; const char *setting_name = setting ? nm_setting_get_name(setting) : NULL; - char * res; + char *res; if (setting_name) { if (property_name && !strcmp(group, setting_name)) @@ -51,18 +51,18 @@ typedef struct { } ReadInfo; static gboolean -_handler_read(GKeyFile * keyfile, - NMConnection * connection, +_handler_read(GKeyFile *keyfile, + NMConnection *connection, NMKeyfileHandlerType handler_type, NMKeyfileHandlerData *handler_data, - void * user_data) + void *user_data) { const ReadInfo *read_info = user_data; if (handler_type == NM_KEYFILE_HANDLER_TYPE_WARN) { const NMKeyfileHandlerDataWarn *warn_data = &handler_data->warn; NMLogLevel level; - char * message_free = NULL; + char *message_free = NULL; if (!read_info->verbose) return TRUE; @@ -90,21 +90,21 @@ _handler_read(GKeyFile * keyfile, } NMConnection * -nms_keyfile_reader_from_keyfile(GKeyFile * key_file, +nms_keyfile_reader_from_keyfile(GKeyFile *key_file, const char *filename, const char *base_dir, const char *profile_dir, gboolean verbose, - GError ** error) + GError **error) { NMConnection *connection; ReadInfo read_info = { - .verbose = verbose, + .verbose = verbose, }; gs_free char *base_dir_free = NULL; gs_free char *profile_filename_free = NULL; gs_free char *filename_id = NULL; - const char * profile_filename = NULL; + const char *profile_filename = NULL; nm_assert(filename && filename[0]); nm_assert(!base_dir || base_dir[0] == '/'); @@ -154,19 +154,19 @@ nms_keyfile_reader_from_keyfile(GKeyFile * key_file, } NMConnection * -nms_keyfile_reader_from_file(const char * full_filename, - const char * profile_dir, +nms_keyfile_reader_from_file(const char *full_filename, + const char *profile_dir, struct stat *out_stat, - NMTernary * out_is_nm_generated, - NMTernary * out_is_volatile, - NMTernary * out_is_external, - char ** out_shadowed_storage, - NMTernary * out_shadowed_owned, - GError ** error) + NMTernary *out_is_nm_generated, + NMTernary *out_is_volatile, + NMTernary *out_is_external, + char **out_shadowed_storage, + NMTernary *out_shadowed_owned, + GError **error) { nm_auto_unref_keyfile GKeyFile *key_file = NULL; - NMConnection * connection = NULL; - GError * verify_error = NULL; + NMConnection *connection = NULL; + GError *verify_error = NULL; nm_assert(full_filename && full_filename[0] == '/'); nm_assert(!profile_dir || profile_dir[0] == '/'); diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-reader.h b/src/core/settings/plugins/keyfile/nms-keyfile-reader.h index 247457d816..3722fb8a63 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-reader.h +++ b/src/core/settings/plugins/keyfile/nms-keyfile-reader.h @@ -9,23 +9,23 @@ #include "nm-connection.h" -NMConnection *nms_keyfile_reader_from_keyfile(GKeyFile * key_file, +NMConnection *nms_keyfile_reader_from_keyfile(GKeyFile *key_file, const char *filename, const char *base_dir, const char *profile_dir, gboolean verbose, - GError ** error); + GError **error); struct stat; -NMConnection *nms_keyfile_reader_from_file(const char * full_filename, - const char * profile_dir, +NMConnection *nms_keyfile_reader_from_file(const char *full_filename, + const char *profile_dir, struct stat *out_stat, - NMTernary * out_is_nm_generated, - NMTernary * out_is_volatile, - NMTernary * out_is_external, - char ** out_shadowed_storage, - NMTernary * out_shadowed_owned, - GError ** error); + NMTernary *out_is_nm_generated, + NMTernary *out_is_volatile, + NMTernary *out_is_external, + char **out_shadowed_storage, + NMTernary *out_shadowed_owned, + GError **error); #endif /* __NMS_KEYFILE_READER_H__ */ diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-storage.c b/src/core/settings/plugins/keyfile/nms-keyfile-storage.c index ec0634c43d..ddbb3c857e 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-storage.c +++ b/src/core/settings/plugins/keyfile/nms-keyfile-storage.c @@ -41,7 +41,7 @@ nms_keyfile_storage_copy_content(NMSKeyfileStorage *dst, const NMSKeyfileStorage dst->u.meta_data.shadowed_storage = g_strdup(dst->u.meta_data.shadowed_storage); } else { gs_unref_object NMConnection *connection_to_free = NULL; - gs_free char * shadowed_storage_to_free = NULL; + gs_free char *shadowed_storage_to_free = NULL; connection_to_free = g_steal_pointer(&dst->u.conn_data.connection); shadowed_storage_to_free = g_steal_pointer(&dst->u.conn_data.shadowed_storage); @@ -99,9 +99,9 @@ nms_keyfile_storage_init(NMSKeyfileStorage *self) {} static NMSKeyfileStorage * -_storage_new(NMSKeyfilePlugin * plugin, - const char * uuid, - const char * filename, +_storage_new(NMSKeyfilePlugin *plugin, + const char *uuid, + const char *filename, gboolean is_meta_data, NMSKeyfileStorageType storage_type) @@ -128,11 +128,11 @@ _storage_new(NMSKeyfilePlugin * plugin, } NMSKeyfileStorage * -nms_keyfile_storage_new_tombstone(NMSKeyfilePlugin * plugin, - const char * uuid, - const char * filename, +nms_keyfile_storage_new_tombstone(NMSKeyfilePlugin *plugin, + const char *uuid, + const char *filename, NMSKeyfileStorageType storage_type, - const char * shadowed_storage) + const char *shadowed_storage) { NMSKeyfileStorage *self; @@ -149,14 +149,14 @@ nms_keyfile_storage_new_tombstone(NMSKeyfilePlugin * plugin, } NMSKeyfileStorage * -nms_keyfile_storage_new_connection(NMSKeyfilePlugin * plugin, - NMConnection * connection_take /* pass reference */, - const char * filename, +nms_keyfile_storage_new_connection(NMSKeyfilePlugin *plugin, + NMConnection *connection_take /* pass reference */, + const char *filename, NMSKeyfileStorageType storage_type, NMTernary is_nm_generated_opt, NMTernary is_volatile_opt, NMTernary is_external_opt, - const char * shadowed_storage, + const char *shadowed_storage, NMTernary shadowed_owned_opt, const struct timespec *stat_mtime) { @@ -228,7 +228,7 @@ nms_keyfile_storage_destroy(NMSKeyfileStorage *self) static void nms_keyfile_storage_class_init(NMSKeyfileStorageClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingsStorageClass *storage_class = NM_SETTINGS_STORAGE_CLASS(klass); object_class->dispose = dispose; @@ -241,7 +241,7 @@ nms_keyfile_storage_class_init(NMSKeyfileStorageClass *klass) #include "settings/nm-settings-connection.h" void -nm_settings_storage_load_sett_flags(NMSettingsStorage * self, +nm_settings_storage_load_sett_flags(NMSettingsStorage *self, NMSettingsConnectionIntFlags *sett_flags, NMSettingsConnectionIntFlags *sett_mask) { diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-storage.h b/src/core/settings/plugins/keyfile/nms-keyfile-storage.h index 008070df4f..8343cb2b23 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-storage.h +++ b/src/core/settings/plugins/keyfile/nms-keyfile-storage.h @@ -106,22 +106,22 @@ GType nms_keyfile_storage_get_type(void); struct _NMSKeyfilePlugin; NMSKeyfileStorage *nms_keyfile_storage_new_tombstone(struct _NMSKeyfilePlugin *self, - const char * uuid, - const char * filename, + const char *uuid, + const char *filename, NMSKeyfileStorageType storage_type, - const char * shadowed_storage); + const char *shadowed_storage); NMSKeyfileStorage * nms_keyfile_storage_new_connection(struct _NMSKeyfilePlugin *self, - NMConnection * connection_take /* pass reference */, - const char * filename, + NMConnection *connection_take /* pass reference */, + const char *filename, NMSKeyfileStorageType storage_type, NMTernary is_nm_generated_opt, NMTernary is_volatile_opt, NMTernary is_external_opt, - const char * shadowed_storage, + const char *shadowed_storage, NMTernary shadowed_owned_opt, - const struct timespec * stat_mtime); + const struct timespec *stat_mtime); void nms_keyfile_storage_destroy(NMSKeyfileStorage *storage); @@ -204,7 +204,7 @@ nm_settings_storage_is_meta_data_alive(const NMSettingsStorage *storage) static inline const char * nm_settings_storage_get_shadowed_storage(const NMSettingsStorage *storage, - gboolean * out_shadowed_owned) + gboolean *out_shadowed_owned) { if (NMS_IS_KEYFILE_STORAGE(storage)) { const NMSKeyfileStorage *self = (const NMSKeyfileStorage *) storage; @@ -248,7 +248,7 @@ nm_settings_storage_get_filename_for_shadowed_storage(const NMSettingsStorage *s enum _NMSettingsConnectionIntFlags; -void nm_settings_storage_load_sett_flags(NMSettingsStorage * self, +void nm_settings_storage_load_sett_flags(NMSettingsStorage *self, enum _NMSettingsConnectionIntFlags *sett_flags, enum _NMSettingsConnectionIntFlags *sett_mask); diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-utils.c b/src/core/settings/plugins/keyfile/nms-keyfile-utils.c index e2c68bbecc..68ceee5d26 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-utils.c +++ b/src/core/settings/plugins/keyfile/nms-keyfile-utils.c @@ -95,21 +95,21 @@ nms_keyfile_nmmeta_filename(const char *dirname, const char *uuid, gboolean temp } gboolean -nms_keyfile_nmmeta_read(const char * dirname, - const char * filename, - char ** out_full_filename, - char ** out_uuid, - char ** out_loaded_path, - char ** out_shadowed_storage, +nms_keyfile_nmmeta_read(const char *dirname, + const char *filename, + char **out_full_filename, + char **out_uuid, + char **out_loaded_path, + char **out_shadowed_storage, struct stat *out_st) { - const char * uuid; + const char *uuid; guint uuid_len; gs_free char *full_filename = NULL; gs_free char *loaded_path = NULL; gs_free char *shadowed_storage = NULL; struct stat st_stack; - struct stat * st = out_st ?: &st_stack; + struct stat *st = out_st ?: &st_stack; nm_assert(dirname && dirname[0] == '/'); nm_assert(filename && filename[0] && !strchr(filename, '/')); @@ -128,7 +128,7 @@ nms_keyfile_nmmeta_read(const char * dirname, if (S_ISREG(st->st_mode)) { nm_auto_unref_keyfile GKeyFile *kf = NULL; - gs_free char * v_uuid = NULL; + gs_free char *v_uuid = NULL; kf = g_key_file_new(); @@ -176,11 +176,11 @@ nms_keyfile_nmmeta_read(const char * dirname, gboolean nms_keyfile_nmmeta_read_from_file(const char *full_filename, - char ** out_dirname, - char ** out_filename, - char ** out_uuid, - char ** out_loaded_path, - char ** out_shadowed_storage) + char **out_dirname, + char **out_filename, + char **out_uuid, + char **out_loaded_path, + char **out_shadowed_storage) { gs_free char *dirname = NULL; gs_free char *filename = NULL; @@ -210,7 +210,7 @@ nms_keyfile_nmmeta_write(const char *dirname, const char *loaded_path, gboolean loaded_path_allow_relative, const char *shadowed_storage, - char ** out_full_filename) + char **out_full_filename) { gs_free char *full_filename_tmp = NULL; gs_free char *full_filename = NULL; @@ -255,7 +255,7 @@ nms_keyfile_nmmeta_write(const char *dirname, if (shadowed_storage) { nm_auto_unref_keyfile GKeyFile *kf = NULL; - gs_free char * contents = NULL; + gs_free char *contents = NULL; gsize length; kf = g_key_file_new(); @@ -313,7 +313,7 @@ nms_keyfile_nmmeta_write(const char *dirname, gboolean nms_keyfile_utils_check_file_permissions_stat(NMSKeyfileFiletype filetype, const struct stat *st, - GError ** error) + GError **error) { g_return_val_if_fail(st, FALSE); @@ -361,9 +361,9 @@ nms_keyfile_utils_check_file_permissions_stat(NMSKeyfileFiletype filetype, gboolean nms_keyfile_utils_check_file_permissions(NMSKeyfileFiletype filetype, - const char * filename, - struct stat * out_st, - GError ** error) + const char *filename, + struct stat *out_st, + GError **error) { struct stat st; int errsv; diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-utils.h b/src/core/settings/plugins/keyfile/nms-keyfile-utils.h index 419a17ed7a..0fd83bdf35 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-utils.h +++ b/src/core/settings/plugins/keyfile/nms-keyfile-utils.h @@ -34,38 +34,38 @@ const char *nms_keyfile_nmmeta_check_filename(const char *filename, guint *out_u char *nms_keyfile_nmmeta_filename(const char *dirname, const char *uuid, gboolean temporary); -gboolean nms_keyfile_nmmeta_read(const char * dirname, - const char * filename, - char ** out_full_filename, - char ** out_uuid, - char ** out_loaded_path, - char ** out_shadowed_storage, +gboolean nms_keyfile_nmmeta_read(const char *dirname, + const char *filename, + char **out_full_filename, + char **out_uuid, + char **out_loaded_path, + char **out_shadowed_storage, struct stat *out_st); gboolean nms_keyfile_nmmeta_read_from_file(const char *full_filename, - char ** out_dirname, - char ** out_filename, - char ** out_uuid, - char ** out_loaded_path, - char ** out_shadowed_storage); + char **out_dirname, + char **out_filename, + char **out_uuid, + char **out_loaded_path, + char **out_shadowed_storage); int nms_keyfile_nmmeta_write(const char *dirname, const char *uuid, const char *loaded_path, gboolean loaded_path_allow_relative, const char *shadowed_storage, - char ** out_full_filename); + char **out_full_filename); /*****************************************************************************/ struct stat; gboolean nms_keyfile_utils_check_file_permissions_stat(NMSKeyfileFiletype filetype, const struct stat *st, - GError ** error); + GError **error); gboolean nms_keyfile_utils_check_file_permissions(NMSKeyfileFiletype filetype, - const char * filename, - struct stat * out_st, - GError ** error); + const char *filename, + struct stat *out_st, + GError **error); #endif /* __NMS_KEYFILE_UTILS_H__ */ diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-writer.c b/src/core/settings/plugins/keyfile/nms-keyfile-writer.c index 70afdc2362..73788e891e 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-writer.c +++ b/src/core/settings/plugins/keyfile/nms-keyfile-writer.c @@ -26,21 +26,21 @@ typedef struct { } WriteInfo; static void -cert_writer(NMConnection * connection, - GKeyFile * file, - NMSetting8021x * setting, +cert_writer(NMConnection *connection, + GKeyFile *file, + NMSetting8021x *setting, const NMSetting8021xSchemeVtable *vtable, - WriteInfo * info, - GError ** error) + WriteInfo *info, + GError **error) { - const char * setting_name = nm_setting_get_name(NM_SETTING(setting)); + const char *setting_name = nm_setting_get_name(NM_SETTING(setting)); NMSetting8021xCKScheme scheme; NMSetting8021xCKFormat format; - const char * path = NULL, *ext = "pem"; + const char *path = NULL, *ext = "pem"; scheme = vtable->scheme_func(setting); if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) { - char * tmp = NULL; + char *tmp = NULL; const char *accepted_path = NULL; path = vtable->path_func(setting); @@ -92,12 +92,12 @@ cert_writer(NMConnection * connection, vtable->setting_key, vtable->uri_func(setting)); } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) { - GBytes * blob; + GBytes *blob; const guint8 *blob_data; gsize blob_len; gboolean success; - GError * local = NULL; - char * new_path; + GError *local = NULL; + char *new_path; blob = vtable->blob_func(setting); g_assert(blob); @@ -163,11 +163,11 @@ cert_writer(NMConnection * connection, } static gboolean -_handler_write(NMConnection * connection, - GKeyFile * keyfile, +_handler_write(NMConnection *connection, + GKeyFile *keyfile, NMKeyfileHandlerType type, NMKeyfileHandlerData *type_data, - void * user_data) + void *user_data) { if (type == NM_KEYFILE_HANDLER_TYPE_WRITE_CERT) { cert_writer(connection, @@ -182,39 +182,39 @@ _handler_write(NMConnection * connection, } static gboolean -_internal_write_connection(NMConnection * connection, +_internal_write_connection(NMConnection *connection, gboolean is_nm_generated, gboolean is_volatile, gboolean is_external, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, - const char * keyfile_dir, - const char * profile_dir, + const char *keyfile_dir, + const char *profile_dir, gboolean with_extension, uid_t owner_uid, pid_t owner_grp, - const char * existing_path, + const char *existing_path, gboolean existing_path_read_only, gboolean force_rename, NMSKeyfileWriterAllowFilenameCb allow_filename_cb, gpointer allow_filename_user_data, - char ** out_path, - NMConnection ** out_reread, - gboolean * out_reread_same, - GError ** error) + char **out_path, + NMConnection **out_reread, + gboolean *out_reread_same, + GError **error) { nm_auto_unref_keyfile GKeyFile *kf_file = NULL; - gs_free char * kf_content_buf = NULL; + gs_free char *kf_content_buf = NULL; gsize kf_content_len; - gs_free char * path = NULL; - const char * id; - WriteInfo info = {0}; - gs_free_error GError *local_err = NULL; - int errsv; - gboolean rename; - int i_path; - gs_unref_object NMConnection *reread = NULL; - gboolean reread_same = FALSE; + gs_free char *path = NULL; + const char *id; + WriteInfo info = {0}; + gs_free_error GError *local_err = NULL; + int errsv; + gboolean rename; + int i_path; + gs_unref_object NMConnection *reread = NULL; + gboolean reread_same = FALSE; g_return_val_if_fail(!out_path || !*out_path, FALSE); g_return_val_if_fail(keyfile_dir && keyfile_dir[0] == '/', FALSE); @@ -417,23 +417,23 @@ _internal_write_connection(NMConnection * connection, } gboolean -nms_keyfile_writer_connection(NMConnection * connection, +nms_keyfile_writer_connection(NMConnection *connection, gboolean is_nm_generated, gboolean is_volatile, gboolean is_external, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, - const char * keyfile_dir, - const char * profile_dir, - const char * existing_path, + const char *keyfile_dir, + const char *profile_dir, + const char *existing_path, gboolean existing_path_read_only, gboolean force_rename, NMSKeyfileWriterAllowFilenameCb allow_filename_cb, gpointer allow_filename_user_data, - char ** out_path, - NMConnection ** out_reread, - gboolean * out_reread_same, - GError ** error) + char **out_path, + NMConnection **out_reread, + gboolean *out_reread_same, + GError **error) { return _internal_write_connection(connection, is_nm_generated, @@ -458,14 +458,14 @@ nms_keyfile_writer_connection(NMConnection * connection, } gboolean -nms_keyfile_writer_test_connection(NMConnection * connection, - const char * keyfile_dir, +nms_keyfile_writer_test_connection(NMConnection *connection, + const char *keyfile_dir, uid_t owner_uid, pid_t owner_grp, - char ** out_path, + char **out_path, NMConnection **out_reread, - gboolean * out_reread_same, - GError ** error) + gboolean *out_reread_same, + GError **error) { return _internal_write_connection(connection, FALSE, diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-writer.h b/src/core/settings/plugins/keyfile/nms-keyfile-writer.h index dffd3b043d..62aaa19da7 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-writer.h +++ b/src/core/settings/plugins/keyfile/nms-keyfile-writer.h @@ -12,31 +12,31 @@ typedef gboolean (*NMSKeyfileWriterAllowFilenameCb)(const char *check_filename, gpointer allow_filename_user_data); -gboolean nms_keyfile_writer_connection(NMConnection * connection, +gboolean nms_keyfile_writer_connection(NMConnection *connection, gboolean is_nm_generated, gboolean is_volatile, gboolean is_external, - const char * shadowed_storage, + const char *shadowed_storage, gboolean shadowed_owned, - const char * keyfile_dir, - const char * profile_dir, - const char * existing_path, + const char *keyfile_dir, + const char *profile_dir, + const char *existing_path, gboolean existing_path_read_only, gboolean force_rename, NMSKeyfileWriterAllowFilenameCb allow_filename_cb, gpointer allow_filename_user_data, - char ** out_path, - NMConnection ** out_reread, - gboolean * out_reread_same, - GError ** error); + char **out_path, + NMConnection **out_reread, + gboolean *out_reread_same, + GError **error); -gboolean nms_keyfile_writer_test_connection(NMConnection * connection, - const char * keyfile_dir, +gboolean nms_keyfile_writer_test_connection(NMConnection *connection, + const char *keyfile_dir, uid_t owner_uid, pid_t owner_grp, - char ** out_path, + char **out_path, NMConnection **out_reread, - gboolean * out_reread_same, - GError ** error); + gboolean *out_reread_same, + GError **error); #endif /* __NMS_KEYFILE_WRITER_H__ */ diff --git a/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c b/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c index 4ceed49da9..b4c30df7d2 100644 --- a/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c +++ b/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c @@ -42,9 +42,9 @@ check_ip_address(NMSettingIPConfig *config, int idx, const char *address, int pl static void check_ip_route(NMSettingIPConfig *config, int idx, - const char * destination, + const char *destination, int plen, - const char * next_hop, + const char *next_hop, gint64 metric) { NMIPRoute *route = nm_setting_ip_config_get_route(config, idx); @@ -59,7 +59,7 @@ check_ip_route(NMSettingIPConfig *config, #define keyfile_read_connection_from_file(full_filename) \ ({ \ gs_free_error GError *_error = NULL; \ - NMConnection * _connection; \ + NMConnection *_connection; \ \ g_assert(full_filename &&full_filename[0] == '/'); \ \ @@ -84,7 +84,7 @@ assert_reread(NMConnection *connection, gboolean normalize_connection, const cha { gs_unref_object NMConnection *reread = NULL; gs_unref_object NMConnection *connection_clone = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; g_assert(NM_IS_CONNECTION(connection)); @@ -104,7 +104,7 @@ assert_reread(NMConnection *connection, gboolean normalize_connection, const cha static void assert_reread_and_unlink(NMConnection *connection, gboolean normalize_connection, - const char * testfile) + const char *testfile) { assert_reread(connection, normalize_connection, testfile); unlink(testfile); @@ -118,16 +118,16 @@ assert_reread_same(NMConnection *connection, NMConnection *reread) } static void -write_test_connection_reread(NMConnection * connection, - char ** testfile, +write_test_connection_reread(NMConnection *connection, + char **testfile, NMConnection **out_reread, - gboolean * out_reread_same) + gboolean *out_reread_same) { - uid_t owner_uid; - gid_t owner_grp; - gboolean success; - GError * error = NULL; - GError ** p_error = (nmtst_get_rand_uint32() % 2) ? &error : NULL; + uid_t owner_uid; + gid_t owner_grp; + gboolean success; + GError *error = NULL; + GError **p_error = (nmtst_get_rand_uint32() % 2) ? &error : NULL; gs_unref_object NMConnection *connection_normalized = NULL; g_assert(NM_IS_CONNECTION(connection)); @@ -177,7 +177,7 @@ static GKeyFile * keyfile_load_from_file(const char *testfile) { GKeyFile *keyfile; - GError * error = NULL; + GError *error = NULL; gboolean success; g_assert(testfile && *testfile); @@ -193,12 +193,12 @@ keyfile_load_from_file(const char *testfile) static void _setting_copy_property_gbytes(NMConnection *src, NMConnection *dst, - const char * setting_name, - const char * property_name) + const char *setting_name, + const char *property_name) { gs_unref_bytes GBytes *blob = NULL; - NMSetting * s_src; - NMSetting * s_dst; + NMSetting *s_src; + NMSetting *s_dst; g_assert(NM_IS_CONNECTION(src)); g_assert(NM_IS_CONNECTION(dst)); @@ -220,12 +220,12 @@ static void test_read_valid_wired_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPRoute * route; - const char * mac; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPRoute *route; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; NMTST_EXPECT_NM_INFO("*ipv4.addresses:*semicolon at the end*addresses1*"); @@ -370,7 +370,7 @@ test_read_valid_wired_connection(void) static void add_one_ip_address(NMSettingIPConfig *s_ip, const char *addr, guint32 prefix) { - NMIPAddress * ip_addr; + NMIPAddress *ip_addr; gs_free_error GError *error = NULL; ip_addr = nm_ip_address_new(NM_IS_SETTING_IP4_CONFIG(s_ip) ? AF_INET : AF_INET6, @@ -384,12 +384,12 @@ add_one_ip_address(NMSettingIPConfig *s_ip, const char *addr, guint32 prefix) static void add_one_ip_route(NMSettingIPConfig *s_ip, - const char * dest, - const char * nh, + const char *dest, + const char *nh, guint32 prefix, gint64 metric) { - NMIPRoute * route; + NMIPRoute *route; gs_free_error GError *error = NULL; g_assert(prefix > 0); @@ -409,39 +409,39 @@ test_write_wired_connection(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPRoute * rt; - const char * mac = "99:88:77:66:55:44"; - const char * dns1 = "4.2.2.1"; - const char * dns2 = "4.2.2.2"; - const char * address1 = "192.168.0.5"; - const char * address2 = "1.2.3.4"; - const char * gw = "192.168.0.1"; - const char * route1 = "10.10.10.2"; - const char * route1_nh = "10.10.10.1"; - const char * route2 = "1.1.1.1"; - const char * route2_nh = "1.2.1.1"; - const char * route3 = "2.2.2.2"; - const char * route3_nh = NULL; - const char * route4 = "3.3.3.3"; - const char * route4_nh = NULL; - const char * dns6_1 = "1::cafe"; - const char * dns6_2 = "2::cafe"; - const char * address6_1 = "abcd::beef"; - const char * address6_2 = "dcba::beef"; - const char * route6_1 = "1:2:3:4:5:6:7:8"; - const char * route6_1_nh = "8:7:6:5:4:3:2:1"; - const char * route6_2 = "2001::1000"; - const char * route6_2_nh = "2001::1111"; - const char * route6_3 = "4:5:6:7:8:9:0:1"; - const char * route6_3_nh = "::"; - const char * route6_4 = "5:6:7:8:9:0:1:2"; - const char * route6_4_nh = "::"; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPRoute *rt; + const char *mac = "99:88:77:66:55:44"; + const char *dns1 = "4.2.2.1"; + const char *dns2 = "4.2.2.2"; + const char *address1 = "192.168.0.5"; + const char *address2 = "1.2.3.4"; + const char *gw = "192.168.0.1"; + const char *route1 = "10.10.10.2"; + const char *route1_nh = "10.10.10.1"; + const char *route2 = "1.1.1.1"; + const char *route2_nh = "1.2.1.1"; + const char *route3 = "2.2.2.2"; + const char *route3_nh = NULL; + const char *route4 = "3.3.3.3"; + const char *route4_nh = NULL; + const char *dns6_1 = "1::cafe"; + const char *dns6_2 = "2::cafe"; + const char *address6_1 = "abcd::beef"; + const char *address6_2 = "dcba::beef"; + const char *route6_1 = "1:2:3:4:5:6:7:8"; + const char *route6_1_nh = "8:7:6:5:4:3:2:1"; + const char *route6_2 = "2001::1000"; + const char *route6_2_nh = "2001::1111"; + const char *route6_3 = "4:5:6:7:8:9:0:1"; + const char *route6_3_nh = "::"; + const char *route6_4 = "5:6:7:8:9:0:1:2"; + const char *route6_4_nh = "::"; guint64 timestamp = 0x12345678L; - GError * error = NULL; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -534,10 +534,10 @@ static void test_read_ip6_wired_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Wired_Connection_IP6"); @@ -573,13 +573,13 @@ test_write_ip6_wired_connection(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - const char * dns = "1::cafe"; - const char * address = "abcd::beef"; - const char * gw = "dcba::beef"; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + const char *dns = "1::cafe"; + const char *address = "abcd::beef"; + const char *gw = "dcba::beef"; connection = nm_simple_connection_new(); @@ -639,9 +639,9 @@ static void test_read_wired_mac_case(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - const char * mac; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + const char *mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55}; NMTST_EXPECT_NM_INFO("*ipv4.addresses*semicolon at the end*addresses1*"); @@ -669,8 +669,8 @@ static void test_read_mac_old_format(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - const char * mac; + NMSettingWired *s_wired; + const char *mac; char expected_mac[ETH_ALEN] = {0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55}; char expected_cloned_mac[ETH_ALEN] = {0x00, 0x16, 0xaa, 0xbb, 0xcc, 0xfe}; @@ -692,8 +692,8 @@ static void test_read_mac_ib_old_format(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingInfiniband * s_ib; - const char * mac; + NMSettingInfiniband *s_ib; + const char *mac; guint8 expected_mac[INFINIBAND_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x90}; @@ -713,10 +713,10 @@ static void test_read_valid_wireless_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingIPConfig * s_ip4; - const char * bssid; + NMSettingConnection *s_con; + NMSettingWireless *s_wireless; + NMSettingIPConfig *s_ip4; + const char *bssid; const guint8 expected_bssid[ETH_ALEN] = {0x00, 0x1a, 0x33, 0x44, 0x99, 0x82}; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Wireless_Connection"); @@ -746,12 +746,12 @@ test_write_wireless_connection(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - const char * bssid = "aa:b9:a1:74:55:44"; - GBytes * ssid; + NMSettingConnection *s_con; + NMSettingWireless *s_wireless; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + const char *bssid = "aa:b9:a1:74:55:44"; + GBytes *ssid; unsigned char tmpssid[] = {0x31, 0x33, 0x33, 0x37}; guint64 timestamp = 0x12344433L; @@ -814,11 +814,11 @@ static void test_read_string_ssid(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWireless * s_wireless; - GBytes * ssid; - const guint8 * ssid_data; + NMSettingWireless *s_wireless; + GBytes *ssid; + const guint8 *ssid_data; gsize ssid_len; - const char * expected_ssid = "blah blah ssid 1234"; + const char *expected_ssid = "blah blah ssid 1234"; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_String_SSID"); @@ -836,15 +836,15 @@ static void test_write_string_ssid(void) { NMTST_UUID_INIT(uuid); - gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingIPConfig * s_ip4; - char * tmp; - gs_free char * testfile = NULL; - GBytes * ssid; - unsigned char tmpssid[] = {65, 49, 50, 51, 32, 46, 92, 46, 36, 37, 126, 93}; - nm_auto_unref_keyfile GKeyFile *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wireless; + NMSettingIPConfig *s_ip4; + char *tmp; + gs_free char *testfile = NULL; + GBytes *ssid; + unsigned char tmpssid[] = {65, 49, 50, 51, 32, 46, 92, 46, 36, 37, 126, 93}; + nm_auto_unref_keyfile GKeyFile *keyfile = NULL; connection = nm_simple_connection_new(); @@ -894,11 +894,11 @@ static void test_read_intlist_ssid(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWireless * s_wifi; - GBytes * ssid; - const guint8 * ssid_data; + NMSettingWireless *s_wifi; + GBytes *ssid; + const guint8 *ssid_data; gsize ssid_len; - const char * expected_ssid = "blah1234"; + const char *expected_ssid = "blah1234"; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Intlist_SSID"); @@ -915,16 +915,16 @@ static void test_write_intlist_ssid(void) { NMTST_UUID_INIT(uuid); - gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingIPConfig * s_ip4; - gs_free char * testfile = NULL; - GBytes * ssid; - unsigned char tmpssid[] = {65, 49, 50, 51, 0, 50, 50}; - gs_free_error GError *error = NULL; - nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - int * intlist; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingIPConfig *s_ip4; + gs_free char *testfile = NULL; + GBytes *ssid; + unsigned char tmpssid[] = {65, 49, 50, 51, 0, 50, 50}; + gs_free_error GError *error = NULL; + nm_auto_unref_keyfile GKeyFile *keyfile = NULL; + int *intlist; gsize len = 0, i; connection = nm_simple_connection_new(); @@ -981,9 +981,9 @@ static void test_read_intlike_ssid(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWireless * s_wifi; - GBytes * ssid; - const char * expected_ssid = "101"; + NMSettingWireless *s_wifi; + GBytes *ssid; + const char *expected_ssid = "101"; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Intlike_SSID"); @@ -999,9 +999,9 @@ static void test_read_intlike_ssid_2(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWireless * s_wifi; - GBytes * ssid; - const char * expected_ssid = "11;12;13;"; + NMSettingWireless *s_wifi; + GBytes *ssid; + const char *expected_ssid = "11;12;13;"; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Intlike_SSID_2"); @@ -1017,16 +1017,16 @@ static void test_write_intlike_ssid(void) { NMTST_UUID_INIT(uuid); - gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingIPConfig * s_ip4; - gs_free char * testfile = NULL; - GBytes * ssid; - unsigned char tmpssid[] = {49, 48, 49}; - gs_free_error GError *error = NULL; - nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - char * tmp; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingIPConfig *s_ip4; + gs_free char *testfile = NULL; + GBytes *ssid; + unsigned char tmpssid[] = {49, 48, 49}; + gs_free_error GError *error = NULL; + nm_auto_unref_keyfile GKeyFile *keyfile = NULL; + char *tmp; connection = nm_simple_connection_new(); @@ -1078,16 +1078,16 @@ static void test_write_intlike_ssid_2(void) { NMTST_UUID_INIT(uuid); - gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingIPConfig * s_ip4; - gs_free char * testfile = NULL; - GBytes * ssid; - unsigned char tmpssid[] = {49, 49, 59, 49, 50, 59, 49, 51, 59}; - gs_free_error GError *error = NULL; - nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - char * tmp; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingIPConfig *s_ip4; + gs_free char *testfile = NULL; + GBytes *ssid; + unsigned char tmpssid[] = {49, 49, 59, 49, 50, 59, 49, 51, 59}; + gs_free_error GError *error = NULL; + nm_auto_unref_keyfile GKeyFile *keyfile = NULL; + char *tmp; connection = nm_simple_connection_new(); g_assert(connection); @@ -1140,11 +1140,11 @@ static void test_read_bt_dun_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingBluetooth * s_bluetooth; - NMSettingSerial * s_serial; - NMSettingGsm * s_gsm; - const char * bdaddr; + NMSettingConnection *s_con; + NMSettingBluetooth *s_bluetooth; + NMSettingSerial *s_serial; + NMSettingGsm *s_gsm; + const char *bdaddr; const guint8 expected_bdaddr[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/ATT_Data_Connect_BT"); @@ -1181,11 +1181,11 @@ test_write_bt_dun_connection(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingBluetooth * s_bt; - NMSettingIPConfig * s_ip4; - NMSettingGsm * s_gsm; - const char * bdaddr = "aa:b9:a1:74:55:44"; + NMSettingConnection *s_con; + NMSettingBluetooth *s_bt; + NMSettingIPConfig *s_ip4; + NMSettingGsm *s_gsm; + const char *bdaddr = "aa:b9:a1:74:55:44"; guint64 timestamp = 0x12344433L; connection = nm_simple_connection_new(); @@ -1247,9 +1247,9 @@ static void test_read_gsm_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingSerial * s_serial; - NMSettingGsm * s_gsm; + NMSettingConnection *s_con; + NMSettingSerial *s_serial; + NMSettingGsm *s_gsm; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/ATT_Data_Connect_Plain"); @@ -1286,9 +1286,9 @@ test_write_gsm_connection(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingGsm * s_gsm; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingGsm *s_gsm; guint64 timestamp = 0x12344433L; connection = nm_simple_connection_new(); @@ -1350,10 +1350,10 @@ static void test_read_wired_8021x_tls_blob_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSetting8021x * s_8021x; - const char * tmp; - GBytes * blob; + NMSettingWired *s_wired; + NMSetting8021x *s_8021x; + const char *tmp; + GBytes *blob; NMTST_EXPECT_NM_WARN("keyfile: 802-1x.client-cert: certificate or key file " "'/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); @@ -1403,10 +1403,10 @@ static void test_read_wired_8021x_tls_bad_path_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSetting8021x * s_8021x; - const char * tmp; - char * tmp2; + NMSettingWired *s_wired; + NMSetting8021x *s_8021x; + const char *tmp; + char *tmp2; NMTST_EXPECT_NM_WARN("*does not exist*"); connection = @@ -1451,9 +1451,9 @@ static void test_read_wired_8021x_tls_old_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSetting8021x * s_8021x; - const char * tmp; + NMSettingWired *s_wired; + NMSetting8021x *s_8021x; + const char *tmp; NMTST_EXPECT_NM_WARN("keyfile: 802-1x.ca-cert: certificate or key file " "'/CASA/dcbw/Desktop/certinfra/CA/eaptest_ca_cert.pem' does not exist*"); @@ -1493,10 +1493,10 @@ static void test_read_wired_8021x_tls_new_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSetting8021x * s_8021x; - const char * tmp; - char * tmp2; + NMSettingWired *s_wired; + NMSetting8021x *s_8021x; + const char *tmp; + char *tmp2; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Wired_TLS_New"); @@ -1540,12 +1540,12 @@ static NMConnection * create_wired_tls_connection(NMSetting8021xCKScheme scheme) { NMTST_UUID_INIT(uuid); - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSetting * s_wired; - NMSetting8021x * s_8021x; - gboolean success; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSetting *s_wired; + NMSetting8021x *s_8021x; + gboolean success; gs_free_error GError *error = NULL; connection = nm_simple_connection_new(); @@ -1617,11 +1617,11 @@ get_path(const char *file, gboolean relative) static void test_write_wired_8021x_tls_connection_path(void) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMConnection *reread = NULL; - char * tmp, *tmp2; - gboolean success; - gs_free char * testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + char *tmp, *tmp2; + gboolean success; + gs_free char *testfile = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; gboolean relative = FALSE; gboolean reread_same = FALSE; @@ -1705,15 +1705,15 @@ test_write_wired_8021x_tls_connection_blob(void) { gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; - NMSettingConnection * s_con; - NMSetting8021x * s_8021x; - gs_free char * testfile = NULL; - char * new_ca_cert; - char * new_client_cert; - char * new_priv_key; - const char * uuid; + NMSettingConnection *s_con; + NMSetting8021x *s_8021x; + gs_free char *testfile = NULL; + char *new_ca_cert; + char *new_client_cert; + char *new_priv_key; + const char *uuid; gboolean reread_same = FALSE; - GBytes * password_raw; + GBytes *password_raw; #define PASSWORD_RAW "password-raw\0test" @@ -1801,9 +1801,9 @@ static void test_read_infiniband_connection(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingInfiniband * s_ib; - const char * mac; + NMSettingConnection *s_con; + NMSettingInfiniband *s_ib; + const char *mac; guint8 expected_mac[INFINIBAND_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x90}; @@ -1830,10 +1830,10 @@ test_write_infiniband_connection(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingInfiniband * s_ib; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingInfiniband *s_ib; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; const char *mac = "99:88:77:66:55:44:ab:bc:cd:de:ef:f0:0a:1b:2c:3d:4e:5f:6f:ba"; connection = nm_simple_connection_new(); @@ -1888,11 +1888,11 @@ static void test_read_bridge_main(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingBridge * s_bridge; - const char * expected_id = "Test Bridge Main"; - const char * expected_uuid = "8f061643-fe41-4d4c-a8d9-097d26e2ad3a"; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingBridge *s_bridge; + const char *expected_id = "Test Bridge Main"; + const char *expected_uuid = "8f061643-fe41-4d4c-a8d9-097d26e2ad3a"; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Bridge_Main"); @@ -1922,10 +1922,10 @@ test_write_bridge_main(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingBridge * s_bridge; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingBridge *s_bridge; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = nm_simple_connection_new(); g_assert(connection); @@ -1981,13 +1981,13 @@ static void test_read_bridge_component(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingBridgePort * s_port; - NMSettingWired * s_wired; - const char * mac; + NMSettingConnection *s_con; + NMSettingBridgePort *s_port; + NMSettingWired *s_wired; + const char *mac; guint8 expected_mac[ETH_ALEN] = {0x00, 0x22, 0x15, 0x59, 0x62, 0x97}; - const char * expected_id = "Test Bridge Component"; - const char * expected_uuid = "d7b4f96c-c45e-4298-bef8-f48574f8c1c0"; + const char *expected_id = "Test Bridge Component"; + const char *expected_uuid = "d7b4f96c-c45e-4298-bef8-f48574f8c1c0"; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Bridge_Component"); @@ -2016,10 +2016,10 @@ test_write_bridge_component(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingBridgePort * s_port; - NMSettingWired * s_wired; - const char * mac = "99:88:77:66:55:44"; + NMSettingConnection *s_con; + NMSettingBridgePort *s_port; + NMSettingWired *s_wired; + const char *mac = "99:88:77:66:55:44"; connection = nm_simple_connection_new(); g_assert(connection); @@ -2070,8 +2070,8 @@ static void test_read_new_wired_group_name(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - const char * mac; + NMSettingWired *s_wired; + const char *mac; guint8 expected_mac[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_New_Wired_Group_Name"); @@ -2089,14 +2089,14 @@ static void test_write_new_wired_group_name(void) { NMTST_UUID_INIT(uuid); - gs_unref_object NMConnection *connection = NULL; - nm_auto_unref_keyfile GKeyFile *kf = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - gs_free char * testfile = NULL; - gs_free_error GError *error = NULL; - char * s; - int mtu; + gs_unref_object NMConnection *connection = NULL; + nm_auto_unref_keyfile GKeyFile *kf = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + gs_free char *testfile = NULL; + gs_free_error GError *error = NULL; + char *s; + int mtu; connection = nm_simple_connection_new(); g_assert(connection); @@ -2147,10 +2147,10 @@ static void test_read_new_wireless_group_names(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - GBytes * ssid; - const char * expected_ssid = "foobar"; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + GBytes *ssid; + const char *expected_ssid = "foobar"; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_New_Wireless_Group_Names"); @@ -2174,17 +2174,17 @@ static void test_write_new_wireless_group_names(void) { NMTST_UUID_INIT(uuid); - gs_unref_object NMConnection *connection = NULL; - nm_auto_unref_keyfile GKeyFile *kf = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity * s_wsec; - GBytes * ssid; + gs_unref_object NMConnection *connection = NULL; + nm_auto_unref_keyfile GKeyFile *kf = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + GBytes *ssid; unsigned char tmpssid[] = {0x31, 0x33, 0x33, 0x37}; - const char * expected_psk = "asdfasdfasdfa12315"; - gs_free char * testfile = NULL; - gs_free_error GError *error = NULL; - char * s; + const char *expected_psk = "asdfasdfasdfa12315"; + gs_free char *testfile = NULL; + gs_free_error GError *error = NULL; + char *s; connection = nm_simple_connection_new(); @@ -2257,7 +2257,7 @@ static void test_read_missing_vlan_setting(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Missing_Vlan_Setting"); @@ -2271,7 +2271,7 @@ static void test_read_missing_vlan_flags(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Missing_Vlan_Flags"); @@ -2287,8 +2287,8 @@ static void test_read_missing_id_uuid(void) { gs_unref_object NMConnection *connection = NULL; - gs_free char * expected_uuid = NULL; - const char * FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID"; + gs_free char *expected_uuid = NULL; + const char *FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID"; expected_uuid = nm_uuid_generate_from_strings("keyfile", FILENAME, NULL); @@ -2303,7 +2303,7 @@ test_read_minimal(void) { gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *con_archetype = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; con_archetype = nmtst_create_minimal_connection("Test_minimal_x", "a15bd68f-c32b-40b8-8d27-49e472a85919", @@ -2337,7 +2337,7 @@ test_read_minimal_slave(void) { gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *con_archetype = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; con_archetype = nmtst_create_minimal_connection("Test_minimal_slave_x", "a56b4ca5-7075-43d4-82c7-5d0cb15f7654", @@ -2396,7 +2396,7 @@ static void test_read_enum_property(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip6; + NMSettingIPConfig *s_ip6; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Enum_Property"); @@ -2412,9 +2412,9 @@ test_write_enum_property(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip6; connection = nm_simple_connection_new(); @@ -2455,7 +2455,7 @@ static void test_read_flags_property(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingGsm * s_gsm; + NMSettingGsm *s_gsm; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Flags_Property"); @@ -2471,8 +2471,8 @@ test_write_flags_property(void) { NMTST_UUID_INIT(uuid); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSetting * s_gsm; + NMSettingConnection *s_con; + NMSetting *s_gsm; connection = nm_simple_connection_new(); @@ -2513,10 +2513,10 @@ static void test_read_tc_config(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingTCConfig * s_tc; - NMTCQdisc * qdisc1, *qdisc2; - NMTCAction * action1, *action2; - NMTCTfilter * tfilter1, *tfilter2; + NMSettingTCConfig *s_tc; + NMTCQdisc *qdisc1, *qdisc2; + NMTCAction *action1, *action2; + NMTCTfilter *tfilter1, *tfilter2; connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_TC_Config"); @@ -2567,11 +2567,11 @@ static void test_write_tc_config(void) { gs_unref_object NMConnection *connection = NULL; - NMSetting * s_tc; - NMTCQdisc * qdisc1, *qdisc2; - NMTCTfilter * tfilter1, *tfilter2; - NMTCAction * action; - GError * error = NULL; + NMSetting *s_tc; + NMTCQdisc *qdisc1, *qdisc2; + NMTCTfilter *tfilter1, *tfilter2; + NMTCAction *action; + GError *error = NULL; connection = nmtst_create_minimal_connection("Test TC", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); @@ -2751,12 +2751,12 @@ _assert_keyfile_nmmeta(const char *dirname, static void test_nmmeta(void) { - const char * uuid = "3c03fd17-ddc3-4100-a954-88b6fafff959"; + const char *uuid = "3c03fd17-ddc3-4100-a954-88b6fafff959"; gs_free char *filename = g_strdup_printf("%s%s", uuid, NM_KEYFILE_PATH_SUFFIX_NMMETA); gs_free char *full_filename = g_strdup_printf("%s/%s", TEST_SCRATCH_DIR, filename); - const char * loaded_path0 = NM_KEYFILE_PATH_NMMETA_SYMLINK_NULL; - const char * loaded_path1 = "/some/where/but/not/scratch/dir"; - const char * filename2 = "foo1"; + const char *loaded_path0 = NM_KEYFILE_PATH_NMMETA_SYMLINK_NULL; + const char *loaded_path1 = "/some/where/but/not/scratch/dir"; + const char *filename2 = "foo1"; gs_free char *loaded_path2 = g_strdup_printf("%s/%s", TEST_SCRATCH_DIR, filename2); _assert_keyfile_nmmeta(TEST_SCRATCH_DIR, uuid, NULL, FALSE, full_filename, NULL, NULL, NULL); diff --git a/src/core/supplicant/nm-supplicant-config.c b/src/core/supplicant/nm-supplicant-config.c index c486ba1dbc..96c23579d0 100644 --- a/src/core/supplicant/nm-supplicant-config.c +++ b/src/core/supplicant/nm-supplicant-config.c @@ -20,7 +20,7 @@ #include "nm-setting-ip4-config.h" typedef struct { - char * value; + char *value; guint32 len; NMSupplOptType type; } ConfigOption; @@ -28,8 +28,8 @@ typedef struct { /*****************************************************************************/ typedef struct { - GHashTable * config; - GHashTable * blobs; + GHashTable *config; + GHashTable *blobs; NMSupplCapMask capabilities; guint32 ap_scan; bool fast_required : 1; @@ -63,7 +63,7 @@ NMSupplicantConfig * nm_supplicant_config_new(NMSupplCapMask capabilities) { NMSupplicantConfigPrivate *priv; - NMSupplicantConfig * self; + NMSupplicantConfig *self; self = g_object_new(NM_TYPE_SUPPLICANT_CONFIG, NULL); priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE(self); @@ -96,16 +96,16 @@ nm_supplicant_config_init(NMSupplicantConfig *self) static gboolean nm_supplicant_config_add_option_with_type(NMSupplicantConfig *self, - const char * key, - const char * value, + const char *key, + const char *value, gint32 len, NMSupplOptType opt_type, - const char * display_value, - GError ** error) + const char *display_value, + GError **error) { NMSupplicantConfigPrivate *priv; - ConfigOption * old_opt; - ConfigOption * opt; + ConfigOption *old_opt; + ConfigOption *opt; NMSupplOptType type; g_return_val_if_fail(NM_IS_SUPPLICANT_CONFIG(self), FALSE); @@ -124,7 +124,7 @@ nm_supplicant_config_add_option_with_type(NMSupplicantConfig *self, type = nm_supplicant_settings_verify_setting(key, value, len); if (type == NM_SUPPL_OPT_TYPE_INVALID) { gs_free char *str_free = NULL; - const char * str; + const char *str; str = nm_utils_buf_utf8safe_escape(value, len, @@ -178,11 +178,11 @@ nm_supplicant_config_add_option_with_type(NMSupplicantConfig *self, static gboolean nm_supplicant_config_add_option(NMSupplicantConfig *self, - const char * key, - const char * value, + const char *key, + const char *value, gint32 len, - const char * display_value, - GError ** error) + const char *display_value, + GError **error) { return nm_supplicant_config_add_option_with_type(self, key, @@ -195,16 +195,16 @@ nm_supplicant_config_add_option(NMSupplicantConfig *self, static gboolean nm_supplicant_config_add_blob(NMSupplicantConfig *self, - const char * key, - GBytes * value, - const char * blobid, - GError ** error) + const char *key, + GBytes *value, + const char *blobid, + GError **error) { NMSupplicantConfigPrivate *priv; - ConfigOption * old_opt; - ConfigOption * opt; + ConfigOption *old_opt; + ConfigOption *opt; NMSupplOptType type; - const guint8 * data; + const guint8 *data; gsize data_len; g_return_val_if_fail(NM_IS_SUPPLICANT_CONFIG(self), FALSE); @@ -256,14 +256,14 @@ nm_supplicant_config_add_blob(NMSupplicantConfig *self, static gboolean nm_supplicant_config_add_blob_for_connection(NMSupplicantConfig *self, - GBytes * field, - const char * name, - const char * con_uid, - GError ** error) + GBytes *field, + const char *name, + const char *con_uid, + GError **error) { if (field && g_bytes_get_size(field)) { gs_free char *uid = NULL; - char * p; + char *p; uid = g_strdup_printf("%s-%s", con_uid, name); for (p = uid; *p; p++) { @@ -317,8 +317,8 @@ nm_supplicant_config_to_variant(NMSupplicantConfig *self) NMSupplicantConfigPrivate *priv; GVariantBuilder builder; GHashTableIter iter; - ConfigOption * option; - const char * key; + ConfigOption *option; + const char *key; g_return_val_if_fail(NM_IS_SUPPLICANT_CONFIG(self), NULL); @@ -364,8 +364,8 @@ wifi_freqs_to_string(gboolean bg_band) { static const char *str_2ghz = NULL; static const char *str_5ghz = NULL; - const char ** f_p; - const char * f; + const char **f_p; + const char *f; f_p = bg_band ? &str_2ghz : &str_5ghz; @@ -374,7 +374,7 @@ again: if (G_UNLIKELY(!f)) { nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(400, FALSE); - const guint * freqs; + const guint *freqs; int i; freqs = bg_band ? nm_utils_wifi_2ghz_freqs() : nm_utils_wifi_5ghz_freqs(); @@ -397,8 +397,8 @@ again: gboolean nm_supplicant_config_add_setting_macsec(NMSupplicantConfig *self, - NMSettingMacsec * setting, - GError ** error) + NMSettingMacsec *setting, + GError **error) { const char *value; char buf[32]; @@ -467,16 +467,16 @@ nm_supplicant_config_add_setting_macsec(NMSupplicantConfig *self, gboolean nm_supplicant_config_add_setting_wireless(NMSupplicantConfig *self, - NMSettingWireless * setting, + NMSettingWireless *setting, guint32 fixed_freq, - GError ** error) + GError **error) { NMSupplicantConfigPrivate *priv; gboolean is_adhoc, is_ap, is_mesh; - const char * mode, *band; + const char *mode, *band; guint32 channel; - GBytes * ssid; - const char * bssid; + GBytes *ssid; + const char *bssid; g_return_val_if_fail(NM_IS_SUPPLICANT_CONFIG(self), FALSE); g_return_val_if_fail(setting != NULL, FALSE); @@ -584,9 +584,9 @@ nm_supplicant_config_add_setting_wireless(NMSupplicantConfig *self, gboolean nm_supplicant_config_add_bgscan(NMSupplicantConfig *self, NMConnection *connection, GError **error) { - NMSettingWireless * s_wifi; + NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - const char * bgscan; + const char *bgscan; s_wifi = nm_connection_get_setting_wireless(connection); g_assert(s_wifi); @@ -632,11 +632,11 @@ nm_supplicant_config_add_bgscan(NMSupplicantConfig *self, NMConnection *connecti static gboolean add_string_val(NMSupplicantConfig *self, - const char * field, - const char * name, + const char *field, + const char *name, gboolean ucase, - const char * display_value, - GError ** error) + const char *display_value, + GError **error) { if (field) { gs_free char *value = NULL; @@ -671,7 +671,7 @@ add_string_val(NMSupplicantConfig *self, \ if (nm_setting_##setting_name##_get_num_##field_plural(_setting)) { \ const char _separator = (separator); \ - GString * _str = g_string_new(NULL); \ + GString *_str = g_string_new(NULL); \ guint _k, _n; \ \ _n = nm_setting_##setting_name##_get_num_##field_plural(_setting); \ @@ -727,10 +727,10 @@ wep128_passphrase_hash(const char *input, gsize input_len, guint8 *digest /* 13 static gboolean add_wep_key(NMSupplicantConfig *self, - const char * key, - const char * name, + const char *key, + const char *name, NMWepKeyType wep_type, - GError ** error) + GError **error) { gsize key_len; @@ -801,19 +801,19 @@ add_wep_key(NMSupplicantConfig *self, } gboolean -nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * self, - NMSettingWirelessSecurity * setting, - NMSetting8021x * setting_8021x, - const char * con_uuid, +nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig *self, + NMSettingWirelessSecurity *setting, + NMSetting8021x *setting_8021x, + const char *con_uuid, guint32 mtu, NMSettingWirelessSecurityPmf pmf, NMSettingWirelessSecurityFils fils, - GError ** error) + GError **error) { - NMSupplicantConfigPrivate *priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE(self); + NMSupplicantConfigPrivate *priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE(self); nm_auto_free_gstring GString *key_mgmt_conf = NULL; - const char * key_mgmt, *auth_alg; - const char * psk; + const char *key_mgmt, *auth_alg; + const char *psk; gboolean set_pmf, wps_disabled; g_return_val_if_fail(NM_IS_SUPPLICANT_CONFIG(self), FALSE); @@ -1056,10 +1056,10 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * /* WEP keys if required */ if (nm_streq(key_mgmt, "none")) { NMWepKeyType wep_type = nm_setting_wireless_security_get_wep_key_type(setting); - const char * wep0 = nm_setting_wireless_security_get_wep_key(setting, 0); - const char * wep1 = nm_setting_wireless_security_get_wep_key(setting, 1); - const char * wep2 = nm_setting_wireless_security_get_wep_key(setting, 2); - const char * wep3 = nm_setting_wireless_security_get_wep_key(setting, 3); + const char *wep0 = nm_setting_wireless_security_get_wep_key(setting, 0); + const char *wep1 = nm_setting_wireless_security_get_wep_key(setting, 1); + const char *wep2 = nm_setting_wireless_security_get_wep_key(setting, 2); + const char *wep3 = nm_setting_wireless_security_get_wep_key(setting, 3); if (!add_wep_key(self, wep0, "wep_key0", wep_type, error)) return FALSE; @@ -1148,18 +1148,18 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * } static gboolean -add_pkcs11_uri_with_pin(NMSupplicantConfig * self, - const char * name, - const char * uri, - const char * pin, +add_pkcs11_uri_with_pin(NMSupplicantConfig *self, + const char *name, + const char *uri, + const char *pin, const NMSettingSecretFlags pin_flags, - GError ** error) + GError **error) { gs_strfreev char **split = NULL; - gs_free char * tmp = NULL; - gs_free char * tmp_log = NULL; - gs_free char * pin_qattr = NULL; - char * escaped = NULL; + gs_free char *tmp = NULL; + gs_free char *tmp_log = NULL; + gs_free char *pin_qattr = NULL; + char *escaped = NULL; if (uri == NULL) return TRUE; @@ -1195,25 +1195,25 @@ add_pkcs11_uri_with_pin(NMSupplicantConfig * self, gboolean nm_supplicant_config_add_setting_8021x(NMSupplicantConfig *self, - NMSetting8021x * setting, - const char * con_uuid, + NMSetting8021x *setting, + const char *con_uuid, guint32 mtu, gboolean wired, - GError ** error) + GError **error) { - NMSupplicantConfigPrivate *priv; - char * tmp; - const char * peapver, *value, *path; - gboolean added; - GString * phase1, *phase2; - GBytes * bytes; - gboolean fast = FALSE; - guint32 i, num_eap; - gboolean fast_provisoning_allowed = FALSE; - const char * ca_path_override = NULL, *ca_cert_override = NULL; - guint32 frag, hdrs; - gs_free char * frag_str = NULL; - NMSetting8021xAuthFlags phase1_auth_flags; + NMSupplicantConfigPrivate *priv; + char *tmp; + const char *peapver, *value, *path; + gboolean added; + GString *phase1, *phase2; + GBytes *bytes; + gboolean fast = FALSE; + guint32 i, num_eap; + gboolean fast_provisoning_allowed = FALSE; + const char *ca_path_override = NULL, *ca_cert_override = NULL; + guint32 frag, hdrs; + gs_free char *frag_str = NULL; + NMSetting8021xAuthFlags phase1_auth_flags; nm_auto_free_gstring GString *eap_str = NULL; g_return_val_if_fail(NM_IS_SUPPLICANT_CONFIG(self), FALSE); diff --git a/src/core/supplicant/nm-supplicant-config.h b/src/core/supplicant/nm-supplicant-config.h index b561936239..349c310f18 100644 --- a/src/core/supplicant/nm-supplicant-config.h +++ b/src/core/supplicant/nm-supplicant-config.h @@ -40,34 +40,34 @@ GVariant *nm_supplicant_config_to_variant(NMSupplicantConfig *self); GHashTable *nm_supplicant_config_get_blobs(NMSupplicantConfig *self); gboolean nm_supplicant_config_add_setting_wireless(NMSupplicantConfig *self, - NMSettingWireless * setting, + NMSettingWireless *setting, guint32 fixed_freq, - GError ** error); + GError **error); gboolean nm_supplicant_config_add_bgscan(NMSupplicantConfig *self, NMConnection *connection, GError **error); -gboolean nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * self, +gboolean nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig *self, NMSettingWirelessSecurity *setting, NMSetting8021x *setting_8021x, - const char * con_uuid, + const char *con_uuid, guint32 mtu, NMSettingWirelessSecurityPmf pmf, NMSettingWirelessSecurityFils fils, - GError ** error); + GError **error); gboolean nm_supplicant_config_add_no_security(NMSupplicantConfig *self, GError **error); gboolean nm_supplicant_config_add_setting_8021x(NMSupplicantConfig *self, - NMSetting8021x * setting, - const char * con_uuid, + NMSetting8021x *setting, + const char *con_uuid, guint32 mtu, gboolean wired, - GError ** error); + GError **error); gboolean nm_supplicant_config_add_setting_macsec(NMSupplicantConfig *self, - NMSettingMacsec * setting, - GError ** error); + NMSettingMacsec *setting, + GError **error); gboolean nm_supplicant_config_enable_pmf_akm(NMSupplicantConfig *self, GError **error); diff --git a/src/core/supplicant/nm-supplicant-interface.c b/src/core/supplicant/nm-supplicant-interface.c index 2d56b8368f..54d7c7210c 100644 --- a/src/core/supplicant/nm-supplicant-interface.c +++ b/src/core/supplicant/nm-supplicant-interface.c @@ -26,11 +26,11 @@ typedef struct { NMSupplicantInterface *self; - char * type; - char * bssid; - char * pin; + char *type; + char *bssid; + char *pin; guint signal_id; - GCancellable * cancellable; + GCancellable *cancellable; bool needs_cancelling : 1; bool is_cancelling : 1; } WpsData; @@ -38,23 +38,23 @@ typedef struct { struct _AddNetworkData; typedef struct { - NMSupplicantInterface * self; - NMSupplicantConfig * cfg; - GCancellable * cancellable; + NMSupplicantInterface *self; + NMSupplicantConfig *cfg; + GCancellable *cancellable; NMSupplicantInterfaceAssocCb callback; gpointer user_data; guint fail_on_idle_id; guint blobs_left; guint calls_left; - struct _AddNetworkData * add_network_data; + struct _AddNetworkData *add_network_data; } AssocData; typedef struct _AddNetworkData { /* the assoc_data at the time when doing the call. */ - AssocData * assoc_data; + AssocData *assoc_data; NMRefString *name_owner; NMRefString *object_path; - GObject * shutdown_wait_obj; + GObject *shutdown_wait_obj; } AddNetworkData; enum { @@ -86,8 +86,8 @@ typedef struct _NMSupplicantInterfacePrivate { NMSupplicantManager *supplicant_manager; GDBusConnection *dbus_connection; - NMRefString * name_owner; - NMRefString * object_path; + NMRefString *name_owner; + NMRefString *object_path; char *ifname; @@ -197,7 +197,7 @@ _log_pretty_object_path(NMSupplicantInterfacePrivate *priv) #define _NMLOG(level, ...) \ G_STMT_START \ { \ - NMSupplicantInterface * _self = (self); \ + NMSupplicantInterface *_self = (self); \ NMSupplicantInterfacePrivate *_priv = \ _self ? NM_SUPPLICANT_INTERFACE_GET_PRIVATE(_self) : NULL; \ char _sbuf[255]; \ @@ -268,10 +268,10 @@ static NM80211ApSecurityFlags security_from_vardict(GVariant *security) { NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE; - const char ** array; - const char * tmp; + const char **array; + const char *tmp; gsize i; - const char * v; + const char *v; nm_assert(g_variant_is_of_type(security, G_VARIANT_TYPE_VARDICT)); @@ -339,13 +339,13 @@ security_from_vardict(GVariant *security) static void _dbus_connection_call(NMSupplicantInterface *self, - const char * interface_name, - const char * method_name, - GVariant * parameters, - const GVariantType * reply_type, + const char *interface_name, + const char *method_name, + GVariant *parameters, + const GVariantType *reply_type, GDBusCallFlags flags, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -368,13 +368,13 @@ _dbus_connection_call(NMSupplicantInterface *self, static void _dbus_connection_call_simple_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSupplicantInterface *self; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; - const char * log_reason; - gs_free char * remote_error = NULL; - gpointer p_suppress_warning; - gboolean suppress_warning; + NMSupplicantInterface *self; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + const char *log_reason; + gs_free char *remote_error = NULL; + gpointer p_suppress_warning; + gboolean suppress_warning; nm_utils_user_data_unpack(user_data, &self, &log_reason, &p_suppress_warning); @@ -403,11 +403,11 @@ _dbus_connection_call_simple_cb(GObject *source, GAsyncResult *result, gpointer static void _dbus_connection_call_simple_full_impl(NMSupplicantInterface *self, - const char * interface_name, - const char * method_name, - GVariant * parameters, - const GVariantType * reply_type, - const char * log_reason, + const char *interface_name, + const char *method_name, + GVariant *parameters, + const GVariantType *reply_type, + const char *log_reason, gboolean suppress_warning) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); @@ -457,7 +457,7 @@ _dbus_connection_call_simple_full_impl(NMSupplicantInterface *self, /*****************************************************************************/ static void -_emit_signal_state(NMSupplicantInterface * self, +_emit_signal_state(NMSupplicantInterface *self, NMSupplicantInterfaceState new_state, NMSupplicantInterfaceState old_state, gint32 disconnect_reason) @@ -476,7 +476,7 @@ static void _remove_network(NMSupplicantInterface *self) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - gs_free char * net_path = NULL; + gs_free char *net_path = NULL; if (!priv->net_path) return; @@ -588,7 +588,7 @@ _bss_info_destroy(NMSupplicantBssInfo *bss_info) static void _bss_info_changed_emit(NMSupplicantInterface *self, - NMSupplicantBssInfo * bss_info, + NMSupplicantBssInfo *bss_info, gboolean is_present) { _LOGT("BSS %s %s", bss_info->bss_path->str, is_present ? "updated" : "deleted"); @@ -597,20 +597,20 @@ _bss_info_changed_emit(NMSupplicantInterface *self, static void _bss_info_properties_changed(NMSupplicantInterface *self, - NMSupplicantBssInfo * bss_info, - GVariant * properties, + NMSupplicantBssInfo *bss_info, + GVariant *properties, gboolean initial) { gboolean v_b; - GVariant * v_v; - const char * v_s; + GVariant *v_v; + const char *v_s; gint16 v_i16; guint16 v_u16; guint32 v_u32; NM80211ApFlags p_ap_flags; _NM80211Mode p_mode; guint8 p_signal_percent; - const guint8 * arr_data; + const guint8 *arr_data; gsize arr_len; guint32 p_max_rate; gboolean p_max_rate_has; @@ -786,10 +786,10 @@ _bss_info_properties_changed(NMSupplicantInterface *self, static void _bss_info_get_all_cb(GVariant *result, GError *error, gpointer user_data) { - NMSupplicantBssInfo * bss_info; - NMSupplicantInterface * self; + NMSupplicantBssInfo *bss_info; + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *properties = NULL; + gs_unref_variant GVariant *properties = NULL; if (nm_utils_error_is_cancelled(error)) return; @@ -814,9 +814,9 @@ _bss_info_get_all_cb(GVariant *result, GError *error, gpointer user_data) static void _bss_info_add(NMSupplicantInterface *self, const char *object_path) { - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); nm_auto_ref_string NMRefString *bss_path = NULL; - NMSupplicantBssInfo * bss_info; + NMSupplicantBssInfo *bss_info; bss_path = nm_ref_string_new(nm_dbus_path_not_empty(object_path)); if (!bss_path) @@ -851,7 +851,7 @@ static gboolean _bss_info_remove(NMSupplicantInterface *self, NMRefString **p_bss_path) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - NMSupplicantBssInfo * bss_info; + NMSupplicantBssInfo *bss_info; gpointer unused_but_required; if (!g_hash_table_steal_extended(priv->bss_idx, @@ -893,7 +893,7 @@ _peer_info_destroy(NMSupplicantPeerInfo *peer_info) static void _peer_info_changed_emit(NMSupplicantInterface *self, - NMSupplicantPeerInfo * peer_info, + NMSupplicantPeerInfo *peer_info, gboolean is_present) { g_signal_emit(self, signals[PEER_CHANGED], 0, peer_info, is_present); @@ -901,13 +901,13 @@ _peer_info_changed_emit(NMSupplicantInterface *self, static void _peer_info_properties_changed(NMSupplicantInterface *self, - NMSupplicantPeerInfo * peer_info, - GVariant * properties, + NMSupplicantPeerInfo *peer_info, + GVariant *properties, gboolean initial) { - GVariant * v_v; - const char * v_s; - const char ** v_strv; + GVariant *v_v; + const char *v_s; + const char **v_strv; gint32 v_i32; const guint8 *arr_data; gsize arr_len; @@ -985,10 +985,10 @@ _peer_info_properties_changed(NMSupplicantInterface *self, static void _peer_info_get_all_cb(GVariant *result, GError *error, gpointer user_data) { - NMSupplicantPeerInfo * peer_info; - NMSupplicantInterface * self; + NMSupplicantPeerInfo *peer_info; + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *properties = NULL; + gs_unref_variant GVariant *properties = NULL; if (nm_utils_error_is_cancelled(error)) return; @@ -1011,9 +1011,9 @@ _peer_info_get_all_cb(GVariant *result, GError *error, gpointer user_data) static void _peer_info_add(NMSupplicantInterface *self, const char *object_path) { - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); nm_auto_ref_string NMRefString *peer_path = NULL; - NMSupplicantPeerInfo * peer_info; + NMSupplicantPeerInfo *peer_info; peer_path = nm_ref_string_new(nm_dbus_path_not_empty(object_path)); if (!peer_path) @@ -1049,7 +1049,7 @@ static gboolean _peer_info_remove(NMSupplicantInterface *self, NMRefString **p_peer_path) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - NMSupplicantPeerInfo * peer_info; + NMSupplicantPeerInfo *peer_info; gpointer unused_but_required; if (!g_hash_table_steal_extended(priv->peer_idx, @@ -1073,12 +1073,12 @@ _peer_info_remove(NMSupplicantInterface *self, NMRefString **p_peer_path) static void set_state_down(NMSupplicantInterface *self, gboolean force_remove_from_supplicant, - const char * reason) + const char *reason) { _nm_unused gs_unref_object NMSupplicantInterface *self_keep_alive = g_object_ref(self); NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - NMSupplicantBssInfo * bss_info; - NMSupplicantPeerInfo * peer_info; + NMSupplicantBssInfo *bss_info; + NMSupplicantPeerInfo *peer_info; NMSupplicantInterfaceState old_state; nm_assert(priv->state != NM_SUPPLICANT_INTERFACE_STATE_DOWN); @@ -1224,7 +1224,7 @@ parse_capabilities(NMSupplicantInterface *self, GVariant *capabilities) gboolean have_ft = FALSE; gboolean have_sae = FALSE; gint32 max_scan_ssids; - const char ** array; + const char **array; nm_assert(capabilities && g_variant_is_of_type(capabilities, G_VARIANT_TYPE_VARDICT)); @@ -1399,7 +1399,7 @@ set_bridge_cb(GVariant *ret, GError *error, gpointer user_data) { NMSupplicantInterface *self; NMLogLevel level; - gs_free const char * bridge = NULL; + gs_free const char *bridge = NULL; nm_utils_user_data_unpack(user_data, &self, &bridge); @@ -1462,7 +1462,7 @@ static void _p2p_group_properties_changed(NMSupplicantInterface *self, GVariant *properties) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - const char * s; + const char *s; if (!properties) priv->p2p_group_owner_property = FALSE; @@ -1474,16 +1474,16 @@ _p2p_group_properties_changed(NMSupplicantInterface *self, GVariant *properties) static void _p2p_group_properties_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMSupplicantInterface * self = NM_SUPPLICANT_INTERFACE(user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - gs_unref_variant GVariant *changed_properties = NULL; + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE(user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + gs_unref_variant GVariant *changed_properties = NULL; if (priv->p2p_group_properties_cancellable) return; @@ -1498,9 +1498,9 @@ _p2p_group_properties_changed_cb(GDBusConnection *connection, static void _p2p_group_properties_get_all_cb(GVariant *result, GError *error, gpointer user_data) { - NMSupplicantInterface * self; + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *properties = NULL; + gs_unref_variant GVariant *properties = NULL; if (nm_utils_error_is_cancelled(error)) return; @@ -1527,7 +1527,7 @@ _p2p_group_properties_get_all_cb(GVariant *result, GError *error, gpointer user_ static void _p2p_group_set_path(NMSupplicantInterface *self, const char *path) { - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); nm_auto_ref_string NMRefString *group_path = NULL; group_path = nm_ref_string_new(nm_dbus_path_not_empty(path)); @@ -1583,14 +1583,14 @@ _wps_data_free(WpsData *wps_data, GDBusConnection *dbus_connection) static void _wps_credentials_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMSupplicantInterface *self = user_data; + NMSupplicantInterface *self = user_data; gs_unref_variant GVariant *props = NULL; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(a{sv})"))) @@ -1605,10 +1605,10 @@ _wps_credentials_changed_cb(GDBusConnection *connection, static void _wps_handle_start_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSupplicantInterface *self; - WpsData * wps_data; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + NMSupplicantInterface *self; + WpsData *wps_data; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -1631,9 +1631,9 @@ _wps_handle_start_cb(GObject *source, GAsyncResult *result, gpointer user_data) static void _wps_handle_set_pc_cb(GVariant *res, GError *error, gpointer user_data) { - NMSupplicantInterface * self; + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; - WpsData * wps_data; + WpsData *wps_data; GVariantBuilder start_args; guint8 bssid_buf[ETH_ALEN]; @@ -1715,12 +1715,12 @@ _wps_call_set_pc(NMSupplicantInterface *self, WpsData *wps_data) static void _wps_handle_cancel_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - GDBusConnection * dbus_connection = G_DBUS_CONNECTION(source); - NMSupplicantInterface * self; + GDBusConnection *dbus_connection = G_DBUS_CONNECTION(source); + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; - WpsData * wps_data; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + WpsData *wps_data; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(dbus_connection, result, &error); nm_assert(!nm_utils_error_is_cancelled(error)); @@ -1763,7 +1763,7 @@ static void _wps_start(NMSupplicantInterface *self, const char *type, const char *bssid, const char *pin) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - WpsData * wps_data; + WpsData *wps_data; if (type) _LOGI("wps: type %s start...", type); @@ -1828,9 +1828,9 @@ _wps_start(NMSupplicantInterface *self, const char *type, const char *bssid, con void nm_supplicant_interface_enroll_wps(NMSupplicantInterface *self, - const char * type, - const char * bssid, - const char * pin) + const char *type, + const char *bssid, + const char *pin) { _wps_start(self, type, bssid, pin); } @@ -1846,12 +1846,12 @@ nm_supplicant_interface_cancel_wps(NMSupplicantInterface *self) static void iface_introspect_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSupplicantInterface * self; + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; - const char * data; - NMTernary value; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + const char *data; + NMTernary value; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -1882,11 +1882,11 @@ static void _properties_changed_main(NMSupplicantInterface *self, GVariant *properties) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - const char ** v_strv; - const char * v_s; + const char **v_strv; + const char *v_s; gboolean v_b; gint32 v_i32; - GVariant * v_v; + GVariant *v_v; gboolean do_log_driver_info = FALSE; gboolean do_set_state = FALSE; gboolean do_notify_current_bss = FALSE; @@ -1972,7 +1972,7 @@ _properties_changed_main(NMSupplicantInterface *self, GVariant *properties) if (nm_g_variant_lookup(properties, "BSSs", "^a&o", &v_strv)) { NMSupplicantBssInfo *bss_info; NMSupplicantBssInfo *bss_info_safe; - const char ** iter; + const char **iter; c_list_for_each_entry (bss_info, &priv->bss_lst_head, _bss_lst) bss_info->_bss_dirty = TRUE; @@ -2010,15 +2010,15 @@ static void _properties_changed_p2p_device(NMSupplicantInterface *self, GVariant *properties) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - const char ** v_strv; - const char * v_s; + const char **v_strv; + const char *v_s; nm_assert(!properties || g_variant_is_of_type(properties, G_VARIANT_TYPE("a{sv}"))); if (nm_g_variant_lookup(properties, "Peers", "^a&o", &v_strv)) { NMSupplicantPeerInfo *peer_info; NMSupplicantPeerInfo *peer_info_safe; - const char *const * iter; + const char *const *iter; c_list_for_each_entry (peer_info, &priv->peer_lst_head, _peer_lst) peer_info->_peer_dirty = TRUE; @@ -2053,7 +2053,7 @@ static void assoc_return(NMSupplicantInterface *self, GError *error, const char *message) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - AssocData * assoc_data; + AssocData *assoc_data; assoc_data = g_steal_pointer(&priv->assoc_data); if (!assoc_data) @@ -2122,11 +2122,11 @@ nm_supplicant_interface_disconnect(NMSupplicantInterface *self) static void disconnect_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_object NMSupplicantInterface *self = NULL; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError * error = NULL; - NMSupplicantInterfaceDisconnectCb callback; - gpointer callback_user_data; + gs_unref_object NMSupplicantInterface *self = NULL; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + NMSupplicantInterfaceDisconnectCb callback; + gpointer callback_user_data; nm_utils_user_data_unpack(user_data, &self, &callback, &callback_user_data); @@ -2141,8 +2141,8 @@ disconnect_cb(GObject *source, GAsyncResult *result, gpointer user_data) } void -nm_supplicant_interface_disconnect_async(NMSupplicantInterface * self, - GCancellable * cancellable, +nm_supplicant_interface_disconnect_async(NMSupplicantInterface *self, + GCancellable *cancellable, NMSupplicantInterfaceDisconnectCb callback, gpointer user_data) { @@ -2164,9 +2164,9 @@ nm_supplicant_interface_disconnect_async(NMSupplicantInterface * self, static void assoc_select_network_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSupplicantInterface *self; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + NMSupplicantInterface *self; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -2199,10 +2199,10 @@ assoc_call_select_network(NMSupplicantInterface *self) static void assoc_add_blob_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSupplicantInterface * self; + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -2227,16 +2227,16 @@ assoc_add_blob_cb(GObject *source, GAsyncResult *result, gpointer user_data) static void assoc_add_network_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - AddNetworkData * add_network_data = user_data; - AssocData * assoc_data; - NMSupplicantInterface * self; - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; - GHashTable * blobs; - GHashTableIter iter; - const char * blob_name; - GBytes * blob_data; + AddNetworkData *add_network_data = user_data; + AssocData *assoc_data; + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + GHashTable *blobs; + GHashTableIter iter; + const char *blob_name; + GBytes *blob_data; nm_auto_ref_string NMRefString *name_owner = NULL; nm_auto_ref_string NMRefString *object_path = NULL; @@ -2322,7 +2322,7 @@ static void add_network(NMSupplicantInterface *self) { NMSupplicantInterfacePrivate *priv; - AddNetworkData * add_network_data; + AddNetworkData *add_network_data; priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); @@ -2359,7 +2359,7 @@ add_network(NMSupplicantInterface *self) static void assoc_set_ap_isolation(GVariant *ret, GError *error, gpointer user_data) { - NMSupplicantInterface * self; + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; gboolean value; @@ -2389,7 +2389,7 @@ assoc_set_ap_isolation(GVariant *ret, GError *error, gpointer user_data) static void assoc_set_ap_scan_cb(GVariant *ret, GError *error, gpointer user_data) { - NMSupplicantInterface * self; + NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; if (nm_utils_error_is_cancelled(error)) @@ -2415,9 +2415,9 @@ assoc_set_ap_scan_cb(GVariant *ret, GError *error, gpointer user_data) static gboolean assoc_fail_on_idle_cb(gpointer user_data) { - NMSupplicantInterface * self = user_data; - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - gs_free_error GError *error = NULL; + NMSupplicantInterface *self = user_data; + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + gs_free_error GError *error = NULL; priv->assoc_data->fail_on_idle_id = 0; g_set_error(&error, @@ -2443,13 +2443,13 @@ assoc_fail_on_idle_cb(gpointer user_data) * an error reason indicating cancellation/disposing (see nm_utils_error_is_cancelled()). */ void -nm_supplicant_interface_assoc(NMSupplicantInterface * self, - NMSupplicantConfig * cfg, +nm_supplicant_interface_assoc(NMSupplicantInterface *self, + NMSupplicantConfig *cfg, NMSupplicantInterfaceAssocCb callback, gpointer user_data) { NMSupplicantInterfacePrivate *priv; - AssocData * assoc_data; + AssocData *assoc_data; gboolean ap_isolation; g_return_if_fail(NM_IS_SUPPLICANT_INTERFACE(self)); @@ -2525,8 +2525,8 @@ nm_supplicant_interface_assoc(NMSupplicantInterface * self, /*****************************************************************************/ typedef struct { - NMSupplicantInterface * self; - GCancellable * cancellable; + NMSupplicantInterface *self; + GCancellable *cancellable; NMSupplicantInterfaceRequestScanCallback callback; gpointer user_data; } ScanRequestData; @@ -2535,11 +2535,11 @@ static void scan_request_cb(GObject *source, GAsyncResult *result, gpointer user_data) { gs_unref_object NMSupplicantInterface *self_keep_alive = NULL; - NMSupplicantInterface * self; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; - ScanRequestData * data = user_data; - gboolean cancelled = FALSE; + NMSupplicantInterface *self; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + ScanRequestData *data = user_data; + gboolean cancelled = FALSE; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) { @@ -2583,16 +2583,16 @@ scan_request_cb(GObject *source, GAsyncResult *result, gpointer user_data) } void -nm_supplicant_interface_request_scan(NMSupplicantInterface * self, - GBytes *const * ssids, +nm_supplicant_interface_request_scan(NMSupplicantInterface *self, + GBytes *const *ssids, guint ssids_len, - GCancellable * cancellable, + GCancellable *cancellable, NMSupplicantInterfaceRequestScanCallback callback, gpointer user_data) { NMSupplicantInterfacePrivate *priv; GVariantBuilder builder; - ScanRequestData * data; + ScanRequestData *data; guint i; g_return_if_fail(NM_IS_SUPPLICANT_INTERFACE(self)); @@ -2662,7 +2662,7 @@ nm_supplicant_interface_get_state(NMSupplicantInterface *self) void _nm_supplicant_interface_set_state_down(NMSupplicantInterface *self, gboolean force_remove_from_supplicant, - const char * reason) + const char *reason) { set_state_down(self, force_remove_from_supplicant, reason); } @@ -2740,9 +2740,9 @@ nm_supplicant_interface_p2p_stop_find(NMSupplicantInterface *self) void nm_supplicant_interface_p2p_connect(NMSupplicantInterface *self, - const char * peer, - const char * wps_method, - const char * wps_pin) + const char *peer, + const char *wps_method, + const char *wps_pin) { GVariantBuilder builder; @@ -2797,8 +2797,8 @@ nm_supplicant_interface_p2p_disconnect(NMSupplicantInterface *self) static void _properties_changed(NMSupplicantInterface *self, - const char * interface_name, - GVariant * properties, + const char *interface_name, + GVariant *properties, gboolean initial) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); @@ -2841,15 +2841,15 @@ _properties_changed(NMSupplicantInterface *self, static void _properties_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE(user_data); - const char * interface_name; + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE(user_data); + const char *interface_name; gs_unref_variant GVariant *changed_properties = NULL; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sa{sv}as)"))) @@ -2861,18 +2861,18 @@ _properties_changed_cb(GDBusConnection *connection, static void _bss_properties_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMSupplicantInterface * self = NM_SUPPLICANT_INTERFACE(user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - nm_auto_ref_string NMRefString *bss_path = NULL; - gs_unref_variant GVariant *changed_properties = NULL; - NMSupplicantBssInfo * bss_info; + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE(user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + nm_auto_ref_string NMRefString *bss_path = NULL; + gs_unref_variant GVariant *changed_properties = NULL; + NMSupplicantBssInfo *bss_info; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sa{sv}as)"))) return; @@ -2891,18 +2891,18 @@ _bss_properties_changed_cb(GDBusConnection *connection, static void _peer_properties_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMSupplicantInterface * self = NM_SUPPLICANT_INTERFACE(user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - nm_auto_ref_string NMRefString *peer_path = NULL; - gs_unref_variant GVariant *changed_properties = NULL; - NMSupplicantPeerInfo * peer_info; + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE(user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + nm_auto_ref_string NMRefString *peer_path = NULL; + gs_unref_variant GVariant *changed_properties = NULL; + NMSupplicantPeerInfo *peer_info; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sa{sv}as)"))) return; @@ -2956,12 +2956,12 @@ _set_p2p_assigned_addr(NMSupplicantInterface *self, gconstpointer addr, guint8 p static void _signal_handle(NMSupplicantInterface *self, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters) + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - const char * path; + const char *path; if (nm_streq(signal_interface_name, NM_WPAS_DBUS_IFACE_INTERFACE)) { if (!priv->is_ready_main) @@ -2990,8 +2990,8 @@ _signal_handle(NMSupplicantInterface *self, if (nm_streq(signal_name, "EAP")) { NMSupplicantAuthState auth_state = NM_SUPPLICANT_AUTH_STATE_UNKNOWN; - const char * status; - const char * parameter; + const char *status; + const char *parameter; if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(ss)"))) return; @@ -3044,11 +3044,11 @@ _signal_handle(NMSupplicantInterface *self, if (nm_streq(signal_name, "GroupStarted")) { if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(a{sv})"))) { - gs_unref_variant GVariant *args = NULL; + gs_unref_variant GVariant *args = NULL; gs_unref_object NMSupplicantInterface *iface = NULL; - const char * group_path; - const char * iface_path; - GVariant * v_v = NULL; + const char *group_path; + const char *iface_path; + GVariant *v_v = NULL; g_variant_get(parameters, "(@a{sv})", &args); if (!g_variant_lookup(args, "group_object", "&o", &group_path)) @@ -3107,7 +3107,7 @@ _signal_handle(NMSupplicantInterface *self, if (nm_streq(signal_name, "GroupFinished")) { if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(a{sv})"))) { gs_unref_variant GVariant *args = NULL; - const char * iface_path; + const char *iface_path; g_variant_get(parameters, "(@a{sv})", &args); @@ -3134,14 +3134,14 @@ _signal_handle(NMSupplicantInterface *self, static void _signal_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMSupplicantInterface * self = user_data; + NMSupplicantInterface *self = user_data; NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); priv->starting_pending_count++; @@ -3180,8 +3180,8 @@ nm_supplicant_interface_get_p2p_group_owner(NMSupplicantInterface *self) gboolean nm_supplicant_interface_get_p2p_assigned_addr(NMSupplicantInterface *self, - in_addr_t * addr, - guint8 * plen) + in_addr_t *addr, + guint8 *plen) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); @@ -3201,7 +3201,7 @@ nm_supplicant_interface_get_p2p_assigned_addr(NMSupplicantInterface *self, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSupplicantInterface * self = NM_SUPPLICANT_INTERFACE(object); + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE(object); NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); switch (prop_id) { @@ -3314,7 +3314,7 @@ nm_supplicant_interface_init(NMSupplicantInterface *self) static void constructed(GObject *object) { - NMSupplicantInterface * self = NM_SUPPLICANT_INTERFACE(object); + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE(object); NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); G_OBJECT_CLASS(nm_supplicant_interface_parent_class)->constructed(object); @@ -3439,7 +3439,7 @@ constructed(GObject *object) NMSupplicantInterface * nm_supplicant_interface_new(NMSupplicantManager *supplicant_manager, - NMRefString * object_path, + NMRefString *object_path, int ifindex, NMSupplicantDriver driver) { @@ -3460,7 +3460,7 @@ nm_supplicant_interface_new(NMSupplicantManager *supplicant_manager, static void dispose(GObject *object) { - NMSupplicantInterface * self = NM_SUPPLICANT_INTERFACE(object); + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE(object); NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); if (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DOWN) diff --git a/src/core/supplicant/nm-supplicant-interface.h b/src/core/supplicant/nm-supplicant-interface.h index 4c5d8f6488..5ccb455caf 100644 --- a/src/core/supplicant/nm-supplicant-interface.h +++ b/src/core/supplicant/nm-supplicant-interface.h @@ -100,7 +100,7 @@ struct _NMSupplicantInterface { GType nm_supplicant_interface_get_type(void); NMSupplicantInterface *nm_supplicant_interface_new(NMSupplicantManager *supplicant_manager, - NMRefString * object_path, + NMRefString *object_path, int ifindex, NMSupplicantDriver driver); @@ -109,36 +109,36 @@ NMRefString *nm_supplicant_interface_get_object_path(NMSupplicantInterface *ifac void _nm_supplicant_interface_set_state_down(NMSupplicantInterface *self, gboolean force_remove_from_supplicant, - const char * reason); + const char *reason); typedef void (*NMSupplicantInterfaceAssocCb)(NMSupplicantInterface *iface, - GError * error, + GError *error, gpointer user_data); -void nm_supplicant_interface_assoc(NMSupplicantInterface * self, - NMSupplicantConfig * cfg, +void nm_supplicant_interface_assoc(NMSupplicantInterface *self, + NMSupplicantConfig *cfg, NMSupplicantInterfaceAssocCb callback, gpointer user_data); void nm_supplicant_interface_disconnect(NMSupplicantInterface *iface); typedef void (*NMSupplicantInterfaceDisconnectCb)(NMSupplicantInterface *iface, - GError * error, + GError *error, gpointer user_data); -void nm_supplicant_interface_disconnect_async(NMSupplicantInterface * self, - GCancellable * cancellable, +void nm_supplicant_interface_disconnect_async(NMSupplicantInterface *self, + GCancellable *cancellable, NMSupplicantInterfaceDisconnectCb callback, gpointer user_data); typedef void (*NMSupplicantInterfaceRequestScanCallback)(NMSupplicantInterface *self, - GCancellable * cancellable, + GCancellable *cancellable, gpointer user_data); -void nm_supplicant_interface_request_scan(NMSupplicantInterface * self, - GBytes *const * ssids, +void nm_supplicant_interface_request_scan(NMSupplicantInterface *self, + GBytes *const *ssids, guint ssids_len, - GCancellable * cancellable, + GCancellable *cancellable, NMSupplicantInterfaceRequestScanCallback callback, gpointer user_data); @@ -165,16 +165,16 @@ const char *nm_supplicant_interface_get_p2p_group_path(NMSupplicantInterface *se gboolean nm_supplicant_interface_get_p2p_group_owner(NMSupplicantInterface *self); gboolean nm_supplicant_interface_get_p2p_assigned_addr(NMSupplicantInterface *self, - in_addr_t * assigned_addr, - guint8 * plen); + in_addr_t *assigned_addr, + guint8 *plen); void nm_supplicant_interface_p2p_start_find(NMSupplicantInterface *self, guint timeout); void nm_supplicant_interface_p2p_stop_find(NMSupplicantInterface *self); void nm_supplicant_interface_p2p_connect(NMSupplicantInterface *self, - const char * peer, - const char * wps_method, - const char * wps_pin); + const char *peer, + const char *wps_method, + const char *wps_pin); void nm_supplicant_interface_p2p_cancel_connect(NMSupplicantInterface *self); void nm_supplicant_interface_p2p_disconnect(NMSupplicantInterface *self); @@ -187,8 +187,8 @@ NMSupplCapMask nm_supplicant_interface_get_capabilities(NMSupplicantInterface *s void nm_supplicant_interface_enroll_wps(NMSupplicantInterface *self, const char *const type, - const char * bssid, - const char * pin); + const char *bssid, + const char *pin); void nm_supplicant_interface_cancel_wps(NMSupplicantInterface *self); diff --git a/src/core/supplicant/nm-supplicant-manager.c b/src/core/supplicant/nm-supplicant-manager.c index 52beae7830..1f8f0105d4 100644 --- a/src/core/supplicant/nm-supplicant-manager.c +++ b/src/core/supplicant/nm-supplicant-manager.c @@ -21,14 +21,14 @@ #define CREATE_IFACE_TRY_COUNT_MAX 7u struct _NMSupplMgrCreateIfaceHandle { - NMSupplicantManager * self; + NMSupplicantManager *self; CList create_iface_lst; - GCancellable * cancellable; + GCancellable *cancellable; NMSupplicantManagerCreateInterfaceCb callback; gpointer callback_user_data; - NMShutdownWaitObjHandle * shutdown_handle; - NMRefString * name_owner; - GError * fail_on_idle_error; + NMShutdownWaitObjHandle *shutdown_handle; + NMRefString *name_owner; + GError *fail_on_idle_error; NMSupplicantDriver driver; int ifindex; guint fail_on_idle_id; @@ -98,19 +98,19 @@ NM_CACHED_QUARK_FCN("nm-supplicant-error-quark", nm_supplicant_error_quark); /*****************************************************************************/ static void _create_iface_proceed_all(NMSupplicantManager *self, GError *error); -static void _supp_iface_add(NMSupplicantManager * self, - NMRefString * iface_path, +static void _supp_iface_add(NMSupplicantManager *self, + NMRefString *iface_path, NMSupplicantInterface *supp_iface); -static void _supp_iface_remove_one(NMSupplicantManager * self, +static void _supp_iface_remove_one(NMSupplicantManager *self, NMSupplicantInterface *supp_iface, gboolean force_remove_from_supplicant, - const char * reason); -static void _create_iface_dbus_call_get_interface(NMSupplicantManager * self, + const char *reason); +static void _create_iface_dbus_call_get_interface(NMSupplicantManager *self, NMSupplMgrCreateIfaceHandle *handle, - const char * ifname); -static void _create_iface_dbus_call_create_interface(NMSupplicantManager * self, + const char *ifname); +static void _create_iface_dbus_call_create_interface(NMSupplicantManager *self, NMSupplMgrCreateIfaceHandle *handle, - const char * ifname); + const char *ifname); static gboolean _create_iface_fail_on_idle_cb(gpointer user_data); static gboolean _available_reset_cb(gpointer user_data); @@ -172,8 +172,8 @@ _caps_set(NMSupplicantManagerPrivate *priv, NMSupplCapType type, NMTernary value static void _dbus_call_remove_interface(GDBusConnection *dbus_connection, - const char * name_owner, - const char * iface_path) + const char *name_owner, + const char *iface_path) { nm_assert(G_IS_DBUS_CONNECTION(dbus_connection)); nm_assert(name_owner); @@ -195,8 +195,8 @@ _dbus_call_remove_interface(GDBusConnection *dbus_connection, void _nm_supplicant_manager_dbus_call_remove_interface(NMSupplicantManager *self, - const char * name_owner, - const char * iface_path) + const char *name_owner, + const char *iface_path) { _dbus_call_remove_interface(NM_SUPPLICANT_MANAGER_GET_PRIVATE(self)->dbus_connection, name_owner, @@ -208,8 +208,8 @@ _nm_supplicant_manager_dbus_call_remove_interface(NMSupplicantManager *self, static void on_supplicant_wfd_ies_set(GObject *source_object, GAsyncResult *result, gpointer user_data) { - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source_object), result, &error); if (!res) @@ -265,10 +265,10 @@ nm_supplicant_manager_set_wfd_ies(NMSupplicantManager *self, GBytes *wfd_ies) static gboolean _poke_name_owner_timeout_cb(gpointer user_data) { - NMSupplicantManager * self = user_data; - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); - gs_free_error GError *error = NULL; - gboolean available_changed = FALSE; + NMSupplicantManager *self = user_data; + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); + gs_free_error GError *error = NULL; + gboolean available_changed = FALSE; nm_assert(!priv->name_owner); @@ -307,8 +307,8 @@ _poke_name_owner_timeout_cb(gpointer user_data) static void _poke_name_owner_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -347,8 +347,8 @@ _poke_name_owner(NMSupplicantManager *self) static void _create_iface_complete(NMSupplMgrCreateIfaceHandle *handle, - NMSupplicantInterface * supp_iface, - GError * error) + NMSupplicantInterface *supp_iface, + GError *error) { nm_assert(!supp_iface || NM_IS_SUPPLICANT_INTERFACE(supp_iface)); nm_assert((!!supp_iface) != (!!error)); @@ -385,13 +385,13 @@ _create_iface_complete(NMSupplMgrCreateIfaceHandle *handle, } static void -_create_iface_add(NMSupplicantManager * self, +_create_iface_add(NMSupplicantManager *self, NMSupplMgrCreateIfaceHandle *handle, - const char * iface_path_str, + const char *iface_path_str, gboolean created_by_us) { - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); - nm_auto_ref_string NMRefString *iface_path = NULL; + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); + nm_auto_ref_string NMRefString *iface_path = NULL; gs_unref_object NMSupplicantInterface *supp_iface = NULL; iface_path = nm_ref_string_new(iface_path_str); @@ -425,13 +425,13 @@ _create_iface_add(NMSupplicantManager * self, static void _create_iface_dbus_call_get_interface_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - GDBusConnection * dbus_connection = G_DBUS_CONNECTION(source); + GDBusConnection *dbus_connection = G_DBUS_CONNECTION(source); NMSupplMgrCreateIfaceHandle *handle; - NMSupplicantManager * self; - NMSupplicantManagerPrivate * priv; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; - const char * iface_path_str; + NMSupplicantManager *self; + NMSupplicantManagerPrivate *priv; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + const char *iface_path_str; res = g_dbus_connection_call_finish(dbus_connection, result, &error); @@ -478,18 +478,18 @@ _create_iface_dbus_call_get_interface_cb(GObject *source, GAsyncResult *result, } static void -_create_iface_dbus_call_create_interface_cb(GObject * source, +_create_iface_dbus_call_create_interface_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - GDBusConnection * dbus_connection = G_DBUS_CONNECTION(source); + GDBusConnection *dbus_connection = G_DBUS_CONNECTION(source); NMSupplMgrCreateIfaceHandle *handle = user_data; - NMSupplicantManager * self; - NMSupplicantManagerPrivate * priv; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; - const char * iface_path_str; - char ifname[NMP_IFNAMSIZ]; + NMSupplicantManager *self; + NMSupplicantManagerPrivate *priv; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + const char *iface_path_str; + char ifname[NMP_IFNAMSIZ]; res = g_dbus_connection_call_finish(dbus_connection, result, &error); @@ -553,9 +553,9 @@ _create_iface_dbus_call_create_interface_cb(GObject * source, } static void -_create_iface_dbus_call_get_interface(NMSupplicantManager * self, +_create_iface_dbus_call_get_interface(NMSupplicantManager *self, NMSupplMgrCreateIfaceHandle *handle, - const char * ifname) + const char *ifname) { NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); @@ -577,9 +577,9 @@ _create_iface_dbus_call_get_interface(NMSupplicantManager * self, } static void -_create_iface_dbus_call_create_interface(NMSupplicantManager * self, +_create_iface_dbus_call_create_interface(NMSupplicantManager *self, NMSupplMgrCreateIfaceHandle *handle, - const char * ifname) + const char *ifname) { NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); GVariantBuilder builder; @@ -676,13 +676,13 @@ _create_iface_fail_on_idle_cb(gpointer user_data) } NMSupplMgrCreateIfaceHandle * -nm_supplicant_manager_create_interface(NMSupplicantManager * self, +nm_supplicant_manager_create_interface(NMSupplicantManager *self, int ifindex, NMSupplicantDriver driver, NMSupplicantManagerCreateInterfaceCb callback, gpointer user_data) { - NMSupplicantManagerPrivate * priv; + NMSupplicantManagerPrivate *priv; NMSupplMgrCreateIfaceHandle *handle; g_return_val_if_fail(NM_IS_SUPPLICANT_MANAGER(self), NULL); @@ -751,7 +751,7 @@ nm_supplicant_manager_create_interface(NMSupplicantManager * self static void _create_iface_proceed_all(NMSupplicantManager *self, GError *error) { - NMSupplicantManagerPrivate * priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); NMSupplMgrCreateIfaceHandle *handle; nm_assert(error || priv->name_owner); @@ -810,8 +810,8 @@ nm_supplicant_manager_create_interface_cancel(NMSupplMgrCreateIfaceHandle *handl NMSupplicantInterface * nm_supplicant_manager_create_interface_from_path(NMSupplicantManager *self, const char *object_path) { - NMSupplicantManagerPrivate *priv; - NMSupplicantInterface * supp_iface; + NMSupplicantManagerPrivate *priv; + NMSupplicantInterface *supp_iface; nm_auto_ref_string NMRefString *iface_path = NULL; g_return_val_if_fail(NM_IS_SUPPLICANT_MANAGER(self), NULL); @@ -837,17 +837,17 @@ nm_supplicant_manager_create_interface_from_path(NMSupplicantManager *self, cons static void _dbus_interface_removed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMSupplicantManager * self = user_data; - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); - NMSupplicantInterface * supp_iface; - const char * iface_path_str; + NMSupplicantManager *self = user_data; + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); + NMSupplicantInterface *supp_iface; + const char *iface_path_str; nm_auto_ref_string NMRefString *iface_path = NULL; nm_assert(nm_streq(sender_name, priv->name_owner->str)); @@ -871,7 +871,7 @@ _dbus_interface_removed_cb(GDBusConnection *connection, static void _dbus_get_capabilities_cb(GVariant *res, GError *error, gpointer user_data) { - NMSupplicantManager * self; + NMSupplicantManager *self; NMSupplicantManagerPrivate *priv; if (nm_utils_error_is_cancelled(error)) @@ -905,15 +905,15 @@ _dbus_get_capabilities_cb(GVariant *res, GError *error, gpointer user_data) if (res) { nm_auto_free_variant_iter GVariantIter *res_iter = NULL; - const char * res_key; - GVariant * res_val; + const char *res_key; + GVariant *res_val; g_variant_get(res, "(a{sv})", &res_iter); while (g_variant_iter_loop(res_iter, "{&sv}", &res_key, &res_val)) { if (nm_streq(res_key, "Capabilities")) { if (g_variant_is_of_type(res_val, G_VARIANT_TYPE_STRING_ARRAY)) { gs_free const char **array = NULL; - const char ** a; + const char **a; array = g_variant_get_strv(res_val, NULL); _caps_set(priv, NM_SUPPL_CAP_TYPE_AP, NM_TERNARY_FALSE); @@ -962,7 +962,7 @@ _dbus_get_capabilities_cb(GVariant *res, GError *error, gpointer user_data) if (nm_streq(res_key, "EapMethods")) { if (g_variant_is_of_type(res_val, G_VARIANT_TYPE_STRING_ARRAY)) { gs_free const char **array = NULL; - const char ** a; + const char **a; array = g_variant_get_strv(res_val, NULL); if (array) { @@ -1013,7 +1013,7 @@ _dbus_get_capabilities_cb(GVariant *res, GError *error, gpointer user_data) /*****************************************************************************/ void -_nm_supplicant_manager_unregister_interface(NMSupplicantManager * self, +_nm_supplicant_manager_unregister_interface(NMSupplicantManager *self, NMSupplicantInterface *supp_iface) { NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); @@ -1029,8 +1029,8 @@ _nm_supplicant_manager_unregister_interface(NMSupplicantManager * self, } static void -_supp_iface_add(NMSupplicantManager * self, - NMRefString * iface_path, +_supp_iface_add(NMSupplicantManager *self, + NMRefString *iface_path, NMSupplicantInterface *supp_iface) { NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); @@ -1041,10 +1041,10 @@ _supp_iface_add(NMSupplicantManager * self, } static void -_supp_iface_remove_one(NMSupplicantManager * self, +_supp_iface_remove_one(NMSupplicantManager *self, NMSupplicantInterface *supp_iface, gboolean force_remove_from_supplicant, - const char * reason) + const char *reason) { #if NM_MORE_ASSERTS _nm_unused gs_unref_object NMSupplicantInterface *supp_iface_keep_alive = @@ -1064,10 +1064,10 @@ _supp_iface_remove_one(NMSupplicantManager * self, static void _supp_iface_remove_all(NMSupplicantManager *self, gboolean force_remove_from_supplicant, - const char * reason) + const char *reason) { NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); - NMSupplicantInterface * supp_iface; + NMSupplicantInterface *supp_iface; while ((supp_iface = c_list_first_entry(&priv->supp_lst_head, NMSupplicantInterface, supp_lst))) _supp_iface_remove_one(self, supp_iface, force_remove_from_supplicant, reason); @@ -1078,7 +1078,7 @@ _supp_iface_remove_all(NMSupplicantManager *self, static gboolean _available_reset_cb(gpointer user_data) { - NMSupplicantManager * self = user_data; + NMSupplicantManager *self = user_data; NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); priv->available_reset_id = 0; @@ -1209,16 +1209,16 @@ name_owner_changed(NMSupplicantManager *self, const char *name_owner, gboolean f static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { gs_unref_object NMSupplicantManager *self = g_object_ref(user_data); - NMSupplicantManagerPrivate * priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); - const char * name_owner; + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); + const char *name_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) return; @@ -1244,7 +1244,7 @@ name_owner_changed_cb(GDBusConnection *connection, static void get_name_owner_cb(const char *name_owner, GError *error, gpointer user_data) { - NMSupplicantManager * self = user_data; + NMSupplicantManager *self = user_data; NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); if (!name_owner && nm_utils_error_is_cancelled(error)) @@ -1297,7 +1297,7 @@ nm_supplicant_manager_init(NMSupplicantManager *self) static void dispose(GObject *object) { - NMSupplicantManager * self = (NMSupplicantManager *) object; + NMSupplicantManager *self = (NMSupplicantManager *) object; NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self); _supp_iface_remove_all(self, TRUE, "NMSupplicantManager is disposing"); diff --git a/src/core/supplicant/nm-supplicant-manager.h b/src/core/supplicant/nm-supplicant-manager.h index 3000d064bb..ab163b0dd5 100644 --- a/src/core/supplicant/nm-supplicant-manager.h +++ b/src/core/supplicant/nm-supplicant-manager.h @@ -33,21 +33,21 @@ NMSupplicantManager *nm_supplicant_manager_get(void); NMTernary nm_supplicant_manager_is_available(NMSupplicantManager *self); GDBusConnection *nm_supplicant_manager_get_dbus_connection(NMSupplicantManager *self); -NMRefString * nm_supplicant_manager_get_dbus_name_owner(NMSupplicantManager *self); +NMRefString *nm_supplicant_manager_get_dbus_name_owner(NMSupplicantManager *self); NMSupplCapMask nm_supplicant_manager_get_global_capabilities(NMSupplicantManager *self); void nm_supplicant_manager_set_wfd_ies(NMSupplicantManager *self, GBytes *wfd_ies); typedef struct _NMSupplMgrCreateIfaceHandle NMSupplMgrCreateIfaceHandle; -typedef void (*NMSupplicantManagerCreateInterfaceCb)(NMSupplicantManager * self, +typedef void (*NMSupplicantManagerCreateInterfaceCb)(NMSupplicantManager *self, NMSupplMgrCreateIfaceHandle *handle, - NMSupplicantInterface * iface, - GError * error, + NMSupplicantInterface *iface, + GError *error, gpointer user_data); NMSupplMgrCreateIfaceHandle * -nm_supplicant_manager_create_interface(NMSupplicantManager * self, +nm_supplicant_manager_create_interface(NMSupplicantManager *self, int ifindex, NMSupplicantDriver driver, NMSupplicantManagerCreateInterfaceCb callback, @@ -60,11 +60,11 @@ NMSupplicantInterface *nm_supplicant_manager_create_interface_from_path(NMSuppli /*****************************************************************************/ -void _nm_supplicant_manager_unregister_interface(NMSupplicantManager * self, +void _nm_supplicant_manager_unregister_interface(NMSupplicantManager *self, NMSupplicantInterface *supp_iface); void _nm_supplicant_manager_dbus_call_remove_interface(NMSupplicantManager *self, - const char * name_owner, - const char * iface_path); + const char *name_owner, + const char *iface_path); #endif /* __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ */ diff --git a/src/core/supplicant/nm-supplicant-settings-verify.c b/src/core/supplicant/nm-supplicant-settings-verify.c index ceb4b6ae8f..566173af75 100644 --- a/src/core/supplicant/nm-supplicant-settings-verify.c +++ b/src/core/supplicant/nm-supplicant-settings-verify.c @@ -11,8 +11,8 @@ #include struct Opt { - const char * key; - const char *const * str_allowed; + const char *key; + const char *const *str_allowed; const NMSupplOptType type; const guint32 int_low; /* Inclusive */ const guint32 int_high; /* Inclusive; max length for strings */ diff --git a/src/core/supplicant/nm-supplicant-types.h b/src/core/supplicant/nm-supplicant-types.h index 743ef8f028..d5cf1bf704 100644 --- a/src/core/supplicant/nm-supplicant-types.h +++ b/src/core/supplicant/nm-supplicant-types.h @@ -160,7 +160,7 @@ typedef struct _NMSupplicantBssInfo { NMSupplicantInterface *_self; CList _bss_lst; - GCancellable * _init_cancellable; + GCancellable *_init_cancellable; GBytes *ssid; @@ -194,7 +194,7 @@ typedef struct _NMSupplicantPeerInfo { CList _peer_lst; NMSupplicantInterface *_self; - GCancellable * _init_cancellable; + GCancellable *_init_cancellable; char *device_name; char *manufacturer; diff --git a/src/core/supplicant/tests/test-supplicant-config.c b/src/core/supplicant/tests/test-supplicant-config.c index 0cf35d0e5d..53c5f70f3c 100644 --- a/src/core/supplicant/tests/test-supplicant-config.c +++ b/src/core/supplicant/tests/test-supplicant-config.c @@ -26,14 +26,14 @@ /*****************************************************************************/ static gboolean -validate_opt(const char * detail, - GVariant * config, - const char * key, +validate_opt(const char *detail, + GVariant *config, + const char *key, NMSupplOptType val_type, gconstpointer expected) { - char * config_key; - GVariant * config_value; + char *config_key; + GVariant *config_value; gboolean found = FALSE; GVariantIter iter; @@ -86,17 +86,17 @@ validate_opt(const char * detail, } static GVariant * -build_supplicant_config(NMConnection * connection, +build_supplicant_config(NMConnection *connection, guint mtu, guint fixed_freq, NMSupplCapMask capabilities) { gs_unref_object NMSupplicantConfig *config = NULL; - gs_free_error GError * error = NULL; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity *s_wsec; - NMSetting8021x * s_8021x; - gboolean success; + gs_free_error GError *error = NULL; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSetting8021x *s_8021x; + gboolean success; config = nm_supplicant_config_new(capabilities); @@ -136,11 +136,11 @@ build_supplicant_config(NMConnection * connection, static NMConnection * new_basic_connection(const char *id, GBytes *ssid, const char *bssid_str) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWireless * s_wifi; - NMSettingIPConfig * s_ip4; - gs_free char * uuid = nm_utils_uuid_generate(); + NMSettingWireless *s_wifi; + NMSettingIPConfig *s_ip4; + gs_free char *uuid = nm_utils_uuid_generate(); connection = nm_simple_connection_new(); @@ -183,13 +183,13 @@ new_basic_connection(const char *id, GBytes *ssid, const char *bssid_str) static void test_wifi_open(void) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *config_dict = NULL; - gboolean success; - GError * error = NULL; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - const char * bssid_str = "11:22:33:44:55:66"; + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *config_dict = NULL; + gboolean success; + GError *error = NULL; + const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + const char *bssid_str = "11:22:33:44:55:66"; connection = new_basic_connection("Test Wifi Open", ssid, bssid_str); success = nm_connection_verify(connection, &error); @@ -216,24 +216,24 @@ test_wifi_open(void) } static void -test_wifi_wep_key(const char * detail, +test_wifi_wep_key(const char *detail, gboolean test_bssid, NMWepKeyType wep_type, - const char * key_data, + const char *key_data, const unsigned char *expected, size_t expected_size) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *config_dict = NULL; - NMSettingWirelessSecurity *s_wsec; - gboolean success; - GError * error = NULL; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - const char * bssid_str = "11:22:33:44:55:66"; - gs_unref_bytes GBytes *wep_key_bytes = g_bytes_new(expected, expected_size); - const char * bgscan_data = "simple:30:-70:86400"; - gs_unref_bytes GBytes *bgscan = g_bytes_new(bgscan_data, strlen(bgscan_data)); + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *config_dict = NULL; + NMSettingWirelessSecurity *s_wsec; + gboolean success; + GError *error = NULL; + const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + const char *bssid_str = "11:22:33:44:55:66"; + gs_unref_bytes GBytes *wep_key_bytes = g_bytes_new(expected, expected_size); + const char *bgscan_data = "simple:30:-70:86400"; + gs_unref_bytes GBytes *bgscan = g_bytes_new(bgscan_data, strlen(bgscan_data)); connection = new_basic_connection("Test Wifi WEP Key", ssid, test_bssid ? bssid_str : NULL); @@ -287,17 +287,17 @@ test_wifi_wep_key(const char * detail, static void test_wifi_wep(void) { - const char * key1 = "12345"; + const char *key1 = "12345"; const unsigned char key1_expected[] = {0x31, 0x32, 0x33, 0x34, 0x35}; - const char * key2 = "ascii test$$$"; + const char *key2 = "ascii test$$$"; const unsigned char key2_expected[] = {0x61, 0x73, 0x63, 0x69, 0x69, 0x20, 0x74, 0x65, 0x73, 0x74, 0x24, 0x24, 0x24}; - const char * key3 = "abcdef1234"; + const char *key3 = "abcdef1234"; const unsigned char key3_expected[] = {0xab, 0xcd, 0xef, 0x12, 0x34}; - const char * key4 = "96aec785c6392675f87f592972"; + const char *key4 = "96aec785c6392675f87f592972"; const unsigned char key4_expected[] = {0x96, 0xae, 0xc7, 0x85, 0xc6, 0x39, 0x26, 0x75, 0xf8, 0x7f, 0x59, 0x29, 0x72}; - const char * key5 = "r34lly l33t w3p p4ssphr4s3 for t3st1ng"; + const char *key5 = "r34lly l33t w3p p4ssphr4s3 for t3st1ng"; const unsigned char key5_expected[] = {0xce, 0x68, 0x8b, 0x35, 0xf6, 0x0a, 0x2b, 0xbf, 0xc9, 0x8f, 0xed, 0x10, 0xda}; @@ -349,22 +349,22 @@ test_wifi_wep(void) } static void -test_wifi_wpa_psk(const char * detail, +test_wifi_wpa_psk(const char *detail, NMSupplOptType key_type, - const char * key_data, - const unsigned char * expected, + const char *key_data, + const unsigned char *expected, size_t expected_size, NMSettingWirelessSecurityPmf pmf) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *config_dict = NULL; - NMSettingWirelessSecurity *s_wsec; - gboolean success; - GError * error = NULL; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - const char * bssid_str = "11:22:33:44:55:66"; - gs_unref_bytes GBytes *wpa_psk_bytes = g_bytes_new(expected, expected_size); + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *config_dict = NULL; + NMSettingWirelessSecurity *s_wsec; + gboolean success; + GError *error = NULL; + const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + const char *bssid_str = "11:22:33:44:55:66"; + gs_unref_bytes GBytes *wpa_psk_bytes = g_bytes_new(expected, expected_size); connection = new_basic_connection("Test Wifi WPA PSK", ssid, bssid_str); @@ -461,15 +461,15 @@ test_wifi_wpa_psk(const char * detail, static void test_wifi_sae_psk(const char *psk) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *config_dict = NULL; - NMSettingWirelessSecurity *s_wsec; - gboolean success; - GError * error = NULL; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - const char * bssid_str = "11:22:33:44:55:66"; - int short_psk = strlen(psk) < 8; + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *config_dict = NULL; + NMSettingWirelessSecurity *s_wsec; + gboolean success; + GError *error = NULL; + const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + const char *bssid_str = "11:22:33:44:55:66"; + int short_psk = strlen(psk) < 8; connection = new_basic_connection("Test Wifi SAE", ssid, bssid_str); @@ -537,12 +537,12 @@ test_wifi_sae(void) static void test_wifi_wpa_psk_types(void) { - const char * key1 = "d4721e911461d3cdef9793858e977fcda091779243abb7316c2f11605a160893"; + const char *key1 = "d4721e911461d3cdef9793858e977fcda091779243abb7316c2f11605a160893"; const unsigned char key1_expected[] = {0xd4, 0x72, 0x1e, 0x91, 0x14, 0x61, 0xd3, 0xcd, 0xef, 0x97, 0x93, 0x85, 0x8e, 0x97, 0x7f, 0xcd, 0xa0, 0x91, 0x77, 0x92, 0x43, 0xab, 0xb7, 0x31, 0x6c, 0x2f, 0x11, 0x60, 0x5a, 0x16, 0x08, 0x93}; - const char * key2 = "r34lly l33t wp4 p4ssphr4s3 for t3st1ng"; + const char *key2 = "r34lly l33t wp4 p4ssphr4s3 for t3st1ng"; test_wifi_wpa_psk("wifi-wpa-psk-hex", NM_SUPPL_OPT_TYPE_BYTES, @@ -565,16 +565,16 @@ test_wifi_wpa_psk_types(void) } static NMConnection * -generate_wifi_eap_connection(const char * id, - GBytes * ssid, - const char * bssid_str, +generate_wifi_eap_connection(const char *id, + GBytes *ssid, + const char *bssid_str, NMSettingWirelessSecurityFils fils) { - NMConnection * connection = NULL; + NMConnection *connection = NULL; NMSettingWirelessSecurity *s_wsec; - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; - GError * error = NULL; + GError *error = NULL; connection = new_basic_connection(id, ssid, bssid_str); @@ -625,11 +625,11 @@ generate_wifi_eap_connection(const char * id, static NMConnection * generate_wifi_eap_suite_b_192_connection(const char *id, GBytes *ssid, const char *bssid_str) { - NMConnection * connection = NULL; + NMConnection *connection = NULL; NMSettingWirelessSecurity *s_wsec; - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; - GError * error = NULL; + GError *error = NULL; connection = new_basic_connection(id, ssid, bssid_str); @@ -669,12 +669,12 @@ generate_wifi_eap_suite_b_192_connection(const char *id, GBytes *ssid, const cha static void test_wifi_eap_locked_bssid(void) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *config_dict = NULL; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - const char * bssid_str = "11:22:33:44:55:66"; - guint32 mtu = 1100; + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *config_dict = NULL; + const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + const char *bssid_str = "11:22:33:44:55:66"; + guint32 mtu = 1100; connection = generate_wifi_eap_connection("Test Wifi EAP-TLS Locked", ssid, @@ -716,13 +716,13 @@ test_wifi_eap_locked_bssid(void) static void test_wifi_eap_unlocked_bssid(void) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *config_dict = NULL; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - const char * bgscan_data = "simple:30:-65:300"; - gs_unref_bytes GBytes *bgscan = g_bytes_new(bgscan_data, strlen(bgscan_data)); - guint32 mtu = 1100; + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *config_dict = NULL; + const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + const char *bgscan_data = "simple:30:-65:300"; + gs_unref_bytes GBytes *bgscan = g_bytes_new(bgscan_data, strlen(bgscan_data)); + guint32 mtu = 1100; connection = generate_wifi_eap_connection("Test Wifi EAP-TLS Unlocked", ssid, @@ -768,13 +768,13 @@ test_wifi_eap_unlocked_bssid(void) static void test_wifi_eap_fils_disabled(void) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *config_dict = NULL; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - const char * bgscan_data = "simple:30:-65:300"; - gs_unref_bytes GBytes *bgscan = g_bytes_new(bgscan_data, strlen(bgscan_data)); - guint32 mtu = 1100; + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *config_dict = NULL; + const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + const char *bgscan_data = "simple:30:-65:300"; + gs_unref_bytes GBytes *bgscan = g_bytes_new(bgscan_data, strlen(bgscan_data)); + guint32 mtu = 1100; connection = generate_wifi_eap_connection("Test Wifi FILS disabled", ssid, @@ -824,12 +824,12 @@ test_wifi_eap_fils_disabled(void) static void test_wifi_eap_suite_b_generation(void) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *config_dict = NULL; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - const char * bssid_str = "11:22:33:44:55:66"; - guint32 mtu = 1100; + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *config_dict = NULL; + const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + const char *bssid_str = "11:22:33:44:55:66"; + guint32 mtu = 1100; connection = generate_wifi_eap_suite_b_192_connection("EAP-TLS Suite B 192", ssid, bssid_str); diff --git a/src/core/tests/config/nm-test-device.c b/src/core/tests/config/nm-test-device.c index f724b03a5d..21f9bec4b4 100644 --- a/src/core/tests/config/nm-test-device.c +++ b/src/core/tests/config/nm-test-device.c @@ -69,7 +69,7 @@ nm_test_device_new(const char *hwaddr) static void nm_test_device_class_init(NMTestDeviceClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; diff --git a/src/core/tests/config/test-config.c b/src/core/tests/config/test-config.c index 6794fbf6cb..fa7fae0757 100644 --- a/src/core/tests/config/test-config.c +++ b/src/core/tests/config/test-config.c @@ -23,10 +23,10 @@ static void _assert_config_value(const NMConfigData *config_data, - const char * group, - const char * key, - const char * expected_value, - const char * file, + const char *group, + const char *key, + const char *expected_value, + const char *file, int line) { gs_free char *value = NULL; @@ -59,22 +59,22 @@ _assert_config_value(const NMConfigData *config_data, /*****************************************************************************/ static NMConfig * -setup_config(GError ** error, - const char * config_file, - const char * intern_config, +setup_config(GError **error, + const char *config_file, + const char *intern_config, const char *const *atomic_section_prefixes, - const char * config_dir, - const char * system_config_dir, + const char *config_dir, + const char *system_config_dir, ...) { va_list ap; - GPtrArray * args; - char ** argv, *arg; + GPtrArray *args; + char **argv, *arg; int argc; - GOptionContext * context; + GOptionContext *context; gboolean success; - NMConfig * config; - GError * local_error = NULL; + NMConfig *config; + GError *local_error = NULL; NMConfigCmdLineOptions *cli; g_assert(!error || !*error); @@ -149,9 +149,9 @@ static void test_config_simple(void) { gs_unref_object NMConfig *config = NULL; - gs_strfreev char ** plugins = NULL; - char * value; - const char * cvalue; + gs_strfreev char **plugins = NULL; + char *value; + const char *cvalue; gs_unref_object NMDevice *dev50 = nm_test_device_new("00:00:00:00:00:50"); gs_unref_object NMDevice *dev51 = nm_test_device_new("00:00:00:00:00:51"); gs_unref_object NMDevice *dev52 = nm_test_device_new("00:00:00:00:00:52"); @@ -277,7 +277,7 @@ static void test_config_override(void) { gs_unref_object NMConfig *config = NULL; - gs_strfreev char ** plugins = NULL; + gs_strfreev char **plugins = NULL; config = setup_config(NULL, TEST_DIR "/NetworkManager.conf", @@ -311,10 +311,10 @@ test_config_override(void) static void test_config_global_dns(void) { - NMConfig * config; + NMConfig *config; const NMGlobalDnsConfig *dns; - NMGlobalDnsDomain * domain; - const char *const * strv; + NMGlobalDnsDomain *domain; + const char *const *strv; config = setup_config(NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", NULL); @@ -382,8 +382,8 @@ static void test_config_connectivity_check(void) { #if WITH_CONCHECK - const char * CONFIG_INTERN = BUILD_DIR "/test-connectivity-check-intern.conf"; - NMConfig * config; + const char *CONFIG_INTERN = BUILD_DIR "/test-connectivity-check-intern.conf"; + NMConfig *config; NMConnectivity *connectivity; g_assert(g_file_set_contents(CONFIG_INTERN, "", 0, NULL)); @@ -425,9 +425,9 @@ static void test_config_no_auto_default(void) { NMConfig *config; - GError * error = NULL; + GError *error = NULL; int fd, nwrote; - char * state_file; + char *state_file; NMDevice *dev1, *dev2, *dev3, *dev4; fd = g_file_open_tmp(NULL, &state_file, &error); @@ -497,9 +497,9 @@ static void test_config_confdir(void) { gs_unref_object NMConfig *config = NULL; - gs_strfreev char ** plugins = NULL; - char * value; - GSList * specs; + gs_strfreev char **plugins = NULL; + char *value; + GSList *specs; config = setup_config(NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL); @@ -680,7 +680,7 @@ static void test_config_warnings(void) { gs_unref_object NMConfig *config = NULL; - const char *const * warnings; + const char *const *warnings; config = setup_config(NULL, TEST_DIR "/NetworkManager-warn.conf", @@ -716,15 +716,15 @@ test_config_warnings(void) /*****************************************************************************/ -typedef void (*TestSetValuesUserSetFcn)(NMConfig * config, +typedef void (*TestSetValuesUserSetFcn)(NMConfig *config, gboolean is_user, - GKeyFile * keyfile_user, + GKeyFile *keyfile_user, NMConfigChangeFlags *out_expected_changes); -typedef void (*TestSetValuesCheckStateFcn)(NMConfig * config, - NMConfigData * config_data, +typedef void (*TestSetValuesCheckStateFcn)(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data); + NMConfigData *old_data); typedef struct { NMConfigChangeFlags changes; @@ -732,10 +732,10 @@ typedef struct { } TestSetValuesConfigChangedData; static void -_set_values_config_changed_cb(NMConfig * config, - NMConfigData * config_data, +_set_values_config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, + NMConfigData *old_data, TestSetValuesConfigChangedData *config_changed_data) { g_assert(changes != NM_CONFIG_CHANGE_NONE); @@ -753,19 +753,19 @@ _set_values_config_changed_cb(NMConfig * config, } static void -_set_values_user(NMConfig * config, - const char * CONFIG_USER, +_set_values_user(NMConfig *config, + const char *CONFIG_USER, TestSetValuesUserSetFcn set_fcn, TestSetValuesCheckStateFcn check_state_fcn) { - GKeyFile * keyfile_user; - gboolean success; - gs_free_error GError * error = NULL; + GKeyFile *keyfile_user; + gboolean success; + gs_free_error GError *error = NULL; TestSetValuesConfigChangedData config_changed_data = { .changes = NM_CONFIG_CHANGE_NONE, .check_state_fcn = check_state_fcn, }; - NMConfigChangeFlags expected_changes = NM_CONFIG_CHANGE_NONE; + NMConfigChangeFlags expected_changes = NM_CONFIG_CHANGE_NONE; gs_unref_object NMConfigData *config_data_before = NULL; keyfile_user = nm_config_create_keyfile(); @@ -812,16 +812,16 @@ _set_values_user(NMConfig * config, } static void -_set_values_intern(NMConfig * config, +_set_values_intern(NMConfig *config, TestSetValuesUserSetFcn set_fcn, TestSetValuesCheckStateFcn check_state_fcn) { - GKeyFile * keyfile_intern; + GKeyFile *keyfile_intern; TestSetValuesConfigChangedData config_changed_data = { .changes = NM_CONFIG_CHANGE_NONE, .check_state_fcn = check_state_fcn, }; - NMConfigChangeFlags expected_changes = NM_CONFIG_CHANGE_NONE; + NMConfigChangeFlags expected_changes = NM_CONFIG_CHANGE_NONE; gs_unref_object NMConfigData *config_data_before = NULL; config_data_before = g_object_ref(nm_config_get_data(config)); @@ -860,9 +860,9 @@ _set_values_intern(NMConfig * config, } static void -_set_values_user_intern_section_set(NMConfig * config, +_set_values_user_intern_section_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, @@ -872,11 +872,11 @@ _set_values_user_intern_section_set(NMConfig * config, } static void -_set_values_user_intern_section_check(NMConfig * config, - NMConfigData * config_data, +_set_values_user_intern_section_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { g_assert(changes == NM_CONFIG_CHANGE_NONE); g_assert( @@ -884,9 +884,9 @@ _set_values_user_intern_section_check(NMConfig * config, } static void -_set_values_user_initial_values_set(NMConfig * config, +_set_values_user_initial_values_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_remove_group(keyfile, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN "section1", NULL); @@ -895,11 +895,11 @@ _set_values_user_initial_values_set(NMConfig * config, } static void -_set_values_user_initial_values_check(NMConfig * config, - NMConfigData * config_data, +_set_values_user_initial_values_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes == (NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_USER)); @@ -907,9 +907,9 @@ _set_values_user_initial_values_check(NMConfig * config, } static void -_set_values_intern_internal_set(NMConfig * config, +_set_values_intern_internal_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, @@ -921,11 +921,11 @@ _set_values_intern_internal_set(NMConfig * config, } static void -_set_values_intern_internal_check(NMConfig * config, - NMConfigData * config_data, +_set_values_intern_internal_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes @@ -938,9 +938,9 @@ _set_values_intern_internal_check(NMConfig * config, } static void -_set_values_user_atomic_section_1_set(NMConfig * config, +_set_values_user_atomic_section_1_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, "atomic-prefix-1.section-a", "key1", "user-value1"); @@ -952,11 +952,11 @@ _set_values_user_atomic_section_1_set(NMConfig * config, } static void -_set_values_user_atomic_section_1_check(NMConfig * config, - NMConfigData * config_data, +_set_values_user_atomic_section_1_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes == (NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_USER)); @@ -968,9 +968,9 @@ _set_values_user_atomic_section_1_check(NMConfig * config, } static void -_set_values_intern_atomic_section_1_set(NMConfig * config, +_set_values_intern_atomic_section_1_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, "atomic-prefix-1.section-a", "key1", "intern-value1"); @@ -982,11 +982,11 @@ _set_values_intern_atomic_section_1_set(NMConfig * config, } static void -_set_values_intern_atomic_section_1_check(NMConfig * config, - NMConfigData * config_data, +_set_values_intern_atomic_section_1_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes @@ -1005,9 +1005,9 @@ _set_values_intern_atomic_section_1_check(NMConfig * config, } static void -_set_values_user_atomic_section_2_set(NMConfig * config, +_set_values_user_atomic_section_2_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, "atomic-prefix-1.section-a", "key1", "user-value1-x"); @@ -1019,11 +1019,11 @@ _set_values_user_atomic_section_2_set(NMConfig * config, } static void -_set_values_user_atomic_section_2_check(NMConfig * config, - NMConfigData * config_data, +_set_values_user_atomic_section_2_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes @@ -1040,9 +1040,9 @@ _set_values_user_atomic_section_2_check(NMConfig * config, } static void -_set_values_intern_atomic_section_2_set(NMConfig * config, +_set_values_intern_atomic_section_2_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { /* let's hide an atomic section and one key. */ @@ -1068,11 +1068,11 @@ _set_values_intern_atomic_section_2_set(NMConfig * config, } static void -_set_values_intern_atomic_section_2_check(NMConfig * config, - NMConfigData * config_data, +_set_values_intern_atomic_section_2_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes @@ -1100,9 +1100,9 @@ static void test_config_set_values(void) { gs_unref_object NMConfig *config = NULL; - const char * CONFIG_USER = BUILD_DIR "/test-set-values-user.conf"; - const char * CONFIG_INTERN = BUILD_DIR "/test-set-values-intern.conf"; - const char * atomic_section_prefixes[] = { + const char *CONFIG_USER = BUILD_DIR "/test-set-values-user.conf"; + const char *CONFIG_INTERN = BUILD_DIR "/test-set-values-intern.conf"; + const char *atomic_section_prefixes[] = { "atomic-prefix-1.", "atomic-prefix-2.", NULL, @@ -1150,10 +1150,10 @@ test_config_set_values(void) /*****************************************************************************/ static void -_test_signal_config_changed_cb(NMConfig * config, - NMConfigData * config_data, +_test_signal_config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, + NMConfigData *old_data, gpointer user_data) { const NMConfigChangeFlags *expected = user_data; @@ -1168,10 +1168,10 @@ _test_signal_config_changed_cb(NMConfig * config, } static void -_test_signal_config_changed_cb2(NMConfig * config, - NMConfigData * config_data, +_test_signal_config_changed_cb2(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, + NMConfigData *old_data, gpointer user_data) { const NMConfigChangeFlags *expected = user_data; @@ -1183,8 +1183,8 @@ _test_signal_config_changed_cb2(NMConfig * config, static void test_config_signal(void) { - gs_unref_object NMConfig *config = NULL; - NMConfigChangeFlags expected; + gs_unref_object NMConfig *config = NULL; + NMConfigChangeFlags expected; gs_unref_object NMConfigData *config_data_orig = NULL; config = @@ -1234,7 +1234,7 @@ test_config_enable(void) { gs_unref_object NMConfig *config = NULL; guint match_nm_version = _nm_config_match_nm_version; - char * match_env = g_strdup(_nm_config_match_env); + char *match_env = g_strdup(_nm_config_match_env); nm_clear_g_free(&_nm_config_match_env); _nm_config_match_env = g_strdup("something-else"); @@ -1278,11 +1278,11 @@ test_config_enable(void) static void test_config_state_file(void) { - NMConfig * config; - const NMConfigState *state; + NMConfig *config; + const NMConfigState *state; gs_free_error GError *error = NULL; gboolean ret; - gs_free char * file_data = NULL; + gs_free char *file_data = NULL; gsize file_size; const char *const TMP_FILE = BUILD_DIR "/tmp.state"; diff --git a/src/core/tests/test-core-with-expect.c b/src/core/tests/test-core-with-expect.c index 01784863b9..eca098c438 100644 --- a/src/core/tests/test-core-with-expect.c +++ b/src/core/tests/test-core-with-expect.c @@ -98,7 +98,7 @@ test_nm_utils_kill_child_async_do(const char *name, int sig, guint32 wait_before_kill_msec, gboolean expected_success, - const int * expected_child_status) + const int *expected_child_status) { gboolean success; struct test_nm_utils_kill_child_async_data data = {}; @@ -135,7 +135,7 @@ test_nm_utils_kill_child_sync_do(const char *name, int sig, guint32 wait_before_kill_msec, gboolean expected_success, - const int * expected_child_status) + const int *expected_child_status) { gboolean success; int child_status = -1; @@ -226,11 +226,11 @@ static void do_test_nm_utils_kill_child(void) { GLogLevelFlags fatal_mask; - char * argv_watchdog[] = { + char *argv_watchdog[] = { "bash", "-c", "sleep 4; " - "kill -KILL 0; #watchdog for #" TEST_TOKEN, + "kill -KILL 0; #watchdog for #" TEST_TOKEN, NULL, }; char *argv1[] = { @@ -464,7 +464,7 @@ test_nm_utils_kill_child(void) static void _remove_at_indexes_init_random_idx(GArray *idx, guint array_len, guint idx_len) { - GRand * rand = nmtst_get_rand(); + GRand *rand = nmtst_get_rand(); gs_free char *mask = NULL; guint i, max_test_idx; @@ -515,7 +515,7 @@ _remove_at_indexes_init_random_idx(GArray *idx, guint array_len, guint idx_len) static void test_nm_utils_array_remove_at_indexes(void) { - gs_unref_array GArray *idx = NULL, *array = NULL; + gs_unref_array GArray *idx = NULL, *array = NULL; gs_unref_hashtable GHashTable *unique = NULL; guint i_len, i_idx_len, i_rnd, i; diff --git a/src/core/tests/test-core.c b/src/core/tests/test-core.c index 3524cb170d..f61d66d911 100644 --- a/src/core/tests/test-core.c +++ b/src/core/tests/test-core.c @@ -389,11 +389,11 @@ test_nm_utils_sysctl_ip_conf_path(void) static NMConnection * _match_connection_new(void) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4, *s_ip6; - char * uuid; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4, *s_ip6; + char *uuid; connection = nm_simple_connection_new(); @@ -433,7 +433,7 @@ _match_connection_new(void) } static NMConnection * -_match_connection(GSList * connections, +_match_connection(GSList *connections, NMConnection *original, gboolean device_has_carrier, gint64 default_v4_metric, @@ -466,8 +466,8 @@ _match_connection(GSList * connections, static void test_connection_match_basic(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip4; orig = _match_connection_new(); @@ -495,8 +495,8 @@ test_connection_match_basic(void) static void test_connection_match_ip6_method(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip6; orig = _match_connection_new(); @@ -534,8 +534,8 @@ test_connection_match_ip6_method(void) static void test_connection_match_ip6_method_ignore(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip6; orig = _match_connection_new(); @@ -570,8 +570,8 @@ test_connection_match_ip6_method_ignore(void) static void test_connection_match_ip6_method_ignore_auto(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip6; orig = _match_connection_new(); @@ -606,8 +606,8 @@ test_connection_match_ip6_method_ignore_auto(void) static void test_connection_match_ip4_method(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip4; orig = _match_connection_new(); @@ -649,8 +649,8 @@ test_connection_match_ip4_method(void) static void test_connection_match_interface_name(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingConnection *s_con; orig = _match_connection_new(); @@ -679,11 +679,11 @@ test_connection_match_interface_name(void) static void test_connection_match_wired(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingWired *s_wired; - char * subchan_arr[] = {"0.0.8000", "0.0.8001", "0.0.8002", NULL}; - const char * mac = "52:54:00:ab:db:23"; + char *subchan_arr[] = {"0.0.8000", "0.0.8001", "0.0.8002", NULL}; + const char *mac = "52:54:00:ab:db:23"; orig = _match_connection_new(); copy = nm_simple_connection_new_clone(orig); @@ -722,10 +722,10 @@ test_connection_match_wired(void) static void test_connection_match_wired2(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingWired *s_wired; - const char * mac = "52:54:00:ab:db:23"; + const char *mac = "52:54:00:ab:db:23"; orig = _match_connection_new(); s_wired = nm_connection_get_setting_wired(orig); @@ -756,8 +756,8 @@ test_connection_match_wired2(void) static void test_connection_match_cloned_mac(void) { - NMConnection * orig, *exact, *fuzzy, *matched; - GSList * connections = NULL; + NMConnection *orig, *exact, *fuzzy, *matched; + GSList *connections = NULL; NMSettingWired *s_wired; orig = _match_connection_new(); @@ -794,11 +794,11 @@ test_connection_match_cloned_mac(void) static void test_connection_no_match_ip4_addr(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip4, *s_ip6; - NMIPAddress * nm_addr; - GError * error = NULL; + NMIPAddress *nm_addr; + GError *error = NULL; orig = _match_connection_new(); copy = nm_simple_connection_new_clone(orig); @@ -858,11 +858,11 @@ test_connection_no_match_ip4_addr(void) static void test_connection_no_match_vlan(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingConnection *s_con; - NMSettingVlan * s_vlan_orig, *s_vlan_copy; - char * uuid; + NMSettingVlan *s_vlan_orig, *s_vlan_copy; + char *uuid; orig = nm_simple_connection_new(); s_con = (NMSettingConnection *) nm_setting_connection_new(); @@ -915,9 +915,9 @@ static void test_connection_match_ip4_routes1(void) { gs_unref_object NMConnection *orig = NULL, *copy = NULL; - NMConnection * matched; - nm_auto_free_slist GSList *connections = NULL; - NMSettingIPConfig * s_ip4; + NMConnection *matched; + nm_auto_free_slist GSList *connections = NULL; + NMSettingIPConfig *s_ip4; orig = _match_connection_new(); @@ -952,9 +952,9 @@ static void test_connection_match_ip4_routes2(void) { gs_unref_object NMConnection *orig = NULL, *copy = NULL; - NMConnection * matched; - nm_auto_free_slist GSList *connections = NULL; - NMSettingIPConfig * s_ip4; + NMConnection *matched; + nm_auto_free_slist GSList *connections = NULL; + NMSettingIPConfig *s_ip4; orig = _match_connection_new(); @@ -992,9 +992,9 @@ static void test_connection_match_ip6_routes(void) { gs_unref_object NMConnection *orig = NULL, *copy = NULL; - NMConnection * matched; - nm_auto_free_slist GSList *connections = NULL; - NMSettingIPConfig * s_ip6; + NMConnection *matched; + nm_auto_free_slist GSList *connections = NULL; + NMSettingIPConfig *s_ip6; orig = _match_connection_new(); @@ -1122,7 +1122,7 @@ test_wildcard_match(void) static NMConnection * _create_connection_autoconnect(const char *id, gboolean autoconnect, int autoconnect_priority) { - NMConnection * c; + NMConnection *c; NMSettingConnection *s_con; c = nmtst_create_minimal_connection(id, NULL, NM_SETTING_WIRED_SETTING_NAME, &s_con); @@ -1146,8 +1146,8 @@ _cmp_autoconnect_priority_p_with_data(gconstpointer pa, gconstpointer pb, gpoint static void _test_connection_sort_autoconnect_priority_one(NMConnection **list, gboolean shuffle) { - int i, j; - int count = 0; + int i, j; + int count = 0; gs_unref_ptrarray GPtrArray *connections = g_ptr_array_new(); while (list[count]) @@ -1253,7 +1253,7 @@ _test_match_spec_device(const GSList *specs, const char *match_str) NULL); if (match_str && g_str_has_prefix(match_str, MATCH_DRIVER)) { gs_free char *s = g_strdup(&match_str[NM_STRLEN(MATCH_DRIVER)]); - char * t; + char *t; t = strchr(s, '|'); if (t) { @@ -1266,15 +1266,15 @@ _test_match_spec_device(const GSList *specs, const char *match_str) } static void -_do_test_match_spec_device(const char * spec_str, +_do_test_match_spec_device(const char *spec_str, const char *const *matches, const char *const *no_matches, const char *const *neg_matches) { - GSList * specs, *specs_randperm = NULL, *specs_resplit, *specs_i, *specs_j; + GSList *specs, *specs_randperm = NULL, *specs_resplit, *specs_i, *specs_j; guint i; - gs_free char * specs_joined = NULL; - const char * s; + gs_free char *specs_joined = NULL; + const char *s; static const char *no_matches_default[] = {"e", "em", "em*", @@ -1463,16 +1463,16 @@ test_match_spec_device(void) /*****************************************************************************/ static void -_do_test_match_spec_config(const char * file, +_do_test_match_spec_config(const char *file, int line, - const char * spec_str, + const char *spec_str, guint version, guint v_maj, guint v_min, guint v_mic, NMMatchSpecMatchType expected) { - GSList * specs; + GSList *specs; NMMatchSpecMatchType match_result; guint c_maj, c_min, c_mic; @@ -1500,8 +1500,8 @@ _do_test_match_spec_config(const char * file, if (g_slist_length(specs) == 1 && !g_str_has_prefix(specs->data, "except:")) { /* there is only one spec in the list... test that we match except: */ - char * sss = g_strdup_printf("except:%s", (char *) specs->data); - GSList * specs2 = g_slist_append(NULL, sss); + char *sss = g_strdup_printf("except:%s", (char *) specs->data); + GSList *specs2 = g_slist_append(NULL, sss); NMMatchSpecMatchType match_result2; match_result2 = nm_match_spec_config(specs2, version, NULL); @@ -1731,9 +1731,9 @@ test_nm_utils_strbuf_append(void) #define _strbuf_append(buf, len, format, ...) \ G_STMT_START \ { \ - char ** _buf = (buf); \ - gsize * _len = (len); \ - const char * _str_iter; \ + char **_buf = (buf); \ + gsize *_len = (len); \ + const char *_str_iter; \ gs_free char *_str = NULL; \ \ switch (nmtst_get_rand_uint32() % 4) { \ @@ -1762,8 +1762,8 @@ test_nm_utils_strbuf_append(void) #define _strbuf_append_str(buf, len, str) \ G_STMT_START \ { \ - char ** _buf = (buf); \ - gsize * _len = (len); \ + char **_buf = (buf); \ + gsize *_len = (len); \ const char *_str = (str); \ \ switch (nmtst_get_rand_uint32() % 4) { \ @@ -1813,7 +1813,7 @@ test_nm_utils_strbuf_append(void) for (buf_len = 0; buf_len < 10; buf_len++) { for (rep = 0; rep < 50; rep++) { const int s_len = nmtst_get_rand_uint32() % (sizeof(str) - 5); - char * t_buf; + char *t_buf; gsize t_len; int test_mode; @@ -2044,7 +2044,7 @@ static void test_reverse_dns_ip6(void) { struct in6_addr addr; - GPtrArray * domains = g_ptr_array_new_full(8, g_free); + GPtrArray *domains = g_ptr_array_new_full(8, g_free); inet_pton(AF_INET6, "1234::56", &addr); nm_utils_get_reverse_dns_domains_ip_6(&addr, 16, domains); @@ -2097,11 +2097,11 @@ test_reverse_dns_ip6(void) /*****************************************************************************/ static void -do_test_stable_id_parse(const char * stable_id, +do_test_stable_id_parse(const char *stable_id, NMUtilsStableType expected_stable_type, - const char * expected_generated) + const char *expected_generated) { - gs_free char * generated = NULL; + gs_free char *generated = NULL; NMUtilsStableType stable_type; if (expected_stable_type == NM_UTILS_STABLE_TYPE_GENERATED) @@ -2263,7 +2263,7 @@ test_utils_file_is_in_path(void) const char *const *const _searches = (searches); \ const char *const *const _nameservers = (nameservers); \ const char *const *const _options = (options); \ - gs_free char * _content = NULL; \ + gs_free char *_content = NULL; \ \ _content = nmtst_dns_create_resolv_conf(_searches, _nameservers, _options); \ g_assert_cmpstr(_content, ==, expected); \ @@ -2443,9 +2443,9 @@ test_nm_utils_dhcp_client_id_systemd_node_specific(gconstpointer test_data) g_assert_cmpint(u64, ==, d->duid_id); for (i = 0; i < 2; i++) { - const gboolean legacy_unstable_byteorder = (i != 0); - gs_unref_bytes GBytes *client_id = NULL; - const guint8 * cid; + const gboolean legacy_unstable_byteorder = (i != 0); + gs_unref_bytes GBytes *client_id = NULL; + const guint8 *cid; guint32 iaid = d->iaid_ifname; guint32 tmp; @@ -2489,7 +2489,7 @@ _kernel_cmdline_match(gboolean expected_match, const char *const *patterns) { gs_free_error GError *error = NULL; - GError ** p_error = nmtst_get_rand_bool() ? &error : NULL; + GError **p_error = nmtst_get_rand_bool() ? &error : NULL; gboolean match; nm_assert(proc_cmdline); diff --git a/src/core/tests/test-dcb.c b/src/core/tests/test-dcb.c index fc591fcbc4..f85e90f990 100644 --- a/src/core/tests/test-dcb.c +++ b/src/core/tests/test-dcb.c @@ -18,7 +18,7 @@ static gboolean test_dcb_func(char **argv, guint which, gpointer user_data, GError **error) { DcbExpected *e = user_data; - char * f; + char *f; g_assert(argv[0] == NULL); argv[0] = (which == DCBTOOL) ? "dcbtool" : "fcoeadm"; @@ -49,7 +49,7 @@ test_dcb_fcoe(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -82,7 +82,7 @@ test_dcb_iscsi(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -115,7 +115,7 @@ test_dcb_fip(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -147,7 +147,7 @@ test_dcb_fip_default_prio(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -180,7 +180,7 @@ test_dcb_pfc(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -221,7 +221,7 @@ test_dcb_priority_groups(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; guint i; @@ -267,7 +267,7 @@ test_dcb_cleanup(void) "dcbtool sc eth0 dcb off", NULL}, }; - GError * error = NULL; + GError *error = NULL; gboolean success; success = _fcoe_cleanup("eth0", test_dcb_func, &expected, &error); @@ -292,7 +292,7 @@ test_fcoe_create(void) 0, {"fcoeadm -m vn2vn -c eth0", NULL}, }; - GError * error = NULL; + GError *error = NULL; gboolean success; NMSettingDcb *s_dcb; @@ -323,7 +323,7 @@ test_fcoe_cleanup(void) 0, {"fcoeadm -d eth0", NULL}, }; - GError * error = NULL; + GError *error = NULL; gboolean success; success = _fcoe_cleanup("eth0", test_dcb_func, &expected, &error); diff --git a/src/core/tests/test-l3cfg.c b/src/core/tests/test-l3cfg.c index f02b0f037c..5501079ec4 100644 --- a/src/core/tests/test-l3cfg.c +++ b/src/core/tests/test-l3cfg.c @@ -33,11 +33,11 @@ _netns_access_l3cfg(NMNetns *netns, int ifindex) typedef struct { int test_idx; - NMPlatform * platform; - NMNetns * netns; + NMPlatform *platform; + NMNetns *netns; NMDedupMultiIndex *multiidx; - const char * ifname0; - const char * ifname1; + const char *ifname0; + const char *ifname1; NMPLinkAddress hwaddr0; NMPLinkAddress hwaddr1; int ifindex0; @@ -163,9 +163,9 @@ _test_l3cfg_data_set_notify_type(TestL3cfgData *tdata, TestL3cfgNotifyType notif } static void -_test_l3cfg_signal_notify(NML3Cfg * l3cfg, +_test_l3cfg_signal_notify(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, - TestL3cfgData * tdata) + TestL3cfgData *tdata) { guint i; @@ -327,13 +327,13 @@ test_l3cfg(gconstpointer test_data) const int TEST_IDX = GPOINTER_TO_INT(test_data); const guint32 ACD_TIMEOUT_BASE_MSEC = 1000; nm_auto(_test_fixture_1_teardown) TestFixture1 test_fixture = {}; - const TestFixture1 * f; - NML3CfgCommitTypeHandle * commit_type_1; - NML3CfgCommitTypeHandle * commit_type_2; - gs_unref_object NML3Cfg *l3cfg0 = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd_a = NULL; - TestL3cfgData tdata_stack = { - .f = NULL, + const TestFixture1 *f; + NML3CfgCommitTypeHandle *commit_type_1; + NML3CfgCommitTypeHandle *commit_type_2; + gs_unref_object NML3Cfg *l3cfg0 = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd_a = NULL; + TestL3cfgData tdata_stack = { + .f = NULL, }; TestL3cfgData *const tdata = &tdata_stack; @@ -519,10 +519,10 @@ test_l3cfg(gconstpointer test_data) #define L3IPV4LL_ACD_TIMEOUT_MSEC 1500u typedef struct { - const TestFixture1 * f; + const TestFixture1 *f; NML3CfgCommitTypeHandle *l3cfg_commit_type_1; guint acd_timeout_msec; - NML3IPv4LL * l3ipv4ll; + NML3IPv4LL *l3ipv4ll; bool has_addr4_101; gint8 ready_seen; gint8 addr_commit; @@ -541,8 +541,8 @@ static void _test_l3_ipv4ll_maybe_add_addr_4(const TestL3IPv4LLData *tdata, int ifindex, guint one_case_in_num, - bool * has_addr, - const char * addr) + bool *has_addr, + const char *addr) { if (has_addr) { if (*has_addr || !nmtst_get_rand_one_case_in(one_case_in_num)) @@ -570,9 +570,9 @@ _test_l3_ipv4ll_maybe_add_addr_4(const TestL3IPv4LLData *tdata, } static void -_test_l3_ipv4ll_signal_notify(NML3Cfg * l3cfg, +_test_l3_ipv4ll_signal_notify(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, - TestL3IPv4LLData * tdata) + TestL3IPv4LLData *tdata) { char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; @@ -653,17 +653,17 @@ test_l3_ipv4ll(gconstpointer test_data) { const int TEST_IDX = GPOINTER_TO_INT(test_data); nm_auto(_test_fixture_1_teardown) TestFixture1 test_fixture = {}; - const TestFixture1 * f; - gs_unref_object NML3Cfg *l3cfg0 = NULL; - TestL3IPv4LLData tdata_stack = { - .f = NULL, + const TestFixture1 *f; + gs_unref_object NML3Cfg *l3cfg0 = NULL; + TestL3IPv4LLData tdata_stack = { + .f = NULL, }; - TestL3IPv4LLData *const tdata = &tdata_stack; - NMTstpAcdDefender * acd_defender_1 = NULL; - NMTstpAcdDefender * acd_defender_2 = NULL; - nm_auto_unref_l3ipv4ll NML3IPv4LL * l3ipv4ll = NULL; - gint64 start_time_msec; - gint64 total_poll_time_msec; + TestL3IPv4LLData *const tdata = &tdata_stack; + NMTstpAcdDefender *acd_defender_1 = NULL; + NMTstpAcdDefender *acd_defender_2 = NULL; + nm_auto_unref_l3ipv4ll NML3IPv4LL *l3ipv4ll = NULL; + gint64 start_time_msec; + gint64 total_poll_time_msec; nm_auto_remove_l3ipv4ll_registration NML3IPv4LLRegistration *l3ipv4ll_reg = NULL; char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; @@ -805,12 +805,12 @@ test_l3_ipv4ll(gconstpointer test_data) typedef struct { const TestFixture1 *f; - NML3Cfg * l3cfg0; - NML3IPv6LL * l3ipv6ll; + NML3Cfg *l3cfg0; + NML3IPv6LL *l3ipv6ll; int step; int ipv6ll_callback_step; bool steps_done : 1; - const NMPObject * lladdr0; + const NMPObject *lladdr0; } TestL3IPv6LLData; static const NMPlatformIP6Address * @@ -818,7 +818,7 @@ _test_l3_ipv6ll_find_lladdr(TestL3IPv6LLData *tdata, int ifindex) { const NMPlatformIP6Address *found = NULL; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; NMPLookup lookup; g_assert(tdata); @@ -880,21 +880,21 @@ _test_l3_ipv6ll_find_inet6(TestL3IPv6LLData *tdata, const struct in6_addr *addr) } static void -_test_l3_ipv6ll_signal_notify(NML3Cfg * l3cfg, +_test_l3_ipv6ll_signal_notify(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, - TestL3IPv6LLData * tdata) + TestL3IPv6LLData *tdata) { g_assert_cmpint(tdata->step, >=, 1); g_assert_cmpint(tdata->step, <=, 2); } static void -_test_l3_ipv6ll_callback_changed(NML3IPv6LL * ipv6ll, +_test_l3_ipv6ll_callback_changed(NML3IPv6LL *ipv6ll, NML3IPv6LLState state, const struct in6_addr *lladdr, gpointer user_data) { - TestL3IPv6LLData * tdata = user_data; + TestL3IPv6LLData *tdata = user_data; int step = tdata->ipv6ll_callback_step++; const NMPlatformIP6Address *a1; @@ -950,10 +950,10 @@ test_l3_ipv6ll(gconstpointer test_data) NMTST_UTILS_HOST_ID_CONTEXT("l3-ipv6ll"); const int TEST_IDX = GPOINTER_TO_INT(test_data); nm_auto(_test_fixture_1_teardown) TestFixture1 test_fixture = {}; - gs_unref_object NML3Cfg *l3cfg0 = NULL; - TestL3IPv6LLData tdata_stack = { - .step = 0, - .steps_done = FALSE, + gs_unref_object NML3Cfg *l3cfg0 = NULL; + TestL3IPv6LLData tdata_stack = { + .step = 0, + .steps_done = FALSE, }; TestL3IPv6LLData *const tdata = &tdata_stack; char sbuf1[sizeof(_nm_utils_to_string_buffer)]; diff --git a/src/core/tests/test-systemd.c b/src/core/tests/test-systemd.c index be07024897..71a6a60df1 100644 --- a/src/core/tests/test-systemd.c +++ b/src/core/tests/test-systemd.c @@ -49,7 +49,7 @@ test_lldp_create(void) /*****************************************************************************/ typedef struct { - GMainLoop * mainloop; + GMainLoop *mainloop; sd_event_source *event_source; } TestSdEventData; @@ -76,7 +76,7 @@ test_sd_event(void) guint sd_id = 0; int r; int i, n; - sd_event * other_events[3] = {NULL}, *event = NULL; + sd_event *other_events[3] = {NULL}, *event = NULL; TestSdEventData user_data = {0}; g_assert_cmpint(sd_event_default(NULL), ==, 0); @@ -125,10 +125,10 @@ test_path_equal(void) #define _path_equal_check(path, expected) \ G_STMT_START \ { \ - const char * _path0 = (path); \ - const char * _expected = (expected); \ + const char *_path0 = (path); \ + const char *_expected = (expected); \ gs_free char *_path = g_strdup(_path0); \ - const char * _path_result; \ + const char *_path_result; \ \ _path_result = nm_sd_utils_path_simplify(_path); \ g_assert(_path_result == _path); \ @@ -177,8 +177,8 @@ _test_unbase64char(char ch, gboolean maybe_invalid) static void _test_unbase64mem_mem(const char *base64, const guint8 *expected_arr, gsize expected_len) { - gs_free char *expected_base64 = NULL; - int r; + gs_free char *expected_base64 = NULL; + int r; nm_auto_free guint8 *exp2_arr = NULL; nm_auto_free guint8 *exp3_arr = NULL; gsize exp2_len; diff --git a/src/core/tests/test-utils.c b/src/core/tests/test-utils.c index 59d5fd5331..2d2b73404c 100644 --- a/src/core/tests/test-utils.c +++ b/src/core/tests/test-utils.c @@ -72,15 +72,15 @@ test_stable_privacy(void) static void _do_test_hw_addr(NMUtilsStableType stable_type, - const char * stable_id, - const guint8 * secret_key, + const char *stable_id, + const guint8 *secret_key, gsize key_len, - const char * ifname, - const char * current_mac_address, - const char * generate_mac_address_mask, + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask, const char *const *expected) { - gs_free char * generated = NULL; + gs_free char *generated = NULL; const char *const *e; gboolean found = FALSE; diff --git a/src/core/tests/test-wired-defname.c b/src/core/tests/test-wired-defname.c index f810c56f17..9f7aae1626 100644 --- a/src/core/tests/test-wired-defname.c +++ b/src/core/tests/test-wired-defname.c @@ -15,7 +15,7 @@ static NMConnection * _new_connection(const char *id) { NMConnection *a; - NMSetting * setting; + NMSetting *setting; a = nm_simple_connection_new(); setting = nm_setting_connection_new(); @@ -55,7 +55,7 @@ test_defname_no_connections(void) static void test_defname_no_conflict(void) { - GSList * list = NULL; + GSList *list = NULL; gs_free char *name = NULL; list = g_slist_append(list, _new_connection("asdfasdfasdfadf")); @@ -73,7 +73,7 @@ test_defname_no_conflict(void) static void test_defname_conflict(void) { - GSList * list = NULL; + GSList *list = NULL; gs_free char *name = NULL; list = g_slist_append(list, _new_connection("asdfasdfasdfadf")); @@ -91,7 +91,7 @@ test_defname_conflict(void) static void test_defname_multiple_conflicts(void) { - GSList * list = NULL; + GSList *list = NULL; gs_free char *name = NULL; list = g_slist_append(list, _new_connection("random gsm connection")); diff --git a/src/core/vpn/nm-vpn-connection.c b/src/core/vpn/nm-vpn-connection.c index 5e0990ff62..14ef1c4cac 100644 --- a/src/core/vpn/nm-vpn-connection.c +++ b/src/core/vpn/nm-vpn-connection.c @@ -123,28 +123,28 @@ typedef struct { NMSettingsConnectionCallId *secrets_id; SecretsReq secrets_idx; - char * username; + char *username; VpnState vpn_state; - NMDispatcherCallId * dispatcher_id; + NMDispatcherCallId *dispatcher_id; NMActiveConnectionStateReason failure_reason; NMVpnServiceState service_state; - GSource * start_timeout_source; - NMVpnPluginInfo * plugin_info; + GSource *start_timeout_source; + NMVpnPluginInfo *plugin_info; NMNetns *netns; - NML3Cfg * l3cfg_if; + NML3Cfg *l3cfg_if; NML3CfgCommitTypeHandle *l3cfg_commit_type_if; - NML3Cfg * l3cfg_dev; + NML3Cfg *l3cfg_dev; NML3CfgCommitTypeHandle *l3cfg_commit_type_dev; struct { GDBusConnection *connection; - char * bus_name; - char * owner; + char *bus_name; + char *owner; guint signal_id_vpn; guint signal_id_name_changed; bool name_owner_initialized : 1; @@ -154,7 +154,7 @@ typedef struct { union { const NML3ConfigData *const l3cds[_L3CD_TYPE_NUM]; - const NML3ConfigData * l3cds_[_L3CD_TYPE_NUM]; + const NML3ConfigData *l3cds_[_L3CD_TYPE_NUM]; }; /* This combines the l3cds of the VPN (basically, excluding l3cd_gw_extern which @@ -170,11 +170,11 @@ typedef struct { IPData ip_data_x[2]; }; - GSource * init_fail_on_idle_source; - GSource * connect_timeout_source; - GCancellable * main_cancellable; - GVariant * connect_hash; - char * banner; + GSource *init_fail_on_idle_source; + GSource *connect_timeout_source; + GCancellable *main_cancellable; + GVariant *connect_hash; + char *banner; NMPacrunnerConfId *pacrunner_conf_id; int ifindex_if; @@ -217,7 +217,7 @@ static void _secrets_get(NMVpnConnection *self, SecretsReq secrets_idx, const ch static guint32 get_route_table(NMVpnConnection *self, int addr_family, gboolean fallback_main); -static void _set_vpn_state(NMVpnConnection * self, +static void _set_vpn_state(NMVpnConnection *self, VpnState vpn_state, NMActiveConnectionStateReason reason, gboolean quitting); @@ -236,8 +236,8 @@ static const char * __LOG_create_prefix(char *buf, NMVpnConnection *self, NMSettingsConnection *con) { NMVpnConnectionPrivate *priv; - const char * id; - const char * iface; + const char *id; + const char *iface; char buf1[100]; char buf2[100]; @@ -438,9 +438,9 @@ _get_applied_connection(NMVpnConnection *connection) /*****************************************************************************/ static void -_dbus_connection_call(NMVpnConnection * self, - const char * method_name, - GVariant * parameters, +_dbus_connection_call(NMVpnConnection *self, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, GAsyncReadyCallback callback) { @@ -466,9 +466,9 @@ _dbus_connection_call(NMVpnConnection * self, static NML3ConfigMergeFlags _l3cfg_get_merge_flags(NMVpnConnection *self, L3CDType l3cd_type) { - NMConnection * applied; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMConnection *applied; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; NML3ConfigMergeFlags merge_flags; merge_flags = NM_L3_CONFIG_MERGE_FLAGS_NONE; @@ -714,8 +714,8 @@ _l3cfg_l3cd_set(NMVpnConnection *self, L3CDType l3cd_type, const NML3ConfigData static void _l3cfg_l3cd_update(NMVpnConnection *self, L3CDType l3cd_type) { - NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - NML3Cfg * l3cfg; + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NML3Cfg *l3cfg; int priority; const NML3ConfigData *const *p_l3cd; @@ -843,9 +843,9 @@ _l3cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMVpnC static gboolean _set_ip_ifindex(NMVpnConnection *self, int ifindex, gboolean is_if) { - NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - int * p_ifindex = is_if ? &priv->ifindex_if : &priv->ifindex_dev; - NML3Cfg ** p_l3cfg = is_if ? &priv->l3cfg_if : &priv->l3cfg_dev; + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + int *p_ifindex = is_if ? &priv->ifindex_if : &priv->ifindex_dev; + NML3Cfg **p_l3cfg = is_if ? &priv->l3cfg_if : &priv->l3cfg_dev; NML3CfgCommitTypeHandle **p_l3cfg_commit_type = is_if ? &priv->l3cfg_commit_type_if : &priv->l3cfg_commit_type_dev; gs_unref_object NML3Cfg *l3cfg_old = NULL; @@ -877,9 +877,9 @@ _set_ip_ifindex(NMVpnConnection *self, int ifindex, gboolean is_if) static void disconnect_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMVpnConnection *self; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + NMVpnConnection *self; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -923,7 +923,7 @@ vpn_cleanup(NMVpnConnection *self, NMDevice *parent_dev) static void dispatcher_pre_down_done(NMDispatcherCallId *call_id, gpointer user_data) { - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); + NMVpnConnection *self = NM_VPN_CONNECTION(user_data); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); nm_assert(call_id); @@ -939,7 +939,7 @@ dispatcher_pre_down_done(NMDispatcherCallId *call_id, gpointer user_data) static void dispatcher_pre_up_done(NMDispatcherCallId *call_id, gpointer user_data) { - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); + NMVpnConnection *self = NM_VPN_CONNECTION(user_data); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); nm_assert(call_id); @@ -959,7 +959,7 @@ dispatcher_cleanup(NMVpnConnection *self) } static void -_set_vpn_state(NMVpnConnection * self, +_set_vpn_state(NMVpnConnection *self, VpnState vpn_state, NMActiveConnectionStateReason reason, gboolean quitting) @@ -968,7 +968,7 @@ _set_vpn_state(NMVpnConnection * self, VpnState old_vpn_state; NMVpnConnectionState new_external_state; NMVpnConnectionState old_external_state; - NMDevice * parent_dev = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self)); + NMDevice *parent_dev = nm_active_connection_get_device(NM_ACTIVE_CONNECTION(self)); NMConnection *applied; if (vpn_state == priv->vpn_state) @@ -1142,7 +1142,7 @@ _connection_only_can_persist(NMVpnConnection *self) static void device_state_changed(NMActiveConnection *active, - NMDevice * device, + NMDevice *device, NMDeviceState new_state, NMDeviceState old_state) { @@ -1173,13 +1173,13 @@ device_state_changed(NMActiveConnection *active, static gboolean _parent_device_l3cd_add_gateway_route(NML3ConfigData *l3cd, int addr_family, - NMDevice * parent_device, + NMDevice *parent_device, const NMIPAddr *vpn_gw, - NMPlatform * platform) + NMPlatform *platform) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMIPAddr parent_gw = NM_IP_ADDR_INIT; - gboolean has_parent_gw = FALSE; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMIPAddr parent_gw = NM_IP_ADDR_INIT; + gboolean has_parent_gw = FALSE; nm_auto_nmpobj const NMPObject *route_resolved = NULL; int ifindex; NMPlatformIPXRoute route; @@ -1207,7 +1207,7 @@ _parent_device_l3cd_add_gateway_route(NML3ConfigData *l3cd, (NMPObject **) &route_resolved); if (r >= 0) { const NMPlatformIPXRoute *rx = NMP_OBJECT_CAST_IPX_ROUTE(route_resolved); - const NMPObject * obj; + const NMPObject *obj; if (rx->rx.ifindex == ifindex && nm_platform_route_table_is_main(rx->rx.table_coerced)) { gconstpointer gw = nm_platform_ip_route_get_gateway(addr_family, &rx->rx); @@ -1285,7 +1285,7 @@ _parent_device_l3cd_add_gateway_route(NML3ConfigData *l3cd, static gboolean _l3cfg_l3cd_gw_extern_update(NMVpnConnection *self) { - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; int ifindex; gboolean changed; @@ -1363,12 +1363,12 @@ _apply_config(NMVpnConnection *self) } static void -fw_change_zone_cb(NMFirewalldManager * firewalld_manager, +fw_change_zone_cb(NMFirewalldManager *firewalld_manager, NMFirewalldManagerCallId *call_id, - GError * error, + GError *error, gpointer user_data) { - NMVpnConnection * self = user_data; + NMVpnConnection *self = user_data; NMVpnConnectionPrivate *priv; g_return_if_fail(NM_IS_VPN_CONNECTION(self)); @@ -1387,12 +1387,12 @@ fw_change_zone_cb(NMFirewalldManager * firewalld_manager, static void _check_complete(NMVpnConnection *self, gboolean success) { - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - NMConnection * connection; - NMSettingConnection * s_con; - const char * zone; - const char * iface; + NMConnection *connection; + NMSettingConnection *s_con; + const char *zone; + const char *iface; if (priv->vpn_state < STATE_IP_CONFIG_GET || priv->vpn_state > STATE_ACTIVATED) return; @@ -1494,7 +1494,7 @@ nm_vpn_connection_get_ip_route_metric(NMVpnConnection *self, int addr_family) static guint32 get_route_table(NMVpnConnection *self, int addr_family, gboolean fallback_main) { - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip; guint32 route_table = 0; @@ -1513,7 +1513,7 @@ get_route_table(NMVpnConnection *self, int addr_family, gboolean fallback_main) static gboolean connect_timeout_cb(gpointer user_data) { - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); + NMVpnConnection *self = NM_VPN_CONNECTION(user_data); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->connect_timeout_source); @@ -1544,9 +1544,9 @@ connect_success(NMVpnConnection *self) static void connect_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMVpnConnection *self; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + NMVpnConnection *self; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -1568,10 +1568,10 @@ connect_cb(GObject *source, GAsyncResult *result, gpointer user_data) static void connect_interactive_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMVpnConnection * self; - NMVpnConnectionPrivate *priv; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + NMVpnConnection *self; + NMVpnConnectionPrivate *priv; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -1609,7 +1609,7 @@ static GVariant * _hash_with_username(NMConnection *connection, const char *username) { gs_unref_object NMConnection *dup = NULL; - NMSettingVpn * s_vpn; + NMSettingVpn *s_vpn; /* Shortcut if we weren't given a username or if there already was one in * the VPN setting; don't bother duplicating the connection and everything. @@ -1744,12 +1744,12 @@ _dbus_signal_state_changed_cb(NMVpnConnection *self, guint32 new_service_state) static gboolean _config_process_generic(NMVpnConnection *self, GVariant *dict) { - nm_auto_g_object_thaw_notify GObject *self_thaw = NULL; - NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + nm_auto_g_object_thaw_notify GObject *self_thaw = NULL; + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; int IS_IPv4; int ip_ifindex = 0; - const char * v_str; + const char *v_str; guint32 v_u32; gboolean v_b; @@ -1787,7 +1787,7 @@ _config_process_generic(NMVpnConnection *self, GVariant *dict) } for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { - NML3Cfg * l3cfg = priv->l3cfg_if ?: priv->l3cfg_dev; + NML3Cfg *l3cfg = priv->l3cfg_if ?: priv->l3cfg_dev; gs_unref_object NMIPConfig *ipconfig_old = NULL; ipconfig_old = g_steal_pointer(&priv->ip_data_x[IS_IPv4].ip_config); @@ -1891,14 +1891,14 @@ _dbus_signal_config_cb(NMVpnConnection *self, GVariant *dict) static void _dbus_signal_ip_config_cb(NMVpnConnection *self, int addr_family, GVariant *dict) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - GVariantIter * var_iter; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; + GVariantIter *var_iter; guint32 u32; - const char * v_str; + const char *v_str; NMIPAddr v_addr; - GVariant * v; + GVariant *v; gboolean v_b; int ip_ifindex; guint32 mss = 0; @@ -2083,8 +2083,8 @@ _dbus_signal_ip_config_cb(NMVpnConnection *self, int addr_family, GVariant *dict _nm_unused nm_auto_free_variant_iter GVariantIter *var_iter_ref_owner = var_iter; NMPlatformIPXRoute route = {}; guint32 plen; - GVariant * next_hop; - GVariant * dest; + GVariant *next_hop; + GVariant *dest; guint32 prefix; guint32 metric; @@ -2209,7 +2209,7 @@ _dbus_signal_ip_config_cb(NMVpnConnection *self, int addr_family, GVariant *dict } void -nm_vpn_connection_disconnect(NMVpnConnection * self, +nm_vpn_connection_disconnect(NMVpnConnection *self, NMActiveConnectionStateReason reason, gboolean quitting) { @@ -2219,7 +2219,7 @@ nm_vpn_connection_disconnect(NMVpnConnection * self, } gboolean -nm_vpn_connection_deactivate(NMVpnConnection * self, +nm_vpn_connection_deactivate(NMVpnConnection *self, NMActiveConnectionStateReason reason, gboolean quitting) { @@ -2241,11 +2241,11 @@ nm_vpn_connection_deactivate(NMVpnConnection * self, static void _secrets_dbus_need_secrets_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMVpnConnection * self; - NMVpnConnectionPrivate *priv; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; - const char * setting_name; + NMVpnConnection *self; + NMVpnConnectionPrivate *priv; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; + const char *setting_name; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -2282,9 +2282,9 @@ _secrets_dbus_need_secrets_cb(GObject *source, GAsyncResult *result, gpointer us static void _secrets_dbus_new_secrets_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMVpnConnection *self; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + NMVpnConnection *self; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -2302,16 +2302,16 @@ _secrets_dbus_new_secrets_cb(GObject *source, GAsyncResult *result, gpointer use } static void -_secrets_get_secrets_cb(NMSettingsConnection * connection, +_secrets_get_secrets_cb(NMSettingsConnection *connection, NMSettingsConnectionCallId *call_id, - const char * agent_username, - const char * setting_name, - GError * error, + const char *agent_username, + const char *setting_name, + GError *error, gpointer user_data) { - NMVpnConnection * self = NM_VPN_CONNECTION(user_data); + NMVpnConnection *self = NM_VPN_CONNECTION(user_data); NMVpnConnectionPrivate *priv; - GVariant * dict; + GVariant *dict; g_return_if_fail(NM_IS_VPN_CONNECTION(self)); @@ -2368,7 +2368,7 @@ _secrets_get_secrets_cb(NMSettingsConnection * connection, static void _secrets_get(NMVpnConnection *self, SecretsReq secrets_idx, const char *const *hints) { - NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; g_return_if_fail(secrets_idx < SECRETS_REQ_LAST); @@ -2411,15 +2411,15 @@ _secrets_get(NMVpnConnection *self, SecretsReq secrets_idx, const char *const *h } static void -_dbus_signal_secrets_required_cb(NMVpnConnection * self, - const char * message, +_dbus_signal_secrets_required_cb(NMVpnConnection *self, + const char *message, const char *const *secrets) { NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); const gsize secrets_len = NM_PTRARRAY_LEN(secrets); gsize i; - gs_free const char ** hints = NULL; - gs_free char * message_hint = NULL; + gs_free const char **hints = NULL; + gs_free char *message_hint = NULL; if (!NM_IN_SET(priv->vpn_state, STATE_CONNECT, STATE_NEED_AUTH)) { _LOGD("secrets: request ignored in current state %s", @@ -2488,12 +2488,12 @@ nm_vpn_service_daemon_exec(NMVpnConnection *self, GError **error) { NMVpnConnectionPrivate *priv; GPid pid; - char * vpn_argv[4]; - gs_free char ** envp = NULL; + char *vpn_argv[4]; + gs_free char **envp = NULL; char env_log_level[NM_STRLEN("NM_VPN_LOG_LEVEL=") + 100]; char env_log_syslog[NM_STRLEN("NM_VPN_LOG_SYSLOG=") + 10]; const gsize N_ENVIRON_EXTRA = 3; - char ** p_environ; + char **p_environ; gsize n_environ; gsize i; gsize j; @@ -2548,7 +2548,7 @@ nm_vpn_service_daemon_exec(NMVpnConnection *self, GError **error) static gboolean _start_timeout_cb(gpointer data) { - NMVpnConnection * self = NM_VPN_CONNECTION(data); + NMVpnConnection *self = NM_VPN_CONNECTION(data); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->start_timeout_source); @@ -2567,14 +2567,14 @@ _start_timeout_cb(gpointer data) static void _dbus_dispatch_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMVpnConnection * self = user_data; + NMVpnConnection *self = user_data; NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); guint32 v_u; @@ -2593,7 +2593,7 @@ _dbus_dispatch_cb(GDBusConnection *connection, _dbus_signal_state_changed_cb(self, v_u); } else if (nm_streq(signal_name, "SecretsRequired")) { if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sas)"))) { - const char * v_s; + const char *v_s; gs_free const char **v_strv = NULL; g_variant_get(parameters, "(&s^a&s)", &v_s, &v_strv); @@ -2618,7 +2618,7 @@ static void _name_owner_changed(NMVpnConnection *self, const char *owner, gboolean initializing) { _nm_unused gs_unref_object NMVpnConnection *self_keep_alive = g_object_ref(self); - NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); owner = nm_str_not_empty(owner); @@ -2674,16 +2674,16 @@ _name_owner_changed(NMVpnConnection *self, const char *owner, gboolean initializ static void _name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMVpnConnection * self = user_data; + NMVpnConnection *self = user_data; NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); - const char * new_owner; + const char *new_owner; if (!priv->dbus.name_owner_initialized) return; @@ -2699,7 +2699,7 @@ _name_owner_changed_cb(GDBusConnection *connection, static void _name_owner_get_cb(const char *name_owner, GError *error, gpointer user_data) { - NMVpnConnection * self; + NMVpnConnection *self; NMVpnConnectionPrivate *priv; if (nm_utils_error_is_cancelled(error)) @@ -2715,7 +2715,7 @@ _name_owner_get_cb(const char *name_owner, GError *error, gpointer user_data) static gboolean _init_fail_on_idle_cb(gpointer user_data) { - NMVpnConnection * self = user_data; + NMVpnConnection *self = user_data; NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); nm_clear_g_source_inst(&priv->init_fail_on_idle_source); @@ -2732,9 +2732,9 @@ void nm_vpn_connection_activate(NMVpnConnection *self, NMVpnPluginInfo *plugin_info) { NMVpnConnectionPrivate *priv; - NMConnection * connection; - NMSettingVpn * s_vpn; - const char * service; + NMConnection *connection; + NMSettingVpn *s_vpn; + const char *service; g_return_if_fail(NM_IS_VPN_CONNECTION(self)); g_return_if_fail(NM_IS_VPN_PLUGIN_INFO(plugin_info)); @@ -2812,8 +2812,8 @@ out: static void device_changed(NMActiveConnection *active, NMDevice *new_device, NMDevice *old_device) { - NMVpnConnection * self = NM_VPN_CONNECTION(active); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(active); + NMVpnConnection *self = NM_VPN_CONNECTION(active); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(active); gs_unref_object NML3Cfg *l3cfg_old = NULL; int ifindex; @@ -2865,7 +2865,7 @@ device_changed(NMActiveConnection *active, NMDevice *new_device, NMDevice *old_d static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMVpnConnection * self = NM_VPN_CONNECTION(object); + NMVpnConnection *self = NM_VPN_CONNECTION(object); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); switch (prop_id) { @@ -2905,12 +2905,12 @@ nm_vpn_connection_init(NMVpnConnection *self) } NMVpnConnection * -nm_vpn_connection_new(NMSettingsConnection * settings_connection, - NMDevice * parent_device, - const char * specific_object, +nm_vpn_connection_new(NMSettingsConnection *settings_connection, + NMDevice *parent_device, + const char *specific_object, NMActivationReason activation_reason, NMActivationStateFlags initial_state_flags, - NMAuthSubject * subject) + NMAuthSubject *subject) { g_return_val_if_fail(!settings_connection || NM_IS_SETTINGS_CONNECTION(settings_connection), NULL); @@ -2938,7 +2938,7 @@ nm_vpn_connection_new(NMSettingsConnection * settings_connection, static void dispose(GObject *object) { - NMVpnConnection * self = NM_VPN_CONNECTION(object); + NMVpnConnection *self = NM_VPN_CONNECTION(object); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); nm_clear_g_dbus_connection_signal(priv->dbus.connection, &priv->dbus.signal_id_vpn); @@ -2977,7 +2977,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMVpnConnection * self = NM_VPN_CONNECTION(object); + NMVpnConnection *self = NM_VPN_CONNECTION(object); NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); G_OBJECT_CLASS(nm_vpn_connection_parent_class)->finalize(object); @@ -3018,9 +3018,9 @@ static const NMDBusInterfaceInfoExtended interface_info_vpn_connection = { static void nm_vpn_connection_class_init(NMVpnConnectionClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS(klass); - NMDBusObjectClass * dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); + NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_vpn_connection); diff --git a/src/core/vpn/nm-vpn-connection.h b/src/core/vpn/nm-vpn-connection.h index df575c47f4..51e2e500cf 100644 --- a/src/core/vpn/nm-vpn-connection.h +++ b/src/core/vpn/nm-vpn-connection.h @@ -35,28 +35,28 @@ typedef struct _NMVpnConnectionClass NMVpnConnectionClass; GType nm_vpn_connection_get_type(void); -NMVpnConnection *nm_vpn_connection_new(NMSettingsConnection * settings_connection, - NMDevice * parent_device, - const char * specific_object, +NMVpnConnection *nm_vpn_connection_new(NMSettingsConnection *settings_connection, + NMDevice *parent_device, + const char *specific_object, NMActivationReason activation_reason, NMActivationStateFlags initial_state_flags, - NMAuthSubject * subject); + NMAuthSubject *subject); void nm_vpn_connection_activate(NMVpnConnection *self, NMVpnPluginInfo *plugin_info); NMVpnConnectionState nm_vpn_connection_get_vpn_state(NMVpnConnection *self); -const char * nm_vpn_connection_get_banner(NMVpnConnection *self); -const char * nm_vpn_connection_get_service(NMVpnConnection *self); +const char *nm_vpn_connection_get_banner(NMVpnConnection *self); +const char *nm_vpn_connection_get_service(NMVpnConnection *self); -gboolean nm_vpn_connection_deactivate(NMVpnConnection * self, +gboolean nm_vpn_connection_deactivate(NMVpnConnection *self, NMActiveConnectionStateReason reason, gboolean quitting); -void nm_vpn_connection_disconnect(NMVpnConnection * self, +void nm_vpn_connection_disconnect(NMVpnConnection *self, NMActiveConnectionStateReason reason, gboolean quitting); const NML3ConfigData *nm_vpn_connection_get_l3cd(NMVpnConnection *self); -const char * nm_vpn_connection_get_ip_iface(NMVpnConnection *self, gboolean fallback_device); +const char *nm_vpn_connection_get_ip_iface(NMVpnConnection *self, gboolean fallback_device); int nm_vpn_connection_get_ip_ifindex(NMVpnConnection *self, gboolean fallback_device); guint32 nm_vpn_connection_get_ip4_internal_gateway(NMVpnConnection *self); struct in6_addr *nm_vpn_connection_get_ip6_internal_gateway(NMVpnConnection *self); diff --git a/src/core/vpn/nm-vpn-manager.c b/src/core/vpn/nm-vpn-manager.c index f30dba79bc..6bf8edaee5 100644 --- a/src/core/vpn/nm-vpn-manager.c +++ b/src/core/vpn/nm-vpn-manager.c @@ -15,7 +15,7 @@ #include "libnm-core-intern/nm-core-internal.h" typedef struct { - GSList * plugins; + GSList *plugins; GFileMonitor *monitor_etc; GFileMonitor *monitor_lib; gulong monitor_id_etc; @@ -44,9 +44,9 @@ G_DEFINE_TYPE(NMVpnManager, nm_vpn_manager, G_TYPE_OBJECT) static void vpn_state_changed(NMVpnConnection *vpn, GParamSpec *pspec, NMVpnManager *manager) { - NMVpnManagerPrivate * priv = NM_VPN_MANAGER_GET_PRIVATE(manager); + NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE(manager); NMActiveConnectionState state = nm_active_connection_get_state(NM_ACTIVE_CONNECTION(vpn)); - const char * service_name = nm_vpn_connection_get_service(vpn); + const char *service_name = nm_vpn_connection_get_service(vpn); if (state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { g_hash_table_remove(priv->active_services, service_name); @@ -59,9 +59,9 @@ gboolean nm_vpn_manager_activate_connection(NMVpnManager *manager, NMVpnConnection *vpn, GError **error) { NMVpnManagerPrivate *priv; - NMVpnPluginInfo * plugin_info; - const char * service_name; - NMDevice * device; + NMVpnPluginInfo *plugin_info; + const char *service_name; + NMDevice *device; g_return_val_if_fail(NM_IS_VPN_MANAGER(manager), FALSE); g_return_val_if_fail(NM_IS_VPN_CONNECTION(vpn), FALSE); @@ -121,7 +121,7 @@ static void try_add_plugin(NMVpnManager *self, NMVpnPluginInfo *plugin_info) { NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE(self); - const char * program; + const char *program; program = nm_vpn_plugin_info_get_program(plugin_info); if (!program || !*program) @@ -138,17 +138,17 @@ try_add_plugin(NMVpnManager *self, NMVpnPluginInfo *plugin_info) } static void -vpn_dir_changed(GFileMonitor * monitor, - GFile * file, - GFile * other_file, +vpn_dir_changed(GFileMonitor *monitor, + GFile *file, + GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { - NMVpnManager * self = NM_VPN_MANAGER(user_data); + NMVpnManager *self = NM_VPN_MANAGER(user_data); NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE(self); - NMVpnPluginInfo * plugin_info; - gs_free char * path = NULL; - GError * error = NULL; + NMVpnPluginInfo *plugin_info; + gs_free char *path = NULL; + GError *error = NULL; path = g_file_get_path(file); if (!nm_vpn_plugin_info_validate_filename(path)) @@ -207,10 +207,10 @@ static void nm_vpn_manager_init(NMVpnManager *self) { NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE(self); - GFile * file; - GSList * infos, *info; - const char * conf_dir_etc = _nm_vpn_plugin_info_get_default_dir_etc(); - const char * conf_dir_lib = _nm_vpn_plugin_info_get_default_dir_lib(); + GFile *file; + GSList *infos, *info; + const char *conf_dir_etc = _nm_vpn_plugin_info_get_default_dir_etc(); + const char *conf_dir_lib = _nm_vpn_plugin_info_get_default_dir_lib(); /* Watch the VPN directory for changes */ file = g_file_new_for_path(conf_dir_lib); diff --git a/src/libnm-base/nm-ethtool-base.c b/src/libnm-base/nm-ethtool-base.c index c253ab9452..99bbe68e32 100644 --- a/src/libnm-base/nm-ethtool-base.c +++ b/src/libnm-base/nm-ethtool-base.c @@ -253,7 +253,7 @@ static int _by_name_cmp(gconstpointer a, gconstpointer b, gpointer user_data) { const guint8 *p_id = a; - const char * optname = b; + const char *optname = b; nm_assert(p_id && p_id >= _by_name && p_id <= &_by_name[_NM_ETHTOOL_ID_NUM]); nm_assert(*p_id < _NM_ETHTOOL_ID_NUM); diff --git a/src/libnm-client-aux-extern/nm-libnm-aux.c b/src/libnm-client-aux-extern/nm-libnm-aux.c index 2d17241db3..573eed1d48 100644 --- a/src/libnm-client-aux-extern/nm-libnm-aux.c +++ b/src/libnm-client-aux-extern/nm-libnm-aux.c @@ -7,10 +7,10 @@ /*****************************************************************************/ NMClient * -nmc_client_new_async_valist(GCancellable * cancellable, +nmc_client_new_async_valist(GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data, - const char * first_property_name, + const char *first_property_name, va_list ap) { NMClient *nmc; @@ -25,10 +25,10 @@ nmc_client_new_async_valist(GCancellable * cancellable, } NMClient * -nmc_client_new_async(GCancellable * cancellable, +nmc_client_new_async(GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data, - const char * first_property_name, + const char *first_property_name, ...) { NMClient *nmc; @@ -44,8 +44,8 @@ nmc_client_new_async(GCancellable * cancellable, typedef struct { GMainLoop *main_loop; - NMClient * nmc; - GError * error; + NMClient *nmc; + GError *error; } ClientCreateData; static void @@ -82,12 +82,12 @@ _nmc_client_new_waitsync_cb(GObject *source_object, GAsyncResult *result, gpoint */ gboolean nmc_client_new_waitsync(GCancellable *cancellable, - NMClient ** out_nmc, - GError ** error, - const char * first_property_name, + NMClient **out_nmc, + GError **error, + const char *first_property_name, ...) { - gs_unref_object NMClient *nmc = NULL; + gs_unref_object NMClient *nmc = NULL; nm_auto_unref_gmainloop GMainLoop *main_loop = g_main_loop_new(g_main_context_get_thread_default(), FALSE); ClientCreateData data = { diff --git a/src/libnm-client-aux-extern/nm-libnm-aux.h b/src/libnm-client-aux-extern/nm-libnm-aux.h index c982eab7c9..44344fd0b8 100644 --- a/src/libnm-client-aux-extern/nm-libnm-aux.h +++ b/src/libnm-client-aux-extern/nm-libnm-aux.h @@ -3,22 +3,22 @@ #ifndef __NM_LIBNM_AUX_H__ #define __NM_LIBNM_AUX_H__ -NMClient *nmc_client_new_async_valist(GCancellable * cancellable, +NMClient *nmc_client_new_async_valist(GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data, - const char * first_property_name, + const char *first_property_name, va_list ap); -NMClient *nmc_client_new_async(GCancellable * cancellable, +NMClient *nmc_client_new_async(GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data, - const char * first_property_name, + const char *first_property_name, ...); gboolean nmc_client_new_waitsync(GCancellable *cancellable, - NMClient ** out_nmc, - GError ** error, - const char * first_property_name, + NMClient **out_nmc, + GError **error, + const char *first_property_name, ...); #endif /* __NM_LIBNM_AUX_H__ */ diff --git a/src/libnm-client-aux-extern/tests/test-libnm-client-aux.c b/src/libnm-client-aux-extern/tests/test-libnm-client-aux.c index c4db4d6a39..f727b3d93e 100644 --- a/src/libnm-client-aux-extern/tests/test-libnm-client-aux.c +++ b/src/libnm-client-aux-extern/tests/test-libnm-client-aux.c @@ -15,9 +15,9 @@ static NMTeamLinkWatcher * _team_link_watcher_from_string_impl(const char *str, gsize nextra, const char *const *vextra) { - NMTeamLinkWatcher *watcher; - gs_free char * str1_free = NULL; - gs_free_error GError *error = NULL; + NMTeamLinkWatcher *watcher; + gs_free char *str1_free = NULL; + gs_free_error GError *error = NULL; gsize i; g_assert(str); @@ -27,7 +27,7 @@ _team_link_watcher_from_string_impl(const char *str, gsize nextra, const char *c for (i = 0; i < 1 + nextra; i++) { nm_auto_unref_team_link_watcher NMTeamLinkWatcher *watcher1 = NULL; - const char * str1; + const char *str1; if (i == 0) { str1_free = nm_utils_team_link_watcher_to_string(watcher); diff --git a/src/libnm-client-impl/nm-access-point.c b/src/libnm-client-impl/nm-access-point.c index 3d12aa4588..94b38f0300 100644 --- a/src/libnm-client-impl/nm-access-point.c +++ b/src/libnm-client-impl/nm-access-point.c @@ -36,7 +36,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMAccessPoint, typedef struct { GBytes *ssid; - char * bssid; + char *bssid; guint32 flags; guint32 wpa_flags; guint32 rsn_flags; @@ -251,16 +251,16 @@ NM_BACKPORT_SYMBOL(libnm_1_0_6, int, nm_access_point_get_last_seen, (NMAccessPoi gboolean nm_access_point_connection_valid(NMAccessPoint *ap, NMConnection *connection) { - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - const char * ctype, *ap_bssid; - GBytes * setting_ssid; - GBytes * ap_ssid; - const char * setting_bssid; - const char * setting_mode; + const char *ctype, *ap_bssid; + GBytes *setting_ssid; + GBytes *ap_ssid; + const char *setting_bssid; + const char *setting_mode; NM80211Mode ap_mode; - const char * setting_band; + const char *setting_band; guint32 ap_freq, setting_chan, ap_chan; g_return_val_if_fail(NM_IS_ACCESS_POINT(ap), FALSE); @@ -395,13 +395,13 @@ nm_access_point_filter_connections(NMAccessPoint *ap, const GPtrArray *connectio /*****************************************************************************/ static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_hw_address(NMClient * client, - NMLDBusObject * dbobj, +_notify_update_prop_hw_address(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMAccessPoint * self = NM_ACCESS_POINT(dbobj->nmobj); + NMAccessPoint *self = NM_ACCESS_POINT(dbobj->nmobj); NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE(self); g_free(priv->bssid); diff --git a/src/libnm-client-impl/nm-active-connection.c b/src/libnm-client-impl/nm-active-connection.c index aa96219c04..52e82b9f08 100644 --- a/src/libnm-client-impl/nm-active-connection.c +++ b/src/libnm-client-impl/nm-active-connection.c @@ -62,10 +62,10 @@ enum { typedef struct _NMActiveConnectionPrivate { NMLDBusPropertyO property_o[_PROPERTY_O_IDX_NUM]; NMLDBusPropertyAO devices; - NMRefString * specific_object_path; - char * id; - char * uuid; - char * type; + NMRefString *specific_object_path; + char *id; + char *uuid; + char *type; guint32 state; guint32 state_flags; @@ -397,7 +397,7 @@ static void _notify_event_state_changed(NMClient *client, NMClientNotifyEventWithPtr *notify_event) { gs_unref_object NMActiveConnection *self = notify_event->user_data; - NMActiveConnectionPrivate * priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); /* we expose here the value cache in @priv. In practice, this is the same * value as we received from the signal. In the unexpected case where they @@ -408,7 +408,7 @@ _notify_event_state_changed(NMClient *client, NMClientNotifyEventWithPtr *notify void _nm_active_connection_state_changed_commit(NMActiveConnection *self, guint32 state, guint32 reason) { - NMClient * client; + NMClient *client; NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); client = _nm_object_get_client(self); @@ -605,7 +605,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_connection_active = NML_DBUS_META static void nm_active_connection_class_init(NMActiveConnectionClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); g_type_class_add_private(klass, sizeof(NMActiveConnectionPrivate)); diff --git a/src/libnm-client-impl/nm-checkpoint.c b/src/libnm-client-impl/nm-checkpoint.c index c1f6b09227..424d8e50cc 100644 --- a/src/libnm-client-impl/nm-checkpoint.c +++ b/src/libnm-client-impl/nm-checkpoint.c @@ -105,7 +105,7 @@ nm_checkpoint_init(NMCheckpoint *checkpoint) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMCheckpoint * checkpoint = NM_CHECKPOINT(object); + NMCheckpoint *checkpoint = NM_CHECKPOINT(object); NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE(checkpoint); switch (prop_id) { @@ -145,7 +145,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_checkpoint = NML_DBUS_META_IFACE_ static void nm_checkpoint_class_init(NMCheckpointClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-client.c b/src/libnm-client-impl/nm-client.c index 0f9d8fe15f..27382ec8b9 100644 --- a/src/libnm-client-impl/nm-client.c +++ b/src/libnm-client-impl/nm-client.c @@ -71,7 +71,7 @@ _context_busy_watcher_attach_integration_source_cb(gpointer data, GObject *where void nm_context_busy_watcher_integrate_source(GMainContext *outer_context, GMainContext *inner_context, - GObject * context_busy_watcher) + GObject *context_busy_watcher) { GSource *source; @@ -141,7 +141,7 @@ typedef struct { CList iface_lst; union { const NMLDBusMetaIface *meta; - NMRefString * name; + NMRefString *name; } dbus_iface; CList changed_prop_lst_head; @@ -249,16 +249,16 @@ enum { }; typedef struct { - struct udev * udev; - GMainContext * main_context; - GMainContext * dbus_context; - GObject * context_busy_watcher; + struct udev *udev; + GMainContext *main_context; + GMainContext *dbus_context; + GObject *context_busy_watcher; GDBusConnection *dbus_connection; - NMLInitData * init_data; - GHashTable * dbus_objects; + NMLInitData *init_data; + GHashTable *dbus_objects; CList obj_changed_lst_head; - GCancellable * name_owner_get_cancellable; - GCancellable * get_managed_objects_cancellable; + GCancellable *name_owner_get_cancellable; + GCancellable *get_managed_objects_cancellable; CList queue_notify_lst_head; CList notify_event_lst_head; @@ -274,7 +274,7 @@ typedef struct { gsize log_call_counter; - guint8 * permissions; + guint8 *permissions; GCancellable *permissions_cancellable; char *name_owner; @@ -300,9 +300,9 @@ typedef struct { struct { NMLDBusPropertyO property_o[_PROPERTY_O_IDX_NM_NUM]; NMLDBusPropertyAO property_ao[_PROPERTY_AO_IDX_NM_NUM]; - char * connectivity_check_uri; - char * version; - guint32 * capabilities_arr; + char *connectivity_check_uri; + char *version; + guint32 *capabilities_arr; gsize capabilities_len; guint32 connectivity; guint32 state; @@ -319,14 +319,14 @@ typedef struct { struct { NMLDBusPropertyAO connections; - char * hostname; + char *hostname; bool can_modify; } settings; struct { GPtrArray *configuration; - char * mode; - char * rc_manager; + char *mode; + char *rc_manager; } dns_manager; } NMClientPrivate; @@ -363,11 +363,11 @@ G_DEFINE_TYPE_WITH_CODE(NMClient, static void _init_start_check_complete(NMClient *self); static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data); static void name_owner_get_call(NMClient *self); @@ -484,8 +484,8 @@ _nm_client_new_error_nm_not_cached(void) static void _nm_client_dbus_call_simple_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - GAsyncReadyCallback callback; - gpointer callback_user_data; + GAsyncReadyCallback callback; + gpointer callback_user_data; gs_unref_object GObject *context_busy_watcher = NULL; gpointer obfuscated_self_ptr; gpointer log_call_counter_ptr; @@ -506,21 +506,21 @@ _nm_client_dbus_call_simple_cb(GObject *source, GAsyncResult *result, gpointer u } void -_nm_client_dbus_call_simple(NMClient * self, - GCancellable * cancellable, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_nm_client_dbus_call_simple(NMClient *self, + GCancellable *cancellable, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, int timeout_msec, GAsyncReadyCallback callback, gpointer user_data) { - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; - gs_free char * log_str = NULL; + gs_free char *log_str = NULL; gsize log_call_counter; nm_assert(priv->name_owner); @@ -565,22 +565,22 @@ _nm_client_dbus_call_simple(NMClient * self, } void -_nm_client_dbus_call(NMClient * self, +_nm_client_dbus_call(NMClient *self, gpointer source_obj, gpointer source_tag, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback user_callback, gpointer user_callback_data, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, int timeout_msec, GAsyncReadyCallback internal_callback) { - NMClientPrivate *priv; + NMClientPrivate *priv; gs_unref_object GTask *task = NULL; nm_assert(!source_obj || G_IS_OBJECT(source_obj)); @@ -622,19 +622,19 @@ _nm_client_dbus_call(NMClient * self, } GVariant * -_nm_client_dbus_call_sync(NMClient * self, - GCancellable * cancellable, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_nm_client_dbus_call_sync(NMClient *self, + GCancellable *cancellable, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, int timeout_msec, gboolean strip_dbus_error, - GError ** error) + GError **error) { - NMClientPrivate *priv; + NMClientPrivate *priv; gs_unref_variant GVariant *ret = NULL; nm_assert(!cancellable || G_IS_CANCELLABLE(cancellable)); @@ -679,16 +679,16 @@ _nm_client_dbus_call_sync(NMClient * self, } gboolean -_nm_client_dbus_call_sync_void(NMClient * self, - GCancellable * cancellable, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_nm_client_dbus_call_sync_void(NMClient *self, + GCancellable *cancellable, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusCallFlags flags, int timeout_msec, gboolean strip_dbus_error, - GError ** error) + GError **error) { gs_unref_variant GVariant *ret = NULL; @@ -707,15 +707,15 @@ _nm_client_dbus_call_sync_void(NMClient * self, } void -_nm_client_set_property_sync_legacy(NMClient * self, +_nm_client_set_property_sync_legacy(NMClient *self, const char *object_path, const char *interface_name, const char *property_name, const char *format_string, ...) { - NMClientPrivate *priv; - GVariant * val; + NMClientPrivate *priv; + GVariant *val; gs_unref_variant GVariant *ret = NULL; va_list ap; @@ -816,12 +816,12 @@ _nm_client_queue_notify_object(NMClient *self, gpointer nmobj, const GParamSpec /*****************************************************************************/ gpointer -_nm_client_notify_event_queue(NMClient * self, +_nm_client_notify_event_queue(NMClient *self, int priority, NMClientNotifyEventCb callback, gsize event_size) { - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); NMClientNotifyEvent *notify_event; nm_assert(callback); @@ -836,7 +836,7 @@ _nm_client_notify_event_queue(NMClient * self, } NMClientNotifyEventWithPtr * -_nm_client_notify_event_queue_with_ptr(NMClient * self, +_nm_client_notify_event_queue_with_ptr(NMClient *self, int priority, NMClientNotifyEventWithPtrCb callback, gpointer user_data) @@ -855,8 +855,8 @@ _nm_client_notify_event_queue_with_ptr(NMClient * self, typedef struct { NMClientNotifyEvent parent; - GObject * source; - NMObject * obj; + GObject *source; + NMObject *obj; guint signal_id; } NMClientNotifyEventObjAddedRemove; @@ -882,7 +882,7 @@ _nm_client_notify_event_queue_emit_obj_signal_cb(NMClient *self, gpointer notify void _nm_client_notify_event_queue_emit_obj_signal(NMClient *self, - GObject * source, + GObject *source, NMObject *nmobj, gboolean is_added /* or else removed */, int prio_offset, @@ -924,7 +924,7 @@ _nm_client_notify_event_cmp(const CList *a, const CList *b, const void *user_dat static void _nm_client_notify_event_emit_parts(NMClient *self, int max_priority /* included! */) { - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); NMClientNotifyEvent *notify_event; while (TRUE) { @@ -947,7 +947,7 @@ static void _nm_client_notify_event_emit(NMClient *self) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - NMObjectBase * base; + NMObjectBase *base; _nm_client_notify_event_emit_parts(self, NM_CLIENT_NOTIFY_EVENT_PRIO_GPROP); @@ -1137,12 +1137,12 @@ nml_dbus_object_unref(NMLDBusObject *dbobj) static NMLDBusObjIfaceData * nml_dbus_object_iface_data_get(NMLDBusObject *dbobj, - const char * dbus_iface_name, + const char *dbus_iface_name, gboolean allow_create) { const NMLDBusMetaIface *meta_iface; - NMLDBusObjIfaceData * db_iface_data; - NMLDBusObjPropData * db_prop_data; + NMLDBusObjIfaceData *db_iface_data; + NMLDBusObjPropData *db_prop_data; guint count = 0; guint i; @@ -1245,8 +1245,8 @@ nml_dbus_obj_iface_data_destroy(NMLDBusObjIfaceData *db_iface_data) } gpointer -nml_dbus_object_get_property_location(NMLDBusObject * dbobj, - const NMLDBusMetaIface * meta_iface, +nml_dbus_object_get_property_location(NMLDBusObject *dbobj, + const NMLDBusMetaIface *meta_iface, const NMLDBusMetaProperty *meta_property) { char *target_c; @@ -1327,8 +1327,8 @@ nml_dbus_object_set_obj_state(NMLDBusObject *dbobj, NMLDBusObjState obj_state, N /*****************************************************************************/ static void -nml_dbus_object_obj_changed_link(NMClient * self, - NMLDBusObject * dbobj, +nml_dbus_object_obj_changed_link(NMClient *self, + NMLDBusObject *dbobj, NMLDBusObjChangedType changed_type) { nm_assert(NM_IS_CLIENT(self)); @@ -1365,11 +1365,11 @@ nml_dbus_object_obj_changed_link(NMClient * self, } static NMLDBusObjChangedType -nml_dbus_object_obj_changed_consume(NMClient * self, - NMLDBusObject * dbobj, +nml_dbus_object_obj_changed_consume(NMClient *self, + NMLDBusObject *dbobj, NMLDBusObjChangedType changed_type) { - NMClientPrivate * priv; + NMClientPrivate *priv; NMLDBusObjChangedType changed_type_res; nm_assert(NM_IS_CLIENT(self)); @@ -1408,7 +1408,7 @@ static gboolean nml_dbus_object_obj_changed_any_linked(NMClient *self, NMLDBusObjChangedType changed_type) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - NMLDBusObject * dbobj; + NMLDBusObject *dbobj; nm_assert(changed_type != NML_DBUS_OBJ_CHANGED_TYPE_NONE); @@ -1491,8 +1491,8 @@ static NMLDBusObject * _dbobjs_dbobj_create(NMClient *self, NMRefString *dbus_path_take) { nm_auto_ref_string NMRefString *dbus_path = g_steal_pointer(&dbus_path_take); - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); - NMLDBusObject * dbobj; + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); + NMLDBusObject *dbobj; nm_assert(!_dbobjs_dbobj_get_r(self, dbus_path)); @@ -1506,7 +1506,7 @@ static NMLDBusObject * _dbobjs_dbobj_get_or_create(NMClient *self, NMRefString *dbus_path_take) { nm_auto_ref_string NMRefString *dbus_path = g_steal_pointer(&dbus_path_take); - NMLDBusObject * dbobj; + NMLDBusObject *dbobj; dbobj = _dbobjs_dbobj_get_r(self, dbus_path); if (dbobj) @@ -1550,8 +1550,8 @@ _dbobjs_get_nmobj_unpack_visible(NMClient *self, const char *dbus_path, GType gt /*****************************************************************************/ static gpointer -_dbobjs_obj_watcher_register_o(NMClient * self, - NMLDBusObject * dbobj, +_dbobjs_obj_watcher_register_o(NMClient *self, + NMLDBusObject *dbobj, NMLDBusObjWatchNotifyFcn notify_fcn, gsize struct_size) { @@ -1576,13 +1576,13 @@ _dbobjs_obj_watcher_register_o(NMClient * self, } static gpointer -_dbobjs_obj_watcher_register_r(NMClient * self, - NMRefString * dbus_path_take, +_dbobjs_obj_watcher_register_r(NMClient *self, + NMRefString *dbus_path_take, NMLDBusObjWatchNotifyFcn notify_fcn, gsize struct_size) { nm_auto_ref_string NMRefString *dbus_path = g_steal_pointer(&dbus_path_take); - NMLDBusObject * dbobj; + NMLDBusObject *dbobj; nm_assert(NM_IS_CLIENT(self)); nm_assert(notify_fcn); @@ -1597,7 +1597,7 @@ static void _dbobjs_obj_watcher_unregister(NMClient *self, gpointer obj_watcher_base) { NMLDBusObjWatcher *obj_watcher = obj_watcher_base; - NMLDBusObject * dbobj; + NMLDBusObject *dbobj; nm_assert(NM_IS_CLIENT(self)); nm_assert(obj_watcher); @@ -1654,7 +1654,7 @@ static void nml_dbus_property_o_notify_changed(NMLDBusPropertyO *pr_o, NMClient *self) { const NMLDBusPropertVTableO *vtable; - GObject * nmobj = NULL; + GObject *nmobj = NULL; gboolean is_ready = TRUE; gboolean changed_ready; GType gtype; @@ -1759,7 +1759,7 @@ nml_dbus_property_o_notify_changed_many(NMLDBusPropertyO *ptr, guint len, NMClie static void nml_dbus_property_o_notify_watch_cb(NMClient *self, gpointer obj_watcher) { - PropertyOData * pr_o_data = obj_watcher; + PropertyOData *pr_o_data = obj_watcher; NMLDBusPropertyO *pr_o = pr_o_data->pr_o; nm_assert(pr_o->obj_watcher == obj_watcher); @@ -1771,12 +1771,12 @@ nml_dbus_property_o_notify_watch_cb(NMClient *self, gpointer obj_watcher) } static NMLDBusNotifyUpdatePropFlags -nml_dbus_property_o_notify(NMClient * self, - NMLDBusPropertyO * pr_o, - NMLDBusObject * dbobj, +nml_dbus_property_o_notify(NMClient *self, + NMLDBusPropertyO *pr_o, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { const char *dbus_path = NULL; gboolean changed = FALSE; @@ -1850,9 +1850,9 @@ nml_dbus_property_o_clear_many(NMLDBusPropertyO *pr_o, guint len, NMClient *self typedef struct _NMLDBusPropertyAOData { NMLDBusObjWatcher obj_watcher; - NMLDBusPropertyAO * parent; + NMLDBusPropertyAO *parent; CList data_lst; - GObject * nmobj; + GObject *nmobj; struct _NMLDBusPropertyAOData *changed_next; bool is_ready : 1; bool is_notified : 1; @@ -1894,10 +1894,10 @@ _ASSERT_pr_ao(NMLDBusPropertyAO *pr_ao) static gboolean nml_dbus_property_ao_notify_changed_ao(PropertyAOData *pr_ao_data, - NMClient * self, + NMClient *self, gboolean is_added /* or else removed */) { - NMLDBusPropertyAO * pr_ao; + NMLDBusPropertyAO *pr_ao; const NMLDBusPropertVTableAO *vtable; if (!pr_ao_data->nmobj) @@ -1979,7 +1979,7 @@ nml_dbus_property_ao_notify_changed(NMLDBusPropertyAO *pr_ao, NMClient *self) while (pr_ao->changed_head) { const NMLDBusPropertVTableAO *vtable; - GObject * nmobj = NULL; + GObject *nmobj = NULL; gboolean is_ready = TRUE; GType gtype; @@ -2098,7 +2098,7 @@ nml_dbus_property_ao_notify_changed_many(NMLDBusPropertyAO *ptr, guint len, NMCl static void nml_dbus_property_ao_notify_watch_cb(NMClient *self, gpointer obj_watcher) { - PropertyAOData * pr_ao_data = obj_watcher; + PropertyAOData *pr_ao_data = obj_watcher; NMLDBusPropertyAO *pr_ao = pr_ao_data->parent; nm_assert(g_hash_table_lookup(pr_ao->hash, pr_ao_data) == pr_ao_data); @@ -2119,12 +2119,12 @@ nml_dbus_property_ao_notify_watch_cb(NMClient *self, gpointer obj_watcher) } NMLDBusNotifyUpdatePropFlags -nml_dbus_property_ao_notify(NMClient * self, - NMLDBusPropertyAO * pr_ao, - NMLDBusObject * dbobj, +nml_dbus_property_ao_notify(NMClient *self, + NMLDBusPropertyAO *pr_ao, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { CList stale_lst_head = C_LIST_INIT(stale_lst_head); PropertyAOData *pr_ao_data; @@ -2158,7 +2158,7 @@ nml_dbus_property_ao_notify(NMClient * self, if (value) { GVariantIter iter; - const char * path; + const char *path; g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "&o", &path)) { @@ -2344,23 +2344,23 @@ nml_dbus_property_ao_clear_many(NMLDBusPropertyAO *pr_ao, guint len, NMClient *s /*****************************************************************************/ NMLDBusNotifyUpdatePropFlags -_nml_dbus_notify_update_prop_ignore(NMClient * self, - NMLDBusObject * dbobj, +_nml_dbus_notify_update_prop_ignore(NMClient *self, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { return NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE; } NMLDBusNotifyUpdatePropFlags -_nml_dbus_notify_update_prop_o(NMClient * self, - NMLDBusObject * dbobj, +_nml_dbus_notify_update_prop_o(NMClient *self, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - const char * path = NULL; + const char *path = NULL; NMRefString **p_property; if (value) @@ -2381,17 +2381,17 @@ _nml_dbus_notify_update_prop_o(NMClient * self, /*****************************************************************************/ static void -_obj_handle_dbus_prop_changes(NMClient * self, - NMLDBusObject * dbobj, +_obj_handle_dbus_prop_changes(NMClient *self, + NMLDBusObject *dbobj, NMLDBusObjIfaceData *db_iface_data, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - const NMLDBusMetaIface * meta_iface = db_iface_data->dbus_iface.meta; - const NMLDBusMetaProperty * meta_property = &meta_iface->dbus_properties[dbus_property_idx]; + const NMLDBusMetaIface *meta_iface = db_iface_data->dbus_iface.meta; + const NMLDBusMetaProperty *meta_property = &meta_iface->dbus_properties[dbus_property_idx]; gpointer p_property; - const char * dbus_type_s; - const GParamSpec * param_spec; + const char *dbus_type_s; + const GParamSpec *param_spec; NMLDBusNotifyUpdatePropFlags notify_update_prop_flags; nm_assert(G_IS_OBJECT(dbobj->nmobj)); @@ -2528,7 +2528,7 @@ _obj_handle_dbus_prop_changes(NMClient * self, { gconstpointer v; gsize l; - GBytes * b = NULL; + GBytes *b = NULL; if (value) { v = g_variant_get_fixed_array(value, &l, 1); @@ -2576,8 +2576,8 @@ notify: } static void -_obj_handle_dbus_iface_changes(NMClient * self, - NMLDBusObject * dbobj, +_obj_handle_dbus_iface_changes(NMClient *self, + NMLDBusObject *dbobj, NMLDBusObjIfaceData *db_iface_data) { NMLDBusObjPropData *db_prop_data; @@ -2648,9 +2648,9 @@ _obj_handle_dbus_iface_changes(NMClient * self, static void _obj_handle_dbus_changes(NMClient *self, NMLDBusObject *dbobj) { - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); - NMLDBusObjIfaceData *db_iface_data; - NMLDBusObjIfaceData *db_iface_data_safe; + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); + NMLDBusObjIfaceData *db_iface_data; + NMLDBusObjIfaceData *db_iface_data_safe; gs_unref_object GObject *nmobj_unregistering = NULL; _ASSERT_dbobj(dbobj, self); @@ -2791,7 +2791,7 @@ static void _dbus_handle_obj_changed_nmobj(NMClient *self) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - NMLDBusObject * dbobj; + NMLDBusObject *dbobj; CList obj_changed_tmp_lst_head = C_LIST_INIT(obj_changed_tmp_lst_head); nm_assert(!nml_dbus_object_obj_changed_any_linked(self, ~NML_DBUS_OBJ_CHANGED_TYPE_NMOBJ)); @@ -2852,7 +2852,7 @@ static void _dbus_handle_obj_changed_dbus(NMClient *self, const char *log_context) { NMClientPrivate *priv; - NMLDBusObject * dbobj; + NMLDBusObject *dbobj; CList obj_changed_tmp_lst_head = C_LIST_INIT(obj_changed_tmp_lst_head); priv = NM_CLIENT_GET_PRIVATE(self); @@ -2898,7 +2898,7 @@ _dbus_handle_obj_changed_dbus(NMClient *self, const char *log_context) static void _dbus_handle_changes_commit(NMClient *self, gboolean allow_init_start_check_complete) { - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; _dbus_handle_obj_changed_nmobj(self); @@ -2914,7 +2914,7 @@ _dbus_handle_changes_commit(NMClient *self, gboolean allow_init_start_check_comp } static void -_dbus_handle_changes(NMClient * self, +_dbus_handle_changes(NMClient *self, const char *log_context, gboolean allow_init_start_check_complete) { @@ -2923,17 +2923,17 @@ _dbus_handle_changes(NMClient * self, } static gboolean -_dbus_handle_properties_changed(NMClient * self, - const char * log_context, - const char * object_path, - const char * interface_name, +_dbus_handle_properties_changed(NMClient *self, + const char *log_context, + const char *object_path, + const char *interface_name, gboolean allow_add_iface, - GVariant * changed_properties, + GVariant *changed_properties, NMLDBusObject **inout_dbobj) { - NMLDBusObject * dbobj = NULL; - NMLDBusObjIfaceData *db_iface_data = NULL; - nm_auto_ref_string NMRefString *dbus_path = NULL; + NMLDBusObject *dbobj = NULL; + NMLDBusObjIfaceData *db_iface_data = NULL; + nm_auto_ref_string NMRefString *dbus_path = NULL; nm_assert(!changed_properties || g_variant_is_of_type(changed_properties, G_VARIANT_TYPE("a{sv}"))); @@ -3000,14 +3000,14 @@ _dbus_handle_properties_changed(NMClient * self, interface_name); else if (changed_properties) { GVariantIter iter_prop; - const char * property_name; - GVariant * property_value_tmp; + const char *property_name; + GVariant *property_value_tmp; g_variant_iter_init(&iter_prop, changed_properties); while (g_variant_iter_next(&iter_prop, "{&sv}", &property_name, &property_value_tmp)) { _nm_unused gs_unref_variant GVariant *property_value = property_value_tmp; - const NMLDBusMetaProperty * meta_property; - NMLDBusObjPropData * db_propdata; + const NMLDBusMetaProperty *meta_property; + NMLDBusObjPropData *db_propdata; guint property_idx; meta_property = nml_dbus_meta_property_get(db_iface_data->dbus_iface.meta, @@ -3045,14 +3045,14 @@ _dbus_handle_properties_changed(NMClient * self, } static gboolean -_dbus_handle_interface_added(NMClient * self, +_dbus_handle_interface_added(NMClient *self, const char *log_context, const char *object_path, - GVariant * ifaces) + GVariant *ifaces) { gboolean changed = FALSE; - const char * interface_name; - GVariant * changed_properties; + const char *interface_name; + GVariant *changed_properties; GVariantIter iter_ifaces; NMLDBusObject *dbobj = NULL; @@ -3076,10 +3076,10 @@ _dbus_handle_interface_added(NMClient * self, } static gboolean -_dbus_handle_interface_removed(NMClient * self, - const char * log_context, - const char * object_path, - NMLDBusObject ** inout_dbobj, +_dbus_handle_interface_removed(NMClient *self, + const char *log_context, + const char *object_path, + NMLDBusObject **inout_dbobj, const char *const *removed_interfaces) { gboolean changed = FALSE; @@ -3103,7 +3103,7 @@ _dbus_handle_interface_removed(NMClient * self, for (i = 0; removed_interfaces[i]; i++) { NMLDBusObjIfaceData *db_iface_data; - const char * interface_name = removed_interfaces[i]; + const char *interface_name = removed_interfaces[i]; db_iface_data = nml_dbus_object_iface_data_get(dbobj, interface_name, FALSE); if (!db_iface_data) { @@ -3133,16 +3133,16 @@ _dbus_handle_interface_removed(NMClient * self, static void _dbus_managed_objects_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * arg_object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *arg_object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMClient * self = user_data; + NMClient *self = user_data; NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - const char * log_context; + const char *log_context; gboolean changed; nm_assert(nm_streq0(interface_name, DBUS_INTERFACE_OBJECT_MANAGER)); @@ -3154,7 +3154,7 @@ _dbus_managed_objects_changed_cb(GDBusConnection *connection, if (nm_streq(signal_name, "InterfacesAdded")) { gs_unref_variant GVariant *interfaces_and_properties = NULL; - const char * object_path; + const char *object_path; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(oa{sa{sv}})"))) return; @@ -3169,7 +3169,7 @@ _dbus_managed_objects_changed_cb(GDBusConnection *connection, if (nm_streq(signal_name, "InterfacesRemoved")) { gs_free const char **interfaces = NULL; - const char * object_path; + const char *object_path; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(oas)"))) return; @@ -3190,19 +3190,19 @@ out: static void _dbus_properties_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMClient * self = user_data; - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - const char * interface_name; + NMClient *self = user_data; + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); + const char *interface_name; gs_unref_variant GVariant *changed_properties = NULL; - gs_free const char ** invalidated_properties = NULL; - const char * log_context = "properties-changed"; + gs_free const char **invalidated_properties = NULL; + const char *log_context = "properties-changed"; if (priv->get_managed_objects_cancellable) { /* we still wait for the initial GetManagedObjects(). Ignore the event. */ @@ -3239,12 +3239,12 @@ _dbus_properties_changed_cb(GDBusConnection *connection, static void _dbus_get_managed_objects_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMClient * self; - NMClientPrivate *priv; - gs_unref_variant GVariant *ret = NULL; - gs_unref_variant GVariant *managed_objects = NULL; - gs_free_error GError *error = NULL; - gs_unref_object GObject *context_busy_watcher = NULL; + NMClient *self; + NMClientPrivate *priv; + gs_unref_variant GVariant *ret = NULL; + gs_unref_variant GVariant *managed_objects = NULL; + gs_free_error GError *error = NULL; + gs_unref_object GObject *context_busy_watcher = NULL; nm_utils_user_data_unpack(user_data, &self, &context_busy_watcher); @@ -3273,8 +3273,8 @@ _dbus_get_managed_objects_cb(GObject *source, GAsyncResult *result, gpointer use if (managed_objects) { GVariantIter iter; - const char * object_path; - GVariant * ifaces_tmp; + const char *object_path; + GVariant *ifaces_tmp; g_variant_iter_init(&iter, managed_objects); while (g_variant_iter_next(&iter, "{&o@a{sa{sv}}}", &object_path, &ifaces_tmp)) { @@ -3294,12 +3294,12 @@ _dbus_get_managed_objects_cb(GObject *source, GAsyncResult *result, gpointer use static void _nm_client_get_settings_call_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMRemoteConnection *remote_connection; - NMClient * self; + NMRemoteConnection *remote_connection; + NMClient *self; gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; gs_unref_variant GVariant *settings = NULL; - NMLDBusObject * dbobj; + NMLDBusObject *dbobj; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (!ret && nm_utils_error_is_cancelled(error)) @@ -3352,17 +3352,17 @@ _nm_client_get_settings_call(NMClient *self, NMLDBusObject *dbobj) static void _dbus_settings_updated_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMClient * self = user_data; + NMClient *self = user_data; NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - const char * log_context = "settings-updated"; - NMLDBusObject * dbobj; + const char *log_context = "settings-updated"; + NMLDBusObject *dbobj; if (priv->get_managed_objects_cancellable) { /* we still wait for the initial GetManagedObjects(). Ignore the event. */ @@ -3391,17 +3391,17 @@ _dbus_settings_updated_cb(GDBusConnection *connection, static void _dbus_nm_connection_active_state_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMClient * self = user_data; + NMClient *self = user_data; NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - const char * log_context = "active-connection-state-changed"; - NMLDBusObject * dbobj; + const char *log_context = "active-connection-state-changed"; + NMLDBusObject *dbobj; guint32 state; guint32 reason; @@ -3441,17 +3441,17 @@ _dbus_nm_connection_active_state_changed_cb(GDBusConnection *connection, static void _dbus_nm_vpn_connection_state_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMClient * self = user_data; + NMClient *self = user_data; NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - const char * log_context = "vpn-connection-state-changed"; - NMLDBusObject * dbobj; + const char *log_context = "vpn-connection-state-changed"; + NMLDBusObject *dbobj; guint32 state; guint32 reason; @@ -3520,16 +3520,16 @@ _emit_permissions_changed(NMClient *self, const guint8 *old_permissions, const g static void _dbus_check_permissions_start_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; - NMClient * self; - NMClientPrivate * priv; - gs_unref_variant GVariant *ret = NULL; - nm_auto_free_variant_iter GVariantIter *v_permissions = NULL; - gs_free guint8 *old_permissions = NULL; - gs_free_error GError *error = NULL; - const char * pkey; - const char * pvalue; - int i; + nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; + NMClient *self; + NMClientPrivate *priv; + gs_unref_variant GVariant *ret = NULL; + nm_auto_free_variant_iter GVariantIter *v_permissions = NULL; + gs_free guint8 *old_permissions = NULL; + gs_free_error GError *error = NULL; + const char *pkey; + const char *pvalue; + int i; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (!ret && nm_utils_error_is_cancelled(error)) @@ -3611,14 +3611,14 @@ _dbus_check_permissions_start(NMClient *self) static void _dbus_nm_check_permissions_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * signal_interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *signal_interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMClient * self = user_data; + NMClient *self = user_data; NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("()"))) { @@ -3639,8 +3639,8 @@ _dbus_nm_check_permissions_cb(GDBusConnection *connection, static void _property_ao_notify_changed_connections_cb(NMLDBusPropertyAO *pr_ao, - NMClient * self, - NMObject * nmobj, + NMClient *self, + NMObject *nmobj, gboolean is_added /* or else removed */) { _nm_client_notify_event_queue_emit_obj_signal(self, @@ -3654,8 +3654,8 @@ _property_ao_notify_changed_connections_cb(NMLDBusPropertyAO *pr_ao, static void _property_ao_notify_changed_all_devices_cb(NMLDBusPropertyAO *pr_ao, - NMClient * self, - NMObject * nmobj, + NMClient *self, + NMObject *nmobj, gboolean is_added /* or else removed */) { _nm_client_notify_event_queue_emit_obj_signal(self, @@ -3669,8 +3669,8 @@ _property_ao_notify_changed_all_devices_cb(NMLDBusPropertyAO *pr_ao, static void _property_ao_notify_changed_devices_cb(NMLDBusPropertyAO *pr_ao, - NMClient * self, - NMObject * nmobj, + NMClient *self, + NMObject *nmobj, gboolean is_added /* or else removed */) { _nm_client_notify_event_queue_emit_obj_signal(self, @@ -3684,8 +3684,8 @@ _property_ao_notify_changed_devices_cb(NMLDBusPropertyAO *pr_ao, static void _property_ao_notify_changed_active_connections_cb(NMLDBusPropertyAO *pr_ao, - NMClient * self, - NMObject * nmobj, + NMClient *self, + NMObject *nmobj, gboolean is_added /* or else removed */) { _nm_client_notify_event_queue_emit_obj_signal(self, @@ -3701,10 +3701,10 @@ _property_ao_notify_changed_active_connections_cb(NMLDBusPropertyAO *pr_ao, typedef struct { NMLDBusObjWatcherWithPtr *obj_watcher; - const char * op_name; - NMLDBusObject * dbobj; - GTask * task; - GVariant * extra_results; + const char *op_name; + NMLDBusObject *dbobj; + GTask *task; + GVariant *extra_results; gpointer result; GType gtype; gulong cancellable_id; @@ -3801,8 +3801,8 @@ static void _request_wait_obj_watcher_cb(NMClient *self, gpointer obj_watcher_base) { NMLDBusObjWatcherWithPtr *obj_watcher = obj_watcher_base; - RequestWaitData * request_data = obj_watcher->user_data; - NMLDBusObject * dbobj; + RequestWaitData *request_data = obj_watcher->user_data; + NMLDBusObject *dbobj; dbobj = request_data->dbobj; @@ -3829,8 +3829,8 @@ static void _request_wait_cancelled_cb(GCancellable *cancellable, gpointer user_data) { RequestWaitData *request_data = user_data; - NMClient * self; - GError * error = NULL; + NMClient *self; + GError *error = NULL; nm_assert(cancellable == g_task_get_cancellable(request_data->task)); @@ -3848,17 +3848,17 @@ _request_wait_cancelled_cb(GCancellable *cancellable, gpointer user_data) } static void -_request_wait_start(GTask * task_take, +_request_wait_start(GTask *task_take, const char *op_name, GType gtype, const char *dbus_path, - GVariant * extra_results_take) + GVariant *extra_results_take) { - NMClient * self; + NMClient *self; gs_unref_object GTask *task = g_steal_pointer(&task_take); - RequestWaitData * request_data; - GCancellable * cancellable; - NMLDBusObject * dbobj; + RequestWaitData *request_data; + GCancellable *cancellable; + NMLDBusObject *dbobj; nm_assert(G_IS_TASK(task)); @@ -3922,11 +3922,11 @@ _request_wait_start(GTask * task_take, } static gpointer -_request_wait_finish(NMClient * client, +_request_wait_finish(NMClient *client, GAsyncResult *result, gpointer source_tag, - GVariant ** out_result, - GError ** error) + GVariant **out_result, + GError **error) { RequestWaitData *request_data = NULL; gpointer r; @@ -4501,7 +4501,7 @@ nm_client_set_logging(NMClient *client, const char *level, const char *domains, NMClientPermissionResult nm_client_get_permission_result(NMClient *client, NMClientPermission permission) { - NMClientPrivate * priv; + NMClientPrivate *priv; NMClientPermissionResult result = NM_CLIENT_PERMISSION_RESULT_UNKNOWN; g_return_val_if_fail(NM_IS_CLIENT(client), NM_CLIENT_PERMISSION_RESULT_UNKNOWN); @@ -4575,7 +4575,7 @@ nm_client_get_connectivity(NMClient *client) NMConnectivityState nm_client_check_connectivity(NMClient *client, GCancellable *cancellable, GError **error) { - NMClientPrivate *priv; + NMClientPrivate *priv; gs_unref_variant GVariant *ret = NULL; guint32 connectivity; @@ -4626,8 +4626,8 @@ nm_client_check_connectivity(NMClient *client, GCancellable *cancellable, GError * re-checking, and nm_client_check_connectivity(), which blocks. */ void -nm_client_check_connectivity_async(NMClient * client, - GCancellable * cancellable, +nm_client_check_connectivity_async(NMClient *client, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -4695,10 +4695,10 @@ nm_client_check_connectivity_finish(NMClient *client, GAsyncResult *result, GErr * Deprecated: 1.22: Use nm_client_save_hostname_async() or GDBusConnection. **/ gboolean -nm_client_save_hostname(NMClient * client, - const char * hostname, +nm_client_save_hostname(NMClient *client, + const char *hostname, GCancellable *cancellable, - GError ** error) + GError **error) { g_return_val_if_fail(NM_IS_CLIENT(client), FALSE); g_return_val_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable), FALSE); @@ -4728,9 +4728,9 @@ nm_client_save_hostname(NMClient * client, * or cleared. **/ void -nm_client_save_hostname_async(NMClient * client, - const char * hostname, - GCancellable * cancellable, +nm_client_save_hostname_async(NMClient *client, + const char *hostname, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -4950,10 +4950,10 @@ nm_client_get_activating_connection(NMClient *client) static void activate_connection_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - gs_unref_object GTask *task = user_data; - gs_unref_variant GVariant *ret = NULL; - const char * v_active_connection; - GError * error = NULL; + gs_unref_object GTask *task = user_data; + gs_unref_variant GVariant *ret = NULL; + const char *v_active_connection; + GError *error = NULL; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(object), result, &error); if (!ret) { @@ -5006,11 +5006,11 @@ activate_connection_cb(GObject *object, GAsyncResult *result, gpointer user_data * track the activation to its completion. **/ void -nm_client_activate_connection_async(NMClient * client, - NMConnection * connection, - NMDevice * device, - const char * specific_object, - GCancellable * cancellable, +nm_client_activate_connection_async(NMClient *client, + NMConnection *connection, + NMDevice *device, + const char *specific_object, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -5076,17 +5076,17 @@ nm_client_activate_connection_finish(NMClient *client, GAsyncResult *result, GEr /*****************************************************************************/ static void -_add_and_activate_connection_done(GObject * object, +_add_and_activate_connection_done(GObject *object, GAsyncResult *result, gboolean use_add_and_activate_v2, - GTask * task_take) + GTask *task_take) { - _nm_unused gs_unref_object GTask *task = task_take; - gs_unref_variant GVariant *ret = NULL; - GError * error = NULL; - gs_unref_variant GVariant *v_result = NULL; - const char * v_active_connection; - const char * v_path; + _nm_unused gs_unref_object GTask *task = task_take; + gs_unref_variant GVariant *ret = NULL; + GError *error = NULL; + gs_unref_variant GVariant *v_result = NULL; + const char *v_active_connection; + const char *v_path; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(object), result, &error); if (!ret) { @@ -5122,17 +5122,17 @@ _add_and_activate_connection_v2_cb(GObject *object, GAsyncResult *result, gpoint } static void -_add_and_activate_connection(NMClient * self, +_add_and_activate_connection(NMClient *self, gboolean is_v2, - NMConnection * partial, - NMDevice * device, - const char * specific_object, - GVariant * options, - GCancellable * cancellable, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + GVariant *options, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { - GVariant * arg_connection = NULL; + GVariant *arg_connection = NULL; gboolean use_add_and_activate_v2 = FALSE; const char *arg_device = NULL; gpointer source_tag; @@ -5239,11 +5239,11 @@ _add_and_activate_connection(NMClient * self, * track the activation to its completion. **/ void -nm_client_add_and_activate_connection_async(NMClient * client, - NMConnection * partial, - NMDevice * device, - const char * specific_object, - GCancellable * cancellable, +nm_client_add_and_activate_connection_async(NMClient *client, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -5326,12 +5326,12 @@ nm_client_add_and_activate_connection_finish(NMClient *client, GAsyncResult *res * Since: 1.16 **/ void -nm_client_add_and_activate_connection2(NMClient * client, - NMConnection * partial, - NMDevice * device, - const char * specific_object, - GVariant * options, - GCancellable * cancellable, +nm_client_add_and_activate_connection2(NMClient *client, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + GVariant *options, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -5364,10 +5364,10 @@ nm_client_add_and_activate_connection2(NMClient * client, * failure, in which case @error will be set. **/ NMActiveConnection * -nm_client_add_and_activate_connection2_finish(NMClient * client, +nm_client_add_and_activate_connection2_finish(NMClient *client, GAsyncResult *result, - GVariant ** out_result, - GError ** error) + GVariant **out_result, + GError **error) { return NM_ACTIVE_CONNECTION(_request_wait_finish(client, result, @@ -5392,10 +5392,10 @@ nm_client_add_and_activate_connection2_finish(NMClient * client, * Deprecated: 1.22: Use nm_client_deactivate_connection_async() or GDBusConnection. **/ gboolean -nm_client_deactivate_connection(NMClient * client, +nm_client_deactivate_connection(NMClient *client, NMActiveConnection *active, - GCancellable * cancellable, - GError ** error) + GCancellable *cancellable, + GError **error) { const char *active_path; @@ -5428,9 +5428,9 @@ nm_client_deactivate_connection(NMClient * client, * Asynchronously deactivates an active #NMActiveConnection. **/ void -nm_client_deactivate_connection_async(NMClient * client, +nm_client_deactivate_connection_async(NMClient *client, NMActiveConnection *active, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -5591,16 +5591,16 @@ nm_client_get_connection_by_uuid(NMClient *client, const char *uuid) /*****************************************************************************/ static void -_add_connection_cb(GObject * source, +_add_connection_cb(GObject *source, GAsyncResult *result, gboolean with_extra_arg, gpointer user_data) { gs_unref_variant GVariant *ret = NULL; - gs_unref_object GTask *task = user_data; + gs_unref_object GTask *task = user_data; gs_unref_variant GVariant *v_result = NULL; - const char * v_path; - GError * error = NULL; + const char *v_path; + GError *error = NULL; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (!ret) { @@ -5636,13 +5636,13 @@ _add_connection_cb_with_extra_result(GObject *object, GAsyncResult *result, gpoi } static void -_add_connection_call(NMClient * self, +_add_connection_call(NMClient *self, gpointer source_tag, gboolean ignore_out_result, - GVariant * settings, + GVariant *settings, NMSettingsAddConnection2Flags flags, - GVariant * args, - GCancellable * cancellable, + GVariant *args, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -5736,10 +5736,10 @@ _add_connection_call(NMClient * self, * completion and/or normalization of connection properties. **/ void -nm_client_add_connection_async(NMClient * client, - NMConnection * connection, +nm_client_add_connection_async(NMClient *client, + NMConnection *connection, gboolean save_to_disk, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -5798,12 +5798,12 @@ nm_client_add_connection_finish(NMClient *client, GAsyncResult *result, GError * * Since: 1.20 **/ void -nm_client_add_connection2(NMClient * client, - GVariant * settings, +nm_client_add_connection2(NMClient *client, + GVariant *settings, NMSettingsAddConnection2Flags flags, - GVariant * args, + GVariant *args, gboolean ignore_out_result, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -5834,10 +5834,10 @@ nm_client_add_connection2(NMClient * client, * Since: 1.20 */ NMRemoteConnection * -nm_client_add_connection2_finish(NMClient * client, +nm_client_add_connection2_finish(NMClient *client, GAsyncResult *result, - GVariant ** out_result, - GError ** error) + GVariant **out_result, + GError **error) { return NM_REMOTE_CONNECTION( _request_wait_finish(client, result, nm_client_add_connection2, out_result, error)); @@ -5880,11 +5880,11 @@ nm_client_add_connection2_finish(NMClient * client, * Deprecated: 1.22: Use nm_client_load_connections_async() or GDBusConnection. **/ gboolean -nm_client_load_connections(NMClient * client, - char ** filenames, - char *** failures, +nm_client_load_connections(NMClient *client, + char **filenames, + char ***failures, GCancellable *cancellable, - GError ** error) + GError **error) { gs_unref_variant GVariant *ret = NULL; @@ -5926,9 +5926,9 @@ nm_client_load_connections(NMClient * client, * See nm_client_load_connections() for more details. **/ void -nm_client_load_connections_async(NMClient * client, - char ** filenames, - GCancellable * cancellable, +nm_client_load_connections_async(NMClient *client, + char **filenames, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -5967,10 +5967,10 @@ nm_client_load_connections_async(NMClient * client, * Note that even in the success case, you might have individual @failures. **/ gboolean -nm_client_load_connections_finish(NMClient * client, - char *** failures, +nm_client_load_connections_finish(NMClient *client, + char ***failures, GAsyncResult *result, - GError ** error) + GError **error) { gs_unref_variant GVariant *ret = NULL; @@ -6040,8 +6040,8 @@ nm_client_reload_connections(NMClient *client, GCancellable *cancellable, GError * in-memory state matches the on-disk state. **/ void -nm_client_reload_connections_async(NMClient * client, - GCancellable * cancellable, +nm_client_reload_connections_async(NMClient *client, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -6152,36 +6152,36 @@ nm_client_get_dns_configuration(NMClient *client) } static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_dns_manager_configuration(NMClient * self, - NMLDBusObject * dbobj, +_notify_update_prop_dns_manager_configuration(NMClient *self, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *configuration_old = NULL; gs_unref_ptrarray GPtrArray *configuration_new = NULL; nm_assert(G_OBJECT(self) == dbobj->nmobj); if (value) { - GVariant * entry_var_tmp; + GVariant *entry_var_tmp; GVariantIter iter; - GPtrArray * array; + GPtrArray *array; configuration_new = g_ptr_array_new_with_free_func((GDestroyNotify) nm_dns_entry_unref); g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "@a{sv}", &entry_var_tmp)) { - gs_unref_variant GVariant *entry_var = entry_var_tmp; + gs_unref_variant GVariant *entry_var = entry_var_tmp; nm_auto_free_variant_iter GVariantIter *iterp_nameservers = NULL; nm_auto_free_variant_iter GVariantIter *iterp_domains = NULL; - gs_free char ** nameservers = NULL; - gs_free char ** domains = NULL; + gs_free char **nameservers = NULL; + gs_free char **domains = NULL; gboolean vpn = FALSE; - NMDnsEntry * entry; - char * interface = NULL; - char * str; + NMDnsEntry *entry; + char *interface = NULL; + char *str; gint32 priority = 0; if (!g_variant_lookup(entry_var, "nameservers", "as", &iterp_nameservers) @@ -6256,11 +6256,11 @@ nm_client_get_capabilities(NMClient *client, gsize *length) } static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_nm_capabilities(NMClient * self, - NMLDBusObject * dbobj, +_notify_update_prop_nm_capabilities(NMClient *self, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); @@ -6310,10 +6310,10 @@ nm_client_get_checkpoints(NMClient *client) static void checkpoint_create_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - gs_unref_object GTask *task = user_data; - gs_unref_variant GVariant *ret = NULL; - const char * v_checkpoint_path; - GError * error = NULL; + gs_unref_object GTask *task = user_data; + gs_unref_variant GVariant *ret = NULL; + const char *v_checkpoint_path; + GError *error = NULL; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(object), result, &error); if (!ret) { @@ -6351,11 +6351,11 @@ checkpoint_create_cb(GObject *object, GAsyncResult *result, gpointer user_data) * Since: 1.12 **/ void -nm_client_checkpoint_create(NMClient * client, - const GPtrArray * devices, +nm_client_checkpoint_create(NMClient *client, + const GPtrArray *devices, guint32 rollback_timeout, NMCheckpointCreateFlags flags, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -6421,9 +6421,9 @@ nm_client_checkpoint_create_finish(NMClient *client, GAsyncResult *result, GErro * Since: 1.12 **/ void -nm_client_checkpoint_destroy(NMClient * client, - const char * checkpoint_path, - GCancellable * cancellable, +nm_client_checkpoint_destroy(NMClient *client, + const char *checkpoint_path, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -6481,9 +6481,9 @@ nm_client_checkpoint_destroy_finish(NMClient *client, GAsyncResult *result, GErr * Since: 1.12 **/ void -nm_client_checkpoint_rollback(NMClient * client, - const char * checkpoint_path, - GCancellable * cancellable, +nm_client_checkpoint_rollback(NMClient *client, + const char *checkpoint_path, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -6526,8 +6526,8 @@ nm_client_checkpoint_rollback_finish(NMClient *client, GAsyncResult *result, GEr gs_unref_variant GVariant *ret = NULL; gs_unref_variant GVariant *v_result = NULL; GVariantIter iter; - GHashTable * hash; - const char * path; + GHashTable *hash; + const char *path; guint32 r; g_return_val_if_fail(NM_IS_CLIENT(client), NULL); @@ -6564,10 +6564,10 @@ nm_client_checkpoint_rollback_finish(NMClient *client, GAsyncResult *result, GEr * Since: 1.12 **/ void -nm_client_checkpoint_adjust_rollback_timeout(NMClient * client, - const char * checkpoint_path, +nm_client_checkpoint_adjust_rollback_timeout(NMClient *client, + const char *checkpoint_path, guint32 add_timeout, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -6603,9 +6603,9 @@ nm_client_checkpoint_adjust_rollback_timeout(NMClient * client, * Since: 1.12 **/ gboolean -nm_client_checkpoint_adjust_rollback_timeout_finish(NMClient * client, +nm_client_checkpoint_adjust_rollback_timeout_finish(NMClient *client, GAsyncResult *result, - GError ** error) + GError **error) { g_return_val_if_fail(NM_IS_CLIENT(client), FALSE); g_return_val_if_fail( @@ -6632,9 +6632,9 @@ nm_client_checkpoint_adjust_rollback_timeout_finish(NMClient * client, * Since: 1.22 **/ void -nm_client_reload(NMClient * client, +nm_client_reload(NMClient *client, NMManagerReloadFlags flags, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -6709,14 +6709,14 @@ nm_client_reload_finish(NMClient *client, GAsyncResult *result, GError **error) * Since: 1.24 **/ void -nm_client_dbus_call(NMClient * client, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +nm_client_dbus_call(NMClient *client, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -6782,13 +6782,13 @@ nm_client_dbus_call_finish(NMClient *client, GAsyncResult *result, GError **erro * Since: 1.24 **/ void -nm_client_dbus_set_property(NMClient * client, - const char * object_path, - const char * interface_name, - const char * property_name, - GVariant * value, +nm_client_dbus_set_property(NMClient *client, + const char *object_path, + const char *interface_name, + const char *property_name, + GVariant *value, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -6839,7 +6839,7 @@ nm_client_dbus_set_property_finish(NMClient *client, GAsyncResult *result, GErro static void _init_fetch_all(NMClient *self) { - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; dbus_context = nm_g_main_context_push_thread_default_if_necessary(priv->dbus_context); @@ -6936,8 +6936,8 @@ static void _init_release_all(NMClient *self) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - CList ** dbus_objects_lst_heads; - NMLDBusObject * dbobj; + CList **dbus_objects_lst_heads; + NMLDBusObject *dbobj; int i; gboolean permissions_state_changed = FALSE; @@ -7008,10 +7008,10 @@ _init_release_all(NMClient *self) static void name_owner_changed(NMClient *self, const char *name_owner) { - NMClientPrivate * priv = NM_CLIENT_GET_PRIVATE(self); - gboolean changed; - gs_free char * old_name_owner_free = NULL; - const char * old_name_owner; + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); + gboolean changed; + gs_free char *old_name_owner_free = NULL; + const char *old_name_owner; nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; name_owner = nm_str_not_empty(name_owner); @@ -7087,16 +7087,16 @@ name_owner_changed(NMClient *self, const char *name_owner) static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { - NMClient * self = user_data; + NMClient *self = user_data; NMClientPrivate *priv; - const char * new_owner; + const char *new_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) return; @@ -7113,12 +7113,12 @@ name_owner_changed_cb(GDBusConnection *connection, static void name_owner_get_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMClient * self; - NMClientPrivate *priv; - gs_unref_object GObject *context_busy_watcher = NULL; - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; - const char * name_owner = NULL; + NMClient *self; + NMClientPrivate *priv; + gs_unref_object GObject *context_busy_watcher = NULL; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + const char *name_owner = NULL; nm_utils_user_data_unpack(user_data, &self, &context_busy_watcher); @@ -7164,8 +7164,8 @@ name_owner_get_call(NMClient *self) static inline gboolean _nml_cleanup_context_busy_watcher_on_idle_cb(gpointer user_data) { - nm_auto_unref_gmaincontext GMainContext *context = NULL; - gs_unref_object GObject *context_busy_watcher = NULL; + nm_auto_unref_gmaincontext GMainContext *context = NULL; + gs_unref_object GObject *context_busy_watcher = NULL; nm_utils_user_data_unpack(user_data, &context, &context_busy_watcher); @@ -7178,7 +7178,7 @@ void nml_cleanup_context_busy_watcher_on_idle(GObject *context_busy_watcher_take, GMainContext *context) { gs_unref_object GObject *context_busy_watcher = g_steal_pointer(&context_busy_watcher_take); - GSource * cleanup_source; + GSource *cleanup_source; nm_assert(G_IS_OBJECT(context_busy_watcher)); nm_assert(context); @@ -7292,9 +7292,9 @@ _init_start_check_complete(NMClient *self) static void _init_start_cancelled_cb(GCancellable *cancellable, gpointer user_data) { - NMClient * self = user_data; + NMClient *self = user_data; NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); - GError * error; + GError *error; nm_assert(NM_IS_CLIENT(self)); nm_assert(priv->init_data); @@ -7315,7 +7315,7 @@ static gboolean _init_start_cancel_on_idle_cb(gpointer user_data) { NMClient *self = user_data; - GError * error; + GError *error; nm_utils_error_set_cancelled(&error, FALSE, NULL); _init_start_complete(self, error); @@ -7358,10 +7358,10 @@ _init_start_with_bus(NMClient *self) static void _init_start_bus_get_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMClient * self = user_data; + NMClient *self = user_data; NMClientPrivate *priv; GDBusConnection *dbus_connection; - GError * error = NULL; + GError *error = NULL; nm_assert(NM_IS_CLIENT(self)); @@ -7402,7 +7402,7 @@ _init_start(NMClient *self) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMClient * self = NM_CLIENT(object); + NMClient *self = NM_CLIENT(object); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(object); switch (prop_id) { @@ -7487,7 +7487,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_CAPABILITIES: { const guint32 *arr; - GArray * out; + GArray *out; gsize len; arr = nm_client_get_capabilities(self, &len); @@ -7536,7 +7536,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMClient * self = NM_CLIENT(object); + NMClient *self = NM_CLIENT(object); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); gboolean b; guint v_uint; @@ -7618,11 +7618,11 @@ static gboolean init_sync(GInitable *initable, GCancellable *cancellable, GError **error) { gs_unref_object NMClient *self = NULL; - NMClientPrivate * priv; - GMainContext * dbus_context; - GError * local_error = NULL; - GMainLoop * main_loop; - GObject * parent_context_busy_watcher; + NMClientPrivate *priv; + GMainContext *dbus_context; + GError *local_error = NULL; + GMainLoop *main_loop; + GObject *parent_context_busy_watcher; g_return_val_if_fail(NM_IS_CLIENT(initable), FALSE); @@ -7702,16 +7702,16 @@ init_sync(GInitable *initable, GCancellable *cancellable, GError **error) /*****************************************************************************/ static void -init_async(GAsyncInitable * initable, +init_async(GAsyncInitable *initable, int io_priority, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { - NMClientPrivate * priv; - NMClient * self; + NMClientPrivate *priv; + NMClient *self; nm_auto_pop_gmaincontext GMainContext *context = NULL; - GTask * task; + GTask *task; g_return_if_fail(NM_IS_CLIENT(initable)); @@ -7863,7 +7863,7 @@ NMClient * nm_client_new_finish(GAsyncResult *result, GError **error) { gs_unref_object GObject *source_object = NULL; - GObject * object; + GObject *object; source_object = g_async_result_get_source_object(result); g_return_val_if_fail(source_object, NULL); @@ -7877,7 +7877,7 @@ nm_client_new_finish(GAsyncResult *result, GError **error) static void constructed(GObject *object) { - NMClient * self = NM_CLIENT(object); + NMClient *self = NM_CLIENT(object); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); priv->main_context = g_main_context_ref_thread_default(); @@ -7890,7 +7890,7 @@ constructed(GObject *object) static void dispose(GObject *object) { - NMClient * self = NM_CLIENT(object); + NMClient *self = NM_CLIENT(object); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self); nm_assert(!priv->init_data); diff --git a/src/libnm-client-impl/nm-dbus-helpers.c b/src/libnm-client-impl/nm-dbus-helpers.c index 3b5f9ff88a..c413bf0231 100644 --- a/src/libnm-client-impl/nm-dbus-helpers.c +++ b/src/libnm-client-impl/nm-dbus-helpers.c @@ -54,7 +54,7 @@ _nm_dbus_bind_properties(gpointer object, gpointer skeleton) static char * signal_name_from_method_name(const char *method_name) { - GString * signal_name; + GString *signal_name; const char *p; signal_name = g_string_new("handle"); @@ -68,8 +68,8 @@ signal_name_from_method_name(const char *method_name) } static void -_nm_dbus_method_meta_marshal(GClosure * closure, - GValue * return_value, +_nm_dbus_method_meta_marshal(GClosure *closure, + GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, @@ -94,9 +94,9 @@ _nm_dbus_bind_methods(gpointer object, gpointer skeleton, ...) { va_list ap; const char *method_name; - char * signal_name; + char *signal_name; GCallback handler; - GClosure * closure; + GClosure *closure; va_start(ap, skeleton); while ((method_name = va_arg(ap, const char *)) && (handler = va_arg(ap, GCallback))) { diff --git a/src/libnm-client-impl/nm-device-6lowpan.c b/src/libnm-client-impl/nm-device-6lowpan.c index e03b4a0037..39558f2542 100644 --- a/src/libnm-client-impl/nm-device-6lowpan.c +++ b/src/libnm-client-impl/nm-device-6lowpan.c @@ -109,7 +109,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_lowpan = NML_DBUS_META_IFA static void nm_device_6lowpan_class_init(NMDevice6LowpanClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-adsl.c b/src/libnm-client-impl/nm-device-adsl.c index 65f875454f..58366c8f8f 100644 --- a/src/libnm-client-impl/nm-device-adsl.c +++ b/src/libnm-client-impl/nm-device-adsl.c @@ -107,7 +107,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_adsl = NML_DBUS_META_IFACE static void nm_device_adsl_class_init(NMDeviceAdslClass *adsl_class) { - GObjectClass * object_class = G_OBJECT_CLASS(adsl_class); + GObjectClass *object_class = G_OBJECT_CLASS(adsl_class); NMDeviceClass *device_class = NM_DEVICE_CLASS(adsl_class); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-bond.c b/src/libnm-client-impl/nm-device-bond.c index add5463999..e8b3e3ebc8 100644 --- a/src/libnm-client-impl/nm-device-bond.c +++ b/src/libnm-client-impl/nm-device-bond.c @@ -158,7 +158,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bond = NML_DBUS_META_IFACE static void nm_device_bond_class_init(NMDeviceBondClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-bridge.c b/src/libnm-client-impl/nm-device-bridge.c index fb0ad873da..6d5d6f9502 100644 --- a/src/libnm-client-impl/nm-device-bridge.c +++ b/src/libnm-client-impl/nm-device-bridge.c @@ -163,7 +163,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bridge = NML_DBUS_META_IFA static void nm_device_bridge_class_init(NMDeviceBridgeClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-bt.c b/src/libnm-client-impl/nm-device-bt.c index 074ada6622..b006cec45e 100644 --- a/src/libnm-client-impl/nm-device-bt.c +++ b/src/libnm-client-impl/nm-device-bt.c @@ -21,7 +21,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_NAME, PROP_BT_CAPABILITIES, ); typedef struct { - char * name; + char *name; guint32 bt_capabilities; } NMDeviceBtPrivate; @@ -96,7 +96,7 @@ static NMBluetoothCapabilities get_connection_bt_type(NMConnection *connection) { NMSettingBluetooth *s_bt; - const char * bt_type; + const char *bt_type; s_bt = nm_connection_get_setting_bluetooth(connection); if (!s_bt) @@ -116,8 +116,8 @@ get_connection_bt_type(NMConnection *connection) static gboolean connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMSettingBluetooth * s_bt; - const char * hw_addr, *setting_addr; + NMSettingBluetooth *s_bt; + const char *hw_addr, *setting_addr; NMBluetoothCapabilities dev_caps; NMBluetoothCapabilities bt_type; @@ -235,7 +235,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bluetooth = NML_DBUS_META_ static void nm_device_bt_class_init(NMDeviceBtClass *bt_class) { - GObjectClass * object_class = G_OBJECT_CLASS(bt_class); + GObjectClass *object_class = G_OBJECT_CLASS(bt_class); NMDeviceClass *device_class = NM_DEVICE_CLASS(bt_class); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-ethernet.c b/src/libnm-client-impl/nm-device-ethernet.c index b32decde14..42b7262ddc 100644 --- a/src/libnm-client-impl/nm-device-ethernet.c +++ b/src/libnm-client-impl/nm-device-ethernet.c @@ -27,8 +27,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PERM_HW_ADDRESS, PROP_S390_SUBCHANNELS, ); typedef struct _NMDeviceEthernetPrivate { - char ** s390_subchannels; - char * perm_hw_address; + char **s390_subchannels; + char *perm_hw_address; guint32 speed; bool carrier; } NMDeviceEthernetPrivate; @@ -132,7 +132,7 @@ static gboolean match_subchans(NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_mac) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - const char *const * subchans; + const char *const *subchans; gsize num1, num2; gsize i, j; @@ -193,7 +193,7 @@ connection_compatible(NMDevice *device, NMConnection *connection, GError **error s_wired = nm_connection_get_setting_wired(connection); /* Wired setting optional for PPPoE */ if (s_wired) { - const char * perm_addr, *s_mac; + const char *perm_addr, *s_mac; gboolean try_mac = TRUE; const char *const *mac_blacklist; int i; @@ -292,7 +292,7 @@ finalize(GObject *object) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceEthernet * device = NM_DEVICE_ETHERNET(object); + NMDeviceEthernet *device = NM_DEVICE_ETHERNET(object); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(device); switch (prop_id) { @@ -338,7 +338,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wired = NML_DBUS_META_IFAC static void nm_device_ethernet_class_init(NMDeviceEthernetClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); g_type_class_add_private(klass, sizeof(NMDeviceEthernetPrivate)); diff --git a/src/libnm-client-impl/nm-device-generic.c b/src/libnm-client-impl/nm-device-generic.c index 9dcc8c911d..4a4200035d 100644 --- a/src/libnm-client-impl/nm-device-generic.c +++ b/src/libnm-client-impl/nm-device-generic.c @@ -147,7 +147,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_generic = NML_DBUS_META_IF static void nm_device_generic_class_init(NMDeviceGenericClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-infiniband.c b/src/libnm-client-impl/nm-device-infiniband.c index 7e4cc054c0..8bca721e9b 100644 --- a/src/libnm-client-impl/nm-device-infiniband.c +++ b/src/libnm-client-impl/nm-device-infiniband.c @@ -77,7 +77,7 @@ static gboolean connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMSettingInfiniband *s_infiniband; - const char * hwaddr, *setting_hwaddr; + const char *hwaddr, *setting_hwaddr; if (!NM_DEVICE_CLASS(nm_device_infiniband_parent_class) ->connection_compatible(device, connection, error)) @@ -156,7 +156,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_infiniband = NML_DBUS_META static void nm_device_infiniband_class_init(NMDeviceInfinibandClass *ib_class) { - GObjectClass * object_class = G_OBJECT_CLASS(ib_class); + GObjectClass *object_class = G_OBJECT_CLASS(ib_class); NMDeviceClass *device_class = NM_DEVICE_CLASS(ib_class); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-ip-tunnel.c b/src/libnm-client-impl/nm-device-ip-tunnel.c index 14c7228209..c34ad84b05 100644 --- a/src/libnm-client-impl/nm-device-ip-tunnel.c +++ b/src/libnm-client-impl/nm-device-ip-tunnel.c @@ -30,10 +30,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MODE, typedef struct { NMLDBusPropertyO parent; - char * local; - char * remote; - char * input_key; - char * output_key; + char *local; + char *remote; + char *input_key; + char *output_key; guint32 mode; guint32 flow_label; guint32 flags; @@ -383,7 +383,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_iptunnel = NML_DBUS_META_I static void nm_device_ip_tunnel_class_init(NMDeviceIPTunnelClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-macsec.c b/src/libnm-client-impl/nm-device-macsec.c index faa5be7e74..525d32d0b7 100644 --- a/src/libnm-client-impl/nm-device-macsec.c +++ b/src/libnm-client-impl/nm-device-macsec.c @@ -29,7 +29,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, typedef struct { NMLDBusPropertyO parent; - char * validation; + char *validation; guint64 sci; guint64 cipher_suite; guint32 window; @@ -428,7 +428,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_macsec = NML_DBUS_META_IFA static void nm_device_macsec_class_init(NMDeviceMacsecClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-macvlan.c b/src/libnm-client-impl/nm-device-macvlan.c index ddb36bab2b..a8363c930c 100644 --- a/src/libnm-client-impl/nm-device-macvlan.c +++ b/src/libnm-client-impl/nm-device-macvlan.c @@ -19,7 +19,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_MODE, PROP_NO_PROMISC, PROP_ typedef struct { NMLDBusPropertyO parent; - char * mode; + char *mode; bool no_promisc; bool tap; } NMDeviceMacvlanPrivate; @@ -138,7 +138,7 @@ static gboolean connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE(device); - NMSettingMacvlan * s_macvlan; + NMSettingMacvlan *s_macvlan; if (!NM_DEVICE_CLASS(nm_device_macvlan_parent_class) ->connection_compatible(device, connection, error)) @@ -227,7 +227,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_macvlan = NML_DBUS_META_IF static void nm_device_macvlan_class_init(NMDeviceMacvlanClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-modem.c b/src/libnm-client-impl/nm-device-modem.c index 57e09bc65d..73b38d3e0a 100644 --- a/src/libnm-client-impl/nm-device-modem.c +++ b/src/libnm-client-impl/nm-device-modem.c @@ -23,9 +23,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MODEM_CAPABILITIES, PROP_APN, ); typedef struct { - char * device_id; - char * operator_code; - char * apn; + char *device_id; + char *operator_code; + char *apn; guint32 modem_capabilities; guint32 current_capabilities; } NMDeviceModemPrivate; @@ -161,8 +161,8 @@ get_type_description(NMDevice *device) static gboolean connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMSettingGsm * s_gsm; - NMSettingCdma * s_cdma; + NMSettingGsm *s_gsm; + NMSettingCdma *s_cdma; NMDeviceModemCapabilities current_caps; if (!NM_DEVICE_CLASS(nm_device_modem_parent_class) @@ -282,7 +282,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_modem = NML_DBUS_META_IFAC static void nm_device_modem_class_init(NMDeviceModemClass *modem_class) { - GObjectClass * object_class = G_OBJECT_CLASS(modem_class); + GObjectClass *object_class = G_OBJECT_CLASS(modem_class); NMDeviceClass *device_class = NM_DEVICE_CLASS(modem_class); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-olpc-mesh.c b/src/libnm-client-impl/nm-device-olpc-mesh.c index 779990aad8..26fceb3bd5 100644 --- a/src/libnm-client-impl/nm-device-olpc-mesh.c +++ b/src/libnm-client-impl/nm-device-olpc-mesh.c @@ -158,7 +158,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_olpcmesh = NML_DBUS_META_I static void nm_device_olpc_mesh_class_init(NMDeviceOlpcMeshClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-ovs-bridge.c b/src/libnm-client-impl/nm-device-ovs-bridge.c index 465957c456..8c30fc3fdf 100644 --- a/src/libnm-client-impl/nm-device-ovs-bridge.c +++ b/src/libnm-client-impl/nm-device-ovs-bridge.c @@ -130,7 +130,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsbridge = NML_DBUS_META_ static void nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-ovs-port.c b/src/libnm-client-impl/nm-device-ovs-port.c index 76ae7a584b..9e20e5b8fa 100644 --- a/src/libnm-client-impl/nm-device-ovs-port.c +++ b/src/libnm-client-impl/nm-device-ovs-port.c @@ -130,7 +130,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsport = NML_DBUS_META_IF static void nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-team.c b/src/libnm-client-impl/nm-device-team.c index 9f7fe76810..0a42089a98 100644 --- a/src/libnm-client-impl/nm-device-team.c +++ b/src/libnm-client-impl/nm-device-team.c @@ -192,7 +192,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_team = NML_DBUS_META_IFACE static void nm_device_team_class_init(NMDeviceTeamClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-tun.c b/src/libnm-client-impl/nm-device-tun.c index 8b8ca0fe29..353b4bdc0c 100644 --- a/src/libnm-client-impl/nm-device-tun.c +++ b/src/libnm-client-impl/nm-device-tun.c @@ -24,7 +24,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MODE, PROP_MULTI_QUEUE, ); typedef struct { - char * mode; + char *mode; gint64 owner; gint64 group; bool no_pi; @@ -191,7 +191,7 @@ connection_compatible(NMDevice *device, NMConnection *connection, GError **error { NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE(device); NMSettingTunMode mode; - NMSettingTun * s_tun; + NMSettingTun *s_tun; if (!NM_DEVICE_CLASS(nm_device_tun_parent_class) ->connection_compatible(device, connection, error)) @@ -294,7 +294,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_tun = NML_DBUS_META_IFACE_ static void nm_device_tun_class_init(NMDeviceTunClass *gre_class) { - GObjectClass * object_class = G_OBJECT_CLASS(gre_class); + GObjectClass *object_class = G_OBJECT_CLASS(gre_class); NMDeviceClass *device_class = NM_DEVICE_CLASS(gre_class); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-device-veth.c b/src/libnm-client-impl/nm-device-veth.c index f35f09b198..d9fc325bb7 100644 --- a/src/libnm-client-impl/nm-device-veth.c +++ b/src/libnm-client-impl/nm-device-veth.c @@ -95,7 +95,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_veth = static void nm_device_veth_class_init(NMDeviceVethClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-vlan.c b/src/libnm-client-impl/nm-device-vlan.c index 4c2a435bd5..882fc171c8 100644 --- a/src/libnm-client-impl/nm-device-vlan.c +++ b/src/libnm-client-impl/nm-device-vlan.c @@ -105,10 +105,10 @@ nm_device_vlan_get_vlan_id(NMDeviceVlan *device) static gboolean connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; NMSettingWired *s_wired; - const char * setting_hwaddr; - const char * hw_address; + const char *setting_hwaddr; + const char *hw_address; if (!NM_DEVICE_CLASS(nm_device_vlan_parent_class) ->connection_compatible(device, connection, error)) @@ -205,7 +205,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_vlan = NML_DBUS_META_IFACE static void nm_device_vlan_class_init(NMDeviceVlanClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-vrf.c b/src/libnm-client-impl/nm-device-vrf.c index bbf37810c5..592785f979 100644 --- a/src/libnm-client-impl/nm-device-vrf.c +++ b/src/libnm-client-impl/nm-device-vrf.c @@ -115,7 +115,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_vrf = NML_DBUS_META_IFACE_ static void nm_device_vrf_class_init(NMDeviceVrfClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-vxlan.c b/src/libnm-client-impl/nm-device-vxlan.c index 6fac3b715e..d7bd9cbe94 100644 --- a/src/libnm-client-impl/nm-device-vxlan.c +++ b/src/libnm-client-impl/nm-device-vxlan.c @@ -34,8 +34,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CARRIER, typedef struct { NMLDBusPropertyO parent; - char * group; - char * local; + char *group; + char *local; guint32 id; guint32 limit; guint32 ageing; @@ -522,7 +522,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_vxlan = NML_DBUS_META_IFAC static void nm_device_vxlan_class_init(NMDeviceVxlanClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-wifi-p2p.c b/src/libnm-client-impl/nm-device-wifi-p2p.c index 2daaf77484..fb72f25052 100644 --- a/src/libnm-client-impl/nm-device-wifi-p2p.c +++ b/src/libnm-client-impl/nm-device-wifi-p2p.c @@ -107,7 +107,7 @@ nm_device_wifi_p2p_get_peer_by_path(NMDeviceWifiP2P *device, const char *path) { const GPtrArray *peers; int i; - NMWifiP2PPeer * peer = NULL; + NMWifiP2PPeer *peer = NULL; g_return_val_if_fail(NM_IS_DEVICE_WIFI_P2P(device), NULL); g_return_val_if_fail(path != NULL, NULL); @@ -145,9 +145,9 @@ nm_device_wifi_p2p_get_peer_by_path(NMDeviceWifiP2P *device, const char *path) * Since: 1.16 **/ void -nm_device_wifi_p2p_start_find(NMDeviceWifiP2P * device, - GVariant * options, - GCancellable * cancellable, +nm_device_wifi_p2p_start_find(NMDeviceWifiP2P *device, + GVariant *options, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -207,8 +207,8 @@ nm_device_wifi_p2p_start_find_finish(NMDeviceWifiP2P *device, GAsyncResult *resu * Since: 1.16 **/ void -nm_device_wifi_p2p_stop_find(NMDeviceWifiP2P * device, - GCancellable * cancellable, +nm_device_wifi_p2p_stop_find(NMDeviceWifiP2P *device, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -286,8 +286,8 @@ get_type_description(NMDevice *device) static void _property_ao_notify_changed_peers_cb(NMLDBusPropertyAO *pr_ao, - NMClient * client, - NMObject * nmobj, + NMClient *client, + NMObject *nmobj, gboolean is_added /* or else removed */) { _nm_client_notify_event_queue_emit_obj_signal(client, @@ -342,7 +342,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wifip2p = NML_DBUS_META_IF static void nm_device_wifi_p2p_class_init(NMDeviceWifiP2PClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device-wifi.c b/src/libnm-client-impl/nm-device-wifi.c index cfbbea2341..b062ea9e04 100644 --- a/src/libnm-client-impl/nm-device-wifi.c +++ b/src/libnm-client-impl/nm-device-wifi.c @@ -33,7 +33,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PERM_HW_ADDRESS, typedef struct { NMLDBusPropertyAO access_points; NMLDBusPropertyO active_access_point; - char * perm_hw_address; + char *perm_hw_address; gint64 last_scan; guint32 mode; guint32 bitrate; @@ -212,7 +212,7 @@ nm_device_wifi_get_access_point_by_path(NMDeviceWifi *device, const char *path) { const GPtrArray *aps; int i; - NMAccessPoint * ap = NULL; + NMAccessPoint *ap = NULL; g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), NULL); g_return_val_if_fail(path != NULL, NULL); @@ -299,9 +299,9 @@ nm_device_wifi_request_scan(NMDeviceWifi *device, GCancellable *cancellable, GEr **/ gboolean nm_device_wifi_request_scan_options(NMDeviceWifi *device, - GVariant * options, + GVariant *options, GCancellable *cancellable, - GError ** error) + GError **error) { g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), FALSE); g_return_val_if_fail(!options || g_variant_is_of_type(options, G_VARIANT_TYPE_VARDICT), FALSE); @@ -342,8 +342,8 @@ NM_BACKPORT_SYMBOL( * that for the scan to complete. **/ void -nm_device_wifi_request_scan_async(NMDeviceWifi * device, - GCancellable * cancellable, +nm_device_wifi_request_scan_async(NMDeviceWifi *device, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -371,9 +371,9 @@ nm_device_wifi_request_scan_async(NMDeviceWifi * device, * Since: 1.2 **/ void -nm_device_wifi_request_scan_options_async(NMDeviceWifi * device, - GVariant * options, - GCancellable * cancellable, +nm_device_wifi_request_scan_options_async(NMDeviceWifi *device, + GVariant *options, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -404,8 +404,8 @@ NM_BACKPORT_SYMBOL(libnm_1_0_6, void, nm_device_wifi_request_scan_options_async, (NMDeviceWifi * device, - GVariant * options, - GCancellable * cancellable, + GVariant *options, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data), (device, options, cancellable, callback, user_data)); @@ -453,11 +453,11 @@ has_proto(NMSettingWirelessSecurity *s_wsec, const char *proto) static gboolean connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { - NMSettingWireless * s_wifi; + NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - const char * hwaddr, *setting_hwaddr; + const char *hwaddr, *setting_hwaddr; NMDeviceWifiCapabilities wifi_caps; - const char * key_mgmt; + const char *key_mgmt; if (!NM_DEVICE_CLASS(nm_device_wifi_parent_class) ->connection_compatible(device, connection, error)) @@ -537,8 +537,8 @@ get_setting_type(NMDevice *device) static void _property_ao_notify_changed_access_points_cb(NMLDBusPropertyAO *pr_ao, - NMClient * client, - NMObject * nmobj, + NMClient *client, + NMObject *nmobj, gboolean is_added /* or else removed */) { _nm_client_notify_event_queue_emit_obj_signal(client, @@ -640,7 +640,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wireless = NML_DBUS_META_I static void nm_device_wifi_class_init(NMDeviceWifiClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); diff --git a/src/libnm-client-impl/nm-device.c b/src/libnm-client-impl/nm-device.c index a680a05f9c..238e7c1709 100644 --- a/src/libnm-client-impl/nm-device.c +++ b/src/libnm-client-impl/nm-device.c @@ -90,16 +90,16 @@ enum { typedef struct _NMDevicePrivate { NMLDBusPropertyO property_o[_PROPERTY_O_IDX_NUM]; NMLDBusPropertyAO property_ao[_PROPERTY_AO_IDX_NUM]; - GPtrArray * lldp_neighbors; - char * driver; - char * driver_version; - char * hw_address; - char * interface; - char * ip_interface; - char * firmware_version; - char * physical_port_id; - char * udi; - char * path; + GPtrArray *lldp_neighbors; + char *driver; + char *driver_version; + char *hw_address; + char *interface; + char *ip_interface; + char *firmware_version; + char *physical_port_id; + char *udi; + char *path; guint32 capabilities; guint32 device_type; guint32 ip4_connectivity; @@ -121,12 +121,12 @@ typedef struct _NMDevicePrivate { guint32 old_state; struct udev *udev; - char * type_description; - char * product; - char * vendor; - char * short_vendor; - char * description; - char * bus_name; + char *type_description; + char *product; + char *vendor; + char *short_vendor; + char *description; + char *bus_name; } NMDevicePrivate; @@ -168,7 +168,7 @@ static void _notify_event_state_changed(NMClient *client, NMClientNotifyEventWithPtr *notify_event) { gs_unref_object NMDevice *self = notify_event->user_data; - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NML_NMCLIENT_LOG_T(client, "[%s] emit Device's StateChanged signal %u -> %u, reason: %u", @@ -186,13 +186,13 @@ _notify_event_state_changed(NMClient *client, NMClientNotifyEventWithPtr *notify } static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_state_reason(NMClient * client, - NMLDBusObject * dbobj, +_notify_update_prop_state_reason(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMDevice * self = NM_DEVICE(dbobj->nmobj); + NMDevice *self = NM_DEVICE(dbobj->nmobj); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); guint32 new_state = NM_DEVICE_STATE_UNKNOWN; guint32 reason = NM_DEVICE_STATE_REASON_NONE; @@ -230,26 +230,26 @@ _notify_update_prop_state_reason(NMClient * client, } static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_lldp_neighbors(NMClient * client, - NMLDBusObject * dbobj, +_notify_update_prop_lldp_neighbors(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMDevice * self = NM_DEVICE(dbobj->nmobj); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - gs_unref_ptrarray GPtrArray *old = NULL; - gs_unref_ptrarray GPtrArray *new = NULL; - GVariantIter * attrs_iter; - GVariantIter iter; + NMDevice *self = NM_DEVICE(dbobj->nmobj); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + gs_unref_ptrarray GPtrArray *old = NULL; + gs_unref_ptrarray GPtrArray *new = NULL; + GVariantIter *attrs_iter; + GVariantIter iter; new = g_ptr_array_new_with_free_func((GDestroyNotify) nm_lldp_neighbor_unref); if (value) { g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "a{sv}", &attrs_iter)) { - GVariant * attr_variant; - const char * attr_name; + GVariant *attr_variant; + const char *attr_name; NMLldpNeighbor *neigh; /* Note that there is no public API to mutate a NMLldpNeighbor instance. @@ -477,7 +477,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMDevice * self = NM_DEVICE(object); + NMDevice *self = NM_DEVICE(object); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean b; @@ -621,7 +621,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT static void nm_device_class_init(NMDeviceClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); g_type_class_add_private(klass, sizeof(NMDevicePrivate)); @@ -1247,7 +1247,7 @@ const char * nm_device_get_type_description(NMDevice *device) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(device); - const char * desc, *typename; + const char *desc, *typename; /* BEWARE: this function should return the same value * as nm_device_get_type_description() in nm-core. */ @@ -1296,13 +1296,13 @@ nm_device_get_ports(NMDevice *device) } NMLDBusNotifyUpdatePropFlags -_nm_device_notify_update_prop_hw_address(NMClient * client, - NMLDBusObject * dbobj, +_nm_device_notify_update_prop_hw_address(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMDevice * self = NM_DEVICE(dbobj->nmobj); + NMDevice *self = NM_DEVICE(dbobj->nmobj); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean is_new = (meta_iface == &_nml_dbus_meta_iface_nm_device); gboolean changed = FALSE; @@ -1360,18 +1360,18 @@ nm_device_get_hw_address(NMDevice *device) } NMLDBusNotifyUpdatePropFlags -_nm_device_notify_update_prop_ports(NMClient * client, - NMLDBusObject * dbobj, +_nm_device_notify_update_prop_ports(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { const NMLDBusMetaProperty *meta_property = &_nml_dbus_meta_iface_nm_device.dbus_properties[_NML_DEVICE_META_PROPERTY_INDEX_PORTS]; NMLDBusNotifyUpdatePropFlags notify_update_prop_flags; - NMDevice * self = NM_DEVICE(dbobj->nmobj); - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMDeviceClass * klass; + NMDevice *self = NM_DEVICE(dbobj->nmobj); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMDeviceClass *klass; gboolean is_new = (meta_iface == &_nml_dbus_meta_iface_nm_device); nm_assert(nm_streq(meta_property->dbus_property_name, "Ports")); @@ -1851,10 +1851,10 @@ get_device_generic_type_name_with_iface(NMDevice *device) static const char * get_bus_name(NMDevice *device) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(device); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(device); struct udev_device *udevice; - const char * ifname; - const char * bus; + const char *ifname; + const char *bus; if (priv->bus_name) goto out; @@ -1893,17 +1893,17 @@ out: } static char * -_get_udev_property(NMDevice * device, +_get_udev_property(NMDevice *device, const char *enc_prop, /* ID_XXX_ENC */ const char *db_prop) /* ID_XXX_FROM_DATABASE */ { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(device); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(device); struct udev_device *udev_device; struct udev_device *tmpdev; - const char * ifname; + const char *ifname; guint32 count = 0; - char * enc_value = NULL; - char * db_value = NULL; + char *enc_value = NULL; + char *db_value = NULL; if (!priv->udev) return NULL; @@ -1944,7 +1944,7 @@ _get_udev_property(NMDevice * device, } static char * -_get_udev_property_utf8safe(NMDevice * device, +_get_udev_property_utf8safe(NMDevice *device, const char *enc_prop, /* ID_XXX_ENC */ const char *db_prop) /* ID_XXX_FROM_DATABASE */ { @@ -2023,8 +2023,8 @@ static void ensure_description(NMDevice *device) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(device); - GParamSpec * name_prop; - gs_free char * short_product = NULL; + GParamSpec *name_prop; + gs_free char *short_product = NULL; priv->short_vendor = nm_str_realloc(nm_utils_fixup_vendor_string(nm_device_get_vendor(device))); @@ -2133,7 +2133,7 @@ find_duplicates(char **names, gboolean *duplicates, int num_devices) char ** nm_device_disambiguate_names(NMDevice **devices, int num_devices) { - char ** names; + char **names; gboolean *duplicates; int i; @@ -2162,7 +2162,7 @@ nm_device_disambiguate_names(NMDevice **devices, int num_devices) for (i = 0; i < num_devices; i++) { if (duplicates[i]) { const char *bus = get_bus_name(devices[i]); - char * name; + char *name; if (!bus) continue; @@ -2186,7 +2186,7 @@ nm_device_disambiguate_names(NMDevice **devices, int num_devices) for (i = 0; i < num_devices; i++) { if (duplicates[i]) { const char *vendor = get_short_vendor(devices[i]); - char * name; + char *name; if (!vendor) continue; @@ -2207,7 +2207,7 @@ nm_device_disambiguate_names(NMDevice **devices, int num_devices) for (i = 0; i < num_devices; i++) { if (duplicates[i] && NM_IS_DEVICE_BT(devices[i])) { const char *devname = nm_device_bt_get_name(NM_DEVICE_BT(devices[i])); - char * name; + char *name; if (!devname) continue; @@ -2382,12 +2382,12 @@ nm_device_is_software(NMDevice *device) * Deprecated: 1.22: Use nm_device_reapply_async() or GDBusConnection. **/ gboolean -nm_device_reapply(NMDevice * device, +nm_device_reapply(NMDevice *device, NMConnection *connection, guint64 version_id, guint32 flags, GCancellable *cancellable, - GError ** error) + GError **error) { GVariant *arg_connection = NULL; @@ -2434,11 +2434,11 @@ nm_device_reapply(NMDevice * device, * Since: 1.2 **/ void -nm_device_reapply_async(NMDevice * device, - NMConnection * connection, +nm_device_reapply_async(NMDevice *device, + NMConnection *connection, guint64 version_id, guint32 flags, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -2515,16 +2515,16 @@ nm_device_reapply_finish(NMDevice *device, GAsyncResult *result, GError **error) * Deprecated: 1.22: Use nm_device_get_applied_connection_async() or GDBusConnection. **/ NMConnection * -nm_device_get_applied_connection(NMDevice * device, +nm_device_get_applied_connection(NMDevice *device, guint32 flags, - guint64 * version_id, + guint64 *version_id, GCancellable *cancellable, - GError ** error) + GError **error) { gs_unref_variant GVariant *ret = NULL; gs_unref_variant GVariant *v_connection = NULL; guint64 v_version_id; - NMConnection * connection; + NMConnection *connection; g_return_val_if_fail(NM_IS_DEVICE(device), NULL); g_return_val_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable), NULL); @@ -2569,9 +2569,9 @@ nm_device_get_applied_connection(NMDevice * device, * Since: 1.2 **/ void -nm_device_get_applied_connection_async(NMDevice * device, +nm_device_get_applied_connection_async(NMDevice *device, guint32 flags, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -2613,15 +2613,15 @@ nm_device_get_applied_connection_async(NMDevice * device, * Since: 1.2 **/ NMConnection * -nm_device_get_applied_connection_finish(NMDevice * device, +nm_device_get_applied_connection_finish(NMDevice *device, GAsyncResult *result, - guint64 * version_id, - GError ** error) + guint64 *version_id, + GError **error) { gs_unref_variant GVariant *ret = NULL; gs_unref_variant GVariant *v_connection = NULL; guint64 v_version_id; - NMConnection * connection; + NMConnection *connection; g_return_val_if_fail(NM_IS_DEVICE(device), NULL); g_return_val_if_fail(nm_g_task_is_valid(result, device, nm_device_get_applied_connection_async), @@ -2691,8 +2691,8 @@ nm_device_disconnect(NMDevice *device, GCancellable *cancellable, GError **error * manual network connection request. **/ void -nm_device_disconnect_async(NMDevice * device, - GCancellable * cancellable, +nm_device_disconnect_async(NMDevice *device, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -2778,8 +2778,8 @@ nm_device_delete(NMDevice *device, GCancellable *cancellable, GError **error) * be deleted. **/ void -nm_device_delete_async(NMDevice * device, - GCancellable * cancellable, +nm_device_delete_async(NMDevice *device, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -2848,7 +2848,7 @@ static gboolean connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { const char *config_iface, *device_iface; - GError * local = NULL; + GError *local = NULL; if (!nm_connection_verify(connection, &local)) { g_set_error(error, @@ -3114,8 +3114,8 @@ nm_lldp_neighbor_get_attr_names(NMLldpNeighbor *neighbor) **/ gboolean nm_lldp_neighbor_get_attr_string_value(NMLldpNeighbor *neighbor, - const char * name, - const char ** out_value) + const char *name, + const char **out_value) { GVariant *variant; diff --git a/src/libnm-client-impl/nm-dhcp-config.c b/src/libnm-client-impl/nm-dhcp-config.c index c7f9a87a07..1f90849101 100644 --- a/src/libnm-client-impl/nm-dhcp-config.c +++ b/src/libnm-client-impl/nm-dhcp-config.c @@ -30,21 +30,21 @@ G_DEFINE_ABSTRACT_TYPE(NMDhcpConfig, nm_dhcp_config, NM_TYPE_OBJECT) /*****************************************************************************/ static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_options(NMClient * client, - NMLDBusObject * dbobj, +_notify_update_prop_options(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMDhcpConfig * self = NM_DHCP_CONFIG(dbobj->nmobj); + NMDhcpConfig *self = NM_DHCP_CONFIG(dbobj->nmobj); NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE(self); g_hash_table_remove_all(priv->options); if (value) { GVariantIter iter; - const char * key; - GVariant * opt; + const char *key; + GVariant *opt; g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "{&sv}", &key, &opt)) { diff --git a/src/libnm-client-impl/nm-dns-manager.c b/src/libnm-client-impl/nm-dns-manager.c index f7c564ffeb..1fdcdd9bae 100644 --- a/src/libnm-client-impl/nm-dns-manager.c +++ b/src/libnm-client-impl/nm-dns-manager.c @@ -23,9 +23,9 @@ G_DEFINE_BOXED_TYPE(NMDnsEntry, nm_dns_entry, nm_dns_entry_dup, nm_dns_entry_unr struct NMDnsEntry { guint refcount; - char * interface; - char ** nameservers; - char ** domains; + char *interface; + char **nameservers; + char **domains; int priority; gboolean vpn; }; @@ -38,7 +38,7 @@ struct NMDnsEntry { * Returns: (transfer full): the new #NMDnsEntry object, or %NULL on error **/ NMDnsEntry * -nm_dns_entry_new(const char * interface, +nm_dns_entry_new(const char *interface, const char *const *nameservers, const char *const *domains, int priority, diff --git a/src/libnm-client-impl/nm-dns-manager.h b/src/libnm-client-impl/nm-dns-manager.h index e6159e617f..20a5286ec6 100644 --- a/src/libnm-client-impl/nm-dns-manager.h +++ b/src/libnm-client-impl/nm-dns-manager.h @@ -12,7 +12,7 @@ #include "nm-client.h" -NMDnsEntry *nm_dns_entry_new(const char * interface, +NMDnsEntry *nm_dns_entry_new(const char *interface, const char *const *nameservers, const char *const *domains, int priority, diff --git a/src/libnm-client-impl/nm-ip-config.c b/src/libnm-client-impl/nm-ip-config.c index 5666888c3a..2307ce2c73 100644 --- a/src/libnm-client-impl/nm-ip-config.c +++ b/src/libnm-client-impl/nm-ip-config.c @@ -31,11 +31,11 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMIPConfig, typedef struct _NMIPConfigPrivate { GPtrArray *addresses; GPtrArray *routes; - char ** nameservers; - char ** domains; - char ** searches; - char ** wins_servers; - char * gateway; + char **nameservers; + char **domains; + char **searches; + char **wins_servers; + char *gateway; bool addresses_new_style : 1; bool routes_new_style : 1; @@ -51,14 +51,14 @@ G_DEFINE_ABSTRACT_TYPE(NMIPConfig, nm_ip_config, NM_TYPE_OBJECT) /*****************************************************************************/ static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_addresses(NMClient * client, - NMLDBusObject * dbobj, +_notify_update_prop_addresses(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMIPConfig * self = NM_IP_CONFIG(dbobj->nmobj); - NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + NMIPConfig *self = NM_IP_CONFIG(dbobj->nmobj); + NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *addresses_old = NULL; gs_unref_ptrarray GPtrArray *addresses_new = NULL; int addr_family = meta_iface == &_nml_dbus_meta_iface_nm_ip4config ? AF_INET : AF_INET6; @@ -91,14 +91,14 @@ _notify_update_prop_addresses(NMClient * client, } static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_routes(NMClient * client, - NMLDBusObject * dbobj, +_notify_update_prop_routes(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMIPConfig * self = NM_IP_CONFIG(dbobj->nmobj); - NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); + NMIPConfig *self = NM_IP_CONFIG(dbobj->nmobj); + NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); gs_unref_ptrarray GPtrArray *routes_old = NULL; gs_unref_ptrarray GPtrArray *routes_new = NULL; int addr_family = meta_iface == &_nml_dbus_meta_iface_nm_ip4config ? AF_INET : AF_INET6; @@ -131,13 +131,13 @@ _notify_update_prop_routes(NMClient * client, } static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_nameservers(NMClient * client, - NMLDBusObject * dbobj, +_notify_update_prop_nameservers(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMIPConfig * self = NM_IP_CONFIG(dbobj->nmobj); + NMIPConfig *self = NM_IP_CONFIG(dbobj->nmobj); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); gs_strfreev char **nameservers_new = NULL; gboolean new_style = TRUE; @@ -160,14 +160,14 @@ _notify_update_prop_nameservers(NMClient * client, else if (!new_style) nameservers_new = nm_utils_ip4_dns_from_variant(value); else { - GVariantIter iter; - GVariantIter * iter_v; + GVariantIter iter; + GVariantIter *iter_v; gs_unref_ptrarray GPtrArray *arr = NULL; g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "a{sv}", &iter_v)) { const char *key; - GVariant * val; + GVariant *val; while (g_variant_iter_next(iter_v, "{&sv}", &key, &val)) { if (nm_streq(key, "address")) { @@ -203,13 +203,13 @@ next: } static NMLDBusNotifyUpdatePropFlags -_notify_update_prop_wins_servers(NMClient * client, - NMLDBusObject * dbobj, +_notify_update_prop_wins_servers(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value) + GVariant *value) { - NMIPConfig * self = NM_IP_CONFIG(dbobj->nmobj); + NMIPConfig *self = NM_IP_CONFIG(dbobj->nmobj); NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self); gs_strfreev char **wins_servers_new = NULL; gboolean new_style; diff --git a/src/libnm-client-impl/nm-libnm-utils.c b/src/libnm-client-impl/nm-libnm-utils.c index 4543eaa137..d3d429eba2 100644 --- a/src/libnm-client-impl/nm-libnm-utils.c +++ b/src/libnm-client-impl/nm-libnm-utils.c @@ -42,9 +42,9 @@ void _nml_dbus_log(NMLDBusLogLevel level, gboolean use_stdout, const char *fmt, ...) { NMLDBusLogLevel configured_log_level; - gs_free char * msg = NULL; + gs_free char *msg = NULL; va_list args; - const char * prefix = ""; + const char *prefix = ""; gint64 ts; pid_t pid; @@ -116,7 +116,7 @@ char * nm_utils_wincaps_to_dash(const char *caps) { const char *p; - GString * str; + GString *str; str = g_string_new(NULL); p = caps; @@ -136,14 +136,14 @@ nm_utils_wincaps_to_dash(const char *caps) /*****************************************************************************/ static char * -_fixup_string(const char * desc, +_fixup_string(const char *desc, const char *const *ignored_phrases, const char *const *ignored_words, gboolean square_brackets_sensible) { - char * desc_full; + char *desc_full; gboolean in_paren = FALSE; - char * p, *q; + char *p, *q; int i; if (!desc || !desc[0]) @@ -727,7 +727,7 @@ static int _strcmp_common_prefix(gconstpointer a, gconstpointer b, gpointer user_data) { const NMLDBusMetaIface *iface = a; - const char * dbus_iface_name = b; + const char *dbus_iface_name = b; nm_assert(g_str_has_prefix(iface->dbus_iface_name, COMMON_PREFIX)); @@ -765,8 +765,8 @@ nml_dbus_meta_iface_get(const char *dbus_iface_name) const NMLDBusMetaProperty * nml_dbus_meta_property_get(const NMLDBusMetaIface *meta_iface, - const char * dbus_property_name, - guint * out_idx) + const char *dbus_property_name, + guint *out_idx) { gssize idx; @@ -788,7 +788,7 @@ nml_dbus_meta_property_get(const NMLDBusMetaIface *meta_iface, } void -_nml_dbus_meta_class_init_with_properties_impl(GObjectClass * object_class, +_nml_dbus_meta_class_init_with_properties_impl(GObjectClass *object_class, const NMLDBusMetaIface *const *meta_ifaces) { int i_iface; @@ -799,7 +799,7 @@ _nml_dbus_meta_class_init_with_properties_impl(GObjectClass * ob for (i_iface = 0; meta_ifaces[i_iface]; i_iface++) { const NMLDBusMetaIface *meta_iface = meta_ifaces[i_iface]; - guint8 * reverse_idx; + guint8 *reverse_idx; guint8 i; nm_assert(g_type_is_a(meta_iface->get_type_fcn(), G_OBJECT_CLASS_TYPE(object_class))); diff --git a/src/libnm-client-impl/nm-libnm-utils.h b/src/libnm-client-impl/nm-libnm-utils.h index 75e8706471..db5f31ea5a 100644 --- a/src/libnm-client-impl/nm-libnm-utils.h +++ b/src/libnm-client-impl/nm-libnm-utils.h @@ -179,13 +179,13 @@ GQuark nm_context_busy_watcher_quark(void); void nm_context_busy_watcher_integrate_source(GMainContext *outer_context, GMainContext *inner_context, - GObject * context_busy_watcher); + GObject *context_busy_watcher); /*****************************************************************************/ typedef struct { GCancellable *cancellable; - GSource * cancel_on_idle_source; + GSource *cancel_on_idle_source; gulong cancelled_id; union { struct { @@ -193,7 +193,7 @@ typedef struct { } async; struct { GMainLoop *main_loop; - GError ** error_location; + GError **error_location; } sync; } data; bool is_sync : 1; @@ -206,7 +206,7 @@ NMLInitData *nml_init_data_new_async(GCancellable *cancellable, GTask *task_take void nml_init_data_return(NMLInitData *init_data, GError *error_take); -void nml_cleanup_context_busy_watcher_on_idle(GObject * context_busy_watcher_take, +void nml_cleanup_context_busy_watcher_on_idle(GObject *context_busy_watcher_take, GMainContext *context); /*****************************************************************************/ @@ -244,9 +244,9 @@ typedef struct { } NMLDBusPropertVTableO; struct _NMLDBusPropertyO { - NMLDBusObject * owner_dbobj; - NMLDBusObjWatcher * obj_watcher; - GObject * nmobj; + NMLDBusObject *owner_dbobj; + NMLDBusObjWatcher *obj_watcher; + GObject *nmobj; const NMLDBusMetaIface *meta_iface; guint dbus_property_idx; bool is_ready : 1; @@ -272,8 +272,8 @@ typedef struct { GType (*get_o_type_fcn)(void); void (*notify_changed_ao)(NMLDBusPropertyAO *pr_ao, - NMClient * self, - NMObject * nmobj, + NMClient *self, + NMObject *nmobj, gboolean is_added /* or else removed */); gboolean (*check_nmobj_visible_fcn)(GObject *nmobj); @@ -289,10 +289,10 @@ struct _NMLDBusPropertyAOData; struct _NMLDBusPropertyAO { CList data_lst_head; - GHashTable * hash; - NMLDBusObject * owner_dbobj; - const NMLDBusMetaIface * meta_iface; - GPtrArray * arr; + GHashTable *hash; + NMLDBusObject *owner_dbobj; + const NMLDBusMetaIface *meta_iface; + GPtrArray *arr; struct _NMLDBusPropertyAOData *changed_head; guint dbus_property_idx; guint n_not_ready; @@ -316,34 +316,34 @@ typedef enum { NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NOTIFY = 0x1, } NMLDBusNotifyUpdatePropFlags; -NMLDBusNotifyUpdatePropFlags _nml_dbus_notify_update_prop_ignore(NMClient * client, - NMLDBusObject * dbobj, +NMLDBusNotifyUpdatePropFlags _nml_dbus_notify_update_prop_ignore(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, GVariant *value); -NMLDBusNotifyUpdatePropFlags _nml_dbus_notify_update_prop_o(NMClient * client, - NMLDBusObject * dbobj, +NMLDBusNotifyUpdatePropFlags _nml_dbus_notify_update_prop_o(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, GVariant *value); -NMLDBusNotifyUpdatePropFlags nml_dbus_property_ao_notify(NMClient * self, - NMLDBusPropertyAO * pr_ao, - NMLDBusObject * dbobj, +NMLDBusNotifyUpdatePropFlags nml_dbus_property_ao_notify(NMClient *self, + NMLDBusPropertyAO *pr_ao, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value); + GVariant *value); typedef struct { - const char * dbus_property_name; + const char *dbus_property_name; const GVariantType *dbus_type; - NMLDBusNotifyUpdatePropFlags (*notify_update_prop)(NMClient * client, - NMLDBusObject * dbobj, + NMLDBusNotifyUpdatePropFlags (*notify_update_prop)(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value); + GVariant *value); guint16 prop_struct_offset; @@ -352,7 +352,7 @@ typedef struct { bool obj_property_no_reverse_idx : 1; union { - const NMLDBusPropertVTableO * property_vtable_o; + const NMLDBusPropertVTableO *property_vtable_o; const NMLDBusPropertVTableAO *property_vtable_ao; } extra; @@ -475,9 +475,9 @@ struct _NMLDBusMetaIface { * assert (meta_iface->dbus_properties[d_idx].obj_properties_idx == o_idx) * if (and only if) two properties correspond. */ - const GParamSpec *const * obj_properties; + const GParamSpec *const *obj_properties; const NMLDBusMetaProperty *dbus_properties; - const guint8 * obj_properties_reverse_idx; + const guint8 *obj_properties_reverse_idx; guint8 n_dbus_properties; guint8 n_obj_properties; @@ -610,10 +610,10 @@ extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_wifip2ppeer; const NMLDBusMetaIface *nml_dbus_meta_iface_get(const char *dbus_iface_name); const NMLDBusMetaProperty *nml_dbus_meta_property_get(const NMLDBusMetaIface *meta_iface, - const char * dbus_property_name, - guint * out_idx); + const char *dbus_property_name, + guint *out_idx); -void _nml_dbus_meta_class_init_with_properties_impl(GObjectClass * object_class, +void _nml_dbus_meta_class_init_with_properties_impl(GObjectClass *object_class, const NMLDBusMetaIface *const *meta_iface); #define _nml_dbus_meta_class_init_with_properties(object_class, ...) \ _nml_dbus_meta_class_init_with_properties_impl( \ @@ -682,8 +682,8 @@ void nml_dbus_object_unref(NMLDBusObject *dbobj); NM_AUTO_DEFINE_FCN0(NMLDBusObject *, _nm_auto_unref_nml_dbusobj, nml_dbus_object_unref); #define nm_auto_unref_nml_dbusobj nm_auto(_nm_auto_unref_nml_dbusobj) -gpointer nml_dbus_object_get_property_location(NMLDBusObject * dbobj, - const NMLDBusMetaIface * meta_iface, +gpointer nml_dbus_object_get_property_location(NMLDBusObject *dbobj, + const NMLDBusMetaIface *meta_iface, const NMLDBusMetaProperty *meta_property); /*****************************************************************************/ @@ -713,7 +713,7 @@ struct _NMObject { typedef struct _NMObjectClassFieldInfo { const struct _NMObjectClassFieldInfo *parent; - NMObjectClass * klass; + NMObjectClass *klass; guint16 offset; guint16 num; } _NMObjectClassFieldInfo; @@ -926,14 +926,14 @@ struct _NMClientNotifyEvent { int priority; }; -gpointer _nm_client_notify_event_queue(NMClient * self, +gpointer _nm_client_notify_event_queue(NMClient *self, int priority, NMClientNotifyEventCb callback, gsize event_size); typedef struct _NMClientNotifyEventWithPtr NMClientNotifyEventWithPtr; -typedef void (*NMClientNotifyEventWithPtrCb)(NMClient * self, +typedef void (*NMClientNotifyEventWithPtrCb)(NMClient *self, NMClientNotifyEventWithPtr *notify_event); struct _NMClientNotifyEventWithPtr { @@ -942,13 +942,13 @@ struct _NMClientNotifyEventWithPtr { }; NMClientNotifyEventWithPtr * -_nm_client_notify_event_queue_with_ptr(NMClient * self, +_nm_client_notify_event_queue_with_ptr(NMClient *self, int priority, NMClientNotifyEventWithPtrCb callback, gpointer user_data); void _nm_client_notify_event_queue_emit_obj_signal(NMClient *self, - GObject * source, + GObject *source, NMObject *nmobj, gboolean is_added /* or else removed */, int prio_offset, @@ -959,57 +959,57 @@ void _nm_client_notify_event_queue_emit_obj_signal(NMClient *self, GError *_nm_client_new_error_nm_not_running(void); GError *_nm_client_new_error_nm_not_cached(void); -void _nm_client_dbus_call_simple(NMClient * self, - GCancellable * cancellable, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +void _nm_client_dbus_call_simple(NMClient *self, + GCancellable *cancellable, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, int timeout_msec, GAsyncReadyCallback callback, gpointer user_data); -void _nm_client_dbus_call(NMClient * self, +void _nm_client_dbus_call(NMClient *self, gpointer source_obj, gpointer source_tag, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback user_callback, gpointer user_callback_data, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, int timeout_msec, GAsyncReadyCallback internal_callback); -GVariant *_nm_client_dbus_call_sync(NMClient * self, - GCancellable * cancellable, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +GVariant *_nm_client_dbus_call_sync(NMClient *self, + GCancellable *cancellable, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, int timeout_msec, gboolean strip_dbus_error, - GError ** error); + GError **error); -gboolean _nm_client_dbus_call_sync_void(NMClient * self, - GCancellable * cancellable, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +gboolean _nm_client_dbus_call_sync_void(NMClient *self, + GCancellable *cancellable, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusCallFlags flags, int timeout_msec, gboolean strip_dbus_error, - GError ** error); + GError **error); -void _nm_client_set_property_sync_legacy(NMClient * self, +void _nm_client_set_property_sync_legacy(NMClient *self, const char *object_path, const char *interface, const char *prop_name, @@ -1034,14 +1034,14 @@ void _nm_vpn_connection_state_changed_commit(NMVpnConnection *self, guint32 stat /*****************************************************************************/ NMLDBusNotifyUpdatePropFlags -_nm_device_notify_update_prop_hw_address(NMClient * client, - NMLDBusObject * dbobj, +_nm_device_notify_update_prop_hw_address(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, - GVariant * value); + GVariant *value); -NMLDBusNotifyUpdatePropFlags _nm_device_notify_update_prop_ports(NMClient * client, - NMLDBusObject * dbobj, +NMLDBusNotifyUpdatePropFlags _nm_device_notify_update_prop_ports(NMClient *client, + NMLDBusObject *dbobj, const NMLDBusMetaIface *meta_iface, guint dbus_property_idx, GVariant *value); diff --git a/src/libnm-client-impl/nm-object.c b/src/libnm-client-impl/nm-object.c index ae48853b4d..60b01ca8e8 100644 --- a/src/libnm-client-impl/nm-object.c +++ b/src/libnm-client-impl/nm-object.c @@ -24,7 +24,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PATH, PROP_CLIENT, ); typedef struct _NMObjectPrivate { - NMClient * client; + NMClient *client; NMLDBusObject *dbobj; } NMObjectPrivate; @@ -117,7 +117,7 @@ nm_object_get_client(NMObject *object) static void clear_properties(NMObject *self, NMClient *client) { - NMObjectClass * klass = NM_OBJECT_GET_CLASS(self); + NMObjectClass *klass = NM_OBJECT_GET_CLASS(self); const _NMObjectClassFieldInfo *p; nm_assert(NM_IS_OBJECT(self)); @@ -141,8 +141,8 @@ clear_properties(NMObject *self, NMClient *client) static gboolean is_ready(NMObject *self) { - NMObjectClass * klass = NM_OBJECT_GET_CLASS(self); - NMClient * client = _nm_object_get_client(self); + NMObjectClass *klass = NM_OBJECT_GET_CLASS(self); + NMClient *client = _nm_object_get_client(self); const _NMObjectClassFieldInfo *p; guint16 i; @@ -172,8 +172,8 @@ is_ready(NMObject *self) static void obj_changed_notify(NMObject *self) { - NMObjectClass * klass = NM_OBJECT_GET_CLASS(self); - NMClient * client = _nm_object_get_client(self); + NMObjectClass *klass = NM_OBJECT_GET_CLASS(self); + NMClient *client = _nm_object_get_client(self); const _NMObjectClassFieldInfo *p; nm_assert(NM_IS_CLIENT(client)); @@ -245,7 +245,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void nm_object_init(NMObject *object) { - NMObject * self = NM_OBJECT(object); + NMObject *self = NM_OBJECT(object); NMObjectPrivate *priv; priv = G_TYPE_INSTANCE_GET_PRIVATE(self, NM_TYPE_OBJECT, NMObjectPrivate); @@ -262,7 +262,7 @@ nm_object_init(NMObject *object) static void dispose(GObject *object) { - NMObject * self = NM_OBJECT(object); + NMObject *self = NM_OBJECT(object); NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE(self); if (!self->obj_base.is_disposing) { diff --git a/src/libnm-client-impl/nm-remote-connection.c b/src/libnm-client-impl/nm-remote-connection.c index 8e36cf6d21..efc4dbfb94 100644 --- a/src/libnm-client-impl/nm-remote-connection.c +++ b/src/libnm-client-impl/nm-remote-connection.c @@ -36,7 +36,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMRemoteConnection, typedef struct { GCancellable *get_settings_cancellable; - char * filename; + char *filename; guint32 flags; bool unsaved; @@ -81,11 +81,11 @@ G_DEFINE_TYPE_WITH_CODE(NMRemoteConnection, * Since: 1.12 **/ void -nm_remote_connection_update2(NMRemoteConnection * connection, - GVariant * settings, +nm_remote_connection_update2(NMRemoteConnection *connection, + GVariant *settings, NMSettingsUpdate2Flags flags, - GVariant * args, - GCancellable * cancellable, + GVariant *args, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -128,11 +128,11 @@ nm_remote_connection_update2(NMRemoteConnection * connection, **/ GVariant * nm_remote_connection_update2_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error) + GAsyncResult *result, + GError **error) { gs_unref_variant GVariant *ret = NULL; - GVariant * v_result; + GVariant *v_result; g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), NULL); g_return_val_if_fail(nm_g_task_is_valid(result, connection, nm_remote_connection_update2), @@ -167,8 +167,8 @@ nm_remote_connection_update2_finish(NMRemoteConnection *connection, gboolean nm_remote_connection_commit_changes(NMRemoteConnection *connection, gboolean save_to_disk, - GCancellable * cancellable, - GError ** error) + GCancellable *cancellable, + GError **error) { gs_unref_variant GVariant *ret = NULL; @@ -213,7 +213,7 @@ nm_remote_connection_commit_changes(NMRemoteConnection *connection, void nm_remote_connection_commit_changes_async(NMRemoteConnection *connection, gboolean save_to_disk, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -242,8 +242,8 @@ nm_remote_connection_commit_changes_async(NMRemoteConnection *connection, **/ gboolean nm_remote_connection_commit_changes_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error) + GAsyncResult *result, + GError **error) { gs_unref_variant GVariant *v_result = NULL; @@ -296,7 +296,7 @@ nm_remote_connection_save(NMRemoteConnection *connection, GCancellable *cancella **/ void nm_remote_connection_save_async(NMRemoteConnection *connection, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -331,8 +331,8 @@ nm_remote_connection_save_async(NMRemoteConnection *connection, **/ gboolean nm_remote_connection_save_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error) + GAsyncResult *result, + GError **error) { g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE); g_return_val_if_fail(nm_g_task_is_valid(result, connection, nm_remote_connection_save_async), @@ -357,8 +357,8 @@ nm_remote_connection_save_finish(NMRemoteConnection *connection, **/ gboolean nm_remote_connection_delete(NMRemoteConnection *connection, - GCancellable * cancellable, - GError ** error) + GCancellable *cancellable, + GError **error) { g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE); @@ -385,7 +385,7 @@ nm_remote_connection_delete(NMRemoteConnection *connection, **/ void nm_remote_connection_delete_async(NMRemoteConnection *connection, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -420,8 +420,8 @@ nm_remote_connection_delete_async(NMRemoteConnection *connection, **/ gboolean nm_remote_connection_delete_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error) + GAsyncResult *result, + GError **error) { g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), FALSE); g_return_val_if_fail(nm_g_task_is_valid(result, connection, nm_remote_connection_delete_async), @@ -447,12 +447,12 @@ nm_remote_connection_delete_finish(NMRemoteConnection *connection, **/ GVariant * nm_remote_connection_get_secrets(NMRemoteConnection *connection, - const char * setting_name, - GCancellable * cancellable, - GError ** error) + const char *setting_name, + GCancellable *cancellable, + GError **error) { gs_unref_variant GVariant *ret = NULL; - GVariant * secrets; + GVariant *secrets; g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), NULL); g_return_val_if_fail(setting_name, NULL); @@ -489,8 +489,8 @@ nm_remote_connection_get_secrets(NMRemoteConnection *connection, **/ void nm_remote_connection_get_secrets_async(NMRemoteConnection *connection, - const char * setting_name, - GCancellable * cancellable, + const char *setting_name, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -527,11 +527,11 @@ nm_remote_connection_get_secrets_async(NMRemoteConnection *connection, **/ GVariant * nm_remote_connection_get_secrets_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error) + GAsyncResult *result, + GError **error) { gs_unref_variant GVariant *ret = NULL; - GVariant * secrets; + GVariant *secrets; g_return_val_if_fail(NM_IS_REMOTE_CONNECTION(connection), NULL); g_return_val_if_fail( @@ -635,7 +635,7 @@ void _nm_remote_settings_get_settings_commit(NMRemoteConnection *self, GVariant *settings) { NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE(self); - GError * error = NULL; + GError *error = NULL; gboolean visible = FALSE; gboolean changed = FALSE; @@ -761,7 +761,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_settings_connection = NML_DBUS_ME static void nm_remote_connection_class_init(NMRemoteConnectionClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-client-impl/nm-secret-agent-old.c b/src/libnm-client-impl/nm-secret-agent-old.c index 881dfd54ce..93475ed3ed 100644 --- a/src/libnm-client-impl/nm-secret-agent-old.c +++ b/src/libnm-client-impl/nm-secret-agent-old.c @@ -23,8 +23,8 @@ /*****************************************************************************/ typedef struct { - char * connection_path; - char * setting_name; + char *connection_path; + char *setting_name; GDBusMethodInvocation *context; CList gsi_lst; bool is_cancelling : 1; @@ -39,12 +39,12 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSecretAgentOld, typedef struct { GDBusConnection *dbus_connection; - GMainContext * main_context; - GMainContext * dbus_context; - GObject * context_busy_watcher; - GCancellable * name_owner_cancellable; - GCancellable * registering_cancellable; - GSource * registering_retry_source; + GMainContext *main_context; + GMainContext *dbus_context; + GObject *context_busy_watcher; + GCancellable *name_owner_cancellable; + GCancellable *registering_cancellable; + GSource *registering_retry_source; NMLInitData *init_data; @@ -289,7 +289,7 @@ static void get_secret_info_complete_and_free_error(GetSecretsInfo *info, GQuark error_domain, int error_code, - const char * error_message) + const char *error_message) { g_dbus_method_invocation_return_error_literal(g_steal_pointer(&info->context), error_domain, @@ -312,16 +312,16 @@ _dbus_connection_call_cb(GObject *source, GAsyncResult *result, gpointer user_da } static void -_dbus_connection_call(NMSecretAgentOld * self, - const char * bus_name, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_dbus_connection_call(NMSecretAgentOld *self, + const char *bus_name, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -350,8 +350,8 @@ _dbus_connection_call(NMSecretAgentOld * self, static GetSecretsInfo * find_get_secrets_info(NMSecretAgentOldPrivate *priv, - const char * connection_path, - const char * setting_name) + const char *connection_path, + const char *setting_name) { GetSecretsInfo *info; @@ -385,15 +385,15 @@ _cancel_get_secret_request(NMSecretAgentOld *self, GetSecretsInfo *info, const c } static gboolean -verify_request(NMSecretAgentOld * self, +verify_request(NMSecretAgentOld *self, GDBusMethodInvocation *context, - GVariant * connection_dict, - const char * connection_path, - NMConnection ** out_connection, - GError ** error) + GVariant *connection_dict, + const char *connection_path, + NMConnection **out_connection, + GError **error) { gs_unref_object NMConnection *connection = NULL; - gs_free_error GError *local = NULL; + gs_free_error GError *local = NULL; if (!nm_dbus_path_not_empty(connection_path)) { g_set_error_literal(error, @@ -422,9 +422,9 @@ verify_request(NMSecretAgentOld * self, static void get_secrets_cb(NMSecretAgentOld *self, - NMConnection * connection, - GVariant * secrets, - GError * error, + NMConnection *connection, + GVariant *secrets, + GError *error, gpointer user_data) { GetSecretsInfo *info = user_data; @@ -446,15 +446,15 @@ get_secrets_cb(NMSecretAgentOld *self, static void impl_get_secrets(NMSecretAgentOld *self, GVariant *parameters, GDBusMethodInvocation *context) { - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - GError * error = NULL; + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); + GError *error = NULL; gs_unref_object NMConnection *connection = NULL; - GetSecretsInfo * info; - gs_unref_variant GVariant *arg_connection = NULL; - const char * arg_connection_path; - const char * arg_setting_name; - gs_free const char ** arg_hints = NULL; - guint32 arg_flags; + GetSecretsInfo *info; + gs_unref_variant GVariant *arg_connection = NULL; + const char *arg_connection_path; + const char *arg_setting_name; + gs_free const char **arg_hints = NULL; + guint32 arg_flags; g_variant_get(parameters, "(@a{sa{sv}}&o&s^a&su)", @@ -494,14 +494,14 @@ impl_get_secrets(NMSecretAgentOld *self, GVariant *parameters, GDBusMethodInvoca } static void -impl_cancel_get_secrets(NMSecretAgentOld * self, - GVariant * parameters, +impl_cancel_get_secrets(NMSecretAgentOld *self, + GVariant *parameters, GDBusMethodInvocation *context) { NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - GetSecretsInfo * info; - const char * arg_connection_path; - const char * arg_setting_name; + GetSecretsInfo *info; + const char *arg_connection_path; + const char *arg_setting_name; g_variant_get(parameters, "(&o&s)", &arg_connection_path, &arg_setting_name); @@ -534,10 +534,10 @@ save_secrets_cb(NMSecretAgentOld *self, NMConnection *connection, GError *error, static void impl_save_secrets(NMSecretAgentOld *self, GVariant *parameters, GDBusMethodInvocation *context) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *arg_connection = NULL; - const char * arg_connection_path; - GError * error = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *arg_connection = NULL; + const char *arg_connection_path; + GError *error = NULL; g_variant_get(parameters, "(@a{sa{sv}}&o)", &arg_connection, &arg_connection_path); @@ -557,8 +557,8 @@ impl_save_secrets(NMSecretAgentOld *self, GVariant *parameters, GDBusMethodInvoc static void delete_secrets_cb(NMSecretAgentOld *self, - NMConnection * connection, - GError * error, + NMConnection *connection, + GError *error, gpointer user_data) { GDBusMethodInvocation *context = user_data; @@ -572,10 +572,10 @@ delete_secrets_cb(NMSecretAgentOld *self, static void impl_delete_secrets(NMSecretAgentOld *self, GVariant *parameters, GDBusMethodInvocation *context) { - gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *arg_connection = NULL; - const char * arg_connection_path; - GError * error = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_variant GVariant *arg_connection = NULL; + const char *arg_connection_path; + GError *error = NULL; g_variant_get(parameters, "(@a{sa{sv}}&o)", &arg_connection, &arg_connection_path); @@ -739,13 +739,13 @@ nm_secret_agent_old_register(NMSecretAgentOld *self, GCancellable *cancellable, static void _register_cancelled_cb(GObject *object, gpointer user_data) { - GTask * task0 = user_data; - gs_unref_object GTask * task = NULL; - NMSecretAgentOld * self = g_task_get_source_object(task0); - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - gulong * p_cancelled_id; - NMCListElem * elem; - gs_free_error GError *error = NULL; + GTask *task0 = user_data; + gs_unref_object GTask *task = NULL; + NMSecretAgentOld *self = g_task_get_source_object(task0); + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); + gulong *p_cancelled_id; + NMCListElem *elem; + gs_free_error GError *error = NULL; elem = nm_c_list_elem_find_first(&priv->pending_tasks_register_lst_head, x, x == task0); @@ -786,8 +786,8 @@ _register_cancelled_cb(GObject *object, gpointer user_data) * you want to check and ensure that the agent is registered. **/ void -nm_secret_agent_old_register_async(NMSecretAgentOld * self, - GCancellable * cancellable, +nm_secret_agent_old_register_async(NMSecretAgentOld *self, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -906,8 +906,8 @@ nm_secret_agent_old_unregister(NMSecretAgentOld *self, GCancellable *cancellable * Deprecated: 1.24: Use nm_secret_agent_old_enable(). **/ void -nm_secret_agent_old_unregister_async(NMSecretAgentOld * self, - GCancellable * cancellable, +nm_secret_agent_old_unregister_async(NMSecretAgentOld *self, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -980,10 +980,10 @@ nm_secret_agent_old_unregister_finish(NMSecretAgentOld *self, GAsyncResult *resu * secrets from the user. */ void -nm_secret_agent_old_get_secrets(NMSecretAgentOld * self, - NMConnection * connection, - const char * setting_name, - const char ** hints, +nm_secret_agent_old_get_secrets(NMSecretAgentOld *self, + NMConnection *connection, + const char *setting_name, + const char **hints, NMSecretAgentGetSecretsFlags flags, NMSecretAgentOldGetSecretsFunc callback, gpointer user_data) @@ -1017,8 +1017,8 @@ nm_secret_agent_old_get_secrets(NMSecretAgentOld * self, * disk. */ void -nm_secret_agent_old_save_secrets(NMSecretAgentOld * self, - NMConnection * connection, +nm_secret_agent_old_save_secrets(NMSecretAgentOld *self, + NMConnection *connection, NMSecretAgentOldSaveSecretsFunc callback, gpointer user_data) { @@ -1044,8 +1044,8 @@ nm_secret_agent_old_save_secrets(NMSecretAgentOld * self, * @connection. */ void -nm_secret_agent_old_delete_secrets(NMSecretAgentOld * self, - NMConnection * connection, +nm_secret_agent_old_delete_secrets(NMSecretAgentOld *self, + NMConnection *connection, NMSecretAgentOldDeleteSecretsFunc callback, gpointer user_data) { @@ -1093,8 +1093,8 @@ validate_identifier(const char *identifier) static gboolean _register_retry_cb(gpointer user_data) { - NMSecretAgentOld * self = user_data; - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); + NMSecretAgentOld *self = user_data; + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; dbus_context = nm_g_main_context_push_thread_default_if_necessary(priv->dbus_context); @@ -1107,10 +1107,10 @@ _register_retry_cb(gpointer user_data) static void _register_call_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSecretAgentOld * self = user_data; - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; + NMSecretAgentOld *self = user_data; + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); @@ -1187,11 +1187,11 @@ _register_dbus_call(NMSecretAgentOld *self) static void _get_connection_unix_user_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMSecretAgentOld * self; - NMSecretAgentOldPrivate *priv; - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; - guint32 sender_uid = 0; + NMSecretAgentOld *self; + NMSecretAgentOldPrivate *priv; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + guint32 sender_uid = 0; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -1275,15 +1275,15 @@ _name_owner_changed(NMSecretAgentOld *self, const char *name_owner, gboolean is_ static void _name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { NMSecretAgentOld *self = user_data; - const char * new_owner; + const char *new_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) return; @@ -1303,16 +1303,16 @@ _name_owner_get_cb(const char *name_owner, GError *error, gpointer user_data) /*****************************************************************************/ static void -_method_call(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_method_call(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *context, gpointer user_data) { - NMSecretAgentOld * self = user_data; + NMSecretAgentOld *self = user_data; NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); nm_assert(nm_streq0(object_path, NM_DBUS_PATH_SECRET_AGENT)); @@ -1349,7 +1349,7 @@ static void _register_state_complete(NMSecretAgentOld *self) { NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - NMCListElem * elem; + NMCListElem *elem; gboolean any_tasks_to_complete = FALSE; if (!c_list_is_empty(&priv->pending_tasks_register_lst_head)) { @@ -1367,7 +1367,7 @@ _register_state_complete(NMSecretAgentOld *self) if (any_tasks_to_complete) { while ( (elem = c_list_first_entry(&priv->pending_tasks_register_lst_head, NMCListElem, lst))) { - gpointer data = nm_c_list_elem_free_steal(elem); + gpointer data = nm_c_list_elem_free_steal(elem); gs_unref_object GTask *task = NULL; if (data == &any_tasks_to_complete) { @@ -1525,8 +1525,8 @@ static void _register_state_change(NMSecretAgentOld *self) { _nm_unused gs_unref_object NMSecretAgentOld *self_keep_alive = g_object_ref(self); - NMSecretAgentOldPrivate * priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); + nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; if (priv->register_state_change_reenter == 0) { /* We are not yet initialized. Do nothing. */ @@ -1558,9 +1558,9 @@ again: static void _init_complete(NMSecretAgentOld *self, GError *error_take) { - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - gs_free_error GError *error = g_steal_pointer(&error_take); - GError * error_cancelled = NULL; + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); + gs_free_error GError *error = g_steal_pointer(&error_take); + GError *error_cancelled = NULL; if (!priv->init_data) return; @@ -1582,10 +1582,10 @@ _init_complete(NMSecretAgentOld *self, GError *error_take) static void _init_register_object(NMSecretAgentOld *self) { - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - gs_free_error GError *error = NULL; - GDBusInterfaceVTable interface_vtable = { - .method_call = _method_call, + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); + gs_free_error GError *error = NULL; + GDBusInterfaceVTable interface_vtable = { + .method_call = _method_call, }; if (g_cancellable_set_error_if_cancelled(priv->init_data->cancellable, &error)) { @@ -1613,9 +1613,9 @@ _init_register_object(NMSecretAgentOld *self) static void _init_got_bus(GObject *initable, GAsyncResult *result, gpointer user_data) { - NMSecretAgentOld * self = user_data; - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); - gs_free_error GError *error = NULL; + NMSecretAgentOld *self = user_data; + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); + gs_free_error GError *error = NULL; priv->dbus_connection = g_bus_get_finish(result, &error); if (!priv->dbus_connection) { @@ -1650,17 +1650,17 @@ _init_start(NMSecretAgentOld *self) } static void -init_async(GAsyncInitable * initable, +init_async(GAsyncInitable *initable, int io_priority, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { - NMSecretAgentOld * self; - NMSecretAgentOldClass * klass; - NMSecretAgentOldPrivate *priv; + NMSecretAgentOld *self; + NMSecretAgentOldClass *klass; + NMSecretAgentOldPrivate *priv; nm_auto_pop_gmaincontext GMainContext *dbus_context = NULL; - gs_unref_object GTask *task = NULL; + gs_unref_object GTask *task = NULL; g_return_if_fail(NM_IS_SECRET_AGENT_OLD(initable)); @@ -1705,10 +1705,10 @@ static gboolean init_sync(GInitable *initable, GCancellable *cancellable, GError **error) { gs_unref_object NMSecretAgentOld *self = NULL; - NMSecretAgentOldPrivate * priv; - NMSecretAgentOldClass * klass; - GMainLoop * main_loop; - GError * local_error = NULL; + NMSecretAgentOldPrivate *priv; + NMSecretAgentOldClass *klass; + GMainLoop *main_loop; + GError *local_error = NULL; g_return_val_if_fail(NM_IS_SECRET_AGENT_OLD(initable), FALSE); @@ -1789,7 +1789,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSecretAgentOld * self = NM_SECRET_AGENT_OLD(object); + NMSecretAgentOld *self = NM_SECRET_AGENT_OLD(object); NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); guint u; @@ -1855,7 +1855,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMSecretAgentOld * self = NM_SECRET_AGENT_OLD(object); + NMSecretAgentOld *self = NM_SECRET_AGENT_OLD(object); NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE(self); _LOGT("finalizing"); diff --git a/src/libnm-client-impl/nm-vpn-connection.c b/src/libnm-client-impl/nm-vpn-connection.c index fb0615328a..4569968086 100644 --- a/src/libnm-client-impl/nm-vpn-connection.c +++ b/src/libnm-client-impl/nm-vpn-connection.c @@ -27,7 +27,7 @@ enum { static guint signals[LAST_SIGNAL] = {0}; typedef struct { - char * banner; + char *banner; guint32 vpn_state; guint32 reason; } NMVpnConnectionPrivate; @@ -89,7 +89,7 @@ static void _notify_event_state_changed(NMClient *client, NMClientNotifyEventWithPtr *notify_event) { gs_unref_object NMVpnConnection *self = notify_event->user_data; - NMVpnConnectionPrivate * priv = NM_VPN_CONNECTION_GET_PRIVATE(self); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); /* we expose here the value cache in @priv. In practice, this is the same * value as we received from the signal. In the unexpected case where they @@ -104,7 +104,7 @@ _notify_event_state_changed(NMClient *client, NMClientNotifyEventWithPtr *notify void _nm_vpn_connection_state_changed_commit(NMVpnConnection *self, guint32 state, guint32 reason) { - NMClient * client; + NMClient *client; NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE(self); client = _nm_object_get_client(self); diff --git a/src/libnm-client-impl/nm-vpn-plugin-old.c b/src/libnm-client-impl/nm-vpn-plugin-old.c index f60bf19c7b..19ba2bb094 100644 --- a/src/libnm-client-impl/nm-vpn-plugin-old.c +++ b/src/libnm-client-impl/nm-vpn-plugin-old.c @@ -37,7 +37,7 @@ typedef struct { /* DBUS-y stuff */ GDBusConnection *connection; NMDBusVpnPlugin *dbus_vpn_plugin_old; - char * dbus_service_name; + char *dbus_service_name; /* Temporary stuff */ guint connect_timer; @@ -226,7 +226,7 @@ static gboolean connect_timer_expired(gpointer data) { NMVpnPluginOld *plugin = NM_VPN_PLUGIN_OLD(data); - GError * err = NULL; + GError *err = NULL; NM_VPN_PLUGIN_OLD_GET_PRIVATE(plugin)->connect_timer = 0; g_message("Connect timer expired, disconnecting."); @@ -330,11 +330,11 @@ void nm_vpn_plugin_old_set_ip4_config(NMVpnPluginOld *plugin, GVariant *ip4_config) { NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE(plugin); - GVariant * combined_config; + GVariant *combined_config; GVariantBuilder builder; GVariantIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_return_if_fail(NM_IS_VPN_PLUGIN_OLD(plugin)); g_return_if_fail(ip4_config != NULL); @@ -415,17 +415,17 @@ connect_timer_start(NMVpnPluginOld *plugin) } static void -_connect_generic(NMVpnPluginOld * plugin, +_connect_generic(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - GVariant * properties, - GVariant * details) + GVariant *properties, + GVariant *details) { - NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE(plugin); - NMVpnPluginOldClass * vpn_class = NM_VPN_PLUGIN_OLD_GET_CLASS(plugin); - gs_unref_object NMConnection *connection = NULL; - gboolean success = FALSE; - gs_free_error GError *error = NULL; - guint fail_stop_timeout = 0; + NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE(plugin); + NMVpnPluginOldClass *vpn_class = NM_VPN_PLUGIN_OLD_GET_CLASS(plugin); + gs_unref_object NMConnection *connection = NULL; + gboolean success = FALSE; + gs_free_error GError *error = NULL; + guint fail_stop_timeout = 0; if (priv->state != NM_VPN_SERVICE_STATE_STOPPED && priv->state != NM_VPN_SERVICE_STATE_INIT) { g_dbus_method_invocation_return_error(context, @@ -488,19 +488,19 @@ _connect_generic(NMVpnPluginOld * plugin, } static void -impl_vpn_plugin_old_connect(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_connect(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - GVariant * connection, + GVariant *connection, gpointer user_data) { _connect_generic(plugin, context, connection, NULL); } static void -impl_vpn_plugin_old_connect_interactive(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_connect_interactive(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - GVariant * connection, - GVariant * details, + GVariant *connection, + GVariant *details, gpointer user_data) { _connect_generic(plugin, context, connection, details); @@ -509,15 +509,15 @@ impl_vpn_plugin_old_connect_interactive(NMVpnPluginOld * plugin, /*****************************************************************************/ static void -impl_vpn_plugin_old_need_secrets(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_need_secrets(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - GVariant * properties, + GVariant *properties, gpointer user_data) { NMConnection *connection; - const char * setting_name; + const char *setting_name; gboolean needed; - GError * error = NULL; + GError *error = NULL; connection = _nm_simple_connection_new_from_dbus(properties, NM_SETTING_PARSE_FLAGS_BEST_EFFORT, &error); @@ -560,14 +560,14 @@ impl_vpn_plugin_old_need_secrets(NMVpnPluginOld * plugin, } static void -impl_vpn_plugin_old_new_secrets(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_new_secrets(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - GVariant * properties, + GVariant *properties, gpointer user_data) { NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE(plugin); - NMConnection * connection; - GError * error = NULL; + NMConnection *connection; + GError *error = NULL; gboolean success; if (priv->state != NM_VPN_SERVICE_STATE_STARTING) { @@ -693,8 +693,8 @@ nm_vpn_plugin_old_read_vpn_details(int fd, GHashTable **out_data, GHashTable **o * Deprecated: 1.2: Replaced by NMVpnServicePlugin. **/ gboolean -nm_vpn_plugin_old_get_secret_flags(GHashTable * data, - const char * secret_name, +nm_vpn_plugin_old_get_secret_flags(GHashTable *data, + const char *secret_name, NMSettingSecretFlags *out_flags) { return nm_vpn_service_plugin_get_secret_flags(data, secret_name, out_flags); @@ -703,7 +703,7 @@ nm_vpn_plugin_old_get_secret_flags(GHashTable * data, /*****************************************************************************/ static void -impl_vpn_plugin_old_disconnect(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_disconnect(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, gpointer user_data) { @@ -716,9 +716,9 @@ impl_vpn_plugin_old_disconnect(NMVpnPluginOld * plugin, } static void -impl_vpn_plugin_old_set_config(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_set_config(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - GVariant * config, + GVariant *config, gpointer user_data) { nm_vpn_plugin_old_set_config(plugin, config); @@ -726,9 +726,9 @@ impl_vpn_plugin_old_set_config(NMVpnPluginOld * plugin, } static void -impl_vpn_plugin_old_set_ip4_config(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_set_ip4_config(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - GVariant * config, + GVariant *config, gpointer user_data) { nm_vpn_plugin_old_set_ip4_config(plugin, config); @@ -736,9 +736,9 @@ impl_vpn_plugin_old_set_ip4_config(NMVpnPluginOld * plugin, } static void -impl_vpn_plugin_old_set_ip6_config(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_set_ip6_config(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - GVariant * config, + GVariant *config, gpointer user_data) { nm_vpn_plugin_old_set_ip6_config(plugin, config); @@ -746,9 +746,9 @@ impl_vpn_plugin_old_set_ip6_config(NMVpnPluginOld * plugin, } static void -impl_vpn_plugin_old_set_failure(NMVpnPluginOld * plugin, +impl_vpn_plugin_old_set_failure(NMVpnPluginOld *plugin, GDBusMethodInvocation *context, - char * reason, + char *reason, gpointer user_data) { nm_vpn_plugin_old_failure(plugin, NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG); @@ -803,11 +803,11 @@ nm_vpn_plugin_old_init(NMVpnPluginOld *plugin) static gboolean init_sync(GInitable *initable, GCancellable *cancellable, GError **error) { - NMVpnPluginOld * plugin = NM_VPN_PLUGIN_OLD(initable); + NMVpnPluginOld *plugin = NM_VPN_PLUGIN_OLD(initable); NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE(plugin); - GDBusConnection * connection = NULL; - GDBusProxy * proxy; - GVariant * ret; + GDBusConnection *connection = NULL; + GDBusProxy *proxy; + GVariant *ret; gboolean success = FALSE; if (!priv->dbus_service_name) { @@ -931,10 +931,10 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void dispose(GObject *object) { - NMVpnPluginOld * plugin = NM_VPN_PLUGIN_OLD(object); + NMVpnPluginOld *plugin = NM_VPN_PLUGIN_OLD(object); NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE(plugin); NMVpnServiceState state; - GError * err = NULL; + GError *err = NULL; nm_clear_g_source(&priv->fail_stop_id); nm_clear_g_source(&priv->quit_timer); @@ -956,7 +956,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMVpnPluginOld * plugin = NM_VPN_PLUGIN_OLD(object); + NMVpnPluginOld *plugin = NM_VPN_PLUGIN_OLD(object); NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE(plugin); nm_vpn_plugin_old_set_connection(plugin, NULL); diff --git a/src/libnm-client-impl/nm-vpn-service-plugin.c b/src/libnm-client-impl/nm-vpn-service-plugin.c index 18a85e913b..2a217502de 100644 --- a/src/libnm-client-impl/nm-vpn-service-plugin.c +++ b/src/libnm-client-impl/nm-vpn-service-plugin.c @@ -39,7 +39,7 @@ typedef struct { /* DBUS-y stuff */ GDBusConnection *connection; NMDBusVpnPlugin *dbus_vpn_service_plugin; - char * dbus_service_name; + char *dbus_service_name; gboolean dbus_watch_peer; /* Temporary stuff */ @@ -240,7 +240,7 @@ nm_vpn_service_plugin_shutdown(NMVpnServicePlugin *plugin) { NMVpnServicePluginPrivate *priv; NMVpnServiceState state; - GError * error = NULL; + GError *error = NULL; g_return_if_fail(NM_IS_VPN_SERVICE_PLUGIN(plugin)); @@ -271,7 +271,7 @@ static gboolean connect_timer_expired(gpointer data) { NMVpnServicePlugin *plugin = NM_VPN_SERVICE_PLUGIN(data); - GError * err = NULL; + GError *err = NULL; NM_VPN_SERVICE_PLUGIN_GET_PRIVATE(plugin)->connect_timer = 0; g_message("Connect timer expired, disconnecting."); @@ -368,11 +368,11 @@ void nm_vpn_service_plugin_set_ip4_config(NMVpnServicePlugin *plugin, GVariant *ip4_config) { NMVpnServicePluginPrivate *priv = NM_VPN_SERVICE_PLUGIN_GET_PRIVATE(plugin); - GVariant * combined_config; + GVariant *combined_config; GVariantBuilder builder; GVariantIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_return_if_fail(NM_IS_VPN_SERVICE_PLUGIN(plugin)); g_return_if_fail(ip4_config != NULL); @@ -454,11 +454,11 @@ connect_timer_start(NMVpnServicePlugin *plugin) static void peer_vanished(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { nm_vpn_service_plugin_disconnect(NM_VPN_SERVICE_PLUGIN(user_data), NULL); @@ -478,16 +478,16 @@ watch_peer(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context) } static void -_connect_generic(NMVpnServicePlugin * plugin, +_connect_generic(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - GVariant * properties, - GVariant * details) + GVariant *properties, + GVariant *details) { NMVpnServicePluginPrivate *priv = NM_VPN_SERVICE_PLUGIN_GET_PRIVATE(plugin); - NMVpnServicePluginClass * vpn_class = NM_VPN_SERVICE_PLUGIN_GET_CLASS(plugin); - NMConnection * connection; + NMVpnServicePluginClass *vpn_class = NM_VPN_SERVICE_PLUGIN_GET_CLASS(plugin); + NMConnection *connection; gboolean success = FALSE; - GError * error = NULL; + GError *error = NULL; guint fail_stop_timeout = 0; if (priv->state != NM_VPN_SERVICE_STATE_STOPPED && priv->state != NM_VPN_SERVICE_STATE_INIT) { @@ -557,19 +557,19 @@ _connect_generic(NMVpnServicePlugin * plugin, } static void -impl_vpn_service_plugin_connect(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_connect(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - GVariant * connection, + GVariant *connection, gpointer user_data) { _connect_generic(plugin, context, connection, NULL); } static void -impl_vpn_service_plugin_connect_interactive(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_connect_interactive(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - GVariant * connection, - GVariant * details, + GVariant *connection, + GVariant *details, gpointer user_data) { _connect_generic(plugin, context, connection, details); @@ -578,15 +578,15 @@ impl_vpn_service_plugin_connect_interactive(NMVpnServicePlugin * plugin, /*****************************************************************************/ static void -impl_vpn_service_plugin_need_secrets(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_need_secrets(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - GVariant * properties, + GVariant *properties, gpointer user_data) { NMConnection *connection; - const char * setting_name; + const char *setting_name; gboolean needed; - GError * error = NULL; + GError *error = NULL; connection = _nm_simple_connection_new_from_dbus(properties, NM_SETTING_PARSE_FLAGS_BEST_EFFORT, &error); @@ -629,14 +629,14 @@ impl_vpn_service_plugin_need_secrets(NMVpnServicePlugin * plugin, } static void -impl_vpn_service_plugin_new_secrets(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_new_secrets(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - GVariant * properties, + GVariant *properties, gpointer user_data) { NMVpnServicePluginPrivate *priv = NM_VPN_SERVICE_PLUGIN_GET_PRIVATE(plugin); - NMConnection * connection; - GError * error = NULL; + NMConnection *connection; + GError *error = NULL; gboolean success; if (priv->state != NM_VPN_SERVICE_STATE_STARTING) { @@ -704,8 +704,8 @@ impl_vpn_service_plugin_new_secrets(NMVpnServicePlugin * plugin, */ void nm_vpn_service_plugin_secrets_required(NMVpnServicePlugin *plugin, - const char * message, - const char ** hints) + const char *message, + const char **hints) { NMVpnServicePluginPrivate *priv = NM_VPN_SERVICE_PLUGIN_GET_PRIVATE(plugin); @@ -803,12 +803,12 @@ nm_vpn_service_plugin_read_vpn_details(int fd, GHashTable **out_data, GHashTable gs_unref_hashtable GHashTable *data = NULL; gs_unref_hashtable GHashTable *secrets = NULL; gboolean success = FALSE; - GHashTable * hash = NULL; - nm_auto_free_gstring GString *key = NULL; - nm_auto_free_gstring GString *val = NULL; - nm_auto_free_gstring GString *line = NULL; - GString * str = NULL; - ReadFdBuf read_buf; + GHashTable *hash = NULL; + nm_auto_free_gstring GString *key = NULL; + nm_auto_free_gstring GString *val = NULL; + nm_auto_free_gstring GString *line = NULL; + GString *str = NULL; + ReadFdBuf read_buf; if (out_data) g_return_val_if_fail(*out_data == NULL, FALSE); @@ -920,12 +920,12 @@ next: * Since: 1.2 **/ gboolean -nm_vpn_service_plugin_get_secret_flags(GHashTable * data, - const char * secret_name, +nm_vpn_service_plugin_get_secret_flags(GHashTable *data, + const char *secret_name, NMSettingSecretFlags *out_flags) { - gs_free char * flag_name_free = NULL; - const char * s; + gs_free char *flag_name_free = NULL; + const char *s; gint64 t1; NMSettingSecretFlags t0; @@ -950,7 +950,7 @@ nm_vpn_service_plugin_get_secret_flags(GHashTable * data, /*****************************************************************************/ static void -impl_vpn_service_plugin_disconnect(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_disconnect(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, gpointer user_data) { @@ -963,9 +963,9 @@ impl_vpn_service_plugin_disconnect(NMVpnServicePlugin * plugin, } static void -impl_vpn_service_plugin_set_config(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_set_config(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - GVariant * config, + GVariant *config, gpointer user_data) { nm_vpn_service_plugin_set_config(plugin, config); @@ -973,9 +973,9 @@ impl_vpn_service_plugin_set_config(NMVpnServicePlugin * plugin, } static void -impl_vpn_service_plugin_set_ip4_config(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_set_ip4_config(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - GVariant * config, + GVariant *config, gpointer user_data) { nm_vpn_service_plugin_set_ip4_config(plugin, config); @@ -983,9 +983,9 @@ impl_vpn_service_plugin_set_ip4_config(NMVpnServicePlugin * plugin, } static void -impl_vpn_service_plugin_set_ip6_config(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_set_ip6_config(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - GVariant * config, + GVariant *config, gpointer user_data) { nm_vpn_service_plugin_set_ip6_config(plugin, config); @@ -993,9 +993,9 @@ impl_vpn_service_plugin_set_ip6_config(NMVpnServicePlugin * plugin, } static void -impl_vpn_service_plugin_set_failure(NMVpnServicePlugin * plugin, +impl_vpn_service_plugin_set_failure(NMVpnServicePlugin *plugin, GDBusMethodInvocation *context, - char * reason, + char *reason, gpointer user_data) { nm_vpn_service_plugin_failure(plugin, NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG); @@ -1050,11 +1050,11 @@ nm_vpn_service_plugin_init(NMVpnServicePlugin *plugin) static gboolean init_sync(GInitable *initable, GCancellable *cancellable, GError **error) { - NMVpnServicePlugin * plugin = NM_VPN_SERVICE_PLUGIN(initable); - NMVpnServicePluginPrivate *priv = NM_VPN_SERVICE_PLUGIN_GET_PRIVATE(plugin); + NMVpnServicePlugin *plugin = NM_VPN_SERVICE_PLUGIN(initable); + NMVpnServicePluginPrivate *priv = NM_VPN_SERVICE_PLUGIN_GET_PRIVATE(plugin); gs_unref_object GDBusConnection *connection = NULL; - gs_unref_object GDBusProxy *proxy = NULL; - GVariant * ret; + gs_unref_object GDBusProxy *proxy = NULL; + GVariant *ret; if (!priv->dbus_service_name) { g_set_error_literal(error, @@ -1186,7 +1186,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMVpnServicePlugin * plugin = NM_VPN_SERVICE_PLUGIN(object); + NMVpnServicePlugin *plugin = NM_VPN_SERVICE_PLUGIN(object); NMVpnServicePluginPrivate *priv = NM_VPN_SERVICE_PLUGIN_GET_PRIVATE(plugin); nm_vpn_service_plugin_set_connection(plugin, NULL); diff --git a/src/libnm-client-impl/nm-wifi-p2p-peer.c b/src/libnm-client-impl/nm-wifi-p2p-peer.c index 1d6b7c9541..54d1c5ed65 100644 --- a/src/libnm-client-impl/nm-wifi-p2p-peer.c +++ b/src/libnm-client-impl/nm-wifi-p2p-peer.c @@ -29,12 +29,12 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_FLAGS, typedef struct { GBytes *wfd_ies; - char * name; - char * manufacturer; - char * model; - char * model_number; - char * serial; - char * hw_address; + char *name; + char *manufacturer; + char *model; + char *model_number; + char *serial; + char *hw_address; gint32 last_seen; guint32 flags; guint8 strength; @@ -261,10 +261,10 @@ gboolean nm_wifi_p2p_peer_connection_valid(NMWifiP2PPeer *peer, NMConnection *connection) { NMSettingConnection *s_con; - NMSettingWifiP2P * s_wifi_p2p; - const char * ctype; - const char * hw_address; - const char * setting_peer; + NMSettingWifiP2P *s_wifi_p2p; + const char *ctype; + const char *hw_address; + const char *setting_peer; s_wifi_p2p = (NMSettingWifiP2P *) nm_connection_get_setting(connection, NM_TYPE_SETTING_WIFI_P2P); diff --git a/src/libnm-client-impl/tests/test-libnm.c b/src/libnm-client-impl/tests/test-libnm.c index 29ffde97d5..0f600a4a01 100644 --- a/src/libnm-client-impl/tests/test-libnm.c +++ b/src/libnm-client-impl/tests/test-libnm.c @@ -2280,18 +2280,18 @@ typedef struct { #define READ_VPN_DETAIL_DATA(...) ((ReadVpnDetailData[]){__VA_ARGS__}) static gboolean -_do_read_vpn_details_impl1(const char * file, +_do_read_vpn_details_impl1(const char *file, int line, int memfd, - char * mem, + char *mem, gsize len, const ReadVpnDetailData *expected_data, guint expected_data_len, const ReadVpnDetailData *expected_secrets, guint expected_secrets_len) { - gssize written; - off_t lseeked; + gssize written; + off_t lseeked; gs_unref_hashtable GHashTable *data = NULL; gs_unref_hashtable GHashTable *secrets = NULL; @@ -2312,11 +2312,11 @@ _do_read_vpn_details_impl1(const char * file, #define _assert_hash(hash, expected, expected_len) \ G_STMT_START \ { \ - GHashTable * _hash = (hash); \ + GHashTable *_hash = (hash); \ guint _expected_len = (expected_len); \ const ReadVpnDetailData *_expected = (expected); \ GHashTableIter _iter; \ - const char * _k, *_v; \ + const char *_k, *_v; \ guint _i; \ \ g_assert(_hash); \ @@ -2759,7 +2759,7 @@ test_types(void) for (i_type = 0; i_type < G_N_ELEMENTS(get_type_fcns); i_type++) { nm_auto_unref_gtypeclass GObjectClass *klass_unref = NULL; GType gtype = (get_type_fcns[i_type])(); - GObjectClass * klass; + GObjectClass *klass; g_assert(g_str_has_prefix(g_type_name(gtype), "NM")); @@ -2803,16 +2803,16 @@ test_types(void) static void test_nml_dbus_meta(void) { - const NMLDBusMetaIface * meta_iface; + const NMLDBusMetaIface *meta_iface; const NMLDBusMetaProperty *meta_property; guint prop_idx; gsize i, j; guint l, m; for (i = 0; i < G_N_ELEMENTS(_nml_dbus_meta_ifaces); i++) { - const NMLDBusMetaIface * mif = _nml_dbus_meta_ifaces[i]; + const NMLDBusMetaIface *mif = _nml_dbus_meta_ifaces[i]; nm_auto_unref_gtypeclass GObjectClass *klass_unref = NULL; - GObjectClass * klass; + GObjectClass *klass; GType gtype; #define COMMON_PREFIX "org.freedesktop.NetworkManager" @@ -3004,7 +3004,7 @@ test_nml_dbus_meta(void) check_dbus_properties: for (l = 0; l < mif->n_dbus_properties; l++) { const NMLDBusMetaProperty *mpr = &mif->dbus_properties[l]; - gs_free char * obj_property_name = NULL; + gs_free char *obj_property_name = NULL; const struct { const char *dbus_type; GType default_gtype; @@ -3218,7 +3218,7 @@ static void test_dbus_meta_types(void) { struct list_data { - const char * dbus_iface_name; + const char *dbus_iface_name; GType gtype; NMLDBusMetaInteracePrio interface_prio; } list[] = { @@ -3464,8 +3464,8 @@ test_nm_auth_permissions(void) for (i = 1; i < NM_CLIENT_PERMISSION_LAST; i++) { NMClientPermission a = nm_auth_permission_sorted[i - 1]; NMClientPermission b = nm_auth_permission_sorted[i]; - const char * s_a = nm_auth_permission_names_by_idx[a - 1]; - const char * s_b = nm_auth_permission_names_by_idx[b - 1]; + const char *s_a = nm_auth_permission_names_by_idx[a - 1]; + const char *s_b = nm_auth_permission_names_by_idx[b - 1]; g_assert_cmpstr(s_a, <, s_b); g_assert(a != b); diff --git a/src/libnm-client-impl/tests/test-nm-client.c b/src/libnm-client-impl/tests/test-nm-client.c index a3fc5847e3..62b4c883ba 100644 --- a/src/libnm-client-impl/tests/test-nm-client.c +++ b/src/libnm-client-impl/tests/test-nm-client.c @@ -28,9 +28,9 @@ loop_quit(gpointer user_data) static void devices_notify_cb(NMClient *c, GParamSpec *pspec, gpointer user_data) { - gboolean * notified = user_data; + gboolean *notified = user_data; const GPtrArray *devices; - NMDevice * device; + NMDevice *device; devices = nm_client_get_devices(c); g_assert(devices); @@ -46,12 +46,12 @@ devices_notify_cb(NMClient *c, GParamSpec *pspec, gpointer user_data) static void test_device_added(void) { - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; - gs_unref_object NMClient *client = NULL; - const GPtrArray * devices; - NMDevice * device; - gboolean notified = FALSE; - GError * error = NULL; + nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; + gs_unref_object NMClient *client = NULL; + const GPtrArray *devices; + NMDevice *device; + gboolean notified = FALSE; + GError *error = NULL; sinfo = nmtstc_service_init(); if (!nmtstc_service_available(sinfo)) @@ -113,9 +113,9 @@ device_sai_added_cb(NMClient *c, NMDevice *device, gpointer user_data) static void devices_sai_notify_cb(NMClient *c, GParamSpec *pspec, gpointer user_data) { - guint * result = user_data; + guint *result = user_data; const GPtrArray *devices; - NMDevice * device; + NMDevice *device; g_assert_cmpstr(pspec->name, ==, "devices"); @@ -134,11 +134,11 @@ devices_sai_notify_cb(NMClient *c, GParamSpec *pspec, gpointer user_data) static void test_device_added_signal_after_init(void) { - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; - gs_unref_object NMClient *client = NULL; - const GPtrArray * devices; - NMDevice * device; - guint result = 0; + nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; + gs_unref_object NMClient *client = NULL; + const GPtrArray *devices; + NMDevice *device; + guint result = 0; sinfo = nmtstc_service_init(); if (!nmtstc_service_available(sinfo)) @@ -187,7 +187,7 @@ static const char *expected_bssid = "66:55:44:33:22:11"; typedef struct { GMainLoop *loop; gboolean found; - char * ap_path; + char *ap_path; gboolean signaled; gboolean notified; guint quit_id; @@ -229,7 +229,7 @@ static void wifi_ap_add_notify_cb(NMDeviceWifi *w, GParamSpec *pspec, WifiApInfo *info) { const GPtrArray *aps; - NMAccessPoint * ap; + NMAccessPoint *ap; aps = nm_device_wifi_get_access_points(w); g_assert(aps); @@ -269,13 +269,13 @@ wifi_ap_remove_notify_cb(NMDeviceWifi *w, GParamSpec *pspec, WifiApInfo *info) static void test_wifi_ap_added_removed(void) { - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; - gs_unref_object NMClient *client = NULL; - NMDeviceWifi * wifi; - WifiApInfo info = {gl.loop, FALSE, FALSE, 0, 0}; - GVariant * ret; - GError * error = NULL; - gs_free char * expected_path = NULL; + nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; + gs_unref_object NMClient *client = NULL; + NMDeviceWifi *wifi; + WifiApInfo info = {gl.loop, FALSE, FALSE, 0, 0}; + GVariant *ret; + GError *error = NULL; + gs_free char *expected_path = NULL; sinfo = nmtstc_service_init(); if (!nmtstc_service_available(sinfo)) @@ -391,9 +391,9 @@ static void da_devices_notify_cb(NMClient *c, GParamSpec *pspec, DaInfo *info) { const GPtrArray *devices; - NMDevice * device; + NMDevice *device; guint i; - const char * iface; + const char *iface; devices = nm_client_get_devices(c); g_assert(devices); @@ -413,13 +413,13 @@ da_devices_notify_cb(NMClient *c, GParamSpec *pspec, DaInfo *info) static void test_devices_array(void) { - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; - gs_unref_object NMClient *client = NULL; - DaInfo info = {gl.loop}; - NMDevice * wlan0, *eth0, *eth1, *device; - const GPtrArray * devices; - GError * error = NULL; - GVariant * ret; + nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; + gs_unref_object NMClient *client = NULL; + DaInfo info = {gl.loop}; + NMDevice *wlan0, *eth0, *eth1, *device; + const GPtrArray *devices; + GError *error = NULL; + GVariant *ret; sinfo = nmtstc_service_init(); if (!nmtstc_service_available(sinfo)) @@ -502,12 +502,12 @@ nm_running_changed(GObject *client, GParamSpec *pspec, gpointer user_data) static void test_client_nm_running(void) { - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; - gs_unref_object NMClient *client1 = NULL; - gs_unref_object NMClient *client2 = NULL; - guint quit_id; - int running_changed = 0; - GError * error = NULL; + nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; + gs_unref_object NMClient *client1 = NULL; + gs_unref_object NMClient *client2 = NULL; + guint quit_id; + int running_changed = 0; + GError *error = NULL; client1 = nmtstc_client_new(TRUE); @@ -560,7 +560,7 @@ test_client_nm_running(void) } typedef struct { - GMainLoop * loop; + GMainLoop *loop; NMActiveConnection *ac; int remaining; @@ -572,8 +572,8 @@ typedef struct { static void assert_ac_and_device(NMClient *client) { - const GPtrArray * devices, *acs, *ac_devices; - NMDevice * device, *ac_device; + const GPtrArray *devices, *acs, *ac_devices; + NMDevice *device, *ac_device; NMActiveConnection *ac, *device_ac; acs = nm_client_get_active_connections(client); @@ -614,9 +614,9 @@ assert_ac_and_device(NMClient *client) static void add_and_activate_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NMClient * client = NM_CLIENT(object); + NMClient *client = NM_CLIENT(object); TestACInfo *info = user_data; - GError * error = NULL; + GError *error = NULL; info->ac = nm_client_add_and_activate_connection_finish(client, result, &error); g_assert_no_error(error); @@ -632,7 +632,7 @@ add_and_activate_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void client_acs_changed_cb(GObject *client, GParamSpec *pspec, gpointer user_data) { - TestACInfo * info = user_data; + TestACInfo *info = user_data; const GPtrArray *acs; acs = nm_client_get_active_connections(NM_CLIENT(client)); @@ -659,11 +659,11 @@ device_ac_changed_cb(GObject *device, GParamSpec *pspec, gpointer user_data) static void test_active_connections(void) { - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; - gs_unref_object NMClient *client = NULL; - NMDevice * device; - NMConnection * conn; - TestACInfo info = {gl.loop, NULL, 0}; + nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; + gs_unref_object NMClient *client = NULL; + NMDevice *device; + NMConnection *conn; + TestACInfo info = {gl.loop, NULL, 0}; sinfo = nmtstc_service_init(); if (!nmtstc_service_available(sinfo)) @@ -719,9 +719,9 @@ test_active_connections(void) static void client_devices_changed_cb(GObject *client, GParamSpec *pspec, gpointer user_data) { - TestACInfo * info = user_data; + TestACInfo *info = user_data; const GPtrArray *devices; - NMDevice * device; + NMDevice *device; devices = nm_client_get_devices(NM_CLIENT(client)); g_assert(devices != NULL); @@ -755,7 +755,7 @@ client_devices_changed_cb(GObject *client, GParamSpec *pspec, gpointer user_data } typedef struct { - GMainLoop * loop; + GMainLoop *loop; NMRemoteConnection *remote; } TestConnectionInfo; @@ -763,7 +763,7 @@ static void add_connection_cb(GObject *object, GAsyncResult *result, gpointer user_data) { TestConnectionInfo *info = user_data; - GError * error = NULL; + GError *error = NULL; info->remote = nm_client_add_connection_finish(NM_CLIENT(object), result, &error); g_assert_no_error(error); @@ -773,9 +773,9 @@ add_connection_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void activate_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NMClient * client = NM_CLIENT(object); + NMClient *client = NM_CLIENT(object); TestACInfo *info = user_data; - GError * error = NULL; + GError *error = NULL; info->ac = nm_client_activate_connection_finish(client, result, &error); g_assert_no_error(error); @@ -791,13 +791,13 @@ activate_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void test_activate_virtual(void) { - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; - gs_unref_object NMClient *client = NULL; - NMConnection * conn; - NMSettingConnection * s_con; - NMSettingVlan * s_vlan; - TestACInfo info = {gl.loop, NULL, 0}; - TestConnectionInfo conn_info = {gl.loop, NULL}; + nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; + gs_unref_object NMClient *client = NULL; + NMConnection *conn; + NMSettingConnection *s_con; + NMSettingVlan *s_vlan; + TestACInfo info = {gl.loop, NULL, 0}; + TestConnectionInfo conn_info = {gl.loop, NULL}; sinfo = nmtstc_service_init(); if (!nmtstc_service_available(sinfo)) @@ -852,18 +852,18 @@ test_activate_virtual(void) static void test_device_connection_compatibility(void) { - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; - gs_unref_object NMClient *client = NULL; - gs_unref_object NMConnection *conn = NULL; - NMDevice * device1; - NMDevice * device2; - NMSettingWired * s_wired; - GError * error = NULL; - const char * subchannels[] = {"0.0.8000", "0.0.8001", "0.0.8002", NULL}; - const char * subchannels_2[] = {"0.0.8000", "0.0.8001", NULL}; - const char * subchannels_x[] = {"0.0.8000", "0.0.8001", "0.0.800X", NULL}; - const char * hw_addr1 = "52:54:00:ab:db:23"; - const char * hw_addr2 = "52:54:00:ab:db:24"; + nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL; + gs_unref_object NMClient *client = NULL; + gs_unref_object NMConnection *conn = NULL; + NMDevice *device1; + NMDevice *device2; + NMSettingWired *s_wired; + GError *error = NULL; + const char *subchannels[] = {"0.0.8000", "0.0.8001", "0.0.8002", NULL}; + const char *subchannels_2[] = {"0.0.8000", "0.0.8001", NULL}; + const char *subchannels_x[] = {"0.0.8000", "0.0.8001", "0.0.800X", NULL}; + const char *hw_addr1 = "52:54:00:ab:db:23"; + const char *hw_addr2 = "52:54:00:ab:db:24"; sinfo = nmtstc_service_init(); if (!nmtstc_service_available(sinfo)) @@ -927,7 +927,7 @@ static gboolean _test_connection_invalid_find_connections(gpointer element, gpointer needle, gpointer user_data) { NMRemoteConnection *con = NM_REMOTE_CONNECTION(element); - const char * path = needle; + const char *path = needle; g_assert(NM_IS_REMOTE_CONNECTION(con)); g_assert(path && *path); @@ -950,17 +950,17 @@ test_connection_invalid(void) { NMTSTC_SERVICE_INFO_SETUP(my_sinfo); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - gs_unref_object NMClient *client = NULL; - const GPtrArray * connections; - gs_free char * path0 = NULL; - gs_free char * path1 = NULL; - gs_free char * path2 = NULL; - gs_free char * path3 = NULL; - gs_free char * uuid2 = NULL; - gsize n_found; - gssize idx[4]; - gs_unref_variant GVariant *variant = NULL; + NMSettingConnection *s_con; + gs_unref_object NMClient *client = NULL; + const GPtrArray *connections; + gs_free char *path0 = NULL; + gs_free char *path1 = NULL; + gs_free char *path2 = NULL; + gs_free char *path3 = NULL; + gs_free char *uuid2 = NULL; + gsize n_found; + gssize idx[4]; + gs_unref_variant GVariant *variant = NULL; g_assert(g_main_loop_get_context(gl.loop) == (g_main_context_get_thread_default() ?: g_main_context_default())); diff --git a/src/libnm-client-impl/tests/test-remote-settings-client.c b/src/libnm-client-impl/tests/test-remote-settings-client.c index e5415f54c0..7e4872e953 100644 --- a/src/libnm-client-impl/tests/test-remote-settings-client.c +++ b/src/libnm-client-impl/tests/test-remote-settings-client.c @@ -13,9 +13,9 @@ #include "libnm-client-test/nm-test-libnm-utils.h" static struct { - NMTstcServiceInfo * sinfo; - NMClient * client; - GDBusConnection * bus; + NMTstcServiceInfo *sinfo; + NMClient *client; + GDBusConnection *bus; NMRemoteConnection *remote; } gl = {}; @@ -25,7 +25,7 @@ static void add_cb(GObject *s, GAsyncResult *result, gpointer user_data) { gboolean *done = user_data; - GError * error = NULL; + GError *error = NULL; gl.remote = nm_client_add_connection_finish(gl.client, result, &error); g_assert_no_error(error); @@ -72,7 +72,7 @@ test_add_connection(void) static void set_visible_cb(GObject *proxy, GAsyncResult *result, gpointer user_data) { - GError * error = NULL; + GError *error = NULL; GVariant *ret; ret = g_dbus_proxy_call_finish(G_DBUS_PROXY(proxy), result, &error); @@ -95,8 +95,8 @@ connection_removed_cb(NMClient *s, NMRemoteConnection *connection, gboolean *don } static void -invis_has_settings_cb(NMSetting * setting, - const char * key, +invis_has_settings_cb(NMSetting *setting, + const char *key, const GValue *value, GParamFlags flags, gpointer user_data) @@ -109,10 +109,10 @@ test_make_invisible(void) { const GPtrArray *conns; int i; - GDBusProxy * proxy; + GDBusProxy *proxy; gboolean visible_changed = FALSE, connection_removed = FALSE; gboolean has_settings = FALSE; - char * path; + char *path; if (!nmtstc_service_available(gl.sinfo)) return; @@ -193,9 +193,9 @@ test_make_visible(void) { const GPtrArray *conns; int i; - GDBusProxy * proxy; + GDBusProxy *proxy; gboolean found = FALSE; - char * path; + char *path; NMRemoteConnection *new = NULL; if (!nmtstc_service_available(gl.sinfo)) @@ -261,7 +261,7 @@ test_make_visible(void) static void deleted_cb(GObject *proxy, GAsyncResult *result, gpointer user_data) { - GError * error = NULL; + GError *error = NULL; GVariant *ret; ret = g_dbus_proxy_call_finish(G_DBUS_PROXY(proxy), result, &error); @@ -280,11 +280,11 @@ static void test_remove_connection(void) { NMRemoteConnection *connection; - const GPtrArray * conns; + const GPtrArray *conns; int i; - GDBusProxy * proxy; + GDBusProxy *proxy; gboolean done = FALSE; - char * path; + char *path; if (!nmtstc_service_available(gl.sinfo)) return; @@ -334,8 +334,8 @@ test_remove_connection(void) static void add_remove_cb(GObject *s, GAsyncResult *result, gpointer user_data) { - NMRemoteConnection *connection; - gboolean * done = user_data; + NMRemoteConnection *connection; + gboolean *done = user_data; gs_free_error GError *error = NULL; connection = nm_client_add_connection_finish(gl.client, result, &error); @@ -348,8 +348,8 @@ add_remove_cb(GObject *s, GAsyncResult *result, gpointer user_data) static void test_add_remove_connection(void) { - gs_unref_variant GVariant *ret = NULL; - GError * error = NULL; + gs_unref_variant GVariant *ret = NULL; + GError *error = NULL; gs_unref_object NMConnection *connection = NULL; gboolean done = FALSE; @@ -382,7 +382,7 @@ test_add_remove_connection(void) static void add_bad_cb(GObject *s, GAsyncResult *result, gpointer user_data) { - gboolean * done = user_data; + gboolean *done = user_data; gs_free_error GError *error = NULL; gl.remote = nm_client_add_connection_finish(gl.client, result, &error); @@ -418,7 +418,7 @@ test_add_bad_connection(void) static void save_hostname_cb(GObject *s, GAsyncResult *result, gpointer user_data) { - gboolean * done = user_data; + gboolean *done = user_data; gs_free_error GError *error = NULL; nm_client_save_hostname_finish(gl.client, result, &error); @@ -432,7 +432,7 @@ test_save_hostname(void) { gint64 until_ts; gboolean done = FALSE; - GError * error = NULL; + GError *error = NULL; if (!nmtstc_service_available(gl.sinfo)) return; diff --git a/src/libnm-client-impl/tests/test-secret-agent.c b/src/libnm-client-impl/tests/test-secret-agent.c index 8f758f3dd8..1fffb55654 100644 --- a/src/libnm-client-impl/tests/test-secret-agent.c +++ b/src/libnm-client-impl/tests/test-secret-agent.c @@ -29,20 +29,20 @@ GType test_secret_agent_get_type(void); G_DEFINE_TYPE(TestSecretAgent, test_secret_agent, NM_TYPE_SECRET_AGENT_OLD) static void -test_secret_agent_get_secrets(NMSecretAgentOld * agent, - NMConnection * connection, - const char * connection_path, - const char * setting_name, - const char ** hints, +test_secret_agent_get_secrets(NMSecretAgentOld *agent, + NMConnection *connection, + const char *connection_path, + const char *setting_name, + const char **hints, NMSecretAgentGetSecretsFlags flags, NMSecretAgentOldGetSecretsFunc callback, gpointer callback_data) { NMSettingWirelessSecurity *s_wsec; - GVariant * secrets = NULL; + GVariant *secrets = NULL; GVariantBuilder secrets_builder, setting_builder; - char * secret = NULL; - GError * error = NULL; + char *secret = NULL; + GError *error = NULL; g_assert_cmpstr(setting_name, ==, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); @@ -91,16 +91,16 @@ done: static void test_secret_agent_cancel_get_secrets(NMSecretAgentOld *agent, - const char * connection_path, - const char * setting_name) + const char *connection_path, + const char *setting_name) { g_assert_not_reached(); } static void -test_secret_agent_save_secrets(NMSecretAgentOld * agent, - NMConnection * connection, - const char * connection_path, +test_secret_agent_save_secrets(NMSecretAgentOld *agent, + NMConnection *connection, + const char *connection_path, NMSecretAgentOldSaveSecretsFunc callback, gpointer callback_data) { @@ -108,9 +108,9 @@ test_secret_agent_save_secrets(NMSecretAgentOld * agent, } static void -test_secret_agent_delete_secrets(NMSecretAgentOld * agent, - NMConnection * connection, - const char * connection_path, +test_secret_agent_delete_secrets(NMSecretAgentOld *agent, + NMConnection *connection, + const char *connection_path, NMSecretAgentOldDeleteSecretsFunc callback, gpointer callback_data) { @@ -136,7 +136,7 @@ test_secret_agent_new(gboolean auto_register) static void test_secret_agent_class_init(TestSecretAgentClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSecretAgentOldClass *agent_class = NM_SECRET_AGENT_OLD_CLASS(klass); agent_class->get_secrets = test_secret_agent_get_secrets; @@ -163,14 +163,14 @@ test_secret_agent_class_init(TestSecretAgentClass *klass) typedef struct { NMTstcServiceInfo *sinfo; - NMClient * client; + NMClient *client; NMSecretAgentOld *agent; - NMDevice * device; - NMConnection * connection; + NMDevice *device; + NMConnection *connection; GMainLoop *loop; - GSource * timeout_source; + GSource *timeout_source; char *ifname; char *con_id; @@ -182,8 +182,8 @@ static void connection_added_cb(GObject *s, GAsyncResult *result, gpointer user_data) { TestSecretAgentData *sadata = user_data; - NMRemoteConnection * connection; - GError * error = NULL; + NMRemoteConnection *connection; + GError *error = NULL; connection = nm_client_add_connection_finish(sadata->client, result, &error); @@ -198,7 +198,7 @@ static void register_cb(GObject *object, GAsyncResult *result, gpointer user_data) { TestSecretAgentData *sadata = user_data; - GError * error = NULL; + GError *error = NULL; nm_secret_agent_old_register_finish(sadata->agent, result, &error); g_assert_no_error(error); @@ -212,14 +212,14 @@ register_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void test_setup(TestSecretAgentData *sadata, gconstpointer test_data) { - static int static_counter = 0; - const int counter = static_counter++; - const char * create_agent = test_data; - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWireless * s_wireless; - GBytes * ssid; - NMSetting * s_wsec; + static int static_counter = 0; + const int counter = static_counter++; + const char *create_agent = test_data; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWireless *s_wireless; + GBytes *ssid; + NMSetting *s_wsec; gs_free_error GError *error = NULL; sadata->sinfo = nmtstc_service_init(); @@ -296,8 +296,8 @@ test_setup(TestSecretAgentData *sadata, gconstpointer test_data) static void test_cleanup(TestSecretAgentData *sadata, gconstpointer test_data) { - GVariant * ret; - GError * error = NULL; + GVariant *ret; + GError *error = NULL; NMTstContextBusyWatcherData watcher_data = {}; g_assert(nm_g_main_context_is_thread_default(NULL)); @@ -358,8 +358,8 @@ test_cleanup(TestSecretAgentData *sadata, gconstpointer test_data) static void connection_activated_none_cb(GObject *c, GAsyncResult *result, gpointer user_data) { - TestSecretAgentData *sadata = user_data; - gs_free_error GError *error = NULL; + TestSecretAgentData *sadata = user_data; + gs_free_error GError *error = NULL; nm_client_activate_connection_finish(sadata->client, result, &error); g_assert_error(error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_NO_SECRETS); @@ -387,10 +387,10 @@ test_secret_agent_none(TestSecretAgentData *sadata, gconstpointer test_data) static char * secrets_requested_no_secrets_cb(TestSecretAgent *agent, - NMConnection * connection, - const char * connection_path, - const char * setting_name, - const char * secret_name, + NMConnection *connection, + const char *connection_path, + const char *setting_name, + const char *secret_name, gpointer user_data) { TestSecretAgentData *sadata = user_data; @@ -404,9 +404,9 @@ secrets_requested_no_secrets_cb(TestSecretAgent *agent, static void connection_activated_no_secrets_cb(GObject *c, GAsyncResult *result, gpointer user_data) { - TestSecretAgentData *sadata = user_data; - gs_unref_object NMActiveConnection *ac = NULL; - gs_free_error GError *error = NULL; + TestSecretAgentData *sadata = user_data; + gs_unref_object NMActiveConnection *ac = NULL; + gs_free_error GError *error = NULL; ac = nm_client_activate_connection_finish(sadata->client, result, &error); g_assert_error(error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_NO_SECRETS); @@ -441,9 +441,9 @@ test_secret_agent_no_secrets(TestSecretAgentData *sadata, gconstpointer test_dat static void connection_activated_cancel_cb(GObject *c, GAsyncResult *result, gpointer user_data) { - TestSecretAgentData *sadata = user_data; - gs_unref_object NMActiveConnection *ac = NULL; - gs_free_error GError *error = NULL; + TestSecretAgentData *sadata = user_data; + gs_unref_object NMActiveConnection *ac = NULL; + gs_free_error GError *error = NULL; ac = nm_client_activate_connection_finish(sadata->client, result, &error); g_assert_error(error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_USER_CANCELED); @@ -452,10 +452,10 @@ connection_activated_cancel_cb(GObject *c, GAsyncResult *result, gpointer user_d static char * secrets_requested_cancel_cb(TestSecretAgent *agent, - NMConnection * connection, - const char * connection_path, - const char * setting_name, - const char * secret_name, + NMConnection *connection, + const char *connection_path, + const char *setting_name, + const char *secret_name, gpointer user_data) { TestSecretAgentData *sadata = user_data; @@ -495,8 +495,8 @@ static void connection_activated_good_cb(GObject *c, GAsyncResult *result, gpointer user_data) { TestSecretAgentData *sadata = user_data; - NMActiveConnection * ac; - GError * error = NULL; + NMActiveConnection *ac; + GError *error = NULL; ac = nm_client_activate_connection_finish(sadata->client, result, &error); g_assert_no_error(error); @@ -508,10 +508,10 @@ connection_activated_good_cb(GObject *c, GAsyncResult *result, gpointer user_dat static char * secrets_requested_good_cb(TestSecretAgent *agent, - NMConnection * connection, - const char * connection_path, - const char * setting_name, - const char * secret_name, + NMConnection *connection, + const char *connection_path, + const char *setting_name, + const char *secret_name, gpointer user_data) { TestSecretAgentData *sadata = user_data; @@ -550,8 +550,8 @@ test_secret_agent_good(TestSecretAgentData *sadata, gconstpointer test_data) static void async_init_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - GMainLoop * loop = user_data; - gs_free_error GError *error = NULL; + GMainLoop *loop = user_data; + gs_free_error GError *error = NULL; gs_unref_object GObject *agent = NULL; agent = g_async_initable_new_finish(G_ASYNC_INITABLE(object), result, &error); @@ -564,9 +564,9 @@ async_init_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void test_secret_agent_nm_not_running(void) { - gs_unref_object NMSecretAgentOld *agent = NULL; + gs_unref_object NMSecretAgentOld *agent = NULL; nm_auto_unref_gmainloop GMainLoop *loop = NULL; - GError * error = NULL; + GError *error = NULL; agent = g_initable_new(test_secret_agent_get_type(), NULL, @@ -626,12 +626,12 @@ registered_changed(GObject *object, GParamSpec *pspec, gpointer user_data) static void test_secret_agent_auto_register(void) { - NMTstcServiceInfo *sinfo; + NMTstcServiceInfo *sinfo; gs_unref_object NMSecretAgentOld *agent = NULL; - GError * error = NULL; + GError *error = NULL; AutoRegisterData auto_register_data = { - .step = 0, - .invoke_count = 0, + .step = 0, + .invoke_count = 0, }; gulong signal_id; NMTstContextBusyWatcherData watcher_data = {}; diff --git a/src/libnm-client-public/nm-access-point.h b/src/libnm-client-public/nm-access-point.h index 50a7429601..9f9216bb59 100644 --- a/src/libnm-client-public/nm-access-point.h +++ b/src/libnm-client-public/nm-access-point.h @@ -49,8 +49,8 @@ GType nm_access_point_get_type(void); NM80211ApFlags nm_access_point_get_flags(NMAccessPoint *ap); NM80211ApSecurityFlags nm_access_point_get_wpa_flags(NMAccessPoint *ap); NM80211ApSecurityFlags nm_access_point_get_rsn_flags(NMAccessPoint *ap); -GBytes * nm_access_point_get_ssid(NMAccessPoint *ap); -const char * nm_access_point_get_bssid(NMAccessPoint *ap); +GBytes *nm_access_point_get_ssid(NMAccessPoint *ap); +const char *nm_access_point_get_bssid(NMAccessPoint *ap); guint32 nm_access_point_get_frequency(NMAccessPoint *ap); NM80211Mode nm_access_point_get_mode(NMAccessPoint *ap); guint32 nm_access_point_get_max_bitrate(NMAccessPoint *ap); diff --git a/src/libnm-client-public/nm-active-connection.h b/src/libnm-client-public/nm-active-connection.h index 76ea107a9d..a65b4f20f7 100644 --- a/src/libnm-client-public/nm-active-connection.h +++ b/src/libnm-client-public/nm-active-connection.h @@ -51,23 +51,23 @@ typedef struct _NMActiveConnectionClass NMActiveConnectionClass; GType nm_active_connection_get_type(void); NMRemoteConnection *nm_active_connection_get_connection(NMActiveConnection *connection); -const char * nm_active_connection_get_id(NMActiveConnection *connection); -const char * nm_active_connection_get_uuid(NMActiveConnection *connection); -const char * nm_active_connection_get_connection_type(NMActiveConnection *connection); -const char * nm_active_connection_get_specific_object_path(NMActiveConnection *connection); -const GPtrArray * nm_active_connection_get_devices(NMActiveConnection *connection); +const char *nm_active_connection_get_id(NMActiveConnection *connection); +const char *nm_active_connection_get_uuid(NMActiveConnection *connection); +const char *nm_active_connection_get_connection_type(NMActiveConnection *connection); +const char *nm_active_connection_get_specific_object_path(NMActiveConnection *connection); +const GPtrArray *nm_active_connection_get_devices(NMActiveConnection *connection); NMActiveConnectionState nm_active_connection_get_state(NMActiveConnection *connection); NM_AVAILABLE_IN_1_10 NMActivationStateFlags nm_active_connection_get_state_flags(NMActiveConnection *connection); NM_AVAILABLE_IN_1_8 NMActiveConnectionStateReason nm_active_connection_get_state_reason(NMActiveConnection *connection); -NMDevice * nm_active_connection_get_master(NMActiveConnection *connection); +NMDevice *nm_active_connection_get_master(NMActiveConnection *connection); gboolean nm_active_connection_get_default(NMActiveConnection *connection); -NMIPConfig * nm_active_connection_get_ip4_config(NMActiveConnection *connection); -NMDhcpConfig * nm_active_connection_get_dhcp4_config(NMActiveConnection *connection); +NMIPConfig *nm_active_connection_get_ip4_config(NMActiveConnection *connection); +NMDhcpConfig *nm_active_connection_get_dhcp4_config(NMActiveConnection *connection); gboolean nm_active_connection_get_default6(NMActiveConnection *connection); -NMIPConfig * nm_active_connection_get_ip6_config(NMActiveConnection *connection); -NMDhcpConfig * nm_active_connection_get_dhcp6_config(NMActiveConnection *connection); +NMIPConfig *nm_active_connection_get_ip6_config(NMActiveConnection *connection); +NMDhcpConfig *nm_active_connection_get_dhcp6_config(NMActiveConnection *connection); gboolean nm_active_connection_get_vpn(NMActiveConnection *connection); G_END_DECLS diff --git a/src/libnm-client-public/nm-client.h b/src/libnm-client-public/nm-client.h index 02c8ee337b..ac615b5716 100644 --- a/src/libnm-client-public/nm-client.h +++ b/src/libnm-client-public/nm-client.h @@ -233,7 +233,7 @@ _NM_DEPRECATED_SYNC_METHOD gboolean nm_client_set_logging(NMClient *client, const char *level, const char *domains, GError **error); -NMClientPermissionResult nm_client_get_permission_result(NMClient * client, +NMClientPermissionResult nm_client_get_permission_result(NMClient *client, NMClientPermission permission); NM_AVAILABLE_IN_1_24 @@ -246,22 +246,22 @@ NM_DEPRECATED_IN_1_22 NMConnectivityState nm_client_check_connectivity(NMClient *client, GCancellable *cancellable, GError **error); -void nm_client_check_connectivity_async(NMClient * client, - GCancellable * cancellable, +void nm_client_check_connectivity_async(NMClient *client, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NMConnectivityState nm_client_check_connectivity_finish(NMClient *client, GAsyncResult *result, GError **error); _NM_DEPRECATED_SYNC_METHOD -gboolean nm_client_save_hostname(NMClient * client, - const char * hostname, +gboolean nm_client_save_hostname(NMClient *client, + const char *hostname, GCancellable *cancellable, - GError ** error); + GError **error); -void nm_client_save_hostname_async(NMClient * client, - const char * hostname, - GCancellable * cancellable, +void nm_client_save_hostname_async(NMClient *client, + const char *hostname, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean nm_client_save_hostname_finish(NMClient *client, GAsyncResult *result, GError **error); @@ -271,8 +271,8 @@ gboolean nm_client_save_hostname_finish(NMClient *client, GAsyncResult *result, const GPtrArray *nm_client_get_devices(NMClient *client); NM_AVAILABLE_IN_1_2 const GPtrArray *nm_client_get_all_devices(NMClient *client); -NMDevice * nm_client_get_device_by_path(NMClient *client, const char *object_path); -NMDevice * nm_client_get_device_by_iface(NMClient *client, const char *iface); +NMDevice *nm_client_get_device_by_path(NMClient *client, const char *object_path); +NMDevice *nm_client_get_device_by_iface(NMClient *client, const char *iface); /* Active Connections */ @@ -281,51 +281,51 @@ const GPtrArray *nm_client_get_active_connections(NMClient *client); NMActiveConnection *nm_client_get_primary_connection(NMClient *client); NMActiveConnection *nm_client_get_activating_connection(NMClient *client); -void nm_client_activate_connection_async(NMClient * client, - NMConnection * connection, - NMDevice * device, - const char * specific_object, - GCancellable * cancellable, +void nm_client_activate_connection_async(NMClient *client, + NMConnection *connection, + NMDevice *device, + const char *specific_object, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NMActiveConnection * nm_client_activate_connection_finish(NMClient *client, GAsyncResult *result, GError **error); -void nm_client_add_and_activate_connection_async(NMClient * client, - NMConnection * partial, - NMDevice * device, - const char * specific_object, - GCancellable * cancellable, +void nm_client_add_and_activate_connection_async(NMClient *client, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); -NMActiveConnection *nm_client_add_and_activate_connection_finish(NMClient * client, +NMActiveConnection *nm_client_add_and_activate_connection_finish(NMClient *client, GAsyncResult *result, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_16 -void nm_client_add_and_activate_connection2(NMClient * client, - NMConnection * partial, - NMDevice * device, - const char * specific_object, - GVariant * options, - GCancellable * cancellable, +void nm_client_add_and_activate_connection2(NMClient *client, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + GVariant *options, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_16 -NMActiveConnection *nm_client_add_and_activate_connection2_finish(NMClient * client, +NMActiveConnection *nm_client_add_and_activate_connection2_finish(NMClient *client, GAsyncResult *result, - GVariant ** out_result, - GError ** error); + GVariant **out_result, + GError **error); _NM_DEPRECATED_SYNC_METHOD -gboolean nm_client_deactivate_connection(NMClient * client, +gboolean nm_client_deactivate_connection(NMClient *client, NMActiveConnection *active, - GCancellable * cancellable, - GError ** error); + GCancellable *cancellable, + GError **error); -void nm_client_deactivate_connection_async(NMClient * client, +void nm_client_deactivate_connection_async(NMClient *client, NMActiveConnection *active, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean @@ -339,53 +339,53 @@ NMRemoteConnection *nm_client_get_connection_by_id(NMClient *client, const char NMRemoteConnection *nm_client_get_connection_by_path(NMClient *client, const char *path); NMRemoteConnection *nm_client_get_connection_by_uuid(NMClient *client, const char *uuid); -void nm_client_add_connection_async(NMClient * client, - NMConnection * connection, +void nm_client_add_connection_async(NMClient *client, + NMConnection *connection, gboolean save_to_disk, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NMRemoteConnection * nm_client_add_connection_finish(NMClient *client, GAsyncResult *result, GError **error); NM_AVAILABLE_IN_1_20 -void nm_client_add_connection2(NMClient * client, - GVariant * settings, +void nm_client_add_connection2(NMClient *client, + GVariant *settings, NMSettingsAddConnection2Flags flags, - GVariant * args, + GVariant *args, gboolean ignore_out_result, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_20 -NMRemoteConnection *nm_client_add_connection2_finish(NMClient * client, +NMRemoteConnection *nm_client_add_connection2_finish(NMClient *client, GAsyncResult *result, - GVariant ** out_result, - GError ** error); + GVariant **out_result, + GError **error); _NM_DEPRECATED_SYNC_METHOD -gboolean nm_client_load_connections(NMClient * client, - char ** filenames, - char *** failures, +gboolean nm_client_load_connections(NMClient *client, + char **filenames, + char ***failures, GCancellable *cancellable, - GError ** error); + GError **error); -void nm_client_load_connections_async(NMClient * client, - char ** filenames, - GCancellable * cancellable, +void nm_client_load_connections_async(NMClient *client, + char **filenames, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); -gboolean nm_client_load_connections_finish(NMClient * client, - char *** failures, +gboolean nm_client_load_connections_finish(NMClient *client, + char ***failures, GAsyncResult *result, - GError ** error); + GError **error); _NM_DEPRECATED_SYNC_METHOD gboolean nm_client_reload_connections(NMClient *client, GCancellable *cancellable, GError **error); -void nm_client_reload_connections_async(NMClient * client, - GCancellable * cancellable, +void nm_client_reload_connections_async(NMClient *client, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean @@ -402,11 +402,11 @@ NM_AVAILABLE_IN_1_12 const GPtrArray *nm_client_get_checkpoints(NMClient *client); NM_AVAILABLE_IN_1_12 -void nm_client_checkpoint_create(NMClient * client, - const GPtrArray * devices, +void nm_client_checkpoint_create(NMClient *client, + const GPtrArray *devices, guint32 rollback_timeout, NMCheckpointCreateFlags flags, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_12 @@ -414,9 +414,9 @@ NMCheckpoint * nm_client_checkpoint_create_finish(NMClient *client, GAsyncResult *result, GError **error); NM_AVAILABLE_IN_1_12 -void nm_client_checkpoint_destroy(NMClient * client, - const char * checkpoint_path, - GCancellable * cancellable, +void nm_client_checkpoint_destroy(NMClient *client, + const char *checkpoint_path, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_12 @@ -424,9 +424,9 @@ gboolean nm_client_checkpoint_destroy_finish(NMClient *client, GAsyncResult *result, GError **error); NM_AVAILABLE_IN_1_12 -void nm_client_checkpoint_rollback(NMClient * client, - const char * checkpoint_path, - GCancellable * cancellable, +void nm_client_checkpoint_rollback(NMClient *client, + const char *checkpoint_path, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_12 @@ -434,22 +434,22 @@ GHashTable * nm_client_checkpoint_rollback_finish(NMClient *client, GAsyncResult *result, GError **error); NM_AVAILABLE_IN_1_12 -void nm_client_checkpoint_adjust_rollback_timeout(NMClient * client, - const char * checkpoint_path, +void nm_client_checkpoint_adjust_rollback_timeout(NMClient *client, + const char *checkpoint_path, guint32 add_timeout, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_12 -gboolean nm_client_checkpoint_adjust_rollback_timeout_finish(NMClient * client, +gboolean nm_client_checkpoint_adjust_rollback_timeout_finish(NMClient *client, GAsyncResult *result, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_22 -void nm_client_reload(NMClient * client, +void nm_client_reload(NMClient *client, NMManagerReloadFlags flags, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_22 @@ -458,14 +458,14 @@ gboolean nm_client_reload_finish(NMClient *client, GAsyncResult *result, GError /*****************************************************************************/ NM_AVAILABLE_IN_1_24 -void nm_client_dbus_call(NMClient * client, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +void nm_client_dbus_call(NMClient *client, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -473,13 +473,13 @@ NM_AVAILABLE_IN_1_24 GVariant *nm_client_dbus_call_finish(NMClient *client, GAsyncResult *result, GError **error); NM_AVAILABLE_IN_1_24 -void nm_client_dbus_set_property(NMClient * client, - const char * object_path, - const char * interface_name, - const char * property_name, - GVariant * value, +void nm_client_dbus_set_property(NMClient *client, + const char *object_path, + const char *interface_name, + const char *property_name, + GVariant *value, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); diff --git a/src/libnm-client-public/nm-device-wifi-p2p.h b/src/libnm-client-public/nm-device-wifi-p2p.h index 3395ca2906..cf68b496b9 100644 --- a/src/libnm-client-public/nm-device-wifi-p2p.h +++ b/src/libnm-client-public/nm-device-wifi-p2p.h @@ -50,9 +50,9 @@ NM_AVAILABLE_IN_1_16 const GPtrArray *nm_device_wifi_p2p_get_peers(NMDeviceWifiP2P *device); NM_AVAILABLE_IN_1_16 -void nm_device_wifi_p2p_start_find(NMDeviceWifiP2P * device, - GVariant * options, - GCancellable * cancellable, +void nm_device_wifi_p2p_start_find(NMDeviceWifiP2P *device, + GVariant *options, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_16 @@ -60,8 +60,8 @@ gboolean nm_device_wifi_p2p_start_find_finish(NMDeviceWifiP2P *device, GAsyncResult *result, GError **error); NM_AVAILABLE_IN_1_16 -void nm_device_wifi_p2p_stop_find(NMDeviceWifiP2P * device, - GCancellable * cancellable, +void nm_device_wifi_p2p_stop_find(NMDeviceWifiP2P *device, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_16 diff --git a/src/libnm-client-public/nm-device-wifi.h b/src/libnm-client-public/nm-device-wifi.h index 85062f518d..1c767316ae 100644 --- a/src/libnm-client-public/nm-device-wifi.h +++ b/src/libnm-client-public/nm-device-wifi.h @@ -43,11 +43,11 @@ GType nm_device_wifi_get_type(void); NM_DEPRECATED_IN_1_24_FOR(nm_device_get_hw_address) const char *nm_device_wifi_get_hw_address(NMDeviceWifi *device); -const char * nm_device_wifi_get_permanent_hw_address(NMDeviceWifi *device); +const char *nm_device_wifi_get_permanent_hw_address(NMDeviceWifi *device); NM80211Mode nm_device_wifi_get_mode(NMDeviceWifi *device); guint32 nm_device_wifi_get_bitrate(NMDeviceWifi *device); NMDeviceWifiCapabilities nm_device_wifi_get_capabilities(NMDeviceWifi *device); -NMAccessPoint * nm_device_wifi_get_active_access_point(NMDeviceWifi *device); +NMAccessPoint *nm_device_wifi_get_active_access_point(NMDeviceWifi *device); NMAccessPoint *nm_device_wifi_get_access_point_by_path(NMDeviceWifi *device, const char *path); @@ -62,17 +62,17 @@ nm_device_wifi_request_scan(NMDeviceWifi *device, GCancellable *cancellable, GEr NM_AVAILABLE_IN_1_2 _NM_DEPRECATED_SYNC_METHOD gboolean nm_device_wifi_request_scan_options(NMDeviceWifi *device, - GVariant * options, + GVariant *options, GCancellable *cancellable, - GError ** error); -void nm_device_wifi_request_scan_async(NMDeviceWifi * device, - GCancellable * cancellable, + GError **error); +void nm_device_wifi_request_scan_async(NMDeviceWifi *device, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_2 -void nm_device_wifi_request_scan_options_async(NMDeviceWifi * device, - GVariant * options, - GCancellable * cancellable, +void nm_device_wifi_request_scan_options_async(NMDeviceWifi *device, + GVariant *options, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean diff --git a/src/libnm-client-public/nm-device.h b/src/libnm-client-public/nm-device.h index 23b1a805d3..9e9dbea64d 100644 --- a/src/libnm-client-public/nm-device.h +++ b/src/libnm-client-public/nm-device.h @@ -128,17 +128,17 @@ typedef struct _NMLldpNeighbor NMLldpNeighbor; GType nm_device_get_type(void); -const char * nm_device_get_iface(NMDevice *device); -const char * nm_device_get_ip_iface(NMDevice *device); +const char *nm_device_get_iface(NMDevice *device); +const char *nm_device_get_ip_iface(NMDevice *device); NMDeviceType nm_device_get_device_type(NMDevice *device); -const char * nm_device_get_udi(NMDevice *device); +const char *nm_device_get_udi(NMDevice *device); NM_AVAILABLE_IN_1_26 -const char * nm_device_get_path(NMDevice *device); -const char * nm_device_get_driver(NMDevice *device); -const char * nm_device_get_driver_version(NMDevice *device); -const char * nm_device_get_firmware_version(NMDevice *device); -const char * nm_device_get_type_description(NMDevice *device); -const char * nm_device_get_hw_address(NMDevice *device); +const char *nm_device_get_path(NMDevice *device); +const char *nm_device_get_driver(NMDevice *device); +const char *nm_device_get_driver_version(NMDevice *device); +const char *nm_device_get_firmware_version(NMDevice *device); +const char *nm_device_get_type_description(NMDevice *device); +const char *nm_device_get_hw_address(NMDevice *device); NMDeviceCapabilities nm_device_get_capabilities(NMDevice *device); gboolean nm_device_get_managed(NMDevice *device); @@ -159,17 +159,17 @@ void nm_device_set_autoconnect(NMDevice *device, gboolean autoconnect); gboolean nm_device_get_firmware_missing(NMDevice *device); NM_AVAILABLE_IN_1_2 gboolean nm_device_get_nm_plugin_missing(NMDevice *device); -NMIPConfig * nm_device_get_ip4_config(NMDevice *device); +NMIPConfig *nm_device_get_ip4_config(NMDevice *device); NMDhcpConfig *nm_device_get_dhcp4_config(NMDevice *device); -NMIPConfig * nm_device_get_ip6_config(NMDevice *device); +NMIPConfig *nm_device_get_ip6_config(NMDevice *device); NMDhcpConfig *nm_device_get_dhcp6_config(NMDevice *device); NM_AVAILABLE_IN_1_16 NMConnectivityState nm_device_get_connectivity(NMDevice *device, int addr_family); NMDeviceState nm_device_get_state(NMDevice *device); NMDeviceStateReason nm_device_get_state_reason(NMDevice *device); NMActiveConnection *nm_device_get_active_connection(NMDevice *device); -const GPtrArray * nm_device_get_available_connections(NMDevice *device); -const char * nm_device_get_physical_port_id(NMDevice *device); +const GPtrArray *nm_device_get_available_connections(NMDevice *device); +const char *nm_device_get_physical_port_id(NMDevice *device); guint32 nm_device_get_mtu(NMDevice *device); NM_AVAILABLE_IN_1_2 gboolean nm_device_is_real(NMDevice *device); @@ -188,18 +188,18 @@ NMDeviceInterfaceFlags nm_device_get_interface_flags(NMDevice *device); char **nm_device_disambiguate_names(NMDevice **devices, int num_devices); NM_AVAILABLE_IN_1_2 _NM_DEPRECATED_SYNC_METHOD -gboolean nm_device_reapply(NMDevice * device, +gboolean nm_device_reapply(NMDevice *device, NMConnection *connection, guint64 version_id, guint32 flags, GCancellable *cancellable, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_2 -void nm_device_reapply_async(NMDevice * device, - NMConnection * connection, +void nm_device_reapply_async(NMDevice *device, + NMConnection *connection, guint64 version_id, guint32 flags, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_2 @@ -207,35 +207,35 @@ gboolean nm_device_reapply_finish(NMDevice *device, GAsyncResult *result, GError NM_AVAILABLE_IN_1_2 _NM_DEPRECATED_SYNC_METHOD -NMConnection *nm_device_get_applied_connection(NMDevice * device, +NMConnection *nm_device_get_applied_connection(NMDevice *device, guint32 flags, - guint64 * version_id, + guint64 *version_id, GCancellable *cancellable, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_2 -void nm_device_get_applied_connection_async(NMDevice * device, +void nm_device_get_applied_connection_async(NMDevice *device, guint32 flags, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_2 -NMConnection *nm_device_get_applied_connection_finish(NMDevice * device, +NMConnection *nm_device_get_applied_connection_finish(NMDevice *device, GAsyncResult *result, - guint64 * version_id, - GError ** error); + guint64 *version_id, + GError **error); _NM_DEPRECATED_SYNC_METHOD gboolean nm_device_disconnect(NMDevice *device, GCancellable *cancellable, GError **error); -void nm_device_disconnect_async(NMDevice * device, - GCancellable * cancellable, +void nm_device_disconnect_async(NMDevice *device, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean nm_device_disconnect_finish(NMDevice *device, GAsyncResult *result, GError **error); _NM_DEPRECATED_SYNC_METHOD gboolean nm_device_delete(NMDevice *device, GCancellable *cancellable, GError **error); -void nm_device_delete_async(NMDevice * device, - GCancellable * cancellable, +void nm_device_delete_async(NMDevice *device, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean nm_device_delete_finish(NMDevice *device, GAsyncResult *result, GError **error); @@ -264,8 +264,8 @@ NM_AVAILABLE_IN_1_2 NMLldpNeighbor *nm_lldp_neighbor_new(void); NM_AVAILABLE_IN_1_2 gboolean nm_lldp_neighbor_get_attr_string_value(NMLldpNeighbor *neighbor, - const char * name, - const char ** out_value); + const char *name, + const char **out_value); NM_AVAILABLE_IN_1_2 gboolean nm_lldp_neighbor_get_attr_uint_value(NMLldpNeighbor *neighbor, const char *name, guint *out_value); diff --git a/src/libnm-client-public/nm-ip-config.h b/src/libnm-client-public/nm-ip-config.h index a63dea67d0..99b1948dbe 100644 --- a/src/libnm-client-public/nm-ip-config.h +++ b/src/libnm-client-public/nm-ip-config.h @@ -41,9 +41,9 @@ typedef struct _NMIPConfigClass NMIPConfigClass; GType nm_ip_config_get_type(void); int nm_ip_config_get_family(NMIPConfig *config); -const char * nm_ip_config_get_gateway(NMIPConfig *config); -GPtrArray * nm_ip_config_get_addresses(NMIPConfig *config); -GPtrArray * nm_ip_config_get_routes(NMIPConfig *config); +const char *nm_ip_config_get_gateway(NMIPConfig *config); +GPtrArray *nm_ip_config_get_addresses(NMIPConfig *config); +GPtrArray *nm_ip_config_get_routes(NMIPConfig *config); const char *const *nm_ip_config_get_nameservers(NMIPConfig *config); const char *const *nm_ip_config_get_domains(NMIPConfig *config); const char *const *nm_ip_config_get_searches(NMIPConfig *config); diff --git a/src/libnm-client-public/nm-remote-connection.h b/src/libnm-client-public/nm-remote-connection.h index 06088e8664..6104ecb817 100644 --- a/src/libnm-client-public/nm-remote-connection.h +++ b/src/libnm-client-public/nm-remote-connection.h @@ -42,73 +42,73 @@ typedef struct _NMRemoteConnectionClass NMRemoteConnectionClass; GType nm_remote_connection_get_type(void); NM_AVAILABLE_IN_1_12 -void nm_remote_connection_update2(NMRemoteConnection * connection, - GVariant * settings, +void nm_remote_connection_update2(NMRemoteConnection *connection, + GVariant *settings, NMSettingsUpdate2Flags flags, - GVariant * args, - GCancellable * cancellable, + GVariant *args, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NM_AVAILABLE_IN_1_12 GVariant *nm_remote_connection_update2_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error); + GAsyncResult *result, + GError **error); _NM_DEPRECATED_SYNC_METHOD gboolean nm_remote_connection_commit_changes(NMRemoteConnection *connection, gboolean save_to_disk, - GCancellable * cancellable, - GError ** error); + GCancellable *cancellable, + GError **error); void nm_remote_connection_commit_changes_async(NMRemoteConnection *connection, gboolean save_to_disk, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean nm_remote_connection_commit_changes_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error); + GAsyncResult *result, + GError **error); _NM_DEPRECATED_SYNC_METHOD gboolean nm_remote_connection_save(NMRemoteConnection *connection, - GCancellable * cancellable, - GError ** error); + GCancellable *cancellable, + GError **error); void nm_remote_connection_save_async(NMRemoteConnection *connection, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean nm_remote_connection_save_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error); + GAsyncResult *result, + GError **error); _NM_DEPRECATED_SYNC_METHOD gboolean nm_remote_connection_delete(NMRemoteConnection *connection, - GCancellable * cancellable, - GError ** error); + GCancellable *cancellable, + GError **error); void nm_remote_connection_delete_async(NMRemoteConnection *connection, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean nm_remote_connection_delete_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error); + GAsyncResult *result, + GError **error); _NM_DEPRECATED_SYNC_METHOD GVariant *nm_remote_connection_get_secrets(NMRemoteConnection *connection, - const char * setting_name, - GCancellable * cancellable, - GError ** error); + const char *setting_name, + GCancellable *cancellable, + GError **error); void nm_remote_connection_get_secrets_async(NMRemoteConnection *connection, - const char * setting_name, - GCancellable * cancellable, + const char *setting_name, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); GVariant *nm_remote_connection_get_secrets_finish(NMRemoteConnection *connection, - GAsyncResult * result, - GError ** error); + GAsyncResult *result, + GError **error); gboolean nm_remote_connection_get_unsaved(NMRemoteConnection *connection); diff --git a/src/libnm-client-public/nm-secret-agent-old.h b/src/libnm-client-public/nm-secret-agent-old.h index cc33c14ae4..b45b12bb6a 100644 --- a/src/libnm-client-public/nm-secret-agent-old.h +++ b/src/libnm-client-public/nm-secret-agent-old.h @@ -80,9 +80,9 @@ typedef struct { * */ typedef void (*NMSecretAgentOldGetSecretsFunc)(NMSecretAgentOld *agent, - NMConnection * connection, - GVariant * secrets, - GError * error, + NMConnection *connection, + GVariant *secrets, + GError *error, gpointer user_data); /** @@ -100,8 +100,8 @@ typedef void (*NMSecretAgentOldGetSecretsFunc)(NMSecretAgentOld *agent, * should be called. */ typedef void (*NMSecretAgentOldSaveSecretsFunc)(NMSecretAgentOld *agent, - NMConnection * connection, - GError * error, + NMConnection *connection, + GError *error, gpointer user_data); /** @@ -119,8 +119,8 @@ typedef void (*NMSecretAgentOldSaveSecretsFunc)(NMSecretAgentOld *agent, * should be called. */ typedef void (*NMSecretAgentOldDeleteSecretsFunc)(NMSecretAgentOld *agent, - NMConnection * connection, - GError * error, + NMConnection *connection, + GError *error, gpointer user_data); typedef struct { @@ -138,11 +138,11 @@ typedef struct { * error. Since 1.24, invoking the callback has no effect during cancellation * and may be omitted. */ - void (*get_secrets)(NMSecretAgentOld * self, - NMConnection * connection, - const char * connection_path, - const char * setting_name, - const char ** hints, + void (*get_secrets)(NMSecretAgentOld *self, + NMConnection *connection, + const char *connection_path, + const char *setting_name, + const char **hints, NMSecretAgentGetSecretsFlags flags, NMSecretAgentOldGetSecretsFunc callback, gpointer user_data); @@ -156,8 +156,8 @@ typedef struct { * the get_secrets callback will be ignored during cancellation and may be omitted. */ void (*cancel_get_secrets)(NMSecretAgentOld *self, - const char * connection_path, - const char * setting_name); + const char *connection_path, + const char *setting_name); /* Called when the subclass should save the secrets contained in the * connection to backing storage. Subclass must copy or reference any @@ -165,9 +165,9 @@ typedef struct { * arguments will freed (except for 'self', 'callback', and 'user_data' * of course). */ - void (*save_secrets)(NMSecretAgentOld * self, - NMConnection * connection, - const char * connection_path, + void (*save_secrets)(NMSecretAgentOld *self, + NMConnection *connection, + const char *connection_path, NMSecretAgentOldSaveSecretsFunc callback, gpointer user_data); @@ -177,9 +177,9 @@ typedef struct { * arguments will freed (except for 'self', 'callback', and 'user_data' * of course). */ - void (*delete_secrets)(NMSecretAgentOld * self, - NMConnection * connection, - const char * connection_path, + void (*delete_secrets)(NMSecretAgentOld *self, + NMConnection *connection, + const char *connection_path, NMSecretAgentOldDeleteSecretsFunc callback, gpointer user_data); @@ -208,8 +208,8 @@ gboolean nm_secret_agent_old_get_registered(NMSecretAgentOld *self); NM_AVAILABLE_IN_1_24 void nm_secret_agent_old_enable(NMSecretAgentOld *self, gboolean enable); -void nm_secret_agent_old_register_async(NMSecretAgentOld * self, - GCancellable * cancellable, +void nm_secret_agent_old_register_async(NMSecretAgentOld *self, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean @@ -229,8 +229,8 @@ gboolean nm_secret_agent_old_unregister(NMSecretAgentOld *self, GCancellable *cancellable, GError **error); NM_DEPRECATED_IN_1_24_FOR(nm_secret_agent_old_enable) -void nm_secret_agent_old_unregister_async(NMSecretAgentOld * self, - GCancellable * cancellable, +void nm_secret_agent_old_unregister_async(NMSecretAgentOld *self, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -240,21 +240,21 @@ nm_secret_agent_old_unregister_finish(NMSecretAgentOld *self, GAsyncResult *resu /*****************************************************************************/ -void nm_secret_agent_old_get_secrets(NMSecretAgentOld * self, - NMConnection * connection, - const char * setting_name, - const char ** hints, +void nm_secret_agent_old_get_secrets(NMSecretAgentOld *self, + NMConnection *connection, + const char *setting_name, + const char **hints, NMSecretAgentGetSecretsFlags flags, NMSecretAgentOldGetSecretsFunc callback, gpointer user_data); -void nm_secret_agent_old_save_secrets(NMSecretAgentOld * self, - NMConnection * connection, +void nm_secret_agent_old_save_secrets(NMSecretAgentOld *self, + NMConnection *connection, NMSecretAgentOldSaveSecretsFunc callback, gpointer user_data); -void nm_secret_agent_old_delete_secrets(NMSecretAgentOld * self, - NMConnection * connection, +void nm_secret_agent_old_delete_secrets(NMSecretAgentOld *self, + NMConnection *connection, NMSecretAgentOldDeleteSecretsFunc callback, gpointer user_data); diff --git a/src/libnm-client-public/nm-vpn-connection.h b/src/libnm-client-public/nm-vpn-connection.h index 1a20d0afd7..33ca139d20 100644 --- a/src/libnm-client-public/nm-vpn-connection.h +++ b/src/libnm-client-public/nm-vpn-connection.h @@ -37,7 +37,7 @@ typedef struct _NMVpnConnectionClass NMVpnConnectionClass; GType nm_vpn_connection_get_type(void); NMVpnConnectionState nm_vpn_connection_get_vpn_state(NMVpnConnection *vpn); -const char * nm_vpn_connection_get_banner(NMVpnConnection *vpn); +const char *nm_vpn_connection_get_banner(NMVpnConnection *vpn); G_END_DECLS diff --git a/src/libnm-client-public/nm-vpn-plugin-old.h b/src/libnm-client-public/nm-vpn-plugin-old.h index 116b8b9083..7704c1539e 100644 --- a/src/libnm-client-public/nm-vpn-plugin-old.h +++ b/src/libnm-client-public/nm-vpn-plugin-old.h @@ -66,9 +66,9 @@ typedef struct { NM_DEPRECATED_IN_1_2 gboolean (*need_secrets)(NMVpnPluginOld *plugin, - NMConnection * connection, - const char ** setting_name, - GError ** error); + NMConnection *connection, + const char **setting_name, + GError **error); NM_DEPRECATED_IN_1_2 gboolean (*disconnect)(NMVpnPluginOld *plugin, GError **err); @@ -78,9 +78,9 @@ typedef struct { NM_DEPRECATED_IN_1_2 gboolean (*connect_interactive)(NMVpnPluginOld *plugin, - NMConnection * connection, - GVariant * details, - GError ** error); + NMConnection *connection, + GVariant *details, + GError **error); /*< private >*/ NM_DEPRECATED_IN_1_2 @@ -126,8 +126,8 @@ gboolean nm_vpn_plugin_old_read_vpn_details(int fd, GHashTable **out_data, GHashTable **out_secrets); NM_DEPRECATED_IN_1_2 -gboolean nm_vpn_plugin_old_get_secret_flags(GHashTable * data, - const char * secret_name, +gboolean nm_vpn_plugin_old_get_secret_flags(GHashTable *data, + const char *secret_name, NMSettingSecretFlags *out_flags); G_END_DECLS diff --git a/src/libnm-client-public/nm-vpn-service-plugin.h b/src/libnm-client-public/nm-vpn-service-plugin.h index 916ea52a3d..81fb6730ae 100644 --- a/src/libnm-client-public/nm-vpn-service-plugin.h +++ b/src/libnm-client-public/nm-vpn-service-plugin.h @@ -73,9 +73,9 @@ typedef struct { NM_AVAILABLE_IN_1_2 gboolean (*need_secrets)(NMVpnServicePlugin *plugin, - NMConnection * connection, - const char ** setting_name, - GError ** error); + NMConnection *connection, + const char **setting_name, + GError **error); NM_AVAILABLE_IN_1_2 gboolean (*disconnect)(NMVpnServicePlugin *plugin, GError **err); @@ -85,9 +85,9 @@ typedef struct { NM_AVAILABLE_IN_1_2 gboolean (*connect_interactive)(NMVpnServicePlugin *plugin, - NMConnection * connection, - GVariant * details, - GError ** error); + NMConnection *connection, + GVariant *details, + GError **error); /*< private >*/ NM_AVAILABLE_IN_1_2 @@ -102,8 +102,8 @@ GDBusConnection *nm_vpn_service_plugin_get_connection(NMVpnServicePlugin *plugin NM_AVAILABLE_IN_1_2 void nm_vpn_service_plugin_secrets_required(NMVpnServicePlugin *plugin, - const char * message, - const char ** hints); + const char *message, + const char **hints); NM_AVAILABLE_IN_1_2 void nm_vpn_service_plugin_set_login_banner(NMVpnServicePlugin *plugin, const char *banner); @@ -133,8 +133,8 @@ gboolean nm_vpn_service_plugin_read_vpn_details(int fd, GHashTable **out_data, GHashTable **out_secrets); NM_AVAILABLE_IN_1_2 -gboolean nm_vpn_service_plugin_get_secret_flags(GHashTable * data, - const char * secret_name, +gboolean nm_vpn_service_plugin_get_secret_flags(GHashTable *data, + const char *secret_name, NMSettingSecretFlags *out_flags); G_END_DECLS diff --git a/src/libnm-client-test/nm-test-libnm-utils.h b/src/libnm-client-test/nm-test-libnm-utils.h index 4997ab33a5..2a4dae8736 100644 --- a/src/libnm-client-test/nm-test-libnm-utils.h +++ b/src/libnm-client-test/nm-test-libnm-utils.h @@ -12,7 +12,7 @@ typedef struct { GDBusConnection *bus; - GDBusProxy * proxy; + GDBusProxy *proxy; GPid pid; int keepalive_fd; } NMTstcServiceInfo; @@ -39,34 +39,34 @@ _nmtstc_auto_service_cleanup(NMTstcServiceInfo **info) }) NMDevice *nmtstc_service_add_device(NMTstcServiceInfo *info, - NMClient * client, - const char * method, - const char * ifname); + NMClient *client, + const char *method, + const char *ifname); NMDevice *nmtstc_service_add_wired_device(NMTstcServiceInfo *sinfo, - NMClient * client, - const char * ifname, - const char * hwaddr, - const char ** subchannels); + NMClient *client, + const char *ifname, + const char *hwaddr, + const char **subchannels); void nmtstc_service_add_connection(NMTstcServiceInfo *sinfo, - NMConnection * connection, + NMConnection *connection, gboolean verify_connection, - char ** out_path); + char **out_path); void nmtstc_service_add_connection_variant(NMTstcServiceInfo *sinfo, - GVariant * connection, + GVariant *connection, gboolean verify_connection, - char ** out_path); + char **out_path); void nmtstc_service_update_connection(NMTstcServiceInfo *sinfo, - const char * path, - NMConnection * connection, + const char *path, + NMConnection *connection, gboolean verify_connection); void nmtstc_service_update_connection_variant(NMTstcServiceInfo *sinfo, - const char * path, - GVariant * connection, + const char *path, + GVariant *connection, gboolean verify_connection); gpointer nmtstc_context_object_new_valist(GType gtype, diff --git a/src/libnm-client-test/nm-test-utils-impl.c b/src/libnm-client-test/nm-test-utils-impl.c index 610232b000..ef98d9c221 100644 --- a/src/libnm-client-test/nm-test-utils-impl.c +++ b/src/libnm-client-test/nm-test-utils-impl.c @@ -42,7 +42,7 @@ name_exists(GDBusConnection *c, const char *name) } typedef struct { - GMainLoop * mainloop; + GMainLoop *mainloop; GDBusConnection *bus; int exit_code; bool exited : 1; @@ -92,8 +92,8 @@ NMTstcServiceInfo * nmtstc_service_init(void) { NMTstcServiceInfo *info; - const char * args[] = {TEST_NM_PYTHON, NMTSTC_NM_SERVICE, NULL}; - GError * error = NULL; + const char *args[] = {TEST_NM_PYTHON, NMTSTC_NM_SERVICE, NULL}; + GError *error = NULL; info = g_malloc0(sizeof(*info)); @@ -120,10 +120,10 @@ nmtstc_service_init(void) { nm_auto_unref_gsource GSource *timeout_source = NULL; nm_auto_unref_gsource GSource *child_source = NULL; - GMainContext * context = g_main_context_new(); + GMainContext *context = g_main_context_new(); ServiceInitWaitData data = { - .bus = info->bus, - .mainloop = g_main_loop_new(context, FALSE), + .bus = info->bus, + .mainloop = g_main_loop_new(context, FALSE), }; gboolean had_timeout; @@ -226,10 +226,10 @@ again_wait: } typedef struct { - GMainLoop * loop; + GMainLoop *loop; const char *ifname; const char *path; - NMDevice * device; + NMDevice *device; } AddDeviceInfo; static void @@ -249,11 +249,11 @@ device_added_cb(NMClient *client, NMDevice *device, gpointer user_data) } static GVariant * -call_add_wired_device(GDBusProxy * proxy, - const char * ifname, - const char * hwaddr, +call_add_wired_device(GDBusProxy *proxy, + const char *ifname, + const char *hwaddr, const char **subchannels, - GError ** error) + GError **error) { const char *empty[] = {NULL}; @@ -285,16 +285,16 @@ call_add_device(GDBusProxy *proxy, const char *method, const char *ifname, GErro static NMDevice * add_device_common(NMTstcServiceInfo *sinfo, - NMClient * client, - const char * method, - const char * ifname, - const char * hwaddr, - const char ** subchannels) + NMClient *client, + const char *method, + const char *ifname, + const char *hwaddr, + const char **subchannels) { - nm_auto_unref_gmainloop GMainLoop *loop = NULL; - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; - AddDeviceInfo info; + nm_auto_unref_gmainloop GMainLoop *loop = NULL; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + AddDeviceInfo info; g_assert(sinfo); g_assert(NM_IS_CLIENT(client)); @@ -334,28 +334,28 @@ add_device_common(NMTstcServiceInfo *sinfo, NMDevice * nmtstc_service_add_device(NMTstcServiceInfo *sinfo, - NMClient * client, - const char * method, - const char * ifname) + NMClient *client, + const char *method, + const char *ifname) { return add_device_common(sinfo, client, method, ifname, NULL, NULL); } NMDevice * nmtstc_service_add_wired_device(NMTstcServiceInfo *sinfo, - NMClient * client, - const char * ifname, - const char * hwaddr, - const char ** subchannels) + NMClient *client, + const char *ifname, + const char *hwaddr, + const char **subchannels) { return add_device_common(sinfo, client, "AddWiredDevice", ifname, hwaddr, subchannels); } void nmtstc_service_add_connection(NMTstcServiceInfo *sinfo, - NMConnection * connection, + NMConnection *connection, gboolean verify_connection, - char ** out_path) + char **out_path) { nmtstc_service_add_connection_variant( sinfo, @@ -366,12 +366,12 @@ nmtstc_service_add_connection(NMTstcServiceInfo *sinfo, void nmtstc_service_add_connection_variant(NMTstcServiceInfo *sinfo, - GVariant * connection, + GVariant *connection, gboolean verify_connection, - char ** out_path) + char **out_path) { GVariant *result; - GError * error = NULL; + GError *error = NULL; g_assert(sinfo); g_assert(G_IS_DBUS_PROXY(sinfo->proxy)); @@ -393,8 +393,8 @@ nmtstc_service_add_connection_variant(NMTstcServiceInfo *sinfo, void nmtstc_service_update_connection(NMTstcServiceInfo *sinfo, - const char * path, - NMConnection * connection, + const char *path, + NMConnection *connection, gboolean verify_connection) { if (!path) @@ -410,12 +410,12 @@ nmtstc_service_update_connection(NMTstcServiceInfo *sinfo, void nmtstc_service_update_connection_variant(NMTstcServiceInfo *sinfo, - const char * path, - GVariant * connection, + const char *path, + GVariant *connection, gboolean verify_connection) { GVariant *result; - GError * error = NULL; + GError *error = NULL; g_assert(sinfo); g_assert(G_IS_DBUS_PROXY(sinfo->proxy)); @@ -439,14 +439,14 @@ nmtstc_service_update_connection_variant(NMTstcServiceInfo *sinfo, typedef struct { GType gtype; GMainLoop *loop; - GObject * obj; + GObject *obj; bool call_nm_client_new_async : 1; } NMTstcObjNewData; static void _context_object_new_do_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMTstcObjNewData *d = user_data; + NMTstcObjNewData *d = user_data; gs_free_error GError *error = NULL; g_assert(!d->obj); @@ -472,7 +472,7 @@ _context_object_new_do(GType gtype, va_list var_args) { gs_free_error GError *error = NULL; - GObject * obj; + GObject *obj; /* Create a GObject instance synchronously, and arbitrarily use either * the sync or async constructor. @@ -508,8 +508,8 @@ _context_object_new_do(GType gtype, } else { nm_auto_unref_gmainloop GMainLoop *loop = NULL; NMTstcObjNewData d = { - .gtype = gtype, - .loop = NULL, + .gtype = gtype, + .loop = NULL, }; gs_unref_object GObject *obj2 = NULL; @@ -545,8 +545,8 @@ typedef struct { GType gtype; const char *first_property_name; va_list var_args; - GMainLoop * loop; - GObject * obj; + GMainLoop *loop; + GObject *obj; bool sync; } NewSyncInsideDispatchedData; @@ -570,13 +570,13 @@ _context_object_new_inside_loop(GType gtype, const char *first_property_name, va_list var_args) { - GMainContext * context = g_main_context_get_thread_default(); - nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(context, FALSE); - NewSyncInsideDispatchedData d = { - .gtype = gtype, - .first_property_name = first_property_name, - .sync = sync, - .loop = loop, + GMainContext *context = g_main_context_get_thread_default(); + nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(context, FALSE); + NewSyncInsideDispatchedData d = { + .gtype = gtype, + .first_property_name = first_property_name, + .sync = sync, + .loop = loop, }; nm_auto_destroy_and_unref_gsource GSource *source = NULL; diff --git a/src/libnm-core-aux-extern/nm-libnm-core-aux.c b/src/libnm-core-aux-extern/nm-libnm-core-aux.c index e92c234f81..dfc70e35b4 100644 --- a/src/libnm-core-aux-extern/nm-libnm-core-aux.c +++ b/src/libnm-core-aux-extern/nm-libnm-core-aux.c @@ -27,7 +27,7 @@ typedef struct { } ParseData; typedef struct { - const char * name; + const char *name; NMTeamLinkWatcherType watcher_type; KeyType key_type; union { @@ -65,8 +65,8 @@ _team_link_watcher_send_always(const NMTeamLinkWatcher *watcher) static const TeamLinkWatcherKeyInfo _team_link_watcher_key_infos[_NM_TEAM_LINK_WATCHER_KEY_NUM] = { #define _KEY_INFO(key_id, _name, _watcher_type, _key_type, ...) \ - [key_id] = {.name = ""_name \ - "", \ + [key_id] = {.name = ""_name \ + "", \ .watcher_type = (_watcher_type), \ .key_type = _key_type, \ ##__VA_ARGS__} @@ -189,7 +189,7 @@ char * nm_utils_team_link_watcher_to_string(const NMTeamLinkWatcher *watcher) { nm_auto_free_gstring GString *str = NULL; - const char * name; + const char *name; NMTeamLinkWatcherType watcher_type; NMTeamLinkWatcherKeyId key_id; @@ -205,7 +205,7 @@ nm_utils_team_link_watcher_to_string(const NMTeamLinkWatcher *watcher) for (key_id = 0; key_id < _NM_TEAM_LINK_WATCHER_KEY_NUM; key_id++) { const TeamLinkWatcherKeyInfo *info = &_team_link_watcher_key_infos[key_id]; - const char * vstr; + const char *vstr; int vint; bool vbool; @@ -257,12 +257,12 @@ nm_utils_team_link_watcher_to_string(const NMTeamLinkWatcher *watcher) NMTeamLinkWatcher * nm_utils_team_link_watcher_from_string(const char *str, GError **error) { - gs_free const char ** tokens = NULL; + gs_free const char **tokens = NULL; ParseData parse_data[_NM_TEAM_LINK_WATCHER_KEY_NUM] = {}; NMTeamLinkWatcherType watcher_type; NMTeamLinkWatcherKeyId key_id; gsize i_token; - NMTeamLinkWatcher * watcher; + NMTeamLinkWatcher *watcher; int errsv; g_return_val_if_fail(str, NULL); @@ -276,8 +276,8 @@ nm_utils_team_link_watcher_from_string(const char *str, GError **error) for (i_token = 0; tokens[i_token]; i_token++) { const TeamLinkWatcherKeyInfo *info; - const char * key = tokens[i_token]; - const char * val; + const char *key = tokens[i_token]; + const char *val; val = strchr(key, '='); if (!val) { @@ -413,7 +413,7 @@ nm_utils_team_link_watcher_from_string(const char *str, GError **error) #if NM_MORE_ASSERTS > 5 if (watcher) { - gs_free char * str2 = NULL; + gs_free char *str2 = NULL; nm_auto_unref_team_link_watcher NMTeamLinkWatcher *watcher2 = NULL; static _nm_thread_local int recursive; diff --git a/src/libnm-core-aux-intern/nm-auth-subject.c b/src/libnm-core-aux-intern/nm-auth-subject.c index 536b4e474d..db499b8894 100644 --- a/src/libnm-core-aux-intern/nm-auth-subject.c +++ b/src/libnm-core-aux-intern/nm-auth-subject.c @@ -34,7 +34,7 @@ typedef struct { gulong pid; gulong uid; guint64 start_time; - char * dbus_sender; + char *dbus_sender; } unix_process; struct { @@ -273,7 +273,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps NMAuthSubjectPrivate *priv = NM_AUTH_SUBJECT_GET_PRIVATE(object); NMAuthSubjectType subject_type; int i; - const char * str; + const char *str; gulong id; switch (prop_id) { @@ -348,7 +348,7 @@ nm_auth_subject_init(NMAuthSubject *self) static void constructed(GObject *object) { - NMAuthSubject * self = NM_AUTH_SUBJECT(object); + NMAuthSubject *self = NM_AUTH_SUBJECT(object); NMAuthSubjectPrivate *priv = NM_AUTH_SUBJECT_GET_PRIVATE(self); /* validate that the created instance. */ diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.c b/src/libnm-core-aux-intern/nm-libnm-core-utils.c index e168885947..3751881570 100644 --- a/src/libnm-core-aux-intern/nm-libnm-core-utils.c +++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.c @@ -104,11 +104,11 @@ _nm_setting_bond_mode_to_string(int mode) gboolean nm_utils_vlan_priority_map_parse_str(NMVlanPriorityMap map_type, - const char * str, + const char *str, gboolean allow_wildcard_to, - guint32 * out_from, - guint32 * out_to, - gboolean * out_has_wildcard_to) + guint32 *out_from, + guint32 *out_to, + gboolean *out_has_wildcard_to) { const char *s2; gint64 v1, v2; @@ -216,7 +216,7 @@ _nm_auth_permission_from_string_cmp(gconstpointer a, gconstpointer b, gpointer u { const NMClientPermission *const p = a; const char *const needle = b; - const char * ss = nm_auth_permission_names_by_idx[*p - 1]; + const char *ss = nm_auth_permission_names_by_idx[*p - 1]; nm_assert(NM_STR_HAS_PREFIX(ss, AUTH_PERMISSION_PREFIX)); nm_assert(ss[NM_STRLEN(AUTH_PERMISSION_PREFIX)] != '\0'); @@ -281,7 +281,7 @@ nm_client_permission_result_to_string(NMClientPermissionResult permission) gboolean nm_utils_validate_dhcp4_vendor_class_id(const char *vci, GError **error) { - const char * bin; + const char *bin; gsize unescaped_len; gs_free char *to_free = NULL; diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.h b/src/libnm-core-aux-intern/nm-libnm-core-utils.h index f90e3984c1..eb30c931fa 100644 --- a/src/libnm-core-aux-intern/nm-libnm-core-utils.h +++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.h @@ -93,11 +93,11 @@ nm_utils_vlan_priority_map_get_max_prio(NMVlanPriorityMap map, gboolean from) } gboolean nm_utils_vlan_priority_map_parse_str(NMVlanPriorityMap map_type, - const char * str, + const char *str, gboolean allow_wildcard_to, - guint32 * out_from, - guint32 * out_to, - gboolean * out_has_wildcard_to); + guint32 *out_from, + guint32 *out_to, + gboolean *out_has_wildcard_to); /*****************************************************************************/ @@ -149,13 +149,13 @@ nm_setting_ip_config_get_addr_family(NMSettingIPConfig *s_ip) extern const char *const nm_auth_permission_names_by_idx[NM_CLIENT_PERMISSION_LAST]; extern const NMClientPermission nm_auth_permission_sorted[NM_CLIENT_PERMISSION_LAST]; -const char * nm_auth_permission_to_string(NMClientPermission permission); +const char *nm_auth_permission_to_string(NMClientPermission permission); NMClientPermission nm_auth_permission_from_string(const char *str); /*****************************************************************************/ NMClientPermissionResult nm_client_permission_result_from_string(const char *nm); -const char * nm_client_permission_result_to_string(NMClientPermissionResult permission); +const char *nm_client_permission_result_to_string(NMClientPermissionResult permission); gboolean nm_utils_validate_dhcp4_vendor_class_id(const char *vci, GError **error); diff --git a/src/libnm-core-impl/nm-connection-private.h b/src/libnm-core-impl/nm-connection-private.h index 27769ec14e..08abb9a495 100644 --- a/src/libnm-core-impl/nm-connection-private.h +++ b/src/libnm-core-impl/nm-connection-private.h @@ -18,12 +18,12 @@ NMSetting *_nm_connection_find_base_type_setting(NMConnection *connection); const char *_nm_connection_detect_slave_type(NMConnection *connection, NMSetting **out_s_port); gboolean _nm_connection_detect_slave_type_full(NMSettingConnection *s_con, - NMConnection * connection, - const char ** out_slave_type, - const char ** out_normerr_slave_setting_type, - const char ** out_normerr_missing_slave_type, + NMConnection *connection, + const char **out_slave_type, + const char **out_normerr_slave_setting_type, + const char **out_normerr_missing_slave_type, const char **out_normerr_missing_slave_type_port, - GError ** error); + GError **error); const char *_nm_connection_detect_bluetooth_type(NMConnection *self); @@ -32,11 +32,11 @@ gboolean _nm_setting_connection_verify_secondaries(GArray *secondaries, GError * gboolean _nm_connection_verify_required_interface_name(NMConnection *connection, GError **error); int _nm_setting_ovs_interface_verify_interface_type(NMSettingOvsInterface *self, - const char * type, - NMConnection * connection, + const char *type, + NMConnection *connection, gboolean normalize, - gboolean * out_modified, - const char ** out_normalized_type, - GError ** error); + gboolean *out_modified, + const char **out_normalized_type, + GError **error); #endif /* __NM_CONNECTION_PRIVATE_H__ */ diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c index dc85ea0c03..a9b130a792 100644 --- a/src/libnm-core-impl/nm-connection.c +++ b/src/libnm-core-impl/nm-connection.c @@ -126,7 +126,7 @@ _nm_connection_get_private_from_qdata(NMConnection *connection) #define NM_CONNECTION_GET_PRIVATE(connection) \ ({ \ - NMConnection * _connection = (connection); \ + NMConnection *_connection = (connection); \ NMConnectionPrivate *_priv; \ \ if (G_LIKELY(NM_IS_SIMPLE_CONNECTION(_connection))) \ @@ -215,8 +215,8 @@ static void _nm_connection_add_setting(NMConnection *connection, NMSetting *setting) { const NMMetaSettingInfo *setting_info; - NMConnectionPrivate * priv; - NMSetting * s_old; + NMConnectionPrivate *priv; + NMSetting *s_old; nm_assert(NM_IS_CONNECTION(connection)); nm_assert(NM_IS_SETTING(setting)); @@ -264,8 +264,8 @@ nm_connection_add_setting(NMConnection *connection, NMSetting *setting) gboolean _nm_connection_remove_setting(NMConnection *connection, GType setting_type) { - NMConnectionPrivate * priv; - NMSetting * setting; + NMConnectionPrivate *priv; + NMSetting *setting; const NMMetaSettingInfo *setting_info; g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE); @@ -302,7 +302,7 @@ nm_connection_remove_setting(NMConnection *connection, GType setting_type) static gpointer _connection_get_setting(NMConnection *connection, GType setting_type) { - NMSetting * setting; + NMSetting *setting; const NMMetaSettingInfo *setting_info; nm_assert(NM_IS_CONNECTION(connection)); @@ -399,8 +399,8 @@ nm_connection_get_setting_by_name(NMConnection *connection, const char *name) gpointer /* (NMSetting *) */ _nm_connection_check_main_setting(NMConnection *connection, - const char * setting_name, - GError ** error) + const char *setting_name, + GError **error) { NMSetting *setting; @@ -498,16 +498,16 @@ _auto_settings(NMSetting ***p_settings) * are lost. **/ gboolean -_nm_connection_replace_settings(NMConnection * connection, - GVariant * new_settings, +_nm_connection_replace_settings(NMConnection *connection, + GVariant *new_settings, NMSettingParseFlags parse_flags, - GError ** error) + GError **error) { - NMSetting * settings[_NM_META_SETTING_TYPE_NUM] = {}; + NMSetting *settings[_NM_META_SETTING_TYPE_NUM] = {}; nm_auto(_auto_settings) NMSetting **settings_cleanup = settings; GVariantIter iter; - const char * setting_name; - GVariant * setting_dict; + const char *setting_name; + GVariant *setting_dict; gboolean changed; gboolean success; guint n_settings = 0; @@ -528,9 +528,9 @@ _nm_connection_replace_settings(NMConnection * connection, g_variant_iter_init(&iter, new_settings); while (g_variant_iter_next(&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) { gs_unref_variant GVariant *setting_dict_free = NULL; - GError * local = NULL; - NMSetting * setting; - const NMMetaSettingInfo * setting_info; + GError *local = NULL; + NMSetting *setting; + const NMMetaSettingInfo *setting_info; setting_dict_free = setting_dict; @@ -748,11 +748,11 @@ nm_connection_compare(NMConnection *a, NMConnection *b, NMSettingCompareFlags fl } static gboolean -diff_one_connection(NMConnection * a, - NMConnection * b, +diff_one_connection(NMConnection *a, + NMConnection *b, NMSettingCompareFlags flags, gboolean invert_results, - GHashTable * diffs) + GHashTable *diffs) { NMConnectionPrivate *a_priv = NM_CONNECTION_GET_PRIVATE(a); NMConnectionPrivate *b_priv = b ? NM_CONNECTION_GET_PRIVATE(b) : NULL; @@ -763,7 +763,7 @@ diff_one_connection(NMConnection * a, NMSetting *a_setting = a_priv->settings[i]; if (a_setting) { - NMSetting * b_setting = b ? b_priv->settings[i] : NULL; + NMSetting *b_setting = b ? b_priv->settings[i] : NULL; const char *setting_name = nm_setting_get_name(a_setting); GHashTable *results; gboolean new_results = TRUE; @@ -803,10 +803,10 @@ diff_one_connection(NMConnection * a, * not **/ gboolean -nm_connection_diff(NMConnection * a, - NMConnection * b, +nm_connection_diff(NMConnection *a, + NMConnection *b, NMSettingCompareFlags flags, - GHashTable ** out_settings) + GHashTable **out_settings) { GHashTable *diffs; gboolean diff_found = FALSE; @@ -845,12 +845,12 @@ NMSetting * _nm_connection_find_base_type_setting(NMConnection *connection) { NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE(connection); - NMSetting * setting = NULL; + NMSetting *setting = NULL; NMSettingPriority setting_prio = NM_SETTING_PRIORITY_USER; int i; for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) { - NMSetting * s_iter = priv->settings[i]; + NMSetting *s_iter = priv->settings[i]; NMSettingPriority s_iter_prio; if (!s_iter) @@ -865,7 +865,7 @@ _nm_connection_find_base_type_setting(NMConnection *connection) continue; } else if (s_iter_prio == setting_prio) { NMSettingConnection *s_con = nm_connection_get_setting_connection(connection); - const char * type; + const char *type; if (s_con) { type = nm_setting_connection_get_connection_type(s_con); @@ -886,7 +886,7 @@ _normalize_connection_uuid(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); char uuid_normalized[37]; - const char * uuid; + const char *uuid; nm_assert(s_con); @@ -942,7 +942,7 @@ _nm_setting_connection_verify_secondaries(GArray *secondaries, GError **error) if (len > 1) { gs_free const char **strv_to_free = NULL; - const char ** strv2; + const char **strv2; strv2 = nm_strv_dup_shallow_maybe_a(20, strv, len, &strv_to_free); nm_strv_sort(strv2, len); @@ -979,8 +979,8 @@ static gboolean _normalize_connection_secondaries(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); - GArray * secondaries; - gs_strfreev char ** strv = NULL; + GArray *secondaries; + gs_strfreev char **strv = NULL; guint i; guint j; @@ -1017,8 +1017,8 @@ static gboolean _normalize_connection_type(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); - NMSetting * s_base = NULL; - const char * type; + NMSetting *s_base = NULL; + const char *type; type = nm_setting_connection_get_connection_type(s_con); @@ -1066,12 +1066,12 @@ const char * _nm_connection_detect_slave_type(NMConnection *connection, NMSetting **out_s_port) { NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE(connection); - const char * slave_type = NULL; - NMSetting * s_port = NULL; + const char *slave_type = NULL; + NMSetting *s_port = NULL; int i; static const struct { NMMetaSettingType meta_type; - const char * controller_type_name; + const char *controller_type_name; } infos[] = { {NM_META_SETTING_TYPE_BRIDGE_PORT, NM_SETTING_BRIDGE_SETTING_NAME}, {NM_META_SETTING_TYPE_BOND_PORT, NM_SETTING_BOND_SETTING_NAME}, @@ -1105,7 +1105,7 @@ static gboolean _normalize_connection_slave_type(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); - const char * slave_type, *port_type; + const char *slave_type, *port_type; if (!s_con) return FALSE; @@ -1177,7 +1177,7 @@ _normalize_ethernet_link_neg(NMConnection *self) static gboolean _supports_addr_family(NMConnection *self, int family) { - const char * connection_type = nm_connection_get_connection_type(self); + const char *connection_type = nm_connection_get_connection_type(self); NMSettingConnection *s_con; g_return_val_if_fail(connection_type, TRUE); @@ -1198,8 +1198,8 @@ static gboolean _normalize_ip_config(NMConnection *self, GHashTable *parameters) { NMSettingIPConfig *s_ip4, *s_ip6; - NMSettingProxy * s_proxy; - NMSetting * setting; + NMSettingProxy *s_proxy; + NMSetting *setting; gboolean changed = FALSE; guint num, i; @@ -1397,7 +1397,7 @@ _normalize_bond_options(NMConnection *self) { NMSettingBond *s_bond = nm_connection_get_setting_bond(self); gboolean changed = FALSE; - const char * name, *mode_str; + const char *name, *mode_str; NMBondMode mode; guint32 num, i; @@ -1425,8 +1425,8 @@ again: static gboolean _normalize_wireless_mac_address_randomization(NMConnection *self) { - NMSettingWireless * s_wifi = nm_connection_get_setting_wireless(self); - const char * cloned_mac_address; + NMSettingWireless *s_wifi = nm_connection_get_setting_wireless(self); + const char *cloned_mac_address; NMSettingMacRandomization mac_address_randomization; if (!s_wifi) @@ -1645,7 +1645,7 @@ static gboolean _normalize_required_settings(NMConnection *self) { NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth(self); - NMSetting * s_bridge; + NMSetting *s_bridge; gboolean changed = FALSE; if (nm_connection_get_setting_vlan(self)) { @@ -1671,7 +1671,7 @@ static gboolean _normalize_invalid_slave_port_settings(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); - const char * slave_type; + const char *slave_type; gboolean changed = FALSE; slave_type = nm_setting_connection_get_slave_type(s_con); @@ -1725,10 +1725,10 @@ nm_connection_verify(NMConnection *connection, GError **error) NMSettingVerifyResult _nm_connection_verify(NMConnection *connection, GError **error) { - NMConnectionPrivate *priv; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingProxy * s_proxy; + NMConnectionPrivate *priv; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingProxy *s_proxy; gs_free_error GError *normalizable_error = NULL; NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS; int i; @@ -1748,8 +1748,8 @@ _nm_connection_verify(NMConnection *connection, GError **error) } for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) { - NMSetting * setting = priv->settings[nm_meta_setting_types_by_priority[i]]; - GError * verify_error = NULL; + NMSetting *setting = priv->settings[nm_meta_setting_types_by_priority[i]]; + GError *verify_error = NULL; NMSettingVerifyResult verify_result; if (!setting) @@ -1909,9 +1909,9 @@ nm_connection_verify_secrets(NMConnection *connection, GError **error) static gboolean _connection_normalize(NMConnection *connection, - GHashTable * parameters, - gboolean * modified, - GError ** error) + GHashTable *parameters, + gboolean *modified, + GError **error) { NMSettingVerifyResult success; gboolean was_modified; @@ -2006,9 +2006,9 @@ _connection_normalize(NMConnection *connection, **/ gboolean nm_connection_normalize(NMConnection *connection, - GHashTable * parameters, - gboolean * modified, - GError ** error) + GHashTable *parameters, + gboolean *modified, + GError **error) { NMSettingVerifyResult success; gs_free_error GError *normalizable_error = NULL; @@ -2044,16 +2044,16 @@ nm_connection_normalize(NMConnection *connection, } gboolean -_nm_connection_ensure_normalized(NMConnection * connection, +_nm_connection_ensure_normalized(NMConnection *connection, gboolean allow_modify, - const char * expected_uuid, + const char *expected_uuid, gboolean coerce_uuid, NMConnection **out_connection_clone, - GError ** error) + GError **error) { gs_unref_object NMConnection *connection_clone = NULL; - gs_free_error GError *local = NULL; - NMSettingVerifyResult vresult; + gs_free_error GError *local = NULL; + NMSettingVerifyResult vresult; nm_assert(NM_IS_CONNECTION(connection)); nm_assert(!out_connection_clone || !*out_connection_clone); @@ -2122,7 +2122,7 @@ _nm_assert_connection_unchanging_changed_cb(NMConnection *connection, gpointer u static void _nm_assert_connection_unchanging_secrets_updated_cb(NMConnection *connection, - const char * setting_name, + const char *setting_name, gpointer user_data) { nm_assert_not_reached(); @@ -2187,16 +2187,16 @@ nm_assert_connection_unchanging(NMConnection *connection) **/ gboolean nm_connection_update_secrets(NMConnection *connection, - const char * setting_name, - GVariant * secrets, - GError ** error) + const char *setting_name, + GVariant *secrets, + GError **error) { - NMSetting * setting; + NMSetting *setting; gboolean success = TRUE; gboolean updated = FALSE; - GVariant * setting_dict = NULL; + GVariant *setting_dict = NULL; GVariantIter iter; - const char * key; + const char *key; gboolean full_connection; int success_detail; @@ -2320,7 +2320,7 @@ nm_connection_update_secrets(NMConnection *connection, const char * nm_connection_need_secrets(NMConnection *connection, GPtrArray **hints) { - NMSetting * setting_before = NULL; + NMSetting *setting_before = NULL; NMConnectionPrivate *priv; int i; @@ -2380,7 +2380,7 @@ nm_connection_clear_secrets(NMConnection *connection) * Clears and frees secrets determined by @func. **/ void -nm_connection_clear_secrets_with_flags(NMConnection * connection, +nm_connection_clear_secrets_with_flags(NMConnection *connection, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { @@ -2406,8 +2406,8 @@ nm_connection_clear_secrets_with_flags(NMConnection * connecti } static gboolean -_clear_secrets_by_secret_flags_cb(NMSetting * setting, - const char * secret, +_clear_secrets_by_secret_flags_cb(NMSetting *setting, + const char *secret, NMSettingSecretFlags flags, gpointer user_data) { @@ -2454,8 +2454,8 @@ _nm_connection_clear_secrets_by_secret_flags(NMConnection *self, NMSettingSecret /* Returns always a non-NULL, floating variant that must * be unrefed by the caller. */ GVariant * -_nm_connection_for_each_secret(NMConnection * self, - GVariant * secrets, +_nm_connection_for_each_secret(NMConnection *self, + GVariant *secrets, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data) @@ -2463,8 +2463,8 @@ _nm_connection_for_each_secret(NMConnection * self, GVariantBuilder secrets_builder; GVariantBuilder setting_builder; GVariantIter secrets_iter; - GVariantIter * setting_iter; - const char * setting_name; + GVariantIter *setting_iter; + const char *setting_name; /* This function, given a dict of dicts representing new secrets of * an NMConnection, walks through each toplevel dict (which represents a @@ -2486,9 +2486,9 @@ _nm_connection_for_each_secret(NMConnection * self, g_variant_builder_init(&secrets_builder, NM_VARIANT_TYPE_CONNECTION); while (g_variant_iter_next(&secrets_iter, "{&sa{sv}}", &setting_name, &setting_iter)) { _nm_unused nm_auto_free_variant_iter GVariantIter *setting_iter_free = setting_iter; - NMSetting * setting; - const char * secret_name; - GVariant * val; + NMSetting *setting; + const char *secret_name; + GVariant *val; setting = nm_connection_get_setting_by_name(self, setting_name); if (!setting) @@ -2532,16 +2532,16 @@ find_secret_for_each_func(NMSettingSecretFlags flags, gpointer user_data) } gboolean -_nm_connection_find_secret(NMConnection * self, - GVariant * secrets, +_nm_connection_find_secret(NMConnection *self, + GVariant *secrets, NMConnectionFindSecretFunc callback, gpointer callback_data) { gs_unref_variant GVariant *dummy = NULL; FindSecretData data = { - .find_func = callback, - .find_func_data = callback_data, - .found = FALSE, + .find_func = callback, + .find_func_data = callback_data, + .found = FALSE, }; dummy = _nm_connection_for_each_secret(self, secrets, FALSE, find_secret_for_each_func, &data); @@ -2600,7 +2600,7 @@ nm_connection_to_dbus(NMConnection *connection, NMConnectionSerializationFlags f } GVariant * -nm_connection_to_dbus_full(NMConnection * connection, +nm_connection_to_dbus_full(NMConnection *connection, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options) { @@ -2618,7 +2618,7 @@ nm_connection_to_dbus_full(NMConnection * connection, for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) { NMSetting *setting = priv->settings[nm_meta_setting_types_by_priority[i]]; - GVariant * setting_dict; + GVariant *setting_dict; if (!setting) continue; @@ -2702,7 +2702,7 @@ NMSetting ** nm_connection_get_settings(NMConnection *connection, guint *out_length) { NMConnectionPrivate *priv; - NMSetting ** arr; + NMSetting **arr; int len; int i; int j; @@ -2746,7 +2746,7 @@ nm_connection_get_settings(NMConnection *connection, guint *out_length) * calling the supplied user function for each property. **/ void -nm_connection_for_each_setting_value(NMConnection * connection, +nm_connection_for_each_setting_value(NMConnection *connection, NMSettingValueIterFn func, gpointer user_data) { @@ -2931,7 +2931,7 @@ nm_connection_get_interface_name(NMConnection *connection) NMConnectionMultiConnect _nm_connection_get_multi_connect(NMConnection *connection) { - NMSettingConnection * s_con; + NMSettingConnection *s_con; NMConnectionMultiConnect multi_connect; const NMConnectionMultiConnect DEFAULT = NM_CONNECTION_MULTI_CONNECT_SINGLE; diff --git a/src/libnm-core-impl/nm-crypto-gnutls.c b/src/libnm-core-impl/nm-crypto-gnutls.c index 88b123ad5a..d9e5913645 100644 --- a/src/libnm-core-impl/nm-crypto-gnutls.c +++ b/src/libnm-core-impl/nm-crypto-gnutls.c @@ -68,14 +68,14 @@ _nm_crypto_init(GError **error) guint8 * _nmtst_crypto_decrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error) + gsize *out_len, + GError **error) { gnutls_cipher_hd_t ctx; gnutls_datum_t key_dt, iv_dt; @@ -168,14 +168,14 @@ _nmtst_crypto_decrypt(NMCryptoCipherType cipher, guint8 * _nmtst_crypto_encrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error) + gsize *out_len, + GError **error) { gnutls_cipher_hd_t ctx; gnutls_datum_t key_dt, iv_dt; @@ -350,8 +350,8 @@ gboolean _nm_crypto_verify_pkcs8(const guint8 *data, gsize data_len, gboolean is_encrypted, - const char * password, - GError ** error) + const char *password, + GError **error) { gnutls_x509_privkey_t p8; gnutls_datum_t dt; diff --git a/src/libnm-core-impl/nm-crypto-impl.h b/src/libnm-core-impl/nm-crypto-impl.h index 0fd8f194d4..61c3f7f8e2 100644 --- a/src/libnm-core-impl/nm-crypto-impl.h +++ b/src/libnm-core-impl/nm-crypto-impl.h @@ -21,29 +21,29 @@ _nm_crypto_verify_pkcs12(const guint8 *data, gsize data_len, const char *passwor gboolean _nm_crypto_verify_pkcs8(const guint8 *data, gsize data_len, gboolean is_encrypted, - const char * password, - GError ** error); + const char *password, + GError **error); /*****************************************************************************/ guint8 *_nmtst_crypto_encrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error); + gsize *out_len, + GError **error); guint8 *_nmtst_crypto_decrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error); + gsize *out_len, + GError **error); #endif /* __NM_CRYPTO_IMPL_H__ */ diff --git a/src/libnm-core-impl/nm-crypto-nss.c b/src/libnm-core-impl/nm-crypto-nss.c index e59a11b9a3..c27bf09e35 100644 --- a/src/libnm-core-impl/nm-crypto-nss.c +++ b/src/libnm-core-impl/nm-crypto-nss.c @@ -28,7 +28,7 @@ NM_PRAGMA_WARNING_REENABLE static gboolean _get_cipher_info(NMCryptoCipherType cipher, CK_MECHANISM_TYPE *out_cipher_mech, - guint8 * out_real_iv_len) + guint8 *out_real_iv_len) { static const CK_MECHANISM_TYPE cipher_mechs[] = { [NM_CRYPTO_CIPHER_DES_EDE3_CBC] = CKM_DES3_CBC_PAD, @@ -87,21 +87,21 @@ _nm_crypto_init(GError **error) guint8 * _nmtst_crypto_decrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error) + gsize *out_len, + GError **error) { CK_MECHANISM_TYPE cipher_mech; - PK11SlotInfo * slot = NULL; + PK11SlotInfo *slot = NULL; SECItem key_item; - PK11SymKey * sym_key = NULL; - SECItem * sec_param = NULL; - PK11Context * ctx = NULL; + PK11SymKey *sym_key = NULL; + SECItem *sec_param = NULL; + PK11Context *ctx = NULL; nm_auto_clear_secret_ptr NMSecretPtr output = {0}; SECStatus s; gboolean success = FALSE; @@ -258,23 +258,23 @@ out: guint8 * _nmtst_crypto_encrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error) + gsize *out_len, + GError **error) { SECStatus ret; CK_MECHANISM_TYPE cipher_mech = CKM_DES3_CBC_PAD; - PK11SlotInfo * slot = NULL; + PK11SlotInfo *slot = NULL; SECItem key_item = {.data = (unsigned char *) key, .len = key_len}; SECItem iv_item = {.data = (unsigned char *) iv, .len = iv_len}; - PK11SymKey * sym_key = NULL; - SECItem * sec_param = NULL; - PK11Context * ctx = NULL; + PK11SymKey *sym_key = NULL; + SECItem *sec_param = NULL; + PK11Context *ctx = NULL; nm_auto_clear_secret_ptr NMSecretPtr padded_buf = {0}; nm_auto_clear_secret_ptr NMSecretPtr output = {0}; int encrypted_len = 0, i; @@ -409,7 +409,7 @@ _nm_crypto_verify_pkcs12(const guint8 *data, gsize data_len, const char *passwor { SEC_PKCS12DecoderContext *p12ctx = NULL; SECItem pw = {0}; - PK11SlotInfo * slot = NULL; + PK11SlotInfo *slot = NULL; SECStatus s; gboolean success = FALSE; @@ -513,8 +513,8 @@ gboolean _nm_crypto_verify_pkcs8(const guint8 *data, gsize data_len, gboolean is_encrypted, - const char * password, - GError ** error) + const char *password, + GError **error) { g_return_val_if_fail(data != NULL, FALSE); diff --git a/src/libnm-core-impl/nm-crypto.c b/src/libnm-core-impl/nm-crypto.c index ea17449f26..78f793bd0b 100644 --- a/src/libnm-core-impl/nm-crypto.c +++ b/src/libnm-core-impl/nm-crypto.c @@ -44,9 +44,9 @@ static const NMCryptoCipherInfo cipher_infos[] = { #define _CI(_cipher, _name, _digest_len, _real_iv_len) \ - [(_cipher) -1] = {.cipher = _cipher, \ - .name = ""_name \ - "", \ + [(_cipher) -1] = {.cipher = _cipher, \ + .name = ""_name \ + "", \ .digest_len = _digest_len, \ .real_iv_len = _real_iv_len} _CI(NM_CRYPTO_CIPHER_DES_EDE3_CBC, "DES-EDE3-CBC", 24, 8), @@ -166,26 +166,26 @@ _extract_line(const guint8 **p, const guint8 *p_end) } static gboolean -parse_old_openssl_key_file(const guint8 * data, +parse_old_openssl_key_file(const guint8 *data, gsize data_len, - NMSecretPtr * out_parsed, - NMCryptoKeyType * out_key_type, + NMSecretPtr *out_parsed, + NMCryptoKeyType *out_key_type, NMCryptoCipherType *out_cipher, - char ** out_iv, - GError ** error) + char **out_iv, + GError **error) { gsize start = 0, end = 0; - nm_auto_free_secret char * str = NULL; - char * str_p; + nm_auto_free_secret char *str = NULL; + char *str_p; gsize str_len; int enc_tags = 0; NMCryptoKeyType key_type; nm_auto_clear_secret_ptr NMSecretPtr parsed = {0}; - nm_auto_free_secret char * iv = NULL; + nm_auto_free_secret char *iv = NULL; NMCryptoCipherType cipher = NM_CRYPTO_CIPHER_UNKNOWN; - const char * start_tag; - const char * end_tag; - const guint8 * data_start, *data_end; + const char *start_tag; + const char *end_tag; + const guint8 *data_start, *data_end; nm_assert(!out_parsed || (out_parsed->len == 0 && !out_parsed->bin)); nm_assert(!out_iv || !*out_iv); @@ -229,7 +229,7 @@ parse_old_openssl_key_file(const guint8 * data, while (data_start < data_end) { nm_auto_free_secret char *line = NULL; - char * p; + char *p; line = _extract_line(&data_start, data_end); if (!line) @@ -257,7 +257,7 @@ parse_old_openssl_key_file(const guint8 * data, } } else if (!strncmp(p, DEK_INFO_TAG, strlen(DEK_INFO_TAG))) { const NMCryptoCipherInfo *cipher_info; - char * comma; + char *comma; gsize p_len; if (enc_tags++ != 1 || str_p != str) { @@ -335,12 +335,12 @@ parse_old_openssl_key_file(const guint8 * data, static gboolean parse_pkcs8_key_file(const guint8 *data, gsize data_len, - NMSecretPtr * parsed, - gboolean * out_encrypted, - GError ** error) + NMSecretPtr *parsed, + gboolean *out_encrypted, + GError **error) { gsize start = 0, end = 0; - const char * start_tag = NULL, *end_tag = NULL; + const char *start_tag = NULL, *end_tag = NULL; gboolean encrypted = FALSE; nm_auto_free_secret char *der_base64 = NULL; @@ -396,8 +396,8 @@ parse_pkcs8_key_file(const guint8 *data, static gboolean parse_tpm2_wrapped_key_file(const guint8 *data, gsize data_len, - gboolean * out_encrypted, - GError ** error) + gboolean *out_encrypted, + GError **error) { gsize start = 0, end = 0; const char *start_tag = NULL, *end_tag = NULL; @@ -467,7 +467,7 @@ nm_crypto_read_file(const char *filename, GError **error) static guint8 * _nmtst_convert_iv(const char *src, gsize *out_len, GError **error) { - gsize i, num; + gsize i, num; gs_free guint8 *c = NULL; int c0, c1; @@ -508,13 +508,13 @@ _nmtst_convert_iv(const char *src, gsize *out_len, GError **error) guint8 * nmtst_crypto_make_des_aes_key(NMCryptoCipherType cipher, - const guint8 * salt, + const guint8 *salt, gsize salt_len, - const char * password, - gsize * out_len, - GError ** error) + const char *password, + gsize *out_len, + GError **error) { - guint8 * key; + guint8 *key; const NMCryptoCipherInfo *cipher_info; g_return_val_if_fail(salt != NULL, NULL); @@ -546,12 +546,12 @@ nmtst_crypto_make_des_aes_key(NMCryptoCipherType cipher, static gboolean _nmtst_decrypt_key(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const char * iv, - const char * password, - NMSecretPtr * parsed, - GError ** error) + const char *iv, + const char *password, + NMSecretPtr *parsed, + GError **error) { nm_auto_clear_secret_ptr NMSecretPtr bin_iv = {0}; nm_auto_clear_secret_ptr NMSecretPtr key = {0}; @@ -599,15 +599,15 @@ _nmtst_decrypt_key(NMCryptoCipherType cipher, } GBytes * -nmtst_crypto_decrypt_openssl_private_key_data(const guint8 * data, +nmtst_crypto_decrypt_openssl_private_key_data(const guint8 *data, gsize data_len, - const char * password, + const char *password, NMCryptoKeyType *out_key_type, - GError ** error) + GError **error) { NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; nm_auto_clear_secret_ptr NMSecretPtr parsed = {0}; - nm_auto_free_secret char * iv = NULL; + nm_auto_free_secret char *iv = NULL; NMCryptoCipherType cipher = NM_CRYPTO_CIPHER_UNKNOWN; g_return_val_if_fail(data != NULL, NULL); @@ -651,10 +651,10 @@ nmtst_crypto_decrypt_openssl_private_key_data(const guint8 * data, } GBytes * -nmtst_crypto_decrypt_openssl_private_key(const char * file, - const char * password, +nmtst_crypto_decrypt_openssl_private_key(const char *file, + const char *password, NMCryptoKeyType *out_key_type, - GError ** error) + GError **error) { nm_auto_clear_secret_ptr NMSecretPtr contents = {0}; @@ -674,8 +674,8 @@ nmtst_crypto_decrypt_openssl_private_key(const char * file, static gboolean extract_pem_cert_data(const guint8 *contents, gsize contents_len, - NMSecretPtr * out_cert, - GError ** error) + NMSecretPtr *out_cert, + GError **error) { gsize start = 0; gsize end = 0; @@ -722,10 +722,10 @@ extract_pem_cert_data(const guint8 *contents, } gboolean -nm_crypto_load_and_verify_certificate(const char * file, +nm_crypto_load_and_verify_certificate(const char *file, NMCryptoFileFormat *out_file_format, - GBytes ** out_certificate, - GError ** error) + GBytes **out_certificate, + GError **error) { nm_auto_clear_secret_ptr NMSecretPtr contents = {0}; @@ -786,7 +786,7 @@ out: gboolean nm_crypto_is_pkcs12_data(const guint8 *data, gsize data_len, GError **error) { - GError * local = NULL; + GError *local = NULL; gboolean success; if (!data_len) { @@ -838,9 +838,9 @@ nm_crypto_is_pkcs12_file(const char *file, GError **error) NMCryptoFileFormat nm_crypto_verify_private_key_data(const guint8 *data, gsize data_len, - const char * password, - gboolean * out_is_encrypted, - GError ** error) + const char *password, + gboolean *out_is_encrypted, + GError **error) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gboolean is_encrypted = FALSE; @@ -894,8 +894,8 @@ nm_crypto_verify_private_key_data(const guint8 *data, NMCryptoFileFormat nm_crypto_verify_private_key(const char *filename, const char *password, - gboolean * out_is_encrypted, - GError ** error) + gboolean *out_is_encrypted, + GError **error) { nm_auto_clear_secret_ptr NMSecretPtr contents = {0}; @@ -939,21 +939,21 @@ nm_crypto_randomize(void *buffer, gsize buffer_len, GError **error) GBytes * nmtst_crypto_rsa_key_encrypt(const guint8 *data, gsize len, - const char * in_password, - char ** out_password, - GError ** error) + const char *in_password, + char **out_password, + GError **error) { guint8 salt[8]; - nm_auto_clear_secret_ptr NMSecretPtr key = {0}; - nm_auto_clear_secret_ptr NMSecretPtr enc = {0}; - gs_unref_ptrarray GPtrArray *pem = NULL; - nm_auto_free_secret char * tmp_password = NULL; - nm_auto_free_secret char * enc_base64 = NULL; - gsize enc_base64_len; - const char * p; - gsize ret_len, ret_idx; - guint i; - NMSecretBuf * ret; + nm_auto_clear_secret_ptr NMSecretPtr key = {0}; + nm_auto_clear_secret_ptr NMSecretPtr enc = {0}; + gs_unref_ptrarray GPtrArray *pem = NULL; + nm_auto_free_secret char *tmp_password = NULL; + nm_auto_free_secret char *enc_base64 = NULL; + gsize enc_base64_len; + const char *p; + gsize ret_len, ret_idx; + guint i; + NMSecretBuf *ret; g_return_val_if_fail(data, NULL); g_return_val_if_fail(len > 0, NULL); diff --git a/src/libnm-core-impl/nm-crypto.h b/src/libnm-core-impl/nm-crypto.h index 855e4f9c68..a740c43c5b 100644 --- a/src/libnm-core-impl/nm-crypto.h +++ b/src/libnm-core-impl/nm-crypto.h @@ -17,7 +17,7 @@ typedef enum { } NMCryptoCipherType; typedef struct { - const char * name; + const char *name; NMCryptoCipherType cipher; guint8 digest_len; guint8 real_iv_len; @@ -43,10 +43,10 @@ typedef enum { GBytes *nm_crypto_read_file(const char *filename, GError **error); -gboolean nm_crypto_load_and_verify_certificate(const char * file, +gboolean nm_crypto_load_and_verify_certificate(const char *file, NMCryptoFileFormat *out_file_format, - GBytes ** out_certificat, - GError ** error); + GBytes **out_certificat, + GError **error); gboolean nm_crypto_is_pkcs12_file(const char *file, GError **error); @@ -54,42 +54,42 @@ gboolean nm_crypto_is_pkcs12_data(const guint8 *data, gsize len, GError **error) NMCryptoFileFormat nm_crypto_verify_private_key_data(const guint8 *data, gsize data_len, - const char * password, - gboolean * out_is_encrypted, - GError ** error); + const char *password, + gboolean *out_is_encrypted, + GError **error); NMCryptoFileFormat nm_crypto_verify_private_key(const char *file, const char *password, - gboolean * out_is_encrypted, - GError ** error); + gboolean *out_is_encrypted, + GError **error); gboolean nm_crypto_randomize(void *buffer, gsize buffer_len, GError **error); /*****************************************************************************/ -GBytes *nmtst_crypto_decrypt_openssl_private_key_data(const guint8 * data, +GBytes *nmtst_crypto_decrypt_openssl_private_key_data(const guint8 *data, gsize data_len, - const char * password, + const char *password, NMCryptoKeyType *out_key_type, - GError ** error); + GError **error); -GBytes *nmtst_crypto_decrypt_openssl_private_key(const char * file, - const char * password, +GBytes *nmtst_crypto_decrypt_openssl_private_key(const char *file, + const char *password, NMCryptoKeyType *out_key_type, - GError ** error); + GError **error); GBytes *nmtst_crypto_rsa_key_encrypt(const guint8 *data, gsize len, - const char * in_password, - char ** out_password, - GError ** error); + const char *in_password, + char **out_password, + GError **error); guint8 *nmtst_crypto_make_des_aes_key(NMCryptoCipherType cipher, - const guint8 * salt, + const guint8 *salt, gsize salt_len, - const char * password, - gsize * out_len, - GError ** error); + const char *password, + gsize *out_len, + GError **error); /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-dbus-utils.c b/src/libnm-core-impl/nm-dbus-utils.c index a272f08ce9..c9443ff944 100644 --- a/src/libnm-core-impl/nm-dbus-utils.c +++ b/src/libnm-core-impl/nm-dbus-utils.c @@ -8,7 +8,7 @@ #include "libnm-core-intern/nm-core-internal.h" typedef struct { - char * signal_name; + char *signal_name; const GVariantType *signature; } NMDBusSignalData; @@ -22,17 +22,17 @@ dbus_signal_data_free(gpointer data, GClosure *closure) } static void -dbus_signal_meta_marshal(GClosure * closure, - GValue * return_value, +dbus_signal_meta_marshal(GClosure *closure, + GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data) { NMDBusSignalData *sd = marshal_data; - const char * signal_name; - GVariant * parameters, *param; - GValue * closure_params; + const char *signal_name; + GVariant *parameters, *param; + GValue *closure_params; gsize n_params, i; g_return_if_fail(n_param_values == 4); @@ -110,8 +110,8 @@ dbus_signal_meta_marshal(GClosure * closure, * g_signal_handlers_disconnect_by_data() will work correctly. */ gulong -_nm_dbus_signal_connect_data(GDBusProxy * proxy, - const char * signal_name, +_nm_dbus_signal_connect_data(GDBusProxy *proxy, + const char *signal_name, const GVariantType *signature, GCallback c_handler, gpointer data, @@ -119,7 +119,7 @@ _nm_dbus_signal_connect_data(GDBusProxy * proxy, GConnectFlags connect_flags) { NMDBusSignalData *sd; - GClosure * closure; + GClosure *closure; gboolean swapped = !!(connect_flags & G_CONNECT_SWAPPED); gboolean after = !!(connect_flags & G_CONNECT_AFTER); @@ -201,10 +201,10 @@ _nm_dbus_typecheck_response(GVariant *response, const GVariantType *reply_type, * return values. Free with g_variant_unref(). */ GVariant * -_nm_dbus_proxy_call_finish(GDBusProxy * proxy, - GAsyncResult * res, +_nm_dbus_proxy_call_finish(GDBusProxy *proxy, + GAsyncResult *res, const GVariantType *reply_type, - GError ** error) + GError **error) { GVariant *variant; @@ -215,10 +215,10 @@ _nm_dbus_proxy_call_finish(GDBusProxy * proxy, } GVariant * -_nm_dbus_connection_call_finish(GDBusConnection * dbus_connection, - GAsyncResult * result, +_nm_dbus_connection_call_finish(GDBusConnection *dbus_connection, + GAsyncResult *result, const GVariantType *reply_type, - GError ** error) + GError **error) { GVariant *variant; diff --git a/src/libnm-core-impl/nm-keyfile-utils.c b/src/libnm-core-impl/nm-keyfile-utils.c index f8c2f387b0..0e2e2d45b7 100644 --- a/src/libnm-core-impl/nm-keyfile-utils.c +++ b/src/libnm-core-impl/nm-keyfile-utils.c @@ -107,15 +107,15 @@ nm_keyfile_plugin_get_setting_name_for_alias(const char *alias) /*****************************************************************************/ char ** -nm_keyfile_plugin_kf_get_string_list(GKeyFile * kf, +nm_keyfile_plugin_kf_get_string_list(GKeyFile *kf, const char *group, const char *key, - gsize * out_length, - GError ** error) + gsize *out_length, + GError **error) { - char ** list; + char **list; const char *alias; - GError * local = NULL; + GError *local = NULL; gsize l; list = g_key_file_get_string_list(kf, group, key, &l, &local); @@ -135,16 +135,16 @@ nm_keyfile_plugin_kf_get_string_list(GKeyFile * kf, } guint * -nm_keyfile_plugin_kf_get_integer_list_uint(GKeyFile * key_file, +nm_keyfile_plugin_kf_get_integer_list_uint(GKeyFile *key_file, const char *group_name, const char *key, - gsize * out_length, - GError ** error) + gsize *out_length, + GError **error) { - GError * key_file_error = NULL; + GError *key_file_error = NULL; gs_strfreev char **values = NULL; - gs_free guint *int_values = NULL; - gsize i, num_ints; + gs_free guint *int_values = NULL; + gsize i, num_ints; NM_SET_OUT(out_length, 0); @@ -183,9 +183,9 @@ nm_keyfile_plugin_kf_get_integer_list_uint(GKeyFile * key_file, } void -nm_keyfile_plugin_kf_set_string_list(GKeyFile * kf, - const char * group, - const char * key, +nm_keyfile_plugin_kf_set_string_list(GKeyFile *kf, + const char *group, + const char *key, const char *const *list, gsize length) { @@ -196,9 +196,9 @@ nm_keyfile_plugin_kf_set_string_list(GKeyFile * kf, } void -nm_keyfile_plugin_kf_set_integer_list_uint(GKeyFile * kf, - const char * group, - const char * key, +nm_keyfile_plugin_kf_set_integer_list_uint(GKeyFile *kf, + const char *group, + const char *key, const guint *data, gsize length) { @@ -217,9 +217,9 @@ nm_keyfile_plugin_kf_set_integer_list_uint(GKeyFile * kf, } void -nm_keyfile_plugin_kf_set_integer_list_uint8(GKeyFile * kf, - const char * group, - const char * key, +nm_keyfile_plugin_kf_set_integer_list_uint8(GKeyFile *kf, + const char *group, + const char *key, const guint8 *data, gsize length) { @@ -242,7 +242,7 @@ nm_keyfile_plugin_kf_set_integer_list_uint8(GKeyFile * kf, { \ get_ctype val; \ const char *alias; \ - GError * local = NULL; \ + GError *local = NULL; \ \ val = key_file_get_fcn(kf, group, key, &local); \ if (nm_g_error_matches(local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { \ @@ -275,14 +275,14 @@ DEFINE_KF_WRAPPER_SET(nm_keyfile_plugin_kf_set_boolean, gboolean, g_key_file_set DEFINE_KF_WRAPPER_SET(nm_keyfile_plugin_kf_set_value, const char *, g_key_file_set_value); gint64 -nm_keyfile_plugin_kf_get_int64(GKeyFile * kf, +nm_keyfile_plugin_kf_get_int64(GKeyFile *kf, const char *group, const char *key, guint base, gint64 min, gint64 max, gint64 fallback, - GError ** error) + GError **error) { gs_free char *s = NULL; int errsv; @@ -311,9 +311,9 @@ nm_keyfile_plugin_kf_get_int64(GKeyFile * kf, char ** nm_keyfile_plugin_kf_get_keys(GKeyFile *kf, const char *group, gsize *out_length, GError **error) { - char ** keys; + char **keys; const char *alias; - GError * local = NULL; + GError *local = NULL; gsize l; keys = g_key_file_get_keys(kf, group, &l, &local); @@ -339,7 +339,7 @@ nm_keyfile_plugin_kf_has_key(GKeyFile *kf, const char *group, const char *key, G { gboolean has; const char *alias; - GError * local = NULL; + GError *local = NULL; has = g_key_file_has_key(kf, group, key, &local); if (nm_g_error_matches(local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { @@ -364,7 +364,7 @@ _nm_keyfile_copy(GKeyFile *dst, GKeyFile *src) groups = g_key_file_get_groups(src, NULL); for (g = 0; groups && groups[g]; g++) { - const char * group = groups[g]; + const char *group = groups[g]; gs_strfreev char **keys = NULL; keys = g_key_file_get_keys(src, group, NULL, NULL); @@ -372,7 +372,7 @@ _nm_keyfile_copy(GKeyFile *dst, GKeyFile *src) continue; for (k = 0; keys[k]; k++) { - const char * key = keys[k]; + const char *key = keys[k]; gs_free char *value = NULL; value = g_key_file_get_value(src, group, key, NULL); @@ -644,7 +644,7 @@ nm_keyfile_key_encode(const char *name, char **out_to_free) nm_assert(!*out_to_free || !nm_streq0(name, key)); { gs_free char *to_free2 = NULL; - const char * name2; + const char *name2; name2 = _keyfile_key_decode(key, &to_free2); /* name2, the result of encode()+decode() is identical to name. @@ -669,7 +669,7 @@ nm_keyfile_key_decode(const char *key, char **out_to_free) nm_assert(!*out_to_free || name == *out_to_free); { gs_free char *to_free2 = NULL; - const char * key2; + const char *key2; key2 = _keyfile_key_encode(name, &to_free2); /* key2, the result of decode+encode may not be identical diff --git a/src/libnm-core-impl/nm-keyfile.c b/src/libnm-core-impl/nm-keyfile.c index 1171ab03ee..4ff9b5827a 100644 --- a/src/libnm-core-impl/nm-keyfile.c +++ b/src/libnm-core-impl/nm-keyfile.c @@ -41,22 +41,22 @@ typedef struct _ParseInfoProperty ParseInfoProperty; typedef struct { - NMConnection * connection; - GKeyFile * keyfile; - const char * base_dir; + NMConnection *connection; + GKeyFile *keyfile; + const char *base_dir; NMKeyfileReadHandler read_handler; - void * user_data; - GError * error; - const char * group; - NMSetting * setting; + void *user_data; + GError *error; + const char *group; + NMSetting *setting; } KeyfileReaderInfo; typedef struct { - NMConnection * connection; - GKeyFile * keyfile; - GError * error; + NMConnection *connection; + GKeyFile *keyfile; + GError *error; NMKeyfileWriteHandler write_handler; - void * user_data; + void *user_data; } KeyfileWriterInfo; /*****************************************************************************/ @@ -64,11 +64,11 @@ typedef struct { static void _key_file_handler_data_init(NMKeyfileHandlerData *handler_data, NMKeyfileHandlerType handler_type, - const char * kf_group_name, - const char * kf_key, - NMSetting * cur_setting, - const char * cur_property, - GError ** p_error) + const char *kf_group_name, + const char *kf_key, + NMSetting *cur_setting, + const char *cur_property, + GError **p_error) { nm_assert(handler_data); nm_assert(p_error && !*p_error); @@ -84,9 +84,9 @@ _key_file_handler_data_init(NMKeyfileHandlerData *handler_data, static void _key_file_handler_data_init_read(NMKeyfileHandlerData *handler_data, NMKeyfileHandlerType handler_type, - KeyfileReaderInfo * info, - const char * kf_key, - const char * cur_property) + KeyfileReaderInfo *info, + const char *kf_key, + const char *cur_property) { _key_file_handler_data_init(handler_data, handler_type, @@ -100,11 +100,11 @@ _key_file_handler_data_init_read(NMKeyfileHandlerData *handler_data, static void _key_file_handler_data_init_write(NMKeyfileHandlerData *handler_data, NMKeyfileHandlerType handler_type, - KeyfileWriterInfo * info, - const char * kf_group, - const char * kf_key, - NMSetting * cur_setting, - const char * cur_property) + KeyfileWriterInfo *info, + const char *kf_group, + const char *kf_key, + NMSetting *cur_setting, + const char *cur_property) { _key_file_handler_data_init(handler_data, handler_type, @@ -115,11 +115,11 @@ _key_file_handler_data_init_write(NMKeyfileHandlerData *handler_data, &info->error); } -_nm_printf(5, 6) static void _handle_warn(KeyfileReaderInfo * info, - const char * kf_key, - const char * cur_property, +_nm_printf(5, 6) static void _handle_warn(KeyfileReaderInfo *info, + const char *kf_key, + const char *cur_property, NMKeyfileWarnSeverity severity, - const char * fmt, + const char *fmt, ...) { NMKeyfileHandlerData handler_data; @@ -178,8 +178,8 @@ _secret_flags_persist_secret(NMSettingSecretFlags flags) static void setting_alias_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - const char * key_setting_name; + const char *setting_name = nm_setting_get_name(setting); + const char *key_setting_name; gs_free char *s = NULL; s = nm_keyfile_plugin_kf_get_string(info->keyfile, setting_name, key, NULL); @@ -193,10 +193,10 @@ setting_alias_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *ke static void sriov_vfs_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_ptrarray GPtrArray *vfs = NULL; - gs_strfreev char ** keys = NULL; - gsize n_keys = 0; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_ptrarray GPtrArray *vfs = NULL; + gs_strfreev char **keys = NULL; + gsize n_keys = 0; int i; keys = nm_keyfile_plugin_kf_get_keys(info->keyfile, setting_name, &n_keys, NULL); @@ -207,8 +207,8 @@ sriov_vfs_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) for (i = 0; i < n_keys; i++) { gs_free char *value = NULL; - NMSriovVF * vf; - const char * rest; + NMSriovVF *vf; + const char *rest; if (!g_str_has_prefix(keys[i], "vf.")) continue; @@ -232,9 +232,9 @@ static void read_array_of_uint(GKeyFile *file, NMSetting *setting, const char *key) { gs_unref_array GArray *array = NULL; - gs_free_error GError *error = NULL; - gs_free guint *tmp = NULL; - gsize length; + gs_free_error GError *error = NULL; + gs_free guint *tmp = NULL; + gsize length; tmp = nm_keyfile_plugin_kf_get_integer_list_uint(file, nm_setting_get_name(setting), @@ -251,11 +251,11 @@ read_array_of_uint(GKeyFile *file, NMSetting *setting, const char *key) static gboolean get_one_int(KeyfileReaderInfo *info, - const char * kf_key, - const char * property_name, - const char * str, + const char *kf_key, + const char *property_name, + const char *str, guint32 max_val, - guint32 * out) + guint32 *out) { gint64 tmp; @@ -292,14 +292,14 @@ get_one_int(KeyfileReaderInfo *info, static gpointer build_address(KeyfileReaderInfo *info, - const char * kf_key, - const char * property_name, + const char *kf_key, + const char *property_name, int family, - const char * address_str, + const char *address_str, guint32 plen) { NMIPAddress *addr; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(address_str, NULL); @@ -320,18 +320,18 @@ build_address(KeyfileReaderInfo *info, static gpointer build_route(KeyfileReaderInfo *info, - const char * kf_key, - const char * property_name, + const char *kf_key, + const char *property_name, int family, - const char * dest_str, + const char *dest_str, guint32 plen, - const char * gateway_str, - const char * metric_str) + const char *gateway_str, + const char *metric_str) { NMIPRoute *route; guint32 u32; gint64 metric = -1; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(dest_str, NULL); @@ -455,7 +455,7 @@ read_field(char **current, const char **out_err_str, const char *characters, con static void openconnect_fix_secret_flags(NMSetting *setting) { - NMSettingVpn * s_vpn; + NMSettingVpn *s_vpn; NMSettingSecretFlags flags; /* Huge hack. There were some openconnect changes that needed to happen @@ -518,22 +518,22 @@ openconnect_fix_secret_flags(NMSetting *setting) */ static gpointer read_one_ip_address_or_route(KeyfileReaderInfo *info, - const char * property_name, - const char * setting_name, - const char * kf_key, + const char *property_name, + const char *setting_name, + const char *kf_key, gboolean ipv6, gboolean route, - char ** out_gateway, - NMSetting * setting) + char **out_gateway, + NMSetting *setting) { guint plen; gpointer result; - const char * address_str; - const char * plen_str; - const char * gateway_str; - const char * metric_str; - const char * err_str = NULL; - char * current; + const char *address_str; + const char *plen_str; + const char *gateway_str; + const char *metric_str; + const char *err_str = NULL; + char *current; gs_free char *value = NULL; gs_free char *value_orig = NULL; @@ -680,17 +680,17 @@ read_one_ip_address_or_route(KeyfileReaderInfo *info, } static void -fill_route_attributes(GKeyFile * kf, - NMIPRoute * route, +fill_route_attributes(GKeyFile *kf, + NMIPRoute *route, const char *setting, const char *key, int family) { - gs_free char * value = NULL; - gs_unref_hashtable GHashTable *hash = NULL; + gs_free char *value = NULL; + gs_unref_hashtable GHashTable *hash = NULL; GHashTableIter iter; - char * name; - GVariant * variant; + char *name; + GVariant *variant; value = nm_keyfile_plugin_kf_get_string(kf, setting, key, NULL); if (!value || !value[0]) @@ -751,7 +751,7 @@ static gboolean _build_list_match_key_w_name_impl(const char *key, const char *base_name, gsize base_name_l, - gint32 * out_key_idx) + gint32 *out_key_idx) { gint64 v; @@ -798,14 +798,14 @@ _build_list_match_key_w_name_impl(const char *key, _build_list_match_key_w_name_impl(key, base_name, NM_STRLEN(base_name), out_key_idx) static BuildListData * -_build_list_create(GKeyFile * keyfile, - const char * group_name, +_build_list_create(GKeyFile *keyfile, + const char *group_name, BuildListType build_list_type, - gsize * out_build_list_len, - char *** out_keys_strv) + gsize *out_build_list_len, + char ***out_keys_strv) { - gs_strfreev char **keys = NULL; - gsize i_keys, n_keys; + gs_strfreev char **keys = NULL; + gsize i_keys, n_keys; gs_free BuildListData *build_list = NULL; gsize build_list_len = 0; @@ -878,14 +878,14 @@ _build_list_create(GKeyFile * keyfile, static void ip_address_or_route_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *setting_key) { - const char * setting_name = nm_setting_get_name(setting); - gboolean is_ipv6 = nm_streq(setting_name, "ipv6"); - gboolean is_routes = nm_streq(setting_key, "routes"); - gs_free char * gateway = NULL; - gs_unref_ptrarray GPtrArray *list = NULL; - gs_strfreev char ** keys = NULL; - gs_free BuildListData *build_list = NULL; - gsize i_build_list, build_list_len = 0; + const char *setting_name = nm_setting_get_name(setting); + gboolean is_ipv6 = nm_streq(setting_name, "ipv6"); + gboolean is_routes = nm_streq(setting_key, "routes"); + gs_free char *gateway = NULL; + gs_unref_ptrarray GPtrArray *list = NULL; + gs_strfreev char **keys = NULL; + gs_free BuildListData *build_list = NULL; + gsize i_build_list, build_list_len = 0; build_list = _build_list_create(info->keyfile, setting_name, @@ -940,16 +940,16 @@ ip_address_or_route_parser(KeyfileReaderInfo *info, NMSetting *setting, const ch } static void -ip_routing_rule_parser_full(KeyfileReaderInfo * info, - const NMMetaSettingInfo * setting_info, +ip_routing_rule_parser_full(KeyfileReaderInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - const char * setting_name = nm_setting_get_name(setting); - gboolean is_ipv6 = nm_streq(setting_name, "ipv6"); - gs_strfreev char **keys = NULL; - gs_free BuildListData *build_list = NULL; + const char *setting_name = nm_setting_get_name(setting); + gboolean is_ipv6 = nm_streq(setting_name, "ipv6"); + gs_strfreev char **keys = NULL; + gs_free BuildListData *build_list = NULL; gsize i_build_list, build_list_len = 0; build_list = _build_list_create(info->keyfile, @@ -962,8 +962,8 @@ ip_routing_rule_parser_full(KeyfileReaderInfo * info, for (i_build_list = 0; i_build_list < build_list_len; i_build_list++) { nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; - gs_free char * value = NULL; - gs_free_error GError *local = NULL; + gs_free char *value = NULL; + gs_free_error GError *local = NULL; if (_build_list_data_is_shadowed(build_list, build_list_len, i_build_list)) continue; @@ -999,13 +999,13 @@ ip_routing_rule_parser_full(KeyfileReaderInfo * info, } static void -_parser_full_ovs_external_ids_data(KeyfileReaderInfo * info, - const NMMetaSettingInfo * setting_info, +_parser_full_ovs_external_ids_data(KeyfileReaderInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - const char * setting_name = NM_SETTING_OVS_EXTERNAL_IDS_SETTING_NAME; + const char *setting_name = NM_SETTING_OVS_EXTERNAL_IDS_SETTING_NAME; gs_strfreev char **keys = NULL; gsize n_keys; gsize i; @@ -1018,10 +1018,10 @@ _parser_full_ovs_external_ids_data(KeyfileReaderInfo * info, keys = nm_keyfile_plugin_kf_get_keys(info->keyfile, setting_name, &n_keys, NULL); for (i = 0; i < n_keys; i++) { - const char * key = keys[i]; + const char *key = keys[i]; gs_free char *name_to_free = NULL; gs_free char *value = NULL; - const char * name; + const char *name; if (!NM_STR_HAS_PREFIX(key, OVS_EXTERNAL_IDS_DATA_PREFIX)) continue; @@ -1089,8 +1089,8 @@ static void ip6_addr_gen_mode_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { NMSettingIP6ConfigAddrGenMode addr_gen_mode; - const char * setting_name = nm_setting_get_name(setting); - gs_free char * s = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_free char *s = NULL; s = nm_keyfile_plugin_kf_get_string(info->keyfile, setting_name, key, NULL); if (s) { @@ -1115,17 +1115,17 @@ ip6_addr_gen_mode_parser(KeyfileReaderInfo *info, NMSetting *setting, const char static void mac_address_parser(KeyfileReaderInfo *info, - NMSetting * setting, - const char * key, + NMSetting *setting, + const char *key, gsize addr_len, gboolean cloned_mac_addr) { - const char * setting_name = nm_setting_get_name(setting); - char addr_str[NM_UTILS_HWADDR_LEN_MAX * 3]; - guint8 addr_bin[NM_UTILS_HWADDR_LEN_MAX]; - gs_free char *tmp_string = NULL; - gs_free guint *int_list = NULL; - const char * mac_str; + const char *setting_name = nm_setting_get_name(setting); + char addr_str[NM_UTILS_HWADDR_LEN_MAX * 3]; + guint8 addr_bin[NM_UTILS_HWADDR_LEN_MAX]; + gs_free char *tmp_string = NULL; + gs_free guint *int_list = NULL; + const char *mac_str; gsize int_list_len; gsize i; @@ -1191,13 +1191,13 @@ mac_address_parser_INFINIBAND(KeyfileReaderInfo *info, NMSetting *setting, const static void read_hash_of_string(KeyfileReaderInfo *info, - GKeyFile * file, - NMSetting * setting, - const char * kf_group) + GKeyFile *file, + NMSetting *setting, + const char *kf_group) { gs_strfreev char **keys = NULL; const char *const *iter; - const char * setting_name = nm_setting_get_name(setting); + const char *setting_name = nm_setting_get_name(setting); gboolean is_vpn; gsize n_keys; @@ -1212,10 +1212,10 @@ read_hash_of_string(KeyfileReaderInfo *info, if ((is_vpn = NM_IS_SETTING_VPN(setting)) || NM_IS_SETTING_BOND(setting)) { for (iter = (const char *const *) keys; *iter; iter++) { - const char * kf_key = *iter; + const char *kf_key = *iter; gs_free char *to_free = NULL; gs_free char *value = NULL; - const char * name; + const char *name; value = nm_keyfile_plugin_kf_get_string(file, setting_name, kf_key, NULL); if (!value) @@ -1256,8 +1256,8 @@ read_hash_of_string(KeyfileReaderInfo *info, data = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); for (iter = (const char *const *) keys; *iter; iter++) { gs_free char *to_free = NULL; - char * value = NULL; - const char * name; + char *value = NULL; + const char *name; value = nm_keyfile_plugin_kf_get_string(file, setting_name, *iter, NULL); if (!value) @@ -1288,15 +1288,15 @@ unescape_semicolons(char *str) static GBytes * get_bytes(KeyfileReaderInfo *info, - const char * setting_name, - const char * key, + const char *setting_name, + const char *key, gboolean zero_terminate, gboolean unescape_semicolon) { nm_auto_free_secret char *tmp_string = NULL; gboolean may_be_int_list = TRUE; gsize length; - GBytes * result; + GBytes *result; /* New format: just a string * Old format: integer list; e.g. 11;25;38; @@ -1421,8 +1421,8 @@ get_bytes(KeyfileReaderInfo *info, static void ssid_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_bytes GBytes *bytes = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_bytes GBytes *bytes = NULL; bytes = get_bytes(info, setting_name, key, FALSE, TRUE); if (!bytes) { @@ -1435,8 +1435,8 @@ ssid_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) static void password_raw_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_bytes GBytes *bytes = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_bytes GBytes *bytes = NULL; bytes = get_bytes(info, setting_name, key, FALSE, TRUE); if (!bytes) { @@ -1454,7 +1454,7 @@ static char * get_cert_path(const char *base_dir, const guint8 *cert_path, gsize cert_path_len) { const char *base; - char * p = NULL, *path, *tmp; + char *p = NULL, *path, *tmp; g_return_val_if_fail(base_dir != NULL, NULL); g_return_val_if_fail(cert_path != NULL, NULL); @@ -1489,13 +1489,13 @@ has_cert_ext(const char *path) } char * -nm_keyfile_detect_unqualified_path_scheme(const char * base_dir, +nm_keyfile_detect_unqualified_path_scheme(const char *base_dir, gconstpointer pdata, gsize data_len, gboolean consider_exists, - gboolean * out_exists) + gboolean *out_exists) { - const char * data = pdata; + const char *data = pdata; gboolean exists = FALSE; gsize validate_len; gsize path_len, pathuri_len; @@ -1573,11 +1573,11 @@ nm_keyfile_detect_unqualified_path_scheme(const char * base_dir, static void cert_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_bytes GBytes *bytes = NULL; - const char * bin = NULL; - gsize bin_len = 0; - char * path; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_bytes GBytes *bytes = NULL; + const char *bin = NULL; + gsize bin_len = 0; + char *path; gboolean path_exists; bytes = get_bytes(info, setting_name, key, TRUE, FALSE); @@ -1591,7 +1591,7 @@ cert_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) } if (HAS_SCHEME_PREFIX(bin, bin_len, NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)) { - const char * path2 = &bin[NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)]; + const char *path2 = &bin[NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)]; gs_free char *path2_free = NULL; if (nm_setting_802_1x_check_cert_scheme(bin, bin_len, NULL) @@ -1648,8 +1648,8 @@ cert_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) } if (HAS_SCHEME_PREFIX(bin, bin_len, NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)) { - const char *cdata = bin + NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB); - gsize cdata_len = bin_len - NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB) - 1; + const char *cdata = bin + NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB); + gsize cdata_len = bin_len - NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB) - 1; gs_free guchar *bin_decoded = NULL; gsize bin_decoded_len = 0; gsize i; @@ -1801,10 +1801,10 @@ _parity_from_char(int ch) static void parity_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_free_error GError *err = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_free_error GError *err = NULL; int parity; - gs_free char * tmp_str = NULL; + gs_free char *tmp_str = NULL; gint64 i64; /* Keyfile traditionally stored this as the ASCII value for 'E', 'o', or 'n'. @@ -1869,9 +1869,9 @@ out_err: static void team_config_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_free char *conf = NULL; - gs_free_error GError *error = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_free char *conf = NULL; + gs_free_error GError *error = NULL; conf = nm_keyfile_plugin_kf_get_string(info->keyfile, setting_name, key, NULL); @@ -1892,11 +1892,11 @@ static void bridge_vlan_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { gs_unref_ptrarray GPtrArray *vlans = NULL; - gs_free char * value = NULL; - gs_free const char ** strv = NULL; - const char *const * iter; - GError * local = NULL; - NMBridgeVlan * vlan; + gs_free char *value = NULL; + gs_free const char **strv = NULL; + const char *const *iter; + GError *local = NULL; + NMBridgeVlan *vlan; value = nm_keyfile_plugin_kf_get_string(info->keyfile, nm_setting_get_name(setting), key, NULL); if (!value || !value[0]) @@ -1929,10 +1929,10 @@ bridge_vlan_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) static void qdisc_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_ptrarray GPtrArray *qdiscs = NULL; - gs_strfreev char ** keys = NULL; - gsize n_keys = 0; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_ptrarray GPtrArray *qdiscs = NULL; + gs_strfreev char **keys = NULL; + gsize n_keys = 0; int i; keys = nm_keyfile_plugin_kf_get_keys(info->keyfile, setting_name, &n_keys, NULL); @@ -1942,11 +1942,11 @@ qdisc_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) qdiscs = g_ptr_array_new_with_free_func((GDestroyNotify) nm_tc_qdisc_unref); for (i = 0; i < n_keys; i++) { - NMTCQdisc * qdisc; - const char * qdisc_parent; - gs_free char *qdisc_rest = NULL; - gs_free char *qdisc_str = NULL; - gs_free_error GError *err = NULL; + NMTCQdisc *qdisc; + const char *qdisc_parent; + gs_free char *qdisc_rest = NULL; + gs_free char *qdisc_str = NULL; + gs_free_error GError *err = NULL; if (!g_str_has_prefix(keys[i], "qdisc.")) continue; @@ -1979,10 +1979,10 @@ qdisc_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) static void tfilter_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_ptrarray GPtrArray *tfilters = NULL; - gs_strfreev char ** keys = NULL; - gsize n_keys = 0; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_ptrarray GPtrArray *tfilters = NULL; + gs_strfreev char **keys = NULL; + gsize n_keys = 0; int i; keys = nm_keyfile_plugin_kf_get_keys(info->keyfile, setting_name, &n_keys, NULL); @@ -1992,11 +1992,11 @@ tfilter_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) tfilters = g_ptr_array_new_with_free_func((GDestroyNotify) nm_tc_tfilter_unref); for (i = 0; i < n_keys; i++) { - NMTCTfilter * tfilter; - const char * tfilter_parent; - gs_free char *tfilter_rest = NULL; - gs_free char *tfilter_str = NULL; - gs_free_error GError *err = NULL; + NMTCTfilter *tfilter; + const char *tfilter_parent; + gs_free char *tfilter_rest = NULL; + gs_free char *tfilter_str = NULL; + gs_free_error GError *err = NULL; if (!g_str_has_prefix(keys[i], "tfilter.")) continue; @@ -2037,9 +2037,9 @@ tfilter_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) */ static void setting_alias_writer(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value) + NMSetting *setting, + const char *key, + const GValue *value) { const char *str, *alias; @@ -2060,7 +2060,7 @@ sriov_vfs_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, c for (i = 0; i < vfs->len; i++) { const NMSriovVF *vf = vfs->pdata[i]; - gs_free char * kf_value = NULL; + gs_free char *kf_value = NULL; char kf_key[32]; kf_value = nm_utils_sriov_vf_to_str(vf, TRUE, NULL); @@ -2112,12 +2112,12 @@ dns_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const G static void ip6_addr_gen_mode_writer(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value) + NMSetting *setting, + const char *key, + const GValue *value) { NMSettingIP6ConfigAddrGenMode addr_gen_mode; - gs_free char * str = NULL; + gs_free char *str = NULL; addr_gen_mode = (NMSettingIP6ConfigAddrGenMode) g_value_get_int(value); str = nm_utils_enum_to_str(nm_setting_ip6_config_addr_gen_mode_get_type(), addr_gen_mode); @@ -2125,9 +2125,9 @@ ip6_addr_gen_mode_writer(KeyfileWriterInfo *info, } static void -write_ip_values(GKeyFile * file, +write_ip_values(GKeyFile *file, const char *setting_name, - GPtrArray * array, + GPtrArray *array, const char *gateway, gboolean is_route) { @@ -2135,11 +2135,11 @@ write_ip_values(GKeyFile * file, nm_auto_str_buf NMStrBuf output = NM_STR_BUF_INIT(2 * INET_ADDRSTRLEN + 10, FALSE); int addr_family; guint i; - const char * addr; - const char * gw; + const char *addr; + const char *gw; guint32 plen; char key_name[64]; - char * key_name_idx; + char *key_name_idx; addr_family = nm_streq(setting_name, NM_SETTING_IP4_CONFIG_SETTING_NAME) ? AF_INET : AF_INET6; @@ -2211,7 +2211,7 @@ write_ip_values(GKeyFile * file, static void addr_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const GValue *value) { - GPtrArray * array; + GPtrArray *array; const char *setting_name = nm_setting_get_name(setting); const char *gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting)); @@ -2223,7 +2223,7 @@ addr_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const static void route_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const GValue *value) { - GPtrArray * array; + GPtrArray *array; const char *setting_name = nm_setting_get_name(setting); array = (GPtrArray *) g_value_get_boxed(value); @@ -2233,9 +2233,9 @@ route_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const static void bridge_vlan_writer(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value) + NMSetting *setting, + const char *key, + const GValue *value) { GPtrArray *vlans; @@ -2262,13 +2262,13 @@ bridge_vlan_writer(KeyfileWriterInfo *info, } static void -wired_s390_options_parser_full(KeyfileReaderInfo * info, - const NMMetaSettingInfo * setting_info, +wired_s390_options_parser_full(KeyfileReaderInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - NMSettingWired * s_wired = NM_SETTING_WIRED(setting); + NMSettingWired *s_wired = NM_SETTING_WIRED(setting); gs_strfreev char **keys = NULL; gsize n_keys; gsize i; @@ -2297,11 +2297,11 @@ wired_s390_options_parser_full(KeyfileReaderInfo * info, } static void -wired_s390_options_writer_full(KeyfileWriterInfo * info, - const NMMetaSettingInfo * setting_info, +wired_s390_options_writer_full(KeyfileWriterInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { NMSettingWired *s_wired = NM_SETTING_WIRED(setting); guint i, n; @@ -2309,8 +2309,8 @@ wired_s390_options_writer_full(KeyfileWriterInfo * info, n = nm_setting_wired_get_num_s390_options(s_wired); for (i = 0; i < n; i++) { gs_free char *key_to_free = NULL; - const char * opt_key; - const char * opt_val; + const char *opt_key; + const char *opt_val; nm_setting_wired_get_s390_option(s_wired, i, &opt_key, &opt_val); nm_keyfile_plugin_kf_set_string(info->keyfile, @@ -2321,23 +2321,23 @@ wired_s390_options_writer_full(KeyfileWriterInfo * info, } static void -ip_routing_rule_writer_full(KeyfileWriterInfo * info, - const NMMetaSettingInfo * setting_info, +ip_routing_rule_writer_full(KeyfileWriterInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - const char * setting_name = nm_setting_get_name(setting); + const char *setting_name = nm_setting_get_name(setting); NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); guint i, j, n; char key_name_full[100] = "routing-rule"; - char * key_name_num = &key_name_full[NM_STRLEN("routing-rule")]; + char *key_name_num = &key_name_full[NM_STRLEN("routing-rule")]; n = nm_setting_ip_config_get_num_routing_rules(s_ip); j = 0; for (i = 0; i < n; i++) { NMIPRoutingRule *rule = nm_setting_ip_config_get_routing_rule(s_ip, i); - gs_free char * str = NULL; + gs_free char *str = NULL; str = nm_ip_routing_rule_to_string(rule, NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE, NULL, NULL); @@ -2354,7 +2354,7 @@ qdisc_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const { nm_auto_free_gstring GString *key_name = NULL; nm_auto_free_gstring GString *value_str = NULL; - GPtrArray * array; + GPtrArray *array; guint i; array = g_value_get_boxed(value); @@ -2383,7 +2383,7 @@ tfilter_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, con { nm_auto_free_gstring GString *key_name = NULL; nm_auto_free_gstring GString *value_str = NULL; - GPtrArray * array; + GPtrArray *array; guint i; array = g_value_get_boxed(value); @@ -2408,16 +2408,16 @@ tfilter_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, con } static void -_writer_full_ovs_external_ids_data(KeyfileWriterInfo * info, - const NMMetaSettingInfo * setting_info, +_writer_full_ovs_external_ids_data(KeyfileWriterInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - GHashTable * hash; - NMUtilsNamedValue data_static[300u / sizeof(NMUtilsNamedValue)]; + GHashTable *hash; + NMUtilsNamedValue data_static[300u / sizeof(NMUtilsNamedValue)]; gs_free NMUtilsNamedValue *data_free = NULL; - const NMUtilsNamedValue * data; + const NMUtilsNamedValue *data; guint data_len; char full_key_static[NM_STRLEN(OVS_EXTERNAL_IDS_DATA_PREFIX) + 300u]; guint i; @@ -2436,13 +2436,13 @@ _writer_full_ovs_external_ids_data(KeyfileWriterInfo * info, memcpy(full_key_static, OVS_EXTERNAL_IDS_DATA_PREFIX, NM_STRLEN(OVS_EXTERNAL_IDS_DATA_PREFIX)); for (i = 0; i < data_len; i++) { - const char * key = data[i].name; - const char * val = data[i].value_str; + const char *key = data[i].name; + const char *val = data[i].value_str; gs_free char *escaped_key_to_free = NULL; - const char * escaped_key; + const char *escaped_key; gsize len; gs_free char *full_key_free = NULL; - char * full_key = full_key_static; + char *full_key = full_key_static; escaped_key = nm_keyfile_key_encode(key, &escaped_key_to_free); @@ -2464,8 +2464,8 @@ _writer_full_ovs_external_ids_data(KeyfileWriterInfo * info, static void write_hash_of_string(GKeyFile *file, NMSetting *setting, const char *key, const GValue *value) { - GHashTable * hash; - const char * group_name = nm_setting_get_name(setting); + GHashTable *hash; + const char *group_name = nm_setting_get_name(setting); gboolean vpn_secrets = FALSE; gs_free const char **keys = NULL; guint i, l; @@ -2486,7 +2486,7 @@ write_hash_of_string(GKeyFile *file, NMSetting *setting, const char *key, const keys = nm_strdict_get_keys(hash, TRUE, &l); for (i = 0; i < l; i++) { gs_free char *to_free = NULL; - const char * property, *data; + const char *property, *data; property = keys[i]; @@ -2514,10 +2514,10 @@ write_hash_of_string(GKeyFile *file, NMSetting *setting, const char *key, const static void ssid_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const GValue *value) { - GBytes * bytes; + GBytes *bytes; const guint8 *ssid_data; gsize ssid_len; - const char * setting_name = nm_setting_get_name(setting); + const char *setting_name = nm_setting_get_name(setting); gboolean new_format = TRUE; gsize semicolons = 0; gsize i; @@ -2576,12 +2576,12 @@ ssid_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const static void password_raw_writer(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value) + NMSetting *setting, + const char *key, + const GValue *value) { - const char * setting_name = nm_setting_get_name(setting); - GBytes * array; + const char *setting_name = nm_setting_get_name(setting); + GBytes *array; gsize len; const guint8 *data; @@ -2599,10 +2599,10 @@ password_raw_writer(KeyfileWriterInfo *info, /*****************************************************************************/ static void -cert_writer_default(NMConnection * connection, - GKeyFile * file, - NMSetting8021x * setting, - const char * setting_name, +cert_writer_default(NMConnection *connection, + GKeyFile *file, + NMSetting8021x *setting, + const char *setting_name, const NMSetting8021xSchemeVtable *vtable) { NMSetting8021xCKScheme scheme; @@ -2612,7 +2612,7 @@ cert_writer_default(NMConnection * connection, gs_free char *path_free = NULL; gs_free char *base_dir = NULL; gs_free char *tmp = NULL; - const char * path; + const char *path; path = vtable->path_func(setting); g_assert(path); @@ -2643,7 +2643,7 @@ cert_writer_default(NMConnection * connection, nm_keyfile_plugin_kf_set_string(file, setting_name, vtable->setting_key, path); } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) { - GBytes * blob; + GBytes *blob; const guint8 *blob_data; gsize blob_len; gs_free char *blob_base64 = NULL; @@ -2677,7 +2677,7 @@ static void cert_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const GValue *value) { const NMSetting8021xSchemeVtable *vtable = NULL; - const char * setting_name; + const char *setting_name; guint i; for (i = 0; nm_setting_8021x_scheme_vtable[i].setting_key; i++) { @@ -2728,22 +2728,22 @@ struct _ParseInfoProperty { const char *property_name; union { void (*parser)(KeyfileReaderInfo *info, NMSetting *setting, const char *key); - void (*parser_full)(KeyfileReaderInfo * info, - const NMMetaSettingInfo * setting_info, + void (*parser_full)(KeyfileReaderInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting); + const ParseInfoProperty *pip, + NMSetting *setting); }; union { void (*writer)(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value); - void (*writer_full)(KeyfileWriterInfo * info, - const NMMetaSettingInfo * setting_info, + NMSetting *setting, + const char *key, + const GValue *value); + void (*writer_full)(KeyfileWriterInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting); + const ParseInfoProperty *pip, + NMSetting *setting); }; bool parser_skip; bool parser_no_check_key : 1; @@ -3021,14 +3021,14 @@ static const ParseInfoSetting *const parse_infos[_NM_META_SETTING_TYPE_NUM] = { }; static void -_parse_info_find(NMSetting * setting, - const char * property_name, +_parse_info_find(NMSetting *setting, + const char *property_name, const NMMetaSettingInfo **out_setting_info, - const ParseInfoSetting ** out_parse_info_setting, + const ParseInfoSetting **out_parse_info_setting, const ParseInfoProperty **out_parse_info_property) { const NMMetaSettingInfo *setting_info; - const ParseInfoSetting * pis; + const ParseInfoSetting *pis; const ParseInfoProperty *pip; #if NM_MORE_ASSERTS > 10 @@ -3105,16 +3105,16 @@ _parse_info_find(NMSetting * setting, /*****************************************************************************/ static void -read_one_setting_value(KeyfileReaderInfo * info, - NMSetting * setting, +read_one_setting_value(KeyfileReaderInfo *info, + NMSetting *setting, const NMSettInfoProperty *property_info) { - GKeyFile * keyfile = info->keyfile; - gs_free_error GError * err = NULL; + GKeyFile *keyfile = info->keyfile; + gs_free_error GError *err = NULL; const NMMetaSettingInfo *setting_info; const ParseInfoProperty *pip; - gs_free char * tmp_str = NULL; - const char * key; + gs_free char *tmp_str = NULL; + const char *key; GType type; guint64 u64; gint64 i64; @@ -3255,11 +3255,11 @@ read_one_setting_value(KeyfileReaderInfo * info, } } else if (type == G_TYPE_BYTES) { nm_auto_unref_bytearray GByteArray *array = NULL; - gs_unref_bytes GBytes *bytes = NULL; - gs_free guint *tmp = NULL; - gsize length; - int i; - gboolean already_warned = FALSE; + gs_unref_bytes GBytes *bytes = NULL; + gs_free guint *tmp = NULL; + gsize length; + int i; + gboolean already_warned = FALSE; tmp = nm_keyfile_plugin_kf_get_integer_list_uint(keyfile, setting_info->setting_name, @@ -3347,9 +3347,9 @@ read_one_setting_value(KeyfileReaderInfo * info, static void _read_setting(KeyfileReaderInfo *info) { - const NMSettInfoSetting *sett_info; + const NMSettInfoSetting *sett_info; gs_unref_object NMSetting *setting = NULL; - const char * alias; + const char *alias; GType type; guint16 i; @@ -3386,10 +3386,10 @@ _read_setting(KeyfileReaderInfo *info) nm_strv_sort(keys, n_keys); for (k = 0; k < n_keys; k++) { - gs_free char *key = keys[k]; + gs_free char *key = keys[k]; gs_free_error GError *local = NULL; - const GVariantType * variant_type; - GVariant * variant; + const GVariantType *variant_type; + GVariant *variant; /* a GKeyFile can return duplicate keys, there is just no API to make sense * of them. Skip them. */ @@ -3477,16 +3477,16 @@ out: static void _read_setting_wireguard_peer(KeyfileReaderInfo *info) { - gs_unref_object NMSettingWireGuard *s_wg_new = NULL; - nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; - gs_free_error GError *error = NULL; - NMSettingWireGuard * s_wg; - gs_free char * str = NULL; - const char * cstr = NULL; - const char * key; - gint64 i64; - gs_strfreev char ** sa = NULL; - gsize n_sa; + gs_unref_object NMSettingWireGuard *s_wg_new = NULL; + nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; + gs_free_error GError *error = NULL; + NMSettingWireGuard *s_wg; + gs_free char *str = NULL; + const char *cstr = NULL; + const char *key; + gint64 i64; + gs_strfreev char **sa = NULL; + gsize n_sa; peer = nm_wireguard_peer_new(); @@ -3643,7 +3643,7 @@ _read_setting_vpn_secrets(KeyfileReaderInfo *info) { gs_strfreev char **keys = NULL; gsize i, n_keys; - NMSettingVpn * s_vpn; + NMSettingVpn *s_vpn; s_vpn = nm_connection_get_setting_vpn(info->connection); if (!s_vpn) { @@ -3689,7 +3689,7 @@ gboolean nm_keyfile_read_ensure_uuid(NMConnection *connection, const char *fallback_uuid_seed) { NMSettingConnection *s_con; - gs_free char * hashed_uuid = NULL; + gs_free char *hashed_uuid = NULL; g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE); g_return_val_if_fail(fallback_uuid_seed, FALSE); @@ -3724,16 +3724,16 @@ nm_keyfile_read_ensure_uuid(NMConnection *connection, const char *fallback_uuid_ * Since: 1.30 */ NMConnection * -nm_keyfile_read(GKeyFile * keyfile, - const char * base_dir, +nm_keyfile_read(GKeyFile *keyfile, + const char *base_dir, NMKeyfileHandlerFlags handler_flags, NMKeyfileReadHandler handler, - void * user_data, - GError ** error) + void *user_data, + GError **error) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - gs_strfreev char ** groups = NULL; + NMSettingConnection *s_con; + gs_strfreev char **groups = NULL; gsize n_groups; gsize i; gboolean vpn_secrets = FALSE; @@ -3814,13 +3814,13 @@ out_with_info_error: /*****************************************************************************/ static void -write_setting_value(KeyfileWriterInfo * info, - NMSetting * setting, +write_setting_value(KeyfileWriterInfo *info, + NMSetting *setting, const NMSettInfoProperty *property_info) { const NMMetaSettingInfo *setting_info; const ParseInfoProperty *pip; - const char * key; + const char *key; char numstr[64]; GValue value; GType type; @@ -3919,7 +3919,7 @@ write_setting_value(KeyfileWriterInfo * info, nm_sprintf_buf(numstr, "%d", (int) g_value_get_schar(&value)); nm_keyfile_plugin_kf_set_value(info->keyfile, setting_info->setting_name, key, numstr); } else if (type == G_TYPE_BYTES) { - GBytes * bytes; + GBytes *bytes; const guint8 *data; gsize len = 0; @@ -3968,13 +3968,13 @@ _write_setting_wireguard(NMSetting *setting, KeyfileWriterInfo *info) n_peers = nm_setting_wireguard_get_peers_len(s_wg); for (i_peer = 0; i_peer < n_peers; i_peer++) { - NMWireGuardPeer * peer = nm_setting_wireguard_get_peer(s_wg, i_peer); - const char * public_key; + NMWireGuardPeer *peer = nm_setting_wireguard_get_peer(s_wg, i_peer); + const char *public_key; char group[NM_STRLEN(NM_KEYFILE_GROUPPREFIX_WIREGUARD_PEER) + 200]; NMSettingSecretFlags secret_flags; gboolean any_key = FALSE; guint i_aip, n_aip; - const char * cstr; + const char *cstr; guint32 u32; public_key = nm_wireguard_peer_get_public_key(peer); @@ -4073,16 +4073,16 @@ _write_setting_wireguard(NMSetting *setting, KeyfileWriterInfo *info) * Since: 1.30 */ GKeyFile * -nm_keyfile_write(NMConnection * connection, +nm_keyfile_write(NMConnection *connection, NMKeyfileHandlerFlags handler_flags, NMKeyfileWriteHandler handler, - void * user_data, - GError ** error) + void *user_data, + GError **error) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - GError * local = NULL; + GError *local = NULL; KeyfileWriterInfo info; - NMSetting ** settings; + NMSetting **settings; int i; guint16 j; @@ -4124,10 +4124,10 @@ nm_keyfile_write(NMConnection * connection, settings = _nm_connection_get_settings_arr(connection); for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) { - NMSetting * setting = settings[nm_meta_setting_types_by_priority[i]]; + NMSetting *setting = settings[nm_meta_setting_types_by_priority[i]]; const NMSettInfoSetting *sett_info; - const char * setting_name; - const char * setting_alias; + const char *setting_name; + const char *setting_alias; if (!setting) continue; @@ -4150,7 +4150,7 @@ nm_keyfile_write(NMConnection * connection, for (k = 0; k < n_keys; k++) { const char *key = keys[k]; - GVariant * v; + GVariant *v; v = g_hash_table_lookup(h, key); @@ -4305,7 +4305,7 @@ nm_keyfile_utils_create_filename(const char *name, gboolean with_extension) const char ESCAPE_CHAR = with_extension ? '_' : '*'; const char ESCAPE_CHAR2 = '_'; NMStrBuf str; - char * p; + char *p; gsize len; gsize i; @@ -4392,10 +4392,10 @@ nm_keyfile_handler_data_fail_with_error(NMKeyfileHandlerData *handler_data, GErr */ void nm_keyfile_handler_data_get_context(const NMKeyfileHandlerData *handler_data, - const char ** out_kf_group_name, - const char ** out_kf_key_name, - NMSetting ** out_cur_setting, - const char ** out_cur_property_name) + const char **out_kf_group_name, + const char **out_kf_key_name, + NMSetting **out_cur_setting, + const char **out_cur_property_name) { g_return_if_fail(handler_data); @@ -4435,8 +4435,8 @@ _nm_keyfile_handler_data_warn_get_message(const NMKeyfileHandlerData *handler_da */ void nm_keyfile_handler_data_warn_get(const NMKeyfileHandlerData *handler_data, - const char ** out_message, - NMKeyfileWarnSeverity * out_severity) + const char **out_message, + NMKeyfileWarnSeverity *out_severity) { g_return_if_fail(handler_data); g_return_if_fail(handler_data->type == NM_KEYFILE_HANDLER_TYPE_WARN); diff --git a/src/libnm-core-impl/nm-meta-setting-base-impl.c b/src/libnm-core-impl/nm-meta-setting-base-impl.c index 8c1ad10ea8..cd55779f11 100644 --- a/src/libnm-core-impl/nm-meta-setting-base-impl.c +++ b/src/libnm-core-impl/nm-meta-setting-base-impl.c @@ -646,8 +646,8 @@ nm_meta_setting_infos_by_gtype(GType gtype) { #if _NM_META_SETTING_BASE_IMPL_LIBNM nm_auto_unref_gtypeclass GTypeClass *gtypeclass_unref = NULL; - GTypeClass * gtypeclass; - NMSettingClass * klass; + GTypeClass *gtypeclass; + NMSettingClass *klass; if (!g_type_is_a(gtype, NM_TYPE_SETTING)) goto out_none; diff --git a/src/libnm-core-impl/nm-property-compare.c b/src/libnm-core-impl/nm-property-compare.c index 4347d6d678..6273e90bc3 100644 --- a/src/libnm-core-impl/nm-property-compare.c +++ b/src/libnm-core-impl/nm-property-compare.c @@ -43,8 +43,8 @@ _nm_property_compare_vardict(GVariant *value1, GVariant *value2) { GVariantIter iter; int len1, len2; - const char * key; - GVariant * val1, *val2; + const char *key; + GVariant *val1, *val2; len1 = g_variant_n_children(value1); len2 = g_variant_n_children(value2); @@ -75,7 +75,7 @@ _nm_property_compare_strdict(GVariant *value1, GVariant *value2) { GVariantIter iter; int len1, len2; - const char * key, *val1, *val2; + const char *key, *val1, *val2; int ret; len1 = g_variant_n_children(value1); diff --git a/src/libnm-core-impl/nm-setting-6lowpan.c b/src/libnm-core-impl/nm-setting-6lowpan.c index 606fa8243c..765af69b13 100644 --- a/src/libnm-core-impl/nm-setting-6lowpan.c +++ b/src/libnm-core-impl/nm-setting-6lowpan.c @@ -66,7 +66,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE(setting); - NMSettingConnection * s_con = NULL; + NMSettingConnection *s_con = NULL; if (connection) s_con = nm_connection_get_setting_connection(connection); @@ -150,9 +150,9 @@ nm_setting_6lowpan_new(void) static void nm_setting_6lowpan_class_init(NMSetting6LowpanClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSetting6LowpanPrivate)); diff --git a/src/libnm-core-impl/nm-setting-8021x.c b/src/libnm-core-impl/nm-setting-8021x.c index 103443ba49..60abc0f77d 100644 --- a/src/libnm-core-impl/nm-setting-8021x.c +++ b/src/libnm-core-impl/nm-setting-8021x.c @@ -72,7 +72,7 @@ typedef void (*EAPMethodNeedSecretsFunc)(NMSetting8021x *self, GPtrArray *secret typedef gboolean (*EAPMethodValidateFunc)(NMSetting8021x *self, gboolean phase2, GError **error); typedef struct { - const char * method; + const char *method; EAPMethodNeedSecretsFunc ns_func; EAPMethodValidateFunc v_func; } EAPMethodsTable; @@ -132,39 +132,39 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSetting8021x, typedef struct { GSList *eap; /* GSList of strings */ - char * identity; - char * anonymous_identity; - char * pac_file; + char *identity; + char *anonymous_identity; + char *pac_file; GBytes *ca_cert; - char * ca_cert_password; - char * ca_path; - char * subject_match; + char *ca_cert_password; + char *ca_path; + char *subject_match; GSList *altsubject_matches; - char * domain_suffix_match; - char * domain_match; + char *domain_suffix_match; + char *domain_match; GBytes *client_cert; - char * client_cert_password; - char * phase1_peapver; - char * phase1_peaplabel; - char * phase1_fast_provisioning; - char * phase2_auth; - char * phase2_autheap; + char *client_cert_password; + char *phase1_peapver; + char *phase1_peaplabel; + char *phase1_fast_provisioning; + char *phase2_auth; + char *phase2_autheap; GBytes *phase2_ca_cert; - char * phase2_ca_cert_password; - char * phase2_ca_path; - char * phase2_subject_match; + char *phase2_ca_cert_password; + char *phase2_ca_path; + char *phase2_subject_match; GSList *phase2_altsubject_matches; - char * phase2_domain_suffix_match; - char * phase2_domain_match; + char *phase2_domain_suffix_match; + char *phase2_domain_match; GBytes *phase2_client_cert; - char * phase2_client_cert_password; - char * password; + char *phase2_client_cert_password; + char *password; GBytes *password_raw; - char * pin; + char *pin; GBytes *private_key; - char * private_key_password; + char *private_key_password; GBytes *phase2_private_key; - char * phase2_private_key_password; + char *phase2_private_key_password; guint ca_cert_password_flags; guint client_cert_password_flags; guint phase2_ca_cert_password_flags; @@ -221,7 +221,7 @@ G_DEFINE_TYPE(NMSetting8021x, nm_setting_802_1x, NM_TYPE_SETTING) NMSetting8021xCKScheme nm_setting_802_1x_check_cert_scheme(gconstpointer pdata, gsize length, GError **error) { - const char * data = pdata; + const char *data = pdata; NMSetting8021xCKScheme scheme; gsize prefix_length; @@ -309,7 +309,7 @@ _nm_setting_802_1x_cert_get_scheme(GBytes *bytes, GError **error) static gboolean _cert_verify_scheme(NMSetting8021xCKScheme scheme, GBytes *bytes, GError **error) { - GError * local = NULL; + GError *local = NULL; NMSetting8021xCKScheme scheme_detected; nm_assert(bytes); @@ -337,12 +337,12 @@ _cert_verify_scheme(NMSetting8021xCKScheme scheme, GBytes *bytes, GError **error GBytes * _nm_setting_802_1x_cert_value_to_bytes(NMSetting8021xCKScheme scheme, - const guint8 * val_bin, + const guint8 *val_bin, gssize val_len, - GError ** error) + GError **error) { gs_unref_bytes GBytes *bytes = NULL; - guint8 * mem; + guint8 *mem; gsize total_len; nm_assert(val_bin); @@ -411,7 +411,7 @@ _cert_get_path(GBytes *bytes) G_STMT_START \ { \ NMSetting8021x *const _setting = (setting); \ - GBytes * _cert; \ + GBytes *_cert; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NM_SETTING_802_1X_CK_SCHEME_UNKNOWN); \ \ @@ -425,7 +425,7 @@ _cert_get_path(GBytes *bytes) G_STMT_START \ { \ NMSetting8021x *const _setting = (setting); \ - GBytes * _cert; \ + GBytes *_cert; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NULL); \ \ @@ -441,7 +441,7 @@ _cert_get_path(GBytes *bytes) G_STMT_START \ { \ NMSetting8021x *const _setting = (setting); \ - GBytes * _cert; \ + GBytes *_cert; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NULL); \ \ @@ -457,7 +457,7 @@ _cert_get_path(GBytes *bytes) G_STMT_START \ { \ NMSetting8021x *const _setting = (setting); \ - GBytes * _cert; \ + GBytes *_cert; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NULL); \ \ @@ -470,20 +470,20 @@ _cert_get_path(GBytes *bytes) G_STMT_END static gboolean -_cert_impl_set(NMSetting8021x * setting, +_cert_impl_set(NMSetting8021x *setting, _PropertyEnums property, - const char * value, - const char * password, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { NMSetting8021xPrivate *priv; NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gs_unref_bytes GBytes *cert = NULL; - GBytes ** p_cert = NULL; - GBytes ** p_client_cert = NULL; - char ** p_password = NULL; + GBytes **p_cert = NULL; + GBytes **p_client_cert = NULL; + char **p_password = NULL; _PropertyEnums notify_cert = property; _PropertyEnums notify_password = PROP_0; _PropertyEnums notify_client_cert = PROP_0; @@ -630,7 +630,7 @@ static NMSetting8021xCKFormat _cert_impl_get_key_format_from_bytes(GBytes *private_key) { const char *path; - GError * error = NULL; + GError *error = NULL; if (!private_key) return NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; @@ -660,7 +660,7 @@ _cert_impl_get_key_format_from_bytes(GBytes *private_key) } #define _cert_impl_get_key_format(setting, private_key_field) \ ({ \ - NMSetting8021x * _setting = (setting); \ + NMSetting8021x *_setting = (setting); \ NMSetting8021xPrivate *_priv; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NM_SETTING_802_1X_CK_FORMAT_UNKNOWN); \ @@ -670,13 +670,13 @@ _cert_impl_get_key_format_from_bytes(GBytes *private_key) }) static gboolean -_cert_verify_property(GBytes * bytes, +_cert_verify_property(GBytes *bytes, const char *prop_name, const char *password, const char *password_prop_name, - GError ** error) + GError **error) { - GError * local = NULL; + GError *local = NULL; NMSetting8021xCKScheme scheme; if (!bytes) @@ -766,7 +766,7 @@ gboolean nm_setting_802_1x_add_eap_method(NMSetting8021x *setting, const char *eap) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(eap != NULL, FALSE); @@ -793,7 +793,7 @@ void nm_setting_802_1x_remove_eap_method(NMSetting8021x *setting, guint32 i) { NMSetting8021xPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_802_1X(setting)); @@ -819,7 +819,7 @@ gboolean nm_setting_802_1x_remove_eap_method_by_value(NMSetting8021x *setting, const char *eap) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(eap != NULL, FALSE); @@ -1044,11 +1044,11 @@ nm_setting_802_1x_get_ca_cert_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_ca_cert(NMSetting8021x * setting, - const char * value, +nm_setting_802_1x_set_ca_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_CA_CERT, value, NULL, scheme, out_format, error); } @@ -1160,7 +1160,7 @@ gboolean nm_setting_802_1x_add_altsubject_match(NMSetting8021x *setting, const char *altsubject_match) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(altsubject_match != NULL, FALSE); @@ -1187,7 +1187,7 @@ void nm_setting_802_1x_remove_altsubject_match(NMSetting8021x *setting, guint32 i) { NMSetting8021xPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_802_1X(setting)); @@ -1212,10 +1212,10 @@ nm_setting_802_1x_remove_altsubject_match(NMSetting8021x *setting, guint32 i) **/ gboolean nm_setting_802_1x_remove_altsubject_match_by_value(NMSetting8021x *setting, - const char * altsubject_match) + const char *altsubject_match) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(altsubject_match != NULL, FALSE); @@ -1377,11 +1377,11 @@ nm_setting_802_1x_get_client_cert_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_client_cert(NMSetting8021x * setting, - const char * value, +nm_setting_802_1x_set_client_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_CLIENT_CERT, value, NULL, scheme, out_format, error); } @@ -1635,11 +1635,11 @@ nm_setting_802_1x_get_phase2_ca_cert_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_phase2_ca_cert(NMSetting8021x * setting, - const char * value, +nm_setting_802_1x_set_phase2_ca_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_PHASE2_CA_CERT, value, NULL, scheme, out_format, error); } @@ -1782,10 +1782,10 @@ nm_setting_802_1x_get_phase2_altsubject_match(NMSetting8021x *setting, guint32 i **/ gboolean nm_setting_802_1x_add_phase2_altsubject_match(NMSetting8021x *setting, - const char * phase2_altsubject_match) + const char *phase2_altsubject_match) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(phase2_altsubject_match != NULL, FALSE); @@ -1813,7 +1813,7 @@ void nm_setting_802_1x_remove_phase2_altsubject_match(NMSetting8021x *setting, guint32 i) { NMSetting8021xPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_802_1X(setting)); @@ -1838,10 +1838,10 @@ nm_setting_802_1x_remove_phase2_altsubject_match(NMSetting8021x *setting, guint3 **/ gboolean nm_setting_802_1x_remove_phase2_altsubject_match_by_value(NMSetting8021x *setting, - const char * phase2_altsubject_match) + const char *phase2_altsubject_match) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(phase2_altsubject_match != NULL, FALSE); @@ -1975,11 +1975,11 @@ nm_setting_802_1x_get_phase2_client_cert_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_phase2_client_cert(NMSetting8021x * setting, - const char * value, +nm_setting_802_1x_set_phase2_client_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_PHASE2_CLIENT_CERT, value, NULL, scheme, out_format, error); } @@ -2227,12 +2227,12 @@ nm_setting_802_1x_get_private_key_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_private_key(NMSetting8021x * setting, - const char * value, - const char * password, +nm_setting_802_1x_set_private_key(NMSetting8021x *setting, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_PRIVATE_KEY, value, password, scheme, out_format, error); } @@ -2430,12 +2430,12 @@ nm_setting_802_1x_get_phase2_private_key_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_phase2_private_key(NMSetting8021x * setting, - const char * value, - const char * password, +nm_setting_802_1x_set_phase2_private_key(NMSetting8021x *setting, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_PHASE2_PRIVATE_KEY, @@ -2521,10 +2521,10 @@ need_secrets_sim(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) } static gboolean -need_private_key_password(GBytes * blob, +need_private_key_password(GBytes *blob, NMSetting8021xCKScheme scheme, - const char * path, - const char * password, + const char *path, + const char *password, NMSettingSecretFlags flags) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; @@ -2554,8 +2554,8 @@ need_secrets_tls(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); NMSetting8021xCKScheme scheme; - GBytes * blob = NULL; - const char * path = NULL; + GBytes *blob = NULL; + const char *path = NULL; if (phase2) { scheme = nm_setting_802_1x_get_phase2_private_key_scheme(self); @@ -2823,7 +2823,7 @@ static void need_secrets_phase2(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - char * method = NULL; + char *method = NULL; int i; g_return_if_fail(phase2 == FALSE); @@ -2871,9 +2871,9 @@ static const EAPMethodsTable eap_methods_table[] = { static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSetting8021x * self = NM_SETTING_802_1X(setting); + NMSetting8021x *self = NM_SETTING_802_1X(setting); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - const char * valid_eap[] = + const char *valid_eap[] = {"leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd", "external", NULL}; GSList *iter; @@ -3057,10 +3057,10 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) static GPtrArray * need_secrets(NMSetting *setting) { - NMSetting8021x * self = NM_SETTING_802_1X(setting); + NMSetting8021x *self = NM_SETTING_802_1X(setting); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - GSList * iter; - GPtrArray * secrets; + GSList *iter; + GPtrArray *secrets; gboolean eap_method_found = FALSE; secrets = g_ptr_array_sized_new(4); @@ -3099,7 +3099,7 @@ need_secrets(NMSetting *setting) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSetting8021x * setting = NM_SETTING_802_1X(object); + NMSetting8021x *setting = NM_SETTING_802_1X(object); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(setting); switch (prop_id) { @@ -3121,7 +3121,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSetting8021x * setting = NM_SETTING_802_1X(object); + NMSetting8021x *setting = NM_SETTING_802_1X(object); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(setting); switch (prop_id) { @@ -3165,7 +3165,7 @@ nm_setting_802_1x_new(void) static void finalize(GObject *object) { - NMSetting8021x * self = NM_SETTING_802_1X(object); + NMSetting8021x *self = NM_SETTING_802_1X(object); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); g_slist_free_full(priv->eap, g_free); @@ -3178,9 +3178,9 @@ finalize(GObject *object) static void nm_setting_802_1x_class_init(NMSetting8021xClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSetting8021xPrivate)); diff --git a/src/libnm-core-impl/nm-setting-adsl.c b/src/libnm-core-impl/nm-setting-adsl.c index 8e5dc8cfca..88606b69a0 100644 --- a/src/libnm-core-impl/nm-setting-adsl.c +++ b/src/libnm-core-impl/nm-setting-adsl.c @@ -31,10 +31,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_USERNAME, PROP_VCI, ); typedef struct { - char * username; - char * password; - char * protocol; - char * encapsulation; + char *username; + char *password; + char *protocol; + char *encapsulation; guint password_flags; guint32 vpi; guint32 vci; @@ -228,7 +228,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (priv->password && *priv->password) return NULL; @@ -263,9 +263,9 @@ nm_setting_adsl_new(void) static void nm_setting_adsl_class_init(NMSettingAdslClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingAdslPrivate)); diff --git a/src/libnm-core-impl/nm-setting-bluetooth.c b/src/libnm-core-impl/nm-setting-bluetooth.c index 53e4912f79..f657ff131a 100644 --- a/src/libnm-core-impl/nm-setting-bluetooth.c +++ b/src/libnm-core-impl/nm-setting-bluetooth.c @@ -100,7 +100,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE(setting); - const char * type; + const char *type; gboolean missing_nap_bridge = FALSE; if (priv->bdaddr && !nm_utils_hwaddr_valid(priv->bdaddr, ETH_ALEN)) { @@ -250,9 +250,9 @@ nm_setting_bluetooth_new(void) static void nm_setting_bluetooth_class_init(NMSettingBluetoothClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingBluetoothPrivate)); diff --git a/src/libnm-core-impl/nm-setting-bond-port.c b/src/libnm-core-impl/nm-setting-bond-port.c index 4538e8b9f5..9b41a74f96 100644 --- a/src/libnm-core-impl/nm-setting-bond-port.c +++ b/src/libnm-core-impl/nm-setting-bond-port.c @@ -72,7 +72,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) { if (connection) { NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(connection); if (!s_con) { @@ -127,9 +127,9 @@ nm_setting_bond_port_new(void) static void nm_setting_bond_port_class_init(NMSettingBondPortClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-bond.c b/src/libnm-core-impl/nm-setting-bond.c index e81130cd38..ae2fe051b2 100644 --- a/src/libnm-core-impl/nm-setting-bond.c +++ b/src/libnm-core-impl/nm-setting-bond.c @@ -34,7 +34,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingBond, PROP_OPTIONS, ); typedef struct { - GHashTable * options; + GHashTable *options; NMUtilsNamedValue *options_idx_cache; } NMSettingBondPrivate; @@ -95,7 +95,7 @@ static const char *const valid_options_lst[] = { }; typedef struct { - const char * val; + const char *val; NMBondOptionType opt_type; guint min; guint max; @@ -449,8 +449,8 @@ _ensure_options_idx_cache(NMSettingBondPrivate *priv) gboolean nm_setting_bond_get_option(NMSettingBond *setting, guint32 idx, - const char ** out_name, - const char ** out_value) + const char **out_name, + const char **out_value) { NMSettingBondPrivate *priv; guint len; @@ -778,17 +778,17 @@ _nm_setting_bond_get_option_type(NMSettingBond *setting, const char *name) static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingBond * self = NM_SETTING_BOND(setting); - NMSettingBondPrivate * priv = NM_SETTING_BOND_GET_PRIVATE(setting); + NMSettingBond *self = NM_SETTING_BOND(setting); + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE(setting); int miimon; int arp_interval; int num_grat_arp; int num_unsol_na; int peer_notif_delay; - const char * mode_str; - const char * arp_ip_target = NULL; - const char * lacp_rate; - const char * primary; + const char *mode_str; + const char *arp_ip_target = NULL; + const char *lacp_rate; + const char *primary; NMBondMode bond_mode; guint i; const NMUtilsNamedValue *n; @@ -1062,7 +1062,7 @@ static gboolean options_equal_asym(NMSettingBond *s_bond, NMSettingBond *s_bond2, NMSettingCompareFlags flags) { GHashTableIter iter; - const char * key, *value; + const char *key, *value; g_hash_table_iter_init(&iter, NM_SETTING_BOND_GET_PRIVATE(s_bond)->options); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) { @@ -1169,9 +1169,9 @@ finalize(GObject *object) static void nm_setting_bond_class_init(NMSettingBondClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingBondPrivate)); diff --git a/src/libnm-core-impl/nm-setting-bridge-port.c b/src/libnm-core-impl/nm-setting-bridge-port.c index 48ad74a143..b94a348e8b 100644 --- a/src/libnm-core-impl/nm-setting-bridge-port.c +++ b/src/libnm-core-impl/nm-setting-bridge-port.c @@ -318,7 +318,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(connection); if (!s_con) { @@ -451,9 +451,9 @@ finalize(GObject *object) static void nm_setting_bridge_port_class_init(NMSettingBridgePortClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingBridgePortPrivate)); diff --git a/src/libnm-core-impl/nm-setting-bridge.c b/src/libnm-core-impl/nm-setting-bridge.c index 9045d6196f..e65dcfd329 100644 --- a/src/libnm-core-impl/nm-setting-bridge.c +++ b/src/libnm-core-impl/nm-setting-bridge.c @@ -57,10 +57,10 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingBridge, typedef struct { GPtrArray *vlans; - char * mac_address; - char * multicast_router; - char * group_address; - char * vlan_protocol; + char *mac_address; + char *multicast_router; + char *group_address; + char *vlan_protocol; guint64 multicast_last_member_interval; guint64 multicast_membership_interval; guint64 multicast_querier_interval; @@ -465,12 +465,12 @@ nm_bridge_vlan_to_str(const NMBridgeVlan *vlan, GError **error) NMBridgeVlan * nm_bridge_vlan_from_str(const char *str, GError **error) { - NMBridgeVlan * vlan = NULL; + NMBridgeVlan *vlan = NULL; gs_free const char **tokens = NULL; guint i, vid_start, vid_end = 0; gboolean pvid = FALSE; gboolean untagged = FALSE; - char * c; + char *c; g_return_val_if_fail(str, NULL); g_return_val_if_fail(!error || !*error, NULL); @@ -868,7 +868,7 @@ gboolean nm_setting_bridge_remove_vlan_by_vid(NMSettingBridge *setting, guint16 vid_start, guint16 vid_end) { NMSettingBridgePrivate *priv; - NMBridgeVlan * vlan; + NMBridgeVlan *vlan; guint i; g_return_val_if_fail(NM_IS_SETTING_BRIDGE(setting), FALSE); @@ -1398,9 +1398,9 @@ finalize(GObject *object) static void nm_setting_bridge_class_init(NMSettingBridgeClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-cdma.c b/src/libnm-core-impl/nm-setting-cdma.c index 214f3b918b..46f29f969b 100644 --- a/src/libnm-core-impl/nm-setting-cdma.c +++ b/src/libnm-core-impl/nm-setting-cdma.c @@ -29,9 +29,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_NUMBER, PROP_MTU, ); typedef struct { - char * number; - char * username; - char * password; + char *number; + char *username; + char *password; guint32 mtu; NMSettingSecretFlags password_flags; } NMSettingCdmaPrivate; @@ -177,7 +177,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (!nm_str_is_empty(priv->password)) return NULL; @@ -214,9 +214,9 @@ nm_setting_cdma_new(void) static void nm_setting_cdma_class_init(NMSettingCdmaClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingCdmaPrivate)); diff --git a/src/libnm-core-impl/nm-setting-connection.c b/src/libnm-core-impl/nm-setting-connection.c index 322250f884..8fe1e87274 100644 --- a/src/libnm-core-impl/nm-setting-connection.c +++ b/src/libnm-core-impl/nm-setting-connection.c @@ -39,7 +39,7 @@ typedef enum _nm_packed { typedef struct { PermType ptype; - char * item; + char *item; } Permission; NM_GOBJECT_PROPERTIES_DEFINE(NMSettingConnection, @@ -73,15 +73,15 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingConnection, 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; + 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; @@ -322,12 +322,12 @@ nm_setting_connection_get_num_permissions(NMSettingConnection *setting) gboolean nm_setting_connection_get_permission(NMSettingConnection *setting, guint32 idx, - const char ** out_ptype, - const char ** out_pitem, - const char ** out_detail) + const char **out_ptype, + const char **out_pitem, + const char **out_detail) { NMSettingConnectionPrivate *priv; - Permission * permission; + Permission *permission; g_return_val_if_fail(NM_IS_SETTING_CONNECTION(setting), FALSE); @@ -408,9 +408,9 @@ nm_setting_connection_permissions_user_allowed(NMSettingConnection *setting, con */ gboolean nm_setting_connection_add_permission(NMSettingConnection *setting, - const char * ptype, - const char * pitem, - const char * detail) + const char *ptype, + const char *pitem, + const char *detail) { NMSettingConnectionPrivate *priv; guint i; @@ -487,9 +487,9 @@ nm_setting_connection_remove_permission(NMSettingConnection *setting, guint32 id */ gboolean nm_setting_connection_remove_permission_by_value(NMSettingConnection *setting, - const char * ptype, - const char * pitem, - const char * detail) + const char *ptype, + const char *pitem, + const char *detail) { NMSettingConnectionPrivate *priv; guint i; @@ -1009,20 +1009,20 @@ _set_error_missing_base_setting(GError **error, const char *type) gboolean _nm_connection_detect_slave_type_full(NMSettingConnection *s_con, - NMConnection * connection, - const char ** out_slave_type, - const char ** out_normerr_slave_setting_type, - const char ** out_normerr_missing_slave_type, - const char ** out_normerr_missing_slave_type_port, - GError ** error) + NMConnection *connection, + const char **out_slave_type, + const char **out_normerr_slave_setting_type, + const char **out_normerr_missing_slave_type, + const char **out_normerr_missing_slave_type_port, + GError **error) { NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(s_con); gboolean is_slave; - const char * slave_setting_type; - const char * slave_type; - const char * normerr_slave_setting_type = NULL; - const char * normerr_missing_slave_type = NULL; - const char * normerr_missing_slave_type_port = NULL; + const char *slave_setting_type; + const char *slave_type; + const char *normerr_slave_setting_type = NULL; + const char *normerr_missing_slave_type = NULL; + const char *normerr_missing_slave_type_port = NULL; is_slave = FALSE; slave_setting_type = NULL; @@ -1094,14 +1094,14 @@ _nm_connection_detect_slave_type_full(NMSettingConnection *s_con, static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingConnection * self = NM_SETTING_CONNECTION(setting); + NMSettingConnection *self = NM_SETTING_CONNECTION(setting); NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(self); - NMSetting * normerr_base_type = NULL; - const char * type; - const char * slave_type; - const char * normerr_slave_setting_type = NULL; - const char * normerr_missing_slave_type = NULL; - const char * normerr_missing_slave_type_port = NULL; + NMSetting *normerr_base_type = NULL; + const char *type; + const char *slave_type; + const char *normerr_slave_setting_type = NULL; + const char *normerr_missing_slave_type = NULL; + const char *normerr_missing_slave_type_port = NULL; gboolean normerr_base_setting = FALSE; gboolean uuid_was_normalized = FALSE; @@ -1187,7 +1187,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /* Make sure the corresponding 'type' item is present */ if (connection && !nm_connection_get_setting_by_name(connection, type)) { - NMSetting * s_base; + NMSetting *s_base; NMConnection *connection2; s_base = g_object_new(base_type, NULL); @@ -1206,7 +1206,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } if (priv->interface_name) { - GError * tmp_error = NULL; + GError *tmp_error = NULL; NMUtilsIfaceType iface_type; if (NM_IN_STRSET(type, @@ -1215,7 +1215,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) iface_type = NMU_IFACE_OVS; else if (nm_streq(type, NM_SETTING_OVS_INTERFACE_SETTING_NAME)) { NMSettingOvsInterface *s_ovs_iface = NULL; - const char * ovs_iface_type; + const char *ovs_iface_type; if (connection) s_ovs_iface = nm_connection_get_setting_ovs_interface(connection); @@ -1533,7 +1533,7 @@ after_interface_name: static const char * find_virtual_interface_name(GVariant *connection_dict, GVariant **variant_to_free) { - GVariant * setting_dict; + GVariant *setting_dict; const char *interface_name; nm_assert(variant_to_free && !*variant_to_free); @@ -1569,7 +1569,7 @@ find_virtual_interface_name(GVariant *connection_dict, GVariant **variant_to_fre static gboolean nm_setting_connection_no_interface_name(_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil) { - const char * virtual_interface_name; + const char *virtual_interface_name; gs_unref_variant GVariant *variant_to_free = NULL; virtual_interface_name = find_virtual_interface_name(connection_dict, &variant_to_free); @@ -1615,7 +1615,7 @@ compare_fcn_timestamp(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingConnection * setting = NM_SETTING_CONNECTION(object); + NMSettingConnection *setting = NM_SETTING_CONNECTION(object); NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(setting); switch (prop_id) { @@ -1717,9 +1717,9 @@ finalize(GObject *object) static void nm_setting_connection_class_init(NMSettingConnectionClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingConnectionPrivate)); diff --git a/src/libnm-core-impl/nm-setting-dcb.c b/src/libnm-core-impl/nm-setting-dcb.c index a6f4a973e5..d689089124 100644 --- a/src/libnm-core-impl/nm-setting-dcb.c +++ b/src/libnm-core-impl/nm-setting-dcb.c @@ -48,7 +48,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingDcb, PROP_PRIORITY_TRAFFIC_CLASS, ); typedef struct { - char * app_fcoe_mode; + char *app_fcoe_mode; guint pfc[8]; guint priority_group_id[8]; guint priority_group_bandwidth[8]; @@ -514,14 +514,14 @@ check_dcb_flags(NMSettingDcbFlags flags, const char *prop_name, GError **error) } static gboolean -check_uint_array(const guint * array, +check_uint_array(const guint *array, guint len, NMSettingDcbFlags flags, guint max, guint extra, gboolean sum_pct, - const char * prop_name, - GError ** error) + const char *prop_name, + GError **error) { guint i, sum = 0; @@ -714,7 +714,7 @@ G_STATIC_ASSERT(sizeof(guint) == sizeof(gboolean)); static void set_array_from_gvalue(const GValue *v, uint *a, size_t len) { - GArray * src = g_value_get_boxed(v); + GArray *src = g_value_get_boxed(v); const guint total_len = len * sizeof(a[0]); memset(a, 0, total_len); @@ -761,7 +761,7 @@ static const NMSettInfoPropertType nm_sett_info_propert_type_dcb_au = static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingDcb * setting = NM_SETTING_DCB(object); + NMSettingDcb *setting = NM_SETTING_DCB(object); NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE(setting); switch (prop_id) { @@ -841,9 +841,9 @@ nm_setting_dcb_new(void) static void nm_setting_dcb_class_init(NMSettingDcbClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingDcbPrivate)); diff --git a/src/libnm-core-impl/nm-setting-ethtool.c b/src/libnm-core-impl/nm-setting-ethtool.c index 901dab487f..49c0d78097 100644 --- a/src/libnm-core-impl/nm-setting-ethtool.c +++ b/src/libnm-core-impl/nm-setting-ethtool.c @@ -212,14 +212,14 @@ nm_setting_ethtool_clear_features(NMSettingEthtool *setting) guint nm_setting_ethtool_init_features( NMSettingEthtool *setting, - NMOptionBool * requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */) + NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */) { - GHashTable * hash; + GHashTable *hash; GHashTableIter iter; guint i; guint n_req = 0; - const char * name; - GVariant * variant; + const char *name; + GVariant *variant; nm_assert(NM_IS_SETTING_ETHTOOL(setting)); nm_assert(requested); @@ -286,7 +286,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { const char *const *optnames; - GVariant *const * variants; + GVariant *const *variants; guint len; guint i; NMTernary pause_autoneg = NM_TERNARY_DEFAULT; @@ -296,8 +296,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) len = _nm_setting_option_get_all(setting, &optnames, &variants); for (i = 0; i < len; i++) { - const char * optname = optnames[i]; - GVariant * variant = variants[i]; + const char *optname = optnames[i]; + GVariant *variant = variants[i]; const GVariantType *variant_type; NMEthtoolID ethtool_id; diff --git a/src/libnm-core-impl/nm-setting-gsm.c b/src/libnm-core-impl/nm-setting-gsm.c index 8b2749d9ae..22f3e6e54c 100644 --- a/src/libnm-core-impl/nm-setting-gsm.c +++ b/src/libnm-core-impl/nm-setting-gsm.c @@ -39,15 +39,15 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_AUTO_CONFIG, PROP_MTU, ); typedef struct { - char * number; /* For dialing, duh */ - char * username; - char * password; - char * device_id; - char * sim_id; - char * sim_operator_id; - char * apn; /* NULL for dynamic */ - char * network_id; /* for manual registration or NULL for automatic */ - char * pin; + char *number; /* For dialing, duh */ + char *username; + char *password; + char *device_id; + char *sim_id; + char *sim_operator_id; + char *apn; /* NULL for dynamic */ + char *network_id; /* for manual registration or NULL for automatic */ + char *pin; NMSettingSecretFlags password_flags; NMSettingSecretFlags pin_flags; guint32 mtu; @@ -463,7 +463,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (priv->password && *priv->password) return NULL; @@ -538,7 +538,7 @@ static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE(object); - char * tmp; + char *tmp; switch (prop_id) { case PROP_AUTO_CONFIG: @@ -644,9 +644,9 @@ finalize(GObject *object) static void nm_setting_gsm_class_init(NMSettingGsmClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingGsmPrivate)); diff --git a/src/libnm-core-impl/nm-setting-hostname.c b/src/libnm-core-impl/nm-setting-hostname.c index d0a1568435..276a75a862 100644 --- a/src/libnm-core-impl/nm-setting-hostname.c +++ b/src/libnm-core-impl/nm-setting-hostname.c @@ -145,9 +145,9 @@ nm_setting_hostname_new(void) static void nm_setting_hostname_class_init(NMSettingHostnameClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-infiniband.c b/src/libnm-core-impl/nm-setting-infiniband.c index adbf3636a6..7acdac5b92 100644 --- a/src/libnm-core-impl/nm-setting-infiniband.c +++ b/src/libnm-core-impl/nm-setting-infiniband.c @@ -32,10 +32,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MAC_ADDRESS, PROP_PARENT, ); typedef struct { - char * mac_address; - char * transport_mode; - char * parent; - char * virtual_iface_name; + char *mac_address; + char *transport_mode; + char *parent; + char *virtual_iface_name; int p_key; guint32 mtu; } NMSettingInfinibandPrivate; @@ -169,7 +169,7 @@ nm_setting_infiniband_get_virtual_interface_name(NMSettingInfiniband *setting) static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingConnection * s_con = NULL; + NMSettingConnection *s_con = NULL; NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(setting); if (priv->mac_address && !nm_utils_hwaddr_valid(priv->mac_address, INFINIBAND_ALEN)) { @@ -388,9 +388,9 @@ finalize(GObject *object) static void nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingInfinibandPrivate)); diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index 33779ed952..bdbd17aace 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -311,8 +311,8 @@ nm_ip_address_cmp_full(const NMIPAddress *a, const NMIPAddress *b, NMIPAddressCm if (NM_FLAGS_HAS(cmp_flags, NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS)) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; + const char *key; + GVariant *value, *value2; guint n; n = a->attributes ? g_hash_table_size(a->attributes) : 0u; @@ -382,8 +382,8 @@ nm_ip_address_dup(NMIPAddress *address) copy = nm_ip_address_new(address->family, address->address, address->prefix, NULL); if (address->attributes) { GHashTableIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_hash_table_iter_init(&iter, address->attributes); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) @@ -609,9 +609,9 @@ struct NMIPRoute { guint refcount; int family; - char * dest; + char *dest; guint prefix; - char * next_hop; + char *next_hop; gint64 metric; GHashTable *attributes; @@ -637,7 +637,7 @@ nm_ip_route_new(int family, guint prefix, const char *next_hop, gint64 metric, - GError ** error) + GError **error) { NMIPRoute *route; @@ -686,7 +686,7 @@ nm_ip_route_new_binary(int family, guint prefix, gconstpointer next_hop, gint64 metric, - GError ** error) + GError **error) { NMIPRoute *route; @@ -783,8 +783,8 @@ nm_ip_route_equal_full(NMIPRoute *route, NMIPRoute *other, guint cmp_flags) return FALSE; if (cmp_flags == NM_IP_ROUTE_EQUAL_CMP_FLAGS_WITH_ATTRS) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; + const char *key; + GVariant *value, *value2; guint n; n = route->attributes ? g_hash_table_size(route->attributes) : 0u; @@ -850,8 +850,8 @@ nm_ip_route_dup(NMIPRoute *route) NULL); if (route->attributes) { GHashTableIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_hash_table_iter_init(&iter, route->attributes); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) @@ -1307,10 +1307,10 @@ nm_ip_route_get_variant_attribute_spec(void) */ gboolean nm_ip_route_attribute_validate(const char *name, - GVariant * value, + GVariant *value, int family, - gboolean * known, - GError ** error) + gboolean *known, + GError **error) { const NMVariantAttributeSpec *spec; @@ -1369,8 +1369,8 @@ nm_ip_route_attribute_validate(const char *name, case 'p': /* IP address + optional prefix */ { gs_free char *addr_free = NULL; - const char * addr = string; - const char * str; + const char *addr = string; + const char *str; str = strchr(addr, '/'); if (str) { @@ -1418,11 +1418,11 @@ nm_ip_route_attribute_validate(const char *name, gboolean _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error) { - NMUtilsNamedValue attrs_static[G_N_ELEMENTS(ip_route_attribute_spec)]; + NMUtilsNamedValue attrs_static[G_N_ELEMENTS(ip_route_attribute_spec)]; gs_free NMUtilsNamedValue *attrs_free = NULL; - const NMUtilsNamedValue * attrs; + const NMUtilsNamedValue *attrs; guint attrs_len; - GVariant * val; + GVariant *val; guint i; guint8 u8; @@ -1438,7 +1438,7 @@ _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error) &attrs_free); for (i = 0; i < attrs_len; i++) { const char *key = attrs[i].name; - GVariant * val2 = attrs[i].value_ptr; + GVariant *val2 = attrs[i].value_ptr; if (!nm_ip_route_attribute_validate(key, val2, route->family, NULL, error)) return FALSE; @@ -1475,10 +1475,10 @@ _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error) struct NMIPRoutingRule { NMIPAddr from_bin; NMIPAddr to_bin; - char * from_str; - char * to_str; - char * iifname; - char * oifname; + char *from_str; + char *to_str; + char *iifname; + char *oifname; guint ref_count; guint32 priority; guint32 table; @@ -2254,7 +2254,7 @@ nm_ip_routing_rule_get_xifname_bin(const NMIPRoutingRule *self, char out_xifname[static 16 /* IFNAMSIZ */]) { gs_free gpointer bin_to_free = NULL; - const char * xifname; + const char *xifname; gconstpointer bin; gsize len; @@ -2448,8 +2448,8 @@ nm_ip_routing_rule_set_suppress_prefixlength(NMIPRoutingRule *self, gint32 suppr */ gboolean nm_ip_routing_rule_get_uid_range(const NMIPRoutingRule *self, - guint32 * out_range_start, - guint32 * out_range_end) + guint32 *out_range_start, + guint32 *out_range_end) { g_return_val_if_fail(NM_IS_IP_ROUTING_RULE(self, TRUE), -1); @@ -2590,7 +2590,7 @@ _rr_xport_range_parse(char *str, gint64 *out_start, guint16 *out_end) { guint16 start, end; gint64 i64; - char * s; + char *s; s = strchr(str, '-'); if (s) @@ -2823,7 +2823,7 @@ typedef enum { } RRDbusAttr; typedef struct { - const char * name; + const char *name; const GVariantType *dbus_type; } RRDbusData; @@ -2905,16 +2905,16 @@ _rr_variants_free(GVariant *(*p_variants)[]) NMIPRoutingRule * nm_ip_routing_rule_from_dbus(GVariant *variant, gboolean strict, GError **error) { - nm_auto(_rr_variants_free) GVariant *variants[_RR_DBUS_ATTR_NUM] = {}; - nm_auto_unref_ip_routing_rule NMIPRoutingRule *self = NULL; + nm_auto(_rr_variants_free) GVariant *variants[_RR_DBUS_ATTR_NUM] = {}; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *self = NULL; RRDbusAttr attr; GVariantIter iter; - const char * iter_key; - GVariant * iter_val; + const char *iter_key; + GVariant *iter_val; int addr_family; int i; - GVariant * v_start; - GVariant * v_end; + GVariant *v_start; + GVariant *v_end; g_variant_iter_init(&iter, variant); @@ -3216,8 +3216,8 @@ nm_ip_routing_rule_to_dbus(const NMIPRoutingRule *self) static gboolean _rr_string_validate(gboolean for_from /* or else to-string */, NMIPRoutingRuleAsStringFlags to_string_flags, - GHashTable * extra_args, - GError ** error) + GHashTable *extra_args, + GError **error) { if (NM_FLAGS_ANY(to_string_flags, ~(NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET @@ -3266,21 +3266,21 @@ _rr_string_addr_family_from_flags(NMIPRoutingRuleAsStringFlags to_string_flags) * Since: 1.18 */ NMIPRoutingRule * -nm_ip_routing_rule_from_string(const char * str, +nm_ip_routing_rule_from_string(const char *str, NMIPRoutingRuleAsStringFlags to_string_flags, - GHashTable * extra_args, - GError ** error) + GHashTable *extra_args, + GError **error) { nm_auto_unref_ip_routing_rule NMIPRoutingRule *self = NULL; - gs_free const char ** tokens = NULL; + gs_free const char **tokens = NULL; gsize i_token; gboolean any_words = FALSE; - char * word0 = NULL; - char * word1 = NULL; - char * word_from = NULL; - char * word_to = NULL; - char * word_iifname = NULL; - char * word_oifname = NULL; + char *word0 = NULL; + char *word1 = NULL; + char *word_from = NULL; + char *word_to = NULL; + char *word_iifname = NULL; + char *word_oifname = NULL; gint64 i64_priority = -1; gint64 i64_table = -1; gint64 i64_tos = -1; @@ -3302,7 +3302,7 @@ nm_ip_routing_rule_from_string(const char * str, NMIPAddr val_to = {}; int val_from_len = -1; int val_to_len = -1; - char * s; + char *s; g_return_val_if_fail(str, NULL); @@ -3688,7 +3688,7 @@ next_words_consumed: } static void -_rr_string_append_inet_addr(NMStrBuf * str, +_rr_string_append_inet_addr(NMStrBuf *str, gboolean is_from /* or else is-to */, gboolean required, int addr_family, @@ -3730,10 +3730,10 @@ _rr_string_append_inet_addr(NMStrBuf * str, * Since: 1.18 */ char * -nm_ip_routing_rule_to_string(const NMIPRoutingRule * self, +nm_ip_routing_rule_to_string(const NMIPRoutingRule *self, NMIPRoutingRuleAsStringFlags to_string_flags, - GHashTable * extra_args, - GError ** error) + GHashTable *extra_args, + GError **error) { int addr_family; NMStrBuf str; @@ -4000,7 +4000,7 @@ gboolean nm_setting_ip_config_add_dns(NMSettingIPConfig *setting, const char *dns) { NMSettingIPConfigPrivate *priv; - char * dns_canonical; + char *dns_canonical; guint i; g_return_val_if_fail(NM_IS_SETTING_IP_CONFIG(setting), FALSE); @@ -4057,7 +4057,7 @@ gboolean nm_setting_ip_config_remove_dns_by_value(NMSettingIPConfig *setting, const char *dns) { NMSettingIPConfigPrivate *priv; - char * dns_canonical; + char *dns_canonical; guint i; g_return_val_if_fail(NM_IS_SETTING_IP_CONFIG(setting), FALSE); @@ -4951,7 +4951,7 @@ nm_setting_ip_config_clear_routing_rules(NMSettingIPConfig *setting) static GVariant * _routing_rules_dbus_only_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - NMSettingIPConfig * self = NM_SETTING_IP_CONFIG(setting); + NMSettingIPConfig *self = NM_SETTING_IP_CONFIG(setting); NMSettingIPConfigPrivate *priv; GVariantBuilder builder; gboolean any = FALSE; @@ -4983,7 +4983,7 @@ static gboolean _routing_rules_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GVariantIter iter_rules; - GVariant * rule_var; + GVariant *rule_var; guint i_rule; gboolean success = FALSE; gboolean rules_changed = FALSE; @@ -4994,9 +4994,9 @@ _routing_rules_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) i_rule = 0; while (g_variant_iter_next(&iter_rules, "@a{sv}", &rule_var)) { - _nm_unused gs_unref_variant GVariant *rule_var_unref = rule_var; - nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; - gs_free_error GError *local = NULL; + _nm_unused gs_unref_variant GVariant *rule_var_unref = rule_var; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; + gs_free_error GError *local = NULL; i_rule++; @@ -5322,7 +5322,7 @@ static gboolean verify_label(const char *label) { const char *p; - char * iface; + char *iface; p = strchr(label, ':'); if (!p) @@ -5390,7 +5390,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /* Validate addresses */ for (i = 0; i < priv->addresses->len; i++) { NMIPAddress *addr = (NMIPAddress *) priv->addresses->pdata[i]; - GVariant * label; + GVariant *label; if (nm_ip_address_get_family(addr) != NM_SETTING_IP_CONFIG_GET_FAMILY(setting)) { g_set_error(error, @@ -5465,7 +5465,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /* Validate routes */ for (i = 0; i < priv->routes->len; i++) { gs_free_error GError *local = NULL; - NMIPRoute * route = (NMIPRoute *) priv->routes->pdata[i]; + NMIPRoute *route = (NMIPRoute *) priv->routes->pdata[i]; if (nm_ip_route_get_family(route) != NM_SETTING_IP_CONFIG_GET_FAMILY(setting)) { g_set_error(error, @@ -5496,7 +5496,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (priv->routing_rules) { for (i = 0; i < priv->routing_rules->len; i++) { - NMIPRoutingRule *rule = priv->routing_rules->pdata[i]; + NMIPRoutingRule *rule = priv->routing_rules->pdata[i]; gs_free_error GError *local = NULL; if (_ip_routing_rule_get_addr_family(rule) @@ -5720,14 +5720,14 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM static void enumerate_values(const NMSettInfoProperty *property_info, - NMSetting * setting, + NMSetting *setting, NMSettingValueIterFn func, gpointer user_data) { if (nm_streq(property_info->name, NM_SETTING_IP_CONFIG_ROUTING_RULES)) { - NMSettingIPConfigPrivate * priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); + NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); nm_auto_unset_gvalue GValue value = G_VALUE_INIT; - GPtrArray * ptr = NULL; + GPtrArray *ptr = NULL; guint i; if (priv->routing_rules && priv->routing_rules->len > 0) { @@ -5859,7 +5859,7 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingIPConfig * setting = NM_SETTING_IP_CONFIG(object); + NMSettingIPConfig *setting = NM_SETTING_IP_CONFIG(object); NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); switch (prop_id) { @@ -5946,9 +5946,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingIPConfig * setting = NM_SETTING_IP_CONFIG(object); + NMSettingIPConfig *setting = NM_SETTING_IP_CONFIG(object); NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); - char ** strv; + char **strv; guint i; switch (prop_id) { @@ -6079,7 +6079,7 @@ nm_setting_ip_config_init(NMSettingIPConfig *setting) static void finalize(GObject *object) { - NMSettingIPConfig * self = NM_SETTING_IP_CONFIG(object); + NMSettingIPConfig *self = NM_SETTING_IP_CONFIG(object); NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(self); g_ptr_array_unref(priv->dns); @@ -6098,7 +6098,7 @@ finalize(GObject *object) static void nm_setting_ip_config_class_init(NMSettingIPConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-core-impl/nm-setting-ip-tunnel.c b/src/libnm-core-impl/nm-setting-ip-tunnel.c index 38f9047dca..3f8529a8d3 100644 --- a/src/libnm-core-impl/nm-setting-ip-tunnel.c +++ b/src/libnm-core-impl/nm-setting-ip-tunnel.c @@ -32,11 +32,11 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_FLAGS, ); typedef struct { - char * parent; - char * local; - char * remote; - char * input_key; - char * output_key; + char *parent; + char *local; + char *remote; + char *input_key; + char *output_key; guint ttl; guint tos; guint encapsulation_limit; @@ -505,7 +505,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingIPTunnel * setting = NM_SETTING_IP_TUNNEL(object); + NMSettingIPTunnel *setting = NM_SETTING_IP_TUNNEL(object); NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting); switch (prop_id) { @@ -557,7 +557,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingIPTunnel * setting = NM_SETTING_IP_TUNNEL(object); + NMSettingIPTunnel *setting = NM_SETTING_IP_TUNNEL(object); NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting); switch (prop_id) { @@ -635,9 +635,9 @@ nm_setting_ip_tunnel_new(void) static void nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingIPTunnelPrivate)); diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index a7b3d68bd3..006275044b 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -131,9 +131,9 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting); - NMSettingIPConfig * s_ip = NM_SETTING_IP_CONFIG(setting); + NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); NMSettingVerifyResult ret; - const char * method; + const char *method; ret = NM_SETTING_CLASS(nm_setting_ip4_config_parent_class)->verify(setting, connection, error); if (ret != NM_SETTING_VERIFY_SUCCESS) @@ -344,7 +344,7 @@ static GVariant * ip4_addresses_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; - const char * gateway; + const char *gateway; g_object_get(setting, NM_SETTING_IP_CONFIG_ADDRESSES, &addrs, NULL); gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting)); @@ -355,8 +355,8 @@ static gboolean ip4_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; - GVariant * s_ip4; - char ** labels, *gateway = NULL; + GVariant *s_ip4; + char **labels, *gateway = NULL; int i; /* FIXME: properly handle errors */ @@ -397,8 +397,8 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); gboolean have_labels = FALSE; - GPtrArray * labels; - GVariant * ret; + GPtrArray *labels; + GVariant *ret; int num_addrs, i; if (!_nm_connection_serialize_non_secret(flags)) @@ -407,7 +407,7 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) num_addrs = nm_setting_ip_config_get_num_addresses(s_ip); for (i = 0; i < num_addrs; i++) { NMIPAddress *addr = nm_setting_ip_config_get_address(s_ip, i); - GVariant * label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); + GVariant *label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); if (label) { have_labels = TRUE; @@ -420,7 +420,7 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) labels = g_ptr_array_sized_new(num_addrs); for (i = 0; i < num_addrs; i++) { NMIPAddress *addr = nm_setting_ip_config_get_address(s_ip, i); - GVariant * label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); + GVariant *label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); g_ptr_array_add(labels, (char *) (label ? g_variant_get_string(label, NULL) : "")); } @@ -593,8 +593,8 @@ nm_setting_ip4_config_new(void) static void nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *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); NMSettingIPConfigClass *setting_ip_config_class = NM_SETTING_IP_CONFIG_CLASS(klass); GArray *properties_override = _nm_sett_info_property_override_create_array_ip_config(AF_INET); diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index 87b9d9581f..b66f1197e7 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -48,8 +48,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_IP6_PRIVACY, typedef struct { NMSettingIPConfigPrivate parent; - char * token; - char * dhcp_duid; + char *token; + char *dhcp_duid; NMSettingIP6ConfigPrivacy ip6_privacy; NMSettingIP6ConfigAddrGenMode addr_gen_mode; gint32 ra_timeout; @@ -175,9 +175,9 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(setting); - NMSettingIPConfig * s_ip = NM_SETTING_IP_CONFIG(setting); + NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); NMSettingVerifyResult ret; - const char * method; + const char *method; gboolean token_needs_normalization = FALSE; ret = NM_SETTING_CLASS(nm_setting_ip6_config_parent_class)->verify(setting, connection, error); @@ -385,7 +385,7 @@ static GVariant * ip6_addresses_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; - const char * gateway; + const char *gateway; g_object_get(setting, NM_SETTING_IP_CONFIG_ADDRESSES, &addrs, NULL); gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting)); @@ -396,7 +396,7 @@ static gboolean ip6_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; - char * gateway = NULL; + char *gateway = NULL; if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { *out_is_modified = FALSE; @@ -586,8 +586,8 @@ nm_setting_ip6_config_new(void) static void nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *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); NMSettingIPConfigClass *setting_ip_config_class = NM_SETTING_IP_CONFIG_CLASS(klass); GArray *properties_override = _nm_sett_info_property_override_create_array_ip_config(AF_INET6); diff --git a/src/libnm-core-impl/nm-setting-macsec.c b/src/libnm-core-impl/nm-setting-macsec.c index 1a9e9bd8ab..0579d6cbf8 100644 --- a/src/libnm-core-impl/nm-setting-macsec.c +++ b/src/libnm-core-impl/nm-setting-macsec.c @@ -38,9 +38,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_SEND_SCI, ); typedef struct { - char * parent; - char * mka_cak; - char * mka_ckn; + char *parent; + char *mka_cak; + char *mka_ckn; int port; NMSettingMacsecMode mode; NMSettingSecretFlags mka_cak_flags; @@ -212,7 +212,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (priv->mode == NM_SETTING_MACSEC_MODE_PSK) { if (!priv->mka_cak @@ -271,9 +271,9 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); - NMSettingConnection * s_con = NULL; - NMSettingWired * s_wired = NULL; - NMSetting8021x * s_8021x = NULL; + NMSettingConnection *s_con = NULL; + NMSettingWired *s_wired = NULL; + NMSetting8021x *s_8021x = NULL; if (connection) { s_con = nm_connection_get_setting_connection(connection); @@ -404,7 +404,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingMacsec * setting = NM_SETTING_MACSEC(object); + NMSettingMacsec *setting = NM_SETTING_MACSEC(object); NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); switch (prop_id) { @@ -444,7 +444,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingMacsec * setting = NM_SETTING_MACSEC(object); + NMSettingMacsec *setting = NM_SETTING_MACSEC(object); NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); switch (prop_id) { @@ -514,7 +514,7 @@ nm_setting_macsec_new(void) static void finalize(GObject *object) { - NMSettingMacsec * setting = NM_SETTING_MACSEC(object); + NMSettingMacsec *setting = NM_SETTING_MACSEC(object); NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); g_free(priv->parent); @@ -527,9 +527,9 @@ finalize(GObject *object) static void nm_setting_macsec_class_init(NMSettingMacsecClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingMacsecPrivate)); diff --git a/src/libnm-core-impl/nm-setting-macvlan.c b/src/libnm-core-impl/nm-setting-macvlan.c index 32b30c2cfa..d7a1063b44 100644 --- a/src/libnm-core-impl/nm-setting-macvlan.c +++ b/src/libnm-core-impl/nm-setting-macvlan.c @@ -28,7 +28,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_MODE, PROP_PROMISCUOUS, PROP_TAP, ); typedef struct { - char * parent; + char *parent; NMSettingMacvlanMode mode; bool promiscuous; bool tap; @@ -123,7 +123,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting); - NMSettingWired * s_wired; + NMSettingWired *s_wired; if (connection) s_wired = nm_connection_get_setting_wired(connection); @@ -182,7 +182,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingMacvlan * setting = NM_SETTING_MACVLAN(object); + NMSettingMacvlan *setting = NM_SETTING_MACVLAN(object); NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting); switch (prop_id) { @@ -207,7 +207,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingMacvlan * setting = NM_SETTING_MACVLAN(object); + NMSettingMacvlan *setting = NM_SETTING_MACVLAN(object); NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting); switch (prop_id) { @@ -254,7 +254,7 @@ nm_setting_macvlan_new(void) static void finalize(GObject *object) { - NMSettingMacvlan * setting = NM_SETTING_MACVLAN(object); + NMSettingMacvlan *setting = NM_SETTING_MACVLAN(object); NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting); g_free(priv->parent); @@ -265,9 +265,9 @@ finalize(GObject *object) static void nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingMacvlanPrivate)); diff --git a/src/libnm-core-impl/nm-setting-match.c b/src/libnm-core-impl/nm-setting-match.c index 20c6b798e6..0ddffee582 100644 --- a/src/libnm-core-impl/nm-setting-match.c +++ b/src/libnm-core-impl/nm-setting-match.c @@ -33,10 +33,10 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingMatch, */ struct _NMSettingMatch { NMSetting parent; - GArray * interface_name; - GArray * kernel_command_line; - GArray * driver; - GArray * path; + GArray *interface_name; + GArray *kernel_command_line; + GArray *driver; + GArray *path; }; struct _NMSettingMatchClass { @@ -278,7 +278,7 @@ nm_setting_match_remove_kernel_command_line(NMSettingMatch *setting, guint idx) **/ gboolean nm_setting_match_remove_kernel_command_line_by_value(NMSettingMatch *setting, - const char * kernel_command_line) + const char *kernel_command_line) { g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), FALSE); g_return_val_if_fail(kernel_command_line, FALSE); @@ -781,7 +781,7 @@ finalize(GObject *object) static void nm_setting_match_class_init(NMSettingMatchClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-core-impl/nm-setting-olpc-mesh.c b/src/libnm-core-impl/nm-setting-olpc-mesh.c index 0da1d5b427..fe6d3842e8 100644 --- a/src/libnm-core-impl/nm-setting-olpc-mesh.c +++ b/src/libnm-core-impl/nm-setting-olpc-mesh.c @@ -29,7 +29,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_SSID, PROP_CHANNEL, PROP_DHCP_ANYCAST_ADD typedef struct { GBytes *ssid; - char * dhcp_anycast_addr; + char *dhcp_anycast_addr; guint32 channel; } NMSettingOlpcMeshPrivate; @@ -167,9 +167,9 @@ nm_setting_olpc_mesh_new(void) static void nm_setting_olpc_mesh_class_init(NMSettingOlpcMeshClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingOlpcMeshPrivate)); diff --git a/src/libnm-core-impl/nm-setting-ovs-bridge.c b/src/libnm-core-impl/nm-setting-ovs-bridge.c index 711d5461c1..e62c7eaec3 100644 --- a/src/libnm-core-impl/nm-setting-ovs-bridge.c +++ b/src/libnm-core-impl/nm-setting-ovs-bridge.c @@ -289,9 +289,9 @@ finalize(GObject *object) static void nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-ovs-dpdk.c b/src/libnm-core-impl/nm-setting-ovs-dpdk.c index 3107531b27..cca6a11bc5 100644 --- a/src/libnm-core-impl/nm-setting-ovs-dpdk.c +++ b/src/libnm-core-impl/nm-setting-ovs-dpdk.c @@ -125,7 +125,7 @@ finalize(GObject *object) static void nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-ovs-external-ids.c b/src/libnm-core-impl/nm-setting-ovs-external-ids.c index ea4004f042..02ade4f4b8 100644 --- a/src/libnm-core-impl/nm-setting-ovs-external-ids.c +++ b/src/libnm-core-impl/nm-setting-ovs-external-ids.c @@ -28,7 +28,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingOvsExternalIDs, PROP_DATA, ); typedef struct { - GHashTable * data; + GHashTable *data; const char **data_keys; } NMSettingOvsExternalIDsPrivate; @@ -199,7 +199,7 @@ _nm_setting_ovs_external_ids_get_data(NMSettingOvsExternalIDs *self) const char *const * nm_setting_ovs_external_ids_get_data_keys(NMSettingOvsExternalIDs *setting, guint *out_len) { - NMSettingOvsExternalIDs * self = setting; + NMSettingOvsExternalIDs *self = setting; NMSettingOvsExternalIDsPrivate *priv; g_return_val_if_fail(NM_IS_SETTING_OVS_EXTERNAL_IDS(self), NULL); @@ -233,7 +233,7 @@ nm_setting_ovs_external_ids_get_data_keys(NMSettingOvsExternalIDs *setting, guin const char * nm_setting_ovs_external_ids_get_data(NMSettingOvsExternalIDs *setting, const char *key) { - NMSettingOvsExternalIDs * self = setting; + NMSettingOvsExternalIDs *self = setting; NMSettingOvsExternalIDsPrivate *priv; g_return_val_if_fail(NM_IS_SETTING_OVS_EXTERNAL_IDS(self), NULL); @@ -257,10 +257,10 @@ nm_setting_ovs_external_ids_get_data(NMSettingOvsExternalIDs *setting, const cha */ void nm_setting_ovs_external_ids_set_data(NMSettingOvsExternalIDs *setting, - const char * key, - const char * val) + const char *key, + const char *val) { - NMSettingOvsExternalIDs * self = setting; + NMSettingOvsExternalIDs *self = setting; NMSettingOvsExternalIDsPrivate *priv; g_return_if_fail(NM_IS_SETTING_OVS_EXTERNAL_IDS(self)); @@ -295,14 +295,14 @@ out_changed: static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingOvsExternalIDs * self = NM_SETTING_OVS_EXTERNAL_IDS(setting); + NMSettingOvsExternalIDs *self = NM_SETTING_OVS_EXTERNAL_IDS(setting); NMSettingOvsExternalIDsPrivate *priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(self); if (priv->data) { gs_free_error GError *local = NULL; GHashTableIter iter; - const char * key; - const char * val; + const char *key; + const char *val; g_hash_table_iter_init(&iter, priv->data); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { @@ -346,8 +346,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingConnection *s_con; - const char * type; - const char * slave_type; + const char *type; + const char *slave_type; type = nm_connection_get_connection_type(connection); if (!type) { @@ -408,12 +408,12 @@ compare_fcn_data(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingOvsExternalIDs * self = NM_SETTING_OVS_EXTERNAL_IDS(object); + NMSettingOvsExternalIDs *self = NM_SETTING_OVS_EXTERNAL_IDS(object); NMSettingOvsExternalIDsPrivate *priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(self); GHashTableIter iter; - GHashTable * data; - const char * key; - const char * val; + GHashTable *data; + const char *key; + const char *val; switch (prop_id) { case PROP_DATA: @@ -434,7 +434,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingOvsExternalIDs * self = NM_SETTING_OVS_EXTERNAL_IDS(object); + NMSettingOvsExternalIDs *self = NM_SETTING_OVS_EXTERNAL_IDS(object); NMSettingOvsExternalIDsPrivate *priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(self); switch (prop_id) { @@ -442,9 +442,9 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps { gs_unref_hashtable GHashTable *old = NULL; GHashTableIter iter; - GHashTable * data; - const char * key; - const char * val; + GHashTable *data; + const char *key; + const char *val; nm_clear_g_free(&priv->data_keys); @@ -491,7 +491,7 @@ nm_setting_ovs_external_ids_new(void) static void finalize(GObject *object) { - NMSettingOvsExternalIDs * self = NM_SETTING_OVS_EXTERNAL_IDS(object); + NMSettingOvsExternalIDs *self = NM_SETTING_OVS_EXTERNAL_IDS(object); NMSettingOvsExternalIDsPrivate *priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(self); g_free(priv->data_keys); @@ -504,9 +504,9 @@ finalize(GObject *object) static void nm_setting_ovs_external_ids_class_init(NMSettingOvsExternalIDsClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-ovs-interface.c b/src/libnm-core-impl/nm-setting-ovs-interface.c index 58a01fcc4c..26ae48fb6f 100644 --- a/src/libnm-core-impl/nm-setting-ovs-interface.c +++ b/src/libnm-core-impl/nm-setting-ovs-interface.c @@ -62,12 +62,12 @@ nm_setting_ovs_interface_get_interface_type(NMSettingOvsInterface *self) int _nm_setting_ovs_interface_verify_interface_type(NMSettingOvsInterface *self, - const char * type, - NMConnection * connection, + const char *type, + NMConnection *connection, gboolean normalize, - gboolean * out_modified, - const char ** out_normalized_type, - GError ** error) + gboolean *out_modified, + const char **out_normalized_type, + GError **error) { const char *type_from_setting = NULL; const char *type_setting = NULL; @@ -276,7 +276,7 @@ static int verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingOvsInterface *self = NM_SETTING_OVS_INTERFACE(setting); - NMSettingConnection * s_con = NULL; + NMSettingConnection *s_con = NULL; if (connection) { const char *slave_type; @@ -398,7 +398,7 @@ finalize(GObject *object) static void nm_setting_ovs_interface_class_init(NMSettingOvsInterfaceClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-core-impl/nm-setting-ovs-patch.c b/src/libnm-core-impl/nm-setting-ovs-patch.c index 578f5ee247..bc54bda619 100644 --- a/src/libnm-core-impl/nm-setting-ovs-patch.c +++ b/src/libnm-core-impl/nm-setting-ovs-patch.c @@ -158,7 +158,7 @@ finalize(GObject *object) static void nm_setting_ovs_patch_class_init(NMSettingOvsPatchClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-ovs-port.c b/src/libnm-core-impl/nm-setting-ovs-port.c index fc593268ee..ab9c0a1141 100644 --- a/src/libnm-core-impl/nm-setting-ovs-port.c +++ b/src/libnm-core-impl/nm-setting-ovs-port.c @@ -36,9 +36,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_VLAN_MODE, struct _NMSettingOvsPort { NMSetting parent; - char * vlan_mode; - char * lacp; - char * bond_mode; + char *vlan_mode; + char *lacp; + char *bond_mode; guint32 tag; guint32 bond_updelay; guint32 bond_downdelay; @@ -160,7 +160,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(connection); if (!s_con) { @@ -284,9 +284,9 @@ nm_setting_ovs_port_new(void) static void nm_setting_ovs_port_class_init(NMSettingOvsPortClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-ppp.c b/src/libnm-core-impl/nm-setting-ppp.c index e4e4951e8a..a9d2b9a2c1 100644 --- a/src/libnm-core-impl/nm-setting-ppp.c +++ b/src/libnm-core-impl/nm-setting-ppp.c @@ -398,9 +398,9 @@ nm_setting_ppp_new(void) static void nm_setting_ppp_class_init(NMSettingPppClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingPppPrivate)); diff --git a/src/libnm-core-impl/nm-setting-pppoe.c b/src/libnm-core-impl/nm-setting-pppoe.c index 3ae547a24c..c4a9a89cbd 100644 --- a/src/libnm-core-impl/nm-setting-pppoe.c +++ b/src/libnm-core-impl/nm-setting-pppoe.c @@ -135,8 +135,8 @@ nm_setting_pppoe_get_password_flags(NMSettingPppoe *setting) static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(setting); - gs_free_error GError *local_error = NULL; + NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(setting); + gs_free_error GError *local_error = NULL; if (nm_str_is_empty(priv->username)) { if (!priv->username) { @@ -181,7 +181,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (priv->password) return NULL; @@ -216,9 +216,9 @@ nm_setting_pppoe_new(void) static void nm_setting_pppoe_class_init(NMSettingPppoeClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingPppoePrivate)); diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h index 7faf5d1c64..61dc7f6159 100644 --- a/src/libnm-core-impl/nm-setting-private.h +++ b/src/libnm-core-impl/nm-setting-private.h @@ -59,49 +59,49 @@ struct _NMSettingClass { int (*update_one_secret)(NMSetting *setting, const char *key, GVariant *value, GError **error); - gboolean (*get_secret_flags)(NMSetting * setting, - const char * secret_name, + gboolean (*get_secret_flags)(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error); + GError **error); - gboolean (*set_secret_flags)(NMSetting * setting, - const char * secret_name, + gboolean (*set_secret_flags)(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error); + GError **error); gboolean (*clear_secrets)(const struct _NMSettInfoSetting *sett_info, - const NMSettInfoProperty * property_info, - NMSetting * setting, + const NMSettInfoProperty *property_info, + NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); void (*padding_1)(void); void (*duplicate_copy_properties)(const struct _NMSettInfoSetting *sett_info, - NMSetting * src, - NMSetting * dst); + NMSetting *src, + NMSetting *dst); void (*enumerate_values)(const struct _NMSettInfoProperty *property_info, - NMSetting * setting, + NMSetting *setting, NMSettingValueIterFn func, gpointer user_data); gboolean (*aggregate)(NMSetting *setting, int type_i, gpointer arg); - void (*for_each_secret)(NMSetting * setting, - const char * secret_name, - GVariant * val, + void (*for_each_secret)(NMSetting *setting, + const char *secret_name, + GVariant *val, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data, - GVariantBuilder * setting_builder); + GVariantBuilder *setting_builder); - gboolean (*init_from_dbus)(NMSetting * setting, - GHashTable * keys, - GVariant * setting_dict, - GVariant * connection_dict, + gboolean (*init_from_dbus)(NMSetting *setting, + GHashTable *keys, + GVariant *setting_dict, + GVariant *connection_dict, guint /* NMSettingParseFlags */ parse_flags, - GError ** error); + GError **error); const struct _NMMetaSettingInfo *setting_info; }; @@ -134,11 +134,11 @@ typedef struct { GPtrArray *addresses; /* array of NMIPAddress */ GPtrArray *routes; /* array of NMIPRoute */ GPtrArray *routing_rules; - GArray * dhcp_reject_servers; - char * method; - char * gateway; - char * dhcp_hostname; - char * dhcp_iaid; + GArray *dhcp_reject_servers; + char *method; + char *gateway; + char *dhcp_hostname; + char *dhcp_iaid; gint64 route_metric; guint dhcp_hostname_flags; int dns_priority; @@ -226,7 +226,7 @@ typedef enum NMSettingUpdateSecretResult { NMSettingUpdateSecretResult _nm_setting_update_secrets(NMSetting *setting, GVariant *secrets, GError **error); -gboolean _nm_setting_clear_secrets(NMSetting * setting, +gboolean _nm_setting_clear_secrets(NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); @@ -289,16 +289,16 @@ _nm_setting_verify(NMSetting *setting, NMConnection *connection, GError **error) gboolean _nm_setting_verify_secret_string(const char *str, const char *setting_name, const char *property, - GError ** error); + GError **error); gboolean _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType type, gpointer arg); gboolean _nm_setting_slave_type_is_valid(const char *slave_type, const char **out_port_type); -gboolean _nm_setting_compare_flags_check(const GParamSpec * param_spec, +gboolean _nm_setting_compare_flags_check(const GParamSpec *param_spec, NMSettingCompareFlags flags, - NMSetting * set_a, - NMSetting * set_b); + NMSetting *set_a, + NMSetting *set_b); NMTernary _nm_setting_property_compare_fcn_ignore(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); @@ -306,15 +306,15 @@ NMTernary _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN NMTernary _nm_setting_property_compare_fcn_default(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); -void _nm_setting_property_get_property_direct(GObject * object, +void _nm_setting_property_get_property_direct(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec); -void _nm_setting_property_set_property_direct(GObject * object, +void _nm_setting_property_set_property_direct(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec); + GParamSpec *pspec); GVariant *_nm_setting_property_to_dbus_fcn_ignore(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); @@ -337,26 +337,26 @@ gboolean _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_ gboolean _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); -GVariant *_nm_setting_to_dbus(NMSetting * setting, - NMConnection * connection, +GVariant *_nm_setting_to_dbus(NMSetting *setting, + NMConnection *connection, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options); NMSetting *_nm_setting_new_from_dbus(GType setting_type, - GVariant * setting_dict, - GVariant * connection_dict, + GVariant *setting_dict, + GVariant *connection_dict, NMSettingParseFlags parse_flags, - GError ** error); + GError **error); gboolean _nm_setting_property_is_regular_secret(NMSetting *setting, const char *secret_name); -gboolean _nm_setting_property_is_regular_secret_flags(NMSetting * setting, +gboolean _nm_setting_property_is_regular_secret_flags(NMSetting *setting, const char *secret_flags_name); /*****************************************************************************/ const NMSettInfoProperty * _nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info, - const GParamSpec * param_spec); + const GParamSpec *param_spec); static inline GArray * _nm_sett_info_property_override_create_array_sized(guint reserved_size) @@ -375,10 +375,10 @@ _nm_sett_info_property_override_create_array(void) GArray *_nm_sett_info_property_override_create_array_ip_config(int addr_family); -void _nm_setting_class_commit(NMSettingClass * setting_class, +void _nm_setting_class_commit(NMSettingClass *setting_class, NMMetaSettingType meta_type, const NMSettInfoSettDetail *detail, - GArray * properties_override, + GArray *properties_override, gint16 private_offset); #define NM_SETT_INFO_SETT_GENDATA(...) \ @@ -464,7 +464,7 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p G_STMT_START \ { \ const gboolean _default_value = (default_value); \ - GParamSpec * _param_spec; \ + GParamSpec *_param_spec; \ \ G_STATIC_ASSERT( \ !NM_FLAGS_ANY((param_flags), \ @@ -641,7 +641,7 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p ... /* extra NMSettInfoProperty fields */) \ G_STMT_START \ { \ - GParamSpec * _param_spec; \ + GParamSpec *_param_spec; \ const NMSettInfoPropertType *_property_type = (property_type); \ \ G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \ @@ -890,16 +890,16 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p /*****************************************************************************/ -gboolean _nm_setting_use_legacy_property(NMSetting * setting, - GVariant * connection_dict, +gboolean _nm_setting_use_legacy_property(NMSetting *setting, + GVariant *connection_dict, const char *legacy_property, const char *new_property); GPtrArray *_nm_setting_need_secrets(NMSetting *setting); -gboolean _nm_setting_should_compare_secret_property(NMSetting * setting, - NMSetting * other, - const char * secret_name, +gboolean _nm_setting_should_compare_secret_property(NMSetting *setting, + NMSetting *other, + const char *secret_name, NMSettingCompareFlags flags); NMBridgeVlan *_nm_bridge_vlan_dup(const NMBridgeVlan *vlan); diff --git a/src/libnm-core-impl/nm-setting-proxy.c b/src/libnm-core-impl/nm-setting-proxy.c index 0425ec456e..4b9a297058 100644 --- a/src/libnm-core-impl/nm-setting-proxy.c +++ b/src/libnm-core-impl/nm-setting-proxy.c @@ -29,8 +29,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_METHOD, PROP_BROWSER_ONLY, PROP_PAC_URL, PROP_PAC_SCRIPT, ); typedef struct { - char * pac_url; - char * pac_script; + char *pac_url; + char *pac_script; gint32 method; bool browser_only; } NMSettingProxyPrivate; @@ -229,9 +229,9 @@ nm_setting_proxy_new(void) static void nm_setting_proxy_class_init(NMSettingProxyClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingProxyPrivate)); diff --git a/src/libnm-core-impl/nm-setting-serial.c b/src/libnm-core-impl/nm-setting-serial.c index 3ebcf0623f..a820187630 100644 --- a/src/libnm-core-impl/nm-setting-serial.c +++ b/src/libnm-core-impl/nm-setting-serial.c @@ -222,9 +222,9 @@ nm_setting_serial_new(void) static void nm_setting_serial_class_init(NMSettingSerialClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingSerialPrivate)); diff --git a/src/libnm-core-impl/nm-setting-sriov.c b/src/libnm-core-impl/nm-setting-sriov.c index a024dba6c2..4c323c0c42 100644 --- a/src/libnm-core-impl/nm-setting-sriov.c +++ b/src/libnm-core-impl/nm-setting-sriov.c @@ -49,7 +49,7 @@ struct _NMSriovVF { guint index; GHashTable *attributes; GHashTable *vlans; - guint * vlan_ids; + guint *vlan_ids; }; typedef struct { @@ -163,9 +163,9 @@ gboolean nm_sriov_vf_equal(const NMSriovVF *vf, const NMSriovVF *other) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; - VFVlan * vlan, *vlan2; + const char *key; + GVariant *value, *value2; + VFVlan *vlan, *vlan2; guint n_vlans; g_return_val_if_fail(vf, FALSE); @@ -239,11 +239,11 @@ vf_add_vlan(NMSriovVF *vf, guint vlan_id, guint qos, NMSriovVFVlanProtocol proto NMSriovVF * nm_sriov_vf_dup(const NMSriovVF *vf) { - NMSriovVF * copy; + NMSriovVF *copy; GHashTableIter iter; - const char * name; - GVariant * variant; - VFVlan * vlan; + const char *name; + GVariant *variant; + VFVlan *vlan; g_return_val_if_fail(vf, NULL); g_return_val_if_fail(vf->refcount > 0, NULL); @@ -378,7 +378,7 @@ gboolean nm_sriov_vf_attribute_validate(const char *name, GVariant *value, gboolean *known, GError **error) { const NMVariantAttributeSpec *const *iter; - const NMVariantAttributeSpec * spec = NULL; + const NMVariantAttributeSpec *spec = NULL; g_return_val_if_fail(name, FALSE); g_return_val_if_fail(value, FALSE); @@ -438,9 +438,9 @@ gboolean _nm_sriov_vf_attribute_validate_all(const NMSriovVF *vf, GError **error) { GHashTableIter iter; - const char * name; - GVariant * variant; - GVariant * min, *max; + const char *name; + GVariant *variant; + GVariant *min, *max; g_return_val_if_fail(vf, FALSE); g_return_val_if_fail(vf->refcount > 0, FALSE); @@ -546,7 +546,7 @@ const guint * nm_sriov_vf_get_vlan_ids(const NMSriovVF *vf, guint *length) { GHashTableIter iter; - VFVlan * vlan; + VFVlan *vlan; guint num, i; g_return_val_if_fail(vf, NULL); @@ -888,10 +888,10 @@ vfs_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) if (vfs) { for (i = 0; i < vfs->len; i++) { gs_free const char **attr_names = NULL; - NMSriovVF * vf = vfs->pdata[i]; + NMSriovVF *vf = vfs->pdata[i]; GVariantBuilder vf_builder; - const guint * vlan_ids; - const char ** name; + const guint *vlan_ids; + const char **name; guint num_vlans = 0; g_variant_builder_init(&vf_builder, G_VARIANT_TYPE_VARDICT); @@ -954,20 +954,20 @@ vfs_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) static gboolean vfs_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { - GPtrArray * vfs; + GPtrArray *vfs; GVariantIter vf_iter; - GVariant * vf_var; + GVariant *vf_var; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), FALSE); vfs = g_ptr_array_new_with_free_func((GDestroyNotify) nm_sriov_vf_unref); g_variant_iter_init(&vf_iter, value); while (g_variant_iter_next(&vf_iter, "@a{sv}", &vf_var)) { - NMSriovVF * vf; + NMSriovVF *vf; guint32 index; GVariantIter attr_iter; - const char * attr_name; - GVariant * attr_var, *vlans_var; + const char *attr_name; + GVariant *attr_var, *vlans_var; if (!g_variant_lookup(vf_var, "index", "u", &index)) goto next; @@ -983,7 +983,7 @@ vfs_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) if (g_variant_lookup(vf_var, "vlans", "@aa{sv}", &vlans_var)) { GVariantIter vlan_iter; - GVariant * vlan_var; + GVariant *vlan_var; g_variant_iter_init(&vlan_iter, vlans_var); while (g_variant_iter_next(&vlan_iter, "@a{sv}", &vlan_var)) { @@ -1035,7 +1035,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) h = g_hash_table_new(nm_direct_hash, NULL); for (i = 0; i < self->vfs->len; i++) { - NMSriovVF * vf = self->vfs->pdata[i]; + NMSriovVF *vf = self->vfs->pdata[i]; gs_free_error GError *local = NULL; if (vf->index >= self->total_vfs) { @@ -1218,9 +1218,9 @@ finalize(GObject *object) static void nm_setting_sriov_class_init(NMSettingSriovClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-tc-config.c b/src/libnm-core-impl/nm-setting-tc-config.c index cd13709a47..08a7f94de5 100644 --- a/src/libnm-core-impl/nm-setting-tc-config.c +++ b/src/libnm-core-impl/nm-setting-tc-config.c @@ -24,7 +24,7 @@ G_DEFINE_BOXED_TYPE(NMTCQdisc, nm_tc_qdisc, nm_tc_qdisc_dup, nm_tc_qdisc_unref) struct NMTCQdisc { guint refcount; - char * kind; + char *kind; guint32 handle; guint32 parent; GHashTable *attributes; @@ -138,8 +138,8 @@ gboolean nm_tc_qdisc_equal(NMTCQdisc *qdisc, NMTCQdisc *other) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; + const char *key; + GVariant *value, *value2; guint n; g_return_val_if_fail(qdisc != NULL, FALSE); @@ -172,9 +172,9 @@ nm_tc_qdisc_equal(NMTCQdisc *qdisc, NMTCQdisc *other) static guint _nm_tc_qdisc_hash(NMTCQdisc *qdisc) { - NMUtilsNamedValue attrs_static[30]; + NMUtilsNamedValue attrs_static[30]; gs_free NMUtilsNamedValue *attrs_free = NULL; - const NMUtilsNamedValue * attrs; + const NMUtilsNamedValue *attrs; NMHashState h; guint length; guint i; @@ -186,8 +186,8 @@ _nm_tc_qdisc_hash(NMTCQdisc *qdisc) nm_hash_update_vals(&h, qdisc->handle, qdisc->parent, length); nm_hash_update_str0(&h, qdisc->kind); for (i = 0; i < length; i++) { - const char * key = attrs[i].name; - GVariant * variant = attrs[i].value_ptr; + const char *key = attrs[i].name; + GVariant *variant = attrs[i].value_ptr; const GVariantType *vtype; vtype = g_variant_get_type(variant); @@ -224,8 +224,8 @@ nm_tc_qdisc_dup(NMTCQdisc *qdisc) if (qdisc->attributes) { GHashTableIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_hash_table_iter_init(&iter, qdisc->attributes); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) @@ -495,8 +495,8 @@ gboolean nm_tc_action_equal(NMTCAction *action, NMTCAction *other) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; + const char *key; + GVariant *value, *value2; guint n; g_return_val_if_fail(!action || action->refcount > 0, FALSE); @@ -549,8 +549,8 @@ nm_tc_action_dup(NMTCAction *action) if (action->attributes) { GHashTableIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_hash_table_iter_init(&iter, action->attributes); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) @@ -667,7 +667,7 @@ G_DEFINE_BOXED_TYPE(NMTCTfilter, nm_tc_tfilter, nm_tc_tfilter_dup, nm_tc_tfilter struct NMTCTfilter { guint refcount; - char * kind; + char *kind; guint32 handle; guint32 parent; NMTCAction *action; @@ -806,7 +806,7 @@ _nm_tc_tfilter_hash(NMTCTfilter *tfilter) if (tfilter->action) { gs_free NMUtilsNamedValue *attrs_free = NULL; NMUtilsNamedValue attrs_static[30]; - const NMUtilsNamedValue * attrs; + const NMUtilsNamedValue *attrs; guint length; guint i; @@ -1370,10 +1370,10 @@ _qdiscs_to_variant(GPtrArray *qdiscs) if (qdiscs) { for (i = 0; i < qdiscs->len; i++) { - NMUtilsNamedValue attrs_static[30]; + NMUtilsNamedValue attrs_static[30]; gs_free NMUtilsNamedValue *attrs_free = NULL; - const NMUtilsNamedValue * attrs; - NMTCQdisc * qdisc = qdiscs->pdata[i]; + const NMUtilsNamedValue *attrs; + NMTCQdisc *qdisc = qdiscs->pdata[i]; guint length; GVariantBuilder qdisc_builder; guint y; @@ -1423,10 +1423,10 @@ _qdiscs_to_variant(GPtrArray *qdiscs) static GPtrArray * _qdiscs_from_variant(GVariant *value) { - GPtrArray * qdiscs; - GVariant * qdisc_var; + GPtrArray *qdiscs; + GVariant *qdisc_var; GVariantIter iter; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -1434,12 +1434,12 @@ _qdiscs_from_variant(GVariant *value) qdiscs = g_ptr_array_new_with_free_func((GDestroyNotify) nm_tc_qdisc_unref); while (g_variant_iter_next(&iter, "@a{sv}", &qdisc_var)) { - const char * kind; + const char *kind; guint32 parent; - NMTCQdisc * qdisc; + NMTCQdisc *qdisc; GVariantIter qdisc_iter; - const char * key; - GVariant * attr_value; + const char *key; + GVariant *attr_value; if (!g_variant_lookup(qdisc_var, "kind", "&s", &kind) || !g_variant_lookup(qdisc_var, "parent", "u", &parent)) { @@ -1537,8 +1537,8 @@ _tfilters_to_variant(GPtrArray *tfilters) if (tfilters) { for (i = 0; i < tfilters->len; i++) { - NMTCTfilter * tfilter = tfilters->pdata[i]; - NMTCAction * action = nm_tc_tfilter_get_action(tfilter); + NMTCTfilter *tfilter = tfilters->pdata[i]; + NMTCAction *action = nm_tc_tfilter_get_action(tfilter); GVariantBuilder tfilter_builder; g_variant_builder_init(&tfilter_builder, G_VARIANT_TYPE("a{sv}")); @@ -1583,10 +1583,10 @@ _tfilters_to_variant(GPtrArray *tfilters) static GPtrArray * _tfilters_from_variant(GVariant *value) { - GPtrArray * tfilters; - GVariant * tfilter_var; + GPtrArray *tfilters; + GVariant *tfilter_var; GVariantIter iter; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -1595,15 +1595,15 @@ _tfilters_from_variant(GVariant *value) while (g_variant_iter_next(&iter, "@a{sv}", &tfilter_var)) { NMTCTfilter *tfilter = NULL; - const char * kind; + const char *kind; guint32 handle; guint32 parent; - NMTCAction * action; - const char * action_kind = NULL; - char * action_key; + NMTCAction *action; + const char *action_kind = NULL; + char *action_key; GVariantIter action_iter; - GVariant * action_var = NULL; - GVariant * action_val; + GVariant *action_var = NULL; + GVariant *action_val; if (!g_variant_lookup(tfilter_var, "kind", "&s", &kind) || !g_variant_lookup(tfilter_var, "parent", "u", &parent)) { @@ -1767,9 +1767,9 @@ finalize(GObject *object) static void nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-team-port.c b/src/libnm-core-impl/nm-setting-team-port.c index 5e5f89101b..816d85d9ff 100644 --- a/src/libnm-core-impl/nm-setting-team-port.c +++ b/src/libnm-core-impl/nm-setting-team-port.c @@ -313,7 +313,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(connection); if (!s_con) { @@ -400,12 +400,12 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM } static gboolean -init_from_dbus(NMSetting * setting, - GHashTable * keys, - GVariant * setting_dict, - GVariant * connection_dict, +init_from_dbus(NMSetting *setting, + GHashTable *keys, + GVariant *setting_dict, + GVariant *connection_dict, guint /* NMSettingParseFlags */ parse_flags, - GError ** error) + GError **error) { guint32 changed = 0; gboolean success; @@ -426,7 +426,7 @@ init_from_dbus(NMSetting * setting, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingTeamPort * setting = NM_SETTING_TEAM_PORT(object); + NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT(object); NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(setting); switch (prop_id) { @@ -457,10 +457,10 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingTeamPort * setting = NM_SETTING_TEAM_PORT(object); + NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT(object); NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(setting); guint32 changed; - const GPtrArray * v_ptrarr; + const GPtrArray *v_ptrarr; switch (prop_id) { case NM_TEAM_ATTRIBUTE_CONFIG: @@ -528,9 +528,9 @@ finalize(GObject *object) static void nm_setting_team_port_class_init(NMSettingTeamPortClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingTeamPortPrivate)); diff --git a/src/libnm-core-impl/nm-setting-team.c b/src/libnm-core-impl/nm-setting-team.c index 1a11b0439c..3eeeb2c335 100644 --- a/src/libnm-core-impl/nm-setting-team.c +++ b/src/libnm-core-impl/nm-setting-team.c @@ -60,8 +60,8 @@ struct NMTeamLinkWatcher { int missed_max; } nsna_ping; struct { - const char * target_host; - const char * source_host; + const char *target_host; + const char *source_host; int init_wait; int interval; int missed_max; @@ -106,7 +106,7 @@ NMTeamLinkWatcher * nm_team_link_watcher_new_ethtool(int delay_up, int delay_down, GError **error) { NMTeamLinkWatcher *watcher; - const char * val_fail = NULL; + const char *val_fail = NULL; if (delay_up < 0 || !_NM_INT_LE_MAXINT32(delay_up)) val_fail = "delay-up"; @@ -156,11 +156,11 @@ nm_team_link_watcher_new_nsna_ping(int init_wait, int interval, int missed_max, const char *target_host, - GError ** error) + GError **error) { NMTeamLinkWatcher *watcher; - const char * val_fail = NULL; - char * str; + const char *val_fail = NULL; + char *str; gsize l_target_host; if (!target_host) { @@ -235,10 +235,10 @@ NMTeamLinkWatcher * nm_team_link_watcher_new_arp_ping(int init_wait, int interval, int missed_max, - const char * target_host, - const char * source_host, + const char *target_host, + const char *source_host, NMTeamLinkWatcherArpPingFlags flags, - GError ** error) + GError **error) { return nm_team_link_watcher_new_arp_ping2(init_wait, interval, @@ -274,14 +274,14 @@ nm_team_link_watcher_new_arp_ping2(int init_wait, int interval, int missed_max, int vlanid, - const char * target_host, - const char * source_host, + const char *target_host, + const char *source_host, NMTeamLinkWatcherArpPingFlags flags, - GError ** error) + GError **error) { NMTeamLinkWatcher *watcher; - const char * val_fail = NULL; - char * str; + const char *val_fail = NULL; + char *str; gsize l_target_host; gsize l_source_host; @@ -1016,7 +1016,7 @@ gboolean nm_setting_team_remove_runner_tx_hash_by_value(NMSettingTeam *setting, const char *txhash) { NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE(setting); - const GPtrArray * arr; + const GPtrArray *arr; guint i; g_return_val_if_fail(NM_IS_SETTING_TEAM(setting), FALSE); @@ -1228,7 +1228,7 @@ nm_setting_team_remove_link_watcher(NMSettingTeam *setting, guint idx) * Since: 1.12 **/ gboolean -nm_setting_team_remove_link_watcher_by_value(NMSettingTeam * setting, +nm_setting_team_remove_link_watcher_by_value(NMSettingTeam *setting, NMTeamLinkWatcher *link_watcher) { g_return_val_if_fail(NM_IS_SETTING_TEAM(setting), FALSE); @@ -1325,12 +1325,12 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM } static gboolean -init_from_dbus(NMSetting * setting, - GHashTable * keys, - GVariant * setting_dict, - GVariant * connection_dict, +init_from_dbus(NMSetting *setting, + GHashTable *keys, + GVariant *setting_dict, + GVariant *connection_dict, guint /* NMSettingParseFlags */ parse_flags, - GError ** error) + GError **error) { guint32 changed = 0; gboolean success; @@ -1353,9 +1353,9 @@ init_from_dbus(NMSetting * setting, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingTeam * setting = NM_SETTING_TEAM(object); + NMSettingTeam *setting = NM_SETTING_TEAM(object); NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE(setting); - const GPtrArray * v_ptrarr; + const GPtrArray *v_ptrarr; switch (prop_id) { case NM_TEAM_ATTRIBUTE_CONFIG: @@ -1400,10 +1400,10 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingTeam * setting = NM_SETTING_TEAM(object); + NMSettingTeam *setting = NM_SETTING_TEAM(object); NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE(object); guint32 changed; - const GPtrArray * v_ptrarr; + const GPtrArray *v_ptrarr; switch (prop_id) { case NM_TEAM_ATTRIBUTE_CONFIG: @@ -1490,9 +1490,9 @@ finalize(GObject *object) static void nm_setting_team_class_init(NMSettingTeamClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingTeamPrivate)); diff --git a/src/libnm-core-impl/nm-setting-tun.c b/src/libnm-core-impl/nm-setting-tun.c index c26948472b..ec095155ee 100644 --- a/src/libnm-core-impl/nm-setting-tun.c +++ b/src/libnm-core-impl/nm-setting-tun.c @@ -32,8 +32,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MODE, PROP_MULTI_QUEUE, ); typedef struct { - char * owner; - char * group; + char *owner; + char *group; guint32 mode; bool pi; bool vnet_hdr; @@ -219,9 +219,9 @@ nm_setting_tun_new(void) static void nm_setting_tun_class_init(NMSettingTunClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingTunPrivate)); diff --git a/src/libnm-core-impl/nm-setting-user.c b/src/libnm-core-impl/nm-setting-user.c index 4068f33735..5c88397d87 100644 --- a/src/libnm-core-impl/nm-setting-user.c +++ b/src/libnm-core-impl/nm-setting-user.c @@ -26,8 +26,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingUser, PROP_DATA, ); typedef struct { - GHashTable * data; - GHashTable * data_invalid; + GHashTable *data; + GHashTable *data_invalid; const char **keys; } NMSettingUserPrivate; @@ -220,7 +220,7 @@ _create_data_hash(void) const char *const * nm_setting_user_get_keys(NMSettingUser *setting, guint *out_len) { - NMSettingUser * self = setting; + NMSettingUser *self = setting; NMSettingUserPrivate *priv; g_return_val_if_fail(NM_IS_SETTING_USER(self), NULL); @@ -276,7 +276,7 @@ nm_setting_user_get_data(NMSettingUser *setting, const char *key) gboolean nm_setting_user_set_data(NMSettingUser *setting, const char *key, const char *val, GError **error) { - NMSettingUser * self = setting; + NMSettingUser *self = setting; NMSettingUserPrivate *priv; gboolean changed = FALSE; @@ -340,12 +340,12 @@ out: static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingUser * self = NM_SETTING_USER(setting); + NMSettingUser *self = NM_SETTING_USER(setting); NMSettingUserPrivate *priv = NM_SETTING_USER_GET_PRIVATE(self); if (priv->data_invalid) { - const char * key, *val; - GHashTableIter iter; + const char *key, *val; + GHashTableIter iter; gs_free_error GError *local = NULL; g_hash_table_iter_init(&iter, priv->data_invalid); @@ -411,11 +411,11 @@ compare_fcn_data(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingUser * self = NM_SETTING_USER(object); + NMSettingUser *self = NM_SETTING_USER(object); NMSettingUserPrivate *priv = NM_SETTING_USER_GET_PRIVATE(self); GHashTableIter iter; - GHashTable * data; - const char * key, *val; + GHashTable *data; + const char *key, *val; switch (prop_id) { case PROP_DATA: @@ -441,11 +441,11 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingUser * self = NM_SETTING_USER(object); + NMSettingUser *self = NM_SETTING_USER(object); NMSettingUserPrivate *priv = NM_SETTING_USER_GET_PRIVATE(self); GHashTableIter iter; - GHashTable * data; - const char * key, *val; + GHashTable *data; + const char *key, *val; switch (prop_id) { case PROP_DATA: @@ -508,7 +508,7 @@ nm_setting_user_new(void) static void finalize(GObject *object) { - NMSettingUser * self = NM_SETTING_USER(object); + NMSettingUser *self = NM_SETTING_USER(object); NMSettingUserPrivate *priv = NM_SETTING_USER_GET_PRIVATE(self); g_free(priv->keys); @@ -523,9 +523,9 @@ finalize(GObject *object) static void nm_setting_user_class_init(NMSettingUserClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-veth.c b/src/libnm-core-impl/nm-setting-veth.c index 43d8da4f93..2a0d536e88 100644 --- a/src/libnm-core-impl/nm-setting-veth.c +++ b/src/libnm-core-impl/nm-setting-veth.c @@ -103,7 +103,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingVeth * setting = NM_SETTING_VETH(object); + NMSettingVeth *setting = NM_SETTING_VETH(object); NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting); switch (prop_id) { @@ -116,7 +116,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingVeth * setting = NM_SETTING_VETH(object); + NMSettingVeth *setting = NM_SETTING_VETH(object); NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting); switch (prop_id) { @@ -151,7 +151,7 @@ nm_setting_veth_new(void) static void finalize(GObject *object) { - NMSettingVeth * setting = NM_SETTING_VETH(object); + NMSettingVeth *setting = NM_SETTING_VETH(object); NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting); g_free(priv->peer); @@ -162,7 +162,7 @@ finalize(GObject *object) static void nm_setting_veth_class_init(NMSettingVethClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); g_type_class_add_private(klass, sizeof(NMSettingVethPrivate)); diff --git a/src/libnm-core-impl/nm-setting-vlan.c b/src/libnm-core-impl/nm-setting-vlan.c index 1124953edc..43ccb687fd 100644 --- a/src/libnm-core-impl/nm-setting-vlan.c +++ b/src/libnm-core-impl/nm-setting-vlan.c @@ -36,7 +36,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingVlan, typedef struct { GSList *ingress_priority_map; GSList *egress_priority_map; - char * parent; + char *parent; guint32 id; guint32 flags; } NMSettingVlanPrivate; @@ -197,7 +197,7 @@ set_map(NMSettingVlan *self, NMVlanPriorityMap map, GSList *list) static gboolean check_replace_duplicate_priority(GSList *list, guint32 from, guint32 to) { - GSList * iter; + GSList *iter; NMVlanQosMapping *p; for (iter = list; iter; iter = g_slist_next(iter)) { @@ -226,7 +226,7 @@ check_replace_duplicate_priority(GSList *list, guint32 from, guint32 to) gboolean nm_setting_vlan_add_priority_str(NMSettingVlan *setting, NMVlanPriorityMap map, const char *str) { - GSList * list = NULL; + GSList *list = NULL; NMVlanQosMapping *item = NULL; g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), FALSE); @@ -287,14 +287,14 @@ nm_setting_vlan_get_num_priorities(NMSettingVlan *setting, NMVlanPriorityMap map * Returns: returns %TRUE if @idx is in range. Otherwise, %FALSE. **/ gboolean -nm_setting_vlan_get_priority(NMSettingVlan * setting, +nm_setting_vlan_get_priority(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 idx, - guint32 * out_from, - guint32 * out_to) + guint32 *out_from, + guint32 *out_to) { NMVlanQosMapping *item; - GSList * list; + GSList *list; g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), FALSE); g_return_val_if_fail(NM_IN_SET(map, NM_VLAN_INGRESS_MAP, NM_VLAN_EGRESS_MAP), FALSE); @@ -334,12 +334,12 @@ nm_setting_vlan_get_priority(NMSettingVlan * setting, * Returns: %TRUE. */ gboolean -nm_setting_vlan_add_priority(NMSettingVlan * setting, +nm_setting_vlan_add_priority(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 from, guint32 to) { - GSList * list = NULL; + GSList *list = NULL; NMVlanQosMapping *item; g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), FALSE); @@ -363,13 +363,13 @@ nm_setting_vlan_add_priority(NMSettingVlan * setting, } gboolean -_nm_setting_vlan_set_priorities(NMSettingVlan * setting, +_nm_setting_vlan_set_priorities(NMSettingVlan *setting, NMVlanPriorityMap map, const NMVlanQosMapping *qos_map, guint n_qos_map) { gboolean has_changes = FALSE; - GSList * map_prev, *map_new; + GSList *map_prev, *map_new; guint i; gint64 from_last; @@ -398,7 +398,7 @@ _nm_setting_vlan_set_priorities(NMSettingVlan * setting, from_last = G_MAXINT64; for (i = n_qos_map; i > 0;) { const NMVlanQosMapping *m = &qos_map[--i]; - NMVlanQosMapping * item; + NMVlanQosMapping *item; /* We require the array to be presorted. */ if (m->from >= from_last) @@ -418,12 +418,12 @@ _nm_setting_vlan_set_priorities(NMSettingVlan * setting, } void -_nm_setting_vlan_get_priorities(NMSettingVlan * setting, +_nm_setting_vlan_get_priorities(NMSettingVlan *setting, NMVlanPriorityMap map, NMVlanQosMapping **out_qos_map, - guint * out_n_qos_map) + guint *out_n_qos_map) { - GSList * list; + GSList *list; NMVlanQosMapping *qos_map = NULL; guint n_qos_map, i; @@ -470,13 +470,13 @@ nm_setting_vlan_remove_priority(NMSettingVlan *setting, NMVlanPriorityMap map, g } static gboolean -priority_map_remove_by_value(NMSettingVlan * setting, +priority_map_remove_by_value(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 from, guint32 to, gboolean wildcard_to) { - GSList * list = NULL, *iter = NULL; + GSList *list = NULL, *iter = NULL; NMVlanQosMapping *item; nm_assert(NM_IS_SETTING_VLAN(setting)); @@ -512,7 +512,7 @@ priority_map_remove_by_value(NMSettingVlan * setting, * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not. */ gboolean -nm_setting_vlan_remove_priority_by_value(NMSettingVlan * setting, +nm_setting_vlan_remove_priority_by_value(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 from, guint32 to) @@ -536,9 +536,9 @@ nm_setting_vlan_remove_priority_by_value(NMSettingVlan * setting, * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not. */ gboolean -nm_setting_vlan_remove_priority_str_by_value(NMSettingVlan * setting, +nm_setting_vlan_remove_priority_str_by_value(NMSettingVlan *setting, NMVlanPriorityMap map, - const char * str) + const char *str) { gboolean is_wildcard_to; guint32 from, to; @@ -578,8 +578,8 @@ static int verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE(setting); - NMSettingConnection * s_con; - NMSettingWired * s_wired; + NMSettingConnection *s_con; + NMSettingWired *s_wired; if (connection) { s_con = nm_connection_get_setting_connection(connection); @@ -712,7 +712,7 @@ priority_strv_to_maplist(NMVlanPriorityMap map, char **strv) static char ** priority_maplist_to_strv(GSList *list) { - GSList * iter; + GSList *iter; GPtrArray *strv; strv = g_ptr_array_new(); @@ -732,7 +732,7 @@ priority_maplist_to_strv(GSList *list) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingVlan * setting = NM_SETTING_VLAN(object); + NMSettingVlan *setting = NM_SETTING_VLAN(object); NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE(setting); switch (prop_id) { @@ -757,7 +757,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingVlan * setting = NM_SETTING_VLAN(object); + NMSettingVlan *setting = NM_SETTING_VLAN(object); NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE(setting); switch (prop_id) { @@ -810,7 +810,7 @@ nm_setting_vlan_new(void) static void finalize(GObject *object) { - NMSettingVlan * setting = NM_SETTING_VLAN(object); + NMSettingVlan *setting = NM_SETTING_VLAN(object); NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE(setting); g_free(priv->parent); @@ -823,9 +823,9 @@ finalize(GObject *object) static void nm_setting_vlan_class_init(NMSettingVlanClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingVlanPrivate)); diff --git a/src/libnm-core-impl/nm-setting-vpn.c b/src/libnm-core-impl/nm-setting-vpn.c index a543051bc5..8d7e9d51f4 100644 --- a/src/libnm-core-impl/nm-setting-vpn.c +++ b/src/libnm-core-impl/nm-setting-vpn.c @@ -272,7 +272,7 @@ static void foreach_item_helper(NMSettingVpn *self, GHashTable **p_hash, NMVpnIterFunc func, gpointer user_data) { gs_unref_object NMSettingVpn *self_keep_alive = NULL; - gs_strfreev char ** keys = NULL; + gs_strfreev char **keys = NULL; guint i, len; nm_assert(NM_IS_SETTING_VPN(self)); @@ -457,10 +457,10 @@ nm_setting_vpn_foreach_secret(NMSettingVpn *setting, NMVpnIterFunc func, gpointe static gboolean aggregate(NMSetting *setting, int type_i, gpointer arg) { - NMSettingVpnPrivate * priv = NM_SETTING_VPN_GET_PRIVATE(setting); + NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); NMConnectionAggregateType type = type_i; NMSettingSecretFlags secret_flags; - const char * key_name; + const char *key_name; GHashTableIter iter; switch (type) { @@ -597,9 +597,9 @@ update_secret_string(NMSetting *setting, const char *key, const char *value, GEr static NMSettingUpdateSecretResult update_secret_dict(NMSetting *setting, GVariant *secrets, GError **error) { - NMSettingVpnPrivate * priv = NM_SETTING_VPN_GET_PRIVATE(setting); + NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); GVariantIter iter; - const char * name, *value; + const char *name, *value; NMSettingUpdateSecretResult result = NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED; g_return_val_if_fail(secrets != NULL, NM_SETTING_UPDATE_SECRET_ERROR); @@ -669,18 +669,18 @@ update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError * } static void -for_each_secret(NMSetting * setting, - const char * secret_name, - GVariant * val, +for_each_secret(NMSetting *setting, + const char *secret_name, + GVariant *val, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data, - GVariantBuilder * setting_builder) + GVariantBuilder *setting_builder) { GVariantBuilder vpn_secrets_builder; GVariantIter vpn_secrets_iter; - const char * vpn_secret_name; - const char * secret; + const char *vpn_secret_name; + const char *secret; if (!nm_streq(secret_name, NM_SETTING_VPN_SECRETS)) { NM_SETTING_CLASS(nm_setting_vpn_parent_class) @@ -723,15 +723,15 @@ for_each_secret(NMSetting * setting, } static gboolean -get_secret_flags(NMSetting * setting, - const char * secret_name, +get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); - gs_free char * flags_key_free = NULL; - const char * flags_key; - const char * flags_val; + gs_free char *flags_key_free = NULL; + const char *flags_key; + const char *flags_val; gint64 i64; nm_assert(secret_name); @@ -779,10 +779,10 @@ get_secret_flags(NMSetting * setting, } static gboolean -set_secret_flags(NMSetting * setting, - const char * secret_name, +set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { nm_assert(secret_name); @@ -812,7 +812,7 @@ static NMTernary compare_property_secrets(NMSettingVpn *a, NMSettingVpn *b, NMSettingCompareFlags flags) { GHashTableIter iter; - const char * key, *val; + const char *key, *val; int run; if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_FUZZY)) @@ -824,8 +824,8 @@ compare_property_secrets(NMSettingVpn *a, NMSettingVpn *b, NMSettingCompareFlags return TRUE; for (run = 0; run < 2; run++) { - NMSettingVpn * current_a = (run == 0) ? a : b; - NMSettingVpn * current_b = (run == 0) ? b : a; + NMSettingVpn *current_a = (run == 0) ? a : b; + NMSettingVpn *current_b = (run == 0) ? b : a; NMSettingVpnPrivate *priv_a = NM_SETTING_VPN_GET_PRIVATE(current_a); if (!priv_a->secrets) @@ -857,15 +857,15 @@ compare_fcn_secrets(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) } static gboolean -clear_secrets(const NMSettInfoSetting * sett_info, - const NMSettInfoProperty * property_info, - NMSetting * setting, +clear_secrets(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); GHashTableIter iter; - const char * secret; + const char *secret; gboolean changed = TRUE; if (!property_info->param_spec @@ -903,12 +903,12 @@ clear_secrets(const NMSettInfoSetting * sett_info, static gboolean vpn_secrets_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { - NMSettingVpn * self = NM_SETTING_VPN(setting); - NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(self); + NMSettingVpn *self = NM_SETTING_VPN(setting); + NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(self); gs_unref_hashtable GHashTable *hash_free = NULL; GVariantIter iter; - const char * key; - const char * val; + const char *key; + const char *val; hash_free = g_steal_pointer(&priv->secrets); @@ -943,7 +943,7 @@ vpn_secrets_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) keys = nm_strdict_get_keys(priv->secrets, TRUE, &len); for (i = 0; i < len; i++) { - const char * key = keys[i]; + const char *key = keys[i]; NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; if (NM_FLAGS_ANY(flags, @@ -966,7 +966,7 @@ vpn_secrets_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingVpn * setting = NM_SETTING_VPN(object); + NMSettingVpn *setting = NM_SETTING_VPN(object); NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); switch (prop_id) { @@ -1015,8 +1015,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps case PROP_SECRETS: { gs_unref_hashtable GHashTable *hash_free = NULL; - GHashTable * src_hash = g_value_get_boxed(value); - GHashTable ** p_hash; + GHashTable *src_hash = g_value_get_boxed(value); + GHashTable **p_hash; const gboolean is_secrets = (prop_id == PROP_SECRETS); if (is_secrets) @@ -1028,8 +1028,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps if (src_hash && g_hash_table_size(src_hash) > 0) { GHashTableIter iter; - const char * key; - const char * val; + const char *key; + const char *val; g_hash_table_iter_init(&iter, src_hash); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { @@ -1092,9 +1092,9 @@ finalize(GObject *object) static void nm_setting_vpn_class_init(NMSettingVpnClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingVpnPrivate)); diff --git a/src/libnm-core-impl/nm-setting-vrf.c b/src/libnm-core-impl/nm-setting-vrf.c index f998a7dd69..4588149f96 100644 --- a/src/libnm-core-impl/nm-setting-vrf.c +++ b/src/libnm-core-impl/nm-setting-vrf.c @@ -102,9 +102,9 @@ nm_setting_vrf_new(void) static void nm_setting_vrf_class_init(NMSettingVrfClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-vxlan.c b/src/libnm-core-impl/nm-setting-vxlan.c index c2d23a7fb6..6439011d01 100644 --- a/src/libnm-core-impl/nm-setting-vxlan.c +++ b/src/libnm-core-impl/nm-setting-vxlan.c @@ -407,7 +407,7 @@ _addrstr_set(char **dst, const char *src) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingVxlan * setting = NM_SETTING_VXLAN(object); + NMSettingVxlan *setting = NM_SETTING_VXLAN(object); NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting); switch (prop_id) { @@ -468,7 +468,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingVxlan * setting = NM_SETTING_VXLAN(object); + NMSettingVxlan *setting = NM_SETTING_VXLAN(object); NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting); switch (prop_id) { @@ -556,7 +556,7 @@ nm_setting_vxlan_new(void) static void finalize(GObject *object) { - NMSettingVxlan * setting = NM_SETTING_VXLAN(object); + NMSettingVxlan *setting = NM_SETTING_VXLAN(object); NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting); g_free(priv->parent); @@ -569,9 +569,9 @@ finalize(GObject *object) static void nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingVxlanPrivate)); diff --git a/src/libnm-core-impl/nm-setting-wifi-p2p.c b/src/libnm-core-impl/nm-setting-wifi-p2p.c index 06d450fccb..e8ce4bdc83 100644 --- a/src/libnm-core-impl/nm-setting-wifi-p2p.c +++ b/src/libnm-core-impl/nm-setting-wifi-p2p.c @@ -35,7 +35,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PEER, PROP_WPS_METHOD, PROP_WFD_IES, ); typedef struct { - char * peer; + char *peer; GBytes *wfd_ies; guint32 wps_method; } NMSettingWifiP2PPrivate; @@ -170,9 +170,9 @@ nm_setting_wifi_p2p_new(void) static void nm_setting_wifi_p2p_class_init(NMSettingWifiP2PClass *setting_wifi_p2p_class) { - GObjectClass * object_class = G_OBJECT_CLASS(setting_wifi_p2p_class); + GObjectClass *object_class = G_OBJECT_CLASS(setting_wifi_p2p_class); NMSettingClass *setting_class = NM_SETTING_CLASS(setting_wifi_p2p_class); - GArray * properties_override = _nm_sett_info_property_override_create_array(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-wimax.c b/src/libnm-core-impl/nm-setting-wimax.c index f7fed08e82..2ad0916542 100644 --- a/src/libnm-core-impl/nm-setting-wimax.c +++ b/src/libnm-core-impl/nm-setting-wimax.c @@ -215,9 +215,9 @@ finalize(GObject *object) static void nm_setting_wimax_class_init(NMSettingWimaxClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingWimaxPrivate)); diff --git a/src/libnm-core-impl/nm-setting-wired.c b/src/libnm-core-impl/nm-setting-wired.c index 8c9bdcd447..64dcbba187 100644 --- a/src/libnm-core-impl/nm-setting-wired.c +++ b/src/libnm-core-impl/nm-setting-wired.c @@ -53,15 +53,15 @@ typedef struct { guint len; guint n_alloc; } s390_options; - GArray * mac_address_blacklist; - char ** s390_subchannels; - char * port; - char * duplex; - char * device_mac_address; - char * cloned_mac_address; - char * generate_mac_address_mask; - char * s390_nettype; - char * wol_password; + GArray *mac_address_blacklist; + char **s390_subchannels; + char *port; + char *duplex; + char *device_mac_address; + char *cloned_mac_address; + char *generate_mac_address_mask; + char *s390_nettype; + char *wol_password; NMSettingWiredWakeOnLan wol; NMTernary accept_all_mac_addresses; guint32 speed; @@ -344,7 +344,7 @@ gboolean nm_setting_wired_add_mac_blacklist_item(NMSettingWired *setting, const char *mac) { NMSettingWiredPrivate *priv; - const char * candidate; + const char *candidate; int i; g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); @@ -401,7 +401,7 @@ gboolean nm_setting_wired_remove_mac_blacklist_item_by_value(NMSettingWired *setting, const char *mac) { NMSettingWiredPrivate *priv; - const char * candidate; + const char *candidate; int i; g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); @@ -526,8 +526,8 @@ nm_setting_wired_get_num_s390_options(NMSettingWired *setting) gboolean nm_setting_wired_get_s390_option(NMSettingWired *setting, guint32 idx, - const char ** out_key, - const char ** out_value) + const char **out_key, + const char **out_value) { NMSettingWiredPrivate *priv; @@ -773,7 +773,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - GError * local = NULL; + GError *local = NULL; guint i; if (!NM_IN_STRSET(priv->port, NULL, "tp", "aui", "bnc", "mii")) { @@ -996,9 +996,9 @@ clear_blacklist_item(char **item_p) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingWired * setting = NM_SETTING_WIRED(object); + NMSettingWired *setting = NM_SETTING_WIRED(object); NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - GHashTable * hash; + GHashTable *hash; guint i; switch (prop_id) { @@ -1063,8 +1063,8 @@ static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(object); - const char *const * blacklist; - const char * mac; + const char *const *blacklist; + const char *mac; switch (prop_id) { case PROP_PORT: @@ -1132,8 +1132,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps if (priv->s390_options.n_alloc > 0u) { gboolean invalid_content = FALSE; GHashTableIter iter; - const char * key; - const char * val; + const char *key; + const char *val; guint j; guint i; @@ -1244,9 +1244,9 @@ finalize(GObject *object) static void nm_setting_wired_class_init(NMSettingWiredClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingWiredPrivate)); diff --git a/src/libnm-core-impl/nm-setting-wireguard.c b/src/libnm-core-impl/nm-setting-wireguard.c index 27b8148891..6d44bfe207 100644 --- a/src/libnm-core-impl/nm-setting-wireguard.c +++ b/src/libnm-core-impl/nm-setting-wireguard.c @@ -46,10 +46,10 @@ G_DEFINE_BOXED_TYPE(NMWireGuardPeer, * Since: 1.16 */ struct _NMWireGuardPeer { - NMSockAddrEndpoint * endpoint; - char * public_key; - char * preshared_key; - GPtrArray * allowed_ips; + NMSockAddrEndpoint *endpoint; + char *public_key; + char *preshared_key; + GPtrArray *allowed_ips; guint refcount; NMSettingSecretFlags preshared_key_flags; guint16 persistent_keepalive; @@ -278,10 +278,10 @@ nm_wireguard_peer_get_public_key(const NMWireGuardPeer *self) */ gboolean nm_wireguard_peer_set_public_key(NMWireGuardPeer *self, - const char * public_key, + const char *public_key, gboolean accept_invalid) { - char * public_key_normalized = NULL; + char *public_key_normalized = NULL; gboolean is_valid; g_return_val_if_fail(NM_IS_WIREGUARD_PEER(self, FALSE), FALSE); @@ -365,10 +365,10 @@ nm_wireguard_peer_get_preshared_key(const NMWireGuardPeer *self) */ gboolean nm_wireguard_peer_set_preshared_key(NMWireGuardPeer *self, - const char * preshared_key, + const char *preshared_key, gboolean accept_invalid) { - char * preshared_key_normalized = NULL; + char *preshared_key_normalized = NULL; gboolean is_valid; g_return_val_if_fail(NM_IS_WIREGUARD_PEER(self, FALSE), FALSE); @@ -418,7 +418,7 @@ nm_wireguard_peer_get_preshared_key_flags(const NMWireGuardPeer *self) * Since: 1.16 */ void -nm_wireguard_peer_set_preshared_key_flags(NMWireGuardPeer * self, +nm_wireguard_peer_set_preshared_key_flags(NMWireGuardPeer *self, NMSettingSecretFlags preshared_key_flags) { g_return_if_fail(NM_IS_WIREGUARD_PEER(self, FALSE)); @@ -620,7 +620,7 @@ _peer_append_allowed_ip(NMWireGuardPeer *self, const char *allowed_ip, gboolean int addr_family; int prefix; NMIPAddr addrbin; - char * str; + char *str; gboolean is_valid = TRUE; nm_assert(NM_IS_WIREGUARD_PEER(self, FALSE)); @@ -677,7 +677,7 @@ _peer_append_allowed_ip(NMWireGuardPeer *self, const char *allowed_ip, gboolean */ gboolean nm_wireguard_peer_append_allowed_ip(NMWireGuardPeer *self, - const char * allowed_ip, + const char *allowed_ip, gboolean accept_invalid) { g_return_val_if_fail(NM_IS_WIREGUARD_PEER(self, FALSE), FALSE); @@ -733,7 +733,7 @@ gboolean nm_wireguard_peer_is_valid(const NMWireGuardPeer *self, gboolean check_non_secrets, gboolean check_secrets, - GError ** error) + GError **error) { guint i; @@ -876,7 +876,7 @@ nm_wireguard_peer_cmp(const NMWireGuardPeer *a, /*****************************************************************************/ typedef struct { - const char * public_key; + const char *public_key; NMWireGuardPeer *peer; guint idx; } PeerData; @@ -893,9 +893,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_FWMARK, PROP_PRIVATE_KEY_FLAGS, ); typedef struct { - char * private_key; - GPtrArray * peers_arr; - GHashTable * peers_hash; + char *private_key; + GPtrArray *peers_arr; + GHashTable *peers_hash; NMSettingSecretFlags private_key_flags; NMTernary ip4_auto_default_route; NMTernary ip6_auto_default_route; @@ -941,7 +941,7 @@ G_DEFINE_TYPE(NMSettingWireGuard, nm_setting_wireguard, NM_TYPE_SETTING) #define peers_psk_get_secret_parse_a(secret_public_key, public_key_free) \ ({ \ const char *_secret_public_key = (secret_public_key); \ - char ** _public_key_free = (public_key_free); \ + char **_public_key_free = (public_key_free); \ const char *_public_key = NULL; \ \ nm_assert(_public_key_free && !*_public_key_free); \ @@ -1132,11 +1132,11 @@ _peers_get(NMSettingWireGuardPrivate *priv, guint idx) static PeerData * _peers_get_by_public_key(NMSettingWireGuardPrivate *priv, - const char * public_key, + const char *public_key, gboolean try_with_normalized_key) { gs_free char *public_key_normalized = NULL; - PeerData * pd; + PeerData *pd; again: nm_assert(priv); @@ -1233,11 +1233,11 @@ nm_setting_wireguard_get_peer(NMSettingWireGuard *self, guint idx) */ NMWireGuardPeer * nm_setting_wireguard_get_peer_by_public_key(NMSettingWireGuard *self, - const char * public_key, - guint * out_idx) + const char *public_key, + guint *out_idx) { NMSettingWireGuardPrivate *priv; - PeerData * pd; + PeerData *pd; g_return_val_if_fail(NM_IS_SETTING_WIREGUARD(self), NULL); g_return_val_if_fail(public_key, NULL); @@ -1255,12 +1255,12 @@ nm_setting_wireguard_get_peer_by_public_key(NMSettingWireGuard *self, static gboolean _peers_set(NMSettingWireGuardPrivate *priv, - NMWireGuardPeer * peer, + NMWireGuardPeer *peer, guint idx, gboolean check_same_key) { - PeerData * pd_same_key = NULL; - PeerData * pd_idx = NULL; + PeerData *pd_same_key = NULL; + PeerData *pd_idx = NULL; const char *public_key; nm_assert(idx <= priv->peers_arr->len); @@ -1462,7 +1462,7 @@ nm_setting_wireguard_clear_peers(NMSettingWireGuard *self) static GVariant * _peers_dbus_only_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - NMSettingWireGuard * self = NM_SETTING_WIREGUARD(setting); + NMSettingWireGuard *self = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv; gboolean any_peers = FALSE; GVariantBuilder peers_builder; @@ -1518,7 +1518,7 @@ _peers_dbus_only_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) if (_nm_connection_serialize_non_secret(flags) && peer->allowed_ips && peer->allowed_ips->len > 0) { - const char *const * strv = (const char *const *) peer->allowed_ips->pdata; + const char *const *strv = (const char *const *) peer->allowed_ips->pdata; gs_free const char **strv_fixed = NULL; for (i = 0; i < peer->allowed_ips->len; i++) { @@ -1561,7 +1561,7 @@ static gboolean _peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GVariantIter iter_peers; - GVariant * peer_var; + GVariant *peer_var; guint i_peer; gboolean success = FALSE; gboolean peers_changed = FALSE; @@ -1574,9 +1574,9 @@ _peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) while (g_variant_iter_next(&iter_peers, "@a{sv}", &peer_var)) { _nm_unused gs_unref_variant GVariant *peer_var_unref = peer_var; nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; - const char * cstr; + const char *cstr; guint32 u32; - GVariant * var; + GVariant *var; i_peer++; @@ -1633,7 +1633,7 @@ _peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) if (g_variant_lookup(peer_var, NM_WIREGUARD_PEER_ATTR_ALLOWED_IPS, "@as", &var)) { _nm_unused gs_unref_variant GVariant *var_free = var; - gs_free const char ** allowed_ips = NULL; + gs_free const char **allowed_ips = NULL; gsize i, l; allowed_ips = g_variant_get_strv(var, &l); @@ -1688,7 +1688,7 @@ out: static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingWireGuard * s_wg = NM_SETTING_WIREGUARD(setting); + NMSettingWireGuard *s_wg = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); guint i; @@ -1718,7 +1718,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - const char * method; + const char *method; /* WireGuard is Layer 3 only. For the moment, we only support a restricted set of * IP methods. We may relax that later, once we fix the implementations so they @@ -1803,7 +1803,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; guint i; if (!priv->private_key || !priv->private_key_valid) { @@ -1832,9 +1832,9 @@ need_secrets(NMSetting *setting) } static gboolean -clear_secrets(const NMSettInfoSetting * sett_info, - const NMSettInfoProperty * property_info, - NMSetting * setting, +clear_secrets(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { @@ -1852,7 +1852,7 @@ clear_secrets(const NMSettInfoSetting * sett_info, if (func) { gs_free char *name_free = NULL; - const char * name; + const char *name; if (j++ < 5) { /* we use alloca() inside a loop here, but it is guarded to happen at most @@ -1891,12 +1891,12 @@ clear_secrets(const NMSettInfoSetting * sett_info, static int update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError **error) { - NMSettingWireGuard * self = NM_SETTING_WIREGUARD(setting); + NMSettingWireGuard *self = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv; gboolean has_changes = FALSE; gboolean has_error = FALSE; GVariantIter iter_peers; - GVariant * peer_var; + GVariant *peer_var; guint i_peer; if (!nm_streq(key, NM_SETTING_WIREGUARD_PEERS)) { @@ -1924,8 +1924,8 @@ update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError * while (g_variant_iter_next(&iter_peers, "@a{sv}", &peer_var)) { _nm_unused gs_unref_variant GVariant *peer_var_unref = peer_var; nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; - PeerData * pd; - const char * cstr; + PeerData *pd; + const char *cstr; i_peer++; @@ -2041,14 +2041,14 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM static void enumerate_values(const NMSettInfoProperty *property_info, - NMSetting * setting, + NMSetting *setting, NMSettingValueIterFn func, gpointer user_data) { if (nm_streq(property_info->name, NM_SETTING_WIREGUARD_PEERS)) { - NMSettingWireGuardPrivate * priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); + NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); nm_auto_unset_gvalue GValue value = G_VALUE_INIT; - GPtrArray * ptr = NULL; + GPtrArray *ptr = NULL; guint i; if (priv->peers_arr && priv->peers_arr->len > 0) { @@ -2115,16 +2115,16 @@ out_done: } static gboolean -get_secret_flags(NMSetting * setting, - const char * secret_name, +get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { if (NM_STR_HAS_PREFIX(secret_name, NM_SETTING_WIREGUARD_PEERS ".")) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); - gs_free char * public_key_free = NULL; - const char * public_key; - PeerData * pd; + gs_free char *public_key_free = NULL; + const char *public_key; + PeerData *pd; public_key = peers_psk_get_secret_parse_a(secret_name, &public_key_free); if (public_key && (pd = _peers_get_by_public_key(priv, public_key, FALSE))) { @@ -2138,17 +2138,17 @@ get_secret_flags(NMSetting * setting, } static gboolean -set_secret_flags(NMSetting * setting, - const char * secret_name, +set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { if (NM_STR_HAS_PREFIX(secret_name, NM_SETTING_WIREGUARD_PEERS ".")) { - NMSettingWireGuard * self = NM_SETTING_WIREGUARD(setting); + NMSettingWireGuard *self = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(self); - gs_free char * public_key_free = NULL; - const char * public_key; - PeerData * pd; + gs_free char *public_key_free = NULL; + const char *public_key; + PeerData *pd; public_key = peers_psk_get_secret_parse_a(secret_name, &public_key_free); if (public_key && (pd = _peers_get_by_public_key(priv, public_key, FALSE))) { @@ -2170,20 +2170,20 @@ set_secret_flags(NMSetting * setting, } static void -for_each_secret(NMSetting * setting, - const char * data_key, - GVariant * data_val, +for_each_secret(NMSetting *setting, + const char *data_key, + GVariant *data_val, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data, - GVariantBuilder * setting_builder) + GVariantBuilder *setting_builder) { - NMSettingWireGuard * s_wg; + NMSettingWireGuard *s_wg; NMSettingWireGuardPrivate *priv; GVariantBuilder peers_builder; - GVariantIter * peer_iter; + GVariantIter *peer_iter; GVariantIter data_iter; - const char * key; + const char *key; if (!nm_streq(data_key, NM_SETTING_WIREGUARD_PEERS)) { NM_SETTING_CLASS(nm_setting_wireguard_parent_class) @@ -2210,11 +2210,11 @@ for_each_secret(NMSetting * setting, g_variant_iter_init(&data_iter, data_val); while (g_variant_iter_next(&data_iter, "a{sv}", &peer_iter)) { _nm_unused nm_auto_free_variant_iter GVariantIter *peer_iter_free = peer_iter; - gs_unref_variant GVariant *preshared_key = NULL; - PeerData * pd = NULL; - NMSettingSecretFlags secret_flags; - GVariant * val; - GVariantBuilder peer_builder; + gs_unref_variant GVariant *preshared_key = NULL; + PeerData *pd = NULL; + NMSettingSecretFlags secret_flags; + GVariant *val; + GVariantBuilder peer_builder; g_variant_builder_init(&peer_builder, G_VARIANT_TYPE("a{sv}")); @@ -2261,7 +2261,7 @@ for_each_secret(NMSetting * setting, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingWireGuard * setting = NM_SETTING_WIREGUARD(object); + NMSettingWireGuard *setting = NM_SETTING_WIREGUARD(object); NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); switch (prop_id) { @@ -2299,7 +2299,7 @@ static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(object); - const char * str; + const char *str; switch (prop_id) { case PROP_FWMARK: @@ -2388,9 +2388,9 @@ finalize(GObject *object) static void nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-wireless-security.c b/src/libnm-core-impl/nm-setting-wireless-security.c index 0bfc30c892..5188516516 100644 --- a/src/libnm-core-impl/nm-setting-wireless-security.c +++ b/src/libnm-core-impl/nm-setting-wireless-security.c @@ -62,18 +62,18 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingWirelessSecurity, PROP_FILS, ); typedef struct { - GSList * proto; /* GSList of strings */ - GSList * pairwise; /* GSList of strings */ - GSList * group; /* GSList of strings */ - char * key_mgmt; - char * auth_alg; - char * leap_username; - char * leap_password; - char * wep_key0; - char * wep_key1; - char * wep_key2; - char * wep_key3; - char * psk; + GSList *proto; /* GSList of strings */ + GSList *pairwise; /* GSList of strings */ + GSList *group; /* GSList of strings */ + char *key_mgmt; + char *auth_alg; + char *leap_username; + char *leap_password; + char *wep_key0; + char *wep_key1; + char *wep_key2; + char *wep_key3; + char *psk; NMSettingSecretFlags leap_password_flags; NMSettingSecretFlags wep_key_flags; NMSettingSecretFlags psk_flags; @@ -177,7 +177,7 @@ gboolean nm_setting_wireless_security_add_proto(NMSettingWirelessSecurity *setting, const char *proto) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(proto != NULL, FALSE); @@ -204,7 +204,7 @@ void nm_setting_wireless_security_remove_proto(NMSettingWirelessSecurity *setting, guint32 i) { NMSettingWirelessSecurityPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting)); @@ -228,10 +228,10 @@ nm_setting_wireless_security_remove_proto(NMSettingWirelessSecurity *setting, gu **/ gboolean nm_setting_wireless_security_remove_proto_by_value(NMSettingWirelessSecurity *setting, - const char * proto) + const char *proto) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(proto != NULL, FALSE); @@ -321,7 +321,7 @@ gboolean nm_setting_wireless_security_add_pairwise(NMSettingWirelessSecurity *setting, const char *pairwise) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(pairwise != NULL, FALSE); @@ -349,7 +349,7 @@ void nm_setting_wireless_security_remove_pairwise(NMSettingWirelessSecurity *setting, guint32 i) { NMSettingWirelessSecurityPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting)); @@ -374,10 +374,10 @@ nm_setting_wireless_security_remove_pairwise(NMSettingWirelessSecurity *setting, **/ gboolean nm_setting_wireless_security_remove_pairwise_by_value(NMSettingWirelessSecurity *setting, - const char * pairwise) + const char *pairwise) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(pairwise != NULL, FALSE); @@ -468,7 +468,7 @@ gboolean nm_setting_wireless_security_add_group(NMSettingWirelessSecurity *setting, const char *group) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(group != NULL, FALSE); @@ -496,7 +496,7 @@ void nm_setting_wireless_security_remove_group(NMSettingWirelessSecurity *setting, guint32 i) { NMSettingWirelessSecurityPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting)); @@ -522,10 +522,10 @@ nm_setting_wireless_security_remove_group(NMSettingWirelessSecurity *setting, gu **/ gboolean nm_setting_wireless_security_remove_group_by_value(NMSettingWirelessSecurity *setting, - const char * group) + const char *group) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(group != NULL, FALSE); @@ -691,7 +691,7 @@ nm_setting_wireless_security_get_wep_key(NMSettingWirelessSecurity *setting, gui void nm_setting_wireless_security_set_wep_key(NMSettingWirelessSecurity *setting, guint32 idx, - const char * key) + const char *key) { NMSettingWirelessSecurityPrivate *priv; @@ -817,9 +817,9 @@ nm_setting_wireless_security_get_fils(NMSettingWirelessSecurity *setting) static GPtrArray * need_secrets(NMSetting *setting) { - NMSettingWirelessSecurity * self = NM_SETTING_WIRELESS_SECURITY(setting); + NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self); - GPtrArray * secrets; + GPtrArray *secrets; secrets = g_ptr_array_sized_new(4); @@ -895,16 +895,16 @@ no_secrets: static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingWirelessSecurity * self = NM_SETTING_WIRELESS_SECURITY(setting); + NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self); - const char * valid_key_mgmt[] = + const char *valid_key_mgmt[] = {"none", "ieee8021x", "wpa-psk", "wpa-eap", "wpa-eap-suite-b-192", "sae", "owe", NULL}; - const char * valid_auth_algs[] = {"open", "shared", "leap", NULL}; - const char * valid_protos[] = {"wpa", "rsn", NULL}; - const char * valid_pairwise[] = {"tkip", "ccmp", NULL}; - const char * valid_groups[] = {"wep40", "wep104", "tkip", "ccmp", NULL}; + const char *valid_auth_algs[] = {"open", "shared", "leap", NULL}; + const char *valid_protos[] = {"wpa", "rsn", NULL}; + const char *valid_pairwise[] = {"tkip", "ccmp", NULL}; + const char *valid_groups[] = {"wep40", "wep104", "tkip", "ccmp", NULL}; NMSettingWireless *s_wifi; - const char * wifi_mode; + const char *wifi_mode; s_wifi = connection ? nm_connection_get_setting_wireless(connection) : NULL; wifi_mode = s_wifi ? nm_setting_wireless_get_mode(s_wifi) : NULL; @@ -1161,10 +1161,10 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static gboolean -_verify_wep_key(const char * wep_key, +_verify_wep_key(const char *wep_key, NMWepKeyType wep_key_type, - const char * property, - GError ** error) + const char *property, + GError **error) { if (wep_key && !nm_utils_wep_key_valid(wep_key, wep_key_type)) { g_set_error_literal(error, @@ -1180,7 +1180,7 @@ _verify_wep_key(const char * wep_key, static gboolean verify_secrets(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingWirelessSecurity * self = NM_SETTING_WIRELESS_SECURITY(setting); + NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self); /* LEAP */ @@ -1231,10 +1231,10 @@ verify_secrets(NMSetting *setting, NMConnection *connection, GError **error) } static gboolean -get_secret_flags(NMSetting * setting, - const char * secret_name, +get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { NMSettingSecretFlags flags; @@ -1260,10 +1260,10 @@ get_secret_flags(NMSetting * setting, } static gboolean -set_secret_flags(NMSetting * setting, - const char * secret_name, +set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { if (NM_IN_STRSET(secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, @@ -1310,7 +1310,7 @@ wep_key_type_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingWirelessSecurity * setting = NM_SETTING_WIRELESS_SECURITY(object); + NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY(object); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(setting); switch (prop_id) { @@ -1383,9 +1383,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingWirelessSecurity * setting = NM_SETTING_WIRELESS_SECURITY(object); + NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY(object); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(setting); - const char * str; + const char *str; switch (prop_id) { case PROP_KEY_MGMT: @@ -1495,7 +1495,7 @@ nm_setting_wireless_security_new(void) static void finalize(GObject *object) { - NMSettingWirelessSecurity * self = NM_SETTING_WIRELESS_SECURITY(object); + NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(object); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self); g_free(priv->key_mgmt); @@ -1518,9 +1518,9 @@ finalize(GObject *object) static void nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingWirelessSecurityPrivate)); diff --git a/src/libnm-core-impl/nm-setting-wireless.c b/src/libnm-core-impl/nm-setting-wireless.c index f5a4cb6a85..ed41c93673 100644 --- a/src/libnm-core-impl/nm-setting-wireless.c +++ b/src/libnm-core-impl/nm-setting-wireless.c @@ -46,15 +46,15 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingWireless, PROP_AP_ISOLATION, ); typedef struct { - GBytes * ssid; - GArray * mac_address_blacklist; - GPtrArray * seen_bssids; - char * mode; - char * band; - char * bssid; - char * device_mac_address; - char * cloned_mac_address; - char * generate_mac_address_mask; + GBytes *ssid; + GArray *mac_address_blacklist; + GPtrArray *seen_bssids; + char *mode; + char *band; + char *bssid; + char *device_mac_address; + char *cloned_mac_address; + char *generate_mac_address_mask; NMSettingMacRandomization mac_address_randomization; NMTernary ap_isolation; guint32 channel; @@ -127,7 +127,7 @@ match_cipher(const char *cipher, * security flags and mode, %FALSE if they are not. */ gboolean -nm_setting_wireless_ap_security_compatible(NMSettingWireless * s_wireless, +nm_setting_wireless_ap_security_compatible(NMSettingWireless *s_wireless, NMSettingWirelessSecurity *s_wireless_sec, NM80211ApFlags ap_flags, NM80211ApSecurityFlags ap_wpa, @@ -511,7 +511,7 @@ gboolean nm_setting_wireless_add_mac_blacklist_item(NMSettingWireless *setting, const char *mac) { NMSettingWirelessPrivate *priv; - const char * candidate; + const char *candidate; int i; g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), FALSE); @@ -568,7 +568,7 @@ gboolean nm_setting_wireless_remove_mac_blacklist_item_by_value(NMSettingWireless *setting, const char *mac) { NMSettingWirelessPrivate *priv; - const char * candidate; + const char *candidate; int i; g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), FALSE); @@ -678,7 +678,7 @@ gboolean nm_setting_wireless_add_seen_bssid(NMSettingWireless *setting, const char *bssid) { NMSettingWirelessPrivate *priv; - gs_free char * lower_bssid = NULL; + gs_free char *lower_bssid = NULL; g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), FALSE); g_return_val_if_fail(bssid != NULL, FALSE); @@ -764,7 +764,7 @@ static gboolean _from_dbus_fcn_seen_bssids(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { NMSettingWirelessPrivate *priv; - gs_free const char ** s = NULL; + gs_free const char **s = NULL; gsize len; gsize i; @@ -810,15 +810,15 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(setting); - const char * valid_modes[] = {NM_SETTING_WIRELESS_MODE_INFRA, + const char *valid_modes[] = {NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NM_SETTING_WIRELESS_MODE_MESH, NULL}; - const char * valid_bands[] = {"a", "bg", NULL}; + const char *valid_bands[] = {"a", "bg", NULL}; guint i; gsize length; - GError * local = NULL; + GError *local = NULL; if (!priv->ssid) { g_set_error_literal(error, @@ -1152,7 +1152,7 @@ clear_blacklist_item(char **item_p) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingWireless * setting = NM_SETTING_WIRELESS(object); + NMSettingWireless *setting = NM_SETTING_WIRELESS(object); NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(object); switch (prop_id) { @@ -1212,8 +1212,8 @@ static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(object); - const char *const * blacklist; - const char * mac; + const char *const *blacklist; + const char *mac; gboolean bool_val; switch (prop_id) { @@ -1270,7 +1270,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps case PROP_SEEN_BSSIDS: { gs_unref_ptrarray GPtrArray *arr_old = NULL; - const char *const * strv; + const char *const *strv; arr_old = g_steal_pointer(&priv->seen_bssids); @@ -1350,9 +1350,9 @@ finalize(GObject *object) static void nm_setting_wireless_class_init(NMSettingWirelessClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingWirelessPrivate)); diff --git a/src/libnm-core-impl/nm-setting-wpan.c b/src/libnm-core-impl/nm-setting-wpan.c index 78cdc03650..9e25dd1656 100644 --- a/src/libnm-core-impl/nm-setting-wpan.c +++ b/src/libnm-core-impl/nm-setting-wpan.c @@ -42,7 +42,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MAC_ADDRESS, PROP_CHANNEL, ); typedef struct { - char * mac_address; + char *mac_address; guint32 pan_id; guint32 short_address; gint32 page; @@ -222,9 +222,9 @@ nm_setting_wpan_new(void) static void nm_setting_wpan_class_init(NMSettingWpanClass *klass) { - GObjectClass * object_class = G_OBJECT_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(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(setting_class, sizeof(NMSettingWpanPrivate)); diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index 9ef9e96c43..3cf5ba5fb7 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -29,13 +29,13 @@ /*****************************************************************************/ typedef struct { - GHashTable * hash; + GHashTable *hash; const char **names; - GVariant ** values; + GVariant **values; } GenData; typedef struct { - const char * name; + const char *name; GType type; NMSettingPriority priority; } SettingInfo; @@ -55,8 +55,8 @@ G_DEFINE_ABSTRACT_TYPE(NMSetting, nm_setting, G_TYPE_OBJECT) static GenData *_gendata_hash(NMSetting *setting, gboolean create_if_necessary); static gboolean set_property_from_dbus(const NMSettInfoProperty *property_info, - GVariant * src_value, - GValue * dst_value); + GVariant *src_value, + GValue *dst_value); /*****************************************************************************/ @@ -148,7 +148,7 @@ _nm_setting_slave_type_is_valid(const char *slave_type, const char **out_port_ty static const NMSettInfoProperty * _nm_sett_info_property_find_in_array(const NMSettInfoProperty *properties, guint len, - const char * name) + const char *name) { guint i; @@ -234,7 +234,7 @@ _property_infos_sort_cmp_setting_connection(gconstpointer p_a, static const NMSettInfoProperty *const * _property_infos_sort(const NMSettInfoProperty *property_infos, guint16 property_infos_len, - NMSettingClass * setting_class) + NMSettingClass *setting_class) { const NMSettInfoProperty **arr; guint16 i; @@ -280,14 +280,14 @@ _property_lookup_by_param_spec_sort(gconstpointer p_a, gconstpointer p_b, gpoint } void -_nm_setting_class_commit(NMSettingClass * setting_class, +_nm_setting_class_commit(NMSettingClass *setting_class, NMMetaSettingType meta_type, const NMSettInfoSettDetail *detail, - GArray * properties_override, + GArray *properties_override, gint16 private_offset) { - NMSettInfoSetting *sett_info; - gs_free GParamSpec ** property_specs = NULL; + NMSettInfoSetting *sett_info; + gs_free GParamSpec **property_specs = NULL; guint n_property_specs; NMSettInfoPropertLookupByParamSpec *lookup_by_iter; guint override_len; @@ -350,7 +350,7 @@ _nm_setting_class_commit(NMSettingClass * setting_class, #endif for (i = 0; i < n_property_specs; i++) { - const char * name = property_specs[i]->name; + const char *name = property_specs[i]->name; NMSettInfoProperty *p; if (_nm_sett_info_property_find_in_array((NMSettInfoProperty *) properties_override->data, @@ -493,7 +493,7 @@ has_property_type: const NMSettInfoProperty * _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info, - const char * property_name) + const char *property_name) { const NMSettInfoProperty *property_info; gssize idx; @@ -539,7 +539,7 @@ _nm_setting_class_get_sett_info(NMSettingClass *setting_class) const NMSettInfoProperty * _nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info, - const GParamSpec * param_spec) + const GParamSpec *param_spec) { NMSettInfoPropertLookupByParamSpec needle; int imin; @@ -610,8 +610,8 @@ _nm_setting_emit_property_changed(NMSetting *setting) /*****************************************************************************/ gboolean -_nm_setting_use_legacy_property(NMSetting * setting, - GVariant * connection_dict, +_nm_setting_use_legacy_property(NMSetting *setting, + GVariant *connection_dict, const char *legacy_property, const char *new_property) { @@ -676,13 +676,13 @@ _property_direct_set_string(const NMSettInfoProperty *property_info, char **dst, } void -_nm_setting_property_get_property_direct(GObject * object, +_nm_setting_property_get_property_direct(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec) { - NMSetting * setting = NM_SETTING(object); - const NMSettInfoSetting * sett_info; + NMSetting *setting = NM_SETTING(object); + const NMSettInfoSetting *sett_info; const NMSettInfoProperty *property_info; sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); @@ -770,13 +770,13 @@ out_fail: } void -_nm_setting_property_set_property_direct(GObject * object, +_nm_setting_property_set_property_direct(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { - NMSetting * setting = NM_SETTING(object); - const NMSettInfoSetting * sett_info; + NMSetting *setting = NM_SETTING(object); + const NMSettInfoSetting *sett_info; const NMSettInfoProperty *property_info; sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); @@ -791,7 +791,7 @@ _nm_setting_property_set_property_direct(GObject * object, switch (property_info->property_type->direct_type) { case NM_VALUE_TYPE_BOOL: { - bool * p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + bool *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); gboolean v; v = g_value_get_boolean(value); @@ -873,7 +873,7 @@ _nm_setting_property_set_property_direct(GObject * object, case NM_VALUE_TYPE_BYTES: { GBytes **p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); - GBytes * v; + GBytes *v; _nm_unused gs_unref_bytes GBytes *old = NULL; v = g_value_get_boxed(value); @@ -1271,7 +1271,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS ({ \ const NMSettInfoProperty const *_property_info = (property_info); \ const GType _gtype = (gtype); \ - GVariant * _value = (value); \ + GVariant *_value = (value); \ gboolean _success = FALSE; \ \ nm_assert(_property_info->param_spec->value_type == _gtype); \ @@ -1292,7 +1292,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS switch (property_info->property_type->direct_type) { case NM_VALUE_TYPE_BOOL: { - bool * p_val; + bool *p_val; gboolean v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) @@ -1316,7 +1316,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_INT32: { const GParamSpecInt *param_spec; - gint32 * p_val; + gint32 *p_val; int v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32)) { @@ -1344,7 +1344,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_UINT32: { const GParamSpecUInt *param_spec; - guint32 * p_val; + guint32 *p_val; guint v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) { @@ -1372,7 +1372,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_UINT64: { const GParamSpecUInt64 *param_spec; - guint64 * p_val; + guint64 *p_val; guint64 v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT64)) @@ -1399,7 +1399,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_ENUM: { const GParamSpecEnum *param_spec; - int * p_val; + int *p_val; int v; param_spec = NM_G_PARAM_SPEC_CAST_ENUM(property_info->param_spec); @@ -1428,7 +1428,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_FLAGS: { const GParamSpecFlags *param_spec; - guint * p_val; + guint *p_val; guint v; param_spec = NM_G_PARAM_SPEC_CAST_FLAGS(property_info->param_spec); @@ -1457,8 +1457,8 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_STRING: { gs_free char *v_free = NULL; - char ** p_val; - const char * v; + char **p_val; + const char *v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) { v = g_variant_get_string(value, NULL); @@ -1481,7 +1481,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_BYTES: { gs_unref_bytes GBytes *v = NULL; - GBytes ** p_val; + GBytes **p_val; if (!g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) goto out_error_wrong_dbus_type; @@ -1542,7 +1542,7 @@ gboolean _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { nm_auto_unset_gvalue GValue object_value = G_VALUE_INIT; - gs_free_error GError *local = NULL; + gs_free_error GError *local = NULL; nm_assert(property_info->param_spec); @@ -1586,10 +1586,10 @@ _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _ } static GVariant * -property_to_dbus(const NMSettInfoSetting * sett_info, - const NMSettInfoProperty * property_info, - NMConnection * connection, - NMSetting * setting, +property_to_dbus(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMConnection *connection, + NMSetting *setting, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options, gboolean ignore_flags) @@ -1646,8 +1646,8 @@ property_to_dbus(const NMSettInfoSetting * sett_info, static gboolean set_property_from_dbus(const NMSettInfoProperty *property_info, - GVariant * src_value, - GValue * dst_value) + GVariant *src_value, + GValue *dst_value) { nm_assert(property_info->param_spec); nm_assert(property_info->property_type->dbus_type); @@ -1687,18 +1687,18 @@ set_property_from_dbus(const NMSettInfoProperty *property_info, * properties **/ GVariant * -_nm_setting_to_dbus(NMSetting * setting, - NMConnection * connection, +_nm_setting_to_dbus(NMSetting *setting, + NMConnection *connection, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options) { - NMSettingPrivate * priv; + NMSettingPrivate *priv; GVariantBuilder builder; const NMSettInfoSetting *sett_info; guint n_properties; guint i; guint16 j; - const char *const * gendata_keys; + const char *const *gendata_keys; g_return_val_if_fail(NM_IS_SETTING(setting), NULL); @@ -1716,8 +1716,8 @@ _nm_setting_to_dbus(NMSetting * setting, sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); for (j = 0; j < sett_info->property_infos_len; j++) { - const NMSettInfoProperty *property_info = &sett_info->property_infos[j]; - gs_unref_variant GVariant *dbus_value = NULL; + const NMSettInfoProperty *property_info = &sett_info->property_infos[j]; + gs_unref_variant GVariant *dbus_value = NULL; dbus_value = property_to_dbus(sett_info, property_info, connection, setting, flags, options, FALSE); @@ -1751,14 +1751,14 @@ _nm_setting_to_dbus(NMSetting * setting, **/ NMSetting * _nm_setting_new_from_dbus(GType setting_type, - GVariant * setting_dict, - GVariant * connection_dict, + GVariant *setting_dict, + GVariant *connection_dict, NMSettingParseFlags parse_flags, - GError ** error) + GError **error) { - gs_unref_ptrarray GPtrArray *keys_keep_variant = NULL; - gs_unref_object NMSetting *setting = NULL; - gs_unref_hashtable GHashTable *keys = NULL; + gs_unref_ptrarray GPtrArray *keys_keep_variant = NULL; + gs_unref_object NMSetting *setting = NULL; + gs_unref_hashtable GHashTable *keys = NULL; g_return_val_if_fail(G_TYPE_IS_INSTANTIATABLE(setting_type), NULL); g_return_val_if_fail(g_variant_is_of_type(setting_dict, NM_VARIANT_TYPE_SETTING), NULL); @@ -1783,8 +1783,8 @@ _nm_setting_new_from_dbus(GType setting_type, if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) { GVariantIter iter; - GVariant * entry, *entry_key; - const char * key; + GVariant *entry, *entry_key; + const char *key; keys_keep_variant = g_ptr_array_new_with_free_func((GDestroyNotify) g_variant_unref); keys = g_hash_table_new(nm_str_hash, g_str_equal); @@ -1813,7 +1813,7 @@ _nm_setting_new_from_dbus(GType setting_type, if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT) && g_hash_table_size(keys) > 0) { GHashTableIter iter; - const char * key; + const char *key; g_hash_table_iter_init(&iter, keys); if (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) { @@ -1830,14 +1830,14 @@ _nm_setting_new_from_dbus(GType setting_type, } static gboolean -_property_set_from_dbus(const NMSettInfoSetting * sett_info, +_property_set_from_dbus(const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, - NMSetting * setting, - GVariant * connection_dict, - GVariant * value, + NMSetting *setting, + GVariant *connection_dict, + GVariant *value, NMSettingParseFlags parse_flags, - gboolean * out_is_modified, - GError ** error) + gboolean *out_is_modified, + GError **error) { gs_free_error GError *local = NULL; NMTernary is_modified = NM_TERNARY_DEFAULT; @@ -1904,12 +1904,12 @@ _property_set_from_dbus(const NMSettInfoSetting * sett_info, } static gboolean -init_from_dbus(NMSetting * setting, - GHashTable * keys, - GVariant * setting_dict, - GVariant * connection_dict, +init_from_dbus(NMSetting *setting, + GHashTable *keys, + GVariant *setting_dict, + GVariant *connection_dict, guint /* NMSettingParseFlags */ parse_flags, - GError ** error) + GError **error) { const NMSettInfoSetting *sett_info; guint16 i; @@ -1922,10 +1922,10 @@ init_from_dbus(NMSetting * setting, sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); if (sett_info->detail.gendata_info) { - GHashTable * hash; + GHashTable *hash; GVariantIter iter; - char * key; - GVariant * val; + char *key; + GVariant *val; hash = _gendata_hash(setting, TRUE)->hash; @@ -1952,9 +1952,9 @@ init_from_dbus(NMSetting * setting, } for (i = 0; i < sett_info->property_infos_len; i++) { - const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; - gs_unref_variant GVariant *value = NULL; - gs_free_error GError *local = NULL; + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; + gs_unref_variant GVariant *value = NULL; + gs_free_error GError *local = NULL; if (property_info->property_type == &nm_sett_info_propert_type_setting_name) continue; @@ -2034,7 +2034,7 @@ nm_setting_get_dbus_property_type(NMSetting *setting, const char *property_name) gboolean _nm_setting_get_property(NMSetting *setting, const char *property_name, GValue *value) { - const NMSettInfoSetting * sett_info; + const NMSettInfoSetting *sett_info; const NMSettInfoProperty *property_info; g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); @@ -2045,7 +2045,7 @@ _nm_setting_get_property(NMSetting *setting, const char *property_name, GValue * if (sett_info->detail.gendata_info) { GVariant *variant; - GenData * gendata = _gendata_hash(setting, FALSE); + GenData *gendata = _gendata_hash(setting, FALSE); variant = gendata ? g_hash_table_lookup(gendata->hash, property_name) : NULL; @@ -2096,9 +2096,9 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM if (gendata && g_hash_table_size(gendata->hash) > 0) { GHashTableIter iter; - GHashTable * h = _gendata_hash(dst, TRUE)->hash; - const char * key; - GVariant * val; + GHashTable *h = _gendata_hash(dst, TRUE)->hash; + const char *key; + GVariant *val; g_hash_table_iter_init(&iter, gendata->hash); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { @@ -2146,8 +2146,8 @@ NMSetting * nm_setting_duplicate(NMSetting *setting) { const NMSettInfoSetting *sett_info; - NMSettingClass * klass; - NMSetting * dst; + NMSettingClass *klass; + NMSetting *dst; g_return_val_if_fail(NM_IS_SETTING(setting), NULL); @@ -2256,7 +2256,7 @@ gboolean _nm_setting_verify_secret_string(const char *str, const char *setting_name, const char *property, - GError ** error) + GError **error) { if (str && !*str) { g_set_error_literal(error, @@ -2270,9 +2270,9 @@ _nm_setting_verify_secret_string(const char *str, } gboolean -_nm_setting_should_compare_secret_property(NMSetting * setting, - NMSetting * other, - const char * secret_name, +_nm_setting_should_compare_secret_property(NMSetting *setting, + NMSetting *other, + const char *secret_name, NMSettingCompareFlags flags) { NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE; @@ -2328,10 +2328,10 @@ _nm_setting_should_compare_secret_property(NMSetting * setting, /*****************************************************************************/ gboolean -_nm_setting_compare_flags_check(const GParamSpec * param_spec, +_nm_setting_compare_flags_check(const GParamSpec *param_spec, NMSettingCompareFlags flags, - NMSetting * set_a, - NMSetting * set_b) + NMSetting *set_a, + NMSetting *set_b) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_FUZZY) && NM_FLAGS_ANY(param_spec->flags, NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)) @@ -2443,12 +2443,12 @@ _nm_setting_property_compare_fcn_default(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm } static NMTernary -_compare_property(const NMSettInfoSetting * sett_info, +_compare_property(const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, + NMConnection *con_a, + NMSetting *set_a, + NMConnection *con_b, + NMSetting *set_b, NMSettingCompareFlags flags) { NMTernary compare_result; @@ -2500,10 +2500,10 @@ nm_setting_compare(NMSetting *a, NMSetting *b, NMSettingCompareFlags flags) } gboolean -_nm_setting_compare(NMConnection * con_a, - NMSetting * a, - NMConnection * con_b, - NMSetting * b, +_nm_setting_compare(NMConnection *con_a, + NMSetting *a, + NMConnection *con_b, + NMSetting *b, NMSettingCompareFlags flags) { const NMSettInfoSetting *sett_info; @@ -2579,23 +2579,23 @@ _setting_diff_add_result(GHashTable *results, const char *prop_name, NMSettingDi * Returns: %TRUE if the settings contain the same values, %FALSE if they do not **/ gboolean -nm_setting_diff(NMSetting * a, - NMSetting * b, +nm_setting_diff(NMSetting *a, + NMSetting *b, NMSettingCompareFlags flags, gboolean invert_results, - GHashTable ** results) + GHashTable **results) { return _nm_setting_diff(NULL, a, NULL, b, flags, invert_results, results); } gboolean -_nm_setting_diff(NMConnection * con_a, - NMSetting * a, - NMConnection * con_b, - NMSetting * b, +_nm_setting_diff(NMConnection *con_a, + NMSetting *a, + NMConnection *con_b, + NMSetting *b, NMSettingCompareFlags flags, gboolean invert_results, - GHashTable ** results) + GHashTable **results) { const NMSettInfoSetting *sett_info; NMSettingDiffResult a_result = NM_SETTING_DIFF_RESULT_IN_A; @@ -2650,11 +2650,11 @@ _nm_setting_diff(NMConnection * con_a, sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(a)); if (sett_info->detail.gendata_info) { - const char * key; - GVariant * val, *val2; + const char *key; + GVariant *val, *val2; GHashTableIter iter; - GenData * a_gendata = _gendata_hash(a, FALSE); - GenData * b_gendata = b ? _gendata_hash(b, FALSE) : NULL; + GenData *a_gendata = _gendata_hash(a, FALSE); + GenData *b_gendata = b ? _gendata_hash(b, FALSE) : NULL; if (!a_gendata || !b_gendata) { if (a_gendata || b_gendata) { @@ -2692,7 +2692,7 @@ _nm_setting_diff(NMConnection * con_a, NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN; const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; NMTernary compare_result; - GParamSpec * prop_spec; + GParamSpec *prop_spec; compare_result = _compare_property(sett_info, property_info, con_a, a, con_b, b, flags); if (compare_result == NM_TERNARY_DEFAULT) @@ -2809,7 +2809,7 @@ _nm_setting_diff(NMConnection * con_a, static void enumerate_values(const NMSettInfoProperty *property_info, - NMSetting * setting, + NMSetting *setting, NMSettingValueIterFn func, gpointer user_data) { @@ -2859,7 +2859,7 @@ nm_setting_enumerate_values(NMSetting *setting, NMSettingValueIterFn func, gpoin n_properties = _nm_setting_option_get_all(setting, &names, NULL); if (n_properties > 0) { gs_strfreev char **keys = g_strdupv((char **) names); - GHashTable * h = _gendata_hash(setting, FALSE)->hash; + GHashTable *h = _gendata_hash(setting, FALSE)->hash; for (i = 0; i < n_properties; i++) { GValue value = G_VALUE_INIT; @@ -2894,7 +2894,7 @@ static gboolean aggregate(NMSetting *setting, int type_i, gpointer arg) { NMConnectionAggregateType type = type_i; - const NMSettInfoSetting * sett_info; + const NMSettInfoSetting *sett_info; guint16 i; nm_assert(NM_IN_SET(type, @@ -2903,8 +2903,8 @@ aggregate(NMSetting *setting, int type_i, gpointer arg) sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); for (i = 0; i < sett_info->property_infos_len; i++) { - const NMSettInfoProperty * property_info = &sett_info->property_infos[i]; - GParamSpec * prop_spec = property_info->param_spec; + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; + GParamSpec *prop_spec = property_info->param_spec; nm_auto_unset_gvalue GValue value = G_VALUE_INIT; NMSettingSecretFlags secret_flags; @@ -2969,14 +2969,14 @@ _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType type, gpoint } static gboolean -clear_secrets(const NMSettInfoSetting * sett_info, - const NMSettInfoProperty * property_info, - NMSetting * setting, +clear_secrets(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - GParamSpec * param_spec = property_info->param_spec; + GParamSpec *param_spec = property_info->param_spec; if (!param_spec) return FALSE; @@ -3019,13 +3019,13 @@ clear_secrets(const NMSettInfoSetting * sett_info, * Returns: %TRUE if the setting changed at all **/ gboolean -_nm_setting_clear_secrets(NMSetting * setting, +_nm_setting_clear_secrets(NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { const NMSettInfoSetting *sett_info; gboolean changed = FALSE; - NMSettingClass * klass; + NMSettingClass *klass; guint16 i; g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); @@ -3073,7 +3073,7 @@ _nm_setting_need_secrets(NMSetting *setting) static int update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError **error) { - const NMSettInfoSetting * sett_info; + const NMSettInfoSetting *sett_info; const NMSettInfoProperty *property_info; gboolean is_modified; @@ -3125,9 +3125,9 @@ NMSettingUpdateSecretResult _nm_setting_update_secrets(NMSetting *setting, GVariant *secrets, GError **error) { GVariantIter iter; - const char * secret_key; - GVariant * secret_value; - GError * tmp_error = NULL; + const char *secret_key; + GVariant *secret_value; + GError *tmp_error = NULL; NMSettingUpdateSecretResult result = NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED; g_return_val_if_fail(NM_IS_SETTING(setting), NM_SETTING_UPDATE_SECRET_ERROR); @@ -3161,13 +3161,13 @@ _nm_setting_update_secrets(NMSetting *setting, GVariant *secrets, GError **error } static void -for_each_secret(NMSetting * setting, - const char * secret_name, - GVariant * val, +for_each_secret(NMSetting *setting, + const char *secret_name, + GVariant *val, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data, - GVariantBuilder * setting_builder) + GVariantBuilder *setting_builder) { NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; @@ -3219,13 +3219,13 @@ _nm_setting_property_is_regular_secret_flags(NMSetting *setting, const char *sec } static gboolean -get_secret_flags(NMSetting * setting, - const char * secret_name, +get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { - gs_free char * secret_flags_name_free = NULL; - const char * secret_flags_name; + gs_free char *secret_flags_name_free = NULL; + const char *secret_flags_name; NMSettingSecretFlags flags; if (!_nm_setting_property_is_regular_secret(setting, secret_name)) { @@ -3257,10 +3257,10 @@ get_secret_flags(NMSetting * setting, * this setting, and if that property is secret), %FALSE if not **/ gboolean -nm_setting_get_secret_flags(NMSetting * setting, - const char * secret_name, +nm_setting_get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); g_return_val_if_fail(secret_name != NULL, FALSE); @@ -3269,13 +3269,13 @@ nm_setting_get_secret_flags(NMSetting * setting, } static gboolean -set_secret_flags(NMSetting * setting, - const char * secret_name, +set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { gs_free char *secret_flags_name_free = NULL; - const char * secret_flags_name; + const char *secret_flags_name; if (!_nm_setting_property_is_regular_secret(setting, secret_name)) { _set_error_secret_property_not_found(error, setting, secret_name); @@ -3309,10 +3309,10 @@ set_secret_flags(NMSetting * setting, * this setting, and if that property is secret), %FALSE if not **/ gboolean -nm_setting_set_secret_flags(NMSetting * setting, - const char * secret_name, +nm_setting_set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); g_return_val_if_fail(secret_name != NULL, FALSE); @@ -3337,9 +3337,9 @@ nm_setting_set_secret_flags(NMSetting * setting, char * nm_setting_to_string(NMSetting *setting) { - GString * string; + GString *string; gs_unref_variant GVariant *variant = NULL; - GVariant * child; + GVariant *child; GVariantIter iter; string = g_string_new(nm_setting_get_name(setting)); @@ -3349,9 +3349,9 @@ nm_setting_to_string(NMSetting *setting) g_variant_iter_init(&iter, variant); while ((child = g_variant_iter_next_value(&iter))) { - gs_free char * name = NULL; - gs_free char * value_str = NULL; - gs_unref_variant GVariant *value = NULL; + gs_free char *name = NULL; + gs_free char *value_str = NULL; + gs_unref_variant GVariant *value = NULL; g_variant_get(child, "{sv}", &name, &value); value_str = g_variant_print(value, FALSE); @@ -3568,11 +3568,11 @@ out: } guint -_nm_setting_option_get_all(NMSetting * setting, +_nm_setting_option_get_all(NMSetting *setting, const char *const **out_names, - GVariant *const ** out_values) + GVariant *const **out_values) { - GenData * gendata; + GenData *gendata; GHashTable *hash; guint i, len; @@ -3668,9 +3668,9 @@ _nm_setting_option_clear(NMSetting *setting, const char *optname) void nm_setting_option_clear_by_name(NMSetting *setting, NMUtilsPredicateStr predicate) { - GHashTable * hash; + GHashTable *hash; GHashTableIter iter; - const char * name; + const char *name; gboolean changed = FALSE; g_return_if_fail(NM_IS_SETTING(setting)); @@ -3790,7 +3790,7 @@ nm_setting_option_get_uint32(NMSetting *setting, const char *opt_name, guint32 * void nm_setting_option_set(NMSetting *setting, const char *opt_name, GVariant *variant) { - GVariant * old_variant; + GVariant *old_variant; gboolean changed_name; gboolean changed_value; GHashTable *hash; @@ -3850,7 +3850,7 @@ nm_setting_option_set(NMSetting *setting, const char *opt_name, GVariant *varian void nm_setting_option_set_boolean(NMSetting *setting, const char *opt_name, gboolean value) { - GVariant * old_variant; + GVariant *old_variant; gboolean changed_name; gboolean changed_value; GHashTable *hash; @@ -3887,7 +3887,7 @@ nm_setting_option_set_boolean(NMSetting *setting, const char *opt_name, gboolean void nm_setting_option_set_uint32(NMSetting *setting, const char *opt_name, guint32 value) { - GVariant * old_variant; + GVariant *old_variant; gboolean changed_name; gboolean changed_value; GHashTable *hash; @@ -3936,7 +3936,7 @@ nm_setting_init(NMSetting *setting) static void constructed(GObject *object) { - NMSetting * self = NM_SETTING(object); + NMSetting *self = NM_SETTING(object); NMSettingClass *klass = NM_SETTING_GET_CLASS(self); /* we don't support that NMSetting subclasses override constructed. @@ -3962,7 +3962,7 @@ constructed(GObject *object) static void finalize(GObject *object) { - NMSetting * self = NM_SETTING(object); + NMSetting *self = NM_SETTING(object); NMSettingPrivate *priv = NM_SETTING_GET_PRIVATE(self); if (priv->gendata) { diff --git a/src/libnm-core-impl/nm-simple-connection.c b/src/libnm-core-impl/nm-simple-connection.c index f16d9d59c6..5039b13b91 100644 --- a/src/libnm-core-impl/nm-simple-connection.c +++ b/src/libnm-core-impl/nm-simple-connection.c @@ -139,7 +139,7 @@ NMConnection * nm_simple_connection_new_clone(NMConnection *connection) { NMConnection *clone; - const char * path; + const char *path; g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL); diff --git a/src/libnm-core-impl/nm-team-utils.c b/src/libnm-core-impl/nm-team-utils.c index f67c08be68..2f62f6c613 100644 --- a/src/libnm-core-impl/nm-team-utils.c +++ b/src/libnm-core-impl/nm-team-utils.c @@ -133,7 +133,7 @@ static const RunnerCompatElem _runner_compat_lst[] = { typedef struct { const char *const *js_keys; - const char * property_name; + const char *property_name; NMValueTypUnion default_val; union { struct { @@ -377,8 +377,8 @@ typedef enum { LINK_WATCHER_ATTRIBUTE_VLANID, LINK_WATCHER_ATTRIBUTE_SEND_ALWAYS typedef struct { - const char * js_key; - const char * dbus_name; + const char *js_key; + const char *dbus_name; NMValueTypUnion default_val; LinkWatcherAttribute link_watcher_attr; NMValueType value_type; @@ -389,9 +389,9 @@ static const LinkWatcherAttrData link_watcher_attr_datas[] = { [_link_watcher_attr] = {.link_watcher_attr = (_link_watcher_attr), \ .value_type = (_value_type), \ .js_key = (""_js_key \ - ""), \ + ""), \ .dbus_name = (""_dbus_name \ - ""), \ + ""), \ __VA_ARGS__} _INIT(LINK_WATCHER_ATTRIBUTE_NAME, "name", "name", NM_VALUE_TYPE_STRING, ), _INIT(LINK_WATCHER_ATTRIBUTE_DELAY_UP, "delay_up", "delay-up", NM_VALUE_TYPE_INT, ), @@ -547,9 +547,9 @@ _team_attr_data_copy(const TeamAttrData *attr_data, gpointer dst, gconstpointer src) { - GPtrArray * v_ptrarray_dst; + GPtrArray *v_ptrarray_dst; const GPtrArray *v_ptrarray_src; - GPtrArray * dst_array; + GPtrArray *dst_array; guint i, len; if (attr_data->value_type != NM_VALUE_TYPE_UNSPEC) @@ -595,7 +595,7 @@ _team_attr_data_copy(const TeamAttrData *attr_data, static void _team_attr_data_to_json(const TeamAttrData *attr_data, gboolean is_port, - GString * gstr, + GString *gstr, gconstpointer p_field) { guint i; @@ -677,7 +677,7 @@ _team_setting_has_field(const NMTeamSetting *self, const TeamAttrData *attr_data } static gboolean -_team_setting_has_fields_any_v(const NMTeamSetting * self, +_team_setting_has_fields_any_v(const NMTeamSetting *self, const NMTeamAttribute *team_attrs, gsize n_team_attrs) { @@ -698,7 +698,7 @@ _team_setting_has_fields_any_v(const NMTeamSetting * self, NM_NARG(__VA_ARGS__)) static void -_team_setting_has_field_set(NMTeamSetting * self, +_team_setting_has_field_set(NMTeamSetting *self, const TeamAttrData *attr_data, SetFieldModeEnum set_field_mode) { @@ -745,7 +745,7 @@ _team_setting_get_field(const NMTeamSetting *self, const TeamAttrData *attr_data } static guint32 -_team_setting_attribute_changed(NMTeamSetting * self, +_team_setting_attribute_changed(NMTeamSetting *self, const TeamAttrData *attr_data, gboolean changed, SetFieldModeEnum set_field_mode, @@ -785,7 +785,7 @@ _team_setting_attribute_changed(NMTeamSetting * self, } static guint32 -_team_setting_attribute_changed_attr(NMTeamSetting * self, +_team_setting_attribute_changed_attr(NMTeamSetting *self, NMTeamAttribute team_attr, gboolean changed, SetFieldModeEnum set_field_mode, @@ -800,9 +800,9 @@ _team_setting_attribute_changed_attr(NMTeamSetting * self, static gboolean _team_setting_field_to_json(const NMTeamSetting *self, - GString * gstr, + GString *gstr, gboolean prepend_delimiter, - const TeamAttrData * attr_data) + const TeamAttrData *attr_data) { if (!_team_setting_has_field(self, attr_data)) return FALSE; @@ -817,8 +817,8 @@ _team_setting_field_to_json(const NMTeamSetting *self, } static gboolean -_team_setting_fields_to_json_maybe(const NMTeamSetting * self, - GString * gstr, +_team_setting_fields_to_json_maybe(const NMTeamSetting *self, + GString *gstr, gboolean prepend_delimiter, const NMTeamAttribute *team_attrs_lst, gsize team_attrs_lst_len) @@ -839,9 +839,9 @@ _team_setting_fields_to_json_maybe(const NMTeamSetting * self, } static guint32 -_team_setting_set(NMTeamSetting * self, +_team_setting_set(NMTeamSetting *self, gboolean modify, - const bool * has_lst, + const bool *has_lst, const NMValueTypUnion *val_lst) { guint32 changed_flags = 0; @@ -914,7 +914,7 @@ _nm_team_setting_value_get(const NMTeamSetting *self, } static guint32 -_team_setting_value_set(NMTeamSetting * self, +_team_setting_value_set(NMTeamSetting *self, const TeamAttrData *attr_data, gconstpointer val, SetFieldModeEnum set_field_mode, @@ -936,7 +936,7 @@ _team_setting_value_set(NMTeamSetting * self, } guint32 -nm_team_setting_value_reset(NMTeamSetting * self, +nm_team_setting_value_reset(NMTeamSetting *self, NMTeamAttribute team_attr, gboolean to_default /* or else unset */) { @@ -954,7 +954,7 @@ nm_team_setting_value_reset(NMTeamSetting * self, } guint32 -_nm_team_setting_value_set(NMTeamSetting * self, +_nm_team_setting_value_set(NMTeamSetting *self, NMTeamAttribute team_attr, NMValueType value_type, gconstpointer val) @@ -998,7 +998,7 @@ out: } guint32 -nm_team_setting_value_link_watchers_remove_by_value(NMTeamSetting * self, +nm_team_setting_value_link_watchers_remove_by_value(NMTeamSetting *self, const NMTeamLinkWatcher *link_watcher) { guint i; @@ -1026,7 +1026,7 @@ nm_team_setting_value_link_watchers_remove(NMTeamSetting *self, guint idx) } static guint32 -_team_setting_value_link_watchers_set_list(NMTeamSetting * self, +_team_setting_value_link_watchers_set_list(NMTeamSetting *self, const NMTeamLinkWatcher *const *arr, guint len, SetFieldModeEnum set_field_mode, @@ -1074,7 +1074,7 @@ out: } guint32 -nm_team_setting_value_link_watchers_set_list(NMTeamSetting * self, +nm_team_setting_value_link_watchers_set_list(NMTeamSetting *self, const NMTeamLinkWatcher *const *arr, guint len) { @@ -1125,7 +1125,7 @@ nm_team_setting_value_master_runner_tx_hash_remove(NMTeamSetting *self, guint id } static guint32 -_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self, +_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting *self, const char *const *arr, guint len, SetFieldModeEnum set_field_mode, @@ -1167,7 +1167,7 @@ out: } guint32 -nm_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self, +nm_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting *self, const char *const *arr, guint len) { @@ -1214,7 +1214,7 @@ static void _link_watcher_unpack(const NMTeamLinkWatcher *link_watcher, NMValueTypUnioMaybe args[static G_N_ELEMENTS(link_watcher_attr_datas)]) { - const char * v_name = nm_team_link_watcher_get_name(link_watcher); + const char *v_name = nm_team_link_watcher_get_name(link_watcher); NMTeamLinkWatcherArpPingFlags v_arp_ping_flags; memset(args, 0, sizeof(args[0]) * G_N_ELEMENTS(link_watcher_attr_datas)); @@ -1305,22 +1305,22 @@ _link_watcher_to_json(const NMTeamLinkWatcher *link_watcher, GString *gstr) } static NMTeamLinkWatcher * -_link_watcher_from_json(const NMJsonVt * vt, +_link_watcher_from_json(const NMJsonVt *vt, const nm_json_t *root_js_obj, - gboolean * out_unrecognized_content) + gboolean *out_unrecognized_content) { NMValueTypUnioMaybe args[G_N_ELEMENTS(link_watcher_attr_datas)] = {}; - const char * j_key; - nm_json_t * j_val; - const char * v_name; - NMTeamLinkWatcher * result = NULL; + const char *j_key; + nm_json_t *j_val; + const char *v_name; + NMTeamLinkWatcher *result = NULL; if (!nm_json_is_object(root_js_obj)) goto fail; nm_json_object_foreach (vt, (nm_json_t *) root_js_obj, j_key, j_val) { const LinkWatcherAttrData *attr_data = NULL; - NMValueTypUnioMaybe * parse_result; + NMValueTypUnioMaybe *parse_result; if (j_key) { int i; @@ -1434,7 +1434,7 @@ _link_watcher_to_variant(const NMTeamLinkWatcher *link_watcher) for (i = 0; i < (int) G_N_ELEMENTS(link_watcher_attr_datas); i++) { const NMValueTypUnioMaybe *p_val = &args[i]; const LinkWatcherAttrData *attr_data = &link_watcher_attr_datas[i]; - GVariant * v; + GVariant *v; if (!p_val->has) continue; @@ -1459,7 +1459,7 @@ _link_watcher_to_variant(const NMTeamLinkWatcher *link_watcher) #define _LINK_WATCHER_ATTR_VARGET(variants, link_watcher_attribute, _value_type, c_type, _cmd) \ ({ \ GVariant *const *_variants = (variants); \ - GVariant * _cc; \ + GVariant *_cc; \ \ nm_assert(link_watcher_attr_datas[(link_watcher_attribute)].value_type == (_value_type)); \ \ @@ -1502,9 +1502,9 @@ _link_watcher_from_variant(GVariant *watcher_var, gboolean strict_parsing, GErro GVariant *variants[G_N_ELEMENTS(link_watcher_attr_datas)] = { NULL, }; - const char * v_key; - GVariant * v_val; - const char * v_name; + const char *v_key; + GVariant *v_val; + const char *v_name; GVariantIter iter; g_return_val_if_fail(g_variant_is_of_type(watcher_var, G_VARIANT_TYPE("a{sv}")), NULL); @@ -1512,8 +1512,8 @@ _link_watcher_from_variant(GVariant *watcher_var, gboolean strict_parsing, GErro g_variant_iter_init(&iter, watcher_var); while (g_variant_iter_next(&iter, "{&sv}", &v_key, &v_val)) { _nm_unused gs_unref_variant GVariant *v_val_free = v_val; - const LinkWatcherAttrData * attr_data = NULL; - const GVariantType * variant_type; + const LinkWatcherAttrData *attr_data = NULL; + const GVariantType *variant_type; int i; for (i = 0; i < (int) G_N_ELEMENTS(link_watcher_attr_datas); i++) { @@ -1704,7 +1704,7 @@ _nm_utils_team_link_watchers_from_variant(GVariant *value, gboolean strict_parsi { gs_unref_ptrarray GPtrArray *link_watchers = NULL; GVariantIter iter; - GVariant * watcher_var; + GVariant *watcher_var; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -1713,7 +1713,7 @@ _nm_utils_team_link_watchers_from_variant(GVariant *value, gboolean strict_parsi g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "@a{sv}", &watcher_var)) { _nm_unused gs_unref_variant GVariant *watcher_var_free = watcher_var; - NMTeamLinkWatcher * watcher; + NMTeamLinkWatcher *watcher; watcher = _link_watcher_from_variant(watcher_var, strict_parsing, error); if (error && *error) @@ -1942,18 +1942,18 @@ _attr_data_find_by_json_key(gboolean is_port, const char *const *keys, guint8 n_ static void _js_parse_locate_keys(const NMJsonVt *vt, - NMTeamSetting * self, - nm_json_t * root_js_obj, - nm_json_t * found_keys[static _NM_TEAM_ATTRIBUTE_NUM], - gboolean * out_unrecognized_content) + NMTeamSetting *self, + nm_json_t *root_js_obj, + nm_json_t *found_keys[static _NM_TEAM_ATTRIBUTE_NUM], + gboolean *out_unrecognized_content) { const char *keys[3]; const char *cur_key1; const char *cur_key2; const char *cur_key3; - nm_json_t * cur_val1; - nm_json_t * cur_val2; - nm_json_t * cur_val3; + nm_json_t *cur_val1; + nm_json_t *cur_val2; + nm_json_t *cur_val3; nm_assert(vt); @@ -2007,12 +2007,12 @@ _js_parse_locate_keys(const NMJsonVt *vt, static void _js_parse_unpack(const NMJsonVt *vt, gboolean is_port, - nm_json_t * found_keys[static _NM_TEAM_ATTRIBUTE_NUM], + nm_json_t *found_keys[static _NM_TEAM_ATTRIBUTE_NUM], bool out_has_lst[static _NM_TEAM_ATTRIBUTE_NUM], NMValueTypUnion out_val_lst[static _NM_TEAM_ATTRIBUTE_NUM], - gboolean * out_unrecognized_content, - GPtrArray ** out_ptr_array_link_watchers_free, - GPtrArray ** out_ptr_array_master_runner_tx_hash_free) + gboolean *out_unrecognized_content, + GPtrArray **out_ptr_array_link_watchers_free, + GPtrArray **out_ptr_array_master_runner_tx_hash_free) { const TeamAttrData *attr_data; @@ -2023,7 +2023,7 @@ _js_parse_unpack(const NMJsonVt *vt, attr_data++) { NMValueTypUnion *p_out_val; gboolean valid = FALSE; - nm_json_t * arg_js_obj; + nm_json_t *arg_js_obj; if (!_team_attr_data_is_relevant(attr_data, is_port)) continue; @@ -2039,7 +2039,7 @@ _js_parse_unpack(const NMJsonVt *vt, if (attr_data->value_type != NM_VALUE_TYPE_UNSPEC) valid = nm_value_type_from_json(vt, attr_data->value_type, arg_js_obj, p_out_val); else if (attr_data->team_attr == NM_TEAM_ATTRIBUTE_LINK_WATCHERS) { - GPtrArray * link_watchers = NULL; + GPtrArray *link_watchers = NULL; NMTeamLinkWatcher *link_watcher; nm_assert(out_ptr_array_link_watchers_free && !*out_ptr_array_link_watchers_free); @@ -2151,7 +2151,7 @@ nm_team_setting_config_set(NMTeamSetting *self, const char *js_str) FALSE, }; NMValueTypUnion val_lst[_NM_TEAM_ATTRIBUTE_NUM]; - nm_json_t * found_keys[_NM_TEAM_ATTRIBUTE_NUM] = { + nm_json_t *found_keys[_NM_TEAM_ATTRIBUTE_NUM] = { NULL, }; gs_unref_ptrarray GPtrArray *ptr_array_master_runner_tx_hash_free = NULL; @@ -2199,9 +2199,9 @@ _team_setting_prefix_error_plain(gboolean is_port, const char *property_name, GE static void _team_setting_prefix_error(const NMTeamSetting *self, - const char * prop_name_master, - const char * prop_name_port, - GError ** error) + const char *prop_name_master, + const char *prop_name_port, + GError **error) { _team_setting_ASSERT(self); nm_assert(self->d.is_port ? (!!prop_name_port) : (!!prop_name_master)); @@ -2501,29 +2501,29 @@ _variants_list_team_unref_auto(GVariant *(*p_variants)[]) } gboolean -nm_team_setting_reset_from_dbus(NMTeamSetting * self, - GVariant * setting_dict, - GHashTable * keys, - guint32 * out_changed, +nm_team_setting_reset_from_dbus(NMTeamSetting *self, + GVariant *setting_dict, + GHashTable *keys, + guint32 *out_changed, guint /* NMSettingParseFlags */ parse_flags, - GError ** error) + GError **error) { nm_auto(_variants_list_team_unref_auto) GVariant *variants[_NM_TEAM_ATTRIBUTE_NUM] = { NULL, }; gs_unref_ptrarray GPtrArray *v_link_watchers = NULL; - const TeamAttrData * attr_data; + const TeamAttrData *attr_data; GVariantIter iter; - const char * v_key; - GVariant * v_val; - const NMJsonVt * vt; + const char *v_key; + GVariant *v_val; + const NMJsonVt *vt; *out_changed = 0; g_variant_iter_init(&iter, setting_dict); while (g_variant_iter_next(&iter, "{&sv}", &v_key, &v_val)) { _nm_unused gs_unref_variant GVariant *v_val_free = v_val; - const GVariantType * variant_type = NULL; + const GVariantType *variant_type = NULL; attr_data = _team_attr_data_find_for_property_name(self->d.is_port, v_key); if (!attr_data) { @@ -2678,7 +2678,7 @@ nm_team_setting_reset_from_dbus(NMTeamSetting * self, /*****************************************************************************/ gboolean -nm_team_setting_maybe_changed(NMSetting * source, +nm_team_setting_maybe_changed(NMSetting *source, const GParamSpec *const *obj_properties, guint32 changed_flags) { @@ -2727,7 +2727,7 @@ _nm_setting_get_team_setting(struct _NMSetting *setting) GVariant * _nm_team_settings_property_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - NMTeamSetting * self = _nm_setting_get_team_setting(setting); + NMTeamSetting *self = _nm_setting_get_team_setting(setting); const TeamAttrData *attr_data = _team_attr_data_get(self->d.is_port, property_info->param_spec->param_id); diff --git a/src/libnm-core-impl/nm-team-utils.h b/src/libnm-core-impl/nm-team-utils.h index d888e191f8..06fa6cc8b8 100644 --- a/src/libnm-core-impl/nm-team-utils.h +++ b/src/libnm-core-impl/nm-team-utils.h @@ -87,10 +87,10 @@ struct _NMTeamSettingData { union { struct { const GPtrArray *runner_tx_hash; - const char * runner; - const char * runner_hwaddr_policy; - const char * runner_tx_balancer; - const char * runner_agg_select_policy; + const char *runner; + const char *runner_hwaddr_policy; + const char *runner_tx_balancer; + const char *runner_agg_select_policy; gint32 notify_peers_count; gint32 notify_peers_interval; gint32 mcast_rejoin_count; @@ -169,11 +169,11 @@ nm_team_setting_value_get_string(const NMTeamSetting *self, NMTeamAttribute team /*****************************************************************************/ -guint32 nm_team_setting_value_reset(NMTeamSetting * self, +guint32 nm_team_setting_value_reset(NMTeamSetting *self, NMTeamAttribute team_attr, gboolean to_default /* or else unset */); -guint32 _nm_team_setting_value_set(NMTeamSetting * self, +guint32 _nm_team_setting_value_set(NMTeamSetting *self, NMTeamAttribute team_attr, NMValueType value_type, gconstpointer val); @@ -200,16 +200,16 @@ nm_team_setting_value_set_string(NMTeamSetting *self, NMTeamAttribute team_attr, /*****************************************************************************/ -guint32 nm_team_setting_value_link_watchers_add(NMTeamSetting * self, +guint32 nm_team_setting_value_link_watchers_add(NMTeamSetting *self, const struct NMTeamLinkWatcher *link_watcher); guint32 nm_team_setting_value_link_watchers_remove(NMTeamSetting *self, guint idx); guint32 -nm_team_setting_value_link_watchers_remove_by_value(NMTeamSetting * self, +nm_team_setting_value_link_watchers_remove_by_value(NMTeamSetting *self, const struct NMTeamLinkWatcher *link_watcher); -guint32 nm_team_setting_value_link_watchers_set_list(NMTeamSetting * self, +guint32 nm_team_setting_value_link_watchers_set_list(NMTeamSetting *self, const struct NMTeamLinkWatcher *const *arr, guint len); @@ -219,7 +219,7 @@ guint32 nm_team_setting_value_master_runner_tx_hash_add(NMTeamSetting *self, con guint32 nm_team_setting_value_master_runner_tx_hash_remove(NMTeamSetting *self, guint idx); -guint32 nm_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self, +guint32 nm_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting *self, const char *const *arr, guint len); @@ -235,12 +235,12 @@ int nm_team_setting_cmp(const NMTeamSetting *self_a, guint32 nm_team_setting_reset(NMTeamSetting *self, const NMTeamSetting *src); -gboolean nm_team_setting_reset_from_dbus(NMTeamSetting * self, - GVariant * setting_dict, - GHashTable * keys, - guint32 * out_changed, +gboolean nm_team_setting_reset_from_dbus(NMTeamSetting *self, + GVariant *setting_dict, + GHashTable *keys, + guint32 *out_changed, guint /* NMSettingParseFlags */ parse_flags, - GError ** error); + GError **error); /*****************************************************************************/ @@ -250,7 +250,7 @@ GVariant *_nm_utils_team_link_watchers_to_variant(const GPtrArray *link_watchers /*****************************************************************************/ -gboolean nm_team_setting_maybe_changed(struct _NMSetting * source, +gboolean nm_team_setting_maybe_changed(struct _NMSetting *source, const GParamSpec *const *obj_properties, guint32 changed); diff --git a/src/libnm-core-impl/nm-utils-private.h b/src/libnm-core-impl/nm-utils-private.h index 679fd6b4fa..49802753d1 100644 --- a/src/libnm-core-impl/nm-utils-private.h +++ b/src/libnm-core-impl/nm-utils-private.h @@ -19,16 +19,16 @@ gboolean _nm_utils_string_slist_validate(GSList *list, const char **valid_values); gboolean _nm_utils_secret_flags_validate(NMSettingSecretFlags secret_flags, - const char * setting_name, - const char * property_name, + const char *setting_name, + const char *property_name, NMSettingSecretFlags disallowed_flags, - GError ** error); + GError **error); gboolean _nm_utils_wps_method_validate(NMSettingWirelessSecurityWpsMethod wps_method, - const char * setting_name, - const char * property_name, + const char *setting_name, + const char *property_name, gboolean wps_required, - GError ** error); + GError **error); /* D-Bus transform funcs */ @@ -50,9 +50,9 @@ gboolean _nm_utils_hwaddr_link_local_valid(const char *mac); gboolean _nm_sriov_vf_parse_vlans(NMSriovVF *vf, const char *str, GError **error); -gboolean _nm_utils_bridge_vlan_verify_list(GPtrArray * vlans, +gboolean _nm_utils_bridge_vlan_verify_list(GPtrArray *vlans, gboolean check_normalizable, - GError ** error, + GError **error, const char *setting, const char *property); diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index ccdd4b92a6..12a4780e39 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -79,7 +79,7 @@ NM_IS_SOCK_ADDR_ENDPOINT(const NMSockAddrEndpoint *self) static const char * _parse_endpoint(char *str, guint16 *out_port) { - char * s; + char *s; const char *s_port; gint16 port; @@ -147,8 +147,8 @@ nm_sock_addr_endpoint_new(const char *endpoint) gsize l_endpoint; gsize l_host = 0; gsize i; - gs_free char * host_clone = NULL; - const char * host; + gs_free char *host_clone = NULL; + const char *host; guint16 port; g_return_val_if_fail(endpoint, NULL); @@ -294,7 +294,7 @@ nm_sock_addr_endpoint_get_fixed_sockaddr(NMSockAddrEndpoint *self, gpointer sock { gs_free char *tmp_str = NULL; - const char * host_part; + const char *host_part; host_part = nm_strndup_a(200, self->host, s - self->host, &tmp_str); if (nm_utils_parse_inaddr_bin(AF_INET6, host_part, &addr_family, &addrbin)) @@ -329,7 +329,7 @@ good: /*****************************************************************************/ struct IsoLangToEncodings { - const char * lang; + const char *lang; const char *const *encodings; }; @@ -458,9 +458,9 @@ static const char *const * get_system_encodings(void) { static const char *const *cached_encodings; - static char * default_encodings[4]; - const char *const * encodings = NULL; - char * lang; + static char *default_encodings[4]; + const char *const *encodings = NULL; + char *lang; if (cached_encodings) return cached_encodings; @@ -560,7 +560,7 @@ nm_utils_ssid_to_utf8(const guint8 *ssid, gsize len) { const char *const *encodings; const char *const *e; - char * converted = NULL; + char *converted = NULL; g_return_val_if_fail(ssid != NULL, NULL); @@ -652,7 +652,7 @@ nm_utils_escape_ssid(const guint8 *ssid, gsize len) { static char escaped[NM_IW_ESSID_MAX_SIZE * 2 + 1]; const guint8 *s = ssid; - char * d = escaped; + char *d = escaped; if (nm_utils_is_empty_ssid(ssid, len)) { memcpy(escaped, "", sizeof("")); @@ -746,9 +746,9 @@ _nm_utils_string_slist_validate(GSList *list, const char **valid_values) GSList * _nm_utils_hash_values_to_slist(GHashTable *hash) { - GSList * list = NULL; + GSList *list = NULL; GHashTableIter iter; - void * value; + void *value; g_return_val_if_fail(hash, NULL); @@ -763,8 +763,8 @@ void _nm_utils_strdict_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil) { GVariantIter iter; - const char * key, *value; - GHashTable * hash; + const char *key, *value; + GHashTable *hash; hash = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); g_variant_iter_init(&iter, from); @@ -786,7 +786,7 @@ const NMSettInfoPropertType nm_sett_info_propert_type_strdict = GHashTable * _nm_utils_copy_strdict(GHashTable *strdict) { - GHashTable * copy; + GHashTable *copy; GHashTableIter iter; gpointer key, value; @@ -861,7 +861,7 @@ char ** _nm_utils_slist_to_strv(const GSList *slist, gboolean deep_copy) { const GSList *iter; - char ** strv; + char **strv; guint len, i; if (!slist) @@ -1328,7 +1328,7 @@ nm_utils_ip4_dns_from_variant(GVariant *value) { const guint32 *array; gsize length; - char ** dns; + char **dns; gsize i; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("au")), NULL); @@ -1409,9 +1409,9 @@ nm_utils_ip4_addresses_to_variant(GPtrArray *addresses, const char *gateway) GPtrArray * nm_utils_ip4_addresses_from_variant(GVariant *value, char **out_gateway) { - GPtrArray * addresses; + GPtrArray *addresses; GVariantIter iter; - GVariant * addr_var; + GVariant *addr_var; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aau")), NULL); @@ -1424,8 +1424,8 @@ nm_utils_ip4_addresses_from_variant(GVariant *value, char **out_gateway) while (g_variant_iter_next(&iter, "@au", &addr_var)) { const guint32 *addr_array; gsize length; - NMIPAddress * addr; - GError * error = NULL; + NMIPAddress *addr; + GError *error = NULL; addr_array = g_variant_get_fixed_array(addr_var, &length, sizeof(guint32)); if (length < 3) { @@ -1506,8 +1506,8 @@ GPtrArray * nm_utils_ip4_routes_from_variant(GVariant *value) { GVariantIter iter; - GVariant * route_var; - GPtrArray * routes; + GVariant *route_var; + GPtrArray *routes; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aau")), NULL); @@ -1517,8 +1517,8 @@ nm_utils_ip4_routes_from_variant(GVariant *value) while (g_variant_iter_next(&iter, "@au", &route_var)) { const guint32 *route_array; gsize length; - NMIPRoute * route; - GError * error = NULL; + NMIPRoute *route; + GError *error = NULL; route_array = g_variant_get_fixed_array(route_var, &length, sizeof(guint32)); if (length < 4) { @@ -1647,8 +1647,8 @@ char ** nm_utils_ip6_dns_from_variant(GVariant *value) { GVariantIter iter; - GVariant * ip_var; - char ** dns; + GVariant *ip_var; + char **dns; gsize i; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aay")), NULL); @@ -1695,7 +1695,7 @@ nm_utils_ip6_addresses_to_variant(GPtrArray *addresses, const char *gateway) if (addresses) { for (i = 0; i < addresses->len; i++) { - NMIPAddress * addr = addresses->pdata[i]; + NMIPAddress *addr = addresses->pdata[i]; struct in6_addr address_bin; struct in6_addr gateway_bin_data; const struct in6_addr *gateway_bin; @@ -1741,9 +1741,9 @@ GPtrArray * nm_utils_ip6_addresses_from_variant(GVariant *value, char **out_gateway) { GVariantIter iter; - GVariant * addr_var, *gateway_var; + GVariant *addr_var, *gateway_var; guint32 prefix; - GPtrArray * addresses; + GPtrArray *addresses; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("a(ayuay)")), NULL); @@ -1754,10 +1754,10 @@ nm_utils_ip6_addresses_from_variant(GVariant *value, char **out_gateway) addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref); while (g_variant_iter_next(&iter, "(@ayu@ay)", &addr_var, &prefix, &gateway_var)) { - NMIPAddress * addr; + NMIPAddress *addr; const struct in6_addr *addr_bytes, *gateway_bytes; gsize addr_len, gateway_len; - GError * error = NULL; + GError *error = NULL; if (!g_variant_is_of_type(addr_var, G_VARIANT_TYPE_BYTESTRING) || !g_variant_is_of_type(gateway_var, G_VARIANT_TYPE_BYTESTRING)) { @@ -1820,7 +1820,7 @@ nm_utils_ip6_routes_to_variant(GPtrArray *routes) if (routes) { for (i = 0; i < routes->len; i++) { - NMIPRoute * route = routes->pdata[i]; + NMIPRoute *route = routes->pdata[i]; struct in6_addr dest_bytes; struct in6_addr next_hop_bytes; guint32 metric; @@ -1860,9 +1860,9 @@ nm_utils_ip6_routes_to_variant(GPtrArray *routes) GPtrArray * nm_utils_ip6_routes_from_variant(GVariant *value) { - GPtrArray * routes; + GPtrArray *routes; GVariantIter iter; - GVariant * dest_var, *next_hop_var; + GVariant *dest_var, *next_hop_var; const struct in6_addr *dest, *next_hop; gsize dest_len, next_hop_len; guint32 prefix, metric; @@ -1874,7 +1874,7 @@ nm_utils_ip6_routes_from_variant(GVariant *value) g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "(@ayu@ayu)", &dest_var, &prefix, &next_hop_var, &metric)) { NMIPRoute *route; - GError * error = NULL; + GError *error = NULL; if (!g_variant_is_of_type(dest_var, G_VARIANT_TYPE_BYTESTRING) || !g_variant_is_of_type(next_hop_var, G_VARIANT_TYPE_BYTESTRING)) { @@ -1939,7 +1939,7 @@ nm_utils_ip_addresses_to_variant(GPtrArray *addresses) if (addresses) { for (i = 0; i < addresses->len; i++) { - NMIPAddress * addr = addresses->pdata[i]; + NMIPAddress *addr = addresses->pdata[i]; GVariantBuilder addr_builder; gs_free const char **names = NULL; guint j, len; @@ -1985,15 +1985,15 @@ nm_utils_ip_addresses_to_variant(GPtrArray *addresses) GPtrArray * nm_utils_ip_addresses_from_variant(GVariant *value, int family) { - GPtrArray * addresses; + GPtrArray *addresses; GVariantIter iter, attrs_iter; - GVariant * addr_var; - const char * ip; + GVariant *addr_var; + const char *ip; guint32 prefix; - const char * attr_name; - GVariant * attr_val; + const char *attr_name; + GVariant *attr_val; NMIPAddress *addr; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -2051,7 +2051,7 @@ nm_utils_ip_routes_to_variant(GPtrArray *routes) if (routes) { for (i = 0; i < routes->len; i++) { - NMIPRoute * route = routes->pdata[i]; + NMIPRoute *route = routes->pdata[i]; GVariantBuilder route_builder; gs_free const char **names = NULL; guint j, len; @@ -2110,16 +2110,16 @@ nm_utils_ip_routes_to_variant(GPtrArray *routes) GPtrArray * nm_utils_ip_routes_from_variant(GVariant *value, int family) { - GPtrArray * routes; + GPtrArray *routes; GVariantIter iter, attrs_iter; - GVariant * route_var; - const char * dest, *next_hop; + GVariant *route_var; + const char *dest, *next_hop; guint32 prefix, metric32; gint64 metric; - const char * attr_name; - GVariant * attr_val; - NMIPRoute * route; - GError * error = NULL; + const char *attr_name; + GVariant *attr_val; + NMIPRoute *route; + GError *error = NULL; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -2297,7 +2297,7 @@ static const NMVariantAttributeSpec *const tc_qdisc_fq_codel_spec[] = { }; typedef struct { - const char * kind; + const char *kind; const NMVariantAttributeSpec *const *attrs; } NMQdiscAttributeSpec; @@ -2323,7 +2323,7 @@ void _nm_utils_string_append_tc_qdisc_rest(GString *string, NMTCQdisc *qdisc) { guint32 handle = nm_tc_qdisc_get_handle(qdisc); - const char * kind = nm_tc_qdisc_get_kind(qdisc); + const char *kind = nm_tc_qdisc_get_kind(qdisc); gs_free char *str = NULL; if (handle != TC_H_UNSPEC && !NM_IN_STRSET(kind, "ingress", "clsact")) { @@ -2368,14 +2368,14 @@ nm_utils_tc_qdisc_to_str(NMTCQdisc *qdisc, GError **error) static gboolean _tc_read_common_opts(const char *str, - guint32 * handle, - guint32 * parent, - char ** kind, - char ** rest, - GError ** error) + guint32 *handle, + guint32 *parent, + char **kind, + char **rest, + GError **error) { gs_unref_hashtable GHashTable *ht = NULL; - GVariant * variant; + GVariant *variant; ht = nm_utils_parse_variant_attributes(str, ' ', ' ', FALSE, tc_object_attribute_spec, error); if (!ht) @@ -2456,11 +2456,11 @@ _tc_read_common_opts(const char *str, NMTCQdisc * nm_utils_tc_qdisc_from_str(const char *str, GError **error) { - guint32 handle = TC_H_UNSPEC; - guint32 parent = TC_H_UNSPEC; - gs_free char * kind = NULL; - gs_free char * rest = NULL; - NMTCQdisc * qdisc = NULL; + guint32 handle = TC_H_UNSPEC; + guint32 parent = TC_H_UNSPEC; + gs_free char *kind = NULL; + gs_free char *rest = NULL; + NMTCQdisc *qdisc = NULL; gs_unref_hashtable GHashTable *options = NULL; GHashTableIter iter; gpointer key, value; @@ -2541,8 +2541,8 @@ static const NMVariantAttributeSpec *const tc_action_attribute_spec[] = { static gboolean _string_append_tc_action(GString *string, NMTCAction *action, GError **error) { - const char * kind = nm_tc_action_get_kind(action); - gs_free char * str = NULL; + const char *kind = nm_tc_action_get_kind(action); + gs_free char *str = NULL; const NMVariantAttributeSpec *const *attrs; if (nm_streq(kind, "simple")) @@ -2605,12 +2605,12 @@ nm_utils_tc_action_to_str(NMTCAction *action, GError **error) NMTCAction * nm_utils_tc_action_from_str(const char *str, GError **error) { - const char * kind = NULL; - const char * rest = NULL; - nm_auto_unref_tc_action NMTCAction *action = NULL; - gs_unref_hashtable GHashTable *ht = NULL; - gs_unref_hashtable GHashTable * options = NULL; - GVariant * variant; + const char *kind = NULL; + const char *rest = NULL; + nm_auto_unref_tc_action NMTCAction *action = NULL; + gs_unref_hashtable GHashTable *ht = NULL; + gs_unref_hashtable GHashTable *options = NULL; + GVariant *variant; const NMVariantAttributeSpec *const *attrs; nm_assert(str); @@ -2753,15 +2753,15 @@ static const NMVariantAttributeSpec *const tc_tfilter_attribute_spec[] = { NMTCTfilter * nm_utils_tc_tfilter_from_str(const char *str, GError **error) { - guint32 handle = TC_H_UNSPEC; - guint32 parent = TC_H_UNSPEC; - gs_free char * kind = NULL; - gs_free char * rest = NULL; + guint32 handle = TC_H_UNSPEC; + guint32 parent = TC_H_UNSPEC; + gs_free char *kind = NULL; + gs_free char *rest = NULL; nm_auto_unref_tc_action NMTCAction *action = NULL; - const char * extra_opts = NULL; - NMTCTfilter * tfilter = NULL; - gs_unref_hashtable GHashTable *ht = NULL; - GVariant * variant; + const char *extra_opts = NULL; + NMTCTfilter *tfilter = NULL; + gs_unref_hashtable GHashTable *ht = NULL; + GVariant *variant; nm_assert(str); nm_assert(!error || !*error); @@ -2826,11 +2826,11 @@ char * nm_utils_sriov_vf_to_str(const NMSriovVF *vf, gboolean omit_index, GError **error) { gs_free NMUtilsNamedValue *values = NULL; - gs_free const char ** names = NULL; - const guint * vlan_ids; + gs_free const char **names = NULL; + const guint *vlan_ids; guint num_vlans, num_attrs; guint i; - GString * str; + GString *str; str = g_string_new(""); if (!omit_index) @@ -2987,7 +2987,7 @@ NMSriovVF * nm_utils_sriov_vf_from_str(const char *str, GError **error) { gs_free char *index_free = NULL; - const char * detail; + const char *detail; g_return_val_if_fail(str, NULL); g_return_val_if_fail(!error || !*error, NULL); @@ -3008,13 +3008,13 @@ NMSriovVF * _nm_utils_sriov_vf_from_strparts(const char *index, const char *detail, gboolean ignore_unknown, - GError ** error) + GError **error) { - NMSriovVF * vf; - guint32 n_index; - GHashTableIter iter; - char * key; - GVariant * variant; + NMSriovVF *vf; + guint32 n_index; + GHashTableIter iter; + char *key; + GVariant *variant; gs_unref_hashtable GHashTable *ht = NULL; n_index = _nm_utils_ascii_str_to_int64(index, 10, 0, G_MAXUINT32, 0); @@ -3102,7 +3102,7 @@ file_has_extension(const char *filename, const char *extensions[]) gboolean nm_utils_file_is_certificate(const char *filename) { - const char * extensions[] = {".der", ".pem", ".crt", ".cer", NULL}; + const char *extensions[] = {".der", ".pem", ".crt", ".cer", NULL}; NMCryptoFileFormat file_format; g_return_val_if_fail(filename != NULL, FALSE); @@ -3160,12 +3160,12 @@ nm_utils_file_is_pkcs12(const char *filename) /*****************************************************************************/ gboolean -_nm_utils_check_file(const char * filename, +_nm_utils_check_file(const char *filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - struct stat * out_st, - GError ** error) + struct stat *out_st, + GError **error) { struct stat st_backup; @@ -3232,11 +3232,11 @@ _nm_utils_check_file(const char * filename, } gboolean -_nm_utils_check_module_file(const char * name, +_nm_utils_check_module_file(const char *name, int check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error) + GError **error) { if (!g_path_is_absolute(name)) { g_set_error(error, @@ -3310,13 +3310,13 @@ _nm_utils_check_module_file(const char * name, * invocations of the function might overwrite it. */ const char * -nm_utils_file_search_in_paths(const char * progname, - const char * try_first, - const char *const * paths, +nm_utils_file_search_in_paths(const char *progname, + const char *try_first, + const char *const *paths, GFileTest file_test_flags, NMUtilsFileSearchInPathsPredicate predicate, gpointer user_data, - GError ** error) + GError **error) { g_return_val_if_fail(!error || !*error, NULL); g_return_val_if_fail(progname && progname[0] && !strchr(progname, '/'), NULL); @@ -4078,7 +4078,7 @@ _nm_utils_hwaddr_cloned_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { gsize length; const guint8 *array; - char * str; + char *str; nm_assert(nm_streq0(property_info->name, "cloned-mac-address")); @@ -4174,10 +4174,10 @@ const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address = * For new settings, they shall validate the secret-flags strictly. */ gboolean _nm_utils_secret_flags_validate(NMSettingSecretFlags secret_flags, - const char * setting_name, - const char * property_name, + const char *setting_name, + const char *property_name, NMSettingSecretFlags disallowed_flags, - GError ** error) + GError **error) { if (secret_flags == NM_SETTING_SECRET_FLAG_NONE) return TRUE; @@ -4226,10 +4226,10 @@ _nm_utils_secret_flags_validate(NMSettingSecretFlags secret_flags, gboolean _nm_utils_wps_method_validate(NMSettingWirelessSecurityWpsMethod wps_method, - const char * setting_name, - const char * property_name, + const char *setting_name, + const char *property_name, gboolean wps_required, - GError ** error) + GError **error) { if (wps_method > NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PIN) { g_set_error_literal(error, @@ -4283,15 +4283,15 @@ _split_word(char *s) } gboolean -_nm_utils_generate_mac_address_mask_parse(const char * value, - struct ether_addr * out_mask, +_nm_utils_generate_mac_address_mask_parse(const char *value, + struct ether_addr *out_mask, struct ether_addr **out_ouis, - gsize * out_ouis_len, - GError ** error) + gsize *out_ouis_len, + GError **error) { - gs_free char * s_free = NULL; - char * s, *s_next; - struct ether_addr mask; + gs_free char *s_free = NULL; + char *s, *s_next; + struct ether_addr mask; gs_unref_array GArray *ouis = NULL; g_return_val_if_fail(!error || !*error, FALSE); @@ -4694,7 +4694,7 @@ guint _nm_utils_strstrdictkey_hash(gconstpointer a) { const NMUtilsStrStrDictKey *k = a; - const char * p; + const char *p; NMHashState h; nm_hash_init(&h, 76642997u); @@ -4777,7 +4777,7 @@ _nm_utils_strstrdictkey_create(const char *v1, const char *v2) } static gboolean -validate_dns_option(const char * name, +validate_dns_option(const char *name, gboolean numeric, gboolean ipv6, const NMUtilsDNSOptionDesc *option_descs) @@ -4813,16 +4813,16 @@ validate_dns_option(const char * name, * %FALSE otherwise */ gboolean -_nm_utils_dns_option_validate(const char * option, - char ** out_name, - long * out_value, +_nm_utils_dns_option_validate(const char *option, + char **out_name, + long *out_value, gboolean ipv6, const NMUtilsDNSOptionDesc *option_descs) { gs_free char *option0_free = NULL; - const char * option0; - const char * option1; - const char * delim; + const char *option0; + const char *option1; + const char *delim; long option1_num; g_return_val_if_fail(option != NULL, FALSE); @@ -5013,7 +5013,7 @@ gboolean nm_utils_is_json_object(const char *str, GError **error) { nm_auto_decref_json nm_json_t *json = NULL; - const NMJsonVt * vt; + const NMJsonVt *vt; nm_json_error_t jerror; g_return_val_if_fail(!error || !*error, FALSE); @@ -5097,7 +5097,7 @@ _nmtst_variant_attribute_spec_assert_sorted(const NMVariantAttributeSpec *const const NMVariantAttributeSpec * _nm_variant_attribute_spec_find_binary_search(const NMVariantAttributeSpec *const *array, gsize len, - const char * name) + const char *name) { gssize idx; @@ -5132,16 +5132,16 @@ _nm_variant_attribute_spec_find_binary_search(const NMVariantAttributeSpec *cons * Since: 1.8 */ GHashTable * -nm_utils_parse_variant_attributes(const char * string, +nm_utils_parse_variant_attributes(const char *string, char attr_separator, char key_value_separator, gboolean ignore_unknown, const NMVariantAttributeSpec *const *spec, - GError ** error) + GError **error) { - gs_unref_hashtable GHashTable * ht = NULL; - const char * ptr = string, *start = NULL, *sep; - GVariant * variant; + gs_unref_hashtable GHashTable *ht = NULL; + const char *ptr = string, *start = NULL, *sep; + GVariant *variant; const NMVariantAttributeSpec *const *s; g_return_val_if_fail(string, NULL); @@ -5460,11 +5460,11 @@ nm_utils_base64secret_decode(const char *base64_key, gsize required_key_len, gui gboolean nm_utils_base64secret_normalize(const char *base64_key, gsize required_key_len, - char ** out_base64_key_norm) + char **out_base64_key_norm) { gs_free guint8 *buf_free = NULL; guint8 buf_static[200]; - guint8 * buf; + guint8 *buf; if (required_key_len > sizeof(buf_static)) { buf_free = g_new(guint8, required_key_len); @@ -5488,7 +5488,7 @@ _nm_utils_bridge_vlans_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) gs_unref_ptrarray GPtrArray *vlans = NULL; GVariantBuilder builder; guint i; - const char * property_name = property_info->name; + const char *property_name = property_info->name; nm_assert(property_name); @@ -5497,7 +5497,7 @@ _nm_utils_bridge_vlans_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) if (vlans) { for (i = 0; i < vlans->len; i++) { - NMBridgeVlan * vlan = vlans->pdata[i]; + NMBridgeVlan *vlan = vlans->pdata[i]; GVariantBuilder vlan_builder; guint16 vid_start, vid_end; @@ -5529,7 +5529,7 @@ _nm_utils_bridge_vlans_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *vlans = NULL; GVariantIter vlan_iter; - GVariant * vlan_var; + GVariant *vlan_var; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), FALSE); @@ -5537,7 +5537,7 @@ _nm_utils_bridge_vlans_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) g_variant_iter_init(&vlan_iter, value); while (g_variant_iter_next(&vlan_iter, "@a{sv}", &vlan_var)) { _nm_unused gs_unref_variant GVariant *var_unref = vlan_var; - NMBridgeVlan * vlan; + NMBridgeVlan *vlan; guint16 vid_start, vid_end; gboolean pvid = FALSE, untagged = FALSE; @@ -5587,13 +5587,13 @@ _nm_utils_bridge_compare_vlans(GPtrArray *vlans_a, GPtrArray *vlans_b) } gboolean -_nm_utils_bridge_vlan_verify_list(GPtrArray * vlans, +_nm_utils_bridge_vlan_verify_list(GPtrArray *vlans, gboolean check_normalizable, - GError ** error, + GError **error, const char *setting, const char *property) { - guint i; + guint i; gs_unref_hashtable GHashTable *h = NULL; gboolean pvid_found = FALSE; diff --git a/src/libnm-core-impl/nm-vpn-editor-plugin.c b/src/libnm-core-impl/nm-vpn-editor-plugin.c index 468ddcead5..225f25ef22 100644 --- a/src/libnm-core-impl/nm-vpn-editor-plugin.c +++ b/src/libnm-core-impl/nm-vpn-editor-plugin.c @@ -141,7 +141,7 @@ void nm_vpn_editor_plugin_set_plugin_info(NMVpnEditorPlugin *plugin, NMVpnPluginInfo *plugin_info) { NMVpnEditorPluginInterface *interface; - NMVpnEditorPluginPrivate * priv; + NMVpnEditorPluginPrivate *priv; g_return_if_fail(NM_IS_VPN_EDITOR_PLUGIN(plugin)); @@ -192,7 +192,7 @@ nm_vpn_editor_plugin_set_plugin_info(NMVpnEditorPlugin *plugin, NMVpnPluginInfo gsize nm_vpn_editor_plugin_get_vt(NMVpnEditorPlugin *plugin, NMVpnEditorPluginVT *vt, gsize vt_size) { - const NMVpnEditorPluginVT * p_vt = NULL; + const NMVpnEditorPluginVT *p_vt = NULL; gsize p_vt_size = 0; NMVpnEditorPluginInterface *interface; @@ -218,23 +218,23 @@ nm_vpn_editor_plugin_get_vt(NMVpnEditorPlugin *plugin, NMVpnEditorPluginVT *vt, /*****************************************************************************/ static NMVpnEditorPlugin * -_nm_vpn_editor_plugin_load(const char * plugin_name, +_nm_vpn_editor_plugin_load(const char *plugin_name, gboolean do_file_checks, - const char * check_service, + const char *check_service, int check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error) + GError **error) { - void * dl_module = NULL; - gboolean loaded_before; - NMVpnEditorPluginFactory factory = NULL; + void *dl_module = NULL; + gboolean loaded_before; + NMVpnEditorPluginFactory factory = NULL; gs_unref_object NMVpnEditorPlugin *editor_plugin = NULL; - gs_free char * plugin_filename_free = NULL; - const char * plugin_filename; - gs_free_error GError *factory_error = NULL; - gs_free char * plug_name = NULL; - gs_free char * plug_service = NULL; + gs_free char *plugin_filename_free = NULL; + const char *plugin_filename; + gs_free_error GError *factory_error = NULL; + gs_free char *plug_name = NULL; + gs_free char *plug_service = NULL; g_return_val_if_fail(plugin_name && *plugin_name, NULL); @@ -385,12 +385,12 @@ _nm_vpn_editor_plugin_load(const char * plugin_name, * Since: 1.2 */ NMVpnEditorPlugin * -nm_vpn_editor_plugin_load_from_file(const char * plugin_name, - const char * check_service, +nm_vpn_editor_plugin_load_from_file(const char *plugin_name, + const char *check_service, int check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error) + GError **error) { return _nm_vpn_editor_plugin_load(plugin_name, TRUE, @@ -484,9 +484,9 @@ nm_vpn_editor_plugin_import(NMVpnEditorPlugin *plugin, const char *path, GError gboolean nm_vpn_editor_plugin_export(NMVpnEditorPlugin *plugin, - const char * path, - NMConnection * connection, - GError ** error) + const char *path, + NMConnection *connection, + GError **error) { g_return_val_if_fail(NM_IS_VPN_EDITOR_PLUGIN(plugin), FALSE); diff --git a/src/libnm-core-impl/nm-vpn-plugin-info.c b/src/libnm-core-impl/nm-vpn-plugin-info.c index 2ffb777458..473063fbca 100644 --- a/src/libnm-core-impl/nm-vpn-plugin-info.c +++ b/src/libnm-core-impl/nm-vpn-plugin-info.c @@ -25,11 +25,11 @@ enum { }; typedef struct { - char * filename; - char * name; - char * service; - char * auth_dialog; - char ** aliases; + char *filename; + char *name; + char *service; + char *auth_dialog; + char **aliases; GKeyFile *keyfile; /* It is convenient for nm_vpn_plugin_info_lookup_property() to return a const char *, @@ -96,14 +96,14 @@ nm_vpn_plugin_info_validate_filename(const char *filename) } static gboolean -nm_vpn_plugin_info_check_file_full(const char * filename, +nm_vpn_plugin_info_check_file_full(const char *filename, gboolean check_absolute, gboolean do_validate_filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - struct stat * out_st, - GError ** error) + struct stat *out_st, + GError **error) { if (!filename || !*filename) { g_set_error(error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, _("missing filename")); @@ -153,13 +153,13 @@ nm_vpn_plugin_info_check_file_full(const char * filename, * Since: 1.2 */ gboolean -_nm_vpn_plugin_info_check_file(const char * filename, +_nm_vpn_plugin_info_check_file(const char *filename, gboolean check_absolute, gboolean do_validate_filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error) + GError **error) { return nm_vpn_plugin_info_check_file_full(filename, check_absolute, @@ -244,16 +244,16 @@ _nm_vpn_plugin_info_get_default_dir_user() * Returns: (transfer full) (element-type NMVpnPluginInfo): list of loaded plugin infos. */ GSList * -_nm_vpn_plugin_info_list_load_dir(const char * dirname, +_nm_vpn_plugin_info_list_load_dir(const char *dirname, gboolean do_validate_filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data) { - GDir * dir; + GDir *dir; const char *fn; - GArray * array; - GSList * res = NULL; + GArray *array; + GSList *res = NULL; guint i; g_return_val_if_fail(dirname, NULL); @@ -316,8 +316,8 @@ nm_vpn_plugin_info_list_load() { int i; gint64 uid; - GSList * list = NULL; - GSList * infos, *info; + GSList *list = NULL; + GSList *infos, *info; const char *const dir[] = { /* We load plugins from NM_VPN_PLUGIN_DIR *and* DEFAULT_DIR*, with * preference to the former. @@ -370,7 +370,7 @@ NMVpnPluginInfo * nm_vpn_plugin_info_new_search_file(const char *name, const char *service) { NMVpnPluginInfo *info; - GSList * infos; + GSList *infos; if (!name && !service) g_return_val_if_reached(NULL); @@ -402,7 +402,7 @@ _check_no_conflict(NMVpnPluginInfo *i1, NMVpnPluginInfo *i2, GError **error) for (i = 0; i < G_N_ELEMENTS(check_list); i++) { gs_free NMUtilsStrStrDictKey *k = NULL; - const char * s1, *s2; + const char *s1, *s2; k = _nm_utils_strstrdictkey_create(check_list[i].group, check_list[i].key); s1 = g_hash_table_lookup(priv1->keys, k); @@ -440,7 +440,7 @@ _check_no_conflict(NMVpnPluginInfo *i1, NMVpnPluginInfo *i2, GError **error) gboolean nm_vpn_plugin_info_list_add(GSList **list, NMVpnPluginInfo *plugin_info, GError **error) { - GSList * iter; + GSList *iter; const char *name; g_return_val_if_fail(list, FALSE); @@ -619,7 +619,7 @@ char * nm_vpn_plugin_info_list_find_service_type(GSList *list, const char *name) { NMVpnPluginInfo *info; - char * n; + char *n; if (!name) g_return_val_if_reached(NULL); @@ -685,12 +685,12 @@ _service_type_get_default_abbreviation(const char *service_type) * Since: 1.4 */ char ** -nm_vpn_plugin_info_list_get_service_types(GSList * list, +nm_vpn_plugin_info_list_get_service_types(GSList *list, gboolean only_existing, gboolean with_abbreviations) { - GSList * iter; - GPtrArray * l; + GSList *iter; + GPtrArray *l; guint i, j; const char *n; @@ -953,7 +953,7 @@ nm_vpn_plugin_info_get_aliases(NMVpnPluginInfo *self) const char * nm_vpn_plugin_info_lookup_property(NMVpnPluginInfo *self, const char *group, const char *key) { - NMVpnPluginInfoPrivate *priv; + NMVpnPluginInfoPrivate *priv; gs_free NMUtilsStrStrDictKey *k = NULL; g_return_val_if_fail(NM_IS_VPN_PLUGIN_INFO(self), NULL); @@ -997,7 +997,7 @@ void nm_vpn_plugin_info_set_editor_plugin(NMVpnPluginInfo *self, NMVpnEditorPlugin *plugin) { NMVpnPluginInfoPrivate *priv; - NMVpnEditorPlugin * old; + NMVpnEditorPlugin *old; g_return_if_fail(NM_IS_VPN_PLUGIN_INFO(self)); g_return_if_fail(!plugin || G_IS_OBJECT(plugin)); @@ -1033,7 +1033,7 @@ NMVpnEditorPlugin * nm_vpn_plugin_info_load_editor_plugin(NMVpnPluginInfo *self, GError **error) { NMVpnPluginInfoPrivate *priv; - const char * plugin_filename; + const char *plugin_filename; g_return_val_if_fail(NM_IS_VPN_PLUGIN_INFO(self), NULL); @@ -1121,9 +1121,9 @@ nm_vpn_plugin_info_init(NMVpnPluginInfo *plugin) static gboolean init_sync(GInitable *initable, GCancellable *cancellable, GError **error) { - NMVpnPluginInfo * self = NM_VPN_PLUGIN_INFO(initable); + NMVpnPluginInfo *self = NM_VPN_PLUGIN_INFO(initable); NMVpnPluginInfoPrivate *priv = NM_VPN_PLUGIN_INFO_GET_PRIVATE(self); - gs_strfreev char ** groups = NULL; + gs_strfreev char **groups = NULL; guint i, j; if (!priv->keyfile) { @@ -1258,7 +1258,7 @@ nm_vpn_plugin_info_new_with_data(const char *filename, GKeyFile *keyfile, GError static void dispose(GObject *object) { - NMVpnPluginInfo * self = NM_VPN_PLUGIN_INFO(object); + NMVpnPluginInfo *self = NM_VPN_PLUGIN_INFO(object); NMVpnPluginInfoPrivate *priv = NM_VPN_PLUGIN_INFO_GET_PRIVATE(self); g_clear_object(&priv->editor_plugin); @@ -1269,7 +1269,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMVpnPluginInfo * self = NM_VPN_PLUGIN_INFO(object); + NMVpnPluginInfo *self = NM_VPN_PLUGIN_INFO(object); NMVpnPluginInfoPrivate *priv = NM_VPN_PLUGIN_INFO_GET_PRIVATE(self); g_free(priv->name); diff --git a/src/libnm-core-impl/tests/test-compare.c b/src/libnm-core-impl/tests/test-compare.c index 3716399a9a..77d2e17b68 100644 --- a/src/libnm-core-impl/tests/test-compare.c +++ b/src/libnm-core-impl/tests/test-compare.c @@ -37,7 +37,7 @@ compare_ints(void) static void compare_strings(void) { - GVariant * value1, *value2; + GVariant *value1, *value2; const char *str1 = "hello"; const char *str2 = "world"; @@ -58,7 +58,7 @@ compare_strings(void) static void compare_strv(void) { - GVariant * value1, *value2; + GVariant *value1, *value2; const char *const strv1[] = {"foo", "bar", "baz", NULL}; const char *const strv2[] = {"foo", "bar", "bar", NULL}; const char *const strv3[] = {"foo", "bar", NULL}; @@ -123,7 +123,7 @@ compare_arrays(void) static void compare_str_hash(void) { - GVariant * value1, *value2; + GVariant *value1, *value2; GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE("a{ss}")); @@ -165,7 +165,7 @@ compare_str_hash(void) static void compare_ip6_addresses(void) { - GVariant * value1, *value2; + GVariant *value1, *value2; struct in6_addr addr1; struct in6_addr addr2; struct in6_addr addr3; diff --git a/src/libnm-core-impl/tests/test-crypto.c b/src/libnm-core-impl/tests/test-crypto.c index 1c072f71bf..6a6e7fbc80 100644 --- a/src/libnm-core-impl/tests/test-crypto.c +++ b/src/libnm-core-impl/tests/test-crypto.c @@ -80,10 +80,10 @@ out: static void test_cert(gconstpointer test_data) { - gs_free char * path = NULL; + gs_free char *path = NULL; gs_unref_bytes GBytes *cert = NULL; NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; - GError * error = NULL; + GError *error = NULL; gboolean success; path = g_build_filename(TEST_CERT_DIR, (const char *) test_data, NULL); @@ -101,10 +101,10 @@ test_load_private_key(const char *path, const char *decrypted_path, int expected_error) { - NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; - gboolean is_encrypted = FALSE; - gs_unref_bytes GBytes *array = NULL; - GError * error = NULL; + NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; + gboolean is_encrypted = FALSE; + gs_unref_bytes GBytes *array = NULL; + GError *error = NULL; g_assert(nm_utils_file_is_private_key(path, &is_encrypted)); g_assert(is_encrypted); @@ -144,7 +144,7 @@ test_load_pkcs12(const char *path, const char *password, int expected_error) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gboolean is_encrypted = FALSE; - GError * error = NULL; + GError *error = NULL; g_assert(nm_utils_file_is_private_key(path, NULL)); @@ -165,7 +165,7 @@ test_load_pkcs12_no_password(const char *path) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gboolean is_encrypted = FALSE; - GError * error = NULL; + GError *error = NULL; g_assert(nm_utils_file_is_private_key(path, NULL)); @@ -180,7 +180,7 @@ static void test_is_pkcs12(const char *path, gboolean expect_fail) { gboolean is_pkcs12; - GError * error = NULL; + GError *error = NULL; is_pkcs12 = nm_crypto_is_pkcs12_file(path, &error); @@ -199,7 +199,7 @@ test_load_pkcs8(const char *path, const char *password, int expected_error) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gboolean is_encrypted = FALSE; - GError * error = NULL; + GError *error = NULL; g_assert(nm_utils_file_is_private_key(path, NULL)); @@ -218,11 +218,11 @@ test_load_pkcs8(const char *path, const char *password, int expected_error) static void test_encrypt_private_key(const char *path, const char *password) { - NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; + NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; gs_unref_bytes GBytes *array = NULL; gs_unref_bytes GBytes *encrypted = NULL; gs_unref_bytes GBytes *re_decrypted = NULL; - GError * error = NULL; + GError *error = NULL; array = nmtst_crypto_decrypt_openssl_private_key(path, password, &key_type, &error); nmtst_assert_success(array, error); @@ -281,7 +281,7 @@ test_key_decrypted(gconstpointer test_data) { const char *file = (const char *) test_data; gboolean is_encrypted = FALSE; - char * path; + char *path; path = g_build_filename(TEST_CERT_DIR, file, NULL); @@ -404,7 +404,7 @@ NMTST_DEFINE(); int main(int argc, char **argv) { - GError * error = NULL; + GError *error = NULL; gboolean success; int ret; diff --git a/src/libnm-core-impl/tests/test-general.c b/src/libnm-core-impl/tests/test-general.c index 5c831cb7cd..c9bcab47e1 100644 --- a/src/libnm-core-impl/tests/test-general.c +++ b/src/libnm-core-impl/tests/test-general.c @@ -110,8 +110,8 @@ static void test_wired_wake_on_lan_enum(void) { nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NMSettingWiredWakeOnLan) == sizeof(_NMSettingWiredWakeOnLan)); G_STATIC_ASSERT_EXPR(sizeof(NMSettingWiredWakeOnLan) < sizeof(gint64)); @@ -161,8 +161,8 @@ static void test_wireless_wake_on_wlan_enum(void) { nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NMSettingWirelessWakeOnWLan) == sizeof(_NMSettingWirelessWakeOnWLan)); @@ -215,8 +215,8 @@ static void test_device_wifi_capabilities(void) { nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NMDeviceWifiCapabilities) == sizeof(_NMDeviceWifiCapabilities)); G_STATIC_ASSERT_EXPR(sizeof(NMDeviceWifiCapabilities) < sizeof(gint64)); @@ -268,8 +268,8 @@ static void test_80211_mode(void) { nm_auto_unref_gtypeclass GEnumClass *enum_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NM80211Mode) == sizeof(_NM80211Mode)); G_STATIC_ASSERT_EXPR(sizeof(NM80211Mode) < sizeof(gint64)); @@ -312,8 +312,8 @@ static void test_vlan_flags(void) { nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NMVlanFlags) == sizeof(_NMVlanFlags)); G_STATIC_ASSERT_EXPR(sizeof(NMVlanFlags) < sizeof(gint64)); @@ -543,9 +543,9 @@ test_nm_g_slice_free_fcn(void) static void _do_test_nm_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, - const char * str, + const char *str, gsize words_len, - const char *const * exp_words) + const char *const *exp_words) { #define DELIMITERS " \n" #define DELIMITERS_C ' ', '\n' @@ -554,7 +554,7 @@ _do_test_nm_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, gsize i, j, k; const gboolean f_allow_escaping = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); const gboolean f_preserve_empty = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); - const char * s1; + const char *s1; gsize initial_offset; gs_strfreev char **words_g = NULL; @@ -750,9 +750,9 @@ _do_test_nm_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, static void _do_test_nm_strsplit_set_f(NMUtilsStrsplitSetFlags flags, - const char * str, + const char *str, gsize words_len, - const char *const * exp_words) + const char *const *exp_words) { _do_test_nm_strsplit_set_f_one(flags, str, words_len, exp_words); @@ -784,9 +784,9 @@ _do_test_nm_strsplit_set_f(NMUtilsStrsplitSetFlags flags, static void _do_test_nm_strsplit_set_simple(NMUtilsStrsplitSetFlags flags, - const char * str, + const char *str, gsize words_len, - const char *const * exp_words) + const char *const *exp_words) { gs_free const char **tokens = NULL; gsize n_tokens; @@ -1108,7 +1108,7 @@ _escaped_tokens_split(char *str, const char **out_key, const char **out_val) } static void -_escaped_tokens_combine(GString * combined, +_escaped_tokens_combine(GString *combined, const char *key, const char *val, gboolean strict, @@ -1139,9 +1139,9 @@ _escaped_tokens_combine(GString * combined, } static void -_escaped_tokens_check_one_impl(const char * expected_key, - const char * expected_val, - const char * expected_combination, +_escaped_tokens_check_one_impl(const char *expected_key, + const char *expected_val, + const char *expected_combination, const char *const *other, gsize n_other) { @@ -1158,11 +1158,11 @@ _escaped_tokens_check_one_impl(const char * expected_key, for (i = 0; i < n_other + 2u; i++) { nm_auto_free_gstring GString *str0 = NULL; - gs_free const char ** strv_split = NULL; - gs_free char * strv_split0 = NULL; - const char * comb; - const char * key; - const char * val; + gs_free const char **strv_split = NULL; + gs_free char *strv_split0 = NULL; + const char *comb; + const char *key; + const char *val; if (i == 0) comb = expected_combination; @@ -1208,10 +1208,10 @@ test_nm_utils_escaped_tokens(void) int i_run; for (i_run = 0; i_run < 1000; i_run++) { - const guint num_options = nmtst_get_rand_word_length(NULL); - gs_unref_ptrarray GPtrArray *options = g_ptr_array_new_with_free_func(g_free); - nm_auto_free_gstring GString *combined = g_string_new(NULL); - gs_free const char ** strv_split = NULL; + const guint num_options = nmtst_get_rand_word_length(NULL); + gs_unref_ptrarray GPtrArray *options = g_ptr_array_new_with_free_func(g_free); + nm_auto_free_gstring GString *combined = g_string_new(NULL); + gs_free const char **strv_split = NULL; guint i_option; guint i; @@ -1244,8 +1244,8 @@ test_nm_utils_escaped_tokens(void) /* ensure that we can split and parse the options without difference. */ strv_split = nm_utils_escaped_tokens_options_split_list(combined->str); for (i_option = 0; i_option < num_options; i_option++) { - const char * expected_key = options->pdata[2u * i_option + 0u]; - const char * expected_val = options->pdata[2u * i_option + 1u]; + const char *expected_key = options->pdata[2u * i_option + 0u]; + const char *expected_val = options->pdata[2u * i_option + 1u]; gs_free char *s_split = i_option < NM_PTRARRAY_LEN(strv_split) ? g_strdup(strv_split[i_option]) : NULL; const char *key = NULL; @@ -1301,7 +1301,7 @@ test_nm_utils_escaped_tokens(void) */ for (i = 0; i < 1u + 2u * i_option; i++) { gs_free char *str = NULL; - const char * cstr; + const char *cstr; if (i == 0) cstr = combined->str; @@ -1359,7 +1359,7 @@ _do_test_c_list_sort(CListSort *elements, guint n_list, gboolean headless) CList head, *iter, *iter_prev, *lst; guint i; const CListSort *el_prev; - CListSort * el; + CListSort *el; c_list_init(&head); for (i = 0; i < n_list; i++) { @@ -1409,8 +1409,8 @@ _do_test_c_list_sort(CListSort *elements, guint n_list, gboolean headless) static void test_c_list_sort(void) { - const guint N_ELEMENTS = 10000; - guint n_list, repeat; + const guint N_ELEMENTS = 10000; + guint n_list, repeat; gs_free CListSort *elements = NULL; { @@ -1545,11 +1545,11 @@ _dedup_idx_assert(const NMDedupMultiIdxType *idx_type) static void _dedup_idx_obj_id_hash_update(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - NMHashState * h) + const NMDedupMultiObj *obj, + NMHashState *h) { const DedupIdxType *t; - const DedupObj * o; + const DedupObj *o; t = _dedup_idx_assert(idx_type); o = _dedup_obj_assert(obj); @@ -1560,12 +1560,12 @@ _dedup_idx_obj_id_hash_update(const NMDedupMultiIdxType *idx_type, static gboolean _dedup_idx_obj_id_equal(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b) + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b) { const DedupIdxType *t; - const DedupObj * o_a; - const DedupObj * o_b; + const DedupObj *o_a; + const DedupObj *o_b; t = _dedup_idx_assert(idx_type); o_a = _dedup_obj_assert(obj_a); @@ -1577,11 +1577,11 @@ _dedup_idx_obj_id_equal(const NMDedupMultiIdxType *idx_type, static void _dedup_idx_obj_partition_hash_update(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - NMHashState * h) + const NMDedupMultiObj *obj, + NMHashState *h) { const DedupIdxType *t; - const DedupObj * o; + const DedupObj *o; t = _dedup_idx_assert(idx_type); o = _dedup_obj_assert(obj); @@ -1591,12 +1591,12 @@ _dedup_idx_obj_partition_hash_update(const NMDedupMultiIdxType *idx_type, static gboolean _dedup_idx_obj_partition_equal(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b) + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b) { const DedupIdxType *t; - const DedupObj * o_a; - const DedupObj * o_b; + const DedupObj *o_a; + const DedupObj *o_b; t = _dedup_idx_assert(idx_type); o_a = _dedup_obj_assert(obj_a); @@ -1622,9 +1622,9 @@ DEDUP_IDX_TYPE_INIT(DedupIdxType *idx_type, guint partition_size, guint val_mod) } static gboolean -_dedup_idx_add(NMDedupMultiIndex * idx, - const DedupIdxType * idx_type, - const DedupObj * obj, +_dedup_idx_add(NMDedupMultiIndex *idx, + const DedupIdxType *idx_type, + const DedupObj *obj, NMDedupMultiIdxMode mode, const NMDedupMultiEntry **out_entry) { @@ -1675,7 +1675,7 @@ _dedup_entry_get_idx_type(const NMDedupMultiEntry *entry) static void _dedup_entry_assert_all(const NMDedupMultiEntry *entry, gssize expected_idx, - const DedupObj *const * expected_obj) + const DedupObj *const *expected_obj) { gsize n, i; CList *iter; @@ -1698,8 +1698,8 @@ _dedup_entry_assert_all(const NMDedupMultiEntry *entry, i = 0; c_list_for_each (iter, &entry->head->lst_entries_head) { const NMDedupMultiEntry *entry_current = c_list_entry(iter, NMDedupMultiEntry, lst_entries); - const DedupObj * obj_current; - const DedupIdxType * idx_type = _dedup_entry_get_idx_type(entry_current); + const DedupObj *obj_current; + const DedupIdxType *idx_type = _dedup_entry_get_idx_type(entry_current); obj_current = _dedup_entry_assert(entry_current); g_assert(obj_current); @@ -1719,10 +1719,10 @@ _dedup_entry_assert_all(const NMDedupMultiEntry *entry, static void test_dedup_multi(void) { - NMDedupMultiIndex * idx; + NMDedupMultiIndex *idx; DedupIdxType IDX_20_3_a_stack; const DedupIdxType *const IDX_20_3_a = DEDUP_IDX_TYPE_INIT(&IDX_20_3_a_stack, 20, 3); - const NMDedupMultiEntry * entry1; + const NMDedupMultiEntry *entry1; idx = nm_dedup_multi_index_new(); @@ -1800,7 +1800,7 @@ static void test_setting_vpn_items(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVpn * s_vpn; + NMSettingVpn *s_vpn; connection = nmtst_create_minimal_connection("vpn-items", NULL, NM_SETTING_VPN_SETTING_NAME, NULL); @@ -1919,17 +1919,17 @@ test_setting_vpn_items(void) static void test_setting_vpn_update_secrets(void) { - NMConnection * connection; - NMSettingVpn * s_vpn; + NMConnection *connection; + NMSettingVpn *s_vpn; GVariantBuilder settings_builder, vpn_builder, secrets_builder; - GVariant * settings; + GVariant *settings; gboolean success; - GError * error = NULL; - const char * tmp; - const char * key1 = "foobar"; - const char * key2 = "blahblah"; - const char * val1 = "value1"; - const char * val2 = "value2"; + GError *error = NULL; + const char *tmp; + const char *key1 = "foobar"; + const char *key2 = "blahblah"; + const char *val1 = "value1"; + const char *val2 = "value2"; connection = nm_simple_connection_new(); s_vpn = (NMSettingVpn *) nm_setting_vpn_new(); @@ -1970,7 +1970,7 @@ test_setting_vpn_update_secrets(void) #define TO_DEL_NUM 50 typedef struct { NMSettingVpn *s_vpn; - char * to_del[TO_DEL_NUM]; + char *to_del[TO_DEL_NUM]; guint called; } IterInfo; @@ -1998,7 +1998,7 @@ test_setting_vpn_modify_during_foreach(void) { NMSettingVpn *s_vpn; IterInfo info; - char * key, *val; + char *key, *val; int i, u = 0; s_vpn = (NMSettingVpn *) nm_setting_vpn_new(); @@ -2040,13 +2040,13 @@ static void test_setting_ip4_config_labels(void) { NMSettingIPConfig *s_ip4; - NMIPAddress * addr; - GVariant * label; - GPtrArray * addrs; - char ** labels; - NMConnection * conn; - GVariant * dict, *dict2, *setting_dict, *value; - GError * error = NULL; + NMIPAddress *addr; + GVariant *label; + GPtrArray *addrs; + char **labels; + NMConnection *conn; + GVariant *dict, *dict2, *setting_dict, *value; + GError *error = NULL; s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); g_object_set(G_OBJECT(s_ip4), @@ -2242,11 +2242,11 @@ static void test_setting_ip4_config_address_data(void) { NMSettingIPConfig *s_ip4; - NMIPAddress * addr; - GPtrArray * addrs; - NMConnection * conn; - GVariant * dict, *setting_dict, *value; - GError * error = NULL; + NMIPAddress *addr; + GPtrArray *addrs; + NMConnection *conn; + GVariant *dict, *setting_dict, *value; + GError *error = NULL; s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); g_object_set(G_OBJECT(s_ip4), @@ -2412,7 +2412,7 @@ static void test_setting_gsm_apn_spaces(void) { gs_unref_object NMSettingGsm *s_gsm = NULL; - const char * tmp; + const char *tmp; s_gsm = (NMSettingGsm *) nm_setting_gsm_new(); g_assert(s_gsm); @@ -2558,7 +2558,7 @@ static void test_setting_to_dbus_all(void) { NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; s_wsec = make_test_wsec_setting("setting-to-dbus-all"); @@ -2578,7 +2578,7 @@ static void test_setting_to_dbus_no_secrets(void) { NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; s_wsec = make_test_wsec_setting("setting-to-dbus-no-secrets"); @@ -2603,7 +2603,7 @@ static void test_setting_to_dbus_only_secrets(void) { NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; s_wsec = make_test_wsec_setting("setting-to-dbus-only-secrets"); @@ -2625,9 +2625,9 @@ test_setting_to_dbus_only_secrets(void) static void test_setting_to_dbus_transform(void) { - NMSetting * s_wired; - GVariant * dict, *val; - const char * test_mac_address = "11:22:33:44:55:66"; + NMSetting *s_wired; + GVariant *dict, *val; + const char *test_mac_address = "11:22:33:44:55:66"; const guint8 *dbus_mac_address; guint8 cmp_mac_address[ETH_ALEN]; gsize len; @@ -2660,7 +2660,7 @@ static void test_setting_to_dbus_enum(void) { NMSetting *s_ip6, *s_wsec, *s_serial; - GVariant * dict, *val; + GVariant *dict, *val; /* enum */ s_ip6 = nm_setting_ip6_config_new(); @@ -2730,9 +2730,9 @@ test_setting_to_dbus_enum(void) static void test_connection_to_dbus_setting_name(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; connection = nm_simple_connection_new(); s_wsec = make_test_wsec_setting("connection-to-dbus-setting-name"); @@ -2781,11 +2781,11 @@ test_connection_to_dbus_setting_name(void) static void test_connection_to_dbus_deprecated_props(void) { - NMConnection * connection; - NMSetting * s_wireless; - GBytes * ssid; + NMConnection *connection; + NMSetting *s_wireless; + GBytes *ssid; NMSettingWirelessSecurity *s_wsec; - GVariant * dict, *wireless_dict, *sec_val; + GVariant *dict, *wireless_dict, *sec_val; connection = nmtst_create_minimal_connection("test-connection-to-dbus-deprecated-props", NULL, @@ -2839,7 +2839,7 @@ static void test_setting_new_from_dbus(void) { NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; s_wsec = make_test_wsec_setting("setting-new-from-dbus"); dict = _nm_setting_to_dbus(NM_SETTING(s_wsec), NULL, NM_CONNECTION_SERIALIZE_ALL, NULL); @@ -2863,12 +2863,12 @@ test_setting_new_from_dbus(void) static void test_setting_new_from_dbus_transform(void) { - NMSetting * s_wired; - GVariant * dict; + NMSetting *s_wired; + GVariant *dict; GVariantBuilder builder; - const char * test_mac_address = "11:22:33:44:55:66"; + const char *test_mac_address = "11:22:33:44:55:66"; guint8 dbus_mac_address[ETH_ALEN]; - GError * error = NULL; + GError *error = NULL; nm_utils_hwaddr_aton(test_mac_address, dbus_mac_address, ETH_ALEN); @@ -2898,12 +2898,12 @@ test_setting_new_from_dbus_transform(void) static void test_setting_new_from_dbus_enum(void) { - NMSettingIP6Config * s_ip6; + NMSettingIP6Config *s_ip6; NMSettingWirelessSecurity *s_wsec; - NMSettingSerial * s_serial; - GVariant * dict; + NMSettingSerial *s_serial; + GVariant *dict; GVariantBuilder builder; - GError * error = NULL; + GError *error = NULL; /* enum */ g_variant_builder_init(&builder, NM_VARIANT_TYPE_SETTING); @@ -2977,12 +2977,12 @@ test_setting_new_from_dbus_enum(void) static void test_setting_new_from_dbus_bad(void) { - NMSetting * setting; + NMSetting *setting; NMConnection *conn; - GBytes * ssid; - GPtrArray * addrs; - GVariant * orig_dict, *dict; - GError * error = NULL; + GBytes *ssid; + GPtrArray *addrs; + GVariant *orig_dict, *dict; + GError *error = NULL; /* We want to test: * - ordinary scalar properties @@ -3166,8 +3166,8 @@ static NMConnection * new_test_connection(void) { NMConnection *connection; - NMSetting * setting; - char * uuid; + NMSetting *setting; + char *uuid; guint64 timestamp = time(NULL); connection = nm_simple_connection_new(); @@ -3204,7 +3204,7 @@ new_test_connection(void) } static GVariant * -new_connection_dict(char ** out_uuid, +new_connection_dict(char **out_uuid, const char **out_expected_id, const char **out_expected_ip6_method) { @@ -3264,14 +3264,14 @@ new_connection_dict(char ** out_uuid, static void test_connection_replace_settings(void) { - NMConnection * connection; - GVariant * new_settings; - GError * error = NULL; + NMConnection *connection; + GVariant *new_settings; + GError *error = NULL; gboolean success; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip6; - char * uuid = NULL; - const char * expected_id = NULL, *expected_method = NULL; + NMSettingIPConfig *s_ip6; + char *uuid = NULL; + const char *expected_id = NULL, *expected_method = NULL; connection = new_test_connection(); @@ -3303,12 +3303,12 @@ test_connection_replace_settings(void) static void test_connection_replace_settings_from_connection(void) { - NMConnection * connection, *replacement; + NMConnection *connection, *replacement; NMSettingConnection *s_con; - NMSetting * setting; - GBytes * ssid; - char * uuid = NULL; - const char * expected_id = "Awesome connection"; + NMSetting *setting; + GBytes *ssid; + char *uuid = NULL; + const char *expected_id = "Awesome connection"; connection = new_test_connection(); g_assert(connection); @@ -3365,10 +3365,10 @@ test_connection_replace_settings_from_connection(void) static void test_connection_replace_settings_bad(void) { - NMConnection * connection, *new_connection; - GVariant * new_settings; + NMConnection *connection, *new_connection; + GVariant *new_settings; GVariantBuilder builder, setting_builder; - GError * error = NULL; + GError *error = NULL; gboolean success; NMSettingConnection *s_con; @@ -3426,13 +3426,13 @@ test_connection_replace_settings_bad(void) static void test_connection_new_from_dbus(void) { - NMConnection * connection; - GVariant * new_settings; - GError * error = NULL; + NMConnection *connection; + GVariant *new_settings; + GError *error = NULL; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip6; - char * uuid = NULL; - const char * expected_id = NULL, *expected_method = NULL; + NMSettingIPConfig *s_ip6; + char *uuid = NULL; + const char *expected_id = NULL, *expected_method = NULL; new_settings = new_connection_dict(&uuid, &expected_id, &expected_method); g_assert(new_settings); @@ -3484,8 +3484,8 @@ test_setting_connection_permissions_helpers(void) NMSettingConnection *s_con; gboolean success; char buf[9] = {0x61, 0x62, 0x63, 0xff, 0xfe, 0xfd, 0x23, 0x01, 0x00}; - char ** perms; - const char * expected_perm = "user:" TEST_UNAME ":"; + char **perms; + const char *expected_perm = "user:" TEST_UNAME ":"; s_con = NM_SETTING_CONNECTION(nm_setting_connection_new()); @@ -3552,13 +3552,13 @@ test_setting_connection_permissions_helpers(void) static void add_permission_property(NMSettingConnection *s_con, - const char * ptype, - const char * pitem, + const char *ptype, + const char *pitem, int pitem_len, - const char * detail) + const char *detail) { GString *str; - char * perms[2]; + char *perms[2]; str = g_string_sized_new(50); if (ptype) @@ -3598,12 +3598,12 @@ test_setting_connection_permissions_property(void) { \ NMSettingConnection *_s_con = (s_con); \ guint _idx = (idx); \ - const char * _ptype; \ - const char * _pitem; \ - const char * _detail; \ - const char ** _p_ptype = nmtst_get_rand_bool() ? &_ptype : NULL; \ - const char ** _p_pitem = nmtst_get_rand_bool() ? &_pitem : NULL; \ - const char ** _p_detail = nmtst_get_rand_bool() ? &_detail : NULL; \ + const char *_ptype; \ + const char *_pitem; \ + const char *_detail; \ + const char **_p_ptype = nmtst_get_rand_bool() ? &_ptype : NULL; \ + const char **_p_pitem = nmtst_get_rand_bool() ? &_pitem : NULL; \ + const char **_p_detail = nmtst_get_rand_bool() ? &_detail : NULL; \ \ g_assert_cmpint(_idx, <, nm_setting_connection_get_num_permissions(_s_con)); \ g_assert( \ @@ -3690,7 +3690,7 @@ test_connection_compare_same(void) static void test_connection_compare_key_only_in_a(void) { - NMConnection * a, *b; + NMConnection *a, *b; NMSettingConnection *s_con; a = new_test_connection(); @@ -3720,7 +3720,7 @@ test_connection_compare_setting_only_in_a(void) static void test_connection_compare_key_only_in_b(void) { - NMConnection * a, *b; + NMConnection *a, *b; NMSettingConnection *s_con; a = new_test_connection(); @@ -3792,8 +3792,8 @@ ensure_diffs(GHashTable *diffs, const DiffSetting *check, gsize n_check) static void test_connection_diff_a_only(void) { - NMConnection * connection; - GHashTable * out_diffs = NULL; + NMConnection *connection; + GHashTable *out_diffs = NULL; gboolean same; const DiffSetting settings[] = { {NM_SETTING_CONNECTION_SETTING_NAME, @@ -3892,7 +3892,7 @@ static void test_connection_diff_same(void) { NMConnection *a, *b; - GHashTable * out_diffs = NULL; + GHashTable *out_diffs = NULL; gboolean same; a = new_test_connection(); @@ -3908,8 +3908,8 @@ test_connection_diff_same(void) static void test_connection_diff_different(void) { - NMConnection * a, *b; - GHashTable * out_diffs = NULL; + NMConnection *a, *b; + GHashTable *out_diffs = NULL; NMSettingIPConfig *s_ip4; gboolean same; const DiffSetting settings[] = { @@ -3945,9 +3945,9 @@ test_connection_diff_different(void) static void test_connection_diff_no_secrets(void) { - NMConnection * a, *b; - GHashTable * out_diffs = NULL; - NMSetting * s_pppoe; + NMConnection *a, *b; + GHashTable *out_diffs = NULL; + NMSetting *s_pppoe; gboolean same; const DiffSetting settings[] = { {NM_SETTING_PPPOE_SETTING_NAME, @@ -3990,13 +3990,13 @@ test_connection_diff_no_secrets(void) static void test_connection_diff_inferrable(void) { - NMConnection * a, *b; - GHashTable * out_diffs = NULL; + NMConnection *a, *b; + GHashTable *out_diffs = NULL; gboolean same; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * uuid; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + char *uuid; const DiffSetting settings[] = { {NM_SETTING_CONNECTION_SETTING_NAME, { @@ -4053,7 +4053,7 @@ static void add_generic_settings(NMConnection *connection, const char *ctype) { NMSetting *setting; - char * uuid; + char *uuid; uuid = nm_utils_uuid_generate(); @@ -4083,11 +4083,11 @@ static void test_connection_good_base_types(void) { NMConnection *connection; - NMSetting * setting; + NMSetting *setting; gboolean success; - GError * error = NULL; - GBytes * ssid; - const char * bdaddr = "11:22:33:44:55:66"; + GError *error = NULL; + GBytes *ssid; + const char *bdaddr = "11:22:33:44:55:66"; /* Try a basic wired connection */ connection = nm_simple_connection_new(); @@ -4193,9 +4193,9 @@ static void test_connection_bad_base_types(void) { NMConnection *connection; - NMSetting * setting; + NMSetting *setting; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test various non-base connection types to make sure they are rejected; * using a fake 'wired' connection so the rest of it verifies @@ -4303,8 +4303,8 @@ test_setting_compare_addresses(void) { gs_unref_object NMSetting *s1 = NULL, *s2 = NULL; gboolean success; - NMIPAddress * a; - GHashTable * result = NULL; + NMIPAddress *a; + GHashTable *result = NULL; s1 = nm_setting_ip4_config_new(); s2 = nm_setting_ip4_config_new(); @@ -4335,8 +4335,8 @@ test_setting_compare_routes(void) { gs_unref_object NMSetting *s1 = NULL, *s2 = NULL; gboolean success; - NMIPRoute * r; - GHashTable * result = NULL; + NMIPRoute *r; + GHashTable *result = NULL; s1 = nm_setting_ip4_config_new(); s2 = nm_setting_ip4_config_new(); @@ -4367,7 +4367,7 @@ test_setting_compare_wired_cloned_mac_address(void) { gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; - gs_free char * str1 = NULL; + gs_free char *str1 = NULL; old = nm_setting_wired_new(); g_object_set(old, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "stable", NULL); @@ -4411,7 +4411,7 @@ test_setting_compare_wireless_cloned_mac_address(void) { gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; - gs_free char * str1 = NULL; + gs_free char *str1 = NULL; old = nm_setting_wireless_new(); g_object_set(old, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, "stable", NULL); @@ -4501,8 +4501,8 @@ test_data_compare_secrets_new(NMSettingSecretFlags secret_flags, } static void -_test_compare_secrets_check_diff(NMSetting * a, - NMSetting * b, +_test_compare_secrets_check_diff(NMSetting *a, + NMSetting *b, NMSettingCompareFlags flags, gboolean exp_same_psk, gboolean exp_same_psk_flags) @@ -4617,11 +4617,11 @@ _test_compare_secrets_check_diff(NMSetting * a, static void test_setting_compare_secrets(gconstpointer test_data) { - const TestDataCompareSecrets *data = test_data; - gs_unref_object NMConnection *conn_old = NULL; - gs_unref_object NMConnection *conn_new = NULL; - gs_unref_object NMSetting *old = NULL; - gs_unref_object NMSetting *new = NULL; + const TestDataCompareSecrets *data = test_data; + gs_unref_object NMConnection *conn_old = NULL; + gs_unref_object NMConnection *conn_new = NULL; + gs_unref_object NMSetting *old = NULL; + gs_unref_object NMSetting *new = NULL; /* Make sure that a connection with transient/unsaved secrets compares * successfully to the same connection without those secrets. @@ -4700,8 +4700,8 @@ static void test_setting_compare_vpn_secrets(gconstpointer test_data) { const TestDataCompareSecrets *data = test_data; - gs_unref_object NMSetting *old = NULL, *new = NULL; - gboolean success; + gs_unref_object NMSetting *old = NULL, *new = NULL; + gboolean success; /* Make sure that a connection with transient/unsaved secrets compares * successfully to the same connection without those secrets. @@ -4773,15 +4773,15 @@ test_hwaddr_aton_malformed(void) static void test_hwaddr_equal(void) { - const char * string = "00:1a:2b:03:44:05"; - const char * upper_string = "00:1A:2B:03:44:05"; - const char * bad_string = "0:1a:2b:3:44:5"; + const char *string = "00:1a:2b:03:44:05"; + const char *upper_string = "00:1A:2B:03:44:05"; + const char *bad_string = "0:1a:2b:3:44:5"; const guint8 binary[ETH_ALEN] = {0x00, 0x1A, 0x2B, 0x03, 0x44, 0x05}; - const char * other_string = "1a:2b:03:44:05:00"; + const char *other_string = "1a:2b:03:44:05:00"; const guint8 other_binary[ETH_ALEN] = {0x1A, 0x2B, 0x03, 0x44, 0x05, 0x00}; - const char * long_string = "00:1a:2b:03:44:05:06:07"; + const char *long_string = "00:1a:2b:03:44:05:06:07"; const guint8 long_binary[8] = {0x00, 0x1A, 0x2B, 0x03, 0x44, 0x05, 0x06, 0x07}; - const char * null_string = "00:00:00:00:00:00"; + const char *null_string = "00:00:00:00:00:00"; const guint8 null_binary[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; g_assert(nm_utils_hwaddr_matches(string, -1, string, -1)); @@ -4860,7 +4860,7 @@ test_hwaddr_canonical(void) const char *short_string = "0:1a:2b:3:44:5"; const char *hyphen_string = "00-1a-2b-03-44-05"; const char *invalid_string = "00:1A:2B"; - char * canonical; + char *canonical; canonical = nm_utils_hwaddr_canonical(string, ETH_ALEN); g_assert_cmpstr(canonical, ==, string); @@ -5032,10 +5032,10 @@ test_connection_changed_signal(void) static void test_setting_connection_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingConnection *s_con; - gs_free char * uuid = NULL; + gs_free char *uuid = NULL; connection = nm_simple_connection_new(); g_signal_connect(connection, @@ -5069,7 +5069,7 @@ test_setting_connection_changed_signal(void) static void test_setting_bond_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingBond *s_bond; @@ -5092,12 +5092,12 @@ test_setting_bond_changed_signal(void) static void test_setting_ip4_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingIPConfig *s_ip4; - NMIPAddress * addr; - NMIPRoute * route; - GError * error = NULL; + NMIPAddress *addr; + NMIPRoute *route; + GError *error = NULL; connection = nm_simple_connection_new(); g_signal_connect(connection, @@ -5168,12 +5168,12 @@ test_setting_ip4_changed_signal(void) static void test_setting_ip6_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingIPConfig *s_ip6; - NMIPAddress * addr; - NMIPRoute * route; - GError * error = NULL; + NMIPAddress *addr; + NMIPRoute *route; + GError *error = NULL; connection = nm_simple_connection_new(); g_signal_connect(connection, @@ -5238,7 +5238,7 @@ test_setting_ip6_changed_signal(void) static void test_setting_vlan_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingVlan *s_vlan; @@ -5300,7 +5300,7 @@ test_setting_vpn_changed_signal(void) static void test_setting_wired_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingWired *s_wired; @@ -5323,7 +5323,7 @@ test_setting_wired_changed_signal(void) static void test_setting_wireless_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingWireless *s_wifi; @@ -5344,7 +5344,7 @@ test_setting_wireless_changed_signal(void) static void test_setting_wireless_security_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingWirelessSecurity *s_wsec; @@ -5411,7 +5411,7 @@ test_setting_wireless_security_changed_signal(void) static void test_setting_802_1x_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSetting8021x *s_8021x; @@ -5505,13 +5505,13 @@ test_connection_normalize_uuid(void) static void test_connection_normalize_virtual_iface_name(void) { - NMConnection * con = NULL; + NMConnection *con = NULL; NMSettingConnection *s_con; - NMSettingVlan * s_vlan; - GVariant * connection_dict, *setting_dict, *var; - GError * error = NULL; - const char * IFACE_NAME = "iface"; - const char * IFACE_VIRT = "iface-X"; + NMSettingVlan *s_vlan; + GVariant *connection_dict, *setting_dict, *var; + GError *error = NULL; + const char *IFACE_NAME = "iface"; + const char *IFACE_VIRT = "iface-X"; con = nmtst_create_minimal_connection("test1", "22001632-bbb4-4616-b277-363dce3dfb5b", @@ -5605,11 +5605,11 @@ _test_connection_normalize_type_normalizable_setting( const char *type, void (*prepare_normalizable_fcn)(NMConnection *con)) { - NMSettingConnection *s_con; - NMSetting * s_base; - GType base_type; + NMSettingConnection *s_con; + NMSetting *s_base; + GType base_type; gs_unref_object NMConnection *con = NULL; - gs_free char * id = g_strdup_printf("%s[%s]", G_STRFUNC, type); + gs_free char *id = g_strdup_printf("%s[%s]", G_STRFUNC, type); base_type = nm_setting_lookup_type(type); g_assert(base_type != G_TYPE_INVALID); @@ -5640,10 +5640,10 @@ _test_connection_normalize_type_normalizable_setting( static void _test_connection_normalize_type_unnormalizable_setting(const char *type) { - NMSettingConnection *s_con; - GType base_type; + NMSettingConnection *s_con; + GType base_type; gs_unref_object NMConnection *con = NULL; - gs_free char * id = g_strdup_printf("%s[%s]", G_STRFUNC, type); + gs_free char *id = g_strdup_printf("%s[%s]", G_STRFUNC, type); base_type = nm_setting_lookup_type(type); g_assert(base_type != G_TYPE_INVALID); @@ -5666,11 +5666,11 @@ static void _test_connection_normalize_type_normalizable_type(const char *type, NMSetting *(*add_setting_fcn)(NMConnection *con)) { - NMSettingConnection *s_con; - NMSetting * s_base; - GType base_type; + NMSettingConnection *s_con; + NMSetting *s_base; + GType base_type; gs_unref_object NMConnection *con = NULL; - gs_free char * id = g_strdup_printf("%s[%s]", G_STRFUNC, type); + gs_free char *id = g_strdup_printf("%s[%s]", G_STRFUNC, type); base_type = nm_setting_lookup_type(type); g_assert(base_type != G_TYPE_INVALID); @@ -5738,7 +5738,7 @@ _add_setting_fcn_bluetooth(NMConnection *con) static NMSetting * _add_setting_fcn_bond(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; NMSettingConnection *s_con; setting = g_object_new(NM_TYPE_SETTING_BOND, NULL); @@ -5755,7 +5755,7 @@ _add_setting_fcn_bond(NMConnection *con) static NMSetting * _add_setting_fcn_bridge(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; NMSettingConnection *s_con; setting = g_object_new(NM_TYPE_SETTING_BRIDGE, NULL); @@ -5797,9 +5797,9 @@ _add_setting_fcn_infiniband(NMConnection *con) static NMSetting * _add_setting_fcn_olpc_mesh(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; const char *ssid_data = "ssid-test"; - GBytes * ssid; + GBytes *ssid; ssid = g_bytes_new(ssid_data, strlen(ssid_data)); setting = g_object_new(NM_TYPE_SETTING_OLPC_MESH, @@ -5817,7 +5817,7 @@ _add_setting_fcn_olpc_mesh(NMConnection *con) static NMSetting * _add_setting_fcn_team(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; NMSettingConnection *s_con; setting = g_object_new(NM_TYPE_SETTING_TEAM, NULL); @@ -5871,9 +5871,9 @@ _add_setting_fcn_wimax(NMConnection *con) static NMSetting * _add_setting_fcn_wireless(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; const char *ssid_data = "ssid-test"; - GBytes * ssid; + GBytes *ssid; ssid = g_bytes_new(ssid_data, strlen(ssid_data)); setting = g_object_new(NM_TYPE_SETTING_WIRELESS, NM_SETTING_WIRELESS_SSID, ssid, NULL); @@ -5939,7 +5939,7 @@ static void test_connection_normalize_slave_type_1(void) { gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; con = nmtst_create_minimal_connection("test_connection_normalize_slave_type_1", "cc4cd5df-45dc-483e-b291-6b76c2338ecb", @@ -5975,7 +5975,7 @@ static void test_connection_normalize_slave_type_2(void) { gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; con = nmtst_create_minimal_connection("test_connection_normalize_slave_type_2", "40bea008-ca72-439a-946b-e65f827656f9", @@ -6013,7 +6013,7 @@ static void test_connection_normalize_infiniband_mtu(void) { gs_unref_object NMConnection *con = NULL; - NMSettingInfiniband * s_infini; + NMSettingInfiniband *s_infini; guint mtu_regular = nmtst_rand_select(2044, 2045, 65520); con = nmtst_create_minimal_connection("test_connection_normalize_infiniband_mtu", @@ -6073,9 +6073,9 @@ static void test_connection_normalize_gateway_never_default(void) { gs_unref_object NMConnection *con = NULL; - NMSettingIPConfig * s_ip4, *s_ip6; - NMIPAddress * addr; - gs_free_error GError *error = NULL; + NMSettingIPConfig *s_ip4, *s_ip6; + NMIPAddress *addr; + gs_free_error GError *error = NULL; con = nmtst_create_minimal_connection("test1", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); nmtst_assert_connection_verifies_and_normalizable(con); @@ -6124,7 +6124,7 @@ static void test_connection_normalize_may_fail(void) { gs_unref_object NMConnection *con = NULL; - NMSettingIPConfig * s_ip4, *s_ip6; + NMSettingIPConfig *s_ip4, *s_ip6; con = nmtst_create_minimal_connection("test2", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); nmtst_assert_connection_verifies_and_normalizable(con); @@ -6166,9 +6166,9 @@ static void test_connection_normalize_shared_addresses(void) { gs_unref_object NMConnection *con = NULL; - NMSettingIPConfig * s_ip4, *s_ip6; - NMIPAddress * addr; - gs_free_error GError *error = NULL; + NMSettingIPConfig *s_ip4, *s_ip6; + NMIPAddress *addr; + gs_free_error GError *error = NULL; con = nmtst_create_minimal_connection("test1", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); nmtst_assert_connection_verifies_and_normalizable(con); @@ -6217,10 +6217,10 @@ test_connection_normalize_shared_addresses(void) static void test_connection_normalize_ovs_interface_type_system(gconstpointer test_data) { - const guint TEST_CASE = GPOINTER_TO_UINT(test_data); - gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; - NMSettingOvsInterface * s_ovs_if; + const guint TEST_CASE = GPOINTER_TO_UINT(test_data); + gs_unref_object NMConnection *con = NULL; + NMSettingConnection *s_con; + NMSettingOvsInterface *s_ovs_if; con = nmtst_create_minimal_connection("test_connection_normalize_ovs_interface_type_system", NULL, @@ -6370,13 +6370,13 @@ test_connection_normalize_ovs_interface_type_system(gconstpointer test_data) static void test_connection_normalize_ovs_interface_type_ovs_interface(gconstpointer test_data) { - const guint TEST_CASE = GPOINTER_TO_UINT(test_data); - gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; - NMSettingOvsInterface * s_ovs_if; - NMSettingOvsPatch * s_ovs_patch; - NMSettingIP4Config * s_ip4; - NMSettingIP6Config * s_ip6; + const guint TEST_CASE = GPOINTER_TO_UINT(test_data); + gs_unref_object NMConnection *con = NULL; + NMSettingConnection *s_con; + NMSettingOvsInterface *s_ovs_if; + NMSettingOvsPatch *s_ovs_patch; + NMSettingIP4Config *s_ip4; + NMSettingIP6Config *s_ip6; con = nmtst_create_minimal_connection( "test_connection_normalize_ovs_interface_type_ovs_interface", @@ -6602,16 +6602,16 @@ test_connection_normalize_ovs_interface_type_ovs_interface(gconstpointer test_da static void test_setting_ip4_gateway(void) { - NMConnection * conn; + NMConnection *conn; NMSettingIPConfig *s_ip4; - NMIPAddress * addr; - GVariant * conn_dict, *ip4_dict, *value; + NMIPAddress *addr; + GVariant *conn_dict, *ip4_dict, *value; GVariantIter iter; - GVariant * addr_var; + GVariant *addr_var; guint32 addr_vals_0[] = {htonl(0xc0a8010a), 0x00000018, htonl(0x00000000)}; guint32 addr_vals_1[] = {htonl(0xc0a8010b), 0x00000018, htonl(0xc0a80101)}; GVariantBuilder addrs_builder; - GError * error = NULL; + GError *error = NULL; nmtst_assert_ip4_address(addr_vals_0[0], "192.168.1.10"); @@ -6713,12 +6713,12 @@ test_setting_ip4_gateway(void) static void test_setting_ip6_gateway(void) { - NMConnection * conn; + NMConnection *conn; NMSettingIPConfig *s_ip6; - NMIPAddress * addr; - GVariant * conn_dict, *ip6_dict, *value; + NMIPAddress *addr; + GVariant *conn_dict, *ip6_dict, *value; GVariantIter iter; - GVariant * gateway_var; + GVariant *gateway_var; GVariantBuilder addrs_builder; guint8 addr_bytes_0[] = {0xab, 0xcd, @@ -6768,7 +6768,7 @@ test_setting_ip6_gateway(void) 0x00, 0x00, 0x01}; - GError * error = NULL; + GError *error = NULL; /* When serializing on the daemon side, ipv6.gateway is copied to the first * entry of ipv6.addresses @@ -6872,7 +6872,7 @@ test_setting_ip6_gateway(void) } typedef struct { - const char * str; + const char *str; const guint8 expected[20]; const guint expected_len; } HexItem; @@ -6881,10 +6881,10 @@ static void test_setting_compare_default_strv(void) { gs_unref_object NMConnection *c1 = NULL, *c2 = NULL; - char ** strv; - NMSettingIPConfig * s_ip2, *s_ip1; + char **strv; + NMSettingIPConfig *s_ip2, *s_ip1; gboolean compare; - GHashTable * out_settings = NULL; + GHashTable *out_settings = NULL; c1 = nmtst_create_minimal_connection("test_compare_default_strv", NULL, @@ -6951,8 +6951,8 @@ static void _sock_addr_endpoint(const char *endpoint, const char *host, gint32 port) { nm_auto_unref_sockaddrendpoint NMSockAddrEndpoint *ep = NULL; - const char * s_endpoint; - const char * s_host; + const char *s_endpoint; + const char *s_host; gint32 s_port; SockAddrUnion sockaddr = {}; @@ -6993,8 +6993,8 @@ static void _sock_addr_endpoint_fixed(const char *endpoint, const char *host, guint16 port, guint scope_id) { nm_auto_unref_sockaddrendpoint NMSockAddrEndpoint *ep = NULL; - const char * s_endpoint; - const char * s_host; + const char *s_endpoint; + const char *s_host; gint32 s_port; int addr_family; NMIPAddr addrbin; @@ -7130,8 +7130,8 @@ _do_strquote(const char *str, gsize buf_len, const char *expected) { char canary = (char) nmtst_get_rand_uint32(); gs_free char *buf_full = g_malloc(buf_len + 2); - char * buf = &buf_full[1]; - const char * b; + char *buf = &buf_full[1]; + const char *b; buf[-1] = canary; buf[buf_len] = canary; @@ -7932,8 +7932,8 @@ test_nm_utils_ascii_str_to_int64_do(const char *str, int exp_errno, gint64 exp_val) { - const char * sign = ""; - const char * val; + const char *sign = ""; + const char *val; static const char *whitespaces[] = { "", " ", @@ -7972,7 +7972,7 @@ test_nm_utils_ascii_str_to_int64_do(const char *str, for (ws_post = whitespaces; *ws_post; ws_post++) { for (null = nulls; *null; null++) { for (i = 0;; i++) { - char * s; + char *s; const char *str_base = ""; if (base == 16) { @@ -8145,8 +8145,8 @@ test_nm_utils_strstrdictkey(void) .v1 = _v1, .v2 = _v2, .v_static = _nm_utils_strstrdictkey_static(_v1, _v2), \ } const struct { - const char * v1; - const char * v2; + const char *v1; + const char *v2; NMUtilsStrStrDictKey *v_static; } * val1, *val2, values[] = { @@ -8210,11 +8210,11 @@ test_nm_ptrarray_len(void) #define _PTRARRAY_LEN0(T) \ G_STMT_START \ { \ - T ** vnull = NULL; \ - T *const * vnull1 = NULL; \ + T **vnull = NULL; \ + T *const *vnull1 = NULL; \ T *const *const vnull2 = NULL; \ - T * v0[] = {NULL}; \ - T *const * v01 = v0; \ + T *v0[] = {NULL}; \ + T *const *v01 = v0; \ T *const *const v02 = v0; \ T **const v03 = v0; \ \ @@ -8241,13 +8241,13 @@ test_nm_ptrarray_len(void) { \ T x[5] = {0}; \ \ - T * v1[] = {&x[0], NULL}; \ - T *const * v11 = v1; \ + T *v1[] = {&x[0], NULL}; \ + T *const *v11 = v1; \ T *const *const v12 = v1; \ T **const v13 = v1; \ \ - T * v2[] = {&x[0], &x[1], NULL}; \ - T *const * v21 = v2; \ + T *v2[] = {&x[0], &x[1], NULL}; \ + T *const *v21 = v2; \ T *const *const v22 = v2; \ T **const v23 = v2; \ \ @@ -8273,14 +8273,14 @@ test_nm_ptrarray_len(void) /*****************************************************************************/ static void -test_nm_utils_dns_option_validate_do(char * option, +test_nm_utils_dns_option_validate_do(char *option, gboolean ipv6, const NMUtilsDNSOptionDesc *descs, gboolean exp_result, - char * exp_name, + char *exp_name, gboolean exp_value) { - char * name; + char *name; long value = 0; gboolean result; @@ -8556,7 +8556,7 @@ test_nm_utils_is_power_of_two(void) { guint64 xyes, xno; int i, j; - GRand * rand = nmtst_get_rand(); + GRand *rand = nmtst_get_rand(); int numbits; g_assert(!nm_utils_is_power_of_two(0)); @@ -8636,8 +8636,8 @@ _test_find_binary_search_cmp(gconstpointer a, gconstpointer b, gpointer dummy) static void _test_find_binary_search_do(const int *array, gsize len) { - gsize i; - gssize idx, idx2, idx_first, idx_last; + gsize i; + gssize idx, idx2, idx_first, idx_last; gs_free gconstpointer *parray = g_new(gconstpointer, len); const int NEEDLE = 0; gconstpointer pneedle = GINT_TO_POINTER(NEEDLE); @@ -8884,7 +8884,7 @@ test_nm_utils_ptrarray_find_binary_search_with_duplicates(void) static void _test_nm_utils_enum_to_str_do_full(GType type, int flags, - const char * exp_str, + const char *exp_str, const NMUtilsEnumValueInfo *value_infos) { gs_free char *str = NULL; @@ -8914,10 +8914,10 @@ _test_nm_utils_enum_to_str_do_full(GType type, static void _test_nm_utils_enum_from_str_do_full(GType type, - const char * str, + const char *str, gboolean exp_result, int exp_flags, - const char * exp_err_token, + const char *exp_err_token, const NMUtilsEnumValueInfo *value_infos) { int flags; @@ -8962,7 +8962,7 @@ static void _test_nm_utils_enum_get_values_do(GType type, int from, int to, const char *exp_str) { gs_free const char **strv = NULL; - gs_free char * str = NULL; + gs_free char *str = NULL; g_assert(exp_str); @@ -9132,9 +9132,9 @@ static void _do_test_utils_str_utf8safe_unescape(const char *str, const char *expected, gsize expected_len) { gsize l; - const char * s; + const char *s; gs_free gpointer buf_free_1 = NULL; - gs_free char * str_free_1 = NULL; + gs_free char *str_free_1 = NULL; s = nm_utils_buf_utf8safe_unescape(str, NM_UTILS_STR_UTF8_SAFE_FLAG_NONE, &l, &buf_free_1); g_assert_cmpint(expected_len, ==, l); @@ -9174,14 +9174,14 @@ _do_test_utils_str_utf8safe_unescape(const char *str, const char *expected, gsiz _do_test_utils_str_utf8safe_unescape("" str "", expected, NM_STRLEN(expected)) static void -_do_test_utils_str_utf8safe(const char * str, +_do_test_utils_str_utf8safe(const char *str, gsize str_len, - const char * expected, + const char *expected, NMUtilsStrUtf8SafeFlags flags) { - const char * str_safe; - const char * buf_safe; - const char * s; + const char *str_safe; + const char *buf_safe; + const char *s; gs_free char *str_free_1 = NULL; gs_free char *str_free_2 = NULL; gs_free char *str_free_3 = NULL; @@ -9623,8 +9623,8 @@ static void test_route_attributes_parse(void) { GHashTable *ht; - GError * error = NULL; - GVariant * variant; + GError *error = NULL; + GVariant *variant; ht = nm_utils_parse_variant_attributes("mtu=1400 src=1.2.3.4 cwnd=14", ' ', @@ -9689,7 +9689,7 @@ static void test_route_attributes_format(void) { gs_unref_hashtable GHashTable *ht = NULL; - char * str; + char *str; ht = g_hash_table_new_full(nm_str_hash, g_str_equal, NULL, (GDestroyNotify) g_variant_unref); @@ -9918,9 +9918,9 @@ test_ethtool_offload(void) /*****************************************************************************/ typedef struct { - GMainLoop * loop1; + GMainLoop *loop1; GMainContext *c2; - GSource * extra_sources[2]; + GSource *extra_sources[2]; bool got_signal[5]; int fd_2; } IntegData; @@ -9971,7 +9971,7 @@ static gboolean _test_integrate_cb_idle_2(gpointer user_data) { IntegData *d = user_data; - GSource * extra_source; + GSource *extra_source; g_assert(d->got_signal[1]); g_assert(d->got_signal[2]); @@ -9995,7 +9995,7 @@ static gboolean _test_integrate_cb_idle_1(gpointer user_data) { IntegData *d = user_data; - GSource * extra_source; + GSource *extra_source; g_assert(d->got_signal[2]); g_assert(!d->extra_sources[0]); @@ -10032,9 +10032,9 @@ _test_integrate_maincontext_cb_idle1(gpointer user_data) static void test_integrate_maincontext(gconstpointer test_data) { - const guint TEST_IDX = GPOINTER_TO_UINT(test_data); - GMainContext * c1 = g_main_context_default(); - nm_auto_unref_gmaincontext GMainContext *c2 = g_main_context_new(); + const guint TEST_IDX = GPOINTER_TO_UINT(test_data); + GMainContext *c1 = g_main_context_default(); + nm_auto_unref_gmaincontext GMainContext *c2 = g_main_context_new(); nm_auto_destroy_and_unref_gsource GSource *integ_source = NULL; integ_source = nm_utils_g_main_context_create_integrate_source(c2); @@ -10056,11 +10056,11 @@ test_integrate_maincontext(gconstpointer test_data) nm_auto_destroy_and_unref_gsource GSource *timeout_source_1 = NULL; nm_auto_destroy_and_unref_gsource GSource *idle_source_1 = NULL; nm_auto_destroy_and_unref_gsource GSource *fd_source_1 = NULL; - nm_auto_unref_gmainloop GMainLoop *loop1 = NULL; - nm_auto_close int fd_1 = -1; - nm_auto_close int fd_2 = -1; - IntegData d; - int i; + nm_auto_unref_gmainloop GMainLoop *loop1 = NULL; + nm_auto_close int fd_1 = -1; + nm_auto_close int fd_2 = -1; + IntegData d; + int i; main_timeout_source = g_timeout_source_new(3000); g_source_set_callback(main_timeout_source, nmtst_g_source_assert_not_called, NULL, NULL); @@ -10134,14 +10134,14 @@ test_nm_ip_addr_zero(void) static void test_connection_ovs_ifname(gconstpointer test_data) { - const guint TEST_CASE = GPOINTER_TO_UINT(test_data); + const guint TEST_CASE = GPOINTER_TO_UINT(test_data); gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con = NULL; - NMSettingOvsBridge * s_ovs_bridge = NULL; - NMSettingOvsPort * s_ovs_port = NULL; - NMSettingOvsInterface * s_ovs_iface = NULL; - NMSettingOvsPatch * s_ovs_patch = NULL; - const char * ovs_iface_type = NULL; + NMSettingConnection *s_con = NULL; + NMSettingOvsBridge *s_ovs_bridge = NULL; + NMSettingOvsPort *s_ovs_port = NULL; + NMSettingOvsInterface *s_ovs_iface = NULL; + NMSettingOvsPatch *s_ovs_patch = NULL; + const char *ovs_iface_type = NULL; switch (TEST_CASE) { case 1: @@ -10345,10 +10345,10 @@ static char * _strsplit_quoted_join_strv_rand(const char *const *strv) { NMStrBuf strbuf = NM_STR_BUF_INIT(nmtst_get_rand_uint32() % 200, nmtst_get_rand_bool()); - char * result; + char *result; gsize l; gsize l2; - gsize * p_l2 = nmtst_get_rand_bool() ? &l2 : NULL; + gsize *p_l2 = nmtst_get_rand_bool() ? &l2 : NULL; gsize i; g_assert(strv); @@ -10419,14 +10419,14 @@ next_maybe_quote: } static void -_strsplit_quoted_assert_strv(const char * topic, - const char * str, +_strsplit_quoted_assert_strv(const char *topic, + const char *str, const char *const *strv1, const char *const *strv2) { nm_auto_str_buf NMStrBuf s1 = {}; nm_auto_str_buf NMStrBuf s2 = {}; - gs_free char * str_escaped = NULL; + gs_free char *str_escaped = NULL; int i; g_assert(str); @@ -10504,7 +10504,7 @@ test_strsplit_quoted(void) for (i_run = 0; i_run < 1000; i_run++) { gs_strfreev char **strv = NULL; - gs_free char * str = NULL; + gs_free char *str = NULL; /* create random strv array and join them carefully so that splitting * them will yield the original value. */ @@ -10530,7 +10530,7 @@ test_nm_property_variant_to_gvalue(void) #define _test_variant_to_gvalue_bad(variant, gtype) \ G_STMT_START \ { \ - gs_unref_variant GVariant * _variant = (variant); \ + gs_unref_variant GVariant *_variant = (variant); \ GType _gtype = (gtype); \ nm_auto_unset_gvalue GValue _gvalue = G_VALUE_INIT; \ \ @@ -10542,10 +10542,10 @@ test_nm_property_variant_to_gvalue(void) #define _test_variant_to_gvalue(variant, gtype, check) \ G_STMT_START \ { \ - gs_unref_variant GVariant * _variant = (variant); \ + gs_unref_variant GVariant *_variant = (variant); \ GType _gtype = (gtype); \ nm_auto_unset_gvalue GValue _gvalue = G_VALUE_INIT; \ - _nm_unused GValue *const gg = &_gvalue; \ + _nm_unused GValue *const gg = &_gvalue; \ \ g_value_init(&_gvalue, _gtype); \ g_assert_cmpint(_nm_property_variant_to_gvalue(_variant, &_gvalue), ==, TRUE); \ diff --git a/src/libnm-core-impl/tests/test-keyfile.c b/src/libnm-core-impl/tests/test-keyfile.c index db19337934..9bd13ffc30 100644 --- a/src/libnm-core-impl/tests/test-keyfile.c +++ b/src/libnm-core-impl/tests/test-keyfile.c @@ -26,15 +26,15 @@ /*****************************************************************************/ static void -do_test_encode_key_full(GKeyFile * kf, +do_test_encode_key_full(GKeyFile *kf, const char *name, const char *key, const char *key_decode_encode) { gs_free char *to_free1 = NULL; gs_free char *to_free2 = NULL; - const char * key2; - const char * name2; + const char *key2; + const char *name2; g_assert(key); @@ -105,7 +105,7 @@ test_encode_key(void) G_STMT_START \ { \ NMConnection **_con = (con); \ - GKeyFile ** _keyfile = (keyfile); \ + GKeyFile **_keyfile = (keyfile); \ \ g_clear_object(_con); \ nm_clear_pointer(_keyfile, g_key_file_unref); \ @@ -129,7 +129,7 @@ _assert_gbytes(GBytes *bytes, gconstpointer data, gssize len) static GKeyFile * _keyfile_load_from_data(const char *str) { - GError * error = NULL; + GError *error = NULL; gboolean success; GKeyFile *keyfile; @@ -146,7 +146,7 @@ _keyfile_load_from_data(const char *str) static GKeyFile * _nm_keyfile_write(NMConnection *connection, NMKeyfileWriteHandler handler, void *user_data) { - GError * error = NULL; + GError *error = NULL; GKeyFile *kf; g_assert(NM_IS_CONNECTION(connection)); @@ -158,13 +158,13 @@ _nm_keyfile_write(NMConnection *connection, NMKeyfileWriteHandler handler, void } static NMConnection * -_nm_keyfile_read(GKeyFile * keyfile, - const char * keyfile_name, +_nm_keyfile_read(GKeyFile *keyfile, + const char *keyfile_name, NMKeyfileReadHandler read_handler, - void * read_data, + void *read_data, gboolean needs_normalization) { - GError * error = NULL; + GError *error = NULL; NMConnection *con; gs_free char *filename = NULL; gs_free char *base_dir = NULL; @@ -208,18 +208,18 @@ _nm_keyfile_read(GKeyFile * keyfile, } static void -_keyfile_convert(NMConnection ** con, - GKeyFile ** keyfile, - const char * keyfile_name, +_keyfile_convert(NMConnection **con, + GKeyFile **keyfile, + const char *keyfile_name, NMKeyfileReadHandler read_handler, - void * read_data, + void *read_data, NMKeyfileWriteHandler write_handler, - void * write_data, + void *write_data, gboolean needs_normalization) { - NMConnection * c0; - GKeyFile * k0; - gs_unref_object NMConnection *c0_k1_c2 = NULL, *k0_c1 = NULL, *k0_c1_k2_c3 = NULL; + NMConnection *c0; + GKeyFile *k0; + gs_unref_object NMConnection *c0_k1_c2 = NULL, *k0_c1 = NULL, *k0_c1_k2_c3 = NULL; nm_auto_unref_keyfile GKeyFile *k0_c1_k2 = NULL, *c0_k1 = NULL, *c0_k1_c2_k3 = NULL; /* convert from @con to @keyfile and check that we can make @@ -263,7 +263,7 @@ _keyfile_convert(NMConnection ** con, nmtst_assert_resolve_relative_path_equals(p1, p2); if (strcmp(p1, p2) != 0) { - gs_free char * puri = NULL; + gs_free char *puri = NULL; gs_unref_bytes GBytes *pfile = NULL; g_assert(p1[0] != '/' && p2[0] == '/'); @@ -310,14 +310,14 @@ _keyfile_convert(NMConnection ** con, /*****************************************************************************/ static void -_test_8021x_cert_check(NMConnection * con, +_test_8021x_cert_check(NMConnection *con, NMSetting8021xCKScheme expected_scheme, - const void * value, + const void *value, gssize val_len) { - GKeyFile * keyfile = NULL; + GKeyFile *keyfile = NULL; NMSetting8021x *s_8021x; - gs_free char * kval = NULL; + gs_free char *kval = NULL; _keyfile_convert(&con, &keyfile, "/_test_8021x_cert_check/foo", NULL, NULL, NULL, NULL, FALSE); @@ -335,7 +335,7 @@ _test_8021x_cert_check(NMConnection * con, g_assert(kval); g_assert_cmpstr(kval, ==, value); } else if (expected_scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) { - GBytes * blob = nm_setting_802_1x_get_ca_cert_blob(s_8021x); + GBytes *blob = nm_setting_802_1x_get_ca_cert_blob(s_8021x); gs_free char *file_blob = NULL; if (val_len == -1) { @@ -363,7 +363,7 @@ _test_8021x_cert_check(NMConnection * con, static void _test_8021x_cert_check_blob_full(NMConnection *con, const void *data, gsize len) { - GBytes * bytes; + GBytes *bytes; NMSetting8021x *s_8021x = nm_connection_get_setting_802_1x(con); bytes = g_bytes_new(data, len); @@ -380,10 +380,10 @@ _test_8021x_cert_check_blob_full(NMConnection *con, const void *data, gsize len) static void _test_8021x_cert_from_files(const char *cert, const char *key) { - NMSetting8021x *s_8021x; + NMSetting8021x *s_8021x; gs_unref_object NMConnection *con = nmtst_create_minimal_connection("test-cert", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - GError * error = NULL; + GError *error = NULL; gboolean success; NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_PATH; gs_free char *full_TEST_WIRED_TLS_CA_CERT = nmtst_file_resolve_relative_path(cert, NULL); @@ -456,9 +456,9 @@ test_8021x_cert_tpm2key(void) static void test_8021x_cert_read(void) { - GKeyFile * keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSetting8021x * s_8021x; + GKeyFile *keyfile = NULL; + gs_unref_object NMConnection *con = NULL; + NMSetting8021x *s_8021x; con = nmtst_create_connection_from_keyfile("[connection]\n" "type=ethernet", @@ -649,9 +649,9 @@ test_8021x_cert_read(void) static void test_team_conf_read_valid(void) { - GKeyFile * keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingTeam * s_team; + GKeyFile *keyfile = NULL; + gs_unref_object NMConnection *con = NULL; + NMSettingTeam *s_team; con = nmtst_create_connection_from_keyfile("[connection]\n" "type=team\n" @@ -671,9 +671,9 @@ test_team_conf_read_valid(void) static void test_team_conf_read_invalid(void) { - GKeyFile * keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingTeam * s_team; + GKeyFile *keyfile = NULL; + gs_unref_object NMConnection *con = NULL; + NMSettingTeam *s_team; if (!nm_json_vt()) { g_test_skip("team test requires JSON validation"); @@ -701,8 +701,8 @@ static void test_user_1(void) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingUser * s_user; + gs_unref_object NMConnection *con = NULL; + NMSettingUser *s_user; con = nmtst_create_connection_from_keyfile("[connection]\n" "id=t\n" @@ -728,7 +728,7 @@ test_user_1(void) #define _USER_SET_DATA(s_user, key, val) \ G_STMT_START \ { \ - GError * _error = NULL; \ + GError *_error = NULL; \ gboolean _success; \ \ _success = nm_setting_user_set_data((s_user), (key), (val), &_error); \ @@ -771,8 +771,8 @@ static void test_vpn_1(void) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingVpn * s_vpn; + gs_unref_object NMConnection *con = NULL; + NMSettingVpn *s_vpn; con = nmtst_create_connection_from_keyfile("[connection]\n" "id=t\n" @@ -797,19 +797,19 @@ static void test_bridge_vlans(void) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingBridge * s_bridge; - NMBridgeVlan * vlan; - guint16 vid, vid_end; + gs_unref_object NMConnection *con = NULL; + NMSettingBridge *s_bridge; + NMBridgeVlan *vlan; + guint16 vid, vid_end; con = nmtst_create_connection_from_keyfile("[connection]\n" - "id=t\n" - "type=bridge\n" - "interface-name=br4\n" - "\n" - "[bridge]\n" - "vlans=900 , 1 pvid untagged, 100-123 untagged\n" - "", + "id=t\n" + "type=bridge\n" + "interface-name=br4\n" + "\n" + "[bridge]\n" + "vlans=900 , 1 pvid untagged, 100-123 untagged\n" + "", "/test_bridge_port/vlans"); s_bridge = NM_SETTING_BRIDGE(nm_connection_get_setting(con, NM_TYPE_SETTING_BRIDGE)); g_assert(s_bridge); @@ -846,21 +846,21 @@ static void test_bridge_port_vlans(void) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingBridgePort * s_port; - NMBridgeVlan * vlan; - guint16 vid_start, vid_end; + gs_unref_object NMConnection *con = NULL; + NMSettingBridgePort *s_port; + NMBridgeVlan *vlan; + guint16 vid_start, vid_end; con = nmtst_create_connection_from_keyfile("[connection]\n" - "id=t\n" - "type=dummy\n" - "interface-name=dummy1\n" - "master=br0\n" - "slave-type=bridge\n" - "\n" - "[bridge-port]\n" - "vlans=4094 pvid , 10-20 untagged\n" - "", + "id=t\n" + "type=dummy\n" + "interface-name=dummy1\n" + "master=br0\n" + "slave-type=bridge\n" + "\n" + "[bridge-port]\n" + "vlans=4094 pvid , 10-20 untagged\n" + "", "/test_bridge_port/vlans"); s_port = NM_SETTING_BRIDGE_PORT(nm_connection_get_setting(con, NM_TYPE_SETTING_BRIDGE_PORT)); g_assert(s_port); diff --git a/src/libnm-core-impl/tests/test-secrets.c b/src/libnm-core-impl/tests/test-secrets.c index 41dcc4b312..2fa3f1059e 100644 --- a/src/libnm-core-impl/tests/test-secrets.c +++ b/src/libnm-core-impl/tests/test-secrets.c @@ -46,14 +46,14 @@ _assert_hints_has(GPtrArray *hints, const char *item) static NMConnection * make_tls_connection(const char *detail, NMSetting8021xCKScheme scheme) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSetting8021x * s_8021x; - NMSettingWired * s_wired; - NMSettingIP4Config * s_ip4; - char * uuid; + NMSetting8021x *s_8021x; + NMSettingWired *s_wired; + NMSettingIP4Config *s_ip4; + char *uuid; gboolean success; - GError * error = NULL; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -129,8 +129,8 @@ static void test_need_tls_secrets_path(void) { NMConnection *connection; - const char * setting_name; - GPtrArray * hints = NULL; + const char *setting_name; + GPtrArray *hints = NULL; connection = make_tls_connection("need-tls-secrets-path-key", NM_SETTING_802_1X_CK_SCHEME_PATH); @@ -155,8 +155,8 @@ static void test_need_tls_secrets_blob(void) { NMConnection *connection; - const char * setting_name; - GPtrArray * hints = NULL; + const char *setting_name; + GPtrArray *hints = NULL; connection = make_tls_connection("need-tls-secrets-blob-key", NM_SETTING_802_1X_CK_SCHEME_BLOB); @@ -180,14 +180,14 @@ test_need_tls_secrets_blob(void) static NMConnection * make_tls_phase2_connection(const char *detail, NMSetting8021xCKScheme scheme) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSetting8021x * s_8021x; - NMSettingWired * s_wired; - NMSettingIP4Config * s_ip4; - char * uuid; + NMSetting8021x *s_8021x; + NMSettingWired *s_wired; + NMSettingIP4Config *s_ip4; + char *uuid; gboolean success; - GError * error = NULL; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -264,8 +264,8 @@ static void test_need_tls_phase2_secrets_path(void) { NMConnection *connection; - const char * setting_name; - GPtrArray * hints = NULL; + const char *setting_name; + GPtrArray *hints = NULL; connection = make_tls_phase2_connection("need-tls-phase2-secrets-path-key", NM_SETTING_802_1X_CK_SCHEME_PATH); @@ -291,8 +291,8 @@ static void test_need_tls_phase2_secrets_blob(void) { NMConnection *connection; - const char * setting_name; - GPtrArray * hints = NULL; + const char *setting_name; + GPtrArray *hints = NULL; connection = make_tls_phase2_connection("need-tls-phase2-secrets-blob-key", NM_SETTING_802_1X_CK_SCHEME_BLOB); @@ -317,13 +317,13 @@ test_need_tls_phase2_secrets_blob(void) static NMConnection * wifi_connection_new(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; unsigned char tmpssid[] = {0x31, 0x33, 0x33, 0x37}; - char * uuid; - GBytes * ssid; + char *uuid; + GBytes *ssid; connection = nm_simple_connection_new(); g_assert(connection); @@ -386,13 +386,13 @@ build_wep_secrets(const char *wepkey) static void test_update_secrets_wifi_single_setting(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; - const char * tmp; + const char *wepkey = "11111111111111111111111111"; + const char *tmp; /* Test update with a hashed setting of 802-11-wireless secrets */ @@ -420,14 +420,14 @@ test_update_secrets_wifi_single_setting(void) static void test_update_secrets_wifi_full_hash(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; GVariantBuilder builder; - GVariant * all; - GError * error = NULL; + GVariant *all; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; - const char * tmp; + const char *wepkey = "11111111111111111111111111"; + const char *tmp; /* Test update with a hashed connection containing only 802-11-wireless * setting and secrets. @@ -464,10 +464,10 @@ static void test_update_secrets_wifi_bad_setting_name(void) { NMConnection *connection; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; + const char *wepkey = "11111111111111111111111111"; /* Test that passing an invalid setting name to * nm_connection_update_secrets() fails with the correct error. @@ -489,12 +489,12 @@ test_update_secrets_wifi_bad_setting_name(void) static void test_update_secrets_whole_connection(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; + const char *wepkey = "11111111111111111111111111"; /* Test calling nm_connection_update_secrets() with an entire hashed * connection including non-secrets. @@ -527,8 +527,8 @@ static void test_update_secrets_whole_connection_empty_hash(void) { gs_unref_object NMConnection *connection = NULL; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; /* Test that updating secrets with an empty connection hash returns success */ @@ -550,15 +550,15 @@ test_update_secrets_whole_connection_empty_hash(void) static void test_update_secrets_whole_connection_bad_setting(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; - GVariant * secrets, *copy, *setting_hash; - const char * setting_name; + GVariant *secrets, *copy, *setting_hash; + const char *setting_name; GVariantBuilder conn_builder; GVariantIter conn_iter; - GError * error = NULL; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; + const char *wepkey = "11111111111111111111111111"; /* Test that sending a hashed connection containing an invalid setting * name fails with the right error. @@ -601,8 +601,8 @@ static void test_update_secrets_whole_connection_empty_base_setting(void) { NMConnection *connection; - GVariant * secrets, *setting; - GError * error = NULL; + GVariant *secrets, *setting; + GError *error = NULL; gboolean success; /* Test that a hashed connection which does not have any hashed secrets @@ -632,10 +632,10 @@ static void test_update_secrets_null_setting_name_with_setting_hash(void) { NMConnection *connection; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; + const char *wepkey = "11111111111111111111111111"; /* Ensure that a NULL setting name and only a hashed setting fails */ diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index 7444f2c143..eeb2385f33 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -48,8 +48,8 @@ _connection_new_from_dbus_strict(GVariant *dict, gboolean normalize) gs_unref_object NMConnection *con_n_0 = NULL; gs_unref_object NMConnection *con_n_s = NULL; gs_unref_object NMConnection *con_n_e = NULL; - gs_free_error GError *error = NULL; - guint i; + gs_free_error GError *error = NULL; + guint i; g_assert(g_variant_is_of_type(dict, NM_VARIANT_TYPE_CONNECTION)); @@ -128,7 +128,7 @@ test_nm_meta_setting_types_by_priority(void) for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) { const NMMetaSettingType meta_type = nm_meta_setting_types_by_priority[i]; const NMMetaSettingInfo *setting_info; - NMSetting * setting; + NMSetting *setting; g_assert(_NM_INT_NOT_NEGATIVE(meta_type)); g_assert(meta_type < _NM_META_SETTING_TYPE_NUM); @@ -203,7 +203,7 @@ compare_blob_data(const char *test, const char *key_path, GBytes *key) { gs_free char *contents = NULL; gsize len = 0; - GError * error = NULL; + GError *error = NULL; gboolean success; g_assert(key && g_bytes_get_size(key) > 0); @@ -237,13 +237,13 @@ check_scheme_path(GBytes *value, const char *path) static void test_private_key_import(const char *path, const char *password, NMSetting8021xCKScheme scheme) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; NMSetting8021xCKFormat tmp_fmt; - GError * error = NULL; - GBytes * tmp_key = NULL, *client_cert = NULL; - const char * pw; + GError *error = NULL; + GBytes *tmp_key = NULL, *client_cert = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -293,7 +293,7 @@ static void _do_test_connection_uuid(NMConnection *con, const char *uuid, const char *expected_uuid) { NMSettingConnection *s_con; - gs_free char * uuid_old = NULL; + gs_free char *uuid_old = NULL; gboolean success; gboolean is_normalized; char uuid_normalized[37]; @@ -407,17 +407,17 @@ test_connection_uuid(void) /*****************************************************************************/ static void -test_phase2_private_key_import(const char * path, - const char * password, +test_phase2_private_key_import(const char *path, + const char *password, NMSetting8021xCKScheme scheme) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; NMSetting8021xCKFormat tmp_fmt; - GError * error = NULL; - GBytes * tmp_key = NULL, *client_cert = NULL; - const char * pw; + GError *error = NULL; + GBytes *tmp_key = NULL, *client_cert = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -465,11 +465,11 @@ test_phase2_private_key_import(const char * path, static void test_wrong_password_keeps_data(const char *path, const char *password) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GError * error = NULL; - const char * pw; + GError *error = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -506,11 +506,11 @@ test_wrong_password_keeps_data(const char *path, const char *password) static void test_clear_private_key(const char *path, const char *password) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GError * error = NULL; - const char * pw; + GError *error = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -547,11 +547,11 @@ test_clear_private_key(const char *path, const char *password) static void test_wrong_phase2_password_keeps_data(const char *path, const char *password) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GError * error = NULL; - const char * pw; + GError *error = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -588,11 +588,11 @@ test_wrong_phase2_password_keeps_data(const char *path, const char *password) static void test_clear_phase2_private_key(const char *path, const char *password) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GError * error = NULL; - const char * pw; + GError *error = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -683,8 +683,8 @@ static void _test_verify_options(gboolean expected_result, const char *const *options) { gs_unref_object NMConnection *con = NULL; - NMSettingBond * s_bond; - const char *const * option; + NMSettingBond *s_bond; + const char *const *option; g_assert(NM_PTRARRAY_LEN(options) % 2 == 0); @@ -777,7 +777,7 @@ static void test_bond_compare_options(gboolean exp_res, const char **opts1, const char **opts2) { gs_unref_object NMSettingBond *s_bond1 = NULL, *s_bond2 = NULL; - const char ** p; + const char **p; s_bond1 = (NMSettingBond *) nm_setting_bond_new(); g_assert(s_bond1); @@ -830,10 +830,10 @@ static void test_bond_normalize_options(const char **opts1, const char **opts2) { gs_unref_object NMConnection *con = NULL; - NMSettingBond * s_bond; - GError * error = NULL; + NMSettingBond *s_bond; + GError *error = NULL; gboolean success; - const char ** p; + const char **p; int num = 0; create_bond_connection(&con, &s_bond); @@ -880,7 +880,7 @@ static void test_dummy_normalize(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; connection = nm_simple_connection_new(); s_con = NM_SETTING_CONNECTION(nm_setting_connection_new()); @@ -911,7 +911,7 @@ static void test_dcb_flags_valid(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; guint i; @@ -969,7 +969,7 @@ static void test_dcb_flags_invalid(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -1039,7 +1039,7 @@ static void test_dcb_app_priorities(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -1107,7 +1107,7 @@ static void test_dcb_priorities_valid(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; guint i; @@ -1166,7 +1166,7 @@ static void test_dcb_bandwidth_sums(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -1225,17 +1225,17 @@ _test_team_config_sync(const char *team_config, int notify_peers_interval, int mcast_rejoin_count, int mcast_rejoin_interval, - char * runner, - char * runner_hwaddr_policy, /* activebackup */ - GPtrArray * runner_tx_hash, /* lacp, loadbalance */ - char * runner_tx_balancer, /* lacp, loadbalance */ + char *runner, + char *runner_hwaddr_policy, /* activebackup */ + GPtrArray *runner_tx_hash, /* lacp, loadbalance */ + char *runner_tx_balancer, /* lacp, loadbalance */ int runner_tx_balancer_interval, /* lacp, loadbalance */ gboolean runner_active, /* lacp */ gboolean runner_fast_rate, /* lacp */ int runner_sys_prio, /* lacp */ int runner_min_ports, /* lacp */ - char * runner_agg_select_policy, /* lacp */ - GPtrArray * link_watchers) + char *runner_agg_select_policy, /* lacp */ + GPtrArray *link_watchers) { gs_unref_object NMSettingTeam *s_team = NULL; guint i, j; @@ -1634,7 +1634,7 @@ _test_team_port_config_sync(const char *team_port_config, gboolean sticky, int lacp_prio, int lacp_key, - GPtrArray * link_watchers) + GPtrArray *link_watchers) { gs_unref_object NMSettingTeamPort *s_team_port = NULL; guint i, j; @@ -1812,8 +1812,8 @@ test_team_setting(void) G_VARIANT_TYPE_VARDICT, "{'config': <'{\"link_watch\": {\"name\": \"ethtool\"}}'>, 'interface-name': <'nm-team'>, " "'link-watchers': <[{'name': <'ethtool'>}]>}"); - gs_free_error GError *error = NULL; - gs_unref_object NMSetting * setting = NULL; + gs_free_error GError *error = NULL; + gs_unref_object NMSetting *setting = NULL; nm_auto_unref_team_link_watcher NMTeamLinkWatcher *watcher1 = nm_team_link_watcher_new_nsna_ping(1, 3, 4, "bbb", NULL); nm_auto_unref_team_link_watcher NMTeamLinkWatcher *watcher2 = @@ -1939,16 +1939,16 @@ _setting_ethtool_get_feature(NMSettingEthtool *s_ethtool, const char *opt_name) static void test_ethtool_features(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - gs_unref_object NMConnection *con3 = NULL; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *con3 = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - NMSettingConnection * s_con; - NMSettingEthtool * s_ethtool; - NMSettingEthtool * s_ethtool2; - NMSettingEthtool * s_ethtool3; + NMSettingConnection *s_con; + NMSettingEthtool *s_ethtool; + NMSettingEthtool *s_ethtool2; + NMSettingEthtool *s_ethtool3; con = nmtst_create_minimal_connection("ethtool-1", NULL, NM_SETTING_WIRED_SETTING_NAME, &s_con); s_ethtool = NM_SETTING_ETHTOOL(nm_setting_ethtool_new()); @@ -2024,16 +2024,16 @@ test_ethtool_features(void) static void test_ethtool_coalesce(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - gs_unref_object NMConnection *con3 = NULL; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *con3 = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - NMSettingConnection * s_con; - NMSettingEthtool * s_ethtool; - NMSettingEthtool * s_ethtool2; - NMSettingEthtool * s_ethtool3; + NMSettingConnection *s_con; + NMSettingEthtool *s_ethtool; + NMSettingEthtool *s_ethtool2; + NMSettingEthtool *s_ethtool3; guint32 u32; con = nmtst_create_minimal_connection("ethtool-coalesce", @@ -2120,16 +2120,16 @@ test_ethtool_coalesce(void) static void test_ethtool_ring(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - gs_unref_object NMConnection *con3 = NULL; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *con3 = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - NMSettingConnection * s_con; - NMSettingEthtool * s_ethtool; - NMSettingEthtool * s_ethtool2; - NMSettingEthtool * s_ethtool3; + NMSettingConnection *s_con; + NMSettingEthtool *s_ethtool; + NMSettingEthtool *s_ethtool2; + NMSettingEthtool *s_ethtool3; guint32 out_value; con = nmtst_create_minimal_connection("ethtool-ring", @@ -2214,16 +2214,16 @@ test_ethtool_ring(void) static void test_ethtool_pause(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - gs_unref_object NMConnection *con3 = NULL; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *con3 = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - NMSettingConnection * s_con; - NMSettingEthtool * s_ethtool; - NMSettingEthtool * s_ethtool2; - NMSettingEthtool * s_ethtool3; + NMSettingConnection *s_con; + NMSettingEthtool *s_ethtool; + NMSettingEthtool *s_ethtool2; + NMSettingEthtool *s_ethtool3; gboolean out_value; con = nmtst_create_minimal_connection("ethtool-pause", @@ -2311,8 +2311,8 @@ static void test_sriov_vf(void) { NMSriovVF *vf1, *vf2; - GError * error = NULL; - char * str; + GError *error = NULL; + char *str; vf1 = nm_sriov_vf_new(1); nm_sriov_vf_set_attribute(vf1, @@ -2369,10 +2369,10 @@ test_sriov_vf_dup(void) static void test_sriov_vf_vlan(void) { - NMSriovVF * vf; - const guint * vlan_ids; + NMSriovVF *vf; + const guint *vlan_ids; guint num; - GError * error = NULL; + GError *error = NULL; gs_free char *str = NULL; vf = nm_sriov_vf_new(19); @@ -2430,10 +2430,10 @@ static void test_sriov_setting(void) { gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; - NMSettingSriov * s_sriov = NULL; - NMSriovVF * vf1, *vf2, *vf3; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingSriov *s_sriov = NULL; + NMSriovVF *vf1, *vf2, *vf3; + GError *error = NULL; gboolean success; con = nm_simple_connection_new(); @@ -2491,7 +2491,7 @@ typedef struct { static void _test_sriov_parse_vlan_one(const char *string, gboolean exp_res, VlanData *data, guint data_length) { - NMSriovVF * vf; + NMSriovVF *vf; gboolean res; guint i, num_vlans; const guint *vlan_ids; @@ -2550,9 +2550,9 @@ static void test_bridge_vlans(void) { NMBridgeVlan *v1, *v2; - GError * error = NULL; + GError *error = NULL; guint16 vid_start, vid_end; - char * str; + char *str; v1 = nm_bridge_vlan_from_str("1 foobar", &error); nmtst_assert_no_success(v1, error); @@ -2641,8 +2641,8 @@ static void _test_verify_options_bridge(gboolean expected_result, const char *const *options) { gs_unref_object NMConnection *con = NULL; - NMSettingBridge * s_bridge; - const char *const * option; + NMSettingBridge *s_bridge; + const char *const *option; g_assert(NM_PTRARRAY_LEN(options) % 2 == 0); @@ -2729,9 +2729,9 @@ static void test_tc_config_qdisc(void) { NMTCQdisc *qdisc1, *qdisc2; - char * str; - GError * error = NULL; - GVariant * variant; + char *str; + GError *error = NULL; + GVariant *variant; qdisc1 = nm_tc_qdisc_new("fq_codel", TC_H_ROOT, &error); nmtst_assert_success(qdisc1, error); @@ -2844,8 +2844,8 @@ static void test_tc_config_action(void) { NMTCAction *action1, *action2; - char * str; - GError * error = NULL; + char *str; + GError *error = NULL; action1 = nm_tc_action_new("drop", &error); nmtst_assert_success(action1, error); @@ -2897,10 +2897,10 @@ test_tc_config_action(void) static void test_tc_config_tfilter_matchall_sdata(void) { - NMTCAction * action1; + NMTCAction *action1; NMTCTfilter *tfilter1, *tfilter2; - char * str; - GError * error = NULL; + char *str; + GError *error = NULL; tfilter1 = nm_tc_tfilter_new("matchall", TC_H_MAKE(0x1234u << 16, 0x0000u), &error); nmtst_assert_success(tfilter1, error); @@ -2948,12 +2948,12 @@ test_tc_config_tfilter_matchall_sdata(void) static void test_tc_config_tfilter_matchall_mirred(void) { - NMTCAction * action; - NMTCTfilter * tfilter1; - GError * error = NULL; + NMTCAction *action; + NMTCTfilter *tfilter1; + GError *error = NULL; gs_strfreev char **attr_names = NULL; - gs_free char * str; - GVariant * variant; + gs_free char *str; + GVariant *variant; tfilter1 = nm_utils_tc_tfilter_from_str("parent ffff: matchall action mirred ingress mirror dev eth0", @@ -2995,8 +2995,8 @@ static void test_tc_config_setting_valid(void) { gs_unref_object NMSettingTCConfig *s_tc = NULL; - NMTCQdisc * qdisc1, *qdisc2; - GError * error = NULL; + NMTCQdisc *qdisc1, *qdisc2; + GError *error = NULL; s_tc = (NMSettingTCConfig *) nm_setting_tc_config_new(); @@ -3028,12 +3028,12 @@ test_tc_config_setting_duplicates(void) { gs_unref_ptrarray GPtrArray *qdiscs = NULL; gs_unref_ptrarray GPtrArray *tfilters = NULL; - NMSettingConnection * s_con; - NMConnection * con; - NMSetting * s_tc; - NMTCQdisc * qdisc; - NMTCTfilter * tfilter; - GError * error = NULL; + NMSettingConnection *s_con; + NMConnection *con; + NMSetting *s_tc; + NMTCQdisc *qdisc; + NMTCTfilter *tfilter; + GError *error = NULL; con = nmtst_create_minimal_connection("dummy", NULL, NM_SETTING_DUMMY_SETTING_NAME, &s_con); g_object_set(s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, "dummy1", NULL); @@ -3088,12 +3088,12 @@ static void test_tc_config_dbus(void) { NMConnection *connection1, *connection2; - NMSetting * s_tc; - NMTCQdisc * qdisc1, *qdisc2; - NMTCTfilter * tfilter1, *tfilter2; - NMTCAction * action; - GVariant * dbus, *tc_dbus, *var1, *var2; - GError * error = NULL; + NMSetting *s_tc; + NMTCQdisc *qdisc1, *qdisc2; + NMTCTfilter *tfilter1, *tfilter2; + NMTCAction *action; + GVariant *dbus, *tc_dbus, *var1, *var2; + GError *error = NULL; gboolean success; connection1 = @@ -3183,13 +3183,13 @@ test_tc_config_dbus(void) static void _rndt_wired_add_s390_options(NMSettingWired *s_wired, char **out_keyfile_entries) { - gsize n_opts; - gsize i, j; - const char *const * option_names; - gs_free const char **opt_keys = NULL; - gs_strfreev char ** opt_vals = NULL; - gs_free bool * opt_found = NULL; - GString * keyfile_entries; + gsize n_opts; + gsize i, j; + const char *const *option_names; + gs_free const char **opt_keys = NULL; + gs_strfreev char **opt_vals = NULL; + gs_free bool *opt_found = NULL; + GString *keyfile_entries; nm_auto_free_gstring GString *str_tmp = NULL; option_names = nm_setting_wired_get_valid_s390_options(nmtst_get_rand_bool() ? NULL : s_wired); @@ -3288,9 +3288,9 @@ _rndt_wg_peers_create(void) NMWireGuardPeer *peer; guint8 public_key_buf[NM_WIREGUARD_PUBLIC_KEY_LEN]; guint8 preshared_key_buf[NM_WIREGUARD_SYMMETRIC_KEY_LEN]; - gs_free char * public_key = NULL; - gs_free char * preshared_key = NULL; - gs_free char * s_endpoint = NULL; + gs_free char *public_key = NULL; + gs_free char *preshared_key = NULL; + gs_free char *s_endpoint = NULL; guint i_aip, n_aip; /* we don't bother to create a valid curve25519 public key. Of course, libnm cannot @@ -3358,11 +3358,11 @@ _rndt_wg_peers_to_keyfile(GPtrArray *wg_peers, gboolean strict, char **out_str) nm_gstring_prepare(&gstr); for (i = 0; i < wg_peers->len; i++) { const NMWireGuardPeer *peer = wg_peers->pdata[i]; - gs_free char * s_endpoint = NULL; - gs_free char * s_preshared_key = NULL; - gs_free char * s_preshared_key_flags = NULL; - gs_free char * s_persistent_keepalive = NULL; - gs_free char * s_allowed_ips = NULL; + gs_free char *s_endpoint = NULL; + gs_free char *s_preshared_key = NULL; + gs_free char *s_preshared_key_flags = NULL; + gs_free char *s_persistent_keepalive = NULL; + gs_free char *s_allowed_ips = NULL; if (nm_wireguard_peer_get_endpoint(peer)) s_endpoint = g_strdup_printf("endpoint=%s\n", nm_wireguard_peer_get_endpoint(peer)); @@ -3421,7 +3421,7 @@ _rndt_wg_peers_to_keyfile(GPtrArray *wg_peers, gboolean strict, char **out_str) static void _rndt_wg_peers_assert_equal(NMSettingWireGuard *s_wg, - GPtrArray * peers, + GPtrArray *peers, gboolean consider_persistent_secrets, gboolean consider_all_secrets, gboolean expect_no_secrets) @@ -3476,8 +3476,8 @@ _rndt_wg_peers_fix_secrets(NMSettingWireGuard *s_wg, GPtrArray *peers) g_assert_cmpint(peers->len, ==, nm_setting_wireguard_get_peers_len(s_wg)); for (i = 0; i < peers->len; i++) { - const NMWireGuardPeer *a = peers->pdata[i]; - const NMWireGuardPeer *b = nm_setting_wireguard_get_peer(s_wg, i); + const NMWireGuardPeer *a = peers->pdata[i]; + const NMWireGuardPeer *b = nm_setting_wireguard_get_peer(s_wg, i); nm_auto_unref_wgpeer NMWireGuardPeer *b_clone = NULL; g_assert(a); @@ -3538,23 +3538,23 @@ test_roundtrip_conversion(gconstpointer test_data) nmtst_rand_select(NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_SECRET_FLAG_NOT_SAVED, NM_SETTING_SECRET_FLAG_AGENT_OWNED); - const guint WG_LISTEN_PORT = nmtst_rand_select(0u, nmtst_get_rand_uint32() % 0x10000); - const guint WG_FWMARK = nmtst_rand_select(0u, nmtst_get_rand_uint32()); - gs_unref_ptrarray GPtrArray *kf_data_arr = g_ptr_array_new_with_free_func(g_free); - gs_unref_ptrarray GPtrArray * wg_peers = NULL; + const guint WG_LISTEN_PORT = nmtst_rand_select(0u, nmtst_get_rand_uint32() % 0x10000); + const guint WG_FWMARK = nmtst_rand_select(0u, nmtst_get_rand_uint32()); + gs_unref_ptrarray GPtrArray *kf_data_arr = g_ptr_array_new_with_free_func(g_free); + gs_unref_ptrarray GPtrArray *wg_peers = NULL; const NMConnectionSerializationFlags dbus_serialization_flags[] = { NM_CONNECTION_SERIALIZE_ALL, NM_CONNECTION_SERIALIZE_WITH_NON_SECRET, NM_CONNECTION_SERIALIZE_WITH_SECRETS, }; - guint dbus_serialization_flags_idx; - gs_unref_object NMConnection *con = NULL; - gs_free_error GError *error = NULL; - gs_free char * tmp_str = NULL; - guint kf_data_idx; - NMSettingConnection * s_con = NULL; - NMSettingWired * s_eth = NULL; - NMSettingWireGuard * s_wg = NULL; + guint dbus_serialization_flags_idx; + gs_unref_object NMConnection *con = NULL; + gs_free_error GError *error = NULL; + gs_free char *tmp_str = NULL; + guint kf_data_idx; + NMSettingConnection *s_con = NULL; + NMSettingWired *s_eth = NULL; + NMSettingWireGuard *s_wg = NULL; union { struct { NMSettingIPConfig *s_6; @@ -3849,8 +3849,8 @@ test_roundtrip_conversion(gconstpointer test_data) /* check that reading any of kf_data_arr yields the same result that we expect. */ for (kf_data_idx = 0; kf_data_idx < kf_data_arr->len; kf_data_idx++) { gs_unref_object NMConnection *con2 = NULL; - NMSettingWireGuard * s_wg2 = NULL; - NMSettingWired * s_eth2 = NULL; + NMSettingWireGuard *s_wg2 = NULL; + NMSettingWired *s_eth2 = NULL; con2 = nmtst_create_connection_from_keyfile(kf_data_arr->pdata[kf_data_idx], "/no/where/file.nmconnection"); @@ -3918,9 +3918,9 @@ test_roundtrip_conversion(gconstpointer test_data) dbus_serialization_flags_idx++) { NMConnectionSerializationFlags flag = dbus_serialization_flags[dbus_serialization_flags_idx]; - gs_unref_variant GVariant *con_var = NULL; - gs_unref_object NMConnection *con2 = NULL; - NMSettingWireGuard * s_wg2 = NULL; + gs_unref_variant GVariant *con_var = NULL; + gs_unref_object NMConnection *con2 = NULL; + NMSettingWireGuard *s_wg2 = NULL; con_var = nm_connection_to_dbus(con, flag); g_assert(g_variant_is_of_type(con_var, NM_VARIANT_TYPE_CONNECTION)); @@ -3963,12 +3963,12 @@ test_roundtrip_conversion(gconstpointer test_data) static NMIPRoutingRule * _rr_from_str_get_impl(const char *str, const char *const *aliases) { - nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr = NULL; - gs_free_error GError * error = NULL; - gboolean vbool; - int addr_family; - int i; - NMIPRoutingRuleAsStringFlags to_string_flags; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr = NULL; + gs_free_error GError *error = NULL; + gboolean vbool; + int addr_family; + int i; + NMIPRoutingRuleAsStringFlags to_string_flags; rr = nm_ip_routing_rule_from_string(str, NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE, @@ -3985,10 +3985,10 @@ _rr_from_str_get_impl(const char *str, const char *const *aliases) to_string_flags = NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET6; for (i = 0; TRUE; i++) { - nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr2 = NULL; - gs_free char * str1 = NULL; - gs_unref_variant GVariant *variant1 = NULL; - const char * cstr1; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr2 = NULL; + gs_free char *str1 = NULL; + gs_unref_variant GVariant *variant1 = NULL; + const char *cstr1; switch (i) { case 0: @@ -4084,7 +4084,7 @@ test_routing_rule(gconstpointer test_data) nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr1 = NULL; gboolean success; char ifname_buf[16]; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; _rr_from_str("priority 5 from 0.0.0.0 table 1", " from 0.0.0.0 priority 5 lookup 1 "); _rr_from_str("priority 5 from 0.0.0.0/0 table 4"); @@ -4190,7 +4190,7 @@ test_parse_tc_handle(void) G_STMT_START \ { \ gs_free_error GError *_error = NULL; \ - GError ** _perror = nmtst_get_rand_bool() ? &_error : NULL; \ + GError **_perror = nmtst_get_rand_bool() ? &_error : NULL; \ guint32 _v; \ const guint32 _v_exp = (exp); \ \ @@ -4247,12 +4247,12 @@ test_parse_tc_handle(void) static void test_empty_setting(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - NMSettingBluetooth * s_bt; - NMSettingGsm * s_gsm; - nm_auto_unref_keyfile GKeyFile *kf = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + NMSettingBluetooth *s_bt; + NMSettingGsm *s_gsm; + nm_auto_unref_keyfile GKeyFile *kf = NULL; + gs_free_error GError *error = NULL; con = nmtst_create_minimal_connection("bt-empty-gsm", "dca3192a-f2dc-48eb-b806-d0ff788f122c", @@ -4307,7 +4307,7 @@ _PROP_IDX_OWNER(GHashTable *h_property_types, const NMSettInfoPropertType *prope const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings(); const NMSettInfoSetting *sis; const NMMetaSettingInfo *msi; - GArray * arr; + GArray *arr; guint idx; NMMetaSettingType meta_type; guint prop_idx; @@ -4341,8 +4341,8 @@ _PROP_IDX_OWNER(GHashTable *h_property_types, const NMSettInfoPropertType *prope static void test_setting_metadata(void) { - const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings(); - NMMetaSettingType meta_type; + const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings(); + NMMetaSettingType meta_type; gs_unref_hashtable GHashTable *h_property_types = NULL; G_STATIC_ASSERT(_NM_META_SETTING_TYPE_NUM == NM_META_SETTING_TYPE_UNKNOWN); @@ -4351,7 +4351,7 @@ test_setting_metadata(void) g_hash_table_new_full(nm_direct_hash, NULL, NULL, (GDestroyNotify) g_array_unref); for (meta_type = 0; meta_type < _NM_META_SETTING_TYPE_NUM; meta_type++) { - const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; + const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; nm_auto_unref_gtypeclass NMSettingClass *klass = NULL; GType gtype; @@ -4382,17 +4382,17 @@ test_setting_metadata(void) g_assert(sett_info_settings); for (meta_type = 0; meta_type < _NM_META_SETTING_TYPE_NUM; meta_type++) { - const NMSettInfoSetting *sis = &sett_info_settings[meta_type]; - const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; + const NMSettInfoSetting *sis = &sett_info_settings[meta_type]; + const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; gs_unref_hashtable GHashTable *h_properties = NULL; GType gtype; - gs_unref_object NMSetting *setting = NULL; - guint prop_idx; - gs_free GParamSpec **property_specs = NULL; - guint n_property_specs; - guint n_param_spec; - guint i; - guint j; + gs_unref_object NMSetting *setting = NULL; + guint prop_idx; + gs_free GParamSpec **property_specs = NULL; + guint n_property_specs; + guint n_param_spec; + guint i; + guint j; g_assert(sis); @@ -4427,7 +4427,7 @@ test_setting_metadata(void) for (prop_idx = 0; prop_idx < sis->property_infos_len; prop_idx++) { const NMSettInfoProperty *sip = &sis->property_infos[prop_idx]; - GArray * property_types_data; + GArray *property_types_data; guint prop_idx_val; gboolean can_set_including_default = FALSE; @@ -4892,7 +4892,7 @@ static void test_setting_connection_secondaries_verify(void) { gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; guint i_run; guint i_word; @@ -4900,7 +4900,7 @@ test_setting_connection_secondaries_verify(void) nmtst_connection_normalize(con); for (i_run = 0; i_run < 100; i_run++) { - guint word_len = nmtst_get_rand_word_length(NULL); + guint word_len = nmtst_get_rand_word_length(NULL); gs_unref_ptrarray GPtrArray *arr = NULL; gs_unref_ptrarray GPtrArray *arr_norm = NULL; gboolean was_normalized; @@ -4930,10 +4930,10 @@ test_setting_connection_secondaries_verify(void) G_STMT_START \ { \ NMSettingConnection *const _s_con = (s_con); \ - const char *const * _expected = (expected); \ - GArray * _secondaries; \ + const char *const *_expected = (expected); \ + GArray *_secondaries; \ const guint _expected_len = NM_PTRARRAY_LEN(_expected); \ - gs_strfreev char ** _sec_strv = NULL; \ + gs_strfreev char **_sec_strv = NULL; \ guint _i; \ \ g_assert(_expected); \ @@ -5011,8 +5011,8 @@ static void test_6lowpan_1(void) { gs_unref_object NMConnection *con = NULL; - NMSetting6Lowpan * s_6low; - gs_free char * value = NULL; + NMSetting6Lowpan *s_6low; + gs_free char *value = NULL; con = nmtst_create_minimal_connection("test-sec", NULL, NM_SETTING_6LOWPAN_SETTING_NAME, NULL); diff --git a/src/libnm-core-impl/tests/test-settings-defaults.c b/src/libnm-core-impl/tests/test-settings-defaults.c index b9db71074a..ade28c53b8 100644 --- a/src/libnm-core-impl/tests/test-settings-defaults.c +++ b/src/libnm-core-impl/tests/test-settings-defaults.c @@ -27,7 +27,7 @@ test_defaults(GType type, const char *name) { GParamSpec **property_specs; guint n_property_specs; - GObject * setting; + GObject *setting; int i; setting = g_object_new(type, NULL); @@ -39,7 +39,7 @@ test_defaults(GType type, const char *name) GParamSpec *prop_spec = property_specs[i]; GValue value = G_VALUE_INIT; GValue defvalue = G_VALUE_INIT; - char * actual, *expected; + char *actual, *expected; gboolean ok = FALSE; /* Ignore non-fundamental types since they won't really have diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index 93d75e442d..4b9213ce4c 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -199,14 +199,14 @@ typedef enum { /*< skip >*/ NM_SETTING_PARSE_FLAGS_ALL = ((_NM_SETTING_PARSE_FLAGS_LAST - 1) << 1) - 1, } NMSettingParseFlags; -gboolean _nm_connection_replace_settings(NMConnection * connection, - GVariant * new_settings, +gboolean _nm_connection_replace_settings(NMConnection *connection, + GVariant *new_settings, NMSettingParseFlags parse_flags, - GError ** error); + GError **error); gpointer _nm_connection_check_main_setting(NMConnection *connection, - const char * setting_name, - GError ** error); + const char *setting_name, + GError **error); typedef struct { struct { @@ -221,7 +221,7 @@ typedef struct { gboolean nm_connection_serialization_options_equal(const NMConnectionSerializationOptions *a, const NMConnectionSerializationOptions *b); -GVariant *nm_connection_to_dbus_full(NMConnection * connection, +GVariant *nm_connection_to_dbus_full(NMConnection *connection, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options); @@ -262,12 +262,12 @@ typedef enum { NMSettingVerifyResult _nm_connection_verify(NMConnection *connection, GError **error); -gboolean _nm_connection_ensure_normalized(NMConnection * connection, +gboolean _nm_connection_ensure_normalized(NMConnection *connection, gboolean allow_modify, - const char * expected_uuid, + const char *expected_uuid, gboolean coerce_uuid, NMConnection **out_connection_clone, - GError ** error); + GError **error); gboolean _nm_connection_remove_setting(NMConnection *connection, GType setting_type); @@ -280,9 +280,9 @@ nm_assert_connection_unchanging(NMConnection *connection) {} #endif -NMConnection *_nm_simple_connection_new_from_dbus(GVariant * dict, +NMConnection *_nm_simple_connection_new_from_dbus(GVariant *dict, NMSettingParseFlags parse_flags, - GError ** error); + GError **error); NMSettingPriority _nm_setting_get_setting_priority(NMSetting *setting); @@ -294,9 +294,9 @@ GHashTable *_nm_setting_option_hash(NMSetting *setting, gboolean create_if_neces void _nm_setting_option_notify(NMSetting *setting, gboolean keys_changed); -guint _nm_setting_option_get_all(NMSetting * setting, +guint _nm_setting_option_get_all(NMSetting *setting, const char *const **out_names, - GVariant *const ** out_values); + GVariant *const **out_values); gboolean _nm_setting_option_clear(NMSetting *setting, const char *optname); @@ -304,7 +304,7 @@ gboolean _nm_setting_option_clear(NMSetting *setting, const char *optname); guint nm_setting_ethtool_init_features( NMSettingEthtool *setting, - NMOptionBool * requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */); + NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */); /*****************************************************************************/ @@ -335,7 +335,7 @@ GHashTable *_nm_ip_route_get_attributes(NMIPRoute *route); NMSriovVF *_nm_utils_sriov_vf_from_strparts(const char *index, const char *detail, gboolean ignore_unknown, - GError ** error); + GError **error); gboolean _nm_sriov_vf_attribute_validate_all(const NMSriovVF *vf, GError **error); GPtrArray * @@ -343,23 +343,23 @@ _nm_utils_copy_array(const GPtrArray *array, NMUtilsCopyFunc copy_func, GDestroy GPtrArray *_nm_utils_copy_object_array(const GPtrArray *array); GSList *nm_strv_to_gslist(char **strv, gboolean deep_copy); -char ** _nm_utils_slist_to_strv(const GSList *slist, gboolean deep_copy); +char **_nm_utils_slist_to_strv(const GSList *slist, gboolean deep_copy); GPtrArray *nm_strv_to_ptrarray(char **strv); -char ** _nm_utils_ptrarray_to_strv(const GPtrArray *ptrarray); +char **_nm_utils_ptrarray_to_strv(const GPtrArray *ptrarray); -gboolean _nm_utils_check_file(const char * filename, +gboolean _nm_utils_check_file(const char *filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - struct stat * out_st, - GError ** error); + struct stat *out_st, + GError **error); -gboolean _nm_utils_check_module_file(const char * name, +gboolean _nm_utils_check_module_file(const char *name, int check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error); + GError **error); /*****************************************************************************/ @@ -370,8 +370,8 @@ extern gboolean _nm_utils_is_manager_process; gboolean _nm_dbus_typecheck_response(GVariant *response, const GVariantType *reply_type, GError **error); -gulong _nm_dbus_signal_connect_data(GDBusProxy * proxy, - const char * signal_name, +gulong _nm_dbus_signal_connect_data(GDBusProxy *proxy, + const char *signal_name, const GVariantType *signature, GCallback c_handler, gpointer data, @@ -380,15 +380,15 @@ gulong _nm_dbus_signal_connect_data(GDBusProxy * proxy, #define _nm_dbus_signal_connect(proxy, name, signature, handler, data) \ _nm_dbus_signal_connect_data(proxy, name, signature, handler, data, NULL, (GConnectFlags) 0) -GVariant *_nm_dbus_proxy_call_finish(GDBusProxy * proxy, - GAsyncResult * res, +GVariant *_nm_dbus_proxy_call_finish(GDBusProxy *proxy, + GAsyncResult *res, const GVariantType *reply_type, - GError ** error); + GError **error); -GVariant *_nm_dbus_connection_call_finish(GDBusConnection * dbus_connection, - GAsyncResult * result, +GVariant *_nm_dbus_connection_call_finish(GDBusConnection *dbus_connection, + GAsyncResult *result, const GVariantType *reply_type, - GError ** error); + GError **error); gboolean _nm_dbus_error_has_name(GError *error, const char *dbus_error_name); @@ -398,19 +398,19 @@ char *_nm_utils_ssid_to_utf8(GBytes *ssid); /*****************************************************************************/ -gboolean _nm_vpn_plugin_info_check_file(const char * filename, +gboolean _nm_vpn_plugin_info_check_file(const char *filename, gboolean check_absolute, gboolean do_validate_filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error); + GError **error); const char *_nm_vpn_plugin_info_get_default_dir_etc(void); const char *_nm_vpn_plugin_info_get_default_dir_lib(void); const char *_nm_vpn_plugin_info_get_default_dir_user(void); -GSList *_nm_vpn_plugin_info_list_load_dir(const char * dirname, +GSList *_nm_vpn_plugin_info_list_load_dir(const char *dirname, gboolean do_validate_filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, @@ -430,9 +430,9 @@ typedef struct { extern const NMUtilsDNSOptionDesc _nm_utils_dns_option_descs[]; -gboolean _nm_utils_dns_option_validate(const char * option, - char ** out_name, - long * out_value, +gboolean _nm_utils_dns_option_validate(const char *option, + char **out_name, + long *out_value, gboolean ipv6, const NMUtilsDNSOptionDesc *option_descs); gssize _nm_utils_dns_option_find_idx(GPtrArray *array, const char *option); @@ -450,24 +450,24 @@ NMUtilsStrStrDictKey *_nm_utils_strstrdictkey_create(const char *v1, const char /*****************************************************************************/ -gboolean _nm_setting_vlan_set_priorities(NMSettingVlan * setting, +gboolean _nm_setting_vlan_set_priorities(NMSettingVlan *setting, NMVlanPriorityMap map, const NMVlanQosMapping *qos_map, guint n_qos_map); -void _nm_setting_vlan_get_priorities(NMSettingVlan * setting, +void _nm_setting_vlan_get_priorities(NMSettingVlan *setting, NMVlanPriorityMap map, NMVlanQosMapping **out_qos_map, - guint * out_n_qos_map); + guint *out_n_qos_map); /*****************************************************************************/ struct ether_addr; -gboolean _nm_utils_generate_mac_address_mask_parse(const char * value, - struct ether_addr * out_mask, +gboolean _nm_utils_generate_mac_address_mask_parse(const char *value, + struct ether_addr *out_mask, struct ether_addr **out_ouis, - gsize * out_ouis_len, - GError ** error); + gsize *out_ouis_len, + GError **error); /*****************************************************************************/ @@ -645,7 +645,7 @@ gboolean nm_ip_routing_rule_get_xifname_bin(const NMIPRoutingRule *self, #define NM_IP_ROUTING_RULE_ATTR_UID_RANGE_END "uid-range-end" NMIPRoutingRule *nm_ip_routing_rule_from_dbus(GVariant *variant, gboolean strict, GError **error); -GVariant * nm_ip_routing_rule_to_dbus(const NMIPRoutingRule *self); +GVariant *nm_ip_routing_rule_to_dbus(const NMIPRoutingRule *self); /*****************************************************************************/ @@ -787,8 +787,8 @@ typedef struct { typedef struct { const GVariantType *(*get_variant_type)(const struct _NMSettInfoSetting *sett_info, - const char * name, - GError ** error); + const char *name, + GError **error); } NMSettInfoSettGendata; typedef struct { @@ -861,7 +861,7 @@ _nm_sett_info_property_info_get_sorted(const NMSettInfoSetting *sett_info, guint const NMSettInfoProperty * _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info, - const char * property_name); + const char *property_name); const NMSettInfoSetting *_nm_setting_class_get_sett_info(NMSettingClass *setting_class); @@ -874,26 +874,26 @@ _nm_setting_class_get_property_info(NMSettingClass *setting_class, const char *p /*****************************************************************************/ -gboolean _nm_setting_compare(NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, +gboolean _nm_setting_compare(NMConnection *con_a, + NMSetting *set_a, + NMConnection *con_b, + NMSetting *set_b, NMSettingCompareFlags flags); -gboolean _nm_setting_diff(NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, +gboolean _nm_setting_diff(NMConnection *con_a, + NMSetting *set_a, + NMConnection *con_b, + NMSetting *set_b, NMSettingCompareFlags flags, gboolean invert_results, - GHashTable ** results); + GHashTable **results); NMSetting8021xCKScheme _nm_setting_802_1x_cert_get_scheme(GBytes *bytes, GError **error); GBytes *_nm_setting_802_1x_cert_value_to_bytes(NMSetting8021xCKScheme scheme, - const guint8 * val_bin, + const guint8 *val_bin, gssize val_len, - GError ** error); + GError **error); /*****************************************************************************/ @@ -936,19 +936,19 @@ _nm_connection_serialize_secrets(NMConnectionSerializationFlags flags, return FALSE; } -void _nm_connection_clear_secrets_by_secret_flags(NMConnection * self, +void _nm_connection_clear_secrets_by_secret_flags(NMConnection *self, NMSettingSecretFlags filter_flags); -GVariant *_nm_connection_for_each_secret(NMConnection * self, - GVariant * secrets, +GVariant *_nm_connection_for_each_secret(NMConnection *self, + GVariant *secrets, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data); typedef gboolean (*NMConnectionFindSecretFunc)(NMSettingSecretFlags flags, gpointer user_data); -gboolean _nm_connection_find_secret(NMConnection * self, - GVariant * secrets, +gboolean _nm_connection_find_secret(NMConnection *self, + GVariant *secrets, NMConnectionFindSecretFunc callback, gpointer callback_data); @@ -956,7 +956,7 @@ gboolean _nm_connection_find_secret(NMConnection * self, gboolean nm_utils_base64secret_normalize(const char *base64_key, gsize required_key_len, - char ** out_base64_key_norm); + char **out_base64_key_norm); /*****************************************************************************/ @@ -977,7 +977,7 @@ gboolean _nmtst_variant_attribute_spec_assert_sorted(const NMVariantAttributeSpe const NMVariantAttributeSpec * _nm_variant_attribute_spec_find_binary_search(const NMVariantAttributeSpec *const *array, gsize len, - const char * name); + const char *name); /*****************************************************************************/ diff --git a/src/libnm-core-intern/nm-keyfile-internal.h b/src/libnm-core-intern/nm-keyfile-internal.h index d3fd77d240..ecbcedb2ad 100644 --- a/src/libnm-core-intern/nm-keyfile-internal.h +++ b/src/libnm-core-intern/nm-keyfile-internal.h @@ -26,11 +26,11 @@ #define NM_KEYFILE_CERT_SCHEME_PREFIX_PKCS11 "pkcs11:" #define NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB "data:;base64," -char *nm_keyfile_detect_unqualified_path_scheme(const char * base_dir, +char *nm_keyfile_detect_unqualified_path_scheme(const char *base_dir, gconstpointer pdata, gsize data_len, gboolean consider_exists, - gboolean * out_exists); + gboolean *out_exists); gboolean nm_keyfile_read_ensure_id(NMConnection *connection, const char *fallback_id); @@ -46,8 +46,8 @@ gboolean nm_keyfile_read_ensure_uuid(NMConnection *connection, const char *fallb */ typedef struct { NMKeyfileWarnSeverity severity; - char * message; - const char * fmt; + char *message; + const char *fmt; va_list ap; } NMKeyfileHandlerDataWarn; @@ -69,7 +69,7 @@ struct _NMKeyfileHandlerData { const char *kf_group_name; const char *kf_key; - NMSetting * cur_setting; + NMSetting *cur_setting; const char *cur_property; union { @@ -86,7 +86,7 @@ const char *_nm_keyfile_handler_data_warn_get_message(const NMKeyfileHandlerData char * nm_keyfile_plugin_kf_get_string(GKeyFile *kf, const char *group, const char *key, GError **error); -void nm_keyfile_plugin_kf_set_string(GKeyFile * kf, +void nm_keyfile_plugin_kf_set_string(GKeyFile *kf, const char *group, const char *key, const char *value); diff --git a/src/libnm-core-intern/nm-keyfile-utils.h b/src/libnm-core-intern/nm-keyfile-utils.h index 4dde70295e..45741646b7 100644 --- a/src/libnm-core-intern/nm-keyfile-utils.h +++ b/src/libnm-core-intern/nm-keyfile-utils.h @@ -31,16 +31,16 @@ const char *nm_keyfile_plugin_get_setting_name_for_alias(const char *alias); /*****************************************************************************/ -guint *nm_keyfile_plugin_kf_get_integer_list_uint(GKeyFile * kf, +guint *nm_keyfile_plugin_kf_get_integer_list_uint(GKeyFile *kf, const char *group, const char *key, - gsize * out_length, - GError ** error); -char **nm_keyfile_plugin_kf_get_string_list(GKeyFile * kf, + gsize *out_length, + GError **error); +char **nm_keyfile_plugin_kf_get_string_list(GKeyFile *kf, const char *group, const char *key, - gsize * out_length, - GError ** error); + gsize *out_length, + GError **error); char * nm_keyfile_plugin_kf_get_string(GKeyFile *kf, const char *group, const char *key, GError **error); gboolean @@ -48,23 +48,23 @@ nm_keyfile_plugin_kf_get_boolean(GKeyFile *kf, const char *group, const char *ke char * nm_keyfile_plugin_kf_get_value(GKeyFile *kf, const char *group, const char *key, GError **error); -void nm_keyfile_plugin_kf_set_integer_list_uint8(GKeyFile * kf, - const char * group, - const char * key, +void nm_keyfile_plugin_kf_set_integer_list_uint8(GKeyFile *kf, + const char *group, + const char *key, const guint8 *list, gsize length); -void nm_keyfile_plugin_kf_set_integer_list_uint(GKeyFile * kf, - const char * group, - const char * key, +void nm_keyfile_plugin_kf_set_integer_list_uint(GKeyFile *kf, + const char *group, + const char *key, const guint *list, gsize length); -void nm_keyfile_plugin_kf_set_string_list(GKeyFile * kf, - const char * group, - const char * key, +void nm_keyfile_plugin_kf_set_string_list(GKeyFile *kf, + const char *group, + const char *key, const char *const *list, gsize length); -void nm_keyfile_plugin_kf_set_string(GKeyFile * kf, +void nm_keyfile_plugin_kf_set_string(GKeyFile *kf, const char *group, const char *key, const char *value); @@ -73,14 +73,14 @@ nm_keyfile_plugin_kf_set_boolean(GKeyFile *kf, const char *group, const char *ke void nm_keyfile_plugin_kf_set_value(GKeyFile *kf, const char *group, const char *key, const char *value); -gint64 nm_keyfile_plugin_kf_get_int64(GKeyFile * kf, +gint64 nm_keyfile_plugin_kf_get_int64(GKeyFile *kf, const char *group, const char *key, guint base, gint64 min, gint64 max, gint64 fallback, - GError ** error); + GError **error); char ** nm_keyfile_plugin_kf_get_keys(GKeyFile *kf, const char *group, gsize *out_length, GError **error); diff --git a/src/libnm-core-intern/nm-meta-setting-base-impl.h b/src/libnm-core-intern/nm-meta-setting-base-impl.h index eba1fb96f4..ea4f85ff1b 100644 --- a/src/libnm-core-intern/nm-meta-setting-base-impl.h +++ b/src/libnm-core-intern/nm-meta-setting-base-impl.h @@ -73,18 +73,18 @@ typedef struct { const char *(*uri_func)(NMSetting8021x *setting); const char *(*passwd_func)(NMSetting8021x *setting); NMSettingSecretFlags (*pwflag_func)(NMSetting8021x *setting); - gboolean (*set_cert_func)(NMSetting8021x * setting, - const char * value, + gboolean (*set_cert_func)(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); - gboolean (*set_private_key_func)(NMSetting8021x * setting, - const char * value, - const char * password, + GError **error); + gboolean (*set_private_key_func)(NMSetting8021x *setting, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); - const char * file_suffix; + GError **error); + const char *file_suffix; NMSetting8021xSchemeType scheme_type; bool is_secret : 1; } NMSetting8021xSchemeVtable; diff --git a/src/libnm-core-public/nm-connection.h b/src/libnm-core-public/nm-connection.h index fb54ce88ed..081f115e80 100644 --- a/src/libnm-core-public/nm-connection.h +++ b/src/libnm-core-public/nm-connection.h @@ -145,31 +145,31 @@ void nm_connection_clear_settings(NMConnection *connection); gboolean nm_connection_compare(NMConnection *a, NMConnection *b, NMSettingCompareFlags flags); -gboolean nm_connection_diff(NMConnection * a, - NMConnection * b, +gboolean nm_connection_diff(NMConnection *a, + NMConnection *b, NMSettingCompareFlags flags, - GHashTable ** out_settings); + GHashTable **out_settings); gboolean nm_connection_verify(NMConnection *connection, GError **error); NM_AVAILABLE_IN_1_2 gboolean nm_connection_verify_secrets(NMConnection *connection, GError **error); gboolean nm_connection_normalize(NMConnection *connection, - GHashTable * parameters, - gboolean * modified, - GError ** error); + GHashTable *parameters, + gboolean *modified, + GError **error); const char *nm_connection_need_secrets(NMConnection *connection, GPtrArray **hints); void nm_connection_clear_secrets(NMConnection *connection); -void nm_connection_clear_secrets_with_flags(NMConnection * connection, +void nm_connection_clear_secrets_with_flags(NMConnection *connection, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); gboolean nm_connection_update_secrets(NMConnection *connection, - const char * setting_name, - GVariant * secrets, - GError ** error); + const char *setting_name, + GVariant *secrets, + GError **error); void nm_connection_set_path(NMConnection *connection, const char *path); @@ -179,7 +179,7 @@ const char *nm_connection_get_interface_name(NMConnection *connection); gboolean nm_connection_is_type(NMConnection *connection, const char *type); -void nm_connection_for_each_setting_value(NMConnection * connection, +void nm_connection_for_each_setting_value(NMConnection *connection, NMSettingValueIterFn func, gpointer user_data); @@ -194,22 +194,22 @@ const char *nm_connection_get_id(NMConnection *connection); const char *nm_connection_get_connection_type(NMConnection *connection); gboolean nm_connection_is_virtual(NMConnection *connection); -char * nm_connection_get_virtual_device_description(NMConnection *connection); +char *nm_connection_get_virtual_device_description(NMConnection *connection); -NMSetting8021x * nm_connection_get_setting_802_1x(NMConnection *connection); -NMSettingBluetooth * nm_connection_get_setting_bluetooth(NMConnection *connection); -NMSettingBond * nm_connection_get_setting_bond(NMConnection *connection); -NMSettingTeam * nm_connection_get_setting_team(NMConnection *connection); -NMSettingTeamPort * nm_connection_get_setting_team_port(NMConnection *connection); -NMSettingBridge * nm_connection_get_setting_bridge(NMConnection *connection); +NMSetting8021x *nm_connection_get_setting_802_1x(NMConnection *connection); +NMSettingBluetooth *nm_connection_get_setting_bluetooth(NMConnection *connection); +NMSettingBond *nm_connection_get_setting_bond(NMConnection *connection); +NMSettingTeam *nm_connection_get_setting_team(NMConnection *connection); +NMSettingTeamPort *nm_connection_get_setting_team_port(NMConnection *connection); +NMSettingBridge *nm_connection_get_setting_bridge(NMConnection *connection); NMSettingBridgePort *nm_connection_get_setting_bridge_port(NMConnection *connection); -NMSettingCdma * nm_connection_get_setting_cdma(NMConnection *connection); +NMSettingCdma *nm_connection_get_setting_cdma(NMConnection *connection); NMSettingConnection *nm_connection_get_setting_connection(NMConnection *connection); -NMSettingDcb * nm_connection_get_setting_dcb(NMConnection *connection); +NMSettingDcb *nm_connection_get_setting_dcb(NMConnection *connection); NM_AVAILABLE_IN_1_8 -NMSettingDummy * nm_connection_get_setting_dummy(NMConnection *connection); -NMSettingGeneric * nm_connection_get_setting_generic(NMConnection *connection); -NMSettingGsm * nm_connection_get_setting_gsm(NMConnection *connection); +NMSettingDummy *nm_connection_get_setting_dummy(NMConnection *connection); +NMSettingGeneric *nm_connection_get_setting_generic(NMConnection *connection); +NMSettingGsm *nm_connection_get_setting_gsm(NMConnection *connection); NMSettingInfiniband *nm_connection_get_setting_infiniband(NMConnection *connection); NM_AVAILABLE_IN_1_2 NMSettingIPTunnel *nm_connection_get_setting_ip_tunnel(NMConnection *connection); @@ -218,31 +218,31 @@ NMSettingIPConfig *nm_connection_get_setting_ip6_config(NMConnection *connection NM_AVAILABLE_IN_1_6 NMSettingMacsec *nm_connection_get_setting_macsec(NMConnection *connection); NM_AVAILABLE_IN_1_2 -NMSettingMacvlan * nm_connection_get_setting_macvlan(NMConnection *connection); +NMSettingMacvlan *nm_connection_get_setting_macvlan(NMConnection *connection); NMSettingOlpcMesh *nm_connection_get_setting_olpc_mesh(NMConnection *connection); NM_AVAILABLE_IN_1_10 NMSettingOvsBridge *nm_connection_get_setting_ovs_bridge(NMConnection *connection); NM_AVAILABLE_IN_1_10 NMSettingOvsInterface *nm_connection_get_setting_ovs_interface(NMConnection *connection); -NMSettingOvsPatch * nm_connection_get_setting_ovs_patch(NMConnection *connection); +NMSettingOvsPatch *nm_connection_get_setting_ovs_patch(NMConnection *connection); NM_AVAILABLE_IN_1_10 NMSettingOvsPort *nm_connection_get_setting_ovs_port(NMConnection *connection); -NMSettingPpp * nm_connection_get_setting_ppp(NMConnection *connection); -NMSettingPppoe * nm_connection_get_setting_pppoe(NMConnection *connection); +NMSettingPpp *nm_connection_get_setting_ppp(NMConnection *connection); +NMSettingPppoe *nm_connection_get_setting_pppoe(NMConnection *connection); NM_AVAILABLE_IN_1_6 -NMSettingProxy * nm_connection_get_setting_proxy(NMConnection *connection); +NMSettingProxy *nm_connection_get_setting_proxy(NMConnection *connection); NMSettingSerial *nm_connection_get_setting_serial(NMConnection *connection); NM_AVAILABLE_IN_1_12 NMSettingTCConfig *nm_connection_get_setting_tc_config(NMConnection *connection); NM_AVAILABLE_IN_1_2 -NMSettingTun * nm_connection_get_setting_tun(NMConnection *connection); -NMSettingVpn * nm_connection_get_setting_vpn(NMConnection *connection); -NMSettingWimax * nm_connection_get_setting_wimax(NMConnection *connection); -NMSettingAdsl * nm_connection_get_setting_adsl(NMConnection *connection); -NMSettingWired * nm_connection_get_setting_wired(NMConnection *connection); -NMSettingWireless * nm_connection_get_setting_wireless(NMConnection *connection); +NMSettingTun *nm_connection_get_setting_tun(NMConnection *connection); +NMSettingVpn *nm_connection_get_setting_vpn(NMConnection *connection); +NMSettingWimax *nm_connection_get_setting_wimax(NMConnection *connection); +NMSettingAdsl *nm_connection_get_setting_adsl(NMConnection *connection); +NMSettingWired *nm_connection_get_setting_wired(NMConnection *connection); +NMSettingWireless *nm_connection_get_setting_wireless(NMConnection *connection); NMSettingWirelessSecurity *nm_connection_get_setting_wireless_security(NMConnection *connection); -NMSettingVlan * nm_connection_get_setting_vlan(NMConnection *connection); +NMSettingVlan *nm_connection_get_setting_vlan(NMConnection *connection); NM_AVAILABLE_IN_1_2 NMSettingVxlan *nm_connection_get_setting_vxlan(NMConnection *connection); diff --git a/src/libnm-core-public/nm-keyfile.h b/src/libnm-core-public/nm-keyfile.h index e298aae8ef..8f8b1f1b5f 100644 --- a/src/libnm-core-public/nm-keyfile.h +++ b/src/libnm-core-public/nm-keyfile.h @@ -71,19 +71,19 @@ typedef struct _NMKeyfileHandlerData NMKeyfileHandlerData; * * Since: 1.30 */ -typedef gboolean (*NMKeyfileReadHandler)(GKeyFile * keyfile, - NMConnection * connection, +typedef gboolean (*NMKeyfileReadHandler)(GKeyFile *keyfile, + NMConnection *connection, NMKeyfileHandlerType handler_type, NMKeyfileHandlerData *handler_data, - void * user_data); + void *user_data); NM_AVAILABLE_IN_1_30 -NMConnection *nm_keyfile_read(GKeyFile * keyfile, - const char * base_dir, +NMConnection *nm_keyfile_read(GKeyFile *keyfile, + const char *base_dir, NMKeyfileHandlerFlags handler_flags, NMKeyfileReadHandler handler, - void * user_data, - GError ** error); + void *user_data, + GError **error); /** * NMKeyfileWriteHandler: @@ -112,18 +112,18 @@ NMConnection *nm_keyfile_read(GKeyFile * keyfile, * * Since: 1.30 */ -typedef gboolean (*NMKeyfileWriteHandler)(NMConnection * connection, - GKeyFile * keyfile, +typedef gboolean (*NMKeyfileWriteHandler)(NMConnection *connection, + GKeyFile *keyfile, NMKeyfileHandlerType handler_type, NMKeyfileHandlerData *handler_data, - void * user_data); + void *user_data); NM_AVAILABLE_IN_1_30 -GKeyFile *nm_keyfile_write(NMConnection * connection, +GKeyFile *nm_keyfile_write(NMConnection *connection, NMKeyfileHandlerFlags handler_flags, NMKeyfileWriteHandler handler, - void * user_data, - GError ** error); + void *user_data, + GError **error); /*****************************************************************************/ @@ -132,10 +132,10 @@ void nm_keyfile_handler_data_fail_with_error(NMKeyfileHandlerData *handler_data, NM_AVAILABLE_IN_1_30 void nm_keyfile_handler_data_get_context(const NMKeyfileHandlerData *handler_data, - const char ** out_kf_group_name, - const char ** out_kf_key_name, - NMSetting ** out_cur_setting, - const char ** out_cur_property_name); + const char **out_kf_group_name, + const char **out_kf_key_name, + NMSetting **out_cur_setting, + const char **out_cur_property_name); /** * NMKeyfileWarnSeverity: @@ -157,8 +157,8 @@ typedef enum { NM_AVAILABLE_IN_1_30 void nm_keyfile_handler_data_warn_get(const NMKeyfileHandlerData *handler_data, - const char ** out_message, - NMKeyfileWarnSeverity * out_severity); + const char **out_message, + NMKeyfileWarnSeverity *out_severity); G_END_DECLS diff --git a/src/libnm-core-public/nm-setting-8021x.h b/src/libnm-core-public/nm-setting-8021x.h index f9ebdd1ce0..2bd089dacf 100644 --- a/src/libnm-core-public/nm-setting-8021x.h +++ b/src/libnm-core-public/nm-setting-8021x.h @@ -192,15 +192,15 @@ const char *nm_setting_802_1x_get_ca_path(NMSetting8021x *setting); const char *nm_setting_802_1x_get_phase2_ca_path(NMSetting8021x *setting); NMSetting8021xCKScheme nm_setting_802_1x_get_ca_cert_scheme(NMSetting8021x *setting); -GBytes * nm_setting_802_1x_get_ca_cert_blob(NMSetting8021x *setting); -const char * nm_setting_802_1x_get_ca_cert_path(NMSetting8021x *setting); +GBytes *nm_setting_802_1x_get_ca_cert_blob(NMSetting8021x *setting); +const char *nm_setting_802_1x_get_ca_cert_path(NMSetting8021x *setting); NM_AVAILABLE_IN_1_6 const char *nm_setting_802_1x_get_ca_cert_uri(NMSetting8021x *setting); -gboolean nm_setting_802_1x_set_ca_cert(NMSetting8021x * setting, - const char * value, +gboolean nm_setting_802_1x_set_ca_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_8 const char *nm_setting_802_1x_get_ca_cert_password(NMSetting8021x *setting); @@ -212,10 +212,10 @@ const char *nm_setting_802_1x_get_subject_match(NMSetting8021x *setting); guint32 nm_setting_802_1x_get_num_altsubject_matches(NMSetting8021x *setting); const char *nm_setting_802_1x_get_altsubject_match(NMSetting8021x *setting, guint32 i); gboolean nm_setting_802_1x_add_altsubject_match(NMSetting8021x *setting, - const char * altsubject_match); + const char *altsubject_match); void nm_setting_802_1x_remove_altsubject_match(NMSetting8021x *setting, guint32 i); gboolean nm_setting_802_1x_remove_altsubject_match_by_value(NMSetting8021x *setting, - const char * altsubject_match); + const char *altsubject_match); void nm_setting_802_1x_clear_altsubject_matches(NMSetting8021x *setting); NM_AVAILABLE_IN_1_2 const char *nm_setting_802_1x_get_domain_suffix_match(NMSetting8021x *setting); @@ -224,15 +224,15 @@ NM_AVAILABLE_IN_1_24 const char *nm_setting_802_1x_get_domain_match(NMSetting8021x *setting); NMSetting8021xCKScheme nm_setting_802_1x_get_client_cert_scheme(NMSetting8021x *setting); -GBytes * nm_setting_802_1x_get_client_cert_blob(NMSetting8021x *setting); -const char * nm_setting_802_1x_get_client_cert_path(NMSetting8021x *setting); +GBytes *nm_setting_802_1x_get_client_cert_blob(NMSetting8021x *setting); +const char *nm_setting_802_1x_get_client_cert_path(NMSetting8021x *setting); NM_AVAILABLE_IN_1_6 const char *nm_setting_802_1x_get_client_cert_uri(NMSetting8021x *setting); -gboolean nm_setting_802_1x_set_client_cert(NMSetting8021x * setting, - const char * value, +gboolean nm_setting_802_1x_set_client_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_8 const char *nm_setting_802_1x_get_client_cert_password(NMSetting8021x *setting); @@ -250,15 +250,15 @@ const char *nm_setting_802_1x_get_phase2_auth(NMSetting8021x *setting); const char *nm_setting_802_1x_get_phase2_autheap(NMSetting8021x *setting); NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_ca_cert_scheme(NMSetting8021x *setting); -GBytes * nm_setting_802_1x_get_phase2_ca_cert_blob(NMSetting8021x *setting); -const char * nm_setting_802_1x_get_phase2_ca_cert_path(NMSetting8021x *setting); +GBytes *nm_setting_802_1x_get_phase2_ca_cert_blob(NMSetting8021x *setting); +const char *nm_setting_802_1x_get_phase2_ca_cert_path(NMSetting8021x *setting); NM_AVAILABLE_IN_1_6 const char *nm_setting_802_1x_get_phase2_ca_cert_uri(NMSetting8021x *setting); -gboolean nm_setting_802_1x_set_phase2_ca_cert(NMSetting8021x * setting, - const char * value, +gboolean nm_setting_802_1x_set_phase2_ca_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_8 const char *nm_setting_802_1x_get_phase2_ca_cert_password(NMSetting8021x *setting); @@ -270,11 +270,11 @@ const char *nm_setting_802_1x_get_phase2_subject_match(NMSetting8021x *setting); guint32 nm_setting_802_1x_get_num_phase2_altsubject_matches(NMSetting8021x *setting); const char *nm_setting_802_1x_get_phase2_altsubject_match(NMSetting8021x *setting, guint32 i); gboolean nm_setting_802_1x_add_phase2_altsubject_match(NMSetting8021x *setting, - const char * phase2_altsubject_match); + const char *phase2_altsubject_match); void nm_setting_802_1x_remove_phase2_altsubject_match(NMSetting8021x *setting, guint32 i); gboolean nm_setting_802_1x_remove_phase2_altsubject_match_by_value(NMSetting8021x *setting, - const char * phase2_altsubject_match); + const char *phase2_altsubject_match); void nm_setting_802_1x_clear_phase2_altsubject_matches(NMSetting8021x *setting); NM_AVAILABLE_IN_1_2 const char *nm_setting_802_1x_get_phase2_domain_suffix_match(NMSetting8021x *setting); @@ -283,15 +283,15 @@ NM_AVAILABLE_IN_1_24 const char *nm_setting_802_1x_get_phase2_domain_match(NMSetting8021x *setting); NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_client_cert_scheme(NMSetting8021x *setting); -GBytes * nm_setting_802_1x_get_phase2_client_cert_blob(NMSetting8021x *setting); -const char * nm_setting_802_1x_get_phase2_client_cert_path(NMSetting8021x *setting); +GBytes *nm_setting_802_1x_get_phase2_client_cert_blob(NMSetting8021x *setting); +const char *nm_setting_802_1x_get_phase2_client_cert_path(NMSetting8021x *setting); NM_AVAILABLE_IN_1_6 const char *nm_setting_802_1x_get_phase2_client_cert_uri(NMSetting8021x *setting); -gboolean nm_setting_802_1x_set_phase2_client_cert(NMSetting8021x * setting, - const char * value, +gboolean nm_setting_802_1x_set_phase2_client_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_8 const char *nm_setting_802_1x_get_phase2_client_cert_password(NMSetting8021x *setting); @@ -299,41 +299,41 @@ NM_AVAILABLE_IN_1_8 NMSettingSecretFlags nm_setting_802_1x_get_phase2_client_cert_password_flags(NMSetting8021x *setting); -const char * nm_setting_802_1x_get_password(NMSetting8021x *setting); +const char *nm_setting_802_1x_get_password(NMSetting8021x *setting); NMSettingSecretFlags nm_setting_802_1x_get_password_flags(NMSetting8021x *setting); -GBytes * nm_setting_802_1x_get_password_raw(NMSetting8021x *setting); +GBytes *nm_setting_802_1x_get_password_raw(NMSetting8021x *setting); NMSettingSecretFlags nm_setting_802_1x_get_password_raw_flags(NMSetting8021x *setting); -const char * nm_setting_802_1x_get_pin(NMSetting8021x *setting); +const char *nm_setting_802_1x_get_pin(NMSetting8021x *setting); NMSettingSecretFlags nm_setting_802_1x_get_pin_flags(NMSetting8021x *setting); NMSetting8021xCKScheme nm_setting_802_1x_get_private_key_scheme(NMSetting8021x *setting); -GBytes * nm_setting_802_1x_get_private_key_blob(NMSetting8021x *setting); -const char * nm_setting_802_1x_get_private_key_path(NMSetting8021x *setting); +GBytes *nm_setting_802_1x_get_private_key_blob(NMSetting8021x *setting); +const char *nm_setting_802_1x_get_private_key_path(NMSetting8021x *setting); NM_AVAILABLE_IN_1_6 -const char * nm_setting_802_1x_get_private_key_uri(NMSetting8021x *setting); -gboolean nm_setting_802_1x_set_private_key(NMSetting8021x * setting, - const char * value, - const char * password, +const char *nm_setting_802_1x_get_private_key_uri(NMSetting8021x *setting); +gboolean nm_setting_802_1x_set_private_key(NMSetting8021x *setting, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); -const char * nm_setting_802_1x_get_private_key_password(NMSetting8021x *setting); + GError **error); +const char *nm_setting_802_1x_get_private_key_password(NMSetting8021x *setting); NMSettingSecretFlags nm_setting_802_1x_get_private_key_password_flags(NMSetting8021x *setting); NMSetting8021xCKFormat nm_setting_802_1x_get_private_key_format(NMSetting8021x *setting); NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_private_key_scheme(NMSetting8021x *setting); -GBytes * nm_setting_802_1x_get_phase2_private_key_blob(NMSetting8021x *setting); -const char * nm_setting_802_1x_get_phase2_private_key_path(NMSetting8021x *setting); +GBytes *nm_setting_802_1x_get_phase2_private_key_blob(NMSetting8021x *setting); +const char *nm_setting_802_1x_get_phase2_private_key_path(NMSetting8021x *setting); NM_AVAILABLE_IN_1_6 const char *nm_setting_802_1x_get_phase2_private_key_uri(NMSetting8021x *setting); -gboolean nm_setting_802_1x_set_phase2_private_key(NMSetting8021x * setting, - const char * value, - const char * password, +gboolean nm_setting_802_1x_set_phase2_private_key(NMSetting8021x *setting, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); + GError **error); const char *nm_setting_802_1x_get_phase2_private_key_password(NMSetting8021x *setting); NMSettingSecretFlags nm_setting_802_1x_get_phase2_private_key_password_flags(NMSetting8021x *setting); diff --git a/src/libnm-core-public/nm-setting-adsl.h b/src/libnm-core-public/nm-setting-adsl.h index 8c584fed4a..1c8c56a5fb 100644 --- a/src/libnm-core-public/nm-setting-adsl.h +++ b/src/libnm-core-public/nm-setting-adsl.h @@ -45,11 +45,11 @@ typedef struct _NMSettingAdslClass NMSettingAdslClass; GType nm_setting_adsl_get_type(void); -NMSetting * nm_setting_adsl_new(void); -const char * nm_setting_adsl_get_username(NMSettingAdsl *setting); -const char * nm_setting_adsl_get_password(NMSettingAdsl *setting); -const char * nm_setting_adsl_get_protocol(NMSettingAdsl *setting); -const char * nm_setting_adsl_get_encapsulation(NMSettingAdsl *setting); +NMSetting *nm_setting_adsl_new(void); +const char *nm_setting_adsl_get_username(NMSettingAdsl *setting); +const char *nm_setting_adsl_get_password(NMSettingAdsl *setting); +const char *nm_setting_adsl_get_protocol(NMSettingAdsl *setting); +const char *nm_setting_adsl_get_encapsulation(NMSettingAdsl *setting); guint32 nm_setting_adsl_get_vpi(NMSettingAdsl *setting); guint32 nm_setting_adsl_get_vci(NMSettingAdsl *setting); NMSettingSecretFlags nm_setting_adsl_get_password_flags(NMSettingAdsl *setting); diff --git a/src/libnm-core-public/nm-setting-bluetooth.h b/src/libnm-core-public/nm-setting-bluetooth.h index 6388430a03..613005c996 100644 --- a/src/libnm-core-public/nm-setting-bluetooth.h +++ b/src/libnm-core-public/nm-setting-bluetooth.h @@ -59,7 +59,7 @@ typedef struct _NMSettingBluetoothClass NMSettingBluetoothClass; GType nm_setting_bluetooth_get_type(void); -NMSetting * nm_setting_bluetooth_new(void); +NMSetting *nm_setting_bluetooth_new(void); const char *nm_setting_bluetooth_get_bdaddr(NMSettingBluetooth *setting); const char *nm_setting_bluetooth_get_connection_type(NMSettingBluetooth *setting); diff --git a/src/libnm-core-public/nm-setting-bond.h b/src/libnm-core-public/nm-setting-bond.h index e819b4e104..ed44abbff1 100644 --- a/src/libnm-core-public/nm-setting-bond.h +++ b/src/libnm-core-public/nm-setting-bond.h @@ -62,12 +62,12 @@ typedef struct _NMSettingBondClass NMSettingBondClass; GType nm_setting_bond_get_type(void); -NMSetting * nm_setting_bond_new(void); +NMSetting *nm_setting_bond_new(void); guint32 nm_setting_bond_get_num_options(NMSettingBond *setting); gboolean nm_setting_bond_get_option(NMSettingBond *setting, guint32 idx, - const char ** out_name, - const char ** out_value); + const char **out_name, + const char **out_value); const char *nm_setting_bond_get_option_by_name(NMSettingBond *setting, const char *name); gboolean nm_setting_bond_add_option(NMSettingBond *setting, const char *name, const char *value); gboolean nm_setting_bond_remove_option(NMSettingBond *setting, const char *name); diff --git a/src/libnm-core-public/nm-setting-cdma.h b/src/libnm-core-public/nm-setting-cdma.h index 1378f1705f..9b2e5ed7b9 100644 --- a/src/libnm-core-public/nm-setting-cdma.h +++ b/src/libnm-core-public/nm-setting-cdma.h @@ -37,10 +37,10 @@ typedef struct _NMSettingCdmaClass NMSettingCdmaClass; GType nm_setting_cdma_get_type(void); -NMSetting * nm_setting_cdma_new(void); -const char * nm_setting_cdma_get_number(NMSettingCdma *setting); -const char * nm_setting_cdma_get_username(NMSettingCdma *setting); -const char * nm_setting_cdma_get_password(NMSettingCdma *setting); +NMSetting *nm_setting_cdma_new(void); +const char *nm_setting_cdma_get_number(NMSettingCdma *setting); +const char *nm_setting_cdma_get_username(NMSettingCdma *setting); +const char *nm_setting_cdma_get_password(NMSettingCdma *setting); NMSettingSecretFlags nm_setting_cdma_get_password_flags(NMSettingCdma *setting); NM_AVAILABLE_IN_1_8 diff --git a/src/libnm-core-public/nm-setting-connection.h b/src/libnm-core-public/nm-setting-connection.h index 54fc792937..83b5fd349a 100644 --- a/src/libnm-core-public/nm-setting-connection.h +++ b/src/libnm-core-public/nm-setting-connection.h @@ -150,7 +150,7 @@ typedef struct _NMSettingConnectionClass NMSettingConnectionClass; GType nm_setting_connection_get_type(void); -NMSetting * nm_setting_connection_new(void); +NMSetting *nm_setting_connection_new(void); const char *nm_setting_connection_get_id(NMSettingConnection *setting); const char *nm_setting_connection_get_uuid(NMSettingConnection *setting); NM_AVAILABLE_IN_1_4 @@ -169,21 +169,21 @@ gboolean nm_setting_connection_get_read_only(NMSettingConnection guint32 nm_setting_connection_get_num_permissions(NMSettingConnection *setting); gboolean nm_setting_connection_get_permission(NMSettingConnection *setting, guint32 idx, - const char ** out_ptype, - const char ** out_pitem, - const char ** out_detail); + const char **out_ptype, + const char **out_pitem, + const char **out_detail); const char *nm_setting_connection_get_zone(NMSettingConnection *setting); gboolean nm_setting_connection_permissions_user_allowed(NMSettingConnection *setting, - const char * uname); + const char *uname); gboolean nm_setting_connection_add_permission(NMSettingConnection *setting, - const char * ptype, - const char * pitem, - const char * detail); + const char *ptype, + const char *pitem, + const char *detail); void nm_setting_connection_remove_permission(NMSettingConnection *setting, guint32 idx); gboolean nm_setting_connection_remove_permission_by_value(NMSettingConnection *setting, - const char * ptype, - const char * pitem, - const char * detail); + const char *ptype, + const char *pitem, + const char *detail); const char *nm_setting_connection_get_master(NMSettingConnection *setting); gboolean nm_setting_connection_is_slave_type(NMSettingConnection *setting, const char *type); @@ -197,7 +197,7 @@ const char *nm_setting_connection_get_secondary(NMSettingConnection *setting, gu gboolean nm_setting_connection_add_secondary(NMSettingConnection *setting, const char *sec_uuid); void nm_setting_connection_remove_secondary(NMSettingConnection *setting, guint32 idx); gboolean nm_setting_connection_remove_secondary_by_value(NMSettingConnection *setting, - const char * sec_uuid); + const char *sec_uuid); guint32 nm_setting_connection_get_gateway_ping_timeout(NMSettingConnection *setting); NM_AVAILABLE_IN_1_2 diff --git a/src/libnm-core-public/nm-setting-dcb.h b/src/libnm-core-public/nm-setting-dcb.h index 5378621355..ba702bd708 100644 --- a/src/libnm-core-public/nm-setting-dcb.h +++ b/src/libnm-core-public/nm-setting-dcb.h @@ -85,7 +85,7 @@ NMSetting *nm_setting_dcb_new(void); NMSettingDcbFlags nm_setting_dcb_get_app_fcoe_flags(NMSettingDcb *setting); int nm_setting_dcb_get_app_fcoe_priority(NMSettingDcb *setting); -const char * nm_setting_dcb_get_app_fcoe_mode(NMSettingDcb *setting); +const char *nm_setting_dcb_get_app_fcoe_mode(NMSettingDcb *setting); NMSettingDcbFlags nm_setting_dcb_get_app_iscsi_flags(NMSettingDcb *setting); int nm_setting_dcb_get_app_iscsi_priority(NMSettingDcb *setting); diff --git a/src/libnm-core-public/nm-setting-infiniband.h b/src/libnm-core-public/nm-setting-infiniband.h index 44f30839cb..313b20874f 100644 --- a/src/libnm-core-public/nm-setting-infiniband.h +++ b/src/libnm-core-public/nm-setting-infiniband.h @@ -38,7 +38,7 @@ typedef struct _NMSettingInfinibandClass NMSettingInfinibandClass; GType nm_setting_infiniband_get_type(void); -NMSetting * nm_setting_infiniband_new(void); +NMSetting *nm_setting_infiniband_new(void); const char *nm_setting_infiniband_get_mac_address(NMSettingInfiniband *setting); guint32 nm_setting_infiniband_get_mtu(NMSettingInfiniband *setting); const char *nm_setting_infiniband_get_transport_mode(NMSettingInfiniband *setting); diff --git a/src/libnm-core-public/nm-setting-ip-config.h b/src/libnm-core-public/nm-setting-ip-config.h index 126c4c11da..6a19bdb39f 100644 --- a/src/libnm-core-public/nm-setting-ip-config.h +++ b/src/libnm-core-public/nm-setting-ip-config.h @@ -61,7 +61,7 @@ void nm_ip_address_set_address_binary(NMIPAddress *address, gconstpointer guint nm_ip_address_get_prefix(NMIPAddress *address); void nm_ip_address_set_prefix(NMIPAddress *address, guint prefix); -char ** nm_ip_address_get_attribute_names(NMIPAddress *address); +char **nm_ip_address_get_attribute_names(NMIPAddress *address); GVariant *nm_ip_address_get_attribute(NMIPAddress *address, const char *name); void nm_ip_address_set_attribute(NMIPAddress *address, const char *name, GVariant *value); @@ -74,13 +74,13 @@ NMIPRoute *nm_ip_route_new(int family, guint prefix, const char *next_hop, gint64 metric, - GError ** error); + GError **error); NMIPRoute *nm_ip_route_new_binary(int family, gconstpointer dest, guint prefix, gconstpointer next_hop, gint64 metric, - GError ** error); + GError **error); void nm_ip_route_ref(NMIPRoute *route); void nm_ip_route_unref(NMIPRoute *route); @@ -111,17 +111,17 @@ void nm_ip_route_set_next_hop_binary(NMIPRoute *route, gconstpointer next gint64 nm_ip_route_get_metric(NMIPRoute *route); void nm_ip_route_set_metric(NMIPRoute *route, gint64 metric); -char ** nm_ip_route_get_attribute_names(NMIPRoute *route); +char **nm_ip_route_get_attribute_names(NMIPRoute *route); GVariant *nm_ip_route_get_attribute(NMIPRoute *route, const char *name); void nm_ip_route_set_attribute(NMIPRoute *route, const char *name, GVariant *value); NM_AVAILABLE_IN_1_8 const NMVariantAttributeSpec *const *nm_ip_route_get_variant_attribute_spec(void); NM_AVAILABLE_IN_1_8 gboolean nm_ip_route_attribute_validate(const char *name, - GVariant * value, + GVariant *value, int family, - gboolean * known, - GError ** error); + gboolean *known, + GError **error); #define NM_IP_ROUTE_ATTRIBUTE_CWND "cwnd" #define NM_IP_ROUTE_ATTRIBUTE_FROM "from" @@ -250,8 +250,8 @@ void nm_ip_routing_rule_set_suppress_prefixlength(NMIPRoutingRule *self, NM_AVAILABLE_IN_1_34 gboolean nm_ip_routing_rule_get_uid_range(const NMIPRoutingRule *self, - guint32 * out_range_start, - guint32 * out_range_end); + guint32 *out_range_start, + guint32 *out_range_end); NM_AVAILABLE_IN_1_34 void nm_ip_routing_rule_set_uid_range(NMIPRoutingRule *self, guint32 uid_range_start, @@ -286,16 +286,16 @@ typedef enum { /*< flags >*/ } NMIPRoutingRuleAsStringFlags; NM_AVAILABLE_IN_1_18 -NMIPRoutingRule *nm_ip_routing_rule_from_string(const char * str, +NMIPRoutingRule *nm_ip_routing_rule_from_string(const char *str, NMIPRoutingRuleAsStringFlags to_string_flags, - GHashTable * extra_args, - GError ** error); + GHashTable *extra_args, + GError **error); NM_AVAILABLE_IN_1_18 -char *nm_ip_routing_rule_to_string(const NMIPRoutingRule * self, +char *nm_ip_routing_rule_to_string(const NMIPRoutingRule *self, NMIPRoutingRuleAsStringFlags to_string_flags, - GHashTable * extra_args, - GError ** error); + GHashTable *extra_args, + GError **error); /*****************************************************************************/ @@ -413,7 +413,7 @@ const char *nm_setting_ip_config_get_dns_search(NMSettingIPConfig *setting, int gboolean nm_setting_ip_config_add_dns_search(NMSettingIPConfig *setting, const char *dns_search); void nm_setting_ip_config_remove_dns_search(NMSettingIPConfig *setting, int idx); gboolean nm_setting_ip_config_remove_dns_search_by_value(NMSettingIPConfig *setting, - const char * dns_search); + const char *dns_search); void nm_setting_ip_config_clear_dns_searches(NMSettingIPConfig *setting); guint nm_setting_ip_config_get_num_dns_options(NMSettingIPConfig *setting); @@ -422,7 +422,7 @@ const char *nm_setting_ip_config_get_dns_option(NMSettingIPConfig *setting, guin gboolean nm_setting_ip_config_add_dns_option(NMSettingIPConfig *setting, const char *dns_option); void nm_setting_ip_config_remove_dns_option(NMSettingIPConfig *setting, int idx); gboolean nm_setting_ip_config_remove_dns_option_by_value(NMSettingIPConfig *setting, - const char * dns_option); + const char *dns_option); void nm_setting_ip_config_clear_dns_options(NMSettingIPConfig *setting, gboolean is_set); NM_AVAILABLE_IN_1_4 @@ -433,7 +433,7 @@ NMIPAddress *nm_setting_ip_config_get_address(NMSettingIPConfig *setting, int id gboolean nm_setting_ip_config_add_address(NMSettingIPConfig *setting, NMIPAddress *address); void nm_setting_ip_config_remove_address(NMSettingIPConfig *setting, int idx); gboolean nm_setting_ip_config_remove_address_by_value(NMSettingIPConfig *setting, - NMIPAddress * address); + NMIPAddress *address); void nm_setting_ip_config_clear_addresses(NMSettingIPConfig *setting); const char *nm_setting_ip_config_get_gateway(NMSettingIPConfig *setting); @@ -456,7 +456,7 @@ NM_AVAILABLE_IN_1_18 NMIPRoutingRule *nm_setting_ip_config_get_routing_rule(NMSettingIPConfig *setting, guint idx); NM_AVAILABLE_IN_1_18 void nm_setting_ip_config_add_routing_rule(NMSettingIPConfig *setting, - NMIPRoutingRule * routing_rule); + NMIPRoutingRule *routing_rule); NM_AVAILABLE_IN_1_18 void nm_setting_ip_config_remove_routing_rule(NMSettingIPConfig *setting, guint idx); NM_AVAILABLE_IN_1_18 @@ -484,7 +484,7 @@ NMDhcpHostnameFlags nm_setting_ip_config_get_dhcp_hostname_flags(NMSettingIPConf NM_AVAILABLE_IN_1_28 const char *const *nm_setting_ip_config_get_dhcp_reject_servers(NMSettingIPConfig *setting, - guint * out_len); + guint *out_len); NM_AVAILABLE_IN_1_28 void nm_setting_ip_config_add_dhcp_reject_server(NMSettingIPConfig *setting, const char *server); NM_AVAILABLE_IN_1_28 diff --git a/src/libnm-core-public/nm-setting-match.h b/src/libnm-core-public/nm-setting-match.h index a4e283e2ad..6f3666b560 100644 --- a/src/libnm-core-public/nm-setting-match.h +++ b/src/libnm-core-public/nm-setting-match.h @@ -46,7 +46,7 @@ NM_AVAILABLE_IN_1_14 void nm_setting_match_remove_interface_name(NMSettingMatch *setting, int idx); NM_AVAILABLE_IN_1_14 gboolean nm_setting_match_remove_interface_name_by_value(NMSettingMatch *setting, - const char * interface_name); + const char *interface_name); NM_AVAILABLE_IN_1_14 void nm_setting_match_add_interface_name(NMSettingMatch *setting, const char *interface_name); NM_AVAILABLE_IN_1_14 @@ -62,15 +62,15 @@ NM_AVAILABLE_IN_1_26 void nm_setting_match_remove_kernel_command_line(NMSettingMatch *setting, guint idx); NM_AVAILABLE_IN_1_26 gboolean nm_setting_match_remove_kernel_command_line_by_value(NMSettingMatch *setting, - const char * kernel_command_line); + const char *kernel_command_line); NM_AVAILABLE_IN_1_26 void nm_setting_match_add_kernel_command_line(NMSettingMatch *setting, - const char * kernel_command_line); + const char *kernel_command_line); NM_AVAILABLE_IN_1_26 void nm_setting_match_clear_kernel_command_lines(NMSettingMatch *setting); NM_AVAILABLE_IN_1_26 const char *const *nm_setting_match_get_kernel_command_lines(NMSettingMatch *setting, - guint * length); + guint *length); NM_AVAILABLE_IN_1_26 guint nm_setting_match_get_num_drivers(NMSettingMatch *setting); diff --git a/src/libnm-core-public/nm-setting-olpc-mesh.h b/src/libnm-core-public/nm-setting-olpc-mesh.h index c9903f756e..b055adbb6d 100644 --- a/src/libnm-core-public/nm-setting-olpc-mesh.h +++ b/src/libnm-core-public/nm-setting-olpc-mesh.h @@ -37,8 +37,8 @@ typedef struct _NMSettingOlpcMeshClass NMSettingOlpcMeshClass; GType nm_setting_olpc_mesh_get_type(void); -NMSetting * nm_setting_olpc_mesh_new(void); -GBytes * nm_setting_olpc_mesh_get_ssid(NMSettingOlpcMesh *setting); +NMSetting *nm_setting_olpc_mesh_new(void); +GBytes *nm_setting_olpc_mesh_get_ssid(NMSettingOlpcMesh *setting); guint32 nm_setting_olpc_mesh_get_channel(NMSettingOlpcMesh *setting); const char *nm_setting_olpc_mesh_get_dhcp_anycast_address(NMSettingOlpcMesh *setting); diff --git a/src/libnm-core-public/nm-setting-ovs-external-ids.h b/src/libnm-core-public/nm-setting-ovs-external-ids.h index 3ae991a13a..03cb299e71 100644 --- a/src/libnm-core-public/nm-setting-ovs-external-ids.h +++ b/src/libnm-core-public/nm-setting-ovs-external-ids.h @@ -46,15 +46,15 @@ NMSetting *nm_setting_ovs_external_ids_new(void); NM_AVAILABLE_IN_1_30 const char *const *nm_setting_ovs_external_ids_get_data_keys(NMSettingOvsExternalIDs *setting, - guint * out_len); + guint *out_len); NM_AVAILABLE_IN_1_30 const char *nm_setting_ovs_external_ids_get_data(NMSettingOvsExternalIDs *setting, const char *key); NM_AVAILABLE_IN_1_30 void nm_setting_ovs_external_ids_set_data(NMSettingOvsExternalIDs *setting, - const char * key, - const char * val); + const char *key, + const char *val); /*****************************************************************************/ diff --git a/src/libnm-core-public/nm-setting-pppoe.h b/src/libnm-core-public/nm-setting-pppoe.h index 5abf9c9fef..b94046d4cc 100644 --- a/src/libnm-core-public/nm-setting-pppoe.h +++ b/src/libnm-core-public/nm-setting-pppoe.h @@ -39,10 +39,10 @@ GType nm_setting_pppoe_get_type(void); NMSetting *nm_setting_pppoe_new(void); NM_AVAILABLE_IN_1_10 -const char * nm_setting_pppoe_get_parent(NMSettingPppoe *setting); -const char * nm_setting_pppoe_get_service(NMSettingPppoe *setting); -const char * nm_setting_pppoe_get_username(NMSettingPppoe *setting); -const char * nm_setting_pppoe_get_password(NMSettingPppoe *setting); +const char *nm_setting_pppoe_get_parent(NMSettingPppoe *setting); +const char *nm_setting_pppoe_get_service(NMSettingPppoe *setting); +const char *nm_setting_pppoe_get_username(NMSettingPppoe *setting); +const char *nm_setting_pppoe_get_password(NMSettingPppoe *setting); NMSettingSecretFlags nm_setting_pppoe_get_password_flags(NMSettingPppoe *setting); G_END_DECLS diff --git a/src/libnm-core-public/nm-setting-serial.h b/src/libnm-core-public/nm-setting-serial.h index 4f8ead8259..82a97cb499 100644 --- a/src/libnm-core-public/nm-setting-serial.h +++ b/src/libnm-core-public/nm-setting-serial.h @@ -51,7 +51,7 @@ typedef struct _NMSettingSerialClass NMSettingSerialClass; GType nm_setting_serial_get_type(void); -NMSetting * nm_setting_serial_new(void); +NMSetting *nm_setting_serial_new(void); guint nm_setting_serial_get_baud(NMSettingSerial *setting); guint nm_setting_serial_get_bits(NMSettingSerial *setting); NMSettingSerialParity nm_setting_serial_get_parity(NMSettingSerial *setting); diff --git a/src/libnm-core-public/nm-setting-tc-config.h b/src/libnm-core-public/nm-setting-tc-config.h index 7e8a44b539..abd616836b 100644 --- a/src/libnm-core-public/nm-setting-tc-config.h +++ b/src/libnm-core-public/nm-setting-tc-config.h @@ -153,7 +153,7 @@ NM_AVAILABLE_IN_1_12 void nm_setting_tc_config_remove_tfilter(NMSettingTCConfig *setting, guint idx); NM_AVAILABLE_IN_1_12 gboolean nm_setting_tc_config_remove_tfilter_by_value(NMSettingTCConfig *setting, - NMTCTfilter * tfilter); + NMTCTfilter *tfilter); NM_AVAILABLE_IN_1_12 void nm_setting_tc_config_clear_tfilters(NMSettingTCConfig *setting); diff --git a/src/libnm-core-public/nm-setting-team.h b/src/libnm-core-public/nm-setting-team.h index 821741524c..339830d3e3 100644 --- a/src/libnm-core-public/nm-setting-team.h +++ b/src/libnm-core-public/nm-setting-team.h @@ -48,24 +48,24 @@ NMTeamLinkWatcher *nm_team_link_watcher_new_nsna_ping(int init_wait, int interval, int missed_max, const char *target_host, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_12 NMTeamLinkWatcher *nm_team_link_watcher_new_arp_ping(int init_wait, int interval, int missed_max, - const char * target_host, - const char * source_host, + const char *target_host, + const char *source_host, NMTeamLinkWatcherArpPingFlags flags, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_16 NMTeamLinkWatcher *nm_team_link_watcher_new_arp_ping2(int init_wait, int interval, int missed_max, int vlanid, - const char * target_host, - const char * source_host, + const char *target_host, + const char *source_host, NMTeamLinkWatcherArpPingFlags flags, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_12 void nm_team_link_watcher_ref(NMTeamLinkWatcher *watcher); NM_AVAILABLE_IN_1_12 @@ -203,7 +203,7 @@ gboolean nm_setting_team_add_link_watcher(NMSettingTeam *setting, NMTeamLinkWatc NM_AVAILABLE_IN_1_12 void nm_setting_team_remove_link_watcher(NMSettingTeam *setting, guint idx); NM_AVAILABLE_IN_1_12 -gboolean nm_setting_team_remove_link_watcher_by_value(NMSettingTeam * setting, +gboolean nm_setting_team_remove_link_watcher_by_value(NMSettingTeam *setting, NMTeamLinkWatcher *link_watcher); NM_AVAILABLE_IN_1_12 void nm_setting_team_clear_link_watchers(NMSettingTeam *setting); diff --git a/src/libnm-core-public/nm-setting-vlan.h b/src/libnm-core-public/nm-setting-vlan.h index 09a407db50..10a95da056 100644 --- a/src/libnm-core-public/nm-setting-vlan.h +++ b/src/libnm-core-public/nm-setting-vlan.h @@ -89,27 +89,27 @@ guint32 nm_setting_vlan_get_flags(NMSettingVlan *setting); gint32 nm_setting_vlan_get_num_priorities(NMSettingVlan *setting, NMVlanPriorityMap map); -gboolean nm_setting_vlan_get_priority(NMSettingVlan * setting, +gboolean nm_setting_vlan_get_priority(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 idx, - guint32 * out_from, - guint32 * out_to); + guint32 *out_from, + guint32 *out_to); -gboolean nm_setting_vlan_add_priority(NMSettingVlan * setting, +gboolean nm_setting_vlan_add_priority(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 from, guint32 to); void nm_setting_vlan_remove_priority(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 idx); -gboolean nm_setting_vlan_remove_priority_by_value(NMSettingVlan * setting, +gboolean nm_setting_vlan_remove_priority_by_value(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 from, guint32 to); -gboolean nm_setting_vlan_remove_priority_str_by_value(NMSettingVlan * setting, +gboolean nm_setting_vlan_remove_priority_str_by_value(NMSettingVlan *setting, NMVlanPriorityMap map, - const char * str); + const char *str); void nm_setting_vlan_clear_priorities(NMSettingVlan *setting, NMVlanPriorityMap map); diff --git a/src/libnm-core-public/nm-setting-vpn.h b/src/libnm-core-public/nm-setting-vpn.h index 9fbb791b81..151a293a1b 100644 --- a/src/libnm-core-public/nm-setting-vpn.h +++ b/src/libnm-core-public/nm-setting-vpn.h @@ -46,7 +46,7 @@ typedef void (*NMVpnIterFunc)(const char *key, const char *value, gpointer user_ GType nm_setting_vpn_get_type(void); -NMSetting * nm_setting_vpn_new(void); +NMSetting *nm_setting_vpn_new(void); const char *nm_setting_vpn_get_service_type(NMSettingVpn *setting); const char *nm_setting_vpn_get_user_name(NMSettingVpn *setting); gboolean nm_setting_vpn_get_persistent(NMSettingVpn *setting); diff --git a/src/libnm-core-public/nm-setting-wired.h b/src/libnm-core-public/nm-setting-wired.h index 54c8f9c065..ebe0d00a05 100644 --- a/src/libnm-core-public/nm-setting-wired.h +++ b/src/libnm-core-public/nm-setting-wired.h @@ -85,7 +85,7 @@ typedef struct _NMSettingWiredClass NMSettingWiredClass; GType nm_setting_wired_get_type(void); -NMSetting * nm_setting_wired_new(void); +NMSetting *nm_setting_wired_new(void); const char *nm_setting_wired_get_port(NMSettingWired *setting); guint32 nm_setting_wired_get_speed(NMSettingWired *setting); const char *nm_setting_wired_get_duplex(NMSettingWired *setting); @@ -101,23 +101,23 @@ const char *nm_setting_wired_get_generate_mac_address_mask(NMSettingWired *setti const char *const *nm_setting_wired_get_mac_address_blacklist(NMSettingWired *setting); guint32 nm_setting_wired_get_num_mac_blacklist_items(NMSettingWired *setting); -const char * nm_setting_wired_get_mac_blacklist_item(NMSettingWired *setting, guint32 idx); +const char *nm_setting_wired_get_mac_blacklist_item(NMSettingWired *setting, guint32 idx); gboolean nm_setting_wired_add_mac_blacklist_item(NMSettingWired *setting, const char *mac); void nm_setting_wired_remove_mac_blacklist_item(NMSettingWired *setting, guint32 idx); gboolean nm_setting_wired_remove_mac_blacklist_item_by_value(NMSettingWired *setting, - const char * mac); + const char *mac); void nm_setting_wired_clear_mac_blacklist_items(NMSettingWired *setting); guint32 nm_setting_wired_get_mtu(NMSettingWired *setting); const char *const *nm_setting_wired_get_s390_subchannels(NMSettingWired *setting); -const char * nm_setting_wired_get_s390_nettype(NMSettingWired *setting); +const char *nm_setting_wired_get_s390_nettype(NMSettingWired *setting); guint32 nm_setting_wired_get_num_s390_options(NMSettingWired *setting); gboolean nm_setting_wired_get_s390_option(NMSettingWired *setting, guint32 idx, - const char ** out_key, - const char ** out_value); + const char **out_key, + const char **out_value); const char *nm_setting_wired_get_s390_option_by_key(NMSettingWired *setting, const char *key); gboolean nm_setting_wired_add_s390_option(NMSettingWired *setting, const char *key, const char *value); @@ -125,7 +125,7 @@ gboolean nm_setting_wired_remove_s390_option(NMSettingWired *setting, const const char **nm_setting_wired_get_valid_s390_options(NMSettingWired *setting); NMSettingWiredWakeOnLan nm_setting_wired_get_wake_on_lan(NMSettingWired *setting); -const char * nm_setting_wired_get_wake_on_lan_password(NMSettingWired *setting); +const char *nm_setting_wired_get_wake_on_lan_password(NMSettingWired *setting); G_END_DECLS diff --git a/src/libnm-core-public/nm-setting-wireguard.h b/src/libnm-core-public/nm-setting-wireguard.h index cb475d271a..7e62e2ed40 100644 --- a/src/libnm-core-public/nm-setting-wireguard.h +++ b/src/libnm-core-public/nm-setting-wireguard.h @@ -47,20 +47,20 @@ NM_AVAILABLE_IN_1_16 const char *nm_wireguard_peer_get_public_key(const NMWireGuardPeer *self); NM_AVAILABLE_IN_1_16 gboolean nm_wireguard_peer_set_public_key(NMWireGuardPeer *self, - const char * public_key, + const char *public_key, gboolean accept_invalid); NM_AVAILABLE_IN_1_16 const char *nm_wireguard_peer_get_preshared_key(const NMWireGuardPeer *self); NM_AVAILABLE_IN_1_16 gboolean nm_wireguard_peer_set_preshared_key(NMWireGuardPeer *self, - const char * preshared_key, + const char *preshared_key, gboolean accept_invalid); NM_AVAILABLE_IN_1_16 NMSettingSecretFlags nm_wireguard_peer_get_preshared_key_flags(const NMWireGuardPeer *self); NM_AVAILABLE_IN_1_16 -void nm_wireguard_peer_set_preshared_key_flags(NMWireGuardPeer * self, +void nm_wireguard_peer_set_preshared_key_flags(NMWireGuardPeer *self, NMSettingSecretFlags preshared_key_flags); NM_AVAILABLE_IN_1_16 @@ -84,7 +84,7 @@ NM_AVAILABLE_IN_1_16 void nm_wireguard_peer_clear_allowed_ips(NMWireGuardPeer *self); NM_AVAILABLE_IN_1_16 gboolean nm_wireguard_peer_append_allowed_ip(NMWireGuardPeer *self, - const char * allowed_ip, + const char *allowed_ip, gboolean accept_invalid); NM_AVAILABLE_IN_1_16 gboolean nm_wireguard_peer_remove_allowed_ip(NMWireGuardPeer *self, guint idx); @@ -93,7 +93,7 @@ NM_AVAILABLE_IN_1_16 gboolean nm_wireguard_peer_is_valid(const NMWireGuardPeer *self, gboolean check_non_secrets, gboolean check_secrets, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_16 int nm_wireguard_peer_cmp(const NMWireGuardPeer *a, @@ -168,8 +168,8 @@ NMWireGuardPeer *nm_setting_wireguard_get_peer(NMSettingWireGuard *self, guint i NM_AVAILABLE_IN_1_16 NMWireGuardPeer *nm_setting_wireguard_get_peer_by_public_key(NMSettingWireGuard *self, - const char * public_key, - guint * out_idx); + const char *public_key, + guint *out_idx); NM_AVAILABLE_IN_1_16 void nm_setting_wireguard_set_peer(NMSettingWireGuard *self, NMWireGuardPeer *peer, guint idx); diff --git a/src/libnm-core-public/nm-setting-wireless-security.h b/src/libnm-core-public/nm-setting-wireless-security.h index 9686e7d551..c9aec27da9 100644 --- a/src/libnm-core-public/nm-setting-wireless-security.h +++ b/src/libnm-core-public/nm-setting-wireless-security.h @@ -163,36 +163,36 @@ const char *nm_setting_wireless_security_get_key_mgmt(NMSettingWirelessSecurity guint32 nm_setting_wireless_security_get_num_protos(NMSettingWirelessSecurity *setting); const char *nm_setting_wireless_security_get_proto(NMSettingWirelessSecurity *setting, guint32 i); gboolean nm_setting_wireless_security_add_proto(NMSettingWirelessSecurity *setting, - const char * proto); + const char *proto); void nm_setting_wireless_security_remove_proto(NMSettingWirelessSecurity *setting, guint32 i); gboolean nm_setting_wireless_security_remove_proto_by_value(NMSettingWirelessSecurity *setting, - const char * proto); + const char *proto); void nm_setting_wireless_security_clear_protos(NMSettingWirelessSecurity *setting); guint32 nm_setting_wireless_security_get_num_pairwise(NMSettingWirelessSecurity *setting); const char *nm_setting_wireless_security_get_pairwise(NMSettingWirelessSecurity *setting, guint32 i); gboolean nm_setting_wireless_security_add_pairwise(NMSettingWirelessSecurity *setting, - const char * pairwise); + const char *pairwise); void nm_setting_wireless_security_remove_pairwise(NMSettingWirelessSecurity *setting, guint32 i); gboolean nm_setting_wireless_security_remove_pairwise_by_value(NMSettingWirelessSecurity *setting, - const char * pairwise); + const char *pairwise); void nm_setting_wireless_security_clear_pairwise(NMSettingWirelessSecurity *setting); guint32 nm_setting_wireless_security_get_num_groups(NMSettingWirelessSecurity *setting); const char *nm_setting_wireless_security_get_group(NMSettingWirelessSecurity *setting, guint32 i); gboolean nm_setting_wireless_security_add_group(NMSettingWirelessSecurity *setting, - const char * group); + const char *group); void nm_setting_wireless_security_remove_group(NMSettingWirelessSecurity *setting, guint32 i); gboolean nm_setting_wireless_security_remove_group_by_value(NMSettingWirelessSecurity *setting, - const char * group); + const char *group); void nm_setting_wireless_security_clear_groups(NMSettingWirelessSecurity *setting); NM_AVAILABLE_IN_1_10 NMSettingWirelessSecurityPmf nm_setting_wireless_security_get_pmf(NMSettingWirelessSecurity *setting); -const char * nm_setting_wireless_security_get_psk(NMSettingWirelessSecurity *setting); +const char *nm_setting_wireless_security_get_psk(NMSettingWirelessSecurity *setting); NMSettingSecretFlags nm_setting_wireless_security_get_psk_flags(NMSettingWirelessSecurity *setting); const char *nm_setting_wireless_security_get_leap_username(NMSettingWirelessSecurity *setting); @@ -204,7 +204,7 @@ const char *nm_setting_wireless_security_get_wep_key(NMSettingWirelessSecurity * guint32 idx); void nm_setting_wireless_security_set_wep_key(NMSettingWirelessSecurity *setting, guint32 idx, - const char * key); + const char *key); guint32 nm_setting_wireless_security_get_wep_tx_keyidx(NMSettingWirelessSecurity *setting); const char *nm_setting_wireless_security_get_auth_alg(NMSettingWirelessSecurity *setting); diff --git a/src/libnm-core-public/nm-setting-wireless.h b/src/libnm-core-public/nm-setting-wireless.h index 4451785f16..0d4872fb61 100644 --- a/src/libnm-core-public/nm-setting-wireless.h +++ b/src/libnm-core-public/nm-setting-wireless.h @@ -148,7 +148,7 @@ GType nm_setting_wireless_get_type(void); NMSetting *nm_setting_wireless_new(void); -GBytes * nm_setting_wireless_get_ssid(NMSettingWireless *setting); +GBytes *nm_setting_wireless_get_ssid(NMSettingWireless *setting); const char *nm_setting_wireless_get_mode(NMSettingWireless *setting); const char *nm_setting_wireless_get_band(NMSettingWireless *setting); guint32 nm_setting_wireless_get_channel(NMSettingWireless *setting); @@ -167,7 +167,7 @@ const char *nm_setting_wireless_get_mac_blacklist_item(NMSettingWireless *settin gboolean nm_setting_wireless_add_mac_blacklist_item(NMSettingWireless *setting, const char *mac); void nm_setting_wireless_remove_mac_blacklist_item(NMSettingWireless *setting, guint32 idx); gboolean nm_setting_wireless_remove_mac_blacklist_item_by_value(NMSettingWireless *setting, - const char * mac); + const char *mac); void nm_setting_wireless_clear_mac_blacklist_items(NMSettingWireless *setting); guint32 nm_setting_wireless_get_mtu(NMSettingWireless *setting); @@ -184,7 +184,7 @@ gboolean nm_setting_wireless_add_seen_bssid(NMSettingWireless *setting, const ch guint32 nm_setting_wireless_get_num_seen_bssids(NMSettingWireless *setting); const char *nm_setting_wireless_get_seen_bssid(NMSettingWireless *setting, guint32 i); -gboolean nm_setting_wireless_ap_security_compatible(NMSettingWireless * s_wireless, +gboolean nm_setting_wireless_ap_security_compatible(NMSettingWireless *s_wireless, NMSettingWirelessSecurity *s_wireless_sec, NM80211ApFlags ap_flags, NM80211ApSecurityFlags ap_wpa, diff --git a/src/libnm-core-public/nm-setting.h b/src/libnm-core-public/nm-setting.h index ea2525dc38..ddf648bca2 100644 --- a/src/libnm-core-public/nm-setting.h +++ b/src/libnm-core-public/nm-setting.h @@ -138,8 +138,8 @@ typedef enum { * * Returns: %TRUE to clear the secret, %FALSE to not clear the secret */ -typedef gboolean (*NMSettingClearSecretsWithFlagsFn)(NMSetting * setting, - const char * secret, +typedef gboolean (*NMSettingClearSecretsWithFlagsFn)(NMSetting *setting, + const char *secret, NMSettingSecretFlags flags, gpointer user_data); @@ -156,8 +156,8 @@ struct _NMSettInfoProperty; * @flags: The property's flags, like %NM_SETTING_PARAM_SECRET * @user_data: User data passed to nm_setting_enumerate_values() */ -typedef void (*NMSettingValueIterFn)(NMSetting * setting, - const char * key, +typedef void (*NMSettingValueIterFn)(NMSetting *setting, + const char *key, const GValue *value, GParamFlags flags, gpointer user_data); @@ -202,11 +202,11 @@ typedef enum { NM_SETTING_DIFF_RESULT_IN_B_DEFAULT = 0x00000008, } NMSettingDiffResult; -gboolean nm_setting_diff(NMSetting * a, - NMSetting * b, +gboolean nm_setting_diff(NMSetting *a, + NMSetting *b, NMSettingCompareFlags flags, gboolean invert_results, - GHashTable ** results); + GHashTable **results); void nm_setting_enumerate_values(NMSetting *setting, NMSettingValueIterFn func, gpointer user_data); @@ -214,15 +214,15 @@ char *nm_setting_to_string(NMSetting *setting); /*****************************************************************************/ -gboolean nm_setting_get_secret_flags(NMSetting * setting, - const char * secret_name, +gboolean nm_setting_get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error); + GError **error); -gboolean nm_setting_set_secret_flags(NMSetting * setting, - const char * secret_name, +gboolean nm_setting_set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error); + GError **error); /*****************************************************************************/ @@ -253,7 +253,7 @@ void nm_setting_option_clear_by_name(NMSetting *setting, NMUtilsPredicateStr pre /*****************************************************************************/ -const GVariantType *nm_setting_get_dbus_property_type(NMSetting * setting, +const GVariantType *nm_setting_get_dbus_property_type(NMSetting *setting, const char *property_name); /*****************************************************************************/ diff --git a/src/libnm-core-public/nm-utils.h b/src/libnm-core-public/nm-utils.h index 5100b678a0..0a7c7a8136 100644 --- a/src/libnm-core-public/nm-utils.h +++ b/src/libnm-core-public/nm-utils.h @@ -31,7 +31,7 @@ gboolean nm_utils_same_ssid(const guint8 *ssid1, const guint8 *ssid2, gsize len2, gboolean ignore_trailing_null); -char * nm_utils_ssid_to_utf8(const guint8 *ssid, gsize len); +char *nm_utils_ssid_to_utf8(const guint8 *ssid, gsize len); /** * NMUtilsSecurityType: @@ -86,27 +86,27 @@ gboolean nm_utils_wpa_psk_valid(const char *psk); NM_AVAILABLE_IN_1_6 gboolean nm_utils_is_json_object(const char *str, GError **error); -GVariant * nm_utils_ip4_dns_to_variant(char **dns); -char ** nm_utils_ip4_dns_from_variant(GVariant *value); -GVariant * nm_utils_ip4_addresses_to_variant(GPtrArray *addresses, const char *gateway); +GVariant *nm_utils_ip4_dns_to_variant(char **dns); +char **nm_utils_ip4_dns_from_variant(GVariant *value); +GVariant *nm_utils_ip4_addresses_to_variant(GPtrArray *addresses, const char *gateway); GPtrArray *nm_utils_ip4_addresses_from_variant(GVariant *value, char **out_gateway); -GVariant * nm_utils_ip4_routes_to_variant(GPtrArray *routes); +GVariant *nm_utils_ip4_routes_to_variant(GPtrArray *routes); GPtrArray *nm_utils_ip4_routes_from_variant(GVariant *value); guint32 nm_utils_ip4_netmask_to_prefix(guint32 netmask); guint32 nm_utils_ip4_prefix_to_netmask(guint32 prefix); guint32 nm_utils_ip4_get_default_prefix(guint32 ip); -GVariant * nm_utils_ip6_dns_to_variant(char **dns); -char ** nm_utils_ip6_dns_from_variant(GVariant *value); -GVariant * nm_utils_ip6_addresses_to_variant(GPtrArray *addresses, const char *gateway); +GVariant *nm_utils_ip6_dns_to_variant(char **dns); +char **nm_utils_ip6_dns_from_variant(GVariant *value); +GVariant *nm_utils_ip6_addresses_to_variant(GPtrArray *addresses, const char *gateway); GPtrArray *nm_utils_ip6_addresses_from_variant(GVariant *value, char **out_gateway); -GVariant * nm_utils_ip6_routes_to_variant(GPtrArray *routes); +GVariant *nm_utils_ip6_routes_to_variant(GPtrArray *routes); GPtrArray *nm_utils_ip6_routes_from_variant(GVariant *value); -GVariant * nm_utils_ip_addresses_to_variant(GPtrArray *addresses); +GVariant *nm_utils_ip_addresses_to_variant(GPtrArray *addresses); GPtrArray *nm_utils_ip_addresses_from_variant(GVariant *value, int family); -GVariant * nm_utils_ip_routes_to_variant(GPtrArray *routes); +GVariant *nm_utils_ip_routes_to_variant(GPtrArray *routes); GPtrArray *nm_utils_ip_routes_from_variant(GVariant *value, int family); char *nm_utils_uuid_generate(void); @@ -119,18 +119,18 @@ typedef gboolean (*NMUtilsFileSearchInPathsPredicate)(const char *filename, gpoi struct stat; -typedef gboolean (*NMUtilsCheckFilePredicate)(const char * filename, +typedef gboolean (*NMUtilsCheckFilePredicate)(const char *filename, const struct stat *stat, gpointer user_data, - GError ** error); + GError **error); -const char *nm_utils_file_search_in_paths(const char * progname, - const char * try_first, - const char *const * paths, +const char *nm_utils_file_search_in_paths(const char *progname, + const char *try_first, + const char *const *paths, GFileTest file_test_flags, NMUtilsFileSearchInPathsPredicate predicate, gpointer user_data, - GError ** error); + GError **error); guint32 nm_utils_wifi_freq_to_channel(guint32 freq); guint32 nm_utils_wifi_channel_to_freq(guint32 channel, const char *band); @@ -153,18 +153,18 @@ const char *nm_utils_wifi_strength_bars(guint8 strength); gsize nm_utils_hwaddr_len(int type) G_GNUC_PURE; -char * nm_utils_hwaddr_ntoa(gconstpointer addr, gsize length); +char *nm_utils_hwaddr_ntoa(gconstpointer addr, gsize length); GByteArray *nm_utils_hwaddr_atoba(const char *asc, gsize length); -guint8 * nm_utils_hwaddr_aton(const char *asc, gpointer buffer, gsize length); +guint8 *nm_utils_hwaddr_aton(const char *asc, gpointer buffer, gsize length); gboolean nm_utils_hwaddr_valid(const char *asc, gssize length); -char * nm_utils_hwaddr_canonical(const char *asc, gssize length); +char *nm_utils_hwaddr_canonical(const char *asc, gssize length); gboolean nm_utils_hwaddr_matches(gconstpointer hwaddr1, gssize hwaddr1_len, gconstpointer hwaddr2, gssize hwaddr2_len); -char * nm_utils_bin2hexstr(gconstpointer src, gsize len, int final_len); +char *nm_utils_bin2hexstr(gconstpointer src, gsize len, int final_len); GBytes *nm_utils_hexstr2bin(const char *hex); NM_DEPRECATED_IN_1_6_FOR(nm_utils_is_valid_iface_name) @@ -214,7 +214,7 @@ GHashTable *nm_utils_parse_variant_attributes(const char *string, char key_value_separator, gboolean ignore_unknown, const NMVariantAttributeSpec *const *spec, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_8 char *nm_utils_format_variant_attributes(GHashTable *attributes, diff --git a/src/libnm-core-public/nm-vpn-editor-plugin.h b/src/libnm-core-public/nm-vpn-editor-plugin.h index e25c358e18..4e632244fa 100644 --- a/src/libnm-core-public/nm-vpn-editor-plugin.h +++ b/src/libnm-core-public/nm-vpn-editor-plugin.h @@ -103,9 +103,9 @@ typedef struct { NMConnection *(*import_from_file)(NMVpnEditorPlugin *plugin, const char *path, GError **error); gboolean (*export_to_file)(NMVpnEditorPlugin *plugin, - const char * path, - NMConnection * connection, - GError ** error); + const char *path, + NMConnection *connection, + GError **error); char *(*get_suggested_filename)(NMVpnEditorPlugin *plugin, NMConnection *connection); @@ -117,8 +117,8 @@ typedef struct { GType nm_vpn_editor_plugin_get_type(void); NMVpnEditor *nm_vpn_editor_plugin_get_editor(NMVpnEditorPlugin *plugin, - NMConnection * connection, - GError ** error); + NMConnection *connection, + GError **error); NMVpnEditorPluginCapability nm_vpn_editor_plugin_get_capabilities(NMVpnEditorPlugin *plugin); @@ -126,22 +126,22 @@ NM_AVAILABLE_IN_1_4 gsize nm_vpn_editor_plugin_get_vt(NMVpnEditorPlugin *plugin, NMVpnEditorPluginVT *vt, gsize vt_size); -NMConnection * - nm_vpn_editor_plugin_import(NMVpnEditorPlugin *plugin, const char *path, GError **error); +NMConnection * +nm_vpn_editor_plugin_import(NMVpnEditorPlugin *plugin, const char *path, GError **error); gboolean nm_vpn_editor_plugin_export(NMVpnEditorPlugin *plugin, - const char * path, - NMConnection * connection, - GError ** error); -char * nm_vpn_editor_plugin_get_suggested_filename(NMVpnEditorPlugin *plugin, - NMConnection * connection); + const char *path, + NMConnection *connection, + GError **error); +char *nm_vpn_editor_plugin_get_suggested_filename(NMVpnEditorPlugin *plugin, + NMConnection *connection); NM_AVAILABLE_IN_1_2 -NMVpnEditorPlugin *nm_vpn_editor_plugin_load_from_file(const char * plugin_name, - const char * check_service, +NMVpnEditorPlugin *nm_vpn_editor_plugin_load_from_file(const char *plugin_name, + const char *check_service, int check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error); + GError **error); NM_AVAILABLE_IN_1_4 NMVpnEditorPlugin * diff --git a/src/libnm-core-public/nm-vpn-plugin-info.h b/src/libnm-core-public/nm-vpn-plugin-info.h index 1e9870c88e..aa319a5777 100644 --- a/src/libnm-core-public/nm-vpn-plugin-info.h +++ b/src/libnm-core-public/nm-vpn-plugin-info.h @@ -89,7 +89,7 @@ NMVpnPluginInfo *nm_vpn_plugin_info_list_find_by_service(GSList *list, const cha NM_AVAILABLE_IN_1_4 char *nm_vpn_plugin_info_list_find_service_type(GSList *list, const char *name); NM_AVAILABLE_IN_1_4 -char **nm_vpn_plugin_info_list_get_service_types(GSList * list, +char **nm_vpn_plugin_info_list_get_service_types(GSList *list, gboolean only_existing, gboolean with_abbreviations); diff --git a/src/libnm-glib-aux/nm-c-list.h b/src/libnm-glib-aux/nm-c-list.h index 6dd3ac720f..d89a922307 100644 --- a/src/libnm-glib-aux/nm-c-list.h +++ b/src/libnm-glib-aux/nm-c-list.h @@ -169,7 +169,7 @@ nm_c_list_move_after(CList *lst, CList *elem) G_STMT_START \ { \ CList *const _lst = (lst); \ - type * _elem; \ + type *_elem; \ \ while ((_elem = c_list_first_entry(_lst, type, member))) { \ destroy_fcn(_elem); \ diff --git a/src/libnm-glib-aux/nm-dbus-aux.c b/src/libnm-glib-aux/nm-dbus-aux.c index 454bd2d8c6..0f43ba8e03 100644 --- a/src/libnm-glib-aux/nm-dbus-aux.c +++ b/src/libnm-glib-aux/nm-dbus-aux.c @@ -12,9 +12,9 @@ static void _nm_dbus_connection_call_get_name_owner_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError * error = NULL; - const char * owner = NULL; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + const char *owner = NULL; gpointer orig_user_data; NMDBusConnectionCallGetNameOwnerCb callback; @@ -28,10 +28,10 @@ _nm_dbus_connection_call_get_name_owner_cb(GObject *source, GAsyncResult *res, g } void -nm_dbus_connection_call_get_name_owner(GDBusConnection * dbus_connection, - const char * service_name, +nm_dbus_connection_call_get_name_owner(GDBusConnection *dbus_connection, + const char *service_name, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMDBusConnectionCallGetNameOwnerCb callback, gpointer user_data) { @@ -56,8 +56,8 @@ nm_dbus_connection_call_get_name_owner(GDBusConnection * dbus_c static void _nm_dbus_connection_call_default_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError * error = NULL; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; gpointer orig_user_data; NMDBusConnectionCallDefaultCb callback; @@ -71,12 +71,12 @@ _nm_dbus_connection_call_default_cb(GObject *source, GAsyncResult *res, gpointer } void -nm_dbus_connection_call_get_all(GDBusConnection * dbus_connection, - const char * bus_name, - const char * object_path, - const char * interface_name, +nm_dbus_connection_call_get_all(GDBusConnection *dbus_connection, + const char *bus_name, + const char *object_path, + const char *interface_name, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMDBusConnectionCallDefaultCb callback, gpointer user_data) { @@ -97,14 +97,14 @@ nm_dbus_connection_call_get_all(GDBusConnection * dbus_connection, } void -nm_dbus_connection_call_set(GDBusConnection * dbus_connection, - const char * bus_name, - const char * object_path, - const char * interface_name, - const char * property_name, - GVariant * value, +nm_dbus_connection_call_set(GDBusConnection *dbus_connection, + const char *bus_name, + const char *object_path, + const char *interface_name, + const char *property_name, + GVariant *value, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMDBusConnectionCallDefaultCb callback, gpointer user_data) { @@ -125,13 +125,13 @@ nm_dbus_connection_call_set(GDBusConnection * dbus_connection, /*****************************************************************************/ static void -_nm_dbus_connection_call_get_managed_objects_cb(GObject * source, +_nm_dbus_connection_call_get_managed_objects_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - gs_unref_variant GVariant *ret = NULL; - gs_unref_variant GVariant *arg = NULL; - gs_free_error GError * error = NULL; + gs_unref_variant GVariant *ret = NULL; + gs_unref_variant GVariant *arg = NULL; + gs_free_error GError *error = NULL; gpointer orig_user_data; NMDBusConnectionCallDefaultCb callback; @@ -150,12 +150,12 @@ _nm_dbus_connection_call_get_managed_objects_cb(GObject * source, } void -nm_dbus_connection_call_get_managed_objects(GDBusConnection * dbus_connection, - const char * bus_name, - const char * object_path, +nm_dbus_connection_call_get_managed_objects(GDBusConnection *dbus_connection, + const char *bus_name, + const char *object_path, GDBusCallFlags flags, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMDBusConnectionCallDefaultCb callback, gpointer user_data) { @@ -178,15 +178,15 @@ nm_dbus_connection_call_get_managed_objects(GDBusConnection * dbus_c /*****************************************************************************/ static void -_call_finish_cb(GObject * source, +_call_finish_cb(GObject *source, GAsyncResult *result, gpointer user_data, gboolean return_void, gboolean strip_dbus_error) { - gs_unref_object GTask *task = user_data; + gs_unref_object GTask *task = user_data; gs_unref_variant GVariant *ret = NULL; - GError * error = NULL; + GError *error = NULL; nm_assert(G_IS_DBUS_CONNECTION(source)); nm_assert(G_IS_TASK(user_data)); @@ -230,7 +230,7 @@ nm_dbus_connection_call_finish_void_cb(GObject *source, GAsyncResult *result, gp * is that on error this will first call g_dbus_error_strip_remote_error() on the error. */ void -nm_dbus_connection_call_finish_void_strip_dbus_error_cb(GObject * source, +nm_dbus_connection_call_finish_void_strip_dbus_error_cb(GObject *source, GAsyncResult *result, gpointer user_data) { @@ -259,7 +259,7 @@ nm_dbus_connection_call_finish_variant_cb(GObject *source, GAsyncResult *result, * is that on error this will first call g_dbus_error_strip_remote_error() on the error. */ void -nm_dbus_connection_call_finish_variant_strip_dbus_error_cb(GObject * source, +nm_dbus_connection_call_finish_variant_strip_dbus_error_cb(GObject *source, GAsyncResult *result, gpointer user_data) { @@ -269,12 +269,12 @@ nm_dbus_connection_call_finish_variant_strip_dbus_error_cb(GObject * source, /*****************************************************************************/ typedef struct { - char * bus_name; - char * object_path; - char * interface_name; - char * method_name; - GVariant * parameters; - GDBusConnection * connection; + char *bus_name; + char *object_path; + char *interface_name; + char *method_name; + GVariant *parameters; + GDBusConnection *connection; const GVariantType *reply_type; int timeout_msec; } CallAsyncInfo; @@ -295,8 +295,8 @@ static void call_cb(GObject *source, GAsyncResult *result, gpointer user_data) { gs_unref_object GTask *task = user_data; - GError * error = NULL; - GVariant * ret; + GError *error = NULL; + GVariant *ret; ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (!ret) { @@ -311,9 +311,9 @@ static void call_bus_get_cb(GObject *source, GAsyncResult *result, gpointer user_data) { gs_unref_object GTask *task = user_data; - GCancellable * cancellable; - CallAsyncInfo * info; - GError * error = NULL; + GCancellable *cancellable; + CallAsyncInfo *info; + GError *error = NULL; info = g_task_get_task_data(task); info->connection = g_bus_get_finish(result, &error); @@ -340,18 +340,18 @@ call_bus_get_cb(GObject *source, GAsyncResult *result, gpointer user_data) void nm_dbus_call(GBusType bus_type, - const char * bus_name, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, + const char *bus_name, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, - GCancellable * cancellable, + GCancellable *cancellable, int timeout_msec, GAsyncReadyCallback callback, gpointer user_data) { - GTask * task; + GTask *task; CallAsyncInfo *info; info = g_new(CallAsyncInfo, 1); @@ -385,7 +385,7 @@ gboolean _nm_dbus_error_is(GError *error, ...) { gs_free char *dbus_error = NULL; - const char * name; + const char *name; va_list ap; dbus_error = g_dbus_error_get_remote_error(error); @@ -408,7 +408,7 @@ _nm_dbus_error_is(GError *error, ...) typedef struct { GDBusConnection **p_dbus_connection; - GError ** p_error; + GError **p_error; } BusGetData; static void @@ -433,12 +433,12 @@ _bus_get_cb(GObject *source, GAsyncResult *result, gpointer user_data) GDBusConnection * nm_g_bus_get_blocking(GCancellable *cancellable, GError **error) { - gs_free_error GError *local_error = NULL; + gs_free_error GError *local_error = NULL; gs_unref_object GDBusConnection *dbus_connection = NULL; - GMainContext * main_context = g_main_context_get_thread_default(); + GMainContext *main_context = g_main_context_get_thread_default(); BusGetData data = { - .p_dbus_connection = &dbus_connection, - .p_error = &local_error, + .p_dbus_connection = &dbus_connection, + .p_error = &local_error, }; g_bus_get(G_BUS_TYPE_SYSTEM, cancellable, _bus_get_cb, &data); @@ -471,9 +471,9 @@ nm_dbus_connection_call_blocking_callback(GObject *source, GAsyncResult *res, gp GVariant * nm_dbus_connection_call_blocking(NMDBusConnectionCallBlockingData *data, GError **error) { - GMainContext *main_context = g_main_context_get_thread_default(); - gs_free_error GError *local_error = NULL; - gs_unref_variant GVariant *result = NULL; + GMainContext *main_context = g_main_context_get_thread_default(); + gs_free_error GError *local_error = NULL; + gs_unref_variant GVariant *result = NULL; nm_assert(data); diff --git a/src/libnm-glib-aux/nm-dbus-aux.h b/src/libnm-glib-aux/nm-dbus-aux.h index 420a0c5549..dfba61b0e7 100644 --- a/src/libnm-glib-aux/nm-dbus-aux.h +++ b/src/libnm-glib-aux/nm-dbus-aux.h @@ -30,10 +30,10 @@ typedef void (*NMDBusConnectionCallDefaultCb)(GVariant *result, GError *error, g /*****************************************************************************/ static inline void -nm_dbus_connection_call_start_service_by_name(GDBusConnection * dbus_connection, - const char * name, +nm_dbus_connection_call_start_service_by_name(GDBusConnection *dbus_connection, + const char *name, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -54,8 +54,8 @@ nm_dbus_connection_call_start_service_by_name(GDBusConnection * dbus_connectio /*****************************************************************************/ static inline guint -nm_dbus_connection_signal_subscribe_name_owner_changed(GDBusConnection * dbus_connection, - const char * service_name, +nm_dbus_connection_signal_subscribe_name_owner_changed(GDBusConnection *dbus_connection, + const char *service_name, GDBusSignalCallback callback, gpointer user_data, GDestroyNotify user_data_free_func) @@ -74,22 +74,22 @@ nm_dbus_connection_signal_subscribe_name_owner_changed(GDBusConnection * dbus_ } typedef void (*NMDBusConnectionCallGetNameOwnerCb)(const char *name_owner, - GError * error, + GError *error, gpointer user_data); -void nm_dbus_connection_call_get_name_owner(GDBusConnection * dbus_connection, - const char * service_name, +void nm_dbus_connection_call_get_name_owner(GDBusConnection *dbus_connection, + const char *service_name, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMDBusConnectionCallGetNameOwnerCb callback, gpointer user_data); static inline void -nm_dbus_connection_call_request_name(GDBusConnection * dbus_connection, - const char * name, +nm_dbus_connection_call_request_name(GDBusConnection *dbus_connection, + const char *name, guint32 flags, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -108,10 +108,10 @@ nm_dbus_connection_call_request_name(GDBusConnection * dbus_connection, } static inline guint -nm_dbus_connection_signal_subscribe_properties_changed(GDBusConnection * dbus_connection, - const char * bus_name, - const char * object_path, - const char * interface_name, +nm_dbus_connection_signal_subscribe_properties_changed(GDBusConnection *dbus_connection, + const char *bus_name, + const char *object_path, + const char *interface_name, GDBusSignalCallback callback, gpointer user_data, GDestroyNotify user_data_free_func) @@ -138,33 +138,33 @@ nm_dbus_connection_signal_subscribe_properties_changed(GDBusConnection * dbus_ user_data_free_func); } -void nm_dbus_connection_call_get_all(GDBusConnection * dbus_connection, - const char * bus_name, - const char * object_path, - const char * interface_name, +void nm_dbus_connection_call_get_all(GDBusConnection *dbus_connection, + const char *bus_name, + const char *object_path, + const char *interface_name, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMDBusConnectionCallDefaultCb callback, gpointer user_data); -void nm_dbus_connection_call_set(GDBusConnection * dbus_connection, - const char * bus_name, - const char * object_path, - const char * interface_name, - const char * property_name, - GVariant * value, +void nm_dbus_connection_call_set(GDBusConnection *dbus_connection, + const char *bus_name, + const char *object_path, + const char *interface_name, + const char *property_name, + GVariant *value, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMDBusConnectionCallDefaultCb callback, gpointer user_data); /*****************************************************************************/ static inline guint -nm_dbus_connection_signal_subscribe_object_manager(GDBusConnection * dbus_connection, - const char * service_name, - const char * object_path, - const char * signal_name, +nm_dbus_connection_signal_subscribe_object_manager(GDBusConnection *dbus_connection, + const char *service_name, + const char *object_path, + const char *signal_name, GDBusSignalCallback callback, gpointer user_data, GDestroyNotify user_data_free_func) @@ -181,12 +181,12 @@ nm_dbus_connection_signal_subscribe_object_manager(GDBusConnection * dbus_conn user_data_free_func); } -void nm_dbus_connection_call_get_managed_objects(GDBusConnection * dbus_connection, - const char * bus_name, - const char * object_path, +void nm_dbus_connection_call_get_managed_objects(GDBusConnection *dbus_connection, + const char *bus_name, + const char *object_path, GDBusCallFlags flags, int timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMDBusConnectionCallDefaultCb callback, gpointer user_data); @@ -195,28 +195,28 @@ void nm_dbus_connection_call_get_managed_objects(GDBusConnection * d void nm_dbus_connection_call_finish_void_cb(GObject *source, GAsyncResult *result, gpointer user_data); -void nm_dbus_connection_call_finish_void_strip_dbus_error_cb(GObject * source, +void nm_dbus_connection_call_finish_void_strip_dbus_error_cb(GObject *source, GAsyncResult *result, gpointer user_data); -void nm_dbus_connection_call_finish_variant_cb(GObject * source, +void nm_dbus_connection_call_finish_variant_cb(GObject *source, GAsyncResult *result, gpointer user_data); -void nm_dbus_connection_call_finish_variant_strip_dbus_error_cb(GObject * source, +void nm_dbus_connection_call_finish_variant_strip_dbus_error_cb(GObject *source, GAsyncResult *result, gpointer user_data); /*****************************************************************************/ void nm_dbus_call(GBusType bus_type, - const char * bus_name, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, + const char *bus_name, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, const GVariantType *reply_type, - GCancellable * cancellable, + GCancellable *cancellable, int timeout_msec, GAsyncReadyCallback callback, gpointer user_data); @@ -244,7 +244,7 @@ GDBusConnection *nm_g_bus_get_blocking(GCancellable *cancellable, GError **error typedef struct { GVariant *result; - GError * error; + GError *error; } NMDBusConnectionCallBlockingData; void diff --git a/src/libnm-glib-aux/nm-dedup-multi.c b/src/libnm-glib-aux/nm-dedup-multi.c index f77bb3cd7f..7d451d0d35 100644 --- a/src/libnm-glib-aux/nm-dedup-multi.c +++ b/src/libnm-glib-aux/nm-dedup-multi.c @@ -21,7 +21,7 @@ typedef struct { * always non-NULL. * */ CList lst_entries_sentinel; - const NMDedupMultiObj * obj; + const NMDedupMultiObj *obj; const NMDedupMultiIdxType *idx_type; bool lookup_head; } LookupEntry; @@ -65,9 +65,9 @@ nm_dedup_multi_idx_type_init(NMDedupMultiIdxType *idx_type, const NMDedupMultiId /*****************************************************************************/ static NMDedupMultiEntry * -_entry_lookup_obj(const NMDedupMultiIndex * self, +_entry_lookup_obj(const NMDedupMultiIndex *self, const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj) + const NMDedupMultiObj *obj) { const LookupEntry stack_entry = { .obj = obj, @@ -80,15 +80,15 @@ _entry_lookup_obj(const NMDedupMultiIndex * self, } static NMDedupMultiHeadEntry * -_entry_lookup_head(const NMDedupMultiIndex * self, +_entry_lookup_head(const NMDedupMultiIndex *self, const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj) + const NMDedupMultiObj *obj) { NMDedupMultiHeadEntry *head_entry; const LookupEntry stack_entry = { - .obj = obj, - .idx_type = idx_type, - .lookup_head = TRUE, + .obj = obj, + .idx_type = idx_type, + .lookup_head = TRUE, }; ASSERT_idx_type(idx_type); @@ -108,13 +108,13 @@ _entry_lookup_head(const NMDedupMultiIndex * self, } static void -_entry_unpack(const NMDedupMultiEntry * entry, +_entry_unpack(const NMDedupMultiEntry *entry, const NMDedupMultiIdxType **out_idx_type, - const NMDedupMultiObj ** out_obj, - gboolean * out_lookup_head) + const NMDedupMultiObj **out_obj, + gboolean *out_lookup_head) { const NMDedupMultiHeadEntry *head_entry; - const LookupEntry * lookup_entry; + const LookupEntry *lookup_entry; nm_assert(entry); @@ -162,7 +162,7 @@ static guint _dict_idx_entries_hash(const NMDedupMultiEntry *entry) { const NMDedupMultiIdxType *idx_type; - const NMDedupMultiObj * obj; + const NMDedupMultiObj *obj; gboolean lookup_head; NMHashState h; @@ -185,7 +185,7 @@ static gboolean _dict_idx_entries_equal(const NMDedupMultiEntry *entry_a, const NMDedupMultiEntry *entry_b) { const NMDedupMultiIdxType *idx_type_a, *idx_type_b; - const NMDedupMultiObj * obj_a, *obj_b; + const NMDedupMultiObj *obj_a, *obj_b; gboolean lookup_head_a, lookup_head_b; _entry_unpack(entry_a, &idx_type_a, &obj_a, &lookup_head_a); @@ -203,15 +203,15 @@ _dict_idx_entries_equal(const NMDedupMultiEntry *entry_a, const NMDedupMultiEntr /*****************************************************************************/ static gboolean -_add(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, - const NMDedupMultiObj * obj, - NMDedupMultiEntry * entry, +_add(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, + const NMDedupMultiObj *obj, + NMDedupMultiEntry *entry, NMDedupMultiIdxMode mode, - const NMDedupMultiEntry * entry_order, - NMDedupMultiHeadEntry * head_existing, + const NMDedupMultiEntry *entry_order, + NMDedupMultiHeadEntry *head_existing, const NMDedupMultiEntry **out_entry, - const NMDedupMultiObj ** out_obj_old) + const NMDedupMultiObj **out_obj_old) { NMDedupMultiHeadEntry *head_entry; const NMDedupMultiObj *obj_new, *obj_old; @@ -365,11 +365,11 @@ _add(NMDedupMultiIndex * self, } gboolean -nm_dedup_multi_index_add(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_add(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj, NMDedupMultiIdxMode mode, - const NMDedupMultiEntry ** out_entry, + const NMDedupMultiEntry **out_entry, /* const NMDedupMultiObj ** */ gpointer out_obj_old) { NMDedupMultiEntry *entry; @@ -423,14 +423,14 @@ nm_dedup_multi_index_add(NMDedupMultiIndex * self, * Return: %TRUE if anything changed, %FALSE if nothing changed. */ gboolean -nm_dedup_multi_index_add_full(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_add_full(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj, NMDedupMultiIdxMode mode, - const NMDedupMultiEntry * entry_order, - const NMDedupMultiEntry * entry_existing, - const NMDedupMultiHeadEntry * head_existing, - const NMDedupMultiEntry ** out_entry, + const NMDedupMultiEntry *entry_order, + const NMDedupMultiEntry *entry_existing, + const NMDedupMultiHeadEntry *head_existing, + const NMDedupMultiEntry **out_entry, /* const NMDedupMultiObj ** */ gpointer out_obj_old) { NMDedupMultiEntry *entry; @@ -472,7 +472,7 @@ _remove_entry(NMDedupMultiIndex *self, NMDedupMultiEntry *entry, gboolean *out_h { const NMDedupMultiObj *obj; NMDedupMultiHeadEntry *head_entry; - NMDedupMultiIdxType * idx_type; + NMDedupMultiIdxType *idx_type; nm_assert(self); nm_assert(entry); @@ -519,14 +519,14 @@ _remove_entry(NMDedupMultiIndex *self, NMDedupMultiEntry *entry, gboolean *out_h } static guint -_remove_head(NMDedupMultiIndex * self, +_remove_head(NMDedupMultiIndex *self, NMDedupMultiHeadEntry *head_entry, gboolean remove_all /* otherwise just dirty ones */, gboolean mark_survivors_dirty) { guint n; gboolean head_entry_removed; - CList * iter_entry, *iter_entry_safe; + CList *iter_entry, *iter_entry_safe; nm_assert(self); nm_assert(head_entry); @@ -552,7 +552,7 @@ _remove_head(NMDedupMultiIndex * self, } static guint -_remove_idx_entry(NMDedupMultiIndex * self, +_remove_idx_entry(NMDedupMultiIndex *self, NMDedupMultiIdxType *idx_type, gboolean remove_all /* otherwise just dirty ones */, gboolean mark_survivors_dirty) @@ -588,8 +588,8 @@ nm_dedup_multi_index_remove_entry(NMDedupMultiIndex *self, gconstpointer entry) } guint -nm_dedup_multi_index_remove_obj(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_remove_obj(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj, /*const NMDedupMultiObj ** */ gconstpointer *out_obj) { @@ -611,8 +611,8 @@ nm_dedup_multi_index_remove_obj(NMDedupMultiIndex * sel } guint -nm_dedup_multi_index_remove_head(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_remove_head(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj) { const NMDedupMultiHeadEntry *entry; @@ -643,8 +643,8 @@ nm_dedup_multi_index_remove_idx(NMDedupMultiIndex *self, NMDedupMultiIdxType *id * Returns: the cache entry or %NULL if the entry wasn't found. */ const NMDedupMultiEntry * -nm_dedup_multi_index_lookup_obj(const NMDedupMultiIndex * self, - const NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_lookup_obj(const NMDedupMultiIndex *self, + const NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj) { g_return_val_if_fail(self, FALSE); @@ -669,8 +669,8 @@ nm_dedup_multi_index_lookup_obj(const NMDedupMultiIndex * self, * Returns: the cache entry or %NULL if the entry wasn't found. */ const NMDedupMultiHeadEntry * -nm_dedup_multi_index_lookup_head(const NMDedupMultiIndex * self, - const NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_lookup_head(const NMDedupMultiIndex *self, + const NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj) { g_return_val_if_fail(self, FALSE); @@ -682,12 +682,12 @@ nm_dedup_multi_index_lookup_head(const NMDedupMultiIndex * self /*****************************************************************************/ void -nm_dedup_multi_index_dirty_set_head(NMDedupMultiIndex * self, - const NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_dirty_set_head(NMDedupMultiIndex *self, + const NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj) { NMDedupMultiHeadEntry *head_entry; - CList * iter_entry; + CList *iter_entry; g_return_if_fail(self); g_return_if_fail(idx_type); @@ -740,7 +740,7 @@ nm_dedup_multi_index_dirty_set_idx(NMDedupMultiIndex *self, const NMDedupMultiId * Returns: number of deleted entries. */ guint -nm_dedup_multi_index_dirty_remove_idx(NMDedupMultiIndex * self, +nm_dedup_multi_index_dirty_remove_idx(NMDedupMultiIndex *self, NMDedupMultiIdxType *idx_type, gboolean mark_survivors_dirty) { @@ -770,7 +770,7 @@ _dict_idx_objs_equal(const NMDedupMultiObj *obj_a, const NMDedupMultiObj *obj_b) } void -nm_dedup_multi_index_obj_release(NMDedupMultiIndex * self, +nm_dedup_multi_index_obj_release(NMDedupMultiIndex *self, /* const NMDedupMultiObj * */ gconstpointer obj) { nm_assert(self); @@ -784,7 +784,7 @@ nm_dedup_multi_index_obj_release(NMDedupMultiIndex * sel } gconstpointer -nm_dedup_multi_index_obj_find(NMDedupMultiIndex * self, +nm_dedup_multi_index_obj_find(NMDedupMultiIndex *self, /* const NMDedupMultiObj * */ gconstpointer obj) { g_return_val_if_fail(self, NULL); @@ -794,7 +794,7 @@ nm_dedup_multi_index_obj_find(NMDedupMultiIndex * self, } gconstpointer -nm_dedup_multi_index_obj_intern(NMDedupMultiIndex * self, +nm_dedup_multi_index_obj_intern(NMDedupMultiIndex *self, /* const NMDedupMultiObj * */ gconstpointer obj) { const NMDedupMultiObj *obj_new = obj; @@ -885,13 +885,13 @@ nm_dedup_multi_obj_clone(const NMDedupMultiObj *obj) } gconstpointer * -nm_dedup_multi_objs_to_array_head(const NMDedupMultiHeadEntry * head_entry, +nm_dedup_multi_objs_to_array_head(const NMDedupMultiHeadEntry *head_entry, NMDedupMultiFcnSelectPredicate predicate, gpointer user_data, - guint * out_len) + guint *out_len) { gconstpointer *result; - CList * iter; + CList *iter; guint i; if (!head_entry) { @@ -923,12 +923,12 @@ nm_dedup_multi_objs_to_array_head(const NMDedupMultiHeadEntry * head_entry, } GPtrArray * -nm_dedup_multi_objs_to_ptr_array_head(const NMDedupMultiHeadEntry * head_entry, +nm_dedup_multi_objs_to_ptr_array_head(const NMDedupMultiHeadEntry *head_entry, NMDedupMultiFcnSelectPredicate predicate, gpointer user_data) { GPtrArray *result; - CList * iter; + CList *iter; if (!head_entry) return NULL; @@ -1028,8 +1028,8 @@ nm_dedup_multi_index_unref(NMDedupMultiIndex *self) { GHashTableIter iter; const NMDedupMultiIdxType *idx_type; - NMDedupMultiEntry * entry; - const NMDedupMultiObj * obj; + NMDedupMultiEntry *entry; + const NMDedupMultiObj *obj; g_return_val_if_fail(self, NULL); g_return_val_if_fail(self->ref_count > 0, NULL); diff --git a/src/libnm-glib-aux/nm-dedup-multi.h b/src/libnm-glib-aux/nm-dedup-multi.h index fb1cb86340..0fa47422a3 100644 --- a/src/libnm-glib-aux/nm-dedup-multi.h +++ b/src/libnm-glib-aux/nm-dedup-multi.h @@ -83,14 +83,14 @@ void nm_dedup_multi_obj_unref(const NMDedupMultiObj *obj); const NMDedupMultiObj *nm_dedup_multi_obj_clone(const NMDedupMultiObj *obj); gboolean nm_dedup_multi_obj_needs_clone(const NMDedupMultiObj *obj); -gconstpointer nm_dedup_multi_index_obj_intern(NMDedupMultiIndex * self, +gconstpointer nm_dedup_multi_index_obj_intern(NMDedupMultiIndex *self, /* const NMDedupMultiObj * */ gconstpointer obj); -void nm_dedup_multi_index_obj_release(NMDedupMultiIndex * self, +void nm_dedup_multi_index_obj_release(NMDedupMultiIndex *self, /* const NMDedupMultiObj * */ gconstpointer obj); /* const NMDedupMultiObj * */ gconstpointer -nm_dedup_multi_index_obj_find(NMDedupMultiIndex * self, +nm_dedup_multi_index_obj_find(NMDedupMultiIndex *self, /* const NMDedupMultiObj * */ gconstpointer obj); /*****************************************************************************/ @@ -132,18 +132,18 @@ struct _NMDedupMultiIdxType { guint len; }; -void nm_dedup_multi_idx_type_init(NMDedupMultiIdxType * idx_type, +void nm_dedup_multi_idx_type_init(NMDedupMultiIdxType *idx_type, const NMDedupMultiIdxTypeClass *klass); struct _NMDedupMultiIdxTypeClass { NMObjBaseClass parent; void (*idx_obj_id_hash_update)(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - struct _NMHashState * h); + const NMDedupMultiObj *obj, + struct _NMHashState *h); gboolean (*idx_obj_id_equal)(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b); + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b); /* an NMDedupMultiIdxTypeClass which implements partitioning of the * tracked objects, must implement the idx_obj_partition*() functions. @@ -153,17 +153,17 @@ struct _NMDedupMultiIdxTypeClass { * routes that don't have a valid ifindex. If the idx-type says that the * object is not partitionable, it is never added to the NMDedupMultiIndex. */ gboolean (*idx_obj_partitionable)(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj); + const NMDedupMultiObj *obj); void (*idx_obj_partition_hash_update)(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - struct _NMHashState * h); + const NMDedupMultiObj *obj, + struct _NMHashState *h); gboolean (*idx_obj_partition_equal)(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b); + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b); }; static inline gboolean -nm_dedup_multi_idx_type_id_equal(const NMDedupMultiIdxType * idx_type, +nm_dedup_multi_idx_type_id_equal(const NMDedupMultiIdxType *idx_type, /* const NMDedupMultiObj * */ gconstpointer obj_a, /* const NMDedupMultiObj * */ gconstpointer obj_b) { @@ -172,7 +172,7 @@ nm_dedup_multi_idx_type_id_equal(const NMDedupMultiIdxType * idx } static inline gboolean -nm_dedup_multi_idx_type_partition_equal(const NMDedupMultiIdxType * idx_type, +nm_dedup_multi_idx_type_partition_equal(const NMDedupMultiIdxType *idx_type, /* const NMDedupMultiObj * */ gconstpointer obj_a, /* const NMDedupMultiObj * */ gconstpointer obj_b) { @@ -255,54 +255,54 @@ _nm_auto_unref_dedup_multi_index(NMDedupMultiIndex **v) #define NM_DEDUP_MULTI_ENTRY_MISSING ((const NMDedupMultiEntry *) GUINT_TO_POINTER(1)) #define NM_DEDUP_MULTI_HEAD_ENTRY_MISSING ((const NMDedupMultiHeadEntry *) GUINT_TO_POINTER(1)) -gboolean nm_dedup_multi_index_add_full(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, +gboolean nm_dedup_multi_index_add_full(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj, NMDedupMultiIdxMode mode, - const NMDedupMultiEntry * entry_order, - const NMDedupMultiEntry * entry_existing, - const NMDedupMultiHeadEntry * head_existing, - const NMDedupMultiEntry ** out_entry, + const NMDedupMultiEntry *entry_order, + const NMDedupMultiEntry *entry_existing, + const NMDedupMultiHeadEntry *head_existing, + const NMDedupMultiEntry **out_entry, /* const NMDedupMultiObj ** */ gpointer out_obj_old); -gboolean nm_dedup_multi_index_add(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, +gboolean nm_dedup_multi_index_add(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj, NMDedupMultiIdxMode mode, - const NMDedupMultiEntry ** out_entry, + const NMDedupMultiEntry **out_entry, /* const NMDedupMultiObj ** */ gpointer out_obj_old); const NMDedupMultiEntry * -nm_dedup_multi_index_lookup_obj(const NMDedupMultiIndex * self, - const NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_lookup_obj(const NMDedupMultiIndex *self, + const NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj); const NMDedupMultiHeadEntry * -nm_dedup_multi_index_lookup_head(const NMDedupMultiIndex * self, - const NMDedupMultiIdxType * idx_type, +nm_dedup_multi_index_lookup_head(const NMDedupMultiIndex *self, + const NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj); guint nm_dedup_multi_index_remove_entry(NMDedupMultiIndex *self, gconstpointer entry); -guint nm_dedup_multi_index_remove_obj(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, +guint nm_dedup_multi_index_remove_obj(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj, /*const NMDedupMultiObj ** */ gconstpointer *out_obj); -guint nm_dedup_multi_index_remove_head(NMDedupMultiIndex * self, - NMDedupMultiIdxType * idx_type, +guint nm_dedup_multi_index_remove_head(NMDedupMultiIndex *self, + NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj); guint nm_dedup_multi_index_remove_idx(NMDedupMultiIndex *self, NMDedupMultiIdxType *idx_type); -void nm_dedup_multi_index_dirty_set_head(NMDedupMultiIndex * self, - const NMDedupMultiIdxType * idx_type, +void nm_dedup_multi_index_dirty_set_head(NMDedupMultiIndex *self, + const NMDedupMultiIdxType *idx_type, /*const NMDedupMultiObj * */ gconstpointer obj); -void nm_dedup_multi_index_dirty_set_idx(NMDedupMultiIndex * self, +void nm_dedup_multi_index_dirty_set_idx(NMDedupMultiIndex *self, const NMDedupMultiIdxType *idx_type); -guint nm_dedup_multi_index_dirty_remove_idx(NMDedupMultiIndex * self, +guint nm_dedup_multi_index_dirty_remove_idx(NMDedupMultiIndex *self, NMDedupMultiIdxType *idx_type, gboolean mark_survivors_dirty); @@ -395,11 +395,11 @@ nm_dedup_multi_iter_prev(NMDedupMultiIter *iter) typedef gboolean (*NMDedupMultiFcnSelectPredicate)(/* const NMDedupMultiObj * */ gconstpointer obj, gpointer user_data); -gconstpointer *nm_dedup_multi_objs_to_array_head(const NMDedupMultiHeadEntry * head_entry, +gconstpointer *nm_dedup_multi_objs_to_array_head(const NMDedupMultiHeadEntry *head_entry, NMDedupMultiFcnSelectPredicate predicate, gpointer user_data, - guint * out_len); -GPtrArray * nm_dedup_multi_objs_to_ptr_array_head(const NMDedupMultiHeadEntry * head_entry, + guint *out_len); +GPtrArray *nm_dedup_multi_objs_to_ptr_array_head(const NMDedupMultiHeadEntry *head_entry, NMDedupMultiFcnSelectPredicate predicate, gpointer user_data); diff --git a/src/libnm-glib-aux/nm-enum-utils.c b/src/libnm-glib-aux/nm-enum-utils.c index f97cdfcbb5..3b9b7e8d13 100644 --- a/src/libnm-glib-aux/nm-enum-utils.c +++ b/src/libnm-glib-aux/nm-enum-utils.c @@ -17,7 +17,7 @@ _ASSERT_enum_values_info(GType type, const NMUtilsEnumValueInfo *value_infos) { #if NM_MORE_ASSERTS > 5 nm_auto_unref_gtypeclass GTypeClass *klass = NULL; - gs_unref_hashtable GHashTable *ht = NULL; + gs_unref_hashtable GHashTable *ht = NULL; klass = g_type_class_ref(type); @@ -109,7 +109,7 @@ _enum_is_valid_flags_nick(const char *str) char * _nm_utils_enum_to_str_full(GType type, int value, - const char * flags_separator, + const char *flags_separator, const NMUtilsEnumValueInfo *value_infos) { nm_auto_unref_gtypeclass GTypeClass *klass = NULL; @@ -199,18 +199,18 @@ _find_value_info(const NMUtilsEnumValueInfo *value_infos, const char *needle) gboolean _nm_utils_enum_from_str_full(GType type, - const char * str, - int * out_value, - char ** err_token, + const char *str, + int *out_value, + char **err_token, const NMUtilsEnumValueInfo *value_infos) { nm_auto_unref_gtypeclass GTypeClass *klass = NULL; gboolean ret = FALSE; int value = 0; - gs_free char * str_clone = NULL; - char * s; + gs_free char *str_clone = NULL; + char *s; gint64 v64; - const NMUtilsEnumValueInfo * nick; + const NMUtilsEnumValueInfo *nick; g_return_val_if_fail(str, FALSE); @@ -317,7 +317,7 @@ const char ** _nm_utils_enum_get_values(GType type, int from, int to) { GTypeClass *klass; - GPtrArray * array; + GPtrArray *array; int i; char sbuf[64]; diff --git a/src/libnm-glib-aux/nm-enum-utils.h b/src/libnm-glib-aux/nm-enum-utils.h index 89be54e77f..6478cadfd8 100644 --- a/src/libnm-glib-aux/nm-enum-utils.h +++ b/src/libnm-glib-aux/nm-enum-utils.h @@ -15,14 +15,14 @@ typedef struct _NMUtilsEnumValueInfo { int value; } NMUtilsEnumValueInfo; -char * _nm_utils_enum_to_str_full(GType type, +char *_nm_utils_enum_to_str_full(GType type, int value, - const char * sep, + const char *sep, const NMUtilsEnumValueInfo *value_infos); gboolean _nm_utils_enum_from_str_full(GType type, - const char * str, - int * out_value, - char ** err_token, + const char *str, + int *out_value, + char **err_token, const NMUtilsEnumValueInfo *value_infos); const char **_nm_utils_enum_get_values(GType type, int from, int to); diff --git a/src/libnm-glib-aux/nm-errno.c b/src/libnm-glib-aux/nm-errno.c index 0426a21d40..14d93d64c9 100644 --- a/src/libnm-glib-aux/nm-errno.c +++ b/src/libnm-glib-aux/nm-errno.c @@ -156,7 +156,7 @@ const char * nm_strerror_native(int errsv) { static _nm_thread_local char *buf_static = NULL; - char * buf; + char *buf; buf = buf_static; if (G_UNLIKELY(!buf)) { diff --git a/src/libnm-glib-aux/nm-glib.h b/src/libnm-glib-aux/nm-glib.h index 49470d9216..4ab9cbbda8 100644 --- a/src/libnm-glib-aux/nm-glib.h +++ b/src/libnm-glib-aux/nm-glib.h @@ -195,7 +195,7 @@ __nmtst_g_test_skip(const char *msg) /* g_test_add_data_func_full() is only available since glib 2.34. Add a compatibility wrapper. */ static inline void -__g_test_add_data_func_full(const char * testpath, +__g_test_add_data_func_full(const char *testpath, gpointer test_data, GTestDataFunc test_func, GDestroyNotify data_free_func) @@ -311,7 +311,7 @@ _nm_g_ptr_array_insert(GPtrArray *array, int index_, gpointer data) static inline gboolean _g_key_file_save_to_file(GKeyFile *key_file, const char *filename, GError **error) { - char * contents; + char *contents; gboolean success; gsize length; @@ -484,7 +484,7 @@ _nm_g_variant_new_take_string(char *string) #if !GLIB_CHECK_VERSION(2, 38, 0) _nm_printf(1, 2) static inline GVariant *_nm_g_variant_new_printf(const char *format_string, ...) { - char * string; + char *string; va_list ap; g_return_val_if_fail(format_string, NULL); @@ -650,10 +650,10 @@ _g_atomic_pointer_compare_and_exchange(void **atomic, void *oldval, void *newval #if !GLIB_CHECK_VERSION(2, 58, 0) static inline gboolean -g_hash_table_steal_extended(GHashTable * hash_table, +g_hash_table_steal_extended(GHashTable *hash_table, gconstpointer lookup_key, - gpointer * stolen_key, - gpointer * stolen_value) + gpointer *stolen_key, + gpointer *stolen_value) { g_assert(stolen_key); g_assert(stolen_value); diff --git a/src/libnm-glib-aux/nm-hash-utils.c b/src/libnm-glib-aux/nm-hash-utils.c index a6949ebd32..5cfc3d4ad5 100644 --- a/src/libnm-glib-aux/nm-hash-utils.c +++ b/src/libnm-glib-aux/nm-hash-utils.c @@ -257,7 +257,7 @@ nm_ppdirect_equal(gconstpointer a, gconstpointer b) guint nm_g_bytes_hash(gconstpointer p) { - GBytes * ptr = (GBytes *) p; + GBytes *ptr = (GBytes *) p; gconstpointer arr; gsize len; diff --git a/src/libnm-glib-aux/nm-io-utils.c b/src/libnm-glib-aux/nm-io-utils.c index 85a81f69bc..503f044f30 100644 --- a/src/libnm-glib-aux/nm-io-utils.c +++ b/src/libnm-glib-aux/nm-io-utils.c @@ -20,9 +20,9 @@ /*****************************************************************************/ -_nm_printf(4, 5) static int _get_contents_error(GError ** error, +_nm_printf(4, 5) static int _get_contents_error(GError **error, int errsv, - int * out_errsv, + int *out_errsv, const char *format, ...) { @@ -94,14 +94,14 @@ nm_utils_fd_get_contents(int fd, gboolean close_fd, gsize max_length, NMUtilsFileGetContentsFlags flags, - char ** contents, - gsize * length, - int * out_errsv, - GError ** error) + char **contents, + gsize *length, + int *out_errsv, + GError **error) { nm_auto_close int fd_keeper = close_fd ? fd : -1; struct stat stat_buf; - gs_free char * str = NULL; + gs_free char *str = NULL; const bool do_bzero_mem = NM_FLAGS_HAS(flags, NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET); int errsv; @@ -288,13 +288,13 @@ nm_utils_fd_get_contents(int fd, */ gboolean nm_utils_file_get_contents(int dirfd, - const char * filename, + const char *filename, gsize max_length, NMUtilsFileGetContentsFlags flags, - char ** contents, - gsize * length, - int * out_errsv, - GError ** error) + char **contents, + gsize *length, + int *out_errsv, + GError **error) { int fd; @@ -338,13 +338,13 @@ nm_utils_file_get_contents(int dirfd, * and last modification times. */ gboolean -nm_utils_file_set_contents(const char * filename, - const char * contents, +nm_utils_file_set_contents(const char *filename, + const char *contents, gssize length, mode_t mode, const struct timespec *times, - int * out_errsv, - GError ** error) + int *out_errsv, + GError **error) { gs_free char *tmp_name = NULL; struct stat statbuf; @@ -498,7 +498,7 @@ nm_utils_fd_read(int fd, NMStrBuf *out_string) typedef struct { GSubprocess *subprocess; - GSource * timeout_source; + GSource *timeout_source; } SubprocessTerminateData; static void @@ -527,7 +527,7 @@ void nm_g_subprocess_terminate_in_background(GSubprocess *subprocess, int timeout_msec_before_kill) { SubprocessTerminateData *term_data; - GMainContext * main_context; + GMainContext *main_context; nm_assert(timeout_msec_before_kill > 0); @@ -573,9 +573,9 @@ char ** nm_utils_find_mkstemp_files(const char *dirname, const char *filename) { static const char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - DIR * dir; - struct dirent * entry; - GPtrArray * arr = NULL; + DIR *dir; + struct dirent *entry; + GPtrArray *arr = NULL; gsize l; /* We write files with g_file_set_contents() and nm_utils_file_set_contents(). @@ -685,12 +685,12 @@ nm_sd_notify(const char *state) struct sockaddr_un sockaddr; struct iovec iovec; struct msghdr msghdr = { - .msg_iov = &iovec, - .msg_iovlen = 1, - .msg_name = &sockaddr, + .msg_iov = &iovec, + .msg_iovlen = 1, + .msg_name = &sockaddr, }; nm_auto_close int fd = -1; - const char * e; + const char *e; int r; if (!state) diff --git a/src/libnm-glib-aux/nm-io-utils.h b/src/libnm-glib-aux/nm-io-utils.h index 479d0e5100..a850398679 100644 --- a/src/libnm-glib-aux/nm-io-utils.h +++ b/src/libnm-glib-aux/nm-io-utils.h @@ -26,27 +26,27 @@ gboolean nm_utils_fd_get_contents(int fd, gboolean close_fd, gsize max_length, NMUtilsFileGetContentsFlags flags, - char ** contents, - gsize * length, - int * out_errsv, - GError ** error); + char **contents, + gsize *length, + int *out_errsv, + GError **error); gboolean nm_utils_file_get_contents(int dirfd, - const char * filename, + const char *filename, gsize max_length, NMUtilsFileGetContentsFlags flags, - char ** contents, - gsize * length, - int * out_errsv, - GError ** error); + char **contents, + gsize *length, + int *out_errsv, + GError **error); -gboolean nm_utils_file_set_contents(const char * filename, - const char * contents, +gboolean nm_utils_file_set_contents(const char *filename, + const char *contents, gssize length, mode_t mode, const struct timespec *times, - int * out_errsv, - GError ** error); + int *out_errsv, + GError **error); struct _NMStrBuf; diff --git a/src/libnm-glib-aux/nm-json-aux.c b/src/libnm-glib-aux/nm-json-aux.c index 0a3b25f8e3..6216d93cd1 100644 --- a/src/libnm-glib-aux/nm-json-aux.c +++ b/src/libnm-glib-aux/nm-json-aux.c @@ -155,15 +155,15 @@ nm_json_gstr_append_obj_name(GString *gstr, const char *key, char start_containe typedef struct { NMJsonVt vt; - void * dl_handle; + void *dl_handle; } NMJsonVtInternal; static NMJsonVtInternal * _nm_json_vt_internal_load(void) { NMJsonVtInternal *v; - const char * soname; - void * handle; + const char *soname; + void *handle; v = g_new0(NMJsonVtInternal, 1); diff --git a/src/libnm-glib-aux/nm-json-aux.h b/src/libnm-glib-aux/nm-json-aux.h index 088d67a9c3..275ed7709a 100644 --- a/src/libnm-glib-aux/nm-json-aux.h +++ b/src/libnm-glib-aux/nm-json-aux.h @@ -399,7 +399,7 @@ nm_value_type_to_json(NMValueType value_type, GString *gstr, gconstpointer p_fie } static inline gboolean -nm_value_type_from_json(const NMJsonVt * vt, +nm_value_type_from_json(const NMJsonVt *vt, NMValueType value_type, const nm_json_t *elem, gpointer out_val) diff --git a/src/libnm-glib-aux/nm-keyfile-aux.c b/src/libnm-glib-aux/nm-keyfile-aux.c index 9cda1cf714..1cae28b49a 100644 --- a/src/libnm-glib-aux/nm-keyfile-aux.c +++ b/src/libnm-glib-aux/nm-keyfile-aux.c @@ -19,8 +19,8 @@ struct _NMKeyFileDB { NMKeyFileDBLogFcn log_fcn; NMKeyFileDBGotDirtyFcn got_dirty_fcn; gpointer user_data; - const char * group_name; - GKeyFile * kf; + const char *group_name; + GKeyFile *kf; guint ref_count; bool is_started : 1; @@ -77,8 +77,8 @@ _key_file_new(void) /*****************************************************************************/ NMKeyFileDB * -nm_key_file_db_new(const char * filename, - const char * group_name, +nm_key_file_db_new(const char *filename, + const char *group_name, NMKeyFileDBLogFcn log_fcn, NMKeyFileDBGotDirtyFcn got_dirty_fcn, gpointer user_data) @@ -175,8 +175,8 @@ nm_key_file_db_destroy(NMKeyFileDB *self) void nm_key_file_db_start(NMKeyFileDB *self) { - gs_free char *contents = NULL; - gsize contents_len; + gs_free char *contents = NULL; + gsize contents_len; gs_free_error GError *error = NULL; g_return_if_fail(_IS_KEY_FILE_DB(self, FALSE, FALSE)); @@ -309,7 +309,7 @@ nm_key_file_db_set_value(NMKeyFileDB *self, const char *key, const char *value) if (!self->dirty && !got_dirty) { gs_free_error GError *error = NULL; - gs_free char * new_value = NULL; + gs_free char *new_value = NULL; new_value = g_key_file_get_value(self->kf, self->group_name, key, &error); if (error || !new_value || !nm_streq0(old_value, new_value)) @@ -321,8 +321,8 @@ nm_key_file_db_set_value(NMKeyFileDB *self, const char *key, const char *value) } void -nm_key_file_db_set_string_list(NMKeyFileDB * self, - const char * key, +nm_key_file_db_set_string_list(NMKeyFileDB *self, + const char *key, const char *const *value, gssize len) { @@ -352,7 +352,7 @@ nm_key_file_db_set_string_list(NMKeyFileDB * self, if (!self->dirty && !got_dirty) { gs_free_error GError *error = NULL; - gs_free char * new_value = NULL; + gs_free char *new_value = NULL; new_value = g_key_file_get_value(self->kf, self->group_name, key, &error); if (error || !new_value || !nm_streq0(old_value, new_value)) @@ -388,8 +388,8 @@ nm_key_file_db_to_file(NMKeyFileDB *self, gboolean force) void nm_key_file_db_prune_tmp_files(NMKeyFileDB *self) { - gs_free char * n_file = NULL; - gs_free char * n_dir = NULL; + gs_free char *n_file = NULL; + gs_free char *n_dir = NULL; gs_strfreev char **tmpfiles = NULL; gsize i; @@ -401,7 +401,7 @@ nm_key_file_db_prune_tmp_files(NMKeyFileDB *self) return; for (i = 0; tmpfiles[i]; i++) { - const char * tmpfile = tmpfiles[i]; + const char *tmpfile = tmpfiles[i]; gs_free char *full_file = NULL; int r; @@ -430,10 +430,10 @@ nm_key_file_db_prune(NMKeyFileDB *self, gboolean (*predicate)(const char *key, gpointer user_data), gpointer user_data) { - gs_strfreev char ** keys = NULL; + gs_strfreev char **keys = NULL; nm_auto_unref_keyfile GKeyFile *kf_to_free = NULL; - GKeyFile * kf_src = NULL; - GKeyFile * kf_dst = NULL; + GKeyFile *kf_src = NULL; + GKeyFile *kf_dst = NULL; guint k; g_return_if_fail(_IS_KEY_FILE_DB(self, TRUE, FALSE)); diff --git a/src/libnm-glib-aux/nm-keyfile-aux.h b/src/libnm-glib-aux/nm-keyfile-aux.h index e756c57a84..7ada402996 100644 --- a/src/libnm-glib-aux/nm-keyfile-aux.h +++ b/src/libnm-glib-aux/nm-keyfile-aux.h @@ -13,13 +13,13 @@ typedef struct _NMKeyFileDB NMKeyFileDB; typedef void (*NMKeyFileDBLogFcn)(NMKeyFileDB *self, int syslog_level, gpointer user_data, - const char * fmt, + const char *fmt, ...) G_GNUC_PRINTF(4, 5); typedef void (*NMKeyFileDBGotDirtyFcn)(NMKeyFileDB *self, gpointer user_data); -NMKeyFileDB *nm_key_file_db_new(const char * filename, - const char * group, +NMKeyFileDB *nm_key_file_db_new(const char *filename, + const char *group, NMKeyFileDBLogFcn log_fcn, NMKeyFileDBGotDirtyFcn got_dirty_fcn, gpointer user_data); @@ -43,8 +43,8 @@ void nm_key_file_db_remove_key(NMKeyFileDB *self, const char *key); void nm_key_file_db_set_value(NMKeyFileDB *self, const char *key, const char *value); -void nm_key_file_db_set_string_list(NMKeyFileDB * self, - const char * key, +void nm_key_file_db_set_string_list(NMKeyFileDB *self, + const char *key, const char *const *value, gssize len); diff --git a/src/libnm-glib-aux/nm-logging-base.c b/src/libnm-glib-aux/nm-logging-base.c index cc19ef15db..5195cbb798 100644 --- a/src/libnm-glib-aux/nm-logging-base.c +++ b/src/libnm-glib-aux/nm-logging-base.c @@ -104,8 +104,8 @@ _nm_log_simple_printf(NMLogLevel level, const char *fmt, ...) { gs_free char *msg_heap = NULL; char msg_stack[700]; - const char * msg; - const char * level_str; + const char *msg; + const char *level_str; gint64 ts; ts = nm_utils_clock_gettime_nsec(CLOCK_BOOTTIME); diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index e7ee7f38ab..0950f3ae85 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -137,7 +137,7 @@ static inline void _nm_auto_freev(gpointer ptr) { gpointer **p = ptr; - gpointer * _ptr; + gpointer *_ptr; if (*p) { for (_ptr = *p; *_ptr; _ptr++) @@ -552,12 +552,12 @@ nm_str_realloc(char *str) #define NM_GOBJECT_PROPERTIES_DEFINE_NOTIFY(suffix, obj_type) \ static inline void _nm_gobject_notify_together_impl##suffix( \ - obj_type * obj, \ + obj_type *obj, \ guint n, \ const _PropertyEnums##suffix *props) \ { \ GObject *const gobj = (GObject *) obj; \ - GParamSpec * pspec_first = NULL; \ + GParamSpec *pspec_first = NULL; \ gboolean frozen = FALSE; \ \ nm_assert(G_IS_OBJECT(obj)); \ @@ -565,7 +565,7 @@ nm_str_realloc(char *str) \ while (n-- > 0) { \ const _PropertyEnums##suffix prop = *props++; \ - GParamSpec * pspec; \ + GParamSpec *pspec; \ \ if (prop == PROP_0##suffix) \ continue; \ @@ -1040,7 +1040,7 @@ nm_g_variant_equal(GVariant *a, GVariant *b) #define nm_str_skip_leading_spaces(str) \ ({ \ - typeof(*(str)) * _str_sls = (str); \ + typeof(*(str)) *_str_sls = (str); \ _nm_unused const char *const _str_type_check = _str_sls; \ \ if (_str_sls) { \ @@ -1085,7 +1085,7 @@ nm_strstrip_avoid_copy(const char *str, char **str_free) #define nm_strstrip_avoid_copy_a(alloca_maxlen, str, out_str_free) \ ({ \ const char *_str_ssac = (str); \ - char ** _out_str_free_ssac = (out_str_free); \ + char **_out_str_free_ssac = (out_str_free); \ \ G_STATIC_ASSERT_EXPR((alloca_maxlen) > 0); \ \ @@ -1315,7 +1315,7 @@ _nm_strndup_a_step(char *s, const char *str, gsize len) const char *const _str_snd = (str); \ const gsize _len_snd = (len); \ char **const _out_str_free_snd = (out_str_free); \ - char * _s_snd; \ + char *_s_snd; \ \ G_STATIC_ASSERT_EXPR((alloca_maxlen) <= 300); \ \ @@ -1423,7 +1423,7 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) (_str ? ({ \ const gsize _trunc_at = (trunc_at); \ const gsize _strlen_trunc = NM_MIN(strlen(_str), _trunc_at); \ - char * _buf; \ + char *_buf; \ \ G_STATIC_ASSERT_EXPR((trunc_at) <= 300); \ \ @@ -1456,7 +1456,7 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) char *const _sbuf_stack = (sbuf_stack); \ char **const _out_sbuf_heap = (out_sbuf_heap); \ gsize *const _out_len = (out_len); \ - const char * _msg; \ + const char *_msg; \ va_list _va_args; \ int _l; \ \ @@ -1470,7 +1470,7 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) \ if ((gsize) _l >= sizeof(sbuf_stack)) { \ const gsize _l2 = ((gsize) _l) + 1u; \ - char * _sbuf_heap; \ + char *_sbuf_heap; \ \ /* Don't use g_strdup_vprintf() here either, because that also needs * to first determine the length (which is commonly does by printing @@ -1503,7 +1503,7 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) * must not be larger than 300 bytes, as this gets stack allocated. */ #define nm_sprintf_buf_unsafe_a(bufsize, format, ...) \ ({ \ - char * _buf; \ + char *_buf; \ int _buf_len; \ typeof(bufsize) _bufsize = (bufsize); \ \ @@ -1531,7 +1531,7 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) const char *const _name = (name); \ char **const _p_val_to_free = (p_val_to_free); \ const gsize _name_len = strlen(_name); \ - char * _buf2; \ + char *_buf2; \ \ nm_assert(_p_val_to_free && !*_p_val_to_free); \ if (NM_STRLEN(format) <= 290 && _name_len < (gsize) (290 - NM_STRLEN(format))) \ diff --git a/src/libnm-glib-aux/nm-random-utils.c b/src/libnm-glib-aux/nm-random-utils.c index 2f42f3f6f5..3a8ba64f71 100644 --- a/src/libnm-glib-aux/nm-random-utils.c +++ b/src/libnm-glib-aux/nm-random-utils.c @@ -80,7 +80,7 @@ _bad_random_init_seed(BadRandSeed *seed) { const guint8 *p_at_random; int seed_idx; - GRand * rand; + GRand *rand; /* g_rand_new() reads /dev/urandom, but we already noticed that * /dev/urandom fails to give us good randomness (which is why @@ -148,7 +148,7 @@ _bad_random_bytes(guint8 *buf, gsize n) { static BadRandState gl_state; - static GRand * gl_rand; + static GRand *gl_rand; static GMutex gl_mutex; NM_G_MUTEX_LOCKED(&gl_mutex); @@ -224,7 +224,7 @@ nm_utils_random_bytes(void *p, size_t n) int fd; int r; gboolean has_high_quality = TRUE; - guint8 * buf = p; + guint8 *buf = p; g_return_val_if_fail(p, FALSE); g_return_val_if_fail(n > 0, FALSE); diff --git a/src/libnm-glib-aux/nm-secret-utils.h b/src/libnm-glib-aux/nm-secret-utils.h index ac27963571..226d77ffd7 100644 --- a/src/libnm-glib-aux/nm-secret-utils.h +++ b/src/libnm-glib-aux/nm-secret-utils.h @@ -46,8 +46,8 @@ typedef struct { /* the data pointer. This pointer must be allocated with malloc (at least * when used with nm_secret_ptr_clear()). */ union { - char * str; - void * ptr; + char *str; + void *ptr; guint8 *bin; }; } NMSecretPtr; diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c index 9d1a1bf1b8..d35f99d7fc 100644 --- a/src/libnm-glib-aux/nm-shared-utils.c +++ b/src/libnm-glib-aux/nm-shared-utils.c @@ -54,7 +54,7 @@ nm_ip_addr_set_from_untrusted(int addr_family, gpointer dst, gconstpointer src, gsize src_len, - int * out_addr_family) + int *out_addr_family) { nm_assert(dst); @@ -177,7 +177,7 @@ nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr *addr, const NMUtils * the interface identifier. */ void -nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId * iid, +nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId *iid, const struct in6_addr *addr) { memcpy(iid, addr->s6_addr + 8, 8); @@ -377,7 +377,7 @@ nm_strbuf_append_str(char **buf, gsize *len, const char *str) void nm_strbuf_append(char **buf, gsize *len, const char *format, ...) { - char * p = *buf; + char *p = *buf; va_list args; int retval; @@ -480,7 +480,7 @@ GBytes * nm_g_bytes_get_empty(void) { static GBytes *bytes = NULL; - GBytes * b; + GBytes *b; again: b = g_atomic_pointer_get(&bytes); @@ -566,7 +566,7 @@ nm_g_bytes_to_variant_ay(const GBytes *bytes) #define _variant_singleton_get(create_variant) \ ({ \ static GVariant *_singleton = NULL; \ - GVariant * _v; \ + GVariant *_v; \ \ while (TRUE) { \ _v = g_atomic_pointer_get(&_singleton); \ @@ -629,7 +629,7 @@ _variant_singleton_get_array_init(GVariant **p_singleton, const char *variant_ty #define _variant_singleton_get_array(variant_type) \ ({ \ static GVariant *_singleton = NULL; \ - GVariant * _v; \ + GVariant *_v; \ \ _v = g_atomic_pointer_get(&_singleton); \ if (G_UNLIKELY(!_v)) { \ @@ -708,10 +708,10 @@ nm_g_variant_maybe_singleton_i(gint32 value) GHashTable * nm_strdict_clone(GHashTable *src) { - GHashTable * dst; + GHashTable *dst; GHashTableIter iter; - const char * key; - const char * val; + const char *key; + const char *val; if (!src) return NULL; @@ -732,7 +732,7 @@ nm_strdict_to_variant_ass(GHashTable *strdict) { gs_free NMUtilsNamedValue *values_free = NULL; NMUtilsNamedValue values_prepared[20]; - const NMUtilsNamedValue * values; + const NMUtilsNamedValue *values; GVariantBuilder builder; guint i; guint n; @@ -753,7 +753,7 @@ nm_strdict_to_variant_asv(GHashTable *strdict) { gs_free NMUtilsNamedValue *values_free = NULL; NMUtilsNamedValue values_prepared[20]; - const NMUtilsNamedValue * values; + const NMUtilsNamedValue *values; GVariantBuilder builder; guint i; guint n; @@ -873,7 +873,7 @@ const char * nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs, gsize n_descs, unsigned flags, - char * buf, + char *buf, gsize len) { gsize i; @@ -986,10 +986,10 @@ nm_utils_ip_is_site_local(int addr_family, const void *address) static gboolean _parse_legacy_addr4(const char *text, in_addr_t *out_addr, GError **error) { - gs_free char * s_free = NULL; + gs_free char *s_free = NULL; struct in_addr a1; guint8 bin[sizeof(a1)]; - char * s; + char *s; int i; if (inet_aton(text, &a1) != 1) { @@ -1024,7 +1024,7 @@ _parse_legacy_addr4(const char *text, in_addr_t *out_addr, GError **error) s = nm_memdup_maybe_a(300, text, strlen(text) + 1, &s_free); for (i = 0; i < G_N_ELEMENTS(bin); i++) { - char * current_token = s; + char *current_token = s; gint32 v; s = strchr(s, '.'); @@ -1088,7 +1088,7 @@ gboolean nm_utils_parse_inaddr_bin_full(int addr_family, gboolean accept_legacy, const char *text, - int * out_addr_family, + int *out_addr_family, gpointer out_addr) { NMIPAddr addrbin; @@ -1160,14 +1160,14 @@ nm_utils_parse_inaddr(int addr_family, const char *text, char **out_addr) gboolean nm_utils_parse_inaddr_prefix_bin(int addr_family, const char *text, - int * out_addr_family, + int *out_addr_family, gpointer out_addr, - int * out_prefix) + int *out_prefix) { gs_free char *addrstr_free = NULL; int prefix = -1; - const char * slash; - const char * addrstr; + const char *slash; + const char *addrstr; NMIPAddr addrbin; g_return_val_if_fail(text, FALSE); @@ -1218,9 +1218,9 @@ nm_utils_parse_inaddr_prefix(int addr_family, const char *text, char **out_addr, gboolean nm_utils_parse_next_line(const char **inout_ptr, - gsize * inout_len, + gsize *inout_len, const char **out_line, - gsize * out_line_len) + gsize *out_line_len) { gboolean eol_is_carriage_return; const char *line_start; @@ -1843,12 +1843,12 @@ _char_lookup_has_all(const CharLookupTable *lookup, const char *candidates) const char ** nm_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsplitSetFlags flags) { - const char ** ptr; + const char **ptr; gsize num_tokens; gsize i_token; gsize str_len_p1; - const char * c_str; - char * s; + const char *c_str; + char *s; CharLookupTable ch_lookup; const gboolean f_escaped = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ESCAPED); const gboolean f_allow_escaping = @@ -1884,7 +1884,7 @@ nm_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsplitSet ({ \ const char *const _str_start = (str_start); \ const char *const _str_cur = (str_cur); \ - const char * _str_i = (_str_cur); \ + const char *_str_i = (_str_cur); \ \ while (_str_i > _str_start && _str_i[-1] == '\\') \ _str_i--; \ @@ -2030,16 +2030,16 @@ done2: /*****************************************************************************/ const char * -nm_utils_escaped_tokens_escape_full(const char * str, - const char * delimiters, - const char * delimiters_as_needed, +nm_utils_escaped_tokens_escape_full(const char *str, + const char *delimiters, + const char *delimiters_as_needed, NMUtilsEscapedTokensEscapeFlags flags, - char ** out_to_free) + char **out_to_free) { CharLookupTable ch_lookup; CharLookupTable ch_lookup_as_needed; gboolean has_ch_lookup_as_needed = FALSE; - char * ret; + char *ret; gsize str_len; gsize alloc_len; gsize n_escapes; @@ -2268,7 +2268,7 @@ char ** nm_utils_strsplit_quoted(const char *str) { gs_unref_ptrarray GPtrArray *arr = NULL; - gs_free char * str_out = NULL; + gs_free char *str_out = NULL; CharLookupTable ch_lookup; nm_assert(str); @@ -2520,7 +2520,7 @@ nm_strv_cleanup(char **strv, gboolean strip_whitespace, gboolean skip_empty, gbo /*****************************************************************************/ GPtrArray * -_nm_g_ptr_array_copy(GPtrArray * array, +_nm_g_ptr_array_copy(GPtrArray *array, GCopyFunc func, gpointer user_data, GDestroyNotify element_free_func) @@ -2624,14 +2624,14 @@ nm_utils_error_is_notfound(GError *error) * Returns: whether the value was successfully set. */ gboolean -nm_g_object_set_property(GObject * object, - const char * property_name, +nm_g_object_set_property(GObject *object, + const char *property_name, const GValue *value, - GError ** error) + GError **error) { - GParamSpec * pspec; + GParamSpec *pspec; nm_auto_unset_gvalue GValue tmp_value = G_VALUE_INIT; - GObjectClass * klass; + GObjectClass *klass; g_return_val_if_fail(G_IS_OBJECT(object), FALSE); g_return_val_if_fail(property_name != NULL, FALSE); @@ -2725,46 +2725,46 @@ nm_g_object_set_property(GObject * object, G_STMT_END gboolean -nm_g_object_set_property_string(GObject * object, +nm_g_object_set_property_string(GObject *object, const char *property_name, const char *value, - GError ** error) + GError **error) { _set_property(object, property_name, G_TYPE_STRING, g_value_set_string, value, error); } gboolean -nm_g_object_set_property_string_static(GObject * object, +nm_g_object_set_property_string_static(GObject *object, const char *property_name, const char *value, - GError ** error) + GError **error) { _set_property(object, property_name, G_TYPE_STRING, g_value_set_static_string, value, error); } gboolean -nm_g_object_set_property_string_take(GObject * object, +nm_g_object_set_property_string_take(GObject *object, const char *property_name, - char * value, - GError ** error) + char *value, + GError **error) { _set_property(object, property_name, G_TYPE_STRING, g_value_take_string, value, error); } gboolean -nm_g_object_set_property_boolean(GObject * object, +nm_g_object_set_property_boolean(GObject *object, const char *property_name, gboolean value, - GError ** error) + GError **error) { _set_property(object, property_name, G_TYPE_BOOLEAN, g_value_set_boolean, !!value, error); } gboolean -nm_g_object_set_property_char(GObject * object, +nm_g_object_set_property_char(GObject *object, const char *property_name, gint8 value, - GError ** error) + GError **error) { /* glib says about G_TYPE_CHAR: * @@ -2775,10 +2775,10 @@ nm_g_object_set_property_char(GObject * object, } gboolean -nm_g_object_set_property_uchar(GObject * object, +nm_g_object_set_property_uchar(GObject *object, const char *property_name, guint8 value, - GError ** error) + GError **error) { _set_property(object, property_name, G_TYPE_UCHAR, g_value_set_uchar, value, error); } @@ -2790,38 +2790,38 @@ nm_g_object_set_property_int(GObject *object, const char *property_name, int val } gboolean -nm_g_object_set_property_int64(GObject * object, +nm_g_object_set_property_int64(GObject *object, const char *property_name, gint64 value, - GError ** error) + GError **error) { _set_property(object, property_name, G_TYPE_INT64, g_value_set_int64, value, error); } gboolean -nm_g_object_set_property_uint(GObject * object, +nm_g_object_set_property_uint(GObject *object, const char *property_name, guint value, - GError ** error) + GError **error) { _set_property(object, property_name, G_TYPE_UINT, g_value_set_uint, value, error); } gboolean -nm_g_object_set_property_uint64(GObject * object, +nm_g_object_set_property_uint64(GObject *object, const char *property_name, guint64 value, - GError ** error) + GError **error) { _set_property(object, property_name, G_TYPE_UINT64, g_value_set_uint64, value, error); } gboolean -nm_g_object_set_property_flags(GObject * object, +nm_g_object_set_property_flags(GObject *object, const char *property_name, GType gtype, guint value, - GError ** error) + GError **error) { nm_assert(({ nm_auto_unref_gtypeclass GTypeClass *gtypeclass = g_type_class_ref(gtype); @@ -2831,11 +2831,11 @@ nm_g_object_set_property_flags(GObject * object, } gboolean -nm_g_object_set_property_enum(GObject * object, +nm_g_object_set_property_enum(GObject *object, const char *property_name, GType gtype, int value, - GError ** error) + GError **error) { nm_assert(({ nm_auto_unref_gtypeclass GTypeClass *gtypeclass = g_type_class_ref(gtype); @@ -2873,7 +2873,7 @@ GType nm_g_type_find_implementing_class_for_property(GType gtype, const char *pname) { nm_auto_unref_gtypeclass GObjectClass *klass = NULL; - GParamSpec * pspec; + GParamSpec *pspec; g_return_val_if_fail(pname, G_TYPE_INVALID); @@ -2949,10 +2949,10 @@ _str_buf_append_c_escape_octal(NMStrBuf *strbuf, char ch) * containing the unescaped string and returned. */ gconstpointer -nm_utils_buf_utf8safe_unescape(const char * str, +nm_utils_buf_utf8safe_unescape(const char *str, NMUtilsStrUtf8SafeFlags flags, - gsize * out_len, - gpointer * to_free) + gsize *out_len, + gpointer *to_free) { gboolean strip_spaces = NM_FLAGS_HAS(flags, NM_UTILS_STR_UTF8_SAFE_UNESCAPE_STRIP_SPACES); NMStrBuf strbuf; @@ -3114,11 +3114,11 @@ const char * nm_utils_buf_utf8safe_escape(gconstpointer buf, gssize buflen, NMUtilsStrUtf8SafeFlags flags, - char ** to_free) + char **to_free) { const char *const str = buf; - const char * p = NULL; - const char * s; + const char *p = NULL; + const char *s; gboolean nul_terminated = FALSE; NMStrBuf strbuf; @@ -3209,7 +3209,7 @@ char * nm_utils_buf_utf8safe_escape_cp(gconstpointer buf, gssize buflen, NMUtilsStrUtf8SafeFlags flags) { const char *s_const; - char * s; + char *s; s_const = nm_utils_buf_utf8safe_escape(buf, buflen, flags, &s); nm_assert(!s || s == s_const); @@ -3419,11 +3419,11 @@ nm_utils_named_value_clear_with_g_free(NMUtilsNamedValue *val) G_STATIC_ASSERT(G_STRUCT_OFFSET(NMUtilsNamedValue, name) == 0); NMUtilsNamedValue * -nm_utils_named_values_from_strdict_full(GHashTable * hash, - guint * out_len, +nm_utils_named_values_from_strdict_full(GHashTable *hash, + guint *out_len, GCompareDataFunc compare_func, gpointer user_data, - NMUtilsNamedValue * provided_buffer, + NMUtilsNamedValue *provided_buffer, guint provided_buffer_len, NMUtilsNamedValue **out_allocated_buffer) { @@ -3466,7 +3466,7 @@ nm_utils_named_values_from_strdict_full(GHashTable * hash, gssize nm_utils_named_value_list_find(const NMUtilsNamedValue *arr, gsize len, - const char * name, + const char *name, gboolean sorted) { gsize i; @@ -3556,10 +3556,10 @@ nm_utils_named_value_list_sort(NMUtilsNamedValue *arr, /*****************************************************************************/ gpointer * -nm_utils_hash_keys_to_array(GHashTable * hash, +nm_utils_hash_keys_to_array(GHashTable *hash, GCompareDataFunc compare_func, gpointer user_data, - guint * out_len) + guint *out_len) { guint len; gpointer *keys; @@ -3580,14 +3580,14 @@ nm_utils_hash_keys_to_array(GHashTable * hash, } gpointer * -nm_utils_hash_values_to_array(GHashTable * hash, +nm_utils_hash_values_to_array(GHashTable *hash, GCompareDataFunc compare_func, gpointer user_data, - guint * out_len) + guint *out_len) { GHashTableIter iter; gpointer value; - gpointer * arr; + gpointer *arr; guint i, len; if (!hash || (len = g_hash_table_size(hash)) == 0u) { @@ -3669,8 +3669,8 @@ nm_utils_hashtable_equal(const GHashTable *a, } static gboolean -_utils_hashtable_equal(GHashTable * hash_a, - GHashTable * hash_b, +_utils_hashtable_equal(GHashTable *hash_a, + GHashTable *hash_b, GCompareDataFunc cmp_values, gpointer user_data) { @@ -3768,8 +3768,8 @@ static int _hashtable_cmp_func(gconstpointer a, gconstpointer b, gpointer user_data) { const HashTableUserData *d = user_data; - const HashTableCmpData * d_a = *((const HashTableCmpData *const *) a); - const HashTableCmpData * d_b = *((const HashTableCmpData *const *) b); + const HashTableCmpData *d_a = *((const HashTableCmpData *const *) a); + const HashTableCmpData *d_b = *((const HashTableCmpData *const *) b); NM_CMP_RETURN(d->cmp_keys(d_a, d_b, d->user_data)); return 0; @@ -3805,11 +3805,11 @@ nm_utils_hashtable_cmp(const GHashTable *a, GCompareDataFunc cmp_values, gpointer user_data) { - GHashTable *hash_a = (GHashTable *) a; - GHashTable *hash_b = (GHashTable *) b; + GHashTable *hash_a = (GHashTable *) a; + GHashTable *hash_b = (GHashTable *) b; gs_free HashTableCmpData *cmp_array_free = NULL; - HashTableCmpData * cmp_array_a; - HashTableCmpData * cmp_array_b; + HashTableCmpData *cmp_array_a; + HashTableCmpData *cmp_array_b; GHashTableIter h; gpointer i_key; gpointer i_val; @@ -4011,12 +4011,12 @@ _nm_strv_dup_packed(const char *const *strv, gssize len) { gs_free gsize *str_len_free = NULL; - gsize * str_len; - const char ** result; + gsize *str_len; + const char **result; gsize mem_len; gsize pre_len; gsize len2; - char * sbuf; + char *sbuf; gsize i; nm_assert(len >= -1); @@ -4113,7 +4113,7 @@ nm_utils_ptrarray_find_first(gconstpointer *list, gssize len, gconstpointer need /*****************************************************************************/ gboolean -nm_utils_ptrarray_is_sorted(gconstpointer * list, +nm_utils_ptrarray_is_sorted(gconstpointer *list, gsize len, gboolean require_strict, GCompareDataFunc cmpfcn, @@ -4135,7 +4135,7 @@ nm_utils_ptrarray_is_sorted(gconstpointer * list, } gssize -nm_utils_ptrarray_find_binary_search(gconstpointer * list, +nm_utils_ptrarray_find_binary_search(gconstpointer *list, gsize len, gconstpointer needle, GCompareDataFunc cmpfcn, @@ -4172,13 +4172,13 @@ nm_utils_ptrarray_find_binary_search(gconstpointer * list, } gssize -nm_utils_ptrarray_find_binary_search_range(gconstpointer * list, +nm_utils_ptrarray_find_binary_search_range(gconstpointer *list, gsize len, gconstpointer needle, GCompareDataFunc cmpfcn, gpointer user_data, - gssize * out_idx_first, - gssize * out_idx_last) + gssize *out_idx_first, + gssize *out_idx_last) { gssize imin, imax, imid, i2min, i2max, i2mid; int cmp; @@ -4336,10 +4336,10 @@ nm_utils_get_start_time_for_pid(pid_t pid, char *out_state, pid_t *out_ppid) { guint64 start_time; char filename[256]; - gs_free char * contents = NULL; + gs_free char *contents = NULL; size_t length; gs_free const char **tokens = NULL; - char * p; + char *p; char state = ' '; gint64 ppid = 0; @@ -4593,8 +4593,8 @@ _nm_utils_user_data_unpack(NMUtilsUserData *user_data, int nargs, ...) typedef struct { gpointer callback_user_data; - GCancellable * cancellable; - GSource * source; + GCancellable *cancellable; + GSource *source; NMUtilsInvokeOnIdleCallback callback; gulong cancelled_id; } InvokeOnIdleData; @@ -4639,12 +4639,12 @@ _nm_utils_invoke_on_idle_cb_cancelled(GCancellable *cancellable, InvokeOnIdleDat static void _nm_utils_invoke_on_idle_start(gboolean use_timeout, guint timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMUtilsInvokeOnIdleCallback callback, gpointer callback_user_data) { InvokeOnIdleData *data; - GSource * source; + GSource *source; g_return_if_fail(callback); @@ -4688,7 +4688,7 @@ _nm_utils_invoke_on_idle_start(gboolean use_timeout, } void -nm_utils_invoke_on_idle(GCancellable * cancellable, +nm_utils_invoke_on_idle(GCancellable *cancellable, NMUtilsInvokeOnIdleCallback callback, gpointer callback_user_data) { @@ -4697,7 +4697,7 @@ nm_utils_invoke_on_idle(GCancellable * cancellable, void nm_utils_invoke_on_timeout(guint timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMUtilsInvokeOnIdleCallback callback, gpointer callback_user_data) { @@ -4787,11 +4787,11 @@ nm_utils_bin2hexstr_full(gconstpointer addr, gsize length, char delimiter, gboolean upper_case, - char * out) + char *out) { const guint8 *in = addr; - const char * LOOKUP = upper_case ? "0123456789ABCDEF" : "0123456789abcdef"; - char * out0; + const char *LOOKUP = upper_case ? "0123456789ABCDEF" : "0123456789abcdef"; + char *out0; if (out) out0 = out; @@ -4829,12 +4829,12 @@ nm_utils_hexstr2bin_full(const char *hexstr, gboolean hexdigit_pairs_required, const char *delimiter_candidates, gsize required_len, - guint8 * buffer, + guint8 *buffer, gsize buffer_len, - gsize * out_len) + gsize *out_len) { const char *in = hexstr; - guint8 * out = buffer; + guint8 *out = buffer; gboolean delimiter_has = TRUE; guint8 delimiter = '\0'; gsize len; @@ -4918,7 +4918,7 @@ nm_utils_hexstr2bin_alloc(const char *hexstr, gboolean delimiter_required, const char *delimiter_candidates, gsize required_len, - gsize * out_len) + gsize *out_len) { guint8 *buffer; gsize buffer_len, len; @@ -4968,16 +4968,16 @@ fail: GVariant * nm_utils_gvariant_vardict_filter(GVariant *src, gboolean (*filter_fcn)(const char *key, - GVariant * val, - char ** out_key, - GVariant ** out_val, + GVariant *val, + char **out_key, + GVariant **out_val, gpointer user_data), gpointer user_data) { GVariantIter iter; GVariantBuilder builder; - const char * key; - GVariant * val; + const char *key; + GVariant *val; g_return_val_if_fail(src && g_variant_is_of_type(src, G_VARIANT_TYPE_VARDICT), NULL); g_return_val_if_fail(filter_fcn, NULL); @@ -4987,8 +4987,8 @@ nm_utils_gvariant_vardict_filter(GVariant *src, g_variant_iter_init(&iter, src); while (g_variant_iter_next(&iter, "{&sv}", &key, &val)) { _nm_unused gs_unref_variant GVariant *val_free = val; - gs_free char * key2 = NULL; - gs_unref_variant GVariant *val2 = NULL; + gs_free char *key2 = NULL; + gs_unref_variant GVariant *val2 = NULL; if (filter_fcn(key, val, &key2, &val2, user_data)) { g_variant_builder_add(&builder, "{sv}", key2 ?: key, val2 ?: val); @@ -5000,9 +5000,9 @@ nm_utils_gvariant_vardict_filter(GVariant *src, static gboolean _gvariant_vardict_filter_drop_one(const char *key, - GVariant * val, - char ** out_key, - GVariant ** out_val, + GVariant *val, + char **out_key, + GVariant **out_val, gpointer user_data) { return !nm_streq(key, user_data); @@ -5231,8 +5231,8 @@ typedef struct { typedef struct { GSource source; GMainContext *context; - GHashTable * fds; - GPollFD * fds_arr; + GHashTable *fds; + GPollFD *fds_arr; guint fds_len; int max_priority; bool acquired : 1; @@ -5272,16 +5272,16 @@ _ctx_integ_source_reacquire(CtxIntegSource *ctx_src) static gboolean _ctx_integ_source_prepare(GSource *source, int *out_timeout) { - CtxIntegSource *ctx_src = ((CtxIntegSource *) source); - int max_priority; - int timeout = -1; - gboolean any_ready; - GHashTableIter h_iter; - PollData * poll_data; - gboolean fds_changed; - GPollFD new_fds_stack[300u / sizeof(GPollFD)]; + CtxIntegSource *ctx_src = ((CtxIntegSource *) source); + int max_priority; + int timeout = -1; + gboolean any_ready; + GHashTableIter h_iter; + PollData *poll_data; + gboolean fds_changed; + GPollFD new_fds_stack[300u / sizeof(GPollFD)]; gs_free GPollFD *new_fds_heap = NULL; - GPollFD * new_fds; + GPollFD *new_fds; guint new_fds_len; guint new_fds_alloc; guint i; @@ -5455,7 +5455,7 @@ _ctx_integ_source_check(GSource *source) CtxIntegSource *ctx_src = ((CtxIntegSource *) source); GHashTableIter h_iter; gboolean some_ready; - PollData * poll_data; + PollData *poll_data; nm_assert(ctx_src->context); @@ -5511,7 +5511,7 @@ _ctx_integ_source_finalize(GSource *source) { CtxIntegSource *ctx_src = ((CtxIntegSource *) source); GHashTableIter h_iter; - PollData * poll_data; + PollData *poll_data; g_return_if_fail(ctx_src->context); @@ -5890,17 +5890,17 @@ attribute_escape(const char *src, char c1, char c2) } void -_nm_utils_format_variant_attributes_full(GString * str, - const NMUtilsNamedValue * values, +_nm_utils_format_variant_attributes_full(GString *str, + const NMUtilsNamedValue *values, guint num_values, const NMVariantAttributeSpec *const *spec, char attr_separator, char key_value_separator) { const NMVariantAttributeSpec *const *s; - const char * name, *value; - GVariant * variant; - char * escaped; + const char *name, *value; + GVariant *variant; + char *escaped; char buf[64]; char sep = 0; guint i; @@ -5960,15 +5960,15 @@ _nm_utils_format_variant_attributes_full(GString * st } char * -_nm_utils_format_variant_attributes(GHashTable * attributes, +_nm_utils_format_variant_attributes(GHashTable *attributes, const NMVariantAttributeSpec *const *spec, char attr_separator, char key_value_separator) { gs_free NMUtilsNamedValue *values_free = NULL; NMUtilsNamedValue values_prepared[20]; - const NMUtilsNamedValue * values; - GString * str = NULL; + const NMUtilsNamedValue *values; + GString *str = NULL; guint len; g_return_val_if_fail(attr_separator, NULL); @@ -6078,7 +6078,7 @@ nm_utils_uid_to_name(uid_t uid) gs_free char *buf_heap = NULL; char buf_stack[4096]; gsize bufsize; - char * buf; + char *buf; bufsize = sizeof(buf_stack); buf = buf_stack; @@ -6112,7 +6112,7 @@ nm_utils_name_to_uid(const char *name, uid_t *out_uid) gs_free char *buf_heap = NULL; char buf_stack[4096]; gsize bufsize; - char * buf; + char *buf; if (!name) return nm_assert_unreachable_val(FALSE); @@ -6210,7 +6210,7 @@ char * _nm_utils_ssid_to_string_arr(const guint8 *ssid, gsize len) { gs_free char *s_copy = NULL; - const char * s_cnst; + const char *s_cnst; if (len == 0) return g_strdup("(empty)"); @@ -6286,7 +6286,7 @@ nm_utils_ip4_address_clear_host_address(in_addr_t addr, guint8 plen) * @dst and @src to the same destination or set @src NULL. */ const struct in6_addr * -nm_utils_ip6_address_clear_host_address(struct in6_addr * dst, +nm_utils_ip6_address_clear_host_address(struct in6_addr *dst, const struct in6_addr *src, guint8 plen) { @@ -6475,10 +6475,10 @@ nm_crypto_md5_hash(const guint8 *salt, gsize salt_len, const guint8 *password, gsize password_len, - guint8 * buffer, + guint8 *buffer, gsize buflen) { - nm_auto_free_checksum GChecksum * ctx = NULL; + nm_auto_free_checksum GChecksum *ctx = NULL; nm_auto_clear_static_secret_ptr const NMSecretPtr digest = NM_SECRET_PTR_STATIC(NM_UTILS_CHECKSUM_LENGTH_MD5); gsize bufidx = 0; @@ -6569,7 +6569,7 @@ static pthread_key_t _tls_reg_key; static void _tls_reg_destroy(gpointer data) { - CList * lst_head = data; + CList *lst_head = data; TlsRegData *entry; if (!lst_head) @@ -6612,8 +6612,8 @@ nm_utils_thread_local_register_destroy(gpointer tls_data, GDestroyNotify destroy { NM_AUTO_PROTECT_ERRNO(errsv); static pthread_once_t key_once = PTHREAD_ONCE_INIT; - CList * lst_head; - TlsRegData * entry; + CList *lst_head; + TlsRegData *entry; nm_assert(destroy_notify); diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index e6e470b4cc..51c88f9e48 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -90,7 +90,7 @@ G_STATIC_ASSERT(sizeof(int) == sizeof(gint32)); #define _NM_INT_LE_MAXINT32(value) \ ({ \ _nm_unused typeof(value) _value = (value); \ - _nm_unused const int * _p_value = &_value; \ + _nm_unused const int *_p_value = &_value; \ \ TRUE; \ }) @@ -312,7 +312,7 @@ gboolean nm_ip_addr_set_from_untrusted(int addr_family, gpointer dst, gconstpointer src, gsize src_len, - int * out_addr_family); + int *out_addr_family); gboolean nm_ip_addr_set_from_variant(int addr_family, gpointer dst, GVariant *variant, int *out_addr_family); @@ -374,20 +374,20 @@ typedef struct _NMUtilsIPv6IfaceId { } \ } -void nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr * addr, +void nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr *addr, const NMUtilsIPv6IfaceId *iid); -void nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId * iid, +void nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId *iid, const struct in6_addr *addr); gboolean nm_utils_ipv6_interface_identifier_get_from_token(NMUtilsIPv6IfaceId *iid, - const char * token); + const char *token); const char *nm_utils_inet6_interface_identifier_to_token(const NMUtilsIPv6IfaceId *iid, char buf[static INET6_ADDRSTRLEN]); gboolean nm_utils_get_ipv6_interface_identifier(NMLinkType link_type, - const guint8 * hwaddr, + const guint8 *hwaddr, guint len, guint dev_id, NMUtilsIPv6IfaceId *out_iid); @@ -397,7 +397,7 @@ gboolean nm_utils_get_ipv6_interface_identifier(NMLinkType link_type, gconstpointer nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer src, guint8 plen); in_addr_t nm_utils_ip4_address_clear_host_address(in_addr_t addr, guint8 plen); -const struct in6_addr *nm_utils_ip6_address_clear_host_address(struct in6_addr * dst, +const struct in6_addr *nm_utils_ip6_address_clear_host_address(struct in6_addr *dst, const struct in6_addr *src, guint8 plen); @@ -622,9 +622,9 @@ GVariant *nm_strdict_to_variant_asv(GHashTable *strdict); GVariant *nm_utils_gvariant_vardict_filter(GVariant *src, gboolean (*filter_fcn)(const char *key, - GVariant * val, - char ** out_key, - GVariant ** out_val, + GVariant *val, + char **out_key, + GVariant **out_val, gpointer user_data), gpointer user_data); @@ -750,7 +750,7 @@ gboolean nm_strv_has_duplicate(const char *const *list, gssize len, gboolean is_ const char **nm_strv_cleanup_const(const char **strv, gboolean skip_empty, gboolean skip_repeated); -char **nm_strv_cleanup(char ** strv, +char **nm_strv_cleanup(char **strv, gboolean strip_whitespace, gboolean skip_empty, gboolean skip_repeated); @@ -823,7 +823,7 @@ const char *nm_utils_escaped_tokens_escape_full(const char *str, const char *delimiters, const char *delimiters_as_needed, NMUtilsEscapedTokensEscapeFlags flags, - char ** out_to_free); + char **out_to_free); static inline const char * nm_utils_escaped_tokens_escape(const char *str, const char *delimiters, char **out_to_free) @@ -858,7 +858,7 @@ nm_utils_escaped_tokens_escape_unnecessary(const char *str, const char *delimite { gs_free char *str_to_free = NULL; - const char * str0; + const char *str0; str0 = nm_utils_escaped_tokens_escape(str, delimiters, &str_to_free); nm_assert(str0 == str); @@ -872,7 +872,7 @@ nm_utils_escaped_tokens_escape_unnecessary(const char *str, const char *delimite static inline void nm_utils_escaped_tokens_escape_gstr_assert(const char *str, const char *delimiters, - GString * gstring) + GString *gstring) { g_string_append(gstring, nm_utils_escaped_tokens_escape_unnecessary(str, delimiters)); } @@ -986,7 +986,7 @@ guint32 _nm_utils_ip4_get_default_prefix(in_addr_t ip); gconstpointer nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer src, guint8 plen); in_addr_t nm_utils_ip4_address_clear_host_address(in_addr_t addr, guint8 plen); -const struct in6_addr *nm_utils_ip6_address_clear_host_address(struct in6_addr * dst, +const struct in6_addr *nm_utils_ip6_address_clear_host_address(struct in6_addr *dst, const struct in6_addr *src, guint8 plen); int nm_utils_ip6_address_same_prefix_cmp(const struct in6_addr *addr_a, @@ -1000,12 +1000,12 @@ gboolean nm_utils_ip_is_site_local(int addr_family, const void *address); gboolean nm_utils_parse_inaddr_bin_full(int addr_family, gboolean accept_legacy, const char *text, - int * out_addr_family, + int *out_addr_family, gpointer out_addr); static inline gboolean nm_utils_parse_inaddr_bin(int addr_family, const char *text, - int * out_addr_family, + int *out_addr_family, gpointer out_addr) { return nm_utils_parse_inaddr_bin_full(addr_family, FALSE, text, out_addr_family, out_addr); @@ -1015,17 +1015,17 @@ gboolean nm_utils_parse_inaddr(int addr_family, const char *text, char **out_add gboolean nm_utils_parse_inaddr_prefix_bin(int addr_family, const char *text, - int * out_addr_family, + int *out_addr_family, gpointer out_addr, - int * out_prefix); + int *out_prefix); gboolean nm_utils_parse_inaddr_prefix(int addr_family, const char *text, char **out_addr, int *out_prefix); gboolean nm_utils_parse_next_line(const char **inout_ptr, - gsize * inout_len, + gsize *inout_len, const char **out_line, - gsize * out_line_len); + gsize *out_line_len); gint64 nm_g_ascii_strtoll(const char *nptr, char **endptr, guint base); @@ -1082,7 +1082,7 @@ typedef struct { const char *nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs, gsize n_descs, unsigned flags, - char * buf, + char *buf, gsize len); /*****************************************************************************/ @@ -1372,70 +1372,70 @@ nm_utils_error_set_literal(GError **error, int error_code, const char *literal) /*****************************************************************************/ -gboolean nm_g_object_set_property(GObject * object, - const char * property_name, +gboolean nm_g_object_set_property(GObject *object, + const char *property_name, const GValue *value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_string(GObject * object, +gboolean nm_g_object_set_property_string(GObject *object, const char *property_name, const char *value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_string_static(GObject * object, +gboolean nm_g_object_set_property_string_static(GObject *object, const char *property_name, const char *value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_string_take(GObject * object, +gboolean nm_g_object_set_property_string_take(GObject *object, const char *property_name, - char * value, - GError ** error); + char *value, + GError **error); -gboolean nm_g_object_set_property_boolean(GObject * object, +gboolean nm_g_object_set_property_boolean(GObject *object, const char *property_name, gboolean value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_char(GObject * object, +gboolean nm_g_object_set_property_char(GObject *object, const char *property_name, gint8 value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_uchar(GObject * object, +gboolean nm_g_object_set_property_uchar(GObject *object, const char *property_name, guint8 value, - GError ** error); + GError **error); gboolean nm_g_object_set_property_int(GObject *object, const char *property_name, int value, GError **error); -gboolean nm_g_object_set_property_int64(GObject * object, +gboolean nm_g_object_set_property_int64(GObject *object, const char *property_name, gint64 value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_uint(GObject * object, +gboolean nm_g_object_set_property_uint(GObject *object, const char *property_name, guint value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_uint64(GObject * object, +gboolean nm_g_object_set_property_uint64(GObject *object, const char *property_name, guint64 value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_flags(GObject * object, +gboolean nm_g_object_set_property_flags(GObject *object, const char *property_name, GType gtype, guint value, - GError ** error); + GError **error); -gboolean nm_g_object_set_property_enum(GObject * object, +gboolean nm_g_object_set_property_enum(GObject *object, const char *property_name, GType gtype, int value, - GError ** error); + GError **error); GParamSpec *nm_g_object_class_find_property_from_gtype(GType gtype, const char *property_name); @@ -1525,15 +1525,15 @@ typedef enum { const char *nm_utils_buf_utf8safe_escape(gconstpointer buf, gssize buflen, NMUtilsStrUtf8SafeFlags flags, - char ** to_free); + char **to_free); char * nm_utils_buf_utf8safe_escape_cp(gconstpointer buf, gssize buflen, NMUtilsStrUtf8SafeFlags flags); const char * nm_utils_buf_utf8safe_escape_bytes(GBytes *bytes, NMUtilsStrUtf8SafeFlags flags, char **to_free); -gconstpointer nm_utils_buf_utf8safe_unescape(const char * str, +gconstpointer nm_utils_buf_utf8safe_unescape(const char *str, NMUtilsStrUtf8SafeFlags flags, - gsize * out_len, - gpointer * to_free); + gsize *out_len, + gpointer *to_free); const char * nm_utils_str_utf8safe_escape(const char *str, NMUtilsStrUtf8SafeFlags flags, char **to_free); @@ -1633,8 +1633,8 @@ nm_g_variant_builder_add_sv(GVariantBuilder *builder, const char *key, GVariant static inline void nm_g_variant_builder_add_sv_bytearray(GVariantBuilder *builder, - const char * key, - const guint8 * arr, + const char *key, + const guint8 *arr, gsize len) { g_variant_builder_add(builder, "{sv}", key, nm_g_variant_new_ay(arr, len)); @@ -1959,12 +1959,12 @@ typedef struct { typedef struct { union { NMUtilsNamedEntry named_entry; - const char * name; - char * name_mutable; + const char *name; + char *name_mutable; }; union { const char *value_str; - char * value_str_mutable; + char *value_str_mutable; gpointer value_ptr; }; } NMUtilsNamedValue; @@ -1975,11 +1975,11 @@ typedef struct { } NMUtilsNamedValue * -nm_utils_named_values_from_strdict_full(GHashTable * hash, - guint * out_len, +nm_utils_named_values_from_strdict_full(GHashTable *hash, + guint *out_len, GCompareDataFunc compare_func, gpointer user_data, - NMUtilsNamedValue * provided_buffer, + NMUtilsNamedValue *provided_buffer, guint provided_buffer_len, NMUtilsNamedValue **out_allocated_buffer); @@ -1994,7 +1994,7 @@ nm_utils_named_values_from_strdict_full(GHashTable * hash, gssize nm_utils_named_value_list_find(const NMUtilsNamedValue *arr, gsize len, - const char * name, + const char *name, gboolean sorted); gboolean nm_utils_named_value_list_is_sorted(const NMUtilsNamedValue *arr, @@ -2012,15 +2012,15 @@ void nm_utils_named_value_clear_with_g_free(NMUtilsNamedValue *val); /*****************************************************************************/ -gpointer *nm_utils_hash_keys_to_array(GHashTable * hash, +gpointer *nm_utils_hash_keys_to_array(GHashTable *hash, GCompareDataFunc compare_func, gpointer user_data, - guint * out_len); + guint *out_len); -gpointer *nm_utils_hash_values_to_array(GHashTable * hash, +gpointer *nm_utils_hash_values_to_array(GHashTable *hash, GCompareDataFunc compare_func, gpointer user_data, - guint * out_len); + guint *out_len); static inline const char ** nm_strdict_get_keys(const GHashTable *hash, gboolean sorted, guint *out_length) @@ -2077,7 +2077,7 @@ const char **_nm_strv_dup_packed(const char *const *strv, gssize len); ({ \ const char *const *const _strv = NM_CAST_STRV_CC(strv); \ const gssize _len = (len); \ - const char ** _result = NULL; \ + const char **_result = NULL; \ const char ***const _to_free = (to_free); \ \ G_STATIC_ASSERT_EXPR((alloca_maxlen) <= 500u / sizeof(const char *)); \ @@ -2176,7 +2176,7 @@ nm_g_ptr_array_unref(GPtrArray *arr) #define nm_g_ptr_array_set(pdst, val) \ ({ \ GPtrArray **_pdst = (pdst); \ - GPtrArray * _val = (val); \ + GPtrArray *_val = (val); \ gboolean _changed = FALSE; \ \ nm_assert(_pdst); \ @@ -2193,7 +2193,7 @@ nm_g_ptr_array_unref(GPtrArray *arr) #define nm_g_ptr_array_set_take(pdst, val) \ ({ \ GPtrArray **_pdst = (pdst); \ - GPtrArray * _val = (val); \ + GPtrArray *_val = (val); \ gboolean _changed = FALSE; \ \ nm_assert(_pdst); \ @@ -2221,7 +2221,7 @@ nm_g_ptr_array_pdata(const GPtrArray *arr) return arr ? arr->pdata : NULL; } -GPtrArray *_nm_g_ptr_array_copy(GPtrArray * array, +GPtrArray *_nm_g_ptr_array_copy(GPtrArray *array, GCopyFunc func, gpointer user_data, GDestroyNotify element_free_func); @@ -2297,25 +2297,25 @@ nm_g_hash_table_remove(GHashTable *hash, gconstpointer key) /*****************************************************************************/ -gboolean nm_utils_ptrarray_is_sorted(gconstpointer * list, +gboolean nm_utils_ptrarray_is_sorted(gconstpointer *list, gsize len, gboolean require_strict, GCompareDataFunc cmpfcn, gpointer user_data); -gssize nm_utils_ptrarray_find_binary_search(gconstpointer * list, +gssize nm_utils_ptrarray_find_binary_search(gconstpointer *list, gsize len, gconstpointer needle, GCompareDataFunc cmpfcn, gpointer user_data); -gssize nm_utils_ptrarray_find_binary_search_range(gconstpointer * list, +gssize nm_utils_ptrarray_find_binary_search_range(gconstpointer *list, gsize len, gconstpointer needle, GCompareDataFunc cmpfcn, gpointer user_data, - gssize * out_idx_first, - gssize * out_idx_last); + gssize *out_idx_first, + gssize *out_idx_last); #define nm_strv_find_binary_search(strv, len, needle) \ ({ \ @@ -2545,12 +2545,12 @@ void _nm_utils_user_data_unpack(NMUtilsUserData *user_data, int nargs, ...); typedef void (*NMUtilsInvokeOnIdleCallback)(gpointer user_data, GCancellable *cancellable); -void nm_utils_invoke_on_idle(GCancellable * cancellable, +void nm_utils_invoke_on_idle(GCancellable *cancellable, NMUtilsInvokeOnIdleCallback callback, gpointer callback_user_data); void nm_utils_invoke_on_timeout(guint timeout_msec, - GCancellable * cancellable, + GCancellable *cancellable, NMUtilsInvokeOnIdleCallback callback, gpointer callback_user_data); @@ -2706,15 +2706,15 @@ char *nm_utils_bin2hexstr_full(gconstpointer addr, gsize length, char delimiter, gboolean upper_case, - char * out); + char *out); #define nm_utils_bin2hexstr_a(addr, length, delimiter, upper_case, str_to_free) \ ({ \ gconstpointer _addr = (addr); \ gsize _length = (length); \ char _delimiter = (delimiter); \ - char ** _str_to_free = (str_to_free); \ - char * _s; \ + char **_str_to_free = (str_to_free); \ + char *_s; \ gsize _s_len; \ \ nm_assert(_str_to_free); \ @@ -2747,9 +2747,9 @@ guint8 *nm_utils_hexstr2bin_full(const char *hexstr, gboolean hexdigit_pairs_required, const char *delimiter_candidates, gsize required_len, - guint8 * buffer, + guint8 *buffer, gsize buffer_len, - gsize * out_len); + gsize *out_len); #define nm_utils_hexstr2bin_buf(hexstr, \ allow_0x_prefix, \ @@ -2771,7 +2771,7 @@ guint8 *nm_utils_hexstr2bin_alloc(const char *hexstr, gboolean delimiter_required, const char *delimiter_candidates, gsize required_len, - gsize * out_len); + gsize *out_len); /** * _nm_utils_hwaddr_aton: @@ -2833,7 +2833,7 @@ static inline const char * _nm_utils_hwaddr_ntoa(gconstpointer addr, gsize addr_len, gboolean upper_case, - char * buf, + char *buf, gsize buf_len) { g_return_val_if_fail(addr, NULL); @@ -2951,7 +2951,7 @@ _nm_utils_hwaddr_ntoa(gconstpointer addr, static inline GTask * nm_g_task_new(gpointer source_object, - GCancellable * cancellable, + GCancellable *cancellable, gpointer source_tag, GAsyncReadyCallback callback, gpointer callback_data) @@ -3142,7 +3142,7 @@ nm_strvarray_remove_first(GArray *strv, const char *needle) /*****************************************************************************/ struct _NMVariantAttributeSpec { - char * name; + char *name; const GVariantType *type; bool v4 : 1; bool v6 : 1; @@ -3153,14 +3153,14 @@ struct _NMVariantAttributeSpec { typedef struct _NMVariantAttributeSpec NMVariantAttributeSpec; -void _nm_utils_format_variant_attributes_full(GString * str, - const NMUtilsNamedValue * values, +void _nm_utils_format_variant_attributes_full(GString *str, + const NMUtilsNamedValue *values, guint num_values, const NMVariantAttributeSpec *const *spec, char attr_separator, char key_value_separator); -char *_nm_utils_format_variant_attributes(GHashTable * attributes, +char *_nm_utils_format_variant_attributes(GHashTable *attributes, const NMVariantAttributeSpec *const *spec, char attr_separator, char key_value_separator); @@ -3171,7 +3171,7 @@ gboolean nm_utils_is_localhost(const char *name); gboolean nm_utils_is_specific_hostname(const char *name); -char * nm_utils_uid_to_name(uid_t uid); +char *nm_utils_uid_to_name(uid_t uid); gboolean nm_utils_name_to_uid(const char *name, uid_t *out_uid); /*****************************************************************************/ @@ -3182,8 +3182,8 @@ double nm_utils_exp10(gint16 e); gboolean _nm_utils_is_empty_ssid_arr(const guint8 *ssid, gsize len); gboolean _nm_utils_is_empty_ssid_gbytes(GBytes *ssid); -char * _nm_utils_ssid_to_string_arr(const guint8 *ssid, gsize len); -char * _nm_utils_ssid_to_string_gbytes(GBytes *ssid); +char *_nm_utils_ssid_to_string_arr(const guint8 *ssid, gsize len); +char *_nm_utils_ssid_to_string_gbytes(GBytes *ssid); /*****************************************************************************/ @@ -3206,7 +3206,7 @@ void nm_crypto_md5_hash(const guint8 *salt, gsize salt_len, const guint8 *password, gsize password_len, - guint8 * buffer, + guint8 *buffer, gsize buflen); /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-str-buf.h b/src/libnm-glib-aux/nm-str-buf.h index 7a7f580ccb..47d1f055be 100644 --- a/src/libnm-glib-aux/nm-str-buf.h +++ b/src/libnm-glib-aux/nm-str-buf.h @@ -348,7 +348,7 @@ nm_utils_escaped_tokens_escape_strbuf(const char *str, const char *delimiters, N static inline void nm_utils_escaped_tokens_escape_strbuf_assert(const char *str, const char *delimiters, - NMStrBuf * strbuf) + NMStrBuf *strbuf) { nm_str_buf_append(strbuf, nm_utils_escaped_tokens_escape_unnecessary(str, delimiters)); } diff --git a/src/libnm-glib-aux/nm-test-utils.h b/src/libnm-glib-aux/nm-test-utils.h index 253aaf0e86..0965134e14 100644 --- a/src/libnm-glib-aux/nm-test-utils.h +++ b/src/libnm-glib-aux/nm-test-utils.h @@ -104,7 +104,7 @@ #define nmtst_assert_error(error, expect_error_domain, expect_error_code, expect_error_pattern) \ G_STMT_START \ { \ - GError * _error = (error); \ + GError *_error = (error); \ GQuark _expect_error_domain = (expect_error_domain); \ const char *_expect_error_pattern = (expect_error_pattern); \ \ @@ -204,16 +204,16 @@ /*****************************************************************************/ struct __nmtst_internal { - GRand * rand0; + GRand *rand0; guint32 rand_seed; - GRand * rand; + GRand *rand; gboolean is_debug; gboolean assert_logging; gboolean no_expect_message; gboolean test_quick; gboolean test_tap_log; - char * sudo_cmd; - char ** orig_argv; + char *sudo_cmd; + char **orig_argv; }; extern struct __nmtst_internal __nmtst_internal; @@ -255,7 +255,7 @@ static inline char ** nmtst_str_split(char *str, const char *delimiters) { const char *d; - GArray * result = g_array_sized_new(TRUE, FALSE, sizeof(char *), 3); + GArray *result = g_array_sized_new(TRUE, FALSE, sizeof(char *), 3); g_assert(str); g_assert(delimiters && !strchr(delimiters, '\\')); @@ -312,35 +312,35 @@ nmtst_free(void) } static inline void -_nmtst_log_handler(const char * log_domain, +_nmtst_log_handler(const char *log_domain, GLogLevelFlags log_level, - const char * message, + const char *message, gpointer user_data) { g_print("%s\n", message); } static inline void -__nmtst_init(int * argc, - char *** argv, +__nmtst_init(int *argc, + char ***argv, gboolean assert_logging, const char *log_level, const char *log_domains, - gboolean * out_set_logging) + gboolean *out_set_logging) { - const char * nmtst_debug; - gboolean is_debug = FALSE; - char * c_log_level = NULL, *c_log_domains = NULL; - char * sudo_cmd = NULL; - GArray * debug_messages = g_array_new(TRUE, FALSE, sizeof(char *)); - int i; - gboolean no_expect_message = FALSE; - gboolean _out_set_logging; - gboolean test_quick = FALSE; - gboolean test_quick_set = FALSE; - gboolean test_quick_argv = FALSE; - gs_unref_ptrarray GPtrArray *p_tests = NULL; - gs_unref_ptrarray GPtrArray *s_tests = NULL; + const char *nmtst_debug; + gboolean is_debug = FALSE; + char *c_log_level = NULL, *c_log_domains = NULL; + char *sudo_cmd = NULL; + GArray *debug_messages = g_array_new(TRUE, FALSE, sizeof(char *)); + int i; + gboolean no_expect_message = FALSE; + gboolean _out_set_logging; + gboolean test_quick = FALSE; + gboolean test_quick_set = FALSE; + gboolean test_quick_argv = FALSE; + gs_unref_ptrarray GPtrArray *p_tests = NULL; + gs_unref_ptrarray GPtrArray *s_tests = NULL; if (!out_set_logging) out_set_logging = &_out_set_logging; @@ -471,10 +471,10 @@ __nmtst_init(int * argc, /* g_test_init() sets g_log_set_always_fatal() for G_LOG_LEVEL_WARNING * and G_LOG_LEVEL_CRITICAL. So, beware that the test will fail if you * have any WARN or ERR log messages -- unless you g_test_expect_message(). */ - GPtrArray * arg_array = g_ptr_array_new(); + GPtrArray *arg_array = g_ptr_array_new(); gs_free char **arg_array_c = NULL; int arg_array_n, j; - static char ** s_tests_x, **p_tests_x; + static char **s_tests_x, **p_tests_x; if (*argc) { for (i = 0; i < *argc; i++) @@ -628,7 +628,7 @@ __nmtst_init(int * argc, * add "/bin" and "/sbin" to $PATH for all tests. */ { static char *path_new; - const char * path_old; + const char *path_old; g_assert(!path_new); @@ -747,10 +747,10 @@ typedef void (*NmtstTestHandler)(const NmtstTestData *test_data); struct _NmtstTestData { union { const char *testpath; - char * _testpath; + char *_testpath; }; gsize n_args; - gpointer * args; + gpointer *args; NmtstTestHandler _func_setup; GTestDataFunc _func_test; NmtstTestHandler _func_teardown; @@ -804,7 +804,7 @@ _nmtst_test_run(gconstpointer data) } static inline void -_nmtst_add_test_func_full(const char * testpath, +_nmtst_add_test_func_full(const char *testpath, GTestDataFunc func_test, NmtstTestHandler func_setup, NmtstTestHandler func_teardown, @@ -874,7 +874,7 @@ nmtst_get_rand(void) g_rand_set_seed(__nmtst_internal.rand, seed); } else { /* NMTST_SEED_RAND is set. Use it as a seed. */ - char * s; + char *s; gint64 i; i = g_ascii_strtoll(str, &s, 0); @@ -1067,7 +1067,7 @@ nmtst_stable_rand(guint64 seed, gpointer buf, gsize len) { const guint64 C = 1442695040888963407llu; const guint64 A = 6364136223846793005llu; - guint8 * b; + guint8 *b; union { guint8 a[sizeof(guint64)]; guint64 n; @@ -1203,7 +1203,7 @@ static inline gboolean nmtst_main_loop_run(GMainLoop *loop, guint timeout_msec) { nm_auto_unref_gsource GSource *source = NULL; - GMainLoop * loopx = loop; + GMainLoop *loopx = loop; if (timeout_msec > 0) { source = g_timeout_source_new(timeout_msec); @@ -1244,7 +1244,7 @@ _nmtst_main_loop_quit_on_notify(GObject *object, GParamSpec *pspec, gpointer use ({ \ nm_auto_destroy_and_unref_gsource GSource *_source_timeout = NULL; \ nm_auto_destroy_and_unref_gsource GSource *_source_poll = NULL; \ - GMainContext * _context = (context); \ + GMainContext *_context = (context); \ gboolean _had_timeout = FALSE; \ typeof(timeout_msec) _timeout_msec0 = (timeout_msec); \ typeof(poll_msec) _poll_msec0 = (poll_msec); \ @@ -1319,7 +1319,7 @@ nmtst_main_context_assert_no_dispatch(GMainContext *context, guint timeout_msec) typedef struct { GMainLoop *_main_loop; union { - GSList * _list; + GSList *_list; const void *const is_waiting; }; } NMTstContextBusyWatcherData; @@ -1328,7 +1328,7 @@ static inline void _nmtst_context_busy_watcher_add_cb(gpointer data, GObject *where_the_object_was) { NMTstContextBusyWatcherData *watcher_data = data; - GSList * l; + GSList *l; g_assert(watcher_data); @@ -1389,7 +1389,7 @@ nmtst_get_sudo_cmd(void) static inline void nmtst_reexec_sudo(void) { - char * str; + char *str; char **argv; int i; int errsv; @@ -1426,7 +1426,7 @@ nmtst_find_all_indexes(gpointer *elements, gsize n_needles, gboolean (*equal_fcn)(gpointer element, gpointer needle, gpointer user_data), gpointer user_data, - gssize * out_idx) + gssize *out_idx) { gsize i, j, k; gsize found = 0; @@ -1489,13 +1489,13 @@ __define_nmtst_static(01, 1024) __define_nmtst_static(02, 1024) __define_nmtst_s #if defined(__NM_UTILS_H__) || defined(NM_UTILS_H) #define NMTST_UUID_INIT(uuid) \ - gs_free char * _nmtst_hidden_##uuid = nm_utils_uuid_generate(); \ + gs_free char *_nmtst_hidden_##uuid = nm_utils_uuid_generate(); \ const char *const uuid = _nmtst_hidden_##uuid static inline const char *nmtst_uuid_generate(void) { static _nm_thread_local char u[37]; - gs_free char * m = NULL; + gs_free char *m = NULL; m = nm_utils_uuid_generate(); g_assert(m && strlen(m) == sizeof(u) - 1); @@ -1609,10 +1609,10 @@ _nmtst_assert_ip4_address(const char *file, int line, in_addr_t addr, const char _nmtst_assert_ip4_address(__FILE__, __LINE__, addr, str_expected) static inline void -_nmtst_assert_ip6_address(const char * file, +_nmtst_assert_ip6_address(const char *file, int line, const struct in6_addr *addr, - const char * str_expected) + const char *str_expected) { struct in6_addr any = in6addr_any; @@ -1650,20 +1650,20 @@ _nmtst_assert_ip6_address(const char * file, ##__VA_ARGS__, \ NULL) static inline int __nmtst_spawn_sync(const char *working_directory, - char ** standard_out, - char ** standard_err, + char **standard_out, + char **standard_err, int assert_exit_status, ...) G_GNUC_NULL_TERMINATED; static inline int __nmtst_spawn_sync(const char *working_directory, - char ** standard_out, - char ** standard_err, + char **standard_out, + char **standard_err, int assert_exit_status, ...) { int exit_status = 0; - GError * error = NULL; - char * arg; + GError *error = NULL; + char *arg; va_list va_args; GPtrArray *argv = g_ptr_array_new(); gboolean success; @@ -1724,9 +1724,9 @@ nmtst_file_resolve_relative_path(const char *rel, const char *cwd) static inline char * nmtst_file_get_contents(const char *filename) { - GError * error = NULL; + GError *error = NULL; gboolean success; - char * contents = NULL; + char *contents = NULL; gsize len; success = g_file_get_contents(filename, &contents, &len, &error); @@ -1738,7 +1738,7 @@ nmtst_file_get_contents(const char *filename) #define nmtst_file_set_contents_size(filename, content, size) \ G_STMT_START \ { \ - GError * _error = NULL; \ + GError *_error = NULL; \ gboolean _success; \ const char *_content = (content); \ gssize _size = (size); \ @@ -1924,9 +1924,9 @@ nmtst_setting_ip_config_add_address(NMSettingIPConfig *s_ip, const char *address static inline void nmtst_setting_ip_config_add_route(NMSettingIPConfig *s_ip, - const char * dest, + const char *dest, guint prefix, - const char * next_hop, + const char *next_hop, gint64 metric) { NMIPRoute *route; @@ -2030,15 +2030,15 @@ nmtst_clone_connection(NMConnection *connection) } static inline NMConnection * -nmtst_create_minimal_connection(const char * id, - const char * uuid, - const char * type, +nmtst_create_minimal_connection(const char *id, + const char *uuid, + const char *type, NMSettingConnection **out_s_con) { - NMConnection * con; - NMSetting * s_base = NULL; + NMConnection *con; + NMSetting *s_base = NULL; NMSettingConnection *s_con; - gs_free char * uuid_free = NULL; + gs_free char *uuid_free = NULL; g_assert(id); @@ -2095,7 +2095,7 @@ nmtst_create_minimal_connection(const char * id, static inline gboolean _nmtst_connection_normalize_v(NMConnection *connection, va_list args) { - GError * error = NULL; + GError *error = NULL; gboolean success; gboolean was_modified = FALSE; GHashTable *parameters = NULL; @@ -2156,10 +2156,10 @@ nmtst_assert_connection_equals(NMConnection *a, NMConnection *b, gboolean normalize_b) { - gboolean compare; + gboolean compare; gs_unref_object NMConnection *a2 = NULL; gs_unref_object NMConnection *b2 = NULL; - GHashTable * out_settings = NULL; + GHashTable *out_settings = NULL; g_assert(NM_IS_CONNECTION(a)); g_assert(NM_IS_CONNECTION(b)); @@ -2171,8 +2171,8 @@ nmtst_assert_connection_equals(NMConnection *a, compare = nm_connection_diff(a, b, NM_SETTING_COMPARE_FLAG_EXACT, &out_settings); if (!compare || out_settings) { - const char * name, *pname; - GHashTable * setting; + const char *name, *pname; + GHashTable *setting; GHashTableIter iter, iter2; __NMTST_LOG(g_message, ">>> ASSERTION nmtst_assert_connection_equals() fails"); @@ -2190,7 +2190,7 @@ nmtst_assert_connection_equals(NMConnection *a, #ifdef __NM_KEYFILE_INTERNAL_H__ { nm_auto_unref_keyfile GKeyFile *kf_a = NULL, *kf_b = NULL; - gs_free char * str_a = NULL, *str_b = NULL; + gs_free char *str_a = NULL, *str_b = NULL; kf_a = nm_keyfile_write(a, NM_KEYFILE_HANDLER_FLAGS_NONE, NULL, NULL, NULL); kf_b = nm_keyfile_write(b, NM_KEYFILE_HANDLER_FLAGS_NONE, NULL, NULL, NULL); @@ -2222,7 +2222,7 @@ static inline void nmtst_assert_connection_verifies(NMConnection *con) { /* assert that the connection does verify, it might be normaliziable or not */ - GError * error = NULL; + GError *error = NULL; gboolean success; g_assert(NM_IS_CONNECTION(con)); @@ -2236,10 +2236,10 @@ static inline void nmtst_assert_connection_verifies_without_normalization(NMConnection *con) { /* assert that the connection verifies and does not need any normalization */ - GError * error = NULL; - gboolean success; - gboolean was_modified = FALSE; - gs_unref_object NMConnection *clone = NULL; + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + gs_unref_object NMConnection *clone = NULL; clone = nmtst_clone_connection(con); @@ -2256,10 +2256,10 @@ static inline void nmtst_assert_connection_verifies_and_normalizable(NMConnection *con) { /* assert that the connection does verify, but normalization still modifies it */ - GError * error = NULL; - gboolean success; - gboolean was_modified = FALSE; - gs_unref_object NMConnection *clone = NULL; + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + gs_unref_object NMConnection *clone = NULL; clone = nmtst_clone_connection(con); @@ -2280,10 +2280,10 @@ nmtst_assert_connection_verifies_after_normalization(NMConnection *con, int expect_error_code) { /* assert that the connection does not verify, but normalization does fix it */ - GError * error = NULL; - gboolean success; - gboolean was_modified = FALSE; - gs_unref_object NMConnection *clone = NULL; + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + gs_unref_object NMConnection *clone = NULL; clone = nmtst_clone_connection(con); @@ -2308,10 +2308,10 @@ nmtst_assert_connection_unnormalizable(NMConnection *con, { /* assert that the connection does not verify, and it cannot be fixed by normalization */ - GError * error = NULL; - gboolean success; - gboolean was_modified = FALSE; - gs_unref_object NMConnection *clone = NULL; + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + gs_unref_object NMConnection *clone = NULL; clone = nmtst_clone_connection(con); @@ -2333,7 +2333,7 @@ nmtst_assert_setting_verifies(NMSetting *setting) { /* assert that the setting verifies without an error */ - GError * error = NULL; + GError *error = NULL; gboolean success; g_assert(NM_IS_SETTING(setting)); @@ -2351,12 +2351,12 @@ _nmtst_assert_connection_has_settings(NMConnection *connection, gboolean has_at_most, ...) { - gs_unref_hashtable GHashTable *names = NULL; - gs_free NMSetting **settings = NULL; - va_list ap; - const char * name; - guint i, len; - gs_unref_ptrarray GPtrArray *names_arr = NULL; + gs_unref_hashtable GHashTable *names = NULL; + gs_free NMSetting **settings = NULL; + va_list ap; + const char *name; + guint i, len; + gs_unref_ptrarray GPtrArray *names_arr = NULL; g_assert(NM_IS_CONNECTION(connection)); @@ -2382,9 +2382,9 @@ _nmtst_assert_connection_has_settings(NMConnection *connection, } } if (g_hash_table_size(names) > 0 && has_at_least) { - gs_free char * expected_str = g_strjoinv(" ", (char **) names_arr->pdata); + gs_free char *expected_str = g_strjoinv(" ", (char **) names_arr->pdata); gs_free const char **settings_names = NULL; - gs_free char * has_str = NULL; + gs_free char *has_str = NULL; settings_names = g_new0(const char *, len + 1); for (i = 0; i < len; i++) @@ -2413,7 +2413,7 @@ nmtst_assert_setting_verify_fails(NMSetting *setting, { /* assert that the setting verification fails */ - GError * error = NULL; + GError *error = NULL; gboolean success; g_assert(NM_IS_SETTING(setting)); @@ -2452,7 +2452,7 @@ nmtst_assert_setting_is_equal(gconstpointer /* const NMSetting * */ a, static inline NMSetting * nmtst_assert_setting_dbus_new(GType gtype, GVariant *variant) { - NMSetting * setting; + NMSetting *setting; gs_free_error GError *error = NULL; g_assert(g_type_is_a(gtype, NM_TYPE_SETTING)); @@ -2484,8 +2484,8 @@ nmtst_assert_setting_dbus_roundtrip(gconstpointer /* const NMSetting * */ settin static inline void nmtst_assert_hwaddr_equals(gconstpointer hwaddr1, gssize hwaddr1_len, - const char * expected, - const char * file, + const char *expected, + const char *file, int line) { guint8 buf2[NM_UTILS_HWADDR_LEN_MAX]; @@ -2531,11 +2531,11 @@ static inline NMConnection * nmtst_create_connection_from_keyfile(const char *keyfile_str, const char *full_filename) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_free_error GError *error = NULL; - gboolean success; - NMConnection * con; - gs_free char * filename = g_path_get_basename(full_filename); - gs_free char * base_dir = g_path_get_dirname(full_filename); + gs_free_error GError *error = NULL; + gboolean success; + NMConnection *con; + gs_free char *filename = g_path_get_basename(full_filename); + gs_free char *base_dir = g_path_get_dirname(full_filename); g_assert(keyfile_str); g_assert(full_filename && full_filename[0] == '/'); @@ -2568,8 +2568,8 @@ _nmtst_variant_new_vardict(int dummy, ...) { GVariantBuilder builder; va_list ap; - const char * name; - GVariant * variant; + const char *name; + GVariant *variant; g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); @@ -2608,7 +2608,7 @@ _nmtst_variant_new_vardict(int dummy, ...) G_STMT_START \ { \ gsize _l; \ - GVariant * _variant = (variant); \ + GVariant *_variant = (variant); \ const char *_str = (str); \ \ nmtst_assert_variant_is_of_type(_variant, G_VARIANT_TYPE_STRING); \ @@ -2625,8 +2625,8 @@ _nmtst_variant_new_vardict(int dummy, ...) if (memcmp(_ptr2, _ptr, _len) != 0) { \ gs_free char *_x1 = NULL; \ gs_free char *_x2 = NULL; \ - const char * _xx1; \ - const char * _xx2; \ + const char *_xx1; \ + const char *_xx2; \ \ _xx1 = nm_utils_buf_utf8safe_escape(_ptr, \ _len, \ @@ -2650,7 +2650,7 @@ _nmtst_variant_new_vardict(int dummy, ...) #define nmtst_assert_variant_bytestring(variant, ptr, len) \ G_STMT_START \ { \ - GVariant * _variant = (variant); \ + GVariant *_variant = (variant); \ gconstpointer _ptr = (ptr); \ gconstpointer _ptr2; \ gsize _len = (len); \ @@ -2677,8 +2677,8 @@ typedef enum { { \ GVariantIter __connection_iter, *__setting_iter; \ GVariantBuilder __connection_builder, __setting_builder; \ - const char * __cur_setting_name, *__cur_property_name; \ - GVariant * __property_val; \ + const char *__cur_setting_name, *__cur_property_name; \ + GVariant *__property_val; \ NmtstVariantEditorPhase __phase; \ \ g_variant_builder_init(&__connection_builder, NM_VARIANT_TYPE_CONNECTION); \ @@ -2790,7 +2790,7 @@ static inline GVariant * nmtst_variant_from_string(const GVariantType *variant_type, const char *variant_str) { GVariant *variant; - GError * error = NULL; + GError *error = NULL; g_assert(variant_type); g_assert(variant_str); @@ -2805,13 +2805,13 @@ nmtst_variant_from_string(const GVariantType *variant_type, const char *variant_ static inline void nmtst_keyfile_assert_data(GKeyFile *kf, const char *data, gssize data_len) { - nm_auto_unref_keyfile GKeyFile *kf2 = NULL; - gs_free_error GError *error = NULL; - gs_free char * d1 = NULL; - gs_free char * d2 = NULL; - gboolean success; - gsize d1_len; - gsize d2_len; + nm_auto_unref_keyfile GKeyFile *kf2 = NULL; + gs_free_error GError *error = NULL; + gs_free char *d1 = NULL; + gs_free char *d2 = NULL; + gboolean success; + gsize d1_len; + gsize d2_len; g_assert(kf); g_assert(data || data_len == 0); @@ -2843,7 +2843,7 @@ nmtst_keyfile_assert_data(GKeyFile *kf, const char *data, gssize data_len) static inline gssize nmtst_keyfile_get_num_keys(GKeyFile *keyfile, const char *group_name) { - gs_strfreev char **keys = NULL; + gs_strfreev char **keys = NULL; gs_free_error GError *error = NULL; gsize l = 0; @@ -2871,7 +2871,7 @@ nmtst_ip_address_new(int addr_family, const char *str) { NMIPAddr addr; int plen; - GError * error = NULL; + GError *error = NULL; NMIPAddress *a; if (!nm_utils_parse_inaddr_prefix_bin(addr_family, str, &addr_family, &addr, &plen)) diff --git a/src/libnm-glib-aux/nm-uuid.c b/src/libnm-glib-aux/nm-uuid.c index e7f67c70e3..23f57f23aa 100644 --- a/src/libnm-glib-aux/nm-uuid.c +++ b/src/libnm-glib-aux/nm-uuid.c @@ -45,7 +45,7 @@ gboolean nm_uuid_parse_full(const char *str, NMUuid *out_uuid, gboolean *out_is_normalized) { NMUuid uuid; - guint8 * p; + guint8 *p; int i; gboolean is_normalized = TRUE; @@ -194,8 +194,8 @@ nm_uuid_is_valid_nmlegacy(const char *str) gboolean nm_uuid_is_valid_nm(const char *str, - gboolean * out_normalized, - char * out_normalized_str /* [static 37] */) + gboolean *out_normalized, + char *out_normalized_str /* [static 37] */) { NMUuid uuid; gboolean is_normalized; @@ -310,8 +310,8 @@ nm_uuid_generate_random_str(char buf[static 37]) * Returns: the input @uuid. This function cannot fail. **/ NMUuid * -nm_uuid_generate_from_string(NMUuid * uuid, - const char * s, +nm_uuid_generate_from_string(NMUuid *uuid, + const char *s, gssize slen, NMUuidType uuid_type, const NMUuid *type_args) @@ -382,7 +382,7 @@ nm_uuid_generate_from_string(NMUuid * uuid, * object's #NMSettingConnection:id: property **/ char * -nm_uuid_generate_from_string_str(const char * s, +nm_uuid_generate_from_string_str(const char *s, gssize slen, NMUuidType uuid_type, const NMUuid *type_args) @@ -415,7 +415,7 @@ nm_uuid_generate_from_strings(const char *string1, ...) { nm_auto_str_buf NMStrBuf str = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE); va_list args; - const char * s; + const char *s; nm_str_buf_append_len(&str, string1, strlen(string1) + 1u); diff --git a/src/libnm-glib-aux/nm-uuid.h b/src/libnm-glib-aux/nm-uuid.h index 504ec789be..15b03a2d47 100644 --- a/src/libnm-glib-aux/nm-uuid.h +++ b/src/libnm-glib-aux/nm-uuid.h @@ -76,8 +76,8 @@ nm_uuid_is_normalized(const char *str) gboolean nm_uuid_is_valid_nmlegacy(const char *str); gboolean nm_uuid_is_valid_nm(const char *str, - gboolean * out_normalized, - char * out_normalized_str /* [static 37] */); + gboolean *out_normalized, + char *out_normalized_str /* [static 37] */); /*****************************************************************************/ @@ -109,13 +109,13 @@ typedef enum { NM_UUID_TYPE_VERSION5 = 5, } NMUuidType; -NMUuid *nm_uuid_generate_from_string(NMUuid * uuid, - const char * s, +NMUuid *nm_uuid_generate_from_string(NMUuid *uuid, + const char *s, gssize slen, NMUuidType uuid_type, const NMUuid *type_args); -char *nm_uuid_generate_from_string_str(const char * s, +char *nm_uuid_generate_from_string_str(const char *s, gssize slen, NMUuidType uuid_type, const NMUuid *type_args); diff --git a/src/libnm-glib-aux/nm-value-type.h b/src/libnm-glib-aux/nm-value-type.h index 0addeec699..d774e12072 100644 --- a/src/libnm-glib-aux/nm-value-type.h +++ b/src/libnm-glib-aux/nm-value-type.h @@ -44,7 +44,7 @@ typedef union { /* for convenience, also let the union contain other pointer types. These are * for NM_VALUE_TYPE_UNSPEC. */ - gconstpointer * v_ptr; + gconstpointer *v_ptr; const GPtrArray *v_ptrarray; } NMValueTypUnion; @@ -181,7 +181,7 @@ nm_value_type_copy(NMValueType value_type, gpointer dst, gconstpointer src) static inline void nm_value_type_get_from_variant(NMValueType value_type, gpointer dst, - GVariant * variant, + GVariant *variant, gboolean clone) { switch (value_type) { @@ -230,7 +230,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 char *v_string; const GBytes *v_bytes; switch (value_type) { diff --git a/src/libnm-glib-aux/tests/test-json-aux.c b/src/libnm-glib-aux/tests/test-json-aux.c index 5f33f4fe39..32462a2981 100644 --- a/src/libnm-glib-aux/tests/test-json-aux.c +++ b/src/libnm-glib-aux/tests/test-json-aux.c @@ -13,7 +13,7 @@ static void test_jansson(void) { - const NMJsonVt * vt; + const NMJsonVt *vt; nm_auto_decref_json nm_json_t *js1 = NULL; nm_auto_decref_json nm_json_t *js2 = NULL; diff --git a/src/libnm-glib-aux/tests/test-shared-general.c b/src/libnm-glib-aux/tests/test-shared-general.c index 9674f228a8..f12579e363 100644 --- a/src/libnm-glib-aux/tests/test-shared-general.c +++ b/src/libnm-glib-aux/tests/test-shared-general.c @@ -35,7 +35,7 @@ test_nm_static_assert(void) { int v1[NM_STATIC_ASSERT_EXPR_1(1)]; typeof(NM_STATIC_ASSERT_EXPR_1(1)) v_int; - int * p_int; + int *p_int; G_STATIC_ASSERT(sizeof(v1) == sizeof(int)); G_STATIC_ASSERT(NM_STATIC_ASSERT_EXPR_1(1) == 1); @@ -218,7 +218,7 @@ test_nm_strndup_a(void) { gs_free char *dup_free = NULL; - const char * dup; + const char *dup; l = strlen(input) + 1; dup = nm_strndup_a(10, input, l - 1, &dup_free); @@ -231,7 +231,7 @@ test_nm_strndup_a(void) { gs_free char *dup_free = NULL; - const char * dup; + const char *dup; l = nmtst_get_rand_uint32() % 23; dup = nm_strndup_a(10, input, l, &dup_free); @@ -321,10 +321,10 @@ test_unaligned(void) /*****************************************************************************/ static void -_strv_cmp_fuzz_input(const char *const * in, +_strv_cmp_fuzz_input(const char *const *in, gssize l, - const char *** out_strv_free_shallow, - char *** out_strv_free_deep, + const char ***out_strv_free_shallow, + char ***out_strv_free_deep, const char *const **out_s1, const char *const **out_s2) { @@ -402,12 +402,12 @@ test_strv_cmp(void) { \ gssize _l1 = (l1); \ gssize _l2 = (l2); \ - const char *const * _a1; \ - const char *const * _a2; \ - const char *const * _a1x; \ - const char *const * _a2x; \ - char ** _a1_free_deep = NULL; \ - char ** _a2_free_deep = NULL; \ + const char *const *_a1; \ + const char *const *_a2; \ + const char *const *_a1x; \ + const char *const *_a2x; \ + char **_a1_free_deep = NULL; \ + char **_a2_free_deep = NULL; \ gs_free const char **_a1_free_shallow = NULL; \ gs_free const char **_a2_free_shallow = NULL; \ int _c1, _c2; \ @@ -468,8 +468,8 @@ _do_strstrip_avoid_copy(const char *str) gs_free char *str2 = g_strdup(str); gs_free char *str3 = NULL; gs_free char *str4 = NULL; - const char * s3; - const char * s4; + const char *s3; + const char *s4; if (str1) g_strstrip(str1); @@ -528,11 +528,11 @@ test_nm_utils_bin2hexstr(void) gboolean upper_case = nmtst_get_rand_bool(); gboolean hexdigit_pairs_mangled; gsize expected_strlen; - char * str_hex; + char *str_hex; gsize required_len; gboolean outlen_set; gsize outlen; - guint8 * bin2; + guint8 *bin2; guint i, j; nmtst_rand_buf(NULL, buf, len); @@ -647,7 +647,7 @@ static void test_nm_ref_string(void) { nm_auto_ref_string NMRefString *s1 = NULL; - NMRefString * s2; + NMRefString *s2; g_assert(NULL == NM_REF_STRING_UPCAST(NULL)); @@ -909,8 +909,8 @@ test_nm_str_buf(void) guint i_run; for (i_run = 0; TRUE; i_run++) { - nm_auto_str_buf NMStrBuf strbuf = {}; - nm_auto_free_gstring GString *gstr = NULL; + nm_auto_str_buf NMStrBuf strbuf = {}; + nm_auto_free_gstring GString *gstr = NULL; int i, j, k; int c; @@ -1102,7 +1102,7 @@ test_strv_dup_packed(void) for (i_run = 0; i_run < 500; i_run++) { const int strv_len = nmtst_get_rand_word_length(NULL); gs_free const char **strv_cpy = NULL; - const char *const * strv_src; + const char *const *strv_src; int i, j; g_ptr_array_set_size(src, 0); diff --git a/src/libnm-log-core/nm-logging.c b/src/libnm-log-core/nm-logging.c index 6d2c085eee..f464ef296d 100644 --- a/src/libnm-log-core/nm-logging.c +++ b/src/libnm-log-core/nm-logging.c @@ -257,7 +257,7 @@ match_log_level(const char *level, NMLogLevel *out_level, GError **error) gboolean nm_logging_setup(const char *level, const char *domains, char **bad_domains, GError **error) { - GString * unrecognized = NULL; + GString *unrecognized = NULL; NMLogDomain cur_log_state[_LOGL_N_REAL]; NMLogDomain new_log_state[_LOGL_N_REAL]; NMLogLevel cur_log_level; @@ -266,7 +266,7 @@ nm_logging_setup(const char *level, const char *domains, char **bad_domains, GEr gsize i_d; int i; gboolean had_platform_debug; - gs_free char * domains_free = NULL; + gs_free char *domains_free = NULL; NM_ASSERT_ON_MAIN_THREAD(); @@ -298,8 +298,8 @@ nm_logging_setup(const char *level, const char *domains, char **bad_domains, GEr domains_v = nm_strsplit_set(domains, ", "); for (i_d = 0; domains_v && domains_v[i_d]; i_d++) { - const char * s = domains_v[i_d]; - const char * p; + const char *s = domains_v[i_d]; + const char *p; const LogDesc *diter; NMLogLevel domain_log_level; NMLogDomain bits; @@ -517,7 +517,7 @@ again: static gsize once = 0; const LogDesc *diter; gsize buf_l; - char * buf_p; + char *buf_p; if (!g_once_init_enter(&once)) goto again; @@ -603,12 +603,12 @@ _iovec_set_string(struct iovec *iov, const char *str) #define _iovec_set_string_literal(iov, str) _iovec_set((iov), "" str "", NM_STRLEN(str)) _nm_printf(3, 4) static void _iovec_set_format(struct iovec *iov, - char ** iov_free, - const char * format, + char **iov_free, + const char *format, ...) { va_list ap; - char * str; + char *str; va_start(ap, format); str = g_strdup_vprintf(format, ap); @@ -663,14 +663,14 @@ _nm_log_impl(const char *file, ...) { char msg_stack[400]; - gs_free char * msg_heap = NULL; - const char * msg; + gs_free char *msg_heap = NULL; + const char *msg; GTimeVal tv; int errsv; const NMLogDomain *cur_log_state; NMLogDomain cur_log_state_copy[_LOGL_N_REAL]; Global g_copy; - const Global * g; + const Global *g; if (G_UNLIKELY(mt_require_locking)) { G_LOCK(log); @@ -722,9 +722,9 @@ _nm_log_impl(const char *file, { gint64 now, boottime; struct iovec iov_data[15]; - struct iovec * iov = iov_data; - char * iov_free_data[5]; - char ** iov_free = iov_free_data; + struct iovec *iov = iov_data; + char *iov_free_data[5]; + char **iov_free = iov_free_data; const LogDesc *diter; NMLogDomain dom_all; char s_log_domains_buf[NM_STRLEN("NM_LOG_DOMAINS=") + sizeof(_all_logging_domains_to_str)]; diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 867ef7b501..1a468f2054 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -403,10 +403,10 @@ typedef struct { WaitForNlResponseResult seq_result; DelayedActionWaitForNlResponseType response_type; gint64 timeout_abs_ns; - WaitForNlResponseResult * out_seq_result; - char ** out_errmsg; + WaitForNlResponseResult *out_seq_result; + char **out_errmsg; union { - int * out_refresh_all_in_progress; + int *out_refresh_all_in_progress; NMPObject **out_route_get; gpointer out_data; } response; @@ -446,7 +446,7 @@ typedef struct { GPtrArray *list_master_connected; GPtrArray *list_refresh_link; - GArray * list_wait_for_nl_response; + GArray *list_wait_for_nl_response; int is_handling; } delayed_action; @@ -493,7 +493,7 @@ NM_LINUX_PLATFORM_FROM_PRIVATE(NMLinuxPlatformPrivate *priv) G_STMT_START \ { \ char __prefix[32]; \ - const char * __p_prefix = _NMLOG_PREFIX_NAME; \ + const char *__p_prefix = _NMLOG_PREFIX_NAME; \ NMPlatform *const __self = (self); \ \ if (__self && nm_platform_get_log_with_ptr(__self)) { \ @@ -554,7 +554,7 @@ delayed_action_schedule(NMPlatform *platform, DelayedActionType action_type, gpo static gboolean delayed_action_handle_all(NMPlatform *platform, gboolean read_netlink); static void do_request_link_no_delayed_actions(NMPlatform *platform, int ifindex, const char *name); static void do_request_all_no_delayed_actions(NMPlatform *platform, DelayedActionType action_type); -static void cache_on_change(NMPlatform * platform, +static void cache_on_change(NMPlatform *platform, NMPCacheOpsType cache_op, const NMPObject *obj_old, const NMPObject *obj_new); @@ -576,8 +576,8 @@ wait_for_nl_response_to_nmerr(WaitForNlResponseResult seq_result) static const char * wait_for_nl_response_to_string(WaitForNlResponseResult seq_result, - const char * errmsg, - char * buf, + const char *errmsg, + char *buf, gsize buf_size) { char *buf0 = buf; @@ -993,9 +993,9 @@ _addrtime_get_lifetimes(guint32 timestamp, /*****************************************************************************/ static const NMPObject * -_lookup_cached_link(const NMPCache * cache, +_lookup_cached_link(const NMPCache *cache, int ifindex, - gboolean * completed_from_cache, + gboolean *completed_from_cache, const NMPObject **link_cached) { const NMPObject *obj; @@ -1019,7 +1019,7 @@ static char * _linktype_read_devtype(int dirfd) { gs_free char *contents = NULL; - char * cont, *end; + char *cont, *end; nm_assert(dirfd >= 0); @@ -1046,16 +1046,16 @@ _linktype_read_devtype(int dirfd) } static NMLinkType -_linktype_get_type(NMPlatform * platform, - const NMPCache * cache, - const char * kind, +_linktype_get_type(NMPlatform *platform, + const NMPCache *cache, + const char *kind, int ifindex, - const char * ifname, + const char *ifname, unsigned flags, unsigned arptype, - gboolean * completed_from_cache, + gboolean *completed_from_cache, const NMPObject **link_cached, - const char ** out_kind) + const char **out_kind) { NMLinkType link_type; @@ -1138,7 +1138,7 @@ _linktype_get_type(NMPlatform * platform, { nm_auto_close int dirfd = -1; - gs_free char * devtype = NULL; + gs_free char *devtype = NULL; char ifname_verified[IFNAMSIZ]; dirfd = nmp_utils_sysctl_open_netdir(ifindex, ifname, ifname_verified); @@ -1242,12 +1242,12 @@ _nl_addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int al /* Copied and heavily modified from libnl3's inet6_parse_protinfo(). */ static gboolean -_parse_af_inet6(NMPlatform * platform, - struct nlattr * attr, +_parse_af_inet6(NMPlatform *platform, + struct nlattr *attr, NMUtilsIPv6IfaceId *out_token, - gboolean * out_token_valid, - guint8 * out_addr_gen_mode_inv, - gboolean * out_addr_gen_mode_valid) + gboolean *out_token_valid, + guint8 *out_addr_gen_mode_inv, + gboolean *out_addr_gen_mode_valid) { static const struct nla_policy policy[] = { [IFLA_INET6_FLAGS] = {.type = NLA_U32}, @@ -1258,7 +1258,7 @@ _parse_af_inet6(NMPlatform * platform, [IFLA_INET6_TOKEN] = {.minlen = sizeof(struct in6_addr)}, [IFLA_INET6_ADDR_GEN_MODE] = {.type = NLA_U8}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; + struct nlattr *tb[G_N_ELEMENTS(policy)]; struct in6_addr i6_token; gboolean token_valid = FALSE; gboolean addr_gen_mode_valid = FALSE; @@ -1331,8 +1331,8 @@ _parse_lnk_bridge(const char *kind, struct nlattr *info_data) [IFLA_BR_MCAST_STARTUP_QUERY_INTVL] = {.type = NLA_U64}, }; NMPlatformLnkBridge *props; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; if (!info_data || !nm_streq0(kind, "bridge")) return NULL; @@ -1420,8 +1420,8 @@ _parse_lnk_gre(const char *kind, struct nlattr *info_data) [IFLA_GRE_TOS] = {.type = NLA_U8}, [IFLA_GRE_PMTUDISC] = {.type = NLA_U8}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; NMPlatformLnkGre *props; gboolean is_tap; @@ -1480,10 +1480,10 @@ _parse_lnk_infiniband(const char *kind, struct nlattr *info_data) [IFLA_IPOIB_MODE] = {.type = NLA_U16}, [IFLA_IPOIB_UMCAST] = {.type = NLA_U16}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; + struct nlattr *tb[G_N_ELEMENTS(policy)]; NMPlatformLnkInfiniband *info; - NMPObject * obj; - const char * mode; + NMPObject *obj; + const char *mode; if (!info_data || !nm_streq0(kind, "ipoib")) return NULL; @@ -1529,8 +1529,8 @@ _parse_lnk_ip6tnl(const char *kind, struct nlattr *info_data) [IFLA_IPTUN_PROTO] = {.type = NLA_U8}, [IFLA_IPTUN_FLAGS] = {.type = NLA_U32}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; NMPlatformLnkIp6Tnl *props; guint32 flowinfo; @@ -1582,8 +1582,8 @@ _parse_lnk_ip6gre(const char *kind, struct nlattr *info_data) [IFLA_GRE_FLOWINFO] = {.type = NLA_U32}, [IFLA_GRE_FLAGS] = {.type = NLA_U32}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; NMPlatformLnkIp6Tnl *props; guint32 flowinfo; gboolean is_tap; @@ -1648,8 +1648,8 @@ _parse_lnk_ipip(const char *kind, struct nlattr *info_data) [IFLA_IPTUN_TOS] = {.type = NLA_U8}, [IFLA_IPTUN_PMTUDISC] = {.type = NLA_U8}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; NMPlatformLnkIpIp *props; if (!info_data || !nm_streq0(kind, "ipip")) @@ -1681,8 +1681,8 @@ _parse_lnk_macvlan(const char *kind, struct nlattr *info_data) [IFLA_MACVLAN_FLAGS] = {.type = NLA_U16}, }; NMPlatformLnkMacvlan *props; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; gboolean tap; if (!info_data || !kind) @@ -1732,8 +1732,8 @@ _parse_lnk_macsec(const char *kind, struct nlattr *info_data) [IFLA_MACSEC_REPLAY_PROTECT] = {.type = NLA_U8}, [IFLA_MACSEC_VALIDATION] = {.type = NLA_U8}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; NMPlatformLnkMacsec *props; if (!info_data || !nm_streq0(kind, "macsec")) @@ -1800,8 +1800,8 @@ _parse_lnk_sit(const char *kind, struct nlattr *info_data) [IFLA_IPTUN_FLAGS] = {.type = NLA_U16}, [IFLA_IPTUN_PROTO] = {.type = NLA_U8}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; NMPlatformLnkSit *props; if (!info_data || !nm_streq0(kind, "sit")) @@ -1841,8 +1841,8 @@ _parse_lnk_tun(const char *kind, struct nlattr *info_data) [IFLA_TUN_NUM_QUEUES] = {.type = NLA_U32}, [IFLA_TUN_NUM_DISABLED_QUEUES] = {.type = NLA_U32}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; NMPlatformLnkTun *props; if (!info_data || !nm_streq0(kind, "tun")) @@ -1878,12 +1878,12 @@ _parse_lnk_tun(const char *kind, struct nlattr *info_data) /*****************************************************************************/ static gboolean -_vlan_qos_mapping_from_nla(struct nlattr * nlattr, +_vlan_qos_mapping_from_nla(struct nlattr *nlattr, const NMVlanQosMapping **out_map, - guint * out_n_map) + guint *out_n_map) { - struct nlattr * nla; - int remaining; + struct nlattr *nla; + int remaining; gs_unref_ptrarray GPtrArray *array = NULL; G_STATIC_ASSERT(sizeof(NMVlanQosMapping) == sizeof(struct ifla_vlan_qos_mapping)); @@ -1950,9 +1950,9 @@ _parse_lnk_vlan(const char *kind, struct nlattr *info_data) [IFLA_VLAN_EGRESS_QOS] = {.type = NLA_NESTED}, [IFLA_VLAN_PROTOCOL] = {.type = NLA_U16}, }; - struct nlattr *tb[G_N_ELEMENTS(policy)]; + struct nlattr *tb[G_N_ELEMENTS(policy)]; nm_auto_nmpobj NMPObject *obj = NULL; - NMPObject * obj_result; + NMPObject *obj_result; if (!info_data || !nm_streq0(kind, "vlan")) return NULL; @@ -2050,8 +2050,8 @@ _parse_lnk_vxlan(const char *kind, struct nlattr *info_data) [IFLA_VXLAN_PORT] = {.type = NLA_U16}, }; NMPlatformLnkVxlan *props; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; if (!info_data || !nm_streq0(kind, "vxlan")) return NULL; @@ -2117,8 +2117,8 @@ _parse_lnk_vrf(const char *kind, struct nlattr *info_data) [IFLA_VRF_TABLE] = {.type = NLA_U32}, }; NMPlatformLnkVrf *props; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj; if (!info_data || !nm_streq0(kind, "vrf")) return NULL; @@ -2199,7 +2199,7 @@ _wireguard_update_from_peers_nla(CList *peers, GArray **p_allowed_ips, struct nl [WGPEER_A_TX_BYTES] = {.type = NLA_U64}, [WGPEER_A_ALLOWEDIPS] = {.type = NLA_NESTED}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; + struct nlattr *tb[G_N_ELEMENTS(policy)]; WireGuardPeerConstruct *peer_c; if (nla_parse_nested_arr(tb, peer_attr, policy) < 0) @@ -2259,7 +2259,7 @@ _wireguard_update_from_peers_nla(CList *peers, GArray **p_allowed_ips, struct nl if (tb[WGPEER_A_ALLOWEDIPS]) { struct nlattr *attr; int rem; - GArray * allowed_ips = *p_allowed_ips; + GArray *allowed_ips = *p_allowed_ips; nla_for_each_nested (attr, tb[WGPEER_A_ALLOWEDIPS], rem) { if (!allowed_ips) { @@ -2290,7 +2290,7 @@ typedef struct { const int ifindex; NMPObject *obj; CList peers; - GArray * allowed_ips; + GArray *allowed_ips; } WireGuardParseData; static int @@ -2306,7 +2306,7 @@ _wireguard_get_device_cb(struct nl_msg *msg, void *arg) [WGDEVICE_A_FWMARK] = {.type = NLA_U32}, [WGDEVICE_A_PEERS] = {.type = NLA_NESTED}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; + struct nlattr *tb[G_N_ELEMENTS(policy)]; WireGuardParseData *parse_data = arg; if (genlmsg_parse_arr(nlmsg_hdr(msg), 0, tb, policy) < 0) @@ -2327,7 +2327,7 @@ _wireguard_get_device_cb(struct nl_msg *msg, void *arg) /* we already have an object instance. This means the netlink message * is a continuation, only providing more WGDEVICE_A_PEERS data below. */ } else { - NMPObject * obj; + NMPObject *obj; NMPlatformLnkWireGuard *props; obj = nmp_object_new(NMP_OBJECT_TYPE_LNK_WIREGUARD, NULL); @@ -2370,18 +2370,18 @@ _wireguard_get_device_cb(struct nl_msg *msg, void *arg) } static const NMPObject * -_wireguard_read_info(NMPlatform * platform /* used only as logging context */, +_wireguard_read_info(NMPlatform *platform /* used only as logging context */, struct nl_sock *genl, int wireguard_family_id, int ifindex) { nm_auto_nlmsg struct nl_msg *msg = NULL; - NMPObject * obj = NULL; - WireGuardPeerConstruct * peer_c; - WireGuardPeerConstruct * peer_c_safe; - gs_unref_array GArray *allowed_ips = NULL; - WireGuardParseData parse_data = { - .ifindex = ifindex, + NMPObject *obj = NULL; + WireGuardPeerConstruct *peer_c; + WireGuardPeerConstruct *peer_c_safe; + gs_unref_array GArray *allowed_ips = NULL; + WireGuardParseData parse_data = { + .ifindex = ifindex, }; guint i; @@ -2522,13 +2522,13 @@ _wireguard_get_family_id(NMPlatform *platform, int ifindex_try) static const NMPObject * _wireguard_refresh_link(NMPlatform *platform, int wireguard_family_id, int ifindex) { - NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); nm_auto_nmpobj const NMPObject *obj_old = NULL; nm_auto_nmpobj const NMPObject *obj_new = NULL; nm_auto_nmpobj const NMPObject *lnk_new = NULL; NMPCacheOpsType cache_op; - const NMPObject * plink = NULL; - nm_auto_nmpobj NMPObject *obj = NULL; + const NMPObject *plink = NULL; + nm_auto_nmpobj NMPObject *obj = NULL; nm_assert(wireguard_family_id >= 0); nm_assert(ifindex > 0); @@ -2587,25 +2587,25 @@ _wireguard_refresh_link(NMPlatform *platform, int wireguard_family_id, int ifind } static int -_wireguard_create_change_nlmsgs(NMPlatform * platform, +_wireguard_create_change_nlmsgs(NMPlatform *platform, int ifindex, int wireguard_family_id, - const NMPlatformLnkWireGuard * lnk_wireguard, - const NMPWireGuardPeer * peers, + const NMPlatformLnkWireGuard *lnk_wireguard, + const NMPWireGuardPeer *peers, const NMPlatformWireGuardChangePeerFlags *peer_flags, guint peers_len, NMPlatformWireGuardChangeFlags change_flags, - GPtrArray ** out_msgs) + GPtrArray **out_msgs) { - gs_unref_ptrarray GPtrArray * msgs = NULL; - nm_auto_nlmsg struct nl_msg * msg = NULL; + gs_unref_ptrarray GPtrArray *msgs = NULL; + nm_auto_nlmsg struct nl_msg *msg = NULL; const guint IDX_NIL = G_MAXUINT; guint idx_peer_curr; guint idx_allowed_ips_curr; - struct nlattr * nest_peers; - struct nlattr * nest_curr_peer; - struct nlattr * nest_allowed_ips; - struct nlattr * nest_curr_allowed_ip; + struct nlattr *nest_peers; + struct nlattr *nest_curr_peer; + struct nlattr *nest_allowed_ips; + struct nlattr *nest_curr_allowed_ip; NMPlatformWireGuardChangePeerFlags p_flags = NM_PLATFORM_WIREGUARD_CHANGE_PEER_FLAG_DEFAULT; #define _nla_nest_end(msg, nest_start) \ @@ -2821,15 +2821,15 @@ nla_put_failure: } static int -link_wireguard_change(NMPlatform * platform, +link_wireguard_change(NMPlatform *platform, int ifindex, - const NMPlatformLnkWireGuard * lnk_wireguard, - const NMPWireGuardPeer * peers, + const NMPlatformLnkWireGuard *lnk_wireguard, + const NMPWireGuardPeer *peers, const NMPlatformWireGuardChangePeerFlags *peer_flags, guint peers_len, NMPlatformWireGuardChangeFlags change_flags) { - NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); gs_unref_ptrarray GPtrArray *msgs = NULL; int wireguard_family_id; guint i; @@ -2897,8 +2897,8 @@ _nmp_link_address_set(NMPLinkAddress *dst, const struct nlattr *nla) /* Copied and heavily modified from libnl3's link_msg_parser(). */ static NMPObject * -_new_from_nl_link(NMPlatform * platform, - const NMPCache * cache, +_new_from_nl_link(NMPlatform *platform, + const NMPCache *cache, struct nlmsghdr *nlh, gboolean id_only) { @@ -2930,15 +2930,15 @@ _new_from_nl_link(NMPlatform * platform, [IFLA_LINK_NETNSID] = {}, [IFLA_PERM_ADDRESS] = {.type = NLA_UNSPEC}, }; - const struct ifinfomsg *ifi; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - struct nlattr * nl_info_data = NULL; - const char * nl_info_kind = NULL; + const struct ifinfomsg *ifi; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + struct nlattr *nl_info_data = NULL; + const char *nl_info_kind = NULL; nm_auto_nmpobj NMPObject *obj = NULL; gboolean completed_from_cache_val = FALSE; - gboolean * completed_from_cache = cache ? &completed_from_cache_val : NULL; - const NMPObject * link_cached = NULL; - const NMPObject * lnk_data = NULL; + gboolean *completed_from_cache = cache ? &completed_from_cache_val : NULL; + const NMPObject *link_cached = NULL; + const NMPObject *lnk_data = NULL; gboolean address_complete_from_cache = TRUE; gboolean perm_address_complete_from_cache = TRUE; gboolean broadcast_complete_from_cache = TRUE; @@ -3210,7 +3210,7 @@ _new_from_nl_link(NMPlatform * platform, if (obj->link.type == NM_LINK_TYPE_WIREGUARD) { const NMPObject *lnk_data_new = NULL; - struct nl_sock * genl = NM_LINUX_PLATFORM_GET_PRIVATE(platform)->genl; + struct nl_sock *genl = NM_LINUX_PLATFORM_GET_PRIVATE(platform)->genl; /* The WireGuard kernel module does not yet send link update * notifications, so we don't actually update the cache. For @@ -3255,9 +3255,9 @@ _new_from_nl_addr(struct nlmsghdr *nlh, gboolean id_only) [IFA_CACHEINFO] = {.minlen = nm_offsetofend(struct ifa_cacheinfo, tstamp)}, [IFA_FLAGS] = {}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - const struct ifaddrmsg *ifa; - gboolean is_v4; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + const struct ifaddrmsg *ifa; + gboolean is_v4; nm_auto_nmpobj NMPObject *obj = NULL; int addr_len; guint32 lifetime, preferred, timestamp; @@ -3374,9 +3374,9 @@ _new_from_nl_route(struct nlmsghdr *nlh, gboolean id_only) [RTA_METRICS] = {.type = NLA_NESTED}, [RTA_MULTIPATH] = {.type = NLA_NESTED}, }; - const struct rtmsg *rtm; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - gboolean is_v4; + const struct rtmsg *rtm; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + gboolean is_v4; nm_auto_nmpobj NMPObject *obj = NULL; int addr_len; struct { @@ -3681,12 +3681,12 @@ _new_from_nl_routing_rule(struct nlmsghdr *nlh, gboolean id_only) .maxlen = sizeof(NMFibRulePortRange), }, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; + struct nlattr *tb[G_N_ELEMENTS(policy)]; const struct fib_rule_hdr *frh; - NMPlatformRoutingRule * props; - nm_auto_nmpobj NMPObject *obj = NULL; - int addr_family; - guint8 addr_size; + NMPlatformRoutingRule *props; + nm_auto_nmpobj NMPObject *obj = NULL; + int addr_family; + guint8 addr_size; if (nlmsg_parse_arr(nlh, sizeof(*frh), tb, policy) < 0) return NULL; @@ -3875,8 +3875,8 @@ _new_from_nl_qdisc(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_only) [TCA_KIND] = {.type = NLA_STRING}, [TCA_OPTIONS] = {.type = NLA_NESTED}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - const struct tcmsg *tcm; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + const struct tcmsg *tcm; nm_auto_nmpobj NMPObject *obj = NULL; if (!nm_platform_get_cache_tc(platform)) @@ -3925,7 +3925,7 @@ _new_from_nl_qdisc(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_only) [TCA_TBF_PARMS] = {.minlen = sizeof(struct tc_tbf_qopt)}, [TCA_TBF_RATE64] = {.type = NLA_U64}, }; - struct nlattr * tbf_tb[G_N_ELEMENTS(tbf_policy)]; + struct nlattr *tbf_tb[G_N_ELEMENTS(tbf_policy)]; struct tc_tbf_qopt opt; if (nla_parse_nested_arr(tbf_tb, tb[TCA_OPTIONS], tbf_policy) < 0) @@ -3987,8 +3987,8 @@ _new_from_nl_tfilter(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_onl static const struct nla_policy policy[] = { [TCA_KIND] = {.type = NLA_STRING}, }; - struct nlattr * tb[G_N_ELEMENTS(policy)]; - NMPObject * obj = NULL; + struct nlattr *tb[G_N_ELEMENTS(policy)]; + NMPObject *obj = NULL; const struct tcmsg *tcm; if (!nm_platform_get_cache_tc(platform)) @@ -4027,9 +4027,9 @@ _new_from_nl_tfilter(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_onl * Returns: %NULL or a newly created NMPObject instance. **/ static NMPObject * -nmp_object_new_from_nl(NMPlatform * platform, +nmp_object_new_from_nl(NMPlatform *platform, const NMPCache *cache, - struct nl_msg * msg, + struct nl_msg *msg, gboolean id_only) { struct nlmsghdr *msghdr; @@ -4112,7 +4112,7 @@ _nl_msg_new_link_set_linkinfo(struct nl_msg *msg, NMLinkType link_type, gconstpo { struct nlattr *info; struct nlattr *data = NULL; - const char * kind; + const char *kind; nm_assert(msg); @@ -4241,9 +4241,9 @@ _nl_msg_new_link_set_linkinfo(struct nl_msg *msg, NMLinkType link_type, gconstpo } case NM_LINK_TYPE_VETH: { - const char * veth_peer = extra_data; + const char *veth_peer = extra_data; const struct ifinfomsg ifi = {}; - struct nlattr * info_peer; + struct nlattr *info_peer; nm_assert(veth_peer); @@ -4437,7 +4437,7 @@ nla_put_failure: } static gboolean -_nl_msg_new_link_set_linkinfo_vlan(struct nl_msg * msg, +_nl_msg_new_link_set_linkinfo_vlan(struct nl_msg *msg, int vlan_id, guint32 flags_mask, guint32 flags_set, @@ -4558,10 +4558,10 @@ _nl_msg_new_link_full(int nlmsg_type, { nm_auto_nlmsg struct nl_msg *msg = NULL; const struct ifinfomsg ifi = { - .ifi_family = family, - .ifi_change = flags_mask, - .ifi_flags = flags_set, - .ifi_index = ifindex, + .ifi_family = family, + .ifi_change = flags_mask, + .ifi_flags = flags_set, + .ifi_index = ifindex, }; nm_assert(NM_IN_SET(nlmsg_type, RTM_DELLINK, RTM_NEWLINK, RTM_GETLINK, RTM_SETLINK)); @@ -4600,14 +4600,14 @@ _nl_msg_new_address(int nlmsg_type, guint32 lifetime, guint32 preferred, in_addr_t ip4_broadcast_address, - const char * label) + const char *label) { nm_auto_nlmsg struct nl_msg *msg = NULL; struct ifaddrmsg am = { - .ifa_family = family, - .ifa_index = ifindex, - .ifa_prefixlen = plen, - .ifa_flags = flags, + .ifa_family = family, + .ifa_index = ifindex, + .ifa_prefixlen = plen, + .ifa_flags = flags, }; gsize addr_len; @@ -4684,7 +4684,7 @@ static struct nl_msg * _nl_msg_new_route(int nlmsg_type, guint16 nlmsgflags, const NMPObject *obj) { nm_auto_nlmsg struct nl_msg *msg = NULL; - const NMPClass * klass = NMP_OBJECT_GET_CLASS(obj); + const NMPClass *klass = NMP_OBJECT_GET_CLASS(obj); gboolean is_v4 = klass->addr_family == AF_INET; const guint32 lock = ip_route_get_lock_flag(NMP_OBJECT_CAST_IP_ROUTE(obj)); const guint32 table = @@ -4903,13 +4903,13 @@ static struct nl_msg * _nl_msg_new_qdisc(int nlmsg_type, int nlmsg_flags, const NMPlatformQdisc *qdisc) { nm_auto_nlmsg struct nl_msg *msg = NULL; - struct nlattr * tc_options; + struct nlattr *tc_options; const struct tcmsg tcm = { - .tcm_family = qdisc->addr_family, - .tcm_ifindex = qdisc->ifindex, - .tcm_handle = qdisc->handle, - .tcm_parent = qdisc->parent, - .tcm_info = qdisc->info, + .tcm_family = qdisc->addr_family, + .tcm_ifindex = qdisc->ifindex, + .tcm_handle = qdisc->handle, + .tcm_parent = qdisc->parent, + .tcm_info = qdisc->info, }; msg = nlmsg_alloc_simple(nlmsg_type, nlmsg_flags | NMP_NLM_FLAG_F_ECHO); @@ -4990,14 +4990,14 @@ static struct nl_msg * _nl_msg_new_tfilter(int nlmsg_type, int nlmsg_flags, const NMPlatformTfilter *tfilter) { nm_auto_nlmsg struct nl_msg *msg = NULL; - struct nlattr * tc_options; - struct nlattr * act_tab; + struct nlattr *tc_options; + struct nlattr *act_tab; const struct tcmsg tcm = { - .tcm_family = tfilter->addr_family, - .tcm_ifindex = tfilter->ifindex, - .tcm_handle = tfilter->handle, - .tcm_parent = tfilter->parent, - .tcm_info = tfilter->info, + .tcm_family = tfilter->addr_family, + .tcm_ifindex = tfilter->ifindex, + .tcm_handle = tfilter->handle, + .tcm_parent = tfilter->parent, + .tcm_info = tfilter->info, }; msg = nlmsg_alloc_simple(nlmsg_type, nlmsg_flags | NMP_NLM_FLAG_F_ECHO); @@ -5015,8 +5015,8 @@ _nl_msg_new_tfilter(int nlmsg_type, int nlmsg_flags, const NMPlatformTfilter *tf if (tfilter->action.kind) { const NMPlatformAction *action = &tfilter->action; - struct nlattr * prio; - struct nlattr * act_options; + struct nlattr *prio; + struct nlattr *act_options; if (!(prio = nla_nest_start(msg, 1 /* priority */))) goto nla_put_failure; @@ -5120,7 +5120,7 @@ _log_dbg_sysctl_set_impl(NMPlatform *platform, const char *path, const char *value) { - GError * error = NULL; + GError *error = NULL; gs_free char *contents = NULL; gs_free char *value_escaped = g_strescape(value, NULL); @@ -5174,7 +5174,7 @@ sysctl_set_internal(NMPlatform *platform, int fd, tries; gssize nwrote; gssize len; - char * actual; + char *actual; gs_free char *actual_free = NULL; int errsv; @@ -5313,12 +5313,12 @@ sysctl_set(NMPlatform *platform, const char *pathid, int dirfd, const char *path } typedef struct { - NMPlatform * platform; - char * pathid; + NMPlatform *platform; + char *pathid; int dirfd; - char * path; - char ** values; - GCancellable * cancellable; + char *path; + char **values; + GCancellable *cancellable; NMPlatformAsyncCallback callback; gpointer callback_data; } SysctlAsyncInfo; @@ -5339,11 +5339,11 @@ sysctl_async_info_free(SysctlAsyncInfo *info) static void sysctl_async_cb(GObject *object, GAsyncResult *res, gpointer user_data) { - NMPlatform * platform; - GTask * task = G_TASK(res); - SysctlAsyncInfo *info; + NMPlatform *platform; + GTask *task = G_TASK(res); + SysctlAsyncInfo *info; gs_free_error GError *error = NULL; - gs_free char * values_str = NULL; + gs_free char *values_str = NULL; info = g_task_get_task_data(task); @@ -5359,15 +5359,15 @@ sysctl_async_cb(GObject *object, GAsyncResult *res, gpointer user_data) } static void -sysctl_async_thread_fn(GTask * task, +sysctl_async_thread_fn(GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable) { nm_auto_pop_netns NMPNetns *netns = NULL; - SysctlAsyncInfo * info = task_data; - GError * error = NULL; - char ** value; + SysctlAsyncInfo *info = task_data; + GError *error = NULL; + char **value; if (g_task_return_error_if_cancelled(task)) return; @@ -5402,11 +5402,11 @@ sysctl_async_thread_fn(GTask * task, static void sysctl_set_async_return_idle(gpointer user_data, GCancellable *cancellable) { - gs_unref_object NMPlatform *platform = NULL; - gs_free_error GError *cancelled_error = NULL; - gs_free_error GError * error = NULL; - NMPlatformAsyncCallback callback; - gpointer callback_data; + gs_unref_object NMPlatform *platform = NULL; + gs_free_error GError *cancelled_error = NULL; + gs_free_error GError *error = NULL; + NMPlatformAsyncCallback callback; + gpointer callback_data; nm_utils_user_data_unpack(user_data, &platform, &callback, &callback_data, &error); g_cancellable_set_error_if_cancelled(cancellable, &cancelled_error); @@ -5414,20 +5414,20 @@ sysctl_set_async_return_idle(gpointer user_data, GCancellable *cancellable) } static void -sysctl_set_async(NMPlatform * platform, - const char * pathid, +sysctl_set_async(NMPlatform *platform, + const char *pathid, int dirfd, - const char * path, - const char *const * values, + const char *path, + const char *const *values, NMPlatformAsyncCallback callback, gpointer data, - GCancellable * cancellable) + GCancellable *cancellable) { SysctlAsyncInfo *info; - GTask * task; + GTask *task; int dirfd_dup, errsv; gpointer packed; - GError * error = NULL; + GError *error = NULL; g_return_if_fail(platform); g_return_if_fail(path); @@ -5500,7 +5500,7 @@ _nm_logging_clear_platform_logging_cache(void) typedef struct { const char *path; CList lst; - char * value; + char *value; char path_data[]; } SysctlCacheEntry; @@ -5538,7 +5538,7 @@ _log_dbg_sysctl_get_impl(NMPlatform *platform, const char *pathid, const char *c **/ NM_G_MUTEX_LOCKED(&sysctl_clear_cache_lock); NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); - SysctlCacheEntry * entry = NULL; + SysctlCacheEntry *entry = NULL; if (!priv->sysctl_get_prev_values) { c_list_link_tail(&sysctl_clear_cache_lst_head, &priv->sysctl_clear_cache_lst); @@ -5566,7 +5566,7 @@ _log_dbg_sysctl_get_impl(NMPlatform *platform, const char *pathid, const char *c nm_c_list_move_front(&priv->sysctl_list, &entry->lst); } else { - gs_free char * contents_escaped = g_strescape(contents, NULL); + gs_free char *contents_escaped = g_strescape(contents, NULL); SysctlCacheEntry *old; size_t len; @@ -5601,8 +5601,8 @@ static char * sysctl_get(NMPlatform *platform, const char *pathid, int dirfd, const char *path) { nm_auto_pop_netns NMPNetns *netns = NULL; - GError * error = NULL; - gs_free char * contents = NULL; + GError *error = NULL; + gs_free char *contents = NULL; ASSERT_SYSCTL_ARGS(pathid, dirfd, path); @@ -5812,10 +5812,10 @@ static NM_UTILS_LOOKUP_STR_DEFINE( static const char * delayed_action_to_string_full(DelayedActionType action_type, gpointer user_data, - char * buf, + char *buf, gsize buf_size) { - char * buf0 = buf; + char *buf0 = buf; const DelayedActionWaitForNlResponseData *data; nm_strbuf_append_str(&buf, &buf_size, delayed_action_to_string(action_type)); @@ -5888,11 +5888,11 @@ delayed_action_refresh_all_in_progress(NMPlatform *platform, DelayedActionType a } static void -delayed_action_wait_for_nl_response_complete(NMPlatform * platform, +delayed_action_wait_for_nl_response_complete(NMPlatform *platform, guint idx, WaitForNlResponseResult seq_result) { - NMLinuxPlatformPrivate * priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); DelayedActionWaitForNlResponseData *data; nm_assert(NM_FLAGS_HAS(priv->delayed_action.flags, DELAYED_ACTION_TYPE_WAIT_FOR_NL_RESPONSE)); @@ -5931,11 +5931,11 @@ delayed_action_wait_for_nl_response_complete(NMPlatform * platform, } static void -delayed_action_wait_for_nl_response_complete_check(NMPlatform * platform, +delayed_action_wait_for_nl_response_complete_check(NMPlatform *platform, WaitForNlResponseResult force_result, - guint32 * out_next_seq_number, - gint64 * out_next_timeout_abs_ns, - gint64 * p_now_ns) + guint32 *out_next_seq_number, + gint64 *out_next_timeout_abs_ns, + gint64 *p_now_ns) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); guint i; @@ -5982,7 +5982,7 @@ delayed_action_wait_for_nl_response_complete_check(NMPlatform * platf } static void -delayed_action_wait_for_nl_response_complete_all(NMPlatform * platform, +delayed_action_wait_for_nl_response_complete_all(NMPlatform *platform, WaitForNlResponseResult fallback_result) { delayed_action_wait_for_nl_response_complete_check(platform, fallback_result, NULL, NULL, NULL); @@ -6182,10 +6182,10 @@ delayed_action_schedule(NMPlatform *platform, DelayedActionType action_type, gpo } static void -delayed_action_schedule_WAIT_FOR_NL_RESPONSE(NMPlatform * platform, +delayed_action_schedule_WAIT_FOR_NL_RESPONSE(NMPlatform *platform, guint32 seq_number, - WaitForNlResponseResult * out_seq_result, - char ** out_errmsg, + WaitForNlResponseResult *out_seq_result, + char **out_errmsg, DelayedActionWaitForNlResponseType response_type, gpointer response_out_data) { @@ -6210,7 +6210,7 @@ cache_prune_one_type(NMPlatform *platform, const NMPLookup *lookup) NMDedupMultiIter iter; const NMPObject *obj; NMPCacheOpsType cache_op; - NMPCache * cache = nm_platform_get_cache(platform); + NMPCache *cache = nm_platform_get_cache(platform); nm_dedup_multi_iter_init(&iter, nmp_cache_lookup(cache, lookup)); while (nm_dedup_multi_iter_next(&iter)) { @@ -6259,7 +6259,7 @@ cache_prune_all(NMPlatform *platform) } static void -cache_on_change(NMPlatform * platform, +cache_on_change(NMPlatform *platform, NMPCacheOpsType cache_op, const NMPObject *obj_old, const NMPObject *obj_new) @@ -6267,7 +6267,7 @@ cache_on_change(NMPlatform * platform, const NMPClass *klass; char str_buf[sizeof(_nm_utils_to_string_buffer)]; char str_buf2[sizeof(_nm_utils_to_string_buffer)]; - NMPCache * cache = nm_platform_get_cache(platform); + NMPCache *cache = nm_platform_get_cache(platform); ASSERT_nmp_cache_ops(cache, cache_op, obj_old, obj_new); nm_assert(cache_op != NMP_CACHE_OPS_UNCHANGED); @@ -6530,10 +6530,10 @@ _nlh_seq_next_get(NMLinuxPlatformPrivate *priv) * Returns: 0 on success or a negative errno. */ static int -_nl_send_nlmsghdr(NMPlatform * platform, - struct nlmsghdr * nlhdr, - WaitForNlResponseResult * out_seq_result, - char ** out_errmsg, +_nl_send_nlmsghdr(NMPlatform *platform, + struct nlmsghdr *nlhdr, + WaitForNlResponseResult *out_seq_result, + char **out_errmsg, DelayedActionWaitForNlResponseType response_type, gpointer response_out_data) { @@ -6597,15 +6597,15 @@ again: * Returns: 0 on success, or a negative libnl3 error code (beware, it's not an errno). */ static int -_nl_send_nlmsg(NMPlatform * platform, - struct nl_msg * nlmsg, - WaitForNlResponseResult * out_seq_result, - char ** out_errmsg, +_nl_send_nlmsg(NMPlatform *platform, + struct nl_msg *nlmsg, + WaitForNlResponseResult *out_seq_result, + char **out_errmsg, DelayedActionWaitForNlResponseType response_type, gpointer response_out_data) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); - struct nlmsghdr * nlhdr; + struct nlmsghdr *nlhdr; guint32 seq; int nle; @@ -6631,7 +6631,7 @@ _nl_send_nlmsg(NMPlatform * platform, static void do_request_link_no_delayed_actions(NMPlatform *platform, int ifindex, const char *name) { - NMLinuxPlatformPrivate * priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); nm_auto_nlmsg struct nl_msg *nlmsg = NULL; int nle; @@ -6679,7 +6679,7 @@ static struct nl_msg * _nl_msg_new_dump(NMPObjectType obj_type, int preferred_addr_family) { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - const NMPClass * klass; + const NMPClass *klass; klass = nmp_class_from_type(obj_type); @@ -6767,7 +6767,7 @@ do_request_all_no_delayed_actions(NMPlatform *platform, DelayedActionType action RefreshAllType refresh_all_type = delayed_action_type_to_refresh_all_type(iflags); const RefreshAllInfo *refresh_all_info = refresh_all_type_get_info(refresh_all_type); nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - int * out_refresh_all_in_progress; + int *out_refresh_all_in_progress; out_refresh_all_in_progress = &priv->delayed_action.refresh_all_in_progress[refresh_all_type]; @@ -6825,7 +6825,7 @@ do_request_one_type_by_needle_object(NMPlatform *platform, const NMPObject *obj_ static void event_seq_check_refresh_all(NMPlatform *platform, guint32 seq_number) { - NMLinuxPlatformPrivate * priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); DelayedActionWaitForNlResponseData *data; guint i; @@ -6854,12 +6854,12 @@ event_seq_check_refresh_all(NMPlatform *platform, guint32 seq_number) } static void -event_seq_check(NMPlatform * platform, +event_seq_check(NMPlatform *platform, guint32 seq_number, WaitForNlResponseResult seq_result, - const char * msg) + const char *msg) { - NMLinuxPlatformPrivate * priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); DelayedActionWaitForNlResponseData *data; guint i; @@ -6900,14 +6900,14 @@ event_seq_check(NMPlatform * platform, static void event_valid_msg(NMPlatform *platform, struct nl_msg *msg, gboolean handle_events) { - NMLinuxPlatformPrivate *priv; + NMLinuxPlatformPrivate *priv; nm_auto_nmpobj NMPObject *obj = NULL; NMPCacheOpsType cache_op; - struct nlmsghdr * msghdr; + struct nlmsghdr *msghdr; char buf_nlmsghdr[400]; gboolean is_del = FALSE; gboolean is_dump = FALSE; - NMPCache * cache = nm_platform_get_cache(platform); + NMPCache *cache = nm_platform_get_cache(platform); msghdr = nlmsg_hdr(msg); @@ -7084,18 +7084,18 @@ event_valid_msg(NMPlatform *platform, struct nl_msg *msg, gboolean handle_events /*****************************************************************************/ static int -do_add_link_with_lookup(NMPlatform * platform, +do_add_link_with_lookup(NMPlatform *platform, NMLinkType link_type, - const char * name, - struct nl_msg * nlmsg, + const char *name, + struct nl_msg *nlmsg, const NMPlatformLink **out_link) { - const NMPObject * obj = NULL; + const NMPObject *obj = NULL; WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; - gs_free char * errmsg = NULL; + gs_free char *errmsg = NULL; int nle; char s_buf[256]; - NMPCache * cache = nm_platform_get_cache(platform); + NMPCache *cache = nm_platform_get_cache(platform); event_handler_read_netlink(platform, FALSE); @@ -7134,13 +7134,13 @@ do_add_link_with_lookup(NMPlatform * platform, } static int -do_add_addrroute(NMPlatform * platform, +do_add_addrroute(NMPlatform *platform, const NMPObject *obj_id, - struct nl_msg * nlmsg, + struct nl_msg *nlmsg, gboolean suppress_netlink_failure) { WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; - gs_free char * errmsg = NULL; + gs_free char *errmsg = NULL; int nle; char s_buf[256]; @@ -7199,11 +7199,11 @@ static gboolean do_delete_object(NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *nlmsg) { WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; - gs_free char * errmsg = NULL; + gs_free char *errmsg = NULL; int nle; char s_buf[256]; gboolean success; - const char * log_detail = ""; + const char *log_detail = ""; event_handler_read_netlink(platform, FALSE); @@ -7269,23 +7269,23 @@ do_delete_object(NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *n } static int -do_change_link(NMPlatform * platform, +do_change_link(NMPlatform *platform, ChangeLinkType change_link_type, int ifindex, - struct nl_msg * nlmsg, + struct nl_msg *nlmsg, const ChangeLinkData *data) { nm_auto_pop_netns NMPNetns *netns = NULL; int nle; WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; - gs_free char * errmsg = NULL; + gs_free char *errmsg = NULL; char s_buf[256]; int result = 0; NMLogLevel log_level = LOGL_DEBUG; - const char * log_result = "failure"; - const char * log_detail = ""; - gs_free char * log_detail_free = NULL; - const NMPObject * obj_cache; + const char *log_result = "failure"; + const char *log_detail = ""; + gs_free char *log_detail_free = NULL; + const NMPObject *obj_cache; if (!nm_platform_netns_push(platform, &netns)) { log_level = LOGL_ERR; @@ -7367,11 +7367,11 @@ out: } static int -link_add(NMPlatform * platform, +link_add(NMPlatform *platform, NMLinkType type, - const char * name, + const char *name, int parent, - const void * address, + const void *address, size_t address_len, guint32 mtu, gconstpointer extra_data, @@ -7417,7 +7417,7 @@ link_delete(NMPlatform *platform, int ifindex) { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; NMPObject obj_id; - const NMPObject * obj; + const NMPObject *obj; obj = nmp_cache_lookup_link(nm_platform_get_cache(platform), ifindex); if (!obj || !obj->_link.netlink.is_in_netlink) @@ -7526,7 +7526,7 @@ static gboolean link_supports_vlans(NMPlatform *platform, int ifindex) { nm_auto_pop_netns NMPNetns *netns = NULL; - const NMPObject * obj; + const NMPObject *obj; obj = nm_platform_link_get_obj(platform, ifindex, TRUE); @@ -7568,10 +7568,10 @@ link_set_address(NMPlatform *platform, int ifindex, gconstpointer address, size_ { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; const ChangeLinkData d = { - .set_address = + .set_address = { - .address = address, - .length = length, + .address = address, + .length = length, }, }; @@ -7642,11 +7642,11 @@ nla_put_failure: static void sriov_idle_cb(gpointer user_data, GCancellable *cancellable) { - gs_unref_object NMPlatform *platform = NULL; - gs_free_error GError *cancelled_error = NULL; - gs_free_error GError * error = NULL; - NMPlatformAsyncCallback callback; - gpointer callback_data; + gs_unref_object NMPlatform *platform = NULL; + gs_free_error GError *cancelled_error = NULL; + gs_free_error GError *error = NULL; + NMPlatformAsyncCallback callback; + gpointer callback_data; g_cancellable_set_error_if_cancelled(cancellable, &cancelled_error); nm_utils_user_data_unpack(user_data, &platform, &error, &callback, &callback_data); @@ -7654,24 +7654,24 @@ sriov_idle_cb(gpointer user_data, GCancellable *cancellable) } static void -link_set_sriov_params_async(NMPlatform * platform, +link_set_sriov_params_async(NMPlatform *platform, int ifindex, guint num_vfs, NMOptionBool autoprobe, NMPlatformAsyncCallback callback, gpointer data, - GCancellable * cancellable) + GCancellable *cancellable) { nm_auto_pop_netns NMPNetns *netns = NULL; - gs_free_error GError *error = NULL; - nm_auto_close int dirfd = -1; - int current_autoprobe; - guint i, total; - gint64 current_num; - char ifname[IFNAMSIZ]; - gpointer packed; - const char * values[3]; - char buf[64]; + gs_free_error GError *error = NULL; + nm_auto_close int dirfd = -1; + int current_autoprobe; + guint i, total; + gint64 current_num; + char ifname[IFNAMSIZ]; + gpointer packed; + const char *values[3]; + char buf[64]; g_return_if_fail(callback || !data); g_return_if_fail(cancellable); @@ -7780,7 +7780,7 @@ static gboolean link_set_sriov_vfs(NMPlatform *platform, int ifindex, const NMPlatformVF *const *vfs) { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - struct nlattr * list, *info, *vlan_list; + struct nlattr *list, *info, *vlan_list; guint i; nlmsg = _nl_msg_new_link(RTM_NEWLINK, 0, ifindex, NULL); @@ -7867,13 +7867,13 @@ nla_put_failure: } static gboolean -link_set_bridge_vlans(NMPlatform * platform, +link_set_bridge_vlans(NMPlatform *platform, int ifindex, gboolean on_master, const NMPlatformBridgeVlan *const *vlans) { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - struct nlattr * list; + struct nlattr *list; struct bridge_vlan_info vinfo = {}; guint i; @@ -7958,13 +7958,13 @@ link_get_dev_id(NMPlatform *platform, int ifindex) } static gboolean -link_tun_add(NMPlatform * platform, - const char * name, +link_tun_add(NMPlatform *platform, + const char *name, const NMPlatformLnkTun *props, - const NMPlatformLink ** out_link, - int * out_fd) + const NMPlatformLink **out_link, + int *out_fd) { - const NMPObject * obj; + const NMPObject *obj; struct ifreq ifr = {}; nm_auto_close int fd = -1; @@ -8022,8 +8022,8 @@ _vlan_change_vlan_qos_mapping_create(gboolean is_ingress_map, guint current_n_map, const NMVlanQosMapping *set_map, guint set_n_map, - NMVlanQosMapping ** out_map, - guint * out_n_map) + NMVlanQosMapping **out_map, + guint *out_n_map) { NMVlanQosMapping *map; guint i, j, len; @@ -8086,7 +8086,7 @@ _vlan_change_vlan_qos_mapping_create(gboolean is_ingress_map, } static gboolean -link_vlan_change(NMPlatform * platform, +link_vlan_change(NMPlatform *platform, int ifindex, _NMVlanFlags flags_mask, _NMVlanFlags flags_set, @@ -8097,13 +8097,13 @@ link_vlan_change(NMPlatform * platform, const NMVlanQosMapping *egress_map, gsize n_egress_map) { - const NMPObject * obj_cache; + const NMPObject *obj_cache; nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - const NMPObjectLnkVlan * lnk; + const NMPObjectLnkVlan *lnk; guint new_n_ingress_map = 0; guint new_n_egress_map = 0; - gs_free NMVlanQosMapping *new_ingress_map = NULL; - gs_free NMVlanQosMapping *new_egress_map = NULL; + gs_free NMVlanQosMapping *new_ingress_map = NULL; + gs_free NMVlanQosMapping *new_egress_map = NULL; obj_cache = nmp_cache_lookup_link(nm_platform_get_cache(platform), ifindex); if (!obj_cache || !obj_cache->_link.netlink.is_in_netlink) { @@ -8174,7 +8174,7 @@ link_release(NMPlatform *platform, int master, int slave) /*****************************************************************************/ static gboolean -_infiniband_partition_action(NMPlatform * platform, +_infiniband_partition_action(NMPlatform *platform, InfinibandAction action, int parent, int p_key, @@ -8182,7 +8182,7 @@ _infiniband_partition_action(NMPlatform * platform, { nm_auto_close int dirfd = -1; char ifname_parent[IFNAMSIZ]; - const NMPObject * obj; + const NMPObject *obj; char id[20]; char name[IFNAMSIZ]; gboolean success; @@ -8233,7 +8233,7 @@ _infiniband_partition_action(NMPlatform * platform, } static gboolean -infiniband_partition_add(NMPlatform * platform, +infiniband_partition_add(NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link) @@ -8273,7 +8273,7 @@ get_ext_data(NMPlatform *platform, int ifindex) #define WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, retval) \ nm_auto_pop_netns NMPNetns *netns = NULL; \ - NMWifiUtils * wifi_data; \ + NMWifiUtils *wifi_data; \ if (!nm_platform_netns_push(platform, &netns)) \ return retval; \ wifi_data = NM_WIFI_UTILS(get_ext_data(platform, ifindex)); \ @@ -8297,11 +8297,11 @@ wifi_get_frequency(NMPlatform *platform, int ifindex) } static gboolean -wifi_get_station(NMPlatform * platform, +wifi_get_station(NMPlatform *platform, int ifindex, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate) + int *out_quality, + 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); @@ -8364,7 +8364,7 @@ link_can_assume(NMPlatform *platform, int ifindex) NMPLookup lookup; const NMPObject *link, *o; NMDedupMultiIter iter; - NMPCache * cache = nm_platform_get_cache(platform); + NMPCache *cache = nm_platform_get_cache(platform); if (ifindex <= 0) return FALSE; @@ -8487,9 +8487,9 @@ link_get_wake_on_lan(NMPlatform *platform, int ifindex) static gboolean link_get_driver_info(NMPlatform *platform, int ifindex, - char ** out_driver_name, - char ** out_driver_version, - char ** out_fw_version) + char **out_driver_name, + char **out_driver_version, + char **out_fw_version) { nm_auto_pop_netns NMPNetns *netns = NULL; NMPUtilsEthtoolDriverInfo driver_info; @@ -8542,7 +8542,7 @@ ip4_address_add(NMPlatform *platform, } static gboolean -ip6_address_add(NMPlatform * platform, +ip6_address_add(NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen, @@ -8631,7 +8631,7 @@ ip6_address_delete(NMPlatform *platform, int ifindex, struct in6_addr addr, guin /*****************************************************************************/ static int -ip_route_add(NMPlatform * platform, +ip_route_add(NMPlatform *platform, NMPNlmFlags flags, int addr_family, const NMPlatformIPRoute *route) @@ -8658,7 +8658,7 @@ static gboolean object_delete(NMPlatform *platform, const NMPObject *obj) { nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL; - nm_auto_nlmsg struct nl_msg * nlmsg = NULL; + nm_auto_nlmsg struct nl_msg *nlmsg = NULL; if (!NMP_OBJECT_IS_STACKINIT(obj)) obj_keep_alive = nmp_object_ref(obj); @@ -8689,17 +8689,17 @@ object_delete(NMPlatform *platform, const NMPObject *obj) /*****************************************************************************/ static int -ip_route_get(NMPlatform * platform, +ip_route_get(NMPlatform *platform, int addr_family, gconstpointer address, int oif_ifindex, - NMPObject ** out_route) + NMPObject **out_route) { - const gboolean is_v4 = (addr_family == AF_INET); - const int addr_len = is_v4 ? 4 : 16; - int try_count = 0; - WaitForNlResponseResult seq_result; - int nle; + const gboolean is_v4 = (addr_family == AF_INET); + const int addr_len = is_v4 ? 4 : 16; + int try_count = 0; + WaitForNlResponseResult seq_result; + int nle; nm_auto_nmpobj NMPObject *route = NULL; nm_assert(NM_IS_LINUX_PLATFORM(platform)); @@ -8777,7 +8777,7 @@ routing_rule_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformRoutin { WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; nm_auto_nlmsg struct nl_msg *msg = NULL; - gs_free char * errmsg = NULL; + gs_free char *errmsg = NULL; char s_buf[256]; int nle; @@ -8817,7 +8817,7 @@ static int qdisc_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformQdisc *qdisc) { WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; - gs_free char * errmsg = NULL; + gs_free char *errmsg = NULL; int nle; char s_buf[256]; nm_auto_nlmsg struct nl_msg *msg = NULL; @@ -8859,14 +8859,14 @@ static int tc_delete(NMPlatform *platform, int nlmsgtype, int ifindex, guint32 parent, gboolean log_error) { WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; - gs_free char * errmsg = NULL; + gs_free char *errmsg = NULL; int nle; char s_buf[256]; - const char * log_tag; + const char *log_tag; nm_auto_nlmsg struct nl_msg *msg = NULL; const struct tcmsg tcm = { - .tcm_ifindex = ifindex, - .tcm_parent = parent, + .tcm_ifindex = ifindex, + .tcm_parent = parent, }; switch (nlmsgtype) { @@ -8933,7 +8933,7 @@ static int tfilter_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformTfilter *tfilter) { WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; - gs_free char * errmsg = NULL; + gs_free char *errmsg = NULL; int nle; char s_buf[256]; nm_auto_nlmsg struct nl_msg *msg = NULL; @@ -8991,13 +8991,13 @@ event_handler(int fd, GIOCondition io_condition, gpointer user_data) static int event_handler_recvmsgs(NMPlatform *platform, gboolean handle_events) { - NMLinuxPlatformPrivate * priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); - struct nl_sock * sk = priv->nlh; + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); + struct nl_sock *sk = priv->nlh; int n; int err = 0; gboolean multipart = 0; gboolean interrupted = FALSE; - struct nlmsghdr * hdr; + struct nlmsghdr *hdr; WaitForNlResponseResult seq_result; struct sockaddr_nl nla = {0}; struct ucred creds; @@ -9036,7 +9036,7 @@ continue_reading: gboolean process_valid_msg = FALSE; guint32 seq_number; char buf_nlmsghdr[400]; - const char * extack_msg = NULL; + const char *extack_msg = NULL; msg = nlmsg_alloc_convert(hdr); @@ -9194,7 +9194,7 @@ static gboolean event_handler_read_netlink(NMPlatform *platform, gboolean wait_for_acks) { nm_auto_pop_netns NMPNetns *netns = NULL; - NMLinuxPlatformPrivate * priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); int r; struct pollfd pfd; gboolean any = FALSE; @@ -9411,11 +9411,11 @@ static void handle_udev_event(NMUdevClient *udev_client, struct udev_device *udevice, gpointer user_data) { nm_auto_pop_netns NMPNetns *netns = NULL; - NMPlatform * platform = NM_PLATFORM(user_data); - const char * subsys; - const char * ifindex; + NMPlatform *platform = NM_PLATFORM(user_data); + const char *subsys; + const char *ifindex; guint64 seqnum; - const char * action; + const char *action; action = udev_device_get_action(udevice); g_return_if_fail(action); @@ -9460,7 +9460,7 @@ nm_linux_platform_init(NMLinuxPlatform *self) static void constructed(GObject *_object) { - NMPlatform * platform = NM_PLATFORM(_object); + NMPlatform *platform = NM_PLATFORM(_object); NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); int nle; int fd; @@ -9570,7 +9570,7 @@ constructed(GObject *_object) /* Set up udev monitoring */ if (priv->udev_client) { - struct udev_enumerate * enumerator; + struct udev_enumerate *enumerator; struct udev_list_entry *devices, *l; /* And read initial device list */ @@ -9642,7 +9642,7 @@ nm_linux_platform_new(gboolean log_with_ptr, gboolean netns_support, gboolean ca static void dispose(GObject *object) { - NMPlatform * platform = NM_PLATFORM(object); + NMPlatform *platform = NM_PLATFORM(object); NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform); _LOGD("dispose"); @@ -9692,7 +9692,7 @@ finalize(GObject *object) static void nm_linux_platform_class_init(NMLinuxPlatformClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMPlatformClass *platform_class = NM_PLATFORM_CLASS(klass); object_class->constructed = constructed; diff --git a/src/libnm-platform/nm-netlink.c b/src/libnm-platform/nm-netlink.c index 56cde50ca7..949514536f 100644 --- a/src/libnm-platform/nm-netlink.c +++ b/src/libnm-platform/nm-netlink.c @@ -32,7 +32,7 @@ struct nl_msg { struct sockaddr_nl nm_src; struct sockaddr_nl nm_dst; struct ucred nm_creds; - struct nlmsghdr * nm_nlh; + struct nlmsghdr *nm_nlh; size_t nm_size; bool nm_creds_has : 1; }; @@ -245,7 +245,7 @@ nlmsg_hdr(struct nl_msg *n) void * nlmsg_reserve(struct nl_msg *n, size_t len, int pad) { - char * buf = (char *) n->nm_nlh; + char *buf = (char *) n->nm_nlh; size_t nlmsg_len = n->nm_nlh->nlmsg_len; size_t tlen; @@ -386,9 +386,9 @@ nlmsg_append(struct nl_msg *n, const void *data, size_t len, int pad) /*****************************************************************************/ int -nlmsg_parse(struct nlmsghdr * nlh, +nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, - struct nlattr * tb[], + struct nlattr *tb[], int maxtype, const struct nla_policy *policy) { @@ -639,9 +639,9 @@ validate_nla(const struct nlattr *nla, int maxtype, const struct nla_policy *pol } int -nla_parse(struct nlattr * tb[], +nla_parse(struct nlattr *tb[], int maxtype, - struct nlattr * head, + struct nlattr *head, int len, const struct nla_policy *policy) { @@ -718,7 +718,7 @@ genlmsg_put(struct nl_msg *msg, uint8_t cmd, uint8_t version) { - struct nlmsghdr * nlh; + struct nlmsghdr *nlh; struct genlmsghdr hdr = { .cmd = cmd, .version = version, @@ -794,9 +794,9 @@ genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen) } int -genlmsg_parse(struct nlmsghdr * nlh, +genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, - struct nlattr * tb[], + struct nlattr *tb[], int maxtype, const struct nla_policy *policy) { @@ -825,9 +825,9 @@ _genl_parse_getfamily(struct nl_msg *msg, void *arg) [CTRL_ATTR_OPS] = {.type = NLA_NESTED}, [CTRL_ATTR_MCAST_GROUPS] = {.type = NLA_NESTED}, }; - struct nlattr * tb[G_N_ELEMENTS(ctrl_policy)]; + struct nlattr *tb[G_N_ELEMENTS(ctrl_policy)]; struct nlmsghdr *nlh = nlmsg_hdr(msg); - gint32 * response_data = arg; + gint32 *response_data = arg; if (genlmsg_parse_arr(nlh, 0, tb, ctrl_policy) < 0) return NL_SKIP; @@ -845,8 +845,8 @@ genl_ctrl_resolve(struct nl_sock *sk, const char *name) int nmerr; gint32 response_data = -1; const struct nl_cb cb = { - .valid_cb = _genl_parse_getfamily, - .valid_arg = &response_data, + .valid_cb = _genl_parse_getfamily, + .valid_arg = &response_data, }; msg = nlmsg_alloc(); @@ -1170,7 +1170,7 @@ nl_recvmsgs(struct nl_sock *sk, const struct nl_cb *cb) { int n, nmerr = 0, multipart = 0, interrupted = 0, nrecv = 0; gs_free unsigned char *buf = NULL; - struct nlmsghdr * hdr; + struct nlmsghdr *hdr; struct sockaddr_nl nla = {0}; struct ucred creds; gboolean creds_has; @@ -1327,12 +1327,12 @@ int nl_send_iovec(struct nl_sock *sk, struct nl_msg *msg, struct iovec *iov, unsigned iovlen) { struct sockaddr_nl *dst; - struct ucred * creds; + struct ucred *creds; struct msghdr hdr = { - .msg_name = (void *) &sk->s_peer, - .msg_namelen = sizeof(struct sockaddr_nl), - .msg_iov = iov, - .msg_iovlen = iovlen, + .msg_name = (void *) &sk->s_peer, + .msg_namelen = sizeof(struct sockaddr_nl), + .msg_iov = iov, + .msg_iovlen = iovlen, }; char buf[CMSG_SPACE(sizeof(struct ucred))]; @@ -1402,11 +1402,11 @@ nl_send_auto(struct nl_sock *sk, struct nl_msg *msg) } int -nl_recv(struct nl_sock * sk, +nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla, - unsigned char ** buf, - struct ucred * out_creds, - gboolean * out_creds_has) + unsigned char **buf, + struct ucred *out_creds, + gboolean *out_creds_has) { /* We really expect msg_contol_buf to be large enough and MSG_CTRUNC not * happening. We nm_assert() against that. However, in release builds diff --git a/src/libnm-platform/nm-netlink.h b/src/libnm-platform/nm-netlink.h index 00d817cdbb..ac3159bf5f 100644 --- a/src/libnm-platform/nm-netlink.h +++ b/src/libnm-platform/nm-netlink.h @@ -328,9 +328,9 @@ void nla_nest_cancel(struct nl_msg *msg, const struct nlattr *attr); struct nlattr *nla_nest_start(struct nl_msg *msg, int attrtype); int nla_nest_end(struct nl_msg *msg, struct nlattr *start); -int nla_parse(struct nlattr * tb[], +int nla_parse(struct nlattr *tb[], int maxtype, - struct nlattr * head, + struct nlattr *head, int len, const struct nla_policy *policy); @@ -342,9 +342,9 @@ int nla_parse(struct nlattr * tb[], }) static inline int -nla_parse_nested(struct nlattr * tb[], +nla_parse_nested(struct nlattr *tb[], int maxtype, - struct nlattr * nla, + struct nlattr *nla, const struct nla_policy *policy) { return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy); @@ -468,9 +468,9 @@ nlmsg_find_attr(struct nlmsghdr *nlh, int hdrlen, int attrtype) return nla_find(nlmsg_attrdata(nlh, hdrlen), nlmsg_attrlen(nlh, hdrlen), attrtype); } -int nlmsg_parse(struct nlmsghdr * nlh, +int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, - struct nlattr * tb[], + struct nlattr *tb[], int maxtype, const struct nla_policy *policy); @@ -517,11 +517,11 @@ int nl_socket_add_memberships(struct nl_sock *sk, int group, ...); int nl_connect(struct nl_sock *sk, int protocol); -int nl_recv(struct nl_sock * sk, +int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla, - unsigned char ** buf, - struct ucred * out_creds, - gboolean * out_creds_has); + unsigned char **buf, + struct ucred *out_creds, + gboolean *out_creds_has); int nl_send(struct nl_sock *sk, struct nl_msg *msg); @@ -544,16 +544,16 @@ typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla, struct nlmsgerr *nle struct nl_cb { nl_recvmsg_msg_cb_t valid_cb; - void * valid_arg; + void *valid_arg; nl_recvmsg_msg_cb_t finish_cb; - void * finish_arg; + void *finish_arg; nl_recvmsg_msg_cb_t ack_cb; - void * ack_arg; + void *ack_arg; nl_recvmsg_err_cb_t err_cb; - void * err_arg; + void *err_arg; }; int nl_sendmsg(struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr); @@ -570,7 +570,7 @@ int nl_socket_set_ext_ack(struct nl_sock *sk, gboolean enable); /*****************************************************************************/ -void * genlmsg_put(struct nl_msg *msg, +void *genlmsg_put(struct nl_msg *msg, uint32_t port, uint32_t seq, int family, @@ -578,18 +578,18 @@ void * genlmsg_put(struct nl_msg *msg, int flags, uint8_t cmd, uint8_t version); -void * genlmsg_data(const struct genlmsghdr *gnlh); -void * genlmsg_user_hdr(const struct genlmsghdr *gnlh); +void *genlmsg_data(const struct genlmsghdr *gnlh); +void *genlmsg_user_hdr(const struct genlmsghdr *gnlh); struct genlmsghdr *genlmsg_hdr(struct nlmsghdr *nlh); -void * genlmsg_user_data(const struct genlmsghdr *gnlh, const int hdrlen); -struct nlattr * genlmsg_attrdata(const struct genlmsghdr *gnlh, int hdrlen); +void *genlmsg_user_data(const struct genlmsghdr *gnlh, const int hdrlen); +struct nlattr *genlmsg_attrdata(const struct genlmsghdr *gnlh, int hdrlen); int genlmsg_len(const struct genlmsghdr *gnlh); int genlmsg_attrlen(const struct genlmsghdr *gnlh, int hdrlen); int genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen); -int genlmsg_parse(struct nlmsghdr * nlh, +int genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, - struct nlattr * tb[], + struct nlattr *tb[], int maxtype, const struct nla_policy *policy); diff --git a/src/libnm-platform/nm-platform-private.h b/src/libnm-platform/nm-platform-private.h index cf80568912..7537bb0b64 100644 --- a/src/libnm-platform/nm-platform-private.h +++ b/src/libnm-platform/nm-platform-private.h @@ -21,7 +21,7 @@ NMPCache *nm_platform_get_cache(NMPlatform *self); } \ G_STMT_END -void nm_platform_cache_update_emit_signal(NMPlatform * platform, +void nm_platform_cache_update_emit_signal(NMPlatform *platform, NMPCacheOpsType cache_op, const NMPObject *obj_old, const NMPObject *obj_new); diff --git a/src/libnm-platform/nm-platform-utils.c b/src/libnm-platform/nm-platform-utils.c index f052273635..9ad030df76 100644 --- a/src/libnm-platform/nm-platform-utils.c +++ b/src/libnm-platform/nm-platform-utils.c @@ -91,16 +91,16 @@ typedef enum { } IoctlCallDataType; static int -_ioctl_call(const char * log_ioctl_type, - const char * log_subtype, +_ioctl_call(const char *log_ioctl_type, + const char *log_subtype, unsigned long int ioctl_request, int ifindex, - int * inout_fd, - char * inout_ifname, + int *inout_fd, + char *inout_ifname, IoctlCallDataType edata_type, gpointer edata, gsize edata_size, - struct ifreq * out_ifreq) + struct ifreq *out_ifreq) { nm_auto_close int fd_close = -1; int fd; @@ -109,7 +109,7 @@ _ioctl_call(const char * log_ioctl_type, gs_free gpointer edata_backup_free = NULL; guint try_count; char known_ifnames[2][IFNAMSIZ]; - const char * failure_reason = NULL; + const char *failure_reason = NULL; struct ifreq ifr; nm_assert(ifindex > 0); @@ -365,7 +365,7 @@ ethtool_get_stringset(SocketHandle *shandle, int stringset_id) .info.reserved = 0, .info.sset_mask = (1ULL << stringset_id), }; - const guint32 * pdata; + const guint32 *pdata; gs_free struct ethtool_gstrings *gstrings = NULL; gsize gstrings_len; guint32 i, len; @@ -574,7 +574,7 @@ _ASSERT_ethtool_feature_infos(void) static NMEthtoolFeatureStates * ethtool_get_features(SocketHandle *shandle) { - gs_free NMEthtoolFeatureStates * states = NULL; + gs_free NMEthtoolFeatureStates *states = NULL; gs_free struct ethtool_gstrings *ss_features = NULL; _ASSERT_ethtool_feature_infos(); @@ -584,11 +584,11 @@ ethtool_get_features(SocketHandle *shandle) return NULL; if (ss_features->len > 0) { - gs_free struct ethtool_gfeatures * gfeatures_free = NULL; - struct ethtool_gfeatures * gfeatures; + gs_free struct ethtool_gfeatures *gfeatures_free = NULL; + struct ethtool_gfeatures *gfeatures; gsize gfeatures_len; guint idx; - const NMEthtoolFeatureState * states_list0 = NULL; + const NMEthtoolFeatureState *states_list0 = NULL; const NMEthtoolFeatureState *const *states_plist0 = NULL; guint states_plist_n = 0; @@ -606,7 +606,7 @@ ethtool_get_features(SocketHandle *shandle) for (idx_kernel_name = 0; idx_kernel_name < info->n_kernel_names; idx_kernel_name++) { NMEthtoolFeatureState *kstate; - const char * kernel_name = info->kernel_names[idx_kernel_name]; + const char *kernel_name = info->kernel_names[idx_kernel_name]; int i_feature; guint i_block; guint32 i_flag; @@ -667,7 +667,7 @@ NMEthtoolFeatureStates * nmp_utils_ethtool_get_features(int ifindex) { nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex); - NMEthtoolFeatureStates * features; + NMEthtoolFeatureStates *features; g_return_val_if_fail(ifindex > 0, 0); @@ -689,10 +689,10 @@ nmp_utils_ethtool_get_features(int ifindex) } static const char * -_ethtool_feature_state_to_string(char * buf, +_ethtool_feature_state_to_string(char *buf, gsize buf_size, const NMEthtoolFeatureState *s, - const char * prefix) + const char *prefix) { int l; @@ -718,8 +718,8 @@ nmp_utils_ethtool_set_features( gboolean do_set /* or reset */) { nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex); - gs_free struct ethtool_sfeatures * sfeatures_free = NULL; - struct ethtool_sfeatures * sfeatures; + gs_free struct ethtool_sfeatures *sfeatures_free = NULL; + struct ethtool_sfeatures *sfeatures; gsize sfeatures_len; int r; guint i, j; @@ -1215,8 +1215,8 @@ gboolean nmp_utils_ethtool_supports_vlans(int ifindex) { nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex); - gs_free struct ethtool_gfeatures * features_free = NULL; - struct ethtool_gfeatures * features; + gs_free struct ethtool_gfeatures *features_free = NULL; + struct ethtool_gfeatures *features; gsize features_len; int idx, block, bit, size; @@ -1250,8 +1250,8 @@ nmp_utils_ethtool_get_peer_ifindex(int ifindex) { nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex); gsize stats_len; - gs_free struct ethtool_stats * stats_free = NULL; - struct ethtool_stats * stats; + gs_free struct ethtool_stats *stats_free = NULL; + struct ethtool_stats *stats; int peer_ifindex_stat; g_return_val_if_fail(ifindex > 0, 0); @@ -1289,8 +1289,8 @@ nmp_utils_ethtool_get_wake_on_lan(int ifindex) gboolean nmp_utils_ethtool_get_link_settings(int ifindex, - gboolean * out_autoneg, - guint32 * out_speed, + gboolean *out_autoneg, + guint32 *out_speed, NMPlatformLinkDuplexType *out_duplex) { struct ethtool_cmd edata = { @@ -1474,7 +1474,7 @@ const guint32 _nmp_link_mode_all_advertised_modes[] = { }; static NMOptionBool -set_link_settings_new(SocketHandle * shandle, +set_link_settings_new(SocketHandle *shandle, gboolean autoneg, guint32 speed, NMPlatformLinkDuplexType duplex) @@ -1512,8 +1512,8 @@ set_link_settings_new(SocketHandle * shandle, { const guint32 *v_map_supported = &edata->link_mode_masks[0]; - guint32 * v_map_advertising = &edata->link_mode_masks[nwords]; - guint32 * v_map_lp_advertising = &edata->link_mode_masks[2 * nwords]; + guint32 *v_map_advertising = &edata->link_mode_masks[nwords]; + guint32 *v_map_lp_advertising = &edata->link_mode_masks[2 * nwords]; memcpy(v_map_advertising, v_map_supported, sizeof(guint32) * nwords); (void) v_map_lp_advertising; @@ -1574,7 +1574,7 @@ nmp_utils_ethtool_set_link_settings(int ifindex, { nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex); struct ethtool_cmd edata = { - .cmd = ETHTOOL_GSET, + .cmd = ETHTOOL_GSET, }; NMOptionBool ret; @@ -1651,7 +1651,7 @@ set_autoneg: gboolean nmp_utils_ethtool_set_wake_on_lan(int ifindex, _NMSettingWiredWakeOnLan wol, - const char * wol_password) + const char *wol_password) { struct ethtool_wolinfo wol_info = { .cmd = ETHTOOL_SWOL, @@ -1706,7 +1706,7 @@ nmp_utils_mii_supports_carrier_detect(int ifindex) nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex); int r; struct ifreq ifr; - struct mii_ioctl_data * mii; + struct mii_ioctl_data *mii; g_return_val_if_fail(ifindex > 0, FALSE); @@ -1757,7 +1757,7 @@ const char * nmp_utils_udev_get_driver(struct udev_device *udevice) { struct udev_device *parent = NULL, *grandparent = NULL; - const char * driver, *subsys; + const char *driver, *subsys; driver = udev_device_get_driver(udevice); if (driver) @@ -2194,10 +2194,10 @@ nmp_utils_modprobe(GError **error, gboolean suppress_error_logging, const char * { gs_unref_ptrarray GPtrArray *argv = NULL; int exit_status; - gs_free char * _log_str = NULL; + gs_free char *_log_str = NULL; #define ARGV_TO_STR(argv) \ (_log_str ? _log_str : (_log_str = g_strjoinv(" ", (char **) argv->pdata))) - GError * local = NULL; + GError *local = NULL; va_list ap; NMLogLevel llevel = suppress_error_logging ? LOGL_DEBUG : LOGL_ERR; gs_free char *std_out = NULL, *std_err = NULL; diff --git a/src/libnm-platform/nm-platform-utils.h b/src/libnm-platform/nm-platform-utils.h index 5511e8af53..a9ccebb3e2 100644 --- a/src/libnm-platform/nm-platform-utils.h +++ b/src/libnm-platform/nm-platform-utils.h @@ -18,7 +18,7 @@ int nmp_utils_ethtool_get_peer_ifindex(int ifindex); gboolean nmp_utils_ethtool_get_wake_on_lan(int ifindex); gboolean nmp_utils_ethtool_set_wake_on_lan(int ifindex, _NMSettingWiredWakeOnLan wol, - const char * wol_password); + const char *wol_password); const char *nm_platform_link_duplex_type_to_string(NMPlatformLinkDuplexType duplex); @@ -26,8 +26,8 @@ extern const guint8 _nmp_link_mode_all_advertised_modes_bits[79]; extern const guint32 _nmp_link_mode_all_advertised_modes[3]; gboolean nmp_utils_ethtool_get_link_settings(int ifindex, - gboolean * out_autoneg, - guint32 * out_speed, + gboolean *out_autoneg, + guint32 *out_speed, NMPlatformLinkDuplexType *out_duplex); gboolean nmp_utils_ethtool_set_link_settings(int ifindex, gboolean autoneg, @@ -77,7 +77,7 @@ int nmp_utils_if_nametoindex(const char *ifname); int nmp_utils_sysctl_open_netdir(int ifindex, const char *ifname_guess, char *out_ifname); -char * nmp_utils_new_vlan_name(const char *parent_iface, guint32 vlan_id); +char *nmp_utils_new_vlan_name(const char *parent_iface, guint32 vlan_id); const char *nmp_utils_new_infiniband_name(char *name, const char *parent_name, int p_key); guint32 diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index e9403c6189..cfb05b68b8 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -115,9 +115,9 @@ nmp_link_address_get_as_bytes(const NMPLinkAddress *addr) #define NMLOG_COMMON(level, name, ...) \ char __prefix[32]; \ - const char * __p_prefix = _NMLOG_PREFIX_NAME; \ + const char *__p_prefix = _NMLOG_PREFIX_NAME; \ const NMPlatform *const __self = (self); \ - const char * __name = name; \ + const char *__name = name; \ \ if (__self && NM_PLATFORM_GET_PRIVATE(__self)->log_with_ptr) { \ g_snprintf(__prefix, sizeof(__prefix), "%s[%p]", _NMLOG_PREFIX_NAME, __self); \ @@ -187,9 +187,9 @@ typedef struct _NMPlatformPrivate { guint ip4_dev_route_blacklist_check_id; guint ip4_dev_route_blacklist_gc_timeout_id; - GHashTable * ip4_dev_route_blacklist_hash; + GHashTable *ip4_dev_route_blacklist_hash; NMDedupMultiIndex *multi_idx; - NMPCache * cache; + NMPCache *cache; } NMPlatformPrivate; G_DEFINE_TYPE(NMPlatform, nm_platform, G_TYPE_OBJECT) @@ -255,7 +255,7 @@ _nm_platform_signal_id_get(NMPlatformSignalIdType signal_type) #define _CHECK_SELF_NETNS(self, klass, netns, err_val) \ nm_auto_pop_netns NMPNetns *netns = NULL; \ - NMPlatformClass * klass; \ + NMPlatformClass *klass; \ do { \ g_return_val_if_fail(NM_IS_PLATFORM(self), err_val); \ klass = NM_PLATFORM_GET_CLASS(self); \ @@ -531,14 +531,14 @@ nm_platform_sysctl_set(NMPlatform *self, * independently of how /proc/sys/kernel/sysctl_writes_strict is configured. */ void -nm_platform_sysctl_set_async(NMPlatform * self, - const char * pathid, +nm_platform_sysctl_set_async(NMPlatform *self, + const char *pathid, int dirfd, - const char * path, - const char *const * values, + const char *path, + const char *const *values, NMPlatformAsyncCallback callback, gpointer data, - GCancellable * cancellable) + GCancellable *cancellable) { _CHECK_SELF_VOID(self, klass); @@ -717,7 +717,7 @@ nm_platform_sysctl_get_int_checked(NMPlatform *self, gint64 max, gint64 fallback) { - char * value = NULL; + char *value = NULL; gint32 ret; int errsv; @@ -821,7 +821,7 @@ int nm_platform_sysctl_ip_conf_get_rp_filter_ipv4(NMPlatform *self, const char *ifname, gboolean consider_all, - gboolean * out_due_to_all) + gboolean *out_due_to_all) { int val, val_all; @@ -899,11 +899,11 @@ _link_get_all_presort(gconstpointer p_a, gconstpointer p_b, gpointer sort_by_nam GPtrArray * nm_platform_link_get_all(NMPlatform *self, gboolean sort_by_name) { - gs_unref_ptrarray GPtrArray *links = NULL; - GPtrArray * result; - guint i, nresult; + gs_unref_ptrarray GPtrArray *links = NULL; + GPtrArray *result; + guint i, nresult; gs_unref_hashtable GHashTable *unseen = NULL; - const NMPlatformLink * item; + const NMPlatformLink *item; NMPLookup lookup; _CHECK_SELF(self, klass, NULL); @@ -1077,7 +1077,7 @@ struct _nm_platform_link_get_by_address_data { }; static gboolean -_nm_platform_link_get_by_address_match_link(const NMPObject * obj, +_nm_platform_link_get_by_address_match_link(const NMPObject *obj, struct _nm_platform_link_get_by_address_data *d) { return obj->link.l_address.len == d->len && !memcmp(obj->link.l_address.data, d->data, d->len); @@ -1093,12 +1093,12 @@ _nm_platform_link_get_by_address_match_link(const NMPObject * * address. **/ const NMPlatformLink * -nm_platform_link_get_by_address(NMPlatform * self, +nm_platform_link_get_by_address(NMPlatform *self, NMLinkType link_type, gconstpointer address, size_t length) { - const NMPObject * obj; + const NMPObject *obj; struct _nm_platform_link_get_by_address_data d = { .data = address, .len = length, @@ -1125,8 +1125,8 @@ nm_platform_link_get_by_address(NMPlatform * self, } static int -_link_add_check_existing(NMPlatform * self, - const char * name, +_link_add_check_existing(NMPlatform *self, + const char *name, NMLinkType type, const NMPlatformLink **out_link) { @@ -1174,11 +1174,11 @@ _link_add_check_existing(NMPlatform * self, * Returns: the negative nm-error on failure. */ int -nm_platform_link_add(NMPlatform * self, +nm_platform_link_add(NMPlatform *self, NMLinkType type, - const char * name, + const char *name, int parent, - const void * address, + const void *address, size_t address_len, guint32 mtu, gconstpointer extra_data, @@ -1439,13 +1439,13 @@ nm_platform_link_get_type_name(NMPlatform *self, int ifindex) } gboolean -nm_platform_link_get_udev_property(NMPlatform * self, +nm_platform_link_get_udev_property(NMPlatform *self, int ifindex, - const char * name, + const char *name, const char **out_value) { struct udev_device *udevice = NULL; - const char * uproperty; + const char *uproperty; udevice = nm_platform_link_get_udev_device(self, ifindex); if (!udevice) @@ -1717,7 +1717,7 @@ nm_platform_link_get_address(NMPlatform *self, int ifindex, size_t *length) * address. */ gboolean -nm_platform_link_get_permanent_address_ethtool(NMPlatform * self, +nm_platform_link_get_permanent_address_ethtool(NMPlatform *self, int ifindex, NMPLinkAddress *out_address) { @@ -1735,9 +1735,9 @@ nm_platform_link_get_permanent_address_ethtool(NMPlatform * self, } gboolean -nm_platform_link_get_permanent_address(NMPlatform * self, +nm_platform_link_get_permanent_address(NMPlatform *self, const NMPlatformLink *plink, - NMPLinkAddress * out_address) + NMPLinkAddress *out_address) { _CHECK_SELF(self, klass, FALSE); nm_assert(out_address); @@ -1804,13 +1804,13 @@ nm_platform_link_supports_sriov(NMPlatform *self, int ifindex) * always invoked, and asynchronously. */ void -nm_platform_link_set_sriov_params_async(NMPlatform * self, +nm_platform_link_set_sriov_params_async(NMPlatform *self, int ifindex, guint num_vfs, NMOptionBool autoprobe, NMPlatformAsyncCallback callback, gpointer callback_data, - GCancellable * cancellable) + GCancellable *cancellable) { _CHECK_SELF_VOID(self, klass); @@ -1845,7 +1845,7 @@ nm_platform_link_set_sriov_vfs(NMPlatform *self, int ifindex, const NMPlatformVF } gboolean -nm_platform_link_set_bridge_vlans(NMPlatform * self, +nm_platform_link_set_bridge_vlans(NMPlatform *self, int ifindex, gboolean on_master, const NMPlatformBridgeVlan *const *vlans) @@ -2038,9 +2038,9 @@ nm_platform_link_get_wake_on_lan(NMPlatform *self, int ifindex) gboolean nm_platform_link_get_driver_info(NMPlatform *self, int ifindex, - char ** out_driver_name, - char ** out_driver_version, - char ** out_fw_version) + char **out_driver_name, + char **out_driver_version, + char **out_fw_version) { _CHECK_SELF(self, klass, FALSE); @@ -2149,7 +2149,7 @@ nm_platform_link_can_assume(NMPlatform *self, int ifindex) * (but don't modify it). */ const NMPObject * -nm_platform_link_get_lnk(NMPlatform * self, +nm_platform_link_get_lnk(NMPlatform *self, int ifindex, NMLinkType link_type, const NMPlatformLink **out_link) @@ -2308,10 +2308,10 @@ static NM_UTILS_FLAGS2STR_DEFINE( NM_UTILS_FLAGS2STR(NM_PLATFORM_WIREGUARD_CHANGE_PEER_FLAG_REPLACE_ALLOWEDIPS, "remove-aips"), ); int -nm_platform_link_wireguard_change(NMPlatform * self, +nm_platform_link_wireguard_change(NMPlatform *self, int ifindex, - const NMPlatformLnkWireGuard * lnk_wireguard, - const NMPWireGuardPeer * peers, + const NMPlatformLnkWireGuard *lnk_wireguard, + const NMPWireGuardPeer *peers, const NMPlatformWireGuardChangePeerFlags *peer_flags, guint peers_len, NMPlatformWireGuardChangeFlags change_flags) @@ -2391,11 +2391,11 @@ nm_platform_link_wireguard_change(NMPlatform * self * Create a TUN or TAP interface. */ int -nm_platform_link_tun_add(NMPlatform * self, - const char * name, +nm_platform_link_tun_add(NMPlatform *self, + const char *name, const NMPlatformLnkTun *props, - const NMPlatformLink ** out_link, - int * out_fd) + const NMPlatformLink **out_link, + int *out_fd) { char b[255]; int r; @@ -2466,7 +2466,7 @@ link_set_option(NMPlatform *self, { nm_auto_close int dirfd = -1; char ifname_verified[IFNAMSIZ]; - const char * path; + const char *path; if (!category || !option) return FALSE; @@ -2487,7 +2487,7 @@ link_get_option(NMPlatform *self, int ifindex, const char *category, const char { nm_auto_close int dirfd = -1; char ifname_verified[IFNAMSIZ]; - const char * path; + const char *path; if (!category || !option) return NULL; @@ -2588,7 +2588,7 @@ nm_platform_sysctl_slave_get_option(NMPlatform *self, int ifindex, const char *o /*****************************************************************************/ gboolean -nm_platform_link_vlan_change(NMPlatform * self, +nm_platform_link_vlan_change(NMPlatform *self, int ifindex, _NMVlanFlags flags_mask, _NMVlanFlags flags_set, @@ -2680,7 +2680,7 @@ nm_platform_link_vlan_set_egress_map(NMPlatform *self, int ifindex, int from, in } static int -_infiniband_add_add_or_delete(NMPlatform * self, +_infiniband_add_add_or_delete(NMPlatform *self, int ifindex, int p_key, gboolean add, @@ -2727,7 +2727,7 @@ _infiniband_add_add_or_delete(NMPlatform * self, } int -nm_platform_link_infiniband_add(NMPlatform * self, +nm_platform_link_infiniband_add(NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link) @@ -2742,18 +2742,18 @@ nm_platform_link_infiniband_delete(NMPlatform *self, int parent, int p_key) } gboolean -nm_platform_link_infiniband_get_properties(NMPlatform * self, +nm_platform_link_infiniband_get_properties(NMPlatform *self, int ifindex, - int * out_parent, - int * out_p_key, + int *out_parent, + int *out_p_key, const char **out_mode) { nm_auto_close int dirfd = -1; char ifname_verified[IFNAMSIZ]; const NMPlatformLnkInfiniband *plnk; - const NMPlatformLink * plink; - char * contents; - const char * mode; + const NMPlatformLink *plink; + char *contents; + const char *mode; int p_key = 0; _CHECK_SELF(self, klass, FALSE); @@ -2968,11 +2968,11 @@ nm_platform_wifi_get_frequency(NMPlatform *self, int ifindex) } gboolean -nm_platform_wifi_get_station(NMPlatform * self, +nm_platform_wifi_get_station(NMPlatform *self, int ifindex, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate) + int *out_quality, + guint32 *out_rate) { _CHECK_SELF(self, klass, FALSE); @@ -3147,7 +3147,7 @@ _to_string_dev(NMPlatform *self, int ifindex, char *buf, size_t size) if (ifindex) { const char *name = ifindex > 0 && self ? nm_platform_link_get_name(self, ifindex) : NULL; - char * buf2; + char *buf2; strcpy(buf, " dev "); buf2 = buf + 5; @@ -3188,10 +3188,10 @@ _to_string_ifa_flags(guint32 ifa_flags, char *buf, gsize size) /*****************************************************************************/ gboolean -nm_platform_ethtool_set_wake_on_lan(NMPlatform * self, +nm_platform_ethtool_set_wake_on_lan(NMPlatform *self, int ifindex, _NMSettingWiredWakeOnLan wol, - const char * wol_password) + const char *wol_password) { _CHECK_SELF_NETNS(self, klass, netns, FALSE); @@ -3201,7 +3201,7 @@ nm_platform_ethtool_set_wake_on_lan(NMPlatform * self, } gboolean -nm_platform_ethtool_set_link_settings(NMPlatform * self, +nm_platform_ethtool_set_link_settings(NMPlatform *self, int ifindex, gboolean autoneg, guint32 speed, @@ -3215,10 +3215,10 @@ nm_platform_ethtool_set_link_settings(NMPlatform * self, } gboolean -nm_platform_ethtool_get_link_settings(NMPlatform * self, +nm_platform_ethtool_get_link_settings(NMPlatform *self, int ifindex, - gboolean * out_autoneg, - guint32 * out_speed, + gboolean *out_autoneg, + guint32 *out_speed, NMPlatformLinkDuplexType *out_duplex) { _CHECK_SELF_NETNS(self, klass, netns, FALSE); @@ -3242,7 +3242,7 @@ nm_platform_ethtool_get_link_features(NMPlatform *self, int ifindex) gboolean nm_platform_ethtool_set_features( - NMPlatform * self, + NMPlatform *self, int ifindex, const NMEthtoolFeatureStates *features, const NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */, @@ -3256,7 +3256,7 @@ nm_platform_ethtool_set_features( } gboolean -nm_platform_ethtool_get_link_coalesce(NMPlatform * self, +nm_platform_ethtool_get_link_coalesce(NMPlatform *self, int ifindex, NMEthtoolCoalesceState *coalesce) { @@ -3269,7 +3269,7 @@ nm_platform_ethtool_get_link_coalesce(NMPlatform * self, } gboolean -nm_platform_ethtool_set_coalesce(NMPlatform * self, +nm_platform_ethtool_set_coalesce(NMPlatform *self, int ifindex, const NMEthtoolCoalesceState *coalesce) { @@ -3380,8 +3380,8 @@ nm_platform_lookup_predicate_routes_main_skip_rtprot_kernel(const NMPObject *obj * Returns: the result of the lookup. */ GPtrArray * -nm_platform_lookup_clone(NMPlatform * self, - const NMPLookup * lookup, +nm_platform_lookup_clone(NMPlatform *self, + const NMPLookup *lookup, NMPObjectPredicateFunc predicate, gpointer user_data) { @@ -3511,7 +3511,7 @@ nm_platform_ip4_address_add(NMPlatform *self, } gboolean -nm_platform_ip6_address_add(NMPlatform * self, +nm_platform_ip6_address_add(NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen, @@ -3630,7 +3630,7 @@ nm_platform_ip6_address_get(NMPlatform *self, int ifindex, const struct in6_addr static gboolean _addr_array_clean_expired(int addr_family, int ifindex, - GPtrArray * array, + GPtrArray *array, guint32 now, GHashTable **idx) { @@ -3748,7 +3748,7 @@ ip4_addr_subnets_build_index(const GPtrArray *addresses, for (i = 0; i < addresses->len; i++) { const NMPlatformIP4Address *address; gpointer p_address; - GPtrArray * addr_list; + GPtrArray *addr_list; guint32 net; int position; gpointer p; @@ -3805,16 +3805,16 @@ ip4_addr_subnets_build_index(const GPtrArray *addresses, * Returns: %TRUE if the address is secondary, %FALSE otherwise */ static gboolean -ip4_addr_subnets_is_secondary(const NMPObject * address, - GHashTable * subnets, - const GPtrArray * addresses, +ip4_addr_subnets_is_secondary(const NMPObject *address, + GHashTable *subnets, + const GPtrArray *addresses, const GPtrArray **out_addr_list) { const NMPlatformIP4Address *a; - const GPtrArray * addr_list; + const GPtrArray *addr_list; gconstpointer p; guint32 net; - const NMPObject ** o; + const NMPObject **o; a = NMP_OBJECT_CAST_IP4_ADDRESS(address); @@ -3902,14 +3902,14 @@ gboolean nm_platform_ip_address_sync(NMPlatform *self, int addr_family, int ifindex, - GPtrArray * known_addresses, - GPtrArray * addresses_prune) + GPtrArray *known_addresses, + GPtrArray *addresses_prune) { - const gint32 now = nm_utils_get_monotonic_timestamp_sec(); - const int IS_IPv4 = NM_IS_IPv4(addr_family); + const gint32 now = nm_utils_get_monotonic_timestamp_sec(); + const int IS_IPv4 = NM_IS_IPv4(addr_family); gs_unref_hashtable GHashTable *known_addresses_idx = NULL; - GPtrArray * plat_addresses; - GHashTable * known_subnets = NULL; + GPtrArray *plat_addresses; + GHashTable *known_subnets = NULL; guint i_plat; guint i_know; guint i; @@ -3947,9 +3947,9 @@ nm_platform_ip_address_sync(NMPlatform *self, plat_subnets = ip4_addr_subnets_build_index(plat_addresses, TRUE, TRUE); for (i = 0; i < plat_addresses->len; i++) { - const NMPObject * plat_obj; + const NMPObject *plat_obj; const NMPlatformIP4Address *plat_address; - const GPtrArray * addr_list; + const GPtrArray *addr_list; plat_obj = plat_addresses->pdata[i]; if (!plat_obj) { @@ -4044,8 +4044,8 @@ nm_platform_ip_address_sync(NMPlatform *self, * * Note that we mark handled addresses by setting it to %NULL in @plat_addresses array. */ for (i_plat = 0; i_plat < plat_addresses->len; i_plat++) { - const NMPObject * plat_obj = plat_addresses->pdata[i_plat]; - const NMPObject * know_obj; + const NMPObject *plat_obj = plat_addresses->pdata[i_plat]; + const NMPObject *know_obj; const NMPlatformIP6Address *plat_addr = NMP_OBJECT_CAST_IP6_ADDRESS(plat_obj); if (known_addresses_idx) { @@ -4141,7 +4141,7 @@ next_plat:; */ for (i_know = 0; i_know < known_addresses->len; i_know++) { const NMPlatformIPXAddress *known_address; - const NMPObject * o; + const NMPObject *o; guint32 lifetime; guint32 preferred; @@ -4211,7 +4211,7 @@ nm_platform_ip_address_flush(NMPlatform *self, int addr_family, int ifindex) static gboolean _err_inval_due_to_ipv6_tentative_pref_src(NMPlatform *self, const NMPObject *obj) { - const NMPlatformIP6Route * r; + const NMPlatformIP6Route *r; const NMPlatformIP6Address *a; nm_assert(NM_IS_PLATFORM(self)); @@ -4253,8 +4253,8 @@ nm_platform_ip_address_get_prune_list(NMPlatform *self, const int IS_IPv4 = NM_IS_IPv4(addr_family); const NMDedupMultiHeadEntry *head_entry; NMPLookup lookup; - GPtrArray * result; - CList * iter; + GPtrArray *result; + CList *iter; nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(NM_IS_IPv4(addr_family)), ifindex); @@ -4285,20 +4285,20 @@ nm_platform_ip_address_get_prune_list(NMPlatform *self, } GPtrArray * -nm_platform_ip_route_get_prune_list(NMPlatform * self, +nm_platform_ip_route_get_prune_list(NMPlatform *self, int addr_family, int ifindex, NMIPRouteTableSyncMode route_table_sync) { NMPLookup lookup; - GPtrArray * routes_prune; + GPtrArray *routes_prune; const NMDedupMultiHeadEntry *head_entry; - CList * iter; + CList *iter; NMPlatformIP4Route rt_local4; NMPlatformIP6Route rt_local6; NMPlatformIP6Route rt_mcast6; - const NMPlatformLink * pllink; - const NMPlatformLnkVrf * lnk_vrf; + const NMPlatformLink *pllink; + const NMPlatformLnkVrf *lnk_vrf; guint32 local_table; nm_assert(NM_IS_PLATFORM(self)); @@ -4326,7 +4326,7 @@ nm_platform_ip_route_get_prune_list(NMPlatform * self, routes_prune = g_ptr_array_new_full(head_entry->len, (GDestroyNotify) nm_dedup_multi_obj_unref); c_list_for_each (iter, &head_entry->lst_entries_head) { - const NMPObject * obj = c_list_entry(iter, NMDedupMultiEntry, lst_entries)->obj; + const NMPObject *obj = c_list_entry(iter, NMDedupMultiEntry, lst_entries)->obj; const NMPlatformIPXRoute *rt = NMP_OBJECT_CAST_IPX_ROUTE(obj); switch (route_table_sync) { @@ -4493,15 +4493,15 @@ gboolean nm_platform_ip_route_sync(NMPlatform *self, int addr_family, int ifindex, - GPtrArray * routes, - GPtrArray * routes_prune, + GPtrArray *routes, + GPtrArray *routes_prune, GPtrArray **out_temporary_not_available) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - const NMPlatformVTableRoute *vt; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + const NMPlatformVTableRoute *vt; gs_unref_hashtable GHashTable *routes_idx = NULL; - const NMPObject * conf_o; - const NMDedupMultiEntry * plat_entry; + const NMPObject *conf_o; + const NMDedupMultiEntry *plat_entry; guint i; int i_type; gboolean success = TRUE; @@ -4934,11 +4934,11 @@ nm_platform_object_delete(NMPlatform *self, const NMPObject *obj) /*****************************************************************************/ int -nm_platform_ip_route_get(NMPlatform * self, +nm_platform_ip_route_get(NMPlatform *self, int addr_family, gconstpointer address /* in_addr_t or struct in6_addr */, int oif_ifindex, - NMPObject ** out_route) + NMPObject **out_route) { nm_auto_nmpobj NMPObject *route = NULL; int result; @@ -5003,11 +5003,11 @@ _ip4_dev_route_blacklist_timeout_ms_marked(gint64 timeout_msec) static gboolean _ip4_dev_route_blacklist_check_cb(gpointer user_data) { - NMPlatform * self = user_data; + NMPlatform *self = user_data; NMPlatformPrivate *priv = NM_PLATFORM_GET_PRIVATE(self); GHashTableIter iter; - const NMPObject * p_obj; - gint64 * p_timeout_ms; + const NMPObject *p_obj; + gint64 *p_timeout_ms; gint64 now_ms; priv->ip4_dev_route_blacklist_check_id = 0; @@ -5057,8 +5057,8 @@ static void _ip4_dev_route_blacklist_notify_route(NMPlatform *self, const NMPObject *obj) { NMPlatformPrivate *priv; - const NMPObject * p_obj; - gint64 * p_timeout_ms; + const NMPObject *p_obj; + gint64 *p_timeout_ms; gint64 now_ms; nm_assert(NM_IS_PLATFORM(self)); @@ -5096,11 +5096,11 @@ _ip4_dev_route_blacklist_notify_route(NMPlatform *self, const NMPObject *obj) static gboolean _ip4_dev_route_blacklist_gc_timeout_handle(gpointer user_data) { - NMPlatform * self = user_data; + NMPlatform *self = user_data; NMPlatformPrivate *priv = NM_PLATFORM_GET_PRIVATE(self); GHashTableIter iter; - const NMPObject * p_obj; - gint64 * p_timeout_ms; + const NMPObject *p_obj; + gint64 *p_timeout_ms; gint64 now_ms; nm_assert(priv->ip4_dev_route_blacklist_gc_timeout_id); @@ -5169,15 +5169,15 @@ _ip4_dev_route_blacklist_schedule(NMPlatform *self) void nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self, int ifindex, - GPtrArray * ip4_dev_route_blacklist) + GPtrArray *ip4_dev_route_blacklist) { NMPlatformPrivate *priv; GHashTableIter iter; - const NMPObject * p_obj; + const NMPObject *p_obj; guint i; gint64 timeout_msec; gint64 timeout_msec_val; - gint64 * p_timeout_ms; + gint64 *p_timeout_ms; gboolean needs_check = FALSE; nm_assert(NM_IS_PLATFORM(self)); @@ -5251,7 +5251,7 @@ nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self, /*****************************************************************************/ int -nm_platform_routing_rule_add(NMPlatform * self, +nm_platform_routing_rule_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformRoutingRule *routing_rule) { @@ -5331,8 +5331,8 @@ nm_platform_tfilter_delete(NMPlatform *self, int ifindex, guint32 parent, gboole gboolean nm_platform_tc_sync(NMPlatform *self, int ifindex, - GPtrArray * known_qdiscs, - GPtrArray * known_tfilters) + GPtrArray *known_qdiscs, + GPtrArray *known_tfilters) { guint i; gboolean success = TRUE; @@ -5373,10 +5373,10 @@ nm_platform_tc_sync(NMPlatform *self, /*****************************************************************************/ const char * -nm_platform_vlan_qos_mapping_to_string(const char * name, +nm_platform_vlan_qos_mapping_to_string(const char *name, const NMVlanQosMapping *map, gsize n_map, - char * buf, + char *buf, gsize len) { gsize i; @@ -5424,7 +5424,7 @@ _lifetime_summary_to_string(gint32 now, guint32 timestamp, guint32 preferred, guint32 lifetime, - char * buf, + char *buf, size_t buf_size) { g_snprintf(buf, @@ -5454,7 +5454,7 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) char parent[20]; char str_flags[1 + NM_PLATFORM_LINK_FLAGS2STR_MAX_LEN + 1]; char str_highlighted_flags[50]; - char * s; + char *s; gsize l; char str_addrmode[30]; char str_address[_NM_UTILS_HWADDR_LEN_MAX * 3]; @@ -6085,7 +6085,7 @@ nm_platform_lnk_vxlan_to_string(const NMPlatformLnkVxlan *lnk, char *buf, gsize const char * nm_platform_wireguard_peer_to_string(const NMPWireGuardPeer *peer, char *buf, gsize len) { - char * buf0 = buf; + char *buf0 = buf; gs_free char *public_key_b64 = NULL; char s_sockaddr[NM_UTILS_INET_ADDRSTRLEN + 100]; char s_endpoint[20 + sizeof(s_sockaddr)]; @@ -6190,7 +6190,7 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf char str_dev[TO_STRING_DEV_BUF_SIZE]; char str_label[32]; char str_lft[30], str_pref[30], str_time[50], s_source[50]; - char * str_peer = NULL; + char *str_peer = NULL; const char *str_lft_p, *str_pref_p, *str_time_p; gint32 now = nm_utils_get_monotonic_timestamp_sec(); in_addr_t broadcast_address; @@ -6350,7 +6350,7 @@ nm_platform_ip6_address_to_string(const NMPlatformIP6Address *address, char *buf char s_peer[INET6_ADDRSTRLEN]; char str_lft[30], str_pref[30], str_time[50], s_source[50]; char str_dev[TO_STRING_DEV_BUF_SIZE]; - char * str_peer = NULL; + char *str_peer = NULL; const char *str_lft_p, *str_pref_p, *str_time_p; gint32 now = nm_utils_get_monotonic_timestamp_sec(); @@ -6693,8 +6693,8 @@ nm_platform_ip6_route_to_string(const NMPlatformIP6Route *route, char *buf, gsiz } static void -_routing_rule_addr_to_string(char ** buf, - gsize * len, +_routing_rule_addr_to_string(char **buf, + gsize *len, int addr_family, const NMIPAddr *addr, guint8 plen, @@ -6728,10 +6728,10 @@ _routing_rule_addr_to_string(char ** buf, } static void -_routing_rule_port_range_to_string(char ** buf, - gsize * len, +_routing_rule_port_range_to_string(char **buf, + gsize *len, const NMFibRulePortRange *port_range, - const char * name) + const char *name) { if (port_range->start == 0 && port_range->end == 0) nm_strbuf_append_str(buf, len, ""); @@ -7155,11 +7155,11 @@ nm_platform_tfilter_cmp(const NMPlatformTfilter *a, const NMPlatformTfilter *b) const char * nm_platform_vf_to_string(const NMPlatformVF *vf, char *buf, gsize len) { - char str_mac[128], mac[128]; - char str_spoof_check[64]; - char str_trust[64]; - char str_min_tx_rate[64]; - char str_max_tx_rate[64]; + char str_mac[128], mac[128]; + char str_spoof_check[64]; + char str_trust[64]; + char str_min_tx_rate[64]; + char str_max_tx_rate[64]; nm_auto_free_gstring GString *gstr_vlans = NULL; guint i; @@ -7893,7 +7893,7 @@ nm_platform_ip6_address_cmp(const NMPlatformIP6Address *a, const NMPlatformIP6Ad void nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj, NMPlatformIPRouteCmpType cmp_type, - NMHashState * h) + NMHashState *h) { switch (cmp_type) { case NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID: @@ -8098,7 +8098,7 @@ nm_platform_ip4_route_cmp(const NMPlatformIP4Route *a, void nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj, NMPlatformIPRouteCmpType cmp_type, - NMHashState * h) + NMHashState *h) { struct in6_addr a1, a2; @@ -8285,7 +8285,7 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a, void nm_platform_routing_rule_hash_update(const NMPlatformRoutingRule *obj, NMPlatformRoutingRuleCmpType cmp_type, - NMHashState * h) + NMHashState *h) { gboolean cmp_full = TRUE; gsize addr_size; @@ -8528,9 +8528,9 @@ nm_platform_ip4_address_addr_to_hash(NMPlatform *self, int ifindex) { const NMDedupMultiHeadEntry *head_entry; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; NMPLookup lookup; - GHashTable * hash; + GHashTable *hash; g_return_val_if_fail(NM_IS_PLATFORM(self), NULL); g_return_val_if_fail(ifindex > 0, NULL); @@ -8560,7 +8560,7 @@ nm_platform_ip4_address_generate_device_route(const NMPlatformIP4Address *addr, int ifindex, guint32 route_table, guint32 route_metric, - NMPlatformIP4Route * dst) + NMPlatformIP4Route *dst) { in_addr_t network_4; @@ -8622,10 +8622,10 @@ nm_platform_signal_change_type_to_string(NMPlatformSignalChangeType change_type) } static void -log_link(NMPlatform * self, +log_link(NMPlatform *self, NMPObjectType obj_type, int ifindex, - NMPlatformLink * device, + NMPlatformLink *device, NMPlatformSignalChangeType change_type, gpointer user_data) { @@ -8635,10 +8635,10 @@ log_link(NMPlatform * self, } static void -log_ip4_address(NMPlatform * self, +log_ip4_address(NMPlatform *self, NMPObjectType obj_type, int ifindex, - NMPlatformIP4Address * address, + NMPlatformIP4Address *address, NMPlatformSignalChangeType change_type, gpointer user_data) { @@ -8648,10 +8648,10 @@ log_ip4_address(NMPlatform * self, } static void -log_ip6_address(NMPlatform * self, +log_ip6_address(NMPlatform *self, NMPObjectType obj_type, int ifindex, - NMPlatformIP6Address * address, + NMPlatformIP6Address *address, NMPlatformSignalChangeType change_type, gpointer user_data) { @@ -8661,10 +8661,10 @@ log_ip6_address(NMPlatform * self, } static void -log_ip4_route(NMPlatform * self, +log_ip4_route(NMPlatform *self, NMPObjectType obj_type, int ifindex, - NMPlatformIP4Route * route, + NMPlatformIP4Route *route, NMPlatformSignalChangeType change_type, gpointer user_data) { @@ -8674,10 +8674,10 @@ log_ip4_route(NMPlatform * self, } static void -log_ip6_route(NMPlatform * self, +log_ip6_route(NMPlatform *self, NMPObjectType obj_type, int ifindex, - NMPlatformIP6Route * route, + NMPlatformIP6Route *route, NMPlatformSignalChangeType change_type, gpointer user_data) { @@ -8687,10 +8687,10 @@ log_ip6_route(NMPlatform * self, } static void -log_routing_rule(NMPlatform * self, +log_routing_rule(NMPlatform *self, NMPObjectType obj_type, int ifindex, - NMPlatformRoutingRule * routing_rule, + NMPlatformRoutingRule *routing_rule, NMPlatformSignalChangeType change_type, gpointer user_data) { @@ -8701,10 +8701,10 @@ log_routing_rule(NMPlatform * self, } static void -log_qdisc(NMPlatform * self, +log_qdisc(NMPlatform *self, NMPObjectType obj_type, int ifindex, - NMPlatformQdisc * qdisc, + NMPlatformQdisc *qdisc, NMPlatformSignalChangeType change_type, gpointer user_data) { @@ -8714,10 +8714,10 @@ log_qdisc(NMPlatform * self, } static void -log_tfilter(NMPlatform * self, +log_tfilter(NMPlatform *self, NMPObjectType obj_type, int ifindex, - NMPlatformTfilter * tfilter, + NMPlatformTfilter *tfilter, NMPlatformSignalChangeType change_type, gpointer user_data) { @@ -8729,7 +8729,7 @@ log_tfilter(NMPlatform * self, /*****************************************************************************/ void -nm_platform_cache_update_emit_signal(NMPlatform * self, +nm_platform_cache_update_emit_signal(NMPlatform *self, NMPCacheOpsType cache_op, const NMPObject *obj_old, const NMPObject *obj_new) @@ -8737,7 +8737,7 @@ nm_platform_cache_update_emit_signal(NMPlatform * self, gboolean visible_new; gboolean visible_old; const NMPObject *o; - const NMPClass * klass; + const NMPClass *klass; int ifindex; nm_assert(NM_IN_SET((NMPlatformSignalChangeType) cache_op, @@ -8852,7 +8852,7 @@ const _NMPlatformVTableRouteUnion nm_platform_vtable_route = { const NMPlatformIPXRoute *b, NMPlatformIPRouteCmpType cmp_type)) nm_platform_ip4_route_cmp, .route_to_string = (const char *(*) (const NMPlatformIPXRoute *route, - char * buf, + char *buf, gsize len)) nm_platform_ip4_route_to_string, }, .v6 = @@ -8865,7 +8865,7 @@ const _NMPlatformVTableRouteUnion nm_platform_vtable_route = { const NMPlatformIPXRoute *b, NMPlatformIPRouteCmpType cmp_type)) nm_platform_ip6_route_cmp, .route_to_string = (const char *(*) (const NMPlatformIPXRoute *route, - char * buf, + char *buf, gsize len)) nm_platform_ip6_route_to_string, }, }; @@ -8875,7 +8875,7 @@ const _NMPlatformVTableRouteUnion nm_platform_vtable_route = { static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMPlatform * self = NM_PLATFORM(object); + NMPlatform *self = NM_PLATFORM(object); NMPlatformPrivate *priv = NM_PLATFORM_GET_PRIVATE(self); switch (prop_id) { @@ -8916,8 +8916,8 @@ nm_platform_init(NMPlatform *self) static GObject * constructor(GType type, guint n_construct_params, GObjectConstructParam *construct_params) { - GObject * object; - NMPlatform * self; + GObject *object; + NMPlatform *self; NMPlatformPrivate *priv; object = G_OBJECT_CLASS(nm_platform_parent_class) @@ -8935,7 +8935,7 @@ constructor(GType type, guint n_construct_params, GObjectConstructParam *constru static void finalize(GObject *object) { - NMPlatform * self = NM_PLATFORM(object); + NMPlatform *self = NM_PLATFORM(object); NMPlatformPrivate *priv = NM_PLATFORM_GET_PRIVATE(self); nm_clear_g_source(&priv->ip4_dev_route_blacklist_check_id); diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index f3a4534ce7..a3acc13cb8 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -155,7 +155,7 @@ G_STATIC_ASSERT(_nm_alignof(NMEtherAddr) == 1); G_STATIC_ASSERT(_nm_alignof(NMPLinkAddress) == 1); gconstpointer nmp_link_address_get(const NMPLinkAddress *addr, size_t *length); -GBytes * nmp_link_address_get_as_bytes(const NMPLinkAddress *addr); +GBytes *nmp_link_address_get_as_bytes(const NMPLinkAddress *addr); typedef enum { @@ -1071,7 +1071,7 @@ struct _NMPlatformPrivate; struct _NMPlatform { GObject parent; - NMPNetns * _netns; + NMPNetns *_netns; struct _NMPlatformPrivate *_priv; }; @@ -1083,24 +1083,24 @@ typedef struct { int dirfd, const char *path, const char *value); - void (*sysctl_set_async)(NMPlatform * self, - const char * pathid, + void (*sysctl_set_async)(NMPlatform *self, + const char *pathid, int dirfd, - const char * path, - const char *const * values, + const char *path, + const char *const *values, NMPlatformAsyncCallback callback, gpointer data, - GCancellable * cancellable); + GCancellable *cancellable); char *(*sysctl_get)(NMPlatform *self, const char *pathid, int dirfd, const char *path); void (*refresh_all)(NMPlatform *self, NMPObjectType obj_type); void (*process_events)(NMPlatform *self); - int (*link_add)(NMPlatform * self, + int (*link_add)(NMPlatform *self, NMLinkType type, - const char * name, + const char *name, int parent, - const void * address, + const void *address, size_t address_len, guint32 mtu, gconstpointer extra_data, @@ -1116,21 +1116,21 @@ typedef struct { int (*link_set_inet6_addr_gen_mode)(NMPlatform *self, int ifindex, guint8 enabled); gboolean (*link_set_token)(NMPlatform *self, int ifindex, const NMUtilsIPv6IfaceId *iid); - gboolean (*link_get_permanent_address_ethtool)(NMPlatform * self, + gboolean (*link_get_permanent_address_ethtool)(NMPlatform *self, int ifindex, NMPLinkAddress *out_address); int (*link_set_address)(NMPlatform *self, int ifindex, gconstpointer address, size_t length); int (*link_set_mtu)(NMPlatform *self, int ifindex, guint32 mtu); gboolean (*link_set_name)(NMPlatform *self, int ifindex, const char *name); - void (*link_set_sriov_params_async)(NMPlatform * self, + void (*link_set_sriov_params_async)(NMPlatform *self, int ifindex, guint num_vfs, NMOptionBool autoprobe, NMPlatformAsyncCallback callback, gpointer callback_data, - GCancellable * cancellable); + GCancellable *cancellable); gboolean (*link_set_sriov_vfs)(NMPlatform *self, int ifindex, const NMPlatformVF *const *vfs); - gboolean (*link_set_bridge_vlans)(NMPlatform * self, + gboolean (*link_set_bridge_vlans)(NMPlatform *self, int ifindex, gboolean on_master, const NMPlatformBridgeVlan *const *vlans); @@ -1140,9 +1140,9 @@ typedef struct { gboolean (*link_get_wake_on_lan)(NMPlatform *self, int ifindex); gboolean (*link_get_driver_info)(NMPlatform *self, int ifindex, - char ** out_driver_name, - char ** out_driver_version, - char ** out_fw_version); + char **out_driver_name, + char **out_driver_version, + char **out_fw_version); gboolean (*link_supports_carrier_detect)(NMPlatform *self, int ifindex); gboolean (*link_supports_vlans)(NMPlatform *self, int ifindex); @@ -1153,15 +1153,15 @@ typedef struct { gboolean (*link_can_assume)(NMPlatform *self, int ifindex); - int (*link_wireguard_change)(NMPlatform * self, + int (*link_wireguard_change)(NMPlatform *self, int ifindex, - const NMPlatformLnkWireGuard * lnk_wireguard, - const struct _NMPWireGuardPeer * peers, + const NMPlatformLnkWireGuard *lnk_wireguard, + const struct _NMPWireGuardPeer *peers, const NMPlatformWireGuardChangePeerFlags *peer_flags, guint peers_len, NMPlatformWireGuardChangeFlags change_flags); - gboolean (*link_vlan_change)(NMPlatform * self, + gboolean (*link_vlan_change)(NMPlatform *self, int ifindex, _NMVlanFlags flags_mask, _NMVlanFlags flags_set, @@ -1171,26 +1171,26 @@ typedef struct { gboolean egress_reset_all, const NMVlanQosMapping *egress_map, gsize n_egress_map); - gboolean (*link_tun_add)(NMPlatform * self, - const char * name, + gboolean (*link_tun_add)(NMPlatform *self, + const char *name, const NMPlatformLnkTun *props, - const NMPlatformLink ** out_link, - int * out_fd); + const NMPlatformLink **out_link, + int *out_fd); - gboolean (*infiniband_partition_add)(NMPlatform * self, + gboolean (*infiniband_partition_add)(NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link); gboolean (*infiniband_partition_delete)(NMPlatform *self, int parent, int p_key); - gboolean (*wifi_get_capabilities)(NMPlatform * self, + gboolean (*wifi_get_capabilities)(NMPlatform *self, int ifindex, _NMDeviceWifiCapabilities *caps); - gboolean (*wifi_get_station)(NMPlatform * self, + gboolean (*wifi_get_station)(NMPlatform *self, int ifindex, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate); + int *out_quality, + guint32 *out_rate); gboolean (*wifi_get_bssid)(NMPlatform *self, int ifindex, guint8 *bssid); guint32 (*wifi_get_frequency)(NMPlatform *self, int ifindex); int (*wifi_get_quality)(NMPlatform *self, int ifindex); @@ -1201,7 +1201,7 @@ typedef struct { guint32 (*wifi_find_frequency)(NMPlatform *self, int ifindex, const guint32 *freqs); void (*wifi_indicate_addressing_running)(NMPlatform *self, int ifindex, gboolean running); _NMSettingWirelessWakeOnWLan (*wifi_get_wake_on_wlan)(NMPlatform *self, int ifindex); - gboolean (*wifi_set_wake_on_wlan)(NMPlatform * self, + gboolean (*wifi_set_wake_on_wlan)(NMPlatform *self, int ifindex, _NMSettingWirelessWakeOnWLan wowl); @@ -1227,7 +1227,7 @@ typedef struct { guint32 preferred_lft, guint32 flags, const char *label); - gboolean (*ip6_address_add)(NMPlatform * self, + gboolean (*ip6_address_add)(NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen, @@ -1240,22 +1240,22 @@ typedef struct { in_addr_t address, guint8 plen, in_addr_t peer_address); - gboolean (*ip6_address_delete)(NMPlatform * self, + gboolean (*ip6_address_delete)(NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen); - int (*ip_route_add)(NMPlatform * self, + int (*ip_route_add)(NMPlatform *self, NMPNlmFlags flags, int addr_family, const NMPlatformIPRoute *route); - int (*ip_route_get)(NMPlatform * self, + int (*ip_route_get)(NMPlatform *self, int addr_family, gconstpointer address, int oif_ifindex, - NMPObject ** out_route); + NMPObject **out_route); - int (*routing_rule_add)(NMPlatform * self, + int (*routing_rule_add)(NMPlatform *self, NMPNlmFlags flags, const NMPlatformRoutingRule *routing_rule); @@ -1477,15 +1477,15 @@ gboolean nm_platform_sysctl_set(NMPlatform *self, int dirfd, const char *path, const char *value); -void nm_platform_sysctl_set_async(NMPlatform * self, - const char * pathid, +void nm_platform_sysctl_set_async(NMPlatform *self, + const char *pathid, int dirfd, - const char * path, - const char *const * values, + const char *path, + const char *const *values, NMPlatformAsyncCallback callback, gpointer data, - GCancellable * cancellable); -char * nm_platform_sysctl_get(NMPlatform *self, const char *pathid, int dirfd, const char *path); + GCancellable *cancellable); +char *nm_platform_sysctl_get(NMPlatform *self, const char *pathid, int dirfd, const char *path); gint32 nm_platform_sysctl_get_int32(NMPlatform *self, const char *pathid, int dirfd, @@ -1537,7 +1537,7 @@ gboolean nm_platform_sysctl_ip_neigh_set_ipv6_retrans_time(NMPlatform *self, int nm_platform_sysctl_ip_conf_get_rp_filter_ipv4(NMPlatform *platform, const char *iface, gboolean consider_all, - gboolean * out_due_to_all); + gboolean *out_due_to_all); const char *nm_platform_if_indextoname(NMPlatform *self, int ifindex, @@ -1547,27 +1547,27 @@ int nm_platform_if_nametoindex(NMPlatform *self, const char *ifname); const NMPObject *nm_platform_link_get_obj(NMPlatform *self, int ifindex, gboolean visible_only); const NMPlatformLink *nm_platform_link_get(NMPlatform *self, int ifindex); const NMPlatformLink *nm_platform_link_get_by_ifname(NMPlatform *self, const char *ifname); -const NMPlatformLink *nm_platform_link_get_by_address(NMPlatform * self, +const NMPlatformLink *nm_platform_link_get_by_address(NMPlatform *self, NMLinkType link_type, gconstpointer address, size_t length); GPtrArray *nm_platform_link_get_all(NMPlatform *self, gboolean sort_by_name); -int nm_platform_link_add(NMPlatform * self, +int nm_platform_link_add(NMPlatform *self, NMLinkType type, - const char * name, + const char *name, int parent, - const void * address, + const void *address, size_t address_len, guint32 mtu, gconstpointer extra_data, const NMPlatformLink **out_link); static inline int -nm_platform_link_veth_add(NMPlatform * self, - const char * name, - const char * peer, +nm_platform_link_veth_add(NMPlatform *self, + const char *name, + const char *peer, const NMPlatformLink **out_link) { return nm_platform_link_add(self, NM_LINK_TYPE_VETH, name, 0, NULL, 0, 0, peer, out_link); @@ -1580,13 +1580,13 @@ nm_platform_link_dummy_add(NMPlatform *self, const char *name, const NMPlatformL } static inline int -nm_platform_link_bridge_add(NMPlatform * self, - const char * name, - const void * address, +nm_platform_link_bridge_add(NMPlatform *self, + const char *name, + const void *address, size_t address_len, guint32 mtu, const NMPlatformLnkBridge *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { return nm_platform_link_add(self, NM_LINK_TYPE_BRIDGE, @@ -1618,12 +1618,12 @@ nm_platform_link_wireguard_add(NMPlatform *self, const char *name, const NMPlatf } static inline int -nm_platform_link_gre_add(NMPlatform * self, - const char * name, - const void * address, +nm_platform_link_gre_add(NMPlatform *self, + const char *name, + const void *address, size_t address_len, const NMPlatformLnkGre *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { g_return_val_if_fail(props, -NME_BUG); @@ -1639,17 +1639,17 @@ nm_platform_link_gre_add(NMPlatform * self, } static inline int -nm_platform_link_sit_add(NMPlatform * self, - const char * name, +nm_platform_link_sit_add(NMPlatform *self, + const char *name, const NMPlatformLnkSit *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { return nm_platform_link_add(self, NM_LINK_TYPE_SIT, name, 0, NULL, 0, 0, props, out_link); } static inline int -nm_platform_link_vlan_add(NMPlatform * self, - const char * name, +nm_platform_link_vlan_add(NMPlatform *self, + const char *name, int parent, int vlanid, guint32 vlanflags, @@ -1673,26 +1673,26 @@ nm_platform_link_vlan_add(NMPlatform * self, } static inline int -nm_platform_link_vrf_add(NMPlatform * self, - const char * name, +nm_platform_link_vrf_add(NMPlatform *self, + const char *name, const NMPlatformLnkVrf *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { return nm_platform_link_add(self, NM_LINK_TYPE_VRF, name, 0, NULL, 0, 0, props, out_link); } static inline int -nm_platform_link_vxlan_add(NMPlatform * self, - const char * name, +nm_platform_link_vxlan_add(NMPlatform *self, + const char *name, const NMPlatformLnkVxlan *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { return nm_platform_link_add(self, NM_LINK_TYPE_VXLAN, name, 0, NULL, 0, 0, props, out_link); } static inline int -nm_platform_link_6lowpan_add(NMPlatform * self, - const char * name, +nm_platform_link_6lowpan_add(NMPlatform *self, + const char *name, int parent, const NMPlatformLink **out_link) { @@ -1708,10 +1708,10 @@ nm_platform_link_6lowpan_add(NMPlatform * self, } static inline int -nm_platform_link_ip6tnl_add(NMPlatform * self, - const char * name, +nm_platform_link_ip6tnl_add(NMPlatform *self, + const char *name, const NMPlatformLnkIp6Tnl *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { g_return_val_if_fail(props, -NME_BUG); g_return_val_if_fail(!props->is_gre, -NME_BUG); @@ -1720,12 +1720,12 @@ nm_platform_link_ip6tnl_add(NMPlatform * self, } static inline int -nm_platform_link_ip6gre_add(NMPlatform * self, - const char * name, - const void * address, +nm_platform_link_ip6gre_add(NMPlatform *self, + const char *name, + const void *address, size_t address_len, const NMPlatformLnkIp6Tnl *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { g_return_val_if_fail(props, -NME_BUG); g_return_val_if_fail(props->is_gre, -NME_BUG); @@ -1742,10 +1742,10 @@ nm_platform_link_ip6gre_add(NMPlatform * self, } static inline int -nm_platform_link_ipip_add(NMPlatform * self, - const char * name, +nm_platform_link_ipip_add(NMPlatform *self, + const char *name, const NMPlatformLnkIpIp *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { g_return_val_if_fail(props, -NME_BUG); @@ -1753,11 +1753,11 @@ nm_platform_link_ipip_add(NMPlatform * self, } static inline int -nm_platform_link_macsec_add(NMPlatform * self, - const char * name, +nm_platform_link_macsec_add(NMPlatform *self, + const char *name, int parent, const NMPlatformLnkMacsec *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { g_return_val_if_fail(props, -NME_BUG); g_return_val_if_fail(parent > 0, -NME_BUG); @@ -1774,11 +1774,11 @@ nm_platform_link_macsec_add(NMPlatform * self, } static inline int -nm_platform_link_macvlan_add(NMPlatform * self, - const char * name, +nm_platform_link_macvlan_add(NMPlatform *self, + const char *name, int parent, const NMPlatformLnkMacvlan *props, - const NMPlatformLink ** out_link) + const NMPlatformLink **out_link) { g_return_val_if_fail(props, -NME_BUG); g_return_val_if_fail(parent > 0, -NME_BUG); @@ -1800,7 +1800,7 @@ gboolean nm_platform_link_set_netns(NMPlatform *self, int ifindex, int netns_fd) struct _NMDedupMultiHeadEntry; struct _NMPLookup; -const struct _NMDedupMultiHeadEntry *nm_platform_lookup(NMPlatform * self, +const struct _NMDedupMultiHeadEntry *nm_platform_lookup(NMPlatform *self, const struct _NMPLookup *lookup); #define nm_platform_iter_obj_for_each(iter, self, lookup, obj) \ @@ -1811,7 +1811,7 @@ gboolean nm_platform_lookup_predicate_routes_main(const NMPObject *obj, gpointer gboolean nm_platform_lookup_predicate_routes_main_skip_rtprot_kernel(const NMPObject *obj, gpointer user_data); -GPtrArray *nm_platform_lookup_clone(NMPlatform * self, +GPtrArray *nm_platform_lookup_clone(NMPlatform *self, const struct _NMPLookup *lookup, NMPObjectPredicateFunc predicate, gpointer user_data); @@ -1867,9 +1867,9 @@ nm_platform_link_change_flags(NMPlatform *self, int ifindex, unsigned value, gbo return nm_platform_link_change_flags_full(self, ifindex, value, set ? value : 0u); } -gboolean nm_platform_link_get_udev_property(NMPlatform * self, +gboolean nm_platform_link_get_udev_property(NMPlatform *self, int ifindex, - const char * name, + const char *name, const char **out_value); const char *nm_platform_link_get_udi(NMPlatform *self, int ifindex); const char *nm_platform_link_get_path(NMPlatform *self, int ifindex); @@ -1880,39 +1880,39 @@ int nm_platform_link_set_inet6_addr_gen_mode(NMPlatform *self, int ifindex, guin gboolean nm_platform_link_set_ipv6_token(NMPlatform *self, int ifindex, const NMUtilsIPv6IfaceId *iid); -gboolean nm_platform_link_get_permanent_address_ethtool(NMPlatform * self, +gboolean nm_platform_link_get_permanent_address_ethtool(NMPlatform *self, int ifindex, NMPLinkAddress *out_address); -gboolean nm_platform_link_get_permanent_address(NMPlatform * self, +gboolean nm_platform_link_get_permanent_address(NMPlatform *self, const NMPlatformLink *plink, - NMPLinkAddress * out_address); + NMPLinkAddress *out_address); int nm_platform_link_set_address(NMPlatform *self, int ifindex, const void *address, size_t length); int nm_platform_link_set_mtu(NMPlatform *self, int ifindex, guint32 mtu); gboolean nm_platform_link_set_name(NMPlatform *self, int ifindex, const char *name); -void nm_platform_link_set_sriov_params_async(NMPlatform * self, +void nm_platform_link_set_sriov_params_async(NMPlatform *self, int ifindex, guint num_vfs, NMOptionBool autoprobe, NMPlatformAsyncCallback callback, gpointer callback_data, - GCancellable * cancellable); + GCancellable *cancellable); gboolean nm_platform_link_set_sriov_vfs(NMPlatform *self, int ifindex, const NMPlatformVF *const *vfs); -gboolean nm_platform_link_set_bridge_vlans(NMPlatform * self, +gboolean nm_platform_link_set_bridge_vlans(NMPlatform *self, int ifindex, gboolean on_master, const NMPlatformBridgeVlan *const *vlans); -char * nm_platform_link_get_physical_port_id(NMPlatform *self, int ifindex); +char *nm_platform_link_get_physical_port_id(NMPlatform *self, int ifindex); guint nm_platform_link_get_dev_id(NMPlatform *self, int ifindex); gboolean nm_platform_link_get_wake_on_lan(NMPlatform *self, int ifindex); gboolean nm_platform_link_get_driver_info(NMPlatform *self, int ifindex, - char ** out_driver_name, - char ** out_driver_version, - char ** out_fw_version); + char **out_driver_name, + char **out_driver_version, + char **out_fw_version); gboolean nm_platform_link_supports_carrier_detect(NMPlatform *self, int ifindex); gboolean nm_platform_link_supports_vlans(NMPlatform *self, int ifindex); @@ -1925,14 +1925,14 @@ gboolean nm_platform_sysctl_master_set_option(NMPlatform *self, int ifindex, const char *option, const char *value); -char * nm_platform_sysctl_master_get_option(NMPlatform *self, int ifindex, const char *option); +char *nm_platform_sysctl_master_get_option(NMPlatform *self, int ifindex, const char *option); gboolean nm_platform_sysctl_slave_set_option(NMPlatform *self, int ifindex, const char *option, const char *value); -char * nm_platform_sysctl_slave_get_option(NMPlatform *self, int ifindex, const char *option); +char *nm_platform_sysctl_slave_get_option(NMPlatform *self, int ifindex, const char *option); -const NMPObject *nm_platform_link_get_lnk(NMPlatform * self, +const NMPObject *nm_platform_link_get_lnk(NMPlatform *self, int ifindex, NMLinkType link_type, const NMPlatformLink **out_link); @@ -1975,7 +1975,7 @@ nm_platform_link_get_lnk_wireguard(NMPlatform *self, int ifindex, const NMPlatfo gboolean nm_platform_link_vlan_set_ingress_map(NMPlatform *self, int ifindex, int from, int to); gboolean nm_platform_link_vlan_set_egress_map(NMPlatform *self, int ifindex, int from, int to); -gboolean nm_platform_link_vlan_change(NMPlatform * self, +gboolean nm_platform_link_vlan_change(NMPlatform *self, int ifindex, _NMVlanFlags flags_mask, _NMVlanFlags flags_set, @@ -1986,30 +1986,30 @@ gboolean nm_platform_link_vlan_change(NMPlatform * self, const NMVlanQosMapping *egress_map, gsize n_egress_map); -int nm_platform_link_infiniband_add(NMPlatform * self, +int nm_platform_link_infiniband_add(NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link); int nm_platform_link_infiniband_delete(NMPlatform *self, int parent, int p_key); -gboolean nm_platform_link_infiniband_get_properties(NMPlatform * self, +gboolean nm_platform_link_infiniband_get_properties(NMPlatform *self, int ifindex, - int * parent, - int * p_key, + int *parent, + int *p_key, const char **mode); gboolean nm_platform_link_veth_get_properties(NMPlatform *self, int ifindex, int *out_peer_ifindex); -gboolean nm_platform_link_tun_get_properties(NMPlatform * self, +gboolean nm_platform_link_tun_get_properties(NMPlatform *self, int ifindex, NMPlatformLnkTun *out_properties); gboolean nm_platform_wifi_get_capabilities(NMPlatform *self, int ifindex, _NMDeviceWifiCapabilities *caps); guint32 nm_platform_wifi_get_frequency(NMPlatform *self, int ifindex); -gboolean nm_platform_wifi_get_station(NMPlatform * self, +gboolean nm_platform_wifi_get_station(NMPlatform *self, int ifindex, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate); + int *out_quality, + guint32 *out_rate); _NM80211Mode nm_platform_wifi_get_mode(NMPlatform *self, int ifindex); void nm_platform_wifi_set_mode(NMPlatform *self, int ifindex, _NM80211Mode mode); void nm_platform_wifi_set_powersave(NMPlatform *self, int ifindex, guint32 powersave); @@ -2038,24 +2038,24 @@ const NMPlatformIP4Address *nm_platform_ip4_address_get(NMPlatform *self, guint8 plen, in_addr_t peer_address); -int nm_platform_link_sit_add(NMPlatform * self, - const char * name, +int nm_platform_link_sit_add(NMPlatform *self, + const char *name, const NMPlatformLnkSit *props, - const NMPlatformLink ** out_link); -int nm_platform_link_tun_add(NMPlatform * self, - const char * name, + const NMPlatformLink **out_link); +int nm_platform_link_tun_add(NMPlatform *self, + const char *name, const NMPlatformLnkTun *props, - const NMPlatformLink ** out_link, - int * out_fd); + const NMPlatformLink **out_link, + int *out_fd); gboolean nm_platform_link_6lowpan_get_properties(NMPlatform *self, int ifindex, int *out_parent); int nm_platform_link_wireguard_add(NMPlatform *self, const char *name, const NMPlatformLink **out_link); -int nm_platform_link_wireguard_change(NMPlatform * self, +int nm_platform_link_wireguard_change(NMPlatform *self, int ifindex, - const NMPlatformLnkWireGuard * lnk_wireguard, - const struct _NMPWireGuardPeer * peers, + const NMPlatformLnkWireGuard *lnk_wireguard, + const struct _NMPWireGuardPeer *peers, const NMPlatformWireGuardChangePeerFlags *peer_flags, guint peers_len, NMPlatformWireGuardChangeFlags change_flags); @@ -2075,7 +2075,7 @@ gboolean nm_platform_ip4_address_add(NMPlatform *self, guint32 preferred_lft, guint32 flags, const char *label); -gboolean nm_platform_ip6_address_add(NMPlatform * self, +gboolean nm_platform_ip6_address_add(NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen, @@ -2094,8 +2094,8 @@ nm_platform_ip6_address_delete(NMPlatform *self, int ifindex, struct in6_addr ad gboolean nm_platform_ip_address_sync(NMPlatform *self, int addr_family, int ifindex, - GPtrArray * known_addresses, - GPtrArray * addresses_prune); + GPtrArray *known_addresses, + GPtrArray *addresses_prune); GPtrArray *nm_platform_ip_address_get_prune_list(NMPlatform *self, int addr_family, @@ -2106,7 +2106,7 @@ static inline gboolean _nm_platform_ip_address_sync(NMPlatform *self, int addr_family, int ifindex, - GPtrArray * known_addresses, + GPtrArray *known_addresses, gboolean full_sync) { gs_unref_ptrarray GPtrArray *addresses_prune = NULL; @@ -2128,7 +2128,7 @@ nm_platform_ip4_address_sync(NMPlatform *self, int ifindex, GPtrArray *known_add static inline gboolean nm_platform_ip6_address_sync(NMPlatform *self, int ifindex, - GPtrArray * known_addresses, + GPtrArray *known_addresses, gboolean full_sync) { return _nm_platform_ip_address_sync(self, AF_INET6, ifindex, known_addresses, full_sync); @@ -2194,7 +2194,7 @@ int nm_platform_ip_route_add(NMPlatform *self, NMPNlmFlags flags, const NMPObjec int nm_platform_ip4_route_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformIP4Route *route); int nm_platform_ip6_route_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformIP6Route *route); -GPtrArray *nm_platform_ip_route_get_prune_list(NMPlatform * self, +GPtrArray *nm_platform_ip_route_get_prune_list(NMPlatform *self, int addr_family, int ifindex, NMIPRouteTableSyncMode route_table_sync); @@ -2202,19 +2202,19 @@ GPtrArray *nm_platform_ip_route_get_prune_list(NMPlatform * self, gboolean nm_platform_ip_route_sync(NMPlatform *self, int addr_family, int ifindex, - GPtrArray * routes, - GPtrArray * routes_prune, + GPtrArray *routes, + GPtrArray *routes_prune, GPtrArray **out_temporary_not_available); gboolean nm_platform_ip_route_flush(NMPlatform *self, int addr_family, int ifindex); -int nm_platform_ip_route_get(NMPlatform * self, +int nm_platform_ip_route_get(NMPlatform *self, int addr_family, gconstpointer address, int oif_ifindex, - NMPObject ** out_route); + NMPObject **out_route); -int nm_platform_routing_rule_add(NMPlatform * self, +int nm_platform_routing_rule_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformRoutingRule *routing_rule); @@ -2224,8 +2224,8 @@ int nm_platform_tfilter_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatfor int nm_platform_tfilter_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error); gboolean nm_platform_tc_sync(NMPlatform *self, int ifindex, - GPtrArray * known_qdiscs, - GPtrArray * known_tfilters); + GPtrArray *known_qdiscs, + GPtrArray *known_tfilters); const char *nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len); const char *nm_platform_lnk_bridge_to_string(const NMPlatformLnkBridge *lnk, char *buf, gsize len); @@ -2258,10 +2258,10 @@ const char *nm_platform_vf_to_string(const NMPlatformVF *vf, char *buf, gsize le const char * nm_platform_bridge_vlan_to_string(const NMPlatformBridgeVlan *vlan, char *buf, gsize len); -const char *nm_platform_vlan_qos_mapping_to_string(const char * name, +const char *nm_platform_vlan_qos_mapping_to_string(const char *name, const NMVlanQosMapping *map, gsize n_map, - char * buf, + char *buf, gsize len); const char * @@ -2334,13 +2334,13 @@ void nm_platform_ip4_address_hash_update(const NMPlatformIP4Address *obj, NMHash void nm_platform_ip6_address_hash_update(const NMPlatformIP6Address *obj, NMHashState *h); void nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj, NMPlatformIPRouteCmpType cmp_type, - NMHashState * h); + NMHashState *h); void nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj, NMPlatformIPRouteCmpType cmp_type, - NMHashState * h); + NMHashState *h); void nm_platform_routing_rule_hash_update(const NMPlatformRoutingRule *obj, NMPlatformRoutingRuleCmpType cmp_type, - NMHashState * h); + NMHashState *h); void nm_platform_lnk_bridge_hash_update(const NMPlatformLnkBridge *obj, NMHashState *h); void nm_platform_lnk_gre_hash_update(const NMPlatformLnkGre *obj, NMHashState *h); void nm_platform_lnk_infiniband_hash_update(const NMPlatformLnkInfiniband *obj, NMHashState *h); @@ -2367,34 +2367,34 @@ const char *nm_platform_route_scope2str(int scope, char *buf, gsize len); int nm_platform_ip_address_cmp_expiry(const NMPlatformIPAddress *a, const NMPlatformIPAddress *b); -gboolean nm_platform_ethtool_set_wake_on_lan(NMPlatform * self, +gboolean nm_platform_ethtool_set_wake_on_lan(NMPlatform *self, int ifindex, _NMSettingWiredWakeOnLan wol, - const char * wol_password); -gboolean nm_platform_ethtool_set_link_settings(NMPlatform * self, + const char *wol_password); +gboolean nm_platform_ethtool_set_link_settings(NMPlatform *self, int ifindex, gboolean autoneg, guint32 speed, NMPlatformLinkDuplexType duplex); -gboolean nm_platform_ethtool_get_link_settings(NMPlatform * self, +gboolean nm_platform_ethtool_get_link_settings(NMPlatform *self, int ifindex, - gboolean * out_autoneg, - guint32 * out_speed, + gboolean *out_autoneg, + guint32 *out_speed, NMPlatformLinkDuplexType *out_duplex); NMEthtoolFeatureStates *nm_platform_ethtool_get_link_features(NMPlatform *self, int ifindex); gboolean nm_platform_ethtool_set_features( - NMPlatform * self, + NMPlatform *self, int ifindex, const NMEthtoolFeatureStates *features, const NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */, gboolean do_set /* or reset */); -gboolean nm_platform_ethtool_get_link_coalesce(NMPlatform * self, +gboolean nm_platform_ethtool_get_link_coalesce(NMPlatform *self, int ifindex, NMEthtoolCoalesceState *coalesce); -gboolean nm_platform_ethtool_set_coalesce(NMPlatform * self, +gboolean nm_platform_ethtool_set_coalesce(NMPlatform *self, int ifindex, const NMEthtoolCoalesceState *coalesce); @@ -2411,7 +2411,7 @@ nm_platform_ethtool_set_pause(NMPlatform *self, int ifindex, const NMEthtoolPaus void nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self, int ifindex, - GPtrArray * ip4_dev_route_blacklist); + GPtrArray *ip4_dev_route_blacklist); struct _NMDedupMultiIndex *nm_platform_get_multi_idx(NMPlatform *self); diff --git a/src/libnm-platform/nmp-netns.c b/src/libnm-platform/nmp-netns.c index d06c3e11b3..2563e8f640 100644 --- a/src/libnm-platform/nmp-netns.c +++ b/src/libnm-platform/nmp-netns.c @@ -147,8 +147,8 @@ static GArray * _netns_stack_get_impl(void) { gs_unref_object NMPNetns *netns = NULL; - gs_free_error GError *error = NULL; - GArray * s; + gs_free_error GError *error = NULL; + GArray *s; s = g_array_new(FALSE, FALSE, sizeof(NetnsInfo)); g_array_set_clear_func(s, _netns_stack_clear_cb); @@ -444,7 +444,7 @@ nmp_netns_get_fd_mnt(NMPNetns *self) static gboolean _nmp_netns_push_type(NMPNetns *self, int ns_types) { - GArray * netns_stack = _netns_stack_get(); + GArray *netns_stack = _netns_stack_get(); NetnsInfo *info; char sbuf[100]; @@ -493,10 +493,10 @@ nmp_netns_push_type(NMPNetns *self, int ns_types) NMPNetns * nmp_netns_new(void) { - GArray * netns_stack = _netns_stack_get(); - NMPNetns * self; + GArray *netns_stack = _netns_stack_get(); + NMPNetns *self; int errsv; - GError * error = NULL; + GError *error = NULL; unsigned long mountflags = 0; if (!_stack_peek(netns_stack)) { @@ -553,7 +553,7 @@ err_out: gboolean nmp_netns_pop(NMPNetns *self) { - GArray * netns_stack = _netns_stack_get(); + GArray *netns_stack = _netns_stack_get(); NetnsInfo *info; int ns_types; @@ -608,9 +608,9 @@ nmp_netns_is_initial(void) gboolean nmp_netns_bind_to_path(NMPNetns *self, const char *filename, int *out_fd) { - gs_free char * dirname = NULL; - int errsv; - int fd; + gs_free char *dirname = NULL; + int errsv; + int fd; nm_auto_pop_netns NMPNetns *netns_pop = NULL; g_return_val_if_fail(NMP_IS_NETNS(self), FALSE); @@ -690,7 +690,7 @@ nmp_netns_bind_to_path_destroy(NMPNetns *self, const char *filename) static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMPNetns * self = NMP_NETNS(object); + NMPNetns *self = NMP_NETNS(object); NMPNetnsPrivate *priv = NMP_NETNS_GET_PRIVATE(self); switch (prop_id) { @@ -717,7 +717,7 @@ nmp_netns_init(NMPNetns *self) static void dispose(GObject *object) { - NMPNetns * self = NMP_NETNS(object); + NMPNetns *self = NMP_NETNS(object); NMPNetnsPrivate *priv = NMP_NETNS_GET_PRIVATE(self); nm_close(priv->fd_net); diff --git a/src/libnm-platform/nmp-object.c b/src/libnm-platform/nmp-object.c index 559fd8d60d..ef94942e22 100644 --- a/src/libnm-platform/nmp-object.c +++ b/src/libnm-platform/nmp-object.c @@ -279,8 +279,8 @@ static const NMDedupMultiIdxTypeClass _dedup_multi_idx_type_class; static void _idx_obj_id_hash_update(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - NMHashState * h) + const NMDedupMultiObj *obj, + NMHashState *h) { const NMPObject *o = (NMPObject *) obj; @@ -292,8 +292,8 @@ _idx_obj_id_hash_update(const NMDedupMultiIdxType *idx_type, static gboolean _idx_obj_id_equal(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b) + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b) { const NMPObject *o_a = (NMPObject *) obj_a; const NMPObject *o_b = (NMPObject *) obj_b; @@ -307,9 +307,9 @@ _idx_obj_id_equal(const NMDedupMultiIdxType *idx_type, static guint _idx_obj_part(const DedupMultiIdxType *idx_type, - const NMPObject * obj_a, - const NMPObject * obj_b, - NMHashState * h) + const NMPObject *obj_a, + const NMPObject *obj_b, + NMHashState *h) { NMPObjectType obj_type; @@ -466,16 +466,16 @@ _idx_obj_partitionable(const NMDedupMultiIdxType *idx_type, const NMDedupMultiOb static void _idx_obj_partition_hash_update(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - NMHashState * h) + const NMDedupMultiObj *obj, + NMHashState *h) { _idx_obj_part((DedupMultiIdxType *) idx_type, (NMPObject *) obj, NULL, h); } static gboolean _idx_obj_partition_equal(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b) + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b) { return _idx_obj_part((DedupMultiIdxType *) idx_type, (NMPObject *) obj_a, @@ -528,8 +528,8 @@ _vlan_xgress_qos_mappings_cmp(guint n_map, } static void -_vlan_xgress_qos_mappings_cpy(guint * dst_n_map, - NMVlanQosMapping ** dst_map, +_vlan_xgress_qos_mappings_cpy(guint *dst_n_map, + NMVlanQosMapping **dst_map, guint src_n_map, const NMVlanQosMapping *src_map) { @@ -655,7 +655,7 @@ _nmp_object_fixup_link_udev_fields(NMPObject **obj_new, NMPObject *obj_orig, gbo { const char *driver = NULL; gboolean initialized = FALSE; - NMPObject * obj; + NMPObject *obj; nm_assert(obj_orig || *obj_new); nm_assert(obj_new); @@ -695,8 +695,8 @@ _nmp_object_fixup_link_udev_fields(NMPObject **obj_new, NMPObject *obj_orig, gbo } static void -_nmp_object_fixup_link_master_connected(NMPObject ** obj_new, - NMPObject * obj_orig, +_nmp_object_fixup_link_master_connected(NMPObject **obj_new, + NMPObject *obj_orig, const NMPCache *cache) { NMPObject *obj; @@ -775,7 +775,7 @@ NMPObject * nmp_object_new(NMPObjectType obj_type, gconstpointer plobj) { const NMPClass *klass = nmp_class_from_type(obj_type); - NMPObject * obj; + NMPObject *obj; obj = _nmp_object_new_from_class(klass); if (plobj) @@ -891,9 +891,9 @@ nmp_object_stackinit_id_ip6_address(NMPObject *obj, int ifindex, const struct in /*****************************************************************************/ const char * -nmp_object_to_string(const NMPObject * obj, +nmp_object_to_string(const NMPObject *obj, NMPObjectToStringMode to_string_mode, - char * buf, + char *buf, gsize buf_size) { const NMPClass *klass; @@ -937,13 +937,13 @@ nmp_object_to_string(const NMPObject * obj, } static const char * -_vt_cmd_obj_to_string_link(const NMPObject * obj, +_vt_cmd_obj_to_string_link(const NMPObject *obj, NMPObjectToStringMode to_string_mode, - char * buf, + char *buf, gsize buf_size) { const NMPClass *klass = NMP_OBJECT_GET_CLASS(obj); - char * b = buf; + char *b = buf; switch (to_string_mode) { case NMP_OBJECT_TO_STRING_ID: @@ -982,14 +982,14 @@ _vt_cmd_obj_to_string_link(const NMPObject * obj, } static const char * -_vt_cmd_obj_to_string_lnk_vlan(const NMPObject * obj, +_vt_cmd_obj_to_string_lnk_vlan(const NMPObject *obj, NMPObjectToStringMode to_string_mode, - char * buf, + char *buf, gsize buf_size) { const NMPClass *klass; char buf2[sizeof(_nm_utils_to_string_buffer)]; - char * b; + char *b; gsize l; klass = NMP_OBJECT_GET_CLASS(obj); @@ -1046,14 +1046,14 @@ _vt_cmd_obj_to_string_lnk_vlan(const NMPObject * obj, } static const char * -_vt_cmd_obj_to_string_lnk_wireguard(const NMPObject * obj, +_vt_cmd_obj_to_string_lnk_wireguard(const NMPObject *obj, NMPObjectToStringMode to_string_mode, - char * buf, + char *buf, gsize buf_size) { const NMPClass *klass; char buf2[sizeof(_nm_utils_to_string_buffer)]; - char * b; + char *b; guint i; klass = NMP_OBJECT_GET_CLASS(obj); @@ -1100,7 +1100,7 @@ _vt_cmd_obj_to_string_lnk_wireguard(const NMPObject * obj, #define _vt_cmd_plobj_to_string_id(type, plat_type, ...) \ static const char *_vt_cmd_plobj_to_string_id_##type(const NMPlatformObject *_obj, \ - char * buf, \ + char *buf, \ gsize buf_len) \ { \ plat_type *const obj = (plat_type *) _obj; \ @@ -1825,7 +1825,7 @@ static const guint8 _supported_cache_ids_routing_rules[] = { static void _vt_dedup_obj_destroy(NMDedupMultiObj *obj) { - NMPObject * o = (NMPObject *) obj; + NMPObject *o = (NMPObject *) obj; const NMPClass *klass; nm_assert(o->parent._ref_count == 0); @@ -1907,7 +1907,7 @@ nmp_cache_link_connected_for_slave(int ifindex_master, const NMPObject *slave) * Returns: %TRUE, if @master->link.connected should be flipped/toggled. **/ gboolean -nmp_cache_link_connected_needs_toggle(const NMPCache * cache, +nmp_cache_link_connected_needs_toggle(const NMPCache *cache, const NMPObject *master, const NMPObject *potential_slave, const NMPObject *ignore_slave) @@ -1972,7 +1972,7 @@ nmp_cache_link_connected_needs_toggle(const NMPCache * cache, * The connected flag of that master should be toggled. */ const NMPObject * -nmp_cache_link_connected_needs_toggle_by_ifindex(const NMPCache * cache, +nmp_cache_link_connected_needs_toggle_by_ifindex(const NMPCache *cache, int master_ifindex, const NMPObject *potential_slave, const NMPObject *ignore_slave) @@ -1990,7 +1990,7 @@ nmp_cache_link_connected_needs_toggle_by_ifindex(const NMPCache * cache, /*****************************************************************************/ static const NMDedupMultiEntry * -_lookup_entry_with_idx_type(const NMPCache * cache, +_lookup_entry_with_idx_type(const NMPCache *cache, NMPCacheIdType cache_id_type, const NMPObject *obj) { @@ -2014,7 +2014,7 @@ _lookup_entry(const NMPCache *cache, const NMPObject *obj) } const NMDedupMultiEntry * -nmp_cache_lookup_entry_with_idx_type(const NMPCache * cache, +nmp_cache_lookup_entry_with_idx_type(const NMPCache *cache, NMPCacheIdType cache_id_type, const NMPObject *obj) { @@ -2063,7 +2063,7 @@ nmp_cache_lookup_link(const NMPCache *cache, int ifindex) /*****************************************************************************/ const NMDedupMultiHeadEntry * -nmp_cache_lookup_all(const NMPCache * cache, +nmp_cache_lookup_all(const NMPCache *cache, NMPCacheIdType cache_id_type, const NMPObject *select_obj) { @@ -2220,7 +2220,7 @@ nmp_lookup_init_ip4_route_by_weak_id(NMPLookup *lookup, } const NMPLookup * -nmp_lookup_init_ip6_route_by_weak_id(NMPLookup * lookup, +nmp_lookup_init_ip6_route_by_weak_id(NMPLookup *lookup, const struct in6_addr *network, guint plen, guint32 metric, @@ -2269,10 +2269,10 @@ nmp_cache_lookup_to_array(const NMDedupMultiHeadEntry *head_entry, NMPObjectType obj_type, gboolean visible_only) { - const NMPClass * klass = nmp_class_from_type(obj_type); + const NMPClass *klass = nmp_class_from_type(obj_type); NMDedupMultiIter iter; const NMPObject *o; - GArray * array; + GArray *array; g_return_val_if_fail(klass, NULL); @@ -2289,19 +2289,19 @@ nmp_cache_lookup_to_array(const NMDedupMultiHeadEntry *head_entry, /*****************************************************************************/ const NMPObject * -nmp_cache_lookup_link_full(const NMPCache * cache, +nmp_cache_lookup_link_full(const NMPCache *cache, int ifindex, - const char * ifname, + const char *ifname, gboolean visible_only, NMLinkType link_type, NMPObjectMatchFn match_fn, gpointer user_data) { NMPObject obj_needle; - const NMPObject * obj; + const NMPObject *obj; NMDedupMultiIter iter; const NMDedupMultiHeadEntry *head_entry; - const NMPlatformLink * link = NULL; + const NMPlatformLink *link = NULL; NMPLookup lookup; if (ifindex > 0) { @@ -2369,8 +2369,8 @@ _obj_get_add_mode(const NMPObject *obj) static void _idxcache_update_order_for_dump(NMPCache *cache, const NMDedupMultiEntry *entry) { - const NMPClass * klass; - const guint8 * i_idx_type; + const NMPClass *klass; + const guint8 *i_idx_type; const NMDedupMultiEntry *entry2; nm_dedup_multi_entry_reorder(entry, NULL, TRUE); @@ -2396,7 +2396,7 @@ _idxcache_update_order_for_dump(NMPCache *cache, const NMDedupMultiEntry *entry) } static void -_idxcache_update_other_cache_ids(NMPCache * cache, +_idxcache_update_other_cache_ids(NMPCache *cache, NMPCacheIdType cache_id_type, const NMPObject *obj_old, const NMPObject *obj_new, @@ -2405,7 +2405,7 @@ _idxcache_update_other_cache_ids(NMPCache * cache, const NMDedupMultiEntry *entry_new; const NMDedupMultiEntry *entry_old; const NMDedupMultiEntry *entry_order; - NMDedupMultiIdxType * idx_type; + NMDedupMultiIdxType *idx_type; nm_assert(obj_new || obj_old); nm_assert(!obj_new || NMP_OBJECT_GET_TYPE(obj_new) != NMP_OBJECT_TYPE_UNKNOWN); @@ -2474,15 +2474,15 @@ _idxcache_update_other_cache_ids(NMPCache * cache, } static void -_idxcache_update(NMPCache * cache, - const NMDedupMultiEntry * entry_old, - NMPObject * obj_new, +_idxcache_update(NMPCache *cache, + const NMDedupMultiEntry *entry_old, + NMPObject *obj_new, gboolean is_dump, const NMDedupMultiEntry **out_entry_new) { - const NMPClass * klass; - const guint8 * i_idx_type; - NMDedupMultiIdxType * idx_type_o = _idx_type_get(cache, NMP_CACHE_ID_TYPE_OBJECT_TYPE); + const NMPClass *klass; + const guint8 *i_idx_type; + NMDedupMultiIdxType *idx_type_o = _idx_type_get(cache, NMP_CACHE_ID_TYPE_OBJECT_TYPE); const NMDedupMultiEntry *entry_new = NULL; nm_auto_nmpobj const NMPObject *obj_old = NULL; @@ -2559,14 +2559,14 @@ _idxcache_update(NMPCache * cache, } NMPCacheOpsType -nmp_cache_remove(NMPCache * cache, - const NMPObject * obj_needle, +nmp_cache_remove(NMPCache *cache, + const NMPObject *obj_needle, gboolean equals_by_ptr, gboolean only_dirty, const NMPObject **out_obj_old) { const NMDedupMultiEntry *entry_old; - const NMPObject * obj_old; + const NMPObject *obj_old; entry_old = _lookup_entry(cache, obj_needle); @@ -2593,14 +2593,14 @@ nmp_cache_remove(NMPCache * cache, } NMPCacheOpsType -nmp_cache_remove_netlink(NMPCache * cache, - const NMPObject * obj_needle, +nmp_cache_remove_netlink(NMPCache *cache, + const NMPObject *obj_needle, const NMPObject **out_obj_old, const NMPObject **out_obj_new) { - const NMDedupMultiEntry *entry_old; - const NMDedupMultiEntry *entry_new = NULL; - const NMPObject * obj_old; + const NMDedupMultiEntry *entry_old; + const NMDedupMultiEntry *entry_new = NULL; + const NMPObject *obj_old; nm_auto_nmpobj NMPObject *obj_new = NULL; entry_old = _lookup_entry(cache, obj_needle); @@ -2679,15 +2679,15 @@ nmp_cache_remove_netlink(NMPCache * cache, * and @out_obj_new will be set accordingly. **/ NMPCacheOpsType -nmp_cache_update_netlink(NMPCache * cache, - NMPObject * obj_hand_over, +nmp_cache_update_netlink(NMPCache *cache, + NMPObject *obj_hand_over, gboolean is_dump, const NMPObject **out_obj_old, const NMPObject **out_obj_new) { const NMDedupMultiEntry *entry_old; const NMDedupMultiEntry *entry_new; - const NMPObject * obj_old; + const NMPObject *obj_old; gboolean is_alive; nm_assert(cache); @@ -2789,20 +2789,20 @@ nmp_cache_update_netlink(NMPCache * cache, } NMPCacheOpsType -nmp_cache_update_netlink_route(NMPCache * cache, - NMPObject * obj_hand_over, +nmp_cache_update_netlink_route(NMPCache *cache, + NMPObject *obj_hand_over, gboolean is_dump, guint16 nlmsgflags, const NMPObject **out_obj_old, const NMPObject **out_obj_new, const NMPObject **out_obj_replace, - gboolean * out_resync_required) + gboolean *out_resync_required) { NMDedupMultiIter iter; - const NMDedupMultiEntry * entry_old; - const NMDedupMultiEntry * entry_new; - const NMDedupMultiEntry * entry_cur; - const NMDedupMultiEntry * entry_replace; + const NMDedupMultiEntry *entry_old; + const NMDedupMultiEntry *entry_new; + const NMDedupMultiEntry *entry_cur; + const NMDedupMultiEntry *entry_replace; const NMDedupMultiHeadEntry *head_entry; gboolean is_alive; NMPCacheOpsType ops_type = NMP_CACHE_OPS_UNCHANGED; @@ -2937,16 +2937,16 @@ out: } NMPCacheOpsType -nmp_cache_update_link_udev(NMPCache * cache, +nmp_cache_update_link_udev(NMPCache *cache, int ifindex, struct udev_device *udevice, - const NMPObject ** out_obj_old, - const NMPObject ** out_obj_new) + const NMPObject **out_obj_old, + const NMPObject **out_obj_new) { - const NMPObject *obj_old; + const NMPObject *obj_old; nm_auto_nmpobj NMPObject *obj_new = NULL; - const NMDedupMultiEntry * entry_old; - const NMDedupMultiEntry * entry_new; + const NMDedupMultiEntry *entry_old; + const NMDedupMultiEntry *entry_new; entry_old = nmp_cache_lookup_entry_link(cache, ifindex); @@ -2997,14 +2997,14 @@ nmp_cache_update_link_udev(NMPCache * cache, } NMPCacheOpsType -nmp_cache_update_link_master_connected(NMPCache * cache, +nmp_cache_update_link_master_connected(NMPCache *cache, int ifindex, const NMPObject **out_obj_old, const NMPObject **out_obj_new) { - const NMDedupMultiEntry *entry_old; - const NMDedupMultiEntry *entry_new = NULL; - const NMPObject * obj_old; + const NMDedupMultiEntry *entry_old; + const NMDedupMultiEntry *entry_new = NULL; + const NMPObject *obj_old; nm_auto_nmpobj NMPObject *obj_new = NULL; entry_old = nmp_cache_lookup_entry_link(cache, ifindex); diff --git a/src/libnm-platform/nmp-object.h b/src/libnm-platform/nmp-object.h index 9a35014fbb..784dcc2dec 100644 --- a/src/libnm-platform/nmp-object.h +++ b/src/libnm-platform/nmp-object.h @@ -170,9 +170,9 @@ typedef enum { typedef struct { NMDedupMultiObjClass parent; - const char * obj_type_name; - const char * signal_type; - const guint8 * supported_cache_ids; + const char *obj_type_name; + const char *signal_type; + const guint8 *supported_cache_ids; int sizeof_data; int sizeof_public; int addr_family; @@ -189,9 +189,9 @@ typedef struct { void (*cmd_obj_dispose)(NMPObject *obj); gboolean (*cmd_obj_is_alive)(const NMPObject *obj); gboolean (*cmd_obj_is_visible)(const NMPObject *obj); - const char *(*cmd_obj_to_string)(const NMPObject * obj, + const char *(*cmd_obj_to_string)(const NMPObject *obj, NMPObjectToStringMode to_string_mode, - char * buf, + char *buf, gsize buf_size); /* functions that operate on NMPlatformObject */ @@ -302,7 +302,7 @@ typedef struct { typedef struct { NMPlatformLnkWireGuard _public; - const NMPWireGuardPeer * peers; + const NMPWireGuardPeer *peers; const NMPWireGuardAllowedIP *_allowed_ips_buf; guint peers_len; guint _allowed_ips_buf_len; @@ -662,7 +662,7 @@ nmp_object_ref_set_up_cast(gpointer pp, gconstpointer obj) { gboolean _changed = FALSE; const NMPObject *p; - gconstpointer * pp2 = pp; + gconstpointer *pp2 = pp; nm_assert(!pp2 || !*pp2 || NMP_OBJECT_IS_VALID(NMP_OBJECT_UP_CAST(*pp2))); nm_assert(!obj || NMP_OBJECT_IS_VALID(NMP_OBJECT_UP_CAST(obj))); @@ -699,9 +699,9 @@ const NMPObject *nmp_object_stackinit_id_ip4_address(NMPObject *obj, const NMPObject * nmp_object_stackinit_id_ip6_address(NMPObject *obj, int ifindex, const struct in6_addr *address); -const char *nmp_object_to_string(const NMPObject * obj, +const char *nmp_object_to_string(const NMPObject *obj, NMPObjectToStringMode to_string_mode, - char * buf, + char *buf, gsize buf_size); void nmp_object_hash_update(const NMPObject *obj, NMHashState *h); @@ -758,7 +758,7 @@ _nm_auto_nmpobj_cleanup(gpointer p) typedef struct _NMPCache NMPCache; -typedef void (*NMPCachePreHook)(NMPCache * cache, +typedef void (*NMPCachePreHook)(NMPCache *cache, const NMPObject *old, const NMPObject *new, NMPCacheOpsType ops_type, @@ -766,12 +766,12 @@ typedef void (*NMPCachePreHook)(NMPCache * cache, typedef gboolean (*NMPObjectMatchFn)(const NMPObject *obj, gpointer user_data); const NMDedupMultiEntry *nmp_cache_lookup_entry(const NMPCache *cache, const NMPObject *obj); -const NMDedupMultiEntry *nmp_cache_lookup_entry_with_idx_type(const NMPCache * cache, +const NMDedupMultiEntry *nmp_cache_lookup_entry_with_idx_type(const NMPCache *cache, NMPCacheIdType cache_id_type, const NMPObject *obj); const NMDedupMultiEntry *nmp_cache_lookup_entry_link(const NMPCache *cache, int ifindex); -const NMPObject * nmp_cache_lookup_obj(const NMPCache *cache, const NMPObject *obj); -const NMPObject * nmp_cache_lookup_link(const NMPCache *cache, int ifindex); +const NMPObject *nmp_cache_lookup_obj(const NMPCache *cache, const NMPObject *obj); +const NMPObject *nmp_cache_lookup_link(const NMPCache *cache, int ifindex); typedef struct _NMPLookup NMPLookup; @@ -780,7 +780,7 @@ struct _NMPLookup { NMPObject selector_obj; }; -const NMDedupMultiHeadEntry *nmp_cache_lookup_all(const NMPCache * cache, +const NMDedupMultiHeadEntry *nmp_cache_lookup_all(const NMPCache *cache, NMPCacheIdType cache_id_type, const NMPObject *select_obj); @@ -800,7 +800,7 @@ const NMPLookup *nmp_lookup_init_ip4_route_by_weak_id(NMPLookup *lookup, guint plen, guint32 metric, guint8 tos); -const NMPLookup *nmp_lookup_init_ip6_route_by_weak_id(NMPLookup * lookup, +const NMPLookup *nmp_lookup_init_ip6_route_by_weak_id(NMPLookup *lookup, const struct in6_addr *network, guint plen, guint32 metric, @@ -858,20 +858,20 @@ nmp_cache_iter_next_link(NMDedupMultiIter *iter, const NMPlatformLink **out_obj) #define nmp_cache_iter_for_each_link(iter, head, obj) \ for (nm_dedup_multi_iter_init((iter), (head)); nmp_cache_iter_next_link((iter), (obj));) -const NMPObject *nmp_cache_lookup_link_full(const NMPCache * cache, +const NMPObject *nmp_cache_lookup_link_full(const NMPCache *cache, int ifindex, - const char * ifname, + const char *ifname, gboolean visible_only, NMLinkType link_type, NMPObjectMatchFn match_fn, gpointer user_data); gboolean nmp_cache_link_connected_for_slave(int ifindex_master, const NMPObject *slave); -gboolean nmp_cache_link_connected_needs_toggle(const NMPCache * cache, +gboolean nmp_cache_link_connected_needs_toggle(const NMPCache *cache, const NMPObject *master, const NMPObject *potential_slave, const NMPObject *ignore_slave); -const NMPObject *nmp_cache_link_connected_needs_toggle_by_ifindex(const NMPCache * cache, +const NMPObject *nmp_cache_link_connected_needs_toggle_by_ifindex(const NMPCache *cache, int master_ifindex, const NMPObject *potential_slave, const NMPObject *ignore_slave); @@ -880,42 +880,42 @@ gboolean nmp_cache_use_udev_get(const NMPCache *cache); void nmtst_assert_nmp_cache_is_consistent(const NMPCache *cache); -NMPCacheOpsType nmp_cache_remove(NMPCache * cache, - const NMPObject * obj_needle, +NMPCacheOpsType nmp_cache_remove(NMPCache *cache, + const NMPObject *obj_needle, gboolean equals_by_ptr, gboolean only_dirty, const NMPObject **out_obj_old); -NMPCacheOpsType nmp_cache_remove_netlink(NMPCache * cache, - const NMPObject * obj_needle, +NMPCacheOpsType nmp_cache_remove_netlink(NMPCache *cache, + const NMPObject *obj_needle, const NMPObject **out_obj_old, const NMPObject **out_obj_new); -NMPCacheOpsType nmp_cache_update_netlink(NMPCache * cache, - NMPObject * obj_hand_over, +NMPCacheOpsType nmp_cache_update_netlink(NMPCache *cache, + NMPObject *obj_hand_over, gboolean is_dump, const NMPObject **out_obj_old, const NMPObject **out_obj_new); -NMPCacheOpsType nmp_cache_update_netlink_route(NMPCache * cache, - NMPObject * obj_hand_over, +NMPCacheOpsType nmp_cache_update_netlink_route(NMPCache *cache, + NMPObject *obj_hand_over, gboolean is_dump, guint16 nlmsgflags, const NMPObject **out_obj_old, const NMPObject **out_obj_new, const NMPObject **out_obj_replace, - gboolean * out_resync_required); -NMPCacheOpsType nmp_cache_update_link_udev(NMPCache * cache, + gboolean *out_resync_required); +NMPCacheOpsType nmp_cache_update_link_udev(NMPCache *cache, int ifindex, struct udev_device *udevice, - const NMPObject ** out_obj_old, - const NMPObject ** out_obj_new); -NMPCacheOpsType nmp_cache_update_link_master_connected(NMPCache * cache, + const NMPObject **out_obj_old, + const NMPObject **out_obj_new); +NMPCacheOpsType nmp_cache_update_link_master_connected(NMPCache *cache, int ifindex, const NMPObject **out_obj_old, const NMPObject **out_obj_new); static inline const NMDedupMultiEntry * -nmp_cache_reresolve_main_entry(NMPCache * cache, +nmp_cache_reresolve_main_entry(NMPCache *cache, const NMDedupMultiEntry *entry, - const NMPLookup * lookup) + const NMPLookup *lookup) { const NMDedupMultiEntry *main_entry; @@ -944,7 +944,7 @@ NMPCache *nmp_cache_new(NMDedupMultiIndex *multi_idx, gboolean use_udev); void nmp_cache_free(NMPCache *cache); static inline void -ASSERT_nmp_cache_ops(const NMPCache * cache, +ASSERT_nmp_cache_ops(const NMPCache *cache, NMPCacheOpsType ops_type, const NMPObject *obj_old, const NMPObject *obj_new) @@ -1024,7 +1024,7 @@ nm_platform_lookup_object(NMPlatform *platform, NMPObjectType obj_type, int ifin } static inline GPtrArray * -nm_platform_lookup_object_clone(NMPlatform * platform, +nm_platform_lookup_object_clone(NMPlatform *platform, NMPObjectType obj_type, int ifindex, NMPObjectPredicateFunc predicate, @@ -1046,7 +1046,7 @@ nm_platform_lookup_route_default(NMPlatform *platform, NMPObjectType obj_type) } static inline GPtrArray * -nm_platform_lookup_route_default_clone(NMPlatform * platform, +nm_platform_lookup_route_default_clone(NMPlatform *platform, NMPObjectType obj_type, NMPObjectPredicateFunc predicate, gpointer user_data) @@ -1071,7 +1071,7 @@ nm_platform_lookup_ip4_route_by_weak_id(NMPlatform *platform, } static inline const NMDedupMultiHeadEntry * -nm_platform_lookup_ip6_route_by_weak_id(NMPlatform * platform, +nm_platform_lookup_ip6_route_by_weak_id(NMPlatform *platform, const struct in6_addr *network, guint plen, guint32 metric, @@ -1085,7 +1085,7 @@ nm_platform_lookup_ip6_route_by_weak_id(NMPlatform * platform, } static inline const NMDedupMultiHeadEntry * -nm_platform_lookup_object_by_addr_family(NMPlatform * platform, +nm_platform_lookup_object_by_addr_family(NMPlatform *platform, NMPObjectType obj_type, int addr_family) { diff --git a/src/libnm-platform/nmp-rules-manager.c b/src/libnm-platform/nmp-rules-manager.c index 636c90b299..746d1eaa74 100644 --- a/src/libnm-platform/nmp-rules-manager.c +++ b/src/libnm-platform/nmp-rules-manager.c @@ -127,7 +127,7 @@ typedef struct { /*****************************************************************************/ static void _rules_data_untrack(NMPRulesManager *self, - RulesData * rules_data, + RulesData *rules_data, gboolean remove_user_tag_data, gboolean make_owned_by_us); @@ -192,7 +192,7 @@ _rules_data_destroy(gpointer data) static const RulesData * _rules_obj_get_best_data(RulesObjData *obj_data) { - RulesData * rules_data; + RulesData *rules_data; const RulesData *rd_best = NULL; c_list_for_each_entry (rules_data, &obj_data->obj_lst_head, obj_lst) { @@ -308,16 +308,16 @@ _rules_data_lookup(GHashTable *by_data, const NMPObject *obj, gconstpointer user * The purpose here is to set this to %NMP_RULES_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG. */ void -nmp_rules_manager_track(NMPRulesManager * self, +nmp_rules_manager_track(NMPRulesManager *self, const NMPlatformRoutingRule *routing_rule, gint32 track_priority, gconstpointer user_tag, gconstpointer user_tag_untrack) { NMPObject obj_stack; - const NMPObject * p_obj_stack; - RulesData * rules_data; - RulesObjData * obj_data; + const NMPObject *p_obj_stack; + RulesData *rules_data; + RulesObjData *obj_data; RulesUserTagData *user_tag_data; gboolean changed = FALSE; guint32 track_priority_val; @@ -415,7 +415,7 @@ nmp_rules_manager_track(NMPRulesManager * self, static void _rules_data_untrack(NMPRulesManager *self, - RulesData * rules_data, + RulesData *rules_data, gboolean remove_user_tag_data, gboolean make_owned_by_us) { @@ -465,13 +465,13 @@ _rules_data_untrack(NMPRulesManager *self, } void -nmp_rules_manager_untrack(NMPRulesManager * self, +nmp_rules_manager_untrack(NMPRulesManager *self, const NMPlatformRoutingRule *routing_rule, gconstpointer user_tag) { NMPObject obj_stack; const NMPObject *p_obj_stack; - RulesData * rules_data; + RulesData *rules_data; g_return_if_fail(NMP_IS_RULES_MANAGER(self)); g_return_if_fail(routing_rule); @@ -491,7 +491,7 @@ nmp_rules_manager_untrack(NMPRulesManager * self, void nmp_rules_manager_set_dirty(NMPRulesManager *self, gconstpointer user_tag) { - RulesData * rules_data; + RulesData *rules_data; RulesUserTagData *user_tag_data; g_return_if_fail(NMP_IS_RULES_MANAGER(self)); @@ -513,8 +513,8 @@ nmp_rules_manager_untrack_all(NMPRulesManager *self, gconstpointer user_tag, gboolean all /* or only dirty */) { - RulesData * rules_data; - RulesData * rules_data_safe; + RulesData *rules_data; + RulesData *rules_data_safe; RulesUserTagData *user_tag_data; g_return_if_fail(NMP_IS_RULES_MANAGER(self)); @@ -543,12 +543,12 @@ nmp_rules_manager_sync(NMPRulesManager *self, gboolean keep_deleted_rules) { const NMDedupMultiHeadEntry *pl_head_entry; NMDedupMultiIter pl_iter; - const NMPObject * plobj; + const NMPObject *plobj; gs_unref_ptrarray GPtrArray *rules_to_delete = NULL; - RulesObjData * obj_data; + RulesObjData *obj_data; GHashTableIter h_iter; guint i; - const RulesData * rd_best; + const RulesData *rd_best; g_return_if_fail(NMP_IS_RULES_MANAGER(self)); @@ -644,7 +644,7 @@ nmp_rules_manager_sync(NMPRulesManager *self, gboolean keep_deleted_rules) void nmp_rules_manager_track_from_platform(NMPRulesManager *self, - NMPlatform * platform, + NMPlatform *platform, int addr_family, gint32 tracking_priority, gconstpointer user_tag) @@ -652,7 +652,7 @@ nmp_rules_manager_track_from_platform(NMPRulesManager *self, NMPLookup lookup; const NMDedupMultiHeadEntry *head_entry; NMDedupMultiIter iter; - const NMPObject * o; + const NMPObject *o; g_return_if_fail(NMP_IS_RULES_MANAGER(self)); diff --git a/src/libnm-platform/nmp-rules-manager.h b/src/libnm-platform/nmp-rules-manager.h index 69cf907555..65e8ddb236 100644 --- a/src/libnm-platform/nmp-rules-manager.h +++ b/src/libnm-platform/nmp-rules-manager.h @@ -19,7 +19,7 @@ void nmp_rules_manager_unref(NMPRulesManager *self); #define nm_auto_unref_rules_manager nm_auto(_nmp_rules_manager_unref) NM_AUTO_DEFINE_FCN0(NMPRulesManager *, _nmp_rules_manager_unref, nmp_rules_manager_unref); -void nmp_rules_manager_track(NMPRulesManager * self, +void nmp_rules_manager_track(NMPRulesManager *self, const NMPlatformRoutingRule *routing_rule, gint32 track_priority, gconstpointer user_tag, @@ -31,12 +31,12 @@ void nmp_rules_manager_track_default(NMPRulesManager *self, gconstpointer user_tag); void nmp_rules_manager_track_from_platform(NMPRulesManager *self, - NMPlatform * platform, + NMPlatform *platform, int addr_family, gint32 tracking_priority, gconstpointer user_tag); -void nmp_rules_manager_untrack(NMPRulesManager * self, +void nmp_rules_manager_untrack(NMPRulesManager *self, const NMPlatformRoutingRule *routing_rule, gconstpointer user_tag); diff --git a/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c b/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c index 148657ea27..2fa46e3884 100644 --- a/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c +++ b/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c @@ -43,7 +43,7 @@ typedef struct { NMWifiUtils parent; struct nl_sock *nl_sock; - guint32 * freqs; + guint32 *freqs; int id; int num_freqs; int phy; @@ -104,21 +104,21 @@ nl80211_alloc_msg(NMWifiUtilsNl80211 *self, guint32 cmd, guint32 flags) static int nl80211_send_and_recv(NMWifiUtilsNl80211 *self, - struct nl_msg * msg, + struct nl_msg *msg, int (*valid_handler)(struct nl_msg *, void *), void *valid_data) { int err; int done = 0; const struct nl_cb cb = { - .err_cb = error_handler, - .err_arg = &done, - .finish_cb = finish_handler, - .finish_arg = &done, - .ack_cb = ack_handler, - .ack_arg = &done, - .valid_cb = valid_handler, - .valid_arg = valid_data, + .err_cb = error_handler, + .err_arg = &done, + .finish_cb = finish_handler, + .finish_arg = &done, + .ack_cb = ack_handler, + .ack_arg = &done, + .valid_cb = valid_handler, + .valid_arg = valid_data, }; g_return_val_if_fail(msg != NULL, -ENOMEM); @@ -169,8 +169,8 @@ static int nl80211_iface_info_handler(struct nl_msg *msg, void *arg) { struct nl80211_iface_info *info = arg; - struct genlmsghdr * gnlh = nlmsg_data(nlmsg_hdr(msg)); - struct nlattr * tb[NL80211_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *tb[NL80211_ATTR_MAX + 1]; if (nla_parse_arr(tb, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL) < 0) return NL_SKIP; @@ -202,7 +202,7 @@ nl80211_iface_info_handler(struct nl_msg *msg, void *arg) static _NM80211Mode wifi_nl80211_get_mode(NMWifiUtils *data) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; struct nl80211_iface_info iface_info = { .mode = _NM_802_11_MODE_UNKNOWN, }; @@ -219,7 +219,7 @@ wifi_nl80211_get_mode(NMWifiUtils *data) static gboolean wifi_nl80211_set_mode(NMWifiUtils *data, const _NM80211Mode mode) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; nm_auto_nlmsg struct nl_msg *msg = NULL; int err; @@ -252,7 +252,7 @@ nla_put_failure: static gboolean wifi_nl80211_set_powersave(NMWifiUtils *data, guint32 powersave) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; nm_auto_nlmsg struct nl_msg *msg = NULL; int err; @@ -271,9 +271,9 @@ static int nl80211_get_wake_on_wlan_handler(struct nl_msg *msg, void *arg) { _NMSettingWirelessWakeOnWLan *wowl = arg; - struct nlattr * attrs[NL80211_ATTR_MAX + 1]; - struct nlattr * trig[NUM_NL80211_WOWLAN_TRIG]; - struct genlmsghdr * gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *attrs[NL80211_ATTR_MAX + 1]; + struct nlattr *trig[NUM_NL80211_WOWLAN_TRIG]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); nla_parse_arr(attrs, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL); @@ -309,7 +309,7 @@ nl80211_get_wake_on_wlan_handler(struct nl_msg *msg, void *arg) static _NMSettingWirelessWakeOnWLan wifi_nl80211_get_wake_on_wlan(NMWifiUtils *data) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; _NMSettingWirelessWakeOnWLan wowl = _NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE; nm_auto_nlmsg struct nl_msg *msg = NULL; @@ -323,9 +323,9 @@ wifi_nl80211_get_wake_on_wlan(NMWifiUtils *data) static gboolean wifi_nl80211_set_wake_on_wlan(NMWifiUtils *data, _NMSettingWirelessWakeOnWLan wowl) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; nm_auto_nlmsg struct nl_msg *msg = NULL; - struct nlattr * triggers; + struct nlattr *triggers; int err; if (wowl == _NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE) @@ -365,7 +365,7 @@ nla_put_failure: static guint32 wifi_nl80211_get_freq(NMWifiUtils *data) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; struct nl80211_iface_info iface_info = {}; nm_auto_nlmsg struct nl_msg *msg = NULL; @@ -441,11 +441,11 @@ nl80211_station_dump_handler(struct nl_msg *msg, void *arg) [NL80211_RATE_INFO_40_MHZ_WIDTH] = {.type = NLA_FLAG}, [NL80211_RATE_INFO_SHORT_GI] = {.type = NLA_FLAG}, }; - struct nlattr * rinfo[G_N_ELEMENTS(rate_policy)]; - struct nlattr * sinfo[G_N_ELEMENTS(stats_policy)]; + struct nlattr *rinfo[G_N_ELEMENTS(rate_policy)]; + struct nlattr *sinfo[G_N_ELEMENTS(stats_policy)]; struct nl80211_station_info *info = arg; - struct nlattr * tb[NL80211_ATTR_MAX + 1]; - struct genlmsghdr * gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *tb[NL80211_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); if (nla_parse_arr(tb, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL) < 0) return NL_SKIP; @@ -495,10 +495,10 @@ nl80211_station_dump_handler(struct nl_msg *msg, void *arg) static gboolean wifi_nl80211_get_station(NMWifiUtils *data, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate) + int *out_quality, + guint32 *out_rate) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; nm_auto_nlmsg struct nl_msg *msg = NULL; struct nl80211_station_info sta_info = {}; @@ -525,7 +525,7 @@ wifi_nl80211_get_station(NMWifiUtils *data, static gboolean wifi_nl80211_indicate_addressing_running(NMWifiUtils *data, gboolean running) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; nm_auto_nlmsg struct nl_msg *msg = NULL; int err; @@ -552,7 +552,7 @@ nla_put_failure: struct nl80211_device_info { NMWifiUtilsNl80211 *self; int phy; - guint32 * freqs; + guint32 *freqs; int num_freqs; guint32 freq; guint32 caps; @@ -587,14 +587,14 @@ nl80211_wiphy_info_handler(struct nl_msg *msg, void *arg) [NL80211_FREQUENCY_ATTR_RADAR] = {.type = NLA_FLAG}, [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = {.type = NLA_U32}, }; - struct nlattr * tb[NL80211_ATTR_MAX + 1]; - struct genlmsghdr * gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *tb[NL80211_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); struct nl80211_device_info *info = arg; - NMWifiUtilsNl80211 * self = info->self; - struct nlattr * tb_band[NL80211_BAND_ATTR_MAX + 1]; - struct nlattr * tb_freq[G_N_ELEMENTS(freq_policy)]; - struct nlattr * nl_band; - struct nlattr * nl_freq; + NMWifiUtilsNl80211 *self = info->self; + struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1]; + struct nlattr *tb_freq[G_N_ELEMENTS(freq_policy)]; + struct nlattr *nl_band; + struct nlattr *nl_freq; int rem_freq; int rem_band; int freq_idx; @@ -761,7 +761,7 @@ nl80211_wiphy_info_handler(struct nl_msg *msg, void *arg) static guint32 wifi_nl80211_get_mesh_channel(NMWifiUtils *data) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; nm_auto_nlmsg struct nl_msg *msg = NULL; struct nl80211_device_info device_info = {.self = self}; int i; @@ -783,7 +783,7 @@ wifi_nl80211_get_mesh_channel(NMWifiUtils *data) static gboolean wifi_nl80211_set_mesh_channel(NMWifiUtils *data, guint32 channel) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; nm_auto_nlmsg struct nl_msg *msg = NULL; int err; @@ -802,7 +802,7 @@ nla_put_failure: static gboolean wifi_nl80211_set_mesh_ssid(NMWifiUtils *data, const guint8 *ssid, gsize len) { - NMWifiUtilsNl80211 * self = (NMWifiUtilsNl80211 *) data; + NMWifiUtilsNl80211 *self = (NMWifiUtilsNl80211 *) data; nm_auto_nlmsg struct nl_msg *msg = NULL; int err; @@ -822,7 +822,7 @@ nm_wifi_utils_nl80211_init(NMWifiUtilsNl80211 *self) static void nm_wifi_utils_nl80211_class_init(NMWifiUtilsNl80211Class *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMWifiUtilsClass *wifi_utils_class = NM_WIFI_UTILS_CLASS(klass); object_class->dispose = dispose; @@ -845,7 +845,7 @@ NMWifiUtils * nm_wifi_utils_nl80211_new(int ifindex, struct nl_sock *genl) { gs_unref_object NMWifiUtilsNl80211 *self = NULL; - nm_auto_nlmsg struct nl_msg * msg = NULL; + nm_auto_nlmsg struct nl_msg *msg = NULL; struct nl80211_device_info device_info = {}; if (!genl) diff --git a/src/libnm-platform/wifi/nm-wifi-utils-private.h b/src/libnm-platform/wifi/nm-wifi-utils-private.h index bc1e75ec56..7461b65e73 100644 --- a/src/libnm-platform/wifi/nm-wifi-utils-private.h +++ b/src/libnm-platform/wifi/nm-wifi-utils-private.h @@ -39,8 +39,8 @@ typedef struct { */ gboolean (*get_station)(NMWifiUtils *data, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate); + int *out_quality, + guint32 *out_rate); /* OLPC Mesh-only functions */ diff --git a/src/libnm-platform/wifi/nm-wifi-utils-wext.c b/src/libnm-platform/wifi/nm-wifi-utils-wext.c index 6fb37c49eb..2d4112bc05 100644 --- a/src/libnm-platform/wifi/nm-wifi-utils-wext.c +++ b/src/libnm-platform/wifi/nm-wifi-utils-wext.c @@ -427,7 +427,7 @@ wext_qual_to_percent(const struct iw_quality *qual, const struct iw_quality *max static int wifi_wext_get_qual(NMWifiUtils *data) { - NMWifiUtilsWext * wext = (NMWifiUtilsWext *) data; + NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data; struct iwreq wrq; struct iw_statistics stats; char ifname[IFNAMSIZ]; @@ -455,8 +455,8 @@ wifi_wext_get_qual(NMWifiUtils *data) static gboolean wifi_wext_get_station(NMWifiUtils *data, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate) + int *out_quality, + guint32 *out_rate) { NMEtherAddr local_addr; @@ -588,9 +588,9 @@ wext_can_scan_ifname(NMWifiUtilsWext *wext, const char *ifname) static gboolean wext_get_range_ifname(NMWifiUtilsWext *wext, - const char * ifname, + const char *ifname, struct iw_range *range, - guint32 * response_len) + guint32 *response_len) { int i = 26; gboolean success = FALSE; @@ -698,7 +698,7 @@ nm_wifi_utils_wext_init(NMWifiUtilsWext *self) static void nm_wifi_utils_wext_class_init(NMWifiUtilsWextClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMWifiUtilsClass *wifi_utils_class = NM_WIFI_UTILS_CLASS(klass); object_class->dispose = dispose; @@ -717,7 +717,7 @@ nm_wifi_utils_wext_class_init(NMWifiUtilsWextClass *klass) NMWifiUtils * nm_wifi_utils_wext_new(int ifindex, gboolean check_scan) { - NMWifiUtilsWext * wext; + NMWifiUtilsWext *wext; struct iw_range range; guint32 response_len = 0; struct iw_range_with_scan_capa *scan_capa_range; diff --git a/src/libnm-platform/wifi/nm-wifi-utils.c b/src/libnm-platform/wifi/nm-wifi-utils.c index 0b5f8d7124..8bdd65c2bc 100644 --- a/src/libnm-platform/wifi/nm-wifi-utils.c +++ b/src/libnm-platform/wifi/nm-wifi-utils.c @@ -132,8 +132,8 @@ nm_wifi_utils_find_freq(NMWifiUtils *data, const guint32 *freqs) gboolean nm_wifi_utils_get_station(NMWifiUtils *data, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate) + int *out_quality, + guint32 *out_rate) { g_return_val_if_fail(data != NULL, FALSE); diff --git a/src/libnm-platform/wifi/nm-wifi-utils.h b/src/libnm-platform/wifi/nm-wifi-utils.h index 157522ee26..be33b90ca8 100644 --- a/src/libnm-platform/wifi/nm-wifi-utils.h +++ b/src/libnm-platform/wifi/nm-wifi-utils.h @@ -51,8 +51,8 @@ guint32 nm_wifi_utils_find_freq(NMWifiUtils *data, const guint32 *freqs); */ gboolean nm_wifi_utils_get_station(NMWifiUtils *data, NMEtherAddr *out_bssid, - int * out_quality, - guint32 * out_rate); + int *out_quality, + guint32 *out_rate); /* Tells the driver DHCP or SLAAC is running */ gboolean nm_wifi_utils_indicate_addressing_running(NMWifiUtils *data, gboolean running); diff --git a/src/libnm-platform/wpan/nm-wpan-utils.c b/src/libnm-platform/wpan/nm-wpan-utils.c index 082cc3e7b7..d9bbd0f0fa 100644 --- a/src/libnm-platform/wpan/nm-wpan-utils.c +++ b/src/libnm-platform/wpan/nm-wpan-utils.c @@ -95,7 +95,7 @@ nl802154_alloc_msg(NMWpanUtils *self, guint32 cmd, guint32 flags) } static int -nl802154_send_and_recv(NMWpanUtils * self, +nl802154_send_and_recv(NMWpanUtils *self, struct nl_msg *msg, int (*valid_handler)(struct nl_msg *, void *), void *valid_data) @@ -103,14 +103,14 @@ nl802154_send_and_recv(NMWpanUtils * self, int err; int done = 0; const struct nl_cb cb = { - .err_cb = error_handler, - .err_arg = &done, - .finish_cb = finish_handler, - .finish_arg = &done, - .ack_cb = ack_handler, - .ack_arg = &done, - .valid_cb = valid_handler, - .valid_arg = valid_data, + .err_cb = error_handler, + .err_arg = &done, + .finish_cb = finish_handler, + .finish_arg = &done, + .ack_cb = ack_handler, + .ack_arg = &done, + .valid_cb = valid_handler, + .valid_arg = valid_data, }; g_return_val_if_fail(msg != NULL, -ENOMEM); @@ -149,9 +149,9 @@ nl802154_get_interface_handler(struct nl_msg *msg, void *arg) [NL802154_ATTR_PAN_ID] = {.type = NLA_U16}, [NL802154_ATTR_SHORT_ADDR] = {.type = NLA_U16}, }; - struct nlattr * tb[G_N_ELEMENTS(nl802154_policy)]; + struct nlattr *tb[G_N_ELEMENTS(nl802154_policy)]; struct nl802154_interface *info = arg; - struct genlmsghdr * gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); if (nla_parse_arr(tb, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), nl802154_policy) < 0) return NL_SKIP; diff --git a/src/libnm-std-aux/c-list-util.h b/src/libnm-std-aux/c-list-util.h index 9d86d6635f..dbfef0f825 100644 --- a/src/libnm-std-aux/c-list-util.h +++ b/src/libnm-std-aux/c-list-util.h @@ -31,7 +31,7 @@ static inline int c_list_length_is(const CList *list, unsigned long check_len) { unsigned long n = 0; - const CList * iter; + const CList *iter; c_list_for_each (iter, list) { ++n; diff --git a/src/libnm-systemd-core/nm-sd-utils-dhcp.h b/src/libnm-systemd-core/nm-sd-utils-dhcp.h index 5d126d5bd9..6487a90dfe 100644 --- a/src/libnm-systemd-core/nm-sd-utils-dhcp.h +++ b/src/libnm-systemd-core/nm-sd-utils-dhcp.h @@ -11,7 +11,7 @@ typedef struct { uint8_t code; uint8_t data_len; - void * data; + void *data; } nm_sd_dhcp_option; int nm_sd_dhcp_lease_get_private_options(sd_dhcp_lease *lease, nm_sd_dhcp_option **out_options); diff --git a/src/libnm-udev-aux/nm-udev-utils.c b/src/libnm-udev-aux/nm-udev-utils.c index ef1cf26b2d..744d03ce9e 100644 --- a/src/libnm-udev-aux/nm-udev-utils.c +++ b/src/libnm-udev-aux/nm-udev-utils.c @@ -10,9 +10,9 @@ #include struct _NMPUdevClient { - char ** subsystems; - GSource * watch_source; - struct udev * udev; + char **subsystems; + GSource *watch_source; + struct udev *udev; struct udev_monitor *monitor; NMUdevClientEvent event_handler; gpointer event_user_data; @@ -36,8 +36,8 @@ const char * nm_udev_utils_property_decode(const char *uproperty, char **to_free) { const char *p; - char * unescaped = NULL; - char * n = NULL; + char *unescaped = NULL; + char *n = NULL; if (!uproperty) { *to_free = NULL; @@ -87,10 +87,10 @@ nm_udev_utils_property_decode_cp(const char *uproperty) /*****************************************************************************/ static void -_subsystem_split(const char * subsystem_full, +_subsystem_split(const char *subsystem_full, const char **out_subsystem, const char **out_devtype, - char ** to_free) + char **to_free) { char *tmp, *s; @@ -124,8 +124,8 @@ nm_udev_utils_enumerate(struct udev *uclient, const char *const *subsystems) if (subsystems) { for (n = 0; subsystems[n]; n++) { - const char * subsystem; - const char * devtype; + const char *subsystem; + const char *devtype; gs_free char *to_free = NULL; _subsystem_split(subsystems[n], &subsystem, &devtype, &to_free); @@ -161,7 +161,7 @@ nm_udev_client_enumerate_new(NMUdevClient *self) static gboolean monitor_event(int fd, GIOCondition condition, gpointer user_data) { - NMUdevClient * self = user_data; + NMUdevClient *self = user_data; struct udev_device *udevice; if (!self->monitor) @@ -217,8 +217,8 @@ nm_udev_client_new(const char *const *subsystems, /* install subsystem filters to only wake up for certain events */ for (n = 0; self->subsystems[n]; n++) { gs_free char *to_free = NULL; - const char * subsystem; - const char * devtype; + const char *subsystem; + const char *devtype; _subsystem_split(self->subsystems[n], &subsystem, &devtype, &to_free); udev_monitor_filter_add_match_subsystem_devtype(self->monitor, subsystem, devtype); diff --git a/src/libnm-udev-aux/nm-udev-utils.h b/src/libnm-udev-aux/nm-udev-utils.h index 191f9a89a4..1c04fc58d4 100644 --- a/src/libnm-udev-aux/nm-udev-utils.h +++ b/src/libnm-udev-aux/nm-udev-utils.h @@ -12,11 +12,11 @@ struct udev_enumerate; gboolean nm_udev_utils_property_as_boolean(const char *uproperty); const char *nm_udev_utils_property_decode(const char *uproperty, char **to_free); -char * nm_udev_utils_property_decode_cp(const char *uproperty); +char *nm_udev_utils_property_decode_cp(const char *uproperty); typedef struct _NMPUdevClient NMUdevClient; -typedef void (*NMUdevClientEvent)(NMUdevClient * udev_client, +typedef void (*NMUdevClientEvent)(NMUdevClient *udev_client, struct udev_device *udevice, gpointer event_user_data); diff --git a/src/libnmc-base/nm-client-utils.c b/src/libnmc-base/nm-client-utils.c index 49234d9752..01b3df327d 100644 --- a/src/libnmc-base/nm-client-utils.c +++ b/src/libnmc-base/nm-client-utils.c @@ -55,14 +55,14 @@ nmc_objects_sort_by_path(const NMObject *const *objs, gssize len) * If required, the resulting number is checked to be in the range. */ static gboolean -nmc_string_to_uint_base(const char * str, +nmc_string_to_uint_base(const char *str, int base, gboolean range_check, unsigned long int min, unsigned long int max, unsigned long int *value) { - char * end; + char *end; unsigned long int tmp; if (!str || !str[0]) @@ -79,7 +79,7 @@ nmc_string_to_uint_base(const char * str, } gboolean -nmc_string_to_uint(const char * str, +nmc_string_to_uint(const char *str, gboolean range_check, unsigned long int min, unsigned long int max, @@ -130,10 +130,10 @@ nmc_string_to_bool(const char *str, gboolean *val_bool, GError **error) } gboolean -nmc_string_to_ternary_full(const char * str, +nmc_string_to_ternary_full(const char *str, NMCStringToTernaryFlags flags, - NMTernary * val, - GError ** error) + NMTernary *val, + GError **error) { gs_free char *str_to_free = NULL; int i; @@ -194,7 +194,7 @@ _nmc_string_is_valid(const char *input, const char *const *allowed, GError **err { const char *const *p; size_t input_ln, p_len; - const char * partial_match = NULL; + const char *partial_match = NULL; gboolean ambiguous = FALSE; g_return_val_if_fail(!error || !*error, NULL); @@ -324,7 +324,7 @@ nmc_device_state_to_string_with_external(NMDevice *device) { NMActiveConnection *ac; NMDeviceState state; - const char * s; + const char *s; state = nm_device_get_state(device); @@ -501,8 +501,8 @@ NM_UTILS_LOOKUP_STR_DEFINE( NMActiveConnectionState nmc_activation_get_effective_state(NMActiveConnection *active, - NMDevice * device, - const char ** reason) + NMDevice *device, + const char **reason) { NMActiveConnectionState ac_state; NMActiveConnectionStateReason ac_reason; @@ -569,7 +569,7 @@ can_show_utf8(void) { static gboolean can_show_utf8_set = FALSE; static gboolean can_show_utf8 = TRUE; - char * locale_str; + char *locale_str; if (G_LIKELY(can_show_utf8_set)) return can_show_utf8; @@ -763,12 +763,12 @@ nmc_utils_read_passwd_file(const char *passwd_file, gssize *out_error_line, GErr } GHashTable * -nmc_utils_parse_passwd_file(char * contents /* will be modified */, - gssize * out_error_line, +nmc_utils_parse_passwd_file(char *contents /* will be modified */, + gssize *out_error_line, GError **error) { gs_unref_hashtable GHashTable *pwds_hash = NULL; - const char * contents_str; + const char *contents_str; gsize contents_line; pwds_hash = @@ -781,11 +781,11 @@ nmc_utils_parse_passwd_file(char * contents /* will be modified */, while (contents_str[0]) { nm_auto_free_secret char *l_hash_key = NULL; nm_auto_free_secret char *l_hash_val = NULL; - const char * l_content_line; - const char * l_setting; - const char * l_prop; - const char * l_val; - const char * s; + const char *l_content_line; + const char *l_setting; + const char *l_prop; + const char *l_val; + const char *s; gsize l_hash_val_len; /* consume first line. As line delimiters we accept "\r\n", "\n", and "\r". */ diff --git a/src/libnmc-base/nm-client-utils.h b/src/libnmc-base/nm-client-utils.h index 1fc18acaf6..7d6ec70701 100644 --- a/src/libnmc-base/nm-client-utils.h +++ b/src/libnmc-base/nm-client-utils.h @@ -17,7 +17,7 @@ const char *_nmc_string_is_valid(const char *input, const char *const *allowed, #define nmc_string_is_valid(input, allowed, error) \ _nmc_string_is_valid((input), NM_CAST_STRV_CC(allowed), (error)) -gboolean nmc_string_to_uint(const char * str, +gboolean nmc_string_to_uint(const char *str, gboolean range_check, unsigned long int min, unsigned long int max, @@ -29,10 +29,10 @@ typedef enum { NMC_STRING_TO_TERNARY_FLAGS_IGNORE_FOR_DEFAULT = (1LL << 0), } NMCStringToTernaryFlags; -gboolean nmc_string_to_ternary_full(const char * str, +gboolean nmc_string_to_ternary_full(const char *str, NMCStringToTernaryFlags flags, - NMTernary * val, - GError ** error); + NMTernary *val, + GError **error); static inline gboolean nmc_string_to_ternary(const char *str, NMTernary *val, GError **error) @@ -53,8 +53,8 @@ const char *nmc_device_reason_to_string(NMDeviceStateReason reason); const char *nmc_device_metered_to_string(NMMetered value); NMActiveConnectionState nmc_activation_get_effective_state(NMActiveConnection *active, - NMDevice * device, - const char ** reason); + NMDevice *device, + const char **reason); const char *nmc_wifi_strength_bars(guint8 strength); diff --git a/src/libnmc-base/nm-polkit-listener.c b/src/libnmc-base/nm-polkit-listener.c index 29c25b4e67..39a06bc6d4 100644 --- a/src/libnmc-base/nm-polkit-listener.c +++ b/src/libnmc-base/nm-polkit-listener.c @@ -59,9 +59,9 @@ static guint signals[LAST_SIGNAL] = {0}; struct _NMPolkitListener { GObject parent; GDBusConnection *dbus_connection; - char * name_owner; - GCancellable * cancellable; - GMainContext * main_context; + char *name_owner; + GCancellable *cancellable; + GMainContext *main_context; CList request_lst_head; guint pk_auth_agent_reg_id; guint name_owner_changed_id; @@ -79,14 +79,14 @@ G_DEFINE_TYPE(NMPolkitListener, nm_polkit_listener, G_TYPE_OBJECT); typedef struct { CList request_lst; - NMPolkitListener * listener; - GSource * child_stdout_watch_source; - GSource * child_stdin_watch_source; + NMPolkitListener *listener; + GSource *child_stdout_watch_source; + GSource *child_stdin_watch_source; GDBusMethodInvocation *dbus_invocation; - char * action_id; - char * message; - char * username; - char * cookie; + char *action_id; + char *message; + char *username; + char *cookie; NMStrBuf in_buffer; NMStrBuf out_buffer; gsize out_buffer_offset; @@ -163,11 +163,11 @@ static char * choose_identity(GVariant *identities) { GVariantIter identity_iter; - GVariant * details_tmp; - const char * kind; + GVariant *details_tmp; + const char *kind; gs_free char *username_first = NULL; gs_free char *username_root = NULL; - const char * user; + const char *user; /* Choose identity. First try current user, then root, and else * take the first one we find. */ @@ -221,10 +221,10 @@ choose_identity(GVariant *identities) static void agent_register_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMPolkitListener *listener = NM_POLKIT_LISTENER(user_data); - GDBusConnection * dbus_connection = G_DBUS_CONNECTION(source_object); - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; + NMPolkitListener *listener = NM_POLKIT_LISTENER(user_data); + GDBusConnection *dbus_connection = G_DBUS_CONNECTION(source_object); + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; ret = g_dbus_connection_call_finish(dbus_connection, res, &error); @@ -242,9 +242,9 @@ agent_register_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) static void agent_register(NMPolkitListener *self, const char *session_id) { - const char * locale = NULL; + const char *locale = NULL; gs_unref_object NMAuthSubject *subject = NULL; - GVariant * subject_variant = NULL; + GVariant *subject_variant = NULL; locale = g_getenv("LANG"); if (locale == NULL) { @@ -277,7 +277,7 @@ static void agent_unregister(NMPolkitListener *self) { gs_unref_object NMAuthSubject *subject = NULL; - GVariant * subject_variant = NULL; + GVariant *subject_variant = NULL; subject = nm_auth_subject_new_unix_process_self(); subject_variant = nm_auth_subject_unix_to_polkit_gvariant(subject); @@ -299,14 +299,14 @@ agent_unregister(NMPolkitListener *self) static void retrieve_session_id_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMPolkitListener * listener = NM_POLKIT_LISTENER(user_data); - char * session_id; - guint32 session_uid; - nm_auto_free_variant_iter GVariantIter *iter = NULL; - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; - gs_free char * err_str = NULL; - uid_t uid = getuid(); + NMPolkitListener *listener = NM_POLKIT_LISTENER(user_data); + char *session_id; + guint32 session_uid; + nm_auto_free_variant_iter GVariantIter *iter = NULL; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + gs_free char *err_str = NULL; + uid_t uid = getuid(); ret = g_dbus_connection_call_finish(listener->dbus_connection, res, &error); @@ -437,7 +437,7 @@ io_watch_have_data(int fd, GIOCondition condition, gpointer user_data) } while (TRUE) { - char * line_terminator; + char *line_terminator; const char *line; line = nm_str_buf_get_str(&request->in_buffer); @@ -568,12 +568,12 @@ get_request(NMPolkitListener *listener, const char *cookie) } static AuthRequest * -create_request(NMPolkitListener * listener, +create_request(NMPolkitListener *listener, GDBusMethodInvocation *invocation, - const char * action_id, - const char * message, - char * username_take, - const char * cookie) + const char *action_id, + const char *message, + char *username_take, + const char *cookie) { AuthRequest *request; @@ -596,20 +596,20 @@ create_request(NMPolkitListener * listener, } static void -dbus_method_call_cb(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +dbus_method_call_cb(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { - NMPolkitListener *listener = NM_POLKIT_LISTENER(user_data); - const char * action_id; - const char * message; - const char * cookie; - AuthRequest * request; + NMPolkitListener *listener = NM_POLKIT_LISTENER(user_data); + const char *action_id; + const char *message; + const char *cookie; + AuthRequest *request; gs_unref_variant GVariant *identities_gvariant = NULL; if (nm_streq(method_name, "BeginAuthentication")) { @@ -724,15 +724,15 @@ name_owner_changed(NMPolkitListener *self, const char *name_owner) static void name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { NMPolkitListener *self = user_data; - const char * new_owner; + const char *new_owner; if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) { return; @@ -829,7 +829,7 @@ static void dispose(GObject *object) { NMPolkitListener *self = NM_POLKIT_LISTENER(object); - AuthRequest * request; + AuthRequest *request; nm_clear_g_cancellable(&self->cancellable); diff --git a/src/libnmc-base/nm-secret-agent-simple.c b/src/libnmc-base/nm-secret-agent-simple.c index a3d5062d83..5651a15bb8 100644 --- a/src/libnmc-base/nm-secret-agent-simple.c +++ b/src/libnmc-base/nm-secret-agent-simple.c @@ -34,12 +34,12 @@ typedef struct { NMSecretAgentSimple *self; - NMConnection * connection; - const char * setting_name; - char ** hints; + NMConnection *connection; + const char *setting_name; + char **hints; NMSecretAgentOldGetSecretsFunc callback; gpointer callback_data; - GCancellable * cancellable; + GCancellable *cancellable; NMSecretAgentGetSecretsFlags flags; } RequestData; @@ -54,7 +54,7 @@ static guint signals[LAST_SIGNAL] = {0}; typedef struct { GHashTable *requests; - char * path; + char *path; gboolean enabled; } NMSecretAgentSimplePrivate; @@ -88,12 +88,12 @@ _request_data_free(gpointer data) } static void -_request_data_complete(RequestData * request, - GVariant * secrets, - GError * error, +_request_data_complete(RequestData *request, + GVariant *secrets, + GError *error, GHashTableIter *iter_to_remove) { - NMSecretAgentSimple * self = request->self; + NMSecretAgentSimple *self = request->self; NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(self); nm_assert((secrets != NULL) != (error != NULL)); @@ -124,8 +124,8 @@ _request_data_complete(RequestData * request, typedef struct { NMSecretAgentSimpleSecret base; - NMSetting * setting; - char * property; + NMSetting *setting; + char *property; } SecretReal; static void @@ -145,11 +145,11 @@ _secret_real_free(NMSecretAgentSimpleSecret *secret) static NMSecretAgentSimpleSecret * _secret_real_new_plain(NMSecretAgentSecretType secret_type, - const char * pretty_name, - NMSetting * setting, - const char * property) + const char *pretty_name, + NMSetting *setting, + const char *property) { - SecretReal * real; + SecretReal *real; gs_free char *value = NULL; nm_assert(property); @@ -178,7 +178,7 @@ _secret_real_new_plain(NMSecretAgentSecretType secret_type, static NMSecretAgentSimpleSecret * _secret_real_new_vpn_secret(const char *pretty_name, - NMSetting * setting, + NMSetting *setting, const char *property, const char *vpn_type) { @@ -208,8 +208,8 @@ _secret_real_new_vpn_secret(const char *pretty_name, static NMSecretAgentSimpleSecret * _secret_real_new_wireguard_peer_psk(NMSettingWireGuard *s_wg, - const char * public_key, - const char * preshared_key) + const char *public_key, + const char *preshared_key) { SecretReal *real; @@ -238,8 +238,8 @@ _secret_real_new_wireguard_peer_psk(NMSettingWireGuard *s_wg, static gboolean add_8021x_secrets(RequestData *request, GPtrArray *secrets) { - NMSetting8021x * s_8021x = nm_connection_get_setting_802_1x(request->connection); - const char * eap_method; + NMSetting8021x *s_8021x = nm_connection_get_setting_802_1x(request->connection); + const char *eap_method; NMSecretAgentSimpleSecret *secret; /* If hints are given, then always ask for what the hints require */ @@ -301,7 +301,7 @@ add_wireless_secrets(RequestData *request, GPtrArray *secrets) { NMSettingWirelessSecurity *s_wsec = nm_connection_get_setting_wireless_security(request->connection); - const char * key_mgmt = nm_setting_wireless_security_get_key_mgmt(s_wsec); + const char *key_mgmt = nm_setting_wireless_security_get_key_mgmt(s_wsec); NMSecretAgentSimpleSecret *secret; if (!key_mgmt || nm_streq(key_mgmt, "owe")) @@ -350,7 +350,7 @@ add_wireless_secrets(RequestData *request, GPtrArray *secrets) static gboolean add_pppoe_secrets(RequestData *request, GPtrArray *secrets) { - NMSettingPppoe * s_pppoe = nm_connection_get_setting_pppoe(request->connection); + NMSettingPppoe *s_pppoe = nm_connection_get_setting_pppoe(request->connection); NMSecretAgentSimpleSecret *secret; secret = _secret_real_new_plain(NM_SECRET_AGENT_SECRET_TYPE_PROPERTY, @@ -375,7 +375,7 @@ static NMSettingSecretFlags get_vpn_secret_flags(NMSettingVpn *s_vpn, const char *secret_name) { NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - GHashTable * vpn_data; + GHashTable *vpn_data; g_object_get(s_vpn, NM_SETTING_VPN_DATA, &vpn_data, NULL); nm_vpn_service_plugin_get_secret_flags(vpn_data, secret_name, &flags); @@ -385,10 +385,10 @@ get_vpn_secret_flags(NMSettingVpn *s_vpn, const char *secret_name) } static void -add_vpn_secret_helper(GPtrArray * secrets, +add_vpn_secret_helper(GPtrArray *secrets, NMSettingVpn *s_vpn, - const char * name, - const char * ui_name) + const char *name, + const char *ui_name) { NMSecretAgentSimpleSecret *secret; NMSettingSecretFlags flags; @@ -421,10 +421,10 @@ add_vpn_secret_helper(GPtrArray * secrets, static gboolean add_vpn_secrets(RequestData *request, GPtrArray *secrets, char **msg) { - NMSettingVpn * s_vpn = nm_connection_get_setting_vpn(request->connection); + NMSettingVpn *s_vpn = nm_connection_get_setting_vpn(request->connection); const NmcVpnPasswordName *p; - const char * vpn_msg = NULL; - char ** iter; + const char *vpn_msg = NULL; + char **iter; /* If hints are given, then always ask for what the hints require */ if (request->hints) { @@ -451,7 +451,7 @@ add_vpn_secrets(RequestData *request, GPtrArray *secrets, char **msg) static gboolean add_wireguard_secrets(RequestData *request, GPtrArray *secrets, char **msg, GError **error) { - NMSettingWireGuard * s_wg; + NMSettingWireGuard *s_wg; NMSecretAgentSimpleSecret *secret; guint i; @@ -479,8 +479,8 @@ add_wireguard_secrets(RequestData *request, GPtrArray *secrets, char **msg, GErr if (request->hints) { for (i = 0; request->hints[i]; i++) { NMWireGuardPeer *peer; - const char * name = request->hints[i]; - gs_free char * public_key = NULL; + const char *name = request->hints[i]; + gs_free char *public_key = NULL; if (nm_streq(name, NM_SETTING_WIREGUARD_PRIVATE_KEY)) continue; @@ -516,13 +516,13 @@ add_wireguard_secrets(RequestData *request, GPtrArray *secrets, char **msg, GErr typedef struct { GPid auth_dialog_pid; - GString * auth_dialog_response; - RequestData * request; - GPtrArray * secrets; - GCancellable * cancellable; + GString *auth_dialog_response; + RequestData *request; + GPtrArray *secrets; + GCancellable *cancellable; gulong cancellable_id; guint child_watch_id; - GInputStream * input_stream; + GInputStream *input_stream; GOutputStream *output_stream; char read_buf[5]; } AuthDialogData; @@ -544,16 +544,16 @@ _auth_dialog_data_free(AuthDialogData *data) static void _auth_dialog_exited(GPid pid, int status, gpointer user_data) { - AuthDialogData * data = user_data; - RequestData * request = data->request; - GPtrArray * secrets = data->secrets; - NMSettingVpn * s_vpn = nm_connection_get_setting_vpn(request->connection); + AuthDialogData *data = user_data; + RequestData *request = data->request; + GPtrArray *secrets = data->secrets; + NMSettingVpn *s_vpn = nm_connection_get_setting_vpn(request->connection); nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_strfreev char ** groups = NULL; - gs_free char * title = NULL; - gs_free char * message = NULL; + gs_strfreev char **groups = NULL; + gs_free char *title = NULL; + gs_free char *message = NULL; int i; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; data->child_watch_id = 0; @@ -646,9 +646,9 @@ _request_cancelled(GObject *object, gpointer user_data) static void _auth_dialog_read_done(GObject *source_object, GAsyncResult *res, gpointer user_data) { - GInputStream * auth_dialog_out = G_INPUT_STREAM(source_object); - AuthDialogData *data = user_data; - gssize read_size; + GInputStream *auth_dialog_out = G_INPUT_STREAM(source_object); + AuthDialogData *data = user_data; + gssize read_size; gs_free_error GError *error = NULL; read_size = g_input_stream_read_finish(auth_dialog_out, res, &error); @@ -684,7 +684,7 @@ _auth_dialog_read_done(GObject *source_object, GAsyncResult *res, gpointer user_ static void _auth_dialog_write_done(GObject *source_object, GAsyncResult *res, gpointer user_data) { - GOutputStream *auth_dialog_out = G_OUTPUT_STREAM(source_object); + GOutputStream *auth_dialog_out = G_OUTPUT_STREAM(source_object); _nm_unused gs_free char *auth_dialog_request_free = user_data; /* We don't care about write errors. If there are any problems, the @@ -732,20 +732,20 @@ _add_secret_to_string(const char *key, const char *value, gpointer user_data) static gboolean try_spawn_vpn_auth_helper(RequestData *request, GPtrArray *secrets) { - NMSettingVpn * s_vpn = nm_connection_get_setting_vpn(request->connection); + NMSettingVpn *s_vpn = nm_connection_get_setting_vpn(request->connection); gs_unref_ptrarray GPtrArray *auth_dialog_argv = NULL; - NMVpnPluginInfo * plugin_info; - const char * s; + NMVpnPluginInfo *plugin_info; + const char *s; GPid auth_dialog_pid; int auth_dialog_in_fd; int auth_dialog_out_fd; - GOutputStream * auth_dialog_in; - GInputStream * auth_dialog_out; - GError * error = NULL; - GString * auth_dialog_request; - gs_free char * auth_dialog_request_str = NULL; + GOutputStream *auth_dialog_in; + GInputStream *auth_dialog_out; + GError *error = NULL; + GString *auth_dialog_request; + gs_free char *auth_dialog_request_str = NULL; gsize auth_dialog_request_len; - AuthDialogData * data; + AuthDialogData *data; int i; plugin_info = nm_vpn_plugin_info_list_find_by_service(nm_vpn_get_plugin_infos(), @@ -845,11 +845,11 @@ static void request_secrets_from_ui(RequestData *request) { gs_unref_ptrarray GPtrArray *secrets = NULL; - gs_free_error GError * error = NULL; - NMSecretAgentSimplePrivate *priv; - NMSecretAgentSimpleSecret * secret; - const char * title; - gs_free char * msg = NULL; + gs_free_error GError *error = NULL; + NMSecretAgentSimplePrivate *priv; + NMSecretAgentSimpleSecret *secret; + const char *title; + gs_free char *msg = NULL; priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(request->self); g_return_if_fail(priv->enabled); @@ -869,8 +869,8 @@ request_secrets_from_ui(RequestData *request) if (nm_connection_is_type(request->connection, NM_SETTING_WIRELESS_SETTING_NAME)) { NMSettingWireless *s_wireless; - GBytes * ssid; - gs_free char * ssid_utf8 = NULL; + GBytes *ssid; + gs_free char *ssid_utf8 = NULL; s_wireless = nm_connection_get_setting_wireless(request->connection); ssid = nm_setting_wireless_get_ssid(s_wireless); @@ -1022,21 +1022,21 @@ out_fail_error: } static void -get_secrets(NMSecretAgentOld * agent, - NMConnection * connection, - const char * connection_path, - const char * setting_name, - const char ** hints, +get_secrets(NMSecretAgentOld *agent, + NMConnection *connection, + const char *connection_path, + const char *setting_name, + const char **hints, NMSecretAgentGetSecretsFlags flags, NMSecretAgentOldGetSecretsFunc callback, gpointer callback_data) { - NMSecretAgentSimple * self = NM_SECRET_AGENT_SIMPLE(agent); + NMSecretAgentSimple *self = NM_SECRET_AGENT_SIMPLE(agent); NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(self); - RequestData * request; - gs_free_error GError *error = NULL; - gs_free char * request_id = NULL; - const char * request_id_setting_name; + RequestData *request; + gs_free_error GError *error = NULL; + gs_free char *request_id = NULL; + const char *request_id_setting_name; request_id = g_strdup_printf("%s/%s", connection_path, setting_name); @@ -1097,14 +1097,14 @@ get_secrets(NMSecretAgentOld * agent, */ void nm_secret_agent_simple_response(NMSecretAgentSimple *self, - const char * request_id, - GPtrArray * secrets) + const char *request_id, + GPtrArray *secrets) { NMSecretAgentSimplePrivate *priv; - RequestData * request; - gs_unref_variant GVariant *secrets_dict = NULL; - gs_free_error GError *error = NULL; - int i; + RequestData *request; + gs_unref_variant GVariant *secrets_dict = NULL; + gs_free_error GError *error = NULL; + int i; g_return_if_fail(NM_IS_SECRET_AGENT_SIMPLE(self)); @@ -1117,9 +1117,9 @@ nm_secret_agent_simple_response(NMSecretAgentSimple *self, GVariantBuilder vpn_secrets_builder; GVariantBuilder wg_secrets_builder; GVariantBuilder wg_peer_builder; - GHashTable * settings; + GHashTable *settings; GHashTableIter iter; - const char * name; + const char *name; gboolean has_vpn = FALSE; gboolean has_wg = FALSE; @@ -1207,11 +1207,11 @@ nm_secret_agent_simple_response(NMSecretAgentSimple *self, static void cancel_get_secrets(NMSecretAgentOld *agent, const char *connection_path, const char *setting_name) { - NMSecretAgentSimple * self = NM_SECRET_AGENT_SIMPLE(agent); - NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(self); - gs_free_error GError *error = NULL; - gs_free char * request_id = NULL; - RequestData * request; + NMSecretAgentSimple *self = NM_SECRET_AGENT_SIMPLE(agent); + NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(self); + gs_free_error GError *error = NULL; + gs_free char *request_id = NULL; + RequestData *request; request_id = g_strdup_printf("%s/%s", connection_path, setting_name); request = g_hash_table_lookup(priv->requests, &request_id); @@ -1229,9 +1229,9 @@ cancel_get_secrets(NMSecretAgentOld *agent, const char *connection_path, const c } static void -save_secrets(NMSecretAgentOld * agent, - NMConnection * connection, - const char * connection_path, +save_secrets(NMSecretAgentOld *agent, + NMConnection *connection, + const char *connection_path, NMSecretAgentOldSaveSecretsFunc callback, gpointer callback_data) { @@ -1240,9 +1240,9 @@ save_secrets(NMSecretAgentOld * agent, } static void -delete_secrets(NMSecretAgentOld * agent, - NMConnection * connection, - const char * connection_path, +delete_secrets(NMSecretAgentOld *agent, + NMConnection *connection, + const char *connection_path, NMSecretAgentOldDeleteSecretsFunc callback, gpointer callback_data) { @@ -1263,10 +1263,10 @@ delete_secrets(NMSecretAgentOld * agent, void nm_secret_agent_simple_enable(NMSecretAgentSimple *self, const char *path) { - NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(self); - gs_free RequestData **requests = NULL; - gsize i; - gs_free char * path_full = NULL; + NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(self); + gs_free RequestData **requests = NULL; + gsize i; + gs_free char *path_full = NULL; /* The path is only used to match a request_id with the current * connection. Since the request_id is "${CONNECTION_PATH}/${SETTING}", @@ -1326,10 +1326,10 @@ nm_secret_agent_simple_new(const char *name) static void dispose(GObject *object) { - NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(object); - gs_free_error GError *error = NULL; - GHashTableIter iter; - RequestData * request; + NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE(object); + gs_free_error GError *error = NULL; + GHashTableIter iter; + RequestData *request; g_hash_table_iter_init(&iter, priv->requests); while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &request)) { @@ -1356,7 +1356,7 @@ finalize(GObject *object) void nm_secret_agent_simple_class_init(NMSecretAgentSimpleClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSecretAgentOldClass *agent_class = NM_SECRET_AGENT_OLD_CLASS(klass); object_class->dispose = dispose; diff --git a/src/libnmc-base/nm-secret-agent-simple.h b/src/libnmc-base/nm-secret-agent-simple.h index 878f9c75c0..7193f7e512 100644 --- a/src/libnmc-base/nm-secret-agent-simple.h +++ b/src/libnmc-base/nm-secret-agent-simple.h @@ -17,10 +17,10 @@ typedef enum { typedef struct { NMSecretAgentSecretType secret_type; - const char * pretty_name; - const char * entry_id; - char * value; - const char * vpn_type; + const char *pretty_name; + const char *entry_id; + char *value; + const char *vpn_type; bool is_secret : 1; bool no_prompt_entry_id : 1; } NMSecretAgentSimpleSecret; @@ -53,8 +53,8 @@ GType nm_secret_agent_simple_get_type(void); NMSecretAgentSimple *nm_secret_agent_simple_new(const char *name); void nm_secret_agent_simple_response(NMSecretAgentSimple *self, - const char * request_id, - GPtrArray * secrets); + const char *request_id, + GPtrArray *secrets); void nm_secret_agent_simple_enable(NMSecretAgentSimple *self, const char *path); diff --git a/src/libnmc-base/nm-vpn-helpers.c b/src/libnmc-base/nm-vpn-helpers.c index 99a692762b..e2c0c394bd 100644 --- a/src/libnmc-base/nm-vpn-helpers.c +++ b/src/libnmc-base/nm-vpn-helpers.c @@ -25,8 +25,8 @@ NMVpnEditorPlugin * nm_vpn_get_editor_plugin(const char *service_type, GError **error) { - NMVpnEditorPlugin *plugin = NULL; - NMVpnPluginInfo * plugin_info; + NMVpnEditorPlugin *plugin = NULL; + NMVpnPluginInfo *plugin_info; gs_free_error GError *local = NULL; g_return_val_if_fail(service_type, NULL); @@ -95,8 +95,8 @@ nm_vpn_get_plugin_infos(void) gboolean nm_vpn_supports_ipv6(NMConnection *connection) { - NMSettingVpn * s_vpn; - const char * service_type; + NMSettingVpn *s_vpn; + const char *service_type; NMVpnEditorPlugin *plugin; guint32 capabilities; @@ -188,16 +188,16 @@ _extract_variable_value(char *line, const char *tag, char **value) gboolean nm_vpn_openconnect_authenticate_helper(const char *host, - char ** cookie, - char ** gateway, - char ** gwcert, - int * status, - GError ** error) + char **cookie, + char **gateway, + char **gwcert, + int *status, + GError **error) { - gs_free char * output = NULL; + gs_free char *output = NULL; gs_free const char **output_v = NULL; - const char *const * iter; - const char * path; + const char *const *iter; + const char *path; const char *const DEFAULT_PATHS[] = { "/sbin/", "/usr/sbin/", @@ -249,14 +249,14 @@ nm_vpn_openconnect_authenticate_helper(const char *host, } static gboolean -_wg_complete_peer(GPtrArray ** p_peers, +_wg_complete_peer(GPtrArray **p_peers, NMWireGuardPeer *peer_take, gsize peer_start_line_nr, - const char * filename, - GError ** error) + const char *filename, + GError **error) { - nm_auto_unref_wgpeer NMWireGuardPeer *peer = peer_take; - gs_free_error GError *local = NULL; + nm_auto_unref_wgpeer NMWireGuardPeer *peer = peer_take; + gs_free_error GError *local = NULL; if (!peer) return TRUE; @@ -330,37 +330,37 @@ nm_vpn_wireguard_import(const char *filename, GError **error) { nm_auto_clear_secret_ptr NMSecretPtr file_content = NM_SECRET_PTR_INIT(); char ifname[IFNAMSIZ]; - gs_free char * uuid = NULL; + gs_free char *uuid = NULL; gboolean ifname_valid = FALSE; - const char * cstr; - char * line_remainder; - gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingWireGuard * s_wg; - gs_free_error GError *local = NULL; + const char *cstr; + char *line_remainder; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingWireGuard *s_wg; + gs_free_error GError *local = NULL; enum { LINE_CONTEXT_INIT, LINE_CONTEXT_INTERFACE, LINE_CONTEXT_PEER, } line_context; - gsize line_nr; - gsize current_peer_start_line_nr = 0; - nm_auto_unref_wgpeer NMWireGuardPeer *current_peer = NULL; - gs_unref_ptrarray GPtrArray *data_dns_search = NULL; - gs_unref_ptrarray GPtrArray *data_dns_v4 = NULL; - gs_unref_ptrarray GPtrArray *data_dns_v6 = NULL; - gs_unref_ptrarray GPtrArray *data_addr_v4 = NULL; - gs_unref_ptrarray GPtrArray *data_addr_v6 = NULL; - gs_unref_ptrarray GPtrArray *data_peers = NULL; - const char * data_private_key = NULL; - gint64 data_table; - guint data_listen_port = 0; - guint data_fwmark = 0; - guint data_mtu = 0; - int is_v4; - guint i; + gsize line_nr; + gsize current_peer_start_line_nr = 0; + nm_auto_unref_wgpeer NMWireGuardPeer *current_peer = NULL; + gs_unref_ptrarray GPtrArray *data_dns_search = NULL; + gs_unref_ptrarray GPtrArray *data_dns_v4 = NULL; + gs_unref_ptrarray GPtrArray *data_dns_v6 = NULL; + gs_unref_ptrarray GPtrArray *data_addr_v4 = NULL; + gs_unref_ptrarray GPtrArray *data_addr_v6 = NULL; + gs_unref_ptrarray GPtrArray *data_peers = NULL; + const char *data_private_key = NULL; + gint64 data_table; + guint data_listen_port = 0; + guint data_fwmark = 0; + guint data_mtu = 0; + int is_v4; + guint i; g_return_val_if_fail(filename, NULL); g_return_val_if_fail(!error || !*error, NULL); @@ -420,8 +420,8 @@ nm_vpn_wireguard_import(const char *filename, GError **error) line_nr = 0; while (line_remainder[0] != '\0') { const char *matched_key = NULL; - char * value = NULL; - char * line; + char *value = NULL; + char *line; char ch; gint64 i64; @@ -742,9 +742,9 @@ fail_invalid_secret: const char *method_manual = is_v4 ? NM_SETTING_IP4_CONFIG_METHOD_MANUAL : NM_SETTING_IP6_CONFIG_METHOD_MANUAL; NMSettingIPConfig *s_ip = is_v4 ? s_ip4 : s_ip6; - GPtrArray * data_dns = is_v4 ? data_dns_v4 : data_dns_v6; - GPtrArray * data_addr = is_v4 ? data_addr_v4 : data_addr_v6; - GPtrArray * data_dns_search2 = data_dns_search; + GPtrArray *data_dns = is_v4 ? data_dns_v4 : data_dns_v6; + GPtrArray *data_addr = is_v4 ? data_addr_v4 : data_addr_v6; + GPtrArray *data_dns_search2 = data_dns_search; if (!data_addr) { /* When specifying "DNS", we also require an "Address" for the same address diff --git a/src/libnmc-base/nm-vpn-helpers.h b/src/libnmc-base/nm-vpn-helpers.h index 1cf06743df..678ce1e2a9 100644 --- a/src/libnmc-base/nm-vpn-helpers.h +++ b/src/libnmc-base/nm-vpn-helpers.h @@ -20,11 +20,11 @@ gboolean nm_vpn_supports_ipv6(NMConnection *connection); const NmcVpnPasswordName *nm_vpn_get_secret_names(const char *service_type); gboolean nm_vpn_openconnect_authenticate_helper(const char *host, - char ** cookie, - char ** gateway, - char ** gwcert, - int * status, - GError ** error); + char **cookie, + char **gateway, + char **gwcert, + int *status, + GError **error); NMConnection *nm_vpn_wireguard_import(const char *filename, GError **error); diff --git a/src/libnmc-base/qrcodegen.c b/src/libnmc-base/qrcodegen.c index 0aacdb0141..b86ca5870c 100644 --- a/src/libnmc-base/qrcodegen.c +++ b/src/libnmc-base/qrcodegen.c @@ -133,7 +133,7 @@ static const int PENALTY_N4 = 10; // Public function - see documentation comment in header file. bool -qrcodegen_encodeText(const char * text, +qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode[], enum qrcodegen_Ecc ecl, diff --git a/src/libnmc-base/qrcodegen.h b/src/libnmc-base/qrcodegen.h index b91ae49ab6..46d986a380 100644 --- a/src/libnmc-base/qrcodegen.h +++ b/src/libnmc-base/qrcodegen.h @@ -158,7 +158,7 @@ struct qrcodegen_Segment { * - Please consult the QR Code specification for information on * data capacities per version, ECC level, and text encoding mode. */ -bool qrcodegen_encodeText(const char * text, +bool qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode[], enum qrcodegen_Ecc ecl, diff --git a/src/libnmc-setting/nm-meta-setting-access.c b/src/libnmc-setting/nm-meta-setting-access.c index cd4cbdd548..7f679ae5fa 100644 --- a/src/libnmc-setting/nm-meta-setting-access.c +++ b/src/libnmc-setting/nm-meta-setting-access.c @@ -72,7 +72,7 @@ nm_meta_setting_info_editor_find_by_setting(NMSetting *setting) const NMMetaPropertyInfo * nm_meta_setting_info_editor_get_property_info(const NMMetaSettingInfoEditor *setting_info, - const char * property_name) + const char *property_name) { guint i; @@ -109,7 +109,7 @@ const NMMetaPropertyInfo * nm_meta_property_info_find_by_name(const char *setting_name, const char *property_name) { const NMMetaSettingInfoEditor *setting_info; - const NMMetaPropertyInfo * property_info; + const NMMetaPropertyInfo *property_info; setting_info = nm_meta_setting_info_editor_find_by_name(setting_name, FALSE); if (!setting_info) @@ -128,7 +128,7 @@ const NMMetaPropertyInfo * nm_meta_property_info_find_by_setting(NMSetting *setting, const char *property_name) { const NMMetaSettingInfoEditor *setting_info; - const NMMetaPropertyInfo * property_info; + const NMMetaPropertyInfo *property_info; setting_info = nm_meta_setting_info_editor_find_by_setting(setting); if (!setting_info) @@ -193,8 +193,8 @@ nm_meta_abstract_info_get_name(const NMMetaAbstractInfo *abstract_info, gboolean const NMMetaAbstractInfo *const * nm_meta_abstract_info_get_nested(const NMMetaAbstractInfo *abstract_info, - guint * out_len, - gpointer * nested_to_free) + guint *out_len, + gpointer *nested_to_free) { const NMMetaAbstractInfo *const *nested; guint l = 0; @@ -219,16 +219,16 @@ nm_meta_abstract_info_get_nested(const NMMetaAbstractInfo *abstract_info, } gconstpointer -nm_meta_abstract_info_get(const NMMetaAbstractInfo * abstract_info, - const NMMetaEnvironment * environment, +nm_meta_abstract_info_get(const NMMetaAbstractInfo *abstract_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, gpointer target, gpointer target_data, NMMetaAccessorGetType get_type, NMMetaAccessorGetFlags get_flags, NMMetaAccessorGetOutFlags *out_flags, - gboolean * out_is_default, - gpointer * out_to_free) + gboolean *out_is_default, + gpointer *out_to_free) { nm_assert(abstract_info); nm_assert(abstract_info->meta_type); @@ -254,13 +254,13 @@ nm_meta_abstract_info_get(const NMMetaAbstractInfo * abstract_info, } const char *const * -nm_meta_abstract_info_complete(const NMMetaAbstractInfo * abstract_info, - const NMMetaEnvironment * environment, +nm_meta_abstract_info_complete(const NMMetaAbstractInfo *abstract_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, const NMMetaOperationContext *operation_context, - const char * text, - gboolean * out_complete_filename, - char *** out_to_free) + const char *text, + gboolean *out_complete_filename, + char ***out_to_free) { const char *const *values; gsize i, j, text_len; @@ -319,7 +319,7 @@ nm_meta_abstract_info_complete(const NMMetaAbstractInfo * abstract_info, return (const char *const *) v; } else { const char *const *v = values; - char ** r; + char **r; for (i = 0, j = 0; v[i]; i++) { if (strncmp(v[i], text, text_len) != 0) @@ -347,7 +347,7 @@ nm_meta_abstract_info_complete(const NMMetaAbstractInfo * abstract_info, char * nm_meta_abstract_info_get_nested_names_str(const NMMetaAbstractInfo *abstract_info, - const char * name_prefix) + const char *name_prefix) { gs_free gpointer nested_to_free = NULL; const NMMetaAbstractInfo *const *nested; @@ -364,7 +364,7 @@ nm_meta_abstract_info_get_nested_names_str(const NMMetaAbstractInfo *abstract_in char * nm_meta_abstract_infos_get_names_str(const NMMetaAbstractInfo *const *fields_array, - const char * name_prefix) + const char *name_prefix) { GString *str; guint i; @@ -417,7 +417,7 @@ _output_selection_pack(const NMMetaAbstractInfo *const *fields_array, GArray *ar memcpy(pdata, str->str, str->len); for (i = 0; i < len; i++) { const OutputSelectionItem *a = &g_array_index(array, OutputSelectionItem, i); - NMMetaSelectionItem * p = (NMMetaSelectionItem *) &result->items[i]; + NMMetaSelectionItem *p = (NMMetaSelectionItem *) &result->items[i]; p->info = fields_array[a->idx]; p->idx = a->idx; @@ -433,19 +433,19 @@ _output_selection_pack(const NMMetaAbstractInfo *const *fields_array, GArray *ar static gboolean _output_selection_select_one(const NMMetaAbstractInfo *const *fields_array, - const char * fields_prefix, - const char * fields_str, + const char *fields_prefix, + const char *fields_str, gboolean validate_nested, - GArray ** p_array, - GString ** p_str, - GError ** error) + GArray **p_array, + GString **p_str, + GError **error) { guint i, j; - const char * i_name; - const char * right; + const char *i_name; + const char *right; gboolean found = FALSE; const NMMetaAbstractInfo *fields_array_failure = NULL; - gs_free char * fields_str_clone = NULL; + gs_free char *fields_str_clone = NULL; nm_assert(fields_str); nm_assert(p_array); @@ -465,7 +465,7 @@ _output_selection_select_one(const NMMetaAbstractInfo *const *fields_array, goto not_found; for (i = 0; fields_array[i]; i++) { - const NMMetaAbstractInfo * fi = fields_array[i]; + const NMMetaAbstractInfo *fi = fields_array[i]; const NMMetaAbstractInfo *const *nested; gs_free gpointer nested_to_free = NULL; @@ -536,7 +536,7 @@ not_found: } { - GString * str; + GString *str; OutputSelectionItem s = { .idx = i, }; @@ -588,14 +588,14 @@ nm_meta_selection_create_all(const NMMetaAbstractInfo *const *fields_array) NMMetaSelectionResultList * nm_meta_selection_create_parse_one( const NMMetaAbstractInfo *const *fields_array, - const char * fields_prefix, + const char *fields_prefix, const char * fields_str, /* one field selector (contains no commas) and is already stripped of spaces. */ gboolean validate_nested, GError **error) { - gs_unref_array GArray *array = NULL; - nm_auto_free_gstring GString *str = NULL; + gs_unref_array GArray *array = NULL; + nm_auto_free_gstring GString *str = NULL; g_return_val_if_fail(!error || !*error, NULL); nm_assert(fields_str && !strchr(fields_str, ',')); @@ -614,15 +614,15 @@ nm_meta_selection_create_parse_one( NMMetaSelectionResultList * nm_meta_selection_create_parse_list( const NMMetaAbstractInfo *const *fields_array, - const char * fields_str, /* a comma separated list of selectors */ + const char *fields_str, /* a comma separated list of selectors */ gboolean validate_nested, - GError ** error) + GError **error) { - gs_unref_array GArray *array = NULL; + gs_unref_array GArray *array = NULL; nm_auto_free_gstring GString *str = NULL; - gs_free char * fields_str_clone = NULL; - char * fields_str_cur; - char * fields_str_next; + gs_free char *fields_str_clone = NULL; + char *fields_str_cur; + char *fields_str_next; g_return_val_if_fail(!error || !*error, NULL); diff --git a/src/libnmc-setting/nm-meta-setting-access.h b/src/libnmc-setting/nm-meta-setting-access.h index 81aa3b6f67..9b00eb0ada 100644 --- a/src/libnmc-setting/nm-meta-setting-access.h +++ b/src/libnmc-setting/nm-meta-setting-access.h @@ -20,10 +20,10 @@ const NMMetaSettingInfoEditor *nm_meta_setting_info_editor_find_by_setting(NMSet const NMMetaPropertyInfo * nm_meta_setting_info_editor_get_property_info(const NMMetaSettingInfoEditor *setting_info, - const char * property_name); + const char *property_name); const NMMetaPropertyInfo *nm_meta_property_info_find_by_name(const char *setting_name, const char *property_name); -const NMMetaPropertyInfo *nm_meta_property_info_find_by_setting(NMSetting * setting, +const NMMetaPropertyInfo *nm_meta_property_info_find_by_setting(NMSetting *setting, const char *property_name); gboolean nm_meta_setting_info_editor_has_secrets(const NMMetaSettingInfoEditor *setting_info); @@ -39,41 +39,41 @@ const char *nm_meta_abstract_info_get_name(const NMMetaAbstractInfo *abstract_in const NMMetaAbstractInfo *const * nm_meta_abstract_info_get_nested(const NMMetaAbstractInfo *abstract_info, - guint * out_len, - gpointer * nested_to_free); + guint *out_len, + gpointer *nested_to_free); -gconstpointer nm_meta_abstract_info_get(const NMMetaAbstractInfo * abstract_info, - const NMMetaEnvironment * environment, +gconstpointer nm_meta_abstract_info_get(const NMMetaAbstractInfo *abstract_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, gpointer target, gpointer target_data, NMMetaAccessorGetType get_type, NMMetaAccessorGetFlags get_flags, NMMetaAccessorGetOutFlags *out_flags, - gboolean * out_is_default, - gpointer * out_to_free); + gboolean *out_is_default, + gpointer *out_to_free); const char *const *nm_meta_abstract_info_complete(const NMMetaAbstractInfo *abstract_info, - const NMMetaEnvironment * environment, + const NMMetaEnvironment *environment, gpointer environment_user_data, const NMMetaOperationContext *operation_context, - const char * text, + const char *text, gboolean *out_complete_filename, - char *** out_to_free); + char ***out_to_free); /*****************************************************************************/ char *nm_meta_abstract_info_get_nested_names_str(const NMMetaAbstractInfo *abstract_info, - const char * name_prefix); + const char *name_prefix); char *nm_meta_abstract_infos_get_names_str(const NMMetaAbstractInfo *const *fields_array, - const char * name_prefix); + const char *name_prefix); /*****************************************************************************/ typedef struct { const NMMetaAbstractInfo *info; - const char * self_selection; - const char * sub_selection; + const char *self_selection; + const char *sub_selection; guint idx; } NMMetaSelectionItem; @@ -86,14 +86,14 @@ NMMetaSelectionResultList * nm_meta_selection_create_all(const NMMetaAbstractInfo *const *fields_array); NMMetaSelectionResultList * nm_meta_selection_create_parse_one(const NMMetaAbstractInfo *const *fields_array, - const char * fields_prefix, - const char * fields_str, + const char *fields_prefix, + const char *fields_str, gboolean validate_nested, - GError ** error); + GError **error); NMMetaSelectionResultList * nm_meta_selection_create_parse_list(const NMMetaAbstractInfo *const *fields_array, - const char * fields_str, + const char *fields_str, gboolean validate_nested, - GError ** error); + GError **error); #endif /* _NM_META_SETTING_ACCESS_H__ */ diff --git a/src/libnmc-setting/nm-meta-setting-base-impl.c b/src/libnmc-setting/nm-meta-setting-base-impl.c index 8c1ad10ea8..cd55779f11 100644 --- a/src/libnmc-setting/nm-meta-setting-base-impl.c +++ b/src/libnmc-setting/nm-meta-setting-base-impl.c @@ -646,8 +646,8 @@ nm_meta_setting_infos_by_gtype(GType gtype) { #if _NM_META_SETTING_BASE_IMPL_LIBNM nm_auto_unref_gtypeclass GTypeClass *gtypeclass_unref = NULL; - GTypeClass * gtypeclass; - NMSettingClass * klass; + GTypeClass *gtypeclass; + NMSettingClass *klass; if (!g_type_is_a(gtype, NM_TYPE_SETTING)) goto out_none; diff --git a/src/libnmc-setting/nm-meta-setting-base-impl.h b/src/libnmc-setting/nm-meta-setting-base-impl.h index eba1fb96f4..ea4f85ff1b 100644 --- a/src/libnmc-setting/nm-meta-setting-base-impl.h +++ b/src/libnmc-setting/nm-meta-setting-base-impl.h @@ -73,18 +73,18 @@ typedef struct { const char *(*uri_func)(NMSetting8021x *setting); const char *(*passwd_func)(NMSetting8021x *setting); NMSettingSecretFlags (*pwflag_func)(NMSetting8021x *setting); - gboolean (*set_cert_func)(NMSetting8021x * setting, - const char * value, + gboolean (*set_cert_func)(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); - gboolean (*set_private_key_func)(NMSetting8021x * setting, - const char * value, - const char * password, + GError **error); + gboolean (*set_private_key_func)(NMSetting8021x *setting, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error); - const char * file_suffix; + GError **error); + const char *file_suffix; NMSetting8021xSchemeType scheme_type; bool is_secret : 1; } NMSetting8021xSchemeVtable; diff --git a/src/libnmc-setting/nm-meta-setting-desc.c b/src/libnmc-setting/nm-meta-setting-desc.c index 90e080b668..cfe434cfb6 100644 --- a/src/libnmc-setting/nm-meta-setting-desc.c +++ b/src/libnmc-setting/nm-meta-setting-desc.c @@ -49,7 +49,7 @@ _gtype_property_get_gtype(GType gtype, const char *property_name) /* given @gtype, a type for a GObject, lookup the property @property_name * and return its value_type. */ if (G_TYPE_IS_CLASSED(gtype)) { - GParamSpec * param_spec; + GParamSpec *param_spec; nm_auto_unref_gtypeclass GTypeClass *gtypeclass = g_type_class_ref(gtype); if (G_IS_OBJECT_CLASS(gtypeclass)) { @@ -88,12 +88,12 @@ _int64_cmp_desc(gconstpointer a, gconstpointer b, gpointer user_data) static gint64 * _value_str_as_index_list(const char *value, gsize *out_len) { - gs_free char *str_clone_free = NULL; - gboolean str_cloned = FALSE; - char * str; - gsize i, j; - gsize n_alloc; - gsize len; + gs_free char *str_clone_free = NULL; + gboolean str_cloned = FALSE; + char *str; + gsize i, j; + gsize n_alloc; + gsize len; gs_free gint64 *arr = NULL; *out_len = 0; @@ -244,10 +244,10 @@ _parse_ip_address(int family, const char *address, GError **error) { gs_free char *ip_str = NULL; const int MAX_PREFIX = (family == AF_INET) ? 32 : 128; - NMIPAddress * addr; - char * plen; + NMIPAddress *addr; + char *plen; int prefix; - GError * local = NULL; + GError *local = NULL; g_return_val_if_fail(address, NULL); g_return_val_if_fail(!error || !*error, NULL); @@ -285,19 +285,19 @@ _parse_ip_address(int family, const char *address, GError **error) static NMIPRoute * _parse_ip_route(int family, const char *str, GError **error) { - const int MAX_PREFIX = (family == AF_INET) ? 32 : 128; - const char * next_hop = NULL; - int prefix; - NMIPRoute * route = NULL; - GError * local = NULL; - gint64 metric = -1; - guint i; - gs_free const char **routev = NULL; - gs_free char * str_clean_free = NULL; - const char * str_clean; - gs_free char * dest_clone = NULL; - const char * dest; - const char * plen; + const int MAX_PREFIX = (family == AF_INET) ? 32 : 128; + const char *next_hop = NULL; + int prefix; + NMIPRoute *route = NULL; + GError *local = NULL; + gint64 metric = -1; + guint i; + gs_free const char **routev = NULL; + gs_free char *str_clean_free = NULL; + const char *str_clean; + gs_free char *dest_clone = NULL; + const char *dest; + const char *plen; gs_unref_hashtable GHashTable *attrs = NULL; #define ROUTE_SYNTAX \ _("The valid syntax is: 'ip[/prefix] [next-hop] [metric] [attribute=val]... [,ip[/prefix] " \ @@ -357,9 +357,9 @@ _parse_ip_route(int family, const char *str, GError **error) } metric = tmp64; } else if (strchr(routev[i], '=')) { - GHashTableIter iter; - char * iter_key; - GVariant * iter_value; + GHashTableIter iter; + char *iter_key; + GVariant *iter_value; gs_unref_hashtable GHashTable *tmp_attrs = NULL; tmp_attrs = nm_utils_parse_variant_attributes(routev[i], @@ -409,8 +409,8 @@ _parse_ip_route(int family, const char *str, GError **error) if (attrs) { GHashTableIter iter; - char * name; - GVariant * variant; + char *name; + GVariant *variant; g_hash_table_iter_init(&iter, attrs); while (g_hash_table_iter_next(&iter, (gpointer *) &name, (gpointer *) &variant)) @@ -445,7 +445,7 @@ nmc_proxy_check_script(const char *script, char **out_script, GError **error) _PAC_SCRIPT_TYPE_FILE, _PAC_SCRIPT_TYPE_JSON, } desired_type = _PAC_SCRIPT_TYPE_GUESS; - const char * filename = NULL; + const char *filename = NULL; size_t c_len = 0; gs_free char *script_clone = NULL; @@ -588,7 +588,7 @@ static void _env_warn_fcn(const NMMetaEnvironment *environment, gpointer environment_user_data, NMMetaEnvWarnLevel warn_level, - const char * fmt_l10n, + const char *fmt_l10n, ...) { va_list ap; @@ -636,7 +636,7 @@ static gboolean _set_fcn_optionlist(ARGS_SET_FCN); static gboolean _SET_FCN_DO_RESET_DEFAULT(const NMMetaPropertyInfo *property_info, NMMetaAccessorModifier modifier, - const char * value) + const char *value) { nm_assert(property_info); nm_assert(!property_info->property_type->set_supports_remove); @@ -649,7 +649,7 @@ _SET_FCN_DO_RESET_DEFAULT(const NMMetaPropertyInfo *property_info, static gboolean _SET_FCN_DO_RESET_DEFAULT_WITH_SUPPORTS_REMOVE(const NMMetaPropertyInfo *property_info, NMMetaAccessorModifier modifier, - const char * value) + const char *value) { nm_assert(property_info); nm_assert(property_info->property_type->set_supports_remove); @@ -724,9 +724,9 @@ static gboolean _gobject_property_is_default(NMSetting *setting, const char *prop_name) { nm_auto_unset_gvalue GValue v = G_VALUE_INIT; - GParamSpec * pspec; - GHashTable * ht; - char ** strv; + GParamSpec *pspec; + GHashTable *ht; + char **strv; pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(setting)), prop_name); if (!G_IS_PARAM_SPEC(pspec)) @@ -750,7 +750,7 @@ static gboolean _gobject_property_reset(NMSetting *setting, const char *prop_name, gboolean reset_default) { nm_auto_unset_gvalue GValue v = G_VALUE_INIT; - GParamSpec * pspec; + GParamSpec *pspec; pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(setting)), prop_name); if (!G_IS_PARAM_SPEC(pspec)) @@ -772,8 +772,8 @@ _gobject_property_reset_default(NMSetting *setting, const char *prop_name) static const char * _coerce_str_emptyunset(NMMetaAccessorGetType get_type, gboolean is_default, - const char * cstr, - char ** out_str) + const char *cstr, + char **out_str) { nm_assert(out_str && !*out_str); nm_assert((!is_default && cstr && cstr[0] != '\0') || NM_IN_STRSET(cstr, NULL, "")); @@ -803,7 +803,7 @@ _coerce_str_emptyunset(NMMetaAccessorGetType get_type, #define RETURN_STR_EMPTYUNSET(get_type, is_default, cstr) \ G_STMT_START \ { \ - char * _str = NULL; \ + char *_str = NULL; \ const char *_cstr; \ \ _cstr = _coerce_str_emptyunset((get_type), (is_default), (cstr), &_str); \ @@ -824,13 +824,13 @@ _is_default(const NMMetaPropertyInfo *property_info, NMSetting *setting) static gconstpointer _get_fcn_gobject_impl(const NMMetaPropertyInfo *property_info, - NMSetting * setting, + NMSetting *setting, NMMetaAccessorGetType get_type, gboolean handle_emptyunset, - gboolean * out_is_default, - gpointer * out_to_free) + gboolean *out_is_default, + gpointer *out_to_free) { - const char * cstr; + const char *cstr; GType gtype_prop; nm_auto_unset_gvalue GValue val = G_VALUE_INIT; gboolean is_default; @@ -910,9 +910,9 @@ _get_fcn_gobject_impl(const NMMetaPropertyInfo *property_info, } if (gtype_prop == G_TYPE_HASH_TABLE) { - GHashTable * strdict; + GHashTable *strdict; gs_free const char **keys = NULL; - GString * str; + GString *str; gsize i; nm_assert(property_info->setting_info @@ -927,8 +927,8 @@ _get_fcn_gobject_impl(const NMMetaPropertyInfo *property_info, str = g_string_new(NULL); for (i = 0; keys[i]; i++) { - const char * key = keys[i]; - const char * v = g_hash_table_lookup(strdict, key); + const char *key = keys[i]; + const char *v = g_hash_table_lookup(strdict, key); gs_free char *escaped_key = NULL; gs_free char *escaped_val = NULL; @@ -945,7 +945,8 @@ _get_fcn_gobject_impl(const NMMetaPropertyInfo *property_info, return NULL; } -static gconstpointer _get_fcn_gobject(ARGS_GET_FCN) +static gconstpointer +_get_fcn_gobject(ARGS_GET_FCN) { return _get_fcn_gobject_impl(property_info, setting, @@ -955,15 +956,16 @@ static gconstpointer _get_fcn_gobject(ARGS_GET_FCN) out_to_free); } -static gconstpointer _get_fcn_gobject_int(ARGS_GET_FCN) +static gconstpointer +_get_fcn_gobject_int(ARGS_GET_FCN) { - GParamSpec * pspec; + GParamSpec *pspec; nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; gboolean is_uint64 = FALSE; NMMetaSignUnsignInt64 v; guint base = 10; const NMMetaUtilsIntValueInfo *value_infos; - char * return_str; + char *return_str; RETURN_UNSUPPORTED_GET_TYPE(); @@ -1034,7 +1036,8 @@ static gconstpointer _get_fcn_gobject_int(ARGS_GET_FCN) RETURN_STR_TO_FREE(return_str); } -static gconstpointer _get_fcn_gobject_mtu(ARGS_GET_FCN) +static gconstpointer +_get_fcn_gobject_mtu(ARGS_GET_FCN) { guint32 mtu; @@ -1058,7 +1061,8 @@ static gconstpointer _get_fcn_gobject_mtu(ARGS_GET_FCN) RETURN_STR_TO_FREE(g_strdup_printf("%u", (unsigned) mtu)); } -static gconstpointer _get_fcn_gobject_secret_flags(ARGS_GET_FCN) +static gconstpointer +_get_fcn_gobject_secret_flags(ARGS_GET_FCN) { guint v; GValue val = G_VALUE_INIT; @@ -1072,12 +1076,13 @@ static gconstpointer _get_fcn_gobject_secret_flags(ARGS_GET_FCN) RETURN_STR_TO_FREE(secret_flags_to_string(v, get_type)); } -static gconstpointer _get_fcn_gobject_enum(ARGS_GET_FCN) +static gconstpointer +_get_fcn_gobject_enum(ARGS_GET_FCN) { - GType gtype = 0; + GType gtype = 0; nm_auto_unref_gtypeclass GTypeClass *gtype_class = NULL; nm_auto_unref_gtypeclass GTypeClass *gtype_prop_class = NULL; - const struct _NMUtilsEnumValueInfo * value_infos = NULL; + const struct _NMUtilsEnumValueInfo *value_infos = NULL; gboolean has_gtype = FALSE; nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; gint64 v; @@ -1086,9 +1091,9 @@ static gconstpointer _get_fcn_gobject_enum(ARGS_GET_FCN) gboolean format_numeric_hex_unknown = FALSE; gboolean format_text = FALSE; gboolean format_text_l10n = FALSE; - gs_free char * s = NULL; + gs_free char *s = NULL; char s_numeric[64]; - GParamSpec * pspec; + GParamSpec *pspec; RETURN_UNSUPPORTED_GET_TYPE(); @@ -1221,7 +1226,8 @@ static gconstpointer _get_fcn_gobject_enum(ARGS_GET_FCN) /*****************************************************************************/ -static gboolean _set_fcn_gobject_string(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_string(ARGS_SET_FCN) { gs_free char *to_free = NULL; @@ -1264,10 +1270,10 @@ static gboolean _set_fcn_gobject_string(ARGS_SET_FCN) static gboolean _set_fcn_gobject_bool_impl(const NMMetaPropertyInfo *property_info, - NMSetting * setting, + NMSetting *setting, NMMetaAccessorModifier modifier, - const char * value, - GError ** error) + const char *value, + GError **error) { gboolean val_bool; @@ -1281,12 +1287,14 @@ _set_fcn_gobject_bool_impl(const NMMetaPropertyInfo *property_info, return TRUE; } -static gboolean _set_fcn_gobject_bool(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_bool(ARGS_SET_FCN) { return _set_fcn_gobject_bool_impl(property_info, setting, modifier, value, error); } -static gboolean _set_fcn_gobject_ternary(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_ternary(ARGS_SET_FCN) { NMTernary val; @@ -1303,10 +1311,11 @@ static gboolean _set_fcn_gobject_ternary(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_gobject_int(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_int(ARGS_SET_FCN) { int errsv; - const GParamSpec * pspec; + const GParamSpec *pspec; nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; gboolean is_uint64; NMMetaSignUnsignInt64 v; @@ -1330,7 +1339,7 @@ static gboolean _set_fcn_gobject_int(ARGS_SET_FCN) if (value && (value_infos = property_info->property_typ_data->subtype.gobject_int.value_infos)) { gs_free char *vv_free = NULL; - const char * vv; + const char *vv; vv = nm_strstrip_avoid_copy_a(300, value, &vv_free); for (; value_infos->nick; value_infos++) { @@ -1454,10 +1463,11 @@ have_value_from_nick: return TRUE; } -static gboolean _set_fcn_gobject_mtu(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_mtu(ARGS_SET_FCN) { nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; - const GParamSpec * pspec; + const GParamSpec *pspec; gint64 v; if (_SET_FCN_DO_RESET_DEFAULT(property_info, modifier, value)) @@ -1496,7 +1506,8 @@ static gboolean _set_fcn_gobject_mtu(ARGS_SET_FCN) #define IEEE802154_ADDR_LEN 8 #endif -static gboolean _set_fcn_gobject_mac(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_mac(ARGS_SET_FCN) { NMMetaPropertyTypeMacMode mode; gboolean valid; @@ -1528,12 +1539,13 @@ static gboolean _set_fcn_gobject_mac(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_gobject_enum(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_enum(ARGS_SET_FCN) { - GType gtype = 0; - GType gtype_prop; - gboolean has_gtype = FALSE; - nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; + GType gtype = 0; + GType gtype_prop; + gboolean has_gtype = FALSE; + nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; nm_auto_unref_gtypeclass GTypeClass *gtype_prop_class = NULL; nm_auto_unref_gtypeclass GTypeClass *gtype_class = NULL; gboolean is_flags; @@ -1619,7 +1631,7 @@ static gboolean _set_fcn_gobject_enum(ARGS_SET_FCN) fail: if (error) { gs_free const char **valid_all = NULL; - gs_free const char * valid_str = NULL; + gs_free const char *valid_str = NULL; gboolean has_minmax = FALSE; int min = G_MININT; int max = G_MAXINT; @@ -1661,14 +1673,15 @@ fail: /*****************************************************************************/ -static const char *const *_values_fcn_gobject_enum(ARGS_VALUES_FCN) +static const char *const * +_values_fcn_gobject_enum(ARGS_VALUES_FCN) { GType gtype = 0; gboolean has_gtype = FALSE; gboolean has_minmax = FALSE; int min = G_MININT; int max = G_MAXINT; - char ** v; + char **v; if (property_info->property_typ_data) { if (property_info->property_typ_data->subtype.gobject_enum.min @@ -1707,7 +1720,8 @@ static const char *const *_values_fcn_gobject_enum(ARGS_VALUES_FCN) /*****************************************************************************/ -static const char *const *_complete_fcn_gobject_bool(ARGS_COMPLETE_FCN) +static const char *const * +_complete_fcn_gobject_bool(ARGS_COMPLETE_FCN) { static const char *const v[] = { "true", @@ -1726,7 +1740,8 @@ static const char *const *_complete_fcn_gobject_bool(ARGS_COMPLETE_FCN) return v; } -static const char *const *_complete_fcn_gobject_ternary(ARGS_COMPLETE_FCN) +static const char *const * +_complete_fcn_gobject_ternary(ARGS_COMPLETE_FCN) { static const char *const v[] = { "on", @@ -1748,12 +1763,13 @@ static const char *const *_complete_fcn_gobject_ternary(ARGS_COMPLETE_FCN) return v; } -static const char *const *_complete_fcn_gobject_devices(ARGS_COMPLETE_FCN) +static const char *const * +_complete_fcn_gobject_devices(ARGS_COMPLETE_FCN) { NMDevice *const *devices = NULL; guint i, j; guint len = 0; - char ** ifnames; + char **ifnames; if (environment && environment->get_nm_devices) { devices = environment->get_nm_devices(environment, environment_user_data, &len); @@ -1860,9 +1876,9 @@ secret_flags_to_string(guint32 flags, NMMetaAccessorGetType get_type) static const char * _multilist_do_validate(const NMMetaPropertyInfo *property_info, - NMSetting * setting, - const char * item, - GError ** error) + NMSetting *setting, + const char *item, + GError **error) { if (property_info->property_typ_data->values_static) { nm_assert(!property_info->property_typ_data->subtype.multilist.validate_fcn); @@ -1882,7 +1898,8 @@ _multilist_do_validate(const NMMetaPropertyInfo *property_info, return item; } -static gconstpointer _get_fcn_multilist(ARGS_GET_FCN) +static gconstpointer +_get_fcn_multilist(ARGS_GET_FCN) { return _get_fcn_gobject_impl( property_info, @@ -1895,7 +1912,7 @@ static gconstpointer _get_fcn_multilist(ARGS_GET_FCN) static gboolean _multilist_clear_property(const NMMetaPropertyInfo *property_info, - NMSetting * setting, + NMSetting *setting, gboolean is_set /* or else set default */) { if (property_info->property_typ_data->subtype.multilist.clear_emptyunset_fcn) { @@ -1909,7 +1926,8 @@ _multilist_clear_property(const NMMetaPropertyInfo *property_info, return _gobject_property_reset(setting, property_info->property_name, FALSE); } -static gboolean _set_fcn_multilist(ARGS_SET_FCN) +static gboolean +_set_fcn_multilist(ARGS_SET_FCN) { gs_free const char **strv = NULL; gsize i, j, nstrv; @@ -2000,7 +2018,8 @@ static gboolean _set_fcn_multilist(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_optionlist(ARGS_SET_FCN) +static gboolean +_set_fcn_optionlist(ARGS_SET_FCN) { gs_free const char **strv = NULL; gs_free const char **strv_val = NULL; @@ -2112,7 +2131,7 @@ validate_flags(NMSetting *setting, const char *prop, guint val, GError **error) if (g_param_value_validate(pspec, &value)) { GParamSpecFlags *pspec_flags = (GParamSpecFlags *) pspec; - gs_free char * flag_values = NULL; + gs_free char *flag_values = NULL; flag_values = flag_values_to_string(pspec_flags->flags_class->values, pspec_flags->flags_class->n_values); @@ -2129,7 +2148,8 @@ validate_flags(NMSetting *setting, const char *prop, guint val, GError **error) return success; } -static gboolean _set_fcn_gobject_flags(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_flags(ARGS_SET_FCN) { unsigned long val_int; @@ -2149,7 +2169,8 @@ static gboolean _set_fcn_gobject_flags(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_gobject_ssid(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_ssid(ARGS_SET_FCN) { gs_unref_bytes GBytes *ssid = NULL; @@ -2166,7 +2187,8 @@ static gboolean _set_fcn_gobject_ssid(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_gobject_ifname(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_ifname(ARGS_SET_FCN) { if (_SET_FCN_DO_RESET_DEFAULT(property_info, modifier, value)) return _gobject_property_reset_default(setting, property_info->property_name); @@ -2175,7 +2197,8 @@ static gboolean _set_fcn_gobject_ifname(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_vpn_service_type(ARGS_SET_FCN) +static gboolean +_set_fcn_vpn_service_type(ARGS_SET_FCN) { gs_free char *service_name = NULL; @@ -2187,7 +2210,8 @@ static gboolean _set_fcn_vpn_service_type(ARGS_SET_FCN) return TRUE; } -static const char *const *_complete_fcn_vpn_service_type(ARGS_COMPLETE_FCN) +static const char *const * +_complete_fcn_vpn_service_type(ARGS_COMPLETE_FCN) { gsize i, j; char **values; @@ -2240,14 +2264,15 @@ _multilist_validate_fcn_is_ipv4_addr_or_subnet(const char *value, GError **error return value; } -static gboolean _set_fcn_gobject_bytes(ARGS_SET_FCN) +static gboolean +_set_fcn_gobject_bytes(ARGS_SET_FCN) { - gs_free char * val_strip_free = NULL; - gs_free const char **strv = NULL; - const char * val_strip; - const char ** iter; + gs_free char *val_strip_free = NULL; + gs_free const char **strv = NULL; + const char *val_strip; + const char **iter; gs_unref_bytes GBytes *bytes = NULL; - GByteArray * array; + GByteArray *array; if (_SET_FCN_DO_RESET_DEFAULT(property_info, modifier, value)) return _gobject_property_reset_default(setting, property_info->property_name); @@ -2294,11 +2319,12 @@ done: /*****************************************************************************/ -static gconstpointer _get_fcn_cert_8021x(ARGS_GET_FCN) +static gconstpointer +_get_fcn_cert_8021x(ARGS_GET_FCN) { - NMSetting8021x * s_8021X = NM_SETTING_802_1X(setting); + NMSetting8021x *s_8021X = NM_SETTING_802_1X(setting); const NMSetting8021xSchemeVtable *vtable; - char * str = NULL; + char *str = NULL; RETURN_UNSUPPORTED_GET_TYPE(); @@ -2325,9 +2351,10 @@ static gconstpointer _get_fcn_cert_8021x(ARGS_GET_FCN) RETURN_STR_TO_FREE(str); } -static gboolean _set_fcn_cert_8021x(ARGS_SET_FCN) +static gboolean +_set_fcn_cert_8021x(ARGS_SET_FCN) { - gs_free char * value_to_free = NULL; + gs_free char *value_to_free = NULL; NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_PATH; const NMSetting8021xSchemeVtable *vtable; @@ -2352,9 +2379,9 @@ static gboolean _set_fcn_cert_8021x(ARGS_SET_FCN) if (vtable->is_secret) { nm_auto_free_secret char *password_free = NULL; - gs_free const char ** strv = NULL; - const char * password; - const char * path; + gs_free const char **strv = NULL; + const char *password; + const char *path; gsize len; strv = nm_utils_escaped_tokens_split(value, NM_ASCII_SPACES); @@ -2383,7 +2410,8 @@ static gboolean _set_fcn_cert_8021x(ARGS_SET_FCN) } } -static const char *const *_complete_fcn_cert_8021x(ARGS_COMPLETE_FCN) +static const char *const * +_complete_fcn_cert_8021x(ARGS_COMPLETE_FCN) { const NMSetting8021xSchemeVtable *vtable; @@ -2403,10 +2431,11 @@ static const char *const *_complete_fcn_cert_8021x(ARGS_COMPLETE_FCN) return NULL; } -static gconstpointer _get_fcn_bond_options(ARGS_GET_FCN) +static gconstpointer +_get_fcn_bond_options(ARGS_GET_FCN) { NMSettingBond *s_bond = NM_SETTING_BOND(setting); - GString * str; + GString *str; guint32 i, len; RETURN_UNSUPPORTED_GET_TYPE(); @@ -2414,10 +2443,10 @@ static gconstpointer _get_fcn_bond_options(ARGS_GET_FCN) str = g_string_new(NULL); len = nm_setting_bond_get_num_options(s_bond); for (i = 0; i < len; i++) { - const char * key; - const char * val; + const char *key; + const char *val; gs_free char *val_tmp = NULL; - char * p; + char *p; gs_free char *escaped_key = NULL; gs_free char *escaped_val = NULL; @@ -2444,15 +2473,15 @@ static gconstpointer _get_fcn_bond_options(ARGS_GET_FCN) } gboolean -_nm_meta_setting_bond_add_option(NMSetting * setting, +_nm_meta_setting_bond_add_option(NMSetting *setting, const char *name, const char *value, - GError ** error) + GError **error) { NMSettingBond *s_bond = NM_SETTING_BOND(setting); - gs_free char * tmp_value = NULL; - const char * val2; - char * p; + gs_free char *tmp_value = NULL; + const char *val2; + char *p; if (!value || !value[0]) { /* This call only fails if name is currently not tracked. It's not an @@ -2513,11 +2542,12 @@ _nm_meta_setting_bond_add_option(NMSetting * setting, return TRUE; } -static const char *_describe_fcn_bond_options(ARGS_DESCRIBE_FCN) +static const char * +_describe_fcn_bond_options(ARGS_DESCRIBE_FCN) { gs_free char *options_str = NULL; - const char ** valid_options; - char * s; + const char **valid_options; + char *s; valid_options = nm_setting_bond_get_valid_options(NULL); options_str = g_strjoinv(", ", (char **) valid_options); @@ -2538,17 +2568,19 @@ static const char *_describe_fcn_bond_options(ARGS_DESCRIBE_FCN) return (*out_to_free = s); } -static const char *const *_values_fcn_bond_options(ARGS_VALUES_FCN) +static const char *const * +_values_fcn_bond_options(ARGS_VALUES_FCN) { return nm_setting_bond_get_valid_options(NULL); } -static gconstpointer _get_fcn_connection_permissions(ARGS_GET_FCN) +static gconstpointer +_get_fcn_connection_permissions(ARGS_GET_FCN) { NMSettingConnection *s_con = NM_SETTING_CONNECTION(setting); - GString * perm = NULL; - const char * perm_item; - const char * perm_type; + GString *perm = NULL; + const char *perm_item; + const char *perm_type; guint i, n; RETURN_UNSUPPORTED_GET_TYPE(); @@ -2575,7 +2607,8 @@ static gconstpointer _get_fcn_connection_permissions(ARGS_GET_FCN) return NULL; } -static gboolean _set_fcn_connection_type(ARGS_SET_FCN) +static gboolean +_set_fcn_connection_type(ARGS_SET_FCN) { gs_free char *uuid = NULL; @@ -2603,10 +2636,11 @@ static gboolean _set_fcn_connection_type(ARGS_SET_FCN) return TRUE; } -static const char *const *_complete_fcn_connection_type(ARGS_COMPLETE_FCN) +static const char *const * +_complete_fcn_connection_type(ARGS_COMPLETE_FCN) { guint i, j; - char ** result; + char **result; gsize text_len; const char *slave_types[] = {"bond-slave", "bridge-slave", "team-slave"}; @@ -2617,7 +2651,7 @@ static const char *const *_complete_fcn_connection_type(ARGS_COMPLETE_FCN) for (i = 0, j = 0; i < _NM_META_SETTING_TYPE_NUM; i++) { const NMMetaSettingInfoEditor *setting_info = &nm_meta_setting_infos_editor[i]; GType gtype = setting_info->general->get_setting_gtype(); - const char * v; + const char *v; if (_nm_setting_type_get_base_type_priority(gtype) == NM_SETTING_PRIORITY_INVALID) { nm_assert(!setting_info->valid_parts); @@ -2662,9 +2696,9 @@ _sanitize_connection_permission_user(const char *perm) } static const char * -_multilist_validate2_fcn_connection_permissions(NMSetting * setting, +_multilist_validate2_fcn_connection_permissions(NMSetting *setting, const char *item, - GError ** error) + GError **error) { if (!_sanitize_connection_permission_user(item)) { nm_utils_error_set(error, @@ -2703,14 +2737,15 @@ _multilist_remove_by_value_fcn_connection_permissions(NMSetting *setting, const return TRUE; } -static const char *const *_complete_fcn_connection_master(ARGS_COMPLETE_FCN) +static const char *const * +_complete_fcn_connection_master(ARGS_COMPLETE_FCN) { NMRemoteConnection *const *connections = NULL; guint len = 0; guint i, j; - char ** result; - NMSettingConnection * s_con; - const char * expected_type = NULL; + char **result; + NMSettingConnection *s_con; + const char *expected_type = NULL; gsize text_len; if (environment && environment->get_nm_connections) { @@ -2776,10 +2811,11 @@ _multilist_validate2_fcn_uuid(NMSetting *setting, const char *item, GError **err return item; } -static gconstpointer _get_fcn_connection_metered(ARGS_GET_FCN) +static gconstpointer +_get_fcn_connection_metered(ARGS_GET_FCN) { NMSettingConnection *s_conn = NM_SETTING_CONNECTION(setting); - const char * s; + const char *s; RETURN_UNSUPPORTED_GET_TYPE(); @@ -2802,7 +2838,8 @@ static gconstpointer _get_fcn_connection_metered(ARGS_GET_FCN) return s; } -static gboolean _set_fcn_connection_metered(ARGS_SET_FCN) +static gboolean +_set_fcn_connection_metered(ARGS_SET_FCN) { NMMetered metered; NMTernary ts_val; @@ -2859,10 +2896,11 @@ dcb_flags_to_string(NMSettingDcbFlags flags) return g_string_free(flag_str, FALSE); } -static gconstpointer _get_fcn_dcb(ARGS_GET_FCN) +static gconstpointer +_get_fcn_dcb(ARGS_GET_FCN) { NMSettingDcb *s_dcb = NM_SETTING_DCB(setting); - GString * str; + GString *str; guint i; RETURN_UNSUPPORTED_GET_TYPE(); @@ -2884,7 +2922,8 @@ static gconstpointer _get_fcn_dcb(ARGS_GET_FCN) #define DCB_ALL_FLAGS \ (NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING) -static gconstpointer _get_fcn_dcb_flags(ARGS_GET_FCN) +static gconstpointer +_get_fcn_dcb_flags(ARGS_GET_FCN) { nm_auto_unset_gvalue GValue val = G_VALUE_INIT; guint v; @@ -2898,7 +2937,8 @@ static gconstpointer _get_fcn_dcb_flags(ARGS_GET_FCN) RETURN_STR_TO_FREE(dcb_flags_to_string(v)); } -static gboolean _set_fcn_dcb_flags(ARGS_SET_FCN) +static gboolean +_set_fcn_dcb_flags(ARGS_SET_FCN) { NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; long int t; @@ -2912,7 +2952,7 @@ static gboolean _set_fcn_dcb_flags(ARGS_SET_FCN) flags = (guint) t; else { gs_free const char **strv = NULL; - const char *const * iter; + const char *const *iter; /* Check for individual flag numbers */ strv = nm_strsplit_set(value, " \t,"); @@ -2950,10 +2990,10 @@ dcb_parse_uint_array(const char *val, guint max, guint other, guint out_array[static 8], - GError ** error) + GError **error) { gs_free const char **items = NULL; - const char *const * iter; + const char *const *iter; gsize i; items = nm_strsplit_set_with_empty(val, ","); @@ -2997,9 +3037,9 @@ dcb_parse_uint_array(const char *val, static void dcb_check_feature_enabled(const NMMetaEnvironment *environment, - gpointer * environment_user_data, - NMSettingDcb * s_dcb, - const char * flags_prop) + gpointer *environment_user_data, + NMSettingDcb *s_dcb, + const char *flags_prop) { NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; @@ -3013,7 +3053,8 @@ dcb_check_feature_enabled(const NMMetaEnvironment *environment, } } -static gboolean _set_fcn_dcb(ARGS_SET_FCN) +static gboolean +_set_fcn_dcb(ARGS_SET_FCN) { guint i = 0; guint nums[8] = { @@ -3054,10 +3095,11 @@ static gboolean _set_fcn_dcb(ARGS_SET_FCN) return TRUE; } -static gconstpointer _get_fcn_dcb_bool(ARGS_GET_FCN) +static gconstpointer +_get_fcn_dcb_bool(ARGS_GET_FCN) { NMSettingDcb *s_dcb = NM_SETTING_DCB(setting); - GString * str; + GString *str; guint i; RETURN_UNSUPPORTED_GET_TYPE(); @@ -3076,7 +3118,8 @@ static gconstpointer _get_fcn_dcb_bool(ARGS_GET_FCN) RETURN_STR_TO_FREE(g_string_free(str, FALSE)); } -static gboolean _set_fcn_dcb_bool(ARGS_SET_FCN) +static gboolean +_set_fcn_dcb_bool(ARGS_SET_FCN) { guint i = 0; guint nums[8] = { @@ -3105,7 +3148,8 @@ static gboolean _set_fcn_dcb_bool(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_gsm_auto_config(ARGS_SET_FCN) +static gboolean +_set_fcn_gsm_auto_config(ARGS_SET_FCN) { if (!_set_fcn_gobject_bool_impl(property_info, setting, modifier, value, error)) return FALSE; @@ -3127,7 +3171,8 @@ static gboolean _set_fcn_gsm_auto_config(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_gsm_sim_operator_id(ARGS_SET_FCN) +static gboolean +_set_fcn_gsm_sim_operator_id(ARGS_SET_FCN) { const char *p = value; @@ -3152,7 +3197,8 @@ static gboolean _set_fcn_gsm_sim_operator_id(ARGS_SET_FCN) return TRUE; } -static gboolean _set_fcn_infiniband_p_key(ARGS_SET_FCN) +static gboolean +_set_fcn_infiniband_p_key(ARGS_SET_FCN) { gint64 p_key; @@ -3173,7 +3219,8 @@ static gboolean _set_fcn_infiniband_p_key(ARGS_SET_FCN) return TRUE; } -static gconstpointer _get_fcn_infiniband_p_key(ARGS_GET_FCN) +static gconstpointer +_get_fcn_infiniband_p_key(ARGS_GET_FCN) { NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND(setting); int p_key; @@ -3192,7 +3239,8 @@ static gconstpointer _get_fcn_infiniband_p_key(ARGS_GET_FCN) RETURN_STR_TO_FREE(g_strdup_printf("0x%04x", p_key)); } -static gconstpointer _get_fcn_objlist(ARGS_GET_FCN) +static gconstpointer +_get_fcn_objlist(ARGS_GET_FCN) { GString *str = NULL; guint num; @@ -3247,9 +3295,9 @@ static gconstpointer _get_fcn_objlist(ARGS_GET_FCN) static void _objlist_obj_to_str_fcn_ip_config_addresses(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str) + GString *str) { NMIPAddress *obj; @@ -3262,14 +3310,14 @@ _objlist_obj_to_str_fcn_ip_config_addresses(NMMetaAccessorGetType get_type, static void _objlist_obj_to_str_fcn_ip_config_routes(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str) + GString *str) { - NMIPRoute * route; - gs_free char * attr_str = NULL; - gs_strfreev char **attr_names = NULL; - gs_unref_hashtable GHashTable *hash = g_hash_table_new(nm_str_hash, g_str_equal); + NMIPRoute *route; + gs_free char *attr_str = NULL; + gs_strfreev char **attr_names = NULL; + gs_unref_hashtable GHashTable *hash = g_hash_table_new(nm_str_hash, g_str_equal); int j; route = nm_setting_ip_config_get_route(NM_SETTING_IP_CONFIG(setting), idx); @@ -3314,7 +3362,8 @@ _objlist_obj_to_str_fcn_ip_config_routes(NMMetaAccessorGetType get_type, } } -static gboolean _set_fcn_ip_config_method(ARGS_SET_FCN) +static gboolean +_set_fcn_ip_config_method(ARGS_SET_FCN) { if (_SET_FCN_DO_RESET_DEFAULT(property_info, modifier, value)) return _gobject_property_reset_default(setting, property_info->property_name); @@ -3367,7 +3416,8 @@ _multilist_add_fcn_ip_config_dns_options(NMSetting *setting, const char *item) return TRUE; } -static gboolean _set_fcn_objlist(ARGS_SET_FCN) +static gboolean +_set_fcn_objlist(ARGS_SET_FCN) { gs_free const char **strv = NULL; gsize i, nstrv; @@ -3439,10 +3489,10 @@ static gboolean _set_fcn_objlist(ARGS_SET_FCN) } static gboolean -_objlist_set_fcn_ip_config_addresses(NMSetting * setting, +_objlist_set_fcn_ip_config_addresses(NMSetting *setting, gboolean do_add, const char *value, - GError ** error) + GError **error) { int addr_family = nm_setting_ip_config_get_addr_family(NM_SETTING_IP_CONFIG(setting)); nm_auto_unref_ip_address NMIPAddress *addr = NULL; @@ -3457,7 +3507,8 @@ _objlist_set_fcn_ip_config_addresses(NMSetting * setting, return TRUE; } -static gboolean _set_fcn_ip_config_gateway(ARGS_SET_FCN) +static gboolean +_set_fcn_ip_config_gateway(ARGS_SET_FCN) { gs_free char *value_to_free = NULL; int addr_family = nm_setting_ip_config_get_addr_family(NM_SETTING_IP_CONFIG(setting)); @@ -3489,10 +3540,10 @@ static gboolean _set_fcn_ip_config_gateway(ARGS_SET_FCN) } static gboolean -_objlist_set_fcn_ip_config_routes(NMSetting * setting, +_objlist_set_fcn_ip_config_routes(NMSetting *setting, gboolean do_add, const char *value, - GError ** error) + GError **error) { int addr_family = nm_setting_ip_config_get_addr_family(NM_SETTING_IP_CONFIG(setting)); nm_auto_unref_ip_route NMIPRoute *route = NULL; @@ -3515,12 +3566,12 @@ _is_default_func_ip_config_dns_options(NMSetting *setting) static void _objlist_obj_to_str_fcn_ip_config_routing_rules(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str) + GString *str) { NMIPRoutingRule *rule; - gs_free char * s = NULL; + gs_free char *s = NULL; rule = nm_setting_ip_config_get_routing_rule(NM_SETTING_IP_CONFIG(setting), idx); s = nm_ip_routing_rule_to_string(rule, NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE, NULL, NULL); @@ -3529,12 +3580,12 @@ _objlist_obj_to_str_fcn_ip_config_routing_rules(NMMetaAccessorGetType get_type, } static gboolean -_objlist_set_fcn_ip_config_routing_rules(NMSetting * setting, +_objlist_set_fcn_ip_config_routing_rules(NMSetting *setting, gboolean do_add, const char *str, - GError ** error) + GError **error) { - NMSettingIPConfig * s_ip = NM_SETTING_IP_CONFIG(setting); + NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; guint i, n; @@ -3581,7 +3632,7 @@ _multilist_get_num_fcn_ip_config_dhcp_reject_servers(NMSettingIPConfig *setting) static gboolean _multilist_remove_by_value_fcn_ip_config_dhcp_reject_servers(NMSettingIPConfig *setting, - const char * item) + const char *item) { const char *const *strv; guint num; @@ -3594,11 +3645,12 @@ _multilist_remove_by_value_fcn_ip_config_dhcp_reject_servers(NMSettingIPConfig * return TRUE; } -static gconstpointer _get_fcn_olpc_mesh_ssid(ARGS_GET_FCN) +static gconstpointer +_get_fcn_olpc_mesh_ssid(ARGS_GET_FCN) { NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH(setting); - GBytes * ssid; - char * ssid_str = NULL; + GBytes *ssid; + char *ssid_str = NULL; RETURN_UNSUPPORTED_GET_TYPE(); @@ -3611,7 +3663,8 @@ static gconstpointer _get_fcn_olpc_mesh_ssid(ARGS_GET_FCN) RETURN_STR_TO_FREE(ssid_str); } -static gboolean _set_fcn_olpc_mesh_channel(ARGS_SET_FCN) +static gboolean +_set_fcn_olpc_mesh_channel(ARGS_SET_FCN) { unsigned long chan_int; @@ -3638,12 +3691,12 @@ _validate_fcn_proxy_pac_script(const char *value, char **out_to_free, GError **e static void _objlist_obj_to_str_fcn_sriov_vfs(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str) + GString *str) { gs_free char *s = NULL; - NMSriovVF * vf; + NMSriovVF *vf; vf = nm_setting_sriov_get_vf(NM_SETTING_SRIOV(setting), idx); s = nm_utils_sriov_vf_to_str(vf, FALSE, NULL); @@ -3653,12 +3706,12 @@ _objlist_obj_to_str_fcn_sriov_vfs(NMMetaAccessorGetType get_type, static void _objlist_obj_to_str_fcn_tc_config_qdiscs(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str) + GString *str) { gs_free char *s = NULL; - NMTCQdisc * qdisc; + NMTCQdisc *qdisc; qdisc = nm_setting_tc_config_get_qdisc(NM_SETTING_TC_CONFIG(setting), idx); s = nm_utils_tc_qdisc_to_str(qdisc, NULL); @@ -3668,9 +3721,9 @@ _objlist_obj_to_str_fcn_tc_config_qdiscs(NMMetaAccessorGetType get_type, static void _objlist_obj_to_str_fcn_bridge_vlans(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str) + GString *str) { gs_free char *s = NULL; NMBridgeVlan *vlan; @@ -3688,8 +3741,8 @@ _objlist_obj_to_str_fcn_bridge_vlans(NMMetaAccessorGetType get_type, static gboolean _objlist_set_fcn_sriov_vfs(NMSetting *setting, gboolean do_add, const char *value, GError **error) { - nm_auto_unref_sriov_vf NMSriovVF *vf = NULL; - gs_free_error GError *local = NULL; + nm_auto_unref_sriov_vf NMSriovVF *vf = NULL; + gs_free_error GError *local = NULL; vf = nm_utils_sriov_vf_from_str(value, &local); if (!vf) { @@ -3709,13 +3762,13 @@ _objlist_set_fcn_sriov_vfs(NMSetting *setting, gboolean do_add, const char *valu } static gboolean -_objlist_set_fcn_tc_config_qdiscs(NMSetting * setting, +_objlist_set_fcn_tc_config_qdiscs(NMSetting *setting, gboolean do_add, const char *value, - GError ** error) + GError **error) { nm_auto_unref_tc_qdisc NMTCQdisc *tc_qdisc = NULL; - gs_free_error GError *local = NULL; + gs_free_error GError *local = NULL; tc_qdisc = nm_utils_tc_qdisc_from_str(value, &local); if (!tc_qdisc) { @@ -3735,14 +3788,14 @@ _objlist_set_fcn_tc_config_qdiscs(NMSetting * setting, } static gboolean -_objlist_set_fcn_bridge_vlans(NMSetting * setting, +_objlist_set_fcn_bridge_vlans(NMSetting *setting, gboolean do_add, const char *value, - GError ** error) + GError **error) { - nm_auto_unref_bridge_vlan NMBridgeVlan *vlan = NULL; - gs_free_error GError *local = NULL; - guint16 vid_start, vid_end; + nm_auto_unref_bridge_vlan NMBridgeVlan *vlan = NULL; + gs_free_error GError *local = NULL; + guint16 vid_start, vid_end; vlan = nm_bridge_vlan_from_str(value, &local); if (!vlan) { @@ -3777,11 +3830,11 @@ _objlist_set_fcn_bridge_vlans(NMSetting * setting, static void _objlist_obj_to_str_fcn_tc_config_tfilters(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str) + GString *str) { - NMTCTfilter * tfilter; + NMTCTfilter *tfilter; gs_free char *s = NULL; tfilter = nm_setting_tc_config_get_tfilter(NM_SETTING_TC_CONFIG(setting), idx); @@ -3791,12 +3844,12 @@ _objlist_obj_to_str_fcn_tc_config_tfilters(NMMetaAccessorGetType get_type, } static gboolean -_objlist_set_fcn_tc_config_tfilters(NMSetting * setting, +_objlist_set_fcn_tc_config_tfilters(NMSetting *setting, gboolean do_add, const char *value, - GError ** error) + GError **error) { - gs_free_error GError * local = NULL; + gs_free_error GError *local = NULL; nm_auto_unref_tc_tfilter NMTCTfilter *tc_tfilter = NULL; tc_tfilter = nm_utils_tc_tfilter_from_str(value, &local); @@ -3828,12 +3881,12 @@ _validate_fcn_team_config(const char *value, char **out_to_free, GError **error) static void _objlist_obj_to_str_fcn_team_link_watchers(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str) + GString *str) { NMTeamLinkWatcher *watcher; - gs_free char * s = NULL; + gs_free char *s = NULL; if (NM_IS_SETTING_TEAM(setting)) watcher = nm_setting_team_get_link_watcher(NM_SETTING_TEAM(setting), idx); @@ -3846,10 +3899,10 @@ _objlist_obj_to_str_fcn_team_link_watchers(NMMetaAccessorGetType get_type, } static gboolean -_objlist_set_fcn_team_link_watchers(NMSetting * setting, +_objlist_set_fcn_team_link_watchers(NMSetting *setting, gboolean do_add, const char *value, - GError ** error) + GError **error) { nm_auto_unref_team_link_watcher NMTeamLinkWatcher *watcher = NULL; @@ -3871,7 +3924,8 @@ _objlist_set_fcn_team_link_watchers(NMSetting * setting, return TRUE; } -static gconstpointer _get_fcn_vlan_flags(ARGS_GET_FCN) +static gconstpointer +_get_fcn_vlan_flags(ARGS_GET_FCN) { NMSettingVlan *s_vlan = NM_SETTING_VLAN(setting); guint32 flags; @@ -3898,11 +3952,12 @@ _vlan_priority_map_type_from_property_info(const NMMetaPropertyInfo *property_in : NM_VLAN_EGRESS_MAP; } -static gconstpointer _get_fcn_vlan_xgress_priority_map(ARGS_GET_FCN) +static gconstpointer +_get_fcn_vlan_xgress_priority_map(ARGS_GET_FCN) { NMVlanPriorityMap map_type = _vlan_priority_map_type_from_property_info(property_info); - NMSettingVlan * s_vlan = NM_SETTING_VLAN(setting); - GString * str = NULL; + NMSettingVlan *s_vlan = NM_SETTING_VLAN(setting); + GString *str = NULL; gint32 i, num; RETURN_UNSUPPORTED_GET_TYPE(); @@ -3927,7 +3982,8 @@ static gconstpointer _get_fcn_vlan_xgress_priority_map(ARGS_GET_FCN) RETURN_STR_TO_FREE(g_string_free(str, FALSE)); } -static gboolean _set_fcn_vlan_xgress_priority_map(ARGS_SET_FCN) +static gboolean +_set_fcn_vlan_xgress_priority_map(ARGS_SET_FCN) { NMVlanPriorityMap map_type = _vlan_priority_map_type_from_property_info(property_info); gs_free const char **prio_map = NULL; @@ -3970,7 +4026,7 @@ static gboolean _set_fcn_vlan_xgress_priority_map(ARGS_SET_FCN) static void _vpn_options_callback(const char *key, const char *val, gpointer user_data) { - GString * str = user_data; + GString *str = user_data; gs_free char *escaped_key = NULL; gs_free char *escaped_val = NULL; @@ -3982,10 +4038,11 @@ _vpn_options_callback(const char *key, const char *val, gpointer user_data) g_string_append(str, nm_utils_escaped_tokens_options_escape_val(val, &escaped_val)); } -static gconstpointer _get_fcn_vpn_options(ARGS_GET_FCN) +static gconstpointer +_get_fcn_vpn_options(ARGS_GET_FCN) { NMSettingVpn *s_vpn = NM_SETTING_VPN(setting); - GString * str; + GString *str; RETURN_UNSUPPORTED_GET_TYPE(); @@ -3999,10 +4056,10 @@ static gconstpointer _get_fcn_vpn_options(ARGS_GET_FCN) } static gboolean -_optionlist_set_fcn_vpn_data(NMSetting * setting, +_optionlist_set_fcn_vpn_data(NMSetting *setting, const char *option, const char *value, - GError ** error) + GError **error) { if (value) nm_setting_vpn_add_data_item(NM_SETTING_VPN(setting), option, value); @@ -4012,10 +4069,10 @@ _optionlist_set_fcn_vpn_data(NMSetting * setting, } static gboolean -_optionlist_set_fcn_vpn_secrets(NMSetting * setting, +_optionlist_set_fcn_vpn_secrets(NMSetting *setting, const char *option, const char *value, - GError ** error) + GError **error) { if (value) nm_setting_vpn_add_secret(NM_SETTING_VPN(setting), option, value); @@ -4024,7 +4081,8 @@ _optionlist_set_fcn_vpn_secrets(NMSetting * setting, return TRUE; } -static gboolean _set_fcn_wired_s390_subchannels(ARGS_SET_FCN) +static gboolean +_set_fcn_wired_s390_subchannels(ARGS_SET_FCN) { gs_free const char **strv = NULL; gsize len; @@ -4044,10 +4102,10 @@ static gboolean _set_fcn_wired_s390_subchannels(ARGS_SET_FCN) } static gboolean -_optionlist_set_fcn_wired_s390_options(NMSetting * setting, +_optionlist_set_fcn_wired_s390_options(NMSetting *setting, const char *name, const char *value, - GError ** error) + GError **error) { if (value) nm_setting_wired_add_s390_option(NM_SETTING_WIRED(setting), name, value); @@ -4056,16 +4114,18 @@ _optionlist_set_fcn_wired_s390_options(NMSetting * setting, return TRUE; } -static const char *const *_values_fcn_wired_s390_options(ARGS_VALUES_FCN) +static const char *const * +_values_fcn_wired_s390_options(ARGS_VALUES_FCN) { return nm_setting_wired_get_valid_s390_options(NULL); } -static const char *_describe_fcn_wired_s390_options(ARGS_DESCRIBE_FCN) +static const char * +_describe_fcn_wired_s390_options(ARGS_DESCRIBE_FCN) { gs_free char *options_str = NULL; - const char ** valid_options; - char * s; + const char **valid_options; + char *s; valid_options = nm_setting_wired_get_valid_s390_options(NULL); @@ -4078,11 +4138,12 @@ static const char *_describe_fcn_wired_s390_options(ARGS_DESCRIBE_FCN) return (*out_to_free = s); } -static gconstpointer _get_fcn_wireless_ssid(ARGS_GET_FCN) +static gconstpointer +_get_fcn_wireless_ssid(ARGS_GET_FCN) { NMSettingWireless *s_wireless = NM_SETTING_WIRELESS(setting); - GBytes * ssid; - char * ssid_str = NULL; + GBytes *ssid; + char *ssid_str = NULL; RETURN_UNSUPPORTED_GET_TYPE(); @@ -4095,7 +4156,8 @@ static gconstpointer _get_fcn_wireless_ssid(ARGS_GET_FCN) RETURN_STR_TO_FREE(ssid_str); } -static gboolean _set_fcn_wireless_channel(ARGS_SET_FCN) +static gboolean +_set_fcn_wireless_channel(ARGS_SET_FCN) { unsigned long chan_int; @@ -4133,10 +4195,11 @@ _multilist_validate2_fcn_mac_addr(NMSetting *setting, const char *item, GError * return item; } -static gconstpointer _get_fcn_wireless_security_wep_key(ARGS_GET_FCN) +static gconstpointer +_get_fcn_wireless_security_wep_key(ARGS_GET_FCN) { NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY(setting); - char * key; + char *key; guint index; RETURN_UNSUPPORTED_GET_TYPE(); @@ -4152,7 +4215,8 @@ static gconstpointer _get_fcn_wireless_security_wep_key(ARGS_GET_FCN) RETURN_STR_TO_FREE(key); } -static gboolean _set_fcn_wireless_wep_key(ARGS_SET_FCN) +static gboolean +_set_fcn_wireless_wep_key(ARGS_SET_FCN) { NMWepKeyType guessed_type = NM_WEP_KEY_TYPE_UNKNOWN; NMWepKeyType type; @@ -4221,9 +4285,9 @@ static gboolean _set_fcn_wireless_wep_key(ARGS_SET_FCN) static void _gobject_enum_pre_set_notify_fcn_wireless_security_wep_key_type( const NMMetaPropertyInfo *property_info, - const NMMetaEnvironment * environment, + const NMMetaEnvironment *environment, gpointer environment_user_data, - NMSetting * setting, + NMSetting *setting, int value) { guint i; @@ -4255,7 +4319,8 @@ _gobject_enum_pre_set_notify_fcn_wireless_security_wep_key_type( /*****************************************************************************/ -static gconstpointer _get_fcn_ethtool(ARGS_GET_FCN) +static gconstpointer +_get_fcn_ethtool(ARGS_GET_FCN) { NMEthtoolID ethtool_id = property_info->property_typ_data->subtype.ethtool.ethtool_id; const char *s; @@ -4286,7 +4351,8 @@ static gconstpointer _get_fcn_ethtool(ARGS_GET_FCN) return s; } -static gboolean _set_fcn_ethtool(ARGS_SET_FCN) +static gboolean +_set_fcn_ethtool(ARGS_SET_FCN) { NMEthtoolID ethtool_id = property_info->property_typ_data->subtype.ethtool.ethtool_id; gint64 i64; @@ -4336,7 +4402,8 @@ do_unset: return TRUE; } -static const char *const *_complete_fcn_ethtool(ARGS_COMPLETE_FCN) +static const char *const * +_complete_fcn_ethtool(ARGS_COMPLETE_FCN) { static const char *const v[] = { "true", @@ -8596,16 +8663,16 @@ _meta_type_property_info_get_name(const NMMetaAbstractInfo *abstract_info, gbool } static gconstpointer -_meta_type_setting_info_editor_get_fcn(const NMMetaAbstractInfo * abstract_info, - const NMMetaEnvironment * environment, +_meta_type_setting_info_editor_get_fcn(const NMMetaAbstractInfo *abstract_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, gpointer target, gpointer target_data, NMMetaAccessorGetType get_type, NMMetaAccessorGetFlags get_flags, NMMetaAccessorGetOutFlags *out_flags, - gboolean * out_is_default, - gpointer * out_to_free) + gboolean *out_is_default, + gpointer *out_to_free) { const NMMetaSettingInfoEditor *info = (const NMMetaSettingInfoEditor *) abstract_info; @@ -8622,16 +8689,16 @@ _meta_type_setting_info_editor_get_fcn(const NMMetaAbstractInfo * abstract_info, } static gconstpointer -_meta_type_property_info_get_fcn(const NMMetaAbstractInfo * abstract_info, - const NMMetaEnvironment * environment, +_meta_type_property_info_get_fcn(const NMMetaAbstractInfo *abstract_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, gpointer target, gpointer target_data, NMMetaAccessorGetType get_type, NMMetaAccessorGetFlags get_flags, NMMetaAccessorGetOutFlags *out_flags, - gboolean * out_is_default, - gpointer * out_to_free) + gboolean *out_is_default, + gpointer *out_to_free) { const NMMetaPropertyInfo *info = (const NMMetaPropertyInfo *) abstract_info; gboolean is_default_local = FALSE; @@ -8671,8 +8738,8 @@ _meta_type_property_info_get_fcn(const NMMetaAbstractInfo * abstract_info, static const NMMetaAbstractInfo *const * _meta_type_setting_info_editor_get_nested(const NMMetaAbstractInfo *abstract_info, - guint * out_len, - gpointer * out_to_free) + guint *out_len, + gpointer *out_to_free) { const NMMetaSettingInfoEditor *info; @@ -8684,21 +8751,21 @@ _meta_type_setting_info_editor_get_nested(const NMMetaAbstractInfo *abstract_inf static const NMMetaAbstractInfo *const * _meta_type_property_info_get_nested(const NMMetaAbstractInfo *abstract_info, - guint * out_len, - gpointer * out_to_free) + guint *out_len, + gpointer *out_to_free) { NM_SET_OUT(out_len, 0); return NULL; } static const char *const * -_meta_type_property_info_complete_fcn(const NMMetaAbstractInfo * abstract_info, - const NMMetaEnvironment * environment, +_meta_type_property_info_complete_fcn(const NMMetaAbstractInfo *abstract_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, const NMMetaOperationContext *operation_context, - const char * text, - gboolean * out_complete_filename, - char *** out_to_free) + const char *text, + gboolean *out_complete_filename, + char ***out_to_free) { const NMMetaPropertyInfo *info = (const NMMetaPropertyInfo *) abstract_info; diff --git a/src/libnmc-setting/nm-meta-setting-desc.h b/src/libnmc-setting/nm-meta-setting-desc.h index 29416dcbf8..9190525304 100644 --- a/src/libnmc-setting/nm-meta-setting-desc.h +++ b/src/libnmc-setting/nm-meta-setting-desc.h @@ -203,32 +203,32 @@ struct _NMMetaPropertyType { /* should return a translated string */ const char *(*describe_fcn)(const NMMetaPropertyInfo *property_info, char **out_to_free); - gconstpointer (*get_fcn)(const NMMetaPropertyInfo * property_info, - const NMMetaEnvironment * environment, + gconstpointer (*get_fcn)(const NMMetaPropertyInfo *property_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, - NMSetting * setting, + NMSetting *setting, NMMetaAccessorGetType get_type, NMMetaAccessorGetFlags get_flags, NMMetaAccessorGetOutFlags *out_flags, - gboolean * out_is_default, - gpointer * out_to_free); + gboolean *out_is_default, + gpointer *out_to_free); gboolean (*set_fcn)(const NMMetaPropertyInfo *property_info, - const NMMetaEnvironment * environment, + const NMMetaEnvironment *environment, gpointer environment_user_data, - NMSetting * setting, + NMSetting *setting, NMMetaAccessorModifier modifier, - const char * value, - GError ** error); + const char *value, + GError **error); const char *const *(*values_fcn)(const NMMetaPropertyInfo *property_info, char ***out_to_free); - const char *const *(*complete_fcn)(const NMMetaPropertyInfo * property_info, - const NMMetaEnvironment * environment, + const char *const *(*complete_fcn)(const NMMetaPropertyInfo *property_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, const NMMetaOperationContext *operation_context, - const char * text, - gboolean * out_complete_filename, - char *** out_to_free); + const char *text, + gboolean *out_complete_filename, + char ***out_to_free); /* Whether set_fcn() supports the '-' modifier. That is, whether the property * is a list type. */ @@ -243,7 +243,7 @@ typedef union { } NMMetaSignUnsignInt64; typedef struct { - const char * nick; + const char *nick; NMMetaSignUnsignInt64 value; } NMMetaUtilsIntValueInfo; @@ -256,9 +256,9 @@ struct _NMMetaPropertyTypData { const struct _NMUtilsEnumValueInfo *value_infos_get; /* nicks for get function */ const struct _NMUtilsEnumValueInfo *value_infos; /* nicks for set function */ void (*pre_set_notify)(const NMMetaPropertyInfo *property_info, - const NMMetaEnvironment * environment, + const NMMetaEnvironment *environment, gpointer environment_user_data, - NMSetting * setting, + NMSetting *setting, int value); } gobject_enum; struct { @@ -299,13 +299,13 @@ struct _NMMetaPropertyTypData { struct { guint (*get_num_fcn)(NMSetting *setting); void (*obj_to_str_fcn)(NMMetaAccessorGetType get_type, - NMSetting * setting, + NMSetting *setting, guint idx, - GString * str); - gboolean (*set_fcn)(NMSetting * setting, + GString *str); + gboolean (*set_fcn)(NMSetting *setting, gboolean do_add /* or else remove. */, const char *value, - GError ** error); + GError **error); void (*clear_all_fcn)(NMSetting *setting); void (*remove_by_idx_fcn_u)(NMSetting *setting, guint idx); void (*remove_by_idx_fcn_s)(NMSetting *setting, int idx); @@ -313,10 +313,10 @@ struct _NMMetaPropertyTypData { bool strsplit_plain : 1; } objlist; struct { - gboolean (*set_fcn)(NMSetting * setting, + gboolean (*set_fcn)(NMSetting *setting, const char *option, const char *value, - GError ** error); + GError **error); bool no_empty_value : 1; } optionlist; struct { @@ -345,7 +345,7 @@ struct _NMMetaPropertyTypData { } ethtool; } subtype; gboolean (*is_default_fcn)(NMSetting *setting); - const char *const * values_static; + const char *const *values_static; const NMMetaPropertyTypDataNested *nested; NMMetaPropertyTypFlags typ_flags; }; @@ -396,7 +396,7 @@ struct _NMMetaPropertyInfo { /* a non-translated but translatable static description (marked with N_()). */ const char *describe_message; - const NMMetaPropertyType * property_type; + const NMMetaPropertyType *property_type; const NMMetaPropertyTypData *property_typ_data; }; @@ -410,9 +410,9 @@ struct _NMMetaSettingInfoEditor { NMObjBaseInst parent; const NMMetaType *meta_type; }; - const NMMetaSettingInfo * general; - const char * alias; - const char * pretty_name; + const NMMetaSettingInfo *general; + const char *alias; + const char *pretty_name; const NMMetaPropertyInfo *const *properties; guint properties_num; @@ -429,34 +429,34 @@ struct _NMMetaSettingInfoEditor { const NMMetaSettingValidPartItem *const *valid_parts; void (*setting_init_fcn)(const NMMetaSettingInfoEditor *setting_info, - NMSetting * setting, + NMSetting *setting, NMMetaAccessorSettingInitType init_type); }; struct _NMMetaType { NMObjBaseClass parent; - const char * type_name; + const char *type_name; const char *(*get_name)(const NMMetaAbstractInfo *abstract_info, gboolean for_header); const NMMetaAbstractInfo *const *(*get_nested)(const NMMetaAbstractInfo *abstract_info, - guint * out_len, - gpointer * out_to_free); - gconstpointer (*get_fcn)(const NMMetaAbstractInfo * info, - const NMMetaEnvironment * environment, + guint *out_len, + gpointer *out_to_free); + gconstpointer (*get_fcn)(const NMMetaAbstractInfo *info, + const NMMetaEnvironment *environment, gpointer environment_user_data, gpointer target, gpointer target_data, NMMetaAccessorGetType get_type, NMMetaAccessorGetFlags get_flags, NMMetaAccessorGetOutFlags *out_flags, - gboolean * out_is_default, - gpointer * out_to_free); - const char *const *(*complete_fcn)(const NMMetaAbstractInfo * info, - const NMMetaEnvironment * environment, + gboolean *out_is_default, + gpointer *out_to_free); + const char *const *(*complete_fcn)(const NMMetaAbstractInfo *info, + const NMMetaEnvironment *environment, gpointer environment_user_data, const NMMetaOperationContext *operation_context, - const char * text, - gboolean * out_complete_filename, - char *** out_to_free); + const char *text, + gboolean *out_complete_filename, + char ***out_to_free); }; struct _NMMetaAbstractInfo { @@ -474,7 +474,7 @@ extern const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[_NM_META_SETTI extern const NMMetaSettingValidPartItem *const nm_meta_setting_info_valid_parts_default[]; const NMMetaSettingValidPartItem *const * -nm_meta_setting_info_valid_parts_for_slave_type(const char * slave_type, +nm_meta_setting_info_valid_parts_for_slave_type(const char *slave_type, const char **out_slave_name); /*****************************************************************************/ @@ -499,11 +499,11 @@ struct _NMMetaEnvironment { struct _NMDevice *const *(*get_nm_devices)(const NMMetaEnvironment *environment, gpointer environment_user_data, - guint * out_len); + guint *out_len); struct _NMRemoteConnection *const *(*get_nm_connections)(const NMMetaEnvironment *environment, gpointer environment_user_data, - guint * out_len); + guint *out_len); }; /*****************************************************************************/ @@ -516,7 +516,7 @@ extern const NMMetaType nm_meta_type_nested_property_info; struct _NMMetaNestedPropertyInfo { union { - const NMMetaType * meta_type; + const NMMetaType *meta_type; NMMetaPropertyInfo base; }; const NMMetaPropertyInfo *parent_info; @@ -531,10 +531,10 @@ extern const NMMetaPropertyTypDataNested nm_meta_property_typ_data_bond; /*****************************************************************************/ -gboolean _nm_meta_setting_bond_add_option(NMSetting * setting, +gboolean _nm_meta_setting_bond_add_option(NMSetting *setting, const char *name, const char *value, - GError ** error); + GError **error); /*****************************************************************************/ diff --git a/src/libnmc-setting/tests/test-libnmc-setting.c b/src/libnmc-setting/tests/test-libnmc-setting.c index fe196ad014..12226615ef 100644 --- a/src/libnmc-setting/tests/test-libnmc-setting.c +++ b/src/libnmc-setting/tests/test-libnmc-setting.c @@ -106,7 +106,7 @@ test_client_meta_check(void) g_assert((!!info->valid_parts) == is_base_type); if (info->valid_parts) { - gsize i, l; + gsize i, l; gs_unref_hashtable GHashTable *dup = g_hash_table_new(nm_direct_hash, NULL); l = NM_PTRARRAY_LEN(info->valid_parts); @@ -162,11 +162,11 @@ static void test_client_import_wireguard_test0(void) { gs_unref_object NMConnection *connection; - NMSettingWireGuard * s_wg; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMWireGuardPeer * peer; - gs_free_error GError *error = NULL; + NMSettingWireGuard *s_wg; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMWireGuardPeer *peer; + gs_free_error GError *error = NULL; connection = nm_vpn_wireguard_import(NM_BUILD_SRCDIR "/src/libnmc-setting/tests/wg-test0.conf", &error); @@ -271,48 +271,48 @@ test_client_import_wireguard_missing(void) /*****************************************************************************/ -#define _do_test_parse_passwd_file(contents, success, exp_error_line, ...) \ - G_STMT_START \ - { \ - static const NMUtilsNamedValue _values[] = {__VA_ARGS__}; \ - gs_free char * _contents = g_strndup(contents, NM_STRLEN(contents)); \ - gs_unref_hashtable GHashTable *_secrets = NULL; \ - gs_free_error GError *_local = NULL; \ - gssize _error_line; \ - GError ** _p_local = nmtst_get_rand_bool() ? &_local : NULL; \ - gssize * _p_error_line = nmtst_get_rand_bool() ? &_error_line : NULL; \ - gboolean _success = !!(success); \ - gssize _exp_error_line = (exp_error_line); \ - int _i; \ - \ - g_assert(_success || (G_N_ELEMENTS(_values) == 0)); \ - \ - _secrets = nmc_utils_parse_passwd_file(_contents, _p_error_line, _p_local); \ - \ - g_assert(_success == (!!_secrets)); \ - if (!_success) { \ - if (_p_error_line) \ - g_assert_cmpint(_exp_error_line, ==, *_p_error_line); \ - if (_p_local) \ - g_assert(_local); \ - } else { \ - if (_p_error_line) \ - g_assert_cmpint(-1, ==, *_p_error_line); \ - g_assert(!_local); \ - \ - for (_i = 0; _i < (int) G_N_ELEMENTS(_values); _i++) { \ - const NMUtilsNamedValue *_n = &_values[_i]; \ - const char * _v; \ - \ - _v = g_hash_table_lookup(_secrets, _n->name); \ - if (!_v) \ - g_error("cannot find key \"%s\"", _n->name); \ - g_assert_cmpstr(_v, ==, _n->value_str); \ - } \ - \ - g_assert_cmpint(g_hash_table_size(_secrets), ==, G_N_ELEMENTS(_values)); \ - } \ - } \ +#define _do_test_parse_passwd_file(contents, success, exp_error_line, ...) \ + G_STMT_START \ + { \ + static const NMUtilsNamedValue _values[] = {__VA_ARGS__}; \ + gs_free char *_contents = g_strndup(contents, NM_STRLEN(contents)); \ + gs_unref_hashtable GHashTable *_secrets = NULL; \ + gs_free_error GError *_local = NULL; \ + gssize _error_line; \ + GError **_p_local = nmtst_get_rand_bool() ? &_local : NULL; \ + gssize *_p_error_line = nmtst_get_rand_bool() ? &_error_line : NULL; \ + gboolean _success = !!(success); \ + gssize _exp_error_line = (exp_error_line); \ + int _i; \ + \ + g_assert(_success || (G_N_ELEMENTS(_values) == 0)); \ + \ + _secrets = nmc_utils_parse_passwd_file(_contents, _p_error_line, _p_local); \ + \ + g_assert(_success == (!!_secrets)); \ + if (!_success) { \ + if (_p_error_line) \ + g_assert_cmpint(_exp_error_line, ==, *_p_error_line); \ + if (_p_local) \ + g_assert(_local); \ + } else { \ + if (_p_error_line) \ + g_assert_cmpint(-1, ==, *_p_error_line); \ + g_assert(!_local); \ + \ + for (_i = 0; _i < (int) G_N_ELEMENTS(_values); _i++) { \ + const NMUtilsNamedValue *_n = &_values[_i]; \ + const char *_v; \ + \ + _v = g_hash_table_lookup(_secrets, _n->name); \ + if (!_v) \ + g_error("cannot find key \"%s\"", _n->name); \ + g_assert_cmpstr(_v, ==, _n->value_str); \ + } \ + \ + g_assert_cmpint(g_hash_table_size(_secrets), ==, G_N_ELEMENTS(_values)); \ + } \ + } \ G_STMT_END #define _do_test_parse_passwd_file_bad(contents, exp_error_line) \ diff --git a/src/libnmt-newt/nmt-newt-button-box.c b/src/libnmt-newt/nmt-newt-button-box.c index d86a154cb2..f3c8b27e3b 100644 --- a/src/libnmt-newt/nmt-newt-button-box.c +++ b/src/libnmt-newt/nmt-newt-button-box.c @@ -29,7 +29,7 @@ G_DEFINE_TYPE(NmtNewtButtonBox, nmt_newt_button_box, NMT_TYPE_NEWT_CONTAINER) typedef struct { NmtNewtButtonBoxOrientation orientation; - GPtrArray * start_buttons, *end_buttons; + GPtrArray *start_buttons, *end_buttons; } NmtNewtButtonBoxPrivate; enum { @@ -193,7 +193,7 @@ static newtComponent * nmt_newt_button_box_get_components(NmtNewtWidget *widget) { NmtNewtButtonBoxPrivate *priv = NMT_NEWT_BUTTON_BOX_GET_PRIVATE(widget); - GPtrArray * cos; + GPtrArray *cos; cos = g_ptr_array_new(); add_buttons(priv->start_buttons, cos); @@ -231,7 +231,7 @@ size_request_buttons(NmtNewtButtonBox *bbox, GPtrArray *buttons, int *width, int static void nmt_newt_button_box_size_request(NmtNewtWidget *widget, int *width, int *height) { - NmtNewtButtonBox * bbox = NMT_NEWT_BUTTON_BOX(widget); + NmtNewtButtonBox *bbox = NMT_NEWT_BUTTON_BOX(widget); NmtNewtButtonBoxPrivate *priv = NMT_NEWT_BUTTON_BOX_GET_PRIVATE(widget); *width = *height = 0; @@ -248,7 +248,7 @@ static void nmt_newt_button_box_size_allocate(NmtNewtWidget *widget, int x, int y, int width, int height) { NmtNewtButtonBoxPrivate *priv = NMT_NEWT_BUTTON_BOX_GET_PRIVATE(widget); - NmtNewtWidget * child; + NmtNewtWidget *child; int child_x, child_y, child_width, child_height; int i; @@ -295,10 +295,10 @@ nmt_newt_button_box_size_allocate(NmtNewtWidget *widget, int x, int y, int width } static void -nmt_newt_button_box_set_property(GObject * object, +nmt_newt_button_box_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtNewtButtonBoxPrivate *priv = NMT_NEWT_BUTTON_BOX_GET_PRIVATE(object); @@ -330,8 +330,8 @@ nmt_newt_button_box_get_property(GObject *object, guint prop_id, GValue *value, static void nmt_newt_button_box_class_init(NmtNewtButtonBoxClass *bbox_class) { - GObjectClass * object_class = G_OBJECT_CLASS(bbox_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(bbox_class); + GObjectClass *object_class = G_OBJECT_CLASS(bbox_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(bbox_class); NmtNewtContainerClass *container_class = NMT_NEWT_CONTAINER_CLASS(bbox_class); g_type_class_add_private(bbox_class, sizeof(NmtNewtButtonBoxPrivate)); diff --git a/src/libnmt-newt/nmt-newt-button.c b/src/libnmt-newt/nmt-newt-button.c index 974d05bdf4..b21ae53772 100644 --- a/src/libnmt-newt/nmt-newt-button.c +++ b/src/libnmt-newt/nmt-newt-button.c @@ -108,7 +108,7 @@ nmt_newt_button_build_component(NmtNewtComponent *component, gboolean sensitive) { NmtNewtButtonPrivate *priv = NMT_NEWT_BUTTON_GET_PRIVATE(component); newtComponent co; - gs_free char * label_lc = NULL; + gs_free char *label_lc = NULL; if (sensitive) { label_lc = nmt_newt_locale_from_utf8(priv->label); @@ -183,9 +183,9 @@ nmt_newt_button_get_property(GObject *object, guint prop_id, GValue *value, GPar static void nmt_newt_button_class_init(NmtNewtButtonClass *button_class) { - GObjectClass * object_class = G_OBJECT_CLASS(button_class); + GObjectClass *object_class = G_OBJECT_CLASS(button_class); NmtNewtComponentClass *component_class = NMT_NEWT_COMPONENT_CLASS(button_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(button_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(button_class); g_type_class_add_private(button_class, sizeof(NmtNewtButtonPrivate)); diff --git a/src/libnmt-newt/nmt-newt-checkbox.c b/src/libnmt-newt/nmt-newt-checkbox.c index cf825e08d9..26e7ebf043 100644 --- a/src/libnmt-newt/nmt-newt-checkbox.c +++ b/src/libnmt-newt/nmt-newt-checkbox.c @@ -21,7 +21,7 @@ G_DEFINE_TYPE(NmtNewtCheckbox, nmt_newt_checkbox, NMT_TYPE_NEWT_COMPONENT) (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_NEWT_CHECKBOX, NmtNewtCheckboxPrivate)) typedef struct { - char * label_lc; + char *label_lc; gboolean active; } NmtNewtCheckboxPrivate; @@ -139,12 +139,12 @@ nmt_newt_checkbox_build_component(NmtNewtComponent *component, gboolean sensitiv } static void -nmt_newt_checkbox_set_property(GObject * object, +nmt_newt_checkbox_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { - NmtNewtCheckbox * checkbox = NMT_NEWT_CHECKBOX(object); + NmtNewtCheckbox *checkbox = NMT_NEWT_CHECKBOX(object); NmtNewtCheckboxPrivate *priv = NMT_NEWT_CHECKBOX_GET_PRIVATE(object); switch (prop_id) { @@ -182,7 +182,7 @@ nmt_newt_checkbox_get_property(GObject *object, guint prop_id, GValue *value, GP static void nmt_newt_checkbox_class_init(NmtNewtCheckboxClass *checkbox_class) { - GObjectClass * object_class = G_OBJECT_CLASS(checkbox_class); + GObjectClass *object_class = G_OBJECT_CLASS(checkbox_class); NmtNewtComponentClass *component_class = NMT_NEWT_COMPONENT_CLASS(checkbox_class); g_type_class_add_private(checkbox_class, sizeof(NmtNewtCheckboxPrivate)); diff --git a/src/libnmt-newt/nmt-newt-component.c b/src/libnmt-newt/nmt-newt-component.c index 8d7a9005c9..d3cb12c60f 100644 --- a/src/libnmt-newt/nmt-newt-component.c +++ b/src/libnmt-newt/nmt-newt-component.c @@ -89,7 +89,7 @@ static newtComponent * nmt_newt_component_get_components(NmtNewtWidget *widget) { NmtNewtComponentPrivate *priv = NMT_NEWT_COMPONENT_GET_PRIVATE(widget); - newtComponent * cos; + newtComponent *cos; priv->own_component = FALSE; cos = g_new0(newtComponent, 2); @@ -209,10 +209,10 @@ nmt_newt_component_set_sensitive(NmtNewtComponent *component, gboolean sensitive } static void -nmt_newt_component_set_property(GObject * object, +nmt_newt_component_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtNewtComponent *component = NMT_NEWT_COMPONENT(object); @@ -247,7 +247,7 @@ nmt_newt_component_get_property(GObject *object, guint prop_id, GValue *value, G static void nmt_newt_component_class_init(NmtNewtComponentClass *component_class) { - GObjectClass * object_class = G_OBJECT_CLASS(component_class); + GObjectClass *object_class = G_OBJECT_CLASS(component_class); NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(component_class); g_type_class_add_private(component_class, sizeof(NmtNewtComponentPrivate)); diff --git a/src/libnmt-newt/nmt-newt-container.c b/src/libnmt-newt/nmt-newt-container.c index 4cc8db242a..65e0a6449d 100644 --- a/src/libnmt-newt/nmt-newt-container.c +++ b/src/libnmt-newt/nmt-newt-container.c @@ -42,7 +42,7 @@ nmt_newt_container_init(NmtNewtContainer *container) static void nmt_newt_container_finalize(GObject *object) { - NmtNewtContainer * container = NMT_NEWT_CONTAINER(object); + NmtNewtContainer *container = NMT_NEWT_CONTAINER(object); NmtNewtContainerPrivate *priv = NMT_NEWT_CONTAINER_GET_PRIVATE(object); while (priv->children->len) @@ -178,7 +178,7 @@ static NmtNewtWidget * nmt_newt_container_find_component(NmtNewtWidget *widget, newtComponent co) { NmtNewtContainerPrivate *priv = NMT_NEWT_CONTAINER_GET_PRIVATE(widget); - NmtNewtWidget * found, *child; + NmtNewtWidget *found, *child; int i; for (i = 0; i < priv->children->len; i++) { @@ -204,7 +204,7 @@ GSList * nmt_newt_container_get_children(NmtNewtContainer *container) { NmtNewtContainerPrivate *priv = NMT_NEWT_CONTAINER_GET_PRIVATE(container); - GSList * ret; + GSList *ret; int i; for (i = 0, ret = NULL; i < priv->children->len; i++) @@ -215,7 +215,7 @@ nmt_newt_container_get_children(NmtNewtContainer *container) static void nmt_newt_container_class_init(NmtNewtContainerClass *container_class) { - GObjectClass * object_class = G_OBJECT_CLASS(container_class); + GObjectClass *object_class = G_OBJECT_CLASS(container_class); NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(container_class); g_type_class_add_private(container_class, sizeof(NmtNewtContainerPrivate)); diff --git a/src/libnmt-newt/nmt-newt-entry-numeric.c b/src/libnmt-newt/nmt-newt-entry-numeric.c index 7e8edd6cad..829eac1146 100644 --- a/src/libnmt-newt/nmt-newt-entry-numeric.c +++ b/src/libnmt-newt/nmt-newt-entry-numeric.c @@ -84,7 +84,7 @@ nmt_newt_entry_numeric_new_full(int width, gint64 min, gint64 max, gboolean opti static gboolean newt_entry_numeric_filter(NmtNewtEntry *entry, - const char * text, + const char *text, int ch, int position, gpointer user_data) @@ -136,10 +136,10 @@ nmt_newt_entry_numeric_constructed(GObject *object) } static void -nmt_newt_entry_numeric_set_property(GObject * object, +nmt_newt_entry_numeric_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtNewtEntryNumericPrivate *priv = NMT_NEWT_ENTRY_NUMERIC_GET_PRIVATE(object); @@ -160,9 +160,9 @@ nmt_newt_entry_numeric_set_property(GObject * object, } static void -nmt_newt_entry_numeric_get_property(GObject * object, +nmt_newt_entry_numeric_get_property(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec) { NmtNewtEntryNumericPrivate *priv = NMT_NEWT_ENTRY_NUMERIC_GET_PRIVATE(object); diff --git a/src/libnmt-newt/nmt-newt-entry.c b/src/libnmt-newt/nmt-newt-entry.c index 76a96df2f2..3b0a21be80 100644 --- a/src/libnmt-newt/nmt-newt-entry.c +++ b/src/libnmt-newt/nmt-newt-entry.c @@ -28,7 +28,7 @@ G_DEFINE_TYPE(NmtNewtEntry, nmt_newt_entry, NMT_TYPE_NEWT_COMPONENT) typedef struct { int width; NmtNewtEntryFlags flags; - char * text; + char *text; int last_cursor_pos; guint idle_update; @@ -150,7 +150,7 @@ nmt_newt_entry_check_valid(NmtNewtEntry *entry) * will not be considered #NmtNewtWidget:valid. */ void -nmt_newt_entry_set_validator(NmtNewtEntry * entry, +nmt_newt_entry_set_validator(NmtNewtEntry *entry, NmtNewtEntryValidator validator, gpointer user_data) { @@ -296,7 +296,7 @@ idle_update_entry(gpointer entry) { NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry); newtComponent co = nmt_newt_component_get_component(entry); - char * text; + char *text; priv->idle_update = 0; if (!co) @@ -351,7 +351,7 @@ nmt_newt_entry_build_component(NmtNewtComponent *component, gboolean sensitive) { NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(component); newtComponent co; - char * text_lc; + char *text_lc; int flags; flags = convert_flags(priv->flags); @@ -385,7 +385,7 @@ nmt_newt_entry_activated(NmtNewtWidget *widget) static void nmt_newt_entry_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NmtNewtEntry * entry = NMT_NEWT_ENTRY(object); + NmtNewtEntry *entry = NMT_NEWT_ENTRY(object); NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry); switch (prop_id) { @@ -415,7 +415,7 @@ nmt_newt_entry_set_property(GObject *object, guint prop_id, const GValue *value, static void nmt_newt_entry_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NmtNewtEntry * entry = NMT_NEWT_ENTRY(object); + NmtNewtEntry *entry = NMT_NEWT_ENTRY(object); NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry); switch (prop_id) { @@ -440,8 +440,8 @@ nmt_newt_entry_get_property(GObject *object, guint prop_id, GValue *value, GPara static void nmt_newt_entry_class_init(NmtNewtEntryClass *entry_class) { - GObjectClass * object_class = G_OBJECT_CLASS(entry_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(entry_class); + GObjectClass *object_class = G_OBJECT_CLASS(entry_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(entry_class); NmtNewtComponentClass *component_class = NMT_NEWT_COMPONENT_CLASS(entry_class); g_type_class_add_private(entry_class, sizeof(NmtNewtEntryPrivate)); diff --git a/src/libnmt-newt/nmt-newt-entry.h b/src/libnmt-newt/nmt-newt-entry.h index da1a9aeee8..81221812c1 100644 --- a/src/libnmt-newt/nmt-newt-entry.h +++ b/src/libnmt-newt/nmt-newt-entry.h @@ -41,7 +41,7 @@ typedef enum { NmtNewtWidget *nmt_newt_entry_new(int width, NmtNewtEntryFlags flags); void nmt_newt_entry_set_filter(NmtNewtEntry *entry, NmtNewtEntryFilter filter, gpointer user_data); -void nmt_newt_entry_set_validator(NmtNewtEntry * entry, +void nmt_newt_entry_set_validator(NmtNewtEntry *entry, NmtNewtEntryValidator validator, gpointer user_data); diff --git a/src/libnmt-newt/nmt-newt-form.c b/src/libnmt-newt/nmt-newt-form.c index 825f7cfe61..7d28c80e14 100644 --- a/src/libnmt-newt/nmt-newt-form.c +++ b/src/libnmt-newt/nmt-newt-form.c @@ -34,7 +34,7 @@ typedef struct { guint padding; gboolean fixed_x, fixed_y; gboolean fixed_width, fixed_height; - char * title_lc; + char *title_lc; gboolean dirty, escape_exits; NmtNewtWidget *focus; @@ -137,7 +137,7 @@ nmt_newt_form_needs_rebuild(NmtNewtWidget *widget) static void nmt_newt_form_remove(NmtNewtContainer *container, NmtNewtWidget *widget) { - NmtNewtFormPrivate * priv = NMT_NEWT_FORM_GET_PRIVATE(container); + NmtNewtFormPrivate *priv = NMT_NEWT_FORM_GET_PRIVATE(container); NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS(nmt_newt_form_parent_class); g_return_if_fail(widget == priv->content); @@ -156,7 +156,7 @@ nmt_newt_form_remove(NmtNewtContainer *container, NmtNewtWidget *widget) void nmt_newt_form_set_content(NmtNewtForm *form, NmtNewtWidget *content) { - NmtNewtFormPrivate * priv = NMT_NEWT_FORM_GET_PRIVATE(form); + NmtNewtFormPrivate *priv = NMT_NEWT_FORM_GET_PRIVATE(form); NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS(nmt_newt_form_parent_class); if (priv->content) @@ -173,7 +173,7 @@ nmt_newt_form_build(NmtNewtForm *form) { NmtNewtFormPrivate *priv = NMT_NEWT_FORM_GET_PRIVATE(form); int screen_height, screen_width, form_height, form_width; - newtComponent * cos; + newtComponent *cos; int i; priv->dirty = FALSE; @@ -260,8 +260,8 @@ nmt_newt_form_destroy(NmtNewtForm *form) static void nmt_newt_form_iterate(NmtNewtForm *form) { - NmtNewtFormPrivate * priv = NMT_NEWT_FORM_GET_PRIVATE(form); - NmtNewtWidget * focus; + NmtNewtFormPrivate *priv = NMT_NEWT_FORM_GET_PRIVATE(form); + NmtNewtWidget *focus; struct newtExitStruct es; if (priv->dirty) { @@ -301,7 +301,7 @@ nmt_newt_form_iterate(NmtNewtForm *form) * nmt_newt_form_keypress_callback() iterates the top-most form, so it can * process the keypress. */ -static GSList * form_stack; +static GSList *form_stack; static GSource *keypress_source; static gboolean @@ -552,9 +552,9 @@ nmt_newt_form_get_property(GObject *object, guint prop_id, GValue *value, GParam static void nmt_newt_form_class_init(NmtNewtFormClass *form_class) { - GObjectClass * object_class = G_OBJECT_CLASS(form_class); + GObjectClass *object_class = G_OBJECT_CLASS(form_class); NmtNewtContainerClass *container_class = NMT_NEWT_CONTAINER_CLASS(form_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(form_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(form_class); g_type_class_add_private(form_class, sizeof(NmtNewtFormPrivate)); diff --git a/src/libnmt-newt/nmt-newt-grid.c b/src/libnmt-newt/nmt-newt-grid.c index a68a496bce..1078723d9c 100644 --- a/src/libnmt-newt/nmt-newt-grid.c +++ b/src/libnmt-newt/nmt-newt-grid.c @@ -37,16 +37,16 @@ G_DEFINE_TYPE(NmtNewtGrid, nmt_newt_grid, NMT_TYPE_NEWT_CONTAINER) (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_NEWT_GRID, NmtNewtGridPrivate)) typedef struct { - NmtNewtWidget * widget; + NmtNewtWidget *widget; int x, y; NmtNewtGridFlags flags; int req_height, req_width; } NmtNewtGridChild; typedef struct { - GArray * children; + GArray *children; int max_x, max_y; - int * row_heights, *col_widths; + int *row_heights, *col_widths; gboolean *expand_rows, *expand_cols; int n_expand_rows, n_expand_cols; int req_height, req_width; @@ -103,9 +103,9 @@ static newtComponent * nmt_newt_grid_get_components(NmtNewtWidget *widget) { NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(widget); - NmtNewtGridChild * children; - GPtrArray * cos; - newtComponent * child_cos; + NmtNewtGridChild *children; + GPtrArray *cos; + newtComponent *child_cos; int i, c; g_array_sort(priv->children, child_sort_func); @@ -130,9 +130,9 @@ nmt_newt_grid_get_components(NmtNewtWidget *widget) static void nmt_newt_grid_size_request(NmtNewtWidget *widget, int *width, int *height) { - NmtNewtGrid * grid = NMT_NEWT_GRID(widget); + NmtNewtGrid *grid = NMT_NEWT_GRID(widget); NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid); - NmtNewtGridChild * children = (NmtNewtGridChild *) priv->children->data; + NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data; int row, col, i; g_free(priv->row_heights); @@ -190,7 +190,7 @@ static void nmt_newt_grid_size_allocate(NmtNewtWidget *widget, int x, int y, int width, int height) { NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(widget); - NmtNewtGridChild * children = (NmtNewtGridChild *) priv->children->data, *child; + NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data, *child; int i, row, col; int child_x, child_y, child_width, child_height; int extra, extra_all, extra_some; @@ -268,7 +268,7 @@ static void nmt_newt_grid_find_size(NmtNewtGrid *grid) { NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid); - NmtNewtGridChild * children = (NmtNewtGridChild *) priv->children->data; + NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data; int i; priv->max_x = priv->max_y = 0; @@ -315,7 +315,7 @@ static int find_child(NmtNewtGrid *grid, NmtNewtWidget *widget) { NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid); - NmtNewtGridChild * children = (NmtNewtGridChild *) priv->children->data; + NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data; int i; for (i = 0; i < priv->children->len; i++) { @@ -329,7 +329,7 @@ find_child(NmtNewtGrid *grid, NmtNewtWidget *widget) static void nmt_newt_grid_remove(NmtNewtContainer *container, NmtNewtWidget *widget) { - NmtNewtGrid * grid = NMT_NEWT_GRID(container); + NmtNewtGrid *grid = NMT_NEWT_GRID(container); NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid); int i; @@ -355,7 +355,7 @@ void nmt_newt_grid_move(NmtNewtGrid *grid, NmtNewtWidget *widget, int x, int y) { NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid); - NmtNewtGridChild * children = (NmtNewtGridChild *) priv->children->data; + NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data; int i; i = find_child(grid, widget); @@ -411,7 +411,7 @@ void nmt_newt_grid_set_flags(NmtNewtGrid *grid, NmtNewtWidget *widget, NmtNewtGridFlags flags) { NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid); - NmtNewtGridChild * children = (NmtNewtGridChild *) priv->children->data; + NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data; int i; i = find_child(grid, widget); @@ -422,8 +422,8 @@ nmt_newt_grid_set_flags(NmtNewtGrid *grid, NmtNewtWidget *widget, NmtNewtGridFla static void nmt_newt_grid_class_init(NmtNewtGridClass *grid_class) { - GObjectClass * object_class = G_OBJECT_CLASS(grid_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(grid_class); + GObjectClass *object_class = G_OBJECT_CLASS(grid_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(grid_class); NmtNewtContainerClass *container_class = NMT_NEWT_CONTAINER_CLASS(grid_class); g_type_class_add_private(grid_class, sizeof(NmtNewtGridPrivate)); diff --git a/src/libnmt-newt/nmt-newt-hacks.c b/src/libnmt-newt/nmt-newt-hacks.c index 40114a29a7..a4539ed59c 100644 --- a/src/libnmt-newt/nmt-newt-hacks.c +++ b/src/libnmt-newt/nmt-newt-hacks.c @@ -25,10 +25,10 @@ struct newtComponent_0_52_15_struct_hack { struct componentOps *ops; newtCallback callback; - void * callbackData; + void *callbackData; newtCallback destroyCallback; - void * destroyCallbackData; + void *destroyCallbackData; void *data; }; @@ -57,7 +57,7 @@ newtComponentGetPosition(newtComponent component, int *left, int *top) #ifndef HAVE_NEWTENTRYGETCURSORPOSITION struct newtEntry_0_52_15_struct_hack { int flags; - char * buf; + char *buf; const char **resultPtr; int bufAlloced; int bufUsed; @@ -69,7 +69,7 @@ int newtEntryGetCursorPosition(newtComponent component) { struct newtComponent_0_52_15_struct_hack *co_hack = (void *) component; - struct newtEntry_0_52_15_struct_hack * entry_hack = co_hack->data; + struct newtEntry_0_52_15_struct_hack *entry_hack = co_hack->data; return entry_hack->cursorPosition; } @@ -78,7 +78,7 @@ void newtEntrySetCursorPosition(newtComponent component, int position) { struct newtComponent_0_52_15_struct_hack *co_hack = (void *) component; - struct newtEntry_0_52_15_struct_hack * entry_hack = co_hack->data; + struct newtEntry_0_52_15_struct_hack *entry_hack = co_hack->data; entry_hack->cursorPosition = position; } diff --git a/src/libnmt-newt/nmt-newt-label.c b/src/libnmt-newt/nmt-newt-label.c index 32c7809d4d..f823b9b213 100644 --- a/src/libnmt-newt/nmt-newt-label.c +++ b/src/libnmt-newt/nmt-newt-label.c @@ -24,7 +24,7 @@ G_DEFINE_TYPE(NmtNewtLabel, nmt_newt_label, NMT_TYPE_NEWT_COMPONENT) (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_NEWT_LABEL, NmtNewtLabelPrivate)) typedef struct { - char * text; + char *text; NmtNewtLabelStyle style; gboolean highlight; } NmtNewtLabelPrivate; @@ -193,7 +193,7 @@ nmt_newt_label_build_component(NmtNewtComponent *component, gboolean sensitive) { NmtNewtLabelPrivate *priv = NMT_NEWT_LABEL_GET_PRIVATE(component); newtComponent co; - char * text_lc; + char *text_lc; text_lc = nmt_newt_locale_from_utf8(priv->text); co = newtLabel(-1, -1, text_lc); @@ -252,7 +252,7 @@ nmt_newt_label_get_property(GObject *object, guint prop_id, GValue *value, GPara static void nmt_newt_label_class_init(NmtNewtLabelClass *label_class) { - GObjectClass * object_class = G_OBJECT_CLASS(label_class); + GObjectClass *object_class = G_OBJECT_CLASS(label_class); NmtNewtComponentClass *component_class = NMT_NEWT_COMPONENT_CLASS(label_class); g_type_class_add_private(label_class, sizeof(NmtNewtLabelPrivate)); diff --git a/src/libnmt-newt/nmt-newt-listbox.c b/src/libnmt-newt/nmt-newt-listbox.c index cfe23647a1..96e04c15ee 100644 --- a/src/libnmt-newt/nmt-newt-listbox.c +++ b/src/libnmt-newt/nmt-newt-listbox.c @@ -307,7 +307,7 @@ update_active_internal(NmtNewtListbox *listbox, int new_active) static void selection_changed_callback(newtComponent co, void *user_data) { - NmtNewtListbox * listbox = user_data; + NmtNewtListbox *listbox = user_data; NmtNewtListboxPrivate *priv = NMT_NEWT_LISTBOX_GET_PRIVATE(listbox); int new_active; @@ -369,12 +369,12 @@ nmt_newt_listbox_activated(NmtNewtWidget *widget) } static void -nmt_newt_listbox_set_property(GObject * object, +nmt_newt_listbox_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { - NmtNewtListbox * listbox = NMT_NEWT_LISTBOX(object); + NmtNewtListbox *listbox = NMT_NEWT_LISTBOX(object); NmtNewtListboxPrivate *priv = NMT_NEWT_LISTBOX_GET_PRIVATE(object); switch (prop_id) { @@ -430,8 +430,8 @@ nmt_newt_listbox_get_property(GObject *object, guint prop_id, GValue *value, GPa static void nmt_newt_listbox_class_init(NmtNewtListboxClass *listbox_class) { - GObjectClass * object_class = G_OBJECT_CLASS(listbox_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(listbox_class); + GObjectClass *object_class = G_OBJECT_CLASS(listbox_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(listbox_class); NmtNewtComponentClass *component_class = NMT_NEWT_COMPONENT_CLASS(listbox_class); g_type_class_add_private(listbox_class, sizeof(NmtNewtListboxPrivate)); diff --git a/src/libnmt-newt/nmt-newt-popup.c b/src/libnmt-newt/nmt-newt-popup.c index 1822c9d953..c62951ca5d 100644 --- a/src/libnmt-newt/nmt-newt-popup.c +++ b/src/libnmt-newt/nmt-newt-popup.c @@ -59,7 +59,7 @@ enum { NmtNewtWidget * nmt_newt_popup_new(NmtNewtPopupEntry *entries) { - NmtNewtWidget * widget; + NmtNewtWidget *widget; NmtNewtPopupPrivate *priv; int i; @@ -107,7 +107,7 @@ static newtComponent nmt_newt_popup_build_component(NmtNewtComponent *component, gboolean sensitive) { NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE(component); - NmtNewtPopupEntry * entries = (NmtNewtPopupEntry *) priv->entries->data; + NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *) priv->entries->data; nmt_newt_button_set_label(NMT_NEWT_BUTTON(component), entries[priv->active].label); return NMT_NEWT_COMPONENT_CLASS(nmt_newt_popup_parent_class) @@ -118,9 +118,9 @@ static void nmt_newt_popup_activated(NmtNewtWidget *widget) { NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE(widget); - NmtNewtPopupEntry * entries = (NmtNewtPopupEntry *) priv->entries->data; - NmtNewtForm * form; - NmtNewtWidget * listbox, *ret; + NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *) priv->entries->data; + NmtNewtForm *form; + NmtNewtWidget *listbox, *ret; int button_x, button_y; int window_x, window_y; int list_w, list_h; @@ -234,7 +234,7 @@ const char * nmt_newt_popup_get_active_id(NmtNewtPopup *popup) { NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE(popup); - NmtNewtPopupEntry * entries = (NmtNewtPopupEntry *) priv->entries->data; + NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *) priv->entries->data; return entries[priv->active].id; } @@ -250,7 +250,7 @@ void nmt_newt_popup_set_active_id(NmtNewtPopup *popup, const char *active_id) { NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE(popup); - NmtNewtPopupEntry * entries = (NmtNewtPopupEntry *) priv->entries->data; + NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *) priv->entries->data; int i; for (i = 0; i < priv->entries->len; i++) { @@ -300,8 +300,8 @@ nmt_newt_popup_get_property(GObject *object, guint prop_id, GValue *value, GPara static void nmt_newt_popup_class_init(NmtNewtPopupClass *popup_class) { - GObjectClass * object_class = G_OBJECT_CLASS(popup_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(popup_class); + GObjectClass *object_class = G_OBJECT_CLASS(popup_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(popup_class); NmtNewtComponentClass *component_class = NMT_NEWT_COMPONENT_CLASS(popup_class); g_type_class_add_private(popup_class, sizeof(NmtNewtPopupPrivate)); diff --git a/src/libnmt-newt/nmt-newt-section.c b/src/libnmt-newt/nmt-newt-section.c index fa73ea4a07..eb551273a3 100644 --- a/src/libnmt-newt/nmt-newt-section.c +++ b/src/libnmt-newt/nmt-newt-section.c @@ -47,7 +47,7 @@ typedef struct { NmtNewtWidget *border_open_label; NmtNewtWidget *border_closed_label; NmtNewtWidget *border_end_label; - GPtrArray * border_line_labels; + GPtrArray *border_line_labels; gboolean open; } NmtNewtSectionPrivate; @@ -124,7 +124,7 @@ nmt_newt_section_set_header(NmtNewtSection *section, NmtNewtWidget *header) { NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE(section); NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS(nmt_newt_section_parent_class); - NmtNewtContainer * container = NMT_NEWT_CONTAINER(section); + NmtNewtContainer *container = NMT_NEWT_CONTAINER(section); if (priv->header) parent_class->remove(container, priv->header); @@ -160,7 +160,7 @@ nmt_newt_section_set_body(NmtNewtSection *section, NmtNewtWidget *body) { NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE(section); NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS(nmt_newt_section_parent_class); - NmtNewtContainer * container = NMT_NEWT_CONTAINER(section); + NmtNewtContainer *container = NMT_NEWT_CONTAINER(section); if (priv->body) parent_class->remove(container, priv->body); @@ -187,7 +187,7 @@ nmt_newt_section_get_body(NmtNewtSection *section) static void nmt_newt_section_remove(NmtNewtContainer *container, NmtNewtWidget *widget) { - NmtNewtSection * section = NMT_NEWT_SECTION(container); + NmtNewtSection *section = NMT_NEWT_SECTION(container); NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE(section); NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS(nmt_newt_section_parent_class); @@ -205,8 +205,8 @@ static newtComponent * nmt_newt_section_get_components(NmtNewtWidget *widget) { NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE(widget); - newtComponent * child_cos; - GPtrArray * cos; + newtComponent *child_cos; + GPtrArray *cos; int i; g_return_val_if_fail(priv->header != NULL && priv->body != NULL, NULL); @@ -316,10 +316,10 @@ nmt_newt_section_size_allocate(NmtNewtWidget *widget, int x, int y, int width, i } static void -nmt_newt_section_set_property(GObject * object, +nmt_newt_section_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE(object); @@ -359,8 +359,8 @@ nmt_newt_section_get_property(GObject *object, guint prop_id, GValue *value, GPa static void nmt_newt_section_class_init(NmtNewtSectionClass *section_class) { - GObjectClass * object_class = G_OBJECT_CLASS(section_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(section_class); + GObjectClass *object_class = G_OBJECT_CLASS(section_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(section_class); NmtNewtContainerClass *container_class = NMT_NEWT_CONTAINER_CLASS(section_class); g_type_class_add_private(section_class, sizeof(NmtNewtSectionPrivate)); diff --git a/src/libnmt-newt/nmt-newt-stack.c b/src/libnmt-newt/nmt-newt-stack.c index e0fdb3b9a2..bb05e51b98 100644 --- a/src/libnmt-newt/nmt-newt-stack.c +++ b/src/libnmt-newt/nmt-newt-stack.c @@ -87,7 +87,7 @@ nmt_newt_stack_get_components(NmtNewtWidget *widget) static void nmt_newt_stack_size_request(NmtNewtWidget *widget, int *width, int *height) { - NmtNewtStack * stack = NMT_NEWT_STACK(widget); + NmtNewtStack *stack = NMT_NEWT_STACK(widget); NmtNewtStackPrivate *priv = NMT_NEWT_STACK_GET_PRIVATE(stack); int i, child_width, child_height; @@ -142,7 +142,7 @@ nmt_newt_stack_add(NmtNewtStack *stack, const char *id, NmtNewtWidget *widget) static void nmt_newt_stack_remove(NmtNewtContainer *container, NmtNewtWidget *widget) { - NmtNewtStack * stack = NMT_NEWT_STACK(container); + NmtNewtStack *stack = NMT_NEWT_STACK(container); NmtNewtStackPrivate *priv = NMT_NEWT_STACK_GET_PRIVATE(stack); int i; @@ -293,8 +293,8 @@ nmt_newt_stack_get_property(GObject *object, guint prop_id, GValue *value, GPara static void nmt_newt_stack_class_init(NmtNewtStackClass *stack_class) { - GObjectClass * object_class = G_OBJECT_CLASS(stack_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(stack_class); + GObjectClass *object_class = G_OBJECT_CLASS(stack_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(stack_class); NmtNewtContainerClass *container_class = NMT_NEWT_CONTAINER_CLASS(stack_class); g_type_class_add_private(stack_class, sizeof(NmtNewtStackPrivate)); diff --git a/src/libnmt-newt/nmt-newt-textbox.c b/src/libnmt-newt/nmt-newt-textbox.c index 128e539b91..24aae9f9e7 100644 --- a/src/libnmt-newt/nmt-newt-textbox.c +++ b/src/libnmt-newt/nmt-newt-textbox.c @@ -76,7 +76,7 @@ void nmt_newt_textbox_set_text(NmtNewtTextbox *textbox, const char *text) { NmtNewtTextboxPrivate *priv = NMT_NEWT_TEXTBOX_GET_PRIVATE(textbox); - char ** lines; + char **lines; int i, width; if (!text) @@ -151,8 +151,8 @@ nmt_newt_textbox_build_component(NmtNewtComponent *component, gboolean sensitive { NmtNewtTextboxPrivate *priv = NMT_NEWT_TEXTBOX_GET_PRIVATE(component); newtComponent co; - const char * text; - char * text_lc; + const char *text; + char *text_lc; text = priv->text; if (!*text) @@ -176,12 +176,12 @@ nmt_newt_textbox_build_component(NmtNewtComponent *component, gboolean sensitive } static void -nmt_newt_textbox_set_property(GObject * object, +nmt_newt_textbox_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { - NmtNewtTextbox * textbox = NMT_NEWT_TEXTBOX(object); + NmtNewtTextbox *textbox = NMT_NEWT_TEXTBOX(object); NmtNewtTextboxPrivate *priv = NMT_NEWT_TEXTBOX_GET_PRIVATE(textbox); switch (prop_id) { @@ -224,7 +224,7 @@ nmt_newt_textbox_get_property(GObject *object, guint prop_id, GValue *value, GPa static void nmt_newt_textbox_class_init(NmtNewtTextboxClass *textbox_class) { - GObjectClass * object_class = G_OBJECT_CLASS(textbox_class); + GObjectClass *object_class = G_OBJECT_CLASS(textbox_class); NmtNewtComponentClass *component_class = NMT_NEWT_COMPONENT_CLASS(textbox_class); g_type_class_add_private(textbox_class, sizeof(NmtNewtTextboxPrivate)); diff --git a/src/libnmt-newt/nmt-newt-toggle-button.c b/src/libnmt-newt/nmt-newt-toggle-button.c index c48931e5d7..069dff8412 100644 --- a/src/libnmt-newt/nmt-newt-toggle-button.c +++ b/src/libnmt-newt/nmt-newt-toggle-button.c @@ -20,7 +20,7 @@ G_DEFINE_TYPE(NmtNewtToggleButton, nmt_newt_toggle_button, NMT_TYPE_NEWT_BUTTON) (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_NEWT_TOGGLE_BUTTON, NmtNewtToggleButtonPrivate)) typedef struct { - char * on_label, *off_label; + char *on_label, *off_label; gboolean active; } NmtNewtToggleButtonPrivate; @@ -115,10 +115,10 @@ nmt_newt_toggle_button_activated(NmtNewtWidget *widget) } static void -nmt_newt_toggle_button_set_property(GObject * object, +nmt_newt_toggle_button_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtNewtToggleButtonPrivate *priv = NMT_NEWT_TOGGLE_BUTTON_GET_PRIVATE(object); @@ -146,9 +146,9 @@ nmt_newt_toggle_button_set_property(GObject * object, } static void -nmt_newt_toggle_button_get_property(GObject * object, +nmt_newt_toggle_button_get_property(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec) { NmtNewtToggleButtonPrivate *priv = NMT_NEWT_TOGGLE_BUTTON_GET_PRIVATE(object); @@ -172,7 +172,7 @@ nmt_newt_toggle_button_get_property(GObject * object, static void nmt_newt_toggle_button_class_init(NmtNewtToggleButtonClass *button_class) { - GObjectClass * object_class = G_OBJECT_CLASS(button_class); + GObjectClass *object_class = G_OBJECT_CLASS(button_class); NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(button_class); g_type_class_add_private(button_class, sizeof(NmtNewtToggleButtonPrivate)); diff --git a/src/libnmt-newt/nmt-newt-utils.c b/src/libnmt-newt/nmt-newt-utils.c index 99bde74795..14825fab0a 100644 --- a/src/libnmt-newt/nmt-newt-utils.c +++ b/src/libnmt-newt/nmt-newt-utils.c @@ -19,13 +19,13 @@ #include "libnm-glib-aux/nm-io-utils.h" static void -nmt_newt_dialog_g_log_handler(const char * log_domain, +nmt_newt_dialog_g_log_handler(const char *log_domain, GLogLevelFlags log_level, - const char * message, + const char *message, gpointer user_data) { - const char * level_name; - char * full_message; + const char *level_name; + char *full_message; int screen_width, screen_height; newtComponent text, ok, form; newtGrid grid; @@ -85,9 +85,9 @@ nmt_newt_dialog_g_log_handler(const char * log_domain, } static void -nmt_newt_basic_g_log_handler(const char * log_domain, +nmt_newt_basic_g_log_handler(const char *log_domain, GLogLevelFlags log_level, - const char * message, + const char *message, gpointer user_data) { newtSuspend(); @@ -133,7 +133,7 @@ nmt_newt_parse_colors(const char *s, bool is_newt) const char *name; const char *fg; const char *bg; - char * parsed_s; + char *parsed_s; parsed_s = (char *) lines[i]; name = parsed_s; @@ -178,7 +178,7 @@ nmt_newt_parse_colors(const char *s, bool is_newt) static void nmt_newt_init_colors(gboolean is_newt) { - const char * colors; + const char *colors; gs_free char *file_content = NULL; colors = getenv(is_newt ? "NEWT_COLORS" : "NMT_NEWT_COLORS"); @@ -257,7 +257,7 @@ void nmt_newt_message_dialog(const char *message, ...) { va_list ap; - char * msg, *msg_lc, *ok_lc; + char *msg, *msg_lc, *ok_lc; va_start(ap, message); msg = g_strdup_vprintf(message, ap); @@ -288,7 +288,7 @@ int nmt_newt_choice_dialog(const char *button1, const char *button2, const char *message, ...) { va_list ap; - char * msg, *msg_lc, *button1_lc, *button2_lc; + char *msg, *msg_lc, *button1_lc, *button2_lc; int choice; va_start(ap, message); @@ -402,10 +402,10 @@ char * nmt_newt_edit_string(const char *data) { gssize len, nwrote; - char * filename, *argv[3]; + char *filename, *argv[3]; GError *error = NULL; int fd, status; - char * new_data = NULL; + char *new_data = NULL; fd = g_file_open_tmp("XXXXXX.json", &filename, &error); if (fd == -1) { diff --git a/src/nm-cloud-setup/main.c b/src/nm-cloud-setup/main.c index 916f41da91..f6acadca33 100644 --- a/src/nm-cloud-setup/main.c +++ b/src/nm-cloud-setup/main.c @@ -16,7 +16,7 @@ /*****************************************************************************/ typedef struct { - GMainLoop * main_loop; + GMainLoop *main_loop; GCancellable *cancellable; NMCSProvider *provider_result; guint detect_count; @@ -26,9 +26,9 @@ static void _provider_detect_cb(GObject *source, GAsyncResult *result, gpointer user_data) { gs_unref_object NMCSProvider *provider = NMCS_PROVIDER(source); - gs_free_error GError *error = NULL; - ProviderDetectData * dd; - gboolean success; + gs_free_error GError *error = NULL; + ProviderDetectData *dd; + gboolean success; success = nmcs_provider_detect_finish(provider, result, &error); @@ -75,14 +75,14 @@ _provider_detect_sigterm_cb(GCancellable *source, gpointer user_data) static NMCSProvider * _provider_detect(GCancellable *sigterm_cancellable) { - nm_auto_unref_gmainloop GMainLoop *main_loop = g_main_loop_new(NULL, FALSE); - gs_unref_object GCancellable *cancellable = g_cancellable_new(); - gs_unref_object NMHttpClient *http_client = NULL; - ProviderDetectData dd = { - .cancellable = cancellable, - .main_loop = main_loop, - .detect_count = 0, - .provider_result = NULL, + nm_auto_unref_gmainloop GMainLoop *main_loop = g_main_loop_new(NULL, FALSE); + gs_unref_object GCancellable *cancellable = g_cancellable_new(); + gs_unref_object NMHttpClient *http_client = NULL; + ProviderDetectData dd = { + .cancellable = cancellable, + .main_loop = main_loop, + .detect_count = 0, + .provider_result = NULL, }; const GType gtypes[] = { NMCS_TYPE_PROVIDER_EC2, @@ -127,17 +127,17 @@ static char ** _nmc_get_hwaddrs(NMClient *nmc) { gs_unref_ptrarray GPtrArray *hwaddrs = NULL; - const GPtrArray * devices; - char ** hwaddrs_v; - gs_free char * str = NULL; + const GPtrArray *devices; + char **hwaddrs_v; + gs_free char *str = NULL; guint i; devices = nm_client_get_devices(nmc); for (i = 0; i < devices->len; i++) { - NMDevice * device = devices->pdata[i]; + NMDevice *device = devices->pdata[i]; const char *hwaddr; - char * s; + char *s; if (!NM_IS_DEVICE_ETHERNET(device)) continue; @@ -180,8 +180,8 @@ _nmc_get_device_by_hwaddr(NMClient *nmc, const char *hwaddr) devices = nm_client_get_devices(nmc); for (i = 0; i < devices->len; i++) { - NMDevice * device = devices->pdata[i]; - const char * hwaddr_dev; + NMDevice *device = devices->pdata[i]; + const char *hwaddr_dev; gs_free char *s = NULL; if (!NM_IS_DEVICE_ETHERNET(device)) @@ -202,16 +202,16 @@ _nmc_get_device_by_hwaddr(NMClient *nmc, const char *hwaddr) /*****************************************************************************/ typedef struct { - GMainLoop * main_loop; + GMainLoop *main_loop; NMCSProviderGetConfigResult *result; } GetConfigData; static void _get_config_cb(GObject *source, GAsyncResult *res, gpointer user_data) { - GetConfigData * data = user_data; + GetConfigData *data = user_data; nm_auto_free_nmcs_provider_get_config_result NMCSProviderGetConfigResult *result = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; result = nmcs_provider_get_config_finish(NMCS_PROVIDER(source), res, &error); @@ -230,7 +230,7 @@ _get_config(GCancellable *sigterm_cancellable, NMCSProvider *provider, NMClient { nm_auto_unref_gmainloop GMainLoop *main_loop = g_main_loop_new(NULL, FALSE); GetConfigData data = { - .main_loop = main_loop, + .main_loop = main_loop, }; gs_strfreev char **hwaddrs = NULL; @@ -254,7 +254,7 @@ static gboolean _nmc_skip_connection(NMConnection *connection) { NMSettingUser *s_user; - const char * v; + const char *v; s_user = NM_SETTING_USER(nm_connection_get_setting(connection, NM_TYPE_SETTING_USER)); if (!s_user) @@ -269,24 +269,24 @@ _nmc_skip_connection(NMConnection *connection) } static gboolean -_nmc_mangle_connection(NMDevice * device, - NMConnection * connection, - const NMCSProviderGetConfigResult * result, +_nmc_mangle_connection(NMDevice *device, + NMConnection *connection, + const NMCSProviderGetConfigResult *result, const NMCSProviderGetConfigIfaceData *config_data, - gboolean * out_skipped_single_addr, - gboolean * out_changed) + gboolean *out_skipped_single_addr, + gboolean *out_changed) { - NMSettingIPConfig * s_ip; - NMActiveConnection *ac; - NMConnection * remote_connection; - NMSettingIPConfig * remote_s_ip = NULL; - gsize i; - gboolean addrs_changed = FALSE; - gboolean rules_changed = FALSE; - gboolean routes_changed = FALSE; - gs_unref_ptrarray GPtrArray *addrs_new = NULL; - gs_unref_ptrarray GPtrArray *rules_new = NULL; - gs_unref_ptrarray GPtrArray *routes_new = NULL; + NMSettingIPConfig *s_ip; + NMActiveConnection *ac; + NMConnection *remote_connection; + NMSettingIPConfig *remote_s_ip = NULL; + gsize i; + gboolean addrs_changed = FALSE; + gboolean rules_changed = FALSE; + gboolean routes_changed = FALSE; + gs_unref_ptrarray GPtrArray *addrs_new = NULL; + gs_unref_ptrarray GPtrArray *rules_new = NULL; + gs_unref_ptrarray GPtrArray *routes_new = NULL; NM_SET_OUT(out_skipped_single_addr, FALSE); NM_SET_OUT(out_changed, FALSE); @@ -339,8 +339,8 @@ _nmc_mangle_connection(NMDevice * device, } else if (config_data->has_ipv4s && config_data->has_cidr) { gs_unref_hashtable GHashTable *unique_subnets = g_hash_table_new(nm_direct_hash, g_direct_equal); - NMIPAddress * addr_entry; - NMIPRoute * route_entry; + NMIPAddress *addr_entry; + NMIPRoute *route_entry; NMIPRoutingRule *rule_entry; in_addr_t gateway; char sbuf[NM_UTILS_INET_ADDRSTRLEN]; @@ -435,22 +435,22 @@ _nmc_mangle_connection(NMDevice * device, /*****************************************************************************/ static gboolean -_config_one(GCancellable * sigterm_cancellable, - NMClient * nmc, +_config_one(GCancellable *sigterm_cancellable, + NMClient *nmc, const NMCSProviderGetConfigResult *result, guint idx) { - const NMCSProviderGetConfigIfaceData *config_data = result->iface_datas_arr[idx]; - const char * hwaddr = config_data->hwaddr; - gs_unref_object NMDevice *device = NULL; - gs_unref_object NMConnection *applied_connection = NULL; - guint64 applied_version_id; - gs_free_error GError *error = NULL; - gboolean changed; - gboolean skipped_single_addr; - gboolean version_id_changed; - guint try_count; - gboolean any_changes = FALSE; + const NMCSProviderGetConfigIfaceData *config_data = result->iface_datas_arr[idx]; + const char *hwaddr = config_data->hwaddr; + gs_unref_object NMDevice *device = NULL; + gs_unref_object NMConnection *applied_connection = NULL; + guint64 applied_version_id; + gs_free_error GError *error = NULL; + gboolean changed; + gboolean skipped_single_addr; + gboolean version_id_changed; + guint try_count; + gboolean any_changes = FALSE; g_main_context_iteration(NULL, FALSE); @@ -572,8 +572,8 @@ try_again: } static gboolean -_config_all(GCancellable * sigterm_cancellable, - NMClient * nmc, +_config_all(GCancellable *sigterm_cancellable, + NMClient *nmc, const NMCSProviderGetConfigResult *result) { gboolean any_changes = FALSE; @@ -607,12 +607,12 @@ sigterm_handler(gpointer user_data) int main(int argc, const char *const *argv) { - gs_unref_object GCancellable * sigterm_cancellable = NULL; + gs_unref_object GCancellable *sigterm_cancellable = NULL; nm_auto_destroy_and_unref_gsource GSource *sigterm_source = NULL; - gs_unref_object NMCSProvider *provider = NULL; - gs_unref_object NMClient * nmc = NULL; + gs_unref_object NMCSProvider *provider = NULL; + gs_unref_object NMClient *nmc = NULL; nm_auto_free_nmcs_provider_get_config_result NMCSProviderGetConfigResult *result = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; _nm_logging_enabled_init(g_getenv(NMCS_ENV_VARIABLE("NM_CLOUD_SETUP_LOG"))); diff --git a/src/nm-cloud-setup/nm-cloud-setup-utils.c b/src/nm-cloud-setup/nm-cloud-setup-utils.c index 206461e4d0..bf705549f3 100644 --- a/src/nm-cloud-setup/nm-cloud-setup-utils.c +++ b/src/nm-cloud-setup/nm-cloud-setup-utils.c @@ -113,7 +113,7 @@ _wait_for_objects_iterate_until_done_idle_cb(gpointer user_data) gboolean nmcs_wait_for_objects_iterate_until_done(GMainContext *context, int timeout_msec) { - nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(context, FALSE); + nm_auto_unref_gmainloop GMainLoop *loop = g_main_loop_new(context, FALSE); nm_auto_destroy_and_unref_gsource GSource *timeout_source = NULL; WaitForObjectsData data; gboolean has_more_objects; @@ -167,11 +167,11 @@ nmcs_wait_for_objects_iterate_until_done(GMainContext *context, int timeout_msec /*****************************************************************************/ typedef struct { - GTask * task; - GSource * source_timeout; - GSource * source_next_poll; - GMainContext * context; - GCancellable * internal_cancellable; + GTask *task; + GSource *source_timeout; + GSource *source_next_poll; + GMainContext *context; + GCancellable *internal_cancellable; NMCSUtilsPollProbeStartFcn probe_start_fcn; NMCSUtilsPollProbeFinishFcn probe_finish_fcn; gpointer probe_user_data; @@ -220,7 +220,7 @@ static gboolean _poll_start_cb(gpointer user_data); static void _poll_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - PollTaskData * poll_task_data = user_data; + PollTaskData *poll_task_data = user_data; _nm_unused gs_unref_object GTask *task = poll_task_data->task; /* balance ref from _poll_start_cb() */ gs_free_error GError *error = NULL; @@ -291,7 +291,7 @@ static void _poll_cancelled_cb(GObject *object, gpointer user_data) { PollTaskData *poll_task_data = user_data; - GError * error = NULL; + GError *error = NULL; nm_clear_g_signal_handler(g_task_get_cancellable(poll_task_data->task), &poll_task_data->cancellable_id); @@ -330,7 +330,7 @@ nmcs_utils_poll(int poll_timeout_ms, NMCSUtilsPollProbeStartFcn probe_start_fcn, NMCSUtilsPollProbeFinishFcn probe_finish_fcn, gpointer probe_user_data, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -400,7 +400,7 @@ nmcs_utils_poll(int poll_timeout_ms, gboolean nmcs_utils_poll_finish(GAsyncResult *result, gpointer *probe_user_data, GError **error) { - GTask * task; + GTask *task; PollTaskData *poll_task_data; g_return_val_if_fail(nm_g_task_is_valid(result, NULL, nmcs_utils_poll), FALSE); @@ -422,7 +422,7 @@ char * nmcs_utils_hwaddr_normalize(const char *hwaddr, gssize len) { gs_free char *hwaddr_clone = NULL; - char * hw; + char *hw; guint8 buf[ETH_ALEN]; gsize l; @@ -474,11 +474,11 @@ gboolean nmcs_utils_ipaddr_normalize_bin(int addr_family, const char *addr, gssize len, - int * out_addr_family, + int *out_addr_family, gpointer out_addr_bin) { gs_free char *addr_clone = NULL; - char * ad; + char *ad; gsize l; nm_assert(len >= -1); @@ -620,7 +620,7 @@ nmcs_utils_uri_complete_interned(const char *uri) gboolean nmcs_setting_ip_replace_ipv4_addresses(NMSettingIPConfig *s_ip, - NMIPAddress ** entries_arr, + NMIPAddress **entries_arr, guint entries_len) { gboolean any_changes = FALSE; @@ -667,7 +667,7 @@ nmcs_setting_ip_replace_ipv4_addresses(NMSettingIPConfig *s_ip, gboolean nmcs_setting_ip_replace_ipv4_routes(NMSettingIPConfig *s_ip, - NMIPRoute ** entries_arr, + NMIPRoute **entries_arr, guint entries_len) { gboolean any_changes = FALSE; @@ -713,7 +713,7 @@ nmcs_setting_ip_replace_ipv4_routes(NMSettingIPConfig *s_ip, gboolean nmcs_setting_ip_replace_ipv4_rules(NMSettingIPConfig *s_ip, - NMIPRoutingRule ** entries_arr, + NMIPRoutingRule **entries_arr, guint entries_len) { gboolean any_changes = FALSE; @@ -758,9 +758,9 @@ nmcs_setting_ip_replace_ipv4_rules(NMSettingIPConfig *s_ip, /*****************************************************************************/ typedef struct { - GMainLoop * main_loop; + GMainLoop *main_loop; NMConnection *connection; - GError * error; + GError *error; guint64 version_id; } DeviceGetAppliedConnectionData; @@ -777,14 +777,14 @@ _nmcs_device_get_applied_connection_cb(GObject *source, GAsyncResult *result, gp } NMConnection * -nmcs_device_get_applied_connection(NMDevice * device, +nmcs_device_get_applied_connection(NMDevice *device, GCancellable *cancellable, - guint64 * version_id, - GError ** error) + guint64 *version_id, + GError **error) { nm_auto_unref_gmainloop GMainLoop *main_loop = g_main_loop_new(NULL, FALSE); DeviceGetAppliedConnectionData data = { - .main_loop = main_loop, + .main_loop = main_loop, }; nm_device_get_applied_connection_async(device, @@ -805,7 +805,7 @@ nmcs_device_get_applied_connection(NMDevice * device, typedef struct { GMainLoop *main_loop; - GError * error; + GError *error; } DeviceReapplyData; static void @@ -818,16 +818,16 @@ _nmcs_device_reapply_cb(GObject *source, GAsyncResult *result, gpointer user_dat } gboolean -nmcs_device_reapply(NMDevice * device, +nmcs_device_reapply(NMDevice *device, GCancellable *sigterm_cancellable, NMConnection *connection, guint64 version_id, - gboolean * out_version_id_changed, - GError ** error) + gboolean *out_version_id_changed, + GError **error) { nm_auto_unref_gmainloop GMainLoop *main_loop = g_main_loop_new(NULL, FALSE); DeviceReapplyData data = { - .main_loop = main_loop, + .main_loop = main_loop, }; nm_device_reapply_async(device, diff --git a/src/nm-cloud-setup/nm-cloud-setup-utils.h b/src/nm-cloud-setup/nm-cloud-setup-utils.h index e1502b9525..4131abfe7c 100644 --- a/src/nm-cloud-setup/nm-cloud-setup-utils.h +++ b/src/nm-cloud-setup/nm-cloud-setup-utils.h @@ -40,15 +40,15 @@ gboolean nmcs_wait_for_objects_iterate_until_done(GMainContext *context, int tim /*****************************************************************************/ -typedef void (*NMCSUtilsPollProbeStartFcn)(GCancellable * cancellable, +typedef void (*NMCSUtilsPollProbeStartFcn)(GCancellable *cancellable, gpointer probe_user_data, GAsyncReadyCallback callback, gpointer user_data); -typedef gboolean (*NMCSUtilsPollProbeFinishFcn)(GObject * source, +typedef gboolean (*NMCSUtilsPollProbeFinishFcn)(GObject *source, GAsyncResult *result, gpointer probe_user_data, - GError ** error); + GError **error); void nmcs_utils_poll(int poll_timeout_ms, int ratelimit_timeout_ms, @@ -56,7 +56,7 @@ void nmcs_utils_poll(int poll_timeout_ms, NMCSUtilsPollProbeStartFcn probe_start_fcn, NMCSUtilsPollProbeFinishFcn probe_finish_fcn, gpointer probe_user_data, - GCancellable * cancellable, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -81,7 +81,7 @@ nmcs_utils_hwaddr_normalize_gbytes(GBytes *hwaddr) gboolean nmcs_utils_ipaddr_normalize_bin(int addr_family, const char *addr, gssize len, - int * out_addr_family, + int *out_addr_family, gpointer out_addr_bin); char *nmcs_utils_ipaddr_normalize(int addr_family, const char *addr, gssize len); @@ -114,29 +114,29 @@ const char *nmcs_utils_uri_complete_interned(const char *uri); /*****************************************************************************/ gboolean nmcs_setting_ip_replace_ipv4_addresses(NMSettingIPConfig *s_ip, - NMIPAddress ** entries_arr, + NMIPAddress **entries_arr, guint entries_len); gboolean nmcs_setting_ip_replace_ipv4_routes(NMSettingIPConfig *s_ip, - NMIPRoute ** entries_arr, + NMIPRoute **entries_arr, guint entries_len); gboolean nmcs_setting_ip_replace_ipv4_rules(NMSettingIPConfig *s_ip, - NMIPRoutingRule ** entries_arr, + NMIPRoutingRule **entries_arr, guint entries_len); /*****************************************************************************/ -NMConnection *nmcs_device_get_applied_connection(NMDevice * device, +NMConnection *nmcs_device_get_applied_connection(NMDevice *device, GCancellable *cancellable, - guint64 * version_id, - GError ** error); + guint64 *version_id, + GError **error); -gboolean nmcs_device_reapply(NMDevice * device, +gboolean nmcs_device_reapply(NMDevice *device, GCancellable *sigterm_cancellable, NMConnection *connection, guint64 version_id, - gboolean * out_version_id_changed, - GError ** error); + gboolean *out_version_id_changed, + GError **error); #endif /* __NM_CLOUD_SETUP_UTILS_H__ */ diff --git a/src/nm-cloud-setup/nm-http-client.c b/src/nm-cloud-setup/nm-http-client.c index 618ab1be10..2f71cefa3d 100644 --- a/src/nm-cloud-setup/nm-http-client.c +++ b/src/nm-cloud-setup/nm-http-client.c @@ -15,9 +15,9 @@ typedef struct { GMainContext *context; - CURLM * mhandle; - GSource * mhandle_source_timeout; - GHashTable * source_sockets_hashtable; + CURLM *mhandle; + GSource *mhandle_source_timeout; + GHashTable *source_sockets_hashtable; } NMHttpClientPrivate; struct _NMHttpClient { @@ -113,11 +113,11 @@ _get_result_free(gpointer data) } typedef struct { - GTask * task; - GSource * timeout_source; + GTask *task; + GSource *timeout_source; CURLcode ehandle_result; - CURL * ehandle; - char * url; + CURL *ehandle; + char *url; NMStrBuf recv_data; struct curl_slist *headers; gssize max_data; @@ -128,7 +128,7 @@ static void _ehandle_free_ehandle(EHandleData *edata) { if (edata->ehandle) { - NMHttpClient * self = g_task_get_source_object(edata->task); + NMHttpClient *self = g_task_get_source_object(edata->task); NMHttpClientPrivate *priv = NM_HTTP_CLIENT_GET_PRIVATE(self); curl_multi_remove_handle(priv->mhandle, edata->ehandle); @@ -154,7 +154,7 @@ _ehandle_free(EHandleData *edata) static void _ehandle_complete(EHandleData *edata, GError *error_take) { - GetResult * get_result; + GetResult *get_result; gs_free char *str_tmp_1 = NULL; long response_code = -1; @@ -249,7 +249,7 @@ static void _get_cancelled_cb(GObject *object, gpointer user_data) { EHandleData *edata = user_data; - GError * error = NULL; + GError *error = NULL; nm_clear_g_signal_handler(g_task_get_cancellable(edata->task), &edata->cancellable_id); nm_utils_error_set_cancelled(&error, FALSE, NULL); @@ -257,17 +257,17 @@ _get_cancelled_cb(GObject *object, gpointer user_data) } void -nm_http_client_get(NMHttpClient * self, - const char * url, +nm_http_client_get(NMHttpClient *self, + const char *url, int timeout_msec, gssize max_data, - const char *const * http_headers, - GCancellable * cancellable, + const char *const *http_headers, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { NMHttpClientPrivate *priv; - EHandleData * edata; + EHandleData *edata; guint i; g_return_if_fail(NM_IS_HTTP_CLIENT(self)); @@ -363,9 +363,9 @@ nm_http_client_get(NMHttpClient * self, gboolean nm_http_client_get_finish(NMHttpClient *self, GAsyncResult *result, - long * out_response_code, - GBytes ** out_response_data, - GError ** error) + long *out_response_code, + GBytes **out_response_data, + GError **error) { GetResult *get_result; @@ -394,12 +394,12 @@ nm_http_client_get_finish(NMHttpClient *self, /*****************************************************************************/ typedef struct { - GTask * task; - char * uri; - const char *const * http_headers; + GTask *task; + char *uri; + const char *const *http_headers; NMHttpClientPollGetCheckFcn check_fcn; gpointer check_user_data; - GBytes * response_data; + GBytes *response_data; gsize request_max_data; long response_code; int request_timeout_ms; @@ -419,7 +419,7 @@ _poll_get_data_free(gpointer data) } static void -_poll_get_probe_start_fcn(GCancellable * cancellable, +_poll_get_probe_start_fcn(GCancellable *cancellable, gpointer probe_user_data, GAsyncReadyCallback callback, gpointer user_data) @@ -440,16 +440,16 @@ _poll_get_probe_start_fcn(GCancellable * cancellable, } static gboolean -_poll_get_probe_finish_fcn(GObject * source, +_poll_get_probe_finish_fcn(GObject *source, GAsyncResult *result, gpointer probe_user_data, - GError ** error) + GError **error) { - PollGetData * poll_get_data = probe_user_data; + PollGetData *poll_get_data = probe_user_data; _nm_unused gs_unref_object GTask *task = poll_get_data->task; /* balance ref from _poll_get_probe_start_fcn() */ - gboolean success; - gs_free_error GError *local_error = NULL; + gboolean success; + gs_free_error GError *local_error = NULL; gs_unref_bytes GBytes *response_data = NULL; long response_code = -1; @@ -496,8 +496,8 @@ _poll_get_probe_finish_fcn(GObject * source, static void _poll_get_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - PollGetData * poll_get_data = user_data; - gs_free_error GError *error = NULL; + PollGetData *poll_get_data = user_data; + gs_free_error GError *error = NULL; gboolean success; success = nmcs_utils_poll_finish(result, NULL, &error); @@ -513,21 +513,21 @@ _poll_get_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) } void -nm_http_client_poll_get(NMHttpClient * self, - const char * uri, +nm_http_client_poll_get(NMHttpClient *self, + const char *uri, int request_timeout_ms, gssize request_max_data, int poll_timeout_ms, int ratelimit_timeout_ms, - const char *const * http_headers, - GCancellable * cancellable, + const char *const *http_headers, + GCancellable *cancellable, NMHttpClientPollGetCheckFcn check_fcn, gpointer check_user_data, GAsyncReadyCallback callback, gpointer user_data) { nm_auto_pop_gmaincontext GMainContext *context = NULL; - PollGetData * poll_get_data; + PollGetData *poll_get_data; g_return_if_fail(NM_IS_HTTP_CLIENT(self)); g_return_if_fail(uri && uri[0]); @@ -570,13 +570,13 @@ nm_http_client_poll_get(NMHttpClient * self, gboolean nm_http_client_poll_get_finish(NMHttpClient *self, GAsyncResult *result, - long * out_response_code, - GBytes ** out_response_data, - GError ** error) + long *out_response_code, + GBytes **out_response_data, + GError **error) { - PollGetData * poll_get_data; - GTask * task; - gboolean success; + PollGetData *poll_get_data; + GTask *task; + gboolean success; gs_free_error GError *local_error = NULL; g_return_val_if_fail(NM_HTTP_CLIENT(self), FALSE); @@ -608,8 +608,8 @@ static void _mhandle_action(NMHttpClient *self, int sockfd, int ev_bitmask) { NMHttpClientPrivate *priv = NM_HTTP_CLIENT_GET_PRIVATE(self); - EHandleData * edata; - CURLMsg * msg; + EHandleData *edata; + CURLMsg *msg; CURLcode eret; int m_left; CURLMcode ret; @@ -652,14 +652,14 @@ _mhandle_socket_cb(int fd, GIOCondition condition, gpointer user_data) } static int -_mhandle_socketfunction_cb(CURL * e_handle, +_mhandle_socketfunction_cb(CURL *e_handle, curl_socket_t fd, int what, - void * user_data, - void * socketp) + void *user_data, + void *socketp) { - GSource * source_socket; - NMHttpClient * self = user_data; + GSource *source_socket; + NMHttpClient *self = user_data; NMHttpClientPrivate *priv = NM_HTTP_CLIENT_GET_PRIVATE(self); (void) _NM_ENSURE_TYPE(int, fd); @@ -704,7 +704,7 @@ _mhandle_timeout_cb(gpointer user_data) static int _mhandle_timerfunction_cb(CURLM *multi, long timeout_msec, void *user_data) { - NMHttpClient * self = user_data; + NMHttpClient *self = user_data; NMHttpClientPrivate *priv = NM_HTTP_CLIENT_GET_PRIVATE(self); nm_clear_pointer(&priv->mhandle_source_timeout, nm_g_source_destroy_and_unref); @@ -737,7 +737,7 @@ nm_http_client_init(NMHttpClient *self) static void constructed(GObject *object) { - NMHttpClient * self = NM_HTTP_CLIENT(object); + NMHttpClient *self = NM_HTTP_CLIENT(object); NMHttpClientPrivate *priv = NM_HTTP_CLIENT_GET_PRIVATE(self); priv->context = g_main_context_ref_thread_default(); @@ -764,7 +764,7 @@ nm_http_client_new(void) static void dispose(GObject *object) { - NMHttpClient * self = NM_HTTP_CLIENT(object); + NMHttpClient *self = NM_HTTP_CLIENT(object); NMHttpClientPrivate *priv = NM_HTTP_CLIENT_GET_PRIVATE(self); nm_clear_pointer(&priv->mhandle, curl_multi_cleanup); @@ -778,7 +778,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMHttpClient * self = NM_HTTP_CLIENT(object); + NMHttpClient *self = NM_HTTP_CLIENT(object); NMHttpClientPrivate *priv = NM_HTTP_CLIENT_GET_PRIVATE(self); G_OBJECT_CLASS(nm_http_client_parent_class)->finalize(object); diff --git a/src/nm-cloud-setup/nm-http-client.h b/src/nm-cloud-setup/nm-http-client.h index 862b733814..0a7052ae25 100644 --- a/src/nm-cloud-setup/nm-http-client.h +++ b/src/nm-cloud-setup/nm-http-client.h @@ -27,34 +27,34 @@ GMainContext *nm_http_client_get_main_context(NMHttpClient *self); /*****************************************************************************/ -void nm_http_client_get(NMHttpClient * self, - const char * uri, +void nm_http_client_get(NMHttpClient *self, + const char *uri, int timeout_msec, gssize max_data, - const char *const * http_headers, - GCancellable * cancellable, + const char *const *http_headers, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean nm_http_client_get_finish(NMHttpClient *self, GAsyncResult *result, - long * out_response_code, - GBytes ** out_response_data, - GError ** error); + long *out_response_code, + GBytes **out_response_data, + GError **error); typedef gboolean (*NMHttpClientPollGetCheckFcn)(long response_code, - GBytes * response_data, + GBytes *response_data, gpointer check_user_data, GError **error); -void nm_http_client_poll_get(NMHttpClient * self, - const char * uri, +void nm_http_client_poll_get(NMHttpClient *self, + const char *uri, int request_timeout_ms, gssize request_max_data, int poll_timeout_ms, int ratelimit_timeout_ms, - const char *const * http_headers, - GCancellable * cancellable, + const char *const *http_headers, + GCancellable *cancellable, NMHttpClientPollGetCheckFcn check_fcn, gpointer check_user_data, GAsyncReadyCallback callback, @@ -62,9 +62,9 @@ void nm_http_client_poll_get(NMHttpClient * self, gboolean nm_http_client_poll_get_finish(NMHttpClient *self, GAsyncResult *result, - long * out_response_code, - GBytes ** out_response_data, - GError ** error); + long *out_response_code, + GBytes **out_response_data, + GError **error); /*****************************************************************************/ diff --git a/src/nm-cloud-setup/nmcs-provider-aliyun.c b/src/nm-cloud-setup/nmcs-provider-aliyun.c index 7073318c13..31c9830d2d 100644 --- a/src/nm-cloud-setup/nmcs-provider-aliyun.c +++ b/src/nm-cloud-setup/nmcs-provider-aliyun.c @@ -22,7 +22,7 @@ static const char * _aliyun_base(void) { static const char *base_cached = NULL; - const char * base; + const char *base; again: base = g_atomic_pointer_get(&base_cached); @@ -73,9 +73,9 @@ filter_chars(char *str, const char *chars) static void _detect_get_meta_data_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_object GTask *task = user_data; - gs_free_error GError *get_error = NULL; - gs_free_error GError *error = NULL; + gs_unref_object GTask *task = user_data; + gs_free_error GError *get_error = NULL; + gs_free_error GError *error = NULL; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, NULL, &get_error); @@ -128,20 +128,20 @@ typedef enum { } GetConfigFetchDoneType; static void -_get_config_fetch_done_cb(NMHttpClient * http_client, - GAsyncResult * result, +_get_config_fetch_done_cb(NMHttpClient *http_client, + GAsyncResult *result, gpointer user_data, GetConfigFetchDoneType fetch_type) { - NMCSProviderGetConfigTaskData *get_config_data; - gs_unref_bytes GBytes *response = NULL; - gs_free_error GError * error = NULL; + NMCSProviderGetConfigTaskData *get_config_data; + gs_unref_bytes GBytes *response = NULL; + gs_free_error GError *error = NULL; NMCSProviderGetConfigIfaceData *config_iface_data; in_addr_t tmp_addr; int tmp_prefix; in_addr_t netmask_bin; in_addr_t gateway_bin; - gs_free const char ** s_addrs = NULL; + gs_free const char **s_addrs = NULL; gsize i; gsize len; @@ -263,11 +263,11 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us { NMCSProviderGetConfigTaskData *get_config_data; gs_unref_hashtable GHashTable *response_parsed = NULL; - gs_free_error GError *error = NULL; - GetConfigMetadataMac *v_mac_data; - const char * v_hwaddr; - GHashTableIter h_iter; - NMHttpClient * http_client; + gs_free_error GError *error = NULL; + GetConfigMetadataMac *v_mac_data; + const char *v_hwaddr; + GHashTableIter h_iter; + NMHttpClient *http_client; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, NULL, &error); @@ -293,10 +293,10 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us g_hash_table_iter_init(&h_iter, response_parsed); while (g_hash_table_iter_next(&h_iter, (gpointer *) &v_hwaddr, (gpointer *) &v_mac_data)) { NMCSProviderGetConfigIfaceData *config_iface_data; - gs_free char * uri1 = NULL; - gs_free char * uri2 = NULL; - gs_free char * uri3 = NULL; - gs_free char * uri4 = NULL; + gs_free char *uri1 = NULL; + gs_free char *uri2 = NULL; + gs_free char *uri3 = NULL; + gs_free char *uri4 = NULL; config_iface_data = g_hash_table_lookup(get_config_data->result_dict, v_hwaddr); @@ -397,19 +397,19 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us static gboolean _get_config_metadata_ready_check(long response_code, - GBytes * response, + GBytes *response, gpointer check_user_data, GError **error) { NMCSProviderGetConfigTaskData *get_config_data = check_user_data; gs_unref_hashtable GHashTable *response_parsed = NULL; - const guint8 * r_data; - const char * cur_line; + const guint8 *r_data; + const char *cur_line; gsize r_len; gsize cur_line_len; GHashTableIter h_iter; gboolean has_all; - const char * c_hwaddr; + const char *c_hwaddr; gssize iface_idx_counter = 0; if (response_code != 200 || !response) { @@ -423,7 +423,7 @@ _get_config_metadata_ready_check(long response_code, while (nm_utils_parse_next_line((const char **) &r_data, &r_len, &cur_line, &cur_line_len)) { GetConfigMetadataMac *mac_data; - char * hwaddr; + char *hwaddr; if (cur_line_len == 0) continue; diff --git a/src/nm-cloud-setup/nmcs-provider-azure.c b/src/nm-cloud-setup/nmcs-provider-azure.c index b3f0c68ba6..06f23ea73e 100644 --- a/src/nm-cloud-setup/nmcs-provider-azure.c +++ b/src/nm-cloud-setup/nmcs-provider-azure.c @@ -38,9 +38,9 @@ G_DEFINE_TYPE(NMCSProviderAzure, nmcs_provider_azure, NMCS_TYPE_PROVIDER); static void _detect_get_meta_data_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_object GTask *task = user_data; - gs_free_error GError *get_error = NULL; - gs_free_error GError *error = NULL; + gs_unref_object GTask *task = user_data; + gs_free_error GError *get_error = NULL; + gs_free_error GError *error = NULL; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, NULL, &get_error); @@ -92,7 +92,7 @@ typedef enum { } GetConfigFetchType; typedef struct { - NMCSProviderGetConfigTaskData * get_config_data; + NMCSProviderGetConfigTaskData *get_config_data; NMCSProviderGetConfigIfaceData *iface_get_config; gssize intern_iface_idx; gssize extern_iface_idx; @@ -106,20 +106,20 @@ _azure_iface_data_destroy(AzureIfaceData *iface_data) } static void -_get_config_fetch_done_cb(NMHttpClient * http_client, - GAsyncResult * result, - AzureIfaceData * iface_data, +_get_config_fetch_done_cb(NMHttpClient *http_client, + GAsyncResult *result, + AzureIfaceData *iface_data, GetConfigFetchType fetch_type) { - NMCSProviderGetConfigTaskData * get_config_data; + NMCSProviderGetConfigTaskData *get_config_data; NMCSProviderGetConfigIfaceData *iface_get_config; - gs_unref_bytes GBytes *response = NULL; - gs_free_error GError *error = NULL; - const char * resp_str = NULL; - gsize resp_len; - char tmp_addr_str[NM_UTILS_INET_ADDRSTRLEN]; - in_addr_t tmp_addr; - int tmp_prefix = -1; + gs_unref_bytes GBytes *response = NULL; + gs_free_error GError *error = NULL; + const char *resp_str = NULL; + gsize resp_len; + char tmp_addr_str[NM_UTILS_INET_ADDRSTRLEN]; + in_addr_t tmp_addr; + int tmp_prefix = -1; nm_http_client_poll_get_finish(http_client, result, NULL, &response, &error); @@ -196,7 +196,7 @@ out_done: } static void -_get_config_fetch_done_cb_ipv4_ipaddress_x_privateipaddress(GObject * source, +_get_config_fetch_done_cb_ipv4_ipaddress_x_privateipaddress(GObject *source, GAsyncResult *result, gpointer user_data) { @@ -207,7 +207,7 @@ _get_config_fetch_done_cb_ipv4_ipaddress_x_privateipaddress(GObject * source } static void -_get_config_fetch_done_cb_ipv4_subnet_0_address(GObject * source, +_get_config_fetch_done_cb_ipv4_subnet_0_address(GObject *source, GAsyncResult *result, gpointer user_data) { @@ -218,7 +218,7 @@ _get_config_fetch_done_cb_ipv4_subnet_0_address(GObject * source, } static void -_get_config_fetch_done_cb_ipv4_subnet_0_prefix(GObject * source, +_get_config_fetch_done_cb_ipv4_subnet_0_prefix(GObject *source, GAsyncResult *result, gpointer user_data) { @@ -231,13 +231,13 @@ _get_config_fetch_done_cb_ipv4_subnet_0_prefix(GObject * source, static void _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_bytes GBytes *response = NULL; - AzureIfaceData * iface_data = user_data; - gs_free_error GError * error = NULL; - const char * response_str = NULL; + gs_unref_bytes GBytes *response = NULL; + AzureIfaceData *iface_data = user_data; + gs_free_error GError *error = NULL; + const char *response_str = NULL; gsize response_len; NMCSProviderGetConfigTaskData *get_config_data; - const char * line; + const char *line; gsize line_len; char iface_idx_str[30]; @@ -350,12 +350,12 @@ static void _get_config_iface_cb(GObject *source, GAsyncResult *result, gpointer user_data) { NMCSProviderGetConfigTaskData *get_config_data; - gs_unref_bytes GBytes *response = NULL; - AzureIfaceData * iface_data = user_data; - gs_free char * v_hwaddr = NULL; - gs_free_error GError *error = NULL; - gs_free const char * uri = NULL; - char buf[100]; + gs_unref_bytes GBytes *response = NULL; + AzureIfaceData *iface_data = user_data; + gs_free char *v_hwaddr = NULL; + gs_free_error GError *error = NULL; + gs_free const char *uri = NULL; + char buf[100]; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, &response, &error); @@ -433,15 +433,15 @@ static void _get_net_ifaces_list_cb(GObject *source, GAsyncResult *result, gpointer user_data) { NMCSProviderGetConfigTaskData *get_config_data; - gs_unref_ptrarray GPtrArray *ifaces_arr = NULL; - gs_unref_bytes GBytes *response = NULL; - gs_free_error GError *error = NULL; - const char * response_str; - gsize response_len; - const char * line; - gsize line_len; - guint i; - gssize extern_iface_idx_cnt = 0; + gs_unref_ptrarray GPtrArray *ifaces_arr = NULL; + gs_unref_bytes GBytes *response = NULL; + gs_free_error GError *error = NULL; + const char *response_str; + gsize response_len; + const char *line; + gsize line_len; + guint i; + gssize extern_iface_idx_cnt = 0; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, &response, &error); @@ -500,7 +500,7 @@ _get_net_ifaces_list_cb(GObject *source, GAsyncResult *result, gpointer user_dat } for (i = 0; i < ifaces_arr->len; ++i) { - AzureIfaceData * iface_data = ifaces_arr->pdata[i]; + AzureIfaceData *iface_data = ifaces_arr->pdata[i]; gs_free const char *uri = NULL; char buf[100]; diff --git a/src/nm-cloud-setup/nmcs-provider-ec2.c b/src/nm-cloud-setup/nmcs-provider-ec2.c index 96b0880752..ee4e2a95fa 100644 --- a/src/nm-cloud-setup/nmcs-provider-ec2.c +++ b/src/nm-cloud-setup/nmcs-provider-ec2.c @@ -20,7 +20,7 @@ static const char * _ec2_base(void) { static const char *base_cached = NULL; - const char * base; + const char *base; again: base = g_atomic_pointer_get(&base_cached); @@ -58,7 +58,7 @@ G_DEFINE_TYPE(NMCSProviderEC2, nmcs_provider_ec2, NMCS_TYPE_PROVIDER); static gboolean _detect_get_meta_data_check_cb(long response_code, - GBytes * response, + GBytes *response, gpointer check_user_data, GError **error) { @@ -68,9 +68,9 @@ _detect_get_meta_data_check_cb(long response_code, static void _detect_get_meta_data_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_object GTask *task = user_data; - gs_free_error GError *get_error = NULL; - gs_free_error GError *error = NULL; + gs_unref_object GTask *task = user_data; + gs_free_error GError *get_error = NULL; + gs_free_error GError *error = NULL; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, NULL, &get_error); @@ -121,9 +121,9 @@ _get_config_fetch_done_cb(NMHttpClient *http_client, gpointer user_data, gboolean is_local_ipv4) { - NMCSProviderGetConfigTaskData *get_config_data; - gs_unref_bytes GBytes *response = NULL; - gs_free_error GError * error = NULL; + NMCSProviderGetConfigTaskData *get_config_data; + gs_unref_bytes GBytes *response = NULL; + gs_free_error GError *error = NULL; NMCSProviderGetConfigIfaceData *config_iface_data; in_addr_t tmp_addr; int tmp_prefix; @@ -178,7 +178,7 @@ out: } static void -_get_config_fetch_done_cb_subnet_ipv4_cidr_block(GObject * source, +_get_config_fetch_done_cb_subnet_ipv4_cidr_block(GObject *source, GAsyncResult *result, gpointer user_data) { @@ -201,11 +201,11 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us { NMCSProviderGetConfigTaskData *get_config_data; gs_unref_hashtable GHashTable *response_parsed = NULL; - gs_free_error GError *error = NULL; - GetConfigMetadataMac *v_mac_data; - const char * v_hwaddr; - GHashTableIter h_iter; - NMHttpClient * http_client; + gs_free_error GError *error = NULL; + GetConfigMetadataMac *v_mac_data; + const char *v_hwaddr; + GHashTableIter h_iter; + NMHttpClient *http_client; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, NULL, &error); @@ -231,8 +231,8 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us g_hash_table_iter_init(&h_iter, response_parsed); while (g_hash_table_iter_next(&h_iter, (gpointer *) &v_hwaddr, (gpointer *) &v_mac_data)) { NMCSProviderGetConfigIfaceData *config_iface_data; - gs_free char * uri1 = NULL; - gs_free char * uri2 = NULL; + gs_free char *uri1 = NULL; + gs_free char *uri2 = NULL; config_iface_data = g_hash_table_lookup(get_config_data->result_dict, v_hwaddr); @@ -298,19 +298,19 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us static gboolean _get_config_metadata_ready_check(long response_code, - GBytes * response, + GBytes *response, gpointer check_user_data, GError **error) { NMCSProviderGetConfigTaskData *get_config_data = check_user_data; gs_unref_hashtable GHashTable *response_parsed = NULL; - const guint8 * r_data; - const char * cur_line; + const guint8 *r_data; + const char *cur_line; gsize r_len; gsize cur_line_len; GHashTableIter h_iter; gboolean has_all; - const char * c_hwaddr; + const char *c_hwaddr; gssize iface_idx_counter = 0; if (response_code != 200 || !response) { @@ -324,7 +324,7 @@ _get_config_metadata_ready_check(long response_code, while (nm_utils_parse_next_line((const char **) &r_data, &r_len, &cur_line, &cur_line_len)) { GetConfigMetadataMac *mac_data; - char * hwaddr; + char *hwaddr; if (cur_line_len == 0) continue; diff --git a/src/nm-cloud-setup/nmcs-provider-gcp.c b/src/nm-cloud-setup/nmcs-provider-gcp.c index 60425ad978..0df2bdd607 100644 --- a/src/nm-cloud-setup/nmcs-provider-gcp.c +++ b/src/nm-cloud-setup/nmcs-provider-gcp.c @@ -41,9 +41,9 @@ G_DEFINE_TYPE(NMCSProviderGCP, nmcs_provider_gcp, NMCS_TYPE_PROVIDER); static void _detect_get_meta_data_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_object GTask *task = user_data; - gs_free_error GError *get_error = NULL; - gs_free_error GError *error = NULL; + gs_unref_object GTask *task = user_data; + gs_free_error GError *get_error = NULL; + gs_free_error GError *error = NULL; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, NULL, &get_error); @@ -89,7 +89,7 @@ detect(NMCSProvider *provider, GTask *task) /*****************************************************************************/ typedef struct { - NMCSProviderGetConfigTaskData * get_config_data; + NMCSProviderGetConfigTaskData *get_config_data; NMCSProviderGetConfigIfaceData *iface_get_config; gssize intern_iface_idx; gssize extern_iface_idx; @@ -105,14 +105,14 @@ _gcp_iface_data_destroy(GCPIfaceData *iface_data) static void _get_config_fip_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NMCSProviderGetConfigTaskData * get_config_data; + NMCSProviderGetConfigTaskData *get_config_data; NMCSProviderGetConfigIfaceData *iface_get_config; - gs_unref_bytes GBytes *response = NULL; - GCPIfaceData * iface_data = user_data; - gs_free_error GError *error = NULL; - gs_free char * ipaddr = NULL; - NMIPRoute ** routes_arr; - NMIPRoute * route_new; + gs_unref_bytes GBytes *response = NULL; + GCPIfaceData *iface_data = user_data; + gs_free_error GError *error = NULL; + gs_free char *ipaddr = NULL; + NMIPRoute **routes_arr; + NMIPRoute *route_new; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, &response, &error); @@ -161,15 +161,15 @@ static void _get_config_ips_list_cb(GObject *source, GAsyncResult *result, gpointer user_data) { NMCSProviderGetConfigTaskData *get_config_data; - gs_unref_ptrarray GPtrArray *uri_arr = NULL; - gs_unref_bytes GBytes *response = NULL; - GCPIfaceData * iface_data = user_data; - gs_free_error GError *error = NULL; - const char * response_str = NULL; - gsize response_len; - const char * line; - gsize line_len; - guint i; + gs_unref_ptrarray GPtrArray *uri_arr = NULL; + gs_unref_bytes GBytes *response = NULL; + GCPIfaceData *iface_data = user_data; + gs_free_error GError *error = NULL; + const char *response_str = NULL; + gsize response_len; + const char *line; + gsize line_len; + guint i; nm_http_client_poll_get_finish(NM_HTTP_CLIENT(source), result, NULL, &response, &error); @@ -217,7 +217,7 @@ _get_config_ips_list_cb(GObject *source, GAsyncResult *result, gpointer user_dat iface_data->iface_get_config->iproutes_arr = g_new(NMIPRoute *, iface_data->n_fips_pending); for (i = 0; i < uri_arr->len; ++i) { - const char * str = uri_arr->pdata[i]; + const char *str = uri_arr->pdata[i]; gs_free const char *uri = NULL; nm_http_client_poll_get(NM_HTTP_CLIENT(source), @@ -243,11 +243,11 @@ out_error: static void _get_config_iface_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_bytes GBytes *response = NULL; - GCPIfaceData * iface_data = user_data; - gs_free_error GError * error = NULL; - gs_free char * v_hwaddr = NULL; - gs_free const char * uri = NULL; + gs_unref_bytes GBytes *response = NULL; + GCPIfaceData *iface_data = user_data; + gs_free_error GError *error = NULL; + gs_free char *v_hwaddr = NULL; + gs_free const char *uri = NULL; char sbuf[100]; NMCSProviderGetConfigTaskData *get_config_data; gboolean is_requested; @@ -330,13 +330,13 @@ out_done: static void _get_net_ifaces_list_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - gs_unref_ptrarray GPtrArray *ifaces_arr = NULL; - gs_unref_bytes GBytes *response = NULL; - gs_free_error GError * error = NULL; + gs_unref_ptrarray GPtrArray *ifaces_arr = NULL; + gs_unref_bytes GBytes *response = NULL; + gs_free_error GError *error = NULL; NMCSProviderGetConfigTaskData *get_config_data; - const char * response_str; + const char *response_str; gsize response_len; - const char * line; + const char *line; gsize line_len; guint i; gssize extern_iface_idx_cnt = 0; @@ -397,7 +397,7 @@ _get_net_ifaces_list_cb(GObject *source, GAsyncResult *result, gpointer user_dat } for (i = 0; i < ifaces_arr->len; ++i) { - GCPIfaceData * data = ifaces_arr->pdata[i]; + GCPIfaceData *data = ifaces_arr->pdata[i]; gs_free const char *uri = NULL; char sbuf[100]; diff --git a/src/nm-cloud-setup/nmcs-provider.c b/src/nm-cloud-setup/nmcs-provider.c index 138e78d41b..f14a3d0272 100644 --- a/src/nm-cloud-setup/nmcs-provider.c +++ b/src/nm-cloud-setup/nmcs-provider.c @@ -68,11 +68,11 @@ static NMCSProviderGetConfigResult * nmcs_provider_get_config_result_new(GHashTable *iface_datas) { const NMCSProviderGetConfigIfaceData *iface_data; - NMCSProviderGetConfigResult * result; + NMCSProviderGetConfigResult *result; GHashTableIter h_iter; guint num_valid_ifaces = 0; guint num_ipv4s = 0; - GPtrArray * ptrarr; + GPtrArray *ptrarr; guint n_iface_datas; n_iface_datas = g_hash_table_size(iface_datas); @@ -137,13 +137,13 @@ nmcs_provider_get_config_result_free(NMCSProviderGetConfigResult *result) /*****************************************************************************/ void -nmcs_provider_detect(NMCSProvider * self, - GCancellable * cancellable, +nmcs_provider_detect(NMCSProvider *self, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { gs_unref_object GTask *task = NULL; - const char * env; + const char *env; g_return_if_fail(NMCS_IS_PROVIDER(self)); g_return_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable)); @@ -251,7 +251,7 @@ _get_config_task_maybe_return(NMCSProviderGetConfigTaskData *get_config_data, GE void _nmcs_provider_get_config_task_maybe_return(NMCSProviderGetConfigTaskData *get_config_data, - GError * error_take) + GError *error_take) { nm_assert(!error_take || !nm_utils_error_is_cancelled(error_take)); _get_config_task_maybe_return(get_config_data, error_take); @@ -264,10 +264,10 @@ _get_config_cancelled_cb(GObject *object, gpointer user_data) } void -nmcs_provider_get_config(NMCSProvider * self, +nmcs_provider_get_config(NMCSProvider *self, gboolean any, - const char *const * hwaddrs, - GCancellable * cancellable, + const char *const *hwaddrs, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -351,7 +351,7 @@ nmcs_provider_init(NMCSProvider *self) static void dispose(GObject *object) { - NMCSProvider * self = NMCS_PROVIDER(object); + NMCSProvider *self = NMCS_PROVIDER(object); NMCSProviderPrivate *priv = NMCS_PROVIDER_GET_PRIVATE(self); g_clear_object(&priv->http_client); diff --git a/src/nm-cloud-setup/nmcs-provider.h b/src/nm-cloud-setup/nmcs-provider.h index 3663205964..bce41dcb82 100644 --- a/src/nm-cloud-setup/nmcs-provider.h +++ b/src/nm-cloud-setup/nmcs-provider.h @@ -125,8 +125,8 @@ typedef struct { typedef struct { GObjectClass parent; - const char * _name; - const char * _env_provider_enabled; + const char *_name; + const char *_env_provider_enabled; void (*detect)(NMCSProvider *self, GTask *task); @@ -145,8 +145,8 @@ GMainContext *nmcs_provider_get_main_context(NMCSProvider *provider); /*****************************************************************************/ -void nmcs_provider_detect(NMCSProvider * provider, - GCancellable * cancellable, +void nmcs_provider_detect(NMCSProvider *provider, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -155,12 +155,12 @@ gboolean nmcs_provider_detect_finish(NMCSProvider *provider, GAsyncResult *resul /*****************************************************************************/ void _nmcs_provider_get_config_task_maybe_return(NMCSProviderGetConfigTaskData *get_config_data, - GError * error_take); + GError *error_take); -void nmcs_provider_get_config(NMCSProvider * provider, +void nmcs_provider_get_config(NMCSProvider *provider, gboolean any, - const char *const * hwaddrs, - GCancellable * cancellable, + const char *const *hwaddrs, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); diff --git a/src/nm-cloud-setup/tests/test-cloud-setup-general.c b/src/nm-cloud-setup/tests/test-cloud-setup-general.c index 82df4e1737..c863500931 100644 --- a/src/nm-cloud-setup/tests/test-cloud-setup-general.c +++ b/src/nm-cloud-setup/tests/test-cloud-setup-general.c @@ -41,10 +41,10 @@ static void _test_ri4a(const char *const *addrs_before, const char *const *addrs_new) { gs_unref_object NMSettingIPConfig *s_ip = NULL; - gs_unref_ptrarray GPtrArray *arr = NULL; - const gsize n = NM_PTRARRAY_LEN(addrs_new); - gboolean changed; - gsize i; + gs_unref_ptrarray GPtrArray *arr = NULL; + const gsize n = NM_PTRARRAY_LEN(addrs_new); + gboolean changed; + gsize i; s_ip = _ri4a_new_s_ip(addrs_before); arr = _ri4a_new_arr(addrs_new); diff --git a/src/nm-dispatcher/nm-dispatcher-utils.c b/src/nm-dispatcher/nm-dispatcher-utils.c index f754a3fa70..74ea4e4001 100644 --- a/src/nm-dispatcher/nm-dispatcher-utils.c +++ b/src/nm-dispatcher/nm-dispatcher-utils.c @@ -131,7 +131,7 @@ static void _items_add_printf(GPtrArray *items, const char *fmt, ...) { va_list ap; - char * line; + char *line; nm_assert(items); nm_assert(fmt); @@ -225,8 +225,8 @@ construct_ip_items(GPtrArray *items, int addr_family, GVariant *ip_config, const : G_VARIANT_TYPE("a(ayuay)")); if (val) { gs_unref_ptrarray GPtrArray *addresses = NULL; - gs_free char * gateway_free = NULL; - const char * gateway; + gs_free char *gateway_free = NULL; + const char *gateway; if (addr_family == AF_INET) addresses = nm_utils_ip4_addresses_from_variant(val, &gateway_free); @@ -346,12 +346,12 @@ construct_ip_items(GPtrArray *items, int addr_family, GVariant *ip_config, const static void construct_device_dhcp_items(GPtrArray *items, int addr_family, GVariant *dhcp_config) { - GVariantIter iter; - const char * key; - GVariant * val; - char four_or_six; - gboolean found_unknown_245 = FALSE; - gs_unref_variant GVariant *private_245_val = NULL; + GVariantIter iter; + const char *key; + GVariant *val; + char four_or_six; + gboolean found_unknown_245 = FALSE; + gs_unref_variant GVariant *private_245_val = NULL; if (!dhcp_config) return; @@ -415,34 +415,34 @@ construct_device_dhcp_items(GPtrArray *items, int addr_family, GVariant *dhcp_co /*****************************************************************************/ char ** -nm_dispatcher_utils_construct_envp(const char * action, - GVariant * connection_dict, - GVariant * connection_props, - GVariant * device_props, - GVariant * device_proxy_props, - GVariant * device_ip4_props, - GVariant * device_ip6_props, - GVariant * device_dhcp4_props, - GVariant * device_dhcp6_props, - const char * connectivity_state, - const char * vpn_ip_iface, - GVariant * vpn_proxy_props, - GVariant * vpn_ip4_props, - GVariant * vpn_ip6_props, - char ** out_iface, +nm_dispatcher_utils_construct_envp(const char *action, + GVariant *connection_dict, + GVariant *connection_props, + GVariant *device_props, + GVariant *device_proxy_props, + GVariant *device_ip4_props, + GVariant *device_ip6_props, + GVariant *device_dhcp4_props, + GVariant *device_dhcp6_props, + const char *connectivity_state, + const char *vpn_ip_iface, + GVariant *vpn_proxy_props, + GVariant *vpn_ip4_props, + GVariant *vpn_ip6_props, + char **out_iface, const char **out_error_message) { - const char * iface = NULL; - const char * ip_iface = NULL; - const char * uuid = NULL; - const char * id = NULL; - const char * path = NULL; - const char * filename = NULL; - gboolean external; - NMDeviceState dev_state = NM_DEVICE_STATE_UNKNOWN; - GVariant * variant; + const char *iface = NULL; + const char *ip_iface = NULL; + const char *uuid = NULL; + const char *id = NULL; + const char *path = NULL; + const char *filename = NULL; + gboolean external; + NMDeviceState dev_state = NM_DEVICE_STATE_UNKNOWN; + GVariant *variant; gs_unref_ptrarray GPtrArray *items = NULL; - const char * error_message_backup; + const char *error_message_backup; if (!out_error_message) out_error_message = &error_message_backup; diff --git a/src/nm-dispatcher/nm-dispatcher-utils.h b/src/nm-dispatcher/nm-dispatcher-utils.h index cb40d14628..b9e9b2c1f4 100644 --- a/src/nm-dispatcher/nm-dispatcher-utils.h +++ b/src/nm-dispatcher/nm-dispatcher-utils.h @@ -6,21 +6,21 @@ #ifndef __NETWORKMANAGER_DISPATCHER_UTILS_H__ #define __NETWORKMANAGER_DISPATCHER_UTILS_H__ -char **nm_dispatcher_utils_construct_envp(const char * action, - GVariant * connection_dict, - GVariant * connection_props, - GVariant * device_props, - GVariant * device_proxy_props, - GVariant * device_ip4_props, - GVariant * device_ip6_props, - GVariant * device_dhcp4_props, - GVariant * device_dhcp6_props, - const char * connectivity_state, - const char * vpn_ip_iface, - GVariant * vpn_proxy_props, - GVariant * vpn_ip4_props, - GVariant * vpn_ip6_props, - char ** out_iface, +char **nm_dispatcher_utils_construct_envp(const char *action, + GVariant *connection_dict, + GVariant *connection_props, + GVariant *device_props, + GVariant *device_proxy_props, + GVariant *device_ip4_props, + GVariant *device_ip6_props, + GVariant *device_dhcp4_props, + GVariant *device_dhcp6_props, + const char *connectivity_state, + const char *vpn_ip_iface, + GVariant *vpn_proxy_props, + GVariant *vpn_ip4_props, + GVariant *vpn_ip6_props, + char **out_iface, const char **out_error_message); #endif /* __NETWORKMANAGER_DISPATCHER_UTILS_H__ */ diff --git a/src/nm-dispatcher/nm-dispatcher.c b/src/nm-dispatcher/nm-dispatcher.c index b29f5acaca..aeecaa9b22 100644 --- a/src/nm-dispatcher/nm-dispatcher.c +++ b/src/nm-dispatcher/nm-dispatcher.c @@ -35,7 +35,7 @@ typedef struct Request Request; typedef struct { GDBusConnection *dbus_connection; - GCancellable * quit_cancellable; + GCancellable *quit_cancellable; bool log_verbose; bool log_stdout; @@ -50,7 +50,7 @@ typedef struct { gboolean persist; Request *current_request; - GQueue * requests_waiting; + GQueue *requests_waiting; int num_requests_pending; bool exit_with_failure; @@ -67,23 +67,23 @@ GlobalData gl; typedef struct { Request *request; - char * script; + char *script; GPid pid; DispatchResult result; - char * error; + char *error; gboolean wait; gboolean dispatched; - GSource * watch_source; - GSource * timeout_source; + GSource *watch_source; + GSource *timeout_source; } ScriptInfo; struct Request { guint request_id; GDBusMethodInvocation *context; - char * action; - char * iface; - char ** envp; + char *action; + char *iface; + char **envp; gboolean debug; GPtrArray *scripts; /* list of ScriptInfo */ @@ -293,7 +293,7 @@ static void complete_request(Request *request) { GVariantBuilder results; - GVariant * ret; + GVariant *ret; guint i; nm_assert(request); @@ -397,7 +397,7 @@ complete_script(ScriptInfo *script) static void script_watch_cb(GPid pid, int status, gpointer user_data) { - ScriptInfo * script = user_data; + ScriptInfo *script = user_data; gs_free char *status_desc = NULL; g_assert(pid == script->pid); @@ -518,8 +518,8 @@ static gboolean script_dispatch(ScriptInfo *script) { gs_free_error GError *error = NULL; - char * argv[4]; - Request * request = script->request; + char *argv[4]; + Request *request = script->request; if (script->dispatched) return FALSE; @@ -596,10 +596,10 @@ _compare_basenames(gconstpointer a, gconstpointer b) static void _find_scripts(Request *request, GHashTable *scripts, const char *base, const char *subdir) { - const char * filename; + const char *filename; gs_free char *dirname = NULL; - GError * error = NULL; - GDir * dir; + GError *error = NULL; + GDir *dir; dirname = g_build_filename(base, "dispatcher.d", subdir, NULL); @@ -628,11 +628,11 @@ static GSList * find_scripts(Request *request) { gs_unref_hashtable GHashTable *scripts = NULL; - GSList * script_list = NULL; + GSList *script_list = NULL; GHashTableIter iter; - const char * subdir; - char * path; - char * filename; + const char *subdir; + char *path; + char *filename; if (NM_IN_STRSET(request->action, NMD_ACTION_PRE_UP, NMD_ACTION_VPN_PRE_UP)) subdir = "pre-up.d"; @@ -649,7 +649,7 @@ find_scripts(Request *request) g_hash_table_iter_init(&iter, scripts); while (g_hash_table_iter_next(&iter, (gpointer *) &filename, (gpointer *) &path)) { gs_free char *link_target = NULL; - const char * err_msg = NULL; + const char *err_msg = NULL; struct stat st; int err; @@ -681,7 +681,7 @@ script_must_wait(const char *path) link = g_file_read_link(path, NULL); if (link) { - gs_free char * dir = NULL; + gs_free char *dir = NULL; nm_auto_free char *real = NULL; if (!g_path_is_absolute(link)) { @@ -706,7 +706,7 @@ script_must_wait(const char *path) static void _handle_action(GDBusMethodInvocation *invocation, GVariant *parameters) { - const char * action; + const char *action; gs_unref_variant GVariant *connection = NULL; gs_unref_variant GVariant *connection_properties = NULL; gs_unref_variant GVariant *device_properties = NULL; @@ -715,18 +715,18 @@ _handle_action(GDBusMethodInvocation *invocation, GVariant *parameters) gs_unref_variant GVariant *device_ip6_config = NULL; gs_unref_variant GVariant *device_dhcp4_config = NULL; gs_unref_variant GVariant *device_dhcp6_config = NULL; - const char * connectivity_state; - const char * vpn_ip_iface; + const char *connectivity_state; + const char *vpn_ip_iface; gs_unref_variant GVariant *vpn_proxy_properties = NULL; gs_unref_variant GVariant *vpn_ip4_config = NULL; gs_unref_variant GVariant *vpn_ip6_config = NULL; gboolean debug; - GSList * sorted_scripts = NULL; - GSList * iter; - Request * request; - char ** p; + GSList *sorted_scripts = NULL; + GSList *iter; + Request *request; + char **p; guint i, num_nowait = 0; - const char * error_message = NULL; + const char *error_message = NULL; g_variant_get(parameters, "(" @@ -872,7 +872,7 @@ _handle_ping(GDBusMethodInvocation *invocation, GVariant *parameters) { gs_free char *msg = NULL; gint64 running_msec; - const char * arg_s; + const char *arg_s; g_variant_get(parameters, "(&s)", &arg_s); @@ -888,12 +888,12 @@ _handle_ping(GDBusMethodInvocation *invocation, GVariant *parameters) } static void -_bus_method_call(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_bus_method_call(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -955,9 +955,9 @@ _bus_register_service(void) static const GDBusInterfaceVTable interface_vtable = { .method_call = _bus_method_call, }; - gs_free_error GError * error = NULL; + gs_free_error GError *error = NULL; NMDBusConnectionCallBlockingData data = { - .result = NULL, + .result = NULL, }; gs_unref_variant GVariant *ret = NULL; guint32 ret_val; @@ -1185,8 +1185,8 @@ int main(int argc, char **argv) { gs_free_error GError *error = NULL; - GSource * source_term = NULL; - GSource * source_int = NULL; + GSource *source_term = NULL; + GSource *source_int = NULL; signal(SIGPIPE, SIG_IGN); source_term = diff --git a/src/nm-dispatcher/tests/test-dispatcher-envp.c b/src/nm-dispatcher/tests/test-dispatcher-envp.c index 8a24c426db..f53bb1c137 100644 --- a/src/nm-dispatcher/tests/test-dispatcher-envp.c +++ b/src/nm-dispatcher/tests/test-dispatcher-envp.c @@ -24,7 +24,7 @@ _print_env(const char *const *denv, GHashTable *expected_env) { const char *const *iter; GHashTableIter k; - const char * key; + const char *key; g_print("\n******* Generated environment:\n"); for (iter = denv; iter && *iter; iter++) @@ -37,22 +37,22 @@ _print_env(const char *const *denv, GHashTable *expected_env) } static gboolean -parse_main(GKeyFile * kf, +parse_main(GKeyFile *kf, const char *filename, - GVariant ** out_con_dict, - GVariant ** out_con_props, - char ** out_expected_iface, - char ** out_action, - char ** out_connectivity_state, - char ** out_vpn_ip_iface, - GError ** error) + GVariant **out_con_dict, + GVariant **out_con_props, + char **out_expected_iface, + char **out_action, + char **out_connectivity_state, + char **out_vpn_ip_iface, + GError **error) { - nm_auto_clear_variant_builder GVariantBuilder props = {}; - gs_free char * uuid = NULL; - gs_free char * id = NULL; - gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - const char * s; + nm_auto_clear_variant_builder GVariantBuilder props = {}; + gs_free char *uuid = NULL; + gs_free char *id = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + const char *s; *out_expected_iface = g_key_file_get_string(kf, "main", "expected-iface", NULL); @@ -108,7 +108,7 @@ static gboolean parse_device(GKeyFile *kf, GVariant **out_device_props, GError **error) { nm_auto_clear_variant_builder GVariantBuilder props = {}; - gs_free char * tmp = NULL; + gs_free char *tmp = NULL; int i; g_variant_builder_init(&props, G_VARIANT_TYPE("a{sv}")); @@ -145,13 +145,13 @@ parse_device(GKeyFile *kf, GVariant **out_device_props, GError **error) } static gboolean -add_uint_array(GKeyFile * kf, +add_uint_array(GKeyFile *kf, GVariantBuilder *props, - const char * section, - const char * key, - GError ** error) + const char *section, + const char *key, + GError **error) { - gs_free char * tmp = NULL; + gs_free char *tmp = NULL; gs_free const char **split = NULL; gsize i; @@ -193,7 +193,7 @@ static gboolean parse_proxy(GKeyFile *kf, GVariant **out_props, const char *section, GError **error) { nm_auto_clear_variant_builder GVariantBuilder props = {}; - gs_free char * tmp = NULL; + gs_free char *tmp = NULL; g_variant_builder_init(&props, G_VARIANT_TYPE("a{sv}")); @@ -216,9 +216,9 @@ static gboolean parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **error) { nm_auto_clear_variant_builder GVariantBuilder props = {}; - gs_free char * tmp = NULL; - gs_free const char ** split = NULL; - const char ** iter; + gs_free char *tmp = NULL; + gs_free const char **split = NULL; + const char **iter; g_variant_builder_init(&props, G_VARIANT_TYPE("a{sv}")); @@ -250,14 +250,14 @@ parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **erro split = nm_strsplit_set_with_empty(tmp, ","); if (split) { gs_unref_ptrarray GPtrArray *addresses = NULL; - const char * gateway = NULL; + const char *gateway = NULL; addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref); for (iter = split; *iter; iter++) { - const char * s = *iter; + const char *s = *iter; NMIPAddress *addr; - const char * ip; - const char * prefix; + const char *ip; + const char *prefix; g_strstrip((char *) s); if (s[0] == '\0') @@ -298,7 +298,7 @@ parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **erro routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref); for (iter = split; *iter; iter++) { const char *s = *iter; - NMIPRoute * route; + NMIPRoute *route; const char *dest; const char *prefix; const char *next_hop; @@ -344,8 +344,8 @@ static gboolean parse_dhcp(GKeyFile *kf, const char *group_name, GVariant **out_props, GError **error) { nm_auto_clear_variant_builder GVariantBuilder props = {}; - gs_strfreev char ** keys = NULL; - char ** iter; + gs_strfreev char **keys = NULL; + char **iter; keys = g_key_file_get_keys(kf, group_name, NULL, error); if (!keys) @@ -366,28 +366,28 @@ parse_dhcp(GKeyFile *kf, const char *group_name, GVariant **out_props, GError ** } static gboolean -get_dispatcher_file(const char * file, - GVariant ** out_con_dict, - GVariant ** out_con_props, - GVariant ** out_device_props, - GVariant ** out_device_proxy_props, - GVariant ** out_device_ip4_props, - GVariant ** out_device_ip6_props, - GVariant ** out_device_dhcp4_props, - GVariant ** out_device_dhcp6_props, - char ** out_connectivity_state, - char ** out_vpn_ip_iface, - GVariant ** out_vpn_proxy_props, - GVariant ** out_vpn_ip4_props, - GVariant ** out_vpn_ip6_props, - char ** out_expected_iface, - char ** out_action, +get_dispatcher_file(const char *file, + GVariant **out_con_dict, + GVariant **out_con_props, + GVariant **out_device_props, + GVariant **out_device_proxy_props, + GVariant **out_device_ip4_props, + GVariant **out_device_ip6_props, + GVariant **out_device_dhcp4_props, + GVariant **out_device_dhcp6_props, + char **out_connectivity_state, + char **out_vpn_ip_iface, + GVariant **out_vpn_proxy_props, + GVariant **out_vpn_ip4_props, + GVariant **out_vpn_ip6_props, + char **out_expected_iface, + char **out_action, GHashTable **out_env, - GError ** error) + GError **error) { nm_auto_unref_keyfile GKeyFile *kf = NULL; - gs_strfreev char ** keys = NULL; - char ** iter; + gs_strfreev char **keys = NULL; + char **iter; g_assert(!error || !*error); g_assert(out_con_dict && !*out_con_dict); @@ -465,29 +465,29 @@ get_dispatcher_file(const char * file, static void test_generic(const char *file, const char *override_vpn_ip_iface) { - gs_unref_variant GVariant *con_dict = NULL; - gs_unref_variant GVariant *con_props = NULL; - gs_unref_variant GVariant *device_props = NULL; - gs_unref_variant GVariant *device_proxy_props = NULL; - gs_unref_variant GVariant *device_ip4_props = NULL; - gs_unref_variant GVariant *device_ip6_props = NULL; - gs_unref_variant GVariant *device_dhcp4_props = NULL; - gs_unref_variant GVariant *device_dhcp6_props = NULL; - gs_free char * connectivity_change = NULL; - gs_free char * vpn_ip_iface = NULL; - gs_unref_variant GVariant *vpn_proxy_props = NULL; - gs_unref_variant GVariant *vpn_ip4_props = NULL; - gs_unref_variant GVariant *vpn_ip6_props = NULL; - gs_free char * expected_iface = NULL; - gs_free char * action = NULL; - gs_free char * out_iface = NULL; - const char * error_message = NULL; - gs_unref_hashtable GHashTable *expected_env = NULL; - GError * error = NULL; + gs_unref_variant GVariant *con_dict = NULL; + gs_unref_variant GVariant *con_props = NULL; + gs_unref_variant GVariant *device_props = NULL; + gs_unref_variant GVariant *device_proxy_props = NULL; + gs_unref_variant GVariant *device_ip4_props = NULL; + gs_unref_variant GVariant *device_ip6_props = NULL; + gs_unref_variant GVariant *device_dhcp4_props = NULL; + gs_unref_variant GVariant *device_dhcp6_props = NULL; + gs_free char *connectivity_change = NULL; + gs_free char *vpn_ip_iface = NULL; + gs_unref_variant GVariant *vpn_proxy_props = NULL; + gs_unref_variant GVariant *vpn_ip4_props = NULL; + gs_unref_variant GVariant *vpn_ip6_props = NULL; + gs_free char *expected_iface = NULL; + gs_free char *action = NULL; + gs_free char *out_iface = NULL; + const char *error_message = NULL; + gs_unref_hashtable GHashTable *expected_env = NULL; + GError *error = NULL; gboolean success; - gs_free char * filename = NULL; - gs_strfreev char ** denv = NULL; - char ** iter; + gs_free char *filename = NULL; + gs_strfreev char **denv = NULL; + char **iter; filename = g_build_filename(TEST_DIR, file, NULL); success = get_dispatcher_file(filename, diff --git a/src/nm-initrd-generator/nm-initrd-generator.c b/src/nm-initrd-generator/nm-initrd-generator.c index b78808b210..1705e8fcae 100644 --- a/src/nm-initrd-generator/nm-initrd-generator.c +++ b/src/nm-initrd-generator/nm-initrd-generator.c @@ -28,14 +28,14 @@ static void output_conn(gpointer key, gpointer value, gpointer user_data) { - const char * basename = key; - NMConnection * connection = value; - char * connections_dir = user_data; - nm_auto_unref_keyfile GKeyFile *file = NULL; - gs_free char * data = NULL; - gs_free_error GError *error = NULL; - gsize len; - NMSetting * setting; + const char *basename = key; + NMConnection *connection = value; + char *connections_dir = user_data; + nm_auto_unref_keyfile GKeyFile *file = NULL; + gs_free char *data = NULL; + gs_free_error GError *error = NULL; + gsize len; + NMSetting *setting; setting = nm_setting_user_new(); nm_connection_add_setting(connection, setting); @@ -79,11 +79,11 @@ err_out: int main(int argc, char *argv[]) { - GHashTable * connections; - gs_free char * connections_dir = NULL; - gs_free char * initrd_dir = NULL; - gs_free char * sysfs_dir = NULL; - gs_free char * run_config_dir = NULL; + GHashTable *connections; + gs_free char *connections_dir = NULL; + gs_free char *initrd_dir = NULL; + gs_free char *sysfs_dir = NULL; + gs_free char *run_config_dir = NULL; gboolean dump_to_stdout = FALSE; gs_strfreev char **remaining = NULL; GOptionEntry option_entries[] = { @@ -125,10 +125,10 @@ main(int argc, char *argv[]) {G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, NULL}, {NULL}}; nm_auto_free_option_context GOptionContext *option_context = NULL; - gs_free_error GError *error = NULL; - gs_free char * hostname = NULL; - int errsv; - gint64 carrier_timeout_sec = 0; + gs_free_error GError *error = NULL; + gs_free char *hostname = NULL; + int errsv; + gint64 carrier_timeout_sec = 0; option_context = g_option_context_new( "-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] " @@ -207,7 +207,7 @@ main(int argc, char *argv[]) } if (carrier_timeout_sec != 0) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_free char * filename = NULL; + gs_free char *filename = NULL; keyfile = g_key_file_new(); g_key_file_set_list_separator(keyfile, NM_CONFIG_KEYFILE_LIST_SEPARATOR); diff --git a/src/nm-initrd-generator/nm-initrd-generator.h b/src/nm-initrd-generator/nm-initrd-generator.h index 2ec52a010a..dabf3201c0 100644 --- a/src/nm-initrd-generator/nm-initrd-generator.h +++ b/src/nm-initrd-generator/nm-initrd-generator.h @@ -38,9 +38,9 @@ nmi_ibft_update_connection_from_nic(NMConnection *connection, GHashTable *nic, G NMConnection *nmi_dt_reader_parse(const char *sysfs_dir); -GHashTable *nmi_cmdline_reader_parse(const char * sysfs_dir, +GHashTable *nmi_cmdline_reader_parse(const char *sysfs_dir, const char *const *argv, - char ** hostname, - gint64 * carrier_timeout_sec); + char **hostname, + gint64 *carrier_timeout_sec); #endif /* __NM_INITRD_GENERATOR_H__ */ diff --git a/src/nm-initrd-generator/nmi-cmdline-reader.c b/src/nm-initrd-generator/nmi-cmdline-reader.c index 8fafb08f53..77b2cfba73 100644 --- a/src/nm-initrd-generator/nmi-cmdline-reader.c +++ b/src/nm-initrd-generator/nmi-cmdline-reader.c @@ -27,18 +27,18 @@ /*****************************************************************************/ typedef struct { - GHashTable * hash; - GPtrArray * array; - GPtrArray * vlan_parents; - GHashTable * explicit_ip_connections; + GHashTable *hash; + GPtrArray *array; + GPtrArray *vlan_parents; + GHashTable *explicit_ip_connections; NMConnection *bootdev_connection; /* connection for bootdev=$ifname */ NMConnection *default_connection; /* connection not bound to any ifname */ - char * hostname; + char *hostname; /* Parameters to be set for all connections */ gboolean ignore_auto_dns; int dhcp_timeout; - char * dhcp4_vci; + char *dhcp4_vci; gint64 carrier_timeout_sec; } Reader; @@ -91,16 +91,16 @@ reader_add_connection(Reader *reader, const char *name, NMConnection *connection /* Returns a new connection owned by the reader */ static NMConnection * -reader_create_connection(Reader * reader, - const char * basename, - const char * id, - const char * ifname, - const char * mac, - const char * type_name, +reader_create_connection(Reader *reader, + const char *basename, + const char *id, + const char *ifname, + const char *mac, + const char *type_name, NMConnectionMultiConnect multi_connect) { NMConnection *connection; - NMSetting * setting; + NMSetting *setting; connection = reader_add_connection(reader, basename, nm_simple_connection_new()); @@ -195,14 +195,14 @@ reader_get_default_connection(Reader *reader) } static NMConnection * -reader_get_connection(Reader * reader, +reader_get_connection(Reader *reader, const char *iface_spec, const char *type_name, gboolean create_if_missing) { NMConnection *connection = NULL; - NMSetting * setting; - const char * ifname = NULL; + NMSetting *setting; + const char *ifname = NULL; gs_free char *mac = NULL; if (iface_spec) { @@ -216,7 +216,7 @@ reader_get_connection(Reader * reader, } if (!ifname && !mac) { - NMConnection * candidate; + NMConnection *candidate; NMSettingConnection *s_con; guint i; @@ -314,14 +314,14 @@ get_word(char **argument, const char separator) static void connection_set(NMConnection *connection, - const char * setting_name, - const char * property, - const char * value) + const char *setting_name, + const char *property, + const char *value) { - NMSetting * setting; - GType setting_type; + NMSetting *setting; + GType setting_type; nm_auto_unref_gtypeclass GObjectClass *object_class = NULL; - GParamSpec * spec; + GParamSpec *spec; setting_type = nm_setting_lookup_type(setting_name); object_class = g_type_class_ref(setting_type); @@ -355,20 +355,20 @@ static void reader_read_all_connections_from_fw(Reader *reader, const char *sysfs_dir) { gs_unref_hashtable GHashTable *ibft = NULL; - NMConnection * dt_connection; - const char * mac; - GHashTable * nic; - const char * index; - GError * error = NULL; + NMConnection *dt_connection; + const char *mac; + GHashTable *nic; + const char *index; + GError *error = NULL; guint i, length; - gs_free const char ** keys = NULL; + gs_free const char **keys = NULL; ibft = nmi_ibft_read(sysfs_dir); keys = nm_strdict_get_keys(ibft, TRUE, &length); for (i = 0; i < length; i++) { gs_unref_object NMConnection *connection = NULL; - gs_free char * name = NULL; + gs_free char *name = NULL; mac = keys[i]; nic = g_hash_table_lookup(ibft, mac); @@ -426,7 +426,7 @@ _parse_ip_method(const char *kind) "auto", "ibft", }; - gs_free char * kind_to_free = NULL; + gs_free char *kind_to_free = NULL; gs_free const char **strv = NULL; gsize i; @@ -512,26 +512,26 @@ _parse_ip_method(const char *kind) static void reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4 = NULL, *s_ip6 = NULL; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4 = NULL, *s_ip6 = NULL; gs_unref_hashtable GHashTable *ibft = NULL; - const char * tmp; - const char * tmp2; - const char * tmp3; - const char * kind; - const char * client_ip = NULL; - const char * peer = NULL; - const char * gateway_ip = NULL; - const char * netmask = NULL; - const char * client_hostname = NULL; - const char * iface_spec = NULL; - const char * mtu = NULL; - const char * macaddr = NULL; + const char *tmp; + const char *tmp2; + const char *tmp3; + const char *kind; + const char *client_ip = NULL; + const char *peer = NULL; + const char *gateway_ip = NULL; + const char *netmask = NULL; + const char *client_hostname = NULL; + const char *iface_spec = NULL; + const char *mtu = NULL; + const char *macaddr = NULL; int client_ip_family = AF_UNSPEC; int client_ip_prefix = -1; gboolean clear_ip4_required_timeout = TRUE; - const char * dns[2] = { + const char *dns[2] = { NULL, NULL, }; @@ -770,11 +770,11 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) } } else if (nm_streq(kind, "ibft")) { NMSettingWired *s_wired; - const char * mac = NULL; - const char * ifname; - gs_free char * mac_free = NULL; - gs_free char * address_path = NULL; - GHashTable * nic = NULL; + const char *mac = NULL; + const char *ifname; + gs_free char *mac_free = NULL; + gs_free char *address_path = NULL; + GHashTable *nic = NULL; if ((s_wired = nm_connection_get_setting_wired(connection)) && (mac = nm_setting_wired_get_mac_address(s_wired))) { @@ -857,14 +857,14 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) static void reader_parse_master(Reader *reader, char *argument, const char *type_name, const char *default_name) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - gs_free char * master_to_free = NULL; - const char * master; - char * slaves; - const char * slave; - char * opts; - const char * mtu = NULL; + gs_free char *master_to_free = NULL; + const char *master; + char *slaves; + const char *slave; + char *opts; + const char *mtu = NULL; master = get_word(&argument, ':'); if (!master) @@ -886,8 +886,8 @@ reader_parse_master(Reader *reader, char *argument, const char *type_name, const opts = get_word(&argument, ':'); while (opts && *opts) { gs_free_error GError *error = NULL; - char * opt; - const char * opt_name; + char *opt; + const char *opt_name; opt = get_word(&opts, ','); opt_name = get_word(&opt, '='); @@ -934,17 +934,17 @@ reader_add_routes(Reader *reader, GPtrArray *array) guint i; for (i = 0; i < array->len; i++) { - NMConnection * connection = NULL; - const char * net; - const char * gateway; - const char * interface; - int family = AF_UNSPEC; - NMIPAddr net_addr = {}; - NMIPAddr gateway_addr = {}; - int net_prefix = -1; - NMIPRoute * route; - NMSettingIPConfig *s_ip; - char * argument; + NMConnection *connection = NULL; + const char *net; + const char *gateway; + const char *interface; + int family = AF_UNSPEC; + NMIPAddr net_addr = {}; + NMIPAddr gateway_addr = {}; + int net_prefix = -1; + NMIPRoute *route; + NMSettingIPConfig *s_ip; + char *argument; gs_free_error GError *error = NULL; argument = array->pdata[i]; @@ -1010,11 +1010,11 @@ reader_add_routes(Reader *reader, GPtrArray *array) static void reader_parse_vlan(Reader *reader, char *argument) { - NMConnection * connection; + NMConnection *connection; NMSettingVlan *s_vlan; - const char * vlan; - const char * phy; - const char * vlanid; + const char *vlan; + const char *phy; + const char *vlanid; vlan = get_word(&argument, ':'); phy = get_word(&argument, ':'); @@ -1044,11 +1044,11 @@ reader_parse_vlan(Reader *reader, char *argument) static void reader_parse_ib_pkey(Reader *reader, char *argument) { - NMConnection * connection; + NMConnection *connection; NMSettingInfiniband *s_ib; - char * ifname; - gs_free char * parent = NULL; - char * pkey; + char *ifname; + gs_free char *parent = NULL; + char *pkey; gint64 pkey_int; /* At the moment we only support ib.pkey=.; @@ -1094,12 +1094,12 @@ reader_parse_ib_pkey(Reader *reader, char *argument) static void reader_parse_rd_znet(Reader *reader, char *argument, gboolean net_ifnames) { - const char * nettype; - const char * subchannels[4] = {0, 0, 0, 0}; - const char * tmp; - gs_free char * ifname = NULL; - const char * prefix; - NMConnection * connection; + const char *nettype; + const char *subchannels[4] = {0, 0, 0, 0}; + const char *tmp; + gs_free char *ifname = NULL; + const char *prefix; + NMConnection *connection; NMSettingWired *s_wired; static int count_ctc = 0; static int count_eth = 0; @@ -1160,7 +1160,7 @@ reader_parse_rd_znet(Reader *reader, char *argument, gboolean net_ifnames) while ((tmp = get_word(&argument, ',')) != NULL) { const char *key; - char * val; + char *val; val = strchr(tmp, '='); if (!val) { @@ -1184,11 +1184,11 @@ reader_parse_rd_znet(Reader *reader, char *argument, gboolean net_ifnames) static void reader_parse_ethtool(Reader *reader, char *argument) { - NMConnection * connection; + NMConnection *connection; NMSettingWired *s_wired; - const char * autoneg_str; - const char * speed_str; - const char * interface; + const char *autoneg_str; + const char *speed_str; + const char *interface; int autoneg; guint speed; @@ -1251,11 +1251,11 @@ _normalize_conn(gpointer key, gpointer value, gpointer user_data) static void reader_add_nameservers(Reader *reader, GPtrArray *nameservers) { - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip; GHashTableIter iter; int addr_family; - const char * ns; + const char *ns; guint i; for (i = 0; i < nameservers->len; i++) { @@ -1316,21 +1316,21 @@ connection_set_needed_cb(gpointer key, gpointer value, gpointer user_data) } GHashTable * -nmi_cmdline_reader_parse(const char * sysfs_dir, +nmi_cmdline_reader_parse(const char *sysfs_dir, const char *const *argv, - char ** hostname, - gint64 * carrier_timeout_sec) + char **hostname, + gint64 *carrier_timeout_sec) { - Reader * reader; - const char * tag; - gboolean ignore_bootif = FALSE; - gboolean neednet = FALSE; - gs_free char * bootif_val = NULL; - gs_free char * bootdev = NULL; - gboolean net_ifnames = TRUE; - gs_unref_ptrarray GPtrArray *nameservers = NULL; - gs_unref_ptrarray GPtrArray *routes = NULL; - gs_unref_ptrarray GPtrArray *znets = NULL; + Reader *reader; + const char *tag; + gboolean ignore_bootif = FALSE; + gboolean neednet = FALSE; + gs_free char *bootif_val = NULL; + gs_free char *bootdev = NULL; + gboolean net_ifnames = TRUE; + gs_unref_ptrarray GPtrArray *nameservers = NULL; + gs_unref_ptrarray GPtrArray *routes = NULL; + gs_unref_ptrarray GPtrArray *znets = NULL; int i; guint64 dhcp_timeout = 90; guint64 dhcp_num_tries = 1; @@ -1339,7 +1339,7 @@ nmi_cmdline_reader_parse(const char * sysfs_dir, for (i = 0; argv[i]; i++) { gs_free char *argument_clone = NULL; - char * argument; + char *argument; argument_clone = g_strdup(argv[i]); argument = argument_clone; @@ -1375,8 +1375,8 @@ nmi_cmdline_reader_parse(const char * sysfs_dir, for (i = 0; argv[i]; i++) { gs_free char *argument_clone = NULL; - char * argument; - char * word; + char *argument; + char *word; argument_clone = g_strdup(argv[i]); argument = argument_clone; @@ -1430,7 +1430,7 @@ nmi_cmdline_reader_parse(const char * sysfs_dir, } for (i = 0; i < reader->vlan_parents->len; i++) { - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip; /* Disable IP configuration for parent connections of VLANs, @@ -1459,9 +1459,9 @@ nmi_cmdline_reader_parse(const char * sysfs_dir, if (ignore_bootif) nm_clear_g_free(&bootif_val); if (bootif_val) { - NMConnection * connection; + NMConnection *connection; NMSettingWired *s_wired; - const char * bootif = bootif_val; + const char *bootif = bootif_val; char prefix[4]; if (!nm_utils_hwaddr_valid(bootif, ETH_ALEN)) { diff --git a/src/nm-initrd-generator/nmi-dt-reader.c b/src/nm-initrd-generator/nmi-dt-reader.c index 99c149dcba..8bd591a803 100644 --- a/src/nm-initrd-generator/nmi-dt-reader.c +++ b/src/nm-initrd-generator/nmi-dt-reader.c @@ -28,11 +28,11 @@ static gboolean dt_get_property(const char *base, const char *dev, const char *prop, - char ** contents, - size_t * length) + char **contents, + size_t *length) { - gs_free char *filename = g_build_filename(base, dev, prop, NULL); - gs_free_error GError *error = NULL; + gs_free char *filename = g_build_filename(base, dev, prop, NULL); + gs_free_error GError *error = NULL; if (!g_file_test(filename, G_FILE_TEST_EXISTS)) return FALSE; @@ -106,31 +106,31 @@ str_addr(const char *str, int *family) NMConnection * nmi_dt_reader_parse(const char *sysfs_dir) { - gs_unref_object NMConnection *connection = NULL; - gs_free char * base = NULL; - gs_free char * bootpath = NULL; - gs_strfreev char ** tokens = NULL; - char * path = NULL; - gboolean bootp = FALSE; - const char * s_ipaddr = NULL; - const char * s_netmask = NULL; - const char * s_gateway = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_free char *base = NULL; + gs_free char *bootpath = NULL; + gs_strfreev char **tokens = NULL; + char *path = NULL; + gboolean bootp = FALSE; + const char *s_ipaddr = NULL; + const char *s_netmask = NULL; + const char *s_gateway = NULL; nm_auto_unref_ip_address NMIPAddress *ipaddr = NULL; nm_auto_unref_ip_address NMIPAddress *gateway = NULL; - const char * duplex = NULL; - gs_free char * hwaddr = NULL; - gs_free char * local_hwaddr = NULL; - gs_free char * hostname = NULL; + const char *duplex = NULL; + gs_free char *hwaddr = NULL; + gs_free char *local_hwaddr = NULL; + gs_free char *hostname = NULL; guint32 speed = 0; int prefix = -1; - NMSettingIPConfig * s_ip = NULL; - NMSetting * s_ip4 = NULL; - NMSetting * s_ip6 = NULL; - NMSetting * s_wired = NULL; + NMSettingIPConfig *s_ip = NULL; + NMSetting *s_ip4 = NULL; + NMSetting *s_ip6 = NULL; + NMSetting *s_wired = NULL; int family = AF_UNSPEC; int i = 0; - char * c; - gs_free_error GError *error = NULL; + char *c; + gs_free_error GError *error = NULL; base = g_build_filename(sysfs_dir, "firmware", "devicetree", "base", NULL); diff --git a/src/nm-initrd-generator/nmi-ibft-reader.c b/src/nm-initrd-generator/nmi-ibft-reader.c index b3db3f0180..196bb141c4 100644 --- a/src/nm-initrd-generator/nmi-ibft-reader.c +++ b/src/nm-initrd-generator/nmi-ibft-reader.c @@ -36,12 +36,12 @@ static GHashTable * load_one_nic(const char *sysfs_dir, const char *dir_name) { - gs_free char *nic_path = g_build_filename(sysfs_dir, dir_name, NULL); - GDir * nic_dir; - const char * entry_name; - char * content; + gs_free char *nic_path = g_build_filename(sysfs_dir, dir_name, NULL); + GDir *nic_dir; + const char *entry_name; + char *content; gs_free_error GError *error = NULL; - GHashTable * nic; + GHashTable *nic; g_return_val_if_fail(sysfs_dir != NULL, FALSE); @@ -77,11 +77,11 @@ load_one_nic(const char *sysfs_dir, const char *dir_name) GHashTable * nmi_ibft_read(const char *sysfs_dir) { - gs_free char *ibft_path = NULL; - GDir * ibft_dir; - const char * dir_name; - GHashTable * ibft, *nic; - char * mac; + gs_free char *ibft_path = NULL; + GDir *ibft_dir; + const char *dir_name; + GHashTable *ibft, *nic; + char *mac; gs_free_error GError *error = NULL; g_return_val_if_fail(sysfs_dir != NULL, FALSE); @@ -133,14 +133,14 @@ ip_setting_add_from_block(GHashTable *nic, NMConnection *connection, GError **er NMSettingIPConfig *s_ip = NULL; NMSettingIPConfig *s_ip4 = NULL; NMSettingIPConfig *s_ip6 = NULL; - NMIPAddress * addr; - const char * s_ipaddr = NULL; - const char * s_prefix = NULL; - const char * s_gateway = NULL; - const char * s_dns1 = NULL; - const char * s_dns2 = NULL; - const char * s_origin = NULL; - const char * method = NULL; + NMIPAddress *addr; + const char *s_ipaddr = NULL; + const char *s_prefix = NULL; + const char *s_gateway = NULL; + const char *s_dns1 = NULL; + const char *s_dns2 = NULL; + const char *s_origin = NULL; + const char *method = NULL; int family; gint64 prefix; @@ -276,14 +276,14 @@ ip_setting_add_from_block(GHashTable *nic, NMConnection *connection, GError **er } static gboolean -connection_setting_add(GHashTable * nic, +connection_setting_add(GHashTable *nic, NMConnection *connection, - const char * type, - const char * prefix, - GError ** error) + const char *type, + const char *prefix, + GError **error) { - NMSetting * s_con; - char * id, *uuid; + NMSetting *s_con; + char *id, *uuid; const char *s_index, *s_hwaddr, *s_ipaddr, *s_vlanid; s_index = (const char *) g_hash_table_lookup(nic, "index"); @@ -359,7 +359,7 @@ is_ibft_vlan_device(GHashTable *nic) static gboolean vlan_setting_add_from_block(GHashTable *nic, NMConnection *connection, GError **error) { - NMSetting * s_vlan = NULL; + NMSetting *s_vlan = NULL; const char *vlan_id_str = NULL; gint64 vlan_id = -1; @@ -397,7 +397,7 @@ vlan_setting_add_from_block(GHashTable *nic, NMConnection *connection, GError ** static gboolean wired_setting_add_from_block(GHashTable *nic, NMConnection *connection, GError **error) { - NMSetting * s_wired = NULL; + NMSetting *s_wired = NULL; const char *hwaddr = NULL; g_assert(nic); diff --git a/src/nm-initrd-generator/tests/test-cmdline-reader.c b/src/nm-initrd-generator/tests/test-cmdline-reader.c index 2cb1b2f49d..02d87eb8f8 100644 --- a/src/nm-initrd-generator/tests/test-cmdline-reader.c +++ b/src/nm-initrd-generator/tests/test-cmdline-reader.c @@ -27,7 +27,7 @@ const char *const *const _ARGV = (ARGV); \ char **const _out_hostname = (out_hostname); \ gint64 *const _out_carrier_timeout_sec = (out_carrier_timeout_sec); \ - GHashTable * _connections; \ + GHashTable *_connections; \ \ _connections = nmi_cmdline_reader_parse(TEST_INITRD_DIR "/sysfs", \ _ARGV, \ @@ -41,7 +41,7 @@ #define _parse_cons(ARGV) \ ({ \ - GHashTable * _con_connections; \ + GHashTable *_con_connections; \ gs_free char *_con_hostname = NULL; \ gint64 _con_carrier_timeout_sec = 0; \ \ @@ -57,7 +57,7 @@ #define _parse_con(ARGV, connection_name) \ ({ \ gs_unref_hashtable GHashTable *_1_connections = NULL; \ - NMConnection * _1_connection; \ + NMConnection *_1_connection; \ const char *const _1_connection_name = (connection_name); \ \ g_assert(_1_connection_name); \ @@ -89,12 +89,12 @@ static void test_auto(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=auto"); + const char *const *ARGV = NM_MAKE_STRV("ip=auto"); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "default_connection"); @@ -140,13 +140,13 @@ static void test_dhcp_with_hostname(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=::::host1::dhcp,dhcp6"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_free char * hostname = NULL; + const char *const *ARGV = NM_MAKE_STRV("ip=::::host1::dhcp,dhcp6"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -198,10 +198,10 @@ test_dhcp_with_mtu(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV[i], "default_connection"); @@ -259,9 +259,9 @@ test_dhcp_timeout(void) for (i = 0; i < G_N_ELEMENTS(data); i++) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(data[i].cmdline, "default_connection"); @@ -300,12 +300,12 @@ test_dhcp_timeout(void) static void test_if_auto_with_mtu(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=eth0:dhcp,dhcp6:1666", "="); + const char *const *ARGV = NM_MAKE_STRV("ip=eth0:dhcp,dhcp6:1666", "="); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "eth0"); @@ -340,10 +340,10 @@ test_if_auto_with_mtu(void) static void test_if_dhcp6(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=eth1:dhcp6"); + const char *const *ARGV = NM_MAKE_STRV("ip=eth1:dhcp6"); gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "eth1"); @@ -365,11 +365,11 @@ test_if_dhcp6(void) static void test_if_auto_with_mtu_and_mac(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=eth2:auto6:2048:00:53:ef:12:34:56"); + const char *const *ARGV = NM_MAKE_STRV("ip=eth2:auto6:2048:00:53:ef:12:34:56"); gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "eth2"); @@ -397,16 +397,16 @@ static void test_if_ip4_manual(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=192.0.2.2::192.0.2.1:255.255.255.0:" - "hostname0.example.com:eth3:none:192.0.2.53", + const char *const *ARGV = NM_MAKE_STRV("ip=192.0.2.2::192.0.2.1:255.255.255.0:" + "hostname0.example.com:eth3:none:192.0.2.53", "ip=203.0.113.2::203.0.113.1:26:" - "hostname1.example.com:eth4"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip_addr; - gs_free char * hostname = NULL; + "hostname1.example.com:eth4"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip_addr; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -477,12 +477,12 @@ test_if_ip4_manual(void) static void test_if_ip4_manual_no_dev(void) { - const char *const * ARGV = NM_MAKE_STRV("ip=192.0.2.2::192.0.2.1:24:::", "=foo"); - NMConnection * connection; + const char *const *ARGV = NM_MAKE_STRV("ip=192.0.2.2::192.0.2.1:24:::", "=foo"); + NMConnection *connection; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip_addr; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip_addr; connection = _parse_con(ARGV, "default_connection"); g_assert_cmpstr(nm_connection_get_id(connection), ==, "Wired Connection"); @@ -518,12 +518,12 @@ static void test_if_ip6_manual(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=[2001:0db8::02]/64::[2001:0db8::01]::" - "hostname0.example.com:eth4::[2001:0db8::53]"); - NMConnection * connection; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip_addr; - gs_free char * hostname = NULL; + const char *const *ARGV = NM_MAKE_STRV("ip=[2001:0db8::02]/64::[2001:0db8::01]::" + "hostname0.example.com:eth4::[2001:0db8::53]"); + NMConnection *connection; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip_addr; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -557,13 +557,13 @@ static void test_if_off(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=off", + const char *const *ARGV = NM_MAKE_STRV("ip=off", "ip=ens3:off", "ip=10.0.0.8:::::ens4:off", "ip=[2001:DB8::8]:::::ens5:off"); - NMConnection * connection; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMConnection *connection; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; struct { const char name[32]; const char ipv4_method[32]; @@ -599,13 +599,13 @@ static void test_if_mac_ifname(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=[2001:0db8::42]/64::[2001:0db8::01]::" - "hostname0:00-11-22-33-44-55::[2001:0db8::53]"); - NMConnection * connection; - NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; - NMIPAddress * ip_addr; - gs_free char * hostname = NULL; + const char *const *ARGV = NM_MAKE_STRV("ip=[2001:0db8::42]/64::[2001:0db8::01]::" + "hostname0:00-11-22-33-44-55::[2001:0db8::53]"); + NMConnection *connection; + NMSettingIPConfig *s_ip6; + NMSettingWired *s_wired; + NMIPAddress *ip_addr; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -646,11 +646,11 @@ test_multiple_merge(void) const char *const *ARGV = NM_MAKE_STRV("ip=192.0.2.2/16:::::eth0", "ip=[2001:db8::2]:::56::eth0"); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip_addr; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip_addr; connection = _parse_con(ARGV, "eth0"); @@ -699,10 +699,10 @@ test_multiple_bootdev(void) "ip=eth5:link6", "bootdev=eth4"); - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -745,9 +745,9 @@ static void test_bootdev(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("vlan=vlan2:ens5", "bootdev=ens3"); - NMConnection * connection; - NMSettingConnection * s_con; + const char *const *ARGV = NM_MAKE_STRV("vlan=vlan2:ens5", "bootdev=ens3"); + NMConnection *connection; + NMSettingConnection *s_con; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -793,7 +793,7 @@ static void test_some_more(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("bootdev=eth1", + const char *const *ARGV = NM_MAKE_STRV("bootdev=eth1", "hail", "nameserver=[2001:DB8:3::53]", "satan", @@ -802,12 +802,12 @@ test_some_more(void) "doom", "rd.peerdns=0", "rd.route=[2001:DB8:3::/48]:[2001:DB8:2::1]:ens10"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPRoute * ip_route; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPRoute *ip_route; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -883,17 +883,17 @@ static void test_bond(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("rd.route=192.0.2.53::bong0", + const char *const *ARGV = NM_MAKE_STRV("rd.route=192.0.2.53::bong0", "bond=bong0:eth0,eth1:mode=balance-rr:9000", "nameserver=203.0.113.53"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingBond * s_bond; - NMSettingWired * s_wired; - NMIPRoute * ip_route; - const char * master_uuid; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingBond *s_bond; + NMSettingWired *s_wired; + NMIPRoute *ip_route; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -976,18 +976,18 @@ static void test_bond_ip(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = + const char *const *ARGV = NM_MAKE_STRV("bond=bond0:eth0,eth1", "ip=192.168.1.1::192.168.1.254:24::bond0:none:1480:01:02:03:04:05:06", "nameserver=4.8.15.16"); - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; - NMSettingBond * s_bond; - NMIPAddress * ip_addr; - const char * master_uuid; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingWired *s_wired; + NMSettingBond *s_bond; + NMIPAddress *ip_addr; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -1073,13 +1073,13 @@ static void test_bond_default(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("bond"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingBond * s_bond; - const char * master_uuid; + const char *const *ARGV = NM_MAKE_STRV("bond"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingBond *s_bond; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1136,16 +1136,16 @@ static void test_bridge(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("bridge=bridge0:eth0,eth1", + const char *const *ARGV = NM_MAKE_STRV("bridge=bridge0:eth0,eth1", "rd.route=192.0.2.53::bridge0", "rd.net.timeout.dhcp=10"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingBridge * s_bridge; - NMIPRoute * ip_route; - const char * master_uuid; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingBridge *s_bridge; + NMIPRoute *ip_route; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -1232,13 +1232,13 @@ static void test_bridge_default(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("bridge"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingBridge * s_bridge; - const char * master_uuid; + const char *const *ARGV = NM_MAKE_STRV("bridge"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingBridge *s_bridge; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1295,16 +1295,16 @@ static void test_bridge_ip(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = + const char *const *ARGV = NM_MAKE_STRV("ip=bridge123:auto:1280:00:11:22:33:CA:fe", "bridge=bridge123:eth0,eth1,eth2,eth3,eth4,eth5,eth6,eth7,eth8,eth9"); - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; - NMSettingBridge * s_bridge; - const char * master_uuid; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingWired *s_wired; + NMSettingBridge *s_bridge; + const char *master_uuid; guint i; connections = _parse_cons(ARGV); @@ -1364,13 +1364,13 @@ static void test_team(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("team=team0:eth0,eth1", "ip=team0:dhcp6"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingTeam * s_team; - const char * master_uuid; + const char *const *ARGV = NM_MAKE_STRV("team=team0:eth0,eth1", "ip=team0:dhcp6"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingTeam *s_team; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -1448,10 +1448,10 @@ test_vlan(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingVlan * s_vlan; + NMConnection *connection; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingVlan *s_vlan; connections = _parse_cons(ARGV[i]); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1513,10 +1513,10 @@ test_vlan_with_dhcp_on_parent(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingVlan * s_vlan; + NMConnection *connection; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingVlan *s_vlan; connections = _parse_cons(ARGV[i]); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1585,10 +1585,10 @@ test_vlan_over_bond(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingVlan * s_vlan; + NMConnection *connection; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingVlan *s_vlan; connections = _parse_cons(ARGV[i]); g_assert_cmpint(g_hash_table_size(connections), ==, 4); @@ -1649,8 +1649,8 @@ test_vlan_over_bond(void) static void test_ibft_ip_dev(void) { - const char *const * ARGV = NM_MAKE_STRV("ip=eth0:ibft"); - NMSettingConnection *s_con; + const char *const *ARGV = NM_MAKE_STRV("ip=eth0:ibft"); + NMSettingConnection *s_con; gs_unref_object NMConnection *connection = NULL; connection = _parse_con(ARGV, "eth0"); @@ -1666,8 +1666,8 @@ test_ibft_ip_dev(void) static void test_ibft_ip_dev_mac(void) { - const char *const * ARGV = NM_MAKE_STRV("ip=00-53-06-66-ab-01:ibft"); - NMSettingConnection *s_con; + const char *const *ARGV = NM_MAKE_STRV("ip=00-53-06-66-ab-01:ibft"); + NMSettingConnection *s_con; gs_unref_object NMConnection *connection = NULL; connection = _parse_con(ARGV, "00:53:06:66:AB:01"); @@ -1684,7 +1684,7 @@ static void _test_ibft_ip(const char *const *ARGV) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; + NMConnection *connection; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1721,7 +1721,7 @@ static void test_ignore_extra(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("blabla", "extra", "lalala"); + const char *const *ARGV = NM_MAKE_STRV("blabla", "extra", "lalala"); connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 0); @@ -1736,10 +1736,10 @@ test_rd_znet(void) "ip=slc600:dhcp", "rd.znet=qeth,0.0.0800,0.0.0801,0.0.0802,layer2=0,portno=1", "rd.znet=ctc,0.0.0600,0.0.0601,layer2=0,portno=0"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - const char *const * v_subchannels; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + const char *const *v_subchannels; const NMUtilsNamedValue s390_options[] = { {.name = "layer2", .value_str = "0"}, {.name = "portno", .value_str = "1"}, @@ -1778,9 +1778,9 @@ test_rd_znet(void) for (i_s390_options_keys = 0; i_s390_options_keys < G_N_ELEMENTS(s390_options); i_s390_options_keys++) { const NMUtilsNamedValue *s390_option = &s390_options[i_s390_options_keys]; - const char * k; - const char * v; - const char * v2; + const char *k; + const char *v; + const char *v2; g_assert(s390_option->name); g_assert(s390_option->value_str); @@ -1830,9 +1830,9 @@ test_rd_znet_legacy(void) "rd.znet=ctc,0.0.0600,0.0.0601,layer2=0,portno=0", "ip=ctc0:dhcp", "net.ifnames=0"); - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - gs_free char * hostname = NULL; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -1899,11 +1899,11 @@ test_rd_znet_malformed(void) static void test_bootif_ip(void) { - const char *const *ARGV = NM_MAKE_STRV("BOOTIF=00:53:AB:cd:02:03", "ip=dhcp"); + const char *const *ARGV = NM_MAKE_STRV("BOOTIF=00:53:AB:cd:02:03", "ip=dhcp"); gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "default_connection"); @@ -1928,11 +1928,11 @@ test_bootif_ip(void) static void test_neednet_no_args(void) { - const char *const *ARGV = NM_MAKE_STRV("rd.neednet"); + const char *const *ARGV = NM_MAKE_STRV("rd.neednet"); gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "default_connection"); @@ -1960,12 +1960,12 @@ static void test_neednet_args(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("rd.neednet", + const char *const *ARGV = NM_MAKE_STRV("rd.neednet", "ip=eno1:dhcp", "ip=172.25.1.100::172.25.1.1:24::eno2", "bridge=br0:eno3"); - NMConnection * connection; - NMSettingConnection * s_con; + NMConnection *connection; + NMSettingConnection *s_con; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 4); @@ -2008,11 +2008,11 @@ test_neednet_args(void) static void test_bootif_no_ip(void) { - const char *const *ARGV = NM_MAKE_STRV("BOOTIF=00:53:AB:cd:02:03"); + const char *const *ARGV = NM_MAKE_STRV("BOOTIF=00:53:AB:cd:02:03"); gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "default_connection"); @@ -2043,10 +2043,10 @@ test_bootif_hwtype(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMConnection *connection; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connections = _parse_cons(ARGV[i]); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -2108,16 +2108,16 @@ static void test_nameserver(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = + const char *const *ARGV = NM_MAKE_STRV("nameserver=1.1.1.1", "ip=eth0:dhcp", "ip=eth1:auto6", "ip=10.11.12.13::10.11.12.1:24:foo.example.com:eth2:none", "nameserver=1.0.0.1", "nameserver=[2606:4700:4700::1111]"); - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip; - gs_free char * hostname = NULL; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -2165,10 +2165,10 @@ test_bootif_off(void) static void test_dhcp_vendor_class_id(void) { - const char *const *ARGV; + const char *const *ARGV; gs_unref_object NMConnection *connection = NULL; - NMSettingIP4Config * s_ip4; - gs_free char * vci_long = NULL; + NMSettingIP4Config *s_ip4; + gs_free char *vci_long = NULL; char vci_arg_long[512] = {0}; ARGV = NM_MAKE_STRV("rd.net.dhcp.vendor-class=testvci", "ip=eno1:dhcp"); @@ -2196,9 +2196,9 @@ test_dhcp_vendor_class_id(void) static void test_infiniband_iface(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=ib1:dhcp"); + const char *const *ARGV = NM_MAKE_STRV("ip=ib1:dhcp"); gs_unref_object NMConnection *connection = NULL; - NMSettingInfiniband * s_ib; + NMSettingInfiniband *s_ib; connection = _parse_con(ARGV, "ib1"); @@ -2215,7 +2215,7 @@ test_infiniband_mac(void) const char *const *ARGV = NM_MAKE_STRV("ip=00-11-22-33-44-55-66-77-88-99-aa-bb-cc-dd-ee-ff-00-11-22-33:dhcp"); gs_unref_object NMConnection *connection = NULL; - NMSettingInfiniband * s_ib; + NMSettingInfiniband *s_ib; connection = _parse_con(ARGV, "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33"); @@ -2233,12 +2233,12 @@ test_infiniband_mac(void) static void test_infiniband_pkey(void) { - const char *const *const ARGV = NM_MAKE_STRV("ib.pkey=ib0.8004", "ip=ib0.8004:dhcp"); + const char *const *const ARGV = NM_MAKE_STRV("ib.pkey=ib0.8004", "ip=ib0.8004:dhcp"); gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingInfiniband * s_ib; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMConnection *connection; + NMSettingInfiniband *s_ib; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 1); @@ -2268,8 +2268,8 @@ static void test_carrier_timeout(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("rd.net.timeout.carrier=20"); - gs_free char * hostname = NULL; + const char *const *ARGV = NM_MAKE_STRV("rd.net.timeout.carrier=20"); + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -2295,7 +2295,7 @@ test_carrier_timeout(void) G_STMT_START \ { \ gs_unref_object NMConnection *_connection = NULL; \ - NMSettingWired * _s_wired; \ + NMSettingWired *_s_wired; \ typeof(speed) _speed = speed; \ \ _connection = _parse_con(strv, "eth0"); \ diff --git a/src/nm-initrd-generator/tests/test-dt-reader.c b/src/nm-initrd-generator/tests/test-dt-reader.c index c1c28e0673..e194646d50 100644 --- a/src/nm-initrd-generator/tests/test-dt-reader.c +++ b/src/nm-initrd-generator/tests/test-dt-reader.c @@ -25,12 +25,12 @@ static void test_read_dt_ofw(void) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - const char * mac_address; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + const char *mac_address; connection = nmi_dt_reader_parse(TEST_INITRD_DIR "/sysfs-dt"); g_assert(connection); @@ -69,12 +69,12 @@ test_read_dt_ofw(void) static void test_read_dt_slof(void) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip4_addr; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip4_addr; connection = nmi_dt_reader_parse(TEST_INITRD_DIR "/sysfs-dt-tftp"); g_assert(connection); diff --git a/src/nm-initrd-generator/tests/test-ibft-reader.c b/src/nm-initrd-generator/tests/test-ibft-reader.c index 0d43751974..55925a9a93 100644 --- a/src/nm-initrd-generator/tests/test-ibft-reader.c +++ b/src/nm-initrd-generator/tests/test-ibft-reader.c @@ -25,10 +25,10 @@ static NMConnection * read_connection(const char *sysfs_dir, const char *expected_mac, GError **error) { - NMConnection * connection = NULL; - gs_unref_hashtable GHashTable *ibft = NULL; - gs_free char * mac = NULL; - GHashTable * nic = NULL; + NMConnection *connection = NULL; + gs_unref_hashtable GHashTable *ibft = NULL; + gs_free char *mac = NULL; + GHashTable *nic = NULL; ibft = nmi_ibft_read(sysfs_dir); @@ -48,14 +48,14 @@ read_connection(const char *sysfs_dir, const char *expected_mac, GError **error) static void test_read_ibft_dhcp(void) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - GError * error = NULL; - const char * mac_address; - const char * expected_mac_address = "00:33:21:98:b9:f1"; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + GError *error = NULL; + const char *mac_address; + const char *expected_mac_address = "00:33:21:98:b9:f1"; connection = read_connection(TEST_INITRD_DIR "/sysfs-dhcp", expected_mac_address, &error); g_assert_no_error(error); @@ -96,15 +96,15 @@ test_read_ibft_dhcp(void) static void test_read_ibft_static(void) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - GError * error = NULL; - const char * mac_address; - const char * expected_mac_address = "00:33:21:98:b9:f0"; - NMIPAddress * ip4_addr; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + GError *error = NULL; + const char *mac_address; + const char *expected_mac_address = "00:33:21:98:b9:f0"; + NMIPAddress *ip4_addr; connection = read_connection(TEST_INITRD_DIR "/sysfs-static", expected_mac_address, &error); g_assert_no_error(error); @@ -159,9 +159,9 @@ test_read_ibft_static(void) static void test_read_ibft_bad_address(gconstpointer user_data) { - const char * sysfs_dir = user_data; + const char *sysfs_dir = user_data; NMConnection *connection; - GError * error = NULL; + GError *error = NULL; g_assert(g_file_test(sysfs_dir, G_FILE_TEST_EXISTS)); @@ -174,15 +174,15 @@ test_read_ibft_bad_address(gconstpointer user_data) static void test_read_ibft_vlan(void) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingVlan * s_vlan; - NMSettingIPConfig * s_ip4; - const char * mac_address; - const char * expected_mac_address = "00:33:21:98:b9:f0"; - NMIPAddress * ip4_addr; - GError * error = NULL; + NMSettingWired *s_wired; + NMSettingVlan *s_vlan; + NMSettingIPConfig *s_ip4; + const char *mac_address; + const char *expected_mac_address = "00:33:21:98:b9:f0"; + NMIPAddress *ip4_addr; + GError *error = NULL; connection = read_connection(TEST_INITRD_DIR "/sysfs-vlan", expected_mac_address, &error); g_assert_no_error(error); @@ -231,10 +231,10 @@ test_read_ibft_vlan(void) static void test_read_ibft(void) { - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - GError * error = NULL; + GError *error = NULL; /* This test doesn't actually test too much (apart from the presence of * IPv6 that is not covered by other tests), but the test fixture is a good diff --git a/src/nm-online/nm-online.c b/src/nm-online/nm-online.c index 6c807a6084..340c2d1955 100644 --- a/src/nm-online/nm-online.c +++ b/src/nm-online/nm-online.c @@ -34,8 +34,8 @@ #define EXIT_FAILURE_UNSPECIFIED 43 typedef struct { - GMainLoop * loop; - NMClient * client; + GMainLoop *loop; + NMClient *client; GCancellable *client_new_cancellable; guint client_new_timeout_id; guint handle_timeout_id; @@ -139,7 +139,7 @@ client_properties_changed(GObject *object, GParamSpec *pspec, gpointer user_data static gboolean handle_timeout(gpointer user_data) { - OnlineData * data = user_data; + OnlineData *data = user_data; const gint64 now = _now_ms(); gint64 remaining_ms = data->end_timestamp_ms - now; const gint64 elapsed_ms = now - data->start_timestamp_ms; @@ -194,7 +194,7 @@ got_client_timeout(gpointer user_data) static void got_client(GObject *source_object, GAsyncResult *res, gpointer user_data) { - OnlineData * data = user_data; + OnlineData *data = user_data; gs_free_error GError *error = NULL; nm_assert(NM_IS_CLIENT(source_object)); diff --git a/src/nm-sudo/nm-sudo.c b/src/nm-sudo/nm-sudo.c index 1e8c941fd0..a97087a0bb 100644 --- a/src/nm-sudo/nm-sudo.c +++ b/src/nm-sudo/nm-sudo.c @@ -38,7 +38,7 @@ typedef struct { struct _GlobalData { GDBusConnection *dbus_connection; - GCancellable * quit_cancellable; + GCancellable *quit_cancellable; GSource *source_sigterm; @@ -112,9 +112,9 @@ _handle_ping(GlobalData *gl, GDBusMethodInvocation *invocation, const char *arg) static void _handle_get_fd(GlobalData *gl, GDBusMethodInvocation *invocation, guint32 fd_type) { - nm_auto_close int fd = -1; + nm_auto_close int fd = -1; gs_unref_object GUnixFDList *fd_list = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; if (fd_type != (NMSudoGetFDType) fd_type) fd_type = NM_SUDO_GET_FD_TYPE_NONE; @@ -151,7 +151,7 @@ _signal_callback_term(gpointer user_data) static GDBusConnection * _bus_get(GCancellable *cancellable, int *out_exit_code) { - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; gs_unref_object GDBusConnection *dbus_connection = NULL; dbus_connection = nm_g_bus_get_blocking(cancellable, &error); @@ -178,11 +178,11 @@ _bus_get(GCancellable *cancellable, int *out_exit_code) static void _name_owner_changed_cb(GDBusConnection *connection, - const char * sender_name, - const char * object_path, - const char * interface_name, - const char * signal_name, - GVariant * parameters, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, gpointer user_data) { GlobalData *gl = user_data; @@ -207,7 +207,7 @@ _name_owner_changed_cb(GDBusConnection *connection, typedef struct { GlobalData *gl; - char ** p_name_owner; + char **p_name_owner; gboolean is_cancelled; } BusFindNMNameOwnerData; @@ -226,7 +226,7 @@ _bus_find_nm_nameowner(GlobalData *gl) { BusFindNMNameOwnerData data; guint name_owner_changed_id; - gs_free char * name_owner = NULL; + gs_free char *name_owner = NULL; name_owner_changed_id = nm_dbus_connection_signal_subscribe_name_owner_changed(gl->dbus_connection, @@ -262,12 +262,12 @@ _bus_find_nm_nameowner(GlobalData *gl) /*****************************************************************************/ static void -_bus_method_call(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, +_bus_method_call(GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -351,9 +351,9 @@ _bus_register_service(GlobalData *gl) static const GDBusInterfaceVTable interface_vtable = { .method_call = _bus_method_call, }; - gs_free_error GError * error = NULL; + gs_free_error GError *error = NULL; NMDBusConnectionCallBlockingData data = { - .result = NULL, + .result = NULL, }; gs_unref_variant GVariant *ret = NULL; guint32 ret_val; @@ -453,7 +453,7 @@ static gboolean _pending_job_register_object_release_on_idle_cb(gpointer data) { PendingJobData *idle_data = data; - GlobalData * gl = idle_data->gl; + GlobalData *gl = idle_data->gl; c_list_unlink_stale(&idle_data->pending_jobs_lst); nm_g_slice_free(idle_data); @@ -496,7 +496,7 @@ static void _bus_release_name_cb(GObject *source, GAsyncResult *result, gpointer user_data) { _nm_unused gs_unref_object GObject *keep_alive_object = NULL; - GlobalData * gl; + GlobalData *gl; nm_utils_user_data_unpack(user_data, &gl, &keep_alive_object); diff --git a/src/nmcli/agent.c b/src/nmcli/agent.c index bdbd6e458d..6d0fcfb5c9 100644 --- a/src/nmcli/agent.c +++ b/src/nmcli/agent.c @@ -56,7 +56,8 @@ usage_agent_all(void) static char *pre_input_deftext; -static int set_deftext(_NMC_RL_STARTUPHOOK_ARGS) +static int +set_deftext(_NMC_RL_STARTUPHOOK_ARGS) { if (pre_input_deftext && rl_startup_hook) { rl_insert_text(pre_input_deftext); @@ -68,16 +69,16 @@ static int set_deftext(_NMC_RL_STARTUPHOOK_ARGS) static gboolean get_secrets_from_user(const NmcConfig *nmc_config, - const char * request_id, - const char * title, - const char * msg, - GPtrArray * secrets) + const char *request_id, + const char *title, + const char *msg, + GPtrArray *secrets) { int i; for (i = 0; i < secrets->len; i++) { NMSecretAgentSimpleSecret *secret = secrets->pdata[i]; - char * pwd = NULL; + char *pwd = NULL; /* Ask user for the password */ if (msg) @@ -103,13 +104,13 @@ get_secrets_from_user(const NmcConfig *nmc_config, static void secrets_requested(NMSecretAgentSimple *agent, - const char * request_id, - const char * title, - const char * msg, - GPtrArray * secrets, + const char *request_id, + const char *title, + const char *msg, + GPtrArray *secrets, gpointer user_data) { - NmCli * nmc = user_data; + NmCli *nmc = user_data; gboolean success; if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY) diff --git a/src/nmcli/common.c b/src/nmcli/common.c index d9a981c30f..26398c8429 100644 --- a/src/nmcli/common.c +++ b/src/nmcli/common.c @@ -30,8 +30,8 @@ static char ** _ip_config_get_routes(NMIPConfig *cfg) { gs_unref_hashtable GHashTable *hash = NULL; - GPtrArray * ptr_array; - char ** arr; + GPtrArray *ptr_array; + char **arr; guint i; ptr_array = nm_ip_config_get_routes(cfg); @@ -43,12 +43,12 @@ _ip_config_get_routes(NMIPConfig *cfg) arr = g_new(char *, ptr_array->len + 1); for (i = 0; i < ptr_array->len; i++) { - NMIPRoute * route = g_ptr_array_index(ptr_array, i); + NMIPRoute *route = g_ptr_array_index(ptr_array, i); gs_strfreev char **names = NULL; gsize j; - GString * str; + GString *str; guint64 metric; - gs_free char * attributes = NULL; + gs_free char *attributes = NULL; str = g_string_new(NULL); g_string_append_printf( @@ -92,14 +92,15 @@ _ip_config_get_routes(NMIPConfig *cfg) /*****************************************************************************/ -static gconstpointer _metagen_ip4_config_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_ip4_config_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMIPConfig * cfg4 = target; - GPtrArray * ptr_array; - char ** arr; + NMIPConfig *cfg4 = target; + GPtrArray *ptr_array; + char **arr; const char *const *arrc; guint i = 0; - const char * str; + const char *str; nm_assert(info->info_type < _NMC_GENERIC_INFO_TYPE_IP4_CONFIG_NUM); @@ -185,14 +186,15 @@ const NmcMetaGenericInfo *const metagen_ip4_config[_NMC_GENERIC_INFO_TYPE_IP4_CO /*****************************************************************************/ -static gconstpointer _metagen_ip6_config_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_ip6_config_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMIPConfig * cfg6 = target; - GPtrArray * ptr_array; - char ** arr; + NMIPConfig *cfg6 = target; + GPtrArray *ptr_array; + char **arr; const char *const *arrc; guint i = 0; - const char * str; + const char *str; nm_assert(info->info_type < _NMC_GENERIC_INFO_TYPE_IP6_CONFIG_NUM); @@ -272,18 +274,19 @@ const NmcMetaGenericInfo *const metagen_ip6_config[_NMC_GENERIC_INFO_TYPE_IP6_CO /*****************************************************************************/ -static gconstpointer _metagen_dhcp_config_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_dhcp_config_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { NMDhcpConfig *dhcp = target; guint i; - char ** arr = NULL; + char **arr = NULL; NMC_HANDLE_COLOR(NM_META_COLOR_NONE); switch (info->info_type) { case NMC_GENERIC_INFO_TYPE_DHCP_CONFIG_OPTION: { - GHashTable * table; + GHashTable *table; gs_free char **arr2 = NULL; guint n; @@ -333,13 +336,13 @@ const NmcMetaGenericInfo *const metagen_dhcp_config[_NMC_GENERIC_INFO_TYPE_DHCP_ /*****************************************************************************/ gboolean -print_ip_config(NMIPConfig * cfg, +print_ip_config(NMIPConfig *cfg, int addr_family, const NmcConfig *nmc_config, - const char * one_field) + const char *one_field) { gs_free_error GError *error = NULL; - gs_free char * field_str = NULL; + gs_free char *field_str = NULL; if (!cfg) return FALSE; @@ -364,13 +367,13 @@ print_ip_config(NMIPConfig * cfg, } gboolean -print_dhcp_config(NMDhcpConfig * dhcp, +print_dhcp_config(NMDhcpConfig *dhcp, int addr_family, const NmcConfig *nmc_config, - const char * one_field) + const char *one_field) { gs_free_error GError *error = NULL; - gs_free char * field_str = NULL; + gs_free char *field_str = NULL; if (!dhcp) return FALSE; @@ -416,16 +419,16 @@ print_dhcp_config(NMDhcpConfig * dhcp, */ NMConnection * nmc_find_connection(const GPtrArray *connections, - const char * filter_type, - const char * filter_val, - GPtrArray ** out_result, + const char *filter_type, + const char *filter_val, + GPtrArray **out_result, gboolean complete) { - NMConnection * best_candidate_uuid = NULL; - NMConnection * best_candidate = NULL; - gs_unref_ptrarray GPtrArray *result_allocated = NULL; - GPtrArray * result = out_result ? *out_result : NULL; - const guint result_inital_len = result ? result->len : 0u; + NMConnection *best_candidate_uuid = NULL; + NMConnection *best_candidate = NULL; + gs_unref_ptrarray GPtrArray *result_allocated = NULL; + GPtrArray *result = out_result ? *out_result : NULL; + const guint result_inital_len = result ? result->len : 0u; guint i, j; nm_assert(connections); @@ -434,8 +437,8 @@ nmc_find_connection(const GPtrArray *connections, for (i = 0; i < connections->len; i++) { gboolean match_by_uuid = FALSE; NMConnection *connection; - const char * v; - const char * v_num; + const char *v; + const char *v_num; connection = NM_CONNECTION(connections->pdata[i]); @@ -517,21 +520,21 @@ found: NMActiveConnection * nmc_find_active_connection(const GPtrArray *active_cons, - const char * filter_type, - const char * filter_val, - GPtrArray ** out_result, + const char *filter_type, + const char *filter_val, + GPtrArray **out_result, gboolean complete) { guint i, j; NMActiveConnection *best_candidate = NULL; - GPtrArray * result = out_result ? *out_result : NULL; + GPtrArray *result = out_result ? *out_result : NULL; nm_assert(filter_val); for (i = 0; i < active_cons->len; i++) { NMRemoteConnection *con; NMActiveConnection *candidate = g_ptr_array_index(active_cons, i); - const char * v, *v_num; + const char *v, *v_num; con = nm_active_connection_get_connection(candidate); @@ -606,9 +609,9 @@ found: static gboolean vpn_openconnect_get_secrets(NMConnection *connection, GPtrArray *secrets) { - GError * error = NULL; + GError *error = NULL; NMSettingVpn *s_vpn; - const char * gw, *port; + const char *gw, *port; gs_free char *cookie = NULL; gs_free char *gateway = NULL; gs_free char *gwcert = NULL; @@ -679,13 +682,13 @@ vpn_openconnect_get_secrets(NMConnection *connection, GPtrArray *secrets) static gboolean get_secrets_from_user(const NmcConfig *nmc_config, - const char * request_id, - const char * title, - const char * msg, - NMConnection * connection, + const char *request_id, + const char *title, + const char *msg, + NMConnection *connection, gboolean ask, - GHashTable * pwds_hash, - GPtrArray * secrets) + GHashTable *pwds_hash, + GPtrArray *secrets) { int i; @@ -695,7 +698,7 @@ get_secrets_from_user(const NmcConfig *nmc_config, for (i = 0; i < secrets->len; i++) { NMSecretAgentSimpleSecret *secret = secrets->pdata[i]; - char * pwd = NULL; + char *pwd = NULL; /* First try to find the password in provided passwords file, * then ask user. */ @@ -764,15 +767,15 @@ get_secrets_from_user(const NmcConfig *nmc_config, */ void nmc_secrets_requested(NMSecretAgentSimple *agent, - const char * request_id, - const char * title, - const char * msg, - GPtrArray * secrets, + const char *request_id, + const char *title, + const char *msg, + GPtrArray *secrets, gpointer user_data) { - NmCli * nmc = (NmCli *) user_data; - NMConnection * connection = NULL; - char * path, *p; + NmCli *nmc = (NmCli *) user_data; + NMConnection *connection = NULL; + char *path, *p; gboolean success = FALSE; const GPtrArray *connections; @@ -814,8 +817,8 @@ char * nmc_unique_connection_name(const GPtrArray *connections, const char *try_name) { NMConnection *connection; - const char * name; - char * new_name; + const char *name; + char *new_name; unsigned num = 1; int i = 0; @@ -837,7 +840,7 @@ nmc_unique_connection_name(const GPtrArray *connections, const char *try_name) /* readline state variables */ static gboolean nmcli_in_readline = FALSE; static gboolean rl_got_line; -static char * rl_string; +static char *rl_string; /** * nmc_cleanup_readline: @@ -978,7 +981,7 @@ nmc_secret_redisplay(void) { int save_point = rl_point; int save_end = rl_end; - char * save_line_buffer = rl_line_buffer; + char *save_line_buffer = rl_line_buffer; const char *subst = nmc_password_subst_char(); int subst_len = strlen(subst); int i; @@ -1009,7 +1012,7 @@ nmc_readline_echo(const NmcConfig *nmc_config, gboolean echo_on, const char *pro { va_list args; gs_free char *prompt = NULL; - char * str; + char *str; #if HAVE_READLINE_HISTORY nm_auto_free HISTORY_STATE *saved_history = NULL; HISTORY_STATE passwd_history = { @@ -1129,8 +1132,8 @@ nmc_rl_gen_func_ifnames(const char *text, int state) { int i; const GPtrArray *devices; - const char ** ifnames; - char * ret; + const char **ifnames; + char *ret; devices = nm_client_get_devices(nm_cli_global_readline->client); if (devices->len == 0) @@ -1138,7 +1141,7 @@ nmc_rl_gen_func_ifnames(const char *text, int state) ifnames = g_new(const char *, devices->len + 1); for (i = 0; i < devices->len; i++) { - NMDevice * dev = g_ptr_array_index(devices, i); + NMDevice *dev = g_ptr_array_index(devices, i); const char *ifname = nm_device_get_iface(dev); ifnames[i] = ifname; } @@ -1152,7 +1155,8 @@ nmc_rl_gen_func_ifnames(const char *text, int state) char *nmc_rl_pre_input_deftext; -int nmc_rl_set_deftext(_NMC_RL_STARTUPHOOK_ARGS) +int +nmc_rl_set_deftext(_NMC_RL_STARTUPHOOK_ARGS) { if (nmc_rl_pre_input_deftext && rl_startup_hook) { rl_insert_text(nmc_rl_pre_input_deftext); @@ -1186,7 +1190,7 @@ nmc_parse_lldp_capabilities(guint value) "s-vlan-component", "tpmr"}; gboolean first = TRUE; - GString * str; + GString *str; int i; if (!value) @@ -1217,8 +1221,8 @@ nmc_parse_lldp_capabilities(guint value) static void command_done(GObject *object, GAsyncResult *res, gpointer user_data) { - GTask * task = G_TASK(res); - NmCli * nmc = user_data; + GTask *task = G_TASK(res); + NmCli *nmc = user_data; gs_free_error GError *error = NULL; if (!g_task_propagate_boolean(task, &error)) { @@ -1233,8 +1237,8 @@ command_done(GObject *object, GAsyncResult *res, gpointer user_data) typedef struct { const NMCCommand *cmd; int argc; - char ** argv; - GTask * task; + char **argv; + GTask *task; } CmdCall; static void @@ -1243,10 +1247,10 @@ call_cmd(NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, const char *c static void got_client(GObject *source_object, GAsyncResult *res, gpointer user_data) { - gs_unref_object GTask *task = NULL; - gs_free_error GError *error = NULL; - CmdCall * call = user_data; - NmCli * nmc; + gs_unref_object GTask *task = NULL; + gs_free_error GError *error = NULL; + CmdCall *call = user_data; + NmCli *nmc; nm_assert(NM_IS_CLIENT(source_object)); @@ -1343,7 +1347,7 @@ nmc_complete_help(const char *prefix) void nmc_do_cmd(NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, const char *const *argv) { - const NMCCommand *c; + const NMCCommand *c; gs_unref_object GTask *task = NULL; task = nm_g_task_new(NULL, NULL, nmc_do_cmd, command_done, nmc); diff --git a/src/nmcli/common.h b/src/nmcli/common.h index 908dad0672..1572c53458 100644 --- a/src/nmcli/common.h +++ b/src/nmcli/common.h @@ -9,33 +9,33 @@ #include "nmcli.h" #include "libnmc-base/nm-secret-agent-simple.h" -gboolean print_ip_config(NMIPConfig * cfg, +gboolean print_ip_config(NMIPConfig *cfg, int addr_family, const NmcConfig *nmc_config, - const char * one_field); + const char *one_field); -gboolean print_dhcp_config(NMDhcpConfig * dhcp, +gboolean print_dhcp_config(NMDhcpConfig *dhcp, int addr_family, const NmcConfig *nmc_config, - const char * one_field); + const char *one_field); NMConnection *nmc_find_connection(const GPtrArray *connections, - const char * filter_type, - const char * filter_val, - GPtrArray ** out_result, + const char *filter_type, + const char *filter_val, + GPtrArray **out_result, gboolean complete); NMActiveConnection *nmc_find_active_connection(const GPtrArray *active_cons, - const char * filter_type, - const char * filter_val, - GPtrArray ** out_result, + const char *filter_type, + const char *filter_val, + GPtrArray **out_result, gboolean complete); void nmc_secrets_requested(NMSecretAgentSimple *agent, - const char * request_id, - const char * title, - const char * msg, - GPtrArray * secrets, + const char *request_id, + const char *title, + const char *msg, + GPtrArray *secrets, gpointer user_data); char *nmc_unique_connection_name(const GPtrArray *connections, const char *try_name); @@ -45,8 +45,8 @@ char *nmc_readline(const NmcConfig *nmc_config, const char *prompt_fmt, ...) G_G char *nmc_readline_echo(const NmcConfig *nmc_config, gboolean echo_on, const char *prompt_fmt, ...) G_GNUC_PRINTF(3, 4); NmcCompEntryFunc nmc_rl_compentry_func_wrap(const char *const *values); -char * nmc_rl_gen_func_basic(const char *text, int state, const char *const *words); -char * nmc_rl_gen_func_ifnames(const char *text, int state); +char *nmc_rl_gen_func_basic(const char *text, int state, const char *const *words); +char *nmc_rl_gen_func_ifnames(const char *text, int state); gboolean nmc_get_in_readline(void); void nmc_set_in_readline(gboolean in_readline); diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index 5edd33f084..831e5bfc5f 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -45,13 +45,13 @@ typedef char *(*CompEntryFunc)(const char *, int); typedef struct _OptionInfo { const NMMetaSettingInfoEditor *setting_info; - const char * property; - const char * option; - gboolean (*check_and_set)(NmCli * nmc, - NMConnection * connection, + const char *property; + const char *option; + gboolean (*check_and_set)(NmCli *nmc, + NMConnection *connection, const struct _OptionInfo *option, - const char * value, - GError ** error); + const char *value, + GError **error); CompEntryFunc generator_func; } OptionInfo; @@ -100,9 +100,9 @@ static NM_UTILS_LOOKUP_STR_DEFINE( typedef struct { NmCli *nmc; - char * orig_id; - char * orig_uuid; - char * new_id; + char *orig_id; + char *orig_uuid; + char *new_id; } AddConnectionInfo; static AddConnectionInfo * @@ -189,10 +189,10 @@ active_connection_get_state_ord(NMActiveConnection *active) int nmc_active_connection_cmp(NMActiveConnection *ac_a, NMActiveConnection *ac_b) { - NMSettingIPConfig * s_ip; + NMSettingIPConfig *s_ip; NMRemoteConnection *conn; - NMIPConfig * da_ip; - NMIPConfig * db_ip; + NMIPConfig *da_ip; + NMIPConfig *db_ip; int da_num_addrs; int db_num_addrs; int cmp = 0; @@ -254,7 +254,7 @@ nmc_active_connection_cmp(NMActiveConnection *ac_a, NMActiveConnection *ac_b) static char * get_ac_device_string(NMActiveConnection *active) { - GString * dev_str; + GString *dev_str; const GPtrArray *devices; guint i; @@ -265,7 +265,7 @@ get_ac_device_string(NMActiveConnection *active) dev_str = g_string_new(NULL); devices = nm_active_connection_get_devices(active); for (i = 0; i < devices->len; i++) { - NMDevice * device = g_ptr_array_index(devices, i); + NMDevice *device = g_ptr_array_index(devices, i); const char *dev_iface = nm_device_get_iface(device); if (dev_iface) { @@ -288,7 +288,7 @@ static const char * get_vpn_connection_type(NMConnection *connection) { NMSettingVpn *s_vpn; - const char * type, *p; + const char *type, *p; s_vpn = nm_connection_get_setting_vpn(connection); if (!s_vpn) @@ -387,9 +387,9 @@ get_vpn_data_item(NMConnection *connection, enum VpnDataItem vpn_data_item) /*****************************************************************************/ typedef struct { - NMConnection * connection; + NMConnection *connection; NMActiveConnection *primary_active; - GPtrArray * all_active; + GPtrArray *all_active; bool show_active_fields; } MetagenConShowRowData; @@ -422,7 +422,7 @@ _metagen_con_show_row_data_new_for_active_connection(NMRemoteConnection *connect static void _metagen_con_show_row_data_add_active_connection(MetagenConShowRowData *row_data, - NMActiveConnection * active) + NMActiveConnection *active) { if (!row_data->primary_active) { row_data->primary_active = g_object_ref(active); @@ -477,7 +477,7 @@ static const char * _con_show_fcn_get_id(NMConnection *c, NMActiveConnection *ac) { NMSettingConnection *s_con = NULL; - const char * s; + const char *s; if (c) s_con = nm_connection_get_setting_connection(c); @@ -499,7 +499,7 @@ static const char * _con_show_fcn_get_type(NMConnection *c, NMActiveConnection *ac, NMMetaAccessorGetType get_type) { NMSettingConnection *s_con = NULL; - const char * s; + const char *s; if (c) s_con = nm_connection_get_setting_connection(c); @@ -513,14 +513,15 @@ _con_show_fcn_get_type(NMConnection *c, NMActiveConnection *ac, NMMetaAccessorGe return connection_type_to_display(s, get_type); } -static gconstpointer _metagen_con_show_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_con_show_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { const MetagenConShowRowData *row_data = target; - NMConnection * c = row_data->connection; - NMActiveConnection * ac = row_data->primary_active; - NMSettingConnection * s_con = NULL; - const char * s; - char * s_mut; + NMConnection *c = row_data->connection; + NMActiveConnection *ac = row_data->primary_active; + NMSettingConnection *s_con = NULL; + const char *s; + char *s_mut; NMC_HANDLE_COLOR(nmc_active_connection_state_to_color(ac)); @@ -654,14 +655,15 @@ const NmcMetaGenericInfo *const metagen_con_show[_NMC_GENERIC_INFO_TYPE_CON_SHOW /*****************************************************************************/ -static gconstpointer _metagen_con_active_general_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_con_active_general_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMActiveConnection * ac = target; - NMConnection * c; + NMActiveConnection *ac = target; + NMConnection *c; NMSettingConnection *s_con = NULL; - NMDevice * dev; + NMDevice *dev; guint i; - const char * s; + const char *s; NMC_HANDLE_COLOR(NM_META_COLOR_NONE); @@ -680,14 +682,14 @@ static gconstpointer _metagen_con_active_general_get_fcn(NMC_META_GENERIC_INFO_G case NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_DEVICES: case NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_IP_IFACE: { - GString * str = NULL; + GString *str = NULL; const GPtrArray *devices; s = NULL; devices = nm_active_connection_get_devices(ac); if (devices) { for (i = 0; i < devices->len; i++) { - NMDevice * device = g_ptr_array_index(devices, i); + NMDevice *device = g_ptr_array_index(devices, i); const char *iface; if (info->info_type == NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_DEVICES) { @@ -767,15 +769,16 @@ const NmcMetaGenericInfo /*****************************************************************************/ -static gconstpointer _metagen_con_active_vpn_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_con_active_vpn_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMActiveConnection * ac = target; - NMConnection * c; - NMSettingVpn * s_vpn = NULL; + NMActiveConnection *ac = target; + NMConnection *c; + NMSettingVpn *s_vpn = NULL; NMVpnConnectionState vpn_state; guint i; - const char * s; - char ** arr = NULL; + const char *s; + char **arr = NULL; nm_assert(NM_IS_VPN_CONNECTION(ac)); @@ -909,12 +912,12 @@ static guint progress_id = 0; /* ID of event source for displaying progress */ /* for readline TAB completion in editor */ typedef struct { - NmCli * nmc; - char * con_type; + NmCli *nmc; + char *con_type; NMConnection *connection; - NMSetting * setting; - const char * property; - char ** words; + NMSetting *setting; + const char *property; + char **words; } TabCompletionInfo; static TabCompletionInfo nmc_tab_completion; @@ -1291,12 +1294,12 @@ get_ac_for_connection_cmp(gconstpointer pa, gconstpointer pb) static NMActiveConnection * get_ac_for_connection(const GPtrArray *active_cons, - NMConnection * connection, - GPtrArray ** out_result) + NMConnection *connection, + GPtrArray **out_result) { guint i; NMActiveConnection *best_candidate = NULL; - GPtrArray * result = out_result ? *out_result : NULL; + GPtrArray *result = out_result ? *out_result : NULL; for (i = 0; i < active_cons->len; i++) { NMActiveConnection *candidate = g_ptr_array_index(active_cons, i); @@ -1323,16 +1326,16 @@ get_ac_for_connection(const GPtrArray *active_cons, } typedef struct { - GMainLoop * loop; + GMainLoop *loop; NMConnection *local; - const char * setting_name; + const char *setting_name; } GetSecretsData; static void got_secrets(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMRemoteConnection *remote = NM_REMOTE_CONNECTION(source_object); - GetSecretsData * data = user_data; + NMRemoteConnection *remote = NM_REMOTE_CONNECTION(source_object); + GetSecretsData *data = user_data; gs_unref_variant GVariant *secrets = NULL; secrets = nm_remote_connection_get_secrets_finish(remote, res, NULL); @@ -1384,13 +1387,13 @@ update_secrets_in_connection(NMRemoteConnection *remote, NMConnection *local) static gboolean nmc_connection_profile_details(NMConnection *connection, NmCli *nmc) { - GError * error = NULL; - GArray * print_settings_array; - GPtrArray * prop_array = NULL; + GError *error = NULL; + GArray *print_settings_array; + GPtrArray *prop_array = NULL; guint i; - char * fields_str; - char * fields_all = NMC_FIELDS_SETTINGS_NAMES_ALL; - char * fields_common = NMC_FIELDS_SETTINGS_NAMES_ALL; + char *fields_str; + char *fields_all = NMC_FIELDS_SETTINGS_NAMES_ALL; + char *fields_common = NMC_FIELDS_SETTINGS_NAMES_ALL; const char *base_hdr = _("Connection profile details"); gboolean was_output = FALSE; @@ -1417,9 +1420,9 @@ nmc_connection_profile_details(NMConnection *connection, NmCli *nmc) /* Main header */ { - gs_free char *header_name = NULL; - gs_free NmcOutputField *row = NULL; - gs_unref_array GArray *out_indices = NULL; + gs_free char *header_name = NULL; + gs_free NmcOutputField *row = NULL; + gs_unref_array GArray *out_indices = NULL; header_name = construct_header_name(base_hdr, nm_connection_get_id(connection)); out_indices = parse_output_fields( @@ -1444,7 +1447,7 @@ nmc_connection_profile_details(NMConnection *connection, NmCli *nmc) /* Loop through the required settings and print them. */ for (i = 0; i < print_settings_array->len; i++) { - NMSetting * setting; + NMSetting *setting; int section_idx = g_array_index(print_settings_array, int, i); const char *prop_name = (const char *) g_ptr_array_index(prop_array, i); @@ -1496,9 +1499,9 @@ nmc_active_connection_state_to_color(NMActiveConnection *ac) static gboolean nmc_active_connection_details(NMActiveConnection *acon, NmCli *nmc) { - GError * error = NULL; - GArray * print_groups; - GPtrArray * group_fields = NULL; + GError *error = NULL; + GArray *print_groups; + GPtrArray *group_fields = NULL; int i; const char *fields_str = NULL; const char *base_hdr = _("Activate connection details"); @@ -1527,9 +1530,9 @@ nmc_active_connection_details(NMActiveConnection *acon, NmCli *nmc) /* Main header */ { - gs_free char *header_name = NULL; - gs_free NmcOutputField *row = NULL; - gs_unref_array GArray *out_indices = NULL; + gs_free char *header_name = NULL; + gs_free NmcOutputField *row = NULL; + gs_unref_array GArray *out_indices = NULL; header_name = construct_header_name(base_hdr, nm_active_connection_get_uuid(acon)); out_indices = parse_output_fields( @@ -1648,12 +1651,12 @@ nmc_active_connection_details(NMActiveConnection *acon, NmCli *nmc) static gboolean split_required_fields_for_con_show(const char *input, - char ** profile_flds, - char ** active_flds, - GError ** error) + char **profile_flds, + char **active_flds, + GError **error) { - gs_free const char **fields = NULL; - const char *const * iter; + gs_free const char **fields = NULL; + const char *const *iter; nm_auto_free_gstring GString *str1 = NULL; nm_auto_free_gstring GString *str2 = NULL; gboolean group_profile = FALSE; @@ -1671,8 +1674,8 @@ split_required_fields_for_con_show(const char *input, fields = nm_strsplit_set_with_empty(input, ","); for (iter = fields; iter && *iter; iter++) { - char * s_mutable = (char *) (*iter); - char * dot; + char *s_mutable = (char *) (*iter); + char *dot; gboolean is_all; gboolean is_common; gboolean found; @@ -1789,7 +1792,7 @@ typedef enum { } NmcSortOrder; typedef struct { - NmCli * nmc; + NmCli *nmc; const GArray *order; gboolean show_active_fields; } ConShowSortInfo; @@ -1797,15 +1800,15 @@ typedef struct { static int con_show_get_items_cmp(gconstpointer pa, gconstpointer pb, gpointer user_data) { - const ConShowSortInfo * sort_info = user_data; + const ConShowSortInfo *sort_info = user_data; const MetagenConShowRowData *row_data_a = *((const MetagenConShowRowData *const *) pa); const MetagenConShowRowData *row_data_b = *((const MetagenConShowRowData *const *) pb); - NMConnection * c_a = row_data_a->connection; - NMConnection * c_b = row_data_b->connection; - NMActiveConnection * ac_a = row_data_a->primary_active; - NMActiveConnection * ac_b = row_data_b->primary_active; - NMActiveConnection * ac_a_effective = sort_info->show_active_fields ? ac_a : NULL; - NMActiveConnection * ac_b_effective = sort_info->show_active_fields ? ac_b : NULL; + NMConnection *c_a = row_data_a->connection; + NMConnection *c_b = row_data_b->connection; + NMActiveConnection *ac_a = row_data_a->primary_active; + NMActiveConnection *ac_b = row_data_b->primary_active; + NMActiveConnection *ac_a_effective = sort_info->show_active_fields ? ac_a : NULL; + NMActiveConnection *ac_b_effective = sort_info->show_active_fields ? ac_b : NULL; /* first sort active-connections which are invisible, i.e. that have no connection */ if (!c_a && c_b) @@ -1815,7 +1818,7 @@ con_show_get_items_cmp(gconstpointer pa, gconstpointer pb, gpointer user_data) /* we have two connections... */ if (c_a && c_b && c_a != c_b) { - const NmcSortOrder * order_arr; + const NmcSortOrder *order_arr; guint i, order_len; NMMetaAccessorGetType get_type = nmc_print_output_to_accessor_get_type(sort_info->nmc->nmc_config.print_output); @@ -1892,15 +1895,15 @@ con_show_get_items(NmCli *nmc, gboolean active_only, gboolean show_active_fields { gs_unref_hashtable GHashTable *row_hash = NULL; GHashTableIter hiter; - GPtrArray * result; - const GPtrArray * arr; - NMRemoteConnection * c; - MetagenConShowRowData * row_data; + GPtrArray *result; + const GPtrArray *arr; + NMRemoteConnection *c; + MetagenConShowRowData *row_data; guint i; const ConShowSortInfo sort_info = { - .nmc = nmc, - .order = order, - .show_active_fields = show_active_fields, + .nmc = nmc, + .order = order, + .show_active_fields = show_active_fields, }; row_hash = g_hash_table_new(nm_direct_hash, NULL); @@ -2003,9 +2006,9 @@ static GArray * parse_preferred_connection_order(const char *order, GError **error) { gs_free const char **strv = NULL; - const char *const * iter; - const char * str; - GArray * order_arr; + const char *const *iter; + const char *str; + GArray *order_arr; NmcSortOrder val; gboolean inverse, unique; guint i; @@ -2057,17 +2060,17 @@ parse_preferred_connection_order(const char *order, GError **error) } static NMConnection * -get_connection(NmCli * nmc, - int * argc, +get_connection(NmCli *nmc, + int *argc, const char *const **argv, - const char ** out_selector, - const char ** out_value, - GPtrArray ** out_result, - GError ** error) + const char **out_selector, + const char **out_value, + GPtrArray **out_result, + GError **error) { const GPtrArray *connections; - NMConnection * connection = NULL; - const char * selector = NULL; + NMConnection *connection = NULL; + const char *selector = NULL; NM_SET_OUT(out_selector, NULL); NM_SET_OUT(out_value, NULL); @@ -2121,11 +2124,11 @@ get_connection(NmCli * nmc, static void do_connections_show(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - gs_free_error GError *err = NULL; - gs_free char * profile_flds = NULL; - gs_free char * active_flds = NULL; - gboolean active_only = FALSE; - gs_unref_array GArray *order = NULL; + gs_free_error GError *err = NULL; + gs_free char *profile_flds = NULL; + gs_free char *active_flds = NULL; + gboolean active_only = FALSE; + gs_unref_array GArray *order = NULL; guint i; int option; @@ -2153,8 +2156,8 @@ do_connections_show(const NMCCommand *cmd, NmCli *nmc, int argc, const char *con } if (argc == 0) { - const char * fields_str = NULL; - gs_unref_ptrarray GPtrArray *items = NULL; + const char *fields_str = NULL; + gs_unref_ptrarray GPtrArray *items = NULL; gs_free NMMetaSelectionResultList *selection = NULL; gboolean show_active_fields = TRUE; @@ -2242,14 +2245,14 @@ do_connections_show(const NMCCommand *cmd, NmCli *nmc, int argc, const char *con } while (argc > 0) { - const GPtrArray *connections; - gboolean res; - NMConnection * con; - gs_unref_object NMActiveConnection *explicit_acon = NULL; - const char * selector = NULL; - gs_unref_ptrarray GPtrArray *found_cons = NULL; - gboolean explicit_acon_handled = FALSE; - guint i_found_cons; + const GPtrArray *connections; + gboolean res; + NMConnection *con; + gs_unref_object NMActiveConnection *explicit_acon = NULL; + const char *selector = NULL; + gs_unref_ptrarray GPtrArray *found_cons = NULL; + gboolean explicit_acon_handled = FALSE; + guint i_found_cons; if (argc == 1 && nmc->complete) nmc_complete_strings(*argv, "id", "uuid", "path", "filename", "apath"); @@ -2396,9 +2399,9 @@ static NMActiveConnection * get_default_active_connection(NmCli *nmc, NMDevice **device) { NMActiveConnection *default_ac = NULL; - NMDevice * non_default_device = NULL; + NMDevice *non_default_device = NULL; NMActiveConnection *non_default_ac = NULL; - const GPtrArray * connections; + const GPtrArray *connections; guint i; g_return_val_if_fail(nmc, NULL); @@ -2408,7 +2411,7 @@ get_default_active_connection(NmCli *nmc, NMDevice **device) connections = nm_client_get_active_connections(nmc->client); for (i = 0; i < connections->len; i++) { NMActiveConnection *candidate = g_ptr_array_index(connections, i); - const GPtrArray * devices; + const GPtrArray *devices; devices = nm_active_connection_get_devices(candidate); if (!devices->len) @@ -2447,17 +2450,17 @@ get_default_active_connection(NmCli *nmc, NMDevice **device) * RETURNS: TRUE when a device is found, FALSE otherwise. */ static gboolean -find_device_for_connection(NmCli * nmc, +find_device_for_connection(NmCli *nmc, NMConnection *connection, - const char * iface, - const char * ap, - const char * nsp, - NMDevice ** device, - const char ** spec_object, - GError ** error) + const char *iface, + const char *ap, + const char *nsp, + NMDevice **device, + const char **spec_object, + GError **error) { NMSettingConnection *s_con; - const char * con_type; + const char *con_type; guint i, j; g_return_val_if_fail(nmc, FALSE); @@ -2495,7 +2498,7 @@ find_device_for_connection(NmCli * nmc, } } else { /* Other connections */ - NMDevice * found_device = NULL; + NMDevice *found_device = NULL; const GPtrArray *devices = nm_client_get_devices(nmc->client); gboolean found_device_with_name = FALSE; @@ -2524,14 +2527,14 @@ find_device_for_connection(NmCli * nmc, found_device = dev; if (ap && nm_streq(con_type, NM_SETTING_WIRELESS_SETTING_NAME) && NM_IS_DEVICE_WIFI(dev)) { - gs_free char * bssid_up = g_ascii_strup(ap, -1); + gs_free char *bssid_up = g_ascii_strup(ap, -1); const GPtrArray *aps = nm_device_wifi_get_access_points(NM_DEVICE_WIFI(dev)); found_device = NULL; /* Mark as not found; set to the device again later, only if AP matches */ for (j = 0; j < aps->len; j++) { NMAccessPoint *candidate_ap = g_ptr_array_index(aps, j); - const char * candidate_bssid = nm_access_point_get_bssid(candidate_ap); + const char *candidate_bssid = nm_access_point_get_bssid(candidate_ap); if (nm_streq0(bssid_up, candidate_bssid)) { found_device = dev; @@ -2575,17 +2578,17 @@ find_device_for_connection(NmCli * nmc, } typedef struct { - NmCli * nmc; - NMDevice * device; + NmCli *nmc; + NMDevice *device; NMActiveConnection *active; } ActivateConnectionInfo; static void active_connection_hint(GString *return_text, NMActiveConnection *active, NMDevice *device) { - NMRemoteConnection * connection; + NMRemoteConnection *connection; nm_auto_free_gstring GString *hint = NULL; - const GPtrArray * devices; + const GPtrArray *devices; guint i; if (!active) @@ -2623,8 +2626,8 @@ static void check_activated(ActivateConnectionInfo *info) { NMActiveConnectionState ac_state; - NmCli * nmc = info->nmc; - const char * reason = NULL; + NmCli *nmc = info->nmc; + const char *reason = NULL; ac_state = nmc_activation_get_effective_state(info->active, info->device, &reason); switch (ac_state) { @@ -2668,10 +2671,10 @@ device_state_cb(NMDevice *device, GParamSpec *pspec, ActivateConnectionInfo *inf } static void -active_connection_state_cb(NMActiveConnection * active, +active_connection_state_cb(NMActiveConnection *active, NMActiveConnectionState state, NMActiveConnectionStateReason reason, - ActivateConnectionInfo * info) + ActivateConnectionInfo *info) { check_activated(info); } @@ -2707,11 +2710,11 @@ progress_cb(gpointer user_data) static gboolean progress_active_connection_cb(gpointer user_data) { - NMActiveConnection * active = user_data; - const char * str; - NMDevice * device; + NMActiveConnection *active = user_data; + const char *str; + NMDevice *device; NMActiveConnectionState ac_state; - const GPtrArray * ac_devs; + const GPtrArray *ac_devs; ac_state = nm_active_connection_get_state(active); @@ -2755,12 +2758,12 @@ static void activate_connection_cb(GObject *client, GAsyncResult *result, gpointer user_data) { ActivateConnectionInfo *info = (ActivateConnectionInfo *) user_data; - NmCli * nmc = info->nmc; - NMDevice * device = info->device; - NMActiveConnection * active; + NmCli *nmc = info->nmc; + NMDevice *device = info->device; + NMActiveConnection *active; NMActiveConnectionState state; - const GPtrArray * ac_devs; - GError * error = NULL; + const GPtrArray *ac_devs; + GError *error = NULL; info->active = active = nm_client_activate_connection_finish(NM_CLIENT(client), result, &error); @@ -2820,19 +2823,19 @@ activate_connection_cb(GObject *client, GAsyncResult *result, gpointer user_data } static gboolean -nmc_activate_connection(NmCli * nmc, - NMConnection * connection, - const char * ifname, - const char * ap, - const char * nsp, - const char * pwds, +nmc_activate_connection(NmCli *nmc, + NMConnection *connection, + const char *ifname, + const char *ap, + const char *nsp, + const char *pwds, GAsyncReadyCallback callback, - GError ** error) + GError **error) { ActivateConnectionInfo *info; GHashTable *pwds_hash; - NMDevice * device = NULL; + NMDevice *device = NULL; const char *spec_object = NULL; gboolean device_found; @@ -2930,16 +2933,16 @@ nmc_activate_connection(NmCli * nmc, static void do_connection_up(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMConnection *connection = NULL; - const char * ifname = NULL; - const char * ap = NULL; - const char * nsp = NULL; - const char * pwds = NULL; - gs_free_error GError *error = NULL; - gs_strfreev char ** arg_arr = NULL; + NMConnection *connection = NULL; + const char *ifname = NULL; + const char *ap = NULL; + const char *nsp = NULL; + const char *pwds = NULL; + gs_free_error GError *error = NULL; + gs_strfreev char **arg_arr = NULL; int arg_num; - const char *const ** argv_ptr; - int * argc_ptr; + const char *const **argv_ptr; + int *argc_ptr; /* * Set default timeout for connection activation. @@ -3058,7 +3061,7 @@ typedef struct { NmCli *nmc; /* a list of object that is relevant for the callback. The object * type differs, and depends on the type of callback. */ - GPtrArray * obj_list; + GPtrArray *obj_list; guint timeout_id; GCancellable *cancellable; } ConnectionCbInfo; @@ -3067,8 +3070,8 @@ static void connection_removed_cb(NMClient *client, NMConnection *connection, ConnectionCbInfo *info); static void down_active_connection_state_cb(NMActiveConnection *active, - GParamSpec * pspec, - ConnectionCbInfo * info); + GParamSpec *pspec, + ConnectionCbInfo *info); static void connection_cb_info_obj_list_destroy(ConnectionCbInfo *info, gpointer obj) @@ -3165,8 +3168,8 @@ connection_removed_cb(NMClient *client, NMConnection *connection, ConnectionCbIn static void down_active_connection_state_cb(NMActiveConnection *active, - GParamSpec * pspec, - ConnectionCbInfo * info) + GParamSpec *pspec, + ConnectionCbInfo *info) { if (nm_active_connection_get_state(active) < NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) return; @@ -3194,13 +3197,13 @@ connection_op_timeout_cb(gpointer user_data) static void do_connection_down(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMActiveConnection *active; - ConnectionCbInfo * info = NULL; - const GPtrArray * active_cons; - gs_strfreev char ** arg_arr = NULL; - const char *const * arg_ptr; - int arg_num; - guint i; + NMActiveConnection *active; + ConnectionCbInfo *info = NULL; + const GPtrArray *active_cons; + gs_strfreev char **arg_arr = NULL; + const char *const *arg_ptr; + int arg_num; + guint i; gs_unref_ptrarray GPtrArray *found_active_cons = NULL; if (nmc->timeout == -1) @@ -3351,7 +3354,7 @@ get_valid_options_string(const NMMetaSettingValidPartItem *const *array, const NMMetaSettingValidPartItem *const *array_slv) { const NMMetaSettingValidPartItem *const *iter = array; - GString * str; + GString *str; int i; str = g_string_sized_new(150); @@ -3422,8 +3425,8 @@ get_valid_settings_array(const char *con_type) } static char * -_construct_property_name(const char * setting_name, - const char * property_name, +_construct_property_name(const char *setting_name, + const char *property_name, NMMetaAccessorModifier modifier) { return g_strdup_printf("%s%s.%s\n", @@ -3452,12 +3455,12 @@ static char * get_valid_properties_string(const NMMetaSettingValidPartItem *const *array, const NMMetaSettingValidPartItem *const *array_slv, NMMetaAccessorModifier modifier, - const char * prefix, - const char * postfix) + const char *prefix, + const char *postfix) { const NMMetaSettingValidPartItem *const *iter = array; - const char * prop_name = NULL; - GString * str; + const char *prop_name = NULL; + GString *str; guint i, j; gboolean full_match = FALSE; @@ -3493,7 +3496,7 @@ get_valid_properties_string(const NMMetaSettingValidPartItem *const *array, /* Search the array with the arguments of the current property */ for (j = 0; j < setting_info->properties_num; j++) { gs_free char *ss1 = NULL; - const char * arg_name; + const char *arg_name; arg_name = setting_info->properties[j]->property_name; @@ -3526,16 +3529,16 @@ get_valid_properties_string(const NMMetaSettingValidPartItem *const *array, * The returned string must not be freed. */ static const char * -check_valid_name(const char * val, +check_valid_name(const char *val, const NMMetaSettingValidPartItem *const *array, const NMMetaSettingValidPartItem *const *array_slv, - GError ** error) + GError **error) { const NMMetaSettingValidPartItem *const *iter; - gs_unref_ptrarray GPtrArray *tmp_arr = NULL; - const char * str; - GError * tmp_err = NULL; - int i; + gs_unref_ptrarray GPtrArray *tmp_arr = NULL; + const char *str; + GError *tmp_err = NULL; + int i; g_return_val_if_fail(array, NULL); @@ -3590,11 +3593,11 @@ check_valid_name(const char * val, static const char * check_valid_name_toplevel(const char *val, const char **slave_type, GError **error) { - gs_unref_ptrarray GPtrArray * tmp_arr = NULL; + gs_unref_ptrarray GPtrArray *tmp_arr = NULL; const NMMetaSettingInfoEditor *setting_info; - gs_free_error GError *tmp_err = NULL; - const char * str; - int i; + gs_free_error GError *tmp_err = NULL; + const char *str; + int i; NM_SET_OUT(slave_type, NULL); @@ -3649,11 +3652,11 @@ check_valid_name_toplevel(const char *val, const char **slave_type, GError **err static gboolean is_setting_mandatory(NMConnection *connection, NMSetting *setting) { - NMSettingConnection * s_con; - const char * c_type; + NMSettingConnection *s_con; + const char *c_type; const NMMetaSettingValidPartItem *const *item; - const char * name; - const char * s_type; + const char *name; + const char *s_type; guint i; s_con = nm_connection_get_setting_connection(connection); @@ -3716,17 +3719,17 @@ _strip_master_prefix(const char *master, const char *(**func)(NMConnection *) ) */ static const char * normalized_master_for_slave(const GPtrArray *connections, - const char * master, - const char * type, - const char ** out_type) + const char *master, + const char *type, + const char **out_type) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - const char * con_type = NULL, *id, *uuid, *ifname; + const char *con_type = NULL, *id, *uuid, *ifname; guint i; - const char * found_by_id = NULL; - const char * out_type_by_id = NULL; - const char * out_master = NULL; + const char *found_by_id = NULL; + const char *out_type_by_id = NULL; + const char *out_master = NULL; const char *(*func)(NMConnection *) = NULL; if (!master) @@ -3806,10 +3809,10 @@ prompt_yes_no(gboolean default_yes, char *delim) } static NMSetting * -is_setting_valid(NMConnection * connection, +is_setting_valid(NMConnection *connection, const NMMetaSettingValidPartItem *const *valid_settings_main, const NMMetaSettingValidPartItem *const *valid_settings_slave, - const char * setting) + const char *setting) { const char *setting_name; @@ -3823,7 +3826,7 @@ static char * is_property_valid(NMSetting *setting, const char *property, GError **error) { gs_strfreev char **valid_props = NULL; - const char * prop_name; + const char *prop_name; valid_props = nmc_setting_get_valid_properties(setting); prop_name = nmc_string_is_valid(property, (const char **) valid_props, error); @@ -3876,7 +3879,7 @@ set_default_interface_name(NmCli *nmc, NMSettingConnection *s_con) if (default_name) { const GPtrArray *connections; - gs_free char * ifname = NULL; + gs_free char *ifname = NULL; connections = nm_client_get_connections(nmc->client); ifname = unique_master_iface_ifname(connections, default_name); @@ -3932,10 +3935,10 @@ _meta_property_needs_bond_hack(const NMMetaPropertyInfo *property_info) static char ** _meta_abstract_complete(const NMMetaAbstractInfo *abstract_info, const char *text) { - const char *const * values; - char ** values_to_free = NULL; + const char *const *values; + char **values_to_free = NULL; const NMMetaOperationContext ctx = { - .connection = nmc_tab_completion.connection, + .connection = nmc_tab_completion.connection, }; values = nm_meta_abstract_info_complete(abstract_info, @@ -3961,14 +3964,14 @@ _meta_abstract_generator(const char *text, int state) } static void -_meta_abstract_get(const NMMetaAbstractInfo * abstract_info, +_meta_abstract_get(const NMMetaAbstractInfo *abstract_info, const NMMetaSettingInfoEditor **out_setting_info, - const char ** out_setting_name, - const char ** out_property_name, - const char ** out_option, - NMMetaPropertyInfFlags * out_inf_flags, - const char ** out_prompt, - const char ** out_def_hint) + const char **out_setting_name, + const char **out_property_name, + const char **out_option, + NMMetaPropertyInfFlags *out_inf_flags, + const char **out_prompt, + const char **out_def_hint) { const NMMetaPropertyInfo *info = (const NMMetaPropertyInfo *) abstract_info; @@ -4031,7 +4034,7 @@ enable_options(const char *setting_name, const char *property, const char *const static void disable_options(const char *setting_name, const char *property) { - const NMMetaPropertyInfo * property_infos_local[2]; + const NMMetaPropertyInfo *property_infos_local[2]; const NMMetaPropertyInfo *const *property_infos; guint p; @@ -4119,17 +4122,17 @@ reset_options(void) } static gboolean -set_property(NMClient * client, - NMConnection * connection, - const char * setting_name, - const char * property, - const char * value, +set_property(NMClient *client, + NMConnection *connection, + const char *setting_name, + const char *property, + const char *value, NMMetaAccessorModifier modifier, - GError ** error) + GError **error) { - gs_free char *property_name = NULL; - gs_free_error GError *local = NULL; - NMSetting * setting; + gs_free char *property_name = NULL; + gs_free_error GError *local = NULL; + NMSetting *setting; nm_assert(setting_name && setting_name[0]); nm_assert(NM_IN_SET(modifier, @@ -4182,15 +4185,15 @@ set_property(NMClient * client, } static gboolean -set_option(NmCli * nmc, - NMConnection * connection, +set_option(NmCli *nmc, + NMConnection *connection, const NMMetaAbstractInfo *abstract_info, - const char * value, - GError ** error) + const char *value, + GError **error) { - const char * setting_name, *property_name, *option_name; + const char *setting_name, *property_name, *option_name; NMMetaPropertyInfFlags inf_flags; - const OptionInfo * option; + const OptionInfo *option; option = _meta_abstract_get_option_info(abstract_info); @@ -4227,12 +4230,12 @@ set_option(NmCli * nmc, * and slave type. */ static gboolean -con_settings(NMConnection * connection, +con_settings(NMConnection *connection, const NMMetaSettingValidPartItem *const **type_settings, const NMMetaSettingValidPartItem *const **slv_settings, - GError ** error) + GError **error) { - const char * con_type; + const char *con_type; NMSettingConnection *s_con; g_return_val_if_fail(type_settings, FALSE); @@ -4332,17 +4335,17 @@ gen_func_bond_lacp_rate(const char *text, int state) /*****************************************************************************/ static gboolean -set_connection_type(NmCli * nmc, - NMConnection * con, +set_connection_type(NmCli *nmc, + NMConnection *con, const OptionInfo *option, - const char * value, - GError ** error) + const char *value, + GError **error) { const NMMetaSettingValidPartItem *const *type_settings; const NMMetaSettingValidPartItem *const *slv_settings; - GError * local = NULL; - const char * master[] = {"master", NULL}; - const char * slave_type = NULL; + GError *local = NULL; + const char *master[] = {"master", NULL}; + const char *slave_type = NULL; value = check_valid_name_toplevel(value, &slave_type, &local); if (!value) { @@ -4396,11 +4399,11 @@ set_connection_type(NmCli * nmc, } static gboolean -set_connection_iface(NmCli * nmc, - NMConnection * con, +set_connection_iface(NmCli *nmc, + NMConnection *con, const OptionInfo *option, - const char * value, - GError ** error) + const char *value, + GError **error) { if (value) { /* Special value of '*' means no specific interface name */ @@ -4418,15 +4421,15 @@ set_connection_iface(NmCli * nmc, } static gboolean -set_connection_master(NmCli * nmc, - NMConnection * con, +set_connection_master(NmCli *nmc, + NMConnection *con, const OptionInfo *option, - const char * value, - GError ** error) + const char *value, + GError **error) { - const GPtrArray * connections; + const GPtrArray *connections; NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(con); g_return_val_if_fail(s_con, FALSE); @@ -4463,16 +4466,16 @@ set_connection_master(NmCli * nmc, } static gboolean -set_bond_option(NmCli * nmc, - NMConnection * con, +set_bond_option(NmCli *nmc, + NMConnection *con, const OptionInfo *option, - const char * value, - GError ** error) + const char *value, + GError **error) { NMSettingBond *s_bond; gboolean success; - gs_free char * name = NULL; - char * p; + gs_free char *name = NULL; + char *p; s_bond = nm_connection_get_setting_bond(con); g_return_val_if_fail(s_bond, FALSE); @@ -4507,16 +4510,16 @@ set_bond_option(NmCli * nmc, } static gboolean -set_bond_monitoring_mode(NmCli * nmc, - NMConnection * con, +set_bond_monitoring_mode(NmCli *nmc, + NMConnection *con, const OptionInfo *option, - const char * value, - GError ** error) + const char *value, + GError **error) { NMSettingBond *s_bond; - gs_free char * monitor_mode = NULL; - const char * miimon_opts[] = {"miimon", "downdelay", "updelay", NULL}; - const char * arp_opts[] = {"arp-interval", "arp-ip-target", NULL}; + gs_free char *monitor_mode = NULL; + const char *miimon_opts[] = {"miimon", "downdelay", "updelay", NULL}; + const char *arp_opts[] = {"arp-interval", "arp-ip-target", NULL}; s_bond = nm_connection_get_setting_bond(con); g_return_val_if_fail(s_bond, FALSE); @@ -4547,11 +4550,11 @@ set_bond_monitoring_mode(NmCli * nmc, } static gboolean -set_bluetooth_type(NmCli * nmc, - NMConnection * con, +set_bluetooth_type(NmCli *nmc, + NMConnection *con, const OptionInfo *option, - const char * value, - GError ** error) + const char *value, + GError **error) { NMSetting *setting; @@ -4595,11 +4598,11 @@ set_bluetooth_type(NmCli * nmc, } static gboolean -set_ip4_address(NmCli * nmc, - NMConnection * con, +set_ip4_address(NmCli *nmc, + NMConnection *con, const OptionInfo *option, - const char * value, - GError ** error) + const char *value, + GError **error) { NMSettingIPConfig *s_ip4; @@ -4622,11 +4625,11 @@ set_ip4_address(NmCli * nmc, } static gboolean -set_ip6_address(NmCli * nmc, - NMConnection * con, +set_ip6_address(NmCli *nmc, + NMConnection *con, const OptionInfo *option, - const char * value, - GError ** error) + const char *value, + GError **error) { NMSettingIPConfig *s_ip6; @@ -4703,9 +4706,9 @@ _meta_abstract_get_option_info(const NMMetaAbstractInfo *abstract_info) OPTION_INFO(IP6_CONFIG, NM_SETTING_IP_CONFIG_ADDRESSES, "ip6", set_ip6_address, NULL), {0}, }; - const char * property_name, *option; + const char *property_name, *option; const NMMetaSettingInfoEditor *setting_info; - const OptionInfo * candidate; + const OptionInfo *candidate; _meta_abstract_get(abstract_info, &setting_info, @@ -4728,7 +4731,7 @@ _meta_abstract_get_option_info(const NMMetaAbstractInfo *abstract_info) static gboolean option_relevant(NMConnection *connection, const NMMetaAbstractInfo *abstract_info) { - const char * setting_name; + const char *setting_name; NMMetaPropertyInfFlags inf_flags; _meta_abstract_get(abstract_info, NULL, &setting_name, NULL, NULL, &inf_flags, NULL, NULL); @@ -4746,18 +4749,18 @@ option_relevant(NMConnection *connection, const NMMetaAbstractInfo *abstract_inf /*****************************************************************************/ static void -complete_property_name(NmCli * nmc, - NMConnection * connection, +complete_property_name(NmCli *nmc, + NMConnection *connection, NMMetaAccessorModifier modifier, - const char * prefix, - const char * postfix) + const char *prefix, + const char *postfix) { - NMSettingConnection * s_con; + NMSettingConnection *s_con; const NMMetaSettingValidPartItem *const *valid_settings_main; const NMMetaSettingValidPartItem *const *valid_settings_slave; - const char * connection_type = NULL; - const char * slave_type = NULL; - gs_free char * word_list = NULL; + const char *connection_type = NULL; + const char *slave_type = NULL; + gs_free char *word_list = NULL; NMMetaSettingType s; connection_type = nm_connection_get_connection_type(connection); @@ -4831,17 +4834,17 @@ run_rl_generator(rl_compentry_func_t *generator_func, const char *prefix) } static gboolean -complete_option(NmCli * nmc, +complete_option(NmCli *nmc, const NMMetaAbstractInfo *abstract_info, - const char * prefix, - NMConnection * context_connection) + const char *prefix, + NMConnection *context_connection) { - const OptionInfo * candidate; - const char *const * values; - gs_strfreev char ** values_to_free = NULL; + const OptionInfo *candidate; + const char *const *values; + gs_strfreev char **values_to_free = NULL; gboolean complete_filename = FALSE; const NMMetaOperationContext ctx = { - .connection = context_connection, + .connection = context_connection, }; values = nm_meta_abstract_info_complete(abstract_info, @@ -4873,7 +4876,7 @@ complete_option(NmCli * nmc, static void complete_existing_setting(NmCli *nmc, NMConnection *connection, const char *prefix) { - gs_free NMSetting ** settings = NULL; + gs_free NMSetting **settings = NULL; const NMMetaSettingInfoEditor *editor; guint i; @@ -4892,10 +4895,10 @@ complete_existing_setting(NmCli *nmc, NMConnection *connection, const char *pref } static void -complete_property(NmCli * nmc, - const char * setting_name, - const char * property, - const char * prefix, +complete_property(NmCli *nmc, + const char *setting_name, + const char *property, + const char *prefix, NMConnection *connection) { const NMMetaPropertyInfo *property_info; @@ -4928,11 +4931,11 @@ connection_remove_setting(NMConnection *connection, NMSetting *setting, GError * } static gboolean -get_value(const char ** value, - int * argc, +get_value(const char **value, + int *argc, const char *const **argv, - const char * option, - GError ** error) + const char *option, + GError **error) { if (!**argv) { g_set_error(error, @@ -4955,12 +4958,12 @@ get_value(const char ** value, } gboolean -nmc_process_connection_properties(NmCli * nmc, - NMConnection * connection, - int * argc, +nmc_process_connection_properties(NmCli *nmc, + NMConnection *connection, + int *argc, const char *const **argv, gboolean allow_setting_removal, - GError ** error) + GError **error) { /* First check if we have a slave-type, as this would mean we will not * have ip properties but possibly others, slave-type specific. @@ -4970,13 +4973,13 @@ nmc_process_connection_properties(NmCli * nmc, const NMMetaSettingValidPartItem *const *type_settings; const NMMetaSettingValidPartItem *const *slv_settings; NMMetaAccessorModifier modifier; - const char * option_orig; - const char * option; - const char * value = NULL; - const char * tmp; - const NMMetaAbstractInfo * chosen = NULL; - const char * chosen_setting_name = NULL; - const char * chosen_option = NULL; + const char *option_orig; + const char *option; + const char *value = NULL; + const char *tmp; + const NMMetaAbstractInfo *chosen = NULL; + const char *chosen_setting_name = NULL; + const char *chosen_option = NULL; NMMetaSettingType s; if (!con_settings(connection, &type_settings, &slv_settings, error)) @@ -5016,7 +5019,7 @@ nmc_process_connection_properties(NmCli * nmc, if (allow_setting_removal && modifier == NM_META_ACCESSOR_MODIFIER_SET && nm_streq(option, "remove")) { - NMSetting * ss; + NMSetting *ss; const char *setting_name; (*argc)--; @@ -5060,9 +5063,9 @@ nmc_process_connection_properties(NmCli * nmc, if ((tmp = strchr(option, '.'))) { gs_free char *option_sett = g_strndup(option, tmp - option); - const char * option_prop = &tmp[1]; - const char * option_sett_expanded; - GError * local = NULL; + const char *option_prop = &tmp[1]; + const char *option_sett_expanded; + GError *local = NULL; /* This seems like a . (such as "connection.id" or "bond.mode"), * optionally prefixed with "+| or "-". */ @@ -5208,10 +5211,10 @@ static void add_connection_cb(GObject *client, GAsyncResult *result, gpointer user_data) { nm_auto_free_add_connection_info AddConnectionInfo *info = user_data; - NmCli * nmc = info->nmc; - NMRemoteConnection * connection; - GError * error = NULL; - const GPtrArray * connections; + NmCli *nmc = info->nmc; + NMRemoteConnection *connection; + GError *error = NULL; + const GPtrArray *connections; guint i, found; connection = nm_client_add_connection2_finish(NM_CLIENT(client), result, NULL, &error); @@ -5266,8 +5269,8 @@ add_connection_cb(GObject *client, GAsyncResult *result, gpointer user_data) } static void -add_connection(NMClient * client, - NMConnection * connection, +add_connection(NMClient *client, + NMConnection *connection, gboolean temporary, GAsyncReadyCallback callback, gpointer user_data) @@ -5311,10 +5314,10 @@ static char ** nmcli_con_add_tab_completion(const char *text, int start, int end) { NMMetaSettingType s; - char ** match_array = NULL; - rl_compentry_func_t * generator_func = NULL; - gs_free char * no = g_strdup_printf("[%s]: ", _("no")); - gs_free char * yes = g_strdup_printf("[%s]: ", _("yes")); + char **match_array = NULL; + rl_compentry_func_t *generator_func = NULL; + gs_free char *no = g_strdup_printf("[%s]: ", _("no")); + gs_free char *yes = g_strdup_printf("[%s]: ", _("yes")); const NMMetaAbstractInfo *info; /* Disable readline's default filename completion */ @@ -5379,11 +5382,11 @@ next: static void ask_option(NmCli *nmc, NMConnection *connection, const NMMetaAbstractInfo *abstract_info) { - char * value; - GError * error = NULL; - gs_free char * prompt = NULL; + char *value; + GError *error = NULL; + gs_free char *prompt = NULL; gboolean multi; - const char * opt_prompt, *opt_def_hint; + const char *opt_prompt, *opt_def_hint; NMMetaPropertyInfFlags inf_flags; _meta_abstract_get(abstract_info, @@ -5420,8 +5423,8 @@ again: static NMMetaSettingType connection_get_base_meta_setting_type(NMConnection *connection) { - const char * connection_type; - NMSetting * base_setting; + const char *connection_type; + NMSetting *base_setting; const NMMetaSettingInfoEditor *editor; connection_type = nm_connection_get_connection_type(connection); @@ -5438,7 +5441,7 @@ static void questionnaire_mandatory_ask_setting(NmCli *nmc, NMConnection *connection, NMMetaSettingType type) { const NMMetaSettingInfoEditor *editor; - const NMMetaPropertyInfo * property_info; + const NMMetaPropertyInfo *property_info; guint p; editor = &nm_meta_setting_infos_editor[type]; @@ -5516,7 +5519,7 @@ want_provide_opt_args(const NmcConfig *nmc_config, const char *type, guint num) static gboolean questionnaire_one_optional(NmCli *nmc, NMConnection *connection) { - NMMetaSettingType base; + NMMetaSettingType base; gs_unref_ptrarray GPtrArray *infos = NULL; guint i, j; gboolean already_confirmed = FALSE; @@ -5600,11 +5603,11 @@ static void do_connection_add(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - gs_free_error GError *error = NULL; - gboolean save_bool = TRUE; - gboolean seen_dash_dash = FALSE; - NMMetaSettingType s; + NMSettingConnection *s_con; + gs_free_error GError *error = NULL; + gboolean save_bool = TRUE; + gboolean seen_dash_dash = FALSE; + NMMetaSettingType s; next_arg(nmc, &argc, &argv, NULL); @@ -5679,8 +5682,8 @@ read_properties: /* If only bother when there's a type, which is not guaranteed at this point. * Otherwise, the validation will fail anyway. */ if (type) { - gs_free char * try_name = NULL; - gs_free char * default_name = NULL; + gs_free char *try_name = NULL; + gs_free char *default_name = NULL; const GPtrArray *connections; connections = nm_client_get_connections(nmc->client); @@ -5769,10 +5772,10 @@ static void uuid_display_hook(char **array, int len, int max_len) { const GPtrArray *connections; - NMConnection * con; + NMConnection *con; int i, max = 0; - char * tmp; - const char * id; + char *tmp; + const char *id; for (i = 1; i <= len; i++) { connections = nm_client_get_connections(nmc_tab_completion.nmc->client); con = nmc_find_connection(connections, "uuid", array[i], NULL, FALSE); @@ -5842,12 +5845,12 @@ static char * gen_cmd_print0(const char *text, int state) { static char **words = NULL; - char * ret = NULL; + char *ret = NULL; if (!state) { - GVariant * settings; + GVariant *settings; GVariantIter iter; - const char * setting_name; + const char *setting_name; int i = 0; settings = nm_connection_to_dbus(nmc_tab_completion.connection, @@ -5888,9 +5891,9 @@ gen_cmd_save(const char *text, int state) static rl_compentry_func_t * gen_connection_types(const char *text) { - gs_free char ** values = NULL; + gs_free char **values = NULL; const NMMetaSettingInfoEditor *editor; - GPtrArray * array; + GPtrArray *array; int i; array = g_ptr_array_new(); @@ -5918,10 +5921,10 @@ static char * gen_setting_names(const char *text, int state) { static int list_idx, len, is_slv; - const char * s_name, *a_name; + const char *s_name, *a_name; const NMMetaSettingValidPartItem *const *valid_settings_arr; - NMSettingConnection * s_con; - const char * s_type = NULL; + NMSettingConnection *s_con; + const char *s_type = NULL; if (!state) { list_idx = 0; @@ -5982,16 +5985,16 @@ gen_setting_names(const char *text, int state) static char * gen_property_names(const char *text, int state) { - NMSetting * setting = NULL; - char ** valid_props = NULL; - char * ret = NULL; - const char * line = rl_line_buffer; - const char * setting_name; - char ** strv = NULL; + NMSetting *setting = NULL; + char **valid_props = NULL; + char *ret = NULL; + const char *line = rl_line_buffer; + const char *setting_name; + char **strv = NULL; const NMMetaSettingValidPartItem *const *valid_settings_main; const NMMetaSettingValidPartItem *const *valid_settings_slave; - const char * p1; - const char * slv_type; + const char *p1; + const char *slv_type; /* Try to get the setting from 'line' - setting_name.property */ p1 = strchr(line, '.'); @@ -6046,8 +6049,8 @@ gen_compat_devices(const char *text, int state) { guint i, j = 0; const GPtrArray *devices; - const char ** compatible_devices; - char * ret; + const char **compatible_devices; + char *ret; devices = nm_client_get_devices(nmc_tab_completion.nmc->client); if (devices->len == 0) @@ -6055,9 +6058,9 @@ gen_compat_devices(const char *text, int state) compatible_devices = g_new(const char *, devices->len + 1); for (i = 0; i < devices->len; i++) { - NMDevice * dev = g_ptr_array_index(devices, i); + NMDevice *dev = g_ptr_array_index(devices, i); const char *ifname = nm_device_get_iface(dev); - NMDevice * device = NULL; + NMDevice *device = NULL; const char *spec_object = NULL; if (find_device_for_connection(nmc_tab_completion.nmc, @@ -6091,7 +6094,7 @@ _create_vpn_array(const GPtrArray *connections, gboolean uuid) array = g_new(const char *, connections->len + 1); for (c = 0; c < connections->len; c++) { NMConnection *connection = NM_CONNECTION(connections->pdata[c]); - const char * type = nm_connection_get_connection_type(connection); + const char *type = nm_connection_get_connection_type(connection); if (nm_streq0(type, NM_SETTING_VPN_SETTING_NAME)) array[idx++] = @@ -6105,8 +6108,8 @@ static char * gen_vpn_uuids(const char *text, int state) { const GPtrArray *connections; - const char ** uuids; - char * ret; + const char **uuids; + char *ret; connections = nm_client_get_connections(nm_cli_global_readline->client); if (connections->len < 1) @@ -6122,8 +6125,8 @@ static char * gen_vpn_ids(const char *text, int state) { const GPtrArray *connections; - const char ** ids; - char * ret; + const char **ids; + char *ret; connections = nm_client_get_connections(nm_cli_global_readline->client); if (connections->len < 1) @@ -6171,7 +6174,7 @@ get_gen_func_cmd_nmcli(const char *str) static gboolean should_complete_cmd(const char *line, int end, const char *cmd, int *cw_num, char **prev_word) { - char * tmp; + char *tmp; const char *word1, *word2, *word3; size_t n1, n2, n3, n4, n5, n6; gboolean word1_done, word2_done, word3_done; @@ -6305,17 +6308,17 @@ static void get_setting_and_property(const char *prompt, const char *line, NMSetting **setting_out, - char ** property_out) + char **property_out) { const NMMetaSettingValidPartItem *const *valid_settings_main; const NMMetaSettingValidPartItem *const *valid_settings_slave; - gs_unref_object NMSetting *setting = NULL; - gs_free char * property = NULL; - NMSettingConnection * s_con; - gs_free char * sett = NULL; - gs_free char * prop = NULL; - const char * s_type = NULL; - const char * setting_name; + gs_unref_object NMSetting *setting = NULL; + gs_free char *property = NULL; + NMSettingConnection *s_con; + gs_free char *sett = NULL; + gs_free char *prop = NULL; + const char *s_type = NULL; + const char *setting_name; extract_setting_and_property(prompt, line, &sett, &prop); @@ -6345,11 +6348,11 @@ get_setting_and_property(const char *prompt, } static gboolean -_get_and_check_property(const char * prompt, - const char * line, +_get_and_check_property(const char *prompt, + const char *line, const char **array, const char **array_multi, - gboolean * multi) + gboolean *multi) { gs_free char *prop = NULL; gboolean found = FALSE; @@ -6398,8 +6401,8 @@ static const char *const * get_allowed_property_values(char ***out_to_free) { gs_unref_object NMSetting *setting = NULL; - gs_free char * property = NULL; - const char *const * avals = NULL; + gs_free char *property = NULL; + const char *const *avals = NULL; get_setting_and_property(rl_prompt, rl_line_buffer, &setting, &property); if (setting && property) @@ -6444,7 +6447,7 @@ static gboolean should_complete_boolean(const char *prompt, const char *line) { gs_unref_object NMSetting *setting = NULL; - gs_free char * property = NULL; + gs_free char *property = NULL; get_setting_and_property(prompt, line, &setting, &property); return setting && property && _setting_property_is_boolean(setting, property); @@ -6477,10 +6480,10 @@ static char ** nmcli_editor_tab_completion(const char *text, int start, int end) { rl_compentry_func_t *generator_func = NULL; - const char * line = rl_line_buffer; - gs_free char * prompt_tmp = NULL; - gs_free char * word = NULL; - char ** match_array = NULL; + const char *line = rl_line_buffer; + gs_free char *prompt_tmp = NULL; + gs_free char *word = NULL; + char **match_array = NULL; size_t n1; int num; @@ -6615,11 +6618,11 @@ static void load_history_cmds(const char *uuid) { GKeyFile *kf; - char * filename; - char ** keys; - char * line; + char *filename; + char **keys; + char *line; size_t i; - GError * err = NULL; + GError *err = NULL; filename = g_build_filename(g_get_home_dir(), NMCLI_EDITOR_HISTORY, NULL); kf = g_key_file_new(); @@ -6645,13 +6648,13 @@ load_history_cmds(const char *uuid) static void save_history_cmds(const char *uuid) { - nm_auto_unref_keyfile GKeyFile *kf = NULL; - gs_free_error GError *error = NULL; - gs_free char * filename = NULL; - gs_free char * data = NULL; - HIST_ENTRY ** hist; - gsize len; - gsize i; + nm_auto_unref_keyfile GKeyFile *kf = NULL; + gs_free_error GError *error = NULL; + gs_free char *filename = NULL; + gs_free char *data = NULL; + HIST_ENTRY **hist; + gsize len; + gsize i; hist = history_list(); if (!hist) @@ -6729,7 +6732,7 @@ static void _split_cmd(const char *cmd, char **out_arg0, const char **out_argr) { gs_free char *arg0 = NULL; - const char * argr = NULL; + const char *argr = NULL; gsize l; NM_SET_OUT(out_arg0, NULL); @@ -6760,8 +6763,8 @@ static NmcEditorMainCmd parse_editor_main_cmd(const char *cmd, char **cmd_arg) { NmcEditorMainCmd editor_cmd = NMC_EDITOR_MAIN_CMD_UNKNOWN; - gs_free char * cmd_arg0 = NULL; - const char * cmd_argr; + gs_free char *cmd_arg0 = NULL; + const char *cmd_argr; _split_cmd(cmd, &cmd_arg0, &cmd_argr); if (!cmd_arg0) @@ -6951,8 +6954,8 @@ static NmcEditorSubCmd parse_editor_sub_cmd(const char *cmd, char **cmd_arg) { NmcEditorSubCmd editor_cmd = NMC_EDITOR_SUB_CMD_UNKNOWN; - gs_free char * cmd_arg0 = NULL; - const char * cmd_argr; + gs_free char *cmd_arg0 = NULL; + const char *cmd_argr; _split_cmd(cmd, &cmd_arg0, &cmd_argr); if (!cmd_arg0) @@ -7074,14 +7077,14 @@ editor_sub_usage(const char *command) /*****************************************************************************/ typedef struct { - NMDevice * device; + NMDevice *device; NMActiveConnection *ac; guint monitor_id; - NmCli * nmc; + NmCli *nmc; } MonitorACInfo; static gboolean nmc_editor_cb_called; -static GError * nmc_editor_error; +static GError *nmc_editor_error; static MonitorACInfo *nmc_editor_monitor_ac; static void @@ -7107,7 +7110,7 @@ static void add_connection_editor_cb(GObject *client, GAsyncResult *result, gpointer user_data) { gs_unref_object NMRemoteConnection *connection = NULL; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; connection = nm_client_add_connection2_finish(NM_CLIENT(client), result, NULL, &error); set_info_and_signal_editor_thread(error, NULL); @@ -7126,9 +7129,9 @@ update_connection_editor_cb(GObject *connection, GAsyncResult *result, gpointer static gboolean progress_activation_editor_cb(gpointer user_data) { - MonitorACInfo * info = (MonitorACInfo *) user_data; - NMDevice * device = info->device; - NMActiveConnection * ac = info->ac; + MonitorACInfo *info = (MonitorACInfo *) user_data; + NMDevice *device = info->device; + NMActiveConnection *ac = info->ac; NMActiveConnectionState ac_state; NMDeviceState dev_state; @@ -7174,11 +7177,11 @@ static void activate_connection_editor_cb(GObject *client, GAsyncResult *result, gpointer user_data) { ActivateConnectionInfo *info = (ActivateConnectionInfo *) user_data; - NMDevice * device = info->device; - const GPtrArray * ac_devs; - MonitorACInfo * monitor_ac_info = NULL; - NMActiveConnection * active; - GError * error = NULL; + NMDevice *device = info->device; + const GPtrArray *ac_devs; + MonitorACInfo *monitor_ac_info = NULL; + NMActiveConnection *active; + GError *error = NULL; active = nm_client_activate_connection_finish(NM_CLIENT(client), result, &error); @@ -7237,7 +7240,7 @@ static void editor_show_status_line(NMConnection *connection, gboolean dirty, gboolean temp) { NMSettingConnection *s_con; - const char * con_type, *con_id, *con_uuid; + const char *con_type, *con_id, *con_uuid; s_con = nm_connection_get_setting_connection(connection); g_assert(s_con); @@ -7296,17 +7299,17 @@ confirm_quit(const NmcConfig *nmc_config) * Return: TRUE - continue; FALSE - should quit */ static gboolean -property_edit_submenu(NmCli * nmc, - NMConnection * connection, +property_edit_submenu(NmCli *nmc, + NMConnection *connection, NMRemoteConnection **rem_con, - GWeakRef * rem_con_weak, - NMSetting * curr_setting, - const char * prop_name) + GWeakRef *rem_con_weak, + NMSetting *curr_setting, + const char *prop_name) { NmcEditorSubCmd cmdsub; gboolean set_result; - GError * tmp_err = NULL; - gs_free char * prompt = NULL; + GError *tmp_err = NULL; + gs_free char *prompt = NULL; gboolean temp_changes; /* Set global variable for use in TAB completion */ @@ -7467,8 +7470,8 @@ static void split_editor_main_cmd_args(const char *str, char **setting, char **property, char **value) { gs_free char *cmd_arg0 = NULL; - const char * cmd_argr; - const char * s; + const char *cmd_argr; + const char *s; NM_SET_OUT(setting, NULL); NM_SET_OUT(property, NULL); @@ -7489,12 +7492,12 @@ split_editor_main_cmd_args(const char *str, char **setting, char **property, cha } static NMSetting * -create_setting_by_name(const char * name, +create_setting_by_name(const char *name, const NMMetaSettingValidPartItem *const *valid_settings_main, const NMMetaSettingValidPartItem *const *valid_settings_slave) { const char *setting_name; - NMSetting * setting = NULL; + NMSetting *setting = NULL; /* Get a valid setting name */ setting_name = check_valid_name(name, valid_settings_main, valid_settings_slave, NULL); @@ -7508,15 +7511,15 @@ create_setting_by_name(const char * name, } static const char * -ask_check_setting(const NmcConfig * nmc_config, - const char * arg, +ask_check_setting(const NmcConfig *nmc_config, + const char *arg, const NMMetaSettingValidPartItem *const *valid_settings_main, const NMMetaSettingValidPartItem *const *valid_settings_slave, - const char * valid_settings_str) + const char *valid_settings_str) { gs_free char *setting_name_user = NULL; - const char * setting_name; - GError * err = NULL; + const char *setting_name; + GError *err = NULL; if (!arg) { g_print(_("Available settings: %s\n"), valid_settings_str); @@ -7538,13 +7541,13 @@ ask_check_setting(const NmcConfig * nmc_config, static const char * ask_check_property(const NmcConfig *nmc_config, - const char * arg, - const char ** valid_props, - const char * valid_props_str) + const char *arg, + const char **valid_props, + const char *valid_props_str) { gs_free_error GError *tmp_err = NULL; - gs_free char * prop_name_user = NULL; - const char * prop_name; + gs_free char *prop_name_user = NULL; + const char *prop_name; if (!arg) { g_print(_("Available properties: %s\n"), valid_props_str); @@ -7609,16 +7612,16 @@ confirm_connection_saving(const NmcConfig *nmc_config, NMConnection *local, NMCo typedef struct { guint level; - char * main_prompt; + char *main_prompt; NMSetting *curr_setting; - char ** valid_props; - char * valid_props_str; + char **valid_props; + char *valid_props_str; } NmcEditorMenuContext; static void -menu_switch_to_level0(const NmcConfig * nmc_config, +menu_switch_to_level0(const NmcConfig *nmc_config, NmcEditorMenuContext *menu_ctx, - const char * prompt) + const char *prompt) { menu_ctx->level = 0; g_free(menu_ctx->main_prompt); @@ -7631,10 +7634,10 @@ menu_switch_to_level0(const NmcConfig * nmc_config, } static void -menu_switch_to_level1(const NmcConfig * nmc_config, +menu_switch_to_level1(const NmcConfig *nmc_config, NmcEditorMenuContext *menu_ctx, - NMSetting * setting, - const char * setting_name) + NMSetting *setting, + const char *setting_name) { menu_ctx->level = 1; g_free(menu_ctx->main_prompt); @@ -7660,19 +7663,19 @@ editor_save_timeout(gpointer user_data) static gboolean editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_type) { - gs_unref_object NMRemoteConnection * rem_con = NULL; - NMSettingConnection * s_con; - NMRemoteConnection * con_tmp; + gs_unref_object NMRemoteConnection *rem_con = NULL; + NMSettingConnection *s_con; + NMRemoteConnection *con_tmp; GWeakRef weak = {{NULL}}; gboolean removed; NmcEditorMainCmd cmd; gboolean cmd_loop = TRUE; const NMMetaSettingValidPartItem *const *valid_settings_main; const NMMetaSettingValidPartItem *const *valid_settings_slave; - gs_free char * valid_settings_str = NULL; - const char * s_type = NULL; + gs_free char *valid_settings_str = NULL; + const char *s_type = NULL; gboolean temp_changes; - GError * err1 = NULL; + GError *err1 = NULL; NmcEditorMenuContext menu_ctx = {0}; s_con = nm_connection_get_setting_connection(connection); @@ -7729,10 +7732,10 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty if (!cmd_arg) { if (menu_ctx.level == 1) { gs_strfreev char **avals_to_free = NULL; - gs_free char * prop_val_user = NULL; - const char * prop_name; + gs_free char *prop_val_user = NULL; + const char *prop_name; const char *const *avals; - GError * tmp_err = NULL; + GError *tmp_err = NULL; prop_name = ask_check_property(&nmc->nmc_config, cmd_arg, @@ -7769,10 +7772,10 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty g_print(_("use 'goto ' first, or 'set .'\n")); } } else { - gs_free char * prop_name = NULL; + gs_free char *prop_name = NULL; gs_unref_object NMSetting *ss_created = NULL; - NMSetting * ss = NULL; - GError * tmp_err = NULL; + NMSetting *ss = NULL; + GError *tmp_err = NULL; if (cmd_arg_s) { /* setting provided as "setting.property" */ @@ -7847,7 +7850,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty if (menu_ctx.level == 0 || cmd_arg_s) { /* in top level - no setting selected yet */ const char *setting_name; - NMSetting * setting; + NMSetting *setting; const char *user_arg = cmd_arg_s ?: cmd_arg_p; setting_name = ask_check_setting(&nmc->nmc_config, @@ -7920,7 +7923,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty /* Remove setting from connection, or delete value of a property */ if (!cmd_arg) { if (menu_ctx.level == 1) { - GError * tmp_err = NULL; + GError *tmp_err = NULL; const char *prop_name; prop_name = ask_check_property(&nmc->nmc_config, @@ -7946,7 +7949,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty } else { NMSetting *ss = NULL; gboolean descr_all; - char * user_s; + char *user_s; /* cmd_arg_s != NULL means argument is "setting.property" */ descr_all = !cmd_arg_s && !menu_ctx.curr_setting; @@ -7985,8 +7988,8 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty nmc_tab_completion.setting = NULL; /* for TAB completion */ } } else { - gs_free char *prop_name = NULL; - gs_free_error GError *tmp_err = NULL; + gs_free char *prop_name = NULL; + gs_free_error GError *tmp_err = NULL; prop_name = is_property_valid(ss, cmd_arg_p, &tmp_err); if (prop_name) { @@ -8051,9 +8054,9 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty } } else { gs_unref_object NMSetting *ss_free = NULL; - NMSetting * ss = NULL; + NMSetting *ss = NULL; gboolean descr_all; - char * user_s; + char *user_s; /* cmd_arg_s != NULL means argument is "setting.property" */ descr_all = !cmd_arg_s && !menu_ctx.curr_setting; @@ -8086,7 +8089,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty print_setting_description(ss); } else { gs_free_error GError *tmp_err = NULL; - gs_free char * prop_name = NULL; + gs_free char *prop_name = NULL; prop_name = is_property_valid(ss, cmd_arg_p, &tmp_err); if (prop_name) { @@ -8120,7 +8123,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty else { NMSetting *ss = NULL; gboolean whole_setting; - char * user_s; + char *user_s; /* cmd_arg_s != NULL means argument is "setting.property" */ whole_setting = !cmd_arg_s && !menu_ctx.curr_setting; @@ -8150,7 +8153,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty editor_show_setting(ss, nmc); } else { gs_free char *prop_name = NULL; - GError * err = NULL; + GError *err = NULL; prop_name = is_property_valid(ss, cmd_arg_p, &err); if (prop_name) { @@ -8220,8 +8223,8 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty case NMC_EDITOR_MAIN_CMD_SAVE: /* Save the connection */ if (nm_connection_verify(connection, &err1)) { - gboolean temporary = FALSE; - gboolean connection_changed; + gboolean temporary = FALSE; + gboolean connection_changed; nm_auto_unref_gsource GSource *source = NULL; gboolean timeout = FALSE; gulong handler_id = 0; @@ -8338,7 +8341,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty case NMC_EDITOR_MAIN_CMD_ACTIVATE: { - GError * tmp_err = NULL; + GError *tmp_err = NULL; const char *ifname = cmd_arg_p; const char *ap_nsp = cmd_arg_v; @@ -8421,7 +8424,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty case NMC_EDITOR_MAIN_CMD_NMCLI: if (cmd_arg_p && matches(cmd_arg_p, "status-line")) { - GError * tmp_err = NULL; + GError *tmp_err = NULL; gboolean bb; if (!nmc_string_to_bool(cmd_arg_v ? g_strstrip(cmd_arg_v) : "", &bb, &tmp_err)) { g_print(_("Error: status-line: %s\n"), tmp_err->message); @@ -8429,7 +8432,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty } else nmc->editor_status_line = bb; } else if (cmd_arg_p && matches(cmd_arg_p, "save-confirmation")) { - GError * tmp_err = NULL; + GError *tmp_err = NULL; gboolean bb; if (!nmc_string_to_bool(cmd_arg_v ? g_strstrip(cmd_arg_v) : "", &bb, &tmp_err)) { g_print(_("Error: save-confirmation: %s\n"), tmp_err->message); @@ -8437,7 +8440,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty } else nmc->editor_save_confirmation = bb; } else if (cmd_arg_p && matches(cmd_arg_p, "show-secrets")) { - GError * tmp_err = NULL; + GError *tmp_err = NULL; gboolean bb; if (!nmc_string_to_bool(cmd_arg_v ? g_strstrip(cmd_arg_v) : "", &bb, &tmp_err)) { g_print(_("Error: show-secrets: %s\n"), tmp_err->message); @@ -8508,9 +8511,9 @@ get_ethernet_device_name(NmCli *nmc) static void editor_init_new_connection(NmCli *nmc, NMConnection *connection, const char *slave_type) { - NMSetting * setting, *base_setting; + NMSetting *setting, *base_setting; NMSettingConnection *s_con; - const char * con_type; + const char *con_type; s_con = nm_connection_get_setting_connection(connection); g_assert(s_con); @@ -8579,9 +8582,9 @@ editor_init_new_connection(NmCli *nmc, NMConnection *connection, const char *sla static void editor_init_existing_connection(NMConnection *connection) { - NMSettingIPConfig * s_ip4, *s_ip6; - NMSettingProxy * s_proxy; - NMSettingWireless * s_wireless; + NMSettingIPConfig *s_ip4, *s_ip6; + NMSettingProxy *s_proxy; + NMSettingWireless *s_wireless; NMSettingConnection *s_con; /* FIXME: this approach of connecting handlers to do something is fundamentally @@ -8623,21 +8626,21 @@ nmc_complete_connection_type(const char *prefix) static void do_connection_edit(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - const GPtrArray *connections; + const GPtrArray *connections; gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - const char * connection_type; - const char * type = NULL; - const char * con_name = NULL; - const char * con = NULL; - const char * con_id = NULL; - const char * con_uuid = NULL; - const char * con_path = NULL; - const char * con_filename = NULL; - const char * selector = NULL; - gs_free_error GError *error = NULL; - GError * err1 = NULL; - nmc_arg_t exp_args[] = {{"type", TRUE, &type, FALSE}, + NMSettingConnection *s_con; + const char *connection_type; + const char *type = NULL; + const char *con_name = NULL; + const char *con = NULL; + const char *con_id = NULL; + const char *con_uuid = NULL; + const char *con_path = NULL; + const char *con_filename = NULL; + const char *selector = NULL; + gs_free_error GError *error = NULL; + GError *err1 = NULL; + nmc_arg_t exp_args[] = {{"type", TRUE, &type, FALSE}, {"con-name", TRUE, &con_name, FALSE}, {"id", TRUE, &con_id, FALSE}, {"uuid", TRUE, &con_uuid, FALSE}, @@ -8731,7 +8734,7 @@ do_connection_edit(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons editor_init_existing_connection(connection); } else { - const char * slave_type = NULL; + const char *slave_type = NULL; gs_free char *uuid = NULL; gs_free char *default_name = NULL; gs_free char *tmp_str = NULL; @@ -8825,7 +8828,7 @@ do_connection_edit(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons static void modify_connection_cb(GObject *connection, GAsyncResult *result, gpointer user_data) { - NmCli * nmc = user_data; + NmCli *nmc = user_data; gs_free_error GError *error = NULL; if (!nm_remote_connection_commit_changes_finish(NM_REMOTE_CONNECTION(connection), @@ -8849,10 +8852,10 @@ modify_connection_cb(GObject *connection, GAsyncResult *result, gpointer user_da static void do_connection_modify(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMConnection * connection = NULL; - NMRemoteConnection *rc = NULL; - gs_free_error GError *error = NULL; - gboolean temporary = FALSE; + NMConnection *connection = NULL; + NMRemoteConnection *rc = NULL; + gs_free_error GError *error = NULL; + gboolean temporary = FALSE; if (next_arg(nmc, &argc, &argv, "--temporary", NULL) > 0) { temporary = TRUE; @@ -8891,10 +8894,10 @@ do_connection_modify(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co static void clone_connection_cb(GObject *client, GAsyncResult *result, gpointer user_data) { - nm_auto_free_add_connection_info AddConnectionInfo *info = user_data; - NmCli * nmc = info->nmc; - gs_unref_object NMRemoteConnection *connection = NULL; - gs_free_error GError *error = NULL; + nm_auto_free_add_connection_info AddConnectionInfo *info = user_data; + NmCli *nmc = info->nmc; + gs_unref_object NMRemoteConnection *connection = NULL; + gs_free_error GError *error = NULL; connection = nm_client_add_connection2_finish(NM_CLIENT(client), result, NULL, &error); if (error) { @@ -8917,17 +8920,17 @@ clone_connection_cb(GObject *client, GAsyncResult *result, gpointer user_data) static void do_connection_clone(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMConnection * connection = NULL; + NMConnection *connection = NULL; gs_unref_object NMConnection *new_connection = NULL; - const char * new_name; - gs_free char * new_name_free = NULL; - gs_free char * uuid = NULL; + const char *new_name; + gs_free char *new_name_free = NULL; + gs_free char *uuid = NULL; gboolean temporary = FALSE; - gs_strfreev char ** arg_arr = NULL; + gs_strfreev char **arg_arr = NULL; int arg_num; - const char *const ** argv_ptr; - int * argc_ptr; - GError * error = NULL; + const char *const **argv_ptr; + int *argc_ptr; + GError *error = NULL; if (next_arg(nmc, &argc, &argv, "--temporary", NULL) > 0) { temporary = TRUE; @@ -8999,7 +9002,7 @@ static void delete_cb(GObject *con, GAsyncResult *result, gpointer user_data) { ConnectionCbInfo *info = (ConnectionCbInfo *) user_data; - GError * error = NULL; + GError *error = NULL; if (!nm_remote_connection_delete_finish(NM_REMOTE_CONNECTION(con), result, &error)) { if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -9018,15 +9021,15 @@ delete_cb(GObject *con, GAsyncResult *result, gpointer user_data) static void do_connection_delete(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMConnection * connection; - ConnectionCbInfo * info = NULL; - gs_strfreev char ** arg_arr = NULL; - const char *const * arg_ptr; - guint i; - int arg_num; + NMConnection *connection; + ConnectionCbInfo *info = NULL; + gs_strfreev char **arg_arr = NULL; + const char *const *arg_ptr; + guint i; + int arg_num; nm_auto_free_gstring GString *invalid_cons = NULL; - gs_unref_ptrarray GPtrArray *found_cons = NULL; - GError * error = NULL; + gs_unref_ptrarray GPtrArray *found_cons = NULL; + GError *error = NULL; if (nmc->timeout == -1) nmc->timeout = 10; @@ -9168,10 +9171,10 @@ connection_removed(NMClient *client, NMRemoteConnection *con, NmCli *nmc) static void do_connection_monitor(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - GError * error = NULL; - guint i; + GError *error = NULL; + guint i; gs_unref_ptrarray GPtrArray *found_cons = NULL; - const GPtrArray * connections = NULL; + const GPtrArray *connections = NULL; next_arg(nmc, &argc, &argv, NULL); if (argc == 0) { @@ -9222,9 +9225,9 @@ do_connection_monitor(const NMCCommand *cmd, NmCli *nmc, int argc, const char *c static void connection_reload_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NmCli * nmc = user_data; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; + NmCli *nmc = user_data; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; ret = nm_dbus_call_finish(result, &error); if (error) { @@ -9261,10 +9264,10 @@ do_connection_reload(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co static void do_connection_load(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - GError * error = NULL; + GError *error = NULL; gs_strfreev char **filenames = NULL; gs_strfreev char **failures = NULL; - gs_free char * current_dir = NULL; + gs_free char *current_dir = NULL; int i; next_arg(nmc, &argc, &argv, NULL); @@ -9318,13 +9321,13 @@ do_connection_load(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons static void do_connection_import(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - gs_free_error GError *error = NULL; - const char * type = NULL, *filename = NULL; - gs_free char * type_ask = NULL; - gs_free char * filename_ask = NULL; - gs_unref_object NMConnection *connection = NULL; - NMVpnEditorPlugin * plugin; - gs_free char * service_type = NULL; + gs_free_error GError *error = NULL; + const char *type = NULL, *filename = NULL; + gs_free char *type_ask = NULL; + gs_free char *filename_ask = NULL; + gs_unref_object NMConnection *connection = NULL; + NMVpnEditorPlugin *plugin; + gs_free char *service_type = NULL; gboolean temporary = FALSE; /* Check --temporary */ @@ -9457,18 +9460,18 @@ do_connection_import(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co static void do_connection_export(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMConnection * connection = NULL; - const char * out_name = NULL; - gs_free char * out_name_ask = NULL; - const char * path = NULL; - const char * type = NULL; - NMVpnEditorPlugin *plugin; + NMConnection *connection = NULL; + const char *out_name = NULL; + gs_free char *out_name_ask = NULL; + const char *path = NULL; + const char *type = NULL; + NMVpnEditorPlugin *plugin; gs_free_error GError *error = NULL; char tmpfile[] = "/tmp/nmcli-export-temp-XXXXXX"; - gs_strfreev char ** arg_arr = NULL; + gs_strfreev char **arg_arr = NULL; int arg_num; - const char *const ** argv_ptr; - int * argc_ptr; + const char *const **argv_ptr; + int *argc_ptr; next_arg(nmc, &argc, &argv, NULL); argv_ptr = &argv; @@ -9577,8 +9580,8 @@ gen_func_connection_names(const char *text, int state) { guint i; const GPtrArray *connections; - const char ** connection_names; - char * ret; + const char **connection_names; + char *ret; connections = nm_client_get_connections(nm_cli_global_readline->client); if (connections->len == 0) @@ -9600,8 +9603,8 @@ gen_func_active_connection_names(const char *text, int state) { guint i; const GPtrArray *acs; - const char ** connections; - char * ret; + const char **connections; + char *ret; if (!nm_cli_global_readline->client) return NULL; @@ -9624,8 +9627,8 @@ gen_func_active_connection_names(const char *text, int state) static char ** nmcli_con_tab_completion(const char *text, int start, int end) { - char ** match_array = NULL; - rl_compentry_func_t * generator_func = NULL; + char **match_array = NULL; + rl_compentry_func_t *generator_func = NULL; const NMMetaAbstractInfo *info; /* Disable readline's default filename completion */ diff --git a/src/nmcli/connections.h b/src/nmcli/connections.h index 74c1fe0039..782c4eafca 100644 --- a/src/nmcli/connections.h +++ b/src/nmcli/connections.h @@ -10,12 +10,12 @@ void monitor_connections(NmCli *nmc); -gboolean nmc_process_connection_properties(NmCli * nmc, - NMConnection * connection, - int * argc, +gboolean nmc_process_connection_properties(NmCli *nmc, + NMConnection *connection, + int *argc, const char *const **argv, gboolean allow_remove_setting, - GError ** error); + GError **error); NMMetaColor nmc_active_connection_state_to_color(NMActiveConnection *ac); diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index d2e472a083..e23ef681bf 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -93,9 +93,10 @@ wifi_signal_to_color(guint8 strength) /*****************************************************************************/ -static gconstpointer _metagen_device_status_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_device_status_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMDevice * d = target; + NMDevice *d = target; NMActiveConnection *ac; NMC_HANDLE_COLOR(nmc_device_state_to_color(d)); @@ -152,13 +153,14 @@ const NmcMetaGenericInfo /*****************************************************************************/ -static gconstpointer _metagen_device_detail_general_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_device_detail_general_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMDevice * d = target; + NMDevice *d = target; NMActiveConnection *ac; NMDeviceStateReason state_reason; NMConnectivityState connectivity; - const char * s; + const char *s; NMC_HANDLE_COLOR(NM_META_COLOR_NONE); @@ -317,7 +319,7 @@ static NMRemoteConnection ** _device_get_available_connections(NMDevice *d, guint *out_len) { NMRemoteConnection **avail_cons; - const GPtrArray * avail_cons_arr; + const GPtrArray *avail_cons_arr; avail_cons_arr = nm_device_get_available_connections(d); if (!avail_cons_arr || avail_cons_arr->len == 0) { @@ -333,15 +335,16 @@ _device_get_available_connections(NMDevice *d, guint *out_len) return avail_cons; } -static gconstpointer _metagen_device_detail_connections_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_device_detail_connections_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMDevice *d = target; + NMDevice *d = target; gs_free NMRemoteConnection **avail_cons = NULL; guint avail_cons_len; guint i; guint j; - char ** arr = NULL; - GString * str; + char **arr = NULL; + GString *str; gboolean had_prefix; gboolean has_prefix; @@ -360,8 +363,8 @@ static gconstpointer _metagen_device_detail_connections_get_fcn(NMC_META_GENERIC j = 0; for (i = 0; i < avail_cons_len; i++) { NMRemoteConnection *ac = avail_cons[i]; - const char * ac_id = nm_connection_get_id(NM_CONNECTION(ac)); - const char * ac_uuid = nm_connection_get_uuid(NM_CONNECTION(ac)); + const char *ac_id = nm_connection_get_id(NM_CONNECTION(ac)); + const char *ac_uuid = nm_connection_get_uuid(NM_CONNECTION(ac)); if (!ac_id || !ac_uuid) { const char *ac_path = nm_connection_get_path(NM_CONNECTION(ac)); @@ -390,7 +393,7 @@ static gconstpointer _metagen_device_detail_connections_get_fcn(NMC_META_GENERIC had_prefix = FALSE; for (i = 0; i < avail_cons_len; i++) { NMRemoteConnection *ac = avail_cons[i]; - const char * p = nm_connection_get_path(NM_CONNECTION(ac)); + const char *p = nm_connection_get_path(NM_CONNECTION(ac)); if (!p) continue; @@ -447,9 +450,10 @@ const NmcMetaGenericInfo *const /*****************************************************************************/ -static gconstpointer _metagen_device_detail_capabilities_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_device_detail_capabilities_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMDevice * d = target; + NMDevice *d = target; NMDeviceCapabilities caps; guint32 speed; @@ -511,7 +515,7 @@ const NmcMetaGenericInfo /*****************************************************************************/ static gconstpointer - _metagen_device_detail_wired_properties_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +_metagen_device_detail_wired_properties_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { NMDevice *d = target; @@ -552,9 +556,9 @@ const NmcMetaGenericInfo *const /*****************************************************************************/ static gconstpointer - _metagen_device_detail_wifi_properties_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +_metagen_device_detail_wifi_properties_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMDevice * d = target; + NMDevice *d = target; NMDeviceWifiCapabilities wcaps; NMC_HANDLE_COLOR(NM_META_COLOR_NONE); @@ -649,9 +653,9 @@ const NmcMetaGenericInfo *const /*****************************************************************************/ static gconstpointer - _metagen_device_detail_interface_flags_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +_metagen_device_detail_interface_flags_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NMDevice * d = target; + NMDevice *d = target; NMDeviceInterfaceFlags flags; NMC_HANDLE_COLOR(NM_META_COLOR_NONE); @@ -1049,8 +1053,8 @@ quit(void) static int compare_devices(const void *a, const void *b) { - NMDevice * da = *(NMDevice **) a; - NMDevice * db = *(NMDevice **) b; + NMDevice *da = *(NMDevice **) a; + NMDevice *db = *(NMDevice **) b; NMActiveConnection *da_ac = nm_device_get_active_connection(da); NMActiveConnection *db_ac = nm_device_get_active_connection(db); @@ -1067,7 +1071,7 @@ NMDevice ** nmc_get_devices_sorted(NMClient *client) { const GPtrArray *devs; - NMDevice ** sorted; + NMDevice **sorted; devs = nm_client_get_devices(client); @@ -1111,9 +1115,9 @@ get_device_list(NmCli *nmc, int argc, const char *const *argv) int arg_num = argc; gs_strfreev char **arg_arr = NULL; const char *const *arg_ptr = argv; - NMDevice ** devices; - GSList * queue = NULL; - NMDevice * device; + NMDevice **devices; + GSList *queue = NULL; + NMDevice *device; int i; if (argc == 0) { @@ -1171,8 +1175,8 @@ static NMDevice * get_device(NmCli *nmc, int *argc, const char *const **argv, GError **error) { gs_free NMDevice **devices = NULL; - gs_free char * ifname_ask = NULL; - const char * ifname = NULL; + gs_free char *ifname_ask = NULL; + const char *ifname = NULL; int i; if (*argc == 0) { @@ -1245,39 +1249,39 @@ sort_access_points(const GPtrArray *aps) } typedef struct { - NmCli * nmc; + NmCli *nmc; int index; guint32 output_flags; const char *active_bssid; const char *device; - GPtrArray * output_data; + GPtrArray *output_data; } APInfo; static void fill_output_access_point(gpointer data, gpointer user_data) { - NMAccessPoint * ap = NM_ACCESS_POINT(data); - APInfo * info = (APInfo *) user_data; - NmcOutputField * arr; + NMAccessPoint *ap = NM_ACCESS_POINT(data); + APInfo *info = (APInfo *) user_data; + NmcOutputField *arr; gboolean active = FALSE; NM80211ApFlags flags; NM80211ApSecurityFlags wpa_flags, rsn_flags; guint32 freq, bitrate; guint8 strength; - GBytes * ssid; - const char * bssid; + GBytes *ssid; + const char *bssid; NM80211Mode mode; - char * channel_str; - char * freq_str; - char * ssid_str = NULL; - char * ssid_hex_str = NULL; - char * bitrate_str; - char * strength_str; - char * wpa_flags_str; - char * rsn_flags_str; - GString * security_str; - char * ap_name; - const char * sig_bars; + char *channel_str; + char *freq_str; + char *ssid_str = NULL; + char *ssid_hex_str = NULL; + char *bitrate_str; + char *strength_str; + char *wpa_flags_str; + char *rsn_flags_str; + GString *security_str; + char *ap_name; + const char *sig_bars; NMMetaColor color; if (info->active_bssid) { @@ -1413,16 +1417,16 @@ construct_header_name(const char *base, const char *spec) } static gboolean -print_bond_bridge_info(NMDevice * device, - NmCli * nmc, +print_bond_bridge_info(NMDevice *device, + NmCli *nmc, const char *group_prefix, const char *one_field) { - const GPtrArray * slaves = NULL; - GString * slaves_str; + const GPtrArray *slaves = NULL; + GString *slaves_str; int idx; const NMMetaAbstractInfo *const *tmpl; - NmcOutputField * arr; + NmcOutputField *arr; NMC_OUTPUT_DATA_DEFINE_SCOPED(out); if (NM_IS_DEVICE_BOND(device)) @@ -1434,7 +1438,7 @@ print_bond_bridge_info(NMDevice * device, slaves_str = g_string_new(NULL); for (idx = 0; slaves && idx < slaves->len; idx++) { - NMDevice * slave = g_ptr_array_index(slaves, idx); + NMDevice *slave = g_ptr_array_index(slaves, idx); const char *iface = nm_device_get_iface(slave); if (iface) { @@ -1483,11 +1487,11 @@ sanitize_team_config(const char *config) static gboolean print_team_info(NMDevice *device, NmCli *nmc, const char *group_prefix, const char *one_field) { - const GPtrArray * slaves = NULL; - GString * slaves_str; + const GPtrArray *slaves = NULL; + GString *slaves_str; int idx; const NMMetaAbstractInfo *const *tmpl; - NmcOutputField * arr; + NmcOutputField *arr; NMC_OUTPUT_DATA_DEFINE_SCOPED(out); if (NM_IS_DEVICE_TEAM(device)) @@ -1497,7 +1501,7 @@ print_team_info(NMDevice *device, NmCli *nmc, const char *group_prefix, const ch slaves_str = g_string_new(NULL); for (idx = 0; slaves && idx < slaves->len; idx++) { - NMDevice * slave = g_ptr_array_index(slaves, idx); + NMDevice *slave = g_ptr_array_index(slaves, idx); const char *iface = nm_device_get_iface(slave); if (iface) { @@ -1528,18 +1532,18 @@ print_team_info(NMDevice *device, NmCli *nmc, const char *group_prefix, const ch static gboolean show_device_info(NMDevice *device, NmCli *nmc) { - GError * error = NULL; + GError *error = NULL; NMDeviceState state = NM_DEVICE_STATE_UNKNOWN; - GArray * sections_array; + GArray *sections_array; int k; - const char * fields_str = NULL; + const char *fields_str = NULL; const NMMetaAbstractInfo *const *tmpl; - NmcOutputField * arr; + NmcOutputField *arr; gboolean was_output = FALSE; - NMIPConfig * cfg4, *cfg6; - NMDhcpConfig * dhcp4, *dhcp6; - const char * base_hdr = _("Device details"); - GPtrArray * fields_in_section = NULL; + NMIPConfig *cfg4, *cfg6; + NMDhcpConfig *dhcp4, *dhcp6; + const char *base_hdr = _("Device details"); + GPtrArray *fields_in_section = NULL; if (!nmc->required_fields || g_ascii_strcasecmp(nmc->required_fields, "common") == 0) fields_str = NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON; @@ -1562,9 +1566,9 @@ show_device_info(NMDevice *device, NmCli *nmc) } { - gs_unref_array GArray *out_indices = NULL; - gs_free char * header_name = NULL; - gs_free NmcOutputField *row = NULL; + gs_unref_array GArray *out_indices = NULL; + gs_free char *header_name = NULL; + gs_free NmcOutputField *row = NULL; int i; /* Main header (pretty only) */ @@ -1676,7 +1680,7 @@ show_device_info(NMDevice *device, NmCli *nmc) /* Wireless specific information */ if ((NM_IS_DEVICE_WIFI(device))) { NMAccessPoint *active_ap = NULL; - const char * active_bssid = NULL; + const char *active_bssid = NULL; /* section AP */ if (!g_ascii_strcasecmp(nmc_fields_dev_show_sections[section_idx]->name, @@ -1701,12 +1705,12 @@ show_device_info(NMDevice *device, NmCli *nmc) { gs_unref_ptrarray GPtrArray *aps = NULL; APInfo info = { - .nmc = nmc, - .index = 1, - .output_flags = NMC_OF_FLAG_SECTION_PREFIX, - .active_bssid = active_bssid, - .device = nm_device_get_iface(device), - .output_data = out.output_data, + .nmc = nmc, + .index = 1, + .output_flags = NMC_OF_FLAG_SECTION_PREFIX, + .active_bssid = active_bssid, + .device = nm_device_get_iface(device), + .output_data = out.output_data, }; aps = sort_access_points( @@ -1908,9 +1912,9 @@ nmc_device_state_to_color(NMDevice *device) static void do_devices_status(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - GError *error = NULL; + GError *error = NULL; gs_free NMDevice **devices = NULL; - const char * fields_str = NULL; + const char *fields_str = NULL; next_arg(nmc, &argc, &argv, NULL); @@ -2020,17 +2024,17 @@ progress_cb(gpointer user_data) } typedef struct { - NmCli * nmc; - NMDevice * device; + NmCli *nmc; + NMDevice *device; NMActiveConnection *active; - char * specific_object; + char *specific_object; bool hotspot : 1; bool create : 1; } AddAndActivateInfo; static AddAndActivateInfo * -add_and_activate_info_new(NmCli * nmc, - NMDevice * device, +add_and_activate_info_new(NmCli *nmc, + NMDevice *device, gboolean hotspot, gboolean create, const char *specific_object) @@ -2103,10 +2107,10 @@ connected_state_cb(AddAndActivateInfo *info) static void add_and_activate_cb(GObject *client, GAsyncResult *result, gpointer user_data) { - nm_auto_free_add_and_activate_info AddAndActivateInfo *info = user_data; - NmCli * nmc = info->nmc; - gs_unref_object NMActiveConnection *active = NULL; - gs_free_error GError *error = NULL; + nm_auto_free_add_and_activate_info AddAndActivateInfo *info = user_data; + NmCli *nmc = info->nmc; + gs_unref_object NMActiveConnection *active = NULL; + gs_free_error GError *error = NULL; if (info->create) active = nm_client_add_and_activate_connection_finish(NM_CLIENT(client), result, &error); @@ -2151,7 +2155,7 @@ add_and_activate_cb(GObject *client, GAsyncResult *result, gpointer user_data) static void create_connect_connection_for_device(AddAndActivateInfo *info) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; /* Create new connection and tie it to the device */ @@ -2172,10 +2176,10 @@ create_connect_connection_for_device(AddAndActivateInfo *info) static void connect_device_cb(GObject *client, GAsyncResult *result, gpointer user_data) { - nm_auto_free_add_and_activate_info AddAndActivateInfo *info = user_data; - NmCli * nmc = info->nmc; - gs_unref_object NMActiveConnection *active = NULL; - GError * error = NULL; + nm_auto_free_add_and_activate_info AddAndActivateInfo *info = user_data; + NmCli *nmc = info->nmc; + gs_unref_object NMActiveConnection *active = NULL; + GError *error = NULL; active = nm_client_activate_connection_finish(NM_CLIENT(client), result, &error); @@ -2220,8 +2224,8 @@ connect_device_cb(GObject *client, GAsyncResult *result, gpointer user_data) static void do_device_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice * device = NULL; - AddAndActivateInfo *info; + NMDevice *device = NULL; + AddAndActivateInfo *info; gs_free_error GError *error = NULL; /* Set default timeout for connect operation. */ @@ -2277,8 +2281,8 @@ do_device_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const } typedef struct { - NmCli * nmc; - GSList * queue; + NmCli *nmc; + GSList *queue; guint timeout_id; gboolean cmd_disconnect; GCancellable *cancellable; @@ -2367,10 +2371,10 @@ device_cb_info_finish(DeviceCbInfo *info, NMDevice *device) static void reapply_device_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NMDevice * device = NM_DEVICE(object); + NMDevice *device = NM_DEVICE(object); DeviceCbInfo *info = (DeviceCbInfo *) user_data; - NmCli * nmc = info->nmc; - GError * error = NULL; + NmCli *nmc = info->nmc; + GError *error = NULL; if (!nm_device_reapply_finish(device, result, &error)) { g_string_printf(nmc->return_text, @@ -2393,8 +2397,8 @@ reapply_device_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void do_device_reapply(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice * device; - DeviceCbInfo *info = NULL; + NMDevice *device; + DeviceCbInfo *info = NULL; gs_free_error GError *error = NULL; /* Set default timeout for reapply operation. */ @@ -2447,10 +2451,10 @@ NM_AUTO_DEFINE_FCN_VOID0(ModifyInfo *, _auto_free_modify_info, modify_info_free) static void modify_reapply_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NMDevice * device = NM_DEVICE(object); + NMDevice *device = NM_DEVICE(object); nm_auto(_auto_free_modify_info) ModifyInfo *info = user_data; - NmCli * nmc = info->nmc; - GError * error = NULL; + NmCli *nmc = info->nmc; + GError *error = NULL; if (!nm_device_reapply_finish(device, result, &error)) { g_string_printf(nmc->return_text, @@ -2473,14 +2477,14 @@ modify_reapply_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void modify_get_applied_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NMDevice * device = NM_DEVICE(object); + NMDevice *device = NM_DEVICE(object); nm_auto(_auto_free_modify_info) ModifyInfo *info = user_data; - NmCli * nmc = info->nmc; - gs_free_error GError *error = NULL; - NMConnection * connection; - guint64 version_id; - int argc; - const char *const * argv; + NmCli *nmc = info->nmc; + gs_free_error GError *error = NULL; + NMConnection *connection; + guint64 version_id; + int argc; + const char *const *argv; connection = nm_device_get_applied_connection_finish(device, result, &version_id, &error); if (!connection) { @@ -2521,8 +2525,8 @@ modify_get_applied_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void do_device_modify(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice * device = NULL; - ModifyInfo * info; + NMDevice *device = NULL; + ModifyInfo *info; gs_free_error GError *error = NULL; next_arg(nmc, &argc, &argv, NULL); @@ -2552,11 +2556,11 @@ do_device_modify(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const static void disconnect_device_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NMDevice * device = NM_DEVICE(object); + NMDevice *device = NM_DEVICE(object); DeviceCbInfo *info = (DeviceCbInfo *) user_data; - NmCli * nmc; + NmCli *nmc; NMDeviceState state; - GError * error = NULL; + GError *error = NULL; if (!nm_device_disconnect_finish(device, result, &error)) { if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -2588,9 +2592,9 @@ disconnect_device_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void do_devices_disconnect(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice * device; + NMDevice *device; DeviceCbInfo *info = NULL; - GSList * queue, *iter; + GSList *queue, *iter; /* Set default timeout for disconnect operation. */ if (nmc->timeout == -1) @@ -2633,10 +2637,10 @@ out: static void delete_device_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NMDevice * device = NM_DEVICE(object); + NMDevice *device = NM_DEVICE(object); DeviceCbInfo *info = (DeviceCbInfo *) user_data; - NmCli * nmc = info->nmc; - GError * error = NULL; + NmCli *nmc = info->nmc; + GError *error = NULL; if (!nm_device_delete_finish(device, result, &error)) { g_string_printf(nmc->return_text, _("Error: not all devices deleted.")); @@ -2656,9 +2660,9 @@ delete_device_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void do_devices_delete(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice * device; + NMDevice *device; DeviceCbInfo *info = NULL; - GSList * queue, *iter; + GSList *queue, *iter; /* Set default timeout for delete operation. */ if (nmc->timeout == -1) @@ -2814,7 +2818,7 @@ static void device_ac(NMDevice *device, GParamSpec *pspec, NmCli *nmc) { NMActiveConnection *ac = nm_device_get_active_connection(device); - const char * id = ac ? nm_active_connection_get_id(ac) : NULL; + const char *id = ac ? nm_active_connection_get_id(ac) : NULL; if (!id) return; @@ -2928,7 +2932,7 @@ static NMAccessPoint * find_ap_on_device(NMDevice *device, const char *bssid, const char *ssid, gboolean complete) { const GPtrArray *aps; - NMAccessPoint * ap = NULL; + NMAccessPoint *ap = NULL; int i; g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), NULL); @@ -2954,7 +2958,7 @@ find_ap_on_device(NMDevice *device, const char *bssid, const char *ssid, gboolea if (ssid) { /* Parameter is SSID */ GBytes *candidate_ssid; - char * ssid_tmp; + char *ssid_tmp; candidate_ssid = nm_access_point_get_ssid(candidate_ap); if (!candidate_ssid) @@ -2987,8 +2991,8 @@ find_ap_on_device(NMDevice *device, const char *bssid, const char *ssid, gboolea static void show_access_point_info(NMDeviceWifi *wifi, NmCli *nmc, NmcOutputData *out) { - NMAccessPoint * active_ap = NULL; - const char * active_bssid = NULL; + NMAccessPoint *active_ap = NULL; + const char *active_bssid = NULL; NmcOutputField *arr; if (nm_device_get_state(NM_DEVICE(wifi)) == NM_DEVICE_STATE_ACTIVATED) { @@ -3003,12 +3007,12 @@ show_access_point_info(NMDeviceWifi *wifi, NmCli *nmc, NmcOutputData *out) { gs_unref_ptrarray GPtrArray *aps = NULL; APInfo info = { - .nmc = nmc, - .index = 1, - .output_flags = 0, - .active_bssid = active_bssid, - .device = nm_device_get_iface(NM_DEVICE(wifi)), - .output_data = out->output_data, + .nmc = nmc, + .index = 1, + .output_flags = 0, + .active_bssid = active_bssid, + .device = nm_device_get_iface(NM_DEVICE(wifi)), + .output_data = out->output_data, }; aps = sort_access_points(nm_device_wifi_get_access_points(wifi)); @@ -3019,21 +3023,21 @@ show_access_point_info(NMDeviceWifi *wifi, NmCli *nmc, NmcOutputData *out) } static void -wifi_print_aps(NMDeviceWifi * wifi, - NmCli * nmc, - GArray * _out_indices, +wifi_print_aps(NMDeviceWifi *wifi, + NmCli *nmc, + GArray *_out_indices, const NMMetaAbstractInfo *const *tmpl, - const char * bssid_user, - gboolean * bssid_found) + const char *bssid_user, + gboolean *bssid_found) { - NMAccessPoint * ap = NULL; + NMAccessPoint *ap = NULL; const GPtrArray *aps; - APInfo * info; + APInfo *info; guint i; - NmcOutputField * arr; - const char * base_hdr = _("Wi-Fi scan list"); + NmcOutputField *arr; + const char *base_hdr = _("Wi-Fi scan list"); NMC_OUTPUT_DATA_DEFINE_SCOPED(out); - gs_free char * header_name = NULL; + gs_free char *header_name = NULL; static gboolean empty_line = FALSE; if (empty_line) @@ -3097,17 +3101,17 @@ _device_wifi_get_last_scan(NMDeviceWifi *wifi) } typedef struct { - NmCli * nmc; - NMDevice ** devices; + NmCli *nmc; + NMDevice **devices; const NMMetaAbstractInfo *const *tmpl; - char * bssid_user; - GArray * out_indices; + char *bssid_user; + GArray *out_indices; gint64 rescan_cutoff_msec; guint pending; } ScanInfo; typedef struct { - ScanInfo * scan_info; + ScanInfo *scan_info; NMDeviceWifi *wifi; gulong last_scan_id; guint timeout_id; @@ -3118,7 +3122,7 @@ static void wifi_list_finish(WifiListData *wifi_list_data, gboolean force_finished) { ScanInfo *scan_info = wifi_list_data->scan_info; - NmCli * nmc = scan_info->nmc; + NmCli *nmc = scan_info->nmc; gboolean bssid_found = FALSE; guint i; @@ -3189,9 +3193,9 @@ wifi_list_rescan_retry_cb(gpointer user_data, GCancellable *cancellable) static void wifi_list_rescan_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMDeviceWifi *wifi = NM_DEVICE_WIFI(source_object); + NMDeviceWifi *wifi = NM_DEVICE_WIFI(source_object); gs_free_error GError *error = NULL; - WifiListData * wifi_list_data; + WifiListData *wifi_list_data; gboolean force_finished; gboolean done; @@ -3248,7 +3252,7 @@ wifi_list_scan_timeout(gpointer user_data) } static void -complete_aps(NMDevice ** devices, +complete_aps(NMDevice **devices, const char *ifname, const char *bssid_prefix, const char *ssid_prefix) @@ -3272,21 +3276,21 @@ nmc_complete_bssid(NMClient *client, const char *ifname, const char *bssid_prefi static void do_device_wifi_list(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - GError * error = NULL; - NMDevice * device = NULL; - const char *ifname = NULL; - const char *bssid_user = NULL; - const char *rescan = NULL; - gs_free NMDevice ** devices = NULL; - const char * fields_str = NULL; + GError *error = NULL; + NMDevice *device = NULL; + const char *ifname = NULL; + const char *bssid_user = NULL; + const char *rescan = NULL; + gs_free NMDevice **devices = NULL; + const char *fields_str = NULL; const NMMetaAbstractInfo *const *tmpl; - gs_unref_array GArray *out_indices = NULL; - int option; - gint64 rescan_cutoff_msec; - ScanInfo * scan_info = NULL; - gboolean ifname_handled; - NMDevice * ifname_handled_candidate; - guint i, j; + gs_unref_array GArray *out_indices = NULL; + int option; + gint64 rescan_cutoff_msec; + ScanInfo *scan_info = NULL; + gboolean ifname_handled; + NMDevice *ifname_handled_candidate; + guint i, j; devices = nmc_get_devices_sorted(nmc->client); @@ -3488,11 +3492,11 @@ do_device_wifi_list(const NMCCommand *cmd, NmCli *nmc, int argc, const char *con static void activate_update2_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { - NMRemoteConnection *remote_con = NM_REMOTE_CONNECTION(source_object); - AddAndActivateInfo *info = user_data; - NmCli * nmc = info->nmc; - gs_unref_variant GVariant *ret = NULL; - GError * error = NULL; + NMRemoteConnection *remote_con = NM_REMOTE_CONNECTION(source_object); + AddAndActivateInfo *info = user_data; + NmCli *nmc = info->nmc; + gs_unref_variant GVariant *ret = NULL; + GError *error = NULL; ret = nm_remote_connection_update2_finish(remote_con, res, &error); @@ -3515,11 +3519,11 @@ activate_update2_cb(GObject *source_object, GAsyncResult *res, gpointer user_dat } static void -save_and_activate_connection(NmCli * nmc, - NMDevice * device, +save_and_activate_connection(NmCli *nmc, + NMDevice *device, NMConnection *connection, gboolean hotspot, - const char * specific_object) + const char *specific_object) { AddAndActivateInfo *info; @@ -3551,29 +3555,29 @@ save_and_activate_connection(NmCli * nmc, static void do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice * device = NULL; - NMAccessPoint * ap = NULL; - NM80211ApFlags ap_flags; - NM80211ApSecurityFlags ap_wpa_flags; - NM80211ApSecurityFlags ap_rsn_flags; + NMDevice *device = NULL; + NMAccessPoint *ap = NULL; + NM80211ApFlags ap_flags; + NM80211ApSecurityFlags ap_wpa_flags; + NM80211ApSecurityFlags ap_rsn_flags; gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; - const char * param_user = NULL; - const char * ifname = NULL; - const char * bssid = NULL; - const char * password = NULL; - const char * con_name = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + const char *param_user = NULL; + const char *ifname = NULL; + const char *bssid = NULL; + const char *password = NULL; + const char *con_name = NULL; gboolean private = FALSE; - gboolean hidden = FALSE; - gboolean wep_passphrase = FALSE; - GByteArray *bssid1_arr = NULL; - GByteArray *bssid2_arr = NULL; + gboolean hidden = FALSE; + gboolean wep_passphrase = FALSE; + GByteArray *bssid1_arr = NULL; + GByteArray *bssid2_arr = NULL; gs_free NMDevice **devices = NULL; int devices_idx; - char * ssid_ask = NULL; - char * passwd_ask = NULL; - const GPtrArray * avail_cons; + char *ssid_ask = NULL; + char *passwd_ask = NULL; + const GPtrArray *avail_cons; gboolean name_match = FALSE; int i; @@ -3781,8 +3785,8 @@ do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char * /* For hidden SSID first scan it so that NM learns about the AP */ if (hidden) { GVariantBuilder builder, array_builder; - GVariant * options; - GError * scan_err = NULL; + GVariant *options; + GError *scan_err = NULL; g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_init(&array_builder, G_VARIANT_TYPE("aay")); @@ -3840,7 +3844,7 @@ do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char * avail_cons = nm_device_get_available_connections(device); for (i = 0; i < avail_cons->len; i++) { NMConnection *avail_con = g_ptr_array_index(avail_cons, i); - const char * id = nm_connection_get_id(NM_CONNECTION(avail_con)); + const char *id = nm_connection_get_id(NM_CONNECTION(avail_con)); if (con_name) { if (!id || strcmp(id, con_name)) @@ -3929,7 +3933,7 @@ do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char * || (ap_rsn_flags != NM_802_11_AP_SEC_NONE && !NM_FLAGS_ANY(ap_rsn_flags, NM_802_11_AP_SEC_KEY_MGMT_OWE | NM_802_11_AP_SEC_KEY_MGMT_OWE_TM))) { - const char * con_password = NULL; + const char *con_password = NULL; NMSettingWirelessSecurity *s_wsec = NULL; if (connection) { @@ -4006,7 +4010,7 @@ static GBytes * generate_ssid_for_hotspot(void) { GBytes *ssid_bytes; - char * ssid = NULL; + char *ssid = NULL; ssid = g_strdup_printf("Hotspot-%s", g_get_host_name()); if (strlen(ssid) > 32) @@ -4059,11 +4063,11 @@ generate_wep_key(char *key, size_t len) static gboolean set_wireless_security_for_hotspot(NMSettingWirelessSecurity *s_wsec, - const char * wifi_mode, + const char *wifi_mode, NMDeviceWifiCapabilities caps, - const char * password, + const char *password, gboolean show_password, - GError ** error) + GError **error) { char generated_key[11]; const char *key; @@ -4135,15 +4139,15 @@ set_wireless_security_for_hotspot(NMSettingWirelessSecurity *s_wsec, } static NMConnection * -find_hotspot_conn(NMDevice * device, +find_hotspot_conn(NMDevice *device, const GPtrArray *connections, - const char * con_name, - GBytes * ssid_bytes, - const char * wifi_mode, - const char * band, + const char *con_name, + GBytes *ssid_bytes, + const char *wifi_mode, + const char *band, gint64 channel_int) { - NMConnection * connection; + NMConnection *connection; NMSettingWireless *s_wifi; int i; @@ -4177,19 +4181,19 @@ find_hotspot_conn(NMDevice * device, static NMConnection * create_hotspot_conn(const GPtrArray *connections, - const char * con_name, - GBytes * ssid_bytes, - const char * wifi_mode, - const char * band, + const char *con_name, + GBytes *ssid_bytes, + const char *wifi_mode, + const char *band, gint64 channel_int) { - char * default_name = NULL; - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; + char *default_name = NULL; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig * s_ip4, *s_ip6; - NMSettingProxy * s_proxy; + NMSettingIPConfig *s_ip4, *s_ip6; + NMSettingProxy *s_proxy; connection = nm_simple_connection_new(); s_con = (NMSettingConnection *) nm_setting_connection_new(); @@ -4244,22 +4248,22 @@ create_hotspot_conn(const GPtrArray *connections, static void do_device_wifi_hotspot(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - const char * ifname = NULL; - const char * con_name = NULL; - gs_unref_bytes GBytes *ssid_bytes = NULL; - const char * wifi_mode; - const char * band = NULL; - const char * channel = NULL; - gint64 channel_int = -1; - const char * password = NULL; - gboolean show_password = FALSE; - NMDevice * device = NULL; - gs_free NMDevice ** devices = NULL; - NMDeviceWifiCapabilities caps; + const char *ifname = NULL; + const char *con_name = NULL; + gs_unref_bytes GBytes *ssid_bytes = NULL; + const char *wifi_mode; + const char *band = NULL; + const char *channel = NULL; + gint64 channel_int = -1; + const char *password = NULL; + gboolean show_password = FALSE; + NMDevice *device = NULL; + gs_free NMDevice **devices = NULL; + NMDeviceWifiCapabilities caps; gs_unref_object NMConnection *connection = NULL; - const GPtrArray * connections; - NMSettingWirelessSecurity * s_wsec; - GError * error = NULL; + const GPtrArray *connections; + NMSettingWirelessSecurity *s_wsec; + GError *error = NULL; /* Set default timeout waiting for operation completion. */ if (nmc->timeout == -1) @@ -4459,7 +4463,7 @@ do_device_wifi_hotspot(const NMCCommand *cmd, NmCli *nmc, int argc, const char * static void request_rescan_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NmCli * nmc = (NmCli *) user_data; + NmCli *nmc = (NmCli *) user_data; GError *error = NULL; nm_device_wifi_request_scan_finish(NM_DEVICE_WIFI(object), result, &error); @@ -4474,13 +4478,13 @@ request_rescan_cb(GObject *object, GAsyncResult *result, gpointer user_data) static void do_device_wifi_rescan(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice * device; - const char * ifname = NULL; - gs_unref_ptrarray GPtrArray *ssids = NULL; - gs_free NMDevice **devices = NULL; - GVariantBuilder builder, array_builder; - GVariant * options; - int i; + NMDevice *device; + const char *ifname = NULL; + gs_unref_ptrarray GPtrArray *ssids = NULL; + gs_free NMDevice **devices = NULL; + GVariantBuilder builder, array_builder; + GVariant *options; + int i; ssids = g_ptr_array_new(); devices = nmc_get_devices_sorted(nmc->client); @@ -4599,13 +4603,13 @@ string_append_mecard(GString *string, const char *tag, const char *text) static void print_wifi_connection(const NmcConfig *nmc_config, NMConnection *connection) { - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - const char * key_mgmt = NULL; - const char * psk = NULL; - const char * type = NULL; - GBytes * ssid_bytes; - gs_free char * ssid = NULL; + NMSettingWireless *s_wireless; + NMSettingWirelessSecurity *s_wsec; + const char *key_mgmt = NULL; + const char *psk = NULL; + const char *type = NULL; + GBytes *ssid_bytes; + gs_free char *ssid = NULL; nm_auto_free_gstring GString *string = NULL; s_wireless = nm_connection_get_setting_wireless(connection); @@ -4661,9 +4665,9 @@ print_wifi_connection(const NmcConfig *nmc_config, NMConnection *connection) static gboolean wifi_show_device(const NmcConfig *nmc_config, NMDevice *device, GError **error) { - NMActiveConnection *active_conn; + NMActiveConnection *active_conn; gs_unref_object NMConnection *connection = NULL; - gs_unref_variant GVariant *secrets = NULL; + gs_unref_variant GVariant *secrets = NULL; if (!NM_IS_DEVICE_WIFI(device)) { g_set_error(error, @@ -4708,10 +4712,10 @@ wifi_show_device(const NmcConfig *nmc_config, NMDevice *device, GError **error) static void do_device_wifi_show_password(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - const char *ifname = NULL; - gs_free NMDevice **devices = NULL; - gs_free_error GError *error = NULL; - gboolean found = FALSE; + const char *ifname = NULL; + gs_free NMDevice **devices = NULL; + gs_free_error GError *error = NULL; + gboolean found = FALSE; int i; devices = nmc_get_devices_sorted(nmc->client); @@ -4795,9 +4799,9 @@ static int show_device_lldp_list(NMDevice *device, NmCli *nmc, const char *fields_str, int *counter) { const NMMetaAbstractInfo *const *tmpl; - NmcOutputField * arr; - GPtrArray * neighbors; - const char * str; + NmcOutputField *arr; + GPtrArray *neighbors; + const char *str; int i; NMC_OUTPUT_DATA_DEFINE_SCOPED(out); gs_free char *header_name = NULL; @@ -4894,10 +4898,10 @@ show_device_lldp_list(NMDevice *device, NmCli *nmc, const char *fields_str, int static void do_device_lldp_list(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice * device = NULL; - gs_free_error GError *error = NULL; - const char * fields_str = NULL; - int counter = 0; + NMDevice *device = NULL; + gs_free_error GError *error = NULL; + const char *fields_str = NULL; + int counter = 0; gs_unref_array GArray *out_indices = NULL; next_arg(nmc, &argc, &argv, NULL); @@ -4996,7 +5000,7 @@ is_single_word(const char *line) static char ** nmcli_device_tab_completion(const char *text, int start, int end) { - char ** match_array = NULL; + char **match_array = NULL; rl_compentry_func_t *generator_func = NULL; /* Disable readline's default filename completion */ diff --git a/src/nmcli/general.c b/src/nmcli/general.c index d87df17a9d..65437e7966 100644 --- a/src/nmcli/general.c +++ b/src/nmcli/general.c @@ -108,10 +108,11 @@ static NM_UTILS_LOOKUP_DEFINE( static const NmcMetaGenericInfo *const metagen_general_status[]; -static gconstpointer _metagen_general_status_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_general_status_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NmCli * nmc = target; - const char * value; + NmCli *nmc = target; + const char *value; gboolean v_bool; NMState state; NMConnectivityState connectivity; @@ -209,12 +210,13 @@ static const NmcMetaGenericInfo /*****************************************************************************/ -static gconstpointer _metagen_general_permissions_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_general_permissions_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { NMClientPermission perm = GPOINTER_TO_UINT(target); - NmCli * nmc = environment_user_data; + NmCli *nmc = environment_user_data; NMClientPermissionResult perm_result; - const char * s; + const char *s; switch (info->info_type) { case NMC_GENERIC_INFO_TYPE_GENERAL_PERMISSIONS_PERMISSION: @@ -252,9 +254,10 @@ typedef struct { char **domains; } GetGeneralLoggingData; -static gconstpointer _metagen_general_logging_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) +static gconstpointer +_metagen_general_logging_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) { - NmCli * nmc = environment_user_data; + NmCli *nmc = environment_user_data; GetGeneralLoggingData *d = target; nm_assert(info->info_type < _NMC_GENERIC_INFO_TYPE_GENERAL_LOGGING_NUM); @@ -466,9 +469,9 @@ static gboolean show_nm_status(NmCli *nmc, const char *pretty_header_name, const char *print_flds) { gs_free_error GError *error = NULL; - const char * fields_str; - const char * fields_all = print_flds ?: NMC_FIELDS_NM_STATUS_ALL; - const char * fields_common = print_flds ?: NMC_FIELDS_NM_STATUS_COMMON; + const char *fields_str; + const char *fields_all = print_flds ?: NMC_FIELDS_NM_STATUS_ALL; + const char *fields_common = print_flds ?: NMC_FIELDS_NM_STATUS_COMMON; if (!nmc->required_fields || g_ascii_strcasecmp(nmc->required_fields, "common") == 0) fields_str = fields_common; @@ -519,9 +522,9 @@ timeout_cb(gpointer user_data) static void print_permissions(void *user_data) { - NmCli * nmc = user_data; + NmCli *nmc = user_data; gs_free_error GError *error = NULL; - const char * fields_str = NULL; + const char *fields_str = NULL; gpointer permissions[G_N_ELEMENTS(nm_auth_permission_sorted) + 1]; gboolean is_running; int i; @@ -603,9 +606,9 @@ show_nm_permissions(NmCli *nmc) static void reload_cb(GObject *source, GAsyncResult *result, gpointer user_data) { - NmCli * nmc = user_data; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; + NmCli *nmc = user_data; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; ret = nm_dbus_call_finish(result, &error); if (error) { @@ -622,8 +625,8 @@ static void do_general_reload(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { gs_free const char **values = NULL; - gs_free char * err_token = NULL; - gs_free char * joined = NULL; + gs_free char *err_token = NULL; + gs_free char *joined = NULL; int flags = 0; next_arg(nmc, &argc, &argv, NULL); @@ -694,13 +697,13 @@ do_general_permissions(const NMCCommand *cmd, NmCli *nmc, int argc, const char * static void show_general_logging(NmCli *nmc) { - gs_free char *level_cache = NULL; - gs_free char *domains_cache = NULL; - gs_free_error GError *error = NULL; - const char * fields_str = NULL; - GetGeneralLoggingData d = { - .level = &level_cache, - .domains = &domains_cache, + gs_free char *level_cache = NULL; + gs_free char *domains_cache = NULL; + gs_free_error GError *error = NULL; + const char *fields_str = NULL; + GetGeneralLoggingData d = { + .level = &level_cache, + .domains = &domains_cache, }; if (!nmc->required_fields || g_ascii_strcasecmp(nmc->required_fields, "common") == 0) { @@ -742,9 +745,9 @@ nmc_complete_strings_nocase(const char *prefix, ...) static void _set_logging_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NmCli * nmc = user_data; - gs_unref_variant GVariant *res = NULL; - gs_free_error GError *error = NULL; + NmCli *nmc = user_data; + gs_unref_variant GVariant *res = NULL; + gs_free_error GError *error = NULL; res = nm_client_dbus_call_finish(NM_CLIENT(object), result, &error); if (!res) { @@ -878,7 +881,7 @@ do_general_logging(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons static void save_hostname_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NmCli * nmc = user_data; + NmCli *nmc = user_data; gs_free_error GError *error = NULL; nm_client_save_hostname_finish(NM_CLIENT(object), result, &error); @@ -984,9 +987,9 @@ nmc_switch_parse_on_off(NmCli *nmc, const char *arg1, const char *arg2, gboolean static void _do_networking_on_off_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NmCli * nmc = user_data; - gs_unref_variant GVariant *ret = NULL; - gs_free_error GError *error = NULL; + NmCli *nmc = user_data; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; ret = nm_client_dbus_call_finish(NM_CLIENT(object), result, &error); if (!ret) { @@ -1119,7 +1122,7 @@ do_radio_all(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *arg static void _do_radio_wifi_cb(GObject *object, GAsyncResult *result, gpointer user_data) { - NmCli * nmc = user_data; + NmCli *nmc = user_data; gs_free_error GError *error = NULL; if (!nm_client_dbus_set_property_finish(NM_CLIENT(object), result, &error)) { @@ -1214,7 +1217,7 @@ static void networkmanager_running(NMClient *client, GParamSpec *param, NmCli *nmc) { gboolean running; - char * str; + char *str; running = nm_client_get_nm_running(client); str = nmc_colorize(&nmc->nmc_config, @@ -1237,7 +1240,7 @@ static void client_primary_connection(NMClient *client, GParamSpec *param, NmCli *nmc) { NMActiveConnection *primary; - const char * id; + const char *id; primary = nm_client_get_primary_connection(client); if (primary) { @@ -1255,7 +1258,7 @@ static void client_connectivity(NMClient *client, GParamSpec *param, NmCli *nmc) { NMConnectivityState connectivity; - char * str; + char *str; g_object_get(client, NM_CLIENT_CONNECTIVITY, &connectivity, NULL); str = nmc_colorize(&nmc->nmc_config, @@ -1270,7 +1273,7 @@ static void client_state(NMClient *client, GParamSpec *param, NmCli *nmc) { NMState state; - char * str; + char *str; g_object_get(client, NM_CLIENT_STATE, &state, NULL); str = nmc_colorize(&nmc->nmc_config, @@ -1284,8 +1287,8 @@ client_state(NMClient *client, GParamSpec *param, NmCli *nmc) static void device_overview(NmCli *nmc, NMDevice *device) { - GString * outbuf = g_string_sized_new(80); - char * tmp; + GString *outbuf = g_string_sized_new(80); + char *tmp; const GPtrArray *activatable; activatable = nm_device_get_available_connections(device); @@ -1392,8 +1395,8 @@ device_overview(NmCli *nmc, NMDevice *device) static void ac_overview(NmCli *nmc, NMActiveConnection *ac) { - GString * outbuf = g_string_sized_new(80); - NMIPConfig * ip; + GString *outbuf = g_string_sized_new(80); + NMIPConfig *ip; nm_auto_str_buf NMStrBuf str = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE); if (nm_active_connection_get_master(ac)) { @@ -1463,12 +1466,12 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac) void nmc_command_func_overview(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - NMDevice ** devices; - const GPtrArray * p; + NMDevice **devices; + const GPtrArray *p; NMActiveConnection *ac; NMMetaColor color; - NMDnsEntry * dns; - char * tmp; + NMDnsEntry *dns; + char *tmp; int i; next_arg(nmc, &argc, &argv, NULL); diff --git a/src/nmcli/generate-docs-nm-settings-nmcli.c b/src/nmcli/generate-docs-nm-settings-nmcli.c index cd1bb67099..196e4d35f8 100644 --- a/src/nmcli/generate-docs-nm-settings-nmcli.c +++ b/src/nmcli/generate-docs-nm-settings-nmcli.c @@ -34,8 +34,8 @@ main(int argc, char *argv[]) for (i_sett_infos = 0; i_sett_infos < G_N_ELEMENTS(nm_meta_setting_infos_editor); i_sett_infos++) { const NMMetaSettingInfoEditor *sett_info = &nm_meta_setting_infos_editor[i_sett_infos]; - gs_free char * tmp_s1 = NULL; - gs_free char * tmp_s2 = NULL; + gs_free char *tmp_s1 = NULL; + gs_free char *tmp_s2 = NULL; g_print("%sgeneral->setting_name)); @@ -47,9 +47,9 @@ main(int argc, char *argv[]) for (i_property = 0; i_property < sett_info->properties_num; i_property++) { const NMMetaPropertyInfo *prop_info = sett_info->properties[i_property]; - gs_free char * tmp2 = NULL; - gs_free char * tmp3 = NULL; - gs_free char * tmp4 = NULL; + gs_free char *tmp2 = NULL; + gs_free char *tmp3 = NULL; + gs_free char *tmp4 = NULL; g_print("%sproperty_name)); diff --git a/src/nmcli/nmcli.c b/src/nmcli/nmcli.c index b2b2cd8143..fae4058490 100644 --- a/src/nmcli/nmcli.c +++ b/src/nmcli/nmcli.c @@ -118,7 +118,7 @@ typedef struct { } ArgsInfo; /* --- Global variables --- */ -GMainLoop * loop = NULL; +GMainLoop *loop = NULL; struct termios termios_orig; NM_CACHED_QUARK_FCN("nmcli-error-quark", nmcli_error_quark); @@ -150,10 +150,10 @@ static void complete_one(gpointer key, gpointer value, gpointer user_data) { const char **option_with_value = user_data; - const char * option = option_with_value[0]; - const char * prefix = option_with_value[1]; - const char * name = key; - const char * last; + const char *option = option_with_value[0]; + const char *prefix = option_with_value[1]; + const char *name = key; + const char *last; last = strrchr(prefix, ','); if (last) @@ -272,9 +272,9 @@ static gboolean matches_arg(NmCli *nmc, int *argc, const char *const **argv, const char *pattern, char **arg) { gs_free char *opt_free = NULL; - const char * opt = (*argv)[0]; + const char *opt = (*argv)[0]; gs_free char *arg_tmp = NULL; - const char * s; + const char *s; nm_assert(opt); nm_assert(opt[0] == '-'); @@ -377,7 +377,7 @@ check_colors_check_palette_one_file(const char *base_dir, const char *name, cons for (i = 0; i < G_N_ELEMENTS(extensions); i++) { gs_free char *filename = NULL; - char * contents; + char *contents; filename = check_colors_construct_filename(base_dir, name, term, extensions[i]); if (g_file_get_contents(filename, &contents, NULL, NULL)) @@ -470,9 +470,9 @@ check_colors_check_palette(const char *base_dir_1, static gboolean check_colors(NmcColorOption color_option, char **out_palette_str) { - const char * base_dir_1, *base_dir_2; + const char *base_dir_1, *base_dir_2; const char *const NAME = "nmcli"; - const char * term; + const char *term; *out_palette_str = NULL; @@ -681,8 +681,8 @@ parse_color_scheme(char *palette_buffer, NmcColorPalette *out_palette, GError ** static void set_colors(NmcColorOption color_option, - bool * out_use_colors, - char ** out_palette_buffer, + bool *out_use_colors, + char **out_palette_buffer, NmcColorPalette *out_palette) { gs_free char *palette_str = NULL; @@ -730,7 +730,7 @@ process_command_line(NmCli *nmc, int argc, char **argv_orig) {NULL, nmc_command_func_overview, usage, TRUE, TRUE}, }; NmcColorOption colors = NMC_USE_COLOR_AUTO; - const char * base; + const char *base; const char *const *argv; base = strrchr(argv_orig[0], '/'); diff --git a/src/nmcli/nmcli.h b/src/nmcli/nmcli.h index f130337879..157aae9982 100644 --- a/src/nmcli/nmcli.h +++ b/src/nmcli/nmcli.h @@ -85,7 +85,7 @@ typedef struct _NmcMetaGenericInfo NmcMetaGenericInfo; struct _NmcOutputField { const NMMetaAbstractInfo *info; int width; /* Width in screen columns */ - void * value; /* Value of current field - char* or char** (NULL-terminated array) */ + void *value; /* Value of current field - char* or char** (NULL-terminated array) */ gboolean value_is_array; /* Whether value is char** instead of char* */ gboolean free_value; /* Whether to free the value */ NmcOfFlags flags; /* Flags - whether and how to print values/field names/headers */ @@ -118,14 +118,14 @@ typedef struct _NmCli { NMClient *client; /* Pointer to NMClient of libnm */ NMCResultCode return_value; /* Return code of nmcli */ - GString * return_text; /* Reason text */ + GString *return_text; /* Reason text */ NmcPagerData pager_data; int timeout; /* Operation timeout */ - NMSecretAgentSimple * secret_agent; /* Secret agent */ - GHashTable * pwds_hash; /* Hash table with passwords in passwd-file */ + NMSecretAgentSimple *secret_agent; /* Secret agent */ + GHashTable *pwds_hash; /* Hash table with passwords in passwd-file */ struct _NMPolkitListener *pk_listener; /* polkit agent listener */ int should_wait; /* Semaphore indicating whether nmcli should not end or not yet */ @@ -135,7 +135,7 @@ typedef struct _NmCli { const NmcConfig nmc_config; NmcConfig nmc_config_mutable; }; - char * required_fields; /* Required fields in output: '--fields' option */ + char *required_fields; /* Required fields in output: '--fields' option */ gboolean ask; /* Ask for missing parameters: option '--ask' */ gboolean complete; /* Autocomplete the command line */ gboolean editor_status_line; /* Whether to display status line in connection editor */ @@ -163,9 +163,9 @@ void nm_cli_spawn_pager(const NmcConfig *nmc_config, NmcPagerData *pager_data); void nmc_empty_output_fields(NmcOutputData *output_data); #define NMC_OUTPUT_DATA_DEFINE_SCOPED(out) \ - gs_unref_array GArray * out##_indices = NULL; \ + gs_unref_array GArray *out##_indices = NULL; \ nm_auto(nmc_empty_output_fields) NmcOutputData out = { \ - .output_data = g_ptr_array_new_full(20, g_free), \ + .output_data = g_ptr_array_new_full(20, g_free), \ } /*****************************************************************************/ diff --git a/src/nmcli/polkit-agent.c b/src/nmcli/polkit-agent.c index 7776d7e7b2..41567023d3 100644 --- a/src/nmcli/polkit-agent.c +++ b/src/nmcli/polkit-agent.c @@ -43,7 +43,7 @@ gboolean nmc_polkit_agent_init(NmCli *nmc, gboolean for_session, GError **error) { NMPolkitListener *listener; - GDBusConnection * dbus_connection = NULL; + GDBusConnection *dbus_connection = NULL; g_return_val_if_fail(error == NULL || *error == NULL, FALSE); diff --git a/src/nmcli/settings.c b/src/nmcli/settings.c index f496640087..c80d0c7c5b 100644 --- a/src/nmcli/settings.c +++ b/src/nmcli/settings.c @@ -24,8 +24,8 @@ static gboolean get_answer(const char *prop, const char *value) { - char * tmp_str; - char * question; + char *tmp_str; + char *question; gboolean answer = FALSE; if (value) @@ -226,7 +226,7 @@ proxy_method_changed_cb(GObject *object, GParamSpec *pspec, gpointer user_data) static void wireless_band_channel_changed_cb(GObject *object, GParamSpec *pspec, gpointer user_data) { - const char * value = NULL, *mode; + const char *value = NULL, *mode; char str[16]; NMSettingWireless *s_wireless = NM_SETTING_WIRELESS(object); @@ -257,9 +257,9 @@ static void connection_master_changed_cb(GObject *object, GParamSpec *pspec, gpointer user_data) { NMSettingConnection *s_con = NM_SETTING_CONNECTION(object); - NMConnection * connection = NM_CONNECTION(user_data); - NMSetting * s_ipv4, *s_ipv6; - const char * value, *tmp_str; + NMConnection *connection = NM_CONNECTION(user_data); + NMSetting *s_ipv4, *s_ipv6; + const char *value, *tmp_str; value = nm_setting_connection_get_master(s_con); if (value) { @@ -350,16 +350,16 @@ nmc_setting_connection_connect_handlers(NMSettingConnection *setting, NMConnecti /*****************************************************************************/ static gboolean -_set_fcn_precheck_connection_secondaries(NMClient * client, +_set_fcn_precheck_connection_secondaries(NMClient *client, const char *value, - char ** value_coerced, - GError ** error) + char **value_coerced, + GError **error) { - const GPtrArray * connections; - NMConnection * con; + const GPtrArray *connections; + NMConnection *con; gs_free const char **strv0 = NULL; - gs_strfreev char ** strv = NULL; - char ** iter; + gs_strfreev char **strv = NULL; + char **iter; gboolean modified = FALSE; strv0 = nm_strsplit_set(value, " \t,"); @@ -419,7 +419,7 @@ _env_warn_fcn_handle( fmt_l10n, /* the untranslated format string, but it is marked for translation using N_(). */ va_list ap) { - NmCli * nmc = environment_user_data; + NmCli *nmc = environment_user_data; gs_free char *m = NULL; if (nmc->complete) @@ -443,9 +443,9 @@ _env_warn_fcn_handle( static NMDevice *const * _env_get_nm_devices(const NMMetaEnvironment *environment, gpointer environment_user_data, - guint * out_len) + guint *out_len) { - NmCli * nmc = environment_user_data; + NmCli *nmc = environment_user_data; const GPtrArray *devices; nm_assert(nmc); @@ -467,9 +467,9 @@ _env_get_nm_devices(const NMMetaEnvironment *environment, static NMRemoteConnection *const * _env_get_nm_connections(const NMMetaEnvironment *environment, gpointer environment_user_data, - guint * out_len) + guint *out_len) { - NmCli * nmc = environment_user_data; + NmCli *nmc = environment_user_data; const GPtrArray *values; nm_assert(nmc); @@ -497,11 +497,11 @@ const NMMetaEnvironment *const nmc_meta_environment = &((NMMetaEnvironment){ }); static char * -get_property_val(NMSetting * setting, - const char * prop, +get_property_val(NMSetting *setting, + const char *prop, NMMetaAccessorGetType get_type, gboolean show_secrets, - GError ** error) + GError **error) { const NMMetaPropertyInfo *property_info; @@ -514,8 +514,8 @@ get_property_val(NMSetting * setting, if ((property_info = nm_meta_property_info_find_by_setting(setting, prop))) { if (property_info->property_type->get_fcn) { NMMetaAccessorGetOutFlags out_flags = NM_META_ACCESSOR_GET_OUT_FLAGS_NONE; - char * to_free = NULL; - const char * value; + char *to_free = NULL; + const char *value; value = property_info->property_type->get_fcn( property_info, @@ -560,15 +560,15 @@ nmc_setting_get_property_parsable(NMSetting *setting, const char *prop, GError * } gboolean -nmc_setting_set_property(NMClient * client, - NMSetting * setting, - const char * prop, +nmc_setting_set_property(NMClient *client, + NMSetting *setting, + const char *prop, NMMetaAccessorModifier modifier, - const char * value, - GError ** error) + const char *value, + GError **error) { const NMMetaPropertyInfo *property_info; - gs_free char * value_to_free = NULL; + gs_free char *value_to_free = NULL; gboolean success; g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); @@ -639,7 +639,7 @@ char ** nmc_setting_get_valid_properties(NMSetting *setting) { const NMMetaSettingInfoEditor *setting_info; - char ** valid_props; + char **valid_props; guint i, num; setting_info = nm_meta_setting_info_editor_find_by_setting(setting); @@ -686,14 +686,14 @@ nmc_setting_get_property_allowed_values(NMSetting *setting, const char *prop, ch char * nmc_setting_get_property_desc(NMSetting *setting, const char *prop) { - gs_free char * desc_to_free = NULL; - const char * setting_desc = NULL; - const char * setting_desc_title = ""; - const char * nmcli_desc = NULL; - const char * nmcli_desc_title = ""; - const char * nmcli_nl = ""; + gs_free char *desc_to_free = NULL; + const char *setting_desc = NULL; + const char *setting_desc_title = ""; + const char *nmcli_desc = NULL; + const char *nmcli_desc_title = ""; + const char *nmcli_nl = ""; const NMMetaPropertyInfo *property_info; - const char * desc = NULL; + const char *desc = NULL; g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); @@ -732,8 +732,8 @@ gboolean setting_details(const NmcConfig *nmc_config, NMSetting *setting, const char *one_prop) { const NMMetaSettingInfoEditor *setting_info; - gs_free_error GError *error = NULL; - gs_free char * fields_str = NULL; + gs_free_error GError *error = NULL; + gs_free char *fields_str = NULL; g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); diff --git a/src/nmcli/settings.h b/src/nmcli/settings.h index 2dbe76074f..9cbf13c4b7 100644 --- a/src/nmcli/settings.h +++ b/src/nmcli/settings.h @@ -17,20 +17,20 @@ void nmc_setting_ip6_connect_handlers(NMSettingIPConfig *setting); void nmc_setting_proxy_connect_handlers(NMSettingProxy *setting); void nmc_setting_wireless_connect_handlers(NMSettingWireless *setting); void nmc_setting_connection_connect_handlers(NMSettingConnection *setting, - NMConnection * connection); + NMConnection *connection); char **nmc_setting_get_valid_properties(NMSetting *setting); -char * nmc_setting_get_property_desc(NMSetting *setting, const char *prop); +char *nmc_setting_get_property_desc(NMSetting *setting, const char *prop); const char *const * nmc_setting_get_property_allowed_values(NMSetting *setting, const char *prop, char ***out_to_free); -char * nmc_setting_get_property(NMSetting *setting, const char *prop, GError **error); -char * nmc_setting_get_property_parsable(NMSetting *setting, const char *prop, GError **error); -gboolean nmc_setting_set_property(NMClient * client, - NMSetting * setting, - const char * prop, +char *nmc_setting_get_property(NMSetting *setting, const char *prop, GError **error); +char *nmc_setting_get_property_parsable(NMSetting *setting, const char *prop, GError **error); +gboolean nmc_setting_set_property(NMClient *client, + NMSetting *setting, + const char *prop, NMMetaAccessorModifier modifier, - const char * val, - GError ** error); + const char *val, + GError **error); gboolean setting_details(const NmcConfig *nmc_config, NMSetting *setting, const char *one_prop); diff --git a/src/nmcli/utils.c b/src/nmcli/utils.c index 85768c1908..7645a08cd6 100644 --- a/src/nmcli/utils.c +++ b/src/nmcli/utils.c @@ -40,8 +40,8 @@ _meta_type_nmc_generic_info_get_name(const NMMetaAbstractInfo *abstract_info, gb static const NMMetaAbstractInfo *const * _meta_type_nmc_generic_info_get_nested(const NMMetaAbstractInfo *abstract_info, - guint * out_len, - gpointer * out_to_free) + guint *out_len, + gpointer *out_to_free) { const NmcMetaGenericInfo *info; @@ -52,16 +52,16 @@ _meta_type_nmc_generic_info_get_nested(const NMMetaAbstractInfo *abstract_info, } static gconstpointer -_meta_type_nmc_generic_info_get_fcn(const NMMetaAbstractInfo * abstract_info, - const NMMetaEnvironment * environment, +_meta_type_nmc_generic_info_get_fcn(const NMMetaAbstractInfo *abstract_info, + const NMMetaEnvironment *environment, gpointer environment_user_data, gpointer target, gpointer target_data, NMMetaAccessorGetType get_type, NMMetaAccessorGetFlags get_flags, NMMetaAccessorGetOutFlags *out_flags, - gboolean * out_is_default, - gpointer * out_to_free) + gboolean *out_is_default, + gpointer *out_to_free) { const NmcMetaGenericInfo *info = (const NmcMetaGenericInfo *) abstract_info; @@ -244,11 +244,11 @@ nmc_arg_is_option(const char *str, const char *opt_name) * Returns: TRUE on success, FALSE on an error and sets 'error' */ gboolean -nmc_parse_args(nmc_arg_t * arg_arr, +nmc_parse_args(nmc_arg_t *arg_arr, gboolean last, - int * argc, + int *argc, const char *const **argv, - GError ** error) + GError **error) { nmc_arg_t *p; gboolean found; @@ -376,7 +376,7 @@ nmc_colorize(const NmcConfig *nmc_config, NMMetaColor color, const char *fmt, .. { va_list args; gs_free char *str = NULL; - const char * ansi_seq = NULL; + const char *ansi_seq = NULL; va_start(args, fmt); str = g_strdup_vprintf(fmt, args); @@ -423,7 +423,7 @@ void nmc_filter_out_colors_inplace(char *str) { const char *p1; - char * p2; + char *p2; gboolean copy_char = TRUE; if (!str) @@ -463,7 +463,7 @@ nmc_filter_out_colors(const char *str) char * nmc_get_user_input(const char *ask_str) { - char * line = NULL; + char *line = NULL; size_t line_ln = 0; ssize_t num; @@ -489,11 +489,11 @@ int nmc_string_to_arg_array(const char *line, const char *delim, gboolean unquote, - char *** argv, - int * argc) + char ***argv, + int *argc) { gs_free const char **arr0 = NULL; - char ** arr; + char **arr; arr0 = nm_strsplit_set(line ?: "", delim ?: " \t"); if (!arr0) @@ -503,7 +503,7 @@ nmc_string_to_arg_array(const char *line, if (unquote) { int i = 0; - char * s; + char *s; size_t l; const char *quotes = "\"'"; @@ -658,17 +658,17 @@ typedef struct _PrintDataCol { } PrintDataCol; static gboolean -_output_selection_append(GArray * cols, +_output_selection_append(GArray *cols, guint parent_idx, const NMMetaSelectionItem *selection_item, - GPtrArray * gfree_keeper, - GError ** error) + GPtrArray *gfree_keeper, + GError **error) { gs_free gpointer nested_to_free = NULL; guint col_idx; guint i; const NMMetaAbstractInfo *const *nested; - NMMetaSelectionResultList * selection; + NMMetaSelectionResultList *selection; col_idx = cols->len; @@ -787,16 +787,16 @@ _output_selection_complete(GArray *cols) */ static gboolean _output_selection_parse(const NMMetaAbstractInfo *const *fields, - const char * fields_str, - PrintDataCol ** out_cols_data, - guint * out_cols_len, - GPtrArray ** out_gfree_keeper, - GError ** error) + const char *fields_str, + PrintDataCol **out_cols_data, + guint *out_cols_len, + GPtrArray **out_gfree_keeper, + GError **error) { - NMMetaSelectionResultList *selection; + NMMetaSelectionResultList *selection; gs_unref_ptrarray GPtrArray *gfree_keeper = NULL; - gs_unref_array GArray *cols = NULL; - guint i; + gs_unref_array GArray *cols = NULL; + guint i; selection = nm_meta_selection_create_parse_list(fields, fields_str, FALSE, error); if (!selection) @@ -853,15 +853,15 @@ _output_selection_parse(const NMMetaAbstractInfo *const *fields, * Caller is responsible for freeing the array. */ GArray * -parse_output_fields(const char * fields_str, +parse_output_fields(const char *fields_str, const NMMetaAbstractInfo *const *fields_array, gboolean parse_groups, - GPtrArray ** out_group_fields, - GError ** error) + GPtrArray **out_group_fields, + GError **error) { gs_free NMMetaSelectionResultList *selection = NULL; - GArray * array; - GPtrArray * group_fields = NULL; + GArray *array; + GPtrArray *group_fields = NULL; guint i; g_return_val_if_fail(!error || !*error, NULL); @@ -926,7 +926,7 @@ nmc_empty_output_fields(NmcOutputData *output_data) typedef struct { guint col_idx; const PrintDataCol *col; - const char * title; + const char *title; bool title_to_free : 1; /* whether the column should be printed. If not %TRUE, @@ -946,7 +946,7 @@ typedef struct { const PrintDataHeaderCell *header_cell; NMMetaColor color; union { - const char * plain; + const char *plain; const char *const *strv; } text; PrintDataCellFormatType text_format : 3; @@ -993,16 +993,16 @@ _print_data_cell_clear(gpointer cell_p) } static void -_print_fill(const NmcConfig * nmc_config, - gpointer const * targets, +_print_fill(const NmcConfig *nmc_config, + gpointer const *targets, gpointer targets_data, const PrintDataCol *cols, guint cols_len, - GArray ** out_header_row, - GArray ** out_cells) + GArray **out_header_row, + GArray **out_cells) { - GArray * cells; - GArray * header_row; + GArray *cells; + GArray *header_row; guint i_row, i_col; guint targets_len; NMMetaAccessorGetType text_get_type; @@ -1012,8 +1012,8 @@ _print_fill(const NmcConfig * nmc_config, g_array_set_clear_func(header_row, _print_data_header_cell_clear); for (i_col = 0; i_col < cols_len; i_col++) { - const PrintDataCol * col; - PrintDataHeaderCell * header_cell; + const PrintDataCol *col; + PrintDataHeaderCell *header_cell; guint col_idx; const NMMetaAbstractInfo *info; @@ -1064,9 +1064,9 @@ _print_fill(const NmcConfig * nmc_config, PrintDataCell *cells_line = &g_array_index(cells, PrintDataCell, i_row * header_row->len); for (i_col = 0; i_col < header_row->len; i_col++) { - char * to_free = NULL; - PrintDataCell * cell = &cells_line[i_col]; - PrintDataHeaderCell * header_cell; + char *to_free = NULL; + PrintDataCell *cell = &cells_line[i_col]; + PrintDataHeaderCell *header_cell; const NMMetaAbstractInfo *info; NMMetaAccessorGetOutFlags text_out_flags, color_out_flags; gconstpointer value; @@ -1155,7 +1155,7 @@ _print_fill(const NmcConfig * nmc_config, const PrintDataCell *cells_line = &g_array_index(cells, PrintDataCell, i_row * header_row->len); const PrintDataCell *cell = &cells_line[i_col]; - const char *const * i_strv; + const char *const *i_strv; switch (cell->text_format) { case PRINT_DATA_CELL_FORMAT_TYPE_PLAIN: @@ -1185,7 +1185,7 @@ static gboolean _print_skip_column(const NmcConfig *nmc_config, const PrintDataHeaderCell *header_cell) { const NMMetaSelectionItem *selection_item; - const NMMetaAbstractInfo * info; + const NMMetaAbstractInfo *info; selection_item = header_cell->col->selection_item; info = selection_item->info; @@ -1217,16 +1217,16 @@ _print_skip_column(const NmcConfig *nmc_config, const PrintDataHeaderCell *heade } static void -_print_do(const NmcConfig * nmc_config, - const char * header_name_no_l10n, +_print_do(const NmcConfig *nmc_config, + const char *header_name_no_l10n, guint col_len, guint row_len, const PrintDataHeaderCell *header_row, - const PrintDataCell * cells) + const PrintDataCell *cells) { - int width1, width2; - int table_width = 0; - guint i_row, i_col; + int width1, width2; + int table_width = 0; + guint i_row, i_col; nm_auto_free_gstring GString *str = NULL; g_assert(col_len); @@ -1235,7 +1235,7 @@ _print_do(const NmcConfig * nmc_config, if (nmc_config->print_output == NMC_PRINT_PRETTY && header_name_no_l10n) { gs_free char *line = NULL; int header_width; - const char * header_name = _(header_name_no_l10n); + const char *header_name = _(header_name_no_l10n); header_width = nmc_string_screen_width(header_name, NULL) + 4; @@ -1261,7 +1261,7 @@ _print_do(const NmcConfig * nmc_config, && !nmc_config->multiline_output) { for (i_col = 0; i_col < col_len; i_col++) { const PrintDataHeaderCell *header_cell = &header_row[i_col]; - const char * title; + const char *title; if (_print_skip_column(nmc_config, header_cell)) continue; @@ -1297,7 +1297,7 @@ _print_do(const NmcConfig * nmc_config, for (i_col = 0; i_col < col_len; i_col++) { const PrintDataCell *cell = ¤t_line[i_col]; - const char *const * lines = NULL; + const char *const *lines = NULL; guint i_lines, lines_len; if (_print_skip_column(nmc_config, cell->header_cell)) @@ -1318,7 +1318,7 @@ _print_do(const NmcConfig * nmc_config, for (i_lines = 0; i_lines < lines_len; i_lines++) { gs_free char *text_to_free = NULL; - const char * text; + const char *text; text = colorize_string(nmc_config, cell->color, lines[i_lines], &text_to_free); if (nmc_config->multiline_output) { @@ -1385,19 +1385,19 @@ _print_do(const NmcConfig * nmc_config, } gboolean -nmc_print(const NmcConfig * nmc_config, - gpointer const * targets, +nmc_print(const NmcConfig *nmc_config, + gpointer const *targets, gpointer targets_data, - const char * header_name_no_l10n, + const char *header_name_no_l10n, const NMMetaAbstractInfo *const *fields, - const char * fields_str, - GError ** error) + const char *fields_str, + GError **error) { gs_unref_ptrarray GPtrArray *gfree_keeper = NULL; - gs_free PrintDataCol *cols_data = NULL; - guint cols_len; - gs_unref_array GArray *header_row = NULL; - gs_unref_array GArray *cells = NULL; + gs_free PrintDataCol *cols_data = NULL; + guint cols_len; + gs_unref_array GArray *header_row = NULL; + gs_unref_array GArray *cells = NULL; if (!_output_selection_parse(fields, fields_str, &cols_data, &cols_len, &gfree_keeper, error)) return FALSE; @@ -1528,15 +1528,15 @@ nmc_terminal_spawn_pager(const NmcConfig *nmc_config) /*****************************************************************************/ static const char * -get_value_to_print(const NmcConfig * nmc_config, +get_value_to_print(const NmcConfig *nmc_config, const NmcOutputField *field, gboolean field_name, - const char * not_set_str, - char ** out_to_free) + const char *not_set_str, + char **out_to_free) { gboolean is_array = field->value_is_array; - const char * value; - const char * out; + const char *value; + const char *out; gs_free char *free_value = NULL; nm_assert(out_to_free && !*out_to_free); @@ -1569,18 +1569,18 @@ get_value_to_print(const NmcConfig * nmc_config, * of 'field_values' array. */ void -print_required_fields(const NmcConfig * nmc_config, - NmcPagerData * pager_data, +print_required_fields(const NmcConfig *nmc_config, + NmcPagerData *pager_data, NmcOfFlags of_flags, - const GArray * indices, - const char * header_name, + const GArray *indices, + const char *header_name, int indent, const NmcOutputField *field_values) { nm_auto_free_gstring GString *str = NULL; int width1, width2; int table_width = 0; - const char * not_set_str; + const char *not_set_str; int i; gboolean main_header_add = of_flags & NMC_OF_FLAG_MAIN_HEADER_ADD; gboolean main_header_only = of_flags & NMC_OF_FLAG_MAIN_HEADER_ONLY; @@ -1635,7 +1635,7 @@ print_required_fields(const NmcConfig * nmc_config, if (is_array) { gs_free char *val_to_free = NULL; - const char ** p, *val, *print_val; + const char **p, *val, *print_val; int j; /* value is a null-terminated string array */ @@ -1664,9 +1664,9 @@ print_required_fields(const NmcConfig * nmc_config, } else { gs_free char *val_to_free = NULL; gs_free char *tmp = NULL; - const char * hdr_name = (const char *) field_values[0].value; - const char * val = (const char *) field_values[idx].value; - const char * print_val; + const char *hdr_name = (const char *) field_values[0].value; + const char *val = (const char *) field_values[idx].value; + const char *print_val; /* value is a string */ @@ -1703,7 +1703,7 @@ print_required_fields(const NmcConfig * nmc_config, for (i = 0; i < indices->len; i++) { gs_free char *val_to_free = NULL; int idx; - const char * value; + const char *value; idx = g_array_index(indices, int, i); @@ -1782,7 +1782,7 @@ print_data_prepare_width(GPtrArray *output_data) for (j = 0; j < output_data->len; j++) { gboolean field_names; gs_free char *val_to_free = NULL; - const char * value; + const char *value; row = g_ptr_array_index(output_data, j); field_names = row[0].flags & NMC_OF_FLAG_FIELD_NAMES; @@ -1798,10 +1798,10 @@ print_data_prepare_width(GPtrArray *output_data) } void -print_data(const NmcConfig * nmc_config, - NmcPagerData * pager_data, - const GArray * indices, - const char * header_name, +print_data(const NmcConfig *nmc_config, + NmcPagerData *pager_data, + const GArray *indices, + const char *header_name, int indent, const NmcOutputData *out) { diff --git a/src/nmcli/utils.h b/src/nmcli/utils.h index aadaab6749..c6ead55b86 100644 --- a/src/nmcli/utils.h +++ b/src/nmcli/utils.h @@ -11,7 +11,7 @@ /* === Types === */ typedef struct { - const char * name; + const char *name; gboolean has_value; const char **value; gboolean mandatory; @@ -22,16 +22,16 @@ typedef struct { int next_arg(NmCli *nmc, int *argc, const char *const **argv, ...); gboolean nmc_arg_is_help(const char *arg); gboolean nmc_arg_is_option(const char *arg, const char *opt_name); -gboolean nmc_parse_args(nmc_arg_t * arg_arr, +gboolean nmc_parse_args(nmc_arg_t *arg_arr, gboolean last, - int * argc, + int *argc, const char *const **argv, - GError ** error); -char * ssid_to_hex(const char *str, gsize len); + GError **error); +char *ssid_to_hex(const char *str, gsize len); void nmc_terminal_erase_line(void); void nmc_terminal_show_progress(const char *str); pid_t nmc_terminal_spawn_pager(const NmcConfig *nmc_config); -char * nmc_colorize(const NmcConfig *nmc_config, NMMetaColor color, const char *fmt, ...) +char *nmc_colorize(const NmcConfig *nmc_config, NMMetaColor color, const char *fmt, ...) _nm_printf(3, 4); void nmc_filter_out_colors_inplace(char *str); char *nmc_filter_out_colors(const char *str); @@ -39,8 +39,8 @@ char *nmc_get_user_input(const char *ask_str); int nmc_string_to_arg_array(const char *line, const char *delim, gboolean unquote, - char *** argv, - int * argc); + char ***argv, + int *argc); char *nmc_util_strv_for_display(const char *const *strv, gboolean brackets); int nmc_string_screen_width(const char *start, const char *end); void set_val_str(NmcOutputField fields_array[], guint32 index, char *value); @@ -50,25 +50,25 @@ void set_val_arrc(NmcOutputField fields_array[], guint32 index, const char **va void set_val_color_all(NmcOutputField fields_array[], NMMetaColor color); void nmc_free_output_field_values(NmcOutputField fields_array[]); -GArray * parse_output_fields(const char * fields_str, +GArray *parse_output_fields(const char *fields_str, const NMMetaAbstractInfo *const *fields_array, gboolean parse_groups, - GPtrArray ** group_fields, - GError ** error); + GPtrArray **group_fields, + GError **error); NmcOutputField *nmc_dup_fields_array(const NMMetaAbstractInfo *const *fields, NmcOfFlags flags); void nmc_empty_output_fields(NmcOutputData *output_data); -void print_required_fields(const NmcConfig * nmc_config, - NmcPagerData * pager_data, +void print_required_fields(const NmcConfig *nmc_config, + NmcPagerData *pager_data, NmcOfFlags of_flags, - const GArray * indices, - const char * header_name, + const GArray *indices, + const char *header_name, int indent, const NmcOutputField *field_values); void print_data_prepare_width(GPtrArray *output_data); -void print_data(const NmcConfig * nmc_config, - NmcPagerData * pager_data, - const GArray * indices, - const char * header_name, +void print_data(const NmcConfig *nmc_config, + NmcPagerData *pager_data, + const GArray *indices, + const char *header_name, int indent, const NmcOutputData *out); @@ -251,8 +251,8 @@ struct _NmcMetaGenericInfo { const NMMetaType *meta_type; }; NmcGenericInfoType info_type; - const char * name; - const char * name_header; + const char *name; + const char *name_header; const NmcMetaGenericInfo *const *nested; #define NMC_META_GENERIC_INFO_GET_FCN_ARGS \ @@ -327,7 +327,7 @@ typedef enum { static inline char * nmc_meta_generic_get_enum_with_detail(NmcMetaGenericGetEnumType get_enum_type, gint64 enum_val, - const char * str_val, + const char *str_val, NMMetaAccessorGetType get_type) { if (!NM_IN_SET(get_type, NM_META_ACCESSOR_GET_TYPE_PRETTY, NM_META_ACCESSOR_GET_TYPE_PARSABLE)) @@ -359,13 +359,13 @@ nmc_meta_generic_get_enum_with_detail(NmcMetaGenericGetEnumType get_enum_type, /*****************************************************************************/ -gboolean nmc_print(const NmcConfig * nmc_config, - gpointer const * targets, +gboolean nmc_print(const NmcConfig *nmc_config, + gpointer const *targets, gpointer targets_data, - const char * header_name_no_l10n, + const char *header_name_no_l10n, const NMMetaAbstractInfo *const *fields, - const char * fields_str, - GError ** error); + const char *fields_str, + GError **error); /*****************************************************************************/ diff --git a/src/nmtui/nm-editor-bindings.c b/src/nmtui/nm-editor-bindings.c index 59474fba42..22ffdfd598 100644 --- a/src/nmtui/nm-editor-bindings.c +++ b/src/nmtui/nm-editor-bindings.c @@ -55,16 +55,16 @@ nm_editor_bindings_init(void) } static gboolean -ip_addresses_with_prefix_to_strv(GBinding * binding, +ip_addresses_with_prefix_to_strv(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { - GPtrArray * addrs; + GPtrArray *addrs; NMIPAddress *addr; - const char * addrstr; + const char *addrstr; guint32 prefix; - char ** strings; + char **strings; int i; addrs = g_value_get_boxed(source_value); @@ -86,16 +86,16 @@ ip_addresses_with_prefix_to_strv(GBinding * binding, } static gboolean -ip_addresses_with_prefix_from_strv(GBinding * binding, +ip_addresses_with_prefix_from_strv(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { int addr_family = GPOINTER_TO_INT(user_data); - char ** strings; - GPtrArray * addrs; + char **strings; + GPtrArray *addrs; NMIPAddress *addr; - char * addrstr; + char *addrstr; int prefix; int i; @@ -165,9 +165,9 @@ ip_addresses_with_prefix_from_strv(GBinding * binding, void nm_editor_bind_ip_addresses_with_prefix_to_strv(int addr_family, gpointer source, - const char * source_property, + const char *source_property, gpointer target, - const char * target_property, + const char *target_property, GBindingFlags flags) { g_object_bind_property_full(source, @@ -182,9 +182,9 @@ nm_editor_bind_ip_addresses_with_prefix_to_strv(int addr_family, } static gboolean -ip_addresses_check_and_copy(GBinding * binding, +ip_addresses_check_and_copy(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { int addr_family = GPOINTER_TO_INT(user_data); @@ -220,9 +220,9 @@ ip_addresses_check_and_copy(GBinding * binding, void nm_editor_bind_ip_addresses_to_strv(int addr_family, gpointer source, - const char * source_property, + const char *source_property, gpointer target, - const char * target_property, + const char *target_property, GBindingFlags flags) { g_object_bind_property_full(source, @@ -237,9 +237,9 @@ nm_editor_bind_ip_addresses_to_strv(int addr_family, } static gboolean -ip_gateway_to_string(GBinding * binding, +ip_gateway_to_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { g_value_set_string(target_value, g_value_get_string(source_value)); @@ -247,9 +247,9 @@ ip_gateway_to_string(GBinding * binding, } static gboolean -ip_gateway_from_string(GBinding * binding, +ip_gateway_from_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { int addr_family = GPOINTER_TO_INT(user_data); @@ -264,9 +264,9 @@ ip_gateway_from_string(GBinding * binding, } static gboolean -ip_addresses_to_gateway(GBinding * binding, +ip_addresses_to_gateway(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { GPtrArray *addrs; @@ -280,9 +280,9 @@ ip_addresses_to_gateway(GBinding * binding, } static gboolean -ip_addresses_to_sensitivity(GBinding * binding, +ip_addresses_to_sensitivity(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { GPtrArray *addrs; @@ -319,8 +319,8 @@ void nm_editor_bind_ip_gateway_to_string(int addr_family, NMSettingIPConfig *source, gpointer target, - const char * target_property, - const char * target_sensitive_property, + const char *target_property, + const char *target_sensitive_property, GBindingFlags flags) { g_object_bind_property_full(source, @@ -353,14 +353,14 @@ nm_editor_bind_ip_gateway_to_string(int addr_family, } static gboolean -ip_route_transform_to_dest_string(GBinding * binding, +ip_route_transform_to_dest_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { - NMIPRoute * route; + NMIPRoute *route; const char *addrstr; - char * string; + char *string; route = g_value_get_boxed(source_value); if (route) @@ -377,12 +377,12 @@ ip_route_transform_to_dest_string(GBinding * binding, } static gboolean -ip_route_transform_to_next_hop_string(GBinding * binding, +ip_route_transform_to_next_hop_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { - NMIPRoute * route; + NMIPRoute *route; const char *addrstr; route = g_value_get_boxed(source_value); @@ -398,13 +398,13 @@ ip_route_transform_to_next_hop_string(GBinding * binding, } static gboolean -ip_route_transform_to_metric_string(GBinding * binding, +ip_route_transform_to_metric_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMIPRoute *route; - char * string; + char *string; route = g_value_get_boxed(source_value); if (route && nm_ip_route_get_dest(route) && nm_ip_route_get_metric(route) != -1) { @@ -416,15 +416,15 @@ ip_route_transform_to_metric_string(GBinding * binding, } static gboolean -ip_route_transform_from_dest_string(GBinding * binding, +ip_route_transform_from_dest_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { int addr_family = GPOINTER_TO_INT(user_data); - NMIPRoute * route; + NMIPRoute *route; const char *text; - char * addrstr; + char *addrstr; int prefix; text = g_value_get_string(source_value); @@ -461,13 +461,13 @@ ip_route_transform_from_dest_string(GBinding * binding, } static gboolean -ip_route_transform_from_next_hop_string(GBinding * binding, +ip_route_transform_from_next_hop_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { int addr_family = GPOINTER_TO_INT(user_data); - NMIPRoute * route; + NMIPRoute *route; const char *text; text = g_value_get_string(source_value); @@ -490,12 +490,12 @@ ip_route_transform_from_next_hop_string(GBinding * binding, } static gboolean -ip_route_transform_from_metric_string(GBinding * binding, +ip_route_transform_from_metric_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { - NMIPRoute * route; + NMIPRoute *route; const char *text; gint64 metric; @@ -538,13 +538,13 @@ ip_route_transform_from_metric_string(GBinding * binding, void nm_editor_bind_ip_route_to_strings(int addr_family, gpointer source, - const char * source_property, + const char *source_property, gpointer dest_target, - const char * dest_target_property, + const char *dest_target_property, gpointer next_hop_target, - const char * next_hop_target_property, + const char *next_hop_target_property, gpointer metric_target, - const char * metric_target_property, + const char *metric_target_property, GBindingFlags flags) { g_object_bind_property_full(source, @@ -577,13 +577,13 @@ nm_editor_bind_ip_route_to_strings(int addr_family, } gboolean -peer_transform_to_public_key_string(GBinding * binding, +peer_transform_to_public_key_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - char * string; + char *string; peer = g_value_get_boxed(source_value); if (peer && nm_wireguard_peer_get_public_key(peer)) { @@ -595,13 +595,13 @@ peer_transform_to_public_key_string(GBinding * binding, } gboolean -peer_transform_to_allowed_ips_string(GBinding * binding, +peer_transform_to_allowed_ips_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - GString * string = NULL; + GString *string = NULL; guint i, len; peer = g_value_get_boxed(source_value); @@ -623,13 +623,13 @@ peer_transform_to_allowed_ips_string(GBinding * binding, } gboolean -peer_transform_to_endpoint_string(GBinding * binding, +peer_transform_to_endpoint_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - char * string; + char *string; peer = g_value_get_boxed(source_value); if (peer && nm_wireguard_peer_get_endpoint(peer)) { @@ -641,13 +641,13 @@ peer_transform_to_endpoint_string(GBinding * binding, } gboolean -peer_transform_to_preshared_key_string(GBinding * binding, +peer_transform_to_preshared_key_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - char * string; + char *string; peer = g_value_get_boxed(source_value); if (peer && nm_wireguard_peer_get_preshared_key(peer)) { @@ -659,13 +659,13 @@ peer_transform_to_preshared_key_string(GBinding * binding, } gboolean -peer_transform_to_persistent_keepalive_string(GBinding * binding, +peer_transform_to_persistent_keepalive_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - char * string; + char *string; peer = g_value_get_boxed(source_value); if (peer && nm_wireguard_peer_get_persistent_keepalive(peer)) { @@ -677,13 +677,13 @@ peer_transform_to_persistent_keepalive_string(GBinding * binding, } gboolean -peer_transform_from_public_key_string(GBinding * binding, +peer_transform_from_public_key_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - const char * text; + const char *text; text = g_value_get_string(source_value); @@ -700,14 +700,14 @@ peer_transform_from_public_key_string(GBinding * binding, } gboolean -peer_transform_from_allowed_ips_string(GBinding * binding, +peer_transform_from_allowed_ips_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - const char * text; - char ** strv; + const char *text; + char **strv; guint i; text = g_value_get_string(source_value); @@ -730,13 +730,13 @@ peer_transform_from_allowed_ips_string(GBinding * binding, } gboolean -peer_transform_from_endpoint_string(GBinding * binding, +peer_transform_from_endpoint_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - const char * text; + const char *text; text = g_value_get_string(source_value); @@ -753,13 +753,13 @@ peer_transform_from_endpoint_string(GBinding * binding, } gboolean -peer_transform_from_preshared_key_string(GBinding * binding, +peer_transform_from_preshared_key_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - const char * text; + const char *text; text = g_value_get_string(source_value); @@ -777,13 +777,13 @@ peer_transform_from_preshared_key_string(GBinding * binding, } gboolean -peer_transform_from_persistent_keepalive_string(GBinding * binding, +peer_transform_from_persistent_keepalive_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMWireGuardPeer *peer; - const char * text; + const char *text; text = g_value_get_string(source_value); @@ -801,12 +801,12 @@ peer_transform_from_persistent_keepalive_string(GBinding * binding, /* Wireless security method binding */ typedef struct { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; gboolean s_wsec_in_use; GObject *target; - char * target_property; + char *target_property; gboolean updating; } NMEditorWirelessSecurityMethodBinding; @@ -873,7 +873,7 @@ static void wireless_connection_changed(NMConnection *connection, gpointer user_data) { NMEditorWirelessSecurityMethodBinding *binding = user_data; - NMSettingWirelessSecurity * s_wsec; + NMSettingWirelessSecurity *s_wsec; if (binding->updating) return; @@ -890,7 +890,7 @@ static void wireless_security_target_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { NMEditorWirelessSecurityMethodBinding *binding = user_data; - char * method; + char *method; if (binding->updating) return; @@ -1029,14 +1029,14 @@ wireless_security_target_destroyed(gpointer user_data, GObject *ex_target) * changes. */ void -nm_editor_bind_wireless_security_method(NMConnection * connection, +nm_editor_bind_wireless_security_method(NMConnection *connection, NMSettingWirelessSecurity *s_wsec, gpointer target, - const char * target_property, + const char *target_property, GBindingFlags flags) { NMEditorWirelessSecurityMethodBinding *binding; - char * notify; + char *notify; binding = g_slice_new0(NMEditorWirelessSecurityMethodBinding); @@ -1078,8 +1078,8 @@ nm_editor_bind_wireless_security_method(NMConnection * connection, typedef struct { NMSettingWirelessSecurity *s_wsec; - GObject * entry, *key_selector; - char * entry_property, *key_selector_property; + GObject *entry, *key_selector; + char *entry_property, *key_selector_property; gboolean updating; } NMEditorWepKeyBinding; @@ -1088,7 +1088,7 @@ static void wep_key_setting_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { NMEditorWepKeyBinding *binding = user_data; - const char * key; + const char *key; int index; if (binding->updating) @@ -1107,7 +1107,7 @@ static void wep_key_ui_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { NMEditorWepKeyBinding *binding = user_data; - char * key; + char *key; int index; if (binding->updating) @@ -1180,13 +1180,13 @@ wep_key_target_destroyed(gpointer user_data, GObject *ex_target) void nm_editor_bind_wireless_security_wep_key(NMSettingWirelessSecurity *s_wsec, gpointer entry, - const char * entry_property, + const char *entry_property, gpointer key_selector, - const char * key_selector_property, + const char *key_selector_property, GBindingFlags flags) { NMEditorWepKeyBinding *binding; - char * notify; + char *notify; binding = g_slice_new0(NMEditorWepKeyBinding); binding->s_wsec = g_object_ref(s_wsec); @@ -1237,7 +1237,7 @@ nm_editor_bind_wireless_security_wep_key(NMSettingWirelessSecurity *s_wsec, /* VLAN binding */ typedef struct { - NMSettingVlan * s_vlan; + NMSettingVlan *s_vlan; NMSettingConnection *s_con; char *last_ifname_parent; @@ -1250,7 +1250,7 @@ static gboolean parse_interface_name(const char *ifname, char **parent_ifname, int *id) { const char *ifname_end; - char * end; + char *end; if (!ifname || !*ifname) return FALSE; @@ -1280,8 +1280,8 @@ static void vlan_settings_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { NMEditorVlanWidgetBinding *binding = user_data; - const char * ifname, *parent; - char * ifname_parent; + const char *ifname, *parent; + char *ifname_parent; int ifname_id, id; if (binding->updating) @@ -1341,7 +1341,7 @@ void nm_editor_bind_vlan_name(NMSettingVlan *s_vlan, NMSettingConnection *s_con) { NMEditorVlanWidgetBinding *binding; - const char * ifname; + const char *ifname; binding = g_slice_new0(NMEditorVlanWidgetBinding); binding->s_vlan = s_vlan; diff --git a/src/nmtui/nm-editor-bindings.h b/src/nmtui/nm-editor-bindings.h index a9bf51ed0f..ef2f36f2d1 100644 --- a/src/nmtui/nm-editor-bindings.h +++ b/src/nmtui/nm-editor-bindings.h @@ -10,97 +10,97 @@ void nm_editor_bindings_init(void); void nm_editor_bind_ip_addresses_with_prefix_to_strv(int family, gpointer source, - const char * source_property, + const char *source_property, gpointer target, - const char * target_property, + const char *target_property, GBindingFlags flags); void nm_editor_bind_ip_addresses_to_strv(int family, gpointer source, - const char * source_property, + const char *source_property, gpointer target, - const char * target_property, + const char *target_property, GBindingFlags flags); void nm_editor_bind_ip_gateway_to_string(int family, NMSettingIPConfig *source, gpointer target, - const char * target_property, - const char * target_sensitive_property, + const char *target_property, + const char *target_sensitive_property, GBindingFlags flags); void nm_editor_bind_ip_route_to_strings(int family, gpointer source, - const char * source_property, + const char *source_property, gpointer dest_target, - const char * dest_target_property, + const char *dest_target_property, gpointer next_hop_target, - const char * next_hop_target_property, + const char *next_hop_target_property, gpointer metric_target, - const char * metric_target_property, + const char *metric_target_property, GBindingFlags flags); -void nm_editor_bind_wireless_security_method(NMConnection * connection, +void nm_editor_bind_wireless_security_method(NMConnection *connection, NMSettingWirelessSecurity *s_wsec, gpointer target, - const char * target_property, + const char *target_property, GBindingFlags flags); void nm_editor_bind_wireless_security_wep_key(NMSettingWirelessSecurity *s_wsec, gpointer entry, - const char * entry_property, + const char *entry_property, gpointer key_selector, - const char * key_selector_property, + const char *key_selector_property, GBindingFlags flags); void nm_editor_bind_vlan_name(NMSettingVlan *s_vlan, NMSettingConnection *s_con); -gboolean peer_transform_to_public_key_string(GBinding * binding, +gboolean peer_transform_to_public_key_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_to_allowed_ips_string(GBinding * binding, +gboolean peer_transform_to_allowed_ips_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_to_endpoint_string(GBinding * binding, +gboolean peer_transform_to_endpoint_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_to_preshared_key_string(GBinding * binding, +gboolean peer_transform_to_preshared_key_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_to_persistent_keepalive_string(GBinding * binding, +gboolean peer_transform_to_persistent_keepalive_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_from_public_key_string(GBinding * binding, +gboolean peer_transform_from_public_key_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_from_allowed_ips_string(GBinding * binding, +gboolean peer_transform_from_allowed_ips_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_from_endpoint_string(GBinding * binding, +gboolean peer_transform_from_endpoint_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_from_preshared_key_string(GBinding * binding, +gboolean peer_transform_from_preshared_key_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); -gboolean peer_transform_from_persistent_keepalive_string(GBinding * binding, +gboolean peer_transform_from_persistent_keepalive_string(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data); #endif /* NM_EDITOR_BINDINGS_H */ diff --git a/src/nmtui/nm-editor-utils.c b/src/nmtui/nm-editor-utils.c index 2b6acbbe24..a3ee7a75de 100644 --- a/src/nmtui/nm-editor-utils.c +++ b/src/nmtui/nm-editor-utils.c @@ -49,9 +49,9 @@ wifi_connection_setup_func(NMConnection *connection, NMSettingConnection *s_con, static void bond_connection_setup_func(NMConnection *connection, NMSettingConnection *s_con, NMSetting *s_hw) { - NMSettingBond * s_bond = NM_SETTING_BOND(s_hw); + NMSettingBond *s_bond = NM_SETTING_BOND(s_hw); guint i; - const char * value; + const char *value; static const char *const options[] = { NM_SETTING_BOND_OPTION_MODE, NM_SETTING_BOND_OPTION_MIIMON, @@ -67,9 +67,9 @@ bond_connection_setup_func(NMConnection *connection, NMSettingConnection *s_con, } static void -wireguard_connection_setup_func(NMConnection * connection, +wireguard_connection_setup_func(NMConnection *connection, NMSettingConnection *s_con, - NMSetting * s_hw) + NMSetting *s_hw) { NMSettingIPConfig *s_ip; @@ -82,14 +82,14 @@ wireguard_connection_setup_func(NMConnection * connection, nm_connection_add_setting(connection, (NMSetting *) s_ip); } -typedef void (*NMEditorNewConnectionSetupFunc)(NMConnection * connection, +typedef void (*NMEditorNewConnectionSetupFunc)(NMConnection *connection, NMSettingConnection *s_con, - NMSetting * s_hw); + NMSetting *s_hw); typedef struct { NMEditorConnectionTypeData data; - const char * id_format; + const char *id_format; NMEditorNewConnectionSetupFunc connection_setup_func; gboolean no_autoconnect; } NMEditorConnectionTypeDataReal; @@ -127,8 +127,8 @@ sort_types(gconstpointer a, gconstpointer b) NMEditorConnectionTypeData ** nm_editor_utils_get_connection_type_list(void) { - GPtrArray * array; - NMEditorConnectionTypeDataReal * item; + GPtrArray *array; + NMEditorConnectionTypeDataReal *item; static NMEditorConnectionTypeData **list; #if 0 GHashTable *vpn_plugins_hash; @@ -291,8 +291,8 @@ static char * get_available_connection_name(const char *format, NMClient *client) { const GPtrArray *conns; - GSList * names = NULL, *iter; - char * cname = NULL; + GSList *names = NULL, *iter; + char *cname = NULL; int i = 0; nm_assert(_assert_format_int(format)); @@ -308,7 +308,7 @@ get_available_connection_name(const char *format, NMClient *client) /* Find the next available unique connection name */ for (i = 1; !cname && i < 10000; i++) { - char * temp; + char *temp; gboolean found = FALSE; NM_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral") @@ -334,11 +334,11 @@ static char * get_available_iface_name(const char *try_name, NMClient *client) { const GPtrArray *connections; - NMConnection * connection; - char * new_name; + NMConnection *connection; + char *new_name; unsigned num = 1; int i = 0; - const char * ifname = NULL; + const char *ifname = NULL; connections = nm_client_get_connections(client); @@ -374,14 +374,14 @@ get_available_iface_name(const char *try_name, NMClient *client) NMConnection * nm_editor_utils_create_connection(GType type, NMConnection *master, NMClient *client) { - NMEditorConnectionTypeData ** types; + NMEditorConnectionTypeData **types; NMEditorConnectionTypeDataReal *type_data = NULL; - const char * master_setting_type = NULL, *master_uuid = NULL; + const char *master_setting_type = NULL, *master_uuid = NULL; GType master_type = G_TYPE_INVALID, slave_setting_type = G_TYPE_INVALID; - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSetting * s_hw, *s_slave; - char * uuid, *id, *ifname; + NMSetting *s_hw, *s_slave; + char *uuid, *id, *ifname; int i; if (master) { @@ -469,8 +469,8 @@ nm_editor_utils_create_connection(GType type, NMConnection *master, NMClient *cl NMEditorConnectionTypeData * nm_editor_utils_get_connection_type_data(NMConnection *conn) { - NMSettingConnection * s_con; - const char * conn_type; + NMSettingConnection *s_con; + const char *conn_type; GType conn_gtype; NMEditorConnectionTypeData **types; int i; diff --git a/src/nmtui/nm-editor-utils.h b/src/nmtui/nm-editor-utils.h index 5b624f9361..decbc271a2 100644 --- a/src/nmtui/nm-editor-utils.h +++ b/src/nmtui/nm-editor-utils.h @@ -15,7 +15,7 @@ typedef struct { } NMEditorConnectionTypeData; NMEditorConnectionTypeData **nm_editor_utils_get_connection_type_list(void); -NMEditorConnectionTypeData * nm_editor_utils_get_connection_type_data(NMConnection *conn); +NMEditorConnectionTypeData *nm_editor_utils_get_connection_type_data(NMConnection *conn); NMConnection *nm_editor_utils_create_connection(GType type, NMConnection *master, NMClient *client); diff --git a/src/nmtui/nmt-address-list.c b/src/nmtui/nmt-address-list.c index 265457d658..1678f33f50 100644 --- a/src/nmtui/nmt-address-list.c +++ b/src/nmtui/nmt-address-list.c @@ -32,7 +32,7 @@ G_DEFINE_TYPE(NmtAddressList, nmt_address_list, NMT_TYPE_WIDGET_LIST) typedef struct { NmtAddressListType list_type; - char ** strings; + char **strings; } NmtAddressListPrivate; enum { @@ -73,9 +73,9 @@ nmt_address_list_init(NmtAddressList *list) {} static gboolean -strings_transform_to_entry(GBinding * binding, +strings_transform_to_entry(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { int n = GPOINTER_TO_INT(user_data); @@ -90,12 +90,12 @@ strings_transform_to_entry(GBinding * binding, } static gboolean -strings_transform_from_entry(GBinding * binding, +strings_transform_from_entry(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { - NmtAddressList * list = NMT_ADDRESS_LIST(g_binding_get_source(binding)); + NmtAddressList *list = NMT_ADDRESS_LIST(g_binding_get_source(binding)); NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(list); int n = GPOINTER_TO_INT(user_data); @@ -119,7 +119,7 @@ static NmtNewtWidget * nmt_address_list_create_widget(NmtWidgetList *list, int num) { NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(list); - NmtNewtWidget * entry; + NmtNewtWidget *entry; if (priv->list_type == NMT_ADDRESS_LIST_IP4_WITH_PREFIX) entry = nmt_ip_entry_new(25, AF_INET, TRUE, FALSE); @@ -178,10 +178,10 @@ nmt_address_list_remove_clicked(NmtWidgetList *list, int num) } static void -nmt_address_list_set_property(GObject * object, +nmt_address_list_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(object); @@ -223,7 +223,7 @@ nmt_address_list_get_property(GObject *object, guint prop_id, GValue *value, GPa static void nmt_address_list_class_init(NmtAddressListClass *list_class) { - GObjectClass * object_class = G_OBJECT_CLASS(list_class); + GObjectClass *object_class = G_OBJECT_CLASS(list_class); NmtWidgetListClass *widget_list_class = NMT_WIDGET_LIST_CLASS(list_class); g_type_class_add_private(list_class, sizeof(NmtAddressListPrivate)); diff --git a/src/nmtui/nmt-connect-connection-list.c b/src/nmtui/nmt-connect-connection-list.c index 486e14004f..535cf8fd26 100644 --- a/src/nmtui/nmt-connect-connection-list.c +++ b/src/nmtui/nmt-connect-connection-list.c @@ -27,7 +27,7 @@ G_DEFINE_TYPE(NmtConnectConnectionList, nmt_connect_connection_list, NMT_TYPE_NE NmtConnectConnectionListPrivate)) typedef struct { - char * name; + char *name; NMDevice *device; int sort_order; @@ -37,11 +37,11 @@ typedef struct { typedef struct { const char *name; - char * ssid; + char *ssid; - NMConnection * conn; - NMAccessPoint * ap; - NMDevice * device; + NMConnection *conn; + NMAccessPoint *ap; + NMDevice *device; NMActiveConnection *active; } NmtConnectConnection; @@ -124,7 +124,7 @@ static int get_sort_order_for_connection(NMConnection *conn) { NMSettingConnection *s_con; - const char * type; + const char *type; int i; s_con = nm_connection_get_setting_connection(conn); @@ -178,7 +178,7 @@ add_connections_for_device(NmtConnectDevice *nmtdev, const GPtrArray *connection int i; for (i = 0; i < connections->len; i++) { - NMConnection * conn = connections->pdata[i]; + NMConnection *conn = connections->pdata[i]; NMSettingConnection *s_con; s_con = nm_connection_get_setting_connection(conn); @@ -201,7 +201,7 @@ static char * hash_ap(NMAccessPoint *ap) { unsigned char input[66]; - GBytes * ssid; + GBytes *ssid; NM80211Mode mode; guint32 flags; guint32 wpa_flags; @@ -246,12 +246,12 @@ static void add_connections_for_aps(NmtConnectDevice *nmtdev, const GPtrArray *connections) { NmtConnectConnection *nmtconn; - NMConnection * conn; - NMAccessPoint * ap; - const GPtrArray * aps; - GHashTable * seen_ssids; - GBytes * ssid; - char * ap_hash; + NMConnection *conn; + NMAccessPoint *ap; + const GPtrArray *aps; + GHashTable *seen_ssids; + GBytes *ssid; + char *ap_hash; int i, c; aps = nm_device_wifi_get_access_points(NM_DEVICE_WIFI(nmtdev->device)); @@ -301,13 +301,13 @@ add_connections_for_aps(NmtConnectDevice *nmtdev, const GPtrArray *connections) } static GSList * -append_nmt_devices_for_devices(GSList * nmt_devices, +append_nmt_devices_for_devices(GSList *nmt_devices, const GPtrArray *devices, - char ** names, + char **names, const GPtrArray *connections) { NmtConnectDevice *nmtdev; - NMDevice * device; + NMDevice *device; int i, sort_order; for (i = 0; i < devices->len; i++) { @@ -337,11 +337,11 @@ append_nmt_devices_for_devices(GSList * nmt_devices, static GSList * append_nmt_devices_for_virtual_devices(GSList *nmt_devices, const GPtrArray *connections) { - NmtConnectDevice * nmtdev = NULL; + NmtConnectDevice *nmtdev = NULL; int i; - GHashTable * devices_by_name; - char * name; - NMConnection * conn; + GHashTable *devices_by_name; + char *name; + NMConnection *conn; NmtConnectConnection *nmtconn; int sort_order; @@ -381,9 +381,9 @@ append_nmt_devices_for_virtual_devices(GSList *nmt_devices, const GPtrArray *con static GSList * append_nmt_devices_for_vpns(GSList *nmt_devices, const GPtrArray *connections) { - NmtConnectDevice * nmtdev; + NmtConnectDevice *nmtdev; int i; - NMConnection * conn; + NMConnection *conn; NmtConnectConnection *nmtconn; nmtdev = g_slice_new0(NmtConnectDevice); @@ -444,14 +444,14 @@ static void nmt_connect_connection_list_rebuild(NmtConnectConnectionList *list) { NmtConnectConnectionListPrivate *priv = NMT_CONNECT_CONNECTION_LIST_GET_PRIVATE(list); - NmtNewtListbox * listbox = NMT_NEWT_LISTBOX(list); - const GPtrArray * devices, *acs, *connections; + NmtNewtListbox *listbox = NMT_NEWT_LISTBOX(list); + const GPtrArray *devices, *acs, *connections; int max_width; - char ** names, *row, active_col; - const char * strength_col; - GSList * nmt_devices, *diter, *citer; - NmtConnectDevice * nmtdev; - NmtConnectConnection * nmtconn; + char **names, *row, active_col; + const char *strength_col; + GSList *nmt_devices, *diter, *citer; + NmtConnectDevice *nmtdev; + NmtConnectConnection *nmtconn; g_slist_free_full(priv->nmt_devices, (GDestroyNotify) nmt_connect_device_free); priv->nmt_devices = NULL; @@ -599,17 +599,17 @@ nmt_connect_connection_list_class_init(NmtConnectConnectionListClass *list_class */ gboolean nmt_connect_connection_list_get_connection(NmtConnectConnectionList *list, - const char * identifier, - NMConnection ** connection, - NMDevice ** device, - NMObject ** specific_object, - NMActiveConnection ** active) + const char *identifier, + NMConnection **connection, + NMDevice **device, + NMObject **specific_object, + NMActiveConnection **active) { NmtConnectConnectionListPrivate *priv = NMT_CONNECT_CONNECTION_LIST_GET_PRIVATE(list); - GSList * diter, *citer; - NmtConnectDevice * nmtdev; - NmtConnectConnection * nmtconn = NULL; - NMConnection * conn = NULL; + GSList *diter, *citer; + NmtConnectDevice *nmtdev; + NmtConnectConnection *nmtconn = NULL; + NMConnection *conn = NULL; g_return_val_if_fail(identifier, FALSE); @@ -669,10 +669,10 @@ found: */ gboolean nmt_connect_connection_list_get_selection(NmtConnectConnectionList *list, - NMConnection ** connection, - NMDevice ** device, - NMObject ** specific_object, - NMActiveConnection ** active) + NMConnection **connection, + NMDevice **device, + NMObject **specific_object, + NMActiveConnection **active) { NmtConnectConnection *nmtconn; diff --git a/src/nmtui/nmt-connect-connection-list.h b/src/nmtui/nmt-connect-connection-list.h index 15a319b13f..1eea4d049d 100644 --- a/src/nmtui/nmt-connect-connection-list.h +++ b/src/nmtui/nmt-connect-connection-list.h @@ -39,15 +39,15 @@ GType nmt_connect_connection_list_get_type(void); NmtNewtWidget *nmt_connect_connection_list_new(void); gboolean nmt_connect_connection_list_get_connection(NmtConnectConnectionList *list, - const char * identifier, - NMConnection ** connection, - NMDevice ** device, - NMObject ** specific_object, - NMActiveConnection ** active); + const char *identifier, + NMConnection **connection, + NMDevice **device, + NMObject **specific_object, + NMActiveConnection **active); gboolean nmt_connect_connection_list_get_selection(NmtConnectConnectionList *list, - NMConnection ** connection, - NMDevice ** device, - NMObject ** specific_object, - NMActiveConnection ** active); + NMConnection **connection, + NMDevice **device, + NMObject **specific_object, + NMActiveConnection **active); #endif /* NMT_CONNECT_CONNECTION_LIST_H */ diff --git a/src/nmtui/nmt-device-entry.c b/src/nmtui/nmt-device-entry.c index e831f4e474..7f312bd1fc 100644 --- a/src/nmtui/nmt-device-entry.c +++ b/src/nmtui/nmt-device-entry.c @@ -44,8 +44,8 @@ typedef struct { char *interface_name; char *mac_address; - char * label; - NmtNewtEntry * entry; + char *label; + NmtNewtEntry *entry; NmtNewtWidget *button; gboolean updating; @@ -91,13 +91,13 @@ nmt_device_entry_new(const char *label, int width, GType hardware_type) static gboolean device_entry_parse(NmtDeviceEntry *deventry, - const char * text, - char ** interface_name, - char ** mac_address) + const char *text, + char **interface_name, + char **mac_address) { NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE(deventry); guint8 buf[NM_UTILS_HWADDR_LEN_MAX]; - char ** words; + char **words; int len; *interface_name = *mac_address = NULL; @@ -151,7 +151,7 @@ static gboolean device_entry_validate(NmtNewtEntry *entry, const char *text, gpointer user_data) { NmtDeviceEntry *deventry = user_data; - char * ifname, *mac; + char *ifname, *mac; if (!device_entry_parse(deventry, text, &ifname, &mac)) return FALSE; @@ -165,8 +165,8 @@ static NMDevice * find_device_by_interface_name(NmtDeviceEntry *deventry, const char *interface_name) { NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE(deventry); - const GPtrArray * devices; - NMDevice * device = NULL; + const GPtrArray *devices; + NMDevice *device = NULL; int i; devices = nm_client_get_devices(nm_client); @@ -192,14 +192,14 @@ static NMDevice * find_device_by_mac_address(NmtDeviceEntry *deventry, const char *mac_address) { NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE(deventry); - const GPtrArray * devices; - NMDevice * device = NULL; + const GPtrArray *devices; + NMDevice *device = NULL; int i; devices = nm_client_get_devices(nm_client); for (i = 0; i < devices->len && !device; i++) { NMDevice *candidate = devices->pdata[i]; - char * hwaddr; + char *hwaddr; if (priv->hardware_type != G_TYPE_NONE && !G_TYPE_CHECK_INSTANCE_TYPE(candidate, priv->hardware_type)) @@ -222,9 +222,9 @@ static void update_entry(NmtDeviceEntry *deventry) { NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE(deventry); - const char * ifname; - char * mac, *text; - NMDevice * ifname_device, *mac_device; + const char *ifname; + char *mac, *text; + NMDevice *ifname_device, *mac_device; if (priv->interface_name) { ifname = priv->interface_name; @@ -314,8 +314,8 @@ static void entry_text_changed(GObject *object, GParamSpec *pspec, gpointer deventry) { NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE(deventry); - const char * text; - char * ifname, *mac; + const char *text; + char *ifname, *mac; if (priv->updating) return; @@ -335,7 +335,7 @@ static void nmt_device_entry_init(NmtDeviceEntry *deventry) { NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE(deventry); - NmtNewtWidget * entry; + NmtNewtWidget *entry; priv->hardware_type = G_TYPE_NONE; @@ -401,7 +401,7 @@ nmt_device_entry_finalize(GObject *object) * accepted by the filter will be allowed. */ void -nmt_device_entry_set_device_filter(NmtDeviceEntry * deventry, +nmt_device_entry_set_device_filter(NmtDeviceEntry *deventry, NmtDeviceEntryDeviceFilter filter, gpointer user_data) { @@ -412,15 +412,15 @@ nmt_device_entry_set_device_filter(NmtDeviceEntry * deventry, } static void -nmt_device_entry_set_property(GObject * object, +nmt_device_entry_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { - NmtDeviceEntry * deventry = NMT_DEVICE_ENTRY(object); + NmtDeviceEntry *deventry = NMT_DEVICE_ENTRY(object); NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE(deventry); - const char * interface_name; - const char * mac_address; + const char *interface_name; + const char *mac_address; switch (prop_id) { case PROP_LABEL: diff --git a/src/nmtui/nmt-device-entry.h b/src/nmtui/nmt-device-entry.h index 13f82bc809..f66c3d8d6a 100644 --- a/src/nmtui/nmt-device-entry.h +++ b/src/nmtui/nmt-device-entry.h @@ -33,9 +33,9 @@ GType nmt_device_entry_get_type(void); NmtNewtWidget *nmt_device_entry_new(const char *label, int width, GType hardware_type); typedef gboolean (*NmtDeviceEntryDeviceFilter)(NmtDeviceEntry *deventry, - NMDevice * device, + NMDevice *device, gpointer user_data); -void nmt_device_entry_set_device_filter(NmtDeviceEntry * deventry, +void nmt_device_entry_set_device_filter(NmtDeviceEntry *deventry, NmtDeviceEntryDeviceFilter filter, gpointer user_data); diff --git a/src/nmtui/nmt-edit-connection-list.c b/src/nmtui/nmt-edit-connection-list.c index 9b31e06f79..aec669c81b 100644 --- a/src/nmtui/nmt-edit-connection-list.c +++ b/src/nmtui/nmt-edit-connection-list.c @@ -32,7 +32,7 @@ typedef struct { NmtEditConnectionListFilter connection_filter; gpointer connection_filter_data; - NmtNewtListbox * listbox; + NmtNewtListbox *listbox; NmtNewtButtonBox *buttons; NmtNewtWidget *add; @@ -73,8 +73,8 @@ static void nmt_edit_connection_list_init(NmtEditConnectionList *list) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(list); - NmtNewtWidget * listbox, *buttons; - NmtNewtGrid * grid = NMT_NEWT_GRID(list); + NmtNewtWidget *listbox, *buttons; + NmtNewtGrid *grid = NMT_NEWT_GRID(list); listbox = g_object_new(NMT_TYPE_NEWT_LISTBOX, "flags", @@ -135,8 +135,8 @@ static void free_connections(NmtEditConnectionList *list) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(list); - NMConnection * conn; - GSList * iter; + NMConnection *conn; + GSList *iter; for (iter = priv->connections; iter; iter = iter->next) { conn = iter->data; @@ -152,11 +152,11 @@ static void nmt_edit_connection_list_rebuild(NmtEditConnectionList *list) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(list); - const GPtrArray * connections; - GSList * iter; + const GPtrArray *connections; + GSList *iter; gboolean did_header = FALSE, did_vpn = FALSE; - NMEditorConnectionTypeData ** types; - NMConnection * conn, *selected_conn; + NMEditorConnectionTypeData **types; + NMConnection *conn, *selected_conn; int i, row, selected_row; selected_row = nmt_newt_listbox_get_active(priv->listbox); @@ -213,7 +213,7 @@ nmt_edit_connection_list_rebuild(NmtEditConnectionList *list) for (iter = priv->connections; iter; iter = iter->next) { NMSetting *setting; - char * indented; + char *indented; conn = iter->data; setting = nm_connection_get_setting(conn, types[i]->setting_type); @@ -254,7 +254,7 @@ rebuild_on_connections_changed(GObject *object, GParamSpec *pspec, gpointer list static void nmt_edit_connection_list_constructed(GObject *object) { - NmtEditConnectionList * list = NMT_EDIT_CONNECTION_LIST(object); + NmtEditConnectionList *list = NMT_EDIT_CONNECTION_LIST(object); NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(list); if (priv->extra) @@ -280,7 +280,7 @@ static void edit_clicked(NmtNewtButton *button, gpointer list) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(list); - NMConnection * connection; + NMConnection *connection; connection = nmt_newt_listbox_get_active_key(priv->listbox); g_return_if_fail(connection != NULL); @@ -292,7 +292,7 @@ static void delete_clicked(NmtNewtButton *button, gpointer list) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(list); - NMRemoteConnection * connection; + NMRemoteConnection *connection; connection = nmt_newt_listbox_get_active_key(priv->listbox); g_return_if_fail(connection != NULL); @@ -318,8 +318,8 @@ void nmt_edit_connection_list_recommit(NmtEditConnectionList *list) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(list); - NMConnection * conn; - GSList * iter; + NMConnection *conn; + GSList *iter; for (iter = priv->connections; iter; iter = iter->next) { conn = iter->data; @@ -346,10 +346,10 @@ nmt_edit_connection_list_finalize(GObject *object) } static void -nmt_edit_connection_list_set_property(GObject * object, +nmt_edit_connection_list_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(object); @@ -375,14 +375,14 @@ nmt_edit_connection_list_set_property(GObject * object, } static void -nmt_edit_connection_list_get_property(GObject * object, +nmt_edit_connection_list_get_property(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(object); - GPtrArray * connections; - GSList * iter; + GPtrArray *connections; + GSList *iter; switch (prop_id) { case PROP_GROUPED: diff --git a/src/nmtui/nmt-edit-connection-list.h b/src/nmtui/nmt-edit-connection-list.h index 824f767a79..a5375be43b 100644 --- a/src/nmtui/nmt-edit-connection-list.h +++ b/src/nmtui/nmt-edit-connection-list.h @@ -37,7 +37,7 @@ typedef struct { GType nmt_edit_connection_list_get_type(void); typedef gboolean (*NmtEditConnectionListFilter)(NmtEditConnectionList *list, - NMConnection * connection, + NMConnection *connection, gpointer user_data); void nmt_edit_connection_list_recommit(NmtEditConnectionList *list); diff --git a/src/nmtui/nmt-editor-grid.c b/src/nmtui/nmt-editor-grid.c index 8c79e8d967..bb25780559 100644 --- a/src/nmtui/nmt-editor-grid.c +++ b/src/nmtui/nmt-editor-grid.c @@ -35,14 +35,14 @@ G_DEFINE_TYPE(NmtEditorGrid, nmt_editor_grid, NMT_TYPE_NEWT_CONTAINER) typedef struct { GArray *rows; - int * row_heights; + int *row_heights; int indent; } NmtEditorGridPrivate; typedef struct { - NmtNewtWidget * label; - NmtNewtWidget * widget; - NmtNewtWidget * extra; + NmtNewtWidget *label; + NmtNewtWidget *widget; + NmtNewtWidget *extra; NmtEditorGridRowFlags flags; } NmtEditorGridRow; @@ -102,13 +102,13 @@ nmt_editor_grid_finalize(GObject *object) */ void nmt_editor_grid_append(NmtEditorGrid *grid, - const char * label, + const char *label, NmtNewtWidget *widget, NmtNewtWidget *extra) { - NmtEditorGridPrivate * priv = NMT_EDITOR_GRID_GET_PRIVATE(grid); + NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(grid); NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS(nmt_editor_grid_parent_class); - NmtNewtContainer * container = NMT_NEWT_CONTAINER(grid); + NmtNewtContainer *container = NMT_NEWT_CONTAINER(grid); NmtEditorGridRow row; g_return_if_fail(label != NULL || widget != NULL); @@ -147,7 +147,7 @@ static int nmt_editor_grid_find_widget(NmtEditorGrid *grid, NmtNewtWidget *widget) { NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(grid); - NmtEditorGridRow * rows = (NmtEditorGridRow *) priv->rows->data; + NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data; int i; for (i = 0; i < priv->rows->len; i++) { @@ -177,12 +177,12 @@ nmt_editor_grid_find_widget(NmtEditorGrid *grid, NmtNewtWidget *widget) * Sets flags to adjust the layout of @widget's row in @grid. */ void -nmt_editor_grid_set_row_flags(NmtEditorGrid * grid, - NmtNewtWidget * widget, +nmt_editor_grid_set_row_flags(NmtEditorGrid *grid, + NmtNewtWidget *widget, NmtEditorGridRowFlags flags) { NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(grid); - NmtEditorGridRow * rows = (NmtEditorGridRow *) priv->rows->data; + NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data; int i; i = nmt_editor_grid_find_widget(grid, widget); @@ -193,10 +193,10 @@ nmt_editor_grid_set_row_flags(NmtEditorGrid * grid, static void nmt_editor_grid_remove(NmtNewtContainer *container, NmtNewtWidget *widget) { - NmtEditorGrid * grid = NMT_EDITOR_GRID(container); - NmtEditorGridPrivate * priv = NMT_EDITOR_GRID_GET_PRIVATE(grid); + NmtEditorGrid *grid = NMT_EDITOR_GRID(container); + NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(grid); NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS(nmt_editor_grid_parent_class); - NmtEditorGridRow * rows = (NmtEditorGridRow *) priv->rows->data; + NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data; int i; i = nmt_editor_grid_find_widget(grid, widget); @@ -219,9 +219,9 @@ static newtComponent * nmt_editor_grid_get_components(NmtNewtWidget *widget) { NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(widget); - NmtEditorGridRow * rows = (NmtEditorGridRow *) priv->rows->data; - newtComponent * child_cos; - GPtrArray * cos; + NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data; + newtComponent *child_cos; + GPtrArray *cos; int i, c; cos = g_ptr_array_new(); @@ -257,7 +257,7 @@ nmt_editor_grid_get_components(NmtNewtWidget *widget) static NmtEditorGridFormState * get_form_state(NmtNewtWidget *widget) { - NmtNewtForm * form = nmt_newt_widget_get_form(widget); + NmtNewtForm *form = nmt_newt_widget_get_form(widget); NmtEditorGridFormState *state; if (!form) @@ -276,7 +276,7 @@ static void nmt_editor_grid_realize(NmtNewtWidget *widget) { NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(widget); - NmtNewtWidget * parent; + NmtNewtWidget *parent; NMT_NEWT_WIDGET_CLASS(nmt_editor_grid_parent_class)->realize(widget); @@ -307,8 +307,8 @@ nmt_editor_grid_unrealize(NmtNewtWidget *widget) static void nmt_editor_grid_size_request(NmtNewtWidget *widget, int *width, int *height) { - NmtEditorGridPrivate * priv = NMT_EDITOR_GRID_GET_PRIVATE(widget); - NmtEditorGridRow * rows = (NmtEditorGridRow *) priv->rows->data; + NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(widget); + NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data; NmtEditorGridFormState *state = get_form_state(widget); gboolean add_padding = FALSE; int i; @@ -355,8 +355,8 @@ nmt_editor_grid_size_request(NmtNewtWidget *widget, int *width, int *height) static void nmt_editor_grid_size_allocate(NmtNewtWidget *widget, int x, int y, int width, int height) { - NmtEditorGridPrivate * priv = NMT_EDITOR_GRID_GET_PRIVATE(widget); - NmtEditorGridRow * rows = (NmtEditorGridRow *) priv->rows->data; + NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(widget); + NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data; NmtEditorGridFormState *state = get_form_state(widget); int col0_width, col1_width, col2_width; int i, row; @@ -422,8 +422,8 @@ nmt_editor_grid_size_allocate(NmtNewtWidget *widget, int x, int y, int width, in static void nmt_editor_grid_class_init(NmtEditorGridClass *grid_class) { - GObjectClass * object_class = G_OBJECT_CLASS(grid_class); - NmtNewtWidgetClass * widget_class = NMT_NEWT_WIDGET_CLASS(grid_class); + GObjectClass *object_class = G_OBJECT_CLASS(grid_class); + NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(grid_class); NmtNewtContainerClass *container_class = NMT_NEWT_CONTAINER_CLASS(grid_class); g_type_class_add_private(grid_class, sizeof(NmtEditorGridPrivate)); diff --git a/src/nmtui/nmt-editor-grid.h b/src/nmtui/nmt-editor-grid.h index 39a860672d..3a91753688 100644 --- a/src/nmtui/nmt-editor-grid.h +++ b/src/nmtui/nmt-editor-grid.h @@ -38,11 +38,11 @@ typedef enum { NmtNewtWidget *nmt_editor_grid_new(void); void nmt_editor_grid_append(NmtEditorGrid *grid, - const char * label, + const char *label, NmtNewtWidget *widget, NmtNewtWidget *extra); -void nmt_editor_grid_set_row_flags(NmtEditorGrid * grid, - NmtNewtWidget * widget, +void nmt_editor_grid_set_row_flags(NmtEditorGrid *grid, + NmtNewtWidget *widget, NmtEditorGridRowFlags flags); #endif /* NMT_EDITOR_GRID_H */ diff --git a/src/nmtui/nmt-editor-page-device.c b/src/nmtui/nmt-editor-page-device.c index 950f4db12f..57503f47ae 100644 --- a/src/nmtui/nmt-editor-page-device.c +++ b/src/nmtui/nmt-editor-page-device.c @@ -60,10 +60,10 @@ nmt_editor_page_device_get_device_entry(NmtEditorPageDevice *page) } static void -nmt_editor_page_device_set_property(GObject * object, +nmt_editor_page_device_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtEditorPageDevicePrivate *priv = NMT_EDITOR_PAGE_DEVICE_GET_PRIVATE(object); @@ -78,9 +78,9 @@ nmt_editor_page_device_set_property(GObject * object, } static void -nmt_editor_page_device_get_property(GObject * object, +nmt_editor_page_device_get_property(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec) { NmtEditorPageDevicePrivate *priv = NMT_EDITOR_PAGE_DEVICE_GET_PRIVATE(object); diff --git a/src/nmtui/nmt-editor-page.c b/src/nmtui/nmt-editor-page.c index 6d90d71e99..d94b1f0fe9 100644 --- a/src/nmtui/nmt-editor-page.c +++ b/src/nmtui/nmt-editor-page.c @@ -22,7 +22,7 @@ G_DEFINE_ABSTRACT_TYPE(NmtEditorPage, nmt_editor_page, G_TYPE_OBJECT) typedef struct { NMConnection *connection; - GSList * sections; + GSList *sections; } NmtEditorPagePrivate; diff --git a/src/nmtui/nmt-editor-section.c b/src/nmtui/nmt-editor-section.c index 3fbfe7a31d..462d1f89fa 100644 --- a/src/nmtui/nmt-editor-section.c +++ b/src/nmtui/nmt-editor-section.c @@ -22,7 +22,7 @@ G_DEFINE_TYPE(NmtEditorSection, nmt_editor_section, NMT_TYPE_NEWT_SECTION) typedef struct { NmtEditorGrid *header, *body; - char * title; + char *title; NmtNewtWidget *header_widget; NmtNewtWidget *toggle; @@ -156,12 +156,12 @@ nmt_editor_section_get_title(NmtEditorSection *section) } static void -nmt_editor_section_set_property(GObject * object, +nmt_editor_section_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { - NmtEditorSection * section = NMT_EDITOR_SECTION(object); + NmtEditorSection *section = NMT_EDITOR_SECTION(object); NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE(section); switch (prop_id) { diff --git a/src/nmtui/nmt-editor-section.h b/src/nmtui/nmt-editor-section.h index b7baf82165..43e6852b01 100644 --- a/src/nmtui/nmt-editor-section.h +++ b/src/nmtui/nmt-editor-section.h @@ -35,7 +35,7 @@ GType nmt_editor_section_get_type(void); NmtEditorSection * nmt_editor_section_new(const char *title, NmtNewtWidget *header_widget, gboolean show_by_default); -const char * nmt_editor_section_get_title(NmtEditorSection *section); +const char *nmt_editor_section_get_title(NmtEditorSection *section); NmtNewtWidget *nmt_editor_section_get_header_widget(NmtEditorSection *section); NmtEditorGrid *nmt_editor_section_get_body(NmtEditorSection *section); diff --git a/src/nmtui/nmt-editor.c b/src/nmtui/nmt-editor.c index 94e9b7a8c8..8e6a760c1a 100644 --- a/src/nmtui/nmt-editor.c +++ b/src/nmtui/nmt-editor.c @@ -55,7 +55,7 @@ typedef struct { NMEditorConnectionTypeData *type_data; - GSList * pages; + GSList *pages; NmtNewtWidget *ok, *cancel; gboolean running; } NmtEditorPrivate; @@ -128,7 +128,7 @@ static void connection_added(GObject *client, GAsyncResult *result, gpointer op) { NMRemoteConnection *connection; - GError * error = NULL; + GError *error = NULL; connection = nm_client_add_connection_finish(NM_CLIENT(client), result, &error); nmt_sync_op_complete_boolean(op, error == NULL, error); @@ -147,10 +147,10 @@ page_saved(gpointer data, gpointer user_data) static void save_connection_and_exit(NmtNewtButton *button, gpointer user_data) { - NmtEditor * editor = user_data; + NmtEditor *editor = user_data; NmtEditorPrivate *priv = NMT_EDITOR_GET_PRIVATE(editor); NmtSyncOp op; - GError * error = NULL; + GError *error = NULL; nm_connection_replace_settings_from_connection(priv->orig_connection, priv->edit_connection); @@ -195,7 +195,7 @@ static void got_secrets(GObject *object, GAsyncResult *result, gpointer op) { GVariant *secrets; - GError * error = NULL; + GError *error = NULL; secrets = nm_remote_connection_get_secrets_finish(NM_REMOTE_CONNECTION(object), result, &error); if (secrets) @@ -208,9 +208,9 @@ static NMConnection * build_edit_connection(NMConnection *orig_connection) { NMConnection *edit_connection; - GVariant * settings, *secrets; + GVariant *settings, *secrets; GVariantIter iter; - const char * setting_name; + const char *setting_name; NmtSyncOp op; edit_connection = nm_simple_connection_new_clone(orig_connection); @@ -243,9 +243,9 @@ build_edit_connection(NMConnection *orig_connection) } static gboolean -permissions_transform_to_allusers(GBinding * binding, +permissions_transform_to_allusers(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { char **perms = g_value_get_boxed(source_value); @@ -255,13 +255,13 @@ permissions_transform_to_allusers(GBinding * binding, } static gboolean -permissions_transform_from_allusers(GBinding * binding, +permissions_transform_from_allusers(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { gboolean allusers = g_value_get_boolean(source_value); - char ** perms = NULL; + char **perms = NULL; if (!allusers) { perms = g_new(char *, 2); @@ -277,8 +277,8 @@ static NmtNewtWidget * add_sections_for_page(NmtEditor *editor, NmtEditorGrid *grid, NmtEditorPage *page) { NmtEditorPrivate *priv = NMT_EDITOR_GET_PRIVATE(editor); - NmtNewtWidget * first_section = NULL; - const GSList * sections, *iter; + NmtNewtWidget *first_section = NULL; + const GSList *sections, *iter; g_return_val_if_fail(NMT_IS_EDITOR_PAGE(page), NULL); @@ -297,16 +297,16 @@ add_sections_for_page(NmtEditor *editor, NmtEditorGrid *grid, NmtEditorPage *pag static void nmt_editor_constructed(GObject *object) { - NmtEditor * editor = NMT_EDITOR(object); - NmtEditorPrivate * priv = NMT_EDITOR_GET_PRIVATE(editor); + NmtEditor *editor = NMT_EDITOR(object); + NmtEditorPrivate *priv = NMT_EDITOR_GET_PRIVATE(editor); NMSettingConnection *s_con; - NmtNewtWidget * vbox, *widget, *buttons; - NmtEditorGrid * grid; - const char * deventry_label; - NmtDeviceEntry * deventry; + NmtNewtWidget *vbox, *widget, *buttons; + NmtEditorGrid *grid; + const char *deventry_label; + NmtDeviceEntry *deventry; GType hardware_type; - const char * slave_type; - NmtEditorPage * page; + const char *slave_type; + NmtEditorPage *page; if (G_OBJECT_CLASS(nmt_editor_parent_class)->constructed) G_OBJECT_CLASS(nmt_editor_parent_class)->constructed(object); diff --git a/src/nmtui/nmt-ip-entry.c b/src/nmtui/nmt-ip-entry.c index b801eec4c7..9bd0f12ddf 100644 --- a/src/nmtui/nmt-ip-entry.c +++ b/src/nmtui/nmt-ip-entry.c @@ -76,7 +76,7 @@ static gboolean ip_entry_filter(NmtNewtEntry *entry, const char *text, int ch, int position, gpointer user_data) { NmtIPEntryPrivate *priv = NMT_IP_ENTRY_GET_PRIVATE(entry); - const char * slash; + const char *slash; gboolean inaddr; if (g_ascii_isdigit(ch)) diff --git a/src/nmtui/nmt-mac-entry.c b/src/nmtui/nmt-mac-entry.c index 3f71f4c9e4..11ceecf9e9 100644 --- a/src/nmtui/nmt-mac-entry.c +++ b/src/nmtui/nmt-mac-entry.c @@ -85,7 +85,7 @@ static gboolean mac_validator(NmtNewtEntry *entry, const char *text, gpointer user_data) { NmtMacEntryPrivate *priv = NMT_MAC_ENTRY_GET_PRIVATE(entry); - const char * p; + const char *p; if (!*text) return TRUE; diff --git a/src/nmtui/nmt-mtu-entry.c b/src/nmtui/nmt-mtu-entry.c index eab25a23c1..664ee88f57 100644 --- a/src/nmtui/nmt-mtu-entry.c +++ b/src/nmtui/nmt-mtu-entry.c @@ -75,9 +75,9 @@ mtu_validator(NmtNewtEntry *entry, const char *text, gpointer user_data) } static gboolean -mtu_transform_to_text(GBinding * binding, +mtu_transform_to_text(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { int mtu = g_value_get_int(source_value); @@ -93,8 +93,8 @@ static void nmt_mtu_entry_init(NmtMtuEntry *entry) { NmtMtuEntryPrivate *priv = NMT_MTU_ENTRY_GET_PRIVATE(entry); - NmtNewtGrid * grid = NMT_NEWT_GRID(entry); - NmtNewtWidget * real_entry, *label; + NmtNewtGrid *grid = NMT_NEWT_GRID(entry); + NmtNewtWidget *real_entry, *label; real_entry = nmt_newt_entry_numeric_new(10, 0, 65535); priv->entry = NMT_NEWT_ENTRY(real_entry); diff --git a/src/nmtui/nmt-page-bond-port.c b/src/nmtui/nmt-page-bond-port.c index 156553c257..bed8a0f602 100644 --- a/src/nmtui/nmt-page-bond-port.c +++ b/src/nmtui/nmt-page-bond-port.c @@ -29,12 +29,12 @@ nmt_page_bond_port_new(NMConnection *conn) static void nmt_page_bond_port_constructed(GObject *object) { - NmtPageBondPort * bond = NMT_PAGE_BOND_PORT(object); - NmtEditorSection * section; - NmtEditorGrid * grid; + NmtPageBondPort *bond = NMT_PAGE_BOND_PORT(object); + NmtEditorSection *section; + NmtEditorGrid *grid; NMSettingBondPort *s_port; - NmtNewtWidget * widget; - NMConnection * conn; + NmtNewtWidget *widget; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bond)); s_port = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_BOND_PORT); diff --git a/src/nmtui/nmt-page-bond.c b/src/nmtui/nmt-page-bond.c index aea7949ef5..edcf681ecf 100644 --- a/src/nmtui/nmt-page-bond.c +++ b/src/nmtui/nmt-page-bond.c @@ -41,13 +41,13 @@ typedef struct { /* Note: when adding new options to the UI also ensure they are * initialized in bond_connection_setup_func() */ - NmtNewtPopup * mode; - NmtNewtEntry * primary; - NmtNewtPopup * monitoring; - NmtNewtEntry * miimon; - NmtNewtEntry * updelay; - NmtNewtEntry * downdelay; - NmtNewtEntry * arp_interval; + NmtNewtPopup *mode; + NmtNewtEntry *primary; + NmtNewtPopup *monitoring; + NmtNewtEntry *miimon; + NmtNewtEntry *updelay; + NmtNewtEntry *downdelay; + NmtNewtEntry *arp_interval; NmtAddressList *arp_ip_target; NmtPageBondMonitoringMode monitoring_mode; @@ -96,11 +96,11 @@ static NmtNewtPopupEntry bond_monitoring[] = {{N_("MII (recommended)"), "mii"}, static void bond_options_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NMSettingBond * s_bond = NM_SETTING_BOND(object); - NmtPageBond * bond = NMT_PAGE_BOND(user_data); - NmtPageBondPrivate * priv = NMT_PAGE_BOND_GET_PRIVATE(bond); + NMSettingBond *s_bond = NM_SETTING_BOND(object); + NmtPageBond *bond = NMT_PAGE_BOND(user_data); + NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); gs_free const char **ips = NULL; - const char * val; + const char *val; gboolean visible_mii; NMBondMode mode; @@ -161,9 +161,9 @@ bond_options_changed(GObject *object, GParamSpec *pspec, gpointer user_data) static void slaves_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NmtPageBond * bond = NMT_PAGE_BOND(user_data); + NmtPageBond *bond = NMT_PAGE_BOND(user_data); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); - GPtrArray * slaves; + GPtrArray *slaves; g_object_get(object, "connections", &slaves, NULL); if (slaves->len == 0) { @@ -207,9 +207,9 @@ _bond_add_option(NMSettingBond *s_bond, const char *option, const char *value) #define WIDGET_CHANGED_FUNC(widget, func, option, dflt) \ static void widget##_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_data) \ { \ - NmtPageBond * bond = NMT_PAGE_BOND(user_data); \ + NmtPageBond *bond = NMT_PAGE_BOND(user_data); \ NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); \ - const char * v; \ + const char *v; \ \ if (priv->updating) \ return; \ @@ -229,9 +229,9 @@ WIDGET_CHANGED_FUNC(arp_interval, nmt_newt_entry_get_text, NM_SETTING_BOND_OPTIO static void mode_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NmtPageBond * bond = NMT_PAGE_BOND(user_data); + NmtPageBond *bond = NMT_PAGE_BOND(user_data); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); - const char * mode; + const char *mode; if (priv->updating) return; @@ -261,7 +261,7 @@ mode_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_data) static void monitoring_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NmtPageBond * bond = NMT_PAGE_BOND(user_data); + NmtPageBond *bond = NMT_PAGE_BOND(user_data); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); gboolean visible_mii; @@ -290,9 +290,9 @@ monitoring_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_data static void arp_ip_target_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NmtPageBond * bond = NMT_PAGE_BOND(user_data); + NmtPageBond *bond = NMT_PAGE_BOND(user_data); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); - char ** ips, *target; + char **ips, *target; if (priv->updating) return; @@ -311,7 +311,7 @@ arp_ip_target_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_d static gboolean bond_connection_type_filter(GType connection_type, gpointer user_data) { - NmtPageBond * bond = user_data; + NmtPageBond *bond = user_data; NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); if (priv->slave_type != NM_TYPE_SETTING_WIRED && connection_type == NM_TYPE_SETTING_INFINIBAND) @@ -325,14 +325,14 @@ bond_connection_type_filter(GType connection_type, gpointer user_data) static void nmt_page_bond_constructed(GObject *object) { - NmtPageBond * bond = NMT_PAGE_BOND(object); + NmtPageBond *bond = NMT_PAGE_BOND(object); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); - NmtEditorSection * section; - NmtEditorGrid * grid; - NMSettingWired * s_wired; - NMSettingBond * s_bond; - NmtNewtWidget * widget, *label; - NMConnection * conn; + NmtEditorSection *section; + NmtEditorGrid *grid; + NMSettingWired *s_wired; + NMSettingBond *s_bond; + NmtNewtWidget *widget, *label; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bond)); s_bond = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_BOND); @@ -426,7 +426,7 @@ nmt_page_bond_saved(NmtEditorPage *editor_page) static void nmt_page_bond_class_init(NmtPageBondClass *bond_class) { - GObjectClass * object_class = G_OBJECT_CLASS(bond_class); + GObjectClass *object_class = G_OBJECT_CLASS(bond_class); NmtEditorPageClass *editor_page_class = NMT_EDITOR_PAGE_CLASS(bond_class); g_type_class_add_private(bond_class, sizeof(NmtPageBondPrivate)); diff --git a/src/nmtui/nmt-page-bridge-port.c b/src/nmtui/nmt-page-bridge-port.c index f6c18d7c57..e39d15e218 100644 --- a/src/nmtui/nmt-page-bridge-port.c +++ b/src/nmtui/nmt-page-bridge-port.c @@ -29,12 +29,12 @@ nmt_page_bridge_port_init(NmtPageBridgePort *bridge) static void nmt_page_bridge_port_constructed(GObject *object) { - NmtPageBridgePort * bridge = NMT_PAGE_BRIDGE_PORT(object); - NmtEditorSection * section; - NmtEditorGrid * grid; + NmtPageBridgePort *bridge = NMT_PAGE_BRIDGE_PORT(object); + NmtEditorSection *section; + NmtEditorGrid *grid; NMSettingBridgePort *s_port; - NmtNewtWidget * widget; - NMConnection * conn; + NmtNewtWidget *widget; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bridge)); s_port = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_BRIDGE_PORT); diff --git a/src/nmtui/nmt-page-bridge.c b/src/nmtui/nmt-page-bridge.c index 684b17bd35..bc32e2a28c 100644 --- a/src/nmtui/nmt-page-bridge.c +++ b/src/nmtui/nmt-page-bridge.c @@ -45,13 +45,13 @@ bridge_connection_type_filter(GType connection_type, gpointer user_data) static void nmt_page_bridge_constructed(GObject *object) { - NmtPageBridge * bridge = NMT_PAGE_BRIDGE(object); + NmtPageBridge *bridge = NMT_PAGE_BRIDGE(object); NmtPageBridgePrivate *priv = NMT_PAGE_BRIDGE_GET_PRIVATE(bridge); - NmtEditorSection * section; - NmtEditorGrid * grid; - NMSettingBridge * s_bridge; - NmtNewtWidget * widget, *label, *stp; - NMConnection * conn; + NmtEditorSection *section; + NmtEditorGrid *grid; + NMSettingBridge *s_bridge; + NmtNewtWidget *widget, *label, *stp; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bridge)); s_bridge = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_BRIDGE); @@ -171,7 +171,7 @@ nmt_page_bridge_saved(NmtEditorPage *editor_page) static void nmt_page_bridge_class_init(NmtPageBridgeClass *bridge_class) { - GObjectClass * object_class = G_OBJECT_CLASS(bridge_class); + GObjectClass *object_class = G_OBJECT_CLASS(bridge_class); NmtEditorPageClass *editor_page_class = NMT_EDITOR_PAGE_CLASS(bridge_class); object_class->constructed = nmt_page_bridge_constructed; diff --git a/src/nmtui/nmt-page-dsl.c b/src/nmtui/nmt-page-dsl.c index a0d8cdf446..5fa756cc2c 100644 --- a/src/nmtui/nmt-page-dsl.c +++ b/src/nmtui/nmt-page-dsl.c @@ -41,8 +41,8 @@ static NmtEditorSection * build_dsl_section(NmtPageDsl *dsl, NMSettingPppoe *s_pppoe) { NmtEditorSection *section; - NmtEditorGrid * grid; - NmtNewtWidget * widget; + NmtEditorGrid *grid; + NmtNewtWidget *widget; section = nmt_editor_section_new(_("DSL"), NULL, TRUE); grid = nmt_editor_section_get_body(section); @@ -77,12 +77,12 @@ build_dsl_section(NmtPageDsl *dsl, NMSettingPppoe *s_pppoe) static void nmt_page_dsl_constructed(GObject *object) { - NmtPageDsl * dsl = NMT_PAGE_DSL(object); + NmtPageDsl *dsl = NMT_PAGE_DSL(object); NmtPageDslPrivate *priv = NMT_PAGE_DSL_GET_PRIVATE(dsl); - NMConnection * conn; - NMSettingPppoe * s_pppoe; - NmtEditorSection * section; - const GSList * sections, *iter; + NMConnection *conn; + NMSettingPppoe *s_pppoe; + NmtEditorSection *section; + const GSList *sections, *iter; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(dsl)); s_pppoe = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_PPPOE); @@ -108,7 +108,7 @@ nmt_page_dsl_constructed(GObject *object) static void nmt_page_dsl_finalize(GObject *object) { - NmtPageDsl * dsl = NMT_PAGE_DSL(object); + NmtPageDsl *dsl = NMT_PAGE_DSL(object); NmtPageDslPrivate *priv = NMT_PAGE_DSL_GET_PRIVATE(dsl); g_clear_object(&priv->ethernet_page); diff --git a/src/nmtui/nmt-page-ethernet.c b/src/nmtui/nmt-page-ethernet.c index addbd3f390..89026d0f6a 100644 --- a/src/nmtui/nmt-page-ethernet.c +++ b/src/nmtui/nmt-page-ethernet.c @@ -34,13 +34,13 @@ nmt_page_ethernet_init(NmtPageEthernet *ethernet) static void nmt_page_ethernet_constructed(GObject *object) { - NmtPageEthernet * ethernet = NMT_PAGE_ETHERNET(object); - NmtDeviceEntry * deventry; + NmtPageEthernet *ethernet = NMT_PAGE_ETHERNET(object); + NmtDeviceEntry *deventry; NmtEditorSection *section; - NmtEditorGrid * grid; - NMSettingWired * s_wired; - NmtNewtWidget * widget; - NMConnection * conn; + NmtEditorGrid *grid; + NMSettingWired *s_wired; + NmtNewtWidget *widget; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ethernet)); s_wired = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIRED); diff --git a/src/nmtui/nmt-page-infiniband.c b/src/nmtui/nmt-page-infiniband.c index 1216208f09..b292c751bc 100644 --- a/src/nmtui/nmt-page-infiniband.c +++ b/src/nmtui/nmt-page-infiniband.c @@ -39,13 +39,13 @@ static NmtNewtPopupEntry transport_mode[] = {{N_("Datagram"), "datagram"}, static void nmt_page_infiniband_constructed(GObject *object) { - NmtPageInfiniband * infiniband = NMT_PAGE_INFINIBAND(object); - NmtDeviceEntry * deventry; - NmtEditorSection * section; - NmtEditorGrid * grid; + NmtPageInfiniband *infiniband = NMT_PAGE_INFINIBAND(object); + NmtDeviceEntry *deventry; + NmtEditorSection *section; + NmtEditorGrid *grid; NMSettingInfiniband *s_ib; - NmtNewtWidget * widget; - NMConnection * conn; + NmtNewtWidget *widget; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(infiniband)); s_ib = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_INFINIBAND); diff --git a/src/nmtui/nmt-page-ip-tunnel.c b/src/nmtui/nmt-page-ip-tunnel.c index 96864919c8..c74037b628 100644 --- a/src/nmtui/nmt-page-ip-tunnel.c +++ b/src/nmtui/nmt-page-ip-tunnel.c @@ -43,8 +43,8 @@ nmt_page_ip_tunnel_init(NmtPageIPTunnel *ip_tunnel) static void mode_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NMSettingIPTunnel * s_ip_tunnel = NM_SETTING_IP_TUNNEL(object); - NmtPageIPTunnel * ip_tunnel = NMT_PAGE_IP_TUNNEL(user_data); + NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL(object); + NmtPageIPTunnel *ip_tunnel = NMT_PAGE_IP_TUNNEL(user_data); NmtPageIPTunnelPrivate *priv = NMT_PAGE_IP_TUNNEL_GET_PRIVATE(ip_tunnel); NMIPTunnelMode mode; gboolean enable_keys; @@ -93,14 +93,14 @@ add_offset(GBinding *binding, const GValue *from_value, GValue *to_value, gpoint static void nmt_page_ip_tunnel_constructed(GObject *object) { - NmtPageIPTunnel * ip_tunnel = NMT_PAGE_IP_TUNNEL(object); + NmtPageIPTunnel *ip_tunnel = NMT_PAGE_IP_TUNNEL(object); NmtPageIPTunnelPrivate *priv = NMT_PAGE_IP_TUNNEL_GET_PRIVATE(ip_tunnel); - NmtEditorSection * section; - NmtEditorGrid * grid; - NMSettingIPTunnel * s_ip_tunnel; - NmtNewtWidget * widget, *parent; - NMConnection * conn; - GClosure * s2w, *w2s; + NmtEditorSection *section; + NmtEditorGrid *grid; + NMSettingIPTunnel *s_ip_tunnel; + NmtNewtWidget *widget, *parent; + NMConnection *conn; + GClosure *s2w, *w2s; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ip_tunnel)); s_ip_tunnel = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_IP_TUNNEL); diff --git a/src/nmtui/nmt-page-ip4.c b/src/nmtui/nmt-page-ip4.c index a7e4bdae74..4d01b35662 100644 --- a/src/nmtui/nmt-page-ip4.c +++ b/src/nmtui/nmt-page-ip4.c @@ -44,7 +44,7 @@ nmt_page_ip4_init(NmtPageIP4 *ip4) static void edit_routes(NmtNewtButton *button, gpointer user_data) { - NMSetting * s_ip4 = user_data; + NMSetting *s_ip4 = user_data; NmtNewtForm *form; form = nmt_route_editor_new(s_ip4); @@ -53,13 +53,13 @@ edit_routes(NmtNewtButton *button, gpointer user_data) } static gboolean -ip4_routes_transform_to_description(GBinding * binding, +ip4_routes_transform_to_description(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { GPtrArray *routes; - char * text; + char *text; routes = g_value_get_boxed(source_value); if (!routes || !routes->len) @@ -77,13 +77,13 @@ ip4_routes_transform_to_description(GBinding * binding, static void nmt_page_ip4_constructed(GObject *object) { - NmtPageIP4 * ip4 = NMT_PAGE_IP4(object); + NmtPageIP4 *ip4 = NMT_PAGE_IP4(object); gboolean show_by_default; - NmtEditorSection * section; - NmtEditorGrid * grid; + NmtEditorSection *section; + NmtEditorGrid *grid; NMSettingIPConfig *s_ip4; - NmtNewtWidget * widget, *button; - NMConnection * conn; + NmtNewtWidget *widget, *button; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ip4)); s_ip4 = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_IP4_CONFIG); diff --git a/src/nmtui/nmt-page-ip6.c b/src/nmtui/nmt-page-ip6.c index 0d4de65a60..7e7a48c54b 100644 --- a/src/nmtui/nmt-page-ip6.c +++ b/src/nmtui/nmt-page-ip6.c @@ -45,7 +45,7 @@ nmt_page_ip6_init(NmtPageIP6 *ip6) static void edit_routes(NmtNewtButton *button, gpointer user_data) { - NMSetting * s_ip6 = user_data; + NMSetting *s_ip6 = user_data; NmtNewtForm *form; form = nmt_route_editor_new(s_ip6); @@ -54,13 +54,13 @@ edit_routes(NmtNewtButton *button, gpointer user_data) } static gboolean -ip6_routes_transform_to_description(GBinding * binding, +ip6_routes_transform_to_description(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { GPtrArray *routes; - char * text; + char *text; routes = g_value_get_boxed(source_value); if (!routes || !routes->len) @@ -78,13 +78,13 @@ ip6_routes_transform_to_description(GBinding * binding, static void nmt_page_ip6_constructed(GObject *object) { - NmtPageIP6 * ip6 = NMT_PAGE_IP6(object); + NmtPageIP6 *ip6 = NMT_PAGE_IP6(object); gboolean show_by_default; - NmtEditorSection * section; - NmtEditorGrid * grid; + NmtEditorSection *section; + NmtEditorGrid *grid; NMSettingIPConfig *s_ip6; - NmtNewtWidget * widget, *button; - NMConnection * conn; + NmtNewtWidget *widget, *button; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ip6)); s_ip6 = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_IP6_CONFIG); diff --git a/src/nmtui/nmt-page-ppp.c b/src/nmtui/nmt-page-ppp.c index ffa1a8b20b..6f844fd664 100644 --- a/src/nmtui/nmt-page-ppp.c +++ b/src/nmtui/nmt-page-ppp.c @@ -37,9 +37,9 @@ nmt_page_ppp_init(NmtPagePpp *ppp) {} static gboolean -transform_lcp_echo_properties_to_checkbox(GBinding * binding, +transform_lcp_echo_properties_to_checkbox(GBinding *binding, const GValue *from_value, - GValue * to_value, + GValue *to_value, gpointer user_data) { NMSettingPpp *s_ppp = NM_SETTING_PPP(g_binding_get_source(binding)); @@ -54,12 +54,12 @@ transform_lcp_echo_properties_to_checkbox(GBinding * binding, } static gboolean -transform_checkbox_to_lcp_echo_interval(GBinding * binding, +transform_checkbox_to_lcp_echo_interval(GBinding *binding, const GValue *from_value, - GValue * to_value, + GValue *to_value, gpointer user_data) { - NmtPagePpp * ppp = user_data; + NmtPagePpp *ppp = user_data; NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE(ppp); if (g_value_get_boolean(from_value)) @@ -71,12 +71,12 @@ transform_checkbox_to_lcp_echo_interval(GBinding * binding, } static gboolean -transform_checkbox_to_lcp_echo_failure(GBinding * binding, +transform_checkbox_to_lcp_echo_failure(GBinding *binding, const GValue *from_value, - GValue * to_value, + GValue *to_value, gpointer user_data) { - NmtPagePpp * ppp = user_data; + NmtPagePpp *ppp = user_data; NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE(ppp); if (g_value_get_boolean(from_value)) @@ -90,15 +90,15 @@ transform_checkbox_to_lcp_echo_failure(GBinding * binding, static void nmt_page_ppp_constructed(GObject *object) { - NmtPagePpp * ppp = NMT_PAGE_PPP(object); + NmtPagePpp *ppp = NMT_PAGE_PPP(object); NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE(ppp); - NmtEditorSection * section; - NmtEditorGrid * grid; - NMSettingPpp * s_ppp; - NmtNewtWidget * widget, *use_mppe; - NmtNewtGrid * auth_grid, *mppe_grid; - NmtNewtSection * auth_section, *mppe_section; - NMConnection * conn; + NmtEditorSection *section; + NmtEditorGrid *grid; + NMSettingPpp *s_ppp; + NmtNewtWidget *widget, *use_mppe; + NmtNewtGrid *auth_grid, *mppe_grid; + NmtNewtSection *auth_section, *mppe_section; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ppp)); s_ppp = nm_connection_get_setting_ppp(conn); diff --git a/src/nmtui/nmt-page-team-port.c b/src/nmtui/nmt-page-team-port.c index c1f3cbc6d0..af401fa6b5 100644 --- a/src/nmtui/nmt-page-team-port.c +++ b/src/nmtui/nmt-page-team-port.c @@ -37,10 +37,10 @@ nmt_page_team_port_init(NmtPageTeamPort *team) static void edit_clicked(NmtNewtButton *button, gpointer user_data) { - NmtPageTeamPort * team = user_data; + NmtPageTeamPort *team = user_data; NmtPageTeamPortPrivate *priv = NMT_PAGE_TEAM_PORT_GET_PRIVATE(team); - const char * config; - char * new_config; + const char *config; + char *new_config; config = nm_setting_team_port_get_config(priv->s_port); if (!config) @@ -57,13 +57,13 @@ edit_clicked(NmtNewtButton *button, gpointer user_data) static void nmt_page_team_port_constructed(GObject *object) { - NmtPageTeamPort * team = NMT_PAGE_TEAM_PORT(object); + NmtPageTeamPort *team = NMT_PAGE_TEAM_PORT(object); NmtPageTeamPortPrivate *priv = NMT_PAGE_TEAM_PORT_GET_PRIVATE(team); - NmtEditorSection * section; - NmtNewtGrid * grid; - NMSettingTeamPort * s_port; - NmtNewtWidget * widget; - NMConnection * conn; + NmtEditorSection *section; + NmtNewtGrid *grid; + NMSettingTeamPort *s_port; + NmtNewtWidget *widget; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(team)); s_port = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_TEAM_PORT); diff --git a/src/nmtui/nmt-page-team.c b/src/nmtui/nmt-page-team.c index d61c06c529..1a554aada1 100644 --- a/src/nmtui/nmt-page-team.c +++ b/src/nmtui/nmt-page-team.c @@ -45,9 +45,9 @@ nmt_page_team_init(NmtPageTeam *team) static void slaves_changed(GObject *object, GParamSpec *pspec, gpointer user_data) { - NmtPageTeam * team = NMT_PAGE_TEAM(user_data); + NmtPageTeam *team = NMT_PAGE_TEAM(user_data); NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE(team); - GPtrArray * slaves; + GPtrArray *slaves; g_object_get(object, "connections", &slaves, NULL); if (slaves->len == 0) { @@ -65,7 +65,7 @@ slaves_changed(GObject *object, GParamSpec *pspec, gpointer user_data) static gboolean team_connection_type_filter(GType connection_type, gpointer user_data) { - NmtPageTeam * team = user_data; + NmtPageTeam *team = user_data; NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE(team); if (priv->slave_type != NM_TYPE_SETTING_WIRED) { @@ -84,10 +84,10 @@ team_connection_type_filter(GType connection_type, gpointer user_data) static void edit_clicked(NmtNewtButton *button, gpointer user_data) { - NmtPageTeam * team = user_data; + NmtPageTeam *team = user_data; NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE(team); - const char * config; - char * new_config; + const char *config; + char *new_config; config = nm_setting_team_get_config(priv->s_team); if (!config) @@ -104,13 +104,13 @@ edit_clicked(NmtNewtButton *button, gpointer user_data) static void nmt_page_team_constructed(GObject *object) { - NmtPageTeam * team = NMT_PAGE_TEAM(object); + NmtPageTeam *team = NMT_PAGE_TEAM(object); NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE(team); - NmtEditorSection * section; - NmtNewtGrid * grid; - NMSettingTeam * s_team; - NmtNewtWidget * widget; - NMConnection * conn; + NmtEditorSection *section; + NmtNewtGrid *grid; + NMSettingTeam *s_team; + NmtNewtWidget *widget; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(team)); s_team = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_TEAM); @@ -162,7 +162,7 @@ nmt_page_team_saved(NmtEditorPage *editor_page) static void nmt_page_team_class_init(NmtPageTeamClass *team_class) { - GObjectClass * object_class = G_OBJECT_CLASS(team_class); + GObjectClass *object_class = G_OBJECT_CLASS(team_class); NmtEditorPageClass *editor_page_class = NMT_EDITOR_PAGE_CLASS(team_class); g_type_class_add_private(team_class, sizeof(NmtPageTeamPrivate)); diff --git a/src/nmtui/nmt-page-vlan.c b/src/nmtui/nmt-page-vlan.c index 5baf9756a4..1956d3d64a 100644 --- a/src/nmtui/nmt-page-vlan.c +++ b/src/nmtui/nmt-page-vlan.c @@ -42,13 +42,13 @@ vlan_device_filter(NmtDeviceEntry *deventry, NMDevice *device, gpointer user_dat static void nmt_page_vlan_constructed(GObject *object) { - NmtPageVlan * vlan = NMT_PAGE_VLAN(object); + NmtPageVlan *vlan = NMT_PAGE_VLAN(object); NmtEditorSection *section; - NmtEditorGrid * grid; - NMSettingWired * s_wired; - NMSettingVlan * s_vlan; - NmtNewtWidget * widget, *parent, *id_entry; - NMConnection * conn; + NmtEditorGrid *grid; + NMSettingWired *s_wired; + NMSettingVlan *s_vlan; + NmtNewtWidget *widget, *parent, *id_entry; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(vlan)); s_vlan = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_VLAN); diff --git a/src/nmtui/nmt-page-wifi.c b/src/nmtui/nmt-page-wifi.c index 1a476b0210..60960e6409 100644 --- a/src/nmtui/nmt-page-wifi.c +++ b/src/nmtui/nmt-page-wifi.c @@ -80,9 +80,9 @@ static NmtNewtPopupEntry wep_auth[] = {{N_("Open System"), "open"}, {NULL, NULL}}; static gboolean -mode_transform_to_band_visibility(GBinding * binding, +mode_transform_to_band_visibility(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { if (!g_strcmp0(g_value_get_string(source_value), NM_SETTING_WIRELESS_MODE_INFRA)) @@ -93,9 +93,9 @@ mode_transform_to_band_visibility(GBinding * binding, } static gboolean -band_transform_to_channel_visibility(GBinding * binding, +band_transform_to_channel_visibility(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { g_value_set_boolean(target_value, g_value_get_string(source_value) != NULL); @@ -103,13 +103,13 @@ band_transform_to_channel_visibility(GBinding * binding, } static gboolean -ssid_transform_to_entry(GBinding * binding, +ssid_transform_to_entry(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { GBytes *ssid; - char * utf8; + char *utf8; ssid = g_value_get_boxed(source_value); if (ssid) @@ -121,15 +121,15 @@ ssid_transform_to_entry(GBinding * binding, } static gboolean -ssid_transform_from_entry(GBinding * binding, +ssid_transform_from_entry(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { NMSettingWireless *s_wireless = user_data; - const char * text; - GBytes * old_ssid, *ssid; - char * utf8; + const char *text; + GBytes *old_ssid, *ssid; + char *utf8; text = g_value_get_string(source_value); @@ -153,17 +153,17 @@ ssid_transform_from_entry(GBinding * binding, static void nmt_page_wifi_constructed(GObject *object) { - NmtPageWifiPrivate * priv = NMT_PAGE_WIFI_GET_PRIVATE(object); - NmtPageWifi * wifi = NMT_PAGE_WIFI(object); - NmtDeviceEntry * deventry; - NmtEditorSection * section; - NmtEditorGrid * grid; - NMSettingWireless * s_wireless; + NmtPageWifiPrivate *priv = NMT_PAGE_WIFI_GET_PRIVATE(object); + NmtPageWifi *wifi = NMT_PAGE_WIFI(object); + NmtDeviceEntry *deventry; + NmtEditorSection *section; + NmtEditorGrid *grid; + NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; - NmtNewtWidget * widget, *hbox, *subgrid; - NmtNewtWidget * mode, *band, *security, *entry; - NmtNewtStack * stack; - NMConnection * conn; + NmtNewtWidget *widget, *hbox, *subgrid; + NmtNewtWidget *mode, *band, *security, *entry; + NmtNewtStack *stack; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(wifi)); s_wireless = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIRELESS); diff --git a/src/nmtui/nmt-page-wireguard.c b/src/nmtui/nmt-page-wireguard.c index 30a984e013..77e327b88c 100644 --- a/src/nmtui/nmt-page-wireguard.c +++ b/src/nmtui/nmt-page-wireguard.c @@ -43,13 +43,13 @@ nmt_page_wireguard_init(NmtPageWireGuard *wireguard) static void nmt_page_wireguard_constructed(GObject *object) { - NmtPageWireGuard * wireguard = NMT_PAGE_WIREGUARD(object); + NmtPageWireGuard *wireguard = NMT_PAGE_WIREGUARD(object); NmtPageWireGuardPrivate *priv = NMT_PAGE_WIREGUARD_GET_PRIVATE(wireguard); - NmtEditorSection * section; - NmtEditorGrid * grid; - NMSettingWireGuard * s_wireguard; - NmtNewtWidget * widget; - NMConnection * conn; + NmtEditorSection *section; + NmtEditorGrid *grid; + NMSettingWireGuard *s_wireguard; + NmtNewtWidget *widget; + NMConnection *conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(wireguard)); s_wireguard = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIREGUARD); diff --git a/src/nmtui/nmt-password-dialog.c b/src/nmtui/nmt-password-dialog.c index 99b9b3f785..6189997f27 100644 --- a/src/nmtui/nmt-password-dialog.c +++ b/src/nmtui/nmt-password-dialog.c @@ -23,8 +23,8 @@ G_DEFINE_TYPE(NmtPasswordDialog, nmt_password_dialog, NMT_TYPE_NEWT_FORM) (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_PASSWORD_DIALOG, NmtPasswordDialogPrivate)) typedef struct { - char * request_id; - char * prompt; + char *request_id; + char *prompt; GPtrArray *secrets; GPtrArray *entries; @@ -60,7 +60,7 @@ NmtNewtForm * nmt_password_dialog_new(const char *request_id, const char *title, const char *prompt, - GPtrArray * secrets) + GPtrArray *secrets) { return g_object_new(NMT_TYPE_PASSWORD_DIALOG, "request-id", @@ -111,11 +111,11 @@ maybe_save_input_and_exit(NmtNewtWidget *widget, gpointer dialog) static void nmt_password_dialog_constructed(GObject *object) { - NmtPasswordDialog * dialog = NMT_PASSWORD_DIALOG(object); + NmtPasswordDialog *dialog = NMT_PASSWORD_DIALOG(object); NmtPasswordDialogPrivate *priv = NMT_PASSWORD_DIALOG_GET_PRIVATE(dialog); - NmtNewtWidget * widget; - NmtNewtGrid * grid, *secret_grid; - NmtNewtButtonBox * bbox; + NmtNewtWidget *widget; + NmtNewtGrid *grid, *secret_grid; + NmtNewtButtonBox *bbox; int i; widget = nmt_newt_grid_new(); @@ -187,10 +187,10 @@ nmt_password_dialog_finalize(GObject *object) } static void -nmt_password_dialog_set_property(GObject * object, +nmt_password_dialog_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtPasswordDialogPrivate *priv = NMT_PASSWORD_DIALOG_GET_PRIVATE(object); diff --git a/src/nmtui/nmt-password-dialog.h b/src/nmtui/nmt-password-dialog.h index 77e8f292cc..4c60e33d99 100644 --- a/src/nmtui/nmt-password-dialog.h +++ b/src/nmtui/nmt-password-dialog.h @@ -34,11 +34,11 @@ GType nmt_password_dialog_get_type(void); NmtNewtForm *nmt_password_dialog_new(const char *request_id, const char *title, const char *prompt, - GPtrArray * secrets); + GPtrArray *secrets); gboolean nmt_password_dialog_succeeded(NmtPasswordDialog *dialog); const char *nmt_password_dialog_get_request_id(NmtPasswordDialog *dialog); -GPtrArray * nmt_password_dialog_get_secrets(NmtPasswordDialog *dialog); +GPtrArray *nmt_password_dialog_get_secrets(NmtPasswordDialog *dialog); #endif /* NMT_PASSWORD_DIALOG_H */ diff --git a/src/nmtui/nmt-password-fields.c b/src/nmtui/nmt-password-fields.c index 45073c7e47..09573c727f 100644 --- a/src/nmtui/nmt-password-fields.c +++ b/src/nmtui/nmt-password-fields.c @@ -24,7 +24,7 @@ G_DEFINE_TYPE(NmtPasswordFields, nmt_password_fields, NMT_TYPE_NEWT_GRID) typedef struct { NmtPasswordFieldsExtras extras; - NmtNewtEntry * entry; + NmtNewtEntry *entry; NmtNewtCheckbox *always_ask; NmtNewtCheckbox *show_password; @@ -113,7 +113,7 @@ static void nmt_password_fields_constructed(GObject *object) { NmtPasswordFieldsPrivate *priv = NMT_PASSWORD_FIELDS_GET_PRIVATE(object); - NmtNewtGrid * grid = NMT_NEWT_GRID(object); + NmtNewtGrid *grid = NMT_NEWT_GRID(object); nmt_newt_grid_add(grid, NMT_NEWT_WIDGET(priv->entry), 0, 0); @@ -169,12 +169,12 @@ nmt_password_fields_finalize(GObject *object) } static void -nmt_password_fields_set_property(GObject * object, +nmt_password_fields_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { - NmtPasswordFields * fields = NMT_PASSWORD_FIELDS(object); + NmtPasswordFields *fields = NMT_PASSWORD_FIELDS(object); NmtPasswordFieldsPrivate *priv = NMT_PASSWORD_FIELDS_GET_PRIVATE(fields); switch (prop_id) { @@ -205,7 +205,7 @@ nmt_password_fields_set_property(GObject * object, static void nmt_password_fields_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NmtPasswordFields * entry = NMT_PASSWORD_FIELDS(object); + NmtPasswordFields *entry = NMT_PASSWORD_FIELDS(object); NmtPasswordFieldsPrivate *priv = NMT_PASSWORD_FIELDS_GET_PRIVATE(entry); switch (prop_id) { diff --git a/src/nmtui/nmt-route-editor.c b/src/nmtui/nmt-route-editor.c index ffccf38d2d..52272310a5 100644 --- a/src/nmtui/nmt-route-editor.c +++ b/src/nmtui/nmt-route-editor.c @@ -56,9 +56,9 @@ nmt_route_editor_init(NmtRouteEditor *entry) static void save_routes_and_exit(NmtNewtButton *button, gpointer user_data) { - NmtRouteEditor * editor = user_data; + NmtRouteEditor *editor = user_data; NmtRouteEditorPrivate *priv = NMT_ROUTE_EDITOR_GET_PRIVATE(editor); - GPtrArray * routes; + GPtrArray *routes; g_object_get(priv->edit_setting, NM_SETTING_IP_CONFIG_ROUTES, &routes, NULL); g_object_set(priv->orig_setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL); @@ -70,9 +70,9 @@ save_routes_and_exit(NmtNewtButton *button, gpointer user_data) static void nmt_route_editor_constructed(GObject *object) { - NmtRouteEditor * editor = NMT_ROUTE_EDITOR(object); + NmtRouteEditor *editor = NMT_ROUTE_EDITOR(object); NmtRouteEditorPrivate *priv = NMT_ROUTE_EDITOR_GET_PRIVATE(editor); - NmtNewtWidget * vbox, *routes, *buttons, *ok, *cancel; + NmtNewtWidget *vbox, *routes, *buttons, *ok, *cancel; if (G_OBJECT_CLASS(nmt_route_editor_parent_class)->constructed) G_OBJECT_CLASS(nmt_route_editor_parent_class)->constructed(object); @@ -123,10 +123,10 @@ nmt_route_editor_finalize(GObject *object) } static void -nmt_route_editor_set_property(GObject * object, +nmt_route_editor_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtRouteEditorPrivate *priv = NMT_ROUTE_EDITOR_GET_PRIVATE(object); diff --git a/src/nmtui/nmt-route-entry.c b/src/nmtui/nmt-route-entry.c index 5cd150b087..e186fff23c 100644 --- a/src/nmtui/nmt-route-entry.c +++ b/src/nmtui/nmt-route-entry.c @@ -75,9 +75,9 @@ nmt_route_entry_init(NmtRouteEntry *entry) {} static gboolean -entry_validity_transform_to_warning_label(GBinding * binding, +entry_validity_transform_to_warning_label(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { if (g_value_get_boolean(source_value)) @@ -109,8 +109,8 @@ static void nmt_route_entry_constructed(GObject *object) { NmtRouteEntryPrivate *priv = NMT_ROUTE_ENTRY_GET_PRIVATE(object); - NmtNewtGrid * grid = NMT_NEWT_GRID(object); - NmtNewtWidget * warning_label; + NmtNewtGrid *grid = NMT_NEWT_GRID(object); + NmtNewtWidget *warning_label; priv->dest = nmt_ip_entry_new(priv->ip_entry_width, priv->family, TRUE, FALSE); priv->next_hop = nmt_ip_entry_new(priv->ip_entry_width, priv->family, FALSE, TRUE); @@ -213,7 +213,7 @@ nmt_route_entry_get_property(GObject *object, guint prop_id, GValue *value, GPar static void nmt_route_entry_class_init(NmtRouteEntryClass *entry_class) { - GObjectClass * object_class = G_OBJECT_CLASS(entry_class); + GObjectClass *object_class = G_OBJECT_CLASS(entry_class); NmtNewtWidgetClass *widget_class = NMT_NEWT_WIDGET_CLASS(entry_class); g_type_class_add_private(entry_class, sizeof(NmtRouteEntryPrivate)); diff --git a/src/nmtui/nmt-route-table.c b/src/nmtui/nmt-route-table.c index fcb14e6a1d..4dc28d7ca5 100644 --- a/src/nmtui/nmt-route-table.c +++ b/src/nmtui/nmt-route-table.c @@ -32,7 +32,7 @@ typedef struct { int ip_entry_width; int metric_entry_width; - GPtrArray * routes; + GPtrArray *routes; NmtNewtWidget *list; } NmtRouteTablePrivate; @@ -59,15 +59,15 @@ nmt_route_table_new(int family) } static gboolean -route_list_transform_to_route(GBinding * binding, +route_list_transform_to_route(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { - NmtRouteTable * table = NMT_ROUTE_TABLE(g_binding_get_source(binding)); + NmtRouteTable *table = NMT_ROUTE_TABLE(g_binding_get_source(binding)); NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE(table); int n = GPOINTER_TO_INT(user_data); - NMIPRoute * route; + NMIPRoute *route; if (n >= priv->routes->len) return FALSE; @@ -78,16 +78,16 @@ route_list_transform_to_route(GBinding * binding, } static gboolean -route_list_transform_from_route(GBinding * binding, +route_list_transform_from_route(GBinding *binding, const GValue *source_value, - GValue * target_value, + GValue *target_value, gpointer user_data) { - NmtRouteTable * table = NMT_ROUTE_TABLE(g_binding_get_source(binding)); + NmtRouteTable *table = NMT_ROUTE_TABLE(g_binding_get_source(binding)); NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE(table); int n = GPOINTER_TO_INT(user_data); - GPtrArray * routes; - NMIPRoute * route; + GPtrArray *routes; + NMIPRoute *route; if (n >= priv->routes->len) return FALSE; @@ -108,7 +108,7 @@ static NmtNewtWidget * create_route_entry(NmtWidgetList *list, int num, gpointer table) { NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE(table); - NmtNewtWidget * entry; + NmtNewtWidget *entry; entry = nmt_route_entry_new(priv->family, priv->ip_entry_width, priv->metric_entry_width); @@ -128,7 +128,7 @@ static void add_route(NmtWidgetList *list, gpointer table) { NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE(table); - NMIPRoute * route; + NMIPRoute *route; if (priv->family == AF_INET) route = nm_ip_route_new(AF_INET, "0.0.0.0", 32, NULL, -1, NULL); @@ -157,10 +157,10 @@ static void nmt_route_table_init(NmtRouteTable *table) { NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE(table); - NmtNewtWidget * header, *empty; - NmtNewtWidget * dest_prefix_label, *next_hop_label, *metric_label; + NmtNewtWidget *header, *empty; + NmtNewtWidget *dest_prefix_label, *next_hop_label, *metric_label; int dest_prefix_width, next_hop_width, metric_width; - char * text; + char *text; priv->routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref); @@ -219,7 +219,7 @@ static void nmt_route_table_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE(object); - GPtrArray * array; + GPtrArray *array; int i; switch (prop_id) { diff --git a/src/nmtui/nmt-slave-list.c b/src/nmtui/nmt-slave-list.c index a6ce554de7..b3ba8dc4ca 100644 --- a/src/nmtui/nmt-slave-list.c +++ b/src/nmtui/nmt-slave-list.c @@ -22,7 +22,7 @@ G_DEFINE_TYPE(NmtSlaveList, nmt_slave_list, NMT_TYPE_EDIT_CONNECTION_LIST) typedef struct { NMConnection *master; - const char * master_type, *master_uuid; + const char *master_type, *master_uuid; NmtAddConnectionTypeFilter type_filter; gpointer type_filter_data; @@ -38,7 +38,7 @@ enum { }; static gboolean nmt_slave_list_connection_filter(NmtEditConnectionList *list, - NMConnection * connection, + NMConnection *connection, gpointer user_data); /** @@ -59,7 +59,7 @@ static gboolean nmt_slave_list_connection_filter(NmtEditConnectionList *list, * Returns: a new #NmtSlaveList. */ NmtNewtWidget * -nmt_slave_list_new(NMConnection * master, +nmt_slave_list_new(NMConnection *master, NmtAddConnectionTypeFilter type_filter, gpointer type_filter_data) { @@ -93,12 +93,12 @@ nmt_slave_list_finalize(GObject *object) static gboolean nmt_slave_list_connection_filter(NmtEditConnectionList *list, - NMConnection * connection, + NMConnection *connection, gpointer user_data) { NmtSlaveListPrivate *priv = NMT_SLAVE_LIST_GET_PRIVATE(list); NMSettingConnection *s_con; - const char * master, *master_ifname, *slave_type; + const char *master, *master_ifname, *slave_type; s_con = nm_connection_get_setting_connection(connection); g_return_val_if_fail(s_con != NULL, FALSE); @@ -193,7 +193,7 @@ nmt_slave_list_get_property(GObject *object, guint prop_id, GValue *value, GPara static void nmt_slave_list_class_init(NmtSlaveListClass *list_class) { - GObjectClass * object_class = G_OBJECT_CLASS(list_class); + GObjectClass *object_class = G_OBJECT_CLASS(list_class); NmtEditConnectionListClass *connection_list_class = NMT_EDIT_CONNECTION_LIST_CLASS(list_class); g_type_class_add_private(list_class, sizeof(NmtSlaveListPrivate)); diff --git a/src/nmtui/nmt-slave-list.h b/src/nmtui/nmt-slave-list.h index f220fc128f..ab7de7b798 100644 --- a/src/nmtui/nmt-slave-list.h +++ b/src/nmtui/nmt-slave-list.h @@ -30,7 +30,7 @@ typedef struct { GType nmt_slave_list_get_type(void); -NmtNewtWidget *nmt_slave_list_new(NMConnection * master, +NmtNewtWidget *nmt_slave_list_new(NMConnection *master, NmtAddConnectionTypeFilter type_filter, gpointer type_filter_data); diff --git a/src/nmtui/nmt-utils.c b/src/nmtui/nmt-utils.c index bac763f696..84d9e9bbbf 100644 --- a/src/nmtui/nmt-utils.c +++ b/src/nmtui/nmt-utils.c @@ -42,7 +42,7 @@ typedef struct { gpointer result; - GError * error; + GError *error; gpointer complete; } NmtSyncOpReal; diff --git a/src/nmtui/nmt-widget-list.c b/src/nmtui/nmt-widget-list.c index cd0c6c3c0b..18d4d16e3b 100644 --- a/src/nmtui/nmt-widget-list.c +++ b/src/nmtui/nmt-widget-list.c @@ -45,7 +45,7 @@ typedef struct { GPtrArray *remove_buttons; NmtNewtWidget *add_button; - GBinding * add_sensitivity; + GBinding *add_sensitivity; } NmtWidgetListPrivate; enum { @@ -106,7 +106,7 @@ NmtNewtWidget * nmt_widget_list_new(NmtWidgetListCallback create_callback, gpointer user_data, GDestroyNotify destroy_notify, - NmtNewtWidget * empty_widget) + NmtNewtWidget *empty_widget) { return g_object_new(NMT_TYPE_WIDGET_LIST, "create-callback", @@ -166,9 +166,9 @@ static void ensure_widgets(NmtWidgetList *list) { NmtWidgetListPrivate *priv = NMT_WIDGET_LIST_GET_PRIVATE(list); - NmtNewtWidget * widget, *button, *focus; + NmtNewtWidget *widget, *button, *focus; gboolean was_empty; - NmtNewtForm * form; + NmtNewtForm *form; int i; was_empty = priv->widgets->len == 0; diff --git a/src/nmtui/nmt-widget-list.h b/src/nmtui/nmt-widget-list.h index 1825c884b5..f6ed8c4d37 100644 --- a/src/nmtui/nmt-widget-list.h +++ b/src/nmtui/nmt-widget-list.h @@ -42,7 +42,7 @@ typedef NmtNewtWidget *(*NmtWidgetListCallback)(NmtWidgetList *list, int n, gpoi NmtNewtWidget *nmt_widget_list_new(NmtWidgetListCallback create_callback, gpointer user_data, GDestroyNotify destroy_notify, - NmtNewtWidget * empty_widget); + NmtNewtWidget *empty_widget); int nmt_widget_list_get_length(NmtWidgetList *list); void nmt_widget_list_set_length(NmtWidgetList *list, int length); diff --git a/src/nmtui/nmt-wireguard-peer-editor.c b/src/nmtui/nmt-wireguard-peer-editor.c index 810bdf6966..a78cfdf064 100644 --- a/src/nmtui/nmt-wireguard-peer-editor.c +++ b/src/nmtui/nmt-wireguard-peer-editor.c @@ -28,8 +28,8 @@ G_DEFINE_TYPE(NmtWireguardPeerEditor, nmt_wireguard_peer_editor, NMT_TYPE_NEWT_F typedef struct { NMSettingWireGuard *orig_setting; NMSettingWireGuard *edit_setting; - NMWireGuardPeer * peer; - NmtNewtEntry * private_key; + NMWireGuardPeer *peer; + NmtNewtEntry *private_key; } NmtWireguardPeerEditorPrivate; enum { @@ -55,7 +55,7 @@ nmt_wireguard_peer_editor_init(NmtWireguardPeerEditor *peer) static void save_peer_and_exit(NmtNewtButton *button, gpointer user_data) { - NmtWireguardPeerEditor * editor = user_data; + NmtWireguardPeerEditor *editor = user_data; NmtWireguardPeerEditorPrivate *priv = NMT_WIREGUARD_PEER_EDITOR_GET_PRIVATE(editor); nm_setting_wireguard_append_peer(priv->orig_setting, priv->peer); @@ -67,10 +67,10 @@ static void nmt_wireguard_peer_editor_constructed(GObject *object) { NmtWireguardPeerEditor *peer = NMT_WIREGUARD_PEER_EDITOR(object); - NmtEditorSection * section; - NmtEditorGrid * grid; - NmtNewtWidget * widget, *label; - NmtNewtWidget * buttons, *ok, *cancel; + NmtEditorSection *section; + NmtEditorGrid *grid; + NmtNewtWidget *widget, *label; + NmtNewtWidget *buttons, *ok, *cancel; if (G_OBJECT_CLASS(nmt_wireguard_peer_editor_parent_class)->constructed) G_OBJECT_CLASS(nmt_wireguard_peer_editor_parent_class)->constructed(object); @@ -161,10 +161,10 @@ nmt_wireguard_peer_editor_constructed(GObject *object) } static void -nmt_wireguard_peer_editor_set_property(GObject * object, +nmt_wireguard_peer_editor_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtWireguardPeerEditorPrivate *priv = NMT_WIREGUARD_PEER_EDITOR_GET_PRIVATE(object); @@ -184,9 +184,9 @@ nmt_wireguard_peer_editor_set_property(GObject * object, } static void -nmt_wireguard_peer_editor_get_property(GObject * object, +nmt_wireguard_peer_editor_get_property(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec) { NmtWireguardPeerEditorPrivate *priv = NMT_WIREGUARD_PEER_EDITOR_GET_PRIVATE(object); diff --git a/src/nmtui/nmt-wireguard-peer-list.c b/src/nmtui/nmt-wireguard-peer-list.c index 03f3ef9aaa..3ac8a88c7f 100644 --- a/src/nmtui/nmt-wireguard-peer-list.c +++ b/src/nmtui/nmt-wireguard-peer-list.c @@ -24,9 +24,9 @@ G_DEFINE_TYPE(NmtWireguardPeerList, nmt_wireguard_peer_list, NMT_TYPE_NEWT_GRID) typedef struct { NMSettingWireGuard *setting; - GSList * peers; + GSList *peers; - NmtNewtListbox * listbox; + NmtNewtListbox *listbox; NmtNewtButtonBox *buttons; NmtNewtWidget *add; @@ -98,8 +98,8 @@ static void nmt_wireguard_peer_list_init(NmtWireguardPeerList *list) { NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); - NmtNewtWidget * listbox, *buttons; - NmtNewtGrid * grid = NMT_NEWT_GRID(list); + NmtNewtWidget *listbox, *buttons; + NmtNewtGrid *grid = NMT_NEWT_GRID(list); listbox = g_object_new(NMT_TYPE_NEWT_LISTBOX, "flags", @@ -166,8 +166,8 @@ static void nmt_wireguard_peer_list_add_peer(NmtWireguardPeerList *list) { NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); - NMWireGuardPeer * peer = nm_wireguard_peer_new(); - NmtNewtForm * editor; + NMWireGuardPeer *peer = nm_wireguard_peer_new(); + NmtNewtForm *editor; editor = nmt_wireguard_peer_editor_new(priv->setting, peer); @@ -183,8 +183,8 @@ static void nmt_wireguard_peer_list_edit_peer(NmtWireguardPeerList *list) { NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); - NMWireGuardPeer * orig_peer, *edit_peer; - NmtNewtForm * editor; + NMWireGuardPeer *orig_peer, *edit_peer; + NmtNewtForm *editor; int selected_row; selected_row = nmt_newt_listbox_get_active(priv->listbox); @@ -216,10 +216,10 @@ nmt_wireguard_peer_list_remove_peer(NmtWireguardPeerList *list) } static void -nmt_wireguard_peer_list_set_property(GObject * object, +nmt_wireguard_peer_list_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(object); @@ -237,14 +237,14 @@ nmt_wireguard_peer_list_set_property(GObject * object, } static void -nmt_wireguard_peer_list_get_property(GObject * object, +nmt_wireguard_peer_list_get_property(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec) { NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(object); - GPtrArray * peers; - GSList * iter; + GPtrArray *peers; + GSList *iter; switch (prop_id) { case PROP_SETTING: @@ -269,10 +269,10 @@ static void nmt_wireguard_peer_list_rebuild(NmtWireguardPeerList *list) { NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); - GSList * iter; - NMWireGuardPeer * peer, *selected_peer; + GSList *iter; + NMWireGuardPeer *peer, *selected_peer; int i, row, selected_row, num; - NMSettingWireGuard * setting = priv->setting; + NMSettingWireGuard *setting = priv->setting; selected_row = nmt_newt_listbox_get_active(priv->listbox); selected_peer = nmt_newt_listbox_get_active_key(priv->listbox); diff --git a/src/nmtui/nmtui-connect.c b/src/nmtui/nmtui-connect.c index 4aa91acb44..fb456653fd 100644 --- a/src/nmtui/nmtui-connect.c +++ b/src/nmtui/nmtui-connect.c @@ -33,11 +33,11 @@ static gboolean openconnect_authenticate(NMConnection *connection, char **cookie, char **gateway, char **gwcert) { - GError * error = NULL; + GError *error = NULL; NMSettingVpn *s_vpn; gboolean ret; int status = 0; - const char * gw, *port; + const char *gw, *port; nmt_newt_message_dialog( _("openconnect will be run to authenticate.\nIt will return to nmtui when completed.")); @@ -80,13 +80,13 @@ openconnect_authenticate(NMConnection *connection, char **cookie, char **gateway static void secrets_requested(NMSecretAgentSimple *agent, - const char * request_id, - const char * title, - const char * msg, - GPtrArray * secrets, + const char *request_id, + const char *title, + const char *msg, + GPtrArray *secrets, gpointer user_data) { - NmtNewtForm * form; + NmtNewtForm *form; NMConnection *connection = NM_CONNECTION(user_data); int i; @@ -138,16 +138,16 @@ secrets_requested(NMSecretAgentSimple *agent, } typedef struct { - NMDevice * device; + NMDevice *device; NMActiveConnection *active; - NmtSyncOp * op; + NmtSyncOp *op; } ActivateConnectionInfo; static void connect_cancelled(NmtNewtForm *form, gpointer user_data) { ActivateConnectionInfo *info = user_data; - GError * error = NULL; + GError *error = NULL; error = g_error_new_literal(G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled"); nmt_sync_op_complete_boolean(info->op, FALSE, error); @@ -158,8 +158,8 @@ static void check_activated(ActivateConnectionInfo *info) { NMActiveConnectionState ac_state; - const char * reason = NULL; - gs_free_error GError *error = NULL; + const char *reason = NULL; + gs_free_error GError *error = NULL; ac_state = nmc_activation_get_effective_state(info->active, info->device, &reason); if (!NM_IN_SET(ac_state, @@ -193,9 +193,9 @@ activate_device_state_changed(GObject *object, GParamSpec *pspec, gpointer user_ static void activate_callback(GObject *client, GAsyncResult *result, gpointer user_data) { - NmtSyncOp * op = user_data; + NmtSyncOp *op = user_data; NMActiveConnection *ac; - GError * error = NULL; + GError *error = NULL; ac = nm_client_activate_connection_finish(NM_CLIENT(client), result, &error); if (error) @@ -207,9 +207,9 @@ activate_callback(GObject *client, GAsyncResult *result, gpointer user_data) static void add_and_activate_callback(GObject *client, GAsyncResult *result, gpointer user_data) { - NmtSyncOp * op = user_data; + NmtSyncOp *op = user_data; NMActiveConnection *ac; - GError * error = NULL; + GError *error = NULL; ac = nm_client_add_and_activate_connection_finish(NM_CLIENT(client), result, &error); if (error) @@ -232,13 +232,13 @@ deactivate_connection(NMActiveConnection *ac) static void activate_connection(NMConnection *connection, NMDevice *device, NMObject *specific_object) { - NmtNewtForm * form; + NmtNewtForm *form; gs_unref_object NMSecretAgentSimple *agent = NULL; - NmtNewtWidget * label; + NmtNewtWidget *label; NmtSyncOp op; - const char * specific_object_path; - NMActiveConnection * ac; - GError * error = NULL; + const char *specific_object_path; + NMActiveConnection *ac; + GError *error = NULL; ActivateConnectionInfo info = {}; form = g_object_new(NMT_TYPE_NEWT_FORM, "escape-exits", TRUE, NULL); @@ -351,10 +351,10 @@ static void listbox_activated(NmtNewtListbox *listbox, gpointer user_data) { NmtConnectConnectionList *list = NMT_CONNECT_CONNECTION_LIST(listbox); - NMConnection * connection; - NMDevice * device; - NMObject * specific_object; - NMActiveConnection * ac; + NMConnection *connection; + NMDevice *device; + NMObject *specific_object; + NMActiveConnection *ac; if (!nmt_connect_connection_list_get_selection(list, &connection, @@ -379,9 +379,9 @@ static void listbox_active_changed(GObject *object, GParamSpec *pspec, gpointer button) { NmtConnectConnectionList *list = NMT_CONNECT_CONNECTION_LIST(object); - static const char * activate, *deactivate; + static const char *activate, *deactivate; static int deactivate_padding, activate_padding; - NMActiveConnection * ac; + NMActiveConnection *ac; gboolean has_selection; if (G_UNLIKELY(activate == NULL)) { @@ -412,7 +412,7 @@ static NmtNewtForm * nmt_connect_connection_list(gboolean is_top) { int screen_width, screen_height; - NmtNewtForm * form; + NmtNewtForm *form; NmtNewtWidget *list, *activate, *quit, *bbox, *grid; newtGetScreenSize(&screen_width, &screen_height); @@ -455,10 +455,10 @@ nmt_connect_connection_list(gboolean is_top) static NmtNewtForm * nmt_connect_connection(const char *identifier) { - NmtNewtWidget * list; - NMConnection * connection; - NMDevice * device; - NMObject * specific_object; + NmtNewtWidget *list; + NMConnection *connection; + NMDevice *device; + NMObject *specific_object; NMActiveConnection *ac; list = nmt_connect_connection_list_new(); diff --git a/src/nmtui/nmtui-edit.c b/src/nmtui/nmtui-edit.c index 534643a764..ec80a20359 100644 --- a/src/nmtui/nmtui-edit.c +++ b/src/nmtui/nmtui-edit.c @@ -45,13 +45,13 @@ list_remove_connection(NmtEditConnectionList *list, NMRemoteConnection *connecti static gboolean edit_connection_list_filter(NmtEditConnectionList *list, - NMConnection * connection, + NMConnection *connection, gpointer user_data) { NMSettingConnection *s_con; - const char * master, *slave_type; - const char * uuid, *ifname; - const GPtrArray * conns; + const char *master, *slave_type; + const char *uuid, *ifname; + const GPtrArray *conns; int i; gboolean found_master = FALSE; @@ -86,7 +86,7 @@ static NmtNewtForm * nmt_edit_main_connection_list(gboolean is_top) { int screen_width, screen_height; - NmtNewtForm * form; + NmtNewtForm *form; NmtNewtWidget *quit, *list; newtGetScreenSize(&screen_width, &screen_height); @@ -137,9 +137,9 @@ typedef struct { NmtNewtTextbox *textbox; NmtNewtListbox *listbox; - char * primary_text; - char * secondary_text; - NMConnection * master; + char *primary_text; + char *secondary_text; + NMConnection *master; NmtAddConnectionTypeFilter type_filter; gpointer type_filter_data; @@ -181,8 +181,8 @@ static void nmt_add_connection_init(NmtAddConnection *form) { NmtAddConnectionPrivate *priv = NMT_ADD_CONNECTION_GET_PRIVATE(form); - NmtNewtWidget * textbox, *listbox, *button; - NmtNewtGrid * grid, *buttons; + NmtNewtWidget *textbox, *listbox, *button; + NmtNewtGrid *grid, *buttons; grid = NMT_NEWT_GRID(nmt_newt_grid_new()); @@ -222,9 +222,9 @@ nmt_add_connection_init(NmtAddConnection *form) static void nmt_add_connection_constructed(GObject *object) { - NmtAddConnectionPrivate * priv = NMT_ADD_CONNECTION_GET_PRIVATE(object); + NmtAddConnectionPrivate *priv = NMT_ADD_CONNECTION_GET_PRIVATE(object); NMEditorConnectionTypeData **types; - char * text; + char *text; int i, num_types; if (priv->secondary_text) { @@ -275,10 +275,10 @@ nmt_add_connection_finalize(GObject *object) } static void -nmt_add_connection_set_property(GObject * object, +nmt_add_connection_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { NmtAddConnectionPrivate *priv = NMT_ADD_CONNECTION_GET_PRIVATE(object); @@ -334,7 +334,7 @@ nmt_add_connection_get_property(GObject *object, guint prop_id, GValue *value, G static void nmt_add_connection_class_init(NmtAddConnectionClass *add_class) { - GObjectClass * object_class = G_OBJECT_CLASS(add_class); + GObjectClass *object_class = G_OBJECT_CLASS(add_class); NmtNewtFormClass *form_class = NMT_NEWT_FORM_CLASS(add_class); g_type_class_add_private(add_class, sizeof(NmtAddConnectionPrivate)); @@ -404,9 +404,9 @@ nmt_add_connection(void) } void -nmt_add_connection_full(const char * primary_text, - const char * secondary_text, - NMConnection * master, +nmt_add_connection_full(const char *primary_text, + const char *secondary_text, + NMConnection *master, NmtAddConnectionTypeFilter type_filter, gpointer type_filter_data) { @@ -453,7 +453,7 @@ static void connection_deleted_callback(GObject *connection, GAsyncResult *result, gpointer user_data) { ConnectionDeleteData *data = user_data; - GError * error = NULL; + GError *error = NULL; if (!nm_remote_connection_delete_finish(data->connection, result, &error)) { nmt_newt_message_dialog(_("Unable to delete connection: %s"), error->message); @@ -481,7 +481,7 @@ static void remove_one_connection(NMRemoteConnection *connection) { ConnectionDeleteData data; - GError * error = NULL; + GError *error = NULL; data.got_callback = data.got_signal = FALSE; nmt_sync_op_init(&data.op); @@ -506,12 +506,12 @@ remove_one_connection(NMRemoteConnection *connection) void nmt_remove_connection(NMRemoteConnection *connection) { - const GPtrArray * all_conns; - GSList * slaves, *iter; + const GPtrArray *all_conns; + GSList *slaves, *iter; int i; - NMRemoteConnection * slave; + NMRemoteConnection *slave; NMSettingConnection *s_con; - const char * uuid, *iface, *master; + const char *uuid, *iface, *master; int choice; choice = nmt_newt_choice_dialog(_("Cancel"), diff --git a/src/nmtui/nmtui-edit.h b/src/nmtui/nmtui-edit.h index 99e370b40e..e868560225 100644 --- a/src/nmtui/nmtui-edit.h +++ b/src/nmtui/nmtui-edit.h @@ -13,9 +13,9 @@ typedef gboolean (*NmtAddConnectionTypeFilter)(GType connection_type, gpointer u NmtNewtForm *nmtui_edit(gboolean is_top, int argc, char **argv); void nmt_add_connection(void); -void nmt_add_connection_full(const char * primary_text, - const char * secondary_text, - NMConnection * master, +void nmt_add_connection_full(const char *primary_text, + const char *secondary_text, + NMConnection *master, NmtAddConnectionTypeFilter type_filter, gpointer type_filter_data); diff --git a/src/nmtui/nmtui-hostname.c b/src/nmtui/nmtui-hostname.c index 2f2524285d..65af73cc6c 100644 --- a/src/nmtui/nmtui-hostname.c +++ b/src/nmtui/nmtui-hostname.c @@ -21,12 +21,12 @@ static char * nmtui_hostname_run_dialog(void) { - NmtNewtForm * form; - NmtNewtWidget * widget, *ok, *cancel; - NmtNewtGrid * grid; - NmtNewtEntry * entry; + NmtNewtForm *form; + NmtNewtWidget *widget, *ok, *cancel; + NmtNewtGrid *grid; + NmtNewtEntry *entry; NmtNewtButtonBox *bbox; - char * hostname, *ret = NULL; + char *hostname, *ret = NULL; form = g_object_new(NMT_TYPE_NEWT_FORM, "title", _("Set Hostname"), "escape-exits", TRUE, NULL); @@ -79,9 +79,9 @@ NmtNewtForm * nmtui_hostname(gboolean is_top, int argc, char **argv) { const char *hostname; - char * tmp = NULL; + char *tmp = NULL; NmtSyncOp op; - GError * error = NULL; + GError *error = NULL; if (argc == 2) hostname = argv[1]; diff --git a/src/nmtui/nmtui.c b/src/nmtui/nmtui.c index 897e09112a..c99d1641f1 100644 --- a/src/nmtui/nmtui.c +++ b/src/nmtui/nmtui.c @@ -27,14 +27,14 @@ #include "nmtui-connect.h" #include "nmtui-hostname.h" -NMClient * nm_client; +NMClient *nm_client; static GMainLoop *loop; typedef NmtNewtForm *(*NmtuiSubprogram)(gboolean is_top, int argc, char **argv); static const struct { - const char * name, *shortcut, *arg; - const char * display_name; + const char *name, *shortcut, *arg; + const char *display_name; NmtuiSubprogram func; } subprograms[] = { {"edit", "nmtui-edit", N_("connection"), N_("Edit a connection"), nmtui_edit}, @@ -57,7 +57,7 @@ quit_func(int argc, char **argv) static void main_list_activated(NmtNewtWidget *widget, NmtNewtListbox *listbox) { - NmtNewtForm * form; + NmtNewtForm *form; NmtuiSubprogram sub; sub = nmt_newt_listbox_get_active_key(listbox); @@ -73,10 +73,10 @@ main_list_activated(NmtNewtWidget *widget, NmtNewtListbox *listbox) static NmtNewtForm * nmtui_main(gboolean is_top, int argc, char **argv) { - NmtNewtForm * form; - NmtNewtWidget * widget, *ok; - NmtNewtGrid * grid; - NmtNewtListbox * listbox; + NmtNewtForm *form; + NmtNewtWidget *widget, *ok; + NmtNewtGrid *grid; + NmtNewtListbox *listbox; NmtNewtButtonBox *bbox; int i; @@ -162,7 +162,7 @@ usage(void) typedef struct { NmtuiSubprogram subprogram; int argc; - char ** argv; + char **argv; } NmtuiStartupData; static void @@ -175,7 +175,7 @@ static gboolean idle_run_subprogram(gpointer user_data) { NmtuiStartupData *data = user_data; - NmtNewtForm * form; + NmtNewtForm *form; form = data->subprogram(TRUE, data->argc, data->argv); if (form) { @@ -210,10 +210,10 @@ GOptionEntry entries[] = {{"sleep", int main(int argc, char **argv) { - GOptionContext * opts; - GError * error = NULL; + GOptionContext *opts; + GError *error = NULL; NmtuiStartupData startup_data; - const char * prgname; + const char *prgname; int i; setlocale(LC_ALL, ""); From 081510ed94dd29c6084204bc30f7b99310dec3c0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 9 Nov 2021 10:00:52 +0100 Subject: [PATCH 058/110] gitlab-ci: use Fedora 35 as default build target --- .gitlab-ci.yml | 22 ++++++++++----------- .gitlab-ci/config.yml | 4 ++-- contrib/scripts/nm-code-format-container.sh | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cfbd51320..e00df3d1e3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,11 +47,11 @@ variables: # # This is done by running `ci-fairy generate-template` and possibly bump # ".default_tag". - FEDORA_TAG: '2021-08-30.0-7ff339b89ca1' - UBUNTU_TAG: '2021-08-30.0-432f46c6a3a4' - DEBIAN_TAG: '2021-08-30.0-432f46c6a3a4' - CENTOS_TAG: '2021-08-30.0-7ff339b89ca1' - ALPINE_TAG: '2021-08-30.0-20e22c5d34b7' + 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_EXEC: 'bash .gitlab-ci/fedora-install.sh' UBUNTU_EXEC: 'bash .gitlab-ci/debian-install.sh' @@ -680,23 +680,23 @@ t_fedora:34: extends: - .build@template - .fdo.distribution-image@fedora - - .nm_artifacts variables: FDO_DISTRIBUTION_VERSION: '34' FDO_DISTRIBUTION_TAG: $FEDORA_TAG needs: - "fedora:34@container-prep" + when: manual t_fedora:35: extends: - .build@template - .fdo.distribution-image@fedora + - .nm_artifacts variables: FDO_DISTRIBUTION_VERSION: '35' FDO_DISTRIBUTION_TAG: $FEDORA_TAG needs: - "fedora:35@container-prep" - when: manual t_fedora:36: extends: @@ -926,7 +926,7 @@ t_alpine:latest: check-patch: extends: - - t_fedora:34 + - t_fedora:35 - .nm_artifacts_undo stage: test script: @@ -935,7 +935,7 @@ check-patch: check-tree: extends: - - t_fedora:34 + - t_fedora:35 - .nm_artifacts_undo stage: test script: @@ -955,9 +955,9 @@ pages: only: - main dependencies: - - t_fedora:34 + - t_fedora:35 needs: - - t_fedora:34 + - t_fedora:35 triage:issues: stage: triage diff --git a/.gitlab-ci/config.yml b/.gitlab-ci/config.yml index 35bc8a29aa..eb96ce18e8 100644 --- a/.gitlab-ci/config.yml +++ b/.gitlab-ci/config.yml @@ -8,7 +8,7 @@ # # We're happy to rebuild all containers when one changes. -.default_tag: &default_tag '2021-08-30.0' +.default_tag: &default_tag '2021-11-09.0' # The list of all distributions we want to create job for. @@ -64,4 +64,4 @@ distributions: # specifies which of the above distros is used as source for pages pages_build: name: fedora - version: '34' + version: '35' diff --git a/contrib/scripts/nm-code-format-container.sh b/contrib/scripts/nm-code-format-container.sh index 9aa6d56d52..a79bc4feb4 100755 --- a/contrib/scripts/nm-code-format-container.sh +++ b/contrib/scripts/nm-code-format-container.sh @@ -37,7 +37,7 @@ if ! podman container exists "$PODNAME" ; then --name="$PODNAME" \ -v "$DIR:/tmp/NetworkManager:Z" \ -w /tmp/NetworkManager \ - fedora:34 \ + fedora:35 \ /bin/bash -c 'dnf upgrade -y && dnf install -y git /usr/bin/clang-format && ./contrib/scripts/nm-code-format.sh -i' exit 0 fi From 9a76b07f744201f1a94c95a40d7493927283ff7e Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 24 Nov 2021 15:56:49 +0100 Subject: [PATCH 059/110] l3cfg: fix assertion failure Fix the following assertion failure: src/core/nm-l3cfg.c:2636:_l3_acd_data_state_change: assertion failed: (!acd_data->nacd_probe) When AcdData enters state NM_L3_ACD_ADDR_STATE_READY, the duplicate address detection procedure completed successfully but the address is not configured yet on the interface. In the READY state we don't clear the probe because the same probe can be reused also for defending the address. Change the assertion. https://bugzilla.redhat.com/show_bug.cgi?id=2026288 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1035 --- src/core/nm-l3cfg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 18d08f5986..8337895714 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -2629,12 +2629,13 @@ handle_init: acd_data->nacd_probe = n_acd_probe_free(acd_data->nacd_probe); _l3_acd_data_timeout_schedule(acd_data, 0); return; - case NM_L3_ACD_ADDR_STATE_READY: case NM_L3_ACD_ADDR_STATE_USED: case NM_L3_ACD_ADDR_STATE_CONFLICT: case NM_L3_ACD_ADDR_STATE_EXTERNAL_REMOVED: nm_assert(!acd_data->nacd_probe); return; + case NM_L3_ACD_ADDR_STATE_READY: + return; } nm_assert_not_reached(); return; From 7f8c8078a123a2bbf7ce0eff7831c078cb3f8647 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 24 Nov 2021 16:57:23 +0100 Subject: [PATCH 060/110] dhcp: accept IPv4-address options longer than expected Some DHCP servers send duplicate options, and we concatenate them according to RFC 3396 section 7. Therefore, it's possible that a option carrying a IPv4 address has a length > 4. See also commit 1cbf9d22a5f6 ('n-dhcp4: accept options that are longer than requested') which did something similar in the nettools client. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/848 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1034 --- src/core/dhcp/nm-dhcp-utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/dhcp/nm-dhcp-utils.c b/src/core/dhcp/nm-dhcp-utils.c index a167673598..72a77cfe9e 100644 --- a/src/core/dhcp/nm-dhcp-utils.c +++ b/src/core/dhcp/nm-dhcp-utils.c @@ -1010,7 +1010,11 @@ nm_dhcp_lease_data_parse_in_addr(const guint8 *data, gsize n_data, in_addr_t *ou * - option 28, https://tools.ietf.org/html/rfc2132#section-5.3 */ - if (n_data != 4) + /* Some DHCP servers send duplicate options, and we concatenate them + * according to RFC 3396 section 7. Therefore, it's possible that a + * option carrying a IPv4 address has a length > 4. + */ + if (n_data < 4) return FALSE; *out_val = unaligned_read_ne32(data); From 7f517e09d05142a32e30452b8ca503e882c3b3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=81=E6=B5=AA=E7=8C=AB?= Date: Tue, 9 Nov 2021 20:28:11 +0800 Subject: [PATCH 061/110] po: update and fix Simplified Chinese translation https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1021 --- po/zh_CN.po | 4346 +++++++++++++++++++++++++-------------------------- 1 file changed, 2173 insertions(+), 2173 deletions(-) diff --git a/po/zh_CN.po b/po/zh_CN.po index 67873f138a..47db2a415b 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -11,23 +11,25 @@ # shijing , 2016. # Mingye Wang (Arthur2e5) , 2016. # Mingcong Bai , 2017. -# Dingzhong Chen , 2016, 2017, 2018. # ljanda , 2019. #zanata # tfu , 2019. #zanata +# Dingzhong Chen , 2016-2021. +# msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-06-01 17:17+0200\n" -"PO-Revision-Date: 2019-08-15 12:20+0000\n" -"Last-Translator: tfu \n" -"Language-Team: Chinese (China) \n" -"Language: zh_Hans\n" +"Project-Id-Version: NetworkManager main\n" +"Report-Msgid-Bugs-To: https://gitlab.freedesktop.org/NetworkManager/" +"NetworkManager/issues\n" +"POT-Creation-Date: 2021-11-07 03:29+0000\n" +"PO-Revision-Date: 2021-11-09 20:06+0800\n" +"Last-Translator: Dingzhong Chen \n" +"Language-Team: Chinese - China \n" +"Language: zh_CN\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Zanata 4.6.2\n" +"Plural-Forms: nplurals=1; plural=0\n" +"X-Generator: Gtranslator 40.0\n" #: ../data/org.freedesktop.NetworkManager.policy.in.in.h:1 msgid "Enable or disable system networking" @@ -175,18 +177,18 @@ msgstr "系统策略阻止启用或禁用连接性检查" #. * as "Wired Connection" or "VPN Connection". The %d is a number #. * that is combined with the first argument to create a unique #. * connection id. -#: ../src/core/NetworkManagerUtils.c:113 +#: ../src/core/NetworkManagerUtils.c:111 #, c-format msgctxt "connection id fallback" msgid "%s %u" msgstr "%s %u" #: ../src/core/devices/adsl/nm-device-adsl.c:117 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:8080 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:7971 msgid "ADSL connection" msgstr "ADSL 连接" -#: ../src/core/devices/bluetooth/nm-bluez-manager.c:1327 +#: ../src/core/devices/bluetooth/nm-bluez-manager.c:1325 #, c-format msgid "%s Network" msgstr "%s 网络" @@ -250,22 +252,22 @@ msgstr "虚拟连接" msgid "Wired connection %d" msgstr "有线连接 %d" -#: ../src/core/devices/nm-device-ethernet.c:1614 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:8117 -#, fuzzy +#: ../src/core/devices/nm-device-ethernet.c:1613 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:8008 +#| msgid "VPN connection" msgid "Veth connection" -msgstr "VPN 连接" +msgstr "Veth 连接" -#: ../src/core/devices/nm-device-ethernet.c:1680 +#: ../src/core/devices/nm-device-ethernet.c:1679 msgid "PPPoE connection" msgstr "PPPoE 连接" -#: ../src/core/devices/nm-device-ethernet.c:1680 +#: ../src/core/devices/nm-device-ethernet.c:1679 msgid "Wired connection" msgstr "有线连接" #: ../src/core/devices/nm-device-infiniband.c:161 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:8093 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:7984 msgid "InfiniBand connection" msgstr "InfiniBand 连接" @@ -282,17 +284,17 @@ msgid "TUN connection" msgstr "TUN 连接" #: ../src/core/devices/nm-device-vlan.c:401 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:8118 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:8009 msgid "VLAN connection" msgstr "VLAN 连接" #: ../src/core/devices/nm-device-vrf.c:181 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:8120 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:8011 msgid "VRF connection" msgstr "VRF 连接" #: ../src/core/devices/nm-device-vxlan.c:382 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:8121 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:8012 msgid "VXLAN connection" msgstr "VXLAN 连接" @@ -305,159 +307,159 @@ msgid "Team connection" msgstr "组合连接" #: ../src/core/devices/wifi/nm-device-olpc-mesh.c:115 -#: ../src/nmcli/devices.c:1352 +#: ../src/nmcli/devices.c:1338 msgid "Mesh" msgstr "Mesh" -#: ../src/core/devices/wifi/nm-wifi-utils.c:32 +#: ../src/core/devices/wifi/nm-wifi-utils.c:31 #, c-format msgid "%s is incompatible with static WEP keys" msgstr "%s 不兼容静态 WEP 密钥" -#: ../src/core/devices/wifi/nm-wifi-utils.c:67 +#: ../src/core/devices/wifi/nm-wifi-utils.c:66 msgid "LEAP authentication requires a LEAP username" msgstr "LEAP 验证要求 LEAP 用户名" -#: ../src/core/devices/wifi/nm-wifi-utils.c:79 +#: ../src/core/devices/wifi/nm-wifi-utils.c:78 msgid "LEAP username requires 'leap' authentication" msgstr "LEAP 用户名要求 \"leap\" 验证" -#: ../src/core/devices/wifi/nm-wifi-utils.c:94 +#: ../src/core/devices/wifi/nm-wifi-utils.c:93 msgid "LEAP authentication requires IEEE 802.1x key management" msgstr "LEAP 验证要求 IEEE 802.1x 密钥管理" -#: ../src/core/devices/wifi/nm-wifi-utils.c:116 +#: ../src/core/devices/wifi/nm-wifi-utils.c:115 msgid "LEAP authentication is incompatible with Ad-Hoc mode" msgstr "LEAP 验证和 Ad-Hoc 模式不兼容" -#: ../src/core/devices/wifi/nm-wifi-utils.c:128 +#: ../src/core/devices/wifi/nm-wifi-utils.c:127 msgid "LEAP authentication is incompatible with 802.1x setting" msgstr "LEAP 验证和 802.1x 设置不兼容" -#: ../src/core/devices/wifi/nm-wifi-utils.c:148 +#: ../src/core/devices/wifi/nm-wifi-utils.c:147 #, c-format msgid "a connection using '%s' authentication cannot use WPA key management" msgstr "使用 \"%s\" 验证的连接无法使用 WPA 密钥管理" -#: ../src/core/devices/wifi/nm-wifi-utils.c:161 +#: ../src/core/devices/wifi/nm-wifi-utils.c:160 #, c-format msgid "a connection using '%s' authentication cannot specify WPA protocols" msgstr "使用 \"%s\" 验证的连接无法指定 WPA 协议" -#: ../src/core/devices/wifi/nm-wifi-utils.c:179 -#: ../src/core/devices/wifi/nm-wifi-utils.c:198 +#: ../src/core/devices/wifi/nm-wifi-utils.c:178 +#: ../src/core/devices/wifi/nm-wifi-utils.c:197 #, c-format msgid "a connection using '%s' authentication cannot specify WPA ciphers" msgstr "使用 \"%s\" 验证的连接无法指定 WPA 密文" -#: ../src/core/devices/wifi/nm-wifi-utils.c:212 +#: ../src/core/devices/wifi/nm-wifi-utils.c:211 #, c-format msgid "a connection using '%s' authentication cannot specify a WPA password" msgstr "使用 \"%s\" 验证的连接无法指定 WPA 密码" -#: ../src/core/devices/wifi/nm-wifi-utils.c:245 +#: ../src/core/devices/wifi/nm-wifi-utils.c:244 msgid "Dynamic WEP requires an 802.1x setting" msgstr "动态 WEP 要求 802.1x 设置" -#: ../src/core/devices/wifi/nm-wifi-utils.c:255 -#: ../src/core/devices/wifi/nm-wifi-utils.c:287 +#: ../src/core/devices/wifi/nm-wifi-utils.c:254 +#: ../src/core/devices/wifi/nm-wifi-utils.c:286 msgid "Dynamic WEP requires 'open' authentication" msgstr "动态 WEP 要求 \"open\" 验证" -#: ../src/core/devices/wifi/nm-wifi-utils.c:272 +#: ../src/core/devices/wifi/nm-wifi-utils.c:271 msgid "Dynamic WEP requires 'ieee8021x' key management" msgstr "动态 WEP 要求 \"ieee8021x\" 密钥管理" -#: ../src/core/devices/wifi/nm-wifi-utils.c:323 +#: ../src/core/devices/wifi/nm-wifi-utils.c:322 msgid "WPA-PSK authentication is incompatible with 802.1x" msgstr "WPA-PSK 验证和 802.1x 兼容" -#: ../src/core/devices/wifi/nm-wifi-utils.c:333 +#: ../src/core/devices/wifi/nm-wifi-utils.c:332 msgid "WPA-PSK requires 'open' authentication" msgstr "WPA-PSK 要求 \"open\" 验证" -#: ../src/core/devices/wifi/nm-wifi-utils.c:347 +#: ../src/core/devices/wifi/nm-wifi-utils.c:346 msgid "Access point does not support PSK but setting requires it" msgstr "接入点不支持 PSK 但设置要求它" -#: ../src/core/devices/wifi/nm-wifi-utils.c:362 +#: ../src/core/devices/wifi/nm-wifi-utils.c:361 msgid "WPA Ad-Hoc authentication requires 'rsn' protocol" -msgstr "WPA Ad-Hoc 身份验证需要 “rsn” 协议" +msgstr "WPA Ad-Hoc 身份验证需要 \"rsn\" 协议" -#: ../src/core/devices/wifi/nm-wifi-utils.c:375 +#: ../src/core/devices/wifi/nm-wifi-utils.c:374 msgid "WPA Ad-Hoc authentication requires 'ccmp' pairwise cipher" -msgstr "WPA Ad-Hoc 身份验证需要 'ccmp' 成对密码" +msgstr "WPA Ad-Hoc 身份验证需要 \"ccmp\" 成对密码" -#: ../src/core/devices/wifi/nm-wifi-utils.c:388 +#: ../src/core/devices/wifi/nm-wifi-utils.c:387 msgid "WPA Ad-Hoc requires 'ccmp' group cipher" -msgstr "WPA Ad-Hoc 需要 “ccmp” 组密码" +msgstr "WPA Ad-Hoc 需要 \"ccmp\" 组密码" -#: ../src/core/devices/wifi/nm-wifi-utils.c:419 +#: ../src/core/devices/wifi/nm-wifi-utils.c:418 msgid "WPA-EAP authentication requires an 802.1x setting" msgstr "WPA-EAP 验证要求 802.1x 设置" -#: ../src/core/devices/wifi/nm-wifi-utils.c:429 +#: ../src/core/devices/wifi/nm-wifi-utils.c:428 msgid "WPA-EAP requires 'open' authentication" msgstr "WPA-EAP 要求 \"open\" 验证" -#: ../src/core/devices/wifi/nm-wifi-utils.c:442 +#: ../src/core/devices/wifi/nm-wifi-utils.c:441 msgid "802.1x setting requires 'wpa-eap' key management" msgstr "802.1x 设置要求 \"wpa-eap\" 密钥管理" -#: ../src/core/devices/wifi/nm-wifi-utils.c:456 +#: ../src/core/devices/wifi/nm-wifi-utils.c:455 msgid "Access point does not support 802.1x but setting requires it" msgstr "接入点不支持 802.1x 但设置要求它" -#: ../src/core/devices/wifi/nm-wifi-utils.c:486 +#: ../src/core/devices/wifi/nm-wifi-utils.c:485 msgid "Ad-Hoc mode requires 'none' or 'wpa-psk' key management" -msgstr "Ad-Hoc 模式需要 'none' 或 'wpa-psk' 密钥管理" +msgstr "Ad-Hoc 模式需要 \"none\" 或 \"wpa-psk\" 密钥管理" -#: ../src/core/devices/wifi/nm-wifi-utils.c:498 +#: ../src/core/devices/wifi/nm-wifi-utils.c:497 msgid "Ad-Hoc mode is incompatible with 802.1x security" msgstr "Ad-Hoc 模式和 802.1x 安全性不兼容" -#: ../src/core/devices/wifi/nm-wifi-utils.c:507 +#: ../src/core/devices/wifi/nm-wifi-utils.c:506 msgid "Ad-Hoc mode is incompatible with LEAP security" msgstr "Ad-Hoc 模式和 LEAP 安全性不兼容" -#: ../src/core/devices/wifi/nm-wifi-utils.c:519 +#: ../src/core/devices/wifi/nm-wifi-utils.c:518 msgid "Ad-Hoc mode requires 'open' authentication" msgstr "Ad-Hoc 模式要求 \"open\" 验证" -#: ../src/core/devices/wifi/nm-wifi-utils.c:563 -#: ../src/core/devices/wifi/nm-wifi-utils.c:598 +#: ../src/core/devices/wifi/nm-wifi-utils.c:562 +#: ../src/core/devices/wifi/nm-wifi-utils.c:597 #, c-format msgid "connection does not match access point" msgstr "连接和接入点不匹配" -#: ../src/core/devices/wifi/nm-wifi-utils.c:652 +#: ../src/core/devices/wifi/nm-wifi-utils.c:651 #, c-format msgid "connection does not match mesh point" msgstr "连接与 mesh 点不匹配" -#: ../src/core/devices/wifi/nm-wifi-utils.c:671 +#: ../src/core/devices/wifi/nm-wifi-utils.c:670 msgid "Access point is unencrypted but setting specifies security" msgstr "接入点未加密但设置指定了安全性" -#: ../src/core/devices/wifi/nm-wifi-utils.c:762 +#: ../src/core/devices/wifi/nm-wifi-utils.c:761 msgid "" "WPA authentication is incompatible with non-EAP (original) LEAP or Dynamic " "WEP" msgstr "WPA 验证和非 EAP(原始的)LEAP 或动态 WEP 不兼容" -#: ../src/core/devices/wifi/nm-wifi-utils.c:775 +#: ../src/core/devices/wifi/nm-wifi-utils.c:774 msgid "WPA authentication is incompatible with Shared Key authentication" msgstr "WPA 验证和共享密钥(Shared Key)验证不兼容" -#: ../src/core/devices/wifi/nm-wifi-utils.c:866 +#: ../src/core/devices/wifi/nm-wifi-utils.c:857 msgid "Failed to determine AP security information" msgstr "确定 AP 安全信息失败" -#: ../src/core/dhcp/nm-dhcp-dhclient-utils.c:317 +#: ../src/core/dhcp/nm-dhcp-dhclient-utils.c:316 msgid "# Created by NetworkManager\n" msgstr "# 由 NetworkManger 创建\n" -#: ../src/core/dhcp/nm-dhcp-dhclient-utils.c:330 +#: ../src/core/dhcp/nm-dhcp-dhclient-utils.c:329 #, c-format msgid "" "# Merged from %s\n" @@ -496,48 +498,48 @@ msgstr "%s 已在运行中(pid %ld)\n" msgid "You must be root to run %s!\n" msgstr "运行 %s 必须是根用户!\n" -#: ../src/core/main-utils.c:284 ../src/core/main.c:375 +#: ../src/core/main-utils.c:284 ../src/core/main.c:374 #: ../src/core/nm-iface-helper.c:585 #, c-format msgid "%s. Please use --help to see a list of valid options.\n" msgstr "%s。请使用 --help 查看有效选项列表。\n" -#: ../src/core/main.c:164 ../src/core/main.c:385 +#: ../src/core/main.c:163 ../src/core/main.c:384 #, c-format msgid "Failed to read configuration: %s\n" msgstr "读取配置失败:%s\n" -#: ../src/core/main.c:191 ../src/core/nm-iface-helper.c:406 +#: ../src/core/main.c:190 ../src/core/nm-iface-helper.c:406 msgid "Print NetworkManager version and exit" msgstr "输出网络管理器版本并退出" -#: ../src/core/main.c:198 ../src/core/nm-iface-helper.c:413 +#: ../src/core/main.c:197 ../src/core/nm-iface-helper.c:413 msgid "Don't become a daemon" msgstr "不成为守护进程" -#: ../src/core/main.c:205 ../src/core/nm-iface-helper.c:427 +#: ../src/core/main.c:204 ../src/core/nm-iface-helper.c:427 #, c-format msgid "Log level: one of [%s]" msgstr "日志级别:取 [%s] 之一" -#: ../src/core/main.c:212 ../src/core/nm-iface-helper.c:434 +#: ../src/core/main.c:211 ../src/core/nm-iface-helper.c:434 #, c-format msgid "Log domains separated by ',': any combination of [%s]" msgstr "以 \",\" 分开的日志域:可以是 [%s] 的任意组合" -#: ../src/core/main.c:219 ../src/core/nm-iface-helper.c:441 +#: ../src/core/main.c:218 ../src/core/nm-iface-helper.c:441 msgid "Make all warnings fatal" msgstr "视所有警告为致命错误" -#: ../src/core/main.c:226 +#: ../src/core/main.c:225 msgid "Specify the location of a PID file" msgstr "指定一个 PID 文件的位置" -#: ../src/core/main.c:240 +#: ../src/core/main.c:239 msgid "Print NetworkManager configuration and exit" msgstr "输出网络管理器配置并退出" -#: ../src/core/main.c:251 +#: ../src/core/main.c:250 msgid "" "NetworkManager monitors all network connections and automatically\n" "chooses the best connection to use. It also allows the user to\n" @@ -547,15 +549,15 @@ msgstr "" "网络管理器(NetworkManager)监视所有网络连接,并自动选择要使用的最佳连接。\n" "它还允许用户指定计算机无线网卡连接的无线访问点。" -#: ../src/core/main.c:408 ../src/core/nm-iface-helper.c:599 +#: ../src/core/main.c:407 ../src/core/nm-iface-helper.c:599 #, c-format msgid "Could not daemonize: %s [error %u]\n" msgstr "无法设为守护进程:%s [错误 %u]\n" #: ../src/core/nm-config.c:542 #: ../src/libnm-core-impl/nm-setting-ovs-bridge.c:187 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:2157 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:4175 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:2107 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:4103 #, c-format msgid "'%s' is not valid" msgstr "\"%s\" 无效" @@ -563,7 +565,7 @@ msgstr "\"%s\" 无效" #: ../src/core/nm-config.c:561 #, c-format msgid "Bad '%s' option: " -msgstr "错误的 '%s' 选项: " +msgstr "错误的 \"%s\" 选项:" #: ../src/core/nm-config.c:578 msgid "Config file location" @@ -734,44 +736,44 @@ msgstr "(%s):无效的 IID %s\n" msgid "(%s): Invalid DHCP client-id %s\n" msgstr "(%s):无效的 DHCP 客户端 ID %s\n" -#: ../src/core/nm-manager.c:5926 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:8119 +#: ../src/core/nm-manager.c:5867 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:8010 msgid "VPN connection" msgstr "VPN 连接" -#: ../src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c:5478 +#: ../src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c:5467 #: ../src/libnm-client-impl/nm-device.c:1683 -#: ../src/libnm-core-impl/nm-connection.c:2707 +#: ../src/libnm-core-impl/nm-connection.c:2696 #: ../src/nmtui/nm-editor-utils.c:180 msgid "Bond" msgstr "绑定" -#: ../src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c:5549 +#: ../src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c:5538 #: ../src/libnm-client-impl/nm-device.c:1685 -#: ../src/libnm-core-impl/nm-connection.c:2709 +#: ../src/libnm-core-impl/nm-connection.c:2698 #: ../src/nmtui/nm-editor-utils.c:198 msgid "Team" msgstr "组合" -#: ../src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c:5886 +#: ../src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c:5875 #: ../src/libnm-client-impl/nm-device.c:1687 -#: ../src/libnm-core-impl/nm-connection.c:2711 +#: ../src/libnm-core-impl/nm-connection.c:2700 #: ../src/nmtui/nm-editor-utils.c:189 msgid "Bridge" msgstr "网桥" -#: ../src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c:9974 +#: ../src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c:9973 #: ../src/libnm-core-impl/nm-team-utils.c:2396 #, c-format msgid "invalid json" msgstr "无效的 json" -#: ../src/libnm-client-impl/nm-client.c:3782 +#: ../src/libnm-client-impl/nm-client.c:3773 #, c-format msgid "request succeeded with %s but object is in an unsuitable state" msgstr "使用 %s 请求成功,但对象处于不合适的状态" -#: ../src/libnm-client-impl/nm-client.c:3874 +#: ../src/libnm-client-impl/nm-client.c:3865 #, c-format msgid "operation succeeded but object %s does not exist" msgstr "操作成功,但对象 %s 不存在" @@ -934,7 +936,7 @@ msgstr "此连接不是 VRF 连接。" #: ../src/libnm-client-impl/nm-device-vrf.c:74 msgid "The VRF table of the device and the connection didn't match." -msgstr "设备的 VRF 表和连接不匹配" +msgstr "设备的 VRF 表和连接不匹配。" #: ../src/libnm-client-impl/nm-device-vxlan.c:383 msgid "The connection was not a VXLAN connection." @@ -1001,13 +1003,13 @@ msgid "Mobile Broadband" msgstr "移动宽带" #: ../src/libnm-client-impl/nm-device.c:1681 -#: ../src/libnm-core-impl/nm-connection.c:2715 +#: ../src/libnm-core-impl/nm-connection.c:2704 #: ../src/nmtui/nm-editor-utils.c:153 msgid "InfiniBand" msgstr "InfiniBand" #: ../src/libnm-client-impl/nm-device.c:1689 -#: ../src/libnm-core-impl/nm-connection.c:2713 +#: ../src/libnm-core-impl/nm-connection.c:2702 #: ../src/nmtui/nm-editor-utils.c:207 ../src/nmtui/nmt-page-vlan.c:64 msgid "VLAN" msgstr "VLAN" @@ -1071,8 +1073,8 @@ msgstr "VRF" #. TRANSLATORS: Unknown reason for a device state change (NMDeviceStateReason) #. TRANSLATORS: Unknown reason for a connection state change (NMActiveConnectionStateReason) #: ../src/libnm-client-impl/nm-device.c:1724 -#: ../src/libnmc-base/nm-client-utils.c:352 -#: ../src/libnmc-base/nm-client-utils.c:473 +#: ../src/libnmc-base/nm-client-utils.c:326 +#: ../src/libnmc-base/nm-client-utils.c:447 msgid "Unknown" msgstr "未知" @@ -1108,135 +1110,135 @@ msgstr "连接无效:%s" #: ../src/libnm-client-impl/nm-device.c:2773 #, c-format -msgid "The interface names of the device and the connection didn't match" +msgid "The interface names of the device and the connection didn't match." msgstr "这个设备的接口名和连接不匹配。" #: ../src/libnm-client-impl/nm-secret-agent-old.c:1384 msgid "registration failed" -msgstr "注册失败。" +msgstr "注册失败" -#: ../src/libnm-client-impl/nm-vpn-plugin-old.c:817 -#: ../src/libnm-client-impl/nm-vpn-service-plugin.c:1063 +#: ../src/libnm-client-impl/nm-vpn-plugin-old.c:819 +#: ../src/libnm-client-impl/nm-vpn-service-plugin.c:1014 msgid "No service name specified" msgstr "未指定服务" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:286 #, c-format msgid "'%s' is not valid: properties should be specified as 'key=value'" -msgstr "'%s' 无效:属性需要以 'key=value' 的形式指定" +msgstr "\"%s\" 无效:属性需要以 \"key=value\" 的形式指定" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:300 #, c-format msgid "'%s' is not a valid key" -msgstr "'%s' 不是一个有效的关键字" +msgstr "\"%s\" 不是一个有效的关键字" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:305 #, c-format msgid "duplicate key '%s'" -msgstr "重复的关键字 '%s'" +msgstr "重复的关键字 \"%s\"" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:319 #, c-format msgid "number for '%s' is out of range" -msgstr "'%s' 的值超出了范围" +msgstr "\"%s\" 的值超出了范围" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:324 #, c-format msgid "value for '%s' must be a number" -msgstr "'%s' 的值需要是一个数字" +msgstr "\"%s\" 的值需要是一个数字" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:337 #, c-format msgid "value for '%s' must be a boolean" -msgstr "'%s' 的值需要是一个布尔值" +msgstr "\"%s\" 的值需要是一个布尔值" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:346 msgid "missing 'name' attribute" -msgstr "缺少 'name' 属性" +msgstr "缺少 \"name\" 属性" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:355 #, c-format msgid "invalid 'name' \"%s\"" -msgstr "无效的 'name' \"%s\"" +msgstr "无效的 \"name\" \"%s\"" #: ../src/libnm-core-aux-extern/nm-libnm-core-aux.c:368 #, c-format msgid "attribute '%s' is invalid for \"%s\"" -msgstr "属性 '%s' 无效(对于\"%s\")" +msgstr "属性 \"%s\" 对于 \"%s\" 无效" #: ../src/libnm-core-aux-intern/nm-libnm-core-utils.c:293 -#, fuzzy msgid "property cannot be an empty string" -msgstr "\"%s=%s\" 不允许这个属性为空" +msgstr "属性不能为空的字符串" #: ../src/libnm-core-aux-intern/nm-libnm-core-utils.c:310 -#, fuzzy msgid "property cannot be longer than 255 bytes" -msgstr "DHCP选项不能多于 255 个字符" +msgstr "属性不能多于 255 个字符" #: ../src/libnm-core-aux-intern/nm-libnm-core-utils.c:321 -#, fuzzy msgid "property cannot contain any nul bytes" -msgstr "属性必须只包含数字" +msgstr "属性不能包含任何 nul 字节" -#: ../src/libnm-core-impl/nm-connection.c:300 +#: ../src/libnm-core-impl/nm-connection.c:299 msgid "wrong type; should be a list of strings." msgstr "错误的类型;应为一个字符串列表。" -#: ../src/libnm-core-impl/nm-connection.c:374 +#: ../src/libnm-core-impl/nm-connection.c:373 msgid "unknown setting name" msgstr "未知的设置名称" -#: ../src/libnm-core-impl/nm-connection.c:386 +#: ../src/libnm-core-impl/nm-connection.c:385 msgid "duplicate setting name" msgstr "重复的设置名称" -#: ../src/libnm-core-impl/nm-connection.c:1433 +#: ../src/libnm-core-impl/nm-connection.c:1422 msgid "setting not found" msgstr "未找到设置" -#: ../src/libnm-core-impl/nm-connection.c:1486 -#: ../src/libnm-core-impl/nm-connection.c:1511 -#: ../src/libnm-core-impl/nm-connection.c:1536 +#: ../src/libnm-core-impl/nm-connection.c:1475 +#: ../src/libnm-core-impl/nm-connection.c:1500 +#: ../src/libnm-core-impl/nm-connection.c:1525 msgid "setting is required for non-slave connections" msgstr "对于非从连接,设置是必需的" -#: ../src/libnm-core-impl/nm-connection.c:1499 -#: ../src/libnm-core-impl/nm-connection.c:1524 -#: ../src/libnm-core-impl/nm-connection.c:1549 +#: ../src/libnm-core-impl/nm-connection.c:1488 +#: ../src/libnm-core-impl/nm-connection.c:1513 +#: ../src/libnm-core-impl/nm-connection.c:1538 msgid "setting not allowed in slave connection" msgstr "从连接中不允许设置" -#: ../src/libnm-core-impl/nm-connection.c:1654 +#: ../src/libnm-core-impl/nm-connection.c:1643 msgid "Unexpected failure to normalize the connection" msgstr "正常化连接意外地失败" -#: ../src/libnm-core-impl/nm-connection.c:1715 +#: ../src/libnm-core-impl/nm-connection.c:1704 msgid "Unexpected failure to verify the connection" msgstr "检验连接意外地失败" -#: ../src/libnm-core-impl/nm-connection.c:1752 +#: ../src/libnm-core-impl/nm-connection.c:1741 #, c-format msgid "unexpected uuid %s instead of %s" msgstr "非预期的 uuid %s,而不是 %s" -#: ../src/libnm-core-impl/nm-connection.c:2566 +#: ../src/libnm-core-impl/nm-connection.c:2555 #: ../src/libnm-core-impl/nm-setting-8021x.c:2618 #: ../src/libnm-core-impl/nm-setting-8021x.c:2641 #: ../src/libnm-core-impl/nm-setting-8021x.c:2681 #: ../src/libnm-core-impl/nm-setting-8021x.c:2704 -#: ../src/libnm-core-impl/nm-setting-8021x.c:2754 -#: ../src/libnm-core-impl/nm-setting-8021x.c:2795 -#: ../src/libnm-core-impl/nm-setting-8021x.c:2895 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2755 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2773 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2797 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2815 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2845 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2945 #: ../src/libnm-core-impl/nm-setting-adsl.c:157 #: ../src/libnm-core-impl/nm-setting-bluetooth.c:110 #: ../src/libnm-core-impl/nm-setting-bluetooth.c:174 #: ../src/libnm-core-impl/nm-setting-bluetooth.c:191 #: ../src/libnm-core-impl/nm-setting-cdma.c:127 -#: ../src/libnm-core-impl/nm-setting-connection.c:1075 -#: ../src/libnm-core-impl/nm-setting-connection.c:1113 -#: ../src/libnm-core-impl/nm-setting-connection.c:1385 -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5333 +#: ../src/libnm-core-impl/nm-setting-connection.c:1073 +#: ../src/libnm-core-impl/nm-setting-connection.c:1111 +#: ../src/libnm-core-impl/nm-setting-connection.c:1383 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5332 #: ../src/libnm-core-impl/nm-setting-ip-tunnel.c:371 #: ../src/libnm-core-impl/nm-setting-olpc-mesh.c:83 #: ../src/libnm-core-impl/nm-setting-ovs-patch.c:75 @@ -1249,7 +1251,7 @@ msgstr "非预期的 uuid %s,而不是 %s" msgid "property is missing" msgstr "缺少属性" -#: ../src/libnm-core-impl/nm-connection.c:2719 +#: ../src/libnm-core-impl/nm-connection.c:2708 msgid "IP Tunnel" msgstr "IP 隧道" @@ -1511,7 +1513,7 @@ msgstr "无法找到预期的 TSS 起始标记。" #: ../src/libnm-core-impl/nm-crypto.c:426 #, c-format msgid "Failed to find expected TSS end tag '%s'." -msgstr "无法找到预期的 TSS 结束标记 '%s'。" +msgstr "无法找到预期的 TSS 结束标记 \"%s\"。" #: ../src/libnm-core-impl/nm-crypto.c:481 #, c-format @@ -1562,7 +1564,7 @@ msgstr "整数文件为空" #: ../src/libnm-core-impl/nm-crypto.c:778 #, c-format msgid "Failed to recognize certificate" -msgstr "识别证书失败。" +msgstr "识别证书失败" #: ../src/libnm-core-impl/nm-crypto.c:886 #, c-format @@ -1584,237 +1586,239 @@ msgstr "值不能解释为一个数字列表。" msgid "value is not an integer in range [%lld, %lld]" msgstr "值不是在 [%lld, %lld] 范围内的一个整数" -#: ../src/libnm-core-impl/nm-keyfile.c:270 +#: ../src/libnm-core-impl/nm-keyfile.c:269 msgid "ignoring missing number" msgstr "忽略缺失的数字" -#: ../src/libnm-core-impl/nm-keyfile.c:282 +#: ../src/libnm-core-impl/nm-keyfile.c:281 #, c-format msgid "ignoring invalid number '%s'" msgstr "忽略无效的数字 \"%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:311 +#: ../src/libnm-core-impl/nm-keyfile.c:310 #, c-format msgid "ignoring invalid %s address: %s" msgstr "忽略无效的 %s 地址:%s" -#: ../src/libnm-core-impl/nm-keyfile.c:357 +#: ../src/libnm-core-impl/nm-keyfile.c:356 #, c-format msgid "ignoring invalid gateway '%s' for %s route" msgstr "忽略 %s%s 路由的无效网关 \"\"" -#: ../src/libnm-core-impl/nm-keyfile.c:379 +#: ../src/libnm-core-impl/nm-keyfile.c:378 #, c-format msgid "ignoring invalid %s route: %s" msgstr "忽略无效的 %s 路由:%s" -#: ../src/libnm-core-impl/nm-keyfile.c:557 +#: ../src/libnm-core-impl/nm-keyfile.c:556 #, c-format msgid "unexpected character '%c' for address %s: '%s' (position %td)" msgstr "对于地址 %2$s 的意外字符 \"%1$c\":\"%3$s\"(位置 %4$td)" -#: ../src/libnm-core-impl/nm-keyfile.c:573 +#: ../src/libnm-core-impl/nm-keyfile.c:572 #, c-format msgid "unexpected character '%c' for %s: '%s' (position %td)" msgstr "对于 %2$s 的意外字符 \"%1$c\":\"%3$s\"(位置 %4$td)" -#: ../src/libnm-core-impl/nm-keyfile.c:588 +#: ../src/libnm-core-impl/nm-keyfile.c:587 #, c-format msgid "unexpected character '%c' in prefix length for %s: '%s' (position %td)" msgstr "对于 %2$s,前缀长度中有意外字符 \"%1$c\":\"%3$s\"(位置 %4$td)" -#: ../src/libnm-core-impl/nm-keyfile.c:605 +#: ../src/libnm-core-impl/nm-keyfile.c:604 #, c-format msgid "garbage at the end of value %s: '%s'" msgstr "值 %s 的末尾有无用信息:\"%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:615 +#: ../src/libnm-core-impl/nm-keyfile.c:614 #, c-format msgid "deprecated semicolon at the end of value %s: '%s'" msgstr "值 %s 的末尾有舍弃的分号:\"%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:634 +#: ../src/libnm-core-impl/nm-keyfile.c:633 #, c-format msgid "invalid prefix length for %s '%s', defaulting to %d" msgstr "%s 的前缀长度 \"%s\" 无效,默认为 %d" -#: ../src/libnm-core-impl/nm-keyfile.c:646 +#: ../src/libnm-core-impl/nm-keyfile.c:645 #, c-format msgid "missing prefix length for %s '%s', defaulting to %d" msgstr "缺少 %s 的前缀长度 \"%s\",默认为 %d" -#: ../src/libnm-core-impl/nm-keyfile.c:989 +#: ../src/libnm-core-impl/nm-keyfile.c:988 #: ../src/libnm-core-impl/nm-setting-ovs-external-ids.c:320 #: ../src/libnm-core-impl/nm-setting-user.c:372 #, c-format msgid "invalid value for \"%s\": %s" msgstr "对 \"%s\" 无效的值:%s" -#: ../src/libnm-core-impl/nm-keyfile.c:1067 +#: ../src/libnm-core-impl/nm-keyfile.c:1066 #, c-format msgid "ignoring invalid DNS server IPv%c address '%s'" msgstr "忽略无效的 DNS 服务器 IPv%c 地址 \"%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:1104 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1651 +#: ../src/libnm-core-impl/nm-keyfile.c:1103 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1623 #, c-format msgid "invalid option '%s', use one of [%s]" msgstr "无效选项 \"%s\",请使用 [%s] 中的一个。" -#: ../src/libnm-core-impl/nm-keyfile.c:1162 +#: ../src/libnm-core-impl/nm-keyfile.c:1161 msgid "ignoring invalid MAC address" msgstr "忽略无效的 MAC 地址" -#: ../src/libnm-core-impl/nm-keyfile.c:1238 -#, fuzzy, c-format +#: ../src/libnm-core-impl/nm-keyfile.c:1237 +#, c-format +#| msgid "ignoring invalid %s address: %s" msgid "ignoring invalid bond option %s%s%s = %s%s%s: %s" -msgstr "忽略无效的 %s 地址:%s" +msgstr "忽略无效的绑定(bond)选项 %s%s%s = %s%s%s:%s" -#: ../src/libnm-core-impl/nm-keyfile.c:1428 +#: ../src/libnm-core-impl/nm-keyfile.c:1427 msgid "ignoring invalid SSID" msgstr "忽略无效的 SSID" -#: ../src/libnm-core-impl/nm-keyfile.c:1446 +#: ../src/libnm-core-impl/nm-keyfile.c:1445 msgid "ignoring invalid raw password" msgstr "忽略无效的原始密码" -#: ../src/libnm-core-impl/nm-keyfile.c:1587 +#: ../src/libnm-core-impl/nm-keyfile.c:1586 msgid "invalid key/cert value" msgstr "无效的密钥/证书值" -#: ../src/libnm-core-impl/nm-keyfile.c:1602 +#: ../src/libnm-core-impl/nm-keyfile.c:1601 #, c-format msgid "invalid key/cert value path \"%s\"" msgstr "无效的密钥/证书值路径 \"%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:1627 -#: ../src/libnm-core-impl/nm-keyfile.c:1724 +#: ../src/libnm-core-impl/nm-keyfile.c:1626 +#: ../src/libnm-core-impl/nm-keyfile.c:1723 #, c-format msgid "certificate or key file '%s' does not exist" msgstr "证书或密钥文件 \"%s\" 不存在" -#: ../src/libnm-core-impl/nm-keyfile.c:1640 +#: ../src/libnm-core-impl/nm-keyfile.c:1639 #, c-format msgid "invalid PKCS#11 URI \"%s\"" msgstr "无效的 PKCS#11 URI \"%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:1686 +#: ../src/libnm-core-impl/nm-keyfile.c:1685 msgid "invalid key/cert value data:;base64, is not base64" msgstr "无效的密钥/证书值 data:;base64,不是 base64" -#: ../src/libnm-core-impl/nm-keyfile.c:1699 +#: ../src/libnm-core-impl/nm-keyfile.c:1698 msgid "invalid key/cert value data:;base64,file://" msgstr "无效的密钥/证书值 data:;base64,file://" -#: ../src/libnm-core-impl/nm-keyfile.c:1740 +#: ../src/libnm-core-impl/nm-keyfile.c:1739 msgid "invalid key/cert value is not a valid blob" msgstr "无效的密钥/证书值,不是有效的比特块(blob)" -#: ../src/libnm-core-impl/nm-keyfile.c:1842 +#: ../src/libnm-core-impl/nm-keyfile.c:1841 #, c-format msgid "invalid parity value '%s'" msgstr "无效的奇偶校验值 \"%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:1864 -#: ../src/libnm-core-impl/nm-keyfile.c:3337 +#: ../src/libnm-core-impl/nm-keyfile.c:1863 +#: ../src/libnm-core-impl/nm-keyfile.c:3336 #, c-format msgid "invalid setting: %s" msgstr "无效设置:%s" -#: ../src/libnm-core-impl/nm-keyfile.c:1884 +#: ../src/libnm-core-impl/nm-keyfile.c:1883 #, c-format msgid "ignoring invalid team configuration: %s" msgstr "忽略无效的组合(team)配置:%s" -#: ../src/libnm-core-impl/nm-keyfile.c:1967 +#: ../src/libnm-core-impl/nm-keyfile.c:1966 #, c-format msgid "invalid qdisc: %s" msgstr "无效的排队规则(qdisc):%s" -#: ../src/libnm-core-impl/nm-keyfile.c:2017 +#: ../src/libnm-core-impl/nm-keyfile.c:2016 #, c-format msgid "invalid tfilter: %s" msgstr "无效的流量过滤器(tfilter):%s" -#: ../src/libnm-core-impl/nm-keyfile.c:3162 +#: ../src/libnm-core-impl/nm-keyfile.c:3161 #, c-format msgid "error loading setting value: %s" msgstr "加载设置值时出错:%s" -#: ../src/libnm-core-impl/nm-keyfile.c:3193 -#: ../src/libnm-core-impl/nm-keyfile.c:3205 -#: ../src/libnm-core-impl/nm-keyfile.c:3224 -#: ../src/libnm-core-impl/nm-keyfile.c:3236 -#: ../src/libnm-core-impl/nm-keyfile.c:3248 -#: ../src/libnm-core-impl/nm-keyfile.c:3310 -#: ../src/libnm-core-impl/nm-keyfile.c:3322 +#: ../src/libnm-core-impl/nm-keyfile.c:3192 +#: ../src/libnm-core-impl/nm-keyfile.c:3204 +#: ../src/libnm-core-impl/nm-keyfile.c:3223 +#: ../src/libnm-core-impl/nm-keyfile.c:3235 +#: ../src/libnm-core-impl/nm-keyfile.c:3247 +#: ../src/libnm-core-impl/nm-keyfile.c:3309 +#: ../src/libnm-core-impl/nm-keyfile.c:3321 msgid "value cannot be interpreted as integer" msgstr "值无法被解析为整数" -#: ../src/libnm-core-impl/nm-keyfile.c:3278 +#: ../src/libnm-core-impl/nm-keyfile.c:3277 #, c-format msgid "ignoring invalid byte element '%u' (not between 0 and 255 inclusive)" -msgstr "忽略无效的字节元素 '%u'(不在 0 和 255 之间)" +msgstr "忽略无效的字节元素 \"%u\"(不在 0 和 255 之间)" -#: ../src/libnm-core-impl/nm-keyfile.c:3362 +#: ../src/libnm-core-impl/nm-keyfile.c:3361 #, c-format msgid "invalid setting name '%s'" msgstr "无效的设置名称 \"%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:3409 +#: ../src/libnm-core-impl/nm-keyfile.c:3408 #, c-format msgid "invalid key '%s.%s'" msgstr "无效的密钥 \"%s.%s\"" -#: ../src/libnm-core-impl/nm-keyfile.c:3425 +#: ../src/libnm-core-impl/nm-keyfile.c:3424 #, c-format msgid "key '%s.%s' is not boolean" msgstr "密钥 \"%s.%s\" 不是布尔值" -#: ../src/libnm-core-impl/nm-keyfile.c:3442 +#: ../src/libnm-core-impl/nm-keyfile.c:3441 #, c-format msgid "key '%s.%s' is not a uint32" -msgstr "key '%s.%s' 不是一个 uint32" +msgstr "key \"%s.%s\" 不是一个 uint32" -#: ../src/libnm-core-impl/nm-keyfile.c:3499 +#: ../src/libnm-core-impl/nm-keyfile.c:3498 #, c-format msgid "invalid peer public key in section '%s'" -msgstr "'%s' 项中无效的 peer 公钥" +msgstr "\"%s\" 项中存在无效的对等端公钥" -#: ../src/libnm-core-impl/nm-keyfile.c:3514 +#: ../src/libnm-core-impl/nm-keyfile.c:3513 #, c-format msgid "key '%s.%s' is not a valid 256 bit key in base64 encoding" -msgstr "密钥 '%s.%s' 不是一个以 base64 编码的有效的 256 位密钥" +msgstr "密钥 \"%s.%s\" 不是一个以 base64 编码的有效的 256 位密钥" -#: ../src/libnm-core-impl/nm-keyfile.c:3537 +#: ../src/libnm-core-impl/nm-keyfile.c:3536 #, c-format msgid "key '%s.%s' is not a valid secret flag" -msgstr "'%s.%s' 不是一个有效的 secret 标记" +msgstr "\"%s.%s\" 不是一个有效的机密(secret)标记" -#: ../src/libnm-core-impl/nm-keyfile.c:3560 +#: ../src/libnm-core-impl/nm-keyfile.c:3559 #, c-format msgid "key '%s.%s' is not a integer in range 0 to 2^32" -msgstr "'%s.%s' 不是在 0 到 2^32 范围内的一个整数" +msgstr "\"%s.%s\" 不是在 0 到 2^32 范围内的一个整数" -#: ../src/libnm-core-impl/nm-keyfile.c:3576 +#: ../src/libnm-core-impl/nm-keyfile.c:3575 #, c-format msgid "key '%s.%s' is not a valid endpoint" -msgstr "'%s.%s' 不是一个有效的端点" +msgstr "\"%s.%s\" 不是一个有效的端点" -#: ../src/libnm-core-impl/nm-keyfile.c:3602 +#: ../src/libnm-core-impl/nm-keyfile.c:3601 #, c-format msgid "key '%s.%s' has invalid allowed-ips" -msgstr "'%s.%s' 包括无效的 allowed-ips" +msgstr "\"%s.%s\" 包括无效的 allowed-ips" -#: ../src/libnm-core-impl/nm-keyfile.c:3617 +#: ../src/libnm-core-impl/nm-keyfile.c:3616 #, c-format msgid "peer '%s' is invalid: %s" -msgstr "peer '%s' 无效 : %s" +msgstr "对等端 \"%s\" 无效:%s" -#: ../src/libnm-core-impl/nm-keyfile.c:4108 -#, fuzzy, c-format +#: ../src/libnm-core-impl/nm-keyfile.c:4107 +#, c-format +#| msgid "rule is invalid: %s" msgid "the profile is not valid: %s" -msgstr "规则无效:%s" +msgstr "该配置集无效:%s" #: ../src/libnm-core-impl/nm-setting-6lowpan.c:78 #: ../src/libnm-core-impl/nm-setting-veth.c:80 @@ -1887,19 +1891,22 @@ msgstr "当证书不在 PKCS#11 令牌上时不支持密码" #: ../src/libnm-core-impl/nm-setting-8021x.c:2651 #: ../src/libnm-core-impl/nm-setting-8021x.c:2691 #: ../src/libnm-core-impl/nm-setting-8021x.c:2714 -#: ../src/libnm-core-impl/nm-setting-8021x.c:2759 -#: ../src/libnm-core-impl/nm-setting-8021x.c:2805 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2764 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2782 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2806 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2824 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2855 #: ../src/libnm-core-impl/nm-setting-adsl.c:165 #: ../src/libnm-core-impl/nm-setting-cdma.c:134 #: ../src/libnm-core-impl/nm-setting-cdma.c:143 -#: ../src/libnm-core-impl/nm-setting-connection.c:1085 -#: ../src/libnm-core-impl/nm-setting-connection.c:1128 -#: ../src/libnm-core-impl/nm-setting-connection.c:1323 +#: ../src/libnm-core-impl/nm-setting-connection.c:1083 +#: ../src/libnm-core-impl/nm-setting-connection.c:1126 +#: ../src/libnm-core-impl/nm-setting-connection.c:1321 #: ../src/libnm-core-impl/nm-setting-gsm.c:282 #: ../src/libnm-core-impl/nm-setting-gsm.c:337 #: ../src/libnm-core-impl/nm-setting-gsm.c:380 #: ../src/libnm-core-impl/nm-setting-gsm.c:389 -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5342 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5341 #: ../src/libnm-core-impl/nm-setting-ip4-config.c:206 #: ../src/libnm-core-impl/nm-setting-ip4-config.c:218 #: ../src/libnm-core-impl/nm-setting-pppoe.c:136 @@ -1907,8 +1914,8 @@ msgstr "当证书不在 PKCS#11 令牌上时不支持密码" #: ../src/libnm-core-impl/nm-setting-vpn.c:540 #: ../src/libnm-core-impl/nm-setting-vpn.c:550 #: ../src/libnm-core-impl/nm-setting-wimax.c:104 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:955 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:983 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:956 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:984 #: ../src/libnm-core-impl/nm-setting.c:1240 msgid "property is empty" msgstr "属性为空" @@ -1919,15 +1926,11 @@ msgstr "属性为空" msgid "has to match '%s' property for PKCS#12" msgstr "必须匹配 PKCS#12 的 \"%s\" 属性" -#: ../src/libnm-core-impl/nm-setting-8021x.c:2773 -msgid "exactly one property must be set" -msgstr "" - -#: ../src/libnm-core-impl/nm-setting-8021x.c:2883 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2933 msgid "can be enabled only on Ethernet connections" msgstr "只能为以太网连接启用" -#: ../src/libnm-core-impl/nm-setting-8021x.c:2904 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2954 #: ../src/libnm-core-impl/nm-setting-bluetooth.c:92 #: ../src/libnm-core-impl/nm-setting-infiniband.c:163 #: ../src/libnm-core-impl/nm-setting-infiniband.c:175 @@ -1937,38 +1940,38 @@ msgstr "只能为以太网连接启用" #: ../src/libnm-core-impl/nm-setting-olpc-mesh.c:121 #: ../src/libnm-core-impl/nm-setting-wifi-p2p.c:132 #: ../src/libnm-core-impl/nm-setting-wimax.c:116 -#: ../src/libnm-core-impl/nm-setting-wired.c:820 -#: ../src/libnm-core-impl/nm-setting-wired.c:833 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1008 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1020 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1032 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1045 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1058 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1089 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1156 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1205 +#: ../src/libnm-core-impl/nm-setting-wired.c:802 +#: ../src/libnm-core-impl/nm-setting-wired.c:815 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1009 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1021 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1033 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1046 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1059 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1090 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1141 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1190 #: ../src/libnm-core-impl/nm-setting-wireless.c:884 #: ../src/libnm-core-impl/nm-setting-wireless.c:896 #: ../src/libnm-core-impl/nm-setting-wireless.c:909 #: ../src/libnm-core-impl/nm-setting-wpan.c:161 -#: ../src/libnm-core-impl/nm-utils.c:4232 +#: ../src/libnm-core-impl/nm-utils.c:4454 msgid "property is invalid" msgstr "属性无效" -#: ../src/libnm-core-impl/nm-setting-8021x.c:2929 -#: ../src/libnm-core-impl/nm-setting-8021x.c:2942 -#: ../src/libnm-core-impl/nm-setting-8021x.c:2955 -#: ../src/libnm-core-impl/nm-setting-8021x.c:2989 -#: ../src/libnm-core-impl/nm-setting-8021x.c:3002 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2979 +#: ../src/libnm-core-impl/nm-setting-8021x.c:2992 +#: ../src/libnm-core-impl/nm-setting-8021x.c:3005 +#: ../src/libnm-core-impl/nm-setting-8021x.c:3039 +#: ../src/libnm-core-impl/nm-setting-8021x.c:3052 #: ../src/libnm-core-impl/nm-setting-adsl.c:177 #: ../src/libnm-core-impl/nm-setting-adsl.c:190 #: ../src/libnm-core-impl/nm-setting-bluetooth.c:127 -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:911 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:926 #, c-format msgid "'%s' is not a valid value for the property" msgstr "\"%s\" 不是该属性的有效取值" -#: ../src/libnm-core-impl/nm-setting-8021x.c:2968 +#: ../src/libnm-core-impl/nm-setting-8021x.c:3018 msgid "invalid auth flags" msgstr "无效的验证标记" @@ -1993,19 +1996,19 @@ msgid "'%s' is not a valid IPv4 address for '%s' option" msgstr "\"%s\" 不是 \"%s\" 选项的有效 IPv4 地址" #: ../src/libnm-core-impl/nm-setting-bond.c:531 -#, fuzzy, c-format +#, c-format msgid "missing option name" -msgstr "缺少文件名" +msgstr "缺少选项名" #: ../src/libnm-core-impl/nm-setting-bond.c:536 -#, fuzzy, c-format +#, c-format msgid "invalid option '%s'" -msgstr "无效操作: " +msgstr "无效选项 \"%s\"" #: ../src/libnm-core-impl/nm-setting-bond.c:572 -#, fuzzy, c-format +#, c-format msgid "invalid value '%s' for option '%s'" -msgstr "uint32 值 \"%s\" 对属性 \"%s\" 无效" +msgstr "值 \"%s\" 对选项 \"%s\" 无效" #: ../src/libnm-core-impl/nm-setting-bond.c:814 #, c-format @@ -2041,7 +2044,7 @@ msgstr "\"%s=%s\" 不是 \"%s\" 的有效配置" #: ../src/libnm-core-impl/nm-setting-bond.c:905 #, c-format msgid "'%s' option requires '%s' option to be enabled" -msgstr "'%s' 选项需要 '%s' 选项来启用" +msgstr "\"%s\" 选项需要 \"%s\" 选项来启用" #: ../src/libnm-core-impl/nm-setting-bond.c:922 #: ../src/libnm-core-impl/nm-setting-bond.c:933 @@ -2069,7 +2072,7 @@ msgstr "\"%s\" 选项应该为字符串" msgid "'%s' option is not valid with mode '%s'" msgstr "\"%s\" 选项在 \"%s\" 模式里无效" -#: ../src/libnm-core-impl/nm-setting-bridge-port.c:310 +#: ../src/libnm-core-impl/nm-setting-bridge-port.c:302 #: ../src/libnm-core-impl/nm-setting-ovs-bridge.c:151 #: ../src/libnm-core-impl/nm-setting-ovs-interface.c:289 #: ../src/libnm-core-impl/nm-setting-ovs-port.c:170 @@ -2078,7 +2081,7 @@ msgstr "\"%s\" 选项在 \"%s\" 模式里无效" msgid "missing setting" msgstr "缺少设置" -#: ../src/libnm-core-impl/nm-setting-bridge-port.c:320 +#: ../src/libnm-core-impl/nm-setting-bridge-port.c:312 #: ../src/libnm-core-impl/nm-setting-ovs-interface.c:312 #: ../src/libnm-core-impl/nm-setting-ovs-port.c:193 #: ../src/libnm-core-impl/nm-setting-team-port.c:317 @@ -2088,107 +2091,107 @@ msgid "" "Instead it is '%s'" msgstr "具有 \"%s\" 设置的连接必须将 slave-type 设置为 \"%s\"。而它是 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-bridge.c:1175 +#: ../src/libnm-core-impl/nm-setting-bridge.c:1165 #, c-format msgid "value '%d' is out of range <%d-%d>" -msgstr "值 '%d' 超出了范围 <%d-%d>" +msgstr "值 \"%d\" 超出了范围 <%d-%d>" -#: ../src/libnm-core-impl/nm-setting-bridge.c:1194 +#: ../src/libnm-core-impl/nm-setting-bridge.c:1184 msgid "is not a valid MAC address" msgstr "不是有效的 MAC 地址" -#: ../src/libnm-core-impl/nm-setting-bridge.c:1238 +#: ../src/libnm-core-impl/nm-setting-bridge.c:1228 msgid "the mask can't contain bits 0 (STP), 1 (MAC) or 2 (LACP)" msgstr "掩码不能包含位 0(STP)、1(MAC)或2(LACP)" -#: ../src/libnm-core-impl/nm-setting-bridge.c:1260 +#: ../src/libnm-core-impl/nm-setting-bridge.c:1250 msgid "is not a valid link local MAC address" msgstr "不是一个有效的链路本地 MAC 地址" -#: ../src/libnm-core-impl/nm-setting-bridge.c:1272 +#: ../src/libnm-core-impl/nm-setting-bridge.c:1262 msgid "is not a valid VLAN filtering protocol" msgstr "不是一个有效的 VLAN 过滤协议" -#: ../src/libnm-core-impl/nm-setting-bridge.c:1284 +#: ../src/libnm-core-impl/nm-setting-bridge.c:1274 msgid "is not a valid option" msgstr "不是一个有效的选项" -#: ../src/libnm-core-impl/nm-setting-bridge.c:1296 +#: ../src/libnm-core-impl/nm-setting-bridge.c:1286 #, c-format msgid "'%s' option must be a power of 2" -msgstr "'%s' 选项需要是 2 个指数" +msgstr "\"%s\" 选项需要是 2 个指数" -#: ../src/libnm-core-impl/nm-setting-connection.c:968 +#: ../src/libnm-core-impl/nm-setting-connection.c:967 #, c-format msgid "setting required for connection of type '%s'" msgstr "类型为 \"%s\" 的连接需要设置" -#: ../src/libnm-core-impl/nm-setting-connection.c:999 +#: ../src/libnm-core-impl/nm-setting-connection.c:998 #, c-format msgid "Unknown slave type '%s'" msgstr "未知的从类型 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-connection.c:1014 +#: ../src/libnm-core-impl/nm-setting-connection.c:1013 #, c-format msgid "Slave connections need a valid '%s' property" msgstr "从连接需要有效的 \"%s\" 属性" -#: ../src/libnm-core-impl/nm-setting-connection.c:1038 +#: ../src/libnm-core-impl/nm-setting-connection.c:1037 #, c-format msgid "Cannot set '%s' without '%s'" msgstr "没有 \"%s\" 无法设置 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-connection.c:1097 +#: ../src/libnm-core-impl/nm-setting-connection.c:1095 #, c-format msgid "'%s' is not a valid UUID" msgstr "\"%s\"不是有效的 UUID" -#: ../src/libnm-core-impl/nm-setting-connection.c:1142 +#: ../src/libnm-core-impl/nm-setting-connection.c:1140 #, c-format msgid "connection type '%s' is not valid" msgstr "连接类型 \"%s\" 无效" -#: ../src/libnm-core-impl/nm-setting-connection.c:1248 +#: ../src/libnm-core-impl/nm-setting-connection.c:1246 #, c-format msgid "'%s' connections must be enslaved to '%s', not '%s'" msgstr "\"%s\" 连接必须从属于 \"%s\",而不是 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-connection.c:1264 +#: ../src/libnm-core-impl/nm-setting-connection.c:1262 #, c-format msgid "metered value %d is not valid" msgstr "计量值 %d 无效" -#: ../src/libnm-core-impl/nm-setting-connection.c:1278 -#: ../src/libnm-core-impl/nm-setting-connection.c:1292 -#: ../src/libnm-core-impl/nm-setting-connection.c:1309 +#: ../src/libnm-core-impl/nm-setting-connection.c:1276 +#: ../src/libnm-core-impl/nm-setting-connection.c:1290 +#: ../src/libnm-core-impl/nm-setting-connection.c:1307 #, c-format msgid "value %d is not valid" msgstr "值 %d 无效" -#: ../src/libnm-core-impl/nm-setting-connection.c:1337 +#: ../src/libnm-core-impl/nm-setting-connection.c:1335 msgid "DHCP option cannot be longer than 255 characters" -msgstr "DHCP选项不能多于 255 个字符" +msgstr "DHCP 选项不能多于 255 个字符" -#: ../src/libnm-core-impl/nm-setting-connection.c:1348 +#: ../src/libnm-core-impl/nm-setting-connection.c:1346 msgid "MUD URL is not a valid URL" msgstr "MUD URL不是一个有效的URL" -#: ../src/libnm-core-impl/nm-setting-connection.c:1368 -#, fuzzy +#: ../src/libnm-core-impl/nm-setting-connection.c:1366 +#| msgid "invalid permission \"%s\"" msgid "invalid permissions not in format \"user:$UNAME[:]\"" -msgstr "无效的权限 \"%s\"" +msgstr "无效的权限,没有以 \"user:$UNAME[:]\" 为格式" -#: ../src/libnm-core-impl/nm-setting-connection.c:1397 +#: ../src/libnm-core-impl/nm-setting-connection.c:1395 #, c-format msgid "property type should be set to '%s'" msgstr "属性类型应该设置为 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-connection.c:1415 +#: ../src/libnm-core-impl/nm-setting-connection.c:1413 #, c-format msgid "slave-type '%s' requires a '%s' setting in the connection" msgstr "slave-type \"%s\" 要求连接中有 \"%s\" 设置" -#: ../src/libnm-core-impl/nm-setting-connection.c:1426 +#: ../src/libnm-core-impl/nm-setting-connection.c:1424 #, c-format msgid "" "Detect a slave connection with '%s' set and a port type '%s'. '%s' should be " @@ -2196,15 +2199,11 @@ msgid "" msgstr "" "检测到设置了 \"%s\" 和端口类型为 \"%s\" 的从连接。\"%s\" 应该设置为 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-connection.c:1452 +#: ../src/libnm-core-impl/nm-setting-connection.c:1450 #, c-format msgid "A slave connection with '%s' set to '%s' cannot have a '%s' setting" msgstr "\"%s\" 设为 \"%s\" 的从连接不能有个 \"%s\" 设置" -#: ../src/libnm-core-impl/nm-setting-connection.c:1469 -msgid "UUID needs normalization" -msgstr "" - #: ../src/libnm-core-impl/nm-setting-dcb.c:483 msgid "flags invalid" msgstr "标志无效" @@ -2235,23 +2234,19 @@ msgstr "属性无效" msgid "property missing" msgstr "缺少属性" -#: ../src/libnm-core-impl/nm-setting-ethtool.c:311 +#: ../src/libnm-core-impl/nm-setting-ethtool.c:291 msgid "unsupported ethtool setting" msgstr "不支持的 ethtool 设置" -#: ../src/libnm-core-impl/nm-setting-ethtool.c:320 +#: ../src/libnm-core-impl/nm-setting-ethtool.c:300 msgid "setting has invalid variant type" msgstr "设置有无效的变量类型" -#: ../src/libnm-core-impl/nm-setting-ethtool.c:332 +#: ../src/libnm-core-impl/nm-setting-ethtool.c:312 msgid "coalesce option must be either 0 or 1" -msgstr "coalesce 选项必须是 0 或 1。" +msgstr "coalesce 选项必须是 0 或 1" -#: ../src/libnm-core-impl/nm-setting-ethtool.c:349 -msgid "pause-autoneg cannot be enabled when setting rx/tx options" -msgstr "" - -#: ../src/libnm-core-impl/nm-setting-ethtool.c:374 +#: ../src/libnm-core-impl/nm-setting-ethtool.c:335 #, c-format msgid "unknown ethtool option '%s'" msgstr "未知的 ethtool 选项 \"%s\"" @@ -2341,7 +2336,7 @@ msgstr "无效 IPv6 地址前缀 \"%u\"" #: ../src/libnm-core-impl/nm-setting-ip-config.c:154 #, c-format msgid "Invalid routing metric '%s'" -msgstr "无效的路由度量 \"%s\"" +msgstr "无效的路由跃点数 \"%s\"" #: ../src/libnm-core-impl/nm-setting-ip-config.c:1318 #: ../src/libnm-core-impl/nm-setting-sriov.c:399 @@ -2400,9 +2395,9 @@ msgid "missing table" msgstr "缺少表" #: ../src/libnm-core-impl/nm-setting-ip-config.c:2654 -#, fuzzy +#| msgid "invalid action: " msgid "invalid action type" -msgstr "无效操作: " +msgstr "无效的操作类型" #: ../src/libnm-core-impl/nm-setting-ip-config.c:2663 msgid "has from/src but the prefix-length is zero" @@ -2473,21 +2468,21 @@ msgstr "重复的 %s" #: ../src/libnm-core-impl/nm-setting-ip-config.c:2941 #, c-format msgid "invalid variant type '%s' for \"%s\"" -msgstr "无效的变体类型 '%s'(对于 \"%s\")" +msgstr "无效的变体类型 \"%s\"(对于 \"%s\")" #: ../src/libnm-core-impl/nm-setting-ip-config.c:2952 -#, fuzzy +#| msgid "missing \"" msgid "missing \"family\"" -msgstr "缺少 \"" +msgstr "缺少 \"family\"" #: ../src/libnm-core-impl/nm-setting-ip-config.c:2960 -#, fuzzy +#| msgid "invalid address family" msgid "invalid \"family\"" -msgstr "无效的 地址家族" +msgstr "无效的 \"family\"" #: ../src/libnm-core-impl/nm-setting-ip-config.c:3017 msgid "\"uid-range-start\" is greater than \"uid-range-end\"" -msgstr "" +msgstr "\"uid-range-start\" 大于 \"uid-range-end\"" #: ../src/libnm-core-impl/nm-setting-ip-config.c:3211 msgid "Unsupported to-string-flags argument" @@ -2497,126 +2492,126 @@ msgstr "不支持的 to-string-flags 参数" msgid "Unsupported extra-argument" msgstr "不支持的 extra-argument" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3524 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3523 #, c-format msgid "unsupported key \"%s\"" msgstr "不支持的 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3531 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3530 #, c-format msgid "duplicate key \"%s\"" msgstr "重复的 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3538 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3537 #, c-format msgid "invalid value for \"%s\"" msgstr "\"%s\" 无效的值" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3550 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3549 msgid "empty text does not describe a rule" msgstr "空文本没有描述一个规则" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3558 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3557 #, c-format msgid "missing argument for \"%s\"" msgstr "\"%s\" 缺少参数" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3572 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3571 msgid "invalid \"from\" part" msgstr "无效的 \"from\" 部分" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3588 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3587 msgid "invalid \"to\" part" msgstr "无效的 \"to\" 部分" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3599 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3598 #, c-format msgid "cannot detect address family for rule" msgstr "无法为规则检测到地址家族" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3666 -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3756 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3665 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3755 #, c-format msgid "rule is invalid: %s" msgstr "规则无效:%s" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:3737 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:3736 msgid "invalid address family" msgstr "无效的 地址家族" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5010 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5009 #, c-format msgid "rule #%u is invalid: %s" msgstr "规则 #%u 无效:%s" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5358 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5357 #, c-format msgid "%d. DNS server address is invalid" msgstr "%d。DNS 服务器地址无效" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5377 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5376 #, c-format msgid "%d. IP address is invalid" msgstr "%d。IP 地址无效" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5392 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5391 #, c-format msgid "%d. IP address has 'label' property with invalid type" msgstr "%d。IP 地址有无效类型的 \"label\" 属性" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5404 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5403 #, c-format msgid "%d. IP address has invalid label '%s'" msgstr "%d。IP 地址有无效标签 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5422 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5421 msgid "gateway cannot be set if there are no addresses configured" msgstr "如果没有配置地址,网关会无法设置" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5434 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5433 msgid "gateway is invalid" msgstr "网关无效" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5452 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5451 #, c-format msgid "%d. route is invalid" msgstr "%d。路由无效" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5465 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5464 #, c-format msgid "invalid attribute: %s" msgstr "无效的属性:%s" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5485 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5484 #, c-format msgid "%u. rule has wrong address-family" msgstr "%u. 规则带有错误的地址家族" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5497 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5496 #, c-format msgid "%u. rule is invalid: %s" msgstr "%u. 规则无效:%s" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5513 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5512 #, c-format msgid "'%s' is not a valid IAID" -msgstr "'%s' 不是一个有效的 IAID" +msgstr "\"%s\" 不是一个有效的 IAID" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5527 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5526 #, c-format msgid "the property cannot be set when '%s' is disabled" -msgstr "当 '%s' 被禁用时不能设置这个属性" +msgstr "当 \"%s\" 被禁用时不能设置这个属性" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5552 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5551 msgid "the property is currently supported only for DHCPv4" -msgstr "" +msgstr "该属性当前只被 DHCPv4 支持" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5569 -#, fuzzy, c-format +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5568 +#, c-format msgid "'%s' is not a valid IP or subnet" -msgstr "\"%s\" 不是有效的 IP 地址" +msgstr "\"%s\" 不是有效的 IP 或子网" -#: ../src/libnm-core-impl/nm-setting-ip-config.c:5585 +#: ../src/libnm-core-impl/nm-setting-ip-config.c:5584 #, c-format msgid "a gateway is incompatible with '%s'" msgstr "网关与 \"%s\" 不兼容" @@ -2806,9 +2801,9 @@ msgid "key contains invalid characters" msgstr "密钥包含无效的字符" #: ../src/libnm-core-impl/nm-setting-ovs-external-ids.c:123 -#, fuzzy +#| msgid "key cannot contain \"..\"" msgid "key cannot start with \"NM.\"" -msgstr "密钥不能包含 \"..\"" +msgstr "密钥不能以 \"NM.\" 开头" #: ../src/libnm-core-impl/nm-setting-ovs-external-ids.c:153 #: ../src/libnm-core-impl/nm-setting-user.c:180 @@ -2842,6 +2837,8 @@ msgid "" "OVS external IDs can only be added to a profile of type OVS bridge/port/" "interface or to OVS system interface" msgstr "" +"OVS 外部 ID 只能添加到 OVS 桥接/端口/接口类型的配置集,或者添加到 OVS 系统接" +"口" #: ../src/libnm-core-impl/nm-setting-ovs-interface.c:93 #, c-format @@ -2866,7 +2863,7 @@ msgstr "\"%s\" 类型的连接不能有 ovs-interface.type \"%s\"" #: ../src/libnm-core-impl/nm-setting-ovs-interface.c:170 #, c-format msgid "A connection can not have both '%s' and '%s' settings at the same time" -msgstr "一个连接不能同时设置 '%s' 和 '%s'" +msgstr "一个连接不能同时设置 \"%s\" 和 \"%s\"" #: ../src/libnm-core-impl/nm-setting-ovs-interface.c:184 #, c-format @@ -2881,7 +2878,7 @@ msgstr "" #, c-format msgid "" "A connection with '%s' setting needs to be of '%s' interface type, not '%s'" -msgstr "一个带有 '%s' 设置的连接需要是 '%s' 接口类型,而不是 '%s'" +msgstr "一个带有 \"%s\" 设置的连接需要是 \"%s\" 接口类型,而不是 \"%s\"" #: ../src/libnm-core-impl/nm-setting-ovs-interface.c:222 #, c-format @@ -2927,7 +2924,7 @@ msgstr "\"%s\" 在 bond_mode 里不允许" #: ../src/libnm-core-impl/nm-setting-ppp.c:335 #, c-format msgid "'%d' is out of valid range <128-16384>" -msgstr "'%d' 超出了有效范围 <128-16384>" +msgstr "\"%d\" 超出了有效范围 <128-16384>" #: ../src/libnm-core-impl/nm-setting-ppp.c:348 #, c-format @@ -2961,13 +2958,13 @@ msgid "the script lacks FindProxyForURL function" msgstr "脚本缺少 FindProxyForURL 功能" #: ../src/libnm-core-impl/nm-setting-sriov.c:424 -#: ../src/libnm-core-impl/nm-setting-wired.c:787 -#: ../src/libnm-core-impl/nm-setting-wired.c:803 -#: ../src/libnm-core-impl/nm-setting-wired.c:877 -#: ../src/libnm-core-impl/nm-setting-wired.c:935 +#: ../src/libnm-core-impl/nm-setting-wired.c:769 +#: ../src/libnm-core-impl/nm-setting-wired.c:785 +#: ../src/libnm-core-impl/nm-setting-wired.c:859 +#: ../src/libnm-core-impl/nm-setting-wired.c:917 #: ../src/libnm-core-impl/nm-setting-wireless.c:944 #: ../src/libnm-core-impl/nm-setting-wireless.c:963 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:4125 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:4053 #, c-format msgid "'%s' is not a valid MAC address" msgstr "\"%s\" 不是有效的 MAC 地址" @@ -3079,9 +3076,10 @@ msgid "maximum number of user data entries reached" msgstr "已达到最大的用户数据输入项" #: ../src/libnm-core-impl/nm-setting-veth.c:89 -#, fuzzy, c-format +#, c-format +#| msgid "'%s' is not a valid interface type" msgid "'%s' is not a valid interface name" -msgstr "\"%s\" 不是有效的接口类型" +msgstr "\"%s\" 不是有效的接口名称" #: ../src/libnm-core-impl/nm-setting-vlan.c:632 #, c-format @@ -3129,48 +3127,51 @@ msgstr "表大小不能为零" #: ../src/libnm-core-impl/nm-setting-vxlan.c:329 #: ../src/libnm-core-impl/nm-setting-vxlan.c:340 -#, fuzzy, c-format +#, c-format +#| msgid "'%s' is not a valid IP%c address" msgid "'%s' is not a valid IP%s address" -msgstr "\"%s\" 不是有效的 IP%c 地址" +msgstr "\"%s\" 不是有效的 IP%s 地址" #: ../src/libnm-core-impl/nm-setting-vxlan.c:363 #, c-format msgid "%d is greater than local port max %d" msgstr "%d 大于本地端口最大值 %d" -#: ../src/libnm-core-impl/nm-setting-wired.c:767 +#: ../src/libnm-core-impl/nm-setting-wired.c:749 #, c-format msgid "'%s' is not a valid Ethernet port value" msgstr "\"%s\" 不是有效的以太网端口值" -#: ../src/libnm-core-impl/nm-setting-wired.c:777 +#: ../src/libnm-core-impl/nm-setting-wired.c:759 #, c-format msgid "'%s' is not a valid duplex value" msgstr "\"%s\"不是有效的双工值" -#: ../src/libnm-core-impl/nm-setting-wired.c:850 -#, fuzzy, c-format +#: ../src/libnm-core-impl/nm-setting-wired.c:832 +#, c-format +#| msgid "invalid key '%s.%s'" msgid "invalid key '%s'" -msgstr "无效的密钥 \"%s.%s\"" +msgstr "无效的密钥 \"%s\"" -#: ../src/libnm-core-impl/nm-setting-wired.c:862 -#, fuzzy, c-format +#: ../src/libnm-core-impl/nm-setting-wired.c:844 +#, c-format +#| msgid "invalid value for \"%s\"" msgid "invalid value for key '%s'" -msgstr "\"%s\" 无效的值" +msgstr "值对于密钥 \"%s\" 无效" -#: ../src/libnm-core-impl/nm-setting-wired.c:911 +#: ../src/libnm-core-impl/nm-setting-wired.c:893 msgid "Wake-on-LAN mode 'default' and 'ignore' are exclusive flags" msgstr "LAN 唤醒模式 \"default\" 和 \"ignore\" 是相互排斥的标记" -#: ../src/libnm-core-impl/nm-setting-wired.c:923 +#: ../src/libnm-core-impl/nm-setting-wired.c:905 msgid "Wake-on-LAN password can only be used with magic packet mode" msgstr "LAN 唤醒密码只能在幻数据包模式使用" -#: ../src/libnm-core-impl/nm-setting-wired.c:954 +#: ../src/libnm-core-impl/nm-setting-wired.c:936 msgid "both speed and duplex should have a valid value or both should be unset" msgstr "速度和双工都应设定有效值或者都保持未设定" -#: ../src/libnm-core-impl/nm-setting-wired.c:955 +#: ../src/libnm-core-impl/nm-setting-wired.c:937 msgid "both speed and duplex are required for static link configuration" msgstr "静态链路配置需要设置速度和双工" @@ -3199,93 +3200,90 @@ msgstr "peer 的 allowed-ip 无效的 IP 地址 \"%s\"" msgid "invalid preshared-key-flags for peer" msgstr "peer 无效的 preshared-key-flags" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1598 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1587 #, c-format msgid "peer #%u has no public-key" msgstr "peer #%u 没有 public-key" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1611 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1600 #, c-format msgid "peer #%u has invalid public-key" msgstr "peer #%u 带有无效的 public-key" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1627 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1616 #, c-format msgid "peer #%u has invalid endpoint" msgstr "peer #%u 带有无效的端点" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1659 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1648 #, c-format msgid "peer #%u has invalid allowed-ips setting" msgstr "peer #%u 带有无效的 allowed-ips 设置" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1673 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1662 #, c-format msgid "peer #%u is invalid: %s" msgstr "peer #%u 无效:%s" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1744 -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1763 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1733 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1752 #, c-format msgid "method \"%s\" is not supported for WireGuard" msgstr "方法 \"%s\" 不支持 WireGuard" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1787 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1776 msgid "key must be 32 bytes base64 encoded" msgstr "密钥需要是基于 base64 编码的 32 个字节" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1918 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1906 msgid "invalid peer secrets" msgstr "无效的 peer secrets" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1944 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1932 #, c-format msgid "peer #%u lacks public-key" msgstr "peer #%u 缺少 public-key" -#: ../src/libnm-core-impl/nm-setting-wireguard.c:1961 +#: ../src/libnm-core-impl/nm-setting-wireguard.c:1949 #, c-format msgid "non-existing peer '%s'" -msgstr "不存在 peer '%s'" +msgstr "不存在 peer \"%s\"" -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:925 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:912 #, c-format msgid "'%s' is not a valid value for '%s' mode connections" msgstr "\"%s\" 不是 \"%s\" 模式连接的有效值" -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:941 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:942 #, c-format msgid "'%s' security requires '%s=%s'" msgstr "\"%s\" 安全需要 \"%s=%s\"" -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:970 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:971 #, c-format msgid "'%s' security requires '%s' setting presence" msgstr "\"%s\" 安全需要 \"%s\" 设置存在" -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:995 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:996 #, c-format msgid "'%d' value is out of range <0-3>" -msgstr "'%d' 值超出了 范围 <0-3>" +msgstr "\"%d\" 值超出了 范围 <0-3>" -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1072 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1073 #, c-format msgid "'%s' can only be used with '%s=%s' (WEP)" msgstr "\"%s\" 只能与 \"%s=%s\"(WEP)共用" -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1109 -#, fuzzy, c-format -msgid "" -"'%s' can only be used with 'owe', 'wpa-psk', 'sae', 'wpa-eap' or 'wpa-eap-" -"suite-b-192' key management" -msgstr "'%s' 只能用于 'wpa-eap'、'wpa-psk' 或 'sae' 密钥管理 " - -#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1127 +#: ../src/libnm-core-impl/nm-setting-wireless-security.c:1111 #, c-format +#| msgid "" +#| "'%s' can only be used with 'wpa-eap', 'wpa-psk' or 'sae' key management " msgid "" -"pmf can only be 'default' or 'required' when using 'owe', 'sae' or 'wpa-eap-" -"suite-b-192' key management" +"'%s' can only be used with 'wpa-eap', 'wpa-eap-suite-b-192', 'wpa-psk' or " +"'sae' key management " msgstr "" +"\"%s\" 只能用于 \"wpa-eap\"、\"wpa-eap-suite-b-192\"、\"wpa-psk\" 或 \"sae\" " +"密钥管理 " #: ../src/libnm-core-impl/nm-setting-wireless.c:813 #, c-format @@ -3305,7 +3303,7 @@ msgstr "\"%s\" 需要设置 \"%s\" 属性" #: ../src/libnm-core-impl/nm-setting-wireless.c:869 #, c-format msgid "'%s' requires '%s' and '%s' property" -msgstr "'%s' 需要 '%s' 和 '%s' 属性" +msgstr "\"%s\" 需要 \"%s\" 和 \"%s\" 属性" #: ../src/libnm-core-impl/nm-setting-wireless.c:981 #: ../src/libnm-core-impl/nm-team-utils.c:2253 @@ -3323,7 +3321,7 @@ msgstr "WLAN 唤醒正在尝试设定未知的标记" #: ../src/libnm-core-impl/nm-setting-wireless.c:1018 msgid "AP isolation can be set only in AP mode" -msgstr "" +msgstr "AP 隔离只能在 AP 模式下设定" #: ../src/libnm-core-impl/nm-setting-wireless.c:1042 #, c-format @@ -3332,7 +3330,7 @@ msgstr "mac-address-randomization 和 cloned-mac-address 的值冲突" #: ../src/libnm-core-impl/nm-setting-wpan.c:171 msgid "page must be defined along with a channel" -msgstr "页需要和一个频道定义" +msgstr "页需要和一个信道定义" #: ../src/libnm-core-impl/nm-setting-wpan.c:180 #, c-format @@ -3342,7 +3340,7 @@ msgstr "页需要在 %d 和 %d 之间" #: ../src/libnm-core-impl/nm-setting-wpan.c:191 #, c-format msgid "channel must not be between %d and %d" -msgstr "频道不能在 %d 和 %d 之间" +msgstr "信道不能在 %d 和 %d 之间" #: ../src/libnm-core-impl/nm-setting.c:795 #, c-format @@ -3446,228 +3444,228 @@ msgstr "无效的 D-Bus 类型 \"%s\"" msgid "invalid link-watchers: %s" msgstr "无效的 link-watcher:%s" -#: ../src/libnm-core-impl/nm-utils.c:2227 +#: ../src/libnm-core-impl/nm-utils.c:2233 #, c-format msgid "'%s' is not a valid handle." msgstr "\"%s\" 不是有效的处理模块。" -#: ../src/libnm-core-impl/nm-utils.c:2375 +#: ../src/libnm-core-impl/nm-utils.c:2381 #, c-format msgid "'%s' unexpected: parent already specified." msgstr "意外的 \"%s\":已指定上级。" -#: ../src/libnm-core-impl/nm-utils.c:2393 +#: ../src/libnm-core-impl/nm-utils.c:2399 #, c-format msgid "invalid handle: '%s'" msgstr "无效的句柄:\"%s\"" -#: ../src/libnm-core-impl/nm-utils.c:2415 +#: ../src/libnm-core-impl/nm-utils.c:2421 msgid "parent not specified." msgstr "未指定上级。" -#: ../src/libnm-core-impl/nm-utils.c:2479 +#: ../src/libnm-core-impl/nm-utils.c:2485 #, c-format msgid "unsupported qdisc option: '%s'." msgstr "不支持的排队规则(qdisc)选项:\"%s\"。" -#: ../src/libnm-core-impl/nm-utils.c:2609 +#: ../src/libnm-core-impl/nm-utils.c:2615 msgid "action name missing." msgstr "操作名缺失。" -#: ../src/libnm-core-impl/nm-utils.c:2634 +#: ../src/libnm-core-impl/nm-utils.c:2641 #, c-format msgid "unsupported action option: '%s'." msgstr "不支持的操作选项:\"%s\"。" -#: ../src/libnm-core-impl/nm-utils.c:2771 +#: ../src/libnm-core-impl/nm-utils.c:2780 msgid "invalid action: " -msgstr "无效操作: " +msgstr "无效操作:" -#: ../src/libnm-core-impl/nm-utils.c:2775 +#: ../src/libnm-core-impl/nm-utils.c:2784 #, c-format msgid "unsupported tfilter option: '%s'." msgstr "不支持的流量过滤器(tfilter)选项:\"%s\"。" -#: ../src/libnm-core-impl/nm-utils.c:3163 +#: ../src/libnm-core-impl/nm-utils.c:3385 #, c-format msgid "failed stat file %s: %s" msgstr "统计文件 %s 失败:%s" -#: ../src/libnm-core-impl/nm-utils.c:3174 +#: ../src/libnm-core-impl/nm-utils.c:3396 #, c-format msgid "not a file (%s)" msgstr "不是一个文件(%s)" -#: ../src/libnm-core-impl/nm-utils.c:3185 +#: ../src/libnm-core-impl/nm-utils.c:3407 #, c-format msgid "invalid file owner %d for %s" msgstr "对 %d%s 无效的文件所有者" -#: ../src/libnm-core-impl/nm-utils.c:3197 +#: ../src/libnm-core-impl/nm-utils.c:3419 #, c-format msgid "file permissions for %s" msgstr "%s 的文件权限" -#: ../src/libnm-core-impl/nm-utils.c:3207 +#: ../src/libnm-core-impl/nm-utils.c:3429 #, c-format msgid "reject %s" msgstr "拒绝 %s" -#: ../src/libnm-core-impl/nm-utils.c:3227 +#: ../src/libnm-core-impl/nm-utils.c:3449 #, c-format msgid "path is not absolute (%s)" msgstr "路径不是绝对路径(%s)" -#: ../src/libnm-core-impl/nm-utils.c:3242 +#: ../src/libnm-core-impl/nm-utils.c:3464 #, c-format msgid "Plugin file does not exist (%s)" msgstr "插件文件不存在(%s)" -#: ../src/libnm-core-impl/nm-utils.c:3251 +#: ../src/libnm-core-impl/nm-utils.c:3473 #, c-format msgid "Plugin is not a valid file (%s)" msgstr "插件不是有效的文件(%s)" -#: ../src/libnm-core-impl/nm-utils.c:3262 +#: ../src/libnm-core-impl/nm-utils.c:3484 #, c-format msgid "libtool archives are not supported (%s)" msgstr "不支持 libtool 归档(%s)" -#: ../src/libnm-core-impl/nm-utils.c:3339 +#: ../src/libnm-core-impl/nm-utils.c:3561 #, c-format msgid "Could not find \"%s\" binary" msgstr "无法找到 \"%s\" 二进制文件" -#: ../src/libnm-core-impl/nm-utils.c:4183 +#: ../src/libnm-core-impl/nm-utils.c:4405 msgid "unknown secret flags" msgstr "未知的 secret 标记" -#: ../src/libnm-core-impl/nm-utils.c:4193 +#: ../src/libnm-core-impl/nm-utils.c:4415 msgid "conflicting secret flags" msgstr "冲突的 secret 标记" -#: ../src/libnm-core-impl/nm-utils.c:4204 +#: ../src/libnm-core-impl/nm-utils.c:4426 msgid "secret flags must not be \"not-required\"" msgstr "secret 标记不能为 \"not-required\"" -#: ../src/libnm-core-impl/nm-utils.c:4212 +#: ../src/libnm-core-impl/nm-utils.c:4434 msgid "unsupported secret flags" msgstr "不支持的 secret 标记" -#: ../src/libnm-core-impl/nm-utils.c:4242 +#: ../src/libnm-core-impl/nm-utils.c:4464 msgid "can't be simultaneously disabled and enabled" msgstr "不能同时启用和禁用" -#: ../src/libnm-core-impl/nm-utils.c:4250 +#: ../src/libnm-core-impl/nm-utils.c:4472 msgid "WPS is required" msgstr "需要 WPS" -#: ../src/libnm-core-impl/nm-utils.c:4318 +#: ../src/libnm-core-impl/nm-utils.c:4540 #, c-format msgid "not a valid ethernet MAC address for mask at position %lld" msgstr "对于 %lld 位置的掩码,该以太网 MAC 地址无效" -#: ../src/libnm-core-impl/nm-utils.c:4337 +#: ../src/libnm-core-impl/nm-utils.c:4559 #, c-format msgid "not a valid ethernet MAC address #%u at position %lld" msgstr "在位置 %u%lld,该以太网 MAC 地址 # 无效" -#: ../src/libnm-core-impl/nm-utils.c:4952 +#: ../src/libnm-core-impl/nm-utils.c:5191 msgid "not valid utf-8" msgstr "不是有效的 utf-8" -#: ../src/libnm-core-impl/nm-utils.c:4973 -#: ../src/libnm-core-impl/nm-utils.c:5026 +#: ../src/libnm-core-impl/nm-utils.c:5212 +#: ../src/libnm-core-impl/nm-utils.c:5265 msgid "is not a JSON object" msgstr "不是 JSON 对象" -#: ../src/libnm-core-impl/nm-utils.c:5002 +#: ../src/libnm-core-impl/nm-utils.c:5241 msgid "value is NULL" msgstr "值为 NULL" -#: ../src/libnm-core-impl/nm-utils.c:5002 +#: ../src/libnm-core-impl/nm-utils.c:5241 msgid "value is empty" msgstr "值为空" -#: ../src/libnm-core-impl/nm-utils.c:5014 +#: ../src/libnm-core-impl/nm-utils.c:5253 #, c-format msgid "invalid JSON at position %d (%s)" msgstr "位置 %d 有无效的 JSON(%s)" -#: ../src/libnm-core-impl/nm-utils.c:5142 -#: ../src/libnm-core-impl/nm-utils.c:5162 +#: ../src/libnm-core-impl/nm-utils.c:5381 +#: ../src/libnm-core-impl/nm-utils.c:5401 msgid "unterminated escape sequence" msgstr "未结束的转义序列" -#: ../src/libnm-core-impl/nm-utils.c:5188 +#: ../src/libnm-core-impl/nm-utils.c:5427 #, c-format msgid "unknown attribute '%s'" msgstr "未知属性 \"%s\"" -#: ../src/libnm-core-impl/nm-utils.c:5206 +#: ../src/libnm-core-impl/nm-utils.c:5445 #, c-format msgid "missing key-value separator '%c' after '%s'" msgstr "在 \"%2$s\" 后缺少键值对分隔符 \"%1$c\"" -#: ../src/libnm-core-impl/nm-utils.c:5226 +#: ../src/libnm-core-impl/nm-utils.c:5465 #, c-format msgid "invalid uint32 value '%s' for attribute '%s'" msgstr "uint32 值 \"%1$s\" 对属性 \"%2$s\" 无效" -#: ../src/libnm-core-impl/nm-utils.c:5240 +#: ../src/libnm-core-impl/nm-utils.c:5479 #, c-format msgid "invalid int32 value '%s' for attribute '%s'" msgstr "uint32 值 \"%s\" 对属性 \"%s\" 无效" -#: ../src/libnm-core-impl/nm-utils.c:5253 +#: ../src/libnm-core-impl/nm-utils.c:5492 #, c-format msgid "invalid uint64 value '%s' for attribute '%s'" msgstr "uint8 值 \"%s\" 对属性 \"%s\" 无效" -#: ../src/libnm-core-impl/nm-utils.c:5266 +#: ../src/libnm-core-impl/nm-utils.c:5505 #, c-format msgid "invalid uint8 value '%s' for attribute '%s'" msgstr "uint8 值 \"%1$s\" 对属性 \"%2$s\" 无效" -#: ../src/libnm-core-impl/nm-utils.c:5280 +#: ../src/libnm-core-impl/nm-utils.c:5519 #, c-format msgid "invalid boolean value '%s' for attribute '%s'" msgstr "布尔值 \"%1$s\" 对属性 \"%2$s\" 无效" -#: ../src/libnm-core-impl/nm-utils.c:5294 +#: ../src/libnm-core-impl/nm-utils.c:5533 #, c-format msgid "unsupported attribute '%s' of type '%s'" msgstr "不支持类型 \"%2$s\" 的属性 \"%1$s\"" -#: ../src/libnm-core-impl/nm-utils.c:5596 +#: ../src/libnm-core-impl/nm-utils.c:5835 #, c-format msgid "Bridge VLANs %d and %d are not sorted by ascending vid" msgstr "网桥 VLANs %d 和 %d 没有根据生序 vid 进行排序" -#: ../src/libnm-core-impl/nm-utils.c:5620 +#: ../src/libnm-core-impl/nm-utils.c:5859 #, c-format msgid "duplicate bridge VLAN vid %u" msgstr "重复的网桥 VLAN vid %u" -#: ../src/libnm-core-impl/nm-utils.c:5632 +#: ../src/libnm-core-impl/nm-utils.c:5871 msgid "only one VLAN can be the PVID" msgstr "只有一个 VLAN 可以是 PVID" -#: ../src/libnm-core-impl/nm-utils.c:5677 +#: ../src/libnm-core-impl/nm-utils.c:5916 #, c-format msgid "unknown flags 0x%x" msgstr "未知标志 0x%x" -#: ../src/libnm-core-impl/nm-utils.c:5689 +#: ../src/libnm-core-impl/nm-utils.c:5928 msgid "" "'fqdn-no-update' and 'fqdn-serv-update' flags cannot be set at the same time" -msgstr "不能同时设置 'fqdn-no-update' 和 'fqdn-serv-update' 标志" +msgstr "不能同时设置 \"fqdn-no-update\" 和 \"fqdn-serv-update\" 标志" -#: ../src/libnm-core-impl/nm-utils.c:5700 +#: ../src/libnm-core-impl/nm-utils.c:5939 msgid "'fqdn-clear-flags' flag is incompatible with other FQDN flags" -msgstr "'fqdn-clear-flags' 标志与其他 FQDN 标志不兼容" +msgstr "\"fqdn-clear-flags\" 标志与其他 FQDN 标志不兼容" -#: ../src/libnm-core-impl/nm-utils.c:5708 +#: ../src/libnm-core-impl/nm-utils.c:5947 msgid "DHCPv6 does not support the E (encoded) FQDN flag" msgstr "DHCPv6 不支持 E(编码)FQDN 标志" @@ -3753,33 +3751,33 @@ msgstr "缺少 VPN 插件信息的名称" msgid "missing service for VPN plugin info" msgstr "缺少 VPN 插件信息的服务" -#: ../src/libnm-glib-aux/nm-shared-utils.c:2453 +#: ../src/libnm-glib-aux/nm-shared-utils.c:2367 #, c-format msgid "object class '%s' has no property named '%s'" msgstr "对象类 \"%s\" 没有名为 \"%s\" 的属性" -#: ../src/libnm-glib-aux/nm-shared-utils.c:2462 +#: ../src/libnm-glib-aux/nm-shared-utils.c:2376 #, c-format msgid "property '%s' of object class '%s' is not writable" msgstr "对象类 \"%2$s\" 的 \"%1$s\" 属性是不可写的" -#: ../src/libnm-glib-aux/nm-shared-utils.c:2471 +#: ../src/libnm-glib-aux/nm-shared-utils.c:2385 #, c-format msgid "" "construct property \"%s\" for object '%s' can't be set after construction" msgstr "对象 \"%2$s\" 的构造属性 \"%1$s\" 在构造后不能被设定" -#: ../src/libnm-glib-aux/nm-shared-utils.c:2482 +#: ../src/libnm-glib-aux/nm-shared-utils.c:2396 #, c-format msgid "'%s::%s' is not a valid property name; '%s' is not a GObject subtype" msgstr "\"%s::%s\" 不是有效的属性名;\"%s\" 不是 GObject 子类型" -#: ../src/libnm-glib-aux/nm-shared-utils.c:2495 +#: ../src/libnm-glib-aux/nm-shared-utils.c:2409 #, c-format msgid "unable to set property '%s' of type '%s' from value of type '%s'" msgstr "无法从类型 \"%3$s\" 的值设定类型为 \"%2$s\" 的属性 \"%1$s\"" -#: ../src/libnm-glib-aux/nm-shared-utils.c:2507 +#: ../src/libnm-glib-aux/nm-shared-utils.c:2421 #, c-format msgid "" "value \"%s\" of type '%s' is invalid or out of range for property '%s' of " @@ -3787,46 +3785,46 @@ msgid "" msgstr "" "类型 \"%2$s\" 的值 \"%1$s\" 无效或超出类型为 \"%4$s\" 的属性 \"%3$s\" 范围" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5405 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5287 msgid "interface name is missing" msgstr "缺少接口名" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5413 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5295 msgid "interface name is too short" msgstr "接口名太短" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5421 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5303 msgid "interface name is reserved" msgstr "接口名被保留" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5434 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5316 msgid "interface name contains an invalid character" msgstr "接口名包含无效字符" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5442 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5324 msgid "interface name is longer than 15 characters" msgstr "接口名长度超过 15 字符" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5467 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5349 #, c-format msgid "'%%' is not allowed in interface names" -msgstr "接口名称中不允许使用 '%%'。" +msgstr "接口名称中不允许使用 \"%%\"" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5479 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5361 #, c-format msgid "'%s' is not allowed as interface name" -msgstr "''%s不允许作为接口名" +msgstr "\"\"%s不允许作为接口名" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5501 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5383 msgid "" "interface name must be alphanumerical with no forward or backward slashes" -msgstr "接口名称必须是字母数字,没有正反斜杠。" +msgstr "接口名称必须是字母数字,没有正反斜杠" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5518 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5400 msgid "interface name must not be empty" msgstr "接口名称不能为空" -#: ../src/libnm-glib-aux/nm-shared-utils.c:5526 +#: ../src/libnm-glib-aux/nm-shared-utils.c:5408 msgid "interface name must be UTF-8 encoded" msgstr "接口名称必须是 UTF-8 编码" @@ -3843,513 +3841,513 @@ msgstr "未知的日志域 \"%s\"" #. TRANSLATORS: the first %s is the partial value entered by #. * the user, the second %s a list of compatible values. #. -#: ../src/libnmc-base/nm-client-utils.c:108 -#: ../src/libnmc-base/nm-client-utils.c:152 +#: ../src/libnmc-base/nm-client-utils.c:106 +#: ../src/libnmc-base/nm-client-utils.c:145 #, c-format msgid "'%s' is ambiguous (%s)" msgstr "\"%s\" 不明确(%s)" -#: ../src/libnmc-base/nm-client-utils.c:123 +#: ../src/libnmc-base/nm-client-utils.c:120 #, c-format msgid "'%s' is not valid; use [%s] or [%s]" msgstr "\"%s\" 无效,请使用 [%s] 或 [%s]" -#: ../src/libnmc-base/nm-client-utils.c:176 +#: ../src/libnmc-base/nm-client-utils.c:161 #, c-format msgid "'%s' is not valid; use [%s], [%s] or [%s]" msgstr "\"%s\" 无效,请使用 [%s]、[%s] 或 [%s]" -#: ../src/libnmc-base/nm-client-utils.c:230 +#: ../src/libnmc-base/nm-client-utils.c:213 #, c-format msgid "'%s' is ambiguous: %s" msgstr "\"%s\" 不明确:%s" -#: ../src/libnmc-base/nm-client-utils.c:243 +#: ../src/libnmc-base/nm-client-utils.c:222 #, c-format msgid "missing name, try one of [%s]" msgstr "缺少名称,请尝试使用 [%s] 之一。" -#: ../src/libnmc-base/nm-client-utils.c:248 ../src/nmcli/connections.c:3543 -#: ../src/nmcli/connections.c:3601 +#: ../src/libnmc-base/nm-client-utils.c:224 ../src/nmcli/connections.c:3542 +#: ../src/nmcli/connections.c:3600 #, c-format msgid "'%s' not among [%s]" msgstr "\"%s\" 不在 [%s] 中" -#: ../src/libnmc-base/nm-client-utils.c:291 -#: ../src/libnmc-base/nm-client-utils.c:305 -#: ../src/libnmc-base/nm-client-utils.c:341 -#: ../src/libnmc-base/nm-client-utils.c:346 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1818 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1849 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:2793 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:2850 ../src/nmcli/common.c:1453 -#: ../src/nmcli/connections.c:73 ../src/nmcli/connections.c:83 -#: ../src/nmcli/devices.c:476 ../src/nmcli/devices.c:583 -#: ../src/nmcli/devices.c:589 ../src/nmcli/general.c:30 -#: ../src/nmcli/general.c:85 ../src/nmcli/general.c:91 +#: ../src/libnmc-base/nm-client-utils.c:265 +#: ../src/libnmc-base/nm-client-utils.c:279 +#: ../src/libnmc-base/nm-client-utils.c:315 +#: ../src/libnmc-base/nm-client-utils.c:320 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1768 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1799 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:2743 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:2800 ../src/nmcli/common.c:1497 +#: ../src/nmcli/connections.c:72 ../src/nmcli/connections.c:82 +#: ../src/nmcli/devices.c:474 ../src/nmcli/devices.c:581 +#: ../src/nmcli/devices.c:587 ../src/nmcli/general.c:29 +#: ../src/nmcli/general.c:84 ../src/nmcli/general.c:90 msgid "unknown" msgstr "未知" -#: ../src/libnmc-base/nm-client-utils.c:292 +#: ../src/libnmc-base/nm-client-utils.c:266 msgid "unmanaged" msgstr "未托管" -#: ../src/libnmc-base/nm-client-utils.c:293 +#: ../src/libnmc-base/nm-client-utils.c:267 msgid "unavailable" msgstr "不可用" -#: ../src/libnmc-base/nm-client-utils.c:294 ../src/nmcli/general.c:39 +#: ../src/libnmc-base/nm-client-utils.c:268 ../src/nmcli/general.c:38 msgid "disconnected" msgstr "已断开" -#: ../src/libnmc-base/nm-client-utils.c:295 +#: ../src/libnmc-base/nm-client-utils.c:269 msgid "connecting (prepare)" msgstr "连接中(准备)" -#: ../src/libnmc-base/nm-client-utils.c:296 +#: ../src/libnmc-base/nm-client-utils.c:270 msgid "connecting (configuring)" msgstr "连接中(正在配置)" -#: ../src/libnmc-base/nm-client-utils.c:297 +#: ../src/libnmc-base/nm-client-utils.c:271 msgid "connecting (need authentication)" msgstr "连接中(需要验证)" -#: ../src/libnmc-base/nm-client-utils.c:298 +#: ../src/libnmc-base/nm-client-utils.c:272 msgid "connecting (getting IP configuration)" msgstr "连接中(正在获取 IP 配置)" -#: ../src/libnmc-base/nm-client-utils.c:299 +#: ../src/libnmc-base/nm-client-utils.c:273 msgid "connecting (checking IP connectivity)" msgstr "连接中(正在检查 IP 连接性)" -#: ../src/libnmc-base/nm-client-utils.c:301 +#: ../src/libnmc-base/nm-client-utils.c:275 msgid "connecting (starting secondary connections)" msgstr "连接中(正在启动次级连接)" -#: ../src/libnmc-base/nm-client-utils.c:302 ../src/nmcli/general.c:37 +#: ../src/libnmc-base/nm-client-utils.c:276 ../src/nmcli/general.c:36 msgid "connected" msgstr "已连接" -#: ../src/libnmc-base/nm-client-utils.c:303 ../src/nmcli/connections.c:76 +#: ../src/libnmc-base/nm-client-utils.c:277 ../src/nmcli/connections.c:75 msgid "deactivating" msgstr "停用中" -#: ../src/libnmc-base/nm-client-utils.c:304 +#: ../src/libnmc-base/nm-client-utils.c:278 msgid "connection failed" msgstr "连接失败" -#: ../src/libnmc-base/nm-client-utils.c:311 -#: ../src/libnmc-base/nm-client-utils.c:312 -#: ../src/libnmc-base/nm-client-utils.c:313 -#: ../src/libnmc-base/nm-client-utils.c:314 -#: ../src/libnmc-base/nm-client-utils.c:315 -#: ../src/libnmc-base/nm-client-utils.c:316 +#: ../src/libnmc-base/nm-client-utils.c:285 +#: ../src/libnmc-base/nm-client-utils.c:286 +#: ../src/libnmc-base/nm-client-utils.c:287 +#: ../src/libnmc-base/nm-client-utils.c:288 +#: ../src/libnmc-base/nm-client-utils.c:289 +#: ../src/libnmc-base/nm-client-utils.c:290 msgid "connecting (externally)" msgstr "连接(外部)" -#: ../src/libnmc-base/nm-client-utils.c:317 +#: ../src/libnmc-base/nm-client-utils.c:291 msgid "connected (externally)" msgstr "连接(外部)" -#: ../src/libnmc-base/nm-client-utils.c:318 -#: ../src/libnmc-base/nm-client-utils.c:319 +#: ../src/libnmc-base/nm-client-utils.c:292 +#: ../src/libnmc-base/nm-client-utils.c:293 msgid "deactivating (externally)" msgstr "取消激活(外部)" -#: ../src/libnmc-base/nm-client-utils.c:342 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:880 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:2785 -#: ../src/nmcli/connections.c:5295 ../src/nmcli/connections.c:7221 -#: ../src/nmcli/connections.c:7222 ../src/nmcli/devices.c:582 -#: ../src/nmcli/devices.c:588 ../src/nmcli/devices.c:1363 -#: ../src/nmcli/general.c:92 ../src/nmcli/utils.h:311 +#: ../src/libnmc-base/nm-client-utils.c:316 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:879 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:2735 +#: ../src/nmcli/connections.c:5291 ../src/nmcli/connections.c:7217 +#: ../src/nmcli/connections.c:7218 ../src/nmcli/devices.c:580 +#: ../src/nmcli/devices.c:586 ../src/nmcli/devices.c:1349 +#: ../src/nmcli/general.c:91 ../src/nmcli/utils.h:311 msgid "yes" msgstr "是" -#: ../src/libnmc-base/nm-client-utils.c:343 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:880 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:2788 -#: ../src/nmcli/connections.c:5294 ../src/nmcli/connections.c:7221 -#: ../src/nmcli/connections.c:7222 ../src/nmcli/devices.c:582 -#: ../src/nmcli/devices.c:588 ../src/nmcli/devices.c:1363 -#: ../src/nmcli/general.c:93 ../src/nmcli/utils.h:311 +#: ../src/libnmc-base/nm-client-utils.c:317 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:879 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:2738 +#: ../src/nmcli/connections.c:5290 ../src/nmcli/connections.c:7217 +#: ../src/nmcli/connections.c:7218 ../src/nmcli/devices.c:580 +#: ../src/nmcli/devices.c:586 ../src/nmcli/devices.c:1349 +#: ../src/nmcli/general.c:92 ../src/nmcli/utils.h:311 msgid "no" msgstr "否" -#: ../src/libnmc-base/nm-client-utils.c:344 +#: ../src/libnmc-base/nm-client-utils.c:318 msgid "yes (guessed)" msgstr "是(猜测)" -#: ../src/libnmc-base/nm-client-utils.c:345 +#: ../src/libnmc-base/nm-client-utils.c:319 msgid "no (guessed)" msgstr "否(猜测)" -#: ../src/libnmc-base/nm-client-utils.c:353 +#: ../src/libnmc-base/nm-client-utils.c:327 msgid "No reason given" msgstr "未给出原因" #. We should not really come here -#: ../src/libnmc-base/nm-client-utils.c:354 ../src/nmcli/connections.c:3563 -#: ../src/nmcli/connections.c:3622 +#: ../src/libnmc-base/nm-client-utils.c:328 ../src/nmcli/connections.c:3562 +#: ../src/nmcli/connections.c:3621 #, c-format msgid "Unknown error" msgstr "未知错误" -#: ../src/libnmc-base/nm-client-utils.c:355 +#: ../src/libnmc-base/nm-client-utils.c:329 msgid "Device is now managed" msgstr "设备现在已托管" -#: ../src/libnmc-base/nm-client-utils.c:356 +#: ../src/libnmc-base/nm-client-utils.c:330 msgid "Device is now unmanaged" msgstr "设备现在未托管" -#: ../src/libnmc-base/nm-client-utils.c:358 +#: ../src/libnmc-base/nm-client-utils.c:332 msgid "The device could not be readied for configuration" msgstr "设备配置未就绪" -#: ../src/libnmc-base/nm-client-utils.c:361 +#: ../src/libnmc-base/nm-client-utils.c:335 msgid "" "IP configuration could not be reserved (no available address, timeout, etc.)" msgstr "IP 配置无法保留(无可用地址、超时等)" -#: ../src/libnmc-base/nm-client-utils.c:363 +#: ../src/libnmc-base/nm-client-utils.c:337 msgid "The IP configuration is no longer valid" msgstr "IP 配置不再有效" -#: ../src/libnmc-base/nm-client-utils.c:365 +#: ../src/libnmc-base/nm-client-utils.c:339 msgid "Secrets were required, but not provided" msgstr "需要密钥,但未提供" -#: ../src/libnmc-base/nm-client-utils.c:367 +#: ../src/libnmc-base/nm-client-utils.c:341 msgid "802.1X supplicant disconnected" msgstr "802.1X 请求方已断开连接" -#: ../src/libnmc-base/nm-client-utils.c:369 +#: ../src/libnmc-base/nm-client-utils.c:343 msgid "802.1X supplicant configuration failed" msgstr "802.1X 请求方配置失败" -#: ../src/libnmc-base/nm-client-utils.c:370 +#: ../src/libnmc-base/nm-client-utils.c:344 msgid "802.1X supplicant failed" msgstr "802.1X 请求方失败" -#: ../src/libnmc-base/nm-client-utils.c:372 +#: ../src/libnmc-base/nm-client-utils.c:346 msgid "802.1X supplicant took too long to authenticate" msgstr "802.1X 请求方验证时间过长" -#: ../src/libnmc-base/nm-client-utils.c:374 +#: ../src/libnmc-base/nm-client-utils.c:348 msgid "PPP service failed to start" msgstr "PPP 服务无法启动" -#: ../src/libnmc-base/nm-client-utils.c:375 +#: ../src/libnmc-base/nm-client-utils.c:349 msgid "PPP service disconnected" msgstr "PPP 服务已断开连接" # auto translated by TM merge from project: control-center, version: 3.8.3, DocId: gnome-control-center-2.0 -#: ../src/libnmc-base/nm-client-utils.c:376 +#: ../src/libnmc-base/nm-client-utils.c:350 msgid "PPP failed" msgstr "PPP 失败" -#: ../src/libnmc-base/nm-client-utils.c:378 +#: ../src/libnmc-base/nm-client-utils.c:352 msgid "DHCP client failed to start" msgstr "DHCP 客户端启动失败" # auto translated by TM merge from project: control-center, version: 3.8.3, DocId: gnome-control-center-2.0 -#: ../src/libnmc-base/nm-client-utils.c:379 +#: ../src/libnmc-base/nm-client-utils.c:353 msgid "DHCP client error" msgstr "DHCP 客户端错误" -#: ../src/libnmc-base/nm-client-utils.c:380 +#: ../src/libnmc-base/nm-client-utils.c:354 msgid "DHCP client failed" msgstr "DHCP 客户端失败" -#: ../src/libnmc-base/nm-client-utils.c:382 +#: ../src/libnmc-base/nm-client-utils.c:356 msgid "Shared connection service failed to start" msgstr "共享连接服务启动失败" -#: ../src/libnmc-base/nm-client-utils.c:384 +#: ../src/libnmc-base/nm-client-utils.c:358 msgid "Shared connection service failed" msgstr "共享连接服务失败" -#: ../src/libnmc-base/nm-client-utils.c:386 +#: ../src/libnmc-base/nm-client-utils.c:360 msgid "AutoIP service failed to start" msgstr "自动 IP(AutoIP)服务无法启动" -#: ../src/libnmc-base/nm-client-utils.c:387 +#: ../src/libnmc-base/nm-client-utils.c:361 msgid "AutoIP service error" msgstr "自动 IP(AutoIP)服务出错" -#: ../src/libnmc-base/nm-client-utils.c:388 +#: ../src/libnmc-base/nm-client-utils.c:362 msgid "AutoIP service failed" msgstr "自动 IP(AutoIP)服务失败" -#: ../src/libnmc-base/nm-client-utils.c:389 +#: ../src/libnmc-base/nm-client-utils.c:363 msgid "The line is busy" msgstr "线路正忙" -#: ../src/libnmc-base/nm-client-utils.c:390 +#: ../src/libnmc-base/nm-client-utils.c:364 msgid "No dial tone" msgstr "无拨号音" -#: ../src/libnmc-base/nm-client-utils.c:392 +#: ../src/libnmc-base/nm-client-utils.c:366 msgid "No carrier could be established" msgstr "无法建立载波" -#: ../src/libnmc-base/nm-client-utils.c:394 +#: ../src/libnmc-base/nm-client-utils.c:368 msgid "The dialing request timed out" msgstr "拨号请求超时" -#: ../src/libnmc-base/nm-client-utils.c:396 +#: ../src/libnmc-base/nm-client-utils.c:370 msgid "The dialing attempt failed" msgstr "拨号尝试失败" -#: ../src/libnmc-base/nm-client-utils.c:398 +#: ../src/libnmc-base/nm-client-utils.c:372 msgid "Modem initialization failed" msgstr "调制解调器初始化失败" -#: ../src/libnmc-base/nm-client-utils.c:400 +#: ../src/libnmc-base/nm-client-utils.c:374 msgid "Failed to select the specified APN" msgstr "无法选择指定的 APN" -#: ../src/libnmc-base/nm-client-utils.c:402 +#: ../src/libnmc-base/nm-client-utils.c:376 msgid "Not searching for networks" msgstr "不搜索网络" -#: ../src/libnmc-base/nm-client-utils.c:404 +#: ../src/libnmc-base/nm-client-utils.c:378 msgid "Network registration denied" msgstr "网络注册遭拒绝" -#: ../src/libnmc-base/nm-client-utils.c:406 +#: ../src/libnmc-base/nm-client-utils.c:380 msgid "Network registration timed out" msgstr "网络注册超时" -#: ../src/libnmc-base/nm-client-utils.c:408 +#: ../src/libnmc-base/nm-client-utils.c:382 msgid "Failed to register with the requested network" msgstr "注册请求的网络失败" -#: ../src/libnmc-base/nm-client-utils.c:409 +#: ../src/libnmc-base/nm-client-utils.c:383 msgid "PIN check failed" msgstr "PIN 检查失败" -#: ../src/libnmc-base/nm-client-utils.c:411 +#: ../src/libnmc-base/nm-client-utils.c:385 msgid "Necessary firmware for the device may be missing" msgstr "该设备所需固件可能缺失" -#: ../src/libnmc-base/nm-client-utils.c:412 +#: ../src/libnmc-base/nm-client-utils.c:386 msgid "The device was removed" msgstr "设备已被移除" -#: ../src/libnmc-base/nm-client-utils.c:413 +#: ../src/libnmc-base/nm-client-utils.c:387 msgid "NetworkManager went to sleep" msgstr "网络管理器已挂起" -#: ../src/libnmc-base/nm-client-utils.c:415 +#: ../src/libnmc-base/nm-client-utils.c:389 msgid "The device's active connection disappeared" msgstr "设备的活动连接已消失" -#: ../src/libnmc-base/nm-client-utils.c:417 +#: ../src/libnmc-base/nm-client-utils.c:391 msgid "Device disconnected by user or client" msgstr "用户或客户端断开了设备连接" -#: ../src/libnmc-base/nm-client-utils.c:418 +#: ../src/libnmc-base/nm-client-utils.c:392 msgid "Carrier/link changed" msgstr "载波/链路已更改" -#: ../src/libnmc-base/nm-client-utils.c:420 +#: ../src/libnmc-base/nm-client-utils.c:394 msgid "The device's existing connection was assumed" msgstr "假定设备已有连接" -#: ../src/libnmc-base/nm-client-utils.c:422 +#: ../src/libnmc-base/nm-client-utils.c:396 msgid "The supplicant is now available" msgstr "客户端目前可用" -#: ../src/libnmc-base/nm-client-utils.c:424 +#: ../src/libnmc-base/nm-client-utils.c:398 msgid "The modem could not be found" msgstr "未找到调制解调器" -#: ../src/libnmc-base/nm-client-utils.c:426 +#: ../src/libnmc-base/nm-client-utils.c:400 msgid "The Bluetooth connection failed or timed out" msgstr "蓝牙连接失败或超时" -#: ../src/libnmc-base/nm-client-utils.c:428 +#: ../src/libnmc-base/nm-client-utils.c:402 msgid "GSM Modem's SIM card not inserted" msgstr "GSM 调制解调器的 SIM 卡未插入" -#: ../src/libnmc-base/nm-client-utils.c:430 +#: ../src/libnmc-base/nm-client-utils.c:404 msgid "GSM Modem's SIM PIN required" msgstr "GSM 调制解调器的 SIM 需要 PIN 码" -#: ../src/libnmc-base/nm-client-utils.c:432 +#: ../src/libnmc-base/nm-client-utils.c:406 msgid "GSM Modem's SIM PUK required" msgstr "GSM 调制解调器的 SIM 需要 PUK 码" -#: ../src/libnmc-base/nm-client-utils.c:433 +#: ../src/libnmc-base/nm-client-utils.c:407 msgid "GSM Modem's SIM wrong" msgstr "GSM 调制解调器的 SIM 错误" -#: ../src/libnmc-base/nm-client-utils.c:435 +#: ../src/libnmc-base/nm-client-utils.c:409 msgid "InfiniBand device does not support connected mode" msgstr "InfiniBand 设备不支持已连接的模式" -#: ../src/libnmc-base/nm-client-utils.c:437 +#: ../src/libnmc-base/nm-client-utils.c:411 msgid "A dependency of the connection failed" msgstr "连接的依赖关系失败" -#: ../src/libnmc-base/nm-client-utils.c:439 +#: ../src/libnmc-base/nm-client-utils.c:413 msgid "A problem with the RFC 2684 Ethernet over ADSL bridge" msgstr "ADSL 网桥上的 RFC 2684 以太网出现问题" -#: ../src/libnmc-base/nm-client-utils.c:441 +#: ../src/libnmc-base/nm-client-utils.c:415 msgid "ModemManager is unavailable" msgstr "ModemManager 不可用" -#: ../src/libnmc-base/nm-client-utils.c:443 +#: ../src/libnmc-base/nm-client-utils.c:417 msgid "The Wi-Fi network could not be found" msgstr "未找到 Wi-Fi 网络" -#: ../src/libnmc-base/nm-client-utils.c:445 +#: ../src/libnmc-base/nm-client-utils.c:419 msgid "A secondary connection of the base connection failed" msgstr "基础连接的次级连接失败" -#: ../src/libnmc-base/nm-client-utils.c:446 +#: ../src/libnmc-base/nm-client-utils.c:420 msgid "DCB or FCoE setup failed" msgstr "DCB 或 FCoE 设置失败" -#: ../src/libnmc-base/nm-client-utils.c:447 +#: ../src/libnmc-base/nm-client-utils.c:421 msgid "teamd control failed" msgstr "teamd 控制失败" # auto translated by TM merge from project: NetworkManager, version: 0.9.8.2, DocId: NetworkManager -#: ../src/libnmc-base/nm-client-utils.c:449 +#: ../src/libnmc-base/nm-client-utils.c:423 msgid "Modem failed or no longer available" msgstr "调制解调器出现故障或不再可用" # auto translated by TM merge from project: NetworkManager, version: 0.9.8.2, DocId: NetworkManager -#: ../src/libnmc-base/nm-client-utils.c:451 +#: ../src/libnmc-base/nm-client-utils.c:425 msgid "Modem now ready and available" msgstr "调制解调器现已就绪且可用" -#: ../src/libnmc-base/nm-client-utils.c:452 +#: ../src/libnmc-base/nm-client-utils.c:426 msgid "SIM PIN was incorrect" msgstr "SIM PIN 不正确" -#: ../src/libnmc-base/nm-client-utils.c:454 +#: ../src/libnmc-base/nm-client-utils.c:428 msgid "New connection activation was enqueued" msgstr "新连接激活已排队" -#: ../src/libnmc-base/nm-client-utils.c:455 +#: ../src/libnmc-base/nm-client-utils.c:429 msgid "The device's parent changed" msgstr "设备的上级已更改" -#: ../src/libnmc-base/nm-client-utils.c:457 +#: ../src/libnmc-base/nm-client-utils.c:431 msgid "The device parent's management changed" msgstr "设备的上级管理已更改" -#: ../src/libnmc-base/nm-client-utils.c:459 +#: ../src/libnmc-base/nm-client-utils.c:433 msgid "Open vSwitch database connection failed" msgstr "Open vSwitch 数据库连接失败" -#: ../src/libnmc-base/nm-client-utils.c:461 +#: ../src/libnmc-base/nm-client-utils.c:435 msgid "A duplicate IP address was detected" msgstr "检测到重复的 IP 地址" -#: ../src/libnmc-base/nm-client-utils.c:463 +#: ../src/libnmc-base/nm-client-utils.c:437 msgid "The selected IP method is not supported" msgstr "选中的 IP 方法未支持" -#: ../src/libnmc-base/nm-client-utils.c:465 +#: ../src/libnmc-base/nm-client-utils.c:439 msgid "Failed to configure SR-IOV parameters" msgstr "配置 SR-IOV 参数失败" -#: ../src/libnmc-base/nm-client-utils.c:467 +#: ../src/libnmc-base/nm-client-utils.c:441 msgid "The Wi-Fi P2P peer could not be found" msgstr "无法找到 Wi-Fi P2P peer" -#: ../src/libnmc-base/nm-client-utils.c:474 +#: ../src/libnmc-base/nm-client-utils.c:448 msgid "Unknown reason" msgstr "未知原因" -#: ../src/libnmc-base/nm-client-utils.c:476 +#: ../src/libnmc-base/nm-client-utils.c:450 msgid "The connection was disconnected" msgstr "连接已断开" -#: ../src/libnmc-base/nm-client-utils.c:478 +#: ../src/libnmc-base/nm-client-utils.c:452 msgid "Disconnected by user" msgstr "已被用户断开连接" -#: ../src/libnmc-base/nm-client-utils.c:480 +#: ../src/libnmc-base/nm-client-utils.c:454 msgid "The base network connection was interrupted" msgstr "基础网络连接已中断" -#: ../src/libnmc-base/nm-client-utils.c:482 +#: ../src/libnmc-base/nm-client-utils.c:456 msgid "The VPN service stopped unexpectedly" msgstr "VPN 服务意外停止" -#: ../src/libnmc-base/nm-client-utils.c:484 +#: ../src/libnmc-base/nm-client-utils.c:458 msgid "The VPN service returned invalid configuration" msgstr "VPN 服务返回了无效配置" -#: ../src/libnmc-base/nm-client-utils.c:486 +#: ../src/libnmc-base/nm-client-utils.c:460 msgid "The connection attempt timed out" msgstr "连接尝试超时" -#: ../src/libnmc-base/nm-client-utils.c:488 +#: ../src/libnmc-base/nm-client-utils.c:462 msgid "The VPN service did not start in time" msgstr "VPN 连接没有及时启动" -#: ../src/libnmc-base/nm-client-utils.c:490 +#: ../src/libnmc-base/nm-client-utils.c:464 msgid "The VPN service failed to start" msgstr "VPN 服务启动失败" -#: ../src/libnmc-base/nm-client-utils.c:491 +#: ../src/libnmc-base/nm-client-utils.c:465 msgid "No valid secrets" msgstr "没有有效的密钥" -#: ../src/libnmc-base/nm-client-utils.c:492 +#: ../src/libnmc-base/nm-client-utils.c:466 msgid "Invalid secrets" msgstr "无效的密钥" -#: ../src/libnmc-base/nm-client-utils.c:494 +#: ../src/libnmc-base/nm-client-utils.c:468 msgid "The connection was removed" msgstr "连接已被移除" -#: ../src/libnmc-base/nm-client-utils.c:496 +#: ../src/libnmc-base/nm-client-utils.c:470 msgid "Master connection failed" msgstr "主连接失败" -#: ../src/libnmc-base/nm-client-utils.c:498 +#: ../src/libnmc-base/nm-client-utils.c:472 msgid "Could not create a software link" -msgstr "无法创建软件链路:" +msgstr "无法创建软件链路" -#: ../src/libnmc-base/nm-client-utils.c:500 +#: ../src/libnmc-base/nm-client-utils.c:474 msgid "The device disappeared" msgstr "设备已消失" -#: ../src/libnmc-base/nm-client-utils.c:823 +#: ../src/libnmc-base/nm-client-utils.c:797 msgid "missing colon for \".:\" format" -msgstr "缺少 \".:\" 格式中的冒号" +msgstr "缺少 \"<设置>.<属性>:<机密>\" 格式中的冒号" -#: ../src/libnmc-base/nm-client-utils.c:840 +#: ../src/libnmc-base/nm-client-utils.c:814 msgid "missing dot for \".:\" format" -msgstr "缺少 \".:\" 格式中的点" +msgstr "缺少 \"<设置>.<属性>:<机密>\" 格式中的点" -#: ../src/libnmc-base/nm-client-utils.c:846 +#: ../src/libnmc-base/nm-client-utils.c:820 msgid "missing setting for \".:\" format" -msgstr "缺少 \".:\" 格式的设置" +msgstr "缺少 \"<设置>.<属性>:<机密>\" 格式的设置" -#: ../src/libnmc-base/nm-client-utils.c:857 +#: ../src/libnmc-base/nm-client-utils.c:831 msgid "missing property for \".:\" format" -msgstr "缺少 \".:\" 格式的属性" +msgstr "缺少 \"<设置>.<属性>:<机密>\" 格式的属性" -#: ../src/libnmc-base/nm-client-utils.c:867 +#: ../src/libnmc-base/nm-client-utils.c:841 msgid "invalid setting name" msgstr "无效的设置名称" -#: ../src/libnmc-base/nm-client-utils.c:881 +#: ../src/libnmc-base/nm-client-utils.c:855 msgid "property name is not UTF-8" msgstr "属性名不是UTF-8" -#: ../src/libnmc-base/nm-client-utils.c:898 -#: ../src/libnmc-base/nm-client-utils.c:904 +#: ../src/libnmc-base/nm-client-utils.c:872 +#: ../src/libnmc-base/nm-client-utils.c:878 msgid "secret is not UTF-8" msgstr "secret 不是 UTF-8" @@ -4370,7 +4368,7 @@ msgstr "%s 的预共享密钥" #: ../src/libnmc-base/nm-secret-agent-simple.c:270 #: ../src/libnmc-base/nm-secret-agent-simple.c:357 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:4954 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:4879 #: ../src/nmtui/nmt-page-dsl.c:49 ../src/nmtui/nmt-page-wifi.c:334 msgid "Username" msgstr "用户名" @@ -4379,13 +4377,13 @@ msgstr "用户名" #: ../src/libnmc-base/nm-secret-agent-simple.c:312 #: ../src/libnmc-base/nm-secret-agent-simple.c:335 #: ../src/libnmc-base/nm-secret-agent-simple.c:367 -#: ../src/libnmc-base/nm-secret-agent-simple.c:918 -#: ../src/libnmc-base/nm-secret-agent-simple.c:953 -#: ../src/libnmc-base/nm-secret-agent-simple.c:980 +#: ../src/libnmc-base/nm-secret-agent-simple.c:915 +#: ../src/libnmc-base/nm-secret-agent-simple.c:950 +#: ../src/libnmc-base/nm-secret-agent-simple.c:977 #: ../src/libnmc-base/nm-vpn-helpers.c:143 #: ../src/libnmc-base/nm-vpn-helpers.c:147 #: ../src/libnmc-base/nm-vpn-helpers.c:153 -#: ../src/libnmc-base/nm-vpn-helpers.c:158 ../src/nmcli/devices.c:4641 +#: ../src/libnmc-base/nm-vpn-helpers.c:158 ../src/nmcli/devices.c:4635 #: ../src/nmtui/nmt-page-dsl.c:62 ../src/nmtui/nmt-page-wifi.c:274 #: ../src/nmtui/nmt-page-wifi.c:308 ../src/nmtui/nmt-page-wifi.c:347 msgid "Password" @@ -4416,87 +4414,87 @@ msgstr "WireGuard 私钥" #: ../src/libnmc-base/nm-secret-agent-simple.c:512 #, c-format msgid "Secrets are required to connect WireGuard VPN '%s'" -msgstr "连接到 WireGuard VPN '%s' 所需要的 secret" +msgstr "连接到 WireGuard VPN \"%s\" 所需要的 secret" #: ../src/libnmc-base/nm-secret-agent-simple.c:620 -#: ../src/libnmc-base/nm-secret-agent-simple.c:914 -#: ../src/libnmc-base/nm-secret-agent-simple.c:949 -#: ../src/libnmc-base/nm-secret-agent-simple.c:976 -#: ../src/libnmc-base/nm-secret-agent-simple.c:995 +#: ../src/libnmc-base/nm-secret-agent-simple.c:911 +#: ../src/libnmc-base/nm-secret-agent-simple.c:946 +#: ../src/libnmc-base/nm-secret-agent-simple.c:973 +#: ../src/libnmc-base/nm-secret-agent-simple.c:992 #, c-format msgid "A password is required to connect to '%s'." msgstr "需要密码来连接到 \"%s\"。" -#: ../src/libnmc-base/nm-secret-agent-simple.c:879 +#: ../src/libnmc-base/nm-secret-agent-simple.c:876 msgid "Authentication required by wireless network" msgstr "无线网络要求身份验证" -#: ../src/libnmc-base/nm-secret-agent-simple.c:881 +#: ../src/libnmc-base/nm-secret-agent-simple.c:878 #, c-format msgid "" "Passwords or encryption keys are required to access the wireless network " "'%s'." msgstr "需要密码或密钥来访问无线网络 \"%s\"。" -#: ../src/libnmc-base/nm-secret-agent-simple.c:887 +#: ../src/libnmc-base/nm-secret-agent-simple.c:884 msgid "Wired 802.1X authentication" msgstr "有线 802.1X 身份验证" -#: ../src/libnmc-base/nm-secret-agent-simple.c:888 +#: ../src/libnmc-base/nm-secret-agent-simple.c:885 #, c-format msgid "Secrets are required to access the wired network '%s'" msgstr "需要密钥来访问有线网络 \"%s\"。" -#: ../src/libnmc-base/nm-secret-agent-simple.c:894 +#: ../src/libnmc-base/nm-secret-agent-simple.c:891 msgid "DSL authentication" msgstr "DSL 身份验证" -#: ../src/libnmc-base/nm-secret-agent-simple.c:895 +#: ../src/libnmc-base/nm-secret-agent-simple.c:892 #, c-format msgid "Secrets are required for the DSL connection '%s'" msgstr "DSL 连接 \"%s\" 需要密钥。" -#: ../src/libnmc-base/nm-secret-agent-simple.c:904 +#: ../src/libnmc-base/nm-secret-agent-simple.c:901 msgid "PIN code required" msgstr "需要 PIN 码" -#: ../src/libnmc-base/nm-secret-agent-simple.c:905 +#: ../src/libnmc-base/nm-secret-agent-simple.c:902 msgid "PIN code is needed for the mobile broadband device" msgstr "移动宽带设备需要 PIN 码" -#: ../src/libnmc-base/nm-secret-agent-simple.c:908 +#: ../src/libnmc-base/nm-secret-agent-simple.c:905 msgid "PIN" msgstr "PIN" -#: ../src/libnmc-base/nm-secret-agent-simple.c:913 -#: ../src/libnmc-base/nm-secret-agent-simple.c:948 -#: ../src/libnmc-base/nm-secret-agent-simple.c:975 +#: ../src/libnmc-base/nm-secret-agent-simple.c:910 +#: ../src/libnmc-base/nm-secret-agent-simple.c:945 +#: ../src/libnmc-base/nm-secret-agent-simple.c:972 msgid "Mobile broadband network password" msgstr "移动宽带网络密码" -#: ../src/libnmc-base/nm-secret-agent-simple.c:926 +#: ../src/libnmc-base/nm-secret-agent-simple.c:923 #, c-format msgid "Secrets are required to access the MACsec network '%s'" msgstr "需要密钥来访问 MACsec 网络 \"%s\"。" -#: ../src/libnmc-base/nm-secret-agent-simple.c:930 +#: ../src/libnmc-base/nm-secret-agent-simple.c:927 msgid "MACsec PSK authentication" msgstr "MACsec PSK 身份验证" -#: ../src/libnmc-base/nm-secret-agent-simple.c:932 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:6382 +#: ../src/libnmc-base/nm-secret-agent-simple.c:929 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:6276 msgid "MKA CAK" msgstr "MKA CAK" -#: ../src/libnmc-base/nm-secret-agent-simple.c:937 +#: ../src/libnmc-base/nm-secret-agent-simple.c:934 msgid "MACsec EAP authentication" msgstr "MACsec EAP 身份验证" -#: ../src/libnmc-base/nm-secret-agent-simple.c:942 +#: ../src/libnmc-base/nm-secret-agent-simple.c:939 msgid "WireGuard VPN secret" msgstr "WireGuard VPN secret" -#: ../src/libnmc-base/nm-secret-agent-simple.c:985 +#: ../src/libnmc-base/nm-secret-agent-simple.c:982 msgid "VPN password required" msgstr "需要 VPN 密码" @@ -4550,7 +4548,7 @@ msgstr "网关证书散列" #: ../src/libnmc-base/nm-vpn-helpers.c:267 #, c-format msgid "Invalid peer starting at %s:%zu: %s" -msgstr "于 %s:%zu: %s 启动的无效 peer" +msgstr "在 %s:%zu 正启动无效的对等端:%s" #: ../src/libnmc-base/nm-vpn-helpers.c:388 msgid "" @@ -4566,17 +4564,17 @@ msgstr "无法识别的行 %s:%zu" #: ../src/libnmc-base/nm-vpn-helpers.c:678 #, c-format msgid "invalid value for '%s' at %s:%zu" -msgstr "无效的值 '%s' 于 %s:%zu" +msgstr "%2$s:%3$zu 有无效的值 \"%1$s\"" #: ../src/libnmc-base/nm-vpn-helpers.c:686 #, c-format msgid "invalid secret '%s' at %s:%zu" -msgstr "无效的 secret '%s' 于 %s:%zu" +msgstr "%2$s:%3$zu 有无效的机密(secret)\"%1$s\"" #: ../src/libnmc-base/nm-vpn-helpers.c:815 #, c-format msgid "Failed to create WireGuard connection: %s" -msgstr "创建 WireGuard 连接失败 : %s" +msgstr "创建 WireGuard 连接失败:%s" #: ../src/libnmc-setting/nm-meta-setting-access.c:501 #, c-format @@ -4588,18 +4586,18 @@ msgstr "字段 \"%s\" 必须是单独的" msgid "invalid field '%s%s%s%s%s'; %s%s%s" msgstr "无效字段 \"%s%s%s%s%s\";%s%s%s" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:263 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:329 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:262 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:328 #, c-format msgid "invalid prefix '%s'; <1-%d> allowed" -msgstr "无效的前缀 '%s'; 只允许 <1-%d>" +msgstr "无效的前缀 \"%s\";只允许 <1-%d>" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:275 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:274 #, c-format msgid "invalid IP address: %s" msgstr "无效的 IP 地址:%s" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:300 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:299 msgid "" "The valid syntax is: 'ip[/prefix] [next-hop] [metric] [attribute=val]... [," "ip[/prefix] ...]'" @@ -4607,183 +4605,183 @@ msgstr "" "有效语法为:\"ip[/prefix] [next-hop] [metric] [attribute=val]... [,ip[/" "prefix] ...]\"" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:341 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:340 #, c-format msgid "the next hop ('%s') must be first" msgstr "下一跳(\"%s\")必须在首位" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:351 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:350 #, c-format msgid "the metric ('%s') must be before attributes" msgstr "跃点数(\"%s\")必需在属性前" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:402 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:401 #, c-format msgid "invalid route: %s. %s" msgstr "无效路由:%s。%s" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:470 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:469 #, c-format msgid "cannot read pac-script from file '%s'" msgstr "无法从文件 \"%s\" 读取 PAC 脚本" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:479 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:478 #, c-format msgid "file '%s' contains non-valid utf-8" msgstr "文件 \"%s\" 包含无效的 utf-8" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:493 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:492 #, c-format msgid "'%s' does not contain a valid PAC Script" msgstr "\"%s\" 没有包含有效的 PAC 脚本" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:499 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:498 #, c-format msgid "Not a valid PAC Script" msgstr "不是有效的 PAC 脚本" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:552 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:551 #, c-format msgid "cannot read team config from file '%s'" msgstr "无法从文件 \"%s\" 读取组合(team)配置" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:561 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:560 #, c-format msgid "team config file '%s' contains non-valid utf-8" msgstr "组合(team)配置文件 \"%s\" 包含无效的 utf-8" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1052 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1051 msgid "auto" msgstr "自动" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1214 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1213 #, c-format msgid "%s (%s)" msgstr "%s(%s)" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1403 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1411 -#: ../src/libnmc-setting/nm-meta-setting-desc.c:4301 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1375 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1383 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:4230 msgid "'%s' is out of range [%" -msgstr "'%s' 超出范围 [%" +msgstr "\"%s\" 超出范围 [%" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1420 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1392 #, c-format msgid "'%s' is not a valid number" msgstr "\"%s\" 不是有效的数字" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1476 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1448 #, c-format msgid "'%s' is out of range [0, %u]" msgstr "\"%s\" 超出范围 [0, %u]" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1520 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1492 #, c-format msgid "'%s' is not a valid Ethernet MAC" msgstr "\"%s\" 不是有效的以太网 MAC" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1644 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1616 #, c-format msgid "invalid option '%s', use a combination of [%s]" msgstr "无效选项 \"%s\",请使用 [%s] 的组合" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1785 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1735 #, c-format msgid "%d (key)" msgstr "%d(密钥)" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1787 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1737 #, c-format msgid "%d (passphrase)" msgstr "%d(密码)" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1790 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1740 #, c-format msgid "%d (unknown)" msgstr "%d(未知)" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1803 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1753 msgid "0 (NONE)" msgstr "0(无)" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1809 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1759 msgid "REORDER_HEADERS, " msgstr "记录头、 " -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1811 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1761 msgid "GVRP, " msgstr "GVRP、 " -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1813 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1763 msgid "LOOSE_BINDING, " msgstr "松散绑定、 " -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1815 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1765 msgid "MVRP, " msgstr "MVRP、 " -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1836 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1786 msgid "0 (none)" msgstr "0(无)" -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1842 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1792 msgid "agent-owned, " msgstr "为代理拥有、 " -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1844 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1794 msgid "not saved, " msgstr "未保存、 " -#: ../src/libnmc-setting/nm-meta-setting-desc.c:1846 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1796 msgid "not required, " msgstr "不必需、 " -#: ../src/libnmc-setting/nm-meta-setting-desc.c:2048 +#: ../src/libnmc-setting/nm-meta-setting-desc.c:1998 #, c-format msgid "'%s' is not valid; use