summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-21 12:56:26 +0200
committerThomas Haller <thaller@redhat.com>2019-04-21 12:56:26 +0200
commitb237c4303f6990f09e2e5888707ca99d6ae580cc (patch)
tree1594dba8ce76d2f87e8f8847769e226dcd0429e7
parentcb739531832730e0585a740cd389c715d072cd72 (diff)
parent32594889bfbf808bf5745e9186e332118e04c6cc (diff)
release: bump version to 1.19.1-dev after 1.18.0 release1.19.1-dev
After 1.18.0 is released, merge it back into master so that 1.18.0 is part of the history of master. That means, $ git log --first-parent master will also traverse 1.18.0 and 1.18-rc*. Also bump the micro version to 1.19.1-dev to indicate that this is after 1.18.0 is out.
-rw-r--r--.travis.yml1
-rw-r--r--Makefile.am739
-rw-r--r--NEWS17
-rwxr-xr-xautogen.sh2
-rw-r--r--clients/cli/common.c102
-rw-r--r--clients/cli/connections.c10
-rw-r--r--clients/cli/devices.c16
-rw-r--r--clients/cli/general.c4
-rw-r--r--clients/cli/nmcli.c2
-rw-r--r--clients/cli/utils.c4
-rw-r--r--config.h.meson9
-rw-r--r--configure.ac78
-rwxr-xr-xcontrib/debian/REQUIRED_PACKAGES1
-rwxr-xr-xcontrib/fedora/REQUIRED_PACKAGES1
-rw-r--r--contrib/fedora/rpm/NetworkManager.spec97
-rwxr-xr-xcontrib/fedora/rpm/build_clean.sh1
-rwxr-xr-xcontrib/scripts/nm-ci-run.sh2
-rw-r--r--docs/libnm-glib/Makefile.am79
-rw-r--r--docs/libnm-glib/libnm-glib-docs.xml117
-rw-r--r--docs/libnm-glib/libnm-glib.pngbin82140 -> 0 bytes
-rw-r--r--docs/libnm-glib/libnm-glib.svg893
-rw-r--r--docs/libnm-glib/libnm-glib.types55
-rw-r--r--docs/libnm-glib/meson.build39
-rw-r--r--docs/libnm-glib/version.xml.in1
-rw-r--r--docs/libnm-util/Makefile.am74
-rw-r--r--docs/libnm-util/libnm-util-docs.sgml96
-rw-r--r--docs/libnm-util/meson.build32
-rw-r--r--docs/libnm-util/version.xml.in1
-rw-r--r--docs/meson.build5
-rw-r--r--libnm-core/nm-setting.c15
-rw-r--r--libnm-core/nm-version.h14
-rw-r--r--libnm-glib/libnm-glib-test.c426
-rw-r--r--libnm-glib/libnm-glib-vpn.pc.in13
-rw-r--r--libnm-glib/libnm-glib-vpn.ver29
-rw-r--r--libnm-glib/libnm-glib.pc.in13
-rw-r--r--libnm-glib/libnm-glib.ver309
-rw-r--r--libnm-glib/libnm_glib.c580
-rw-r--r--libnm-glib/libnm_glib.h58
-rw-r--r--libnm-glib/meson.build286
-rw-r--r--libnm-glib/nm-access-point.c720
-rw-r--r--libnm-glib/nm-access-point.h98
-rw-r--r--libnm-glib/nm-active-connection.c851
-rw-r--r--libnm-glib/nm-active-connection.h105
-rw-r--r--libnm-glib/nm-client.c2514
-rw-r--r--libnm-glib/nm-client.h269
-rw-r--r--libnm-glib/nm-dbus-helpers-private.h33
-rw-r--r--libnm-glib/nm-dbus-helpers.c47
-rw-r--r--libnm-glib/nm-device-adsl.c245
-rw-r--r--libnm-glib/nm-device-adsl.h75
-rw-r--r--libnm-glib/nm-device-bond.c346
-rw-r--r--libnm-glib/nm-device-bond.h82
-rw-r--r--libnm-glib/nm-device-bridge.c358
-rw-r--r--libnm-glib/nm-device-bridge.h84
-rw-r--r--libnm-glib/nm-device-bt.c372
-rw-r--r--libnm-glib/nm-device-bt.h90
-rw-r--r--libnm-glib/nm-device-ethernet.c391
-rw-r--r--libnm-glib/nm-device-ethernet.h87
-rw-r--r--libnm-glib/nm-device-generic.c310
-rw-r--r--libnm-glib/nm-device-generic.h79
-rw-r--r--libnm-glib/nm-device-infiniband.c310
-rw-r--r--libnm-glib/nm-device-infiniband.h82
-rw-r--r--libnm-glib/nm-device-modem.c290
-rw-r--r--libnm-glib/nm-device-modem.h79
-rw-r--r--libnm-glib/nm-device-olpc-mesh.c325
-rw-r--r--libnm-glib/nm-device-olpc-mesh.h81
-rw-r--r--libnm-glib/nm-device-private.h27
-rw-r--r--libnm-glib/nm-device-team.c352
-rw-r--r--libnm-glib/nm-device-team.h85
-rw-r--r--libnm-glib/nm-device-vlan.c390
-rw-r--r--libnm-glib/nm-device-vlan.h89
-rw-r--r--libnm-glib/nm-device-wifi.c837
-rw-r--r--libnm-glib/nm-device-wifi.h115
-rw-r--r--libnm-glib/nm-device-wimax.c795
-rw-r--r--libnm-glib/nm-device-wimax.h109
-rw-r--r--libnm-glib/nm-device.c2375
-rw-r--r--libnm-glib/nm-device.h191
-rw-r--r--libnm-glib/nm-dhcp4-config.c218
-rw-r--r--libnm-glib/nm-dhcp4-config.h66
-rw-r--r--libnm-glib/nm-dhcp6-config.c218
-rw-r--r--libnm-glib/nm-dhcp6-config.h66
-rw-r--r--libnm-glib/nm-glib-enum-types.c.template62
-rw-r--r--libnm-glib/nm-glib-enum-types.h.template21
-rw-r--r--libnm-glib/nm-ip4-config.c472
-rw-r--r--libnm-glib/nm-ip4-config.h79
-rw-r--r--libnm-glib/nm-ip6-config.c498
-rw-r--r--libnm-glib/nm-ip6-config.h81
-rw-r--r--libnm-glib/nm-object-cache.c90
-rw-r--r--libnm-glib/nm-object-cache.h35
-rw-r--r--libnm-glib/nm-object-private.h93
-rw-r--r--libnm-glib/nm-object.c1576
-rw-r--r--libnm-glib/nm-object.h91
-rw-r--r--libnm-glib/nm-remote-connection-private.h33
-rw-r--r--libnm-glib/nm-remote-connection.c954
-rw-r--r--libnm-glib/nm-remote-connection.h148
-rw-r--r--libnm-glib/nm-remote-settings.c1569
-rw-r--r--libnm-glib/nm-remote-settings.h159
-rw-r--r--libnm-glib/nm-secret-agent.c1052
-rw-r--r--libnm-glib/nm-secret-agent.h307
-rw-r--r--libnm-glib/nm-types-private.h33
-rw-r--r--libnm-glib/nm-types.c375
-rw-r--r--libnm-glib/nm-types.h54
-rw-r--r--libnm-glib/nm-vpn-connection.c270
-rw-r--r--libnm-glib/nm-vpn-connection.h73
-rw-r--r--libnm-glib/nm-vpn-enum-types.c.template37
-rw-r--r--libnm-glib/nm-vpn-enum-types.h.template21
-rw-r--r--libnm-glib/nm-vpn-plugin-ui-interface.c246
-rw-r--r--libnm-glib/nm-vpn-plugin-ui-interface.h271
-rw-r--r--libnm-glib/nm-vpn-plugin-utils.c189
-rw-r--r--libnm-glib/nm-vpn-plugin-utils.h39
-rw-r--r--libnm-glib/nm-vpn-plugin.c1041
-rw-r--r--libnm-glib/nm-vpn-plugin.h175
-rw-r--r--libnm-glib/nm-wimax-nsp.c331
-rw-r--r--libnm-glib/nm-wimax-nsp.h91
-rw-r--r--libnm-glib/tests/meson.build30
-rw-r--r--libnm-glib/tests/test-nm-client.c1156
-rw-r--r--libnm-glib/tests/test-remote-settings-client.c470
-rw-r--r--libnm-util/COPYING488
-rw-r--r--libnm-util/NetworkManager.h555
-rw-r--r--libnm-util/NetworkManagerVPN.h294
-rw-r--r--libnm-util/crypto.c749
-rw-r--r--libnm-util/crypto.h141
-rw-r--r--libnm-util/crypto_gnutls.c465
-rw-r--r--libnm-util/crypto_nss.c555
-rw-r--r--libnm-util/libnm-util.pc.in13
-rw-r--r--libnm-util/libnm-util.ver671
-rw-r--r--libnm-util/meson.build217
-rw-r--r--libnm-util/nm-connection.c2212
-rw-r--r--libnm-util/nm-connection.h256
-rw-r--r--libnm-util/nm-dbus-glib-types.h45
-rw-r--r--libnm-util/nm-gvaluearray-compat.h104
-rw-r--r--libnm-util/nm-param-spec-specialized.c973
-rw-r--r--libnm-util/nm-param-spec-specialized.h41
-rw-r--r--libnm-util/nm-setting-8021x.c3730
-rw-r--r--libnm-util/nm-setting-8021x.h294
-rw-r--r--libnm-util/nm-setting-adsl.c462
-rw-r--r--libnm-util/nm-setting-adsl.h96
-rw-r--r--libnm-util/nm-setting-bluetooth.c298
-rw-r--r--libnm-util/nm-setting-bluetooth.h100
-rw-r--r--libnm-util/nm-setting-bond.c834
-rw-r--r--libnm-util/nm-setting-bond.h120
-rw-r--r--libnm-util/nm-setting-bridge-port.c279
-rw-r--r--libnm-util/nm-setting-bridge-port.h86
-rw-r--r--libnm-util/nm-setting-bridge.c576
-rw-r--r--libnm-util/nm-setting-bridge.h102
-rw-r--r--libnm-util/nm-setting-cdma.c347
-rw-r--r--libnm-util/nm-setting-cdma.h87
-rw-r--r--libnm-util/nm-setting-connection.c1332
-rw-r--r--libnm-util/nm-setting-connection.h151
-rw-r--r--libnm-util/nm-setting-dcb.c1219
-rw-r--r--libnm-util/nm-setting-dcb.h185
-rw-r--r--libnm-util/nm-setting-generic.c100
-rw-r--r--libnm-util/nm-setting-generic.h78
-rw-r--r--libnm-util/nm-setting-gsm.c714
-rw-r--r--libnm-util/nm-setting-gsm.h204
-rw-r--r--libnm-util/nm-setting-infiniband.c474
-rw-r--r--libnm-util/nm-setting-infiniband.h85
-rw-r--r--libnm-util/nm-setting-ip4-config.c1853
-rw-r--r--libnm-util/nm-setting-ip4-config.h235
-rw-r--r--libnm-util/nm-setting-ip6-config.c1776
-rw-r--r--libnm-util/nm-setting-ip6-config.h258
-rw-r--r--libnm-util/nm-setting-olpc-mesh.c275
-rw-r--r--libnm-util/nm-setting-olpc-mesh.h82
-rw-r--r--libnm-util/nm-setting-ppp.c822
-rw-r--r--libnm-util/nm-setting-ppp.h115
-rw-r--r--libnm-util/nm-setting-pppoe.c342
-rw-r--r--libnm-util/nm-setting-pppoe.h87
-rw-r--r--libnm-util/nm-setting-private.h125
-rw-r--r--libnm-util/nm-setting-serial.c319
-rw-r--r--libnm-util/nm-setting-serial.h89
-rw-r--r--libnm-util/nm-setting-team-port.c197
-rw-r--r--libnm-util/nm-setting-team-port.h79
-rw-r--r--libnm-util/nm-setting-team.c254
-rw-r--r--libnm-util/nm-setting-team.h81
-rw-r--r--libnm-util/nm-setting-vlan.c852
-rw-r--r--libnm-util/nm-setting-vlan.h164
-rw-r--r--libnm-util/nm-setting-vpn.c922
-rw-r--r--libnm-util/nm-setting-vpn.h121
-rw-r--r--libnm-util/nm-setting-wimax.c278
-rw-r--r--libnm-util/nm-setting-wimax.h78
-rw-r--r--libnm-util/nm-setting-wired.c1029
-rw-r--r--libnm-util/nm-setting-wired.h131
-rw-r--r--libnm-util/nm-setting-wireless-security.c1552
-rw-r--r--libnm-util/nm-setting-wireless-security.h178
-rw-r--r--libnm-util/nm-setting-wireless.c1286
-rw-r--r--libnm-util/nm-setting-wireless.h177
-rw-r--r--libnm-util/nm-setting.c1505
-rw-r--r--libnm-util/nm-setting.h334
-rw-r--r--libnm-util/nm-utils-enum-types.c.template65
-rw-r--r--libnm-util/nm-utils-enum-types.h.template21
-rw-r--r--libnm-util/nm-utils-private.h34
-rw-r--r--libnm-util/nm-utils.c2608
-rw-r--r--libnm-util/nm-utils.h190
-rw-r--r--libnm-util/nm-value-transforms.c593
-rw-r--r--libnm-util/nm-version.h149
-rw-r--r--libnm-util/tests/meson.build45
-rw-r--r--libnm-util/tests/test-crypto.c403
-rw-r--r--libnm-util/tests/test-general.c2560
-rw-r--r--libnm-util/tests/test-libnm-linking.c45
-rw-r--r--libnm-util/tests/test-secrets.c684
-rw-r--r--libnm-util/tests/test-setting-8021x.c407
-rw-r--r--libnm-util/tests/test-setting-dcb.c319
-rw-r--r--libnm-util/tests/test-settings-defaults.c127
-rw-r--r--libnm/fake-typelib/NMClient.gir9
-rw-r--r--libnm/fake-typelib/NetworkManager.gir10
-rw-r--r--libnm/fake-typelib/meson.build30
-rw-r--r--libnm/fake-typelib/typelibs.gresource.xml7
-rw-r--r--libnm/meson.build5
-rw-r--r--libnm/nm-libnm-utils.c82
-rw-r--r--m4/compiler_options.m44
-rw-r--r--m4/vapigen.m42
-rw-r--r--meson.build46
-rw-r--r--meson_options.txt1
-rw-r--r--po/POTFILES.in31
-rw-r--r--shared/c-list/AUTHORS4
-rw-r--r--shared/c-list/AUTHORS-ASL201
-rw-r--r--shared/c-list/AUTHORS-LGPL502
l---------shared/c-list/LICENSE1
-rw-r--r--shared/c-list/NEWS.md (renamed from shared/c-list/NEWS)8
-rw-r--r--shared/c-list/README48
-rw-r--r--shared/c-list/README.md52
-rw-r--r--shared/c-list/src/test-api.c1
-rw-r--r--shared/c-list/src/test-basic.c1
-rw-r--r--shared/c-list/src/test-embed.c1
-rwxr-xr-xshared/c-rbtree/.cherryci/matrix6
-rw-r--r--shared/c-rbtree/.gitmodules3
-rw-r--r--shared/c-rbtree/AUTHORS4
-rw-r--r--shared/c-rbtree/AUTHORS-ASL201
-rw-r--r--shared/c-rbtree/AUTHORS-LGPL502
l---------shared/c-rbtree/LICENSE1
-rw-r--r--shared/c-rbtree/NEWS.md (renamed from shared/c-rbtree/NEWS)8
-rw-r--r--shared/c-rbtree/README52
-rw-r--r--shared/c-rbtree/README.md54
-rw-r--r--shared/c-rbtree/meson.build4
-rw-r--r--shared/c-rbtree/src/c-rbtree-private.h7
-rw-r--r--shared/c-rbtree/src/c-rbtree.c83
-rw-r--r--shared/c-rbtree/src/meson.build7
-rw-r--r--shared/c-rbtree/src/test-api.c1
-rw-r--r--shared/c-rbtree/src/test-basic.c48
-rw-r--r--shared/c-rbtree/src/test-map.c128
-rw-r--r--shared/c-rbtree/src/test-misc.c22
-rw-r--r--shared/c-rbtree/src/test-parallel.c38
-rw-r--r--shared/c-rbtree/src/test-posix.c22
m---------shared/c-rbtree/subprojects/c-stdaux0
-rw-r--r--shared/c-siphash/.gitmodules3
-rw-r--r--shared/c-siphash/AUTHORS4
-rw-r--r--shared/c-siphash/AUTHORS-ASL201
-rw-r--r--shared/c-siphash/AUTHORS-LGPL502
l---------shared/c-siphash/LICENSE1
-rw-r--r--shared/c-siphash/NEWS.md11
-rw-r--r--shared/c-siphash/README51
-rw-r--r--shared/c-siphash/README.md53
-rw-r--r--shared/c-siphash/meson.build4
-rw-r--r--shared/c-siphash/src/c-siphash.c11
-rw-r--r--shared/c-siphash/src/meson.build7
-rw-r--r--shared/c-siphash/src/test-api.c1
-rw-r--r--shared/c-siphash/src/test-basic.c36
m---------shared/c-siphash/subprojects/c-stdaux0
-rwxr-xr-xshared/c-stdaux/.cherryci/ci-test12
-rw-r--r--shared/c-stdaux/.editorconfig11
-rw-r--r--shared/c-stdaux/.travis.yml21
-rw-r--r--shared/c-stdaux/AUTHORS38
-rw-r--r--shared/c-stdaux/NEWS.md11
-rw-r--r--shared/c-stdaux/README.md53
-rw-r--r--shared/c-stdaux/meson.build15
-rw-r--r--shared/c-stdaux/src/c-stdaux.h546
-rw-r--r--shared/c-stdaux/src/meson.build31
-rw-r--r--shared/c-stdaux/src/test-api.c209
-rw-r--r--shared/c-stdaux/src/test-basic.c432
-rw-r--r--shared/meson.build19
-rwxr-xr-xshared/n-acd/.cherryci/ci-test2
-rw-r--r--shared/n-acd/.gitmodules3
-rw-r--r--shared/n-acd/AUTHORS4
-rw-r--r--shared/n-acd/AUTHORS-ASL201
-rw-r--r--shared/n-acd/AUTHORS-LGPL502
l---------shared/n-acd/LICENSE1
-rw-r--r--shared/n-acd/NEWS21
-rw-r--r--shared/n-acd/NEWS.md46
-rw-r--r--shared/n-acd/README54
-rw-r--r--shared/n-acd/README.md60
-rw-r--r--shared/n-acd/meson.build4
-rw-r--r--shared/n-acd/src/meson.build1
-rw-r--r--shared/n-acd/src/n-acd-bpf-fallback.c1
-rw-r--r--shared/n-acd/src/n-acd-bpf.c1
-rw-r--r--shared/n-acd/src/n-acd-private.h20
-rw-r--r--shared/n-acd/src/n-acd-probe.c135
-rw-r--r--shared/n-acd/src/n-acd.c264
-rw-r--r--shared/n-acd/src/n-acd.h2
-rw-r--r--shared/n-acd/src/test-api.c169
-rw-r--r--shared/n-acd/src/test-bpf.c66
-rw-r--r--shared/n-acd/src/test-loopback.c24
-rw-r--r--shared/n-acd/src/test-twice.c32
-rw-r--r--shared/n-acd/src/test-unplug.c20
-rw-r--r--shared/n-acd/src/test-unused.c20
-rw-r--r--shared/n-acd/src/test-veth.c64
-rw-r--r--shared/n-acd/src/test.h121
-rw-r--r--shared/n-acd/src/util/test-timer.c73
-rw-r--r--shared/n-acd/src/util/timer.c14
-rw-r--r--shared/n-acd/src/util/timer.h1
m---------shared/n-acd/subprojects/c-list0
m---------shared/n-acd/subprojects/c-rbtree0
m---------shared/n-acd/subprojects/c-siphash0
m---------shared/n-acd/subprojects/c-stdaux0
-rw-r--r--shared/nm-default.h20
-rw-r--r--shared/nm-test-libnm-utils.h27
-rw-r--r--shared/nm-test-utils-impl.c139
-rw-r--r--shared/nm-utils/nm-test-utils.h8
-rw-r--r--shared/nm-version-macros.h.in1
-rwxr-xr-xtools/run-nm-test.sh2
-rwxr-xr-xtools/test-build.sh2
-rw-r--r--valgrind.suppressions2
-rw-r--r--vapi/NMClient-1.0.metadata121
-rw-r--r--vapi/NetworkManager-1.0.metadata164
-rw-r--r--vapi/libnm-glib.deps3
-rw-r--r--vapi/libnm-util.deps2
-rw-r--r--vapi/meson.build22
315 files changed, 2738 insertions, 78498 deletions
diff --git a/.travis.yml b/.travis.yml
index 6dd6ae0491..ca6b370cd6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,6 @@ addons:
- libtool
- pkg-config
- intltool
- - libdbus-glib-1-dev
- libdbus-1-dev
- libiw-dev
- libglib2.0-dev
diff --git a/Makefile.am b/Makefile.am
index d78bfdeda8..21359e5d6e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -97,12 +97,6 @@ SUBDIRS += \
docs/libnm \
docs/api
-if WITH_LEGACY_LIBRARIES
-SUBDIRS += \
- docs/libnm-util \
- docs/libnm-glib
-endif
-
endif
dflt_cppflags = -std=gnu11
@@ -160,7 +154,6 @@ check_so_symbols = \
DISTCHECK_CONFIGURE_FLAGS = \
--enable-tests=yes \
--with-valgrind=no \
- --with-libnm-glib=yes \
--enable-gtk-doc \
--enable-more-warnings=error \
--with-udev-dir=$$dc_install_base/lib/udev \
@@ -172,14 +165,11 @@ DISTCHECK_CONFIGURE_FLAGS = \
$(NULL)
dist-configure-check:
- @echo "*** 'make dist' requires '--enable-gtk-doc --enable-introspection --with-libnm-glib'. ***"
+ @echo "*** 'make dist' requires '--enable-gtk-doc --enable-introspection'. ***"
@false
if !BUILD_DOCS
dist_configure_check += dist-configure-check
endif
-if !WITH_LEGACY_LIBRARIES
-dist_configure_check += dist-configure-check
-endif
dist: $(dist_configure_check) $(dist_dependencies)
@@ -187,12 +177,6 @@ DISTCLEANFILES += intltool-extract intltool-merge intltool-update
###############################################################################
-if WITH_LEGACY_LIBRARIES
-pkgconfig_DATA += NetworkManager.pc
-endif
-
-###############################################################################
-
polkit_policydir = $(datadir)/polkit-1/actions
dist_polkit_policy_in_in_files = \
@@ -206,8 +190,20 @@ DISTCLEANFILES += $(polkit_policy_DATA)
###############################################################################
+EXTRA_DIST += \
+ shared/c-stdaux/src/c-stdaux.h \
+ $(NULL)
+
+###############################################################################
+
noinst_LTLIBRARIES += shared/libcsiphash.la
+shared_libcsiphash_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ -std=c11 \
+ -I$(srcdir)/shared/c-stdaux/src \
+ $(NULL)
+
shared_libcsiphash_la_CPPFLAGS = \
$(CODE_COVERAGE_CFLAGS) \
$(SANITIZER_LIB_CFLAGS) \
@@ -228,6 +224,7 @@ noinst_LTLIBRARIES += shared/libcrbtree.la
shared_libcrbtree_la_CFLAGS = \
$(AM_CFLAGS) \
-std=c11 \
+ -I$(srcdir)/shared/c-stdaux/src \
$(NULL)
shared_libcrbtree_la_CPPFLAGS = \
@@ -260,6 +257,7 @@ shared_libnacd_la_CPPFLAGS = \
-DSO_ATTACH_BPF=50 \
$(CODE_COVERAGE_CFLAGS) \
$(SANITIZER_LIB_CFLAGS) \
+ -I$(srcdir)/shared/c-stdaux/src \
-I$(srcdir)/shared/c-list/src \
-I$(srcdir)/shared/c-siphash/src \
-I$(srcdir)/shared/c-rbtree/src \
@@ -1382,36 +1380,6 @@ libnm/libnm.typelib: libnm/libnm.gir
INTROSPECTION_GIRS += libnm/NM-1.0.gir
-if WITH_FAKE_TYPELIBS
-
-libnm/fake-typelib/NetworkManager.typelib: libnm/fake-typelib/NetworkManager.gir libnm/fake-typelib/.dirstamp
- $(AM_V_GEN) $(INTROSPECTION_COMPILER) $< -o $@
-
-libnm/fake-typelib/NMClient.typelib: libnm/fake-typelib/NMClient.gir libnm/fake-typelib/.dirstamp
- $(AM_V_GEN) $(INTROSPECTION_COMPILER) $< -o $@
-
-libnm/fake-typelib/typelibs.c: libnm/fake-typelib/typelibs.gresource.xml libnm/fake-typelib/NetworkManager.typelib libnm/fake-typelib/NMClient.typelib
- $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(builddir)/libnm/fake-typelib --generate-source --manual-register
-
-nodist_libnm_libnm_utils_la_SOURCES = \
- libnm/fake-typelib/typelibs.c
-
-CLEANFILES += \
- libnm/fake-typelib/typelibs.c \
- libnm/fake-typelib/NMClient.typelib \
- libnm/fake-typelib/NetworkManager.typelib
-endif
-
-endif
-
-EXTRA_DIST += \
- libnm/fake-typelib/NetworkManager.gir \
- libnm/fake-typelib/NMClient.gir \
- libnm/fake-typelib/typelibs.gresource.xml \
- libnm/fake-typelib/meson.build
-
-if HAVE_INTROSPECTION
-
libnm_noinst_data = \
libnm/nm-property-docs.xml \
libnm/nm-settings-docs-overrides.xml \
@@ -4511,660 +4479,6 @@ CLEANFILES += \
data/server.conf
###############################################################################
-# libnm-util
-###############################################################################
-
-if WITH_LEGACY_LIBRARIES
-
-lib_LTLIBRARIES += libnm-util/libnm-util.la
-
-libnm_util_libnm_util_includedir=$(includedir)/NetworkManager
-
-libnm_util_cppflags = \
- $(dflt_cppflags) \
- -I$(srcdir)/libnm-util \
- -I$(builddir)/libnm-util \
- -I$(srcdir)/shared \
- -I$(builddir)/shared \
- -DG_LOG_DOMAIN=\""libnm-util"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL \
- $(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
- $(UUID_CFLAGS)
-
-libnm_util_lib_h_pub_real = \
- shared/nm-version-macros.h \
- libnm-util/NetworkManager.h \
- libnm-util/NetworkManagerVPN.h \
- libnm-util/nm-connection.h \
- libnm-util/nm-setting.h \
- libnm-util/nm-setting-8021x.h \
- libnm-util/nm-setting-adsl.h \
- libnm-util/nm-setting-bluetooth.h \
- libnm-util/nm-setting-bond.h \
- libnm-util/nm-setting-team.h \
- libnm-util/nm-setting-team-port.h \
- libnm-util/nm-setting-bridge.h \
- libnm-util/nm-setting-bridge-port.h \
- libnm-util/nm-setting-connection.h \
- libnm-util/nm-setting-dcb.h \
- libnm-util/nm-setting-infiniband.h \
- libnm-util/nm-setting-ip4-config.h \
- libnm-util/nm-setting-vlan.h \
- libnm-util/nm-setting-ip6-config.h \
- libnm-util/nm-setting-ppp.h \
- libnm-util/nm-setting-pppoe.h \
- libnm-util/nm-setting-serial.h \
- libnm-util/nm-setting-generic.h \
- libnm-util/nm-setting-gsm.h \
- libnm-util/nm-setting-cdma.h \
- libnm-util/nm-setting-olpc-mesh.h \
- libnm-util/nm-setting-wimax.h \
- libnm-util/nm-setting-wired.h \
- libnm-util/nm-setting-wireless.h \
- libnm-util/nm-setting-wireless-security.h \
- libnm-util/nm-setting-vpn.h \
- libnm-util/nm-utils.h \
- libnm-util/nm-version.h
-libnm_util_lib_h_pub_mkenums = \
- libnm-util/nm-utils-enum-types.h
-libnm_util_lib_h_priv = \
- libnm-util/crypto.h \
- libnm-util/nm-dbus-glib-types.h \
- libnm-util/nm-gvaluearray-compat.h \
- libnm-util/nm-param-spec-specialized.h \
- libnm-util/nm-setting-private.h \
- libnm-util/nm-utils-private.h
-
-libnm_util_libnm_util_include_HEADERS = \
- $(libnm_util_lib_h_pub_real)
-
-nodist_libnm_util_libnm_util_include_HEADERS = \
- $(libnm_util_lib_h_pub_mkenums)
-
-libnm_util_lib_c_real = \
- libnm-util/crypto.c \
- libnm-util/nm-connection.c \
- libnm-util/nm-param-spec-specialized.c \
- libnm-util/nm-setting.c \
- libnm-util/nm-setting-8021x.c \
- libnm-util/nm-setting-adsl.c \
- libnm-util/nm-setting-bluetooth.c \
- libnm-util/nm-setting-bond.c \
- libnm-util/nm-setting-team.c \
- libnm-util/nm-setting-team-port.c \
- libnm-util/nm-setting-bridge.c \
- libnm-util/nm-setting-bridge-port.c \
- libnm-util/nm-setting-connection.c \
- libnm-util/nm-setting-dcb.c \
- libnm-util/nm-setting-infiniband.c \
- libnm-util/nm-setting-ip4-config.c \
- libnm-util/nm-setting-vlan.c \
- libnm-util/nm-setting-ip6-config.c \
- libnm-util/nm-setting-ppp.c \
- libnm-util/nm-setting-pppoe.c \
- libnm-util/nm-setting-serial.c \
- libnm-util/nm-setting-generic.c \
- libnm-util/nm-setting-gsm.c \
- libnm-util/nm-setting-cdma.c \
- libnm-util/nm-setting-olpc-mesh.c \
- libnm-util/nm-setting-wimax.c \
- libnm-util/nm-setting-wired.c \
- libnm-util/nm-setting-wireless.c \
- libnm-util/nm-setting-wireless-security.c \
- libnm-util/nm-setting-vpn.c \
- libnm-util/nm-utils.c \
- libnm-util/nm-value-transforms.c
-libnm_util_lib_c_mkenums = \
- libnm-util/nm-utils-enum-types.c
-
-libnm_util_libnm_util_la_SOURCES = \
- $(libnm_util_lib_c_real) \
- $(libnm_util_lib_h_pub_real) \
- $(libnm_util_lib_h_priv)
-
-nodist_libnm_util_libnm_util_la_SOURCES = \
- $(libnm_util_lib_h_pub_mkenums) \
- $(libnm_util_lib_c_mkenums)
-
-$(libnm_util_libnm_util_la_OBJECTS): $(libnm_util_lib_h_pub_mkenums)
-
-libnm_util_libnm_util_la_CPPFLAGS = $(libnm_util_cppflags)
-
-
-GLIB_GENERATED += \
- $(libnm_util_lib_h_pub_mkenums) \
- $(libnm_util_lib_c_mkenums)
-nm_utils_enum_types_sources = $(filter-out libnm-util/NetworkManager%,$(libnm_util_lib_h_pub_real))
-
-$(libnm_util_libnm_util_la_OBJECTS): $(libnm_util_lib_h_pub_mkenums)
-
-libnm_util_libnm_util_la_LIBADD = \
- shared/nm-glib-aux/libnm-glib-aux.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(UUID_LIBS)
-
-libnm_util_libnm_util_la_LDFLAGS = \
- -Wl,--version-script=$(srcdir)/libnm-util/libnm-util.ver \
- -version-info "9:0:7"
-
-if WITH_GNUTLS
-libnm_util_cppflags += $(GNUTLS_CFLAGS)
-libnm_util_lib_c_real += libnm-util/crypto_gnutls.c
-libnm_util_libnm_util_la_LIBADD += $(GNUTLS_LIBS)
-endif
-
-if WITH_NSS
-libnm_util_cppflags += $(NSS_CFLAGS)
-libnm_util_lib_c_real += libnm-util/crypto_nss.c
-libnm_util_libnm_util_la_LIBADD += $(NSS_LIBS)
-endif
-
-EXTRA_DIST += \
- libnm-util/crypto_gnutls.c \
- libnm-util/crypto_nss.c
-
-check_ltlibraries += libnm-util/libtest-crypto.la
-
-libnm_util_libtest_crypto_la_SOURCES = \
- libnm-util/crypto.c
-libnm_util_libtest_crypto_la_CPPFLAGS = $(libnm_util_cppflags)
-libnm_util_libtest_crypto_la_LIBADD = \
- $(GLIB_LIBS)
-
-if WITH_GNUTLS
-libnm_util_libtest_crypto_la_SOURCES += libnm-util/crypto_gnutls.c
-libnm_util_libtest_crypto_la_LIBADD += $(GNUTLS_LIBS)
-endif
-
-if WITH_NSS
-libnm_util_libtest_crypto_la_SOURCES += libnm-util/crypto_nss.c
-libnm_util_libtest_crypto_la_LIBADD += $(NSS_LIBS)
-endif
-
-pkgconfig_DATA += libnm-util/libnm-util.pc
-
-DISTCLEANFILES += libnm-util/libnm-util.pc
-
-EXTRA_DIST += \
- libnm-util/COPYING \
- libnm-util/libnm-util.pc.in \
- libnm-util/libnm-util.ver \
- libnm-util/nm-utils-enum-types.c.template \
- libnm-util/nm-utils-enum-types.h.template \
- libnm-util/meson.build
-
-if HAVE_INTROSPECTION
-libnm-util/NetworkManager-1.0.gir: libnm-util/libnm-util.la
-libnm_util_NetworkManager_1_0_gir_INCLUDES = GObject-2.0 DBusGLib-1.0
-libnm_util_NetworkManager_1_0_gir_PACKAGES = gobject-2.0 dbus-glib-1
-libnm_util_NetworkManager_1_0_gir_EXPORT_PACKAGES = libnm-util
-libnm_util_NetworkManager_1_0_gir_CFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/libnm-util
-libnm_util_NetworkManager_1_0_gir_LIBS = libnm-util/libnm-util.la
-libnm_util_NetworkManager_1_0_gir_FILES = \
- $(libnm_util_lib_h_pub_mkenums) \
- $(libnm_util_lib_h_pub_real) \
- $(libnm_util_lib_c_mkenums) \
- $(libnm_util_lib_c_real)
-libnm_util_NetworkManager_1_0_gir_SCANNERFLAGS = \
- -I$(srcdir)/shared \
- -I$(builddir)/shared \
- -I$(srcdir)/libnm-util \
- -I$(builddir)/libnm-util \
- --warn-all --identifier-prefix=NM --symbol-prefix=nm
-
-libnm-util/NetworkManager-1.0.typelib: libnm-util/NetworkManager-1.0.gir
- $(INTROSPECTION_COMPILER) "--includedir=$(srcdir)/libnm-util" "--includedir=$(builddir)/libnm-util" $< -o $@
-
-INTROSPECTION_GIRS += libnm-util/NetworkManager-1.0.gir
-endif
-
-check-local-exports-libnm-util: libnm-util/libnm-util.la
- $(srcdir)/tools/check-exports.sh "$(builddir)/libnm-util/.libs/libnm-util.so" "$(srcdir)/libnm-util/libnm-util.ver"
-
-check_local += check-local-exports-libnm-util
-
-dist_dependencies += libnm-util/libnm-util.la
-
-###############################################################################
-# libnm-util/tests
-###############################################################################
-
-libnm_util_tests_cppflags = \
- $(dflt_cppflags) \
- -I$(srcdir)/shared \
- -I$(builddir)/shared \
- -I$(srcdir)/libnm-util \
- -I$(builddir)/libnm-util \
- $(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
- -DNETWORKMANAGER_COMPILATION_TEST \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL \
- $(SANITIZER_EXEC_CFLAGS) \
- $(NULL)
-
-libnm_util_tests_ldadd = \
- libnm-util/libnm-util.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS)
-
-libnm_util_tests_ldflags = \
- $(SANITIZER_EXEC_LDFLAGS)
-
-check_programs += \
- libnm-util/tests/test-settings-defaults \
- libnm-util/tests/test-crypto \
- libnm-util/tests/test-secrets \
- libnm-util/tests/test-general \
- libnm-util/tests/test-setting-8021x \
- libnm-util/tests/test-setting-dcb
-
-check_programs_norun += \
- libnm-util/tests/test-libnm-linking
-
-libnm_util_tests_test_settings_defaults_CPPFLAGS = $(libnm_util_tests_cppflags)
-libnm_util_tests_test_settings_defaults_LDADD = $(libnm_util_tests_ldadd)
-libnm_util_tests_test_settings_defaults_LDFLAGS = $(libnm_util_tests_ldflags)
-
-libnm_util_tests_test_crypto_CPPFLAGS = $(libnm_util_tests_cppflags)
-libnm_util_tests_test_crypto_LDADD = \
- libnm-util/libtest-crypto.la \
- $(libnm_util_tests_ldadd)
-libnm_util_tests_test_crypto_LDFLAGS = $(libnm_util_tests_ldflags)
-
-libnm_util_tests_test_secrets_CPPFLAGS = $(libnm_util_tests_cppflags)
-libnm_util_tests_test_secrets_LDADD = $(libnm_util_tests_ldadd)
-libnm_util_tests_test_secrets_LDFLAGS = $(libnm_util_tests_ldflags)
-
-libnm_util_tests_test_general_DEPENDENCIES = libnm-util/tests/test-libnm-linking
-libnm_util_tests_test_general_CPPFLAGS = $(libnm_util_tests_cppflags)
-libnm_util_tests_test_general_LDADD = $(libnm_util_tests_ldadd)
-libnm_util_tests_test_general_LDFLAGS = $(libnm_util_tests_ldflags)
-
-libnm_util_tests_test_setting_8021x_CPPFLAGS = $(libnm_util_tests_cppflags)
-libnm_util_tests_test_setting_8021x_LDADD = $(libnm_util_tests_ldadd)
-libnm_util_tests_test_setting_8021x_LDFLAGS = $(libnm_util_tests_ldflags)
-
-libnm_util_tests_test_setting_dcb_CPPFLAGS = $(libnm_util_tests_cppflags)
-libnm_util_tests_test_setting_dcb_LDADD = $(libnm_util_tests_ldadd)
-libnm_util_tests_test_setting_dcb_LDFLAGS = $(libnm_util_tests_ldflags)
-
-libnm_util_tests_test_libnm_linking_CPPFLAGS = $(libnm_util_tests_cppflags)
-libnm_util_tests_test_libnm_linking_LDADD = \
- libnm/libnm.la \
- $(libnm_util_tests_ldadd)
-libnm_util_tests_test_libnm_linking_LDFLAGS = $(libnm_util_tests_ldflags)
-
-$(libnm_util_tests_test_settings_defaults_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-$(libnm_util_tests_test_crypto_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-$(libnm_util_tests_test_secrets_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-$(libnm_util_tests_test_general_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-$(libnm_util_tests_test_setting_8021x_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-$(libnm_util_tests_test_setting_dcb_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-$(libnm_util_tests_test_libnm_linking_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-
-EXTRA_DIST += \
- libnm-util/tests/meson.build
-
-###############################################################################
-# libnm-glib
-###############################################################################
-
-libnm_glib_cppflags = \
- $(dflt_cppflags) \
- -I$(srcdir)/shared \
- -I$(builddir)/shared \
- -I$(srcdir)/libnm-util \
- -I$(builddir)/libnm-util \
- -I$(srcdir)/libnm-glib \
- -I$(builddir)/libnm-glib \
- -DG_LOG_DOMAIN=\""libnm-glib"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB \
- $(DBUS_CFLAGS) \
- $(GLIB_CFLAGS)
-
-
-noinst_LTLIBRARIES += libnm-glib/libdeprecated-nm-glib.la
-
-libnm_glib_libdeprecated_nm_glib_la_SOURCES = \
- libnm-glib/libnm_glib.h \
- libnm-glib/libnm_glib.c
-
-libnm_glib_libdeprecated_nm_glib_la_CPPFLAGS = \
- $(libnm_glib_cppflags) \
- -Wno-deprecated-declarations \
- -Wno-deprecated
-
-libnm_glib_libdeprecated_nm_glib_la_LIBADD = \
- $(DBUS_LIBS) \
- $(GLIB_LIBS)
-
-libdeprecateddir = $(includedir)/libnm-glib
-libdeprecated_HEADERS = \
- libnm-glib/libnm_glib.h
-
-
-lib_LTLIBRARIES += libnm-glib/libnm-glib.la
-
-libnm_glib_libnmincludedir = $(includedir)/libnm-glib
-libnm_glib_libnmvpndir = $(includedir)/libnm-glib
-
-libnm_glib_lib_h_pub_real = \
- libnm-glib/nm-object.h \
- libnm-glib/nm-client.h \
- libnm-glib/nm-device.h \
- libnm-glib/nm-device-ethernet.h \
- libnm-glib/nm-device-infiniband.h \
- libnm-glib/nm-device-adsl.h \
- libnm-glib/nm-device-wifi.h \
- libnm-glib/nm-device-bt.h \
- libnm-glib/nm-device-olpc-mesh.h \
- libnm-glib/nm-device-bond.h \
- libnm-glib/nm-device-team.h \
- libnm-glib/nm-device-bridge.h \
- libnm-glib/nm-device-vlan.h \
- libnm-glib/nm-device-generic.h \
- libnm-glib/nm-access-point.h \
- libnm-glib/nm-ip4-config.h \
- libnm-glib/nm-device-modem.h \
- libnm-glib/nm-vpn-connection.h \
- libnm-glib/nm-types.h \
- libnm-glib/nm-active-connection.h \
- libnm-glib/nm-dhcp4-config.h \
- libnm-glib/nm-ip6-config.h \
- libnm-glib/nm-dhcp6-config.h \
- libnm-glib/nm-remote-connection.h \
- libnm-glib/nm-remote-settings.h \
- libnm-glib/nm-secret-agent.h \
- libnm-glib/nm-device-wimax.h \
- libnm-glib/nm-wimax-nsp.h
-libnm_glib_lib_h_pub_mkenums = \
- libnm-glib/nm-glib-enum-types.h
-libnm_glib_lib_h_priv = \
- libnm-glib/nm-object-private.h \
- libnm-glib/nm-device-private.h \
- libnm-glib/nm-types-private.h \
- libnm-glib/nm-object-cache.h \
- libnm-glib/nm-remote-connection-private.h \
- libnm-glib/nm-dbus-helpers-private.h
-
-libnm_glib_libnminclude_HEADERS = \
- $(libnm_glib_lib_h_pub_real)
-nodist_libnm_glib_libnminclude_HEADERS = \
- $(libnm_glib_lib_h_pub_mkenums)
-
-libnm_glib_vpn_h_real = \
- libnm-glib/nm-vpn-plugin.h \
- libnm-glib/nm-vpn-plugin-ui-interface.h \
- libnm-glib/nm-vpn-plugin-utils.h
-libnm_glib_vpn_h_mkenums = \
- libnm-glib/nm-vpn-enum-types.h
-
-libnm_glib_libnmvpn_HEADERS = \
- $(libnm_glib_vpn_h_real)
-
-nodist_libnm_glib_libnmvpn_HEADERS = \
- $(libnm_glib_vpn_h_mkenums)
-
-libnm_glib_lib_c_real = \
- libnm-glib/nm-object.c \
- libnm-glib/nm-dbus-helpers.c \
- libnm-glib/nm-client.c \
- libnm-glib/nm-device.c \
- libnm-glib/nm-device-ethernet.c \
- libnm-glib/nm-device-infiniband.c \
- libnm-glib/nm-device-adsl.c \
- libnm-glib/nm-device-wifi.c \
- libnm-glib/nm-device-bt.c \
- libnm-glib/nm-device-olpc-mesh.c \
- libnm-glib/nm-device-bond.c \
- libnm-glib/nm-device-team.c \
- libnm-glib/nm-device-bridge.c \
- libnm-glib/nm-device-vlan.c \
- libnm-glib/nm-device-generic.c \
- libnm-glib/nm-access-point.c \
- libnm-glib/nm-ip4-config.c \
- libnm-glib/nm-device-modem.c \
- libnm-glib/nm-vpn-connection.c \
- libnm-glib/nm-types.c \
- libnm-glib/nm-object-cache.c \
- libnm-glib/nm-active-connection.c \
- libnm-glib/nm-dhcp4-config.c \
- libnm-glib/nm-ip6-config.c \
- libnm-glib/nm-dhcp6-config.c \
- libnm-glib/nm-remote-connection.c \
- libnm-glib/nm-remote-settings.c \
- libnm-glib/nm-secret-agent.c \
- libnm-glib/nm-device-wimax.c \
- libnm-glib/nm-wimax-nsp.c
-libnm_glib_lib_c_mkenums = \
- libnm-glib/nm-glib-enum-types.c
-
-libnm_glib_libnm_glib_la_SOURCES = \
- $(libnm_glib_lib_c_real) \
- $(libnm_glib_lib_h_pub_real) \
- $(libnm_glib_lib_h_priv)
-
-nodist_libnm_glib_libnm_glib_la_SOURCES = \
- $(libnm_glib_lib_c_mkenums) \
- $(libnm_glib_lib_h_pub_mkenums)
-
-libnm_glib_libnm_glib_la_CPPFLAGS = \
- $(libnm_glib_cppflags) \
- $(LIBUDEV_CFLAGS) \
- $(NULL)
-
-libnm_glib_libnm_glib_la_LDFLAGS = \
- -Wl,--version-script=$(srcdir)/libnm-glib/libnm-glib.ver \
- -version-info "13:0:9"
-
-libnm_glib_libnm_glib_la_LIBADD = \
- libnm-util/libnm-util.la \
- libnm-glib/libdeprecated-nm-glib.la \
- shared/nm-udev-aux/libnm-udev-aux.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(LIBUDEV_LIBS) \
- $(NULL)
-
-$(libnm_glib_libnm_glib_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-
-GLIB_GENERATED += \
- $(libnm_glib_lib_h_pub_mkenums) \
- $(libnm_glib_lib_c_mkenums)
-nm_glib_enum_types_sources = $(libnm_glib_lib_h_pub_real)
-
-$(libnm_glib_libnm_glib_la_OBJECTS): $(libnm_glib_lib_h_pub_mkenums)
-
-check_programs_norun += libnm-glib/libnm-glib-test
-
-libnm_glib_libnm_glib_test_CFLAGS = $(libnm_glib_cppflags)
-libnm_glib_libnm_glib_test_LDADD = \
- libnm-glib/libnm-glib.la \
- libnm-util/libnm-util.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS)
-$(libnm_glib_libnm_glib_test_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-
-lib_LTLIBRARIES += libnm-glib/libnm-glib-vpn.la
-
-libnm_glib_vpn_c_real = \
- libnm-glib/nm-vpn-plugin.c \
- libnm-glib/nm-vpn-plugin-ui-interface.c \
- libnm-glib/nm-vpn-plugin-utils.c
-libnm_glib_vpn_c_mkenums = \
- libnm-glib/nm-vpn-enum-types.c
-libnm_glib_libnm_glib_vpn_la_SOURCES = \
- $(libnm_glib_vpn_c_real)
-nodist_libnm_glib_libnm_glib_vpn_la_SOURCES = \
- $(libnm_glib_vpn_c_mkenums)
-libnm_glib_libnm_glib_vpn_la_CPPFLAGS = $(libnm_glib_cppflags)
-libnm_glib_libnm_glib_vpn_la_LIBADD = \
- libnm-util/libnm-util.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS)
-libnm_glib_libnm_glib_vpn_la_LDFLAGS = \
- -Wl,--version-script=$(srcdir)/libnm-glib/libnm-glib-vpn.ver \
- -version-info "3:0:2"
-$(libnm_glib_libnm_glib_vpn_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-
-
-GLIB_GENERATED += \
- $(libnm_glib_vpn_h_mkenums) \
- $(libnm_glib_vpn_c_mkenums)
-nm_vpn_enum_types_sources = $(libnm_glib_vpn_h_real)
-
-$(libnm_glib_libnm_glib_vpn_la_OBJECTS): $(libnm_glib_vpn_h_mkenums)
-
-libnm-glib/nm-vpn-plugin-glue.h: introspection/org.freedesktop.NetworkManager.VPN.Plugin.xml
- $(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_plugin --mode=glib-server --output=$@ $<
-
-libnm-glib/nm-secret-agent-glue.h: introspection/org.freedesktop.NetworkManager.SecretAgent.xml
- $(AM_V_GEN) dbus-binding-tool --prefix=nm_secret_agent --mode=glib-server --output=$@ $<
-
-CLEANFILES += \
- libnm-glib/nm-vpn-plugin-glue.h \
- libnm-glib/nm-secret-agent-glue.h
-
-$(libnm_glib_libnm_glib_vpn_la_OBJECTS): libnm-glib/nm-vpn-plugin-glue.h
-$(libnm_glib_libnm_glib_la_OBJECTS): libnm-glib/nm-secret-agent-glue.h
-
-
-pkgconfig_DATA += \
- libnm-glib/libnm-glib.pc \
- libnm-glib/libnm-glib-vpn.pc
-
-DISTCLEANFILES += \
- libnm-glib/libnm-glib.pc \
- libnm-glib/libnm-glib.pc
-
-EXTRA_DIST += \
- libnm-glib/libnm-glib.pc.in \
- libnm-glib/libnm-glib-vpn.pc.in \
- libnm-glib/libnm-glib.ver \
- libnm-glib/libnm-glib-vpn.ver \
- libnm-glib/nm-vpn-enum-types.c.template \
- libnm-glib/nm-vpn-enum-types.h.template \
- libnm-glib/nm-glib-enum-types.c.template \
- libnm-glib/nm-glib-enum-types.h.template \
- libnm-glib/meson.build
-
-if HAVE_INTROSPECTION
-libnm-glib/NMClient-1.0.gir: libnm-glib/libnm-glib.la $(builddir)/libnm-util/NetworkManager-1.0.gir
-libnm_glib_NMClient_1_0_gir_INCLUDES = Gio-2.0 DBusGLib-1.0
-libnm_glib_NMClient_1_0_gir_PACKAGES = gio-2.0 dbus-glib-1
-libnm_glib_NMClient_1_0_gir_EXPORT_PACKAGES = libnm-glib libnm-glib-vpn
-libnm_glib_NMClient_1_0_gir_CFLAGS = $(libnm_glib_cppflags)
-libnm_glib_NMClient_1_0_gir_LIBS = \
- libnm-glib/libnm-glib.la \
- libnm-util/libnm-util.la
-libnm_glib_NMClient_1_0_gir_FILES = \
- $(libnm_glib_lib_h_pub_mkenums) \
- $(libnm_glib_lib_h_pub_real) \
- $(libnm_glib_lib_c_mkenums) \
- $(libnm_glib_lib_c_real)
-libnm_glib_NMClient_1_0_gir_SCANNERFLAGS = \
- -I$(srcdir)/libnm-util \
- -I$(builddir)/libnm-util \
- -I$(srcdir)/libnm-glib \
- -I$(builddir)/libnm-glib \
- --warn-all --identifier-prefix=NM --symbol-prefix=nm \
- --include-uninstalled=$(builddir)/libnm-util/NetworkManager-1.0.gir
-
-libnm-glib/NMClient-1.0.typelib: libnm-glib/NMClient-1.0.gir
- $(INTROSPECTION_COMPILER) "--includedir=$(srcdir)/libnm-util" "--includedir=$(builddir)/libnm-util" $< -o $@
-
-INTROSPECTION_GIRS += libnm-glib/NMClient-1.0.gir
-endif
-
-check-local-exports-libnm-glib:
- $(srcdir)/tools/check-exports.sh $(builddir)/libnm-glib/.libs/libnm-glib.so $(srcdir)/libnm-glib/libnm-glib.ver
-
-check_local += check-local-exports-libnm-glib
-
-dist_dependencies += \
- libnm-glib/libnm-glib.la \
- libnm-glib/libnm-glib-vpn.la
-
-###############################################################################
-# libnm-glib/tests
-###############################################################################
-
-libnm_glib_tests_cppflags = \
- $(dflt_cppflags) \
- -I$(srcdir)/shared \
- -I$(builddir)/shared \
- -I$(srcdir)/libnm-util \
- -I$(builddir)/libnm-util \
- -I$(srcdir)/libnm-glib \
- -DNETWORKMANAGER_COMPILATION_TEST \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB \
- $(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
- $(NULL)
-
-if HAVE_INTROSPECTION
-check-local-libnm-glib-nm-client: libnm-glib/tests/test-nm-client
- ( $(LOG_COMPILER) "$(builddir)/libnm-glib/tests/test-nm-client"; r="$$?"; test "$$r" = 0 -o "$$r" = 77 ) || \
- ( $(LOG_COMPILER) "$(builddir)/libnm-glib/tests/test-nm-client"; r="$$?"; test "$$r" = 0 -o "$$r" = 77 ) || \
- ( $(LOG_COMPILER) "$(builddir)/libnm-glib/tests/test-nm-client"; r="$$?"; test "$$r" = 0 -o "$$r" = 77 ) || \
- ( $(LOG_COMPILER) "$(builddir)/libnm-glib/tests/test-nm-client"; r="$$?"; test "$$r" = 0 -o "$$r" = 77 ) || \
- ( $(LOG_COMPILER) "$(builddir)/libnm-glib/tests/test-nm-client"; r="$$?"; test "$$r" = 0 -o "$$r" = 77 ) || \
- false
-
-check_local += check-local-libnm-glib-nm-client
-endif
-check_programs_norun += libnm-glib/tests/test-nm-client
-
-if HAVE_INTROSPECTION
-check_programs += libnm-glib/tests/test-remote-settings-client
-else
-check_programs_norun += libnm-glib/tests/test-remote-settings-client
-endif
-
-libnm_glib_tests_test_nm_client_CPPFLAGS = $(libnm_glib_tests_cppflags)
-
-libnm_glib_tests_test_nm_client_SOURCES = \
- shared/nm-test-utils-impl.c \
- shared/nm-test-libnm-utils.h \
- libnm-glib/tests/test-nm-client.c
-
-libnm_glib_tests_test_nm_client_LDADD = \
- libnm-util/libnm-util.la \
- libnm-glib/libnm-glib.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS)
-
-$(libnm_glib_tests_test_nm_client_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-
-
-libnm_glib_tests_test_remote_settings_client_CPPFLAGS = $(libnm_glib_tests_cppflags)
-
-libnm_glib_tests_test_remote_settings_client_SOURCES = \
- shared/nm-test-utils-impl.c \
- shared/nm-test-libnm-utils.h \
- libnm-glib/tests/test-remote-settings-client.c
-
-libnm_glib_tests_test_remote_settings_client_LDADD = \
- libnm-util/libnm-util.la \
- libnm-glib/libnm-glib.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS)
-
-$(libnm_glib_tests_test_remote_settings_client_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-
-# tools/test-networkmanager-service.py uses libnm's typelib. Ensure it
-# is built first.
-$(libnm_glib_tests_test_nm_client_OBJECTS): $(libnm_NM_1_0_typelib)
-$(libnm_glib_tests_test_remote_settings_client_OBJECTS): $(libnm_NM_1_0_typelib)
-
-endif
-
-EXTRA_DIST += \
- libnm-glib/tests/meson.build
-
-###############################################################################
# man
###############################################################################
@@ -5288,29 +4602,12 @@ if ENABLE_VAPIGEN
VAPIGEN_VAPIS += \
vapi/libnm.vapi
-if WITH_LEGACY_LIBRARIES
-VAPIGEN_VAPIS += \
- vapi/libnm-util.vapi \
- vapi/libnm-glib.vapi
-endif
-
vapi/libnm.vapi: $(builddir)/libnm/NM-1.0.gir vapi/libnm.deps vapi/NM-1.0.metadata
-vapi/libnm-util.vapi: $(builddir)/libnm-util/NetworkManager-1.0.gir vapi/libnm-util.deps vapi/NetworkManager-1.0.metadata
-vapi/libnm-glib.vapi: $(builddir)/libnm-glib/NMClient-1.0.gir vapi/libnm-glib.deps vapi/NMClient-1.0.metadata vapi/libnm-util.vapi
vapi_libnm_vapi_METADATADIRS = $(srcdir)/vapi
vapi_libnm_vapi_FILES = $(builddir)/libnm/NM-1.0.gir
vapi_libnm_vapi_DEPS = gio-2.0
-vapi_libnm_util_vapi_METADATADIRS = $(srcdir)/vapi
-vapi_libnm_util_vapi_FILES = $(builddir)/libnm-util/NetworkManager-1.0.gir
-
-vapi_libnm_glib_vapi_METADATADIRS = $(srcdir)/vapi
-vapi_libnm_glib_vapi_FILES = $(builddir)/libnm-glib/NMClient-1.0.gir
-vapi_libnm_glib_vapi_VAPIDIRS = $(builddir)/vapi
-vapi_libnm_glib_vapi_GIRDIRS = $(builddir)/libnm-util
-vapi_libnm_glib_vapi_DEPS = gio-2.0 dbus-glib-1 libnm-util
-
vapi_DATA += \
$(VAPIGEN_VAPIS) \
$(VAPIGEN_VAPIS:.vapi=.deps)
@@ -5321,11 +4618,7 @@ endif
EXTRA_DIST += \
vapi/NM-1.0.metadata \
- vapi/NetworkManager-1.0.metadata \
- vapi/NMClient-1.0.metadata \
vapi/libnm.deps \
- vapi/libnm-util.deps \
- vapi/libnm-glib.deps \
vapi/meson.build
###############################################################################
@@ -5445,7 +4738,7 @@ uninstall-hook: $(uninstall_hook)
###############################################################################
cscope:
- cscope -b -q -R -sshared -ssrc -slibnm-core -slibnm -slibnm-glib -slibnm-util -sclients;
+ cscope -b -q -R -sshared -ssrc -slibnm-core -slibnm -sclients;
###############################################################################
diff --git a/NEWS b/NEWS
index 5ec3facf9d..42b3c460e1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,21 @@
=============================================
+NetworkManager-1.20
+Overview of changes since NetworkManager-1.18
+=============================================
+
+This is a snapshot of NetworkManager 1.20 development series.
+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!
+
+* The libnm-glib library, deprecated in favor of libnm since NetworkManager 1.0,
+ and disabled by default since NetworkManager 1.12 has now been removed.
+* The DHCP client now defaults to "internal". The default can be overriden
+ at build time by using the --with-config-dhcp-default option of the
+ configure script or at run time by setting the main.dhcp option in the
+ configuration file.
+
+=============================================
NetworkManager-1.18
Overview of changes since NetworkManager-1.16
=============================================
diff --git a/autogen.sh b/autogen.sh
index 836bb60307..9bb0294888 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -28,5 +28,5 @@ AUTOPOINT='intltoolize --automake --copy' autoreconf --force --install --verbose
cd $olddir
if test -z "$NOCONFIGURE"; then
- exec $srcdir/configure --enable-maintainer-mode --enable-more-warnings=error --enable-gtk-doc --enable-introspection --with-libnm-glib "$@"
+ exec $srcdir/configure --enable-maintainer-mode --enable-more-warnings=error --enable-gtk-doc --enable-introspection "$@"
fi
diff --git a/clients/cli/common.c b/clients/cli/common.c
index 3c1c315d5e..2fc8aaf643 100644
--- a/clients/cli/common.c
+++ b/clients/cli/common.c
@@ -425,36 +425,38 @@ nmc_find_connection (const GPtrArray *connections,
GPtrArray **out_result,
gboolean complete)
{
- NMConnection *connection;
+ 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);
nm_assert (filter_val);
for (i = 0; i < connections->len; i++) {
- const char *v, *v_num;
+ gboolean match_by_uuid = FALSE;
+ NMConnection *connection;
+ const char *v;
+ const char *v_num;
connection = NM_CONNECTION (connections->pdata[i]);
- /* When filter_type is NULL, compare connection ID (filter_val)
- * against all types. Otherwise, only compare against the specific
- * type. If 'path' filter type is specified, comparison against
- * numeric index (in addition to the whole path) is allowed.
- */
- if (NM_IN_STRSET (filter_type, NULL, "id")) {
- v = nm_connection_get_id (connection);
- if (complete)
- nmc_complete_strings (filter_val, v, NULL);
- if (nm_streq0 (filter_val, v))
- goto found;
- }
-
if (NM_IN_STRSET (filter_type, NULL, "uuid")) {
v = nm_connection_get_uuid (connection);
if (complete && (filter_type || *filter_val))
- nmc_complete_strings (filter_val, v, NULL);
+ nmc_complete_strings (filter_val, v);
+ if (nm_streq0 (filter_val, v)) {
+ match_by_uuid = TRUE;
+ goto found;
+ }
+ }
+
+ if (NM_IN_STRSET (filter_type, NULL, "id")) {
+ v = nm_connection_get_id (connection);
+ if (complete)
+ nmc_complete_strings (filter_val, v);
if (nm_streq0 (filter_val, v))
goto found;
}
@@ -463,7 +465,7 @@ nmc_find_connection (const GPtrArray *connections,
v = nm_connection_get_path (connection);
v_num = nm_utils_dbus_path_get_last_component (v);
if (complete && (filter_type || *filter_val))
- nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL, NULL);
+ nmc_complete_strings (filter_val, v, (*filter_val ? v_num : NULL));
if ( nm_streq0 (filter_val, v)
|| (filter_type && nm_streq0 (filter_val, v_num)))
goto found;
@@ -472,29 +474,51 @@ nmc_find_connection (const GPtrArray *connections,
if (NM_IN_STRSET (filter_type, NULL, "filename")) {
v = nm_remote_connection_get_filename (NM_REMOTE_CONNECTION (connections->pdata[i]));
if (complete && (filter_type || *filter_val))
- nmc_complete_strings (filter_val, v, NULL);
+ nmc_complete_strings (filter_val, v);
if (nm_streq0 (filter_val, v))
goto found;
}
continue;
+
found:
- if (!out_result)
- return connection;
- if (!best_candidate)
- best_candidate = connection;
- if (!result)
- result = g_ptr_array_new_with_free_func (g_object_unref);
- for (j = 0; j < result->len; j++) {
- if (connection == result->pdata[j])
- break;
+ if (match_by_uuid) {
+ if ( !complete
+ && !out_result)
+ return connection;
+ best_candidate_uuid = connection;
+ } else {
+ if (!best_candidate)
+ best_candidate = connection;
+ }
+ if (out_result) {
+ gboolean already_tracked = FALSE;
+
+ if (!result) {
+ result_allocated = g_ptr_array_new_with_free_func (g_object_unref);
+ result = result_allocated;
+ } else {
+ for (j = 0; j < result->len; j++) {
+ if (connection == result->pdata[j]) {
+ already_tracked = TRUE;
+ break;
+ }
+ }
+ }
+ if (!already_tracked) {
+ if (match_by_uuid) {
+ /* the profile is matched exactly (by UUID). We prepend it
+ * to the list of all found profiles. */
+ g_ptr_array_insert (result, result_inital_len, g_object_ref (connection));
+ } else
+ g_ptr_array_add (result, g_object_ref (connection));
+ }
}
- if (j == result->len)
- g_ptr_array_add (result, g_object_ref (connection));
}
- NM_SET_OUT (out_result, result);
- return best_candidate;
+ if (result_allocated)
+ *out_result = g_steal_pointer (&result_allocated);
+ return best_candidate_uuid ?: best_candidate;
}
NMActiveConnection *
@@ -525,7 +549,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
if (NM_IN_STRSET (filter_type, NULL, "id")) {
v = nm_active_connection_get_id (candidate);
if (complete)
- nmc_complete_strings (filter_val, v, NULL);
+ nmc_complete_strings (filter_val, v);
if (nm_streq0 (filter_val, v))
goto found;
}
@@ -533,7 +557,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
if (NM_IN_STRSET (filter_type, NULL, "uuid")) {
v = nm_active_connection_get_uuid (candidate);
if (complete && (filter_type || *filter_val))
- nmc_complete_strings (filter_val, v, NULL);
+ nmc_complete_strings (filter_val, v);
if (nm_streq0 (filter_val, v))
goto found;
}
@@ -542,7 +566,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
v = con ? nm_connection_get_path (NM_CONNECTION (con)) : NULL;
v_num = nm_utils_dbus_path_get_last_component (v);
if (complete && (filter_type || *filter_val))
- nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL, NULL);
+ nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL);
if ( nm_streq0 (filter_val, v)
|| (filter_type && nm_streq0 (filter_val, v_num)))
goto found;
@@ -551,7 +575,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
if (NM_IN_STRSET (filter_type, NULL, "filename")) {
v = nm_remote_connection_get_filename (con);
if (complete && (filter_type || *filter_val))
- nmc_complete_strings (filter_val, v, NULL);
+ nmc_complete_strings (filter_val, v);
if (nm_streq0 (filter_val, v))
goto found;
}
@@ -560,7 +584,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
v = nm_object_get_path (NM_OBJECT (candidate));
v_num = nm_utils_dbus_path_get_last_component (v);
if (complete && (filter_type || *filter_val))
- nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL, NULL);
+ nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL);
if ( nm_streq0 (filter_val, v)
|| (filter_type && nm_streq0 (filter_val, v_num)))
goto found;
@@ -1254,9 +1278,9 @@ call_cmd (NmCli *nmc, GSimpleAsyncResult *simple, const NMCCommand *cmd, int arg
static void
nmc_complete_help (const char *prefix)
{
- nmc_complete_strings (prefix, "help", NULL);
+ nmc_complete_strings (prefix, "help");
if (*prefix == '-')
- nmc_complete_strings (prefix, "-help", "--help", NULL);
+ nmc_complete_strings (prefix, "-help", "--help");
}
/**
@@ -1395,7 +1419,7 @@ void
nmc_complete_bool (const char *prefix)
{
nmc_complete_strings (prefix, "true", "yes", "on",
- "false", "no", "off", NULL);
+ "false", "no", "off");
}
/**
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 6ee3b49f9d..0abbe8358f 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -1945,7 +1945,7 @@ get_connection (NmCli *nmc,
}
if (*argc == 1 && nmc->complete)
- nmc_complete_strings (**argv, "id", "uuid", "path", "filename", NULL);
+ nmc_complete_strings (**argv, "id", "uuid", "path", "filename");
if (NM_IN_STRSET (**argv, "id", "uuid", "path", "filename")) {
if (*argc == 1) {
@@ -2104,7 +2104,7 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
guint i_found_cons;
if (argc == 1 && nmc->complete)
- nmc_complete_strings (*argv, "id", "uuid", "path", "filename", "apath", NULL);
+ nmc_complete_strings (*argv, "id", "uuid", "path", "filename", "apath");
if (NM_IN_STRSET (*argv, "id", "uuid", "path", "filename", "apath")) {
selector = *argv;
@@ -2850,7 +2850,7 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
while (argc > 0) {
if (argc == 1 && nmc->complete)
- nmc_complete_strings (*argv, "ifname", "ap", "passwd-file", NULL);
+ nmc_complete_strings (*argv, "ifname", "ap", "passwd-file");
if (strcmp (*argv, "ifname") == 0) {
argc--;
@@ -3102,7 +3102,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
const char *selector = NULL;
if (arg_num == 1 && nmc->complete)
- nmc_complete_strings (*arg_ptr, "id", "uuid", "path", "filename", "apath", NULL);
+ nmc_complete_strings (*arg_ptr, "id", "uuid", "path", "filename", "apath");
if (NM_IN_STRSET (*arg_ptr, "id", "uuid", "path", "filename", "apath")) {
selector = *arg_ptr;
@@ -8171,7 +8171,7 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
next_arg (nmc, &argc, &argv, NULL);
if (argc == 1 && nmc->complete)
- nmc_complete_strings (*argv, "type", "con-name", "id", "uuid", "path", "filename", NULL);
+ nmc_complete_strings (*argv, "type", "con-name", "id", "uuid", "path", "filename");
nmc->return_value = NMC_RESULT_SUCCESS;
diff --git a/clients/cli/devices.c b/clients/cli/devices.c
index ad3a44c4de..0a0c3159e3 100644
--- a/clients/cli/devices.c
+++ b/clients/cli/devices.c
@@ -2473,7 +2473,7 @@ do_device_set (NmCli *nmc, int argc, char **argv)
gboolean flag;
if (argc == 1 && nmc->complete)
- nmc_complete_strings (*argv, "managed", "autoconnect", NULL);
+ nmc_complete_strings (*argv, "managed", "autoconnect");
if (matches (*argv, "managed")) {
argc--;
@@ -2997,7 +2997,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
}
rescan = *argv;
if (argc == 1 && nmc->complete)
- nmc_complete_strings (rescan, "auto", "no", "yes", NULL);
+ nmc_complete_strings (rescan, "auto", "no", "yes");
break;
default:
g_assert_not_reached();
@@ -3179,7 +3179,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
while (argc > 0) {
if (argc == 1 && nmc->complete) {
nmc_complete_strings (*argv, "ifname", "bssid", "password", "wep-key-type",
- "name", "private", "hidden", NULL);
+ "name", "private", "hidden");
}
if (strcmp (*argv, "ifname") == 0) {
@@ -3229,7 +3229,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
goto finish;
}
if (argc == 1 && nmc->complete)
- nmc_complete_strings (*argv, "key", "phrase", NULL);
+ nmc_complete_strings (*argv, "key", "phrase");
if (strcmp (*argv, "key") == 0)
wep_passphrase = FALSE;
else if (strcmp (*argv, "phrase") == 0)
@@ -3711,7 +3711,7 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv)
while (argc > 0) {
if (argc == 1 && nmc->complete) {
nmc_complete_strings (*argv, "ifname", "con-name", "ssid", "band",
- "channel", "password", NULL);
+ "channel", "password");
}
if (strcmp (*argv, "ifname") == 0) {
@@ -3753,7 +3753,7 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv)
}
band = *argv;
if (argc == 1 && nmc->complete)
- nmc_complete_strings (band, "a", "bg", NULL);
+ nmc_complete_strings (band, "a", "bg");
if (strcmp (band, "a") && strcmp (band, "bg")) {
g_string_printf (nmc->return_text, _("Error: band argument value '%s' is invalid; use 'a' or 'bg'."),
band);
@@ -3935,7 +3935,7 @@ do_device_wifi_rescan (NmCli *nmc, int argc, char **argv)
/* Get the parameters */
while (argc > 0) {
if (argc == 1 && nmc->complete)
- nmc_complete_strings (*argv, "ifname", "ssid", NULL);
+ nmc_complete_strings (*argv, "ifname", "ssid");
if (strcmp (*argv, "ifname") == 0) {
if (ifname) {
@@ -4122,7 +4122,7 @@ do_device_lldp_list (NmCli *nmc, int argc, char **argv)
next_arg (nmc, &argc, &argv, NULL);
while (argc > 0) {
if (argc == 1 && nmc->complete)
- nmc_complete_strings (*argv, "ifname", NULL);
+ nmc_complete_strings (*argv, "ifname");
if (strcmp (*argv, "ifname") == 0) {
argc--;
diff --git a/clients/cli/general.c b/clients/cli/general.c
index d713426b15..e2ce639ece 100644
--- a/clients/cli/general.c
+++ b/clients/cli/general.c
@@ -683,7 +683,7 @@ do_general_logging (NmCli *nmc, int argc, char **argv)
do {
if (argc == 1 && nmc->complete)
- nmc_complete_strings (*argv, "level", "domains", NULL);
+ nmc_complete_strings (*argv, "level", "domains");
if (matches (*argv, "level")) {
argc--;
@@ -878,7 +878,7 @@ do_networking_connectivity (NmCli *nmc, int argc, char **argv)
next_arg (nmc, &argc, &argv, NULL);
if (nmc->complete) {
if (argc == 1)
- nmc_complete_strings (*argv, "check", NULL);
+ nmc_complete_strings (*argv, "check");
return nmc->return_value;
}
diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c
index d7bc2a4629..d8300e780c 100644
--- a/clients/cli/nmcli.c
+++ b/clients/cli/nmcli.c
@@ -732,7 +732,7 @@ process_command_line (NmCli *nmc, int argc, char **argv)
nmc_complete_strings (argv[0], "--terse", "--pretty", "--mode", "--overview",
"--colors", "--escape",
"--fields", "--nocheck", "--get-values",
- "--wait", "--version", "--help", NULL);
+ "--wait", "--version", "--help");
}
if (argv[0][1] == '-' && argv[0][2] == '\0') {
diff --git a/clients/cli/utils.c b/clients/cli/utils.c
index a8b81279ed..a822dd89da 100644
--- a/clients/cli/utils.c
+++ b/clients/cli/utils.c
@@ -189,10 +189,10 @@ next_arg (NmCli *nmc, int *argc, char ***argv, ...)
if (nmc && nmc->complete && *argc == 1) {
while ((cmd_option = va_arg (args, const char *)))
- nmc_complete_strings (**argv, cmd_option, NULL);
+ nmc_complete_strings (**argv, cmd_option);
if (***argv == '-')
- nmc_complete_strings (**argv, "--ask", "--show-secrets", NULL);
+ nmc_complete_strings (**argv, "--ask", "--show-secrets");
va_end (args);
return 0;
diff --git a/config.h.meson b/config.h.meson
index c8f9805526..d4efd49f56 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -49,9 +49,6 @@
/* Define to 1 if you have the <sys/auxv.h> header file. */
#mesondefine HAVE_SYS_AUXV_H
-/* Define if systemd support is available */
-#mesondefine HAVE_SYSTEMD
-
/* Define if you have Linux Wireless Extensions support */
#mesondefine HAVE_WEXT
@@ -197,9 +194,6 @@
/* Define if you have dhcpcd */
#mesondefine WITH_DHCPCD
-/* Define for libnm to prevent GIR from loading libnm-glib */
-#mesondefine WITH_FAKE_TYPELIBS
-
/* Define if JANSSON is enabled */
#mesondefine WITH_JANSSON
@@ -221,9 +215,6 @@
/* Whether compilation of ibft setting plugin is enabled */
#mesondefine WITH_SETTINGS_PLUGIN_IBFT
-/* Define if you have Wi-Fi support */
-#mesondefine WITH_WIFI
-
/* Define if you have iwd support */
#mesondefine WITH_IWD
diff --git a/configure.ac b/configure.ac
index bf1967802f..f866cc8854 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], [18])
-m4_define([nm_micro_version], [0])
+m4_define([nm_minor_version], [19])
+m4_define([nm_micro_version], [1])
m4_define([nm_version],
[nm_major_version.nm_minor_version.nm_micro_version])
@@ -191,9 +191,6 @@ AC_SUBST(NM_DIST_VERSION, "$ac_distver")
AC_ARG_ENABLE(wifi, AS_HELP_STRING([--enable-wifi], [enable Wi-Fi support]))
if test "${enable_wifi}" != "no"; then
enable_wifi='yes'
- AC_DEFINE(WITH_WIFI, 1, [Define if you have Wi-Fi support])
-else
- AC_DEFINE(WITH_WIFI, 0, [Define if you have Wi-Fi support])
fi
AM_CONDITIONAL(WITH_WIFI, test "${enable_wifi}" = "yes")
@@ -257,34 +254,6 @@ AC_SUBST(GLIB_LIBS)
GOBJECT_INTROSPECTION_CHECK([0.9.6])
-AC_ARG_WITH(libnm-glib,
- AS_HELP_STRING([--with-libnm-glib],
- [build legacy libraries]))
-fake_typelibs=no
-if test "$with_libnm_glib" == "yes"; then
- PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.1 dbus-glib-1 >= 0.94, :,
- [AC_MSG_FAILURE([$DBUS_PKG_ERRORS
-
-Configure with --without-libnm-glib if you do not need the legacy libraries])
- ])
-
- if test "${found_introspection}" = "yes"; then
- AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
- if ! test x"$GLIB_COMPILE_RESOURCES" = x""; then
- fake_typelibs=yes
- fi
- fi
-else
- with_libnm_glib=no
-fi
-AM_CONDITIONAL(WITH_LEGACY_LIBRARIES, test "$with_libnm_glib" == "yes")
-if test "$fake_typelibs" = "yes"; then
- AC_DEFINE(WITH_FAKE_TYPELIBS, 1, [Define for libnm to prevent GIR from loading libnm-glib])
-else
- AC_DEFINE(WITH_FAKE_TYPELIBS, 0, [Define for libnm to prevent GIR from loading libnm-glib])
-fi
-AM_CONDITIONAL(WITH_FAKE_TYPELIBS, test "${fake_typelibs}" = "yes")
-
PKG_CHECK_MODULES([LIBUDEV], [libudev >= 175])
# Qt4
@@ -330,9 +299,6 @@ AS_IF([test -z "$with_systemdsystemunitdir"], with_systemdsystemunitdir=no)
AM_CONDITIONAL(HAVE_SYSTEMD, [test "$with_systemdsystemunitdir" != no])
if test "$with_systemdsystemunitdir" != no; then
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
- AC_DEFINE(HAVE_SYSTEMD, 1, [Define if systemd support is available])
-else
- AC_DEFINE(HAVE_SYSTEMD, 0, [Define if systemd support is available])
fi
PKG_CHECK_MODULES(SYSTEMD_200, [systemd >= 200], [have_systemd_200=yes], [have_systemd_200=no])
@@ -527,7 +493,7 @@ esac
# eBPF support
AC_ARG_WITH(ebpf,
- AS_HELP_STRING([--with-ebpf=yes|no|auto], [Build with eBPF support (default: auto)]),
+ AS_HELP_STRING([--with-ebpf=yes|no|auto], [Build with eBPF support [default=auto]]),
[], [with_ebpf=auto])
# 'auto' means 'false' because there are still some issues.
if test "$with_ebpf" = "yes" ; then
@@ -542,7 +508,7 @@ AM_CONDITIONAL(WITH_EBPF, test "${have_ebpf}" = "yes")
# SELinux support
AC_ARG_WITH(selinux,
- AS_HELP_STRING([--with-selinux=yes|no|auto], [Build with SELinux (default: auto)]),
+ AS_HELP_STRING([--with-selinux=yes|no|auto], [Build with SELinux [default=auto]]),
[], [with_selinux=auto])
if test "$with_selinux" = "yes" -o "$with_selinux" = "auto"; then
PKG_CHECK_MODULES(SELINUX, libselinux, [have_selinux=yes], [have_selinux=no])
@@ -559,7 +525,7 @@ else
fi
# libaudit support
-AC_ARG_WITH(libaudit, AS_HELP_STRING([--with-libaudit=yes|yes-disabled-by-default|no|auto], [Build with audit daemon support (default: auto). yes-disabled-by-default enables support, but disables it unless explicitly configured via NetworkManager.conf]),,[with_libaudit=auto])
+AC_ARG_WITH(libaudit, AS_HELP_STRING([--with-libaudit=yes|yes-disabled-by-default|no|auto], [Build with audit daemon support [default=auto]. yes-disabled-by-default enables support, but disables it unless explicitly configured via NetworkManager.conf]),,[with_libaudit=auto])
if test "$with_libaudit" = "yes" -o "$with_libaudit" = "yes-disabled-by-default" -o "$with_libaudit" = "auto"; then
PKG_CHECK_MODULES(LIBAUDIT, audit, [have_libaudit=yes], [have_libaudit=no])
if test "$with_libaudit" != "auto" -a "$have_libaudit" = "no"; then
@@ -881,15 +847,11 @@ fi
AC_ARG_WITH(config-dhcp-default,
AS_HELP_STRING([--with-config-dhcp-default=dhclient|dhcpcd|internal],
- [Default configuration option for main.dhcp setting, used as fallback if the configuration option is unset]),
+ [Default configuration option for main.dhcp setting, used as fallback if the configuration option is unset [default=internal]]),
[config_dhcp_default="$withval"], [config_dhcp_default=""])
-if test "$config_dhcp_default" = yes -o "$config_dhcp_default" = no; then
- config_dhcp_default=''
+if test "$config_dhcp_default" = yes -o "$config_dhcp_default" = no -o -z "$config_dhcp_default"; then
+ config_dhcp_default='internal'
fi
-test -z "$config_dhcp_default" -a "$with_dhcpcanon" != "no" && config_dhcp_default='dhcpcanon'
-test -z "$config_dhcp_default" -a "$with_dhclient" != "no" && config_dhcp_default='dhclient'
-test -z "$config_dhcp_default" -a "$with_dhcpcd" != "no" && config_dhcp_default='dhcpcd'
-test -z "$config_dhcp_default" && config_dhcp_default='internal'
AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_MAIN_DHCP, "$config_dhcp_default", [Default configuration option for main.dhcp setting])
AC_SUBST(NM_CONFIG_DEFAULT_MAIN_DHCP, $config_dhcp_default)
@@ -990,7 +952,7 @@ AC_DEFINE_UNQUOTED(SYSTEM_CA_PATH, "$SYSTEM_CA_PATH", [Define to path to system
AC_SUBST(SYSTEM_CA_PATH)
AC_ARG_WITH(kernel-firmware-dir,
- AS_HELP_STRING([--with-kernel-firmware-dir=DIR], [where kernel firmware directory is (default is /lib/firmware)]))
+ AS_HELP_STRING([--with-kernel-firmware-dir=DIR], [where kernel firmware directory is [default=/lib/firmware]]))
if test -n "$with_kernel_firmware_dir" ; then
KERNEL_FIRMWARE_DIR="$with_kernel_firmware_dir"
else
@@ -1077,12 +1039,12 @@ AM_CFLAGS="$AM_CFLAGS $with_cflags"
AC_ARG_ENABLE(more-asserts,
AS_HELP_STRING([--enable-more-asserts],
- [Enable more assertions for debugging (default: auto). Deprecated option. Use --with-more-asserts=level]))
+ [Enable more assertions for debugging [default=auto]. Deprecated option. Use --with-more-asserts=level]))
if test "${enable_more_asserts}" = "yes"; then
more_asserts=100
fi
AC_ARG_WITH(more-asserts,
- AS_HELP_STRING([--with-more-asserts=level], [Enable more assertions for debugging (0 = none, 100 = all, default: auto)]),
+ AS_HELP_STRING([--with-more-asserts=level], [Enable more assertions for debugging (0 = none, 100 = all) [default=auto]]),
[more_asserts=${with_more_asserts}],
[])
if test "${more_asserts}" = "no"; then
@@ -1097,7 +1059,7 @@ if test "${more_asserts}" = ""; then
fi
AC_DEFINE_UNQUOTED(NM_MORE_ASSERTS, $more_asserts, [Define if more asserts are enabled])
-AC_ARG_ENABLE(more-logging, AS_HELP_STRING([--enable-more-logging], [Enable more debug logging (default: auto)]))
+AC_ARG_ENABLE(more-logging, AS_HELP_STRING([--enable-more-logging], [Enable more debug logging [default=auto]]))
if test "${enable_more_logging}" = ""; then
enable_more_logging=${more_logging_default}
fi
@@ -1111,7 +1073,7 @@ NM_LTO
NM_LD_GC
AC_ARG_WITH(address-sanitizer,
- AS_HELP_STRING([--with-address-sanitizer=yes|no|exec], [Enable address sanitizer (default: no)]))
+ AS_HELP_STRING([--with-address-sanitizer=yes|no|exec], [Enable address sanitizer [default=no]]))
if test "$with_address_sanitizer" = yes -o "$with_address_sanitizer" = "exec"; then
CC_CHECK_FLAGS_APPEND([asan_cflags], [CFLAGS], [-fsanitize=address])
AS_IF([test -z "$asan_cflags"],
@@ -1133,7 +1095,7 @@ fi
AC_ARG_ENABLE(undefined-sanitizer,
AS_HELP_STRING([--enable-undefined-sanitizer],
- [Compile with undefined behavior sanitizer (default: no)]))
+ [Compile with undefined behavior sanitizer [default=no]]))
if (test "${enable_undefined_sanitizer}" = "yes"); then
CC_CHECK_FLAGS_APPEND([ubsan_cflags], [CFLAGS], [-fsanitize=undefined])
AS_IF([test -z "$ubsan_cflags"],
@@ -1179,9 +1141,9 @@ VAPIGEN_CHECK(0.17.1.24)
AC_CONFIG_COMMANDS([vapi], [$MKDIR_P vapi])
# Tests, utilities and documentation
-AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests=root|yes|no], [Build NetworkManager tests (default: yes)]))
+AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests=root|yes|no], [Build NetworkManager tests [default=yes]]))
AC_ARG_WITH(valgrind,
- AS_HELP_STRING([--with-valgrind=yes|no|path], [Use valgrind to memory-check the tests (default: no)]))
+ AS_HELP_STRING([--with-valgrind=yes|no|path], [Use valgrind to memory-check the tests [default=no]]))
# Fallback to --with-tests
AC_ARG_WITH(tests,
AS_HELP_STRING([--with-tests], [Build NetworkManager tests (deprecated)]))
@@ -1276,17 +1238,10 @@ AC_CONFIG_FILES([
Makefile
shared/nm-version-macros.h
libnm/libnm.pc
-libnm-util/libnm-util.pc
-libnm-glib/libnm-glib.pc
-libnm-glib/libnm-glib-vpn.pc
po/Makefile.in
data/org.freedesktop.NetworkManager.policy.in
docs/api/Makefile
docs/api/version.xml
-docs/libnm-glib/Makefile
-docs/libnm-glib/version.xml
-docs/libnm-util/Makefile
-docs/libnm-util/version.xml
docs/libnm/Makefile
docs/libnm/version.xml
NetworkManager.pc
@@ -1335,7 +1290,6 @@ echo " ofono: $with_ofono"
echo " concheck: $enable_concheck"
echo " libteamdctl: $enable_teamdctl"
echo " ovs: $enable_ovs"
-echo " libnm-glib: $with_libnm_glib"
echo " nmcli: $build_nmcli"
echo " nmtui: $build_nmtui"
echo " iwd: $ac_with_iwd"
diff --git a/contrib/debian/REQUIRED_PACKAGES b/contrib/debian/REQUIRED_PACKAGES
index 618c63cb70..a56c55d024 100755
--- a/contrib/debian/REQUIRED_PACKAGES
+++ b/contrib/debian/REQUIRED_PACKAGES
@@ -37,7 +37,6 @@ install \
iptables \
libcurl4-gnutls-dev \
libdbus-1-dev \
- libdbus-glib-1-dev \
libgcrypt11-dev \
libgirepository1.0-dev \
libglib2.0-dev \
diff --git a/contrib/fedora/REQUIRED_PACKAGES b/contrib/fedora/REQUIRED_PACKAGES
index 23a532f9e4..9928cf0000 100755
--- a/contrib/fedora/REQUIRED_PACKAGES
+++ b/contrib/fedora/REQUIRED_PACKAGES
@@ -28,7 +28,6 @@ install \
bzip2 \
cscope \
dbus-devel \
- dbus-glib-devel \
dbus-python \
dbus-x11 \
dhclient \
diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec
index cdb141f157..c237866a87 100644
--- a/contrib/fedora/rpm/NetworkManager.spec
+++ b/contrib/fedora/rpm/NetworkManager.spec
@@ -7,8 +7,6 @@
# Note that it contains __PLACEHOLDERS__ that will be replaced by the accompanying 'build.sh' script.
-%global dbus_glib_version 0.100
-
%global wireless_tools_version 1:28-0pre9
%global wpa_supplicant_version 1:1.1
@@ -62,11 +60,6 @@
%bcond_with test
%bcond_with lto
%bcond_with sanitizer
-%if 0%{?fedora} > 28 || 0%{?rhel} > 7
-%bcond_with libnm_glib
-%else
-%bcond_without libnm_glib
-%endif
%if 0%{?fedora}
%bcond_without connectivity_fedora
%else
@@ -190,7 +183,6 @@ BuildRequires: intltool
BuildRequires: gettext-devel
BuildRequires: dbus-devel >= %{dbus_version}
-BuildRequires: dbus-glib-devel >= %{dbus_glib_version}
%if 0%{?fedora}
BuildRequires: wireless-tools-devel >= %{wireless_tools_version}
%endif
@@ -392,37 +384,6 @@ This package contains NetworkManager support for PPP.
%endif
-%package glib
-Summary: Libraries for adding NetworkManager support to applications (old API).
-Group: Development/Libraries
-Requires: dbus >= %{dbus_version}
-Requires: dbus-glib >= %{dbus_glib_version}
-Conflicts: NetworkManager-libnm < %{epoch}:%{version}-%{release}
-
-%description glib
-This package contains the libraries that make it easier to use some
-NetworkManager functionality from applications that use glib. This is
-the older NetworkManager API. See also NetworkManager-libnm.
-
-
-%package glib-devel
-Summary: Header files for adding NetworkManager support to applications (old API).
-Group: Development/Libraries
-Requires: %{name}-glib%{?_isa} = %{epoch}:%{version}-%{release}
-Requires: glib2-devel
-Requires: pkgconfig
-Requires: dbus-glib-devel >= %{dbus_glib_version}
-Provides: %{name}-devel = %{epoch}:%{version}-%{release}
-Provides: %{name}-devel%{?_isa} = %{epoch}:%{version}-%{release}
-Obsoletes: %{name}-devel < %{epoch}:%{version}-%{release}
-
-%description glib-devel
-This package contains the header and pkg-config files for development
-applications using NetworkManager functionality from applications that
-use glib.
-This is the older NetworkManager API. See also NetworkManager-libnm-devel.
-
-
%package libnm
Summary: Libraries for adding NetworkManager support to applications (new API).
Group: Development/Libraries
@@ -624,12 +585,7 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
-Dconfig_plugins_default=%{config_plugins_default} \
-Dconfig_dns_rc_manager_default=%{dns_rc_manager_default} \
-Dconfig_logging_backend_default=%{logging_backend_default} \
- -Djson_validation=true \
-%if %{with libnm_glib}
- -Dlibnm_glib=true
-%else
- -Dlibnm_glib=false
-%endif
+ -Djson_validation=true
%meson_build
@@ -746,12 +702,7 @@ intltoolize --automake --copy --force
--with-config-plugins-default=%{config_plugins_default} \
--with-config-dns-rc-manager-default=%{dns_rc_manager_default} \
--with-config-logging-backend-default=%{logging_backend_default} \
- --enable-json-validation \
-%if %{with libnm_glib}
- --with-libnm-glib
-%else
- --without-libnm-glib
-%endif
+ --enable-json-validation
make %{?_smp_mflags}
@@ -861,9 +812,6 @@ fi
%if (0%{?fedora} && 0%{?fedora} < 28) || 0%{?rhel}
-%post glib -p /sbin/ldconfig
-%postun glib -p /sbin/ldconfig
-
%post libnm -p /sbin/ldconfig
%postun libnm -p /sbin/ldconfig
%endif
@@ -972,47 +920,6 @@ fi
%endif
-%if %{with libnm_glib}
-%files glib -f %{name}.lang
-%{_libdir}/libnm-glib.so.*
-%{_libdir}/libnm-glib-vpn.so.*
-%{_libdir}/libnm-util.so.*
-%{_libdir}/girepository-1.0/NetworkManager-1.0.typelib
-%{_libdir}/girepository-1.0/NMClient-1.0.typelib
-%endif
-
-
-%if %{with libnm_glib}
-%files glib-devel
-%dir %{_includedir}/libnm-glib
-%dir %{_includedir}/%{name}
-%{_includedir}/libnm-glib/*.h
-%{_includedir}/%{name}/%{name}.h
-%{_includedir}/%{name}/NetworkManagerVPN.h
-%{_includedir}/%{name}/nm-setting*.h
-%{_includedir}/%{name}/nm-connection.h
-%{_includedir}/%{name}/nm-utils-enum-types.h
-%{_includedir}/%{name}/nm-utils.h
-%{_includedir}/%{name}/nm-version.h
-%{_includedir}/%{name}/nm-version-macros.h
-%{_libdir}/pkgconfig/libnm-glib.pc
-%{_libdir}/pkgconfig/libnm-glib-vpn.pc
-%{_libdir}/pkgconfig/libnm-util.pc
-%{_libdir}/pkgconfig/%{name}.pc
-%{_libdir}/libnm-glib.so
-%{_libdir}/libnm-glib-vpn.so
-%{_libdir}/libnm-util.so
-%{_datadir}/gir-1.0/NetworkManager-1.0.gir
-%{_datadir}/gir-1.0/NMClient-1.0.gir
-%dir %{_datadir}/gtk-doc/html/libnm-glib
-%{_datadir}/gtk-doc/html/libnm-glib/*
-%dir %{_datadir}/gtk-doc/html/libnm-util
-%{_datadir}/gtk-doc/html/libnm-util/*
-%{_datadir}/vala/vapi/libnm-*.deps
-%{_datadir}/vala/vapi/libnm-*.vapi
-%endif
-
-
%files libnm -f %{name}.lang
%{_libdir}/libnm.so.*
%{_libdir}/girepository-1.0/NM-1.0.typelib
diff --git a/contrib/fedora/rpm/build_clean.sh b/contrib/fedora/rpm/build_clean.sh
index c486be5129..4efb3088c2 100755
--- a/contrib/fedora/rpm/build_clean.sh
+++ b/contrib/fedora/rpm/build_clean.sh
@@ -148,7 +148,6 @@ if [[ $NO_DIST != 1 ]]; then
--disable-dependency-tracking \
--enable-gtk-doc \
--enable-introspection \
- --with-libnm-glib \
--enable-ifcfg-rh \
--enable-ifupdown \
--enable-config-plugin-ibft \
diff --git a/contrib/scripts/nm-ci-run.sh b/contrib/scripts/nm-ci-run.sh
index 4a50dc30d8..fca58ca61f 100755
--- a/contrib/scripts/nm-ci-run.sh
+++ b/contrib/scripts/nm-ci-run.sh
@@ -107,7 +107,6 @@ run_autotools() {
\
--with-ebpf=no \
\
- --with-libnm-glib=yes \
--with-iwd=yes \
--with-ofono=yes \
--enable-teamdctl=$_WITH_LIBTEAM \
@@ -178,7 +177,6 @@ run_meson() {
\
-D ebpf=false \
\
- -D libnm_glib=true \
-D iwd=true \
-D ofono=true \
-D teamdctl=$_WITH_LIBTEAM \
diff --git a/docs/libnm-glib/Makefile.am b/docs/libnm-glib/Makefile.am
deleted file mode 100644
index dab2e3f7f7..0000000000
--- a/docs/libnm-glib/Makefile.am
+++ /dev/null
@@ -1,79 +0,0 @@
-## Process this file with automake to produce Makefile.in
-AUTOMAKE_OPTIONS = 1.6
-
-# The name of the module
-DOC_MODULE=libnm-glib
-
-# The top-level SGML file.
-DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml
-
-# The directory containing the source code. Relative to $(srcdir).
-# gtk-doc will search all .c & .h files beneath here for inline comments
-# documenting functions and macros.
-DOC_SOURCE_DIR=$(top_srcdir)/libnm-glib
-
-# Extra options to supply to gtkdoc-scan.
-SCAN_OPTIONS=
-
-# Extra options to supply to gtkdoc-mkdb.
-MKDB_OPTIONS=--sgml-mode --output-format=xml
-
-# Extra options to supply to gtkdoc-fixref.
-FIXXREF_OPTIONS=
-
-# Used for dependencies.
-HFILE_GLOB=$(top_srcdir)/libnm-glib/*.h
-CFILE_GLOB=$(top_srcdir)/libnm-glib/*.c
-
-# Header files to ignore when scanning.
-IGNORE_HFILES= \
- common.h \
- nm-dbus-helpers-private.h \
- nm-device-private.h \
- nm-object-cache.h \
- nm-object-private.h \
- nm-remote-connection-private.h \
- nm-types-private.h \
- nm-secret-agent-glue.h \
- nm-vpn-plugin-glue.h
-
-# Images to copy into HTML directory.
-HTML_IMAGES = libnm-glib.png
-
-# Extra XML files that are included by $(DOC_MAIN_SGML_FILE).
-content_files = version.xml
-
-# Other files to distribute.
-extra_files = libnm-glib.png
-
-
-# CFLAGS and LDFLAGS for compiling scan program. Only needed
-# if $(DOC_MODULE).types is non-empty.
-GTKDOC_CFLAGS = \
- -I$(top_srcdir)/shared \
- -I$(top_builddir)/shared \
- -I$(top_srcdir)/libnm-util \
- -I$(top_builddir)/libnm-util \
- -I$(top_srcdir)/libnm-glib \
- -I$(top_builddir)/libnm-glib \
- -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_8 \
- $(GLIB_CFLAGS) \
- $(DBUS_CFLAGS)
-
-GTKDOC_LIBS = \
- $(top_builddir)/libnm-glib/libnm-glib.la \
- $(GLIB_LIBS)
-
-
-# include common portion ...
-include $(top_srcdir)/gtk-doc.make
-
-EXTRA_DIST += version.xml.in meson.build
-
-CLEANFILES += \
- libnm-glib-sections.txt \
- libnm-glib-overrides.txt \
- html/* \
- tmpl/* \
- xml/*
-
diff --git a/docs/libnm-glib/libnm-glib-docs.xml b/docs/libnm-glib/libnm-glib-docs.xml
deleted file mode 100644
index 07551fb82c..0000000000
--- a/docs/libnm-glib/libnm-glib-docs.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
- <!ENTITY version SYSTEM "version.xml">
-]>
-
-<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
- <bookinfo>
- <title>libnm-glib Reference Manual</title>
- <releaseinfo>
- for libnm-glib &version;
- The latest version of this documentation can be found on-line at
- <ulink url="https://developer.gnome.org/libnm-glib/stable/">https://developer.gnome.org/libnm-glib/stable/</ulink>.
- </releaseinfo>
-
- <copyright>
- <year>2012</year>
- <year>2013</year>
- <year>2014</year>
- <year>2015</year>
- <year>2016</year>
- <year>2017</year>
- <year>2018</year>
- <holder>The NetworkManager Authors</holder>
- </copyright>
-
- <legalnotice>
- <para>
- Permission is granted to copy, distribute and/or modify this
- document under the terms of the <citetitle>GNU Free
- Documentation License</citetitle>, Version 1.1 or any later
- version published by the Free Software Foundation with no
- Invariant Sections, no Front-Cover Texts, and no Back-Cover
- Texts. You may obtain a copy of the <citetitle>GNU Free
- Documentation License</citetitle> from the Free Software
- Foundation by visiting <ulink type="http"
- url="http://www.fsf.org">their Web site</ulink> or by writing
- to:
-
- <address>
- The Free Software Foundation, Inc.,
- <street>51 Franklin Street</street> - Fifth Floor,
- <city>Boston</city>, <state>MA</state> <postcode>02110-1301</postcode>,
- <country>USA</country>
- </address>
- </para>
- </legalnotice>
- </bookinfo>
-
- <chapter id="ref-overview">
- <title>Object Overview</title>
- <para>
- libnm-glib maps closely to the actual D-Bus API that NetworkManager
- provides, simply wrapping the remote D-Bus objects as native GObjects,
- mapping D-Bus signals and properties to GObject signals and properties,
- and providing helpful accessor and utility functions. As such, objects
- in the libnm-glib API have the same properties, behavior, signals, and
- semantics as the NM D-Bus API.
- </para>
- <para>
- The following is a rough overview of the libnm-glib object structure and
- how to use the various parts of it:
- <mediaobject id="libnm-glib-overview">
- <imageobject>
- <imagedata fileref="libnm-glib.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </para>
- </chapter>
-
- <chapter>
- <title>libnm-glib API Reference</title>
- <xi:include href="xml/nm-client.xml"/>
- <xi:include href="xml/nm-active-connection.xml"/>
- <xi:include href="xml/nm-device.xml"/>
- <xi:include href="xml/nm-device-ethernet.xml"/>
- <xi:include href="xml/nm-device-wifi.xml"/>
- <xi:include href="xml/nm-device-modem.xml"/>
- <xi:include href="xml/nm-device-bt.xml"/>
- <xi:include href="xml/nm-device-wimax.xml"/>
- <xi:include href="xml/nm-device-adsl.xml"/>
- <xi:include href="xml/nm-device-bond.xml"/>
- <xi:include href="xml/nm-device-bridge.xml"/>
- <xi:include href="xml/nm-device-team.xml"/>
- <xi:include href="xml/nm-device-generic.xml"/>
- <xi:include href="xml/nm-device-infiniband.xml"/>
- <xi:include href="xml/nm-device-vlan.xml"/>
- <xi:include href="xml/nm-device-olpc-mesh.xml"/>
- <xi:include href="xml/nm-wimax-nsp.xml"/>
- <xi:include href="xml/nm-access-point.xml"/>
- <xi:include href="xml/nm-ip4-config.xml"/>
- <xi:include href="xml/nm-ip6-config.xml"/>
- <xi:include href="xml/nm-dhcp4-config.xml"/>
- <xi:include href="xml/nm-dhcp6-config.xml"/>
- <xi:include href="xml/nm-object.xml"/>
- <xi:include href="xml/nm-remote-connection.xml"/>
- <xi:include href="xml/nm-remote-settings.xml"/>
- <xi:include href="xml/nm-types.xml"/>
- <xi:include href="xml/nm-secret-agent.xml"/>
- <xi:include href="xml/nm-vpn-connection.xml"/>
- <xi:include href="xml/nm-vpn-plugin.xml"/>
- <xi:include href="xml/nm-vpn-plugin-ui-interface.xml"/>
- <xi:include href="xml/nm-vpn-plugin-utils.xml"/>
- </chapter>
-
- <chapter id="object-tree">
- <title>Object Hierarchy</title>
- <xi:include href="xml/tree_index.sgml"/>
- </chapter>
- <index id="api-index-full">
- <title>API Index</title>
- <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
- </index>
-
- <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
-</book>
-
diff --git a/docs/libnm-glib/libnm-glib.png b/docs/libnm-glib/libnm-glib.png
deleted file mode 100644
index dc00072842..0000000000
--- a/docs/libnm-glib/libnm-glib.png
+++ /dev/null
Binary files differ
diff --git a/docs/libnm-glib/libnm-glib.svg b/docs/libnm-glib/libnm-glib.svg
deleted file mode 100644
index 6bbfa29517..0000000000
--- a/docs/libnm-glib/libnm-glib.svg
+++ /dev/null
@@ -1,893 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="1052.3622"
- height="744.09448"
- id="svg2"
- version="1.1"
- inkscape:version="0.48.1 r9760"
- sodipodi:docname="libnm-glib.svg">
- <defs
- id="defs4">
- <marker
- inkscape:stockid="Arrow1Lend"
- orient="auto"
- refY="0"
- refX="0"
- id="Arrow1Lend"
- style="overflow:visible">
- <path
- id="path4069"
- d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
- style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
- transform="matrix(-0.8,0,0,-0.8,-10,0)"
- inkscape:connector-curvature="0" />
- </marker>
- <marker
- inkscape:stockid="Arrow1Lend"
- orient="auto"
- refY="0"
- refX="0"
- id="Arrow1Lend-2"
- style="overflow:visible">
- <path
- id="path4069-0"
- d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
- style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
- transform="matrix(-0.8,0,0,-0.8,-10,0)"
- inkscape:connector-curvature="0" />
- </marker>
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="0.98994949"
- inkscape:cx="433.76249"
- inkscape:cy="491.18568"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- inkscape:window-width="1280"
- inkscape:window-height="739"
- inkscape:window-x="0"
- inkscape:window-y="26"
- inkscape:window-maximized="1" />
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-308.2677)">
- <text
- xml:space="preserve"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="283.85287"
- y="97.768028"
- id="text3783"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3787"
- x="283.85287"
- y="97.768028"></tspan></text>
- <flowRoot
- xml:space="preserve"
- id="flowRoot3789"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"><flowRegion
- id="flowRegion3791"><rect
- id="rect3793"
- width="139.40105"
- height="113.13708"
- x="265.6701"
- y="97.768028" /></flowRegion><flowPara
- id="flowPara3795"></flowPara></flowRoot> <flowRoot
- xml:space="preserve"
- id="flowRoot3797"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"><flowRegion
- id="flowRegion3799"><rect
- id="rect3801"
- width="208.09143"
- height="133.34013"
- x="273.75134"
- y="121.00153"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans" /></flowRegion><flowPara
- id="flowPara3803"></flowPara></flowRoot> <flowRoot
- xml:space="preserve"
- id="flowRoot3825"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"><flowRegion
- id="flowRegion3827"><rect
- id="rect3829"
- width="175.76654"
- height="41.416256"
- x="28.284271"
- y="88.676651" /></flowRegion><flowPara
- id="flowPara3831">Propr</flowPara></flowRoot> <g
- id="g5635"
- transform="translate(-64.649763,3.0507627)">
- <text
- sodipodi:linespacing="125%"
- id="text3755-0"
- y="341.21481"
- x="573.86121"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
- xml:space="preserve"><tspan
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
- y="341.21481"
- x="573.86121"
- id="tspan3757-1"
- sodipodi:role="line">NMClient</tspan></text>
- <text
- sodipodi:linespacing="125%"
- id="text3833-6"
- y="357.37726"
- x="529.33325"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- xml:space="preserve"><tspan
- id="tspan3837-8"
- y="357.37726"
- x="529.33325"
- sodipodi:role="line">Base object; provides access to</tspan><tspan
- id="tspan4548"
- y="369.87726"
- x="529.33325"
- sodipodi:role="line">network device objects, active</tspan><tspan
- id="tspan4550"
- y="382.37726"
- x="529.33325"
- sodipodi:role="line">network connection objects and</tspan><tspan
- id="tspan4552"
- y="394.87726"
- x="529.33325"
- sodipodi:role="line">general network state information</tspan></text>
- </g>
- <text
- xml:space="preserve"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="104.07935"
- y="372.52951"
- id="text3833-6-7"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- x="104.07935"
- y="372.52951"
- id="tspan4552-6" /></text>
- <rect
- style="fill:none;stroke:#01003d;stroke-width:2.85214233;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985"
- width="209.21587"
- height="312.09604"
- x="12.270507"
- y="319.61136" />
- <text
- xml:space="preserve"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
- x="40.322777"
- y="344.24524"
- id="text3755"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757"
- x="40.322777"
- y="344.24524"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold">NMRemoteSettings</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="19.192902"
- y="360.40768"
- id="text3833"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- x="19.192902"
- y="360.40768"
- id="tspan3839">Retrieves, adds, and notifes of changes</tspan><tspan
- sodipodi:role="line"
- x="19.192902"
- y="372.90768"
- id="tspan3837">to network configuration objects</tspan><tspan
- sodipodi:role="line"
- x="19.192902"
- y="385.40768"
- id="tspan4682">(called NMRemoteConnections) </tspan></text>
- <rect
- style="fill:none;stroke:#01003d;stroke-width:1.13669348;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8"
- width="176.20061"
- height="82.832512"
- x="29.077385"
- y="403.84424" />
- <text
- xml:space="preserve"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
- x="38.158276"
- y="424.04724"
- id="text3755-3"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8"
- x="38.158276"
- y="424.04724"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMRemoteConnection</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="36.03054"
- y="443.60046"
- id="text3833-0"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- x="36.03054"
- y="443.60046"
- id="tspan3837-7">The basic unit of network</tspan><tspan
- sodipodi:role="line"
- x="36.03054"
- y="456.10046"
- id="tspan3873">configuration information,</tspan><tspan
- sodipodi:role="line"
- x="36.03054"
- y="468.60046"
- id="tspan3875">contains all settings required to</tspan><tspan
- sodipodi:role="line"
- x="36.03054"
- y="481.10046"
- id="tspan3877">connect to a specific network.</tspan></text>
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.68221813;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-4"
- width="176.20061"
- height="29.837376"
- x="28.067242"
- y="494.75793" />
- <text
- xml:space="preserve"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
- x="37.148129"
- y="514.96094"
- id="text3755-3-9"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8-0"
- x="37.148129"
- y="514.96094"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMRemoteConnection</tspan></text>
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.68221813;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-4-6"
- width="176.20061"
- height="29.837376"
- x="28.06724"
- y="532.36725" />
- <text
- xml:space="preserve"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
- x="37.148129"
- y="552.57025"
- id="text3755-3-9-3"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8-0-8"
- x="37.148129"
- y="552.57025"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMRemoteConnection</tspan></text>
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.68221813;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-4-8"
- width="176.20061"
- height="29.837376"
- x="28.067238"
- y="569.74286" />
- <text
- xml:space="preserve"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
- x="37.148125"
- y="589.94586"
- id="text3755-3-9-6"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8-0-6"
- x="37.148125"
- y="589.94586"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMRemoteConnection</tspan></text>
- <g
- id="g5581">
- <path
- transform="translate(24,308.27784)"
- d="m 75.76144,306.19336 a 3.5355339,3.5355339 0 1 1 -7.071068,0 3.5355339,3.5355339 0 1 1 7.071068,0 z"
- sodipodi:ry="3.5355339"
- sodipodi:rx="3.5355339"
- sodipodi:cy="306.19336"
- sodipodi:cx="72.225906"
- id="path4776"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- sodipodi:type="arc" />
- <path
- d="m 75.76144,306.19336 a 3.5355339,3.5355339 0 1 1 -7.071068,0 3.5355339,3.5355339 0 1 1 7.071068,0 z"
- sodipodi:ry="3.5355339"
- sodipodi:rx="3.5355339"
- sodipodi:cy="306.19336"
- sodipodi:cx="72.225906"
- id="path4776-1"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- sodipodi:type="arc"
- transform="translate(44.950515,308.27784)" />
- <path
- d="m 75.76144,306.19336 a 3.5355339,3.5355339 0 1 1 -7.071068,0 3.5355339,3.5355339 0 1 1 7.071068,0 z"
- sodipodi:ry="3.5355339"
- sodipodi:rx="3.5355339"
- sodipodi:cy="306.19336"
- sodipodi:cx="72.225906"
- id="path4776-1-4"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- sodipodi:type="arc"
- transform="translate(65.901025,308.27784)" />
- </g>
- <rect
- style="fill:none;stroke:#c30000;stroke-width:2.71445656;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-5"
- width="641.21594"
- height="454.62848"
- x="286.68472"
- y="321.29346" />
- <g
- id="g5644"
- transform="translate(348.50263,-5.0507629)">
- <rect
- y="466.47369"
- x="346.26532"
- height="68.182198"
- width="176.20061"
- id="rect2985-8-9"
- style="fill:none;stroke:#01003d;stroke-width:1.03128445;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982" />
- <text
- sodipodi:linespacing="125%"
- id="text3755-3-5"
- y="486.6767"
- x="400.8031"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
- xml:space="preserve"><tspan
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- y="486.6767"
- x="400.8031"
- id="tspan3757-8-00"
- sodipodi:role="line">NMDevice</tspan></text>
- <text
- sodipodi:linespacing="125%"
- id="text3833-0-5"
- y="501.17917"
- x="353.21848"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- xml:space="preserve"><tspan
- id="tspan3877-3"
- y="501.17917"
- x="353.21848"
- sodipodi:role="line">Represents a known network</tspan><tspan
- id="tspan5003"
- y="513.6792"
- x="353.21848"
- sodipodi:role="line">interface that may be used to</tspan><tspan
- id="tspan5005"
- y="526.1792"
- x="353.21848"
- sodipodi:role="line">connect to a network</tspan></text>
- </g>
- <text
- xml:space="preserve"
- style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="706.53918"
- y="144.96414"
- id="text5191"
- sodipodi:linespacing="125%"
- transform="matrix(0.91955281,0.39296645,-0.39296645,0.91955281,0,0)"><tspan
- sodipodi:role="line"
- id="tspan5193"
- x="706.53918"
- y="144.96414">nm_client_get_devices()</tspan></text>
- <g
- id="g5623"
- transform="translate(-419.9159,137.94419)">
- <rect
- y="447.99072"
- x="721.03192"
- height="96.526291"
- width="176.20061"
- id="rect2985-8-9-7"
- style="fill:none;stroke:#01003d;stroke-width:1.22705996;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982" />
- <text
- sodipodi:linespacing="125%"
- id="text3755-3-5-9"
- y="465.92065"
- x="740.21436"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
- xml:space="preserve"><tspan
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- y="465.92065"
- x="740.21436"
- id="tspan3757-8-00-9"
- sodipodi:role="line">NMActiveConnection</tspan></text>
- <text
- sodipodi:linespacing="125%"
- id="text3833-0-5-2"
- y="478.42313"
- x="723.98505"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- xml:space="preserve"><tspan
- id="tspan5005-7"
- y="478.42313"
- x="723.98505"
- sodipodi:role="line">Represents an active connection</tspan><tspan
- id="tspan5236"
- y="490.92313"
- x="723.98505"
- sodipodi:role="line">to a specific network, using</tspan><tspan
- id="tspan5238"
- y="503.42313"
- x="723.98505"
- sodipodi:role="line">settings from an</tspan><tspan
- id="tspan5240"
- y="515.9231"
- x="723.98505"
- sodipodi:role="line">NMRemoteConnection,and</tspan><tspan
- id="tspan5449"
- y="528.4231"
- x="723.98505"
- sodipodi:role="line">provided by on or more NMDevice</tspan><tspan
- id="tspan5451"
- y="540.9231"
- x="723.98505"
- sodipodi:role="line">objects.</tspan></text>
- </g>
- <text
- xml:space="preserve"
- style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="270.79764"
- y="722.53766"
- id="text5191-5"
- sodipodi:linespacing="125%"
- transform="matrix(0.94281033,-0.33332969,0.33332969,0.94281033,0,0)"><tspan
- sodipodi:role="line"
- id="tspan5193-8"
- x="270.79764"
- y="722.53766">nm_active_connection_get_devices()</tspan></text>
- <g
- id="g6720"
- transform="translate(-23.213166,-3.4365595)">
- <g
- transform="translate(320.19803,-24.89035)"
- id="g5561">
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-9-3-4"
- width="126.1828"
- height="26.245613"
- x="397.53818"
- y="597.80267" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="419.1745"
- y="615.39911"
- id="text3755-3-5-1-8"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8-00-3-7"
- x="419.1745"
- y="615.39911"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMDeviceWifi</tspan></text>
- </g>
- <g
- transform="translate(175.74622,-53.780741)"
- id="g5566">
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-9-3-5"
- width="126.1828"
- height="26.245613"
- x="541.98999"
- y="659.422" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="552.62244"
- y="677.01843"
- id="text3755-3-5-1-9"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- x="552.62244"
- y="677.01843"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- id="tspan5526">NMDeviceModem</tspan></text>
- </g>
- <g
- transform="translate(390.90872,-24.082284)"
- id="g5571">
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-9-3-2"
- width="126.1828"
- height="26.245613"
- x="326.82748"
- y="662.45251" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="330"
- y="680.04895"
- id="text3755-3-5-1-7"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8-00-3-1"
- x="330"
- y="680.04895"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMDeviceInfiniband</tspan></text>
- </g>
- <g
- transform="translate(278.7818,-37.820326)"
- id="g5576">
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-9-3-7"
- width="126.1828"
- height="26.245613"
- x="438.95441"
- y="708.91949" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="442.65225"
- y="726.51593"
- id="text3755-3-5-1-0"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- x="442.65225"
- y="726.51593"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- id="tspan5552">NMDeviceBluetooth</tspan></text>
- </g>
- <g
- id="g5581-7"
- transform="translate(663.65119,96.47973)">
- <path
- sodipodi:type="arc"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="path4776-10"
- sodipodi:cx="72.225906"
- sodipodi:cy="306.19336"
- sodipodi:rx="3.5355339"
- sodipodi:ry="3.5355339"
- d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z"
- transform="translate(24,308.27784)" />
- <path
- transform="translate(44.950515,308.27784)"
- sodipodi:type="arc"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="path4776-1-0"
- sodipodi:cx="72.225906"
- sodipodi:cy="306.19336"
- sodipodi:rx="3.5355339"
- sodipodi:ry="3.5355339"
- d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z" />
- <path
- transform="translate(65.901025,308.27784)"
- sodipodi:type="arc"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="path4776-1-4-7"
- sodipodi:cx="72.225906"
- sodipodi:cy="306.19336"
- sodipodi:rx="3.5355339"
- sodipodi:ry="3.5355339"
- d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z" />
- </g>
- <g
- transform="translate(371.71582,-10.142135)"
- id="g5556">
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.54146165;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-9-3"
- width="126.1828"
- height="26.245613"
- x="346.02039"
- y="550.3255" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="352.6069"
- y="567.92194"
- id="text3755-3-5-1"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8-00-3"
- x="352.6069"
- y="567.92194"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMDeviceEthernet</tspan></text>
- </g>
- </g>
- <path
- style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
- d="M 553.56359,93.556243 699.43095,153.15523"
- id="path6047"
- inkscape:connector-type="polyline"
- inkscape:connector-curvature="3"
- inkscape:connection-end="#g5644"
- inkscape:connection-end-point="d4"
- transform="translate(0,308.2677)" />
- <path
- style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
- d="M 477.31663,294.89252 694.76795,218.28417"
- id="path6231"
- inkscape:connector-type="polyline"
- inkscape:connector-curvature="3"
- inkscape:connection-start="#g5623"
- inkscape:connection-start-point="d4"
- inkscape:connection-end="#g5644"
- inkscape:connection-end-point="d4"
- transform="translate(0,308.2677)" />
- <path
- style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
- d="M 537.40115,93.556243 419.9937,277.66721"
- id="path6415"
- inkscape:connector-type="polyline"
- inkscape:connector-curvature="3"
- inkscape:connection-end="#g5623"
- inkscape:connection-end-point="d4"
- transform="translate(0,308.2677)" />
- <text
- xml:space="preserve"
- style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="-235.89041"
- y="662.71521"
- id="text5191-5-1"
- sodipodi:linespacing="125%"
- transform="matrix(0.53998594,-0.84167404,0.84167404,0.53998594,0,0)"><tspan
- sodipodi:role="line"
- id="tspan5193-8-5"
- x="-235.89041"
- y="662.71521">nm_client_get_active_connections()</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="824.3454"
- y="617.99652"
- id="text6932"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan6934"
- x="824.3454"
- y="617.99652">(Device subclasses)</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="685.34247"
- y="161.22107"
- id="text5191-9"
- sodipodi:linespacing="125%"
- transform="matrix(0.91955281,0.39296645,-0.39296645,0.91955281,0,0)"><tspan
- sodipodi:role="line"
- id="tspan5193-1"
- x="685.34247"
- y="161.22107">Gets all known interfaces</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="251.42001"
- y="738.39777"
- id="text5191-5-5"
- sodipodi:linespacing="125%"
- transform="matrix(0.94354535,-0.33124338,0.33124338,0.94354535,0,0)"><tspan
- sodipodi:role="line"
- id="tspan5193-8-1"
- x="251.42001"
- y="738.39777">Gets interfaces used by this active connection</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:9px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="-227.90929"
- y="680.09265"
- id="text5191-5-1-7"
- sodipodi:linespacing="125%"
- transform="matrix(0.54025777,-0.84149958,0.84149958,0.54025777,0,0)"><tspan
- sodipodi:role="line"
- id="tspan5193-8-5-2"
- x="-227.90929"
- y="680.09265">Gets all active network connections</tspan></text>
- <path
- style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend-2)"
- d="M 314.15744,683.6768 C 282.94516,704.65454 170.8596,719.38945 163.64471,598.82399"
- id="path7053"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cc" />
- <text
- xml:space="preserve"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="19.152279"
- y="706.91034"
- id="text7239"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan7241"
- x="19.152279"
- y="706.91034">Retrieve the NMRemoteConnection that provides</tspan><tspan
- sodipodi:role="line"
- x="19.152279"
- y="719.41034"
- id="tspan7243">configuration settings for the NMActiveConnection</tspan><tspan
- sodipodi:role="line"
- x="19.152279"
- y="731.91034"
- id="tspan7245">by getting its object path with</tspan><tspan
- sodipodi:role="line"
- x="19.152279"
- y="744.41034"
- id="tspan7247">nm_active_connection_get_connection() and then</tspan><tspan
- sodipodi:role="line"
- x="19.152279"
- y="756.91034"
- id="tspan7249">passing the returned path to</tspan><tspan
- sodipodi:role="line"
- x="19.152279"
- y="769.41034"
- id="tspan7251">nm_remote_settings_get_connection_by_path()</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:18px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
- x="10.101524"
- y="653.3316"
- id="text7253"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan7255"
- x="10.101524"
- y="653.3316">Network</tspan><tspan
- sodipodi:role="line"
- x="10.101524"
- y="675.8316"
- id="tspan7278">Configuration</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:18px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
- x="284.19009"
- y="798.65869"
- id="text7253-4"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan7255-8"
- x="284.19009"
- y="798.65869">Network Control</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
- x="701.04297"
- y="363.09201"
- id="text7239-7"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- x="701.04297"
- y="363.09201"
- id="tspan7251-6">Connect to a network by calling</tspan><tspan
- sodipodi:role="line"
- x="701.04297"
- y="375.59201"
- id="tspan7336">nm_client_activate_connection() and</tspan><tspan
- sodipodi:role="line"
- x="701.04297"
- y="388.09201"
- id="tspan7338">passing the NMDevice to use, along with</tspan><tspan
- sodipodi:role="line"
- x="701.04297"
- y="400.59201"
- id="tspan7342">the NMRemoteConnection that contains</tspan><tspan
- sodipodi:role="line"
- x="701.04297"
- y="413.09201"
- id="tspan7346">the settings that describe how to connect</tspan><tspan
- sodipodi:role="line"
- x="701.04297"
- y="425.59201"
- id="tspan7350">to that network</tspan></text>
- <g
- id="g5623-9"
- transform="translate(-369.71587,253.62599)">
- <g
- id="g7418"
- transform="translate(-28.915799,-13.111678)">
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.57918203;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-9-7-5"
- width="155.24031"
- height="24.408838"
- x="721.03192"
- y="447.99072" />
- <text
- xml:space="preserve"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
- x="725.99634"
- y="465.41437"
- id="text3755-3-5-9-3"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8-00-9-0"
- x="725.99634"
- y="465.41437"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMActiveConnection</tspan></text>
- </g>
- <g
- transform="translate(-28.915799,18.947049)"
- id="g7418-5">
- <rect
- style="fill:none;stroke:#01003d;stroke-width:0.57918203;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- id="rect2985-8-9-7-5-7"
- width="155.24031"
- height="24.408838"
- x="721.03192"
- y="447.99072" />
- <text
- xml:space="preserve"
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
- x="725.99634"
- y="465.41437"
- id="text3755-3-5-9-3-7"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3757-8-00-9-0-0"
- x="725.99634"
- y="465.41437"
- style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">NMActiveConnection</tspan></text>
- </g>
- </g>
- <g
- transform="translate(282.84399,143.9366)"
- id="g5581-6">
- <path
- transform="translate(24,308.27784)"
- d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z"
- sodipodi:ry="3.5355339"
- sodipodi:rx="3.5355339"
- sodipodi:cy="306.19336"
- sodipodi:cx="72.225906"
- id="path4776-6"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- sodipodi:type="arc" />
- <path
- d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z"
- sodipodi:ry="3.5355339"
- sodipodi:rx="3.5355339"
- sodipodi:cy="306.19336"
- sodipodi:cx="72.225906"
- id="path4776-1-2"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- sodipodi:type="arc"
- transform="translate(44.950515,308.27784)" />
- <path
- d="m 75.76144,306.19336 c 0,1.95262 -1.582912,3.53553 -3.535534,3.53553 -1.952621,0 -3.535534,-1.58291 -3.535534,-3.53553 0,-1.95262 1.582913,-3.53553 3.535534,-3.53553 1.952622,0 3.535534,1.58291 3.535534,3.53553 z"
- sodipodi:ry="3.5355339"
- sodipodi:rx="3.5355339"
- sodipodi:cy="306.19336"
- sodipodi:cx="72.225906"
- id="path4776-1-4-6"
- style="fill:#000000;fill-opacity:1;stroke:#01003d;stroke-width:0;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:10.49999982"
- sodipodi:type="arc"
- transform="translate(65.901025,308.27784)" />
- </g>
- </g>
-</svg>
diff --git a/docs/libnm-glib/libnm-glib.types b/docs/libnm-glib/libnm-glib.types
deleted file mode 100644
index 1cb7d40626..0000000000
--- a/docs/libnm-glib/libnm-glib.types
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "nm-client.h"
-#include "nm-object.h"
-#include "nm-device.h"
-#include "nm-device-ethernet.h"
-#include "nm-device-wifi.h"
-#include "nm-device-modem.h"
-#include "nm-device-bt.h"
-#include "nm-device-wimax.h"
-#include "nm-device-olpc-mesh.h"
-#include "nm-device-adsl.h"
-#include "nm-device-infiniband.h"
-#include "nm-device-bond.h"
-#include "nm-device-bridge.h"
-#include "nm-device-team.h"
-#include "nm-device-generic.h"
-#include "nm-device-vlan.h"
-#include "nm-access-point.h"
-#include "nm-ip4-config.h"
-#include "nm-ip6-config.h"
-#include "nm-active-connection.h"
-#include "nm-dhcp4-config.h"
-#include "nm-dhcp6-config.h"
-#include "nm-remote-settings.h"
-#include "nm-remote-connection.h"
-#include "nm-secret-agent.h"
-#include "nm-vpn-connection.h"
-
-nm_client_get_type
-nm_object_get_type
-nm_device_get_type
-nm_device_ethernet_get_type
-nm_device_wifi_get_type
-nm_device_modem_get_type
-nm_device_bt_get_type
-nm_device_wimax_get_type
-nm_device_olpc_mesh_get_type
-nm_device_adsl_get_type
-nm_device_infiniband_get_type
-nm_device_bond_get_type
-nm_device_bridge_get_type
-nm_device_team_get_type
-nm_device_generic_get_type
-nm_device_vlan_get_type
-nm_wimax_nsp_get_type
-nm_access_point_get_type
-nm_ip4_config_get_type
-nm_ip6_config_get_type
-nm_active_connection_get_type
-nm_dhcp4_config_get_type
-nm_dhcp6_config_get_type
-nm_remote_settings_get_type
-nm_remote_connection_get_type
-nm_secret_agent_get_type
-nm_vpn_connection_get_type
-
diff --git a/docs/libnm-glib/meson.build b/docs/libnm-glib/meson.build
deleted file mode 100644
index 622669ee76..0000000000
--- a/docs/libnm-glib/meson.build
+++ /dev/null
@@ -1,39 +0,0 @@
-doc_module = libnm_glib_name
-
-private_headers = [
- 'common.h',
- 'nm-dbus-helpers-private.h',
- 'nm-device-private.h',
- 'nm-object-cache.h',
- 'nm-object-private.h',
- 'nm-remote-connection-private.h',
- 'nm-types-private.h',
- 'nm-secret-agent-glue.h',
- 'nm-vpn-plugin-glue.h',
-]
-
-configure_file(
- input: version_xml + '.in',
- output: version_xml,
- configuration: version_conf,
-)
-
-gnome.gtkdoc(
- doc_module,
- main_xml: doc_module + '-docs.xml',
- src_dir: join_paths(meson.source_root(), 'libnm-glib'),
- dependencies: [
- libnm_glib_dep,
- libnm_glib_vpn_dep,
- ],
- scan_args: [
- '--rebuild-types',
- '--rebuild-sections',
- '--ignore-headers=' + ' '.join(private_headers),
- ],
- scanobjs_args: '--type-init-func="g_type_init();"',
- fixxref_args: '--html-dir=' + join_paths(nm_prefix, gnome.gtkdoc_html_dir(doc_module)),
- gobject_typesfile: doc_module + '.types',
- html_assets: doc_module + '.png',
- install: true,
-)
diff --git a/docs/libnm-glib/version.xml.in b/docs/libnm-glib/version.xml.in
deleted file mode 100644
index d78bda9342..0000000000
--- a/docs/libnm-glib/version.xml.in
+++ /dev/null
@@ -1 +0,0 @@
-@VERSION@
diff --git a/docs/libnm-util/Makefile.am b/docs/libnm-util/Makefile.am
deleted file mode 100644
index 5b8d7260ab..0000000000
--- a/docs/libnm-util/Makefile.am
+++ /dev/null
@@ -1,74 +0,0 @@
-## Process this file with automake to produce Makefile.in
-AUTOMAKE_OPTIONS = 1.6
-
-# The name of the module
-DOC_MODULE=libnm-util
-
-# The top-level SGML file.
-DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
-
-# The directory containing the source code. Relative to $(srcdir).
-# gtk-doc will search all .c & .h files beneath here for inline comments
-# documenting functions and macros.
-DOC_SOURCE_DIR= \
- $(top_builddir)/libnm-util \
- $(top_srcdir)/libnm-util
-
-# Extra options to supply to gtkdoc-scan.
-SCAN_OPTIONS=--rebuild-types --rebuild-sections
-
-# Extra options to supply to gtkdoc-mkdb.
-MKDB_OPTIONS=--sgml-mode --output-format=xml
-
-# Extra options to supply to gtkdoc-fixref.
-FIXXREF_OPTIONS=
-
-# Used for dependencies.
-HFILE_GLOB=$(top_srcdir)/libnm-util/*.h
-CFILE_GLOB=$(top_srcdir)/libnm-util/*.c
-
-# Header files to ignore when scanning.
-IGNORE_HFILES= \
- crypto.h \
- nm-utils-private.h \
- nm-setting-private.h \
- nm-param-spec-specialized.h \
- nm-test-utils.h \
- nm-version.h
-
-# Images to copy into HTML directory.
-HTML_IMAGES =
-
-# Extra XML files that are included by $(DOC_MAIN_SGML_FILE).
-content_files = version.xml
-
-# Other files to distribute.
-extra_files =
-
-
-# CFLAGS and LDFLAGS for compiling scan program. Only needed
-# if $(DOC_MODULE).types is non-empty.
-GTKDOC_CFLAGS = \
- -I$(top_srcdir)/libnm-util \
- -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_8 \
- $(GLIB_CFLAGS) \
- $(DBUS_CFLAGS)
-
-GTKDOC_LIBS = \
- $(top_builddir)/libnm-util/libnm-util.la \
- $(GLIB_LIBS)
-
-
-
-# include common portion ...
-include $(top_srcdir)/gtk-doc.make
-
-EXTRA_DIST += version.xml.in meson.build
-
-CLEANFILES += \
- libnm-util-sections.txt \
- libnm-util-overrides.txt \
- html/* \
- tmpl/* \
- xml/*
-
diff --git a/docs/libnm-util/libnm-util-docs.sgml b/docs/libnm-util/libnm-util-docs.sgml
deleted file mode 100644
index 6581788894..0000000000
--- a/docs/libnm-util/libnm-util-docs.sgml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
-[
- <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
- <!ENTITY version SYSTEM "version.xml">
-]>
-<book id="index">
- <bookinfo>
- <title>libnm-util Reference Manual</title>
- <releaseinfo>
- for libnm-util &version;
- The latest version of this documentation can be found on-line at
- <ulink url="https://developer.gnome.org/libnm-util/stable/">https://developer.gnome.org/libnm-util/stable/</ulink>.
- </releaseinfo>
-
- <copyright>
- <year>2012</year>
- <year>2013</year>
- <year>2014</year>
- <year>2015</year>
- <year>2016</year>
- <year>2017</year>
- <year>2018</year>
- <holder>The NetworkManager Authors</holder>
- </copyright>
-
- <legalnotice>
- <para>
- Permission is granted to copy, distribute and/or modify this
- document under the terms of the <citetitle>GNU Free
- Documentation License</citetitle>, Version 1.1 or any later
- version published by the Free Software Foundation with no
- Invariant Sections, no Front-Cover Texts, and no Back-Cover
- Texts. You may obtain a copy of the <citetitle>GNU Free
- Documentation License</citetitle> from the Free Software
- Foundation by visiting <ulink type="http"
- url="http://www.fsf.org">their Web site</ulink> or by writing
- to:
-
- <address>
- The Free Software Foundation, Inc.,
- <street>51 Franklin Street</street> - Fifth Floor,
- <city>Boston</city>, <state>MA</state> <postcode>02110-1301</postcode>,
- <country>USA</country>
- </address>
- </para>
- </legalnotice>
- </bookinfo>
-
- <chapter>
- <title>libnm-util API Reference</title>
- <xi:include href="xml/nm-connection.xml"/>
- <xi:include href="xml/nm-setting.xml"/>
- <xi:include href="xml/nm-setting-connection.xml"/>
- <xi:include href="xml/nm-setting-wired.xml"/>
- <xi:include href="xml/nm-setting-wireless.xml"/>
- <xi:include href="xml/nm-setting-wireless-security.xml"/>
- <xi:include href="xml/nm-setting-bluetooth.xml"/>
- <xi:include href="xml/nm-setting-serial.xml"/>
- <xi:include href="xml/nm-setting-cdma.xml"/>
- <xi:include href="xml/nm-setting-gsm.xml"/>
- <xi:include href="xml/nm-setting-wimax.xml"/>
- <xi:include href="xml/nm-setting-bond.xml"/>
- <xi:include href="xml/nm-setting-bridge.xml"/>
- <xi:include href="xml/nm-setting-bridge-port.xml"/>
- <xi:include href="xml/nm-setting-team.xml"/>
- <xi:include href="xml/nm-setting-team-port.xml"/>
- <xi:include href="xml/nm-setting-generic.xml"/>
- <xi:include href="xml/nm-setting-infiniband.xml"/>
- <xi:include href="xml/nm-setting-vlan.xml"/>
- <xi:include href="xml/nm-setting-olpc-mesh.xml"/>
- <xi:include href="xml/nm-setting-adsl.xml"/>
- <xi:include href="xml/nm-setting-dcb.xml"/>
- <xi:include href="xml/nm-setting-8021x.xml"/>
- <xi:include href="xml/nm-setting-ip4-config.xml"/>
- <xi:include href="xml/nm-setting-ip6-config.xml"/>
- <xi:include href="xml/nm-setting-ppp.xml"/>
- <xi:include href="xml/nm-setting-pppoe.xml"/>
- <xi:include href="xml/nm-setting-vpn.xml"/>
- <xi:include href="xml/nm-utils.xml"/>
- <xi:include href="xml/NetworkManager.xml"/>
- <xi:include href="xml/NetworkManagerVPN.xml"/>
-
- </chapter>
- <chapter id="object-tree">
- <title>Object Hierarchy</title>
- <xi:include href="xml/tree_index.sgml"/>
- </chapter>
- <index id="api-index-full">
- <title>API Index</title>
- <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
- </index>
-
- <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
-</book>
diff --git a/docs/libnm-util/meson.build b/docs/libnm-util/meson.build
deleted file mode 100644
index 1492103dc9..0000000000
--- a/docs/libnm-util/meson.build
+++ /dev/null
@@ -1,32 +0,0 @@
-doc_module = libnm_util_name
-
-private_headers = [
- 'crypto.h',
- 'nm-utils-private.h',
- 'nm-setting-private.h',
- 'nm-param-spec-specialized.h',
- 'nm-test-utils.h',
- 'nm-version.h',
-]
-
-configure_file(
- input: version_xml + '.in',
- output: version_xml,
- configuration: version_conf,
-)
-
-gnome.gtkdoc(
- doc_module,
- main_xml: doc_module + '-docs.sgml',
- src_dir: libnm_util_inc,
- dependencies: libnm_util_dep,
- scan_args: [
- '--rebuild-types',
- '--rebuild-sections',
- '--ignore-headers=' + ' '.join(private_headers),
- ],
- scanobjs_args: '--type-init-func="g_type_init();"',
- fixxref_args: '--html-dir=' + join_paths(nm_prefix, gnome.gtkdoc_html_dir(doc_module)),
- gobject_typesfile: doc_module + '.types',
- install: true,
-)
diff --git a/docs/libnm-util/version.xml.in b/docs/libnm-util/version.xml.in
deleted file mode 100644
index d78bda9342..0000000000
--- a/docs/libnm-util/version.xml.in
+++ /dev/null
@@ -1 +0,0 @@
-@VERSION@
diff --git a/docs/meson.build b/docs/meson.build
index 5c053165a1..cc814b77e7 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -6,11 +6,6 @@ version_xml = 'version.xml'
subdir('libnm')
subdir('api')
-if enable_libnm_glib
- subdir('libnm-util')
- subdir('libnm-glib')
-endif
-
test(
'check-docs',
find_program(join_paths(meson.source_root(), 'tools', 'check-docs.sh')),
diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c
index 2e9081df29..db0f64644c 100644
--- a/libnm-core/nm-setting.c
+++ b/libnm-core/nm-setting.c
@@ -2612,21 +2612,6 @@ static void
nm_setting_class_init (NMSettingClass *setting_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- GModule *self_module;
- gpointer func;
-
- /* loading libnm and legacy libraries libnm-util/libnm-glib at the same
- * time is not supported. The reason is, that both libraries use the same
- * glib type names ("NMSetting"), and glib does not support namespacing
- * to allow for that.
- *
- * Arbitrarily, add a check here, see whether a known symbol from libnm-util
- * is present. If it is, it indicates that the process is borked and we
- * abort. */
- self_module = g_module_open (NULL, 0);
- if (g_module_symbol (self_module, "nm_util_get_private", &func))
- g_error ("libnm-util symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported");
- g_module_close (self_module);
g_type_class_add_private (setting_class, sizeof (NMSettingPrivate));
diff --git a/libnm-core/nm-version.h b/libnm-core/nm-version.h
index 0ac2955baa..189efe8249 100644
--- a/libnm-core/nm-version.h
+++ b/libnm-core/nm-version.h
@@ -202,4 +202,18 @@
# define NM_AVAILABLE_IN_1_18
#endif
+#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_20
+# define NM_DEPRECATED_IN_1_20 G_DEPRECATED
+# define NM_DEPRECATED_IN_1_20_FOR(f) G_DEPRECATED_FOR(f)
+#else
+# define NM_DEPRECATED_IN_1_20
+# define NM_DEPRECATED_IN_1_20_FOR(f)
+#endif
+
+#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_20
+# define NM_AVAILABLE_IN_1_20 G_UNAVAILABLE(1,20)
+#else
+# define NM_AVAILABLE_IN_1_20
+#endif
+
#endif /* NM_VERSION_H */
diff --git a/libnm-glib/libnm-glib-test.c b/libnm-glib/libnm-glib-test.c
deleted file mode 100644
index 3b1866c587..0000000000
--- a/libnm-glib/libnm-glib-test.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * libnm_glib -- Access network status & information from glib applications
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2008 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <stdlib.h>
-#include <signal.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "nm-client.h"
-#include "nm-device.h"
-#include "nm-device-ethernet.h"
-#include "nm-device-wifi.h"
-#include "nm-device-generic.h"
-#include "nm-utils.h"
-#include "nm-active-connection.h"
-#include "nm-vpn-connection.h"
-#include "nm-setting-ip4-config.h"
-
-static gboolean
-test_wireless_enabled (NMClient *client)
-{
- gboolean wireless;
-
- wireless = nm_client_wireless_get_enabled (client);
- g_print ("Wireless enabled? %s\n", wireless ? "yes" : "no");
-
-// nm_client_wireless_set_enabled (client, !wireless);
-
- wireless = nm_client_wireless_hardware_get_enabled (client);
- g_print ("Wireless HW enabled? %s\n", wireless ? "yes" : "no");
-
-// nm_client_wireless_set_enabled (client, !wireless);
-
- return TRUE;
-}
-
-static gboolean
-test_get_state (NMClient *client)
-{
- guint state;
-
- state = nm_client_get_state (client);
- g_print ("Current state: %d\n", state);
-
- return TRUE;
-}
-
-static char *
-ip4_address_as_string (guint32 ip)
-{
- char buf[INET_ADDRSTRLEN+1];
- guint32 tmp_addr;
-
- memset (&buf, '\0', sizeof (buf));
- tmp_addr = ip;
-
- if (inet_ntop (AF_INET, &tmp_addr, buf, INET_ADDRSTRLEN)) {
- return g_strdup (buf);
- } else {
- g_warning ("%s: error converting IP4 address 0x%X",
- __func__, ntohl (tmp_addr));
- return NULL;
- }
-}
-
-static void
-dump_ip4_config (NMIP4Config *cfg)
-{
- char *tmp;
- const GArray *array;
- const GPtrArray *ptr_array;
- GSList *iter;
- int i;
-
- for (iter = (GSList *) nm_ip4_config_get_addresses (cfg); iter; iter = g_slist_next (iter)) {
- NMIP4Address *addr = iter->data;
- guint32 u;
-
- tmp = ip4_address_as_string (nm_ip4_address_get_address (addr));
- g_print ("IP4 address: %s\n", tmp);
- g_free (tmp);
-
- u = nm_ip4_address_get_prefix (addr);
- tmp = ip4_address_as_string (nm_utils_ip4_prefix_to_netmask (u));
- g_print ("IP4 prefix: %d (%s)\n", u, tmp);
- g_free (tmp);
-
- tmp = ip4_address_as_string (nm_ip4_address_get_gateway (addr));
- g_print ("IP4 gateway: %s\n\n", tmp);
- g_free (tmp);
- }
-
- array = nm_ip4_config_get_nameservers (cfg);
- if (array) {
- g_print ("IP4 DNS:\n");
- for (i = 0; i < array->len; i++) {
- tmp = ip4_address_as_string (g_array_index (array, guint32, i));
- g_print ("\t%s\n", tmp);
- g_free (tmp);
- }
- }
-
- ptr_array = nm_ip4_config_get_domains (cfg);
- if (ptr_array) {
- g_print ("IP4 domains:\n");
- for (i = 0; i < ptr_array->len; i++)
- g_print ("\t%s\n", (const char *) g_ptr_array_index (ptr_array, i));
- }
-
- array = nm_ip4_config_get_wins_servers (cfg);
- if (array) {
- g_print ("IP4 WINS:\n");
- for (i = 0; i < array->len; i++) {
- tmp = ip4_address_as_string (g_array_index (array, guint32, i));
- g_print ("\t%s\n", tmp);
- g_free (tmp);
- }
- }
-}
-
-static void
-print_one_dhcp4_option (gpointer key, gpointer data, gpointer user_data)
-{
- const char *option = (const char *) key;
- const char *value = (const char *) data;
-
- g_print (" %s: %s\n", option, value);
-}
-
-static void
-dump_dhcp4_config (NMDHCP4Config *config)
-{
- GHashTable *options = NULL;
-
- if (!config)
- return;
-
- g_print ("\nDHCP4 Options:\n");
- g_print ("-------------------------------------\n");
-
- g_object_get (G_OBJECT (config), NM_DHCP4_CONFIG_OPTIONS, &options, NULL);
- g_hash_table_foreach (options, print_one_dhcp4_option, NULL);
-}
-
-static void
-dump_access_point (NMAccessPoint *ap)
-{
- const GByteArray * ssid;
- const char * str;
-
- ssid = nm_access_point_get_ssid (ap);
- g_print ("\tSsid: %s\n",
- ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
-
- str = nm_access_point_get_bssid (ap);
- g_print ("\tMAC Address: %s\n", str);
-
- g_print ("\tFlags: 0x%X\n", nm_access_point_get_flags (ap));
- g_print ("\tWPA Flags: 0x%X\n", nm_access_point_get_wpa_flags (ap));
- g_print ("\tRSN Flags: 0x%X\n", nm_access_point_get_rsn_flags (ap));
- g_print ("\tFrequency: %u\n", nm_access_point_get_frequency (ap));
-
- g_print ("\tMode: %d\n", nm_access_point_get_mode (ap));
- g_print ("\tRate: %d\n", nm_access_point_get_max_bitrate (ap));
- g_print ("\tStrength: %d\n", nm_access_point_get_strength (ap));
-}
-
-static void
-dump_wireless (NMDeviceWifi *device)
-{
- const char *str;
- const GPtrArray *aps;
- int i;
-
- g_print ("Mode: %d\n", nm_device_wifi_get_mode (device));
- g_print ("Bitrate: %d\n", nm_device_wifi_get_bitrate (device));
-
- str = nm_device_wifi_get_hw_address (device);
- g_print ("MAC: %s\n", str);
-
- g_print ("AccessPoints:\n");
- aps = nm_device_wifi_get_access_points (device);
- for (i = 0; aps && (i < aps->len); i++) {
- dump_access_point (NM_ACCESS_POINT (g_ptr_array_index (aps, i)));
- g_print ("\n");
- }
-}
-
-static void
-dump_generic (NMDeviceGeneric *device)
-{
- g_print ("HW address: %s\n", nm_device_generic_get_hw_address (device));
-}
-
-static void
-dump_wired (NMDeviceEthernet *device)
-{
- const char *str;
-
- g_print ("Speed: %d\n", nm_device_ethernet_get_speed (device));
-
- str = nm_device_ethernet_get_hw_address (device);
- g_print ("MAC: %s\n", str);
-}
-
-static void
-dump_device (NMDevice *device)
-{
- const char *str;
- NMDeviceState state;
-
- str = nm_device_get_iface (device);
- g_print ("Interface: %s\n", str);
-
- str = nm_device_get_udi (device);
- g_print ("Udi: %s\n", str);
-
- str = nm_device_get_driver (device);
- g_print ("Driver: %s\n", str);
-
- str = nm_device_get_vendor (device);
- g_print ("Vendor: %s\n", str);
-
- str = nm_device_get_product (device);
- g_print ("Product: %s\n", str);
-
- state = nm_device_get_state (device);
- g_print ("State: %d\n", state);
-
- if (state == NM_DEVICE_STATE_ACTIVATED)
- dump_ip4_config (nm_device_get_ip4_config (device));
-
- if (NM_IS_DEVICE_ETHERNET (device))
- dump_wired (NM_DEVICE_ETHERNET (device));
- else if (NM_IS_DEVICE_WIFI (device))
- dump_wireless (NM_DEVICE_WIFI (device));
- else if (NM_IS_DEVICE_GENERIC (device))
- dump_generic (NM_DEVICE_GENERIC (device));
-
- dump_dhcp4_config (nm_device_get_dhcp4_config (device));
-}
-
-static gboolean
-test_devices (NMClient *client)
-{
- const GPtrArray *devices;
- int i;
-
- devices = nm_client_get_devices (client);
- g_print ("Got devices:\n");
- if (!devices) {
- g_print (" NONE\n");
- return TRUE;
- }
-
- for (i = 0; i < devices->len; i++) {
- NMDevice *device = g_ptr_array_index (devices, i);
- dump_device (device);
- g_print ("\n");
- }
-
- return TRUE;
-}
-
-static void
-active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_data)
-{
- const GPtrArray *connections;
- int i, j;
-
- g_print ("Active connections changed:\n");
- connections = nm_client_get_active_connections (client);
- for (i = 0; connections && (i < connections->len); i++) {
- NMActiveConnection *connection;
- const GPtrArray *devices;
-
- connection = g_ptr_array_index (connections, i);
- g_print (" %s\n", nm_object_get_path (NM_OBJECT (connection)));
- devices = nm_active_connection_get_devices (connection);
- for (j = 0; devices && j < devices->len; j++)
- g_print (" %s\n", nm_device_get_udi (g_ptr_array_index (devices, j)));
- if (NM_IS_VPN_CONNECTION (connection))
- g_print (" VPN base connection: %s\n", nm_active_connection_get_specific_object (connection));
- }
-}
-
-static void
-show_active_connection_device (gpointer data, gpointer user_data)
-{
- NMDevice *device = NM_DEVICE (data);
-
- g_print (" %s\n", nm_device_get_udi (device));
-}
-
-static void
-test_get_active_connections (NMClient *client)
-{
- const GPtrArray *connections;
- int i;
-
- g_print ("Active connections:\n");
- connections = nm_client_get_active_connections (client);
- for (i = 0; connections && (i < connections->len); i++) {
- const GPtrArray *devices;
-
- g_print (" %s\n", nm_object_get_path (g_ptr_array_index (connections, i)));
- devices = nm_active_connection_get_devices (g_ptr_array_index (connections, i));
- if (devices)
- g_ptr_array_foreach ((GPtrArray *) devices, show_active_connection_device, NULL);
- }
-}
-
-static void
-device_state_changed (NMDevice *device, GParamSpec *pspec, gpointer user_data)
-{
- g_print ("Device state changed: %s %d\n",
- nm_device_get_iface (device),
- nm_device_get_state (device));
-}
-
-static void
-device_added_cb (NMClient *client, NMDevice *device, gpointer user_data)
-{
- g_print ("New device added\n");
- dump_device (device);
- g_signal_connect (G_OBJECT (device), "notify::state",
- (GCallback) device_state_changed, NULL);
-}
-
-static void
-device_removed_cb (NMClient *client, NMDevice *device, gpointer user_data)
-{
- g_print ("Device removed\n");
- dump_device (device);
-}
-
-static void
-manager_running (NMClient *client, GParamSpec *pspec, gpointer user_data)
-{
- if (nm_client_get_manager_running (client)) {
- g_print ("NM appeared\n");
- test_wireless_enabled (client);
- test_get_state (client);
- test_get_active_connections (client);
- test_devices (client);
- } else
- g_print ("NM disappeared\n");
-}
-
-static GMainLoop *loop = NULL;
-
-static void
-signal_handler (int signo)
-{
- if (signo == SIGINT || signo == SIGTERM) {
- g_message ("Caught signal %d, shutting down...", signo);
- g_main_loop_quit (loop);
- }
-}
-
-static void
-setup_signals (void)
-{
- struct sigaction action;
- sigset_t mask;
-
- sigemptyset (&mask);
- action.sa_handler = signal_handler;
- action.sa_mask = mask;
- action.sa_flags = 0;
- sigaction (SIGTERM, &action, NULL);
- sigaction (SIGINT, &action, NULL);
-}
-
-int
-main (int argc, char *argv[])
-{
- NMClient *client;
-
- client = nm_client_new ();
- if (!client) {
- exit (1);
- }
-
- g_signal_connect (client, "notify::" NM_CLIENT_MANAGER_RUNNING,
- G_CALLBACK (manager_running), NULL);
- g_signal_connect (client, "notify::" NM_CLIENT_ACTIVE_CONNECTIONS,
- G_CALLBACK (active_connections_changed), NULL);
- manager_running (client, NULL, NULL);
-
- g_signal_connect (client, "device-added",
- G_CALLBACK (device_added_cb), NULL);
- g_signal_connect (client, "device-removed",
- G_CALLBACK (device_removed_cb), NULL);
-
- loop = g_main_loop_new (NULL, FALSE);
- setup_signals ();
- g_main_loop_run (loop);
-
- g_object_unref (client);
-
- return 0;
-}
diff --git a/libnm-glib/libnm-glib-vpn.pc.in b/libnm-glib/libnm-glib-vpn.pc.in
deleted file mode 100644
index 046f5b0720..0000000000
--- a/libnm-glib/libnm-glib-vpn.pc.in
+++ /dev/null
@@ -1,13 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libnm-glib-vpn
-Description: Convenience library for NetworkManager VPN plugins
-Version: @VERSION@
-Requires: NetworkManager >= @VERSION@ glib-2.0 dbus-glib-1
-Cflags: -I${includedir}/libnm-glib
-Libs: -L${libdir} -lnm-glib-vpn
-
-
diff --git a/libnm-glib/libnm-glib-vpn.ver b/libnm-glib/libnm-glib-vpn.ver
deleted file mode 100644
index b2e763b2a6..0000000000
--- a/libnm-glib/libnm-glib-vpn.ver
+++ /dev/null
@@ -1,29 +0,0 @@
-{
-global:
- nm_vpn_plugin_disconnect;
- nm_vpn_plugin_error_get_type;
- nm_vpn_plugin_error_quark;
- nm_vpn_plugin_failure;
- nm_vpn_plugin_get_connection;
- nm_vpn_plugin_get_state;
- nm_vpn_plugin_get_type;
- nm_vpn_plugin_secrets_required;
- nm_vpn_plugin_set_ip4_config;
- nm_vpn_plugin_set_login_banner;
- nm_vpn_plugin_set_state;
- nm_vpn_plugin_ui_interface_delete_connection;
- nm_vpn_plugin_ui_interface_export;
- nm_vpn_plugin_ui_interface_get_capabilities;
- nm_vpn_plugin_ui_interface_get_suggested_name;
- nm_vpn_plugin_ui_interface_get_type;
- nm_vpn_plugin_ui_interface_import;
- nm_vpn_plugin_ui_interface_ui_factory;
- nm_vpn_plugin_ui_widget_interface_get_type;
- nm_vpn_plugin_ui_widget_interface_get_widget;
- nm_vpn_plugin_ui_widget_interface_save_secrets;
- nm_vpn_plugin_ui_widget_interface_update_connection;
- nm_vpn_plugin_utils_get_secret_flags;
- nm_vpn_plugin_utils_read_vpn_details;
-local:
- *;
-};
diff --git a/libnm-glib/libnm-glib.pc.in b/libnm-glib/libnm-glib.pc.in
deleted file mode 100644
index 2b4e699674..0000000000
--- a/libnm-glib/libnm-glib.pc.in
+++ /dev/null
@@ -1,13 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libnm-glib
-Description: Convenience library for clients of NetworkManager
-Version: @VERSION@
-Requires: libnm-util >= @VERSION@ NetworkManager >= @VERSION@ gobject-2.0 dbus-glib-1
-Cflags: -I${includedir}/libnm-glib
-Libs: -L${libdir} -lnm-glib
-
-
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
deleted file mode 100644
index bce31b0b72..0000000000
--- a/libnm-glib/libnm-glib.ver
+++ /dev/null
@@ -1,309 +0,0 @@
-{
-global:
- libnm_glib_get_network_state;
- libnm_glib_init;
- libnm_glib_register_callback;
- libnm_glib_shutdown;
- libnm_glib_unregister_callback;
- nm_access_point_connection_valid;
- nm_access_point_filter_connections;
- nm_access_point_get_bssid;
- nm_access_point_get_flags;
- nm_access_point_get_frequency;
- nm_access_point_get_hw_address;
- nm_access_point_get_last_seen;
- nm_access_point_get_max_bitrate;
- nm_access_point_get_mode;
- nm_access_point_get_rsn_flags;
- nm_access_point_get_ssid;
- nm_access_point_get_strength;
- nm_access_point_get_type;
- nm_access_point_get_wpa_flags;
- nm_access_point_new;
- nm_active_connection_get_connection;
- nm_active_connection_get_connection_type;
- nm_active_connection_get_default6;
- nm_active_connection_get_default;
- nm_active_connection_get_devices;
- nm_active_connection_get_dhcp4_config;
- nm_active_connection_get_dhcp6_config;
- nm_active_connection_get_id;
- nm_active_connection_get_ip4_config;
- nm_active_connection_get_ip6_config;
- nm_active_connection_get_master;
- nm_active_connection_get_specific_object;
- nm_active_connection_get_state;
- nm_active_connection_get_type;
- nm_active_connection_get_uuid;
- nm_active_connection_get_vpn;
- nm_active_connection_new;
- nm_client_activate_connection;
- nm_client_add_and_activate_connection;
- nm_client_check_connectivity;
- nm_client_check_connectivity_async;
- nm_client_check_connectivity_finish;
- nm_client_deactivate_connection;
- nm_client_error_get_type;
- nm_client_error_quark;
- nm_client_get_activating_connection;
- nm_client_get_active_connections;
- nm_client_get_all_devices;
- nm_client_get_connectivity;
- nm_client_get_device_by_iface;
- nm_client_get_device_by_path;
- nm_client_get_devices;
- nm_client_get_logging;
- nm_client_get_manager_running;
- nm_client_get_permission_result;
- nm_client_get_primary_connection;
- nm_client_get_startup;
- nm_client_get_state;
- nm_client_get_type;
- nm_client_get_version;
- nm_client_networking_get_enabled;
- nm_client_networking_set_enabled;
- nm_client_new;
- nm_client_new_async;
- nm_client_new_finish;
- nm_client_permission_get_type;
- nm_client_permission_result_get_type;
- nm_client_set_logging;
- nm_client_sleep;
- nm_client_wimax_get_enabled;
- nm_client_wimax_hardware_get_enabled;
- nm_client_wimax_set_enabled;
- nm_client_wireless_get_enabled;
- nm_client_wireless_hardware_get_enabled;
- nm_client_wireless_set_enabled;
- nm_client_wwan_get_enabled;
- nm_client_wwan_hardware_get_enabled;
- nm_client_wwan_set_enabled;
- nm_device_adsl_error_get_type;
- nm_device_adsl_error_quark;
- nm_device_adsl_get_carrier;
- nm_device_adsl_get_type;
- nm_device_adsl_new;
- nm_device_bond_error_get_type;
- nm_device_bond_error_quark;
- nm_device_bond_get_carrier;
- nm_device_bond_get_hw_address;
- nm_device_bond_get_slaves;
- nm_device_bond_get_type;
- nm_device_bond_new;
- nm_device_bridge_error_get_type;
- nm_device_bridge_error_quark;
- nm_device_bridge_get_carrier;
- nm_device_bridge_get_hw_address;
- nm_device_bridge_get_slaves;
- nm_device_bridge_get_type;
- nm_device_bridge_new;
- nm_device_bt_error_get_type;
- nm_device_bt_error_quark;
- nm_device_bt_get_capabilities;
- nm_device_bt_get_hw_address;
- nm_device_bt_get_name;
- nm_device_bt_get_type;
- nm_device_bt_new;
- nm_device_connection_compatible;
- nm_device_connection_valid;
- nm_device_delete;
- nm_device_disambiguate_names;
- nm_device_disconnect;
- nm_device_error_get_type;
- nm_device_error_quark;
- nm_device_ethernet_error_get_type;
- nm_device_ethernet_error_quark;
- nm_device_ethernet_get_carrier;
- nm_device_ethernet_get_hw_address;
- nm_device_ethernet_get_permanent_hw_address;
- nm_device_ethernet_get_speed;
- nm_device_ethernet_get_type;
- nm_device_ethernet_new;
- nm_device_filter_connections;
- nm_device_generic_error_get_type;
- nm_device_generic_error_quark;
- nm_device_generic_get_hw_address;
- nm_device_generic_get_type;
- nm_device_generic_new;
- nm_device_get_active_connection;
- nm_device_get_autoconnect;
- nm_device_get_available_connections;
- nm_device_get_capabilities;
- nm_device_get_description;
- nm_device_get_device_type;
- nm_device_get_dhcp4_config;
- nm_device_get_dhcp6_config;
- nm_device_get_driver;
- nm_device_get_driver_version;
- nm_device_get_firmware_missing;
- nm_device_get_firmware_version;
- nm_device_get_hw_address;
- nm_device_get_iface;
- nm_device_get_ip4_config;
- nm_device_get_ip6_config;
- nm_device_get_ip_iface;
- nm_device_get_managed;
- nm_device_get_mtu;
- nm_device_get_physical_port_id;
- nm_device_get_product;
- nm_device_get_setting_type;
- nm_device_get_state;
- nm_device_get_state_reason;
- nm_device_get_type;
- nm_device_get_type_description;
- nm_device_get_udi;
- nm_device_get_vendor;
- nm_device_infiniband_error_get_type;
- nm_device_infiniband_error_quark;
- nm_device_infiniband_get_carrier;
- nm_device_infiniband_get_hw_address;
- nm_device_infiniband_get_type;
- nm_device_infiniband_new;
- nm_device_is_real;
- nm_device_is_software;
- nm_device_modem_error_get_type;
- nm_device_modem_error_quark;
- nm_device_modem_get_current_capabilities;
- nm_device_modem_get_modem_capabilities;
- nm_device_modem_get_type;
- nm_device_new;
- nm_device_olpc_mesh_error_get_type;
- nm_device_olpc_mesh_error_quark;
- nm_device_olpc_mesh_get_active_channel;
- nm_device_olpc_mesh_get_companion;
- nm_device_olpc_mesh_get_hw_address;
- nm_device_olpc_mesh_get_type;
- nm_device_olpc_mesh_new;
- nm_device_set_autoconnect;
- nm_device_set_managed;
- nm_device_team_error_get_type;
- nm_device_team_error_quark;
- nm_device_team_get_carrier;
- nm_device_team_get_hw_address;
- nm_device_team_get_slaves;
- nm_device_team_get_type;
- nm_device_team_new;
- nm_device_vlan_error_get_type;
- nm_device_vlan_error_quark;
- nm_device_vlan_get_carrier;
- nm_device_vlan_get_hw_address;
- nm_device_vlan_get_parent;
- nm_device_vlan_get_type;
- nm_device_vlan_get_vlan_id;
- nm_device_vlan_new;
- nm_device_wifi_error_get_type;
- nm_device_wifi_error_quark;
- nm_device_wifi_get_access_point_by_path;
- nm_device_wifi_get_access_points;
- nm_device_wifi_get_active_access_point;
- nm_device_wifi_get_bitrate;
- nm_device_wifi_get_capabilities;
- nm_device_wifi_get_hw_address;
- nm_device_wifi_get_mode;
- nm_device_wifi_get_permanent_hw_address;
- nm_device_wifi_get_type;
- nm_device_wifi_new;
- nm_device_wifi_request_scan_simple;
- nm_device_wimax_error_get_type;
- nm_device_wimax_error_quark;
- nm_device_wimax_get_active_nsp;
- nm_device_wimax_get_bsid;
- nm_device_wimax_get_center_frequency;
- nm_device_wimax_get_cinr;
- nm_device_wimax_get_hw_address;
- nm_device_wimax_get_nsp_by_path;
- nm_device_wimax_get_nsps;
- nm_device_wimax_get_rssi;
- nm_device_wimax_get_tx_power;
- nm_device_wimax_get_type;
- nm_device_wimax_new;
- nm_dhcp4_config_get_one_option;
- nm_dhcp4_config_get_options;
- nm_dhcp4_config_get_type;
- nm_dhcp4_config_new;
- nm_dhcp6_config_get_one_option;
- nm_dhcp6_config_get_options;
- nm_dhcp6_config_get_type;
- nm_dhcp6_config_new;
- nm_ip4_config_get_addresses;
- nm_ip4_config_get_domains;
- nm_ip4_config_get_gateway;
- nm_ip4_config_get_nameservers;
- nm_ip4_config_get_routes;
- nm_ip4_config_get_searches;
- nm_ip4_config_get_type;
- nm_ip4_config_get_wins_servers;
- nm_ip4_config_new;
- nm_ip6_address_array_get_type;
- nm_ip6_address_object_array_get_type;
- nm_ip6_config_get_addresses;
- nm_ip6_config_get_domains;
- nm_ip6_config_get_gateway;
- nm_ip6_config_get_nameserver;
- nm_ip6_config_get_nameservers;
- nm_ip6_config_get_num_nameservers;
- nm_ip6_config_get_routes;
- nm_ip6_config_get_searches;
- nm_ip6_config_get_type;
- nm_ip6_config_new;
- nm_ip6_route_object_array_get_type;
- nm_object_array_get_type;
- nm_object_error_get_type;
- nm_object_error_quark;
- nm_object_get_connection;
- nm_object_get_path;
- nm_object_get_type;
- nm_remote_connection_commit_changes;
- nm_remote_connection_commit_changes_unsaved;
- nm_remote_connection_delete;
- nm_remote_connection_error_get_type;
- nm_remote_connection_error_quark;
- nm_remote_connection_get_secrets;
- nm_remote_connection_get_type;
- nm_remote_connection_get_unsaved;
- nm_remote_connection_new;
- nm_remote_connection_save;
- nm_remote_settings_add_connection;
- nm_remote_settings_add_connection_unsaved;
- nm_remote_settings_error_get_type;
- nm_remote_settings_error_quark;
- nm_remote_settings_get_connection_by_id;
- nm_remote_settings_get_connection_by_path;
- nm_remote_settings_get_connection_by_uuid;
- nm_remote_settings_get_type;
- nm_remote_settings_list_connections;
- nm_remote_settings_load_connections;
- nm_remote_settings_new;
- nm_remote_settings_new_async;
- nm_remote_settings_new_finish;
- nm_remote_settings_reload_connections;
- nm_remote_settings_save_hostname;
- nm_secret_agent_capabilities_get_type;
- nm_secret_agent_delete_secrets;
- nm_secret_agent_error_get_type;
- nm_secret_agent_error_quark;
- nm_secret_agent_get_registered;
- nm_secret_agent_get_secrets;
- nm_secret_agent_get_secrets_flags_get_type;
- nm_secret_agent_get_type;
- nm_secret_agent_register;
- nm_secret_agent_save_secrets;
- nm_secret_agent_unregister;
- nm_ssid_get_type;
- nm_string_array_get_type;
- nm_uint_array_get_type;
- nm_vpn_connection_get_banner;
- nm_vpn_connection_get_type;
- nm_vpn_connection_get_vpn_state;
- nm_vpn_connection_new;
- nm_wimax_nsp_connection_valid;
- nm_wimax_nsp_filter_connections;
- nm_wimax_nsp_get_name;
- nm_wimax_nsp_get_network_type;
- nm_wimax_nsp_get_signal_quality;
- nm_wimax_nsp_get_type;
- nm_wimax_nsp_network_type_get_type;
- nm_wimax_nsp_new;
-local:
- *;
-};
diff --git a/libnm-glib/libnm_glib.c b/libnm-glib/libnm_glib.c
deleted file mode 100644
index 1e0725ca1d..0000000000
--- a/libnm-glib/libnm_glib.c
+++ /dev/null
@@ -1,580 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * libnm_glib -- Access network status & information from glib applications
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2005 - 2008 Red Hat, Inc.
- * Copyright (C) 2005 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "NetworkManager.h"
-#include "libnm_glib.h"
-
-#define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist"
-
-struct libnm_glib_ctx
-{
- unsigned char check;
-
- GMainContext * g_main_ctx;
- GMainLoop * g_main_loop;
- DBusConnection * dbus_con;
- guint dbus_watcher;
- guint dbus_watch_interval;
-
- gboolean thread_done;
- gboolean thread_inited;
- GThread * thread;
-
- GSList * callbacks;
- GMutex * callbacks_lock;
- guint callback_id_last;
-
- libnm_glib_state nm_state;
-};
-
-typedef struct libnm_glib_callback
-{
- guint id;
- GMainContext * gmain_ctx;
- libnm_glib_ctx * libnm_glib_ctx;
- libnm_glib_callback_func func;
- gpointer user_data;
-} libnm_glib_callback;
-
-static void _libnm_glib_schedule_dbus_watcher (libnm_glib_ctx *ctx);
-static DBusConnection * _libnm_glib_dbus_init (gpointer *user_data, GMainContext *context);
-static void _libnm_glib_update_state (libnm_glib_ctx *ctx, NMState state);
-
-static void
-_libnm_glib_nm_state_cb (DBusPendingCall *pcall, void *user_data)
-{
- DBusMessage *reply;
- libnm_glib_ctx *ctx = (libnm_glib_ctx *) user_data;
- NMState nm_state;
-
- g_return_if_fail (pcall != NULL);
- g_return_if_fail (ctx != NULL);
-
- if (!(reply = dbus_pending_call_steal_reply (pcall)))
- goto out;
-
- if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
- {
- DBusError err;
-
- dbus_error_init (&err);
- dbus_set_error_from_message (&err, reply);
- fprintf (stderr, "%s: dbus returned an error.\n (%s) %s\n", __func__, err.name, err.message);
- dbus_error_free (&err);
- dbus_message_unref (reply);
- goto out;
- }
-
- if (dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &nm_state, DBUS_TYPE_INVALID))
- _libnm_glib_update_state (ctx, nm_state);
-
- dbus_message_unref (reply);
-
-out:
- dbus_pending_call_unref (pcall);
-}
-
-static void
-_libnm_glib_get_nm_state (libnm_glib_ctx *ctx)
-{
- DBusMessage *message;
- DBusPendingCall *pcall = NULL;
-
- g_return_if_fail (ctx != NULL);
-
- if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "state")))
- {
- dbus_connection_send_with_reply (ctx->dbus_con, message, &pcall, -1);
- if (pcall)
- dbus_pending_call_set_notify (pcall, _libnm_glib_nm_state_cb, ctx, NULL);
- dbus_message_unref (message);
- }
-}
-
-static gboolean
-_libnm_glib_callback_helper (gpointer user_data)
-{
- libnm_glib_callback *cb_data = (libnm_glib_callback *)user_data;
-
- g_return_val_if_fail (cb_data != NULL, FALSE);
- g_return_val_if_fail (cb_data->func != NULL, FALSE);
- g_return_val_if_fail (cb_data->libnm_glib_ctx != NULL, FALSE);
-
- (*(cb_data->func)) (cb_data->libnm_glib_ctx, cb_data->user_data);
-
- return FALSE;
-}
-
-static void
-_libnm_glib_schedule_single_callback (libnm_glib_ctx *ctx,
- libnm_glib_callback *callback)
-{
- GSource *source;
-
- g_return_if_fail (ctx != NULL);
- g_return_if_fail (callback != NULL);
-
- callback->libnm_glib_ctx = ctx;
-
- source = g_idle_source_new ();
- g_source_set_callback (source, _libnm_glib_callback_helper, callback, NULL);
- g_source_attach (source, callback->gmain_ctx);
- g_source_unref (source);
-}
-
-static void
-_libnm_glib_unschedule_single_callback (libnm_glib_ctx *ctx,
- libnm_glib_callback *callback)
-{
- GSource *source;
-
- g_return_if_fail (ctx != NULL);
- g_return_if_fail (callback != NULL);
-
- source = g_main_context_find_source_by_user_data (callback->gmain_ctx, callback);
- if (source)
- g_source_destroy (source);
-}
-
-static void
-_libnm_glib_call_callbacks (libnm_glib_ctx *ctx)
-{
- GSList *elem;
-
- g_return_if_fail (ctx != NULL);
-
- g_mutex_lock (ctx->callbacks_lock);
- for (elem = ctx->callbacks; elem; elem = g_slist_next (elem))
- {
- libnm_glib_callback *callback = (libnm_glib_callback *)(elem->data);
- if (callback)
- _libnm_glib_schedule_single_callback (ctx, callback);
- }
- g_mutex_unlock (ctx->callbacks_lock);
-}
-
-static void
-_libnm_glib_update_state (libnm_glib_ctx *ctx, NMState state)
-{
- libnm_glib_state old_state;
-
- g_return_if_fail (ctx != NULL);
-
- old_state = ctx->nm_state;
- switch (state) {
- case NM_STATE_CONNECTED_LOCAL:
- case NM_STATE_CONNECTED_SITE:
- case NM_STATE_CONNECTED_GLOBAL:
- ctx->nm_state = LIBNM_ACTIVE_NETWORK_CONNECTION;
- break;
- case NM_STATE_ASLEEP:
- case NM_STATE_CONNECTING:
- case NM_STATE_DISCONNECTED:
- case NM_STATE_DISCONNECTING:
- ctx->nm_state = LIBNM_NO_NETWORK_CONNECTION;
- break;
- case NM_STATE_UNKNOWN:
- default:
- ctx->nm_state = LIBNM_NO_NETWORKMANAGER;
- break;
- }
-
- if (old_state != ctx->nm_state)
- _libnm_glib_call_callbacks (ctx);
-}
-
-static DBusHandlerResult
-_libnm_glib_dbus_filter (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- libnm_glib_ctx *ctx = (libnm_glib_ctx *)user_data;
- gboolean handled = TRUE;
- DBusError error;
-
- g_return_val_if_fail (ctx != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
- g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
- g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-
- dbus_error_init (&error);
- if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected"))
- {
- /* Try to reactivate our connection to dbus on the next pass through the event loop */
- ctx->nm_state = LIBNM_NO_DBUS;
- dbus_connection_close (ctx->dbus_con);
- dbus_connection_unref (ctx->dbus_con);
- ctx->dbus_con = NULL;
- _libnm_glib_schedule_dbus_watcher (ctx);
- }
- else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged"))
- {
- /* New signal for dbus 0.23... */
- char *service;
- char *old_owner;
- char *new_owner;
-
- if ( dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &service,
- DBUS_TYPE_STRING, &old_owner,
- DBUS_TYPE_STRING, &new_owner,
- DBUS_TYPE_INVALID))
- {
- if (strcmp (service, NM_DBUS_SERVICE) == 0)
- {
- gboolean old_owner_good = (old_owner && (strlen (old_owner) > 0));
- gboolean new_owner_good = (new_owner && (strlen (new_owner) > 0));
-
- if (!old_owner_good && new_owner_good) /* Equivalent to old ServiceCreated signal */
- _libnm_glib_get_nm_state (ctx);
- else if (old_owner_good && !new_owner_good) /* Equivalent to old ServiceDeleted signal */
- ctx->nm_state = LIBNM_NO_NETWORKMANAGER;
- }
- }
- }
- else if ( dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNowActive")
- || dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive")
- || dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivating")
- || dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DevicesChanged"))
- {
- _libnm_glib_get_nm_state (ctx);
- }
- else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "StateChanged"))
- {
- NMState state = NM_STATE_UNKNOWN;
-
- dbus_message_get_args (message, &error, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID);
- _libnm_glib_update_state (ctx, state);
- }
- else
- handled = FALSE;
-
- if (dbus_error_is_set (&error))
- dbus_error_free (&error);
-
- return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-}
-
-/*
- * libnm_glib_dbus_init
- *
- * Initialize a connection to dbus and set up our callbacks.
- *
- */
-static DBusConnection *
-_libnm_glib_dbus_init (gpointer *user_data, GMainContext *context)
-{
- DBusConnection *connection = NULL;
- DBusError error;
-
- dbus_error_init (&error);
- connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &error);
- if (dbus_error_is_set (&error))
- {
- fprintf (stderr, "%s: error, %s raised:\n %s\n\n", __func__, error.name, error.message);
- dbus_error_free (&error);
- return (NULL);
- }
- if (!connection)
- return NULL;
-
- if (!dbus_connection_add_filter (connection, _libnm_glib_dbus_filter, user_data, NULL))
- return (NULL);
-
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
- dbus_connection_setup_with_g_main (connection, context);
-
- dbus_error_init (&error);
- dbus_bus_add_match (connection,
- "type='signal',"
- "interface='" DBUS_INTERFACE_DBUS "',"
- "sender='" DBUS_SERVICE_DBUS "'",
- &error);
- if (dbus_error_is_set (&error))
- dbus_error_free (&error);
-
- dbus_error_init (&error);
- dbus_bus_add_match (connection,
- "type='signal',"
- "interface='" NM_DBUS_INTERFACE "',"
- "path='" NM_DBUS_PATH "',"
- "sender='" NM_DBUS_SERVICE "'",
- &error);
- if (dbus_error_is_set (&error))
- dbus_error_free (&error);
-
- return (connection);
-}
-
-/*
- * libnm_glib_dbus_watcher
- *
- * Repeatedly try to re-activate the connection to dbus.
- *
- */
-static gboolean
-_libnm_glib_dbus_watcher (gpointer user_data)
-{
- libnm_glib_ctx *ctx = (libnm_glib_ctx *)user_data;
-
- g_return_val_if_fail (ctx != NULL, FALSE);
-
- ctx->dbus_watcher = 0;
-
- if (!ctx->dbus_con)
- ctx->dbus_con = _libnm_glib_dbus_init ((gpointer)ctx, ctx->g_main_ctx);
-
- if (ctx->dbus_con)
- {
- /* Get NM's state right away after we reconnect */
- _libnm_glib_get_nm_state (ctx);
- ctx->dbus_watch_interval = 1000;
- }
- else
- {
- /* Wait 3 seconds longer each time we fail to reconnect to dbus,
- * with a maximum wait of one minute.
- */
- ctx->dbus_watch_interval = MIN(ctx->dbus_watch_interval + 3000, 60000);
-
- /* Reschule ourselves if we _still_ don't have a connection to dbus */
- _libnm_glib_schedule_dbus_watcher (ctx);
- }
-
- return FALSE;
-}
-
-/*
- * libnm_glib_schedule_dbus_watcher
- *
- * Schedule an idle handler in our main loop to repeatedly
- * attempt to re-activate the dbus connection until connected.
- *
- */
-static void
-_libnm_glib_schedule_dbus_watcher (libnm_glib_ctx *ctx)
-{
- g_return_if_fail (ctx != NULL);
-
- if (ctx->dbus_watcher == 0)
- {
- GSource *source = g_timeout_source_new (ctx->dbus_watch_interval);
- g_source_set_callback (source, _libnm_glib_dbus_watcher, (gpointer) ctx, NULL);
- ctx->dbus_watcher = g_source_attach (source, ctx->g_main_ctx);
- g_source_unref (source);
- }
-}
-
-/*
- * libnm_glib_dbus_worker
- *
- * Main thread for libnm
- *
- */
-static gpointer
-_libnm_glib_dbus_worker (gpointer user_data)
-{
- libnm_glib_ctx *ctx = (libnm_glib_ctx *)user_data;
-
- g_return_val_if_fail (ctx != NULL, NULL);
-
- /* If dbus isn't up yet, schedule an idle handler to check for dbus.
- * We also need a way to reconnect to dbus if the connection ever goes
- * down. Should probably be done by a timeout polling dbus_connection_is_connected()
- * or by getting connection status out of libdbus or something.
- */
- if (!(ctx->dbus_con = _libnm_glib_dbus_init ((gpointer) ctx, ctx->g_main_ctx)))
- _libnm_glib_schedule_dbus_watcher (ctx);
- else
- _libnm_glib_get_nm_state (ctx);
-
- ctx->thread_inited = TRUE;
- g_main_loop_run (ctx->g_main_loop);
- ctx->thread_done = TRUE;
-
- return NULL;
-}
-
-static void
-_libnm_glib_ctx_free (libnm_glib_ctx *ctx)
-{
- g_return_if_fail (ctx != NULL);
-
- if (ctx->check == 0xDD)
- {
- fprintf (stderr, "%s: context %p already freed!\n", __func__, ctx);
- return;
- }
-
- if (ctx->g_main_ctx)
- g_main_context_unref (ctx->g_main_ctx);
- if (ctx->g_main_loop)
- g_main_loop_unref (ctx->g_main_loop);
-
- if (ctx->dbus_con)
- {
- dbus_connection_close (ctx->dbus_con);
- dbus_connection_unref (ctx->dbus_con);
- ctx->dbus_con = NULL;
- }
-
- if (ctx->callbacks_lock)
- g_mutex_free (ctx->callbacks_lock);
-
- g_slist_free_full (ctx->callbacks, g_free);
-
- if (ctx->thread)
- g_thread_join (ctx->thread);
-
- memset (ctx, 0, sizeof (libnm_glib_ctx));
- memset (&(ctx->check), 0xDD, sizeof (ctx->check));
- g_free (ctx);
-}
-
-static libnm_glib_ctx *
-_libnm_glib_ctx_new (void)
-{
- libnm_glib_ctx *ctx = g_malloc0 (sizeof (libnm_glib_ctx));
-
- if (!(ctx->g_main_ctx = g_main_context_new ()))
- goto error;
- if (!(ctx->g_main_loop = g_main_loop_new (ctx->g_main_ctx, FALSE)))
- goto error;
- if (!(ctx->callbacks_lock = g_mutex_new ()))
- goto error;
- ctx->dbus_watch_interval = 1000;
-
- return ctx;
-
-error:
- _libnm_glib_ctx_free (ctx);
- return NULL;
-}
-
-libnm_glib_ctx *
-libnm_glib_init (void)
-{
- libnm_glib_ctx *ctx = NULL;
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
- dbus_g_thread_init ();
-
- if (!(ctx = _libnm_glib_ctx_new ()))
- return NULL;
-
- ctx->thread = g_thread_create (_libnm_glib_dbus_worker, ctx, TRUE, NULL);
- if (!ctx->thread)
- goto error;
-
- /* Wait until initialization of the thread */
- while (!ctx->thread_inited)
- g_usleep (G_USEC_PER_SEC / 20);
-
- return ctx;
-
-error:
- _libnm_glib_ctx_free (ctx);
- return NULL;
-}
-
-void
-libnm_glib_shutdown (libnm_glib_ctx *ctx)
-{
- g_return_if_fail (ctx != NULL);
-
- g_main_loop_quit (ctx->g_main_loop);
- while (!ctx->thread_done)
- g_usleep (G_USEC_PER_SEC / 20);
-
- _libnm_glib_ctx_free (ctx);
-}
-
-libnm_glib_state
-libnm_glib_get_network_state (const libnm_glib_ctx *ctx)
-{
- if (!ctx)
- return LIBNM_INVALID_CONTEXT;
-
- return ctx->nm_state;
-}
-
-guint
-libnm_glib_register_callback (libnm_glib_ctx *ctx,
- libnm_glib_callback_func func,
- gpointer user_data,
- GMainContext *g_main_ctx)
-{
- libnm_glib_callback *callback = NULL;
-
- g_return_val_if_fail (ctx != NULL, 0);
- g_return_val_if_fail (func != NULL, 0);
-
- callback = g_malloc0 (sizeof (libnm_glib_callback));
-
- callback->id = ++ (ctx->callback_id_last);
- callback->func = func;
- callback->gmain_ctx = g_main_ctx;
- callback->libnm_glib_ctx = ctx;
- callback->user_data = user_data;
-
- g_mutex_lock (ctx->callbacks_lock);
- ctx->callbacks = g_slist_append (ctx->callbacks, callback);
- _libnm_glib_schedule_single_callback (ctx, callback);
- g_mutex_unlock (ctx->callbacks_lock);
-
- return (callback->id);
-}
-
-void
-libnm_glib_unregister_callback (libnm_glib_ctx *ctx,
- guint id)
-{
- GSList *elem;
-
- g_return_if_fail (ctx != NULL);
- g_return_if_fail (id > 0);
-
- g_mutex_lock (ctx->callbacks_lock);
- elem = ctx->callbacks;
- while (elem)
- {
- libnm_glib_callback *callback = (libnm_glib_callback *)(elem->data);
- if (callback && (callback->id == id))
- {
- _libnm_glib_unschedule_single_callback (ctx, callback);
- ctx->callbacks = g_slist_remove_link (ctx->callbacks, elem);
- break;
- }
-
- elem = g_slist_next (elem);
- }
- g_mutex_unlock (ctx->callbacks_lock);
-}
diff --git a/libnm-glib/libnm_glib.h b/libnm-glib/libnm_glib.h
deleted file mode 100644
index 4137a8ca4b..0000000000
--- a/libnm-glib/libnm_glib.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * libnm_glib -- Access network status & information from glib applications
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2005 - 2008 Red Hat, Inc.
- * Copyright (C) 2005 - 2008 Novell, Inc.
- */
-
-#ifndef _LIB_NM_H_
-#define _LIB_NM_H_
-
-#ifndef NM_DISABLE_DEPRECATED
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-typedef enum libnm_glib_state
-{
- LIBNM_NO_DBUS = 0,
- LIBNM_NO_NETWORKMANAGER,
- LIBNM_NO_NETWORK_CONNECTION,
- LIBNM_ACTIVE_NETWORK_CONNECTION,
- LIBNM_INVALID_CONTEXT
-} libnm_glib_state G_GNUC_DEPRECATED;
-
-typedef struct libnm_glib_ctx libnm_glib_ctx G_GNUC_DEPRECATED;
-
-typedef void (*libnm_glib_callback_func) (libnm_glib_ctx *libnm_ctx, gpointer user_data) G_GNUC_DEPRECATED;
-
-G_GNUC_DEPRECATED libnm_glib_ctx * libnm_glib_init (void);
-G_GNUC_DEPRECATED void libnm_glib_shutdown (libnm_glib_ctx *ctx);
-
-G_GNUC_DEPRECATED libnm_glib_state libnm_glib_get_network_state (const libnm_glib_ctx *ctx);
-
-G_GNUC_DEPRECATED guint libnm_glib_register_callback (libnm_glib_ctx *ctx, libnm_glib_callback_func func, gpointer user_data, GMainContext *g_main_ctx);
-G_GNUC_DEPRECATED void libnm_glib_unregister_callback (libnm_glib_ctx *ctx, guint id);
-
-G_END_DECLS
-
-#endif /* NM_DISABLE_DEPRECATED */
-
-#endif /* _LIB_NM_H_ */
diff --git a/libnm-glib/meson.build b/libnm-glib/meson.build
deleted file mode 100644
index 5f08141ea0..0000000000
--- a/libnm-glib/meson.build
+++ /dev/null
@@ -1,286 +0,0 @@
-libnm_glib_inc = include_directories('.')
-
-dbus_binding_tool = find_program('dbus-binding-tool')
-
-common_deps = [
- dbus_dep,
- dbus_glib_dep,
- shared_nm_glib_aux_dep,
-]
-
-common_cflags = [
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB',
-]
-
-cflags = common_cflags + [
- '-DG_LOG_DOMAIN="@0@"'.format(libnm_glib_name),
-]
-
-vpn_headers = files(
- 'nm-vpn-plugin.h',
- 'nm-vpn-plugin-ui-interface.h',
- 'nm-vpn-plugin-utils.h',
-)
-
-headers = files(
- 'nm-access-point.h',
- 'nm-active-connection.h',
- 'nm-client.h',
- 'nm-device-adsl.h',
- 'nm-device-bond.h',
- 'nm-device-bridge.h',
- 'nm-device-bt.h',
- 'nm-device-ethernet.h',
- 'nm-device-generic.h',
- 'nm-device.h',
- 'nm-device-infiniband.h',
- 'nm-device-modem.h',
- 'nm-device-olpc-mesh.h',
- 'nm-device-team.h',
- 'nm-device-vlan.h',
- 'nm-device-wifi.h',
- 'nm-device-wimax.h',
- 'nm-dhcp4-config.h',
- 'nm-dhcp6-config.h',
- 'nm-ip4-config.h',
- 'nm-ip6-config.h',
- 'nm-object.h',
- 'nm-remote-connection.h',
- 'nm-remote-settings.h',
- 'nm-secret-agent.h',
- 'nm-types.h',
- 'nm-vpn-connection.h',
- 'nm-wimax-nsp.h',
-)
-
-deprecated_headers = files('libnm_glib.h')
-
-install_headers(
- headers + vpn_headers + deprecated_headers,
- subdir: libnm_glib_name,
-)
-
-libdeprecated_nm_glib = static_library(
- 'deprecated-nm-glib',
- sources: 'libnm_glib.c',
- include_directories: libnm_util_inc,
- dependencies: common_deps,
- c_args: cflags + [
- '-Wno-deprecated-declarations',
- '-Wno-deprecated',
- ],
-)
-
-sources = files(
- 'nm-vpn-plugin.c',
- 'nm-vpn-plugin-ui-interface.c',
- 'nm-vpn-plugin-utils.c',
-)
-
-glue = 'nm-vpn-plugin-glue.h'
-
-enum_types = 'nm-vpn-enum-types'
-
-libnm_glib_vpn_enum = gnome.mkenums(
- enum_types,
- sources: vpn_headers,
- identifier_prefix: nm_id_prefix,
- c_template: enum_types + '.c.template',
- h_template: enum_types + '.h.template',
- install_header: true,
- install_dir: libnm_glib_pkgincludedir,
-)
-
-linker_script = join_paths(meson.current_source_dir(), 'libnm-glib-vpn.ver')
-
-libnm_glib_vpn = shared_library(
- 'nm-glib-vpn',
- sources: files(
- 'nm-vpn-plugin.c',
- 'nm-vpn-plugin-ui-interface.c',
- 'nm-vpn-plugin-utils.c',
- ) + [
- custom_target(
- glue,
- input: ifaces_vpn_plugin_xml,
- output: glue,
- command: [dbus_binding_tool, '--prefix=nm_vpn_plugin', '--mode=glib-server', '--output=@OUTPUT@', '@INPUT@'],
- ),
- ] + libnm_glib_vpn_enum,
- version: libnm_glib_vpn_version,
- dependencies: common_deps + [libnm_util_dep],
- c_args: cflags,
- link_args: [
- '-Wl,--version-script,@0@'.format(linker_script),
- ],
- link_depends: linker_script,
- install: true,
-)
-
-libnm_glib_vpn_dep = declare_dependency(
- include_directories: libnm_glib_inc,
- link_with: libnm_glib_vpn,
-)
-
-pkg.generate(
- libraries: libnm_glib_vpn,
- version: nm_version,
- name: libnm_glib_vpn_name,
- description: 'Convenience library for NetworkManager VPN plugins',
- filebase: libnm_glib_vpn_name,
- subdirs: libnm_glib_name,
- requires: 'NetworkManager >= ' + nm_version + ' glib-2.0 dbus-glib-1',
- variables: 'exec_prefix=${prefix}',
-)
-
-libnm_glib_sources = files(
- 'nm-access-point.c',
- 'nm-active-connection.c',
- 'nm-client.c',
- 'nm-dbus-helpers.c',
- 'nm-device-adsl.c',
- 'nm-device-bond.c',
- 'nm-device-bridge.c',
- 'nm-device-bt.c',
- 'nm-device.c',
- 'nm-device-ethernet.c',
- 'nm-device-generic.c',
- 'nm-device-infiniband.c',
- 'nm-device-olpc-mesh.c',
- 'nm-device-modem.c',
- 'nm-device-team.c',
- 'nm-device-vlan.c',
- 'nm-device-wifi.c',
- 'nm-device-wimax.c',
- 'nm-dhcp4-config.c',
- 'nm-dhcp6-config.c',
- 'nm-ip4-config.c',
- 'nm-ip6-config.c',
- 'nm-object.c',
- 'nm-object-cache.c',
- 'nm-remote-connection.c',
- 'nm-remote-settings.c',
- 'nm-secret-agent.c',
- 'nm-types.c',
- 'nm-vpn-connection.c',
- 'nm-wimax-nsp.c',
-)
-
-glue = 'nm-secret-agent-glue.h'
-
-nm_secret_agent_glue = custom_target(
- glue,
- input: ifaces_secret_agent_xml,
- output: glue,
- command: [dbus_binding_tool, '--prefix=nm_secret_agent', '--mode=glib-server', '--output=@OUTPUT@', '@INPUT@'],
-)
-
-enum_types = 'nm-glib-enum-types'
-
-libnm_glib_enum = gnome.mkenums(
- enum_types,
- sources: headers,
- identifier_prefix: nm_id_prefix,
- c_template: enum_types + '.c.template',
- h_template: enum_types + '.h.template',
- install_header: true,
- install_dir: libnm_glib_pkgincludedir,
-)
-
-linker_script = join_paths(meson.current_source_dir(), 'libnm-glib.ver')
-
-libnm_glib = shared_library(
- 'nm-glib',
- sources: libnm_glib_sources + libnm_glib_enum + [nm_secret_agent_glue],
- version: libnm_glib_version,
- dependencies: common_deps + [
- libnm_util_dep,
- libudev_dep,
- shared_nm_udev_aux_dep,
- ],
- c_args: cflags,
- link_whole: libdeprecated_nm_glib,
- link_args: [
- '-Wl,--version-script,@0@'.format(linker_script),
- ],
- link_depends: linker_script,
- install: true,
-)
-
-libnm_glib_dep = declare_dependency(
- include_directories: libnm_glib_inc,
- link_with: libnm_glib,
-)
-
-pkg.generate(
- libraries: libnm_glib,
- version: nm_version,
- name: libnm_glib_name,
- description: 'Convenience library for clients of NetworkManager',
- filebase: libnm_glib_name,
- subdirs: libnm_glib_name,
- requires: 'libnm-util >= ' + nm_version + ' NetworkManager >= ' + nm_version + ' gobject-2.0 dbus-glib-1',
- variables: 'exec_prefix=${prefix}',
-)
-
-if enable_introspection
- gir_sources = libnm_glib_sources + headers + libnm_glib_enum
-
- libnm_glib_gir = gnome.generate_gir(
- libnm_glib,
- sources: gir_sources,
- dependencies: [
- dbus_glib_dep,
- libnm_glib_dep,
- libnm_util_gir_dep,
- ],
- nsversion: nm_gir_version,
- namespace: 'NMClient',
- identifier_prefix: nm_id_prefix,
- symbol_prefix: nm_id_prefix.to_lower(),
- export_packages: [libnm_glib_name, libnm_glib_vpn_name],
- includes: [
- 'DBusGLib-1.0',
- 'Gio-2.0',
- ],
- extra_args: cflags + [
- '--include-uninstalled=' + libnm_util_gir[0].full_path(),
- ],
- install: true,
- )
-endif
-
-name = libnm_glib_name + '-test'
-
-executable(
- name,
- name + '.c',
- dependencies: common_deps + [libnm_util_dep],
- c_args: cflags,
- link_with: libnm_glib,
-)
-
-test(
- 'check-local-exports-' + libnm_glib_name,
- check_exports,
- args: [libnm_glib.full_path(), linker_script],
-)
-
-if enable_tests
- subdir('tests')
-endif
-
-pkg.generate(
- version: nm_version,
- name: nm_name,
- description: 'System for maintaining active network connection',
- filebase: nm_name,
- subdirs: nm_name,
- requires: '',
- variables: [
- 'exec_prefix=${prefix}',
- 'libgnome_serverdir=' + nm_libexecdir,
- 'plugindir=' + nm_vpndir,
- 'configdir=' + nm_pkgconfdir,
- ],
-)
diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c
deleted file mode 100644
index a0cacfde4b..0000000000
--- a/libnm-glib/nm-access-point.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2011 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-connection.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-wireless.h"
-#include "nm-setting-wireless-security.h"
-#include "nm-utils.h"
-
-#include "nm-access-point.h"
-#include "NetworkManager.h"
-#include "nm-types-private.h"
-#include "nm-object-private.h"
-
-G_DEFINE_TYPE (NMAccessPoint, nm_access_point, NM_TYPE_OBJECT)
-
-#define NM_ACCESS_POINT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACCESS_POINT, NMAccessPointPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- NM80211ApFlags flags;
- NM80211ApSecurityFlags wpa_flags;
- NM80211ApSecurityFlags rsn_flags;
- GByteArray *ssid;
- guint32 frequency;
- char *bssid;
- NM80211Mode mode;
- guint32 max_bitrate;
- guint8 strength;
- int last_seen;
-} NMAccessPointPrivate;
-
-enum {
- PROP_0,
- PROP_FLAGS,
- PROP_WPA_FLAGS,
- PROP_RSN_FLAGS,
- PROP_SSID,
- PROP_FREQUENCY,
- PROP_HW_ADDRESS,
- PROP_MODE,
- PROP_MAX_BITRATE,
- PROP_STRENGTH,
- PROP_BSSID,
- PROP_LAST_SEEN,
-
- LAST_PROP
-};
-
-/**
- * nm_access_point_new:
- * @connection: the #DBusGConnection
- * @path: the DBusobject path of the access point
- *
- * Creates a new #NMAccessPoint.
- *
- * Returns: (transfer full): a new access point
- **/
-GObject *
-nm_access_point_new (DBusGConnection *connection, const char *path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- return (GObject *) g_object_new (NM_TYPE_ACCESS_POINT,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
-}
-
-/**
- * nm_access_point_get_flags:
- * @ap: a #NMAccessPoint
- *
- * Gets the flags of the access point.
- *
- * Returns: the flags
- **/
-NM80211ApFlags
-nm_access_point_get_flags (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_FLAGS_NONE);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->flags;
-}
-
-/**
- * nm_access_point_get_wpa_flags:
- * @ap: a #NMAccessPoint
- *
- * Gets the WPA (version 1) flags of the access point.
- *
- * Returns: the WPA flags
- **/
-NM80211ApSecurityFlags
-nm_access_point_get_wpa_flags (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->wpa_flags;
-}
-
-/**
- * nm_access_point_get_rsn_flags:
- * @ap: a #NMAccessPoint
- *
- * Gets the RSN (Robust Secure Network, ie WPA version 2) flags of the access
- * point.
- *
- * Returns: the RSN flags
- **/
-NM80211ApSecurityFlags
-nm_access_point_get_rsn_flags (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->rsn_flags;
-}
-
-/**
- * nm_access_point_get_ssid:
- * @ap: a #NMAccessPoint
- *
- * Gets the SSID of the access point.
- *
- * Returns: the #GByteArray containing the SSID. This is the internal copy used by the
- * access point, and must not be modified.
- **/
-const GByteArray *
-nm_access_point_get_ssid (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->ssid;
-}
-
-/**
- * nm_access_point_get_frequency:
- * @ap: a #NMAccessPoint
- *
- * Gets the frequency of the access point in MHz.
- *
- * Returns: the frequency in MHz
- **/
-guint32
-nm_access_point_get_frequency (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->frequency;
-}
-
-/**
- * nm_access_point_get_bssid:
- * @ap: a #NMAccessPoint
- *
- * Gets the Basic Service Set ID (BSSID) of the Wi-Fi access point.
- *
- * Returns: the BSSID of the access point. This is an internal string and must
- * not be modified or freed.
- **/
-const char *
-nm_access_point_get_bssid (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->bssid;
-}
-
-/**
- * nm_access_point_get_hw_address:
- * @ap: a #NMAccessPoint
- *
- * Gets the hardware (MAC) address of the access point.
- *
- * Returns: the hardware address of the access point. This is the internal string used by the
- * access point and must not be modified.
- *
- * Deprecated: 0.9: Use nm_access_point_get_bssid() instead.
- **/
-const char *
-nm_access_point_get_hw_address (NMAccessPoint *ap)
-{
- return nm_access_point_get_bssid (ap);
-}
-
-/**
- * nm_access_point_get_mode:
- * @ap: a #NMAccessPoint
- *
- * Gets the mode of the access point.
- *
- * Returns: the mode
- **/
-NM80211Mode
-nm_access_point_get_mode (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->mode;
-}
-
-/**
- * nm_access_point_get_max_bitrate:
- * @ap: a #NMAccessPoint
- *
- * Gets the maximum bit rate of the access point in kbit/s.
- *
- * Returns: the maximum bit rate (kbit/s)
- **/
-guint32
-nm_access_point_get_max_bitrate (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->max_bitrate;
-}
-
-/**
- * nm_access_point_get_strength:
- * @ap: a #NMAccessPoint
- *
- * Gets the current signal strength of the access point as a percentage.
- *
- * Returns: the signal strength (0 to 100)
- **/
-guint8
-nm_access_point_get_strength (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->strength;
-}
-
-/**
- * nm_access_point_get_last_seen:
- * @ap: a #NMAccessPoint
- *
- * Returns the timestamp (in CLOCK_BOOTTIME seconds) for the last time the
- * access point was found in scan results. A value of -1 means the access
- * point has not been found in a scan.
- *
- * Returns: the last seen time in seconds
- *
- * Since: 1.2
- **/
-int
-nm_access_point_get_last_seen (NMAccessPoint *ap)
-{
- g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), -1);
-
- _nm_object_ensure_inited (NM_OBJECT (ap));
- return NM_ACCESS_POINT_GET_PRIVATE (ap)->last_seen;
-}
-
-/**
- * nm_access_point_connection_valid:
- * @ap: an #NMAccessPoint to validate @connection against
- * @connection: an #NMConnection to validate against @ap
- *
- * Validates a given connection against a given Wi-Fi access point to ensure that
- * the connection may be activated with that AP. The connection must match the
- * @ap's SSID, (if given) BSSID, and other attributes like security settings,
- * channel, band, etc.
- *
- * Returns: %TRUE if the connection may be activated with this Wi-Fi AP,
- * %FALSE if it cannot be.
- **/
-gboolean
-nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection)
-{
- NMSettingConnection *s_con;
- NMSettingWireless *s_wifi;
- NMSettingWirelessSecurity *s_wsec;
- const char *ctype, *ap_bssid_str;
- const GByteArray *setting_ssid;
- const GByteArray *ap_ssid;
- const GByteArray *setting_bssid;
- const char *setting_mode;
- NM80211Mode ap_mode;
- const char *setting_band;
- guint32 ap_freq, setting_chan, ap_chan;
-
- s_con = nm_connection_get_setting_connection (connection);
- if (!s_con)
- return FALSE;
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (!ctype || !nm_streq (ctype, NM_SETTING_WIRELESS_SETTING_NAME))
- return FALSE;
-
- s_wifi = nm_connection_get_setting_wireless (connection);
- if (!s_wifi)
- return FALSE;
-
- /* SSID checks */
- ap_ssid = nm_access_point_get_ssid (ap);
- if (!ap_ssid)
- return FALSE;
- setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
- if ( !setting_ssid
- || setting_ssid->len != ap_ssid->len
- || memcmp (setting_ssid->data, ap_ssid->data, ap_ssid->len) != 0)
- return FALSE;
-
- /* BSSID checks */
- ap_bssid_str = nm_access_point_get_bssid (ap);
- if (!ap_bssid_str)
- return FALSE;
- setting_bssid = nm_setting_wireless_get_bssid (s_wifi);
- if (setting_bssid) {
- struct ether_addr addr;
-
- g_return_val_if_fail (setting_bssid->len == ETH_ALEN, FALSE);
-
- if (!ether_aton_r (ap_bssid_str, &addr))
- return FALSE;
- if (memcmp (addr.ether_addr_octet, setting_bssid->data, ETH_ALEN) != 0)
- return FALSE;
- }
-
- /* Mode */
- ap_mode = nm_access_point_get_mode (ap);
- if (ap_mode == NM_802_11_MODE_UNKNOWN)
- return FALSE;
- setting_mode = nm_setting_wireless_get_mode (s_wifi);
- if (setting_mode && ap_mode) {
- if (!strcmp (setting_mode, "infrastructure") && (ap_mode != NM_802_11_MODE_INFRA))
- return FALSE;
- if (!strcmp (setting_mode, "adhoc") && (ap_mode != NM_802_11_MODE_ADHOC))
- return FALSE;
- /* Hotspot never matches against APs as it's a device-specific mode. */
- if (!strcmp (setting_mode, "ap"))
- return FALSE;
- }
-
- /* Band and Channel/Frequency */
- ap_freq = nm_access_point_get_frequency (ap);
- if (ap_freq) {
- setting_band = nm_setting_wireless_get_band (s_wifi);
- if (g_strcmp0 (setting_band, "a") == 0) {
- if (ap_freq < 4915 || ap_freq > 5825)
- return FALSE;
- } else if (g_strcmp0 (setting_band, "bg") == 0) {
- if (ap_freq < 2412 || ap_freq > 2484)
- return FALSE;
- }
-
- setting_chan = nm_setting_wireless_get_channel (s_wifi);
- if (setting_chan) {
- ap_chan = nm_utils_wifi_freq_to_channel (ap_freq);
- if (setting_chan != ap_chan)
- return FALSE;
- }
- }
-
- s_wsec = nm_connection_get_setting_wireless_security (connection);
- if (!nm_setting_wireless_ap_security_compatible (s_wifi,
- s_wsec,
- nm_access_point_get_flags (ap),
- nm_access_point_get_wpa_flags (ap),
- nm_access_point_get_rsn_flags (ap),
- ap_mode))
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * nm_access_point_filter_connections:
- * @ap: an #NMAccessPoint to filter connections for
- * @connections: (element-type NMConnection): a list of
- * #NMConnection objects to filter
- *
- * Filters a given list of connections for a given #NMAccessPoint object and
- * return connections which may be activated with the access point. Any
- * returned connections will match the @ap's SSID and (if given) BSSID and
- * other attributes like security settings, channel, etc.
- *
- * To obtain the list of connections that are compatible with this access point,
- * use nm_remote_settings_list_connections() and then filter the returned list
- * for a given #NMDevice using nm_device_filter_connections() and finally
- * filter that list with this function.
- *
- * Returns: (transfer container) (element-type NMConnection): a
- * list of #NMConnection objects that could be activated with the given @ap.
- * The elements of the list are owned by their creator and should not be freed
- * by the caller, but the returned list itself is owned by the caller and should
- * be freed with g_slist_free() when it is no longer required.
- **/
-GSList *
-nm_access_point_filter_connections (NMAccessPoint *ap, const GSList *connections)
-{
- GSList *filtered = NULL;
- const GSList *iter;
-
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *candidate = NM_CONNECTION (iter->data);
-
- if (nm_access_point_connection_valid (ap, candidate))
- filtered = g_slist_prepend (filtered, candidate);
- }
-
- return g_slist_reverse (filtered);
-}
-
-/*****************************************************************************/
-
-static void
-nm_access_point_init (NMAccessPoint *ap)
-{
- NM_ACCESS_POINT_GET_PRIVATE (ap)->last_seen = -1;
-}
-
-static void
-dispose (GObject *object)
-{
- NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_access_point_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (object);
-
- if (priv->ssid)
- g_byte_array_free (priv->ssid, TRUE);
-
- g_free (priv->bssid);
-
- G_OBJECT_CLASS (nm_access_point_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMAccessPoint *ap = NM_ACCESS_POINT (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_FLAGS:
- g_value_set_uint (value, nm_access_point_get_flags (ap));
- break;
- case PROP_WPA_FLAGS:
- g_value_set_uint (value, nm_access_point_get_wpa_flags (ap));
- break;
- case PROP_RSN_FLAGS:
- g_value_set_uint (value, nm_access_point_get_rsn_flags (ap));
- break;
- case PROP_SSID:
- g_value_set_boxed (value, nm_access_point_get_ssid (ap));
- break;
- case PROP_FREQUENCY:
- g_value_set_uint (value, nm_access_point_get_frequency (ap));
- break;
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_access_point_get_bssid (ap));
- break;
- case PROP_BSSID:
- g_value_set_string (value, nm_access_point_get_bssid (ap));
- break;
- case PROP_MODE:
- g_value_set_uint (value, nm_access_point_get_mode (ap));
- break;
- case PROP_MAX_BITRATE:
- g_value_set_uint (value, nm_access_point_get_max_bitrate (ap));
- break;
- case PROP_STRENGTH:
- g_value_set_uchar (value, nm_access_point_get_strength (ap));
- break;
- case PROP_LAST_SEEN:
- g_value_set_int (value, nm_access_point_get_last_seen (ap));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static gboolean
-demarshal_ssid (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- if (!_nm_ssid_demarshal (value, (GByteArray **) field))
- return FALSE;
-
- _nm_object_queue_notify (object, NM_ACCESS_POINT_SSID);
- return TRUE;
-}
-
-static void
-register_properties (NMAccessPoint *ap)
-{
- NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
- const NMPropertiesInfo property_info[] = {
- { NM_ACCESS_POINT_FLAGS, &priv->flags },
- { NM_ACCESS_POINT_WPA_FLAGS, &priv->wpa_flags },
- { NM_ACCESS_POINT_RSN_FLAGS, &priv->rsn_flags },
- { NM_ACCESS_POINT_SSID, &priv->ssid, demarshal_ssid },
- { NM_ACCESS_POINT_FREQUENCY, &priv->frequency },
- { NM_ACCESS_POINT_HW_ADDRESS, &priv->bssid },
- { NM_ACCESS_POINT_MODE, &priv->mode },
- { NM_ACCESS_POINT_MAX_BITRATE, &priv->max_bitrate },
- { NM_ACCESS_POINT_STRENGTH, &priv->strength },
- { NM_ACCESS_POINT_LAST_SEEN, &priv->last_seen },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (ap),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMAccessPointPrivate *priv;
-
- G_OBJECT_CLASS (nm_access_point_parent_class)->constructed (object);
-
- priv = NM_ACCESS_POINT_GET_PRIVATE (object);
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_ACCESS_POINT);
- register_properties (NM_ACCESS_POINT (object));
-}
-
-static void
-nm_access_point_class_init (NMAccessPointClass *ap_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
-
- g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMAccessPoint:flags:
- *
- * The flags of the access point.
- **/
- g_object_class_install_property
- (object_class, PROP_FLAGS,
- g_param_spec_uint (NM_ACCESS_POINT_FLAGS, "", "",
- NM_802_11_AP_FLAGS_NONE,
- NM_802_11_AP_FLAGS_PRIVACY,
- NM_802_11_AP_FLAGS_NONE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:wpa-flags:
- *
- * The WPA flags of the access point.
- **/
- g_object_class_install_property
- (object_class, PROP_WPA_FLAGS,
- g_param_spec_uint (NM_ACCESS_POINT_WPA_FLAGS, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:rsn-flags:
- *
- * The RSN flags of the access point.
- **/
- g_object_class_install_property
- (object_class, PROP_RSN_FLAGS,
- g_param_spec_uint (NM_ACCESS_POINT_RSN_FLAGS, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:ssid:
- *
- * The SSID of the access point.
- **/
- g_object_class_install_property
- (object_class, PROP_SSID,
- g_param_spec_boxed (NM_ACCESS_POINT_SSID, "", "",
- NM_TYPE_SSID,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:frequency:
- *
- * The frequency of the access point.
- **/
- g_object_class_install_property
- (object_class, PROP_FREQUENCY,
- g_param_spec_uint (NM_ACCESS_POINT_FREQUENCY, "", "",
- 0, 10000, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:bssid:
- *
- * The BSSID of the access point.
- **/
- g_object_class_install_property
- (object_class, PROP_BSSID,
- g_param_spec_string (NM_ACCESS_POINT_BSSID, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:hw-address:
- *
- * The hardware address of the access point.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_ACCESS_POINT_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:mode:
- *
- * The mode of the access point; either "infrastructure" (a central
- * coordinator of the wireless network allowing clients to connect) or
- * "ad-hoc" (a network with no central controller).
- **/
- g_object_class_install_property
- (object_class, PROP_MODE,
- g_param_spec_uint (NM_ACCESS_POINT_MODE, "", "",
- NM_802_11_MODE_ADHOC, NM_802_11_MODE_INFRA, NM_802_11_MODE_INFRA,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:max-bitrate:
- *
- * The maximum bit rate of the access point in kbit/s.
- **/
- g_object_class_install_property
- (object_class, PROP_MAX_BITRATE,
- g_param_spec_uint (NM_ACCESS_POINT_MAX_BITRATE, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:strength:
- *
- * The current signal strength of the access point.
- **/
- g_object_class_install_property
- (object_class, PROP_STRENGTH,
- g_param_spec_uchar (NM_ACCESS_POINT_STRENGTH, "", "",
- 0, G_MAXUINT8, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMAccessPoint:last-seen:
- *
- * The timestamp (in CLOCK_BOOTTIME seconds) for the last time the
- * access point was found in scan results. A value of -1 means the
- * access point has not been found in a scan.
- *
- * Since: 1.2
- **/
- g_object_class_install_property
- (object_class, PROP_LAST_SEEN,
- g_param_spec_int (NM_ACCESS_POINT_LAST_SEEN, "", "",
- -1, G_MAXINT, -1,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-access-point.h b/libnm-glib/nm-access-point.h
deleted file mode 100644
index d25de5417e..0000000000
--- a/libnm-glib/nm-access-point.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2011 Red Hat, Inc.
- */
-
-#ifndef NM_ACCESS_POINT_H
-#define NM_ACCESS_POINT_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include "NetworkManager.h"
-#include "nm-connection.h"
-#include "nm-object.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_ACCESS_POINT (nm_access_point_get_type ())
-#define NM_ACCESS_POINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACCESS_POINT, NMAccessPoint))
-#define NM_ACCESS_POINT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ACCESS_POINT, NMAccessPointClass))
-#define NM_IS_ACCESS_POINT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_ACCESS_POINT))
-#define NM_IS_ACCESS_POINT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_ACCESS_POINT))
-#define NM_ACCESS_POINT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACCESS_POINT, NMAccessPointClass))
-
-#define NM_ACCESS_POINT_FLAGS "flags"
-#define NM_ACCESS_POINT_WPA_FLAGS "wpa-flags"
-#define NM_ACCESS_POINT_RSN_FLAGS "rsn-flags"
-#define NM_ACCESS_POINT_SSID "ssid"
-#define NM_ACCESS_POINT_BSSID "bssid"
-#define NM_ACCESS_POINT_FREQUENCY "frequency"
-#define NM_ACCESS_POINT_MODE "mode"
-#define NM_ACCESS_POINT_MAX_BITRATE "max-bitrate"
-#define NM_ACCESS_POINT_STRENGTH "strength"
-#define NM_ACCESS_POINT_LAST_SEEN "last-seen"
-
-/* DEPRECATED */
-#define NM_ACCESS_POINT_HW_ADDRESS "hw-address"
-
-typedef struct {
- NMObject parent;
-} NMAccessPoint;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMAccessPointClass;
-
-GType nm_access_point_get_type (void);
-
-GObject *nm_access_point_new (DBusGConnection *connection, const char *path);
-
-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);
-const GByteArray * 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);
-guint8 nm_access_point_get_strength (NMAccessPoint *ap);
-NM_AVAILABLE_IN_1_2
-int nm_access_point_get_last_seen (NMAccessPoint *ap);
-
-GSList * nm_access_point_filter_connections (NMAccessPoint *ap,
- const GSList *connections);
-
-gboolean nm_access_point_connection_valid (NMAccessPoint *ap,
- NMConnection *connection);
-
-/* DEPRECATED */
-NM_DEPRECATED_IN_0_9_10
-const char * nm_access_point_get_hw_address (NMAccessPoint *ap);
-
-G_END_DECLS
-
-#endif /* NM_ACCESS_POINT_H */
diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c
deleted file mode 100644
index a8150755a9..0000000000
--- a/libnm-glib/nm-active-connection.c
+++ /dev/null
@@ -1,851 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "NetworkManager.h"
-#include "nm-active-connection.h"
-#include "nm-object-private.h"
-#include "nm-types-private.h"
-#include "nm-device.h"
-#include "nm-device-private.h"
-#include "nm-connection.h"
-#include "nm-vpn-connection.h"
-#include "nm-dbus-helpers-private.h"
-
-static GType _nm_active_connection_type_for_path (DBusGConnection *connection,
- const char *path);
-static void _nm_active_connection_type_for_path_async (DBusGConnection *connection,
- const char *path,
- NMObjectTypeCallbackFunc callback,
- gpointer user_data);
-
-G_DEFINE_TYPE_WITH_CODE (NMActiveConnection, nm_active_connection, NM_TYPE_OBJECT,
- _nm_object_register_type_func (g_define_type_id,
- _nm_active_connection_type_for_path,
- _nm_active_connection_type_for_path_async);
- )
-
-#define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *connection;
- char *id;
- char *uuid;
- char *type;
- char *specific_object;
- GPtrArray *devices;
- NMActiveConnectionState state;
- gboolean is_default;
- NMIP4Config *ip4_config;
- NMDHCP4Config *dhcp4_config;
- gboolean is_default6;
- NMIP6Config *ip6_config;
- NMDHCP6Config *dhcp6_config;
- gboolean is_vpn;
- char *master;
-} NMActiveConnectionPrivate;
-
-enum {
- PROP_0,
- PROP_CONNECTION,
- PROP_ID,
- PROP_UUID,
- PROP_TYPE,
- PROP_SPECIFIC_OBJECT,
- PROP_DEVICES,
- PROP_STATE,
- PROP_DEFAULT,
- PROP_IP4_CONFIG,
- PROP_DHCP4_CONFIG,
- PROP_DEFAULT6,
- PROP_IP6_CONFIG,
- PROP_DHCP6_CONFIG,
- PROP_VPN,
- PROP_MASTER,
-
- LAST_PROP
-};
-
-/**
- * nm_active_connection_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMActiveConnection.
- *
- * Returns: (transfer full): a new active connection
- **/
-GObject *
-nm_active_connection_new (DBusGConnection *connection, const char *path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- return g_object_new (NM_TYPE_ACTIVE_CONNECTION,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
-}
-
-static GType
-_nm_active_connection_type_for_path (DBusGConnection *connection,
- const char *path)
-{
- DBusGProxy *proxy;
- GError *error = NULL;
- GValue value = G_VALUE_INIT;
- GType type;
-
- proxy = _nm_dbus_new_proxy_for_connection (connection, path, DBUS_INTERFACE_PROPERTIES);
- if (!proxy) {
- g_warning ("%s: couldn't create D-Bus object proxy.", __func__);
- return G_TYPE_INVALID;
- }
-
- /* Have to create an NMVPNConnection if it's a VPN connection, otherwise
- * a plain NMActiveConnection.
- */
- if (dbus_g_proxy_call (proxy,
- "Get", &error,
- G_TYPE_STRING, NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
- G_TYPE_STRING, "Vpn",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID)) {
- if (g_value_get_boolean (&value))
- type = NM_TYPE_VPN_CONNECTION;
- else
- type = NM_TYPE_ACTIVE_CONNECTION;
- } else {
- g_warning ("Error in getting active connection 'Vpn' property: %s",
- error->message);
- g_error_free (error);
- type = G_TYPE_INVALID;
- }
-
- g_object_unref (proxy);
- return type;
-}
-
-typedef struct {
- DBusGConnection *connection;
- NMObjectTypeCallbackFunc callback;
- gpointer user_data;
-} NMActiveConnectionAsyncData;
-
-static void
-async_got_type (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- NMActiveConnectionAsyncData *async_data = user_data;
- GValue value = G_VALUE_INIT;
- const char *path = dbus_g_proxy_get_path (proxy);
- GError *error = NULL;
- GType type;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID)) {
- if (g_value_get_boolean (&value))
- type = NM_TYPE_VPN_CONNECTION;
- else
- type = NM_TYPE_ACTIVE_CONNECTION;
- } else {
- g_warning ("%s: could not read properties for %s: %s", __func__, path, error->message);
- type = G_TYPE_INVALID;
- }
-
- async_data->callback (type, async_data->user_data);
-
- g_object_unref (proxy);
- g_slice_free (NMActiveConnectionAsyncData, async_data);
-}
-
-static void
-_nm_active_connection_type_for_path_async (DBusGConnection *connection,
- const char *path,
- NMObjectTypeCallbackFunc callback,
- gpointer user_data)
-{
- NMActiveConnectionAsyncData *async_data;
- DBusGProxy *proxy;
-
- async_data = g_slice_new (NMActiveConnectionAsyncData);
- async_data->connection = connection;
- async_data->callback = callback;
- async_data->user_data = user_data;
-
- proxy = _nm_dbus_new_proxy_for_connection (connection, path, DBUS_INTERFACE_PROPERTIES);
- dbus_g_proxy_begin_call (proxy, "Get",
- async_got_type, async_data, NULL,
- G_TYPE_STRING, NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
- G_TYPE_STRING, "Vpn",
- G_TYPE_INVALID);
-}
-
-/**
- * nm_active_connection_get_connection:
- * @connection: a #NMActiveConnection
- *
- * Gets the #NMConnection's DBus object path. This is often used with
- * nm_remote_settings_get_connection_by_path() to retrieve the
- * #NMRemoteConnection object that describes the connection.
- *
- * Returns: the object path of the #NMConnection which this #NMActiveConnection
- * is an active instance of. This is the internal string used by the
- * connection, and must not be modified.
- **/
-const char *
-nm_active_connection_get_connection (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->connection;
-}
-
-/**
- * nm_active_connection_get_id:
- * @connection: a #NMActiveConnection
- *
- * Gets the #NMConnection's ID.
- *
- * Returns: the ID of the #NMConnection that backs the #NMActiveConnection.
- * This is the internal string used by the connection, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_active_connection_get_id (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->id;
-}
-
-/**
- * nm_active_connection_get_uuid:
- * @connection: a #NMActiveConnection
- *
- * Gets the #NMConnection's UUID.
- *
- * Returns: the UUID of the #NMConnection that backs the #NMActiveConnection.
- * This is the internal string used by the connection, and must not be modified.
- **/
-const char *
-nm_active_connection_get_uuid (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->uuid;
-}
-
-/**
- * nm_active_connection_get_connection_type:
- * @connection: a #NMActiveConnection
- *
- * Gets the #NMConnection's type.
- *
- * Returns: the type of the #NMConnection that backs the #NMActiveConnection.
- * This is the internal string used by the connection, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_active_connection_get_connection_type (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->type;
-}
-
-/**
- * nm_active_connection_get_specific_object:
- * @connection: a #NMActiveConnection
- *
- * Gets the "specific object" used at the activation.
- *
- * Returns: the specific object's DBus path. This is the internal string used by the
- * connection, and must not be modified.
- **/
-const char *
-nm_active_connection_get_specific_object (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->specific_object;
-}
-
-/**
- * nm_active_connection_get_devices:
- * @connection: a #NMActiveConnection
- *
- * Gets the #NMDevices used for the active connections.
- *
- * Returns: (element-type NMDevice): the #GPtrArray containing #NMDevices.
- * This is the internal copy used by the connection, and must not be modified.
- **/
-const GPtrArray *
-nm_active_connection_get_devices (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return handle_ptr_array_return (NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->devices);
-}
-
-/**
- * nm_active_connection_get_state:
- * @connection: a #NMActiveConnection
- *
- * Gets the active connection's state.
- *
- * Returns: the state
- **/
-NMActiveConnectionState
-nm_active_connection_get_state (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVE_CONNECTION_STATE_UNKNOWN);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->state;
-}
-
-/**
- * nm_active_connection_get_default:
- * @connection: a #NMActiveConnection
- *
- * Whether the active connection is the default IPv4 one (that is, is used for
- * the default IPv4 route and DNS information).
- *
- * Returns: %TRUE if the active connection is the default IPv4 connection
- **/
-gboolean
-nm_active_connection_get_default (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_default;
-}
-
-/**
- * nm_active_connection_get_ip4_config:
- * @connection: an #NMActiveConnection
- *
- * Gets the current #NMIP4Config associated with the #NMActiveConnection.
- *
- * Returns: (transfer none): the #NMIP4Config, or %NULL if the
- * connection is not in the %NM_ACTIVE_CONNECTION_STATE_ACTIVATED
- * state.
- *
- * Since: 0.9.10
- **/
-NMIP4Config *
-nm_active_connection_get_ip4_config (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->ip4_config;
-}
-
-/**
- * nm_active_connection_get_dhcp4_config:
- * @connection: an #NMActiveConnection
- *
- * Gets the current #NMDHCP4Config (if any) associated with the
- * #NMActiveConnection.
- *
- * Returns: (transfer none): the #NMDHCP4Config, or %NULL if the
- * connection does not use DHCP, or is not in the
- * %NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
- *
- * Since: 0.9.10
- **/
-NMDHCP4Config *
-nm_active_connection_get_dhcp4_config (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->dhcp4_config;
-}
-
-/**
- * nm_active_connection_get_default6:
- * @connection: a #NMActiveConnection
- *
- * Whether the active connection is the default IPv6 one (that is, is used for
- * the default IPv6 route and DNS information).
- *
- * Returns: %TRUE if the active connection is the default IPv6 connection
- **/
-gboolean
-nm_active_connection_get_default6 (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_default6;
-}
-
-/**
- * nm_active_connection_get_ip6_config:
- * @connection: an #NMActiveConnection
- *
- * Gets the current #NMIP6Config associated with the #NMActiveConnection.
- *
- * Returns: (transfer none): the #NMIP6Config, or %NULL if the
- * connection is not in the %NM_ACTIVE_CONNECTION_STATE_ACTIVATED
- * state.
- *
- * Since: 0.9.10
- **/
-NMIP6Config *
-nm_active_connection_get_ip6_config (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->ip6_config;
-}
-
-/**
- * nm_active_connection_get_dhcp6_config:
- * @connection: an #NMActiveConnection
- *
- * Gets the current #NMDHCP6Config (if any) associated with the
- * #NMActiveConnection.
- *
- * Returns: (transfer none): the #NMDHCP6Config, or %NULL if the
- * connection does not use DHCPv6, or is not in the
- * %NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
- *
- * Since: 0.9.10
- **/
-NMDHCP6Config *
-nm_active_connection_get_dhcp6_config (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->dhcp6_config;
-}
-
-/**
- * nm_active_connection_get_vpn:
- * @connection: a #NMActiveConnection
- *
- * Whether the active connection is a VPN connection.
- *
- * Returns: %TRUE if the active connection is a VPN connection
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_active_connection_get_vpn (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_vpn;
-}
-
-/**
- * nm_active_connection_get_master:
- * @connection: a #NMActiveConnection
- *
- * Gets the path to the master #NMDevice of the connection.
- *
- * Returns: the path of the master #NMDevice of the #NMActiveConnection.
- * This is the internal string used by the connection, and must not be modified.
- **/
-const char *
-nm_active_connection_get_master (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (connection));
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->master;
-}
-
-static void
-nm_active_connection_init (NMActiveConnection *ap)
-{
-}
-
-static void
-dispose (GObject *object)
-{
- NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
-
- if (priv->devices) {
- g_ptr_array_set_free_func (priv->devices, g_object_unref);
- g_ptr_array_free (priv->devices, TRUE);
- priv->devices = NULL;
- }
-
- g_clear_object (&priv->ip4_config);
- g_clear_object (&priv->dhcp4_config);
- g_clear_object (&priv->ip6_config);
- g_clear_object (&priv->dhcp6_config);
-
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_active_connection_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
-
- g_free (priv->connection);
- g_free (priv->id);
- g_free (priv->uuid);
- g_free (priv->type);
- g_free (priv->specific_object);
- g_free (priv->master);
-
- G_OBJECT_CLASS (nm_active_connection_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMActiveConnection *self = NM_ACTIVE_CONNECTION (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_CONNECTION:
- g_value_set_string (value, nm_active_connection_get_connection (self));
- break;
- case PROP_ID:
- g_value_set_string (value, nm_active_connection_get_id (self));
- break;
- case PROP_UUID:
- g_value_set_string (value, nm_active_connection_get_uuid (self));
- break;
- case PROP_TYPE:
- g_value_set_string (value, nm_active_connection_get_connection_type (self));
- break;
- case PROP_SPECIFIC_OBJECT:
- g_value_set_boxed (value, nm_active_connection_get_specific_object (self));
- break;
- case PROP_DEVICES:
- g_value_set_boxed (value, nm_active_connection_get_devices (self));
- break;
- case PROP_STATE:
- g_value_set_uint (value, nm_active_connection_get_state (self));
- break;
- case PROP_DEFAULT:
- g_value_set_boolean (value, nm_active_connection_get_default (self));
- break;
- case PROP_IP4_CONFIG:
- g_value_set_object (value, nm_active_connection_get_ip4_config (self));
- break;
- case PROP_DHCP4_CONFIG:
- g_value_set_object (value, nm_active_connection_get_dhcp4_config (self));
- break;
- case PROP_DEFAULT6:
- g_value_set_boolean (value, nm_active_connection_get_default6 (self));
- break;
- case PROP_IP6_CONFIG:
- g_value_set_object (value, nm_active_connection_get_ip6_config (self));
- break;
- case PROP_DHCP6_CONFIG:
- g_value_set_object (value, nm_active_connection_get_dhcp6_config (self));
- break;
- case PROP_VPN:
- g_value_set_boolean (value, nm_active_connection_get_vpn (self));
- break;
- case PROP_MASTER:
- g_value_set_string (value, nm_active_connection_get_master (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-register_properties (NMActiveConnection *connection)
-{
- NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
- const NMPropertiesInfo property_info[] = {
- { NM_ACTIVE_CONNECTION_CONNECTION, &priv->connection },
- { NM_ACTIVE_CONNECTION_ID, &priv->id },
- { NM_ACTIVE_CONNECTION_UUID, &priv->uuid },
- { NM_ACTIVE_CONNECTION_TYPE, &priv->type },
- { NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, &priv->specific_object },
- { NM_ACTIVE_CONNECTION_DEVICES, &priv->devices, NULL, NM_TYPE_DEVICE },
- { NM_ACTIVE_CONNECTION_STATE, &priv->state },
- { NM_ACTIVE_CONNECTION_DEFAULT, &priv->is_default },
- { NM_ACTIVE_CONNECTION_IP4_CONFIG, &priv->ip4_config, NULL, NM_TYPE_IP4_CONFIG },
- { NM_ACTIVE_CONNECTION_DHCP4_CONFIG, &priv->dhcp4_config, NULL, NM_TYPE_DHCP4_CONFIG },
- { NM_ACTIVE_CONNECTION_DEFAULT6, &priv->is_default6 },
- { NM_ACTIVE_CONNECTION_IP6_CONFIG, &priv->ip6_config, NULL, NM_TYPE_IP6_CONFIG },
- { NM_ACTIVE_CONNECTION_DHCP6_CONFIG, &priv->dhcp6_config, NULL, NM_TYPE_DHCP6_CONFIG },
- { NM_ACTIVE_CONNECTION_VPN, &priv->is_vpn },
- { NM_ACTIVE_CONNECTION_MASTER, &priv->master },
-
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (connection),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_ACTIVE_CONNECTION);
- register_properties (NM_ACTIVE_CONNECTION (object));
-}
-
-static void
-nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
-
- g_type_class_add_private (ap_class, sizeof (NMActiveConnectionPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMActiveConnection:connection:
- *
- * The connection's path of the active connection.
- **/
- g_object_class_install_property
- (object_class, PROP_CONNECTION,
- g_param_spec_string (NM_ACTIVE_CONNECTION_CONNECTION, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:id:
- *
- * The active connection's ID
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_ID,
- g_param_spec_string (NM_ACTIVE_CONNECTION_ID, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:uuid:
- *
- * The active connection's UUID
- **/
- g_object_class_install_property
- (object_class, PROP_UUID,
- g_param_spec_string (NM_ACTIVE_CONNECTION_UUID, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:type:
- *
- * The active connection's type
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_TYPE,
- g_param_spec_string (NM_ACTIVE_CONNECTION_TYPE, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:specific-object:
- *
- * The specific object's path of the active connection.
- **/
- g_object_class_install_property
- (object_class, PROP_SPECIFIC_OBJECT,
- g_param_spec_string (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:device:
- *
- * The devices (#NMDevice) of the active connection.
- **/
- g_object_class_install_property
- (object_class, PROP_DEVICES,
- g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:state:
- *
- * The state of the active connection.
- **/
- g_object_class_install_property
- (object_class, PROP_STATE,
- g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE, "", "",
- NM_ACTIVE_CONNECTION_STATE_UNKNOWN,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATING,
- NM_ACTIVE_CONNECTION_STATE_UNKNOWN,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:default:
- *
- * Whether the active connection is the default IPv4 one.
- **/
- g_object_class_install_property
- (object_class, PROP_DEFAULT,
- g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:ip4-config:
- *
- * The #NMIP4Config of the connection.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_IP4_CONFIG,
- g_param_spec_object (NM_ACTIVE_CONNECTION_IP4_CONFIG, "", "",
- NM_TYPE_IP4_CONFIG,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:dhcp4-config:
- *
- * The #NMDHCP4Config of the connection.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP4_CONFIG,
- g_param_spec_object (NM_ACTIVE_CONNECTION_DHCP4_CONFIG, "", "",
- NM_TYPE_DHCP4_CONFIG,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:default6:
- *
- * Whether the active connection is the default IPv6 one.
- **/
- g_object_class_install_property
- (object_class, PROP_DEFAULT6,
- g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:ip6-config:
- *
- * The #NMIP6Config of the connection.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_IP6_CONFIG,
- g_param_spec_object (NM_ACTIVE_CONNECTION_IP6_CONFIG, "", "",
- NM_TYPE_IP6_CONFIG,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:dhcp6-config:
- *
- * The #NMDHCP6Config of the connection.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP6_CONFIG,
- g_param_spec_object (NM_ACTIVE_CONNECTION_DHCP6_CONFIG, "", "",
- NM_TYPE_DHCP6_CONFIG,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:vpn:
- *
- * Whether the active connection is a VPN connection.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_VPN,
- g_param_spec_boolean (NM_ACTIVE_CONNECTION_VPN, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMActiveConnection:master:
- *
- * The path of the master device if one exists.
- **/
- g_object_class_install_property
- (object_class, PROP_MASTER,
- g_param_spec_string (NM_ACTIVE_CONNECTION_MASTER, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-active-connection.h b/libnm-glib/nm-active-connection.h
deleted file mode 100644
index cdf02a94e8..0000000000
--- a/libnm-glib/nm-active-connection.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#ifndef NM_ACTIVE_CONNECTION_H
-#define NM_ACTIVE_CONNECTION_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include "nm-object.h"
-#include "nm-connection.h"
-#include "NetworkManager.h"
-#include "nm-ip4-config.h"
-#include "nm-dhcp4-config.h"
-#include "nm-ip6-config.h"
-#include "nm-dhcp6-config.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_ACTIVE_CONNECTION (nm_active_connection_get_type ())
-#define NM_ACTIVE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnection))
-#define NM_ACTIVE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
-#define NM_IS_ACTIVE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_ACTIVE_CONNECTION))
-#define NM_IS_ACTIVE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_ACTIVE_CONNECTION))
-#define NM_ACTIVE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
-
-#define NM_ACTIVE_CONNECTION_CONNECTION "connection"
-#define NM_ACTIVE_CONNECTION_ID "id"
-#define NM_ACTIVE_CONNECTION_UUID "uuid"
-#define NM_ACTIVE_CONNECTION_TYPE "type"
-#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
-#define NM_ACTIVE_CONNECTION_DEVICES "devices"
-#define NM_ACTIVE_CONNECTION_STATE "state"
-#define NM_ACTIVE_CONNECTION_DEFAULT "default"
-#define NM_ACTIVE_CONNECTION_IP4_CONFIG "ip4-config"
-#define NM_ACTIVE_CONNECTION_DHCP4_CONFIG "dhcp4-config"
-#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
-#define NM_ACTIVE_CONNECTION_IP6_CONFIG "ip6-config"
-#define NM_ACTIVE_CONNECTION_DHCP6_CONFIG "dhcp6-config"
-#define NM_ACTIVE_CONNECTION_VPN "vpn"
-#define NM_ACTIVE_CONNECTION_MASTER "master"
-
-typedef struct {
- NMObject parent;
-} NMActiveConnection;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMActiveConnectionClass;
-
-GType nm_active_connection_get_type (void);
-
-GObject *nm_active_connection_new (DBusGConnection *connection, const char *path);
-
-const char * nm_active_connection_get_connection (NMActiveConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_active_connection_get_id (NMActiveConnection *connection);
-const char * nm_active_connection_get_uuid (NMActiveConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_active_connection_get_connection_type (NMActiveConnection *connection);
-const char * nm_active_connection_get_specific_object (NMActiveConnection *connection);
-const GPtrArray *nm_active_connection_get_devices (NMActiveConnection *connection);
-NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *connection);
-const char * nm_active_connection_get_master (NMActiveConnection *connection);
-gboolean nm_active_connection_get_default (NMActiveConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-NMIP4Config * nm_active_connection_get_ip4_config (NMActiveConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-NMDHCP4Config *nm_active_connection_get_dhcp4_config (NMActiveConnection *connection);
-gboolean nm_active_connection_get_default6 (NMActiveConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-NMIP6Config * nm_active_connection_get_ip6_config (NMActiveConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-NMDHCP6Config *nm_active_connection_get_dhcp6_config (NMActiveConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_active_connection_get_vpn (NMActiveConnection *connection);
-
-G_END_DECLS
-
-#endif /* NM_ACTIVE_CONNECTION_H */
diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c
deleted file mode 100644
index 8f1524e33c..0000000000
--- a/libnm-glib/nm-client.c
+++ /dev/null
@@ -1,2514 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-client.h"
-
-#include <dbus/dbus-glib.h>
-#include <string.h>
-
-#include "nm-utils.h"
-#include "nm-libnm-core-intern/nm-common-macros.h"
-
-#include "nm-device-ethernet.h"
-#include "nm-device-wifi.h"
-#include "nm-device-private.h"
-#include "nm-types-private.h"
-#include "nm-object-private.h"
-#include "nm-active-connection.h"
-#include "nm-vpn-connection.h"
-#include "nm-object-cache.h"
-#include "nm-dbus-glib-types.h"
-
-void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled);
-
-static void nm_client_initable_iface_init (GInitableIface *iface);
-static void nm_client_async_initable_iface_init (GAsyncInitableIface *iface);
-static GInitableIface *nm_client_parent_initable_iface;
-static GAsyncInitableIface *nm_client_parent_async_initable_iface;
-
-G_DEFINE_TYPE_WITH_CODE (NMClient, nm_client, NM_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_client_initable_iface_init);
- G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_client_async_initable_iface_init);
- )
-
-#define NM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CLIENT, NMClientPrivate))
-
-typedef struct {
- DBusGProxy *client_proxy;
- DBusGProxy *bus_proxy;
- gboolean manager_running;
- char *version;
- NMState state;
- gboolean startup;
- GPtrArray *devices;
- GPtrArray *all_devices;
- GPtrArray *active_connections;
- NMConnectivityState connectivity;
- NMActiveConnection *primary_connection;
- NMActiveConnection *activating_connection;
-
- DBusGProxyCall *perm_call;
- GHashTable *permissions;
-
- /* Activations waiting for their NMActiveConnection
- * to appear and then their callback to be called.
- */
- GSList *pending_activations;
-
- gboolean networking_enabled;
- gboolean wireless_enabled;
- gboolean wireless_hw_enabled;
-
- gboolean wwan_enabled;
- gboolean wwan_hw_enabled;
-
- gboolean wimax_enabled;
- gboolean wimax_hw_enabled;
-} NMClientPrivate;
-
-enum {
- PROP_0,
- PROP_VERSION,
- PROP_STATE,
- PROP_STARTUP,
- PROP_MANAGER_RUNNING,
- PROP_NETWORKING_ENABLED,
- PROP_WIRELESS_ENABLED,
- PROP_WIRELESS_HARDWARE_ENABLED,
- PROP_WWAN_ENABLED,
- PROP_WWAN_HARDWARE_ENABLED,
- PROP_WIMAX_ENABLED,
- PROP_WIMAX_HARDWARE_ENABLED,
- PROP_ACTIVE_CONNECTIONS,
- PROP_CONNECTIVITY,
- PROP_PRIMARY_CONNECTION,
- PROP_ACTIVATING_CONNECTION,
- PROP_DEVICES,
- PROP_ALL_DEVICES,
-
- LAST_PROP
-};
-
-enum {
- DEVICE_ADDED,
- DEVICE_REMOVED,
- ANY_DEVICE_ADDED,
- ANY_DEVICE_REMOVED,
- PERMISSION_CHANGED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void proxy_name_owner_changed (DBusGProxy *proxy,
- const char *name,
- const char *old_owner,
- const char *new_owner,
- gpointer user_data);
-
-/*****************************************************************************/
-
-/**
- * nm_client_error_quark:
- *
- * Registers an error quark for #NMClient if necessary.
- *
- * Returns: the error quark used for #NMClient errors.
- *
- * Since: 0.9.10
- **/
-GQuark
-nm_client_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-client-error-quark");
- return quark;
-}
-
-/*****************************************************************************/
-
-static void
-nm_client_init (NMClient *client)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
-
- priv->state = NM_STATE_UNKNOWN;
-
- priv->permissions = g_hash_table_new (NULL, NULL);
-}
-
-static void
-poke_wireless_devices_with_rf_status (NMClient *client)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
- int i;
-
- for (i = 0; priv->all_devices && (i < priv->all_devices->len); i++) {
- NMDevice *device = g_ptr_array_index (priv->all_devices, i);
-
- if (NM_IS_DEVICE_WIFI (device))
- _nm_device_wifi_set_wireless_enabled (NM_DEVICE_WIFI (device), priv->wireless_enabled);
- }
-}
-
-static void
-wireless_enabled_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
-{
- poke_wireless_devices_with_rf_status (NM_CLIENT (object));
-}
-
-static void
-register_properties (NMClient *client)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
- const NMPropertiesInfo property_info[] = {
- { NM_CLIENT_VERSION, &priv->version },
- { NM_CLIENT_STATE, &priv->state },
- { NM_CLIENT_STARTUP, &priv->startup },
- { NM_CLIENT_NETWORKING_ENABLED, &priv->networking_enabled },
- { NM_CLIENT_WIRELESS_ENABLED, &priv->wireless_enabled },
- { NM_CLIENT_WIRELESS_HARDWARE_ENABLED, &priv->wireless_hw_enabled },
- { NM_CLIENT_WWAN_ENABLED, &priv->wwan_enabled },
- { NM_CLIENT_WWAN_HARDWARE_ENABLED, &priv->wwan_hw_enabled },
- { NM_CLIENT_WIMAX_ENABLED, &priv->wimax_enabled },
- { NM_CLIENT_WIMAX_HARDWARE_ENABLED, &priv->wimax_hw_enabled },
- { NM_CLIENT_ACTIVE_CONNECTIONS, &priv->active_connections, NULL, NM_TYPE_ACTIVE_CONNECTION },
- { NM_CLIENT_CONNECTIVITY, &priv->connectivity },
- { NM_CLIENT_PRIMARY_CONNECTION, &priv->primary_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
- { NM_CLIENT_ACTIVATING_CONNECTION, &priv->activating_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
- { NM_CLIENT_DEVICES, &priv->devices, NULL, NM_TYPE_DEVICE, "device" },
- { NM_CLIENT_ALL_DEVICES, &priv->all_devices, NULL, NM_TYPE_DEVICE, "any-device" },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (client),
- priv->client_proxy,
- property_info);
-}
-
-static NMClientPermission
-nm_permission_to_client (const char *nm)
-{
- if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK))
- return NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI))
- return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN))
- return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX))
- return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_SLEEP_WAKE))
- return NM_CLIENT_PERMISSION_SLEEP_WAKE;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_NETWORK_CONTROL))
- return NM_CLIENT_PERMISSION_NETWORK_CONTROL;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED))
- return NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN))
- return NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM))
- return NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN))
- return NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_MODIFY_HOSTNAME))
- return NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS))
- return NM_CLIENT_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_RELOAD))
- return NM_CLIENT_PERMISSION_RELOAD;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_CHECKPOINT_ROLLBACK))
- return NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_STATISTICS))
- return NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS;
-
- return NM_CLIENT_PERMISSION_NONE;
-}
-
-static NMClientPermissionResult
-nm_permission_result_to_client (const char *nm)
-{
- if (!strcmp (nm, "yes"))
- return NM_CLIENT_PERMISSION_RESULT_YES;
- else if (!strcmp (nm, "no"))
- return NM_CLIENT_PERMISSION_RESULT_NO;
- else if (!strcmp (nm, "auth"))
- return NM_CLIENT_PERMISSION_RESULT_AUTH;
- return NM_CLIENT_PERMISSION_RESULT_UNKNOWN;
-}
-
-static void
-update_permissions (NMClient *self, GHashTable *permissions)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
- GHashTableIter iter;
- gpointer key, value;
- NMClientPermission perm;
- NMClientPermissionResult perm_result;
- GList *keys, *keys_iter;
-
- /* get list of old permissions for change notification */
- keys = g_hash_table_get_keys (priv->permissions);
- g_hash_table_remove_all (priv->permissions);
-
- if (permissions) {
- /* Process new permissions */
- g_hash_table_iter_init (&iter, permissions);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- perm = nm_permission_to_client ((const char *) key);
- perm_result = nm_permission_result_to_client ((const char *) value);
- if (perm) {
- g_hash_table_insert (priv->permissions,
- GUINT_TO_POINTER (perm),
- GUINT_TO_POINTER (perm_result));
-
- /* Remove this permission from the list of previous permissions
- * we'll be sending NM_CLIENT_PERMISSION_RESULT_UNKNOWN for
- * in the change signal since it is still a known permission.
- */
- keys = g_list_remove (keys, GUINT_TO_POINTER (perm));
- }
- }
- }
-
- /* Signal changes in all updated permissions */
- g_hash_table_iter_init (&iter, priv->permissions);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- g_signal_emit (self, signals[PERMISSION_CHANGED], 0,
- GPOINTER_TO_UINT (key),
- GPOINTER_TO_UINT (value));
- }
-
- /* And signal changes in all permissions that used to be valid but for
- * some reason weren't received in the last request (if any).
- */
- for (keys_iter = keys; keys_iter; keys_iter = g_list_next (keys_iter)) {
- g_signal_emit (self, signals[PERMISSION_CHANGED], 0,
- GPOINTER_TO_UINT (keys_iter->data),
- NM_CLIENT_PERMISSION_RESULT_UNKNOWN);
- }
- g_list_free (keys);
-}
-
-static gboolean
-get_permissions_sync (NMClient *self, GError **error)
-{
- gboolean success;
- gs_unref_hashtable GHashTable *permissions = NULL;
-
- success = dbus_g_proxy_call_with_timeout (NM_CLIENT_GET_PRIVATE (self)->client_proxy,
- "GetPermissions", 3000, error,
- G_TYPE_INVALID,
- DBUS_TYPE_G_MAP_OF_STRING, &permissions, G_TYPE_INVALID);
- update_permissions (self, success ? permissions : NULL);
- return success;
-}
-
-static void
-get_permissions_reply (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- NMClient *self = NM_CLIENT (user_data);
- gs_unref_hashtable GHashTable *permissions = NULL;
- gs_free_error GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_STRING, &permissions,
- G_TYPE_INVALID);
- NM_CLIENT_GET_PRIVATE (self)->perm_call = NULL;
- update_permissions (NM_CLIENT (user_data), error ? NULL : permissions);
-}
-
-static void
-client_recheck_permissions (DBusGProxy *proxy, gpointer user_data)
-{
- NMClient *self = NM_CLIENT (user_data);
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
-
- if (!priv->perm_call) {
- priv->perm_call = dbus_g_proxy_begin_call (NM_CLIENT_GET_PRIVATE (self)->client_proxy, "GetPermissions",
- get_permissions_reply, self, NULL,
- G_TYPE_INVALID);
- }
-}
-
-/**
- * nm_client_get_devices:
- * @client: a #NMClient
- *
- * Gets all the known network devices. Use nm_device_get_type() or the
- * <literal>NM_IS_DEVICE_XXXX</literal> functions to determine what kind of
- * device member of the returned array is, and then you may use device-specific
- * methods such as nm_device_ethernet_get_hw_address().
- *
- * Returns: (transfer none) (element-type NMDevice): a #GPtrArray
- * containing all the #NMDevices. The returned array is owned by the
- * #NMClient object and should not be modified.
- **/
-const GPtrArray *
-nm_client_get_devices (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
-
- return handle_ptr_array_return (NM_CLIENT_GET_PRIVATE (client)->devices);
-}
-
-/**
- * nm_client_get_all_devices:
- * @client: a #NMClient
- *
- * Gets both real devices and device placeholders (eg, software devices which
- * do not currently exist, but could be created automatically by NetworkManager
- * if one of their NMDevice::ActivatableConnections was activated). Use
- * nm_device_is_real() to determine whether each device is a real device or
- * a placeholder.
- *
- * Use nm_device_get_type() or the NM_IS_DEVICE_XXXX() functions to determine
- * what kind of device each member of the returned array is, and then you may
- * use device-specific methods such as nm_device_ethernet_get_hw_address().
- *
- * Returns: (transfer none) (element-type NMDevice): a #GPtrArray
- * containing all the #NMDevices. The returned array is owned by the
- * #NMClient object and should not be modified.
- *
- * Since: 1.2
- **/
-const GPtrArray *
-nm_client_get_all_devices (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
-
- return NM_CLIENT_GET_PRIVATE (client)->all_devices;
-}
-
-/**
- * nm_client_get_device_by_path:
- * @client: a #NMClient
- * @object_path: the object path to search for
- *
- * Gets a #NMDevice from a #NMClient.
- *
- * Returns: (transfer none): the #NMDevice for the given @object_path or %NULL if none is found.
- **/
-NMDevice *
-nm_client_get_device_by_path (NMClient *client, const char *object_path)
-{
- const GPtrArray *devices;
- int i;
- NMDevice *device = NULL;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
- g_return_val_if_fail (object_path, NULL);
-
- devices = nm_client_get_devices (client);
- if (!devices)
- return NULL;
-
- for (i = 0; i < devices->len; i++) {
- NMDevice *candidate = g_ptr_array_index (devices, i);
- if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), object_path)) {
- device = candidate;
- break;
- }
- }
-
- return device;
-}
-
-/**
- * nm_client_get_device_by_iface:
- * @client: a #NMClient
- * @iface: the interface name to search for
- *
- * Gets a #NMDevice from a #NMClient.
- *
- * Returns: (transfer none): the #NMDevice for the given @iface or %NULL if none is found.
- **/
-NMDevice *
-nm_client_get_device_by_iface (NMClient *client, const char *iface)
-{
- const GPtrArray *devices;
- int i;
- NMDevice *device = NULL;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
- g_return_val_if_fail (iface, NULL);
-
- devices = nm_client_get_devices (client);
- if (!devices)
- return NULL;
-
- for (i = 0; i < devices->len; i++) {
- NMDevice *candidate = g_ptr_array_index (devices, i);
- if (!strcmp (nm_device_get_iface (candidate), iface)) {
- device = candidate;
- break;
- }
- }
-
- return device;
-}
-
-typedef struct {
- NMClient *client;
- NMClientActivateFn act_fn;
- NMClientAddActivateFn add_act_fn;
- char *active_path;
- char *new_connection_path;
- guint idle_id;
- gpointer user_data;
-} ActivateInfo;
-
-static void
-activate_info_free (ActivateInfo *info)
-{
- if (info->idle_id)
- g_source_remove (info->idle_id);
- g_free (info->active_path);
- g_free (info->new_connection_path);
- memset (info, 0, sizeof (*info));
- g_slice_free (ActivateInfo, info);
-}
-
-static void
-activate_info_complete (ActivateInfo *info,
- NMActiveConnection *active,
- GError *error)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (info->client);
-
- if (info->act_fn)
- info->act_fn (info->client, error ? NULL : active, error, info->user_data);
- else if (info->add_act_fn) {
- info->add_act_fn (info->client,
- error ? NULL : active,
- error ? NULL : info->new_connection_path,
- error,
- info->user_data);
- } else if (error)
- g_warning ("Device activation failed: %s", error->message);
-
- priv->pending_activations = g_slist_remove (priv->pending_activations, info);
-}
-
-static void
-recheck_pending_activations (NMClient *self, const char *failed_path, GError *error)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
- GSList *iter, *next;
- const GPtrArray *active_connections;
- gboolean found_in_active = FALSE;
- gboolean found_in_pending = FALSE;
- ActivateInfo *ainfo = NULL;
- int i;
-
- active_connections = nm_client_get_active_connections (self);
-
- /* For each pending activation, look for a active connection that has
- * the pending activation's object path, and call pending connection's
- * callback.
- * If the connection to activate doesn't make it to active_connections,
- * due to an error, we have to call the callback for failed_path.
- */
- for (iter = priv->pending_activations; iter; iter = next) {
- ActivateInfo *info = iter->data;
-
- next = g_slist_next (iter);
-
- if (!found_in_pending && failed_path && g_strcmp0 (failed_path, info->active_path) == 0) {
- found_in_pending = TRUE;
- ainfo = info;
- }
-
- for (i = 0; active_connections && i < active_connections->len; i++) {
- NMActiveConnection *active = g_ptr_array_index (active_connections, i);
- const char *active_path = nm_object_get_path (NM_OBJECT (active));
-
- if (!found_in_active && failed_path && g_strcmp0 (failed_path, active_path) == 0)
- found_in_active = TRUE;
-
- if (g_strcmp0 (info->active_path, active_path) == 0) {
- /* Call the pending activation's callback and it all up */
- activate_info_complete (info, active, NULL);
- activate_info_free (info);
- break;
- }
- }
- }
-
- if (!found_in_active && found_in_pending) {
- /* A newly activated connection failed due to some immediate error
- * and disappeared from active connection list. Make sure the
- * callback gets called.
- */
- activate_info_complete (ainfo, NULL, error);
- activate_info_free (ainfo);
- }
-}
-
-static void
-activate_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- ActivateInfo *info = user_data;
- char *path;
- GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_OBJECT_PATH, &path,
- G_TYPE_INVALID);
- if (error) {
- activate_info_complete (info, NULL, error);
- activate_info_free (info);
- g_clear_error (&error);
- } else {
- info->active_path = path;
- recheck_pending_activations (info->client, NULL, NULL);
- }
-}
-
-static gboolean
-activate_nm_not_running (gpointer user_data)
-{
- ActivateInfo *info = user_data;
- GError *error;
-
- info->idle_id = 0;
-
- error = g_error_new_literal (NM_CLIENT_ERROR,
- NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
- "NetworkManager is not running");
- activate_info_complete (info, NULL, error);
- activate_info_free (info);
- g_clear_error (&error);
- return FALSE;
-}
-
-/**
- * nm_client_activate_connection:
- * @client: a #NMClient
- * @connection: (allow-none): an #NMConnection
- * @device: (allow-none): the #NMDevice
- * @specific_object: (allow-none): the object path of a connection-type-specific
- * object this activation should use. This parameter is currently ignored for
- * wired and mobile broadband connections, and the value of %NULL should be used
- * (ie, no specific object). For Wi-Fi or WiMAX connections, pass the object
- * path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can
- * get using nm_object_get_path(), and which will be used to complete the
- * details of the newly added connection.
- * @callback: (scope async) (allow-none): the function to call when the call is done
- * @user_data: (closure): user data to pass to the callback function
- *
- * Starts a connection to a particular network using the configuration settings
- * from @connection and the network device @device. Certain connection types
- * also take a "specific object" which is the object path of a connection-
- * specific object, like an #NMAccessPoint for Wi-Fi connections, or an
- * #NMWimaxNsp for WiMAX connections, to which you wish to connect. If the
- * specific object is not given, NetworkManager can, in some cases, automatically
- * determine which network to connect to given the settings in @connection.
- *
- * If @connection is not given for a device-based activation, NetworkManager
- * picks the best available connection for the device and activates it.
- *
- * Note that the callback is invoked when NetworkManager has started activating
- * the new connection, not when it finishes. You can used the returned
- * #NMActiveConnection object (in particular, #NMActiveConnection:state) to
- * track the activation to its completion.
- **/
-void
-nm_client_activate_connection (NMClient *client,
- NMConnection *connection,
- NMDevice *device,
- const char *specific_object,
- NMClientActivateFn callback,
- gpointer user_data)
-{
- NMClientPrivate *priv;
- ActivateInfo *info;
-
- g_return_if_fail (NM_IS_CLIENT (client));
- if (device)
- g_return_if_fail (NM_IS_DEVICE (device));
- if (connection)
- g_return_if_fail (NM_IS_CONNECTION (connection));
-
- info = g_slice_new0 (ActivateInfo);
- info->act_fn = callback;
- info->user_data = user_data;
- info->client = client;
-
- priv = NM_CLIENT_GET_PRIVATE (client);
- priv->pending_activations = g_slist_prepend (priv->pending_activations, info);
-
- if (priv->manager_running == FALSE) {
- info->idle_id = g_idle_add (activate_nm_not_running, info);
- return;
- }
-
- dbus_g_proxy_begin_call (priv->client_proxy, "ActivateConnection",
- activate_cb, info, NULL,
- DBUS_TYPE_G_OBJECT_PATH, connection ? nm_connection_get_path (connection) : "/",
- DBUS_TYPE_G_OBJECT_PATH, device ? nm_object_get_path (NM_OBJECT (device)) : "/",
- DBUS_TYPE_G_OBJECT_PATH, specific_object ?: "/",
- G_TYPE_INVALID);
-}
-
-static void
-add_activate_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- ActivateInfo *info = user_data;
- char *connection_path;
- char *active_path;
- GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_OBJECT_PATH, &connection_path,
- DBUS_TYPE_G_OBJECT_PATH, &active_path,
- G_TYPE_INVALID);
- if (error) {
- activate_info_complete (info, NULL, error);
- activate_info_free (info);
- } else {
- info->new_connection_path = connection_path;
- info->active_path = active_path;
- recheck_pending_activations (info->client, NULL, NULL);
- }
-}
-
-/**
- * nm_client_add_and_activate_connection:
- * @client: a #NMClient
- * @partial: (allow-none): an #NMConnection to add; the connection may be
- * partially filled (or even %NULL) and will be completed by NetworkManager
- * using the given @device and @specific_object before being added
- * @device: the #NMDevice
- * @specific_object: (allow-none): the object path of a connection-type-specific
- * object this activation should use. This parameter is currently ignored for
- * wired and mobile broadband connections, and the value of %NULL should be used
- * (ie, no specific object). For Wi-Fi or WiMAX connections, pass the object
- * path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can
- * get using nm_object_get_path(), and which will be used to complete the
- * details of the newly added connection.
- * @callback: (scope async) (allow-none): the function to call when the call is done
- * @user_data: (closure): user data to pass to the callback function
- *
- * Adds a new connection using the given details (if any) as a template,
- * automatically filling in missing settings with the capabilities of the
- * given device and specific object. The new connection is then activated.
- * Cannot be used for VPN connections at this time.
- *
- * Note that the callback is invoked when NetworkManager has started activating
- * the new connection, not when it finishes. You can used the returned
- * #NMActiveConnection object (in particular, #NMActiveConnection:state) to
- * track the activation to its completion.
- **/
-void
-nm_client_add_and_activate_connection (NMClient *client,
- NMConnection *partial,
- NMDevice *device,
- const char *specific_object,
- NMClientAddActivateFn callback,
- gpointer user_data)
-{
- NMClientPrivate *priv;
- ActivateInfo *info;
- GHashTable *hash = NULL;
-
- g_return_if_fail (NM_IS_CLIENT (client));
- g_return_if_fail (NM_IS_DEVICE (device));
-
- info = g_slice_new0 (ActivateInfo);
- info->add_act_fn = callback;
- info->user_data = user_data;
- info->client = client;
-
- if (partial)
- hash = nm_connection_to_hash (partial, NM_SETTING_HASH_FLAG_ALL);
- if (!hash)
- hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- priv = NM_CLIENT_GET_PRIVATE (client);
- priv->pending_activations = g_slist_prepend (priv->pending_activations, info);
-
- if (priv->manager_running) {
- dbus_g_proxy_begin_call (priv->client_proxy, "AddAndActivateConnection",
- add_activate_cb, info, NULL,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
- DBUS_TYPE_G_OBJECT_PATH, nm_object_get_path (NM_OBJECT (device)),
- DBUS_TYPE_G_OBJECT_PATH, specific_object ?: "/",
- G_TYPE_INVALID);
- } else
- info->idle_id = g_idle_add (activate_nm_not_running, info);
-
- g_hash_table_unref (hash);
-}
-
-static void
-active_connections_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
-{
- recheck_pending_activations (NM_CLIENT (object), NULL, NULL);
-}
-
-static void
-object_creation_failed_cb (GObject *object, GError *error, char *failed_path)
-{
- if (error)
- recheck_pending_activations (NM_CLIENT (object), failed_path, error);
-}
-
-/**
- * nm_client_deactivate_connection:
- * @client: a #NMClient
- * @active: the #NMActiveConnection to deactivate
- *
- * Deactivates an active #NMActiveConnection.
- **/
-void
-nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active)
-{
- NMClientPrivate *priv;
- const char *path;
- GError *error = NULL;
-
- g_return_if_fail (NM_IS_CLIENT (client));
- g_return_if_fail (NM_IS_ACTIVE_CONNECTION (active));
-
- priv = NM_CLIENT_GET_PRIVATE (client);
- if (!priv->manager_running)
- return;
-
- path = nm_object_get_path (NM_OBJECT (active));
- if (!dbus_g_proxy_call (priv->client_proxy, "DeactivateConnection", &error,
- DBUS_TYPE_G_OBJECT_PATH, path,
- G_TYPE_INVALID,
- G_TYPE_INVALID)) {
- g_warning ("Could not deactivate connection '%s': %s",
- path, NM_G_ERROR_MSG (error));
- g_clear_error (&error);
- }
-}
-
-/**
- * nm_client_get_active_connections:
- * @client: a #NMClient
- *
- * Gets the active connections.
- *
- * Returns: (transfer none) (element-type NMActiveConnection): a #GPtrArray
- * containing all the active #NMActiveConnections.
- * The returned array is owned by the client and should not be modified.
- **/
-const GPtrArray *
-nm_client_get_active_connections (NMClient *client)
-{
- NMClientPrivate *priv;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
-
- priv = NM_CLIENT_GET_PRIVATE (client);
- if (!priv->manager_running)
- return NULL;
-
- return handle_ptr_array_return (priv->active_connections);
-}
-
-/**
- * nm_client_wireless_get_enabled:
- * @client: a #NMClient
- *
- * Determines whether the wireless is enabled.
- *
- * Returns: %TRUE if wireless is enabled
- **/
-gboolean
-nm_client_wireless_get_enabled (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->wireless_enabled;
-}
-
-/**
- * nm_client_wireless_set_enabled:
- * @client: a #NMClient
- * @enabled: %TRUE to enable wireless
- *
- * Enables or disables wireless devices.
- **/
-void
-nm_client_wireless_set_enabled (NMClient *client, gboolean enabled)
-{
- GValue value = G_VALUE_INIT;
-
- g_return_if_fail (NM_IS_CLIENT (client));
-
- if (!NM_CLIENT_GET_PRIVATE (client)->manager_running)
- return;
-
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, enabled);
-
- _nm_object_set_property (NM_OBJECT (client),
- NM_DBUS_INTERFACE,
- "WirelessEnabled",
- &value);
-}
-
-/**
- * nm_client_wireless_hardware_get_enabled:
- * @client: a #NMClient
- *
- * Determines whether the wireless hardware is enabled.
- *
- * Returns: %TRUE if the wireless hardware is enabled
- **/
-gboolean
-nm_client_wireless_hardware_get_enabled (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->wireless_hw_enabled;
-}
-
-/**
- * nm_client_wwan_get_enabled:
- * @client: a #NMClient
- *
- * Determines whether WWAN is enabled.
- *
- * Returns: %TRUE if WWAN is enabled
- **/
-gboolean
-nm_client_wwan_get_enabled (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->wwan_enabled;
-}
-
-/**
- * nm_client_wwan_set_enabled:
- * @client: a #NMClient
- * @enabled: %TRUE to enable WWAN
- *
- * Enables or disables WWAN devices.
- **/
-void
-nm_client_wwan_set_enabled (NMClient *client, gboolean enabled)
-{
- GValue value = G_VALUE_INIT;
-
- g_return_if_fail (NM_IS_CLIENT (client));
-
- if (!NM_CLIENT_GET_PRIVATE (client)->manager_running)
- return;
-
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, enabled);
-
- _nm_object_set_property (NM_OBJECT (client),
- NM_DBUS_INTERFACE,
- "WwanEnabled",
- &value);
-}
-
-/**
- * nm_client_wwan_hardware_get_enabled:
- * @client: a #NMClient
- *
- * Determines whether the WWAN hardware is enabled.
- *
- * Returns: %TRUE if the WWAN hardware is enabled
- **/
-gboolean
-nm_client_wwan_hardware_get_enabled (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->wwan_hw_enabled;
-}
-
-/**
- * nm_client_wimax_get_enabled:
- * @client: a #NMClient
- *
- * Determines whether WiMAX is enabled.
- *
- * Returns: %TRUE if WiMAX is enabled
- **/
-gboolean
-nm_client_wimax_get_enabled (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->wimax_enabled;
-}
-
-/**
- * nm_client_wimax_set_enabled:
- * @client: a #NMClient
- * @enabled: %TRUE to enable WiMAX
- *
- * Enables or disables WiMAX devices.
- **/
-void
-nm_client_wimax_set_enabled (NMClient *client, gboolean enabled)
-{
- GValue value = G_VALUE_INIT;
-
- g_return_if_fail (NM_IS_CLIENT (client));
-
- if (!NM_CLIENT_GET_PRIVATE (client)->manager_running)
- return;
-
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, enabled);
-
- _nm_object_set_property (NM_OBJECT (client),
- NM_DBUS_INTERFACE,
- "WimaxEnabled",
- &value);
-}
-
-/**
- * nm_client_wimax_hardware_get_enabled:
- * @client: a #NMClient
- *
- * Determines whether the WiMAX hardware is enabled.
- *
- * Returns: %TRUE if the WiMAX hardware is enabled
- **/
-gboolean
-nm_client_wimax_hardware_get_enabled (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->wimax_hw_enabled;
-}
-
-/**
- * nm_client_get_version:
- * @client: a #NMClient
- *
- * Gets NetworkManager version.
- *
- * Returns: string with the version
- **/
-const char *
-nm_client_get_version (NMClient *client)
-{
- NMClientPrivate *priv;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
-
- priv = NM_CLIENT_GET_PRIVATE (client);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
-
- return priv->manager_running ? priv->version : NULL;
-}
-
-/**
- * nm_client_get_state:
- * @client: a #NMClient
- *
- * Gets the current daemon state.
- *
- * Returns: the current %NMState
- **/
-NMState
-nm_client_get_state (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
-
- return NM_CLIENT_GET_PRIVATE (client)->state;
-}
-
-/**
- * nm_client_get_startup:
- * @client: a #NMClient
- *
- * Tests whether the daemon is still in the process of activating
- * connections at startup.
- *
- * Returns: whether the daemon is still starting up
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_client_get_startup (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
-
- return NM_CLIENT_GET_PRIVATE (client)->startup;
-}
-
-/**
- * nm_client_networking_get_enabled:
- * @client: a #NMClient
- *
- * Whether networking is enabled or disabled.
- *
- * Returns: %TRUE if networking is enabled, %FALSE if networking is disabled
- **/
-gboolean
-nm_client_networking_get_enabled (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->networking_enabled;
-}
-
-/**
- * nm_client_networking_set_enabled:
- * @client: a #NMClient
- * @enabled: %TRUE to set networking enabled, %FALSE to set networking disabled
- *
- * Enables or disables networking. When networking is disabled, all controlled
- * interfaces are disconnected and deactivated. When networking is enabled,
- * all controlled interfaces are available for activation.
- **/
-void
-nm_client_networking_set_enabled (NMClient *client, gboolean enable)
-{
- GError *err = NULL;
-
- g_return_if_fail (NM_IS_CLIENT (client));
-
- if (!NM_CLIENT_GET_PRIVATE (client)->manager_running)
- return;
-
- if (!dbus_g_proxy_call (NM_CLIENT_GET_PRIVATE (client)->client_proxy, "Enable", &err,
- G_TYPE_BOOLEAN, enable,
- G_TYPE_INVALID,
- G_TYPE_INVALID)) {
- g_warning ("Error enabling/disabling networking: %s",
- err ? err->message : "(unknown)");
- g_clear_error (&err);
- }
-}
-
-/**
- * nm_client_sleep:
- * @client: a #NMClient
- * @sleep_: %TRUE to put the daemon to sleep
- *
- * Deprecated; use nm_client_networking_set_enabled() instead.
- **/
-void
-nm_client_sleep (NMClient *client, gboolean sleep_)
-{
- nm_client_networking_set_enabled (client, !sleep_);
-}
-
-/**
- * nm_client_get_manager_running:
- * @client: a #NMClient
- *
- * Determines whether the daemon is running.
- *
- * Returns: %TRUE if the daemon is running
- **/
-gboolean
-nm_client_get_manager_running (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
-
- return NM_CLIENT_GET_PRIVATE (client)->manager_running;
-}
-
-/**
- * nm_client_get_permission_result:
- * @client: a #NMClient
- * @permission: the permission for which to return the result, one of #NMClientPermission
- *
- * Requests the result of a specific permission, which indicates whether the
- * client can or cannot perform the action the permission represents
- *
- * Returns: the permission's result, one of #NMClientPermissionResult
- **/
-NMClientPermissionResult
-nm_client_get_permission_result (NMClient *client, NMClientPermission permission)
-{
- gpointer result;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NM_CLIENT_PERMISSION_RESULT_UNKNOWN);
-
- result = g_hash_table_lookup (NM_CLIENT_GET_PRIVATE (client)->permissions,
- GUINT_TO_POINTER (permission));
- return GPOINTER_TO_UINT (result);
-}
-
-/**
- * nm_client_get_logging:
- * @client: a #NMClient
- * @level: (allow-none): return location for logging level string
- * @domains: (allow-none): return location for log domains string. The string is
- * a list of domains separated by ","
- * @error: (allow-none): return location for a #GError, or %NULL
- *
- * Gets NetworkManager current logging level and domains.
- *
- * Returns: %TRUE on success, %FALSE otherwise
- *
- * Since: 0.9.8
- **/
-gboolean
-nm_client_get_logging (NMClient *client, char **level, char **domains, GError **error)
-{
- NMClientPrivate *priv;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
- g_return_val_if_fail (level == NULL || *level == NULL, FALSE);
- g_return_val_if_fail (domains == NULL || *domains == NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- priv = NM_CLIENT_GET_PRIVATE (client);
- if (!priv->manager_running) {
- g_set_error_literal (error,
- NM_CLIENT_ERROR,
- NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
- "NetworkManager is not running");
- return FALSE;
- }
-
- if (!level && !domains)
- return TRUE;
-
- return dbus_g_proxy_call (priv->client_proxy, "GetLogging", error,
- G_TYPE_INVALID,
- G_TYPE_STRING, level,
- G_TYPE_STRING, domains,
- G_TYPE_INVALID);
-}
-
-/**
- * nm_client_set_logging:
- * @client: a #NMClient
- * @level: (allow-none): logging level to set (%NULL or an empty string for no change)
- * @domains: (allow-none): logging domains to set. The string should be a list of log
- * domains separated by ",". (%NULL or an empty string for no change)
- * @error: (allow-none): return location for a #GError, or %NULL
- *
- * Sets NetworkManager logging level and/or domains.
- *
- * Returns: %TRUE on success, %FALSE otherwise
- *
- * Since: 0.9.8
- **/
-gboolean
-nm_client_set_logging (NMClient *client, const char *level, const char *domains, GError **error)
-{
- NMClientPrivate *priv;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- priv = NM_CLIENT_GET_PRIVATE (client);
- if (!priv->manager_running) {
- g_set_error_literal (error,
- NM_CLIENT_ERROR,
- NM_CLIENT_ERROR_MANAGER_NOT_RUNNING,
- "NetworkManager is not running");
- return FALSE;
- }
-
- if (!level && !domains)
- return TRUE;
-
- return dbus_g_proxy_call (priv->client_proxy, "SetLogging", error,
- G_TYPE_STRING, level ?: "",
- G_TYPE_STRING, domains ?: "",
- G_TYPE_INVALID,
- G_TYPE_INVALID);
-}
-
-/**
- * nm_client_get_primary_connection:
- * @client: an #NMClient
- *
- * Gets the #NMActiveConnection corresponding to the primary active
- * network device.
- *
- * In particular, when there is no VPN active, or the VPN does not
- * have the default route, this returns the active connection that has
- * the default route. If there is a VPN active with the default route,
- * then this function returns the active connection that contains the
- * route to the VPN endpoint.
- *
- * If there is no default route, or the default route is over a
- * non-NetworkManager-recognized device, this will return %NULL.
- *
- * Returns: (transfer none): the appropriate #NMActiveConnection, if
- * any
- *
- * Since: 0.9.8.6
- */
-NMActiveConnection *
-nm_client_get_primary_connection (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->primary_connection;
-}
-
-/**
- * nm_client_get_activating_connection:
- * @client: an #NMClient
- *
- * Gets the #NMActiveConnection corresponding to a
- * currently-activating connection that is expected to become the new
- * #NMClient:primary-connection upon successful activation.
- *
- * Returns: (transfer none): the appropriate #NMActiveConnection, if
- * any.
- *
- * Since: 0.9.8.6
- */
-NMActiveConnection *
-nm_client_get_activating_connection (NMClient *client)
-{
- g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
- return NM_CLIENT_GET_PRIVATE (client)->activating_connection;
-}
-
-/*****************************************************************************/
-
-static void
-free_devices (NMClient *client, gboolean in_dispose)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
- gs_unref_ptrarray GPtrArray *real_devices = NULL;
- gs_unref_ptrarray GPtrArray *all_devices = NULL;
- GPtrArray *devices = NULL;
- guint i, j;
-
- real_devices = priv->devices;
- all_devices = priv->all_devices;
-
- if (in_dispose) {
- priv->devices = NULL;
- priv->all_devices = NULL;
- } else {
- priv->devices = g_ptr_array_new ();
- priv->all_devices = g_ptr_array_new ();
- }
-
- if (all_devices && all_devices->len > 0)
- devices = all_devices;
- else if (real_devices && real_devices->len > 0)
- devices = real_devices;
-
- if (real_devices && devices != real_devices) {
- for (i = 0; i < real_devices->len; i++) {
- NMDevice *d = real_devices->pdata[i];
-
- if (all_devices) {
- for (j = 0; j < all_devices->len; j++) {
- if (d == all_devices->pdata[j])
- goto next;
- }
- }
- if (!in_dispose)
- g_signal_emit (client, signals[DEVICE_REMOVED], 0, d);
-next:
- g_object_unref (d);
- }
- }
- if (devices) {
- for (i = 0; i < devices->len; i++) {
- NMDevice *d = devices->pdata[i];
-
- if (!in_dispose)
- g_signal_emit (client, signals[DEVICE_REMOVED], 0, d);
- g_object_unref (d);
- }
- }
-}
-
-static void
-free_active_connections (NMClient *client, gboolean emit_signals)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
- GPtrArray *active_connections;
- NMActiveConnection *active_connection;
- int i;
-
- if (!priv->active_connections)
- return;
-
- active_connections = priv->active_connections;
- priv->active_connections = NULL;
- for (i = 0; i < active_connections->len; i++) {
- active_connection = active_connections->pdata[i];
- /* Break circular refs */
- g_object_run_dispose (G_OBJECT (active_connection));
- g_object_unref (active_connection);
- }
- g_ptr_array_free (active_connections, TRUE);
-
- if (emit_signals)
- g_object_notify (G_OBJECT (client), NM_CLIENT_ACTIVE_CONNECTIONS);
-}
-
-static void
-updated_properties (GObject *object, GAsyncResult *result, gpointer user_data)
-{
- NMClient *client = NM_CLIENT (user_data);
- GError *error = NULL;
-
- if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error)) {
- g_warning ("%s: error reading NMClient properties: %s", __func__, error->message);
- g_error_free (error);
- }
-
- _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING);
-}
-
-static void
-proxy_name_owner_changed (DBusGProxy *proxy,
- const char *name,
- const char *old_owner,
- const char *new_owner,
- gpointer user_data)
-{
- NMClient *client = NM_CLIENT (user_data);
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
- gboolean old_good = (old_owner && strlen (old_owner));
- gboolean new_good = (new_owner && strlen (new_owner));
- gboolean new_running = FALSE;
-
- if (!name || strcmp (name, NM_DBUS_SERVICE))
- return;
-
- if (!old_good && new_good)
- new_running = TRUE;
- else if (old_good && !new_good)
- new_running = FALSE;
-
- if (new_running == priv->manager_running)
- return;
-
- priv->manager_running = new_running;
- if (!priv->manager_running) {
- priv->state = NM_STATE_UNKNOWN;
- priv->startup = FALSE;
- _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING);
- _nm_object_suppress_property_updates (NM_OBJECT (client), TRUE);
- poke_wireless_devices_with_rf_status (client);
- free_devices (client, FALSE);
- free_active_connections (client, TRUE);
- update_permissions (client, NULL);
- priv->wireless_enabled = FALSE;
- priv->wireless_hw_enabled = FALSE;
- priv->wwan_enabled = FALSE;
- priv->wwan_hw_enabled = FALSE;
- priv->wimax_enabled = FALSE;
- priv->wimax_hw_enabled = FALSE;
- g_free (priv->version);
- priv->version = NULL;
-
- /* Clear object cache to ensure bad refcounting by clients doesn't
- * keep objects in the cache.
- */
- _nm_object_cache_clear ();
- } else {
- _nm_object_suppress_property_updates (NM_OBJECT (client), FALSE);
- _nm_object_reload_properties_async (NM_OBJECT (client), updated_properties, client);
- client_recheck_permissions (priv->client_proxy, client);
- }
-}
-
-/**
- * nm_client_get_connectivity:
- * @client: an #NMClient
- *
- * Gets the current network connectivity state. Contrast
- * nm_client_check_connectivity() and
- * nm_client_check_connectivity_async(), which re-check the
- * connectivity state first before returning any information.
- *
- * Returns: the current connectivity state
- * Since: 0.9.8.6
- */
-NMConnectivityState
-nm_client_get_connectivity (NMClient *client)
-{
- NMClientPrivate *priv;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NM_CONNECTIVITY_UNKNOWN);
- priv = NM_CLIENT_GET_PRIVATE (client);
-
- _nm_object_ensure_inited (NM_OBJECT (client));
-
- return priv->connectivity;
-}
-
-/**
- * nm_client_check_connectivity:
- * @client: an #NMClient
- * @cancellable: a #GCancellable
- * @error: return location for a #GError
- *
- * Updates the network connectivity state and returns the (new)
- * current state. Contrast nm_client_get_connectivity(), which returns
- * the most recent known state without re-checking.
- *
- * This is a blocking call; use nm_client_check_connectivity_async()
- * if you do not want to block.
- *
- * Returns: the (new) current connectivity state
- * Since: 0.9.8.6
- */
-NMConnectivityState
-nm_client_check_connectivity (NMClient *client,
- GCancellable *cancellable,
- GError **error)
-{
- NMClientPrivate *priv;
- NMConnectivityState connectivity;
-
- g_return_val_if_fail (NM_IS_CLIENT (client), NM_CONNECTIVITY_UNKNOWN);
- priv = NM_CLIENT_GET_PRIVATE (client);
-
- if (!dbus_g_proxy_call (priv->client_proxy, "CheckConnectivity", error,
- G_TYPE_INVALID,
- G_TYPE_UINT, &connectivity,
- G_TYPE_INVALID))
- connectivity = NM_CONNECTIVITY_UNKNOWN;
-
- return connectivity;
-}
-
-typedef struct {
- NMClient *client;
- DBusGProxyCall *call;
- GCancellable *cancellable;
- guint cancelled_id;
- NMConnectivityState connectivity;
-} CheckConnectivityData;
-
-static void
-check_connectivity_data_free (CheckConnectivityData *ccd)
-{
- if (ccd->cancellable) {
- if (ccd->cancelled_id)
- g_signal_handler_disconnect (ccd->cancellable, ccd->cancelled_id);
- g_object_unref (ccd->cancellable);
- }
-
- g_slice_free (CheckConnectivityData, ccd);
-}
-
-static void
-check_connectivity_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple = user_data;
- CheckConnectivityData *ccd = g_simple_async_result_get_op_res_gpointer (simple);
- GError *error = NULL;
-
- if (ccd->cancellable) {
- g_signal_handler_disconnect (ccd->cancellable, ccd->cancelled_id);
- ccd->cancelled_id = 0;
- }
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_UINT, &ccd->connectivity,
- G_TYPE_INVALID))
- g_simple_async_result_take_error (simple, error);
-
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-}
-
-static void
-check_connectivity_cancelled_cb (GCancellable *cancellable,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple = user_data;
- CheckConnectivityData *ccd = g_simple_async_result_get_op_res_gpointer (simple);
-
- g_signal_handler_disconnect (cancellable, ccd->cancelled_id);
- ccd->cancelled_id = 0;
-
- dbus_g_proxy_cancel_call (NM_CLIENT_GET_PRIVATE (ccd->client)->client_proxy, ccd->call);
- g_simple_async_result_complete_in_idle (simple);
-}
-
-/**
- * nm_client_check_connectivity_async:
- * @client: an #NMClient
- * @cancellable: a #GCancellable
- * @callback: callback to call with the result
- * @user_data: data for @callback.
- *
- * Asynchronously updates the network connectivity state and invokes
- * @callback when complete. Contrast nm_client_get_connectivity(),
- * which (immediately) returns the most recent known state without
- * re-checking, and nm_client_check_connectivity(), which blocks.
- *
- * Since: 0.9.8.6
- */
-void
-nm_client_check_connectivity_async (NMClient *client,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- NMClientPrivate *priv;
- GSimpleAsyncResult *simple;
- CheckConnectivityData *ccd;
-
- g_return_if_fail (NM_IS_CLIENT (client));
- priv = NM_CLIENT_GET_PRIVATE (client);
-
- ccd = g_slice_new0 (CheckConnectivityData);
- ccd->client = client;
-
- simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
- nm_client_check_connectivity_async);
- if (cancellable)
- g_simple_async_result_set_check_cancellable (simple, cancellable);
- g_simple_async_result_set_op_res_gpointer (simple, ccd, (GDestroyNotify) check_connectivity_data_free);
-
- if (cancellable) {
- ccd->cancellable = g_object_ref (cancellable);
- ccd->cancelled_id = g_signal_connect (cancellable, "cancelled",
- G_CALLBACK (check_connectivity_cancelled_cb),
- simple);
- g_simple_async_result_set_check_cancellable (simple, cancellable);
- }
-
- ccd->call = dbus_g_proxy_begin_call (priv->client_proxy, "CheckConnectivity",
- check_connectivity_cb, simple, NULL,
- G_TYPE_INVALID);
-}
-
-/**
- * nm_client_check_connectivity_finish:
- * @client: an #NMClient
- * @result: the #GAsyncResult
- * @error: return location for a #GError
- *
- * Retrieves the result of an nm_client_check_connectivity_async()
- * call.
- *
- * Returns: the (new) current connectivity state
- * Since: 0.9.8.6
- */
-NMConnectivityState
-nm_client_check_connectivity_finish (NMClient *client,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- CheckConnectivityData *ccd;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (client), nm_client_check_connectivity_async), NM_CONNECTIVITY_UNKNOWN);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- ccd = g_simple_async_result_get_op_res_gpointer (simple);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return NM_CONNECTIVITY_UNKNOWN;
-
- return ccd->connectivity;
-}
-
-/*****************************************************************************/
-
-/**
- * nm_client_new:
- *
- * Creates a new #NMClient.
- *
- * Note that this will do blocking D-Bus calls to initialize the
- * client. You can use nm_client_new_async() if you want to avoid
- * that.
- *
- * NOTE: #NMClient provides information about devices and a mechanism to
- * control them. To access and modify network configuration data, use the
- * #NMRemoteSettings object.
- *
- * Returns: a new #NMClient or NULL on an error
- **/
-NMClient *
-nm_client_new (void)
-{
- NMClient *client;
-
- client = g_object_new (NM_TYPE_CLIENT, NM_OBJECT_DBUS_PATH, NM_DBUS_PATH, NULL);
-
- /* NMObject's constructor() can fail on a D-Bus connection error. So we can
- * get NULL here instead of a valid NMClient object.
- */
- if (client)
- _nm_object_ensure_inited (NM_OBJECT (client));
-
- return client;
-}
-
-static void
-client_inited (GObject *source, GAsyncResult *result, gpointer user_data)
-{
- GSimpleAsyncResult *simple = user_data;
- GError *error = NULL;
-
- if (!g_async_initable_init_finish (G_ASYNC_INITABLE (source), result, &error))
- g_simple_async_result_take_error (simple, error);
- else
- g_simple_async_result_set_op_res_gpointer (simple, source, g_object_unref);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-}
-
-/**
- * nm_client_new_async:
- * @cancellable: a #GCancellable, or %NULL
- * @callback: callback to call when the client is created
- * @user_data: data for @callback
- *
- * Creates a new #NMClient and begins asynchronously initializing it.
- * @callback will be called when it is done; use
- * nm_client_new_finish() to get the result. Note that on an error,
- * the callback can be invoked with two first parameters as NULL.
- *
- * NOTE: #NMClient provides information about devices and a mechanism to
- * control them. To access and modify network configuration data, use the
- * #NMRemoteSettings object.
- **/
-void
-nm_client_new_async (GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- NMClient *client;
- GSimpleAsyncResult *simple;
-
- client = g_object_new (NM_TYPE_CLIENT, NM_OBJECT_DBUS_PATH, NM_DBUS_PATH, NULL);
- /* When client is NULL, do no continue with initialization and run callback
- * directly with result == NULL indicating NMClient creation failure.
- */
- if (!client) {
- callback (NULL, NULL, user_data);
- return;
- }
-
- simple = g_simple_async_result_new (NULL, callback, user_data, nm_client_new_async);
- if (cancellable)
- g_simple_async_result_set_check_cancellable (simple, cancellable);
- g_async_initable_init_async (G_ASYNC_INITABLE (client), G_PRIORITY_DEFAULT,
- cancellable, client_inited, simple);
-}
-
-/**
- * nm_client_new_finish:
- * @result: a #GAsyncResult
- * @error: location for a #GError, or %NULL
- *
- * Gets the result of an nm_client_new_async() call.
- *
- * Returns: a new #NMClient, or %NULL on error
- **/
-NMClient *
-nm_client_new_finish (GAsyncResult *result, GError **error)
-{
- GSimpleAsyncResult *simple;
-
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- if (!result) {
- g_set_error_literal (error,
- NM_CLIENT_ERROR,
- NM_CLIENT_ERROR_UNKNOWN,
- "NMClient initialization failed (or you passed NULL 'result' by mistake)");
- return NULL;
- }
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, nm_client_new_async), NULL);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- else
- return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple));
-}
-
-/*
- * constructor() shouldn't be overridden in most cases, rather constructed()
- * method is preferred and more useful.
- * But, this serves as a workaround for bindings (use) calling the constructor()
- * directly instead of nm_client_new() function, and neither providing
- * construction properties. So, we fill "dbus-path" here if it was not specified
- * (was set to default value (NULL)).
- *
- * It allows this python code:
- * from gi.repository import NMClient
- * nmclient = NMClient.Client()
- * print nmclient.get_active_connections()
- *
- * instead of proper
- * nmclient = NMClient.Client().new()
- *
- * Note:
- * A nice overview of GObject construction is here:
- * http://blogs.gnome.org/desrt/2012/02/26/a-gentle-introduction-to-gobject-construction
- * It is much better explanation than the official docs
- * http://developer.gnome.org/gobject/unstable/chapter-gobject.html#gobject-instantiation
- */
-static GObject*
-constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- guint i;
- const char *dbus_path;
-
- for (i = 0; i < n_construct_params; i++) {
- if (strcmp (construct_params[i].pspec->name, NM_OBJECT_DBUS_PATH) == 0) {
- dbus_path = g_value_get_string (construct_params[i].value);
- if (dbus_path == NULL) {
- g_value_set_static_string (construct_params[i].value, NM_DBUS_PATH);
- } else {
- if (!g_variant_is_object_path (dbus_path)) {
- g_warning ("Passed D-Bus object path '%s' is invalid; using default '%s' instead",
- dbus_path, NM_DBUS_PATH);
- g_value_set_static_string (construct_params[i].value, NM_DBUS_PATH);
- }
- }
- break;
- }
- }
-
- object = G_OBJECT_CLASS (nm_client_parent_class)->constructor (type,
- n_construct_params,
- construct_params);
-
- return object;
-}
-
-static void
-constructed (GObject *object)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
- GError *error = NULL;
-
- if (!nm_utils_init (&error)) {
- g_warning ("Couldn't initialize nm-utils/crypto system: %s",
- error->message);
- g_clear_error (&error);
- }
-
- G_OBJECT_CLASS (nm_client_parent_class)->constructed (object);
-
- priv->client_proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE);
-
- register_properties (NM_CLIENT (object));
-
- /* Permissions */
- dbus_g_proxy_add_signal (priv->client_proxy, "CheckPermissions", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->client_proxy,
- "CheckPermissions",
- G_CALLBACK (client_recheck_permissions),
- object,
- NULL);
-
- priv->bus_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- g_assert (priv->bus_proxy);
-
- dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->bus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (proxy_name_owner_changed),
- object, NULL);
-
- g_signal_connect (object, "notify::" NM_CLIENT_WIRELESS_ENABLED,
- G_CALLBACK (wireless_enabled_cb), NULL);
-
- g_signal_connect (object, "notify::" NM_CLIENT_ACTIVE_CONNECTIONS,
- G_CALLBACK (active_connections_changed_cb), NULL);
-
- g_signal_connect (object, "object-creation-failed",
- G_CALLBACK (object_creation_failed_cb), NULL);
-}
-
-static gboolean
-init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
-{
- NMClient *client = NM_CLIENT (initable);
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
-
- if (!nm_client_parent_initable_iface->init (initable, cancellable, error))
- return FALSE;
-
- if (!dbus_g_proxy_call (priv->bus_proxy,
- "NameHasOwner", error,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &priv->manager_running,
- G_TYPE_INVALID))
- return FALSE;
-
- if (priv->manager_running && !get_permissions_sync (client, error))
- return FALSE;
-
- return TRUE;
-}
-
-typedef struct {
- NMClient *client;
- GSimpleAsyncResult *result;
- gboolean properties_pending;
- gboolean permissions_pending;
-} NMClientInitData;
-
-static void
-init_async_complete (NMClientInitData *init_data)
-{
- if (init_data->properties_pending || init_data->permissions_pending)
- return;
-
- g_simple_async_result_complete (init_data->result);
- g_object_unref (init_data->result);
- g_slice_free (NMClientInitData, init_data);
-}
-
-static void
-init_async_got_permissions (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- NMClientInitData *init_data = user_data;
- gs_unref_hashtable GHashTable *permissions = NULL;
- gs_free_error GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_STRING, &permissions,
- G_TYPE_INVALID);
- update_permissions (init_data->client, error ? NULL : permissions);
-
- init_data->permissions_pending = FALSE;
- init_async_complete (init_data);
-}
-
-static void
-init_async_got_properties (GObject *source, GAsyncResult *result, gpointer user_data)
-{
- NMClientInitData *init_data = user_data;
- GError *error = NULL;
-
- if (!nm_client_parent_async_initable_iface->init_finish (G_ASYNC_INITABLE (source), result, &error))
- g_simple_async_result_take_error (init_data->result, error);
-
- init_data->properties_pending = FALSE;
- init_async_complete (init_data);
-}
-
-static void
-finish_init (NMClientInitData *init_data)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (init_data->client);
-
- nm_client_parent_async_initable_iface->init_async (G_ASYNC_INITABLE (init_data->client),
- G_PRIORITY_DEFAULT, NULL, /* FIXME cancellable */
- init_async_got_properties, init_data);
- init_data->properties_pending = TRUE;
-
- dbus_g_proxy_begin_call (priv->client_proxy, "GetPermissions",
- init_async_got_permissions, init_data, NULL,
- G_TYPE_INVALID);
- init_data->permissions_pending = TRUE;
-}
-
-static void
-init_async_got_manager_running (DBusGProxy *proxy, DBusGProxyCall *call,
- gpointer user_data)
-{
- NMClientInitData *init_data = user_data;
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (init_data->client);
- GError *error = NULL;
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_BOOLEAN, &priv->manager_running,
- G_TYPE_INVALID)) {
- g_simple_async_result_take_error (init_data->result, error);
- init_async_complete (init_data);
- return;
- }
-
- if (!priv->manager_running) {
- init_async_complete (init_data);
- return;
- }
-
- finish_init (init_data);
-}
-
-static void
-init_async (GAsyncInitable *initable, int io_priority,
- GCancellable *cancellable, GAsyncReadyCallback callback,
- gpointer user_data)
-{
- NMClientInitData *init_data;
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (initable);
-
- init_data = g_slice_new0 (NMClientInitData);
- init_data->client = NM_CLIENT (initable);
- init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
- user_data, init_async);
- if (cancellable)
- g_simple_async_result_set_check_cancellable (init_data->result, cancellable);
- g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
-
- /* Check if NM is running */
- dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
- init_async_got_manager_running,
- init_data, NULL,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID);
-}
-
-static gboolean
-init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- else
- return TRUE;
-}
-
-static void
-dispose (GObject *object)
-{
- NMClient *client = NM_CLIENT (object);
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
-
- if (priv->perm_call) {
- dbus_g_proxy_cancel_call (priv->client_proxy, priv->perm_call);
- priv->perm_call = NULL;
- }
-
- g_clear_object (&priv->client_proxy);
- g_clear_object (&priv->bus_proxy);
-
- free_devices (client, TRUE);
- free_active_connections (client, FALSE);
- g_clear_object (&priv->primary_connection);
- g_clear_object (&priv->activating_connection);
-
- g_slist_free_full (priv->pending_activations, (GDestroyNotify) activate_info_free);
- priv->pending_activations = NULL;
-
- g_hash_table_destroy (priv->permissions);
- priv->permissions = NULL;
-
- G_OBJECT_CLASS (nm_client_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
-
- g_free (priv->version);
-
- G_OBJECT_CLASS (nm_client_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
- gboolean b;
-
- switch (prop_id) {
- case PROP_NETWORKING_ENABLED:
- b = g_value_get_boolean (value);
- if (priv->networking_enabled != b) {
- nm_client_networking_set_enabled (NM_CLIENT (object), b);
- /* Let the property value flip when we get the change signal from NM */
- }
- break;
- case PROP_WIRELESS_ENABLED:
- b = g_value_get_boolean (value);
- if (priv->wireless_enabled != b) {
- nm_client_wireless_set_enabled (NM_CLIENT (object), b);
- /* Let the property value flip when we get the change signal from NM */
- }
- break;
- case PROP_WWAN_ENABLED:
- b = g_value_get_boolean (value);
- if (priv->wwan_enabled != b) {
- nm_client_wwan_set_enabled (NM_CLIENT (object), b);
- /* Let the property value flip when we get the change signal from NM */
- }
- break;
- case PROP_WIMAX_ENABLED:
- b = g_value_get_boolean (value);
- if (priv->wimax_enabled != b) {
- nm_client_wimax_set_enabled (NM_CLIENT (object), b);
- /* Let the property value flip when we get the change signal from NM */
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMClient *self = NM_CLIENT (object);
- NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_VERSION:
- g_value_set_string (value, nm_client_get_version (self));
- break;
- case PROP_STATE:
- g_value_set_uint (value, nm_client_get_state (self));
- break;
- case PROP_STARTUP:
- g_value_set_boolean (value, nm_client_get_startup (self));
- break;
- case PROP_MANAGER_RUNNING:
- g_value_set_boolean (value, priv->manager_running);
- break;
- case PROP_NETWORKING_ENABLED:
- g_value_set_boolean (value, nm_client_networking_get_enabled (self));
- break;
- case PROP_WIRELESS_ENABLED:
- g_value_set_boolean (value, priv->wireless_enabled);
- break;
- case PROP_WIRELESS_HARDWARE_ENABLED:
- g_value_set_boolean (value, priv->wireless_hw_enabled);
- break;
- case PROP_WWAN_ENABLED:
- g_value_set_boolean (value, priv->wwan_enabled);
- break;
- case PROP_WWAN_HARDWARE_ENABLED:
- g_value_set_boolean (value, priv->wwan_hw_enabled);
- break;
- case PROP_WIMAX_ENABLED:
- g_value_set_boolean (value, priv->wimax_enabled);
- break;
- case PROP_WIMAX_HARDWARE_ENABLED:
- g_value_set_boolean (value, priv->wimax_hw_enabled);
- break;
- case PROP_ACTIVE_CONNECTIONS:
- g_value_set_boxed (value, nm_client_get_active_connections (self));
- break;
- case PROP_CONNECTIVITY:
- g_value_set_uint (value, priv->connectivity);
- break;
- case PROP_PRIMARY_CONNECTION:
- g_value_set_object (value, priv->primary_connection);
- break;
- case PROP_ACTIVATING_CONNECTION:
- g_value_set_object (value, priv->activating_connection);
- break;
- case PROP_DEVICES:
- g_value_set_boxed (value, nm_client_get_devices (self));
- break;
- case PROP_ALL_DEVICES:
- g_value_set_boxed (value, nm_client_get_all_devices (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_client_class_init (NMClientClass *client_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (client_class);
-
- g_type_class_add_private (client_class, sizeof (NMClientPrivate));
-
- /* virtual methods */
- object_class->constructor = constructor;
- object_class->constructed = constructed;
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMClient:version:
- *
- * The NetworkManager version.
- **/
- g_object_class_install_property
- (object_class, PROP_VERSION,
- g_param_spec_string (NM_CLIENT_VERSION, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:state:
- *
- * The current daemon state.
- **/
- g_object_class_install_property
- (object_class, PROP_STATE,
- g_param_spec_uint (NM_CLIENT_STATE, "", "",
- NM_STATE_UNKNOWN, NM_STATE_CONNECTED_GLOBAL, NM_STATE_UNKNOWN,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:startup:
- *
- * Whether the daemon is still starting up.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_STARTUP,
- g_param_spec_boolean (NM_CLIENT_STARTUP, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:manager-running:
- *
- * Whether the daemon is running.
- **/
- g_object_class_install_property
- (object_class, PROP_MANAGER_RUNNING,
- g_param_spec_boolean (NM_CLIENT_MANAGER_RUNNING, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:networking-enabled:
- *
- * Whether networking is enabled.
- **/
- g_object_class_install_property
- (object_class, PROP_NETWORKING_ENABLED,
- g_param_spec_boolean (NM_CLIENT_NETWORKING_ENABLED, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:wireless-enabled:
- *
- * Whether wireless is enabled.
- **/
- g_object_class_install_property
- (object_class, PROP_WIRELESS_ENABLED,
- g_param_spec_boolean (NM_CLIENT_WIRELESS_ENABLED, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:wireless-hardware-enabled:
- *
- * Whether the wireless hardware is enabled.
- **/
- g_object_class_install_property
- (object_class, PROP_WIRELESS_HARDWARE_ENABLED,
- g_param_spec_boolean (NM_CLIENT_WIRELESS_HARDWARE_ENABLED, "", "",
- TRUE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:wwan-enabled:
- *
- * Whether WWAN functionality is enabled.
- **/
- g_object_class_install_property
- (object_class, PROP_WWAN_ENABLED,
- g_param_spec_boolean (NM_CLIENT_WWAN_ENABLED, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:wwan-hardware-enabled:
- *
- * Whether the WWAN hardware is enabled.
- **/
- g_object_class_install_property
- (object_class, PROP_WWAN_HARDWARE_ENABLED,
- g_param_spec_boolean (NM_CLIENT_WWAN_HARDWARE_ENABLED, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:wimax-enabled:
- *
- * Whether WiMAX functionality is enabled.
- **/
- g_object_class_install_property
- (object_class, PROP_WIMAX_ENABLED,
- g_param_spec_boolean (NM_CLIENT_WIMAX_ENABLED, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:wimax-hardware-enabled:
- *
- * Whether the WiMAX hardware is enabled.
- **/
- g_object_class_install_property
- (object_class, PROP_WIMAX_HARDWARE_ENABLED,
- g_param_spec_boolean (NM_CLIENT_WIMAX_HARDWARE_ENABLED, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:active-connections: (type GPtrArray):
- *
- * The active connections.
- **/
- g_object_class_install_property
- (object_class, PROP_ACTIVE_CONNECTIONS,
- g_param_spec_boxed (NM_CLIENT_ACTIVE_CONNECTIONS, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:connectivity:
- *
- * The network connectivity state.
- *
- * Since: 0.9.8.6
- */
- g_object_class_install_property
- (object_class, PROP_CONNECTIVITY,
- g_param_spec_uint (NM_CLIENT_CONNECTIVITY, "", "",
- NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_UNKNOWN,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:primary-connection:
- *
- * The #NMActiveConnection of the device with the default route;
- * see nm_client_get_primary_connection() for more details.
- *
- * Since: 0.9.8.6
- **/
- g_object_class_install_property
- (object_class, PROP_PRIMARY_CONNECTION,
- g_param_spec_object (NM_CLIENT_PRIMARY_CONNECTION, "", "",
- NM_TYPE_ACTIVE_CONNECTION,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:activating-connection:
- *
- * The #NMActiveConnection of the activating connection that is
- * likely to become the new #NMClient:primary-connection.
- *
- * Since: 0.9.8.6
- **/
- g_object_class_install_property
- (object_class, PROP_ACTIVATING_CONNECTION,
- g_param_spec_object (NM_CLIENT_ACTIVATING_CONNECTION, "", "",
- NM_TYPE_ACTIVE_CONNECTION,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:devices:
- *
- * List of real network devices. Does not include placeholder devices.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_DEVICES,
- g_param_spec_boxed (NM_CLIENT_DEVICES, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMClient:all-devices:
- *
- * List of both real devices and device placeholders.
- *
- * Since: 1.2
- **/
- g_object_class_install_property
- (object_class, PROP_ALL_DEVICES,
- g_param_spec_boxed (NM_CLIENT_ALL_DEVICES, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /* signals */
-
- /**
- * NMClient::device-added:
- * @client: the client that received the signal
- * @device: (type NMDevice): the new device
- *
- * Notifies that a #NMDevice is added. This signal is not emitted for
- * placeholder devices.
- **/
- signals[DEVICE_ADDED] =
- g_signal_new ("device-added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMClientClass, device_added),
- NULL, NULL, NULL,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-
- /**
- * NMClient::device-removed:
- * @client: the client that received the signal
- * @device: (type NMDevice): the removed device
- *
- * Notifies that a #NMDevice is removed. This signal is not emitted for
- * placeholder devices.
- **/
- signals[DEVICE_REMOVED] =
- g_signal_new ("device-removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMClientClass, device_removed),
- NULL, NULL, NULL,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-
- /**
- * NMClient::any-device-added:
- * @client: the client that received the signal
- * @device: (type NMDevice): the new device
- *
- * Notifies that a #NMDevice is added. This signal is emitted for both
- * regular devices and placeholder devices.
- **/
- signals[ANY_DEVICE_ADDED] =
- g_signal_new ("any-device-added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-
- /**
- * NMClient::any-device-removed:
- * @client: the client that received the signal
- * @device: (type NMDevice): the removed device
- *
- * Notifies that a #NMDevice is removed. This signal is emitted for both
- * regular devices and placeholder devices.
- **/
- signals[ANY_DEVICE_REMOVED] =
- g_signal_new ("any-device-removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-
- /**
- * NMClient::permission-changed:
- * @client: the client that received the signal
- * @permission: a permission from #NMClientPermission
- * @result: the permission's result, one of #NMClientPermissionResult
- *
- * Notifies that a permission has changed
- **/
- signals[PERMISSION_CHANGED] =
- g_signal_new ("permission-changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
-}
-
-static void
-nm_client_initable_iface_init (GInitableIface *iface)
-{
- nm_client_parent_initable_iface = g_type_interface_peek_parent (iface);
-
- iface->init = init_sync;
-}
-
-static void
-nm_client_async_initable_iface_init (GAsyncInitableIface *iface)
-{
- nm_client_parent_async_initable_iface = g_type_interface_peek_parent (iface);
-
- iface->init_async = init_async;
- iface->init_finish = init_finish;
-}
diff --git a/libnm-glib/nm-client.h b/libnm-glib/nm-client.h
deleted file mode 100644
index fbbc3d92f5..0000000000
--- a/libnm-glib/nm-client.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#ifndef NM_CLIENT_H
-#define NM_CLIENT_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <dbus/dbus-glib.h>
-#include "NetworkManager.h"
-#include "nm-object.h"
-#include "nm-device.h"
-#include "nm-active-connection.h"
-#include "nm-vpn-connection.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_CLIENT (nm_client_get_type ())
-#define NM_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CLIENT, NMClient))
-#define NM_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CLIENT, NMClientClass))
-#define NM_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CLIENT))
-#define NM_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_CLIENT))
-#define NM_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CLIENT, NMClientClass))
-
-#define NM_CLIENT_VERSION "version"
-#define NM_CLIENT_STATE "state"
-#define NM_CLIENT_STARTUP "startup"
-#define NM_CLIENT_MANAGER_RUNNING "manager-running"
-#define NM_CLIENT_NETWORKING_ENABLED "networking-enabled"
-#define NM_CLIENT_WIRELESS_ENABLED "wireless-enabled"
-#define NM_CLIENT_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"
-#define NM_CLIENT_WWAN_ENABLED "wwan-enabled"
-#define NM_CLIENT_WWAN_HARDWARE_ENABLED "wwan-hardware-enabled"
-#define NM_CLIENT_WIMAX_ENABLED "wimax-enabled"
-#define NM_CLIENT_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled"
-#define NM_CLIENT_ACTIVE_CONNECTIONS "active-connections"
-#define NM_CLIENT_CONNECTIVITY "connectivity"
-#define NM_CLIENT_PRIMARY_CONNECTION "primary-connection"
-#define NM_CLIENT_ACTIVATING_CONNECTION "activating-connection"
-#define NM_CLIENT_DEVICES "devices"
-#define NM_CLIENT_ALL_DEVICES "all-devices"
-
-/**
- * NMClientPermission:
- * @NM_CLIENT_PERMISSION_NONE: unknown or no permission
- * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK: controls whether networking
- * can be globally enabled or disabled
- * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI: controls whether Wi-Fi can be
- * globally enabled or disabled
- * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN: controls whether WWAN (3G) can be
- * globally enabled or disabled
- * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX: controls whether WiMAX can be
- * globally enabled or disabled
- * @NM_CLIENT_PERMISSION_SLEEP_WAKE: controls whether the client can ask
- * NetworkManager to sleep and wake
- * @NM_CLIENT_PERMISSION_NETWORK_CONTROL: controls whether networking connections
- * can be started, stopped, and changed
- * @NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED: controls whether a password
- * protected Wi-Fi hotspot can be created
- * @NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN: controls whether an open Wi-Fi hotspot
- * can be created
- * @NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM: controls whether connections
- * that are available to all users can be modified
- * @NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN: controls whether connections
- * owned by the current user can be modified
- * @NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME: controls whether the
- * persistent hostname can be changed
- * @NM_CLIENT_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS: modify persistent global
- * DNS configuration
- * @NM_CLIENT_PERMISSION_RELOAD: controls access to Reload.
- * persistent hostname can be changed
- * @NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK: permission to create checkpoints.
- * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS: controls whether device
- * statistics can be globally enabled or disabled
- * @NM_CLIENT_PERMISSION_LAST: a reserved boundary value
- *
- * #NMClientPermission values indicate various permissions that NetworkManager
- * clients can obtain to perform certain tasks on behalf of the current user.
- **/
-typedef enum {
- NM_CLIENT_PERMISSION_NONE = 0,
- NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK = 1,
- NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI = 2,
- NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN = 3,
- NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX = 4,
- NM_CLIENT_PERMISSION_SLEEP_WAKE = 5,
- NM_CLIENT_PERMISSION_NETWORK_CONTROL = 6,
- NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED = 7,
- NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN = 8,
- NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM = 9,
- NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN = 10,
- NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME = 11,
- NM_CLIENT_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS = 12,
- NM_CLIENT_PERMISSION_RELOAD = 13,
- NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK = 14,
- NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS = 15,
-
- NM_CLIENT_PERMISSION_LAST = 15,
-} NMClientPermission;
-
-/**
- * NMClientPermissionResult:
- * @NM_CLIENT_PERMISSION_RESULT_UNKNOWN: unknown or no authorization
- * @NM_CLIENT_PERMISSION_RESULT_YES: the permission is available
- * @NM_CLIENT_PERMISSION_RESULT_AUTH: authorization is necessary before the
- * permission is available
- * @NM_CLIENT_PERMISSION_RESULT_NO: permission to perform the operation is
- * denied by system policy
- *
- * #NMClientPermissionResult values indicate what authorizations and permissions
- * the user requires to obtain a given #NMClientPermission
- **/
-typedef enum {
- NM_CLIENT_PERMISSION_RESULT_UNKNOWN = 0,
- NM_CLIENT_PERMISSION_RESULT_YES,
- NM_CLIENT_PERMISSION_RESULT_AUTH,
- NM_CLIENT_PERMISSION_RESULT_NO
-} NMClientPermissionResult;
-
-/**
- * NMClientError:
- * @NM_CLIENT_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_CLIENT_ERROR_MANAGER_NOT_RUNNING: an operation that requires NetworkManager
- * failed because NetworkManager is not running
- *
- * Describes errors that may result from operations involving a #NMClient.
- **/
-typedef enum {
- NM_CLIENT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_CLIENT_ERROR_MANAGER_NOT_RUNNING, /*< nick=ManagerNotRunning >*/
-} NMClientError;
-
-#define NM_CLIENT_ERROR nm_client_error_quark ()
-NM_AVAILABLE_IN_0_9_10
-GQuark nm_client_error_quark (void);
-
-typedef struct {
- NMObject parent;
-} NMClient;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Signals */
- void (*device_added) (NMClient *client, NMDevice *device);
- void (*device_removed) (NMClient *client, NMDevice *device);
- void (*permission_changed) (NMClient *client,
- NMClientPermission permission,
- NMClientPermissionResult result);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMClientClass;
-
-GType nm_client_get_type (void);
-
-NMClient *nm_client_new (void);
-
-void nm_client_new_async (GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-NMClient *nm_client_new_finish (GAsyncResult *result,
- GError **error);
-
-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);
-
-typedef void (*NMClientActivateFn) (NMClient *client,
- NMActiveConnection *active_connection,
- GError *error,
- gpointer user_data);
-
-void nm_client_activate_connection (NMClient *client,
- NMConnection *connection,
- NMDevice *device,
- const char *specific_object,
- NMClientActivateFn callback,
- gpointer user_data);
-
-typedef void (*NMClientAddActivateFn) (NMClient *client,
- NMActiveConnection *connection,
- const char *new_connection_path,
- GError *error,
- gpointer user_data);
-
-void nm_client_add_and_activate_connection (NMClient *client,
- NMConnection *partial,
- NMDevice *device,
- const char *specific_object,
- NMClientAddActivateFn callback,
- gpointer user_data);
-
-void nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active);
-
-gboolean nm_client_networking_get_enabled (NMClient *client);
-void nm_client_networking_set_enabled (NMClient *client, gboolean enabled);
-
-gboolean nm_client_wireless_get_enabled (NMClient *client);
-void nm_client_wireless_set_enabled (NMClient *client, gboolean enabled);
-gboolean nm_client_wireless_hardware_get_enabled (NMClient *client);
-
-gboolean nm_client_wwan_get_enabled (NMClient *client);
-void nm_client_wwan_set_enabled (NMClient *client, gboolean enabled);
-gboolean nm_client_wwan_hardware_get_enabled (NMClient *client);
-
-gboolean nm_client_wimax_get_enabled (NMClient *client);
-void nm_client_wimax_set_enabled (NMClient *client, gboolean enabled);
-gboolean nm_client_wimax_hardware_get_enabled (NMClient *client);
-
-const char *nm_client_get_version (NMClient *client);
-NMState nm_client_get_state (NMClient *client);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_client_get_startup (NMClient *client);
-gboolean nm_client_get_manager_running (NMClient *client);
-const GPtrArray *nm_client_get_active_connections (NMClient *client);
-void nm_client_sleep (NMClient *client, gboolean sleep_);
-
-NMClientPermissionResult nm_client_get_permission_result (NMClient *client,
- NMClientPermission permission);
-
-gboolean nm_client_get_logging (NMClient *client, char **level, char **domains, GError **error);
-gboolean nm_client_set_logging (NMClient *client, const char *level, const char *domains, GError **error);
-
-NMConnectivityState nm_client_get_connectivity (NMClient *client);
-
-NMConnectivityState nm_client_check_connectivity (NMClient *client,
- GCancellable *cancellable,
- GError **error);
-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);
-
-NMActiveConnection *nm_client_get_primary_connection (NMClient *client);
-NMActiveConnection *nm_client_get_activating_connection (NMClient *client);
-
-G_END_DECLS
-
-#endif /* NM_CLIENT_H */
diff --git a/libnm-glib/nm-dbus-helpers-private.h b/libnm-glib/nm-dbus-helpers-private.h
deleted file mode 100644
index 1d98e77d9d..0000000000
--- a/libnm-glib/nm-dbus-helpers-private.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#ifndef NM_DBUS_HELPERS_PRIVATE_H
-#define NM_DBUS_HELPERS_PRIVATE_H
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-DBusGConnection *_nm_dbus_new_connection (GError **error);
-
-DBusGProxy * _nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
- const char *path,
- const char *interface);
-
-#endif /* NM_DBUS_HELPERS_PRIVATE_H */
diff --git a/libnm-glib/nm-dbus-helpers.c b/libnm-glib/nm-dbus-helpers.c
deleted file mode 100644
index 539dabb970..0000000000
--- a/libnm-glib/nm-dbus-helpers.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "nm-dbus-helpers-private.h"
-#include "NetworkManager.h"
-
-DBusGConnection *
-_nm_dbus_new_connection (GError **error)
-{
- DBusGConnection *connection = NULL;
-
- if (connection == NULL)
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, error);
-
- return connection;
-}
-
-DBusGProxy *
-_nm_dbus_new_proxy_for_connection (DBusGConnection *connection,
- const char *path,
- const char *interface)
-{
- return dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, path, interface);
-}
diff --git a/libnm-glib/nm-device-adsl.c b/libnm-glib/nm-device-adsl.c
deleted file mode 100644
index 30f6c4ec16..0000000000
--- a/libnm-glib/nm-device-adsl.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * author: Pantelis Koukousoulas <pktoss@gmail.com>
- * Copyright 2009 - 2011 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-device-adsl.h"
-
-#include <string.h>
-
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-
-#include "nm-setting-adsl.h"
-
-G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ADSL, NMDeviceAdslPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- gboolean carrier;
-
- gboolean disposed;
-} NMDeviceAdslPrivate;
-
-enum {
- PROP_0,
- PROP_CARRIER,
- LAST_PROP
-};
-
-/**
- * nm_device_adsl_error_quark:
- *
- * Registers an error quark for #NMDeviceAdsl if necessary.
- *
- * Returns: the error quark used for #NMDeviceAdsl errors.
- **/
-GQuark
-nm_device_adsl_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-adsl-error-quark");
- return quark;
-}
-
-/**
- * nm_device_adsl_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceAdsl.
- *
- * Returns: (transfer full): a new device
- **/
-GObject *
-nm_device_adsl_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_ADSL,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_adsl_get_carrier:
- * @device: a #NMDeviceAdsl
- *
- * Whether the device has carrier.
- *
- * Returns: %TRUE if the device has carrier
- **/
-gboolean
-nm_device_adsl_get_carrier (NMDeviceAdsl *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_ADSL (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_ADSL_GET_PRIVATE (device)->carrier;
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingAdsl *s_adsl;
- const char *ctype;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_ADSL_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_ADSL_ERROR, NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION,
- "The connection was not an ADSL connection.");
- return FALSE;
- }
-
- s_adsl = nm_connection_get_setting_adsl (connection);
- if (!s_adsl) {
- g_set_error (error, NM_DEVICE_ADSL_ERROR, NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION,
- "The connection was not a valid ADSL connection.");
- return FALSE;
- }
-
- return NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_ADSL;
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_adsl_init (NMDeviceAdsl *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_ADSL);
-}
-
-static void
-register_properties (NMDeviceAdsl *device)
-{
- NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_ADSL_CARRIER, &priv->carrier },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_adsl_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_ADSL);
- register_properties (NM_DEVICE_ADSL (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (object);
-
- if (priv->disposed) {
- G_OBJECT_CLASS (nm_device_adsl_parent_class)->dispose (object);
- return;
- }
-
- priv->disposed = TRUE;
-
- g_object_unref (priv->proxy);
-
- G_OBJECT_CLASS (nm_device_adsl_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- G_OBJECT_CLASS (nm_device_adsl_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceAdsl *device = NM_DEVICE_ADSL (object);
-
- switch (prop_id) {
- case PROP_CARRIER:
- g_value_set_boolean (value, nm_device_adsl_get_carrier (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_adsl_class_init (NMDeviceAdslClass *adsl_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (adsl_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (adsl_class);
-
- g_type_class_add_private (object_class, sizeof (NMDeviceAdslPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
-
- /* properties */
- /**
- * NMDeviceAdsl:carrier:
- *
- * Whether the device has carrier.
- **/
- g_object_class_install_property
- (object_class, PROP_CARRIER,
- g_param_spec_boolean (NM_DEVICE_ADSL_CARRIER, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-device-adsl.h b/libnm-glib/nm-device-adsl.h
deleted file mode 100644
index 35d2731a2c..0000000000
--- a/libnm-glib/nm-device-adsl.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 Pantelis Koukousoulas <pktoss@gmail.com>
- */
-
-#ifndef NM_DEVICE_ADSL_H
-#define NM_DEVICE_ADSL_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_ADSL (nm_device_adsl_get_type ())
-#define NM_DEVICE_ADSL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_ADSL, NMDeviceAdsl))
-#define NM_DEVICE_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_ADSL, NMDeviceAdslClass))
-#define NM_IS_DEVICE_ADSL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_ADSL))
-#define NM_IS_DEVICE_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_ADSL))
-#define NM_DEVICE_ADSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ADSL, NMDeviceAdslClass))
-
-/**
- * NMDeviceAdslError:
- * @NM_DEVICE_ADSL_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION: the connection was not of ADSL type
- * @NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION: the ADSL connection was invalid
- */
-typedef enum {
- NM_DEVICE_ADSL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION, /*< nick=NotAdslConnection >*/
- NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION, /*< nick=InvalidAdslConnection >*/
-} NMDeviceAdslError;
-
-#define NM_DEVICE_ADSL_ERROR nm_device_adsl_error_quark ()
-GQuark nm_device_adsl_error_quark (void);
-
-#define NM_DEVICE_ADSL_CARRIER "carrier"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceAdsl;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceAdslClass;
-
-GType nm_device_adsl_get_type (void);
-
-GObject *nm_device_adsl_new (DBusGConnection *connection, const char *path);
-gboolean nm_device_adsl_get_carrier (NMDeviceAdsl *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_ADSL_H */
diff --git a/libnm-glib/nm-device-bond.c b/libnm-glib/nm-device-bond.c
deleted file mode 100644
index a4f0f5014c..0000000000
--- a/libnm-glib/nm-device-bond.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-bond.h"
-#include "nm-utils.h"
-
-#include "nm-device-bond.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-#include "nm-types.h"
-
-G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BOND, NMDeviceBondPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- gboolean carrier;
- GPtrArray *slaves;
-} NMDeviceBondPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_CARRIER,
- PROP_SLAVES,
-
- LAST_PROP
-};
-
-/**
- * nm_device_bond_error_quark:
- *
- * Registers an error quark for #NMDeviceBond if necessary.
- *
- * Returns: the error quark used for #NMDeviceBond errors.
- **/
-GQuark
-nm_device_bond_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-bond-error-quark");
- return quark;
-}
-
-/**
- * nm_device_bond_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceBond.
- *
- * Returns: (transfer full): a new device
- **/
-GObject *
-nm_device_bond_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_BOND,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_bond_get_hw_address:
- * @device: a #NMDeviceBond
- *
- * Gets the hardware (MAC) address of the #NMDeviceBond
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_bond_get_hw_address (NMDeviceBond *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BOND (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_BOND_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_bond_get_carrier:
- * @device: a #NMDeviceBond
- *
- * Whether the device has carrier.
- *
- * Returns: %TRUE if the device has carrier
- **/
-gboolean
-nm_device_bond_get_carrier (NMDeviceBond *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_BOND_GET_PRIVATE (device)->carrier;
-}
-
-/**
- * nm_device_bond_get_slaves:
- * @device: a #NMDeviceBond
- *
- * Gets the devices currently enslaved to @device.
- *
- * Returns: (element-type NMDevice): the #GPtrArray containing
- * #NMDevices that are slaves of @device. This is the internal
- * copy used by the device, and must not be modified.
- *
- * Since: 0.9.6.4
- **/
-const GPtrArray *
-nm_device_bond_get_slaves (NMDeviceBond *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return handle_ptr_array_return (NM_DEVICE_BOND_GET_PRIVATE (device)->slaves);
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingBond *s_bond;
- const char *ctype, *dev_iface_name, *bond_iface_name;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_BOND_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION,
- "The connection was not a bond connection.");
- return FALSE;
- }
-
- s_bond = nm_connection_get_setting_bond (connection);
- if (!s_bond) {
- g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION,
- "The connection was not a valid bond connection.");
- return FALSE;
- }
-
- dev_iface_name = nm_device_get_iface (device);
- bond_iface_name = nm_setting_bond_get_interface_name (s_bond);
- if (g_strcmp0 (dev_iface_name, bond_iface_name) != 0) {
- g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH,
- "The interfaces of the device and the connection didn't match.");
- return FALSE;
- }
-
- /* FIXME: check slaves? */
-
- return NM_DEVICE_CLASS (nm_device_bond_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_BOND;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_bond_get_hw_address (NM_DEVICE_BOND (device));
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_bond_init (NMDeviceBond *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_BOND);
-}
-
-static void
-register_properties (NMDeviceBond *device)
-{
- NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_BOND_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_BOND_CARRIER, &priv->carrier },
- { NM_DEVICE_BOND_SLAVES, &priv->slaves, NULL, NM_TYPE_DEVICE },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_bond_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BOND);
- register_properties (NM_DEVICE_BOND (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- if (priv->slaves) {
- g_ptr_array_set_free_func (priv->slaves, g_object_unref);
- g_ptr_array_free (priv->slaves, TRUE);
- priv->slaves = NULL;
- }
-
- G_OBJECT_CLASS (nm_device_bond_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
-
- G_OBJECT_CLASS (nm_device_bond_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceBond *device = NM_DEVICE_BOND (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_bond_get_hw_address (device));
- break;
- case PROP_CARRIER:
- g_value_set_boolean (value, nm_device_bond_get_carrier (device));
- break;
- case PROP_SLAVES:
- g_value_set_boxed (value, nm_device_bond_get_slaves (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_bond_class_init (NMDeviceBondClass *bond_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (bond_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (bond_class);
-
- g_type_class_add_private (bond_class, sizeof (NMDeviceBondPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
-
- /* properties */
-
- /**
- * NMDeviceBond:hw-address:
- *
- * The hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_BOND_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceBond:carrier:
- *
- * Whether the device has carrier.
- **/
- g_object_class_install_property
- (object_class, PROP_CARRIER,
- g_param_spec_boolean (NM_DEVICE_BOND_CARRIER, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceBond:slaves:
- *
- * The devices (#NMDevice) enslaved to the bond device.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_SLAVES,
- g_param_spec_boxed (NM_DEVICE_BOND_SLAVES, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-device-bond.h b/libnm-glib/nm-device-bond.h
deleted file mode 100644
index cd1a60271f..0000000000
--- a/libnm-glib/nm-device-bond.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_BOND_H
-#define NM_DEVICE_BOND_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_BOND (nm_device_bond_get_type ())
-#define NM_DEVICE_BOND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_BOND, NMDeviceBond))
-#define NM_DEVICE_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_BOND, NMDeviceBondClass))
-#define NM_IS_DEVICE_BOND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_BOND))
-#define NM_IS_DEVICE_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BOND))
-#define NM_DEVICE_BOND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BOND, NMDeviceBondClass))
-
-/**
- * NMDeviceBondError:
- * @NM_DEVICE_BOND_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION: the connection was not of bond type
- * @NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION: the bond connection was invalid
- * @NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched
- */
-typedef enum {
- NM_DEVICE_BOND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION, /*< nick=NotBondConnection >*/
- NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION, /*< nick=InvalidBondConnection >*/
- NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
-} NMDeviceBondError;
-
-#define NM_DEVICE_BOND_ERROR nm_device_bond_error_quark ()
-GQuark nm_device_bond_error_quark (void);
-
-#define NM_DEVICE_BOND_HW_ADDRESS "hw-address"
-#define NM_DEVICE_BOND_CARRIER "carrier"
-#define NM_DEVICE_BOND_SLAVES "slaves"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceBond;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceBondClass;
-
-GType nm_device_bond_get_type (void);
-
-GObject *nm_device_bond_new (DBusGConnection *connection, const char *path);
-
-const char *nm_device_bond_get_hw_address (NMDeviceBond *device);
-gboolean nm_device_bond_get_carrier (NMDeviceBond *device);
-const GPtrArray *nm_device_bond_get_slaves (NMDeviceBond *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_BOND_H */
diff --git a/libnm-glib/nm-device-bridge.c b/libnm-glib/nm-device-bridge.c
deleted file mode 100644
index d5a2bbbcc7..0000000000
--- a/libnm-glib/nm-device-bridge.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-bridge.h"
-#include "nm-utils.h"
-
-#include "nm-device-bridge.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-#include "nm-types.h"
-
-G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgePrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- gboolean carrier;
- GPtrArray *slaves;
-} NMDeviceBridgePrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_CARRIER,
- PROP_SLAVES,
-
- LAST_PROP
-};
-
-/**
- * nm_device_bridge_error_quark:
- *
- * Registers an error quark for #NMDeviceBridge if necessary.
- *
- * Returns: the error quark used for #NMDeviceBridge errors.
- *
- * Since: 0.9.8
- **/
-GQuark
-nm_device_bridge_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-bridge-error-quark");
- return quark;
-}
-
-/**
- * nm_device_bridge_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceBridge.
- *
- * Returns: (transfer full): a new device
- *
- * Since: 0.9.8
- **/
-GObject *
-nm_device_bridge_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_BRIDGE,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_bridge_get_hw_address:
- * @device: a #NMDeviceBridge
- *
- * Gets the hardware (MAC) address of the #NMDeviceBridge
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- *
- * Since: 0.9.8
- **/
-const char *
-nm_device_bridge_get_hw_address (NMDeviceBridge *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_bridge_get_carrier:
- * @device: a #NMDeviceBridge
- *
- * Whether the device has carrier.
- *
- * Returns: %TRUE if the device has carrier
- *
- * Since: 0.9.8
- **/
-gboolean
-nm_device_bridge_get_carrier (NMDeviceBridge *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->carrier;
-}
-
-/**
- * nm_device_bridge_get_slaves:
- * @device: a #NMDeviceBridge
- *
- * Gets the devices currently enslaved to @device.
- *
- * Returns: (element-type NMDevice): the #GPtrArray containing
- * #NMDevices that are slaves of @device. This is the internal
- * copy used by the device, and must not be modified.
- *
- * Since: 0.9.8
- **/
-const GPtrArray *
-nm_device_bridge_get_slaves (NMDeviceBridge *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return handle_ptr_array_return (NM_DEVICE_BRIDGE_GET_PRIVATE (device)->slaves);
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingBridge *s_bridge;
- const char *ctype, *dev_iface_name, *bridge_iface_name;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_BRIDGE_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION,
- "The connection was not a bridge connection.");
- return FALSE;
- }
-
- s_bridge = nm_connection_get_setting_bridge (connection);
- if (!s_bridge) {
- g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION,
- "The connection was not a valid bridge connection.");
- return FALSE;
- }
-
- dev_iface_name = nm_device_get_iface (device);
- bridge_iface_name = nm_setting_bridge_get_interface_name (s_bridge);
- if (g_strcmp0 (dev_iface_name, bridge_iface_name) != 0) {
- g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH,
- "The interfaces of the device and the connection didn't match.");
- return FALSE;
- }
-
- /* FIXME: check ports? */
-
- return NM_DEVICE_CLASS (nm_device_bridge_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_BRIDGE;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_bridge_get_hw_address (NM_DEVICE_BRIDGE (device));
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_bridge_init (NMDeviceBridge *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_BRIDGE);
-}
-
-static void
-register_properties (NMDeviceBridge *device)
-{
- NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_BRIDGE_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_BRIDGE_CARRIER, &priv->carrier },
- { NM_DEVICE_BRIDGE_SLAVES, &priv->slaves, NULL, NM_TYPE_DEVICE },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_bridge_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BRIDGE);
- register_properties (NM_DEVICE_BRIDGE (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- if (priv->slaves) {
- g_ptr_array_set_free_func (priv->slaves, g_object_unref);
- g_ptr_array_free (priv->slaves, TRUE);
- priv->slaves = NULL;
- }
-
- G_OBJECT_CLASS (nm_device_bridge_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
-
- G_OBJECT_CLASS (nm_device_bridge_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceBridge *device = NM_DEVICE_BRIDGE (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_bridge_get_hw_address (device));
- break;
- case PROP_CARRIER:
- g_value_set_boolean (value, nm_device_bridge_get_carrier (device));
- break;
- case PROP_SLAVES:
- g_value_set_boxed (value, nm_device_bridge_get_slaves (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (bridge_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (bridge_class);
-
- g_type_class_add_private (bridge_class, sizeof (NMDeviceBridgePrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
-
- /* properties */
-
- /**
- * NMDeviceBridge:hw-address:
- *
- * The hardware (MAC) address of the device.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_BRIDGE_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceBridge:carrier:
- *
- * Whether the device has carrier.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_CARRIER,
- g_param_spec_boolean (NM_DEVICE_BRIDGE_CARRIER, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceBridge:slaves:
- *
- * The devices (#NMDevice) enslaved to the bridge device.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_SLAVES,
- g_param_spec_boxed (NM_DEVICE_BRIDGE_SLAVES, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-device-bridge.h b/libnm-glib/nm-device-bridge.h
deleted file mode 100644
index 2eaf475d8c..0000000000
--- a/libnm-glib/nm-device-bridge.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_BRIDGE_H
-#define NM_DEVICE_BRIDGE_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_BRIDGE (nm_device_bridge_get_type ())
-#define NM_DEVICE_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridge))
-#define NM_DEVICE_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgeClass))
-#define NM_IS_DEVICE_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_BRIDGE))
-#define NM_IS_DEVICE_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BRIDGE))
-#define NM_DEVICE_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgeClass))
-
-/**
- * NMDeviceBridgeError:
- * @NM_DEVICE_BRIDGE_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION: the connection was not of bridge type
- * @NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION: the bridge connection was invalid
- * @NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched
- *
- * Since: 0.9.8
- */
-typedef enum {
- NM_DEVICE_BRIDGE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION, /*< nick=NotBridgeConnection >*/
- NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION, /*< nick=InvalidBridgeConnection >*/
- NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
-} NMDeviceBridgeError;
-
-#define NM_DEVICE_BRIDGE_ERROR nm_device_bridge_error_quark ()
-GQuark nm_device_bridge_error_quark (void);
-
-#define NM_DEVICE_BRIDGE_HW_ADDRESS "hw-address"
-#define NM_DEVICE_BRIDGE_CARRIER "carrier"
-#define NM_DEVICE_BRIDGE_SLAVES "slaves"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceBridge;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceBridgeClass;
-
-GType nm_device_bridge_get_type (void);
-
-GObject * nm_device_bridge_new (DBusGConnection *connection, const char *path);
-
-const char *nm_device_bridge_get_hw_address (NMDeviceBridge *device);
-gboolean nm_device_bridge_get_carrier (NMDeviceBridge *device);
-const GPtrArray *nm_device_bridge_get_slaves (NMDeviceBridge *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_BRIDGE_H */
diff --git a/libnm-glib/nm-device-bt.c b/libnm-glib/nm-device-bt.c
deleted file mode 100644
index 5cf55c576e..0000000000
--- a/libnm-glib/nm-device-bt.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-bluetooth.h"
-
-#include "nm-device-bt.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-
-G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_BT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BT, NMDeviceBtPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- char *name;
- guint32 bt_capabilities;
-} NMDeviceBtPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_NAME,
- PROP_BT_CAPABILITIES,
-
- LAST_PROP
-};
-
-/**
- * nm_device_bt_error_quark:
- *
- * Registers an error quark for #NMDeviceBt if necessary.
- *
- * Returns: the error quark used for #NMDeviceBt errors.
- **/
-GQuark
-nm_device_bt_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-bt-error-quark");
- return quark;
-}
-
-/**
- * nm_device_bt_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceBt.
- *
- * Returns: (transfer full): a new device
- **/
-GObject *
-nm_device_bt_new (DBusGConnection *connection, const char *path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- return g_object_new (NM_TYPE_DEVICE_BT,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
-}
-
-/**
- * nm_device_bt_get_hw_address:
- * @device: a #NMDeviceBt
- *
- * Gets the hardware (MAC) address of the #NMDeviceBt
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_bt_get_hw_address (NMDeviceBt *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_BT_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_bt_get_name:
- * @device: a #NMDeviceBt
- *
- * Gets the name of the #NMDeviceBt.
- *
- * Returns: the name of the device
- **/
-const char *
-nm_device_bt_get_name (NMDeviceBt *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_BT_GET_PRIVATE (device)->name;
-}
-
-/**
- * nm_device_bt_get_capabilities:
- * @device: a #NMDeviceBt
- *
- * Returns the Bluetooth device's usable capabilities.
- *
- * Returns: a combination of #NMBluetoothCapabilities
- **/
-NMBluetoothCapabilities
-nm_device_bt_get_capabilities (NMDeviceBt *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_BT (device), NM_BT_CAPABILITY_NONE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_BT_GET_PRIVATE (device)->bt_capabilities;
-}
-
-static NMBluetoothCapabilities
-get_connection_bt_type (NMConnection *connection)
-{
- NMSettingBluetooth *s_bt;
- const char *bt_type;
-
- s_bt = nm_connection_get_setting_bluetooth (connection);
- if (!s_bt)
- return NM_BT_CAPABILITY_NONE;
-
- bt_type = nm_setting_bluetooth_get_connection_type (s_bt);
- g_assert (bt_type);
-
- if (!strcmp (bt_type, NM_SETTING_BLUETOOTH_TYPE_DUN))
- return NM_BT_CAPABILITY_DUN;
- else if (!strcmp (bt_type, NM_SETTING_BLUETOOTH_TYPE_PANU))
- return NM_BT_CAPABILITY_NAP;
-
- return NM_BT_CAPABILITY_NONE;
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingBluetooth *s_bt;
- const char *ctype;
- const GByteArray *mac;
- const char *hw_str;
- struct ether_addr *hw_mac;
- NMBluetoothCapabilities dev_caps;
- NMBluetoothCapabilities bt_type;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_BLUETOOTH_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION,
- "The connection was not a Bluetooth connection.");
- return FALSE;
- }
-
- s_bt = nm_connection_get_setting_bluetooth (connection);
- if (!s_bt) {
- g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION,
- "The connection was not a valid Bluetooth connection.");
- return FALSE;
- }
-
- /* Check BT address */
- hw_str = nm_device_bt_get_hw_address (NM_DEVICE_BT (device));
- if (hw_str) {
- hw_mac = ether_aton (hw_str);
- if (!hw_mac) {
- g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC,
- "Invalid device MAC address.");
- return FALSE;
- }
- mac = nm_setting_bluetooth_get_bdaddr (s_bt);
- if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) {
- g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_MAC_MISMATCH,
- "The MACs of the device and the connection didn't match.");
- return FALSE;
- }
- }
-
- dev_caps = nm_device_bt_get_capabilities (NM_DEVICE_BT (device));
- bt_type = get_connection_bt_type (connection);
- if (!(bt_type & dev_caps)) {
- g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS,
- "The device missed BT capabilities required by the connection.");
- return FALSE;
- }
-
- return NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_BLUETOOTH;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_bt_get_hw_address (NM_DEVICE_BT (device));
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_bt_init (NMDeviceBt *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_BT);
-}
-
-static void
-register_properties (NMDeviceBt *device)
-{
- NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_BT_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_BT_NAME, &priv->name },
- { NM_DEVICE_BT_CAPABILITIES, &priv->bt_capabilities },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_bt_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BLUETOOTH);
- register_properties (NM_DEVICE_BT (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_bt_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
- g_free (priv->name);
-
- G_OBJECT_CLASS (nm_device_bt_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceBt *device = NM_DEVICE_BT (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_bt_get_hw_address (device));
- break;
- case PROP_NAME:
- g_value_set_string (value, nm_device_bt_get_name (device));
- break;
- case PROP_BT_CAPABILITIES:
- g_value_set_uint (value, nm_device_bt_get_capabilities (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_bt_class_init (NMDeviceBtClass *bt_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (bt_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (bt_class);
-
- g_type_class_add_private (bt_class, sizeof (NMDeviceBtPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
-
- /* properties */
-
- /**
- * NMDeviceBt:hw-address:
- *
- * The hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_BT_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceBt:name:
- *
- * The name of the bluetooth device.
- **/
- g_object_class_install_property
- (object_class, PROP_NAME,
- g_param_spec_string (NM_DEVICE_BT_NAME, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceBt:bt-capabilities:
- *
- * The device's bluetooth capabilities, a combination of #NMBluetoothCapabilities.
- **/
- g_object_class_install_property
- (object_class, PROP_BT_CAPABILITIES,
- g_param_spec_uint (NM_DEVICE_BT_CAPABILITIES, "", "",
- NM_BT_CAPABILITY_NONE, G_MAXUINT32, NM_BT_CAPABILITY_NONE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
-}
diff --git a/libnm-glib/nm-device-bt.h b/libnm-glib/nm-device-bt.h
deleted file mode 100644
index 51dc86e39e..0000000000
--- a/libnm-glib/nm-device-bt.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2012 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#ifndef NM_DEVICE_BT_H
-#define NM_DEVICE_BT_H
-
-#include "NetworkManager.h"
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_BT (nm_device_bt_get_type ())
-#define NM_DEVICE_BT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_BT, NMDeviceBt))
-#define NM_DEVICE_BT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_BT, NMDeviceBtClass))
-#define NM_IS_DEVICE_BT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_BT))
-#define NM_IS_DEVICE_BT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BT))
-#define NM_DEVICE_BT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BT, NMDeviceBtClass))
-
-/**
- * NMDeviceBtError:
- * @NM_DEVICE_BT_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION: the connection was not of bluetooth type
- * @NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION: the bluetooth connection was invalid
- * @NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
- * @NM_DEVICE_BT_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
- * @NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS: the device missed required capabilities
- */
-typedef enum {
- NM_DEVICE_BT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION, /*< nick=NotBtConnection >*/
- NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION, /*< nick=InvalidBtConnection >*/
- NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
- NM_DEVICE_BT_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
- NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS, /*< nick=MissingDeviceCaps >*/
-} NMDeviceBtError;
-
-#define NM_DEVICE_BT_ERROR nm_device_bt_error_quark ()
-GQuark nm_device_bt_error_quark (void);
-
-#define NM_DEVICE_BT_HW_ADDRESS "hw-address"
-#define NM_DEVICE_BT_NAME "name"
-#define NM_DEVICE_BT_CAPABILITIES "bt-capabilities"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceBt;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceBtClass;
-
-GType nm_device_bt_get_type (void);
-
-GObject *nm_device_bt_new (DBusGConnection *connection, const char *path);
-
-const char *nm_device_bt_get_hw_address (NMDeviceBt *device);
-
-const char *nm_device_bt_get_name (NMDeviceBt *device);
-
-NMBluetoothCapabilities nm_device_bt_get_capabilities (NMDeviceBt *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_BT_H */
diff --git a/libnm-glib/nm-device-ethernet.c b/libnm-glib/nm-device-ethernet.c
deleted file mode 100644
index df677b2922..0000000000
--- a/libnm-glib/nm-device-ethernet.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-wired.h"
-#include "nm-setting-pppoe.h"
-
-#include "nm-device-ethernet.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-
-G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_ETHERNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- char *perm_hw_address;
- guint32 speed;
- gboolean carrier;
-} NMDeviceEthernetPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_PERM_HW_ADDRESS,
- PROP_SPEED,
- PROP_CARRIER,
-
- LAST_PROP
-};
-
-/**
- * nm_device_ethernet_error_quark:
- *
- * Registers an error quark for #NMDeviceEthernet if necessary.
- *
- * Returns: the error quark used for #NMDeviceEthernet errors.
- **/
-GQuark
-nm_device_ethernet_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-ethernet-error-quark");
- return quark;
-}
-
-/**
- * nm_device_ethernet_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceEthernet.
- *
- * Returns: (transfer full): a new device
- **/
-GObject *
-nm_device_ethernet_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_ETHERNET,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_ethernet_get_hw_address:
- * @device: a #NMDeviceEthernet
- *
- * Gets the active hardware (MAC) address of the #NMDeviceEthernet
- *
- * Returns: the active hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_ethernet_get_hw_address (NMDeviceEthernet *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_ethernet_get_permanent_hw_address:
- * @device: a #NMDeviceEthernet
- *
- * Gets the permanent hardware (MAC) address of the #NMDeviceEthernet
- *
- * Returns: the permanent hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->perm_hw_address;
-}
-
-/**
- * nm_device_ethernet_get_speed:
- * @device: a #NMDeviceEthernet
- *
- * Gets the speed of the #NMDeviceEthernet in Mbit/s.
- *
- * Returns: the speed of the device in Mbit/s
- **/
-guint32
-nm_device_ethernet_get_speed (NMDeviceEthernet *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->speed;
-}
-
-/**
- * nm_device_ethernet_get_carrier:
- * @device: a #NMDeviceEthernet
- *
- * Whether the device has carrier.
- *
- * Returns: %TRUE if the device has carrier
- **/
-gboolean
-nm_device_ethernet_get_carrier (NMDeviceEthernet *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->carrier;
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingWired *s_wired;
- const char *ctype;
- gboolean is_pppoe = FALSE;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (!strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME))
- is_pppoe = TRUE;
- else if (strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION,
- "The connection was not a wired or PPPoE connection.");
- return FALSE;
- }
-
- s_wired = nm_connection_get_setting_wired (connection);
- /* Wired setting optional for PPPoE */
- if (!is_pppoe && !s_wired) {
- g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION,
- "The connection was not a valid Ethernet connection.");
- return FALSE;
- }
-
- if (s_wired) {
- const GByteArray *mac;
- const char *perm_str;
- struct ether_addr *perm_mac;
-
- /* FIXME: filter using s390 subchannels when they are exported over the bus */
-
- /* Check MAC address */
- perm_str = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device));
- if (perm_str) {
- perm_mac = ether_aton (perm_str);
- if (!perm_mac) {
- g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC,
- "Invalid device MAC address.");
- return FALSE;
- }
- mac = nm_setting_wired_get_mac_address (s_wired);
- if (mac && perm_mac && memcmp (mac->data, perm_mac->ether_addr_octet, ETH_ALEN)) {
- g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH,
- "The MACs of the device and the connection didn't match.");
- return FALSE;
- }
- }
- }
-
- return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_WIRED;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_ethernet_init (NMDeviceEthernet *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_ETHERNET);
-}
-
-static void
-register_properties (NMDeviceEthernet *device)
-{
- NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_ETHERNET_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS, &priv->perm_hw_address },
- { NM_DEVICE_ETHERNET_SPEED, &priv->speed },
- { NM_DEVICE_ETHERNET_CARRIER, &priv->carrier },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIRED);
- register_properties (NM_DEVICE_ETHERNET (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_ethernet_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
- g_free (priv->perm_hw_address);
-
- G_OBJECT_CLASS (nm_device_ethernet_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceEthernet *device = NM_DEVICE_ETHERNET (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_ethernet_get_hw_address (device));
- break;
- case PROP_PERM_HW_ADDRESS:
- g_value_set_string (value, nm_device_ethernet_get_permanent_hw_address (device));
- break;
- case PROP_SPEED:
- g_value_set_uint (value, nm_device_ethernet_get_speed (device));
- break;
- case PROP_CARRIER:
- g_value_set_boolean (value, nm_device_ethernet_get_carrier (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (eth_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class);
-
- g_type_class_add_private (eth_class, sizeof (NMDeviceEthernetPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
-
- /* properties */
-
- /**
- * NMDeviceEthernet:hw-address:
- *
- * The active hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_ETHERNET_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceEthernet:perm-hw-address:
- *
- * The permanent hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_PERM_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceEthernet:speed:
- *
- * The speed of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_SPEED,
- g_param_spec_uint (NM_DEVICE_ETHERNET_SPEED, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceEthernet:carrier:
- *
- * Whether the device has carrier.
- **/
- g_object_class_install_property
- (object_class, PROP_CARRIER,
- g_param_spec_boolean (NM_DEVICE_ETHERNET_CARRIER, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
-}
diff --git a/libnm-glib/nm-device-ethernet.h b/libnm-glib/nm-device-ethernet.h
deleted file mode 100644
index be289cdfcc..0000000000
--- a/libnm-glib/nm-device-ethernet.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_ETHERNET_H
-#define NM_DEVICE_ETHERNET_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_ETHERNET (nm_device_ethernet_get_type ())
-#define NM_DEVICE_ETHERNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernet))
-#define NM_DEVICE_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetClass))
-#define NM_IS_DEVICE_ETHERNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_ETHERNET))
-#define NM_IS_DEVICE_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_ETHERNET))
-#define NM_DEVICE_ETHERNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetClass))
-
-/**
- * NMDeviceEthernetError:
- * @NM_DEVICE_ETHERNET_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION: the connection was not of Ethernet or PPPoE type
- * @NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION: the Ethernet connection was invalid
- * @NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
- * @NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
- */
-typedef enum {
- NM_DEVICE_ETHERNET_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION, /*< nick=NotEthernetConnection >*/
- NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION, /*< nick=InvalidEthernetConnection >*/
- NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
- NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
-} NMDeviceEthernetError;
-
-#define NM_DEVICE_ETHERNET_ERROR nm_device_ethernet_error_quark ()
-GQuark nm_device_ethernet_error_quark (void);
-
-#define NM_DEVICE_ETHERNET_HW_ADDRESS "hw-address"
-#define NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS "perm-hw-address"
-#define NM_DEVICE_ETHERNET_SPEED "speed"
-#define NM_DEVICE_ETHERNET_CARRIER "carrier"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceEthernet;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceEthernetClass;
-
-GType nm_device_ethernet_get_type (void);
-
-GObject *nm_device_ethernet_new (DBusGConnection *connection, const char *path);
-
-const char * nm_device_ethernet_get_hw_address (NMDeviceEthernet *device);
-const char * nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device);
-guint32 nm_device_ethernet_get_speed (NMDeviceEthernet *device);
-gboolean nm_device_ethernet_get_carrier (NMDeviceEthernet *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_ETHERNET_H */
diff --git a/libnm-glib/nm-device-generic.c b/libnm-glib/nm-device-generic.c
deleted file mode 100644
index 206174fb16..0000000000
--- a/libnm-glib/nm-device-generic.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-device-generic.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-#include "nm-setting-generic.h"
-
-G_DEFINE_TYPE (NMDeviceGeneric, nm_device_generic, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_GENERIC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_GENERIC, NMDeviceGenericPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- char *type_description;
-} NMDeviceGenericPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_TYPE_DESCRIPTION,
-
- LAST_PROP
-};
-
-/**
- * nm_device_generic_error_quark:
- *
- * Registers an error quark for #NMDeviceGeneric if necessary.
- *
- * Returns: the error quark used for #NMDeviceGeneric errors.
- *
- * Since: 0.9.10
- **/
-GQuark
-nm_device_generic_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-generic-error-quark");
- return quark;
-}
-
-/**
- * nm_device_generic_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceGeneric.
- *
- * Returns: (transfer full): a new device
- *
- * Since: 0.9.10
- **/
-GObject *
-nm_device_generic_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_GENERIC,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_generic_get_hw_address:
- * @device: a #NMDeviceGeneric
- *
- * Gets the hardware address of the #NMDeviceGeneric
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_device_generic_get_hw_address (NMDeviceGeneric *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_GENERIC (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GENERIC_GET_PRIVATE (device)->hw_address;
-}
-
-/*****************************************************************************/
-
-static const char *
-get_type_description (NMDevice *device)
-{
- NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return priv->type_description;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_generic_get_hw_address (NM_DEVICE_GENERIC (device));
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- const char *ctype, *iface_name;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_GENERIC_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_GENERIC_ERROR, NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION,
- "The connection was not a generic connection.");
- return FALSE;
- }
-
- iface_name = nm_setting_connection_get_interface_name (s_con);
- if (!iface_name) {
- g_set_error (error, NM_DEVICE_GENERIC_ERROR, NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME,
- "The connection did not specify an interface name.");
- return FALSE;
- }
-
- return NM_DEVICE_CLASS (nm_device_generic_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_GENERIC;
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_generic_init (NMDeviceGeneric *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_GENERIC);
-}
-
-static void
-register_properties (NMDeviceGeneric *device)
-{
- NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_GENERIC_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_GENERIC_TYPE_DESCRIPTION, &priv->type_description },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static const char *
-_device_type_to_interface (NMDeviceType type)
-{
- switch (type) {
- case NM_DEVICE_TYPE_GENERIC:
- return NM_DBUS_INTERFACE_DEVICE_GENERIC;
- case NM_DEVICE_TYPE_TUN:
- return NM_DBUS_INTERFACE_DEVICE_TUN;
- default:
- return NULL;
- }
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object);
- NMDeviceType type;
- DBusGConnection *connection;
- const char *path, *interface;
-
- G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object);
-
- g_object_get (object,
- NM_OBJECT_DBUS_CONNECTION, &connection,
- NM_OBJECT_DBUS_PATH, &path,
- NULL);
-
- type = _nm_device_type_for_path (connection, path);
- interface = _device_type_to_interface (type);
-
- if (interface) {
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, interface);
- register_properties (NM_DEVICE_GENERIC (object));
- }
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_generic_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
- g_free (priv->type_description);
-
- G_OBJECT_CLASS (nm_device_generic_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, priv->hw_address);
- break;
- case PROP_TYPE_DESCRIPTION:
- g_value_set_string (value, priv->type_description);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_generic_class_init (NMDeviceGenericClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (NMDeviceGenericPrivate));
-
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
-
- device_class->get_type_description = get_type_description;
- device_class->get_hw_address = get_hw_address;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
-
- /**
- * NMDeviceGeneric:hw-address:
- *
- * The hardware address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_GENERIC_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceGeneric:type-description:
- *
- * A description of the specific type of device this is, or %NULL
- * if not known.
- **/
- g_object_class_install_property
- (object_class, PROP_TYPE_DESCRIPTION,
- g_param_spec_string (NM_DEVICE_GENERIC_TYPE_DESCRIPTION, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-device-generic.h b/libnm-glib/nm-device-generic.h
deleted file mode 100644
index 5bff1e3f55..0000000000
--- a/libnm-glib/nm-device-generic.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_GENERIC_H
-#define NM_DEVICE_GENERIC_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_GENERIC (nm_device_generic_get_type ())
-#define NM_DEVICE_GENERIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_GENERIC, NMDeviceGeneric))
-#define NM_DEVICE_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_GENERIC, NMDeviceGenericClass))
-#define NM_IS_DEVICE_GENERIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_GENERIC))
-#define NM_IS_DEVICE_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_GENERIC))
-#define NM_DEVICE_GENERIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_GENERIC, NMDeviceGenericClass))
-
-/**
- * NMDeviceGenericError:
- * @NM_DEVICE_GENERIC_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION: the connection was not of generic type
- * @NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME: the connection did not specify the interface name
- */
-typedef enum {
- NM_DEVICE_GENERIC_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION, /*< nick=NotGenericConnection >*/
- NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME, /*< nick=MissingInterfaceName >*/
-} NMDeviceGenericError;
-
-#define NM_DEVICE_GENERIC_ERROR nm_device_generic_error_quark ()
-GQuark nm_device_generic_error_quark (void);
-
-#define NM_DEVICE_GENERIC_HW_ADDRESS "hw-address"
-#define NM_DEVICE_GENERIC_TYPE_DESCRIPTION "type-description"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceGeneric;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceGenericClass;
-
-NM_AVAILABLE_IN_0_9_10
-GType nm_device_generic_get_type (void);
-
-NM_AVAILABLE_IN_0_9_10
-GObject *nm_device_generic_new (DBusGConnection *connection, const char *path);
-
-const char *nm_device_generic_get_hw_address (NMDeviceGeneric *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_GENERIC_H */
diff --git a/libnm-glib/nm-device-infiniband.c b/libnm-glib/nm-device-infiniband.c
deleted file mode 100644
index 5c4a8c8b9f..0000000000
--- a/libnm-glib/nm-device-infiniband.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <linux/if_infiniband.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-infiniband.h"
-#include "nm-utils.h"
-
-#include "nm-device-infiniband.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-
-G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- gboolean carrier;
-} NMDeviceInfinibandPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_CARRIER,
-
- LAST_PROP
-};
-
-/**
- * nm_device_infiniband_error_quark:
- *
- * Registers an error quark for #NMDeviceInfiniband if necessary.
- *
- * Returns: the error quark used for #NMDeviceInfiniband errors.
- **/
-GQuark
-nm_device_infiniband_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-infiniband-error-quark");
- return quark;
-}
-
-/**
- * nm_device_infiniband_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceInfiniband.
- *
- * Returns: (transfer full): a new device
- **/
-GObject *
-nm_device_infiniband_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_INFINIBAND,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_infiniband_get_hw_address:
- * @device: a #NMDeviceInfiniband
- *
- * Gets the hardware (MAC) address of the #NMDeviceInfiniband
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_infiniband_get_hw_address (NMDeviceInfiniband *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_infiniband_get_carrier:
- * @device: a #NMDeviceInfiniband
- *
- * Whether the device has carrier.
- *
- * Returns: %TRUE if the device has carrier
- **/
-gboolean
-nm_device_infiniband_get_carrier (NMDeviceInfiniband *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->carrier;
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingInfiniband *s_infiniband;
- const char *ctype, *hwaddr_str;
- const GByteArray *mac;
- guint8 *hwaddr, hwaddr_buf[INFINIBAND_ALEN];
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_INFINIBAND_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION,
- "The connection was not a InfiniBand connection.");
- return FALSE;
- }
-
- s_infiniband = nm_connection_get_setting_infiniband (connection);
- if (!s_infiniband) {
- g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION,
- "The connection was not a valid InfiniBand connection.");
- return FALSE;
- }
-
- hwaddr_str = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
- if (hwaddr_str) {
- hwaddr = nm_utils_hwaddr_aton (hwaddr_str, ARPHRD_INFINIBAND, hwaddr_buf);
- if (!hwaddr) {
- g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC,
- "Invalid device MAC address.");
- return FALSE;
- }
- mac = nm_setting_infiniband_get_mac_address (s_infiniband);
-
- /* We only match against the last 8 bytes */
- if (mac && hwaddr && memcmp (mac->data + INFINIBAND_ALEN - 8, hwaddr + INFINIBAND_ALEN - 8, 8)) {
- g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH,
- "The MACs of the device and the connection didn't match.");
- return FALSE;
- }
- }
-
- return NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_INFINIBAND;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_infiniband_init (NMDeviceInfiniband *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_INFINIBAND);
-}
-
-static void
-register_properties (NMDeviceInfiniband *device)
-{
- NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_INFINIBAND_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_INFINIBAND_CARRIER, &priv->carrier },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_infiniband_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_INFINIBAND);
- register_properties (NM_DEVICE_INFINIBAND (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_infiniband_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
-
- G_OBJECT_CLASS (nm_device_infiniband_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceInfiniband *device = NM_DEVICE_INFINIBAND (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_infiniband_get_hw_address (device));
- break;
- case PROP_CARRIER:
- g_value_set_boolean (value, nm_device_infiniband_get_carrier (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_infiniband_class_init (NMDeviceInfinibandClass *ib_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (ib_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (ib_class);
-
- g_type_class_add_private (ib_class, sizeof (NMDeviceInfinibandPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
-
- /* properties */
-
- /**
- * NMDeviceInfiniband:hw-address:
- *
- * The hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_INFINIBAND_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceInfiniband:carrier:
- *
- * Whether the device has carrier.
- **/
- g_object_class_install_property
- (object_class, PROP_CARRIER,
- g_param_spec_boolean (NM_DEVICE_INFINIBAND_CARRIER, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
-}
diff --git a/libnm-glib/nm-device-infiniband.h b/libnm-glib/nm-device-infiniband.h
deleted file mode 100644
index ba587d93b9..0000000000
--- a/libnm-glib/nm-device-infiniband.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2012 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_INFINIBAND_H
-#define NM_DEVICE_INFINIBAND_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_INFINIBAND (nm_device_infiniband_get_type ())
-#define NM_DEVICE_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfiniband))
-#define NM_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass))
-#define NM_IS_DEVICE_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_INFINIBAND))
-#define NM_IS_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_INFINIBAND))
-#define NM_DEVICE_INFINIBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass))
-
-/**
- * NMDeviceInfinibandError:
- * @NM_DEVICE_INFINIBAND_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION: the connection was not of InfiniBand type
- * @NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION: the InfiniBand connection was invalid
- * @NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
- * @NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
- */
-typedef enum {
- NM_DEVICE_INFINIBAND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION, /*< nick=NotInfinibandConnection >*/
- NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION, /*< nick=InvalidInfinibandConnection >*/
- NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
- NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
-} NMDeviceInfinibandError;
-
-#define NM_DEVICE_INFINIBAND_ERROR nm_device_infiniband_error_quark ()
-GQuark nm_device_infiniband_error_quark (void);
-
-#define NM_DEVICE_INFINIBAND_HW_ADDRESS "hw-address"
-#define NM_DEVICE_INFINIBAND_CARRIER "carrier"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceInfiniband;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceInfinibandClass;
-
-GType nm_device_infiniband_get_type (void);
-
-GObject *nm_device_infiniband_new (DBusGConnection *connection, const char *path);
-
-const char * nm_device_infiniband_get_hw_address (NMDeviceInfiniband *device);
-gboolean nm_device_infiniband_get_carrier (NMDeviceInfiniband *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_INFINIBAND_H */
diff --git a/libnm-glib/nm-device-modem.c b/libnm-glib/nm-device-modem.c
deleted file mode 100644
index d4c156178e..0000000000
--- a/libnm-glib/nm-device-modem.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2012 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-gsm.h"
-#include "nm-setting-cdma.h"
-
-#include "nm-device-modem.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-
-G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MODEM, NMDeviceModemPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- NMDeviceModemCapabilities caps;
- NMDeviceModemCapabilities current_caps;
-} NMDeviceModemPrivate;
-
-enum {
- PROP_0,
- PROP_MODEM_CAPS,
- PROP_CURRENT_CAPS,
- LAST_PROP
-};
-
-/**
- * nm_device_modem_error_quark:
- *
- * Registers an error quark for #NMDeviceModem if necessary.
- *
- * Returns: the error quark used for #NMDeviceModem errors.
- **/
-GQuark
-nm_device_modem_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-modem-error-quark");
- return quark;
-}
-
-/**
- * nm_device_modem_get_modem_capabilities:
- * @self: a #NMDeviceModem
- *
- * Returns a bitfield of the generic access technology families the modem
- * supports. Not all capabilities are available concurrently however; some
- * may require a firmware reload or reinitialization.
- *
- * Returns: the generic access technology families the modem supports
- **/
-NMDeviceModemCapabilities
-nm_device_modem_get_modem_capabilities (NMDeviceModem *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE);
-
- _nm_object_ensure_inited (NM_OBJECT (self));
- return NM_DEVICE_MODEM_GET_PRIVATE (self)->caps;
-}
-
-/**
- * nm_device_modem_get_current_capabilities:
- * @self: a #NMDeviceModem
- *
- * Returns a bitfield of the generic access technology families the modem
- * supports without a firmware reload or reinitialization. This value
- * represents the network types the modem can immediately connect to.
- *
- * Returns: the generic access technology families the modem supports without
- * a firmware reload or other reinitialization
- **/
-NMDeviceModemCapabilities
-nm_device_modem_get_current_capabilities (NMDeviceModem *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE);
-
- _nm_object_ensure_inited (NM_OBJECT (self));
- return NM_DEVICE_MODEM_GET_PRIVATE (self)->current_caps;
-}
-
-static const char *
-get_type_description (NMDevice *device)
-{
- NMDeviceModemCapabilities caps;
-
- caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
- if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
- return "gsm";
- else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
- return "cdma";
- else
- return NULL;
-}
-
-#define MODEM_CAPS_3GPP(caps) (caps & (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | \
- NM_DEVICE_MODEM_CAPABILITY_LTE))
-
-#define MODEM_CAPS_3GPP2(caps) (caps & (NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO))
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingGsm *s_gsm;
- NMSettingCdma *s_cdma;
- const char *ctype;
- NMDeviceModemCapabilities current_caps;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if ( strcmp (ctype, NM_SETTING_GSM_SETTING_NAME) != 0
- && strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION,
- "The connection was not a modem connection.");
- return FALSE;
- }
-
- s_gsm = nm_connection_get_setting_gsm (connection);
- s_cdma = nm_connection_get_setting_cdma (connection);
- if (!s_cdma && !s_gsm) {
- g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION,
- "The connection was not a valid modem connection.");
- return FALSE;
- }
-
- current_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
- if (!(s_gsm && MODEM_CAPS_3GPP (current_caps)) && !(s_cdma && MODEM_CAPS_3GPP2 (current_caps))) {
- g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS,
- "The device missed capabilities required by the GSM/CDMA connection.");
- return FALSE;
- }
-
- return NM_DEVICE_CLASS (nm_device_modem_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- NMDeviceModemCapabilities caps;
-
- caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
- if (caps & (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_LTE))
- return NM_TYPE_SETTING_GSM;
- else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
- return NM_TYPE_SETTING_CDMA;
- else
- return G_TYPE_INVALID;
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_modem_init (NMDeviceModem *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_MODEM);
-}
-
-static void
-register_properties (NMDeviceModem *device)
-{
- NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_MODEM_MODEM_CAPABILITIES, &priv->caps },
- { NM_DEVICE_MODEM_CURRENT_CAPABILITIES, &priv->current_caps },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_modem_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_MODEM);
- register_properties (NM_DEVICE_MODEM (object));
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceModem *self = NM_DEVICE_MODEM (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_MODEM_CAPS:
- g_value_set_uint (value, nm_device_modem_get_modem_capabilities (self));
- break;
- case PROP_CURRENT_CAPS:
- g_value_set_uint (value, nm_device_modem_get_current_capabilities (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object);
-}
-
-static void
-nm_device_modem_class_init (NMDeviceModemClass *modem_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (modem_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (modem_class);
-
- g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
-
- device_class->get_type_description = get_type_description;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
-
- /**
- * NMDeviceModem:modem-capabilities:
- *
- * The generic family of access technologies the modem supports. Not all
- * capabilities are available at the same time however; some modems require
- * a firmware reload or other reinitialization to switch between eg
- * CDMA/EVDO and GSM/UMTS.
- **/
- g_object_class_install_property
- (object_class, PROP_MODEM_CAPS,
- g_param_spec_uint (NM_DEVICE_MODEM_MODEM_CAPABILITIES, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceModem:current-capabilities:
- *
- * The generic family of access technologies the modem currently supports
- * without a firmware reload or reinitialization.
- **/
- g_object_class_install_property
- (object_class, PROP_CURRENT_CAPS,
- g_param_spec_uint (NM_DEVICE_MODEM_CURRENT_CAPABILITIES, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-device-modem.h b/libnm-glib/nm-device-modem.h
deleted file mode 100644
index 226cd04695..0000000000
--- a/libnm-glib/nm-device-modem.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2012 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#ifndef NM_DEVICE_MODEM_H
-#define NM_DEVICE_MODEM_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_MODEM (nm_device_modem_get_type ())
-#define NM_DEVICE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModem))
-#define NM_DEVICE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass))
-#define NM_IS_DEVICE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_MODEM))
-#define NM_IS_DEVICE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_MODEM))
-#define NM_DEVICE_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass))
-
-/**
- * NMDeviceModemError:
- * @NM_DEVICE_MODEM_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION: the connection was not of modem type
- * @NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION: the modem connection was invalid
- * @NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS: the device missed required capabilities
- */
-typedef enum {
- NM_DEVICE_MODEM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION, /*< nick=NotModemConnection >*/
- NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION, /*< nick=InvalidModemConnection >*/
- NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS, /*< nick=MissingDeviceCaps >*/
-} NMDeviceModemError;
-
-#define NM_DEVICE_MODEM_ERROR nm_device_modem_error_quark ()
-GQuark nm_device_modem_error_quark (void);
-
-#define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities"
-#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceModem;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceModemClass;
-
-GType nm_device_modem_get_type (void);
-
-NMDeviceModemCapabilities nm_device_modem_get_modem_capabilities (NMDeviceModem *self);
-NMDeviceModemCapabilities nm_device_modem_get_current_capabilities (NMDeviceModem *self);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_MODEM_H */
diff --git a/libnm-glib/nm-device-olpc-mesh.c b/libnm-glib/nm-device-olpc-mesh.c
deleted file mode 100644
index df4fb4655e..0000000000
--- a/libnm-glib/nm-device-olpc-mesh.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-olpc-mesh.h"
-
-#include "nm-device-olpc-mesh.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-#include "nm-device-wifi.h"
-
-G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- NMDeviceWifi *companion;
- guint32 active_channel;
-} NMDeviceOlpcMeshPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_COMPANION,
- PROP_ACTIVE_CHANNEL,
-
- LAST_PROP
-};
-
-/**
- * nm_device_olpc_mesh_error_quark:
- *
- * Registers an error quark for #NMDeviceOlpcMesh if necessary.
- *
- * Returns: the error quark used for #NMDeviceOlpcMesh errors.
- **/
-GQuark
-nm_device_olpc_mesh_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-olpc-mesh-error-quark");
- return quark;
-}
-
-/**
- * nm_device_olpc_mesh_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceOlpcMesh.
- *
- * Returns: (transfer full): a new OlpcMesh device
- **/
-GObject *
-nm_device_olpc_mesh_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_OLPC_MESH,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_olpc_mesh_get_hw_address:
- * @device: a #NMDeviceOlpcMesh
- *
- * Gets the hardware (MAC) address of the #NMDeviceOlpcMesh
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_olpc_mesh_get_hw_address (NMDeviceOlpcMesh *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_olpc_mesh_get_companion:
- * @device: a #NMDeviceOlpcMesh
- *
- * Gets the companion device of the #NMDeviceOlpcMesh.
- *
- * Returns: (transfer none): the companion of the device of %NULL
- **/
-NMDeviceWifi *
-nm_device_olpc_mesh_get_companion (NMDeviceOlpcMesh *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->companion;
-}
-
-/**
- * nm_device_olpc_mesh_get_active_channel:
- * @device: a #NMDeviceOlpcMesh
- *
- * Returns the active channel of the #NMDeviceOlpcMesh device.
- *
- * Returns: active channel of the device
- **/
-guint32
-nm_device_olpc_mesh_get_active_channel (NMDeviceOlpcMesh *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->active_channel;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_olpc_mesh_get_hw_address (NM_DEVICE_OLPC_MESH (device));
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingOlpcMesh *s_olpc_mesh;
- const char *ctype;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_OLPC_MESH_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_OLPC_MESH_ERROR, NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION,
- "The connection was not a Olpc Mesh connection.");
- return FALSE;
- }
-
- s_olpc_mesh = nm_connection_get_setting_olpc_mesh (connection);
- if (!s_olpc_mesh) {
- g_set_error (error, NM_DEVICE_OLPC_MESH_ERROR, NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION,
- "The connection was not a valid Olpc Mesh connection.");
- return FALSE;
- }
-
- return NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_OLPC_MESH;
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_olpc_mesh_init (NMDeviceOlpcMesh *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_OLPC_MESH);
-}
-
-static void
-register_properties (NMDeviceOlpcMesh *device)
-{
- NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_OLPC_MESH_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_OLPC_MESH_COMPANION, &priv->companion, NULL, NM_TYPE_DEVICE_WIFI },
- { NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL, &priv->active_channel },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH);
- register_properties (NM_DEVICE_OLPC_MESH (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object);
-
- g_clear_object (&priv->companion);
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
-
- G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceOlpcMesh *device = NM_DEVICE_OLPC_MESH (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_olpc_mesh_get_hw_address (device));
- break;
- case PROP_COMPANION:
- g_value_set_object (value, nm_device_olpc_mesh_get_companion (device));
- break;
- case PROP_ACTIVE_CHANNEL:
- g_value_set_uint (value, nm_device_olpc_mesh_get_active_channel (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *olpc_mesh_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (olpc_mesh_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (olpc_mesh_class);
-
- g_type_class_add_private (olpc_mesh_class, sizeof (NMDeviceOlpcMeshPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
-
- /* properties */
-
- /**
- * NMDeviceOlpcMesh:hw-address:
- *
- * The hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_OLPC_MESH_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceOlpcMesh:companion:
- *
- * The companion device.
- **/
- g_object_class_install_property
- (object_class, PROP_COMPANION,
- g_param_spec_object (NM_DEVICE_OLPC_MESH_COMPANION, "", "",
- NM_TYPE_DEVICE_WIFI,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceOlpcMesh:active-channel:
- *
- * The device's active channel.
- **/
- g_object_class_install_property
- (object_class, PROP_ACTIVE_CHANNEL,
- g_param_spec_uint (NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
-}
diff --git a/libnm-glib/nm-device-olpc-mesh.h b/libnm-glib/nm-device-olpc-mesh.h
deleted file mode 100644
index fcef83bcd1..0000000000
--- a/libnm-glib/nm-device-olpc-mesh.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_OLPC_MESH_H
-#define NM_DEVICE_OLPC_MESH_H
-
-#include "nm-device.h"
-#include "nm-device-wifi.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_OLPC_MESH (nm_device_olpc_mesh_get_type ())
-#define NM_DEVICE_OLPC_MESH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMesh))
-#define NM_DEVICE_OLPC_MESH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshClass))
-#define NM_IS_DEVICE_OLPC_MESH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_OLPC_MESH))
-#define NM_IS_DEVICE_OLPC_MESH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OLPC_MESH))
-#define NM_DEVICE_OLPC_MESH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshClass))
-
-/**
- * NMDeviceOlpcMeshError:
- * @NM_DEVICE_OLPC_MESH_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION: the connection was not of Olpc Mesh type
- * @NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION: the Olpc Mesh connection was invalid
- */
-typedef enum {
- NM_DEVICE_OLPC_MESH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION, /*< nick=NotOlpcMeshConnection >*/
- NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION, /*< nick=InvalidOlpcMeshConnection >*/
-} NMDeviceOlpcMeshError;
-
-#define NM_DEVICE_OLPC_MESH_ERROR nm_device_olpc_mesh_error_quark ()
-GQuark nm_device_olpc_mesh_error_quark (void);
-
-#define NM_DEVICE_OLPC_MESH_HW_ADDRESS "hw-address"
-#define NM_DEVICE_OLPC_MESH_COMPANION "companion"
-#define NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL "active-channel"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceOlpcMesh;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceOlpcMeshClass;
-
-GType nm_device_olpc_mesh_get_type (void);
-
-GObject *nm_device_olpc_mesh_new (DBusGConnection *connection, const char *path);
-
-const char *nm_device_olpc_mesh_get_hw_address (NMDeviceOlpcMesh *device);
-NMDeviceWifi *nm_device_olpc_mesh_get_companion (NMDeviceOlpcMesh *device);
-guint32 nm_device_olpc_mesh_get_active_channel (NMDeviceOlpcMesh *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_OLPC_MESH_H */
diff --git a/libnm-glib/nm-device-private.h b/libnm-glib/nm-device-private.h
deleted file mode 100644
index 1a29c97d7b..0000000000
--- a/libnm-glib/nm-device-private.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_PRIVATE_H
-#define NM_DEVICE_PRIVATE_H
-
-void _nm_device_set_device_type (NMDevice *device, NMDeviceType dtype);
-NMDeviceType _nm_device_type_for_path (DBusGConnection *connection, const char *path);
-
-#endif /* NM_DEVICE_PRIVATE_H */
diff --git a/libnm-glib/nm-device-team.c b/libnm-glib/nm-device-team.c
deleted file mode 100644
index 2a12a73289..0000000000
--- a/libnm-glib/nm-device-team.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Jiri Pirko <jiri@resnulli.us>
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-team.h"
-#include "nm-utils.h"
-
-#include "nm-device-team.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-#include "nm-types.h"
-
-G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_TEAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_TEAM, NMDeviceTeamPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- gboolean carrier;
- GPtrArray *slaves;
-} NMDeviceTeamPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_CARRIER,
- PROP_SLAVES,
-
- LAST_PROP
-};
-
-/**
- * nm_device_team_error_quark:
- *
- * Registers an error quark for #NMDeviceTeam if necessary.
- *
- * Returns: the error quark used for #NMDeviceTeam errors.
- *
- * Since: 0.9.10
- **/
-GQuark
-nm_device_team_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-team-error-quark");
- return quark;
-}
-
-/**
- * nm_device_team_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceTeam.
- *
- * Returns: (transfer full): a new device
- *
- * Since: 0.9.10
- **/
-GObject *
-nm_device_team_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_TEAM,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_team_get_hw_address:
- * @device: a #NMDeviceTeam
- *
- * Gets the hardware (MAC) address of the #NMDeviceTeam
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_device_team_get_hw_address (NMDeviceTeam *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_TEAM_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_team_get_carrier:
- * @device: a #NMDeviceTeam
- *
- * Whether the device has carrier.
- *
- * Returns: %TRUE if the device has carrier
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_device_team_get_carrier (NMDeviceTeam *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_TEAM_GET_PRIVATE (device)->carrier;
-}
-
-/**
- * nm_device_team_get_slaves:
- * @device: a #NMDeviceTeam
- *
- * Gets the devices currently enslaved to @device.
- *
- * Returns: (element-type NMDevice): the #GPtrArray containing
- * #NMDevices that are slaves of @device. This is the internal
- * copy used by the device, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const GPtrArray *
-nm_device_team_get_slaves (NMDeviceTeam *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return handle_ptr_array_return (NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves);
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_team_get_hw_address (NM_DEVICE_TEAM (device));
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingTeam *s_team;
- const char *ctype, *dev_iface_name, *team_iface_name;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_TEAM_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION,
- "The connection was not a team connection.");
- return FALSE;
- }
-
- s_team = nm_connection_get_setting_team (connection);
- if (!s_team) {
- g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION,
- "The connection was not a valid team connection.");
- return FALSE;
- }
-
- dev_iface_name = nm_device_get_iface (device);
- team_iface_name = nm_setting_team_get_interface_name (s_team);
- if (g_strcmp0 (dev_iface_name, team_iface_name) != 0) {
- g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH,
- "The interfaces of the device and the connection didn't match.");
- return FALSE;
- }
-
- /* FIXME: check slaves? */
-
- return NM_DEVICE_CLASS (nm_device_team_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_TEAM;
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_team_init (NMDeviceTeam *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_TEAM);
-}
-
-static void
-register_properties (NMDeviceTeam *device)
-{
- NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_TEAM_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_TEAM_CARRIER, &priv->carrier },
- { NM_DEVICE_TEAM_SLAVES, &priv->slaves, NULL, NM_TYPE_DEVICE },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_team_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_TEAM);
- register_properties (NM_DEVICE_TEAM (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- if (priv->slaves) {
- g_ptr_array_set_free_func (priv->slaves, g_object_unref);
- g_ptr_array_free (priv->slaves, TRUE);
- priv->slaves = NULL;
- }
-
- G_OBJECT_CLASS (nm_device_team_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
-
- G_OBJECT_CLASS (nm_device_team_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceTeam *device = NM_DEVICE_TEAM (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_team_get_hw_address (device));
- break;
- case PROP_CARRIER:
- g_value_set_boolean (value, nm_device_team_get_carrier (device));
- break;
- case PROP_SLAVES:
- g_value_set_boxed (value, nm_device_team_get_slaves (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_team_class_init (NMDeviceTeamClass *team_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (team_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (team_class);
-
- g_type_class_add_private (team_class, sizeof (NMDeviceTeamPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
-
- /* properties */
-
- /**
- * NMDeviceTeam:hw-address:
- *
- * The hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_TEAM_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceTeam:carrier:
- *
- * Whether the device has carrier.
- **/
- g_object_class_install_property
- (object_class, PROP_CARRIER,
- g_param_spec_boolean (NM_DEVICE_TEAM_CARRIER, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceTeam:slaves:
- *
- * The devices (#NMDevice) enslaved to the team device.
- **/
- g_object_class_install_property
- (object_class, PROP_SLAVES,
- g_param_spec_boxed (NM_DEVICE_TEAM_SLAVES, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-device-team.h b/libnm-glib/nm-device-team.h
deleted file mode 100644
index 46e910bad1..0000000000
--- a/libnm-glib/nm-device-team.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Jiri Pirko <jiri@resnulli.us>
- */
-
-#ifndef NM_DEVICE_TEAM_H
-#define NM_DEVICE_TEAM_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_TEAM (nm_device_team_get_type ())
-#define NM_DEVICE_TEAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_TEAM, NMDeviceTeam))
-#define NM_DEVICE_TEAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_TEAM, NMDeviceTeamClass))
-#define NM_IS_DEVICE_TEAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_TEAM))
-#define NM_IS_DEVICE_TEAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_TEAM))
-#define NM_DEVICE_TEAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_TEAM, NMDeviceTeamClass))
-
-/**
- * NMDeviceTeamError:
- * @NM_DEVICE_TEAM_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION: the connection was not of team type
- * @NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION: the team connection was invalid
- * @NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched
- */
-typedef enum {
- NM_DEVICE_TEAM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION, /*< nick=NotTeamConnection >*/
- NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION, /*< nick=InvalidTeamConnection >*/
- NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
-} NMDeviceTeamError;
-
-#define NM_DEVICE_TEAM_ERROR nm_device_team_error_quark ()
-NM_AVAILABLE_IN_0_9_10
-GQuark nm_device_team_error_quark (void);
-
-#define NM_DEVICE_TEAM_HW_ADDRESS "hw-address"
-#define NM_DEVICE_TEAM_CARRIER "carrier"
-#define NM_DEVICE_TEAM_SLAVES "slaves"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceTeam;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceTeamClass;
-
-NM_AVAILABLE_IN_0_9_10
-GType nm_device_team_get_type (void);
-
-NM_AVAILABLE_IN_0_9_10
-GObject *nm_device_team_new (DBusGConnection *connection, const char *path);
-
-const char *nm_device_team_get_hw_address (NMDeviceTeam *device);
-gboolean nm_device_team_get_carrier (NMDeviceTeam *device);
-const GPtrArray *nm_device_team_get_slaves (NMDeviceTeam *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_TEAM_H */
diff --git a/libnm-glib/nm-device-vlan.c b/libnm-glib/nm-device-vlan.c
deleted file mode 100644
index 3f40ec567d..0000000000
--- a/libnm-glib/nm-device-vlan.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-vlan.h"
-#include "nm-utils.h"
-
-#include "nm-device-vlan.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-
-G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VLAN, NMDeviceVlanPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- gboolean carrier;
- NMDevice *parent;
- guint vlan_id;
-} NMDeviceVlanPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_CARRIER,
- PROP_PARENT,
- PROP_VLAN_ID,
-
- LAST_PROP
-};
-
-/**
- * nm_device_vlan_error_quark:
- *
- * Registers an error quark for #NMDeviceVlan if necessary.
- *
- * Returns: the error quark used for #NMDeviceVlan errors.
- **/
-GQuark
-nm_device_vlan_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-vlan-error-quark");
- return quark;
-}
-
-/**
- * nm_device_vlan_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceVlan.
- *
- * Returns: (transfer full): a new device
- **/
-GObject *
-nm_device_vlan_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_VLAN,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_vlan_get_hw_address:
- * @device: a #NMDeviceVlan
- *
- * Gets the hardware (MAC) address of the #NMDeviceVlan
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_vlan_get_hw_address (NMDeviceVlan *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_vlan_get_carrier:
- * @device: a #NMDeviceVlan
- *
- * Whether the device has carrier.
- *
- * Returns: %TRUE if the device has carrier
- **/
-gboolean
-nm_device_vlan_get_carrier (NMDeviceVlan *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_VLAN_GET_PRIVATE (device)->carrier;
-}
-
-/**
- * nm_device_vlan_get_parent:
- * @device: a #NMDeviceVlan
- *
- * Returns: (transfer none): the device's parent device
- *
- * Since: 1.0
- **/
-NMDevice *
-nm_device_vlan_get_parent (NMDeviceVlan *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_VLAN_GET_PRIVATE (device)->parent;
-}
-
-/**
- * nm_device_vlan_get_vlan_id:
- * @device: a #NMDeviceVlan
- *
- * Returns: the device's VLAN ID
- **/
-guint
-nm_device_vlan_get_vlan_id (NMDeviceVlan *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_VLAN_GET_PRIVATE (device)->vlan_id;
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingVlan *s_vlan;
- NMSettingWired *s_wired;
- const char *ctype, *dev_iface_name, *vlan_iface_name;
- const GByteArray *mac_address;
- char *mac_address_str;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_VLAN_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION,
- "The connection was not a VLAN connection.");
- return FALSE;
- }
-
- s_vlan = nm_connection_get_setting_vlan (connection);
- if (!s_vlan) {
- g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION,
- "The connection was not a valid VLAN connection.");
- return FALSE;
- }
-
- if (nm_setting_vlan_get_id (s_vlan) != nm_device_vlan_get_vlan_id (NM_DEVICE_VLAN (device))) {
- g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_ID_MISMATCH,
- "The VLAN identifiers of the device and the connection didn't match.");
- return FALSE;
- }
-
- dev_iface_name = nm_device_get_iface (device);
- vlan_iface_name = nm_setting_vlan_get_interface_name (s_vlan);
- if (vlan_iface_name && g_strcmp0 (dev_iface_name, vlan_iface_name) != 0) {
- g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH,
- "The interfaces of the device and the connection didn't match.");
- return FALSE;
- }
-
- s_wired = nm_connection_get_setting_wired (connection);
- if (s_wired)
- mac_address = nm_setting_wired_get_mac_address (s_wired);
- else
- mac_address = NULL;
- if (mac_address) {
- mac_address_str = nm_utils_hwaddr_ntoa_len (mac_address->data, mac_address->len);
- if (!g_strcmp0 (mac_address_str, NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address)) {
- g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_MAC_MISMATCH,
- "The hardware address of the device and the connection didn't match.");
- }
- g_free (mac_address_str);
- }
-
- return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_VLAN;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_vlan_get_hw_address (NM_DEVICE_VLAN (device));
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_vlan_init (NMDeviceVlan *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_VLAN);
-}
-
-static void
-register_properties (NMDeviceVlan *device)
-{
- NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_VLAN_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_VLAN_CARRIER, &priv->carrier },
- { NM_DEVICE_VLAN_PARENT, &priv->parent, NULL, NM_TYPE_DEVICE },
- { NM_DEVICE_VLAN_VLAN_ID, &priv->vlan_id },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_vlan_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_VLAN);
- register_properties (NM_DEVICE_VLAN (object));
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object);
-
- g_clear_object (&priv->parent);
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
-
- G_OBJECT_CLASS (nm_device_vlan_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceVlan *device = NM_DEVICE_VLAN (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_vlan_get_hw_address (device));
- break;
- case PROP_CARRIER:
- g_value_set_boolean (value, nm_device_vlan_get_carrier (device));
- break;
- case PROP_PARENT:
- g_value_set_object (value, nm_device_vlan_get_parent (device));
- break;
- case PROP_VLAN_ID:
- g_value_set_uint (value, nm_device_vlan_get_vlan_id (device));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_vlan_class_init (NMDeviceVlanClass *vlan_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (vlan_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (vlan_class);
-
- g_type_class_add_private (vlan_class, sizeof (NMDeviceVlanPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- object_class->get_property = get_property;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
-
- /* properties */
-
- /**
- * NMDeviceVlan:hw-address:
- *
- * The hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_VLAN_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceVlan:carrier:
- *
- * Whether the device has carrier.
- **/
- g_object_class_install_property
- (object_class, PROP_CARRIER,
- g_param_spec_boolean (NM_DEVICE_VLAN_CARRIER, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceVlan:parent:
- *
- * The devices's parent device.
- *
- * Since: 1.0
- **/
- g_object_class_install_property
- (object_class, PROP_PARENT,
- g_param_spec_object (NM_DEVICE_VLAN_PARENT, "", "",
- NM_TYPE_DEVICE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceVlan:vlan-id:
- *
- * The device's VLAN ID.
- **/
- g_object_class_install_property
- (object_class, PROP_VLAN_ID,
- g_param_spec_uint (NM_DEVICE_VLAN_VLAN_ID, "", "",
- 0, 4095, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-device-vlan.h b/libnm-glib/nm-device-vlan.h
deleted file mode 100644
index 107cfea88f..0000000000
--- a/libnm-glib/nm-device-vlan.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 - 2014 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_VLAN_H
-#define NM_DEVICE_VLAN_H
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_VLAN (nm_device_vlan_get_type ())
-#define NM_DEVICE_VLAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_VLAN, NMDeviceVlan))
-#define NM_DEVICE_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_VLAN, NMDeviceVlanClass))
-#define NM_IS_DEVICE_VLAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_VLAN))
-#define NM_IS_DEVICE_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_VLAN))
-#define NM_DEVICE_VLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_VLAN, NMDeviceVlanClass))
-
-/**
- * NMDeviceVlanError:
- * @NM_DEVICE_VLAN_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION: the connection was not of VLAN type
- * @NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION: the VLAN connection was invalid
- * @NM_DEVICE_VLAN_ERROR_ID_MISMATCH: the VLAN identifiers of the connection and the device mismatched
- * @NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched
- * @NM_DEVICE_VLAN_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
- */
-typedef enum {
- NM_DEVICE_VLAN_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION, /*< nick=NotVlanConnection >*/
- NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION, /*< nick=InvalidVlanConnection >*/
- NM_DEVICE_VLAN_ERROR_ID_MISMATCH, /*< nick=IdMismatch >*/
- NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
- NM_DEVICE_VLAN_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
-} NMDeviceVlanError;
-
-#define NM_DEVICE_VLAN_ERROR nm_device_vlan_error_quark ()
-GQuark nm_device_vlan_error_quark (void);
-
-#define NM_DEVICE_VLAN_HW_ADDRESS "hw-address"
-#define NM_DEVICE_VLAN_CARRIER "carrier"
-#define NM_DEVICE_VLAN_PARENT "parent"
-#define NM_DEVICE_VLAN_VLAN_ID "vlan-id"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceVlan;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceVlanClass;
-
-GType nm_device_vlan_get_type (void);
-
-GObject *nm_device_vlan_new (DBusGConnection *connection, const char *path);
-
-const char * nm_device_vlan_get_hw_address (NMDeviceVlan *device);
-gboolean nm_device_vlan_get_carrier (NMDeviceVlan *device);
-NM_AVAILABLE_IN_1_0
-NMDevice * nm_device_vlan_get_parent (NMDeviceVlan *device);
-guint nm_device_vlan_get_vlan_id (NMDeviceVlan *device);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_VLAN_H */
diff --git a/libnm-glib/nm-device-wifi.c b/libnm-glib/nm-device-wifi.c
deleted file mode 100644
index 08e5b90c10..0000000000
--- a/libnm-glib/nm-device-wifi.c
+++ /dev/null
@@ -1,837 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-wireless.h"
-#include "nm-setting-wireless-security.h"
-
-#include "nm-device-wifi.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-#include "nm-object-cache.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-types-private.h"
-
-G_DEFINE_TYPE (NMDeviceWifi, nm_device_wifi, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_WIFI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIFI, NMDeviceWifiPrivate))
-
-void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled);
-
-typedef struct {
- NMDeviceWifi *device;
- NMDeviceWifiRequestScanFn callback;
- gpointer user_data;
-} RequestScanInfo;
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- char *perm_hw_address;
- NM80211Mode mode;
- guint32 rate;
- NMAccessPoint *active_ap;
- NMDeviceWifiCapabilities wireless_caps;
- GPtrArray *aps;
-
- DBusGProxyCall *scan_call;
- RequestScanInfo *scan_info;
-} NMDeviceWifiPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_PERM_HW_ADDRESS,
- PROP_MODE,
- PROP_BITRATE,
- PROP_ACTIVE_ACCESS_POINT,
- PROP_WIRELESS_CAPABILITIES,
- PROP_ACCESS_POINTS,
-
- LAST_PROP
-};
-
-enum {
- ACCESS_POINT_ADDED,
- ACCESS_POINT_REMOVED,
-
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/**
- * nm_device_wifi_error_quark:
- *
- * Registers an error quark for #NMDeviceWifi if necessary.
- *
- * Returns: the error quark used for #NMDeviceWifi errors.
- **/
-GQuark
-nm_device_wifi_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-wifi-error-quark");
- return quark;
-}
-
-/**
- * nm_device_wifi_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDeviceWifi.
- *
- * Returns: (transfer full): a new Wi-Fi device
- **/
-GObject *
-nm_device_wifi_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_WIFI,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_wifi_get_hw_address:
- * @device: a #NMDeviceWifi
- *
- * Gets the actual hardware (MAC) address of the #NMDeviceWifi
- *
- * Returns: the actual hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_wifi_get_hw_address (NMDeviceWifi *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_WIFI_GET_PRIVATE (device)->hw_address;
-}
-
-/**
- * nm_device_wifi_get_permanent_hw_address:
- * @device: a #NMDeviceWifi
- *
- * Gets the permanent hardware (MAC) address of the #NMDeviceWifi
- *
- * Returns: the permanent hardware address. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_WIFI_GET_PRIVATE (device)->perm_hw_address;
-}
-
-/**
- * nm_device_wifi_get_mode:
- * @device: a #NMDeviceWifi
- *
- * Gets the #NMDeviceWifi mode.
- *
- * Returns: the mode
- **/
-NM80211Mode
-nm_device_wifi_get_mode (NMDeviceWifi *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_WIFI_GET_PRIVATE (device)->mode;
-}
-
-/**
- * nm_device_wifi_get_bitrate:
- * @device: a #NMDeviceWifi
- *
- * Gets the bit rate of the #NMDeviceWifi in kbit/s.
- *
- * Returns: the bit rate (kbit/s)
- **/
-guint32
-nm_device_wifi_get_bitrate (NMDeviceWifi *device)
-{
- NMDeviceState state;
-
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0);
-
- state = nm_device_get_state (NM_DEVICE (device));
- switch (state) {
- case NM_DEVICE_STATE_IP_CONFIG:
- case NM_DEVICE_STATE_IP_CHECK:
- case NM_DEVICE_STATE_SECONDARIES:
- case NM_DEVICE_STATE_ACTIVATED:
- case NM_DEVICE_STATE_DEACTIVATING:
- break;
- default:
- return 0;
- }
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_WIFI_GET_PRIVATE (device)->rate;
-}
-
-/**
- * nm_device_wifi_get_capabilities:
- * @device: a #NMDeviceWifi
- *
- * Gets the Wi-Fi capabilities of the #NMDeviceWifi.
- *
- * Returns: the capabilities
- **/
-NMDeviceWifiCapabilities
-nm_device_wifi_get_capabilities (NMDeviceWifi *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_WIFI_GET_PRIVATE (device)->wireless_caps;
-}
-
-/**
- * nm_device_wifi_get_active_access_point:
- * @device: a #NMDeviceWifi
- *
- * Gets the active #NMAccessPoint.
- *
- * Returns: (transfer none): the access point or %NULL if none is active
- **/
-NMAccessPoint *
-nm_device_wifi_get_active_access_point (NMDeviceWifi *device)
-{
- NMDeviceState state;
-
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
-
- state = nm_device_get_state (NM_DEVICE (device));
- switch (state) {
- case NM_DEVICE_STATE_PREPARE:
- case NM_DEVICE_STATE_CONFIG:
- case NM_DEVICE_STATE_NEED_AUTH:
- case NM_DEVICE_STATE_IP_CONFIG:
- case NM_DEVICE_STATE_IP_CHECK:
- case NM_DEVICE_STATE_SECONDARIES:
- case NM_DEVICE_STATE_ACTIVATED:
- case NM_DEVICE_STATE_DEACTIVATING:
- break;
- default:
- return NULL;
- break;
- }
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_WIFI_GET_PRIVATE (device)->active_ap;
-}
-
-/**
- * nm_device_wifi_get_access_points:
- * @device: a #NMDeviceWifi
- *
- * Gets all the scanned access points of the #NMDeviceWifi.
- *
- * Returns: (element-type NMAccessPoint): a #GPtrArray containing all the
- * scanned #NMAccessPoints.
- * The returned array is owned by the client and should not be modified.
- **/
-const GPtrArray *
-nm_device_wifi_get_access_points (NMDeviceWifi *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return handle_ptr_array_return (NM_DEVICE_WIFI_GET_PRIVATE (device)->aps);
-}
-
-/**
- * nm_device_wifi_get_access_point_by_path:
- * @device: a #NMDeviceWifi
- * @path: the object path of the access point
- *
- * Gets a #NMAccessPoint by path.
- *
- * Returns: (transfer none): the access point or %NULL if none is found.
- **/
-NMAccessPoint *
-nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device,
- const char *path)
-{
- const GPtrArray *aps;
- int i;
- NMAccessPoint *ap = NULL;
-
- g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- aps = nm_device_wifi_get_access_points (device);
- if (!aps)
- return NULL;
-
- for (i = 0; i < aps->len; i++) {
- NMAccessPoint *candidate = g_ptr_array_index (aps, i);
- if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), path)) {
- ap = candidate;
- break;
- }
- }
-
- return ap;
-}
-
-static void
-request_scan_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- RequestScanInfo *info = user_data;
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (info->device);
- GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
-
- if (info->callback)
- info->callback (info->device, error, info->user_data);
-
- g_clear_error (&error);
- g_slice_free (RequestScanInfo, info);
-
- priv->scan_call = NULL;
- priv->scan_info = NULL;
-}
-
-/**
- * nm_device_wifi_request_scan_simple:
- * @device: a #NMDeviceWifi
- * @callback: (scope async) (allow-none): the function to call when the call is done
- * @user_data: (closure): user data to pass to the callback function
- *
- * Request NM to scan for access points on the #NMDeviceWifi. This function only
- * instructs NM to perform scanning. Use nm_device_wifi_get_access_points()
- * to get available access points.
- *
- * Since: 0.9.8
- **/
-void
-nm_device_wifi_request_scan_simple (NMDeviceWifi *device,
- NMDeviceWifiRequestScanFn callback,
- gpointer user_data)
-{
- RequestScanInfo *info;
- GHashTable *options;
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
-
- g_return_if_fail (NM_IS_DEVICE_WIFI (device));
-
- /* If a scan is in progress, just return */
- if (priv->scan_call)
- return;
-
- options = g_hash_table_new (g_str_hash, g_str_equal);
-
- info = g_slice_new0 (RequestScanInfo);
- info->device = device;
- info->callback = callback;
- info->user_data = user_data;
-
- priv->scan_info = info;
- priv->scan_call = dbus_g_proxy_begin_call (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, "RequestScan",
- request_scan_cb, info, NULL,
- DBUS_TYPE_G_MAP_OF_VARIANT, options,
- G_TYPE_INVALID);
-
- g_hash_table_unref (options);
-}
-
-static void
-clean_up_aps (NMDeviceWifi *self, gboolean notify)
-{
- NMDeviceWifiPrivate *priv;
-
- g_return_if_fail (NM_IS_DEVICE_WIFI (self));
-
- priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
-
- if (priv->active_ap) {
- g_object_unref (priv->active_ap);
- priv->active_ap = NULL;
- }
-
- if (priv->aps) {
- while (priv->aps->len) {
- NMAccessPoint *ap = NM_ACCESS_POINT (g_ptr_array_index (priv->aps, 0));
-
- if (notify)
- g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap);
- g_ptr_array_remove (priv->aps, ap);
- g_object_unref (ap);
- }
- g_ptr_array_free (priv->aps, TRUE);
- priv->aps = NULL;
- }
-}
-
-/**
- * _nm_device_wifi_set_wireless_enabled:
- * @device: a #NMDeviceWifi
- * @enabled: %TRUE to enable the device
- *
- * Enables or disables the wireless device.
- **/
-void
-_nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device,
- gboolean enabled)
-{
- g_return_if_fail (NM_IS_DEVICE_WIFI (device));
-
- if (!enabled)
- clean_up_aps (device, TRUE);
-}
-
-#define WPA_CAPS (NM_WIFI_DEVICE_CAP_CIPHER_TKIP | \
- NM_WIFI_DEVICE_CAP_CIPHER_CCMP | \
- NM_WIFI_DEVICE_CAP_WPA | \
- NM_WIFI_DEVICE_CAP_RSN)
-
-#define RSN_CAPS (NM_WIFI_DEVICE_CAP_CIPHER_CCMP | NM_WIFI_DEVICE_CAP_RSN)
-
-static gboolean
-has_proto (NMSettingWirelessSecurity *s_wsec, const char *proto)
-{
- int i;
-
- for (i = 0; i < nm_setting_wireless_security_get_num_protos (s_wsec); i++) {
- if (g_strcmp0 (proto, nm_setting_wireless_security_get_proto (s_wsec, i)) == 0)
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingWireless *s_wifi;
- NMSettingWirelessSecurity *s_wsec;
- const char *ctype;
- const GByteArray *mac;
- const char *hw_str;
- struct ether_addr *hw_mac;
- NMDeviceWifiCapabilities wifi_caps;
- const char *key_mgmt;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION,
- "The connection was not a Wi-Fi connection.");
- return FALSE;
- }
-
- s_wifi = nm_connection_get_setting_wireless (connection);
- if (!s_wifi) {
- g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION,
- "The connection was not a valid Wi-Fi connection.");
- return FALSE;
- }
-
- /* Check MAC address */
- hw_str = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device));
- if (hw_str) {
- hw_mac = ether_aton (hw_str);
- if (!hw_mac) {
- g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC,
- "Invalid device MAC address.");
- return FALSE;
- }
- mac = nm_setting_wireless_get_mac_address (s_wifi);
- if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) {
- g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MAC_MISMATCH,
- "The MACs of the device and the connection didn't match.");
- return FALSE;
- }
- }
-
- /* Check device capabilities; we assume all devices can do WEP at least */
- wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device));
-
- s_wsec = nm_connection_get_setting_wireless_security (connection);
- if (s_wsec) {
- /* Connection has security, verify it against the device's capabilities */
- key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec);
- if ( !g_strcmp0 (key_mgmt, "wpa-none")
- || !g_strcmp0 (key_mgmt, "wpa-psk")
- || !g_strcmp0 (key_mgmt, "wpa-eap")) {
-
- /* Is device only WEP capable? */
- if (!(wifi_caps & WPA_CAPS)) {
- g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS,
- "The device missed WPA capabilities required by the connection.");
- return FALSE;
- }
-
- /* Make sure WPA2/RSN-only connections don't get chosen for WPA-only cards */
- if (has_proto (s_wsec, "rsn") && !has_proto (s_wsec, "wpa") && !(wifi_caps & RSN_CAPS)) {
- g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS,
- "The device missed WPA2/RSN capabilities required by the connection.");
- return FALSE;
- }
- }
- }
-
- return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_WIRELESS;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_wifi_init (NMDeviceWifi *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_WIFI);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceWifi *self = NM_DEVICE_WIFI (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_wifi_get_hw_address (self));
- break;
- case PROP_PERM_HW_ADDRESS:
- g_value_set_string (value, nm_device_wifi_get_permanent_hw_address (self));
- break;
- case PROP_MODE:
- g_value_set_uint (value, nm_device_wifi_get_mode (self));
- break;
- case PROP_BITRATE:
- g_value_set_uint (value, nm_device_wifi_get_bitrate (self));
- break;
- case PROP_ACTIVE_ACCESS_POINT:
- g_value_set_object (value, nm_device_wifi_get_active_access_point (self));
- break;
- case PROP_WIRELESS_CAPABILITIES:
- g_value_set_uint (value, nm_device_wifi_get_capabilities (self));
- break;
- case PROP_ACCESS_POINTS:
- g_value_set_boxed (value, nm_device_wifi_get_access_points (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
-{
- NMDeviceWifi *self = NM_DEVICE_WIFI (device);
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
-
- switch (nm_device_get_state (device)) {
- case NM_DEVICE_STATE_UNKNOWN:
- case NM_DEVICE_STATE_UNMANAGED:
- case NM_DEVICE_STATE_UNAVAILABLE:
- case NM_DEVICE_STATE_DISCONNECTED:
- case NM_DEVICE_STATE_FAILED:
- /* Just clear active AP; don't clear the AP list unless wireless is disabled completely */
- if (priv->active_ap) {
- g_object_unref (priv->active_ap);
- priv->active_ap = NULL;
- }
- _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT);
- priv->rate = 0;
- _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIFI_BITRATE);
- break;
- default:
- break;
- }
-}
-
-static void
-register_properties (NMDeviceWifi *device)
-{
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_WIFI_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, &priv->perm_hw_address },
- { NM_DEVICE_WIFI_MODE, &priv->mode },
- { NM_DEVICE_WIFI_BITRATE, &priv->rate },
- { NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, &priv->active_ap, NULL, NM_TYPE_ACCESS_POINT },
- { NM_DEVICE_WIFI_CAPABILITIES, &priv->wireless_caps },
- { NM_DEVICE_WIFI_ACCESS_POINTS, &priv->aps, NULL, NM_TYPE_ACCESS_POINT, "access-point" },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-static void
-access_point_removed (NMDeviceWifi *self, NMAccessPoint *ap)
-{
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
-
- if (ap == priv->active_ap) {
- g_object_unref (priv->active_ap);
- priv->active_ap = NULL;
- _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT);
-
- priv->rate = 0;
- _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_BITRATE);
- }
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_wifi_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIRELESS);
- register_properties (NM_DEVICE_WIFI (object));
-
- g_signal_connect (NM_DEVICE (object),
- "notify::" NM_DEVICE_STATE,
- G_CALLBACK (state_changed_cb),
- NULL);
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object);
- GError *error = NULL;
-
- if (priv->scan_call) {
- g_set_error_literal (&error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_UNKNOWN,
- "Wi-Fi device was destroyed");
- if (priv->scan_info) {
- if (priv->scan_info->callback)
- priv->scan_info->callback (NULL, error, priv->scan_info->user_data);
- g_slice_free (RequestScanInfo, priv->scan_info);
- priv->scan_info = NULL;
- }
- g_clear_error (&error);
-
- dbus_g_proxy_cancel_call (priv->proxy, priv->scan_call);
- priv->scan_call = NULL;
- }
-
- clean_up_aps (NM_DEVICE_WIFI (object), FALSE);
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_wifi_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object);
-
- g_free (priv->hw_address);
- g_free (priv->perm_hw_address);
-
- G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object);
-}
-
-static void
-nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (wifi_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (wifi_class);
-
- g_type_class_add_private (wifi_class, sizeof (NMDeviceWifiPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
- wifi_class->access_point_removed = access_point_removed;
-
- /* properties */
-
- /**
- * NMDeviceWifi:hw-address:
- *
- * The hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_WIFI_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWifi:perm-hw-address:
- *
- * The hardware (MAC) address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_PERM_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWifi:mode:
- *
- * The mode of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_MODE,
- g_param_spec_uint (NM_DEVICE_WIFI_MODE, "", "",
- NM_802_11_MODE_UNKNOWN, NM_802_11_MODE_AP, NM_802_11_MODE_INFRA,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWifi:bitrate:
- *
- * The bit rate of the device in kbit/s.
- **/
- g_object_class_install_property
- (object_class, PROP_BITRATE,
- g_param_spec_uint (NM_DEVICE_WIFI_BITRATE, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWifi:active-access-point:
- *
- * The active #NMAccessPoint of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_ACTIVE_ACCESS_POINT,
- g_param_spec_object (NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, "", "",
- NM_TYPE_ACCESS_POINT,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWifi:wireless-capabilities:
- *
- * The wireless capabilities of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_WIRELESS_CAPABILITIES,
- g_param_spec_uint (NM_DEVICE_WIFI_CAPABILITIES, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWifi:access-points:
- *
- * List of all Wi-Fi access points the device can see.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_ACCESS_POINTS,
- g_param_spec_boxed (NM_DEVICE_WIFI_ACCESS_POINTS, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /* signals */
-
- /**
- * NMDeviceWifi::access-point-added:
- * @device: the Wi-Fi device that received the signal
- * @ap: the new access point
- *
- * Notifies that a #NMAccessPoint is added to the Wi-Fi device.
- **/
- signals[ACCESS_POINT_ADDED] =
- g_signal_new ("access-point-added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMDeviceWifiClass, access_point_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-
- /**
- * NMDeviceWifi::access-point-removed:
- * @device: the Wi-Fi device that received the signal
- * @ap: the removed access point
- *
- * Notifies that a #NMAccessPoint is removed from the Wi-Fi device.
- **/
- signals[ACCESS_POINT_REMOVED] =
- g_signal_new ("access-point-removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMDeviceWifiClass, access_point_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-}
diff --git a/libnm-glib/nm-device-wifi.h b/libnm-glib/nm-device-wifi.h
deleted file mode 100644
index 2bb432a7b0..0000000000
--- a/libnm-glib/nm-device-wifi.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_WIFI_H
-#define NM_DEVICE_WIFI_H
-
-#include "nm-device.h"
-#include "nm-access-point.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_WIFI (nm_device_wifi_get_type ())
-#define NM_DEVICE_WIFI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIFI, NMDeviceWifi))
-#define NM_DEVICE_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WIFI, NMDeviceWifiClass))
-#define NM_IS_DEVICE_WIFI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WIFI))
-#define NM_IS_DEVICE_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIFI))
-#define NM_DEVICE_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIFI, NMDeviceWifiClass))
-
-/**
- * NMDeviceWifiError:
- * @NM_DEVICE_WIFI_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION: the connection was not of Wi-Fi type
- * @NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION: the Wi-Fi connection was invalid
- * @NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
- * @NM_DEVICE_WIFI_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
- * @NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS: the device missed WPA capabilities
- * required by the connection
- * @NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS: the device missed RSN capabilities
- * required by the connection
- */
-typedef enum {
- NM_DEVICE_WIFI_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION, /*< nick=NotWifiConnection >*/
- NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION, /*< nick=InvalidWifiConnection >*/
- NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
- NM_DEVICE_WIFI_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
- NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS, /*< nick=MissingDeviceWpaCaps >*/
- NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS, /*< nick=MissingDeviceRsnCaps >*/
-} NMDeviceWifiError;
-
-#define NM_DEVICE_WIFI_ERROR nm_device_wifi_error_quark ()
-GQuark nm_device_wifi_error_quark (void);
-
-#define NM_DEVICE_WIFI_HW_ADDRESS "hw-address"
-#define NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS "perm-hw-address"
-#define NM_DEVICE_WIFI_MODE "mode"
-#define NM_DEVICE_WIFI_BITRATE "bitrate"
-#define NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT "active-access-point"
-#define NM_DEVICE_WIFI_CAPABILITIES "wireless-capabilities"
-#define NM_DEVICE_WIFI_ACCESS_POINTS "access-points"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceWifi;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Signals */
- void (*access_point_added) (NMDeviceWifi *device, NMAccessPoint *ap);
- void (*access_point_removed) (NMDeviceWifi *device, NMAccessPoint *ap);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDeviceWifiClass;
-
-GType nm_device_wifi_get_type (void);
-
-GObject *nm_device_wifi_new (DBusGConnection *connection, const char *path);
-
-const char * nm_device_wifi_get_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_access_point_by_path (NMDeviceWifi *device,
- const char *path);
-
-const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi *device);
-
-typedef void (*NMDeviceWifiRequestScanFn) (NMDeviceWifi *device,
- GError *error,
- gpointer user_data);
-void nm_device_wifi_request_scan_simple (NMDeviceWifi *device,
- NMDeviceWifiRequestScanFn callback,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_WIFI_H */
diff --git a/libnm-glib/nm-device-wimax.c b/libnm-glib/nm-device-wimax.c
deleted file mode 100644
index 3465475a4a..0000000000
--- a/libnm-glib/nm-device-wimax.c
+++ /dev/null
@@ -1,795 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2012 Red Hat, Inc.
- * Copyright 2009 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-
-#include "nm-setting-connection.h"
-#include "nm-setting-wimax.h"
-
-#include "nm-device-wimax.h"
-#include "nm-object-private.h"
-#include "nm-object-cache.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-types-private.h"
-#include "nm-device-private.h"
-
-G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxPrivate))
-
-void _nm_device_wimax_set_wireless_enabled (NMDeviceWimax *wimax, gboolean enabled);
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *hw_address;
- NMWimaxNsp *active_nsp;
- GPtrArray *nsps;
-
- guint center_freq;
- int rssi;
- int cinr;
- int tx_power;
- char *bsid;
-} NMDeviceWimaxPrivate;
-
-enum {
- PROP_0,
- PROP_HW_ADDRESS,
- PROP_ACTIVE_NSP,
- PROP_CENTER_FREQ,
- PROP_RSSI,
- PROP_CINR,
- PROP_TX_POWER,
- PROP_BSID,
- PROP_NSPS,
-
- LAST_PROP
-};
-
-enum {
- NSP_ADDED,
- NSP_REMOVED,
-
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/**
- * nm_device_wimax_error_quark:
- *
- * Registers an error quark for #NMDeviceWimax if necessary.
- *
- * Returns: the error quark used for #NMDeviceWimax errors.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-GQuark
-nm_device_wimax_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-wimax-error-quark");
- return quark;
-}
-
-/**
- * nm_device_wimax_new:
- * @connection: the #DBusGConnection
- * @path: the D-Bus object path of the WiMAX device
- *
- * Creates a new #NMDeviceWimax.
- *
- * Returns: (transfer full): a new WiMAX device
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-GObject *
-nm_device_wimax_new (DBusGConnection *connection, const char *path)
-{
- GObject *device;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- device = g_object_new (NM_TYPE_DEVICE_WIMAX,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return device;
-}
-
-/**
- * nm_device_wimax_get_hw_address:
- * @wimax: a #NMDeviceWimax
- *
- * Gets the hardware (MAC) address of the #NMDeviceWimax
- *
- * Returns: the hardware address. This is the internal string used by the
- * device, and must not be modified.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-const char *
-nm_device_wimax_get_hw_address (NMDeviceWimax *wimax)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (wimax));
- return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->hw_address;
-}
-
-/**
- * nm_device_wimax_get_active_nsp:
- * @wimax: a #NMDeviceWimax
- *
- * Gets the active #NMWimaxNsp.
- *
- * Returns: (transfer full): the access point or %NULL if none is active
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-NMWimaxNsp *
-nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax)
-{
- NMDeviceState state;
-
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
-
- state = nm_device_get_state (NM_DEVICE (wimax));
- switch (state) {
- case NM_DEVICE_STATE_PREPARE:
- case NM_DEVICE_STATE_CONFIG:
- case NM_DEVICE_STATE_NEED_AUTH:
- case NM_DEVICE_STATE_IP_CONFIG:
- case NM_DEVICE_STATE_IP_CHECK:
- case NM_DEVICE_STATE_SECONDARIES:
- case NM_DEVICE_STATE_ACTIVATED:
- case NM_DEVICE_STATE_DEACTIVATING:
- break;
- default:
- return NULL;
- break;
- }
-
- _nm_object_ensure_inited (NM_OBJECT (wimax));
- return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->active_nsp;
-}
-
-/**
- * nm_device_wimax_get_nsps:
- * @wimax: a #NMDeviceWimax
- *
- * Gets all the scanned NSPs of the #NMDeviceWimax.
- *
- * Returns: (element-type NMWimaxNsp): a #GPtrArray containing
- * all the scanned #NMWimaxNsps.
- * The returned array is owned by the client and should not be modified.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-const GPtrArray *
-nm_device_wimax_get_nsps (NMDeviceWimax *wimax)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (wimax));
- return handle_ptr_array_return (NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->nsps);
-}
-
-/**
- * nm_device_wimax_get_nsp_by_path:
- * @wimax: a #NMDeviceWimax
- * @path: the object path of the NSP
- *
- * Gets a #NMWimaxNsp by path.
- *
- * Returns: (transfer none): the access point or %NULL if none is found.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-NMWimaxNsp *
-nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax,
- const char *path)
-{
- const GPtrArray *nsps;
- int i;
- NMWimaxNsp *nsp = NULL;
-
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- nsps = nm_device_wimax_get_nsps (wimax);
- if (!nsps)
- return NULL;
-
- for (i = 0; i < nsps->len; i++) {
- NMWimaxNsp *candidate = g_ptr_array_index (nsps, i);
- if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), path)) {
- nsp = candidate;
- break;
- }
- }
-
- return nsp;
-}
-
-static void
-clean_up_nsps (NMDeviceWimax *self, gboolean notify)
-{
- NMDeviceWimaxPrivate *priv;
-
- g_return_if_fail (NM_IS_DEVICE_WIMAX (self));
-
- priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
-
- if (priv->active_nsp) {
- g_object_unref (priv->active_nsp);
- priv->active_nsp = NULL;
- }
-
- if (priv->nsps) {
- while (priv->nsps->len) {
- NMWimaxNsp *nsp = NM_WIMAX_NSP (g_ptr_array_index (priv->nsps, 0));
-
- if (notify)
- g_signal_emit (self, signals[NSP_REMOVED], 0, nsp);
- g_ptr_array_remove (priv->nsps, nsp);
- g_object_unref (nsp);
- }
- g_ptr_array_free (priv->nsps, TRUE);
- priv->nsps = NULL;
- }
-}
-
-/**
- * nm_device_wimax_get_center_frequency:
- * @self: a #NMDeviceWimax
- *
- * Gets the center frequency (in KHz) of the radio channel the device is using
- * to communicate with the network when connected. Has no meaning when the
- * device is not connected.
- *
- * Returns: the center frequency in KHz, or 0
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-guint
-nm_device_wimax_get_center_frequency (NMDeviceWimax *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (self));
- return NM_DEVICE_WIMAX_GET_PRIVATE (self)->center_freq;
-}
-
-/**
- * nm_device_wimax_get_rssi:
- * @self: a #NMDeviceWimax
- *
- * Gets the RSSI of the current radio link in dBm. This value indicates how
- * strong the raw received RF signal from the base station is, but does not
- * indicate the overall quality of the radio link. Has no meaning when the
- * device is not connected.
- *
- * Returns: the RSSI in dBm, or 0
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-int
-nm_device_wimax_get_rssi (NMDeviceWimax *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (self));
- return NM_DEVICE_WIMAX_GET_PRIVATE (self)->rssi;
-}
-
-/**
- * nm_device_wimax_get_cinr:
- * @self: a #NMDeviceWimax
- *
- * Gets the CINR (Carrier to Interference + Noise Ratio) of the current radio
- * link in dB. CINR is a more accurate measure of radio link quality. Has no
- * meaning when the device is not connected.
- *
- * Returns: the CINR in dB, or 0
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-int
-nm_device_wimax_get_cinr (NMDeviceWimax *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (self));
- return NM_DEVICE_WIMAX_GET_PRIVATE (self)->cinr;
-}
-
-/**
- * nm_device_wimax_get_tx_power:
- * @self: a #NMDeviceWimax
- *
- * Average power of the last burst transmitted by the device, in units of
- * 0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of
- * -5.5 dBm. Has no meaning when the device is not connected.
- *
- * Returns: the TX power in dBm, or 0
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-int
-nm_device_wimax_get_tx_power (NMDeviceWimax *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (self));
- return NM_DEVICE_WIMAX_GET_PRIVATE (self)->tx_power;
-}
-
-/**
- * nm_device_wimax_get_bsid:
- * @self: a #NMDeviceWimax
- *
- * Gets the ID of the serving Base Station when the device is connected.
- *
- * Returns: the ID of the serving Base Station, or %NULL
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-const char *
-nm_device_wimax_get_bsid (NMDeviceWimax *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (self));
- return NM_DEVICE_WIMAX_GET_PRIVATE (self)->bsid;
-}
-
-static gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingWimax *s_wimax;
- const char *ctype;
- const GByteArray *mac;
- const char *hw_str;
- struct ether_addr *hw_mac;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_WIMAX_SETTING_NAME) != 0) {
- g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION,
- "The connection was not a Wimax connection.");
- return FALSE;
- }
-
- s_wimax = nm_connection_get_setting_wimax (connection);
- if (!s_wimax) {
- g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION,
- "The connection was not a valid Wimax connection.");
- return FALSE;
- }
-
- /* Check MAC address */
- hw_str = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
- if (hw_str) {
- hw_mac = ether_aton (hw_str);
- if (!hw_mac) {
- g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC,
- "Invalid device MAC address.");
- return FALSE;
- }
- mac = nm_setting_wimax_get_mac_address (s_wimax);
- if (mac && hw_mac && memcmp (mac->data, hw_mac->ether_addr_octet, ETH_ALEN)) {
- g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH,
- "The MACs of the device and the connection didn't match.");
- return FALSE;
- }
- }
-
- return NM_DEVICE_CLASS (nm_device_wimax_parent_class)->connection_compatible (device, connection, error);
-}
-
-static GType
-get_setting_type (NMDevice *device)
-{
- return NM_TYPE_SETTING_WIMAX;
-}
-
-static const char *
-get_hw_address (NMDevice *device)
-{
- return nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
-}
-
-/*****************************************************************************/
-
-static void
-nm_device_wimax_init (NMDeviceWimax *device)
-{
- _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_WIMAX);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDeviceWimax *self = NM_DEVICE_WIMAX (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_HW_ADDRESS:
- g_value_set_string (value, nm_device_wimax_get_hw_address (self));
- break;
- case PROP_ACTIVE_NSP:
- g_value_set_object (value, nm_device_wimax_get_active_nsp (self));
- break;
- case PROP_CENTER_FREQ:
- g_value_set_uint (value, nm_device_wimax_get_center_frequency (self));
- break;
- case PROP_RSSI:
- g_value_set_int (value, nm_device_wimax_get_rssi (self));
- break;
- case PROP_CINR:
- g_value_set_int (value, nm_device_wimax_get_cinr (self));
- break;
- case PROP_TX_POWER:
- g_value_set_int (value, nm_device_wimax_get_tx_power (self));
- break;
- case PROP_BSID:
- g_value_set_string (value, nm_device_wimax_get_bsid (self));
- break;
- case PROP_NSPS:
- g_value_set_boxed (value, nm_device_wimax_get_nsps (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-clear_link_status (NMDeviceWimax *self)
-{
- NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
-
- if (priv->center_freq) {
- priv->center_freq = 0;
- _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CENTER_FREQUENCY);
- }
-
- if (priv->rssi) {
- priv->rssi = 0;
- _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_RSSI);
- }
-
- if (priv->cinr) {
- priv->cinr = 0;
- _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CINR);
- }
-
- if (priv->tx_power) {
- priv->tx_power = 0;
- _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_TX_POWER);
- }
-
- if (priv->bsid) {
- g_free (priv->bsid);
- priv->bsid = NULL;
- _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_BSID);
- }
-}
-
-static void
-state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
-{
- NMDeviceWimax *self = NM_DEVICE_WIMAX (device);
- NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
- NMDeviceState state;
-
- state = nm_device_get_state (device);
- switch (state) {
- case NM_DEVICE_STATE_UNKNOWN:
- case NM_DEVICE_STATE_UNMANAGED:
- case NM_DEVICE_STATE_UNAVAILABLE:
- case NM_DEVICE_STATE_DISCONNECTED:
- case NM_DEVICE_STATE_FAILED:
- if (priv->active_nsp) {
- g_object_unref (priv->active_nsp);
- priv->active_nsp = NULL;
- }
- _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIMAX_ACTIVE_NSP);
- clear_link_status (self);
- break;
- case NM_DEVICE_STATE_PREPARE:
- case NM_DEVICE_STATE_CONFIG:
- case NM_DEVICE_STATE_NEED_AUTH:
- case NM_DEVICE_STATE_IP_CONFIG:
- clear_link_status (self);
- break;
- default:
- break;
- }
-}
-
-static void
-register_properties (NMDeviceWimax *wimax)
-{
- NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_WIMAX_HW_ADDRESS, &priv->hw_address },
- { NM_DEVICE_WIMAX_ACTIVE_NSP, &priv->active_nsp, NULL, NM_TYPE_WIMAX_NSP },
- { NM_DEVICE_WIMAX_CENTER_FREQUENCY, &priv->center_freq },
- { NM_DEVICE_WIMAX_RSSI, &priv->rssi },
- { NM_DEVICE_WIMAX_CINR, &priv->cinr },
- { NM_DEVICE_WIMAX_TX_POWER, &priv->tx_power },
- { NM_DEVICE_WIMAX_BSID, &priv->bsid },
- { NM_DEVICE_WIMAX_NSPS, &priv->nsps, NULL, NM_TYPE_WIMAX_NSP, "nsp" },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (wimax),
- priv->proxy,
- property_info);
-}
-
-static void
-nsp_removed (NMDeviceWimax *self, NMWimaxNsp *nsp)
-{
- NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
-
- if (nsp == priv->active_nsp) {
- g_object_unref (priv->active_nsp);
- priv->active_nsp = NULL;
- _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_ACTIVE_NSP);
- }
-}
-
-static void
-constructed (GObject *object)
-{
- NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_device_wimax_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIMAX);
- register_properties (NM_DEVICE_WIMAX (object));
-
- g_signal_connect (object,
- "notify::" NM_DEVICE_STATE,
- G_CALLBACK (state_changed_cb),
- NULL);
-}
-
-static void
-dispose (GObject *object)
-{
- NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
-
- if (priv->hw_address) {
- g_free (priv->hw_address);
- priv->hw_address = NULL;
- }
-
- if (priv->bsid) {
- g_free (priv->bsid);
- priv->bsid = NULL;
- }
-
- clean_up_nsps (NM_DEVICE_WIMAX (object), FALSE);
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_device_wimax_parent_class)->dispose (object);
-}
-
-static void
-nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (wimax_class);
- NMDeviceClass *device_class = NM_DEVICE_CLASS (wimax_class);
-
- g_type_class_add_private (wimax_class, sizeof (NMDeviceWimaxPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- device_class->connection_compatible = connection_compatible;
- device_class->get_setting_type = get_setting_type;
- device_class->get_hw_address = get_hw_address;
- wimax_class->nsp_removed = nsp_removed;
-
- /* properties */
-
- /**
- * NMDeviceWimax:hw-address:
- *
- * The hardware (MAC) address of the device.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_HW_ADDRESS,
- g_param_spec_string (NM_DEVICE_WIMAX_HW_ADDRESS, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWimax:active-nsp:
- *
- * The active #NMWimaxNsp of the device.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_ACTIVE_NSP,
- g_param_spec_object (NM_DEVICE_WIMAX_ACTIVE_NSP, "", "",
- NM_TYPE_WIMAX_NSP,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWimax:center-frequency:
- *
- * The center frequency (in KHz) of the radio channel the device is using to
- * communicate with the network when connected. Has no meaning when the
- * device is not connected.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_CENTER_FREQ,
- g_param_spec_uint (NM_DEVICE_WIMAX_CENTER_FREQUENCY, "", "",
- 0, G_MAXUINT, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWimax:rssi:
- *
- * RSSI of the current radio link in dBm. This value indicates how strong
- * the raw received RF signal from the base station is, but does not
- * indicate the overall quality of the radio link. Has no meaning when the
- * device is not connected.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_RSSI,
- g_param_spec_int (NM_DEVICE_WIMAX_RSSI, "", "",
- G_MININT, G_MAXINT, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWimax:cinr:
- *
- * CINR (Carrier to Interference + Noise Ratio) of the current radio link
- * in dB. CINR is a more accurate measure of radio link quality. Has no
- * meaning when the device is not connected.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_CINR,
- g_param_spec_int (NM_DEVICE_WIMAX_CINR, "", "",
- G_MININT, G_MAXINT, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWimax:tx-power:
- *
- * Average power of the last burst transmitted by the device, in units of
- * 0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of
- * -5.5 dBm. Has no meaning when the device is not connected.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_TX_POWER,
- g_param_spec_int (NM_DEVICE_WIMAX_TX_POWER, "", "",
- G_MININT, G_MAXINT, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWimax:bsid:
- *
- * The ID of the serving base station as received from the network. Has
- * no meaning when the device is not connected.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_BSID,
- g_param_spec_string (NM_DEVICE_WIMAX_BSID, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDeviceWimax:nsps:
- *
- * List of all WiMAX Network Service Providers the device can see.
- *
- * Since: 0.9.10
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_NSPS,
- g_param_spec_boxed (NM_DEVICE_WIMAX_NSPS, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /* signals */
-
- /**
- * NMDeviceWimax::nsp-added:
- * @self: the wimax device that received the signal
- * @nsp: the new NSP
- *
- * Notifies that a #NMWimaxNsp is added to the wimax device.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- signals[NSP_ADDED] =
- g_signal_new ("nsp-added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMDeviceWimaxClass, nsp_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-
- /**
- * NMDeviceWimax::nsp-removed:
- * @self: the wimax device that received the signal
- * @nsp: the removed NSP
- *
- * Notifies that a #NMWimaxNsp is removed from the wimax device.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- signals[NSP_REMOVED] =
- g_signal_new ("nsp-removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMDeviceWimaxClass, nsp_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-}
diff --git a/libnm-glib/nm-device-wimax.h b/libnm-glib/nm-device-wimax.h
deleted file mode 100644
index 21d28117b4..0000000000
--- a/libnm-glib/nm-device-wimax.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2012 Red Hat, Inc.
- * Copyright 2009 Novell, Inc.
- */
-
-#ifndef NM_DEVICE_WIMAX_H
-#define NM_DEVICE_WIMAX_H
-
-#include "nm-device.h"
-#include "nm-wimax-nsp.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_WIMAX (nm_device_wimax_get_type ())
-#define NM_DEVICE_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimax))
-#define NM_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
-#define NM_IS_DEVICE_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WIMAX))
-#define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIMAX))
-#define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
-
-/**
- * NMDeviceWimaxError:
- * @NM_DEVICE_WIMAX_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION: the connection was not of WiMax type
- * @NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION: the WiMax connection was invalid
- * @NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
- * @NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
- */
-typedef enum {
- NM_DEVICE_WIMAX_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION, /*< nick=NotWimaxConnection >*/
- NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION, /*< nick=InvalidWimaxConnection >*/
- NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
- NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
-} NMDeviceWimaxError;
-
-#define NM_DEVICE_WIMAX_ERROR nm_device_wimax_error_quark ()
-NM_DEPRECATED_IN_1_2
-GQuark nm_device_wimax_error_quark (void);
-
-#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address"
-#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp"
-#define NM_DEVICE_WIMAX_CENTER_FREQUENCY "center-frequency"
-#define NM_DEVICE_WIMAX_RSSI "rssi"
-#define NM_DEVICE_WIMAX_CINR "cinr"
-#define NM_DEVICE_WIMAX_TX_POWER "tx-power"
-#define NM_DEVICE_WIMAX_BSID "bsid"
-#define NM_DEVICE_WIMAX_NSPS "nsps"
-
-typedef struct {
- NMDevice parent;
-} NMDeviceWimax;
-
-typedef struct {
- NMDeviceClass parent;
-
- /* Signals */
- void (*nsp_added) (NMDeviceWimax *self, NMWimaxNsp *nsp);
- void (*nsp_removed) (NMDeviceWimax *self, NMWimaxNsp *nsp);
-} NMDeviceWimaxClass;
-
-NM_DEPRECATED_IN_1_2
-GType nm_device_wimax_get_type (void);
-
-NM_DEPRECATED_IN_1_2
-GObject *nm_device_wimax_new (DBusGConnection *connection,
- const char *path);
-
-NM_DEPRECATED_IN_1_2
-const char *nm_device_wimax_get_hw_address (NMDeviceWimax *wimax);
-NM_DEPRECATED_IN_1_2
-NMWimaxNsp *nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax);
-NM_DEPRECATED_IN_1_2
-NMWimaxNsp *nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax,
- const char *path);
-
-NM_DEPRECATED_IN_1_2
-const GPtrArray *nm_device_wimax_get_nsps (NMDeviceWimax *wimax);
-
-NM_DEPRECATED_IN_1_2
-guint nm_device_wimax_get_center_frequency (NMDeviceWimax *self);
-NM_DEPRECATED_IN_1_2
-int nm_device_wimax_get_rssi (NMDeviceWimax *self);
-NM_DEPRECATED_IN_1_2
-int nm_device_wimax_get_cinr (NMDeviceWimax *self);
-NM_DEPRECATED_IN_1_2
-int nm_device_wimax_get_tx_power (NMDeviceWimax *self);
-NM_DEPRECATED_IN_1_2
-const char * nm_device_wimax_get_bsid (NMDeviceWimax *self);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_WIMAX_H */
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c
deleted file mode 100644
index e9b3b30f96..0000000000
--- a/libnm-glib/nm-device.c
+++ /dev/null
@@ -1,2375 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <libudev.h>
-
-#include "NetworkManager.h"
-
-#include "nm-udev-aux/nm-udev-utils.h"
-#include "nm-device-ethernet.h"
-#include "nm-device-adsl.h"
-#include "nm-device-wifi.h"
-#include "nm-device-modem.h"
-#include "nm-device-bt.h"
-#include "nm-device-olpc-mesh.h"
-#include "nm-device-wimax.h"
-#include "nm-device-infiniband.h"
-#include "nm-device-bond.h"
-#include "nm-device-team.h"
-#include "nm-device-bridge.h"
-#include "nm-device-vlan.h"
-#include "nm-device-generic.h"
-#include "nm-device.h"
-#include "nm-device-private.h"
-#include "nm-object-private.h"
-#include "nm-object-cache.h"
-#include "nm-remote-connection.h"
-#include "nm-types.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-utils.h"
-#include "nm-dbus-helpers-private.h"
-
-static GType _nm_device_gtype_for_path (DBusGConnection *connection,
- const char *path);
-static void _nm_device_gtype_for_path_async (DBusGConnection *connection,
- const char *path,
- NMObjectTypeCallbackFunc callback,
- gpointer user_data);
-gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error);
-
-G_DEFINE_TYPE_WITH_CODE (NMDevice, nm_device, NM_TYPE_OBJECT,
- _nm_object_register_type_func (g_define_type_id, _nm_device_gtype_for_path,
- _nm_device_gtype_for_path_async);
- )
-
-#define DBUS_G_TYPE_UINT_STRUCT (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID))
-
-#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *iface;
- char *ip_iface;
- NMDeviceType device_type;
- char *udi;
- char *driver;
- char *driver_version;
- char *firmware_version;
- char *type_description;
- NMDeviceCapabilities capabilities;
- gboolean real;
- gboolean managed;
- gboolean firmware_missing;
- gboolean autoconnect;
- NMIP4Config *ip4_config;
- NMDHCP4Config *dhcp4_config;
- NMIP6Config *ip6_config;
- NMDHCP6Config *dhcp6_config;
- NMDeviceState state;
- NMDeviceState last_seen_state;
- NMDeviceStateReason reason;
-
- NMActiveConnection *active_connection;
- GPtrArray *available_connections;
-
- NMUdevClient *udev_client;
- char *product, *short_product;
- char *vendor, *short_vendor;
- char *description, *bus_name;
-
- char *physical_port_id;
- guint32 mtu;
-} NMDevicePrivate;
-
-enum {
- PROP_0,
- PROP_INTERFACE,
- PROP_UDI,
- PROP_DRIVER,
- PROP_DRIVER_VERSION,
- PROP_FIRMWARE_VERSION,
- PROP_CAPABILITIES,
- PROP_REAL,
- PROP_MANAGED,
- PROP_AUTOCONNECT,
- PROP_FIRMWARE_MISSING,
- PROP_IP4_CONFIG,
- PROP_DHCP4_CONFIG,
- PROP_IP6_CONFIG,
- PROP_STATE,
- PROP_STATE_REASON,
- PROP_PRODUCT,
- PROP_VENDOR,
- PROP_DHCP6_CONFIG,
- PROP_IP_INTERFACE,
- PROP_DEVICE_TYPE,
- PROP_ACTIVE_CONNECTION,
- PROP_AVAILABLE_CONNECTIONS,
- PROP_PHYSICAL_PORT_ID,
- PROP_MTU,
-
- LAST_PROP
-};
-
-enum {
- STATE_CHANGED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/**
- * nm_device_error_quark:
- *
- * Registers an error quark for #NMDevice if necessary.
- *
- * Returns: the error quark used for #NMDevice errors.
- *
- * Since: 0.9.10
- **/
-GQuark
-nm_device_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-error-quark");
- return quark;
-}
-
-static void
-nm_device_init (NMDevice *device)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
-
- priv->state = NM_DEVICE_STATE_UNKNOWN;
- priv->reason = NM_DEVICE_STATE_REASON_NONE;
-}
-
-static gboolean
-demarshal_state_reason (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
-
- if (!G_VALUE_HOLDS (value, DBUS_G_TYPE_UINT_STRUCT))
- return FALSE;
-
- dbus_g_type_struct_get (value,
- 0, &priv->state,
- 1, &priv->reason,
- G_MAXUINT);
-
- _nm_object_queue_notify (object, NM_DEVICE_STATE_REASON);
- return TRUE;
-}
-
-static void
-register_properties (NMDevice *device)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
- const NMPropertiesInfo property_info[] = {
- { NM_DEVICE_UDI, &priv->udi },
- { NM_DEVICE_INTERFACE, &priv->iface },
- { NM_DEVICE_IP_INTERFACE, &priv->ip_iface },
- { NM_DEVICE_DRIVER, &priv->driver },
- { NM_DEVICE_DRIVER_VERSION, &priv->driver_version },
- { NM_DEVICE_FIRMWARE_VERSION, &priv->firmware_version },
- { NM_DEVICE_CAPABILITIES, &priv->capabilities },
- { NM_DEVICE_REAL, &priv->real },
- { NM_DEVICE_MANAGED, &priv->managed },
- { NM_DEVICE_AUTOCONNECT, &priv->autoconnect },
- { NM_DEVICE_FIRMWARE_MISSING, &priv->firmware_missing },
- { NM_DEVICE_IP4_CONFIG, &priv->ip4_config, NULL, NM_TYPE_IP4_CONFIG },
- { NM_DEVICE_DHCP4_CONFIG, &priv->dhcp4_config, NULL, NM_TYPE_DHCP4_CONFIG },
- { NM_DEVICE_IP6_CONFIG, &priv->ip6_config, NULL, NM_TYPE_IP6_CONFIG },
- { NM_DEVICE_DHCP6_CONFIG, &priv->dhcp6_config, NULL, NM_TYPE_DHCP6_CONFIG },
- { NM_DEVICE_STATE, &priv->state },
- { NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason },
- { NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
- { NM_DEVICE_AVAILABLE_CONNECTIONS, &priv->available_connections, NULL, NM_TYPE_REMOTE_CONNECTION },
- { NM_DEVICE_PHYSICAL_PORT_ID, &priv->physical_port_id },
- { NM_DEVICE_MTU, &priv->mtu },
-
- /* Properties that exist in D-Bus but that we don't track */
- { "ip4-address", NULL },
- { "device-type", NULL },
-
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (device),
- priv->proxy,
- property_info);
-}
-
-typedef struct {
- NMDeviceState old_state;
- NMDeviceState new_state;
- NMDeviceStateReason reason;
-} StateChangeData;
-
-static void
-device_state_change_reloaded (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- NMDevice *self = NM_DEVICE (object);
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- StateChangeData *data = user_data;
- NMDeviceState old_state = data->old_state;
- NMDeviceState new_state = data->new_state;
- NMDeviceStateReason reason = data->reason;
-
- g_slice_free (StateChangeData, data);
-
- _nm_object_reload_properties_finish (NM_OBJECT (object), result, NULL);
-
- /* If the device changes state several times in rapid succession, then we'll
- * queue several reload_properties() calls, and there's no guarantee that
- * they'll finish in the right order. In that case, only emit the signal
- * for the last one.
- */
- if (priv->last_seen_state != new_state)
- return;
-
- /* Ensure that nm_device_get_state() will return the right value even if
- * we haven't processed the corresponding PropertiesChanged yet.
- */
- priv->state = new_state;
-
- g_signal_emit (self, signals[STATE_CHANGED], 0,
- new_state, old_state, reason);
-}
-
-static void
-device_state_changed (DBusGProxy *proxy,
- NMDeviceState new_state,
- NMDeviceState old_state,
- NMDeviceStateReason reason,
- gpointer user_data)
-{
- NMDevice *self = NM_DEVICE (user_data);
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
-
- if (old_state != new_state) {
- StateChangeData *data;
-
- /* Our object-valued properties (eg, ip4_config) will still
- * have their old values at this point, because NMObject is
- * in the process of asynchronously reading the new values.
- * Wait for that to finish before emitting the signal.
- */
- priv->last_seen_state = new_state;
-
- data = g_slice_new (StateChangeData);
- data->old_state = old_state;
- data->new_state = new_state;
- data->reason = reason;
- _nm_object_reload_properties_async (NM_OBJECT (user_data),
- device_state_change_reloaded,
- data);
- }
-}
-
-static GType
-_nm_device_gtype_from_dtype (NMDeviceType dtype)
-{
- switch (dtype) {
- case NM_DEVICE_TYPE_VETH:
- case NM_DEVICE_TYPE_ETHERNET:
- return NM_TYPE_DEVICE_ETHERNET;
- case NM_DEVICE_TYPE_WIFI:
- return NM_TYPE_DEVICE_WIFI;
- case NM_DEVICE_TYPE_MODEM:
- return NM_TYPE_DEVICE_MODEM;
- case NM_DEVICE_TYPE_BT:
- return NM_TYPE_DEVICE_BT;
- case NM_DEVICE_TYPE_ADSL:
- return NM_TYPE_DEVICE_ADSL;
- case NM_DEVICE_TYPE_OLPC_MESH:
- return NM_TYPE_DEVICE_OLPC_MESH;
- case NM_DEVICE_TYPE_WIMAX:
- return NM_TYPE_DEVICE_WIMAX;
- case NM_DEVICE_TYPE_INFINIBAND:
- return NM_TYPE_DEVICE_INFINIBAND;
- case NM_DEVICE_TYPE_BOND:
- return NM_TYPE_DEVICE_BOND;
- case NM_DEVICE_TYPE_TEAM:
- return NM_TYPE_DEVICE_TEAM;
- case NM_DEVICE_TYPE_BRIDGE:
- return NM_TYPE_DEVICE_BRIDGE;
- case NM_DEVICE_TYPE_VLAN:
- return NM_TYPE_DEVICE_VLAN;
- case NM_DEVICE_TYPE_GENERIC:
- case NM_DEVICE_TYPE_TUN:
- case NM_DEVICE_TYPE_IP_TUNNEL:
- return NM_TYPE_DEVICE_GENERIC;
- default:
- /* Fall back to NMDeviceGeneric for unknown devices */
- return NM_TYPE_DEVICE_GENERIC;
- }
-}
-
-static void
-constructed (GObject *object)
-{
- NMDevicePrivate *priv;
-
- G_OBJECT_CLASS (nm_device_parent_class)->constructed (object);
-
- priv = NM_DEVICE_GET_PRIVATE (object);
- /* Catch failure of subclasses to call _nm_device_set_device_type() */
- g_warn_if_fail (priv->device_type != NM_DEVICE_TYPE_UNKNOWN);
- /* Catch a subclass setting the wrong type */
- g_warn_if_fail (G_OBJECT_TYPE (object) == _nm_device_gtype_from_dtype (priv->device_type));
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE);
-
- register_properties (NM_DEVICE (object));
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
- G_TYPE_NONE,
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
- G_TYPE_INVALID);
-
- dbus_g_proxy_add_signal (priv->proxy,
- "StateChanged",
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
- G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (priv->proxy, "StateChanged",
- G_CALLBACK (device_state_changed),
- NM_DEVICE (object),
- NULL);
-}
-
-static void
-dispose (GObject *object)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
- g_clear_object (&priv->ip4_config);
- g_clear_object (&priv->dhcp4_config);
- g_clear_object (&priv->ip6_config);
- g_clear_object (&priv->dhcp6_config);
- g_clear_object (&priv->active_connection);
-
- priv->udev_client = nm_udev_client_unref (priv->udev_client);
-
- if (priv->available_connections) {
- int i;
-
- for (i = 0; i < priv->available_connections->len; i++)
- g_object_unref (priv->available_connections->pdata[i]);
- g_ptr_array_free (priv->available_connections, TRUE);
- priv->available_connections = NULL;
- }
-
- G_OBJECT_CLASS (nm_device_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
-
- g_free (priv->iface);
- g_free (priv->ip_iface);
- g_free (priv->udi);
- g_free (priv->driver);
- g_free (priv->driver_version);
- g_free (priv->firmware_version);
- g_free (priv->product);
- g_free (priv->short_product);
- g_free (priv->vendor);
- g_free (priv->short_vendor);
- g_free (priv->description);
- g_free (priv->bus_name);
- g_free (priv->type_description);
- g_free (priv->physical_port_id);
-
- G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDevice *device = NM_DEVICE (object);
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_DEVICE_TYPE:
- g_value_set_uint (value, nm_device_get_device_type (device));
- break;
- case PROP_UDI:
- g_value_set_string (value, nm_device_get_udi (device));
- break;
- case PROP_INTERFACE:
- g_value_set_string (value, nm_device_get_iface (device));
- break;
- case PROP_IP_INTERFACE:
- g_value_set_string (value, nm_device_get_ip_iface (device));
- break;
- case PROP_DRIVER:
- g_value_set_string (value, nm_device_get_driver (device));
- break;
- case PROP_DRIVER_VERSION:
- g_value_set_string (value, nm_device_get_driver_version (device));
- break;
- case PROP_FIRMWARE_VERSION:
- g_value_set_string (value, nm_device_get_firmware_version (device));
- break;
- case PROP_CAPABILITIES:
- g_value_set_uint (value, nm_device_get_capabilities (device));
- break;
- case PROP_REAL:
- g_value_set_boolean (value, nm_device_is_real (device));
- break;
- case PROP_MANAGED:
- g_value_set_boolean (value, nm_device_get_managed (device));
- break;
- case PROP_AUTOCONNECT:
- g_value_set_boolean (value, nm_device_get_autoconnect (device));
- break;
- case PROP_FIRMWARE_MISSING:
- g_value_set_boolean (value, nm_device_get_firmware_missing (device));
- break;
- case PROP_IP4_CONFIG:
- g_value_set_object (value, nm_device_get_ip4_config (device));
- break;
- case PROP_DHCP4_CONFIG:
- g_value_set_object (value, nm_device_get_dhcp4_config (device));
- break;
- case PROP_IP6_CONFIG:
- g_value_set_object (value, nm_device_get_ip6_config (device));
- break;
- case PROP_DHCP6_CONFIG:
- g_value_set_object (value, nm_device_get_dhcp6_config (device));
- break;
- case PROP_STATE:
- g_value_set_uint (value, nm_device_get_state (device));
- break;
- case PROP_STATE_REASON:
- g_value_set_boxed (value,
- dbus_g_type_specialized_construct (DBUS_G_TYPE_UINT_STRUCT));
- dbus_g_type_struct_set (value,
- 0, priv->state,
- 1, priv->reason,
- G_MAXUINT);
- break;
- case PROP_ACTIVE_CONNECTION:
- g_value_set_object (value, nm_device_get_active_connection (device));
- break;
- case PROP_AVAILABLE_CONNECTIONS:
- g_value_set_boxed (value, nm_device_get_available_connections (device));
- break;
- case PROP_PRODUCT:
- g_value_set_string (value, nm_device_get_product (device));
- break;
- case PROP_VENDOR:
- g_value_set_string (value, nm_device_get_vendor (device));
- break;
- case PROP_PHYSICAL_PORT_ID:
- g_value_set_string (value, nm_device_get_physical_port_id (device));
- break;
- case PROP_MTU:
- g_value_set_uint (value, nm_device_get_mtu (device));
- 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)
-{
- NMDevice *self = NM_DEVICE (object);
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- gboolean b;
-
- switch (prop_id) {
- case PROP_DEVICE_TYPE:
- /* construct-only */
- priv->device_type = g_value_get_uint (value);
- break;
- case PROP_MANAGED:
- b = g_value_get_boolean (value);
- if (priv->managed != b)
- nm_device_set_managed (NM_DEVICE (object), b);
- break;
- case PROP_AUTOCONNECT:
- b = g_value_get_boolean (value);
- if (priv->autoconnect != b)
- nm_device_set_autoconnect (NM_DEVICE (object), b);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_device_class_init (NMDeviceClass *device_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (device_class);
-
- g_type_class_add_private (device_class, sizeof (NMDevicePrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->set_property = set_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- device_class->connection_compatible = connection_compatible;
-
- /* properties */
-
- /**
- * NMDevice:interface:
- *
- * The interface of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_INTERFACE,
- g_param_spec_string (NM_DEVICE_INTERFACE, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:ip-interface:
- *
- * The IP interface of the device which should be used for all IP-related
- * operations like addressing and routing.
- **/
- g_object_class_install_property
- (object_class, PROP_IP_INTERFACE,
- g_param_spec_string (NM_DEVICE_IP_INTERFACE, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:device-type:
- *
- * The numeric type of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_DEVICE_TYPE,
- g_param_spec_uint (NM_DEVICE_DEVICE_TYPE, "", "",
- NM_DEVICE_TYPE_UNKNOWN, G_MAXUINT32, NM_DEVICE_TYPE_UNKNOWN,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- /**
- * NMDevice:udi:
- *
- * An operating-system specific device hardware identifier; this is not
- * unique to a specific hardware device across reboots or hotplugs. It
- * is an opaque string which for some device types (Bluetooth, Modem)
- * contains an identifier provided by the underlying hardware service daemon
- * such as Bluez or ModemManager, and clients can use this property to
- * request more information about the device from those services.
- **/
- g_object_class_install_property
- (object_class, PROP_UDI,
- g_param_spec_string (NM_DEVICE_UDI, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:driver:
- *
- * The driver of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_DRIVER,
- g_param_spec_string (NM_DEVICE_DRIVER, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:driver-version:
- *
- * The version of the device driver.
- **/
- g_object_class_install_property
- (object_class, PROP_DRIVER_VERSION,
- g_param_spec_string (NM_DEVICE_DRIVER_VERSION, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:firmware-version:
- *
- * The firmware version of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_FIRMWARE_VERSION,
- g_param_spec_string (NM_DEVICE_FIRMWARE_VERSION, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:capabilities:
- *
- * The capabilities of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_CAPABILITIES,
- g_param_spec_uint (NM_DEVICE_CAPABILITIES, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:real:
- *
- * Whether the device is real or is a placeholder device that could
- * be created automatically by NetworkManager if one of its
- * #NMDevice:available-connections was activated.
- *
- * Since: 1.2
- **/
- g_object_class_install_property
- (object_class, PROP_REAL,
- g_param_spec_boolean (NM_DEVICE_REAL, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:managed:
- *
- * Whether the device is managed by NetworkManager.
- **/
- g_object_class_install_property
- (object_class, PROP_MANAGED,
- g_param_spec_boolean (NM_DEVICE_MANAGED, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:autoconnect:
- *
- * Whether the device can auto-activate a connection.
- **/
- g_object_class_install_property
- (object_class, PROP_AUTOCONNECT,
- g_param_spec_boolean (NM_DEVICE_AUTOCONNECT, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:firmware-missing:
- *
- * When %TRUE indicates the device is likely missing firmware required
- * for its operation.
- **/
- g_object_class_install_property
- (object_class, PROP_FIRMWARE_MISSING,
- g_param_spec_boolean (NM_DEVICE_FIRMWARE_MISSING, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:ip4-config:
- *
- * The #NMIP4Config of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_IP4_CONFIG,
- g_param_spec_object (NM_DEVICE_IP4_CONFIG, "", "",
- NM_TYPE_IP4_CONFIG,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:dhcp4-config:
- *
- * The #NMDHCP4Config of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP4_CONFIG,
- g_param_spec_object (NM_DEVICE_DHCP4_CONFIG, "", "",
- NM_TYPE_DHCP4_CONFIG,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:ip6-config:
- *
- * The #NMIP6Config of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_IP6_CONFIG,
- g_param_spec_object (NM_DEVICE_IP6_CONFIG, "", "",
- NM_TYPE_IP6_CONFIG,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:dhcp6-config:
- *
- * The #NMDHCP6Config of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP6_CONFIG,
- g_param_spec_object (NM_DEVICE_DHCP6_CONFIG, "", "",
- NM_TYPE_DHCP6_CONFIG,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:state:
- *
- * The state of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_STATE,
- g_param_spec_uint (NM_DEVICE_STATE, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:state-reason:
- *
- * The state and reason of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_STATE_REASON,
- g_param_spec_boxed (NM_DEVICE_STATE_REASON, "", "",
- DBUS_G_TYPE_UINT_STRUCT,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:active-connection:
- *
- * The #NMActiveConnection object that "owns" this device during activation.
- **/
- g_object_class_install_property
- (object_class, PROP_ACTIVE_CONNECTION,
- g_param_spec_object (NM_DEVICE_ACTIVE_CONNECTION, "", "",
- NM_TYPE_ACTIVE_CONNECTION,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:available-connections:
- *
- * The available connections (#NMRemoteConnection) of the device
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_AVAILABLE_CONNECTIONS,
- g_param_spec_boxed (NM_DEVICE_AVAILABLE_CONNECTIONS, "", "",
- NM_TYPE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:vendor:
- *
- * The vendor string of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_VENDOR,
- g_param_spec_string (NM_DEVICE_VENDOR, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:product:
- *
- * The product string of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_PRODUCT,
- g_param_spec_string (NM_DEVICE_PRODUCT, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:physical-port-id:
- *
- * The physical port ID of the device. (See
- * nm_device_get_physical_port_id().)
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PHYSICAL_PORT_ID,
- g_param_spec_string (NM_DEVICE_PHYSICAL_PORT_ID, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMDevice:mtu:
- *
- * The MTU of the device.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_MTU,
- g_param_spec_uint (NM_DEVICE_MTU, "", "",
- 0, G_MAXUINT32, 1500,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /* signals */
-
- /**
- * NMDevice::state-changed:
- * @device: the device object that received the signal
- * @new_state: the new state of the device
- * @old_state: the previous state of the device
- * @reason: the reason describing the state change
- *
- * Notifies the state change of a #NMDevice.
- **/
- signals[STATE_CHANGED] =
- g_signal_new ("state-changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMDeviceClass, state_changed),
- NULL, NULL, NULL,
- G_TYPE_NONE, 3,
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
-}
-
-/**
- * _nm_device_set_device_type:
- * @device: the device
- * @dtype: the NM device type
- *
- * Sets the NM device type if it wasn't set during construction. INTERNAL
- * ONLY METHOD.
- **/
-void
-_nm_device_set_device_type (NMDevice *device, NMDeviceType dtype)
-{
- NMDevicePrivate *priv;
-
- g_return_if_fail (device != NULL);
- g_return_if_fail (dtype != NM_DEVICE_TYPE_UNKNOWN);
-
- priv = NM_DEVICE_GET_PRIVATE (device);
- if (priv->device_type == NM_DEVICE_TYPE_UNKNOWN)
- priv->device_type = dtype;
- else
- g_warn_if_fail (dtype == priv->device_type);
-}
-
-NMDeviceType
-_nm_device_type_for_path (DBusGConnection *connection, const char *path)
-{
- DBusGProxy *proxy;
- GError *err = NULL;
- GValue value = G_VALUE_INIT;
-
- proxy = _nm_dbus_new_proxy_for_connection (connection, path, DBUS_INTERFACE_PROPERTIES);
- if (!proxy) {
- g_warning ("%s: couldn't create D-Bus object proxy.", __func__);
- return G_TYPE_INVALID;
- }
-
- if (!dbus_g_proxy_call (proxy,
- "Get", &err,
- G_TYPE_STRING, NM_DBUS_INTERFACE_DEVICE,
- G_TYPE_STRING, "DeviceType",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID)) {
- g_warning ("Error in get_property: %s\n", err->message);
- g_error_free (err);
- g_object_unref (proxy);
- return G_TYPE_INVALID;
- }
- g_object_unref (proxy);
-
- return g_value_get_uint (&value);
-}
-
-static GType
-_nm_device_gtype_for_path (DBusGConnection *connection,
- const char *path)
-{
- return _nm_device_gtype_from_dtype (_nm_device_type_for_path (connection, path));
-}
-
-/**
- * nm_device_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the device
- *
- * Creates a new #NMDevice.
- *
- * Returns: (transfer full): a new device
- **/
-GObject *
-nm_device_new (DBusGConnection *connection, const char *path)
-{
- GType dtype;
- NMDevice *device = NULL;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- dtype = _nm_device_gtype_for_path (connection, path);
- if (dtype == G_TYPE_INVALID)
- return NULL;
-
- device = (NMDevice *) g_object_new (dtype,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- _nm_object_ensure_inited (NM_OBJECT (device));
- return G_OBJECT (device);
-}
-
-typedef struct {
- DBusGConnection *connection;
- NMObjectTypeCallbackFunc callback;
- gpointer user_data;
-} NMDeviceAsyncData;
-
-static void
-async_got_type (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- NMDeviceAsyncData *async_data = user_data;
- GValue value = G_VALUE_INIT;
- const char *path = dbus_g_proxy_get_path (proxy);
- GError *error = NULL;
- GType type;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID)) {
- NMDeviceType dtype;
-
- dtype = g_value_get_uint (&value);
- type = _nm_device_gtype_from_dtype (dtype);
- } else {
- g_warning ("%s: could not read properties for %s: %s", __func__, path, error->message);
- g_error_free (error);
- type = G_TYPE_INVALID;
- }
-
- async_data->callback (type, async_data->user_data);
- g_object_unref (proxy);
- g_slice_free (NMDeviceAsyncData, async_data);
-}
-
-static void
-_nm_device_gtype_for_path_async (DBusGConnection *connection,
- const char *path,
- NMObjectTypeCallbackFunc callback,
- gpointer user_data)
-{
- NMDeviceAsyncData *async_data;
- DBusGProxy *proxy;
-
- async_data = g_slice_new (NMDeviceAsyncData);
- async_data->connection = connection;
- async_data->callback = callback;
- async_data->user_data = user_data;
-
- proxy = _nm_dbus_new_proxy_for_connection (connection, path, DBUS_INTERFACE_PROPERTIES);
- dbus_g_proxy_begin_call (proxy, "Get",
- async_got_type, async_data, NULL,
- G_TYPE_STRING, NM_DBUS_INTERFACE_DEVICE,
- G_TYPE_STRING, "DeviceType",
- G_TYPE_INVALID);
-}
-
-/**
- * nm_device_get_iface:
- * @device: a #NMDevice
- *
- * Gets the interface name of the #NMDevice.
- *
- * Returns: the interface of the device. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_get_iface (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->iface;
-}
-
-/**
- * nm_device_get_ip_iface:
- * @device: a #NMDevice
- *
- * Gets the IP interface name of the #NMDevice over which IP traffic flows
- * when the device is in the ACTIVATED state.
- *
- * Returns: the IP traffic interface of the device. This is the internal string
- * used by the device, and must not be modified.
- **/
-const char *
-nm_device_get_ip_iface (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->ip_iface;
-}
-
-/**
- * nm_device_get_device_type:
- * @device: a #NMDevice
- *
- * Returns the numeric type of the #NMDevice, ie Ethernet, Wi-Fi, etc.
- *
- * Returns: the device type
- **/
-NMDeviceType
-nm_device_get_device_type (NMDevice *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE (self), NM_DEVICE_TYPE_UNKNOWN);
-
- return NM_DEVICE_GET_PRIVATE (self)->device_type;
-}
-
-/**
- * nm_device_get_udi:
- * @device: a #NMDevice
- *
- * Gets the Unique Device Identifier of the #NMDevice.
- *
- * Returns: the Unique Device Identifier of the device. This identifier may be
- * used to gather more information about the device from various operating
- * system services like udev or sysfs.
- **/
-const char *
-nm_device_get_udi (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->udi;
-}
-
-/**
- * nm_device_get_driver:
- * @device: a #NMDevice
- *
- * Gets the driver of the #NMDevice.
- *
- * Returns: the driver of the device. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_get_driver (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->driver;
-}
-
-/**
- * nm_device_get_driver_version:
- * @device: a #NMDevice
- *
- * Gets the driver version of the #NMDevice.
- *
- * Returns: the version of the device driver. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_get_driver_version (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->driver_version;
-}
-
-/**
- * nm_device_get_firmware_version:
- * @device: a #NMDevice
- *
- * Gets the firmware version of the #NMDevice.
- *
- * Returns: the firmware version of the device. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_get_firmware_version (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->firmware_version;
-}
-
-/**
- * nm_device_get_type_description:
- * @device: a #NMDevice
- *
- * Gets a (non-localized) description of the type of device that
- * @device is.
- *
- * Returns: the type description of the device. This is the internal
- * string used by the device, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_device_get_type_description (NMDevice *device)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
- const char *desc, *typename;
-
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- if (priv->type_description)
- return priv->type_description;
-
- if (NM_DEVICE_GET_CLASS (device)->get_type_description) {
- desc = NM_DEVICE_GET_CLASS (device)->get_type_description (device);
- if (desc)
- return desc;
- }
-
- typename = G_OBJECT_TYPE_NAME (device);
- if (g_str_has_prefix (typename, "NMDevice"))
- typename += 8;
- priv->type_description = g_ascii_strdown (typename, -1);
-
- return priv->type_description;
-}
-
-/**
- * nm_device_get_hw_address:
- * @device: a #NMDevice
- *
- * Gets the current a hardware address (MAC) for the @device.
- *
- * Returns: the current MAC of the device, or %NULL.
- * This is the internal string used by the device, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_device_get_hw_address (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- if (NM_DEVICE_GET_CLASS (device)->get_hw_address)
- return NM_DEVICE_GET_CLASS (device)->get_hw_address (device);
-
- return NULL;
-}
-
-/**
- * nm_device_get_capabilities:
- * @device: a #NMDevice
- *
- * Gets the device' capabilities.
- *
- * Returns: the capabilities
- **/
-NMDeviceCapabilities
-nm_device_get_capabilities (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->capabilities;
-}
-
-/**
- * nm_device_get_managed:
- * @device: a #NMDevice
- *
- * Whether the #NMDevice is managed by NetworkManager.
- *
- * Returns: %TRUE if the device is managed by NetworkManager
- **/
-gboolean
-nm_device_get_managed (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->managed;
-}
-
-/**
- * nm_device_set_managed:
- * @device: a #NMDevice
- * @managed: %TRUE to make the device managed by NetworkManager.
- *
- * Enables or disables management of #NMDevice by NetworkManager.
- *
- * Since: 1.2
- **/
-void
-nm_device_set_managed (NMDevice *device, gboolean managed)
-{
- GValue value = G_VALUE_INIT;
-
- g_return_if_fail (NM_IS_DEVICE (device));
-
- managed = !!managed;
-
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, managed);
-
- NM_DEVICE_GET_PRIVATE (device)->managed = managed;
-
- _nm_object_set_property (NM_OBJECT (device),
- NM_DBUS_INTERFACE_DEVICE,
- "Managed",
- &value);
-}
-
-/**
- * nm_device_get_autoconnect:
- * @device: a #NMDevice
- *
- * Whether the #NMDevice can be autoconnected.
- *
- * Returns: %TRUE if the device is allowed to be autoconnected
- **/
-gboolean
-nm_device_get_autoconnect (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->autoconnect;
-}
-
-/**
- * nm_device_set_autoconnect:
- * @device: a #NMDevice
- * @autoconnect: %TRUE to enable autoconnecting
- *
- * Enables or disables automatic activation of the #NMDevice.
- **/
-void
-nm_device_set_autoconnect (NMDevice *device, gboolean autoconnect)
-{
- GValue value = G_VALUE_INIT;
-
- g_return_if_fail (NM_IS_DEVICE (device));
-
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, autoconnect);
-
- NM_DEVICE_GET_PRIVATE (device)->autoconnect = autoconnect;
-
- _nm_object_set_property (NM_OBJECT (device),
- NM_DBUS_INTERFACE_DEVICE,
- "Autoconnect",
- &value);
-}
-
-/**
- * nm_device_get_firmware_missing:
- * @device: a #NMDevice
- *
- * Indicates that firmware required for the device's operation is likely
- * to be missing.
- *
- * Returns: %TRUE if firmware required for the device's operation is likely
- * to be missing.
- **/
-gboolean
-nm_device_get_firmware_missing (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->firmware_missing;
-}
-
-/**
- * nm_device_get_ip4_config:
- * @device: a #NMDevice
- *
- * Gets the current #NMIP4Config associated with the #NMDevice.
- *
- * Note that as of NetworkManager 0.9.10, you can alternatively use
- * nm_active_connection_get_ip4_config(), which also works with VPN
- * connections.
- *
- * Returns: (transfer none): the #NMIP4Config or %NULL if the device is not activated.
- **/
-NMIP4Config *
-nm_device_get_ip4_config (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->ip4_config;
-}
-
-/**
- * nm_device_get_dhcp4_config:
- * @device: a #NMDevice
- *
- * Gets the current #NMDHCP4Config associated with the #NMDevice.
- *
- * Note that as of NetworkManager 0.9.10, you can alternatively use
- * nm_active_connection_get_dhcp4_config(), which also works with VPN
- * connections.
- *
- * Returns: (transfer none): the #NMDHCP4Config or %NULL if the device is not activated or not
- * using DHCP.
- **/
-NMDHCP4Config *
-nm_device_get_dhcp4_config (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->dhcp4_config;
-}
-
-/**
- * nm_device_get_ip6_config:
- * @device: a #NMDevice
- *
- * Gets the current #NMIP6Config associated with the #NMDevice.
- *
- * Note that as of NetworkManager 0.9.10, you can alternatively use
- * nm_active_connection_get_ip6_config(), which also works with VPN
- * connections.
- *
- * Returns: (transfer none): the #NMIP6Config or %NULL if the device is not activated.
- **/
-NMIP6Config *
-nm_device_get_ip6_config (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->ip6_config;
-}
-
-/**
- * nm_device_get_dhcp6_config:
- * @device: a #NMDevice
- *
- * Gets the current #NMDHCP6Config associated with the #NMDevice.
- *
- * Note that as of NetworkManager 0.9.10, you can alternatively use
- * nm_active_connection_get_dhcp6_config(), which also works with VPN
- * connections.
- *
- * Returns: (transfer none): the #NMDHCP6Config or %NULL if the device is not activated or not
- * using DHCP.
- **/
-NMDHCP6Config *
-nm_device_get_dhcp6_config (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->dhcp6_config;
-}
-
-/**
- * nm_device_get_state:
- * @device: a #NMDevice
- *
- * Gets the current #NMDevice state.
- *
- * Returns: the current device state
- **/
-NMDeviceState
-nm_device_get_state (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->state;
-}
-
-/**
- * nm_device_get_state_reason:
- * @device: a #NMDevice
- * @reason: (out) (allow-none): location to store reason (#NMDeviceStateReason), or %NULL
- *
- * Gets the current #NMDevice state (return value) and the reason for entering
- * the state (@reason argument).
- *
- * Returns: the current device state
- **/
-NMDeviceState
-nm_device_get_state_reason (NMDevice *device, NMDeviceStateReason *reason)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- if (reason)
- *reason = NM_DEVICE_GET_PRIVATE (device)->reason;
- return NM_DEVICE_GET_PRIVATE (device)->state;
-}
-
-/**
- * nm_device_get_active_connection:
- * @device: a #NMDevice
- *
- * Gets the #NMActiveConnection object which owns this device during activation.
- *
- * Returns: (transfer none): the #NMActiveConnection or %NULL if the device is
- * not part of an active connection
- **/
-NMActiveConnection *
-nm_device_get_active_connection (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->active_connection;
-}
-
-/**
- * nm_device_get_available_connections:
- * @device: a #NMDevice
- *
- * Gets the #NMRemoteConnections currently known to the daemon that could
- * be activated on @device.
- *
- * Returns: (element-type NMRemoteConnection): the #GPtrArray
- * containing #NMRemoteConnections. This is the internal copy used by
- * the connection, and must not be modified.
- *
- * Since: 0.9.8
- **/
-const GPtrArray *
-nm_device_get_available_connections (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return handle_ptr_array_return (NM_DEVICE_GET_PRIVATE (device)->available_connections);
-}
-
-static gboolean
-ensure_udev_client (NMDevice *device)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
-
- if (!priv->udev_client) {
- priv->udev_client = nm_udev_client_new ((const char *[]) { "net", "tty", NULL },
- NULL, NULL);
- }
- return !!priv->udev_client;
-}
-
-static char *
-_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);
- struct udev_device *udev_device, *tmpdev;
- const char *ifname;
- guint32 count = 0;
- char *enc_value = NULL, *db_value = NULL;
-
- if (!ensure_udev_client (device))
- return NULL;
-
- ifname = nm_device_get_iface (device);
- if (!ifname)
- return NULL;
-
- udev_device = udev_device_new_from_subsystem_sysname (nm_udev_client_get_udev (priv->udev_client), "net", ifname);
- if (!udev_device) {
- udev_device = udev_device_new_from_subsystem_sysname (nm_udev_client_get_udev (priv->udev_client), "tty", ifname);
- if (!udev_device)
- return NULL;
- }
- /* Walk up the chain of the device and its parents a few steps to grab
- * vendor and device ID information off it.
- */
- tmpdev = udev_device;
- while ((count++ < 3) && tmpdev && !enc_value) {
- if (!enc_value)
- enc_value = nm_udev_utils_property_decode_cp (udev_device_get_property_value (tmpdev, enc_prop));
- if (!db_value)
- db_value = g_strdup (udev_device_get_property_value (tmpdev, db_prop));
-
- tmpdev = udev_device_get_parent (tmpdev);
- }
- udev_device_unref (udev_device);
-
- /* Prefer the encoded value which comes directly from the device
- * over the hwdata database value.
- */
- if (enc_value) {
- g_free (db_value);
- return enc_value;
- }
-
- return db_value;
-}
-
-/**
- * nm_device_get_product:
- * @device: a #NMDevice
- *
- * Gets the product string of the #NMDevice.
- *
- * Returns: the product name of the device. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_get_product (NMDevice *device)
-{
- NMDevicePrivate *priv;
-
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- priv = NM_DEVICE_GET_PRIVATE (device);
- if (!priv->product) {
- priv->product = _get_udev_property (device, "ID_MODEL_ENC", "ID_MODEL_FROM_DATABASE");
- if (!priv->product) {
- /* Sometimes ID_PRODUCT_FROM_DATABASE is used? */
- priv->product = _get_udev_property (device, "ID_MODEL_ENC", "ID_PRODUCT_FROM_DATABASE");
- }
- _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_PRODUCT);
- }
- return priv->product;
-}
-
-/**
- * nm_device_get_vendor:
- * @device: a #NMDevice
- *
- * Gets the vendor string of the #NMDevice.
- *
- * Returns: the vendor name of the device. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_device_get_vendor (NMDevice *device)
-{
- NMDevicePrivate *priv;
-
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- priv = NM_DEVICE_GET_PRIVATE (device);
- if (!priv->vendor) {
- priv->vendor = _get_udev_property (device, "ID_VENDOR_ENC", "ID_VENDOR_FROM_DATABASE");
- _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_VENDOR);
- }
- return priv->vendor;
-}
-
-static const char * const ignored_words[] = {
- "Semiconductor",
- "Components",
- "Corporation",
- "Communications",
- "Company",
- "Corp.",
- "Corp",
- "Co.",
- "Inc.",
- "Inc",
- "Incorporated",
- "Ltd.",
- "Limited.",
- "Intel?",
- "chipset",
- "adapter",
- "[hex]",
- "NDIS",
- "Module",
- NULL
-};
-
-static const char * const ignored_phrases[] = {
- "Multiprotocol MAC/baseband processor",
- "Wireless LAN Controller",
- "Wireless LAN Adapter",
- "Wireless Adapter",
- "Network Connection",
- "Wireless Cardbus Adapter",
- "Wireless CardBus Adapter",
- "54 Mbps Wireless PC Card",
- "Wireless PC Card",
- "Wireless PC",
- "PC Card with XJACK(r) Antenna",
- "Wireless cardbus",
- "Wireless LAN PC Card",
- "Technology Group Ltd.",
- "Communication S.p.A.",
- "Business Mobile Networks BV",
- "Mobile Broadband Minicard Composite Device",
- "Mobile Communications AB",
- "(PC-Suite Mode)",
- NULL
-};
-
-static char *
-fixup_desc_string (const char *desc)
-{
- char *p, *temp;
- char **words, **item;
- GString *str;
- int i;
-
- if (!desc)
- return NULL;
-
- p = temp = g_strdup (desc);
- while (*p) {
- if (*p == '_' || *p == ',')
- *p = ' ';
- p++;
- }
-
- /* Attempt to shorten ID by ignoring certain phrases */
- for (i = 0; ignored_phrases[i]; i++) {
- p = strstr (temp, ignored_phrases[i]);
- if (p) {
- guint32 ignored_len = strlen (ignored_phrases[i]);
-
- memmove (p, p + ignored_len, strlen (p + ignored_len) + 1); /* +1 for the \0 */
- }
- }
-
- /* Attempt to shorten ID by ignoring certain individual words */
- words = g_strsplit (temp, " ", 0);
- str = g_string_new_len (NULL, strlen (temp));
- g_free (temp);
-
- for (item = words; *item; item++) {
- gboolean ignore = FALSE;
-
- if (**item == '\0')
- continue;
-
- for (i = 0; ignored_words[i]; i++) {
- if (!strcmp (*item, ignored_words[i])) {
- ignore = TRUE;
- break;
- }
- }
-
- if (!ignore) {
- if (str->len)
- g_string_append_c (str, ' ');
- g_string_append (str, *item);
- }
- }
- g_strfreev (words);
-
- temp = str->str;
- g_string_free (str, FALSE);
-
- return temp;
-}
-
-static void
-get_description (NMDevice *device)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
- const char *dev_product;
- const char *dev_vendor;
- char *pdown;
- char *vdown;
- GString *str;
- GParamSpec *name_prop;
-
- dev_product = nm_device_get_product (device);
- priv->short_product = fixup_desc_string (dev_product);
-
- dev_vendor = nm_device_get_vendor (device);
- priv->short_vendor = fixup_desc_string (dev_vendor);
-
- /* Grab device's preferred name, if any */
- name_prop = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (device)), "name");
- if (name_prop) {
- g_object_get (device, "name", &priv->description, NULL);
- if (priv->description && priv->description[0])
- return;
- g_clear_pointer (&priv->description, g_free);
- }
-
- if (!dev_product || !dev_vendor) {
- priv->description = g_strdup (nm_device_get_iface (device));
- return;
- }
-
- str = g_string_new_len (NULL, strlen (priv->short_vendor) + strlen (priv->short_product) + 1);
-
- /* Another quick hack; if all of the fixed up vendor string
- * is found in product, ignore the vendor.
- */
- pdown = g_ascii_strdown (priv->short_product, -1);
- vdown = g_ascii_strdown (priv->short_vendor, -1);
- if (!strstr (pdown, vdown)) {
- g_string_append (str, priv->short_vendor);
- g_string_append_c (str, ' ');
- }
- g_free (pdown);
- g_free (vdown);
-
- g_string_append (str, priv->short_product);
-
- priv->description = g_string_free (str, FALSE);
-}
-
-static const char *
-get_short_vendor (NMDevice *device)
-{
- NMDevicePrivate *priv;
-
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- priv = NM_DEVICE_GET_PRIVATE (device);
-
- if (!priv->description)
- get_description (device);
-
- return priv->short_vendor;
-}
-
-/**
- * nm_device_get_description:
- * @device: an #NMDevice
- *
- * Gets a description of @device, based on its vendor and product names.
- *
- * Returns: a description of @device. If either the vendor or the
- * product name is unknown, this returns the interface name.
- *
- * Since: 0.9.10
- */
-const char *
-nm_device_get_description (NMDevice *device)
-{
- NMDevicePrivate *priv;
-
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- priv = NM_DEVICE_GET_PRIVATE (device);
-
- if (!priv->description)
- get_description (device);
-
- return priv->description;
-}
-
-static const char *
-get_type_name (NMDevice *device)
-{
- switch (nm_device_get_device_type (device)) {
- case NM_DEVICE_TYPE_ETHERNET:
- return _("Ethernet");
- case NM_DEVICE_TYPE_WIFI:
- return _("Wi-Fi");
- case NM_DEVICE_TYPE_BT:
- return _("Bluetooth");
- case NM_DEVICE_TYPE_OLPC_MESH:
- return _("OLPC Mesh");
- case NM_DEVICE_TYPE_WIMAX:
- return _("WiMAX");
- case NM_DEVICE_TYPE_MODEM:
- return _("Mobile Broadband");
- case NM_DEVICE_TYPE_INFINIBAND:
- return _("InfiniBand");
- case NM_DEVICE_TYPE_BOND:
- return _("Bond");
- case NM_DEVICE_TYPE_TEAM:
- return _("Team");
- case NM_DEVICE_TYPE_BRIDGE:
- return _("Bridge");
- case NM_DEVICE_TYPE_VLAN:
- return _("VLAN");
- case NM_DEVICE_TYPE_ADSL:
- return _("ADSL");
- case NM_DEVICE_TYPE_MACVLAN:
- return _("MACVLAN");
- case NM_DEVICE_TYPE_VXLAN:
- return _("VXLAN");
- case NM_DEVICE_TYPE_IP_TUNNEL:
- return _("IPTunnel");
- case NM_DEVICE_TYPE_TUN:
- return _("Tun");
- case NM_DEVICE_TYPE_VETH:
- return _("Veth");
- case NM_DEVICE_TYPE_GENERIC:
- case NM_DEVICE_TYPE_UNUSED1:
- case NM_DEVICE_TYPE_UNUSED2:
- case NM_DEVICE_TYPE_UNKNOWN:
- break;
- }
- return _("Unknown");
-}
-
-static char *
-get_device_type_name_with_iface (NMDevice *device)
-{
- const char *type_name = get_type_name (device);
-
- switch (nm_device_get_device_type (device)) {
- case NM_DEVICE_TYPE_BOND:
- case NM_DEVICE_TYPE_TEAM:
- case NM_DEVICE_TYPE_BRIDGE:
- case NM_DEVICE_TYPE_VLAN:
- return g_strdup_printf ("%s (%s)", type_name, nm_device_get_iface (device));
- default:
- return g_strdup (type_name);
- }
-}
-
-static char *
-get_device_generic_type_name_with_iface (NMDevice *device)
-{
- switch (nm_device_get_device_type (device)) {
- case NM_DEVICE_TYPE_ETHERNET:
- case NM_DEVICE_TYPE_INFINIBAND:
- return g_strdup (_("Wired"));
- default:
- return get_device_type_name_with_iface (device);
- }
-}
-
-static const char *
-get_bus_name (NMDevice *device)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
- struct udev_device *udevice;
- const char *ifname, *bus;
-
- if (priv->bus_name)
- goto out;
-
- if (!ensure_udev_client (device))
- return NULL;
-
- ifname = nm_device_get_iface (device);
- if (!ifname)
- return NULL;
-
- udevice = udev_device_new_from_subsystem_sysname (nm_udev_client_get_udev (priv->udev_client), "net", ifname);
- if (!udevice)
- udevice = udev_device_new_from_subsystem_sysname (nm_udev_client_get_udev (priv->udev_client), "tty", ifname);
- if (!udevice)
- return NULL;
-
- bus = udev_device_get_property_value (udevice, "ID_BUS");
- if (!g_strcmp0 (bus, "pci"))
- priv->bus_name = g_strdup (_("PCI"));
- else if (!g_strcmp0 (bus, "usb"))
- priv->bus_name = g_strdup (_("USB"));
- else {
- /* Use "" instead of NULL so we can tell later that we've
- * already tried.
- */
- priv->bus_name = g_strdup ("");
- }
- udev_device_unref (udevice);
-
-out:
- if (*priv->bus_name)
- return priv->bus_name;
- else
- return NULL;
-}
-
-static gboolean
-find_duplicates (char **names,
- gboolean *duplicates,
- int num_devices)
-{
- int i, j;
- gboolean found_any = FALSE;
-
- memset (duplicates, 0, num_devices * sizeof (gboolean));
- for (i = 0; i < num_devices; i++) {
- if (duplicates[i])
- continue;
- for (j = i + 1; j < num_devices; j++) {
- if (duplicates[j])
- continue;
- if (!strcmp (names[i], names[j]))
- duplicates[i] = duplicates[j] = found_any = TRUE;
- }
- }
-
- return found_any;
-}
-
-/**
- * nm_device_disambiguate_names:
- * @devices: (array length=num_devices): an array of #NMDevice
- * @num_devices: length of @devices
- *
- * Generates a list of short-ish unique presentation names for the
- * devices in @devices.
- *
- * Returns: (transfer full) (array zero-terminated=1): the device names
- *
- * Since: 0.9.10
- */
-char **
-nm_device_disambiguate_names (NMDevice **devices,
- int num_devices)
-{
- char **names;
- gboolean *duplicates;
- int i;
-
- names = g_new (char *, num_devices + 1);
- duplicates = g_new (gboolean, num_devices);
-
- /* Generic device name */
- for (i = 0; i < num_devices; i++)
- names[i] = get_device_generic_type_name_with_iface (devices[i]);
- if (!find_duplicates (names, duplicates, num_devices))
- goto done;
-
- /* Try specific names (eg, "Ethernet" and "InfiniBand" rather
- * than "Wired")
- */
- for (i = 0; i < num_devices; i++) {
- if (duplicates[i]) {
- g_free (names[i]);
- names[i] = get_device_type_name_with_iface (devices[i]);
- }
- }
- if (!find_duplicates (names, duplicates, num_devices))
- goto done;
-
- /* Try prefixing bus name (eg, "PCI Ethernet" vs "USB Ethernet") */
- for (i = 0; i < num_devices; i++) {
- if (duplicates[i]) {
- const char *bus = get_bus_name (devices[i]);
- char *name;
-
- if (!bus)
- continue;
-
- g_free (names[i]);
- name = get_device_type_name_with_iface (devices[i]);
- /* TRANSLATORS: the first %s is a bus name (eg, "USB") or
- * product name, the second is a device type (eg,
- * "Ethernet"). You can change this to something like
- * "%2$s (%1$s)" if there's no grammatical way to combine
- * the strings otherwise.
- */
- names[i] = g_strdup_printf (C_("long device name", "%s %s"),
- bus, name);
- g_free (name);
- }
- }
- if (!find_duplicates (names, duplicates, num_devices))
- goto done;
-
- /* Try prefixing vendor name */
- for (i = 0; i < num_devices; i++) {
- if (duplicates[i]) {
- const char *vendor = get_short_vendor (devices[i]);
- char *name;
-
- if (!vendor)
- continue;
-
- g_free (names[i]);
- name = get_device_type_name_with_iface (devices[i]);
- names[i] = g_strdup_printf (C_("long device name", "%s %s"),
- vendor,
- get_type_name (devices[i]));
- g_free (name);
- }
- }
- if (!find_duplicates (names, duplicates, num_devices))
- goto done;
-
- /* We have multiple identical network cards, so we have to differentiate
- * them by interface name.
- */
- for (i = 0; i < num_devices; i++) {
- if (duplicates[i]) {
- const char *interface = nm_device_get_iface (devices[i]);
-
- if (!interface)
- continue;
-
- g_free (names[i]);
- names[i] = g_strdup_printf ("%s (%s)",
- get_type_name (devices[i]),
- interface);
- }
- }
-
-done:
- g_free (duplicates);
- names[num_devices] = NULL;
- return names;
-}
-
-/**
- * nm_device_get_physical_port_id:
- * @device: a #NMDevice
- *
- * Gets the physical port ID of the #NMDevice. If non-%NULL, this is
- * an opaque string that can be used to recognize when
- * seemingly-unrelated #NMDevices are actually just different virtual
- * ports on a single physical port. (Eg, NPAR / SR-IOV.)
- *
- * Returns: the physical port ID of the device, or %NULL if the port
- * ID is unknown. This is the internal string used by the device and
- * must not be modified.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_device_get_physical_port_id (NMDevice *device)
-{
- NMDevicePrivate *priv;
-
- g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
-
- priv = NM_DEVICE_GET_PRIVATE (device);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- if (priv->physical_port_id && *priv->physical_port_id)
- return priv->physical_port_id;
- else
- return NULL;
-}
-
-/**
- * nm_device_get_mtu:
- * @device: a #NMDevice
- *
- * Gets the MTU of the #NMDevice.
- *
- * Returns: the MTU of the device in bytes.
- *
- * Since: 0.9.10
- **/
-guint32
-nm_device_get_mtu (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->mtu;
-}
-
-/**
- * nm_device_is_real:
- * @device: a #NMDevice
- *
- * Returns: %TRUE if the device exists, or %FALSE if it is a placeholder device
- * that could be automatically created by NetworkManager if one of its
- * #NMDevice:available-connections was activated.
- *
- * Since: 1.2
- **/
-gboolean
-nm_device_is_real (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return NM_DEVICE_GET_PRIVATE (device)->real;
-}
-
-/**
- * nm_device_is_software:
- * @device: a #NMDevice
- *
- * Whether the device is a software device.
- *
- * Returns: %TRUE if @device is a software device, %FALSE if it is a hardware device.
- *
- * Since: 1.0
- **/
-gboolean
-nm_device_is_software (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
-
- _nm_object_ensure_inited (NM_OBJECT (device));
- return !!(NM_DEVICE_GET_PRIVATE (device)->capabilities & NM_DEVICE_CAP_IS_SOFTWARE);
-}
-
-typedef struct {
- NMDevice *device;
- NMDeviceCallbackFn fn;
- gpointer user_data;
- const char *method;
-} DeviceCallbackInfo;
-
-static void
-device_operation_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- DeviceCallbackInfo *info = user_data;
- GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_INVALID);
- if (info->fn)
- info->fn (info->device, error, info->user_data);
- else if (error) {
- g_warning ("%s: device %s %s failed: %s",
- __func__,
- nm_object_get_path (NM_OBJECT (info->device)),
- info->method,
- NM_G_ERROR_MSG (error));
- }
- g_clear_error (&error);
-
- g_object_unref (info->device);
- g_slice_free (DeviceCallbackInfo, info);
-}
-
-/**
- * nm_device_disconnect:
- * @device: a #NMDevice
- * @callback: (scope async) (allow-none): callback to be called when disconnect
- * operation completes
- * @user_data: (closure): caller-specific data passed to @callback
- *
- * Disconnects the device if currently connected, and prevents the device from
- * automatically connecting to networks until the next manual network connection
- * request.
- **/
-void
-nm_device_disconnect (NMDevice *device,
- NMDeviceCallbackFn callback,
- gpointer user_data)
-{
- DeviceCallbackInfo *info;
-
- g_return_if_fail (NM_IS_DEVICE (device));
-
- info = g_slice_new (DeviceCallbackInfo);
- info->fn = callback;
- info->user_data = user_data;
- info->method = "Disconnect";
- info->device = g_object_ref (device);
-
- dbus_g_proxy_begin_call (NM_DEVICE_GET_PRIVATE (device)->proxy, "Disconnect",
- device_operation_cb, info, NULL,
- G_TYPE_INVALID);
-}
-
-/**
- * nm_device_delete:
- * @device: a #NMDevice
- * @callback: (scope async) (allow-none): callback to be called when delete
- * operation completes
- * @user_data: (closure): caller-specific data passed to @callback
- *
- * Deletes the software device. Hardware devices can't be deleted.
- *
- * Since: 1.0
- **/
-void
-nm_device_delete (NMDevice *device,
- NMDeviceCallbackFn callback,
- gpointer user_data)
-{
- DeviceCallbackInfo *info;
-
- g_return_if_fail (NM_IS_DEVICE (device));
-
- info = g_slice_new (DeviceCallbackInfo);
- info->fn = callback;
- info->user_data = user_data;
- info->method = "Delete";
- info->device = g_object_ref (device);
-
- dbus_g_proxy_begin_call (NM_DEVICE_GET_PRIVATE (device)->proxy, "Delete",
- device_operation_cb, info, NULL,
- G_TYPE_INVALID);
-}
-
-/**
- * nm_device_connection_valid:
- * @device: an #NMDevice to validate @connection against
- * @connection: an #NMConnection to validate against @device
- *
- * Validates a given connection for a given #NMDevice object and returns
- * whether the connection may be activated with the device. For example if
- * @device is a Wi-Fi device that supports only WEP encryption, the connection
- * will only be valid if it is a Wi-Fi connection which describes a WEP or open
- * network, and will not be valid if it describes a WPA network, or if it is
- * an Ethernet, Bluetooth, WWAN, etc connection that is incompatible with the
- * device.
- *
- * Returns: %TRUE if the connection may be activated with this device, %FALSE
- * if is incompatible with the device's capabilities and characteristics.
- **/
-gboolean
-nm_device_connection_valid (NMDevice *device, NMConnection *connection)
-{
- return nm_device_connection_compatible (device, connection, NULL);
-}
-
-gboolean
-connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
- const char *config_iface, *device_iface;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
-
- config_iface = nm_setting_connection_get_interface_name (s_con);
- device_iface = nm_device_get_iface (device);
- if (config_iface && g_strcmp0 (config_iface, device_iface) != 0) {
- g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INTERFACE_MISMATCH,
- "The interface names of the device and the connection didn't match.");
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- * nm_device_connection_compatible:
- * @device: an #NMDevice to validate @connection against
- * @connection: an #NMConnection to validate against @device
- * @error: return location for a #GError, or %NULL
- *
- * Validates a given connection for a given #NMDevice object and returns
- * whether the connection may be activated with the device. For example if
- * @device is a Wi-Fi device that supports only WEP encryption, the connection
- * will only be valid if it is a Wi-Fi connection which describes a WEP or open
- * network, and will not be valid if it describes a WPA network, or if it is
- * an Ethernet, Bluetooth, WWAN, etc connection that is incompatible with the
- * device.
- *
- * This function does the same as nm_device_connection_valid(), i.e. checking
- * compatibility of the given device and connection. But, in addition, it sets
- * GError when FALSE is returned.
- *
- * Returns: %TRUE if the connection may be activated with this device, %FALSE
- * if is incompatible with the device's capabilities and characteristics.
- **/
-gboolean
-nm_device_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- return NM_DEVICE_GET_CLASS (device)->connection_compatible (device, connection, error);
-}
-
-/**
- * nm_device_filter_connections:
- * @device: an #NMDevice to filter connections for
- * @connections: (element-type NMConnection): a list of #NMConnection objects to filter
- *
- * Filters a given list of connections for a given #NMDevice object and return
- * connections which may be activated with the device. For example if @device
- * is a Wi-Fi device that supports only WEP encryption, the returned list will
- * contain any Wi-Fi connections in @connections that allow connection to
- * unencrypted or WEP-enabled SSIDs. The returned list will not contain
- * Ethernet, Bluetooth, Wi-Fi WPA connections, or any other connection that is
- * incompatible with the device. To get the full list of connections see
- * nm_remote_settings_list_connections().
- *
- * Returns: (transfer container) (element-type NMConnection): a
- * list of #NMConnection objects that could be activated with the given @device.
- * The elements of the list are owned by their creator and should not be freed
- * by the caller, but the returned list itself is owned by the caller and should
- * be freed with g_slist_free() when it is no longer required.
- **/
-GSList *
-nm_device_filter_connections (NMDevice *device, const GSList *connections)
-{
- GSList *filtered = NULL;
- const GSList *iter;
-
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *candidate = NM_CONNECTION (iter->data);
-
- /* Connection applies to this device */
- if (nm_device_connection_valid (device, candidate))
- filtered = g_slist_prepend (filtered, candidate);
- }
-
- return g_slist_reverse (filtered);
-}
-
-/**
- * nm_device_get_setting_type:
- * @device: an #NMDevice
- *
- * Gets the (primary) #NMSetting subtype associated with connections
- * that can be used on @device.
- *
- * Returns: @device's associated #NMSetting type
- *
- * Since: 0.9.10
- */
-GType
-nm_device_get_setting_type (NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_DEVICE (device), G_TYPE_INVALID);
- g_return_val_if_fail (NM_DEVICE_GET_CLASS (device)->get_setting_type != NULL, G_TYPE_INVALID);
-
- return NM_DEVICE_GET_CLASS (device)->get_setting_type (device);
-}
diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h
deleted file mode 100644
index d2d154dc1f..0000000000
--- a/libnm-glib/nm-device.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2013 Red Hat, Inc.
- */
-
-#ifndef NM_DEVICE_H
-#define NM_DEVICE_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include "nm-object.h"
-#include "NetworkManager.h"
-#include "nm-ip4-config.h"
-#include "nm-dhcp4-config.h"
-#include "nm-ip6-config.h"
-#include "nm-dhcp6-config.h"
-#include "nm-connection.h"
-#include "nm-active-connection.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE (nm_device_get_type ())
-#define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice))
-#define NM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE, NMDeviceClass))
-#define NM_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE))
-#define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE))
-#define NM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass))
-
-/**
- * NMDeviceError:
- * @NM_DEVICE_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_DEVICE_ERROR_INTERFACE_MISMATCH: the interface names of the connection and the
- * device mismatched
- */
-typedef enum {
- NM_DEVICE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_DEVICE_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
-} NMDeviceError;
-
-#define NM_DEVICE_ERROR nm_device_error_quark ()
-NM_AVAILABLE_IN_0_9_10
-GQuark nm_device_error_quark (void);
-
-#define NM_DEVICE_DEVICE_TYPE "device-type"
-#define NM_DEVICE_UDI "udi"
-#define NM_DEVICE_INTERFACE "interface"
-#define NM_DEVICE_IP_INTERFACE "ip-interface"
-#define NM_DEVICE_DRIVER "driver"
-#define NM_DEVICE_DRIVER_VERSION "driver-version"
-#define NM_DEVICE_FIRMWARE_VERSION "firmware-version"
-#define NM_DEVICE_CAPABILITIES "capabilities"
-#define NM_DEVICE_REAL "real"
-#define NM_DEVICE_MANAGED "managed"
-#define NM_DEVICE_AUTOCONNECT "autoconnect"
-#define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
-#define NM_DEVICE_IP4_CONFIG "ip4-config"
-#define NM_DEVICE_DHCP4_CONFIG "dhcp4-config"
-#define NM_DEVICE_IP6_CONFIG "ip6-config"
-#define NM_DEVICE_DHCP6_CONFIG "dhcp6-config"
-#define NM_DEVICE_STATE "state"
-#define NM_DEVICE_STATE_REASON "state-reason"
-#define NM_DEVICE_ACTIVE_CONNECTION "active-connection"
-#define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
-#define NM_DEVICE_VENDOR "vendor"
-#define NM_DEVICE_PRODUCT "product"
-#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
-#define NM_DEVICE_MTU "mtu"
-
-typedef struct {
- NMObject parent;
-} NMDevice;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Signals */
- void (*state_changed) (NMDevice *device,
- NMDeviceState new_state,
- NMDeviceState old_state,
- NMDeviceStateReason reason);
-
- gboolean (*connection_compatible) (NMDevice *device,
- NMConnection *connection,
- GError **error);
-
- const char * (*get_type_description) (NMDevice *device);
- const char * (*get_hw_address) (NMDevice *device);
-
- GType (*get_setting_type) (NMDevice *device);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
-} NMDeviceClass;
-
-GType nm_device_get_type (void);
-
-GObject * nm_device_new (DBusGConnection *connection, const char *path);
-
-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_driver (NMDevice *device);
-const char * nm_device_get_driver_version (NMDevice *device);
-const char * nm_device_get_firmware_version (NMDevice *device);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_device_get_type_description (NMDevice *device);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_device_get_hw_address (NMDevice *device);
-NMDeviceCapabilities nm_device_get_capabilities (NMDevice *device);
-gboolean nm_device_get_managed (NMDevice *device);
-NM_AVAILABLE_IN_1_2
-void nm_device_set_managed (NMDevice *device, gboolean managed);
-gboolean nm_device_get_autoconnect (NMDevice *device);
-void nm_device_set_autoconnect (NMDevice *device, gboolean autoconnect);
-gboolean nm_device_get_firmware_missing (NMDevice *device);
-NMIP4Config * nm_device_get_ip4_config (NMDevice *device);
-NMDHCP4Config * nm_device_get_dhcp4_config (NMDevice *device);
-NMIP6Config * nm_device_get_ip6_config (NMDevice *device);
-NMDHCP6Config * nm_device_get_dhcp6_config (NMDevice *device);
-NMDeviceState nm_device_get_state (NMDevice *device);
-NMDeviceState nm_device_get_state_reason (NMDevice *device, NMDeviceStateReason *reason);
-NMActiveConnection * nm_device_get_active_connection(NMDevice *device);
-const GPtrArray * nm_device_get_available_connections(NMDevice *device);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_device_get_physical_port_id (NMDevice *device);
-NM_AVAILABLE_IN_0_9_10
-guint32 nm_device_get_mtu (NMDevice *device);
-NM_AVAILABLE_IN_1_0
-gboolean nm_device_is_software (NMDevice *device);
-NM_AVAILABLE_IN_1_2
-gboolean nm_device_is_real (NMDevice *device);
-
-const char * nm_device_get_product (NMDevice *device);
-const char * nm_device_get_vendor (NMDevice *device);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_device_get_description (NMDevice *device);
-NM_AVAILABLE_IN_0_9_10
-char ** nm_device_disambiguate_names (NMDevice **devices,
- int num_devices);
-
-typedef void (*NMDeviceCallbackFn) (NMDevice *device, GError *error, gpointer user_data);
-
-void nm_device_disconnect (NMDevice *device,
- NMDeviceCallbackFn callback,
- gpointer user_data);
-
-NM_AVAILABLE_IN_1_0
-void nm_device_delete (NMDevice *device,
- NMDeviceCallbackFn callback,
- gpointer user_data);
-
-GSList * nm_device_filter_connections (NMDevice *device,
- const GSList *connections);
-
-gboolean nm_device_connection_valid (NMDevice *device,
- NMConnection *connection);
-
-gboolean nm_device_connection_compatible (NMDevice *device,
- NMConnection *connection,
- GError **error);
-
-NM_AVAILABLE_IN_0_9_10
-GType nm_device_get_setting_type (NMDevice *device);
-
-/* Deprecated */
-NM_DEPRECATED_IN_1_0
-typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_H */
diff --git a/libnm-glib/nm-dhcp4-config.c b/libnm-glib/nm-dhcp4-config.c
deleted file mode 100644
index e446280f1d..0000000000
--- a/libnm-glib/nm-dhcp4-config.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2011 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-dhcp4-config.h"
-#include "NetworkManager.h"
-#include "nm-types-private.h"
-#include "nm-object-private.h"
-#include "nm-utils.h"
-
-G_DEFINE_TYPE (NMDHCP4Config, nm_dhcp4_config, NM_TYPE_OBJECT)
-
-#define NM_DHCP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP4_CONFIG, NMDHCP4ConfigPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- GHashTable *options;
-} NMDHCP4ConfigPrivate;
-
-enum {
- PROP_0,
- PROP_OPTIONS,
-
- LAST_PROP
-};
-
-static void
-nm_dhcp4_config_init (NMDHCP4Config *config)
-{
-}
-
-static gboolean
-demarshal_dhcp4_options (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object);
- GHashTable *new_options;
- GHashTableIter iter;
- const char *key;
- GValue *opt;
-
- g_hash_table_remove_all (priv->options);
-
- new_options = g_value_get_boxed (value);
- if (new_options) {
- g_hash_table_iter_init (&iter, new_options);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &opt))
- g_hash_table_insert (priv->options, g_strdup (key), g_value_dup_string (opt));
- }
-
- _nm_object_queue_notify (object, NM_DHCP4_CONFIG_OPTIONS);
- return TRUE;
-}
-
-static void
-register_properties (NMDHCP4Config *config)
-{
- NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (config);
- const NMPropertiesInfo property_info[] = {
- { NM_DHCP4_CONFIG_OPTIONS, &priv->options, demarshal_dhcp4_options },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (config),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->constructed (object);
-
- priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DHCP4_CONFIG);
- register_properties (NM_DHCP4_CONFIG (object));
-}
-
-static void
-finalize (GObject *object)
-{
- NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object);
-
- if (priv->options)
- g_hash_table_destroy (priv->options);
-
- g_object_unref (priv->proxy);
-
- G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDHCP4Config *self = NM_DHCP4_CONFIG (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_OPTIONS:
- g_value_set_boxed (value, nm_dhcp4_config_get_options (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_dhcp4_config_class_init (NMDHCP4ConfigClass *config_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (config_class);
-
- g_type_class_add_private (config_class, sizeof (NMDHCP4ConfigPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMDHCP4Config:options: (type GHashTable(utf8,GObject.Value)):
- *
- * The #GHashTable containing options of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_OPTIONS,
- g_param_spec_boxed (NM_DHCP4_CONFIG_OPTIONS, "", "",
- G_TYPE_HASH_TABLE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
-
-/**
- * nm_dhcp4_config_new:
- * @connection: the #DBusGConnection
- * @object_path: the DBus object path of the device
- *
- * Creates a new #NMDHCP4Config.
- *
- * Returns: (transfer full): a new configuration
- **/
-GObject *
-nm_dhcp4_config_new (DBusGConnection *connection, const char *object_path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (object_path != NULL, NULL);
-
- return (GObject *) g_object_new (NM_TYPE_DHCP4_CONFIG,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, object_path,
- NULL);
-}
-
-/**
- * nm_dhcp4_config_get_options:
- * @config: a #NMDHCP4Config
- *
- * Gets all the options contained in the configuration.
- *
- * Returns: (transfer none) (element-type utf8 GObject.Value): the #GHashTable containing strings for keys and values.
- * This is the internal copy used by the configuration, and must not be modified.
- **/
-GHashTable *
-nm_dhcp4_config_get_options (NMDHCP4Config *config)
-{
- g_return_val_if_fail (NM_IS_DHCP4_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_DHCP4_CONFIG_GET_PRIVATE (config)->options;
-}
-
-/**
- * nm_dhcp4_config_get_one_option:
- * @config: a #NMDHCP4Config
- * @option: the option to retrieve
- *
- * Gets one option by option name.
- *
- * Returns: the configuration option's value. This is the internal string used by the
- * configuration, and must not be modified.
- **/
-const char *
-nm_dhcp4_config_get_one_option (NMDHCP4Config *config, const char *option)
-{
- g_return_val_if_fail (NM_IS_DHCP4_CONFIG (config), NULL);
-
- return g_hash_table_lookup (nm_dhcp4_config_get_options (config), option);
-}
diff --git a/libnm-glib/nm-dhcp4-config.h b/libnm-glib/nm-dhcp4-config.h
deleted file mode 100644
index c64e9a9c8d..0000000000
--- a/libnm-glib/nm-dhcp4-config.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#ifndef NM_DHCP4_CONFIG_H
-#define NM_DHCP4_CONFIG_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include "nm-object.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ())
-#define NM_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP4_CONFIG, NMDHCP4Config))
-#define NM_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP4_CONFIG, NMDHCP4ConfigClass))
-#define NM_IS_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP4_CONFIG))
-#define NM_IS_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP4_CONFIG))
-
-typedef struct {
- NMObject parent;
-} NMDHCP4Config;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDHCP4ConfigClass;
-
-#define NM_DHCP4_CONFIG_OPTIONS "options"
-
-GType nm_dhcp4_config_get_type (void);
-
-GObject *nm_dhcp4_config_new (DBusGConnection *connection, const char *object_path);
-
-GHashTable * nm_dhcp4_config_get_options (NMDHCP4Config *config);
-
-const char * nm_dhcp4_config_get_one_option (NMDHCP4Config *config, const char *option);
-
-G_END_DECLS
-
-#endif /* NM_DHCP4_CONFIG_H */
diff --git a/libnm-glib/nm-dhcp6-config.c b/libnm-glib/nm-dhcp6-config.c
deleted file mode 100644
index c35fb3ba9b..0000000000
--- a/libnm-glib/nm-dhcp6-config.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2011 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-dhcp6-config.h"
-#include "NetworkManager.h"
-#include "nm-types-private.h"
-#include "nm-object-private.h"
-#include "nm-utils.h"
-
-G_DEFINE_TYPE (NMDHCP6Config, nm_dhcp6_config, NM_TYPE_OBJECT)
-
-#define NM_DHCP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP6_CONFIG, NMDHCP6ConfigPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- GHashTable *options;
-} NMDHCP6ConfigPrivate;
-
-enum {
- PROP_0,
- PROP_OPTIONS,
-
- LAST_PROP
-};
-
-static void
-nm_dhcp6_config_init (NMDHCP6Config *config)
-{
-}
-
-static gboolean
-demarshal_dhcp6_options (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
- GHashTable *new_options;
- GHashTableIter iter;
- const char *key;
- GValue *opt;
-
- g_hash_table_remove_all (priv->options);
-
- new_options = g_value_get_boxed (value);
- if (new_options) {
- g_hash_table_iter_init (&iter, new_options);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &opt))
- g_hash_table_insert (priv->options, g_strdup (key), g_value_dup_string (opt));
- }
-
- _nm_object_queue_notify (object, NM_DHCP6_CONFIG_OPTIONS);
- return TRUE;
-}
-
-static void
-register_properties (NMDHCP6Config *config)
-{
- NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (config);
- const NMPropertiesInfo property_info[] = {
- { NM_DHCP6_CONFIG_OPTIONS, &priv->options, demarshal_dhcp6_options },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (config),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->constructed (object);
-
- priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DHCP6_CONFIG);
- register_properties (NM_DHCP6_CONFIG (object));
-}
-
-static void
-finalize (GObject *object)
-{
- NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
-
- if (priv->options)
- g_hash_table_destroy (priv->options);
-
- g_object_unref (priv->proxy);
-
- G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMDHCP6Config *self = NM_DHCP6_CONFIG (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_OPTIONS:
- g_value_set_boxed (value, nm_dhcp6_config_get_options (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_dhcp6_config_class_init (NMDHCP6ConfigClass *config_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (config_class);
-
- g_type_class_add_private (config_class, sizeof (NMDHCP6ConfigPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMDHCP6Config:options: (type GHashTable(utf8,GObject.Value)):
- *
- * The #GHashTable containing options of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_OPTIONS,
- g_param_spec_boxed (NM_DHCP6_CONFIG_OPTIONS, "", "",
- G_TYPE_HASH_TABLE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
-
-/**
- * nm_dhcp6_config_new:
- * @connection: the #DBusGConnection
- * @object_path: the DBus object path of the device
- *
- * Creates a new #NMDHCP6Config.
- *
- * Returns: (transfer full): a new configuration
- **/
-GObject *
-nm_dhcp6_config_new (DBusGConnection *connection, const char *object_path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (object_path != NULL, NULL);
-
- return (GObject *) g_object_new (NM_TYPE_DHCP6_CONFIG,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, object_path,
- NULL);
-}
-
-/**
- * nm_dhcp6_config_get_options:
- * @config: a #NMDHCP6Config
- *
- * Gets all the options contained in the configuration.
- *
- * Returns: (transfer none) (element-type utf8 GObject.Value): the #GHashTable containing strings for keys and values.
- * This is the internal copy used by the configuration, and must not be modified.
- **/
-GHashTable *
-nm_dhcp6_config_get_options (NMDHCP6Config *config)
-{
- g_return_val_if_fail (NM_IS_DHCP6_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_DHCP6_CONFIG_GET_PRIVATE (config)->options;
-}
-
-/**
- * nm_dhcp6_config_get_one_option:
- * @config: a #NMDHCP6Config
- * @option: the option to retrieve
- *
- * Gets one option by option name.
- *
- * Returns: the configuration option's value. This is the internal string used by the
- * configuration, and must not be modified.
- **/
-const char *
-nm_dhcp6_config_get_one_option (NMDHCP6Config *config, const char *option)
-{
- g_return_val_if_fail (NM_IS_DHCP6_CONFIG (config), NULL);
-
- return g_hash_table_lookup (nm_dhcp6_config_get_options (config), option);
-}
diff --git a/libnm-glib/nm-dhcp6-config.h b/libnm-glib/nm-dhcp6-config.h
deleted file mode 100644
index 939b3fdbe4..0000000000
--- a/libnm-glib/nm-dhcp6-config.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2010 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#ifndef NM_DHCP6_CONFIG_H
-#define NM_DHCP6_CONFIG_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include "nm-object.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DHCP6_CONFIG (nm_dhcp6_config_get_type ())
-#define NM_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP6_CONFIG, NMDHCP6Config))
-#define NM_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP6_CONFIG, NMDHCP6ConfigClass))
-#define NM_IS_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP6_CONFIG))
-#define NM_IS_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP6_CONFIG))
-
-typedef struct {
- NMObject parent;
-} NMDHCP6Config;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMDHCP6ConfigClass;
-
-#define NM_DHCP6_CONFIG_OPTIONS "options"
-
-GType nm_dhcp6_config_get_type (void);
-
-GObject *nm_dhcp6_config_new (DBusGConnection *connection, const char *object_path);
-
-GHashTable * nm_dhcp6_config_get_options (NMDHCP6Config *config);
-
-const char * nm_dhcp6_config_get_one_option (NMDHCP6Config *config, const char *option);
-
-G_END_DECLS
-
-#endif /* NM_DHCP6_CONFIG_H */
diff --git a/libnm-glib/nm-glib-enum-types.c.template b/libnm-glib/nm-glib-enum-types.c.template
deleted file mode 100644
index 8bd4732e01..0000000000
--- a/libnm-glib/nm-glib-enum-types.c.template
+++ /dev/null
@@ -1,62 +0,0 @@
-/*** BEGIN file-header ***/
-#include "config.h"
-
-#include "nm-glib-enum-types.h"
-
-#include "nm-object.h"
-#include "nm-client.h"
-#include "nm-device.h"
-#include "nm-device-ethernet.h"
-#include "nm-device-infiniband.h"
-#include "nm-device-adsl.h"
-#include "nm-device-wifi.h"
-#include "nm-device-bt.h"
-#include "nm-device-olpc-mesh.h"
-#include "nm-device-bond.h"
-#include "nm-device-team.h"
-#include "nm-device-bridge.h"
-#include "nm-device-vlan.h"
-#include "nm-device-generic.h"
-#include "nm-access-point.h"
-#include "nm-ip4-config.h"
-#include "nm-device-modem.h"
-#include "nm-vpn-connection.h"
-#include "nm-types.h"
-#include "nm-active-connection.h"
-#include "nm-dhcp4-config.h"
-#include "nm-ip6-config.h"
-#include "nm-dhcp6-config.h"
-#include "nm-remote-connection.h"
-#include "nm-remote-settings.h"
-#include "nm-secret-agent.h"
-#include "nm-device-wimax.h"
-#include "nm-wimax-nsp.h"
-/*** END file-header ***/
-
-/*** BEGIN value-header ***/
-GType
-@enum_name@_get_type (void)
-{
- static volatile gsize g_define_type_id__volatile = 0;
-
- if (g_once_init_enter (&g_define_type_id__volatile))
- {
- static const G@Type@Value values[] = {
-/*** END value-header ***/
-
-/*** BEGIN value-production ***/
- { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
-/*** END value-production ***/
-
-/*** BEGIN value-tail ***/
- { 0, NULL, NULL }
- };
- GType g_define_type_id =
- g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
-
- return g_define_type_id__volatile;
-}
-
-/*** END value-tail ***/
diff --git a/libnm-glib/nm-glib-enum-types.h.template b/libnm-glib/nm-glib-enum-types.h.template
deleted file mode 100644
index c0699560b9..0000000000
--- a/libnm-glib/nm-glib-enum-types.h.template
+++ /dev/null
@@ -1,21 +0,0 @@
-/*** BEGIN file-header ***/
-#ifndef __NM_GLIB_ENUM_TYPES_H__
-#define __NM_GLIB_ENUM_TYPES_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/*** END file-header ***/
-
-/*** BEGIN enumeration-production ***/
-GType @enum_name@_get_type (void) G_GNUC_CONST;
-#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
-
-/*** END enumeration-production ***/
-
-/*** BEGIN file-tail ***/
-G_END_DECLS
-
-#endif /* __NM_GLIB_ENUM_TYPES_H__ */
-/*** END file-tail ***/
diff --git a/libnm-glib/nm-ip4-config.c b/libnm-glib/nm-ip4-config.c
deleted file mode 100644
index 8954ee7ba8..0000000000
--- a/libnm-glib/nm-ip4-config.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Novell, Inc.
- * Copyright 2008 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-ip4-config.h"
-#include "nm-ip4-config.h"
-#include "NetworkManager.h"
-#include "nm-types-private.h"
-#include "nm-object-private.h"
-#include "nm-utils.h"
-
-G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_OBJECT)
-
-#define NM_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP4_CONFIG, NMIP4ConfigPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *gateway;
- GSList *addresses;
- GSList *routes;
- GArray *nameservers;
- GPtrArray *domains;
- GPtrArray *searches;
- GArray *wins;
-} NMIP4ConfigPrivate;
-
-enum {
- PROP_0,
- PROP_GATEWAY,
- PROP_ADDRESSES,
- PROP_ROUTES,
- PROP_NAMESERVERS,
- PROP_DOMAINS,
- PROP_SEARCHES,
- PROP_WINS_SERVERS,
-
- LAST_PROP
-};
-
-static void
-nm_ip4_config_init (NMIP4Config *config)
-{
-}
-
-static gboolean
-demarshal_ip4_address_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
- g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
- priv->addresses = NULL;
-
- priv->addresses = nm_utils_ip4_addresses_from_gvalue (value);
- _nm_object_queue_notify (object, NM_IP4_CONFIG_ADDRESSES);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- if (!_nm_uint_array_demarshal (value, (GArray **) field))
- return FALSE;
-
- if (!strcmp (pspec->name, NM_IP4_CONFIG_NAMESERVERS))
- _nm_object_queue_notify (object, NM_IP4_CONFIG_NAMESERVERS);
- else if (!strcmp (pspec->name, NM_IP4_CONFIG_WINS_SERVERS))
- _nm_object_queue_notify (object, NM_IP4_CONFIG_WINS_SERVERS);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_string_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- if (!_nm_string_array_demarshal (value, (GPtrArray **) field))
- return FALSE;
-
- _nm_object_queue_notify (object, pspec->name);
- return TRUE;
-}
-
-static gboolean
-demarshal_ip4_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
- g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
- priv->routes = NULL;
-
- priv->routes = nm_utils_ip4_routes_from_gvalue (value);
- _nm_object_queue_notify (object, NM_IP4_CONFIG_ROUTES);
-
- return TRUE;
-}
-
-static void
-register_properties (NMIP4Config *config)
-{
- NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- const NMPropertiesInfo property_info[] = {
- { NM_IP4_CONFIG_GATEWAY, &priv->gateway, },
- { NM_IP4_CONFIG_ADDRESSES, &priv->addresses, demarshal_ip4_address_array },
- { NM_IP4_CONFIG_ROUTES, &priv->routes, demarshal_ip4_routes_array },
- { NM_IP4_CONFIG_NAMESERVERS, &priv->nameservers, demarshal_ip4_array },
- { NM_IP4_CONFIG_DOMAINS, &priv->domains, demarshal_string_array },
- { NM_IP4_CONFIG_SEARCHES, &priv->searches, demarshal_string_array },
- { NM_IP4_CONFIG_WINS_SERVERS, &priv->wins, demarshal_ip4_array },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (config),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_ip4_config_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_IP4_CONFIG);
- register_properties (NM_IP4_CONFIG (object));
-}
-
-static void
-finalize (GObject *object)
-{
- NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
- g_free (priv->gateway);
-
- g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
- g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
-
- if (priv->nameservers)
- g_array_free (priv->nameservers, TRUE);
-
- if (priv->wins)
- g_array_free (priv->wins, TRUE);
-
- if (priv->domains) {
- g_ptr_array_set_free_func (priv->domains, g_free);
- g_ptr_array_free (priv->domains, TRUE);
- }
-
- if (priv->searches) {
- g_ptr_array_set_free_func (priv->searches, g_free);
- g_ptr_array_free (priv->searches, TRUE);
- }
-
- g_object_unref (priv->proxy);
-
- G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
-}
-
-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);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_GATEWAY:
- g_value_set_string (value, nm_ip4_config_get_gateway (self));
- break;
- case PROP_ADDRESSES:
- nm_utils_ip4_addresses_to_gvalue (priv->addresses, value);
- break;
- case PROP_ROUTES:
- nm_utils_ip4_routes_to_gvalue (priv->routes, value);
- break;
- case PROP_NAMESERVERS:
- g_value_set_boxed (value, nm_ip4_config_get_nameservers (self));
- break;
- case PROP_DOMAINS:
- g_value_set_boxed (value, nm_ip4_config_get_domains (self));
- break;
- case PROP_SEARCHES:
- g_value_set_boxed (value, nm_ip4_config_get_searches (self));
- break;
- case PROP_WINS_SERVERS:
- g_value_set_boxed (value, nm_ip4_config_get_wins_servers (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (config_class);
-
- g_type_class_add_private (config_class, sizeof (NMIP4ConfigPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMIP4Config:gateway:
- *
- * The IP4 gateway address of the configuration as string.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_GATEWAY,
- g_param_spec_string (NM_IP4_CONFIG_GATEWAY, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP4Config:addresses:
- *
- * The #GPtrArray containing #NMIP4Address<!-- -->es of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_ADDRESSES,
- g_param_spec_pointer (NM_IP4_CONFIG_ADDRESSES, "", "",
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP4Config:routes:
- *
- * The #GPtrArray containing #NMSettingIP4Route<!-- -->s of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_ROUTES,
- g_param_spec_pointer (NM_IP4_CONFIG_ROUTES, "", "",
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP4Config:nameservers:
- *
- * The #GArray containing name servers (#guint32s) of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_NAMESERVERS,
- g_param_spec_boxed (NM_IP4_CONFIG_NAMESERVERS, "", "",
- NM_TYPE_UINT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP4Config:domains:
- *
- * The #GPtrArray containing domain strings of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_DOMAINS,
- g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS, "", "",
- NM_TYPE_STRING_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP4Config:searches:
- *
- * The #GPtrArray containing dns search strings of the configuration.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_SEARCHES,
- g_param_spec_boxed (NM_IP4_CONFIG_SEARCHES, "", "",
- NM_TYPE_STRING_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP4Config:wins-servers:
- *
- * The #GArray containing WINS servers (#guint32s) of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_WINS_SERVERS,
- g_param_spec_boxed (NM_IP4_CONFIG_WINS_SERVERS, "", "",
- NM_TYPE_UINT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
-
-/**
- * nm_ip4_config_new:
- * @connection: the #DBusGConnection
- * @object_path: the DBus object path of the device
- *
- * Creates a new #NMIP4Config.
- *
- * Returns: (transfer full): a new IP4 configuration
- **/
-GObject *
-nm_ip4_config_new (DBusGConnection *connection, const char *object_path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (object_path != NULL, NULL);
-
- return (GObject *) g_object_new (NM_TYPE_IP4_CONFIG,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, object_path,
- NULL);
-}
-
-/**
- * nm_ip4_config_get_gateway:
- * @config: a #NMIP4Config
- *
- * Gets the IP4 gateway address.
- *
- * Returns: the IP4 address of the gateway.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_ip4_config_get_gateway (NMIP4Config *config)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP4_CONFIG_GET_PRIVATE (config)->gateway;
-}
-
-/**
- * nm_ip4_config_get_addresses:
- * @config: a #NMIP4Config
- *
- * Gets the IP4 addresses (containing the address, prefix, and gateway).
- *
- * Returns: (element-type NMIP4Address): the #GSList containing #NMIP4Address<!-- -->es.
- * This is the internal copy used by the configuration and must not be modified.
- **/
-const GSList *
-nm_ip4_config_get_addresses (NMIP4Config *config)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP4_CONFIG_GET_PRIVATE (config)->addresses;
-}
-
-/**
- * nm_ip4_config_get_nameservers:
- * @config: a #NMIP4Config
- *
- * Gets the domain name servers (DNS).
- *
- * Returns: (element-type guint32): the #GArray containing #guint32s.
- * This is the internal copy used by the configuration and must not be
- * modified.
- **/
-const GArray *
-nm_ip4_config_get_nameservers (NMIP4Config *config)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers;
-}
-
-/**
- * nm_ip4_config_get_domains:
- * @config: a #NMIP4Config
- *
- * Gets the domain names.
- *
- * Returns: (element-type utf8): the #GPtrArray containing domains as strings. This is the
- * internal copy used by the configuration, and must not be modified.
- **/
-const GPtrArray *
-nm_ip4_config_get_domains (NMIP4Config *config)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return handle_ptr_array_return (NM_IP4_CONFIG_GET_PRIVATE (config)->domains);
-}
-
-/**
- * nm_ip4_config_get_searches:
- * @config: a #NMIP4Config
- *
- * Gets the dns searches.
- *
- * Returns: (element-type utf8): the #GPtrArray containing dns searches as strings. This is the
- * internal copy used by the configuration, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const GPtrArray *
-nm_ip4_config_get_searches (NMIP4Config *config)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return handle_ptr_array_return (NM_IP4_CONFIG_GET_PRIVATE (config)->searches);
-}
-
-/**
- * nm_ip4_config_get_wins_servers:
- * @config: a #NMIP4Config
- *
- * Gets the Windows Internet Name Service servers (WINS).
- *
- * Returns: (element-type guint32): the #GArray containing #guint32s.
- * This is the internal copy used by the configuration and must not be
- * modified.
- **/
-const GArray *
-nm_ip4_config_get_wins_servers (NMIP4Config *config)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP4_CONFIG_GET_PRIVATE (config)->wins;
-}
-
-/**
- * nm_ip4_config_get_routes:
- * @config: a #NMIP4Config
- *
- * Gets the routes.
- *
- * Returns: (element-type NMIP4Route): the #GSList containing
- * #NMIP4Route<!-- -->s. This is the internal copy used by the configuration,
- * and must not be modified.
- **/
-const GSList *
-nm_ip4_config_get_routes (NMIP4Config *config)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP4_CONFIG_GET_PRIVATE (config)->routes;
-}
diff --git a/libnm-glib/nm-ip4-config.h b/libnm-glib/nm-ip4-config.h
deleted file mode 100644
index 58b6b3714d..0000000000
--- a/libnm-glib/nm-ip4-config.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2008 Red Hat, Inc.
- */
-
-#ifndef NM_IP4_CONFIG_H
-#define NM_IP4_CONFIG_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include "nm-object.h"
-
-G_BEGIN_DECLS
-
-#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 {
- NMObject parent;
-} NMIP4Config;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMIP4ConfigClass;
-
-#define NM_IP4_CONFIG_GATEWAY "gateway"
-#define NM_IP4_CONFIG_ADDRESSES "addresses"
-#define NM_IP4_CONFIG_ROUTES "routes"
-#define NM_IP4_CONFIG_NAMESERVERS "nameservers"
-#define NM_IP4_CONFIG_DOMAINS "domains"
-#define NM_IP4_CONFIG_SEARCHES "searches"
-#define NM_IP4_CONFIG_WINS_SERVERS "wins-servers"
-
-GType nm_ip4_config_get_type (void);
-
-GObject *nm_ip4_config_new (DBusGConnection *connection, const char *object_path);
-
-NM_AVAILABLE_IN_0_9_10
-const char * nm_ip4_config_get_gateway (NMIP4Config *config);
-const GSList * nm_ip4_config_get_addresses (NMIP4Config *config);
-const GSList * nm_ip4_config_get_routes (NMIP4Config *config);
-const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config);
-const GPtrArray *nm_ip4_config_get_domains (NMIP4Config *config);
-NM_AVAILABLE_IN_0_9_10
-const GPtrArray *nm_ip4_config_get_searches (NMIP4Config *config);
-const GArray * nm_ip4_config_get_wins_servers (NMIP4Config *config);
-
-G_END_DECLS
-
-#endif /* NM_IP4_CONFIG_H */
diff --git a/libnm-glib/nm-ip6-config.c b/libnm-glib/nm-ip6-config.c
deleted file mode 100644
index b655b239ae..0000000000
--- a/libnm-glib/nm-ip6-config.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2008 - 2014 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-ip6-config.h"
-#include "nm-ip6-config.h"
-#include "NetworkManager.h"
-#include "nm-types-private.h"
-#include "nm-object-private.h"
-#include "nm-utils.h"
-
-G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_OBJECT)
-
-#define NM_IP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP6_CONFIG, NMIP6ConfigPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *gateway;
- GSList *addresses;
- GSList *routes;
- GSList *nameservers;
- GPtrArray *domains;
- GPtrArray *searches;
-} NMIP6ConfigPrivate;
-
-enum {
- PROP_0,
- PROP_GATEWAY,
- PROP_ADDRESSES,
- PROP_ROUTES,
- PROP_NAMESERVERS,
- PROP_DOMAINS,
- PROP_SEARCHES,
-
- LAST_PROP
-};
-
-/**
- * nm_ip6_config_new:
- * @connection: the #DBusGConnection
- * @object_path: the DBus object path of the device
- *
- * Creates a new #NMIP6Config.
- *
- * Returns: (transfer full): a new IP6 configuration
- **/
-GObject *
-nm_ip6_config_new (DBusGConnection *connection, const char *object_path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (object_path != NULL, NULL);
-
- return (GObject *) g_object_new (NM_TYPE_IP6_CONFIG,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, object_path,
- NULL);
-}
-
-static gboolean
-demarshal_ip6_address_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-
- g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref);
- priv->addresses = NULL;
-
- priv->addresses = nm_utils_ip6_addresses_from_gvalue (value);
- _nm_object_queue_notify (object, NM_IP6_CONFIG_ADDRESSES);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_ip6_nameserver_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- if (!_nm_ip6_address_array_demarshal (value, (GSList **) field))
- return FALSE;
-
- if (pspec && !strcmp (pspec->name, NM_IP6_CONFIG_NAMESERVERS))
- _nm_object_queue_notify (object, NM_IP6_CONFIG_NAMESERVERS);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_domains (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- if (!_nm_string_array_demarshal (value, (GPtrArray **) field))
- return FALSE;
-
- _nm_object_queue_notify (object, NM_IP6_CONFIG_DOMAINS);
- return TRUE;
-}
-
-static gboolean
-demarshal_searches (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- if (!_nm_string_array_demarshal (value, (GPtrArray **) field))
- return FALSE;
-
- _nm_object_queue_notify (object, NM_IP6_CONFIG_SEARCHES);
- return TRUE;
-}
-
-static gboolean
-demarshal_ip6_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-
- g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
- priv->routes = NULL;
-
- priv->routes = nm_utils_ip6_routes_from_gvalue (value);
- _nm_object_queue_notify (object, NM_IP6_CONFIG_ROUTES);
-
- return TRUE;
-}
-
-static void
-register_properties (NMIP6Config *config)
-{
- NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
- const NMPropertiesInfo property_info[] = {
- { NM_IP6_CONFIG_GATEWAY, &priv->gateway, },
- { NM_IP6_CONFIG_ADDRESSES, &priv->addresses, demarshal_ip6_address_array },
- { NM_IP6_CONFIG_ROUTES, &priv->routes, demarshal_ip6_routes_array },
- { NM_IP6_CONFIG_NAMESERVERS, &priv->nameservers, demarshal_ip6_nameserver_array },
- { NM_IP6_CONFIG_DOMAINS, &priv->domains, demarshal_domains },
- { NM_IP6_CONFIG_SEARCHES, &priv->searches, demarshal_searches },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (config),
- priv->proxy,
- property_info);
-}
-
-/**
- * nm_ip6_config_get_gateway:
- * @config: a #NMIP6Config
- *
- * Gets the IP6 gateway.
- *
- * Returns: the IPv6 gateway of the configuration.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_ip6_config_get_gateway (NMIP6Config *config)
-{
- g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP6_CONFIG_GET_PRIVATE (config)->gateway;
-}
-
-/**
- * nm_ip6_config_get_addresses:
- * @config: a #NMIP6Config
- *
- * Gets the IP6 addresses (containing the address, prefix, and gateway).
- *
- * Returns: (element-type NMIP6Address): the #GSList containing
- * #NMIP6Address<!-- -->es. This is the internal copy used by the configuration
- * and must not be modified.
- **/
-const GSList *
-nm_ip6_config_get_addresses (NMIP6Config *config)
-{
- g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP6_CONFIG_GET_PRIVATE (config)->addresses;
-}
-
-/**
- * nm_ip6_config_get_num_nameservers:
- * @config: a #NMIP6Config
- *
- * Gets the number of the domain name servers in the configuration.
- *
- * Returns: the number of domain name servers
- *
- * Since: 0.9.10
- **/
-guint32
-nm_ip6_config_get_num_nameservers (NMIP6Config *config)
-{
- g_return_val_if_fail (NM_IS_IP6_CONFIG (config), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return g_slist_length (NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers);
-}
-
-/**
- * nm_ip6_config_get_nameserver:
- * @config: a #NMIP6Config
- * @idx: index of the nameserver to return
- *
- * Gets the domain name server at index @idx in the configuration.
- *
- * Returns: (array fixed-size=16) (element-type guint8) (transfer none):
- * the IPv6 address of domain name server at index @iidx
- *
- * Since: 0.9.10
- **/
-const struct in6_addr *
-nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx)
-{
- NMIP6ConfigPrivate *priv;
- GSList *item;
- guint32 i = 0;
-
- g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- priv = NM_IP6_CONFIG_GET_PRIVATE (config);
-
- for (item = priv->nameservers; item && i < idx; i++)
- item = item->next;
-
- g_return_val_if_fail (item, NULL);
- return item ? (const struct in6_addr *) item->data : NULL;
-}
-
-/* FIXME: like in libnm_util, in6_addr is not introspectable, so skipping here */
-/**
- * nm_ip6_config_get_nameservers: (skip)
- * @config: a #NMIP6Config
- *
- * Gets the domain name servers (DNS).
- *
- * Returns: a #GSList containing elements of type 'struct in6_addr' which
- * contain the addresses of nameservers of the configuration. This is the
- * internal copy used by the configuration and must not be modified.
- **/
-const GSList *
-nm_ip6_config_get_nameservers (NMIP6Config *config)
-{
- g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers;
-}
-
-/**
- * nm_ip6_config_get_domains:
- * @config: a #NMIP6Config
- *
- * Gets the domain names.
- *
- * Returns: (element-type utf8): the #GPtrArray containing domains as strings.
- * This is the internal copy used by the configuration, and must not be modified.
- **/
-const GPtrArray *
-nm_ip6_config_get_domains (NMIP6Config *config)
-{
- g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->domains);
-}
-
-/**
- * nm_ip6_config_get_searches:
- * @config: a #NMIP6Config
- *
- * Gets the dns searches.
- *
- * Returns: (element-type utf8): the #GPtrArray containing dns searches as strings.
- * This is the internal copy used by the configuration, and must not be modified.
- *
- * Since: 0.9.10
- **/
-const GPtrArray *
-nm_ip6_config_get_searches (NMIP6Config *config)
-{
- g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->searches);
-}
-
-/**
- * nm_ip6_config_get_routes:
- * @config: a #NMIP6Config
- *
- * Gets the routes.
- *
- * Returns: (element-type NMIP6Route): the #GSList containing
- * #NMIP6Route<!-- -->s. This is the internal copy used by the configuration,
- * and must not be modified.
- **/
-const GSList *
-nm_ip6_config_get_routes (NMIP6Config *config)
-{
- g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (config));
- return NM_IP6_CONFIG_GET_PRIVATE (config)->routes;
-}
-
-static void
-constructed (GObject *object)
-{
- NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_ip6_config_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_IP6_CONFIG);
- register_properties (NM_IP6_CONFIG (object));
-}
-
-static void
-finalize (GObject *object)
-{
- NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-
- g_free (priv->gateway);
-
- g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref);
- g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
- g_slist_free_full (priv->nameservers, g_free);
-
- if (priv->domains) {
- g_ptr_array_set_free_func (priv->domains, g_free);
- g_ptr_array_free (priv->domains, TRUE);
- }
-
- if (priv->searches) {
- g_ptr_array_set_free_func (priv->searches, g_free);
- g_ptr_array_free (priv->searches, TRUE);
- }
-
- g_object_unref (priv->proxy);
-
- G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object);
-}
-
-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);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_GATEWAY:
- g_value_set_string (value, nm_ip6_config_get_gateway (self));
- break;
- case PROP_ADDRESSES:
- nm_utils_ip6_addresses_to_gvalue (priv->addresses, value);
- break;
- case PROP_ROUTES:
- nm_utils_ip6_routes_to_gvalue (priv->routes, value);
- break;
- case PROP_NAMESERVERS:
- g_value_set_boxed (value, nm_ip6_config_get_nameservers (self));
- break;
- case PROP_DOMAINS:
- g_value_set_boxed (value, nm_ip6_config_get_domains (self));
- break;
- case PROP_SEARCHES:
- g_value_set_boxed (value, nm_ip6_config_get_searches (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_ip6_config_init (NMIP6Config *config)
-{
-}
-
-static void
-nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (config_class);
-
- g_type_class_add_private (config_class, sizeof (NMIP6ConfigPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMIP6Config:gateway:
- *
- * The IPv6 gateway as string
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_GATEWAY,
- g_param_spec_string (NM_IP6_CONFIG_GATEWAY, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP6Config:addresses:
- *
- * The #GPtrArray containing the IPv6 addresses; use
- * nm_utils_ip6_addresses_from_gvalue() to return a #GSList of
- * #NMSettingIP6Address objects that is more usable than the raw data.
- **/
- g_object_class_install_property
- (object_class, PROP_ADDRESSES,
- g_param_spec_boxed (NM_IP6_CONFIG_ADDRESSES, "", "",
- NM_TYPE_IP6_ADDRESS_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP6Config:routes:
- *
- * The #GPtrArray containing the IPv6 routes; use
- * nm_utils_ip6_routes_from_gvalue() to return a #GSList of
- * #NMSettingIP6Address objects that is more usable than the raw data.
- **/
- g_object_class_install_property
- (object_class, PROP_ROUTES,
- g_param_spec_boxed (NM_IP6_CONFIG_ROUTES, "", "",
- NM_TYPE_IP6_ROUTE_OBJECT_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP6Config:nameservers:
- *
- * The #GPtrArray containing elements of type 'struct ip6_addr' which
- * contain the addresses of nameservers of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_NAMESERVERS,
- g_param_spec_boxed (NM_IP6_CONFIG_NAMESERVERS, "", "",
- NM_TYPE_IP6_ADDRESS_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP6Config:domains:
- *
- * The #GPtrArray containing domain strings of the configuration.
- **/
- g_object_class_install_property
- (object_class, PROP_DOMAINS,
- g_param_spec_boxed (NM_IP6_CONFIG_DOMAINS, "", "",
- NM_TYPE_STRING_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMIP6Config:searches:
- *
- * The #GPtrArray containing dns search strings of the configuration.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_SEARCHES,
- g_param_spec_boxed (NM_IP6_CONFIG_SEARCHES, "", "",
- NM_TYPE_STRING_ARRAY,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
-}
diff --git a/libnm-glib/nm-ip6-config.h b/libnm-glib/nm-ip6-config.h
deleted file mode 100644
index 7a64805b68..0000000000
--- a/libnm-glib/nm-ip6-config.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2008 - 2014 Red Hat, Inc.
- */
-
-#ifndef NM_IP6_CONFIG_H
-#define NM_IP6_CONFIG_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include "nm-object.h"
-
-G_BEGIN_DECLS
-
-#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 {
- NMObject parent;
-} NMIP6Config;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMIP6ConfigClass;
-
-#define NM_IP6_CONFIG_GATEWAY "gateway"
-#define NM_IP6_CONFIG_ADDRESSES "addresses"
-#define NM_IP6_CONFIG_ROUTES "routes"
-#define NM_IP6_CONFIG_NAMESERVERS "nameservers"
-#define NM_IP6_CONFIG_DOMAINS "domains"
-#define NM_IP6_CONFIG_SEARCHES "searches"
-
-GType nm_ip6_config_get_type (void);
-
-GObject *nm_ip6_config_new (DBusGConnection *connection, const char *object_path);
-
-NM_AVAILABLE_IN_0_9_10
-const char * nm_ip6_config_get_gateway (NMIP6Config *config);
-const GSList * nm_ip6_config_get_addresses (NMIP6Config *config);
-const GSList * nm_ip6_config_get_routes (NMIP6Config *config);
-NM_AVAILABLE_IN_0_9_10
-guint32 nm_ip6_config_get_num_nameservers (NMIP6Config *config);
-NM_AVAILABLE_IN_0_9_10
-const struct in6_addr *nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx);
-const GSList * nm_ip6_config_get_nameservers (NMIP6Config *config);
-const GPtrArray * nm_ip6_config_get_domains (NMIP6Config *config);
-NM_AVAILABLE_IN_0_9_10
-const GPtrArray * nm_ip6_config_get_searches (NMIP6Config *config);
-
-G_END_DECLS
-
-#endif /* NM_IP6_CONFIG_H */
diff --git a/libnm-glib/nm-object-cache.c b/libnm-glib/nm-object-cache.c
deleted file mode 100644
index fa56ace53b..0000000000
--- a/libnm-glib/nm-object-cache.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-object-cache.h"
-#include "nm-object.h"
-
-static GHashTable *cache = NULL;
-
-static void
-_init_cache (void)
-{
- if (G_UNLIKELY (cache == NULL))
- cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-}
-
-static void
-_nm_object_cache_remove_by_path (char *path)
-{
- _init_cache ();
- g_hash_table_remove (cache, path);
- g_free (path);
-}
-
-void
-_nm_object_cache_add (NMObject *object)
-{
- char *path;
-
- _init_cache ();
- path = g_strdup (nm_object_get_path (object));
- g_hash_table_insert (cache, path, object);
- g_object_set_data_full (G_OBJECT (object), "nm-object-cache-tag",
- g_strdup (path), (GDestroyNotify) _nm_object_cache_remove_by_path);
-}
-
-NMObject *
-_nm_object_cache_get (const char *path)
-{
- NMObject *object;
-
- _init_cache ();
- object = g_hash_table_lookup (cache, path);
- return object ? g_object_ref (object) : NULL;
-}
-
-void
-_nm_object_cache_clear (void)
-{
- GHashTableIter iter;
- GObject *obj;
- const char *path;
- char *foo;
-
- if (!cache)
- return;
-
- g_hash_table_iter_init (&iter, cache);
- while (g_hash_table_iter_next (&iter, (gpointer) &path, (gpointer) &obj)) {
- /* Remove the callback so that if the object isn't yet released
- * by a client, when it does finally get unrefed, it won't trigger
- * the cache removal for a new object with the same path as the
- * one being released.
- */
- foo = g_object_steal_data (obj, "nm-object-cache-tag");
- g_free (foo);
-
- g_hash_table_iter_remove (&iter);
- }
-}
diff --git a/libnm-glib/nm-object-cache.h b/libnm-glib/nm-object-cache.h
deleted file mode 100644
index 03229d566b..0000000000
--- a/libnm-glib/nm-object-cache.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 Red Hat, Inc.
- */
-
-#ifndef NM_OBJECT_CACHE_H
-#define NM_OBJECT_CACHE_H
-
-#include "nm-object.h"
-
-G_BEGIN_DECLS
-
-/* Returns referenced object from the cache */
-NMObject *_nm_object_cache_get (const char *path);
-void _nm_object_cache_add (NMObject *object);
-void _nm_object_cache_clear (void);
-
-G_END_DECLS
-
-#endif /* NM_OBJECT_CACHE_H */
diff --git a/libnm-glib/nm-object-private.h b/libnm-glib/nm-object-private.h
deleted file mode 100644
index 87141aab13..0000000000
--- a/libnm-glib/nm-object-private.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2011 Red Hat, Inc.
- */
-
-#ifndef NM_OBJECT_PRIVATE_H
-#define NM_OBJECT_PRIVATE_H
-
-#include "nm-object.h"
-
-void _nm_object_ensure_inited (NMObject *object);
-
-typedef gboolean (*PropertyMarshalFunc) (NMObject *object,
- GParamSpec *pspec,
- GValue *value,
- gpointer field);
-
-typedef struct {
- const char *name;
- gpointer field;
- PropertyMarshalFunc func;
- GType object_type;
- const char *signal_prefix;
-} NMPropertiesInfo;
-
-DBusGProxy *_nm_object_new_proxy (NMObject *self,
- const char *path,
- const char *interface);
-
-void _nm_object_register_properties (NMObject *object,
- DBusGProxy *proxy,
- const NMPropertiesInfo *info);
-
-gboolean _nm_object_reload_properties (NMObject *object, GError **error);
-
-void _nm_object_reload_properties_async (NMObject *object,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean _nm_object_reload_properties_finish (NMObject *object,
- GAsyncResult *result,
- GError **error);
-
-void _nm_object_queue_notify (NMObject *object, const char *property);
-
-void _nm_object_suppress_property_updates (NMObject *object, gboolean suppress);
-
-/* DBus property accessors */
-
-void _nm_object_reload_property (NMObject *object,
- const char *interface,
- const char *prop_name);
-
-void _nm_object_set_property (NMObject *object,
- const char *interface,
- const char *prop_name,
- GValue *value);
-
-static inline const GPtrArray *
-handle_ptr_array_return (GPtrArray *array)
-{
- /* zero-length is special-case; return NULL */
- if (!array || !array->len)
- return NULL;
- return array;
-}
-
-/* object demarshalling support */
-typedef GType (*NMObjectTypeFunc) (DBusGConnection *connection, const char *path);
-typedef void (*NMObjectTypeCallbackFunc) (GType type, gpointer user_data);
-typedef void (*NMObjectTypeAsyncFunc) (DBusGConnection *connection,
- const char *path,
- NMObjectTypeCallbackFunc callback,
- gpointer user_data);
-
-void _nm_object_register_type_func (GType base_type, NMObjectTypeFunc type_func,
- NMObjectTypeAsyncFunc type_async_func);
-
-#endif /* NM_OBJECT_PRIVATE_H */
diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c
deleted file mode 100644
index 967400e739..0000000000
--- a/libnm-glib/nm-object.c
+++ /dev/null
@@ -1,1576 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "nm-utils.h"
-#include "NetworkManager.h"
-#include "nm-object.h"
-#include "nm-object-cache.h"
-#include "nm-object-private.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-types.h"
-#include "nm-dbus-helpers-private.h"
-
-static gboolean debug = FALSE;
-#define dbgmsg(f,...) if (G_UNLIKELY (debug)) { g_message (f, ## __VA_ARGS__ ); }
-
-static void nm_object_initable_iface_init (GInitableIface *iface);
-static void nm_object_async_initable_iface_init (GAsyncInitableIface *iface);
-
-static GHashTable *type_funcs, *type_async_funcs;
-
-G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMObject, nm_object, G_TYPE_OBJECT,
- type_funcs = g_hash_table_new (NULL, NULL);
- type_async_funcs = g_hash_table_new (NULL, NULL);
- G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_object_initable_iface_init);
- G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_object_async_initable_iface_init);
- )
-
-#define NM_OBJECT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_OBJECT, NMObjectPrivate))
-
-typedef struct {
- PropertyMarshalFunc func;
- GType object_type;
- gpointer field;
- const char *signal_prefix;
-} PropertyInfo;
-
-static void reload_complete (NMObject *object, gboolean emit_now);
-
-typedef struct {
- DBusGConnection *connection;
- DBusGProxy *bus_proxy;
- gboolean nm_running;
-
- char *path;
- DBusGProxy *properties_proxy;
- GSList *property_interfaces;
- GSList *property_tables;
- NMObject *parent;
- gboolean suppress_property_updates;
-
- GSList *notify_items;
- guint32 notify_id;
- gboolean inited;
-
- GSList *reload_results;
- guint reload_remaining;
- GError *reload_error;
-} NMObjectPrivate;
-
-enum {
- PROP_0,
- PROP_DBUS_CONNECTION,
- PROP_DBUS_PATH,
-
- LAST_PROP
-};
-
-enum {
- OBJECT_CREATION_FAILED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/**
- * nm_object_error_quark:
- *
- * Registers an error quark for #NMObject if necessary.
- *
- * Returns: the error quark used for #NMObject errors.
- **/
-GQuark
-nm_object_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-object-error-quark");
- return quark;
-}
-
-typedef enum {
- NOTIFY_SIGNAL_PENDING_NONE,
- NOTIFY_SIGNAL_PENDING_ADDED,
- NOTIFY_SIGNAL_PENDING_REMOVED,
- NOTIFY_SIGNAL_PENDING_ADDED_REMOVED,
-} NotifySignalPending;
-
-typedef struct {
- const char *property;
- const char *signal_prefix;
- NotifySignalPending pending;
- NMObject *changed;
-} NotifyItem;
-
-static void
-notify_item_free (NotifyItem *item)
-{
- g_clear_object (&item->changed);
- g_slice_free (NotifyItem, item);
-}
-
-static void
-proxy_name_owner_changed (DBusGProxy *proxy,
- const char *name,
- const char *old_owner,
- const char *new_owner,
- gpointer user_data)
-{
- NMObject *self = NM_OBJECT (user_data);
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
-
- if (g_strcmp0 (name, NM_DBUS_SERVICE) == 0) {
- gboolean old_good = (old_owner && old_owner[0]);
- gboolean new_good = (new_owner && new_owner[0]);
-
- if (!old_good && new_good)
- priv->nm_running = TRUE;
- else if (old_good && !new_good)
- priv->nm_running = FALSE;
- }
-}
-
-static void
-nm_object_init (NMObject *object)
-{
-}
-
-static GObject*
-constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- NMObjectPrivate *priv;
-
- object = G_OBJECT_CLASS (nm_object_parent_class)->constructor (type,
- n_construct_params,
- construct_params);
-
- priv = NM_OBJECT_GET_PRIVATE (object);
-
- if (priv->connection == NULL) {
- GError *error = NULL;
-
- priv->connection = _nm_dbus_new_connection (&error);
-
- if (priv->connection == NULL) {
- g_warning ("Error connecting to system bus: %s", error->message);
- g_clear_error (&error);
- g_object_unref (object);
- return NULL;
- }
- }
-
- g_assert (priv->connection != NULL);
-
- if (priv->path == NULL) {
- g_warn_if_reached ();
- g_object_unref (object);
- return NULL;
- }
-
- return object;
-}
-
-static void
-constructed (GObject *object)
-{
- NMObject *self = NM_OBJECT (object);
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
-
- if (G_OBJECT_CLASS (nm_object_parent_class)->constructed)
- G_OBJECT_CLASS (nm_object_parent_class)->constructed (object);
-
- priv->properties_proxy = _nm_object_new_proxy (self, NULL, DBUS_INTERFACE_PROPERTIES);
-
- priv->bus_proxy = dbus_g_proxy_new_for_name (priv->connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- g_assert (priv->bus_proxy);
-
- dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->bus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (proxy_name_owner_changed),
- object, NULL);
-}
-
-static gboolean
-init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (initable);
-
- if (priv->bus_proxy) {
- if (!dbus_g_proxy_call (priv->bus_proxy,
- "NameHasOwner", error,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &priv->nm_running,
- G_TYPE_INVALID))
- return FALSE;
- }
-
- priv->inited = TRUE;
- return _nm_object_reload_properties (NM_OBJECT (initable), error);
-}
-
-/* Takes ownership of @error */
-static void
-init_async_complete (GSimpleAsyncResult *simple, GError *error)
-{
- if (error)
- g_simple_async_result_take_error (simple, error);
- else
- g_simple_async_result_set_op_res_gboolean (simple, TRUE);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-}
-
-static void
-init_async_got_properties (GObject *object, GAsyncResult *result, gpointer user_data)
-{
- GSimpleAsyncResult *simple = user_data;
- GError *error = NULL;
-
- NM_OBJECT_GET_PRIVATE (object)->inited = TRUE;
- if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error))
- g_assert (error);
- init_async_complete (simple, error);
-}
-
-static void
-init_async_got_manager_running (DBusGProxy *proxy, DBusGProxyCall *call,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple = user_data;
- NMObject *self;
- NMObjectPrivate *priv;
- GError *error = NULL;
-
- self = NM_OBJECT (g_async_result_get_source_object (G_ASYNC_RESULT (simple)));
- priv = NM_OBJECT_GET_PRIVATE (self);
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_BOOLEAN, &priv->nm_running,
- G_TYPE_INVALID)) {
- init_async_complete (simple, error);
- } else if (!priv->nm_running) {
- priv->inited = TRUE;
- init_async_complete (simple, NULL);
- } else
- _nm_object_reload_properties_async (self, init_async_got_properties, simple);
-
- /* g_async_result_get_source_object() adds a ref */
- g_object_unref (self);
-}
-
-static void
-init_async (GAsyncInitable *initable, int io_priority,
- GCancellable *cancellable, GAsyncReadyCallback callback,
- gpointer user_data)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (initable);
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async);
- if (cancellable)
- g_simple_async_result_set_check_cancellable (simple, cancellable);
-
- /* Check if NM is running */
- dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
- init_async_got_manager_running,
- simple, NULL,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID);
-}
-
-static gboolean
-init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- else
- return TRUE;
-}
-
-static void
-dispose (GObject *object)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
-
- if (priv->notify_id) {
- g_source_remove (priv->notify_id);
- priv->notify_id = 0;
- }
-
- g_slist_free_full (priv->notify_items, (GDestroyNotify) notify_item_free);
- priv->notify_items = NULL;
-
- g_slist_free_full (priv->property_interfaces, g_free);
- priv->property_interfaces = NULL;
-
- g_clear_object (&priv->properties_proxy);
- g_clear_object (&priv->bus_proxy);
-
- if (priv->connection) {
- dbus_g_connection_unref (priv->connection);
- priv->connection = NULL;
- }
-
- G_OBJECT_CLASS (nm_object_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
-
- g_slist_free_full (priv->property_tables, (GDestroyNotify) g_hash_table_destroy);
- g_free (priv->path);
-
- G_OBJECT_CLASS (nm_object_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_DBUS_CONNECTION:
- /* construct-only */
- priv->connection = g_value_dup_boxed (value);
- break;
- case PROP_DBUS_PATH:
- /* construct-only */
- priv->path = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_DBUS_CONNECTION:
- g_value_set_boxed (value, priv->connection);
- break;
- case PROP_DBUS_PATH:
- g_value_set_string (value, priv->path);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_object_class_init (NMObjectClass *nm_object_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (nm_object_class);
-
- g_type_class_add_private (nm_object_class, sizeof (NMObjectPrivate));
-
- /* virtual methods */
- object_class->constructor = constructor;
- object_class->constructed = constructed;
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- /* Properties */
-
- /**
- * NMObject:connection:
- *
- * The #DBusGConnection of the object.
- **/
- g_object_class_install_property
- (object_class, PROP_DBUS_CONNECTION,
- g_param_spec_boxed (NM_OBJECT_DBUS_CONNECTION, "", "",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMObject:path:
- *
- * The DBus object path.
- **/
- g_object_class_install_property
- (object_class, PROP_DBUS_PATH,
- g_param_spec_string (NM_OBJECT_DBUS_PATH, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /* signals */
-
- /**
- * NMObject::object-creation-failed:
- * @master_object: the object that received the signal
- * @error: the error that occurred while creating object
- * @failed_path: object path of the failed object
- *
- * Indicates that an error occurred while creating an #NMObject object
- * during property handling of @master_object.
- *
- * Note: Be aware that the signal is private for libnm-glib's internal
- * use.
- **/
- signals[OBJECT_CREATION_FAILED] =
- g_signal_new ("object-creation-failed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMObjectClass, object_creation_failed),
- NULL, NULL, NULL,
- G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
-}
-
-static void
-nm_object_initable_iface_init (GInitableIface *iface)
-{
- iface->init = init_sync;
-}
-
-static void
-nm_object_async_initable_iface_init (GAsyncInitableIface *iface)
-{
- iface->init_async = init_async;
- iface->init_finish = init_finish;
-}
-
-/**
- * nm_object_get_connection:
- * @object: a #NMObject
- *
- * Gets the #NMObject's DBusGConnection.
- *
- * Returns: (transfer none): the connection
- **/
-DBusGConnection *
-nm_object_get_connection (NMObject *object)
-{
- g_return_val_if_fail (NM_IS_OBJECT (object), NULL);
-
- return NM_OBJECT_GET_PRIVATE (object)->connection;
-}
-
-/**
- * nm_object_get_path:
- * @object: a #NMObject
- *
- * Gets the DBus path of the #NMObject.
- *
- * Returns: the object's path. This is the internal string used by the
- * device, and must not be modified.
- **/
-const char *
-nm_object_get_path (NMObject *object)
-{
- g_return_val_if_fail (NM_IS_OBJECT (object), NULL);
-
- return NM_OBJECT_GET_PRIVATE (object)->path;
-}
-
-static gboolean
-deferred_notify_cb (gpointer data)
-{
- NMObject *object = NM_OBJECT (data);
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
- NMObjectClass *object_class = NM_OBJECT_GET_CLASS (object);
- GSList *props, *iter;
-
- priv->notify_id = 0;
-
- /* Wait until all reloads are done before notifying */
- if (priv->reload_remaining)
- return G_SOURCE_REMOVE;
-
- /* Clear priv->notify_items early so that an NMObject subclass that
- * listens to property changes can queue up other property changes
- * during the g_object_notify() call separately from the property
- * list we're iterating.
- */
- props = g_slist_reverse (priv->notify_items);
- priv->notify_items = NULL;
-
- g_object_ref (object);
-
- /* Emit property change notifications first */
- for (iter = props; iter; iter = g_slist_next (iter)) {
- NotifyItem *item = iter->data;
-
- if (item->property)
- g_object_notify (G_OBJECT (object), item->property);
- }
-
- /* And added/removed signals second */
- for (iter = props; iter; iter = g_slist_next (iter)) {
- NotifyItem *item = iter->data;
- char buf[50];
- int ret = 0;
-
- switch (item->pending) {
- case NOTIFY_SIGNAL_PENDING_ADDED:
- ret = g_snprintf (buf, sizeof (buf), "%s-added", item->signal_prefix);
- break;
- case NOTIFY_SIGNAL_PENDING_REMOVED:
- ret = g_snprintf (buf, sizeof (buf), "%s-removed", item->signal_prefix);
- break;
- case NOTIFY_SIGNAL_PENDING_ADDED_REMOVED:
- // XXX
- if (object_class->object_creation_failed)
- object_class->object_creation_failed (object, NULL, g_strdup (nm_object_get_path (item->changed)));
- break;
- case NOTIFY_SIGNAL_PENDING_NONE:
- default:
- break;
- }
- if (ret > 0) {
- g_assert (ret < sizeof (buf));
- g_signal_emit_by_name (object, buf, item->changed);
- }
- }
- g_object_unref (object);
-
- g_slist_free_full (props, (GDestroyNotify) notify_item_free);
- return G_SOURCE_REMOVE;
-}
-
-static void
-_nm_object_defer_notify (NMObject *object)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
-
- if (!priv->notify_id)
- priv->notify_id = g_idle_add_full (G_PRIORITY_LOW, deferred_notify_cb, object, NULL);
-}
-
-static void
-_nm_object_queue_notify_full (NMObject *object,
- const char *property,
- const char *signal_prefix,
- gboolean added,
- NMObject *changed)
-{
- NMObjectPrivate *priv;
- NotifyItem *item;
- GSList *iter;
-
- g_return_if_fail (NM_IS_OBJECT (object));
- g_return_if_fail (!signal_prefix != !property);
- g_return_if_fail (!signal_prefix == !changed);
-
- priv = NM_OBJECT_GET_PRIVATE (object);
- _nm_object_defer_notify (object);
-
- property = g_intern_string (property);
- signal_prefix = g_intern_string (signal_prefix);
- for (iter = priv->notify_items; iter; iter = g_slist_next (iter)) {
- item = iter->data;
-
- if (property && (property == item->property))
- return;
-
- /* Collapse signals for the same object (such as "added->removed") to
- * ensure we don't emit signals when their sum should have no effect.
- * The "added->removed->removed" sequence requires special handling,
- * hence the addition of the ADDED_REMOVED state to ensure that no
- * signal is emitted in this case:
- *
- * Without the ADDED_REMOVED state:
- * NONE + added -> ADDED
- * ADDED + removed -> NONE
- * NONE + removed -> REMOVED (would emit 'removed' signal)
- *
- * With the ADDED_REMOVED state:
- * NONE | ADDED_REMOVED + added -> ADDED
- * ADDED + removed -> ADDED_REMOVED
- * ADDED_REMOVED + removed -> ADDED_REMOVED (emits no signal)
- */
- if (signal_prefix && (changed == item->changed) && (item->signal_prefix == signal_prefix)) {
- switch (item->pending) {
- case NOTIFY_SIGNAL_PENDING_ADDED:
- if (!added)
- item->pending = NOTIFY_SIGNAL_PENDING_ADDED_REMOVED;
- break;
- case NOTIFY_SIGNAL_PENDING_REMOVED:
- if (added)
- item->pending = NOTIFY_SIGNAL_PENDING_NONE;
- break;
- case NOTIFY_SIGNAL_PENDING_ADDED_REMOVED:
- if (added)
- item->pending = NOTIFY_SIGNAL_PENDING_ADDED;
- break;
- case NOTIFY_SIGNAL_PENDING_NONE:
- item->pending = added ? NOTIFY_SIGNAL_PENDING_ADDED : NOTIFY_SIGNAL_PENDING_REMOVED;
- break;
- default:
- g_assert_not_reached ();
- }
- return;
- }
- }
-
- item = g_slice_new0 (NotifyItem);
- item->property = property;
- if (signal_prefix) {
- item->signal_prefix = signal_prefix;
- item->pending = added ? NOTIFY_SIGNAL_PENDING_ADDED : NOTIFY_SIGNAL_PENDING_REMOVED;
- item->changed = changed ? g_object_ref (changed) : NULL;
- }
- priv->notify_items = g_slist_prepend (priv->notify_items, item);
-}
-
-void
-_nm_object_queue_notify (NMObject *object, const char *property)
-{
- _nm_object_queue_notify_full (object, property, NULL, FALSE, NULL);
-}
-
-void
-_nm_object_register_type_func (GType base_type, NMObjectTypeFunc type_func,
- NMObjectTypeAsyncFunc type_async_func)
-{
- g_hash_table_insert (type_funcs,
- GSIZE_TO_POINTER (base_type),
- type_func);
- g_hash_table_insert (type_async_funcs,
- GSIZE_TO_POINTER (base_type),
- type_async_func);
-}
-
-static GObject *
-_nm_object_create (GType type, DBusGConnection *connection, const char *path)
-{
- NMObjectTypeFunc type_func;
- GObject *object;
- GError *error = NULL;
-
- type_func = g_hash_table_lookup (type_funcs, GSIZE_TO_POINTER (type));
- if (type_func)
- type = type_func (connection, path);
-
- if (type == G_TYPE_INVALID) {
- dbgmsg ("Could not create object for %s: unknown object type", path);
- return NULL;
- }
-
- object = g_object_new (type,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
- if (NM_IS_OBJECT (object))
- _nm_object_cache_add (NM_OBJECT (object));
- if (!g_initable_init (G_INITABLE (object), NULL, &error)) {
- dbgmsg ("Could not create object for %s: %s", path, error->message);
- g_error_free (error);
- g_clear_object (&object);
- }
-
- return object;
-}
-
-typedef void (*NMObjectCreateCallbackFunc) (GObject *, const char *, gpointer);
-typedef struct {
- DBusGConnection *connection;
- char *path;
- NMObjectCreateCallbackFunc callback;
- gpointer user_data;
-} NMObjectTypeAsyncData;
-
-static void
-create_async_complete (GObject *object, NMObjectTypeAsyncData *async_data)
-{
- async_data->callback (object, async_data->path, async_data->user_data);
-
- g_free (async_data->path);
- g_slice_free (NMObjectTypeAsyncData, async_data);
-}
-
-static const char *
-nm_object_or_connection_get_path (gpointer instance)
-{
- if (NM_IS_OBJECT (instance))
- return nm_object_get_path (instance);
- else if (NM_IS_CONNECTION (instance))
- return nm_connection_get_path (instance);
-
- g_assert_not_reached ();
-}
-
-static void
-async_inited (GObject *source, GAsyncResult *result, gpointer user_data)
-{
- NMObjectTypeAsyncData *async_data = user_data;
- GObject *object = G_OBJECT (source);
- GError *error = NULL;
-
- if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, &error)) {
- dbgmsg ("Could not create object for %s: %s",
- nm_object_or_connection_get_path (object),
- error->message);
- g_error_free (error);
- g_clear_object (&object);
- }
-
- create_async_complete (object, async_data);
-}
-
-static void
-async_got_type (GType type, gpointer user_data)
-{
- NMObjectTypeAsyncData *async_data = user_data;
- GObject *object;
-
- /* Ensure we don't have the object already; we may get multiple type
- * requests for the same object if there are multiple properties on
- * other objects that refer to the object at this path. One of those
- * other requests may have already completed.
- */
- object = (GObject *) _nm_object_cache_get (async_data->path);
- if (object) {
- create_async_complete (object, async_data);
- return;
- }
-
- if (type == G_TYPE_INVALID) {
- /* Don't know how to create this object */
- create_async_complete (NULL, async_data);
- return;
- }
-
- object = g_object_new (type,
- NM_OBJECT_DBUS_CONNECTION, async_data->connection,
- NM_OBJECT_DBUS_PATH, async_data->path,
- NULL);
- g_warn_if_fail (object != NULL);
- if (NM_IS_OBJECT (object))
- _nm_object_cache_add (NM_OBJECT (object));
- g_async_initable_init_async (G_ASYNC_INITABLE (object), G_PRIORITY_DEFAULT,
- NULL, async_inited, async_data);
-}
-
-static void
-_nm_object_create_async (GType type, DBusGConnection *connection, const char *path,
- NMObjectCreateCallbackFunc callback, gpointer user_data)
-{
- NMObjectTypeAsyncFunc type_async_func;
- NMObjectTypeFunc type_func;
- NMObjectTypeAsyncData *async_data;
-
- async_data = g_slice_new (NMObjectTypeAsyncData);
- async_data->connection = connection;
- async_data->path = g_strdup (path);
- async_data->callback = callback;
- async_data->user_data = user_data;
-
- type_async_func = g_hash_table_lookup (type_async_funcs, GSIZE_TO_POINTER (type));
- if (type_async_func) {
- type_async_func (connection, path, async_got_type, async_data);
- return;
- }
-
- type_func = g_hash_table_lookup (type_funcs, GSIZE_TO_POINTER (type));
- if (type_func)
- type = type_func (connection, path);
-
- async_got_type (type, async_data);
-}
-
-/* Stolen from dbus-glib */
-static char*
-wincaps_to_dash (const char *caps)
-{
- const char *p;
- GString *str;
-
- str = g_string_new (NULL);
- p = caps;
- while (*p) {
- if (g_ascii_isupper (*p)) {
- if (str->len > 0 && (str->len < 2 || str->str[str->len-2] != '-'))
- g_string_append_c (str, '-');
- g_string_append_c (str, g_ascii_tolower (*p));
- } else
- g_string_append_c (str, *p);
- ++p;
- }
-
- return g_string_free (str, FALSE);
-}
-
-/* Adds object to array if it's not already there */
-static void
-add_to_object_array_unique (GPtrArray *array, GObject *obj)
-{
- guint i;
-
- g_return_if_fail (array != NULL);
-
- if (obj != NULL) {
- for (i = 0; i < array->len; i++) {
- if (g_ptr_array_index (array, i) == obj) {
- g_object_unref (obj);
- return;
- }
- }
- g_ptr_array_add (array, obj);
- }
-}
-
-typedef struct {
- NMObject *self;
- PropertyInfo *pi;
-
- GObject **objects;
- int length, remaining;
-
- gboolean array;
- const char *property_name;
-} ObjectCreatedData;
-
-/* Places items from 'needles' that are not in 'haystack' into 'diff' */
-static void
-array_diff (GPtrArray *needles, GPtrArray *haystack, GPtrArray *diff)
-{
- guint i, j;
- GObject *obj;
-
- g_assert (needles);
- g_assert (haystack);
- g_assert (diff);
-
- for (i = 0; i < needles->len; i++) {
- obj = g_ptr_array_index (needles, i);
-
- for (j = 0; j < haystack->len; j++) {
- if (g_ptr_array_index (haystack, j) == obj)
- break;
- }
-
- if (j == haystack->len)
- g_ptr_array_add (diff, obj);
- }
-}
-
-static void
-queue_added_removed_signal (NMObject *self,
- const char *signal_prefix,
- NMObject *changed,
- gboolean added)
-{
- _nm_object_queue_notify_full (self, NULL, signal_prefix, added, changed);
-}
-
-static void
-object_property_complete (ObjectCreatedData *odata)
-{
- NMObject *self = odata->self;
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
- PropertyInfo *pi = odata->pi;
- gboolean different = TRUE;
-
- if (odata->array) {
- GPtrArray *old = *((GPtrArray **) pi->field);
- GPtrArray *new;
- int i;
-
- /* Build up new array */
- new = g_ptr_array_sized_new (odata->length);
- for (i = 0; i < odata->length; i++)
- add_to_object_array_unique (new, odata->objects[i]);
-
- if (pi->signal_prefix) {
- GPtrArray *added = g_ptr_array_sized_new (3);
- GPtrArray *removed = g_ptr_array_sized_new (3);
-
- if (old) {
- /* Find objects in 'old' that do not exist in 'new' */
- array_diff (old, new, removed);
-
- /* Find objects in 'new' that do not exist in old */
- array_diff (new, old, added);
- } else {
- for (i = 0; i < new->len; i++)
- g_ptr_array_add (added, g_ptr_array_index (new, i));
- }
-
- *((GPtrArray **) pi->field) = new;
-
- /* Emit added & removed */
- for (i = 0; i < removed->len; i++) {
- queue_added_removed_signal (self,
- pi->signal_prefix,
- g_ptr_array_index (removed, i),
- FALSE);
- }
-
- for (i = 0; i < added->len; i++) {
- queue_added_removed_signal (self,
- pi->signal_prefix,
- g_ptr_array_index (added, i),
- TRUE);
- }
-
- different = removed->len || added->len;
- g_ptr_array_free (added, TRUE);
- g_ptr_array_free (removed, TRUE);
- } else {
- /* No added/removed signals to send, just replace the property with
- * the new values.
- */
- *((GPtrArray **) pi->field) = new;
- different = TRUE;
- }
-
- /* Free old array last since it will release references, thus freeing
- * any objects in the 'removed' array.
- */
- if (old)
- g_boxed_free (NM_TYPE_OBJECT_ARRAY, old);
- } else {
- GObject **obj_p = pi->field;
-
- different = (*obj_p != odata->objects[0]);
- if (*obj_p)
- g_object_unref (*obj_p);
- *obj_p = odata->objects[0];
- }
-
- if (different && odata->property_name)
- _nm_object_queue_notify (self, odata->property_name);
-
- if (--priv->reload_remaining == 0)
- reload_complete (self, FALSE);
-
- g_object_unref (self);
- g_free (odata->objects);
- g_slice_free (ObjectCreatedData, odata);
-}
-
-static void
-object_created (GObject *obj, const char *path, gpointer user_data)
-{
- ObjectCreatedData *odata = user_data;
-
- /* We assume that on error, the creator_func printed something */
-
- if (obj == NULL && g_strcmp0 (path, "/") != 0 ) {
- GError *error;
- error = g_error_new (NM_OBJECT_ERROR,
- NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE,
- "Creating object for path '%s' failed in libnm-glib.",
- path);
- /* Emit a signal about the error. */
- g_signal_emit (odata->self, signals[OBJECT_CREATION_FAILED], 0, error, path);
- g_error_free (error);
- }
-
- odata->objects[--odata->remaining] = obj;
- if (!odata->remaining)
- object_property_complete (odata);
-}
-
-static gboolean
-handle_object_property (NMObject *self, const char *property_name, GValue *value,
- PropertyInfo *pi, gboolean synchronously)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
- GObject *obj;
- const char *path;
- ObjectCreatedData *odata;
-
- odata = g_slice_new (ObjectCreatedData);
- odata->self = g_object_ref (self);
- odata->pi = pi;
- odata->objects = g_new (GObject *, 1);
- odata->length = odata->remaining = 1;
- odata->array = FALSE;
- odata->property_name = property_name;
-
- priv->reload_remaining++;
-
- path = g_value_get_boxed (value);
-
- if (!strcmp (path, "/")) {
- object_created (NULL, path, odata);
- return TRUE;
- }
-
- obj = G_OBJECT (_nm_object_cache_get (path));
- if (obj) {
- object_created (obj, path, odata);
- return TRUE;
- } else if (synchronously) {
- obj = _nm_object_create (pi->object_type, priv->connection, path);
- object_created (obj, path, odata);
- return obj != NULL;
- } else {
- _nm_object_create_async (pi->object_type, priv->connection, path,
- object_created, odata);
- /* Assume success */
- return TRUE;
- }
-}
-
-static gboolean
-handle_object_array_property (NMObject *self, const char *property_name, GValue *value,
- PropertyInfo *pi, gboolean synchronously)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
- GObject *obj;
- GPtrArray *paths;
- GPtrArray **array = pi->field;
- const char *path;
- ObjectCreatedData *odata;
- int i;
-
- paths = g_value_get_boxed (value);
-
- odata = g_slice_new (ObjectCreatedData);
- odata->self = g_object_ref (self);
- odata->pi = pi;
- odata->objects = g_new0 (GObject *, paths->len);
- odata->length = odata->remaining = paths->len;
- odata->array = TRUE;
- odata->property_name = property_name;
-
- priv->reload_remaining++;
-
- if (paths->len == 0) {
- object_property_complete (odata);
- return TRUE;
- }
-
- for (i = 0; i < paths->len; i++) {
- path = paths->pdata[i];
- if (!strcmp (path, "/")) {
- /* FIXME: can't happen? */
- continue;
- }
-
- obj = G_OBJECT (_nm_object_cache_get (path));
- if (obj) {
- object_created (obj, path, odata);
- } else if (synchronously) {
- obj = _nm_object_create (pi->object_type, priv->connection, path);
- object_created (obj, path, odata);
- } else {
- _nm_object_create_async (pi->object_type, priv->connection, path,
- object_created, odata);
- }
- }
-
- if (!synchronously) {
- /* Assume success */
- return TRUE;
- }
-
- return *array && ((*array)->len == paths->len);
-}
-
-static void
-handle_property_changed (NMObject *self, const char *dbus_name, GValue *value, gboolean synchronously)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
- char *prop_name;
- PropertyInfo *pi;
- GParamSpec *pspec;
- gboolean success = FALSE, found = FALSE;
- GSList *iter;
-
- prop_name = wincaps_to_dash (dbus_name);
-
- /* Iterate through the object and its parents to find the property */
- for (iter = priv->property_tables; iter; iter = g_slist_next (iter)) {
- pi = g_hash_table_lookup ((GHashTable *) iter->data, prop_name);
- if (pi) {
- if (!pi->field) {
- /* We know about this property but aren't tracking changes on it. */
- goto out;
- }
-
- found = TRUE;
- break;
- }
- }
-
- if (!found) {
- dbgmsg ("Property '%s' unhandled.", prop_name);
- goto out;
- }
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (self)), prop_name);
- if (!pspec) {
- dbgmsg ("%s: property '%s' changed but wasn't defined by object type %s.",
- __func__,
- prop_name,
- G_OBJECT_TYPE_NAME (self));
- goto out;
- }
-
- if (G_UNLIKELY (debug)) {
- char *s;
- s = g_strdup_value_contents (value);
- dbgmsg ("PC: (%p) %s::%s => '%s' (%s%s%s)",
- self, G_OBJECT_TYPE_NAME (self),
- prop_name,
- s,
- G_VALUE_TYPE_NAME (value),
- pi->object_type ? " / " : "",
- pi->object_type ? g_type_name (pi->object_type) : "");
- g_free (s);
- }
-
- if (pi->object_type) {
- if (G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
- success = handle_object_property (self, pspec->name, value, pi, synchronously);
- else if (G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH))
- success = handle_object_array_property (self, pspec->name, value, pi, synchronously);
- else {
- g_warn_if_reached ();
- goto out;
- }
- } else
- success = (*(pi->func)) (self, pspec, value, pi->field);
-
- if (!success) {
- dbgmsg ("%s: failed to update property '%s' of object type %s.",
- __func__,
- prop_name,
- G_OBJECT_TYPE_NAME (self));
- }
-
-out:
- g_free (prop_name);
-}
-
-static void
-process_properties_changed (NMObject *self, GHashTable *properties, gboolean synchronously)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
- GHashTableIter iter;
- gpointer name, value;
-
- if (priv->suppress_property_updates)
- return;
-
- g_hash_table_iter_init (&iter, properties);
- while (g_hash_table_iter_next (&iter, &name, &value)) {
- if (value)
- handle_property_changed (self, name, value, synchronously);
- else {
- dbgmsg ("%s:%d %s(): object %s property '%s' value is unexpectedly NULL",
- __FILE__, __LINE__, __func__, G_OBJECT_TYPE_NAME (self), (const char *) name);
- }
- }
-}
-
-static void
-properties_changed_proxy (DBusGProxy *proxy,
- GHashTable *properties,
- gpointer user_data)
-{
- process_properties_changed (NM_OBJECT (user_data), properties, FALSE);
-}
-
-#define HANDLE_TYPE(ucase, lcase, getter) \
- } else if (pspec->value_type == G_TYPE_##ucase) { \
- if (G_VALUE_HOLDS_##ucase (value)) { \
- g##lcase *param = (g##lcase *) field; \
- *param = g_value_get_##getter (value); \
- } else { \
- success = FALSE; \
- goto done; \
- }
-
-static gboolean
-demarshal_generic (NMObject *object,
- GParamSpec *pspec,
- GValue *value,
- gpointer field)
-{
- gboolean success = TRUE;
-
- if (pspec->value_type == G_TYPE_STRING) {
- if (G_VALUE_HOLDS_STRING (value)) {
- char **param = (char **) field;
- g_free (*param);
- *param = g_value_dup_string (value);
- } else if (G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) {
- char **param = (char **) field;
- g_free (*param);
- *param = g_strdup (g_value_get_boxed (value));
- /* Handle "NULL" object paths */
- if (g_strcmp0 (*param, "/") == 0) {
- g_free (*param);
- *param = NULL;
- }
- } else {
- success = FALSE;
- goto done;
- }
- HANDLE_TYPE(BOOLEAN, boolean, boolean)
- HANDLE_TYPE(CHAR, char, schar)
- HANDLE_TYPE(UCHAR, uchar, uchar)
- HANDLE_TYPE(DOUBLE, double, double)
- HANDLE_TYPE(INT, int, int)
- HANDLE_TYPE(UINT, uint, uint)
- HANDLE_TYPE(INT64, int64, int64)
- HANDLE_TYPE(UINT64, uint64, uint64)
- HANDLE_TYPE(LONG, long, long)
- HANDLE_TYPE(ULONG, ulong, ulong)
- } else {
- dbgmsg ("%s: %s/%s unhandled type %s.",
- __func__,
- G_OBJECT_TYPE_NAME (object),
- pspec->name,
- g_type_name (pspec->value_type));
- success = FALSE;
- }
-
-done:
- if (success) {
- _nm_object_queue_notify (object, pspec->name);
- } else {
- dbgmsg ("%s: %s/%s (type %s) couldn't be set with type %s.",
- __func__, G_OBJECT_TYPE_NAME (object), pspec->name,
- g_type_name (pspec->value_type), G_VALUE_TYPE_NAME (value));
- }
- return success;
-}
-
-void
-_nm_object_register_properties (NMObject *object,
- DBusGProxy *proxy,
- const NMPropertiesInfo *info)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
- static gsize dval = 0;
- const char *debugstr;
- NMPropertiesInfo *tmp;
- GHashTable *instance;
-
- g_return_if_fail (NM_IS_OBJECT (object));
- g_return_if_fail (proxy != NULL);
- g_return_if_fail (info != NULL);
-
- if (g_once_init_enter (&dval)) {
- debugstr = getenv ("LIBNM_GLIB_DEBUG");
- if (debugstr && strstr (debugstr, "properties-changed"))
- debug = TRUE;
- g_once_init_leave (&dval, 1);
- }
-
- priv->property_interfaces = g_slist_prepend (priv->property_interfaces,
- g_strdup (dbus_g_proxy_get_interface (proxy)));
-
- dbus_g_proxy_add_signal (proxy, "PropertiesChanged", DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy,
- "PropertiesChanged",
- G_CALLBACK (properties_changed_proxy),
- object,
- NULL);
-
- instance = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- priv->property_tables = g_slist_prepend (priv->property_tables, instance);
-
- for (tmp = (NMPropertiesInfo *) info; tmp->name; tmp++) {
- PropertyInfo *pi;
-
- if (!tmp->name || (tmp->func && !tmp->field)) {
- g_warning ("%s: missing field in NMPropertiesInfo", __func__);
- continue;
- }
-
- pi = g_malloc0 (sizeof (PropertyInfo));
- pi->func = tmp->func ?: demarshal_generic;
- pi->object_type = tmp->object_type;
- pi->field = tmp->field;
- pi->signal_prefix = tmp->signal_prefix;
- g_hash_table_insert (instance, g_strdup (tmp->name), pi);
- }
-}
-
-gboolean
-_nm_object_reload_properties (NMObject *object, GError **error)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
- GHashTable *props = NULL;
- GSList *p;
-
- if (!priv->property_interfaces || !priv->nm_running)
- return TRUE;
-
- priv->reload_remaining++;
-
- for (p = priv->property_interfaces; p; p = p->next) {
- if (!dbus_g_proxy_call (priv->properties_proxy, "GetAll", error,
- G_TYPE_STRING, p->data,
- G_TYPE_INVALID,
- DBUS_TYPE_G_MAP_OF_VARIANT, &props,
- G_TYPE_INVALID))
- return FALSE;
-
- process_properties_changed (object, props, TRUE);
- g_hash_table_destroy (props);
- }
-
- if (--priv->reload_remaining == 0)
- reload_complete (object, TRUE);
-
- return TRUE;
-}
-
-void
-_nm_object_suppress_property_updates (NMObject *object, gboolean suppress)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
-
- priv->suppress_property_updates = suppress;
-}
-
-void
-_nm_object_ensure_inited (NMObject *object)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
- GError *error = NULL;
-
- if (!priv->inited) {
- if (!g_initable_init (G_INITABLE (object), NULL, &error)) {
- dbgmsg ("Could not initialize %s %s: %s",
- G_OBJECT_TYPE_NAME (object),
- priv->path,
- error->message);
- g_error_free (error);
-
- /* Only warn once */
- priv->inited = TRUE;
- }
- }
-}
-
-void
-_nm_object_reload_property (NMObject *object,
- const char *interface,
- const char *prop_name)
-{
- GValue value = G_VALUE_INIT;
- GError *err = NULL;
-
- g_return_if_fail (NM_IS_OBJECT (object));
- g_return_if_fail (interface != NULL);
- g_return_if_fail (prop_name != NULL);
-
- if (!NM_OBJECT_GET_PRIVATE (object)->nm_running)
- return;
-
- if (!dbus_g_proxy_call_with_timeout (NM_OBJECT_GET_PRIVATE (object)->properties_proxy,
- "Get", 15000, &err,
- G_TYPE_STRING, interface,
- G_TYPE_STRING, prop_name,
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID)) {
- dbgmsg ("%s: Error getting '%s' for %s: %s\n",
- __func__,
- prop_name,
- nm_object_get_path (object),
- err->message);
- g_clear_error (&err);
- return;
- }
-
- handle_property_changed (object, prop_name, &value, TRUE);
- g_value_unset (&value);
-}
-
-void
-_nm_object_set_property (NMObject *object,
- const char *interface,
- const char *prop_name,
- GValue *value)
-{
- g_return_if_fail (NM_IS_OBJECT (object));
- g_return_if_fail (interface != NULL);
- g_return_if_fail (prop_name != NULL);
- g_return_if_fail (G_IS_VALUE (value));
-
- if (!NM_OBJECT_GET_PRIVATE (object)->nm_running)
- return;
-
- if (!dbus_g_proxy_call_with_timeout (NM_OBJECT_GET_PRIVATE (object)->properties_proxy,
- "Set", 2000, NULL,
- G_TYPE_STRING, interface,
- G_TYPE_STRING, prop_name,
- G_TYPE_VALUE, value,
- G_TYPE_INVALID)) {
-
- /* Ignore errors. dbus_g_proxy_call_with_timeout() is called instead of
- * dbus_g_proxy_call_no_reply() to give NM chance to authenticate the caller.
- */
- }
-}
-
-static void
-reload_complete (NMObject *object, gboolean emit_now)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
- GSimpleAsyncResult *simple;
- GSList *results, *iter;
- GError *error;
-
- if (emit_now) {
- if (priv->notify_id) {
- g_source_remove (priv->notify_id);
- priv->notify_id = 0;
- }
- deferred_notify_cb (object);
- } else
- _nm_object_defer_notify (object);
-
- results = priv->reload_results;
- priv->reload_results = NULL;
- error = priv->reload_error;
- priv->reload_error = NULL;
-
- for (iter = results; iter; iter = iter->next) {
- simple = iter->data;
-
- if (error)
- g_simple_async_result_set_from_error (simple, error);
- else
- g_simple_async_result_set_op_res_gboolean (simple, TRUE);
-
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- }
- g_slist_free (results);
- g_clear_error (&error);
-}
-
-static void
-reload_got_properties (DBusGProxy *proxy, DBusGProxyCall *call,
- gpointer user_data)
-{
- NMObject *object = user_data;
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
- GHashTable *props = NULL;
- GError *error = NULL;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_VARIANT, &props,
- G_TYPE_INVALID)) {
- process_properties_changed (object, props, FALSE);
- g_hash_table_destroy (props);
- } else {
- if (priv->reload_error)
- g_error_free (error);
- else
- priv->reload_error = error;
- }
-
- if (--priv->reload_remaining == 0)
- reload_complete (object, FALSE);
-}
-
-void
-_nm_object_reload_properties_async (NMObject *object, GAsyncReadyCallback callback, gpointer user_data)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
- GSimpleAsyncResult *simple;
- GSList *p;
-
- simple = g_simple_async_result_new (G_OBJECT (object), callback,
- user_data, _nm_object_reload_properties_async);
-
- if (!priv->property_interfaces) {
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- priv->reload_results = g_slist_prepend (priv->reload_results, simple);
-
- /* If there was already a reload happening, we don't need to
- * re-read the properties again, we just need to wait for the
- * existing reload to finish.
- */
- if (priv->reload_results->next)
- return;
-
- for (p = priv->property_interfaces; p; p = p->next) {
- priv->reload_remaining++;
- dbus_g_proxy_begin_call (priv->properties_proxy, "GetAll",
- reload_got_properties, object, NULL,
- G_TYPE_STRING, p->data,
- G_TYPE_INVALID);
- }
-}
-
-gboolean
-_nm_object_reload_properties_finish (NMObject *object, GAsyncResult *result, GError **error)
-{
- GSimpleAsyncResult *simple;
-
- g_return_val_if_fail (NM_IS_OBJECT (object), FALSE);
- g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (object), _nm_object_reload_properties_async), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- return g_simple_async_result_get_op_res_gboolean (simple);
-}
-
-DBusGProxy *
-_nm_object_new_proxy (NMObject *self, const char *path, const char *interface)
-{
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
-
- return _nm_dbus_new_proxy_for_connection (priv->connection, path ?: priv->path, interface);
-}
diff --git a/libnm-glib/nm-object.h b/libnm-glib/nm-object.h
deleted file mode 100644
index d37fb683c5..0000000000
--- a/libnm-glib/nm-object.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#ifndef NM_OBJECT_H
-#define NM_OBJECT_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-version.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_OBJECT (nm_object_get_type ())
-#define NM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_OBJECT, NMObject))
-#define NM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_OBJECT, NMObjectClass))
-#define NM_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_OBJECT))
-#define NM_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_OBJECT))
-#define NM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_OBJECT, NMObjectClass))
-
-/**
- * NMObjectError:
- * @NM_OBJECT_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE: an error ocured while creating an #NMObject
- *
- * Describes errors that may result from operations involving a #NMObject.
- *
- **/
-typedef enum {
- NM_OBJECT_ERROR_UNKNOWN = 0,
- NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE,
-} NMObjectError;
-
-#define NM_OBJECT_ERROR nm_object_error_quark ()
-GQuark nm_object_error_quark (void);
-
-#define NM_OBJECT_DBUS_CONNECTION "dbus-connection"
-#define NM_OBJECT_DBUS_PATH "dbus-path"
-
-typedef struct {
- GObject parent;
-} NMObject;
-
-typedef struct {
- GObjectClass parent;
-
- /* Signals */
- /* The "object-creation-failed" signal is PRIVATE for libnm-glib and
- * is not meant for any external usage. It indicates that an error
- * occurred during creation of an object.
- */
- void (*object_creation_failed) (NMObject *master_object,
- GError *error,
- char *failed_path);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMObjectClass;
-
-GType nm_object_get_type (void);
-
-DBusGConnection *nm_object_get_connection (NMObject *object);
-const char *nm_object_get_path (NMObject *object);
-
-G_END_DECLS
-
-#endif /* NM_OBJECT_H */
diff --git a/libnm-glib/nm-remote-connection-private.h b/libnm-glib/nm-remote-connection-private.h
deleted file mode 100644
index e3f35428cd..0000000000
--- a/libnm-glib/nm-remote-connection-private.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2009 Red Hat, Inc.
- */
-
-#ifndef __NM_REMOTE_CONNECTION_PRIVATE_H__
-#define __NM_REMOTE_CONNECTION_PRIVATE_H__
-
-#define NM_REMOTE_CONNECTION_INIT_RESULT "init-result"
-
-typedef enum {
- NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN = 0,
- NM_REMOTE_CONNECTION_INIT_RESULT_SUCCESS,
- NM_REMOTE_CONNECTION_INIT_RESULT_ERROR,
- NM_REMOTE_CONNECTION_INIT_RESULT_INVISIBLE,
-} NMRemoteConnectionInitResult;
-
-#endif /* __NM_REMOTE_CONNECTION_PRIVATE__ */
diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c
deleted file mode 100644
index eb99ef355d..0000000000
--- a/libnm-glib/nm-remote-connection.c
+++ /dev/null
@@ -1,954 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2011 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "NetworkManager.h"
-#include "nm-utils.h"
-#include "nm-setting-connection.h"
-#include "nm-remote-connection.h"
-#include "nm-remote-connection-private.h"
-#include "nm-object-private.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-dbus-helpers-private.h"
-#include "nm-setting-private.h"
-
-#define NM_REMOTE_CONNECTION_BUS "bus"
-#define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection"
-#define NM_REMOTE_CONNECTION_DBUS_PATH "dbus-path"
-
-static void nm_remote_connection_initable_iface_init (GInitableIface *iface);
-static void nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION,
- G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_remote_connection_initable_iface_init);
- G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_remote_connection_async_initable_iface_init);
- )
-
-enum {
- PROP_0,
- PROP_BUS,
- PROP_DBUS_CONNECTION,
- PROP_DBUS_PATH,
- PROP_UNSAVED,
-
- LAST_PROP
-};
-
-enum {
- UPDATED,
- REMOVED,
- VISIBLE,
-
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-typedef struct RemoteCall RemoteCall;
-typedef void (*RemoteCallFetchResultCb) (RemoteCall *call, DBusGProxyCall *proxy_call, GError *error);
-
-struct RemoteCall {
- NMRemoteConnection *self;
- DBusGProxyCall *call;
- RemoteCallFetchResultCb fetch_result_cb;
- GFunc callback;
- gpointer user_data;
-};
-
-typedef struct {
- DBusGConnection *bus;
- DBusGProxy *proxy;
- DBusGProxy *props_proxy;
- gboolean proxy_is_destroyed;
- GSList *calls;
-
- gboolean inited;
- gboolean unsaved;
-
- gboolean visible;
-} NMRemoteConnectionPrivate;
-
-#define NM_REMOTE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionPrivate))
-
-/**
- * nm_remote_connection_error_quark:
- *
- * Registers an error quark for #NMRemoteConnection if necessary.
- *
- * Returns: the error quark used for #NMRemoteConnection errors.
- **/
-GQuark
-nm_remote_connection_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-remote-connection-error-quark");
- return quark;
-}
-
-/*****************************************************************************/
-
-static void
-_nm_remote_connection_ensure_inited (NMRemoteConnection *self)
-{
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
- GError *error = NULL;
-
- if (!priv->inited) {
- if (!g_initable_init (G_INITABLE (self), NULL, &error)) {
- /* Don't warn when the call times out because the settings service can't
- * be activated or whatever.
- */
- if (!g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) {
- g_warning ("%s: (NMRemoteConnection) error initializing: %s\n",
- __func__, error->message);
- }
- g_error_free (error);
- }
- priv->inited = TRUE;
- }
-}
-
-/*****************************************************************************/
-
-static void
-remote_call_dbus_cb (DBusGProxy *proxy, DBusGProxyCall *proxy_call, gpointer user_data)
-{
- RemoteCall *call = user_data;
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (call->self);
- GError *error = NULL;
-
- g_assert ( (!proxy && !proxy_call && priv->proxy_is_destroyed) ||
- ( proxy && proxy_call && !priv->proxy_is_destroyed && proxy == priv->proxy) );
-
- if (priv->proxy_is_destroyed) {
- error = g_error_new_literal (NM_REMOTE_CONNECTION_ERROR,
- NM_REMOTE_CONNECTION_ERROR_DISCONNECTED,
- _("Disconnected by D-Bus"));
- }
- call->fetch_result_cb (call, proxy_call, error);
- g_clear_error (&error);
-
- priv->calls = g_slist_remove (priv->calls, call);
- g_object_unref (call->self);
- g_free (call);
-}
-
-static gboolean
-remote_call_cleanup_cb (void *user_data)
-{
- remote_call_dbus_cb (NULL, NULL, user_data);
- return G_SOURCE_REMOVE;
-}
-
-static RemoteCall *
-remote_call_new (NMRemoteConnection *self,
- RemoteCallFetchResultCb fetch_result_cb,
- GFunc callback,
- gpointer user_data)
-{
- RemoteCall *call;
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
-
- g_assert (fetch_result_cb);
-
- if (priv->proxy_is_destroyed && !callback)
- return NULL;
-
- call = g_malloc0 (sizeof (RemoteCall));
- call->self = g_object_ref (self);
- call->fetch_result_cb = fetch_result_cb;
- call->user_data = user_data;
- call->callback = callback;
-
- if (priv->proxy_is_destroyed) {
- g_idle_add (remote_call_cleanup_cb, call);
- return NULL;
- }
- priv->calls = g_slist_prepend (priv->calls, call);
- return call;
-}
-
-static void
-proxy_set_destroyed (NMRemoteConnection *self)
-{
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
-
- if (priv->proxy_is_destroyed) {
- g_assert (!priv->calls);
- return;
- }
-
- priv->proxy_is_destroyed = TRUE;
-
- priv->calls = g_slist_reverse (priv->calls);
- while (priv->calls)
- remote_call_dbus_cb (NULL, NULL, priv->calls->data);
-}
-
-static void
-proxy_destroy_cb (DBusGProxy* proxy, gpointer user_data) {
- proxy_set_destroyed (user_data);
-}
-
-/*****************************************************************************/
-
-static void
-result_cb (RemoteCall *call, DBusGProxyCall *proxy_call, GError *error)
-{
- NMRemoteConnectionResultFunc func = (NMRemoteConnectionResultFunc)(void (*) (void)) call->callback;
- GError *local_error = NULL;
-
- if (!error) {
- dbus_g_proxy_end_call (NM_REMOTE_CONNECTION_GET_PRIVATE (call->self)->proxy,
- proxy_call, &local_error, G_TYPE_INVALID);
- error = local_error;
- }
- if (func)
- (*func) (call->self, error, call->user_data);
- g_clear_error (&local_error);
-}
-
-/**
- * nm_remote_connection_commit_changes:
- * @connection: the #NMRemoteConnection
- * @callback: (scope async) (allow-none): a function to be called when the
- * commit completes
- * @user_data: (closure): caller-specific data to be passed to @callback
- *
- * Send any local changes to the settings and properties of this connection to
- * NetworkManager, which will immediately save them to disk.
- **/
-void
-nm_remote_connection_commit_changes (NMRemoteConnection *self,
- NMRemoteConnectionResultFunc callback,
- gpointer user_data)
-{
- NMRemoteConnectionPrivate *priv;
- RemoteCall *call;
- GHashTable *settings;
-
- g_return_if_fail (NM_IS_REMOTE_CONNECTION (self));
-
- priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
-
- call = remote_call_new (self, result_cb, (GFunc)(void (*) (void)) callback, user_data);
- if (!call)
- return;
-
- settings = nm_connection_to_hash (NM_CONNECTION (self), NM_SETTING_HASH_FLAG_ALL);
- call->call = dbus_g_proxy_begin_call (priv->proxy, "Update",
- remote_call_dbus_cb, call, NULL,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, settings,
- G_TYPE_INVALID);
- g_assert (call->call);
- g_hash_table_destroy (settings);
-}
-
-/**
- * nm_remote_connection_commit_changes_unsaved:
- * @connection: the #NMRemoteConnection
- * @callback: (scope async) (allow-none): a function to be called when the
- * commit completes
- * @user_data: (closure): caller-specific data to be passed to @callback
- *
- * Send any local changes to the settings and properties of this connection to
- * NetworkManager. The changes are not saved to disk until either
- * nm_remote_connection_save() or nm_remote_connection_commit_changes() is
- * called.
- *
- * Since: 0.9.10
- **/
-void
-nm_remote_connection_commit_changes_unsaved (NMRemoteConnection *connection,
- NMRemoteConnectionResultFunc callback,
- gpointer user_data)
-{
- NMRemoteConnectionPrivate *priv;
- GHashTable *settings = NULL;
- RemoteCall *call;
-
- g_return_if_fail (NM_IS_REMOTE_CONNECTION (connection));
-
- priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
-
- call = remote_call_new (connection, result_cb, (GFunc)(void (*) (void)) callback, user_data);
- if (!call)
- return;
-
- settings = nm_connection_to_hash (NM_CONNECTION (connection), NM_SETTING_HASH_FLAG_ALL);
- call->call = dbus_g_proxy_begin_call (priv->proxy, "UpdateUnsaved",
- remote_call_dbus_cb, call, NULL,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, settings,
- G_TYPE_INVALID);
- g_assert (call->call);
- g_hash_table_destroy (settings);
-}
-
-/**
- * nm_remote_connection_save:
- * @connection: the #NMRemoteConnection
- * @callback: (scope async) (allow-none): a function to be called when the
- * save completes
- * @user_data: (closure): caller-specific data to be passed to @callback
- *
- * Saves the connection to disk if the connection has changes that have not yet
- * been written to disk, or if the connection has never been saved.
- *
- * Since: 0.9.10
- **/
-void
-nm_remote_connection_save (NMRemoteConnection *connection,
- NMRemoteConnectionResultFunc callback,
- gpointer user_data)
-{
- NMRemoteConnectionPrivate *priv;
- RemoteCall *call;
-
- g_return_if_fail (NM_IS_REMOTE_CONNECTION (connection));
-
- priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
-
- call = remote_call_new (connection, result_cb, (GFunc)(void (*) (void)) callback, user_data);
- if (!call)
- return;
-
- call->call = dbus_g_proxy_begin_call (priv->proxy, "Save", remote_call_dbus_cb, call, NULL, G_TYPE_INVALID);
- g_assert (call->call);
-}
-
-/**
- * nm_remote_connection_delete:
- * @connection: the #NMRemoteConnection
- * @callback: (scope async) (allow-none): a function to be called when the delete completes
- * @user_data: (closure): caller-specific data to be passed to @callback
- *
- * Delete the connection.
- **/
-void
-nm_remote_connection_delete (NMRemoteConnection *self,
- NMRemoteConnectionResultFunc callback,
- gpointer user_data)
-{
- NMRemoteConnectionPrivate *priv;
- RemoteCall *call;
-
- g_return_if_fail (NM_IS_REMOTE_CONNECTION (self));
-
- priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
-
- call = remote_call_new (self, result_cb, (GFunc)(void (*) (void)) callback, user_data);
- if (!call)
- return;
-
- call->call = dbus_g_proxy_begin_call (priv->proxy, "Delete",
- remote_call_dbus_cb, call, NULL,
- G_TYPE_INVALID);
- g_assert (call->call);
-}
-
-static void
-get_secrets_cb (RemoteCall *call, DBusGProxyCall *proxy_call, GError *error)
-{
- NMRemoteConnectionGetSecretsFunc func = (NMRemoteConnectionGetSecretsFunc)(void (*) (void)) call->callback;
- GHashTable *secrets = NULL;
- GError *local_error = NULL;
-
- if (!error) {
- dbus_g_proxy_end_call (NM_REMOTE_CONNECTION_GET_PRIVATE (call->self)->proxy,
- proxy_call, &local_error,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &secrets,
- G_TYPE_INVALID);
- error = local_error;
- }
- if (func)
- (*func) (call->self, error ? NULL : secrets, error, call->user_data);
- g_clear_error (&local_error);
- if (secrets)
- g_hash_table_destroy (secrets);
-}
-
-/**
- * nm_remote_connection_get_secrets:
- * @connection: the #NMRemoteConnection
- * @setting_name: the #NMSetting object name to get secrets for
- * @callback: (scope async): a function to be called when the update completes;
- * must not be %NULL
- * @user_data: (closure): caller-specific data to be passed to @callback
- *
- * Request the connection's secrets.
- **/
-void
-nm_remote_connection_get_secrets (NMRemoteConnection *self,
- const char *setting_name,
- NMRemoteConnectionGetSecretsFunc callback,
- gpointer user_data)
-{
- NMRemoteConnectionPrivate *priv;
- RemoteCall *call;
-
- g_return_if_fail (NM_IS_REMOTE_CONNECTION (self));
- g_return_if_fail (callback != NULL);
-
- priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
-
- call = remote_call_new (self, get_secrets_cb, (GFunc)(void (*) (void)) callback, user_data);
- if (!call)
- return;
-
- call->call = dbus_g_proxy_begin_call (priv->proxy, "GetSecrets",
- remote_call_dbus_cb, call, NULL,
- G_TYPE_STRING, setting_name,
- G_TYPE_INVALID);
- g_assert (call->call);
-}
-
-/**
- * nm_remote_connection_get_unsaved:
- * @connection: the #NMRemoteConnection
- *
- * Returns: %TRUE if the remote connection contains changes that have not
- * been saved to disk, %FALSE if the connection is the same as its on-disk
- * representation.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_remote_connection_get_unsaved (NMRemoteConnection *connection)
-{
- g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
-
- _nm_remote_connection_ensure_inited (connection);
- return NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->unsaved;
-}
-
-/*****************************************************************************/
-
-static void
-updated_get_settings_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- NMRemoteConnection *self = user_data;
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
- GHashTable *new_settings;
- GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &new_settings,
- G_TYPE_INVALID);
- if (error) {
- GHashTable *hash;
-
- g_error_free (error);
-
- /* Connection is no longer visible to this user. Let the settings
- * service handle this via 'visible'. The settings service will emit
- * the "removed" signal for us since it handles the lifetime of this
- * object.
- */
- hash = g_hash_table_new (g_str_hash, g_str_equal);
- _nm_connection_replace_settings (NM_CONNECTION (self), hash);
- g_hash_table_destroy (hash);
-
- priv->visible = FALSE;
- g_signal_emit (self, signals[VISIBLE], 0, FALSE);
- } else {
- gs_unref_object NMRemoteConnection *self_alive = NULL;
-
- self_alive = g_object_ref (self);
- _nm_connection_replace_settings (NM_CONNECTION (self), new_settings);
- g_signal_emit (self, signals[UPDATED], 0, new_settings);
- g_hash_table_destroy (new_settings);
-
- /* Settings service will handle announcing the connection to clients */
- if (priv->visible == FALSE) {
- priv->visible = TRUE;
- g_signal_emit (self, signals[VISIBLE], 0, TRUE);
- }
- }
-}
-
-static void
-updated_cb (DBusGProxy *proxy, gpointer user_data)
-{
- NMRemoteConnection *self = NM_REMOTE_CONNECTION (user_data);
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
-
- /* The connection got updated; request the replacement settings */
- if (!priv->proxy_is_destroyed) {
- dbus_g_proxy_begin_call (priv->proxy, "GetSettings",
- updated_get_settings_cb, self, NULL,
- G_TYPE_INVALID);
- }
-}
-
-static void
-removed_cb (DBusGProxy *proxy, gpointer user_data)
-{
- g_signal_emit (G_OBJECT (user_data), signals[REMOVED], 0);
-}
-
-static void
-properties_changed_cb (DBusGProxy *proxy,
- GHashTable *properties,
- gpointer user_data)
-{
- NMRemoteConnection *self = NM_REMOTE_CONNECTION (user_data);
- GHashTableIter iter;
- const char *key;
- GValue *value;
-
- g_hash_table_iter_init (&iter, properties);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
- if (!strcmp (key, "Unsaved")) {
- NM_REMOTE_CONNECTION_GET_PRIVATE (self)->unsaved = g_value_get_boolean (value);
- g_object_notify (G_OBJECT (self), NM_REMOTE_CONNECTION_UNSAVED);
- }
- }
-}
-
-/*****************************************************************************/
-
-/**
- * nm_remote_connection_new:
- * @bus: a valid and connected D-Bus connection
- * @path: the D-Bus path of the connection as exported by the settings service
- *
- * Creates a new object representing the remote connection.
- *
- * Returns: the new remote connection object on success, or %NULL on failure
- **/
-NMRemoteConnection *
-nm_remote_connection_new (DBusGConnection *bus,
- const char *path)
-{
- g_return_val_if_fail (bus != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- return (NMRemoteConnection *) g_object_new (NM_TYPE_REMOTE_CONNECTION,
- NM_REMOTE_CONNECTION_BUS, bus,
- NM_CONNECTION_PATH, path,
- NULL);
-}
-
-static void
-constructed (GObject *object)
-{
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_remote_connection_parent_class)->constructed (object);
-
- g_assert (priv->bus);
- g_assert (nm_connection_get_path (NM_CONNECTION (object)));
-
- priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
- nm_connection_get_path (NM_CONNECTION (object)),
- NM_DBUS_IFACE_SETTINGS_CONNECTION);
- g_assert (priv->proxy);
- dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
-
- dbus_g_proxy_add_signal (priv->proxy, "Updated", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->proxy, "Updated", G_CALLBACK (updated_cb), object, NULL);
-
- dbus_g_proxy_add_signal (priv->proxy, "Removed", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->proxy, "Removed", G_CALLBACK (removed_cb), object, NULL);
-
- g_signal_connect (priv->proxy, "destroy", G_CALLBACK (proxy_destroy_cb), object);
-
- /* Monitor properties */
- dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE,
- DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->proxy, "PropertiesChanged",
- DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged",
- G_CALLBACK (properties_changed_cb),
- object,
- NULL);
-
- priv->props_proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
- nm_connection_get_path (NM_CONNECTION (object)),
- DBUS_INTERFACE_PROPERTIES);
- g_assert (priv->props_proxy);
-}
-
-static gboolean
-init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
-{
- NMRemoteConnection *self = NM_REMOTE_CONNECTION (initable);
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
- GHashTable *hash;
- gs_unref_object NMRemoteConnection *self_alive = NULL;
-
- if (!dbus_g_proxy_call (priv->proxy, "GetSettings", error,
- G_TYPE_INVALID,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &hash,
- G_TYPE_INVALID))
- return FALSE;
- priv->visible = TRUE;
- self_alive = g_object_ref (self);
- _nm_connection_replace_settings (NM_CONNECTION (self), hash);
- g_signal_emit (self, signals[UPDATED], 0, hash);
- g_hash_table_destroy (hash);
-
- /* Get properties */
- hash = NULL;
- if (!dbus_g_proxy_call (priv->props_proxy, "GetAll", error,
- G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS_CONNECTION,
- G_TYPE_INVALID,
- DBUS_TYPE_G_MAP_OF_VARIANT, &hash,
- G_TYPE_INVALID))
- return FALSE;
- properties_changed_cb (priv->props_proxy, hash, NM_REMOTE_CONNECTION (initable));
- g_hash_table_destroy (hash);
-
- return TRUE;
-}
-
-typedef struct {
- NMRemoteConnection *connection;
- GSimpleAsyncResult *result;
-} NMRemoteConnectionInitData;
-
-static void
-init_async_complete (NMRemoteConnectionInitData *init_data, GError *error)
-{
- if (error)
- g_simple_async_result_take_error (init_data->result, error);
- else {
- g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
- NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->connection)->inited = TRUE;
- }
-
- g_simple_async_result_complete (init_data->result);
- g_object_unref (init_data->result);
- g_slice_free (NMRemoteConnectionInitData, init_data);
-}
-
-static void
-init_async_got_properties (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- NMRemoteConnectionInitData *init_data = user_data;
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->connection);
- GHashTable *props;
- GError *error = NULL;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_VARIANT, &props,
- G_TYPE_INVALID)) {
- properties_changed_cb (priv->props_proxy, props, init_data->connection);
- g_hash_table_destroy (props);
- }
- init_async_complete (init_data, error);
-}
-
-static void
-init_get_settings_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- NMRemoteConnectionInitData *init_data = user_data;
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->connection);
- GHashTable *settings;
- GError *error = NULL;
- gs_unref_object NMRemoteConnection *self_alive = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
- G_TYPE_INVALID);
- if (error) {
- init_async_complete (init_data, error);
- return;
- }
-
- priv->visible = TRUE;
- self_alive = g_object_ref (init_data->connection);
- _nm_connection_replace_settings (NM_CONNECTION (init_data->connection), settings);
- g_signal_emit (init_data->connection, signals[UPDATED], 0, settings);
- g_hash_table_destroy (settings);
-
- /* Grab properties */
- dbus_g_proxy_begin_call (priv->props_proxy, "GetAll",
- init_async_got_properties, init_data, NULL,
- G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS_CONNECTION,
- G_TYPE_INVALID);
-}
-
-static void
-init_async (GAsyncInitable *initable, int io_priority,
- GCancellable *cancellable, GAsyncReadyCallback callback,
- gpointer user_data)
-{
- NMRemoteConnectionInitData *init_data;
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
-
- init_data = g_slice_new0 (NMRemoteConnectionInitData);
- init_data->connection = NM_REMOTE_CONNECTION (initable);
- init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
- user_data, init_async);
- if (cancellable)
- g_simple_async_result_set_check_cancellable (init_data->result, cancellable);
-
- dbus_g_proxy_begin_call (priv->proxy, "GetSettings",
- init_get_settings_cb, init_data, NULL,
- G_TYPE_INVALID);
-}
-
-static gboolean
-init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- else
- return TRUE;
-}
-
-static void
-nm_remote_connection_init (NMRemoteConnection *self)
-{
-}
-
-static GObject *
-constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- static GParamSpec *nm_connection_path = NULL;
- static GParamSpec *nm_remote_connection_dbus_path = NULL;
- int i, path_index = -1, dbus_path_index = -1;
-
- if (!nm_connection_path) {
- nm_connection_path =
- g_object_class_find_property (g_type_class_peek (NM_TYPE_CONNECTION),
- NM_CONNECTION_PATH);
- nm_remote_connection_dbus_path =
- g_object_class_find_property (g_type_class_peek (NM_TYPE_REMOTE_CONNECTION),
- NM_REMOTE_CONNECTION_DBUS_PATH);
- }
-
- /* Find the two properties */
- for (i = 0; i < n_construct_properties; i++) {
- if (construct_properties[i].pspec == nm_connection_path)
- path_index = i;
- else if (construct_properties[i].pspec == nm_remote_connection_dbus_path)
- dbus_path_index = i;
- }
- g_assert (path_index != -1 && dbus_path_index != -1);
-
- /* If NMRemoteConnection:dbus-path is set, and NMConnection:path
- * is not, then copy the value of the former to the latter.
- */
- if (g_value_get_string (construct_properties[dbus_path_index].value) &&
- !g_value_get_string (construct_properties[path_index].value))
- construct_properties[path_index].value = construct_properties[dbus_path_index].value;
-
- return G_OBJECT_CLASS (nm_remote_connection_parent_class)->
- constructor (type, n_construct_properties, construct_properties);
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- _nm_remote_connection_ensure_inited (NM_REMOTE_CONNECTION (object));
-
- switch (prop_id) {
- case PROP_UNSAVED:
- g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->unsaved);
- 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)
-{
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_BUS:
- case PROP_DBUS_CONNECTION:
- /* construct-only */
- /* priv->bus is set from either of two properties so that it (a) remains
- * backwards compatible with the previous "bus" property, and that (b)
- * it can be created just like an NMObject using the "dbus-connection",
- * even though it's not a subclass of NMObject. So don't overwrite the
- * a valid value that the other property set with NULL, if one of the
- * properties isn't specified at construction time.
- */
- if (!priv->bus)
- priv->bus = g_value_dup_boxed (value);
- break;
- case PROP_DBUS_PATH:
- /* Don't need to do anything; see constructor(). */
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-dispose (GObject *object)
-{
- NMRemoteConnection *self = NM_REMOTE_CONNECTION (object);
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
-
- proxy_set_destroyed (self);
-
- if (priv->proxy) {
- g_signal_handlers_disconnect_by_func (priv->proxy, proxy_destroy_cb, object);
- g_clear_object (&priv->proxy);
- }
- g_clear_object (&priv->props_proxy);
-
- if (priv->bus) {
- dbus_g_connection_unref (priv->bus);
- priv->bus = NULL;
- }
-
- G_OBJECT_CLASS (nm_remote_connection_parent_class)->dispose (object);
-}
-
-static void
-nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (remote_class);
-
- g_type_class_add_private (object_class, sizeof (NMRemoteConnectionPrivate));
-
- /* virtual methods */
- object_class->constructor = constructor;
- object_class->get_property = get_property;
- object_class->set_property = set_property;
- object_class->dispose = dispose;
- object_class->constructed = constructed;
-
- /* Properties */
- /**
- * NMRemoteConnection:bus:
- *
- * The #DBusGConnection that the #NMRemoteConnection is connected to.
- */
- g_object_class_install_property
- (object_class, PROP_BUS,
- g_param_spec_boxed (NM_REMOTE_CONNECTION_BUS, "", "",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /* These are needed so _nm_object_create() can create NMRemoteConnections */
- g_object_class_install_property
- (object_class, PROP_DBUS_CONNECTION,
- g_param_spec_boxed (NM_REMOTE_CONNECTION_DBUS_CONNECTION, "", "",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property
- (object_class, PROP_DBUS_PATH,
- g_param_spec_string (NM_REMOTE_CONNECTION_DBUS_PATH, "", "",
- NULL,
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMRemoteConnection:unsaved:
- *
- * %TRUE if the remote connection contains changes that have not been saved
- * to disk, %FALSE if the connection is the same as its on-disk representation.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_UNSAVED,
- g_param_spec_boolean (NM_REMOTE_CONNECTION_UNSAVED, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /* Signals */
- /**
- * NMRemoteConnection::updated:
- * @connection: a #NMConnection
- *
- * This signal is emitted when a connection changes, and it is
- * still visible to the user.
- */
- signals[UPDATED] =
- g_signal_new (NM_REMOTE_CONNECTION_UPDATED,
- G_TYPE_FROM_CLASS (remote_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMRemoteConnectionClass, updated),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
- * NMRemoteConnection::removed:
- * @connection: a #NMConnection
- *
- * This signal is emitted when a connection is either deleted or becomes
- * invisible to the current user.
- */
- signals[REMOVED] =
- g_signal_new (NM_REMOTE_CONNECTION_REMOVED,
- G_TYPE_FROM_CLASS (remote_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMRemoteConnectionClass, removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /* Private signal */
- signals[VISIBLE] =
- g_signal_new ("visible",
- G_TYPE_FROM_CLASS (remote_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-}
-
-static void
-nm_remote_connection_initable_iface_init (GInitableIface *iface)
-{
- iface->init = init_sync;
-}
-
-static void
-nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface)
-{
- iface->init_async = init_async;
- iface->init_finish = init_finish;
-}
diff --git a/libnm-glib/nm-remote-connection.h b/libnm-glib/nm-remote-connection.h
deleted file mode 100644
index 1f951cfa2e..0000000000
--- a/libnm-glib/nm-remote-connection.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2011 Red Hat, Inc.
- */
-
-#ifndef __NM_REMOTE_CONNECTION_H__
-#define __NM_REMOTE_CONNECTION_H__
-
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-connection.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_REMOTE_CONNECTION (nm_remote_connection_get_type ())
-#define NM_REMOTE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnection))
-#define NM_REMOTE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass))
-#define NM_IS_REMOTE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_REMOTE_CONNECTION))
-#define NM_IS_REMOTE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_REMOTE_CONNECTION))
-#define NM_REMOTE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass))
-
-/**
- * NMRemoteConnectionError:
- * @NM_REMOTE_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_REMOTE_CONNECTION_ERROR_DISCONNECTED: dbus disconnected
- */
-typedef enum {
- NM_REMOTE_CONNECTION_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_REMOTE_CONNECTION_ERROR_DISCONNECTED, /*< nick=Disconnected >*/
-} NMRemoteConnectionError;
-
-#define NM_REMOTE_CONNECTION_ERROR (nm_remote_connection_error_quark ())
-GQuark nm_remote_connection_error_quark (void);
-
-/* Properties */
-#define NM_REMOTE_CONNECTION_UNSAVED "unsaved"
-
-/* Signals */
-#define NM_REMOTE_CONNECTION_UPDATED "updated"
-#define NM_REMOTE_CONNECTION_REMOVED "removed"
-
-typedef struct {
- NMConnection parent;
-} NMRemoteConnection;
-
-typedef struct {
- NMConnectionClass parent_class;
-
- /* Signals */
- void (*updated) (NMRemoteConnection *connection,
- GHashTable *new_settings);
-
- void (*removed) (NMRemoteConnection *connection);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMRemoteConnectionClass;
-
-/**
- * NMRemoteConnectionResultFunc:
- * @connection: the connection for which an operation was performed
- * @error: on failure, a descriptive error
- * @user_data: user data passed to function which began the operation
- *
- * Called when NetworkManager has finished an asynchronous operation on a
- * connection, like commit changes, deleting, saving, etc.
- */
-typedef void (*NMRemoteConnectionResultFunc) (NMRemoteConnection *connection,
- GError *error,
- gpointer user_data);
-
-/* Backwards compatibility */
-typedef NMRemoteConnectionResultFunc NMRemoteConnectionCommitFunc;
-typedef NMRemoteConnectionResultFunc NMRemoteConnectionDeleteFunc;
-
-/**
- * NMRemoteConnectionGetSecretsFunc:
- * @connection: the connection for which secrets were requested
- * @secrets: (element-type utf8 GLib.HashTable): on success, a hash table of
- * hash tables, with each inner hash mapping a setting property to a #GValue
- * containing that property's value
- * @error: on failure, a descriptive error
- * @user_data: user data passed to nm_remote_connection_get_secrets()
- *
- * Called when NetworkManager returns secrets in response to a request for
- * secrets via nm_remote_connection_get_secrets().
- */
-typedef void (*NMRemoteConnectionGetSecretsFunc) (NMRemoteConnection *connection,
- GHashTable *secrets,
- GError *error,
- gpointer user_data);
-
-GType nm_remote_connection_get_type (void);
-
-NMRemoteConnection *nm_remote_connection_new (DBusGConnection *bus,
- const char *path);
-
-void nm_remote_connection_commit_changes (NMRemoteConnection *connection,
- NMRemoteConnectionResultFunc callback,
- gpointer user_data);
-
-NM_AVAILABLE_IN_0_9_10
-void nm_remote_connection_commit_changes_unsaved (NMRemoteConnection *connection,
- NMRemoteConnectionResultFunc callback,
- gpointer user_data);
-
-NM_AVAILABLE_IN_0_9_10
-void nm_remote_connection_save (NMRemoteConnection *connection,
- NMRemoteConnectionResultFunc callback,
- gpointer user_data);
-
-void nm_remote_connection_delete (NMRemoteConnection *connection,
- NMRemoteConnectionResultFunc callback,
- gpointer user_data);
-
-void nm_remote_connection_get_secrets (NMRemoteConnection *connection,
- const char *setting_name,
- NMRemoteConnectionGetSecretsFunc callback,
- gpointer user_data);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_remote_connection_get_unsaved (NMRemoteConnection *connection);
-
-G_END_DECLS
-
-#endif /* __NM_REMOTE_CONNECTION__ */
diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c
deleted file mode 100644
index e8a80f6fda..0000000000
--- a/libnm-glib/nm-remote-settings.c
+++ /dev/null
@@ -1,1569 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 Novell, Inc.
- * Copyright 2009 - 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "NetworkManager.h"
-#include "nm-connection.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-remote-settings.h"
-#include "nm-remote-connection-private.h"
-#include "nm-object-private.h"
-#include "nm-dbus-helpers-private.h"
-#include "nm-object-private.h"
-
-/**
- * SECTION:nm-remote-settings
- * @Short_description: A helper for NetworkManager's settings API
- * @Title: NMRemoteSettings
- * @See_also:#NMRemoteConnection, #NMClient
- *
- * The #NMRemoteSettings object represents NetworkManager's "settings" service,
- * which stores network configuration and allows authenticated clients to
- * add, delete, and modify that configuration. The data required to connect
- * to a specific network is called a "connection" and encapsulated by the
- * #NMConnection object. Once a connection is known to NetworkManager, having
- * either been added by a user or read from on-disk storage, the
- * #NMRemoteSettings object creates a #NMRemoteConnection object which
- * represents this stored connection. Use the #NMRemoteConnection object to
- * perform any operations like modification or deletion.
- *
- * To add a new network connection to the NetworkManager settings service, first
- * build up a template #NMConnection object. Since this connection is not yet
- * added to NetworkManager, it is known only to your program and is not yet
- * an #NMRemoteConnection. Then ask #NMRemoteSettings to add your connection.
- * When the connection is added successfully, the supplied callback is called
- * and returns to your program the new #NMRemoteConnection which represents
- * the stored object known to NetworkManager.
- *
- * |[<!-- language="C" -->
- * static void
- * added_cb (NMRemoteSettings *settings,
- * NMRemoteConnection *remote,
- * GError *error,
- * gpointer user_data)
- * {
- * if (error)
- * g_print ("Error adding connection: %s", error->message);
- * else {
- * g_print ("Added: %s\n", nm_connection_get_path (NM_CONNECTION (remote)));
- * /&ast; Use 'remote' with nm_remote_connection_commit_changes() to save
- * * changes and nm_remote_connection_delete() to delete the connection &ast;/
- * }
- * }
- *
- * static gboolean
- * add_wired_connection (const char *human_name)
- * {
- * NMConnection *connection;
- * NMSettingConnection *s_con;
- * NMSettingWired *s_wired;
- * char *uuid;
- * gboolean success;
- *
- * connection = nm_connection_new ();
- *
- * /&ast; Build up the 'connection' setting &ast;/
- * s_con = (NMSettingConnection *) nm_setting_connection_new ();
- * uuid = nm_utils_uuid_generate ();
- * g_object_set (G_OBJECT (s_con),
- * NM_SETTING_CONNECTION_UUID, uuid,
- * NM_SETTING_CONNECTION_ID, human_name,
- * NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
- * NULL);
- * g_free (uuid);
- * nm_connection_add_setting (connection, NM_SETTING (s_con));
- *
- * /&ast; Add the required 'wired' setting as this is a wired connection &ast;/
- * nm_connection_add_setting (connection, nm_setting_wired_new ());
- *
- * /&ast; Add an 'ipv4' setting using AUTO configuration (eg DHCP) &ast;/
- * s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
- * g_object_set (G_OBJECT (s_ip4),
- * NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
- * NULL);
- * nm_connection_add_setting (connection, NM_SETTING (s_ip4));
- *
- * /&ast; Ask NetworkManager to store the connection &ast;/
- * success = nm_remote_settings_add_connection (settings, connection, added_cb, loop);
- *
- * /&ast; Release the template connection; the actual stored connection will
- * * be returned in added_cb() &ast;/
- * g_object_unref (connection);
- *
- * /&ast; Let glib event loop run and added_cb() will be called when NetworkManager
- * * is done adding the new connection. &ast;/
- *
- * return success;
- * }
- * ]|
- */
-
-static void nm_remote_settings_initable_iface_init (GInitableIface *iface);
-static void nm_remote_settings_async_initable_iface_init (GAsyncInitableIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_remote_settings_initable_iface_init);
- G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_remote_settings_async_initable_iface_init);
- )
-
-#define NM_REMOTE_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsPrivate))
-
-typedef struct {
- DBusGConnection *bus;
- gboolean inited;
-
- DBusGProxy *proxy;
- GHashTable *connections;
- GHashTable *pending; /* Connections we don't have settings for yet */
- gboolean service_running;
- guint32 init_left;
-
- /* AddConnectionInfo objects that are waiting for the connection to become initialized */
- GSList *add_list;
-
- DBusGProxy *props_proxy;
- char *hostname;
- gboolean can_modify;
-
- DBusGProxy *dbus_proxy;
-
- DBusGProxyCall *listcon_call;
-} NMRemoteSettingsPrivate;
-
-enum {
- PROP_0,
- PROP_BUS,
- PROP_SERVICE_RUNNING,
- PROP_HOSTNAME,
- PROP_CAN_MODIFY,
-
- LAST_PROP
-};
-
-/* Signals */
-enum {
- NEW_CONNECTION,
- CONNECTIONS_READ,
-
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/*****************************************************************************/
-
-/**
- * nm_remote_settings_error_quark:
- *
- * Registers an error quark for #NMRemoteSettings if necessary.
- *
- * Returns: the error quark used for #NMRemoteSettings errors.
- **/
-GQuark
-nm_remote_settings_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-remote-settings-error-quark");
- return quark;
-}
-
-/*****************************************************************************/
-
-static void
-_nm_remote_settings_ensure_inited (NMRemoteSettings *self)
-{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- GError *error = NULL;
-
- if (!priv->inited) {
- if (!g_initable_init (G_INITABLE (self), NULL, &error)) {
- /* Don't warn when the call times out because the settings service can't
- * be activated or whatever.
- */
- if (!g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) {
- g_warning ("%s: (NMRemoteSettings) error initializing: %s\n",
- __func__, error->message);
- }
- g_error_free (error);
- }
- priv->inited = TRUE;
- }
-}
-
-/*****************************************************************************/
-
-typedef struct {
- NMRemoteSettings *self;
- NMRemoteSettingsAddConnectionFunc callback;
- gpointer callback_data;
- NMRemoteConnection *connection;
-} AddConnectionInfo;
-
-static AddConnectionInfo *
-add_connection_info_find (NMRemoteSettings *self, NMRemoteConnection *connection)
-{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- GSList *iter;
-
- for (iter = priv->add_list; iter; iter = g_slist_next (iter)) {
- AddConnectionInfo *info = iter->data;
-
- if (info->connection == connection)
- return info;
- }
-
- return NULL;
-}
-
-static void
-add_connection_info_dispose (NMRemoteSettings *self, AddConnectionInfo *info)
-{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
-
- priv->add_list = g_slist_remove (priv->add_list, info);
-
- g_free (info);
-}
-
-static void
-add_connection_info_complete (NMRemoteSettings *self,
- AddConnectionInfo *info,
- GError *error)
-{
- g_return_if_fail (info != NULL);
-
- info->callback (info->self, error ? NULL : info->connection, error, info->callback_data);
- add_connection_info_dispose (self, info);
-}
-
-/**
- * nm_remote_settings_get_connection_by_id:
- * @settings: the %NMRemoteSettings
- * @id: the id of the remote connection
- *
- * Returns the first matching %NMRemoteConnection matching a given @id.
- *
- * Returns: (transfer none): the remote connection object on success, or %NULL if no
- * matching object was found.
- *
- * Since: 0.9.10
- **/
-NMRemoteConnection *
-nm_remote_settings_get_connection_by_id (NMRemoteSettings *settings, const char *id)
-{
- NMRemoteSettingsPrivate *priv;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
- g_return_val_if_fail (id != NULL, NULL);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- if (priv->service_running) {
- GHashTableIter iter;
- NMConnection *candidate;
-
- g_hash_table_iter_init (&iter, priv->connections);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &candidate)) {
-
- if (!strcmp (id, nm_connection_get_id (candidate)))
- return NM_REMOTE_CONNECTION (candidate);
- }
- }
-
- return NULL;
-}
-
-/**
- * nm_remote_settings_get_connection_by_path:
- * @settings: the %NMRemoteSettings
- * @path: the D-Bus object path of the remote connection
- *
- * Returns the %NMRemoteConnection representing the connection at @path.
- *
- * Returns: (transfer none): the remote connection object on success, or %NULL if the object was
- * not known
- **/
-NMRemoteConnection *
-nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, const char *path)
-{
- NMRemoteSettingsPrivate *priv;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- return priv->service_running ? g_hash_table_lookup (priv->connections, path) : NULL;
-}
-
-/**
- * nm_remote_settings_get_connection_by_uuid:
- * @settings: the %NMRemoteSettings
- * @uuid: the UUID of the remote connection
- *
- * Returns the %NMRemoteConnection identified by @uuid.
- *
- * Returns: (transfer none): the remote connection object on success, or %NULL if the object was
- * not known
- **/
-NMRemoteConnection *
-nm_remote_settings_get_connection_by_uuid (NMRemoteSettings *settings, const char *uuid)
-{
- NMRemoteSettingsPrivate *priv;
- GHashTableIter iter;
- NMRemoteConnection *candidate;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
- g_return_val_if_fail (uuid != NULL, NULL);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- if (priv->service_running) {
- g_hash_table_iter_init (&iter, priv->connections);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) {
- if (g_strcmp0 (uuid, nm_connection_get_uuid (NM_CONNECTION (candidate))) == 0)
- return candidate;
- }
- }
-
- return NULL;
-}
-
-static void
-connection_removed_cb (NMRemoteConnection *remote, gpointer user_data)
-{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- AddConnectionInfo *addinfo;
- GError *add_error;
- const char *path;
-
- /* Might have been removed while it was waiting to be initialized */
- addinfo = add_connection_info_find (self, remote);
- if (addinfo) {
- add_error = g_error_new_literal (NM_REMOTE_SETTINGS_ERROR,
- NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED,
- "Connection removed before it was initialized");
- add_connection_info_complete (self, addinfo, add_error);
- g_error_free (add_error);
- }
-
- path = nm_connection_get_path (NM_CONNECTION (remote));
- g_hash_table_remove (priv->connections, path);
- g_hash_table_remove (priv->pending, path);
-}
-
-static void connection_visible_cb (NMRemoteConnection *remote,
- gboolean visible,
- gpointer user_data);
-
-/* Takes a reference to the connection when adding to 'to' */
-static void
-move_connection (NMRemoteSettings *self,
- NMRemoteConnection *remote,
- GHashTable *from,
- GHashTable *to)
-{
- const char *path = nm_connection_get_path (NM_CONNECTION (remote));
-
- g_hash_table_insert (to, g_strdup (path), g_object_ref (remote));
- if (from)
- g_hash_table_remove (from, path);
-
- /* Setup connection signals since removing from 'from' clears them, but
- * also the first time the connection is added to a hash if 'from' is NULL.
- */
- if (!g_signal_handler_find (remote, G_SIGNAL_MATCH_FUNC,
- 0, 0, NULL, connection_removed_cb, NULL)) {
- g_signal_connect (remote,
- NM_REMOTE_CONNECTION_REMOVED,
- G_CALLBACK (connection_removed_cb),
- self);
- }
-
- if (!g_signal_handler_find (remote, G_SIGNAL_MATCH_FUNC,
- 0, 0, NULL, connection_visible_cb, NULL)) {
- g_signal_connect (remote,
- "visible",
- G_CALLBACK (connection_visible_cb),
- self);
- }
-}
-
-static void
-connection_visible_cb (NMRemoteConnection *remote,
- gboolean visible,
- gpointer user_data)
-{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- const char *path;
-
- path = nm_connection_get_path (NM_CONNECTION (remote));
- g_assert (path);
-
- /* When a connection becomes invisible, we put it back in the pending
- * hash until it becomes visible again. When it does, we move it back to
- * the normal connections hash.
- */
- if (visible) {
- /* Connection visible to this user again */
- if (g_hash_table_lookup (priv->pending, path)) {
- /* Move connection from pending to visible hash; emit for clients */
- move_connection (self, remote, priv->pending, priv->connections);
- g_signal_emit (self, signals[NEW_CONNECTION], 0, remote);
- }
- } else {
- /* Connection now invisible to this user */
- if (g_hash_table_lookup (priv->connections, path)) {
- /* Move connection to pending hash and wait for it to become visible again */
- move_connection (self, remote, priv->connections, priv->pending);
-
- /* Signal to clients that the connection is gone; but we have to
- * block our connection removed handler so we don't destroy
- * the connection when the signal is emitted.
- */
- g_signal_handlers_block_by_func (remote, connection_removed_cb, self);
- g_signal_emit_by_name (remote, NM_REMOTE_CONNECTION_REMOVED);
- g_signal_handlers_unblock_by_func (remote, connection_removed_cb, self);
- }
- }
-}
-
-static void
-connection_inited (GObject *source, GAsyncResult *result, gpointer user_data)
-{
- NMRemoteConnection *remote = NM_REMOTE_CONNECTION (source);
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- AddConnectionInfo *addinfo;
- const char *path;
- GError *error = NULL, *local;
- static gboolean print_once = TRUE;
-
- path = nm_connection_get_path (NM_CONNECTION (remote));
- addinfo = add_connection_info_find (self, remote);
-
- if (g_async_initable_init_finish (G_ASYNC_INITABLE (remote), result, &error)) {
- /* Connection is initialized and visible; expose it to clients */
- move_connection (self, remote, priv->pending, priv->connections);
-
- /* If there's a pending AddConnection request, complete that here before
- * signaling new-connection.
- */
- if (addinfo)
- add_connection_info_complete (self, addinfo, NULL);
-
- /* Finally, let users know of the new connection now that it has all
- * its settings and is valid.
- */
- g_signal_emit (self, signals[NEW_CONNECTION], 0, remote);
- } else {
- if (addinfo) {
- local = g_error_new (NM_REMOTE_SETTINGS_ERROR,
- NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE,
- "Connection not visible or not available: %s",
- error->message);
- add_connection_info_complete (self, addinfo, local);
- g_error_free (local);
- }
-
- /* PermissionDenied means the connection isn't visible to this user, so
- * keep it in priv->pending to be notified later of visibility changes.
- * Otherwise forget it.
- */
- if (!dbus_g_error_has_name (error, "org.freedesktop.NetworkManager.Settings.PermissionDenied"))
- g_hash_table_remove (priv->pending, path);
-
- if (print_once && g_error_matches (error, DBUS_GERROR, DBUS_GERROR_LIMITS_EXCEEDED)) {
- g_printerr ("Warning: libnm-glib:%s(): a D-Bus limit exceeded: %s. The application might not work properly.\n"
- "Consider increasing max_replies_per_connection limit in /etc/dbus-1/system.d/org.freedesktop.NetworkManager.conf "
- "like <limit name=\"max_replies_per_connection\">2048</limit>",
- __func__, error->message);
- print_once = FALSE;
- }
-
- g_error_free (error);
- }
-
- /* Let listeners know that all connections have been found */
- priv->init_left--;
- if (priv->init_left == 0)
- g_signal_emit (self, signals[CONNECTIONS_READ], 0);
-
- g_object_unref (self);
-}
-
-static NMRemoteConnection *
-new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data)
-{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- NMRemoteConnection *connection = NULL;
-
- /* Make double-sure we don't already have it */
- connection = g_hash_table_lookup (priv->pending, path);
- if (connection)
- return connection;
- connection = g_hash_table_lookup (priv->connections, path);
- if (connection)
- return connection;
-
- /* Create a new connection object for it */
- connection = nm_remote_connection_new (priv->bus, path);
- if (connection) {
- g_async_initable_init_async (G_ASYNC_INITABLE (connection),
- G_PRIORITY_DEFAULT, NULL,
- connection_inited, g_object_ref (self));
-
- /* Add the connection to the pending table to wait for it to retrieve
- * it's settings asynchronously over D-Bus. The connection isn't
- * really valid until it has all its settings, so hide it until it does.
- */
- move_connection (self, connection, NULL, priv->pending);
- g_object_unref (connection); /* move_connection() takes a ref */
- }
- return connection;
-}
-
-static void
-fetch_connections_done (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- GPtrArray *connections;
- GError *error = NULL;
- int i;
-
- g_warn_if_fail (priv->listcon_call == call);
- priv->listcon_call = NULL;
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &connections,
- G_TYPE_INVALID)) {
- if ( !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN)
- && !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER)
- && priv->service_running) {
- g_warning ("%s: error fetching connections: %s.",
- __func__,
- error->message ?: "(unknown)");
- }
- g_clear_error (&error);
-
- /* We tried to read connections and failed */
- g_signal_emit (self, signals[CONNECTIONS_READ], 0);
- return;
- }
-
- /* Let listeners know we are done getting connections */
- if (connections->len == 0)
- g_signal_emit (self, signals[CONNECTIONS_READ], 0);
- else {
- priv->init_left = connections->len;
- for (i = 0; i < connections->len; i++) {
- char *path = g_ptr_array_index (connections, i);
-
- new_connection_cb (proxy, path, user_data);
- g_free (path);
- }
- }
-
- g_ptr_array_free (connections, TRUE);
-}
-
-/**
- * nm_remote_settings_list_connections:
- * @settings: the %NMRemoteSettings
- *
- * Returns: (transfer container) (element-type NMRemoteConnection): a
- * list containing all connections provided by the remote settings service.
- * Each element of the returned list is a %NMRemoteConnection instance, which is
- * owned by the %NMRemoteSettings object and should not be freed by the caller.
- * The returned list is, however, owned by the caller and should be freed
- * using g_slist_free() when no longer required.
- **/
-GSList *
-nm_remote_settings_list_connections (NMRemoteSettings *settings)
-{
- NMRemoteSettingsPrivate *priv;
- GSList *list = NULL;
- GHashTableIter iter;
- gpointer value;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- if (priv->service_running) {
- g_hash_table_iter_init (&iter, priv->connections);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value));
- }
-
- return list;
-}
-
-static void
-add_connection_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- AddConnectionInfo *info = user_data;
- GError *error = NULL;
- char *path = NULL;
-
- if (dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID)) {
- info->connection = new_connection_cb (proxy, path, info->self);
- g_assert (info->connection);
- /* Wait until this connection is fully initialized before calling the callback */
- g_free (path);
- } else
- add_connection_info_complete (info->self, info, error);
-
- g_clear_error (&error);
-}
-
-/**
- * nm_remote_settings_add_connection:
- * @settings: the %NMRemoteSettings
- * @connection: the connection to add. Note that this object's settings will be
- * added, not the object itself
- * @callback: (scope async): callback to be called when the add operation completes
- * @user_data: (closure): caller-specific data passed to @callback
- *
- * Requests that the remote settings service add the given settings to a new
- * connection. The connection is immediately written to disk. @connection is
- * untouched by this function and only serves as a template of the settings to
- * add. The #NMRemoteConnection object that represents what NetworkManager
- * actually added is returned to @callback when the addition operation is complete.
- *
- * Note that the #NMRemoteConnection returned in @callback may not contain
- * identical settings to @connection as NetworkManager may perform automatic
- * completion and/or normalization of connection properties.
- *
- * Returns: %TRUE if the request was successful, %FALSE if it failed
- **/
-gboolean
-nm_remote_settings_add_connection (NMRemoteSettings *settings,
- NMConnection *connection,
- NMRemoteSettingsAddConnectionFunc callback,
- gpointer user_data)
-{
- NMRemoteSettingsPrivate *priv;
- AddConnectionInfo *info;
- GHashTable *new_settings;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- if (!priv->service_running)
- return FALSE;
-
- info = g_malloc0 (sizeof (AddConnectionInfo));
- info->self = settings;
- info->callback = callback;
- info->callback_data = user_data;
-
- new_settings = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
- dbus_g_proxy_begin_call (priv->proxy, "AddConnection",
- add_connection_done,
- info,
- NULL,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, new_settings,
- G_TYPE_INVALID);
- g_hash_table_destroy (new_settings);
-
- priv->add_list = g_slist_append (priv->add_list, info);
-
- return TRUE;
-}
-
-/**
- * nm_remote_settings_add_connection_unsaved:
- * @settings: the %NMRemoteSettings
- * @connection: the connection to add. Note that this object's settings will be
- * added, not the object itself
- * @callback: (scope async): callback to be called when the add operation completes
- * @user_data: (closure): caller-specific data passed to @callback
- *
- * Requests that the remote settings service add the given settings to a new
- * connection. The connection is not written to disk, which may be done at
- * a later time by calling the connection's nm_remote_connection_commit_changes()
- * method.
- *
- * Returns: %TRUE if the request was successful, %FALSE if it failed
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_remote_settings_add_connection_unsaved (NMRemoteSettings *settings,
- NMConnection *connection,
- NMRemoteSettingsAddConnectionFunc callback,
- gpointer user_data)
-{
- NMRemoteSettingsPrivate *priv;
- AddConnectionInfo *info;
- GHashTable *new_settings;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- if (!priv->service_running)
- return FALSE;
-
- info = g_malloc0 (sizeof (AddConnectionInfo));
- info->self = settings;
- info->callback = callback;
- info->callback_data = user_data;
-
- new_settings = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
- dbus_g_proxy_begin_call (priv->proxy, "AddConnectionUnsaved",
- add_connection_done,
- info,
- NULL,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, new_settings,
- G_TYPE_INVALID);
- g_hash_table_destroy (new_settings);
-
- priv->add_list = g_slist_append (priv->add_list, info);
-
- return TRUE;
-}
-
-/**
- * nm_remote_settings_load_connections:
- * @settings: the %NMRemoteSettings
- * @filenames: %NULL-terminated array of filenames to load
- * @failures: (out) (transfer full): on return, a %NULL-terminated array of
- * filenames that failed to load
- * @error: return location for #GError
- *
- * Requests that the remote settings service load or reload the given files,
- * adding or updating the connections described within.
- *
- * The changes to the indicated files will not yet be reflected in
- * @settings's connections array when the function returns.
- *
- * If all of the indicated files were successfully loaded, the
- * function will return %TRUE, and @failures will be set to %NULL. If
- * NetworkManager tried to load the files, but some (or all) failed,
- * then @failures will be set to a %NULL-terminated array of the
- * filenames that failed to load.
-
- * Returns: %TRUE if NetworkManager at least tried to load @filenames,
- * %FALSE if an error occurred (eg, permission denied).
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_remote_settings_load_connections (NMRemoteSettings *settings,
- char **filenames,
- char ***failures,
- GError **error)
-{
- NMRemoteSettingsPrivate *priv;
- char **my_failures = NULL;
- gboolean ret;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
- g_return_val_if_fail (filenames != NULL, FALSE);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- if (!priv->service_running) {
- g_set_error_literal (error, NM_REMOTE_SETTINGS_ERROR,
- NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE,
- "NetworkManager is not running.");
- return FALSE;
- }
-
- if (!dbus_g_proxy_call (priv->proxy, "LoadConnections", error,
- G_TYPE_STRV, filenames,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &ret,
- G_TYPE_STRV, &my_failures,
- G_TYPE_INVALID))
- ret = FALSE;
-
- if (failures) {
- if (my_failures && !*my_failures)
- g_clear_pointer (&my_failures, g_free);
- *failures = my_failures;
- } else
- g_strfreev (my_failures);
-
- return ret;
-}
-
-/**
- * nm_remote_settings_reload_connections:
- * @settings: the #NMRemoteSettings
- * @error: return location for #GError
- *
- * Requests that the remote settings service reload all connection
- * files from disk, adding, updating, and removing connections until
- * the in-memory state matches the on-disk state.
- *
- * Return value: %TRUE on success, %FALSE on failure
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_remote_settings_reload_connections (NMRemoteSettings *settings,
- GError **error)
-{
- NMRemoteSettingsPrivate *priv;
- gboolean success;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- if (!priv->service_running) {
- g_set_error_literal (error, NM_REMOTE_SETTINGS_ERROR,
- NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE,
- "NetworkManager is not running.");
- return FALSE;
- }
-
- if (!dbus_g_proxy_call (priv->proxy, "ReloadConnections", error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &success,
- G_TYPE_INVALID))
- return FALSE;
- return success;
-}
-
-static void
-clear_one_hash (GHashTable *table)
-{
- GHashTableIter iter;
- gpointer value;
- GSList *list = NULL, *list_iter;
-
- /* Build up the list of connections; we can't emit "removed" during hash
- * table iteration because emission of the "removed" signal may trigger code
- * that explicitly removes the connection from the hash table somewhere
- * else.
- */
- g_hash_table_iter_init (&iter, table);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value));
-
- for (list_iter = list; list_iter; list_iter = g_slist_next (list_iter))
- g_signal_emit_by_name (NM_REMOTE_CONNECTION (list_iter->data), NM_REMOTE_CONNECTION_REMOVED);
- g_slist_free (list);
-
- g_hash_table_remove_all (table);
-}
-
-typedef struct {
- NMRemoteSettings *settings;
- NMRemoteSettingsSaveHostnameFunc callback;
- gpointer callback_data;
-} SaveHostnameInfo;
-
-static void
-save_hostname_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- SaveHostnameInfo *info = user_data;
- GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- if (info->callback != NULL)
- info->callback (info->settings, error, info->callback_data);
- g_clear_error (&error);
-}
-
-/**
- * nm_remote_settings_save_hostname:
- * @settings: the %NMRemoteSettings
- * @hostname: the new persistent hostname to set, or %NULL to clear any existing
- * persistent hostname
- * @callback: (scope async) (allow-none): callback to be called when the
- * hostname operation completes
- * @user_data: (closure): caller-specific data passed to @callback
- *
- * Requests that the machine's persistent hostname be set to the specified value
- * or cleared.
- *
- * Returns: %TRUE if the request was successful, %FALSE if it failed
- **/
-gboolean
-nm_remote_settings_save_hostname (NMRemoteSettings *settings,
- const char *hostname,
- NMRemoteSettingsSaveHostnameFunc callback,
- gpointer user_data)
-{
- NMRemoteSettingsPrivate *priv;
- SaveHostnameInfo *info;
-
- g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
- g_return_val_if_fail (hostname != NULL, FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
-
- _nm_remote_settings_ensure_inited (settings);
-
- if (!priv->service_running)
- return FALSE;
-
- info = g_malloc0 (sizeof (SaveHostnameInfo));
- info->settings = settings;
- info->callback = callback;
- info->callback_data = user_data;
-
- dbus_g_proxy_begin_call (priv->proxy, "SaveHostname",
- save_hostname_cb,
- info,
- g_free,
- G_TYPE_STRING, hostname ?: "",
- G_TYPE_INVALID);
- return TRUE;
-}
-
-static void
-properties_changed_cb (DBusGProxy *proxy,
- GHashTable *properties,
- gpointer user_data)
-{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- GHashTableIter iter;
- gpointer key, tmp;
-
- g_hash_table_iter_init (&iter, properties);
- while (g_hash_table_iter_next (&iter, &key, &tmp)) {
- GValue *value = tmp;
-
- if (!strcmp ((const char *) key, "Hostname")) {
- g_free (priv->hostname);
- priv->hostname = g_value_dup_string (value);
- g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_HOSTNAME);
- }
-
- if (!strcmp ((const char *) key, "CanModify")) {
- priv->can_modify = g_value_get_boolean (value);
- g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_CAN_MODIFY);
- }
- }
-}
-
-static void
-nm_appeared_got_properties (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- GHashTable *props = NULL;
-
- if (dbus_g_proxy_end_call (proxy, call, NULL,
- DBUS_TYPE_G_MAP_OF_VARIANT, &props,
- G_TYPE_INVALID)) {
- properties_changed_cb (priv->props_proxy, props, self);
- g_hash_table_destroy (props);
- }
-}
-
-static void
-name_owner_changed (DBusGProxy *proxy,
- const char *name,
- const char *old_owner,
- const char *new_owner,
- gpointer user_data)
-{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- const char *sname = NM_DBUS_SERVICE;
-
- if (!strcmp (name, sname)) {
- if (new_owner && strlen (new_owner) > 0) {
- priv->service_running = TRUE;
-
- priv->listcon_call = dbus_g_proxy_begin_call (priv->proxy, "ListConnections",
- fetch_connections_done, self, NULL,
- G_TYPE_INVALID);
-
- dbus_g_proxy_begin_call (priv->props_proxy, "GetAll",
- nm_appeared_got_properties, self, NULL,
- G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS,
- G_TYPE_INVALID);
- } else {
- priv->service_running = FALSE;
-
- clear_one_hash (priv->pending);
- clear_one_hash (priv->connections);
-
- /* Clear properties */
- g_free (priv->hostname);
- priv->hostname = NULL;
- g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_HOSTNAME);
-
- priv->can_modify = FALSE;
- g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_CAN_MODIFY);
-
- if (priv->listcon_call) {
- dbus_g_proxy_cancel_call (priv->proxy, priv->listcon_call);
- priv->listcon_call = NULL;
- }
- }
- g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_SERVICE_RUNNING);
- }
-}
-
-/*****************************************************************************/
-
-/**
- * nm_remote_settings_new:
- * @bus: (allow-none): a valid and connected D-Bus connection
- *
- * Creates a new object representing the remote settings service.
- *
- * Note that this will do blocking D-Bus calls to initialize the
- * settings object. You can use nm_remote_settings_new_async() if you
- * want to avoid that.
- *
- * Returns: the new remote settings object on success, or %NULL on failure
- **/
-NMRemoteSettings *
-nm_remote_settings_new (DBusGConnection *bus)
-{
- NMRemoteSettings *self;
-
- self = g_object_new (NM_TYPE_REMOTE_SETTINGS, NM_REMOTE_SETTINGS_BUS, bus, NULL);
- _nm_remote_settings_ensure_inited (self);
- return self;
-}
-
-static void
-remote_settings_inited (GObject *source, GAsyncResult *result, gpointer user_data)
-{
- GSimpleAsyncResult *simple = user_data;
- GError *error = NULL;
-
- if (!g_async_initable_init_finish (G_ASYNC_INITABLE (source), result, &error))
- g_simple_async_result_take_error (simple, error);
- else
- g_simple_async_result_set_op_res_gpointer (simple, source, g_object_unref);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-}
-
-/**
- * nm_remote_settings_new_async:
- * @bus: (allow-none): a valid and connected D-Bus connection
- * @cancellable: a #GCancellable, or %NULL
- * @callback: callback to call when the settings object is created
- * @user_data: data for @callback
- *
- * Creates a new object representing the remote settings service and
- * begins asynchronously initializing it. @callback will be called
- * when it is done; use nm_remote_settings_new_finish() to get the
- * result.
- **/
-void
-nm_remote_settings_new_async (DBusGConnection *bus, GCancellable *cancellable,
- GAsyncReadyCallback callback, gpointer user_data)
-{
- NMRemoteSettings *self;
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (NULL, callback, user_data, nm_remote_settings_new_async);
- if (cancellable)
- g_simple_async_result_set_check_cancellable (simple, cancellable);
-
- self = g_object_new (NM_TYPE_REMOTE_SETTINGS,
- NM_REMOTE_SETTINGS_BUS, bus,
- NULL);
- g_async_initable_init_async (G_ASYNC_INITABLE (self), G_PRIORITY_DEFAULT,
- cancellable, remote_settings_inited, simple);
-}
-
-/**
- * nm_remote_settings_new_finish:
- * @result: a #GAsyncResult
- * @error: location for a #GError, or %NULL
- *
- * Gets the result of an nm_remote_settings_new_async() call.
- *
- * Returns: a new #NMRemoteSettings object, or %NULL on error
- **/
-NMRemoteSettings *
-nm_remote_settings_new_finish (GAsyncResult *result, GError **error)
-{
- GSimpleAsyncResult *simple;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, nm_remote_settings_new_async), NULL);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- else
- return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple));
-}
-
-static void
-forget_connection (gpointer user_data)
-{
- NMRemoteConnection *remote = NM_REMOTE_CONNECTION (user_data);
-
- g_signal_handlers_disconnect_matched (remote, G_SIGNAL_MATCH_FUNC,
- 0, 0, NULL, connection_removed_cb, NULL);
- g_signal_handlers_disconnect_matched (remote, G_SIGNAL_MATCH_FUNC,
- 0, 0, NULL, connection_visible_cb, NULL);
- g_object_unref (remote);
-}
-
-static void
-nm_remote_settings_init (NMRemoteSettings *self)
-{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
-
- priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, forget_connection);
- priv->pending = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, forget_connection);
-}
-
-static void
-constructed (GObject *object)
-{
- NMRemoteSettingsPrivate *priv;
-
- priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
-
- /* D-Bus proxy for clearing connections on NameOwnerChanged */
- priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- g_assert (priv->dbus_proxy);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
- G_TYPE_NONE,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->dbus_proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->dbus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (name_owner_changed),
- object, NULL);
-
- priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
- NM_DBUS_PATH_SETTINGS,
- NM_DBUS_IFACE_SETTINGS);
- g_assert (priv->proxy);
- dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
-
- dbus_g_proxy_add_signal (priv->proxy, "NewConnection",
- DBUS_TYPE_G_OBJECT_PATH,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->proxy, "NewConnection",
- G_CALLBACK (new_connection_cb),
- object,
- NULL);
-
- /* D-Bus properties proxy */
- priv->props_proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
- NM_DBUS_PATH_SETTINGS,
- DBUS_INTERFACE_PROPERTIES);
- g_assert (priv->props_proxy);
-
- /* Monitor properties */
- dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
- G_TYPE_NONE,
- DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->proxy, "PropertiesChanged",
- DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged",
- G_CALLBACK (properties_changed_cb),
- object,
- NULL);
-}
-
-static gboolean
-init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
-{
- NMRemoteSettings *settings = NM_REMOTE_SETTINGS (initable);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
- GHashTable *props;
-
- if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", error,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &priv->service_running,
- G_TYPE_INVALID)) {
- priv->service_running = FALSE;
- return FALSE;
- }
-
- /* If NM isn't running we'll grab properties from name_owner_changed()
- * when it starts.
- */
- if (!priv->service_running)
- return TRUE;
-
- priv->listcon_call = dbus_g_proxy_begin_call (priv->proxy, "ListConnections",
- fetch_connections_done, NM_REMOTE_SETTINGS (initable), NULL,
- G_TYPE_INVALID);
-
- /* Get properties */
- if (!dbus_g_proxy_call (priv->props_proxy, "GetAll", error,
- G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS,
- G_TYPE_INVALID,
- DBUS_TYPE_G_MAP_OF_VARIANT, &props,
- G_TYPE_INVALID))
- return FALSE;
- properties_changed_cb (priv->props_proxy, props, settings);
- g_hash_table_destroy (props);
-
- return TRUE;
-}
-
-typedef struct {
- NMRemoteSettings *settings;
- GSimpleAsyncResult *result;
-} NMRemoteSettingsInitData;
-
-static void
-init_async_complete (NMRemoteSettingsInitData *init_data)
-{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (init_data->settings);
-
- priv->inited = TRUE;
-
- g_simple_async_result_complete (init_data->result);
- g_object_unref (init_data->result);
- g_slice_free (NMRemoteSettingsInitData, init_data);
-}
-
-static void
-init_read_connections (NMRemoteSettings *settings, gpointer user_data)
-{
- NMRemoteSettingsInitData *init_data = user_data;
-
- g_signal_handlers_disconnect_by_func (settings, G_CALLBACK (init_read_connections), user_data);
-
- init_async_complete (init_data);
-}
-
-static void
-init_async_got_properties (DBusGProxy *proxy, DBusGProxyCall *call,
- gpointer user_data)
-{
- NMRemoteSettingsInitData *init_data = user_data;
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (init_data->settings);
- GHashTable *props;
- GError *error = NULL;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_VARIANT, &props,
- G_TYPE_INVALID)) {
- properties_changed_cb (priv->props_proxy, props, init_data->settings);
- g_hash_table_destroy (props);
- g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
- } else
- g_simple_async_result_take_error (init_data->result, error);
-
- /* Read connections and wait for the result */
- priv->listcon_call = dbus_g_proxy_begin_call (priv->proxy, "ListConnections",
- fetch_connections_done, init_data->settings, NULL,
- G_TYPE_INVALID);
- g_signal_connect (init_data->settings, "connections-read",
- G_CALLBACK (init_read_connections), init_data);
-}
-
-static void
-init_get_properties (NMRemoteSettingsInitData *init_data)
-{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (init_data->settings);
-
- dbus_g_proxy_begin_call (priv->props_proxy, "GetAll",
- init_async_got_properties, init_data, NULL,
- G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS,
- G_TYPE_INVALID);
-}
-
-static void
-init_async_got_manager_running (DBusGProxy *proxy, DBusGProxyCall *call,
- gpointer user_data)
-{
- NMRemoteSettingsInitData *init_data = user_data;
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (init_data->settings);
- GError *error = NULL;
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_BOOLEAN, &priv->service_running,
- G_TYPE_INVALID)) {
- g_simple_async_result_take_error (init_data->result, error);
- init_async_complete (init_data);
- return;
- }
-
- if (!priv->service_running) {
- g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
- init_async_complete (init_data);
- return;
- }
-
- init_get_properties (init_data);
-}
-
-static void
-init_async (GAsyncInitable *initable, int io_priority,
- GCancellable *cancellable, GAsyncReadyCallback callback,
- gpointer user_data)
-{
- NMRemoteSettingsInitData *init_data;
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (initable);
-
- init_data = g_slice_new0 (NMRemoteSettingsInitData);
- init_data->settings = NM_REMOTE_SETTINGS (initable);
- init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
- user_data, init_async);
- if (cancellable)
- g_simple_async_result_set_check_cancellable (init_data->result, cancellable);
-
- /* Check if NM is running */
- dbus_g_proxy_begin_call (priv->dbus_proxy, "NameHasOwner",
- init_async_got_manager_running,
- init_data, NULL,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID);
-}
-
-static gboolean
-init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- else
- return TRUE;
-}
-
-static void
-dispose (GObject *object)
-{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (object);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
-
- while (g_slist_length (priv->add_list))
- add_connection_info_dispose (self, (AddConnectionInfo *) priv->add_list->data);
-
- if (priv->connections) {
- g_hash_table_destroy (priv->connections);
- priv->connections = NULL;
- }
-
- if (priv->pending) {
- g_hash_table_destroy (priv->pending);
- priv->pending = NULL;
- }
-
- g_free (priv->hostname);
- priv->hostname = NULL;
-
- g_clear_object (&priv->dbus_proxy);
- g_clear_object (&priv->proxy);
- g_clear_object (&priv->props_proxy);
-
- if (priv->bus) {
- dbus_g_connection_unref (priv->bus);
- priv->bus = NULL;
- }
-
- G_OBJECT_CLASS (nm_remote_settings_parent_class)->dispose (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_BUS:
- /* construct-only */
- priv->bus = g_value_dup_boxed (value);
- if (!priv->bus)
- priv->bus = _nm_dbus_new_connection (NULL);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
-
- _nm_remote_settings_ensure_inited (NM_REMOTE_SETTINGS (object));
-
- switch (prop_id) {
- case PROP_BUS:
- g_value_set_boxed (value, priv->bus);
- break;
- case PROP_SERVICE_RUNNING:
- g_value_set_boolean (value, priv->service_running);
- break;
- case PROP_HOSTNAME:
- g_value_set_string (value, priv->hostname);
- break;
- case PROP_CAN_MODIFY:
- g_value_set_boolean (value, priv->can_modify);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_remote_settings_class_init (NMRemoteSettingsClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- g_type_class_add_private (class, sizeof (NMRemoteSettingsPrivate));
-
- /* Virtual methods */
- object_class->constructed = constructed;
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
-
- /* Properties */
-
- /**
- * NMRemoteSettings:bus:
- *
- * The #DBusGConnection that the #NMRemoteSettings is connected to. Defaults
- * to the system bus if not specified.
- */
- g_object_class_install_property
- (object_class, PROP_BUS,
- g_param_spec_boxed (NM_REMOTE_SETTINGS_BUS, "", "",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMRemoteSettings:service-running:
- *
- * Whether the settings service is running.
- */
- g_object_class_install_property
- (object_class, PROP_SERVICE_RUNNING,
- g_param_spec_boolean (NM_REMOTE_SETTINGS_SERVICE_RUNNING, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMRemoteSettings:hostname:
- *
- * The machine hostname stored in persistent configuration. This can be
- * modified by calling nm_remote_settings_save_hostname().
- */
- g_object_class_install_property
- (object_class, PROP_HOSTNAME,
- g_param_spec_string (NM_REMOTE_SETTINGS_HOSTNAME, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMRemoteSettings:can-modify:
- *
- * If %TRUE, adding and modifying connections is supported.
- */
- g_object_class_install_property
- (object_class, PROP_CAN_MODIFY,
- g_param_spec_boolean (NM_REMOTE_SETTINGS_CAN_MODIFY, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /* Signals */
- signals[NEW_CONNECTION] =
- g_signal_new (NM_REMOTE_SETTINGS_NEW_CONNECTION,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMRemoteSettingsClass, new_connection),
- NULL, NULL, NULL,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- signals[CONNECTIONS_READ] =
- g_signal_new (NM_REMOTE_SETTINGS_CONNECTIONS_READ,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMRemoteSettingsClass, connections_read),
- NULL, NULL, NULL,
- G_TYPE_NONE, 0);
-}
-
-static void
-nm_remote_settings_initable_iface_init (GInitableIface *iface)
-{
- iface->init = init_sync;
-}
-
-static void
-nm_remote_settings_async_initable_iface_init (GAsyncInitableIface *iface)
-{
- iface->init_async = init_async;
- iface->init_finish = init_finish;
-}
diff --git a/libnm-glib/nm-remote-settings.h b/libnm-glib/nm-remote-settings.h
deleted file mode 100644
index 2f9e00a089..0000000000
--- a/libnm-glib/nm-remote-settings.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 Novell, Inc.
- * Copyright 2009 - 2011 Red Hat, Inc.
- */
-
-#ifndef NM_REMOTE_SETTINGS_H
-#define NM_REMOTE_SETTINGS_H
-
-#include <gio/gio.h>
-#include <dbus/dbus-glib.h>
-#include "nm-connection.h"
-#include "nm-remote-connection.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_REMOTE_SETTINGS (nm_remote_settings_get_type ())
-#define NM_REMOTE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettings))
-#define NM_REMOTE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsClass))
-#define NM_IS_REMOTE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS))
-#define NM_IS_REMOTE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_REMOTE_SETTINGS))
-#define NM_REMOTE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsClass))
-
-/**
- * NMRemoteSettingsError:
- * @NM_REMOTE_SETTINGS_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED: the #NMRemoteConnection object
- * was removed before it was completely initialized
- * @NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE: the #NMRemoteConnection object
- * is not visible or otherwise unreadable
- * @NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE: NetworkManager is not running.
- * (Since 0.9.10)
- *
- * Describes errors that may result from operations involving a #NMRemoteSettings.
- *
- **/
-typedef enum {
- NM_REMOTE_SETTINGS_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED, /*< nick=ConnectionRemoved >*/
- NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE, /*< nick=ConnectionUnavailable >*/
- NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE, /*< nick=ServiceUnavailable >*/
-} NMRemoteSettingsError;
-
-#define NM_REMOTE_SETTINGS_ERROR nm_remote_settings_error_quark ()
-GQuark nm_remote_settings_error_quark (void);
-
-#define NM_REMOTE_SETTINGS_BUS "bus"
-#define NM_REMOTE_SETTINGS_SERVICE_RUNNING "service-running"
-#define NM_REMOTE_SETTINGS_HOSTNAME "hostname"
-#define NM_REMOTE_SETTINGS_CAN_MODIFY "can-modify"
-
-#define NM_REMOTE_SETTINGS_NEW_CONNECTION "new-connection"
-#define NM_REMOTE_SETTINGS_CONNECTIONS_READ "connections-read"
-
-typedef struct _NMRemoteSettings NMRemoteSettings;
-typedef struct _NMRemoteSettingsClass NMRemoteSettingsClass;
-
-typedef void (*NMRemoteSettingsAddConnectionFunc) (NMRemoteSettings *settings,
- NMRemoteConnection *connection,
- GError *error,
- gpointer user_data);
-
-typedef void (*NMRemoteSettingsLoadConnectionsFunc) (NMRemoteSettings *settings,
- char **failures,
- GError *error,
- gpointer user_data);
-
-typedef void (*NMRemoteSettingsSaveHostnameFunc) (NMRemoteSettings *settings,
- GError *error,
- gpointer user_data);
-
-struct _NMRemoteSettings {
- GObject parent;
-};
-
-struct _NMRemoteSettingsClass {
- GObjectClass parent;
-
- /* Signals */
- void (*new_connection) (NMRemoteSettings *settings,
- NMRemoteConnection *connection);
-
- void (*connections_read) (NMRemoteSettings *settings);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-};
-
-GType nm_remote_settings_get_type (void);
-
-NMRemoteSettings *nm_remote_settings_new (DBusGConnection *bus);
-
-void nm_remote_settings_new_async (DBusGConnection *bus,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-NMRemoteSettings *nm_remote_settings_new_finish (GAsyncResult *result,
- GError **error);
-
-GSList *nm_remote_settings_list_connections (NMRemoteSettings *settings);
-
-NMRemoteConnection *nm_remote_settings_get_connection_by_id (NMRemoteSettings *settings,
- const char *id);
-
-NMRemoteConnection * nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings,
- const char *path);
-
-NMRemoteConnection *nm_remote_settings_get_connection_by_uuid (NMRemoteSettings *settings,
- const char *uuid);
-
-gboolean nm_remote_settings_add_connection (NMRemoteSettings *settings,
- NMConnection *connection,
- NMRemoteSettingsAddConnectionFunc callback,
- gpointer user_data);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_remote_settings_add_connection_unsaved (NMRemoteSettings *settings,
- NMConnection *connection,
- NMRemoteSettingsAddConnectionFunc callback,
- gpointer user_data);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_remote_settings_load_connections (NMRemoteSettings *settings,
- char **filenames,
- char ***failures,
- GError **error);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_remote_settings_reload_connections (NMRemoteSettings *settings,
- GError **error);
-
-gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings,
- const char *hostname,
- NMRemoteSettingsSaveHostnameFunc callback,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* NM_REMOTE_SETTINGS_H */
diff --git a/libnm-glib/nm-secret-agent.c b/libnm-glib/nm-secret-agent.c
deleted file mode 100644
index 361af6f8d2..0000000000
--- a/libnm-glib/nm-secret-agent.c
+++ /dev/null
@@ -1,1052 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2010 - 2011 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "NetworkManager.h"
-#include "nm-secret-agent.h"
-#include "nm-glib-enum-types.h"
-#include "nm-dbus-helpers-private.h"
-#include "nm-setting-private.h"
-
-static void impl_secret_agent_get_secrets (NMSecretAgent *self,
- GHashTable *connection_hash,
- const char *connection_path,
- const char *setting_name,
- const char **hints,
- guint32 flags,
- DBusGMethodInvocation *context);
-
-static void impl_secret_agent_cancel_get_secrets (NMSecretAgent *self,
- const char *connection_path,
- const char *setting_name,
- DBusGMethodInvocation *context);
-
-static void impl_secret_agent_save_secrets (NMSecretAgent *self,
- GHashTable *connection_hash,
- const char *connection_path,
- DBusGMethodInvocation *context);
-
-static void impl_secret_agent_delete_secrets (NMSecretAgent *self,
- GHashTable *connection_hash,
- const char *connection_path,
- DBusGMethodInvocation *context);
-
-#include "nm-secret-agent-glue.h"
-
-G_DEFINE_ABSTRACT_TYPE (NMSecretAgent, nm_secret_agent, G_TYPE_OBJECT)
-
-#define NM_SECRET_AGENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SECRET_AGENT, NMSecretAgentPrivate))
-
-static gboolean auto_register_cb (gpointer user_data);
-
-typedef struct {
- gboolean registered;
- NMSecretAgentCapabilities capabilities;
-
- DBusGConnection *bus;
- DBusGProxy *dbus_proxy;
- DBusGProxy *manager_proxy;
- DBusGProxyCall *reg_call;
-
- /* GetSecretsInfo structs of in-flight GetSecrets requests */
- GSList *pending_gets;
-
- char *nm_owner;
-
- char *identifier;
- gboolean auto_register;
- gboolean suppress_auto;
- gboolean auto_register_id;
-} NMSecretAgentPrivate;
-
-enum {
- PROP_0,
- PROP_IDENTIFIER,
- PROP_AUTO_REGISTER,
- PROP_REGISTERED,
- PROP_CAPABILITIES,
-
- LAST_PROP
-};
-
-enum {
- REGISTRATION_RESULT,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/*****************************************************************************/
-
-GQuark
-nm_secret_agent_error_quark (void)
-{
- static GQuark ret = 0;
-
- if (G_UNLIKELY (ret == 0))
- ret = g_quark_from_static_string ("nm-secret-agent-error");
- return ret;
-}
-
-/*****************************************************************************/
-
-static const char *
-get_nm_owner (NMSecretAgent *self)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
- GError *error = NULL;
- char *owner;
-
- if (!priv->nm_owner) {
- if (!dbus_g_proxy_call_with_timeout (priv->dbus_proxy,
- "GetNameOwner", 2000, &error,
- G_TYPE_STRING, NM_DBUS_SERVICE,
- G_TYPE_INVALID,
- G_TYPE_STRING, &owner,
- G_TYPE_INVALID))
- return NULL;
-
- priv->nm_owner = g_strdup (owner);
- g_free (owner);
- }
-
- return priv->nm_owner;
-}
-
-static void
-_internal_unregister (NMSecretAgent *self)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
-
- if (priv->registered) {
- dbus_g_connection_unregister_g_object (priv->bus, G_OBJECT (self));
- priv->registered = FALSE;
- g_object_notify (G_OBJECT (self), NM_SECRET_AGENT_REGISTERED);
- }
-}
-
-typedef struct {
- char *path;
- char *setting_name;
- DBusGMethodInvocation *context;
-} GetSecretsInfo;
-
-static void
-get_secrets_info_finalize (NMSecretAgent *self, GetSecretsInfo *info)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
-
- g_return_if_fail (info != NULL);
-
- priv->pending_gets = g_slist_remove (priv->pending_gets, info);
-
- g_free (info->path);
- g_free (info->setting_name);
- memset (info, 0, sizeof (*info));
- g_free (info);
-}
-
-static void
-name_owner_changed (DBusGProxy *proxy,
- const char *name,
- const char *old_owner,
- const char *new_owner,
- gpointer user_data)
-{
- NMSecretAgent *self = NM_SECRET_AGENT (user_data);
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
- gboolean old_owner_good = (old_owner && strlen (old_owner));
- gboolean new_owner_good = (new_owner && strlen (new_owner));
- GSList *iter;
-
- if (strcmp (name, NM_DBUS_SERVICE) == 0) {
- g_free (priv->nm_owner);
- priv->nm_owner = g_strdup (new_owner);
-
- if (!old_owner_good && new_owner_good) {
- /* NM appeared */
- auto_register_cb (self);
- } else if (old_owner_good && !new_owner_good) {
- /* Cancel any pending secrets requests */
- for (iter = priv->pending_gets; iter; iter = g_slist_next (iter)) {
- GetSecretsInfo *info = iter->data;
-
- NM_SECRET_AGENT_GET_CLASS (self)->cancel_get_secrets (self,
- info->path,
- info->setting_name);
- }
- g_slist_free (priv->pending_gets);
- priv->pending_gets = NULL;
-
- /* NM disappeared */
- _internal_unregister (self);
- } else if (old_owner_good && new_owner_good && strcmp (old_owner, new_owner)) {
- /* Hmm, NM magically restarted */
- _internal_unregister (self);
- auto_register_cb (self);
- }
- }
-}
-
-static gboolean
-verify_sender (NMSecretAgent *self,
- DBusGMethodInvocation *context,
- GError **error)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
- DBusConnection *bus;
- char *sender;
- const char *nm_owner;
- DBusError dbus_error;
- uid_t sender_uid = G_MAXUINT;
- gboolean allowed = FALSE;
-
- g_return_val_if_fail (context != NULL, FALSE);
-
- /* Verify the sender's UID is 0, and that the sender is the same as
- * NetworkManager's bus name owner.
- */
-
- nm_owner = get_nm_owner (self);
- if (!nm_owner) {
- g_set_error_literal (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED,
- "NetworkManager bus name owner unknown.");
- return FALSE;
- }
-
- bus = dbus_g_connection_get_connection (priv->bus);
- if (!bus) {
- g_set_error_literal (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED,
- "Failed to get DBus connection.");
- return FALSE;
- }
-
- sender = dbus_g_method_get_sender (context);
- if (!sender) {
- g_set_error_literal (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED,
- "Failed to get request sender.");
- return FALSE;
- }
-
- /* Check that the sender matches the current NM bus name owner */
- if (strcmp (sender, nm_owner) != 0) {
- g_set_error_literal (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED,
- "Request sender does not match NetworkManager bus name owner.");
- goto out;
- }
-
- dbus_error_init (&dbus_error);
- sender_uid = dbus_bus_get_unix_user (bus, sender, &dbus_error);
- if (dbus_error_is_set (&dbus_error)) {
- g_set_error (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED,
- "Failed to get request unix user: (%s) %s.",
- dbus_error.name, dbus_error.message);
- dbus_error_free (&dbus_error);
- goto out;
- }
-
- /* We only accept requests from NM, which always runs as root */
- if (0 != sender_uid) {
- g_set_error_literal (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED,
- "Request sender is not root.");
- goto out;
- }
-
- allowed = TRUE;
-
-out:
- g_free (sender);
- return allowed;
-}
-
-static gboolean
-verify_request (NMSecretAgent *self,
- DBusGMethodInvocation *context,
- GHashTable *connection_hash,
- const char *connection_path,
- NMConnection **out_connection,
- GError **error)
-{
- NMConnection *connection = NULL;
-
- g_return_val_if_fail (!connection_hash || out_connection, FALSE);
-
- if (!verify_sender (self, context, error))
- return FALSE;
-
- /* No connection? If the sender verified, then we allow the request */
- if (connection_hash == NULL)
- return TRUE;
-
- /* If we have a connection hash, we require a path too */
- if (connection_path == NULL) {
- g_set_error_literal (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_INVALID_CONNECTION,
- "Invalid connection: no connection path given.");
- return FALSE;
- }
-
- /* Make sure the given connection is valid */
- connection = _nm_connection_new_from_hash (connection_hash);
- nm_connection_set_path (connection, connection_path);
- *out_connection = connection;
-
- return TRUE;
-}
-
-static void
-get_secrets_cb (NMSecretAgent *self,
- NMConnection *connection,
- GHashTable *secrets,
- GError *error,
- gpointer user_data)
-{
- GetSecretsInfo *info = user_data;
-
- if (error)
- dbus_g_method_return_error (info->context, error);
- else
- dbus_g_method_return (info->context, secrets);
-
- /* Remove the request from internal tracking */
- get_secrets_info_finalize (self, info);
-}
-
-static void
-impl_secret_agent_get_secrets (NMSecretAgent *self,
- GHashTable *connection_hash,
- const char *connection_path,
- const char *setting_name,
- const char **hints,
- guint32 flags,
- DBusGMethodInvocation *context)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
- GError *error = NULL;
- NMConnection *connection = NULL;
- GetSecretsInfo *info;
-
- /* Make sure the request comes from NetworkManager and is valid */
- if (!verify_request (self, context, connection_hash, connection_path, &connection, &error)) {
- dbus_g_method_return_error (context, error);
- g_clear_error (&error);
- return;
- }
-
- info = g_malloc0 (sizeof (GetSecretsInfo));
- info->path = g_strdup (connection_path);
- info->setting_name = g_strdup (setting_name);
- info->context = context;
- priv->pending_gets = g_slist_append (priv->pending_gets, info);
-
- NM_SECRET_AGENT_GET_CLASS (self)->get_secrets (self,
- connection,
- connection_path,
- setting_name,
- hints,
- flags,
- get_secrets_cb,
- info);
- g_object_unref (connection);
-}
-
-static GetSecretsInfo *
-find_get_secrets_info (GSList *list, const char *path, const char *setting_name)
-{
- GSList *iter;
-
- for (iter = list; iter; iter = g_slist_next (iter)) {
- GetSecretsInfo *candidate = iter->data;
-
- if ( g_strcmp0 (path, candidate->path) == 0
- && g_strcmp0 (setting_name, candidate->setting_name) == 0)
- return candidate;
- }
- return NULL;
-}
-
-static void
-impl_secret_agent_cancel_get_secrets (NMSecretAgent *self,
- const char *connection_path,
- const char *setting_name,
- DBusGMethodInvocation *context)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
- GError *error = NULL;
- GetSecretsInfo *info;
-
- /* Make sure the request comes from NetworkManager and is valid */
- if (!verify_request (self, context, NULL, NULL, NULL, &error)) {
- dbus_g_method_return_error (context, error);
- g_clear_error (&error);
- return;
- }
-
- info = find_get_secrets_info (priv->pending_gets, connection_path, setting_name);
- if (!info) {
- g_set_error_literal (&error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
- "No secrets request in progress for this connection.");
- dbus_g_method_return_error (context, error);
- g_clear_error (&error);
- return;
- }
-
- /* Send the cancel request up to the subclass and finalize it */
- NM_SECRET_AGENT_GET_CLASS (self)->cancel_get_secrets (self,
- info->path,
- info->setting_name);
- dbus_g_method_return (context);
-}
-
-static void
-save_secrets_cb (NMSecretAgent *self,
- NMConnection *connection,
- GError *error,
- gpointer user_data)
-{
- DBusGMethodInvocation *context = user_data;
-
- if (error)
- dbus_g_method_return_error (context, error);
- else
- dbus_g_method_return (context);
-}
-
-static void
-impl_secret_agent_save_secrets (NMSecretAgent *self,
- GHashTable *connection_hash,
- const char *connection_path,
- DBusGMethodInvocation *context)
-{
- GError *error = NULL;
- NMConnection *connection = NULL;
-
- /* Make sure the request comes from NetworkManager and is valid */
- if (!verify_request (self, context, connection_hash, connection_path, &connection, &error)) {
- dbus_g_method_return_error (context, error);
- g_clear_error (&error);
- return;
- }
-
- NM_SECRET_AGENT_GET_CLASS (self)->save_secrets (self,
- connection,
- connection_path,
- save_secrets_cb,
- context);
- g_object_unref (connection);
-}
-
-static void
-delete_secrets_cb (NMSecretAgent *self,
- NMConnection *connection,
- GError *error,
- gpointer user_data)
-{
- DBusGMethodInvocation *context = user_data;
-
- if (error)
- dbus_g_method_return_error (context, error);
- else
- dbus_g_method_return (context);
-}
-
-static void
-impl_secret_agent_delete_secrets (NMSecretAgent *self,
- GHashTable *connection_hash,
- const char *connection_path,
- DBusGMethodInvocation *context)
-{
- GError *error = NULL;
- NMConnection *connection = NULL;
-
- /* Make sure the request comes from NetworkManager and is valid */
- if (!verify_request (self, context, connection_hash, connection_path, &connection, &error)) {
- dbus_g_method_return_error (context, error);
- g_clear_error (&error);
- return;
- }
-
- NM_SECRET_AGENT_GET_CLASS (self)->delete_secrets (self,
- connection,
- connection_path,
- delete_secrets_cb,
- context);
- g_object_unref (connection);
-}
-
-/*****************************************************************************/
-
-static void
-reg_result (NMSecretAgent *self, GError *error)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
-
- if (error) {
- /* If registration failed we shouldn't expose ourselves on the bus */
- _internal_unregister (self);
- } else {
- priv->registered = TRUE;
- g_object_notify (G_OBJECT (self), NM_SECRET_AGENT_REGISTERED);
- }
-
- g_signal_emit (self, signals[REGISTRATION_RESULT], 0, error);
-}
-
-static void
-reg_request_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- NMSecretAgent *self = NM_SECRET_AGENT (user_data);
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
- GError *error = NULL;
-
- priv->reg_call = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- reg_result (self, error);
- g_clear_error (&error);
-}
-
-static void
-reg_with_caps_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- NMSecretAgent *self = NM_SECRET_AGENT (user_data);
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
-
- priv->reg_call = NULL;
-
- if (dbus_g_proxy_end_call (proxy, call, NULL, G_TYPE_INVALID)) {
- reg_result (self, NULL);
- return;
- }
-
- /* Might be an old NetworkManager that doesn't support capabilities;
- * fall back to old Register() method instead.
- */
- priv->reg_call = dbus_g_proxy_begin_call_with_timeout (priv->manager_proxy,
- "Register",
- reg_request_cb,
- self,
- NULL,
- 5000,
- G_TYPE_STRING, priv->identifier,
- G_TYPE_INVALID);
-}
-
-/**
- * nm_secret_agent_register:
- * @self: a #NMSecretAgent
- *
- * Registers the #NMSecretAgent with the NetworkManager secret manager,
- * indicating to NetworkManager that the agent is able to provide and save
- * secrets for connections on behalf of its user. Registration is an
- * asynchronous operation and its success or failure is indicated via the
- * 'registration-result' signal.
- *
- * Returns: a new %TRUE if registration was successfully requested (this does
- * not mean registration itself was successful), %FALSE if registration was not
- * successfully requested.
- **/
-gboolean
-nm_secret_agent_register (NMSecretAgent *self)
-{
- NMSecretAgentPrivate *priv;
- NMSecretAgentClass *class;
-
- g_return_val_if_fail (NM_IS_SECRET_AGENT (self), FALSE);
-
- priv = NM_SECRET_AGENT_GET_PRIVATE (self);
-
- g_return_val_if_fail (priv->registered == FALSE, FALSE);
- g_return_val_if_fail (priv->reg_call == NULL, FALSE);
- g_return_val_if_fail (priv->bus != NULL, FALSE);
- g_return_val_if_fail (priv->manager_proxy != NULL, FALSE);
-
- /* Also make sure the subclass can actually respond to secrets requests */
- class = NM_SECRET_AGENT_GET_CLASS (self);
- g_return_val_if_fail (class->get_secrets != NULL, FALSE);
- g_return_val_if_fail (class->save_secrets != NULL, FALSE);
- g_return_val_if_fail (class->delete_secrets != NULL, FALSE);
-
- if (!priv->nm_owner)
- return FALSE;
-
- priv->suppress_auto = FALSE;
-
- /* Export our secret agent interface before registering with the manager */
- dbus_g_connection_register_g_object (priv->bus,
- NM_DBUS_PATH_SECRET_AGENT,
- G_OBJECT (self));
-
- priv->reg_call = dbus_g_proxy_begin_call_with_timeout (priv->manager_proxy,
- "RegisterWithCapabilities",
- reg_with_caps_cb,
- self,
- NULL,
- 5000,
- G_TYPE_STRING, priv->identifier,
- G_TYPE_UINT, priv->capabilities,
- G_TYPE_INVALID);
- return TRUE;
-}
-
-/**
- * nm_secret_agent_unregister:
- * @self: a #NMSecretAgent
- *
- * Unregisters the #NMSecretAgent with the NetworkManager secret manager,
- * indicating to NetworkManager that the agent is will no longer provide or
- * store secrets on behalf of this user.
- *
- * Returns: a new %TRUE if unregistration was successful, %FALSE if it was not.
- **/
-gboolean
-nm_secret_agent_unregister (NMSecretAgent *self)
-{
- NMSecretAgentPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SECRET_AGENT (self), FALSE);
-
- priv = NM_SECRET_AGENT_GET_PRIVATE (self);
-
- g_return_val_if_fail (priv->registered == TRUE, FALSE);
- g_return_val_if_fail (priv->bus != NULL, FALSE);
- g_return_val_if_fail (priv->manager_proxy != NULL, FALSE);
-
- if (!priv->nm_owner)
- return FALSE;
-
- dbus_g_proxy_call_no_reply (priv->manager_proxy, "Unregister", G_TYPE_INVALID);
-
- _internal_unregister (self);
- priv->suppress_auto = TRUE;
-
- return TRUE;
-}
-
-/**
- * nm_secret_agent_get_registered:
- * @self: a #NMSecretAgent
- *
- * Returns: a %TRUE if the agent is registered, %FALSE if it is not.
- **/
-gboolean
-nm_secret_agent_get_registered (NMSecretAgent *self)
-{
- g_return_val_if_fail (NM_IS_SECRET_AGENT (self), FALSE);
-
- return NM_SECRET_AGENT_GET_PRIVATE (self)->registered;
-}
-
-static gboolean
-auto_register_cb (gpointer user_data)
-{
- NMSecretAgent *self = NM_SECRET_AGENT (user_data);
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
-
- priv->auto_register_id = 0;
- if (priv->auto_register && !priv->suppress_auto &&
- (priv->reg_call == NULL && !priv->registered))
- nm_secret_agent_register (self);
- return FALSE;
-}
-
-/*****************************************************************************/
-
-/**
- * nm_secret_agent_get_secrets: (virtual get_secrets):
- * @self: a #NMSecretAgent
- * @connection: the #NMConnection for which we're asked secrets
- * @setting_name: the name of the secret setting
- * @hints: (array zero-terminated=1): hints to the agent
- * @flags: flags that modify the behavior of the request
- * @callback: (scope async): a callback, to be invoked when the operation is done
- * @user_data: (closure): caller-specific data to be passed to @callback
- *
- * Asynchronously retrieve secrets belonging to @connection for the
- * setting @setting_name. @flags indicate specific behavior that the secret
- * agent should use when performing the request, for example returning only
- * existing secrets without user interaction, or requesting entirely new
- * secrets from the user.
- */
-void
-nm_secret_agent_get_secrets (NMSecretAgent *self,
- NMConnection *connection,
- const char *setting_name,
- const char **hints,
- NMSecretAgentGetSecretsFlags flags,
- NMSecretAgentGetSecretsFunc callback,
- gpointer user_data)
-{
- g_return_if_fail (NM_IS_SECRET_AGENT (self));
- g_return_if_fail (NM_IS_CONNECTION (connection));
- g_return_if_fail (nm_connection_get_path (connection));
- g_return_if_fail (setting_name != NULL);
- g_return_if_fail (strlen (setting_name) > 0);
- g_return_if_fail (callback != NULL);
-
- NM_SECRET_AGENT_GET_CLASS (self)->get_secrets (self,
- connection,
- nm_connection_get_path (connection),
- setting_name,
- hints,
- flags,
- callback,
- user_data);
-}
-
-/**
- * nm_secret_agent_save_secrets: (virtual save_secrets):
- * @self: a #NMSecretAgent
- * @connection: a #NMConnection
- * @callback: (scope async): a callback, to be invoked when the operation is done
- * @user_data: (closure): caller-specific data to be passed to @callback
- *
- * Asynchronously ensure that all secrets inside @connection
- * are stored to disk.
- */
-void
-nm_secret_agent_save_secrets (NMSecretAgent *self,
- NMConnection *connection,
- NMSecretAgentSaveSecretsFunc callback,
- gpointer user_data)
-{
- g_return_if_fail (NM_IS_SECRET_AGENT (self));
- g_return_if_fail (NM_IS_CONNECTION (connection));
- g_return_if_fail (nm_connection_get_path (connection));
-
- NM_SECRET_AGENT_GET_CLASS (self)->save_secrets (self,
- connection,
- nm_connection_get_path (connection),
- callback,
- user_data);
-}
-
-/**
- * nm_secret_agent_delete_secrets: (virtual delete_secrets):
- * @self: a #NMSecretAgent
- * @connection: a #NMConnection
- * @callback: (scope async): a callback, to be invoked when the operation is done
- * @user_data: (closure): caller-specific data to be passed to @callback
- *
- * Asynchronously ask the agent to delete all saved secrets belonging to
- * @connection.
- */
-void
-nm_secret_agent_delete_secrets (NMSecretAgent *self,
- NMConnection *connection,
- NMSecretAgentDeleteSecretsFunc callback,
- gpointer user_data)
-{
- g_return_if_fail (NM_IS_SECRET_AGENT (self));
- g_return_if_fail (NM_IS_CONNECTION (connection));
- g_return_if_fail (nm_connection_get_path (connection));
-
- NM_SECRET_AGENT_GET_CLASS (self)->delete_secrets (self,
- connection,
- nm_connection_get_path (connection),
- callback,
- user_data);
-}
-
-/*****************************************************************************/
-
-static gboolean
-validate_identifier (const char *identifier)
-{
- const char *p = identifier;
- size_t id_len;
-
- /* Length between 3 and 255 characters inclusive */
- id_len = strlen (identifier);
- if (id_len < 3 || id_len > 255)
- return FALSE;
-
- if ((identifier[0] == '.') || (identifier[id_len - 1] == '.'))
- return FALSE;
-
- /* FIXME: do complete validation here */
- while (p && *p) {
- if (!g_ascii_isalnum (*p) && (*p != '_') && (*p != '-') && (*p != '.'))
- return FALSE;
- if ((*p == '.') && (*(p + 1) == '.'))
- return FALSE;
- p++;
- }
-
- return TRUE;
-}
-
-static void
-nm_secret_agent_init (NMSecretAgent *self)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
- GError *error = NULL;
-
- priv->bus = _nm_dbus_new_connection (&error);
- if (!priv->bus) {
- g_warning ("Couldn't connect to system bus: %s", error->message);
- g_error_free (error);
- return;
- }
-
- priv->dbus_proxy = dbus_g_proxy_new_for_name (priv->bus,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- g_assert (priv->dbus_proxy);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
- G_TYPE_NONE,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->dbus_proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->dbus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (name_owner_changed),
- self, NULL);
-
- get_nm_owner (self);
-
- priv->manager_proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
- NM_DBUS_PATH_AGENT_MANAGER,
- NM_DBUS_INTERFACE_AGENT_MANAGER);
- if (!priv->manager_proxy) {
- g_warning ("Couldn't create NM agent manager proxy.");
- return;
- }
-
- if (priv->nm_owner)
- priv->auto_register_id = g_idle_add (auto_register_cb, self);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_IDENTIFIER:
- g_value_set_string (value, priv->identifier);
- break;
- case PROP_AUTO_REGISTER:
- g_value_set_boolean (value, priv->auto_register);
- break;
- case PROP_REGISTERED:
- g_value_set_boolean (value, priv->registered);
- break;
- case PROP_CAPABILITIES:
- g_value_set_flags (value, priv->capabilities);
- 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)
-{
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (object);
- const char *identifier;
-
- switch (prop_id) {
- case PROP_IDENTIFIER:
- identifier = g_value_get_string (value);
-
- g_return_if_fail (validate_identifier (identifier));
-
- g_free (priv->identifier);
- priv->identifier = g_strdup (identifier);
- break;
- case PROP_AUTO_REGISTER:
- priv->auto_register = g_value_get_boolean (value);
- break;
- case PROP_CAPABILITIES:
- priv->capabilities = g_value_get_flags (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-dispose (GObject *object)
-{
- NMSecretAgent *self = NM_SECRET_AGENT (object);
- NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
-
- if (priv->registered)
- nm_secret_agent_unregister (self);
-
- if (priv->auto_register_id) {
- g_source_remove (priv->auto_register_id);
- priv->auto_register_id = 0;
- }
-
- g_free (priv->identifier);
- priv->identifier = NULL;
- g_free (priv->nm_owner);
- priv->nm_owner = NULL;
-
- while (priv->pending_gets)
- get_secrets_info_finalize (self, priv->pending_gets->data);
-
- g_clear_object (&priv->dbus_proxy);
- g_clear_object (&priv->manager_proxy);
-
- if (priv->bus) {
- dbus_g_connection_unref (priv->bus);
- priv->bus = NULL;
- }
-
- G_OBJECT_CLASS (nm_secret_agent_parent_class)->dispose (object);
-}
-
-static void
-nm_secret_agent_class_init (NMSecretAgentClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- g_type_class_add_private (class, sizeof (NMSecretAgentPrivate));
-
- /* Virtual methods */
- object_class->dispose = dispose;
- object_class->get_property = get_property;
- object_class->set_property = set_property;
-
- /**
- * NMSecretAgent:identifier:
- *
- * Identifies this agent; only one agent in each user session may use the
- * same identifier. Identifier formatting follows the same rules as
- * D-Bus bus names with the exception that the ':' character is not
- * allowed. The valid set of characters is "[A-Z][a-z][0-9]_-." and the
- * identifier is limited in length to 255 characters with a minimum
- * of 3 characters. An example valid identifier is 'org.gnome.nm-applet'
- * (without quotes).
- **/
- g_object_class_install_property
- (object_class, PROP_IDENTIFIER,
- g_param_spec_string (NM_SECRET_AGENT_IDENTIFIER, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSecretAgent:auto-register:
- *
- * If TRUE, the agent will attempt to automatically register itself after
- * it is created (via an idle handler) and to re-register itself if
- * NetworkManager restarts. If FALSE, the agent does not automatically
- * register with NetworkManager, and nm_secret_agent_register() must be
- * called. If 'auto-register' is TRUE, calling nm_secret_agent_unregister()
- * will suppress auto-registration until nm_secret_agent_register() is
- * called, which re-enables auto-registration.
- **/
- g_object_class_install_property
- (object_class, PROP_AUTO_REGISTER,
- g_param_spec_boolean (NM_SECRET_AGENT_AUTO_REGISTER, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSecretAgent:registered:
- *
- * %TRUE if the agent is registered with NetworkManager, %FALSE if not.
- **/
- g_object_class_install_property
- (object_class, PROP_REGISTERED,
- g_param_spec_boolean (NM_SECRET_AGENT_REGISTERED, "", "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSecretAgent:capabilities:
- *
- * A bitfield of %NMSecretAgentCapabilities.
- **/
- g_object_class_install_property
- (object_class, PROP_CAPABILITIES,
- g_param_spec_flags (NM_SECRET_AGENT_CAPABILITIES, "", "",
- NM_TYPE_SECRET_AGENT_CAPABILITIES,
- NM_SECRET_AGENT_CAPABILITY_NONE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSecretAgent::registration-result:
- * @agent: the agent that received the signal
- * @error: the error, if any, that occurred while registering
- *
- * Indicates the result of a registration request; if @error is NULL the
- * request was successful.
- **/
- signals[REGISTRATION_RESULT] =
- g_signal_new (NM_SECRET_AGENT_REGISTRATION_RESULT,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class),
- &dbus_glib_nm_secret_agent_object_info);
-
- dbus_g_error_domain_register (NM_SECRET_AGENT_ERROR,
- NM_DBUS_INTERFACE_SECRET_AGENT,
- NM_TYPE_SECRET_AGENT_ERROR);
-}
diff --git a/libnm-glib/nm-secret-agent.h b/libnm-glib/nm-secret-agent.h
deleted file mode 100644
index 621e5e7bf9..0000000000
--- a/libnm-glib/nm-secret-agent.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2010 - 2011 Red Hat, Inc.
- */
-
-#ifndef NM_SECRET_AGENT_H
-#define NM_SECRET_AGENT_H
-
-#include "nm-connection.h"
-
-G_BEGIN_DECLS
-
-#define NM_SECRET_AGENT_ERROR (nm_secret_agent_error_quark ())
-
-GQuark nm_secret_agent_error_quark (void);
-
-/**
- * NMSecretAgentError:
- * @NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED: the caller (ie, NetworkManager) is not
- * authorized to make this request
- * @NM_SECRET_AGENT_ERROR_INVALID_CONNECTION: the connection for which secrets
- * were requested could not be found
- * @NM_SECRET_AGENT_ERROR_USER_CANCELED: the request was canceled by the user
- * @NM_SECRET_AGENT_ERROR_AGENT_CANCELED: the agent canceled the request
- * because it was requested to do so by NetworkManager
- * @NM_SECRET_AGENT_ERROR_INTERNAL_ERROR: some internal error in the agent caused
- * the request to fail
- * @NM_SECRET_AGENT_ERROR_NO_SECRETS: the agent cannot find any secrets for this
- * connection
- *
- * #NMSecretAgentError values are passed by secret agents back to NetworkManager
- * when they encounter problems retrieving secrets on behalf of NM.
- */
-typedef enum {
- NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED = 0, /*< nick=NotAuthorized >*/
- NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/
- NM_SECRET_AGENT_ERROR_USER_CANCELED, /*< nick=UserCanceled >*/
- NM_SECRET_AGENT_ERROR_AGENT_CANCELED, /*< nick=AgentCanceled >*/
- NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, /*< nick=InternalError >*/
- NM_SECRET_AGENT_ERROR_NO_SECRETS, /*< nick=NoSecrets >*/
-} NMSecretAgentError;
-
-/**
- * NMSecretAgentCapabilities:
- * @NM_SECRET_AGENT_CAPABILITY_NONE: the agent supports no special capabilities
- * @NM_SECRET_AGENT_CAPABILITY_VPN_HINTS: the agent supports sending hints given
- * by the <literal>get_secrets</literal> class method to VPN plugin
- * authentication dialogs.
- * @NM_SECRET_AGENT_CAPABILITY_LAST: bounds checking value; should not be used.
- *
- * #NMSecretAgentCapabilities indicate various capabilities of the agent.
- *
- * Since: 0.9.10
- */
-typedef enum /*< flags >*/ {
- NM_SECRET_AGENT_CAPABILITY_NONE = 0x0,
- NM_SECRET_AGENT_CAPABILITY_VPN_HINTS = 0x1,
-
- /* boundary value */
- NM_SECRET_AGENT_CAPABILITY_LAST = NM_SECRET_AGENT_CAPABILITY_VPN_HINTS
-} NMSecretAgentCapabilities;
-
-/**
- * NMSecretAgentGetSecretsFlags:
- * @NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE: no special behavior; by default no
- * user interaction is allowed and requests for secrets are fulfilled from
- * persistent storage, or if no secrets are available an error is returned.
- * @NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION: allows the request to
- * interact with the user, possibly prompting via UI for secrets if any are
- * required, or if none are found in persistent storage.
- * @NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW: explicitly prompt for new
- * secrets from the user. This flag signals that NetworkManager thinks any
- * existing secrets are invalid or wrong. This flag implies that interaction
- * is allowed.
- * @NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED: set if the request was
- * initiated by user-requested action via the D-Bus interface, as opposed to
- * automatically initiated by NetworkManager in response to (for example) scan
- * results or carrier changes.
- *
- * #NMSecretAgentGetSecretsFlags values modify the behavior of a GetSecrets request.
- */
-typedef enum /*< flags >*/ {
- NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
- NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
- NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
- NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED = 0x4
-} NMSecretAgentGetSecretsFlags;
-
-#define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ())
-#define NM_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgent))
-#define NM_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT, NMSecretAgentClass))
-#define NM_IS_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SECRET_AGENT))
-#define NM_IS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SECRET_AGENT))
-#define NM_SECRET_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgentClass))
-
-#define NM_SECRET_AGENT_IDENTIFIER "identifier"
-#define NM_SECRET_AGENT_AUTO_REGISTER "auto-register"
-#define NM_SECRET_AGENT_REGISTERED "registered"
-#define NM_SECRET_AGENT_CAPABILITIES "capabilities"
-
-#define NM_SECRET_AGENT_REGISTRATION_RESULT "registration-result"
-
-typedef struct {
- GObject parent;
-} NMSecretAgent;
-
-/**
- * NMSecretAgentGetSecretsFunc:
- * @agent: the secret agent object
- * @connection: (transfer none): the connection for which secrets were requested,
- * note that this object will be unrefed after the callback has returned, use
- * g_object_ref()/g_object_unref() if you want to use this object after the callback
- * has returned
- * @secrets: (element-type utf8 GLib.HashTable): the #GHashTable containing
- * the requested secrets in the same format as an #NMConnection hash (as
- * created by nm_connection_to_hash() for example). Each key in @secrets
- * should be the name of a #NMSetting object (like "802-11-wireless-security")
- * and each value should be a #GHashTable. The sub-hashes map string:#GValue
- * where the string is the setting property name (like "psk") and the value
- * is the secret
- * @error: if the secrets request failed, give a descriptive error here
- * @user_data: caller-specific data to be passed to the function
- *
- * Called as a result of a request by NM to retrieve secrets. When the
- * #NMSecretAgent subclass has finished retrieving secrets and is ready to
- * return them, or to return an error, this function should be called with
- * those secrets or the error.
- *
- * To easily create the hash table to return the Wi-Fi PSK, you could do
- * something like this:
- * <example>
- * <title>Creating a secrets hash</title>
- * <programlisting>
- * NMConnection *secrets;
- * NMSettingWirelessSecurity *s_wsec;
- * GHashTable *secrets_hash;
- *
- * secrets = nm_connection_new ();
- * s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
- * g_object_set (G_OBJECT (s_wsec),
- * NM_SETTING_WIRELESS_SECURITY_PSK, "my really cool PSK",
- * NULL);
- * nm_connection_add_setting (secrets, NM_SETTING (s_wsec));
- * secrets_hash = nm_connection_to_hash (secrets, NM_SETTING_HASH_FLAG_ALL);
- *
- * (call the NMSecretAgentGetSecretsFunc with secrets_hash)
- *
- * g_object_unref (secrets);
- * g_hash_table_unref (secrets_hash);
- * </programlisting>
- * </example>
- */
-typedef void (*NMSecretAgentGetSecretsFunc) (NMSecretAgent *agent,
- NMConnection *connection,
- GHashTable *secrets,
- GError *error,
- gpointer user_data);
-
-/**
- * NMSecretAgentSaveSecretsFunc:
- * @agent: the secret agent object
- * @connection: (transfer none): the connection for which secrets were to be saved,
- * note that this object will be unrefed after the callback has returned, use
- * g_object_ref()/g_object_unref() if you want to use this object after the callback
- * has returned
- * @error: if the saving secrets failed, give a descriptive error here
- * @user_data: caller-specific data to be passed to the function
- *
- * Called as a result of a request by NM to save secrets. When the
- * #NMSecretAgent subclass has finished saving the secrets, this function
- * should be called.
- */
-typedef void (*NMSecretAgentSaveSecretsFunc) (NMSecretAgent *agent,
- NMConnection *connection,
- GError *error,
- gpointer user_data);
-
-/**
- * NMSecretAgentDeleteSecretsFunc:
- * @agent: the secret agent object
- * @connection: (transfer none): the connection for which secrets were to be deleted,
- * note that this object will be unrefed after the callback has returned, use
- * g_object_ref()/g_object_unref() if you want to use this object after the callback
- * has returned
- * @error: if the deleting secrets failed, give a descriptive error here
- * @user_data: caller-specific data to be passed to the function
- *
- * Called as a result of a request by NM to delete secrets. When the
- * #NMSecretAgent subclass has finished deleting the secrets, this function
- * should be called.
- */
-typedef void (*NMSecretAgentDeleteSecretsFunc) (NMSecretAgent *agent,
- NMConnection *connection,
- GError *error,
- gpointer user_data);
-
-typedef struct {
- GObjectClass parent;
-
- /* Virtual methods for subclasses */
-
- /* Called when the subclass should retrieve and return secrets. Subclass
- * must copy or reference any arguments it may require after returning from
- * this method, as the arguments will freed (except for 'self', 'callback',
- * and 'user_data' of course). If the request is canceled, the callback
- * should still be called, but with the NM_SECRET_AGENT_ERROR_AGENT_CANCELED
- * error.
- */
- void (*get_secrets) (NMSecretAgent *self,
- NMConnection *connection,
- const char *connection_path,
- const char *setting_name,
- const char **hints,
- NMSecretAgentGetSecretsFlags flags,
- NMSecretAgentGetSecretsFunc callback,
- gpointer user_data);
-
- /* Called when the subclass should cancel an outstanding request to
- * get secrets for a given connection. Canceling the request MUST
- * call the callback that was passed along with the initial get_secrets
- * call, sending the NM_SECRET_AGENT_ERROR/NM_SECRET_AGENT_ERROR_AGENT_CANCELED
- * error to that callback.
- */
- void (*cancel_get_secrets) (NMSecretAgent *self,
- 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
- * arguments it may require after returning from this method, as the
- * arguments will freed (except for 'self', 'callback', and 'user_data'
- * of course).
- */
- void (*save_secrets) (NMSecretAgent *self,
- NMConnection *connection,
- const char *connection_path,
- NMSecretAgentSaveSecretsFunc callback,
- gpointer user_data);
-
- /* Called when the subclass should delete the secrets contained in the
- * connection from backing storage. Subclass must copy or reference any
- * arguments it may require after returning from this method, as the
- * arguments will freed (except for 'self', 'callback', and 'user_data'
- * of course).
- */
- void (*delete_secrets) (NMSecretAgent *self,
- NMConnection *connection,
- const char *connection_path,
- NMSecretAgentDeleteSecretsFunc callback,
- gpointer user_data);
-
- /* Signals */
- void (*registration_result) (NMSecretAgent *agent, GError *error);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMSecretAgentClass;
-
-GType nm_secret_agent_get_type (void);
-
-gboolean nm_secret_agent_register (NMSecretAgent *self);
-
-gboolean nm_secret_agent_unregister (NMSecretAgent *self);
-
-gboolean nm_secret_agent_get_registered (NMSecretAgent *self);
-
-void nm_secret_agent_get_secrets (NMSecretAgent *self,
- NMConnection *connection,
- const char *setting_name,
- const char **hints,
- NMSecretAgentGetSecretsFlags flags,
- NMSecretAgentGetSecretsFunc callback,
- gpointer user_data);
-
-void nm_secret_agent_save_secrets (NMSecretAgent *self,
- NMConnection *connection,
- NMSecretAgentSaveSecretsFunc callback,
- gpointer user_data);
-
-void nm_secret_agent_delete_secrets (NMSecretAgent *self,
- NMConnection *connection,
- NMSecretAgentDeleteSecretsFunc callback,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* NM_SECRET_AGENT_H */
diff --git a/libnm-glib/nm-types-private.h b/libnm-glib/nm-types-private.h
deleted file mode 100644
index 7cd907dc22..0000000000
--- a/libnm-glib/nm-types-private.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Red Hat, Inc.
- */
-
-#ifndef NM_TYPES_PRIVATE_H
-#define NM_TYPES_PRIVATE_H
-
-#include <dbus/dbus-glib.h>
-#include "nm-types.h"
-#include "nm-object-private.h"
-
-gboolean _nm_ssid_demarshal (GValue *value, GByteArray **dest);
-gboolean _nm_uint_array_demarshal (GValue *value, GArray **dest);
-gboolean _nm_string_array_demarshal (GValue *value, GPtrArray **dest);
-gboolean _nm_ip6_address_array_demarshal (GValue *value, GSList **dest);
-
-#endif /* NM_TYPES_PRIVATE_H */
diff --git a/libnm-glib/nm-types.c b/libnm-glib/nm-types.c
deleted file mode 100644
index 4f7236d365..0000000000
--- a/libnm-glib/nm-types.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <dbus/dbus-glib.h>
-#include <string.h>
-
-#include "nm-types.h"
-#include "nm-types-private.h"
-#include "nm-object-private.h"
-#include "nm-object-cache.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-ip6-config.h"
-
-static gpointer
-_nm_ssid_copy (GByteArray *src)
-{
- GByteArray *dest;
-
- dest = g_byte_array_sized_new (src->len);
- g_byte_array_append (dest, src->data, src->len);
- return dest;
-}
-
-static void
-_nm_ssid_free (GByteArray *ssid)
-{
- g_byte_array_free (ssid, TRUE);
-}
-
-GType
-nm_ssid_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (g_intern_static_string ("NMSsid"),
- (GBoxedCopyFunc) _nm_ssid_copy,
- (GBoxedFreeFunc) _nm_ssid_free);
- return our_type;
-}
-
-gboolean
-_nm_ssid_demarshal (GValue *value, GByteArray **dest)
-{
- GByteArray *array;
-
- if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_UCHAR_ARRAY))
- return FALSE;
-
- if (*dest) {
- g_boxed_free (NM_TYPE_SSID, *dest);
- *dest = NULL;
- }
-
- array = (GByteArray *) g_value_get_boxed (value);
- if (array && (array->len > 0)) {
- *dest = g_byte_array_sized_new (array->len);
- (*dest)->len = array->len;
- memcpy ((*dest)->data, array->data, array->len);
- }
-
- return TRUE;
-}
-
-/*****************************************************************************/
-
-static gpointer
-_nm_uint_array_copy (GArray *src)
-{
- GArray *dest;
-
- dest = g_array_sized_new (FALSE, TRUE, sizeof (guint32), src->len);
- g_array_append_vals (dest, src->data, src->len);
- return dest;
-}
-
-static void
-_nm_uint_array_free (GArray *array)
-{
- g_array_free (array, TRUE);
-}
-
-GType
-nm_uint_array_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (g_intern_static_string ("NMUintArray"),
- (GBoxedCopyFunc) _nm_uint_array_copy,
- (GBoxedFreeFunc) _nm_uint_array_free);
- return our_type;
-}
-
-gboolean
-_nm_uint_array_demarshal (GValue *value, GArray **dest)
-{
- GArray *array;
-
- if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_UINT_ARRAY))
- return FALSE;
-
- if (*dest) {
- g_boxed_free (NM_TYPE_UINT_ARRAY, *dest);
- *dest = NULL;
- }
-
- array = (GArray *) g_value_get_boxed (value);
- if (array && (array->len > 0)) {
- *dest = g_array_sized_new (FALSE, TRUE, sizeof (guint32), array->len);
- g_array_append_vals (*dest, array->data, array->len);
- }
-
- return TRUE;
-}
-
-/*****************************************************************************/
-
-static gpointer
-_nm_string_array_copy (GPtrArray *src)
-{
- GPtrArray *dest;
- int i;
-
- dest = g_ptr_array_sized_new (src->len);
- for (i = 0; i < src->len; i++)
- g_ptr_array_add (dest, g_strdup (g_ptr_array_index (src, i)));
- return dest;
-}
-
-static void
-_nm_string_array_free (GPtrArray *array)
-{
- int i;
-
- for (i = 0; i < array->len; i++)
- g_free (g_ptr_array_index (array, i));
- g_ptr_array_free (array, TRUE);
-}
-
-GType
-nm_string_array_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (g_intern_static_string ("NMStringArray"),
- (GBoxedCopyFunc) _nm_string_array_copy,
- (GBoxedFreeFunc) _nm_string_array_free);
- return our_type;
-}
-
-gboolean
-_nm_string_array_demarshal (GValue *value, GPtrArray **dest)
-{
- char **array;
-
- if (!G_VALUE_HOLDS (value, G_TYPE_STRV))
- return FALSE;
-
- if (*dest) {
- g_boxed_free (NM_TYPE_STRING_ARRAY, *dest);
- *dest = NULL;
- }
-
- array = (char **) g_value_get_boxed (value);
- if (array && array[0]) {
- int i;
-
- *dest = g_ptr_array_new ();
- for (i = 0; array[i]; i++)
- g_ptr_array_add (*dest, g_strdup (array[i]));
- }
-
- return TRUE;
-}
-
-/*****************************************************************************/
-
-static gpointer
-_nm_object_array_copy (GPtrArray *src)
-{
- GPtrArray *dest;
- int i;
-
- dest = g_ptr_array_sized_new (src->len);
- for (i = 0; i < src->len; i++)
- g_ptr_array_add (dest, g_object_ref (g_ptr_array_index (src, i)));
- return dest;
-}
-
-static void
-_nm_object_array_free (GPtrArray *array)
-{
- int i;
-
- for (i = 0; i < array->len; i++)
- g_object_unref (g_ptr_array_index (array, i));
- g_ptr_array_free (array, TRUE);
-}
-
-GType
-nm_object_array_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (g_intern_static_string ("NMObjectArray"),
- (GBoxedCopyFunc) _nm_object_array_copy,
- (GBoxedFreeFunc) _nm_object_array_free);
- return our_type;
-}
-
-/*****************************************************************************/
-
-static gpointer
-_nm_ip6_address_object_array_copy (GPtrArray *src)
-{
- GPtrArray *dest;
- int i;
-
- dest = g_ptr_array_sized_new (src->len);
- for (i = 0; i < src->len; i++)
- g_ptr_array_add (dest, nm_ip6_address_dup (g_ptr_array_index (src, i)));
- return dest;
-}
-
-static void
-_nm_ip6_address_object_array_free (GPtrArray *array)
-{
- int i;
-
- for (i = 0; i < array->len; i++)
- nm_ip6_address_unref (g_ptr_array_index (array, i));
- g_ptr_array_free (array, TRUE);
-}
-
-GType
-nm_ip6_address_object_array_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6AddressObjectArray"),
- (GBoxedCopyFunc) _nm_ip6_address_object_array_copy,
- (GBoxedFreeFunc) _nm_ip6_address_object_array_free);
- return our_type;
-}
-
-/*****************************************************************************/
-
-static gpointer
-_nm_ip6_address_array_copy (GPtrArray *src)
-{
- GPtrArray *dest;
- int i;
-
- dest = g_ptr_array_sized_new (src->len);
- for (i = 0; i < src->len; i++) {
- struct in6_addr *addr = g_ptr_array_index (src, i);
- struct in6_addr *copy;
-
- copy = g_malloc0 (sizeof (struct in6_addr));
- memcpy (copy, addr, sizeof (struct in6_addr));
- g_ptr_array_add (dest, copy);
- }
- return dest;
-}
-
-static void
-_nm_ip6_address_array_free (GPtrArray *array)
-{
- int i;
-
- for (i = 0; i < array->len; i++)
- g_free (g_ptr_array_index (array, i));
- g_ptr_array_free (array, TRUE);
-}
-
-GType
-nm_ip6_address_array_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6AddressArray"),
- (GBoxedCopyFunc) _nm_ip6_address_array_copy,
- (GBoxedFreeFunc) _nm_ip6_address_array_free);
- return our_type;
-}
-
-gboolean
-_nm_ip6_address_array_demarshal (GValue *value, GSList **dest)
-{
- GPtrArray *array;
-
- if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR))
- return FALSE;
-
- if (*dest) {
- g_slist_free_full (*dest, g_free);
- *dest = NULL;
- }
-
- array = (GPtrArray *) g_value_get_boxed (value);
- if (array && array->len) {
- int i;
-
- for (i = 0; i < array->len; i++) {
- GByteArray *bytearray = (GByteArray *) g_ptr_array_index (array, i);
- struct in6_addr *addr;
-
- addr = g_malloc0 (sizeof (struct in6_addr));
- memcpy (addr->s6_addr, bytearray->data, bytearray->len);
- *dest = g_slist_append (*dest, addr);
- }
- }
-
- return TRUE;
-}
-
-/*****************************************************************************/
-
-static gpointer
-_nm_ip6_route_object_array_copy (GPtrArray *src)
-{
- GPtrArray *dest;
- int i;
-
- dest = g_ptr_array_sized_new (src->len);
- for (i = 0; i < src->len; i++)
- g_ptr_array_add (dest, nm_ip6_route_dup (g_ptr_array_index (src, i)));
- return dest;
-}
-
-static void
-_nm_ip6_route_object_array_free (GPtrArray *array)
-{
- int i;
-
- for (i = 0; i < array->len; i++)
- nm_ip6_route_unref (g_ptr_array_index (array, i));
- g_ptr_array_free (array, TRUE);
-}
-
-GType
-nm_ip6_route_object_array_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6RouteObjectArray"),
- (GBoxedCopyFunc) _nm_ip6_route_object_array_copy,
- (GBoxedFreeFunc) _nm_ip6_route_object_array_free);
- return our_type;
-}
diff --git a/libnm-glib/nm-types.h b/libnm-glib/nm-types.h
deleted file mode 100644
index 9b58cd81e9..0000000000
--- a/libnm-glib/nm-types.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 Red Hat, Inc.
- */
-
-#ifndef NM_TYPES_H
-#define NM_TYPES_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "nm-glib-enum-types.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SSID (nm_ssid_get_type ())
-GType nm_ssid_get_type (void) G_GNUC_CONST;
-
-#define NM_TYPE_UINT_ARRAY (nm_uint_array_get_type ())
-GType nm_uint_array_get_type (void) G_GNUC_CONST;
-
-#define NM_TYPE_STRING_ARRAY (nm_string_array_get_type ())
-GType nm_string_array_get_type (void) G_GNUC_CONST;
-
-#define NM_TYPE_OBJECT_ARRAY (nm_object_array_get_type ())
-GType nm_object_array_get_type (void) G_GNUC_CONST;
-
-#define NM_TYPE_IP6_ADDRESS_OBJECT_ARRAY (nm_ip6_address_object_array_get_type ())
-GType nm_ip6_address_object_array_get_type (void) G_GNUC_CONST;
-
-#define NM_TYPE_IP6_ADDRESS_ARRAY (nm_ip6_address_array_get_type ())
-GType nm_ip6_address_array_get_type (void) G_GNUC_CONST;
-
-#define NM_TYPE_IP6_ROUTE_OBJECT_ARRAY (nm_ip6_route_object_array_get_type ())
-GType nm_ip6_route_object_array_get_type (void) G_GNUC_CONST;
-
-G_END_DECLS
-
-#endif /* NM_TYPES_H */
diff --git a/libnm-glib/nm-vpn-connection.c b/libnm-glib/nm-vpn-connection.c
deleted file mode 100644
index 68f495a967..0000000000
--- a/libnm-glib/nm-vpn-connection.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2012 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-vpn-connection.h"
-#include "NetworkManager.h"
-#include "nm-utils.h"
-#include "nm-object-private.h"
-#include "nm-active-connection.h"
-
-G_DEFINE_TYPE (NMVPNConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION)
-
-#define NM_VPN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_VPN_CONNECTION, NMVPNConnectionPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
- char *banner;
- NMVPNConnectionState vpn_state;
-} NMVPNConnectionPrivate;
-
-enum {
- PROP_0,
- PROP_VPN_STATE,
- PROP_BANNER,
-
- LAST_PROP
-};
-
-enum {
- VPN_STATE_CHANGED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/**
- * nm_vpn_connection_new:
- * @connection: the #DBusGConnection
- * @path: the DBus object path of the new connection
- *
- * Creates a new #NMVPNConnection.
- *
- * Returns: (transfer full): a new connection object
- **/
-GObject *
-nm_vpn_connection_new (DBusGConnection *connection, const char *path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- return g_object_new (NM_TYPE_VPN_CONNECTION,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
-}
-
-/**
- * nm_vpn_connection_get_banner:
- * @vpn: a #NMVPNConnection
- *
- * Gets the VPN login banner of the active #NMVPNConnection.
- *
- * Returns: the VPN login banner of the VPN connection. This is the internal
- * string used by the connection, and must not be modified.
- **/
-const char *
-nm_vpn_connection_get_banner (NMVPNConnection *vpn)
-{
- NMVPNConnectionPrivate *priv;
-
- g_return_val_if_fail (NM_IS_VPN_CONNECTION (vpn), NULL);
-
- priv = NM_VPN_CONNECTION_GET_PRIVATE (vpn);
-
- /* We need to update vpn_state first in case it's unknown. */
- _nm_object_ensure_inited (NM_OBJECT (vpn));
-
- if (priv->vpn_state != NM_VPN_CONNECTION_STATE_ACTIVATED)
- return NULL;
-
- return priv->banner;
-}
-
-/**
- * nm_vpn_connection_get_vpn_state:
- * @vpn: a #NMVPNConnection
- *
- * Gets the current #NMVPNConnection state.
- *
- * Returns: the VPN state of the active VPN connection.
- **/
-NMVPNConnectionState
-nm_vpn_connection_get_vpn_state (NMVPNConnection *vpn)
-{
- g_return_val_if_fail (NM_IS_VPN_CONNECTION (vpn), NM_VPN_CONNECTION_STATE_UNKNOWN);
-
- _nm_object_ensure_inited (NM_OBJECT (vpn));
- return NM_VPN_CONNECTION_GET_PRIVATE (vpn)->vpn_state;
-}
-
-static void
-vpn_state_changed_proxy (DBusGProxy *proxy,
- NMVPNConnectionState vpn_state,
- NMVPNConnectionStateReason reason,
- gpointer user_data)
-{
- NMVPNConnection *connection = NM_VPN_CONNECTION (user_data);
- NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
-
- if (priv->vpn_state != vpn_state) {
- priv->vpn_state = vpn_state;
- g_signal_emit (connection, signals[VPN_STATE_CHANGED], 0, vpn_state, reason);
- g_object_notify (G_OBJECT (connection), NM_VPN_CONNECTION_VPN_STATE);
- }
-}
-
-/*****************************************************************************/
-
-static void
-nm_vpn_connection_init (NMVPNConnection *connection)
-{
- NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
-
- priv->vpn_state = NM_VPN_CONNECTION_STATE_UNKNOWN;
-}
-
-static void
-register_properties (NMVPNConnection *connection)
-{
- NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
- const NMPropertiesInfo property_info[] = {
- { NM_VPN_CONNECTION_BANNER, &priv->banner },
- { NM_VPN_CONNECTION_VPN_STATE, &priv->vpn_state },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (connection),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_vpn_connection_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_VPN_CONNECTION);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
- G_TYPE_NONE,
- G_TYPE_UINT, G_TYPE_UINT,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->proxy, "VpnStateChanged", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->proxy,
- "VpnStateChanged",
- G_CALLBACK (vpn_state_changed_proxy),
- object,
- NULL);
-
- register_properties (NM_VPN_CONNECTION (object));
-}
-
-static void
-finalize (GObject *object)
-{
- NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
-
- g_free (priv->banner);
- g_object_unref (priv->proxy);
-
- G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMVPNConnection *self = NM_VPN_CONNECTION (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_VPN_STATE:
- g_value_set_uint (value, nm_vpn_connection_get_vpn_state (self));
- break;
- case PROP_BANNER:
- g_value_set_string (value, nm_vpn_connection_get_banner (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (connection_class);
-
- g_type_class_add_private (connection_class, sizeof (NMVPNConnectionPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMVPNConnection:vpn-state:
- *
- * The VPN state of the active VPN connection.
- **/
- g_object_class_install_property
- (object_class, PROP_VPN_STATE,
- g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE, "", "",
- NM_VPN_CONNECTION_STATE_UNKNOWN,
- NM_VPN_CONNECTION_STATE_DISCONNECTED,
- NM_VPN_CONNECTION_STATE_UNKNOWN,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMVPNConnection:banner:
- *
- * The VPN login banner of the active VPN connection.
- **/
- g_object_class_install_property
- (object_class, PROP_BANNER,
- g_param_spec_string (NM_VPN_CONNECTION_BANNER, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /* signals */
- signals[VPN_STATE_CHANGED] =
- g_signal_new ("vpn-state-changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVPNConnectionClass, vpn_state_changed),
- NULL, NULL, NULL,
- G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
-}
diff --git a/libnm-glib/nm-vpn-connection.h b/libnm-glib/nm-vpn-connection.h
deleted file mode 100644
index 0495310f38..0000000000
--- a/libnm-glib/nm-vpn-connection.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2010 Red Hat, Inc.
- */
-
-#ifndef NM_VPN_CONNECTION_H
-#define NM_VPN_CONNECTION_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include "nm-active-connection.h"
-#include "NetworkManagerVPN.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_VPN_CONNECTION (nm_vpn_connection_get_type ())
-#define NM_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnection))
-#define NM_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_CONNECTION, NMVPNConnectionClass))
-#define NM_IS_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_CONNECTION))
-#define NM_IS_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_CONNECTION))
-#define NM_VPN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnectionClass))
-
-#define NM_VPN_CONNECTION_VPN_STATE "vpn-state"
-#define NM_VPN_CONNECTION_BANNER "banner"
-
-typedef struct {
- NMActiveConnection parent;
-} NMVPNConnection;
-
-typedef struct {
- NMActiveConnectionClass parent;
-
- /* Signals */
- void (*vpn_state_changed) (NMVPNConnection *connection,
- NMVPNConnectionState state,
- NMVPNConnectionStateReason reason);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMVPNConnectionClass;
-
-GType nm_vpn_connection_get_type (void);
-
-GObject * nm_vpn_connection_new (DBusGConnection *connection, const char *path);
-
-NMVPNConnectionState nm_vpn_connection_get_vpn_state (NMVPNConnection *vpn);
-const char * nm_vpn_connection_get_banner (NMVPNConnection *vpn);
-
-G_END_DECLS
-
-#endif /* NM_VPN_CONNECTION_H */
diff --git a/libnm-glib/nm-vpn-enum-types.c.template b/libnm-glib/nm-vpn-enum-types.c.template
deleted file mode 100644
index 8aa02ff7e9..0000000000
--- a/libnm-glib/nm-vpn-enum-types.c.template
+++ /dev/null
@@ -1,37 +0,0 @@
-/*** BEGIN file-header ***/
-#include "config.h"
-
-#include "nm-vpn-enum-types.h"
-
-#include "nm-vpn-plugin.h"
-#include "nm-vpn-plugin-ui-interface.h"
-#include "nm-vpn-plugin-utils.h"
-/*** END file-header ***/
-
-/*** BEGIN value-header ***/
-GType
-@enum_name@_get_type (void)
-{
- static volatile gsize g_define_type_id__volatile = 0;
-
- if (g_once_init_enter (&g_define_type_id__volatile))
- {
- static const G@Type@Value values[] = {
-/*** END value-header ***/
-
-/*** BEGIN value-production ***/
- { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
-/*** END value-production ***/
-
-/*** BEGIN value-tail ***/
- { 0, NULL, NULL }
- };
- GType g_define_type_id =
- g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
-
- return g_define_type_id__volatile;
-}
-
-/*** END value-tail ***/
diff --git a/libnm-glib/nm-vpn-enum-types.h.template b/libnm-glib/nm-vpn-enum-types.h.template
deleted file mode 100644
index 47fd96bea6..0000000000
--- a/libnm-glib/nm-vpn-enum-types.h.template
+++ /dev/null
@@ -1,21 +0,0 @@
-/*** BEGIN file-header ***/
-#ifndef __NM_VPN_ENUM_TYPES_H__
-#define __NM_VPN_ENUM_TYPES_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/*** END file-header ***/
-
-/*** BEGIN enumeration-production ***/
-GType @enum_name@_get_type (void) G_GNUC_CONST;
-#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
-
-/*** END enumeration-production ***/
-
-/*** BEGIN file-tail ***/
-G_END_DECLS
-
-#endif /* __NM_VPN_ENUM_TYPES_H__ */
-/*** END file-tail ***/
diff --git a/libnm-glib/nm-vpn-plugin-ui-interface.c b/libnm-glib/nm-vpn-plugin-ui-interface.c
deleted file mode 100644
index ec554e6cad..0000000000
--- a/libnm-glib/nm-vpn-plugin-ui-interface.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2010 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-vpn-plugin-ui-interface.h"
-
-static void
-interface_init (gpointer g_iface)
-{
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- /* Properties */
-
- /**
- * NMVPNPluginUiInterface:name:
- *
- * Short display name of the VPN plugin.
- */
- g_object_interface_install_property (g_iface,
- g_param_spec_string (NM_VPN_PLUGIN_UI_INTERFACE_NAME, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMVPNPluginUiInterface:desc:
- *
- * Longer description of the VPN plugin.
- */
- g_object_interface_install_property (g_iface,
- g_param_spec_string (NM_VPN_PLUGIN_UI_INTERFACE_DESC, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMVPNPluginUiInterface:service:
- *
- * D-Bus service name of the plugin's VPN service.
- */
- g_object_interface_install_property (g_iface,
- g_param_spec_string (NM_VPN_PLUGIN_UI_INTERFACE_SERVICE, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- initialized = TRUE;
-}
-
-GType
-nm_vpn_plugin_ui_interface_get_type (void)
-{
- static GType vpn_plugin_ui_interface_type = 0;
-
- if (!vpn_plugin_ui_interface_type) {
- const GTypeInfo vpn_plugin_ui_interface_info = {
- sizeof (NMVpnPluginUiInterface), /* class_size */
- interface_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- vpn_plugin_ui_interface_type = g_type_register_static (G_TYPE_INTERFACE,
- "NMVpnPluginUiInterface",
- &vpn_plugin_ui_interface_info,
- 0);
-
- g_type_interface_add_prerequisite (vpn_plugin_ui_interface_type, G_TYPE_OBJECT);
- }
-
- return vpn_plugin_ui_interface_type;
-}
-
-NMVpnPluginUiWidgetInterface *
-nm_vpn_plugin_ui_interface_ui_factory (NMVpnPluginUiInterface *iface,
- NMConnection *connection,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), NULL);
-
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->ui_factory (iface, connection, error);
-}
-
-guint32
-nm_vpn_plugin_ui_interface_get_capabilities (NMVpnPluginUiInterface *iface)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), 0);
-
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->get_capabilities (iface);
-}
-
-NMConnection *
-nm_vpn_plugin_ui_interface_import (NMVpnPluginUiInterface *iface,
- const char *path,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), NULL);
-
- if (nm_vpn_plugin_ui_interface_get_capabilities (iface) & NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT) {
- g_return_val_if_fail (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import_from_file != NULL, NULL);
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import_from_file (iface, path, error);
- }
- return NULL;
-}
-
-gboolean
-nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
- const char *path,
- NMConnection *connection,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), FALSE);
-
- if (nm_vpn_plugin_ui_interface_get_capabilities (iface) & NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT) {
- g_return_val_if_fail (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export_to_file != NULL, FALSE);
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export_to_file (iface, path, connection, error);
- }
- return FALSE;
-}
-
-char *
-nm_vpn_plugin_ui_interface_get_suggested_name (NMVpnPluginUiInterface *iface,
- NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), NULL);
-
- if (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->get_suggested_name)
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->get_suggested_name (iface, connection);
- return NULL;
-}
-
-gboolean
-nm_vpn_plugin_ui_interface_delete_connection (NMVpnPluginUiInterface *iface,
- NMConnection *connection,
- GError **error)
-{
- /* Deprecated and no longer used */
- return TRUE;
-}
-
-static void
-widget_interface_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- /* Signals */
- g_signal_new ("changed",
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVpnPluginUiWidgetInterface, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- initialized = TRUE;
-}
-
-GType
-nm_vpn_plugin_ui_widget_interface_get_type (void)
-{
- static GType vpn_plugin_ui_widget_interface_type = 0;
-
- if (!vpn_plugin_ui_widget_interface_type) {
- const GTypeInfo vpn_plugin_ui_widget_interface_info = {
- sizeof (NMVpnPluginUiWidgetInterface), /* class_size */
- widget_interface_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- vpn_plugin_ui_widget_interface_type = g_type_register_static (G_TYPE_INTERFACE,
- "NMVpnPluginUiWidgetInterface",
- &vpn_plugin_ui_widget_interface_info,
- 0);
-
- g_type_interface_add_prerequisite (vpn_plugin_ui_widget_interface_type, G_TYPE_OBJECT);
- }
-
- return vpn_plugin_ui_widget_interface_type;
-}
-
-GObject *
-nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE (iface), NULL);
-
- return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->get_widget (iface);
-}
-
-gboolean
-nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE (iface), FALSE);
-
- if (error)
- g_return_val_if_fail (*error == NULL, FALSE);
-
- return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->update_connection (iface, connection, error);
-}
-
-gboolean
-nm_vpn_plugin_ui_widget_interface_save_secrets (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error)
-{
- /* Deprecated and no longer used */
- return TRUE;
-}
diff --git a/libnm-glib/nm-vpn-plugin-ui-interface.h b/libnm-glib/nm-vpn-plugin-ui-interface.h
deleted file mode 100644
index 7d870128cd..0000000000
--- a/libnm-glib/nm-vpn-plugin-ui-interface.h
+++ /dev/null
@@ -1,271 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2010 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#ifndef NM_VPN_PLUGIN_UI_INTERFACE_H
-#define NM_VPN_PLUGIN_UI_INTERFACE_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include "nm-connection.h"
-
-G_BEGIN_DECLS
-
-typedef struct _NMVpnPluginUiInterface NMVpnPluginUiInterface;
-typedef struct _NMVpnPluginUiWidgetInterface NMVpnPluginUiWidgetInterface;
-
-/* Plugin's factory function that returns a GObject that implements
- * NMVpnPluginUiInterface.
- */
-typedef NMVpnPluginUiInterface * (*NMVpnPluginUiFactory) (GError **error);
-NMVpnPluginUiInterface *nm_vpn_plugin_ui_factory (GError **error);
-
-/*****************************************************************************/
-/* Plugin interface */
-/*****************************************************************************/
-
-#define NM_TYPE_VPN_PLUGIN_UI_INTERFACE (nm_vpn_plugin_ui_interface_get_type ())
-#define NM_VPN_PLUGIN_UI_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE, NMVpnPluginUiInterface))
-#define NM_IS_VPN_PLUGIN_UI_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE))
-#define NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE, NMVpnPluginUiInterface))
-
-/**
- * NMVpnPluginUiCapability:
- * @NM_VPN_PLUGIN_UI_CAPABILITY_NONE: unknown or no capability
- * @NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT: the plugin can import new connections
- * @NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT: the plugin can export connections
- * @NM_VPN_PLUGIN_UI_CAPABILITY_IPV6: the plugin supports IPv6 addressing
- *
- * Flags that indicate to UI programs certain capabilities of the plugin.
- **/
-typedef enum /*< flags >*/ {
- NM_VPN_PLUGIN_UI_CAPABILITY_NONE = 0x00,
- NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT = 0x01,
- NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT = 0x02,
- NM_VPN_PLUGIN_UI_CAPABILITY_IPV6 = 0x04
-} NMVpnPluginUiCapability;
-
-/* Short display name of the VPN plugin */
-#define NM_VPN_PLUGIN_UI_INTERFACE_NAME "name"
-
-/* Longer description of the VPN plugin */
-#define NM_VPN_PLUGIN_UI_INTERFACE_DESC "desc"
-
-/* D-Bus service name of the plugin's VPN service */
-#define NM_VPN_PLUGIN_UI_INTERFACE_SERVICE "service"
-
-/**
- * NMVpnPluginUiInterfaceProp:
- * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME: the VPN plugin's name
- * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC: description of the VPN plugin and what
- * VPN services it supports
- * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE: the D-Bus service name used by the
- * plugin's VPN service daemon
- *
- * #GObject property numbers that plugins should override to provide certain
- * information to UI programs.
- **/
-typedef enum {
- /* private */
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST = 0x1000,
-
- /* public */
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME = NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST,
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC,
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE
-} NMVpnPluginUiInterfaceProp;
-
-struct _NMVpnPluginUiInterface {
- GTypeInterface g_iface;
-
- /* Plugin's factory function that returns a GObject that implements
- * NMVpnPluginUiWidgetInterface, pre-filled with values from 'connection'
- * if non-NULL.
- */
- NMVpnPluginUiWidgetInterface * (*ui_factory) (NMVpnPluginUiInterface *iface,
- NMConnection *connection,
- GError **error);
-
- /* Plugin's capabiltity function that returns a bitmask of capabilities
- * described by NM_VPN_PLUGIN_UI_CAPABILITY_* defines.
- */
- guint32 (*get_capabilities) (NMVpnPluginUiInterface *iface);
-
- /* Try to import a connection from the specified path. On success, return a
- * partial NMConnection object. On error, return NULL and set 'error' with
- * additional information. Note that 'error' can be NULL, in which case no
- * additional error information should be provided.
- */
- NMConnection * (*import_from_file) (NMVpnPluginUiInterface *iface,
- const char *path,
- GError **error);
-
- /* Export the given connection to the specified path. Return TRUE on success.
- * On error, return FALSE and set 'error' with additional error information.
- * Note that 'error' can be NULL, in which case no additional error information
- * should be provided.
- */
- gboolean (*export_to_file) (NMVpnPluginUiInterface *iface,
- const char *path,
- NMConnection *connection,
- GError **error);
-
- /* For a given connection, return a suggested file name. Returned value should
- * be NULL or a suggested file name allocated via g_malloc/g_new/etc to be freed
- * by the caller.
- */
- char * (*get_suggested_name) (NMVpnPluginUiInterface *iface, NMConnection *connection);
-
- /* Deprecated and no longer used */
- gboolean (*delete_connection) (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-};
-
-GType nm_vpn_plugin_ui_interface_get_type (void);
-
-NMVpnPluginUiWidgetInterface *nm_vpn_plugin_ui_interface_ui_factory (NMVpnPluginUiInterface *iface,
- NMConnection *connection,
- GError **error);
-
-guint32 nm_vpn_plugin_ui_interface_get_capabilities (NMVpnPluginUiInterface *iface);
-
-NMConnection *nm_vpn_plugin_ui_interface_import (NMVpnPluginUiInterface *iface,
- const char *path,
- GError **error);
-
-gboolean nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
- const char *path,
- NMConnection *connection,
- GError **error);
-
-char *nm_vpn_plugin_ui_interface_get_suggested_name (NMVpnPluginUiInterface *iface,
- NMConnection *connection);
-
-/* Deprecated and no longer used */
-NM_DEPRECATED_IN_0_9_10
-gboolean nm_vpn_plugin_ui_interface_delete_connection (NMVpnPluginUiInterface *iface,
- NMConnection *connection,
- GError **error);
-
-/*****************************************************************************/
-/* UI widget interface */
-/*****************************************************************************/
-
-#define NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE (nm_vpn_plugin_ui_widget_interface_get_type ())
-#define NM_VPN_PLUGIN_UI_WIDGET_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, NMVpnPluginUiWidgetInterface))
-#define NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE))
-#define NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, NMVpnPluginUiWidgetInterface))
-
-struct _NMVpnPluginUiWidgetInterface {
- GTypeInterface g_iface;
-
- /* Return the GtkWidget for the VPN's UI */
- GObject * (*get_widget) (NMVpnPluginUiWidgetInterface *iface);
-
- /* Called to save the user-entered options to the connection object. Should
- * return FALSE and set 'error' if the current options are invalid. 'error'
- * should contain enough information for the plugin to determine which UI
- * widget is invalid at a later point in time. For example, creating unique
- * error codes for what error occurred and populating the message field
- * of 'error' with the name of the invalid property.
- */
- gboolean (*update_connection) (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error);
-
- /* Deprecated and no longer used */
- gboolean (*save_secrets) (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error);
-
- /* Emitted when the value of a UI widget changes. May trigger a validity
- * check via update_connection() to write values to the connection */
- void (*changed) (NMVpnPluginUiWidgetInterface *iface);
-};
-
-GType nm_vpn_plugin_ui_widget_interface_get_type (void);
-
-GObject * nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface);
-
-gboolean nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error);
-
-/* Deprecated and no longer used */
-NM_DEPRECATED_IN_0_9_10
-gboolean nm_vpn_plugin_ui_widget_interface_save_secrets (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error);
-
-#ifdef NM_VPN_LIBNM_COMPAT
-#define nm_vpn_editor_plugin_factory nm_vpn_plugin_ui_factory
-
-#define NM_TYPE_VPN_EDITOR_PLUGIN NM_TYPE_VPN_PLUGIN_UI_INTERFACE
-#define NM_VPN_EDITOR_PLUGIN(obj) NM_VPN_PLUGIN_UI_INTERFACE(obj)
-#define NM_IS_VPN_EDITOR_PLUGIN(obj) NM_IS_VPN_PLUGIN_UI_INTERFACE(obj)
-#define NM_VPN_EDITOR_PLUGIN_GET_INTERFACE(obj) NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE(obj)
-
-#define NMVpnEditorPluginCapability NMVpnPluginUiCapability
-#define NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE NM_VPN_PLUGIN_UI_CAPABILITY_NONE
-#define NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT
-#define NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT
-#define NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6 NM_VPN_PLUGIN_UI_CAPABILITY_IPV6
-
-#define NM_VPN_EDITOR_PLUGIN_NAME NM_VPN_PLUGIN_UI_INTERFACE_NAME
-#define NM_VPN_EDITOR_PLUGIN_DESCRIPTION NM_VPN_PLUGIN_UI_INTERFACE_DESC
-#define NM_VPN_EDITOR_PLUGIN_SERVICE NM_VPN_PLUGIN_UI_INTERFACE_SERVICE
-
-#define NMVpnEditorPlugin NMVpnPluginUiInterface
-#define NMVpnEditorPluginInterface NMVpnPluginUiInterface
-
-#define get_editor ui_factory
-#define get_suggested_filename get_suggested_name
-
-#define nm_vpn_editor_plugin_get_type nm_vpn_plugin_ui_interface_get_type
-#define nm_vpn_editor_plugin_get_editor nm_vpn_plugin_ui_interface_ui_factory
-#define nm_vpn_editor_plugin_get_capabilities nm_vpn_plugin_ui_interface_get_capabilities
-#define nm_vpn_editor_plugin_import nm_vpn_plugin_ui_interface_import
-#define nm_vpn_editor_plugin_export nm_vpn_plugin_ui_interface_export
-#define nm_vpn_editor_plugin_get_suggested_filename nm_vpn_plugin_ui_interface_get_suggested_name
-
-#define NM_TYPE_VPN_EDITOR NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE
-#define NM_VPN_EDITOR(obj) NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (obj)
-#define NM_IS_VPN_EDITOR(obj) NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE (obj)
-#define NM_VPN_EDITOR_GET_INTERFACE(obj) NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (obj)
-
-#define NMVpnEditor NMVpnPluginUiWidgetInterface
-#define NMVpnEditorInterface NMVpnPluginUiWidgetInterface
-
-#define nm_vpn_editor_get_type nm_vpn_plugin_ui_widget_interface_get_type
-#define nm_vpn_editor_get_widget nm_vpn_plugin_ui_widget_interface_get_widget
-#define nm_vpn_editor_update_connection nm_vpn_plugin_ui_widget_interface_update_connection
-
-#endif /* NM_VPN_LIBNM_COMPAT */
-
-G_END_DECLS
-
-#endif /* NM_VPN_PLUGIN_UI_INTERFACE_H */
diff --git a/libnm-glib/nm-vpn-plugin-utils.c b/libnm-glib/nm-vpn-plugin-utils.c
deleted file mode 100644
index 30949d1973..0000000000
--- a/libnm-glib/nm-vpn-plugin-utils.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "nm-vpn-plugin-utils.h"
-#include "nm-vpn-plugin.h"
-#include "nm-setting-private.h"
-#include "nm-dbus-glib-types.h"
-
-#define DATA_KEY_TAG "DATA_KEY="
-#define DATA_VAL_TAG "DATA_VAL="
-#define SECRET_KEY_TAG "SECRET_KEY="
-#define SECRET_VAL_TAG "SECRET_VAL="
-
-static void
-free_secret (gpointer data)
-{
- char *secret = data;
-
- memset (secret, 0, strlen (secret));
- g_free (secret);
-}
-
-/**
- * nm_vpn_plugin_utils_read_vpn_details:
- * @fd: file descriptor to read from, usually stdin (0)
- * @out_data: (out) (transfer full): on successful return, a hash table
- * (mapping char*:char*) containing the key/value pairs of VPN data items
- * @out_secrets: (out) (transfer full): on successful return, a hash table
- * (mapping char*:char*) containing the key/value pairsof VPN secrets
- *
- * Parses key/value pairs from a file descriptor (normally stdin) passed by
- * an applet when the applet calls the authentication dialog of the VPN plugin.
- *
- * Returns: %TRUE if reading values was successful, %FALSE if not
- **/
-gboolean
-nm_vpn_plugin_utils_read_vpn_details (int fd,
- GHashTable **out_data,
- GHashTable **out_secrets)
-{
- GHashTable *data, *secrets;
- gboolean success = FALSE;
- char *key = NULL, *val = NULL;
- GString *line;
- char c;
-
- if (out_data)
- g_return_val_if_fail (*out_data == NULL, FALSE);
- if (out_secrets)
- g_return_val_if_fail (*out_secrets == NULL, FALSE);
-
- data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret);
-
- line = g_string_new (NULL);
-
- /* Read stdin for data and secret items until we get a DONE */
- while (1) {
- ssize_t nr;
- GHashTable *hash = NULL;
-
- nr = read (fd, &c, 1);
- if (nr == -1) {
- if (errno == EAGAIN) {
- g_usleep (100);
- continue;
- }
- break;
- }
-
- if (c != '\n') {
- g_string_append_c (line, c);
- continue;
- }
-
- /* Check for the finish marker */
- if (strcmp (line->str, "DONE") == 0)
- break;
-
- /* Otherwise it's a data/secret item */
- if (strncmp (line->str, DATA_KEY_TAG, strlen (DATA_KEY_TAG)) == 0) {
- hash = data;
- key = g_strdup (line->str + strlen (DATA_KEY_TAG));
- } else if (strncmp (line->str, DATA_VAL_TAG, strlen (DATA_VAL_TAG)) == 0) {
- hash = data;
- val = g_strdup (line->str + strlen (DATA_VAL_TAG));
- } else if (strncmp (line->str, SECRET_KEY_TAG, strlen (SECRET_KEY_TAG)) == 0) {
- hash = secrets;
- key = g_strdup (line->str + strlen (SECRET_KEY_TAG));
- } else if (strncmp (line->str, SECRET_VAL_TAG, strlen (SECRET_VAL_TAG)) == 0) {
- hash = secrets;
- val = g_strdup (line->str + strlen (SECRET_VAL_TAG));
- }
- g_string_truncate (line, 0);
-
- if (key && val && hash) {
- g_hash_table_insert (hash, key, val);
- key = NULL;
- val = NULL;
- success = TRUE; /* Got at least one value */
- }
- }
-
- if (success) {
- if (out_data)
- *out_data = data;
- else
- g_hash_table_destroy (data);
-
- if (out_secrets)
- *out_secrets = secrets;
- else
- g_hash_table_destroy (secrets);
- } else {
- g_hash_table_destroy (data);
- g_hash_table_destroy (secrets);
- }
-
- g_string_free (line, TRUE);
- return success;
-}
-
-/**
- * nm_vpn_plugin_utils_get_secret_flags:
- * @data: hash table containing VPN key/value pair data items
- * @secret_name: VPN secret key name for which to retrieve flags for
- * @out_flags: (out): on success, the flags associated with @secret_name
- *
- * Given a VPN secret key name, attempts to find the corresponding flags data
- * item in @data. If found, converts the flags data item to
- * #NMSettingSecretFlags and returns it.
- *
- * Returns: %TRUE if the flag data item was found and successfully converted
- * to flags, %FALSE if not
- **/
-gboolean
-nm_vpn_plugin_utils_get_secret_flags (GHashTable *data,
- const char *secret_name,
- NMSettingSecretFlags *out_flags)
-{
- char *flag_name;
- const char *val;
- unsigned long tmp;
- gboolean success = FALSE;
-
- g_return_val_if_fail (data != NULL, FALSE);
- g_return_val_if_fail (secret_name != NULL, FALSE);
- g_return_val_if_fail (out_flags != NULL, FALSE);
- g_return_val_if_fail (*out_flags == NM_SETTING_SECRET_FLAG_NONE, FALSE);
-
- flag_name = g_strdup_printf ("%s-flags", secret_name);
-
- /* Try new flags value first */
- val = g_hash_table_lookup (data, flag_name);
- if (val) {
- errno = 0;
- tmp = strtoul (val, NULL, 10);
- if (errno == 0 && tmp <= NM_SETTING_SECRET_FLAGS_ALL) {
- *out_flags = (NMSettingSecretFlags) tmp;
- success = TRUE;
- }
- }
-
- g_free (flag_name);
- return success;
-}
diff --git a/libnm-glib/nm-vpn-plugin-utils.h b/libnm-glib/nm-vpn-plugin-utils.h
deleted file mode 100644
index dfb621cad4..0000000000
--- a/libnm-glib/nm-vpn-plugin-utils.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 Red Hat, Inc.
- */
-
-#ifndef NM_VPN_PLUGIN_UTILS_H
-#define NM_VPN_PLUGIN_UTILS_H
-
-#include <glib.h>
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-gboolean nm_vpn_plugin_utils_read_vpn_details (int fd,
- GHashTable **out_data,
- GHashTable **out_secrets);
-
-gboolean nm_vpn_plugin_utils_get_secret_flags (GHashTable *data,
- const char *secret_name,
- NMSettingSecretFlags *out_flags);
-
-G_END_DECLS
-
-#endif /* NM_VPN_PLUGIN_UTILS_H */
diff --git a/libnm-glib/nm-vpn-plugin.c b/libnm-glib/nm-vpn-plugin.c
deleted file mode 100644
index c7c68a8dd4..0000000000
--- a/libnm-glib/nm-vpn-plugin.c
+++ /dev/null
@@ -1,1041 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2008 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-vpn-plugin.h"
-
-#include <signal.h>
-
-#include "nm-vpn-enum-types.h"
-#include "nm-utils.h"
-#include "nm-connection.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-static gboolean impl_vpn_plugin_connect (NMVPNPlugin *plugin,
- GHashTable *connection,
- GError **error);
-
-static gboolean impl_vpn_plugin_connect_interactive (NMVPNPlugin *plugin,
- GHashTable *connection,
- GHashTable *details,
- GError **error);
-
-static gboolean impl_vpn_plugin_need_secrets (NMVPNPlugin *plugin,
- GHashTable *connection,
- char **service_name,
- GError **err);
-
-static gboolean impl_vpn_plugin_new_secrets (NMVPNPlugin *plugin,
- GHashTable *connection,
- GError **err);
-
-static gboolean impl_vpn_plugin_disconnect (NMVPNPlugin *plugin,
- GError **err);
-
-static gboolean impl_vpn_plugin_set_config (NMVPNPlugin *plugin,
- GHashTable *config,
- GError **err);
-
-static gboolean impl_vpn_plugin_set_ip4_config (NMVPNPlugin *plugin,
- GHashTable *config,
- GError **err);
-
-static gboolean impl_vpn_plugin_set_ip6_config (NMVPNPlugin *plugin,
- GHashTable *config,
- GError **err);
-
-static gboolean impl_vpn_plugin_set_failure (NMVPNPlugin *plugin,
- char *reason,
- GError **err);
-
-#include "nm-vpn-plugin-glue.h"
-
-#define NM_VPN_PLUGIN_QUIT_TIMER 180
-
-G_DEFINE_ABSTRACT_TYPE (NMVPNPlugin, nm_vpn_plugin, G_TYPE_OBJECT)
-
-typedef struct {
- NMVPNServiceState state;
-
- /* DBUS-y stuff */
- DBusGConnection *connection;
- char *dbus_service_name;
-
- /* Temporary stuff */
- guint connect_timer;
- guint quit_timer;
- guint fail_stop_id;
- gboolean interactive;
-
- gboolean got_config;
- gboolean has_ip4, got_ip4;
- gboolean has_ip6, got_ip6;
-
- /* Config stuff copied from config to ip4config */
- GValue banner, tundev, gateway, mtu;
-} NMVPNPluginPrivate;
-
-#define NM_VPN_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_VPN_PLUGIN, NMVPNPluginPrivate))
-
-enum {
- STATE_CHANGED,
- CONFIG,
- IP4_CONFIG,
- IP6_CONFIG,
- LOGIN_BANNER,
- FAILURE,
- QUIT,
- SECRETS_REQUIRED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-enum {
- PROP_0,
- PROP_DBUS_SERVICE_NAME,
- PROP_STATE,
-
- LAST_PROP
-};
-
-static GSList *active_plugins = NULL;
-
-GQuark
-nm_vpn_plugin_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (!quark)
- quark = g_quark_from_static_string ("nm_vpn_plugin_error");
-
- return quark;
-}
-
-static void
-nm_vpn_plugin_set_connection (NMVPNPlugin *plugin,
- DBusGConnection *connection)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
-
- if (priv->connection)
- dbus_g_connection_unref (priv->connection);
-
- priv->connection = connection;
-}
-
-DBusGConnection *
-nm_vpn_plugin_get_connection (NMVPNPlugin *plugin)
-{
- DBusGConnection *connection;
-
- g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), NULL);
-
- connection = NM_VPN_PLUGIN_GET_PRIVATE (plugin)->connection;
-
- if (connection)
- dbus_g_connection_ref (connection);
-
- return connection;
-}
-
-NMVPNServiceState
-nm_vpn_plugin_get_state (NMVPNPlugin *plugin)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), NM_VPN_SERVICE_STATE_UNKNOWN);
-
- return NM_VPN_PLUGIN_GET_PRIVATE (plugin)->state;
-}
-
-void
-nm_vpn_plugin_set_state (NMVPNPlugin *plugin,
- NMVPNServiceState state)
-{
- NMVPNPluginPrivate *priv;
-
- g_return_if_fail (NM_IS_VPN_PLUGIN (plugin));
-
- priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
- if (priv->state != state) {
- priv->state = state;
- g_signal_emit (plugin, signals[STATE_CHANGED], 0, state);
- }
-}
-
-void
-nm_vpn_plugin_set_login_banner (NMVPNPlugin *plugin,
- const char *banner)
-{
- g_return_if_fail (NM_IS_VPN_PLUGIN (plugin));
- g_return_if_fail (banner != NULL);
-
- g_signal_emit (plugin, signals[LOGIN_BANNER], 0, banner);
-}
-
-void
-nm_vpn_plugin_failure (NMVPNPlugin *plugin,
- NMVPNPluginFailure reason)
-{
- g_return_if_fail (NM_IS_VPN_PLUGIN (plugin));
-
- g_signal_emit (plugin, signals[FAILURE], 0, reason);
-}
-
-gboolean
-nm_vpn_plugin_disconnect (NMVPNPlugin *plugin, GError **err)
-{
- gboolean ret = FALSE;
- NMVPNServiceState state;
-
- g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE);
-
- state = nm_vpn_plugin_get_state (plugin);
- switch (state) {
- case NM_VPN_SERVICE_STATE_STOPPING:
- g_set_error (err,
- NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS,
- "%s",
- "Could not process the request because the VPN connection is already being stopped.");
- break;
- case NM_VPN_SERVICE_STATE_STOPPED:
- g_set_error (err,
- NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED,
- "%s",
- "Could not process the request because no VPN connection was active.");
- break;
- case NM_VPN_SERVICE_STATE_STARTING:
- case NM_VPN_SERVICE_STATE_STARTED:
- nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPING);
- ret = NM_VPN_PLUGIN_GET_CLASS (plugin)->disconnect (plugin, err);
- nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED);
- break;
- case NM_VPN_SERVICE_STATE_INIT:
- ret = TRUE;
- break;
-
- default:
- g_warning ("Unhandled VPN service state %d", state);
- g_assert_not_reached ();
- break;
- }
-
- return ret;
-}
-
-static void
-nm_vpn_plugin_emit_quit (NMVPNPlugin *plugin)
-{
- g_signal_emit (plugin, signals[QUIT], 0);
-}
-
-static gboolean
-connect_timer_expired (gpointer data)
-{
- NMVPNPlugin *plugin = NM_VPN_PLUGIN (data);
- GError *err = NULL;
-
- NM_VPN_PLUGIN_GET_PRIVATE (plugin)->connect_timer = 0;
- g_message ("Connect timer expired, disconnecting.");
- nm_vpn_plugin_disconnect (plugin, &err);
- if (err) {
- g_warning ("Disconnect failed: %s", err->message);
- g_error_free (err);
- }
-
- return G_SOURCE_REMOVE;
-}
-
-static gboolean
-quit_timer_expired (gpointer data)
-{
- NMVPNPlugin *self = NM_VPN_PLUGIN (data);
-
- NM_VPN_PLUGIN_GET_PRIVATE (self)->quit_timer = 0;
- nm_vpn_plugin_emit_quit (self);
- return G_SOURCE_REMOVE;
-}
-
-static void
-schedule_quit_timer (NMVPNPlugin *self)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (self);
-
- nm_clear_g_source (&priv->quit_timer);
- priv->quit_timer = g_timeout_add_seconds (NM_VPN_PLUGIN_QUIT_TIMER,
- quit_timer_expired,
- self);
-}
-
-static gboolean
-fail_stop (gpointer data)
-{
- NMVPNPlugin *self = NM_VPN_PLUGIN (data);
-
- NM_VPN_PLUGIN_GET_PRIVATE (self)->fail_stop_id = 0;
- nm_vpn_plugin_set_state (self, NM_VPN_SERVICE_STATE_STOPPED);
- return G_SOURCE_REMOVE;
-}
-
-static void
-schedule_fail_stop (NMVPNPlugin *plugin, guint timeout_secs)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
-
- nm_clear_g_source (&priv->fail_stop_id);
- if (timeout_secs)
- priv->fail_stop_id = g_timeout_add_seconds (timeout_secs, fail_stop, plugin);
- else
- priv->fail_stop_id = g_idle_add (fail_stop, plugin);
-}
-
-static void
-_g_value_set (GValue *dst, GValue *src)
-{
- if (src) {
- GType type = G_VALUE_TYPE (src);
-
- if (G_IS_VALUE (dst))
- g_value_unset (dst);
- g_value_init (dst, type);
- g_value_copy (src, dst);
- } else if (G_IS_VALUE (dst))
- g_value_unset (dst);
-}
-
-void
-nm_vpn_plugin_set_config (NMVPNPlugin *plugin,
- GHashTable *config)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
- GValue *val;
-
- g_return_if_fail (NM_IS_VPN_PLUGIN (plugin));
- g_return_if_fail (config != NULL);
-
- priv->got_config = TRUE;
-
- val = g_hash_table_lookup (config, NM_VPN_PLUGIN_CONFIG_HAS_IP4);
- if (val && g_value_get_boolean (val))
- priv->has_ip4 = TRUE;
- val = g_hash_table_lookup (config, NM_VPN_PLUGIN_CONFIG_HAS_IP6);
- if (val && g_value_get_boolean (val))
- priv->has_ip6 = TRUE;
-
- /* Record the items that need to also be inserted into the
- * ip4config, for compatibility with older daemons.
- */
- _g_value_set (&priv->banner, g_hash_table_lookup (config, NM_VPN_PLUGIN_CONFIG_BANNER));
- _g_value_set (&priv->tundev, g_hash_table_lookup (config, NM_VPN_PLUGIN_CONFIG_TUNDEV));
- _g_value_set (&priv->gateway, g_hash_table_lookup (config, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY));
- _g_value_set (&priv->mtu, g_hash_table_lookup (config, NM_VPN_PLUGIN_CONFIG_MTU));
-
- g_signal_emit (plugin, signals[CONFIG], 0, config);
-}
-
-void
-nm_vpn_plugin_set_ip4_config (NMVPNPlugin *plugin,
- GHashTable *ip4_config)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
- GHashTable *combined_config;
- GHashTableIter iter;
- gpointer key, value;
-
- g_return_if_fail (NM_IS_VPN_PLUGIN (plugin));
- g_return_if_fail (ip4_config != NULL);
-
- priv->got_ip4 = TRUE;
-
- /* Old plugins won't send the "config" signal and thus can't send
- * NM_VPN_PLUGIN_CONFIG_HAS_IP4 either. But since they don't support IPv6,
- * we can safely assume that, if we don't receive a "config" signal but do
- * receive an "ip4-config" signal, the old plugin supports IPv4.
- */
- if (!priv->got_config)
- priv->has_ip4 = TRUE;
-
- /* Older NetworkManager daemons expect all config info to be in
- * the ip4 config, so they won't even notice the "config" signal
- * being emitted. So just copy all of that data into the ip4
- * config too.
- */
- combined_config = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_iter_init (&iter, ip4_config);
- while (g_hash_table_iter_next (&iter, &key, &value))
- g_hash_table_insert (combined_config, key, value);
-
- if (G_VALUE_TYPE (&priv->banner) != G_TYPE_INVALID)
- g_hash_table_insert (combined_config, NM_VPN_PLUGIN_IP4_CONFIG_BANNER, &priv->banner);
- if (G_VALUE_TYPE (&priv->tundev) != G_TYPE_INVALID)
- g_hash_table_insert (combined_config, NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, &priv->tundev);
- if (G_VALUE_TYPE (&priv->gateway) != G_TYPE_INVALID)
- g_hash_table_insert (combined_config, NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY, &priv->gateway);
- if (G_VALUE_TYPE (&priv->mtu) != G_TYPE_INVALID)
- g_hash_table_insert (combined_config, NM_VPN_PLUGIN_IP4_CONFIG_MTU, &priv->mtu);
-
- g_signal_emit (plugin, signals[IP4_CONFIG], 0, combined_config);
- g_hash_table_destroy (combined_config);
-
- if ( priv->has_ip4 == priv->got_ip4
- && priv->has_ip6 == priv->got_ip6)
- nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STARTED);
-}
-
-void
-nm_vpn_plugin_set_ip6_config (NMVPNPlugin *plugin,
- GHashTable *ip6_config)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
-
- g_return_if_fail (NM_IS_VPN_PLUGIN (plugin));
- g_return_if_fail (ip6_config != NULL);
-
- priv->got_ip6 = TRUE;
- g_signal_emit (plugin, signals[IP6_CONFIG], 0, ip6_config);
-
- if ( priv->has_ip4 == priv->got_ip4
- && priv->has_ip6 == priv->got_ip6)
- nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STARTED);
-}
-
-static void
-connect_timer_start (NMVPNPlugin *plugin)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
-
- nm_clear_g_source (&priv->connect_timer);
- priv->connect_timer = g_timeout_add_seconds (60, connect_timer_expired, plugin);
-}
-
-static gboolean
-_connect_generic (NMVPNPlugin *plugin,
- GHashTable *properties,
- GHashTable *details,
- GError **error)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
- NMVPNPluginClass *vpn_class = NM_VPN_PLUGIN_GET_CLASS (plugin);
- NMConnection *connection;
- gboolean success = FALSE;
- GError *local = NULL;
- guint fail_stop_timeout = 0;
-
- if (priv->state != NM_VPN_SERVICE_STATE_STOPPED &&
- priv->state != NM_VPN_SERVICE_STATE_INIT) {
- g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_WRONG_STATE,
- "Could not start connection: wrong plugin state %d",
- priv->state);
- return FALSE;
- }
-
- connection = _nm_connection_new_from_hash (properties);
-
- priv->interactive = FALSE;
- if (details && !vpn_class->connect_interactive) {
- g_set_error_literal (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED,
- "Plugin does not implement ConnectInteractive()");
- return FALSE;
- }
-
- nm_clear_g_source (&priv->fail_stop_id);
-
- if (details) {
- priv->interactive = TRUE;
- success = vpn_class->connect_interactive (plugin, connection, details, &local);
- if (g_error_matches (local, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED)) {
- /* Give NetworkManager a bit of time to fall back to Connect() */
- fail_stop_timeout = 5;
- }
- g_propagate_error (error, local);
- } else
- success = vpn_class->connect (plugin, connection, error);
-
- if (success) {
- nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STARTING);
-
- /* Add a timer to make sure we do not wait indefinitely for the successful connect. */
- connect_timer_start (plugin);
- } else {
- /* Stop the plugin from an idle handler so that the Connect
- * method return gets sent before the STOP StateChanged signal.
- */
- schedule_fail_stop (plugin, fail_stop_timeout);
- }
-
- g_object_unref (connection);
- return success;
-}
-
-static gboolean
-impl_vpn_plugin_connect (NMVPNPlugin *plugin,
- GHashTable *connection,
- GError **error)
-{
- return _connect_generic (plugin, connection, NULL, error);
-}
-
-static gboolean
-impl_vpn_plugin_connect_interactive (NMVPNPlugin *plugin,
- GHashTable *connection,
- GHashTable *details,
- GError **error)
-{
- return _connect_generic (plugin, connection, details, error);
-}
-
-/*****************************************************************************/
-
-static gboolean
-impl_vpn_plugin_need_secrets (NMVPNPlugin *plugin,
- GHashTable *properties,
- char **setting_name,
- GError **err)
-{
- gboolean ret = FALSE;
- NMConnection *connection;
- char *sn = NULL;
- GError *ns_err = NULL;
- gboolean needed = FALSE;
-
- g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE);
- g_return_val_if_fail (properties != NULL, FALSE);
-
- connection = _nm_connection_new_from_hash (properties);
-
- if (!NM_VPN_PLUGIN_GET_CLASS (plugin)->need_secrets) {
- *setting_name = "";
- ret = TRUE;
- goto out;
- }
-
- needed = NM_VPN_PLUGIN_GET_CLASS (plugin)->need_secrets (plugin, connection, &sn, &ns_err);
- if (ns_err) {
- *err = g_error_copy (ns_err);
- g_error_free (ns_err);
- goto out;
- }
-
- ret = TRUE;
- if (needed) {
- /* Push back the quit timer so the VPN plugin doesn't quit in the
- * middle of asking the user for secrets.
- */
- schedule_quit_timer (plugin);
-
- g_assert (sn);
- *setting_name = g_strdup (sn);
- } else {
- /* No secrets required */
- *setting_name = g_strdup ("");
- }
-
-out:
- return ret;
-}
-
-static gboolean
-impl_vpn_plugin_new_secrets (NMVPNPlugin *plugin,
- GHashTable *properties,
- GError **error)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
- NMConnection *connection;
- gboolean success;
-
- if (priv->state != NM_VPN_SERVICE_STATE_STARTING) {
- g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_WRONG_STATE,
- "Could not accept new secrets: wrong plugin state %d",
- priv->state);
- return FALSE;
- }
-
- connection = _nm_connection_new_from_hash (properties);
-
- if (!NM_VPN_PLUGIN_GET_CLASS (plugin)->new_secrets) {
- g_set_error_literal (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED,
- "Could not accept new secrets: plugin cannot process interactive secrets");
- g_object_unref (connection);
- return FALSE;
- }
-
- success = NM_VPN_PLUGIN_GET_CLASS (plugin)->new_secrets (plugin, connection, error);
- if (success) {
- /* Add a timer to make sure we do not wait indefinitely for the successful connect. */
- connect_timer_start (plugin);
- } else {
- /* Stop the plugin from and idle handler so that the NewSecrets
- * method return gets sent before the STOP StateChanged signal.
- */
- schedule_fail_stop (plugin, 0);
- }
-
- g_object_unref (connection);
- return success;
-}
-
-/**
- * nm_vpn_plugin_secrets_required:
- * @plugin: the #NMVPNPlugin
- * @message: an information message about why secrets are required, if any
- * @hints: VPN specific secret names for required new secrets
- *
- * Called by VPN plugin implementations to signal to NetworkManager that secrets
- * are required during the connection process. This signal may be used to
- * request new secrets when the secrets originally provided by NetworkManager
- * are insufficient, or the VPN process indicates that it needs additional
- * information to complete the request.
- *
- * Since: 0.9.10
- */
-void
-nm_vpn_plugin_secrets_required (NMVPNPlugin *plugin,
- const char *message,
- const char **hints)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
-
- /* Plugin must be able to accept the new secrets if it calls this method */
- g_return_if_fail (NM_VPN_PLUGIN_GET_CLASS (plugin)->new_secrets);
-
- /* Plugin cannot call this method if NetworkManager didn't originally call
- * ConnectInteractive().
- */
- g_return_if_fail (priv->interactive == TRUE);
-
- /* Cancel the connect timer since secrets might take a while. It'll
- * get restarted when the secrets come back via NewSecrets().
- */
- nm_clear_g_source (&priv->connect_timer);
-
- g_signal_emit (plugin, signals[SECRETS_REQUIRED], 0, message, hints);
-}
-
-/*****************************************************************************/
-
-static gboolean
-impl_vpn_plugin_disconnect (NMVPNPlugin *plugin,
- GError **err)
-{
- return nm_vpn_plugin_disconnect (plugin, err);
-}
-
-static gboolean
-impl_vpn_plugin_set_config (NMVPNPlugin *plugin,
- GHashTable *config,
- GError **err)
-{
- nm_vpn_plugin_set_config (plugin, config);
-
- return TRUE;
-}
-
-static gboolean
-impl_vpn_plugin_set_ip4_config (NMVPNPlugin *plugin,
- GHashTable *config,
- GError **err)
-{
- nm_vpn_plugin_set_ip4_config (plugin, config);
-
- return TRUE;
-}
-
-static gboolean
-impl_vpn_plugin_set_ip6_config (NMVPNPlugin *plugin,
- GHashTable *config,
- GError **err)
-{
- nm_vpn_plugin_set_ip6_config (plugin, config);
-
- return TRUE;
-}
-
-static gboolean
-impl_vpn_plugin_set_failure (NMVPNPlugin *plugin,
- char *reason,
- GError **err)
-{
- nm_vpn_plugin_failure (plugin, NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG);
-
- return TRUE;
-}
-
-/*****************************************************************************/
-
-static void
-_emit_quit (gpointer data, gpointer user_data)
-{
- NMVPNPlugin *plugin = data;
-
- nm_vpn_plugin_emit_quit (plugin);
-}
-
-static void
-sigterm_handler (int signum)
-{
- g_slist_foreach (active_plugins, _emit_quit, NULL);
-}
-
-static void
-setup_unix_signal_handler (void)
-{
- struct sigaction action;
- sigset_t block_mask;
-
- action.sa_handler = sigterm_handler;
- sigemptyset (&block_mask);
- action.sa_mask = block_mask;
- action.sa_flags = 0;
- sigaction (SIGINT, &action, NULL);
- sigaction (SIGTERM, &action, NULL);
-}
-
-/*****************************************************************************/
-
-static void
-one_plugin_destroyed (gpointer data,
- GObject *object)
-{
- active_plugins = g_slist_remove (active_plugins, object);
-}
-
-static void
-nm_vpn_plugin_init (NMVPNPlugin *plugin)
-{
- active_plugins = g_slist_append (active_plugins, plugin);
- g_object_weak_ref (G_OBJECT (plugin),
- one_plugin_destroyed,
- NULL);
-}
-
-static GObject *
-constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- NMVPNPlugin *plugin;
- NMVPNPluginPrivate *priv;
- DBusGConnection *connection;
- DBusGProxy *proxy;
- guint request_name_result;
- GError *err = NULL;
-
- object = G_OBJECT_CLASS (nm_vpn_plugin_parent_class)->constructor (type,
- n_construct_params,
- construct_params);
- if (!object)
- return NULL;
-
- priv = NM_VPN_PLUGIN_GET_PRIVATE (object);
- if (!priv->dbus_service_name)
- goto err;
-
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
- if (!connection)
- goto err;
-
- proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- if (!dbus_g_proxy_call (proxy, "RequestName", &err,
- G_TYPE_STRING, priv->dbus_service_name,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &request_name_result,
- G_TYPE_INVALID)) {
- g_object_unref (proxy);
- goto err;
- }
-
- g_object_unref (proxy);
-
- dbus_g_connection_register_g_object (connection,
- NM_VPN_DBUS_PLUGIN_PATH,
- object);
-
- plugin = NM_VPN_PLUGIN (object);
-
- nm_vpn_plugin_set_connection (plugin, connection);
- nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_INIT);
-
- return object;
-
- err:
- if (err) {
- g_warning ("Failed to initialize VPN plugin: %s", err->message);
- g_error_free (err);
- }
-
- if (object)
- g_object_unref (object);
-
- return NULL;
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_DBUS_SERVICE_NAME:
- /* construct-only */
- priv->dbus_service_name = g_value_dup_string (value);
- break;
- case PROP_STATE:
- nm_vpn_plugin_set_state (NM_VPN_PLUGIN (object),
- (NMVPNServiceState) g_value_get_uint (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_DBUS_SERVICE_NAME:
- g_value_set_string (value, priv->dbus_service_name);
- break;
- case PROP_STATE:
- g_value_set_uint (value, nm_vpn_plugin_get_state (NM_VPN_PLUGIN (object)));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-dispose (GObject *object)
-{
- NMVPNPlugin *plugin = NM_VPN_PLUGIN (object);
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
- NMVPNServiceState state;
- GError *err = NULL;
-
- nm_clear_g_source (&priv->fail_stop_id);
- nm_clear_g_source (&priv->quit_timer);
- nm_clear_g_source (&priv->connect_timer);
-
- state = nm_vpn_plugin_get_state (plugin);
-
- if (state == NM_VPN_SERVICE_STATE_STARTED ||
- state == NM_VPN_SERVICE_STATE_STARTING)
- nm_vpn_plugin_disconnect (plugin, &err);
-
- if (err) {
- g_warning ("Error disconnecting VPN connection: %s", err->message);
- g_error_free (err);
- }
-
- G_OBJECT_CLASS (nm_vpn_plugin_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMVPNPlugin *plugin = NM_VPN_PLUGIN (object);
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
-
- nm_vpn_plugin_set_connection (plugin, NULL);
- g_free (priv->dbus_service_name);
-
- if (G_IS_VALUE (&priv->banner))
- g_value_unset (&priv->banner);
- if (G_IS_VALUE (&priv->tundev))
- g_value_unset (&priv->tundev);
- if (G_IS_VALUE (&priv->gateway))
- g_value_unset (&priv->gateway);
- if (G_IS_VALUE (&priv->mtu))
- g_value_unset (&priv->mtu);
-
- G_OBJECT_CLASS (nm_vpn_plugin_parent_class)->finalize (object);
-}
-
-static void
-state_changed (NMVPNPlugin *plugin, NMVPNServiceState state)
-{
- NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin);
-
- switch (state) {
- case NM_VPN_SERVICE_STATE_STARTING:
- nm_clear_g_source (&priv->quit_timer);
- nm_clear_g_source (&priv->fail_stop_id);
- break;
- case NM_VPN_SERVICE_STATE_STOPPED:
- schedule_quit_timer (plugin);
- break;
- default:
- /* Clean up all timers we might have set up. */
- nm_clear_g_source (&priv->connect_timer);
- nm_clear_g_source (&priv->quit_timer);
- nm_clear_g_source (&priv->fail_stop_id);
- break;
- }
-}
-
-static void
-nm_vpn_plugin_class_init (NMVPNPluginClass *plugin_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (plugin_class);
-
- g_type_class_add_private (object_class, sizeof (NMVPNPluginPrivate));
-
- dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (plugin_class),
- &dbus_glib_nm_vpn_plugin_object_info);
-
- /* virtual methods */
- object_class->constructor = constructor;
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- plugin_class->state_changed = state_changed;
-
- /* properties */
-
- /**
- * NMVPNPlugin:service-name:
- *
- * The D-Bus service name of this plugin.
- */
- g_object_class_install_property
- (object_class, PROP_DBUS_SERVICE_NAME,
- g_param_spec_string (NM_VPN_PLUGIN_DBUS_SERVICE_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMVPNPlugin:state:
- *
- * The state of the plugin.
- */
- g_object_class_install_property
- (object_class, PROP_STATE,
- g_param_spec_uint (NM_VPN_PLUGIN_STATE, "", "",
- NM_VPN_SERVICE_STATE_UNKNOWN,
- NM_VPN_SERVICE_STATE_STOPPED,
- NM_VPN_SERVICE_STATE_INIT,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /* signals */
- signals[STATE_CHANGED] =
- g_signal_new ("state-changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVPNPluginClass, state_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1,
- G_TYPE_UINT);
-
- signals[SECRETS_REQUIRED] =
- g_signal_new ("secrets-required",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- NULL,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRV);
-
- signals[CONFIG] =
- g_signal_new ("config",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVPNPluginClass, config),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- DBUS_TYPE_G_MAP_OF_VARIANT);
-
- signals[IP4_CONFIG] =
- g_signal_new ("ip4-config",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVPNPluginClass, ip4_config),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- DBUS_TYPE_G_MAP_OF_VARIANT);
-
- signals[IP6_CONFIG] =
- g_signal_new ("ip6-config",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVPNPluginClass, ip6_config),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- DBUS_TYPE_G_MAP_OF_VARIANT);
-
- signals[LOGIN_BANNER] =
- g_signal_new ("login-banner",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVPNPluginClass, login_banner),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- signals[FAILURE] =
- g_signal_new ("failure",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVPNPluginClass, failure),
- NULL, NULL,
- g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1,
- G_TYPE_UINT);
-
- signals[QUIT] =
- g_signal_new ("quit",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVPNPluginClass, quit),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0,
- G_TYPE_NONE);
-
- dbus_g_error_domain_register (NM_VPN_PLUGIN_ERROR,
- NM_DBUS_VPN_ERROR_PREFIX,
- NM_TYPE_VPN_PLUGIN_ERROR);
-
- setup_unix_signal_handler ();
-}
diff --git a/libnm-glib/nm-vpn-plugin.h b/libnm-glib/nm-vpn-plugin.h
deleted file mode 100644
index a33349a195..0000000000
--- a/libnm-glib/nm-vpn-plugin.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2007 - 2013 Red Hat, Inc.
- */
-
-#ifndef NM_VPN_PLUGIN_H
-#define NM_VPN_PLUGIN_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-#include "NetworkManagerVPN.h"
-#include "nm-connection.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_VPN_PLUGIN (nm_vpn_plugin_get_type ())
-#define NM_VPN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_PLUGIN, NMVPNPlugin))
-#define NM_VPN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_PLUGIN, NMVPNPluginClass))
-#define NM_IS_VPN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_PLUGIN))
-#define NM_IS_VPN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_PLUGIN))
-#define NM_VPN_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_PLUGIN, NMVPNPluginClass))
-
-#define NM_VPN_PLUGIN_DBUS_SERVICE_NAME "service-name"
-#define NM_VPN_PLUGIN_STATE "state"
-
-/**
- * NMVPNPluginError:
- * @NM_VPN_PLUGIN_ERROR_GENERAL: general failure
- * @NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS: the plugin is already starting,
- * and another connect request was received
- * @NM_VPN_PLUGIN_ERROR_ALREADY_STARTED: the plugin is already connected, and
- * another connect request was received
- * @NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS: the plugin is already stopping,
- * and another stop request was received
- * @NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED: the plugin is already stopped, and
- * another disconnect request was received
- * @NM_VPN_PLUGIN_ERROR_WRONG_STATE: the operation could not be performed in
- * this state
- * @NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS: the operation could not be performed as
- * the request contained malformed arguments, or arguments of unexpected type.
- * Usually means that one of the VPN setting data items or secrets was not of
- * the expected type (ie int, string, bool, etc).
- * @NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED: a child process failed to launch
- * @NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID: the operation could not be performed
- * because the connection was invalid. Usually means that the connection's
- * VPN setting was missing some required data item or secret.
- * @NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED: the operation could not be
- * performed as the plugin does not support interactive operations, such as
- * ConnectInteractive() or NewSecrets()
- *
- * Returned by the VPN service plugin to indicate errors.
- **/
-typedef enum {
- NM_VPN_PLUGIN_ERROR_GENERAL, /*< nick=General >*/
- NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS, /*< nick=StartingInProgress >*/
- NM_VPN_PLUGIN_ERROR_ALREADY_STARTED, /*< nick=AlreadyStarted >*/
- NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS, /*< nick=StoppingInProgress >*/
- NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED, /*< nick=AlreadyStopped >*/
- NM_VPN_PLUGIN_ERROR_WRONG_STATE, /*< nick=WrongState >*/
- NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, /*< nick=BadArguments >*/
- NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, /*< nick=LaunchFailed >*/
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/
- NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED /*< nick=InteractiveNotSupported >*/
-} NMVPNPluginError;
-
-#define NM_VPN_PLUGIN_ERROR (nm_vpn_plugin_error_quark ())
-
-typedef struct {
- GObject parent;
-} NMVPNPlugin;
-
-typedef struct {
- GObjectClass parent;
-
- /* virtual methods */
- gboolean (*connect) (NMVPNPlugin *plugin,
- NMConnection *connection,
- GError **err);
-
- gboolean (*need_secrets) (NMVPNPlugin *plugin,
- NMConnection *connection,
- char **setting_name,
- GError **error);
-
- gboolean (*disconnect) (NMVPNPlugin *plugin,
- GError **err);
-
- /* Signals */
- void (*state_changed) (NMVPNPlugin *plugin,
- NMVPNServiceState state);
-
- void (*ip4_config) (NMVPNPlugin *plugin,
- GHashTable *ip4_config);
-
- void (*login_banner) (NMVPNPlugin *plugin,
- const char *banner);
-
- void (*failure) (NMVPNPlugin *plugin,
- NMVPNPluginFailure reason);
-
- void (*quit) (NMVPNPlugin *plugin);
-
- void (*config) (NMVPNPlugin *plugin,
- GHashTable *config);
-
- void (*ip6_config) (NMVPNPlugin *plugin,
- GHashTable *config);
-
- /* more methods */
- gboolean (*new_secrets) (NMVPNPlugin *plugin,
- NMConnection *connection,
- GError **error);
-
- gboolean (*connect_interactive) (NMVPNPlugin *plugin,
- NMConnection *connection,
- GHashTable *details,
- GError **error);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
-} NMVPNPluginClass;
-
-GType nm_vpn_plugin_get_type (void);
-GQuark nm_vpn_plugin_error_quark (void);
-GType nm_vpn_plugin_error_get_type (void);
-
-DBusGConnection *nm_vpn_plugin_get_connection (NMVPNPlugin *plugin);
-NMVPNServiceState nm_vpn_plugin_get_state (NMVPNPlugin *plugin);
-void nm_vpn_plugin_set_state (NMVPNPlugin *plugin,
- NMVPNServiceState state);
-
-NM_AVAILABLE_IN_0_9_10
-void nm_vpn_plugin_secrets_required (NMVPNPlugin *plugin,
- const char *message,
- const char **hints);
-
-void nm_vpn_plugin_set_login_banner (NMVPNPlugin *plugin,
- const char *banner);
-
-void nm_vpn_plugin_failure (NMVPNPlugin *plugin,
- NMVPNPluginFailure reason);
-
-void nm_vpn_plugin_set_config (NMVPNPlugin *plugin,
- GHashTable *config);
-
-void nm_vpn_plugin_set_ip4_config (NMVPNPlugin *plugin,
- GHashTable *ip4_config);
-
-void nm_vpn_plugin_set_ip6_config (NMVPNPlugin *plugin,
- GHashTable *ip6_config);
-
-gboolean nm_vpn_plugin_disconnect (NMVPNPlugin *plugin,
- GError **err);
-
-G_END_DECLS
-
-#endif /* NM_VPN_PLUGIN_H */
diff --git a/libnm-glib/nm-wimax-nsp.c b/libnm-glib/nm-wimax-nsp.c
deleted file mode 100644
index d0ab1f5c01..0000000000
--- a/libnm-glib/nm-wimax-nsp.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-connection.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-wimax.h"
-#include "nm-wimax-nsp.h"
-#include "NetworkManager.h"
-#include "nm-types-private.h"
-#include "nm-object-private.h"
-
-G_DEFINE_TYPE (NMWimaxNsp, nm_wimax_nsp, NM_TYPE_OBJECT)
-
-#define NM_WIMAX_NSP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_WIMAX_NSP, NMWimaxNspPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
-
- char *name;
- guint32 signal_quality;
- NMWimaxNspNetworkType network_type;
-} NMWimaxNspPrivate;
-
-enum {
- PROP_0,
- PROP_NAME,
- PROP_SIGNAL_QUALITY,
- PROP_NETWORK_TYPE,
-
- LAST_PROP
-};
-
-/**
- * nm_wimax_nsp_new:
- * @connection: the #DBusGConnection
- * @path: the D-Bus object path of the WiMAX NSP
- *
- * Creates a new #NMWimaxNsp.
- *
- * Returns: (transfer full): a new WiMAX NSP
- **/
-GObject *
-nm_wimax_nsp_new (DBusGConnection *connection, const char *path)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- return (GObject *) g_object_new (NM_TYPE_WIMAX_NSP,
- NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
- NULL);
-}
-
-/**
- * nm_wimax_nsp_get_name:
- * @nsp: a #NMWimaxNsp
- *
- * Gets the name of the wimax NSP
- *
- * Returns: the name
- **/
-const char *
-nm_wimax_nsp_get_name (NMWimaxNsp *nsp)
-{
- g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NULL);
-
- _nm_object_ensure_inited (NM_OBJECT (nsp));
- return NM_WIMAX_NSP_GET_PRIVATE (nsp)->name;
-}
-
-/**
- * nm_wimax_nsp_get_signal_quality:
- * @nsp: a #NMWimaxNsp
- *
- * Gets the WPA signal quality of the wimax NSP.
- *
- * Returns: the signal quality
- **/
-guint32
-nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp)
-{
- g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), 0);
-
- _nm_object_ensure_inited (NM_OBJECT (nsp));
- return NM_WIMAX_NSP_GET_PRIVATE (nsp)->signal_quality;
-}
-
-/**
- * nm_wimax_nsp_get_network_type:
- * @nsp: a #NMWimaxNsp
- *
- * Gets the network type of the wimax NSP.
- *
- * Returns: the network type
- **/
-NMWimaxNspNetworkType
-nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp)
-{
- g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN);
-
- _nm_object_ensure_inited (NM_OBJECT (nsp));
- return NM_WIMAX_NSP_GET_PRIVATE (nsp)->network_type;
-}
-
-/**
- * nm_wimax_nsp_connection_valid:
- * @nsp: an #NMWimaxNsp to validate @connection against
- * @connection: an #NMConnection to validate against @nsp
- *
- * Validates a given connection against a given WiMAX NSP to ensure that the
- * connection may be activated with that NSP. The connection must match the
- * @nsp's network name and other attributes.
- *
- * Returns: %TRUE if the connection may be activated with this WiMAX NSP,
- * %FALSE if it cannot be.
- **/
-gboolean
-nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp, NMConnection *connection)
-{
- NMSettingConnection *s_con;
- NMSettingWimax *s_wimax;
- const char *ctype;
- const char *nsp_name;
- const char *setting_name;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (strcmp (ctype, NM_SETTING_WIMAX_SETTING_NAME) != 0)
- return FALSE;
-
- s_wimax = nm_connection_get_setting_wimax (connection);
- if (!s_wimax)
- return FALSE;
-
- setting_name = nm_setting_wimax_get_network_name (s_wimax);
- if (!setting_name)
- return FALSE;
-
- nsp_name = nm_wimax_nsp_get_name (nsp);
- g_warn_if_fail (nsp_name != NULL);
- if (g_strcmp0 (nsp_name, setting_name) != 0)
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * nm_wimax_nsp_filter_connections:
- * @nsp: an #NMWimaxNsp to filter connections for
- * @connections: (element-type NMConnection): a list of
- * #NMConnection objects to filter
- *
- * Filters a given list of connections for a given #NMWimaxNsp object and
- * return connections which may be activated with the access point. Any
- * returned connections will match the @nsp's network name and other attributes.
- *
- * Returns: (transfer container) (element-type NMConnection): a
- * list of #NMConnection objects that could be activated with the given @nsp.
- * The elements of the list are owned by their creator and should not be freed
- * by the caller, but the returned list itself is owned by the caller and should
- * be freed with g_slist_free() when it is no longer required.
- **/
-GSList *
-nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp, const GSList *connections)
-{
- GSList *filtered = NULL;
- const GSList *iter;
-
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *candidate = NM_CONNECTION (iter->data);
-
- if (nm_wimax_nsp_connection_valid (nsp, candidate))
- filtered = g_slist_prepend (filtered, candidate);
- }
-
- return g_slist_reverse (filtered);
-}
-
-/*****************************************************************************/
-
-static void
-nm_wimax_nsp_init (NMWimaxNsp *nsp)
-{
-}
-
-static void
-dispose (GObject *object)
-{
- NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object);
-
- g_clear_object (&priv->proxy);
-
- G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object);
-
- g_free (priv->name);
-
- G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NMWimaxNsp *nsp = NM_WIMAX_NSP (object);
-
- _nm_object_ensure_inited (NM_OBJECT (object));
-
- switch (prop_id) {
- case PROP_NAME:
- g_value_set_string (value, nm_wimax_nsp_get_name (nsp));
- break;
- case PROP_SIGNAL_QUALITY:
- g_value_set_uint (value, nm_wimax_nsp_get_signal_quality (nsp));
- break;
- case PROP_NETWORK_TYPE:
- g_value_set_uint (value, nm_wimax_nsp_get_network_type (nsp));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-register_properties (NMWimaxNsp *nsp)
-{
- NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (nsp);
- const NMPropertiesInfo property_info[] = {
- { NM_WIMAX_NSP_NAME, &priv->name },
- { NM_WIMAX_NSP_SIGNAL_QUALITY, &priv->signal_quality },
- { NM_WIMAX_NSP_NETWORK_TYPE, &priv->network_type },
- { NULL },
- };
-
- _nm_object_register_properties (NM_OBJECT (nsp),
- priv->proxy,
- property_info);
-}
-
-static void
-constructed (GObject *object)
-{
- NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object);
-
- G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->constructed (object);
-
- priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_WIMAX_NSP);
- register_properties (NM_WIMAX_NSP (object));
-}
-
-static void
-nm_wimax_nsp_class_init (NMWimaxNspClass *nsp_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (nsp_class);
-
- g_type_class_add_private (nsp_class, sizeof (NMWimaxNspPrivate));
-
- /* virtual methods */
- object_class->constructed = constructed;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- /* properties */
-
- /**
- * NMWimaxNsp:name:
- *
- * The name of the WiMAX NSP.
- **/
- g_object_class_install_property
- (object_class, PROP_NAME,
- g_param_spec_string (NM_WIMAX_NSP_NAME, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMWimaxNsp:signal-quality:
- *
- * The signal quality of the WiMAX NSP.
- **/
- g_object_class_install_property
- (object_class, PROP_SIGNAL_QUALITY,
- g_param_spec_uint (NM_WIMAX_NSP_SIGNAL_QUALITY, "", "",
- 0, 100, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMWimaxNsp:network-type:
- *
- * The network type of the WiMAX NSP.
- **/
- g_object_class_install_property
- (object_class, PROP_NETWORK_TYPE,
- g_param_spec_uint (NM_WIMAX_NSP_NETWORK_TYPE, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-glib/nm-wimax-nsp.h b/libnm-glib/nm-wimax-nsp.h
deleted file mode 100644
index 336f331dd5..0000000000
--- a/libnm-glib/nm-wimax-nsp.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 Red Hat, Inc.
- * Copyright 2009 Novell, Inc.
- */
-
-#ifndef NM_WIMAX_NSP_H
-#define NM_WIMAX_NSP_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include "NetworkManager.h"
-#include "nm-object.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_WIMAX_NSP (nm_wimax_nsp_get_type ())
-#define NM_WIMAX_NSP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIMAX_NSP, NMWimaxNsp))
-#define NM_WIMAX_NSP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIMAX_NSP, NMWimaxNspClass))
-#define NM_IS_WIMAX_NSP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIMAX_NSP))
-#define NM_IS_WIMAX_NSP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIMAX_NSP))
-#define NM_WIMAX_NSP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIMAX_NSP, NMWimaxNspClass))
-
-#define NM_WIMAX_NSP_NAME "name"
-#define NM_WIMAX_NSP_SIGNAL_QUALITY "signal-quality"
-#define NM_WIMAX_NSP_NETWORK_TYPE "network-type"
-
-/**
- * NMWimaxNspNetworkType:
- * @NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN: unknown network type
- * @NM_WIMAX_NSP_NETWORK_TYPE_HOME: home network
- * @NM_WIMAX_NSP_NETWORK_TYPE_PARTNER: partner network
- * @NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER: roaming partner network
- *
- * WiMAX network type.
- */
-typedef enum {
- NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN = 0,
- NM_WIMAX_NSP_NETWORK_TYPE_HOME = 1,
- NM_WIMAX_NSP_NETWORK_TYPE_PARTNER = 2,
- NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER = 3
-} NMWimaxNspNetworkType;
-
-typedef struct {
- NMObject parent;
-} NMWimaxNsp;
-
-typedef struct {
- NMObjectClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMWimaxNspClass;
-
-GType nm_wimax_nsp_get_type (void);
-
-GObject *nm_wimax_nsp_new (DBusGConnection *connection, const char *path);
-
-const char * nm_wimax_nsp_get_name (NMWimaxNsp *nsp);
-guint32 nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp);
-NMWimaxNspNetworkType nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp);
-
-GSList * nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp,
- const GSList *connections);
-
-gboolean nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp,
- NMConnection *connection);
-
-G_END_DECLS
-
-#endif /* NM_WIMAX_NSP_H */
diff --git a/libnm-glib/tests/meson.build b/libnm-glib/tests/meson.build
deleted file mode 100644
index de74f3b2cb..0000000000
--- a/libnm-glib/tests/meson.build
+++ /dev/null
@@ -1,30 +0,0 @@
-deps = [
- dbus_dep,
- dbus_glib_dep,
- libnm_glib_dep,
- libnm_util_dep,
- shared_nm_glib_aux_dep,
-]
-
-test_units = [
- 'test-nm-client',
- 'test-remote-settings-client',
-]
-
-foreach test_unit: test_units
- exe = executable(
- test_unit,
- [test_unit + '.c'] + shared_nm_test_utils_impl_c,
- dependencies: deps,
- c_args:
- common_cflags + [
- '-DNETWORKMANAGER_COMPILATION_TEST',
- ],
- )
-
- test(
- 'libnm-glib/' + test_unit,
- test_script,
- args: test_args + [exe.full_path()],
- )
-endforeach
diff --git a/libnm-glib/tests/test-nm-client.c b/libnm-glib/tests/test-nm-client.c
deleted file mode 100644
index df85721538..0000000000
--- a/libnm-glib/tests/test-nm-client.c
+++ /dev/null
@@ -1,1156 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2010 - 2014 Red Hat, Inc.
- *
- */
-
-#include "nm-default.h"
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <string.h>
-#include <sys/types.h>
-#include <signal.h>
-
-#include "nm-client.h"
-#include "nm-device-wifi.h"
-#include "nm-device-ethernet.h"
-#include "nm-device-wimax.h"
-#include "nm-connection.h"
-#include "nm-setting.h"
-
-#include "nm-test-libnm-utils.h"
-
-static GMainLoop *loop = NULL;
-static NMTstcServiceInfo *sinfo;
-
-/*****************************************************************************/
-
-static gboolean
-loop_quit (gpointer user_data)
-{
- g_main_loop_quit ((GMainLoop *) user_data);
- return G_SOURCE_REMOVE;
-}
-
-static gboolean
-add_device (const char *method, const char *ifname, char **out_path)
-{
- GError *error = NULL;
- GVariant *ret;
-
- ret = g_dbus_proxy_call_sync (sinfo->proxy,
- method,
- g_variant_new ("(s)", ifname),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- 3000,
- NULL,
- &error);
- g_assert_no_error (error);
- g_assert (ret);
- g_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
- if (out_path)
- g_variant_get (ret, "(o)", out_path);
- g_variant_unref (ret);
- return TRUE;
-}
-
-static gboolean
-add_wired_device (const char *method, const char *ifname, char **out_path)
-{
- const char *empty[] = { NULL };
- GError *error = NULL;
- GVariant *ret;
-
- ret = g_dbus_proxy_call_sync (sinfo->proxy,
- method,
- g_variant_new ("(ss^as)", ifname, "/", empty),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- 3000,
- NULL,
- &error);
- g_assert_no_error (error);
- g_assert (ret);
- g_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
- if (out_path)
- g_variant_get (ret, "(o)", out_path);
- g_variant_unref (ret);
- return TRUE;
-}
-
-/*****************************************************************************/
-
-typedef struct {
- GMainLoop *loop;
- gboolean signaled;
- gboolean notified;
- guint quit_count;
- guint quit_id;
-} DeviceAddedInfo;
-
-static void
-device_add_check_quit (DeviceAddedInfo *info)
-{
- info->quit_count--;
- if (info->quit_count == 0) {
- g_source_remove (info->quit_id);
- info->quit_id = 0;
- g_main_loop_quit (info->loop);
- }
-}
-
-static void
-device_added_cb (NMClient *c,
- NMDevice *device,
- DeviceAddedInfo *info)
-{
- g_assert (device);
- g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
- info->signaled = TRUE;
- device_add_check_quit (info);
-}
-
-static void
-devices_notify_cb (NMClient *c,
- GParamSpec *pspec,
- DeviceAddedInfo *info)
-{
- const GPtrArray *devices;
- NMDevice *device;
-
- devices = nm_client_get_devices (c);
- g_assert (devices);
- g_assert_cmpint (devices->len, ==, 1);
-
- device = g_ptr_array_index (devices, 0);
- g_assert (device);
- g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
-
- info->notified = TRUE;
-
- device_add_check_quit (info);
-}
-
-static void
-test_device_added (void)
-{
- NMClient *client;
- const GPtrArray *devices;
- NMDevice *device;
- DeviceAddedInfo info = { loop, FALSE, FALSE, 0, 0 };
-
- sinfo = nmtstc_service_init ();
- if (!nmtstc_service_available (sinfo))
- return;
-
- client = nmtstc_nm_client_new ();
-
- devices = nm_client_get_devices (client);
- g_assert (devices == NULL);
-
- /* Tell the test service to add a new device */
- add_wired_device ("AddWiredDevice", "eth0", NULL);
-
- g_signal_connect (client,
- "device-added",
- (GCallback) device_added_cb,
- &info);
- info.quit_count++;
-
- g_signal_connect (client,
- "notify::devices",
- (GCallback) devices_notify_cb,
- &info);
- info.quit_count++;
-
- /* Wait for libnm-glib to find the device */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert (info.signaled);
- g_assert (info.notified);
-
- g_signal_handlers_disconnect_by_func (client, device_added_cb, &info);
- g_signal_handlers_disconnect_by_func (client, devices_notify_cb, &info);
-
- devices = nm_client_get_devices (client);
- g_assert (devices);
- g_assert_cmpint (devices->len, ==, 1);
-
- device = g_ptr_array_index (devices, 0);
- g_assert (device);
- g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
-
- g_object_unref (client);
- g_clear_pointer (&sinfo, nmtstc_service_cleanup);
-}
-
-/*****************************************************************************/
-
-static const char *expected_bssid = "66:55:44:33:22:11";
-
-typedef struct {
- GMainLoop *loop;
- gboolean found;
- char *ap_path;
- gboolean signaled;
- gboolean notified;
- guint quit_id;
- guint quit_count;
-} WifiApInfo;
-
-static void
-wifi_check_quit (WifiApInfo *info)
-{
- info->quit_count--;
- if (info->quit_count == 0) {
- g_source_remove (info->quit_id);
- info->quit_id = 0;
- g_main_loop_quit (info->loop);
- }
-}
-
-static void
-wifi_device_added_cb (NMClient *c,
- NMDevice *device,
- WifiApInfo *info)
-{
- g_assert_cmpstr (nm_device_get_iface (device), ==, "wlan0");
- info->found = TRUE;
- wifi_check_quit (info);
-}
-
-static void
-got_ap_path (WifiApInfo *info, const char *path)
-{
- if (info->ap_path)
- g_assert_cmpstr (info->ap_path, ==, path);
- else
- info->ap_path = g_strdup (path);
-}
-
-static void
-wifi_ap_added_cb (NMDeviceWifi *w,
- NMAccessPoint *ap,
- WifiApInfo *info)
-{
- g_assert (ap);
- g_assert_cmpstr (nm_access_point_get_bssid (ap), ==, expected_bssid);
- got_ap_path (info, nm_object_get_path (NM_OBJECT (ap)));
-
- info->signaled = TRUE;
- wifi_check_quit (info);
-}
-
-static void
-wifi_ap_add_notify_cb (NMDeviceWifi *w,
- GParamSpec *pspec,
- WifiApInfo *info)
-{
- const GPtrArray *aps;
- NMAccessPoint *ap;
-
- aps = nm_device_wifi_get_access_points (w);
- g_assert (aps);
- g_assert_cmpint (aps->len, ==, 1);
-
- ap = g_ptr_array_index (aps, 0);
- g_assert (ap);
- g_assert_cmpstr (nm_access_point_get_bssid (ap), ==, "66:55:44:33:22:11");
- got_ap_path (info, nm_object_get_path (NM_OBJECT (ap)));
-
- info->notified = TRUE;
- wifi_check_quit (info);
-}
-
-static void
-wifi_ap_removed_cb (NMDeviceWifi *w,
- NMAccessPoint *ap,
- WifiApInfo *info)
-{
- g_assert (ap);
- g_assert_cmpstr (info->ap_path, ==, nm_object_get_path (NM_OBJECT (ap)));
-
- info->signaled = TRUE;
- wifi_check_quit (info);
-}
-
-static void
-wifi_ap_remove_notify_cb (NMDeviceWifi *w,
- GParamSpec *pspec,
- WifiApInfo *info)
-{
- const GPtrArray *aps;
-
- aps = nm_device_wifi_get_access_points (w);
- g_assert (aps == NULL);
-
- info->notified = TRUE;
- wifi_check_quit (info);
-}
-
-static void
-test_wifi_ap_added_removed (void)
-{
- NMClient *client;
- NMDeviceWifi *wifi;
- WifiApInfo info = { loop, FALSE, FALSE, 0, 0 };
- GVariant *ret;
- GError *error = NULL;
- char *expected_path = NULL;
-
- sinfo = nmtstc_service_init ();
- if (!nmtstc_service_available (sinfo))
- return;
-
- client = nmtstc_nm_client_new ();
-
- /*************************************/
- /* Add the wifi device */
- add_device ("AddWifiDevice", "wlan0", NULL);
-
- g_signal_connect (client,
- "device-added",
- (GCallback) wifi_device_added_cb,
- &info);
- info.quit_count = 1;
-
- /* Wait for libnm-glib to find the device */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert (info.found);
- g_signal_handlers_disconnect_by_func (client, wifi_device_added_cb, &info);
-
- wifi = (NMDeviceWifi *) nm_client_get_device_by_iface (client, "wlan0");
- g_assert (NM_IS_DEVICE_WIFI (wifi));
-
- /*************************************/
- /* Add the wifi device */
- info.signaled = FALSE;
- info.notified = FALSE;
- info.quit_id = 0;
-
- ret = g_dbus_proxy_call_sync (sinfo->proxy,
- "AddWifiAp",
- g_variant_new ("(sss)", "wlan0", "test-ap", expected_bssid),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- 3000,
- NULL,
- &error);
- g_assert_no_error (error);
- g_assert (ret);
- g_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
- g_variant_get (ret, "(o)", &expected_path);
- g_variant_unref (ret);
-
- g_signal_connect (wifi,
- "access-point-added",
- (GCallback) wifi_ap_added_cb,
- &info);
- info.quit_count = 1;
-
- g_signal_connect (wifi,
- "notify::access-points",
- (GCallback) wifi_ap_add_notify_cb,
- &info);
- info.quit_count++;
-
- /* Wait for libnm-glib to find the AP */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert (info.signaled);
- g_assert (info.notified);
- g_assert (info.ap_path);
- g_assert_cmpstr (info.ap_path, ==, expected_path);
- g_signal_handlers_disconnect_by_func (wifi, wifi_ap_added_cb, &info);
- g_signal_handlers_disconnect_by_func (wifi, wifi_ap_add_notify_cb, &info);
-
- /*************************************/
- /* Remove the wifi device */
- info.signaled = FALSE;
- info.notified = FALSE;
- info.quit_id = 0;
-
- ret = g_dbus_proxy_call_sync (sinfo->proxy,
- "RemoveWifiAp",
- g_variant_new ("(so)", "wlan0", expected_path),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- 3000,
- NULL,
- &error);
- g_assert_no_error (error);
- g_clear_pointer (&ret, g_variant_unref);
-
- g_signal_connect (wifi,
- "access-point-removed",
- (GCallback) wifi_ap_removed_cb,
- &info);
- info.quit_count = 1;
-
- g_signal_connect (wifi,
- "notify::access-points",
- (GCallback) wifi_ap_remove_notify_cb,
- &info);
- info.quit_count++;
-
- /* Wait for libnm-glib to find the AP */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert (info.signaled);
- g_assert (info.notified);
- g_signal_handlers_disconnect_by_func (wifi, wifi_ap_removed_cb, &info);
- g_signal_handlers_disconnect_by_func (wifi, wifi_ap_remove_notify_cb, &info);
-
- g_free (info.ap_path);
- g_free (expected_path);
-
- g_object_unref (client);
- g_clear_pointer (&sinfo, nmtstc_service_cleanup);
-}
-
-/*****************************************************************************/
-
-static const char *expected_nsp_name = "Clear";
-
-typedef struct {
- GMainLoop *loop;
- gboolean found;
- char *nsp_path;
- gboolean signaled;
- gboolean notified;
- guint quit_id;
- guint quit_count;
-} WimaxNspInfo;
-
-static void
-wimax_check_quit (WimaxNspInfo *info)
-{
- info->quit_count--;
- if (info->quit_count == 0) {
- g_source_remove (info->quit_id);
- info->quit_id = 0;
- g_main_loop_quit (info->loop);
- }
-}
-
-static void
-wimax_device_added_cb (NMClient *c,
- NMDevice *device,
- WimaxNspInfo *info)
-{
- g_assert_cmpstr (nm_device_get_iface (device), ==, "wmx0");
- info->found = TRUE;
- wimax_check_quit (info);
-}
-
-static void
-got_nsp_path (WimaxNspInfo *info, const char *path)
-{
- if (info->nsp_path)
- g_assert_cmpstr (info->nsp_path, ==, path);
- else
- info->nsp_path = g_strdup (path);
-}
-
-static void
-wimax_nsp_added_cb (NMDeviceWimax *w,
- NMWimaxNsp *nsp,
- WimaxNspInfo *info)
-{
- g_assert (nsp);
- g_assert_cmpstr (nm_wimax_nsp_get_name (nsp), ==, expected_nsp_name);
- got_nsp_path (info, nm_object_get_path (NM_OBJECT (nsp)));
-
- info->signaled = TRUE;
- wimax_check_quit (info);
-}
-
-static void
-wimax_nsp_add_notify_cb (NMDeviceWimax *w,
- GParamSpec *pspec,
- WimaxNspInfo *info)
-{
- const GPtrArray *nsps;
- NMWimaxNsp *nsp;
-
- nsps = nm_device_wimax_get_nsps (w);
- g_assert (nsps);
- g_assert_cmpint (nsps->len, ==, 1);
-
- nsp = g_ptr_array_index (nsps, 0);
- g_assert (nsp);
- g_assert_cmpstr (nm_wimax_nsp_get_name (nsp), ==, expected_nsp_name);
- got_nsp_path (info, nm_object_get_path (NM_OBJECT (nsp)));
-
- info->notified = TRUE;
- wimax_check_quit (info);
-}
-
-static void
-wimax_nsp_removed_cb (NMDeviceWimax *w,
- NMWimaxNsp *nsp,
- WimaxNspInfo *info)
-{
- g_assert (nsp);
- g_assert_cmpstr (info->nsp_path, ==, nm_object_get_path (NM_OBJECT (nsp)));
-
- info->signaled = TRUE;
- wimax_check_quit (info);
-}
-
-static void
-wimax_nsp_remove_notify_cb (NMDeviceWimax *w,
- GParamSpec *pspec,
- WimaxNspInfo *info)
-{
- const GPtrArray *nsps;
-
- nsps = nm_device_wimax_get_nsps (w);
- g_assert (nsps == NULL);
-
- info->notified = TRUE;
- wimax_check_quit (info);
-}
-
-static void
-test_wimax_nsp_added_removed (void)
-{
- NMClient *client;
- NMDeviceWimax *wimax;
- WimaxNspInfo info = { loop, FALSE, FALSE, 0, 0 };
- GVariant *ret;
- GError *error = NULL;
- char *expected_path = NULL;
-
- sinfo = nmtstc_service_init ();
- if (!nmtstc_service_available (sinfo))
- return;
-
- client = nmtstc_nm_client_new ();
-
- /*************************************/
- /* Add the wimax device */
- add_device ("AddWimaxDevice", "wmx0", NULL);
-
- g_signal_connect (client,
- "device-added",
- (GCallback) wimax_device_added_cb,
- &info);
- info.quit_count = 1;
-
- /* Wait for libnm-glib to find the device */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert (info.found);
- g_signal_handlers_disconnect_by_func (client, wimax_device_added_cb, &info);
-
- wimax = (NMDeviceWimax *) nm_client_get_device_by_iface (client, "wmx0");
- g_assert (NM_IS_DEVICE_WIMAX (wimax));
-
- /*************************************/
- /* Add the wimax NSP */
- info.signaled = FALSE;
- info.notified = FALSE;
- info.quit_id = 0;
-
- ret = g_dbus_proxy_call_sync (sinfo->proxy,
- "AddWimaxNsp",
- g_variant_new ("(ss)", "wmx0", expected_nsp_name),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- 3000,
- NULL,
- &error);
- g_assert_no_error (error);
- g_assert (ret);
- g_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
- g_variant_get (ret, "(o)", &expected_path);
- g_variant_unref (ret);
-
- g_signal_connect (wimax,
- "nsp-added",
- (GCallback) wimax_nsp_added_cb,
- &info);
- info.quit_count = 1;
-
- g_signal_connect (wimax,
- "notify::nsps",
- (GCallback) wimax_nsp_add_notify_cb,
- &info);
- info.quit_count++;
-
- /* Wait for libnm-glib to find the AP */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert (info.signaled);
- g_assert (info.notified);
- g_assert (info.nsp_path);
- g_assert_cmpstr (info.nsp_path, ==, expected_path);
- g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_added_cb, &info);
- g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_add_notify_cb, &info);
-
- /*************************************/
- /* Remove the wimax NSP */
- info.signaled = FALSE;
- info.notified = FALSE;
- info.quit_id = 0;
-
- ret = g_dbus_proxy_call_sync (sinfo->proxy,
- "RemoveWimaxNsp",
- g_variant_new ("(so)", "wmx0", expected_path),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- 3000,
- NULL,
- &error);
- g_assert_no_error (error);
- g_clear_pointer (&ret, g_variant_unref);
-
- g_signal_connect (wimax,
- "nsp-removed",
- (GCallback) wimax_nsp_removed_cb,
- &info);
- info.quit_count = 1;
-
- g_signal_connect (wimax,
- "notify::nsps",
- (GCallback) wimax_nsp_remove_notify_cb,
- &info);
- info.quit_count++;
-
- /* Wait for libnm-glib to find the AP */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert (info.signaled);
- g_assert (info.notified);
- g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_removed_cb, &info);
- g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_remove_notify_cb, &info);
-
- g_free (info.nsp_path);
- g_free (expected_path);
-
- g_object_unref (client);
- g_clear_pointer (&sinfo, nmtstc_service_cleanup);
-}
-
-/*****************************************************************************/
-
-typedef struct {
- GMainLoop *loop;
- gboolean signaled;
- gboolean notified;
- guint quit_count;
- guint quit_id;
-} DaInfo;
-
-static void
-da_check_quit (DaInfo *info)
-{
- g_assert (info->quit_count > 0);
- info->quit_count--;
- if (info->quit_count == 0) {
- g_source_remove (info->quit_id);
- info->quit_id = 0;
- g_main_loop_quit (info->loop);
- }
-}
-
-static void
-da_device_added_cb (NMClient *c,
- NMDevice *device,
- DaInfo *info)
-{
- da_check_quit (info);
-}
-
-static void
-da_device_removed_cb (NMClient *c,
- NMDevice *device,
- DaInfo *info)
-{
- g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
- info->signaled = TRUE;
- da_check_quit (info);
-}
-
-static void
-da_devices_notify_cb (NMClient *c,
- GParamSpec *pspec,
- DaInfo *info)
-{
- const GPtrArray *devices;
- NMDevice *device;
- guint i;
- const char *iface;
-
- devices = nm_client_get_devices (c);
- g_assert (devices);
- g_assert_cmpint (devices->len, ==, 2);
-
- for (i = 0; i < devices->len; i++) {
- device = g_ptr_array_index (devices, i);
- iface = nm_device_get_iface (device);
-
- g_assert (!strcmp (iface, "wlan0") || !strcmp (iface, "eth1"));
- }
-
- info->notified = TRUE;
- da_check_quit (info);
-}
-
-static void
-test_devices_array (void)
-{
- NMClient *client;
- DaInfo info = { loop };
- char *paths[3] = { NULL, NULL, NULL };
- NMDevice *device;
- const GPtrArray *devices;
- GError *error = NULL;
- GVariant *ret;
-
- sinfo = nmtstc_service_init ();
- if (!nmtstc_service_available (sinfo))
- return;
-
- client = nmtstc_nm_client_new ();
-
- /*************************************/
- /* Add some devices */
- add_device ("AddWifiDevice", "wlan0", &paths[0]);
- add_wired_device ("AddWiredDevice", "eth0", &paths[1]);
- add_wired_device ("AddWiredDevice", "eth1", &paths[2]);
- info.quit_count = 3;
-
- g_signal_connect (client,
- "device-added",
- (GCallback) da_device_added_cb,
- &info);
-
- /* Wait for libnm-glib to find the device */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert_cmpint (info.quit_count, ==, 0);
- g_signal_handlers_disconnect_by_func (client, da_device_added_cb, &info);
-
- /* Ensure the devices now exist */
- devices = nm_client_get_devices (client);
- g_assert (devices);
- g_assert_cmpint (devices->len, ==, 3);
-
- device = nm_client_get_device_by_iface (client, "wlan0");
- g_assert (NM_IS_DEVICE_WIFI (device));
-
- device = nm_client_get_device_by_iface (client, "eth0");
- g_assert (NM_IS_DEVICE_ETHERNET (device));
-
- device = nm_client_get_device_by_iface (client, "eth1");
- g_assert (NM_IS_DEVICE_ETHERNET (device));
-
- /********************************/
- /* Now remove the device in the middle */
- ret = g_dbus_proxy_call_sync (sinfo->proxy,
- "RemoveDevice",
- g_variant_new ("(o)", paths[1]),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- 3000,
- NULL,
- &error);
- g_assert_no_error (error);
- g_assert (ret);
- g_variant_unref (ret);
-
- g_signal_connect (client,
- "device-removed",
- (GCallback) da_device_removed_cb,
- &info);
-
- g_signal_connect (client,
- "notify::devices",
- (GCallback) da_devices_notify_cb,
- &info);
- info.quit_count = 2;
-
- /* Wait for libnm-glib to find the device */
- info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
-
- g_assert_cmpint (info.quit_count, ==, 0);
- g_signal_handlers_disconnect_by_func (client, da_device_removed_cb, &info);
- g_signal_handlers_disconnect_by_func (client, da_devices_notify_cb, &info);
-
- /* Ensure only two are left */
- devices = nm_client_get_devices (client);
- g_assert (devices);
- g_assert_cmpint (devices->len, ==, 2);
-
- device = nm_client_get_device_by_iface (client, "wlan0");
- g_assert (NM_IS_DEVICE_WIFI (device));
-
- device = nm_client_get_device_by_iface (client, "eth1");
- g_assert (NM_IS_DEVICE_ETHERNET (device));
-
- g_free (paths[0]);
- g_free (paths[1]);
- g_free (paths[2]);
-
- g_object_unref (client);
- g_clear_pointer (&sinfo, nmtstc_service_cleanup);
-}
-
-static void
-manager_running_changed (GObject *client,
- GParamSpec *pspec,
- gpointer user_data)
-{
- int *running_changed = user_data;
-
- (*running_changed)++;
- g_main_loop_quit (loop);
-}
-
-static void
-test_client_manager_running (void)
-{
- gs_unref_object NMClient *client1 = NULL;
- gs_unref_object NMClient *client2 = NULL;
- guint quit_id;
- int running_changed = 0;
- GError *error = NULL;
-
- client1 = nmtstc_nm_client_new ();
-
- g_assert (!nm_client_get_manager_running (client1));
- g_assert_cmpstr (nm_client_get_version (client1), ==, NULL);
-
- g_assert (!nm_client_networking_get_enabled (client1));
- /* This will have no effect, but it shouldn't cause any warnings either. */
- nm_client_networking_set_enabled (client1, TRUE);
- g_assert (!nm_client_networking_get_enabled (client1));
-
- /* OTOH, this should result in an error */
- nm_client_set_logging (client1, "DEFAULT", "INFO", &error);
- g_assert_error (error, NM_CLIENT_ERROR, NM_CLIENT_ERROR_MANAGER_NOT_RUNNING);
- g_clear_error (&error);
-
- /* Now start the test service. */
- sinfo = nmtstc_service_init ();
- if (!nmtstc_service_available (sinfo))
- return;
-
- client2 = nmtstc_nm_client_new ();
-
- /* client2 should know that NM is running, but the previously-created
- * client1 hasn't gotten the news yet.
- */
- g_assert (!nm_client_get_manager_running (client1));
- g_assert (nm_client_get_manager_running (client2));
-
- g_signal_connect (client1, "notify::" NM_CLIENT_MANAGER_RUNNING,
- G_CALLBACK (manager_running_changed), &running_changed);
- quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
- g_assert_cmpint (running_changed, ==, 1);
- g_assert (nm_client_get_manager_running (client1));
- g_source_remove (quit_id);
-
- /* And kill it */
- g_clear_pointer (&sinfo, nmtstc_service_cleanup);
-
- g_assert (nm_client_get_manager_running (client1));
-
- quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
- g_assert_cmpint (running_changed, ==, 2);
- g_assert (!nm_client_get_manager_running (client1));
- g_source_remove (quit_id);
-}
-
-/*****************************************************************************/
-
-static GPtrArray *
-_slist_to_array (GPtrArray **connections, GSList *list)
-{
- GPtrArray *array;
- const GSList *iter;
-
- if (!*connections)
- *connections = array = g_ptr_array_new ();
- else {
- array = *connections;
- g_ptr_array_set_size (array, 0);
- }
- for (iter = list; iter; iter = iter->next)
- g_ptr_array_add (array, iter->data);
- g_slist_free (list);
- return array;
-}
-
-static gboolean
-_test_connection_invalid_find_connections (gpointer element, gpointer needle, gpointer user_data)
-{
- NMRemoteConnection *con = NM_REMOTE_CONNECTION (element);
- const char *path = needle;
-
- g_assert (NM_IS_REMOTE_CONNECTION (con));
- g_assert (path && *path);
-
- return strcmp (path, nm_connection_get_path ((NMConnection *) con)) == 0;
-}
-
-#define ASSERT_IDX(i) \
- g_assert_cmpint (idx[i], >=, 0); \
- g_assert (path##i && *path##i); \
- g_assert (NM_IS_REMOTE_CONNECTION (connections->pdata[idx[i]])); \
- g_assert_cmpstr (nm_connection_get_path (connections->pdata[idx[i]]), ==, path##i);
-
-static void
-test_connection_invalid (void)
-{
- NMTSTC_SERVICE_INFO_SETUP (my_sinfo)
- gs_unref_object NMConnection *connection = NULL;
- NMSettingConnection *s_con;
- gs_unref_object NMRemoteSettings *settings = NULL;
- gs_unref_ptrarray GPtrArray *connections = NULL;
- gs_free char *path0 = NULL;
- gs_free char *path1 = NULL;
- gs_free char *path2 = NULL;
- gs_free char *uuid2 = NULL;
- gsize n_found;
- gssize idx[3];
-
- /**************************************************************************
- * Add two connection before starting libnm. One valid, one invalid.
- *************************************************************************/
-
- connection = nmtst_create_minimal_connection ("test-connection-invalid-0", NULL, NM_SETTING_WIRED_SETTING_NAME, &s_con);
- nmtst_connection_normalize (connection);
- g_object_set (s_con,
- NM_SETTING_CONNECTION_UUID, nmtst_uuid_generate (),
- NULL);
- nmtstc_service_add_connection (my_sinfo,
- connection,
- TRUE,
- &path0);
-
- nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRED);
- g_object_set (s_con,
- NM_SETTING_CONNECTION_ID, "test-connection-invalid-1",
- NM_SETTING_CONNECTION_TYPE, "invalid-type-1",
- NM_SETTING_CONNECTION_UUID, nmtst_uuid_generate (),
- NULL);
- nmtstc_service_add_connection (my_sinfo,
- connection,
- FALSE,
- &path1);
-
- nmtst_main_loop_run (loop, 100);
-
- settings = nmtstc_nm_remote_settings_new ();
-
- nmtst_main_loop_run (loop, 100);
-
- _slist_to_array (&connections, nm_remote_settings_list_connections (settings));
-
- g_assert_cmpint (connections->len, ==, 2);
- n_found = nmtst_find_all_indexes (connections->pdata,
- connections->len,
- (gpointer *) ((const char *[]) { path0, path1 }),
- 2,
- _test_connection_invalid_find_connections,
- NULL,
- idx);
- g_assert_cmpint (n_found, ==, 2);
- ASSERT_IDX (0);
- ASSERT_IDX (1);
- nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[0]]);
- nmtst_assert_connection_unnormalizable (connections->pdata[idx[1]], 0, 0);
-
- /**************************************************************************
- * After having the client up and running, add another invalid connection
- *************************************************************************/
-
- g_object_set (s_con,
- NM_SETTING_CONNECTION_ID, "test-connection-invalid-2",
- NM_SETTING_CONNECTION_TYPE, "invalid-type-2",
- NM_SETTING_CONNECTION_UUID, (uuid2 = g_strdup (nmtst_uuid_generate ())),
- NULL);
- nmtstc_service_add_connection (my_sinfo,
- connection,
- FALSE,
- &path2);
-
- nmtst_main_loop_run (loop, 100);
-
- _slist_to_array (&connections, nm_remote_settings_list_connections (settings));
-
- g_assert_cmpint (connections->len, ==, 3);
- n_found = nmtst_find_all_indexes (connections->pdata,
- connections->len,
- (gpointer *) ((const char *[]) { path0, path1, path2 }),
- 3,
- _test_connection_invalid_find_connections,
- NULL,
- idx);
- g_assert_cmpint (n_found, ==, 3);
- ASSERT_IDX (0);
- ASSERT_IDX (1);
- ASSERT_IDX (2);
- nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[0]]);
- nmtst_assert_connection_unnormalizable (connections->pdata[idx[1]], 0, 0);
- nmtst_assert_connection_unnormalizable (connections->pdata[idx[2]], 0, 0);
-
- /**************************************************************************
- * Modify the invalid connection. Connection disappears
- *************************************************************************/
-
- g_object_set (s_con,
- NM_SETTING_CONNECTION_ID, "test-connection-invalid-2x",
- NULL);
- nmtstc_service_update_connection (my_sinfo,
- path2,
- connection,
- FALSE);
-
- nmtst_main_loop_run (loop, 100);
-
- _slist_to_array (&connections, nm_remote_settings_list_connections (settings));
-
- g_assert_cmpint (connections->len, ==, 3);
- n_found = nmtst_find_all_indexes (connections->pdata,
- connections->len,
- (gpointer *) ((const char *[]) { path0, path1, path2 }),
- 3,
- _test_connection_invalid_find_connections,
- NULL,
- idx);
- g_assert_cmpint (n_found, ==, 3);
- ASSERT_IDX (0);
- ASSERT_IDX (1);
- ASSERT_IDX (2);
- nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[0]]);
- nmtst_assert_connection_unnormalizable (connections->pdata[idx[1]], 0, 0);
- nmtst_assert_connection_unnormalizable (connections->pdata[idx[2]], 0, 0);
-
- /**************************************************************************
- * Modify the invalid connection again. Note that the connection stays
- * invisible (although it exists, and is valid).
- *************************************************************************/
-
- g_clear_object (&connection);
- connection = nmtst_create_minimal_connection ("test-connection-invalid-2", NULL, NM_SETTING_WIRED_SETTING_NAME, &s_con);
- nmtst_connection_normalize (connection);
- g_object_set (s_con,
- NM_SETTING_CONNECTION_ID, "test-connection-invalid-2z",
- NM_SETTING_CONNECTION_TYPE, "802-3-ethernet",
- NM_SETTING_CONNECTION_UUID, uuid2,
- NULL);
-
- nmtstc_service_update_connection (my_sinfo,
- path2,
- connection,
- FALSE);
-
- nmtst_main_loop_run (loop, 100);
-
- _slist_to_array (&connections, nm_remote_settings_list_connections (settings));
-
- g_assert_cmpint (connections->len, ==, 3);
- n_found = nmtst_find_all_indexes (connections->pdata,
- connections->len,
- (gpointer *) ((const char *[]) { path0, path1, path2 }),
- 3,
- _test_connection_invalid_find_connections,
- NULL,
- idx);
- g_assert_cmpint (n_found, ==, 3);
- ASSERT_IDX (0);
- ASSERT_IDX (1);
- ASSERT_IDX (2);
- nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[0]]);
- nmtst_assert_connection_unnormalizable (connections->pdata[idx[1]], 0, 0);
- nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[2]]);
-
- /**************************************************************************
- * Modify the invalid connection and make it valid
- *************************************************************************/
-
- g_clear_object (&connection);
- connection = nmtst_create_minimal_connection ("test-connection-invalid-1", NULL, NM_SETTING_WIRED_SETTING_NAME, &s_con);
- nmtst_connection_normalize (connection);
- g_object_set (s_con,
- NM_SETTING_CONNECTION_ID, "test-connection-invalid-1x",
- NM_SETTING_CONNECTION_TYPE, "802-3-ethernet",
- NM_SETTING_CONNECTION_UUID, nm_connection_get_uuid (connections->pdata[idx[1]]),
- NULL);
-
- nmtstc_service_update_connection (my_sinfo,
- path1,
- connection,
- FALSE);
-
- nmtst_main_loop_run (loop, 100);
-
- _slist_to_array (&connections, nm_remote_settings_list_connections (settings));
-
- g_assert_cmpint (connections->len, ==, 3);
- n_found = nmtst_find_all_indexes (connections->pdata,
- connections->len,
- (gpointer *) ((const char *[]) { path0, path1, path2 }),
- 3,
- _test_connection_invalid_find_connections,
- NULL,
- idx);
- g_assert_cmpint (n_found, ==, 3);
- ASSERT_IDX (0);
- ASSERT_IDX (1);
- ASSERT_IDX (2);
- nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[0]]);
- nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[1]]);
- nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[2]]);
- g_assert_cmpstr ("test-connection-invalid-1x", ==, nm_connection_get_id (connections->pdata[idx[1]]));
-
-#undef ASSERT_IDX
-}
-
-/*****************************************************************************/
-
-NMTST_DEFINE ();
-
-int
-main (int argc, char **argv)
-{
- nmtst_init (&argc, &argv, TRUE);
-
- loop = g_main_loop_new (NULL, FALSE);
-
- g_test_add_func ("/libnm-glib/device-added", test_device_added);
- g_test_add_func ("/libnm-glib/wifi-ap-added-removed", test_wifi_ap_added_removed);
- g_test_add_func ("/libnm-glib/wimax-nsp-added-removed", test_wimax_nsp_added_removed);
- g_test_add_func ("/libnm-glib/devices-array", test_devices_array);
- g_test_add_func ("/libnm-glib/client-manager-running", test_client_manager_running);
- g_test_add_func ("/libnm/connection/invalid", test_connection_invalid);
-
- return g_test_run ();
-}
-
diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c
deleted file mode 100644
index 031e83f81c..0000000000
--- a/libnm-glib/tests/test-remote-settings-client.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2010 - 2011 Red Hat, Inc.
- *
- */
-
-#include "nm-default.h"
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <string.h>
-#include <sys/types.h>
-#include <signal.h>
-
-#include "NetworkManager.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-wired.h"
-#include "nm-utils.h"
-
-#include "nm-remote-settings.h"
-
-#include "nm-test-libnm-utils.h"
-
-static NMTstcServiceInfo *sinfo;
-static NMRemoteSettings *settings = NULL;
-DBusGConnection *bus = NULL;
-NMRemoteConnection *remote = NULL;
-
-/*****************************************************************************/
-
-static void
-add_cb (NMRemoteSettings *s,
- NMRemoteConnection *connection,
- GError *error,
- gpointer user_data)
-{
- if (error)
- g_warning ("Add error: %s", error->message);
-
- *((gboolean *) user_data) = TRUE;
- remote = connection;
- g_object_add_weak_pointer (G_OBJECT (connection), (void **) &remote);
-}
-
-#define TEST_CON_ID "blahblahblah"
-
-static void
-test_add_connection (void)
-{
- gs_unref_object NMConnection *connection = NULL;
- NMSettingConnection *s_con;
- NMSettingWired *s_wired;
- char *uuid;
- gboolean success;
- time_t start, now;
- gboolean done = FALSE;
-
- if (!nmtstc_service_available (sinfo))
- return;
-
- connection = nm_connection_new ();
-
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
- uuid = nm_utils_uuid_generate ();
- g_object_set (G_OBJECT (s_con),
- NM_SETTING_CONNECTION_ID, TEST_CON_ID,
- NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
- NULL);
- g_free (uuid);
- nm_connection_add_setting (connection, NM_SETTING (s_con));
-
- s_wired = (NMSettingWired *) nm_setting_wired_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_wired));
-
- success = nm_remote_settings_add_connection (settings,
- connection,
- add_cb,
- &done);
- g_assert (success == TRUE);
-
- start = time (NULL);
- do {
- now = time (NULL);
- g_main_context_iteration (NULL, FALSE);
- } while ((done == FALSE) && (now - start < 5));
- g_assert (done == TRUE);
- g_assert (remote != NULL);
-
- /* Make sure the connection is the same as what we added */
- g_assert (nm_connection_compare (connection,
- NM_CONNECTION (remote),
- NM_SETTING_COMPARE_FLAG_EXACT) == TRUE);
-}
-
-/*****************************************************************************/
-
-static void
-set_visible_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- GError *error = NULL;
- gboolean success;
-
- success = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- g_assert_no_error (error);
- g_assert (success == TRUE);
-}
-
-static void
-invis_removed_cb (NMRemoteConnection *connection, gboolean *done)
-{
- *done = TRUE;
-}
-
-static void
-invis_has_settings_cb (NMSetting *setting,
- const char *key,
- const GValue *value,
- GParamFlags flags,
- gpointer user_data)
-{
- *((gboolean *) user_data) = TRUE;
-}
-
-static void
-test_make_invisible (void)
-{
- time_t start, now;
- GSList *list, *iter;
- DBusGProxy *proxy;
- gboolean done = FALSE, has_settings = FALSE;
- char *path;
-
- if (!nmtstc_service_available (sinfo))
- return;
-
- g_assert (remote != NULL);
-
- /* Listen for the remove event when the connection becomes invisible */
- g_signal_connect (remote, "removed", G_CALLBACK (invis_removed_cb), &done);
-
- path = g_strdup (nm_connection_get_path (NM_CONNECTION (remote)));
- proxy = dbus_g_proxy_new_for_name (bus,
- NM_DBUS_SERVICE,
- path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION);
- g_assert (proxy != NULL);
-
- /* Bypass the NMRemoteSettings object so we can test it independently */
- dbus_g_proxy_begin_call (proxy, "SetVisible", set_visible_cb, NULL, NULL,
- G_TYPE_BOOLEAN, FALSE, G_TYPE_INVALID);
-
- /* Wait for the connection to be removed */
- start = time (NULL);
- do {
- now = time (NULL);
- g_main_context_iteration (NULL, FALSE);
- } while ((done == FALSE) && (now - start < 5));
- g_assert (done == TRUE);
-
- g_assert (remote);
- g_signal_handlers_disconnect_by_func (remote, G_CALLBACK (invis_removed_cb), &done);
-
- /* Ensure NMRemoteSettings no longer has the connection */
- list = nm_remote_settings_list_connections (settings);
- for (iter = list; iter; iter = g_slist_next (iter)) {
- NMConnection *candidate = NM_CONNECTION (iter->data);
-
- g_assert ((gpointer) remote != (gpointer) candidate);
- g_assert (strcmp (path, nm_connection_get_path (candidate)) != 0);
- }
-
- /* And ensure the invisible connection no longer has any settings */
- g_assert (remote);
- nm_connection_for_each_setting_value (NM_CONNECTION (remote),
- invis_has_settings_cb,
- &has_settings);
- g_assert (has_settings == FALSE);
-
- g_free (path);
- g_object_unref (proxy);
-}
-
-/*****************************************************************************/
-
-static void
-vis_new_connection_cb (NMRemoteSettings *foo,
- NMRemoteConnection *connection,
- NMRemoteConnection **new)
-{
- *new = connection;
-}
-
-static void
-test_make_visible (void)
-{
- time_t start, now;
- GSList *list, *iter;
- DBusGProxy *proxy;
- gboolean found = FALSE;
- char *path;
- NMRemoteConnection *new = NULL;
-
- if (!nmtstc_service_available (sinfo))
- return;
-
- g_assert (remote != NULL);
-
- /* Wait for the new-connection signal when the connection is visible again */
- g_signal_connect (settings, NM_REMOTE_SETTINGS_NEW_CONNECTION,
- G_CALLBACK (vis_new_connection_cb), &new);
-
- path = g_strdup (nm_connection_get_path (NM_CONNECTION (remote)));
- proxy = dbus_g_proxy_new_for_name (bus,
- NM_DBUS_SERVICE,
- path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION);
- g_assert (proxy != NULL);
-
- /* Bypass the NMRemoteSettings object so we can test it independently */
- dbus_g_proxy_begin_call (proxy, "SetVisible", set_visible_cb, NULL, NULL,
- G_TYPE_BOOLEAN, TRUE, G_TYPE_INVALID);
-
- /* Wait for the settings service to announce the connection again */
- start = time (NULL);
- do {
- now = time (NULL);
- g_main_context_iteration (NULL, FALSE);
- } while ((new == NULL) && (now - start < 5));
-
- /* Ensure the new connection is the same as the one we made visible again */
- g_assert (new);
- g_assert (new == remote);
-
- g_signal_handlers_disconnect_by_func (settings, G_CALLBACK (vis_new_connection_cb), &new);
-
- /* Ensure NMRemoteSettings has the connection */
- list = nm_remote_settings_list_connections (settings);
- for (iter = list; iter; iter = g_slist_next (iter)) {
- NMConnection *candidate = NM_CONNECTION (iter->data);
-
- if ((gpointer) remote == (gpointer) candidate) {
- g_assert_cmpstr (path, ==, nm_connection_get_path (candidate));
- g_assert_cmpstr (TEST_CON_ID, ==, nm_connection_get_id (candidate));
- found = TRUE;
- break;
- }
- }
- g_slist_free (list);
- g_assert (found == TRUE);
-
- g_free (path);
- g_object_unref (proxy);
-}
-
-/*****************************************************************************/
-
-static void
-deleted_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- GError *error = NULL;
- gboolean success;
-
- success = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- g_assert_no_error (error);
- g_assert (success == TRUE);
-}
-
-static void
-removed_cb (NMRemoteConnection *connection, gboolean *done)
-{
- *done = TRUE;
-}
-
-static void
-test_remove_connection (void)
-{
- NMRemoteConnection *connection;
- time_t start, now;
- GSList *list, *iter;
- DBusGProxy *proxy;
- gboolean done = FALSE;
- char *path;
-
- if (!nmtstc_service_available (sinfo))
- return;
-
- /* Find a connection to delete */
- list = nm_remote_settings_list_connections (settings);
- g_assert_cmpint (g_slist_length (list), >, 0);
-
- connection = NM_REMOTE_CONNECTION (list->data);
- g_slist_free (list);
- g_assert (connection);
- g_assert (remote == connection);
- path = g_strdup (nm_connection_get_path (NM_CONNECTION (connection)));
- g_signal_connect (connection, "removed", G_CALLBACK (removed_cb), &done);
-
- proxy = dbus_g_proxy_new_for_name (bus,
- NM_DBUS_SERVICE,
- path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION);
- g_assert (proxy != NULL);
-
- /* Bypass the NMRemoteSettings object so we can test it independently */
- dbus_g_proxy_begin_call (proxy, "Delete", deleted_cb, NULL, NULL, G_TYPE_INVALID);
-
- start = time (NULL);
- do {
- now = time (NULL);
- g_main_context_iteration (NULL, FALSE);
- } while ((done == FALSE) && (now - start < 5));
- g_assert (done == TRUE);
-
- g_assert (!remote);
-
- /* Ensure NMRemoteSettings no longer has the connection */
- list = nm_remote_settings_list_connections (settings);
- for (iter = list; iter; iter = g_slist_next (iter)) {
- NMConnection *candidate = NM_CONNECTION (iter->data);
-
- g_assert ((gpointer) connection != (gpointer) candidate);
- g_assert_cmpstr (path, ==, nm_connection_get_path (candidate));
- }
- g_slist_free (list);
-
- g_free (path);
- g_object_unref (proxy);
-}
-
-/*****************************************************************************/
-
-static GMainLoop *loop;
-
-static gboolean
-loop_quit (gpointer user_data)
-{
- g_main_loop_quit (loop);
- return G_SOURCE_REMOVE;
-}
-
-static void
-settings_service_running_changed (GObject *client,
- GParamSpec *pspec,
- gpointer user_data)
-{
- int *running_changed = user_data;
-
- (*running_changed)++;
- g_main_loop_quit (loop);
-}
-
-static void
-test_service_running (void)
-{
- gs_unref_object NMRemoteSettings *settings2 = NULL;
- guint quit_id;
- int running_changed = 0;
- gboolean running;
-
- if (!nmtstc_service_available (sinfo))
- return;
-
- loop = g_main_loop_new (NULL, FALSE);
-
- g_object_get (G_OBJECT (settings),
- NM_REMOTE_SETTINGS_SERVICE_RUNNING, &running,
- NULL);
- g_assert (running == TRUE);
-
- /* Now kill the test service. */
- nmtstc_service_cleanup (sinfo);
-
- settings2 = nm_remote_settings_new (bus);
-
- /* settings2 should know that NM is running, but the previously-created
- * settings hasn't gotten the news yet.
- */
- g_object_get (G_OBJECT (settings2),
- NM_REMOTE_SETTINGS_SERVICE_RUNNING, &running,
- NULL);
- g_assert (running == FALSE);
- g_object_get (G_OBJECT (settings),
- NM_REMOTE_SETTINGS_SERVICE_RUNNING, &running,
- NULL);
- g_assert (running == TRUE);
-
- g_signal_connect (settings, "notify::" NM_REMOTE_SETTINGS_SERVICE_RUNNING,
- G_CALLBACK (settings_service_running_changed), &running_changed);
- quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
- g_assert_cmpint (running_changed, ==, 1);
- g_source_remove (quit_id);
-
- g_object_get (G_OBJECT (settings2),
- NM_REMOTE_SETTINGS_SERVICE_RUNNING, &running,
- NULL);
- g_assert (running == FALSE);
-
- /* Now restart it */
- sinfo = nmtstc_service_init ();
- g_assert (nmtstc_service_available (sinfo));
-
- quit_id = g_timeout_add_seconds (5, loop_quit, loop);
- g_main_loop_run (loop);
- g_assert_cmpint (running_changed, ==, 2);
- g_source_remove (quit_id);
-
- g_object_get (G_OBJECT (settings2),
- NM_REMOTE_SETTINGS_SERVICE_RUNNING, &running,
- NULL);
- g_assert (running == TRUE);
-}
-
-/*****************************************************************************/
-
-NMTST_DEFINE ();
-
-int
-main (int argc, char **argv)
-{
- int ret;
- GError *error = NULL;
-
- nmtst_init (&argc, &argv, TRUE);
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- g_assert_no_error (error);
-
- sinfo = nmtstc_service_init ();
-
- settings = nmtstc_nm_remote_settings_new ();
-
- /* FIXME: these tests assume that they get run in order, but g_test_run()
- * does not actually guarantee that!
- */
- g_test_add_func ("/remote_settings/add_connection", test_add_connection);
- g_test_add_func ("/remote_settings/make_invisible", test_make_invisible);
- g_test_add_func ("/remote_settings/make_visible", test_make_visible);
- g_test_add_func ("/remote_settings/remove_connection", test_remove_connection);
- g_test_add_func ("/remote_settings/service_running", test_service_running);
-
- ret = g_test_run ();
-
- nmtstc_service_cleanup (sinfo);
- g_object_unref (settings);
- dbus_g_connection_unref (bus);
-
- return ret;
-}
-
diff --git a/libnm-util/COPYING b/libnm-util/COPYING
deleted file mode 100644
index 2ec1380e34..0000000000
--- a/libnm-util/COPYING
+++ /dev/null
@@ -1,488 +0,0 @@
-This library 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 of the License, or (at your option) any later version.
-
-
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
-
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-
- GNU LIBRARY GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- c) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- d) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/libnm-util/NetworkManager.h b/libnm-util/NetworkManager.h
deleted file mode 100644
index b4f8b97f98..0000000000
--- a/libnm-util/NetworkManager.h
+++ /dev/null
@@ -1,555 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2004 - 2014 Red Hat, Inc.
- */
-
-/* Definitions related to NetworkManager's D-Bus interfaces.
- *
- * Note that although this header is installed as part of libnm-util, it is also
- * used by some external code that does not link to libnm-util.
- */
-
-#ifndef NETWORK_MANAGER_H
-#define NETWORK_MANAGER_H
-
-/* This header must not include glib or libnm. */
-
-#include "nm-version-macros.h"
-
-/*
- * dbus services details
- */
-#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
-
-#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
-#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
-#define NM_DBUS_INTERFACE_DEVICE NM_DBUS_INTERFACE ".Device"
-#define NM_DBUS_INTERFACE_DEVICE_WIRED NM_DBUS_INTERFACE_DEVICE ".Wired"
-#define NM_DBUS_INTERFACE_DEVICE_ADSL NM_DBUS_INTERFACE_DEVICE ".Adsl"
-#define NM_DBUS_INTERFACE_DEVICE_WIRELESS NM_DBUS_INTERFACE_DEVICE ".Wireless"
-#define NM_DBUS_INTERFACE_DEVICE_BLUETOOTH NM_DBUS_INTERFACE_DEVICE ".Bluetooth"
-#define NM_DBUS_INTERFACE_DEVICE_OLPC_MESH NM_DBUS_INTERFACE_DEVICE ".OlpcMesh"
-#define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint"
-#define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint"
-#define NM_DBUS_INTERFACE_DEVICE_MODEM NM_DBUS_INTERFACE_DEVICE ".Modem"
-#define NM_DBUS_INTERFACE_DEVICE_WIMAX NM_DBUS_INTERFACE_DEVICE ".WiMax"
-#define NM_DBUS_INTERFACE_WIMAX_NSP NM_DBUS_INTERFACE ".WiMax.Nsp"
-#define NM_DBUS_PATH_WIMAX_NSP NM_DBUS_PATH "/Nsp"
-#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
-#define NM_DBUS_INTERFACE_IP4_CONFIG NM_DBUS_INTERFACE ".IP4Config"
-#define NM_DBUS_INTERFACE_DHCP4_CONFIG NM_DBUS_INTERFACE ".DHCP4Config"
-#define NM_DBUS_INTERFACE_IP6_CONFIG NM_DBUS_INTERFACE ".IP6Config"
-#define NM_DBUS_INTERFACE_DHCP6_CONFIG NM_DBUS_INTERFACE ".DHCP6Config"
-#define NM_DBUS_INTERFACE_DEVICE_INFINIBAND NM_DBUS_INTERFACE_DEVICE ".Infiniband"
-#define NM_DBUS_INTERFACE_DEVICE_BOND NM_DBUS_INTERFACE_DEVICE ".Bond"
-#define NM_DBUS_INTERFACE_DEVICE_TEAM NM_DBUS_INTERFACE_DEVICE ".Team"
-#define NM_DBUS_INTERFACE_DEVICE_VLAN NM_DBUS_INTERFACE_DEVICE ".Vlan"
-#define NM_DBUS_INTERFACE_DEVICE_BRIDGE NM_DBUS_INTERFACE_DEVICE ".Bridge"
-#define NM_DBUS_INTERFACE_DEVICE_GENERIC NM_DBUS_INTERFACE_DEVICE ".Generic"
-#define NM_DBUS_INTERFACE_DEVICE_VETH NM_DBUS_INTERFACE_DEVICE ".Veth"
-#define NM_DBUS_INTERFACE_DEVICE_TUN NM_DBUS_INTERFACE_DEVICE ".Tun"
-#define NM_DBUS_INTERFACE_DEVICE_MACVLAN NM_DBUS_INTERFACE_DEVICE ".Macvlan"
-#define NM_DBUS_INTERFACE_DEVICE_VXLAN NM_DBUS_INTERFACE_DEVICE ".Vxlan"
-#define NM_DBUS_INTERFACE_DEVICE_GRE NM_DBUS_INTERFACE_DEVICE ".Gre"
-
-#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManager.Settings"
-#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
-
-#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManager.Settings.Connection"
-#define NM_DBUS_PATH_SETTINGS_CONNECTION "/org/freedesktop/NetworkManager/Settings/Connection"
-#define NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS "org.freedesktop.NetworkManager.Settings.Connection.Secrets"
-
-#define NM_DBUS_INTERFACE_AGENT_MANAGER NM_DBUS_INTERFACE ".AgentManager"
-#define NM_DBUS_PATH_AGENT_MANAGER "/org/freedesktop/NetworkManager/AgentManager"
-
-#define NM_DBUS_INTERFACE_SECRET_AGENT NM_DBUS_INTERFACE ".SecretAgent"
-#define NM_DBUS_PATH_SECRET_AGENT "/org/freedesktop/NetworkManager/SecretAgent"
-
-/**
- * NMState:
- * @NM_STATE_UNKNOWN: networking state is unknown
- * @NM_STATE_ASLEEP: networking is not enabled
- * @NM_STATE_DISCONNECTED: there is no active network connection
- * @NM_STATE_DISCONNECTING: network connections are being cleaned up
- * @NM_STATE_CONNECTING: a network connection is being started
- * @NM_STATE_CONNECTED_LOCAL: there is only local IPv4 and/or IPv6 connectivity
- * @NM_STATE_CONNECTED_SITE: there is only site-wide IPv4 and/or IPv6 connectivity
- * @NM_STATE_CONNECTED_GLOBAL: there is global IPv4 and/or IPv6 Internet connectivity
- *
- * #NMState values indicate the current overall networking state.
- **/
-typedef enum {
- NM_STATE_UNKNOWN = 0,
- NM_STATE_ASLEEP = 10,
- NM_STATE_DISCONNECTED = 20,
- NM_STATE_DISCONNECTING = 30,
- NM_STATE_CONNECTING = 40,
- NM_STATE_CONNECTED_LOCAL = 50,
- NM_STATE_CONNECTED_SITE = 60,
- NM_STATE_CONNECTED_GLOBAL = 70,
-} NMState;
-
-/* For backwards compat */
-#define NM_STATE_CONNECTED NM_STATE_CONNECTED_GLOBAL
-
-/**
- * NMConnectivityState:
- * @NM_CONNECTIVITY_UNKNOWN: Network connectivity is unknown.
- * @NM_CONNECTIVITY_NONE: The host is not connected to any network.
- * @NM_CONNECTIVITY_PORTAL: The host is behind a captive portal and
- * cannot reach the full Internet.
- * @NM_CONNECTIVITY_LIMITED: The host is connected to a network, but
- * does not appear to be able to reach the full Internet.
- * @NM_CONNECTIVITY_FULL: The host is connected to a network, and
- * appears to be able to reach the full Internet.
- *
- * Since: 0.9.8.6
- */
-typedef enum {
- NM_CONNECTIVITY_UNKNOWN = 0,
- NM_CONNECTIVITY_NONE = 1,
- NM_CONNECTIVITY_PORTAL = 2,
- NM_CONNECTIVITY_LIMITED = 3,
- NM_CONNECTIVITY_FULL = 4,
-} NMConnectivityState;
-
-/**
- * NMDeviceType:
- * @NM_DEVICE_TYPE_UNKNOWN: unknown device
- * @NM_DEVICE_TYPE_GENERIC: generic support for unrecognized device types
- * @NM_DEVICE_TYPE_ETHERNET: a wired ethernet device
- * @NM_DEVICE_TYPE_WIFI: an 802.11 Wi-Fi device
- * @NM_DEVICE_TYPE_UNUSED1: not used
- * @NM_DEVICE_TYPE_UNUSED2: not used
- * @NM_DEVICE_TYPE_BT: a Bluetooth device supporting PAN or DUN access protocols
- * @NM_DEVICE_TYPE_OLPC_MESH: an OLPC XO mesh networking device
- * @NM_DEVICE_TYPE_WIMAX: an 802.16e Mobile WiMAX broadband device
- * @NM_DEVICE_TYPE_MODEM: a modem supporting analog telephone, CDMA/EVDO,
- * GSM/UMTS, or LTE network access protocols
- * @NM_DEVICE_TYPE_INFINIBAND: an IP-over-InfiniBand device
- * @NM_DEVICE_TYPE_BOND: a bond master interface
- * @NM_DEVICE_TYPE_VLAN: an 802.1Q VLAN interface
- * @NM_DEVICE_TYPE_ADSL: ADSL modem
- * @NM_DEVICE_TYPE_BRIDGE: a bridge master interface
- * @NM_DEVICE_TYPE_TEAM: a team master interface
- * @NM_DEVICE_TYPE_TUN: a TUN/TAP interface
- * @NM_DEVICE_TYPE_IP_TUNNEL: an IP tunnel interface
- * @NM_DEVICE_TYPE_MACVLAN: a MACVLAN interface
- * @NM_DEVICE_TYPE_VXLAN: a VXLAN interface
- * @NM_DEVICE_TYPE_VETH: a VETH interface
- *
- * #NMDeviceType values indicate the type of hardware represented by
- * an #NMDevice.
- **/
-typedef enum {
- NM_DEVICE_TYPE_UNKNOWN = 0,
- NM_DEVICE_TYPE_ETHERNET = 1,
- NM_DEVICE_TYPE_WIFI = 2,
- NM_DEVICE_TYPE_UNUSED1 = 3,
- NM_DEVICE_TYPE_UNUSED2 = 4,
- NM_DEVICE_TYPE_BT = 5, /* Bluetooth */
- NM_DEVICE_TYPE_OLPC_MESH = 6,
- NM_DEVICE_TYPE_WIMAX = 7,
- NM_DEVICE_TYPE_MODEM = 8,
- NM_DEVICE_TYPE_INFINIBAND = 9,
- NM_DEVICE_TYPE_BOND = 10,
- NM_DEVICE_TYPE_VLAN = 11,
- NM_DEVICE_TYPE_ADSL = 12,
- NM_DEVICE_TYPE_BRIDGE = 13,
- NM_DEVICE_TYPE_GENERIC = 14,
- NM_DEVICE_TYPE_TEAM = 15,
- NM_DEVICE_TYPE_TUN = 16,
- NM_DEVICE_TYPE_IP_TUNNEL = 17,
- NM_DEVICE_TYPE_MACVLAN = 18,
- NM_DEVICE_TYPE_VXLAN = 19,
- NM_DEVICE_TYPE_VETH = 20,
-} NMDeviceType;
-
-/**
- * NMDeviceCapabilities:
- * @NM_DEVICE_CAP_NONE: device has no special capabilities
- * @NM_DEVICE_CAP_NM_SUPPORTED: NetworkManager supports this device
- * @NM_DEVICE_CAP_CARRIER_DETECT: this device can indicate carrier status
- * @NM_DEVICE_CAP_IS_SOFTWARE: this device is a software device
- *
- * General device capability flags.
- **/
-typedef enum { /*< flags >*/
- NM_DEVICE_CAP_NONE = 0x00000000,
- NM_DEVICE_CAP_NM_SUPPORTED = 0x00000001,
- NM_DEVICE_CAP_CARRIER_DETECT = 0x00000002,
- NM_DEVICE_CAP_IS_SOFTWARE = 0x00000004,
-} NMDeviceCapabilities;
-
-/**
- * NMDeviceWifiCapabilities:
- * @NM_WIFI_DEVICE_CAP_NONE: device has no encryption/authentication capabilities
- * @NM_WIFI_DEVICE_CAP_CIPHER_WEP40: device supports 40/64-bit WEP encryption
- * @NM_WIFI_DEVICE_CAP_CIPHER_WEP104: device supports 104/128-bit WEP encryption
- * @NM_WIFI_DEVICE_CAP_CIPHER_TKIP: device supports TKIP encryption
- * @NM_WIFI_DEVICE_CAP_CIPHER_CCMP: device supports AES/CCMP encryption
- * @NM_WIFI_DEVICE_CAP_WPA: device supports WPA1 authentication
- * @NM_WIFI_DEVICE_CAP_RSN: device supports WPA2/RSN authentication
- * @NM_WIFI_DEVICE_CAP_AP: device supports Access Point mode
- * @NM_WIFI_DEVICE_CAP_ADHOC: device supports Ad-Hoc mode
- * @NM_WIFI_DEVICE_CAP_FREQ_VALID: device reports frequency capabilities
- * @NM_WIFI_DEVICE_CAP_FREQ_2GHZ: device supports 2.4GHz frequencies
- * @NM_WIFI_DEVICE_CAP_FREQ_5GHZ: device supports 5GHz frequencies
- *
- * 802.11 specific device encryption and authentication capabilities.
- **/
-typedef enum { /*< flags >*/
- NM_WIFI_DEVICE_CAP_NONE = 0x00000000,
- NM_WIFI_DEVICE_CAP_CIPHER_WEP40 = 0x00000001,
- NM_WIFI_DEVICE_CAP_CIPHER_WEP104 = 0x00000002,
- NM_WIFI_DEVICE_CAP_CIPHER_TKIP = 0x00000004,
- NM_WIFI_DEVICE_CAP_CIPHER_CCMP = 0x00000008,
- NM_WIFI_DEVICE_CAP_WPA = 0x00000010,
- NM_WIFI_DEVICE_CAP_RSN = 0x00000020,
- NM_WIFI_DEVICE_CAP_AP = 0x00000040,
- NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080,
- NM_WIFI_DEVICE_CAP_FREQ_VALID = 0x00000100,
- NM_WIFI_DEVICE_CAP_FREQ_2GHZ = 0x00000200,
- NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000400,
-} NMDeviceWifiCapabilities;
-
-/**
- * NM80211ApFlags:
- * @NM_802_11_AP_FLAGS_NONE: access point has no special capabilities
- * @NM_802_11_AP_FLAGS_PRIVACY: access point requires authentication and
- * encryption (usually means WEP)
- *
- * 802.11 access point flags.
- **/
-typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/
- NM_802_11_AP_FLAGS_NONE = 0x00000000,
- NM_802_11_AP_FLAGS_PRIVACY = 0x00000001,
-} NM80211ApFlags;
-
-/**
- * NM80211ApSecurityFlags:
- * @NM_802_11_AP_SEC_NONE: the access point has no special security requirements
- * @NM_802_11_AP_SEC_PAIR_WEP40: 40/64-bit WEP is supported for
- * pairwise/unicast encryption
- * @NM_802_11_AP_SEC_PAIR_WEP104: 104/128-bit WEP is supported for
- * pairwise/unicast encryption
- * @NM_802_11_AP_SEC_PAIR_TKIP: TKIP is supported for pairwise/unicast encryption
- * @NM_802_11_AP_SEC_PAIR_CCMP: AES/CCMP is supported for pairwise/unicast encryption
- * @NM_802_11_AP_SEC_GROUP_WEP40: 40/64-bit WEP is supported for group/broadcast
- * encryption
- * @NM_802_11_AP_SEC_GROUP_WEP104: 104/128-bit WEP is supported for
- * group/broadcast encryption
- * @NM_802_11_AP_SEC_GROUP_TKIP: TKIP is supported for group/broadcast encryption
- * @NM_802_11_AP_SEC_GROUP_CCMP: AES/CCMP is supported for group/broadcast
- * encryption
- * @NM_802_11_AP_SEC_KEY_MGMT_PSK: WPA/RSN Pre-Shared Key encryption is
- * supported
- * @NM_802_11_AP_SEC_KEY_MGMT_802_1X: 802.1x authentication and key management
- * is supported
- *
- * 802.11 access point security and authentication flags. These flags describe
- * the current security requirements of an access point as determined from the
- * access point's beacon.
- **/
-typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/
- NM_802_11_AP_SEC_NONE = 0x00000000,
- NM_802_11_AP_SEC_PAIR_WEP40 = 0x00000001,
- NM_802_11_AP_SEC_PAIR_WEP104 = 0x00000002,
- NM_802_11_AP_SEC_PAIR_TKIP = 0x00000004,
- NM_802_11_AP_SEC_PAIR_CCMP = 0x00000008,
- NM_802_11_AP_SEC_GROUP_WEP40 = 0x00000010,
- NM_802_11_AP_SEC_GROUP_WEP104 = 0x00000020,
- NM_802_11_AP_SEC_GROUP_TKIP = 0x00000040,
- NM_802_11_AP_SEC_GROUP_CCMP = 0x00000080,
- NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100,
- NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200,
-} NM80211ApSecurityFlags;
-
-/**
- * NM80211Mode:
- * @NM_802_11_MODE_UNKNOWN: the device or access point mode is unknown
- * @NM_802_11_MODE_ADHOC: for both devices and access point objects, indicates
- * the object is part of an Ad-Hoc 802.11 network without a central
- * coordinating access point.
- * @NM_802_11_MODE_INFRA: the device or access point is in infrastructure mode.
- * For devices, this indicates the device is an 802.11 client/station. For
- * access point objects, this indicates the object is an access point that
- * provides connectivity to clients.
- * @NM_802_11_MODE_AP: the device is an access point/hotspot. Not valid for
- * access point objects; used only for hotspot mode on the local machine.
- *
- * Indicates the 802.11 mode an access point or device is currently in.
- **/
-typedef enum { /*< underscore_name=nm_802_11_mode >*/
- NM_802_11_MODE_UNKNOWN = 0,
- NM_802_11_MODE_ADHOC = 1,
- NM_802_11_MODE_INFRA = 2,
- NM_802_11_MODE_AP = 3,
-} NM80211Mode;
-
-/**
- * NMBluetoothCapabilities:
- * @NM_BT_CAPABILITY_NONE: device has no usable capabilities
- * @NM_BT_CAPABILITY_DUN: device provides Dial-Up Networking capability
- * @NM_BT_CAPABILITY_NAP: device provides Network Access Point capability
- *
- * #NMBluetoothCapabilities values indicate the usable capabilities of a
- * Bluetooth device.
- **/
-typedef enum { /*< flags >*/
- NM_BT_CAPABILITY_NONE = 0x00000000,
- NM_BT_CAPABILITY_DUN = 0x00000001,
- NM_BT_CAPABILITY_NAP = 0x00000002,
-} NMBluetoothCapabilities;
-
-/**
- * NMDeviceModemCapabilities:
- * @NM_DEVICE_MODEM_CAPABILITY_NONE: modem has no usable capabilities
- * @NM_DEVICE_MODEM_CAPABILITY_POTS: modem uses the analog wired telephone
- * network and is not a wireless/cellular device
- * @NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO: modem supports at least one of CDMA
- * 1xRTT, EVDO revision 0, EVDO revision A, or EVDO revision B
- * @NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS: modem supports at least one of GSM,
- * GPRS, EDGE, UMTS, HSDPA, HSUPA, or HSPA+ packet switched data capability
- * @NM_DEVICE_MODEM_CAPABILITY_LTE: modem has LTE data capability
- *
- * #NMDeviceModemCapabilities values indicate the generic radio access
- * technology families a modem device supports. For more information on the
- * specific access technologies the device supports use the ModemManager D-Bus
- * API.
- **/
-typedef enum { /*< flags >*/
- NM_DEVICE_MODEM_CAPABILITY_NONE = 0x00000000,
- NM_DEVICE_MODEM_CAPABILITY_POTS = 0x00000001,
- NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 0x00000002,
- NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 0x00000004,
- NM_DEVICE_MODEM_CAPABILITY_LTE = 0x00000008,
-} NMDeviceModemCapabilities;
-
-/**
- * NMDeviceState:
- * @NM_DEVICE_STATE_UNKNOWN: the device's state is unknown
- * @NM_DEVICE_STATE_UNMANAGED: the device is recognized, but not managed by
- * NetworkManager
- * @NM_DEVICE_STATE_UNAVAILABLE: the device is managed by NetworkManager, but
- * is not available for use. Reasons may include the wireless switched off,
- * missing firmware, no ethernet carrier, missing supplicant or modem manager,
- * etc.
- * @NM_DEVICE_STATE_DISCONNECTED: the device can be activated, but is currently
- * idle and not connected to a network.
- * @NM_DEVICE_STATE_PREPARE: the device is preparing the connection to the
- * network. This may include operations like changing the MAC address,
- * setting physical link properties, and anything else required to connect
- * to the requested network.
- * @NM_DEVICE_STATE_CONFIG: the device is connecting to the requested network.
- * This may include operations like associating with the Wi-Fi AP, dialing
- * the modem, connecting to the remote Bluetooth device, etc.
- * @NM_DEVICE_STATE_NEED_AUTH: the device requires more information to continue
- * connecting to the requested network. This includes secrets like WiFi
- * passphrases, login passwords, PIN codes, etc.
- * @NM_DEVICE_STATE_IP_CONFIG: the device is requesting IPv4 and/or IPv6
- * addresses and routing information from the network.
- * @NM_DEVICE_STATE_IP_CHECK: the device is checking whether further action is
- * required for the requested network connection. This may include checking
- * whether only local network access is available, whether a captive portal
- * is blocking access to the Internet, etc.
- * @NM_DEVICE_STATE_SECONDARIES: the device is waiting for a secondary
- * connection (like a VPN) which must activated before the device can be
- * activated
- * @NM_DEVICE_STATE_ACTIVATED: the device has a network connection, either local
- * or global.
- * @NM_DEVICE_STATE_DEACTIVATING: a disconnection from the current network
- * connection was requested, and the device is cleaning up resources used for
- * that connection. The network connection may still be valid.
- * @NM_DEVICE_STATE_FAILED: the device failed to connect to the requested
- * network and is cleaning up the connection request
- **/
-typedef enum {
- NM_DEVICE_STATE_UNKNOWN = 0,
- NM_DEVICE_STATE_UNMANAGED = 10,
- NM_DEVICE_STATE_UNAVAILABLE = 20,
- NM_DEVICE_STATE_DISCONNECTED = 30,
- NM_DEVICE_STATE_PREPARE = 40,
- NM_DEVICE_STATE_CONFIG = 50,
- NM_DEVICE_STATE_NEED_AUTH = 60,
- NM_DEVICE_STATE_IP_CONFIG = 70,
- NM_DEVICE_STATE_IP_CHECK = 80,
- NM_DEVICE_STATE_SECONDARIES = 90,
- NM_DEVICE_STATE_ACTIVATED = 100,
- NM_DEVICE_STATE_DEACTIVATING = 110,
- NM_DEVICE_STATE_FAILED = 120,
-} NMDeviceState;
-
-/**
- * NMDeviceStateReason:
- * @NM_DEVICE_STATE_REASON_NONE: No reason given
- * @NM_DEVICE_STATE_REASON_UNKNOWN: Unknown error
- * @NM_DEVICE_STATE_REASON_NOW_MANAGED: Device is now managed
- * @NM_DEVICE_STATE_REASON_NOW_UNMANAGED: Device is now unmanaged
- * @NM_DEVICE_STATE_REASON_CONFIG_FAILED: The device could not be readied for configuration
- * @NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE: IP configuration could not be reserved (no available address, timeout, etc)
- * @NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED: The IP config is no longer valid
- * @NM_DEVICE_STATE_REASON_NO_SECRETS: Secrets were required, but not provided
- * @NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT: 802.1x supplicant disconnected
- * @NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED: 802.1x supplicant configuration failed
- * @NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED: 802.1x supplicant failed
- * @NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT: 802.1x supplicant took too long to authenticate
- * @NM_DEVICE_STATE_REASON_PPP_START_FAILED: PPP service failed to start
- * @NM_DEVICE_STATE_REASON_PPP_DISCONNECT: PPP service disconnected
- * @NM_DEVICE_STATE_REASON_PPP_FAILED: PPP failed
- * @NM_DEVICE_STATE_REASON_DHCP_START_FAILED: DHCP client failed to start
- * @NM_DEVICE_STATE_REASON_DHCP_ERROR: DHCP client error
- * @NM_DEVICE_STATE_REASON_DHCP_FAILED: DHCP client failed
- * @NM_DEVICE_STATE_REASON_SHARED_START_FAILED: Shared connection service failed to start
- * @NM_DEVICE_STATE_REASON_SHARED_FAILED: Shared connection service failed
- * @NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED: AutoIP service failed to start
- * @NM_DEVICE_STATE_REASON_AUTOIP_ERROR: AutoIP service error
- * @NM_DEVICE_STATE_REASON_AUTOIP_FAILED: AutoIP service failed
- * @NM_DEVICE_STATE_REASON_MODEM_BUSY: The line is busy
- * @NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE: No dial tone
- * @NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER: No carrier could be established
- * @NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT: The dialing request timed out
- * @NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED: The dialing attempt failed
- * @NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED: Modem initialization failed
- * @NM_DEVICE_STATE_REASON_GSM_APN_FAILED: Failed to select the specified APN
- * @NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING: Not searching for networks
- * @NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED: Network registration denied
- * @NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT: Network registration timed out
- * @NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED: Failed to register with the requested network
- * @NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED: PIN check failed
- * @NM_DEVICE_STATE_REASON_FIRMWARE_MISSING: Necessary firmware for the device may be missing
- * @NM_DEVICE_STATE_REASON_REMOVED: The device was removed
- * @NM_DEVICE_STATE_REASON_SLEEPING: NetworkManager went to sleep
- * @NM_DEVICE_STATE_REASON_CONNECTION_REMOVED: The device's active connection disappeared
- * @NM_DEVICE_STATE_REASON_USER_REQUESTED: Device disconnected by user or client
- * @NM_DEVICE_STATE_REASON_CARRIER: Carrier/link changed
- * @NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED: The device's existing connection was assumed
- * @NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE: The supplicant is now available
- * @NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND: The modem could not be found
- * @NM_DEVICE_STATE_REASON_BT_FAILED: The Bluetooth connection failed or timed out
- * @NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED: GSM Modem's SIM Card not inserted
- * @NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED: GSM Modem's SIM Pin required
- * @NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED: GSM Modem's SIM Puk required
- * @NM_DEVICE_STATE_REASON_GSM_SIM_WRONG: GSM Modem's SIM wrong
- * @NM_DEVICE_STATE_REASON_INFINIBAND_MODE: InfiniBand device does not support connected mode
- * @NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED: A dependency of the connection failed
- * @NM_DEVICE_STATE_REASON_BR2684_FAILED: Problem with the RFC 2684 Ethernet over ADSL bridge
- * @NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE: ModemManager not running
- * @NM_DEVICE_STATE_REASON_SSID_NOT_FOUND: The Wi-Fi network could not be found
- * @NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED: A secondary connection of the base connection failed
- * @NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED: DCB or FCoE setup failed
- * @NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED: teamd control failed
- * @NM_DEVICE_STATE_REASON_MODEM_FAILED: Modem failed or no longer available
- * @NM_DEVICE_STATE_REASON_MODEM_AVAILABLE: Modem now ready and available
- * @NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT: SIM PIN was incorrect
- * @NM_DEVICE_STATE_REASON_NEW_ACTIVATION: New connection activation was enqueued
- * @NM_DEVICE_STATE_REASON_PARENT_CHANGED: the device's parent changed
- * @NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED: the device parent's management changed
- *
- * Device state change reason codes
- */
-typedef enum {
- NM_DEVICE_STATE_REASON_NONE = 0,
- NM_DEVICE_STATE_REASON_UNKNOWN = 1,
- NM_DEVICE_STATE_REASON_NOW_MANAGED = 2,
- NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3,
- NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4,
- NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5,
- NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6,
- NM_DEVICE_STATE_REASON_NO_SECRETS = 7,
- NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8,
- NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9,
- NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10,
- NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11,
- NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12,
- NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13,
- NM_DEVICE_STATE_REASON_PPP_FAILED = 14,
- NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15,
- NM_DEVICE_STATE_REASON_DHCP_ERROR = 16,
- NM_DEVICE_STATE_REASON_DHCP_FAILED = 17,
- NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18,
- NM_DEVICE_STATE_REASON_SHARED_FAILED = 19,
- NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20,
- NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21,
- NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22,
- NM_DEVICE_STATE_REASON_MODEM_BUSY = 23,
- NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24,
- NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25,
- NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26,
- NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27,
- NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28,
- NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING = 30,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33,
- NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34,
- NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35,
- NM_DEVICE_STATE_REASON_REMOVED = 36,
- NM_DEVICE_STATE_REASON_SLEEPING = 37,
- NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38,
- NM_DEVICE_STATE_REASON_USER_REQUESTED = 39,
- NM_DEVICE_STATE_REASON_CARRIER = 40,
- NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41,
- NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42,
- NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43,
- NM_DEVICE_STATE_REASON_BT_FAILED = 44,
- NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45,
- NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46,
- NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47,
- NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48,
- NM_DEVICE_STATE_REASON_INFINIBAND_MODE = 49,
- NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED = 50,
- NM_DEVICE_STATE_REASON_BR2684_FAILED = 51,
- NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52,
- NM_DEVICE_STATE_REASON_SSID_NOT_FOUND = 53,
- NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED = 54,
- NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED = 55,
- NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED = 56,
- NM_DEVICE_STATE_REASON_MODEM_FAILED = 57,
- NM_DEVICE_STATE_REASON_MODEM_AVAILABLE = 58,
- NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT = 59,
- NM_DEVICE_STATE_REASON_NEW_ACTIVATION = 60,
- NM_DEVICE_STATE_REASON_PARENT_CHANGED = 61,
- NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62,
-
- NM_DEVICE_STATE_REASON_LAST = 0xFFFF,
-} NMDeviceStateReason;
-
-/**
- * NMActiveConnectionState:
- * @NM_ACTIVE_CONNECTION_STATE_UNKNOWN: the state of the connection is unknown
- * @NM_ACTIVE_CONNECTION_STATE_ACTIVATING: a network connection is being prepared
- * @NM_ACTIVE_CONNECTION_STATE_ACTIVATED: there is a connection to the network
- * @NM_ACTIVE_CONNECTION_STATE_DEACTIVATING: the network connection is being
- * torn down and cleaned up
- * @NM_ACTIVE_CONNECTION_STATE_DEACTIVATED: the network connection is disconnected
- * and will be removed
- *
- * #NMActiveConnectionState values indicate the state of a connection to a
- * specific network while it is starting, connected, or disconnecting from that
- * network.
- **/
-typedef enum {
- NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATING = 1,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATING = 3,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4,
-} NMActiveConnectionState;
-
-#endif /* NETWORK_MANAGER_H */
diff --git a/libnm-util/NetworkManagerVPN.h b/libnm-util/NetworkManagerVPN.h
deleted file mode 100644
index 39a5d9613b..0000000000
--- a/libnm-util/NetworkManagerVPN.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2004 Red Hat, Inc.
- */
-
-/* D-Bus-related definitions for NetworkManager VPN plugins.
- *
- * Note that although this header is installed as part of libnm-util, it is also
- * used by some external code that does not link to libnm-util.
- */
-
-#ifndef NETWORK_MANAGER_VPN_H
-#define NETWORK_MANAGER_VPN_H
-
-/*
- * dbus services details
- */
-#define NM_DBUS_PATH_VPN "/org/freedesktop/NetworkManager/VPN/Manager"
-#define NM_DBUS_INTERFACE_VPN "org.freedesktop.NetworkManager.VPN.Manager"
-
-#define NM_DBUS_PATH_VPN_CONNECTION "/org/freedesktop/NetworkManager/VPN/Connection"
-#define NM_DBUS_INTERFACE_VPN_CONNECTION "org.freedesktop.NetworkManager.VPN.Connection"
-
-#define NM_VPN_DBUS_PLUGIN_PATH "/org/freedesktop/NetworkManager/VPN/Plugin"
-#define NM_VPN_DBUS_PLUGIN_INTERFACE "org.freedesktop.NetworkManager.VPN.Plugin"
-
-/*
- * VPN Errors
- */
-#define NM_DBUS_NO_ACTIVE_VPN_CONNECTION "org.freedesktop.NetworkManager.VPNConnections.NoActiveVPNConnection"
-#define NM_DBUS_NO_VPN_CONNECTIONS "org.freedesktop.NetworkManager.VPNConnections.NoVPNConnections"
-#define NM_DBUS_INVALID_VPN_CONNECTION "org.freedesktop.NetworkManager.VPNConnections.InvalidVPNConnection"
-
-#define NM_DBUS_VPN_ERROR_PREFIX "org.freedesktop.NetworkManager.VPN.Error"
-#define NM_DBUS_VPN_STARTING_IN_PROGRESS "StartingInProgress"
-#define NM_DBUS_VPN_ALREADY_STARTED "AlreadyStarted"
-#define NM_DBUS_VPN_STOPPING_IN_PROGRESS "StoppingInProgress"
-#define NM_DBUS_VPN_ALREADY_STOPPED "AlreadyStopped"
-#define NM_DBUS_VPN_WRONG_STATE "WrongState"
-#define NM_DBUS_VPN_BAD_ARGUMENTS "BadArguments"
-#define NM_DBUS_VPN_INTERACTIVE_NOT_SUPPORTED "InteractiveNotSupported"
-
-/*
- * VPN daemon signals
- */
-#define NM_DBUS_VPN_SIGNAL_LOGIN_BANNER "LoginBanner"
-#define NM_DBUS_VPN_SIGNAL_LOGIN_FAILED "LoginFailed"
-#define NM_DBUS_VPN_SIGNAL_LAUNCH_FAILED "LaunchFailed"
-#define NM_DBUS_VPN_SIGNAL_CONNECT_FAILED "ConnectFailed"
-#define NM_DBUS_VPN_SIGNAL_VPN_CONFIG_BAD "VPNConfigBad"
-#define NM_DBUS_VPN_SIGNAL_IP_CONFIG_BAD "IPConfigBad"
-#define NM_DBUS_VPN_SIGNAL_STATE_CHANGE "StateChange"
-#define NM_DBUS_VPN_SIGNAL_IP4_CONFIG "IP4Config"
-
-/**
- * NMVPNServiceState:
- * @NM_VPN_SERVICE_STATE_UNKNOWN: The state of the VPN plugin is unknown.
- * @NM_VPN_SERVICE_STATE_INIT: The VPN plugin is initialized.
- * @NM_VPN_SERVICE_STATE_SHUTDOWN: Not used.
- * @NM_VPN_SERVICE_STATE_STARTING: The plugin is attempting to connect to a VPN server.
- * @NM_VPN_SERVICE_STATE_STARTED: The plugin has connected to a VPN server.
- * @NM_VPN_SERVICE_STATE_STOPPING: The plugin is disconnecting from the VPN server.
- * @NM_VPN_SERVICE_STATE_STOPPED: The plugin has disconnected from the VPN server.
- *
- * VPN daemon states
- */
-typedef enum NMVPNServiceState {
- NM_VPN_SERVICE_STATE_UNKNOWN = 0,
- NM_VPN_SERVICE_STATE_INIT,
- NM_VPN_SERVICE_STATE_SHUTDOWN,
- NM_VPN_SERVICE_STATE_STARTING,
- NM_VPN_SERVICE_STATE_STARTED,
- NM_VPN_SERVICE_STATE_STOPPING,
- NM_VPN_SERVICE_STATE_STOPPED
-} NMVPNServiceState;
-
-/**
- * NMVPNConnectionState:
- * @NM_VPN_CONNECTION_STATE_UNKNOWN: The state of the VPN connection is
- * unknown.
- * @NM_VPN_CONNECTION_STATE_PREPARE: The VPN connection is preparing to
- * connect.
- * @NM_VPN_CONNECTION_STATE_NEED_AUTH: The VPN connection needs authorization
- * credentials.
- * @NM_VPN_CONNECTION_STATE_CONNECT: The VPN connection is being established.
- * @NM_VPN_CONNECTION_STATE_IP_CONFIG_GET: The VPN connection is getting an IP
- * address.
- * @NM_VPN_CONNECTION_STATE_ACTIVATED: The VPN connection is active.
- * @NM_VPN_CONNECTION_STATE_FAILED: The VPN connection failed.
- * @NM_VPN_CONNECTION_STATE_DISCONNECTED: The VPN connection is disconnected.
- *
- * VPN connection states
- */
-typedef enum NMVPNConnectionState {
- NM_VPN_CONNECTION_STATE_UNKNOWN = 0,
- NM_VPN_CONNECTION_STATE_PREPARE,
- NM_VPN_CONNECTION_STATE_NEED_AUTH,
- NM_VPN_CONNECTION_STATE_CONNECT,
- NM_VPN_CONNECTION_STATE_IP_CONFIG_GET,
- NM_VPN_CONNECTION_STATE_ACTIVATED,
- NM_VPN_CONNECTION_STATE_FAILED,
- NM_VPN_CONNECTION_STATE_DISCONNECTED
-} NMVPNConnectionState;
-
-/**
- * NMVPNConnectionStateReason:
- * @NM_VPN_CONNECTION_STATE_REASON_UNKNOWN: The reason for the VPN connection
- * state change is unknown.
- * @NM_VPN_CONNECTION_STATE_REASON_NONE: No reason was given for the VPN
- * connection state change.
- * @NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED: The VPN connection changed
- * state because the user disconnected it.
- * @NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED: The VPN connection
- * changed state because the device it was using was disconnected.
- * @NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED: The service providing the
- * VPN connection was stopped.
- * @NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID: The IP config of the VPN
- * connection was invalid.
- * @NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT: The connection attempt to
- * the VPN service timed out.
- * @NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT: A timeout occurred
- * while starting the service providing the VPN connection.
- * @NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED: Starting the service
- * starting the service providing the VPN connection failed.
- * @NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS: Necessary secrets for the VPN
- * connection were not provided.
- * @NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED: Authentication to the VPN
- * server failed.
- * @NM_VPN_CONNECTION_STATE_REASON_CONNECTION_REMOVED: The connection was
- * deleted from settings.
- *
- * VPN connection state reasons
- */
-typedef enum NMVPNConnectionStateReason {
- NM_VPN_CONNECTION_STATE_REASON_UNKNOWN = 0,
- NM_VPN_CONNECTION_STATE_REASON_NONE,
- NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED,
- NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED,
- NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED,
- NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID,
- NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT,
- NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT,
- NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED,
- NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS,
- NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED,
- NM_VPN_CONNECTION_STATE_REASON_CONNECTION_REMOVED
-} NMVPNConnectionStateReason;
-
-/**
- * NMVPNPluginFailure:
- * @NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED: Login failed.
- * @NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED: Connect failed.
- * @NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG: Invalid IP configuration returned from
- * the VPN plugin.
- *
- * VPN plugin failure reasons
- */
-typedef enum {
- NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED,
- NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED,
- NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG
-} NMVPNPluginFailure;
-
-/*** Generic config ***/
-
-/* string: VPN interface name (tun0, tap0, etc) */
-#define NM_VPN_PLUGIN_CONFIG_TUNDEV "tundev"
-
-/* string: Login message */
-#define NM_VPN_PLUGIN_CONFIG_BANNER "banner"
-
-/* uint32 / array of uint8: IP address of the public external VPN gateway (network byte order) */
-#define NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY "gateway"
-
-/* uint32: Maximum Transfer Unit that the VPN interface should use */
-#define NM_VPN_PLUGIN_CONFIG_MTU "mtu"
-
-/* boolean: Has IP4 configuration? */
-#define NM_VPN_PLUGIN_CONFIG_HAS_IP4 "has-ip4"
-
-/* boolean: Has IP6 configuration? */
-#define NM_VPN_PLUGIN_CONFIG_HAS_IP6 "has-ip6"
-
-/* boolean: If %TRUE the VPN plugin can persist/reconnect the connection over
- * link changes and VPN server dropouts.
- */
-#define NM_VPN_PLUGIN_CAN_PERSIST "can-persist"
-
-/*** Ip4Config ***/
-
-/* uint32: IP address of the internal gateway of the subnet the VPN interface is
- * on, if the VPN uses subnet configuration (network byte order)
- */
-#define NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY "internal-gateway"
-
-/* uint32: internal IP address of the local VPN interface (network byte order) */
-#define NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS "address"
-
-/* uint32: IP address of the other side of Point-to-Point connection if the VPN
- * uses Point-to-Point configuration. (network byte order)
- */
-#define NM_VPN_PLUGIN_IP4_CONFIG_PTP "ptp"
-
-/* uint32: IP prefix of the VPN interface; 1 - 32 inclusive */
-#define NM_VPN_PLUGIN_IP4_CONFIG_PREFIX "prefix"
-
-/* array of uint32: IP addresses of DNS servers for the VPN (network byte order) */
-#define NM_VPN_PLUGIN_IP4_CONFIG_DNS "dns"
-
-/* array of uint32: IP addresses of NBNS/WINS servers for the VPN (network byte order) */
-#define NM_VPN_PLUGIN_IP4_CONFIG_NBNS "nbns"
-
-/* uint32: Message Segment Size that the VPN interface should use */
-#define NM_VPN_PLUGIN_IP4_CONFIG_MSS "mss"
-
-/* string: DNS domain name */
-#define NM_VPN_PLUGIN_IP4_CONFIG_DOMAIN "domain"
-
-/* array of strings: DNS domain names */
-#define NM_VPN_PLUGIN_IP4_CONFIG_DOMAINS "domains"
-
-/* [ip4 routes]: custom routes the client should apply, in the format used
- * by nm_utils_ip4_routes_to/from_gvalue
- */
-#define NM_VPN_PLUGIN_IP4_CONFIG_ROUTES "routes"
-
-/* boolean: prevent this VPN connection from ever getting the default route */
-#define NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT "never-default"
-
-/* Deprecated */
-#define NM_VPN_PLUGIN_IP4_CONFIG_GATEWAY NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY
-
-/* Legacy IP4 items; these are included in the IP4 config by older plugins,
- * but in the generic config by newer plugins.
- */
-
-#define NM_VPN_PLUGIN_IP4_CONFIG_BANNER NM_VPN_PLUGIN_CONFIG_BANNER
-#define NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY
-#define NM_VPN_PLUGIN_IP4_CONFIG_MTU NM_VPN_PLUGIN_CONFIG_MTU
-#define NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV NM_VPN_PLUGIN_CONFIG_TUNDEV
-
-/*** Ip6Config ***/
-
-/* array of uint8: IP address of the internal gateway of the subnet the VPN interface is
- * on, if the VPN uses subnet configuration (network byte order)
- */
-#define NM_VPN_PLUGIN_IP6_CONFIG_INT_GATEWAY "internal-gateway"
-
-/* array of uint8: internal IP address of the local VPN interface (network byte order) */
-#define NM_VPN_PLUGIN_IP6_CONFIG_ADDRESS "address"
-
-/* array of uint8: IP address of the other side of Point-to-Point connection if the VPN
- * uses Point-to-Point configuration. (network byte order)
- */
-#define NM_VPN_PLUGIN_IP6_CONFIG_PTP "ptp"
-
-/* uint32: prefix length of the VPN interface; 1 - 128 inclusive */
-#define NM_VPN_PLUGIN_IP6_CONFIG_PREFIX "prefix"
-
-/* array of array of uint8: IP addresses of DNS servers for the VPN (network byte order) */
-#define NM_VPN_PLUGIN_IP6_CONFIG_DNS "dns"
-
-/* uint32: Message Segment Size that the VPN interface should use */
-#define NM_VPN_PLUGIN_IP6_CONFIG_MSS "mss"
-
-/* string: DNS domain name */
-#define NM_VPN_PLUGIN_IP6_CONFIG_DOMAIN "domain"
-
-/* array of strings: DNS domain names */
-#define NM_VPN_PLUGIN_IP6_CONFIG_DOMAINS "domains"
-
-/* [ip6 routes]: custom routes the client should apply, in the format used
- * by nm_utils_ip6_routes_to/from_gvalue
- */
-#define NM_VPN_PLUGIN_IP6_CONFIG_ROUTES "routes"
-
-/* boolean: prevent this VPN connection from ever getting the default route */
-#define NM_VPN_PLUGIN_IP6_CONFIG_NEVER_DEFAULT "never-default"
-
-#endif /* NETWORK_MANAGER_VPN_H */
diff --git a/libnm-util/crypto.c b/libnm-util/crypto.c
deleted file mode 100644
index 5d1a37ffc9..0000000000
--- a/libnm-util/crypto.c
+++ /dev/null
@@ -1,749 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * Dan Williams <dcbw@redhat.com>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <strings.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "crypto.h"
-
-GQuark
-_nm_crypto_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-crypto-error-quark");
- return quark;
-}
-
-#define PEM_RSA_KEY_BEGIN "-----BEGIN RSA PRIVATE KEY-----"
-#define PEM_RSA_KEY_END "-----END RSA PRIVATE KEY-----"
-
-#define PEM_DSA_KEY_BEGIN "-----BEGIN DSA PRIVATE KEY-----"
-#define PEM_DSA_KEY_END "-----END DSA PRIVATE KEY-----"
-
-#define PEM_CERT_BEGIN "-----BEGIN CERTIFICATE-----"
-#define PEM_CERT_END "-----END CERTIFICATE-----"
-
-#define PEM_PKCS8_ENC_KEY_BEGIN "-----BEGIN ENCRYPTED PRIVATE KEY-----"
-#define PEM_PKCS8_ENC_KEY_END "-----END ENCRYPTED PRIVATE KEY-----"
-
-#define PEM_PKCS8_DEC_KEY_BEGIN "-----BEGIN PRIVATE KEY-----"
-#define PEM_PKCS8_DEC_KEY_END "-----END PRIVATE KEY-----"
-
-static gboolean
-find_tag (const char *tag,
- const GByteArray *array,
- gsize start_at,
- gsize *out_pos)
-{
- gsize i, taglen;
- gsize len = array->len - start_at;
-
- g_return_val_if_fail (out_pos != NULL, FALSE);
-
- taglen = strlen (tag);
- if (len >= taglen) {
- for (i = 0; i < len - taglen + 1; i++) {
- if (memcmp (array->data + start_at + i, tag, taglen) == 0) {
- *out_pos = start_at + i;
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-#define DEK_INFO_TAG "DEK-Info: "
-#define PROC_TYPE_TAG "Proc-Type: "
-
-static GByteArray *
-parse_old_openssl_key_file (const GByteArray *contents,
- int key_type,
- char **out_cipher,
- char **out_iv,
- GError **error)
-{
- GByteArray *bindata = NULL;
- char **lines = NULL;
- char **ln = NULL;
- gsize start = 0, end = 0;
- GString *str = NULL;
- int enc_tags = 0;
- char *iv = NULL;
- char *cipher = NULL;
- unsigned char *tmp = NULL;
- gsize tmp_len = 0;
- const char *start_tag;
- const char *end_tag;
- guint8 save_end = 0;
-
- switch (key_type) {
- case NM_CRYPTO_KEY_TYPE_RSA:
- start_tag = PEM_RSA_KEY_BEGIN;
- end_tag = PEM_RSA_KEY_END;
- break;
- case NM_CRYPTO_KEY_TYPE_DSA:
- start_tag = PEM_DSA_KEY_BEGIN;
- end_tag = PEM_DSA_KEY_END;
- break;
- default:
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE,
- "Unknown key type %d",
- key_type);
- g_assert_not_reached ();
- return NULL;
- }
-
- if (!find_tag (start_tag, contents, 0, &start))
- goto parse_error;
-
- start += strlen (start_tag);
- if (!find_tag (end_tag, contents, start, &end)) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("PEM key file had no end tag '%s'."),
- end_tag);
- goto parse_error;
- }
-
- save_end = contents->data[end];
- contents->data[end] = '\0';
- lines = g_strsplit ((const char *) (contents->data + start), "\n", 0);
- contents->data[end] = save_end;
-
- if (!lines || g_strv_length (lines) <= 1) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Doesn't look like a PEM private key file."));
- goto parse_error;
- }
-
- str = g_string_new_len (NULL, end - start);
- for (ln = lines; *ln; ln++) {
- char *p = *ln;
-
- /* Chug leading spaces */
- p = g_strstrip (p);
- if (!*p)
- continue;
-
- if (!strncmp (p, PROC_TYPE_TAG, strlen (PROC_TYPE_TAG))) {
- if (enc_tags++ != 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Malformed PEM file: Proc-Type was not first tag."));
- goto parse_error;
- }
-
- p += strlen (PROC_TYPE_TAG);
- if (strcmp (p, "4,ENCRYPTED")) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Malformed PEM file: unknown Proc-Type tag '%s'."),
- p);
- goto parse_error;
- }
- } else if (!strncmp (p, DEK_INFO_TAG, strlen (DEK_INFO_TAG))) {
- char *comma;
-
- if (enc_tags++ != 1) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Malformed PEM file: DEK-Info was not the second tag."));
- goto parse_error;
- }
-
- p += strlen (DEK_INFO_TAG);
-
- /* Grab the IV first */
- comma = strchr (p, ',');
- if (!comma || (*(comma + 1) == '\0')) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Malformed PEM file: no IV found in DEK-Info tag."));
- goto parse_error;
- }
- *comma++ = '\0';
- if (!g_ascii_isxdigit (*comma)) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Malformed PEM file: invalid format of IV in DEK-Info tag."));
- goto parse_error;
- }
- iv = g_strdup (comma);
-
- /* Get the private key cipher */
- if (!strcasecmp (p, "DES-EDE3-CBC")) {
- cipher = g_strdup (p);
- } else if (!strcasecmp (p, "DES-CBC")) {
- cipher = g_strdup (p);
- } else if (!strcasecmp (p, "AES-128-CBC")) {
- cipher = g_strdup (p);
- } else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE,
- _("Malformed PEM file: unknown private key cipher '%s'."),
- p);
- goto parse_error;
- }
- } else {
- if ((enc_tags != 0) && (enc_tags != 2)) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- "Malformed PEM file: both Proc-Type and DEK-Info tags are required.");
- goto parse_error;
- }
- g_string_append (str, p);
- }
- }
-
- tmp = g_base64_decode (str->str, &tmp_len);
- if (tmp == NULL || !tmp_len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_DECODE_FAILED,
- _("Could not decode private key."));
- goto parse_error;
- }
- g_string_free (str, TRUE);
-
- if (lines)
- g_strfreev (lines);
-
- bindata = g_byte_array_sized_new (tmp_len);
- g_byte_array_append (bindata, tmp, tmp_len);
- g_free (tmp);
-
- *out_iv = iv;
- *out_cipher = cipher;
- return bindata;
-
-parse_error:
- g_free (tmp);
- g_free (cipher);
- g_free (iv);
- if (str)
- g_string_free (str, TRUE);
- if (lines)
- g_strfreev (lines);
- return NULL;
-}
-
-static GByteArray *
-parse_pkcs8_key_file (const GByteArray *contents,
- gboolean *out_encrypted,
- GError **error)
-{
- GByteArray *key = NULL;
- gsize start = 0, end = 0;
- unsigned char *der = NULL;
- guint8 save_end;
- gsize length = 0;
- const char *start_tag = NULL, *end_tag = NULL;
- gboolean encrypted = FALSE;
-
- /* Try encrypted first, decrypted next */
- if (find_tag (PEM_PKCS8_ENC_KEY_BEGIN, contents, 0, &start)) {
- start_tag = PEM_PKCS8_ENC_KEY_BEGIN;
- end_tag = PEM_PKCS8_ENC_KEY_END;
- encrypted = TRUE;
- } else if (find_tag (PEM_PKCS8_DEC_KEY_BEGIN, contents, 0, &start)) {
- start_tag = PEM_PKCS8_DEC_KEY_BEGIN;
- end_tag = PEM_PKCS8_DEC_KEY_END;
- encrypted = FALSE;
- } else {
- g_set_error_literal (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Failed to find expected PKCS#8 start tag."));
- return NULL;
- }
-
- start += strlen (start_tag);
- if (!find_tag (end_tag, contents, start, &end)) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Failed to find expected PKCS#8 end tag '%s'."),
- end_tag);
- return NULL;
- }
-
- /* g_base64_decode() wants a NULL-terminated string */
- save_end = contents->data[end];
- contents->data[end] = '\0';
- der = g_base64_decode ((const char *) (contents->data + start), &length);
- contents->data[end] = save_end;
-
- if (der && length) {
- key = g_byte_array_sized_new (length);
- g_byte_array_append (key, der, length);
- g_assert (key->len == length);
- *out_encrypted = encrypted;
- } else {
- g_set_error_literal (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_DECODE_FAILED,
- _("Failed to decode PKCS#8 private key."));
- }
-
- g_free (der);
- return key;
-}
-
-static GByteArray *
-file_to_g_byte_array (const char *filename, GError **error)
-{
- char *contents;
- GByteArray *array = NULL;
- gsize length = 0;
-
- if (g_file_get_contents (filename, &contents, &length, error)) {
- array = g_byte_array_sized_new (length);
- g_byte_array_append (array, (guint8 *) contents, length);
- g_assert (array->len == length);
- g_free (contents);
- }
- return array;
-}
-
-/*
- * Convert a hex string into bytes.
- */
-static char *
-convert_iv (const char *src,
- gsize *out_len,
- GError **error)
-{
- int num;
- int i;
- char conv[3];
- char *c;
-
- g_return_val_if_fail (src != NULL, NULL);
-
- num = strlen (src);
- if (num % 2) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_RAW_IV_INVALID,
- _("IV must be an even number of bytes in length."));
- return NULL;
- }
-
- num /= 2;
- c = g_malloc0 (num + 1);
-
- conv[2] = '\0';
- for (i = 0; i < num; i++) {
- conv[0] = src[(i * 2)];
- conv[1] = src[(i * 2) + 1];
- if (!g_ascii_isxdigit (conv[0]) || !g_ascii_isxdigit (conv[1])) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_RAW_IV_INVALID,
- _("IV contains non-hexadecimal digits."));
- goto error;
- }
-
- c[i] = strtol(conv, NULL, 16);
- }
- *out_len = num;
- return c;
-
-error:
- g_free (c);
- return NULL;
-}
-
-static char *
-make_des_aes_key (const char *cipher,
- const char *salt,
- const gsize salt_len,
- const char *password,
- gsize *out_len,
- GError **error)
-{
- char *key;
- guint32 digest_len;
-
- g_return_val_if_fail (cipher != NULL, NULL);
- g_return_val_if_fail (salt != NULL, NULL);
- g_return_val_if_fail (salt_len >= 8, NULL);
- g_return_val_if_fail (password != NULL, NULL);
- g_return_val_if_fail (out_len != NULL, NULL);
-
- if (!strcmp (cipher, "DES-EDE3-CBC"))
- digest_len = 24;
- else if (!strcmp (cipher, "DES-CBC"))
- digest_len = 8;
- else if (!strcmp (cipher, "AES-128-CBC"))
- digest_len = 16;
- else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_UNKNOWN_CIPHER,
- _("Private key cipher '%s' was unknown."),
- cipher);
- return NULL;
- }
-
- if (password[0] == '\0')
- return NULL;
-
- key = g_malloc0 (digest_len + 1);
-
- if (!crypto_md5_hash (salt,
- salt_len,
- password,
- strlen (password),
- key,
- digest_len,
- error))
- goto error;
-
- *out_len = digest_len;
- return key;
-
-error:
- if (key) {
- /* Don't leak stale key material */
- memset (key, 0, digest_len);
- g_free (key);
- }
- return NULL;
-}
-
-static GByteArray *
-decrypt_key (const char *cipher,
- int key_type,
- GByteArray *data,
- const char *iv,
- const char *password,
- GError **error)
-{
- char *bin_iv = NULL;
- gsize bin_iv_len = 0;
- char *key = NULL;
- gsize key_len = 0;
- char *output = NULL;
- gsize decrypted_len = 0;
- GByteArray *decrypted = NULL;
-
- g_return_val_if_fail (password != NULL, NULL);
-
- bin_iv = convert_iv (iv, &bin_iv_len, error);
- if (!bin_iv)
- return NULL;
-
- /* Convert the password and IV into a DES or AES key */
- key = make_des_aes_key (cipher, bin_iv, bin_iv_len, password, &key_len, error);
- if (!key || !key_len)
- goto out;
-
- output = crypto_decrypt (cipher, key_type,
- data,
- bin_iv, bin_iv_len,
- key, key_len,
- &decrypted_len,
- error);
- if (output && decrypted_len) {
- decrypted = g_byte_array_sized_new (decrypted_len);
- g_byte_array_append (decrypted, (guint8 *) output, decrypted_len);
- }
-
-out:
- /* Don't leak stale key material */
- if (key)
- memset (key, 0, key_len);
- g_free (output);
- g_free (key);
- g_free (bin_iv);
-
- return decrypted;
-}
-
-GByteArray *
-crypto_decrypt_private_key_data (const GByteArray *contents,
- const char *password,
- NMCryptoKeyType *out_key_type,
- GError **error)
-{
- GByteArray *decrypted = NULL;
- NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_RSA;
- GByteArray *data;
- char *iv = NULL;
- char *cipher = NULL;
-
- g_return_val_if_fail (contents != NULL, NULL);
- if (out_key_type)
- g_return_val_if_fail (*out_key_type == NM_CRYPTO_KEY_TYPE_UNKNOWN, NULL);
-
- /* OpenSSL non-standard legacy PEM files */
-
- /* Try RSA keys first */
- data = parse_old_openssl_key_file (contents, key_type, &cipher, &iv, error);
- if (!data) {
- g_clear_error (error);
-
- /* DSA next */
- key_type = NM_CRYPTO_KEY_TYPE_DSA;
- data = parse_old_openssl_key_file (contents, key_type, &cipher, &iv, error);
- if (!data) {
- g_clear_error (error);
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Unable to determine private key type."));
- }
- }
-
- if (data) {
- /* return the key type even if decryption failed */
- if (out_key_type)
- *out_key_type = key_type;
-
- if (password) {
- decrypted = decrypt_key (cipher,
- key_type,
- data,
- iv,
- password,
- error);
- }
- g_byte_array_free (data, TRUE);
- }
-
- g_free (cipher);
- g_free (iv);
-
- return decrypted;
-}
-
-GByteArray *
-crypto_decrypt_private_key (const char *file,
- const char *password,
- NMCryptoKeyType *out_key_type,
- GError **error)
-{
- GByteArray *contents;
- GByteArray *key = NULL;
-
- contents = file_to_g_byte_array (file, error);
- if (contents) {
- key = crypto_decrypt_private_key_data (contents, password, out_key_type, error);
- g_byte_array_free (contents, TRUE);
- }
- return key;
-}
-
-static GByteArray *
-extract_pem_cert_data (GByteArray *contents, GError **error)
-{
- GByteArray *cert = NULL;
- gsize start = 0, end = 0;
- unsigned char *der = NULL;
- guint8 save_end;
- gsize length = 0;
-
- if (!find_tag (PEM_CERT_BEGIN, contents, 0, &start)) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("PEM certificate had no start tag '%s'."),
- PEM_CERT_BEGIN);
- goto done;
- }
-
- start += strlen (PEM_CERT_BEGIN);
- if (!find_tag (PEM_CERT_END, contents, start, &end)) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("PEM certificate had no end tag '%s'."),
- PEM_CERT_END);
- goto done;
- }
-
- /* g_base64_decode() wants a NULL-terminated string */
- save_end = contents->data[end];
- contents->data[end] = '\0';
- der = g_base64_decode ((const char *) (contents->data + start), &length);
- contents->data[end] = save_end;
-
- if (der && length) {
- cert = g_byte_array_sized_new (length);
- g_byte_array_append (cert, der, length);
- g_assert (cert->len == length);
- } else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_DECODE_FAILED,
- _("Failed to decode certificate."));
- }
-
-done:
- g_free (der);
- return cert;
-}
-
-GByteArray *
-crypto_load_and_verify_certificate (const char *file,
- NMCryptoFileFormat *out_file_format,
- GError **error)
-{
- GByteArray *array, *contents;
-
- g_return_val_if_fail (file != NULL, NULL);
- g_return_val_if_fail (out_file_format != NULL, NULL);
- g_return_val_if_fail (*out_file_format == NM_CRYPTO_FILE_FORMAT_UNKNOWN, NULL);
-
- contents = file_to_g_byte_array (file, error);
- if (!contents)
- return NULL;
-
- /* Check for PKCS#12 */
- if (crypto_is_pkcs12_data (contents)) {
- *out_file_format = NM_CRYPTO_FILE_FORMAT_PKCS12;
- return contents;
- }
-
- /* Check for plain DER format */
- if (contents->len > 2 && contents->data[0] == 0x30 && contents->data[1] == 0x82) {
- *out_file_format = crypto_verify_cert (contents->data, contents->len, error);
- } else {
- array = extract_pem_cert_data (contents, error);
- if (!array) {
- g_byte_array_free (contents, TRUE);
- return NULL;
- }
-
- *out_file_format = crypto_verify_cert (array->data, array->len, error);
- g_byte_array_free (array, TRUE);
- }
-
- if (*out_file_format != NM_CRYPTO_FILE_FORMAT_X509) {
- g_byte_array_free (contents, TRUE);
- contents = NULL;
- }
-
- return contents;
-}
-
-gboolean
-crypto_is_pkcs12_data (const GByteArray *data)
-{
- GError *error = NULL;
- gboolean success;
-
- g_return_val_if_fail (data != NULL, FALSE);
-
- if (!data->len)
- return FALSE;
-
- success = crypto_verify_pkcs12 (data, NULL, &error);
- if (success == FALSE) {
- /* If the error was just a decryption error, then it's pkcs#12 */
- if (error) {
- if (g_error_matches (error, NM_CRYPTO_ERROR, NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED))
- success = TRUE;
- g_error_free (error);
- }
- }
- return success;
-}
-
-gboolean
-crypto_is_pkcs12_file (const char *file, GError **error)
-{
- GByteArray *contents;
- gboolean success = FALSE;
-
- g_return_val_if_fail (file != NULL, FALSE);
-
- contents = file_to_g_byte_array (file, error);
- if (contents) {
- success = crypto_is_pkcs12_data (contents);
- g_byte_array_free (contents, TRUE);
- }
- return success;
-}
-
-/* Verifies that a private key can be read, and if a password is given, that
- * the private key can be decrypted with that password.
- */
-NMCryptoFileFormat
-crypto_verify_private_key_data (const GByteArray *contents,
- const char *password,
- GError **error)
-{
- GByteArray *tmp;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- NMCryptoKeyType ktype = NM_CRYPTO_KEY_TYPE_UNKNOWN;
- gboolean is_encrypted = FALSE;
-
- g_return_val_if_fail (contents != NULL, FALSE);
-
- /* Check for PKCS#12 first */
- if (crypto_is_pkcs12_data (contents)) {
- if (!password || crypto_verify_pkcs12 (contents, password, error))
- format = NM_CRYPTO_FILE_FORMAT_PKCS12;
- } else {
- /* Maybe it's PKCS#8 */
- tmp = parse_pkcs8_key_file (contents, &is_encrypted, error);
- if (tmp) {
- if (!password || crypto_verify_pkcs8 (tmp, is_encrypted, password, error))
- format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
- } else {
- g_clear_error (error);
-
- /* Or it's old-style OpenSSL */
- tmp = crypto_decrypt_private_key_data (contents, password, &ktype, error);
- if (tmp)
- format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
- else if (!password && (ktype != NM_CRYPTO_KEY_TYPE_UNKNOWN))
- format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
- }
-
- if (tmp) {
- /* Don't leave decrypted key data around */
- memset (tmp->data, 0, tmp->len);
- g_byte_array_free (tmp, TRUE);
- }
- }
-
- return format;
-}
-
-NMCryptoFileFormat
-crypto_verify_private_key (const char *filename,
- const char *password,
- GError **error)
-{
- GByteArray *contents;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
-
- g_return_val_if_fail (filename != NULL, FALSE);
-
- contents = file_to_g_byte_array (filename, error);
- if (contents) {
- format = crypto_verify_private_key_data (contents, password, error);
- g_byte_array_free (contents, TRUE);
- }
- return format;
-}
diff --git a/libnm-util/crypto.h b/libnm-util/crypto.h
deleted file mode 100644
index 29e1c3dc37..0000000000
--- a/libnm-util/crypto.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * Dan Williams <dcbw@redhat.com>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- */
-
-#ifndef __CRYPTO_H__
-#define __CRYPTO_H__
-
-#define MD5_HASH_LEN 20
-#define CIPHER_DES_EDE3_CBC "DES-EDE3-CBC"
-#define CIPHER_DES_CBC "DES-CBC"
-#define CIPHER_AES_CBC "AES-128-CBC"
-
-enum {
- NM_CRYPTO_ERR_NONE = 0,
- NM_CRYPTO_ERR_INIT_FAILED,
- NM_CRYPTO_ERR_CANT_READ_FILE,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
- NM_CRYPTO_ERR_DECODE_FAILED,
- NM_CRYPTO_ERR_OUT_OF_MEMORY,
- NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE,
- NM_CRYPTO_ERR_UNKNOWN_CIPHER,
- NM_CRYPTO_ERR_RAW_IV_INVALID,
- NM_CRYPTO_ERR_MD5_INIT_FAILED,
- NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
- NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
- NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- NM_CRYPTO_ERR_INVALID_PASSWORD,
- NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED,
- NM_CRYPTO_ERR_RANDOMIZE_FAILED
-};
-
-typedef enum {
- NM_CRYPTO_KEY_TYPE_UNKNOWN = 0,
- NM_CRYPTO_KEY_TYPE_RSA,
- NM_CRYPTO_KEY_TYPE_DSA
-} NMCryptoKeyType;
-
-typedef enum {
- NM_CRYPTO_FILE_FORMAT_UNKNOWN = 0,
- NM_CRYPTO_FILE_FORMAT_X509,
- NM_CRYPTO_FILE_FORMAT_RAW_KEY,
- NM_CRYPTO_FILE_FORMAT_PKCS12
-} NMCryptoFileFormat;
-
-#define NM_CRYPTO_ERROR _nm_crypto_error_quark ()
-GQuark _nm_crypto_error_quark (void);
-
-gboolean crypto_init (GError **error);
-
-GByteArray *crypto_decrypt_private_key_data (const GByteArray *contents,
- const char *password,
- NMCryptoKeyType *out_key_type,
- GError **error);
-
-GByteArray *crypto_decrypt_private_key (const char *file,
- const char *password,
- NMCryptoKeyType *out_key_type,
- GError **error);
-
-GByteArray *crypto_load_and_verify_certificate (const char *file,
- NMCryptoFileFormat *out_file_format,
- GError **error);
-
-gboolean crypto_is_pkcs12_file (const char *file, GError **error);
-
-gboolean crypto_is_pkcs12_data (const GByteArray *data);
-
-NMCryptoFileFormat crypto_verify_private_key_data (const GByteArray *contents,
- const char *password,
- GError **error);
-
-NMCryptoFileFormat crypto_verify_private_key (const char *file,
- const char *password,
- GError **error);
-
-/* Internal utils API bits for crypto providers */
-
-gboolean crypto_md5_hash (const char *salt,
- const gsize salt_len,
- const char *password,
- gsize password_len,
- char *buffer,
- gsize buflen,
- GError **error);
-
-char * crypto_decrypt (const char *cipher,
- int key_type,
- GByteArray *data,
- const char *iv,
- const gsize iv_len,
- const char *key,
- const gsize key_len,
- gsize *out_len,
- GError **error);
-
-char * crypto_encrypt (const char *cipher,
- const GByteArray *data,
- const char *iv,
- gsize iv_len,
- const char *key,
- gsize key_len,
- gsize *out_len,
- GError **error);
-
-gboolean crypto_randomize (void *buffer, gsize buffer_len, GError **error);
-
-NMCryptoFileFormat crypto_verify_cert (const unsigned char *data,
- gsize len,
- GError **error);
-
-gboolean crypto_verify_pkcs12 (const GByteArray *data,
- const char *password,
- GError **error);
-
-gboolean crypto_verify_pkcs8 (const GByteArray *data,
- gboolean is_encrypted,
- const char *password,
- GError **error);
-
-#endif /* __CRYPTO_H__ */
diff --git a/libnm-util/crypto_gnutls.c b/libnm-util/crypto_gnutls.c
deleted file mode 100644
index 47c614b919..0000000000
--- a/libnm-util/crypto_gnutls.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2015 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <gnutls/gnutls.h>
-#include <gnutls/crypto.h>
-#include <gnutls/x509.h>
-#include <gnutls/pkcs12.h>
-
-#include "crypto.h"
-
-#define SALT_LEN 8
-
-static gboolean initialized = FALSE;
-
-gboolean
-crypto_init (GError **error)
-{
- if (initialized)
- return TRUE;
-
- if (gnutls_global_init() != 0) {
- gnutls_global_deinit();
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_INIT_FAILED,
- "%s",
- _("Failed to initialize the crypto engine."));
- return FALSE;
- }
-
- initialized = TRUE;
- return TRUE;
-}
-
-gboolean
-crypto_md5_hash (const char *salt,
- const gsize salt_len,
- const char *password,
- gsize password_len,
- char *buffer,
- gsize buflen,
- GError **error)
-{
- gnutls_hash_hd_t ctx;
- int err;
- int nkey = buflen;
- const gsize digest_len = 16;
- int count = 0;
- char digest[MD5_HASH_LEN];
- char *p = buffer;
-
- if (salt)
- g_return_val_if_fail (salt_len >= SALT_LEN, FALSE);
-
- g_return_val_if_fail (password != NULL, FALSE);
- g_return_val_if_fail (password_len > 0, FALSE);
- g_return_val_if_fail (buffer != NULL, FALSE);
- g_return_val_if_fail (buflen > 0, FALSE);
-
- if (gnutls_hash_get_len (GNUTLS_DIG_MD5) > MD5_HASH_LEN) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_MD5_INIT_FAILED,
- _("Hash length too long (%d > %d)."),
- gnutls_hash_get_len (GNUTLS_DIG_MD5), MD5_HASH_LEN);
- return FALSE;
- }
-
- while (nkey > 0) {
- int i = 0;
-
- err = gnutls_hash_init (&ctx, GNUTLS_DIG_MD5);
- if (err < 0)
- goto error;
-
- if (count++)
- gnutls_hash (ctx, digest, digest_len);
- gnutls_hash (ctx, password, password_len);
- if (salt)
- gnutls_hash (ctx, salt, SALT_LEN); /* Only use 8 bytes of salt */
- gnutls_hash_deinit (ctx, digest);
-
- while (nkey && (i < digest_len)) {
- *(p++) = digest[i++];
- nkey--;
- }
- }
-
- memset (digest, 0, sizeof (digest));
- return TRUE;
-error:
- memset (digest, 0, sizeof (digest));
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_MD5_INIT_FAILED,
- _("Failed to initialize the MD5 engine: %s (%s)"),
- gnutls_strerror_name (err), gnutls_strerror (err));
- return FALSE;
-}
-
-char *
-crypto_decrypt (const char *cipher,
- int key_type,
- GByteArray *data,
- const char *iv,
- const gsize iv_len,
- const char *key,
- const gsize key_len,
- gsize *out_len,
- GError **error)
-{
- gnutls_cipher_hd_t ctx;
- gnutls_datum_t key_dt, iv_dt;
- int err;
- int cipher_mech, i;
- char *output = NULL;
- gboolean success = FALSE;
- gsize pad_len, real_iv_len;
-
- if (!strcmp (cipher, CIPHER_DES_EDE3_CBC)) {
- cipher_mech = GNUTLS_CIPHER_3DES_CBC;
- real_iv_len = SALT_LEN;
- } else if (!strcmp (cipher, CIPHER_DES_CBC)) {
- cipher_mech = GNUTLS_CIPHER_DES_CBC;
- real_iv_len = SALT_LEN;
- } else if (!strcmp (cipher, CIPHER_AES_CBC)) {
- cipher_mech = GNUTLS_CIPHER_AES_128_CBC;
- real_iv_len = 16;
- } else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_UNKNOWN_CIPHER,
- _("Private key cipher '%s' was unknown."),
- cipher);
- return NULL;
- }
-
- if (iv_len < real_iv_len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_RAW_IV_INVALID,
- _("Invalid IV length (must be at least %zd)."),
- real_iv_len);
- return NULL;
- }
-
- output = g_malloc0 (data->len);
-
- key_dt.data = (unsigned char *) key;
- key_dt.size = key_len;
- iv_dt.data = (unsigned char *) iv;
- iv_dt.size = iv_len;
-
- err = gnutls_cipher_init (&ctx, cipher_mech, &key_dt, &iv_dt);
- if (err < 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
- _("Failed to initialize the decryption cipher context: %s (%s)"),
- gnutls_strerror_name (err), gnutls_strerror (err));
- goto out;
- }
-
- err = gnutls_cipher_decrypt2 (ctx, data->data, data->len, output, data->len);
- if (err < 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to decrypt the private key: %s (%s)"),
- gnutls_strerror_name (err), gnutls_strerror (err));
- goto out;
- }
- pad_len = output[data->len - 1];
-
- /* Check if the padding at the end of the decrypted data is valid */
- if (pad_len == 0 || pad_len > real_iv_len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to decrypt the private key: unexpected padding length."));
- goto out;
- }
-
- /* Validate tail padding; last byte is the padding size, and all pad bytes
- * should contain the padding size.
- */
- for (i = 1; i <= pad_len; ++i) {
- if (output[data->len - i] != pad_len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to decrypt the private key."));
- goto out;
- }
- }
-
- *out_len = data->len - pad_len;
- success = TRUE;
-
-out:
- if (!success) {
- if (output) {
- /* Don't expose key material */
- memset (output, 0, data->len);
- g_free (output);
- output = NULL;
- }
- }
- gnutls_cipher_deinit (ctx);
- return output;
-}
-
-char *
-crypto_encrypt (const char *cipher,
- const GByteArray *data,
- const char *iv,
- const gsize iv_len,
- const char *key,
- gsize key_len,
- gsize *out_len,
- GError **error)
-{
- gnutls_cipher_hd_t ctx;
- gnutls_datum_t key_dt, iv_dt;
- int err;
- int cipher_mech;
- char *output = NULL;
- gboolean success = FALSE;
- gsize padded_buf_len, pad_len, output_len;
- char *padded_buf = NULL;
- guint32 i;
-
- if (!strcmp (cipher, CIPHER_DES_EDE3_CBC))
- cipher_mech = GNUTLS_CIPHER_3DES_CBC;
- else if (!strcmp (cipher, CIPHER_AES_CBC))
- cipher_mech = GNUTLS_CIPHER_AES_128_CBC;
- else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_UNKNOWN_CIPHER,
- _("Private key cipher '%s' was unknown."),
- cipher);
- return NULL;
- }
-
- /* If data->len % ivlen == 0, then we add another complete block
- * onto the end so that the decrypter knows there's padding.
- */
- pad_len = iv_len - (data->len % iv_len);
- output_len = padded_buf_len = data->len + pad_len;
- padded_buf = g_malloc0 (padded_buf_len);
-
- memcpy (padded_buf, data->data, data->len);
- for (i = 0; i < pad_len; i++)
- padded_buf[data->len + i] = (guint8) (pad_len & 0xFF);
-
- output = g_malloc0 (output_len);
-
- key_dt.data = (unsigned char *) key;
- key_dt.size = key_len;
- iv_dt.data = (unsigned char *) iv;
- iv_dt.size = iv_len;
-
- err = gnutls_cipher_init (&ctx, cipher_mech, &key_dt, &iv_dt);
- if (err < 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
- _("Failed to initialize the encryption cipher context: %s (%s)"),
- gnutls_strerror_name (err), gnutls_strerror (err));
- goto out;
- }
-
- err = gnutls_cipher_encrypt2 (ctx, padded_buf, padded_buf_len, output, output_len);
- if (err < 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to encrypt the data: %s (%s)"),
- gnutls_strerror_name (err), gnutls_strerror (err));
- goto out;
- }
-
- *out_len = output_len;
- success = TRUE;
-
-out:
- if (padded_buf) {
- memset (padded_buf, 0, padded_buf_len);
- g_free (padded_buf);
- padded_buf = NULL;
- }
-
- if (!success) {
- if (output) {
- /* Don't expose key material */
- memset (output, 0, output_len);
- g_free (output);
- output = NULL;
- }
- }
- gnutls_cipher_deinit (ctx);
- return output;
-}
-
-NMCryptoFileFormat
-crypto_verify_cert (const unsigned char *data,
- gsize len,
- GError **error)
-{
- gnutls_x509_crt_t der;
- gnutls_datum_t dt;
- int err;
-
- err = gnutls_x509_crt_init (&der);
- if (err < 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
- _("Error initializing certificate data: %s"),
- gnutls_strerror (err));
- return NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- }
-
- /* Try DER first */
- dt.data = (unsigned char *) data;
- dt.size = len;
- err = gnutls_x509_crt_import (der, &dt, GNUTLS_X509_FMT_DER);
- if (err == GNUTLS_E_SUCCESS) {
- gnutls_x509_crt_deinit (der);
- return NM_CRYPTO_FILE_FORMAT_X509;
- }
-
- /* And PEM next */
- err = gnutls_x509_crt_import (der, &dt, GNUTLS_X509_FMT_PEM);
- gnutls_x509_crt_deinit (der);
- if (err == GNUTLS_E_SUCCESS)
- return NM_CRYPTO_FILE_FORMAT_X509;
-
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
- _("Couldn't decode certificate: %s"),
- gnutls_strerror (err));
- return NM_CRYPTO_FILE_FORMAT_UNKNOWN;
-}
-
-gboolean
-crypto_verify_pkcs12 (const GByteArray *data,
- const char *password,
- GError **error)
-{
- gnutls_pkcs12_t p12;
- gnutls_datum_t dt;
- gboolean success = FALSE;
- int err;
-
- g_return_val_if_fail (data != NULL, FALSE);
-
- dt.data = (unsigned char *) data->data;
- dt.size = data->len;
-
- err = gnutls_pkcs12_init (&p12);
- if (err < 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_DECODE_FAILED,
- _("Couldn't initialize PKCS#12 decoder: %s"),
- gnutls_strerror (err));
- return FALSE;
- }
-
- /* DER first */
- err = gnutls_pkcs12_import (p12, &dt, GNUTLS_X509_FMT_DER, 0);
- if (err < 0) {
- /* PEM next */
- err = gnutls_pkcs12_import (p12, &dt, GNUTLS_X509_FMT_PEM, 0);
- if (err < 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Couldn't decode PKCS#12 file: %s"),
- gnutls_strerror (err));
- goto out;
- }
- }
-
- err = gnutls_pkcs12_verify_mac (p12, password);
- if (err == GNUTLS_E_SUCCESS)
- success = TRUE;
- else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Couldn't verify PKCS#12 file: %s"),
- gnutls_strerror (err));
- }
-
-out:
- gnutls_pkcs12_deinit (p12);
- return success;
-}
-
-gboolean
-crypto_verify_pkcs8 (const GByteArray *data,
- gboolean is_encrypted,
- const char *password,
- GError **error)
-{
- gnutls_x509_privkey_t p8;
- gnutls_datum_t dt;
- int err;
-
- g_return_val_if_fail (data != NULL, FALSE);
-
- dt.data = (unsigned char *) data->data;
- dt.size = data->len;
-
- err = gnutls_x509_privkey_init (&p8);
- if (err < 0) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_DECODE_FAILED,
- _("Couldn't initialize PKCS#8 decoder: %s"),
- gnutls_strerror (err));
- return FALSE;
- }
-
- err = gnutls_x509_privkey_import_pkcs8 (p8,
- &dt,
- GNUTLS_X509_FMT_DER,
- is_encrypted ? password : NULL,
- is_encrypted ? 0 : GNUTLS_PKCS_PLAIN);
- gnutls_x509_privkey_deinit (p8);
-
- if (err < 0) {
- if (err == GNUTLS_E_UNKNOWN_CIPHER_TYPE) {
- /* HACK: gnutls doesn't support all the cipher types that openssl
- * can use with PKCS#8, so if we encounter one, we have to assume
- * the given password works. gnutls needs to unsuckify, apparently.
- * Specifically, by default openssl uses pbeWithMD5AndDES-CBC
- * which gnutls does not support.
- */
- } else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Couldn't decode PKCS#8 file: %s"),
- gnutls_strerror (err));
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-gboolean
-crypto_randomize (void *buffer, gsize buffer_len, GError **error)
-{
- gnutls_rnd (GNUTLS_RND_RANDOM, buffer, buffer_len);
- return TRUE;
-}
diff --git a/libnm-util/crypto_nss.c b/libnm-util/crypto_nss.c
deleted file mode 100644
index 01bb28c33d..0000000000
--- a/libnm-util/crypto_nss.c
+++ /dev/null
@@ -1,555 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * Dan Williams <dcbw@redhat.com>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2009 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <prinit.h>
-#include <nss.h>
-#include <pk11pub.h>
-#include <pkcs11t.h>
-#include <cert.h>
-#include <prerror.h>
-#include <p12.h>
-#include <ciferfam.h>
-#include <p12plcy.h>
-
-#include "crypto.h"
-
-static gboolean initialized = FALSE;
-
-gboolean
-crypto_init (GError **error)
-{
- SECStatus ret;
-
- if (initialized)
- return TRUE;
-
- PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 1);
- ret = NSS_NoDB_Init (NULL);
- if (ret != SECSuccess) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_INIT_FAILED,
- _("Failed to initialize the crypto engine: %d."),
- PR_GetError ());
- PR_Cleanup ();
- return FALSE;
- }
-
- SEC_PKCS12EnableCipher(PKCS12_RC4_40, 1);
- SEC_PKCS12EnableCipher(PKCS12_RC4_128, 1);
- SEC_PKCS12EnableCipher(PKCS12_RC2_CBC_40, 1);
- SEC_PKCS12EnableCipher(PKCS12_RC2_CBC_128, 1);
- SEC_PKCS12EnableCipher(PKCS12_DES_56, 1);
- SEC_PKCS12EnableCipher(PKCS12_DES_EDE3_168, 1);
- SEC_PKCS12SetPreferredCipher(PKCS12_DES_EDE3_168, 1);
-
- initialized = TRUE;
- return TRUE;
-}
-
-gboolean
-crypto_md5_hash (const char *salt,
- const gsize salt_len,
- const char *password,
- gsize password_len,
- char *buffer,
- gsize buflen,
- GError **error)
-{
- PK11Context *ctx;
- int nkey = buflen;
- unsigned digest_len;
- int count = 0;
- char digest[MD5_HASH_LEN];
- char *p = buffer;
-
- if (salt)
- g_return_val_if_fail (salt_len >= 8, FALSE);
-
- g_return_val_if_fail (password != NULL, FALSE);
- g_return_val_if_fail (password_len > 0, FALSE);
- g_return_val_if_fail (buffer != NULL, FALSE);
- g_return_val_if_fail (buflen > 0, FALSE);
-
- ctx = PK11_CreateDigestContext (SEC_OID_MD5);
- if (!ctx) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_MD5_INIT_FAILED,
- _("Failed to initialize the MD5 context: %d."),
- PORT_GetError ());
- return FALSE;
- }
-
- while (nkey > 0) {
- int i = 0;
-
- PK11_DigestBegin (ctx);
- if (count++)
- PK11_DigestOp (ctx, (const unsigned char *) digest, digest_len);
- PK11_DigestOp (ctx, (const unsigned char *) password, password_len);
- if (salt)
- PK11_DigestOp (ctx, (const unsigned char *) salt, 8); /* Only use 8 bytes of salt */
- PK11_DigestFinal (ctx, (unsigned char *) digest, &digest_len, sizeof (digest));
-
- while (nkey && (i < digest_len)) {
- *(p++) = digest[i++];
- nkey--;
- }
- }
-
- memset (digest, 0, sizeof (digest));
- PK11_DestroyContext (ctx, PR_TRUE);
- return TRUE;
-}
-
-char *
-crypto_decrypt (const char *cipher,
- int key_type,
- GByteArray *data,
- const char *iv,
- const gsize iv_len,
- const char *key,
- const gsize key_len,
- gsize *out_len,
- GError **error)
-{
- char *output = NULL;
- int decrypted_len = 0;
- CK_MECHANISM_TYPE cipher_mech;
- PK11SlotInfo *slot = NULL;
- SECItem key_item;
- PK11SymKey *sym_key = NULL;
- SECItem *sec_param = NULL;
- PK11Context *ctx = NULL;
- SECStatus s;
- gboolean success = FALSE;
- unsigned pad_len = 0, extra = 0;
- guint32 i, real_iv_len = 0;
-
- if (!strcmp (cipher, CIPHER_DES_EDE3_CBC)) {
- cipher_mech = CKM_DES3_CBC_PAD;
- real_iv_len = 8;
- } else if (!strcmp (cipher, CIPHER_DES_CBC)) {
- cipher_mech = CKM_DES_CBC_PAD;
- real_iv_len = 8;
- } else if (!strcmp (cipher, CIPHER_AES_CBC)) {
- cipher_mech = CKM_AES_CBC_PAD;
- real_iv_len = 16;
- } else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_UNKNOWN_CIPHER,
- _("Private key cipher '%s' was unknown."),
- cipher);
- return NULL;
- }
-
- if (iv_len < real_iv_len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_RAW_IV_INVALID,
- _("Invalid IV length (must be at least %d)."),
- real_iv_len);
- return NULL;
- }
-
- output = g_malloc0 (data->len);
-
- slot = PK11_GetBestSlot (cipher_mech, NULL);
- if (!slot) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
- _("Failed to initialize the decryption cipher slot."));
- goto out;
- }
-
- key_item.data = (unsigned char *) key;
- key_item.len = key_len;
- sym_key = PK11_ImportSymKey (slot, cipher_mech, PK11_OriginUnwrap, CKA_DECRYPT, &key_item, NULL);
- if (!sym_key) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
- _("Failed to set symmetric key for decryption."));
- goto out;
- }
-
- key_item.data = (unsigned char *) iv;
- key_item.len = real_iv_len;
- sec_param = PK11_ParamFromIV (cipher_mech, &key_item);
- if (!sec_param) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
- _("Failed to set IV for decryption."));
- goto out;
- }
-
- ctx = PK11_CreateContextBySymKey (cipher_mech, CKA_DECRYPT, sym_key, sec_param);
- if (!ctx) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
- _("Failed to initialize the decryption context."));
- goto out;
- }
-
- s = PK11_CipherOp (ctx,
- (unsigned char *) output,
- &decrypted_len,
- data->len,
- data->data,
- data->len);
- if (s != SECSuccess) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to decrypt the private key: %d."),
- PORT_GetError ());
- goto out;
- }
-
- if (decrypted_len > data->len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to decrypt the private key: decrypted data too large."));
- goto out;
- }
-
- s = PK11_DigestFinal (ctx,
- (unsigned char *) (output + decrypted_len),
- &extra,
- data->len - decrypted_len);
- if (s != SECSuccess) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to finalize decryption of the private key: %d."),
- PORT_GetError ());
- goto out;
- }
- decrypted_len += extra;
- pad_len = data->len - decrypted_len;
-
- /* Check if the padding at the end of the decrypted data is valid */
- if (pad_len == 0 || pad_len > real_iv_len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to decrypt the private key: unexpected padding length."));
- goto out;
- }
-
- /* Validate tail padding; last byte is the padding size, and all pad bytes
- * should contain the padding size.
- */
- for (i = pad_len; i > 0; i--) {
- if (output[data->len - i] != pad_len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Failed to decrypt the private key."));
- goto out;
- }
- }
-
- *out_len = decrypted_len;
- success = TRUE;
-
-out:
- if (ctx)
- PK11_DestroyContext (ctx, PR_TRUE);
- if (sym_key)
- PK11_FreeSymKey (sym_key);
- if (sec_param)
- SECITEM_FreeItem (sec_param, PR_TRUE);
- if (slot)
- PK11_FreeSlot (slot);
-
- if (!success) {
- if (output) {
- /* Don't expose key material */
- memset (output, 0, data->len);
- g_free (output);
- output = NULL;
- }
- }
- return output;
-}
-
-char *
-crypto_encrypt (const char *cipher,
- const GByteArray *data,
- const char *iv,
- gsize iv_len,
- const char *key,
- gsize key_len,
- gsize *out_len,
- GError **error)
-{
- SECStatus ret;
- CK_MECHANISM_TYPE cipher_mech = CKM_DES3_CBC_PAD;
- 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;
- unsigned char *output, *padded_buf;
- gsize output_len;
- int encrypted_len = 0, i;
- gboolean success = FALSE;
- gsize padded_buf_len, pad_len;
-
- if (!strcmp (cipher, CIPHER_DES_EDE3_CBC))
- cipher_mech = CKM_DES3_CBC_PAD;
- else if (!strcmp (cipher, CIPHER_AES_CBC))
- cipher_mech = CKM_AES_CBC_PAD;
- else {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_UNKNOWN_CIPHER,
- _("Private key cipher '%s' was unknown."),
- cipher);
- return NULL;
- }
-
- /* If data->len % ivlen == 0, then we add another complete block
- * onto the end so that the decrypter knows there's padding.
- */
- pad_len = iv_len - (data->len % iv_len);
- output_len = padded_buf_len = data->len + pad_len;
- padded_buf = g_malloc0 (padded_buf_len);
-
- memcpy (padded_buf, data->data, data->len);
- for (i = 0; i < pad_len; i++)
- padded_buf[data->len + i] = (guint8) (pad_len & 0xFF);
-
- output = g_malloc0 (output_len);
-
- slot = PK11_GetBestSlot (cipher_mech, NULL);
- if (!slot) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
- _("Failed to initialize the encryption cipher slot."));
- goto out;
- }
-
- sym_key = PK11_ImportSymKey (slot, cipher_mech, PK11_OriginUnwrap, CKA_ENCRYPT, &key_item, NULL);
- if (!sym_key) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
- _("Failed to set symmetric key for encryption."));
- goto out;
- }
-
- sec_param = PK11_ParamFromIV (cipher_mech, &iv_item);
- if (!sec_param) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
- _("Failed to set IV for encryption."));
- goto out;
- }
-
- ctx = PK11_CreateContextBySymKey (cipher_mech, CKA_ENCRYPT, sym_key, sec_param);
- if (!ctx) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
- _("Failed to initialize the encryption context."));
- goto out;
- }
-
- ret = PK11_CipherOp (ctx, output, &encrypted_len, output_len, padded_buf, padded_buf_len);
- if (ret != SECSuccess) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED,
- _("Failed to encrypt: %d."),
- PORT_GetError ());
- goto out;
- }
-
- if (encrypted_len != output_len) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED,
- _("Unexpected amount of data after encrypting."));
- goto out;
- }
-
- *out_len = encrypted_len;
- success = TRUE;
-
-out:
- if (ctx)
- PK11_DestroyContext (ctx, PR_TRUE);
- if (sym_key)
- PK11_FreeSymKey (sym_key);
- if (sec_param)
- SECITEM_FreeItem (sec_param, PR_TRUE);
- if (slot)
- PK11_FreeSlot (slot);
-
- memset (padded_buf, 0, padded_buf_len);
- g_free (padded_buf);
-
- if (!success) {
- memset (output, 0, output_len);
- g_free (output);
- output = NULL;
- }
- return (char *) output;
-}
-
-NMCryptoFileFormat
-crypto_verify_cert (const unsigned char *data,
- gsize len,
- GError **error)
-{
- CERTCertificate *cert;
-
- /* Try DER/PEM first */
- cert = CERT_DecodeCertFromPackage ((char *) data, len);
- if (!cert) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
- _("Couldn't decode certificate: %d"),
- PORT_GetError());
- return NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- }
-
- CERT_DestroyCertificate (cert);
- return NM_CRYPTO_FILE_FORMAT_X509;
-}
-
-gboolean
-crypto_verify_pkcs12 (const GByteArray *data,
- const char *password,
- GError **error)
-{
- SEC_PKCS12DecoderContext *p12ctx = NULL;
- SECItem pw = { 0 };
- PK11SlotInfo *slot = NULL;
- SECStatus s;
- char *ucs2_password;
- long ucs2_chars = 0;
-
- if (error)
- g_return_val_if_fail (*error == NULL, FALSE);
-
- /* PKCS#12 passwords are apparently UCS2 BIG ENDIAN, and NSS doesn't do
- * any conversions for us.
- */
- if (password && strlen (password)) {
- ucs2_password = (char *) g_utf8_to_utf16 (password, strlen (password), NULL, &ucs2_chars, NULL);
- if (!ucs2_password || !ucs2_chars) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_INVALID_PASSWORD,
- _("Couldn't convert password to UCS2: %d"),
- PORT_GetError());
- return FALSE;
- }
-
- ucs2_chars *= 2; /* convert # UCS2 characters -> bytes */
- pw.data = PORT_ZAlloc(ucs2_chars + 2);
- memcpy (pw.data, ucs2_password, ucs2_chars);
- pw.len = ucs2_chars + 2; /* include terminating NULL */
-
- memset (ucs2_password, 0, ucs2_chars);
- g_free (ucs2_password);
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- {
- guint16 *p;
-
- for (p = (guint16 *) pw.data; p < (guint16 *) (pw.data + pw.len); p++)
- *p = GUINT16_SWAP_LE_BE (*p);
- }
-#endif
- } else {
- /* NULL password */
- pw.data = NULL;
- pw.len = 0;
- }
-
- slot = PK11_GetInternalKeySlot();
- p12ctx = SEC_PKCS12DecoderStart (&pw, slot, NULL, NULL, NULL, NULL, NULL, NULL);
- if (!p12ctx) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_DECODE_FAILED,
- _("Couldn't initialize PKCS#12 decoder: %d"),
- PORT_GetError());
- goto error;
- }
-
- s = SEC_PKCS12DecoderUpdate (p12ctx, data->data, data->len);
- if (s != SECSuccess) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
- _("Couldn't decode PKCS#12 file: %d"),
- PORT_GetError());
- goto error;
- }
-
- s = SEC_PKCS12DecoderVerify (p12ctx);
- if (s != SECSuccess) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
- _("Couldn't verify PKCS#12 file: %d"),
- PORT_GetError());
- goto error;
- }
-
- SEC_PKCS12DecoderFinish (p12ctx);
- SECITEM_ZfreeItem (&pw, PR_FALSE);
- return TRUE;
-
-error:
- if (p12ctx)
- SEC_PKCS12DecoderFinish (p12ctx);
-
- if (slot)
- PK11_FreeSlot(slot);
-
- SECITEM_ZfreeItem (&pw, PR_FALSE);
- return FALSE;
-}
-
-gboolean
-crypto_verify_pkcs8 (const GByteArray *data,
- gboolean is_encrypted,
- const char *password,
- GError **error)
-{
- g_return_val_if_fail (data != NULL, FALSE);
-
- /* NSS apparently doesn't do PKCS#8 natively, but you have to put the
- * PKCS#8 key into a PKCS#12 file and import that?? So until we figure
- * all that out, we can only assume the password is valid.
- */
- return TRUE;
-}
-
-gboolean
-crypto_randomize (void *buffer, gsize buffer_len, GError **error)
-{
- SECStatus s;
-
- s = PK11_GenerateRandom (buffer, buffer_len);
- if (s != SECSuccess) {
- g_set_error_literal (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERR_RANDOMIZE_FAILED,
- _("Could not generate random data."));
- return FALSE;
- }
- return TRUE;
-}
diff --git a/libnm-util/libnm-util.pc.in b/libnm-util/libnm-util.pc.in
deleted file mode 100644
index 4f1ff3ef0e..0000000000
--- a/libnm-util/libnm-util.pc.in
+++ /dev/null
@@ -1,13 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libnm-util
-Description: Convenience library for clients of NetworkManager
-Version: @VERSION@
-Requires: NetworkManager >= @VERSION@ glib-2.0 dbus-glib-1
-Cflags: -I${includedir}/NetworkManager
-Libs: -L${libdir} -lnm-util
-
-
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
deleted file mode 100644
index 385cdb8e3b..0000000000
--- a/libnm-util/libnm-util.ver
+++ /dev/null
@@ -1,671 +0,0 @@
-{
-global:
- _nm_connection_new_from_hash;
- _nm_connection_replace_settings;
- nm_connection_add_setting;
- nm_connection_clear_secrets;
- nm_connection_clear_secrets_with_flags;
- nm_connection_compare;
- nm_connection_create_setting;
- nm_connection_diff;
- nm_connection_dump;
- nm_connection_duplicate;
- nm_connection_error_get_type;
- nm_connection_error_quark;
- nm_connection_for_each_setting_value;
- nm_connection_get_connection_type;
- nm_connection_get_id;
- nm_connection_get_interface_name;
- nm_connection_get_path;
- nm_connection_get_setting;
- nm_connection_get_setting_802_1x;
- nm_connection_get_setting_adsl;
- nm_connection_get_setting_bluetooth;
- nm_connection_get_setting_bond;
- nm_connection_get_setting_bridge;
- nm_connection_get_setting_bridge_port;
- nm_connection_get_setting_by_name;
- nm_connection_get_setting_cdma;
- nm_connection_get_setting_connection;
- nm_connection_get_setting_dcb;
- nm_connection_get_setting_generic;
- nm_connection_get_setting_gsm;
- nm_connection_get_setting_infiniband;
- nm_connection_get_setting_ip4_config;
- nm_connection_get_setting_ip6_config;
- nm_connection_get_setting_olpc_mesh;
- nm_connection_get_setting_ppp;
- nm_connection_get_setting_pppoe;
- nm_connection_get_setting_serial;
- nm_connection_get_setting_team;
- nm_connection_get_setting_team_port;
- nm_connection_get_setting_vlan;
- nm_connection_get_setting_vpn;
- nm_connection_get_setting_wimax;
- nm_connection_get_setting_wired;
- nm_connection_get_setting_wireless;
- nm_connection_get_setting_wireless_security;
- nm_connection_get_type;
- nm_connection_get_uuid;
- nm_connection_get_virtual_device_description;
- nm_connection_get_virtual_iface_name;
- nm_connection_is_type;
- nm_connection_lookup_setting_type;
- nm_connection_lookup_setting_type_by_quark;
- nm_connection_need_secrets;
- nm_connection_new;
- nm_connection_new_from_hash;
- nm_connection_normalize;
- nm_connection_remove_setting;
- nm_connection_replace_settings;
- nm_connection_replace_settings_from_connection;
- nm_connection_set_path;
- nm_connection_to_hash;
- nm_connection_update_secrets;
- nm_connection_verify;
- nm_ip4_address_compare;
- nm_ip4_address_dup;
- nm_ip4_address_get_address;
- nm_ip4_address_get_gateway;
- nm_ip4_address_get_prefix;
- nm_ip4_address_get_type;
- nm_ip4_address_new;
- nm_ip4_address_ref;
- nm_ip4_address_set_address;
- nm_ip4_address_set_gateway;
- nm_ip4_address_set_prefix;
- nm_ip4_address_unref;
- nm_ip4_route_compare;
- nm_ip4_route_dup;
- nm_ip4_route_get_dest;
- nm_ip4_route_get_metric;
- nm_ip4_route_get_next_hop;
- nm_ip4_route_get_prefix;
- nm_ip4_route_get_type;
- nm_ip4_route_new;
- nm_ip4_route_ref;
- nm_ip4_route_set_dest;
- nm_ip4_route_set_metric;
- nm_ip4_route_set_next_hop;
- nm_ip4_route_set_prefix;
- nm_ip4_route_unref;
- nm_ip6_address_compare;
- nm_ip6_address_dup;
- nm_ip6_address_get_address;
- nm_ip6_address_get_gateway;
- nm_ip6_address_get_prefix;
- nm_ip6_address_get_type;
- nm_ip6_address_new;
- nm_ip6_address_ref;
- nm_ip6_address_set_address;
- nm_ip6_address_set_gateway;
- nm_ip6_address_set_prefix;
- nm_ip6_address_unref;
- nm_ip6_route_compare;
- nm_ip6_route_dup;
- nm_ip6_route_get_dest;
- nm_ip6_route_get_metric;
- nm_ip6_route_get_next_hop;
- nm_ip6_route_get_prefix;
- nm_ip6_route_get_type;
- nm_ip6_route_new;
- nm_ip6_route_ref;
- nm_ip6_route_set_dest;
- nm_ip6_route_set_metric;
- nm_ip6_route_set_next_hop;
- nm_ip6_route_set_prefix;
- nm_ip6_route_unref;
- nm_setting_802_1x_add_altsubject_match;
- nm_setting_802_1x_add_eap_method;
- nm_setting_802_1x_add_phase2_altsubject_match;
- nm_setting_802_1x_ck_format_get_type;
- nm_setting_802_1x_ck_scheme_get_type;
- nm_setting_802_1x_clear_altsubject_matches;
- nm_setting_802_1x_clear_eap_methods;
- nm_setting_802_1x_clear_phase2_altsubject_matches;
- nm_setting_802_1x_error_get_type;
- nm_setting_802_1x_error_quark;
- nm_setting_802_1x_get_altsubject_match;
- nm_setting_802_1x_get_anonymous_identity;
- nm_setting_802_1x_get_ca_cert_blob;
- nm_setting_802_1x_get_ca_cert_path;
- nm_setting_802_1x_get_ca_cert_scheme;
- nm_setting_802_1x_get_ca_path;
- nm_setting_802_1x_get_client_cert_blob;
- nm_setting_802_1x_get_client_cert_path;
- nm_setting_802_1x_get_client_cert_scheme;
- nm_setting_802_1x_get_eap_method;
- nm_setting_802_1x_get_identity;
- nm_setting_802_1x_get_num_altsubject_matches;
- nm_setting_802_1x_get_num_eap_methods;
- nm_setting_802_1x_get_num_phase2_altsubject_matches;
- nm_setting_802_1x_get_pac_file;
- nm_setting_802_1x_get_password;
- nm_setting_802_1x_get_password_flags;
- nm_setting_802_1x_get_password_raw;
- nm_setting_802_1x_get_password_raw_flags;
- nm_setting_802_1x_get_phase1_fast_provisioning;
- nm_setting_802_1x_get_phase1_peaplabel;
- nm_setting_802_1x_get_phase1_peapver;
- nm_setting_802_1x_get_phase2_altsubject_match;
- nm_setting_802_1x_get_phase2_auth;
- nm_setting_802_1x_get_phase2_autheap;
- nm_setting_802_1x_get_phase2_ca_cert_blob;
- nm_setting_802_1x_get_phase2_ca_cert_path;
- nm_setting_802_1x_get_phase2_ca_cert_scheme;
- nm_setting_802_1x_get_phase2_ca_path;
- nm_setting_802_1x_get_phase2_client_cert_blob;
- nm_setting_802_1x_get_phase2_client_cert_path;
- nm_setting_802_1x_get_phase2_client_cert_scheme;
- nm_setting_802_1x_get_phase2_private_key_blob;
- nm_setting_802_1x_get_phase2_private_key_format;
- nm_setting_802_1x_get_phase2_private_key_password;
- nm_setting_802_1x_get_phase2_private_key_password_flags;
- nm_setting_802_1x_get_phase2_private_key_path;
- nm_setting_802_1x_get_phase2_private_key_scheme;
- nm_setting_802_1x_get_phase2_subject_match;
- nm_setting_802_1x_get_pin;
- nm_setting_802_1x_get_pin_flags;
- nm_setting_802_1x_get_private_key_blob;
- nm_setting_802_1x_get_private_key_format;
- nm_setting_802_1x_get_private_key_password;
- nm_setting_802_1x_get_private_key_password_flags;
- nm_setting_802_1x_get_private_key_path;
- nm_setting_802_1x_get_private_key_scheme;
- nm_setting_802_1x_get_subject_match;
- nm_setting_802_1x_get_system_ca_certs;
- nm_setting_802_1x_get_type;
- nm_setting_802_1x_new;
- nm_setting_802_1x_remove_altsubject_match;
- nm_setting_802_1x_remove_altsubject_match_by_value;
- nm_setting_802_1x_remove_eap_method;
- nm_setting_802_1x_remove_eap_method_by_value;
- nm_setting_802_1x_remove_phase2_altsubject_match;
- nm_setting_802_1x_remove_phase2_altsubject_match_by_value;
- nm_setting_802_1x_set_ca_cert;
- nm_setting_802_1x_set_client_cert;
- nm_setting_802_1x_set_phase2_ca_cert;
- nm_setting_802_1x_set_phase2_client_cert;
- nm_setting_802_1x_set_phase2_private_key;
- nm_setting_802_1x_set_private_key;
- nm_setting_adsl_error_get_type;
- nm_setting_adsl_error_quark;
- nm_setting_adsl_get_encapsulation;
- nm_setting_adsl_get_password;
- nm_setting_adsl_get_password_flags;
- nm_setting_adsl_get_protocol;
- nm_setting_adsl_get_type;
- nm_setting_adsl_get_username;
- nm_setting_adsl_get_vci;
- nm_setting_adsl_get_vpi;
- nm_setting_adsl_new;
- nm_setting_bluetooth_error_get_type;
- nm_setting_bluetooth_error_quark;
- nm_setting_bluetooth_get_bdaddr;
- nm_setting_bluetooth_get_connection_type;
- nm_setting_bluetooth_get_type;
- nm_setting_bluetooth_new;
- nm_setting_bond_add_option;
- nm_setting_bond_error_get_type;
- nm_setting_bond_error_quark;
- nm_setting_bond_get_interface_name;
- nm_setting_bond_get_num_options;
- nm_setting_bond_get_option;
- nm_setting_bond_get_option_by_name;
- nm_setting_bond_get_option_default;
- nm_setting_bond_get_type;
- nm_setting_bond_get_valid_options;
- nm_setting_bond_new;
- nm_setting_bond_remove_option;
- nm_setting_bond_validate_option;
- nm_setting_bridge_error_get_type;
- nm_setting_bridge_error_quark;
- nm_setting_bridge_get_ageing_time;
- nm_setting_bridge_get_forward_delay;
- nm_setting_bridge_get_hello_time;
- nm_setting_bridge_get_interface_name;
- nm_setting_bridge_get_mac_address;
- nm_setting_bridge_get_max_age;
- nm_setting_bridge_get_priority;
- nm_setting_bridge_get_stp;
- nm_setting_bridge_get_type;
- nm_setting_bridge_new;
- nm_setting_bridge_port_error_get_type;
- nm_setting_bridge_port_error_quark;
- nm_setting_bridge_port_get_hairpin_mode;
- nm_setting_bridge_port_get_path_cost;
- nm_setting_bridge_port_get_priority;
- nm_setting_bridge_port_get_type;
- nm_setting_bridge_port_new;
- nm_setting_cdma_error_get_type;
- nm_setting_cdma_error_quark;
- nm_setting_cdma_get_number;
- nm_setting_cdma_get_password;
- nm_setting_cdma_get_password_flags;
- nm_setting_cdma_get_type;
- nm_setting_cdma_get_username;
- nm_setting_cdma_new;
- nm_setting_clear_secrets;
- nm_setting_clear_secrets_with_flags;
- nm_setting_compare;
- nm_setting_compare_flags_get_type;
- nm_setting_connection_add_permission;
- nm_setting_connection_add_secondary;
- nm_setting_connection_error_get_type;
- nm_setting_connection_error_quark;
- nm_setting_connection_get_autoconnect;
- nm_setting_connection_get_connection_type;
- nm_setting_connection_get_gateway_ping_timeout;
- nm_setting_connection_get_id;
- nm_setting_connection_get_interface_name;
- nm_setting_connection_get_master;
- nm_setting_connection_get_num_permissions;
- nm_setting_connection_get_num_secondaries;
- nm_setting_connection_get_permission;
- nm_setting_connection_get_read_only;
- nm_setting_connection_get_secondary;
- nm_setting_connection_get_slave_type;
- nm_setting_connection_get_timestamp;
- nm_setting_connection_get_type;
- nm_setting_connection_get_uuid;
- nm_setting_connection_get_zone;
- nm_setting_connection_is_slave_type;
- nm_setting_connection_new;
- nm_setting_connection_permissions_user_allowed;
- nm_setting_connection_remove_permission;
- nm_setting_connection_remove_permission_by_value;
- nm_setting_connection_remove_secondary;
- nm_setting_connection_remove_secondary_by_value;
- nm_setting_dcb_error_get_type;
- nm_setting_dcb_error_quark;
- nm_setting_dcb_flags_get_type;
- nm_setting_dcb_get_app_fcoe_flags;
- nm_setting_dcb_get_app_fcoe_mode;
- nm_setting_dcb_get_app_fcoe_priority;
- nm_setting_dcb_get_app_fip_flags;
- nm_setting_dcb_get_app_fip_priority;
- nm_setting_dcb_get_app_iscsi_flags;
- nm_setting_dcb_get_app_iscsi_priority;
- nm_setting_dcb_get_priority_bandwidth;
- nm_setting_dcb_get_priority_flow_control;
- nm_setting_dcb_get_priority_flow_control_flags;
- nm_setting_dcb_get_priority_group_bandwidth;
- nm_setting_dcb_get_priority_group_flags;
- nm_setting_dcb_get_priority_group_id;
- nm_setting_dcb_get_priority_strict_bandwidth;
- nm_setting_dcb_get_priority_traffic_class;
- nm_setting_dcb_get_type;
- nm_setting_dcb_new;
- nm_setting_dcb_set_priority_bandwidth;
- nm_setting_dcb_set_priority_flow_control;
- nm_setting_dcb_set_priority_group_bandwidth;
- nm_setting_dcb_set_priority_group_id;
- nm_setting_dcb_set_priority_strict_bandwidth;
- nm_setting_dcb_set_priority_traffic_class;
- nm_setting_diff;
- nm_setting_diff_result_get_type;
- nm_setting_duplicate;
- nm_setting_enumerate_values;
- nm_setting_error_get_type;
- nm_setting_error_quark;
- nm_setting_generic_error_get_type;
- nm_setting_generic_error_quark;
- nm_setting_generic_get_type;
- nm_setting_generic_new;
- nm_setting_get_name;
- nm_setting_get_secret_flags;
- nm_setting_get_type;
- nm_setting_get_virtual_iface_name;
- nm_setting_gsm_error_get_type;
- nm_setting_gsm_error_quark;
- nm_setting_gsm_get_allowed_bands;
- nm_setting_gsm_get_apn;
- nm_setting_gsm_get_home_only;
- nm_setting_gsm_get_network_id;
- nm_setting_gsm_get_network_type;
- nm_setting_gsm_get_number;
- nm_setting_gsm_get_password;
- nm_setting_gsm_get_password_flags;
- nm_setting_gsm_get_pin;
- nm_setting_gsm_get_pin_flags;
- nm_setting_gsm_get_type;
- nm_setting_gsm_get_username;
- nm_setting_gsm_network_band_get_type;
- nm_setting_gsm_network_type_get_type;
- nm_setting_gsm_new;
- nm_setting_hash_flags_get_type;
- nm_setting_infiniband_error_get_type;
- nm_setting_infiniband_error_quark;
- nm_setting_infiniband_get_mac_address;
- nm_setting_infiniband_get_mtu;
- nm_setting_infiniband_get_p_key;
- nm_setting_infiniband_get_parent;
- nm_setting_infiniband_get_transport_mode;
- nm_setting_infiniband_get_type;
- nm_setting_infiniband_new;
- nm_setting_ip4_config_add_address;
- nm_setting_ip4_config_add_dns;
- nm_setting_ip4_config_add_dns_search;
- nm_setting_ip4_config_add_route;
- nm_setting_ip4_config_clear_addresses;
- nm_setting_ip4_config_clear_dns;
- nm_setting_ip4_config_clear_dns_searches;
- nm_setting_ip4_config_clear_routes;
- nm_setting_ip4_config_error_get_type;
- nm_setting_ip4_config_error_quark;
- nm_setting_ip4_config_get_address;
- nm_setting_ip4_config_get_dhcp_client_id;
- nm_setting_ip4_config_get_dhcp_hostname;
- nm_setting_ip4_config_get_dhcp_send_hostname;
- nm_setting_ip4_config_get_dhcp_timeout;
- nm_setting_ip4_config_get_dns;
- nm_setting_ip4_config_get_dns_search;
- nm_setting_ip4_config_get_ignore_auto_dns;
- nm_setting_ip4_config_get_ignore_auto_routes;
- nm_setting_ip4_config_get_may_fail;
- nm_setting_ip4_config_get_method;
- nm_setting_ip4_config_get_never_default;
- nm_setting_ip4_config_get_num_addresses;
- nm_setting_ip4_config_get_num_dns;
- nm_setting_ip4_config_get_num_dns_searches;
- nm_setting_ip4_config_get_num_routes;
- nm_setting_ip4_config_get_route;
- nm_setting_ip4_config_get_route_metric;
- nm_setting_ip4_config_get_type;
- nm_setting_ip4_config_new;
- nm_setting_ip4_config_remove_address;
- nm_setting_ip4_config_remove_address_by_value;
- nm_setting_ip4_config_remove_dns;
- nm_setting_ip4_config_remove_dns_by_value;
- nm_setting_ip4_config_remove_dns_search;
- nm_setting_ip4_config_remove_dns_search_by_value;
- nm_setting_ip4_config_remove_route;
- nm_setting_ip4_config_remove_route_by_value;
- nm_setting_ip6_config_add_address;
- nm_setting_ip6_config_add_dns;
- nm_setting_ip6_config_add_dns_search;
- nm_setting_ip6_config_add_route;
- nm_setting_ip6_config_clear_addresses;
- nm_setting_ip6_config_clear_dns;
- nm_setting_ip6_config_clear_dns_searches;
- nm_setting_ip6_config_clear_routes;
- nm_setting_ip6_config_error_get_type;
- nm_setting_ip6_config_error_quark;
- nm_setting_ip6_config_get_address;
- nm_setting_ip6_config_get_dhcp_hostname;
- nm_setting_ip6_config_get_dns;
- nm_setting_ip6_config_get_dns_search;
- nm_setting_ip6_config_get_ignore_auto_dns;
- nm_setting_ip6_config_get_ignore_auto_routes;
- nm_setting_ip6_config_get_ip6_privacy;
- nm_setting_ip6_config_get_may_fail;
- nm_setting_ip6_config_get_method;
- nm_setting_ip6_config_get_never_default;
- nm_setting_ip6_config_get_num_addresses;
- nm_setting_ip6_config_get_num_dns;
- nm_setting_ip6_config_get_num_dns_searches;
- nm_setting_ip6_config_get_num_routes;
- nm_setting_ip6_config_get_route;
- nm_setting_ip6_config_get_route_metric;
- nm_setting_ip6_config_get_type;
- nm_setting_ip6_config_new;
- nm_setting_ip6_config_privacy_get_type;
- nm_setting_ip6_config_remove_address;
- nm_setting_ip6_config_remove_address_by_value;
- nm_setting_ip6_config_remove_dns;
- nm_setting_ip6_config_remove_dns_by_value;
- nm_setting_ip6_config_remove_dns_search;
- nm_setting_ip6_config_remove_dns_search_by_value;
- nm_setting_ip6_config_remove_route;
- nm_setting_ip6_config_remove_route_by_value;
- nm_setting_need_secrets;
- nm_setting_new_from_hash;
- nm_setting_olpc_mesh_error_get_type;
- nm_setting_olpc_mesh_error_quark;
- nm_setting_olpc_mesh_get_channel;
- nm_setting_olpc_mesh_get_dhcp_anycast_address;
- nm_setting_olpc_mesh_get_ssid;
- nm_setting_olpc_mesh_get_type;
- nm_setting_olpc_mesh_new;
- nm_setting_ppp_error_get_type;
- nm_setting_ppp_error_quark;
- nm_setting_ppp_get_baud;
- nm_setting_ppp_get_crtscts;
- nm_setting_ppp_get_lcp_echo_failure;
- nm_setting_ppp_get_lcp_echo_interval;
- nm_setting_ppp_get_mppe_stateful;
- nm_setting_ppp_get_mru;
- nm_setting_ppp_get_mtu;
- nm_setting_ppp_get_no_vj_comp;
- nm_setting_ppp_get_noauth;
- nm_setting_ppp_get_nobsdcomp;
- nm_setting_ppp_get_nodeflate;
- nm_setting_ppp_get_refuse_chap;
- nm_setting_ppp_get_refuse_eap;
- nm_setting_ppp_get_refuse_mschap;
- nm_setting_ppp_get_refuse_mschapv2;
- nm_setting_ppp_get_refuse_pap;
- nm_setting_ppp_get_require_mppe;
- nm_setting_ppp_get_require_mppe_128;
- nm_setting_ppp_get_type;
- nm_setting_ppp_new;
- nm_setting_pppoe_error_get_type;
- nm_setting_pppoe_error_quark;
- nm_setting_pppoe_get_password;
- nm_setting_pppoe_get_password_flags;
- nm_setting_pppoe_get_service;
- nm_setting_pppoe_get_type;
- nm_setting_pppoe_get_username;
- nm_setting_pppoe_new;
- nm_setting_secret_flags_get_type;
- nm_setting_serial_error_get_type;
- nm_setting_serial_error_quark;
- nm_setting_serial_get_baud;
- nm_setting_serial_get_bits;
- nm_setting_serial_get_parity;
- nm_setting_serial_get_send_delay;
- nm_setting_serial_get_stopbits;
- nm_setting_serial_get_type;
- nm_setting_serial_new;
- nm_setting_set_secret_flags;
- nm_setting_team_error_get_type;
- nm_setting_team_error_quark;
- nm_setting_team_get_config;
- nm_setting_team_get_interface_name;
- nm_setting_team_get_type;
- nm_setting_team_new;
- nm_setting_team_port_error_get_type;
- nm_setting_team_port_error_quark;
- nm_setting_team_port_get_config;
- nm_setting_team_port_get_type;
- nm_setting_team_port_new;
- nm_setting_to_hash;
- nm_setting_to_string;
- nm_setting_update_secrets;
- nm_setting_verify;
- nm_setting_vlan_add_priority;
- nm_setting_vlan_add_priority_str;
- nm_setting_vlan_clear_priorities;
- nm_setting_vlan_error_get_type;
- nm_setting_vlan_error_quark;
- nm_setting_vlan_get_flags;
- nm_setting_vlan_get_id;
- nm_setting_vlan_get_interface_name;
- nm_setting_vlan_get_num_priorities;
- nm_setting_vlan_get_parent;
- nm_setting_vlan_get_priority;
- nm_setting_vlan_get_type;
- nm_setting_vlan_new;
- nm_setting_vlan_remove_priority;
- nm_setting_vlan_remove_priority_by_value;
- nm_setting_vlan_remove_priority_str_by_value;
- nm_setting_vpn_add_data_item;
- nm_setting_vpn_add_secret;
- nm_setting_vpn_error_get_type;
- nm_setting_vpn_error_quark;
- nm_setting_vpn_foreach_data_item;
- nm_setting_vpn_foreach_secret;
- nm_setting_vpn_get_data_item;
- nm_setting_vpn_get_num_data_items;
- nm_setting_vpn_get_num_secrets;
- nm_setting_vpn_get_secret;
- nm_setting_vpn_get_service_type;
- nm_setting_vpn_get_type;
- nm_setting_vpn_get_user_name;
- nm_setting_vpn_new;
- nm_setting_vpn_remove_data_item;
- nm_setting_vpn_remove_secret;
- nm_setting_wimax_error_get_type;
- nm_setting_wimax_error_quark;
- nm_setting_wimax_get_mac_address;
- nm_setting_wimax_get_network_name;
- nm_setting_wimax_get_type;
- nm_setting_wimax_new;
- nm_setting_wired_add_mac_blacklist_item;
- nm_setting_wired_add_s390_option;
- nm_setting_wired_clear_mac_blacklist_items;
- nm_setting_wired_error_get_type;
- nm_setting_wired_error_quark;
- nm_setting_wired_get_auto_negotiate;
- nm_setting_wired_get_cloned_mac_address;
- nm_setting_wired_get_duplex;
- nm_setting_wired_get_mac_address;
- nm_setting_wired_get_mac_address_blacklist;
- nm_setting_wired_get_mac_blacklist_item;
- nm_setting_wired_get_mtu;
- nm_setting_wired_get_num_mac_blacklist_items;
- nm_setting_wired_get_num_s390_options;
- nm_setting_wired_get_port;
- nm_setting_wired_get_s390_nettype;
- nm_setting_wired_get_s390_option;
- nm_setting_wired_get_s390_option_by_key;
- nm_setting_wired_get_s390_subchannels;
- nm_setting_wired_get_speed;
- nm_setting_wired_get_type;
- nm_setting_wired_get_valid_s390_options;
- nm_setting_wired_new;
- nm_setting_wired_remove_mac_blacklist_item;
- nm_setting_wired_remove_mac_blacklist_item_by_value;
- nm_setting_wired_remove_s390_option;
- nm_setting_wireless_add_mac_blacklist_item;
- nm_setting_wireless_add_seen_bssid;
- nm_setting_wireless_ap_security_compatible;
- nm_setting_wireless_clear_mac_blacklist_items;
- nm_setting_wireless_error_get_type;
- nm_setting_wireless_error_quark;
- nm_setting_wireless_get_band;
- nm_setting_wireless_get_bssid;
- nm_setting_wireless_get_channel;
- nm_setting_wireless_get_cloned_mac_address;
- nm_setting_wireless_get_hidden;
- nm_setting_wireless_get_mac_address;
- nm_setting_wireless_get_mac_address_blacklist;
- nm_setting_wireless_get_mac_blacklist_item;
- nm_setting_wireless_get_mode;
- nm_setting_wireless_get_mtu;
- nm_setting_wireless_get_num_mac_blacklist_items;
- nm_setting_wireless_get_num_seen_bssids;
- nm_setting_wireless_get_powersave;
- nm_setting_wireless_get_rate;
- nm_setting_wireless_get_security;
- nm_setting_wireless_get_seen_bssid;
- nm_setting_wireless_get_ssid;
- nm_setting_wireless_get_tx_power;
- nm_setting_wireless_get_type;
- nm_setting_wireless_new;
- nm_setting_wireless_remove_mac_blacklist_item;
- nm_setting_wireless_remove_mac_blacklist_item_by_value;
- nm_setting_wireless_security_add_group;
- nm_setting_wireless_security_add_pairwise;
- nm_setting_wireless_security_add_proto;
- nm_setting_wireless_security_clear_groups;
- nm_setting_wireless_security_clear_pairwise;
- nm_setting_wireless_security_clear_protos;
- nm_setting_wireless_security_error_get_type;
- nm_setting_wireless_security_error_quark;
- nm_setting_wireless_security_get_auth_alg;
- nm_setting_wireless_security_get_group;
- nm_setting_wireless_security_get_key_mgmt;
- nm_setting_wireless_security_get_leap_password;
- nm_setting_wireless_security_get_leap_password_flags;
- nm_setting_wireless_security_get_leap_username;
- nm_setting_wireless_security_get_num_groups;
- nm_setting_wireless_security_get_num_pairwise;
- nm_setting_wireless_security_get_num_protos;
- nm_setting_wireless_security_get_pairwise;
- nm_setting_wireless_security_get_proto;
- nm_setting_wireless_security_get_psk;
- nm_setting_wireless_security_get_psk_flags;
- nm_setting_wireless_security_get_type;
- nm_setting_wireless_security_get_wep_key;
- nm_setting_wireless_security_get_wep_key_flags;
- nm_setting_wireless_security_get_wep_key_type;
- nm_setting_wireless_security_get_wep_tx_keyidx;
- nm_setting_wireless_security_new;
- nm_setting_wireless_security_remove_group;
- nm_setting_wireless_security_remove_group_by_value;
- nm_setting_wireless_security_remove_pairwise;
- nm_setting_wireless_security_remove_pairwise_by_value;
- nm_setting_wireless_security_remove_proto;
- nm_setting_wireless_security_remove_proto_by_value;
- nm_setting_wireless_security_set_wep_key;
- nm_util_get_private;
- nm_utils_ap_mode_security_valid;
- nm_utils_bin2hexstr;
- nm_utils_check_virtual_device_compatibility;
- nm_utils_deinit;
- nm_utils_escape_ssid;
- nm_utils_file_is_pkcs12;
- nm_utils_file_search_in_paths;
- nm_utils_get_private;
- nm_utils_gvalue_hash_dup;
- nm_utils_hex2byte;
- nm_utils_hexstr2bin;
- nm_utils_hwaddr_atoba;
- nm_utils_hwaddr_aton;
- nm_utils_hwaddr_aton_len;
- nm_utils_hwaddr_len;
- nm_utils_hwaddr_ntoa;
- nm_utils_hwaddr_ntoa_len;
- nm_utils_hwaddr_type;
- nm_utils_hwaddr_valid;
- nm_utils_iface_valid_name;
- nm_utils_inet4_ntop;
- nm_utils_inet6_ntop;
- nm_utils_init;
- nm_utils_ip4_addresses_from_gvalue;
- nm_utils_ip4_addresses_to_gvalue;
- nm_utils_ip4_get_default_prefix;
- nm_utils_ip4_netmask_to_prefix;
- nm_utils_ip4_prefix_to_netmask;
- nm_utils_ip4_routes_from_gvalue;
- nm_utils_ip4_routes_to_gvalue;
- nm_utils_ip6_addresses_from_gvalue;
- nm_utils_ip6_addresses_to_gvalue;
- nm_utils_ip6_dns_from_gvalue;
- nm_utils_ip6_dns_to_gvalue;
- nm_utils_ip6_routes_from_gvalue;
- nm_utils_ip6_routes_to_gvalue;
- nm_utils_is_empty_ssid;
- nm_utils_is_uuid;
- nm_utils_rsa_key_encrypt;
- nm_utils_rsa_key_encrypt_aes;
- nm_utils_same_ssid;
- nm_utils_security_type_get_type;
- nm_utils_security_valid;
- nm_utils_slist_free;
- nm_utils_ssid_to_utf8;
- nm_utils_uuid_generate;
- nm_utils_uuid_generate_from_string;
- nm_utils_wep_key_valid;
- nm_utils_wifi_channel_to_freq;
- nm_utils_wifi_find_next_channel;
- nm_utils_wifi_freq_to_channel;
- nm_utils_wifi_is_channel_valid;
- nm_utils_wpa_psk_valid;
- nm_vlan_flags_get_type;
- nm_vlan_priority_map_get_type;
- nm_wep_key_type_get_type;
-local:
- *;
-};
diff --git a/libnm-util/meson.build b/libnm-util/meson.build
deleted file mode 100644
index e561cb81ee..0000000000
--- a/libnm-util/meson.build
+++ /dev/null
@@ -1,217 +0,0 @@
-libnm_util_inc = include_directories('.')
-
-enums_headers = [version_header] + files(
- 'nm-connection.h',
- 'nm-setting-8021x.h',
- 'nm-setting-adsl.h',
- 'nm-setting-bluetooth.h',
- 'nm-setting-bond.h',
- 'nm-setting-bridge.h',
- 'nm-setting-bridge-port.h',
- 'nm-setting-cdma.h',
- 'nm-setting-connection.h',
- 'nm-setting-dcb.h',
- 'nm-setting-generic.h',
- 'nm-setting-gsm.h',
- 'nm-setting.h',
- 'nm-setting-infiniband.h',
- 'nm-setting-ip4-config.h',
- 'nm-setting-ip6-config.h',
- 'nm-setting-olpc-mesh.h',
- 'nm-setting-ppp.h',
- 'nm-setting-pppoe.h',
- 'nm-setting-serial.h',
- 'nm-setting-team.h',
- 'nm-setting-team-port.h',
- 'nm-setting-vlan.h',
- 'nm-setting-vpn.h',
- 'nm-setting-wimax.h',
- 'nm-setting-wired.h',
- 'nm-setting-wireless.h',
- 'nm-setting-wireless-security.h',
- 'nm-utils.h',
- 'nm-version.h',
-)
-
-headers = enums_headers + files(
- 'NetworkManager.h',
- 'NetworkManagerVPN.h',
-)
-
-install_headers(
- headers,
- subdir: nm_name,
-)
-
-enum_types = 'nm-utils-enum-types'
-
-libnm_utils_enum = gnome.mkenums(
- enum_types,
- sources: enums_headers,
- identifier_prefix: nm_id_prefix,
- c_template: enum_types + '.c.template',
- h_template: enum_types + '.h.template',
- install_header: true,
- install_dir: nm_pkgincludedir,
-)
-
-sources = files(
- 'crypto.c',
- 'nm-connection.c',
- 'nm-param-spec-specialized.c',
- 'nm-setting-8021x.c',
- 'nm-setting-adsl.c',
- 'nm-setting-bluetooth.c',
- 'nm-setting-bridge.c',
- 'nm-setting-bridge-port.c',
- 'nm-setting-bond.c',
- 'nm-setting.c',
- 'nm-setting-cdma.c',
- 'nm-setting-connection.c',
- 'nm-setting-dcb.c',
- 'nm-setting-generic.c',
- 'nm-setting-gsm.c',
- 'nm-setting-infiniband.c',
- 'nm-setting-ip4-config.c',
- 'nm-setting-ip6-config.c',
- 'nm-setting-olpc-mesh.c',
- 'nm-setting-ppp.c',
- 'nm-setting-pppoe.c',
- 'nm-setting-serial.c',
- 'nm-setting-team.c',
- 'nm-setting-team-port.c',
- 'nm-setting-wimax.c',
- 'nm-setting-wired.c',
- 'nm-setting-wireless.c',
- 'nm-setting-wireless-security.c',
- 'nm-setting-vlan.c',
- 'nm-setting-vpn.c',
- 'nm-utils.c',
- 'nm-value-transforms.c',
-)
-
-deps = [
- dbus_dep,
- dbus_glib_dep,
- shared_nm_glib_aux_dep,
- uuid_dep,
-]
-
-common_cflags = [
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL',
-]
-
-cflags = common_cflags + [
- '-DG_LOG_DOMAIN="@0@"'.format(libnm_util_name),
-]
-
-if crypto_gnutls_dep.found()
- libnm_util_crypto_gnutls = static_library(
- 'nm-util-crypto-gnutls',
- sources: [ 'crypto_gnutls.c' ],
- dependencies: deps + [ crypto_gnutls_dep ],
- c_args: cflags,
- )
-endif
-
-if crypto_nss_dep.found()
- libnm_util_crypto_nss = static_library(
- 'nm-util-crypto-nss',
- sources: [ 'crypto_nss.c' ],
- dependencies: deps + [ crypto_nss_dep ],
- c_args: cflags,
- )
-endif
-
-if crypto == 'gnutls'
- libnm_util_crypto = libnm_util_crypto_gnutls
-elif crypto == 'nss'
- libnm_util_crypto = libnm_util_crypto_nss
-else
- error('bug')
-endif
-
-linker_script = join_paths(meson.current_source_dir(), 'libnm-util.ver')
-
-libnm_util = shared_library(
- 'nm-util',
- sources: sources + libnm_utils_enum,
- version: libnm_util_version,
- dependencies: deps,
- c_args: cflags,
- link_args: [
- '-Wl,--version-script,@0@'.format(linker_script),
- ],
- link_depends: linker_script,
- link_with: libnm_util_crypto,
- install: true,
-)
-
-libnm_util_dep = declare_dependency(
- sources: libnm_utils_enum[1],
- include_directories: libnm_util_inc,
- link_with: libnm_util,
-)
-
-pkg.generate(
- libraries: libnm_util,
- version: nm_version,
- name: libnm_util_name,
- description: 'Convenience library for clients of NetworkManager',
- filebase: libnm_util_name,
- subdirs: nm_name,
- requires: 'NetworkManager >= ' + nm_version + ' glib-2.0 dbus-glib-1',
- variables: 'exec_prefix=${prefix}',
-)
-
-if enable_introspection
- gir_sources = sources + headers + libnm_utils_enum
-
- gir_includes = [
- 'DBusGLib-1.0',
- 'GObject-2.0',
- ]
-
- libnm_util_gir = gnome.generate_gir(
- libnm_util,
- sources: gir_sources,
- nsversion: nm_gir_version,
- namespace: nm_name,
- identifier_prefix: nm_id_prefix,
- symbol_prefix: nm_id_prefix.to_lower(),
- export_packages: libnm_util_name,
- includes: gir_includes,
- install: true,
- )
-
- libnm_util_gir_dep = declare_dependency(
- sources: libnm_util_gir,
- link_with: libnm_util,
- )
-endif
-
-test(
- 'check-local-exports-' + libnm_util_name,
- check_exports,
- args: [libnm_util.full_path(), linker_script],
-)
-
-sources = files(
- 'crypto.c',
-)
-
-deps = [
- shared_nm_glib_aux_dep,
-]
-
-libtest_crypto = static_library(
- 'test-crypto',
- sources: sources,
- dependencies: deps,
- link_with: libnm_util_crypto,
- c_args: cflags,
-)
-
-if enable_tests
- subdir('tests')
-endif
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
deleted file mode 100644
index 3ddea2d742..0000000000
--- a/libnm-util/nm-connection.c
+++ /dev/null
@@ -1,2212 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <dbus/dbus-glib.h>
-#include <string.h>
-
-#include "nm-connection.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-#include "nm-setting-8021x.h"
-#include "nm-setting-bluetooth.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-infiniband.h"
-#include "nm-setting-ip4-config.h"
-#include "nm-setting-ip6-config.h"
-#include "nm-setting-ppp.h"
-#include "nm-setting-pppoe.h"
-#include "nm-setting-wimax.h"
-#include "nm-setting-wired.h"
-#include "nm-setting-adsl.h"
-#include "nm-setting-wireless.h"
-#include "nm-setting-wireless-security.h"
-#include "nm-setting-serial.h"
-#include "nm-setting-vpn.h"
-#include "nm-setting-olpc-mesh.h"
-#include "nm-setting-bond.h"
-#include "nm-setting-team.h"
-#include "nm-setting-team-port.h"
-#include "nm-setting-bridge.h"
-#include "nm-setting-bridge-port.h"
-#include "nm-setting-vlan.h"
-#include "nm-setting-serial.h"
-#include "nm-setting-gsm.h"
-#include "nm-setting-cdma.h"
-
-/**
- * SECTION:nm-connection
- * @short_description: Describes a connection to specific network or provider
- * @include: nm-connection.h
- *
- * An #NMConnection describes all the settings and configuration values that
- * are necessary to configure network devices for operation on a specific
- * network. Connections are the fundamental operating object for
- * NetworkManager; no device is connected without a #NMConnection, or
- * disconnected without having been connected with a #NMConnection.
- *
- * Each #NMConnection contains a list of #NMSetting objects usually referenced
- * by name (using nm_connection_get_setting_by_name()) or by type (with
- * nm_connection_get_setting()). The settings describe the actual parameters
- * with which the network devices are configured, including device-specific
- * parameters (MTU, SSID, APN, channel, rate, etc) and IP-level parameters
- * (addresses, routes, addressing methods, etc).
- *
- */
-
-/**
- * nm_connection_error_quark:
- *
- * Registers an error quark for #NMConnection if necessary.
- *
- * Returns: the error quark used for #NMConnection errors.
- **/
-GQuark
-nm_connection_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-connection-error-quark");
- return quark;
-}
-
-typedef struct {
- GHashTable *settings;
-
- /* D-Bus path of the connection, if any */
- char *path;
-} NMConnectionPrivate;
-
-#define NM_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CONNECTION, NMConnectionPrivate))
-
-G_DEFINE_TYPE (NMConnection, nm_connection, G_TYPE_OBJECT)
-
-enum {
- PROP_0,
- PROP_PATH,
-
- LAST_PROP
-};
-
-enum {
- SECRETS_UPDATED,
- SECRETS_CLEARED,
- CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static NMSettingVerifyResult _nm_connection_verify (NMConnection *connection, GError **error);
-
-/*****************************************************************************/
-
-/**
- * nm_connection_lookup_setting_type:
- * @name: a setting name
- *
- * Returns the #GType of the setting's class for a given setting name.
- *
- * Returns: the #GType of the setting's class
- **/
-GType
-nm_connection_lookup_setting_type (const char *name)
-{
- return _nm_setting_lookup_setting_type (name);
-}
-
-/**
- * nm_connection_lookup_setting_type_by_quark:
- * @error_quark: a setting error quark
- *
- * Returns the #GType of the setting's class for a given setting error quark.
- * Useful for figuring out which setting a returned error is for.
- *
- * Returns: the #GType of the setting's class
- **/
-GType
-nm_connection_lookup_setting_type_by_quark (GQuark error_quark)
-{
- return _nm_setting_lookup_setting_type_by_quark (error_quark);
-}
-
-/**
- * nm_connection_create_setting:
- * @name: a setting name
- *
- * Create a new #NMSetting object of the desired type, given a setting name.
- *
- * Returns: (transfer full): the new setting object, or %NULL if the setting name was unknown
- **/
-NMSetting *
-nm_connection_create_setting (const char *name)
-{
- GType type;
- NMSetting *setting = NULL;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- type = nm_connection_lookup_setting_type (name);
- if (type)
- setting = (NMSetting *) g_object_new (type, NULL);
-
- return setting;
-}
-
-static void
-setting_changed_cb (NMSetting *setting,
- GParamSpec *pspec,
- NMConnection *self)
-{
- g_signal_emit (self, signals[CHANGED], 0);
-}
-
-static gboolean
-_setting_release (gpointer key, gpointer value, gpointer user_data)
-{
- g_signal_handlers_disconnect_by_func (user_data, setting_changed_cb, value);
- return TRUE;
-}
-
-static void
-_nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
-{
- NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
- const char *name = G_OBJECT_TYPE_NAME (setting);
- NMSetting *s_old;
-
- if ((s_old = g_hash_table_lookup (priv->settings, (gpointer) name)))
- g_signal_handlers_disconnect_by_func (s_old, setting_changed_cb, connection);
- g_hash_table_insert (priv->settings, (gpointer) name, setting);
- /* Listen for property changes so we can emit the 'changed' signal */
- g_signal_connect (setting, "notify", (GCallback) setting_changed_cb, connection);
-}
-
-/**
- * nm_connection_add_setting:
- * @connection: a #NMConnection
- * @setting: (transfer full): the #NMSetting to add to the connection object
- *
- * Adds a #NMSetting to the connection, replacing any previous #NMSetting of the
- * same name which has previously been added to the #NMConnection. The
- * connection takes ownership of the #NMSetting object and does not increase
- * the setting object's reference count.
- **/
-void
-nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
-{
- g_return_if_fail (NM_IS_CONNECTION (connection));
- g_return_if_fail (NM_IS_SETTING (setting));
-
- _nm_connection_add_setting (connection, setting);
- g_signal_emit (connection, signals[CHANGED], 0);
-}
-
-/**
- * nm_connection_remove_setting:
- * @connection: a #NMConnection
- * @setting_type: the #GType of the setting object to remove
- *
- * Removes the #NMSetting with the given #GType from the #NMConnection. This
- * operation dereferences the #NMSetting object.
- **/
-void
-nm_connection_remove_setting (NMConnection *connection, GType setting_type)
-{
- NMConnectionPrivate *priv;
- NMSetting *setting;
- const char *setting_name;
-
- g_return_if_fail (NM_IS_CONNECTION (connection));
- g_return_if_fail (g_type_is_a (setting_type, NM_TYPE_SETTING));
-
- priv = NM_CONNECTION_GET_PRIVATE (connection);
- setting_name = g_type_name (setting_type);
- setting = g_hash_table_lookup (priv->settings, setting_name);
- if (setting) {
- g_signal_handlers_disconnect_by_func (setting, setting_changed_cb, connection);
- g_hash_table_remove (priv->settings, setting_name);
- g_signal_emit (connection, signals[CHANGED], 0);
- }
-}
-
-/**
- * nm_connection_get_setting:
- * @connection: a #NMConnection
- * @setting_type: the #GType of the setting object to return
- *
- * Gets the #NMSetting with the given #GType, if one has been previously added
- * to the #NMConnection.
- *
- * Returns: (transfer none): the #NMSetting, or %NULL if no setting of that type was previously
- * added to the #NMConnection
- **/
-NMSetting *
-nm_connection_get_setting (NMConnection *connection, GType setting_type)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
- g_return_val_if_fail (g_type_is_a (setting_type, NM_TYPE_SETTING), NULL);
-
- return (NMSetting *) g_hash_table_lookup (NM_CONNECTION_GET_PRIVATE (connection)->settings,
- g_type_name (setting_type));
-}
-
-/**
- * nm_connection_get_setting_by_name:
- * @connection: a #NMConnection
- * @name: a setting name
- *
- * Gets the #NMSetting with the given name, if one has been previously added
- * the #NMConnection.
- *
- * Returns: (transfer none): the #NMSetting, or %NULL if no setting with that name was previously
- * added to the #NMConnection
- **/
-NMSetting *
-nm_connection_get_setting_by_name (NMConnection *connection, const char *name)
-{
- GType type;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- type = nm_connection_lookup_setting_type (name);
-
- return type ? nm_connection_get_setting (connection, type) : NULL;
-}
-
-static gboolean
-validate_permissions_type (GHashTable *hash, GError **error)
-{
- GHashTable *s_con;
- GValue *permissions;
-
- /* Ensure the connection::permissions item (if present) is the correct
- * type, otherwise the g_object_set() will throw a warning and ignore the
- * error, leaving us with no permissions.
- */
- s_con = g_hash_table_lookup (hash, NM_SETTING_CONNECTION_SETTING_NAME);
- if (s_con) {
- permissions = g_hash_table_lookup (s_con, NM_SETTING_CONNECTION_PERMISSIONS);
- if (permissions) {
- if ( !G_VALUE_HOLDS (permissions, G_TYPE_STRV)
- && !G_VALUE_HOLDS (permissions, DBUS_TYPE_G_LIST_OF_STRING)) {
- g_set_error_literal (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- "Wrong permissions property type; should be a list of strings.");
- return FALSE;
- }
- }
- }
- return TRUE;
-}
-
-/**
- * _nm_connection_replace_settings:
- * @connection: a #NMConnection
- * @new_settings: (element-type utf8 GLib.HashTable): a #GHashTable of settings
- **/
-void
-_nm_connection_replace_settings (NMConnection *connection,
- GHashTable *new_settings)
-{
- NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
- GHashTableIter iter;
- const char *setting_name;
- GHashTable *setting_hash;
- gboolean changed;
-
- g_return_if_fail (NM_IS_CONNECTION (connection));
- g_return_if_fail (new_settings != NULL);
-
- priv = NM_CONNECTION_GET_PRIVATE (connection);
-
- if ((changed = g_hash_table_size (priv->settings) > 0))
- g_hash_table_foreach_remove (priv->settings, _setting_release, connection);
-
- g_hash_table_iter_init (&iter, new_settings);
- while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting_hash)) {
- GType type = nm_connection_lookup_setting_type (setting_name);
-
- if (type) {
- NMSetting *setting = nm_setting_new_from_hash (type, setting_hash);
-
- if (setting) {
- _nm_connection_add_setting (connection, setting);
- changed = TRUE;
- }
- }
- }
-
- if (changed)
- g_signal_emit (connection, signals[CHANGED], 0);
-}
-
-/**
- * nm_connection_replace_settings:
- * @connection: a #NMConnection
- * @new_settings: (element-type utf8 GLib.HashTable): a #GHashTable of settings
- * @error: location to store error, or %NULL
- *
- * Returns: %TRUE if the settings were valid and added to the connection, %FALSE
- * if they were not
- **/
-gboolean
-nm_connection_replace_settings (NMConnection *connection,
- GHashTable *new_settings,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (new_settings != NULL, FALSE);
- g_return_val_if_fail (!error || !*error, FALSE);
-
- if (!validate_permissions_type (new_settings, error))
- return FALSE;
-
- _nm_connection_replace_settings (connection, new_settings);
- return nm_connection_verify (connection, error);
-}
-
-/**
- * nm_connection_replace_settings_from_connection:
- * @connection: a #NMConnection
- * @new_connection: a #NMConnection to replace the settings of @connection with
- * @error: location to store error, or %NULL
- *
- * Deep-copies the settings of @new_conenction and replaces the settings of @connection
- * with the copied settings.
- *
- * Returns: %TRUE if the settings were valid after replacing the connection, %FALSE
- * if they were not. Regardless of whether %TRUE or %FALSE is returned, the connection
- * is successfully replaced. %FALSE only means, that the connection does not verify
- * at the end of the operation.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_connection_replace_settings_from_connection (NMConnection *connection,
- NMConnection *new_connection,
- GError **error)
-{
- NMConnectionPrivate *priv;
- GHashTableIter iter;
- NMSetting *setting;
- gboolean changed = FALSE;
- gboolean valid;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (NM_IS_CONNECTION (new_connection), FALSE);
- g_return_val_if_fail (!error || !*error, FALSE);
-
- /* When 'connection' and 'new_connection' are the same object simply return
- * in order not to destroy 'connection' */
- if (connection == new_connection)
- goto out;
-
- /* No need to validate permissions like nm_connection_replace_settings()
- * since we're dealing with an NMConnection which has already done that.
- */
-
- priv = NM_CONNECTION_GET_PRIVATE (connection);
- if ((changed = g_hash_table_size (priv->settings) > 0))
- g_hash_table_foreach_remove (priv->settings, _setting_release, connection);
-
- if (g_hash_table_size (NM_CONNECTION_GET_PRIVATE (new_connection)->settings)) {
- g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (new_connection)->settings);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting))
- _nm_connection_add_setting (connection, nm_setting_duplicate (setting));
- changed = TRUE;
- }
-
-out:
- valid = nm_connection_verify (connection, error);
- if (changed)
- g_signal_emit (connection, signals[CHANGED], 0);
- return valid;
-}
-
-/**
- * nm_connection_compare:
- * @a: a #NMConnection
- * @b: a second #NMConnection to compare with the first
- * @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
- *
- * Compares two #NMConnection objects for similarity, with comparison behavior
- * modified by a set of flags. See nm_setting_compare() for a description of
- * each flag's behavior.
- *
- * Returns: %TRUE if the comparison succeeds, %FALSE if it does not
- **/
-gboolean
-nm_connection_compare (NMConnection *a,
- NMConnection *b,
- NMSettingCompareFlags flags)
-{
- GHashTableIter iter;
- NMSetting *src;
-
- if (a == b)
- return TRUE;
- if (!a || !b)
- return FALSE;
-
- /* B / A: ensure settings in B that are not in A make the comparison fail */
- if (g_hash_table_size (NM_CONNECTION_GET_PRIVATE (a)->settings) !=
- g_hash_table_size (NM_CONNECTION_GET_PRIVATE (b)->settings))
- return FALSE;
-
- /* A / B: ensure all settings in A match corresponding ones in B */
- g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (a)->settings);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &src)) {
- NMSetting *cmp = nm_connection_get_setting (b, G_OBJECT_TYPE (src));
-
- if (!cmp || !nm_setting_compare (src, cmp, flags))
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-diff_one_connection (NMConnection *a,
- NMConnection *b,
- NMSettingCompareFlags flags,
- gboolean invert_results,
- GHashTable *diffs)
-{
- NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (a);
- GHashTableIter iter;
- NMSetting *a_setting = NULL;
-
- g_hash_table_iter_init (&iter, priv->settings);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &a_setting)) {
- NMSetting *b_setting = NULL;
- const char *setting_name = nm_setting_get_name (a_setting);
- GHashTable *results;
- gboolean new_results = TRUE;
-
- if (b)
- b_setting = nm_connection_get_setting (b, G_OBJECT_TYPE (a_setting));
-
- results = g_hash_table_lookup (diffs, setting_name);
- if (results)
- new_results = FALSE;
-
- if (!nm_setting_diff (a_setting, b_setting, flags, invert_results, &results)) {
- if (new_results)
- g_hash_table_insert (diffs, g_strdup (setting_name), results);
- }
- }
-}
-
-/**
- * nm_connection_diff:
- * @a: a #NMConnection
- * @b: a second #NMConnection to compare with the first
- * @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
- * @out_settings: (element-type utf8 GLib.HashTable): if the
- * connections differ, on return a hash table mapping setting names to
- * second-level GHashTable (utf8 to guint32), which contains the key names that
- * differ mapped to one or more of %NMSettingDiffResult as a bitfield
- *
- * Compares two #NMConnection objects for similarity, with comparison behavior
- * modified by a set of flags. See nm_setting_compare() for a description of
- * each flag's behavior. If the connections differ, settings and keys within
- * each setting that differ are added to the returned @out_settings hash table.
- * No values are returned, only key names.
- *
- * Returns: %TRUE if the connections contain the same values, %FALSE if they do
- * not
- **/
-gboolean
-nm_connection_diff (NMConnection *a,
- NMConnection *b,
- NMSettingCompareFlags flags,
- GHashTable **out_settings)
-{
- GHashTable *diffs;
-
- g_return_val_if_fail (NM_IS_CONNECTION (a), FALSE);
- g_return_val_if_fail (out_settings != NULL, FALSE);
- g_return_val_if_fail (*out_settings == NULL, FALSE);
- if (b)
- g_return_val_if_fail (NM_IS_CONNECTION (b), FALSE);
-
- if (a == b)
- return TRUE;
-
- diffs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
-
- /* Diff A to B, then B to A to capture keys in B that aren't in A */
- diff_one_connection (a, b, flags, FALSE, diffs);
- if (b)
- diff_one_connection (b, a, flags, TRUE, diffs);
-
- if (g_hash_table_size (diffs) == 0)
- g_hash_table_destroy (diffs);
- else
- *out_settings = diffs;
-
- return *out_settings ? FALSE : TRUE;
-}
-
-static gboolean
-_normalize_virtual_iface_name (NMConnection *self)
-{
- NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (self);
- GHashTableIter h_iter;
- NMSetting *setting;
- NMSettingConnection *s_con;
- const char *interface_name;
- char *virtual_iface_name = NULL;
- gboolean was_modified = FALSE;
- const char *prop_name = NULL;
-
- /* search for settings that might need normalization of the interface name. */
- g_hash_table_iter_init (&h_iter, priv->settings);
- while ( !prop_name
- && g_hash_table_iter_next (&h_iter, NULL, (void **) &setting)) {
- if (NM_IS_SETTING_BOND (setting))
- prop_name = NM_SETTING_BOND_INTERFACE_NAME;
- else if (NM_IS_SETTING_BRIDGE (setting))
- prop_name = NM_SETTING_BRIDGE_INTERFACE_NAME;
- else if (NM_IS_SETTING_TEAM (setting))
- prop_name = NM_SETTING_TEAM_INTERFACE_NAME;
- else if (NM_IS_SETTING_VLAN (setting))
- prop_name = NM_SETTING_VLAN_INTERFACE_NAME;
- }
- if (!prop_name)
- return FALSE;
-
- s_con = nm_connection_get_setting_connection (self);
- g_return_val_if_fail (s_con, FALSE);
-
- interface_name = nm_setting_connection_get_interface_name (s_con);
-
- /* read the potential virtual_iface_name from the setting. */
- g_object_get (setting, prop_name, &virtual_iface_name, NULL);
-
- if (g_strcmp0 (interface_name, virtual_iface_name) != 0) {
- if (interface_name) {
- /* interface_name is set and overwrites the virtual_iface_name. */
- g_object_set (setting, prop_name, interface_name, NULL);
- } else {
- /* interface in NMSettingConnection must be set. */
- g_object_set (s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, virtual_iface_name, NULL);
- }
- was_modified = TRUE;
- }
-
- g_free (virtual_iface_name);
-
- return was_modified;
-}
-
-static gboolean
-_normalize_ip_config (NMConnection *self, GHashTable *parameters)
-{
- NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
- const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
- const char *default_ip6_method = NULL;
- NMSettingIP4Config *s_ip4;
- NMSettingIP6Config *s_ip6;
- NMSetting *setting;
-
- if (parameters)
- default_ip6_method = g_hash_table_lookup (parameters, NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD);
- if (!default_ip6_method)
- default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
-
- s_ip4 = nm_connection_get_setting_ip4_config (self);
- s_ip6 = nm_connection_get_setting_ip6_config (self);
-
- if (nm_setting_connection_get_master (s_con)) {
- /* Slave connections don't have IP configuration. */
-
- if (s_ip4)
- nm_connection_remove_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
-
- if (s_ip6)
- nm_connection_remove_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
-
- return s_ip4 || s_ip6;
- } else {
- /* Ensure all non-slave connections have IP4 and IP6 settings objects. If no
- * IP6 setting was specified, then assume that means IP6 config is allowed
- * to fail. But if no IP4 setting was specified, assume the caller was just
- * being lazy.
- */
- if (!s_ip4) {
- setting = nm_setting_ip4_config_new ();
-
- g_object_set (setting,
- NM_SETTING_IP4_CONFIG_METHOD, default_ip4_method,
- NULL);
- nm_connection_add_setting (self, setting);
- }
- if (!s_ip6) {
- setting = nm_setting_ip6_config_new ();
-
- g_object_set (setting,
- NM_SETTING_IP6_CONFIG_METHOD, default_ip6_method,
- NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
- NULL);
- nm_connection_add_setting (self, setting);
- }
- return !s_ip4 || !s_ip6;
- }
-}
-
-/**
- * nm_connection_verify:
- * @connection: the #NMConnection to verify
- * @error: location to store error, or %NULL
- *
- * Validates the connection and all its settings. Each setting's properties
- * have allowed values, and some values are dependent on other values. For
- * example, if a Wi-Fi connection is security enabled, the #NMSettingWireless
- * setting object's 'security' property must contain the setting name of the
- * #NMSettingWirelessSecurity object, which must also be present in the
- * connection for the connection to be valid. As another example, the
- * #NMSettingWired object's 'mac-address' property must be a validly formatted
- * MAC address. The returned #GError contains information about which
- * setting and which property failed validation, and how it failed validation.
- *
- * Returns: %TRUE if the connection is valid, %FALSE if it is not
- **/
-gboolean
-nm_connection_verify (NMConnection *connection, GError **error)
-{
- NMSettingVerifyResult result;
-
- result = _nm_connection_verify (connection, error);
-
- /* we treat normalizable connections as valid. */
- if (result == NM_SETTING_VERIFY_NORMALIZABLE)
- g_clear_error (error);
-
- return result == NM_SETTING_VERIFY_SUCCESS || result == NM_SETTING_VERIFY_NORMALIZABLE;
-}
-
-static NMSettingVerifyResult
-_nm_connection_verify (NMConnection *connection, GError **error)
-{
- NMConnectionPrivate *priv;
- NMSettingConnection *s_con;
- NMSettingIP4Config *s_ip4;
- NMSettingIP6Config *s_ip6;
- GHashTableIter iter;
- gpointer value;
- GSList *all_settings = NULL, *setting_i;
- NMSettingVerifyResult success = NM_SETTING_VERIFY_ERROR;
- NMSetting *base;
- const char *ctype;
- GError *normalizable_error = NULL;
- NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS;
-
- if (error)
- g_return_val_if_fail (*error == NULL, NM_SETTING_VERIFY_ERROR);
-
- if (!NM_IS_CONNECTION (connection)) {
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_UNKNOWN,
- "invalid connection; failed verification");
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_SETTING_VERIFY_ERROR);
- }
-
- priv = NM_CONNECTION_GET_PRIVATE (connection);
-
- /* First, make sure there's at least 'connection' setting */
- s_con = nm_connection_get_setting_connection (connection);
- if (!s_con) {
- g_set_error_literal (error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND,
- "connection setting not found");
- goto EXIT;
- }
-
- /* Build up the list of settings */
- g_hash_table_iter_init (&iter, priv->settings);
- while (g_hash_table_iter_next (&iter, NULL, &value)) {
- /* Order NMSettingConnection so that it will be verified first.
- * The reason is, that NMSettingConnection:verify() modifies the connection
- * by setting NMSettingConnection:interface_name. So we want to call that
- * verify() first, because the order can affect the outcome.
- * Another reason is, that errors in this setting might be more fundamental
- * and should be checked and reported with higher priority.
- * Another reason is, that some settings look especially at the
- * NMSettingConnection, so they find it first in the all_settings list. */
- if (value == s_con)
- all_settings = g_slist_append (all_settings, value);
- else
- all_settings = g_slist_prepend (all_settings, value);
- }
- all_settings = g_slist_reverse (all_settings);
-
- /* Now, run the verify function of each setting */
- for (setting_i = all_settings; setting_i; setting_i = setting_i->next) {
- GError *verify_error = NULL;
- NMSettingVerifyResult verify_result;
-
- /* verify all settings. We stop if we find the first non-normalizable
- * @NM_SETTING_VERIFY_ERROR. If we find normalizable errors we continue
- * but remember the error to return it to the user.
- * @NM_SETTING_VERIFY_NORMALIZABLE_ERROR has a higher priority then
- * @NM_SETTING_VERIFY_NORMALIZABLE, so, if we encounter such an error type,
- * we remember it instead (to return it as output).
- **/
- verify_result = _nm_setting_verify (NM_SETTING (setting_i->data), all_settings, &verify_error);
- if (verify_result == NM_SETTING_VERIFY_NORMALIZABLE ||
- verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR) {
- if ( verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR
- && normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE) {
- /* NORMALIZABLE_ERROR has higher priority. */
- g_clear_error (&normalizable_error);
- }
- if (!normalizable_error) {
- g_propagate_error (&normalizable_error, verify_error);
- verify_error = NULL;
- normalizable_error_type = verify_result;
- }
- } else if (verify_result != NM_SETTING_VERIFY_SUCCESS) {
- g_propagate_error (error, verify_error);
- g_slist_free (all_settings);
- g_return_val_if_fail (verify_result == NM_SETTING_VERIFY_ERROR, success);
- goto EXIT;
- }
- g_clear_error (&verify_error);
- }
- g_slist_free (all_settings);
-
- /* Now make sure the given 'type' setting can actually be the base setting
- * of the connection. Can't have type=ppp for example.
- */
- ctype = nm_setting_connection_get_connection_type (s_con);
- if (!ctype) {
- g_set_error_literal (error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID,
- "connection type missing");
- goto EXIT;
- }
-
- base = nm_connection_get_setting_by_name (connection, ctype);
- if (!base) {
- g_set_error_literal (error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID,
- "base setting GType not found");
- goto EXIT;
- }
-
- if (!_nm_setting_is_base_type (base)) {
- g_set_error (error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID,
- "connection type '%s' is not a base type",
- ctype);
- goto EXIT;
- }
-
- s_ip4 = nm_connection_get_setting_ip4_config (connection);
- s_ip6 = nm_connection_get_setting_ip6_config (connection);
-
- if (nm_setting_connection_get_master (s_con)) {
- if ((normalizable_error_type == NM_SETTING_VERIFY_SUCCESS ||
- (normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE)) && (s_ip4 || s_ip6)) {
- g_clear_error (&normalizable_error);
- g_set_error (&normalizable_error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_INVALID_SETTING,
- "slave connection cannot have an IP%c setting",
- s_ip4 ? '4' : '6');
- /* having a slave with IP config *was* and is a verify() error. */
- normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
- }
- } else {
- if (normalizable_error_type == NM_SETTING_VERIFY_SUCCESS && (!s_ip4 || !s_ip6)) {
- g_set_error (&normalizable_error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
- "connection needs an IP%c setting",
- !s_ip4 ? '4' : '6');
- /* having a master without IP config was not a verify() error, accept
- * it for backward compatibility. */
- normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
- }
- }
-
- if (normalizable_error_type != NM_SETTING_VERIFY_SUCCESS) {
- g_propagate_error (error, normalizable_error);
- normalizable_error = NULL;
- success = normalizable_error_type;
- } else
- success = NM_SETTING_VERIFY_SUCCESS;
-
-EXIT:
- g_clear_error (&normalizable_error);
- return success;
-}
-
-/**
- * nm_connection_normalize:
- * @connection: the #NMConnection to normalize
- * @parameters: (allow-none) (element-type utf8 gpointer): a #GHashTable with
- * normalization parameters to allow customization of the normalization by providing
- * specific arguments. Unknown arguments will be ignored and the default will be
- * used. The keys must be strings, hashed by g_str_hash() and g_str_equal() functions.
- * The values are opaque and depend on the parameter name.
- * @modified: (out) (allow-none): outputs whether any settings were modified.
- * @error: location to store error, or %NULL. Contains the reason,
- * why the connection is invalid, if the function returns an error.
- *
- * Does some basic normalization and fixup of well known inconsistencies
- * and deprecated fields. If the connection was modified in any way,
- * the output parameter @modified is set %TRUE.
- *
- * Finally the connection will be verified and %TRUE returns if the connection
- * is valid. As this function only performs some specific normalization steps
- * it cannot repair all connections. If the connection has errors that
- * cannot be normalized, the connection will not be modified.
- *
- * Returns: %TRUE if the connection is valid, %FALSE if it is not
- *
- * Since: 1.0
- **/
-gboolean
-nm_connection_normalize (NMConnection *connection,
- GHashTable *parameters,
- gboolean *modified,
- GError **error)
-{
- NMSettingVerifyResult success;
- gboolean was_modified = FALSE;
- GError *normalizable_error = NULL;
-
- success = _nm_connection_verify (connection, &normalizable_error);
-
- if (success == NM_SETTING_VERIFY_ERROR ||
- success == NM_SETTING_VERIFY_SUCCESS) {
- if (normalizable_error)
- g_propagate_error (error, normalizable_error);
- goto EXIT;
- }
- g_assert (success == NM_SETTING_VERIFY_NORMALIZABLE || success == NM_SETTING_VERIFY_NORMALIZABLE_ERROR);
- g_clear_error (&normalizable_error);
-
- /* Try to perform all kind of normalizations on the settings to fix it.
- * We only do this, after verifying that the connection contains no un-normalizable
- * errors, because in that case we rather fail without touching the settings. */
-
- was_modified |= _normalize_virtual_iface_name (connection);
- was_modified |= _normalize_ip_config (connection, parameters);
-
- /* Verify anew. */
- success = _nm_connection_verify (connection, error);
-
- /* we would expect, that after normalization, the connection can be verified. */
- g_return_val_if_fail (success == NM_SETTING_VERIFY_SUCCESS, success);
-
- /* we would expect, that the connection was modified during normalization. */
- g_return_val_if_fail (was_modified, success);
-
-EXIT:
- if (modified)
- *modified = was_modified;
-
- return success == NM_SETTING_VERIFY_SUCCESS;
-}
-
-/**
- * nm_connection_update_secrets:
- * @connection: the #NMConnection
- * @setting_name: the setting object name to which the secrets apply
- * @secrets: (element-type utf8 GObject.Value): a #GHashTable mapping
- * string:#GValue of setting property names and secrets of the given @setting_name
- * @error: location to store error, or %NULL
- *
- * Update the specified setting's secrets, given a hash table of secrets
- * intended for that setting (deserialized from D-Bus for example). Will also
- * extract the given setting's secrets hash if given a hash of hashes, as would
- * be returned from nm_connection_to_hash(). If @setting_name is %NULL, expects
- * a fully serialized #NMConnection as returned by nm_connection_to_hash() and
- * will update all secrets from all settings contained in @secrets.
- *
- * Returns: %TRUE if the secrets were successfully updated, %FALSE if the update
- * failed (tried to update secrets for a setting that doesn't exist, etc)
- **/
-gboolean
-nm_connection_update_secrets (NMConnection *connection,
- const char *setting_name,
- GHashTable *secrets,
- GError **error)
-{
- NMSetting *setting;
- gboolean success = TRUE, updated = FALSE;
- GHashTable *setting_hash = NULL;
- GHashTableIter iter;
- const char *key;
- gboolean hashed_connection = FALSE;
- int success_detail;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (secrets != NULL, FALSE);
- if (error)
- g_return_val_if_fail (*error == NULL, FALSE);
-
- /* Empty @secrets means success */
- if (g_hash_table_size (secrets) == 0)
- return TRUE;
-
- /* For backwards compatibility, this function accepts either a hashed
- * connection (GHashTable of GHashTables of GValues) or a single hashed
- * setting (GHashTable of GValues).
- */
- g_hash_table_iter_init (&iter, secrets);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, NULL)) {
- if (_nm_setting_lookup_setting_type (key) != G_TYPE_INVALID) {
- /* @secrets looks like a hashed connection */
- hashed_connection = TRUE;
- break;
- }
- }
-
- if (setting_name) {
- /* Update just one setting's secrets */
- setting = nm_connection_get_setting_by_name (connection, setting_name);
- if (!setting) {
- g_set_error_literal (error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
- setting_name);
- return FALSE;
- }
-
- if (hashed_connection) {
- setting_hash = g_hash_table_lookup (secrets, setting_name);
- if (!setting_hash) {
- /* The hashed connection that didn't contain any secrets for
- * @setting_name; just return success.
- */
- return TRUE;
- }
- }
-
- g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
- success_detail = _nm_setting_update_secrets (setting,
- setting_hash ?: secrets,
- error);
- g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
-
- if (success_detail == NM_SETTING_UPDATE_SECRET_ERROR)
- return FALSE;
- if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
- updated = TRUE;
- } else {
- if (!hashed_connection) {
- g_set_error_literal (error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
- key);
- return FALSE;
- }
-
- /* check first, whether all the settings exist... */
- g_hash_table_iter_init (&iter, secrets);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, NULL)) {
- setting = nm_connection_get_setting_by_name (connection, key);
- if (!setting) {
- g_set_error_literal (error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
- key);
- return FALSE;
- }
- }
-
- /* Update each setting with any secrets from the hashed connection */
- g_hash_table_iter_init (&iter, secrets);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &setting_hash)) {
- /* Update the secrets for this setting */
- setting = nm_connection_get_setting_by_name (connection, key);
-
- g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
- success_detail = _nm_setting_update_secrets (setting, setting_hash, error);
- g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
-
- if (success_detail == NM_SETTING_UPDATE_SECRET_ERROR) {
- success = FALSE;
- break;
- }
- if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
- updated = TRUE;
- }
- }
-
- if (updated) {
- g_signal_emit (connection, signals[SECRETS_UPDATED], 0, setting_name);
- g_signal_emit (connection, signals[CHANGED], 0);
- }
-
- return success;
-}
-
-/**
- * nm_connection_need_secrets:
- * @connection: the #NMConnection
- * @hints: (out) (element-type utf8) (allow-none) (transfer container):
- * the address of a pointer to a #GPtrArray, initialized to %NULL, which on
- * return points to an allocated #GPtrArray containing the property names of
- * secrets of the #NMSetting which may be required; the caller owns the array
- * and must free the array itself with g_ptr_array_free(), but not free its
- * elements
- *
- * Returns the name of the first setting object in the connection which would
- * need secrets to make a successful connection. The returned hints are only
- * intended as a guide to what secrets may be required, because in some
- * circumstances, there is no way to conclusively determine exactly which
- * secrets are needed.
- *
- * Returns: the setting name of the #NMSetting object which has invalid or
- * missing secrets
- **/
-const char *
-nm_connection_need_secrets (NMConnection *connection,
- GPtrArray **hints)
-{
- NMConnectionPrivate *priv;
- GHashTableIter hiter;
- GSList *settings = NULL;
- GSList *iter;
- const char *name = NULL;
- NMSetting *setting;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
- if (hints)
- g_return_val_if_fail (*hints == NULL, NULL);
-
- priv = NM_CONNECTION_GET_PRIVATE (connection);
-
- /* Get list of settings in priority order */
- g_hash_table_iter_init (&hiter, priv->settings);
- while (g_hash_table_iter_next (&hiter, NULL, (gpointer) &setting))
- settings = g_slist_insert_sorted (settings, setting, _nm_setting_compare_priority);
-
- for (iter = settings; iter; iter = g_slist_next (iter)) {
- GPtrArray *secrets;
-
- setting = NM_SETTING (iter->data);
- secrets = nm_setting_need_secrets (setting);
- if (secrets) {
- if (hints)
- *hints = secrets;
- else
- g_ptr_array_free (secrets, TRUE);
-
- name = nm_setting_get_name (setting);
- break;
- }
- }
-
- g_slist_free (settings);
- return name;
-}
-
-/**
- * nm_connection_clear_secrets:
- * @connection: the #NMConnection
- *
- * Clears and frees any secrets that may be stored in the connection, to avoid
- * keeping secret data in memory when not needed.
- **/
-void
-nm_connection_clear_secrets (NMConnection *connection)
-{
- GHashTableIter iter;
- NMSetting *setting;
- gboolean changed = FALSE;
-
- g_return_if_fail (NM_IS_CONNECTION (connection));
-
- g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
- g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
- changed |= _nm_setting_clear_secrets (setting);
- g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
- }
-
- g_signal_emit (connection, signals[SECRETS_CLEARED], 0);
- if (changed)
- g_signal_emit (connection, signals[CHANGED], 0);
-}
-
-/**
- * nm_connection_clear_secrets_with_flags:
- * @connection: the #NMConnection
- * @func: (scope call): function to be called to determine whether a
- * specific secret should be cleared or not
- * @user_data: caller-supplied data passed to @func
- *
- * Clears and frees secrets determined by @func.
- **/
-void
-nm_connection_clear_secrets_with_flags (NMConnection *connection,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data)
-{
- GHashTableIter iter;
- NMSetting *setting;
- gboolean changed = FALSE;
-
- g_return_if_fail (NM_IS_CONNECTION (connection));
-
- g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
- g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
- changed |= _nm_setting_clear_secrets_with_flags (setting, func, user_data);
- g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
- }
-
- g_signal_emit (connection, signals[SECRETS_CLEARED], 0);
- if (changed)
- g_signal_emit (connection, signals[CHANGED], 0);
-}
-
-/**
- * nm_connection_to_hash:
- * @connection: the #NMConnection
- * @flags: hash flags, e.g. %NM_SETTING_HASH_FLAG_ALL
- *
- * Converts the #NMConnection into a #GHashTable describing the connection,
- * suitable for marshalling over D-Bus or serializing. The hash table mapping
- * is string:#GHashTable with each element in the returned hash representing
- * a #NMSetting object. The keys are setting object names, and the values
- * are #GHashTables mapping string:GValue, each of which represents the
- * properties of the #NMSetting object.
- *
- * Returns: (transfer full) (element-type utf8 GLib.HashTable): a new
- * #GHashTable describing the connection, its settings, and each setting's
- * properties. The caller owns the hash table and must unref the hash table
- * with g_hash_table_unref() when it is no longer needed.
- **/
-GHashTable *
-nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags)
-{
- NMConnectionPrivate *priv;
- GHashTableIter iter;
- gpointer key, data;
- GHashTable *ret, *setting_hash;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- ret = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) g_hash_table_unref);
-
- priv = NM_CONNECTION_GET_PRIVATE (connection);
-
- /* Add each setting's hash to the main hash */
- g_hash_table_iter_init (&iter, priv->settings);
- while (g_hash_table_iter_next (&iter, &key, &data)) {
- NMSetting *setting = NM_SETTING (data);
-
- setting_hash = nm_setting_to_hash (setting, flags);
- if (setting_hash)
- g_hash_table_insert (ret, g_strdup (nm_setting_get_name (setting)), setting_hash);
- }
-
- /* Don't send empty hashes */
- if (g_hash_table_size (ret) < 1) {
- g_hash_table_destroy (ret);
- ret = NULL;
- }
-
- return ret;
-}
-
-/**
- * nm_connection_is_type:
- * @connection: the #NMConnection
- * @type: a setting name to check the connection's type against (like
- * %NM_SETTING_WIRELESS_SETTING_NAME or %NM_SETTING_WIRED_SETTING_NAME)
- *
- * A convenience function to check if the given @connection is a particular
- * type (ie wired, Wi-Fi, ppp, etc). Checks the #NMSettingConnection:type
- * property of the connection and matches that against @type.
- *
- * Returns: %TRUE if the connection is of the given @type, %FALSE if not
- **/
-gboolean
-nm_connection_is_type (NMConnection *connection, const char *type)
-{
- NMSettingConnection *s_con;
- const char *type2;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (type != NULL, FALSE);
-
- s_con = nm_connection_get_setting_connection (connection);
- if (!s_con)
- return FALSE;
-
- type2 = nm_setting_connection_get_connection_type (s_con);
-
- return (g_strcmp0 (type2, type) == 0);
-}
-
-/**
- * nm_connection_for_each_setting_value:
- * @connection: the #NMConnection
- * @func: (scope call): user-supplied function called for each setting's property
- * @user_data: user data passed to @func at each invocation
- *
- * Iterates over the properties of each #NMSetting object in the #NMConnection,
- * calling the supplied user function for each property.
- **/
-void
-nm_connection_for_each_setting_value (NMConnection *connection,
- NMSettingValueIterFn func,
- gpointer user_data)
-{
- GHashTableIter iter;
- gpointer value;
-
- g_return_if_fail (NM_IS_CONNECTION (connection));
- g_return_if_fail (func != NULL);
-
- g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- nm_setting_enumerate_values (NM_SETTING (value), func, user_data);
-}
-
-/**
- * nm_connection_dump:
- * @connection: the #NMConnection
- *
- * Print the connection to stdout. For debugging purposes ONLY, should NOT
- * be used for serialization of the connection or machine-parsed in any way. The
- * output format is not guaranteed to be stable and may change at any time.
- **/
-void
-nm_connection_dump (NMConnection *connection)
-{
- GHashTableIter iter;
- NMSetting *setting;
- const char *setting_name;
- char *str;
-
- if (!connection)
- return;
-
- g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
- while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting)) {
- str = nm_setting_to_string (setting);
- g_print ("%s\n", str);
- g_free (str);
- }
-}
-
-/**
- * nm_connection_set_path:
- * @connection: the #NMConnection
- * @path: the D-Bus path of the connection as given by the settings service
- * which provides the connection
- *
- * Sets the D-Bus path of the connection. This property is not serialized, and
- * is only for the reference of the caller. Sets the #NMConnection:path
- * property.
- **/
-void
-nm_connection_set_path (NMConnection *connection, const char *path)
-{
- NMConnectionPrivate *priv;
-
- g_return_if_fail (NM_IS_CONNECTION (connection));
-
- priv = NM_CONNECTION_GET_PRIVATE (connection);
-
- g_free (priv->path);
- priv->path = NULL;
-
- if (path)
- priv->path = g_strdup (path);
-}
-
-/**
- * nm_connection_get_path:
- * @connection: the #NMConnection
- *
- * Returns the connection's D-Bus path.
- *
- * Returns: the D-Bus path of the connection, previously set by a call to
- * nm_connection_set_path().
- **/
-const char *
-nm_connection_get_path (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return NM_CONNECTION_GET_PRIVATE (connection)->path;
-}
-
-/**
- * nm_connection_get_interface_name:
- * @connection: The #NMConnection
- *
- * Returns the interface name as stored in NMSettingConnection:interface_name.
- * If the connection contains no NMSettingConnection, it will return %NULL.
- *
- * For hardware devices and software devices created outside of NetworkManager,
- * this name is used to match the device. for software devices created by
- * NetworkManager, this is the name of the created interface.
- *
- * Returns: Name of the kernel interface or %NULL
- *
- * Since: 1.0
- */
-const char *
-nm_connection_get_interface_name (NMConnection *connection)
-{
- NMSettingConnection *s_con;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- s_con = nm_connection_get_setting_connection (connection);
-
- return s_con ? nm_setting_connection_get_interface_name (s_con) : NULL;
-}
-
-/**
- * nm_connection_get_virtual_iface_name:
- * @connection: The #NMConnection
- *
- * Returns the name of the virtual kernel interface which the connection
- * needs to use if specified in the settings. This function abstracts all
- * connection types which require this functionality. For all other
- * connection types, this function will return %NULL.
- *
- * Returns: Name of the kernel interface or %NULL
- */
-const char *
-nm_connection_get_virtual_iface_name (NMConnection *connection)
-{
- NMSettingConnection *s_con;
- const char *type;
- NMSetting *base;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- s_con = nm_connection_get_setting_connection (connection);
- g_return_val_if_fail (s_con, NULL);
-
- type = nm_setting_connection_get_connection_type (s_con);
- g_return_val_if_fail (type, NULL);
-
- base = nm_connection_get_setting_by_name (connection, type);
- if (!base)
- return NULL;
-
- return nm_setting_get_virtual_iface_name (base);
-}
-
-/**
- * nm_connection_new:
- *
- * Creates a new #NMConnection object with no #NMSetting objects.
- *
- * Returns: the new empty #NMConnection object
- **/
-NMConnection *
-nm_connection_new (void)
-{
- return (NMConnection *) g_object_new (NM_TYPE_CONNECTION, NULL);
-}
-
-/**
- * _nm_connection_new_from_hash:
- * @hash: (element-type utf8 GLib.HashTable): the #GHashTable describing
- * the connection
- *
- * Creates a new #NMConnection from a hash table describing the connection. See
- * nm_connection_to_hash() for a description of the expected hash table.
- *
- * Returns: the new #NMConnection object, populated with settings created
- * from the values in the hash table.
- **/
-NMConnection *
-_nm_connection_new_from_hash (GHashTable *hash)
-{
- NMConnection *connection;
-
- g_return_val_if_fail (hash != NULL, NULL);
-
- connection = nm_connection_new ();
- _nm_connection_replace_settings (connection, hash);
- return connection;
-}
-
-/**
- * nm_connection_new_from_hash:
- * @hash: (element-type utf8 GLib.HashTable): the #GHashTable describing
- * the connection
- * @error: on unsuccessful return, an error
- *
- * Creates a new #NMConnection from a hash table describing the connection. See
- * nm_connection_to_hash() for a description of the expected hash table.
- *
- * Returns: the new #NMConnection object, populated with settings created
- * from the values in the hash table, or %NULL if the connection failed to
- * validate
- **/
-NMConnection *
-nm_connection_new_from_hash (GHashTable *hash, GError **error)
-{
- NMConnection *connection;
-
- g_return_val_if_fail (hash != NULL, NULL);
-
- if (!validate_permissions_type (hash, error))
- return NULL;
-
- connection = _nm_connection_new_from_hash (hash);
- if (!nm_connection_verify (connection, error))
- g_clear_object (&connection);
- return connection;
-}
-
-/**
- * nm_connection_duplicate:
- * @connection: the #NMConnection to duplicate
- *
- * Duplicates a #NMConnection.
- *
- * Returns: (transfer full): a new #NMConnection containing the same settings and properties
- * as the source #NMConnection
- **/
-NMConnection *
-nm_connection_duplicate (NMConnection *connection)
-{
- NMConnection *dup;
- GHashTableIter iter;
- NMSetting *setting;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- dup = nm_connection_new ();
- nm_connection_set_path (dup, nm_connection_get_path (connection));
-
- g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting))
- _nm_connection_add_setting (dup, nm_setting_duplicate (setting));
-
- return dup;
-}
-
-/**
- * nm_connection_get_uuid:
- * @connection: the #NMConnection
- *
- * A shortcut to return the UUID from the connection's #NMSettingConnection.
- *
- * Returns: the UUID from the connection's 'connection' setting
- **/
-const char *
-nm_connection_get_uuid (NMConnection *connection)
-{
- NMSettingConnection *s_con;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- s_con = nm_connection_get_setting_connection (connection);
- g_return_val_if_fail (s_con != NULL, NULL);
-
- return nm_setting_connection_get_uuid (s_con);
-}
-
-/**
- * nm_connection_get_id:
- * @connection: the #NMConnection
- *
- * A shortcut to return the ID from the connection's #NMSettingConnection.
- *
- * Returns: the ID from the connection's 'connection' setting
- **/
-const char *
-nm_connection_get_id (NMConnection *connection)
-{
- NMSettingConnection *s_con;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- s_con = nm_connection_get_setting_connection (connection);
- g_return_val_if_fail (s_con != NULL, NULL);
-
- return nm_setting_connection_get_id (s_con);
-}
-
-/**
- * nm_connection_get_connection_type:
- * @connection: the #NMConnection
- *
- * A shortcut to return the type from the connection's #NMSettingConnection.
- *
- * Returns: the type from the connection's 'connection' setting
- *
- * Since: 0.9.10
- **/
-const char *
-nm_connection_get_connection_type (NMConnection *connection)
-{
- NMSettingConnection *s_con;
-
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- s_con = nm_connection_get_setting_connection (connection);
- g_return_val_if_fail (s_con != NULL, NULL);
-
- return nm_setting_connection_get_connection_type (s_con);
-}
-
-/**
- * nm_connection_get_virtual_device_description:
- * @connection: an #NMConnection for a virtual device type
- *
- * Returns the name that nm_device_disambiguate_names() would
- * return for the virtual device that would be created for @connection.
- * Eg, "VLAN (eth1.1)".
- *
- * Returns: (transfer full): the name of @connection's device,
- * or %NULL if @connection is not a virtual connection type
- *
- * Since: 0.9.10
- */
-char *
-nm_connection_get_virtual_device_description (NMConnection *connection)
-{
- const char *iface, *type, *display_type;
- NMSettingConnection *s_con;
-
- iface = nm_connection_get_virtual_iface_name (connection);
- if (!iface)
- return NULL;
-
- s_con = nm_connection_get_setting_connection (connection);
- g_return_val_if_fail (s_con != NULL, NULL);
- type = nm_setting_connection_get_connection_type (s_con);
-
- if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME))
- display_type = _("Bond");
- else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME))
- display_type = _("Team");
- else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME))
- display_type = _("Bridge");
- else if (!strcmp (type, NM_SETTING_VLAN_SETTING_NAME))
- display_type = _("VLAN");
- else {
- g_warning ("Unrecognized virtual device type '%s'", type);
- display_type = type;
- }
-
- return g_strdup_printf ("%s (%s)", display_type, iface);
-}
-
-/*****************************************************************************/
-
-/**
- * nm_connection_get_setting_802_1x:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSetting8021x the connection might contain.
- *
- * Returns: (transfer none): an #NMSetting8021x if the connection contains one, otherwise %NULL
- **/
-NMSetting8021x *
-nm_connection_get_setting_802_1x (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
-}
-
-/**
- * nm_connection_get_setting_bluetooth:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingBluetooth the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingBluetooth if the connection contains one, otherwise %NULL
- **/
-NMSettingBluetooth *
-nm_connection_get_setting_bluetooth (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingBluetooth *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH);
-}
-
-/**
- * nm_connection_get_setting_bond:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingBond the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingBond if the connection contains one, otherwise %NULL
- **/
-NMSettingBond *
-nm_connection_get_setting_bond (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingBond *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BOND);
-}
-
-/**
- * nm_connection_get_setting_team:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingTeam the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingTeam if the connection contains one, otherwise %NULL
- *
- * Since: 0.9.10
- **/
-NMSettingTeam *
-nm_connection_get_setting_team (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingTeam *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM);
-}
-
-/**
- * nm_connection_get_setting_team_port:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingTeamPort the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingTeamPort if the connection contains one, otherwise %NULL
- *
- * Since: 0.9.10
- **/
-NMSettingTeamPort *
-nm_connection_get_setting_team_port (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingTeamPort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM_PORT);
-}
-
-/**
- * nm_connection_get_setting_bridge:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingBridge the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingBridge if the connection contains one, otherwise %NULL
- **/
-NMSettingBridge *
-nm_connection_get_setting_bridge (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingBridge *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BRIDGE);
-}
-
-/**
- * nm_connection_get_setting_cdma:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingCdma the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingCdma if the connection contains one, otherwise %NULL
- **/
-NMSettingCdma *
-nm_connection_get_setting_cdma (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
-}
-
-/**
- * nm_connection_get_setting_connection:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingConnection the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingConnection if the connection contains one, otherwise %NULL
- **/
-NMSettingConnection *
-nm_connection_get_setting_connection (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
-}
-
-/**
- * nm_connection_get_setting_dcb:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingDcb the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingDcb if the connection contains one, otherwise NULL
- *
- * Since: 0.9.10
- **/
-NMSettingDcb *
-nm_connection_get_setting_dcb (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingDcb *) nm_connection_get_setting (connection, NM_TYPE_SETTING_DCB);
-}
-
-/**
- * nm_connection_get_setting_generic:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingGeneric the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingGeneric if the connection contains one, otherwise NULL
- *
- * Since: 0.9.10
- **/
-NMSettingGeneric *
-nm_connection_get_setting_generic (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingGeneric *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GENERIC);
-}
-
-/**
- * nm_connection_get_setting_gsm:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingGsm the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingGsm if the connection contains one, otherwise %NULL
- **/
-NMSettingGsm *
-nm_connection_get_setting_gsm (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
-}
-
-/**
- * nm_connection_get_setting_infiniband:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingInfiniband the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingInfiniband if the connection contains one, otherwise %NULL
- **/
-NMSettingInfiniband *
-nm_connection_get_setting_infiniband (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingInfiniband *) nm_connection_get_setting (connection, NM_TYPE_SETTING_INFINIBAND);
-}
-
-/**
- * nm_connection_get_setting_ip4_config:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingIP4Config the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingIP4Config if the connection contains one, otherwise %NULL
- **/
-NMSettingIP4Config *
-nm_connection_get_setting_ip4_config (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
-}
-
-/**
- * nm_connection_get_setting_ip6_config:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingIP6Config the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingIP6Config if the connection contains one, otherwise %NULL
- **/
-NMSettingIP6Config *
-nm_connection_get_setting_ip6_config (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
-}
-
-/**
- * nm_connection_get_setting_olpc_mesh:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingOlpcMesh the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingOlpcMesh if the connection contains one, otherwise %NULL
- **/
-NMSettingOlpcMesh *
-nm_connection_get_setting_olpc_mesh (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingOlpcMesh *) nm_connection_get_setting (connection, NM_TYPE_SETTING_OLPC_MESH);
-}
-
-/**
- * nm_connection_get_setting_ppp:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingPPP the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingPPP if the connection contains one, otherwise %NULL
- **/
-NMSettingPPP *
-nm_connection_get_setting_ppp (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingPPP *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
-}
-
-/**
- * nm_connection_get_setting_pppoe:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingPPPOE the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingPPPOE if the connection contains one, otherwise %NULL
- **/
-NMSettingPPPOE *
-nm_connection_get_setting_pppoe (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
-}
-
-/**
- * nm_connection_get_setting_serial:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingSerial the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingSerial if the connection contains one, otherwise %NULL
- **/
-NMSettingSerial *
-nm_connection_get_setting_serial (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
-}
-
-/**
- * nm_connection_get_setting_vpn:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingVPN the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingVPN if the connection contains one, otherwise %NULL
- **/
-NMSettingVPN *
-nm_connection_get_setting_vpn (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
-}
-
-/**
- * nm_connection_get_setting_wimax:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingWimax the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingWimax if the connection contains one, otherwise %NULL
- **/
-NMSettingWimax *
-nm_connection_get_setting_wimax (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingWimax *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIMAX);
-}
-
-/**
- * nm_connection_get_setting_wired:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingWired the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingWired if the connection contains one, otherwise %NULL
- **/
-NMSettingWired *
-nm_connection_get_setting_wired (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
-}
-
-/**
- * nm_connection_get_setting_adsl:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingAdsl the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingAdsl if the connection contains one, otherwise %NULL
- **/
-NMSettingAdsl *
-nm_connection_get_setting_adsl (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingAdsl *) nm_connection_get_setting (connection, NM_TYPE_SETTING_ADSL);
-}
-
-/**
- * nm_connection_get_setting_wireless:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingWireless the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingWireless if the connection contains one, otherwise %NULL
- **/
-NMSettingWireless *
-nm_connection_get_setting_wireless (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
-}
-
-/**
- * nm_connection_get_setting_wireless_security:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingWirelessSecurity the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingWirelessSecurity if the connection contains one, otherwise %NULL
- **/
-NMSettingWirelessSecurity *
-nm_connection_get_setting_wireless_security (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
-}
-
-/**
- * nm_connection_get_setting_bridge_port:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingBridgePort the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingBridgePort if the connection contains one, otherwise %NULL
- **/
-NMSettingBridgePort *
-nm_connection_get_setting_bridge_port (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingBridgePort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BRIDGE_PORT);
-}
-
-/**
- * nm_connection_get_setting_vlan:
- * @connection: the #NMConnection
- *
- * A shortcut to return any #NMSettingVlan the connection might contain.
- *
- * Returns: (transfer none): an #NMSettingVlan if the connection contains one, otherwise %NULL
- **/
-NMSettingVlan *
-nm_connection_get_setting_vlan (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- return (NMSettingVlan *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VLAN);
-}
-
-/*****************************************************************************/
-
-static void
-nm_connection_init (NMConnection *connection)
-{
- NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
-
- priv->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
-}
-
-static void
-dispose (GObject *object)
-{
- NMConnection *self = NM_CONNECTION (object);
- NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (self);
-
- g_hash_table_foreach_remove (priv->settings, _setting_release, self);
-
- G_OBJECT_CLASS (nm_connection_parent_class)->dispose (object);
-}
-
-static void
-finalize (GObject *object)
-{
- NMConnection *connection = NM_CONNECTION (object);
- NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
-
- g_assert (g_hash_table_size (priv->settings) == 0);
- g_hash_table_destroy (priv->settings);
- g_free (priv->path);
-
- G_OBJECT_CLASS (nm_connection_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMConnection *connection = NM_CONNECTION (object);
-
- switch (prop_id) {
- case PROP_PATH:
- nm_connection_set_path (connection, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMConnection *connection = NM_CONNECTION (object);
-
- switch (prop_id) {
- case PROP_PATH:
- g_value_set_string (value, nm_connection_get_path (connection));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_connection_class_init (NMConnectionClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (NMConnectionPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
- object_class->finalize = finalize;
-
- /* Properties */
-
- /**
- * NMConnection:path:
- *
- * The connection's D-Bus path, used only by the calling process as a record
- * of the D-Bus path of the connection as provided by a settings service.
- **/
- g_object_class_install_property
- (object_class, PROP_PATH,
- g_param_spec_string (NM_CONNECTION_PATH, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /* Signals */
-
- /**
- * NMConnection::secrets-updated:
- * @connection: the object on which the signal is emitted
- * @setting_name: the setting name of the #NMSetting for which secrets were
- * updated
- *
- * The ::secrets-updated signal is emitted when the secrets of a setting
- * have been changed.
- */
- signals[SECRETS_UPDATED] =
- g_signal_new (NM_CONNECTION_SECRETS_UPDATED,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMConnectionClass, secrets_updated),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- /**
- * NMConnection::secrets-cleared:
- * @connection: the object on which the signal is emitted
- *
- * The ::secrets-cleared signal is emitted when the secrets of a connection
- * are cleared.
- */
- signals[SECRETS_CLEARED] =
- g_signal_new (NM_CONNECTION_SECRETS_CLEARED,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
- * NMConnection::changed:
- * @connection: the object on which the signal is emitted
- *
- * The ::changed signal is emitted when any property of any property
- * (including secrets) of any setting of the connection is modified,
- * or when settings are added or removed.
- *
- * Since: 0.9.10
- */
- signals[CHANGED] =
- g_signal_new (NM_CONNECTION_CHANGED,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h
deleted file mode 100644
index 9bee219e86..0000000000
--- a/libnm-util/nm-connection.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_CONNECTION_H
-#define NM_CONNECTION_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include "nm-setting.h"
-
-#include "nm-setting-8021x.h"
-#include "nm-setting-bluetooth.h"
-#include "nm-setting-bond.h"
-#include "nm-setting-team.h"
-#include "nm-setting-team-port.h"
-#include "nm-setting-bridge.h"
-#include "nm-setting-bridge-port.h"
-#include "nm-setting-cdma.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-dcb.h"
-#include "nm-setting-generic.h"
-#include "nm-setting-gsm.h"
-#include "nm-setting-infiniband.h"
-#include "nm-setting-ip4-config.h"
-#include "nm-setting-ip6-config.h"
-#include "nm-setting-olpc-mesh.h"
-#include "nm-setting-ppp.h"
-#include "nm-setting-pppoe.h"
-#include "nm-setting-serial.h"
-#include "nm-setting-vpn.h"
-#include "nm-setting-wimax.h"
-#include "nm-setting-wired.h"
-#include "nm-setting-adsl.h"
-#include "nm-setting-wireless.h"
-#include "nm-setting-wireless-security.h"
-#include "nm-setting-vlan.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_CONNECTION (nm_connection_get_type ())
-#define NM_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION, NMConnection))
-#define NM_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CONNECTION, NMConnectionClass))
-#define NM_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION))
-#define NM_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_CONNECTION))
-#define NM_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION, NMConnectionClass))
-
-/* Signals */
-#define NM_CONNECTION_SECRETS_UPDATED "secrets-updated"
-#define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared"
-#define NM_CONNECTION_CHANGED "changed"
-
-/* Properties */
-#define NM_CONNECTION_PATH "path"
-
-/**
- * NMConnectionError:
- * @NM_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND: the #NMConnection object
- * did not contain the required #NMSettingConnection object, which must be
- * present for all connections
- * @NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID: the 'type' property of the
- * 'connection' setting did not point to a valid connection base type; ie
- * it was not a hardware-related setting like #NMSettingWired or
- * #NMSettingWireless.
- * @NM_CONNECTION_ERROR_SETTING_NOT_FOUND: the #NMConnection object
- * did not contain the specified #NMSetting object
- *@NM_CONNECTION_ERROR_INVALID_SETTING: the #NMConnection object contains
- * a conflicting setting object
- *
- * Describes errors that may result from operations involving a #NMConnection.
- *
- **/
-typedef enum
-{
- NM_CONNECTION_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, /*< nick=ConnectionSettingNotFound >*/
- NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, /*< nick=ConnectionTypeInvalid >*/
- NM_CONNECTION_ERROR_SETTING_NOT_FOUND, /*< nick=SettingNotFound >*/
- NM_CONNECTION_ERROR_INVALID_SETTING, /*< nick=InvalidSetting >*/
-} NMConnectionError;
-
-/*
- * NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method
- * when normalizing ip6 configuration. If omitted, this defaults to
- * @NM_SETTING_IP6_CONFIG_METHOD_AUTO.
- */
-#define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"
-
-#define NM_CONNECTION_ERROR nm_connection_error_quark ()
-GQuark nm_connection_error_quark (void);
-
-/**
- * NMConnection:
- *
- * The NMConnection struct contains only private data.
- * It should only be accessed through the functions described below.
- */
-typedef struct {
- GObject parent;
-} NMConnection;
-
-typedef struct {
- GObjectClass parent;
-
- /* Signals */
- void (*secrets_updated) (NMConnection *connection, const char * setting);
-} NMConnectionClass;
-
-GType nm_connection_get_type (void);
-
-NMConnection *nm_connection_new (void);
-
-NMConnection *nm_connection_new_from_hash (GHashTable *hash, GError **error);
-
-NMConnection *nm_connection_duplicate (NMConnection *connection);
-
-NMSetting *nm_connection_create_setting (const char *name);
-
-void nm_connection_add_setting (NMConnection *connection,
- NMSetting *setting);
-
-void nm_connection_remove_setting (NMConnection *connection,
- GType setting_type);
-
-NMSetting *nm_connection_get_setting (NMConnection *connection,
- GType setting_type);
-
-NMSetting *nm_connection_get_setting_by_name (NMConnection *connection,
- const char *name);
-
-gboolean nm_connection_replace_settings (NMConnection *connection,
- GHashTable *new_settings,
- GError **error);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_connection_replace_settings_from_connection (NMConnection *connection,
- NMConnection *new_connection,
- GError **error);
-
-gboolean nm_connection_compare (NMConnection *a,
- NMConnection *b,
- NMSettingCompareFlags flags);
-
-gboolean nm_connection_diff (NMConnection *a,
- NMConnection *b,
- NMSettingCompareFlags flags,
- GHashTable **out_settings);
-
-gboolean nm_connection_verify (NMConnection *connection, GError **error);
-NM_AVAILABLE_IN_1_0
-gboolean nm_connection_normalize (NMConnection *connection,
- 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,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data);
-
-gboolean nm_connection_update_secrets (NMConnection *connection,
- const char *setting_name,
- GHashTable *secrets,
- GError **error);
-
-void nm_connection_set_path (NMConnection *connection,
- const char *path);
-
-const char * nm_connection_get_path (NMConnection *connection);
-
-const char * nm_connection_get_virtual_iface_name (NMConnection *connection);
-
-NM_AVAILABLE_IN_1_0
-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,
- NMSettingValueIterFn func,
- gpointer user_data);
-
-GHashTable *nm_connection_to_hash (NMConnection *connection,
- NMSettingHashFlags flags);
-
-void nm_connection_dump (NMConnection *connection);
-
-GType nm_connection_lookup_setting_type (const char *name);
-
-GType nm_connection_lookup_setting_type_by_quark (GQuark error_quark);
-
-/* Helpers */
-const char * nm_connection_get_uuid (NMConnection *connection);
-const char * nm_connection_get_id (NMConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_connection_get_connection_type (NMConnection *connection);
-
-NM_AVAILABLE_IN_0_9_10
-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);
-NM_AVAILABLE_IN_0_9_10
-NMSettingTeam * nm_connection_get_setting_team (NMConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-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);
-NMSettingConnection * nm_connection_get_setting_connection (NMConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-NMSettingDcb * nm_connection_get_setting_dcb (NMConnection *connection);
-NM_AVAILABLE_IN_0_9_10
-NMSettingGeneric * nm_connection_get_setting_generic (NMConnection *connection);
-NMSettingGsm * nm_connection_get_setting_gsm (NMConnection *connection);
-NMSettingInfiniband * nm_connection_get_setting_infiniband (NMConnection *connection);
-NMSettingIP4Config * nm_connection_get_setting_ip4_config (NMConnection *connection);
-NMSettingIP6Config * nm_connection_get_setting_ip6_config (NMConnection *connection);
-NMSettingOlpcMesh * nm_connection_get_setting_olpc_mesh (NMConnection *connection);
-NMSettingPPP * nm_connection_get_setting_ppp (NMConnection *connection);
-NMSettingPPPOE * nm_connection_get_setting_pppoe (NMConnection *connection);
-NMSettingSerial * nm_connection_get_setting_serial (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);
-
-G_END_DECLS
-
-#endif /* NM_CONNECTION_H */
diff --git a/libnm-util/nm-dbus-glib-types.h b/libnm-util/nm-dbus-glib-types.h
deleted file mode 100644
index ad11ab6812..0000000000
--- a/libnm-util/nm-dbus-glib-types.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 Red Hat, Inc.
- */
-
-#ifndef __NM_DBUS_GLIB_TYPES_H__
-#define __NM_DBUS_GLIB_TYPES_H__
-
-#include <dbus/dbus-glib.h>
-
-#define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
-#define DBUS_TYPE_G_ARRAY_OF_STRING (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING))
-#define DBUS_TYPE_G_ARRAY_OF_UINT (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
-#define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_UCHAR_ARRAY))
-#define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_ARRAY_OF_UINT))
-#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
-#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
-#define DBUS_TYPE_G_MAP_OF_STRING (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
-#define DBUS_TYPE_G_LIST_OF_STRING (dbus_g_type_get_collection ("GSList", G_TYPE_STRING))
-
-#define DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_INVALID))
-#define DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_IP6_ADDRESS))
-#define DBUS_TYPE_G_IP6_ROUTE (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
-#define DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_IP6_ROUTE))
-
-#define DBUS_TYPE_NM_IP_ADDRESS DBUS_TYPE_G_MAP_OF_VARIANT
-#define DBUS_TYPE_NM_IP_ADDRESSES (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_NM_IP_ADDRESS))
-#define DBUS_TYPE_NM_IP_ROUTE DBUS_TYPE_G_MAP_OF_VARIANT
-#define DBUS_TYPE_NM_IP_ROUTES (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_NM_IP_ROUTE))
-
-#endif /* __NM_DBUS_GLIB_TYPES_H__ */
diff --git a/libnm-util/nm-gvaluearray-compat.h b/libnm-util/nm-gvaluearray-compat.h
deleted file mode 100644
index 91f4f243a6..0000000000
--- a/libnm-util/nm-gvaluearray-compat.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#ifndef __NM_GVALUEARRAY_COMPAT_H__
-#define __NM_GVALUEARRAY_COMPAT_H__
-
-#define g_value_array_get_type() \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_get_type (); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#define g_value_array_get_nth(value_array, index_) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_get_nth (value_array, index_); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#define g_value_array_new(n_prealloced) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_new (n_prealloced); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-static inline void
-__g_value_array_free (GValueArray *value_array)
-{
- ({
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- g_value_array_free (value_array);
- G_GNUC_END_IGNORE_DEPRECATIONS
- });
-}
-#define g_value_array_free __g_value_array_free
-
-#define g_value_array_copy(value_array) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_copy (value_array); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#define g_value_array_prepend(value_array, value) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_prepend (value_array, value); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#define g_value_array_append(value_array, value) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_append (value_array, value); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#define g_value_array_insert(value_array, index_, value) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_insert (value_array, index_, value); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#define g_value_array_remove(value_array, index_) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_remove (value_array, index_); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#define g_value_array_sort(value_array, compare_func) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_sort (value_array, compare_func); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#define g_value_array_sort_with_data(value_array, compare_func, user_data) \
- ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_sort_with_data (value_array, compare_func, user_data); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
-
-#endif /* __NM_GVALUEARRAY_COMPAT_H__ */
diff --git a/libnm-util/nm-param-spec-specialized.c b/libnm-util/nm-param-spec-specialized.c
deleted file mode 100644
index 8581ecc5b0..0000000000
--- a/libnm-util/nm-param-spec-specialized.c
+++ /dev/null
@@ -1,973 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-gvaluearray-compat.h"
-#include "nm-param-spec-specialized.h"
-
-struct _NMParamSpecSpecialized {
- GParamSpec parent;
-};
-
-#include <string.h>
-#include <netinet/in.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-dbus-glib-types.h"
-
-/*****************************************************************************/
-/* _gvalues_compare */
-
-static int _gvalues_compare (const GValue *value1, const GValue *value2);
-
-static gboolean
-type_is_fixed_size (GType type, gsize *tsize)
-{
- switch (type) {
- case G_TYPE_CHAR:
- if (tsize) *tsize = sizeof (char);
- return TRUE;
- case G_TYPE_UCHAR:
- if (tsize) *tsize = sizeof (guchar);
- return TRUE;
- case G_TYPE_BOOLEAN:
- if (tsize) *tsize = sizeof (gboolean);
- return TRUE;
- case G_TYPE_LONG:
- if (tsize) *tsize = sizeof (long);
- return TRUE;
- case G_TYPE_ULONG:
- if (tsize) *tsize = sizeof (gulong);
- return TRUE;
- case G_TYPE_INT:
- if (tsize) *tsize = sizeof (int);
- return TRUE;
- case G_TYPE_UINT:
- if (tsize) *tsize = sizeof (guint);
- return TRUE;
- case G_TYPE_INT64:
- if (tsize) *tsize = sizeof (gint64);
- return TRUE;
- case G_TYPE_UINT64:
- if (tsize) *tsize = sizeof (guint64);
- return TRUE;
- case G_TYPE_FLOAT:
- if (tsize) *tsize = sizeof (float);
- return TRUE;
- case G_TYPE_DOUBLE:
- if (tsize) *tsize = sizeof (double);
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-#define FLOAT_FACTOR 0.00000001
-
-static int
-_gvalues_compare_fixed (const GValue *value1, const GValue *value2)
-{
- int ret = 0;
-
- switch (G_VALUE_TYPE (value1)) {
- case G_TYPE_CHAR: {
- char val1 = g_value_get_schar (value1);
- char val2 = g_value_get_schar (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_UCHAR: {
- guchar val1 = g_value_get_uchar (value1);
- guchar val2 = g_value_get_uchar (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_BOOLEAN: {
- gboolean val1 = g_value_get_boolean (value1);
- gboolean val2 = g_value_get_boolean (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_LONG: {
- long val1 = g_value_get_long (value1);
- long val2 = g_value_get_long (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_ULONG: {
- gulong val1 = g_value_get_ulong (value1);
- gulong val2 = g_value_get_ulong (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_INT: {
- int val1 = g_value_get_int (value1);
- int val2 = g_value_get_int (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_UINT: {
- guint val1 = g_value_get_uint (value1);
- guint val2 = g_value_get_uint (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_INT64: {
- gint64 val1 = g_value_get_int64 (value1);
- gint64 val2 = g_value_get_int64 (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_UINT64: {
- guint64 val1 = g_value_get_uint64 (value1);
- guint64 val2 = g_value_get_uint64 (value2);
- if (val1 != val2)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_FLOAT: {
- float val1 = g_value_get_float (value1);
- float val2 = g_value_get_float (value2);
- float diff = val1 - val2;
-
- /* Can't use == or != here due to inexactness of FP */
- if (diff > FLOAT_FACTOR || diff < -FLOAT_FACTOR)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- case G_TYPE_DOUBLE: {
- double val1 = g_value_get_double (value1);
- double val2 = g_value_get_double (value2);
- double diff = val1 - val2;
-
- if (diff > FLOAT_FACTOR || diff < -FLOAT_FACTOR)
- ret = val1 < val2 ? -1 : val1 > val2;
- break;
- }
- default:
- g_warning ("Unhandled fixed size type '%s'", G_VALUE_TYPE_NAME (value1));
- }
-
- return ret;
-}
-
-static int
-_gvalues_compare_string (const GValue *value1, const GValue *value2)
-{
- const char *str1 = g_value_get_string (value1);
- const char *str2 = g_value_get_string (value2);
-
- if (str1 == str2)
- return 0;
-
- if (!str1)
- return 1;
- if (!str2)
- return -1;
-
- return strcmp (str1, str2);
-}
-
-static int
-_gvalues_compare_strv (const GValue *value1, const GValue *value2)
-{
- char **strv1;
- char **strv2;
- int ret;
- guint i = 0;
-
- strv1 = (char **) g_value_get_boxed (value1);
- strv2 = (char **) g_value_get_boxed (value2);
-
- while (strv1[i] && strv2[i]) {
- ret = strcmp (strv1[i], strv2[i]);
- if (ret)
- return ret;
- i++;
- }
-
- if (strv1[i] == NULL && strv2[i] == NULL)
- return 0;
-
- if (strv1[i])
- return 1;
-
- return -1;
-}
-
-static void
-_gvalue_destroy (gpointer data)
-{
- GValue *value = (GValue *) data;
-
- g_value_unset (value);
- g_slice_free (GValue, value);
-}
-
-static GValue *
-_gvalue_dup (const GValue *value)
-{
- GValue *dup;
-
- dup = g_slice_new0 (GValue);
- g_value_init (dup, G_VALUE_TYPE (value));
- g_value_copy (value, dup);
-
- return dup;
-}
-
-static void
-iterate_collection (const GValue *value, gpointer user_data)
-{
- GSList **list = (GSList **) user_data;
-
- *list = g_slist_prepend (*list, _gvalue_dup (value));
-}
-
-static int
-_gvalues_compare_collection (const GValue *value1, const GValue *value2)
-{
- int ret;
- guint len1;
- guint len2;
- GType value_type = dbus_g_type_get_collection_specialization (G_VALUE_TYPE (value1));
- gsize element_size = 0;
-
- if (type_is_fixed_size (value_type, &element_size)) {
- gpointer data1 = NULL;
- gpointer data2 = NULL;
-
- dbus_g_type_collection_get_fixed ((GValue *) value1, &data1, &len1);
- dbus_g_type_collection_get_fixed ((GValue *) value2, &data2, &len2);
-
- if (len1 != len2)
- ret = len1 < len2 ? -1 : len1 > len2;
- else
- ret = memcmp (data1, data2, len1 * element_size);
- } else {
- GSList *list1 = NULL;
- GSList *list2 = NULL;
-
- dbus_g_type_collection_value_iterate (value1, iterate_collection, &list1);
- len1 = g_slist_length (list1);
- dbus_g_type_collection_value_iterate (value2, iterate_collection, &list2);
- len2 = g_slist_length (list2);
-
- if (len1 != len2)
- ret = len1 < len2 ? -1 : len1 > len2;
- else {
- GSList *iter1;
- GSList *iter2;
-
- for (iter1 = list1, iter2 = list2, ret = 0;
- ret == 0 && iter1 && iter2;
- iter1 = iter1->next, iter2 = iter2->next)
- ret = _gvalues_compare ((GValue *) iter1->data, (GValue *) iter2->data);
- }
-
- g_slist_free_full (list1, _gvalue_destroy);
- g_slist_free_full (list2, _gvalue_destroy);
- }
-
- return ret;
-}
-
-static void
-iterate_map (const GValue *key_val,
- const GValue *value_val,
- gpointer user_data)
-{
- GHashTable **hash = (GHashTable **) user_data;
-
- g_hash_table_insert (*hash, g_value_dup_string (key_val), _gvalue_dup (value_val));
-}
-
-typedef struct {
- GHashTable *hash2;
- int ret;
-} CompareMapInfo;
-
-static void
-compare_one_map_item (gpointer key, gpointer val, gpointer user_data)
-{
- CompareMapInfo *info = (CompareMapInfo *) user_data;
- GValue *value2;
-
- if (info->ret)
- return;
-
- value2 = (GValue *) g_hash_table_lookup (info->hash2, key);
- if (value2)
- info->ret = _gvalues_compare ((GValue *) val, value2);
- else
- info->ret = 1;
-}
-
-static int
-_gvalues_compare_map (const GValue *value1, const GValue *value2)
-{
- GHashTable *hash1 = NULL;
- GHashTable *hash2 = NULL;
- guint len1;
- guint len2;
- int ret = 0;
-
- if (dbus_g_type_get_map_key_specialization (G_VALUE_TYPE (value1)) != G_TYPE_STRING) {
- g_warning ("Can not compare maps with '%s' for keys",
- g_type_name (dbus_g_type_get_map_key_specialization (G_VALUE_TYPE (value1))));
- return 0;
- }
-
- hash1 = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, _gvalue_destroy);
- dbus_g_type_map_value_iterate (value1, iterate_map, &hash1);
- len1 = g_hash_table_size (hash1);
-
- hash2 = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, _gvalue_destroy);
- dbus_g_type_map_value_iterate (value2, iterate_map, &hash2);
- len2 = g_hash_table_size (hash2);
-
- if (len1 != len2)
- ret = len1 < len2 ? -1 : len1 > len2;
- else {
- CompareMapInfo info;
-
- info.ret = 0;
- info.hash2 = hash2;
- g_hash_table_foreach (hash1, compare_one_map_item, &info);
- ret = info.ret;
- }
-
- g_hash_table_destroy (hash1);
- g_hash_table_destroy (hash2);
-
- return ret;
-}
-
-static int
-_gvalue_ip6_address_compare (const GValue *value1, const GValue *value2)
-{
- GValueArray *values1, *values2;
- GValue *tmp_val;
- GByteArray *addr1, *addr2;
- guint32 prefix1, prefix2;
- GByteArray *gw1, *gw2;
- int ret = 0;
- int i;
-
- /* IP6 addresses are GValueArrays (see nm-dbus-glib-types.h) */
- values1 = g_value_get_boxed (value1);
- values2 = g_value_get_boxed (value2);
-
- /* Since they are NM IPv6 address structures, we expect both
- * to contain two elements as specified in nm-dbus-glib-types.h.
- */
- g_return_val_if_fail (values1->n_values == 3, 0);
- g_return_val_if_fail (values2->n_values == 3, 0);
-
- /* First struct IPv6 address */
- tmp_val = g_value_array_get_nth (values1, 0);
- addr1 = g_value_get_boxed (tmp_val);
- /* First struct IPv6 prefix */
- tmp_val = g_value_array_get_nth (values1, 1);
- prefix1 = g_value_get_uint (tmp_val);
- /* First struct IPv6 gateway */
- tmp_val = g_value_array_get_nth (values1, 2);
- gw1 = g_value_get_boxed (tmp_val);
-
- /* Second struct IPv6 address */
- tmp_val = g_value_array_get_nth (values2, 0);
- addr2 = g_value_get_boxed (tmp_val);
- /* Second struct IPv6 prefix */
- tmp_val = g_value_array_get_nth (values2, 1);
- prefix2 = g_value_get_uint (tmp_val);
- /* Second struct IPv6 gateway */
- tmp_val = g_value_array_get_nth (values2, 2);
- gw2 = g_value_get_boxed (tmp_val);
-
- /* Compare IPv6 addresses */
- if (prefix1 != prefix2)
- return prefix1 < prefix2 ? -1 : prefix1 > prefix2;
-
- if (!IN6_ARE_ADDR_EQUAL ((struct in6_addr *)addr1->data, (struct in6_addr *)addr2->data)) {
- for (i = 0; ret == 0 && i < addr1->len; i++)
- ret = addr1->data[i] < addr2->data[i] ? -1 : addr1->data[i] > addr2->data[i];
- }
-
- if (!IN6_ARE_ADDR_EQUAL ((struct in6_addr *) gw1->data, (struct in6_addr *) gw2->data)) {
- for (i = 0; ret == 0 && i < gw1->len; i++)
- ret = gw1->data[i] < gw2->data[i] ? -1 : gw1->data[i] > gw2->data[i];
- }
-
- return ret;
-}
-
-static int
-_gvalue_ip6_route_compare (const GValue *value1, const GValue *value2)
-{
- GValueArray *values1, *values2;
- GValue *tmp_val;
- GByteArray *dest1, *dest2;
- GByteArray *next_hop1, *next_hop2;
- guint32 prefix1, prefix2;
- guint32 metric1, metric2;
- int ret = 0;
- int i;
-
- /* IP6 routes are GValueArrays (see nm-dbus-glib-types.h) */
- values1 = g_value_get_boxed (value1);
- values2 = g_value_get_boxed (value2);
-
- /* Since they are NM IPv6 route structures, we expect both
- * to contain 4 elements as specified in nm-dbus-glib-types.h.
- */
- g_return_val_if_fail (values1->n_values == 4, 0);
- g_return_val_if_fail (values2->n_values == 4, 0);
-
- /* First struct IPv6 route */
- tmp_val = g_value_array_get_nth (values1, 0);
- dest1 = g_value_get_boxed (tmp_val);
- tmp_val = g_value_array_get_nth (values1, 1);
- prefix1 = g_value_get_uint (tmp_val);
- tmp_val = g_value_array_get_nth (values1, 2);
- next_hop1 = g_value_get_boxed (tmp_val);
- tmp_val = g_value_array_get_nth (values1, 3);
- metric1 = g_value_get_uint (tmp_val);
-
- /* Second struct IPv6 route */
- tmp_val = g_value_array_get_nth (values2, 0);
- dest2 = g_value_get_boxed (tmp_val);
- tmp_val = g_value_array_get_nth (values2, 1);
- prefix2 = g_value_get_uint (tmp_val);
- tmp_val = g_value_array_get_nth (values2, 2);
- next_hop2 = g_value_get_boxed (tmp_val);
- tmp_val = g_value_array_get_nth (values2, 3);
- metric2 = g_value_get_uint (tmp_val);
-
- /* Compare the routes */
- if (prefix1 != prefix2)
- return prefix1 < prefix2 ? -1 : prefix1 > prefix2;
-
- if (!IN6_ARE_ADDR_EQUAL ((struct in6_addr *)dest1->data, (struct in6_addr *)dest2->data)) {
- for (i = 0; ret == 0 && i < dest1->len; i++)
- ret = dest1->data[i] < dest2->data[i] ? -1 : dest1->data[i] > dest2->data[i];
- }
-
- if (!IN6_ARE_ADDR_EQUAL ((struct in6_addr *)next_hop1->data, (struct in6_addr *)next_hop2->data)) {
- for (i = 0; ret == 0 && i < next_hop1->len; i++)
- ret = next_hop1->data[i] < next_hop2->data[i] ? -1 : next_hop1->data[i] > next_hop2->data[i];
- }
-
- if (metric1 != metric2)
- ret = metric1 < metric2 ? -1 : metric1 > metric2;
-
- return ret;
-}
-
-static int
-_gvalues_compare_struct (const GValue *value1, const GValue *value2)
-{
- /* value1 and value2 must contain the same type since
- * _gvalues_compare() enforced that already.
- */
-
- if (G_VALUE_HOLDS (value1, DBUS_TYPE_G_IP6_ADDRESS)) {
- return _gvalue_ip6_address_compare (value1, value2);
- } else if (G_VALUE_HOLDS (value1, DBUS_TYPE_G_IP6_ROUTE)) {
- return _gvalue_ip6_route_compare (value1, value2);
- } else {
- g_warning ("Don't know how to compare structures");
- return (value1 == value2);
- }
-}
-
-int
-_gvalues_compare (const GValue *value1, const GValue *value2)
-{
- GType type1;
- GType type2;
- int ret;
-
- if (value1 == value2)
- return 0;
- if (!value1)
- return 1;
- if (!value2)
- return -1;
-
- type1 = G_VALUE_TYPE (value1);
- type2 = G_VALUE_TYPE (value2);
-
- if (type1 != type2)
- return type1 < type2 ? -1 : type1 > type2;
-
- if (type_is_fixed_size (type1, NULL))
- ret = _gvalues_compare_fixed (value1, value2);
- else if (type1 == G_TYPE_STRING)
- ret = _gvalues_compare_string (value1, value2);
- else if (G_VALUE_HOLDS_BOXED (value1)) {
- gpointer p1 = g_value_get_boxed (value1);
- gpointer p2 = g_value_get_boxed (value2);
-
- if (p1 == p2)
- ret = 0; /* Exactly the same values */
- else if (!p1)
- ret = 1; /* The comparison functions below don't handle NULLs */
- else if (!p2)
- ret = -1; /* The comparison functions below don't handle NULLs */
- else if (type1 == G_TYPE_STRV)
- ret = _gvalues_compare_strv (value1, value2);
- else if (dbus_g_type_is_collection (type1))
- ret = _gvalues_compare_collection (value1, value2);
- else if (dbus_g_type_is_map (type1))
- ret = _gvalues_compare_map (value1, value2);
- else if (dbus_g_type_is_struct (type1))
- ret = _gvalues_compare_struct (value1, value2);
- else if (type1 == G_TYPE_VALUE)
- ret = _gvalues_compare ((GValue *) g_value_get_boxed (value1), (GValue *) g_value_get_boxed (value2));
- else {
- g_warning ("Don't know how to compare boxed types '%s'", g_type_name (type1));
- ret = value1 == value2;
- }
- } else {
- g_warning ("Don't know how to compare types '%s'", g_type_name (type1));
- ret = value1 == value2;
- }
-
- return ret;
-}
-
-/*****************************************************************************/
-
-static void
-param_specialized_init (GParamSpec *pspec)
-{
-}
-
-static void
-param_specialized_set_default (GParamSpec *pspec, GValue *value)
-{
- value->data[0].v_pointer = NULL;
-}
-
-static gboolean
-param_specialized_validate (GParamSpec *pspec, GValue *value)
-{
- NMParamSpecSpecialized *sspec = NM_PARAM_SPEC_SPECIALIZED (pspec);
- GType value_type = G_VALUE_TYPE (value);
- gboolean changed = FALSE;
-
- if (!g_value_type_compatible (value_type, G_PARAM_SPEC_VALUE_TYPE (sspec))) {
- g_value_reset (value);
- changed = TRUE;
- }
-
- return changed;
-}
-
-static int
-param_specialized_values_cmp (GParamSpec *pspec,
- const GValue *value1,
- const GValue *value2)
-{
- return _gvalues_compare (value1, value2);
-}
-
-GType
-_nm_param_spec_specialized_get_type (void)
-{
- static GType type;
-
- if (G_UNLIKELY (type) == 0) {
- static const GParamSpecTypeInfo pspec_info = {
- sizeof (NMParamSpecSpecialized),
- 0,
- param_specialized_init,
- G_TYPE_OBJECT, /* value_type */
- NULL, /* finalize */
- param_specialized_set_default,
- param_specialized_validate,
- param_specialized_values_cmp,
- };
- type = g_param_type_register_static ("NMParamSpecSpecialized", &pspec_info);
- }
-
- return type;
-}
-
-GParamSpec *
-_nm_param_spec_specialized (const char *name,
- const char *nick,
- const char *blurb,
- GType specialized_type,
- GParamFlags flags)
-{
- NMParamSpecSpecialized *pspec;
-
- g_return_val_if_fail (g_type_is_a (specialized_type, G_TYPE_BOXED), NULL);
-
- pspec = g_param_spec_internal (NM_TYPE_PARAM_SPEC_SPECIALIZED,
- name, nick, blurb, flags);
-
- G_PARAM_SPEC (pspec)->value_type = specialized_type;
-
- return G_PARAM_SPEC (pspec);
-}
-
-/*****************************************************************************/
-/* Tests */
-
-#if 0
-
-static void
-compare_ints (void)
-{
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
-
- g_value_init (&value1, G_TYPE_INT);
- g_value_init (&value2, G_TYPE_INT);
-
- g_value_set_int (&value1, 5);
- g_value_set_int (&value2, 5);
- g_print ("Comparing ints 5 and 5: %d\n", _gvalues_compare (&value1, &value2));
-
- g_value_set_int (&value2, 10);
- g_print ("Comparing ints 5 and 10: %d\n", _gvalues_compare (&value1, &value2));
-
- g_value_set_int (&value2, 1);
- g_print ("Comparing ints 5 and 1: %d\n", _gvalues_compare (&value1, &value2));
-}
-
-static void
-compare_strings (void)
-{
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
- const char *str1 = "hello";
- const char *str2 = "world";
-
- g_value_init (&value1, G_TYPE_STRING);
- g_value_init (&value2, G_TYPE_STRING);
-
- g_value_set_string (&value1, str1);
- g_value_set_string (&value2, str1);
- g_print ("Comparing identical strings: %d\n", _gvalues_compare (&value1, &value2));
-
- g_value_set_string (&value2, str2);
- g_print ("Comparing different strings: %d\n", _gvalues_compare (&value1, &value2));
-}
-
-static void
-compare_strv (void)
-{
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
- char *strv1[] = { "foo", "bar", "baz", NULL };
- char *strv2[] = { "foo", "bar", "bar", NULL };
- char *strv3[] = { "foo", "bar", NULL };
- char *strv4[] = { "foo", "bar", "baz", "bam", NULL };
-
- g_value_init (&value1, G_TYPE_STRV);
- g_value_init (&value2, G_TYPE_STRV);
-
- g_value_set_boxed (&value1, strv1);
- g_value_set_boxed (&value2, strv1);
- g_print ("Comparing identical strv's: %d\n", _gvalues_compare (&value1, &value2));
-
- g_value_set_boxed (&value2, strv2);
- g_print ("Comparing different strv's: %d\n", _gvalues_compare (&value1, &value2));
-
- g_value_set_boxed (&value2, strv3);
- g_print ("Comparing different len (smaller) strv's: %d\n", _gvalues_compare (&value1, &value2));
-
- g_value_set_boxed (&value2, strv4);
- g_print ("Comparing different len (longer) strv's: %d\n", _gvalues_compare (&value1, &value2));
-}
-
-static void
-compare_garrays (void)
-{
- GArray *array1;
- GArray *array2;
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
- int i;
-
- g_value_init (&value1, DBUS_TYPE_G_UINT_ARRAY);
- array1 = g_array_new (FALSE, FALSE, sizeof (guint32));
-
- g_value_init (&value2, DBUS_TYPE_G_UINT_ARRAY);
- array2 = g_array_new (FALSE, FALSE, sizeof (guint32));
-
- for (i = 0; i < 5; i++) {
- g_array_append_val (array1, i);
- g_array_append_val (array2, i);
- }
-
- g_value_set_boxed (&value1, array1);
- g_value_set_boxed (&value2, array2);
-
- g_print ("Comparing identical arrays's: %d\n", _gvalues_compare (&value1, &value2));
-
- g_array_remove_index (array2, 0);
- g_value_set_boxed (&value2, array2);
- g_print ("Comparing different length arrays's: %d\n", _gvalues_compare (&value1, &value2));
-
- i = 7;
- g_array_prepend_val (array2, i);
- g_value_set_boxed (&value2, array2);
- g_print ("Comparing different arrays's: %d\n", _gvalues_compare (&value1, &value2));
-}
-
-static void
-compare_ptrarrays (void)
-{
- GPtrArray *array1;
- GPtrArray *array2;
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
-
- g_value_init (&value1, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
- array1 = g_ptr_array_new ();
-
- g_value_init (&value2, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
- array2 = g_ptr_array_new ();
-
- g_ptr_array_add (array1, "hello");
- g_ptr_array_add (array1, "world");
- g_value_set_boxed (&value1, array1);
-
- g_ptr_array_add (array2, "hello");
- g_ptr_array_add (array2, "world");
- g_value_set_boxed (&value2, array2);
-
- g_print ("Comparing identical ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
-
- g_ptr_array_add (array2, "boo");
- g_value_set_boxed (&value2, array2);
- g_print ("Comparing different len ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
-
- g_ptr_array_add (array1, "booz");
- g_value_set_boxed (&value1, array1);
- g_print ("Comparing different ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
-}
-
-static void
-compare_str_hash (void)
-{
- GHashTable *hash1;
- GHashTable *hash2;
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
-
- g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
- g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
-
- hash1 = g_hash_table_new (g_str_hash, g_str_equal);
- hash2 = g_hash_table_new (g_str_hash, g_str_equal);
-
- g_hash_table_insert (hash1, "key1", "hello");
- g_hash_table_insert (hash1, "key2", "world");
-
- g_hash_table_insert (hash2, "key1", "hello");
- g_hash_table_insert (hash2, "key2", "world");
-
- g_value_set_boxed (&value1, hash1);
- g_value_set_boxed (&value2, hash2);
- g_print ("Comparing identical str hashes: %d\n", _gvalues_compare (&value1, &value2));
-
- g_hash_table_remove (hash2, "key2");
- g_value_set_boxed (&value2, hash2);
- g_print ("Comparing different length str hashes: %d\n", _gvalues_compare (&value1, &value2));
-
- g_hash_table_insert (hash2, "key2", "moon");
- g_value_set_boxed (&value2, hash2);
- g_print ("Comparing different str hashes: %d\n", _gvalues_compare (&value1, &value2));
-}
-
-static GValue *
-str_to_gvalue (const char *str)
-{
- GValue *value;
-
- value = g_slice_new0 (GValue);
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, str);
-
- return value;
-}
-
-static GValue *
-int_to_gvalue (int i)
-{
- GValue *value;
-
- value = g_slice_new0 (GValue);
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, i);
-
- return value;
-}
-
-static void
-compare_gvalue_hash (void)
-{
- GHashTable *hash1;
- GHashTable *hash2;
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
-
- g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
- g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
-
- hash1 = g_hash_table_new (g_str_hash, g_str_equal);
- hash2 = g_hash_table_new (g_str_hash, g_str_equal);
-
- g_hash_table_insert (hash1, "key1", str_to_gvalue ("hello"));
- g_hash_table_insert (hash1, "key2", int_to_gvalue (5));
-
- g_hash_table_insert (hash2, "key1", str_to_gvalue ("hello"));
- g_hash_table_insert (hash2, "key2", int_to_gvalue (5));
-
- g_value_set_boxed (&value1, hash1);
- g_value_set_boxed (&value2, hash2);
- g_print ("Comparing identical gvalue hashes: %d\n", _gvalues_compare (&value1, &value2));
-
- g_hash_table_remove (hash2, "key2");
- g_value_set_boxed (&value2, hash2);
- g_print ("Comparing different length str hashes: %d\n", _gvalues_compare (&value1, &value2));
-
- g_hash_table_insert (hash2, "key2", str_to_gvalue ("moon"));
- g_value_set_boxed (&value2, hash2);
- g_print ("Comparing different str hashes: %d\n", _gvalues_compare (&value1, &value2));
-}
-
-static void
-compare_ip6_addresses (void)
-{
- GValueArray *array1;
- GValueArray *array2;
- GValueArray *array3;
- GByteArray *ba1;
- GByteArray *ba2;
- GByteArray *ba3;
- GValue element = G_VALUE_INIT;
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
- struct in6_addr addr1;
- struct in6_addr addr2;
- struct in6_addr addr3;
- guint32 prefix1 = 64;
- guint32 prefix2 = 64;
- guint32 prefix3 = 0;
-
- inet_pton (AF_INET6, "1:2:3:4:5:6:7:8", &addr1, sizeof (struct in6_addr));
- inet_pton (AF_INET6, "ffff:2:3:4:5:6:7:8", &addr2, sizeof (struct in6_addr));
- inet_pton (AF_INET6, "::", &addr3, sizeof (struct in6_addr));
-
- /* address 1 */
- ba1 = g_byte_array_new ();
- array1 = g_value_array_new (2);
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- g_byte_array_append (ba1, (guint8 *) addr1.s6_addr, 16);
- g_value_take_boxed (&element, ba1);
- g_value_array_append (array1, &element);
- g_value_unset (&element);
-
- g_value_init (&element, G_TYPE_UINT);
- g_value_set_uint (&element, prefix1);
- g_value_array_append (array1, &element);
- g_value_unset (&element);
-
- /* address 2 */
- ba2 = g_byte_array_new ();
- array2 = g_value_array_new (2);
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- g_byte_array_append (ba2, (guint8 *) addr2.s6_addr, 16);
- g_value_take_boxed (&element, ba2);
- g_value_array_append (array2, &element);
- g_value_unset (&element);
-
- g_value_init (&element, G_TYPE_UINT);
- g_value_set_uint (&element, prefix2);
- g_value_array_append (array2, &element);
- g_value_unset (&element);
-
- /* address 3 */
- ba3 = g_byte_array_new ();
- array3 = g_value_array_new (2);
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- g_byte_array_append (ba3, (guint8 *) addr3.s6_addr, 16);
- g_value_take_boxed (&element, ba3);
- g_value_array_append (array3, &element);
- g_value_unset (&element);
-
- g_value_init (&element, G_TYPE_UINT);
- g_value_set_uint (&element, prefix3);
- g_value_array_append (array3, &element);
- g_value_unset (&element);
-
- g_value_init (&value1, DBUS_TYPE_G_IP6_ADDRESS);
- g_value_init (&value2, DBUS_TYPE_G_IP6_ADDRESS);
-
- g_value_set_boxed (&value1, array1);
- g_value_set_boxed (&value2, array1);
- g_print ("Comparing identical IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
-
- g_value_set_boxed (&value1, array1);
- g_value_set_boxed (&value2, array2);
- g_print ("Comparing different IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
-
- g_value_set_boxed (&value1, array1);
- g_value_set_boxed (&value2, array3);
- g_print ("Comparing different IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
-}
-
-int
-main (int argc, char *argv[])
-{
- DBusGConnection *bus;
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-
- compare_ints ();
- compare_strings ();
- compare_strv ();
- compare_garrays ();
- compare_ptrarrays ();
- compare_str_hash ();
- compare_gvalue_hash ();
- compare_ip6_addresses ();
-
- return 0;
-}
-
-#endif
diff --git a/libnm-util/nm-param-spec-specialized.h b/libnm-util/nm-param-spec-specialized.h
deleted file mode 100644
index 0c4b07e616..0000000000
--- a/libnm-util/nm-param-spec-specialized.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_PARAM_SPEC_SPECIALIZED_H
-#define NM_PARAM_SPEC_SPECIALIZED_H
-
-typedef struct _NMParamSpecSpecialized NMParamSpecSpecialized;
-
-#define NM_TYPE_PARAM_SPEC_SPECIALIZED (_nm_param_spec_specialized_get_type ())
-
-#define NM_IS_PARAM_SPEC_SPECIALIZED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), NM_TYPE_PARAM_SPEC_SPECIALIZED))
-#define NM_PARAM_SPEC_SPECIALIZED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), NM_TYPE_PARAM_SPEC_SPECIALIZED, NMParamSpecSpecialized))
-
-GType _nm_param_spec_specialized_get_type (void);
-
-GParamSpec *_nm_param_spec_specialized (const char *name,
- const char *nick,
- const char *blurb,
- GType specialized_type,
- GParamFlags flags);
-
-#endif /* NM_PARAM_SPEC_SPECIALIZED_H */
diff --git a/libnm-util/nm-setting-8021x.c b/libnm-util/nm-setting-8021x.c
deleted file mode 100644
index 805a5d25ad..0000000000
--- a/libnm-util/nm-setting-8021x.c
+++ /dev/null
@@ -1,3730 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-setting-8021x.h"
-
-#include <string.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "crypto.h"
-#include "nm-utils-private.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-8021x
- * @short_description: Describes 802.1x-authenticated connection properties
- * @include: nm-setting-8021x.h
- *
- * The #NMSetting8021x object is a #NMSetting subclass that describes
- * properties necessary for connection to 802.1x-authenticated networks, such as
- * WPA and WPA2 Enterprise Wi-Fi networks and wired 802.1x networks. 802.1x
- * connections typically use certificates and/or EAP authentication methods to
- * securely verify, identify, and authenticate the client to the network itself,
- * instead of simply relying on a widely shared static key.
- *
- * It's a good idea to read up on wpa_supplicant configuration before using this
- * setting extensively, since most of the options here correspond closely with
- * the relevant wpa_supplicant configuration options.
- *
- * Furthermore, to get a good idea of 802.1x, EAP, TLS, TTLS, etc and their
- * applications to Wi-Fi and wired networks, you'll want to get copies of the
- * following books.
- *
- * 802.11 Wireless Networks: The Definitive Guide, Second Edition
- * Author: Matthew Gast
- * ISBN: 978-0596100520
- *
- * Cisco Wireless LAN Security
- * Authors: Krishna Sankar, Sri Sundaralingam, Darrin Miller, and Andrew Balinsky
- * ISBN: 978-1587051548
- **/
-
-#define SCHEME_PATH "file://"
-
-/**
- * nm_setting_802_1x_error_quark:
- *
- * Registers an error quark for #NMSetting8021x if necessary.
- *
- * Returns: the error quark used for #NMSetting8021x errors.
- **/
-GQuark
-nm_setting_802_1x_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-802-1x-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSetting8021x, nm_setting_802_1x, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_802_1X_SETTING_NAME,
- g_define_type_id,
- 2,
- NM_SETTING_802_1X_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_802_1X)
-
-#define NM_SETTING_802_1X_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_802_1X, NMSetting8021xPrivate))
-
-G_STATIC_ASSERT ( (NM_SETTING_802_1X_CK_FORMAT_UNKNOWN == (NMSetting8021xCKFormat) NM_CRYPTO_FILE_FORMAT_UNKNOWN) );
-G_STATIC_ASSERT ( (NM_SETTING_802_1X_CK_FORMAT_X509 == (NMSetting8021xCKFormat) NM_CRYPTO_FILE_FORMAT_X509) );
-G_STATIC_ASSERT ( (NM_SETTING_802_1X_CK_FORMAT_RAW_KEY == (NMSetting8021xCKFormat) NM_CRYPTO_FILE_FORMAT_RAW_KEY) );
-G_STATIC_ASSERT ( (NM_SETTING_802_1X_CK_FORMAT_PKCS12 == (NMSetting8021xCKFormat) NM_CRYPTO_FILE_FORMAT_PKCS12) );
-
-typedef struct {
- GSList *eap; /* GSList of strings */
- char *identity;
- char *anonymous_identity;
- char *pac_file;
- GByteArray *ca_cert;
- char *ca_path;
- char *subject_match;
- GSList *altsubject_matches;
- GByteArray *client_cert;
- char *phase1_peapver;
- char *phase1_peaplabel;
- char *phase1_fast_provisioning;
- char *phase2_auth;
- char *phase2_autheap;
- GByteArray *phase2_ca_cert;
- char *phase2_ca_path;
- char *phase2_subject_match;
- GSList *phase2_altsubject_matches;
- GByteArray *phase2_client_cert;
- char *password;
- NMSettingSecretFlags password_flags;
- GByteArray *password_raw;
- NMSettingSecretFlags password_raw_flags;
- char *pin;
- NMSettingSecretFlags pin_flags;
- GByteArray *private_key;
- char *private_key_password;
- NMSettingSecretFlags private_key_password_flags;
- GByteArray *phase2_private_key;
- char *phase2_private_key_password;
- NMSettingSecretFlags phase2_private_key_password_flags;
- gboolean system_ca_certs;
-} NMSetting8021xPrivate;
-
-enum {
- PROP_0,
- PROP_EAP,
- PROP_IDENTITY,
- PROP_ANONYMOUS_IDENTITY,
- PROP_PAC_FILE,
- PROP_CA_CERT,
- PROP_CA_PATH,
- PROP_SUBJECT_MATCH,
- PROP_ALTSUBJECT_MATCHES,
- PROP_CLIENT_CERT,
- PROP_PHASE1_PEAPVER,
- PROP_PHASE1_PEAPLABEL,
- PROP_PHASE1_FAST_PROVISIONING,
- PROP_PHASE2_AUTH,
- PROP_PHASE2_AUTHEAP,
- PROP_PHASE2_CA_CERT,
- PROP_PHASE2_CA_PATH,
- PROP_PHASE2_SUBJECT_MATCH,
- PROP_PHASE2_ALTSUBJECT_MATCHES,
- PROP_PHASE2_CLIENT_CERT,
- PROP_PASSWORD,
- PROP_PASSWORD_FLAGS,
- PROP_PASSWORD_RAW,
- PROP_PASSWORD_RAW_FLAGS,
- PROP_PRIVATE_KEY,
- PROP_PRIVATE_KEY_PASSWORD,
- PROP_PRIVATE_KEY_PASSWORD_FLAGS,
- PROP_PHASE2_PRIVATE_KEY,
- PROP_PHASE2_PRIVATE_KEY_PASSWORD,
- PROP_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS,
- PROP_PIN,
- PROP_PIN_FLAGS,
- PROP_SYSTEM_CA_CERTS,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_802_1x_new:
- *
- * Creates a new #NMSetting8021x object with default values.
- *
- * Returns: the new empty #NMSetting8021x object
- **/
-NMSetting *
-nm_setting_802_1x_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_802_1X, NULL);
-}
-
-/**
- * nm_setting_802_1x_get_num_eap_methods:
- * @setting: the #NMSetting8021x
- *
- * Returns the number of eap methods allowed for use when connecting to the
- * network. Generally only one EAP method is used. Use the functions
- * nm_setting_802_1x_get_eap_method(), nm_setting_802_1x_add_eap_method(),
- * and nm_setting_802_1x_remove_eap_method() for adding, removing, and retrieving
- * allowed EAP methods.
- *
- * Returns: the number of allowed EAP methods
- **/
-guint32
-nm_setting_802_1x_get_num_eap_methods (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), 0);
-
- return g_slist_length (NM_SETTING_802_1X_GET_PRIVATE (setting)->eap);
-}
-
-/**
- * nm_setting_802_1x_get_eap_method:
- * @setting: the #NMSetting8021x
- * @i: the index of the EAP method name to return
- *
- * Returns the name of the allowed EAP method at index @i.
- *
- * Returns: the name of the allowed EAP method at index @i
- **/
-const char *
-nm_setting_802_1x_get_eap_method (NMSetting8021x *setting, guint32 i)
-{
- NMSetting8021xPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->eap), NULL);
-
- return (const char *) g_slist_nth_data (priv->eap, i);
-}
-
-/**
- * nm_setting_802_1x_add_eap_method:
- * @setting: the #NMSetting8021x
- * @eap: the name of the EAP method to allow for this connection
- *
- * Adds an allowed EAP method. The setting is not valid until at least one
- * EAP method has been added. See #NMSetting8021x:eap property for a list of
- * allowed EAP methods.
- *
- * Returns: %TRUE if the EAP method was successfully added, %FALSE if it was
- * not a valid method or if it was already allowed.
- **/
-gboolean
-nm_setting_802_1x_add_eap_method (NMSetting8021x *setting, const char *eap)
-{
- NMSetting8021xPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
- g_return_val_if_fail (eap != NULL, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- for (iter = priv->eap; iter; iter = g_slist_next (iter)) {
- if (!strcmp (eap, (char *) iter->data))
- return FALSE;
- }
-
- priv->eap = g_slist_append (priv->eap, g_ascii_strdown (eap, -1));
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_EAP);
- return TRUE;
-}
-
-/**
- * nm_setting_802_1x_remove_eap_method:
- * @setting: the #NMSetting8021x
- * @i: the index of the EAP method to remove
- *
- * Removes the allowed EAP method at the specified index.
- **/
-void
-nm_setting_802_1x_remove_eap_method (NMSetting8021x *setting, guint32 i)
-{
- NMSetting8021xPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_802_1X (setting));
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->eap, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->eap = g_slist_delete_link (priv->eap, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_EAP);
-}
-
-/**
- * nm_setting_802_1x_remove_eap_method_by_value:
- * @setting: the #NMSetting8021x
- * @eap: the name of the EAP method to remove
- *
- * Removes the allowed EAP method @method.
- *
- * Returns: %TRUE if the EAP method was founs and removed, %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_802_1x_remove_eap_method_by_value (NMSetting8021x *setting,
- const char *eap)
-{
- NMSetting8021xPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
- g_return_val_if_fail (eap != NULL, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- for (iter = priv->eap; iter; iter = g_slist_next (iter)) {
- if (!strcmp (eap, (char *) iter->data)) {
- priv->eap = g_slist_delete_link (priv->eap, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_EAP);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_802_1x_clear_eap_methods:
- * @setting: the #NMSetting8021x
- *
- * Clears all allowed EAP methods.
- **/
-void
-nm_setting_802_1x_clear_eap_methods (NMSetting8021x *setting)
-{
- NMSetting8021xPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_802_1X (setting));
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- g_slist_free_full (priv->eap, g_free);
- priv->eap = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_EAP);
-}
-
-/**
- * nm_setting_802_1x_get_identity:
- * @setting: the #NMSetting8021x
- *
- * Returns the identifier used by some EAP methods (like TLS) to
- * authenticate the user. Often this is a username or login name.
- *
- * Returns: the user identifier
- **/
-const char *
-nm_setting_802_1x_get_identity (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->identity;
-}
-
-/**
- * nm_setting_802_1x_get_anonymous_identity:
- * @setting: the #NMSetting8021x
- *
- * Returns the anonymous identifier used by some EAP methods (like TTLS) to
- * authenticate the user in the outer unencrypted "phase 1" authentication. The
- * inner "phase 2" authentication will use the #NMSetting8021x:identity in
- * a secure form, if applicable for that EAP method.
- *
- * Returns: the anonymous identifier
- **/
-const char *
-nm_setting_802_1x_get_anonymous_identity (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->anonymous_identity;
-}
-
-/**
- * nm_setting_802_1x_get_pac_file:
- * @setting: the #NMSetting8021x
- *
- * Returns the file containing PAC credentials used by EAP-FAST method.
- *
- * Returns: the PAC file
- **/
-const char *
-nm_setting_802_1x_get_pac_file (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->pac_file;
-}
-
-/**
- * nm_setting_802_1x_get_ca_path:
- * @setting: the #NMSetting8021x
- *
- * Returns the path of the CA certificate directory if previously set. Systems
- * will often have a directory that contains multiple individual CA certificates
- * which the supplicant can then add to the verification chain. This may be
- * used in addition to the #NMSetting8021x:ca-cert property to add more CA
- * certificates for verifying the network to client.
- *
- * Returns: the CA certificate directory path
- **/
-const char *
-nm_setting_802_1x_get_ca_path (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->ca_path;
-}
-
-/**
- * nm_setting_802_1x_get_system_ca_certs:
- * @setting: the #NMSetting8021x
- *
- * Sets the #NMSetting8021x:system-ca-certs property. The
- * #NMSetting8021x:ca-path and #NMSetting8021x:phase2-ca-path
- * properties are ignored if the #NMSetting8021x:system-ca-certs property is
- * %TRUE, in which case a system-wide CA certificate directory specified at
- * compile time (using the --system-ca-path configure option) is used in place
- * of these properties.
- *
- * Returns: %TRUE if a system CA certificate path should be used, %FALSE if not
- **/
-gboolean
-nm_setting_802_1x_get_system_ca_certs (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->system_ca_certs;
-}
-
-static NMSetting8021xCKScheme
-get_cert_scheme (GByteArray *array)
-{
- if (!array || !array->len)
- return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
-
- /* interpret the blob as PATH if it starts with "file://". */
- if ( array->len >= NM_STRLEN (SCHEME_PATH)
- && !memcmp (array->data, SCHEME_PATH, NM_STRLEN (SCHEME_PATH))) {
- /* But it must also be NUL terminated, contain at least
- * one non-NUL character, and contain only one trailing NUL
- * character.
- * And ensure it's UTF-8 valid too so we can pass it through
- * D-Bus and stuff like that. */
- if ( array->len > NM_STRLEN (SCHEME_PATH) + 1
- && array->data[array->len - 1] == '\0'
- && g_utf8_validate ((const char *) &array->data[NM_STRLEN (SCHEME_PATH)], array->len - (NM_STRLEN (SCHEME_PATH) + 1), NULL))
- return NM_SETTING_802_1X_CK_SCHEME_PATH;
- return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
- }
-
- return NM_SETTING_802_1X_CK_SCHEME_BLOB;
-}
-
-static GByteArray *
-load_and_verify_certificate (const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMCryptoFileFormat *out_file_format,
- GError **error)
-{
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GByteArray *array;
-
- array = crypto_load_and_verify_certificate (cert_path, &format, error);
-
- if (!array || !array->len || format == NM_CRYPTO_FILE_FORMAT_UNKNOWN)
- format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
- /* If we load the file as blob, we must ensure that the binary data does not
- * start with file://. NMSetting8021x cannot represent blobs that start with
- * file://.
- * If that's the case, coerce the format to UNKNOWN. The callers will take care
- * of that and not set the blob. */
- if (get_cert_scheme (array) != NM_SETTING_802_1X_CK_SCHEME_BLOB)
- format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- }
-
- if (out_file_format)
- *out_file_format = format;
- return array;
-}
-
-/**
- * nm_setting_802_1x_get_ca_cert_scheme:
- * @setting: the #NMSetting8021x
- *
- * Returns the scheme used to store the CA certificate. If the returned scheme
- * is %NM_SETTING_802_1X_CK_SCHEME_BLOB, use nm_setting_802_1x_get_ca_cert_blob();
- * if %NM_SETTING_802_1X_CK_SCHEME_PATH, use nm_setting_802_1x_get_ca_cert_path().
- *
- * Returns: scheme used to store the CA certificate (blob or path)
- **/
-NMSetting8021xCKScheme
-nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_802_1X_CK_SCHEME_UNKNOWN);
-
- return get_cert_scheme (NM_SETTING_802_1X_GET_PRIVATE (setting)->ca_cert);
-}
-
-/**
- * nm_setting_802_1x_get_ca_cert_blob:
- * @setting: the #NMSetting8021x
- *
- * Returns the CA certificate blob if the CA certificate is stored using the
- * %NM_SETTING_802_1X_CK_SCHEME_BLOB scheme. Not all EAP methods use a
- * CA certificate (LEAP for example), and those that can take advantage of the
- * CA certificate allow it to be unset. Note that lack of a CA certificate
- * reduces security by allowing man-in-the-middle attacks, because the identity
- * of the network cannot be confirmed by the client.
- *
- * Returns: the CA certificate data
- **/
-const GByteArray *
-nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_ca_cert_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB, NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->ca_cert;
-}
-
-/**
- * nm_setting_802_1x_get_ca_cert_path:
- * @setting: the #NMSetting8021x
- *
- * Returns the CA certificate path if the CA certificate is stored using the
- * %NM_SETTING_802_1X_CK_SCHEME_PATH scheme. Not all EAP methods use a
- * CA certificate (LEAP for example), and those that can take advantage of the
- * CA certificate allow it to be unset. Note that lack of a CA certificate
- * reduces security by allowing man-in-the-middle attacks, because the identity
- * of the network cannot be confirmed by the client.
- *
- * Returns: path to the CA certificate file
- **/
-const char *
-nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_ca_cert_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
-
- return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->ca_cert->data + strlen (SCHEME_PATH));
-}
-
-static GByteArray *
-path_to_scheme_value (const char *path)
-{
- GByteArray *array;
- gsize len;
-
- g_return_val_if_fail (path != NULL && path[0], NULL);
-
- len = strlen (path);
-
- /* Add the path scheme tag to the front, then the filename */
- array = g_byte_array_sized_new (len + strlen (SCHEME_PATH) + 1);
- g_byte_array_append (array, (const guint8 *) SCHEME_PATH, strlen (SCHEME_PATH));
- g_byte_array_append (array, (const guint8 *) path, len);
- g_byte_array_append (array, (const guint8 *) "\0", 1);
- return array;
-}
-
-/**
- * nm_setting_802_1x_set_ca_cert:
- * @setting: the #NMSetting8021x
- * @cert_path: when @scheme is set to either %NM_SETTING_802_1X_CK_SCHEME_PATH
- * or %NM_SETTING_802_1X_CK_SCHEME_BLOB, pass the path of the CA certificate
- * file (PEM or DER format). The path must be UTF-8 encoded; use
- * g_filename_to_utf8() to convert if needed. Passing %NULL with any @scheme
- * clears the CA certificate.
- * @scheme: desired storage scheme for the certificate
- * @out_format: on successful return, the type of the certificate added
- * @error: on unsuccessful return, an error
- *
- * Reads a certificate from disk and sets the #NMSetting8021x:ca-cert property
- * with the raw certificate data if using the %NM_SETTING_802_1X_CK_SCHEME_BLOB
- * scheme, or with the path to the certificate file if using the
- * %NM_SETTING_802_1X_CK_SCHEME_PATH scheme.
- *
- * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful
- **/
-gboolean
-nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
- const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error)
-{
- NMSetting8021xPrivate *priv;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GByteArray *data;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
-
- if (cert_path) {
- g_return_val_if_fail (g_utf8_validate (cert_path, -1, NULL), FALSE);
- g_return_val_if_fail ( scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB
- || scheme == NM_SETTING_802_1X_CK_SCHEME_PATH,
- FALSE);
- }
-
- if (out_format)
- g_return_val_if_fail (*out_format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- /* Clear out any previous ca_cert blob */
- if (priv->ca_cert) {
- g_byte_array_free (priv->ca_cert, TRUE);
- priv->ca_cert = NULL;
- }
-
- if (!cert_path) {
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CA_CERT);
- return TRUE;
- }
-
- data = load_and_verify_certificate (cert_path, scheme, &format, error);
- if (data) {
- /* wpa_supplicant can only use raw x509 CA certs */
- if (format == NM_CRYPTO_FILE_FORMAT_X509) {
- if (out_format)
- *out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
-
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
- priv->ca_cert = g_byte_array_ref (data);
- else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
- priv->ca_cert = path_to_scheme_value (cert_path);
- else
- g_assert_not_reached ();
- } else {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("CA certificate must be in X.509 format"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CA_CERT);
- }
- g_byte_array_unref (data);
- }
-
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CA_CERT);
- return priv->ca_cert != NULL;
-}
-
-/**
- * nm_setting_802_1x_get_subject_match:
- * @setting: the #NMSetting8021x
- *
- * Returns: the #NMSetting8021x:subject-match property. This is the
- * substring to be matched against the subject of the authentication
- * server certificate, or %NULL no subject verification is to be
- * performed.
- **/
-const char *
-nm_setting_802_1x_get_subject_match (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->subject_match;
-}
-
-/**
- * nm_setting_802_1x_get_num_altsubject_matches:
- * @setting: the #NMSetting8021x
- *
- * Returns the number of entries in the
- * #NMSetting8021x:altsubject-matches property of this setting.
- *
- * Returns: the number of altsubject-matches entries.
- **/
-guint32
-nm_setting_802_1x_get_num_altsubject_matches (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), 0);
-
- return g_slist_length (NM_SETTING_802_1X_GET_PRIVATE (setting)->altsubject_matches);
-}
-
-/**
- * nm_setting_802_1x_get_altsubject_match:
- * @setting: the #NMSettingConnection
- * @i: the zero-based index of the array of altSubjectName matches
- *
- * Returns the altSubjectName match at index @i.
- *
- * Returns: the altSubjectName match at index @i
- **/
-const char *
-nm_setting_802_1x_get_altsubject_match (NMSetting8021x *setting, guint32 i)
-{
- NMSetting8021xPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->altsubject_matches), NULL);
-
- return (const char *) g_slist_nth_data (priv->altsubject_matches, i);
-}
-
-/**
- * nm_setting_802_1x_add_altsubject_match:
- * @setting: the #NMSetting8021x
- * @altsubject_match: the altSubjectName to allow for this connection
- *
- * Adds an allowed alternate subject name match. Until at least one
- * match is added, the altSubjectName of the remote authentication
- * server is not verified.
- *
- * Returns: %TRUE if the alternative subject name match was
- * successfully added, %FALSE if it was already allowed.
- **/
-gboolean
-nm_setting_802_1x_add_altsubject_match (NMSetting8021x *setting,
- const char *altsubject_match)
-{
- NMSetting8021xPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
- g_return_val_if_fail (altsubject_match != NULL, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- for (iter = priv->altsubject_matches; iter; iter = g_slist_next (iter)) {
- if (!strcmp (altsubject_match, (char *) iter->data))
- return FALSE;
- }
-
- priv->altsubject_matches = g_slist_append (priv->altsubject_matches,
- g_strdup (altsubject_match));
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_ALTSUBJECT_MATCHES);
- return TRUE;
-}
-
-/**
- * nm_setting_802_1x_remove_altsubject_match:
- * @setting: the #NMSetting8021x
- * @i: the index of the altSubjectName match to remove
- *
- * Removes the allowed altSubjectName at the specified index.
- **/
-void
-nm_setting_802_1x_remove_altsubject_match (NMSetting8021x *setting, guint32 i)
-{
- NMSetting8021xPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_802_1X (setting));
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->altsubject_matches, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->altsubject_matches = g_slist_delete_link (priv->altsubject_matches, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_ALTSUBJECT_MATCHES);
-}
-
-/**
- * nm_setting_802_1x_remove_altsubject_match_by_value:
- * @setting: the #NMSetting8021x
- * @altsubject_match: the altSubjectName to remove
- *
- * Removes the allowed altSubjectName @altsubject_match.
- *
- * Returns: %TRUE if the alternative subject name match was found and removed,
- * %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_802_1x_remove_altsubject_match_by_value (NMSetting8021x *setting,
- const char *altsubject_match)
-{
- NMSetting8021xPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
- g_return_val_if_fail (altsubject_match != NULL, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- for (iter = priv->altsubject_matches; iter; iter = g_slist_next (iter)) {
- if (!strcmp (altsubject_match, (char *) iter->data)) {
- priv->altsubject_matches = g_slist_delete_link (priv->altsubject_matches, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_ALTSUBJECT_MATCHES);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_802_1x_clear_altsubject_matches:
- * @setting: the #NMSetting8021x
- *
- * Clears all altSubjectName matches.
- **/
-void
-nm_setting_802_1x_clear_altsubject_matches (NMSetting8021x *setting)
-{
- NMSetting8021xPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_802_1X (setting));
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- g_slist_free_full (priv->altsubject_matches, g_free);
- priv->altsubject_matches = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_ALTSUBJECT_MATCHES);
-}
-
-/**
- * nm_setting_802_1x_get_client_cert_scheme:
- * @setting: the #NMSetting8021x
- *
- * Returns the scheme used to store the client certificate. If the returned scheme
- * is %NM_SETTING_802_1X_CK_SCHEME_BLOB, use nm_setting_802_1x_get_client_cert_blob();
- * if %NM_SETTING_802_1X_CK_SCHEME_PATH, use nm_setting_802_1x_get_client_cert_path().
- *
- * Returns: scheme used to store the client certificate (blob or path)
- **/
-NMSetting8021xCKScheme
-nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_802_1X_CK_SCHEME_UNKNOWN);
-
- return get_cert_scheme (NM_SETTING_802_1X_GET_PRIVATE (setting)->client_cert);
-}
-
-/**
- * nm_setting_802_1x_get_client_cert_blob:
- * @setting: the #NMSetting8021x
- *
- * Client certificates are used to identify the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * Returns: the client certificate data
- **/
-const GByteArray *
-nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_client_cert_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB, NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->client_cert;
-}
-
-/**
- * nm_setting_802_1x_get_client_cert_path:
- * @setting: the #NMSetting8021x
- *
- * Client certificates are used to identify the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * Returns: path to the client certificate file
- **/
-const char *
-nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_client_cert_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
-
- return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->client_cert->data + strlen (SCHEME_PATH));
-}
-
-/**
- * nm_setting_802_1x_set_client_cert:
- * @setting: the #NMSetting8021x
- * @cert_path: when @scheme is set to either %NM_SETTING_802_1X_CK_SCHEME_PATH
- * or %NM_SETTING_802_1X_CK_SCHEME_BLOB, pass the path of the client
- * certificate file (PEM, DER, or PKCS#<!-- -->12 format). The path must be UTF-8
- * encoded; use g_filename_to_utf8() to convert if needed. Passing %NULL with
- * any @scheme clears the client certificate.
- * @scheme: desired storage scheme for the certificate
- * @out_format: on successful return, the type of the certificate added
- * @error: on unsuccessful return, an error
- *
- * Reads a certificate from disk and sets the #NMSetting8021x:client-cert
- * property with the raw certificate data if using the
- * %NM_SETTING_802_1X_CK_SCHEME_BLOB scheme, or with the path to the certificate
- * file if using the %NM_SETTING_802_1X_CK_SCHEME_PATH scheme.
- *
- * Client certificates are used to identify the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful
- **/
-gboolean
-nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
- const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error)
-{
- NMSetting8021xPrivate *priv;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GByteArray *data;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
-
- if (cert_path) {
- g_return_val_if_fail (g_utf8_validate (cert_path, -1, NULL), FALSE);
- g_return_val_if_fail ( scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB
- || scheme == NM_SETTING_802_1X_CK_SCHEME_PATH,
- FALSE);
- }
-
- if (out_format)
- g_return_val_if_fail (*out_format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- /* Clear out any previous ca_cert blob */
- if (priv->client_cert) {
- g_byte_array_free (priv->client_cert, TRUE);
- priv->client_cert = NULL;
- }
-
- if (!cert_path) {
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
- return TRUE;
- }
-
- data = load_and_verify_certificate (cert_path, scheme, &format, error);
- if (data) {
- gboolean valid = FALSE;
-
- switch (format) {
- case NM_CRYPTO_FILE_FORMAT_X509:
- if (out_format)
- *out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
- valid = TRUE;
- break;
- case NM_CRYPTO_FILE_FORMAT_PKCS12:
- if (out_format)
- *out_format = NM_SETTING_802_1X_CK_FORMAT_PKCS12;
- valid = TRUE;
- break;
- default:
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("invalid certificate format"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
- break;
- }
-
- if (valid) {
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
- priv->client_cert = g_byte_array_ref (data);
- else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
- priv->client_cert = path_to_scheme_value (cert_path);
- else
- g_assert_not_reached ();
- }
- g_byte_array_unref (data);
- }
-
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
- return priv->client_cert != NULL;
-}
-
-/**
- * nm_setting_802_1x_get_phase1_peapver:
- * @setting: the #NMSetting8021x
- *
- * Returns: the "phase 1" PEAP version to be used when authenticating with
- * EAP-PEAP as contained in the #NMSetting8021x:phase1-peapver property. Valid
- * values are %NULL (unset), "0" (PEAP version 0), and "1" (PEAP version 1).
- **/
-const char *
-nm_setting_802_1x_get_phase1_peapver (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase1_peapver;
-}
-
-/**
- * nm_setting_802_1x_get_phase1_peaplabel:
- * @setting: the #NMSetting8021x
- *
- * Returns: whether the "phase 1" PEAP label is new-style or old-style, to be
- * used when authenticating with EAP-PEAP, as contained in the
- * #NMSetting8021x:phase1-peaplabel property. Valid values are %NULL (unset),
- * "0" (use old-style label), and "1" (use new-style label). See the
- * wpa_supplicant documentation for more details.
- **/
-const char *
-nm_setting_802_1x_get_phase1_peaplabel (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase1_peaplabel;
-}
-
-/**
- * nm_setting_802_1x_get_phase1_fast_provisioning:
- * @setting: the #NMSetting8021x
- *
- * Returns: whether "phase 1" PEAP fast provisioning should be used, as specified
- * by the #NMSetting8021x:phase1-fast-provisioning property. See the
- * wpa_supplicant documentation for more details.
- **/
-const char *
-nm_setting_802_1x_get_phase1_fast_provisioning (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase1_fast_provisioning;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_auth:
- * @setting: the #NMSetting8021x
- *
- * Returns: the "phase 2" non-EAP (ex MD5) allowed authentication method as
- * specified by the #NMSetting8021x:phase2-auth property.
- **/
-const char *
-nm_setting_802_1x_get_phase2_auth (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_auth;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_autheap:
- * @setting: the #NMSetting8021x
- *
- * Returns: the "phase 2" EAP-based (ex TLS) allowed authentication method as
- * specified by the #NMSetting8021x:phase2-autheap property.
- **/
-const char *
-nm_setting_802_1x_get_phase2_autheap (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_autheap;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_ca_path:
- * @setting: the #NMSetting8021x
- *
- * Returns the path of the "phase 2" CA certificate directory if previously set.
- * Systems will often have a directory that contains multiple individual CA
- * certificates which the supplicant can then add to the verification chain.
- * This may be used in addition to the #NMSetting8021x:phase2-ca-cert property
- * to add more CA certificates for verifying the network to client.
- *
- * Returns: the "phase 2" CA certificate directory path
- **/
-const char *
-nm_setting_802_1x_get_phase2_ca_path (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_ca_path;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_ca_cert_scheme:
- * @setting: the #NMSetting8021x
- *
- * Returns the scheme used to store the "phase 2" CA certificate. If the
- * returned scheme is %NM_SETTING_802_1X_CK_SCHEME_BLOB, use
- * nm_setting_802_1x_get_ca_cert_blob(); if %NM_SETTING_802_1X_CK_SCHEME_PATH,
- * use nm_setting_802_1x_get_ca_cert_path().
- *
- * Returns: scheme used to store the "phase 2" CA certificate (blob or path)
- **/
-NMSetting8021xCKScheme
-nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_802_1X_CK_SCHEME_UNKNOWN);
-
- return get_cert_scheme (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_ca_cert);
-}
-
-/**
- * nm_setting_802_1x_get_phase2_ca_cert_blob:
- * @setting: the #NMSetting8021x
- *
- * Returns the "phase 2" CA certificate blob if the CA certificate is stored
- * using the %NM_SETTING_802_1X_CK_SCHEME_BLOB scheme. Not all EAP methods use
- * a CA certificate (LEAP for example), and those that can take advantage of the
- * CA certificate allow it to be unset. Note that lack of a CA certificate
- * reduces security by allowing man-in-the-middle attacks, because the identity
- * of the network cannot be confirmed by the client.
- *
- * Returns: the "phase 2" CA certificate data
- **/
-const GByteArray *
-nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB, NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_ca_cert;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_ca_cert_path:
- * @setting: the #NMSetting8021x
- *
- * Returns the "phase 2" CA certificate path if the CA certificate is stored
- * using the %NM_SETTING_802_1X_CK_SCHEME_PATH scheme. Not all EAP methods use
- * a CA certificate (LEAP for example), and those that can take advantage of the
- * CA certificate allow it to be unset. Note that lack of a CA certificate
- * reduces security by allowing man-in-the-middle attacks, because the identity
- * of the network cannot be confirmed by the client.
- *
- * Returns: path to the "phase 2" CA certificate file
- **/
-const char *
-nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
-
- return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_ca_cert->data + strlen (SCHEME_PATH));
-}
-
-/**
- * nm_setting_802_1x_set_phase2_ca_cert:
- * @setting: the #NMSetting8021x
- * @cert_path: when @scheme is set to either %NM_SETTING_802_1X_CK_SCHEME_PATH
- * or %NM_SETTING_802_1X_CK_SCHEME_BLOB, pass the path of the "phase2" CA
- * certificate file (PEM or DER format). The path must be UTF-8 encoded; use
- * g_filename_to_utf8() to convert if needed. Passing %NULL with any @scheme
- * clears the "phase2" CA certificate.
- * @scheme: desired storage scheme for the certificate
- * @out_format: on successful return, the type of the certificate added
- * @error: on unsuccessful return, an error
- *
- * Reads a certificate from disk and sets the #NMSetting8021x:phase2-ca-cert
- * property with the raw certificate data if using the
- * %NM_SETTING_802_1X_CK_SCHEME_BLOB scheme, or with the path to the certificate
- * file if using the %NM_SETTING_802_1X_CK_SCHEME_PATH scheme.
- *
- * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful
- **/
-gboolean
-nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
- const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error)
-{
- NMSetting8021xPrivate *priv;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GByteArray *data;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
-
- if (cert_path) {
- g_return_val_if_fail (g_utf8_validate (cert_path, -1, NULL), FALSE);
- g_return_val_if_fail ( scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB
- || scheme == NM_SETTING_802_1X_CK_SCHEME_PATH,
- FALSE);
- }
-
- if (out_format)
- g_return_val_if_fail (*out_format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- /* Clear out any previous ca_cert blob */
- if (priv->phase2_ca_cert) {
- g_byte_array_free (priv->phase2_ca_cert, TRUE);
- priv->phase2_ca_cert = NULL;
- }
-
- if (!cert_path) {
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CA_CERT);
- return TRUE;
- }
-
- data = load_and_verify_certificate (cert_path, scheme, &format, error);
- if (data) {
- /* wpa_supplicant can only use raw x509 CA certs */
- if (format == NM_CRYPTO_FILE_FORMAT_X509) {
- if (out_format)
- *out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
-
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
- priv->phase2_ca_cert = g_byte_array_ref (data);
- else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
- priv->phase2_ca_cert = path_to_scheme_value (cert_path);
- else
- g_assert_not_reached ();
- } else {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("invalid certificate format"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CA_CERT);
- }
- g_byte_array_unref (data);
- }
-
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CA_CERT);
- return priv->phase2_ca_cert != NULL;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_subject_match:
- * @setting: the #NMSetting8021x
- *
- * Returns: the #NMSetting8021x:phase2-subject-match property. This is
- * the substring to be matched against the subject of the "phase 2"
- * authentication server certificate, or %NULL no subject verification
- * is to be performed.
- **/
-const char *
-nm_setting_802_1x_get_phase2_subject_match (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_subject_match;
-}
-
-/**
- * nm_setting_802_1x_get_num_phase2_altsubject_matches:
- * @setting: the #NMSetting8021x
- *
- * Returns the number of entries in the
- * #NMSetting8021x:phase2-altsubject-matches property of this setting.
- *
- * Returns: the number of phase2-altsubject-matches entries.
- **/
-guint32
-nm_setting_802_1x_get_num_phase2_altsubject_matches (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), 0);
-
- return g_slist_length (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_altsubject_matches);
-}
-
-/**
- * nm_setting_802_1x_get_phase2_altsubject_match:
- * @setting: the #NMSettingConnection
- * @i: the zero-based index of the array of "phase 2" altSubjectName matches
- *
- * Returns the "phase 2" altSubjectName match at index @i.
- *
- * Returns: the "phase 2" altSubjectName match at index @i
- **/
-const char *
-nm_setting_802_1x_get_phase2_altsubject_match (NMSetting8021x *setting, guint32 i)
-{
- NMSetting8021xPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->phase2_altsubject_matches), NULL);
-
- return (const char *) g_slist_nth_data (priv->phase2_altsubject_matches, i);
-}
-
-/**
- * nm_setting_802_1x_add_phase2_altsubject_match:
- * @setting: the #NMSetting8021x
- * @phase2_altsubject_match: the "phase 2" altSubjectName to allow for this
- * connection
- *
- * Adds an allowed alternate subject name match for "phase 2". Until
- * at least one match is added, the altSubjectName of the "phase 2"
- * remote authentication server is not verified.
- *
- * Returns: %TRUE if the "phase 2" alternative subject name match was
- * successfully added, %FALSE if it was already allowed.
- **/
-gboolean
-nm_setting_802_1x_add_phase2_altsubject_match (NMSetting8021x *setting,
- const char *phase2_altsubject_match)
-{
- NMSetting8021xPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
- g_return_val_if_fail (phase2_altsubject_match != NULL, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- for (iter = priv->phase2_altsubject_matches; iter; iter = g_slist_next (iter)) {
- if (!strcmp (phase2_altsubject_match, (char *) iter->data))
- return FALSE;
- }
-
- priv->phase2_altsubject_matches = g_slist_append (priv->phase2_altsubject_matches,
- g_strdup (phase2_altsubject_match));
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES);
- return TRUE;
-}
-
-/**
- * nm_setting_802_1x_remove_phase2_altsubject_match:
- * @setting: the #NMSetting8021x
- * @i: the index of the "phase 2" altSubjectName match to remove
- *
- * Removes the allowed "phase 2" altSubjectName at the specified index.
- **/
-void
-nm_setting_802_1x_remove_phase2_altsubject_match (NMSetting8021x *setting, guint32 i)
-{
- NMSetting8021xPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_802_1X (setting));
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->phase2_altsubject_matches, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->phase2_altsubject_matches = g_slist_delete_link (priv->phase2_altsubject_matches, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES);
-}
-
-/**
- * nm_setting_802_1x_remove_phase2_altsubject_match_by_value:
- * @setting: the #NMSetting8021x
- * @phase2_altsubject_match: the "phase 2" altSubjectName to remove
- *
- * Removes the allowed "phase 2" altSubjectName @phase2_altsubject_match.
- *
- * Returns: %TRUE if the alternative subject name match for "phase 2" was found and removed,
- * %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_802_1x_remove_phase2_altsubject_match_by_value (NMSetting8021x *setting,
- const char *phase2_altsubject_match)
-{
- NMSetting8021xPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
- g_return_val_if_fail (phase2_altsubject_match != NULL, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- for (iter = priv->phase2_altsubject_matches; iter; iter = g_slist_next (iter)) {
- if (!strcmp (phase2_altsubject_match, (char *) iter->data)) {
- priv->phase2_altsubject_matches = g_slist_delete_link (priv->phase2_altsubject_matches, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_802_1x_clear_phase2_altsubject_matches:
- * @setting: the #NMSetting8021x
- *
- * Clears all "phase 2" altSubjectName matches.
- **/
-void
-nm_setting_802_1x_clear_phase2_altsubject_matches (NMSetting8021x *setting)
-{
- NMSetting8021xPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_802_1X (setting));
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- g_slist_free_full (priv->phase2_altsubject_matches, g_free);
- priv->phase2_altsubject_matches = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES);
-}
-
-/**
- * nm_setting_802_1x_get_phase2_client_cert_scheme:
- * @setting: the #NMSetting8021x
- *
- * Returns the scheme used to store the "phase 2" client certificate. If the
- * returned scheme is %NM_SETTING_802_1X_CK_SCHEME_BLOB, use
- * nm_setting_802_1x_get_client_cert_blob(); if
- * %NM_SETTING_802_1X_CK_SCHEME_PATH, use
- * nm_setting_802_1x_get_client_cert_path().
- *
- * Returns: scheme used to store the "phase 2" client certificate (blob or path)
- **/
-NMSetting8021xCKScheme
-nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_802_1X_CK_SCHEME_UNKNOWN);
-
- return get_cert_scheme (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_client_cert);
-}
-
-/**
- * nm_setting_802_1x_get_phase2_client_cert_blob:
- * @setting: the #NMSetting8021x
- *
- * Client certificates are used to identify the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * Returns: the "phase 2" client certificate data
- **/
-const GByteArray *
-nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB, NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_client_cert;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_client_cert_path:
- * @setting: the #NMSetting8021x
- *
- * Client certificates are used to identify the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * Returns: path to the "phase 2" client certificate file
- **/
-const char *
-nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
-
- return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_client_cert->data + strlen (SCHEME_PATH));
-}
-
-/**
- * nm_setting_802_1x_set_phase2_client_cert:
- * @setting: the #NMSetting8021x
- * @cert_path: when @scheme is set to either %NM_SETTING_802_1X_CK_SCHEME_PATH
- * or %NM_SETTING_802_1X_CK_SCHEME_BLOB, pass the path of the "phase2" client
- * certificate file (PEM, DER, or PKCS#<!-- -->12 format). The path must be UTF-8
- * encoded; use g_filename_to_utf8() to convert if needed. Passing %NULL with
- * any @scheme clears the "phase2" client certificate.
- * @scheme: desired storage scheme for the certificate
- * @out_format: on successful return, the type of the certificate added
- * @error: on unsuccessful return, an error
- *
- * Reads a certificate from disk and sets the #NMSetting8021x:phase2-client-cert
- * property with the raw certificate data if using the
- * %NM_SETTING_802_1X_CK_SCHEME_BLOB scheme, or with the path to the certificate
- * file if using the %NM_SETTING_802_1X_CK_SCHEME_PATH scheme.
- *
- * Client certificates are used to identify the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful
- **/
-gboolean
-nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
- const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error)
-{
- NMSetting8021xPrivate *priv;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GByteArray *data;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
-
- if (cert_path) {
- g_return_val_if_fail (g_utf8_validate (cert_path, -1, NULL), FALSE);
- g_return_val_if_fail ( scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB
- || scheme == NM_SETTING_802_1X_CK_SCHEME_PATH,
- FALSE);
- }
-
- if (out_format)
- g_return_val_if_fail (*out_format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, FALSE);
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- /* Clear out any previous ca_cert blob */
- if (priv->phase2_client_cert) {
- g_byte_array_free (priv->phase2_client_cert, TRUE);
- priv->phase2_client_cert = NULL;
- }
-
- if (!cert_path) {
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
- return TRUE;
- }
-
- data = load_and_verify_certificate (cert_path, scheme, &format, error);
- if (data) {
- gboolean valid = FALSE;
-
- /* wpa_supplicant can only use raw x509 CA certs */
- switch (format) {
- case NM_CRYPTO_FILE_FORMAT_X509:
- if (out_format)
- *out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
- valid = TRUE;
- break;
- case NM_CRYPTO_FILE_FORMAT_PKCS12:
- if (out_format)
- *out_format = NM_SETTING_802_1X_CK_FORMAT_PKCS12;
- valid = TRUE;
- break;
- default:
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("invalid certificate format"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
- break;
- }
-
- if (valid) {
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
- priv->phase2_client_cert = g_byte_array_ref (data);
- else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
- priv->phase2_client_cert = path_to_scheme_value (cert_path);
- else
- g_assert_not_reached ();
- }
- g_byte_array_unref (data);
- }
-
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
- return priv->phase2_client_cert != NULL;
-}
-
-/**
- * nm_setting_802_1x_get_password:
- * @setting: the #NMSetting8021x
- *
- * Returns: the password used by the authentication method, if any, as specified
- * by the #NMSetting8021x:password property
- **/
-const char *
-nm_setting_802_1x_get_password (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->password;
-}
-
-/**
- * nm_setting_802_1x_get_password_flags:
- * @setting: the #NMSetting8021x
- *
- * Returns: the #NMSettingSecretFlags pertaining to the #NMSetting8021x:password
- **/
-NMSettingSecretFlags
-nm_setting_802_1x_get_password_flags (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->password_flags;
-}
-
-/**
- * nm_setting_802_1x_get_password_raw:
- * @setting: the #NMSetting8021x
- *
- * Returns: the password used by the authentication method as a
- * UTF-8-encoded array of bytes, as specified by the
- * #NMSetting8021x:password-raw property
- **/
-const GByteArray *
-nm_setting_802_1x_get_password_raw (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->password_raw;
-}
-
-/**
- * nm_setting_802_1x_get_password_raw_flags:
- * @setting: the #NMSetting8021x
- *
- * Returns: the #NMSettingSecretFlags pertaining to the
- * #NMSetting8021x:password-raw
- **/
-NMSettingSecretFlags
-nm_setting_802_1x_get_password_raw_flags (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->password_raw_flags;
-}
-
-/**
- * nm_setting_802_1x_get_pin:
- * @setting: the #NMSetting8021x
- *
- * Returns: the PIN used by the authentication method, if any, as specified
- * by the #NMSetting8021x:pin property
- **/
-const char *
-nm_setting_802_1x_get_pin (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->pin;
-}
-
-/**
- * nm_setting_802_1x_get_pin_flags:
- * @setting: the #NMSetting8021x
- *
- * Returns: the #NMSettingSecretFlags pertaining to the
- * #NMSetting8021x:pin
- **/
-NMSettingSecretFlags
-nm_setting_802_1x_get_pin_flags (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->pin_flags;
-}
-
-/**
- * nm_setting_802_1x_get_private_key_scheme:
- * @setting: the #NMSetting8021x
- *
- * Returns the scheme used to store the private key. If the returned scheme is
- * %NM_SETTING_802_1X_CK_SCHEME_BLOB, use
- * nm_setting_802_1x_get_client_cert_blob(); if
- * %NM_SETTING_802_1X_CK_SCHEME_PATH, use
- * nm_setting_802_1x_get_client_cert_path().
- *
- * Returns: scheme used to store the private key (blob or path)
- **/
-NMSetting8021xCKScheme
-nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_802_1X_CK_SCHEME_UNKNOWN);
-
- return get_cert_scheme (NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key);
-}
-
-/**
- * nm_setting_802_1x_get_private_key_blob:
- * @setting: the #NMSetting8021x
- *
- * Private keys are used to authenticate the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * WARNING: the private key property is not a "secret" property, and thus
- * unencrypted private key data may be readable by unprivileged users. Private
- * keys should always be encrypted with a private key password.
- *
- * Returns: the private key data
- **/
-const GByteArray *
-nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_private_key_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB, NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key;
-}
-
-/**
- * nm_setting_802_1x_get_private_key_path:
- * @setting: the #NMSetting8021x
- *
- * Private keys are used to authenticate the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * Returns: path to the private key file
- **/
-const char *
-nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_private_key_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
-
- return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key->data + strlen (SCHEME_PATH));
-}
-
-static GByteArray *
-file_to_byte_array (const char *filename)
-{
- char *contents;
- GByteArray *array = NULL;
- gsize length = 0;
-
- if (g_file_get_contents (filename, &contents, &length, NULL)) {
- array = g_byte_array_sized_new (length);
- g_byte_array_append (array, (guint8 *) contents, length);
- g_assert (array->len == length);
- g_free (contents);
- }
- return array;
-}
-
-/**
- * nm_setting_802_1x_set_private_key:
- * @setting: the #NMSetting8021x
- * @key_path: when @scheme is set to either %NM_SETTING_802_1X_CK_SCHEME_PATH or
- * %NM_SETTING_802_1X_CK_SCHEME_BLOB, pass the path of the private key file
- * (PEM, DER, or PKCS#<!-- -->12 format). The path must be UTF-8 encoded; use
- * g_filename_to_utf8() to convert if needed. Passing %NULL with any @scheme
- * clears the private key.
- * @password: password used to decrypt the private key, or %NULL if the password
- * is unknown. If the password is given but fails to decrypt the private key,
- * an error is returned.
- * @scheme: desired storage scheme for the private key
- * @out_format: on successful return, the type of the private key added
- * @error: on unsuccessful return, an error
- *
- * Private keys are used to authenticate the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * This function reads a private key from disk and sets the
- * #NMSetting8021x:private-key property with the private key file data if using
- * the %NM_SETTING_802_1X_CK_SCHEME_BLOB scheme, or with the path to the private
- * key file if using the %NM_SETTING_802_1X_CK_SCHEME_PATH scheme.
- *
- * If @password is given, this function attempts to decrypt the private key to
- * verify that @password is correct, and if it is, updates the
- * #NMSetting8021x:private-key-password property with the given @password. If
- * the decryption is unsuccessful, %FALSE is returned, @error is set, and no
- * internal data is changed. If no @password is given, the private key is
- * assumed to be valid, no decryption is performed, and the password may be set
- * at a later time.
- *
- * WARNING: the private key property is not a "secret" property, and thus
- * unencrypted private key data using the BLOB scheme may be readable by
- * unprivileged users. Private keys should always be encrypted with a private
- * key password to prevent unauthorized access to unencrypted private key data.
- *
- * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful
- **/
-gboolean
-nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
- const char *key_path,
- const char *password,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error)
-{
- NMSetting8021xPrivate *priv;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- gboolean key_cleared = FALSE, password_cleared = FALSE;
- GError *local_err = NULL;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
-
- if (key_path) {
- g_return_val_if_fail (g_utf8_validate (key_path, -1, NULL), FALSE);
- g_return_val_if_fail ( scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB
- || scheme == NM_SETTING_802_1X_CK_SCHEME_PATH,
- FALSE);
- }
-
- if (out_format)
- g_return_val_if_fail (*out_format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, FALSE);
-
- /* Ensure the private key is a recognized format and if the password was
- * given, that it decrypts the private key.
- */
- if (key_path) {
- format = crypto_verify_private_key (key_path, password, &local_err);
- if (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- local_err ? local_err->message : _("invalid private key"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY);
- g_clear_error (&local_err);
- return FALSE;
- }
- }
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- /* Clear out any previous private key data */
- if (priv->private_key) {
- /* Try not to leave the private key around in memory */
- memset (priv->private_key->data, 0, priv->private_key->len);
- g_byte_array_free (priv->private_key, TRUE);
- priv->private_key = NULL;
- key_cleared = TRUE;
- }
-
- if (priv->private_key_password) {
- g_free (priv->private_key_password);
- priv->private_key_password = NULL;
- password_cleared = TRUE;
- }
-
- if (key_path == NULL) {
- if (key_cleared)
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PRIVATE_KEY);
- if (password_cleared)
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
- return TRUE;
- }
-
- priv->private_key_password = g_strdup (password);
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
- /* Shouldn't fail this since we just verified the private key above */
- priv->private_key = file_to_byte_array (key_path);
- g_assert (priv->private_key);
- } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
- priv->private_key = path_to_scheme_value (key_path);
- else
- g_assert_not_reached ();
-
- /* As required by NM and wpa_supplicant, set the client-cert
- * property to the same PKCS#12 data.
- */
- g_assert (format != NM_CRYPTO_FILE_FORMAT_UNKNOWN);
- if (format == NM_CRYPTO_FILE_FORMAT_PKCS12) {
- if (priv->client_cert)
- g_byte_array_free (priv->client_cert, TRUE);
-
- priv->client_cert = g_byte_array_sized_new (priv->private_key->len);
- g_byte_array_append (priv->client_cert, priv->private_key->data, priv->private_key->len);
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
- }
-
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PRIVATE_KEY);
- if (password_cleared || password)
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
-
- if (out_format)
- *out_format = (NMSetting8021xCKFormat) format;
- return priv->private_key != NULL;
-}
-
-/**
- * nm_setting_802_1x_get_private_key_password:
- * @setting: the #NMSetting8021x
- *
- * Returns: the private key password used to decrypt the private key if
- * previously set with nm_setting_802_1x_set_private_key(), or the
- * #NMSetting8021x:private-key-password property.
- **/
-const char *
-nm_setting_802_1x_get_private_key_password (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key_password;
-}
-
-/**
- * nm_setting_802_1x_get_private_key_password_flags:
- * @setting: the #NMSetting8021x
- *
- * Returns: the #NMSettingSecretFlags pertaining to the
- * #NMSetting8021x:private-key-password
- **/
-NMSettingSecretFlags
-nm_setting_802_1x_get_private_key_password_flags (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key_password_flags;
-}
-
-/**
- * nm_setting_802_1x_get_private_key_format:
- * @setting: the #NMSetting8021x
- *
- * Returns: the data format of the private key data stored in the
- * #NMSetting8021x:private-key property
- **/
-NMSetting8021xCKFormat
-nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting)
-{
- NMSetting8021xPrivate *priv;
- const char *path;
- GError *error = NULL;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- if (!priv->private_key)
- return NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
-
- switch (nm_setting_802_1x_get_private_key_scheme (setting)) {
- case NM_SETTING_802_1X_CK_SCHEME_BLOB:
- if (crypto_is_pkcs12_data (priv->private_key))
- return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
- return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
- case NM_SETTING_802_1X_CK_SCHEME_PATH:
- path = nm_setting_802_1x_get_private_key_path (setting);
- if (crypto_is_pkcs12_file (path, &error))
- return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
- if (error) {
- /* Couldn't read the file or something */
- g_error_free (error);
- return NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- }
- return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
- default:
- break;
- }
-
- return NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_private_key_password:
- * @setting: the #NMSetting8021x
- *
- * Returns: the private key password used to decrypt the private key if
- * previously set with nm_setting_802_1x_set_phase2_private_key() or the
- * #NMSetting8021x:phase2-private-key-password property.
- **/
-const char *
-nm_setting_802_1x_get_phase2_private_key_password (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key_password;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_private_key_password_flags:
- * @setting: the #NMSetting8021x
- *
- * Returns: the #NMSettingSecretFlags pertaining to the
- * #NMSetting8021x:phase2-private-key-password
- **/
-NMSettingSecretFlags
-nm_setting_802_1x_get_phase2_private_key_password_flags (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key_password_flags;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_private_key_scheme:
- * @setting: the #NMSetting8021x
- *
- * Returns the scheme used to store the "phase 2" private key. If the returned
- * scheme is %NM_SETTING_802_1X_CK_SCHEME_BLOB, use
- * nm_setting_802_1x_get_client_cert_blob(); if
- * %NM_SETTING_802_1X_CK_SCHEME_PATH, use
- * nm_setting_802_1x_get_client_cert_path().
- *
- * Returns: scheme used to store the "phase 2" private key (blob or path)
- **/
-NMSetting8021xCKScheme
-nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_802_1X_CK_SCHEME_UNKNOWN);
-
- return get_cert_scheme (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key);
-}
-
-/**
- * nm_setting_802_1x_get_phase2_private_key_blob:
- * @setting: the #NMSetting8021x
- *
- * Private keys are used to authenticate the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * WARNING: the phase2 private key property is not a "secret" property, and thus
- * unencrypted private key data may be readable by unprivileged users. Private
- * keys should always be encrypted with a private key password.
- *
- * Returns: the "phase 2" private key data
- **/
-const GByteArray *
-nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_phase2_private_key_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB, NULL);
-
- return NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_private_key_path:
- * @setting: the #NMSetting8021x
- *
- * Private keys are used to authenticate the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * Returns: path to the "phase 2" private key file
- **/
-const char *
-nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting)
-{
- NMSetting8021xCKScheme scheme;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
-
- scheme = nm_setting_802_1x_get_phase2_private_key_scheme (setting);
- g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
-
- return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key->data + strlen (SCHEME_PATH));
-}
-
-/**
- * nm_setting_802_1x_set_phase2_private_key:
- * @setting: the #NMSetting8021x
- * @key_path: when @scheme is set to either %NM_SETTING_802_1X_CK_SCHEME_PATH or
- * %NM_SETTING_802_1X_CK_SCHEME_BLOB, pass the path of the "phase2" private
- * key file (PEM, DER, or PKCS#<!-- -->12 format). The path must be UTF-8 encoded;
- * use g_filename_to_utf8() to convert if needed. Passing %NULL with any
- * @scheme clears the private key.
- * @password: password used to decrypt the private key, or %NULL if the password
- * is unknown. If the password is given but fails to decrypt the private key,
- * an error is returned.
- * @scheme: desired storage scheme for the private key
- * @out_format: on successful return, the type of the private key added
- * @error: on unsuccessful return, an error
- *
- * Private keys are used to authenticate the connecting client to the network
- * when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
- * authentication method.
- *
- * This function reads a private key from disk and sets the
- * #NMSetting8021x:phase2-private-key property with the private key file data if
- * using the %NM_SETTING_802_1X_CK_SCHEME_BLOB scheme, or with the path to the
- * private key file if using the %NM_SETTING_802_1X_CK_SCHEME_PATH scheme.
- *
- * If @password is given, this function attempts to decrypt the private key to
- * verify that @password is correct, and if it is, updates the
- * #NMSetting8021x:phase2-private-key-password property with the given
- * @password. If the decryption is unsuccessful, %FALSE is returned, @error is
- * set, and no internal data is changed. If no @password is given, the private
- * key is assumed to be valid, no decryption is performed, and the password may
- * be set at a later time.
- *
- * WARNING: the "phase2" private key property is not a "secret" property, and
- * thus unencrypted private key data using the BLOB scheme may be readable by
- * unprivileged users. Private keys should always be encrypted with a private
- * key password to prevent unauthorized access to unencrypted private key data.
- *
- * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful
- **/
-gboolean
-nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
- const char *key_path,
- const char *password,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error)
-{
- NMSetting8021xPrivate *priv;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- gboolean key_cleared = FALSE, password_cleared = FALSE;
- GError *local_err = NULL;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), FALSE);
-
- if (key_path) {
- g_return_val_if_fail (g_utf8_validate (key_path, -1, NULL), FALSE);
- g_return_val_if_fail ( scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB
- || scheme == NM_SETTING_802_1X_CK_SCHEME_PATH,
- FALSE);
- }
-
- if (out_format)
- g_return_val_if_fail (*out_format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, FALSE);
-
- /* Ensure the private key is a recognized format and if the password was
- * given, that it decrypts the private key.
- */
- if (key_path) {
- format = crypto_verify_private_key (key_path, password, &local_err);
- if (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- local_err ? local_err->message : _("invalid phase2 private key"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
- g_clear_error (&local_err);
- return FALSE;
- }
- }
-
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- /* Clear out any previous private key data */
- if (priv->phase2_private_key) {
- /* Try not to leave the private key around in memory */
- memset (priv->phase2_private_key->data, 0, priv->phase2_private_key->len);
- g_byte_array_free (priv->phase2_private_key, TRUE);
- priv->phase2_private_key = NULL;
- key_cleared = TRUE;
- }
-
- if (priv->phase2_private_key_password) {
- g_free (priv->phase2_private_key_password);
- priv->phase2_private_key_password = NULL;
- password_cleared = TRUE;
- }
-
- if (key_path == NULL) {
- if (key_cleared)
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
- if (password_cleared)
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
- return TRUE;
- }
-
- priv->phase2_private_key_password = g_strdup (password);
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
- /* Shouldn't fail this since we just verified the private key above */
- priv->phase2_private_key = file_to_byte_array (key_path);
- g_assert (priv->phase2_private_key);
- } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
- priv->phase2_private_key = path_to_scheme_value (key_path);
- else
- g_assert_not_reached ();
-
- /* As required by NM and wpa_supplicant, set the client-cert
- * property to the same PKCS#12 data.
- */
- g_assert (format != NM_CRYPTO_FILE_FORMAT_UNKNOWN);
- if (format == NM_CRYPTO_FILE_FORMAT_PKCS12) {
- if (priv->phase2_client_cert)
- g_byte_array_free (priv->phase2_client_cert, TRUE);
-
- priv->phase2_client_cert = g_byte_array_sized_new (priv->phase2_private_key->len);
- g_byte_array_append (priv->phase2_client_cert, priv->phase2_private_key->data, priv->phase2_private_key->len);
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
- }
-
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
- if (password_cleared || password)
- g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
-
- if (out_format)
- *out_format = (NMSetting8021xCKFormat) format;
- return priv->phase2_private_key != NULL;
-}
-
-/**
- * nm_setting_802_1x_get_phase2_private_key_format:
- * @setting: the #NMSetting8021x
- *
- * Returns: the data format of the "phase 2" private key data stored in the
- * #NMSetting8021x:phase2-private-key property
- **/
-NMSetting8021xCKFormat
-nm_setting_802_1x_get_phase2_private_key_format (NMSetting8021x *setting)
-{
- NMSetting8021xPrivate *priv;
- const char *path;
- GError *error = NULL;
-
- g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
- priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- if (!priv->phase2_private_key)
- return NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
-
- switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) {
- case NM_SETTING_802_1X_CK_SCHEME_BLOB:
- if (crypto_is_pkcs12_data (priv->phase2_private_key))
- return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
- return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
- case NM_SETTING_802_1X_CK_SCHEME_PATH:
- path = nm_setting_802_1x_get_phase2_private_key_path (setting);
- if (crypto_is_pkcs12_file (path, &error))
- return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
- if (error) {
- /* Couldn't read the file or something */
- g_error_free (error);
- return NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- }
- return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
- default:
- break;
- }
-
- return NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
-}
-
-static void
-need_secrets_password (NMSetting8021x *self,
- GPtrArray *secrets,
- gboolean phase2)
-{
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
-
- if ( (!priv->password || !strlen (priv->password))
- && (!priv->password_raw || !priv->password_raw->len)) {
- g_ptr_array_add (secrets, NM_SETTING_802_1X_PASSWORD);
- g_ptr_array_add (secrets, NM_SETTING_802_1X_PASSWORD_RAW);
- }
-}
-
-static void
-need_secrets_sim (NMSetting8021x *self,
- GPtrArray *secrets,
- gboolean phase2)
-{
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
-
- if (!priv->pin || !strlen (priv->pin))
- g_ptr_array_add (secrets, NM_SETTING_802_1X_PIN);
-}
-
-static gboolean
-need_private_key_password (const GByteArray *blob,
- const char *path,
- const char *password)
-{
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
-
- /* Private key password is required */
- if (password) {
- if (path)
- format = crypto_verify_private_key (path, password, NULL);
- else if (blob)
- format = crypto_verify_private_key_data (blob, password, NULL);
- else
- g_warning ("%s: unknown private key password scheme", __func__);
- }
-
- return (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN);
-}
-
-static void
-need_secrets_tls (NMSetting8021x *self,
- GPtrArray *secrets,
- gboolean phase2)
-{
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
- NMSetting8021xCKScheme scheme;
- const GByteArray *blob = NULL;
- const char *path = NULL;
-
- if (phase2) {
- scheme = nm_setting_802_1x_get_phase2_private_key_scheme (self);
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
- path = nm_setting_802_1x_get_phase2_private_key_path (self);
- else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
- blob = nm_setting_802_1x_get_phase2_private_key_blob (self);
- else {
- g_warning ("%s: unknown phase2 private key scheme %d", __func__, scheme);
- g_ptr_array_add (secrets, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
- return;
- }
-
- if (need_private_key_password (blob, path, priv->phase2_private_key_password))
- g_ptr_array_add (secrets, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
- } else {
- scheme = nm_setting_802_1x_get_private_key_scheme (self);
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
- path = nm_setting_802_1x_get_private_key_path (self);
- else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
- blob = nm_setting_802_1x_get_private_key_blob (self);
- else {
- g_warning ("%s: unknown private key scheme %d", __func__, scheme);
- g_ptr_array_add (secrets, NM_SETTING_802_1X_PRIVATE_KEY);
- return;
- }
-
- if (need_private_key_password (blob, path, priv->private_key_password))
- g_ptr_array_add (secrets, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
- }
-}
-
-static gboolean
-verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
-{
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
-
- if (phase2) {
- if (!priv->phase2_client_cert) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
- return FALSE;
- } else if (!priv->phase2_client_cert->len) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
- return FALSE;
- }
-
- /* Private key is required for TLS */
- if (!priv->phase2_private_key) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
- return FALSE;
- } else if (!priv->phase2_private_key->len) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
- return FALSE;
- }
-
- /* If the private key is PKCS#12, check that it matches the client cert */
- if (crypto_is_pkcs12_data (priv->phase2_private_key)) {
- if (priv->phase2_private_key->len != priv->phase2_client_cert->len) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("has to match '%s' property for PKCS#12"),
- NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
- return FALSE;
- }
-
- if (memcmp (priv->phase2_private_key->data,
- priv->phase2_client_cert->data,
- priv->phase2_private_key->len)) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("has to match '%s' property for PKCS#12"),
- NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
- return FALSE;
- }
- }
- } else {
- if (!priv->client_cert) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
- return FALSE;
- } else if (!priv->client_cert->len) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
- return FALSE;
- }
-
- /* Private key is required for TLS */
- if (!priv->private_key) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY);
- return FALSE;
- } else if (!priv->private_key->len) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY);
- return FALSE;
- }
-
- /* If the private key is PKCS#12, check that it matches the client cert */
- if (crypto_is_pkcs12_data (priv->private_key)) {
- if (priv->private_key->len != priv->client_cert->len) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("has to match '%s' property for PKCS#12"),
- NM_SETTING_802_1X_PRIVATE_KEY);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
- return FALSE;
- }
-
- if (memcmp (priv->private_key->data,
- priv->client_cert->data,
- priv->private_key->len)) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("has to match '%s' property for PKCS#12"),
- NM_SETTING_802_1X_PRIVATE_KEY);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
- return FALSE;
- }
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-verify_ttls (NMSetting8021x *self, gboolean phase2, GError **error)
-{
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
-
- if ( (!priv->identity || !strlen (priv->identity))
- && (!priv->anonymous_identity || !strlen (priv->anonymous_identity))) {
- if (!priv->identity) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY);
- } else if (!strlen (priv->identity)) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY);
- } else if (!priv->anonymous_identity) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_ANONYMOUS_IDENTITY);
- } else {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_ANONYMOUS_IDENTITY);
- }
- return FALSE;
- }
-
- if ( (!priv->phase2_auth || !strlen (priv->phase2_auth))
- && (!priv->phase2_autheap || !strlen (priv->phase2_autheap))) {
- if (!priv->phase2_auth) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTH);
- } else if (!strlen (priv->phase2_auth)) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTH);
- } else if (!priv->phase2_autheap) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTHEAP);
- } else {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTHEAP);
- }
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-verify_identity (NMSetting8021x *self, gboolean phase2, GError **error)
-{
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
-
- if (!priv->identity) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY);
- return FALSE;
- } else if (!strlen (priv->identity)) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Implemented below... */
-static void need_secrets_phase2 (NMSetting8021x *self,
- GPtrArray *secrets,
- gboolean phase2);
-
-typedef void (*EAPMethodNeedSecretsFunc) (NMSetting8021x *self,
- GPtrArray *secrets,
- gboolean phase2);
-
-typedef gboolean (*EAPMethodValidateFunc)(NMSetting8021x *self,
- gboolean phase2,
- GError **error);
-
-typedef struct {
- const char *method;
- EAPMethodNeedSecretsFunc ns_func;
- EAPMethodValidateFunc v_func;
-} EAPMethodsTable;
-
-static EAPMethodsTable eap_methods_table[] = {
- { "leap", need_secrets_password, verify_identity },
- { "pwd", need_secrets_password, verify_identity },
- { "md5", need_secrets_password, verify_identity },
- { "pap", need_secrets_password, verify_identity },
- { "chap", need_secrets_password, verify_identity },
- { "mschap", need_secrets_password, verify_identity },
- { "mschapv2", need_secrets_password, verify_identity },
- { "fast", need_secrets_password, verify_identity },
- { "tls", need_secrets_tls, verify_tls },
- { "peap", need_secrets_phase2, verify_ttls },
- { "ttls", need_secrets_phase2, verify_ttls },
- { "sim", need_secrets_sim, NULL },
- { "gtc", need_secrets_password, verify_identity },
- { "otp", NULL, NULL }, // FIXME: implement
- { NULL, NULL, NULL }
-};
-
-static void
-need_secrets_phase2 (NMSetting8021x *self,
- GPtrArray *secrets,
- gboolean phase2)
-{
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
- char *method = NULL;
- int i;
-
- g_return_if_fail (phase2 == FALSE);
-
- /* Check phase2_auth and phase2_autheap */
- method = priv->phase2_auth;
- if (!method && priv->phase2_autheap)
- method = priv->phase2_autheap;
-
- if (!method) {
- g_warning ("Couldn't find EAP method.");
- g_assert_not_reached();
- return;
- }
-
- /* Ask the configured phase2 method if it needs secrets */
- for (i = 0; eap_methods_table[i].method; i++) {
- if (eap_methods_table[i].ns_func == NULL)
- continue;
- if (!strcmp (eap_methods_table[i].method, method)) {
- (*eap_methods_table[i].ns_func) (self, secrets, TRUE);
- break;
- }
- }
-}
-
-static GPtrArray *
-need_secrets (NMSetting *setting)
-{
- NMSetting8021x *self = NM_SETTING_802_1X (setting);
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
- GSList *iter;
- GPtrArray *secrets;
- gboolean eap_method_found = FALSE;
-
- secrets = g_ptr_array_sized_new (4);
-
- /* Ask each configured EAP method if it needs secrets */
- for (iter = priv->eap; iter && !eap_method_found; iter = g_slist_next (iter)) {
- const char *method = (const char *) iter->data;
- int i;
-
- for (i = 0; eap_methods_table[i].method; i++) {
- if (eap_methods_table[i].ns_func == NULL)
- continue;
- if (!strcmp (eap_methods_table[i].method, method)) {
- (*eap_methods_table[i].ns_func) (self, secrets, FALSE);
-
- /* Only break out of the outer loop if this EAP method
- * needed secrets.
- */
- if (secrets->len > 0)
- eap_method_found = TRUE;
- break;
- }
- }
- }
-
- if (secrets->len == 0) {
- g_ptr_array_free (secrets, TRUE);
- secrets = NULL;
- }
-
- return secrets;
-}
-
-static gboolean
-verify_cert (GByteArray *array, const char *prop_name, GError **error)
-{
- if ( !array
- || get_cert_scheme (array) != NM_SETTING_802_1X_CK_SCHEME_UNKNOWN)
- return TRUE;
-
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, prop_name);
- return FALSE;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSetting8021x *self = NM_SETTING_802_1X (setting);
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
- const char *valid_eap[] = { "leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd", NULL };
- const char *valid_phase1_peapver[] = { "0", "1", NULL };
- const char *valid_phase1_peaplabel[] = { "0", "1", NULL };
- const char *valid_phase1_fast_pac[] = { "0", "1", "2", "3", NULL };
- const char *valid_phase2_auth[] = { "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", "tls", NULL };
- const char *valid_phase2_autheap[] = { "md5", "mschapv2", "otp", "gtc", "tls", NULL };
- GSList *iter;
-
- if (error)
- g_return_val_if_fail (*error == NULL, FALSE);
-
- if (!priv->eap) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_EAP);
- return FALSE;
- }
-
- if (!_nm_utils_string_slist_validate (priv->eap, valid_eap)) {
- g_set_error_literal (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_EAP);
- return FALSE;
- }
-
- /* Ask each configured EAP method if its valid */
- for (iter = priv->eap; iter; iter = g_slist_next (iter)) {
- const char *method = (const char *) iter->data;
- int i;
-
- for (i = 0; eap_methods_table[i].method; i++) {
- if (eap_methods_table[i].v_func == NULL)
- continue;
- if (!strcmp (eap_methods_table[i].method, method)) {
- if (!(*eap_methods_table[i].v_func) (self, FALSE, error))
- return FALSE;
- break;
- }
- }
- }
-
- if (priv->phase1_peapver && !g_strv_contains (valid_phase1_peapver, priv->phase1_peapver)) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->phase1_peapver);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE1_PEAPVER);
- return FALSE;
- }
-
- if (priv->phase1_peaplabel && !g_strv_contains (valid_phase1_peaplabel, priv->phase1_peaplabel)) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->phase1_peaplabel);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE1_PEAPLABEL);
- return FALSE;
- }
-
- if (priv->phase1_fast_provisioning && !g_strv_contains (valid_phase1_fast_pac, priv->phase1_fast_provisioning)) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->phase1_fast_provisioning);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING);
- return FALSE;
- }
-
- if (priv->phase2_auth && !g_strv_contains (valid_phase2_auth, priv->phase2_auth)) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->phase2_auth);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTH);
- return FALSE;
- }
-
- if (priv->phase2_autheap && !g_strv_contains (valid_phase2_autheap, priv->phase2_autheap)) {
- g_set_error (error,
- NM_SETTING_802_1X_ERROR,
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->phase2_autheap);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTHEAP);
- return FALSE;
- }
-
- if (!verify_cert (priv->ca_cert, NM_SETTING_802_1X_CA_CERT, error))
- return FALSE;
- if (!verify_cert (priv->phase2_ca_cert, NM_SETTING_802_1X_PHASE2_CA_CERT, error))
- return FALSE;
-
- if (!verify_cert (priv->client_cert, NM_SETTING_802_1X_CLIENT_CERT, error))
- return FALSE;
- if (!verify_cert (priv->phase2_client_cert, NM_SETTING_802_1X_PHASE2_CLIENT_CERT, error))
- return FALSE;
-
- if (!verify_cert (priv->private_key, NM_SETTING_802_1X_PRIVATE_KEY, error))
- return FALSE;
- if (!verify_cert (priv->phase2_private_key, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, error))
- return FALSE;
-
- /* FIXME: finish */
-
- return TRUE;
-}
-
-static void
-nm_setting_802_1x_init (NMSetting8021x *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSetting8021x *self = NM_SETTING_802_1X (object);
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
-
- /* Strings first. g_free() already checks for NULLs so we don't have to */
-
- g_free (priv->identity);
- g_free (priv->anonymous_identity);
- g_free (priv->ca_path);
- g_free (priv->subject_match);
- g_free (priv->phase1_peapver);
- g_free (priv->phase1_peaplabel);
- g_free (priv->phase1_fast_provisioning);
- g_free (priv->phase2_auth);
- g_free (priv->phase2_autheap);
- g_free (priv->phase2_ca_path);
- g_free (priv->phase2_subject_match);
- g_free (priv->password);
- if (priv->password_raw)
- g_byte_array_free (priv->password_raw, TRUE);
- g_free (priv->pin);
-
- g_slist_free_full (priv->eap, g_free);
- g_slist_free_full (priv->altsubject_matches, g_free);
- g_slist_free_full (priv->phase2_altsubject_matches, g_free);
-
- if (priv->ca_cert)
- g_byte_array_free (priv->ca_cert, TRUE);
- if (priv->client_cert)
- g_byte_array_free (priv->client_cert, TRUE);
- if (priv->private_key)
- g_byte_array_free (priv->private_key, TRUE);
- g_free (priv->private_key_password);
- if (priv->phase2_ca_cert)
- g_byte_array_free (priv->phase2_ca_cert, TRUE);
- if (priv->phase2_client_cert)
- g_byte_array_free (priv->phase2_client_cert, TRUE);
- if (priv->phase2_private_key)
- g_byte_array_free (priv->phase2_private_key, TRUE);
- g_free (priv->phase2_private_key_password);
-
- G_OBJECT_CLASS (nm_setting_802_1x_parent_class)->finalize (object);
-}
-
-static GByteArray *
-set_cert_prop_helper (const GValue *value, const char *prop_name, GError **error)
-{
- gboolean valid;
- GByteArray *data = NULL;
-
- data = g_value_dup_boxed (value);
- /* Verify the new data */
- if (data) {
- valid = verify_cert (data, prop_name, error);
- if (!valid) {
- g_byte_array_free (data, TRUE);
- data = NULL;
- }
- }
- return data;
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSetting8021x *setting = NM_SETTING_802_1X (object);
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
- GError *error = NULL;
-
- switch (prop_id) {
- case PROP_EAP:
- g_slist_free_full (priv->eap, g_free);
- priv->eap = g_value_dup_boxed (value);
- break;
- case PROP_IDENTITY:
- g_free (priv->identity);
- priv->identity = g_value_dup_string (value);
- break;
- case PROP_ANONYMOUS_IDENTITY:
- g_free (priv->anonymous_identity);
- priv->anonymous_identity = g_value_dup_string (value);
- break;
- case PROP_PAC_FILE:
- g_free (priv->pac_file);
- priv->pac_file = g_value_dup_string (value);
- break;
- case PROP_CA_CERT:
- if (priv->ca_cert) {
- g_byte_array_free (priv->ca_cert, TRUE);
- priv->ca_cert = NULL;
- }
- priv->ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CA_CERT, &error);
- if (error) {
- g_warning ("Error setting certificate (invalid data): %s",
- error->message);
- g_error_free (error);
- }
- break;
- case PROP_CA_PATH:
- g_free (priv->ca_path);
- priv->ca_path = g_value_dup_string (value);
- break;
- case PROP_SUBJECT_MATCH:
- g_free (priv->subject_match);
- priv->subject_match = g_value_dup_string (value);
- break;
- case PROP_ALTSUBJECT_MATCHES:
- g_slist_free_full (priv->altsubject_matches, g_free);
- priv->altsubject_matches = g_value_dup_boxed (value);
- break;
- case PROP_CLIENT_CERT:
- if (priv->client_cert) {
- g_byte_array_free (priv->client_cert, TRUE);
- priv->client_cert = NULL;
- }
- priv->client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CLIENT_CERT, &error);
- if (error) {
- g_warning ("Error setting certificate (invalid data): %s",
- error->message);
- g_error_free (error);
- }
- break;
- case PROP_PHASE1_PEAPVER:
- g_free (priv->phase1_peapver);
- priv->phase1_peapver = g_value_dup_string (value);
- break;
- case PROP_PHASE1_PEAPLABEL:
- g_free (priv->phase1_peaplabel);
- priv->phase1_peaplabel = g_value_dup_string (value);
- break;
- case PROP_PHASE1_FAST_PROVISIONING:
- g_free (priv->phase1_fast_provisioning);
- priv->phase1_fast_provisioning = g_value_dup_string (value);
- break;
- case PROP_PHASE2_AUTH:
- g_free (priv->phase2_auth);
- priv->phase2_auth = g_value_dup_string (value);
- break;
- case PROP_PHASE2_AUTHEAP:
- g_free (priv->phase2_autheap);
- priv->phase2_autheap = g_value_dup_string (value);
- break;
- case PROP_PHASE2_CA_CERT:
- if (priv->phase2_ca_cert) {
- g_byte_array_free (priv->phase2_ca_cert, TRUE);
- priv->phase2_ca_cert = NULL;
- }
- priv->phase2_ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CA_CERT, &error);
- if (error) {
- g_warning ("Error setting certificate (invalid data): %s",
- error->message);
- g_error_free (error);
- }
- break;
- case PROP_PHASE2_CA_PATH:
- g_free (priv->phase2_ca_path);
- priv->phase2_ca_path = g_value_dup_string (value);
- break;
- case PROP_PHASE2_SUBJECT_MATCH:
- g_free (priv->phase2_subject_match);
- priv->phase2_subject_match = g_value_dup_string (value);
- break;
- case PROP_PHASE2_ALTSUBJECT_MATCHES:
- g_slist_free_full (priv->phase2_altsubject_matches, g_free);
- priv->phase2_altsubject_matches = g_value_dup_boxed (value);
- break;
- case PROP_PHASE2_CLIENT_CERT:
- if (priv->phase2_client_cert) {
- g_byte_array_free (priv->phase2_client_cert, TRUE);
- priv->phase2_client_cert = NULL;
- }
- priv->phase2_client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CLIENT_CERT, &error);
- if (error) {
- g_warning ("Error setting certificate (invalid data): %s",
- error->message);
- g_error_free (error);
- }
- break;
- case PROP_PASSWORD:
- g_free (priv->password);
- priv->password = g_value_dup_string (value);
- break;
- case PROP_PASSWORD_FLAGS:
- priv->password_flags = g_value_get_uint (value);
- break;
- case PROP_PASSWORD_RAW:
- if (priv->password_raw)
- g_byte_array_free (priv->password_raw, TRUE);
- priv->password_raw = g_value_dup_boxed (value);
- break;
- case PROP_PASSWORD_RAW_FLAGS:
- priv->password_raw_flags = g_value_get_uint (value);
- break;
- case PROP_PRIVATE_KEY:
- if (priv->private_key) {
- g_byte_array_free (priv->private_key, TRUE);
- priv->private_key = NULL;
- }
- priv->private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PRIVATE_KEY, &error);
- if (error) {
- g_warning ("Error setting private key (invalid data): %s",
- error->message);
- g_error_free (error);
- }
- break;
- case PROP_PRIVATE_KEY_PASSWORD:
- g_free (priv->private_key_password);
- priv->private_key_password = g_value_dup_string (value);
- break;
- case PROP_PRIVATE_KEY_PASSWORD_FLAGS:
- priv->private_key_password_flags = g_value_get_uint (value);
- break;
- case PROP_PHASE2_PRIVATE_KEY:
- if (priv->phase2_private_key) {
- g_byte_array_free (priv->phase2_private_key, TRUE);
- priv->phase2_private_key = NULL;
- }
- priv->phase2_private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &error);
- if (error) {
- g_warning ("Error setting private key (invalid data): %s",
- error->message);
- g_error_free (error);
- }
- break;
- case PROP_PHASE2_PRIVATE_KEY_PASSWORD:
- g_free (priv->phase2_private_key_password);
- priv->phase2_private_key_password = g_value_dup_string (value);
- break;
- case PROP_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS:
- priv->phase2_private_key_password_flags = g_value_get_uint (value);
- break;
- case PROP_PIN:
- g_free (priv->pin);
- priv->pin = g_value_dup_string (value);
- break;
- case PROP_PIN_FLAGS:
- priv->pin_flags = g_value_get_uint (value);
- break;
- case PROP_SYSTEM_CA_CERTS:
- priv->system_ca_certs = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSetting8021x *setting = NM_SETTING_802_1X (object);
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_EAP:
- g_value_set_boxed (value, priv->eap);
- break;
- case PROP_IDENTITY:
- g_value_set_string (value, priv->identity);
- break;
- case PROP_ANONYMOUS_IDENTITY:
- g_value_set_string (value, priv->anonymous_identity);
- break;
- case PROP_PAC_FILE:
- g_value_set_string (value, priv->pac_file);
- break;
- case PROP_CA_CERT:
- g_value_set_boxed (value, priv->ca_cert);
- break;
- case PROP_CA_PATH:
- g_value_set_string (value, priv->ca_path);
- break;
- case PROP_SUBJECT_MATCH:
- g_value_set_string (value, priv->subject_match);
- break;
- case PROP_ALTSUBJECT_MATCHES:
- g_value_set_boxed (value, priv->altsubject_matches);
- break;
- case PROP_CLIENT_CERT:
- g_value_set_boxed (value, priv->client_cert);
- break;
- case PROP_PHASE1_PEAPVER:
- g_value_set_string (value, priv->phase1_peapver);
- break;
- case PROP_PHASE1_PEAPLABEL:
- g_value_set_string (value, priv->phase1_peaplabel);
- break;
- case PROP_PHASE1_FAST_PROVISIONING:
- g_value_set_string (value, priv->phase1_fast_provisioning);
- break;
- case PROP_PHASE2_AUTH:
- g_value_set_string (value, priv->phase2_auth);
- break;
- case PROP_PHASE2_AUTHEAP:
- g_value_set_string (value, priv->phase2_autheap);
- break;
- case PROP_PHASE2_CA_CERT:
- g_value_set_boxed (value, priv->phase2_ca_cert);
- break;
- case PROP_PHASE2_CA_PATH:
- g_value_set_string (value, priv->phase2_ca_path);
- break;
- case PROP_PHASE2_SUBJECT_MATCH:
- g_value_set_string (value, priv->phase2_subject_match);
- break;
- case PROP_PHASE2_ALTSUBJECT_MATCHES:
- g_value_set_boxed (value, priv->phase2_altsubject_matches);
- break;
- case PROP_PHASE2_CLIENT_CERT:
- g_value_set_boxed (value, priv->phase2_client_cert);
- break;
- case PROP_PASSWORD:
- g_value_set_string (value, priv->password);
- break;
- case PROP_PASSWORD_FLAGS:
- g_value_set_uint (value, priv->password_flags);
- break;
- case PROP_PASSWORD_RAW:
- g_value_set_boxed (value, priv->password_raw);
- break;
- case PROP_PASSWORD_RAW_FLAGS:
- g_value_set_uint (value, priv->password_raw_flags);
- break;
- case PROP_PRIVATE_KEY:
- g_value_set_boxed (value, priv->private_key);
- break;
- case PROP_PRIVATE_KEY_PASSWORD:
- g_value_set_string (value, priv->private_key_password);
- break;
- case PROP_PRIVATE_KEY_PASSWORD_FLAGS:
- g_value_set_uint (value, priv->private_key_password_flags);
- break;
- case PROP_PHASE2_PRIVATE_KEY:
- g_value_set_boxed (value, priv->phase2_private_key);
- break;
- case PROP_PHASE2_PRIVATE_KEY_PASSWORD:
- g_value_set_string (value, priv->phase2_private_key_password);
- break;
- case PROP_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS:
- g_value_set_uint (value, priv->phase2_private_key_password_flags);
- break;
- case PROP_PIN:
- g_value_set_string (value, priv->pin);
- break;
- case PROP_PIN_FLAGS:
- g_value_set_uint (value, priv->pin_flags);
- break;
- case PROP_SYSTEM_CA_CERTS:
- g_value_set_boolean (value, priv->system_ca_certs);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
- GError *error = NULL;
-
- g_type_class_add_private (setting_class, sizeof (NMSetting8021xPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- parent_class->verify = verify;
- parent_class->need_secrets = need_secrets;
-
- /* Properties */
-
- /**
- * NMSetting8021x:eap:
- *
- * The allowed EAP method to be used when authenticating to the network with
- * 802.1x. Valid methods are: "leap", "md5", "tls", "peap", "ttls", "pwd",
- * and "fast". Each method requires different configuration using the
- * properties of this setting; refer to wpa_supplicant documentation for the
- * allowed combinations.
- **/
- g_object_class_install_property
- (object_class, PROP_EAP,
- _nm_param_spec_specialized (NM_SETTING_802_1X_EAP, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:identity:
- *
- * Identity string for EAP authentication methods. Often the user's user or
- * login name.
- **/
- g_object_class_install_property
- (object_class, PROP_IDENTITY,
- g_param_spec_string (NM_SETTING_802_1X_IDENTITY, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:anonymous-identity:
- *
- * Anonymous identity string for EAP authentication methods. Used as the
- * unencrypted identity with EAP types that support different tunneled
- * identity like EAP-TTLS.
- **/
- g_object_class_install_property
- (object_class, PROP_ANONYMOUS_IDENTITY,
- g_param_spec_string (NM_SETTING_802_1X_ANONYMOUS_IDENTITY, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:pac-file:
- *
- * UTF-8 encoded file path containing PAC for EAP-FAST.
- **/
- g_object_class_install_property
- (object_class, PROP_PAC_FILE,
- g_param_spec_string (NM_SETTING_802_1X_PAC_FILE, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:ca-cert:
- *
- * Contains the CA certificate if used by the EAP method specified in the
- * #NMSetting8021x:eap property.
- *
- * Certificate data is specified using a "scheme"; two are currently
- * supported: blob and path. When using the blob scheme (which is backwards
- * compatible with NM 0.7.x) this property should be set to the
- * certificate's DER encoded data. When using the path scheme, this property
- * should be set to the full UTF-8 encoded path of the certificate, prefixed
- * with the string "file://" and ending with a terminating NUL byte. This
- * property can be unset even if the EAP method supports CA certificates,
- * but this allows man-in-the-middle attacks and is NOT recommended.
- *
- * Setting this property directly is discouraged; use the
- * nm_setting_802_1x_set_ca_cert() function instead.
- **/
- g_object_class_install_property
- (object_class, PROP_CA_CERT,
- _nm_param_spec_specialized (NM_SETTING_802_1X_CA_CERT, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:ca-path:
- *
- * UTF-8 encoded path to a directory containing PEM or DER formatted
- * certificates to be added to the verification chain in addition to the
- * certificate specified in the #NMSetting8021x:ca-cert property.
- **/
- g_object_class_install_property
- (object_class, PROP_CA_PATH,
- g_param_spec_string (NM_SETTING_802_1X_CA_PATH, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:subject-match:
- *
- * Substring to be matched against the subject of the certificate presented
- * by the authentication server. When unset, no verification of the
- * authentication server certificate's subject is performed.
- **/
- g_object_class_install_property
- (object_class, PROP_SUBJECT_MATCH,
- g_param_spec_string (NM_SETTING_802_1X_SUBJECT_MATCH, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:altsubject-matches:
- *
- * List of strings to be matched against the altSubjectName of the
- * certificate presented by the authentication server. If the list is empty,
- * no verification of the server certificate's altSubjectName is performed.
- **/
- g_object_class_install_property
- (object_class, PROP_ALTSUBJECT_MATCHES,
- _nm_param_spec_specialized (NM_SETTING_802_1X_ALTSUBJECT_MATCHES, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:client-cert:
- *
- * Contains the client certificate if used by the EAP method specified in
- * the #NMSetting8021x:eap property.
- *
- * Certificate data is specified using a "scheme"; two are currently
- * supported: blob and path. When using the blob scheme (which is backwards
- * compatible with NM 0.7.x) this property should be set to the
- * certificate's DER encoded data. When using the path scheme, this property
- * should be set to the full UTF-8 encoded path of the certificate, prefixed
- * with the string "file://" and ending with a terminating NUL byte.
- *
- * Setting this property directly is discouraged; use the
- * nm_setting_802_1x_set_client_cert() function instead.
- **/
- g_object_class_install_property
- (object_class, PROP_CLIENT_CERT,
- _nm_param_spec_specialized (NM_SETTING_802_1X_CLIENT_CERT, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase1-peapver:
- *
- * Forces which PEAP version is used when PEAP is set as the EAP method in
- * the #NMSetting8021x:eap property. When unset, the version reported by
- * the server will be used. Sometimes when using older RADIUS servers, it
- * is necessary to force the client to use a particular PEAP version. To do
- * so, this property may be set to "0" or "1" to force that specific PEAP
- * version.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE1_PEAPVER,
- g_param_spec_string (NM_SETTING_802_1X_PHASE1_PEAPVER, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase1-peaplabel:
- *
- * Forces use of the new PEAP label during key derivation. Some RADIUS
- * servers may require forcing the new PEAP label to interoperate with
- * PEAPv1. Set to "1" to force use of the new PEAP label. See the
- * wpa_supplicant documentation for more details.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE1_PEAPLABEL,
- g_param_spec_string (NM_SETTING_802_1X_PHASE1_PEAPLABEL, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase1-fast-provisioning:
- *
- * Enables or disables in-line provisioning of EAP-FAST credentials when
- * FAST is specified as the EAP method in the #NMSetting8021x:eap property.
- * Recognized values are "0" (disabled), "1" (allow unauthenticated
- * provisioning), "2" (allow authenticated provisioning), and "3" (allow
- * both authenticated and unauthenticated provisioning). See the
- * wpa_supplicant documentation for more details.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE1_FAST_PROVISIONING,
- g_param_spec_string (NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-auth:
- *
- * Specifies the allowed "phase 2" inner non-EAP authentication methods when
- * an EAP method that uses an inner TLS tunnel is specified in the
- * #NMSetting8021x:eap property. Recognized non-EAP "phase 2" methods are
- * "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", and "tls".
- * Each "phase 2" inner method requires specific parameters for successful
- * authentication; see the wpa_supplicant documentation for more details.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_AUTH,
- g_param_spec_string (NM_SETTING_802_1X_PHASE2_AUTH, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-autheap:
- *
- * Specifies the allowed "phase 2" inner EAP-based authentication methods
- * when an EAP method that uses an inner TLS tunnel is specified in the
- * #NMSetting8021x:eap property. Recognized EAP-based "phase 2" methods are
- * "md5", "mschapv2", "otp", "gtc", and "tls". Each "phase 2" inner method
- * requires specific parameters for successful authentication; see the
- * wpa_supplicant documentation for more details.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_AUTHEAP,
- g_param_spec_string (NM_SETTING_802_1X_PHASE2_AUTHEAP, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-ca-cert:
- *
- * Contains the "phase 2" CA certificate if used by the EAP method specified
- * in the #NMSetting8021x:phase2-auth or #NMSetting8021x:phase2-autheap
- * properties.
- *
- * Certificate data is specified using a "scheme"; two are currently
- * supported: blob and path. When using the blob scheme (which is backwards
- * compatible with NM 0.7.x) this property should be set to the
- * certificate's DER encoded data. When using the path scheme, this property
- * should be set to the full UTF-8 encoded path of the certificate, prefixed
- * with the string "file://" and ending with a terminating NUL byte. This
- * property can be unset even if the EAP method supports CA certificates,
- * but this allows man-in-the-middle attacks and is NOT recommended.
- *
- * Setting this property directly is discouraged; use the
- * nm_setting_802_1x_set_phase2_ca_cert() function instead.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_CA_CERT,
- _nm_param_spec_specialized (NM_SETTING_802_1X_PHASE2_CA_CERT, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-ca-path:
- *
- * UTF-8 encoded path to a directory containing PEM or DER formatted
- * certificates to be added to the verification chain in addition to the
- * certificate specified in the #NMSetting8021x:phase2-ca-cert property.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_CA_PATH,
- g_param_spec_string (NM_SETTING_802_1X_PHASE2_CA_PATH, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-subject-match:
- *
- * Substring to be matched against the subject of the certificate presented
- * by the authentication server during the inner "phase 2"
- * authentication. When unset, no verification of the authentication server
- * certificate's subject is performed.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_SUBJECT_MATCH,
- g_param_spec_string (NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-altsubject-matches:
- *
- * List of strings to be matched against the altSubjectName of the
- * certificate presented by the authentication server during the inner
- * "phase 2" authentication. If the list is empty, no verification of the
- * server certificate's altSubjectName is performed.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_ALTSUBJECT_MATCHES,
- _nm_param_spec_specialized (NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-client-cert:
- *
- * Contains the "phase 2" client certificate if used by the EAP method
- * specified in the #NMSetting8021x:phase2-auth or
- * #NMSetting8021x:phase2-autheap properties.
- *
- * Certificate data is specified using a "scheme"; two are currently
- * supported: blob and path. When using the blob scheme (which is backwards
- * compatible with NM 0.7.x) this property should be set to the
- * certificate's DER encoded data. When using the path scheme, this property
- * should be set to the full UTF-8 encoded path of the certificate, prefixed
- * with the string "file://" and ending with a terminating NUL byte. This
- * property can be unset even if the EAP method supports CA certificates,
- * but this allows man-in-the-middle attacks and is NOT recommended.
- *
- * Setting this property directly is discouraged; use the
- * nm_setting_802_1x_set_phase2_client_cert() function instead.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_CLIENT_CERT,
- _nm_param_spec_specialized (NM_SETTING_802_1X_PHASE2_CLIENT_CERT, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:password:
- *
- * UTF-8 encoded password used for EAP authentication methods. If both the
- * #NMSetting8021x:password property and the #NMSetting8021x:password-raw
- * property are specified, #NMSetting8021x:password is preferred.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD,
- g_param_spec_string (NM_SETTING_802_1X_PASSWORD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:password-flags:
- *
- * Flags indicating how to handle the #NMSetting8021x:password property.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD_FLAGS,
- g_param_spec_uint (NM_SETTING_802_1X_PASSWORD_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:password-raw:
- *
- * Password used for EAP authentication methods, given as a byte array to
- * allow passwords in other encodings than UTF-8 to be used. If both the
- * #NMSetting8021x:password property and the #NMSetting8021x:password-raw
- * property are specified, #NMSetting8021x:password is preferred.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD_RAW,
- _nm_param_spec_specialized (NM_SETTING_802_1X_PASSWORD_RAW, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:password-raw-flags:
- *
- * Flags indicating how to handle the #NMSetting8021x:password-raw property.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD_RAW_FLAGS,
- g_param_spec_uint (NM_SETTING_802_1X_PASSWORD_RAW_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:private-key:
- *
- * Contains the private key when the #NMSetting8021x:eap property is set to
- * "tls".
- *
- * Key data is specified using a "scheme"; two are currently supported: blob
- * and path. When using the blob scheme and private keys, this property
- * should be set to the key's encrypted PEM encoded data. When using private
- * keys with the path scheme, this property should be set to the full UTF-8
- * encoded path of the key, prefixed with the string "file://" and ending
- * with a terminating NUL byte. When using PKCS#<!-- -->12 format private keys and
- * the blob scheme, this property should be set to the PKCS#<!-- -->12 data and the
- * #NMSetting8021x:private-key-password property must be set to password
- * used to decrypt the PKCS#<!-- -->12 certificate and key. When using PKCS#<!-- -->12 files
- * and the path scheme, this property should be set to the full UTF-8
- * encoded path of the key, prefixed with the string "file://" and
- * ending with a terminating NUL byte, and as with the blob scheme the
- * "private-key-password" property must be set to the password used to
- * decode the PKCS#<!-- -->12 private key and certificate.
- *
- * Setting this property directly is discouraged; use the
- * nm_setting_802_1x_set_private_key() function instead.
- *
- * WARNING: #NMSetting8021x:private-key is not a "secret" property, and thus
- * unencrypted private key data using the BLOB scheme may be readable by
- * unprivileged users. Private keys should always be encrypted with a
- * private key password to prevent unauthorized access to unencrypted
- * private key data.
- **/
- g_object_class_install_property
- (object_class, PROP_PRIVATE_KEY,
- _nm_param_spec_specialized (NM_SETTING_802_1X_PRIVATE_KEY, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:private-key-password:
- *
- * The password used to decrypt the private key specified in the
- * #NMSetting8021x:private-key property when the private key either uses the
- * path scheme, or if the private key is a PKCS#<!-- -->12 format key. Setting this
- * property directly is not generally necessary except when returning
- * secrets to NetworkManager; it is generally set automatically when setting
- * the private key by the nm_setting_802_1x_set_private_key() function.
- **/
- g_object_class_install_property
- (object_class, PROP_PRIVATE_KEY_PASSWORD,
- g_param_spec_string (NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:private-key-password-flags:
- *
- * Flags indicating how to handle the #NMSetting8021x:private-key-password
- * property.
- **/
- g_object_class_install_property
- (object_class, PROP_PRIVATE_KEY_PASSWORD_FLAGS,
- g_param_spec_uint (NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-private-key:
- *
- * Contains the "phase 2" inner private key when the
- * #NMSetting8021x:phase2-auth or #NMSetting8021x:phase2-autheap property is
- * set to "tls".
- *
- * Key data is specified using a "scheme"; two are currently supported: blob
- * and path. When using the blob scheme and private keys, this property
- * should be set to the key's encrypted PEM encoded data. When using private
- * keys with the path scheme, this property should be set to the full UTF-8
- * encoded path of the key, prefixed with the string "file://" and ending
- * with a terminating NUL byte. When using PKCS#<!-- -->12 format private keys and
- * the blob scheme, this property should be set to the PKCS#<!-- -->12 data and the
- * #NMSetting8021x:phase2-private-key-password property must be set to
- * password used to decrypt the PKCS#<!-- -->12 certificate and key. When using
- * PKCS#<!-- -->12 files and the path scheme, this property should be set to the
- * full UTF-8 encoded path of the key, prefixed with the string "file://"
- * and ending with a terminating NUL byte, and as with the blob scheme
- * the #NMSetting8021x:phase2-private-key-password property must be set to
- * the password used to decode the PKCS#<!-- -->12 private key and certificate.
- *
- * Setting this property directly is discouraged; use the
- * nm_setting_802_1x_set_phase2_private_key() function instead.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_PRIVATE_KEY,
- _nm_param_spec_specialized (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-private-key-password:
- *
- * The password used to decrypt the "phase 2" private key specified in the
- * #NMSetting8021x:phase2-private-key property when the private key either
- * uses the path scheme, or is a PKCS#<!-- -->12 format key. Setting this property
- * directly is not generally necessary except when returning secrets to
- * NetworkManager; it is generally set automatically when setting the
- * private key by the nm_setting_802_1x_set_phase2_private_key() function.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_PRIVATE_KEY_PASSWORD,
- g_param_spec_string (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:phase2-private-key-password-flags:
- *
- * Flags indicating how to handle the
- * #NMSetting8021x:phase2-private-key-password property.
- **/
- g_object_class_install_property
- (object_class, PROP_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS,
- g_param_spec_uint (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:pin:
- *
- * PIN used for EAP authentication methods.
- **/
- g_object_class_install_property
- (object_class, PROP_PIN,
- g_param_spec_string (NM_SETTING_802_1X_PIN, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:pin-flags:
- *
- * Flags indicating how to handle the #NMSetting8021x:pin property.
- **/
- g_object_class_install_property
- (object_class, PROP_PIN_FLAGS,
- g_param_spec_uint (NM_SETTING_802_1X_PIN_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSetting8021x:system-ca-certs:
- *
- * When %TRUE, overrides the #NMSetting8021x:ca-path and
- * #NMSetting8021x:phase2-ca-path properties using the system CA directory
- * specified at configure time with the --system-ca-path switch. The
- * certificates in this directory are added to the verification chain in
- * addition to any certificates specified by the #NMSetting8021x:ca-cert and
- * #NMSetting8021x:phase2-ca-cert properties.
- **/
- g_object_class_install_property
- (object_class, PROP_SYSTEM_CA_CERTS,
- g_param_spec_boolean (NM_SETTING_802_1X_SYSTEM_CA_CERTS, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /* Initialize crypto lbrary. */
- if (!nm_utils_init (&error)) {
- g_warning ("Couldn't initialize nm-utils/crypto system: %s",
- error->message);
- g_error_free (error);
- }
-}
diff --git a/libnm-util/nm-setting-8021x.h b/libnm-util/nm-setting-8021x.h
deleted file mode 100644
index b3e1e540a7..0000000000
--- a/libnm-util/nm-setting-8021x.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_8021X_H
-#define NM_SETTING_8021X_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-/**
- * NMSetting8021xCKFormat:
- * @NM_SETTING_802_1X_CK_FORMAT_UNKNOWN: unknown file format
- * @NM_SETTING_802_1X_CK_FORMAT_X509: file contains an X.509 format certificate
- * @NM_SETTING_802_1X_CK_FORMAT_RAW_KEY: file contains an old-style OpenSSL PEM
- * or DER private key
- * @NM_SETTING_802_1X_CK_FORMAT_PKCS12: file contains a PKCS#<!-- -->12 certificate
- * and private key
- *
- * #NMSetting8021xCKFormat values indicate the general type of a certificate
- * or private key
- */
-typedef enum { /*< underscore_name=nm_setting_802_1x_ck_format >*/
- NM_SETTING_802_1X_CK_FORMAT_UNKNOWN = 0,
- NM_SETTING_802_1X_CK_FORMAT_X509,
- NM_SETTING_802_1X_CK_FORMAT_RAW_KEY,
- NM_SETTING_802_1X_CK_FORMAT_PKCS12
-} NMSetting8021xCKFormat;
-
-/**
- * NMSetting8021xCKScheme:
- * @NM_SETTING_802_1X_CK_SCHEME_UNKNOWN: unknown certificate or private key
- * scheme
- * @NM_SETTING_802_1X_CK_SCHEME_BLOB: certificate or key is stored as the raw
- * item data
- * @NM_SETTING_802_1X_CK_SCHEME_PATH: certificate or key is stored as a path
- * to a file containing the certificate or key data
- *
- * #NMSetting8021xCKScheme values indicate how a certificate or private key is
- * stored in the setting properties, either as a blob of the item's data, or as
- * a path to a certificate or private key file on the filesystem
- */
-typedef enum { /*< underscore_name=nm_setting_802_1x_ck_scheme >*/
- NM_SETTING_802_1X_CK_SCHEME_UNKNOWN = 0,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- NM_SETTING_802_1X_CK_SCHEME_PATH
-} NMSetting8021xCKScheme;
-
-#define NM_TYPE_SETTING_802_1X (nm_setting_802_1x_get_type ())
-#define NM_SETTING_802_1X(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_802_1X, NMSetting8021x))
-#define NM_SETTING_802_1X_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_802_1X, NMSetting8021xClass))
-#define NM_IS_SETTING_802_1X(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_802_1X))
-#define NM_IS_SETTING_802_1X_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_802_1X))
-#define NM_SETTING_802_1X_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_802_1X, NMSetting8021xClass))
-
-#define NM_SETTING_802_1X_SETTING_NAME "802-1x"
-
-/**
- * NMSetting8021xError:
- * @NM_SETTING_802_1X_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_802_1X_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_802_1X_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum { /*< underscore_name=nm_setting_802_1x_error >*/
- NM_SETTING_802_1X_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_802_1X_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
-} NMSetting8021xError;
-
-#define NM_SETTING_802_1X_ERROR nm_setting_802_1x_error_quark ()
-GQuark nm_setting_802_1x_error_quark (void);
-
-#define NM_SETTING_802_1X_EAP "eap"
-#define NM_SETTING_802_1X_IDENTITY "identity"
-#define NM_SETTING_802_1X_ANONYMOUS_IDENTITY "anonymous-identity"
-#define NM_SETTING_802_1X_PAC_FILE "pac-file"
-#define NM_SETTING_802_1X_CA_CERT "ca-cert"
-#define NM_SETTING_802_1X_CA_PATH "ca-path"
-#define NM_SETTING_802_1X_SUBJECT_MATCH "subject-match"
-#define NM_SETTING_802_1X_ALTSUBJECT_MATCHES "altsubject-matches"
-#define NM_SETTING_802_1X_CLIENT_CERT "client-cert"
-#define NM_SETTING_802_1X_PHASE1_PEAPVER "phase1-peapver"
-#define NM_SETTING_802_1X_PHASE1_PEAPLABEL "phase1-peaplabel"
-#define NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING "phase1-fast-provisioning"
-#define NM_SETTING_802_1X_PHASE2_AUTH "phase2-auth"
-#define NM_SETTING_802_1X_PHASE2_AUTHEAP "phase2-autheap"
-#define NM_SETTING_802_1X_PHASE2_CA_CERT "phase2-ca-cert"
-#define NM_SETTING_802_1X_PHASE2_CA_PATH "phase2-ca-path"
-#define NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH "phase2-subject-match"
-#define NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES "phase2-altsubject-matches"
-#define NM_SETTING_802_1X_PHASE2_CLIENT_CERT "phase2-client-cert"
-#define NM_SETTING_802_1X_PASSWORD "password"
-#define NM_SETTING_802_1X_PASSWORD_FLAGS "password-flags"
-#define NM_SETTING_802_1X_PASSWORD_RAW "password-raw"
-#define NM_SETTING_802_1X_PASSWORD_RAW_FLAGS "password-raw-flags"
-#define NM_SETTING_802_1X_PRIVATE_KEY "private-key"
-#define NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD "private-key-password"
-#define NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS "private-key-password-flags"
-#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY "phase2-private-key"
-#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD "phase2-private-key-password"
-#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS "phase2-private-key-password-flags"
-#define NM_SETTING_802_1X_PIN "pin"
-#define NM_SETTING_802_1X_PIN_FLAGS "pin-flags"
-#define NM_SETTING_802_1X_SYSTEM_CA_CERTS "system-ca-certs"
-
-/* PRIVATE KEY NOTE: when setting PKCS#12 private keys directly via properties
- * using the "blob" scheme, the data must be passed in PKCS#12 binary format.
- * In this case, the appropriate "client-cert" (or "phase2-client-cert")
- * property of the NMSetting8021x object must also contain the exact same
- * PKCS#12 binary data that the private key does. This is because the
- * PKCS#12 file contains both the private key and client certificate, so both
- * properties need to be set to the same thing. When using the "path" scheme,
- * just set both the private-key and client-cert properties to the same path.
- *
- * When setting OpenSSL-derived "traditional" format (ie S/MIME style, not
- * PKCS#8) RSA and DSA keys directly via properties with the "blob" scheme, they
- * should be passed to NetworkManager in PEM format with the "DEK-Info" and
- * "Proc-Type" tags intact. Decrypted private keys should not be used as this
- * is insecure and could allow unprivileged users to access the decrypted
- * private key data.
- *
- * When using the "path" scheme, just set the private-key and client-cert
- * properties to the paths to their respective objects.
- */
-
-typedef struct {
- NMSetting parent;
-} NMSetting8021x;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSetting8021xClass;
-
-GType nm_setting_802_1x_get_type (void);
-
-NMSetting *nm_setting_802_1x_new (void);
-
-guint32 nm_setting_802_1x_get_num_eap_methods (NMSetting8021x *setting);
-const char * nm_setting_802_1x_get_eap_method (NMSetting8021x *setting, guint32 i);
-gboolean nm_setting_802_1x_add_eap_method (NMSetting8021x *setting, const char *eap);
-void nm_setting_802_1x_remove_eap_method (NMSetting8021x *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_802_1x_remove_eap_method_by_value (NMSetting8021x *setting, const char *eap);
-void nm_setting_802_1x_clear_eap_methods (NMSetting8021x *setting);
-
-const char * nm_setting_802_1x_get_identity (NMSetting8021x *setting);
-
-const char * nm_setting_802_1x_get_anonymous_identity (NMSetting8021x *setting);
-
-const char * nm_setting_802_1x_get_pac_file (NMSetting8021x *setting);
-
-gboolean nm_setting_802_1x_get_system_ca_certs (NMSetting8021x *setting);
-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);
-const GByteArray * nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting);
-const char * nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting);
-gboolean nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
- const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error);
-
-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);
-void nm_setting_802_1x_remove_altsubject_match (NMSetting8021x *setting,
- guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_802_1x_remove_altsubject_match_by_value (NMSetting8021x *setting,
- const char *altsubject_match);
-void nm_setting_802_1x_clear_altsubject_matches (NMSetting8021x *setting);
-
-NMSetting8021xCKScheme nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting);
-const GByteArray * nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting);
-const char * nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting);
-gboolean nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
- const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error);
-
-const char * nm_setting_802_1x_get_phase1_peapver (NMSetting8021x *setting);
-
-const char * nm_setting_802_1x_get_phase1_peaplabel (NMSetting8021x *setting);
-
-const char * nm_setting_802_1x_get_phase1_fast_provisioning (NMSetting8021x *setting);
-
-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);
-const GByteArray * nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting);
-const char * nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting);
-gboolean nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
- const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error);
-
-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);
-void nm_setting_802_1x_remove_phase2_altsubject_match (NMSetting8021x *setting,
- guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_802_1x_remove_phase2_altsubject_match_by_value (NMSetting8021x *setting,
- const char *phase2_altsubject_match);
-void nm_setting_802_1x_clear_phase2_altsubject_matches (NMSetting8021x *setting);
-
-NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting);
-const GByteArray * nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting);
-const char * nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting);
-gboolean nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
- const char *cert_path,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- GError **error);
-
-const char * nm_setting_802_1x_get_password (NMSetting8021x *setting);
-NMSettingSecretFlags nm_setting_802_1x_get_password_flags (NMSetting8021x *setting);
-const GByteArray * 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);
-NMSettingSecretFlags nm_setting_802_1x_get_pin_flags (NMSetting8021x *setting);
-
-NMSetting8021xCKScheme nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting);
-const GByteArray * nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting);
-const char * nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting);
-gboolean nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
- const char *key_path,
- const char *password,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- 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);
-const GByteArray * nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting);
-const char * nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting);
-gboolean nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
- const char *key_path,
- const char *password,
- NMSetting8021xCKScheme scheme,
- NMSetting8021xCKFormat *out_format,
- 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);
-
-NMSetting8021xCKFormat nm_setting_802_1x_get_phase2_private_key_format (NMSetting8021x *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_8021X_H */
diff --git a/libnm-util/nm-setting-adsl.c b/libnm-util/nm-setting-adsl.c
deleted file mode 100644
index f2305b38df..0000000000
--- a/libnm-util/nm-setting-adsl.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-adsl.h"
-#include "nm-setting-ppp.h"
-#include "nm-setting-private.h"
-#include "nm-utils.h"
-
-/**
- * SECTION:nm-setting-adsl
- * @short_description: Describes ADSL-based properties
- * @include: nm-setting-adsl.h
- *
- * The #NMSettingAdsl object is a #NMSetting subclass that describes
- * properties of ADSL connections.
- */
-
-/**
- * nm_setting_adsl_error_quark:
- *
- * Registers an error quark for #NMSettingAdsl if necessary.
- *
- * Returns: the error quark used for #NMSettingAdsl errors.
- **/
-GQuark
-nm_setting_adsl_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-adsl-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingAdsl, nm_setting_adsl, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_ADSL_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_ADSL_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_ADSL)
-
-#define NM_SETTING_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_ADSL, NMSettingAdslPrivate))
-
-typedef struct {
- char * username;
- char * password;
- NMSettingSecretFlags password_flags;
- char * protocol;
- char * encapsulation;
- guint32 vpi;
- guint32 vci;
-} NMSettingAdslPrivate;
-
-enum {
- PROP_0,
- PROP_USERNAME,
- PROP_PASSWORD,
- PROP_PASSWORD_FLAGS,
- PROP_PROTOCOL,
- PROP_ENCAPSULATION,
- PROP_VPI,
- PROP_VCI,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_adsl_new:
- *
- * Creates a new #NMSettingAdsl object with default values.
- *
- * Returns: the new empty #NMSettingAdsl object
- **/
-NMSetting *
-nm_setting_adsl_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_ADSL, NULL);
-}
-
-/**
- * nm_setting_adsl_get_username:
- * @setting: the #NMSettingAdsl
- *
- * Returns: the #NMSettingAdsl:username property of the setting
- **/
-const char *
-nm_setting_adsl_get_username (NMSettingAdsl *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL);
-
- return NM_SETTING_ADSL_GET_PRIVATE (setting)->username;
-}
-
-/**
- * nm_setting_adsl_get_password:
- * @setting: the #NMSettingAdsl
- *
- * Returns: the #NMSettingAdsl:password property of the setting
- **/
-const char *
-nm_setting_adsl_get_password (NMSettingAdsl *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL);
-
- return NM_SETTING_ADSL_GET_PRIVATE (setting)->password;
-}
-
-/**
- * nm_setting_adsl_get_password_flags:
- * @setting: the #NMSettingAdsl
- *
- * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingAdsl:password
- **/
-NMSettingSecretFlags
-nm_setting_adsl_get_password_flags (NMSettingAdsl *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_ADSL_GET_PRIVATE (setting)->password_flags;
-}
-
-/**
- * nm_setting_adsl_get_protocol:
- * @setting: the #NMSettingAdsl
- *
- * Returns: the #NMSettingAdsl:protocol property of the setting
- **/
-const char *
-nm_setting_adsl_get_protocol (NMSettingAdsl *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL);
-
- return NM_SETTING_ADSL_GET_PRIVATE (setting)->protocol;
-}
-
-/**
- * nm_setting_adsl_get_encapsulation:
- * @setting: the #NMSettingAdsl
- *
- * Returns: the #NMSettingAdsl:encapsulation property of the setting
- **/
-const char *
-nm_setting_adsl_get_encapsulation (NMSettingAdsl *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL);
-
- return NM_SETTING_ADSL_GET_PRIVATE (setting)->encapsulation;
-}
-
-/**
- * nm_setting_adsl_get_vpi:
- * @setting: the #NMSettingAdsl
- *
- * Returns: the #NMSettingAdsl:vpi property of the setting
- **/
-guint32
-nm_setting_adsl_get_vpi (NMSettingAdsl *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), 0);
-
- return NM_SETTING_ADSL_GET_PRIVATE (setting)->vpi;
-}
-
-/**
- * nm_setting_adsl_get_vci:
- * @setting: the #NMSettingAdsl
- *
- * Returns: the #NMSettingAdsl:vci property of the setting
- **/
-guint32
-nm_setting_adsl_get_vci (NMSettingAdsl *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), 0);
-
- return NM_SETTING_ADSL_GET_PRIVATE (setting)->vci;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting);
-
- if (!priv->username) {
- g_set_error_literal (error,
- NM_SETTING_ADSL_ERROR,
- NM_SETTING_ADSL_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_USERNAME);
- return FALSE;
- } else if (!strlen (priv->username)) {
- g_set_error_literal (error,
- NM_SETTING_ADSL_ERROR,
- NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_USERNAME);
- return FALSE;
- }
-
- if ( !priv->protocol
- || ( strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA)
- && strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)
- && strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_IPOATM))){
- g_set_error (error,
- NM_SETTING_ADSL_ERROR,
- NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->protocol ?: "(null)");
- g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PROTOCOL);
- return FALSE;
- }
-
- if ( priv->encapsulation
- && ( strcmp (priv->encapsulation, NM_SETTING_ADSL_ENCAPSULATION_VCMUX)
- && strcmp (priv->encapsulation, NM_SETTING_ADSL_ENCAPSULATION_LLC) )) {
- g_set_error (error,
- NM_SETTING_ADSL_ERROR,
- NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->encapsulation);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_ENCAPSULATION);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static GPtrArray *
-need_secrets (NMSetting *setting)
-{
- NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting);
- GPtrArray *secrets = NULL;
-
- if (priv->password && *priv->password)
- return NULL;
-
- if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) {
- secrets = g_ptr_array_sized_new (1);
- g_ptr_array_add (secrets, NM_SETTING_ADSL_PASSWORD);
- }
-
- return secrets;
-}
-
-static void
-nm_setting_adsl_init (NMSettingAdsl *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object);
-
- g_free (priv->username);
- g_free (priv->password);
- g_free (priv->protocol);
- g_free (priv->encapsulation);
-
- G_OBJECT_CLASS (nm_setting_adsl_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object);
- const char *str;
-
- switch (prop_id) {
- case PROP_USERNAME:
- g_free (priv->username);
- priv->username = g_value_dup_string (value);
- break;
- case PROP_PASSWORD:
- g_free (priv->password);
- priv->password = g_value_dup_string (value);
- break;
- case PROP_PASSWORD_FLAGS:
- priv->password_flags = g_value_get_uint (value);
- break;
- case PROP_PROTOCOL:
- g_free (priv->protocol);
- str = g_value_get_string (value);
- priv->protocol = str ? g_ascii_strdown (str, -1) : NULL;
- break;
- case PROP_ENCAPSULATION:
- g_free (priv->encapsulation);
- str = g_value_get_string (value);
- priv->encapsulation = str ? g_ascii_strdown (str, -1) : NULL;
- break;
- case PROP_VPI:
- priv->vpi = g_value_get_uint (value);
- break;
- case PROP_VCI:
- priv->vci = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingAdsl *setting = NM_SETTING_ADSL (object);
-
- switch (prop_id) {
- case PROP_USERNAME:
- g_value_set_string (value, nm_setting_adsl_get_username (setting));
- break;
- case PROP_PASSWORD:
- g_value_set_string (value, nm_setting_adsl_get_password (setting));
- break;
- case PROP_PASSWORD_FLAGS:
- g_value_set_uint (value, nm_setting_adsl_get_password_flags (setting));
- break;
- case PROP_PROTOCOL:
- g_value_set_string (value, nm_setting_adsl_get_protocol (setting));
- break;
- case PROP_ENCAPSULATION:
- g_value_set_string (value, nm_setting_adsl_get_encapsulation (setting));
- break;
- case PROP_VPI:
- g_value_set_uint (value, nm_setting_adsl_get_vpi (setting));
- break;
- case PROP_VCI:
- g_value_set_uint (value, nm_setting_adsl_get_vci (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_adsl_class_init (NMSettingAdslClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingAdslPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->need_secrets = need_secrets;
-
- /* Properties */
-
- /**
- * NMSettingAdsl:username:
- *
- * Username used to authenticate with the ADSL service.
- **/
- g_object_class_install_property
- (object_class, PROP_USERNAME,
- g_param_spec_string (NM_SETTING_ADSL_USERNAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingAdsl:password:
- *
- * Password used to authenticate with the ADSL service.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD,
- g_param_spec_string (NM_SETTING_ADSL_PASSWORD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingAdsl:password-flags:
- *
- * Flags indicating how to handle the #NMSettingAdsl:password property.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD_FLAGS,
- g_param_spec_uint (NM_SETTING_ADSL_PASSWORD_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingAdsl:protocol:
- *
- * ADSL connection protocol. Can be "pppoa", "pppoe" or "ipoatm".
- **/
- g_object_class_install_property
- (object_class, PROP_PROTOCOL,
- g_param_spec_string (NM_SETTING_ADSL_PROTOCOL, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingAdsl:encapsulation:
- *
- * Encapsulation of ADSL connection. Can be "vcmux" or "llc".
- **/
- g_object_class_install_property
- (object_class, PROP_ENCAPSULATION,
- g_param_spec_string (NM_SETTING_ADSL_ENCAPSULATION, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingAdsl:vpi:
- *
- * VPI of ADSL connection
- **/
- g_object_class_install_property
- (object_class, PROP_VPI,
- g_param_spec_uint (NM_SETTING_ADSL_VPI, "", "",
- 0, 65536, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingAdsl:vci:
- *
- * VCI of ADSL connection
- **/
- g_object_class_install_property
- (object_class, PROP_VCI,
- g_param_spec_uint (NM_SETTING_ADSL_VCI, "", "",
- 0, 65536, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-adsl.h b/libnm-util/nm-setting-adsl.h
deleted file mode 100644
index 777f0b3636..0000000000
--- a/libnm-util/nm-setting-adsl.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_ADSL_H
-#define NM_SETTING_ADSL_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_ADSL (nm_setting_adsl_get_type ())
-#define NM_SETTING_ADSL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_ADSL, NMSettingAdsl))
-#define NM_SETTING_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_ADSL, NMSettingAdslClass))
-#define NM_IS_SETTING_ADSL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_ADSL))
-#define NM_IS_SETTING_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_ADSL))
-#define NM_SETTING_ADSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_ADSL, NMSettingAdslClass))
-
-#define NM_SETTING_ADSL_SETTING_NAME "adsl"
-
-/**
- * NMSettingAdslError:
- * @NM_SETTING_ADSL_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_ADSL_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_ADSL_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum {
- NM_SETTING_ADSL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_ADSL_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
-} NMSettingAdslError;
-
-#define NM_SETTING_ADSL_ERROR nm_setting_adsl_error_quark ()
-GQuark nm_setting_adsl_error_quark (void);
-
-#define NM_SETTING_ADSL_USERNAME "username"
-#define NM_SETTING_ADSL_PASSWORD "password"
-#define NM_SETTING_ADSL_PASSWORD_FLAGS "password-flags"
-#define NM_SETTING_ADSL_PROTOCOL "protocol"
-#define NM_SETTING_ADSL_ENCAPSULATION "encapsulation"
-#define NM_SETTING_ADSL_VPI "vpi"
-#define NM_SETTING_ADSL_VCI "vci"
-
-#define NM_SETTING_ADSL_PROTOCOL_PPPOA "pppoa"
-#define NM_SETTING_ADSL_PROTOCOL_PPPOE "pppoe"
-#define NM_SETTING_ADSL_PROTOCOL_IPOATM "ipoatm"
-
-#define NM_SETTING_ADSL_ENCAPSULATION_VCMUX "vcmux"
-#define NM_SETTING_ADSL_ENCAPSULATION_LLC "llc"
-
-typedef struct {
- NMSetting parent;
-} NMSettingAdsl;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} 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);
-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);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_ADSL_H */
diff --git a/libnm-util/nm-setting-bluetooth.c b/libnm-util/nm-setting-bluetooth.c
deleted file mode 100644
index d26a5b8f07..0000000000
--- a/libnm-util/nm-setting-bluetooth.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <net/ethernet.h>
-
-#include "nm-param-spec-specialized.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-bluetooth.h"
-#include "nm-setting-cdma.h"
-#include "nm-setting-gsm.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-bluetooth
- * @short_description: Describes Bluetooth connection properties
- * @include: nm-setting-bluetooth.h
- *
- * The #NMSettingBluetooth object is a #NMSetting subclass that describes
- * properties necessary for connection to devices that provide network
- * connections via the Bluetooth Dial-Up Networking (DUN) and Network Access
- * Point (NAP) profiles.
- **/
-
-/**
- * nm_setting_bluetooth_error_quark:
- *
- * Registers an error quark for #NMSettingBluetooth if necessary.
- *
- * Returns: the error quark used for #NMSettingBluetooth errors.
- **/
-GQuark
-nm_setting_bluetooth_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-bluetooth-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingBluetooth, nm_setting_bluetooth, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_BLUETOOTH_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_BLUETOOTH_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BLUETOOTH)
-
-#define NM_SETTING_BLUETOOTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothPrivate))
-
-typedef struct {
- GByteArray *bdaddr;
- char *type;
-} NMSettingBluetoothPrivate;
-
-enum {
- PROP_0,
- PROP_BDADDR,
- PROP_TYPE,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_bluetooth_new:
- *
- * Creates a new #NMSettingBluetooth object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingBluetooth object
- **/
-NMSetting *nm_setting_bluetooth_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_BLUETOOTH, NULL);
-}
-
-/**
- * nm_setting_bluetooth_get_connection_type:
- * @setting: the #NMSettingBluetooth
- *
- * Returns the connection method for communicating with the remote device (i.e.
- * either DUN to a DUN-capable device or PANU to a NAP-capable device).
- *
- * Returns: the type, either %NM_SETTING_BLUETOOTH_TYPE_PANU or
- * %NM_SETTING_BLUETOOTH_TYPE_DUN
- **/
-const char *
-nm_setting_bluetooth_get_connection_type (NMSettingBluetooth *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (setting), NULL);
-
- return NM_SETTING_BLUETOOTH_GET_PRIVATE (setting)->type;
-}
-
-/**
- * nm_setting_bluetooth_get_bdaddr:
- * @setting: the #NMSettingBluetooth
- *
- * Gets the Bluetooth address of the remote device which this setting
- * describes a connection to.
- *
- * Returns: the Bluetooth address
- **/
-const GByteArray *
-nm_setting_bluetooth_get_bdaddr (NMSettingBluetooth *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (setting), NULL);
-
- return NM_SETTING_BLUETOOTH_GET_PRIVATE (setting)->bdaddr;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (setting);
-
- if (!priv->bdaddr) {
- g_set_error_literal (error,
- NM_SETTING_BLUETOOTH_ERROR,
- NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR);
- return FALSE;
- }
-
- if (priv->bdaddr && priv->bdaddr->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_BLUETOOTH_ERROR,
- NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR);
- return FALSE;
- }
-
- if (!priv->type) {
- g_set_error_literal (error,
- NM_SETTING_BLUETOOTH_ERROR,
- NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE);
- return FALSE;
- } else if (!g_str_equal (priv->type, NM_SETTING_BLUETOOTH_TYPE_DUN) &&
- !g_str_equal (priv->type, NM_SETTING_BLUETOOTH_TYPE_PANU)) {
- g_set_error (error,
- NM_SETTING_BLUETOOTH_ERROR,
- NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->type);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE);
- return FALSE;
- }
-
- /* Make sure the corresponding 'type' setting is present */
- if ( all_settings
- && !strcmp (priv->type, NM_SETTING_BLUETOOTH_TYPE_DUN)) {
- gboolean gsm = FALSE, cdma = FALSE;
-
- gsm = !!nm_setting_find_in_list (all_settings, NM_SETTING_GSM_SETTING_NAME);
- cdma = !!nm_setting_find_in_list (all_settings, NM_SETTING_CDMA_SETTING_NAME);
-
- if (!gsm && !cdma) {
- g_set_error (error,
- NM_SETTING_BLUETOOTH_ERROR,
- NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND,
- _("requires '%s' or '%s' setting"),
- NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE);
- return FALSE;
- }
- }
- /* PANU doesn't need a 'type' setting since no further configuration
- * is required at the interface level.
- */
-
- return TRUE;
-}
-
-static void
-nm_setting_bluetooth_init (NMSettingBluetooth *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object);
-
- if (priv->bdaddr)
- g_byte_array_free (priv->bdaddr, TRUE);
- g_free (priv->type);
-
- G_OBJECT_CLASS (nm_setting_bluetooth_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_BDADDR:
- if (priv->bdaddr)
- g_byte_array_free (priv->bdaddr, TRUE);
- priv->bdaddr = g_value_dup_boxed (value);
- break;
- case PROP_TYPE:
- g_free (priv->type);
- priv->type = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingBluetooth *setting = NM_SETTING_BLUETOOTH (object);
-
- switch (prop_id) {
- case PROP_BDADDR:
- g_value_set_boxed (value, nm_setting_bluetooth_get_bdaddr (setting));
- break;
- case PROP_TYPE:
- g_value_set_string (value, nm_setting_bluetooth_get_connection_type (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_bluetooth_class_init (NMSettingBluetoothClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingBluetoothPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
-
- /**
- * NMSettingBluetooth:bdaddr:
- *
- * The Bluetooth address of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_BDADDR,
- _nm_param_spec_specialized (NM_SETTING_BLUETOOTH_BDADDR, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBluetooth:type:
- *
- * Either "dun" for Dial-Up Networking connections or "panu" for Personal
- * Area Networking connections to devices supporting the NAP profile.
- **/
- g_object_class_install_property
- (object_class, PROP_TYPE,
- g_param_spec_string (NM_SETTING_BLUETOOTH_TYPE, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-bluetooth.h b/libnm-util/nm-setting-bluetooth.h
deleted file mode 100644
index caf12158c0..0000000000
--- a/libnm-util/nm-setting-bluetooth.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2009 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_BLUETOOTH_H
-#define NM_SETTING_BLUETOOTH_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_BLUETOOTH (nm_setting_bluetooth_get_type ())
-#define NM_SETTING_BLUETOOTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetooth))
-#define NM_SETTING_BLUETOOTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothClass))
-#define NM_IS_SETTING_BLUETOOTH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BLUETOOTH))
-#define NM_IS_SETTING_BLUETOOTH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_BLUETOOTH))
-#define NM_SETTING_BLUETOOTH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothClass))
-
-#define NM_SETTING_BLUETOOTH_SETTING_NAME "bluetooth"
-
-/**
- * NMSettingBluetoothError:
- * @NM_SETTING_BLUETOOTH_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND: the connection
- * did not contain a required type setting, ie for DUN connections the connection
- * must also contain an #NMSettingGsm or #NMSettingCdma as appropriate
- */
-typedef enum {
- NM_SETTING_BLUETOOTH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND, /*< nick=TypeSettingNotFound >*/
-} NMSettingBluetoothError;
-
-#define NM_SETTING_BLUETOOTH_ERROR nm_setting_bluetooth_error_quark ()
-GQuark nm_setting_bluetooth_error_quark (void);
-
-#define NM_SETTING_BLUETOOTH_BDADDR "bdaddr"
-#define NM_SETTING_BLUETOOTH_TYPE "type"
-
-/**
- * NM_SETTING_BLUETOOTH_TYPE_DUN:
- *
- * Connection type describing a connection to devices that support the Bluetooth
- * DUN profile.
- */
-#define NM_SETTING_BLUETOOTH_TYPE_DUN "dun"
-
-/**
- * NM_SETTING_BLUETOOTH_TYPE_PANU:
- *
- * Connection type describing a connection to devices that support the Bluetooth
- * NAP (Network Access Point) protocol, which accepts connections via PANU.
- */
-#define NM_SETTING_BLUETOOTH_TYPE_PANU "panu"
-
-typedef struct {
- NMSetting parent;
-} NMSettingBluetooth;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingBluetoothClass;
-
-GType nm_setting_bluetooth_get_type (void);
-
-NMSetting * nm_setting_bluetooth_new (void);
-const GByteArray *nm_setting_bluetooth_get_bdaddr (NMSettingBluetooth *setting);
-const char * nm_setting_bluetooth_get_connection_type (NMSettingBluetooth *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_BLUETOOTH_H */
diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c
deleted file mode 100644
index 9a1c5c7391..0000000000
--- a/libnm-util/nm-setting-bond.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-bond.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-bond
- * @short_description: Describes connection properties for bonds
- * @include: nm-setting-bond.h
- *
- * The #NMSettingBond object is a #NMSetting subclass that describes properties
- * necessary for bond connections.
- **/
-
-/**
- * nm_setting_bond_error_quark:
- *
- * Registers an error quark for #NMSettingBond if necessary.
- *
- * Returns: the error quark used for #NMSettingBond errors.
- **/
-GQuark
-nm_setting_bond_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-bond-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingBond, nm_setting_bond, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_BOND_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_BOND_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BOND)
-
-#define NM_SETTING_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BOND, NMSettingBondPrivate))
-
-typedef struct {
- char *interface_name;
- GHashTable *options;
-} NMSettingBondPrivate;
-
-enum {
- PROP_0,
- PROP_INTERFACE_NAME,
- PROP_OPTIONS,
- LAST_PROP
-};
-
-enum {
- TYPE_INT,
- TYPE_STR,
- TYPE_BOTH,
- TYPE_IP,
- TYPE_IFNAME,
-};
-
-typedef struct {
- const char *opt;
- const char *val;
- guint opt_type;
- guint min;
- guint max;
- char *list[10];
-} BondDefault;
-
-static const BondDefault defaults[] = {
- { NM_SETTING_BOND_OPTION_MODE, "balance-rr", TYPE_BOTH, 0, 6,
- { "balance-rr", "active-backup", "balance-xor", "broadcast", "802.3ad", "balance-tlb", "balance-alb", NULL } },
- { NM_SETTING_BOND_OPTION_MIIMON, "100", TYPE_INT, 0, G_MAXINT },
- { NM_SETTING_BOND_OPTION_DOWNDELAY, "0", TYPE_INT, 0, G_MAXINT },
- { NM_SETTING_BOND_OPTION_UPDELAY, "0", TYPE_INT, 0, G_MAXINT },
- { NM_SETTING_BOND_OPTION_ARP_INTERVAL, "0", TYPE_INT, 0, G_MAXINT },
- { NM_SETTING_BOND_OPTION_ARP_IP_TARGET, "", TYPE_IP },
- { NM_SETTING_BOND_OPTION_ARP_VALIDATE, "0", TYPE_BOTH, 0, 3,
- { "none", "active", "backup", "all", NULL } },
- { NM_SETTING_BOND_OPTION_PRIMARY, "", TYPE_IFNAME },
- { NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, "0", TYPE_BOTH, 0, 2,
- { "always", "better", "failure", NULL } },
- { NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, "0", TYPE_BOTH, 0, 2,
- { "none", "active", "follow", NULL } },
- { NM_SETTING_BOND_OPTION_USE_CARRIER, "1", TYPE_INT, 0, 1 },
- { NM_SETTING_BOND_OPTION_AD_SELECT, "0", TYPE_BOTH, 0, 2,
- { "stable", "bandwidth", "count", NULL } },
- { NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, "0", TYPE_BOTH, 0, 2,
- { "layer2", "layer3+4", "layer2+3", NULL } },
- { NM_SETTING_BOND_OPTION_RESEND_IGMP, "1", TYPE_INT, 0, 255 },
- { NM_SETTING_BOND_OPTION_LACP_RATE, "0", TYPE_BOTH, 0, 1,
- { "slow", "fast", NULL } },
-};
-
-/**
- * nm_setting_bond_new:
- *
- * Creates a new #NMSettingBond object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingBond object
- **/
-NMSetting *
-nm_setting_bond_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_BOND, NULL);
-}
-
-/**
- * nm_setting_bond_get_interface_name:
- * @setting: the #NMSettingBond
- *
- * Returns: the #NMSettingBond:interface-name property of the setting
- **/
-const char *
-nm_setting_bond_get_interface_name (NMSettingBond *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL);
-
- return NM_SETTING_BOND_GET_PRIVATE (setting)->interface_name;
-}
-
-/**
- * nm_setting_bond_get_num_options:
- * @setting: the #NMSettingBond
- *
- * Returns the number of options that should be set for this bond when it
- * is activated. This can be used to retrieve each option individually
- * using nm_setting_bond_get_option().
- *
- * Returns: the number of bonding options
- **/
-guint32
-nm_setting_bond_get_num_options (NMSettingBond *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0);
-
- return g_hash_table_size (NM_SETTING_BOND_GET_PRIVATE (setting)->options);
-}
-
-/**
- * nm_setting_bond_get_option:
- * @setting: the #NMSettingBond
- * @idx: index of the desired option, from 0 to
- * nm_setting_bond_get_num_options() - 1
- * @out_name: (out): on return, the name of the bonding option; this
- * value is owned by the setting and should not be modified
- * @out_value: (out): on return, the value of the name of the bonding
- * option; this value is owned by the setting and should not be modified
- *
- * Given an index, return the value of the bonding option at that index. Indexes
- * are *not* guaranteed to be static across modifications to options done by
- * nm_setting_bond_add_option() and nm_setting_bond_remove_option(),
- * and should not be used to refer to options except for short periods of time
- * such as during option iteration.
- *
- * Returns: %TRUE on success if the index was valid and an option was found,
- * %FALSE if the index was invalid (ie, greater than the number of options
- * currently held by the setting)
- **/
-gboolean
-nm_setting_bond_get_option (NMSettingBond *setting,
- guint32 idx,
- const char **out_name,
- const char **out_value)
-{
- NMSettingBondPrivate *priv;
- GList *keys;
- const char *_key = NULL, *_value = NULL;
-
- g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
-
- priv = NM_SETTING_BOND_GET_PRIVATE (setting);
-
- if (idx >= nm_setting_bond_get_num_options (setting))
- return FALSE;
-
- keys = g_hash_table_get_keys (priv->options);
- _key = g_list_nth_data (keys, idx);
- _value = g_hash_table_lookup (priv->options, _key);
-
- if (out_name)
- *out_name = _key;
- if (out_value)
- *out_value = _value;
-
- g_list_free (keys);
- return TRUE;
-}
-
-static gboolean
-validate_int (const char *name, const char *value, const BondDefault *def)
-{
- long num;
- guint i;
-
- for (i = 0; i < strlen (value); i++) {
- if (!g_ascii_isdigit (value[i]) && value[i] != '-')
- return FALSE;
- }
-
- errno = 0;
- num = strtol (value, NULL, 10);
- if (errno)
- return FALSE;
- if (num < def->min || num > def->max)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-validate_list (const char *name, const char *value, const BondDefault *def)
-{
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (def->list) && def->list[i]; i++) {
- if (g_strcmp0 (def->list[i], value) == 0)
- return TRUE;
- }
-
- /* empty validation list means all values pass */
- return def->list[0] == NULL ? TRUE : FALSE;
-}
-
-static gboolean
-validate_ip (const char *name, const char *value)
-{
- gs_free char *value_clone = NULL;
- struct in_addr addr;
-
- if (!value || !value[0])
- return FALSE;
-
- value_clone = g_strdup (value);
- value = value_clone;
- for (;;) {
- char *eow;
-
- /* we do not skip over empty words. E.g
- * "192.168.1.1," is an error.
- *
- * ... for no particular reason. */
-
- eow = strchr (value, ',');
- if (eow)
- *eow = '\0';
-
- if (inet_pton (AF_INET, value, &addr) != 1)
- return FALSE;
-
- if (!eow)
- break;
- value = eow + 1;
- }
- return TRUE;
-}
-
-static gboolean
-validate_ifname (const char *name, const char *value)
-{
- if (!value || !value[0])
- return FALSE;
-
- return nm_utils_iface_valid_name (value);
-}
-
-/**
- * nm_setting_bond_validate_option:
- * @name: the name of the option to validate
- * @value: the value of the option to validate
- *
- * Checks whether @name is a valid bond option and @value is a valid value for
- * the @name. If @value is %NULL, the function only validates the option name.
- *
- * Returns: %TRUE, if the @value is valid for the given name.
- * If the @name is not a valid option, %FALSE will be returned.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_bond_validate_option (const char *name,
- const char *value)
-{
- guint i;
-
- if (!name || !name[0])
- return FALSE;
-
- for (i = 0; i < G_N_ELEMENTS (defaults); i++) {
- if (g_strcmp0 (defaults[i].opt, name) == 0) {
- if (value == NULL)
- return TRUE;
- switch (defaults[i].opt_type) {
- case TYPE_INT:
- return validate_int (name, value, &defaults[i]);
- case TYPE_STR:
- return validate_list (name, value, &defaults[i]);
- case TYPE_BOTH:
- return ( validate_int (name, value, &defaults[i])
- || validate_list (name, value, &defaults[i]));
- case TYPE_IP:
- return validate_ip (name, value);
- case TYPE_IFNAME:
- return validate_ifname (name, value);
- }
- return FALSE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_bond_get_option_by_name:
- * @setting: the #NMSettingBond
- * @name: the option name for which to retrieve the value
- *
- * Returns the value associated with the bonding option specified by
- * @name, if it exists.
- *
- * Returns: the value, or %NULL if the key/value pair was never added to the
- * setting; the value is owned by the setting and must not be modified
- **/
-const char *
-nm_setting_bond_get_option_by_name (NMSettingBond *setting,
- const char *name)
-{
- g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL);
-
- if (!nm_setting_bond_validate_option (name, NULL))
- return NULL;
-
- return g_hash_table_lookup (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name);
-}
-
-/**
- * nm_setting_bond_add_option:
- * @setting: the #NMSettingBond
- * @name: name for the option
- * @value: value for the option
- *
- * Add an option to the table. The option is compared to an internal list
- * of allowed options. Option names may contain only alphanumeric characters
- * (ie [a-zA-Z0-9]). Adding a new name replaces any existing name/value pair
- * that may already exist.
- *
- * The order of how to set several options is relevant because there are options
- * that conflict with each other.
- *
- * Returns: %TRUE if the option was valid and was added to the internal option
- * list, %FALSE if it was not.
- **/
-gboolean
-nm_setting_bond_add_option (NMSettingBond *setting,
- const char *name,
- const char *value)
-{
- NMSettingBondPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
-
- if (!value || !nm_setting_bond_validate_option (name, value))
- return FALSE;
-
- priv = NM_SETTING_BOND_GET_PRIVATE (setting);
-
- g_hash_table_insert (priv->options, g_strdup (name), g_strdup (value));
-
- if ( !strcmp (name, NM_SETTING_BOND_OPTION_MIIMON)
- && strcmp (value, "0") != 0) {
- g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
- g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
- } else if ( !strcmp (name, NM_SETTING_BOND_OPTION_ARP_INTERVAL)
- && strcmp (value, "0") != 0) {
- g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_MIIMON);
- g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY);
- g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_UPDELAY);
- }
-
- g_object_notify (G_OBJECT (setting), NM_SETTING_BOND_OPTIONS);
-
- return TRUE;
-}
-
-/**
- * nm_setting_bond_remove_option:
- * @setting: the #NMSettingBond
- * @name: name of the option to remove
- *
- * Remove the bonding option referenced by @name from the internal option
- * list.
- *
- * Returns: %TRUE if the option was found and removed from the internal option
- * list, %FALSE if it was not.
- **/
-gboolean
-nm_setting_bond_remove_option (NMSettingBond *setting,
- const char *name)
-{
- gboolean found;
-
- g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
-
- if (!nm_setting_bond_validate_option (name, NULL))
- return FALSE;
-
- found = g_hash_table_remove (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name);
- if (found)
- g_object_notify (G_OBJECT (setting), NM_SETTING_BOND_OPTIONS);
- return found;
-}
-
-/**
- * nm_setting_bond_get_valid_options:
- * @setting: the #NMSettingBond
- *
- * Returns a list of valid bond options.
- *
- * Returns: (transfer none): a %NULL-terminated array of strings of valid bond options.
- **/
-const char **
-nm_setting_bond_get_valid_options (NMSettingBond *setting)
-{
- static const char *array[G_N_ELEMENTS (defaults) + 1] = { NULL };
- int i;
-
- /* initialize the array once */
- if (G_UNLIKELY (array[0] == NULL)) {
- for (i = 0; i < G_N_ELEMENTS (defaults); i++)
- array[i] = defaults[i].opt;
- array[i] = NULL;
- }
- return array;
-}
-
-/**
- * nm_setting_bond_get_option_default:
- * @setting: the #NMSettingBond
- * @name: the name of the option
- *
- * Returns: the value of the bond option if not overridden by an entry in
- * the #NMSettingBond:options property.
- **/
-const char *
-nm_setting_bond_get_option_default (NMSettingBond *setting, const char *name)
-{
- guint i;
-
- g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL);
- g_return_val_if_fail (nm_setting_bond_validate_option (name, NULL), NULL);
-
- for (i = 0; i < G_N_ELEMENTS (defaults); i++) {
- if (g_strcmp0 (defaults[i].opt, name) == 0)
- return defaults[i].val;
- }
- /* Any option that passes nm_setting_bond_validate_option() should also be found in defaults */
- g_assert_not_reached ();
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
- GHashTableIter iter;
- const char *key, *value;
- const char *valid_modes[] = { "balance-rr",
- "active-backup",
- "balance-xor",
- "broadcast",
- "802.3ad",
- "balance-tlb",
- "balance-alb",
- NULL };
- int miimon = 0, arp_interval = 0;
- const char *arp_ip_target = NULL;
- const char *lacp_rate;
- const char *primary;
-
- g_hash_table_iter_init (&iter, priv->options);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
- if (!value[0] || !nm_setting_bond_validate_option (key, value)) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("invalid option '%s' or its value '%s'"),
- key, value);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- }
-
- value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MIIMON);
- if (value)
- miimon = atoi (value);
- value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
- if (value)
- arp_interval = atoi (value);
-
- /* Can only set one of miimon and arp_interval */
- if (miimon > 0 && arp_interval > 0) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("only one of '%s' and '%s' can be set"),
- NM_SETTING_BOND_OPTION_MIIMON,
- NM_SETTING_BOND_OPTION_ARP_INTERVAL);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- }
-
- value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE);
- if (!value) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_MISSING_OPTION,
- _("mandatory option '%s' is missing"),
- NM_SETTING_BOND_OPTION_MODE);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- if (!g_strv_contains (valid_modes, value)) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' is not a valid value for '%s'"),
- value, NM_SETTING_BOND_OPTION_MODE);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
-
- /* Make sure mode is compatible with other settings */
- if ( strcmp (value, "balance-alb") == 0
- || strcmp (value, "balance-tlb") == 0) {
- if (arp_interval > 0) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s=%s' is incompatible with '%s > 0'"),
- NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- }
-
- primary = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_PRIMARY);
- if (strcmp (value, "active-backup") == 0) {
- if (primary && !nm_utils_iface_valid_name (primary)) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' is not a valid interface name for '%s' option"),
- primary, NM_SETTING_BOND_OPTION_PRIMARY);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- } else {
- if (primary) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' option is only valid for '%s=%s'"),
- NM_SETTING_BOND_OPTION_PRIMARY,
- NM_SETTING_BOND_OPTION_MODE, "active-backup");
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- }
-
- if (nm_setting_find_in_list (all_settings, NM_SETTING_INFINIBAND_SETTING_NAME)) {
- if (strcmp (value, "active-backup") != 0) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s=%s' is not a valid configuration for '%s'"),
- NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_INFINIBAND_SETTING_NAME);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- }
-
- if (miimon == 0) {
- /* updelay and downdelay can only be used with miimon */
- if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_UPDELAY)) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' option requires '%s' option to be set"),
- NM_SETTING_BOND_OPTION_UPDELAY, NM_SETTING_BOND_OPTION_MIIMON);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY)) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' option requires '%s' option to be set"),
- NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_MIIMON);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- }
-
- /* arp_ip_target can only be used with arp_interval, and must
- * contain a comma-separated list of IPv4 addresses.
- */
- arp_ip_target = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
- if (arp_interval > 0) {
- char **addrs;
- guint32 addr;
- int i;
-
- if (!arp_ip_target) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_MISSING_OPTION,
- _("'%s' option requires '%s' option to be set"),
- NM_SETTING_BOND_OPTION_ARP_INTERVAL, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
-
- addrs = g_strsplit (arp_ip_target, ",", -1);
- if (!addrs[0]) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' option is empty"),
- NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- g_strfreev (addrs);
- return FALSE;
- }
-
- for (i = 0; addrs[i]; i++) {
- if (!inet_pton (AF_INET, addrs[i], &addr)) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' is not a valid IPv4 address for '%s' option"),
- NM_SETTING_BOND_OPTION_ARP_IP_TARGET, addrs[i]);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- g_strfreev (addrs);
- return FALSE;
- }
- }
- g_strfreev (addrs);
- } else {
- if (arp_ip_target) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' option requires '%s' option to be set"),
- NM_SETTING_BOND_OPTION_ARP_IP_TARGET, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
- }
-
- lacp_rate = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_LACP_RATE);
- if ( lacp_rate
- && (g_strcmp0 (value, "802.3ad") != 0 && g_strcmp0 (value, "4") != 0)
- && (strcmp (lacp_rate, "slow") != 0 && strcmp (lacp_rate, "0") != 0)) {
- g_set_error (error,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_OPTION,
- _("'%s' option is only valid with mode '%s'"),
- NM_SETTING_BOND_OPTION_LACP_RATE, "802.3ad");
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
- return FALSE;
- }
-
- return _nm_setting_verify_deprecated_virtual_iface_name (
- priv->interface_name, FALSE,
- NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_INTERFACE_NAME,
- NM_SETTING_BOND_ERROR,
- NM_SETTING_BOND_ERROR_INVALID_PROPERTY,
- NM_SETTING_BOND_ERROR_MISSING_PROPERTY,
- all_settings, error);
-}
-
-static const char *
-get_virtual_iface_name (NMSetting *setting)
-{
- NMSettingBond *self = NM_SETTING_BOND (setting);
-
- return nm_setting_bond_get_interface_name (self);
-}
-
-static void
-nm_setting_bond_init (NMSettingBond *setting)
-{
- NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
-
- priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- /* Default values: */
- nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MODE, "balance-rr");
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
-
- g_free (priv->interface_name);
- g_hash_table_destroy (priv->options);
-
- G_OBJECT_CLASS (nm_setting_bond_parent_class)->finalize (object);
-}
-
-static void
-copy_hash (gpointer key, gpointer value, gpointer user_data)
-{
- g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), g_strdup (value));
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
- GHashTable *new_hash;
-
- switch (prop_id) {
- case PROP_INTERFACE_NAME:
- g_free (priv->interface_name);
- priv->interface_name = g_value_dup_string (value);
- break;
- case PROP_OPTIONS:
- /* Must make a deep copy of the hash table here... */
- g_hash_table_remove_all (priv->options);
- new_hash = g_value_get_boxed (value);
- if (new_hash)
- g_hash_table_foreach (new_hash, copy_hash, priv->options);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
- NMSettingBond *setting = NM_SETTING_BOND (object);
-
- switch (prop_id) {
- case PROP_INTERFACE_NAME:
- g_value_set_string (value, nm_setting_bond_get_interface_name (setting));
- break;
- case PROP_OPTIONS:
- g_value_set_boxed (value, priv->options);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_bond_class_init (NMSettingBondClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingBondPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->get_virtual_iface_name = get_virtual_iface_name;
-
- /* Properties */
- /**
- * NMSettingBond:interface-name:
- *
- * The name of the virtual in-kernel bonding network interface
- **/
- g_object_class_install_property
- (object_class, PROP_INTERFACE_NAME,
- g_param_spec_string (NM_SETTING_BOND_INTERFACE_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBond:options:
- *
- * Dictionary of key/value pairs of bonding options. Both keys and values
- * must be strings. Option names must contain only alphanumeric characters
- * (ie, [a-zA-Z0-9]).
- **/
- g_object_class_install_property
- (object_class, PROP_OPTIONS,
- _nm_param_spec_specialized (NM_SETTING_BOND_OPTIONS, "", "",
- DBUS_TYPE_G_MAP_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-bond.h b/libnm-util/nm-setting-bond.h
deleted file mode 100644
index efef82c882..0000000000
--- a/libnm-util/nm-setting-bond.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2013 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_BOND_H
-#define NM_SETTING_BOND_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_BOND (nm_setting_bond_get_type ())
-#define NM_SETTING_BOND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BOND, NMSettingBond))
-#define NM_SETTING_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BOND, NMSettingBondClass))
-#define NM_IS_SETTING_BOND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BOND))
-#define NM_IS_SETTING_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_BOND))
-#define NM_SETTING_BOND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BOND, NMSettingBondClass))
-
-#define NM_SETTING_BOND_SETTING_NAME "bond"
-
-/**
- * NMSettingBondError:
- * @NM_SETTING_BOND_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_BOND_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_BOND_ERROR_MISSING_PROPERTY: the property was missing and is
- * @NM_SETTING_BOND_ERROR_INVALID_OPTION: the option was invalid
- * @NM_SETTING_BOND_ERROR_MISSING_OPTION: the option was missing
- * required
- */
-typedef enum {
- NM_SETTING_BOND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_BOND_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_BOND_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_BOND_ERROR_INVALID_OPTION, /*< nick=InvalidOption >*/
- NM_SETTING_BOND_ERROR_MISSING_OPTION, /*< nick=MissingOption >*/
-} NMSettingBondError;
-
-#define NM_SETTING_BOND_ERROR nm_setting_bond_error_quark ()
-GQuark nm_setting_bond_error_quark (void);
-
-#define NM_SETTING_BOND_INTERFACE_NAME "interface-name"
-#define NM_SETTING_BOND_OPTIONS "options"
-
-/* Valid options for the 'options' property */
-#define NM_SETTING_BOND_OPTION_MODE "mode"
-#define NM_SETTING_BOND_OPTION_MIIMON "miimon"
-#define NM_SETTING_BOND_OPTION_DOWNDELAY "downdelay"
-#define NM_SETTING_BOND_OPTION_UPDELAY "updelay"
-#define NM_SETTING_BOND_OPTION_ARP_INTERVAL "arp_interval"
-#define NM_SETTING_BOND_OPTION_ARP_IP_TARGET "arp_ip_target"
-#define NM_SETTING_BOND_OPTION_ARP_VALIDATE "arp_validate"
-#define NM_SETTING_BOND_OPTION_PRIMARY "primary"
-#define NM_SETTING_BOND_OPTION_PRIMARY_RESELECT "primary_reselect"
-#define NM_SETTING_BOND_OPTION_FAIL_OVER_MAC "fail_over_mac"
-#define NM_SETTING_BOND_OPTION_USE_CARRIER "use_carrier"
-#define NM_SETTING_BOND_OPTION_AD_SELECT "ad_select"
-#define NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY "xmit_hash_policy"
-#define NM_SETTING_BOND_OPTION_RESEND_IGMP "resend_igmp"
-#define NM_SETTING_BOND_OPTION_LACP_RATE "lacp_rate"
-
-typedef struct {
- NMSetting parent;
-} NMSettingBond;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingBondClass;
-
-GType nm_setting_bond_get_type (void);
-
-NMSetting * nm_setting_bond_new (void);
-const char * nm_setting_bond_get_interface_name (NMSettingBond *setting);
-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 * 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);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_bond_validate_option (const char *name,
- const char *value);
-
-const char **nm_setting_bond_get_valid_options (NMSettingBond *setting);
-
-const char * nm_setting_bond_get_option_default (NMSettingBond *setting,
- const char *name);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_BOND_H */
diff --git a/libnm-util/nm-setting-bridge-port.c b/libnm-util/nm-setting-bridge-port.c
deleted file mode 100644
index 41d5a6f8a8..0000000000
--- a/libnm-util/nm-setting-bridge-port.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 - 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-bridge-port.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-bridge-port
- * @short_description: Describes connection properties for bridge ports
- * @include: nm-setting-bridge-port.h
- *
- * The #NMSettingBridgePort object is a #NMSetting subclass that describes
- * optional properties that apply to bridge ports.
- *
- * Since: 0.9.8
- **/
-
-/**
- * nm_setting_bridge_port_error_quark:
- *
- * Registers an error quark for #NMSettingBridgePort if necessary.
- *
- * Returns: the error quark used for #NMSettingBridgePort errors.
- *
- * Since: 0.9.8
- **/
-GQuark
-nm_setting_bridge_port_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-bridge-port-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingBridgePort, nm_setting_bridge_port, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_BRIDGE_PORT_SETTING_NAME,
- g_define_type_id,
- 3,
- NM_SETTING_BRIDGE_PORT_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE_PORT)
-
-#define NM_SETTING_BRIDGE_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortPrivate))
-
-typedef struct {
- guint16 priority;
- guint16 path_cost;
- gboolean hairpin_mode;
-} NMSettingBridgePortPrivate;
-
-enum {
- PROP_0,
- PROP_PRIORITY,
- PROP_PATH_COST,
- PROP_HAIRPIN_MODE,
- LAST_PROP
-};
-
-/*****************************************************************************/
-
-/**
- * nm_setting_bridge_port_get_priority:
- * @setting: the #NMSettingBridgePort
- *
- * Returns: the #NMSettingBridgePort:priority property of the setting
- *
- * Since: 0.9.8
- **/
-guint16
-nm_setting_bridge_port_get_priority (NMSettingBridgePort *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), 0);
-
- return NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting)->priority;
-}
-
-/**
- * nm_setting_bridge_port_get_path_cost:
- * @setting: the #NMSettingBridgePort
- *
- * Returns: the #NMSettingBridgePort:path-cost property of the setting
- *
- * Since: 0.9.8
- **/
-guint16
-nm_setting_bridge_port_get_path_cost (NMSettingBridgePort *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), 0);
-
- return NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting)->path_cost;
-}
-
-/**
- * nm_setting_bridge_port_get_hairpin_mode:
- * @setting: the #NMSettingBridgePort
- *
- * Returns: the #NMSettingBridgePort:hairpin-mode property of the setting
- *
- * Since: 0.9.8
- **/
-gboolean
-nm_setting_bridge_port_get_hairpin_mode (NMSettingBridgePort *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), FALSE);
-
- return NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting)->hairpin_mode;
-}
-
-/*****************************************************************************/
-
-#define BR_MAX_PORT_PRIORITY 63
-#define BR_DEF_PRIORITY 32
-
-#define BR_MIN_PATH_COST 1
-#define BR_MAX_PATH_COST 65535
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- return TRUE;
-}
-
-/*****************************************************************************/
-
-/**
- * nm_setting_bridge_port_new:
- *
- * Creates a new #NMSettingBridgePort object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingBridgePort object
- *
- * Since: 0.9.8
- **/
-NMSetting *
-nm_setting_bridge_port_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_BRIDGE_PORT, NULL);
-}
-
-static void
-nm_setting_bridge_port_init (NMSettingBridgePort *setting)
-{
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_PRIORITY:
- priv->priority = g_value_get_uint (value);
- break;
- case PROP_PATH_COST:
- priv->path_cost = g_value_get_uint (value);
- break;
- case PROP_HAIRPIN_MODE:
- priv->hairpin_mode = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_PRIORITY:
- g_value_set_uint (value, priv->priority);
- break;
- case PROP_PATH_COST:
- g_value_set_uint (value, priv->path_cost);
- break;
- case PROP_HAIRPIN_MODE:
- g_value_set_boolean (value, priv->hairpin_mode);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_bridge_port_class_init (NMSettingBridgePortClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingBridgePortPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingBridgePort:priority:
- *
- * The Spanning Tree Protocol (STP) priority of this bridge port.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_PRIORITY,
- g_param_spec_uint (NM_SETTING_BRIDGE_PORT_PRIORITY, "", "",
- 0, BR_MAX_PORT_PRIORITY, BR_DEF_PRIORITY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridgePort:path-cost:
- *
- * The Spanning Tree Protocol (STP) port cost for destinations via this
- * port.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_PATH_COST,
- g_param_spec_uint (NM_SETTING_BRIDGE_PORT_PATH_COST, "", "",
- 0, BR_MAX_PATH_COST, 100,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridgePort:hairpin-mode:
- *
- * Enables or disables "hairpin mode" for the port, which allows frames to
- * be sent back out through the port the frame was received on.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_HAIRPIN_MODE,
- g_param_spec_boolean (NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, "", "",
- FALSE,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-bridge-port.h b/libnm-util/nm-setting-bridge-port.h
deleted file mode 100644
index 76527aefdf..0000000000
--- a/libnm-util/nm-setting-bridge-port.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2012 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_BRIDGE_PORT_H
-#define NM_SETTING_BRIDGE_PORT_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_BRIDGE_PORT (nm_setting_bridge_port_get_type ())
-#define NM_SETTING_BRIDGE_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePort))
-#define NM_SETTING_BRIDGE_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortClass))
-#define NM_IS_SETTING_BRIDGE_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BRIDGE_PORT))
-#define NM_IS_SETTING_BRIDGE_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_BRIDGE_PORT))
-#define NM_SETTING_BRIDGE_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortClass))
-
-#define NM_SETTING_BRIDGE_PORT_SETTING_NAME "bridge-port"
-
-/**
- * NMSettingBridgePortError:
- * @NM_SETTING_BRIDGE_PORT_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_BRIDGE_PORT_ERROR_MISSING_PROPERTY: the property was missing and
- * is required
- *
- * Since: 0.9.8
- */
-typedef enum {
- NM_SETTING_BRIDGE_PORT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_BRIDGE_PORT_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
-} NMSettingBridgePortError;
-
-#define NM_SETTING_BRIDGE_PORT_ERROR nm_setting_bridge_port_error_quark ()
-GQuark nm_setting_bridge_port_error_quark (void);
-
-#define NM_SETTING_BRIDGE_PORT_PRIORITY "priority"
-#define NM_SETTING_BRIDGE_PORT_PATH_COST "path-cost"
-#define NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE "hairpin-mode"
-
-typedef struct {
- NMSetting parent;
-} NMSettingBridgePort;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingBridgePortClass;
-
-GType nm_setting_bridge_port_get_type (void);
-
-NMSetting * nm_setting_bridge_port_new (void);
-
-guint16 nm_setting_bridge_port_get_priority (NMSettingBridgePort *setting);
-
-guint16 nm_setting_bridge_port_get_path_cost (NMSettingBridgePort *setting);
-
-gboolean nm_setting_bridge_port_get_hairpin_mode (NMSettingBridgePort *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_BRIDGE_PORT_H */
diff --git a/libnm-util/nm-setting-bridge.c b/libnm-util/nm-setting-bridge.c
deleted file mode 100644
index ceebb98294..0000000000
--- a/libnm-util/nm-setting-bridge.c
+++ /dev/null
@@ -1,576 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <dbus/dbus-glib.h>
-#include <linux/if_ether.h>
-
-#include "nm-setting-bridge.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-setting-private.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-dbus-glib-types.h"
-
-/**
- * SECTION:nm-setting-bridge
- * @short_description: Describes connection properties for bridges
- * @include: nm-setting-bridge.h
- *
- * The #NMSettingBridge object is a #NMSetting subclass that describes properties
- * necessary for bridging connections.
- *
- * Since: 0.9.8
- **/
-
-/**
- * nm_setting_bridge_error_quark:
- *
- * Registers an error quark for #NMSettingBridge if necessary.
- *
- * Returns: the error quark used for #NMSettingBridge errors.
- *
- * Since: 0.9.8
- **/
-GQuark
-nm_setting_bridge_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-bridge-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingBridge, nm_setting_bridge, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_BRIDGE_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_BRIDGE_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE)
-
-#define NM_SETTING_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE, NMSettingBridgePrivate))
-
-typedef struct {
- char * interface_name;
- GByteArray *mac_address;
- gboolean stp;
- guint16 priority;
- guint16 forward_delay;
- guint16 hello_time;
- guint16 max_age;
- guint32 ageing_time;
-} NMSettingBridgePrivate;
-
-enum {
- PROP_0,
- PROP_INTERFACE_NAME,
- PROP_MAC_ADDRESS,
- PROP_STP,
- PROP_PRIORITY,
- PROP_FORWARD_DELAY,
- PROP_HELLO_TIME,
- PROP_MAX_AGE,
- PROP_AGEING_TIME,
- LAST_PROP
-};
-
-/**
- * nm_setting_bridge_new:
- *
- * Creates a new #NMSettingBridge object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingBridge object
- *
- * Since: 0.9.8
- **/
-NMSetting *
-nm_setting_bridge_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_BRIDGE, NULL);
-}
-
-/**
- * nm_setting_bridge_get_interface_name:
- * @setting: the #NMSettingBridge
- *
- * Returns: the #NMSettingBridge:interface-name property of the setting
- *
- * Since: 0.9.8
- **/
-const char *
-nm_setting_bridge_get_interface_name (NMSettingBridge *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
-
- return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->interface_name;
-}
-
-/**
- * nm_setting_bridge_get_mac_address:
- * @setting: the #NMSettingBridge
- *
- * Returns: the #NMSettingBridge:mac-address property of the setting
- *
- * Since: 0.9.10
- **/
-const GByteArray *
-nm_setting_bridge_get_mac_address (NMSettingBridge *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), NULL);
-
- return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->mac_address;
-}
-
-/**
- * nm_setting_bridge_get_stp:
- * @setting: the #NMSettingBridge
- *
- * Returns: the #NMSettingBridge:stp property of the setting
- *
- * Since: 0.9.8
- **/
-gboolean
-nm_setting_bridge_get_stp (NMSettingBridge *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), FALSE);
-
- return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->stp;
-}
-
-/**
- * nm_setting_bridge_get_priority:
- * @setting: the #NMSettingBridge
- *
- * Returns: the #NMSettingBridge:priority property of the setting
- *
- * Since: 0.9.8
- **/
-guint16
-nm_setting_bridge_get_priority (NMSettingBridge *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
-
- return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->priority;
-}
-
-/**
- * nm_setting_bridge_get_forward_delay:
- * @setting: the #NMSettingBridge
- *
- * Returns: the #NMSettingBridge:forward-delay property of the setting
- *
- * Since: 0.9.8
- **/
-guint16
-nm_setting_bridge_get_forward_delay (NMSettingBridge *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
-
- return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->forward_delay;
-}
-
-/**
- * nm_setting_bridge_get_hello_time:
- * @setting: the #NMSettingBridge
- *
- * Returns: the #NMSettingBridge:hello-time property of the setting
- *
- * Since: 0.9.8
- **/
-guint16
-nm_setting_bridge_get_hello_time (NMSettingBridge *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
-
- return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->hello_time;
-}
-
-/**
- * nm_setting_bridge_get_max_age:
- * @setting: the #NMSettingBridge
- *
- * Returns: the #NMSettingBridge:max-age property of the setting
- *
- * Since: 0.9.8
- **/
-guint16
-nm_setting_bridge_get_max_age (NMSettingBridge *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
-
- return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->max_age;
-}
-
-/**
- * nm_setting_bridge_get_ageing_time:
- * @setting: the #NMSettingBridge
- *
- * Returns: the #NMSettingBridge:ageing-time property of the setting
- *
- * Since: 0.9.8
- **/
-guint
-nm_setting_bridge_get_ageing_time (NMSettingBridge *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
-
- return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->ageing_time;
-}
-
-/* IEEE 802.1D-1998 timer values */
-#define BR_MIN_HELLO_TIME 1
-#define BR_MAX_HELLO_TIME 10
-
-#define BR_MIN_FORWARD_DELAY 2
-#define BR_MAX_FORWARD_DELAY 30
-
-#define BR_MIN_MAX_AGE 6
-#define BR_MAX_MAX_AGE 40
-
-/* IEEE 802.1D-1998 Table 7.4 */
-#define BR_MIN_AGEING_TIME 0
-#define BR_MAX_AGEING_TIME 1000000
-
-static gboolean
-check_range (guint32 val,
- guint32 min,
- guint32 max,
- const char *prop,
- GError **error)
-{
- if ((val != 0) && (val < min || val > max)) {
- g_set_error (error,
- NM_SETTING_BRIDGE_ERROR,
- NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
- _("value '%d' is out of range <%d-%d>"),
- val, min, max);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, prop);
- return FALSE;
- }
- return TRUE;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
-
- if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_BRIDGE_ERROR,
- NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
- _("is not a valid MAC address"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_MAC_ADDRESS);
- return FALSE;
- }
-
- if (!check_range (priv->forward_delay,
- BR_MIN_FORWARD_DELAY,
- BR_MAX_FORWARD_DELAY,
- NM_SETTING_BRIDGE_FORWARD_DELAY,
- error))
- return FALSE;
-
- if (!check_range (priv->hello_time,
- BR_MIN_HELLO_TIME,
- BR_MAX_HELLO_TIME,
- NM_SETTING_BRIDGE_HELLO_TIME,
- error))
- return FALSE;
-
- if (!check_range (priv->max_age,
- BR_MIN_MAX_AGE,
- BR_MAX_MAX_AGE,
- NM_SETTING_BRIDGE_MAX_AGE,
- error))
- return FALSE;
-
- if (!check_range (priv->ageing_time,
- BR_MIN_AGEING_TIME,
- BR_MAX_AGEING_TIME,
- NM_SETTING_BRIDGE_AGEING_TIME,
- error))
- return FALSE;
-
- return _nm_setting_verify_deprecated_virtual_iface_name (
- priv->interface_name, FALSE,
- NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_INTERFACE_NAME,
- NM_SETTING_BRIDGE_ERROR,
- NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
- NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY,
- all_settings, error);
-}
-
-static const char *
-get_virtual_iface_name (NMSetting *setting)
-{
- NMSettingBridge *self = NM_SETTING_BRIDGE (setting);
-
- return nm_setting_bridge_get_interface_name (self);
-}
-
-static void
-nm_setting_bridge_init (NMSettingBridge *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
-
- g_free (priv->interface_name);
-
- if (priv->mac_address)
- g_byte_array_free (priv->mac_address, TRUE);
-
- G_OBJECT_CLASS (nm_setting_bridge_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_INTERFACE_NAME:
- g_free (priv->interface_name);
- priv->interface_name = g_value_dup_string (value);
- break;
- case PROP_MAC_ADDRESS:
- if (priv->mac_address)
- g_byte_array_free (priv->mac_address, TRUE);
- priv->mac_address = g_value_dup_boxed (value);
- break;
- case PROP_STP:
- priv->stp = g_value_get_boolean (value);
- break;
- case PROP_PRIORITY:
- priv->priority = (guint16) g_value_get_uint (value);
- break;
- case PROP_FORWARD_DELAY:
- priv->forward_delay = (guint16) g_value_get_uint (value);
- break;
- case PROP_HELLO_TIME:
- priv->hello_time = (guint16) g_value_get_uint (value);
- break;
- case PROP_MAX_AGE:
- priv->max_age = (guint16) g_value_get_uint (value);
- break;
- case PROP_AGEING_TIME:
- priv->ageing_time = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
- NMSettingBridge *setting = NM_SETTING_BRIDGE (object);
-
- switch (prop_id) {
- case PROP_INTERFACE_NAME:
- g_value_set_string (value, nm_setting_bridge_get_interface_name (setting));
- break;
- case PROP_MAC_ADDRESS:
- g_value_set_boxed (value, nm_setting_bridge_get_mac_address (setting));
- break;
- case PROP_STP:
- g_value_set_boolean (value, priv->stp);
- break;
- case PROP_PRIORITY:
- g_value_set_uint (value, priv->priority);
- break;
- case PROP_FORWARD_DELAY:
- g_value_set_uint (value, priv->forward_delay);
- break;
- case PROP_HELLO_TIME:
- g_value_set_uint (value, priv->hello_time);
- break;
- case PROP_MAX_AGE:
- g_value_set_uint (value, priv->max_age);
- break;
- case PROP_AGEING_TIME:
- g_value_set_uint (value, priv->ageing_time);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingBridgePrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->get_virtual_iface_name = get_virtual_iface_name;
-
- /* Properties */
- /**
- * NMSettingBridge:interface-name:
- *
- * The name of the virtual in-kernel bridging network interface
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_INTERFACE_NAME,
- g_param_spec_string (NM_SETTING_BRIDGE_INTERFACE_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridge:mac-address:
- *
- * If specified, the MAC address of bridge. When creating a new bridge, this
- * MAC address will be set. When matching an existing (outside
- * NetworkManager created) bridge, this MAC address must match.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_MAC_ADDRESS,
- _nm_param_spec_specialized (NM_SETTING_BRIDGE_MAC_ADDRESS, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridge:stp:
- *
- * Controls whether Spanning Tree Protocol (STP) is enabled for this bridge.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_STP,
- g_param_spec_boolean (NM_SETTING_BRIDGE_STP, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridge:priority:
- *
- * Sets the Spanning Tree Protocol (STP) priority for this bridge. Lower
- * values are "better"; the lowest priority bridge will be elected the root
- * bridge.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_PRIORITY,
- g_param_spec_uint (NM_SETTING_BRIDGE_PRIORITY, "", "",
- 0, G_MAXUINT16, 0x8000,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridge:forward-delay:
- *
- * The Spanning Tree Protocol (STP) forwarding delay, in seconds.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_FORWARD_DELAY,
- g_param_spec_uint (NM_SETTING_BRIDGE_FORWARD_DELAY, "", "",
- 0, BR_MAX_FORWARD_DELAY, 15,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridge:hello-time:
- *
- * The Spanning Tree Protocol (STP) hello time, in seconds.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_HELLO_TIME,
- g_param_spec_uint (NM_SETTING_BRIDGE_HELLO_TIME, "", "",
- 0, BR_MAX_HELLO_TIME, 2,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridge:max-age:
- *
- * The Spanning Tree Protocol (STP) maximum message age, in seconds.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_MAX_AGE,
- g_param_spec_uint (NM_SETTING_BRIDGE_MAX_AGE, "", "",
- 0, BR_MAX_MAX_AGE, 20,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingBridge:ageing-time:
- *
- * The Ethernet MAC address aging time, in seconds.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_AGEING_TIME,
- g_param_spec_uint (NM_SETTING_BRIDGE_AGEING_TIME, "", "",
- 0, BR_MAX_AGEING_TIME, 300,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-bridge.h b/libnm-util/nm-setting-bridge.h
deleted file mode 100644
index bd74141591..0000000000
--- a/libnm-util/nm-setting-bridge.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2012 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_BRIDGE_H
-#define NM_SETTING_BRIDGE_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_BRIDGE (nm_setting_bridge_get_type ())
-#define NM_SETTING_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BRIDGE, NMSettingBridge))
-#define NM_SETTING_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BRIDGE, NMSettingBridgeClass))
-#define NM_IS_SETTING_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BRIDGE))
-#define NM_IS_SETTING_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_BRIDGE))
-#define NM_SETTING_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BRIDGE, NMSettingBridgeClass))
-
-#define NM_SETTING_BRIDGE_SETTING_NAME "bridge"
-
-/**
- * NMSettingBridgeError:
- * @NM_SETTING_BRIDGE_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- *
- * Since: 0.9.8
- */
-typedef enum {
- NM_SETTING_BRIDGE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
-} NMSettingBridgeError;
-
-#define NM_SETTING_BRIDGE_ERROR nm_setting_bridge_error_quark ()
-GQuark nm_setting_bridge_error_quark (void);
-
-#define NM_SETTING_BRIDGE_INTERFACE_NAME "interface-name"
-#define NM_SETTING_BRIDGE_MAC_ADDRESS "mac-address"
-#define NM_SETTING_BRIDGE_STP "stp"
-#define NM_SETTING_BRIDGE_PRIORITY "priority"
-#define NM_SETTING_BRIDGE_FORWARD_DELAY "forward-delay"
-#define NM_SETTING_BRIDGE_HELLO_TIME "hello-time"
-#define NM_SETTING_BRIDGE_MAX_AGE "max-age"
-#define NM_SETTING_BRIDGE_AGEING_TIME "ageing-time"
-
-typedef struct {
- NMSetting parent;
-} NMSettingBridge;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingBridgeClass;
-
-GType nm_setting_bridge_get_type (void);
-
-NMSetting * nm_setting_bridge_new (void);
-
-const char * nm_setting_bridge_get_interface_name (NMSettingBridge *setting);
-
-NM_AVAILABLE_IN_0_9_10
-const GByteArray *nm_setting_bridge_get_mac_address (NMSettingBridge *setting);
-
-gboolean nm_setting_bridge_get_stp (NMSettingBridge *setting);
-
-guint16 nm_setting_bridge_get_priority (NMSettingBridge *setting);
-
-guint16 nm_setting_bridge_get_forward_delay (NMSettingBridge *setting);
-
-guint16 nm_setting_bridge_get_hello_time (NMSettingBridge *setting);
-
-guint16 nm_setting_bridge_get_max_age (NMSettingBridge *setting);
-
-guint32 nm_setting_bridge_get_ageing_time (NMSettingBridge *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_BRIDGE_H */
diff --git a/libnm-util/nm-setting-cdma.c b/libnm-util/nm-setting-cdma.c
deleted file mode 100644
index fc76be60e1..0000000000
--- a/libnm-util/nm-setting-cdma.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-cdma.h"
-#include "nm-utils.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-cdma
- * @short_description: Describes CDMA-based mobile broadband properties
- * @include: nm-setting-cdma.h
- *
- * The #NMSettingCdma object is a #NMSetting subclass that describes
- * properties that allow connections to IS-95-based mobile broadband
- * networks, including those using CDMA2000/EVDO technology.
- */
-
-/**
- * nm_setting_cdma_error_quark:
- *
- * Registers an error quark for #NMSettingCdma if necessary.
- *
- * Returns: the error quark used for #NMSettingCdma errors.
- **/
-GQuark
-nm_setting_cdma_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-cdma-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingCdma, nm_setting_cdma, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_CDMA_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_CDMA_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_CDMA)
-
-#define NM_SETTING_CDMA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_CDMA, NMSettingCdmaPrivate))
-
-typedef struct {
- char *number; /* For dialing, duh */
- char *username;
- char *password;
- NMSettingSecretFlags password_flags;
-} NMSettingCdmaPrivate;
-
-enum {
- PROP_0,
- PROP_NUMBER,
- PROP_USERNAME,
- PROP_PASSWORD,
- PROP_PASSWORD_FLAGS,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_cdma_new:
- *
- * Creates a new #NMSettingCdma object with default values.
- *
- * Returns: the new empty #NMSettingCdma object
- **/
-NMSetting *
-nm_setting_cdma_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_CDMA, NULL);
-}
-
-/**
- * nm_setting_cdma_get_number:
- * @setting: the #NMSettingCdma
- *
- * Returns: the #NMSettingCdma:number property of the setting
- **/
-const char *
-nm_setting_cdma_get_number (NMSettingCdma *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CDMA (setting), NULL);
-
- return NM_SETTING_CDMA_GET_PRIVATE (setting)->number;
-}
-
-/**
- * nm_setting_cdma_get_username:
- * @setting: the #NMSettingCdma
- *
- * Returns: the #NMSettingCdma:username property of the setting
- **/
-const char *
-nm_setting_cdma_get_username (NMSettingCdma *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CDMA (setting), NULL);
-
- return NM_SETTING_CDMA_GET_PRIVATE (setting)->username;
-}
-
-/**
- * nm_setting_cdma_get_password:
- * @setting: the #NMSettingCdma
- *
- * Returns: the #NMSettingCdma:password property of the setting
- **/
-const char *
-nm_setting_cdma_get_password (NMSettingCdma *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CDMA (setting), NULL);
-
- return NM_SETTING_CDMA_GET_PRIVATE (setting)->password;
-}
-
-/**
- * nm_setting_cdma_get_password_flags:
- * @setting: the #NMSettingCdma
- *
- * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingCdma:password
- **/
-NMSettingSecretFlags
-nm_setting_cdma_get_password_flags (NMSettingCdma *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CDMA (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_CDMA_GET_PRIVATE (setting)->password_flags;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (setting);
-
- if (!priv->number) {
- g_set_error_literal (error,
- NM_SETTING_CDMA_ERROR,
- NM_SETTING_CDMA_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_NUMBER);
- return FALSE;
- } else if (!strlen (priv->number)) {
- g_set_error_literal (error,
- NM_SETTING_CDMA_ERROR,
- NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_NUMBER);
- return FALSE;
- }
-
- if (priv->username && !strlen (priv->username)) {
- g_set_error_literal (error,
- NM_SETTING_CDMA_ERROR,
- NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_USERNAME);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static GPtrArray *
-need_secrets (NMSetting *setting)
-{
- NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (setting);
- GPtrArray *secrets = NULL;
-
- if (priv->password && *priv->password)
- return NULL;
-
- if (priv->username) {
- if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) {
- secrets = g_ptr_array_sized_new (1);
- g_ptr_array_add (secrets, NM_SETTING_CDMA_PASSWORD);
- }
- }
-
- return secrets;
-}
-
-static void
-nm_setting_cdma_init (NMSettingCdma *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (object);
-
- g_free (priv->number);
- g_free (priv->username);
- g_free (priv->password);
-
- G_OBJECT_CLASS (nm_setting_cdma_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_NUMBER:
- g_free (priv->number);
- priv->number = g_value_dup_string (value);
- break;
- case PROP_USERNAME:
- g_free (priv->username);
- priv->username = g_value_dup_string (value);
- break;
- case PROP_PASSWORD:
- g_free (priv->password);
- priv->password = g_value_dup_string (value);
- break;
- case PROP_PASSWORD_FLAGS:
- priv->password_flags = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingCdma *setting = NM_SETTING_CDMA (object);
-
- switch (prop_id) {
- case PROP_NUMBER:
- g_value_set_string (value, nm_setting_cdma_get_number (setting));
- break;
- case PROP_USERNAME:
- g_value_set_string (value, nm_setting_cdma_get_username (setting));
- break;
- case PROP_PASSWORD:
- g_value_set_string (value, nm_setting_cdma_get_password (setting));
- break;
- case PROP_PASSWORD_FLAGS:
- g_value_set_uint (value, nm_setting_cdma_get_password_flags (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_cdma_class_init (NMSettingCdmaClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingCdmaPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->need_secrets = need_secrets;
-
- /* Properties */
-
- /**
- * NMSettingCdma:number:
- *
- * The number to dial to establish the connection to the CDMA-based mobile
- * broadband network, if any. If not specified, the default number (#777)
- * is used when required.
- **/
- g_object_class_install_property
- (object_class, PROP_NUMBER,
- g_param_spec_string (NM_SETTING_CDMA_NUMBER, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingCdma:username:
- *
- * The username used to authenticate with the network, if required. Many
- * providers do not require a username, or accept any username. But if a
- * username is required, it is specified here.
- **/
- g_object_class_install_property
- (object_class, PROP_USERNAME,
- g_param_spec_string (NM_SETTING_CDMA_USERNAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingCdma:password:
- *
- * The password used to authenticate with the network, if required. Many
- * providers do not require a password, or accept any password. But if a
- * password is required, it is specified here.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD,
- g_param_spec_string (NM_SETTING_CDMA_PASSWORD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingCdma:password-flags:
- *
- * Flags indicating how to handle the #NMSettingCdma:password property.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD_FLAGS,
- g_param_spec_uint (NM_SETTING_CDMA_PASSWORD_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-cdma.h b/libnm-util/nm-setting-cdma.h
deleted file mode 100644
index e2c0376eb4..0000000000
--- a/libnm-util/nm-setting-cdma.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_CDMA_H
-#define NM_SETTING_CDMA_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_CDMA (nm_setting_cdma_get_type ())
-#define NM_SETTING_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_CDMA, NMSettingCdma))
-#define NM_SETTING_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_CDMA, NMSettingCdmaClass))
-#define NM_IS_SETTING_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_CDMA))
-#define NM_IS_SETTING_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_CDMA))
-#define NM_SETTING_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_CDMA, NMSettingCdmaClass))
-
-#define NM_SETTING_CDMA_SETTING_NAME "cdma"
-
-/**
- * NMSettingCdmaError:
- * @NM_SETTING_CDMA_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_CDMA_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_CDMA_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING: the required #NMSettingSerial
- * is missing in the connection
- */
-typedef enum {
- NM_SETTING_CDMA_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_CDMA_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING /*< nick=MissingSerialSetting >*/
-} NMSettingCdmaError;
-
-#define NM_SETTING_CDMA_ERROR nm_setting_cdma_error_quark ()
-GQuark nm_setting_cdma_error_quark (void);
-
-#define NM_SETTING_CDMA_NUMBER "number"
-#define NM_SETTING_CDMA_USERNAME "username"
-#define NM_SETTING_CDMA_PASSWORD "password"
-#define NM_SETTING_CDMA_PASSWORD_FLAGS "password-flags"
-
-typedef struct {
- NMSetting parent;
-} NMSettingCdma;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} 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);
-NMSettingSecretFlags nm_setting_cdma_get_password_flags (NMSettingCdma *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_CDMA_H */
diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c
deleted file mode 100644
index 4750733f2a..0000000000
--- a/libnm-util/nm-setting-connection.c
+++ /dev/null
@@ -1,1332 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-connection
- * @short_description: Describes general connection properties
- * @include: nm-setting-connection.h
- *
- * The #NMSettingConnection object is a #NMSetting subclass that describes
- * properties that apply to all #NMConnection objects, regardless of what type
- * of network connection they describe. Each #NMConnection object must contain
- * a #NMSettingConnection setting.
- **/
-
-/**
- * nm_setting_connection_error_quark:
- *
- * Registers an error quark for #NMSettingConnection if necessary.
- *
- * Returns: the error quark used for #NMSettingConnection errors.
- **/
-GQuark
-nm_setting_connection_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-connection-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingConnection, nm_setting_connection, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_CONNECTION_SETTING_NAME,
- g_define_type_id,
- 0,
- NM_SETTING_CONNECTION_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_CONNECTION)
-
-#define NM_SETTING_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_CONNECTION, NMSettingConnectionPrivate))
-
-typedef enum {
- PERM_TYPE_USER = 0,
-} PermType;
-
-typedef struct {
- guint8 ptype;
- char *item;
-} Permission;
-
-typedef struct {
- char *id;
- char *uuid;
- char *interface_name;
- char *type;
- char *master;
- char *slave_type;
- GSList *permissions; /* list of Permission structs */
- gboolean autoconnect;
- guint64 timestamp;
- gboolean read_only;
- char *zone;
- GSList *secondaries; /* secondary connections to activate with the base connection */
- guint gateway_ping_timeout;
-} NMSettingConnectionPrivate;
-
-enum {
- PROP_0,
- PROP_ID,
- PROP_UUID,
- PROP_INTERFACE_NAME,
- PROP_TYPE,
- PROP_PERMISSIONS,
- PROP_AUTOCONNECT,
- PROP_TIMESTAMP,
- PROP_READ_ONLY,
- PROP_ZONE,
- PROP_MASTER,
- PROP_SLAVE_TYPE,
- PROP_SECONDARIES,
- PROP_GATEWAY_PING_TIMEOUT,
-
- LAST_PROP
-};
-
-/*****************************************************************************/
-
-#define PERM_USER_PREFIX "user:"
-
-static Permission *
-permission_new_from_str (const char *str)
-{
- Permission *p;
- const char *last_colon;
- size_t ulen = 0, i;
-
- g_return_val_if_fail (strncmp (str, PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0, NULL);
- str += strlen (PERM_USER_PREFIX);
-
- last_colon = strrchr (str, ':');
- if (last_colon) {
- /* Ensure that somebody didn't pass "user::" */
- g_return_val_if_fail (last_colon > str, NULL);
-
- /* Reject :[detail] for now */
- g_return_val_if_fail (*(last_colon + 1) == '\0', NULL);
-
- /* Make sure we don't include detail in the username */
- ulen = last_colon - str;
- } else
- ulen = strlen (str);
-
- /* Sanity check the length of the username */
- g_return_val_if_fail (ulen < 100, NULL);
-
- /* Make sure there's no ':' in the username */
- for (i = 0; i < ulen; i++)
- g_return_val_if_fail (str[i] != ':', NULL);
-
- /* And the username must be valid UTF-8 */
- g_return_val_if_fail (g_utf8_validate (str, -1, NULL) == TRUE, NULL);
-
- /* Yay, valid... create the new permission */
- p = g_slice_new0 (Permission);
- p->ptype = PERM_TYPE_USER;
- if (last_colon) {
- p->item = g_malloc (ulen + 1);
- memcpy (p->item, str, ulen);
- p->item[ulen] = '\0';
- } else
- p->item = g_strdup (str);
-
- return p;
-}
-
-static Permission *
-permission_new (const char *uname)
-{
- Permission *p;
-
- g_return_val_if_fail (uname, NULL);
- g_return_val_if_fail (uname[0] != '\0', NULL);
- g_return_val_if_fail (strchr (uname, ':') == NULL, NULL);
- g_return_val_if_fail (g_utf8_validate (uname, -1, NULL) == TRUE, NULL);
-
- /* Yay, valid... create the new permission */
- p = g_slice_new0 (Permission);
- p->ptype = PERM_TYPE_USER;
- p->item = g_strdup (uname);
- return p;
-}
-
-static char *
-permission_to_string (Permission *p)
-{
- return g_strdup_printf (PERM_USER_PREFIX "%s:", p->item);
-}
-
-static void
-permission_free (Permission *p)
-{
- g_free (p->item);
- memset (p, 0, sizeof (*p));
- g_slice_free (Permission, p);
-}
-
-/*****************************************************************************/
-
-/**
- * nm_setting_connection_new:
- *
- * Creates a new #NMSettingConnection object with default values.
- *
- * Returns: the new empty #NMSettingConnection object
- **/
-NMSetting *nm_setting_connection_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_CONNECTION, NULL);
-}
-
-/**
- * nm_setting_connection_get_id:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:id property of the connection.
- *
- * Returns: the connection ID
- **/
-const char *
-nm_setting_connection_get_id (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->id;
-}
-
-/**
- * nm_setting_connection_get_uuid:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:uuid property of the connection.
- *
- * Returns: the connection UUID
- **/
-const char *
-nm_setting_connection_get_uuid (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->uuid;
-}
-
-/**
- * nm_setting_connection_get_interface_name:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:interface-name property of the connection.
- *
- * Returns: the connection's interface name
- *
- * Since: 0.9.10
- **/
-const char *
-nm_setting_connection_get_interface_name (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->interface_name;
-}
-
-/**
- * nm_setting_connection_get_connection_type:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:type property of the connection.
- *
- * Returns: the connection type
- **/
-const char *
-nm_setting_connection_get_connection_type (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->type;
-}
-
-/**
- * nm_setting_connection_get_num_permissions:
- * @setting: the #NMSettingConnection
- *
- * Returns the number of entries in the #NMSettingConnection:permissions
- * property of this setting.
- *
- * Returns: the number of permissions entries
- */
-guint32
-nm_setting_connection_get_num_permissions (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
-
- return g_slist_length (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->permissions);
-}
-
-/**
- * nm_setting_connection_get_permission:
- * @setting: the #NMSettingConnection
- * @idx: the zero-based index of the permissions entry
- * @out_ptype: on return, the permission type (at this time, always "user")
- * @out_pitem: on return, the permission item (formatted according to @ptype, see
- * #NMSettingConnection:permissions for more detail
- * @out_detail: on return, the permission detail (at this time, always %NULL)
- *
- * Retrieve one of the entries of the #NMSettingConnection:permissions property
- * of this setting.
- *
- * Returns: %TRUE if a permission was returned, %FALSE if @idx was invalid
- */
-gboolean
-nm_setting_connection_get_permission (NMSettingConnection *setting,
- guint32 idx,
- const char **out_ptype,
- const char **out_pitem,
- const char **out_detail)
-{
- NMSettingConnectionPrivate *priv;
- Permission *p;
-
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
-
- g_return_val_if_fail (idx < g_slist_length (priv->permissions), FALSE);
-
- p = g_slist_nth_data (priv->permissions, idx);
- if (out_ptype)
- *out_ptype = "user";
- if (out_pitem)
- *out_pitem = p->item;
- if (out_detail)
- *out_detail = NULL;
-
- return TRUE;
-}
-
-/**
- * nm_setting_connection_permissions_user_allowed:
- * @setting: the #NMSettingConnection
- * @uname: the user name to check permissions for
- *
- * Checks whether the given username is allowed to view/access this connection.
- *
- * Returns: %TRUE if the requested user is allowed to view this connection,
- * %FALSE if the given user is not allowed to view this connection
- */
-gboolean
-nm_setting_connection_permissions_user_allowed (NMSettingConnection *setting,
- const char *uname)
-{
- NMSettingConnectionPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
- g_return_val_if_fail (uname != NULL, FALSE);
- g_return_val_if_fail (*uname != '\0', FALSE);
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
-
- /* If no permissions, visible to all */
- if (priv->permissions == NULL)
- return TRUE;
-
- /* Find the username in the permissions list */
- for (iter = priv->permissions; iter; iter = g_slist_next (iter)) {
- Permission *p = iter->data;
-
- if (strcmp (uname, p->item) == 0)
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- * nm_setting_connection_add_permission:
- * @setting: the #NMSettingConnection
- * @ptype: the permission type; at this time only "user" is supported
- * @pitem: the permission item formatted as required for @ptype
- * @detail: (allow-none): unused at this time; must be %NULL
- *
- * Adds a permission to the connection's permission list. At this time, only
- * the "user" permission type is supported, and @pitem must be a username. See
- * #NMSettingConnection:permissions: for more details.
- *
- * Returns: %TRUE if the permission was unique and was successfully added to the
- * list, %FALSE if @ptype or @pitem was invalid or it the permission was already
- * present in the list
- */
-gboolean
-nm_setting_connection_add_permission (NMSettingConnection *setting,
- const char *ptype,
- const char *pitem,
- const char *detail)
-{
- NMSettingConnectionPrivate *priv;
- Permission *p;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
- g_return_val_if_fail (ptype, FALSE);
- g_return_val_if_fail (strlen (ptype) > 0, FALSE);
- g_return_val_if_fail (detail == NULL, FALSE);
-
- /* Only "user" for now... */
- g_return_val_if_fail (strcmp (ptype, "user") == 0, FALSE);
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
-
- /* No dupes */
- for (iter = priv->permissions; iter; iter = g_slist_next (iter)) {
- p = iter->data;
- if (strcmp (pitem, p->item) == 0)
- return FALSE;
- }
-
- p = permission_new (pitem);
- g_return_val_if_fail (p != NULL, FALSE);
- priv->permissions = g_slist_append (priv->permissions, p);
- g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_PERMISSIONS);
-
- return TRUE;
-}
-
-/**
- * nm_setting_connection_remove_permission:
- * @setting: the #NMSettingConnection
- * @idx: the zero-based index of the permission to remove
- *
- * Removes the permission at index @idx from the connection.
- */
-void
-nm_setting_connection_remove_permission (NMSettingConnection *setting,
- guint32 idx)
-{
- NMSettingConnectionPrivate *priv;
- GSList *iter;
-
- g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
- iter = g_slist_nth (priv->permissions, idx);
- g_return_if_fail (iter != NULL);
-
- permission_free ((Permission *) iter->data);
- priv->permissions = g_slist_delete_link (priv->permissions, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_PERMISSIONS);
-}
-
-/**
- * nm_setting_connection_remove_permission_by_value:
- * @setting: the #NMSettingConnection
- * @ptype: the permission type; at this time only "user" is supported
- * @pitem: the permission item formatted as required for @ptype
- * @detail: (allow-none): unused at this time; must be %NULL
- *
- * Removes the permission from the connection.
- * At this time, only the "user" permission type is supported, and @pitem must
- * be a username. See #NMSettingConnection:permissions: for more details.
- *
- * Returns: %TRUE if the permission was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- */
-gboolean
-nm_setting_connection_remove_permission_by_value (NMSettingConnection *setting,
- const char *ptype,
- const char *pitem,
- const char *detail)
-{
- NMSettingConnectionPrivate *priv;
- Permission *p;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
- g_return_val_if_fail (ptype, FALSE);
- g_return_val_if_fail (strlen (ptype) > 0, FALSE);
- g_return_val_if_fail (detail == NULL, FALSE);
-
- /* Only "user" for now... */
- g_return_val_if_fail (strcmp (ptype, "user") == 0, FALSE);
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
- for (iter = priv->permissions; iter; iter = g_slist_next (iter)) {
- p = iter->data;
- if (strcmp (pitem, p->item) == 0) {
- permission_free ((Permission *) iter->data);
- priv->permissions = g_slist_delete_link (priv->permissions, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_PERMISSIONS);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_connection_get_autoconnect:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:autoconnect property of the connection.
- *
- * Returns: the connection's autoconnect behavior
- **/
-gboolean
-nm_setting_connection_get_autoconnect (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect;
-}
-
-/**
- * nm_setting_connection_get_timestamp:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:timestamp property of the connection.
- *
- * Returns: the connection's timestamp
- **/
-guint64
-nm_setting_connection_get_timestamp (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->timestamp;
-}
-
-/**
- * nm_setting_connection_get_read_only:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:read-only property of the connection.
- *
- * Returns: %TRUE if the connection is read-only, %FALSE if it is not
- **/
-gboolean
-nm_setting_connection_get_read_only (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), TRUE);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->read_only;
-}
-
-/**
- * nm_setting_connection_get_zone:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:zone property of the connection.
- *
- * Returns: the trust level of a connection
- **/
-const char *
-nm_setting_connection_get_zone (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->zone;
-}
-
-/**
- * nm_setting_connection_get_master:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:master property of the connection.
- *
- * Returns: interface name of the master device or UUID of the master
- * connection.
- */
-const char *
-nm_setting_connection_get_master (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->master;
-}
-
-/**
- * nm_setting_connection_get_slave_type:
- * @setting: the #NMSettingConnection
- *
- * Returns the #NMSettingConnection:slave-type property of the connection.
- *
- * Returns: the type of slave this connection is, if any
- */
-const char *
-nm_setting_connection_get_slave_type (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->slave_type;
-}
-
-/**
- * nm_setting_connection_is_slave_type:
- * @setting: the #NMSettingConnection
- * @type: the setting name (ie #NM_SETTING_BOND_SETTING_NAME) to be matched
- * against @setting's slave type
- *
- * Returns: %TRUE if connection is of the given slave @type
- */
-gboolean
-nm_setting_connection_is_slave_type (NMSettingConnection *setting,
- const char *type)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
-
- return !g_strcmp0 (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->slave_type, type);
-}
-
-/**
- * nm_setting_connection_get_num_secondaries:
- * @setting: the #NMSettingConnection
- *
- * Returns: the number of configured secondary connection UUIDs
- *
- * Since: 0.9.8
- **/
-guint32
-nm_setting_connection_get_num_secondaries (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
-
- return g_slist_length (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->secondaries);
-}
-
-/**
- * nm_setting_connection_get_secondary:
- * @setting: the #NMSettingConnection
- * @idx: the zero-based index of the secondary connection UUID entry
- *
- * Returns: the secondary connection UUID at index @idx
- *
- * Since: 0.9.8
- **/
-const char *
-nm_setting_connection_get_secondary (NMSettingConnection *setting, guint32 idx)
-{
- NMSettingConnectionPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
- g_return_val_if_fail (idx <= g_slist_length (priv->secondaries), NULL);
-
- return (const char *) g_slist_nth_data (priv->secondaries, idx);
-}
-
-/**
- * nm_setting_connection_add_secondary:
- * @setting: the #NMSettingConnection
- * @sec_uuid: the secondary connection UUID to add
- *
- * Adds a new secondary connection UUID to the setting.
- *
- * Returns: %TRUE if the secondary connection UUID was added; %FALSE if the UUID
- * was already present
- *
- * Since: 0.9.8
- **/
-gboolean
-nm_setting_connection_add_secondary (NMSettingConnection *setting,
- const char *sec_uuid)
-{
- NMSettingConnectionPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
- g_return_val_if_fail (sec_uuid != NULL, FALSE);
- g_return_val_if_fail (sec_uuid[0] != '\0', FALSE);
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
- for (iter = priv->secondaries; iter; iter = g_slist_next (iter)) {
- if (!strcmp (sec_uuid, (char *) iter->data))
- return FALSE;
- }
-
- priv->secondaries = g_slist_append (priv->secondaries, g_strdup (sec_uuid));
- g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES);
- return TRUE;
-}
-
-/**
- * nm_setting_connection_remove_secondary:
- * @setting: the #NMSettingConnection
- * @idx: index number of the secondary connection UUID
- *
- * Removes the secondary coonnection UUID at index @idx.
- *
- * Since: 0.9.8
- **/
-void
-nm_setting_connection_remove_secondary (NMSettingConnection *setting, guint32 idx)
-{
- NMSettingConnectionPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->secondaries, idx);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->secondaries = g_slist_delete_link (priv->secondaries, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES);
-}
-
-/**
- * nm_setting_connection_remove_secondary_by_value:
- * @setting: the #NMSettingConnection
- * @sec_uuid: the secondary connection UUID to remove
- *
- * Removes the secondary coonnection UUID @sec_uuid.
- *
- * Returns: %TRUE if the secondary connection UUID was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_connection_remove_secondary_by_value (NMSettingConnection *setting,
- const char *sec_uuid)
-{
- NMSettingConnectionPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
- g_return_val_if_fail (sec_uuid != NULL, FALSE);
- g_return_val_if_fail (sec_uuid[0] != '\0', FALSE);
-
- priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
- for (iter = priv->secondaries; iter; iter = g_slist_next (iter)) {
- if (!strcmp (sec_uuid, (char *) iter->data)) {
- priv->secondaries = g_slist_delete_link (priv->secondaries, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_connection_get_gateway_ping_timeout:
- * @setting: the #NMSettingConnection
- *
- * Returns: the value contained in the #NMSettingConnection:gateway-ping-timeout
- * property.
- *
- * Since: 0.9.10
- **/
-guint32
-nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
-
- return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->gateway_ping_timeout;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
- gboolean is_slave;
- GSList *iter;
-
- if (!priv->id) {
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_ID);
- return FALSE;
- } else if (!strlen (priv->id)) {
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_ID);
- return FALSE;
- }
-
- if (!priv->uuid) {
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_UUID);
- return FALSE;
- } else if (!nm_utils_is_uuid (priv->uuid)) {
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid UUID"),
- priv->uuid);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_UUID);
- return FALSE;
- }
-
- /* FIXME: previously, verify() set the NMSettingConnection:interface_name property,
- * thus modifying the setting. verify() should not do this, but keep this not to change
- * behaviour.
- */
- if (!priv->interface_name) {
- for (iter = all_settings; iter; iter = iter->next) {
- NMSetting *s_current = iter->data;
- char *virtual_iface_name = NULL;
-
- if (NM_IS_SETTING_BOND (s_current))
- g_object_get (s_current, NM_SETTING_BOND_INTERFACE_NAME, &virtual_iface_name, NULL);
- else if (NM_IS_SETTING_BRIDGE (s_current))
- g_object_get (s_current, NM_SETTING_BRIDGE_INTERFACE_NAME, &virtual_iface_name, NULL);
- else if (NM_IS_SETTING_TEAM (s_current))
- g_object_get (s_current, NM_SETTING_TEAM_INTERFACE_NAME, &virtual_iface_name, NULL);
- else if (NM_IS_SETTING_VLAN (s_current))
- g_object_get (s_current, NM_SETTING_VLAN_INTERFACE_NAME, &virtual_iface_name, NULL);
- /* For NMSettingInfiniband, virtual_iface_name has no backing field.
- * No need to set the (unset) interface_name to the default value.
- **/
-
- if (virtual_iface_name) {
- if (nm_utils_iface_valid_name (virtual_iface_name)) {
- /* found a new interface name. */
- priv->interface_name = virtual_iface_name;
- break;
- }
- g_free (virtual_iface_name);
- }
- }
- }
-
- if (priv->interface_name) {
- if (!nm_utils_iface_valid_name (priv->interface_name)) {
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid interface name"),
- priv->interface_name);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
- return FALSE;
- }
- }
-
- if (!priv->type) {
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
- return FALSE;
- } else if (!strlen (priv->type)) {
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
- return FALSE;
- }
-
- /* Make sure the corresponding 'type' item is present */
- if (all_settings && !nm_setting_find_in_list (all_settings, priv->type)) {
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND,
- _("requires presence of '%s' setting in the connection"),
- priv->type);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
- return FALSE;
- }
-
- is_slave = ( priv->slave_type
- && ( !strcmp (priv->slave_type, NM_SETTING_BOND_SETTING_NAME)
- || !strcmp (priv->slave_type, NM_SETTING_BRIDGE_SETTING_NAME)
- || !strcmp (priv->slave_type, NM_SETTING_TEAM_SETTING_NAME)));
-
- if (priv->slave_type && !is_slave) {
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("Unknown slave type '%s'"), priv->slave_type);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE);
- return NM_SETTING_VERIFY_ERROR;
- }
-
- if (is_slave) {
- if (!priv->master) {
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
- _("Slave connections need a valid '%s' property"),
- NM_SETTING_CONNECTION_MASTER);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER);
- return NM_SETTING_VERIFY_ERROR;
- }
- } else {
- if (priv->master) {
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
- _("Cannot set '%s' without '%s'"),
- NM_SETTING_CONNECTION_MASTER, NM_SETTING_CONNECTION_SLAVE_TYPE);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE);
- return NM_SETTING_VERIFY_ERROR;
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-compare_property (NMSetting *setting,
- NMSetting *other,
- const GParamSpec *prop_spec,
- NMSettingCompareFlags flags)
-{
- /* Handle ignore ID */
- if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_ID)
- && g_strcmp0 (prop_spec->name, NM_SETTING_CONNECTION_ID) == 0)
- return TRUE;
-
- return NM_SETTING_CLASS (nm_setting_connection_parent_class)->compare_property (setting, other, prop_spec, flags);
-}
-
-static void
-nm_setting_connection_init (NMSettingConnection *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (object);
-
- g_free (priv->id);
- g_free (priv->uuid);
- g_free (priv->interface_name);
- g_free (priv->type);
- g_free (priv->zone);
- g_free (priv->master);
- g_free (priv->slave_type);
- g_slist_free_full (priv->permissions, (GDestroyNotify) permission_free);
- g_slist_free_full (priv->secondaries, g_free);
-
- G_OBJECT_CLASS (nm_setting_connection_parent_class)->finalize (object);
-}
-
-static GSList *
-perm_stringlist_to_permlist (GSList *strlist)
-{
- GSList *list = NULL, *iter;
-
- for (iter = strlist; iter; iter = g_slist_next (iter)) {
- Permission *p;
-
- p = permission_new_from_str ((const char *) iter->data);
- if (p)
- list = g_slist_append (list, p);
- }
-
- return list;
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_ID:
- g_free (priv->id);
- priv->id = g_value_dup_string (value);
- break;
- case PROP_UUID:
- g_free (priv->uuid);
- priv->uuid = g_value_dup_string (value);
- break;
- case PROP_INTERFACE_NAME:
- g_free (priv->interface_name);
- priv->interface_name = g_value_dup_string (value);
- break;
- case PROP_TYPE:
- g_free (priv->type);
- priv->type = g_value_dup_string (value);
- break;
- case PROP_PERMISSIONS:
- g_slist_free_full (priv->permissions, (GDestroyNotify) permission_free);
- priv->permissions = perm_stringlist_to_permlist (g_value_get_boxed (value));
- break;
- case PROP_AUTOCONNECT:
- priv->autoconnect = g_value_get_boolean (value);
- break;
- case PROP_TIMESTAMP:
- priv->timestamp = g_value_get_uint64 (value);
- break;
- case PROP_READ_ONLY:
- priv->read_only = g_value_get_boolean (value);
- break;
- case PROP_ZONE:
- g_free (priv->zone);
- priv->zone = g_value_dup_string (value);
- break;
- case PROP_MASTER:
- g_free (priv->master);
- priv->master = g_value_dup_string (value);
- break;
- case PROP_SLAVE_TYPE:
- g_free (priv->slave_type);
- priv->slave_type = g_value_dup_string (value);
- break;
- case PROP_SECONDARIES:
- g_slist_free_full (priv->secondaries, g_free);
- priv->secondaries = g_value_dup_boxed (value);
- break;
- case PROP_GATEWAY_PING_TIMEOUT:
- priv->gateway_ping_timeout = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GSList *
-perm_permlist_to_stringlist (GSList *permlist)
-{
- GSList *list = NULL, *iter;
-
- for (iter = permlist; iter; iter = g_slist_next (iter))
- list = g_slist_append (list, permission_to_string ((Permission *) iter->data));
- return list;
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingConnection *setting = NM_SETTING_CONNECTION (object);
- NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_ID:
- g_value_set_string (value, nm_setting_connection_get_id (setting));
- break;
- case PROP_UUID:
- g_value_set_string (value, nm_setting_connection_get_uuid (setting));
- break;
- case PROP_INTERFACE_NAME:
- g_value_set_string (value, nm_setting_connection_get_interface_name (setting));
- break;
- case PROP_TYPE:
- g_value_set_string (value, nm_setting_connection_get_connection_type (setting));
- break;
- case PROP_PERMISSIONS:
- g_value_take_boxed (value, perm_permlist_to_stringlist (priv->permissions));
- break;
- case PROP_AUTOCONNECT:
- g_value_set_boolean (value, nm_setting_connection_get_autoconnect (setting));
- break;
- case PROP_TIMESTAMP:
- g_value_set_uint64 (value, nm_setting_connection_get_timestamp (setting));
- break;
- case PROP_READ_ONLY:
- g_value_set_boolean (value, nm_setting_connection_get_read_only (setting));
- break;
- case PROP_ZONE:
- g_value_set_string (value, nm_setting_connection_get_zone (setting));
- break;
- case PROP_MASTER:
- g_value_set_string (value, nm_setting_connection_get_master (setting));
- break;
- case PROP_SLAVE_TYPE:
- g_value_set_string (value, nm_setting_connection_get_slave_type (setting));
- break;
- case PROP_SECONDARIES:
- g_value_set_boxed (value, priv->secondaries);
- break;
- case PROP_GATEWAY_PING_TIMEOUT:
- g_value_set_uint (value, priv->gateway_ping_timeout);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingConnectionPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->compare_property = compare_property;
-
- /* Properties */
-
- /**
- * NMSettingConnection:id:
- *
- * A human readable unique identifier for the connection, like "Work Wi-Fi"
- * or "T-Mobile 3G".
- **/
- g_object_class_install_property
- (object_class, PROP_ID,
- g_param_spec_string (NM_SETTING_CONNECTION_ID, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:uuid:
- *
- * A universally unique identifier for the connection, for example generated
- * with libuuid. It should be assigned when the connection is created, and
- * never changed as long as the connection still applies to the same
- * network. For example, it should not be changed when the
- * #NMSettingConnection:id property or #NMSettingIP4Config changes, but
- * might need to be re-created when the Wi-Fi SSID, mobile broadband network
- * provider, or #NMSettingConnection:type property changes.
- *
- * The UUID must be in the format "2815492f-7e56-435e-b2e9-246bd7cdc664"
- * (ie, contains only hexadecimal characters and "-"). A suitable UUID may
- * be generated by nm_utils_uuid_generate() or
- * nm_utils_uuid_generate_from_string().
- **/
- g_object_class_install_property
- (object_class, PROP_UUID,
- g_param_spec_string (NM_SETTING_CONNECTION_UUID, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:interface-name:
- *
- * The name of the network interface this connection is bound to. If not
- * set, then the connection can be attached to any interface of the
- * appropriate type (subject to restrictions imposed by other settings).
- *
- * For software devices this specifies the name of the created device.
- *
- * For connection types where interface names cannot easily be made
- * persistent (e.g. mobile broadband or USB Ethernet), this property should
- * not be used. Setting this property restricts the interfaces a connection
- * can be used with, and if interface names change or are reordered the
- * connection may be applied to the wrong interface.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_INTERFACE_NAME,
- g_param_spec_string (NM_SETTING_CONNECTION_INTERFACE_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:type:
- *
- * Base type of the connection. For hardware-dependent connections, should
- * contain the setting name of the hardware-type specific setting (ie,
- * "802-3-ethernet" or "802-11-wireless" or "bluetooth", etc), and for
- * non-hardware dependent connections like VPN or otherwise, should contain
- * the setting name of that setting type (ie, "vpn" or "bridge", etc).
- **/
- g_object_class_install_property
- (object_class, PROP_TYPE,
- g_param_spec_string (NM_SETTING_CONNECTION_TYPE, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:permissions:
- *
- * An array of strings defining what access a given user has to this
- * connection. If this is %NULL or empty, all users are allowed to access
- * this connection. Otherwise a user is allowed to access this connection
- * if and only if they are in this list. Each entry is of the form
- * "[type]:[id]:[reserved]"; for example, "user:dcbw:blah".
- *
- * At this time only the "user" [type] is allowed. Any other values are
- * ignored and reserved for future use. [id] is the username that this
- * permission refers to, which may not contain the ":" character. Any
- * [reserved] information present must be ignored and is reserved for future
- * use. All of [type], [id], and [reserved] must be valid UTF-8.
- */
- g_object_class_install_property
- (object_class, PROP_PERMISSIONS,
- _nm_param_spec_specialized (NM_SETTING_CONNECTION_PERMISSIONS, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:autoconnect:
- *
- * Whether or not the connection should be automatically connected by
- * NetworkManager when the resources for the connection are available.
- * %TRUE to automatically activate the connection, %FALSE to require manual
- * intervention to activate the connection.
- **/
- g_object_class_install_property
- (object_class, PROP_AUTOCONNECT,
- g_param_spec_boolean (NM_SETTING_CONNECTION_AUTOCONNECT, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:timestamp:
- *
- * The time, in seconds since the Unix Epoch, that the connection was last
- * _successfully_ fully activated.
- *
- * NetworkManager updates the connection timestamp periodically when the
- * connection is active to ensure that an active connection has the latest
- * timestamp. The property is only meant for reading (changes to this
- * property will not be preserved).
- **/
- g_object_class_install_property
- (object_class, PROP_TIMESTAMP,
- g_param_spec_uint64 (NM_SETTING_CONNECTION_TIMESTAMP, "", "",
- 0, G_MAXUINT64, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:read-only:
- *
- * %FALSE if the connection can be modified using the provided settings
- * service's D-Bus interface with the right privileges, or %TRUE if the
- * connection is read-only and cannot be modified.
- **/
- g_object_class_install_property
- (object_class, PROP_READ_ONLY,
- g_param_spec_boolean (NM_SETTING_CONNECTION_READ_ONLY, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:zone:
- *
- * The trust level of a the connection. Free form case-insensitive string
- * (for example "Home", "Work", "Public"). %NULL or unspecified zone means
- * the connection will be placed in the default zone as defined by the
- * firewall.
- **/
- g_object_class_install_property
- (object_class, PROP_ZONE,
- g_param_spec_string (NM_SETTING_CONNECTION_ZONE, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:master:
- *
- * Interface name of the master device or UUID of the master connection.
- **/
- g_object_class_install_property
- (object_class, PROP_MASTER,
- g_param_spec_string (NM_SETTING_CONNECTION_MASTER, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:slave-type:
- *
- * Setting name of the device type of this slave's master connection (eg,
- * %NM_SETTING_BOND_SETTING_NAME), or %NULL if this connection is not a
- * slave.
- **/
- g_object_class_install_property
- (object_class, PROP_SLAVE_TYPE,
- g_param_spec_string (NM_SETTING_CONNECTION_SLAVE_TYPE, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:secondaries:
- *
- * List of connection UUIDs that should be activated when the base
- * connection itself is activated. Currently only VPN connections are
- * supported.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_SECONDARIES,
- _nm_param_spec_specialized (NM_SETTING_CONNECTION_SECONDARIES, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingConnection:gateway-ping-timeout:
- *
- * If greater than zero, delay success of IP addressing until either the
- * timeout is reached, or an IP gateway replies to a ping.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_GATEWAY_PING_TIMEOUT,
- g_param_spec_uint (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, "", "",
- 0, 30, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-connection.h b/libnm-util/nm-setting-connection.h
deleted file mode 100644
index 143fa11d58..0000000000
--- a/libnm-util/nm-setting-connection.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_CONNECTION_H
-#define NM_SETTING_CONNECTION_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_CONNECTION (nm_setting_connection_get_type ())
-#define NM_SETTING_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_CONNECTION, NMSettingConnection))
-#define NM_SETTING_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_CONNECTION, NMSettingConnectionClass))
-#define NM_IS_SETTING_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_CONNECTION))
-#define NM_IS_SETTING_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_CONNECTION))
-#define NM_SETTING_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_CONNECTION, NMSettingConnectionClass))
-
-#define NM_SETTING_CONNECTION_SETTING_NAME "connection"
-
-/**
- * NMSettingConnectionError:
- * @NM_SETTING_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY: the property's value is
- * invalid
- * @NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY: a required property is not
- * present
- * @NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND: the #NMSetting object
- * referenced by the setting name contained in the
- * #NMSettingConnection:type property was not present in the #NMConnection
- * @NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED: ip configuration is not
- * allowed to be present.
- *
- * Describes errors that may result from operations involving a
- * #NMSettingConnection.
- *
- **/
-typedef enum
-{
- NM_SETTING_CONNECTION_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, /*< nick=TypeSettingNotFound >*/
- NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED, /*< nick=IpConfigNotAllowed >*/
-} NMSettingConnectionError;
-
-#define NM_SETTING_CONNECTION_ERROR nm_setting_connection_error_quark ()
-GQuark nm_setting_connection_error_quark (void);
-
-#define NM_SETTING_CONNECTION_ID "id"
-#define NM_SETTING_CONNECTION_UUID "uuid"
-#define NM_SETTING_CONNECTION_INTERFACE_NAME "interface-name"
-#define NM_SETTING_CONNECTION_TYPE "type"
-#define NM_SETTING_CONNECTION_AUTOCONNECT "autoconnect"
-#define NM_SETTING_CONNECTION_TIMESTAMP "timestamp"
-#define NM_SETTING_CONNECTION_READ_ONLY "read-only"
-#define NM_SETTING_CONNECTION_PERMISSIONS "permissions"
-#define NM_SETTING_CONNECTION_ZONE "zone"
-#define NM_SETTING_CONNECTION_MASTER "master"
-#define NM_SETTING_CONNECTION_SLAVE_TYPE "slave-type"
-#define NM_SETTING_CONNECTION_SECONDARIES "secondaries"
-#define NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT "gateway-ping-timeout"
-
-/**
- * NMSettingConnection:
- *
- * The NMSettingConnection struct contains only private data.
- * It should only be accessed through the functions described below.
- */
-typedef struct {
- NMSetting parent;
-} NMSettingConnection;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingConnectionClass;
-
-GType nm_setting_connection_get_type (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_0_9_10
-const char *nm_setting_connection_get_interface_name (NMSettingConnection *setting);
-const char *nm_setting_connection_get_connection_type (NMSettingConnection *setting);
-gboolean nm_setting_connection_get_autoconnect (NMSettingConnection *setting);
-guint64 nm_setting_connection_get_timestamp (NMSettingConnection *setting);
-gboolean nm_setting_connection_get_read_only (NMSettingConnection *setting);
-
-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 *nm_setting_connection_get_zone (NMSettingConnection *setting);
-gboolean nm_setting_connection_permissions_user_allowed (NMSettingConnection *setting, const char *uname);
-gboolean nm_setting_connection_add_permission (NMSettingConnection *setting,
- const char *ptype,
- const char *pitem,
- const char *detail);
-void nm_setting_connection_remove_permission (NMSettingConnection *setting,
- guint32 idx);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_connection_remove_permission_by_value (NMSettingConnection *setting,
- 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);
-const char *nm_setting_connection_get_slave_type (NMSettingConnection *setting);
-
-guint32 nm_setting_connection_get_num_secondaries (NMSettingConnection *setting);
-const char *nm_setting_connection_get_secondary (NMSettingConnection *setting, guint32 idx);
-gboolean nm_setting_connection_add_secondary (NMSettingConnection *setting, const char *sec_uuid);
-void nm_setting_connection_remove_secondary (NMSettingConnection *setting, guint32 idx);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_connection_remove_secondary_by_value (NMSettingConnection *setting, const char *sec_uuid);
-
-NM_AVAILABLE_IN_0_9_10
-guint32 nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_CONNECTION_H */
diff --git a/libnm-util/nm-setting-dcb.c b/libnm-util/nm-setting-dcb.c
deleted file mode 100644
index c3cf89dd7f..0000000000
--- a/libnm-util/nm-setting-dcb.c
+++ /dev/null
@@ -1,1219 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-dcb.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-dcb
- * @short_description: Connection properties for Data Center Bridging
- * @include: nm-setting-dcb.h
- *
- * The #NMSettingDcb object is a #NMSetting subclass that describes properties
- * for enabling and using Data Center Bridging (DCB) on Ethernet networks.
- * DCB is a set of protocols (including 802.1Qbb, 802.1Qaz, 802.1Qau, and
- * 802.1AB) to eliminate packet loss in Ethernet networks and support the use
- * of storage technologies like Fibre Channel over Ethernet (FCoE) and iSCSI.
- *
- * Since: 0.9.10
- **/
-
-/**
- * nm_setting_dcb_error_quark:
- *
- * Registers an error quark for #NMSettingDcb if necessary.
- *
- * Returns: the error quark used for #NMSettingDcb errors.
- *
- * Since: 0.9.10
- **/
-GQuark
-nm_setting_dcb_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-dcb-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingDcb, nm_setting_dcb, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_DCB_SETTING_NAME,
- g_define_type_id,
- 2,
- NM_SETTING_DCB_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_DCB)
-
-#define NM_SETTING_DCB_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_DCB, NMSettingDcbPrivate))
-
-typedef struct {
- NMSettingDcbFlags app_fcoe_flags;
- int app_fcoe_priority;
- char * app_fcoe_mode;
-
- NMSettingDcbFlags app_iscsi_flags;
- int app_iscsi_priority;
-
- NMSettingDcbFlags app_fip_flags;
- int app_fip_priority;
-
- /* Priority Flow Control */
- NMSettingDcbFlags pfc_flags;
- guint pfc[8];
-
- /* Priority Groups */
- NMSettingDcbFlags priority_group_flags;
- guint priority_group_id[8];
- guint priority_group_bandwidth[8];
- guint priority_bandwidth[8];
- guint priority_strict[8];
- guint priority_traffic_class[8];
-} NMSettingDcbPrivate;
-
-enum {
- PROP_0,
- PROP_APP_FCOE_FLAGS,
- PROP_APP_FCOE_PRIORITY,
- PROP_APP_FCOE_MODE,
-
- PROP_APP_ISCSI_FLAGS,
- PROP_APP_ISCSI_PRIORITY,
-
- PROP_APP_FIP_FLAGS,
- PROP_APP_FIP_PRIORITY,
-
- PROP_PFC_FLAGS,
- PROP_PFC,
-
- PROP_PRIORITY_GROUP_FLAGS,
- PROP_PRIORITY_GROUP_ID,
- PROP_PRIORITY_GROUP_BANDWIDTH,
- PROP_PRIORITY_BANDWIDTH,
- PROP_PRIORITY_STRICT,
- PROP_PRIORITY_TRAFFIC_CLASS,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_dcb_new:
- *
- * Creates a new #NMSettingDcb object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingDcb object
- *
- * Since: 0.9.10
- **/
-NMSetting *
-nm_setting_dcb_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_DCB, NULL);
-}
-
-/**
- * nm_setting_dcb_get_app_fcoe_flags:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:app-fcoe-flags property of the setting
- *
- * Since: 0.9.10
- **/
-NMSettingDcbFlags
-nm_setting_dcb_get_app_fcoe_flags (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_flags;
-}
-
-/**
- * nm_setting_dcb_get_app_fcoe_priority:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:app-fcoe-priority property of the setting
- *
- * Since: 0.9.10
- **/
-int
-nm_setting_dcb_get_app_fcoe_priority (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_priority;
-}
-
-/**
- * nm_setting_dcb_get_app_fcoe_mode:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:app-fcoe-mode property of the setting
- *
- * Since: 0.9.10
- **/
-const char *
-nm_setting_dcb_get_app_fcoe_mode (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), NULL);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_mode;
-}
-
-/**
- * nm_setting_dcb_get_app_iscsi_flags:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:app-iscsi-flags property of the setting
- *
- * Since: 0.9.10
- **/
-NMSettingDcbFlags
-nm_setting_dcb_get_app_iscsi_flags (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->app_iscsi_flags;
-}
-
-/**
- * nm_setting_dcb_get_app_iscsi_priority:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:app-iscsi-priority property of the setting
- *
- * Since: 0.9.10
- **/
-int
-nm_setting_dcb_get_app_iscsi_priority (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->app_iscsi_priority;
-}
-
-/**
- * nm_setting_dcb_get_app_fip_flags:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:app-fip-flags property of the setting
- *
- * Since: 0.9.10
- **/
-NMSettingDcbFlags
-nm_setting_dcb_get_app_fip_flags (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fip_flags;
-}
-
-/**
- * nm_setting_dcb_get_app_fip_priority:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:app-fip-priority property of the setting
- *
- * Since: 0.9.10
- **/
-int
-nm_setting_dcb_get_app_fip_priority (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fip_priority;
-}
-
-/**
- * nm_setting_dcb_get_priority_flow_control_flags:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:priority-flow-control-flags property of the setting
- *
- * Since: 0.9.10
- **/
-NMSettingDcbFlags
-nm_setting_dcb_get_priority_flow_control_flags (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->pfc_flags;
-}
-
-/**
- * nm_setting_dcb_get_priority_flow_control:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to retrieve flow control for
- *
- * Returns: %TRUE if flow control is enabled for the given @user_priority,
- * %FALSE if not enabled
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_dcb_get_priority_flow_control (NMSettingDcb *setting, guint user_priority)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), FALSE);
- g_return_val_if_fail (user_priority <= 7, FALSE);
-
- return !!NM_SETTING_DCB_GET_PRIVATE (setting)->pfc[user_priority];
-}
-
-/**
- * nm_setting_dcb_set_priority_flow_control:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to set flow control for
- * @enabled: %TRUE to enable flow control for this priority, %FALSE to disable it
- *
- * These values are only valid when #NMSettingDcb:priority-flow-control includes
- * the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_dcb_set_priority_flow_control (NMSettingDcb *setting,
- guint user_priority,
- gboolean enabled)
-{
- NMSettingDcbPrivate *priv;
- guint uint_enabled = enabled ? 1 : 0;
-
- g_return_if_fail (NM_IS_SETTING_DCB (setting));
- g_return_if_fail (user_priority <= 7);
-
- priv = NM_SETTING_DCB_GET_PRIVATE (setting);
- if (priv->pfc[user_priority] != uint_enabled) {
- priv->pfc[user_priority] = uint_enabled;
- g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL);
- }
-}
-
-/**
- * nm_setting_dcb_get_priority_group_flags:
- * @setting: the #NMSettingDcb
- *
- * Returns: the #NMSettingDcb:priority-group-flags property of the setting
- *
- * Since: 0.9.10
- **/
-NMSettingDcbFlags
-nm_setting_dcb_get_priority_group_flags (NMSettingDcb *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_flags;
-}
-
-/**
- * nm_setting_dcb_get_priority_group_id:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to retrieve the group ID for
- *
- * Returns: the group number @user_priority is assigned to. These values are
- * only valid when #NMSettingDcb:priority-group-flags includes the
- * %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-guint
-nm_setting_dcb_get_priority_group_id (NMSettingDcb *setting, guint user_priority)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
- g_return_val_if_fail (user_priority <= 7, 0);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_id[user_priority];
-}
-
-/**
- * nm_setting_dcb_set_priority_group_id:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to set flow control for
- * @group_id: the group (0 - 7) to assign @user_priority to, or 15 for the
- * unrestricted group.
- *
- * These values are only valid when #NMSettingDcb:priority-group-flags includes
- * the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_dcb_set_priority_group_id (NMSettingDcb *setting,
- guint user_priority,
- guint group_id)
-{
- NMSettingDcbPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_DCB (setting));
- g_return_if_fail (user_priority <= 7);
- g_return_if_fail (group_id <= 7 || group_id == 15);
-
- priv = NM_SETTING_DCB_GET_PRIVATE (setting);
- if (priv->priority_group_id[user_priority] != group_id) {
- priv->priority_group_id[user_priority] = group_id;
- g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_GROUP_ID);
- }
-}
-
-/**
- * nm_setting_dcb_get_priority_group_bandwidth:
- * @setting: the #NMSettingDcb
- * @group_id: the priority group (0 - 7) to retrieve the bandwidth percentage for
- *
- * Returns: the bandwidth percentage assigned to @group_id. These values are
- * only valid when #NMSettingDcb:priority-group-flags includes the
- * %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-guint
-nm_setting_dcb_get_priority_group_bandwidth (NMSettingDcb *setting, guint group_id)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
- g_return_val_if_fail (group_id <= 7, FALSE);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_bandwidth[group_id];
-}
-
-/**
- * nm_setting_dcb_set_priority_group_bandwidth:
- * @setting: the #NMSettingDcb
- * @group_id: the priority group (0 - 7) to set the bandwidth percentage for
- * @bandwidth_percent: the bandwidth percentage (0 - 100) to assign to @group_id to
- *
- * These values are only valid when #NMSettingDcb:priority-group-flags includes
- * the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_dcb_set_priority_group_bandwidth (NMSettingDcb *setting,
- guint group_id,
- guint bandwidth_percent)
-{
- NMSettingDcbPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_DCB (setting));
- g_return_if_fail (group_id <= 7);
- g_return_if_fail (bandwidth_percent <= 100);
-
- priv = NM_SETTING_DCB_GET_PRIVATE (setting);
- if (priv->priority_group_bandwidth[group_id] != bandwidth_percent) {
- priv->priority_group_bandwidth[group_id] = bandwidth_percent;
- g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH);
- }
-}
-
-/**
- * nm_setting_dcb_get_priority_bandwidth:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to retrieve the group bandwidth percentage for
- *
- * Returns: the allowed bandwidth percentage of @user_priority in its priority group.
- * These values are only valid when #NMSettingDcb:priority-group-flags includes the
- * %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-guint
-nm_setting_dcb_get_priority_bandwidth (NMSettingDcb *setting, guint user_priority)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
- g_return_val_if_fail (user_priority <= 7, FALSE);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_bandwidth[user_priority];
-}
-
-/**
- * nm_setting_dcb_set_priority_bandwidth:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to set the bandwidth percentage for
- * @bandwidth_percent: the bandwidth percentage (0 - 100) that @user_priority is
- * allowed to use within its priority group
- *
- * These values are only valid when #NMSettingDcb:priority-group-flags includes
- * the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_dcb_set_priority_bandwidth (NMSettingDcb *setting,
- guint user_priority,
- guint bandwidth_percent)
-{
- NMSettingDcbPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_DCB (setting));
- g_return_if_fail (user_priority <= 7);
- g_return_if_fail (bandwidth_percent <= 100);
-
- priv = NM_SETTING_DCB_GET_PRIVATE (setting);
- if (priv->priority_bandwidth[user_priority] != bandwidth_percent) {
- priv->priority_bandwidth[user_priority] = bandwidth_percent;
- g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_BANDWIDTH);
- }
-}
-
-/**
- * nm_setting_dcb_get_priority_strict_bandwidth:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to retrieve strict bandwidth for
- *
- * Returns: %TRUE if @user_priority may use all of the bandwidth allocated to its
- * assigned group, or %FALSE if not. These values are only valid when
- * #NMSettingDcb:priority-group-flags includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_dcb_get_priority_strict_bandwidth (NMSettingDcb *setting, guint user_priority)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
- g_return_val_if_fail (user_priority <= 7, FALSE);
-
- return !!NM_SETTING_DCB_GET_PRIVATE (setting)->priority_strict[user_priority];
-}
-
-/**
- * nm_setting_dcb_set_priority_strict_bandwidth:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to set strict bandwidth for
- * @strict: %TRUE to allow @user_priority to use all the bandwidth allocated to
- * its priority group, or %FALSE if not
- *
- * These values are only valid when #NMSettingDcb:priority-group-flags includes
- * the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_dcb_set_priority_strict_bandwidth (NMSettingDcb *setting,
- guint user_priority,
- gboolean strict)
-{
- NMSettingDcbPrivate *priv;
- guint uint_strict = strict ? 1 : 0;
-
- g_return_if_fail (NM_IS_SETTING_DCB (setting));
- g_return_if_fail (user_priority <= 7);
-
- priv = NM_SETTING_DCB_GET_PRIVATE (setting);
- if (priv->priority_strict[user_priority] != uint_strict) {
- priv->priority_strict[user_priority] = uint_strict;
- g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH);
- }
-}
-
-/**
- * nm_setting_dcb_get_priority_traffic_class:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to retrieve the traffic class for
- *
- * Returns: the traffic class assigned to @user_priority. These values are only
- * valid when #NMSettingDcb:priority-group-flags includes the
- * %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-guint
-nm_setting_dcb_get_priority_traffic_class (NMSettingDcb *setting, guint user_priority)
-{
- g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
- g_return_val_if_fail (user_priority <= 7, FALSE);
-
- return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_traffic_class[user_priority];
-}
-
-/**
- * nm_setting_dcb_set_priority_traffic_clas:
- * @setting: the #NMSettingDcb
- * @user_priority: the User Priority (0 - 7) to set the bandwidth percentage for
- * @traffic_class: the traffic_class (0 - 7) that @user_priority should map to
- *
- * These values are only valid when #NMSettingDcb:priority-group-flags includes
- * the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_dcb_set_priority_traffic_class (NMSettingDcb *setting,
- guint user_priority,
- guint traffic_class)
-{
- NMSettingDcbPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_DCB (setting));
- g_return_if_fail (user_priority <= 7);
- g_return_if_fail (traffic_class <= 7);
-
- priv = NM_SETTING_DCB_GET_PRIVATE (setting);
- if (priv->priority_traffic_class[user_priority] != traffic_class) {
- priv->priority_traffic_class[user_priority] = traffic_class;
- g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS);
- }
-}
-
-/*****************************************************************************/
-
-#define DCB_FLAGS_ALL (NM_SETTING_DCB_FLAG_ENABLE | \
- NM_SETTING_DCB_FLAG_ADVERTISE | \
- NM_SETTING_DCB_FLAG_WILLING)
-
-static gboolean
-check_dcb_flags (NMSettingDcbFlags flags, const char *prop_name, GError **error)
-{
- if (flags & ~DCB_FLAGS_ALL) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
- _("flags invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
- return FALSE;
- }
-
- if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && (flags & ~NM_SETTING_DCB_FLAG_ENABLE)) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
- _("flags invalid - disabled"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-check_uint_array (const guint *array,
- guint len,
- NMSettingDcbFlags flags,
- guint max,
- guint extra,
- gboolean sum_pct,
- const char *prop_name,
- GError **error)
-{
- guint i, sum = 0;
-
- /* Ensure each element is <= to max or equals extra */
- for (i = 0; i < len; i++) {
- if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && array[i]) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
- _("property invalid (not enabled)"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
- return FALSE;
- }
-
- if ((array[i] > max) && (array[i] != extra)) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
- _("element invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
- return FALSE;
- }
- sum += array[i];
- }
-
- /* Verify sum of percentages */
- if (sum_pct) {
- if (flags & NM_SETTING_DCB_FLAG_ENABLE) {
- /* If the feature is enabled, sum must equal 100% */
- if (sum != 100) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
- _("sum not 100%"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
- return FALSE;
- }
- } else {
- /* If the feature is disabled, sum must equal 0%, which was checked
- * by the for() loop above.
- */
- g_assert_cmpint (sum, ==, 0);
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-check_priority (int val,
- NMSettingDcbFlags flags,
- const char *prop_name,
- GError **error)
-{
- if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && (val >= 0)) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
- _("property invalid (not enabled)"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
- return FALSE;
- }
-
- if (val < -1 || val > 7) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
- _("property invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
- return FALSE;
- }
- return TRUE;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (setting);
-
- if (!check_dcb_flags (priv->app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS, error))
- return FALSE;
-
- if (!check_priority (priv->app_fcoe_priority, priv->app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_PRIORITY, error))
- return FALSE;
-
- if (!priv->app_fcoe_mode) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_MISSING_PROPERTY,
- _("property missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE);
- return FALSE;
- }
-
- if (strcmp (priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_FABRIC) &&
- strcmp (priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_VN2VN)) {
- g_set_error_literal (error,
- NM_SETTING_DCB_ERROR,
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
- _("property invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE);
- return FALSE;
- }
-
- if (!check_dcb_flags (priv->app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS, error))
- return FALSE;
-
- if (!check_priority (priv->app_iscsi_priority, priv->app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_PRIORITY, error))
- return FALSE;
-
- if (!check_dcb_flags (priv->app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS, error))
- return FALSE;
-
- if (!check_priority (priv->app_fip_priority, priv->app_fip_flags, NM_SETTING_DCB_APP_FIP_PRIORITY, error))
- return FALSE;
-
- if (!check_dcb_flags (priv->pfc_flags, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, error))
- return FALSE;
-
- if (!check_uint_array (priv->pfc, G_N_ELEMENTS (priv->pfc), priv->pfc_flags, 1, 0, FALSE, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, error))
- return FALSE;
-
- if (!check_dcb_flags (priv->priority_group_flags, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, error))
- return FALSE;
-
- if (!check_uint_array (priv->priority_group_id,
- G_N_ELEMENTS (priv->priority_group_id),
- priv->priority_group_flags,
- 7,
- 15,
- FALSE,
- NM_SETTING_DCB_PRIORITY_GROUP_ID,
- error))
- return FALSE;
-
- if (!check_uint_array (priv->priority_group_bandwidth,
- G_N_ELEMENTS (priv->priority_group_bandwidth),
- priv->priority_group_flags,
- 100,
- 0,
- TRUE,
- NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH,
- error))
- return FALSE;
-
- /* FIXME: sum bandwidths in each group */
- if (!check_uint_array (priv->priority_bandwidth,
- G_N_ELEMENTS (priv->priority_bandwidth),
- priv->priority_group_flags,
- 100,
- 0,
- FALSE,
- NM_SETTING_DCB_PRIORITY_BANDWIDTH,
- error))
- return FALSE;
-
- if (!check_uint_array (priv->priority_strict,
- G_N_ELEMENTS (priv->priority_strict),
- priv->priority_group_flags,
- 1,
- 0,
- FALSE,
- NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH,
- error))
- return FALSE;
-
- if (!check_uint_array (priv->priority_traffic_class,
- G_N_ELEMENTS (priv->priority_traffic_class),
- priv->priority_group_flags,
- 7,
- 0,
- FALSE,
- NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS,
- error))
- return FALSE;
-
- return TRUE;
-}
-
-/*****************************************************************************/
-
-static void
-nm_setting_dcb_init (NMSettingDcb *setting)
-{
-}
-
-static void
-set_uint_array (const GValue *v, uint *a, size_t len)
-{
- GArray *src = g_value_get_boxed (v);
- const guint total_len = len * sizeof (a[0]);
-
- memset (a, 0, total_len);
- if (src) {
- g_return_if_fail (g_array_get_element_size (src) == sizeof (a[0]));
- g_return_if_fail (src->len == len);
- memcpy (a, src->data, total_len);
- }
-}
-#define SET_UINT_ARRAY(v, a) set_uint_array (v, a, G_N_ELEMENTS (a))
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_APP_FCOE_FLAGS:
- priv->app_fcoe_flags = g_value_get_uint (value);
- break;
- case PROP_APP_FCOE_PRIORITY:
- priv->app_fcoe_priority = g_value_get_int (value);
- break;
- case PROP_APP_FCOE_MODE:
- g_free (priv->app_fcoe_mode);
- priv->app_fcoe_mode = g_value_dup_string (value);
- break;
- case PROP_APP_ISCSI_FLAGS:
- priv->app_iscsi_flags = g_value_get_uint (value);
- break;
- case PROP_APP_ISCSI_PRIORITY:
- priv->app_iscsi_priority = g_value_get_int (value);
- break;
- case PROP_APP_FIP_FLAGS:
- priv->app_fip_flags = g_value_get_uint (value);
- break;
- case PROP_APP_FIP_PRIORITY:
- priv->app_fip_priority = g_value_get_int (value);
- break;
- case PROP_PFC_FLAGS:
- priv->pfc_flags = g_value_get_uint (value);
- break;
- case PROP_PFC:
- SET_UINT_ARRAY (value, priv->pfc);
- break;
- case PROP_PRIORITY_GROUP_FLAGS:
- priv->priority_group_flags = g_value_get_uint (value);
- break;
- case PROP_PRIORITY_GROUP_ID:
- SET_UINT_ARRAY (value, priv->priority_group_id);
- break;
- case PROP_PRIORITY_GROUP_BANDWIDTH:
- SET_UINT_ARRAY (value, priv->priority_group_bandwidth);
- break;
- case PROP_PRIORITY_BANDWIDTH:
- SET_UINT_ARRAY (value, priv->priority_bandwidth);
- break;
- case PROP_PRIORITY_STRICT:
- SET_UINT_ARRAY (value, priv->priority_strict);
- break;
- case PROP_PRIORITY_TRAFFIC_CLASS:
- SET_UINT_ARRAY (value, priv->priority_traffic_class);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-#define TAKE_UINT_ARRAY(v, a) \
-{ \
- guint len = G_N_ELEMENTS (a); \
- GArray *dst = g_array_sized_new (FALSE, TRUE, sizeof (guint), len); \
- g_array_append_vals (dst, (a), len); \
- g_value_take_boxed (v, dst); \
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingDcb *setting = NM_SETTING_DCB (object);
- NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_APP_FCOE_FLAGS:
- g_value_set_uint (value, priv->app_fcoe_flags);
- break;
- case PROP_APP_FCOE_PRIORITY:
- g_value_set_int (value, priv->app_fcoe_priority);
- break;
- case PROP_APP_FCOE_MODE:
- g_value_set_string (value, priv->app_fcoe_mode);
- break;
- case PROP_APP_ISCSI_FLAGS:
- g_value_set_uint (value, priv->app_iscsi_flags);
- break;
- case PROP_APP_ISCSI_PRIORITY:
- g_value_set_int (value, priv->app_iscsi_priority);
- break;
- case PROP_APP_FIP_FLAGS:
- g_value_set_uint (value, priv->app_fip_flags);
- break;
- case PROP_APP_FIP_PRIORITY:
- g_value_set_int (value, priv->app_fip_priority);
- break;
- case PROP_PFC_FLAGS:
- g_value_set_uint (value, priv->pfc_flags);
- break;
- case PROP_PFC:
- TAKE_UINT_ARRAY (value, priv->pfc);
- break;
- case PROP_PRIORITY_GROUP_FLAGS:
- g_value_set_uint (value, priv->priority_group_flags);
- break;
- case PROP_PRIORITY_GROUP_ID:
- TAKE_UINT_ARRAY (value, priv->priority_group_id);
- break;
- case PROP_PRIORITY_GROUP_BANDWIDTH:
- TAKE_UINT_ARRAY (value, priv->priority_group_bandwidth);
- break;
- case PROP_PRIORITY_BANDWIDTH:
- TAKE_UINT_ARRAY (value, priv->priority_bandwidth);
- break;
- case PROP_PRIORITY_STRICT:
- TAKE_UINT_ARRAY (value, priv->priority_strict);
- break;
- case PROP_PRIORITY_TRAFFIC_CLASS:
- TAKE_UINT_ARRAY (value, priv->priority_traffic_class);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (object);
-
- g_free (priv->app_fcoe_mode);
-
- G_OBJECT_CLASS (nm_setting_dcb_parent_class)->finalize (object);
-}
-
-static void
-nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingDcbPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingDcb:app-fcoe-flags:
- *
- * Specifies the #NMSettingDcbFlags for the DCB FCoE application. Flags may
- * be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
- * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_APP_FCOE_FLAGS,
- g_param_spec_uint (NM_SETTING_DCB_APP_FCOE_FLAGS, "", "",
- 0, DCB_FLAGS_ALL, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:app-fcoe-priority:
- *
- * The highest User Priority (0 - 7) which FCoE frames should use, or -1 for
- * default priority. Only used when the #NMSettingDcb:app-fcoe-flags
- * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_APP_FCOE_PRIORITY,
- g_param_spec_int (NM_SETTING_DCB_APP_FCOE_PRIORITY, "", "",
- -1, 7, -1,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:app-fcoe-mode:
- *
- * The FCoE controller mode; either %NM_SETTING_DCB_FCOE_MODE_FABRIC
- * (default) or %NM_SETTING_DCB_FCOE_MODE_VN2VN.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_APP_FCOE_MODE,
- g_param_spec_string (NM_SETTING_DCB_APP_FCOE_MODE, "", "",
- NM_SETTING_DCB_FCOE_MODE_FABRIC,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:app-iscsi-flags:
- *
- * Specifies the #NMSettingDcbFlags for the DCB iSCSI application. Flags
- * may be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
- * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_APP_ISCSI_FLAGS,
- g_param_spec_uint (NM_SETTING_DCB_APP_ISCSI_FLAGS, "", "",
- 0, DCB_FLAGS_ALL, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:app-iscsi-priority:
- *
- * The highest User Priority (0 - 7) which iSCSI frames should use, or -1
- * for default priority. Only used when the #NMSettingDcb:app-iscsi-flags
- * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_APP_ISCSI_PRIORITY,
- g_param_spec_int (NM_SETTING_DCB_APP_ISCSI_PRIORITY, "", "",
- -1, 7, -1,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:app-fip-flags:
- *
- * Specifies the #NMSettingDcbFlags for the DCB FIP application. Flags may
- * be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
- * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_APP_FIP_FLAGS,
- g_param_spec_uint (NM_SETTING_DCB_APP_FIP_FLAGS, "", "",
- 0, DCB_FLAGS_ALL, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:app-fip-priority:
- *
- * The highest User Priority (0 - 7) which FIP frames should use, or -1 for
- * default priority. Only used when the #NMSettingDcb:app-fip-flags
- * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_APP_FIP_PRIORITY,
- g_param_spec_int (NM_SETTING_DCB_APP_FIP_PRIORITY, "", "",
- -1, 7, -1,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:priority-flow-control-flags:
- *
- * Specifies the #NMSettingDcbFlags for DCB Priority Flow Control (PFC).
- * Flags may be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
- * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PFC_FLAGS,
- g_param_spec_uint (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, "", "",
- 0, DCB_FLAGS_ALL, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:priority-flow-control:
- *
- * An array of 8 uint values, where the array index corresponds to the User
- * Priority (0 - 7) and the value indicates whether or not the corresponding
- * priority should transmit priority pause. Allowed values are 0 (do not
- * transmit pause) and 1 (transmit pause).
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PFC,
- _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, "", "",
- DBUS_TYPE_G_UINT_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:priority-group-flags:
- *
- * Specifies the #NMSettingDcbFlags for DCB Priority Groups. Flags may be
- * any combination of %NM_SETTING_DCB_FLAG_ENABLE,
- * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PRIORITY_GROUP_FLAGS,
- g_param_spec_uint (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, "", "",
- 0, DCB_FLAGS_ALL, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:priority-group-id:
- *
- * An array of 8 uint values, where the array index corresponds to the User
- * Priority (0 - 7) and the value indicates the Priority Group ID. Allowed
- * Priority Group ID values are 0 - 7 or 15 for the unrestricted group.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PRIORITY_GROUP_ID,
- _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_GROUP_ID, "", "",
- DBUS_TYPE_G_UINT_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:priority-group-bandwidth:
- *
- * An array of 8 uint values, where the array index corresponds to the
- * Priority Group ID (0 - 7) and the value indicates the percentage of link
- * bandwidth allocated to that group. Allowed values are 0 - 100, and the
- * sum of all values must total 100 percents.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PRIORITY_GROUP_BANDWIDTH,
- _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH, "", "",
- DBUS_TYPE_G_UINT_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:priority-bandwidth:
- *
- * An array of 8 uint values, where the array index corresponds to the User
- * Priority (0 - 7) and the value indicates the percentage of bandwidth of
- * the priority's assigned group that the priority may use. The sum of all
- * percentages for priorities which belong to the same group must total 100
- * percents.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PRIORITY_BANDWIDTH,
- _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_BANDWIDTH, "", "",
- DBUS_TYPE_G_UINT_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:priority-strict-bandwidth:
- *
- * An array of 8 uint values, where the array index corresponds to the User
- * Priority (0 - 7) and the value indicates whether or not the priority may
- * use all of the bandwidth allocated to its assigned group. Allowed values
- * are 0 (the priority may not utilize all bandwidth) or 1 (the priority may
- * utilize all bandwidth).
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PRIORITY_STRICT,
- _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH, "", "",
- DBUS_TYPE_G_UINT_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingDcb:priority-traffic-class:
- *
- * An array of 8 uint values, where the array index corresponds to the User
- * Priority (0 - 7) and the value indicates the traffic class (0 - 7) to
- * which the priority is mapped.
- *
- * Since: 0.9.10
- **/
- g_object_class_install_property
- (object_class, PROP_PRIORITY_TRAFFIC_CLASS,
- _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS, "", "",
- DBUS_TYPE_G_UINT_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-dcb.h b/libnm-util/nm-setting-dcb.h
deleted file mode 100644
index 04863545ca..0000000000
--- a/libnm-util/nm-setting-dcb.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_DCB_H
-#define NM_SETTING_DCB_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_DCB (nm_setting_dcb_get_type ())
-#define NM_SETTING_DCB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_DCB, NMSettingDcb))
-#define NM_SETTING_DCB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_DCB, NMSettingDcbClass))
-#define NM_IS_SETTING_DCB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_DCB))
-#define NM_IS_SETTING_DCB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_DCB))
-#define NM_SETTING_DCB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_DCB, NMSettingDcbClass))
-
-#define NM_SETTING_DCB_SETTING_NAME "dcb"
-
-/**
- * NMSettingDcbError:
- * @NM_SETTING_DCB_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_DCB_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_DCB_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum {
- NM_SETTING_DCB_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_DCB_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_DCB_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
-} NMSettingDcbError;
-
-#define NM_SETTING_DCB_ERROR nm_setting_dcb_error_quark ()
-GQuark nm_setting_dcb_error_quark (void);
-
-/**
- * NMSettingDcbFlags:
- * @NM_SETTING_DCB_FLAG_NONE: no flag
- * @NM_SETTING_DCB_FLAG_ENABLE: the feature is enabled
- * @NM_SETTING_DCB_FLAG_ADVERTISE: the feature is advertised
- * @NM_SETTING_DCB_FLAG_WILLING: the feature is willing to change based on
- * peer configuration advertisements
- *
- * DCB feature flags.
- *
- * Since: 0.9.10
- **/
-typedef enum {
- NM_SETTING_DCB_FLAG_NONE = 0x00000000,
- NM_SETTING_DCB_FLAG_ENABLE = 0x00000001,
- NM_SETTING_DCB_FLAG_ADVERTISE = 0x00000002,
- NM_SETTING_DCB_FLAG_WILLING = 0x00000004
-} NMSettingDcbFlags;
-
-/**
- * NM_SETTING_DCB_FCOE_MODE_FABRIC:
- *
- * Indicates that the FCoE controller should use "fabric" mode (default)
- *
- * Since: 0.9.10
- */
-#define NM_SETTING_DCB_FCOE_MODE_FABRIC "fabric"
-
-/**
- * NM_SETTING_DCB_FCOE_MODE_VN2VN:
- *
- * Indicates that the FCoE controller should use "VN2VN" mode.
- *
- * Since: 0.9.10
- */
-#define NM_SETTING_DCB_FCOE_MODE_VN2VN "vn2vn"
-
-/* Properties */
-#define NM_SETTING_DCB_APP_FCOE_FLAGS "app-fcoe-flags"
-#define NM_SETTING_DCB_APP_FCOE_PRIORITY "app-fcoe-priority"
-#define NM_SETTING_DCB_APP_FCOE_MODE "app-fcoe-mode"
-
-#define NM_SETTING_DCB_APP_ISCSI_FLAGS "app-iscsi-flags"
-#define NM_SETTING_DCB_APP_ISCSI_PRIORITY "app-iscsi-priority"
-
-#define NM_SETTING_DCB_APP_FIP_FLAGS "app-fip-flags"
-#define NM_SETTING_DCB_APP_FIP_PRIORITY "app-fip-priority"
-
-#define NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS "priority-flow-control-flags"
-#define NM_SETTING_DCB_PRIORITY_FLOW_CONTROL "priority-flow-control"
-
-#define NM_SETTING_DCB_PRIORITY_GROUP_FLAGS "priority-group-flags"
-#define NM_SETTING_DCB_PRIORITY_GROUP_ID "priority-group-id"
-#define NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH "priority-group-bandwidth"
-#define NM_SETTING_DCB_PRIORITY_BANDWIDTH "priority-bandwidth"
-#define NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH "priority-strict-bandwidth"
-#define NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS "priority-traffic-class"
-
-typedef struct {
- NMSetting parent;
-} NMSettingDcb;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingDcbClass;
-
-NM_AVAILABLE_IN_0_9_10
-GType nm_setting_dcb_get_type (void);
-
-NM_AVAILABLE_IN_0_9_10
-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);
-
-NMSettingDcbFlags nm_setting_dcb_get_app_iscsi_flags (NMSettingDcb *setting);
-int nm_setting_dcb_get_app_iscsi_priority (NMSettingDcb *setting);
-
-NMSettingDcbFlags nm_setting_dcb_get_app_fip_flags (NMSettingDcb *setting);
-int nm_setting_dcb_get_app_fip_priority (NMSettingDcb *setting);
-
-/* Priority Flow Control */
-NMSettingDcbFlags nm_setting_dcb_get_priority_flow_control_flags (NMSettingDcb *setting);
-gboolean nm_setting_dcb_get_priority_flow_control (NMSettingDcb *setting,
- guint user_priority);
-void nm_setting_dcb_set_priority_flow_control (NMSettingDcb *setting,
- guint user_priority,
- gboolean enabled);
-
-/* Priority Groups */
-NMSettingDcbFlags nm_setting_dcb_get_priority_group_flags (NMSettingDcb *setting);
-
-guint nm_setting_dcb_get_priority_group_id (NMSettingDcb *setting,
- guint user_priority);
-void nm_setting_dcb_set_priority_group_id (NMSettingDcb *setting,
- guint user_priority,
- guint group_id);
-
-guint nm_setting_dcb_get_priority_group_bandwidth (NMSettingDcb *setting,
- guint group_id);
-void nm_setting_dcb_set_priority_group_bandwidth (NMSettingDcb *setting,
- guint group_id,
- guint bandwidth_percent);
-
-guint nm_setting_dcb_get_priority_bandwidth (NMSettingDcb *setting,
- guint user_priority);
-void nm_setting_dcb_set_priority_bandwidth (NMSettingDcb *setting,
- guint user_priority,
- guint bandwidth_percent);
-
-gboolean nm_setting_dcb_get_priority_strict_bandwidth (NMSettingDcb *setting,
- guint user_priority);
-void nm_setting_dcb_set_priority_strict_bandwidth (NMSettingDcb *setting,
- guint user_priority,
- gboolean strict);
-
-guint nm_setting_dcb_get_priority_traffic_class (NMSettingDcb *setting,
- guint user_priority);
-void nm_setting_dcb_set_priority_traffic_class (NMSettingDcb *setting,
- guint user_priority,
- guint traffic_class);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_DCB_H */
diff --git a/libnm-util/nm-setting-generic.c b/libnm-util/nm-setting-generic.c
deleted file mode 100644
index 573be86a5b..0000000000
--- a/libnm-util/nm-setting-generic.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-setting-generic.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-generic
- * @short_description: Describes connection properties for generic devices
- * @include: nm-setting-generic.h
- *
- * The #NMSettingGeneric object is a #NMSetting subclass that describes
- * optional properties that apply to "generic" devices (ie, devices that
- * NetworkManager does not specifically recognize).
- *
- * There are currently no properties on this object; it exists only to be
- * the "connection type" setting on #NMConnections for generic devices.
- *
- * Since: 0.9.10
- **/
-
-/**
- * nm_setting_generic_error_quark:
- *
- * Registers an error quark for #NMSettingGeneric if necessary.
- *
- * Returns: the error quark used for #NMSettingGeneric errors.
- *
- * Since: 0.9.10
- **/
-GQuark
-nm_setting_generic_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-generic-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingGeneric, nm_setting_generic, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_GENERIC_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_GENERIC_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_GENERIC)
-
-#define NM_SETTING_GENERIC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_GENERIC, NMSettingGenericPrivate))
-
-typedef struct {
- int dummy;
-} NMSettingGenericPrivate;
-
-/*****************************************************************************/
-
-/**
- * nm_setting_generic_new:
- *
- * Creates a new #NMSettingGeneric object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingGeneric object
- *
- * Since: 0.9.10
- **/
-NMSetting *
-nm_setting_generic_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_GENERIC, NULL);
-}
-
-static void
-nm_setting_generic_init (NMSettingGeneric *setting)
-{
-}
-
-static void
-nm_setting_generic_class_init (NMSettingGenericClass *setting_class)
-{
- g_type_class_add_private (setting_class, sizeof (NMSettingGenericPrivate));
-}
diff --git a/libnm-util/nm-setting-generic.h b/libnm-util/nm-setting-generic.h
deleted file mode 100644
index f3b07f69bd..0000000000
--- a/libnm-util/nm-setting-generic.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_GENERIC_H
-#define NM_SETTING_GENERIC_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_GENERIC (nm_setting_generic_get_type ())
-#define NM_SETTING_GENERIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_GENERIC, NMSettingGeneric))
-#define NM_SETTING_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_GENERIC, NMSettingGenericClass))
-#define NM_IS_SETTING_GENERIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_GENERIC))
-#define NM_IS_SETTING_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_GENERIC))
-#define NM_SETTING_GENERIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_GENERIC, NMSettingGenericClass))
-
-#define NM_SETTING_GENERIC_SETTING_NAME "generic"
-
-/**
- * NMSettingGenericError:
- * @NM_SETTING_GENERIC_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_GENERIC_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_GENERIC_ERROR_MISSING_PROPERTY: the property was missing and
- * is required
- *
- * Since: 0.9.10
- */
-typedef enum {
- NM_SETTING_GENERIC_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_GENERIC_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_GENERIC_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
-} NMSettingGenericError;
-
-#define NM_SETTING_GENERIC_ERROR nm_setting_generic_error_quark ()
-GQuark nm_setting_generic_error_quark (void);
-
-typedef struct {
- NMSetting parent;
-} NMSettingGeneric;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingGenericClass;
-
-NM_AVAILABLE_IN_0_9_10
-GType nm_setting_generic_get_type (void);
-
-NM_AVAILABLE_IN_0_9_10
-NMSetting * nm_setting_generic_new (void);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_GENERIC_H */
diff --git a/libnm-util/nm-setting-gsm.c b/libnm-util/nm-setting-gsm.c
deleted file mode 100644
index 82ebde335e..0000000000
--- a/libnm-util/nm-setting-gsm.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-gsm.h"
-#include "nm-utils.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-gsm
- * @short_description: Describes GSM/3GPP-based mobile broadband properties
- * @include: nm-setting-gsm.h
- *
- * The #NMSettingGsm object is a #NMSetting subclass that describes
- * properties that allow connections to 3GPP-based mobile broadband
- * networks, including those using GPRS/EDGE and UMTS/HSPA technology.
- */
-
-/**
- * nm_setting_gsm_error_quark:
- *
- * Registers an error quark for #NMSettingGsm if necessary.
- *
- * Returns: the error quark used for #NMSettingGsm errors.
- **/
-GQuark
-nm_setting_gsm_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-gsm-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_GSM_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_GSM_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_GSM)
-
-#define NM_SETTING_GSM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_GSM, NMSettingGsmPrivate))
-
-typedef struct {
- char *number; /* For dialing, duh */
- char *username;
- char *password;
- NMSettingSecretFlags password_flags;
-
- char *apn; /* NULL for dynamic */
- char *network_id; /* for manual registration or NULL for automatic */
- int network_type; /* One of the NM_SETTING_GSM_NETWORK_TYPE_* */
- guint32 allowed_bands; /* A bitfield of NM_SETTING_GSM_BAND_* */
-
- char *pin;
- NMSettingSecretFlags pin_flags;
-
- gboolean home_only;
-} NMSettingGsmPrivate;
-
-enum {
- PROP_0,
- PROP_NUMBER,
- PROP_USERNAME,
- PROP_PASSWORD,
- PROP_PASSWORD_FLAGS,
- PROP_APN,
- PROP_NETWORK_ID,
- PROP_NETWORK_TYPE,
- PROP_PIN,
- PROP_PIN_FLAGS,
- PROP_ALLOWED_BANDS,
- PROP_HOME_ONLY,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_gsm_new:
- *
- * Creates a new #NMSettingGsm object with default values.
- *
- * Returns: the new empty #NMSettingGsm object
- **/
-NMSetting *
-nm_setting_gsm_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_GSM, NULL);
-}
-
-/**
- * nm_setting_gsm_get_number:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:number property of the setting
- **/
-const char *
-nm_setting_gsm_get_number (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->number;
-}
-
-/**
- * nm_setting_gsm_get_username:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:username property of the setting
- **/
-const char *
-nm_setting_gsm_get_username (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->username;
-}
-
-/**
- * nm_setting_gsm_get_password:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:password property of the setting
- **/
-const char *
-nm_setting_gsm_get_password (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->password;
-}
-
-/**
- * nm_setting_gsm_get_password_flags:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingGsm:password
- **/
-NMSettingSecretFlags
-nm_setting_gsm_get_password_flags (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->password_flags;
-}
-
-/**
- * nm_setting_gsm_get_apn:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:apn property of the setting
- **/
-const char *
-nm_setting_gsm_get_apn (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->apn;
-}
-
-/**
- * nm_setting_gsm_get_network_id:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:network-id property of the setting
- **/
-const char *
-nm_setting_gsm_get_network_id (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->network_id;
-}
-
-/**
- * nm_setting_gsm_get_network_type:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:network-type property of the setting
- *
- * Deprecated: 0.9.10: No longer used. Network type setting should be done talking to ModemManager directly.
- **/
-int
-nm_setting_gsm_get_network_type (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), -1);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->network_type;
-}
-
-/**
- * nm_setting_gsm_get_allowed_bands:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:allowed-bands property of the setting
- *
- * Deprecated: 0.9.10: No longer used. Bands setting should be done talking to ModemManager directly.
- **/
-guint32
-nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_GSM_BAND_UNKNOWN);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->allowed_bands;
-}
-
-/**
- * nm_setting_gsm_get_pin:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:pin property of the setting
- **/
-const char *
-nm_setting_gsm_get_pin (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->pin;
-}
-
-/**
- * nm_setting_gsm_get_pin_flags:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingGsm:pin
- **/
-NMSettingSecretFlags
-nm_setting_gsm_get_pin_flags (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->pin_flags;
-}
-
-/**
- * nm_setting_gsm_get_home_only:
- * @setting: the #NMSettingGsm
- *
- * Returns: the #NMSettingGsm:home-only property of the setting
- **/
-gboolean
-nm_setting_gsm_get_home_only (NMSettingGsm *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_GSM (setting), FALSE);
-
- return NM_SETTING_GSM_GET_PRIVATE (setting)->home_only;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
-
- if (priv->number && !priv->number[0]) {
- g_set_error_literal (error,
- NM_SETTING_GSM_ERROR,
- NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NUMBER);
- return FALSE;
- }
-
- if (priv->apn) {
- guint32 apn_len = strlen (priv->apn);
- guint32 i;
-
- if (apn_len < 1 || apn_len > 64) {
- g_set_error (error,
- NM_SETTING_GSM_ERROR,
- NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
- _("property value '%s' is empty or too long (>64)"),
- priv->apn);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_APN);
- return FALSE;
- }
-
- /* APNs roughly follow the same rules as DNS domain names. Allowed
- * characters are a-z, 0-9, . and -. GSM 03.03 Section 9.1 states:
- *
- * The syntax of the APN shall follow the Name Syntax defined in
- * RFC 2181 [14] and RFC 1035 [15]. The APN consists of one or
- * more labels. Each label is coded as one octet length field
- * followed by that number of octets coded as 8 bit ASCII characters.
- * Following RFC 1035 [15] the labels should consist only of the
- * alphabetic characters (A-Z and a-z), digits (0-9) and the
- * dash (-). The case of alphabetic characters is not significant.
- *
- * A dot (.) is commonly used to separate parts of the APN, and
- * apparently the underscore (_) is used as well. RFC 2181 indicates
- * that no restrictions of any kind are placed on DNS labels, and thus
- * it would appear that none are placed on APNs either, but many modems
- * and networks will fail to accept APNs that include odd characters
- * like space ( ) and such.
- */
- for (i = 0; i < apn_len; i++) {
- if ( !g_ascii_isalnum (priv->apn[i])
- && (priv->apn[i] != '.')
- && (priv->apn[i] != '_')
- && (priv->apn[i] != '-')) {
- g_set_error (error,
- NM_SETTING_GSM_ERROR,
- NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
- _("'%s' contains invalid char(s) (use [A-Za-z._-])"),
- priv->apn);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_APN);
- return FALSE;
- }
- }
- }
-
- if (priv->username && !strlen (priv->username)) {
- g_set_error_literal (error,
- NM_SETTING_GSM_ERROR,
- NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_USERNAME);
- return FALSE;
- }
-
- if (priv->network_id) {
- guint32 nid_len = strlen (priv->network_id);
- guint32 i;
-
- /* Accept both 5 and 6 digit MCC/MNC codes */
- if ((nid_len < 5) || (nid_len > 6)) {
- g_set_error (error,
- NM_SETTING_GSM_ERROR,
- NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
- _("'%s' length is invalid (should be 5 or 6 digits)"),
- priv->network_id);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NETWORK_ID);
- return FALSE;
- }
-
- for (i = 0; i < nid_len; i++) {
- if (!g_ascii_isdigit (priv->network_id[i])) {
- g_set_error (error,
- NM_SETTING_GSM_ERROR,
- NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
- _("'%s' is not a number"),
- priv->network_id);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NETWORK_ID);
- return FALSE;
- }
- }
- }
-
- return TRUE;
-}
-
-static GPtrArray *
-need_secrets (NMSetting *setting)
-{
- NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
- GPtrArray *secrets = NULL;
-
- if (priv->password && *priv->password)
- return NULL;
-
- if (priv->username) {
- if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) {
- secrets = g_ptr_array_sized_new (1);
- g_ptr_array_add (secrets, NM_SETTING_GSM_PASSWORD);
- }
- }
-
- return secrets;
-}
-
-static void
-nm_setting_gsm_init (NMSettingGsm *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
-
- g_free (priv->number);
- g_free (priv->username);
- g_free (priv->password);
- g_free (priv->apn);
- g_free (priv->network_id);
- g_free (priv->pin);
-
- G_OBJECT_CLASS (nm_setting_gsm_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
- char *tmp;
-
- switch (prop_id) {
- case PROP_NUMBER:
- g_free (priv->number);
- priv->number = g_value_dup_string (value);
- break;
- case PROP_USERNAME:
- g_free (priv->username);
- priv->username = g_value_dup_string (value);
- break;
- case PROP_PASSWORD:
- g_free (priv->password);
- priv->password = g_value_dup_string (value);
- break;
- case PROP_PASSWORD_FLAGS:
- priv->password_flags = g_value_get_uint (value);
- break;
- case PROP_APN:
- g_free (priv->apn);
- priv->apn = NULL;
- tmp = g_value_dup_string (value);
- if (tmp)
- priv->apn = g_strstrip (tmp);
- break;
- case PROP_NETWORK_ID:
- g_free (priv->network_id);
- priv->network_id = NULL;
- tmp = g_value_dup_string (value);
- if (tmp)
- priv->network_id = g_strstrip (tmp);
- break;
- case PROP_NETWORK_TYPE:
- priv->network_type = g_value_get_int (value);
- break;
- case PROP_ALLOWED_BANDS:
- priv->allowed_bands = g_value_get_uint (value);
- break;
- case PROP_PIN:
- g_free (priv->pin);
- priv->pin = g_value_dup_string (value);
- break;
- case PROP_PIN_FLAGS:
- priv->pin_flags = g_value_get_uint (value);
- break;
- case PROP_HOME_ONLY:
- priv->home_only = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingGsm *setting = NM_SETTING_GSM (object);
-
- switch (prop_id) {
- case PROP_NUMBER:
- g_value_set_string (value, nm_setting_gsm_get_number (setting));
- break;
- case PROP_USERNAME:
- g_value_set_string (value, nm_setting_gsm_get_username (setting));
- break;
- case PROP_PASSWORD:
- g_value_set_string (value, nm_setting_gsm_get_password (setting));
- break;
- case PROP_PASSWORD_FLAGS:
- g_value_set_uint (value, nm_setting_gsm_get_password_flags (setting));
- break;
- case PROP_APN:
- g_value_set_string (value, nm_setting_gsm_get_apn (setting));
- break;
- case PROP_NETWORK_ID:
- g_value_set_string (value, nm_setting_gsm_get_network_id (setting));
- break;
- case PROP_NETWORK_TYPE:
- g_value_set_int (value, NM_SETTING_GSM_GET_PRIVATE (setting)->network_type);
- break;
- case PROP_ALLOWED_BANDS:
- g_value_set_uint (value, NM_SETTING_GSM_GET_PRIVATE (setting)->allowed_bands);
- break;
- case PROP_PIN:
- g_value_set_string (value, nm_setting_gsm_get_pin (setting));
- break;
- case PROP_PIN_FLAGS:
- g_value_set_uint (value, nm_setting_gsm_get_pin_flags (setting));
- break;
- case PROP_HOME_ONLY:
- g_value_set_boolean (value, nm_setting_gsm_get_home_only (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingGsmPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->need_secrets = need_secrets;
-
- /* Properties */
-
- /**
- * NMSettingGsm:number:
- *
- * Number to dial when establishing a PPP data session with the GSM-based
- * mobile broadband network. Many modems do not require PPP for connections
- * to the mobile network and thus this property should be left blank, which
- * allows NetworkManager to select the appropriate settings automatically.
- **/
- g_object_class_install_property
- (object_class, PROP_NUMBER,
- g_param_spec_string (NM_SETTING_GSM_NUMBER, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:username:
- *
- * The username used to authenticate with the network, if required. Many
- * providers do not require a username, or accept any username. But if a
- * username is required, it is specified here.
- **/
- g_object_class_install_property
- (object_class, PROP_USERNAME,
- g_param_spec_string (NM_SETTING_GSM_USERNAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:password:
- *
- * The password used to authenticate with the network, if required. Many
- * providers do not require a password, or accept any password. But if a
- * password is required, it is specified here.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD,
- g_param_spec_string (NM_SETTING_GSM_PASSWORD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:password-flags:
- *
- * Flags indicating how to handle the #NMSettingGsm:password property.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD_FLAGS,
- g_param_spec_uint (NM_SETTING_GSM_PASSWORD_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:apn:
- *
- * The GPRS Access Point Name specifying the APN used when establishing a
- * data session with the GSM-based network. The APN often determines how
- * the user will be billed for their network usage and whether the user has
- * access to the Internet or just a provider-specific walled-garden, so it
- * is important to use the correct APN for the user's mobile broadband plan.
- * The APN may only be composed of the characters a-z, 0-9, ., and - per GSM
- * 03.60 Section 14.9.
- **/
- g_object_class_install_property
- (object_class, PROP_APN,
- g_param_spec_string (NM_SETTING_GSM_APN, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:network-id:
- *
- * The Network ID (GSM LAI format, ie MCC-MNC) to force specific network
- * registration. If the Network ID is specified, NetworkManager will
- * attempt to force the device to register only on the specified network.
- * This can be used to ensure that the device does not roam when direct
- * roaming control of the device is not otherwise possible.
- **/
- g_object_class_install_property
- (object_class, PROP_NETWORK_ID,
- g_param_spec_string (NM_SETTING_GSM_NETWORK_ID, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:network-type:
- *
- * Network preference to force the device to only use specific network
- * technologies. The permitted values are %NM_SETTING_GSM_NETWORK_TYPE_ANY,
- * %NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA,
- * %NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE,
- * %NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA,
- * %NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE,
- * %NM_SETTING_GSM_NETWORK_TYPE_PREFER_4G, and
- * %NM_SETTING_GSM_NETWORK_TYPE_4G. Note that not all devices allow network
- * preference control.
- *
- * Deprecated: 0.9.10: No longer used. Network type setting should be done
- * by talking to ModemManager directly.
- **/
- g_object_class_install_property
- (object_class, PROP_NETWORK_TYPE,
- g_param_spec_int (NM_SETTING_GSM_NETWORK_TYPE, "", "",
- NM_SETTING_GSM_NETWORK_TYPE_ANY,
- NM_SETTING_GSM_NETWORK_TYPE_4G,
- NM_SETTING_GSM_NETWORK_TYPE_ANY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:allowed-bands:
- *
- * Bitfield of allowed frequency bands. Note that not all devices allow
- * frequency band control. Permitted values are those specified by
- * #NMSettingGsmNetworkBand.
- *
- * Deprecated: 0.9.10: No longer used. Band setting should be done by
- * talking to ModemManager directly.
- **/
- g_object_class_install_property
- (object_class, PROP_ALLOWED_BANDS,
- g_param_spec_uint (NM_SETTING_GSM_ALLOWED_BANDS, "", "",
- NM_SETTING_GSM_BAND_UNKNOWN,
- NM_SETTING_GSM_BANDS_MAX,
- NM_SETTING_GSM_BAND_ANY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:pin:
- *
- * If the SIM is locked with a PIN it must be unlocked before any other
- * operations are requested. Specify the PIN here to allow operation of the
- * device.
- **/
- g_object_class_install_property
- (object_class, PROP_PIN,
- g_param_spec_string (NM_SETTING_GSM_PIN, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:pin-flags:
- *
- * Flags indicating how to handle the #NMSettingGsm:pin property.
- **/
- g_object_class_install_property
- (object_class, PROP_PIN_FLAGS,
- g_param_spec_uint (NM_SETTING_GSM_PIN_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingGsm:home-only:
- *
- * When %TRUE, only connections to the home network will be allowed.
- * Connections to roaming networks will not be made.
- **/
- g_object_class_install_property
- (object_class, PROP_HOME_ONLY,
- g_param_spec_boolean (NM_SETTING_GSM_HOME_ONLY, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-gsm.h b/libnm-util/nm-setting-gsm.h
deleted file mode 100644
index 438c6b3b32..0000000000
--- a/libnm-util/nm-setting-gsm.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_GSM_H
-#define NM_SETTING_GSM_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_GSM (nm_setting_gsm_get_type ())
-#define NM_SETTING_GSM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_GSM, NMSettingGsm))
-#define NM_SETTING_GSM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_GSM, NMSettingGsmClass))
-#define NM_IS_SETTING_GSM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_GSM))
-#define NM_IS_SETTING_GSM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_GSM))
-#define NM_SETTING_GSM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_GSM, NMSettingGsmClass))
-
-#define NM_SETTING_GSM_SETTING_NAME "gsm"
-
-/**
- * NMSettingGsmError:
- * @NM_SETTING_GSM_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_GSM_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_GSM_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING: the required #NMSettingSerial
- * is missing in the connection
- */
-typedef enum {
- NM_SETTING_GSM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_GSM_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_GSM_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING /*< nick=MissingSerialSetting >*/
-} NMSettingGsmError;
-
-#define NM_SETTING_GSM_ERROR nm_setting_gsm_error_quark ()
-GQuark nm_setting_gsm_error_quark (void);
-
-#define NM_SETTING_GSM_NUMBER "number"
-#define NM_SETTING_GSM_USERNAME "username"
-#define NM_SETTING_GSM_PASSWORD "password"
-#define NM_SETTING_GSM_PASSWORD_FLAGS "password-flags"
-#define NM_SETTING_GSM_APN "apn"
-#define NM_SETTING_GSM_NETWORK_ID "network-id"
-#define NM_SETTING_GSM_PIN "pin"
-#define NM_SETTING_GSM_PIN_FLAGS "pin-flags"
-#define NM_SETTING_GSM_HOME_ONLY "home-only"
-
-/* Deprecated */
-#define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands"
-#define NM_SETTING_GSM_NETWORK_TYPE "network-type"
-
-/**
- * NMSettingGsmNetworkType:
- * @NM_SETTING_GSM_NETWORK_TYPE_ANY: any access technology may be used
- * @NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA: only 3G-type (UMTS and HSPA)
- * technologies may be used
- * @NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE: only 2G-type (GPRS and EDGE)
- * technologies may be used
- * @NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA: 3G-type technologies are
- * preferred but 2G-type technologies may be used as a fallback
- * @NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE: 2G-type technologies are
- * preferred but 3G-type technologies may be used as a fallback
- * @NM_SETTING_GSM_NETWORK_TYPE_PREFER_4G: 4G/LTE-type technologies are
- * preferred but 3G/2/-type technologies may be used as a fallback
- * @NM_SETTING_GSM_NETWORK_TYPE_4G: only 4G/LTE type
- * technologies may be used
- *
- * #NMSettingGsmNetworkType values indicate the allowed access technologies
- * the device may use when connecting to this network.
- *
- * Deprecated: 0.9.10: No longer used.
- */
-typedef enum {
- NM_SETTING_GSM_NETWORK_TYPE_ANY = -1,
- NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA = 0,
- NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE = 1,
- NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA = 2,
- NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE = 3,
- NM_SETTING_GSM_NETWORK_TYPE_PREFER_4G = 4,
- NM_SETTING_GSM_NETWORK_TYPE_4G = 5
-} NMSettingGsmNetworkType;
-
-/**
- * NMSettingGsmNetworkBand:
- * @NM_SETTING_GSM_BAND_UNKNOWN: unknown or no band specified
- * @NM_SETTING_GSM_BAND_ANY: any band is allowed
- * @NM_SETTING_GSM_BAND_EGSM: 900 MHz original GSM band
- * @NM_SETTING_GSM_BAND_DCS: 1800 MHz DCS band
- * @NM_SETTING_GSM_BAND_PCS: US 1900 MHz PCS band
- * @NM_SETTING_GSM_BAND_G850: US 850 MHz Cellular band
- * @NM_SETTING_GSM_BAND_U2100: WCDMA 3GPP UMTS 2100 MHz (Class I)
- * @NM_SETTING_GSM_BAND_U1800: WCDMA 3GPP UMTS 1800 MHz (Class III)
- * @NM_SETTING_GSM_BAND_U17IV: WCDMA 3GPP AWS 1700/2100 MHz (Class IV)
- * @NM_SETTING_GSM_BAND_U800: WCDMA 3GPP UMTS 800 MHz (Class VI)
- * @NM_SETTING_GSM_BAND_U850: WCDMA 3GPP UMTS 850 MHz (Class V)
- * @NM_SETTING_GSM_BAND_U900: WCDMA 3GPP UMTS 900 MHz (Class VIII)
- * @NM_SETTING_GSM_BAND_U17IX: WCDMA 3GPP UMTS 1700 MHz (Class IX)
- * @NM_SETTING_GSM_BAND_U1900: WCDMA 3GPP UMTS 1900 MHz (Class II)
- * @NM_SETTING_GSM_BAND_U2600: WCDMA 3GPP UMTS 2600 MHz (Class VII, internal)
- *
- * #NMSettingGsmNetworkBand values indicate the allowed frequency bands
- * the device may use when connecting to this network.
- *
- * Deprecated: 0.9.10: No longer used.
- */
-typedef enum {
- NM_SETTING_GSM_BAND_UNKNOWN = 0x00000000,
- NM_SETTING_GSM_BAND_ANY = 0x00000001,
- NM_SETTING_GSM_BAND_EGSM = 0x00000002, /* 900 MHz */
- NM_SETTING_GSM_BAND_DCS = 0x00000004, /* 1800 MHz */
- NM_SETTING_GSM_BAND_PCS = 0x00000008, /* 1900 MHz */
- NM_SETTING_GSM_BAND_G850 = 0x00000010, /* 850 MHz */
- NM_SETTING_GSM_BAND_U2100 = 0x00000020, /* WCDMA 3GPP UMTS 2100 MHz (Class I) */
- NM_SETTING_GSM_BAND_U1800 = 0x00000040, /* WCDMA 3GPP UMTS 1800 MHz (Class III) */
- NM_SETTING_GSM_BAND_U17IV = 0x00000080, /* WCDMA 3GPP AWS 1700/2100 MHz (Class IV) */
- NM_SETTING_GSM_BAND_U800 = 0x00000100, /* WCDMA 3GPP UMTS 800 MHz (Class VI) */
- NM_SETTING_GSM_BAND_U850 = 0x00000200, /* WCDMA 3GPP UMTS 850 MHz (Class V) */
- NM_SETTING_GSM_BAND_U900 = 0x00000400, /* WCDMA 3GPP UMTS 900 MHz (Class VIII) */
- NM_SETTING_GSM_BAND_U17IX = 0x00000800, /* WCDMA 3GPP UMTS 1700 MHz (Class IX) */
- NM_SETTING_GSM_BAND_U1900 = 0x00001000, /* WCDMA 3GPP UMTS 1900 MHz (Class II) */
- NM_SETTING_GSM_BAND_U2600 = 0x00002000, /* WCDMA 3GPP UMTS 2600 MHz (Class VII, internal) */
-} NMSettingGsmNetworkBand;
-
-/**
- * NM_SETTING_GSM_BANDS_MAX:
- *
- * #NM_SETTING_GSM_BANDS_MAX macro indicate the maximal value that can be used
- * as the allowed frequency bands (#NMSettingGsm:allowed-bands property).
- *
- * Deprecated: 0.9.10: No longer used.
- */
-#define NM_SETTING_GSM_BANDS_MAX ( NM_SETTING_GSM_BAND_UNKNOWN \
- | NM_SETTING_GSM_BAND_ANY \
- | NM_SETTING_GSM_BAND_EGSM \
- | NM_SETTING_GSM_BAND_DCS \
- | NM_SETTING_GSM_BAND_PCS \
- | NM_SETTING_GSM_BAND_G850 \
- | NM_SETTING_GSM_BAND_U2100 \
- | NM_SETTING_GSM_BAND_U1800 \
- | NM_SETTING_GSM_BAND_U17IV \
- | NM_SETTING_GSM_BAND_U800 \
- | NM_SETTING_GSM_BAND_U850 \
- | NM_SETTING_GSM_BAND_U900 \
- | NM_SETTING_GSM_BAND_U17IX \
- | NM_SETTING_GSM_BAND_U1900 \
- | NM_SETTING_GSM_BAND_U2600)
-
-typedef struct {
- NMSetting parent;
-} NMSettingGsm;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingGsmClass;
-
-GType nm_setting_gsm_get_type (void);
-
-NMSetting *nm_setting_gsm_new (void);
-const char *nm_setting_gsm_get_number (NMSettingGsm *setting);
-const char *nm_setting_gsm_get_username (NMSettingGsm *setting);
-const char *nm_setting_gsm_get_password (NMSettingGsm *setting);
-const char *nm_setting_gsm_get_apn (NMSettingGsm *setting);
-const char *nm_setting_gsm_get_network_id (NMSettingGsm *setting);
-const char *nm_setting_gsm_get_pin (NMSettingGsm *setting);
-gboolean nm_setting_gsm_get_home_only (NMSettingGsm *setting);
-
-NMSettingSecretFlags nm_setting_gsm_get_pin_flags (NMSettingGsm *setting);
-NMSettingSecretFlags nm_setting_gsm_get_password_flags (NMSettingGsm *setting);
-
-/* Deprecated */
-NM_DEPRECATED_IN_0_9_10
-int nm_setting_gsm_get_network_type (NMSettingGsm *setting);
-NM_DEPRECATED_IN_0_9_10
-guint32 nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_GSM_H */
diff --git a/libnm-util/nm-setting-infiniband.c b/libnm-util/nm-setting-infiniband.c
deleted file mode 100644
index c9fa8ec9eb..0000000000
--- a/libnm-util/nm-setting-infiniband.c
+++ /dev/null
@@ -1,474 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <stdlib.h>
-#include <dbus/dbus-glib.h>
-#include <linux/if_infiniband.h>
-
-#include "nm-setting-infiniband.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-setting-private.h"
-#include "nm-setting-connection.h"
-
-/**
- * SECTION:nm-setting-infiniband
- * @short_description: Describes connection properties for IP-over-InfiniBand networks
- * @include: nm-setting-infiniband.h
- *
- * The #NMSettingInfiniband object is a #NMSetting subclass that describes properties
- * necessary for connection to IP-over-InfiniBand networks.
- **/
-
-/**
- * nm_setting_infiniband_error_quark:
- *
- * Registers an error quark for #NMSettingInfiniband if necessary.
- *
- * Returns: the error quark used for #NMSettingInfiniband errors.
- **/
-GQuark
-nm_setting_infiniband_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-infiniband-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingInfiniband, nm_setting_infiniband, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_INFINIBAND_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_INFINIBAND_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_INFINIBAND)
-
-#define NM_SETTING_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_INFINIBAND, NMSettingInfinibandPrivate))
-
-typedef struct {
- GByteArray *mac_address;
- char *transport_mode;
- guint32 mtu;
- int p_key;
- char *parent, *virtual_iface_name;
-} NMSettingInfinibandPrivate;
-
-enum {
- PROP_0,
- PROP_MAC_ADDRESS,
- PROP_MTU,
- PROP_TRANSPORT_MODE,
- PROP_P_KEY,
- PROP_PARENT,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_infiniband_new:
- *
- * Creates a new #NMSettingInfiniband object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingInfiniband object
- **/
-NMSetting *
-nm_setting_infiniband_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_INFINIBAND, NULL);
-}
-
-/**
- * nm_setting_infiniband_get_mac_address:
- * @setting: the #NMSettingInfiniband
- *
- * Returns: the #NMSettingInfiniband:mac-address property of the setting
- **/
-const GByteArray *
-nm_setting_infiniband_get_mac_address (NMSettingInfiniband *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), NULL);
-
- return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->mac_address;
-}
-
-/**
- * nm_setting_infiniband_get_mtu:
- * @setting: the #NMSettingInfiniband
- *
- * Returns: the #NMSettingInfiniband:mtu property of the setting
- **/
-guint32
-nm_setting_infiniband_get_mtu (NMSettingInfiniband *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), 0);
-
- return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->mtu;
-}
-
-/**
- * nm_setting_infiniband_get_transport_mode:
- * @setting: the #NMSettingInfiniband
- *
- * Returns the transport mode for this device. Either 'datagram' or
- * 'connected'.
- *
- * Returns: the IPoIB transport mode
- **/
-const char *
-nm_setting_infiniband_get_transport_mode (NMSettingInfiniband *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), NULL);
-
- return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->transport_mode;
-}
-
-/**
- * nm_setting_infiniband_get_p_key:
- * @setting: the #NMSettingInfiniband
- *
- * Returns the P_Key to use for this device. A value of -1 means to
- * use the default P_Key (aka "the P_Key at index 0"). Otherwise it is
- * a 16-bit unsigned integer.
- *
- * Returns: the IPoIB P_Key
- **/
-int
-nm_setting_infiniband_get_p_key (NMSettingInfiniband *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), -1);
-
- return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->p_key;
-}
-
-/**
- * nm_setting_infiniband_get_parent:
- * @setting: the #NMSettingInfiniband
- *
- * Returns the parent interface name for this device, if set.
- *
- * Returns: the parent interface name
- **/
-const char *
-nm_setting_infiniband_get_parent (NMSettingInfiniband *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), NULL);
-
- return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->parent;
-}
-
-static const char *
-get_virtual_iface_name (NMSetting *setting)
-{
- NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (setting);
-
- if (priv->p_key == -1 || !priv->parent)
- return NULL;
-
- if (!priv->virtual_iface_name)
- priv->virtual_iface_name = g_strdup_printf ("%s.%04x", priv->parent, priv->p_key);
-
- return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->virtual_iface_name;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingConnection *s_con;
- NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (setting);
-
- if (priv->mac_address && priv->mac_address->len != INFINIBAND_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_INFINIBAND_ERROR,
- NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_MAC_ADDRESS);
- return FALSE;
- }
-
- /* FIXME: verify() should not modify the setting, but return NORMALIZABLE success. */
- if (!g_strcmp0 (priv->transport_mode, "datagram")) {
- if (priv->mtu > 2044)
- priv->mtu = 2044;
- } else if (!g_strcmp0 (priv->transport_mode, "connected")) {
- if (priv->mtu > 65520)
- priv->mtu = 65520;
- } else {
- g_set_error_literal (error,
- NM_SETTING_INFINIBAND_ERROR,
- NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_TRANSPORT_MODE);
- return FALSE;
- }
-
- if (priv->parent) {
- if (!nm_utils_iface_valid_name (priv->parent)) {
- g_set_error_literal (error,
- NM_SETTING_INFINIBAND_ERROR,
- NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY,
- _("not a valid interface name"));
- g_prefix_error (error, "%s: ", NM_SETTING_INFINIBAND_PARENT);
- return FALSE;
- }
- if (priv->p_key == -1) {
- g_set_error_literal (error,
- NM_SETTING_INFINIBAND_ERROR,
- NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY,
- _("Must specify a P_Key if specifying parent"));
- g_prefix_error (error, "%s: ", NM_SETTING_INFINIBAND_PARENT);
- }
- }
-
- if (priv->p_key != -1) {
- if (!priv->mac_address && !priv->parent) {
- g_set_error_literal (error,
- NM_SETTING_INFINIBAND_ERROR,
- NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY,
- _("InfiniBand P_Key connection did not specify parent interface name"));
- g_prefix_error (error, "%s: ", NM_SETTING_INFINIBAND_PARENT);
- return FALSE;
- }
- }
-
- s_con = NM_SETTING_CONNECTION (nm_setting_find_in_list (all_settings, NM_SETTING_CONNECTION_SETTING_NAME));
- if (s_con) {
- const char *interface_name = nm_setting_connection_get_interface_name (s_con);
-
- if (!interface_name)
- ;
- else if (!nm_utils_iface_valid_name (interface_name)) {
- /* report the error for NMSettingConnection:interface-name, because
- * it's that property that is invalid -- although we currently verify()
- * NMSettingInfiniband.
- **/
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid interface name"),
- interface_name);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
- return FALSE;
- } else {
- if (priv->p_key != -1) {
- if (!priv->virtual_iface_name)
- priv->virtual_iface_name = g_strdup_printf ("%s.%04x", priv->parent, priv->p_key);
-
- if (strcmp (interface_name, priv->virtual_iface_name) != 0) {
- /* We don't support renaming software infiniband devices. Later we might, but
- * for now just reject such connections.
- **/
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("interface name of software infiniband device must be '%s' or unset (instead it is '%s')"),
- priv->virtual_iface_name, interface_name);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
- return FALSE;
- }
- }
- }
- }
-
- return TRUE;
-}
-
-static void
-nm_setting_infiniband_init (NMSettingInfiniband *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (object);
-
- g_free (priv->transport_mode);
- if (priv->mac_address)
- g_byte_array_free (priv->mac_address, TRUE);
- g_free (priv->parent);
- g_free (priv->virtual_iface_name);
-
- G_OBJECT_CLASS (nm_setting_infiniband_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_MAC_ADDRESS:
- if (priv->mac_address)
- g_byte_array_free (priv->mac_address, TRUE);
- priv->mac_address = g_value_dup_boxed (value);
- break;
- case PROP_MTU:
- priv->mtu = g_value_get_uint (value);
- break;
- case PROP_TRANSPORT_MODE:
- g_free (priv->transport_mode);
- priv->transport_mode = g_value_dup_string (value);
- break;
- case PROP_P_KEY:
- priv->p_key = g_value_get_int (value);
- g_clear_pointer (&priv->virtual_iface_name, g_free);
- break;
- case PROP_PARENT:
- g_free (priv->parent);
- priv->parent = g_value_dup_string (value);
- g_clear_pointer (&priv->virtual_iface_name, g_free);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingInfiniband *setting = NM_SETTING_INFINIBAND (object);
-
- switch (prop_id) {
- case PROP_MAC_ADDRESS:
- g_value_set_boxed (value, nm_setting_infiniband_get_mac_address (setting));
- break;
- case PROP_MTU:
- g_value_set_uint (value, nm_setting_infiniband_get_mtu (setting));
- break;
- case PROP_TRANSPORT_MODE:
- g_value_set_string (value, nm_setting_infiniband_get_transport_mode (setting));
- break;
- case PROP_P_KEY:
- g_value_set_int (value, nm_setting_infiniband_get_p_key (setting));
- break;
- case PROP_PARENT:
- g_value_set_string (value, nm_setting_infiniband_get_parent (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingInfinibandPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- parent_class->verify = verify;
- parent_class->get_virtual_iface_name = get_virtual_iface_name;
-
- /* Properties */
- /**
- * NMSettingInfiniband:mac-address:
- *
- * If specified, this connection will only apply to the IPoIB device whose
- * permanent MAC address matches. This property does not change the MAC
- * address of the device (i.e. MAC spoofing).
- **/
- g_object_class_install_property
- (object_class, PROP_MAC_ADDRESS,
- _nm_param_spec_specialized (NM_SETTING_INFINIBAND_MAC_ADDRESS, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingInfiniband:mtu:
- *
- * If non-zero, only transmit packets of the specified size or smaller,
- * breaking larger packets up into multiple frames.
- **/
- g_object_class_install_property
- (object_class, PROP_MTU,
- g_param_spec_uint (NM_SETTING_INFINIBAND_MTU, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingInfiniband:transport-mode:
- *
- * The IP-over-InfiniBand transport mode. Either "datagram" or
- * "connected".
- **/
- g_object_class_install_property
- (object_class, PROP_TRANSPORT_MODE,
- g_param_spec_string (NM_SETTING_INFINIBAND_TRANSPORT_MODE, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingInfiniband:p-key:
- *
- * The InfiniBand P_Key to use for this device. A value of -1 means to use
- * the default P_Key (aka "the P_Key at index 0"). Otherwise it is a 16-bit
- * unsigned integer, whose high bit is set if it is a "full membership"
- * P_Key.
- **/
- g_object_class_install_property
- (object_class, PROP_P_KEY,
- g_param_spec_int (NM_SETTING_INFINIBAND_P_KEY, "", "",
- -1, 0xFFFF, -1,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingInfiniband:parent:
- *
- * The interface name of the parent device of this device. Normally %NULL,
- * but if the #NMSettingInfiniband:p_key property is set, then you must
- * specify the base device by setting either this property or
- * #NMSettingInfiniband:mac-address.
- **/
- g_object_class_install_property
- (object_class, PROP_PARENT,
- g_param_spec_string (NM_SETTING_INFINIBAND_PARENT, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
-}
diff --git a/libnm-util/nm-setting-infiniband.h b/libnm-util/nm-setting-infiniband.h
deleted file mode 100644
index 95d343e963..0000000000
--- a/libnm-util/nm-setting-infiniband.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_INFINIBAND_H
-#define NM_SETTING_INFINIBAND_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_INFINIBAND (nm_setting_infiniband_get_type ())
-#define NM_SETTING_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_INFINIBAND, NMSettingInfiniband))
-#define NM_SETTING_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_INFINIBAND, NMSettingInfinibandClass))
-#define NM_IS_SETTING_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_INFINIBAND))
-#define NM_IS_SETTING_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_INFINIBAND))
-#define NM_SETTING_INFINIBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_INFINIBAND, NMSettingInfinibandClass))
-
-#define NM_SETTING_INFINIBAND_SETTING_NAME "infiniband"
-
-/**
- * NMSettingInfinibandError:
- * @NM_SETTING_INFINIBAND_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum {
- NM_SETTING_INFINIBAND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
-} NMSettingInfinibandError;
-
-#define NM_SETTING_INFINIBAND_ERROR nm_setting_infiniband_error_quark ()
-GQuark nm_setting_infiniband_error_quark (void);
-
-#define NM_SETTING_INFINIBAND_MAC_ADDRESS "mac-address"
-#define NM_SETTING_INFINIBAND_MTU "mtu"
-#define NM_SETTING_INFINIBAND_TRANSPORT_MODE "transport-mode"
-#define NM_SETTING_INFINIBAND_P_KEY "p-key"
-#define NM_SETTING_INFINIBAND_PARENT "parent"
-
-typedef struct {
- NMSetting parent;
-} NMSettingInfiniband;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingInfinibandClass;
-
-GType nm_setting_infiniband_get_type (void);
-
-NMSetting * nm_setting_infiniband_new (void);
-const GByteArray *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);
-int nm_setting_infiniband_get_p_key (NMSettingInfiniband *setting);
-const char * nm_setting_infiniband_get_parent (NMSettingInfiniband *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_INFINIBAND_H */
diff --git a/libnm-util/nm-setting-ip4-config.c b/libnm-util/nm-setting-ip4-config.c
deleted file mode 100644
index 6a01fca926..0000000000
--- a/libnm-util/nm-setting-ip4-config.c
+++ /dev/null
@@ -1,1853 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-ip4-config.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-ip4-config
- * @short_description: Describes IPv4 addressing, routing, and name service properties
- * @include: nm-setting-ip4-config.h
- *
- * The #NMSettingIP4Config object is a #NMSetting subclass that describes
- * properties related to IPv4 addressing, routing, and Domain Name Service
- **/
-
-/**
- * nm_setting_ip4_config_error_quark:
- *
- * Registers an error quark for #NMSettingIP4Config if necessary.
- *
- * Returns: the error quark used for #NMSettingIP4Config errors.
- **/
-GQuark
-nm_setting_ip4_config_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-ip4-config-error-quark");
- return quark;
-}
-
-G_DEFINE_BOXED_TYPE (NMIP4Address, nm_ip4_address, nm_ip4_address_dup, nm_ip4_address_unref)
-G_DEFINE_BOXED_TYPE (NMIP4Route, nm_ip4_route, nm_ip4_route_dup, nm_ip4_route_unref)
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingIP4Config, nm_setting_ip4_config, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_IP4_CONFIG_SETTING_NAME,
- g_define_type_id,
- 4,
- NM_SETTING_IP4_CONFIG_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP4_CONFIG)
-
-#define NM_SETTING_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_IP4_CONFIG, NMSettingIP4ConfigPrivate))
-
-typedef struct {
- char *method;
- GArray *dns; /* array of guint32; elements in network byte order */
- GSList *dns_search; /* list of strings */
- GSList *addresses; /* array of NMIP4Address */
- GSList *routes; /* array of NMIP4Route */
- gint64 route_metric;
- gboolean ignore_auto_routes;
- gboolean ignore_auto_dns;
- char *dhcp_client_id;
- gboolean dhcp_send_hostname;
- char *dhcp_hostname;
- int dhcp_timeout;
- gboolean never_default;
- gboolean may_fail;
-} NMSettingIP4ConfigPrivate;
-
-enum {
- PROP_0,
- PROP_METHOD,
- PROP_DNS,
- PROP_DNS_SEARCH,
- PROP_ADDRESSES,
- PROP_ROUTES,
- PROP_ROUTE_METRIC,
- PROP_IGNORE_AUTO_ROUTES,
- PROP_IGNORE_AUTO_DNS,
- PROP_DHCP_CLIENT_ID,
- PROP_DHCP_TIMEOUT,
- PROP_DHCP_SEND_HOSTNAME,
- PROP_DHCP_HOSTNAME,
- PROP_NEVER_DEFAULT,
- PROP_MAY_FAIL,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_ip4_config_new:
- *
- * Creates a new #NMSettingIP4Config object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingIP4Config object
- **/
-NMSetting *
-nm_setting_ip4_config_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_IP4_CONFIG, NULL);
-}
-
-/**
- * nm_setting_ip4_config_get_method:
- * @setting: the #NMSettingIP4Config
- *
- * Returns: the #NMSettingIP4Config:method property of the setting
- **/
-const char *
-nm_setting_ip4_config_get_method (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->method;
-}
-
-/**
- * nm_setting_ip4_config_get_num_dns:
- * @setting: the #NMSettingIP4Config
- *
- * Returns: the number of configured DNS servers
- **/
-guint32
-nm_setting_ip4_config_get_num_dns (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dns->len;
-}
-
-/**
- * nm_setting_ip4_config_get_dns:
- * @setting: the #NMSettingIP4Config
- * @i: index number of the DNS server to return
- *
- * Returns: the IPv4 address (network byte order) of the DNS server at index
- * @i
- **/
-guint32
-nm_setting_ip4_config_get_dns (NMSettingIP4Config *setting, guint32 i)
-{
- NMSettingIP4ConfigPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= priv->dns->len, 0);
-
- return g_array_index (priv->dns, guint32, i);
-}
-
-/**
- * nm_setting_ip4_config_add_dns:
- * @setting: the #NMSettingIP4Config
- * @dns: the IPv4 address (network byte order) of the DNS server to add
- *
- * Adds a new DNS server to the setting.
- *
- * Returns: %TRUE if the DNS server was added; %FALSE if the server was already
- * known
- **/
-gboolean
-nm_setting_ip4_config_add_dns (NMSettingIP4Config *setting, guint32 dns)
-{
- NMSettingIP4ConfigPrivate *priv;
- int i;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- for (i = 0; i < priv->dns->len; i++) {
- if (dns == g_array_index (priv->dns, guint32, i))
- return FALSE;
- }
-
- g_array_append_val (priv->dns, dns);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS);
- return TRUE;
-}
-
-/**
- * nm_setting_ip4_config_remove_dns:
- * @setting: the #NMSettingIP4Config
- * @i: index number of the DNS server to remove
- *
- * Removes the DNS server at index @i.
- **/
-void
-nm_setting_ip4_config_remove_dns (NMSettingIP4Config *setting, guint32 i)
-{
- NMSettingIP4ConfigPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- g_return_if_fail (i <= priv->dns->len);
-
- g_array_remove_index (priv->dns, i);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS);
-}
-
-/**
- * nm_setting_ip4_config_remove_dns_by_value:
- * @setting: the #NMSettingIP4Config
- * @dns: the DNS server to remove
- *
- * Removes the DNS server @dns.
- *
- * Returns: %TRUE if the DNS server was found and removed; %FALSE if it was not.
- * domain was already known
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_ip4_config_remove_dns_by_value (NMSettingIP4Config *setting, guint32 dns)
-{
- NMSettingIP4ConfigPrivate *priv;
- int i;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- for (i = 0; i < priv->dns->len; i++) {
- if (dns == g_array_index (priv->dns, guint32, i)) {
- g_array_remove_index (priv->dns, i);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_ip4_config_clear_dns:
- * @setting: the #NMSettingIP4Config
- *
- * Removes all configured DNS servers.
- **/
-void
-nm_setting_ip4_config_clear_dns (NMSettingIP4Config *setting)
-{
- NMSettingIP4ConfigPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- g_array_remove_range (priv->dns, 0, priv->dns->len);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS);
-}
-
-/**
- * nm_setting_ip4_config_get_num_dns_searches:
- * @setting: the #NMSettingIP4Config
- *
- * Returns: the number of configured DNS search domains
- **/
-guint32
-nm_setting_ip4_config_get_num_dns_searches (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
-
- return g_slist_length (NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dns_search);
-}
-
-/**
- * nm_setting_ip4_config_get_dns_search:
- * @setting: the #NMSettingIP4Config
- * @i: index number of the DNS search domain to return
- *
- * Returns: the DNS search domain at index @i
- **/
-const char *
-nm_setting_ip4_config_get_dns_search (NMSettingIP4Config *setting, guint32 i)
-{
- NMSettingIP4ConfigPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->dns_search), NULL);
-
- return (const char *) g_slist_nth_data (priv->dns_search, i);
-}
-
-/**
- * nm_setting_ip4_config_add_dns_search:
- * @setting: the #NMSettingIP4Config
- * @dns_search: the search domain to add
- *
- * Adds a new DNS search domain to the setting.
- *
- * Returns: %TRUE if the DNS search domain was added; %FALSE if the search
- * domain was already known
- **/
-gboolean
-nm_setting_ip4_config_add_dns_search (NMSettingIP4Config *setting,
- const char *dns_search)
-{
- NMSettingIP4ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
- g_return_val_if_fail (dns_search != NULL, FALSE);
- g_return_val_if_fail (dns_search[0] != '\0', FALSE);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->dns_search; iter; iter = g_slist_next (iter)) {
- if (!strcmp (dns_search, (char *) iter->data))
- return FALSE;
- }
-
- priv->dns_search = g_slist_append (priv->dns_search, g_strdup (dns_search));
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS_SEARCH);
- return TRUE;
-}
-
-/**
- * nm_setting_ip4_config_remove_dns_search:
- * @setting: the #NMSettingIP4Config
- * @i: index number of the DNS search domain
- *
- * Removes the DNS search domain at index @i.
- **/
-void
-nm_setting_ip4_config_remove_dns_search (NMSettingIP4Config *setting, guint32 i)
-{
- NMSettingIP4ConfigPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->dns_search, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->dns_search = g_slist_delete_link (priv->dns_search, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS_SEARCH);
-}
-
-/**
- * nm_setting_ip4_config_remove_dns_search_by_value:
- * @setting: the #NMSettingIP4Config
- * @dns_search: the search domain to remove
- *
- * Removes the DNS search domain @dns_search.
- *
- * Returns: %TRUE if the DNS search domain was found and removed; %FALSE if it was not.
- *
- * Since 0.9.10
- **/
-gboolean
-nm_setting_ip4_config_remove_dns_search_by_value (NMSettingIP4Config *setting,
- const char *dns_search)
-{
- NMSettingIP4ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
- g_return_val_if_fail (dns_search != NULL, FALSE);
- g_return_val_if_fail (dns_search[0] != '\0', FALSE);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->dns_search; iter; iter = g_slist_next (iter)) {
- if (!strcmp (dns_search, (char *) iter->data)) {
- priv->dns_search = g_slist_delete_link (priv->dns_search, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS_SEARCH);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_ip4_config_clear_dns_searches:
- * @setting: the #NMSettingIP4Config
- *
- * Removes all configured DNS search domains.
- **/
-void
-nm_setting_ip4_config_clear_dns_searches (NMSettingIP4Config *setting)
-{
- g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
-
- g_slist_free_full (NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dns_search, g_free);
- NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dns_search = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS_SEARCH);
-}
-
-/**
- * nm_setting_ip4_config_get_num_addresses:
- * @setting: the #NMSettingIP4Config
- *
- * Returns: the number of configured addresses
- **/
-guint32
-nm_setting_ip4_config_get_num_addresses (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
-
- return g_slist_length (NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->addresses);
-}
-
-/**
- * nm_setting_ip4_config_get_address:
- * @setting: the #NMSettingIP4Config
- * @i: index number of the address to return
- *
- * Returns: the address at index @i
- **/
-NMIP4Address *
-nm_setting_ip4_config_get_address (NMSettingIP4Config *setting, guint32 i)
-{
- NMSettingIP4ConfigPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->addresses), NULL);
-
- return (NMIP4Address *) g_slist_nth_data (priv->addresses, i);
-}
-
-/**
- * nm_setting_ip4_config_add_address:
- * @setting: the #NMSettingIP4Config
- * @address: the new address to add
- *
- * Adds a new IPv4 address and associated information to the setting. The
- * given address is duplicated internally and is not changed by this function.
- *
- * Returns: %TRUE if the address was added; %FALSE if the address was already
- * known.
- **/
-gboolean
-nm_setting_ip4_config_add_address (NMSettingIP4Config *setting,
- NMIP4Address *address)
-{
- NMSettingIP4ConfigPrivate *priv;
- NMIP4Address *copy;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
- g_return_val_if_fail (address != NULL, FALSE);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->addresses; iter; iter = g_slist_next (iter)) {
- if (nm_ip4_address_compare ((NMIP4Address *) iter->data, address))
- return FALSE;
- }
-
- copy = nm_ip4_address_dup (address);
- priv->addresses = g_slist_append (priv->addresses, copy);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
- return TRUE;
-}
-
-/**
- * nm_setting_ip4_config_remove_address:
- * @setting: the #NMSettingIP4Config
- * @i: index number of the address to remove
- *
- * Removes the address at index @i.
- **/
-void
-nm_setting_ip4_config_remove_address (NMSettingIP4Config *setting, guint32 i)
-{
- NMSettingIP4ConfigPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->addresses, i);
- g_return_if_fail (elt != NULL);
-
- nm_ip4_address_unref ((NMIP4Address *) elt->data);
- priv->addresses = g_slist_delete_link (priv->addresses, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
-}
-
-/**
- * nm_setting_ip4_config_remove_address_by_value:
- * @setting: the #NMSettingIP4Config
- * @address: the IP address to remove
- *
- * Removes the address @address.
- *
- * Returns: %TRUE if the address was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_ip4_config_remove_address_by_value (NMSettingIP4Config *setting,
- NMIP4Address *address)
-{
- NMSettingIP4ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
- g_return_val_if_fail (address != NULL, FALSE);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->addresses; iter; iter = g_slist_next (iter)) {
- if (nm_ip4_address_compare ((NMIP4Address *) iter->data, address)) {
- nm_ip4_address_unref ((NMIP4Address *) iter->data);
- priv->addresses = g_slist_delete_link (priv->addresses, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_ip4_config_clear_addresses:
- * @setting: the #NMSettingIP4Config
- *
- * Removes all configured addresses.
- **/
-void
-nm_setting_ip4_config_clear_addresses (NMSettingIP4Config *setting)
-{
- NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
-
- g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
-
- g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
- priv->addresses = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
-}
-
-/**
- * nm_setting_ip4_config_get_num_routes:
- * @setting: the #NMSettingIP4Config
- *
- * Returns: the number of configured routes
- **/
-guint32
-nm_setting_ip4_config_get_num_routes (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
-
- return g_slist_length (NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->routes);
-}
-
-/**
- * nm_setting_ip4_config_get_route:
- * @setting: the #NMSettingIP4Config
- * @i: index number of the route to return
- *
- * Returns: the route at index @i
- **/
-NMIP4Route *
-nm_setting_ip4_config_get_route (NMSettingIP4Config *setting, guint32 i)
-{
- NMSettingIP4ConfigPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->routes), NULL);
-
- return (NMIP4Route *) g_slist_nth_data (priv->routes, i);
-}
-
-/**
- * nm_setting_ip4_config_add_route:
- * @setting: the #NMSettingIP4Config
- * @route: the route to add
- *
- * Adds a new IPv4 route and associated information to the setting. The
- * given route is duplicated internally and is not changed by this function.
- *
- * Returns: %TRUE if the route was added; %FALSE if the route was already known.
- **/
-gboolean
-nm_setting_ip4_config_add_route (NMSettingIP4Config *setting,
- NMIP4Route *route)
-{
- NMSettingIP4ConfigPrivate *priv;
- NMIP4Route *copy;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
- g_return_val_if_fail (route != NULL, FALSE);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->routes; iter; iter = g_slist_next (iter)) {
- if (nm_ip4_route_compare ((NMIP4Route *) iter->data, route))
- return FALSE;
- }
-
- copy = nm_ip4_route_dup (route);
- priv->routes = g_slist_append (priv->routes, copy);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ROUTES);
- return TRUE;
-}
-
-/**
- * nm_setting_ip4_config_remove_route:
- * @setting: the #NMSettingIP4Config
- * @i: index number of the route
- *
- * Removes the route at index @i.
- **/
-void
-nm_setting_ip4_config_remove_route (NMSettingIP4Config *setting, guint32 i)
-{
- NMSettingIP4ConfigPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->routes, i);
- g_return_if_fail (elt != NULL);
-
- nm_ip4_route_unref ((NMIP4Route *) elt->data);
- priv->routes = g_slist_delete_link (priv->routes, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ROUTES);
-}
-
-/**
- * nm_setting_ip4_config_remove_route_by_value:
- * @setting: the #NMSettingIP4Config
- * @route: the route to remove
- *
- * Removes the route @route.
- *
- * Returns: %TRUE if the route was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_ip4_config_remove_route_by_value (NMSettingIP4Config *setting,
- NMIP4Route *route)
-{
- NMSettingIP4ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
- g_return_val_if_fail (route != NULL, FALSE);
-
- priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->routes; iter; iter = g_slist_next (iter)) {
- if (nm_ip4_route_compare ((NMIP4Route *) iter->data, route)) {
- nm_ip4_route_unref ((NMIP4Route *) iter->data);
- priv->routes = g_slist_delete_link (priv->routes, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ROUTES);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_ip4_config_clear_routes:
- * @setting: the #NMSettingIP4Config
- *
- * Removes all configured routes.
- **/
-void
-nm_setting_ip4_config_clear_routes (NMSettingIP4Config *setting)
-{
- NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
-
- g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
-
- g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
- priv->routes = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ROUTES);
-}
-
-/**
- * nm_setting_ip4_config_get_route_metric:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:route-metric
- * property.
- *
- * Returns: the route metric that is used for IPv4 routes that don't explicitly
- * specify a metric. See #NMSettingIP4Config:route-metric for more details.
- *
- * Since: 1.0
- **/
-gint64
-nm_setting_ip4_config_get_route_metric (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), -1);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->route_metric;
-}
-
-/**
- * nm_setting_ip4_config_get_ignore_auto_routes:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:ignore-auto-routes
- * property.
- *
- * Returns: %TRUE if automatically configured (ie via DHCP) routes should be
- * ignored.
- **/
-gboolean
-nm_setting_ip4_config_get_ignore_auto_routes (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->ignore_auto_routes;
-}
-
-/**
- * nm_setting_ip4_config_get_ignore_auto_dns:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:ignore-auto-dns
- * property.
- *
- * Returns: %TRUE if automatically configured (ie via DHCP) DNS information
- * should be ignored.
- **/
-gboolean
-nm_setting_ip4_config_get_ignore_auto_dns (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->ignore_auto_dns;
-}
-
-/**
- * nm_setting_ip4_config_get_dhcp_client_id:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:dhcp-client-id
- * property.
- *
- * Returns: the configured Client ID to send to the DHCP server when requesting
- * addresses via DHCP.
- **/
-const char *
-nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_client_id;
-}
-
-/**
- * nm_setting_ip4_config_get_dhcp_send_hostname:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:dhcp-send-hostname
- * property.
- *
- * Returns: %TRUE if NetworkManager should send the machine hostname to the
- * DHCP server when requesting addresses to allow the server to automatically
- * update DNS information for this machine.
- **/
-gboolean
-nm_setting_ip4_config_get_dhcp_send_hostname (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_send_hostname;
-}
-
-/**
- * nm_setting_ip4_config_get_dhcp_hostname:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:dhcp-hostname
- * property.
- *
- * Returns: the configured hostname to send to the DHCP server
- **/
-const char *
-nm_setting_ip4_config_get_dhcp_hostname (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_hostname;
-}
-
-/**
- * nm_setting_ip4_config_get_dhcp_timeout:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:dhcp-timeout
- * property.
- *
- * Returns: The number of seconds after which unfinished DHCP transaction
- * fails or zero for "default".
- **/
-int
-nm_setting_ip4_config_get_dhcp_timeout (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_timeout;
-}
-
-/**
- * nm_setting_ip4_config_get_never_default:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:never-default
- * property.
- *
- * Returns: %TRUE if this connection should never be the default connection
- * for IPv4 addressing
- **/
-gboolean
-nm_setting_ip4_config_get_never_default (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->never_default;
-}
-
-/**
- * nm_setting_ip4_config_get_may_fail:
- * @setting: the #NMSettingIP4Config
- *
- * Returns the value contained in the #NMSettingIP4Config:may-fail
- * property.
- *
- * Returns: %TRUE if this connection doesn't require IPv4 addressing to complete
- * for the connection to succeed.
- **/
-gboolean
-nm_setting_ip4_config_get_may_fail (NMSettingIP4Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->may_fail;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
- GSList *iter;
- int i;
-
- if (!priv->method) {
- g_set_error_literal (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD);
- return FALSE;
- }
-
- if (!strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
- if (!priv->addresses) {
- g_set_error (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY,
- _("this property cannot be empty for '%s=%s'"),
- NM_SETTING_IP4_CONFIG_METHOD, priv->method);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES);
- return FALSE;
- }
- } else if ( !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)
- || !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)
- || !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
- if (priv->dns && priv->dns->len) {
- g_set_error (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
- _("this property is not allowed for '%s=%s'"),
- NM_SETTING_IP4_CONFIG_METHOD, priv->method);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS);
- return FALSE;
- }
-
- if (g_slist_length (priv->dns_search)) {
- g_set_error (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
- _("this property is not allowed for '%s=%s'"),
- NM_SETTING_IP4_CONFIG_METHOD, priv->method);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS_SEARCH);
- return FALSE;
- }
-
- /* Shared allows IP addresses; link-local and disabled do not */
- if (strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0) {
- if (g_slist_length (priv->addresses)) {
- g_set_error (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
- _("this property is not allowed for '%s=%s'"),
- NM_SETTING_IP4_CONFIG_METHOD, priv->method);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES);
- return FALSE;
- }
- }
- } else if (!strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
- /* nothing to do */
- } else {
- g_set_error_literal (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD);
- return FALSE;
- }
-
- if (priv->dhcp_client_id && !strlen (priv->dhcp_client_id)) {
- g_set_error_literal (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID);
- return FALSE;
- }
-
- if (priv->dhcp_hostname && !strlen (priv->dhcp_hostname)) {
- g_set_error_literal (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME);
- return FALSE;
- }
-
- /* Validate addresses */
- for (iter = priv->addresses, i = 0; iter; iter = g_slist_next (iter), i++) {
- NMIP4Address *addr = (NMIP4Address *) iter->data;
- guint32 prefix = nm_ip4_address_get_prefix (addr);
-
- if (!nm_ip4_address_get_address (addr)) {
- g_set_error (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
- _("%d. IPv4 address is invalid"),
- i+1);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES);
- return FALSE;
- }
-
- if (!prefix || prefix > 32) {
- g_set_error (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
- _("%d. IPv4 address has invalid prefix"),
- i+1);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES);
- return FALSE;
- }
- }
-
- /* Validate routes */
- for (iter = priv->routes, i = 0; iter; iter = g_slist_next (iter), i++) {
- NMIP4Route *route = (NMIP4Route *) iter->data;
- guint32 prefix = nm_ip4_route_get_prefix (route);
-
- if (!prefix || prefix > 32) {
- g_set_error (error,
- NM_SETTING_IP4_CONFIG_ERROR,
- NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
- _("%d. route has invalid prefix"),
- i+1);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ROUTES);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void
-nm_setting_ip4_config_init (NMSettingIP4Config *setting)
-{
- NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
-
- priv->dns = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingIP4Config *self = NM_SETTING_IP4_CONFIG (object);
- NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (self);
-
- g_free (priv->method);
- g_free (priv->dhcp_hostname);
- g_free (priv->dhcp_client_id);
-
- g_array_free (priv->dns, TRUE);
-
- g_slist_free_full (priv->dns_search, g_free);
- g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
- g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
-
- G_OBJECT_CLASS (nm_setting_ip4_config_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingIP4Config *setting = NM_SETTING_IP4_CONFIG (object);
- NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_METHOD:
- g_free (priv->method);
- priv->method = g_value_dup_string (value);
- break;
- case PROP_DNS:
- g_array_free (priv->dns, TRUE);
- priv->dns = g_value_dup_boxed (value);
- if (!priv->dns)
- priv->dns = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
- break;
- case PROP_DNS_SEARCH:
- g_slist_free_full (priv->dns_search, g_free);
- priv->dns_search = g_value_dup_boxed (value);
- break;
- case PROP_ADDRESSES:
- g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
- priv->addresses = nm_utils_ip4_addresses_from_gvalue (value);
- break;
- case PROP_ROUTES:
- g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
- priv->routes = nm_utils_ip4_routes_from_gvalue (value);
- break;
- case PROP_ROUTE_METRIC:
- priv->route_metric = g_value_get_int64 (value);
- break;
- case PROP_IGNORE_AUTO_ROUTES:
- priv->ignore_auto_routes = g_value_get_boolean (value);
- break;
- case PROP_IGNORE_AUTO_DNS:
- priv->ignore_auto_dns = g_value_get_boolean (value);
- break;
- case PROP_DHCP_CLIENT_ID:
- g_free (priv->dhcp_client_id);
- priv->dhcp_client_id = g_value_dup_string (value);
- break;
- case PROP_DHCP_SEND_HOSTNAME:
- priv->dhcp_send_hostname = g_value_get_boolean (value);
- break;
- case PROP_DHCP_HOSTNAME:
- g_free (priv->dhcp_hostname);
- priv->dhcp_hostname = g_value_dup_string (value);
- break;
- case PROP_DHCP_TIMEOUT:
- priv->dhcp_timeout = g_value_get_uint (value);
- break;
- case PROP_NEVER_DEFAULT:
- priv->never_default = g_value_get_boolean (value);
- break;
- case PROP_MAY_FAIL:
- priv->may_fail = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingIP4Config *setting = NM_SETTING_IP4_CONFIG (object);
- NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_METHOD:
- g_value_set_string (value, nm_setting_ip4_config_get_method (setting));
- break;
- case PROP_DNS:
- g_value_set_boxed (value, priv->dns);
- break;
- case PROP_DNS_SEARCH:
- g_value_set_boxed (value, priv->dns_search);
- break;
- case PROP_ADDRESSES:
- nm_utils_ip4_addresses_to_gvalue (priv->addresses, value);
- break;
- case PROP_ROUTES:
- nm_utils_ip4_routes_to_gvalue (priv->routes, value);
- break;
- case PROP_ROUTE_METRIC:
- g_value_set_int64 (value, priv->route_metric);
- break;
- case PROP_IGNORE_AUTO_ROUTES:
- g_value_set_boolean (value, nm_setting_ip4_config_get_ignore_auto_routes (setting));
- break;
- case PROP_IGNORE_AUTO_DNS:
- g_value_set_boolean (value, nm_setting_ip4_config_get_ignore_auto_dns (setting));
- break;
- case PROP_DHCP_CLIENT_ID:
- g_value_set_string (value, nm_setting_ip4_config_get_dhcp_client_id (setting));
- break;
- case PROP_DHCP_SEND_HOSTNAME:
- g_value_set_boolean (value, nm_setting_ip4_config_get_dhcp_send_hostname (setting));
- break;
- case PROP_DHCP_HOSTNAME:
- g_value_set_string (value, nm_setting_ip4_config_get_dhcp_hostname (setting));
- break;
- case PROP_DHCP_TIMEOUT:
- g_value_set_uint (value, nm_setting_ip4_config_get_dhcp_timeout (setting));
- break;
- case PROP_NEVER_DEFAULT:
- g_value_set_boolean (value, priv->never_default);
- break;
- case PROP_MAY_FAIL:
- g_value_set_boolean (value, priv->may_fail);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingIP4ConfigPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingIP4Config:method:
- *
- * IPv4 configuration method. If "auto" is specified then the appropriate
- * automatic method (DHCP, PPP, etc) is used for the interface and most
- * other properties can be left unset. If "link-local" is specified, then a
- * link-local address in the 169.254/16 range will be assigned to the
- * interface. If "manual" is specified, static IP addressing is used and at
- * least one IP address must be given in the "addresses" property. If
- * "shared" is specified (indicating that this connection will provide
- * network access to other computers) then the interface is assigned an
- * address in the 10.42.x.1/24 range and a DHCP and forwarding DNS server
- * are started, and the interface is NAT-ed to the current default network
- * connection. "disabled" means IPv4 will not be used on this connection.
- * This property must be set.
- **/
- g_object_class_install_property
- (object_class, PROP_METHOD,
- g_param_spec_string (NM_SETTING_IP4_CONFIG_METHOD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:dns:
- *
- * List of DNS servers (network byte order). For the "auto" method, these
- * DNS servers are appended to those (if any) returned by automatic
- * configuration. DNS servers cannot be used with the "shared",
- * "link-local", or "disabled" methods as there is no upstream network. In
- * all other methods, these DNS servers are used as the only DNS servers for
- * this connection.
- **/
- g_object_class_install_property
- (object_class, PROP_DNS,
- _nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_DNS, "", "",
- DBUS_TYPE_G_UINT_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:dns-search:
- *
- * List of DNS search domains. For the "auto" method, these search domains
- * are appended to those returned by automatic configuration. Search domains
- * cannot be used with the "shared", "link-local", or "disabled" methods as
- * there is no upstream network. In all other methods, these search domains
- * are used as the only search domains for this connection.
- **/
- g_object_class_install_property
- (object_class, PROP_DNS_SEARCH,
- _nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_DNS_SEARCH, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:addresses:
- *
- * Array of IPv4 address structures. Each IPv4 address structure is
- * composed of 3 32-bit values; the first being the IPv4 address (network
- * byte order), the second the prefix (1 - 32), and last the IPv4 gateway
- * (network byte order). The gateway may be left as 0 if no gateway exists
- * for that subnet. For the "auto" method, given IP addresses are appended
- * to those returned by automatic configuration. Addresses cannot be used
- * with the "shared", "link-local", or "disabled" methods as addressing is
- * either automatic or disabled with these methods.
- **/
- g_object_class_install_property
- (object_class, PROP_ADDRESSES,
- _nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_ADDRESSES, "", "",
- DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:routes:
- *
- * Array of IPv4 route structures. Each IPv4 route structure is composed of
- * 4 32-bit values; the first being the destination IPv4 network or address
- * (network byte order), the second the destination network or address
- * prefix (1 - 32), the third being the next-hop (network byte order) if
- * any, and the fourth being the route metric. For the "auto" method, given
- * IP routes are appended to those returned by automatic configuration.
- * Routes cannot be used with the "shared", "link-local", or "disabled"
- * methods because there is no upstream network.
- **/
- g_object_class_install_property
- (object_class, PROP_ROUTES,
- _nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_ROUTES, "", "",
- DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:route-metric:
- *
- * The default metric for routes that don't explicitly specify a metric.
- * The default value -1 means that the metric is chosen automatically
- * based on the device type.
- * The metric applies to dynamic routes, manual (static) routes that
- * don't have an explicit metric setting, address prefix routes, and
- * the default route.
- * As the linux kernel accepts zero (0) as a valid metric, zero is
- * a valid value.
- *
- * Since: 1.0
- **/
- g_object_class_install_property
- (object_class, PROP_ROUTE_METRIC,
- g_param_spec_int64 (NM_SETTING_IP4_CONFIG_ROUTE_METRIC, "", "",
- -1, G_MAXUINT32, -1,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:ignore-auto-routes:
- *
- * When the method is set to "auto" and this property to %TRUE,
- * automatically configured routes are ignored and only routes specified in
- * the #NMSettingIP4Config:routes property, if any, are used.
- **/
- g_object_class_install_property
- (object_class, PROP_IGNORE_AUTO_ROUTES,
- g_param_spec_boolean (NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:ignore-auto-dns:
- *
- * When the method is set to "auto" and this property to %TRUE,
- * automatically configured nameservers and search domains are ignored and
- * only nameservers and search domains specified in the
- * #NMSettingIP4Config:dns and #NMSettingIP4Config:dns-search properties, if
- * any, are used.
- **/
- g_object_class_install_property
- (object_class, PROP_IGNORE_AUTO_DNS,
- g_param_spec_boolean (NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:dhcp-client-id:
- *
- * A string sent to the DHCP server to identify the local machine which the
- * DHCP server may use to customize the DHCP lease and options.
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP_CLIENT_ID,
- g_param_spec_string (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:dhcp-send-hostname:
- *
- * If %TRUE, a hostname is sent to the DHCP server when acquiring a lease.
- * Some DHCP servers use this hostname to update DNS databases, essentially
- * providing a static hostname for the computer. If the
- * #NMSettingIP4Config:dhcp-hostname property is empty and this property is
- * %TRUE, the current persistent hostname of the computer is sent.
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP_SEND_HOSTNAME,
- g_param_spec_boolean (NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:dhcp-hostname:
- *
- * If the #NMSettingIP4Config:dhcp-send-hostname property is %TRUE, then the
- * specified name will be sent to the DHCP server when acquiring a lease.
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP_HOSTNAME,
- g_param_spec_string (NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:dhcp-timeout:
- *
- * Number of seconds after which the unfinished DHCP transaction fails
- * or zero for default.
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP_TIMEOUT,
- g_param_spec_uint (NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:never-default:
- *
- * If %TRUE, this connection will never be the default IPv4 connection,
- * meaning it will never be assigned the default route by NetworkManager.
- **/
- g_object_class_install_property
- (object_class, PROP_NEVER_DEFAULT,
- g_param_spec_boolean (NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP4Config:may-fail:
- *
- * If %TRUE, allow overall network configuration to proceed even if IPv4
- * configuration times out. Note that at least one IP configuration must
- * succeed or overall network configuration will still fail. For example,
- * in IPv6-only networks, setting this property to %TRUE allows the overall
- * network configuration to succeed if IPv4 configuration fails but IPv6
- * configuration completes successfully.
- **/
- g_object_class_install_property
- (object_class, PROP_MAY_FAIL,
- g_param_spec_boolean (NM_SETTING_IP4_CONFIG_MAY_FAIL, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-}
-
-struct NMIP4Address {
- guint32 refcount;
- guint32 address; /* network byte order */
- guint32 prefix;
- guint32 gateway; /* network byte order */
-};
-
-/**
- * nm_ip4_address_new:
- *
- * Creates and returns a new #NMIP4Address object.
- *
- * Returns: (transfer full): the new empty #NMIP4Address object
- **/
-NMIP4Address *
-nm_ip4_address_new (void)
-{
- NMIP4Address *address;
-
- address = g_malloc0 (sizeof (NMIP4Address));
- address->refcount = 1;
- return address;
-}
-
-/**
- * nm_ip4_address_dup:
- * @source: the #NMIP4Address object to copy
- *
- * Copies a given #NMIP4Address object and returns the copy.
- *
- * Returns: (transfer full): the copy of the given #NMIP4Address copy
- **/
-NMIP4Address *
-nm_ip4_address_dup (NMIP4Address *source)
-{
- NMIP4Address *address;
-
- g_return_val_if_fail (source != NULL, NULL);
- g_return_val_if_fail (source->refcount > 0, NULL);
-
- address = nm_ip4_address_new ();
- address->address = source->address;
- address->prefix = source->prefix;
- address->gateway = source->gateway;
-
- return address;
-}
-
-/**
- * nm_ip4_address_ref:
- * @address: the #NMIP4Address
- *
- * Increases the reference count of the object.
- **/
-void
-nm_ip4_address_ref (NMIP4Address *address)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
-
- address->refcount++;
-}
-
-/**
- * nm_ip4_address_unref:
- * @address: the #NMIP4Address
- *
- * Decreases the reference count of the object. If the reference count
- * reaches zero, the object will be destroyed.
- **/
-void
-nm_ip4_address_unref (NMIP4Address *address)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
-
- address->refcount--;
- if (address->refcount == 0) {
- memset (address, 0, sizeof (NMIP4Address));
- g_free (address);
- }
-}
-
-/**
- * nm_ip4_address_compare:
- * @address: the #NMIP4Address
- * @other: the #NMIP4Address to compare @address to.
- *
- * Determines if two #NMIP4Address objects contain the same values.
- *
- * Returns: %TRUE if the objects contain the same values, %FALSE if they do not.
- **/
-gboolean
-nm_ip4_address_compare (NMIP4Address *address, NMIP4Address *other)
-{
- g_return_val_if_fail (address != NULL, FALSE);
- g_return_val_if_fail (address->refcount > 0, FALSE);
-
- g_return_val_if_fail (other != NULL, FALSE);
- g_return_val_if_fail (other->refcount > 0, FALSE);
-
- if ( address->address != other->address
- || address->prefix != other->prefix
- || address->gateway != other->gateway)
- return FALSE;
- return TRUE;
-}
-
-/**
- * nm_ip4_address_get_address:
- * @address: the #NMIP4Address
- *
- * Gets the IPv4 address property of this address object.
- *
- * Returns: the IPv4 address in network byte order
- **/
-guint32
-nm_ip4_address_get_address (NMIP4Address *address)
-{
- g_return_val_if_fail (address != NULL, 0);
- g_return_val_if_fail (address->refcount > 0, 0);
-
- return address->address;
-}
-
-/**
- * nm_ip4_address_set_address:
- * @address: the #NMIP4Address
- * @addr: the IPv4 address in network byte order
- *
- * Sets the IPv4 address property of this object.
- **/
-void
-nm_ip4_address_set_address (NMIP4Address *address, guint32 addr)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
-
- address->address = addr;
-}
-
-/**
- * nm_ip4_address_get_prefix:
- * @address: the #NMIP4Address
- *
- * Gets the IPv4 address prefix (ie "24" or "30" etc) property of this address
- * object.
- *
- * Returns: the IPv4 address prefix
- **/
-guint32
-nm_ip4_address_get_prefix (NMIP4Address *address)
-{
- g_return_val_if_fail (address != NULL, 0);
- g_return_val_if_fail (address->refcount > 0, 0);
-
- return address->prefix;
-}
-
-/**
- * nm_ip4_address_set_prefix:
- * @address: the #NMIP4Address
- * @prefix: the address prefix, a number between 1 and 32 inclusive
- *
- * Sets the IPv4 address prefix.
- **/
-void
-nm_ip4_address_set_prefix (NMIP4Address *address, guint32 prefix)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
- g_return_if_fail (prefix <= 32);
- g_return_if_fail (prefix > 0);
-
- address->prefix = prefix;
-}
-
-/**
- * nm_ip4_address_get_gateway:
- * @address: the #NMIP4Address
- *
- * Gets the IPv4 default gateway property of this address object.
- *
- * Returns: the IPv4 gateway address in network byte order
- **/
-guint32
-nm_ip4_address_get_gateway (NMIP4Address *address)
-{
- g_return_val_if_fail (address != NULL, 0);
- g_return_val_if_fail (address->refcount > 0, 0);
-
- return address->gateway;
-}
-
-/**
- * nm_ip4_address_set_gateway:
- * @address: the #NMIP4Address
- * @gateway: the IPv4 default gateway in network byte order
- *
- * Sets the IPv4 default gateway property of this address object.
- **/
-void
-nm_ip4_address_set_gateway (NMIP4Address *address, guint32 gateway)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
-
- address->gateway = gateway;
-}
-
-struct NMIP4Route {
- guint32 refcount;
-
- guint32 dest; /* network byte order */
- guint32 prefix;
- guint32 next_hop; /* network byte order */
- guint32 metric; /* lower metric == more preferred */
-};
-
-/**
- * nm_ip4_route_new:
- *
- * Creates and returns a new #NMIP4Route object.
- *
- * Returns: (transfer full): the new empty #NMIP4Route object
- **/
-NMIP4Route *
-nm_ip4_route_new (void)
-{
- NMIP4Route *route;
-
- route = g_malloc0 (sizeof (NMIP4Route));
- route->refcount = 1;
- return route;
-}
-
-/**
- * nm_ip4_route_dup:
- * @source: the #NMIP4Route object to copy
- *
- * Copies a given #NMIP4Route object and returns the copy.
- *
- * Returns: (transfer full): the copy of the given #NMIP4Route copy
- **/
-NMIP4Route *
-nm_ip4_route_dup (NMIP4Route *source)
-{
- NMIP4Route *route;
-
- g_return_val_if_fail (source != NULL, NULL);
- g_return_val_if_fail (source->refcount > 0, NULL);
-
- route = nm_ip4_route_new ();
- route->dest = source->dest;
- route->prefix = source->prefix;
- route->next_hop = source->next_hop;
- route->metric = source->metric;
-
- return route;
-}
-
-/**
- * nm_ip4_route_ref:
- * @route: the #NMIP4Route
- *
- * Increases the reference count of the object.
- **/
-void
-nm_ip4_route_ref (NMIP4Route *route)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
-
- route->refcount++;
-}
-
-/**
- * nm_ip4_route_unref:
- * @route: the #NMIP4Route
- *
- * Decreases the reference count of the object. If the reference count
- * reaches zero, the object will be destroyed.
- **/
-void
-nm_ip4_route_unref (NMIP4Route *route)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
-
- route->refcount--;
- if (route->refcount == 0) {
- memset (route, 0, sizeof (NMIP4Route));
- g_free (route);
- }
-}
-
-/**
- * nm_ip4_route_compare:
- * @route: the #NMIP4Route
- * @other: the #NMIP4Route to compare @route to.
- *
- * Determines if two #NMIP4Route objects contain the same values.
- *
- * Returns: %TRUE if the objects contain the same values, %FALSE if they do not.
- **/
-gboolean
-nm_ip4_route_compare (NMIP4Route *route, NMIP4Route *other)
-{
- g_return_val_if_fail (route != NULL, FALSE);
- g_return_val_if_fail (route->refcount > 0, FALSE);
-
- g_return_val_if_fail (other != NULL, FALSE);
- g_return_val_if_fail (other->refcount > 0, FALSE);
-
- if ( route->dest != other->dest
- || route->prefix != other->prefix
- || route->next_hop != other->next_hop
- || route->metric != other->metric)
- return FALSE;
- return TRUE;
-}
-
-/**
- * nm_ip4_route_get_dest:
- * @route: the #NMIP4Route
- *
- * Gets the IPv4 destination address property of this route object.
- *
- * Returns: the IPv4 address in network byte order
- **/
-guint32
-nm_ip4_route_get_dest (NMIP4Route *route)
-{
- g_return_val_if_fail (route != NULL, 0);
- g_return_val_if_fail (route->refcount > 0, 0);
-
- return route->dest;
-}
-
-/**
- * nm_ip4_route_set_dest:
- * @route: the #NMIP4Route
- * @dest: the destination address in network byte order
- *
- * Sets the IPv4 destination address property of this route object.
- **/
-void
-nm_ip4_route_set_dest (NMIP4Route *route, guint32 dest)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
-
- route->dest = dest;
-}
-
-/**
- * nm_ip4_route_get_prefix:
- * @route: the #NMIP4Route
- *
- * Gets the IPv4 prefix (ie "24" or "30" etc) of this route.
- *
- * Returns: the IPv4 prefix
- **/
-guint32
-nm_ip4_route_get_prefix (NMIP4Route *route)
-{
- g_return_val_if_fail (route != NULL, 0);
- g_return_val_if_fail (route->refcount > 0, 0);
-
- return route->prefix;
-}
-
-/**
- * nm_ip4_route_set_prefix:
- * @route: the #NMIP4Route
- * @prefix: the prefix, a number between 1 and 32 inclusive
- *
- * Sets the IPv4 prefix of this route.
- **/
-void
-nm_ip4_route_set_prefix (NMIP4Route *route, guint32 prefix)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
- g_return_if_fail (prefix <= 32);
- g_return_if_fail (prefix > 0);
-
- route->prefix = prefix;
-}
-
-/**
- * nm_ip4_route_get_next_hop:
- * @route: the #NMIP4Route
- *
- * Gets the IPv4 address of the next hop of this route.
- *
- * Returns: the IPv4 address in network byte order
- **/
-guint32
-nm_ip4_route_get_next_hop (NMIP4Route *route)
-{
- g_return_val_if_fail (route != NULL, 0);
- g_return_val_if_fail (route->refcount > 0, 0);
-
- return route->next_hop;
-}
-
-/**
- * nm_ip4_route_set_next_hop:
- * @route: the #NMIP4Route
- * @next_hop: the IPv4 address of the next hop in network byte order
- *
- * Sets the IPv4 address of the next hop of this route.
- **/
-void
-nm_ip4_route_set_next_hop (NMIP4Route *route, guint32 next_hop)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
-
- route->next_hop = next_hop;
-}
-
-/**
- * nm_ip4_route_get_metric:
- * @route: the #NMIP4Route
- *
- * Gets the route metric property of this route object; lower values indicate
- * "better" or more preferred routes.
- *
- * Returns: the route metric
- **/
-guint32
-nm_ip4_route_get_metric (NMIP4Route *route)
-{
- g_return_val_if_fail (route != NULL, 0);
- g_return_val_if_fail (route->refcount > 0, 0);
-
- return route->metric;
-}
-
-/**
- * nm_ip4_route_set_metric:
- * @route: the #NMIP4Route
- * @metric: the route metric
- *
- * Sets the route metric property of this route object; lower values indicate
- * "better" or more preferred routes.
- **/
-void
-nm_ip4_route_set_metric (NMIP4Route *route, guint32 metric)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
-
- route->metric = metric;
-}
diff --git a/libnm-util/nm-setting-ip4-config.h b/libnm-util/nm-setting-ip4-config.h
deleted file mode 100644
index 4d50547d79..0000000000
--- a/libnm-util/nm-setting-ip4-config.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_IP4_CONFIG_H
-#define NM_SETTING_IP4_CONFIG_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_IP4_CONFIG (nm_setting_ip4_config_get_type ())
-#define NM_SETTING_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_IP4_CONFIG, NMSettingIP4Config))
-#define NM_SETTING_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_IP4CONFIG, NMSettingIP4ConfigClass))
-#define NM_IS_SETTING_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_IP4_CONFIG))
-#define NM_IS_SETTING_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_IP4_CONFIG))
-#define NM_SETTING_IP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_IP4_CONFIG, NMSettingIP4ConfigClass))
-
-#define NM_SETTING_IP4_CONFIG_SETTING_NAME "ipv4"
-
-/**
- * NMSettingIP4ConfigError:
- * @NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD: the property's value is
- * not valid with the given IP4 method
- */
-typedef enum {
- NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD /*< nick=NotAllowedForMethod >*/
-} NMSettingIP4ConfigError;
-
-#define NM_SETTING_IP4_CONFIG_ERROR nm_setting_ip4_config_error_quark ()
-GQuark nm_setting_ip4_config_error_quark (void);
-
-#define NM_SETTING_IP4_CONFIG_METHOD "method"
-#define NM_SETTING_IP4_CONFIG_DNS "dns"
-#define NM_SETTING_IP4_CONFIG_DNS_SEARCH "dns-search"
-#define NM_SETTING_IP4_CONFIG_ADDRESSES "addresses"
-#define NM_SETTING_IP4_CONFIG_ROUTES "routes"
-#define NM_SETTING_IP4_CONFIG_ROUTE_METRIC "route-metric"
-#define NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
-#define NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
-#define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id"
-#define NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
-#define NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
-#define NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT "dhcp-timeout"
-#define NM_SETTING_IP4_CONFIG_NEVER_DEFAULT "never-default"
-#define NM_SETTING_IP4_CONFIG_MAY_FAIL "may-fail"
-
-/**
- * NM_SETTING_IP4_CONFIG_METHOD_AUTO:
- *
- * IPv4 configuration should be automatically determined via a method appropriate
- * for the hardware interface, ie DHCP or PPP or some other device-specific
- * manner.
- */
-#define NM_SETTING_IP4_CONFIG_METHOD_AUTO "auto"
-
-/**
- * NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL:
- *
- * IPv4 configuration should be automatically configured for link-local-only
- * operation.
- */
-#define NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL "link-local"
-
-/**
- * NM_SETTING_IP4_CONFIG_METHOD_MANUAL:
- *
- * All necessary IPv4 configuration (addresses, prefix, DNS, etc) is specified
- * in the setting's properties.
- */
-#define NM_SETTING_IP4_CONFIG_METHOD_MANUAL "manual"
-
-/**
- * NM_SETTING_IP4_CONFIG_METHOD_SHARED:
- *
- * This connection specifies configuration that allows other computers to
- * connect through it to the default network (usually the Internet). The
- * connection's interface will be assigned a private address, and a DHCP server,
- * caching DNS server, and Network Address Translation (NAT) functionality will
- * be started on this connection's interface to allow other devices to connect
- * through that interface to the default network.
- */
-#define NM_SETTING_IP4_CONFIG_METHOD_SHARED "shared"
-
-/**
- * NM_SETTING_IP4_CONFIG_METHOD_DISABLED:
- *
- * This connection does not use or require IPv4 address and it should be disabled.
- */
-#define NM_SETTING_IP4_CONFIG_METHOD_DISABLED "disabled"
-
-typedef struct NMIP4Address NMIP4Address;
-
-GType nm_ip4_address_get_type (void);
-
-NMIP4Address * nm_ip4_address_new (void);
-NMIP4Address * nm_ip4_address_dup (NMIP4Address *source);
-void nm_ip4_address_ref (NMIP4Address *address);
-void nm_ip4_address_unref (NMIP4Address *address);
-/* Return TRUE if addresses are identical */
-gboolean nm_ip4_address_compare (NMIP4Address *address, NMIP4Address *other);
-
-guint32 nm_ip4_address_get_address (NMIP4Address *address);
-void nm_ip4_address_set_address (NMIP4Address *address,
- guint32 addr); /* network byte order */
-
-guint32 nm_ip4_address_get_prefix (NMIP4Address *address);
-void nm_ip4_address_set_prefix (NMIP4Address *address,
- guint32 prefix);
-
-guint32 nm_ip4_address_get_gateway (NMIP4Address *address);
-void nm_ip4_address_set_gateway (NMIP4Address *address,
- guint32 gateway); /* network byte order */
-
-typedef struct NMIP4Route NMIP4Route;
-
-GType nm_ip4_route_get_type (void);
-
-NMIP4Route * nm_ip4_route_new (void);
-NMIP4Route * nm_ip4_route_dup (NMIP4Route *source);
-void nm_ip4_route_ref (NMIP4Route *route);
-void nm_ip4_route_unref (NMIP4Route *route);
-/* Return TRUE if routes are identical */
-gboolean nm_ip4_route_compare (NMIP4Route *route, NMIP4Route *other);
-
-guint32 nm_ip4_route_get_dest (NMIP4Route *route);
-void nm_ip4_route_set_dest (NMIP4Route *route,
- guint32 dest); /* network byte order */
-
-guint32 nm_ip4_route_get_prefix (NMIP4Route *route);
-void nm_ip4_route_set_prefix (NMIP4Route *route,
- guint32 prefix);
-
-guint32 nm_ip4_route_get_next_hop (NMIP4Route *route);
-void nm_ip4_route_set_next_hop (NMIP4Route *route,
- guint32 next_hop); /* network byte order */
-
-guint32 nm_ip4_route_get_metric (NMIP4Route *route);
-void nm_ip4_route_set_metric (NMIP4Route *route,
- guint32 metric);
-
-typedef struct {
- NMSetting parent;
-} NMSettingIP4Config;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingIP4ConfigClass;
-
-GType nm_setting_ip4_config_get_type (void);
-
-NMSetting * nm_setting_ip4_config_new (void);
-const char * nm_setting_ip4_config_get_method (NMSettingIP4Config *setting);
-
-guint32 nm_setting_ip4_config_get_num_dns (NMSettingIP4Config *setting);
-guint32 nm_setting_ip4_config_get_dns (NMSettingIP4Config *setting, guint32 i);
-gboolean nm_setting_ip4_config_add_dns (NMSettingIP4Config *setting, guint32 dns);
-void nm_setting_ip4_config_remove_dns (NMSettingIP4Config *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_ip4_config_remove_dns_by_value (NMSettingIP4Config *setting, guint32 dns);
-void nm_setting_ip4_config_clear_dns (NMSettingIP4Config *setting);
-
-guint32 nm_setting_ip4_config_get_num_dns_searches (NMSettingIP4Config *setting);
-const char * nm_setting_ip4_config_get_dns_search (NMSettingIP4Config *setting, guint32 i);
-gboolean nm_setting_ip4_config_add_dns_search (NMSettingIP4Config *setting, const char *dns_search);
-void nm_setting_ip4_config_remove_dns_search (NMSettingIP4Config *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_ip4_config_remove_dns_search_by_value (NMSettingIP4Config *setting, const char *dns_search);
-void nm_setting_ip4_config_clear_dns_searches (NMSettingIP4Config *setting);
-
-guint32 nm_setting_ip4_config_get_num_addresses (NMSettingIP4Config *setting);
-NMIP4Address *nm_setting_ip4_config_get_address (NMSettingIP4Config *setting, guint32 i);
-gboolean nm_setting_ip4_config_add_address (NMSettingIP4Config *setting, NMIP4Address *address);
-void nm_setting_ip4_config_remove_address (NMSettingIP4Config *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_ip4_config_remove_address_by_value (NMSettingIP4Config *setting, NMIP4Address *address);
-void nm_setting_ip4_config_clear_addresses (NMSettingIP4Config *setting);
-
-guint32 nm_setting_ip4_config_get_num_routes (NMSettingIP4Config *setting);
-NMIP4Route * nm_setting_ip4_config_get_route (NMSettingIP4Config *setting, guint32 i);
-gboolean nm_setting_ip4_config_add_route (NMSettingIP4Config *setting, NMIP4Route *route);
-void nm_setting_ip4_config_remove_route (NMSettingIP4Config *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_ip4_config_remove_route_by_value (NMSettingIP4Config *setting, NMIP4Route *route);
-void nm_setting_ip4_config_clear_routes (NMSettingIP4Config *setting);
-
-NM_AVAILABLE_IN_1_0
-gint64 nm_setting_ip4_config_get_route_metric (NMSettingIP4Config *setting);
-
-gboolean nm_setting_ip4_config_get_ignore_auto_routes (NMSettingIP4Config *setting);
-gboolean nm_setting_ip4_config_get_ignore_auto_dns (NMSettingIP4Config *setting);
-const char * nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting);
-gboolean nm_setting_ip4_config_get_dhcp_send_hostname (NMSettingIP4Config *setting);
-const char * nm_setting_ip4_config_get_dhcp_hostname (NMSettingIP4Config *setting);
-NM_AVAILABLE_IN_1_2
-int nm_setting_ip4_config_get_dhcp_timeout (NMSettingIP4Config *setting);
-
-gboolean nm_setting_ip4_config_get_never_default (NMSettingIP4Config *setting);
-
-gboolean nm_setting_ip4_config_get_may_fail (NMSettingIP4Config *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_IP4_CONFIG_H */
diff --git a/libnm-util/nm-setting-ip6-config.c b/libnm-util/nm-setting-ip6-config.c
deleted file mode 100644
index 6beeb7da21..0000000000
--- a/libnm-util/nm-setting-ip6-config.c
+++ /dev/null
@@ -1,1776 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-ip6-config.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-ip6-config
- * @short_description: Describes IPv6 addressing, routing, and name service properties
- * @include: nm-setting-ip6-config.h
- *
- * The #NMSettingIP6Config object is a #NMSetting subclass that describes
- * properties related to IPv6 addressing, routing, and Domain Name Service
- **/
-
-/**
- * nm_setting_ip6_config_error_quark:
- *
- * Registers an error quark for #NMSettingIP6Config if necessary.
- *
- * Returns: the error quark used for #NMSettingIP6Config errors.
- **/
-GQuark
-nm_setting_ip6_config_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-ip6-config-error-quark");
- return quark;
-}
-
-G_DEFINE_BOXED_TYPE (NMIP6Address, nm_ip6_address, nm_ip6_address_dup, nm_ip6_address_unref)
-G_DEFINE_BOXED_TYPE (NMIP6Route, nm_ip6_route, nm_ip6_route_dup, nm_ip6_route_unref)
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingIP6Config, nm_setting_ip6_config, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_IP6_CONFIG_SETTING_NAME,
- g_define_type_id,
- 4,
- NM_SETTING_IP6_CONFIG_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP6_CONFIG)
-
-#define NM_SETTING_IP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_IP6_CONFIG, NMSettingIP6ConfigPrivate))
-
-typedef struct {
- char *method;
- char *dhcp_hostname;
- GSList *dns; /* array of struct in6_addr */
- GSList *dns_search; /* list of strings */
- GSList *addresses; /* array of NMIP6Address */
- GSList *routes; /* array of NMIP6Route */
- gint64 route_metric;
- gboolean ignore_auto_routes;
- gboolean ignore_auto_dns;
- gboolean never_default;
- gboolean may_fail;
- NMSettingIP6ConfigPrivacy ip6_privacy;
-} NMSettingIP6ConfigPrivate;
-
-enum {
- PROP_0,
- PROP_METHOD,
- PROP_DHCP_HOSTNAME,
- PROP_DNS,
- PROP_DNS_SEARCH,
- PROP_ADDRESSES,
- PROP_ROUTES,
- PROP_ROUTE_METRIC,
- PROP_IGNORE_AUTO_ROUTES,
- PROP_IGNORE_AUTO_DNS,
- PROP_NEVER_DEFAULT,
- PROP_MAY_FAIL,
- PROP_IP6_PRIVACY,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_ip6_config_new:
- *
- * Creates a new #NMSettingIP6Config object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingIP6Config object
- **/
-NMSetting *
-nm_setting_ip6_config_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_IP6_CONFIG, NULL);
-}
-
-/**
- * nm_setting_ip6_config_get_method:
- * @setting: the #NMSettingIP6Config
- *
- * Returns: the #NMSettingIP6Config:method property of the setting
- **/
-const char *
-nm_setting_ip6_config_get_method (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
-
- return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->method;
-}
-
-/**
- * nm_setting_ip6_config_get_dhcp_hostname:
- * @setting: the #NMSettingIP6Config
- *
- * Returns the value contained in the #NMSettingIP6Config:dhcp-hostname
- * property.
- *
- * Returns: the configured hostname to send to the DHCP server
- *
- * Since: 0.9.8
- **/
-const char *
-nm_setting_ip6_config_get_dhcp_hostname (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
-
- return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->dhcp_hostname;
-}
-
-/**
- * nm_setting_ip6_config_get_num_dns:
- * @setting: the #NMSettingIP6Config
- *
- * Returns: the number of configured DNS servers
- **/
-guint32
-nm_setting_ip6_config_get_num_dns (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), 0);
-
- return g_slist_length (NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->dns);
-}
-
-/**
- * nm_setting_ip6_config_get_dns:
- * @setting: the #NMSettingIP6Config
- * @i: index number of the DNS server to return
- *
- * Returns: (transfer none): the IPv6 address of the DNS server at index @i
- **/
-const struct in6_addr *
-nm_setting_ip6_config_get_dns (NMSettingIP6Config *setting, guint32 i)
-{
- NMSettingIP6ConfigPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->dns), NULL);
-
- return (const struct in6_addr *) g_slist_nth_data (priv->dns, i);
-}
-
-/**
- * nm_setting_ip6_config_add_dns:
- * @setting: the #NMSettingIP6Config
- * @dns: the IPv6 address of the DNS server to add
- *
- * Adds a new DNS server to the setting.
- *
- * Returns: %TRUE if the DNS server was added; %FALSE if the server was already
- * known
- **/
-gboolean
-nm_setting_ip6_config_add_dns (NMSettingIP6Config *setting, const struct in6_addr *addr)
-{
- NMSettingIP6ConfigPrivate *priv;
- struct in6_addr *copy;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->dns; iter; iter = g_slist_next (iter)) {
- if (!memcmp (addr, (struct in6_addr *) iter->data, sizeof (struct in6_addr)))
- return FALSE;
- }
-
- copy = g_malloc0 (sizeof (struct in6_addr));
- memcpy (copy, addr, sizeof (struct in6_addr));
- priv->dns = g_slist_append (priv->dns, copy);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS);
-
- return TRUE;
-}
-
-/**
- * nm_setting_ip6_config_remove_dns:
- * @setting: the #NMSettingIP6Config
- * @i: index number of the DNS server to remove
- *
- * Removes the DNS server at index @i.
- **/
-void
-nm_setting_ip6_config_remove_dns (NMSettingIP6Config *setting, guint32 i)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->dns, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->dns = g_slist_delete_link (priv->dns, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS);
-}
-
-/**
- * nm_setting_ip6_config_remove_dns_by_value:
- * @setting: the #NMSettingIP6Config
- * @dns: the IPv6 address of the DNS server to remove
- *
- * Removes the DNS server at index @i.
- *
- * Returns: %TRUE if the DNS server was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_ip6_config_remove_dns_by_value (NMSettingIP6Config *setting,
- const struct in6_addr *addr)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->dns; iter; iter = g_slist_next (iter)) {
- if (!memcmp (addr, (struct in6_addr *) iter->data, sizeof (struct in6_addr))) {
- priv->dns = g_slist_delete_link (priv->dns, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_ip6_config_clear_dns:
- * @setting: the #NMSettingIP6Config
- *
- * Removes all configured DNS servers.
- **/
-void
-nm_setting_ip6_config_clear_dns (NMSettingIP6Config *setting)
-{
- g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
-
- g_slist_free_full (NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->dns, g_free);
- NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->dns = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS);
-}
-
-/**
- * nm_setting_ip6_config_get_num_dns_searches:
- * @setting: the #NMSettingIP6Config
- *
- * Returns: the number of configured DNS search domains
- **/
-guint32
-nm_setting_ip6_config_get_num_dns_searches (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), 0);
-
- return g_slist_length (NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->dns_search);
-}
-
-/**
- * nm_setting_ip6_config_get_dns_search:
- * @setting: the #NMSettingIP6Config
- * @i: index number of the DNS search domain to return
- *
- * Returns: the DNS search domain at index @i
- **/
-const char *
-nm_setting_ip6_config_get_dns_search (NMSettingIP6Config *setting, guint32 i)
-{
- NMSettingIP6ConfigPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->dns_search), NULL);
-
- return (const char *) g_slist_nth_data (priv->dns_search, i);
-}
-
-/**
- * nm_setting_ip6_config_add_dns_search:
- * @setting: the #NMSettingIP6Config
- * @dns_search: the search domain to add
- *
- * Adds a new DNS search domain to the setting.
- *
- * Returns: %TRUE if the DNS search domain was added; %FALSE if the search
- * domain was already known
- **/
-gboolean
-nm_setting_ip6_config_add_dns_search (NMSettingIP6Config *setting,
- const char *dns_search)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
- g_return_val_if_fail (dns_search != NULL, FALSE);
- g_return_val_if_fail (dns_search[0] != '\0', FALSE);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->dns_search; iter; iter = g_slist_next (iter)) {
- if (!strcmp (dns_search, (char *) iter->data))
- return FALSE;
- }
-
- priv->dns_search = g_slist_append (priv->dns_search, g_strdup (dns_search));
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS_SEARCH);
- return TRUE;
-}
-
-/**
- * nm_setting_ip6_config_remove_dns_search:
- * @setting: the #NMSettingIP6Config
- * @i: index number of the DNS search domain
- *
- * Removes the DNS search domain at index @i.
- **/
-void
-nm_setting_ip6_config_remove_dns_search (NMSettingIP6Config *setting, guint32 i)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->dns_search, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->dns_search = g_slist_delete_link (priv->dns_search, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS_SEARCH);
-}
-
-/**
- * nm_setting_ip6_config_remove_dns_search_by_value:
- * @setting: the #NMSettingIP6Config
- * @dns_search: the search domain to remove
- *
- * Removes the DNS search domain @dns_search.
- *
- * Returns: %TRUE if the DNS search domain was found and removed; %FALSE if it was not.
- *
- * Since 0.9.10
- **/
-gboolean
-nm_setting_ip6_config_remove_dns_search_by_value (NMSettingIP6Config *setting,
- const char *dns_search)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
- g_return_val_if_fail (dns_search != NULL, FALSE);
- g_return_val_if_fail (dns_search[0] != '\0', FALSE);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->dns_search; iter; iter = g_slist_next (iter)) {
- if (!strcmp (dns_search, (char *) iter->data)) {
- priv->dns_search = g_slist_delete_link (priv->dns_search, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS_SEARCH);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_ip6_config_clear_dns_searches:
- * @setting: the #NMSettingIP6Config
- *
- * Removes all configured DNS search domains.
- **/
-void
-nm_setting_ip6_config_clear_dns_searches (NMSettingIP6Config *setting)
-{
- g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
-
- g_slist_free_full (NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->dns_search, g_free);
- NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->dns_search = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS_SEARCH);
-}
-
-/**
- * nm_setting_ip6_config_get_num_addresses:
- * @setting: the #NMSettingIP6Config
- *
- * Returns: the number of configured addresses
- **/
-guint32
-nm_setting_ip6_config_get_num_addresses (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), 0);
-
- return g_slist_length (NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->addresses);
-}
-
-/**
- * nm_setting_ip6_config_get_address:
- * @setting: the #NMSettingIP6Config
- * @i: index number of the address to return
- *
- * Returns: the address at index @i
- **/
-NMIP6Address *
-nm_setting_ip6_config_get_address (NMSettingIP6Config *setting, guint32 i)
-{
- NMSettingIP6ConfigPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->addresses), NULL);
-
- return (NMIP6Address *) g_slist_nth_data (priv->addresses, i);
-}
-
-/**
- * nm_setting_ip6_config_add_address:
- * @setting: the #NMSettingIP6Config
- * @address: the new address to add
- *
- * Adds a new IPv6 address and associated information to the setting. The
- * given address is duplicated internally and is not changed by this function.
- *
- * Returns: %TRUE if the address was added; %FALSE if the address was already
- * known.
- **/
-gboolean
-nm_setting_ip6_config_add_address (NMSettingIP6Config *setting,
- NMIP6Address *address)
-{
- NMSettingIP6ConfigPrivate *priv;
- NMIP6Address *copy;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
- g_return_val_if_fail (address != NULL, FALSE);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->addresses; iter; iter = g_slist_next (iter)) {
- if (nm_ip6_address_compare ((NMIP6Address *) iter->data, address))
- return FALSE;
- }
-
- copy = nm_ip6_address_dup (address);
- priv->addresses = g_slist_append (priv->addresses, copy);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ADDRESSES);
- return TRUE;
-}
-
-/**
- * nm_setting_ip6_config_remove_address:
- * @setting: the #NMSettingIP6Config
- * @i: index number of the address to remove
- *
- * Removes the address at index @i.
- **/
-void
-nm_setting_ip6_config_remove_address (NMSettingIP6Config *setting, guint32 i)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->addresses, i);
- g_return_if_fail (elt != NULL);
-
- nm_ip6_address_unref ((NMIP6Address *) elt->data);
- priv->addresses = g_slist_delete_link (priv->addresses, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ADDRESSES);
-}
-
-/**
- * nm_setting_ip6_config_remove_address_by_value:
- * @setting: the #NMSettingIP6Config
- * @address: the address to remove
- *
- * Removes the address @address.
- *
- * Returns: %TRUE if the address was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_ip6_config_remove_address_by_value (NMSettingIP6Config *setting,
- NMIP6Address *address)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
- g_return_val_if_fail (address != NULL, FALSE);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->addresses; iter; iter = g_slist_next (iter)) {
- if (nm_ip6_address_compare ((NMIP6Address *) iter->data, address)) {
- priv->addresses = g_slist_delete_link (priv->addresses, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ADDRESSES);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_ip6_config_clear_addresses:
- * @setting: the #NMSettingIP6Config
- *
- * Removes all configured addresses.
- **/
-void
-nm_setting_ip6_config_clear_addresses (NMSettingIP6Config *setting)
-{
- NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
-
- g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
-
- g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref);
- priv->addresses = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ADDRESSES);
-}
-
-/**
- * nm_setting_ip6_config_get_num_routes:
- * @setting: the #NMSettingIP6Config
- *
- * Returns: the number of configured routes
- **/
-guint32
-nm_setting_ip6_config_get_num_routes (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), 0);
-
- return g_slist_length (NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->routes);
-}
-
-/**
- * nm_setting_ip6_config_get_route:
- * @setting: the #NMSettingIP6Config
- * @i: index number of the route to return
- *
- * Returns: the route at index @i
- **/
-NMIP6Route *
-nm_setting_ip6_config_get_route (NMSettingIP6Config *setting, guint32 i)
-{
- NMSettingIP6ConfigPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->routes), NULL);
-
- return (NMIP6Route *) g_slist_nth_data (priv->routes, i);
-}
-
-/**
- * nm_setting_ip6_config_add_route:
- * @setting: the #NMSettingIP6Config
- * @route: the route to add
- *
- * Adds a new IPv6 route and associated information to the setting. The
- * given route is duplicated internally and is not changed by this function.
- *
- * Returns: %TRUE if the route was added; %FALSE if the route was already known.
- **/
-gboolean
-nm_setting_ip6_config_add_route (NMSettingIP6Config *setting,
- NMIP6Route *route)
-{
- NMSettingIP6ConfigPrivate *priv;
- NMIP6Route *copy;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
- g_return_val_if_fail (route != NULL, FALSE);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->routes; iter; iter = g_slist_next (iter)) {
- if (nm_ip6_route_compare ((NMIP6Route *) iter->data, route))
- return FALSE;
- }
-
- copy = nm_ip6_route_dup (route);
- priv->routes = g_slist_append (priv->routes, copy);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ROUTES);
- return TRUE;
-}
-
-/**
- * nm_setting_ip6_config_remove_route:
- * @setting: the #NMSettingIP6Config
- * @i: index number of the route
- *
- * Removes the route at index @i.
- **/
-void
-nm_setting_ip6_config_remove_route (NMSettingIP6Config *setting, guint32 i)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->routes, i);
- g_return_if_fail (elt != NULL);
-
- nm_ip6_route_unref ((NMIP6Route *) elt->data);
- priv->routes = g_slist_delete_link (priv->routes, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ROUTES);
-}
-
-/**
- * nm_setting_ip6_config_remove_route_by_value:
- * @setting: the #NMSettingIP6Config
- * @route: the route to remove
- *
- * Removes the route @route.
- *
- * Returns: %TRUE if the route was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_ip6_config_remove_route_by_value (NMSettingIP6Config *setting,
- NMIP6Route *route)
-{
- NMSettingIP6ConfigPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
- g_return_val_if_fail (route != NULL, FALSE);
-
- priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- for (iter = priv->routes; iter; iter = g_slist_next (iter)) {
- if (nm_ip6_route_compare ((NMIP6Route *) iter->data, route)) {
- nm_ip6_route_unref ((NMIP6Route *) iter->data);
- priv->routes = g_slist_delete_link (priv->routes, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ROUTES);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_ip6_config_clear_routes:
- * @setting: the #NMSettingIP6Config
- *
- * Removes all configured routes.
- **/
-void
-nm_setting_ip6_config_clear_routes (NMSettingIP6Config *setting)
-{
- NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
-
- g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
-
- g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
- priv->routes = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ROUTES);
-}
-
-/**
- * nm_setting_ip6_config_get_route_metric:
- * @setting: the #NMSettingIP6Config
- *
- * Returns the value contained in the #NMSettingIP6Config:route-metric
- * property.
- *
- * Returns: the route metric that is used for IPv6 routes that don't explicitly
- * specify a metric. See #NMSettingIP6Config:route-metric for more details.
- *
- * Since: 1.0
- **/
-gint64
-nm_setting_ip6_config_get_route_metric (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), -1);
-
- return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->route_metric;
-}
-
-/**
- * nm_setting_ip6_config_get_ignore_auto_routes:
- * @setting: the #NMSettingIP6Config
- *
- * Returns the value contained in the #NMSettingIP6Config:ignore-auto-routes
- * property.
- *
- * Returns: %TRUE if automatically configured (ie via DHCP) routes should be
- * ignored.
- **/
-gboolean
-nm_setting_ip6_config_get_ignore_auto_routes (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->ignore_auto_routes;
-}
-
-/**
- * nm_setting_ip6_config_get_ignore_auto_dns:
- * @setting: the #NMSettingIP6Config
- *
- * Returns the value contained in the #NMSettingIP6Config:ignore-auto-dns
- * property.
- *
- * Returns: %TRUE if automatically configured (ie via DHCP or router
- * advertisements) DNS information should be ignored.
- **/
-gboolean
-nm_setting_ip6_config_get_ignore_auto_dns (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->ignore_auto_dns;
-}
-
-/**
- * nm_setting_ip6_config_get_never_default:
- * @setting: the #NMSettingIP6Config
- *
- * Returns the value contained in the #NMSettingIP6Config:never-default
- * property.
- *
- * Returns: %TRUE if this connection should never be the default connection
- * for IPv6 addressing
- **/
-gboolean
-nm_setting_ip6_config_get_never_default (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->never_default;
-}
-
-/**
- * nm_setting_ip6_config_get_may_fail:
- * @setting: the #NMSettingIP6Config
- *
- * Returns the value contained in the #NMSettingIP6Config:may-fail
- * property.
- *
- * Returns: %TRUE if this connection doesn't require IPv6 addressing to complete
- * for the connection to succeed.
- **/
-gboolean
-nm_setting_ip6_config_get_may_fail (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
-
- return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->may_fail;
-}
-
-/**
- * nm_setting_ip6_config_get_ip6_privacy:
- * @setting: the #NMSettingIP6Config
- *
- * Returns the value contained in the #NMSettingIP6Config:ip6-privacy
- * property.
- *
- * Returns: IPv6 Privacy Extensions configuration value (#NMSettingIP6ConfigPrivacy).
- **/
-NMSettingIP6ConfigPrivacy
-nm_setting_ip6_config_get_ip6_privacy (NMSettingIP6Config *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
-
- return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->ip6_privacy;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
- GSList *iter;
- int i;
-
- if (!priv->method) {
- g_set_error_literal (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_METHOD);
- return FALSE;
- }
-
- if (!strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
- if (!priv->addresses) {
- g_set_error (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY,
- _("this property cannot be empty for '%s=%s'"),
- NM_SETTING_IP6_CONFIG_METHOD, priv->method);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDRESSES);
- return FALSE;
- }
- } else if ( !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)
- || !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)
- || !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) {
- if (g_slist_length (priv->dns)) {
- g_set_error (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
- _("this property is not allowed for '%s=%s'"),
- NM_SETTING_IP6_CONFIG_METHOD, priv->method);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DNS);
- return FALSE;
- }
-
- if (g_slist_length (priv->dns_search)) {
- g_set_error (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
- _("this property is not allowed for '%s=%s'"),
- NM_SETTING_IP6_CONFIG_METHOD, priv->method);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DNS_SEARCH);
- return FALSE;
- }
-
- /* Shared allows IP addresses; link-local and disabled do not */
- if (strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) != 0) {
- if (g_slist_length (priv->addresses)) {
- g_set_error (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
- _("this property is not allowed for '%s=%s'"),
- NM_SETTING_IP6_CONFIG_METHOD, priv->method);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDRESSES);
- return FALSE;
- }
- }
- } else if ( !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)
- || !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
- /* nothing to do */
- } else {
- g_set_error_literal (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_METHOD);
- return FALSE;
- }
-
- if (priv->dhcp_hostname && !strlen (priv->dhcp_hostname)) {
- g_set_error_literal (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME);
- return FALSE;
- }
-
- /* Validate addresses */
- for (iter = priv->addresses, i = 0; iter; iter = g_slist_next (iter), i++) {
- NMIP6Address *addr = (NMIP6Address *) iter->data;
- guint32 prefix = nm_ip6_address_get_prefix (addr);
-
- if (IN6_IS_ADDR_UNSPECIFIED (nm_ip6_address_get_address (addr))) {
- g_set_error (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY,
- _("%d. IPv6 address is invalid"),
- i+1);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDRESSES);
- return FALSE;
- }
-
- if (!prefix || prefix > 128) {
- g_set_error (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY,
- _("%d. IPv6 address has invalid prefix"),
- i+1);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDRESSES);
- return FALSE;
- }
- }
-
- /* Validate routes */
- for (iter = priv->routes, i = 0; iter; iter = g_slist_next (iter), i++) {
- NMIP6Route *route = (NMIP6Route *) iter->data;
- guint32 prefix = nm_ip6_route_get_prefix (route);
-
- if (!prefix || prefix > 128) {
- g_set_error (error,
- NM_SETTING_IP6_CONFIG_ERROR,
- NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY,
- _("%d. route has invalid prefix"),
- i+1);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ROUTES);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void
-nm_setting_ip6_config_init (NMSettingIP6Config *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (object);
-
- g_free (priv->method);
- g_free (priv->dhcp_hostname);
-
- g_slist_free_full (priv->dns, g_free);
- g_slist_free_full (priv->dns_search, g_free);
- g_slist_free_full (priv->addresses, g_free);
- g_slist_free_full (priv->routes, g_free);
-
- G_OBJECT_CLASS (nm_setting_ip6_config_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_METHOD:
- g_free (priv->method);
- priv->method = g_value_dup_string (value);
- break;
- case PROP_DNS:
- g_slist_free_full (priv->dns, g_free);
- priv->dns = nm_utils_ip6_dns_from_gvalue (value);
- break;
- case PROP_DNS_SEARCH:
- g_slist_free_full (priv->dns_search, g_free);
- priv->dns_search = g_value_dup_boxed (value);
- break;
- case PROP_ADDRESSES:
- g_slist_free_full (priv->addresses, g_free);
- priv->addresses = nm_utils_ip6_addresses_from_gvalue (value);
- break;
- case PROP_ROUTES:
- g_slist_free_full (priv->routes, g_free);
- priv->routes = nm_utils_ip6_routes_from_gvalue (value);
- break;
- case PROP_ROUTE_METRIC:
- priv->route_metric = g_value_get_int64 (value);
- break;
- case PROP_IGNORE_AUTO_ROUTES:
- priv->ignore_auto_routes = g_value_get_boolean (value);
- break;
- case PROP_IGNORE_AUTO_DNS:
- priv->ignore_auto_dns = g_value_get_boolean (value);
- break;
- case PROP_DHCP_HOSTNAME:
- g_free (priv->dhcp_hostname);
- priv->dhcp_hostname = g_value_dup_string (value);
- break;
- case PROP_NEVER_DEFAULT:
- priv->never_default = g_value_get_boolean (value);
- break;
- case PROP_MAY_FAIL:
- priv->may_fail = g_value_get_boolean (value);
- break;
- case PROP_IP6_PRIVACY:
- priv->ip6_privacy = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_METHOD:
- g_value_set_string (value, priv->method);
- break;
- case PROP_DNS:
- nm_utils_ip6_dns_to_gvalue (priv->dns, value);
- break;
- case PROP_DNS_SEARCH:
- g_value_set_boxed (value, priv->dns_search);
- break;
- case PROP_ADDRESSES:
- nm_utils_ip6_addresses_to_gvalue (priv->addresses, value);
- break;
- case PROP_ROUTES:
- nm_utils_ip6_routes_to_gvalue (priv->routes, value);
- break;
- case PROP_ROUTE_METRIC:
- g_value_set_int64 (value, priv->route_metric);
- break;
- case PROP_IGNORE_AUTO_ROUTES:
- g_value_set_boolean (value, priv->ignore_auto_routes);
- break;
- case PROP_IGNORE_AUTO_DNS:
- g_value_set_boolean (value, priv->ignore_auto_dns);
- break;
- case PROP_DHCP_HOSTNAME:
- g_value_set_string (value, priv->dhcp_hostname);
- break;
- case PROP_NEVER_DEFAULT:
- g_value_set_boolean (value, priv->never_default);
- break;
- case PROP_MAY_FAIL:
- g_value_set_boolean (value, priv->may_fail);
- break;
- case PROP_IP6_PRIVACY:
- g_value_set_int (value, priv->ip6_privacy);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingIP6ConfigPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingIP6Config:method:
- *
- * IPv6 configuration method. If "auto" is specified then the appropriate
- * automatic method (PPP, router advertisement, etc) is used for the device
- * and most other properties can be left unset. To force the use of DHCP
- * only, specify "dhcp"; this method is only valid for Ethernet- based
- * hardware. If "link-local" is specified, then an IPv6 link-local address
- * will be assigned to the interface. If "manual" is specified, static IP
- * addressing is used and at least one IP address must be given in the
- * "addresses" property. If "ignore" is specified, IPv6 configuration is
- * not done. This property must be set. Note: the "shared" method is not
- * yet supported.
- **/
- g_object_class_install_property
- (object_class, PROP_METHOD,
- g_param_spec_string (NM_SETTING_IP6_CONFIG_METHOD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:dhcp-hostname:
- *
- * The specified name will be sent to the DHCP server when acquiring a
- * lease.
- *
- * Since: 0.9.8
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP_HOSTNAME,
- g_param_spec_string (NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:dns:
- *
- * Array of DNS servers, where each member of the array is a byte array
- * containing the IPv6 address of the DNS server (in network byte order).
- * For the "auto" method, these DNS servers are appended to those (if any)
- * returned by automatic configuration. DNS servers cannot be used with the
- * "shared" or "link-local" methods as there is no usptream network. In all
- * other methods, these DNS servers are used as the only DNS servers for
- * this connection.
- **/
- g_object_class_install_property
- (object_class, PROP_DNS,
- _nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_DNS, "", "",
- DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:dns-search:
- *
- * List of DNS search domains. For the "auto" method, these search domains
- * are appended to those returned by automatic configuration. Search domains
- * cannot be used with the "shared" or "link-local" methods as there is no
- * upstream network. In all other methods, these search domains are used as
- * the only search domains for this connection.
- **/
- g_object_class_install_property
- (object_class, PROP_DNS_SEARCH,
- _nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_DNS_SEARCH, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:addresses:
- *
- * Array of IPv6 address structures. Each IPv6 address structure is
- * composed of 3 members, the first being a byte array containing the IPv6
- * address (network byte order), the second a 32-bit integer containing the
- * IPv6 address prefix, and the third a byte array containing the IPv6
- * address (network byte order) of the gateway associated with this address,
- * if any. If no gateway is given, the third element should be given as all
- * zeros. For the "auto" method, given IP addresses are appended to those
- * returned by automatic configuration. Addresses cannot be used with the
- * "shared" or "link-local" methods as the interface is automatically
- * assigned an address with these methods.
- **/
- g_object_class_install_property
- (object_class, PROP_ADDRESSES,
- _nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_ADDRESSES, "", "",
- DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:routes:
- *
- * Array of IPv6 route structures. Each IPv6 route structure is composed of
- * 4 members; the first being the destination IPv6 network or address
- * (network byte order) as a byte array, the second the destination network
- * or address IPv6 prefix, the third being the next-hop IPv6 address
- * (network byte order) if any, and the fourth being the route metric. For
- * the "auto" method, given IP routes are appended to those returned by
- * automatic configuration. Routes cannot be used with the "shared" or
- * "link-local" methods because there is no upstream network.
- **/
- g_object_class_install_property
- (object_class, PROP_ROUTES,
- _nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_ROUTES, "", "",
- DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:route-metric:
- *
- * The default metric for routes that don't explicitly specify a metric.
- * The default value -1 means that the metric is chosen automatically
- * based on the device type.
- * The metric applies to dynamic routes, manual (static) routes that
- * don't have an explicit metric setting, address prefix routes, and
- * the default route.
- * As the linux kernel replaces zero (0) by 1024 (user-default), setting
- * this property to 0 means effectively setting it to 1024.
- *
- * Since: 1.0
- **/
- g_object_class_install_property
- (object_class, PROP_ROUTE_METRIC,
- g_param_spec_int64 (NM_SETTING_IP6_CONFIG_ROUTE_METRIC, "", "",
- -1, G_MAXUINT32, -1,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:ignore-auto-routes:
- *
- * When the method is set to "auto" or "dhcp" and this property is set to
- * %TRUE, automatically configured routes are ignored and only routes
- * specified in the #NMSettingIP6Config:routes property, if any, are used.
- **/
- g_object_class_install_property
- (object_class, PROP_IGNORE_AUTO_ROUTES,
- g_param_spec_boolean (NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:ignore-auto-dns:
- *
- * When the method is set to "auto" or "dhcp" and this property is set to
- * %TRUE, automatically configured nameservers and search domains are
- * ignored and only nameservers and search domains specified in the
- * #NMSettingIP6Config:dns and #NMSettingIP6Config:dns-search properties, if
- * any, are used.
- **/
- g_object_class_install_property
- (object_class, PROP_IGNORE_AUTO_DNS,
- g_param_spec_boolean (NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:never-default:
- *
- * If %TRUE, this connection will never be the default IPv6 connection,
- * meaning it will never be assigned the default IPv6 route by
- * NetworkManager.
- **/
- g_object_class_install_property
- (object_class, PROP_NEVER_DEFAULT,
- g_param_spec_boolean (NM_SETTING_IP6_CONFIG_NEVER_DEFAULT, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:may-fail:
- *
- * If %TRUE, allow overall network configuration to proceed even if IPv6
- * configuration times out. Note that at least one IP configuration must
- * succeed or overall network configuration will still fail. For example,
- * in IPv4-only networks, setting this property to %TRUE allows the overall
- * network configuration to succeed if IPv6 configuration fails but IPv4
- * configuration completes successfully.
- **/
- g_object_class_install_property
- (object_class, PROP_MAY_FAIL,
- g_param_spec_boolean (NM_SETTING_IP6_CONFIG_MAY_FAIL, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingIP6Config:ip6-privacy:
- *
- * Configure IPv6 Privacy Extensions for SLAAC, described in RFC4941. If
- * enabled, it makes the kernel generate a temporary IPv6 address in
- * addition to the public one generated from MAC address via modified
- * EUI-64. This enhances privacy, but could cause problems in some
- * applications, on the other hand. The permitted values are: 0: disabled,
- * 1: enabled (prefer public address), 2: enabled (prefer temporary
- * addresses).
- **/
- g_object_class_install_property
- (object_class, PROP_IP6_PRIVACY,
- g_param_spec_int (NM_SETTING_IP6_CONFIG_IP6_PRIVACY, "", "",
- NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN,
- NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR,
- NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-}
-
-/*****************************************************************************/
-
-struct NMIP6Address {
- guint32 refcount;
- struct in6_addr address;
- guint32 prefix;
- struct in6_addr gateway;
-};
-
-/**
- * nm_ip6_address_new:
- *
- * Creates and returns a new #NMIP6Address object.
- *
- * Returns: (transfer full): the new empty #NMIP6Address object
- **/
-NMIP6Address *
-nm_ip6_address_new (void)
-{
- NMIP6Address *address;
-
- address = g_malloc0 (sizeof (NMIP6Address));
- address->refcount = 1;
- return address;
-}
-
-/**
- * nm_ip6_address_dup:
- * @source: the #NMIP6Address object to copy
- *
- * Copies a given #NMIP6Address object and returns the copy.
- *
- * Returns: (transfer full): the copy of the given #NMIP6Address copy
- **/
-NMIP6Address *
-nm_ip6_address_dup (NMIP6Address *source)
-{
- NMIP6Address *address;
-
- g_return_val_if_fail (source != NULL, NULL);
- g_return_val_if_fail (source->refcount > 0, NULL);
-
- address = nm_ip6_address_new ();
- address->prefix = source->prefix;
- memcpy (&address->address, &source->address, sizeof (struct in6_addr));
- memcpy (&address->gateway, &source->gateway, sizeof (struct in6_addr));
-
- return address;
-}
-
-/**
- * nm_ip6_address_ref:
- * @address: the #NMIP6Address
- *
- * Increases the reference count of the object.
- **/
-void
-nm_ip6_address_ref (NMIP6Address *address)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
-
- address->refcount++;
-}
-
-/**
- * nm_ip6_address_unref:
- * @address: the #NMIP6Address
- *
- * Decreases the reference count of the object. If the reference count
- * reaches zero, the object will be destroyed.
- **/
-void
-nm_ip6_address_unref (NMIP6Address *address)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
-
- address->refcount--;
- if (address->refcount == 0) {
- memset (address, 0, sizeof (NMIP6Address));
- g_free (address);
- }
-}
-
-/**
- * nm_ip6_address_compare:
- * @address: the #NMIP6Address
- * @other: the #NMIP6Address to compare @address to.
- *
- * Determines if two #NMIP6Address objects contain the same values.
- *
- * Returns: %TRUE if the objects contain the same values, %FALSE if they do not.
- **/
-gboolean
-nm_ip6_address_compare (NMIP6Address *address, NMIP6Address *other)
-{
- g_return_val_if_fail (address != NULL, FALSE);
- g_return_val_if_fail (address->refcount > 0, FALSE);
-
- g_return_val_if_fail (other != NULL, FALSE);
- g_return_val_if_fail (other->refcount > 0, FALSE);
-
- if ( memcmp (&address->address, &other->address, sizeof (struct in6_addr))
- || address->prefix != other->prefix
- || memcmp (&address->gateway, &other->gateway, sizeof (struct in6_addr)))
- return FALSE;
- return TRUE;
-}
-
-/**
- * nm_ip6_address_get_address:
- * @address: the #NMIP6Address
- *
- * Gets the IPv6 address property of this address object.
- *
- * Returns: (array fixed-size=16) (element-type guint8) (transfer none):
- * the IPv6 address
- **/
-const struct in6_addr *
-nm_ip6_address_get_address (NMIP6Address *address)
-{
- g_return_val_if_fail (address != NULL, NULL);
- g_return_val_if_fail (address->refcount > 0, NULL);
-
- return &address->address;
-}
-
-/**
- * nm_ip6_address_set_address:
- * @address: the #NMIP6Address
- * @addr: the IPv6 address
- *
- * Sets the IPv6 address property of this object.
- **/
-void
-nm_ip6_address_set_address (NMIP6Address *address, const struct in6_addr *addr)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
- g_return_if_fail (addr != NULL);
-
- memcpy (&address->address, addr, sizeof (struct in6_addr));
-}
-
-/**
- * nm_ip6_address_get_prefix:
- * @address: the #NMIP6Address
- *
- * Gets the IPv6 address prefix property of this address object.
- *
- * Returns: the IPv6 address prefix
- **/
-guint32
-nm_ip6_address_get_prefix (NMIP6Address *address)
-{
- g_return_val_if_fail (address != NULL, 0);
- g_return_val_if_fail (address->refcount > 0, 0);
-
- return address->prefix;
-}
-
-/**
- * nm_ip6_address_set_prefix:
- * @address: the #NMIP6Address
- * @prefix: the address prefix, a number between 0 and 128 inclusive
- *
- * Sets the IPv6 address prefix.
- **/
-void
-nm_ip6_address_set_prefix (NMIP6Address *address, guint32 prefix)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
- g_return_if_fail (prefix <= 128);
- g_return_if_fail (prefix > 0);
-
- address->prefix = prefix;
-}
-
-/**
- * nm_ip6_address_get_gateway:
- * @address: the #NMIP6Address
- *
- * Gets the IPv6 default gateway property of this address object.
- *
- * Returns: (array fixed-size=16) (element-type guint8) (transfer none):
- * the IPv6 gateway address
- **/
-const struct in6_addr *
-nm_ip6_address_get_gateway (NMIP6Address *address)
-{
- g_return_val_if_fail (address != NULL, NULL);
- g_return_val_if_fail (address->refcount > 0, NULL);
-
- return &address->gateway;
-}
-
-/**
- * nm_ip6_address_set_gateway:
- * @address: the #NMIP6Address
- * @gateway: the IPv6 default gateway
- *
- * Sets the IPv6 default gateway property of this address object.
- **/
-void
-nm_ip6_address_set_gateway (NMIP6Address *address, const struct in6_addr *gateway)
-{
- g_return_if_fail (address != NULL);
- g_return_if_fail (address->refcount > 0);
- g_return_if_fail (gateway != NULL);
-
- memcpy (&address->gateway, gateway, sizeof (struct in6_addr));
-}
-
-/*****************************************************************************/
-
-struct NMIP6Route {
- guint32 refcount;
-
- struct in6_addr dest;
- guint32 prefix;
- struct in6_addr next_hop;
- guint32 metric; /* lower metric == more preferred */
-};
-
-/**
- * nm_ip6_route_new:
- *
- * Creates and returns a new #NMIP6Route object.
- *
- * Returns: (transfer full): the new empty #NMIP6Route object
- **/
-NMIP6Route *
-nm_ip6_route_new (void)
-{
- NMIP6Route *route;
-
- route = g_malloc0 (sizeof (NMIP6Route));
- route->refcount = 1;
- return route;
-}
-
-/**
- * nm_ip6_route_dup:
- * @source: the #NMIP6Route object to copy
- *
- * Copies a given #NMIP6Route object and returns the copy.
- *
- * Returns: (transfer full): the copy of the given #NMIP6Route copy
- **/
-NMIP6Route *
-nm_ip6_route_dup (NMIP6Route *source)
-{
- NMIP6Route *route;
-
- g_return_val_if_fail (source != NULL, NULL);
- g_return_val_if_fail (source->refcount > 0, NULL);
-
- route = nm_ip6_route_new ();
- route->prefix = source->prefix;
- route->metric = source->metric;
- memcpy (&route->dest, &source->dest, sizeof (struct in6_addr));
- memcpy (&route->next_hop, &source->next_hop, sizeof (struct in6_addr));
-
- return route;
-}
-
-/**
- * nm_ip6_route_ref:
- * @route: the #NMIP6Route
- *
- * Increases the reference count of the object.
- **/
-void
-nm_ip6_route_ref (NMIP6Route *route)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
-
- route->refcount++;
-}
-
-/**
- * nm_ip6_route_unref:
- * @route: the #NMIP6Route
- *
- * Decreases the reference count of the object. If the reference count
- * reaches zero, the object will be destroyed.
- **/
-void
-nm_ip6_route_unref (NMIP6Route *route)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
-
- route->refcount--;
- if (route->refcount == 0) {
- memset (route, 0, sizeof (NMIP6Route));
- g_free (route);
- }
-}
-
-/**
- * nm_ip6_route_compare:
- * @route: the #NMIP6Route
- * @other: the #NMIP6Route to compare @route to.
- *
- * Determines if two #NMIP6Route objects contain the same values.
- *
- * Returns: %TRUE if the objects contain the same values, %FALSE if they do not.
- **/
-gboolean
-nm_ip6_route_compare (NMIP6Route *route, NMIP6Route *other)
-{
- g_return_val_if_fail (route != NULL, FALSE);
- g_return_val_if_fail (route->refcount > 0, FALSE);
-
- g_return_val_if_fail (other != NULL, FALSE);
- g_return_val_if_fail (other->refcount > 0, FALSE);
-
- if ( memcmp (&route->dest, &other->dest, sizeof (struct in6_addr))
- || route->prefix != other->prefix
- || memcmp (&route->next_hop, &other->next_hop, sizeof (struct in6_addr))
- || route->metric != other->metric)
- return FALSE;
- return TRUE;
-}
-
-/**
- * nm_ip6_route_get_dest:
- * @route: the #NMIP6Route
- *
- * Gets the IPv6 destination address property of this route object.
- *
- * Returns: (array fixed-size=16) (element-type guint8) (transfer none):
- * the IPv6 address of destination
- **/
-const struct in6_addr *
-nm_ip6_route_get_dest (NMIP6Route *route)
-{
- g_return_val_if_fail (route != NULL, NULL);
- g_return_val_if_fail (route->refcount > 0, NULL);
-
- return &route->dest;
-}
-
-/**
- * nm_ip6_route_set_dest:
- * @route: the #NMIP6Route
- * @dest: the destination address
- *
- * Sets the IPv6 destination address property of this route object.
- **/
-void
-nm_ip6_route_set_dest (NMIP6Route *route, const struct in6_addr *dest)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
- g_return_if_fail (dest != NULL);
-
- memcpy (&route->dest, dest, sizeof (struct in6_addr));
-}
-
-/**
- * nm_ip6_route_get_prefix:
- * @route: the #NMIP6Route
- *
- * Gets the IPv6 prefix (ie "32" or "64" etc) of this route.
- *
- * Returns: the IPv6 prefix
- **/
-guint32
-nm_ip6_route_get_prefix (NMIP6Route *route)
-{
- g_return_val_if_fail (route != NULL, 0);
- g_return_val_if_fail (route->refcount > 0, 0);
-
- return route->prefix;
-}
-
-/**
- * nm_ip6_route_set_prefix:
- * @route: the #NMIP6Route
- * @prefix: the prefix, a number between 1 and 128 inclusive
- *
- * Sets the IPv6 prefix of this route.
- **/
-void
-nm_ip6_route_set_prefix (NMIP6Route *route, guint32 prefix)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
- g_return_if_fail (prefix <= 128);
- g_return_if_fail (prefix > 0);
-
- route->prefix = prefix;
-}
-
-/**
- * nm_ip6_route_get_next_hop:
- * @route: the #NMIP6Route
- *
- * Gets the IPv6 address of the next hop of this route.
- *
- * Returns: (array fixed-size=16) (element-type guint8) (transfer none):
- * the IPv6 address of next hop
- **/
-const struct in6_addr *
-nm_ip6_route_get_next_hop (NMIP6Route *route)
-{
- g_return_val_if_fail (route != NULL, NULL);
- g_return_val_if_fail (route->refcount > 0, NULL);
-
- return &route->next_hop;
-}
-
-/**
- * nm_ip6_route_set_next_hop:
- * @route: the #NMIP6Route
- * @next_hop: the IPv6 address of the next hop
- *
- * Sets the IPv6 address of the next hop of this route.
- **/
-void
-nm_ip6_route_set_next_hop (NMIP6Route *route, const struct in6_addr *next_hop)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
- g_return_if_fail (next_hop != NULL);
-
- memcpy (&route->next_hop, next_hop, sizeof (struct in6_addr));
-}
-
-/**
- * nm_ip6_route_get_metric:
- * @route: the #NMIP6Route
- *
- * Gets the route metric property of this route object; lower values indicate
- * "better" or more preferred routes.
- *
- * Returns: the route metric
- **/
-guint32
-nm_ip6_route_get_metric (NMIP6Route *route)
-{
- g_return_val_if_fail (route != NULL, 0);
- g_return_val_if_fail (route->refcount > 0, 0);
-
- return route->metric;
-}
-
-/**
- * nm_ip6_route_set_metric:
- * @route: the #NMIP6Route
- * @metric: the route metric
- *
- * Sets the route metric property of this route object; lower values indicate
- * "better" or more preferred routes.
- **/
-void
-nm_ip6_route_set_metric (NMIP6Route *route, guint32 metric)
-{
- g_return_if_fail (route != NULL);
- g_return_if_fail (route->refcount > 0);
-
- route->metric = metric;
-}
diff --git a/libnm-util/nm-setting-ip6-config.h b/libnm-util/nm-setting-ip6-config.h
deleted file mode 100644
index 2a32a92035..0000000000
--- a/libnm-util/nm-setting-ip6-config.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_IP6_CONFIG_H
-#define NM_SETTING_IP6_CONFIG_H
-
-#include <arpa/inet.h>
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_IP6_CONFIG (nm_setting_ip6_config_get_type ())
-#define NM_SETTING_IP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_IP6_CONFIG, NMSettingIP6Config))
-#define NM_SETTING_IP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_IP6CONFIG, NMSettingIP6ConfigClass))
-#define NM_IS_SETTING_IP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_IP6_CONFIG))
-#define NM_IS_SETTING_IP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_IP6_CONFIG))
-#define NM_SETTING_IP6_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_IP6_CONFIG, NMSettingIP6ConfigClass))
-
-#define NM_SETTING_IP6_CONFIG_SETTING_NAME "ipv6"
-
-/**
- * NMSettingIP6ConfigError:
- * @NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD: the property's value is
- * not valid with the given IPv6 method
- */
-typedef enum {
- NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD /*< nick=NotAllowedForMethod >*/
-} NMSettingIP6ConfigError;
-
-#define NM_SETTING_IP6_CONFIG_ERROR nm_setting_ip6_config_error_quark ()
-GQuark nm_setting_ip6_config_error_quark (void);
-
-#define NM_SETTING_IP6_CONFIG_METHOD "method"
-#define NM_SETTING_IP6_CONFIG_DNS "dns"
-#define NM_SETTING_IP6_CONFIG_DNS_SEARCH "dns-search"
-#define NM_SETTING_IP6_CONFIG_ADDRESSES "addresses"
-#define NM_SETTING_IP6_CONFIG_ROUTES "routes"
-#define NM_SETTING_IP6_CONFIG_ROUTE_METRIC "route-metric"
-#define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
-#define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
-#define NM_SETTING_IP6_CONFIG_NEVER_DEFAULT "never-default"
-#define NM_SETTING_IP6_CONFIG_MAY_FAIL "may-fail"
-#define NM_SETTING_IP6_CONFIG_IP6_PRIVACY "ip6-privacy"
-#define NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
-
-/**
- * NM_SETTING_IP6_CONFIG_METHOD_IGNORE:
- *
- * IPv6 is not required or is handled by some other mechanism, and NetworkManager
- * should not configure IPv6 for this connection.
- */
-#define NM_SETTING_IP6_CONFIG_METHOD_IGNORE "ignore"
-
-/**
- * NM_SETTING_IP6_CONFIG_METHOD_AUTO:
- *
- * IPv6 configuration should be automatically determined via a method appropriate
- * for the hardware interface, ie router advertisements, DHCP, or PPP or some
- * other device-specific manner.
- */
-#define NM_SETTING_IP6_CONFIG_METHOD_AUTO "auto"
-
-/**
- * NM_SETTING_IP6_CONFIG_METHOD_DHCP:
- *
- * IPv6 configuration should be automatically determined via DHCPv6 only and
- * router advertisements should be ignored.
- */
-#define NM_SETTING_IP6_CONFIG_METHOD_DHCP "dhcp"
-
-/**
- * NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL:
- *
- * IPv6 configuration should be automatically configured for link-local-only
- * operation.
- */
-#define NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL "link-local"
-
-/**
- * NM_SETTING_IP6_CONFIG_METHOD_MANUAL:
- *
- * All necessary IPv6 configuration (addresses, prefix, DNS, etc) is specified
- * in the setting's properties.
- */
-#define NM_SETTING_IP6_CONFIG_METHOD_MANUAL "manual"
-
-/**
- * NM_SETTING_IP6_CONFIG_METHOD_SHARED:
- *
- * This connection specifies configuration that allows other computers to
- * connect through it to the default network (usually the Internet). The
- * connection's interface will be assigned a private address, and router
- * advertisements, a caching DNS server, and Network Address Translation (NAT)
- * functionality will be started on this connection's interface to allow other
- * devices to connect through that interface to the default network. (not yet
- * supported for IPv6)
- */
-#define NM_SETTING_IP6_CONFIG_METHOD_SHARED "shared"
-
-/**
- * NMSettingIP6ConfigPrivacy:
- * @NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN: unknown or no value specified
- * @NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: IPv6 Privacy Extensions are disabled
- * @NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: IPv6 Privacy Extensions
- * are enabled, but public addresses are preferred over temporary addresses
- * @NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: IPv6 Privacy Extensions
- * are enabled and temporary addresses are preferred over public addresses
- *
- * #NMSettingIP6ConfigPrivacy values indicate if and how IPv6 Privacy
- * Extensions are used (RFC4941).
- */
-typedef enum {
- NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN = -1,
- NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED = 0,
- NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR = 1,
- NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR = 2
-} NMSettingIP6ConfigPrivacy;
-
-typedef struct NMIP6Address NMIP6Address;
-
-GType nm_ip6_address_get_type (void);
-
-NMIP6Address * nm_ip6_address_new (void);
-NMIP6Address * nm_ip6_address_dup (NMIP6Address *source);
-void nm_ip6_address_ref (NMIP6Address *address);
-void nm_ip6_address_unref (NMIP6Address *address);
-/* Return TRUE if addresses are identical */
-gboolean nm_ip6_address_compare (NMIP6Address *address, NMIP6Address *other);
-
-const struct in6_addr *nm_ip6_address_get_address (NMIP6Address *address);
-void nm_ip6_address_set_address (NMIP6Address *address,
- const struct in6_addr *addr);
-
-guint32 nm_ip6_address_get_prefix (NMIP6Address *address);
-void nm_ip6_address_set_prefix (NMIP6Address *address,
- guint32 prefix);
-
-const struct in6_addr *nm_ip6_address_get_gateway (NMIP6Address *address);
-void nm_ip6_address_set_gateway (NMIP6Address *address,
- const struct in6_addr *gateway);
-
-typedef struct NMIP6Route NMIP6Route;
-
-GType nm_ip6_route_get_type (void);
-
-NMIP6Route * nm_ip6_route_new (void);
-NMIP6Route * nm_ip6_route_dup (NMIP6Route *source);
-void nm_ip6_route_ref (NMIP6Route *route);
-void nm_ip6_route_unref (NMIP6Route *route);
-/* Return TRUE if routes are identical */
-gboolean nm_ip6_route_compare (NMIP6Route *route, NMIP6Route *other);
-
-const struct in6_addr *nm_ip6_route_get_dest (NMIP6Route *route);
-void nm_ip6_route_set_dest (NMIP6Route *route,
- const struct in6_addr *dest);
-
-guint32 nm_ip6_route_get_prefix (NMIP6Route *route);
-void nm_ip6_route_set_prefix (NMIP6Route *route,
- guint32 prefix);
-
-const struct in6_addr *nm_ip6_route_get_next_hop (NMIP6Route *route);
-void nm_ip6_route_set_next_hop (NMIP6Route *route,
- const struct in6_addr *next_hop);
-
-guint32 nm_ip6_route_get_metric (NMIP6Route *route);
-void nm_ip6_route_set_metric (NMIP6Route *route,
- guint32 metric);
-
-typedef struct {
- NMSetting parent;
-} NMSettingIP6Config;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingIP6ConfigClass;
-
-GType nm_setting_ip6_config_get_type (void);
-
-NMSetting * nm_setting_ip6_config_new (void);
-const char * nm_setting_ip6_config_get_method (NMSettingIP6Config *setting);
-
-guint32 nm_setting_ip6_config_get_num_dns (NMSettingIP6Config *setting);
-const struct in6_addr *nm_setting_ip6_config_get_dns (NMSettingIP6Config *setting, guint32 i);
-gboolean nm_setting_ip6_config_add_dns (NMSettingIP6Config *setting, const struct in6_addr *dns);
-void nm_setting_ip6_config_remove_dns (NMSettingIP6Config *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_ip6_config_remove_dns_by_value (NMSettingIP6Config *setting, const struct in6_addr *dns);
-void nm_setting_ip6_config_clear_dns (NMSettingIP6Config *setting);
-
-guint32 nm_setting_ip6_config_get_num_dns_searches (NMSettingIP6Config *setting);
-const char * nm_setting_ip6_config_get_dns_search (NMSettingIP6Config *setting, guint32 i);
-gboolean nm_setting_ip6_config_add_dns_search (NMSettingIP6Config *setting, const char *dns_search);
-void nm_setting_ip6_config_remove_dns_search (NMSettingIP6Config *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_ip6_config_remove_dns_search_by_value (NMSettingIP6Config *setting, const char *dns_search);
-void nm_setting_ip6_config_clear_dns_searches (NMSettingIP6Config *setting);
-
-guint32 nm_setting_ip6_config_get_num_addresses (NMSettingIP6Config *setting);
-NMIP6Address * nm_setting_ip6_config_get_address (NMSettingIP6Config *setting, guint32 i);
-gboolean nm_setting_ip6_config_add_address (NMSettingIP6Config *setting, NMIP6Address *address);
-void nm_setting_ip6_config_remove_address (NMSettingIP6Config *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_ip6_config_remove_address_by_value (NMSettingIP6Config *setting, NMIP6Address *address);
-void nm_setting_ip6_config_clear_addresses (NMSettingIP6Config *setting);
-
-guint32 nm_setting_ip6_config_get_num_routes (NMSettingIP6Config *setting);
-NMIP6Route * nm_setting_ip6_config_get_route (NMSettingIP6Config *setting, guint32 i);
-gboolean nm_setting_ip6_config_add_route (NMSettingIP6Config *setting, NMIP6Route *route);
-void nm_setting_ip6_config_remove_route (NMSettingIP6Config *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_ip6_config_remove_route_by_value (NMSettingIP6Config *setting, NMIP6Route *route);
-void nm_setting_ip6_config_clear_routes (NMSettingIP6Config *setting);
-gboolean nm_setting_ip6_config_get_ignore_auto_routes (NMSettingIP6Config *setting);
-
-NM_AVAILABLE_IN_1_0
-gint64 nm_setting_ip6_config_get_route_metric (NMSettingIP6Config *setting);
-
-gboolean nm_setting_ip6_config_get_ignore_auto_dns (NMSettingIP6Config *setting);
-const char * nm_setting_ip6_config_get_dhcp_hostname (NMSettingIP6Config *setting);
-gboolean nm_setting_ip6_config_get_never_default (NMSettingIP6Config *setting);
-gboolean nm_setting_ip6_config_get_may_fail (NMSettingIP6Config *setting);
-NMSettingIP6ConfigPrivacy nm_setting_ip6_config_get_ip6_privacy (NMSettingIP6Config *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_IP6_CONFIG_H */
diff --git a/libnm-util/nm-setting-olpc-mesh.c b/libnm-util/nm-setting-olpc-mesh.c
deleted file mode 100644
index 7785d860a4..0000000000
--- a/libnm-util/nm-setting-olpc-mesh.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2009 One Laptop per Child
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <netinet/ether.h>
-#include <dbus/dbus-glib.h>
-
-#include "NetworkManager.h"
-#include "nm-setting-olpc-mesh.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-utils-private.h"
-#include "nm-setting-private.h"
-
-GQuark
-nm_setting_olpc_mesh_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-olpc-mesh-error-quark");
- return quark;
-}
-
-static void nm_setting_olpc_mesh_init (NMSettingOlpcMesh *setting);
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingOlpcMesh, nm_setting_olpc_mesh, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_OLPC_MESH_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_OLPC_MESH_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_OLPC_MESH)
-
-#define NM_SETTING_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_OLPC_MESH, NMSettingOlpcMeshPrivate))
-
-typedef struct {
- GByteArray *ssid;
- guint32 channel;
- GByteArray *dhcp_anycast_addr;
-} NMSettingOlpcMeshPrivate;
-
-enum {
- PROP_0,
- PROP_SSID,
- PROP_CHANNEL,
- PROP_DHCP_ANYCAST_ADDRESS,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_olpc_mesh_new:
- *
- * Creates a new #NMSettingOlpcMesh object with default values.
- *
- * Returns: the new empty #NMSettingOlpcMesh object
- **/
-NMSetting *nm_setting_olpc_mesh_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_OLPC_MESH, NULL);
-}
-
-static void
-nm_setting_olpc_mesh_init (NMSettingOlpcMesh *setting)
-{
-}
-
-const GByteArray *
-nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (setting), NULL);
-
- return NM_SETTING_OLPC_MESH_GET_PRIVATE (setting)->ssid;
-}
-
-guint32
-nm_setting_olpc_mesh_get_channel (NMSettingOlpcMesh *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (setting), 0);
-
- return NM_SETTING_OLPC_MESH_GET_PRIVATE (setting)->channel;
-}
-
-const GByteArray *
-nm_setting_olpc_mesh_get_dhcp_anycast_address (NMSettingOlpcMesh *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (setting), NULL);
-
- return NM_SETTING_OLPC_MESH_GET_PRIVATE (setting)->dhcp_anycast_addr;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (setting);
-
- if (!priv->ssid) {
- g_set_error_literal (error,
- NM_SETTING_OLPC_MESH_ERROR,
- NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_OLPC_MESH_SETTING_NAME, NM_SETTING_OLPC_MESH_SSID);
- return FALSE;
- }
-
- if (!priv->ssid->len || priv->ssid->len > 32) {
- g_set_error_literal (error,
- NM_SETTING_OLPC_MESH_ERROR,
- NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY,
- _("SSID length is out of range <1-32> bytes"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_OLPC_MESH_SETTING_NAME, NM_SETTING_OLPC_MESH_SSID);
- return FALSE;
- }
-
- if (priv->channel == 0 || priv->channel > 13) {
- g_set_error (error,
- NM_SETTING_OLPC_MESH_ERROR,
- NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY,
- _("'%d' is not a valid channel"),
- priv->channel);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_OLPC_MESH_SETTING_NAME, NM_SETTING_OLPC_MESH_CHANNEL);
- return FALSE;
- }
-
- if (priv->dhcp_anycast_addr && priv->dhcp_anycast_addr->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_OLPC_MESH_ERROR,
- NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_OLPC_MESH_SETTING_NAME, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (object);
-
- if (priv->ssid)
- g_byte_array_free (priv->ssid, TRUE);
- if (priv->dhcp_anycast_addr)
- g_byte_array_free (priv->dhcp_anycast_addr, TRUE);
-
- G_OBJECT_CLASS (nm_setting_olpc_mesh_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_SSID:
- if (priv->ssid)
- g_byte_array_free (priv->ssid, TRUE);
- priv->ssid = g_value_dup_boxed (value);
- break;
- case PROP_CHANNEL:
- priv->channel = g_value_get_uint (value);
- break;
- case PROP_DHCP_ANYCAST_ADDRESS:
- if (priv->dhcp_anycast_addr)
- g_byte_array_free (priv->dhcp_anycast_addr, TRUE);
- priv->dhcp_anycast_addr = g_value_dup_boxed (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingOlpcMesh *setting = NM_SETTING_OLPC_MESH (object);
-
- switch (prop_id) {
- case PROP_SSID:
- g_value_set_boxed (value, nm_setting_olpc_mesh_get_ssid (setting));
- break;
- case PROP_CHANNEL:
- g_value_set_uint (value, nm_setting_olpc_mesh_get_channel (setting));
- break;
- case PROP_DHCP_ANYCAST_ADDRESS:
- g_value_set_boxed (value, nm_setting_olpc_mesh_get_dhcp_anycast_address (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_olpc_mesh_class_init (NMSettingOlpcMeshClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingOlpcMeshPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingOlpcMesh:ssid:
- *
- * SSID of the mesh network to join.
- **/
- g_object_class_install_property
- (object_class, PROP_SSID,
- _nm_param_spec_specialized (NM_SETTING_OLPC_MESH_SSID, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingOlpcMesh:channel:
- *
- * Channel on which the mesh network to join is located.
- **/
- g_object_class_install_property
- (object_class, PROP_CHANNEL,
- g_param_spec_uint (NM_SETTING_OLPC_MESH_CHANNEL, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingOlpcMesh:dhcp-anycast-address:
- *
- * Anycast DHCP MAC address used when requesting an IP address via DHCP.
- * The specific anycast address used determines which DHCP server class
- * answers the request.
- **/
- g_object_class_install_property
- (object_class, PROP_DHCP_ANYCAST_ADDRESS,
- _nm_param_spec_specialized (NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-olpc-mesh.h b/libnm-util/nm-setting-olpc-mesh.h
deleted file mode 100644
index 1764406ef6..0000000000
--- a/libnm-util/nm-setting-olpc-mesh.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2009 One Laptop per Child
- */
-
-#ifndef NM_SETTING_OLPC_MESH_H
-#define NM_SETTING_OLPC_MESH_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_OLPC_MESH (nm_setting_olpc_mesh_get_type ())
-#define NM_SETTING_OLPC_MESH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_OLPC_MESH, NMSettingOlpcMesh))
-#define NM_SETTING_OLPC_MESH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_OLPC_MESH, NMSettingOlpcMeshClass))
-#define NM_IS_SETTING_OLPC_MESH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_OLPC_MESH))
-#define NM_IS_SETTING_OLPC_MESH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_OLPC_MESH))
-#define NM_SETTING_OLPC_MESH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_OLPC_MESH, NMSettingOlpcMeshClass))
-
-#define NM_SETTING_OLPC_MESH_SETTING_NAME "802-11-olpc-mesh"
-
-/**
- * NMSettingOlpcMeshError:
- * @NM_SETTING_OLPC_MESH_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum {
- NM_SETTING_OLPC_MESH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
-} NMSettingOlpcMeshError;
-
-#define NM_SETTING_OLPC_MESH_ERROR nm_setting_olpc_mesh_error_quark ()
-GQuark nm_setting_olpc_mesh_error_quark (void);
-
-#define NM_SETTING_OLPC_MESH_SSID "ssid"
-#define NM_SETTING_OLPC_MESH_CHANNEL "channel"
-#define NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS "dhcp-anycast-address"
-
-typedef struct {
- NMSetting parent;
-} NMSettingOlpcMesh;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingOlpcMeshClass;
-
-GType nm_setting_olpc_mesh_get_type (void);
-
-NMSetting * nm_setting_olpc_mesh_new (void);
-const GByteArray *nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting);
-guint32 nm_setting_olpc_mesh_get_channel (NMSettingOlpcMesh *setting);
-const GByteArray *nm_setting_olpc_mesh_get_dhcp_anycast_address (NMSettingOlpcMesh *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_OLPC_MESH_H */
diff --git a/libnm-util/nm-setting-ppp.c b/libnm-util/nm-setting-ppp.c
deleted file mode 100644
index 3437d1a1f8..0000000000
--- a/libnm-util/nm-setting-ppp.c
+++ /dev/null
@@ -1,822 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-setting-ppp.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-ppp
- * @short_description: Describes connection properties for devices/networks
- * that require PPP to deliver IP capability
- * @include: nm-setting-ppp.h
- *
- * The #NMSettingPPP object is a #NMSetting subclass that describes properties
- * necessary for connection to networks that require PPP transport, like PPPoE
- * cable and DSL modems and some mobile broadband devices.
- **/
-
-/**
- * nm_setting_ppp_error_quark:
- *
- * Registers an error quark for #NMSettingPPP if necessary.
- *
- * Returns: the error quark used for #NMSettingPPP errors.
- **/
-GQuark
-nm_setting_ppp_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-ppp-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingPPP, nm_setting_ppp, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_PPP_SETTING_NAME,
- g_define_type_id,
- 3,
- NM_SETTING_PPP_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_PPP)
-
-#define NM_SETTING_PPP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_PPP, NMSettingPPPPrivate))
-
-typedef struct {
- gboolean noauth;
- gboolean refuse_eap;
- gboolean refuse_pap;
- gboolean refuse_chap;
- gboolean refuse_mschap;
- gboolean refuse_mschapv2;
- gboolean nobsdcomp;
- gboolean nodeflate;
- gboolean no_vj_comp;
- gboolean require_mppe;
- gboolean require_mppe_128;
- gboolean mppe_stateful;
- gboolean crtscts;
- guint32 baud;
- guint32 mru;
- guint32 mtu;
- guint32 lcp_echo_failure;
- guint32 lcp_echo_interval;
-} NMSettingPPPPrivate;
-
-enum {
- PROP_0,
- PROP_NOAUTH,
- PROP_REFUSE_EAP,
- PROP_REFUSE_PAP,
- PROP_REFUSE_CHAP,
- PROP_REFUSE_MSCHAP,
- PROP_REFUSE_MSCHAPV2,
- PROP_NOBSDCOMP,
- PROP_NODEFLATE,
- PROP_NO_VJ_COMP,
- PROP_REQUIRE_MPPE,
- PROP_REQUIRE_MPPE_128,
- PROP_MPPE_STATEFUL,
- PROP_CRTSCTS,
- PROP_BAUD,
- PROP_MRU,
- PROP_MTU,
- PROP_LCP_ECHO_FAILURE,
- PROP_LCP_ECHO_INTERVAL,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_ppp_new:
- *
- * Creates a new #NMSettingPPP object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingPPP object
- **/
-NMSetting *
-nm_setting_ppp_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_PPP, NULL);
-}
-
-/**
- * nm_setting_ppp_get_noauth:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:noauth property of the setting
- **/
-gboolean
-nm_setting_ppp_get_noauth (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->noauth;
-}
-
-/**
- * nm_setting_ppp_get_refuse_eap:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:refuse-eap property of the setting
- **/
-gboolean
-nm_setting_ppp_get_refuse_eap (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->refuse_eap;
-}
-
-/**
- * nm_setting_ppp_get_refuse_pap:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:refuse-pap property of the setting
- **/
-gboolean
-nm_setting_ppp_get_refuse_pap (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->refuse_pap;
-}
-
-/**
- * nm_setting_ppp_get_refuse_chap:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:refuse-chap property of the setting
- **/
-gboolean
-nm_setting_ppp_get_refuse_chap (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->refuse_chap;
-}
-
-/**
- * nm_setting_ppp_get_refuse_mschap:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:refuse-mschap property of the setting
- **/
-gboolean
-nm_setting_ppp_get_refuse_mschap (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->refuse_mschap;
-}
-
-/**
- * nm_setting_ppp_get_refuse_mschapv2:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:refuse-mschapv2 property of the setting
- **/
-gboolean
-nm_setting_ppp_get_refuse_mschapv2 (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->refuse_mschapv2;
-}
-
-/**
- * nm_setting_ppp_get_nobsdcomp:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:nobsdcomp property of the setting
- **/
-gboolean
-nm_setting_ppp_get_nobsdcomp (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->nobsdcomp;
-}
-
-/**
- * nm_setting_ppp_get_nodeflate:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:nodeflate property of the setting
- **/
-gboolean
-nm_setting_ppp_get_nodeflate (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->nodeflate;
-}
-
-/**
- * nm_setting_ppp_get_no_vj_comp:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:no-vj-comp property of the setting
- **/
-gboolean
-nm_setting_ppp_get_no_vj_comp (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->no_vj_comp;
-}
-
-/**
- * nm_setting_ppp_get_require_mppe:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:require-mppe property of the setting
- **/
-gboolean
-nm_setting_ppp_get_require_mppe (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->require_mppe;
-}
-
-/**
- * nm_setting_ppp_get_require_mppe_128:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:require-mppe-128 property of the setting
- **/
-gboolean
-nm_setting_ppp_get_require_mppe_128 (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->require_mppe_128;
-}
-
-/**
- * nm_setting_ppp_get_mppe_stateful:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:mppe-stateful property of the setting
- **/
-gboolean
-nm_setting_ppp_get_mppe_stateful (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->mppe_stateful;
-}
-
-/**
- * nm_setting_ppp_get_crtscts:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:crtscts property of the setting
- **/
-gboolean
-nm_setting_ppp_get_crtscts (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), FALSE);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->crtscts;
-}
-
-/**
- * nm_setting_ppp_get_baud:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:baud property of the setting
- **/
-guint32
-nm_setting_ppp_get_baud (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), 0);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->baud;
-}
-
-/**
- * nm_setting_ppp_get_mru:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:mru property of the setting
- **/
-guint32
-nm_setting_ppp_get_mru (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), 0);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->mru;
-}
-
-/**
- * nm_setting_ppp_get_mtu:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:mtu property of the setting
- **/
-guint32
-nm_setting_ppp_get_mtu (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), 0);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->mtu;
-}
-
-/**
- * nm_setting_ppp_get_lcp_echo_failure:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:lcp-echo-failure property of the setting
- **/
-guint32
-nm_setting_ppp_get_lcp_echo_failure (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), 0);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->lcp_echo_failure;
-}
-
-/**
- * nm_setting_ppp_get_lcp_echo_interval:
- * @setting: the #NMSettingPPP
- *
- * Returns: the #NMSettingPPP:lcp-echo-interval property of the setting
- **/
-guint32
-nm_setting_ppp_get_lcp_echo_interval (NMSettingPPP *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPP (setting), 0);
-
- return NM_SETTING_PPP_GET_PRIVATE (setting)->lcp_echo_interval;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingPPPPrivate *priv = NM_SETTING_PPP_GET_PRIVATE (setting);
-
- /* FIXME: Do we even want this or can we just let pppd evaluate the options? */
- if (priv->mru > 0) {
- if (priv->mru < 128 || priv->mru > 16384) {
- g_set_error (error,
- NM_SETTING_PPP_ERROR,
- NM_SETTING_PPP_ERROR_INVALID_PROPERTY,
- _("'%d' is out of valid range <128-16384>"),
- priv->mru);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_PPP_SETTING_NAME, NM_SETTING_PPP_MRU);
- return FALSE;
- }
- }
-
- if (priv->lcp_echo_failure > 0) {
- /* lcp_echo_interval must also be non-zero */
- if (priv->lcp_echo_interval == 0) {
- g_set_error (error,
- NM_SETTING_PPP_ERROR,
- NM_SETTING_PPP_ERROR_INVALID_PROPERTY,
- _("setting this property requires non-zero '%s' property"),
- NM_SETTING_PPP_LCP_ECHO_INTERVAL);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_PPP_SETTING_NAME, NM_SETTING_PPP_LCP_ECHO_FAILURE);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void
-nm_setting_ppp_init (NMSettingPPP *setting)
-{
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingPPPPrivate *priv = NM_SETTING_PPP_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_NOAUTH:
- priv->noauth = g_value_get_boolean (value);
- break;
- case PROP_REFUSE_EAP:
- priv->refuse_eap = g_value_get_boolean (value);
- break;
- case PROP_REFUSE_PAP:
- priv->refuse_pap = g_value_get_boolean (value);
- break;
- case PROP_REFUSE_CHAP:
- priv->refuse_chap = g_value_get_boolean (value);
- break;
- case PROP_REFUSE_MSCHAP:
- priv->refuse_mschap = g_value_get_boolean (value);
- break;
- case PROP_REFUSE_MSCHAPV2:
- priv->refuse_mschapv2 = g_value_get_boolean (value);
- break;
- case PROP_NOBSDCOMP:
- priv->nobsdcomp = g_value_get_boolean (value);
- break;
- case PROP_NODEFLATE:
- priv->nodeflate = g_value_get_boolean (value);
- break;
- case PROP_NO_VJ_COMP:
- priv->no_vj_comp = g_value_get_boolean (value);
- break;
- case PROP_REQUIRE_MPPE:
- priv->require_mppe = g_value_get_boolean (value);
- break;
- case PROP_REQUIRE_MPPE_128:
- priv->require_mppe_128 = g_value_get_boolean (value);
- break;
- case PROP_MPPE_STATEFUL:
- priv->mppe_stateful = g_value_get_boolean (value);
- break;
- case PROP_CRTSCTS:
- priv->crtscts = g_value_get_boolean (value);
- break;
- case PROP_BAUD:
- priv->baud = g_value_get_uint (value);
- break;
- case PROP_MRU:
- priv->mru = g_value_get_uint (value);
- break;
- case PROP_MTU:
- priv->mtu = g_value_get_uint (value);
- break;
- case PROP_LCP_ECHO_FAILURE:
- priv->lcp_echo_failure = g_value_get_uint (value);
- break;
- case PROP_LCP_ECHO_INTERVAL:
- priv->lcp_echo_interval = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingPPP *setting = NM_SETTING_PPP (object);
-
- switch (prop_id) {
- case PROP_NOAUTH:
- g_value_set_boolean (value, nm_setting_ppp_get_noauth (setting));
- break;
- case PROP_REFUSE_EAP:
- g_value_set_boolean (value, nm_setting_ppp_get_refuse_eap (setting));
- break;
- case PROP_REFUSE_PAP:
- g_value_set_boolean (value, nm_setting_ppp_get_refuse_pap (setting));
- break;
- case PROP_REFUSE_CHAP:
- g_value_set_boolean (value, nm_setting_ppp_get_refuse_chap (setting));
- break;
- case PROP_REFUSE_MSCHAP:
- g_value_set_boolean (value, nm_setting_ppp_get_refuse_mschap (setting));
- break;
- case PROP_REFUSE_MSCHAPV2:
- g_value_set_boolean (value, nm_setting_ppp_get_refuse_mschapv2 (setting));
- break;
- case PROP_NOBSDCOMP:
- g_value_set_boolean (value, nm_setting_ppp_get_nobsdcomp (setting));
- break;
- case PROP_NODEFLATE:
- g_value_set_boolean (value, nm_setting_ppp_get_nodeflate (setting));
- break;
- case PROP_NO_VJ_COMP:
- g_value_set_boolean (value, nm_setting_ppp_get_no_vj_comp (setting));
- break;
- case PROP_REQUIRE_MPPE:
- g_value_set_boolean (value, nm_setting_ppp_get_require_mppe (setting));
- break;
- case PROP_REQUIRE_MPPE_128:
- g_value_set_boolean (value, nm_setting_ppp_get_require_mppe_128 (setting));
- break;
- case PROP_MPPE_STATEFUL:
- g_value_set_boolean (value, nm_setting_ppp_get_mppe_stateful (setting));
- break;
- case PROP_CRTSCTS:
- g_value_set_boolean (value, nm_setting_ppp_get_crtscts (setting));
- break;
- case PROP_BAUD:
- g_value_set_uint (value, nm_setting_ppp_get_baud (setting));
- break;
- case PROP_MRU:
- g_value_set_uint (value, nm_setting_ppp_get_mru (setting));
- break;
- case PROP_MTU:
- g_value_set_uint (value, nm_setting_ppp_get_mtu (setting));
- break;
- case PROP_LCP_ECHO_FAILURE:
- g_value_set_uint (value, nm_setting_ppp_get_lcp_echo_failure (setting));
- break;
- case PROP_LCP_ECHO_INTERVAL:
- g_value_set_uint (value, nm_setting_ppp_get_lcp_echo_interval (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingPPPPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingPPP:noauth:
- *
- * If %TRUE, do not require the other side (usually the PPP server) to
- * authenticate itself to the client. If %FALSE, require authentication
- * from the remote side. In almost all cases, this should be %TRUE.
- **/
- g_object_class_install_property
- (object_class, PROP_NOAUTH,
- g_param_spec_boolean (NM_SETTING_PPP_NOAUTH, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:refuse-eap:
- *
- * If %TRUE, the EAP authentication method will not be used.
- **/
- g_object_class_install_property
- (object_class, PROP_REFUSE_EAP,
- g_param_spec_boolean (NM_SETTING_PPP_REFUSE_EAP, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:refuse-pap:
- *
- * If %TRUE, the PAP authentication method will not be used.
- **/
- g_object_class_install_property
- (object_class, PROP_REFUSE_PAP,
- g_param_spec_boolean (NM_SETTING_PPP_REFUSE_PAP, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:refuse-chap:
- *
- * If %TRUE, the CHAP authentication method will not be used.
- **/
- g_object_class_install_property
- (object_class, PROP_REFUSE_CHAP,
- g_param_spec_boolean (NM_SETTING_PPP_REFUSE_CHAP, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:refuse-mschap:
- *
- * If %TRUE, the MSCHAP authentication method will not be used.
- **/
- g_object_class_install_property
- (object_class, PROP_REFUSE_MSCHAP,
- g_param_spec_boolean (NM_SETTING_PPP_REFUSE_MSCHAP, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:refuse-mschapv2:
- *
- * If %TRUE, the MSCHAPv2 authentication method will not be used.
- **/
- g_object_class_install_property
- (object_class, PROP_REFUSE_MSCHAPV2,
- g_param_spec_boolean (NM_SETTING_PPP_REFUSE_MSCHAPV2, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:nobsdcomp:
- *
- * If %TRUE, BSD compression will not be requested.
- **/
- g_object_class_install_property
- (object_class, PROP_NOBSDCOMP,
- g_param_spec_boolean (NM_SETTING_PPP_NOBSDCOMP, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:nodeflate:
- *
- * If %TRUE, "deflate" compression will not be requested.
- **/
- g_object_class_install_property
- (object_class, PROP_NODEFLATE,
- g_param_spec_boolean (NM_SETTING_PPP_NODEFLATE, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:no-vj-comp:
- *
- * If %TRUE, Van Jacobsen TCP header compression will not be requested.
- **/
- g_object_class_install_property
- (object_class, PROP_NO_VJ_COMP,
- g_param_spec_boolean (NM_SETTING_PPP_NO_VJ_COMP, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:require-mppe:
- *
- * If %TRUE, MPPE (Microsoft Point-to-Point Encryption) will be required for
- * the PPP session. If either 64-bit or 128-bit MPPE is not available the
- * session will fail. Note that MPPE is not used on mobile broadband
- * connections.
- **/
- g_object_class_install_property
- (object_class, PROP_REQUIRE_MPPE,
- g_param_spec_boolean (NM_SETTING_PPP_REQUIRE_MPPE, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:require-mppe-128:
- *
- * If %TRUE, 128-bit MPPE (Microsoft Point-to-Point Encryption) will be
- * required for the PPP session, and the "require-mppe" property must also
- * be set to %TRUE. If 128-bit MPPE is not available the session will fail.
- **/
- g_object_class_install_property
- (object_class, PROP_REQUIRE_MPPE_128,
- g_param_spec_boolean (NM_SETTING_PPP_REQUIRE_MPPE_128, "", "",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:mppe-stateful:
- *
- * If %TRUE, stateful MPPE is used. See pppd documentation for more
- * information on stateful MPPE.
- **/
- g_object_class_install_property
- (object_class, PROP_MPPE_STATEFUL,
- g_param_spec_boolean (NM_SETTING_PPP_MPPE_STATEFUL, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:crtscts:
- *
- * If %TRUE, specify that pppd should set the serial port to use hardware
- * flow control with RTS and CTS signals. This value should normally be set
- * to %FALSE.
- **/
- g_object_class_install_property
- (object_class, PROP_CRTSCTS,
- g_param_spec_boolean (NM_SETTING_PPP_CRTSCTS, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:baud:
- *
- * If non-zero, instruct pppd to set the serial port to the specified
- * baudrate. This value should normally be left as 0 to automatically
- * choose the speed.
- **/
- g_object_class_install_property
- (object_class, PROP_BAUD,
- g_param_spec_uint (NM_SETTING_PPP_BAUD, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:mru:
- *
- * If non-zero, instruct pppd to request that the peer send packets no
- * larger than the specified size. If non-zero, the MRU should be between
- * 128 and 16384.
- */
- g_object_class_install_property
- (object_class, PROP_MRU,
- g_param_spec_uint (NM_SETTING_PPP_MRU, "", "",
- 0, 16384, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:mtu:
- *
- * If non-zero, instruct pppd to send packets no larger than the specified
- * size.
- **/
- g_object_class_install_property
- (object_class, PROP_MTU,
- g_param_spec_uint (NM_SETTING_PPP_MTU, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:lcp-echo-failure:
- *
- * If non-zero, instruct pppd to presume the connection to the peer has
- * failed if the specified number of LCP echo-requests go unanswered by the
- * peer. The "lcp-echo-interval" property must also be set to a non-zero
- * value if this property is used.
- **/
- g_object_class_install_property
- (object_class, PROP_LCP_ECHO_FAILURE,
- g_param_spec_uint (NM_SETTING_PPP_LCP_ECHO_FAILURE, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPP:lcp-echo-interval:
- *
- * If non-zero, instruct pppd to send an LCP echo-request frame to the peer
- * every n seconds (where n is the specified value). Note that some PPP
- * peers will respond to echo requests and some will not, and it is not
- * possible to autodetect this.
- **/
- g_object_class_install_property
- (object_class, PROP_LCP_ECHO_INTERVAL,
- g_param_spec_uint (NM_SETTING_PPP_LCP_ECHO_INTERVAL, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-ppp.h b/libnm-util/nm-setting-ppp.h
deleted file mode 100644
index 52856463a4..0000000000
--- a/libnm-util/nm-setting-ppp.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_PPP_H
-#define NM_SETTING_PPP_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_PPP (nm_setting_ppp_get_type ())
-#define NM_SETTING_PPP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_PPP, NMSettingPPP))
-#define NM_SETTING_PPP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_PPP, NMSettingPPPClass))
-#define NM_IS_SETTING_PPP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_PPP))
-#define NM_IS_SETTING_PPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_PPP))
-#define NM_SETTING_PPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_PPP, NMSettingPPPClass))
-
-#define NM_SETTING_PPP_SETTING_NAME "ppp"
-
-/**
- * NMSettingPPPError:
- * @NM_SETTING_PPP_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_PPP_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_PPP_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED: requiring MPPE is not compatible
- * with other setting configuration parameters
- */
-typedef enum {
- NM_SETTING_PPP_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_PPP_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_PPP_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED /*< nick=RequireMPPENotAllowed >*/
-} NMSettingPPPError;
-
-#define NM_SETTING_PPP_ERROR nm_setting_ppp_error_quark ()
-GQuark nm_setting_ppp_error_quark (void);
-
-#define NM_SETTING_PPP_NOAUTH "noauth"
-#define NM_SETTING_PPP_REFUSE_EAP "refuse-eap"
-#define NM_SETTING_PPP_REFUSE_PAP "refuse-pap"
-#define NM_SETTING_PPP_REFUSE_CHAP "refuse-chap"
-#define NM_SETTING_PPP_REFUSE_MSCHAP "refuse-mschap"
-#define NM_SETTING_PPP_REFUSE_MSCHAPV2 "refuse-mschapv2"
-#define NM_SETTING_PPP_NOBSDCOMP "nobsdcomp"
-#define NM_SETTING_PPP_NODEFLATE "nodeflate"
-#define NM_SETTING_PPP_NO_VJ_COMP "no-vj-comp"
-#define NM_SETTING_PPP_REQUIRE_MPPE "require-mppe"
-#define NM_SETTING_PPP_REQUIRE_MPPE_128 "require-mppe-128"
-#define NM_SETTING_PPP_MPPE_STATEFUL "mppe-stateful"
-#define NM_SETTING_PPP_CRTSCTS "crtscts"
-#define NM_SETTING_PPP_BAUD "baud"
-#define NM_SETTING_PPP_MRU "mru"
-#define NM_SETTING_PPP_MTU "mtu"
-#define NM_SETTING_PPP_LCP_ECHO_FAILURE "lcp-echo-failure"
-#define NM_SETTING_PPP_LCP_ECHO_INTERVAL "lcp-echo-interval"
-
-typedef struct {
- NMSetting parent;
-} NMSettingPPP;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingPPPClass;
-
-GType nm_setting_ppp_get_type (void);
-
-NMSetting *nm_setting_ppp_new (void);
-gboolean nm_setting_ppp_get_noauth (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_refuse_eap (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_refuse_pap (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_refuse_chap (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_refuse_mschap (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_refuse_mschapv2 (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_nobsdcomp (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_nodeflate (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_no_vj_comp (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_require_mppe (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_require_mppe_128 (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_mppe_stateful (NMSettingPPP *setting);
-gboolean nm_setting_ppp_get_crtscts (NMSettingPPP *setting);
-guint32 nm_setting_ppp_get_baud (NMSettingPPP *setting);
-guint32 nm_setting_ppp_get_mru (NMSettingPPP *setting);
-guint32 nm_setting_ppp_get_mtu (NMSettingPPP *setting);
-guint32 nm_setting_ppp_get_lcp_echo_failure (NMSettingPPP *setting);
-guint32 nm_setting_ppp_get_lcp_echo_interval (NMSettingPPP *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_PPP_H */
diff --git a/libnm-util/nm-setting-pppoe.c b/libnm-util/nm-setting-pppoe.c
deleted file mode 100644
index e66165fd09..0000000000
--- a/libnm-util/nm-setting-pppoe.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-pppoe.h"
-#include "nm-setting-ppp.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-pppoe
- * @short_description: Describes PPPoE connection properties
- * @include: nm-setting-pppoe.h
- *
- * The #NMSettingPPPOE object is a #NMSetting subclass that describes
- * properties necessary for connection to networks that require PPPoE connections
- * to provide IP transport, for example cable or DSL modems.
- **/
-
-/**
- * nm_setting_pppoe_error_quark:
- *
- * Registers an error quark for #NMSettingPPPOE if necessary.
- *
- * Returns: the error quark used for #NMSettingPPPOE errors.
- **/
-GQuark
-nm_setting_pppoe_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-pppoe-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingPPPOE, nm_setting_pppoe, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_PPPOE_SETTING_NAME,
- g_define_type_id,
- 3,
- NM_SETTING_PPPOE_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_PPPOE)
-
-#define NM_SETTING_PPPOE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_PPPOE, NMSettingPPPOEPrivate))
-
-typedef struct {
- char *service;
- char *username;
- char *password;
- NMSettingSecretFlags password_flags;
-} NMSettingPPPOEPrivate;
-
-enum {
- PROP_0,
- PROP_SERVICE,
- PROP_USERNAME,
- PROP_PASSWORD,
- PROP_PASSWORD_FLAGS,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_pppoe_new:
- *
- * Creates a new #NMSettingPPPOE object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingPPPOE object
- **/
-NMSetting *
-nm_setting_pppoe_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_PPPOE, NULL);
-}
-
-/**
- * nm_setting_pppoe_get_service:
- * @setting: the #NMSettingPPPOE
- *
- * Returns: the #NMSettingPPPOE:service property of the setting
- **/
-const char *
-nm_setting_pppoe_get_service (NMSettingPPPOE *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NULL);
-
- return NM_SETTING_PPPOE_GET_PRIVATE (setting)->service;
-}
-
-/**
- * nm_setting_pppoe_get_username:
- * @setting: the #NMSettingPPPOE
- *
- * Returns: the #NMSettingPPPOE:username property of the setting
- **/
-const char *
-nm_setting_pppoe_get_username (NMSettingPPPOE *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NULL);
-
- return NM_SETTING_PPPOE_GET_PRIVATE (setting)->username;
-}
-
-/**
- * nm_setting_pppoe_get_password:
- * @setting: the #NMSettingPPPOE
- *
- * Returns: the #NMSettingPPPOE:password property of the setting
- **/
-const char *
-nm_setting_pppoe_get_password (NMSettingPPPOE *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NULL);
-
- return NM_SETTING_PPPOE_GET_PRIVATE (setting)->password;
-}
-
-/**
- * nm_setting_pppoe_get_password_flags:
- * @setting: the #NMSettingPPPOE
- *
- * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingPPPOE:password
- **/
-NMSettingSecretFlags
-nm_setting_pppoe_get_password_flags (NMSettingPPPOE *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_PPPOE_GET_PRIVATE (setting)->password_flags;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingPPPOEPrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (setting);
-
- if (!priv->username) {
- g_set_error_literal (error,
- NM_SETTING_PPPOE_ERROR,
- NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_USERNAME);
- return FALSE;
- } else if (!strlen (priv->username)) {
- g_set_error_literal (error,
- NM_SETTING_PPPOE_ERROR,
- NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_USERNAME);
- return FALSE;
- }
-
- if (priv->service && !strlen (priv->service)) {
- g_set_error_literal (error,
- NM_SETTING_PPPOE_ERROR,
- NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_SERVICE);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static GPtrArray *
-need_secrets (NMSetting *setting)
-{
- NMSettingPPPOEPrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (setting);
- GPtrArray *secrets = NULL;
-
- if (priv->password)
- return NULL;
-
- if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) {
- secrets = g_ptr_array_sized_new (1);
- g_ptr_array_add (secrets, NM_SETTING_PPPOE_PASSWORD);
- }
-
- return secrets;
-}
-
-static void
-nm_setting_pppoe_init (NMSettingPPPOE *setting)
-{
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingPPPOEPrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_SERVICE:
- g_free (priv->service);
- priv->service = g_value_dup_string (value);
- break;
- case PROP_USERNAME:
- g_free (priv->username);
- priv->username = g_value_dup_string (value);
- break;
- case PROP_PASSWORD:
- g_free (priv->password);
- priv->password = g_value_dup_string (value);
- break;
- case PROP_PASSWORD_FLAGS:
- priv->password_flags = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingPPPOE *setting = NM_SETTING_PPPOE (object);
-
- switch (prop_id) {
- case PROP_SERVICE:
- g_value_set_string (value, nm_setting_pppoe_get_service (setting));
- break;
- case PROP_USERNAME:
- g_value_set_string (value, nm_setting_pppoe_get_username (setting));
- break;
- case PROP_PASSWORD:
- g_value_set_string (value, nm_setting_pppoe_get_password (setting));
- break;
- case PROP_PASSWORD_FLAGS:
- g_value_set_uint (value, nm_setting_pppoe_get_password_flags (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingPPPOEPrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (object);
-
- g_free (priv->username);
- g_free (priv->password);
- g_free (priv->service);
-
- G_OBJECT_CLASS (nm_setting_pppoe_parent_class)->finalize (object);
-}
-
-static void
-nm_setting_pppoe_class_init (NMSettingPPPOEClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingPPPOEPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->need_secrets = need_secrets;
-
- /* Properties */
- /**
- * NMSettingPPPOE:service:
- *
- * If specified, instruct PPPoE to only initiate sessions with access
- * concentrators that provide the specified service. For most providers,
- * this should be left blank. It is only required if there are multiple
- * access concentrators or a specific service is known to be required.
- **/
- g_object_class_install_property
- (object_class, PROP_SERVICE,
- g_param_spec_string (NM_SETTING_PPPOE_SERVICE, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPPOE:username:
- *
- * Username used to authenticate with the PPPoE service.
- **/
- g_object_class_install_property
- (object_class, PROP_USERNAME,
- g_param_spec_string (NM_SETTING_PPPOE_USERNAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPPOE:password:
- *
- * Password used to authenticate with the PPPoE service.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD,
- g_param_spec_string (NM_SETTING_PPPOE_PASSWORD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingPPPOE:password-flags:
- *
- * Flags indicating how to handle the #NMSettingPPPOE:password property.
- **/
- g_object_class_install_property
- (object_class, PROP_PASSWORD_FLAGS,
- g_param_spec_uint (NM_SETTING_PPPOE_PASSWORD_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-pppoe.h b/libnm-util/nm-setting-pppoe.h
deleted file mode 100644
index 9f8add4e63..0000000000
--- a/libnm-util/nm-setting-pppoe.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_PPPOE_H
-#define NM_SETTING_PPPOE_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_PPPOE (nm_setting_pppoe_get_type ())
-#define NM_SETTING_PPPOE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_PPPOE, NMSettingPPPOE))
-#define NM_SETTING_PPPOE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_PPPOE, NMSettingPPPOEClass))
-#define NM_IS_SETTING_PPPOE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_PPPOE))
-#define NM_IS_SETTING_PPPOE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_PPPOE))
-#define NM_SETTING_PPPOE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_PPPOE, NMSettingPPPOEClass))
-
-#define NM_SETTING_PPPOE_SETTING_NAME "pppoe"
-
-/**
- * NMSettingPPPOEError:
- * @NM_SETTING_PPPOE_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING: the connection
- * did not contain a required PPP setting for PPP related options
- */
-typedef enum {
- NM_SETTING_PPPOE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING /*< nick=MissingPPPSetting >*/
-} NMSettingPPPOEError;
-
-#define NM_SETTING_PPPOE_ERROR nm_setting_pppoe_error_quark ()
-GQuark nm_setting_pppoe_error_quark (void);
-
-#define NM_SETTING_PPPOE_SERVICE "service"
-#define NM_SETTING_PPPOE_USERNAME "username"
-#define NM_SETTING_PPPOE_PASSWORD "password"
-#define NM_SETTING_PPPOE_PASSWORD_FLAGS "password-flags"
-
-typedef struct {
- NMSetting parent;
-} NMSettingPPPOE;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingPPPOEClass;
-
-GType nm_setting_pppoe_get_type (void);
-
-NMSetting *nm_setting_pppoe_new (void);
-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
-
-#endif /* NM_SETTING_PPPOE_H */
diff --git a/libnm-util/nm-setting-private.h b/libnm-util/nm-setting-private.h
deleted file mode 100644
index 9b8e946454..0000000000
--- a/libnm-util/nm-setting-private.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_PRIVATE_H
-#define NM_SETTING_PRIVATE_H
-
-#include "nm-connection.h"
-
-#define NM_SETTING_SECRET_FLAGS_ALL \
- (NM_SETTING_SECRET_FLAG_NONE | \
- NM_SETTING_SECRET_FLAG_AGENT_OWNED | \
- NM_SETTING_SECRET_FLAG_NOT_SAVED | \
- NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
-
-/**
- * NMSettingVerifyResult:
- * @NM_SETTING_VERIFY_SUCCESS: the setting verifies successfully
- * @NM_SETTING_VERIFY_ERROR: the setting has a serious misconfiguration
- * @NM_SETTING_VERIFY_NORMALIZABLE: the setting is valid but has properties
- * that should be normalized
- * @NM_SETTING_VERIFY_NORMALIZABLE_ERROR: the setting is invalid but the
- * errors can be fixed by nm_connection_normalize().
- */
-typedef enum {
- NM_SETTING_VERIFY_SUCCESS = TRUE,
- NM_SETTING_VERIFY_ERROR = FALSE,
- NM_SETTING_VERIFY_NORMALIZABLE = 2,
- NM_SETTING_VERIFY_NORMALIZABLE_ERROR = 3,
-} NMSettingVerifyResult;
-
-void _nm_register_setting (const char *name,
- const GType type,
- const guint32 priority,
- const GQuark error_quark);
-
-/* Ensure, that name is a compile time constant string. Put the function name in parenthesis to suppress expansion. */
-#define _nm_register_setting(name, type, priority, error_quark) _nm_register_setting ((name ""), type, priority, error_quark)
-
-gboolean _nm_setting_is_base_type (NMSetting *setting);
-gboolean _nm_setting_type_is_base_type (GType type);
-guint32 _nm_setting_get_setting_priority (NMSetting *setting);
-GType _nm_setting_lookup_setting_type (const char *name);
-GType _nm_setting_lookup_setting_type_by_quark (GQuark error_quark);
-int _nm_setting_compare_priority (gconstpointer a, gconstpointer b);
-
-gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
-
-NMConnection *_nm_connection_new_from_hash (GHashTable *hash);
-void _nm_connection_replace_settings (NMConnection *connection,
- GHashTable *new_settings);
-
-typedef enum NMSettingUpdateSecretResult {
- NM_SETTING_UPDATE_SECRET_ERROR = FALSE,
- NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED = TRUE,
- NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED = 2,
-} NMSettingUpdateSecretResult;
-
-NMSettingUpdateSecretResult _nm_setting_update_secrets (NMSetting *setting,
- GHashTable *secrets,
- GError **error);
-gboolean _nm_setting_clear_secrets (NMSetting *setting);
-gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data);
-
-/* NM_SETTING_COMPARE_FLAG_INFERRABLE: check whether a device-generated
- * connection can be replaced by a already-defined connection. This flag only
- * takes into account properties marked with the %NM_SETTING_PARAM_INFERRABLE
- * flag.
- */
-#define NM_SETTING_COMPARE_FLAG_INFERRABLE 0x80000000
-
-/* The property of the #NMSetting should be considered during comparisons that
- * use the %NM_SETTING_COMPARE_FLAG_INFERRABLE flag. Properties that don't have
- * this flag, are ignored when doing an infrerrable comparison. This flag should
- * be set on all properties that are read from the kernel or the system when a
- * connection is generated. eg, IP addresses/routes can be read from the
- * kernel, but the 'autoconnect' property cannot, so
- * %NM_SETTING_IP4_CONFIG_ADDRESSES gets the INFERRABLE flag, but
- * %NM_SETTING_CONNECTION_AUTOCONNECT would not.
- *
- * This flag should not be used with properties where the default cannot be
- * read separately from the current value, like MTU or wired duplex mode.
- */
-#define NM_SETTING_PARAM_INFERRABLE (1 << (4 + G_PARAM_USER_SHIFT))
-
-/* Ensure the setting's GType is registered at library load time */
-#define NM_SETTING_REGISTER_TYPE(x) \
-static void __attribute__((constructor)) register_setting (void) \
-{ g_type_ensure (x); }
-
-NMSetting *nm_setting_find_in_list (GSList *settings_list, const char *setting_name);
-
-NMSettingVerifyResult _nm_setting_verify_deprecated_virtual_iface_name (const char *interface_name,
- gboolean allow_missing,
- const char *setting_name,
- const char *setting_property,
- GQuark error_quark,
- int e_invalid_property,
- int e_missing_property,
- GSList *all_settings,
- GError **error);
-
-NMSettingVerifyResult _nm_setting_verify (NMSetting *setting,
- GSList *all_settings,
- GError **error);
-
-#endif /* NM_SETTING_PRIVATE_H */
diff --git a/libnm-util/nm-setting-serial.c b/libnm-util/nm-setting-serial.c
deleted file mode 100644
index 369c4b109e..0000000000
--- a/libnm-util/nm-setting-serial.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting-serial.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-serial
- * @short_description: Describes connection properties for devices that use
- * serial communications
- * @include: nm-setting-serial.h
- *
- * The #NMSettingSerial object is a #NMSetting subclass that describes
- * properties necessary for connections that may use serial communications,
- * such as mobile broadband or analog telephone connections.
- **/
-
-/**
- * nm_setting_serial_error_quark:
- *
- * Registers an error quark for #NMSettingSerial if necessary.
- *
- * Returns: the error quark used for #NMSettingSerial errors.
- **/
-GQuark
-nm_setting_serial_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-serial-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingSerial, nm_setting_serial, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_SERIAL_SETTING_NAME,
- g_define_type_id,
- 2,
- NM_SETTING_SERIAL_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_SERIAL)
-
-#define NM_SETTING_SERIAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_SERIAL, NMSettingSerialPrivate))
-
-typedef struct {
- guint baud;
- guint bits;
- char parity;
- guint stopbits;
- guint64 send_delay;
-} NMSettingSerialPrivate;
-
-enum {
- PROP_0,
- PROP_BAUD,
- PROP_BITS,
- PROP_PARITY,
- PROP_STOPBITS,
- PROP_SEND_DELAY,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_serial_new:
- *
- * Creates a new #NMSettingSerial object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingSerial object
- **/
-NMSetting *
-nm_setting_serial_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_SERIAL, NULL);
-}
-
-/**
- * nm_setting_serial_get_baud:
- * @setting: the #NMSettingSerial
- *
- * Returns: the #NMSettingSerial:baud property of the setting
- **/
-guint
-nm_setting_serial_get_baud (NMSettingSerial *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_SERIAL (setting), 0);
-
- return NM_SETTING_SERIAL_GET_PRIVATE (setting)->baud;
-}
-
-/**
- * nm_setting_serial_get_bits:
- * @setting: the #NMSettingSerial
- *
- * Returns: the #NMSettingSerial:bits property of the setting
- **/
-guint
-nm_setting_serial_get_bits (NMSettingSerial *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_SERIAL (setting), 0);
-
- return NM_SETTING_SERIAL_GET_PRIVATE (setting)->bits;
-}
-
-/**
- * nm_setting_serial_get_parity:
- * @setting: the #NMSettingSerial
- *
- * Returns: the #NMSettingSerial:parity property of the setting
- **/
-char
-nm_setting_serial_get_parity (NMSettingSerial *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_SERIAL (setting), 0);
-
- return NM_SETTING_SERIAL_GET_PRIVATE (setting)->parity;
-}
-
-/**
- * nm_setting_serial_get_stopbits:
- * @setting: the #NMSettingSerial
- *
- * Returns: the #NMSettingSerial:stopbits property of the setting
- **/
-guint
-nm_setting_serial_get_stopbits (NMSettingSerial *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_SERIAL (setting), 0);
-
- return NM_SETTING_SERIAL_GET_PRIVATE (setting)->stopbits;
-}
-
-/**
- * nm_setting_serial_get_send_delay:
- * @setting: the #NMSettingSerial
- *
- * Returns: the #NMSettingSerial:send-delay property of the setting
- **/
-guint64
-nm_setting_serial_get_send_delay (NMSettingSerial *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_SERIAL (setting), 0);
-
- return NM_SETTING_SERIAL_GET_PRIVATE (setting)->send_delay;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- return TRUE;
-}
-
-static void
-nm_setting_serial_init (NMSettingSerial *setting)
-{
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingSerialPrivate *priv = NM_SETTING_SERIAL_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_BAUD:
- priv->baud = g_value_get_uint (value);
- break;
- case PROP_BITS:
- priv->bits = g_value_get_uint (value);
- break;
- case PROP_PARITY:
- priv->parity = g_value_get_schar (value);
- break;
- case PROP_STOPBITS:
- priv->stopbits = g_value_get_uint (value);
- break;
- case PROP_SEND_DELAY:
- priv->send_delay = g_value_get_uint64 (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingSerial *setting = NM_SETTING_SERIAL (object);
-
- switch (prop_id) {
- case PROP_BAUD:
- g_value_set_uint (value, nm_setting_serial_get_baud (setting));
- break;
- case PROP_BITS:
- g_value_set_uint (value, nm_setting_serial_get_bits (setting));
- break;
- case PROP_PARITY:
- g_value_set_schar (value, nm_setting_serial_get_parity (setting));
- break;
- case PROP_STOPBITS:
- g_value_set_uint (value, nm_setting_serial_get_stopbits (setting));
- break;
- case PROP_SEND_DELAY:
- g_value_set_uint64 (value, nm_setting_serial_get_send_delay (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_serial_class_init (NMSettingSerialClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingSerialPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- parent_class->verify = verify;
-
- /* Properties */
-
- /**
- * NMSettingSerial:baud:
- *
- * Speed to use for communication over the serial port. Note that this
- * value usually has no effect for mobile broadband modems as they generally
- * ignore speed settings and use the highest available speed.
- **/
- g_object_class_install_property
- (object_class, PROP_BAUD,
- g_param_spec_uint (NM_SETTING_SERIAL_BAUD, "", "",
- 0, G_MAXUINT, 57600,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingSerial:bits:
- *
- * Byte-width of the serial communication. The 8 in "8n1" for example.
- **/
- g_object_class_install_property
- (object_class, PROP_BITS,
- g_param_spec_uint (NM_SETTING_SERIAL_BITS, "", "",
- 5, 8, 8,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingSerial:parity:
- *
- * Parity setting of the serial port. Either 'E' for even parity, 'o' for
- * odd parity, or 'n' for no parity.
- **/
- g_object_class_install_property
- (object_class, PROP_PARITY,
- g_param_spec_char (NM_SETTING_SERIAL_PARITY, "", "",
- 'E', 'o', 'n',
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingSerial:stopbits:
- *
- * Number of stop bits for communication on the serial port. Either 1 or 2.
- * The 1 in "8n1" for example.
- **/
- g_object_class_install_property
- (object_class, PROP_STOPBITS,
- g_param_spec_uint (NM_SETTING_SERIAL_STOPBITS, "", "",
- 1, 2, 1,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingSerial:send-delay:
- *
- * Time to delay between each byte sent to the modem, in microseconds.
- **/
- g_object_class_install_property
- (object_class, PROP_SEND_DELAY,
- g_param_spec_uint64 (NM_SETTING_SERIAL_SEND_DELAY, "", "",
- 0, G_MAXUINT64, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-serial.h b/libnm-util/nm-setting-serial.h
deleted file mode 100644
index bca9abae92..0000000000
--- a/libnm-util/nm-setting-serial.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2008 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_SERIAL_H
-#define NM_SETTING_SERIAL_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_SERIAL (nm_setting_serial_get_type ())
-#define NM_SETTING_SERIAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_SERIAL, NMSettingSerial))
-#define NM_SETTING_SERIAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_SERIAL, NMSettingSerialClass))
-#define NM_IS_SETTING_SERIAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_SERIAL))
-#define NM_IS_SETTING_SERIAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_SERIAL))
-#define NM_SETTING_SERIAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_SERIAL, NMSettingSerialClass))
-
-#define NM_SETTING_SERIAL_SETTING_NAME "serial"
-
-/**
- * NMSettingSerialError:
- * @NM_SETTING_SERIAL_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING: one of the properties of the
- * setting requires the connection to contain an #NMSettingPPP setting
- */
-typedef enum {
- NM_SETTING_SERIAL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING /*< nick=MissingPPPSetting >*/
-} NMSettingSerialError;
-
-#define NM_SETTING_SERIAL_ERROR nm_setting_serial_error_quark ()
-GQuark nm_setting_serial_error_quark (void);
-
-#define NM_SETTING_SERIAL_BAUD "baud"
-#define NM_SETTING_SERIAL_BITS "bits"
-#define NM_SETTING_SERIAL_PARITY "parity"
-#define NM_SETTING_SERIAL_STOPBITS "stopbits"
-#define NM_SETTING_SERIAL_SEND_DELAY "send-delay"
-
-typedef struct {
- NMSetting parent;
-} NMSettingSerial;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingSerialClass;
-
-GType nm_setting_serial_get_type (void);
-
-NMSetting *nm_setting_serial_new (void);
-guint nm_setting_serial_get_baud (NMSettingSerial *setting);
-guint nm_setting_serial_get_bits (NMSettingSerial *setting);
-char nm_setting_serial_get_parity (NMSettingSerial *setting);
-guint nm_setting_serial_get_stopbits (NMSettingSerial *setting);
-guint64 nm_setting_serial_get_send_delay (NMSettingSerial *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_SERIAL_H */
diff --git a/libnm-util/nm-setting-team-port.c b/libnm-util/nm-setting-team-port.c
deleted file mode 100644
index 5fa511d988..0000000000
--- a/libnm-util/nm-setting-team-port.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Jiri Pirko <jiri@resnulli.us>
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-team-port.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-team-port
- * @short_description: Describes connection properties for team ports
- * @include: nm-setting-team-port.h
- *
- * The #NMSettingTeamPort object is a #NMSetting subclass that describes
- * optional properties that apply to team ports.
- *
- * Since: 0.9.10
- **/
-
-/**
- * nm_setting_team_port_error_quark:
- *
- * Registers an error quark for #NMSettingTeamPort if necessary.
- *
- * Returns: the error quark used for #NMSettingTeamPort errors.
- *
- * Since: 0.9.10
- **/
-GQuark
-nm_setting_team_port_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-team-port-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingTeamPort, nm_setting_team_port, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_TEAM_PORT_SETTING_NAME,
- g_define_type_id,
- 3,
- NM_SETTING_TEAM_PORT_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM_PORT)
-
-#define NM_SETTING_TEAM_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortPrivate))
-
-typedef struct {
- char *config;
-} NMSettingTeamPortPrivate;
-
-enum {
- PROP_0,
- PROP_CONFIG,
- LAST_PROP
-};
-
-/**
- * nm_setting_team_port_new:
- *
- * Creates a new #NMSettingTeamPort object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingTeamPort object
- *
- * Since: 0.9.10
- **/
-NMSetting *
-nm_setting_team_port_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_TEAM_PORT, NULL);
-}
-
-/**
- * nm_setting_team_port_get_config:
- * @setting: the #NMSettingTeamPort
- *
- * Returns: the #NMSettingTeamPort:config property of the setting
- *
- * Since: 0.9.10
- **/
-const char *
-nm_setting_team_port_get_config (NMSettingTeamPort *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), NULL);
-
- return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->config;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- return TRUE;
-}
-
-static void
-nm_setting_team_port_init (NMSettingTeamPort *setting)
-{
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_CONFIG:
- g_free (priv->config);
- priv->config = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT (object);
-
- switch (prop_id) {
- case PROP_CONFIG:
- g_value_set_string (value, nm_setting_team_port_get_config (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (object);
-
- g_free (priv->config);
-
- G_OBJECT_CLASS (nm_setting_team_port_parent_class)->finalize (object);
-}
-
-static void
-nm_setting_team_port_class_init (NMSettingTeamPortClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingTeamPortPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingTeamPort:config:
- *
- * The JSON configuration for the team port. The property should contain raw
- * JSON configuration data suitable for teamd, because the value is passed
- * directly to teamd. If not specified, the default configuration is
- * used. See man teamd.conf for the format details.
- **/
- g_object_class_install_property
- (object_class, PROP_CONFIG,
- g_param_spec_string (NM_SETTING_TEAM_PORT_CONFIG, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-team-port.h b/libnm-util/nm-setting-team-port.h
deleted file mode 100644
index 2da6518b7a..0000000000
--- a/libnm-util/nm-setting-team-port.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Jiri Pirko <jiri@resnulli.us>
- */
-
-#ifndef NM_SETTING_TEAM_PORT_H
-#define NM_SETTING_TEAM_PORT_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_TEAM_PORT (nm_setting_team_port_get_type ())
-#define NM_SETTING_TEAM_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPort))
-#define NM_SETTING_TEAM_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortClass))
-#define NM_IS_SETTING_TEAM_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_TEAM_PORT))
-#define NM_IS_SETTING_TEAM_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_TEAM_PORT))
-#define NM_SETTING_TEAM_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortClass))
-
-#define NM_SETTING_TEAM_PORT_SETTING_NAME "team-port"
-
-/**
- * NMSettingTeamPortError:
- * @NM_SETTING_TEAM_PORT_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_TEAM_PORT_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_TEAM_PORT_ERROR_MISSING_PROPERTY: the property was missing and
- * is required
- */
-typedef enum {
- NM_SETTING_TEAM_PORT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_TEAM_PORT_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_TEAM_PORT_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
-} NMSettingTeamPortError;
-
-#define NM_SETTING_TEAM_PORT_ERROR nm_setting_team_port_error_quark ()
-GQuark nm_setting_team_port_error_quark (void);
-
-#define NM_SETTING_TEAM_PORT_CONFIG "config"
-
-typedef struct {
- NMSetting parent;
-} NMSettingTeamPort;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingTeamPortClass;
-
-NM_AVAILABLE_IN_0_9_10
-GType nm_setting_team_port_get_type (void);
-
-NM_AVAILABLE_IN_0_9_10
-NMSetting * nm_setting_team_port_new (void);
-
-const char * nm_setting_team_port_get_config (NMSettingTeamPort *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_TEAM_PORT_H */
diff --git a/libnm-util/nm-setting-team.c b/libnm-util/nm-setting-team.c
deleted file mode 100644
index 0ec40320c6..0000000000
--- a/libnm-util/nm-setting-team.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Jiri Pirko <jiri@resnulli.us>
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-team.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-team
- * @short_description: Describes connection properties for teams
- * @include: nm-setting-team.h
- *
- * The #NMSettingTeam object is a #NMSetting subclass that describes properties
- * necessary for team connections.
- *
- * Since: 0.9.10
- **/
-
-/**
- * nm_setting_team_error_quark:
- *
- * Registers an error quark for #NMSettingTeam if necessary.
- *
- * Returns: the error quark used for #NMSettingTeam errors.
- *
- * Since: 0.9.10
- **/
-GQuark
-nm_setting_team_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-team-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingTeam, nm_setting_team, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_TEAM_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_TEAM_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM)
-
-#define NM_SETTING_TEAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM, NMSettingTeamPrivate))
-
-typedef struct {
- char *interface_name;
- char *config;
-} NMSettingTeamPrivate;
-
-enum {
- PROP_0,
- PROP_INTERFACE_NAME,
- PROP_CONFIG,
- LAST_PROP
-};
-
-/**
- * nm_setting_team_new:
- *
- * Creates a new #NMSettingTeam object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingTeam object
- *
- * Since: 0.9.10
- **/
-NMSetting *
-nm_setting_team_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_TEAM, NULL);
-}
-
-/**
- * nm_setting_team_get_interface_name:
- * @setting: the #NMSettingTeam
- *
- * Returns: the #NMSettingTeam:interface-name property of the setting
- *
- * Since: 0.9.10
- **/
-const char *
-nm_setting_team_get_interface_name (NMSettingTeam *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
-
- return NM_SETTING_TEAM_GET_PRIVATE (setting)->interface_name;
-}
-
-/**
- * nm_setting_team_get_config:
- * @setting: the #NMSettingTeam
- *
- * Returns: the #NMSettingTeam:config property of the setting
- *
- * Since: 0.9.10
- **/
-const char *
-nm_setting_team_get_config (NMSettingTeam *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
-
- return NM_SETTING_TEAM_GET_PRIVATE (setting)->config;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
-
- return _nm_setting_verify_deprecated_virtual_iface_name (
- priv->interface_name, FALSE,
- NM_SETTING_TEAM_SETTING_NAME, NM_SETTING_TEAM_INTERFACE_NAME,
- NM_SETTING_TEAM_ERROR,
- NM_SETTING_TEAM_ERROR_INVALID_PROPERTY,
- NM_SETTING_TEAM_ERROR_MISSING_PROPERTY,
- all_settings, error);
-}
-
-static const char *
-get_virtual_iface_name (NMSetting *setting)
-{
- NMSettingTeam *self = NM_SETTING_TEAM (setting);
-
- return nm_setting_team_get_interface_name (self);
-}
-
-static void
-nm_setting_team_init (NMSettingTeam *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (object);
-
- g_free (priv->interface_name);
- g_free (priv->config);
-
- G_OBJECT_CLASS (nm_setting_team_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_INTERFACE_NAME:
- g_free (priv->interface_name);
- priv->interface_name = g_value_dup_string (value);
- break;
- case PROP_CONFIG:
- g_free (priv->config);
- priv->config = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingTeam *setting = NM_SETTING_TEAM (object);
-
- switch (prop_id) {
- case PROP_INTERFACE_NAME:
- g_value_set_string (value, nm_setting_team_get_interface_name (setting));
- break;
- case PROP_CONFIG:
- g_value_set_string (value, nm_setting_team_get_config (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_team_class_init (NMSettingTeamClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingTeamPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->get_virtual_iface_name = get_virtual_iface_name;
-
- /* Properties */
- /**
- * NMSettingTeam:interface-name:
- *
- * The name of the virtual in-kernel team network interface
- **/
- g_object_class_install_property
- (object_class, PROP_INTERFACE_NAME,
- g_param_spec_string (NM_SETTING_TEAM_INTERFACE_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingTeam:config:
- *
- * The JSON configuration for the team network interface. The property
- * should contain raw JSON configuration data suitable for teamd, because
- * the value is passed directly to teamd. If not specified, the default
- * configuration is used. See man teamd.conf for the format details.
- **/
- g_object_class_install_property
- (object_class, PROP_CONFIG,
- g_param_spec_string (NM_SETTING_TEAM_CONFIG, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-team.h b/libnm-util/nm-setting-team.h
deleted file mode 100644
index 87aa769506..0000000000
--- a/libnm-util/nm-setting-team.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Jiri Pirko <jiri@resnulli.us>
- */
-
-#ifndef NM_SETTING_TEAM_H
-#define NM_SETTING_TEAM_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_TEAM (nm_setting_team_get_type ())
-#define NM_SETTING_TEAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_TEAM, NMSettingTeam))
-#define NM_SETTING_TEAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_TEAM, NMSettingTeamClass))
-#define NM_IS_SETTING_TEAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_TEAM))
-#define NM_IS_SETTING_TEAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_TEAM))
-#define NM_SETTING_TEAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_TEAM, NMSettingTeamClass))
-
-#define NM_SETTING_TEAM_SETTING_NAME "team"
-
-/**
- * NMSettingTeamError:
- * @NM_SETTING_TEAM_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_TEAM_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_TEAM_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum {
- NM_SETTING_TEAM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_TEAM_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_TEAM_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
-} NMSettingTeamError;
-
-#define NM_SETTING_TEAM_ERROR nm_setting_team_error_quark ()
-GQuark nm_setting_team_error_quark (void);
-
-#define NM_SETTING_TEAM_INTERFACE_NAME "interface-name"
-#define NM_SETTING_TEAM_CONFIG "config"
-
-typedef struct {
- NMSetting parent;
-} NMSettingTeam;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingTeamClass;
-
-NM_AVAILABLE_IN_0_9_10
-GType nm_setting_team_get_type (void);
-
-NM_AVAILABLE_IN_0_9_10
-NMSetting * nm_setting_team_new (void);
-
-const char * nm_setting_team_get_interface_name (NMSettingTeam *setting);
-const char * nm_setting_team_get_config (NMSettingTeam *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_TEAM_H */
diff --git a/libnm-util/nm-setting-vlan.c b/libnm-util/nm-setting-vlan.c
deleted file mode 100644
index f835e07f4c..0000000000
--- a/libnm-util/nm-setting-vlan.c
+++ /dev/null
@@ -1,852 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2014 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-vlan.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-vlan
- * @short_description: Describes connection properties for VLAN interfaces
- * @include: nm-setting-vlan.h
- *
- * The #NMSettingVlan object is a #NMSetting subclass that describes properties
- * necessary for connection to VLAN interfaces.
- **/
-
-/**
- * nm_setting_vlan_error_quark:
- *
- * Registers an error quark for #NMSettingVlan if necessary.
- *
- * Returns: the error quark used for #NMSettingVlan errors.
- **/
-GQuark
-nm_setting_vlan_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-vlan-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingVlan, nm_setting_vlan, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_VLAN_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_VLAN_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VLAN)
-
-#define NM_SETTING_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VLAN, NMSettingVlanPrivate))
-
-typedef struct {
- char *interface_name;
- char *parent;
- guint32 id;
- guint32 flags;
- GSList *ingress_priority_map;
- GSList *egress_priority_map;
-} NMSettingVlanPrivate;
-
-enum {
- PROP_0,
- PROP_INTERFACE_NAME,
- PROP_PARENT,
- PROP_ID,
- PROP_FLAGS,
- PROP_INGRESS_PRIORITY_MAP,
- PROP_EGRESS_PRIORITY_MAP,
- LAST_PROP
-};
-
-#define MAX_SKB_PRIO G_MAXUINT32
-#define MAX_8021P_PRIO 7 /* Max 802.1p priority */
-
-typedef struct {
- guint32 from;
- guint32 to;
-} PriorityMap;
-
-/**
- * nm_setting_vlan_new:
- *
- * Creates a new #NMSettingVlan object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingVlan object
- **/
-NMSetting *
-nm_setting_vlan_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_VLAN, NULL);
-}
-
-/**
- * nm_setting_vlan_get_interface_name:
- * @setting: the #NMSettingVlan
- *
- * Returns: the #NMSettingVlan:interface_name property of the setting
- **/
-const char *
-nm_setting_vlan_get_interface_name (NMSettingVlan *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), NULL);
- return NM_SETTING_VLAN_GET_PRIVATE (setting)->interface_name;
-}
-
-/**
- * nm_setting_vlan_get_parent:
- * @setting: the #NMSettingVlan
- *
- * Returns: the #NMSettingVlan:parent property of the setting
- **/
-const char *
-nm_setting_vlan_get_parent (NMSettingVlan *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), NULL);
- return NM_SETTING_VLAN_GET_PRIVATE (setting)->parent;
-}
-
-/**
- * nm_setting_vlan_get_id:
- * @setting: the #NMSettingVlan
- *
- * Returns: the #NMSettingVlan:id property of the setting
- **/
-guint32
-nm_setting_vlan_get_id (NMSettingVlan *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), 0);
- return NM_SETTING_VLAN_GET_PRIVATE (setting)->id;
-}
-
-/**
- * nm_setting_vlan_get_flags:
- * @setting: the #NMSettingVlan
- *
- * Returns: the #NMSettingVlan:flags property of the setting
- **/
-guint32
-nm_setting_vlan_get_flags (NMSettingVlan *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), 0);
- return NM_SETTING_VLAN_GET_PRIVATE (setting)->flags;
-}
-
-static guint32
-get_max_prio (NMVlanPriorityMap map, gboolean from)
-{
- if (map == NM_VLAN_INGRESS_MAP)
- return from ? MAX_8021P_PRIO : MAX_SKB_PRIO;
- else if (map == NM_VLAN_EGRESS_MAP)
- return from ? MAX_SKB_PRIO : MAX_8021P_PRIO;
- g_assert_not_reached ();
-}
-
-static PriorityMap *
-priority_map_new_from_str (NMVlanPriorityMap map, const char *str)
-{
- PriorityMap *p = NULL;
- char **t = NULL;
- guint32 len;
- guint64 from, to;
-
- g_return_val_if_fail (str && str[0], NULL);
-
- t = g_strsplit (str, ":", 0);
- len = g_strv_length (t);
- if (len == 2) {
- from = g_ascii_strtoull (t[0], NULL, 10);
- to = g_ascii_strtoull (t[1], NULL, 10);
-
- if ((from <= get_max_prio (map, TRUE)) && (to <= get_max_prio (map, FALSE))) {
- p = g_malloc0 (sizeof (PriorityMap));
- p->from = from;
- p->to = to;
- }
- } else {
- /* Warn */
- g_warn_if_fail (len == 2);
- }
-
- g_strfreev (t);
- return p;
-}
-
-static void
-priority_map_free (PriorityMap *map)
-{
- g_return_if_fail (map != NULL);
- g_free (map);
-}
-
-static GSList *
-get_map (NMSettingVlan *self, NMVlanPriorityMap map)
-{
- if (map == NM_VLAN_INGRESS_MAP)
- return NM_SETTING_VLAN_GET_PRIVATE (self)->ingress_priority_map;
- else if (map == NM_VLAN_EGRESS_MAP)
- return NM_SETTING_VLAN_GET_PRIVATE (self)->egress_priority_map;
- g_assert_not_reached ();
- return NULL;
-}
-
-static void
-set_map (NMSettingVlan *self, NMVlanPriorityMap map, GSList *list)
-{
- if (map == NM_VLAN_INGRESS_MAP) {
- NM_SETTING_VLAN_GET_PRIVATE (self)->ingress_priority_map = list;
- g_object_notify (G_OBJECT (self), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP);
- } else if (map == NM_VLAN_EGRESS_MAP) {
- NM_SETTING_VLAN_GET_PRIVATE (self)->egress_priority_map = list;
- g_object_notify (G_OBJECT (self), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP);
- } else
- g_assert_not_reached ();
-}
-
-/**
- * nm_setting_vlan_add_priority_str:
- * @setting: the #NMSettingVlan
- * @map: the type of priority map
- * @str: the string which contains a priority map, like "3:7"
- *
- * Adds a priority map entry into either the #NMSettingVlan:ingress_priority_map
- * or the #NMSettingVlan:egress_priority_map properties. The priority map maps
- * the Linux SKB priorities to 802.1p priorities.
- *
- * Returns: %TRUE if the entry was successfully added to the list, or it
- * overwrote the old value, %FALSE if error
- */
-gboolean
-nm_setting_vlan_add_priority_str (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- const char *str)
-{
- GSList *list = NULL, *iter = NULL;
- PriorityMap *item = NULL;
-
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
- g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
- g_return_val_if_fail (str && str[0], FALSE);
-
- list = get_map (setting, map);
-
- item = priority_map_new_from_str (map, str);
- if (!item)
- g_return_val_if_reached (FALSE);
-
- /* Duplicates get replaced */
- for (iter = list; iter; iter = g_slist_next (iter)) {
- PriorityMap *p = iter->data;
-
- if (p->from == item->from) {
- p->to = item->to;
- g_free (item);
- if (map == NM_VLAN_INGRESS_MAP)
- g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP);
- else
- g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP);
- return TRUE;
- }
- }
-
- set_map (setting, map, g_slist_append (list, item));
- return TRUE;
-}
-
-/**
- * nm_setting_vlan_get_num_priorities:
- * @setting: the #NMSettingVlan
- * @map: the type of priority map
- *
- * Returns the number of entries in the
- * #NMSettingVlan:ingress_priority_map or #NMSettingVlan:egress_priority_map
- * properties of this setting.
- *
- * Returns: return the number of ingress/egress priority entries, -1 if error
- **/
-gint32
-nm_setting_vlan_get_num_priorities (NMSettingVlan *setting, NMVlanPriorityMap map)
-{
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), -1);
- g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, -1);
-
- return g_slist_length (get_map (setting, map));
-}
-
-/**
- * nm_setting_vlan_get_priority:
- * @setting: the #NMSettingVlan
- * @map: the type of priority map
- * @idx: the zero-based index of the ingress/egress priority map entry
- * @out_from: (out): on return the value of the priority map's 'from' item
- * @out_to: (out): on return the value of priority map's 'to' item
- *
- * Retrieve one of the entries of the #NMSettingVlan:ingress_priority_map
- * or #NMSettingVlan:egress_priority_map properties of this setting.
- *
- * Returns: %TRUE if a priority map was returned, %FALSE if error
- **/
-gboolean
-nm_setting_vlan_get_priority (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- guint32 idx,
- guint32 *out_from,
- guint32 *out_to)
-{
- GSList *list = NULL;
- PriorityMap *item = NULL;
-
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
- g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
- g_return_val_if_fail (out_from != NULL, FALSE);
- g_return_val_if_fail (out_to != NULL, FALSE);
-
- list = get_map (setting, map);
- g_return_val_if_fail (idx < g_slist_length (list), FALSE);
-
- item = g_slist_nth_data (list, idx);
- g_assert (item);
- *out_from = item->from;
- *out_to = item->to;
- return TRUE;
-}
-
-/**
- * nm_setting_vlan_add_priority:
- * @setting: the #NMSettingVlan
- * @map: the type of priority map
- * @from: the priority to map to @to
- * @to: the priority to map @from to
- *
- * Adds a priority mapping to the #NMSettingVlan:ingress_priority_map or
- * #NMSettingVlan:egress_priority_map properties of the setting. If @from is
- * already in the given priority map, this function will overwrite the
- * existing entry with the new @to.
- *
- * If @map is #NM_VLAN_INGRESS_MAP then @from is the incoming 802.1q VLAN
- * Priority Code Point (PCP) value, and @to is the Linux SKB priority value.
- *
- * If @map is #NM_VLAN_EGRESS_MAP then @from is the Linux SKB priority value and
- * @to is the outgoing 802.1q VLAN Priority Code Point (PCP) value.
- *
- * Returns: %TRUE if the new priority mapping was successfully added to the
- * list, %FALSE if error
- */
-gboolean
-nm_setting_vlan_add_priority (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- guint32 from,
- guint32 to)
-{
- GSList *list = NULL, *iter = NULL;
- PriorityMap *item;
-
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
- g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
-
- list = get_map (setting, map);
- for (iter = list; iter; iter = g_slist_next (iter)) {
- item = iter->data;
- if (item->from == from) {
- item->to = to;
- if (map == NM_VLAN_INGRESS_MAP)
- g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP);
- else
- g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP);
- return TRUE;
- }
- }
-
- item = g_malloc0 (sizeof (PriorityMap));
- item->from = from;
- item->to = to;
- set_map (setting, map, g_slist_append (list, item));
-
- return TRUE;
-}
-
-/**
- * nm_setting_vlan_remove_priority:
- * @setting: the #NMSettingVlan
- * @map: the type of priority map
- * @idx: the zero-based index of the priority map to remove
- *
- * Removes the priority map at index @idx from the
- * #NMSettingVlan:ingress_priority_map or #NMSettingVlan:egress_priority_map
- * properties.
- */
-void
-nm_setting_vlan_remove_priority (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- guint32 idx)
-{
- GSList *list = NULL, *item = NULL;
-
- g_return_if_fail (NM_IS_SETTING_VLAN (setting));
- g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP);
-
- list = get_map (setting, map);
- g_return_if_fail (idx < g_slist_length (list));
-
- item = g_slist_nth (list, idx);
- priority_map_free ((PriorityMap *) (item->data));
- set_map (setting, map, g_slist_delete_link (list, item));
-}
-
-/**
- * nm_setting_vlan_remove_priority_by_value:
- * @setting: the #NMSettingVlan
- * @map: the type of priority map
- * @from: the priority to map to @to
- * @to: the priority to map @from to
- *
- * Removes the priority map @form:@to from the #NMSettingVlan:ingress_priority_map
- * or #NMSettingVlan:egress_priority_map (according to @map argument)
- * properties.
- *
- * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- */
-gboolean
-nm_setting_vlan_remove_priority_by_value (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- guint32 from,
- guint32 to)
-{
- GSList *list = NULL, *iter = NULL;
- PriorityMap *item;
-
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
- g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
-
- list = get_map (setting, map);
- for (iter = list; iter; iter = g_slist_next (iter)) {
- item = iter->data;
- if (item->from == from && item->to == to) {
- priority_map_free ((PriorityMap *) (iter->data));
- set_map (setting, map, g_slist_delete_link (list, iter));
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_vlan_remove_priority_str_by_value:
- * @setting: the #NMSettingVlan
- * @map: the type of priority map
- * @str: the string which contains a priority map, like "3:7"
- *
- * Removes the priority map @str from the #NMSettingVlan:ingress_priority_map
- * or #NMSettingVlan:egress_priority_map (according to @map argument)
- * properties.
- *
- * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- */
-gboolean
-nm_setting_vlan_remove_priority_str_by_value (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- const char *str)
-{
- PriorityMap *item;
- gboolean found;
-
- g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
- g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
-
- item = priority_map_new_from_str (map, str);
- if (!item)
- return FALSE;
-
- found = nm_setting_vlan_remove_priority_by_value (setting, map, item->from, item->to);
- g_free (item);
- return found;
-}
-
-/**
- * nm_setting_vlan_clear_priorities:
- * @setting: the #NMSettingVlan
- * @map: the type of priority map
- *
- * Clear all the entries from #NMSettingVlan:ingress_priority_map or
- * #NMSettingVlan:egress_priority_map properties.
- */
-void
-nm_setting_vlan_clear_priorities (NMSettingVlan *setting, NMVlanPriorityMap map)
-{
- GSList *list = NULL;
-
- g_return_if_fail (NM_IS_SETTING_VLAN (setting));
- g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP);
-
- list = get_map (setting, map);
- g_slist_free_full (list, g_free);
- set_map (setting, map, NULL);
-}
-
-/*****************************************************************************/
-
-static void
-nm_setting_vlan_init (NMSettingVlan *setting)
-{
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
- NMSettingConnection *s_con = NULL;
- NMSettingWired *s_wired = NULL;
- GSList *iter;
-
- for (iter = all_settings; iter; iter = iter->next) {
- if (NM_IS_SETTING_CONNECTION (iter->data))
- s_con = iter->data;
- else if (NM_IS_SETTING_WIRED (iter->data))
- s_wired = iter->data;
- }
-
- if (priv->parent) {
- if (nm_utils_is_uuid (priv->parent)) {
- /* If we have an NMSettingConnection:master with slave-type="vlan",
- * then it must be the same UUID.
- */
- if (s_con) {
- const char *master = NULL, *slave_type = NULL;
-
- slave_type = nm_setting_connection_get_slave_type (s_con);
- if (!g_strcmp0 (slave_type, NM_SETTING_VLAN_SETTING_NAME))
- master = nm_setting_connection_get_master (s_con);
-
- if (master && g_strcmp0 (priv->parent, master) != 0) {
- g_set_error (error,
- NM_SETTING_VLAN_ERROR,
- NM_SETTING_VLAN_ERROR_INVALID_PARENT,
- _("'%s' value doesn't match '%s=%s'"),
- priv->parent, NM_SETTING_CONNECTION_MASTER, master);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT);
- return FALSE;
- }
- }
- } else if (!nm_utils_iface_valid_name (priv->parent)) {
- /* parent must be either a UUID or an interface name */
- g_set_error (error,
- NM_SETTING_VLAN_ERROR,
- NM_SETTING_VLAN_ERROR_INVALID_PROPERTY,
- _("'%s' is neither an UUID nor an interface name"),
- priv->parent);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT);
- return FALSE;
- }
- } else {
- /* If parent is NULL, the parent must be specified via
- * NMSettingWired:mac-address.
- */
- if (!s_wired || !nm_setting_wired_get_mac_address (s_wired)) {
- g_set_error (error,
- NM_SETTING_VLAN_ERROR,
- NM_SETTING_VLAN_ERROR_MISSING_PROPERTY,
- _("property is not specified and neither is '%s:%s'"),
- NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT);
- return FALSE;
- }
- }
-
- if (priv->flags & ~NM_VLAN_FLAGS_ALL) {
- g_set_error_literal (error,
- NM_SETTING_VLAN_ERROR,
- NM_SETTING_VLAN_ERROR_INVALID_PROPERTY,
- _("flags are invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_FLAGS);
- return FALSE;
- }
-
- if (priv->id >= 4095) {
- g_set_error (error,
- NM_SETTING_VLAN_ERROR,
- NM_SETTING_VLAN_ERROR_INVALID_PROPERTY,
- _("the vlan id must be in range 0-4094 but is %u"),
- priv->id);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_ID);
- return FALSE;
- }
-
- /* If interface_name is specified, it must be a valid interface name. We
- * don't check that it matches parent and/or id, because we allow
- * renaming vlans to arbitrary names.
- */
- return _nm_setting_verify_deprecated_virtual_iface_name (
- priv->interface_name, TRUE,
- NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_INTERFACE_NAME,
- NM_SETTING_VLAN_ERROR,
- NM_SETTING_VLAN_ERROR_INVALID_PROPERTY,
- NM_SETTING_VLAN_ERROR_MISSING_PROPERTY,
- all_settings, error);
-}
-
-static const char *
-get_virtual_iface_name (NMSetting *setting)
-{
- return nm_setting_vlan_get_interface_name (NM_SETTING_VLAN (setting));
-}
-
-static GSList *
-priority_stringlist_to_maplist (NMVlanPriorityMap map, GSList *strlist)
-{
- GSList *list = NULL, *iter;
-
- for (iter = strlist; iter; iter = g_slist_next (iter)) {
- PriorityMap *item;
-
- item = priority_map_new_from_str (map, (const char *) iter->data);
- if (item)
- list = g_slist_prepend (list, item);
- }
- return g_slist_reverse (list);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingVlan *setting = NM_SETTING_VLAN (object);
- NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_INTERFACE_NAME:
- g_free (priv->interface_name);
- priv->interface_name = g_value_dup_string (value);
- break;
- case PROP_PARENT:
- g_free (priv->parent);
- priv->parent = g_value_dup_string (value);
- break;
- case PROP_ID:
- priv->id = g_value_get_uint (value);
- break;
- case PROP_FLAGS:
- priv->flags = g_value_get_uint (value);
- break;
- case PROP_INGRESS_PRIORITY_MAP:
- g_slist_free_full (priv->ingress_priority_map, g_free);
- priv->ingress_priority_map =
- priority_stringlist_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value));
- break;
- case PROP_EGRESS_PRIORITY_MAP:
- g_slist_free_full (priv->egress_priority_map, g_free);
- priv->egress_priority_map =
- priority_stringlist_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GSList *
-priority_maplist_to_stringlist (GSList *list)
-{
- GSList *strlist = NULL, *iter;
-
- for (iter = list; iter; iter = g_slist_next (iter)) {
- PriorityMap *item = iter->data;
-
- strlist = g_slist_prepend (strlist, g_strdup_printf ("%d:%d", item->from, item->to));
- }
- return g_slist_reverse (strlist);
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingVlan *setting = NM_SETTING_VLAN (object);
- NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_INTERFACE_NAME:
- g_value_set_string (value, priv->interface_name);
- break;
- case PROP_PARENT:
- g_value_set_string (value, priv->parent);
- break;
- case PROP_ID:
- g_value_set_uint (value, priv->id);
- break;
- case PROP_FLAGS:
- g_value_set_uint (value, priv->flags);
- break;
- case PROP_INGRESS_PRIORITY_MAP:
- g_value_take_boxed (value, priority_maplist_to_stringlist (priv->ingress_priority_map));
- break;
- case PROP_EGRESS_PRIORITY_MAP:
- g_value_take_boxed (value, priority_maplist_to_stringlist (priv->egress_priority_map));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingVlan *setting = NM_SETTING_VLAN (object);
- NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
-
- g_free (priv->interface_name);
- g_free (priv->parent);
- g_slist_free_full (priv->ingress_priority_map, g_free);
- g_slist_free_full (priv->egress_priority_map, g_free);
-
- G_OBJECT_CLASS (nm_setting_vlan_parent_class)->finalize (object);
-}
-
-static void
-nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingVlanPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
- parent_class->get_virtual_iface_name = get_virtual_iface_name;
-
- /* Properties */
-
- /**
- * NMSettingVlan:interface-name:
- *
- * If given, specifies the kernel name of the VLAN interface. If not given,
- * a default name will be constructed from the interface described by the
- * parent interface and the #NMSettingVlan:id property, eg "eth2.1". The
- * parent interface may be given by the #NMSettingVlan:parent property or by
- * the #NMSettingWired:mac-address property of an #NMSettingWired setting.
- **/
- g_object_class_install_property
- (object_class, PROP_INTERFACE_NAME,
- g_param_spec_string (NM_SETTING_VLAN_INTERFACE_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVlan:parent:
- *
- * If given, specifies the parent interface name or parent connection UUID
- * from which this VLAN interface should be created. If this property is
- * not specified, the connection must contain an #NMSettingWired setting
- * with a #NMSettingWired:mac-address property.
- **/
- g_object_class_install_property
- (object_class, PROP_PARENT,
- g_param_spec_string (NM_SETTING_VLAN_PARENT, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVlan:id:
- *
- * The VLAN identifier that the interface created by this connection should
- * be assigned.
- **/
- g_object_class_install_property
- (object_class, PROP_ID,
- g_param_spec_uint (NM_SETTING_VLAN_ID, "", "",
- 0, 4095, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVlan:flags:
- *
- * One or more flags which control the behavior and features of the VLAN
- * interface. Flags include %NM_VLAN_FLAG_REORDER_HEADERS (reordering of
- * output packet headers), %NM_VLAN_FLAG_GVRP (use of the GVRP protocol),
- * and %NM_VLAN_FLAG_LOOSE_BINDING (loose binding of the interface to its
- * master device's operating state), %NM_VLAN_FLAG_MVRP (use of the MVRP
- * protocol).
- **/
- g_object_class_install_property
- (object_class, PROP_FLAGS,
- g_param_spec_uint (NM_SETTING_VLAN_FLAGS, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVlan:ingress-priority-map:
- *
- * For incoming packets, a list of mappings from 802.1p priorities to Linux
- * SKB priorities. The mapping is given in the format "from:to" where both
- * "from" and "to" are unsigned integers, ie "7:3".
- **/
- g_object_class_install_property
- (object_class, PROP_INGRESS_PRIORITY_MAP,
- _nm_param_spec_specialized (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVlan:egress-priority-map:
- *
- * For outgoing packets, a list of mappings from Linux SKB priorities to
- * 802.1p priorities. The mapping is given in the format "from:to" where
- * both "from" and "to" are unsigned integers, ie "7:3".
- **/
- g_object_class_install_property
- (object_class, PROP_EGRESS_PRIORITY_MAP,
- _nm_param_spec_specialized (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-vlan.h b/libnm-util/nm-setting-vlan.h
deleted file mode 100644
index ce42dd4154..0000000000
--- a/libnm-util/nm-setting-vlan.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2014 Red Hat, Inc.
- */
-
-#ifndef NM_SETTING_VLAN_H
-#define NM_SETTING_VLAN_H
-
-#include "nm-setting.h"
-#include <linux/if_vlan.h>
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_VLAN (nm_setting_vlan_get_type ())
-#define NM_SETTING_VLAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_VLAN, NMSettingVlan))
-#define NM_SETTING_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_VLANCONFIG, NMSettingVlanClass))
-#define NM_IS_SETTING_VLAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_VLAN))
-#define NM_IS_SETTING_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_VLAN))
-#define NM_SETTING_VLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_VLAN, NMSettingVlanClass))
-
-#define NM_SETTING_VLAN_SETTING_NAME "vlan"
-
-/**
- * NMSettingVlanError:
- * @NM_SETTING_VLAN_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_VLAN_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_VLAN_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_VLAN_ERROR_INVALID_PARENT: the VLAN parent was specified
- * inconsistently
- */
-typedef enum {
- NM_SETTING_VLAN_ERROR_UNKNOWN = 0, /*< nick=Unknown >*/
- NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_VLAN_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_VLAN_ERROR_INVALID_PARENT /*< nick=InvalidParent >*/
-} NMSettingVlanError;
-
-#define NM_SETTING_VLAN_ERROR nm_setting_vlan_error_quark ()
-GQuark nm_setting_vlan_error_quark (void);
-
-#define NM_SETTING_VLAN_INTERFACE_NAME "interface-name"
-#define NM_SETTING_VLAN_PARENT "parent"
-#define NM_SETTING_VLAN_ID "id"
-#define NM_SETTING_VLAN_FLAGS "flags"
-#define NM_SETTING_VLAN_INGRESS_PRIORITY_MAP "ingress-priority-map"
-#define NM_SETTING_VLAN_EGRESS_PRIORITY_MAP "egress-priority-map"
-
-typedef struct {
- NMSetting parent;
-} NMSettingVlan;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingVlanClass;
-
-/**
- * NMVlanPriorityMap:
- * @NM_VLAN_INGRESS_MAP: map for incoming data
- * @NM_VLAN_EGRESS_MAP: map for outgoing data
- *
- * A selector for traffic priority maps; these map Linux SKB priorities
- * to 802.1p priorities used in VLANs.
- **/
-typedef enum {
- NM_VLAN_INGRESS_MAP,
- NM_VLAN_EGRESS_MAP
-} NMVlanPriorityMap;
-
-/**
- * NMVlanFlags:
- * @NM_VLAN_FLAG_REORDER_HEADERS: indicates that this interface should reorder
- * outgoing packet headers to look more like a non-VLAN Ethernet interface
- * @NM_VLAN_FLAG_GVRP: indicates that this interface should use GVRP to register
- * itself with it's switch
- * @NM_VLAN_FLAG_LOOSE_BINDING: indicates that this interface's operating
- * state is tied to the underlying network interface but other details
- * (like routing) are not.
- * @NM_VLAN_FLAG_MVRP: indicates that this interface should use MVRP to register
- * itself with it's switch
- *
- * #NMVlanFlags values control the behavior of the VLAN interface.
- **/
-typedef enum {
- NM_VLAN_FLAG_REORDER_HEADERS = 0x1,
- NM_VLAN_FLAG_GVRP = 0x2,
- NM_VLAN_FLAG_LOOSE_BINDING = 0x4,
- NM_VLAN_FLAG_MVRP = 0x8,
-
- /* NOTE: if adding flags update nm-setting-vlan.c::verify() */
-} NMVlanFlags;
-
-#define NM_VLAN_FLAGS_ALL (NM_VLAN_FLAG_REORDER_HEADERS | \
- NM_VLAN_FLAG_GVRP | \
- NM_VLAN_FLAG_LOOSE_BINDING | \
- NM_VLAN_FLAG_MVRP)
-
-GType nm_setting_vlan_get_type (void);
-NMSetting *nm_setting_vlan_new (void);
-
-const char *nm_setting_vlan_get_interface_name (NMSettingVlan *setting);
-const char *nm_setting_vlan_get_parent (NMSettingVlan *setting);
-guint32 nm_setting_vlan_get_id (NMSettingVlan *setting);
-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,
- NMVlanPriorityMap map,
- guint32 idx,
- guint32 *out_from,
- guint32 *out_to);
-
-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);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_vlan_remove_priority_by_value (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- guint32 from,
- guint32 to);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_vlan_remove_priority_str_by_value (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- const char *str);
-
-void nm_setting_vlan_clear_priorities (NMSettingVlan *setting, NMVlanPriorityMap map);
-
-gboolean nm_setting_vlan_add_priority_str (NMSettingVlan *setting,
- NMVlanPriorityMap map,
- const char *str);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_VLAN_H */
diff --git a/libnm-util/nm-setting-vpn.c b/libnm-util/nm-setting-vpn.c
deleted file mode 100644
index 626ba4ca84..0000000000
--- a/libnm-util/nm-setting-vpn.c
+++ /dev/null
@@ -1,922 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-vpn.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-vpn
- * @short_description: Describes connection properties for Virtual Private Networks
- * @include: nm-setting-vpn.h
- *
- * The #NMSettingVPN object is a #NMSetting subclass that describes properties
- * necessary for connection to Virtual Private Networks. NetworkManager uses
- * a plugin architecture to allow easier use of new VPN types, and this
- * setting abstracts the configuration for those plugins. Since the configuration
- * options are only known to the VPN plugins themselves, the VPN configuration
- * options are stored as key/value pairs of strings rather than GObject
- * properties.
- **/
-
-/**
- * nm_setting_vpn_error_quark:
- *
- * Registers an error quark for #NMSettingVPN if necessary.
- *
- * Returns: the error quark used for #NMSettingVPN errors.
- **/
-GQuark
-nm_setting_vpn_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-vpn-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingVPN, nm_setting_vpn, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_VPN_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_VPN_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VPN)
-
-#define NM_SETTING_VPN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VPN, NMSettingVPNPrivate))
-
-typedef struct {
- char *service_type;
-
- /* username of the user requesting this connection, thus
- * it's really only valid for user connections, and it also
- * should never be saved out to persistent config.
- */
- char *user_name;
-
- /* Whether the VPN stays up across link changes, until the user
- * explicitly disconnects it.
- */
- gboolean persistent;
-
- /* The hash table is created at setting object
- * init time and should not be replaced. It is
- * a char * -> char * mapping, and both the key
- * and value are owned by the hash table, and should
- * be allocated with functions whose value can be
- * freed with g_free(). Should not contain secrets.
- */
- GHashTable *data;
-
- /* The hash table is created at setting object
- * init time and should not be replaced. It is
- * a char * -> char * mapping, and both the key
- * and value are owned by the hash table, and should
- * be allocated with functions whose value can be
- * freed with g_free(). Should contain secrets only.
- */
- GHashTable *secrets;
-} NMSettingVPNPrivate;
-
-enum {
- PROP_0,
- PROP_SERVICE_TYPE,
- PROP_USER_NAME,
- PROP_PERSISTENT,
- PROP_DATA,
- PROP_SECRETS,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_vpn_new:
- *
- * Creates a new #NMSettingVPN object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingVPN object
- **/
-NMSetting *
-nm_setting_vpn_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_VPN, NULL);
-}
-
-/**
- * nm_setting_vpn_get_service_type:
- * @setting: the #NMSettingVPN
- *
- * Returns the service name of the VPN, which identifies the specific VPN
- * plugin that should be used to connect to this VPN.
- *
- * Returns: the VPN plugin's service name
- **/
-const char *
-nm_setting_vpn_get_service_type (NMSettingVPN *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), NULL);
-
- return NM_SETTING_VPN_GET_PRIVATE (setting)->service_type;
-}
-
-/**
- * nm_setting_vpn_get_user_name:
- * @setting: the #NMSettingVPN
- *
- * Returns: the #NMSettingVPN:user-name property of the setting
- **/
-const char *
-nm_setting_vpn_get_user_name (NMSettingVPN *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), NULL);
-
- return NM_SETTING_VPN_GET_PRIVATE (setting)->user_name;
-}
-
-/**
- * nm_setting_vpn_get_persistent:
- * @setting: the #NMSettingVPN
- *
- * Returns: the #NMSettingVPN:persistent property of the setting
- **/
-gboolean
-nm_setting_vpn_get_persistent (NMSettingVPN *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), FALSE);
-
- return NM_SETTING_VPN_GET_PRIVATE (setting)->persistent;
-}
-
-/**
- * nm_setting_vpn_get_num_data_items:
- * @setting: the #NMSettingVPN
- *
- * Gets number of key/value pairs of VPN configuration data.
- *
- * Returns: the number of VPN plugin specific configuration data items
- **/
-guint32
-nm_setting_vpn_get_num_data_items (NMSettingVPN *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), 0);
-
- return g_hash_table_size (NM_SETTING_VPN_GET_PRIVATE (setting)->data);
-}
-
-/**
- * nm_setting_vpn_add_data_item:
- * @setting: the #NMSettingVPN
- * @key: a name that uniquely identifies the given value @item
- * @item: the value to be referenced by @key
- *
- * Establishes a relationship between @key and @item internally in the
- * setting which may be retrieved later. Should not be used to store passwords
- * or other secrets, which is what nm_setting_vpn_add_secret() is for.
- **/
-void
-nm_setting_vpn_add_data_item (NMSettingVPN *setting,
- const char *key,
- const char *item)
-{
- g_return_if_fail (NM_IS_SETTING_VPN (setting));
- g_return_if_fail (key != NULL);
- g_return_if_fail (strlen (key) > 0);
- g_return_if_fail (item != NULL);
- g_return_if_fail (strlen (item) > 0);
-
- g_hash_table_insert (NM_SETTING_VPN_GET_PRIVATE (setting)->data,
- g_strdup (key), g_strdup (item));
- g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_DATA);
-}
-
-/**
- * nm_setting_vpn_get_data_item:
- * @setting: the #NMSettingVPN
- * @key: the name of the data item to retrieve
- *
- * Retrieves the data item of a key/value relationship previously established
- * by nm_setting_vpn_add_data_item().
- *
- * Returns: the data item, if any
- **/
-const char *
-nm_setting_vpn_get_data_item (NMSettingVPN *setting, const char *key)
-{
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), NULL);
-
- return (const char *) g_hash_table_lookup (NM_SETTING_VPN_GET_PRIVATE (setting)->data, key);
-}
-
-/**
- * nm_setting_vpn_remove_data_item:
- * @setting: the #NMSettingVPN
- * @key: the name of the data item to remove
- *
- * Deletes a key/value relationship previously established by
- * nm_setting_vpn_add_data_item().
- *
- * Returns: %TRUE if the data item was found and removed from the internal list,
- * %FALSE if it was not.
- **/
-gboolean
-nm_setting_vpn_remove_data_item (NMSettingVPN *setting, const char *key)
-{
- gboolean found;
-
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), FALSE);
-
- found = g_hash_table_remove (NM_SETTING_VPN_GET_PRIVATE (setting)->data, key);
- if (found)
- g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_DATA);
- return found;
-}
-
-static void
-foreach_item_helper (GHashTable *hash,
- NMVPNIterFunc func,
- gpointer user_data)
-{
- GList *keys, *liter;
- GSList *copied = NULL, *siter;
-
- g_return_if_fail (hash != NULL);
-
- /* Grab keys and copy them so that the callback func can modify
- * the hash table items if it wants to.
- */
- keys = g_hash_table_get_keys (hash);
- for (liter = keys; liter; liter = g_list_next (liter))
- copied = g_slist_prepend (copied, g_strdup (liter->data));
- copied = g_slist_reverse (copied);
- g_list_free (keys);
-
- for (siter = copied; siter; siter = g_slist_next (siter)) {
- gpointer value;
-
- value = g_hash_table_lookup (hash, siter->data);
- func (siter->data, value, user_data);
- }
-
- g_slist_free_full (copied, g_free);
-}
-
-/**
- * nm_setting_vpn_foreach_data_item:
- * @setting: a #NMSettingVPN
- * @func: (scope call): an user provided function
- * @user_data: data to be passed to @func
- *
- * Iterates all data items stored in this setting. It is safe to add, remove,
- * and modify data items inside @func, though any additions or removals made
- * during iteration will not be part of the iteration.
- */
-void
-nm_setting_vpn_foreach_data_item (NMSettingVPN *setting,
- NMVPNIterFunc func,
- gpointer user_data)
-{
- g_return_if_fail (NM_IS_SETTING_VPN (setting));
-
- foreach_item_helper (NM_SETTING_VPN_GET_PRIVATE (setting)->data, func, user_data);
-}
-
-/**
- * nm_setting_vpn_get_num_secrets:
- * @setting: the #NMSettingVPN
- *
- * Gets number of VPN plugin specific secrets in the setting.
- *
- * Returns: the number of VPN plugin specific secrets
- **/
-guint32
-nm_setting_vpn_get_num_secrets (NMSettingVPN *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), 0);
-
- return g_hash_table_size (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets);
-}
-
-/**
- * nm_setting_vpn_add_secret:
- * @setting: the #NMSettingVPN
- * @key: a name that uniquely identifies the given secret @secret
- * @secret: the secret to be referenced by @key
- *
- * Establishes a relationship between @key and @secret internally in the
- * setting which may be retrieved later.
- **/
-void
-nm_setting_vpn_add_secret (NMSettingVPN *setting,
- const char *key,
- const char *secret)
-{
- g_return_if_fail (NM_IS_SETTING_VPN (setting));
- g_return_if_fail (key != NULL);
- g_return_if_fail (strlen (key) > 0);
- g_return_if_fail (secret != NULL);
- g_return_if_fail (strlen (secret) > 0);
-
- g_hash_table_insert (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets,
- g_strdup (key), g_strdup (secret));
- g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
-}
-
-/**
- * nm_setting_vpn_get_secret:
- * @setting: the #NMSettingVPN
- * @key: the name of the secret to retrieve
- *
- * Retrieves the secret of a key/value relationship previously established
- * by nm_setting_vpn_add_secret().
- *
- * Returns: the secret, if any
- **/
-const char *
-nm_setting_vpn_get_secret (NMSettingVPN *setting, const char *key)
-{
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), NULL);
-
- return (const char *) g_hash_table_lookup (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets, key);
-}
-
-/**
- * nm_setting_vpn_remove_secret:
- * @setting: the #NMSettingVPN
- * @key: the name of the secret to remove
- *
- * Deletes a key/value relationship previously established by
- * nm_setting_vpn_add_secret().
- *
- * Returns: %TRUE if the secret was found and removed from the internal list,
- * %FALSE if it was not.
- **/
-gboolean
-nm_setting_vpn_remove_secret (NMSettingVPN *setting, const char *key)
-{
- gboolean found;
-
- g_return_val_if_fail (NM_IS_SETTING_VPN (setting), FALSE);
-
- found = g_hash_table_remove (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets, key);
- if (found)
- g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
- return found;
-}
-
-/**
- * nm_setting_vpn_foreach_secret:
- * @setting: a #NMSettingVPN
- * @func: (scope call): an user provided function
- * @user_data: data to be passed to @func
- *
- * Iterates all secrets stored in this setting. It is safe to add, remove,
- * and modify secrets inside @func, though any additions or removals made during
- * iteration will not be part of the iteration.
- */
-void
-nm_setting_vpn_foreach_secret (NMSettingVPN *setting,
- NMVPNIterFunc func,
- gpointer user_data)
-{
- g_return_if_fail (NM_IS_SETTING_VPN (setting));
-
- foreach_item_helper (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets, func, user_data);
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
-
- if (!priv->service_type) {
- g_set_error_literal (error,
- NM_SETTING_VPN_ERROR,
- NM_SETTING_VPN_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_SERVICE_TYPE);
- return FALSE;
- }
-
- if (!strlen (priv->service_type)) {
- g_set_error_literal (error,
- NM_SETTING_VPN_ERROR,
- NM_SETTING_VPN_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_SERVICE_TYPE);
- return FALSE;
- }
-
- /* default username can be NULL, but can't be zero-length */
- if (priv->user_name && !strlen (priv->user_name)) {
- g_set_error_literal (error,
- NM_SETTING_VPN_ERROR,
- NM_SETTING_VPN_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_USER_NAME);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static NMSettingUpdateSecretResult
-update_secret_string (NMSetting *setting,
- const char *key,
- const char *value,
- GError **error)
-{
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
-
- g_return_val_if_fail (key != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
- g_return_val_if_fail (value != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
-
- if (!value || !strlen (value)) {
- g_set_error (error, NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- "Secret %s was empty", key);
- return NM_SETTING_UPDATE_SECRET_ERROR;
- }
-
- if (g_strcmp0 (g_hash_table_lookup (priv->secrets, key), value) == 0)
- return NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
-
- g_hash_table_insert (priv->secrets, g_strdup (key), g_strdup (value));
- return NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED;
-}
-
-static NMSettingUpdateSecretResult
-update_secret_hash (NMSetting *setting,
- GHashTable *secrets,
- GError **error)
-{
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
- GHashTableIter iter;
- const char *name, *value;
- NMSettingUpdateSecretResult result = NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
-
- g_return_val_if_fail (secrets != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
-
- /* Make sure the items are valid */
- g_hash_table_iter_init (&iter, secrets);
- while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &value)) {
- if (!name || !strlen (name)) {
- g_set_error_literal (error, NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- "Secret name was empty");
- return NM_SETTING_UPDATE_SECRET_ERROR;
- }
-
- if (!value || !strlen (value)) {
- g_set_error (error, NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- "Secret %s value was empty", name);
- return NM_SETTING_UPDATE_SECRET_ERROR;
- }
- }
-
- /* Now add the items to the settings' secrets list */
- g_hash_table_iter_init (&iter, secrets);
- while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &value)) {
- if (value == NULL) {
- g_warn_if_fail (value != NULL);
- continue;
- }
- if (strlen (value) == 0) {
- g_warn_if_fail (strlen (value) > 0);
- continue;
- }
-
- if (g_strcmp0 (g_hash_table_lookup (priv->secrets, name), value) == 0)
- continue;
-
- g_hash_table_insert (priv->secrets, g_strdup (name), g_strdup (value));
- result = NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED;
- }
-
- return result;
-}
-
-static int
-update_one_secret (NMSetting *setting, const char *key, GValue *value, GError **error)
-{
- NMSettingUpdateSecretResult success = NM_SETTING_UPDATE_SECRET_ERROR;
-
- g_return_val_if_fail (key != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
- g_return_val_if_fail (value != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
-
- if (G_VALUE_HOLDS_STRING (value)) {
- /* Passing the string properties individually isn't correct, and won't
- * produce the correct result, but for some reason that's how it used
- * to be done. So even though it's not correct, keep the code around
- * for compatibility's sake.
- */
- success = update_secret_string (setting, key, g_value_get_string (value), error);
- } else if (G_VALUE_HOLDS (value, DBUS_TYPE_G_MAP_OF_STRING)) {
- if (strcmp (key, NM_SETTING_VPN_SECRETS) != 0) {
- g_set_error (error, NM_SETTING_ERROR, NM_SETTING_ERROR_PROPERTY_NOT_SECRET,
- "Property %s not a secret property", key);
- } else
- success = update_secret_hash (setting, g_value_get_boxed (value), error);
- } else
- g_set_error_literal (error, NM_SETTING_ERROR, NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, key);
-
- if (success == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
- g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
-
- return success;
-}
-
-static gboolean
-get_secret_flags (NMSetting *setting,
- const char *secret_name,
- gboolean verify_secret,
- NMSettingSecretFlags *out_flags,
- GError **error)
-{
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
- gboolean success = FALSE;
- char *flags_key;
- gpointer val;
- unsigned long tmp;
- NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
-
- flags_key = g_strdup_printf ("%s-flags", secret_name);
- if (g_hash_table_lookup_extended (priv->data, flags_key, NULL, &val)) {
- errno = 0;
- tmp = strtoul ((const char *) val, NULL, 10);
- if ((errno == 0) && (tmp <= NM_SETTING_SECRET_FLAGS_ALL)) {
- flags = (NMSettingSecretFlags) tmp;
- success = TRUE;
- } else {
- g_set_error (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- _("Failed to convert '%s' value '%s' to uint"),
- flags_key, (const char *) val);
- }
- } else {
- g_set_error (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_NOT_FOUND,
- _("Secret flags property '%s' not found"), flags_key);
- }
- g_free (flags_key);
- if (out_flags)
- *out_flags = flags;
- return success;
-}
-
-static gboolean
-set_secret_flags (NMSetting *setting,
- const char *secret_name,
- gboolean verify_secret,
- NMSettingSecretFlags flags,
- GError **error)
-{
- g_hash_table_insert (NM_SETTING_VPN_GET_PRIVATE (setting)->data,
- g_strdup_printf ("%s-flags", secret_name),
- g_strdup_printf ("%u", flags));
- g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
- return TRUE;
-}
-
-static GPtrArray *
-need_secrets (NMSetting *setting)
-{
- /* Assume that VPN connections need secrets since they almost always will */
- return g_ptr_array_sized_new (1);
-}
-
-static gboolean
-_compare_secrets (NMSettingVPN *a,
- NMSettingVPN *b,
- NMSettingCompareFlags flags)
-{
- GHashTable *a_secrets;
- GHashTableIter iter;
- const char *key, *val;
-
- a_secrets = NM_SETTING_VPN_GET_PRIVATE (a)->secrets;
- g_hash_table_iter_init (&iter, a_secrets);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) {
- NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
- NMSettingSecretFlags b_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
-
- nm_setting_get_secret_flags (NM_SETTING (a), key, &a_secret_flags, NULL);
- nm_setting_get_secret_flags (NM_SETTING (b), key, &b_secret_flags, NULL);
-
- /* If the secret flags aren't the same, the settings aren't the same */
- if (a_secret_flags != b_secret_flags)
- return FALSE;
-
- if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS)
- && (a_secret_flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED))
- continue;
-
- if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)
- && (a_secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED))
- continue;
-
- /* Now compare the values themselves */
- if (g_strcmp0 (val, nm_setting_vpn_get_secret (b, key)) != 0)
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-compare_one_secret (NMSettingVPN *a,
- NMSettingVPN *b,
- NMSettingCompareFlags flags)
-{
- if (!_compare_secrets (a, b, flags))
- return FALSE;
- if (!_compare_secrets (b, a, flags))
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-compare_property (NMSetting *setting,
- NMSetting *other,
- const GParamSpec *prop_spec,
- NMSettingCompareFlags flags)
-{
- gboolean same;
-
- /* We only need to treat the 'secrets' property specially */
- if (g_strcmp0 (prop_spec->name, NM_SETTING_VPN_SECRETS) != 0)
- return NM_SETTING_CLASS (nm_setting_vpn_parent_class)->compare_property (setting, other, prop_spec, flags);
-
- /* Compare A to B to ensure everything in A is found in B */
- same = compare_one_secret (NM_SETTING_VPN (setting), NM_SETTING_VPN (other), flags);
- if (same) {
- /* And then B to A to ensure everything in B is also found in A */
- same = compare_one_secret (NM_SETTING_VPN (other), NM_SETTING_VPN (setting), flags);
- }
-
- return same;
-}
-
-static gboolean
-clear_secrets_with_flags (NMSetting *setting,
- GParamSpec *pspec,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data)
-{
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
- GHashTableIter iter;
- const char *secret;
- gboolean changed = TRUE;
-
- if (priv->secrets == NULL)
- return FALSE;
-
- /* Iterate through secrets hash and check each entry */
- g_hash_table_iter_init (&iter, priv->secrets);
- while (g_hash_table_iter_next (&iter, (gpointer) &secret, NULL)) {
- NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
-
- nm_setting_get_secret_flags (setting, secret, &flags, NULL);
- if (func (setting, pspec->name, flags, user_data) == TRUE) {
- g_hash_table_iter_remove (&iter);
- changed = TRUE;
- }
- }
-
- if (changed)
- g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
-
- return changed;
-}
-
-static void
-destroy_one_secret (gpointer data)
-{
- char *secret = (char *) data;
-
- /* Don't leave the secret lying around in memory */
- memset (secret, 0, strlen (secret));
- g_free (secret);
-}
-
-static void
-nm_setting_vpn_init (NMSettingVPN *setting)
-{
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
-
- priv->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- priv->secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_one_secret);
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (object);
-
- g_free (priv->service_type);
- g_free (priv->user_name);
- g_hash_table_destroy (priv->data);
- g_hash_table_destroy (priv->secrets);
-
- G_OBJECT_CLASS (nm_setting_vpn_parent_class)->finalize (object);
-}
-
-static void
-copy_hash (gpointer key, gpointer value, gpointer user_data)
-{
- g_return_if_fail (value != NULL);
- g_return_if_fail (strlen (value));
- g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), g_strdup (value));
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (object);
- GHashTable *new_hash;
-
- switch (prop_id) {
- case PROP_SERVICE_TYPE:
- g_free (priv->service_type);
- priv->service_type = g_value_dup_string (value);
- break;
- case PROP_USER_NAME:
- g_free (priv->user_name);
- priv->user_name = g_value_dup_string (value);
- break;
- case PROP_PERSISTENT:
- priv->persistent = g_value_get_boolean (value);
- break;
- case PROP_DATA:
- /* Must make a deep copy of the hash table here... */
- g_hash_table_remove_all (priv->data);
- new_hash = g_value_get_boxed (value);
- if (new_hash)
- g_hash_table_foreach (new_hash, copy_hash, priv->data);
- break;
- case PROP_SECRETS:
- /* Must make a deep copy of the hash table here... */
- g_hash_table_remove_all (priv->secrets);
- new_hash = g_value_get_boxed (value);
- if (new_hash)
- g_hash_table_foreach (new_hash, copy_hash, priv->secrets);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingVPN *setting = NM_SETTING_VPN (object);
- NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_SERVICE_TYPE:
- g_value_set_string (value, nm_setting_vpn_get_service_type (setting));
- break;
- case PROP_USER_NAME:
- g_value_set_string (value, nm_setting_vpn_get_user_name (setting));
- break;
- case PROP_PERSISTENT:
- g_value_set_boolean (value, priv->persistent);
- break;
- case PROP_DATA:
- g_value_set_boxed (value, priv->data);
- break;
- case PROP_SECRETS:
- g_value_set_boxed (value, priv->secrets);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_vpn_class_init (NMSettingVPNClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingVPNPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- parent_class->verify = verify;
- parent_class->update_one_secret = update_one_secret;
- parent_class->get_secret_flags = get_secret_flags;
- parent_class->set_secret_flags = set_secret_flags;
- parent_class->need_secrets = need_secrets;
- parent_class->compare_property = compare_property;
- parent_class->clear_secrets_with_flags = clear_secrets_with_flags;
-
- /* Properties */
- /**
- * NMSettingVPN:service-type:
- *
- * D-Bus service name of the VPN plugin that this setting uses to connect to
- * its network. i.e. org.freedesktop.NetworkManager.vpnc for the vpnc
- * plugin.
- **/
- g_object_class_install_property
- (object_class, PROP_SERVICE_TYPE,
- g_param_spec_string (NM_SETTING_VPN_SERVICE_TYPE, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVPN:user-name:
- *
- * If the VPN connection requires a user name for authentication, that name
- * should be provided here. If the connection is available to more than one
- * user, and the VPN requires each user to supply a different name, then
- * leave this property empty. If this property is empty, NetworkManager
- * will automatically supply the username of the user which requested the
- * VPN connection.
- **/
- g_object_class_install_property
- (object_class, PROP_USER_NAME,
- g_param_spec_string (NM_SETTING_VPN_USER_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVPN:persistent:
- *
- * If the VPN service supports persistence, and this property is %TRUE,
- * the VPN will attempt to stay connected across link changes and outages,
- * until explicitly disconnected.
- **/
- g_object_class_install_property
- (object_class, PROP_PERSISTENT,
- g_param_spec_boolean (NM_SETTING_VPN_PERSISTENT, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVPN:data:
- *
- * Dictionary of key/value pairs of VPN plugin specific data. Both keys and
- * values must be strings.
- **/
- g_object_class_install_property
- (object_class, PROP_DATA,
- _nm_param_spec_specialized (NM_SETTING_VPN_DATA, "", "",
- DBUS_TYPE_G_MAP_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingVPN:secrets:
- *
- * Dictionary of key/value pairs of VPN plugin specific secrets like
- * passwords or private keys. Both keys and values must be strings.
- **/
- g_object_class_install_property
- (object_class, PROP_SECRETS,
- _nm_param_spec_specialized (NM_SETTING_VPN_SECRETS, "", "",
- DBUS_TYPE_G_MAP_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-vpn.h b/libnm-util/nm-setting-vpn.h
deleted file mode 100644
index ba952f4263..0000000000
--- a/libnm-util/nm-setting-vpn.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2013 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_VPN_H
-#define NM_SETTING_VPN_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_VPN (nm_setting_vpn_get_type ())
-#define NM_SETTING_VPN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_VPN, NMSettingVPN))
-#define NM_SETTING_VPN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_VPN, NMSettingVPNClass))
-#define NM_IS_SETTING_VPN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_VPN))
-#define NM_IS_SETTING_VPN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_VPN))
-#define NM_SETTING_VPN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_VPN, NMSettingVPNClass))
-
-#define NM_SETTING_VPN_SETTING_NAME "vpn"
-
-/**
- * NMSettingVpnError:
- * @NM_SETTING_VPN_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_VPN_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_VPN_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum {
- NM_SETTING_VPN_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_VPN_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_VPN_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
-} NMSettingVpnError;
-
-#define NM_SETTING_VPN_ERROR nm_setting_vpn_error_quark ()
-GQuark nm_setting_vpn_error_quark (void);
-
-#define NM_SETTING_VPN_SERVICE_TYPE "service-type"
-#define NM_SETTING_VPN_USER_NAME "user-name"
-#define NM_SETTING_VPN_PERSISTENT "persistent"
-#define NM_SETTING_VPN_DATA "data"
-#define NM_SETTING_VPN_SECRETS "secrets"
-
-typedef struct {
- NMSetting parent;
-} NMSettingVPN;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingVPNClass;
-
-/**
- * NMVPNIterFunc:
- * @key: the name of the data or secret item
- * @value: the value of the data or secret item
- * @user_data: User data passed to nm_setting_vpn_foreach_data_item() or
- * nm_setting_vpn_foreach_secret()
- **/
-typedef void (*NMVPNIterFunc) (const char *key, const char *value, gpointer user_data);
-
-GType nm_setting_vpn_get_type (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);
-
-guint32 nm_setting_vpn_get_num_data_items (NMSettingVPN *setting);
-void nm_setting_vpn_add_data_item (NMSettingVPN *setting,
- const char *key,
- const char *item);
-const char * nm_setting_vpn_get_data_item (NMSettingVPN *setting,
- const char *key);
-gboolean nm_setting_vpn_remove_data_item (NMSettingVPN *setting,
- const char *key);
-void nm_setting_vpn_foreach_data_item (NMSettingVPN *setting,
- NMVPNIterFunc func,
- gpointer user_data);
-
-guint32 nm_setting_vpn_get_num_secrets (NMSettingVPN *setting);
-void nm_setting_vpn_add_secret (NMSettingVPN *setting,
- const char *key,
- const char *secret);
-const char * nm_setting_vpn_get_secret (NMSettingVPN *setting,
- const char *key);
-gboolean nm_setting_vpn_remove_secret (NMSettingVPN *setting,
- const char *key);
-void nm_setting_vpn_foreach_secret (NMSettingVPN *setting,
- NMVPNIterFunc func,
- gpointer user_data);
-
-#ifdef NM_VPN_LIBNM_COMPAT
-#define NMSettingVpn NMSettingVPN
-#endif
-
-G_END_DECLS
-
-#endif /* NM_SETTING_VPN_H */
diff --git a/libnm-util/nm-setting-wimax.c b/libnm-util/nm-setting-wimax.c
deleted file mode 100644
index 102fbb5cf7..0000000000
--- a/libnm-util/nm-setting-wimax.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 - 2013 Red Hat, Inc.
- * Copyright 2009 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <net/ethernet.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-wimax.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-wimax
- * @short_description: Describes 802.16e Mobile WiMAX connection properties
- * @include: nm-setting-wimax.h
- *
- * The #NMSettingWimax object is a #NMSetting subclass that describes properties
- * necessary for connection to 802.16e Mobile WiMAX networks.
- *
- * NetworkManager no longer supports WiMAX; while this API remains available for
- * backward-compatibility reasons, it serves no real purpose, since WiMAX
- * connections cannot be activated.
- **/
-
-/**
- * nm_setting_wimax_error_quark:
- *
- * Registers an error quark for #NMSettingWimax if necessary.
- *
- * Returns: the error quark used for #NMSettingWimax errors.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-GQuark
-nm_setting_wimax_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-wimax-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingWimax, nm_setting_wimax, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_WIMAX_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_WIMAX_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIMAX)
-
-#define NM_SETTING_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIMAX, NMSettingWimaxPrivate))
-
-typedef struct {
- char *network_name;
- GByteArray *mac_address;
-} NMSettingWimaxPrivate;
-
-enum {
- PROP_0,
- PROP_NETWORK_NAME,
- PROP_MAC_ADDRESS,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_wimax_new:
- *
- * Creates a new #NMSettingWimax object with default values.
- *
- * Returns: the new empty #NMSettingWimax object
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-NMSetting *
-nm_setting_wimax_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIMAX, NULL);
-}
-
-/**
- * nm_setting_wimax_get_network_name:
- * @setting: the #NMSettingWimax
- *
- * Returns the WiMAX NSP name (ex "Sprint" or "CLEAR") which identifies the
- * specific WiMAX network this setting describes a connection to.
- *
- * Returns: the WiMAX NSP name
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-const char *
-nm_setting_wimax_get_network_name (NMSettingWimax *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), NULL);
-
- return NM_SETTING_WIMAX_GET_PRIVATE (setting)->network_name;
-}
-
-/**
- * nm_setting_wimax_get_mac_address:
- * @setting: the #NMSettingWimax
- *
- * Returns the MAC address of a WiMAX device which this connection is locked
- * to.
- *
- * Returns: the MAC address
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
-const GByteArray *
-nm_setting_wimax_get_mac_address (NMSettingWimax *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), NULL);
-
- return NM_SETTING_WIMAX_GET_PRIVATE (setting)->mac_address;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (setting);
-
- if (!priv->network_name) {
- g_set_error_literal (error,
- NM_SETTING_WIMAX_ERROR,
- NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_NETWORK_NAME);
- return FALSE;
- }
-
- if (!strlen (priv->network_name)) {
- g_set_error_literal (error,
- NM_SETTING_WIMAX_ERROR,
- NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_NETWORK_NAME);
- return FALSE;
- }
-
- if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_WIMAX_ERROR,
- NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_MAC_ADDRESS);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-nm_setting_wimax_init (NMSettingWimax *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (object);
-
- g_free (priv->network_name);
- if (priv->mac_address)
- g_byte_array_free (priv->mac_address, TRUE);
-
- G_OBJECT_CLASS (nm_setting_wimax_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_NETWORK_NAME:
- g_free (priv->network_name);
- priv->network_name = g_value_dup_string (value);
- break;
- case PROP_MAC_ADDRESS:
- if (priv->mac_address)
- g_byte_array_free (priv->mac_address, TRUE);
- priv->mac_address = g_value_dup_boxed (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingWimax *setting = NM_SETTING_WIMAX (object);
-
- switch (prop_id) {
- case PROP_NETWORK_NAME:
- g_value_set_string (value, nm_setting_wimax_get_network_name (setting));
- break;
- case PROP_MAC_ADDRESS:
- g_value_set_boxed (value, nm_setting_wimax_get_mac_address (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_wimax_class_init (NMSettingWimaxClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingWimaxPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingWimax:network-name:
- *
- * Network Service Provider (NSP) name of the WiMAX network this connection
- * should use.
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_NETWORK_NAME,
- g_param_spec_string (NM_SETTING_WIMAX_NETWORK_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWimax:mac-address:
- *
- * If specified, this connection will only apply to the WiMAX device whose
- * MAC address matches. This property does not change the MAC address of the
- * device (known as MAC spoofing).
- *
- * Deprecated: 1.2: WiMAX is no longer supported.
- **/
- g_object_class_install_property
- (object_class, PROP_MAC_ADDRESS,
- _nm_param_spec_specialized (NM_SETTING_WIMAX_MAC_ADDRESS, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-wimax.h b/libnm-util/nm-setting-wimax.h
deleted file mode 100644
index 45e533527b..0000000000
--- a/libnm-util/nm-setting-wimax.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2009 Novell, Inc.
- */
-
-#ifndef NM_SETTING_WIMAX_H
-#define NM_SETTING_WIMAX_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_WIMAX (nm_setting_wimax_get_type ())
-#define NM_SETTING_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_WIMAX, NMSettingWimax))
-#define NM_SETTING_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_WIMAX, NMSettingWimaxClass))
-#define NM_IS_SETTING_WIMAX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_WIMAX))
-#define NM_IS_SETTING_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_WIMAX))
-#define NM_SETTING_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_WIMAX, NMSettingWimaxClass))
-
-#define NM_SETTING_WIMAX_SETTING_NAME "wimax"
-
-/**
- * NMSettingWimaxError:
- * @NM_SETTING_WIMAX_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum {
- NM_SETTING_WIMAX_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
-} NMSettingWimaxError;
-
-#define NM_SETTING_WIMAX_ERROR nm_setting_wimax_error_quark ()
-NM_DEPRECATED_IN_1_2
-GQuark nm_setting_wimax_error_quark (void);
-
-#define NM_SETTING_WIMAX_NETWORK_NAME "network-name"
-#define NM_SETTING_WIMAX_MAC_ADDRESS "mac-address"
-
-typedef struct {
- NMSetting parent;
-} NMSettingWimax;
-
-typedef struct {
- NMSettingClass parent;
-} NMSettingWimaxClass;
-
-NM_DEPRECATED_IN_1_2
-GType nm_setting_wimax_get_type (void);
-
-NM_DEPRECATED_IN_1_2
-NMSetting *nm_setting_wimax_new (void);
-NM_DEPRECATED_IN_1_2
-const char *nm_setting_wimax_get_network_name (NMSettingWimax *setting);
-NM_DEPRECATED_IN_1_2
-const GByteArray *nm_setting_wimax_get_mac_address (NMSettingWimax *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_WIMAX_H */
diff --git a/libnm-util/nm-setting-wired.c b/libnm-util/nm-setting-wired.c
deleted file mode 100644
index 8b297ee68a..0000000000
--- a/libnm-util/nm-setting-wired.c
+++ /dev/null
@@ -1,1029 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <net/ethernet.h>
-#include <netinet/ether.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-wired.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-wired
- * @short_description: Describes connection properties for Ethernet-based networks
- * @include: nm-setting-wired.h
- *
- * The #NMSettingWired object is a #NMSetting subclass that describes properties
- * necessary for connection to Ethernet networks.
- **/
-
-/**
- * nm_setting_wired_error_quark:
- *
- * Registers an error quark for #NMSettingWired if necessary.
- *
- * Returns: the error quark used for #NMSettingWired errors.
- **/
-GQuark
-nm_setting_wired_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-wired-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingWired, nm_setting_wired, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_WIRED_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_WIRED_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRED)
-
-#define NM_SETTING_WIRED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRED, NMSettingWiredPrivate))
-
-typedef struct {
- char *port;
- guint32 speed;
- char *duplex;
- gboolean auto_negotiate;
- GByteArray *device_mac_address;
- GByteArray *cloned_mac_address;
- GSList *mac_address_blacklist;
- guint32 mtu;
- GPtrArray *s390_subchannels;
- char *s390_nettype;
- GHashTable *s390_options;
-} NMSettingWiredPrivate;
-
-enum {
- PROP_0,
- PROP_PORT,
- PROP_SPEED,
- PROP_DUPLEX,
- PROP_AUTO_NEGOTIATE,
- PROP_MAC_ADDRESS,
- PROP_CLONED_MAC_ADDRESS,
- PROP_MAC_ADDRESS_BLACKLIST,
- PROP_MTU,
- PROP_S390_SUBCHANNELS,
- PROP_S390_NETTYPE,
- PROP_S390_OPTIONS,
-
- LAST_PROP
-};
-
-static const char *valid_s390_opts[] = {
- "portno", "layer2", "portname", "protocol", "priority_queueing",
- "buffer_count", "isolation", "total", "inter", "inter_jumbo", "route4",
- "route6", "fake_broadcast", "broadcast_mode", "canonical_macaddr",
- "checksumming", "sniffer", "large_send", "ipato_enable", "ipato_invert4",
- "ipato_add4", "ipato_invert6", "ipato_add6", "vipa_add4", "vipa_add6",
- "rxip_add4", "rxip_add6", "lancmd_timeout", "ctcprot",
- NULL
-};
-
-/**
- * nm_setting_wired_new:
- *
- * Creates a new #NMSettingWired object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingWired object
- **/
-NMSetting *
-nm_setting_wired_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRED, NULL);
-}
-
-/**
- * nm_setting_wired_get_port:
- * @setting: the #NMSettingWired
- *
- * Returns: the #NMSettingWired:port property of the setting
- **/
-const char *
-nm_setting_wired_get_port (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->port;
-}
-
-/**
- * nm_setting_wired_get_speed:
- * @setting: the #NMSettingWired
- *
- * Returns: the #NMSettingWired:speed property of the setting
- **/
-guint32
-nm_setting_wired_get_speed (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->speed;
-}
-
-/**
- * nm_setting_wired_get_duplex:
- * @setting: the #NMSettingWired
- *
- * Returns: the #NMSettingWired:duplex property of the setting
- **/
-const char *
-nm_setting_wired_get_duplex (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->duplex;
-}
-
-/**
- * nm_setting_wired_get_auto_negotiate:
- * @setting: the #NMSettingWired
- *
- * Returns: the #NMSettingWired:auto-negotiate property of the setting
- **/
-gboolean
-nm_setting_wired_get_auto_negotiate (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->auto_negotiate;
-}
-
-/**
- * nm_setting_wired_get_mac_address:
- * @setting: the #NMSettingWired
- *
- * Returns: the #NMSettingWired:mac-address property of the setting
- **/
-const GByteArray *
-nm_setting_wired_get_mac_address (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->device_mac_address;
-}
-
-/**
- * nm_setting_wired_get_cloned_mac_address:
- * @setting: the #NMSettingWired
- *
- * Returns: the #NMSettingWired:cloned-mac-address property of the setting
- **/
-const GByteArray *
-nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->cloned_mac_address;
-}
-
-/**
- * nm_setting_wired_get_mac_address_blacklist:
- * @setting: the #NMSettingWired
- *
- * Returns: (element-type GLib.ByteArray): the #NMSettingWired:mac-address-blacklist
- * property of the setting
- **/
-const GSList *
-nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist;
-}
-
-/**
- * nm_setting_wired_get_num_mac_blacklist_items:
- * @setting: the #NMSettingWired
- *
- * Returns: the number of blacklisted MAC addresses
- *
- * Since: 0.9.10
- **/
-guint32
-nm_setting_wired_get_num_mac_blacklist_items (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
-
- return g_slist_length (NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist);
-}
-
-/**
- * nm_setting_wired_get_mac_blacklist_item:
- * @setting: the #NMSettingWired
- * @idx: the zero-based index of the MAC address entry
- *
- * Returns: the blacklisted MAC address string (hex-digits-and-colons notation)
- * at index @idx
- *
- * Since: 0.9.10
- **/
-const char *
-nm_setting_wired_get_mac_blacklist_item (NMSettingWired *setting, guint32 idx)
-{
- NMSettingWiredPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
-
- priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
- g_return_val_if_fail (idx <= g_slist_length (priv->mac_address_blacklist), NULL);
-
- return (const char *) g_slist_nth_data (priv->mac_address_blacklist, idx);
-}
-
-/**
- * nm_setting_wired_add_mac_blacklist_item:
- * @setting: the #NMSettingWired
- * @mac: the MAC address string (hex-digits-and-colons notation) to blacklist
- *
- * Adds a new MAC address to the #NMSettingWired:mac-address-blacklist property.
- *
- * Returns: %TRUE if the MAC address was added; %FALSE if the MAC address
- * is invalid or was already present
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_wired_add_mac_blacklist_item (NMSettingWired *setting, const char *mac)
-{
- NMSettingWiredPrivate *priv;
- GSList *iter;
- guint8 buf[32];
-
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
- g_return_val_if_fail (mac != NULL, FALSE);
-
- if (!nm_utils_hwaddr_aton (mac, ARPHRD_ETHER, buf))
- return FALSE;
-
- priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
- for (iter = priv->mac_address_blacklist; iter; iter = g_slist_next (iter)) {
- if (!strcasecmp (mac, (char *) iter->data))
- return FALSE;
- }
-
- priv->mac_address_blacklist = g_slist_append (priv->mac_address_blacklist,
- g_ascii_strup (mac, -1));
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
- return TRUE;
-}
-
-/**
- * nm_setting_wired_remove_mac_blacklist_item:
- * @setting: the #NMSettingWired
- * @idx: index number of the MAC address
- *
- * Removes the MAC address at index @idx from the blacklist.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting, guint32 idx)
-{
- NMSettingWiredPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_WIRED (setting));
-
- priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->mac_address_blacklist, idx);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
-}
-
-/**
- * nm_setting_wired_remove_mac_blacklist_item_by_value:
- * @setting: the #NMSettingWired
- * @mac: the MAC address string (hex-digits-and-colons notation) to remove from
- * the blacklist
- *
- * Removes the MAC address @mac from the blacklist.
- *
- * Returns: %TRUE if the MAC address was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_wired_remove_mac_blacklist_item_by_value (NMSettingWired *setting, const char *mac)
-{
- NMSettingWiredPrivate *priv;
- GSList *iter;
- guint8 buf[32];
-
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
- g_return_val_if_fail (mac != NULL, FALSE);
-
- if (!nm_utils_hwaddr_aton (mac, ARPHRD_ETHER, buf))
- return FALSE;
-
- priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
- for (iter = priv->mac_address_blacklist; iter; iter = g_slist_next (iter)) {
- if (!strcasecmp (mac, (char *) iter->data)) {
- priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_wired_clear_mac_blacklist_items:
- * @setting: the #NMSettingWired
- *
- * Removes all blacklisted MAC addresses.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *setting)
-{
- g_return_if_fail (NM_IS_SETTING_WIRED (setting));
-
- g_slist_free_full (NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist, g_free);
- NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
-}
-
-/**
- * nm_setting_wired_get_mtu:
- * @setting: the #NMSettingWired
- *
- * Returns: the #NMSettingWired:mtu property of the setting
- **/
-guint32
-nm_setting_wired_get_mtu (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->mtu;
-}
-
-/**
- * nm_setting_wired_get_s390_subchannels:
- * @setting: the #NMSettingWired
- *
- * Return the list of s390 subchannels that identify the device that this
- * connection is applicable to. The connection should only be used in
- * conjunction with that device.
- *
- * Returns: (element-type utf8): #GPtrArray of strings, each specifying one
- * subchannel the s390 device uses to communicate to the host.
- **/
-const GPtrArray *
-nm_setting_wired_get_s390_subchannels (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels;
-}
-
-/**
- * nm_setting_wired_get_s390_nettype:
- * @setting: the #NMSettingWired
- *
- * Returns the s390 device type this connection should apply to. Will be one
- * of 'qeth', 'lcs', or 'ctc'.
- *
- * Returns: the s390 device type
- **/
-const char *
-nm_setting_wired_get_s390_nettype (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
-
- return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_nettype;
-}
-
-/**
- * nm_setting_wired_get_num_s390_options:
- * @setting: the #NMSettingWired
- *
- * Returns the number of s390-specific options that should be set for this
- * device when it is activated. This can be used to retrieve each s390
- * option individually using nm_setting_wired_get_s390_option().
- *
- * Returns: the number of s390-specific device options
- **/
-guint32
-nm_setting_wired_get_num_s390_options (NMSettingWired *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
-
- return g_hash_table_size (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options);
-}
-
-/**
- * nm_setting_wired_get_s390_option:
- * @setting: the #NMSettingWired
- * @idx: index of the desired option, from 0 to
- * nm_setting_wired_get_num_s390_options() - 1
- * @out_key: (out): on return, the key name of the s390 specific option; this
- * value is owned by the setting and should not be modified
- * @out_value: (out): on return, the value of the key of the s390 specific
- * option; this value is owned by the setting and should not be modified
- *
- * Given an index, return the value of the s390 option at that index. indexes
- * are *not* guaranteed to be static across modifications to options done by
- * nm_setting_wired_add_s390_option() and nm_setting_wired_remove_s390_option(),
- * and should not be used to refer to options except for short periods of time
- * such as during option iteration.
- *
- * Returns: %TRUE on success if the index was valid and an option was found,
- * %FALSE if the index was invalid (ie, greater than the number of options
- * currently held by the setting)
- **/
-gboolean
-nm_setting_wired_get_s390_option (NMSettingWired *setting,
- guint32 idx,
- const char **out_key,
- const char **out_value)
-{
- const char *_key, *_value;
- GHashTableIter iter;
- guint i = 0;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
-
- g_hash_table_iter_init (&iter, NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options);
- while (g_hash_table_iter_next (&iter, (gpointer) &_key, (gpointer) &_value)) {
- if (i == idx) {
- if (out_key)
- *out_key = _key;
- if (out_value)
- *out_value = _value;
- return TRUE;
- }
- i++;
- }
- g_return_val_if_reached (FALSE);
-}
-
-/**
- * nm_setting_wired_get_s390_option_by_key:
- * @setting: the #NMSettingWired
- * @key: the key for which to retrieve the value
- *
- * Returns the value associated with the s390-specific option specified by
- * @key, if it exists.
- *
- * Returns: the value, or %NULL if the key/value pair was never added to the
- * setting; the value is owned by the setting and must not be modified
- **/
-const char *
-nm_setting_wired_get_s390_option_by_key (NMSettingWired *setting,
- const char *key)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
- g_return_val_if_fail (key != NULL, NULL);
- g_return_val_if_fail (strlen (key), NULL);
-
- return g_hash_table_lookup (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key);
-}
-
-/**
- * nm_setting_wired_add_s390_option:
- * @setting: the #NMSettingWired
- * @key: key name for the option
- * @value: value for the option
- *
- * Add an option to the table. The option is compared to an internal list
- * of allowed options. Key names may contain only alphanumeric characters
- * (ie [a-zA-Z0-9]). Adding a new key replaces any existing key/value pair that
- * may already exist.
- *
- * Returns: %TRUE if the option was valid and was added to the internal option
- * list, %FALSE if it was not.
- **/
-gboolean
-nm_setting_wired_add_s390_option (NMSettingWired *setting,
- const char *key,
- const char *value)
-{
- size_t value_len;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
- g_return_val_if_fail (strlen (key), FALSE);
- g_return_val_if_fail (g_strv_contains (valid_s390_opts, key), FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
-
- value_len = strlen (value);
- g_return_val_if_fail (value_len > 0 && value_len < 200, FALSE);
-
- g_hash_table_insert (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options,
- g_strdup (key),
- g_strdup (value));
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_S390_OPTIONS);
- return TRUE;
-}
-
-/**
- * nm_setting_wired_remove_s390_option:
- * @setting: the #NMSettingWired
- * @key: key name for the option to remove
- *
- * Remove the s390-specific option referenced by @key from the internal option
- * list.
- *
- * Returns: %TRUE if the option was found and removed from the internal option
- * list, %FALSE if it was not.
- **/
-gboolean
-nm_setting_wired_remove_s390_option (NMSettingWired *setting,
- const char *key)
-{
- gboolean found;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
- g_return_val_if_fail (strlen (key), FALSE);
-
- found = g_hash_table_remove (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key);
- if (found)
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_S390_OPTIONS);
- return found;
-}
-
-/**
- * nm_setting_wired_get_valid_s390_options:
- * @setting: the #NMSettingWired
- *
- * Returns a list of valid s390 options.
- *
- * Returns: (transfer none): a %NULL-terminated array of strings of valid s390 options.
- *
- * Since: 0.9.10
- **/
-const char **
-nm_setting_wired_get_valid_s390_options (NMSettingWired *setting)
-{
- return valid_s390_opts;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
- const char *valid_ports[] = { "tp", "aui", "bnc", "mii", NULL };
- const char *valid_duplex[] = { "half", "full", NULL };
- const char *valid_nettype[] = { "qeth", "lcs", "ctc", NULL };
- GHashTableIter iter;
- GSList* mac_blacklist_iter;
- const char *key, *value;
-
- if (priv->port && !g_strv_contains (valid_ports, priv->port)) {
- g_set_error (error,
- NM_SETTING_WIRED_ERROR,
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid Ethernet port value"),
- priv->port);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_PORT);
- return FALSE;
- }
-
- if (priv->duplex && !g_strv_contains (valid_duplex, priv->duplex)) {
- g_set_error (error,
- NM_SETTING_WIRED_ERROR,
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid duplex value"),
- priv->duplex);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_DUPLEX);
- return FALSE;
- }
-
- if (priv->device_mac_address && priv->device_mac_address->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_WIRED_ERROR,
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
- _("is not a valid MAC address"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS);
- return FALSE;
- }
-
- for (mac_blacklist_iter = priv->mac_address_blacklist; mac_blacklist_iter;
- mac_blacklist_iter = mac_blacklist_iter->next) {
- struct ether_addr addr;
-
- if (!ether_aton_r (mac_blacklist_iter->data, &addr)) {
- g_set_error (error,
- NM_SETTING_WIRED_ERROR,
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid MAC address"),
- (const char *) mac_blacklist_iter->data);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
- return FALSE;
- }
- }
-
- if ( priv->s390_subchannels
- && !(priv->s390_subchannels->len == 3 || priv->s390_subchannels->len == 2)) {
- g_set_error_literal (error,
- NM_SETTING_WIRED_ERROR,
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS);
- return FALSE;
- }
-
- if (priv->s390_nettype && !g_strv_contains (valid_nettype, priv->s390_nettype)) {
- g_set_error_literal (error,
- NM_SETTING_WIRED_ERROR,
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_NETTYPE);
- return FALSE;
- }
-
- g_hash_table_iter_init (&iter, priv->s390_options);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
- if ( !g_strv_contains (valid_s390_opts, key)
- || !strlen (value)
- || (strlen (value) > 200)) {
- g_set_error (error,
- NM_SETTING_WIRED_ERROR,
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
- _("invalid '%s' or its value '%s'"),
- key, value);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_OPTIONS);
- return FALSE;
- }
- }
-
- if (priv->cloned_mac_address && priv->cloned_mac_address->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_WIRED_ERROR,
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
- _("is not a valid MAC address"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_CLONED_MAC_ADDRESS);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-nm_setting_wired_init (NMSettingWired *setting)
-{
- NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
-
- priv->s390_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object);
-
- g_free (priv->port);
- g_free (priv->duplex);
- g_free (priv->s390_nettype);
-
- g_hash_table_destroy (priv->s390_options);
-
- if (priv->device_mac_address)
- g_byte_array_free (priv->device_mac_address, TRUE);
-
- if (priv->cloned_mac_address)
- g_byte_array_free (priv->cloned_mac_address, TRUE);
-
- g_slist_free_full (priv->mac_address_blacklist, g_free);
-
- if (priv->s390_subchannels) {
- g_ptr_array_set_free_func (priv->s390_subchannels, g_free);
- g_ptr_array_free (priv->s390_subchannels, TRUE);
- }
-
- G_OBJECT_CLASS (nm_setting_wired_parent_class)->finalize (object);
-}
-
-static void
-copy_hash (gpointer key, gpointer value, gpointer user_data)
-{
- g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), g_strdup (value));
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object);
- GHashTable *new_hash;
-
- switch (prop_id) {
- case PROP_PORT:
- g_free (priv->port);
- priv->port = g_value_dup_string (value);
- break;
- case PROP_SPEED:
- priv->speed = g_value_get_uint (value);
- break;
- case PROP_DUPLEX:
- g_free (priv->duplex);
- priv->duplex = g_value_dup_string (value);
- break;
- case PROP_AUTO_NEGOTIATE:
- priv->auto_negotiate = g_value_get_boolean (value);
- break;
- case PROP_MAC_ADDRESS:
- if (priv->device_mac_address)
- g_byte_array_free (priv->device_mac_address, TRUE);
- priv->device_mac_address = g_value_dup_boxed (value);
- break;
- case PROP_CLONED_MAC_ADDRESS:
- if (priv->cloned_mac_address)
- g_byte_array_free (priv->cloned_mac_address, TRUE);
- priv->cloned_mac_address = g_value_dup_boxed (value);
- break;
- case PROP_MAC_ADDRESS_BLACKLIST:
- g_slist_free_full (priv->mac_address_blacklist, g_free);
- priv->mac_address_blacklist = g_value_dup_boxed (value);
- break;
- case PROP_MTU:
- priv->mtu = g_value_get_uint (value);
- break;
- case PROP_S390_SUBCHANNELS:
- if (priv->s390_subchannels) {
- g_ptr_array_set_free_func (priv->s390_subchannels, g_free);
- g_ptr_array_free (priv->s390_subchannels, TRUE);
- }
- priv->s390_subchannels = g_value_dup_boxed (value);
- break;
- case PROP_S390_NETTYPE:
- g_free (priv->s390_nettype);
- priv->s390_nettype = g_value_dup_string (value);
- break;
- case PROP_S390_OPTIONS:
- /* Must make a deep copy of the hash table here... */
- g_hash_table_remove_all (priv->s390_options);
- new_hash = g_value_get_boxed (value);
- if (new_hash)
- g_hash_table_foreach (new_hash, copy_hash, priv->s390_options);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingWired *setting = NM_SETTING_WIRED (object);
- NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_PORT:
- g_value_set_string (value, nm_setting_wired_get_port (setting));
- break;
- case PROP_SPEED:
- g_value_set_uint (value, nm_setting_wired_get_speed (setting));
- break;
- case PROP_DUPLEX:
- g_value_set_string (value, nm_setting_wired_get_duplex (setting));
- break;
- case PROP_AUTO_NEGOTIATE:
- g_value_set_boolean (value, nm_setting_wired_get_auto_negotiate (setting));
- break;
- case PROP_MAC_ADDRESS:
- g_value_set_boxed (value, nm_setting_wired_get_mac_address (setting));
- break;
- case PROP_CLONED_MAC_ADDRESS:
- g_value_set_boxed (value, nm_setting_wired_get_cloned_mac_address (setting));
- break;
- case PROP_MAC_ADDRESS_BLACKLIST:
- g_value_set_boxed (value, nm_setting_wired_get_mac_address_blacklist (setting));
- break;
- case PROP_MTU:
- g_value_set_uint (value, nm_setting_wired_get_mtu (setting));
- break;
- case PROP_S390_SUBCHANNELS:
- g_value_set_boxed (value, nm_setting_wired_get_s390_subchannels (setting));
- break;
- case PROP_S390_NETTYPE:
- g_value_set_string (value, nm_setting_wired_get_s390_nettype (setting));
- break;
- case PROP_S390_OPTIONS:
- g_value_set_boxed (value, priv->s390_options);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingWiredPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingWired:port:
- *
- * Specific port type to use if the device supports multiple
- * attachment methods. One of "tp" (Twisted Pair), "aui" (Attachment Unit
- * Interface), "bnc" (Thin Ethernet) or "mii" (Media Independent Interface).
- * If the device supports only one port type, this setting is ignored.
- **/
- g_object_class_install_property
- (object_class, PROP_PORT,
- g_param_spec_string (NM_SETTING_WIRED_PORT, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:speed:
- *
- * If non-zero, request that the device use only the specified speed. In
- * Mbit/s, ie 100 == 100Mbit/s.
- **/
- g_object_class_install_property
- (object_class, PROP_SPEED,
- g_param_spec_uint (NM_SETTING_WIRED_SPEED, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:duplex:
- *
- * If specified, request that the device only use the specified duplex mode.
- * Either "half" or "full".
- **/
- g_object_class_install_property
- (object_class, PROP_DUPLEX,
- g_param_spec_string (NM_SETTING_WIRED_DUPLEX, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:auto-negotiate:
- *
- * If %TRUE, allow auto-negotiation of port speed and duplex mode. If
- * %FALSE, do not allow auto-negotiation, in which case the "speed" and
- * "duplex" properties should be set.
- **/
- g_object_class_install_property
- (object_class, PROP_AUTO_NEGOTIATE,
- g_param_spec_boolean (NM_SETTING_WIRED_AUTO_NEGOTIATE, "", "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:mac-address:
- *
- * If specified, this connection will only apply to the Ethernet device
- * whose permanent MAC address matches. This property does not change the
- * MAC address of the device (i.e. MAC spoofing).
- **/
- g_object_class_install_property
- (object_class, PROP_MAC_ADDRESS,
- _nm_param_spec_specialized (NM_SETTING_WIRED_MAC_ADDRESS, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:cloned-mac-address:
- *
- * If specified, request that the device use this MAC address instead of its
- * permanent MAC address. This is known as MAC cloning or spoofing.
- **/
- g_object_class_install_property
- (object_class, PROP_CLONED_MAC_ADDRESS,
- _nm_param_spec_specialized (NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:mac-address-blacklist:
- *
- * If specified, this connection will never apply to the Ethernet device
- * whose permanent MAC address matches an address in the list. Each MAC
- * address is in the standard hex-digits-and-colons notation
- * (00:11:22:33:44:55).
- **/
- g_object_class_install_property
- (object_class, PROP_MAC_ADDRESS_BLACKLIST,
- _nm_param_spec_specialized (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:mtu:
- *
- * If non-zero, only transmit packets of the specified size or smaller,
- * breaking larger packets up into multiple Ethernet frames.
- **/
- g_object_class_install_property
- (object_class, PROP_MTU,
- g_param_spec_uint (NM_SETTING_WIRED_MTU, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:s390-subchannels:
- *
- * Identifies specific subchannels that this network device uses for
- * communication with z/VM or s390 host. Like the
- * #NMSettingWired:mac-address property for non-z/VM devices, this property
- * can be used to ensure this connection only applies to the network device
- * that uses these subchannels. The list should contain exactly 3 strings,
- * and each string may only be composed of hexadecimal characters and the
- * period (.) character.
- **/
- g_object_class_install_property
- (object_class, PROP_S390_SUBCHANNELS,
- _nm_param_spec_specialized (NM_SETTING_WIRED_S390_SUBCHANNELS, "", "",
- DBUS_TYPE_G_ARRAY_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:s390-nettype:
- *
- * s390 network device type; one of "qeth", "lcs", or "ctc", representing
- * the different types of virtual network devices available on s390 systems.
- **/
- g_object_class_install_property
- (object_class, PROP_S390_NETTYPE,
- g_param_spec_string (NM_SETTING_WIRED_S390_NETTYPE, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWired:s390-options:
- *
- * Dictionary of key/value pairs of s390-specific device options. Both keys
- * and values must be strings. Allowed keys include "portno", "layer2",
- * "portname", "protocol", among others. Key names must contain only
- * alphanumeric characters (ie, [a-zA-Z0-9]).
- **/
- g_object_class_install_property
- (object_class, PROP_S390_OPTIONS,
- _nm_param_spec_specialized (NM_SETTING_WIRED_S390_OPTIONS, "", "",
- DBUS_TYPE_G_MAP_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_INFERRABLE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-wired.h b/libnm-util/nm-setting-wired.h
deleted file mode 100644
index 08a39153af..0000000000
--- a/libnm-util/nm-setting-wired.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_WIRED_H
-#define NM_SETTING_WIRED_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_WIRED (nm_setting_wired_get_type ())
-#define NM_SETTING_WIRED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_WIRED, NMSettingWired))
-#define NM_SETTING_WIRED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_WIRED, NMSettingWiredClass))
-#define NM_IS_SETTING_WIRED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_WIRED))
-#define NM_IS_SETTING_WIRED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_WIRED))
-#define NM_SETTING_WIRED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_WIRED, NMSettingWiredClass))
-
-#define NM_SETTING_WIRED_SETTING_NAME "802-3-ethernet"
-
-/**
- * NMSettingWiredError:
- * @NM_SETTING_WIRED_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_WIRED_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_WIRED_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- */
-typedef enum {
- NM_SETTING_WIRED_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_WIRED_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
-} NMSettingWiredError;
-
-#define NM_SETTING_WIRED_ERROR nm_setting_wired_error_quark ()
-GQuark nm_setting_wired_error_quark (void);
-
-#define NM_SETTING_WIRED_PORT "port"
-#define NM_SETTING_WIRED_SPEED "speed"
-#define NM_SETTING_WIRED_DUPLEX "duplex"
-#define NM_SETTING_WIRED_AUTO_NEGOTIATE "auto-negotiate"
-#define NM_SETTING_WIRED_MAC_ADDRESS "mac-address"
-#define NM_SETTING_WIRED_CLONED_MAC_ADDRESS "cloned-mac-address"
-#define NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST "mac-address-blacklist"
-#define NM_SETTING_WIRED_MTU "mtu"
-#define NM_SETTING_WIRED_S390_SUBCHANNELS "s390-subchannels"
-#define NM_SETTING_WIRED_S390_NETTYPE "s390-nettype"
-#define NM_SETTING_WIRED_S390_OPTIONS "s390-options"
-
-typedef struct {
- NMSetting parent;
-} NMSettingWired;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingWiredClass;
-
-GType nm_setting_wired_get_type (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);
-gboolean nm_setting_wired_get_auto_negotiate (NMSettingWired *setting);
-const GByteArray *nm_setting_wired_get_mac_address (NMSettingWired *setting);
-const GByteArray *nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting);
-
-const GSList *nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting);
-NM_AVAILABLE_IN_0_9_10
-guint32 nm_setting_wired_get_num_mac_blacklist_items (NMSettingWired *setting);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_setting_wired_get_mac_blacklist_item (NMSettingWired *setting,
- guint32 idx);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_wired_add_mac_blacklist_item (NMSettingWired *setting,
- const char *mac);
-NM_AVAILABLE_IN_0_9_10
-void nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting,
- guint32 idx);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_wired_remove_mac_blacklist_item_by_value (NMSettingWired *setting,
- const char *mac);
-NM_AVAILABLE_IN_0_9_10
-void nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *setting);
-
-guint32 nm_setting_wired_get_mtu (NMSettingWired *setting);
-
-const GPtrArray * nm_setting_wired_get_s390_subchannels (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 * 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);
-gboolean nm_setting_wired_remove_s390_option (NMSettingWired *setting,
- const char *key);
-NM_AVAILABLE_IN_0_9_10
-const char ** nm_setting_wired_get_valid_s390_options (NMSettingWired *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_WIRED_H */
diff --git a/libnm-util/nm-setting-wireless-security.c b/libnm-util/nm-setting-wireless-security.c
deleted file mode 100644
index 33598dfec0..0000000000
--- a/libnm-util/nm-setting-wireless-security.c
+++ /dev/null
@@ -1,1552 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-setting-wireless-security.h"
-#include "nm-setting-8021x.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-utils-private.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-wireless-security
- * @short_description: Describes connection properties for Wi-Fi networks that
- * use WEP, LEAP, WPA or WPA2/RSN security
- * @include: nm-setting-wireless-security.h
- *
- * The #NMSettingWirelessSecurity object is a #NMSetting subclass that describes
- * properties necessary for connection to encrypted Wi-Fi networks.
- *
- * It's a good idea to read up on wpa_supplicant configuration before using this
- * setting extensively, since most of the options here correspond closely with
- * the relevant wpa_supplicant configuration options. To get a better overview
- * of how Wi-Fi security works, you may want to get copies of the following books.
- *
- * 802.11 Wireless Networks: The Definitive Guide, Second Edition
- * Author: Matthew Gast
- * ISBN: 978-0596100520
- *
- * Cisco Wireless LAN Security
- * Authors: Krishna Sankar, Sri Sundaralingam, Darrin Miller, and Andrew Balinsky
- * ISBN: 978-1587051548
- **/
-
-/**
- * nm_setting_wireless_security_error_quark:
- *
- * Registers an error quark for #NMSettingWired if necessary.
- *
- * Returns: the error quark used for #NMSettingWired errors.
- **/
-GQuark
-nm_setting_wireless_security_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-wireless-security-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
- g_define_type_id,
- 2,
- NM_SETTING_WIRELESS_SECURITY_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS_SECURITY)
-
-#define NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityPrivate))
-
-typedef struct {
- char *key_mgmt;
- char *auth_alg;
- GSList *proto; /* GSList of strings */
- GSList *pairwise; /* GSList of strings */
- GSList *group; /* GSList of strings */
-
- /* LEAP */
- char *leap_username;
- char *leap_password;
- NMSettingSecretFlags leap_password_flags;
-
- /* WEP */
- char *wep_key0;
- char *wep_key1;
- char *wep_key2;
- char *wep_key3;
- NMSettingSecretFlags wep_key_flags;
- NMWepKeyType wep_key_type;
- guint32 wep_tx_keyidx;
-
- /* WPA-PSK */
- char *psk;
- NMSettingSecretFlags psk_flags;
-} NMSettingWirelessSecurityPrivate;
-
-enum {
- PROP_0,
- PROP_KEY_MGMT,
- PROP_WEP_TX_KEYIDX,
- PROP_AUTH_ALG,
- PROP_PROTO,
- PROP_PAIRWISE,
- PROP_GROUP,
- PROP_LEAP_USERNAME,
- PROP_WEP_KEY0,
- PROP_WEP_KEY1,
- PROP_WEP_KEY2,
- PROP_WEP_KEY3,
- PROP_WEP_KEY_FLAGS,
- PROP_WEP_KEY_TYPE,
- PROP_PSK,
- PROP_PSK_FLAGS,
- PROP_LEAP_PASSWORD,
- PROP_LEAP_PASSWORD_FLAGS,
-
- LAST_PROP
-};
-
-/**
- * nm_setting_wireless_security_new:
- *
- * Creates a new #NMSettingWirelessSecurity object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingWirelessSecurity object
- **/
-NMSetting *
-nm_setting_wireless_security_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRELESS_SECURITY, NULL);
-}
-
-/**
- * nm_setting_wireless_security_get_key_mgmt:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingWirelessSecurity:key-mgmt property of the setting
- **/
-const char *
-nm_setting_wireless_security_get_key_mgmt (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->key_mgmt;
-}
-
-/**
- * nm_setting_wireless_security_get_num_protos:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the number of security protocols this connection allows when
- * connecting to secure Wi-Fi networks
- **/
-guint32
-nm_setting_wireless_security_get_num_protos (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
-
- return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->proto);
-}
-
-/**
- * nm_setting_wireless_security_get_proto:
- * @setting: the #NMSettingWirelessSecurity
- * @i: an index into the protocol list
- *
- * Returns: the protocol at index @i
- **/
-const char *
-nm_setting_wireless_security_get_proto (NMSettingWirelessSecurity *setting, guint32 i)
-{
- NMSettingWirelessSecurityPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->proto), NULL);
-
- return (const char *) g_slist_nth_data (priv->proto, i);
-}
-
-/**
- * nm_setting_wireless_security_add_proto:
- * @setting: the #NMSettingWirelessSecurity
- * @proto: the protocol to add, one of "wpa" or "rsn"
- *
- * Adds a Wi-Fi security protocol (one of "wpa" or "rsn") to the allowed list;
- * only protocols in this list will be used when finding and connecting to
- * the Wi-Fi network specified by this connection. For example, if the
- * protocol list contains only "wpa" but the access point for the SSID specified
- * by this connection only supports WPA2/RSN, the connection cannot be used
- * with the access point.
- *
- * Returns: %TRUE if the protocol was new and was added to the allowed
- * protocol list, or %FALSE if it was already in the list
- **/
-gboolean
-nm_setting_wireless_security_add_proto (NMSettingWirelessSecurity *setting, const char *proto)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
- g_return_val_if_fail (proto != NULL, FALSE);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- for (iter = priv->proto; iter; iter = g_slist_next (iter)) {
- if (strcasecmp (proto, (char *) iter->data) == 0)
- return FALSE;
- }
-
- priv->proto = g_slist_append (priv->proto, g_ascii_strdown (proto, -1));
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
- return TRUE;
-}
-
-/**
- * nm_setting_wireless_security_remove_proto:
- * @setting: the #NMSettingWirelessSecurity
- * @i: index of the protocol to remove
- *
- * Removes a protocol from the allowed protocol list.
- **/
-void
-nm_setting_wireless_security_remove_proto (NMSettingWirelessSecurity *setting, guint32 i)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->proto, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->proto = g_slist_delete_link (priv->proto, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
-}
-
-/**
- * nm_setting_wireless_security_remove_proto_by_value:
- * @setting: the #NMSettingWirelessSecurity
- * @proto: the protocol to remove, one of "wpa" or "rsn"
- *
- * Removes a protocol from the allowed protocol list.
- *
- * Returns: %TRUE if the protocol was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_wireless_security_remove_proto_by_value (NMSettingWirelessSecurity *setting,
- const char *proto)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
- g_return_val_if_fail (proto != NULL, FALSE);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- for (iter = priv->proto; iter; iter = g_slist_next (iter)) {
- if (strcasecmp (proto, (char *) iter->data) == 0) {
- priv->proto = g_slist_delete_link (priv->proto, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_wireless_security_clear_protos:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Removes all protocols from the allowed list. If there are no protocols
- * specified then all protocols are allowed.
- **/
-void
-nm_setting_wireless_security_clear_protos (NMSettingWirelessSecurity *setting)
-{
- NMSettingWirelessSecurityPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- g_slist_free_full (priv->proto, g_free);
- priv->proto = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
-}
-
-/**
- * nm_setting_wireless_security_get_num_pairwise:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the number of pairwise encryption algorithms in the allowed list
- **/
-guint32
-nm_setting_wireless_security_get_num_pairwise (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
-
- return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->pairwise);
-}
-
-/**
- * nm_setting_wireless_security_get_pairwise:
- * @setting: the #NMSettingWirelessSecurity
- * @i: index of an item in the allowed pairwise encryption algorithm list
- *
- * Returns the allowed pairwise encryption algorithm from allowed algorithm
- * list.
- *
- * Returns: the pairwise encryption algorithm at index @i
- **/
-const char *
-nm_setting_wireless_security_get_pairwise (NMSettingWirelessSecurity *setting, guint32 i)
-{
- NMSettingWirelessSecurityPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->pairwise), NULL);
-
- return (const char *) g_slist_nth_data (priv->pairwise, i);
-}
-
-/**
- * nm_setting_wireless_security_add_pairwise:
- * @setting: the #NMSettingWirelessSecurity
- * @pairwise: the encryption algorithm to add, one of "tkip" or "ccmp"
- *
- * Adds an encryption algorithm to the list of allowed pairwise encryption
- * algorithms. If the list is not empty, then only access points that support
- * one or more of the encryption algorithms in the list will be considered
- * compatible with this connection.
- *
- * Returns: %TRUE if the algorithm was added to the list, %FALSE if it was
- * already in the list
- **/
-gboolean
-nm_setting_wireless_security_add_pairwise (NMSettingWirelessSecurity *setting, const char *pairwise)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
- g_return_val_if_fail (pairwise != NULL, FALSE);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
- if (strcasecmp (pairwise, (char *) iter->data) == 0)
- return FALSE;
- }
-
- priv->pairwise = g_slist_append (priv->pairwise, g_ascii_strdown (pairwise, -1));
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
- return TRUE;
-}
-
-/**
- * nm_setting_wireless_security_remove_pairwise:
- * @setting: the #NMSettingWirelessSecurity
- * @i: the index of an item in the allowed pairwise encryption algorithm list
- *
- * Removes an encryption algorithm from the allowed pairwise encryption
- * algorithm list.
- **/
-void
-nm_setting_wireless_security_remove_pairwise (NMSettingWirelessSecurity *setting, guint32 i)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->pairwise, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->pairwise = g_slist_delete_link (priv->pairwise, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
-}
-
-/**
- * nm_setting_wireless_security_remove_pairwise_by_value:
- * @setting: the #NMSettingWirelessSecurity
- * @pairwise: the encryption algorithm to remove, one of "tkip" or "ccmp"
- *
- * Removes an encryption algorithm from the allowed pairwise encryption
- * algorithm list.
- *
- * Returns: %TRUE if the encryption algorithm was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_wireless_security_remove_pairwise_by_value (NMSettingWirelessSecurity *setting,
- const char *pairwise)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
- g_return_val_if_fail (pairwise != NULL, FALSE);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
- if (strcasecmp (pairwise, (char *) iter->data) == 0) {
- priv->pairwise = g_slist_delete_link (priv->pairwise, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_wireless_security_clear_pairwise:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Removes all algorithms from the allowed list. If there are no algorithms
- * specified then all pairwise encryption algorithms are allowed.
- **/
-void
-nm_setting_wireless_security_clear_pairwise (NMSettingWirelessSecurity *setting)
-{
- NMSettingWirelessSecurityPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- g_slist_free_full (priv->pairwise, g_free);
- priv->pairwise = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
-}
-
-/**
- * nm_setting_wireless_security_get_num_groups:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the number of groupwise encryption algorithms in the allowed list
- **/
-guint32
-nm_setting_wireless_security_get_num_groups (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
-
- return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->group);
-}
-
-/**
- * nm_setting_wireless_security_get_group:
- * @setting: the #NMSettingWirelessSecurity
- * @i: index of an item in the allowed groupwise encryption algorithm list
- *
- * Returns the allowed groupwise encryption algorithm from allowed algorithm
- * list.
- *
- * Returns: the groupwise encryption algorithm at index @i
- **/
-const char *
-nm_setting_wireless_security_get_group (NMSettingWirelessSecurity *setting, guint32 i)
-{
- NMSettingWirelessSecurityPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- g_return_val_if_fail (i <= g_slist_length (priv->group), NULL);
-
- return (const char *) g_slist_nth_data (priv->group, i);
-}
-
-/**
- * nm_setting_wireless_security_add_group:
- * @setting: the #NMSettingWirelessSecurity
- * @group: the encryption algorithm to add, one of "wep40", "wep104",
- * "tkip", or "ccmp"
- *
- * Adds an encryption algorithm to the list of allowed groupwise encryption
- * algorithms. If the list is not empty, then only access points that support
- * one or more of the encryption algorithms in the list will be considered
- * compatible with this connection.
- *
- * Returns: %TRUE if the algorithm was added to the list, %FALSE if it was
- * already in the list
- **/
-gboolean
-nm_setting_wireless_security_add_group (NMSettingWirelessSecurity *setting, const char *group)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
- g_return_val_if_fail (group != NULL, FALSE);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- for (iter = priv->group; iter; iter = g_slist_next (iter)) {
- if (strcasecmp (group, (char *) iter->data) == 0)
- return FALSE;
- }
-
- priv->group = g_slist_append (priv->group, g_ascii_strdown (group, -1));
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
- return TRUE;
-}
-
-/**
- * nm_setting_wireless_security_remove_group:
- * @setting: the #NMSettingWirelessSecurity
- * @i: the index of an item in the allowed groupwise encryption algorithm list
- *
- * Removes an encryption algorithm from the allowed groupwise encryption
- * algorithm list.
- **/
-void
-nm_setting_wireless_security_remove_group (NMSettingWirelessSecurity *setting, guint32 i)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->group, i);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->group = g_slist_delete_link (priv->group, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
-}
-
-/**
- * nm_setting_wireless_security_remove_group_by_value:
- * @setting: the #NMSettingWirelessSecurity
- * @group: the encryption algorithm to remove, one of "wep40", "wep104",
- * "tkip", or "ccmp"
- *
- * Removes an encryption algorithm from the allowed groupwise encryption
- * algorithm list.
- *
- * Returns: %TRUE if the algorithm was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_wireless_security_remove_group_by_value (NMSettingWirelessSecurity *setting,
- const char *group)
-{
- NMSettingWirelessSecurityPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
- g_return_val_if_fail (group != NULL, FALSE);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- for (iter = priv->group; iter; iter = g_slist_next (iter)) {
- if (strcasecmp (group, (char *) iter->data) == 0) {
- priv->group = g_slist_delete_link (priv->group, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_wireless_security_clear_groups:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Removes all algorithms from the allowed list. If there are no algorithms
- * specified then all groupwise encryption algorithms are allowed.
- **/
-void
-nm_setting_wireless_security_clear_groups (NMSettingWirelessSecurity *setting)
-{
- NMSettingWirelessSecurityPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- g_slist_free_full (priv->group, g_free);
- priv->group = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
-}
-
-/**
- * nm_setting_wireless_security_get_psk:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingWirelessSecurity:psk property of the setting
- **/
-const char *
-nm_setting_wireless_security_get_psk (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk;
-}
-
-/**
- * nm_setting_wireless_security_get_psk_flags:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingSecretFlags pertaining to the
- * #NMSettingWirelessSecurity:psk
- **/
-NMSettingSecretFlags
-nm_setting_wireless_security_get_psk_flags (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk_flags;
-}
-
-/**
- * nm_setting_wireless_security_get_leap_username:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingWirelessSecurity:leap-username property of the setting
- **/
-const char *
-nm_setting_wireless_security_get_leap_username (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_username;
-}
-
-/**
- * nm_setting_wireless_security_get_leap_password:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingWirelessSecurity:leap-password property of the setting
- **/
-const char *
-nm_setting_wireless_security_get_leap_password (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_password;
-}
-
-/**
- * nm_setting_wireless_security_get_leap_password_flags:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingSecretFlags pertaining to the
- * #NMSettingWirelessSecurity:leap-password
- **/
-NMSettingSecretFlags
-nm_setting_wireless_security_get_leap_password_flags (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_password_flags;
-}
-
-/**
- * nm_setting_wireless_security_get_wep_key:
- * @setting: the #NMSettingWirelessSecurity
- * @idx: the WEP key index (0..3 inclusive)
- *
- * Returns: the WEP key at the given index
- **/
-const char *
-nm_setting_wireless_security_get_wep_key (NMSettingWirelessSecurity *setting, guint32 idx)
-{
- NMSettingWirelessSecurityPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
- g_return_val_if_fail (idx < 4, NULL);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- if (idx == 0)
- return priv->wep_key0;
- else if (idx == 1)
- return priv->wep_key1;
- else if (idx == 2)
- return priv->wep_key2;
- else if (idx == 3)
- return priv->wep_key3;
-
- g_assert_not_reached ();
- return NULL;
-}
-
-/**
- * nm_setting_wireless_security_set_wep_key:
- * @setting: the #NMSettingWirelessSecurity
- * @idx: the index of the key (0..3 inclusive)
- * @key: the WEP key as a string, in either hexadecimal, ASCII, or passphrase
- * form as determiend by the value of the #NMSettingWirelessSecurity:wep-key-type
- * property.
- *
- * Sets a WEP key in the given index.
- **/
-void
-nm_setting_wireless_security_set_wep_key (NMSettingWirelessSecurity *setting, guint32 idx, const char *key)
-{
- NMSettingWirelessSecurityPrivate *priv;
-
- g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
- g_return_if_fail (idx < 4);
-
- priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- switch (idx) {
- case 0:
- g_free (priv->wep_key0);
- priv->wep_key0 = g_strdup (key);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
- break;
- case 1:
- g_free (priv->wep_key1);
- priv->wep_key1 = g_strdup (key);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
- break;
- case 2:
- g_free (priv->wep_key2);
- priv->wep_key2 = g_strdup (key);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
- break;
- case 3:
- g_free (priv->wep_key3);
- priv->wep_key3 = g_strdup (key);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
- break;
- default:
- g_assert_not_reached ();
- }
-}
-
-/**
- * nm_setting_wireless_security_get_wep_tx_keyidx:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingWirelessSecurity:wep-tx-keyidx property of the setting
- **/
-guint32
-nm_setting_wireless_security_get_wep_tx_keyidx (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_tx_keyidx;
-}
-
-/**
- * nm_setting_wireless_security_get_auth_alg:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingWirelessSecurity:auth-alg property of the setting
- **/
-const char *
-nm_setting_wireless_security_get_auth_alg (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->auth_alg;
-}
-
-/**
- * nm_setting_wireless_security_get_wep_key_flags:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingSecretFlags pertaining to the all WEP keys
- **/
-NMSettingSecretFlags
-nm_setting_wireless_security_get_wep_key_flags (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_key_flags;
-}
-
-/**
- * nm_setting_wireless_security_get_wep_key_type:
- * @setting: the #NMSettingWirelessSecurity
- *
- * Returns: the #NMSettingWirelessSecurity:wep-key-type property of the setting
- **/
-NMWepKeyType
-nm_setting_wireless_security_get_wep_key_type (NMSettingWirelessSecurity *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
-
- return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_key_type;
-}
-
-static GPtrArray *
-need_secrets (NMSetting *setting)
-{
- NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
- NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
- GPtrArray *secrets;
-
- secrets = g_ptr_array_sized_new (4);
-
- g_assert (priv->key_mgmt);
-
- /* Static WEP */
- if (strcmp (priv->key_mgmt, "none") == 0) {
- if ((priv->wep_tx_keyidx == 0) && !nm_utils_wep_key_valid (priv->wep_key0, priv->wep_key_type)) {
- g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
- return secrets;
- }
- if ((priv->wep_tx_keyidx == 1) && !nm_utils_wep_key_valid (priv->wep_key1, priv->wep_key_type)) {
- g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
- return secrets;
- }
- if ((priv->wep_tx_keyidx == 2) && !nm_utils_wep_key_valid (priv->wep_key2, priv->wep_key_type)) {
- g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
- return secrets;
- }
- if ((priv->wep_tx_keyidx == 3) && !nm_utils_wep_key_valid (priv->wep_key3, priv->wep_key_type)) {
- g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
- return secrets;
- }
- goto no_secrets;
- }
-
- /* WPA-PSK infrastructure and adhoc */
- if ( (strcmp (priv->key_mgmt, "wpa-none") == 0)
- || (strcmp (priv->key_mgmt, "wpa-psk") == 0)) {
- if (!nm_utils_wpa_psk_valid (priv->psk)) {
- g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_PSK);
- return secrets;
- }
- goto no_secrets;
- }
-
- /* LEAP */
- if ( priv->auth_alg
- && !strcmp (priv->auth_alg, "leap")
- && !strcmp (priv->key_mgmt, "ieee8021x")) {
- if (!priv->leap_password || !*priv->leap_password) {
- g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
- return secrets;
- }
- goto no_secrets;
- }
-
- if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
- || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
- /* Let caller check the 802.1x setting for secrets */
- goto no_secrets;
- }
-
- g_assert_not_reached ();
- return secrets;
-
-no_secrets:
- if (secrets)
- g_ptr_array_free (secrets, TRUE);
- return NULL;
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
- NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
- const char *valid_key_mgmt[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", 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 };
-
- if (!priv->key_mgmt) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
- return FALSE;
- }
-
- if (!g_strv_contains (valid_key_mgmt, priv->key_mgmt)) {
- g_set_error (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid value for the property"),
- priv->key_mgmt);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
- return FALSE;
- }
-
- if (priv->auth_alg && !strcmp (priv->auth_alg, "leap")) {
- /* LEAP must use ieee8021x key management */
- if (strcmp (priv->key_mgmt, "ieee8021x")) {
- g_set_error (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X,
- _("'%s' security requires '%s=%s'"),
- "leap", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x");
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
- return FALSE;
- }
- if (!priv->leap_username) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
- return FALSE;
- }
- } else {
- if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
- || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
- /* Need an 802.1x setting too */
- if (!nm_setting_find_in_list (all_settings, NM_SETTING_802_1X_SETTING_NAME)) {
- g_set_error (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING,
- _("'%s' security requires '%s' setting presence"),
- priv->key_mgmt, NM_SETTING_802_1X_SETTING_NAME);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
- return FALSE;
- }
- }
- }
-
- if (priv->leap_username && !strlen (priv->leap_username)) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
- return FALSE;
- }
-
- if (priv->wep_tx_keyidx > 3) {
- g_set_error (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("'%d' value is out of range <0-3>"),
- priv->wep_tx_keyidx);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX);
- return FALSE;
- }
-
- if (priv->wep_key_type > NM_WEP_KEY_TYPE_LAST) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE);
- return FALSE;
- }
-
- if (priv->auth_alg && !g_strv_contains (valid_auth_algs, priv->auth_alg)) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
- return FALSE;
- }
-
- if (priv->proto && !_nm_utils_string_slist_validate (priv->proto, valid_protos)) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PROTO);
- return FALSE;
- }
-
- if (priv->pairwise) {
- const char *wpa_none[] = { "wpa-none", NULL };
-
- /* For ad-hoc connections, pairwise must be "none" */
- if (g_strv_contains (wpa_none, priv->key_mgmt)) {
- GSList *iter;
- gboolean found = FALSE;
-
- for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
- if (!strcmp ((char *) iter->data, "none")) {
- found = TRUE;
- break;
- }
- }
-
- /* pairwise cipher list didn't contain "none", which is invalid
- * for WPA adhoc connections.
- */
- if (!found) {
- g_set_error (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("'%s' connections require '%s' in this property"),
- NM_SETTING_WIRELESS_MODE_ADHOC, "none");
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
- return FALSE;
- }
- } else if (!_nm_utils_string_slist_validate (priv->pairwise, valid_pairwise)) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
- return FALSE;
- }
- }
-
- if (priv->group && !_nm_utils_string_slist_validate (priv->group, valid_groups)) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_GROUP);
- return FALSE;
- }
-
- /* Shared Key auth can only be used with WEP */
- if (priv->auth_alg && !strcmp (priv->auth_alg, "shared")) {
- if (priv->key_mgmt && strcmp (priv->key_mgmt, "none")) {
- g_set_error (error,
- NM_SETTING_WIRELESS_SECURITY_ERROR,
- NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP,
- _("'%s' can only be used with '%s=%s' (WEP)"),
- "shared", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none");
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-get_secret_flags (NMSetting *setting,
- const char *secret_name,
- gboolean verify_secret,
- NMSettingSecretFlags *out_flags,
- GError **error)
-{
- NMSettingClass *setting_class;
- gboolean verify_override = verify_secret;
-
- /* There's only one 'flags' property for WEP keys, so alias all the WEP key
- * property names to that flags property.
- */
- if ( !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)
- || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)
- || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)
- || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)) {
- secret_name = "wep-key";
- verify_override = FALSE; /* Already know it's a secret */
- }
-
- /* Chain up to superclass with modified key name */
- setting_class = NM_SETTING_CLASS (nm_setting_wireless_security_parent_class);
- return setting_class->get_secret_flags (setting, secret_name, verify_override, out_flags, error);
-}
-
-static gboolean
-set_secret_flags (NMSetting *setting,
- const char *secret_name,
- gboolean verify_secret,
- NMSettingSecretFlags flags,
- GError **error)
-{
- NMSettingClass *setting_class;
- gboolean verify_override = verify_secret;
-
- /* There's only one 'flags' property for WEP keys, so alias all the WEP key
- * property names to that flags property.
- */
- if ( !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)
- || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)
- || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)
- || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)) {
- secret_name = "wep-key";
- verify_override = FALSE; /* Already know it's a secret */
- }
-
- /* Chain up to superclass with modified key name */
- setting_class = NM_SETTING_CLASS (nm_setting_wireless_security_parent_class);
- return setting_class->set_secret_flags (setting, secret_name, verify_override, flags, error);
-}
-
-static void
-nm_setting_wireless_security_init (NMSettingWirelessSecurity *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (object);
- NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
-
- /* Strings first. g_free() already checks for NULLs so we don't have to */
-
- g_free (priv->key_mgmt);
- g_free (priv->auth_alg);
- g_free (priv->leap_username);
- g_free (priv->wep_key0);
- g_free (priv->wep_key1);
- g_free (priv->wep_key2);
- g_free (priv->wep_key3);
- g_free (priv->psk);
- g_free (priv->leap_password);
-
- g_slist_free_full (priv->proto, g_free);
- g_slist_free_full (priv->pairwise, g_free);
- g_slist_free_full (priv->group, g_free);
-
- G_OBJECT_CLASS (nm_setting_wireless_security_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY (object);
- NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
- const char *str;
-
- switch (prop_id) {
- case PROP_KEY_MGMT:
- g_free (priv->key_mgmt);
- str = g_value_get_string (value);
- priv->key_mgmt = str ? g_ascii_strdown (str, -1) : NULL;
- break;
- case PROP_WEP_TX_KEYIDX:
- priv->wep_tx_keyidx = g_value_get_uint (value);
- break;
- case PROP_AUTH_ALG:
- g_free (priv->auth_alg);
- str = g_value_get_string (value);
- priv->auth_alg = str ? g_ascii_strdown (str, -1) : NULL;
- break;
- case PROP_PROTO:
- g_slist_free_full (priv->proto, g_free);
- priv->proto = g_value_dup_boxed (value);
- break;
- case PROP_PAIRWISE:
- g_slist_free_full (priv->pairwise, g_free);
- priv->pairwise = g_value_dup_boxed (value);
- break;
- case PROP_GROUP:
- g_slist_free_full (priv->group, g_free);
- priv->group = g_value_dup_boxed (value);
- break;
- case PROP_LEAP_USERNAME:
- g_free (priv->leap_username);
- priv->leap_username = g_value_dup_string (value);
- break;
- case PROP_WEP_KEY0:
- g_free (priv->wep_key0);
- priv->wep_key0 = g_value_dup_string (value);
- break;
- case PROP_WEP_KEY1:
- g_free (priv->wep_key1);
- priv->wep_key1 = g_value_dup_string (value);
- break;
- case PROP_WEP_KEY2:
- g_free (priv->wep_key2);
- priv->wep_key2 = g_value_dup_string (value);
- break;
- case PROP_WEP_KEY3:
- g_free (priv->wep_key3);
- priv->wep_key3 = g_value_dup_string (value);
- break;
- case PROP_WEP_KEY_FLAGS:
- priv->wep_key_flags = g_value_get_uint (value);
- break;
- case PROP_PSK:
- g_free (priv->psk);
- priv->psk = g_value_dup_string (value);
- break;
- case PROP_PSK_FLAGS:
- priv->psk_flags = g_value_get_uint (value);
- break;
- case PROP_LEAP_PASSWORD:
- g_free (priv->leap_password);
- priv->leap_password = g_value_dup_string (value);
- break;
- case PROP_LEAP_PASSWORD_FLAGS:
- priv->leap_password_flags = g_value_get_uint (value);
- break;
- case PROP_WEP_KEY_TYPE:
- priv->wep_key_type = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY (object);
- NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
-
- switch (prop_id) {
- case PROP_KEY_MGMT:
- g_value_set_string (value, priv->key_mgmt);
- break;
- case PROP_WEP_TX_KEYIDX:
- g_value_set_uint (value, priv->wep_tx_keyidx);
- break;
- case PROP_AUTH_ALG:
- g_value_set_string (value, priv->auth_alg);
- break;
- case PROP_PROTO:
- g_value_set_boxed (value, priv->proto);
- break;
- case PROP_PAIRWISE:
- g_value_set_boxed (value, priv->pairwise);
- break;
- case PROP_GROUP:
- g_value_set_boxed (value, priv->group);
- break;
- case PROP_LEAP_USERNAME:
- g_value_set_string (value, priv->leap_username);
- break;
- case PROP_WEP_KEY0:
- g_value_set_string (value, priv->wep_key0);
- break;
- case PROP_WEP_KEY1:
- g_value_set_string (value, priv->wep_key1);
- break;
- case PROP_WEP_KEY2:
- g_value_set_string (value, priv->wep_key2);
- break;
- case PROP_WEP_KEY3:
- g_value_set_string (value, priv->wep_key3);
- break;
- case PROP_WEP_KEY_FLAGS:
- g_value_set_uint (value, priv->wep_key_flags);
- break;
- case PROP_PSK:
- g_value_set_string (value, priv->psk);
- break;
- case PROP_PSK_FLAGS:
- g_value_set_uint (value, priv->psk_flags);
- break;
- case PROP_LEAP_PASSWORD:
- g_value_set_string (value, priv->leap_password);
- break;
- case PROP_LEAP_PASSWORD_FLAGS:
- g_value_set_uint (value, priv->leap_password_flags);
- break;
- case PROP_WEP_KEY_TYPE:
- g_value_set_uint (value, priv->wep_key_type);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingWirelessSecurityPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
-
- parent_class->verify = verify;
- parent_class->need_secrets = need_secrets;
- parent_class->get_secret_flags = get_secret_flags;
- parent_class->set_secret_flags = set_secret_flags;
-
- /* Properties */
- /**
- * NMSettingWirelessSecurity:key-mgmt:
- *
- * Key management used for the connection. One of "none" (WEP), "ieee8021x"
- * (Dynamic WEP), "wpa-none" (Ad-Hoc WPA-PSK), "wpa-psk" (infrastructure
- * WPA-PSK), or "wpa-eap" (WPA-Enterprise). This property must be set for
- * any Wi-Fi connection that uses security.
- **/
- g_object_class_install_property
- (object_class, PROP_KEY_MGMT,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_REQUIRED |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:wep-tx-keyidx:
- *
- * When static WEP is used (ie, key-mgmt = "none") and a non-default WEP key
- * index is used by the AP, put that WEP key index here. Valid values are 0
- * (default key) through 3. Note that some consumer access points (like the
- * Linksys WRT54G) number the keys 1 - 4.
- **/
- g_object_class_install_property
- (object_class, PROP_WEP_TX_KEYIDX,
- g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, "", "",
- 0, 3, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:auth-alg:
- *
- * When WEP is used (ie, key-mgmt = "none" or "ieee8021x") indicate the
- * 802.11 authentication algorithm required by the AP here. One of "open"
- * for Open System, "shared" for Shared Key, or "leap" for Cisco LEAP. When
- * using Cisco LEAP (ie, key-mgmt = "ieee8021x" and auth-alg = "leap") the
- * "leap-username" and "leap-password" properties must be specified.
- **/
- g_object_class_install_property
- (object_class, PROP_AUTH_ALG,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:proto:
- *
- * List of strings specifying the allowed WPA protocol versions to use.
- * Each element may be one "wpa" (allow WPA) or "rsn" (allow WPA2/RSN). If
- * not specified, both WPA and RSN connections are allowed.
- **/
- g_object_class_install_property
- (object_class, PROP_PROTO,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_PROTO, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:pairwise:
- *
- * A list of pairwise encryption algorithms which prevents connections to
- * Wi-Fi networks that do not utilize one of the algorithms in the list.
- * For maximum compatibility leave this property empty. Each list element
- * may be one of "tkip" or "ccmp".
- **/
- g_object_class_install_property
- (object_class, PROP_PAIRWISE,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_PAIRWISE, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:group:
- *
- * A list of group/broadcast encryption algorithms which prevents
- * connections to Wi-Fi networks that do not utilize one of the algorithms
- * in the list. For maximum compatibility leave this property empty. Each
- * list element may be one of "wep40", "wep104", "tkip", or "ccmp".
- **/
- g_object_class_install_property
- (object_class, PROP_GROUP,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_GROUP, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:leap-username:
- *
- * The login username for legacy LEAP connections (ie, key-mgmt =
- * "ieee8021x" and auth-alg = "leap").
- **/
- g_object_class_install_property
- (object_class, PROP_LEAP_USERNAME,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:wep-key0:
- *
- * Index 0 WEP key. This is the WEP key used in most networks. See the
- * "wep-key-type" property for a description of how this key is interpreted.
- **/
- g_object_class_install_property
- (object_class, PROP_WEP_KEY0,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:wep-key1:
- *
- * Index 1 WEP key. This WEP index is not used by most networks. See the
- * "wep-key-type" property for a description of how this key is interpreted.
- **/
- g_object_class_install_property
- (object_class, PROP_WEP_KEY1,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:wep-key2:
- *
- * Index 2 WEP key. This WEP index is not used by most networks. See the
- * "wep-key-type" property for a description of how this key is interpreted.
- **/
- g_object_class_install_property
- (object_class, PROP_WEP_KEY2,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:wep-key3:
- *
- * Index 3 WEP key. This WEP index is not used by most networks. See the
- * "wep-key-type" property for a description of how this key is interpreted.
- **/
- g_object_class_install_property
- (object_class, PROP_WEP_KEY3,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:wep-key-flags:
- *
- * Flags indicating how to handle the #NMSettingWirelessSecurity:wep-key0,
- * #NMSettingWirelessSecurity:wep-key1, #NMSettingWirelessSecurity:wep-key2,
- * and #NMSettingWirelessSecurity:wep-key3 properties.
- **/
- g_object_class_install_property
- (object_class, PROP_WEP_KEY_FLAGS,
- g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:psk:
- *
- * Pre-Shared-Key for WPA networks. If the key is 64-characters long, it
- * must contain only hexadecimal characters and is interpreted as a
- * hexadecimal WPA key. Otherwise, the key must be between 8 and 63 ASCII
- * characters (as specified in the 802.11i standard) and is interpreted as a
- * WPA passphrase, and is hashed to derive the actual WPA-PSK used when
- * connecting to the Wi-Fi network.
- **/
- g_object_class_install_property
- (object_class, PROP_PSK,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_PSK, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:psk-flags:
- *
- * Flags indicating how to handle the #NMSettingWirelessSecurity:psk
- * property.
- **/
- g_object_class_install_property
- (object_class, PROP_PSK_FLAGS,
- g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:leap-password:
- *
- * The login password for legacy LEAP connections (ie, key-mgmt =
- * "ieee8021x" and auth-alg = "leap").
- **/
- g_object_class_install_property
- (object_class, PROP_LEAP_PASSWORD,
- g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, "", "",
- NULL,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_SECRET |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:leap-password-flags:
- *
- * Flags indicating how to handle the
- * #NMSettingWirelessSecurity:leap-password property.
- **/
- g_object_class_install_property
- (object_class, PROP_LEAP_PASSWORD_FLAGS,
- g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, "", "",
- NM_SETTING_SECRET_FLAG_NONE,
- NM_SETTING_SECRET_FLAGS_ALL,
- NM_SETTING_SECRET_FLAG_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWirelessSecurity:wep-key-type:
- *
- * Controls the interpretation of WEP keys. Allowed values are
- * %NM_WEP_KEY_TYPE_KEY, in which case the key is either a 10- or
- * 26-character hexadecimal string, or a 5- or 13-character ASCII password;
- * or %NM_WEP_KEY_TYPE_PASSPHRASE, in which case the passphrase is provided
- * as a string and will be hashed using the de-facto MD5 method to derive
- * the actual WEP key.
- **/
- g_object_class_install_property
- (object_class, PROP_WEP_KEY_TYPE,
- g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, "", "",
- NM_WEP_KEY_TYPE_UNKNOWN,
- NM_WEP_KEY_TYPE_LAST,
- NM_WEP_KEY_TYPE_UNKNOWN,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-wireless-security.h b/libnm-util/nm-setting-wireless-security.h
deleted file mode 100644
index cbeeb9bfaf..0000000000
--- a/libnm-util/nm-setting-wireless-security.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_WIRELESS_SECURITY_H
-#define NM_SETTING_WIRELESS_SECURITY_H
-
-#include "nm-setting.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_get_type ())
-#define NM_SETTING_WIRELESS_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurity))
-#define NM_SETTING_WIRELESS_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityClass))
-#define NM_IS_SETTING_WIRELESS_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_WIRELESS_SECURITY))
-#define NM_IS_SETTING_WIRELESS_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_WIRELESS_SECURITY))
-#define NM_SETTING_WIRELESS_SECURITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityClass))
-
-#define NM_SETTING_WIRELESS_SECURITY_SETTING_NAME "802-11-wireless-security"
-
-/**
- * NMSettingWirelessSecurityError:
- * @NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY: the property was
- * missing and is required
- * @NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING: a property contained
- * a value that requires the connection to contain a #NMSetting8021x setting
- * @NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X: LEAP authentication
- * was specified but key management was not set to "8021x"
- * @NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME: LEAP authentication
- * was specified but no LEAP username was given
- * @NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP: Shared Key
- * authentication was specified but the setting did not specify WEP as the
- * encryption protocol
- */
-typedef enum {
- NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING, /*< nick=Missing8021xSetting >*/
- NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X, /*< nick=LEAPRequires8021x >*/
- NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, /*< nick=LEAPRequiresUsername >*/
- NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP /*< nick=SharedKeyRequiresWEP >*/
-} NMSettingWirelessSecurityError;
-
-#define NM_SETTING_WIRELESS_SECURITY_ERROR nm_setting_wireless_security_error_quark ()
-GQuark nm_setting_wireless_security_error_quark (void);
-
-/**
- * NMWepKeyType:
- * @NM_WEP_KEY_TYPE_UNKNOWN: unknown WEP key type
- * @NM_WEP_KEY_TYPE_KEY: indicates a hexadecimal or ASCII formatted WEP key.
- * Hex keys are either 10 or 26 hexadecimal characters (ie "5f782f2f5f" or
- * "732f2d712e4a394a375d366931"), while ASCII keys are either 5 or 13 ASCII
- * characters (ie "abcde" or "blahblah99$*1").
- * @NM_WEP_KEY_TYPE_PASSPHRASE: indicates a WEP passphrase (ex "I bought a duck
- * on my way back from the market 235Q&^%^*%") instead of a hexadecimal or ASCII
- * key. Passphrases are between 8 and 64 characters inclusive and are hashed
- * the actual WEP key using the MD5 hash algorithm.
- * @NM_WEP_KEY_TYPE_LAST: placeholder value for bounds-checking
- *
- * The #NMWepKeyType values specify how any WEP keys present in the setting
- * are interpreted. There are no standards governing how to hash the various WEP
- * key/passphrase formats into the actual WEP key. Unfortunately some WEP keys
- * can be interpreted in multiple ways, requiring the setting to specify how to
- * interpret the any WEP keys. For example, the key "732f2d712e4a394a375d366931"
- * is both a valid Hexadecimal WEP key and a WEP passphrase. Further, many
- * ASCII keys are also valid WEP passphrases, but since passphrases and ASCII
- * keys are hashed differently to determine the actual WEP key the type must be
- * specified.
- */
-typedef enum {
- NM_WEP_KEY_TYPE_UNKNOWN = 0,
- NM_WEP_KEY_TYPE_KEY = 1, /* Hex or ASCII */
- NM_WEP_KEY_TYPE_PASSPHRASE = 2, /* 104/128-bit Passphrase */
-
- NM_WEP_KEY_TYPE_LAST = NM_WEP_KEY_TYPE_PASSPHRASE
-} NMWepKeyType;
-
-#define NM_SETTING_WIRELESS_SECURITY_KEY_MGMT "key-mgmt"
-#define NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX "wep-tx-keyidx"
-#define NM_SETTING_WIRELESS_SECURITY_AUTH_ALG "auth-alg"
-#define NM_SETTING_WIRELESS_SECURITY_PROTO "proto"
-#define NM_SETTING_WIRELESS_SECURITY_PAIRWISE "pairwise"
-#define NM_SETTING_WIRELESS_SECURITY_GROUP "group"
-#define NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME "leap-username"
-#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY0 "wep-key0"
-#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY1 "wep-key1"
-#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY2 "wep-key2"
-#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY3 "wep-key3"
-#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS "wep-key-flags"
-#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE "wep-key-type"
-#define NM_SETTING_WIRELESS_SECURITY_PSK "psk"
-#define NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS "psk-flags"
-#define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD "leap-password"
-#define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS "leap-password-flags"
-
-typedef struct {
- NMSetting parent;
-} NMSettingWirelessSecurity;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingWirelessSecurityClass;
-
-GType nm_setting_wireless_security_get_type (void);
-
-NMSetting * nm_setting_wireless_security_new (void);
-
-const char *nm_setting_wireless_security_get_key_mgmt (NMSettingWirelessSecurity *setting);
-
-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);
-void nm_setting_wireless_security_remove_proto (NMSettingWirelessSecurity *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_wireless_security_remove_proto_by_value (NMSettingWirelessSecurity *setting, 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);
-void nm_setting_wireless_security_remove_pairwise (NMSettingWirelessSecurity *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_wireless_security_remove_pairwise_by_value (NMSettingWirelessSecurity *setting, 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);
-void nm_setting_wireless_security_remove_group (NMSettingWirelessSecurity *setting, guint32 i);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_wireless_security_remove_group_by_value (NMSettingWirelessSecurity *setting, const char *group);
-void nm_setting_wireless_security_clear_groups (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);
-const char *nm_setting_wireless_security_get_leap_password (NMSettingWirelessSecurity *setting);
-NMSettingSecretFlags nm_setting_wireless_security_get_leap_password_flags (NMSettingWirelessSecurity *setting);
-
-const char *nm_setting_wireless_security_get_wep_key (NMSettingWirelessSecurity *setting, guint32 idx);
-void nm_setting_wireless_security_set_wep_key (NMSettingWirelessSecurity *setting, guint32 idx, 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);
-
-NMSettingSecretFlags nm_setting_wireless_security_get_wep_key_flags (NMSettingWirelessSecurity *setting);
-NMWepKeyType nm_setting_wireless_security_get_wep_key_type (NMSettingWirelessSecurity *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_WIRELESS_SECURITY_H */
diff --git a/libnm-util/nm-setting-wireless.c b/libnm-util/nm-setting-wireless.c
deleted file mode 100644
index d3040811c8..0000000000
--- a/libnm-util/nm-setting-wireless.c
+++ /dev/null
@@ -1,1286 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-#include <net/ethernet.h>
-#include <netinet/ether.h>
-#include <dbus/dbus-glib.h>
-
-#include "NetworkManager.h"
-#include "nm-setting-wireless.h"
-#include "nm-param-spec-specialized.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-utils-private.h"
-#include "nm-setting-private.h"
-
-/**
- * SECTION:nm-setting-wireless
- * @short_description: Describes connection properties for 802.11 Wi-Fi networks
- * @include: nm-setting-wireless.h
- *
- * The #NMSettingWireless object is a #NMSetting subclass that describes properties
- * necessary for connection to 802.11 Wi-Fi networks.
- **/
-
-/**
- * nm_setting_wireless_error_quark:
- *
- * Registers an error quark for #NMSettingWireless if necessary.
- *
- * Returns: the error quark used for #NMSettingWireless errors.
- **/
-GQuark
-nm_setting_wireless_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-wireless-error-quark");
- return quark;
-}
-
-G_DEFINE_TYPE_WITH_CODE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING,
- _nm_register_setting (NM_SETTING_WIRELESS_SETTING_NAME,
- g_define_type_id,
- 1,
- NM_SETTING_WIRELESS_ERROR))
-NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS)
-
-#define NM_SETTING_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessPrivate))
-
-typedef struct {
- GByteArray *ssid;
- char *mode;
- char *band;
- guint32 channel;
- GByteArray *bssid;
- guint32 rate;
- guint32 tx_power;
- GByteArray *device_mac_address;
- GByteArray *cloned_mac_address;
- GSList *mac_address_blacklist;
- guint32 mtu;
- GSList *seen_bssids;
- char *security;
- gboolean hidden;
- guint32 powersave;
-} NMSettingWirelessPrivate;
-
-enum {
- PROP_0,
- PROP_SSID,
- PROP_MODE,
- PROP_BAND,
- PROP_CHANNEL,
- PROP_BSSID,
- PROP_RATE,
- PROP_TX_POWER,
- PROP_MAC_ADDRESS,
- PROP_CLONED_MAC_ADDRESS,
- PROP_MAC_ADDRESS_BLACKLIST,
- PROP_MTU,
- PROP_SEEN_BSSIDS,
- PROP_SEC,
- PROP_HIDDEN,
- PROP_POWERSAVE,
-
- LAST_PROP
-};
-
-static gboolean
-match_cipher (const char *cipher,
- const char *expected,
- guint32 wpa_flags,
- guint32 rsn_flags,
- guint32 flag)
-{
- if (strcmp (cipher, expected) != 0)
- return FALSE;
-
- if (!(wpa_flags & flag) && !(rsn_flags & flag))
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * nm_setting_wireless_ap_security_compatible:
- * @s_wireless: a #NMSettingWireless
- * @s_wireless_sec: a #NMSettingWirelessSecurity or %NULL
- * @ap_flags: the %NM80211ApFlags of the given access point
- * @ap_wpa: the %NM80211ApSecurityFlags of the given access point's WPA
- * capabilities
- * @ap_rsn: the %NM80211ApSecurityFlags of the given access point's WPA2/RSN
- * capabilities
- * @ap_mode: the 802.11 mode of the AP, either Ad-Hoc or Infrastructure
- *
- * Given a #NMSettingWireless and an optional #NMSettingWirelessSecurity,
- * determine if the configuration given by the settings is compatible with
- * the security of an access point using that access point's capability flags
- * and mode. Useful for clients that wish to filter a set of connections
- * against a set of access points and determine which connections are
- * compatible with which access points.
- *
- * Returns: %TRUE if the given settings are compatible with the access point's
- * security flags and mode, %FALSE if they are not.
- */
-gboolean
-nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless,
- NMSettingWirelessSecurity *s_wireless_sec,
- NM80211ApFlags ap_flags,
- NM80211ApSecurityFlags ap_wpa,
- NM80211ApSecurityFlags ap_rsn,
- NM80211Mode ap_mode)
-{
- const char *key_mgmt = NULL, *cipher;
- guint32 num, i;
- gboolean found = FALSE;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (s_wireless), FALSE);
-
- if (!s_wireless_sec) {
- if ( (ap_flags & NM_802_11_AP_FLAGS_PRIVACY)
- || (ap_wpa != NM_802_11_AP_SEC_NONE)
- || (ap_rsn != NM_802_11_AP_SEC_NONE))
- return FALSE;
- return TRUE;
- }
-
- key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
- if (!key_mgmt)
- return FALSE;
-
- /* Static WEP */
- if (!strcmp (key_mgmt, "none")) {
- if ( !(ap_flags & NM_802_11_AP_FLAGS_PRIVACY)
- || (ap_wpa != NM_802_11_AP_SEC_NONE)
- || (ap_rsn != NM_802_11_AP_SEC_NONE))
- return FALSE;
- return TRUE;
- }
-
- /* Adhoc WPA */
- if (!strcmp (key_mgmt, "wpa-none")) {
- if (ap_mode != NM_802_11_MODE_ADHOC)
- return FALSE;
- /* FIXME: validate ciphers if they're in the beacon */
- return TRUE;
- }
-
- /* Adhoc WPA2 (ie, RSN IBSS) */
- if (ap_mode == NM_802_11_MODE_ADHOC) {
- if (strcmp (key_mgmt, "wpa-psk"))
- return FALSE;
-
- /* Ensure the AP has RSN PSK capability */
- if (!(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK))
- return FALSE;
-
- /* Fall through and check ciphers in generic WPA-PSK code */
- }
-
- /* Dynamic WEP or LEAP */
- if (!strcmp (key_mgmt, "ieee8021x")) {
- if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
- return FALSE;
-
- /* If the AP is advertising a WPA IE, make sure it supports WEP ciphers */
- if (ap_wpa != NM_802_11_AP_SEC_NONE) {
- if (!(ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
- return FALSE;
-
- /* quick check; can't use AP if it doesn't support at least one
- * WEP cipher in both pairwise and group suites.
- */
- if ( !(ap_wpa & (NM_802_11_AP_SEC_PAIR_WEP40 | NM_802_11_AP_SEC_PAIR_WEP104))
- || !(ap_wpa & (NM_802_11_AP_SEC_GROUP_WEP40 | NM_802_11_AP_SEC_GROUP_WEP104)))
- return FALSE;
-
- /* Match at least one pairwise cipher with AP's capability if the
- * wireless-security setting explicitly lists pairwise ciphers
- */
- num = nm_setting_wireless_security_get_num_pairwise (s_wireless_sec);
- for (i = 0, found = FALSE; i < num; i++) {
- cipher = nm_setting_wireless_security_get_pairwise (s_wireless_sec, i);
- if ((found = match_cipher (cipher, "wep40", ap_wpa, ap_wpa, NM_802_11_AP_SEC_PAIR_WEP40)))
- break;
- if ((found = match_cipher (cipher, "wep104", ap_wpa, ap_wpa, NM_802_11_AP_SEC_PAIR_WEP104)))
- break;
- }
- if (!found && num)
- return FALSE;
-
- /* Match at least one group cipher with AP's capability if the
- * wireless-security setting explicitly lists group ciphers
- */
- num = nm_setting_wireless_security_get_num_groups (s_wireless_sec);
- for (i = 0, found = FALSE; i < num; i++) {
- cipher = nm_setting_wireless_security_get_group (s_wireless_sec, i);
- if ((found = match_cipher (cipher, "wep40", ap_wpa, ap_wpa, NM_802_11_AP_SEC_GROUP_WEP40)))
- break;
- if ((found = match_cipher (cipher, "wep104", ap_wpa, ap_wpa, NM_802_11_AP_SEC_GROUP_WEP104)))
- break;
- }
- if (!found && num)
- return FALSE;
- }
- return TRUE;
- }
-
- /* WPA[2]-PSK and WPA[2] Enterprise */
- if ( !strcmp (key_mgmt, "wpa-psk")
- || !strcmp (key_mgmt, "wpa-eap")) {
-
- if (!strcmp (key_mgmt, "wpa-psk")) {
- if ( !(ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_PSK)
- && !(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK))
- return FALSE;
- } else if (!strcmp (key_mgmt, "wpa-eap")) {
- if ( !(ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
- && !(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
- return FALSE;
- }
-
- // FIXME: should handle WPA and RSN separately here to ensure that
- // if the Connection only uses WPA we don't match a cipher against
- // the AP's RSN IE instead
-
- /* Match at least one pairwise cipher with AP's capability if the
- * wireless-security setting explicitly lists pairwise ciphers
- */
- num = nm_setting_wireless_security_get_num_pairwise (s_wireless_sec);
- for (i = 0, found = FALSE; i < num; i++) {
- cipher = nm_setting_wireless_security_get_pairwise (s_wireless_sec, i);
- if ((found = match_cipher (cipher, "tkip", ap_wpa, ap_rsn, NM_802_11_AP_SEC_PAIR_TKIP)))
- break;
- if ((found = match_cipher (cipher, "ccmp", ap_wpa, ap_rsn, NM_802_11_AP_SEC_PAIR_CCMP)))
- break;
- }
- if (!found && num)
- return FALSE;
-
- /* Match at least one group cipher with AP's capability if the
- * wireless-security setting explicitly lists group ciphers
- */
- num = nm_setting_wireless_security_get_num_groups (s_wireless_sec);
- for (i = 0, found = FALSE; i < num; i++) {
- cipher = nm_setting_wireless_security_get_group (s_wireless_sec, i);
-
- if ((found = match_cipher (cipher, "wep40", ap_wpa, ap_rsn, NM_802_11_AP_SEC_GROUP_WEP40)))
- break;
- if ((found = match_cipher (cipher, "wep104", ap_wpa, ap_rsn, NM_802_11_AP_SEC_GROUP_WEP104)))
- break;
- if ((found = match_cipher (cipher, "tkip", ap_wpa, ap_rsn, NM_802_11_AP_SEC_GROUP_TKIP)))
- break;
- if ((found = match_cipher (cipher, "ccmp", ap_wpa, ap_rsn, NM_802_11_AP_SEC_GROUP_CCMP)))
- break;
- }
- if (!found && num)
- return FALSE;
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- * nm_setting_wireless_new:
- *
- * Creates a new #NMSettingWireless object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingWireless object
- **/
-NMSetting *
-nm_setting_wireless_new (void)
-{
- return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRELESS, NULL);
-}
-
-/**
- * nm_setting_wireless_get_ssid:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:ssid property of the setting
- **/
-const GByteArray *
-nm_setting_wireless_get_ssid (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->ssid;
-}
-
-/**
- * nm_setting_wireless_get_mode:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:mode property of the setting
- **/
-const char *
-nm_setting_wireless_get_mode (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mode;
-}
-
-/**
- * nm_setting_wireless_get_band:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:band property of the setting
- **/
-const char *
-nm_setting_wireless_get_band (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->band;
-}
-
-/**
- * nm_setting_wireless_get_channel:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:channel property of the setting
- **/
-guint32
-nm_setting_wireless_get_channel (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->channel;
-}
-
-/**
- * nm_setting_wireless_get_bssid:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:bssid property of the setting
- **/
-const GByteArray *
-nm_setting_wireless_get_bssid (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->bssid;
-}
-
-/**
- * nm_setting_wireless_get_rate:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:rate property of the setting
- **/
-guint32
-nm_setting_wireless_get_rate (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->rate;
-}
-
-/**
- * nm_setting_wireless_get_tx_power:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:tx-power property of the setting
- **/
-guint32
-nm_setting_wireless_get_tx_power (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->tx_power;
-}
-
-/**
- * nm_setting_wireless_get_mac_address:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:mac-address property of the setting
- **/
-const GByteArray *
-nm_setting_wireless_get_mac_address (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->device_mac_address;
-}
-
-/**
- * nm_setting_wireless_get_cloned_mac_address:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:cloned-mac-address property of the setting
- **/
-const GByteArray *
-nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->cloned_mac_address;
-}
-
-/**
- * nm_setting_wireless_get_mac_address_blacklist:
- * @setting: the #NMSettingWireless
- *
- * Returns: (element-type GLib.ByteArray): the
- * #NMSettingWireless:mac-address-blacklist property of the setting
- **/
-const GSList *
-nm_setting_wireless_get_mac_address_blacklist (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mac_address_blacklist;
-}
-
-/**
- * nm_setting_wireless_get_num_mac_blacklist_items:
- * @setting: the #NMSettingWireless
- *
- * Returns: the number of blacklisted MAC addresses
- *
- * Since: 0.9.10
- **/
-guint32
-nm_setting_wireless_get_num_mac_blacklist_items (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
-
- return g_slist_length (NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mac_address_blacklist);
-}
-
-/**
- * nm_setting_wireless_get_mac_blacklist_item:
- * @setting: the #NMSettingWireless
- * @idx: the zero-based index of the MAC address entry
- *
- * Returns: the blacklisted MAC address string (hex-digits-and-colons notation)
- * at index @idx
- *
- * Since: 0.9.10
- **/
-const char *
-nm_setting_wireless_get_mac_blacklist_item (NMSettingWireless *setting, guint32 idx)
-{
- NMSettingWirelessPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
- g_return_val_if_fail (idx <= g_slist_length (priv->mac_address_blacklist), NULL);
-
- return (const char *) g_slist_nth_data (priv->mac_address_blacklist, idx);
-}
-
-/**
- * nm_setting_wireless_add_mac_blacklist_item:
- * @setting: the #NMSettingWireless
- * @mac: the MAC address string (hex-digits-and-colons notation) to blacklist
- *
- * Adds a new MAC address to the #NMSettingWireless:mac-address-blacklist property.
- *
- * Returns: %TRUE if the MAC address was added; %FALSE if the MAC address
- * is invalid or was already present
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_wireless_add_mac_blacklist_item (NMSettingWireless *setting, const char *mac)
-{
- NMSettingWirelessPrivate *priv;
- GSList *iter;
- guint8 buf[32];
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), FALSE);
- g_return_val_if_fail (mac != NULL, FALSE);
-
- if (!nm_utils_hwaddr_aton (mac, ARPHRD_ETHER, buf))
- return FALSE;
-
- priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
- for (iter = priv->mac_address_blacklist; iter; iter = g_slist_next (iter)) {
- if (!strcasecmp (mac, (char *) iter->data))
- return FALSE;
- }
-
- priv->mac_address_blacklist = g_slist_append (priv->mac_address_blacklist,
- g_ascii_strup (mac, -1));
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST);
- return TRUE;
-}
-
-/**
- * nm_setting_wireless_remove_mac_blacklist_item:
- * @setting: the #NMSettingWireless
- * @idx: index number of the MAC address
- *
- * Removes the MAC address at index @idx from the blacklist.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_wireless_remove_mac_blacklist_item (NMSettingWireless *setting, guint32 idx)
-{
- NMSettingWirelessPrivate *priv;
- GSList *elt;
-
- g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
-
- priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
- elt = g_slist_nth (priv->mac_address_blacklist, idx);
- g_return_if_fail (elt != NULL);
-
- g_free (elt->data);
- priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, elt);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST);
-}
-
-/**
- * nm_setting_wireless_remove_mac_blacklist_item_by_value:
- * @setting: the #NMSettingWireless
- * @mac: the MAC address string (hex-digits-and-colons notation) to remove from
- * the blacklist
- *
- * Removes the MAC address @mac from the blacklist.
- *
- * Returns: %TRUE if the MAC address was found and removed; %FALSE if it was not.
- *
- * Since: 0.9.10
- **/
-gboolean
-nm_setting_wireless_remove_mac_blacklist_item_by_value (NMSettingWireless *setting, const char *mac)
-{
- NMSettingWirelessPrivate *priv;
- GSList *iter;
- guint8 buf[32];
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), FALSE);
- g_return_val_if_fail (mac != NULL, FALSE);
-
- if (!nm_utils_hwaddr_aton (mac, ARPHRD_ETHER, buf))
- return FALSE;
-
- priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
- for (iter = priv->mac_address_blacklist; iter; iter = g_slist_next (iter)) {
- if (!strcasecmp (mac, (char *) iter->data)) {
- priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, iter);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * nm_setting_wireless_clear_mac_blacklist_items:
- * @setting: the #NMSettingWireless
- *
- * Removes all blacklisted MAC addresses.
- *
- * Since: 0.9.10
- **/
-void
-nm_setting_wireless_clear_mac_blacklist_items (NMSettingWireless *setting)
-{
- g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
-
- g_slist_free_full (NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mac_address_blacklist, g_free);
- NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mac_address_blacklist = NULL;
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST);
-}
-
-/**
- * nm_setting_wireless_get_mtu:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:mtu property of the setting
- **/
-guint32
-nm_setting_wireless_get_mtu (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mtu;
-}
-
-/**
- * nm_setting_wireless_get_security:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:security property of the setting
- *
- * Deprecated: 0.9.10: No longer used. Security rescrictions are recognized by
- * the presence of NM_SETTING_WIRELESS_SECURITY_SETTING_NAME in the connection.
- **/
-const char *
-nm_setting_wireless_get_security (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->security;
-}
-
-/**
- * nm_setting_wireless_get_hidden:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:hidden property of the setting
- **/
-gboolean
-nm_setting_wireless_get_hidden (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), FALSE);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->hidden;
-}
-
-/**
- * nm_setting_wireless_get_powersave:
- * @setting: the #NMSettingWireless
- *
- * Returns: the #NMSettingWireless:powersave property of the setting
- *
- * Since: 1.2
- **/
-guint32
-nm_setting_wireless_get_powersave (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
-
- return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->powersave;
-}
-
-/**
- * nm_setting_wireless_add_seen_bssid:
- * @setting: the #NMSettingWireless
- * @bssid: the new BSSID to add to the list
- *
- * Adds a new Wi-Fi AP's BSSID to the previously seen BSSID list of the setting.
- * NetworkManager now tracks previously seen BSSIDs internally so this function
- * no longer has much use. Actually, changes you make using this function will
- * not be preserved.
- *
- * Returns: %TRUE if @bssid was already known, %FALSE if not
- **/
-gboolean
-nm_setting_wireless_add_seen_bssid (NMSettingWireless *setting,
- const char *bssid)
-{
- NMSettingWirelessPrivate *priv;
- char *lower_bssid;
- GSList *iter;
- gboolean found = FALSE;
-
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), FALSE);
- g_return_val_if_fail (bssid != NULL, FALSE);
-
- lower_bssid = g_ascii_strdown (bssid, -1);
- if (!lower_bssid)
- return FALSE;
-
- priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
-
- for (iter = priv->seen_bssids; iter; iter = iter->next) {
- if (!strcmp ((char *) iter->data, lower_bssid)) {
- found = TRUE;
- break;
- }
- }
-
- if (!found) {
- priv->seen_bssids = g_slist_prepend (priv->seen_bssids, lower_bssid);
- g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SEEN_BSSIDS);
- } else
- g_free (lower_bssid);
-
- return !found;
-}
-
-/**
- * nm_setting_wireless_get_num_seen_bssids:
- * @setting: the #NMSettingWireless
- *
- * Returns: the number of BSSIDs in the previously seen BSSID list
- **/
-guint32
-nm_setting_wireless_get_num_seen_bssids (NMSettingWireless *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
-
- return g_slist_length (NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids);
-}
-
-/**
- * nm_setting_wireless_get_seen_bssid:
- * @setting: the #NMSettingWireless
- * @i: index of a BSSID in the previously seen BSSID list
- *
- * Returns: the BSSID at index @i
- **/
-const char *
-nm_setting_wireless_get_seen_bssid (NMSettingWireless *setting,
- guint32 i)
-{
- g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
-
- return (const char *) g_slist_nth_data (NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids, i);
-}
-
-static gboolean
-verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
- const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NULL };
- const char *valid_bands[] = { "a", "bg", NULL };
- GSList *iter;
-
- if (!priv->ssid) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID);
- return FALSE;
- }
-
- if (!priv->ssid->len || priv->ssid->len > 32) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("SSID length is out of range <1-32> bytes"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID);
- return FALSE;
- }
-
- if (priv->mode && !g_strv_contains (valid_modes, priv->mode)) {
- g_set_error (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid Wi-Fi mode"),
- priv->mode);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MODE);
- return FALSE;
- }
-
- if (priv->band && !g_strv_contains (valid_bands, priv->band)) {
- g_set_error (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid band"),
- priv->band);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_BAND);
- return FALSE;
- }
-
- if (priv->channel && !priv->band) {
- g_set_error (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND,
- _("requires setting '%s' property"),
- NM_SETTING_WIRELESS_BAND);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_CHANNEL);
- return FALSE;
- }
-
- if (priv->channel) {
- if (!nm_utils_wifi_is_channel_valid (priv->channel, priv->band)) {
- g_set_error (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("'%d' is not a valid channel"),
- priv->channel);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_CHANNEL);
- return FALSE;
- }
- }
-
- if (priv->bssid && priv->bssid->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_BSSID);
- return FALSE;
- }
-
- if (priv->device_mac_address && priv->device_mac_address->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS);
- return FALSE;
- }
-
- if (priv->cloned_mac_address && priv->cloned_mac_address->len != ETH_ALEN) {
- g_set_error_literal (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS);
- return FALSE;
- }
-
- for (iter = priv->mac_address_blacklist; iter; iter = iter->next) {
- struct ether_addr addr;
-
- if (!ether_aton_r (iter->data, &addr)) {
- g_set_error (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid MAC address"),
- (const char *) iter->data);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST);
- return FALSE;
- }
- }
-
- for (iter = priv->seen_bssids; iter; iter = iter->next) {
- struct ether_addr addr;
-
- if (!ether_aton_r (iter->data, &addr)) {
- g_set_error (error,
- NM_SETTING_WIRELESS_ERROR,
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
- _("'%s' is not a valid MAC address"),
- (const char *) iter->data);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SEEN_BSSIDS);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void
-nm_setting_wireless_init (NMSettingWireless *setting)
-{
-}
-
-static void
-finalize (GObject *object)
-{
- NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (object);
-
- g_free (priv->mode);
- g_free (priv->band);
- g_free (priv->security);
-
- if (priv->ssid)
- g_byte_array_free (priv->ssid, TRUE);
- if (priv->bssid)
- g_byte_array_free (priv->bssid, TRUE);
- if (priv->device_mac_address)
- g_byte_array_free (priv->device_mac_address, TRUE);
- if (priv->cloned_mac_address)
- g_byte_array_free (priv->cloned_mac_address, TRUE);
- g_slist_free_full (priv->mac_address_blacklist, g_free);
- g_slist_free_full (priv->seen_bssids, g_free);
-
- G_OBJECT_CLASS (nm_setting_wireless_parent_class)->finalize (object);
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_SSID:
- if (priv->ssid)
- g_byte_array_free (priv->ssid, TRUE);
- priv->ssid = g_value_dup_boxed (value);
- break;
- case PROP_MODE:
- g_free (priv->mode);
- priv->mode = g_value_dup_string (value);
- break;
- case PROP_BAND:
- g_free (priv->band);
- priv->band = g_value_dup_string (value);
- break;
- case PROP_CHANNEL:
- priv->channel = g_value_get_uint (value);
- break;
- case PROP_BSSID:
- if (priv->bssid)
- g_byte_array_free (priv->bssid, TRUE);
- priv->bssid = g_value_dup_boxed (value);
- break;
- case PROP_RATE:
- priv->rate = g_value_get_uint (value);
- break;
- case PROP_TX_POWER:
- priv->tx_power = g_value_get_uint (value);
- break;
- case PROP_MAC_ADDRESS:
- if (priv->device_mac_address)
- g_byte_array_free (priv->device_mac_address, TRUE);
- priv->device_mac_address = g_value_dup_boxed (value);
- break;
- case PROP_CLONED_MAC_ADDRESS:
- if (priv->cloned_mac_address)
- g_byte_array_free (priv->cloned_mac_address, TRUE);
- priv->cloned_mac_address = g_value_dup_boxed (value);
- break;
- case PROP_MAC_ADDRESS_BLACKLIST:
- g_slist_free_full (priv->mac_address_blacklist, g_free);
- priv->mac_address_blacklist = g_value_dup_boxed (value);
- break;
- case PROP_MTU:
- priv->mtu = g_value_get_uint (value);
- break;
- case PROP_SEEN_BSSIDS:
- g_slist_free_full (priv->seen_bssids, g_free);
- priv->seen_bssids = g_value_dup_boxed (value);
- break;
- case PROP_SEC:
- g_free (priv->security);
- priv->security = g_value_dup_string (value);
- break;
- case PROP_HIDDEN:
- priv->hidden = g_value_get_boolean (value);
- break;
- case PROP_POWERSAVE:
- priv->powersave = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingWireless *setting = NM_SETTING_WIRELESS (object);
-
- switch (prop_id) {
- case PROP_SSID:
- g_value_set_boxed (value, nm_setting_wireless_get_ssid (setting));
- break;
- case PROP_MODE:
- g_value_set_string (value, nm_setting_wireless_get_mode (setting));
- break;
- case PROP_BAND:
- g_value_set_string (value, nm_setting_wireless_get_band (setting));
- break;
- case PROP_CHANNEL:
- g_value_set_uint (value, nm_setting_wireless_get_channel (setting));
- break;
- case PROP_BSSID:
- g_value_set_boxed (value, nm_setting_wireless_get_bssid (setting));
- break;
- case PROP_RATE:
- g_value_set_uint (value, nm_setting_wireless_get_rate (setting));
- break;
- case PROP_TX_POWER:
- g_value_set_uint (value, nm_setting_wireless_get_tx_power (setting));
- break;
- case PROP_MAC_ADDRESS:
- g_value_set_boxed (value, nm_setting_wireless_get_mac_address (setting));
- break;
- case PROP_CLONED_MAC_ADDRESS:
- g_value_set_boxed (value, nm_setting_wireless_get_cloned_mac_address (setting));
- break;
- case PROP_MAC_ADDRESS_BLACKLIST:
- g_value_set_boxed (value, nm_setting_wireless_get_mac_address_blacklist (setting));
- break;
- case PROP_MTU:
- g_value_set_uint (value, nm_setting_wireless_get_mtu (setting));
- break;
- case PROP_SEEN_BSSIDS:
- g_value_set_boxed (value, NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids);
- break;
- case PROP_SEC:
- g_value_set_string (value, NM_SETTING_WIRELESS_GET_PRIVATE (setting)->security);
- break;
- case PROP_HIDDEN:
- g_value_set_boolean (value, nm_setting_wireless_get_hidden (setting));
- break;
- case PROP_POWERSAVE:
- g_value_set_uint (value, nm_setting_wireless_get_powersave (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
- NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingWirelessPrivate));
-
- /* virtual methods */
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->finalize = finalize;
- parent_class->verify = verify;
-
- /* Properties */
- /**
- * NMSettingWireless:ssid:
- *
- * SSID of the Wi-Fi network. Must be specified.
- **/
- g_object_class_install_property
- (object_class, PROP_SSID,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_SSID, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:mode:
- *
- * Wi-Fi network mode; one of "infrastructure", "adhoc" or "ap". If blank,
- * infrastructure is assumed.
- **/
- g_object_class_install_property
- (object_class, PROP_MODE,
- g_param_spec_string (NM_SETTING_WIRELESS_MODE, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:band:
- *
- * 802.11 frequency band of the network. One of "a" for 5GHz 802.11a or
- * "bg" for 2.4GHz 802.11. This will lock associations to the Wi-Fi network
- * to the specific band, i.e. if "a" is specified, the device will not
- * associate with the same network in the 2.4GHz band even if the network's
- * settings are compatible. This setting depends on specific driver
- * capability and may not work with all drivers.
- **/
- g_object_class_install_property
- (object_class, PROP_BAND,
- g_param_spec_string (NM_SETTING_WIRELESS_BAND, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:channel:
- *
- * Wireless channel to use for the Wi-Fi connection. The device will only
- * join (or create for Ad-Hoc networks) a Wi-Fi network on the specified
- * channel. Because channel numbers overlap between bands, this property
- * also requires the "band" property to be set.
- **/
- g_object_class_install_property
- (object_class, PROP_CHANNEL,
- g_param_spec_uint (NM_SETTING_WIRELESS_CHANNEL, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:bssid:
- *
- * If specified, directs the device to only associate with the given access
- * point. This capability is highly driver dependent and not supported by
- * all devices. Note: this property does not control the BSSID used when
- * creating an Ad-Hoc network and is unlikely to in the future.
- **/
- g_object_class_install_property
- (object_class, PROP_BSSID,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_BSSID, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:rate:
- *
- * If non-zero, directs the device to only use the specified bitrate for
- * communication with the access point. Units are in Kb/s, ie 5500 = 5.5
- * Mbit/s. This property is highly driver dependent and not all devices
- * support setting a static bitrate.
- **/
- g_object_class_install_property
- (object_class, PROP_RATE,
- g_param_spec_uint (NM_SETTING_WIRELESS_RATE, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:tx-power:
- *
- * If non-zero, directs the device to use the specified transmit power.
- * Units are dBm. This property is highly driver dependent and not all
- * devices support setting a static transmit power.
- **/
- g_object_class_install_property
- (object_class, PROP_TX_POWER,
- g_param_spec_uint (NM_SETTING_WIRELESS_TX_POWER, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:mac-address:
- *
- * If specified, this connection will only apply to the Wi-Fi device whose
- * permanent MAC address matches. This property does not change the MAC
- * address of the device (i.e. MAC spoofing).
- **/
- g_object_class_install_property
- (object_class, PROP_MAC_ADDRESS,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_MAC_ADDRESS, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:cloned-mac-address:
- *
- * If specified, request that the Wi-Fi device use this MAC address instead
- * of its permanent MAC address. This is known as MAC cloning or spoofing.
- **/
- g_object_class_install_property
- (object_class, PROP_CLONED_MAC_ADDRESS,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, "", "",
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:mac-address-blacklist:
- *
- * A list of permanent MAC addresses of Wi-Fi devices to which this
- * connection should never apply. Each MAC address should be given in the
- * standard hex-digits-and-colons notation (eg "00:11:22:33:44:55").
- **/
- g_object_class_install_property
- (object_class, PROP_MAC_ADDRESS_BLACKLIST,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:seen-bssids:
- *
- * A list of BSSIDs (each BSSID formatted as a MAC address like
- * "00:11:22:33:44:55") that have been detected as part of the Wi-Fi
- * network. NetworkManager internally tracks previously seen BSSIDs. The
- * property is only meant for reading and reflects the BSSID list of
- * NetworkManager. The changes you make to this property will not be
- * preserved.
- **/
- g_object_class_install_property
- (object_class, PROP_SEEN_BSSIDS,
- _nm_param_spec_specialized (NM_SETTING_WIRELESS_SEEN_BSSIDS, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:mtu:
- *
- * If non-zero, only transmit packets of the specified size or smaller,
- * breaking larger packets up into multiple Ethernet frames.
- **/
- g_object_class_install_property
- (object_class, PROP_MTU,
- g_param_spec_uint (NM_SETTING_WIRELESS_MTU, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- NM_SETTING_PARAM_FUZZY_IGNORE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:security:
- *
- * If the wireless connection has any security restrictions, like 802.1x,
- * WEP, or WPA, set this property to
- * %NM_SETTING_WIRELESS_SECURITY_SETTING_NAME and ensure the connection
- * contains a valid #NMSettingWirelessSecurity setting.
- *
- * Deprecated: 0.9.10: No longer used. Security restrictions are recognized
- * by the presence of a #NMSettingWirelessSecurity setting in the
- * connection.
- **/
- g_object_class_install_property
- (object_class, PROP_SEC,
- g_param_spec_string (NM_SETTING_WIRELESS_SEC, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:hidden:
- *
- * If %TRUE, indicates this network is a non-broadcasting network that hides
- * its SSID. In this case various workarounds may take place, such as
- * probe-scanning the SSID for more reliable network discovery. However,
- * these workarounds expose inherent insecurities with hidden SSID networks,
- * and thus hidden SSID networks should be used with caution.
- **/
- g_object_class_install_property
- (object_class, PROP_HIDDEN,
- g_param_spec_boolean (NM_SETTING_WIRELESS_HIDDEN, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMSettingWireless:powersave:
- *
- * If set to %FALSE, Wi-Fi power saving behavior is disabled. If set to
- * %TRUE, Wi-Fi power saving behavior is enabled. All other values are
- * reserved. Note that even though only boolean values are allowed, the
- * property type is an unsigned integer to allow for future expansion.
- *
- * Since: 1.2
- **/
- g_object_class_install_property
- (object_class, PROP_POWERSAVE,
- g_param_spec_uint (NM_SETTING_WIRELESS_POWERSAVE, "", "",
- 0, G_MAXUINT32, 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting-wireless.h b/libnm-util/nm-setting-wireless.h
deleted file mode 100644
index 5a64f0a0f1..0000000000
--- a/libnm-util/nm-setting-wireless.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2014 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_WIRELESS_H
-#define NM_SETTING_WIRELESS_H
-
-#include "NetworkManager.h"
-#include "nm-setting.h"
-#include "nm-setting-wireless-security.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING_WIRELESS (nm_setting_wireless_get_type ())
-#define NM_SETTING_WIRELESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_WIRELESS, NMSettingWireless))
-#define NM_SETTING_WIRELESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessClass))
-#define NM_IS_SETTING_WIRELESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_WIRELESS))
-#define NM_IS_SETTING_WIRELESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_WIRELESS))
-#define NM_SETTING_WIRELESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessClass))
-
-#define NM_SETTING_WIRELESS_SETTING_NAME "802-11-wireless"
-
-/**
- * NMSettingWirelessError:
- * @NM_SETTING_WIRELESS_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY: the property was invalid
- * @NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY: the property was missing and is
- * required
- * @NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING: property values require
- * the presence of an #NMSettingWirelessSecurity object in the connection
- * @NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND: the property channel was
- * set to a value that requires the #NMSettingWireless:band property to be set
- */
-typedef enum {
- NM_SETTING_WIRELESS_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
- NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
- NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING, /*< nick=MissingSecuritySetting >*/
- NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND /*< nick=ChannelRequiresBand >*/
-} NMSettingWirelessError;
-
-#define NM_SETTING_WIRELESS_ERROR nm_setting_wireless_error_quark ()
-GQuark nm_setting_wireless_error_quark (void);
-
-#define NM_SETTING_WIRELESS_SSID "ssid"
-#define NM_SETTING_WIRELESS_MODE "mode"
-#define NM_SETTING_WIRELESS_BAND "band"
-#define NM_SETTING_WIRELESS_CHANNEL "channel"
-#define NM_SETTING_WIRELESS_BSSID "bssid"
-#define NM_SETTING_WIRELESS_RATE "rate"
-#define NM_SETTING_WIRELESS_TX_POWER "tx-power"
-#define NM_SETTING_WIRELESS_MAC_ADDRESS "mac-address"
-#define NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS "cloned-mac-address"
-#define NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST "mac-address-blacklist"
-#define NM_SETTING_WIRELESS_MTU "mtu"
-#define NM_SETTING_WIRELESS_SEEN_BSSIDS "seen-bssids"
-#define NM_SETTING_WIRELESS_HIDDEN "hidden"
-#define NM_SETTING_WIRELESS_POWERSAVE "powersave"
-
-/* Deprecated */
-#define NM_SETTING_WIRELESS_SEC "security"
-
-/**
- * NM_SETTING_WIRELESS_MODE_ADHOC:
- *
- * Indicates Ad-Hoc mode where no access point is expected to be present.
- */
-#define NM_SETTING_WIRELESS_MODE_ADHOC "adhoc"
-
-/**
- * NM_SETTING_WIRELESS_MODE_AP:
- *
- * Indicates AP/master mode where the wireless device is started as an access
- * point/hotspot.
- *
- * Since: 0.9.8
- */
-#define NM_SETTING_WIRELESS_MODE_AP "ap"
-
-/**
- * NM_SETTING_WIRELESS_MODE_INFRA:
- *
- * Indicates infrastructure mode where an access point is expected to be present
- * for this connection.
- */
-#define NM_SETTING_WIRELESS_MODE_INFRA "infrastructure"
-
-typedef struct {
- NMSetting parent;
-} NMSettingWireless;
-
-typedef struct {
- NMSettingClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
-} NMSettingWirelessClass;
-
-GType nm_setting_wireless_get_type (void);
-
-NMSetting *nm_setting_wireless_new (void);
-
-const GByteArray *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);
-const GByteArray *nm_setting_wireless_get_bssid (NMSettingWireless *setting);
-guint32 nm_setting_wireless_get_rate (NMSettingWireless *setting);
-guint32 nm_setting_wireless_get_tx_power (NMSettingWireless *setting);
-const GByteArray *nm_setting_wireless_get_mac_address (NMSettingWireless *setting);
-const GByteArray *nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting);
-
-const GSList *nm_setting_wireless_get_mac_address_blacklist (NMSettingWireless *setting);
-NM_AVAILABLE_IN_0_9_10
-guint32 nm_setting_wireless_get_num_mac_blacklist_items (NMSettingWireless *setting);
-NM_AVAILABLE_IN_0_9_10
-const char * nm_setting_wireless_get_mac_blacklist_item (NMSettingWireless *setting,
- guint32 idx);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_wireless_add_mac_blacklist_item (NMSettingWireless *setting,
- const char *mac);
-NM_AVAILABLE_IN_0_9_10
-void nm_setting_wireless_remove_mac_blacklist_item (NMSettingWireless *setting,
- guint32 idx);
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_setting_wireless_remove_mac_blacklist_item_by_value (NMSettingWireless *setting,
- const char *mac);
-NM_AVAILABLE_IN_0_9_10
-void nm_setting_wireless_clear_mac_blacklist_items (NMSettingWireless *setting);
-
-guint32 nm_setting_wireless_get_mtu (NMSettingWireless *setting);
-gboolean nm_setting_wireless_get_hidden (NMSettingWireless *setting);
-NM_AVAILABLE_IN_1_2
-guint32 nm_setting_wireless_get_powersave (NMSettingWireless *setting);
-
-gboolean nm_setting_wireless_add_seen_bssid (NMSettingWireless *setting,
- const char *bssid);
-
-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,
- NMSettingWirelessSecurity *s_wireless_sec,
- NM80211ApFlags ap_flags,
- NM80211ApSecurityFlags ap_wpa,
- NM80211ApSecurityFlags ap_rsn,
- NM80211Mode ap_mode);
-
-/* Deprecated */
-NM_DEPRECATED_IN_0_9_10
-const char *nm_setting_wireless_get_security (NMSettingWireless *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_WIRELESS_H */
diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c
deleted file mode 100644
index 3edf4005f4..0000000000
--- a/libnm-util/nm-setting.c
+++ /dev/null
@@ -1,1505 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-setting.h"
-#include "nm-setting-private.h"
-#include "nm-setting-connection.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-
-/**
- * SECTION:nm-setting
- * @short_description: Describes related configuration information
- * @include: nm-setting.h
- *
- * Each #NMSetting contains properties that describe configuration that applies
- * to a specific network layer (like IPv4 or IPv6 configuration) or device type
- * (like Ethernet, or Wi-Fi). A collection of individual settings together
- * make up an #NMConnection. Each property is strongly typed and usually has
- * a number of allowed values. See each #NMSetting subclass for a description
- * of properties and allowed values.
- */
-
-/**
- * nm_setting_error_quark:
- *
- * Registers an error quark for #NMSetting if necessary.
- *
- * Returns: the error quark used for NMSetting errors.
- **/
-GQuark
-nm_setting_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-error-quark");
- return quark;
-}
-
-G_DEFINE_ABSTRACT_TYPE (NMSetting, nm_setting, G_TYPE_OBJECT)
-
-#define NM_SETTING_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING, NMSettingPrivate))
-
-typedef struct {
- const char *name;
- GType type;
- guint32 priority;
- GQuark error_quark;
-} SettingInfo;
-
-typedef struct {
- const SettingInfo *info;
-} NMSettingPrivate;
-
-enum {
- PROP_0,
- PROP_NAME,
-
- PROP_LAST
-};
-
-/*****************************************************************************/
-
-static GHashTable *registered_settings = NULL;
-static GHashTable *registered_settings_by_type = NULL;
-
-static gboolean
-_nm_gtype_equal (gconstpointer v1, gconstpointer v2)
-{
- return *((const GType *) v1) == *((const GType *) v2);
-}
-static guint
-_nm_gtype_hash (gconstpointer v)
-{
- return *((const GType *) v);
-}
-
-static void
-_ensure_registered (void)
-{
- if (G_UNLIKELY (registered_settings == NULL)) {
- _nm_value_transforms_register ();
- registered_settings = g_hash_table_new (g_str_hash, g_str_equal);
- registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal);
- }
-}
-
-static void __attribute__((constructor))
-_ensure_registered_constructor (void)
-{
- _ensure_registered ();
-}
-
-#define _ensure_setting_info(self, priv) \
- G_STMT_START { \
- NMSettingPrivate *_priv_esi = (priv); \
- if (G_UNLIKELY (!_priv_esi->info)) { \
- _priv_esi->info = _nm_setting_lookup_setting_by_type (G_OBJECT_TYPE (self)); \
- g_assert (_priv_esi->info); \
- } \
- } G_STMT_END
-
-/*****************************************************************************/
-
-/*
- * _nm_register_setting:
- * @name: the name of the #NMSetting object to register
- * @type: the #GType of the #NMSetting
- * @priority: the sort priority of the setting, see below
- * @error_quark: the setting's error quark
- *
- * INTERNAL ONLY: registers a setting's internal properties, like its priority
- * and its error quark type, with libnm-util.
- *
- * A setting's priority should roughly follow the OSI layer model, but it also
- * controls which settings get asked for secrets first. Thus settings which
- * relate to things that must be working first, like hardware, should get a
- * higher priority than things which layer on top of the hardware. For example,
- * the GSM/CDMA settings should provide secrets before the PPP setting does,
- * because a PIN is required to unlock the device before PPP can even start.
- * Even settings without secrets should be assigned the right priority.
- *
- * 0: reserved for the Connection setting
- *
- * 1: hardware-related settings like Ethernet, Wi-Fi, InfiniBand, Bridge, etc.
- * These priority 1 settings are also "base types", which means that at least
- * one of them is required for the connection to be valid, and their name is
- * valid in the 'type' property of the Connection setting.
- *
- * 2: hardware-related auxiliary settings that require a base setting to be
- * successful first, like Wi-Fi security, 802.1x, etc.
- *
- * 3: hardware-independent settings that are required before IP connectivity
- * can be established, like PPP, PPPoE, etc.
- *
- * 4: IP-level stuff
- */
-void
-(_nm_register_setting) (const char *name,
- const GType type,
- const guint32 priority,
- const GQuark error_quark)
-{
- SettingInfo *info;
-
- g_return_if_fail (name != NULL && *name);
- g_return_if_fail (type != G_TYPE_INVALID);
- g_return_if_fail (type != G_TYPE_NONE);
- g_return_if_fail (error_quark != 0);
- g_return_if_fail (priority <= 4);
-
- _ensure_registered ();
-
- if (G_LIKELY ((info = g_hash_table_lookup (registered_settings, name)))) {
- g_return_if_fail (info->type == type);
- g_return_if_fail (info->error_quark == error_quark);
- g_return_if_fail (info->priority == priority);
- g_return_if_fail (g_strcmp0 (info->name, name) == 0);
- return;
- }
- g_return_if_fail (g_hash_table_lookup (registered_settings_by_type, &type) == NULL);
-
- if (priority == 0)
- g_assert_cmpstr (name, ==, NM_SETTING_CONNECTION_SETTING_NAME);
-
- info = g_slice_new0 (SettingInfo);
- info->type = type;
- info->priority = priority;
- info->error_quark = error_quark;
- info->name = name;
- g_hash_table_insert (registered_settings, (void *) info->name, info);
- g_hash_table_insert (registered_settings_by_type, &info->type, info);
-}
-
-static const SettingInfo *
-_nm_setting_lookup_setting_by_type (GType type)
-{
- _ensure_registered ();
- return g_hash_table_lookup (registered_settings_by_type, &type);
-}
-
-static guint32
-_get_setting_type_priority (GType type)
-{
- const SettingInfo *info;
-
- g_return_val_if_fail (g_type_is_a (type, NM_TYPE_SETTING), G_MAXUINT32);
-
- info = _nm_setting_lookup_setting_by_type (type);
- return info->priority;
-}
-
-guint32
-_nm_setting_get_setting_priority (NMSetting *setting)
-{
- NMSettingPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING (setting), G_MAXUINT32);
- priv = NM_SETTING_GET_PRIVATE (setting);
- _ensure_setting_info (setting, priv);
- return priv->info->priority;
-}
-
-gboolean
-_nm_setting_type_is_base_type (GType type)
-{
- /* Historical oddity: PPPoE is a base-type even though it's not
- * priority 1. It needs to be sorted *after* lower-level stuff like
- * Wi-Fi security or 802.1x for secrets, but it's still allowed as a
- * base type.
- */
- return _get_setting_type_priority (type) == 1 || (type == NM_TYPE_SETTING_PPPOE);
-}
-
-gboolean
-_nm_setting_is_base_type (NMSetting *setting)
-{
- return _nm_setting_type_is_base_type (G_OBJECT_TYPE (setting));
-}
-
-GType
-_nm_setting_lookup_setting_type (const char *name)
-{
- SettingInfo *info;
-
- g_return_val_if_fail (name != NULL, G_TYPE_NONE);
-
- _ensure_registered ();
-
- info = g_hash_table_lookup (registered_settings, name);
- return info ? info->type : G_TYPE_INVALID;
-}
-
-GType
-_nm_setting_lookup_setting_type_by_quark (GQuark error_quark)
-{
- SettingInfo *info;
- GHashTableIter iter;
-
- _ensure_registered ();
-
- g_hash_table_iter_init (&iter, registered_settings);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &info)) {
- if (info->error_quark == error_quark)
- return info->type;
- }
- return G_TYPE_INVALID;
-}
-
-int
-_nm_setting_compare_priority (gconstpointer a, gconstpointer b)
-{
- guint32 prio_a, prio_b;
-
- prio_a = _nm_setting_get_setting_priority ((NMSetting *) a);
- prio_b = _nm_setting_get_setting_priority ((NMSetting *) b);
-
- if (prio_a < prio_b)
- return -1;
- else if (prio_a == prio_b)
- return 0;
- return 1;
-}
-
-/*****************************************************************************/
-
-static void
-destroy_gvalue (gpointer data)
-{
- GValue *value = (GValue *) data;
-
- g_value_unset (value);
- g_slice_free (GValue, value);
-}
-
-/**
- * nm_setting_to_hash:
- * @setting: the #NMSetting
- * @flags: hash flags, e.g. %NM_SETTING_HASH_FLAG_ALL
- *
- * Converts the #NMSetting into a #GHashTable mapping each setting property
- * name to a GValue describing that property, suitable for marshalling over
- * D-Bus or serializing. The mapping is string to GValue.
- *
- * Returns: (transfer full) (element-type utf8 GObject.Value): a new #GHashTable
- * describing the setting's properties
- **/
-GHashTable *
-nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
-{
- GHashTable *hash;
- GParamSpec **property_specs;
- guint n_property_specs;
- guint i;
-
- g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
-
- property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
-
- hash = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, destroy_gvalue);
-
- for (i = 0; i < n_property_specs; i++) {
- GParamSpec *prop_spec = property_specs[i];
- GValue *value;
-
- /* 'name' doesn't get serialized */
- if (strcmp (g_param_spec_get_name (prop_spec), NM_SETTING_NAME) == 0)
- continue;
-
- if ( (flags & NM_SETTING_HASH_FLAG_NO_SECRETS)
- && (prop_spec->flags & NM_SETTING_PARAM_SECRET))
- continue;
-
- if ( (flags & NM_SETTING_HASH_FLAG_ONLY_SECRETS)
- && !(prop_spec->flags & NM_SETTING_PARAM_SECRET))
- continue;
-
- value = g_slice_new0 (GValue);
- g_value_init (value, prop_spec->value_type);
- g_object_get_property (G_OBJECT (setting), prop_spec->name, value);
-
- /* Don't serialize values with default values */
- if (!g_param_value_defaults (prop_spec, value))
- g_hash_table_insert (hash, g_strdup (prop_spec->name), value);
- else
- destroy_gvalue (value);
- }
- g_free (property_specs);
-
- return hash;
-}
-
-/**
- * nm_setting_new_from_hash:
- * @setting_type: the #NMSetting type which the hash contains properties for
- * @hash: (element-type utf8 GObject.Value): the #GHashTable containing a
- * string to GValue mapping of properties that apply to the setting
- *
- * Creates a new #NMSetting object and populates that object with the properties
- * contained in the hash table, using each hash key as the property to set,
- * and each hash value as the value to set that property to. Setting properties
- * are strongly typed, thus the GValue type of the hash value must be correct.
- * See the documentation on each #NMSetting object subclass for the correct
- * property names and value types.
- *
- * Returns: a new #NMSetting object populated with the properties from the
- * hash table, or %NULL on failure
- **/
-NMSetting *
-nm_setting_new_from_hash (GType setting_type, GHashTable *hash)
-{
- GHashTableIter iter;
- NMSetting *setting;
- const char *prop_name;
- GValue *src_value;
- GObjectClass *class;
-
- g_return_val_if_fail (G_TYPE_IS_INSTANTIATABLE (setting_type), NULL);
- g_return_val_if_fail (hash != NULL, NULL);
-
- /* g_type_class_ref() ensures the setting class is created if it hasn't
- * already been used.
- */
- class = g_type_class_ref (setting_type);
-
- setting = (NMSetting *) g_object_new (setting_type, NULL);
-
- g_hash_table_iter_init (&iter, hash);
- while (g_hash_table_iter_next (&iter, (gpointer) &prop_name, (gpointer) &src_value)) {
- GParamSpec *param_spec;
-
- param_spec = g_object_class_find_property (class, prop_name);
- if (!param_spec) {
- /* Assume that any unrecognized property either can be ignored, or
- * else has a backward-compatibility equivalent.
- */
- continue;
- }
-
- (void) nm_g_object_set_property ((GObject *) setting, prop_name, src_value, NULL);
- }
-
- g_type_class_unref (class);
-
- return setting;
-}
-
-gboolean
-_nm_setting_get_property (NMSetting *setting, const char *property_name, GValue *value)
-{
- GParamSpec *prop_spec;
-
- g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
- g_return_val_if_fail (property_name, FALSE);
- g_return_val_if_fail (value, FALSE);
-
- prop_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), property_name);
-
- if (!prop_spec) {
- g_value_unset (value);
- return FALSE;
- }
-
- g_value_init (value, prop_spec->value_type);
- g_object_get_property (G_OBJECT (setting), property_name, value);
- return TRUE;
-}
-
-static void
-duplicate_setting (NMSetting *setting,
- const char *name,
- const GValue *value,
- GParamFlags flags,
- gpointer user_data)
-{
- if ((flags & (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)) == G_PARAM_WRITABLE)
- g_object_set_property (G_OBJECT (user_data), name, value);
-}
-
-/**
- * nm_setting_duplicate:
- * @setting: the #NMSetting to duplicate
- *
- * Duplicates a #NMSetting.
- *
- * Returns: (transfer full): a new #NMSetting containing the same properties and values as the
- * source #NMSetting
- **/
-NMSetting *
-nm_setting_duplicate (NMSetting *setting)
-{
- GObject *dup;
-
- g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
-
- dup = g_object_new (G_OBJECT_TYPE (setting), NULL);
-
- g_object_freeze_notify (dup);
- nm_setting_enumerate_values (setting, duplicate_setting, dup);
- g_object_thaw_notify (dup);
-
- return NM_SETTING (dup);
-}
-
-static int
-find_setting_by_name (gconstpointer a, gconstpointer b)
-{
- NMSetting *setting = NM_SETTING (a);
- const char *str = (const char *) b;
-
- return strcmp (nm_setting_get_name (setting), str);
-}
-
-NMSetting *
-nm_setting_find_in_list (GSList *settings_list,
- const char *setting_name)
-{
- GSList *found;
-
- found = g_slist_find_custom (settings_list, setting_name, find_setting_by_name);
- if (found)
- return found->data;
- else
- return NULL;
-}
-
-/**
- * nm_setting_get_name:
- * @setting: the #NMSetting
- *
- * Returns the type name of the #NMSetting object
- *
- * Returns: a string containing the type name of the #NMSetting object,
- * like 'ppp' or 'wireless' or 'wired'.
- **/
-const char *
-nm_setting_get_name (NMSetting *setting)
-{
- NMSettingPrivate *priv;
-
- g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
- priv = NM_SETTING_GET_PRIVATE (setting);
- _ensure_setting_info (setting, priv);
- return priv->info->name;
-}
-
-/**
- * nm_setting_verify:
- * @setting: the #NMSetting to verify
- * @all_settings: (element-type NMSetting): a #GSList of all settings
- * in the connection from which @setting came
- * @error: location to store error, or %NULL
- *
- * Validates the setting. Each setting's properties have allowed values, and
- * some are dependent on other values (hence the need for @all_settings). The
- * returned #GError contains information about which property of the setting
- * failed validation, and in what way that property failed validation.
- *
- * Returns: %TRUE if the setting is valid, %FALSE if it is not
- **/
-gboolean
-nm_setting_verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- NMSettingVerifyResult result = _nm_setting_verify (setting, all_settings, error);
-
- if (result == NM_SETTING_VERIFY_NORMALIZABLE)
- g_clear_error (error);
-
- return result == NM_SETTING_VERIFY_SUCCESS || result == NM_SETTING_VERIFY_NORMALIZABLE;
-}
-
-NMSettingVerifyResult
-_nm_setting_verify (NMSetting *setting, GSList *all_settings, GError **error)
-{
- g_return_val_if_fail (NM_IS_SETTING (setting), NM_SETTING_VERIFY_ERROR);
- g_return_val_if_fail (!error || *error == NULL, NM_SETTING_VERIFY_ERROR);
-
- if (NM_SETTING_GET_CLASS (setting)->verify)
- return NM_SETTING_GET_CLASS (setting)->verify (setting, all_settings, error);
-
- return NM_SETTING_VERIFY_SUCCESS;
-}
-
-static gboolean
-compare_property (NMSetting *setting,
- NMSetting *other,
- const GParamSpec *prop_spec,
- NMSettingCompareFlags flags)
-{
- GValue value1 = G_VALUE_INIT;
- GValue value2 = G_VALUE_INIT;
- gboolean different;
-
- /* Handle compare flags */
- if (prop_spec->flags & NM_SETTING_PARAM_SECRET) {
- NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
- NMSettingSecretFlags b_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
-
- g_return_val_if_fail (!NM_IS_SETTING_VPN (setting), FALSE);
-
- if (!nm_setting_get_secret_flags (setting, prop_spec->name, &a_secret_flags, NULL))
- g_return_val_if_reached (FALSE);
- if (!nm_setting_get_secret_flags (other, prop_spec->name, &b_secret_flags, NULL))
- g_return_val_if_reached (FALSE);
-
- /* If the secret flags aren't the same the settings aren't the same */
- if (a_secret_flags != b_secret_flags)
- return FALSE;
-
- /* Check for various secret flags that might cause us to ignore comparing
- * this property.
- */
- if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS)
- && (a_secret_flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED))
- return TRUE;
-
- if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)
- && (a_secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED))
- return TRUE;
- }
-
- g_value_init (&value1, prop_spec->value_type);
- g_object_get_property (G_OBJECT (setting), prop_spec->name, &value1);
-
- g_value_init (&value2, prop_spec->value_type);
- g_object_get_property (G_OBJECT (other), prop_spec->name, &value2);
-
- different = g_param_values_cmp ((GParamSpec *) prop_spec, &value1, &value2);
-
- g_value_unset (&value1);
- g_value_unset (&value2);
-
- return different == 0 ? TRUE : FALSE;
-}
-
-/**
- * nm_setting_compare:
- * @a: a #NMSetting
- * @b: a second #NMSetting to compare with the first
- * @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
- *
- * Compares two #NMSetting objects for similarity, with comparison behavior
- * modified by a set of flags. See the documentation for #NMSettingCompareFlags
- * for a description of each flag's behavior.
- *
- * Returns: %TRUE if the comparison succeeds, %FALSE if it does not
- **/
-gboolean
-nm_setting_compare (NMSetting *a,
- NMSetting *b,
- NMSettingCompareFlags flags)
-{
- GParamSpec **property_specs;
- guint n_property_specs;
- int same = TRUE;
- guint i;
-
- g_return_val_if_fail (NM_IS_SETTING (a), FALSE);
- g_return_val_if_fail (NM_IS_SETTING (b), FALSE);
-
- /* First check that both have the same type */
- if (G_OBJECT_TYPE (a) != G_OBJECT_TYPE (b))
- return FALSE;
-
- /* And now all properties */
- property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a), &n_property_specs);
- for (i = 0; i < n_property_specs && same; i++) {
- GParamSpec *prop_spec = property_specs[i];
-
- /* Fuzzy compare ignores secrets and properties defined with the FUZZY_IGNORE flag */
- if ( (flags & NM_SETTING_COMPARE_FLAG_FUZZY)
- && (prop_spec->flags & (NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)))
- continue;
-
- if ((flags & NM_SETTING_COMPARE_FLAG_INFERRABLE) && !(prop_spec->flags & NM_SETTING_PARAM_INFERRABLE))
- continue;
-
- if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS)
- && (prop_spec->flags & NM_SETTING_PARAM_SECRET))
- continue;
-
- same = NM_SETTING_GET_CLASS (a)->compare_property (a, b, prop_spec, flags);
- }
- g_free (property_specs);
-
- return same;
-}
-
-static gboolean
-should_compare_prop (NMSetting *setting,
- const char *prop_name,
- NMSettingCompareFlags comp_flags,
- GParamFlags prop_flags)
-{
- /* Fuzzy compare ignores secrets and properties defined with the FUZZY_IGNORE flag */
- if ( (comp_flags & NM_SETTING_COMPARE_FLAG_FUZZY)
- && (prop_flags & (NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)))
- return FALSE;
-
- if ((comp_flags & NM_SETTING_COMPARE_FLAG_INFERRABLE) && !(prop_flags & NM_SETTING_PARAM_INFERRABLE))
- return FALSE;
-
- if (prop_flags & NM_SETTING_PARAM_SECRET) {
- NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
-
- if (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS)
- return FALSE;
-
- if ( NM_IS_SETTING_VPN (setting)
- && g_strcmp0 (prop_name, NM_SETTING_VPN_SECRETS) == 0) {
- /* FIXME: NMSettingVPN:NM_SETTING_VPN_SECRETS has NM_SETTING_PARAM_SECRET.
- * nm_setting_get_secret_flags() quite possibly fails, but it might succeed if the
- * setting accidentally uses a key "secrets". */
- return FALSE;
- }
-
- if (!nm_setting_get_secret_flags (setting, prop_name, &secret_flags, NULL))
- g_return_val_if_reached (FALSE);
-
- if ( (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS)
- && (secret_flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED))
- return FALSE;
-
- if ( (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)
- && (secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED))
- return FALSE;
- }
-
- if ( (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_ID)
- && NM_IS_SETTING_CONNECTION (setting)
- && !strcmp (prop_name, NM_SETTING_CONNECTION_ID))
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * nm_setting_diff:
- * @a: a #NMSetting
- * @b: a second #NMSetting to compare with the first
- * @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
- * @invert_results: this parameter is used internally by libnm-util and should
- * be set to %FALSE. If %TRUE inverts the meaning of the #NMSettingDiffResult.
- * @results: (inout) (transfer full) (element-type utf8 guint32): if the
- * settings differ, on return a hash table mapping the differing keys to one or
- * more %NMSettingDiffResult values OR-ed together. If the settings do not
- * differ, any hash table passed in is unmodified. If no hash table is passed
- * in and the settings differ, a new one is created and returned.
- *
- * Compares two #NMSetting objects for similarity, with comparison behavior
- * modified by a set of flags. See the documentation for #NMSettingCompareFlags
- * for a description of each flag's behavior. If the settings differ, the keys
- * of each setting that differ from the other are added to @results, mapped to
- * one or more #NMSettingDiffResult values.
- *
- * Returns: %TRUE if the settings contain the same values, %FALSE if they do not
- **/
-gboolean
-nm_setting_diff (NMSetting *a,
- NMSetting *b,
- NMSettingCompareFlags flags,
- gboolean invert_results,
- GHashTable **results)
-{
- GParamSpec **property_specs;
- guint n_property_specs;
- guint i;
- NMSettingDiffResult a_result = NM_SETTING_DIFF_RESULT_IN_A;
- NMSettingDiffResult b_result = NM_SETTING_DIFF_RESULT_IN_B;
- NMSettingDiffResult a_result_default = NM_SETTING_DIFF_RESULT_IN_A_DEFAULT;
- NMSettingDiffResult b_result_default = NM_SETTING_DIFF_RESULT_IN_B_DEFAULT;
- gboolean results_created = FALSE;
-
- g_return_val_if_fail (results != NULL, FALSE);
- g_return_val_if_fail (NM_IS_SETTING (a), FALSE);
- if (b) {
- g_return_val_if_fail (NM_IS_SETTING (b), FALSE);
- g_return_val_if_fail (G_OBJECT_TYPE (a) == G_OBJECT_TYPE (b), FALSE);
- }
-
- if ((flags & (NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT)) ==
- (NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT)) {
- /* conflicting flags: default to WITH_DEFAULT (clearing NO_DEFAULT). */
- flags &= ~NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT;
- }
-
- /* If the caller is calling this function in a pattern like this to get
- * complete diffs:
- *
- * nm_setting_diff (A, B, FALSE, &results);
- * nm_setting_diff (B, A, TRUE, &results);
- *
- * and wants us to invert the results so that the second invocation comes
- * out correctly, do that here.
- */
- if (invert_results) {
- a_result = NM_SETTING_DIFF_RESULT_IN_B;
- b_result = NM_SETTING_DIFF_RESULT_IN_A;
- a_result_default = NM_SETTING_DIFF_RESULT_IN_B_DEFAULT;
- b_result_default = NM_SETTING_DIFF_RESULT_IN_A_DEFAULT;
- }
-
- if (*results == NULL) {
- *results = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- results_created = TRUE;
- }
-
- /* And now all properties */
- property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a), &n_property_specs);
-
- for (i = 0; i < n_property_specs; i++) {
- GParamSpec *prop_spec = property_specs[i];
- NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN;
-
- /* Handle compare flags */
- if (!should_compare_prop (a, prop_spec->name, flags, prop_spec->flags))
- continue;
- if (strcmp (prop_spec->name, NM_SETTING_NAME) == 0)
- continue;
-
- if (b) {
- gboolean different;
-
- different = !NM_SETTING_GET_CLASS (a)->compare_property (a, b, prop_spec, flags);
- if (different) {
- gboolean a_is_default, b_is_default;
- GValue value = G_VALUE_INIT;
-
- g_value_init (&value, prop_spec->value_type);
- g_object_get_property (G_OBJECT (a), prop_spec->name, &value);
- a_is_default = g_param_value_defaults (prop_spec, &value);
-
- g_value_reset (&value);
- g_object_get_property (G_OBJECT (b), prop_spec->name, &value);
- b_is_default = g_param_value_defaults (prop_spec, &value);
-
- g_value_unset (&value);
- if ((flags & NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT) == 0) {
- if (!a_is_default)
- r |= a_result;
- if (!b_is_default)
- r |= b_result;
- } else {
- r |= a_result | b_result;
- if (a_is_default)
- r |= a_result_default;
- if (b_is_default)
- r |= b_result_default;
- }
- }
- } else if ((flags & (NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT)) == 0)
- r = a_result; /* only in A */
- else {
- GValue value = G_VALUE_INIT;
-
- g_value_init (&value, prop_spec->value_type);
- g_object_get_property (G_OBJECT (a), prop_spec->name, &value);
- if (!g_param_value_defaults (prop_spec, &value))
- r |= a_result;
- else if (flags & NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT)
- r |= a_result | a_result_default;
-
- g_value_unset (&value);
- }
-
- if (r != NM_SETTING_DIFF_RESULT_UNKNOWN) {
- void *p;
-
- if (g_hash_table_lookup_extended (*results, prop_spec->name, NULL, &p)) {
- if ((r & GPOINTER_TO_UINT (p)) != r)
- g_hash_table_insert (*results, g_strdup (prop_spec->name), GUINT_TO_POINTER (r | GPOINTER_TO_UINT (p)));
- } else
- g_hash_table_insert (*results, g_strdup (prop_spec->name), GUINT_TO_POINTER (r));
- }
- }
- g_free (property_specs);
-
- /* Don't return an empty hash table */
- if (results_created && !g_hash_table_size (*results)) {
- g_hash_table_destroy (*results);
- *results = NULL;
- }
-
- return !(*results);
-}
-
-/**
- * nm_setting_enumerate_values:
- * @setting: the #NMSetting
- * @func: (scope call): user-supplied function called for each property of the setting
- * @user_data: user data passed to @func at each invocation
- *
- * Iterates over each property of the #NMSetting object, calling the supplied
- * user function for each property.
- **/
-void
-nm_setting_enumerate_values (NMSetting *setting,
- NMSettingValueIterFn func,
- gpointer user_data)
-{
- GParamSpec **property_specs;
- guint n_property_specs;
- int i;
-
- g_return_if_fail (NM_IS_SETTING (setting));
- g_return_if_fail (func != NULL);
-
- property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
- for (i = 0; i < n_property_specs; i++) {
- GParamSpec *prop_spec = property_specs[i];
- GValue value = G_VALUE_INIT;
-
- g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop_spec));
- g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
- func (setting, prop_spec->name, &value, prop_spec->flags, user_data);
- g_value_unset (&value);
- }
-
- g_free (property_specs);
-}
-
-/**
- * nm_setting_clear_secrets:
- * @setting: the #NMSetting
- *
- * Resets and clears any secrets in the setting. Secrets should be added to the
- * setting only when needed, and cleared immediately after use to prevent
- * leakage of information.
- **/
-void
-nm_setting_clear_secrets (NMSetting *setting)
-{
- _nm_setting_clear_secrets (setting);
-}
-
-gboolean
-_nm_setting_clear_secrets (NMSetting *setting)
-{
- GParamSpec **property_specs;
- guint n_property_specs;
- guint i;
- gboolean changed = FALSE;
-
- g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
-
- property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
-
- for (i = 0; i < n_property_specs; i++) {
- GParamSpec *prop_spec = property_specs[i];
-
- if (prop_spec->flags & NM_SETTING_PARAM_SECRET) {
- GValue value = G_VALUE_INIT;
-
- g_value_init (&value, prop_spec->value_type);
- g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
- if (!g_param_value_defaults (prop_spec, &value)) {
- g_param_value_set_default (prop_spec, &value);
- g_object_set_property (G_OBJECT (setting), prop_spec->name, &value);
- changed = TRUE;
- }
- g_value_unset (&value);
- }
- }
-
- g_free (property_specs);
-
- return changed;
-}
-
-static gboolean
-clear_secrets_with_flags (NMSetting *setting,
- GParamSpec *pspec,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data)
-{
- NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
- gboolean changed = FALSE;
-
- g_return_val_if_fail (!NM_IS_SETTING_VPN (setting), FALSE);
-
- /* Clear the secret if the user function says to do so */
- if (!nm_setting_get_secret_flags (setting, pspec->name, &flags, NULL))
- g_return_val_if_reached (FALSE);
-
- if (func (setting, pspec->name, flags, user_data) == TRUE) {
- GValue value = G_VALUE_INIT;
-
- g_value_init (&value, pspec->value_type);
- g_object_get_property (G_OBJECT (setting), pspec->name, &value);
- if (!g_param_value_defaults (pspec, &value)) {
- g_param_value_set_default (pspec, &value);
- g_object_set_property (G_OBJECT (setting), pspec->name, &value);
- changed = TRUE;
- }
- g_value_unset (&value);
- }
-
- return changed;
-}
-
-/**
- * nm_setting_clear_secrets_with_flags:
- * @setting: the #NMSetting
- * @func: (scope call): function to be called to determine whether a
- * specific secret should be cleared or not
- * @user_data: caller-supplied data passed to @func
- *
- * Clears and frees secrets determined by @func.
- **/
-void
-nm_setting_clear_secrets_with_flags (NMSetting *setting,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data)
-{
- _nm_setting_clear_secrets_with_flags (setting, func, user_data);
-}
-
-gboolean
-_nm_setting_clear_secrets_with_flags (NMSetting *setting,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data)
-{
- GParamSpec **property_specs;
- guint n_property_specs;
- guint i;
- gboolean changed = FALSE;
-
- g_return_val_if_fail (setting, FALSE);
- g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
- g_return_val_if_fail (func != NULL, FALSE);
-
- property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
- for (i = 0; i < n_property_specs; i++) {
- if (property_specs[i]->flags & NM_SETTING_PARAM_SECRET) {
- changed |= NM_SETTING_GET_CLASS (setting)->clear_secrets_with_flags (setting,
- property_specs[i],
- func,
- user_data);
- }
- }
-
- g_free (property_specs);
- return changed;
-}
-
-/**
- * nm_setting_need_secrets:
- * @setting: the #NMSetting
- *
- * Returns an array of property names for each secret which may be required
- * to make a successful connection. The returned hints are only intended as a
- * guide to what secrets may be required, because in some circumstances, there
- * is no way to conclusively determine exactly which secrets are needed.
- *
- * Returns: (transfer container) (element-type utf8): a #GPtrArray containing
- * the property names of secrets of the #NMSetting which may be required; the
- * caller owns the array and must free it with g_ptr_array_free(), but must not
- * free the elements.
- **/
-GPtrArray *
-nm_setting_need_secrets (NMSetting *setting)
-{
- GPtrArray *secrets = NULL;
-
- g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
-
- if (NM_SETTING_GET_CLASS (setting)->need_secrets)
- secrets = NM_SETTING_GET_CLASS (setting)->need_secrets (setting);
-
- return secrets;
-}
-
-static int
-update_one_secret (NMSetting *setting, const char *key, GValue *value, GError **error)
-{
- GParamSpec *prop_spec;
-
- prop_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), key);
- if (!prop_spec) {
- g_set_error (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_NOT_FOUND,
- "%s", key);
- return NM_SETTING_UPDATE_SECRET_ERROR;
- }
-
- /* Silently ignore non-secrets */
- if (!(prop_spec->flags & NM_SETTING_PARAM_SECRET))
- return NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
-
- if (g_value_type_compatible (G_VALUE_TYPE (value), G_PARAM_SPEC_VALUE_TYPE (prop_spec))) {
- if (G_VALUE_HOLDS_STRING (value) && G_IS_PARAM_SPEC_STRING (prop_spec)) {
- /* String is expected to be a common case. Handle it specially and check whether
- * the value is already set. Otherwise, we just reset the property and
- * assume the value got modified. */
- char *v;
-
- g_object_get (G_OBJECT (setting), prop_spec->name, &v, NULL);
- if (g_strcmp0 (v, g_value_get_string (value)) == 0) {
- g_free (v);
- return NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
- }
- g_free (v);
- }
- g_object_set_property (G_OBJECT (setting), prop_spec->name, value);
- return NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED;
- }
- g_set_error (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- "%s", key);
- return NM_SETTING_UPDATE_SECRET_ERROR;
-}
-
-/**
- * nm_setting_update_secrets:
- * @setting: the #NMSetting
- * @secrets: (element-type utf8 GObject.Value): a #GHashTable mapping
- * string to #GValue of setting property names and secrets
- * @error: location to store error, or %NULL
- *
- * Update the setting's secrets, given a hash table of secrets intended for that
- * setting (deserialized from D-Bus for example).
- *
- * Returns: %TRUE if the secrets were successfully updated, %FALSE on failure to
- * update one or more of the secrets.
- **/
-gboolean
-nm_setting_update_secrets (NMSetting *setting, GHashTable *secrets, GError **error)
-{
- return _nm_setting_update_secrets (setting, secrets, error) != NM_SETTING_UPDATE_SECRET_ERROR;
-}
-
-NMSettingUpdateSecretResult
-_nm_setting_update_secrets (NMSetting *setting, GHashTable *secrets, GError **error)
-{
- GHashTableIter iter;
- gpointer key, data;
- 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);
- g_return_val_if_fail (secrets != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
- if (error)
- g_return_val_if_fail (*error == NULL, NM_SETTING_UPDATE_SECRET_ERROR);
-
- g_hash_table_iter_init (&iter, secrets);
- while (g_hash_table_iter_next (&iter, &key, &data)) {
- int success;
- const char *secret_key = (const char *) key;
- GValue *secret_value = (GValue *) data;
-
- success = NM_SETTING_GET_CLASS (setting)->update_one_secret (setting, secret_key, secret_value, &tmp_error);
- g_assert (!((success == NM_SETTING_UPDATE_SECRET_ERROR) ^ (!!tmp_error)));
-
- if (success == NM_SETTING_UPDATE_SECRET_ERROR) {
- g_propagate_error (error, tmp_error);
- return NM_SETTING_UPDATE_SECRET_ERROR;
- }
-
- if (success == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
- result = NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED;
- }
-
- return result;
-}
-
-static gboolean
-is_secret_prop (NMSetting *setting, const char *secret_name, GError **error)
-{
- GParamSpec *pspec;
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), secret_name);
- if (!pspec) {
- g_set_error (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_NOT_FOUND,
- "Secret %s not provided by this setting", secret_name);
- return FALSE;
- }
-
- if (!(pspec->flags & NM_SETTING_PARAM_SECRET)) {
- g_set_error (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_NOT_SECRET,
- "Property %s is not a secret", secret_name);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-get_secret_flags (NMSetting *setting,
- const char *secret_name,
- gboolean verify_secret,
- NMSettingSecretFlags *out_flags,
- GError **error)
-{
- char *flags_prop;
- NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
-
- if (verify_secret && !is_secret_prop (setting, secret_name, error)) {
- if (out_flags)
- *out_flags = NM_SETTING_SECRET_FLAG_NONE;
- return FALSE;
- }
-
- flags_prop = g_strdup_printf ("%s-flags", secret_name);
- g_object_get (G_OBJECT (setting), flags_prop, &flags, NULL);
- g_free (flags_prop);
-
- if (out_flags)
- *out_flags = flags;
- return TRUE;
-}
-
-/**
- * nm_setting_get_secret_flags:
- * @setting: the #NMSetting
- * @secret_name: the secret key name to get flags for
- * @out_flags: on success, the #NMSettingSecretFlags for the secret
- * @error: location to store error, or %NULL
- *
- * For a given secret, retrieves the #NMSettingSecretFlags describing how to
- * handle that secret.
- *
- * Returns: %TRUE on success (if the given secret name was a valid property of
- * this setting, and if that property is secret), %FALSE if not
- **/
-gboolean
-nm_setting_get_secret_flags (NMSetting *setting,
- const char *secret_name,
- NMSettingSecretFlags *out_flags,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
- g_return_val_if_fail (secret_name != NULL, FALSE);
-
- return NM_SETTING_GET_CLASS (setting)->get_secret_flags (setting, secret_name, TRUE, out_flags, error);
-}
-
-static gboolean
-set_secret_flags (NMSetting *setting,
- const char *secret_name,
- gboolean verify_secret,
- NMSettingSecretFlags flags,
- GError **error)
-{
- char *flags_prop;
-
- if (verify_secret)
- g_return_val_if_fail (is_secret_prop (setting, secret_name, error), FALSE);
-
- flags_prop = g_strdup_printf ("%s-flags", secret_name);
- g_object_set (G_OBJECT (setting), flags_prop, flags, NULL);
- g_free (flags_prop);
- return TRUE;
-}
-
-/**
- * nm_setting_set_secret_flags:
- * @setting: the #NMSetting
- * @secret_name: the secret key name to set flags for
- * @flags: the #NMSettingSecretFlags for the secret
- * @error: location to store error, or %NULL
- *
- * For a given secret, stores the #NMSettingSecretFlags describing how to
- * handle that secret.
- *
- * Returns: %TRUE on success (if the given secret name was a valid property of
- * this setting, and if that property is secret), %FALSE if not
- **/
-gboolean
-nm_setting_set_secret_flags (NMSetting *setting,
- const char *secret_name,
- NMSettingSecretFlags flags,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
- g_return_val_if_fail (secret_name != NULL, FALSE);
- g_return_val_if_fail (flags <= NM_SETTING_SECRET_FLAGS_ALL, FALSE);
-
- return NM_SETTING_GET_CLASS (setting)->set_secret_flags (setting, secret_name, TRUE, flags, error);
-}
-
-/**
- * nm_setting_to_string:
- * @setting: the #NMSetting
- *
- * Convert the setting into a string. For debugging purposes ONLY, should NOT
- * be used for serialization of the setting, or machine-parsed in any way. The
- * output format is not guaranteed to be stable and may change at any time.
- *
- * Returns: an allocated string containing a textual representation of the
- * setting's properties and values (including secrets!), which the caller should
- * free with g_free()
- **/
-char *
-nm_setting_to_string (NMSetting *setting)
-{
- GString *string;
- GParamSpec **property_specs;
- guint n_property_specs;
- guint i;
-
- g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
-
- property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
-
- string = g_string_new (nm_setting_get_name (setting));
- g_string_append_c (string, '\n');
-
- for (i = 0; i < n_property_specs; i++) {
- GParamSpec *prop_spec = property_specs[i];
- GValue value = G_VALUE_INIT;
- char *value_str;
- gboolean is_default;
-
- if (strcmp (prop_spec->name, NM_SETTING_NAME) == 0)
- continue;
-
- g_value_init (&value, prop_spec->value_type);
- g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
-
- value_str = g_strdup_value_contents (&value);
- g_string_append_printf (string, "\t%s : %s", prop_spec->name, value_str);
- g_free (value_str);
-
- is_default = g_param_value_defaults (prop_spec, &value);
- g_value_unset (&value);
-
- g_string_append (string, " (");
- g_string_append_c (string, 's');
- if (is_default)
- g_string_append_c (string, 'd');
- g_string_append_c (string, ')');
- g_string_append_c (string, '\n');
- }
-
- g_free (property_specs);
- g_string_append_c (string, '\n');
-
- return g_string_free (string, FALSE);
-}
-
-/**
- * nm_setting_get_virtual_iface_name:
- * @setting: the #NMSetting
- *
- * Returns the name of the virtual kernel interface which the connection
- * needs to use if specified in the settings.
- *
- * Returns: Name of the virtual interface or %NULL if the setting does not
- * support this feature
- **/
-const char *
-nm_setting_get_virtual_iface_name (NMSetting *setting)
-{
- g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
-
- if (NM_SETTING_GET_CLASS (setting)->get_virtual_iface_name)
- return NM_SETTING_GET_CLASS (setting)->get_virtual_iface_name (setting);
-
- return NULL;
-}
-
-NMSettingVerifyResult
-_nm_setting_verify_deprecated_virtual_iface_name (const char *interface_name,
- gboolean allow_missing,
- const char *setting_name,
- const char *setting_property,
- GQuark error_quark,
- int e_invalid_property,
- int e_missing_property,
- GSList *all_settings,
- GError **error)
-{
- NMSettingConnection *s_con;
- const char *con_name;
-
- s_con = NM_SETTING_CONNECTION (nm_setting_find_in_list (all_settings, NM_SETTING_CONNECTION_SETTING_NAME));
- con_name = s_con ? nm_setting_connection_get_interface_name (s_con) : NULL;
- if (!interface_name && !con_name) {
- if (allow_missing)
- return NM_SETTING_VERIFY_SUCCESS;
-
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
- return NM_SETTING_VERIFY_ERROR;
- }
- if (!con_name && !nm_utils_iface_valid_name (interface_name)) {
- /* the interface_name is invalid, we cannot normalize it. Only do this if !con_name,
- * because if con_name is set, it can overwrite interface_name. */
- g_set_error_literal (error,
- error_quark,
- e_invalid_property,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", setting_name, setting_property);
- return NM_SETTING_VERIFY_ERROR;
- }
- if (!con_name) {
- /* NMSettingConnection has interface not set, it should be normalized to interface_name */
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
- return NM_SETTING_VERIFY_NORMALIZABLE;
- }
- if (!nm_utils_iface_valid_name (con_name)) {
- /* NMSettingConnection:interface_name is invalid, we cannot normalize it. */
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
- return NM_SETTING_VERIFY_ERROR;
- }
- if (!interface_name) {
- /* Normalize by setting NMSettingConnection:interface_name. */
- g_set_error_literal (error,
- error_quark,
- e_missing_property,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", setting_name, setting_property);
- return NM_SETTING_VERIFY_NORMALIZABLE;
- }
- if (strcmp (con_name, interface_name) != 0) {
- /* con_name and interface_name are different. It can be normalized by setting interface_name
- * to con_name. */
- g_set_error_literal (error,
- error_quark,
- e_invalid_property,
- _("property is invalid"));
- g_prefix_error (error, "%s.%s: ", setting_name, setting_property);
- /* we would like to make this a NORMALIZABLE_ERROR, but that might
- * break older connections. */
- return NM_SETTING_VERIFY_NORMALIZABLE;
- }
-
- return NM_SETTING_VERIFY_SUCCESS;
-}
-
-/*****************************************************************************/
-
-static void
-nm_setting_init (NMSetting *setting)
-{
-}
-
-static GObject*
-constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
-
- object = G_OBJECT_CLASS (nm_setting_parent_class)->constructor (type,
- n_construct_params,
- construct_params);
-
- _ensure_setting_info (object, NM_SETTING_GET_PRIVATE (object));
- return object;
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingPrivate *priv = NM_SETTING_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_NAME:
- /* The setter for NAME is deprecated and should not be used anymore.
- * Keep the setter for NAME to remain backward compatible.
- * Only assert that the caller does not try to set the name to a different value
- * then the registered name, which would be extra wrong.
- **/
- _ensure_setting_info (object, priv);
- g_return_if_fail (!g_strcmp0 (priv->info->name, g_value_get_string (value)));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSetting *setting = NM_SETTING (object);
-
- switch (prop_id) {
- case PROP_NAME:
- g_value_set_string (value, nm_setting_get_name (setting));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_setting_class_init (NMSettingClass *setting_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
-
- g_type_class_add_private (setting_class, sizeof (NMSettingPrivate));
-
- /* virtual methods */
- object_class->constructor = constructor;
- object_class->set_property = set_property;
- object_class->get_property = get_property;
-
- setting_class->update_one_secret = update_one_secret;
- setting_class->get_secret_flags = get_secret_flags;
- setting_class->set_secret_flags = set_secret_flags;
- setting_class->compare_property = compare_property;
- setting_class->clear_secrets_with_flags = clear_secrets_with_flags;
-
- /* Properties */
-
- /**
- * NMSetting:name:
- *
- * The setting's name, which uniquely identifies the setting within the
- * connection. Each setting type has a name unique to that type, for
- * example "ppp" or "wireless" or "wired".
- **/
- g_object_class_install_property
- (object_class, PROP_NAME,
- g_param_spec_string (NM_SETTING_NAME, "", "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-}
diff --git a/libnm-util/nm-setting.h b/libnm-util/nm-setting.h
deleted file mode 100644
index d70445a2e7..0000000000
--- a/libnm-util/nm-setting.h
+++ /dev/null
@@ -1,334 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- * Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_SETTING_H
-#define NM_SETTING_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "nm-version.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTING (nm_setting_get_type ())
-#define NM_SETTING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING, NMSetting))
-#define NM_SETTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING, NMSettingClass))
-#define NM_IS_SETTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING))
-#define NM_IS_SETTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING))
-#define NM_SETTING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING, NMSettingClass))
-
-/**
- * NMSettingError:
- * @NM_SETTING_ERROR_UNKNOWN: unknown or unclassified error
- * @NM_SETTING_ERROR_PROPERTY_NOT_FOUND: a property required by the operation
- * was not found; for example, an attempt to update an invalid secret
- * @NM_SETTING_ERROR_PROPERTY_NOT_SECRET: an operation which requires a secret
- * was attempted on a non-secret property
- * @NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH: the operation requires a property
- * of a specific type, or the value couldn't be transformed to the same type
- * as the property being acted upon
- *
- * Describes errors that may result from operations involving a #NMSetting.
- *
- **/
-typedef enum
-{
- NM_SETTING_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
- NM_SETTING_ERROR_PROPERTY_NOT_FOUND, /*< nick=PropertyNotFound >*/
- NM_SETTING_ERROR_PROPERTY_NOT_SECRET, /*< nick=PropertyNotSecret >*/
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH /*< nick=PropertyTypeMismatch >*/
-} NMSettingError;
-
-#define NM_SETTING_ERROR nm_setting_error_quark ()
-GQuark nm_setting_error_quark (void);
-
-/* DEPRECATED AND UNUSED */
-#define NM_SETTING_PARAM_SERIALIZE (1 << (0 + G_PARAM_USER_SHIFT))
-
-/* The property of the #NMSetting is required for the setting to be valid */
-#define NM_SETTING_PARAM_REQUIRED (1 << (1 + G_PARAM_USER_SHIFT))
-
-/* The property of the #NMSetting is a secret */
-#define NM_SETTING_PARAM_SECRET (1 << (2 + G_PARAM_USER_SHIFT))
-
-/* The property of the #NMSetting should be ignored during comparisons that
- * use the %NM_SETTING_COMPARE_FLAG_FUZZY flag.
- */
-#define NM_SETTING_PARAM_FUZZY_IGNORE (1 << (3 + G_PARAM_USER_SHIFT))
-
-/* Note: all non-glib GParamFlags bits are reserved by NetworkManager */
-
-#define NM_SETTING_NAME "name"
-
-/**
- * NMSettingSecretFlags:
- * @NM_SETTING_SECRET_FLAG_NONE: the system is responsible for providing and
- * storing this secret (default)
- * @NM_SETTING_SECRET_FLAG_AGENT_OWNED: a user secret agent is responsible
- * for providing and storing this secret; when it is required agents will be
- * asked to retrieve it
- * @NM_SETTING_SECRET_FLAG_NOT_SAVED: this secret should not be saved, but
- * should be requested from the user each time it is needed
- * @NM_SETTING_SECRET_FLAG_NOT_REQUIRED: in situations where it cannot be
- * automatically determined that the secret is required (some VPNs and PPP
- * providers don't require all secrets) this flag indicates that the specific
- * secret is not required
- *
- * These flags indicate specific behavior related to handling of a secret. Each
- * secret has a corresponding set of these flags which indicate how the secret
- * is to be stored and/or requested when it is needed.
- *
- **/
-typedef enum {
- NM_SETTING_SECRET_FLAG_NONE = 0x00000000,
- NM_SETTING_SECRET_FLAG_AGENT_OWNED = 0x00000001,
- NM_SETTING_SECRET_FLAG_NOT_SAVED = 0x00000002,
- NM_SETTING_SECRET_FLAG_NOT_REQUIRED = 0x00000004
-
- /* NOTE: if adding flags, update nm-setting-private.h as well */
-} NMSettingSecretFlags;
-
-/**
- * NMSettingCompareFlags:
- * @NM_SETTING_COMPARE_FLAG_EXACT: match all properties exactly
- * @NM_SETTING_COMPARE_FLAG_FUZZY: match only important attributes, like SSID,
- * type, security settings, etc. Does not match, for example, connection ID
- * or UUID.
- * @NM_SETTING_COMPARE_FLAG_IGNORE_ID: ignore the connection's ID
- * @NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS: ignore all secrets
- * @NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS: ignore secrets for which
- * the secret's flags indicate the secret is owned by a user secret agent
- * (ie, the secret's flag includes @NM_SETTING_SECRET_FLAG_AGENT_OWNED)
- * @NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS: ignore secrets for which
- * the secret's flags indicate the secret should not be saved to persistent
- * storage (ie, the secret's flag includes @NM_SETTING_SECRET_FLAG_NOT_SAVED)
- * @NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT: if this flag is set,
- * nm_setting_diff() and nm_connection_diff() will also include properties that
- * are set to their default value. See also @NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT.
- * @NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT: if this flag is set,
- * nm_setting_diff() and nm_connection_diff() will not include properties that
- * are set to their default value. This is the opposite of
- * @NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT. If both flags are set together,
- * @NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT wins. If both flags are unset,
- * this means to exclude default properties if there is a setting to compare,
- * but include all properties, if the setting 'b' is missing. This is the legacy
- * behaviour of libnm-util, where nm_setting_diff() behaved differently depending
- * on whether the setting 'b' was available. If @NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT
- * is set, nm_setting_diff() will also set the flags @NM_SETTING_DIFF_RESULT_IN_A_DEFAULT
- * and @NM_SETTING_DIFF_RESULT_IN_B_DEFAULT, if the values are default values.
- *
- * These flags modify the comparison behavior when comparing two settings or
- * two connections.
- *
- **/
-typedef enum {
- NM_SETTING_COMPARE_FLAG_EXACT = 0x00000000,
- NM_SETTING_COMPARE_FLAG_FUZZY = 0x00000001,
- NM_SETTING_COMPARE_FLAG_IGNORE_ID = 0x00000002,
- NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS = 0x00000004,
- NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS = 0x00000008,
- NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS = 0x00000010,
- NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT = 0x00000020,
- NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT = 0x00000040,
-
- /* 0x80000000 is used for a private flag */
-} NMSettingCompareFlags;
-
-/**
- * NMSetting:
- *
- * The NMSetting struct contains only private data.
- * It should only be accessed through the functions described below.
- */
-typedef struct {
- GObject parent;
-} NMSetting;
-
-/**
- * NMSettingClearSecretsWithFlagsFn:
- * @setting: The setting for which secrets are being iterated
- * @secret: The secret's name
- * @flags: The secret's flags, eg %NM_SETTING_SECRET_FLAG_AGENT_OWNED
- * @user_data: User data passed to nm_connection_clear_secrets_with_flags()
- *
- * Returns: %TRUE to clear the secret, %FALSE to not clear the secret
- */
-typedef gboolean (*NMSettingClearSecretsWithFlagsFn) (NMSetting *setting,
- const char *secret,
- NMSettingSecretFlags flags,
- gpointer user_data);
-
-typedef struct {
- GObjectClass parent;
-
- /* Virtual functions */
- int (*verify) (NMSetting *setting,
- GSList *all_settings,
- GError **error);
-
- GPtrArray *(*need_secrets) (NMSetting *setting);
-
- int (*update_one_secret) (NMSetting *setting,
- const char *key,
- GValue *value,
- GError **error);
-
- gboolean (*get_secret_flags) (NMSetting *setting,
- const char *secret_name,
- gboolean verify_secret,
- NMSettingSecretFlags *out_flags,
- GError **error);
-
- gboolean (*set_secret_flags) (NMSetting *setting,
- const char *secret_name,
- gboolean verify_secret,
- NMSettingSecretFlags flags,
- GError **error);
-
- /* Returns TRUE if the given property contains the same value in both settings */
- gboolean (*compare_property) (NMSetting *setting,
- NMSetting *other,
- const GParamSpec *prop_spec,
- NMSettingCompareFlags flags);
-
- gboolean (*clear_secrets_with_flags) (NMSetting *setting,
- GParamSpec *pspec,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data);
-
- const char *(*get_virtual_iface_name) (NMSetting *setting);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
-} NMSettingClass;
-
-/**
- * NMSettingValueIterFn:
- * @setting: The setting for which properties are being iterated, given to
- * nm_setting_enumerate_values()
- * @key: The value/property name
- * @value: The property's value
- * @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,
- const GValue *value,
- GParamFlags flags,
- gpointer user_data);
-
-GType nm_setting_get_type (void);
-
-/**
- * NMSettingHashFlags:
- * @NM_SETTING_HASH_FLAG_ALL: hash all properties (including secrets)
- * @NM_SETTING_HASH_FLAG_NO_SECRETS: do not include secrets
- * @NM_SETTING_HASH_FLAG_ONLY_SECRETS: only hash secrets
- *
- * These flags determine which properties are added to the resulting hash
- * when calling nm_setting_to_hash().
- *
- **/
-typedef enum {
- NM_SETTING_HASH_FLAG_ALL = 0x00000000,
- NM_SETTING_HASH_FLAG_NO_SECRETS = 0x00000001,
- NM_SETTING_HASH_FLAG_ONLY_SECRETS = 0x00000002,
-} NMSettingHashFlags;
-
-GHashTable *nm_setting_to_hash (NMSetting *setting,
- NMSettingHashFlags flags);
-
-NMSetting *nm_setting_new_from_hash (GType setting_type,
- GHashTable *hash);
-
-NMSetting *nm_setting_duplicate (NMSetting *setting);
-
-const char *nm_setting_get_name (NMSetting *setting);
-
-gboolean nm_setting_verify (NMSetting *setting,
- GSList *all_settings,
- GError **error);
-
-gboolean nm_setting_compare (NMSetting *a,
- NMSetting *b,
- NMSettingCompareFlags flags);
-
-/**
- * NMSettingDiffResult:
- * @NM_SETTING_DIFF_RESULT_UNKNOWN: unknown result
- * @NM_SETTING_DIFF_RESULT_IN_A: the property is present in setting A
- * @NM_SETTING_DIFF_RESULT_IN_B: the property is present in setting B
- * @NM_SETTING_DIFF_RESULT_IN_A_DEFAULT: the property is present in
- * setting A but is set to the default value. This flag is only set,
- * if you specify @NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT.
- * @NM_SETTING_DIFF_RESULT_IN_B_DEFAULT: analog to @NM_SETTING_DIFF_RESULT_IN_A_DEFAULT.
- *
- * These values indicate the result of a setting difference operation.
- **/
-typedef enum {
- NM_SETTING_DIFF_RESULT_UNKNOWN = 0x00000000,
- NM_SETTING_DIFF_RESULT_IN_A = 0x00000001,
- NM_SETTING_DIFF_RESULT_IN_B = 0x00000002,
- NM_SETTING_DIFF_RESULT_IN_A_DEFAULT = 0x00000004,
- NM_SETTING_DIFF_RESULT_IN_B_DEFAULT = 0x00000004,
-} NMSettingDiffResult;
-
-gboolean nm_setting_diff (NMSetting *a,
- NMSetting *b,
- NMSettingCompareFlags flags,
- gboolean invert_results,
- GHashTable **results);
-
-void nm_setting_enumerate_values (NMSetting *setting,
- NMSettingValueIterFn func,
- gpointer user_data);
-
-char *nm_setting_to_string (NMSetting *setting);
-
-/* Secrets */
-void nm_setting_clear_secrets (NMSetting *setting);
-
-void nm_setting_clear_secrets_with_flags (NMSetting *setting,
- NMSettingClearSecretsWithFlagsFn func,
- gpointer user_data);
-
-GPtrArray *nm_setting_need_secrets (NMSetting *setting);
-gboolean nm_setting_update_secrets (NMSetting *setting,
- GHashTable *secrets,
- GError **error);
-
-gboolean nm_setting_get_secret_flags (NMSetting *setting,
- const char *secret_name,
- NMSettingSecretFlags *out_flags,
- GError **error);
-
-gboolean nm_setting_set_secret_flags (NMSetting *setting,
- const char *secret_name,
- NMSettingSecretFlags flags,
- GError **error);
-
-const char *nm_setting_get_virtual_iface_name (NMSetting *setting);
-
-G_END_DECLS
-
-#endif /* NM_SETTING_H */
diff --git a/libnm-util/nm-utils-enum-types.c.template b/libnm-util/nm-utils-enum-types.c.template
deleted file mode 100644
index e6505d343f..0000000000
--- a/libnm-util/nm-utils-enum-types.c.template
+++ /dev/null
@@ -1,65 +0,0 @@
-/*** BEGIN file-header ***/
-#include "config.h"
-
-#include "nm-utils-enum-types.h"
-
-#include "nm-version-macros.h"
-#include "nm-connection.h"
-#include "nm-setting.h"
-#include "nm-setting-8021x.h"
-#include "nm-setting-adsl.h"
-#include "nm-setting-bluetooth.h"
-#include "nm-setting-bond.h"
-#include "nm-setting-team.h"
-#include "nm-setting-team-port.h"
-#include "nm-setting-bridge.h"
-#include "nm-setting-bridge-port.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-dcb.h"
-#include "nm-setting-infiniband.h"
-#include "nm-setting-ip4-config.h"
-#include "nm-setting-vlan.h"
-#include "nm-setting-ip6-config.h"
-#include "nm-setting-ppp.h"
-#include "nm-setting-pppoe.h"
-#include "nm-setting-serial.h"
-#include "nm-setting-generic.h"
-#include "nm-setting-gsm.h"
-#include "nm-setting-cdma.h"
-#include "nm-setting-olpc-mesh.h"
-#include "nm-setting-wimax.h"
-#include "nm-setting-wired.h"
-#include "nm-setting-wireless.h"
-#include "nm-setting-wireless-security.h"
-#include "nm-setting-vpn.h"
-#include "nm-utils.h"
-#include "nm-version.h"
-/*** END file-header ***/
-
-/*** BEGIN value-header ***/
-GType
-@enum_name@_get_type (void)
-{
- static volatile gsize g_define_type_id__volatile = 0;
-
- if (g_once_init_enter (&g_define_type_id__volatile))
- {
- static const G@Type@Value values[] = {
-/*** END value-header ***/
-
-/*** BEGIN value-production ***/
- { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
-/*** END value-production ***/
-
-/*** BEGIN value-tail ***/
- { 0, NULL, NULL }
- };
- GType g_define_type_id =
- g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
-
- return g_define_type_id__volatile;
-}
-
-/*** END value-tail ***/
diff --git a/libnm-util/nm-utils-enum-types.h.template b/libnm-util/nm-utils-enum-types.h.template
deleted file mode 100644
index ac0cc3c848..0000000000
--- a/libnm-util/nm-utils-enum-types.h.template
+++ /dev/null
@@ -1,21 +0,0 @@
-/*** BEGIN file-header ***/
-#ifndef __NM_UTILS_ENUM_TYPES_H__
-#define __NM_UTILS_ENUM_TYPES_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/*** END file-header ***/
-
-/*** BEGIN enumeration-production ***/
-GType @enum_name@_get_type (void) G_GNUC_CONST;
-#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
-
-/*** END enumeration-production ***/
-
-/*** BEGIN file-tail ***/
-G_END_DECLS
-
-#endif /* __NM_UTILS_ENUM_TYPES_H__ */
-/*** END file-tail ***/
diff --git a/libnm-util/nm-utils-private.h b/libnm-util/nm-utils-private.h
deleted file mode 100644
index 2436332a97..0000000000
--- a/libnm-util/nm-utils-private.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2005 - 2008 Red Hat, Inc.
- */
-
-#ifndef __NM_UTILS_PRIVATE_H__
-#define __NM_UTILS_PRIVATE_H__
-
-#include "nm-setting-private.h"
-
-gboolean _nm_utils_string_slist_validate (GSList *list,
- const char **valid_values);
-
-gboolean _nm_utils_gvalue_array_validate (GValueArray *elements,
- guint n_expected, ...);
-
-void _nm_value_transforms_register (void);
-
-#endif
diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
deleted file mode 100644
index eae80a04ca..0000000000
--- a/libnm-util/nm-utils.c
+++ /dev/null
@@ -1,2608 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2005 - 2013 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include "nm-utils.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <netinet/ether.h>
-#include <linux/if_infiniband.h>
-#include <uuid/uuid.h>
-#include <libintl.h>
-#include <gmodule.h>
-
-#include "nm-gvaluearray-compat.h"
-#include "nm-utils-private.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-setting-private.h"
-#include "crypto.h"
-
-/**
- * SECTION:nm-utils
- * @short_description: Utility functions
- * @include: nm-utils.h
- *
- * A collection of utility functions for working with SSIDs, IP addresses, Wi-Fi
- * access points and devices, among other things.
- */
-
-struct EncodingTriplet
-{
- const char *encoding1;
- const char *encoding2;
- const char *encoding3;
-};
-
-struct IsoLangToEncodings
-{
- const char *lang;
- struct EncodingTriplet encodings;
-};
-
-/* 5-letter language codes */
-static const struct IsoLangToEncodings isoLangEntries5[] =
-{
- /* Simplified Chinese */
- { "zh_cn", {"euc-cn", "gb2312", "gb18030"} }, /* PRC */
- { "zh_sg", {"euc-cn", "gb2312", "gb18030"} }, /* Singapore */
-
- /* Traditional Chinese */
- { "zh_tw", {"big5", "euc-tw", NULL} }, /* Taiwan */
- { "zh_hk", {"big5", "euc-tw", "big5-hkcs"} },/* Hong Kong */
- { "zh_mo", {"big5", "euc-tw", NULL} }, /* Macau */
-
- /* Table end */
- { NULL, {NULL, NULL, NULL} }
-};
-
-/* 2-letter language codes; we don't care about the other 3 in this table */
-static const struct IsoLangToEncodings isoLangEntries2[] =
-{
- /* Japanese */
- { "ja", {"euc-jp", "shift_jis", "iso-2022-jp"} },
-
- /* Korean */
- { "ko", {"euc-kr", "iso-2022-kr", "johab"} },
-
- /* Thai */
- { "th", {"iso-8859-11","windows-874", NULL} },
-
- /* Central European */
- { "hu", {"iso-8859-2", "windows-1250", NULL} }, /* Hungarian */
- { "cs", {"iso-8859-2", "windows-1250", NULL} }, /* Czech */
- { "hr", {"iso-8859-2", "windows-1250", NULL} }, /* Croatian */
- { "pl", {"iso-8859-2", "windows-1250", NULL} }, /* Polish */
- { "ro", {"iso-8859-2", "windows-1250", NULL} }, /* Romanian */
- { "sk", {"iso-8859-2", "windows-1250", NULL} }, /* Slovakian */
- { "sl", {"iso-8859-2", "windows-1250", NULL} }, /* Slovenian */
- { "sh", {"iso-8859-2", "windows-1250", NULL} }, /* Serbo-Croatian */
-
- /* Cyrillic */
- { "ru", {"koi8-r", "windows-1251", "iso-8859-5"} }, /* Russian */
- { "be", {"koi8-r", "windows-1251", "iso-8859-5"} }, /* Belorussian */
- { "bg", {"windows-1251","koi8-r", "iso-8859-5"} }, /* Bulgarian */
- { "mk", {"koi8-r", "windows-1251", "iso-8859-5"} }, /* Macedonian */
- { "sr", {"koi8-r", "windows-1251", "iso-8859-5"} }, /* Serbian */
- { "uk", {"koi8-u", "koi8-r", "windows-1251"} }, /* Ukrainian */
-
- /* Arabic */
- { "ar", {"iso-8859-6", "windows-1256", NULL} },
-
- /* Baltic */
- { "et", {"iso-8859-4", "windows-1257", NULL} }, /* Estonian */
- { "lt", {"iso-8859-4", "windows-1257", NULL} }, /* Lithuanian */
- { "lv", {"iso-8859-4", "windows-1257", NULL} }, /* Latvian */
-
- /* Greek */
- { "el", {"iso-8859-7", "windows-1253", NULL} },
-
- /* Hebrew */
- { "he", {"iso-8859-8", "windows-1255", NULL} },
- { "iw", {"iso-8859-8", "windows-1255", NULL} },
-
- /* Turkish */
- { "tr", {"iso-8859-9", "windows-1254", NULL} },
-
- /* Table end */
- { NULL, {NULL, NULL, NULL} }
-};
-
-static GHashTable * langToEncodings5 = NULL;
-static GHashTable * langToEncodings2 = NULL;
-
-static void
-init_lang_to_encodings_hash (void)
-{
- struct IsoLangToEncodings *enc;
-
- if (G_UNLIKELY (langToEncodings5 == NULL)) {
- /* Five-letter codes */
- enc = (struct IsoLangToEncodings *) &isoLangEntries5[0];
- langToEncodings5 = g_hash_table_new (g_str_hash, g_str_equal);
- while (enc->lang) {
- g_hash_table_insert (langToEncodings5, (gpointer) enc->lang,
- (gpointer) &enc->encodings);
- enc++;
- }
- }
-
- if (G_UNLIKELY (langToEncodings2 == NULL)) {
- /* Two-letter codes */
- enc = (struct IsoLangToEncodings *) &isoLangEntries2[0];
- langToEncodings2 = g_hash_table_new (g_str_hash, g_str_equal);
- while (enc->lang) {
- g_hash_table_insert (langToEncodings2, (gpointer) enc->lang,
- (gpointer) &enc->encodings);
- enc++;
- }
- }
-}
-
-static gboolean
-get_encodings_for_lang (const char *lang,
- char **encoding1,
- char **encoding2,
- char **encoding3)
-{
- struct EncodingTriplet *encodings;
- gboolean success = FALSE;
- char *tmp_lang;
-
- g_return_val_if_fail (lang != NULL, FALSE);
- g_return_val_if_fail (encoding1 != NULL, FALSE);
- g_return_val_if_fail (encoding2 != NULL, FALSE);
- g_return_val_if_fail (encoding3 != NULL, FALSE);
-
- *encoding1 = "iso-8859-1";
- *encoding2 = "windows-1251";
- *encoding3 = NULL;
-
- init_lang_to_encodings_hash ();
-
- tmp_lang = g_strdup (lang);
- if ((encodings = g_hash_table_lookup (langToEncodings5, tmp_lang))) {
- *encoding1 = (char *) encodings->encoding1;
- *encoding2 = (char *) encodings->encoding2;
- *encoding3 = (char *) encodings->encoding3;
- success = TRUE;
- }
-
- /* Truncate tmp_lang to length of 2 */
- if (strlen (tmp_lang) > 2)
- tmp_lang[2] = '\0';
- if (!success && (encodings = g_hash_table_lookup (langToEncodings2, tmp_lang))) {
- *encoding1 = (char *) encodings->encoding1;
- *encoding2 = (char *) encodings->encoding2;
- *encoding3 = (char *) encodings->encoding3;
- success = TRUE;
- }
-
- g_free (tmp_lang);
- return success;
-}
-
-/* init, deinit for libnm_util */
-
-static void __attribute__((constructor))
-_check_symbols (void)
-{
- GModule *self;
- gpointer func;
-
- self = g_module_open (NULL, 0);
- if (g_module_symbol (self, "nm_device_state_get_type", &func))
- g_error ("libnm symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported");
- g_module_close (self);
-}
-
-static gboolean initialized = FALSE;
-
-/**
- * nm_utils_init:
- * @error: location to store error, or %NULL
- *
- * Initializes libnm-util; should be called when starting any program that
- * uses libnm-util. This function can be called more than once.
- *
- * Returns: %TRUE if the initialization was successful, %FALSE on failure.
- **/
-gboolean
-nm_utils_init (GError **error)
-{
- if (!initialized) {
- initialized = TRUE;
-
- bindtextdomain (GETTEXT_PACKAGE, NMLOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-
- if (!crypto_init (error))
- return FALSE;
-
- _nm_value_transforms_register ();
- }
- return TRUE;
-}
-
-/**
- * nm_utils_deinit:
- *
- * No-op. Although this function still exists for ABI compatibility reasons, it
- * does not have any effect, and does not ever need to be called.
- **/
-void
-nm_utils_deinit (void)
-{
-}
-
-/* ssid helpers */
-
-/**
- * nm_utils_ssid_to_utf8:
- * @ssid: a byte array containing the SSID data
- *
- * Wi-Fi SSIDs are byte arrays, they are _not_ strings. Thus, an SSID may
- * contain embedded NULLs and other unprintable characters. Often it is
- * useful to print the SSID out for debugging purposes, but that should be the
- * _only_ use of this function. Do not use this function for any persistent
- * storage of the SSID, since the printable SSID returned from this function
- * cannot be converted back into the real SSID of the access point.
- *
- * This function does almost everything humanly possible to convert the input
- * into a printable UTF-8 string, using roughly the following procedure:
- *
- * 1) if the input data is already UTF-8 safe, no conversion is performed
- * 2) attempts to get the current system language from the LANG environment
- * variable, and depending on the language, uses a table of alternative
- * encodings to try. For example, if LANG=hu_HU, the table may first try
- * the ISO-8859-2 encoding, and if that fails, try the Windows-1250 encoding.
- * If all fallback encodings fail, replaces non-UTF-8 characters with '?'.
- * 3) If the system language was unable to be determined, falls back to the
- * ISO-8859-1 encoding, then to the Windows-1251 encoding.
- * 4) If step 3 fails, replaces non-UTF-8 characters with '?'.
- *
- * Again, this function should be used for debugging and display purposes
- * _only_.
- *
- * Returns: (transfer full): an allocated string containing a UTF-8
- * representation of the SSID, which must be freed by the caller using g_free().
- * Returns %NULL on errors.
- **/
-char *
-nm_utils_ssid_to_utf8 (const GByteArray *ssid)
-{
- char *converted = NULL;
- char *lang, *e1 = NULL, *e2 = NULL, *e3 = NULL;
-
- g_return_val_if_fail (ssid != NULL, NULL);
-
- if (g_utf8_validate ((const char *) ssid->data, ssid->len, NULL))
- return g_strndup ((const char *) ssid->data, ssid->len);
-
- /* LANG may be a good encoding hint */
- g_get_charset ((const char **)(&e1));
- if ((lang = getenv ("LANG"))) {
- char * dot;
-
- lang = g_ascii_strdown (lang, -1);
- if ((dot = strchr (lang, '.')))
- *dot = '\0';
-
- get_encodings_for_lang (lang, &e1, &e2, &e3);
- g_free (lang);
- }
-
- converted = g_convert ((const char *) ssid->data, ssid->len, "UTF-8", e1, NULL, NULL, NULL);
- if (!converted && e2)
- converted = g_convert ((const char *) ssid->data, ssid->len, "UTF-8", e2, NULL, NULL, NULL);
-
- if (!converted && e3)
- converted = g_convert ((const char *) ssid->data, ssid->len, "UTF-8", e3, NULL, NULL, NULL);
-
- if (!converted) {
- converted = g_convert_with_fallback ((const char *) ssid->data, ssid->len,
- "UTF-8", e1, "?", NULL, NULL, NULL);
- }
-
- if (!converted) {
- /* If there is still no converted string, the SSID probably
- * contains characters not valid in the current locale. Convert
- * the string to ASCII instead.
- */
-
- /* Use the printable range of 0x20-0x7E */
- char *valid_chars = " !\"#$%&'()*+,-./0123456789:;<=>?@"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"
- "abcdefghijklmnopqrstuvwxyz{|}~";
-
- converted = g_strndup ((const char *)ssid->data, ssid->len);
- g_strcanon (converted, valid_chars, '?');
- }
-
- return converted;
-}
-
-/* Shamelessly ripped from the Linux kernel ieee80211 stack */
-/**
- * nm_utils_is_empty_ssid:
- * @ssid: pointer to a buffer containing the SSID data
- * @len: length of the SSID data in @ssid
- *
- * Different manufacturers use different mechanisms for not broadcasting the
- * AP's SSID. This function attempts to detect blank/empty SSIDs using a
- * number of known SSID-cloaking methods.
- *
- * Returns: %TRUE if the SSID is "empty", %FALSE if it is not
- **/
-gboolean
-nm_utils_is_empty_ssid (const guint8 * ssid, int len)
-{
- /* Single white space is for Linksys APs */
- if (len == 1 && ssid[0] == ' ')
- return TRUE;
-
- /* Otherwise, if the entire ssid is 0, we assume it is hidden */
- while (len--) {
- if (ssid[len] != '\0')
- return FALSE;
- }
- return TRUE;
-}
-
-#define ESSID_MAX_SIZE 32
-
-/**
- * nm_utils_escape_ssid:
- * @ssid: pointer to a buffer containing the SSID data
- * @len: length of the SSID data in @ssid
- *
- * This function does a quick printable character conversion of the SSID, simply
- * replacing embedded NULLs and non-printable characters with the hexadecimal
- * representation of that character. Intended for debugging only, should not
- * be used for display of SSIDs.
- *
- * Returns: pointer to the escaped SSID, which uses an internal static buffer
- * and will be overwritten by subsequent calls to this function
- **/
-const char *
-nm_utils_escape_ssid (const guint8 * ssid, guint32 len)
-{
- static char escaped[ESSID_MAX_SIZE * 2 + 1];
- const guint8 *s = ssid;
- char *d = escaped;
-
- if (nm_utils_is_empty_ssid (ssid, len)) {
- memcpy (escaped, "<hidden>", sizeof ("<hidden>"));
- return escaped;
- }
-
- len = MIN (len, (guint32) ESSID_MAX_SIZE);
- while (len--) {
- if (*s == '\0') {
- *d++ = '\\';
- *d++ = '0';
- s++;
- } else {
- *d++ = *s++;
- }
- }
- *d = '\0';
- return escaped;
-}
-
-/**
- * nm_utils_same_ssid:
- * @ssid1: first SSID data to compare
- * @ssid2: second SSID data to compare
- * @ignore_trailing_null: %TRUE to ignore one trailing NULL byte
- *
- * Earlier versions of the Linux kernel added a NULL byte to the end of the
- * SSID to enable easy printing of the SSID on the console or in a terminal,
- * but this behavior was problematic (SSIDs are simply byte arrays, not strings)
- * and thus was changed. This function compensates for that behavior at the
- * cost of some compatibility with odd SSIDs that may legitimately have trailing
- * NULLs, even though that is functionally pointless.
- *
- * Returns: %TRUE if the SSIDs are the same, %FALSE if they are not
- **/
-gboolean
-nm_utils_same_ssid (const GByteArray * ssid1,
- const GByteArray * ssid2,
- gboolean ignore_trailing_null)
-{
- guint32 ssid1_len, ssid2_len;
-
- if (ssid1 == ssid2)
- return TRUE;
- if (!ssid1 || !ssid2)
- return FALSE;
-
- ssid1_len = ssid1->len;
- ssid2_len = ssid2->len;
- if (ssid1_len && ssid2_len && ignore_trailing_null) {
- if (ssid1->data[ssid1_len - 1] == '\0')
- ssid1_len--;
- if (ssid2->data[ssid2_len - 1] == '\0')
- ssid2_len--;
- }
-
- if (ssid1_len != ssid2_len)
- return FALSE;
-
- return memcmp (ssid1->data, ssid2->data, ssid1_len) == 0 ? TRUE : FALSE;
-}
-
-static void
-value_destroy (gpointer data)
-{
- GValue *value = (GValue *) data;
-
- g_value_unset (value);
- g_slice_free (GValue, value);
-}
-
-static void
-value_dup (gpointer key, gpointer val, gpointer user_data)
-{
- GHashTable *table = (GHashTable *) user_data;
- GValue *value = (GValue *) val;
- GValue *dup_value;
-
- dup_value = g_slice_new0 (GValue);
- g_value_init (dup_value, G_VALUE_TYPE (value));
- g_value_copy (value, dup_value);
-
- g_hash_table_insert (table, g_strdup ((char *) key), dup_value);
-}
-
-/**
- * nm_utils_gvalue_hash_dup:
- * @hash: a #GHashTable mapping string:GValue
- *
- * Utility function to duplicate a hash table of #GValues.
- *
- * Returns: (transfer container) (element-type utf8 GObject.Value): a newly allocated duplicated #GHashTable, caller must free the
- * returned hash with g_hash_table_unref() or g_hash_table_destroy()
- **/
-GHashTable *
-nm_utils_gvalue_hash_dup (GHashTable *hash)
-{
- GHashTable *table;
-
- g_return_val_if_fail (hash != NULL, NULL);
-
- table = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free,
- value_destroy);
-
- g_hash_table_foreach (hash, value_dup, table);
-
- return table;
-}
-
-/**
- * nm_utils_slist_free: (skip)
- * @list: a #GSList
- * @elem_destroy_fn: user function called for each element in @list
- *
- * Utility function to free a #GSList.
- *
- * Deprecated: use g_slist_free_full().
- **/
-void
-nm_utils_slist_free (GSList *list, GDestroyNotify elem_destroy_fn)
-{
- g_slist_free_full (list, elem_destroy_fn);
-}
-
-gboolean
-_nm_utils_string_slist_validate (GSList *list, const char **valid_values)
-{
- GSList *iter;
-
- for (iter = list; iter; iter = iter->next) {
- if (!g_strv_contains (valid_values, (char *) iter->data))
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_nm_utils_gvalue_array_validate (GValueArray *elements, guint n_expected, ...)
-{
- va_list args;
- GValue *tmp;
- int i;
- gboolean valid = FALSE;
-
- if (n_expected != elements->n_values)
- return FALSE;
-
- va_start (args, n_expected);
- for (i = 0; i < n_expected; i++) {
- tmp = g_value_array_get_nth (elements, i);
- if (G_VALUE_TYPE (tmp) != va_arg (args, GType))
- goto done;
- }
- valid = TRUE;
-
-done:
- va_end (args);
- return valid;
-}
-
-static gboolean
-device_supports_ap_ciphers (guint32 dev_caps,
- guint32 ap_flags,
- gboolean static_wep)
-{
- gboolean have_pair = FALSE;
- gboolean have_group = FALSE;
- /* Device needs to support at least one pairwise and one group cipher */
-
- /* Pairwise */
- if (static_wep) {
- /* Static WEP only uses group ciphers */
- have_pair = TRUE;
- } else {
- if (dev_caps & NM_WIFI_DEVICE_CAP_CIPHER_WEP40)
- if (ap_flags & NM_802_11_AP_SEC_PAIR_WEP40)
- have_pair = TRUE;
- if (dev_caps & NM_WIFI_DEVICE_CAP_CIPHER_WEP104)
- if (ap_flags & NM_802_11_AP_SEC_PAIR_WEP104)
- have_pair = TRUE;
- if (dev_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP)
- if (ap_flags & NM_802_11_AP_SEC_PAIR_TKIP)
- have_pair = TRUE;
- if (dev_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)
- if (ap_flags & NM_802_11_AP_SEC_PAIR_CCMP)
- have_pair = TRUE;
- }
-
- /* Group */
- if (dev_caps & NM_WIFI_DEVICE_CAP_CIPHER_WEP40)
- if (ap_flags & NM_802_11_AP_SEC_GROUP_WEP40)
- have_group = TRUE;
- if (dev_caps & NM_WIFI_DEVICE_CAP_CIPHER_WEP104)
- if (ap_flags & NM_802_11_AP_SEC_GROUP_WEP104)
- have_group = TRUE;
- if (!static_wep) {
- if (dev_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP)
- if (ap_flags & NM_802_11_AP_SEC_GROUP_TKIP)
- have_group = TRUE;
- if (dev_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)
- if (ap_flags & NM_802_11_AP_SEC_GROUP_CCMP)
- have_group = TRUE;
- }
-
- return (have_pair && have_group);
-}
-
-/**
- * nm_utils_ap_mode_security_valid:
- * @type: the security type to check device capabilities against,
- * e.g. #NMU_SEC_STATIC_WEP
- * @wifi_caps: bitfield of the capabilities of the specific Wi-Fi device, e.g.
- * #NM_WIFI_DEVICE_CAP_CIPHER_WEP40
- *
- * Given a set of device capabilities, and a desired security type to check
- * against, determines whether the combination of device capabilities and
- * desired security type are valid for AP/Hotspot connections.
- *
- * Returns: %TRUE if the device capabilities are compatible with the desired
- * @type, %FALSE if they are not.
- *
- * Since: 0.9.8
- **/
-gboolean
-nm_utils_ap_mode_security_valid (NMUtilsSecurityType type,
- NMDeviceWifiCapabilities wifi_caps)
-{
- if (!(wifi_caps & NM_WIFI_DEVICE_CAP_AP))
- return FALSE;
-
- /* Return TRUE for any security that wpa_supplicant's lightweight AP
- * mode can handle: which is open, WEP, and WPA/WPA2 PSK.
- */
- switch (type) {
- case NMU_SEC_NONE:
- case NMU_SEC_STATIC_WEP:
- case NMU_SEC_WPA_PSK:
- case NMU_SEC_WPA2_PSK:
- return TRUE;
- default:
- break;
- }
- return FALSE;
-}
-
-/**
- * nm_utils_security_valid:
- * @type: the security type to check AP flags and device capabilities against,
- * e.g. #NMU_SEC_STATIC_WEP
- * @wifi_caps: bitfield of the capabilities of the specific Wi-Fi device, e.g.
- * #NM_WIFI_DEVICE_CAP_CIPHER_WEP40
- * @have_ap: whether the @ap_flags, @ap_wpa, and @ap_rsn arguments are valid
- * @adhoc: whether the capabilities being tested are from an Ad-Hoc AP (IBSS)
- * @ap_flags: bitfield of AP capabilities, e.g. #NM_802_11_AP_FLAGS_PRIVACY
- * @ap_wpa: bitfield of AP capabilities derived from the AP's WPA beacon,
- * e.g. (#NM_802_11_AP_SEC_PAIR_TKIP | #NM_802_11_AP_SEC_KEY_MGMT_PSK)
- * @ap_rsn: bitfield of AP capabilities derived from the AP's RSN/WPA2 beacon,
- * e.g. (#NM_802_11_AP_SEC_PAIR_CCMP | #NM_802_11_AP_SEC_PAIR_TKIP)
- *
- * Given a set of device capabilities, and a desired security type to check
- * against, determines whether the combination of device, desired security
- * type, and AP capabilities intersect.
- *
- * NOTE: this function cannot handle checking security for AP/Hotspot mode;
- * use nm_utils_ap_mode_security_valid() instead.
- *
- * Returns: %TRUE if the device capabilities and AP capabilities intersect and are
- * compatible with the desired @type, %FALSE if they are not
- **/
-gboolean
-nm_utils_security_valid (NMUtilsSecurityType type,
- NMDeviceWifiCapabilities wifi_caps,
- gboolean have_ap,
- gboolean adhoc,
- NM80211ApFlags ap_flags,
- NM80211ApSecurityFlags ap_wpa,
- NM80211ApSecurityFlags ap_rsn)
-{
- gboolean good = TRUE;
-
- if (!have_ap) {
- if (type == NMU_SEC_NONE)
- return TRUE;
- if ( (type == NMU_SEC_STATIC_WEP)
- || ((type == NMU_SEC_DYNAMIC_WEP) && !adhoc)
- || ((type == NMU_SEC_LEAP) && !adhoc)) {
- if (wifi_caps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104))
- return TRUE;
- else
- return FALSE;
- }
- }
-
- switch (type) {
- case NMU_SEC_NONE:
- g_assert (have_ap);
- if (ap_flags & NM_802_11_AP_FLAGS_PRIVACY)
- return FALSE;
- if (ap_wpa || ap_rsn)
- return FALSE;
- break;
- case NMU_SEC_LEAP: /* require PRIVACY bit for LEAP? */
- if (adhoc)
- return FALSE;
- /* fall through */
- case NMU_SEC_STATIC_WEP:
- g_assert (have_ap);
- if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
- return FALSE;
- if (ap_wpa || ap_rsn) {
- if (!device_supports_ap_ciphers (wifi_caps, ap_wpa, TRUE))
- if (!device_supports_ap_ciphers (wifi_caps, ap_rsn, TRUE))
- return FALSE;
- }
- break;
- case NMU_SEC_DYNAMIC_WEP:
- if (adhoc)
- return FALSE;
- g_assert (have_ap);
- if (ap_rsn || !(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
- return FALSE;
- /* Some APs broadcast minimal WPA-enabled beacons that must be handled */
- if (ap_wpa) {
- if (!(ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
- return FALSE;
- if (!device_supports_ap_ciphers (wifi_caps, ap_wpa, FALSE))
- return FALSE;
- }
- break;
- case NMU_SEC_WPA_PSK:
- if (adhoc)
- return FALSE; /* FIXME: Kernel WPA Ad-Hoc support is buggy */
- if (!(wifi_caps & NM_WIFI_DEVICE_CAP_WPA))
- return FALSE;
- if (have_ap) {
- /* Ad-Hoc WPA APs won't necessarily have the PSK flag set, and
- * they don't have any pairwise ciphers. */
- if (adhoc) {
- /* coverity[dead_error_line] */
- if ( (ap_wpa & NM_802_11_AP_SEC_GROUP_TKIP)
- && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
- return TRUE;
- if ( (ap_wpa & NM_802_11_AP_SEC_GROUP_CCMP)
- && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
- return TRUE;
- } else {
- if (ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_PSK) {
- if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_TKIP)
- && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
- return TRUE;
- if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_CCMP)
- && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
- return TRUE;
- }
- }
- return FALSE;
- }
- break;
- case NMU_SEC_WPA2_PSK:
- if (adhoc)
- return FALSE; /* FIXME: Kernel WPA Ad-Hoc support is buggy */
- if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN))
- return FALSE;
- if (have_ap) {
- /* Ad-Hoc WPA APs won't necessarily have the PSK flag set, and
- * they don't have any pairwise ciphers, nor any RSA flags yet. */
- if (adhoc) {
- /* coverity[dead_error_line] */
- if (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP)
- return TRUE;
- if (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)
- return TRUE;
- } else {
- if (ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK) {
- if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_TKIP)
- && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
- return TRUE;
- if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_CCMP)
- && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
- return TRUE;
- }
- }
- return FALSE;
- }
- break;
- case NMU_SEC_WPA_ENTERPRISE:
- if (adhoc)
- return FALSE;
- if (!(wifi_caps & NM_WIFI_DEVICE_CAP_WPA))
- return FALSE;
- if (have_ap) {
- if (!(ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
- return FALSE;
- /* Ensure at least one WPA cipher is supported */
- if (!device_supports_ap_ciphers (wifi_caps, ap_wpa, FALSE))
- return FALSE;
- }
- break;
- case NMU_SEC_WPA2_ENTERPRISE:
- if (adhoc)
- return FALSE;
- if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN))
- return FALSE;
- if (have_ap) {
- if (!(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
- return FALSE;
- /* Ensure at least one WPA cipher is supported */
- if (!device_supports_ap_ciphers (wifi_caps, ap_rsn, FALSE))
- return FALSE;
- }
- break;
- default:
- good = FALSE;
- break;
- }
-
- return good;
-}
-
-/**
- * nm_utils_wep_key_valid:
- * @key: a string that might be a WEP key
- * @wep_type: the #NMWepKeyType type of the WEP key
- *
- * Checks if @key is a valid WEP key
- *
- * Returns: %TRUE if @key is a WEP key, %FALSE if not
- *
- * Since: 0.9.8
- */
-gboolean
-nm_utils_wep_key_valid (const char *key, NMWepKeyType wep_type)
-{
- int keylen, i;
-
- if (!key)
- return FALSE;
-
- keylen = strlen (key);
- if ( wep_type == NM_WEP_KEY_TYPE_KEY
- || wep_type == NM_WEP_KEY_TYPE_UNKNOWN) {
- if (keylen == 10 || keylen == 26) {
- /* Hex key */
- for (i = 0; i < keylen; i++) {
- if (!g_ascii_isxdigit (key[i]))
- return FALSE;
- }
- } else if (keylen == 5 || keylen == 13) {
- /* ASCII key */
- for (i = 0; i < keylen; i++) {
- if (!g_ascii_isprint (key[i]))
- return FALSE;
- }
- } else
- return FALSE;
-
- } else if (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE) {
- if (!keylen || keylen > 64)
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- * nm_utils_wpa_psk_valid:
- * @psk: a string that might be a WPA PSK
- *
- * Checks if @psk is a valid WPA PSK
- *
- * Returns: %TRUE if @psk is a WPA PSK, %FALSE if not
- *
- * Since: 0.9.8
- */
-gboolean
-nm_utils_wpa_psk_valid (const char *psk)
-{
- int psklen, i;
-
- if (!psk)
- return FALSE;
-
- psklen = strlen (psk);
- if (psklen < 8 || psklen > 64)
- return FALSE;
-
- if (psklen == 64) {
- /* Hex PSK */
- for (i = 0; i < psklen; i++) {
- if (!g_ascii_isxdigit (psk[i]))
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/**
- * nm_utils_ip4_addresses_from_gvalue:
- * @value: #GValue containing a #GPtrArray of #GArrays of #guint32s
- *
- * Utility function to convert a #GPtrArray of #GArrays of #guint32s representing
- * a list of NetworkManager IPv4 addresses (which is a tuple of address, gateway,
- * and prefix) into a #GSList of #NMIP4Address objects. The specific format of
- * this serialization is not guaranteed to be stable and the #GArray may be
- * extended in the future.
- *
- * Returns: (transfer full) (element-type NMIP4Address): a newly allocated #GSList of #NMIP4Address objects
- **/
-GSList *
-nm_utils_ip4_addresses_from_gvalue (const GValue *value)
-{
- GPtrArray *addresses;
- int i;
- GSList *list = NULL;
-
- addresses = (GPtrArray *) g_value_get_boxed (value);
- for (i = 0; addresses && (i < addresses->len); i++) {
- GArray *array = (GArray *) g_ptr_array_index (addresses, i);
- NMIP4Address *addr;
-
- if (array->len < 3) {
- g_warning ("Ignoring invalid IP4 address");
- continue;
- }
-
- addr = nm_ip4_address_new ();
- nm_ip4_address_set_address (addr, g_array_index (array, guint32, 0));
- nm_ip4_address_set_prefix (addr, g_array_index (array, guint32, 1));
- nm_ip4_address_set_gateway (addr, g_array_index (array, guint32, 2));
- list = g_slist_prepend (list, addr);
- }
-
- return g_slist_reverse (list);
-}
-
-/**
- * nm_utils_ip4_addresses_to_gvalue:
- * @list: (element-type NMIP4Address): a list of #NMIP4Address objects
- * @value: a pointer to a #GValue into which to place the converted addresses,
- * which should be unset by the caller (when no longer needed) with
- * g_value_unset().
- *
- * Utility function to convert a #GSList of #NMIP4Address objects into a
- * #GPtrArray of #GArrays of #guint32s representing a list of NetworkManager IPv4
- * addresses (which is a tuple of address, gateway, and prefix). The specific
- * format of this serialization is not guaranteed to be stable and may be
- * extended in the future.
- **/
-void
-nm_utils_ip4_addresses_to_gvalue (GSList *list, GValue *value)
-{
- GPtrArray *addresses;
- GSList *iter;
-
- addresses = g_ptr_array_new ();
-
- for (iter = list; iter; iter = iter->next) {
- NMIP4Address *addr = (NMIP4Address *) iter->data;
- GArray *array;
- guint32 tmp;
-
- array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
-
- tmp = nm_ip4_address_get_address (addr);
- g_array_append_val (array, tmp);
-
- tmp = nm_ip4_address_get_prefix (addr);
- g_array_append_val (array, tmp);
-
- tmp = nm_ip4_address_get_gateway (addr);
- g_array_append_val (array, tmp);
-
- g_ptr_array_add (addresses, array);
- }
-
- g_value_take_boxed (value, addresses);
-}
-
-/**
- * nm_utils_ip4_routes_from_gvalue:
- * @value: #GValue containing a #GPtrArray of #GArrays of #guint32s
- *
- * Utility function to convert a #GPtrArray of #GArrays of #guint32s representing
- * a list of NetworkManager IPv4 routes (which is a tuple of route, next hop,
- * prefix, and metric) into a #GSList of #NMIP4Route objects. The specific
- * format of this serialization is not guaranteed to be stable and may be
- * extended in the future.
- *
- * Returns: (transfer full) (element-type NMIP4Route): a newly allocated #GSList of #NMIP4Route objects
- **/
-GSList *
-nm_utils_ip4_routes_from_gvalue (const GValue *value)
-{
- GPtrArray *routes;
- int i;
- GSList *list = NULL;
-
- routes = (GPtrArray *) g_value_get_boxed (value);
- for (i = 0; routes && (i < routes->len); i++) {
- GArray *array = (GArray *) g_ptr_array_index (routes, i);
- NMIP4Route *route;
-
- if (array->len < 4) {
- g_warning ("Ignoring invalid IP4 route");
- continue;
- }
-
- route = nm_ip4_route_new ();
- nm_ip4_route_set_dest (route, g_array_index (array, guint32, 0));
- nm_ip4_route_set_prefix (route, g_array_index (array, guint32, 1));
- nm_ip4_route_set_next_hop (route, g_array_index (array, guint32, 2));
- nm_ip4_route_set_metric (route, g_array_index (array, guint32, 3));
- list = g_slist_prepend (list, route);
- }
-
- return g_slist_reverse (list);
-}
-
-/**
- * nm_utils_ip4_routes_to_gvalue:
- * @list: (element-type NMIP4Route): a list of #NMIP4Route objects
- * @value: a pointer to a #GValue into which to place the converted routes,
- * which should be unset by the caller (when no longer needed) with
- * g_value_unset().
- *
- * Utility function to convert a #GSList of #NMIP4Route objects into a
- * #GPtrArray of #GArrays of #guint32s representing a list of NetworkManager IPv4
- * routes (which is a tuple of route, next hop, prefix, and metric). The
- * specific format of this serialization is not guaranteed to be stable and may
- * be extended in the future.
- **/
-void
-nm_utils_ip4_routes_to_gvalue (GSList *list, GValue *value)
-{
- GPtrArray *routes;
- GSList *iter;
-
- routes = g_ptr_array_new ();
-
- for (iter = list; iter; iter = iter->next) {
- NMIP4Route *route = (NMIP4Route *) iter->data;
- GArray *array;
- guint32 tmp;
-
- array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
-
- tmp = nm_ip4_route_get_dest (route);
- g_array_append_val (array, tmp);
-
- tmp = nm_ip4_route_get_prefix (route);
- g_array_append_val (array, tmp);
-
- tmp = nm_ip4_route_get_next_hop (route);
- g_array_append_val (array, tmp);
-
- tmp = nm_ip4_route_get_metric (route);
- g_array_append_val (array, tmp);
-
- g_ptr_array_add (routes, array);
- }
-
- g_value_take_boxed (value, routes);
-}
-
-/**
- * nm_utils_ip4_netmask_to_prefix:
- * @netmask: an IPv4 netmask in network byte order
- *
- * Returns: the CIDR prefix represented by the netmask
- **/
-guint32
-nm_utils_ip4_netmask_to_prefix (guint32 netmask)
-{
- guint32 prefix;
- guint8 v;
- const guint8 *p = (guint8 *) &netmask;
-
- if (p[3]) {
- prefix = 24;
- v = p[3];
- } else if (p[2]) {
- prefix = 16;
- v = p[2];
- } else if (p[1]) {
- prefix = 8;
- v = p[1];
- } else {
- prefix = 0;
- v = p[0];
- }
-
- while (v) {
- prefix++;
- v <<= 1;
- }
-
- return prefix;
-}
-
-/**
- * nm_utils_ip4_prefix_to_netmask:
- * @prefix: a CIDR prefix
- *
- * Returns: the netmask represented by the prefix, in network byte order
- **/
-guint32
-nm_utils_ip4_prefix_to_netmask (guint32 prefix)
-{
- return _nm_utils_ip4_prefix_to_netmask (prefix);
-}
-
-/**
- * nm_utils_ip4_get_default_prefix:
- * @ip: an IPv4 address (in network byte order)
- *
- * When the Internet was originally set up, various ranges of IP addresses were
- * segmented into three network classes: A, B, and C. This function will return
- * a prefix that is associated with the IP address specified defining where it
- * falls in the predefined classes.
- *
- * Returns: the default class prefix for the given IP
- **/
-/* The function is originally from ipcalc.c of Red Hat's initscripts. */
-guint32
-nm_utils_ip4_get_default_prefix (guint32 ip)
-{
- return _nm_utils_ip4_get_default_prefix (ip);
-}
-
-/**
- * nm_utils_ip6_addresses_from_gvalue:
- * @value: gvalue containing a GPtrArray of GValueArrays of (GArray of guchars) and #guint32
- *
- * Utility function to convert a #GPtrArray of #GValueArrays of (#GArray of guchars) and #guint32
- * representing a list of NetworkManager IPv6 addresses (which is a tuple of address,
- * prefix, and gateway), into a #GSList of #NMIP6Address objects. The specific format of
- * this serialization is not guaranteed to be stable and the #GValueArray may be
- * extended in the future.
- *
- * Returns: (transfer full) (element-type NMIP6Address): a newly allocated #GSList of #NMIP6Address objects
- **/
-GSList *
-nm_utils_ip6_addresses_from_gvalue (const GValue *value)
-{
- GPtrArray *addresses;
- int i;
- GSList *list = NULL;
-
- addresses = (GPtrArray *) g_value_get_boxed (value);
-
- for (i = 0; addresses && (i < addresses->len); i++) {
- GValueArray *elements = (GValueArray *) g_ptr_array_index (addresses, i);
- GValue *tmp;
- GByteArray *ba_addr;
- GByteArray *ba_gw = NULL;
- NMIP6Address *addr;
- guint32 prefix;
-
- if (elements->n_values < 2 || elements->n_values > 3) {
- g_warning ("%s: ignoring invalid IP6 address structure", __func__);
- continue;
- }
-
- /* Third element (gateway) is optional */
- if ( !_nm_utils_gvalue_array_validate (elements, 2, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT)
- && !_nm_utils_gvalue_array_validate (elements, 3, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY)) {
- g_warning ("%s: ignoring invalid IP6 address structure", __func__);
- continue;
- }
-
- tmp = g_value_array_get_nth (elements, 0);
- ba_addr = g_value_get_boxed (tmp);
- if (ba_addr->len != 16) {
- g_warning ("%s: ignoring invalid IP6 address of length %d",
- __func__, ba_addr->len);
- continue;
- }
-
- tmp = g_value_array_get_nth (elements, 1);
- prefix = g_value_get_uint (tmp);
- if (prefix > 128) {
- g_warning ("%s: ignoring invalid IP6 prefix %d",
- __func__, prefix);
- continue;
- }
-
- if (elements->n_values == 3) {
- tmp = g_value_array_get_nth (elements, 2);
- ba_gw = g_value_get_boxed (tmp);
- if (ba_gw->len != 16) {
- g_warning ("%s: ignoring invalid IP6 gateway address of length %d",
- __func__, ba_gw->len);
- continue;
- }
- }
-
- addr = nm_ip6_address_new ();
- nm_ip6_address_set_prefix (addr, prefix);
- nm_ip6_address_set_address (addr, (const struct in6_addr *) ba_addr->data);
- if (ba_gw)
- nm_ip6_address_set_gateway (addr, (const struct in6_addr *) ba_gw->data);
-
- list = g_slist_prepend (list, addr);
- }
-
- return g_slist_reverse (list);
-}
-
-/**
- * nm_utils_ip6_addresses_to_gvalue:
- * @list: (element-type NMIP6Address): a list of #NMIP6Address objects
- * @value: a pointer to a #GValue into which to place the converted addresses,
- * which should be unset by the caller (when no longer needed) with
- * g_value_unset().
- *
- * Utility function to convert a #GSList of #NMIP6Address objects into a
- * #GPtrArray of #GValueArrays representing a list of NetworkManager IPv6 addresses
- * (which is a tuple of address, prefix, and gateway). The specific format of
- * this serialization is not guaranteed to be stable and may be extended in the
- * future.
- **/
-void
-nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value)
-{
- GPtrArray *addresses;
- GSList *iter;
-
- addresses = g_ptr_array_new ();
-
- for (iter = list; iter; iter = iter->next) {
- NMIP6Address *addr = (NMIP6Address *) iter->data;
- GValueArray *array;
- GValue element = G_VALUE_INIT;
- GByteArray *ba;
-
- array = g_value_array_new (3);
-
- /* IP address */
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- ba = g_byte_array_new ();
- g_byte_array_append (ba, (guint8 *) nm_ip6_address_get_address (addr), 16);
- g_value_take_boxed (&element, ba);
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- /* Prefix */
- g_value_init (&element, G_TYPE_UINT);
- g_value_set_uint (&element, nm_ip6_address_get_prefix (addr));
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- /* Gateway */
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- ba = g_byte_array_new ();
- g_byte_array_append (ba, (guint8 *) nm_ip6_address_get_gateway (addr), 16);
- g_value_take_boxed (&element, ba);
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- g_ptr_array_add (addresses, array);
- }
-
- g_value_take_boxed (value, addresses);
-}
-
-/**
- * nm_utils_ip6_routes_from_gvalue:
- * @value: #GValue containing a #GPtrArray of #GValueArrays of (#GArray of #guchars), #guint32,
- * (#GArray of #guchars), and #guint32
- *
- * Utility function #GPtrArray of #GValueArrays of (#GArray of #guchars), #guint32,
- * (#GArray of #guchars), and #guint32 representing a list of NetworkManager IPv6
- * routes (which is a tuple of destination, prefix, next hop, and metric)
- * into a #GSList of #NMIP6Route objects. The specific format of this serialization
- * is not guaranteed to be stable and may be extended in the future.
- *
- * Returns: (transfer full) (element-type NMIP6Route): a newly allocated #GSList of #NMIP6Route objects
- **/
-GSList *
-nm_utils_ip6_routes_from_gvalue (const GValue *value)
-{
- GPtrArray *routes;
- int i;
- GSList *list = NULL;
-
- routes = (GPtrArray *) g_value_get_boxed (value);
- for (i = 0; routes && (i < routes->len); i++) {
- GValueArray *route_values = (GValueArray *) g_ptr_array_index (routes, i);
- GByteArray *dest, *next_hop;
- guint prefix, metric;
- NMIP6Route *route;
-
- if (!_nm_utils_gvalue_array_validate (route_values, 4,
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_TYPE_UINT,
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_TYPE_UINT)) {
- g_warning ("Ignoring invalid IP6 route");
- continue;
- }
-
- dest = g_value_get_boxed (g_value_array_get_nth (route_values, 0));
- if (dest->len != 16) {
- g_warning ("%s: ignoring invalid IP6 dest address of length %d",
- __func__, dest->len);
- continue;
- }
-
- prefix = g_value_get_uint (g_value_array_get_nth (route_values, 1));
-
- next_hop = g_value_get_boxed (g_value_array_get_nth (route_values, 2));
- if (next_hop->len != 16) {
- g_warning ("%s: ignoring invalid IP6 next_hop address of length %d",
- __func__, next_hop->len);
- continue;
- }
-
- metric = g_value_get_uint (g_value_array_get_nth (route_values, 3));
-
- route = nm_ip6_route_new ();
- nm_ip6_route_set_dest (route, (struct in6_addr *)dest->data);
- nm_ip6_route_set_prefix (route, prefix);
- nm_ip6_route_set_next_hop (route, (struct in6_addr *)next_hop->data);
- nm_ip6_route_set_metric (route, metric);
- list = g_slist_prepend (list, route);
- }
-
- return g_slist_reverse (list);
-}
-
-/**
- * nm_utils_ip6_routes_to_gvalue:
- * @list: (element-type NMIP6Route): a list of #NMIP6Route objects
- * @value: a pointer to a #GValue into which to place the converted routes,
- * which should be unset by the caller (when no longer needed) with
- * g_value_unset().
- *
- * Utility function to convert a #GSList of #NMIP6Route objects into a #GPtrArray of
- * #GValueArrays of (#GArray of #guchars), #guint32, (#GArray of #guchars), and #guint32
- * representing a list of NetworkManager IPv6 routes (which is a tuple of destination,
- * prefix, next hop, and metric). The specific format of this serialization is not
- * guaranteed to be stable and may be extended in the future.
- **/
-void
-nm_utils_ip6_routes_to_gvalue (GSList *list, GValue *value)
-{
- GPtrArray *routes;
- GSList *iter;
-
- routes = g_ptr_array_new ();
-
- for (iter = list; iter; iter = iter->next) {
- NMIP6Route *route = (NMIP6Route *) iter->data;
- GValueArray *array;
- const struct in6_addr *addr;
- GByteArray *ba;
- GValue element = G_VALUE_INIT;
-
- array = g_value_array_new (4);
-
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- addr = nm_ip6_route_get_dest (route);
- ba = g_byte_array_new ();
- g_byte_array_append (ba, (guchar *)addr, sizeof (*addr));
- g_value_take_boxed (&element, ba);
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- g_value_init (&element, G_TYPE_UINT);
- g_value_set_uint (&element, nm_ip6_route_get_prefix (route));
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- addr = nm_ip6_route_get_next_hop (route);
- ba = g_byte_array_new ();
- g_byte_array_append (ba, (guchar *)addr, sizeof (*addr));
- g_value_take_boxed (&element, ba);
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- g_value_init (&element, G_TYPE_UINT);
- g_value_set_uint (&element, nm_ip6_route_get_metric (route));
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- g_ptr_array_add (routes, array);
- }
-
- g_value_take_boxed (value, routes);
-}
-
-/**
- * nm_utils_ip6_dns_from_gvalue: (skip)
- * @value: a #GValue
- *
- * Converts a #GValue containing a #GPtrArray of IP6 DNS, represented as
- * #GByteArrays into a #GSList of <literal><type>struct in6_addr</type></literal>s.
- *
- * Returns: a #GSList of IP6 addresses.
- */
-GSList *
-nm_utils_ip6_dns_from_gvalue (const GValue *value)
-{
- GPtrArray *dns;
- int i;
- GSList *list = NULL;
-
- dns = (GPtrArray *) g_value_get_boxed (value);
- for (i = 0; dns && (i < dns->len); i++) {
- GByteArray *bytearray = (GByteArray *) g_ptr_array_index (dns, i);
- struct in6_addr *addr;
-
- if (bytearray->len != 16) {
- g_warning ("%s: ignoring invalid IP6 address of length %d",
- __func__, bytearray->len);
- continue;
- }
-
- addr = g_malloc0 (sizeof (struct in6_addr));
- memcpy (addr->s6_addr, bytearray->data, bytearray->len);
- list = g_slist_prepend (list, addr);
- }
-
- return g_slist_reverse (list);
-}
-
-/**
- * nm_utils_ip6_dns_to_gvalue: (skip)
- * @list: a list of #NMIP6Route objects
- * @value: a pointer to a #GValue into which to place the converted DNS server
- * addresses, which should be unset by the caller (when no longer needed) with
- * g_value_unset().
- *
- * Utility function to convert a #GSList of <literal><type>struct
- * in6_addr</type></literal> structs into a #GPtrArray of #GByteArrays
- * representing each server's IPv6 addresses in network byte order.
- * The specific format of this serialization is not guaranteed to be
- * stable and may be extended in the future.
- */
-void
-nm_utils_ip6_dns_to_gvalue (GSList *list, GValue *value)
-{
- GPtrArray *dns;
- GSList *iter;
-
- dns = g_ptr_array_new ();
-
- for (iter = list; iter; iter = iter->next) {
- struct in6_addr *addr = (struct in6_addr *) iter->data;
- GByteArray *bytearray;
-
- bytearray = g_byte_array_sized_new (16);
- g_byte_array_append (bytearray, (guint8 *) addr->s6_addr, 16);
- g_ptr_array_add (dns, bytearray);
- }
-
- g_value_take_boxed (value, dns);
-}
-
-/**
- * nm_utils_uuid_generate:
- *
- * Returns: a newly allocated UUID suitable for use as the #NMSettingConnection
- * object's #NMSettingConnection:id: property. Should be freed with g_free()
- **/
-char *
-nm_utils_uuid_generate (void)
-{
- uuid_t uuid;
- char *buf;
-
- buf = g_malloc0 (37);
- uuid_generate_random (uuid);
- uuid_unparse_lower (uuid, &buf[0]);
- return buf;
-}
-
-/**
- * nm_utils_uuid_generate_from_string:
- * @s: a string to use as the seed for the UUID
- *
- * For a given @s, this function will always return the same UUID.
- *
- * Returns: a newly allocated UUID suitable for use as the #NMSettingConnection
- * object's #NMSettingConnection:id: property
- **/
-char *
-nm_utils_uuid_generate_from_string (const char *s)
-{
- GError *error = NULL;
- uuid_t uuid;
- char *buf = NULL;
-
- g_return_val_if_fail (s && *s, NULL);
-
- if (!nm_utils_init (&error)) {
- g_warning ("error initializing crypto: %s", error->message);
- g_error_free (error);
- return NULL;
- }
-
- if (!crypto_md5_hash (NULL, 0, s, strlen (s), (char *) uuid, sizeof (uuid), &error)) {
- g_warning ("error generating UUID: %s", error->message);
- g_error_free (error);
- return NULL;
- }
-
- buf = g_malloc0 (37);
- uuid_unparse_lower (uuid, &buf[0]);
-
- return buf;
-}
-
-static char *
-make_key (const char *cipher,
- const char *salt,
- const gsize salt_len,
- const char *password,
- gsize *out_len,
- GError **error)
-{
- char *key;
- guint32 digest_len = 24; /* DES-EDE3-CBC */
-
- g_return_val_if_fail (salt != NULL, NULL);
- g_return_val_if_fail (salt_len >= 8, NULL);
- g_return_val_if_fail (password != NULL, NULL);
- g_return_val_if_fail (out_len != NULL, NULL);
-
- if (!strcmp (cipher, "DES-EDE3-CBC"))
- digest_len = 24;
- else if (!strcmp (cipher, "AES-128-CBC"))
- digest_len = 16;
-
- key = g_malloc0 (digest_len + 1);
-
- if (!crypto_md5_hash (salt, salt_len, password, strlen (password), key, digest_len, error)) {
- *out_len = 0;
- memset (key, 0, digest_len);
- g_free (key);
- key = NULL;
- } else
- *out_len = digest_len;
-
- return key;
-}
-
-/**
- * nm_utils_rsa_key_encrypt_helper:
- * @cipher: cipher to use for encryption ("DES-EDE3-CBC" or "AES-128-CBC")
- * @data: RSA private key data to be encrypted
- * @in_password: (allow-none): existing password to use, if any
- * @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
- * and returned in this argument
- * @error: detailed error information on return, if an error occurred
- *
- * Encrypts the given RSA private key data with the given password (or generates
- * a password if no password was given) and converts the data to PEM format
- * suitable for writing to a file.
- *
- * Returns: (transfer full): on success, PEM-formatted data suitable for writing to a PEM-formatted
- * certificate/private key file.
- **/
-static GByteArray *
-nm_utils_rsa_key_encrypt_helper (const char *cipher,
- const GByteArray *data,
- const char *in_password,
- char **out_password,
- GError **error)
-{
- char salt[16];
- int salt_len;
- char *key = NULL, *enc = NULL, *pw_buf[32];
- gsize key_len = 0, enc_len = 0;
- GString *pem = NULL;
- char *tmp, *tmp_password = NULL;
- int left;
- const char *p;
- GByteArray *ret = NULL;
-
- g_return_val_if_fail (!g_strcmp0 (cipher, CIPHER_DES_EDE3_CBC) || !g_strcmp0 (cipher, CIPHER_AES_CBC), NULL);
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (data->len > 0, NULL);
- if (out_password)
- g_return_val_if_fail (*out_password == NULL, NULL);
-
- /* Make the password if needed */
- if (!in_password) {
- if (!crypto_randomize (pw_buf, sizeof (pw_buf), error))
- return NULL;
- in_password = tmp_password = nm_utils_bin2hexstr ((const char *) pw_buf, sizeof (pw_buf), -1);
- }
-
- if (g_strcmp0 (cipher, CIPHER_AES_CBC) == 0)
- salt_len = 16;
- else
- salt_len = 8;
-
- if (!crypto_randomize (salt, salt_len, error))
- goto out;
-
- key = make_key (cipher, &salt[0], salt_len, in_password, &key_len, error);
- if (!key)
- goto out;
-
- enc = crypto_encrypt (cipher, data, salt, salt_len, key, key_len, &enc_len, error);
- if (!enc)
- goto out;
-
- pem = g_string_sized_new (enc_len * 2 + 100);
- g_string_append (pem, "-----BEGIN RSA PRIVATE KEY-----\n");
- g_string_append (pem, "Proc-Type: 4,ENCRYPTED\n");
-
- /* Convert the salt to a hex string */
- tmp = nm_utils_bin2hexstr ((const char *) salt, salt_len, salt_len * 2);
- g_string_append_printf (pem, "DEK-Info: %s,%s\n\n", cipher, tmp);
- g_free (tmp);
-
- /* Convert the encrypted key to a base64 string */
- p = tmp = g_base64_encode ((const guchar *) enc, enc_len);
- left = strlen (tmp);
- while (left > 0) {
- g_string_append_len (pem, p, (left < 64) ? left : 64);
- g_string_append_c (pem, '\n');
- left -= 64;
- p += 64;
- }
- g_free (tmp);
-
- g_string_append (pem, "-----END RSA PRIVATE KEY-----\n");
-
- ret = g_byte_array_sized_new (pem->len);
- g_byte_array_append (ret, (const unsigned char *) pem->str, pem->len);
- if (tmp_password && out_password)
- *out_password = g_strdup (tmp_password);
-
-out:
- if (key) {
- memset (key, 0, key_len);
- g_free (key);
- }
- if (enc) {
- memset (enc, 0, enc_len);
- g_free (enc);
- }
- if (pem)
- g_string_free (pem, TRUE);
-
- if (tmp_password) {
- memset (tmp_password, 0, strlen (tmp_password));
- g_free (tmp_password);
- }
-
- return ret;
-}
-
-/**
- * nm_utils_rsa_key_encrypt:
- * @data: RSA private key data to be encrypted
- * @in_password: (allow-none): existing password to use, if any
- * @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
- * and returned in this argument
- * @error: detailed error information on return, if an error occurred
- *
- * Encrypts the given RSA private key data with the given password (or generates
- * a password if no password was given) and converts the data to PEM format
- * suitable for writing to a file. It uses Triple DES cipher for the encryption.
- *
- * Returns: (transfer full): on success, PEM-formatted data suitable for writing to a PEM-formatted
- * certificate/private key file.
- **/
-GByteArray *
-nm_utils_rsa_key_encrypt (const GByteArray *data,
- const char *in_password,
- char **out_password,
- GError **error)
-{
-
- return nm_utils_rsa_key_encrypt_helper (CIPHER_DES_EDE3_CBC,
- data,
- in_password,
- out_password,
- error);
-}
-
-/**
- * nm_utils_rsa_key_encrypt_aes:
- * @data: RSA private key data to be encrypted
- * @in_password: (allow-none): existing password to use, if any
- * @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
- * and returned in this argument
- * @error: detailed error information on return, if an error occurred
- *
- * Encrypts the given RSA private key data with the given password (or generates
- * a password if no password was given) and converts the data to PEM format
- * suitable for writing to a file. It uses AES cipher for the encryption.
- *
- * Returns: (transfer full): on success, PEM-formatted data suitable for writing to a PEM-formatted
- * certificate/private key file.
- **/
-GByteArray *
-nm_utils_rsa_key_encrypt_aes (const GByteArray *data,
- const char *in_password,
- char **out_password,
- GError **error)
-{
-
- return nm_utils_rsa_key_encrypt_helper (CIPHER_AES_CBC,
- data,
- in_password,
- out_password,
- error);
-}
-
-/**
- * nm_utils_file_is_pkcs12:
- * @filename: name of the file to test
- *
- * Utility function to find out if the @filename is in PKCS#<!-- -->12 format.
- *
- * Returns: %TRUE if the file is PKCS#<!-- -->12, %FALSE if it is not
- **/
-gboolean
-nm_utils_file_is_pkcs12 (const char *filename)
-{
- return crypto_is_pkcs12_file (filename, NULL);
-}
-
-/*****************************************************************************/
-
-/**
- * nm_utils_file_search_in_paths:
- * @progname: the helper program name, like "iptables"
- * Must be a non-empty string, without path separator (/).
- * @try_first: (allow-none): a custom path to try first before searching.
- * It is silently ignored if it is empty or not an absolute path.
- * @paths: (allow-none): a %NULL terminated list of search paths.
- * Can be empty or %NULL, in which case only @try_first is checked.
- * @file_test_flags: the flags passed to g_file_test() when searching
- * for @progname. Set it to 0 to skip the g_file_test().
- * @predicate: (scope call): if given, pass the file name to this function
- * for additional checks. This check is performed after the check for
- * @file_test_flags. You cannot omit both @file_test_flags and @predicate.
- * @user_data: (closure) (allow-none): user data for @predicate function.
- * @error: (allow-none): on failure, set a "not found" error %G_IO_ERROR %G_IO_ERROR_NOT_FOUND.
- *
- * Searches for a @progname file in a list of search @paths.
- *
- * Returns: (transfer none): the full path to the helper, if found, or %NULL if not found.
- * The returned string is not owned by the caller, but later
- * 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,
- GFileTest file_test_flags,
- NMUtilsFileSearchInPathsPredicate predicate,
- gpointer user_data,
- GError **error)
-{
- GString *tmp;
- const char *ret;
-
- g_return_val_if_fail (!error || !*error, NULL);
- g_return_val_if_fail (progname && progname[0] && !strchr (progname, '/'), NULL);
- g_return_val_if_fail (file_test_flags || predicate, NULL);
-
- /* Only consider @try_first if it is a valid, absolute path. This makes
- * it simpler to pass in a path from configure checks. */
- if ( try_first
- && try_first[0] == '/'
- && (file_test_flags == 0 || g_file_test (try_first, file_test_flags))
- && (!predicate || predicate (try_first, user_data)))
- return g_intern_string (try_first);
-
- if (!paths || !*paths)
- goto NOT_FOUND;
-
- tmp = g_string_sized_new (50);
- for (; *paths; paths++) {
- if (!*paths)
- continue;
- g_string_append (tmp, *paths);
- if (tmp->str[tmp->len - 1] != '/')
- g_string_append_c (tmp, '/');
- g_string_append (tmp, progname);
- if ( (file_test_flags == 0 || g_file_test (tmp->str, file_test_flags))
- && (!predicate || predicate (tmp->str, user_data))) {
- ret = g_intern_string (tmp->str);
- g_string_free (tmp, TRUE);
- return ret;
- }
- g_string_set_size (tmp, 0);
- }
- g_string_free (tmp, TRUE);
-
-NOT_FOUND:
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, _("Could not find \"%s\" binary"), progname);
- return NULL;
-}
-
-/*****************************************************************************/
-
-/* Band, channel/frequency stuff for wireless */
-struct cf_pair {
- guint32 chan;
- guint32 freq;
-};
-
-static struct cf_pair a_table[] = {
- /* A band */
- { 7, 5035 },
- { 8, 5040 },
- { 9, 5045 },
- { 11, 5055 },
- { 12, 5060 },
- { 16, 5080 },
- { 34, 5170 },
- { 36, 5180 },
- { 38, 5190 },
- { 40, 5200 },
- { 42, 5210 },
- { 44, 5220 },
- { 46, 5230 },
- { 48, 5240 },
- { 50, 5250 },
- { 52, 5260 },
- { 56, 5280 },
- { 58, 5290 },
- { 60, 5300 },
- { 64, 5320 },
- { 100, 5500 },
- { 104, 5520 },
- { 108, 5540 },
- { 112, 5560 },
- { 116, 5580 },
- { 120, 5600 },
- { 124, 5620 },
- { 128, 5640 },
- { 132, 5660 },
- { 136, 5680 },
- { 140, 5700 },
- { 149, 5745 },
- { 152, 5760 },
- { 153, 5765 },
- { 157, 5785 },
- { 160, 5800 },
- { 161, 5805 },
- { 165, 5825 },
- { 183, 4915 },
- { 184, 4920 },
- { 185, 4925 },
- { 187, 4935 },
- { 188, 4945 },
- { 192, 4960 },
- { 196, 4980 },
- { 0, -1 }
-};
-
-static struct cf_pair bg_table[] = {
- /* B/G band */
- { 1, 2412 },
- { 2, 2417 },
- { 3, 2422 },
- { 4, 2427 },
- { 5, 2432 },
- { 6, 2437 },
- { 7, 2442 },
- { 8, 2447 },
- { 9, 2452 },
- { 10, 2457 },
- { 11, 2462 },
- { 12, 2467 },
- { 13, 2472 },
- { 14, 2484 },
- { 0, -1 }
-};
-
-/**
- * nm_utils_wifi_freq_to_channel:
- * @freq: frequency
- *
- * Utility function to translate a Wi-Fi frequency to its corresponding channel.
- *
- * Returns: the channel represented by the frequency or 0
- **/
-guint32
-nm_utils_wifi_freq_to_channel (guint32 freq)
-{
- int i = 0;
-
- if (freq > 4900) {
- while (a_table[i].chan && (a_table[i].freq != freq))
- i++;
- return a_table[i].chan;
- } else {
- while (bg_table[i].chan && (bg_table[i].freq != freq))
- i++;
- return bg_table[i].chan;
- }
-
- return 0;
-}
-
-/**
- * nm_utils_wifi_channel_to_freq:
- * @channel: channel
- * @band: frequency band for wireless ("a" or "bg")
- *
- * Utility function to translate a Wi-Fi channel to its corresponding frequency.
- *
- * Returns: the frequency represented by the channel of the band,
- * or -1 when the freq is invalid, or 0 when the band
- * is invalid
- **/
-guint32
-nm_utils_wifi_channel_to_freq (guint32 channel, const char *band)
-{
- int i = 0;
-
- if (!strcmp (band, "a")) {
- while (a_table[i].chan && (a_table[i].chan != channel))
- i++;
- return a_table[i].freq;
- } else if (!strcmp (band, "bg")) {
- while (bg_table[i].chan && (bg_table[i].chan != channel))
- i++;
- return bg_table[i].freq;
- }
-
- return 0;
-}
-
-/**
- * nm_utils_wifi_find_next_channel:
- * @channel: current channel
- * @direction: whether going downward (0 or less) or upward (1 or more)
- * @band: frequency band for wireless ("a" or "bg")
- *
- * Utility function to find out next/previous Wi-Fi channel for a channel.
- *
- * Returns: the next channel in the specified direction or 0
- **/
-guint32
-nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band)
-{
- size_t a_size = sizeof (a_table) / sizeof (struct cf_pair);
- size_t bg_size = sizeof (bg_table) / sizeof (struct cf_pair);
- struct cf_pair *pair = NULL;
-
- if (!strcmp (band, "a")) {
- if (channel < a_table[0].chan)
- return a_table[0].chan;
- if (channel > a_table[a_size - 2].chan)
- return a_table[a_size - 2].chan;
- pair = &a_table[0];
- } else if (!strcmp (band, "bg")) {
- if (channel < bg_table[0].chan)
- return bg_table[0].chan;
- if (channel > bg_table[bg_size - 2].chan)
- return bg_table[bg_size - 2].chan;
- pair = &bg_table[0];
- } else {
- g_assert_not_reached ();
- return 0;
- }
-
- while (pair->chan) {
- if (channel == pair->chan)
- return channel;
- if ((channel < (pair+1)->chan) && (channel > pair->chan)) {
- if (direction > 0)
- return (pair+1)->chan;
- else
- return pair->chan;
- }
- pair++;
- }
- return 0;
-}
-
-/**
- * nm_utils_wifi_is_channel_valid:
- * @channel: channel
- * @band: frequency band for wireless ("a" or "bg")
- *
- * Utility function to verify Wi-Fi channel validity.
- *
- * Returns: %TRUE or %FALSE
- **/
-gboolean
-nm_utils_wifi_is_channel_valid (guint32 channel, const char *band)
-{
- struct cf_pair *table = NULL;
- int i = 0;
-
- if (!strcmp (band, "a"))
- table = a_table;
- else if (!strcmp (band, "bg"))
- table = bg_table;
- else
- return FALSE;
-
- while (table[i].chan && (table[i].chan != channel))
- i++;
-
- if (table[i].chan != 0)
- return TRUE;
- else
- return FALSE;
-}
-
-/**
- * nm_utils_hwaddr_len:
- * @type: the type of address; either <literal>ARPHRD_ETHER</literal> or
- * <literal>ARPHRD_INFINIBAND</literal>
- *
- * Returns the length in octets of a hardware address of type @type.
- *
- * Return value: the positive length, or -1 if the type is unknown/unsupported.
- */
-int
-nm_utils_hwaddr_len (int type)
-{
- if (type == ARPHRD_ETHER)
- return ETH_ALEN;
- else if (type == ARPHRD_INFINIBAND)
- return INFINIBAND_ALEN;
- else
- return -1;
-}
-
-/**
- * nm_utils_hwaddr_type:
- * @len: the length of hardware address in bytes
- *
- * Returns the type (either <literal>ARPHRD_ETHER</literal> or
- * <literal>ARPHRD_INFINIBAND</literal>) of the raw address given its length.
- *
- * Return value: the type, either <literal>ARPHRD_ETHER</literal> or
- * <literal>ARPHRD_INFINIBAND</literal>. If the length is unexpected, return -1
- * (unsupported type/length).
- *
- * Deprecated: This could not be extended to cover other types, since
- * there is not a one-to-one mapping between types and lengths. This
- * was mostly only used to get a type to pass to
- * nm_utils_hwaddr_ntoa() or nm_utils_hwaddr_aton() when you only had
- * a length; but you can just use nm_utils_hwaddr_ntoa_len() or
- * nm_utils_hwaddr_aton_len() now instead.
- */
-int
-nm_utils_hwaddr_type (int len)
-{
- if (len == ETH_ALEN)
- return ARPHRD_ETHER;
- else if (len == INFINIBAND_ALEN)
- return ARPHRD_INFINIBAND;
- else
- return -1;
-}
-
-#define HEXVAL(c) ((c) <= '9' ? (c) - '0' : ((c) & 0x4F) - 'A' + 10)
-
-/**
- * nm_utils_hwaddr_aton:
- * @asc: the ASCII representation of a hardware address
- * @type: the type of address; either <literal>ARPHRD_ETHER</literal> or
- * <literal>ARPHRD_INFINIBAND</literal>
- * @buffer: buffer to store the result into
- *
- * Parses @asc and converts it to binary form in @buffer. See
- * nm_utils_hwaddr_atoba() if you'd rather have the result in a
- * #GByteArray.
- *
- * See also nm_utils_hwaddr_aton_len(), which takes an output length
- * instead of a type.
- *
- * Return value: @buffer, or %NULL if @asc couldn't be parsed
- */
-guint8 *
-nm_utils_hwaddr_aton (const char *asc, int type, gpointer buffer)
-{
- int len = nm_utils_hwaddr_len (type);
-
- if (len <= 0) {
- g_return_val_if_reached (NULL);
- return NULL;
- }
- return nm_utils_hwaddr_aton_len (asc, buffer, len);
-}
-
-/**
- * nm_utils_hwaddr_atoba:
- * @asc: the ASCII representation of a hardware address
- * @type: the type of address; either <literal>ARPHRD_ETHER</literal> or
- * <literal>ARPHRD_INFINIBAND</literal>
- *
- * Parses @asc and converts it to binary form in a #GByteArray. See
- * nm_utils_hwaddr_aton() if you don't want a #GByteArray.
- *
- * Return value: (transfer full): a new #GByteArray, or %NULL if @asc couldn't
- * be parsed
- */
-GByteArray *
-nm_utils_hwaddr_atoba (const char *asc, int type)
-{
- GByteArray *ba;
- int len = nm_utils_hwaddr_len (type);
-
- if (len <= 0) {
- g_return_val_if_reached (NULL);
- return NULL;
- }
-
- ba = g_byte_array_sized_new (len);
- g_byte_array_set_size (ba, len);
- if (!nm_utils_hwaddr_aton_len (asc, ba->data, len)) {
- g_byte_array_unref (ba);
- return NULL;
- }
-
- return ba;
-}
-
-/**
- * nm_utils_hwaddr_ntoa:
- * @addr: a binary hardware address
- * @type: the type of address; either <literal>ARPHRD_ETHER</literal> or
- * <literal>ARPHRD_INFINIBAND</literal>
- *
- * Converts @addr to textual form.
- *
- * See also nm_utils_hwaddr_ntoa_len(), which takes a length instead of
- * a type.
- *
- * Return value: (transfer full): the textual form of @addr
- */
-char *
-nm_utils_hwaddr_ntoa (gconstpointer addr, int type)
-{
- int len = nm_utils_hwaddr_len (type);
-
- if (len <= 0) {
- g_return_val_if_reached (NULL);
- return NULL;
- }
-
- return nm_utils_hwaddr_ntoa_len (addr, len);
-}
-
-/**
- * nm_utils_hwaddr_aton_len:
- * @asc: the ASCII representation of a hardware address
- * @buffer: buffer to store the result into
- * @length: the expected length in bytes of the result and
- * the size of the buffer in bytes.
- *
- * Parses @asc and converts it to binary form in @buffer.
- * Bytes in @asc can be sepatared by colons (:), or hyphens (-), but not mixed.
- *
- * Return value: @buffer, or %NULL if @asc couldn't be parsed
- * or would be shorter or longer than @length.
- *
- * Since: 0.9.10
- */
-guint8 *
-nm_utils_hwaddr_aton_len (const char *asc, gpointer buffer, gsize length)
-{
- const char *in = asc;
- guint8 *out = (guint8 *)buffer;
- char delimiter = '\0';
-
- if (!asc) {
- g_return_val_if_reached (NULL);
- return NULL;
- }
- g_return_val_if_fail (buffer, NULL);
- g_return_val_if_fail (length, NULL);
-
- while (length && *in) {
- guint8 d1 = in[0], d2 = in[1];
-
- if (!g_ascii_isxdigit (d1))
- return NULL;
-
- /* If there's no leading zero (ie "aa:b:cc") then fake it */
- if (d2 && g_ascii_isxdigit (d2)) {
- *out++ = (HEXVAL (d1) << 4) + HEXVAL (d2);
- in += 2;
- } else {
- /* Fake leading zero */
- *out++ = (HEXVAL ('0') << 4) + HEXVAL (d1);
- in += 1;
- }
-
- length--;
- if (*in) {
- if (delimiter == '\0') {
- if (*in == ':' || *in == '-')
- delimiter = *in;
- else
- return NULL;
- } else {
- if (*in != delimiter)
- return NULL;
- }
- in++;
- }
- }
-
- if (length == 0 && !*in)
- return buffer;
- else
- return NULL;
-}
-
-/**
- * nm_utils_hwaddr_ntoa_len:
- * @addr: a binary hardware address
- * @length: the length of @addr
- *
- * Converts @addr to textual form.
- *
- * Return value: (transfer full): the textual form of @addr
- *
- * Since: 0.9.10
- */
-char *
-nm_utils_hwaddr_ntoa_len (gconstpointer addr, gsize length)
-{
- const guint8 *in = addr;
- char *out, *result;
- const char *LOOKUP = "0123456789ABCDEF";
-
- g_return_val_if_fail (addr != NULL, g_strdup (""));
- g_return_val_if_fail (length != 0, g_strdup (""));
-
- result = out = g_malloc (length * 3);
- for (;;) {
- guint8 v = *in++;
-
- *out++ = LOOKUP[v >> 4];
- *out++ = LOOKUP[v & 0x0F];
- if (--length == 0) {
- *out = 0;
- return result;
- }
- *out++ = ':';
- }
-}
-
-/**
- * nm_utils_hwaddr_valid:
- * @asc: the ASCII representation of a hardware address
- *
- * Parses @asc to see if it is a valid hardware address of some type.
- *
- * Return value: %TRUE if @asc appears to be a valid hardware address
- * of some type, %FALSE if not.
- *
- * Since: 0.9.10
- */
-gboolean
-nm_utils_hwaddr_valid (const char *asc)
-{
- guint8 buf[NM_UTILS_HWADDR_LEN_MAX];
- gsize in_len, out_len;
-
- if (!asc || !*asc)
- return FALSE;
- in_len = strlen (asc);
- if ((in_len + 1) % 3 != 0)
- return FALSE;
- out_len = (in_len + 1) / 3;
- if (out_len > NM_UTILS_HWADDR_LEN_MAX)
- return FALSE;
- return nm_utils_hwaddr_aton_len (asc, buf, out_len) != NULL;
-}
-
-/**
- * nm_utils_bin2hexstr:
- * @bytes: an array of bytes
- * @len: the length of the @bytes array
- * @final_len: an index where to cut off the returned string, or -1
- *
- * Converts a byte-array @bytes into a hexadecimal string.
- * If @final_len is greater than -1, the returned string is terminated at
- * that index (returned_string[final_len] == '\0'),
- *
- * Return value: (transfer full): the textual form of @bytes
- *
- * Since: 0.9.10
- */
-/*
- * Code originally by Alex Larsson <alexl@redhat.com> and
- * copyright Red Hat, Inc. under terms of the LGPL.
- */
-char *
-nm_utils_bin2hexstr (const char *bytes, int len, int final_len)
-{
- static char hex_digits[] = "0123456789abcdef";
- char *result;
- int i;
- gsize buflen = (len * 2) + 1;
-
- g_return_val_if_fail (bytes != NULL, NULL);
- g_return_val_if_fail (len > 0, NULL);
- g_return_val_if_fail (len < 4096, NULL); /* Arbitrary limit */
- if (final_len > -1)
- g_return_val_if_fail (final_len < buflen, NULL);
-
- result = g_malloc0 (buflen);
- for (i = 0; i < len; i++) {
- result[2*i] = hex_digits[(bytes[i] >> 4) & 0xf];
- result[2*i+1] = hex_digits[bytes[i] & 0xf];
- }
- /* Cut converted key off at the correct length for this cipher type */
- if (final_len > -1)
- result[final_len] = '\0';
- else
- result[buflen - 1] = '\0';
-
- return result;
-}
-
-/* From hostap, Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi> */
-/**
- * nm_utils_hex2byte:
- * @hex: a string representing a hex byte
- *
- * Converts a hex string (2 characters) into its byte representation.
- *
- * Return value: a byte, or -1 if @hex doesn't represent a hex byte
- *
- * Since: 0.9.10
- */
-int
-nm_utils_hex2byte (const char *hex)
-{
- int a, b;
- a = g_ascii_xdigit_value (*hex++);
- if (a < 0)
- return -1;
- b = g_ascii_xdigit_value (*hex++);
- if (b < 0)
- return -1;
- return (a << 4) | b;
-}
-
-/**
- * nm_utils_hexstr2bin:
- * @hex: an hex string
- * @len: the length of the @hex string (it has to be even)
- *
- * Converts a hexadecimal string @hex into a byte-array. The returned array
- * length is @len/2.
- *
- * Return value: (transfer full): a array of bytes, or %NULL on error
- *
- * Since: 0.9.10
- */
-char *
-nm_utils_hexstr2bin (const char *hex, size_t len)
-{
- size_t i;
- int a;
- const char * ipos = hex;
- char * buf = NULL;
- char * opos;
-
- /* Length must be a multiple of 2 */
- if ((len % 2) != 0)
- return NULL;
-
- opos = buf = g_malloc0 ((len / 2) + 1);
- for (i = 0; i < len; i += 2) {
- a = nm_utils_hex2byte (ipos);
- if (a < 0) {
- g_free (buf);
- return NULL;
- }
- *opos++ = a;
- ipos += 2;
- }
- return buf;
-}
-/* End from hostap */
-
-/**
- * nm_utils_iface_valid_name:
- * @name: Name of interface
- *
- * This function is a 1:1 copy of the kernel's interface validation
- * function in net/core/dev.c.
- *
- * Returns: %TRUE if interface name is valid, otherwise %FALSE is returned.
- *
- * Since: 0.9.8
- */
-gboolean
-nm_utils_iface_valid_name (const char *name)
-{
- g_return_val_if_fail (name != NULL, FALSE);
-
- if (*name == '\0')
- return FALSE;
-
- if (strlen (name) >= 16)
- return FALSE;
-
- if (!strcmp (name, ".") || !strcmp (name, ".."))
- return FALSE;
-
- while (*name) {
- if (*name == '/' || g_ascii_isspace (*name))
- return FALSE;
- name++;
- }
-
- return TRUE;
-}
-
-/**
- * nm_utils_is_uuid:
- * @str: a string that might be a UUID
- *
- * Checks if @str is a UUID
- *
- * Returns: %TRUE if @str is a UUID, %FALSE if not
- *
- * Since: 0.9.8
- */
-gboolean
-nm_utils_is_uuid (const char *str)
-{
- const char *p = str;
- int num_dashes = 0;
-
- while (*p) {
- if (*p == '-')
- num_dashes++;
- else if (!g_ascii_isxdigit (*p))
- return FALSE;
- p++;
- }
-
- if ((num_dashes == 4) && (p - str == 36))
- return TRUE;
-
- /* Backwards compat for older configurations */
- if ((num_dashes == 0) && (p - str == 40))
- return TRUE;
-
- return FALSE;
-}
-
-static char _nm_utils_inet_ntop_buffer[NM_UTILS_INET_ADDRSTRLEN];
-
-/**
- * nm_utils_inet4_ntop: (skip)
- * @inaddr: the address that should be converted to string.
- * @dst: the destination buffer, it must contain at least
- * <literal>INET_ADDRSTRLEN</literal> or %NM_UTILS_INET_ADDRSTRLEN
- * characters. If set to %NULL, it will return a pointer to an internal, static
- * buffer (shared with nm_utils_inet6_ntop()). Beware, that the internal
- * buffer will be overwritten with ever new call of nm_utils_inet4_ntop() or
- * nm_utils_inet6_ntop() that does not provied it's own @dst buffer. Also,
- * using the internal buffer is not thread safe. When in doubt, pass your own
- * @dst buffer to avoid these issues.
- *
- * Wrapper for inet_ntop.
- *
- * Returns: the input buffer @dst, or a pointer to an
- * internal, static buffer. This function cannot fail.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_utils_inet4_ntop (in_addr_t inaddr, char *dst)
-{
- return inet_ntop (AF_INET, &inaddr, dst ?: _nm_utils_inet_ntop_buffer,
- INET_ADDRSTRLEN);
-}
-
-/**
- * nm_utils_inet6_ntop: (skip)
- * @in6addr: the address that should be converted to string.
- * @dst: the destination buffer, it must contain at least
- * <literal>INET6_ADDRSTRLEN</literal> or %NM_UTILS_INET_ADDRSTRLEN
- * characters. If set to %NULL, it will return a pointer to an internal, static
- * buffer (shared with nm_utils_inet4_ntop()). Beware, that the internal
- * buffer will be overwritten with ever new call of nm_utils_inet4_ntop() or
- * nm_utils_inet6_ntop() that does not provied it's own @dst buffer. Also,
- * using the internal buffer is not thread safe. When in doubt, pass your own
- * @dst buffer to avoid these issues.
- *
- * Wrapper for inet_ntop.
- *
- * Returns: the input buffer @dst, or a pointer to an
- * internal, static buffer. %NULL is not allowed as @in6addr,
- * otherwise, this function cannot fail.
- *
- * Since: 0.9.10
- **/
-const char *
-nm_utils_inet6_ntop (const struct in6_addr *in6addr, char *dst)
-{
- g_return_val_if_fail (in6addr, NULL);
- return inet_ntop (AF_INET6, in6addr, dst ?: _nm_utils_inet_ntop_buffer,
- INET6_ADDRSTRLEN);
-}
-
-/**
- * nm_utils_check_virtual_device_compatibility:
- * @virtual_type: a virtual connection type
- * @other_type: a connection type to test against @virtual_type
- *
- * Determines if a connection of type @virtual_type can (in the
- * general case) work with connections of type @other_type.
- *
- * If @virtual_type is %NM_TYPE_SETTING_VLAN, then this checks if
- * @other_type is a valid type for the parent of a VLAN.
- *
- * If @virtual_type is a "master" type (eg, %NM_TYPE_SETTING_BRIDGE),
- * then this checks if @other_type is a valid type for a slave of that
- * master.
- *
- * Note that even if this returns %TRUE it is not guaranteed that
- * <emphasis>every</emphasis> connection of type @other_type is
- * compatible with @virtual_type; it may depend on the exact
- * configuration of the two connections, or on the capabilities of an
- * underlying device driver.
- *
- * Returns: %TRUE or %FALSE
- *
- * Since: 0.9.10
- */
-gboolean
-nm_utils_check_virtual_device_compatibility (GType virtual_type, GType other_type)
-{
- g_return_val_if_fail (_nm_setting_type_is_base_type (virtual_type), FALSE);
- g_return_val_if_fail (_nm_setting_type_is_base_type (other_type), FALSE);
-
- if (virtual_type == NM_TYPE_SETTING_BOND) {
- return ( other_type == NM_TYPE_SETTING_INFINIBAND
- || other_type == NM_TYPE_SETTING_WIRED
- || other_type == NM_TYPE_SETTING_BRIDGE
- || other_type == NM_TYPE_SETTING_BOND
- || other_type == NM_TYPE_SETTING_TEAM
- || other_type == NM_TYPE_SETTING_VLAN);
- } else if (virtual_type == NM_TYPE_SETTING_BRIDGE) {
- return ( other_type == NM_TYPE_SETTING_WIRED
- || other_type == NM_TYPE_SETTING_BOND
- || other_type == NM_TYPE_SETTING_TEAM
- || other_type == NM_TYPE_SETTING_VLAN);
- } else if (virtual_type == NM_TYPE_SETTING_TEAM) {
- return ( other_type == NM_TYPE_SETTING_WIRED
- || other_type == NM_TYPE_SETTING_BRIDGE
- || other_type == NM_TYPE_SETTING_BOND
- || other_type == NM_TYPE_SETTING_TEAM
- || other_type == NM_TYPE_SETTING_VLAN);
- } else if (virtual_type == NM_TYPE_SETTING_VLAN) {
- return ( other_type == NM_TYPE_SETTING_WIRED
- || other_type == NM_TYPE_SETTING_WIRELESS
- || other_type == NM_TYPE_SETTING_BRIDGE
- || other_type == NM_TYPE_SETTING_BOND
- || other_type == NM_TYPE_SETTING_TEAM
- || other_type == NM_TYPE_SETTING_VLAN);
- } else {
- g_warn_if_reached ();
- return FALSE;
- }
-}
-
-/*****************************************************************************/
-
-/* Unused prototypes to make the compiler happy */
-gconstpointer nm_utils_get_private (void);
-gconstpointer nm_util_get_private (void);
-
-/**
- * nm_utils_get_private:
- *
- * Entry point for NetworkManager-internal API. You should not use this
- * function for any reason.
- *
- * Returns: Who knows? It's a mystery.
- *
- * Since: 0.9.10
- */
-gconstpointer
-nm_utils_get_private (void)
-{
- /* We told you not to use it! */
- g_assert_not_reached ();
-}
-
-/**
- * nm_util_get_private:
- *
- * You should not use this function for any reason.
- *
- * Returns: Who knows? It's a mystery.
- *
- * Since: 0.9.10
- */
-gconstpointer
-nm_util_get_private (void)
-{
- /* We told you not to use it! */
- g_assert_not_reached ();
-}
diff --git a/libnm-util/nm-utils.h b/libnm-util/nm-utils.h
deleted file mode 100644
index 530fe8332f..0000000000
--- a/libnm-util/nm-utils.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2005 - 2013 Red Hat, Inc.
- */
-
-#ifndef NM_UTILS_H
-#define NM_UTILS_H
-
-#include <glib.h>
-
-#include "nm-connection.h"
-#include "nm-utils-enum-types.h"
-
-G_BEGIN_DECLS
-
-/* init, deinit nm_utils */
-gboolean nm_utils_init (GError **error);
-void nm_utils_deinit (void);
-
-/* SSID helpers */
-gboolean nm_utils_is_empty_ssid (const guint8 *ssid, int len);
-const char *nm_utils_escape_ssid (const guint8 *ssid, guint32 len);
-gboolean nm_utils_same_ssid (const GByteArray *ssid1,
- const GByteArray *ssid2,
- gboolean ignore_trailing_null);
-char * nm_utils_ssid_to_utf8 (const GByteArray *ssid);
-
-GHashTable *nm_utils_gvalue_hash_dup (GHashTable *hash);
-
-NM_DEPRECATED_IN_0_9_10
-void nm_utils_slist_free (GSList *list, GDestroyNotify elem_destroy_fn);
-
-/**
- * NMUtilsSecurityType:
- * @NMU_SEC_INVALID: unknown or invalid security, placeholder and not used
- * @NMU_SEC_NONE: unencrypted and open
- * @NMU_SEC_STATIC_WEP: static WEP keys are used for encryption
- * @NMU_SEC_LEAP: Cisco LEAP is used for authentication and for generating the
- * dynamic WEP keys automatically
- * @NMU_SEC_DYNAMIC_WEP: standard 802.1x is used for authentication and
- * generating the dynamic WEP keys automatically
- * @NMU_SEC_WPA_PSK: WPA1 is used with Pre-Shared Keys (PSK)
- * @NMU_SEC_WPA_ENTERPRISE: WPA1 is used with 802.1x authentication
- * @NMU_SEC_WPA2_PSK: WPA2/RSN is used with Pre-Shared Keys (PSK)
- * @NMU_SEC_WPA2_ENTERPRISE: WPA2 is used with 802.1x authentication
- *
- * Describes generic security mechanisms that 802.11 access points may offer.
- * Used with nm_utils_security_valid() for checking whether a given access
- * point is compatible with a network device.
- **/
-typedef enum {
- NMU_SEC_INVALID = 0,
- NMU_SEC_NONE,
- NMU_SEC_STATIC_WEP,
- NMU_SEC_LEAP,
- NMU_SEC_DYNAMIC_WEP,
- NMU_SEC_WPA_PSK,
- NMU_SEC_WPA_ENTERPRISE,
- NMU_SEC_WPA2_PSK,
- NMU_SEC_WPA2_ENTERPRISE
-} NMUtilsSecurityType;
-
-gboolean nm_utils_security_valid (NMUtilsSecurityType type,
- NMDeviceWifiCapabilities wifi_caps,
- gboolean have_ap,
- gboolean adhoc,
- NM80211ApFlags ap_flags,
- NM80211ApSecurityFlags ap_wpa,
- NM80211ApSecurityFlags ap_rsn);
-
-gboolean nm_utils_ap_mode_security_valid (NMUtilsSecurityType type,
- NMDeviceWifiCapabilities wifi_caps);
-
-gboolean nm_utils_wep_key_valid (const char *key, NMWepKeyType wep_type);
-gboolean nm_utils_wpa_psk_valid (const char *psk);
-
-GSList *nm_utils_ip4_addresses_from_gvalue (const GValue *value);
-void nm_utils_ip4_addresses_to_gvalue (GSList *list, GValue *value);
-
-GSList *nm_utils_ip4_routes_from_gvalue (const GValue *value);
-void nm_utils_ip4_routes_to_gvalue (GSList *list, GValue *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);
-
-GSList *nm_utils_ip6_addresses_from_gvalue (const GValue *value);
-void nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value);
-
-GSList *nm_utils_ip6_routes_from_gvalue (const GValue *value);
-void nm_utils_ip6_routes_to_gvalue (GSList *list, GValue *value);
-
-GSList *nm_utils_ip6_dns_from_gvalue (const GValue *value);
-void nm_utils_ip6_dns_to_gvalue (GSList *list, GValue *value);
-
-char *nm_utils_uuid_generate (void);
-char *nm_utils_uuid_generate_from_string (const char *s);
-
-GByteArray *nm_utils_rsa_key_encrypt (const GByteArray *data,
- const char *in_password,
- char **out_password,
- GError **error);
-GByteArray *nm_utils_rsa_key_encrypt_aes (const GByteArray *data,
- const char *in_password,
- char **out_password,
- GError **error);
-gboolean nm_utils_file_is_pkcs12 (const char *filename);
-
-typedef gboolean (*NMUtilsFileSearchInPathsPredicate) (const char *filename, gpointer user_data);
-
-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);
-
-guint32 nm_utils_wifi_freq_to_channel (guint32 freq);
-guint32 nm_utils_wifi_channel_to_freq (guint32 channel, const char *band);
-guint32 nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band);
-gboolean nm_utils_wifi_is_channel_valid (guint32 channel, const char *band);
-
-/**
- * NM_UTILS_HWADDR_LEN_MAX:
- *
- * The maximum length of hardware addresses handled by NetworkManager itself,
- * nm_utils_hwaddr_len(), and nm_utils_hwaddr_aton().
- */
-#define NM_UTILS_HWADDR_LEN_MAX 20 /* INFINIBAND_ALEN */
-
-int nm_utils_hwaddr_len (int type) G_GNUC_PURE;
-NM_DEPRECATED_IN_0_9_10
-int nm_utils_hwaddr_type (int len) G_GNUC_PURE;
-char *nm_utils_hwaddr_ntoa (gconstpointer addr, int type);
-GByteArray *nm_utils_hwaddr_atoba (const char *asc, int type);
-guint8 *nm_utils_hwaddr_aton (const char *asc, int type, gpointer buffer);
-
-NM_AVAILABLE_IN_0_9_10
-char *nm_utils_hwaddr_ntoa_len (gconstpointer addr, gsize length);
-NM_AVAILABLE_IN_0_9_10
-guint8 *nm_utils_hwaddr_aton_len (const char *asc, gpointer buffer, gsize length);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_utils_hwaddr_valid (const char *asc);
-
-NM_AVAILABLE_IN_0_9_10
-char *nm_utils_bin2hexstr (const char *bytes, int len, int final_len);
-NM_AVAILABLE_IN_0_9_10
-int nm_utils_hex2byte (const char *hex);
-NM_AVAILABLE_IN_0_9_10
-char *nm_utils_hexstr2bin (const char *hex, size_t len);
-
-gboolean nm_utils_iface_valid_name(const char *name);
-
-gboolean nm_utils_is_uuid (const char *str);
-
-/**
- * NM_UTILS_INET_ADDRSTRLEN:
- *
- * Defines the minimal length for a char buffer that is suitable as @dst argument
- * for both nm_utils_inet4_ntop() and nm_utils_inet6_ntop().
- **/
-#define NM_UTILS_INET_ADDRSTRLEN INET6_ADDRSTRLEN
-NM_AVAILABLE_IN_0_9_10
-const char *nm_utils_inet4_ntop (in_addr_t inaddr, char *dst);
-NM_AVAILABLE_IN_0_9_10
-const char *nm_utils_inet6_ntop (const struct in6_addr *in6addr, char *dst);
-
-NM_AVAILABLE_IN_0_9_10
-gboolean nm_utils_check_virtual_device_compatibility (GType virtual_type, GType other_type);
-
-G_END_DECLS
-
-#endif /* NM_UTILS_H */
diff --git a/libnm-util/nm-value-transforms.c b/libnm-util/nm-value-transforms.c
deleted file mode 100644
index 13f9eb43bc..0000000000
--- a/libnm-util/nm-value-transforms.c
+++ /dev/null
@@ -1,593 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2005 - 2014 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-gvaluearray-compat.h"
-#include "nm-utils.h"
-#include "nm-utils-private.h"
-#include "nm-dbus-glib-types.h"
-
-static void
-_nm_utils_convert_op_to_string (const GValue *src_value, GValue *dest_value)
-{
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_OBJECT_PATH));
-
- g_value_set_string (dest_value, (const char *) g_value_get_boxed (src_value));
-}
-
-static void
-_nm_utils_convert_strv_to_slist (const GValue *src_value, GValue *dest_value)
-{
- char **str;
- GSList *list = NULL;
- guint i = 0;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), G_TYPE_STRV));
-
- str = (char **) g_value_get_boxed (src_value);
-
- while (str && str[i])
- list = g_slist_prepend (list, g_strdup (str[i++]));
-
- g_value_take_boxed (dest_value, g_slist_reverse (list));
-}
-
-static void
-_nm_utils_convert_slist_to_strv (const GValue *src_value, GValue *dest_value)
-{
- GSList *slist;
- char **strv;
- int len, i = 0;
-
- slist = g_value_get_boxed (src_value);
- len = g_slist_length (slist);
-
- strv = g_new (char *, len + 1);
- for (i = 0; slist; slist = slist->next, i++)
- strv[i] = g_strdup (slist->data);
- strv[i] = NULL;
-
- g_value_take_boxed (dest_value, strv);
-}
-
-static void
-_nm_utils_convert_strv_to_ptrarray (const GValue *src_value, GValue *dest_value)
-{
- char **str;
- GPtrArray *array = NULL;
- guint i = 0;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), G_TYPE_STRV));
-
- str = (char **) g_value_get_boxed (src_value);
-
- array = g_ptr_array_sized_new (3);
- while (str && str[i])
- g_ptr_array_add (array, g_strdup (str[i++]));
-
- g_value_take_boxed (dest_value, array);
-}
-
-static void
-_nm_utils_convert_string_list_to_string (const GValue *src_value, GValue *dest_value)
-{
- GSList *strings;
- GString *printable;
- GSList *iter;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_LIST_OF_STRING));
-
- strings = (GSList *) g_value_get_boxed (src_value);
-
- printable = g_string_new (NULL);
- for (iter = strings; iter; iter = iter->next) {
- if (iter != strings)
- g_string_append_c (printable, ',');
- g_string_append (printable, iter->data ?: "(null)");
- }
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-static void
-_string_array_to_string (const GPtrArray *strings, GValue *dest_value)
-{
- GString *printable;
- guint i;
-
- printable = g_string_new (NULL);
- for (i = 0; strings && i < strings->len; i++) {
- if (i > 0)
- g_string_append_c (printable, ',');
- g_string_append (printable, strings->pdata[i]);
- }
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-static void
-_nm_utils_convert_string_array_to_string (const GValue *src_value, GValue *dest_value)
-{
- const GPtrArray *strings;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_STRING));
-
- strings = (const GPtrArray *) g_value_get_boxed (src_value);
- _string_array_to_string (strings, dest_value);
-}
-
-static void
-_nm_utils_convert_op_array_to_string (const GValue *src_value, GValue *dest_value)
-{
- const GPtrArray *strings;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH));
-
- strings = (const GPtrArray *) g_value_get_boxed (src_value);
- _string_array_to_string (strings, dest_value);
-}
-
-static void
-_nm_utils_convert_uint_array_to_string (const GValue *src_value, GValue *dest_value)
-{
- GArray *array;
- GString *printable;
- guint i = 0;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_UINT_ARRAY));
-
- array = (GArray *) g_value_get_boxed (src_value);
-
- printable = g_string_new (NULL);
- while (array && (i < array->len)) {
- guint32 addr;
-
- if (i > 0)
- g_string_append (printable, ", ");
-
- addr = g_array_index (array, guint32, i++);
- g_string_append (printable, nm_utils_inet4_ntop (addr, NULL));
- }
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-static void
-_nm_utils_convert_ip4_addr_route_struct_array_to_string (const GValue *src_value, GValue *dest_value)
-{
- GPtrArray *ptr_array;
- GString *printable;
- guint i = 0;
- char buf[INET_ADDRSTRLEN];
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT));
-
- ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
-
- printable = g_string_new (NULL);
- while (ptr_array && (i < ptr_array->len)) {
- GArray *array;
- gboolean is_addr; /* array contains address x route */
-
- if (i > 0)
- g_string_append (printable, "; ");
-
- g_string_append (printable, "{ ");
- array = (GArray *) g_ptr_array_index (ptr_array, i++);
- if (array->len < 2) {
- g_string_append (printable, "invalid");
- continue;
- }
- is_addr = (array->len < 4);
-
- nm_utils_inet4_ntop (g_array_index (array, guint32, 0), buf);
- if (is_addr)
- g_string_append_printf (printable, "ip = %s", buf);
- else
- g_string_append_printf (printable, "dst = %s", buf);
-
- g_string_append_printf (printable, "/%u",
- g_array_index (array, guint32, 1));
-
- if (array->len > 2) {
- nm_utils_inet4_ntop (g_array_index (array, guint32, 2), buf);
- if (is_addr)
- g_string_append_printf (printable, ", gw = %s", buf);
- else
- g_string_append_printf (printable, ", nh = %s", buf);
- }
-
- if (array->len > 3) {
- g_string_append_printf (printable, ", mt = %u",
- g_array_index (array, guint32, 3));
- }
-
- g_string_append (printable, " }");
- }
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-static void
-convert_one_gvalue_hash_entry (gpointer key, gpointer value, gpointer user_data)
-{
- GString *printable = (GString *) user_data;
- char *value_as_string;
-
- value_as_string = g_strdup_value_contents ((GValue *) value);
- g_string_append_printf (printable, " { '%s': %s },", (const char *) key, value_as_string);
- g_free (value_as_string);
-}
-
-static void
-_nm_utils_convert_gvalue_hash_to_string (const GValue *src_value, GValue *dest_value)
-{
- GHashTable *hash;
- GString *printable;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_MAP_OF_VARIANT));
-
- hash = (GHashTable *) g_value_get_boxed (src_value);
-
- printable = g_string_new ("[");
- g_hash_table_foreach (hash, convert_one_gvalue_hash_entry, printable);
- g_string_append (printable, " ]");
-
- g_value_take_string (dest_value, printable->str);
- g_string_free (printable, FALSE);
-}
-
-static void
-convert_one_string_hash_entry (gpointer key, gpointer value, gpointer user_data)
-{
- GString *printable = (GString *) user_data;
-
- if (printable->len)
- g_string_append_c (printable, ',');
- g_string_append_printf (printable, "%s=%s", (const char *) key, (const char *) value);
-}
-
-static void
-_nm_utils_convert_string_hash_to_string (const GValue *src_value, GValue *dest_value)
-{
- GHashTable *hash;
- GString *printable;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_MAP_OF_STRING));
-
- hash = (GHashTable *) g_value_get_boxed (src_value);
-
- printable = g_string_new (NULL);
- if (hash)
- g_hash_table_foreach (hash, convert_one_string_hash_entry, printable);
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-static void
-_nm_utils_convert_byte_array_to_string (const GValue *src_value, GValue *dest_value)
-{
- GArray *array;
- GString *printable;
- guint i = 0;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_UCHAR_ARRAY));
-
- array = (GArray *) g_value_get_boxed (src_value);
-
- printable = g_string_new ("[");
- if (array) {
- while (i < MIN (array->len, 35)) {
- if (i > 0)
- g_string_append_c (printable, ' ');
- g_string_append_printf (printable, "0x%02X",
- g_array_index (array, unsigned char, i++));
- }
- if (i < array->len)
- g_string_append (printable, " ... ");
- }
- g_string_append_c (printable, ']');
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-static void
-_nm_utils_convert_ip6_dns_array_to_string (const GValue *src_value, GValue *dest_value)
-{
- GPtrArray *ptr_array;
- GString *printable;
- guint i = 0;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR));
-
- ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
-
- printable = g_string_new (NULL);
- while (ptr_array && (i < ptr_array->len)) {
- GByteArray *bytearray;
- struct in6_addr *addr;
-
- if (i > 0)
- g_string_append (printable, ", ");
-
- bytearray = (GByteArray *) g_ptr_array_index (ptr_array, i++);
- if (bytearray->len != 16) {
- g_string_append (printable, "invalid");
- continue;
- }
- addr = (struct in6_addr *) bytearray->data;
- g_string_append (printable, nm_utils_inet6_ntop (addr, NULL));
- }
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-static void
-_nm_utils_convert_ip6_addr_struct_array_to_string (const GValue *src_value, GValue *dest_value)
-{
- GPtrArray *ptr_array;
- GString *printable;
- guint i = 0;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS));
-
- ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
-
- printable = g_string_new (NULL);
- while (ptr_array && (i < ptr_array->len)) {
- GValueArray *elements;
- GValue *tmp;
- GByteArray *ba_addr;
- struct in6_addr *addr;
- guint32 prefix;
-
- if (i > 0)
- g_string_append (printable, "; ");
-
- g_string_append (printable, "{ ");
- elements = (GValueArray *) g_ptr_array_index (ptr_array, i++);
- if (!_nm_utils_gvalue_array_validate (elements, 3,
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_TYPE_UINT,
- DBUS_TYPE_G_UCHAR_ARRAY)) {
- g_string_append (printable, "invalid }");
- continue;
- }
-
- /* IPv6 address */
- tmp = g_value_array_get_nth (elements, 0);
- ba_addr = g_value_get_boxed (tmp);
- if (ba_addr->len != 16) {
- g_string_append (printable, "invalid }");
- continue;
- }
- addr = (struct in6_addr *) ba_addr->data;
- g_string_append_printf (printable, "ip = %s", nm_utils_inet6_ntop (addr, NULL));
-
- /* Prefix */
- tmp = g_value_array_get_nth (elements, 1);
- prefix = g_value_get_uint (tmp);
- if (prefix > 128) {
- g_string_append (printable, "/invalid }");
- continue;
- }
- g_string_append_printf (printable, "/%u", prefix);
- g_string_append (printable, ", ");
-
- /* IPv6 Gateway */
- tmp = g_value_array_get_nth (elements, 2);
- ba_addr = g_value_get_boxed (tmp);
- if (ba_addr->len != 16) {
- g_string_append (printable, "invalid }");
- continue;
- }
- addr = (struct in6_addr *) ba_addr->data;
- g_string_append_printf (printable, "gw = %s", nm_utils_inet6_ntop (addr, NULL));
- g_string_append (printable, " }");
- }
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-static void
-_nm_utils_convert_ip6_route_struct_array_to_string (const GValue *src_value, GValue *dest_value)
-{
- GPtrArray *ptr_array;
- GString *printable;
- guint i = 0;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE));
-
- ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
-
- printable = g_string_new (NULL);
- while (ptr_array && (i < ptr_array->len)) {
- GValueArray *elements;
- GValue *tmp;
- GByteArray *ba_addr;
- struct in6_addr *addr;
- guint32 prefix, metric;
-
- if (i > 0)
- g_string_append (printable, "; ");
-
- g_string_append (printable, "{ ");
- elements = (GValueArray *) g_ptr_array_index (ptr_array, i++);
- if (!_nm_utils_gvalue_array_validate (elements, 4,
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_TYPE_UINT,
- DBUS_TYPE_G_UCHAR_ARRAY,
- G_TYPE_UINT)) {
- g_string_append (printable, "invalid");
- continue;
- }
-
- /* Destination address */
- tmp = g_value_array_get_nth (elements, 0);
- ba_addr = g_value_get_boxed (tmp);
- if (ba_addr->len != 16) {
- g_string_append (printable, "invalid");
- continue;
- }
- addr = (struct in6_addr *) ba_addr->data;
- g_string_append_printf (printable, "dst = %s", nm_utils_inet6_ntop (addr, NULL));
-
- /* Prefix */
- tmp = g_value_array_get_nth (elements, 1);
- prefix = g_value_get_uint (tmp);
- if (prefix > 128) {
- g_string_append (printable, "/invalid");
- continue;
- }
- g_string_append_printf (printable, "/%u", prefix);
- g_string_append (printable, ", ");
-
- /* Next hop addresses */
- tmp = g_value_array_get_nth (elements, 2);
- ba_addr = g_value_get_boxed (tmp);
- if (ba_addr->len != 16) {
- g_string_append (printable, "invalid");
- continue;
- }
- addr = (struct in6_addr *) ba_addr->data;
- g_string_append_printf (printable, "nh = %s", nm_utils_inet6_ntop (addr, NULL));
- g_string_append (printable, ", ");
-
- /* Metric */
- tmp = g_value_array_get_nth (elements, 3);
- metric = g_value_get_uint (tmp);
- g_string_append_printf (printable, "mt = %u", metric);
-
- g_string_append (printable, " }");
- }
-
- g_value_take_string (dest_value, g_string_free (printable, FALSE));
-}
-
-#define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
-#define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS))
-
-static void
-_nm_utils_convert_old_ip6_addr_array (const GValue *src_value, GValue *dst_value)
-{
- GPtrArray *src_outer_array;
- GPtrArray *dst_outer_array;
- guint i;
-
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS));
-
- src_outer_array = (GPtrArray *) g_value_get_boxed (src_value);
- dst_outer_array = g_ptr_array_new ();
-
- for (i = 0; src_outer_array && (i < src_outer_array->len); i++) {
- GValueArray *src_addr_array;
- GValueArray *dst_addr_array;
- GValue element = G_VALUE_INIT;
- GValue *src_addr, *src_prefix;
- GByteArray *ba;
-
- src_addr_array = (GValueArray *) g_ptr_array_index (src_outer_array, i);
- if (!_nm_utils_gvalue_array_validate (src_addr_array, 2, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT)) {
- g_warning ("%s: invalid old IPv6 address type", __func__);
- return;
- }
-
- dst_addr_array = g_value_array_new (3);
-
- src_addr = g_value_array_get_nth (src_addr_array, 0);
- g_value_array_append (dst_addr_array, src_addr);
- src_prefix = g_value_array_get_nth (src_addr_array, 1);
- g_value_array_append (dst_addr_array, src_prefix);
-
- /* Blank Gateway */
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- ba = g_byte_array_new ();
- g_byte_array_append (ba, (guint8 *) "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16);
- g_value_take_boxed (&element, ba);
- g_value_array_append (dst_addr_array, &element);
- g_value_unset (&element);
-
- g_ptr_array_add (dst_outer_array, dst_addr_array);
- }
-
- g_value_take_boxed (dst_value, dst_outer_array);
-}
-
-void
-_nm_value_transforms_register (void)
-{
- static gboolean registered = FALSE;
-
- if (G_UNLIKELY (!registered)) {
- g_value_register_transform_func (DBUS_TYPE_G_OBJECT_PATH,
- G_TYPE_STRING,
- _nm_utils_convert_op_to_string);
- g_value_register_transform_func (G_TYPE_STRV,
- DBUS_TYPE_G_LIST_OF_STRING,
- _nm_utils_convert_strv_to_slist);
- g_value_register_transform_func (DBUS_TYPE_G_LIST_OF_STRING,
- G_TYPE_STRV,
- _nm_utils_convert_slist_to_strv);
- g_value_register_transform_func (G_TYPE_STRV,
- DBUS_TYPE_G_ARRAY_OF_STRING,
- _nm_utils_convert_strv_to_ptrarray);
- g_value_register_transform_func (DBUS_TYPE_G_LIST_OF_STRING,
- G_TYPE_STRING,
- _nm_utils_convert_string_list_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_STRING,
- G_TYPE_STRING,
- _nm_utils_convert_string_array_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
- G_TYPE_STRING,
- _nm_utils_convert_op_array_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_UINT_ARRAY,
- G_TYPE_STRING,
- _nm_utils_convert_uint_array_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
- G_TYPE_STRING,
- _nm_utils_convert_ip4_addr_route_struct_array_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_STRING,
- _nm_utils_convert_gvalue_hash_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_MAP_OF_STRING,
- G_TYPE_STRING,
- _nm_utils_convert_string_hash_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_UCHAR_ARRAY,
- G_TYPE_STRING,
- _nm_utils_convert_byte_array_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR,
- G_TYPE_STRING,
- _nm_utils_convert_ip6_dns_array_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
- G_TYPE_STRING,
- _nm_utils_convert_ip6_addr_struct_array_to_string);
- g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
- G_TYPE_STRING,
- _nm_utils_convert_ip6_route_struct_array_to_string);
- g_value_register_transform_func (OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
- DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
- _nm_utils_convert_old_ip6_addr_array);
- registered = TRUE;
- }
-}
diff --git a/libnm-util/nm-version.h b/libnm-util/nm-version.h
deleted file mode 100644
index f56c3944dd..0000000000
--- a/libnm-util/nm-version.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2011 Red Hat, Inc.
- */
-
-#ifndef NM_VERSION_H
-#define NM_VERSION_H
-
-#include <glib.h>
-
-#include "nm-version-macros.h"
-
-/* Deprecation / Availability macros */
-
-#if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0)
-# undef NM_VERSION_MIN_REQUIRED
-# define NM_VERSION_MIN_REQUIRED (NM_API_VERSION)
-#endif
-
-#if !defined (NM_VERSION_MAX_ALLOWED) || (NM_VERSION_MAX_ALLOWED == 0)
-# undef NM_VERSION_MAX_ALLOWED
-# define NM_VERSION_MAX_ALLOWED (NM_API_VERSION)
-#endif
-
-/* sanity checks */
-#if NM_VERSION_MIN_REQUIRED > NM_API_VERSION
-#error "NM_VERSION_MIN_REQUIRED must be <= NM_API_VERSION"
-#endif
-#if NM_VERSION_MAX_ALLOWED < NM_VERSION_MIN_REQUIRED
-#error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED"
-#endif
-#if NM_VERSION_MIN_REQUIRED < NM_VERSION_0_9_8
-#error "NM_VERSION_MIN_REQUIRED must be >= NM_VERSION_0_9_8"
-#endif
-
-#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_0_9_10
-# define NM_DEPRECATED_IN_0_9_10 G_DEPRECATED
-# define NM_DEPRECATED_IN_0_9_10_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NM_DEPRECATED_IN_0_9_10
-# define NM_DEPRECATED_IN_0_9_10_FOR(f)
-#endif
-
-#if NM_VERSION_MAX_ALLOWED < NM_VERSION_0_9_10
-# define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9,10)
-#else
-# define NM_AVAILABLE_IN_0_9_10
-#endif
-
-#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_0
-# define NM_DEPRECATED_IN_1_0 G_DEPRECATED
-# define NM_DEPRECATED_IN_1_0_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NM_DEPRECATED_IN_1_0
-# define NM_DEPRECATED_IN_1_0_FOR(f)
-#endif
-
-#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0
-# define NM_AVAILABLE_IN_1_0 G_UNAVAILABLE(1,0)
-#else
-# define NM_AVAILABLE_IN_1_0
-#endif
-
-#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_2
-# define NM_DEPRECATED_IN_1_2 G_DEPRECATED
-# define NM_DEPRECATED_IN_1_2_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NM_DEPRECATED_IN_1_2
-# define NM_DEPRECATED_IN_1_2_FOR(f)
-#endif
-
-#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_2
-# define NM_AVAILABLE_IN_1_2 G_UNAVAILABLE(1,2)
-#else
-# define NM_AVAILABLE_IN_1_2
-#endif
-
-#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_4
-# define NM_DEPRECATED_IN_1_4 G_DEPRECATED
-# define NM_DEPRECATED_IN_1_4_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NM_DEPRECATED_IN_1_4
-# define NM_DEPRECATED_IN_1_4_FOR(f)
-#endif
-
-#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_4
-# define NM_AVAILABLE_IN_1_4 G_UNAVAILABLE(1,4)
-#else
-# define NM_AVAILABLE_IN_1_4
-#endif
-
-#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_6
-# define NM_DEPRECATED_IN_1_6 G_DEPRECATED
-# define NM_DEPRECATED_IN_1_6_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NM_DEPRECATED_IN_1_6
-# define NM_DEPRECATED_IN_1_6_FOR(f)
-#endif
-
-#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_6
-# define NM_AVAILABLE_IN_1_6 G_UNAVAILABLE(1,6)
-#else
-# define NM_AVAILABLE_IN_1_6
-#endif
-
-#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_8
-# define NM_DEPRECATED_IN_1_8 G_DEPRECATED
-# define NM_DEPRECATED_IN_1_8_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NM_DEPRECATED_IN_1_8
-# define NM_DEPRECATED_IN_1_8_FOR(f)
-#endif
-
-#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_8
-# define NM_AVAILABLE_IN_1_8 G_UNAVAILABLE(1,8)
-#else
-# define NM_AVAILABLE_IN_1_8
-#endif
-
-#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_10
-# define NM_DEPRECATED_IN_1_10 G_DEPRECATED
-# define NM_DEPRECATED_IN_1_10_FOR(f) G_DEPRECATED_FOR(f)
-#else
-# define NM_DEPRECATED_IN_1_10
-# define NM_DEPRECATED_IN_1_10_FOR(f)
-#endif
-
-#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_10
-# define NM_AVAILABLE_IN_1_10 G_UNAVAILABLE(1,10)
-#else
-# define NM_AVAILABLE_IN_1_10
-#endif
-
-#endif /* NM_VERSION_H */
diff --git a/libnm-util/tests/meson.build b/libnm-util/tests/meson.build
deleted file mode 100644
index 09642f319f..0000000000
--- a/libnm-util/tests/meson.build
+++ /dev/null
@@ -1,45 +0,0 @@
-deps = [
- dbus_dep,
- dbus_glib_dep,
- libnm_util_dep,
- shared_nm_glib_aux_dep,
-]
-
-cflags = common_cflags + [
- '-DNETWORKMANAGER_COMPILATION_TEST',
-]
-
-test = 'test-libnm-linking'
-
-test_libnm_linking = executable(
- test,
- test + '.c',
- dependencies: deps + [libnm_dep],
- c_args: cflags,
-)
-
-test_units = [
- ['test-crypto', [libtest_crypto], []],
- ['test-general', [], [test_libnm_linking]],
- ['test-secrets', [], []],
- ['test-setting-8021x', [], []],
- ['test-setting-dcb', [], []],
- ['test-settings-defaults', [], []],
-]
-
-foreach test_unit: test_units
- exe = executable(
- 'libnm-util-' + test_unit[0],
- test_unit[0] + '.c',
- dependencies: deps,
- c_args: cflags,
- link_with: test_unit[1],
- link_depends: test_unit[2],
- )
-
- test(
- 'libnm-util/' + test_unit[0],
- test_script,
- args: test_args + [exe.full_path()],
- )
-endforeach
diff --git a/libnm-util/tests/test-crypto.c b/libnm-util/tests/test-crypto.c
deleted file mode 100644
index af6028a52e..0000000000
--- a/libnm-util/tests/test-crypto.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * Dan Williams <dcbw@redhat.com>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2007 - 2011 Red Hat, Inc.
- */
-
-#include "nm-default.h"
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "crypto.h"
-#include "nm-utils.h"
-
-#include "nm-utils/nm-test-utils.h"
-
-#define TEST_CERT_DIR NM_BUILD_SRCDIR"/libnm-core/tests/certs"
-
-#if 0
-static const char *pem_rsa_key_begin = "-----BEGIN RSA PRIVATE KEY-----";
-static const char *pem_rsa_key_end = "-----END RSA PRIVATE KEY-----";
-
-static const char *pem_dsa_key_begin = "-----BEGIN DSA PRIVATE KEY-----";
-static const char *pem_dsa_key_end = "-----END DSA PRIVATE KEY-----";
-
-static void
-dump_key_to_pem (const char *key, gsize key_len, int key_type)
-{
- char *b64 = NULL;
- GString *str = NULL;
- const char *start_tag;
- const char *end_tag;
- char *p;
-
- switch (key_type) {
- case NM_CRYPTO_KEY_TYPE_RSA:
- start_tag = pem_rsa_key_begin;
- end_tag = pem_rsa_key_end;
- break;
- case NM_CRYPTO_KEY_TYPE_DSA:
- start_tag = pem_dsa_key_begin;
- end_tag = pem_dsa_key_end;
- break;
- default:
- g_warning ("Unknown key type %d", key_type);
- return;
- }
-
- b64 = g_base64_encode ((const unsigned char *) key, key_len);
- if (!b64) {
- g_warning ("Couldn't base64 encode the key.");
- goto out;
- }
-
- str = g_string_new (NULL);
-
- g_string_append (str, start_tag);
- g_string_append_c (str, '\n');
-
- for (p = b64; p < (b64 + strlen (b64)); p += 64) {
- g_string_append_len (str, p, strnlen (p, 64));
- g_string_append_c (str, '\n');
- }
-
- g_string_append (str, end_tag);
- g_string_append_c (str, '\n');
-
- g_message ("Decrypted private key:\n\n%s", str->str);
-
-out:
- g_free (b64);
- if (str)
- g_string_free (str, TRUE);
-}
-#endif
-
-static void
-test_cert (gconstpointer test_data)
-{
- gs_free char *path = NULL;
- GByteArray *array;
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GError *error = NULL;
-
- path = g_build_filename (TEST_CERT_DIR, (const char *) test_data, NULL);
-
- array = crypto_load_and_verify_certificate (path, &format, &error);
- nmtst_assert_success (array != NULL, error);
- g_assert (format == NM_CRYPTO_FILE_FORMAT_X509);
-
- g_byte_array_free (array, TRUE);
-}
-
-static GByteArray *
-file_to_byte_array (const char *filename)
-{
- char *contents;
- GByteArray *array = NULL;
- gsize length = 0;
-
- if (g_file_get_contents (filename, &contents, &length, NULL)) {
- array = g_byte_array_sized_new (length);
- g_byte_array_append (array, (guint8 *) contents, length);
- g_assert (array->len == length);
- g_free (contents);
- }
- return array;
-}
-
-static void
-test_load_private_key (const char *path,
- const char *password,
- const char *decrypted_path,
- gboolean expect_fail,
- const char *desc)
-{
- NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN;
- GByteArray *array, *decrypted;
- GError *error = NULL;
-
- array = crypto_decrypt_private_key (path, password, &key_type, &error);
- if (expect_fail) {
- g_assert (!array);
- g_assert ((password && error) || (!password && !error));
- g_assert (key_type != NM_CRYPTO_KEY_TYPE_UNKNOWN);
- g_clear_error (&error);
- return;
- }
-
- g_assert (array);
- g_assert (key_type == NM_CRYPTO_KEY_TYPE_RSA);
-
- if (decrypted_path) {
- /* Compare the crypto decrypted key against a known-good decryption */
- decrypted = file_to_byte_array (decrypted_path);
- g_assert (decrypted);
- g_assert_cmpint (decrypted->len, >, 0);
- g_assert_cmpmem (decrypted->data, decrypted->len, array->data, array->len);
-
- g_byte_array_free (decrypted, TRUE);
- }
-
- g_clear_error (&error);
- g_byte_array_free (array, TRUE);
-}
-
-static void
-test_load_pkcs12 (const char *path,
- const char *password,
- gboolean expect_fail,
- const char *desc)
-{
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GError *error = NULL;
-
- format = crypto_verify_private_key (path, password, &error);
- if (expect_fail)
- g_assert (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN);
- else
- g_assert (format == NM_CRYPTO_FILE_FORMAT_PKCS12);
- g_clear_error (&error);
-}
-
-static void
-test_load_pkcs12_no_password (const char *path, const char *desc)
-{
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GError *error = NULL;
-
- /* We should still get a valid returned crypto file format */
- format = crypto_verify_private_key (path, NULL, &error);
- g_assert (format == NM_CRYPTO_FILE_FORMAT_PKCS12);
-}
-
-static void
-test_is_pkcs12 (const char *path, gboolean expect_fail, const char *desc)
-{
- gboolean is_pkcs12;
-
- is_pkcs12 = crypto_is_pkcs12_file (path, NULL);
- if (expect_fail)
- g_assert (!is_pkcs12);
- else
- g_assert (is_pkcs12);
-}
-
-static void
-test_load_pkcs8 (const char *path,
- const char *password,
- gboolean expect_fail,
- const char *desc)
-{
- NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
- GError *error = NULL;
-
- format = crypto_verify_private_key (path, password, &error);
- if (expect_fail)
- g_assert (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN);
- else
- g_assert (format == NM_CRYPTO_FILE_FORMAT_RAW_KEY);
-}
-
-static gboolean
-is_cipher_aes (const char *path)
-{
- char *contents;
- gsize length = 0;
- const char *cipher;
- gboolean is_aes = FALSE;
-
- if (!g_file_get_contents (path, &contents, &length, NULL))
- return FALSE;
-
- cipher = strstr (contents, "DEK-Info: ");
- if (cipher) {
- cipher += strlen ("DEK-Info: ");
- if (g_str_has_prefix (cipher, "AES-128-CBC"))
- is_aes = TRUE;
- }
-
- g_free (contents);
- return is_aes;
-}
-
-static void
-test_encrypt_private_key (const char *path,
- const char *password,
- const char *desc)
-{
- NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN;
- GByteArray *array, *encrypted, *re_decrypted;
- GError *error = NULL;
-
- array = crypto_decrypt_private_key (path, password, &key_type, &error);
- g_assert (array);
- g_assert_no_error (error);
- g_assert (key_type == NM_CRYPTO_KEY_TYPE_RSA);
-
- /* Now re-encrypt the private key */
- if (is_cipher_aes (path))
- encrypted = nm_utils_rsa_key_encrypt_aes (array, password, NULL, &error);
- else
- encrypted = nm_utils_rsa_key_encrypt (array, password, NULL, &error);
- g_assert (encrypted);
- g_assert_no_error (error);
-
- /* Then re-decrypt the private key */
- key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN;
- re_decrypted = crypto_decrypt_private_key_data (encrypted, password, &key_type, &error);
- g_assert (re_decrypted);
- g_assert_no_error (error);
- g_assert (key_type == NM_CRYPTO_KEY_TYPE_RSA);
-
- /* Compare the original decrypted key with the re-decrypted key */
- g_assert_cmpmem (array->data, array->len, re_decrypted->data, re_decrypted->len);
-
- g_byte_array_free (re_decrypted, TRUE);
- g_byte_array_free (encrypted, TRUE);
- g_byte_array_free (array, TRUE);
-}
-
-static void
-test_key (gconstpointer test_data)
-{
- char **parts, *path, *password, *decrypted_path;
- int len;
-
- parts = g_strsplit ((const char *) test_data, ", ", -1);
- len = g_strv_length (parts);
- g_assert (len == 2 || len == 3);
-
- path = g_build_filename (TEST_CERT_DIR, parts[0], NULL);
- password = parts[1];
- decrypted_path = parts[2] ? g_build_filename (TEST_CERT_DIR, parts[2], NULL) : NULL;
-
- test_is_pkcs12 (path, TRUE, "not-pkcs12");
- test_load_private_key (path, password, decrypted_path, FALSE, "private-key");
- test_load_private_key (path, "blahblahblah", NULL, TRUE, "private-key-bad-password");
- test_load_private_key (path, NULL, NULL, TRUE, "private-key-no-password");
- test_encrypt_private_key (path, password, "private-key-rencrypt");
-
- g_free (path);
- g_free (decrypted_path);
- g_strfreev (parts);
-}
-
-static void
-test_pkcs12 (gconstpointer test_data)
-{
- char **parts, *path, *password;
-
- parts = g_strsplit ((const char *) test_data, ", ", -1);
- g_assert_cmpint (g_strv_length (parts), ==, 2);
-
- path = g_build_filename (TEST_CERT_DIR, parts[0], NULL);
- password = parts[1];
-
- test_is_pkcs12 (path, FALSE, "is-pkcs12");
- test_load_pkcs12 (path, password, FALSE, "pkcs12-private-key");
- test_load_pkcs12 (path, "blahblahblah", TRUE, "pkcs12-private-key-bad-password");
- test_load_pkcs12_no_password (path, "pkcs12-private-key-no-password");
-
- g_free (path);
- g_strfreev (parts);
-}
-
-static void
-test_pkcs8 (gconstpointer test_data)
-{
- char **parts, *path, *password;
-
- parts = g_strsplit ((const char *) test_data, ", ", -1);
- g_assert_cmpint (g_strv_length (parts), ==, 2);
-
- path = g_build_filename (TEST_CERT_DIR, parts[0], NULL);
- password = parts[1];
-
- test_is_pkcs12 (path, TRUE, "not-pkcs12");
- test_load_pkcs8 (path, password, FALSE, "pkcs8-private-key");
-
- g_free (path);
- g_strfreev (parts);
-}
-
-NMTST_DEFINE ();
-
-int
-main (int argc, char **argv)
-{
- GError *error = NULL;
- gboolean success;
-
- nmtst_init (&argc, &argv, TRUE);
-
- success = crypto_init (&error);
- g_assert_no_error (error);
- g_assert (success);
-
- g_test_add_data_func ("/libnm/crypto/cert/pem",
- "test_ca_cert.pem",
- test_cert);
- g_test_add_data_func ("/libnm/crypto/cert/pem-2",
- "test2_ca_cert.pem",
- test_cert);
- g_test_add_data_func ("/libnm/crypto/cert/der",
- "test_ca_cert.der",
- test_cert);
- g_test_add_data_func ("/libnm/crypto/cert/pem-no-ending-newline",
- "ca-no-ending-newline.pem",
- test_cert);
- g_test_add_data_func ("/libnm/crypto/cert/pem-combined",
- "test_key_and_cert.pem",
- test_cert);
- g_test_add_data_func ("/libnm/crypto/cert/pem-combined-2",
- "test2_key_and_cert.pem",
- test_cert);
-
- g_test_add_data_func ("/libnm/crypto/key/padding-6",
- "test_key_and_cert.pem, test, test-key-only-decrypted.der",
- test_key);
- g_test_add_data_func ("/libnm/crypto/key/key-only",
- "test-key-only.pem, test, test-key-only-decrypted.der",
- test_key);
- g_test_add_data_func ("/libnm/crypto/key/padding-8",
- "test2_key_and_cert.pem, 12345testing",
- test_key);
- g_test_add_data_func ("/libnm/crypto/key/aes-128",
- "test-aes-128-key.pem, test-aes-password",
- test_key);
-
- g_test_add_data_func ("/libnm/crypto/PKCS#12/1",
- "test-cert.p12, test",
- test_pkcs12);
- g_test_add_data_func ("/libnm/crypto/PKCS#12/2",
- "test2-cert.p12, 12345testing",
- test_pkcs12);
-
- g_test_add_data_func ("/libnm/crypto/PKCS#8",
- "pkcs8-enc-key.pem, 1234567890",
- test_pkcs8);
-
- return g_test_run ();
-}
-
diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c
deleted file mode 100644
index 9e097f19aa..0000000000
--- a/libnm-util/tests/test-general.c
+++ /dev/null
@@ -1,2560 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2011 Red Hat, Inc.
- *
- */
-
-#include "nm-default.h"
-
-#include <dbus/dbus-glib.h>
-#include <string.h>
-#include <netinet/ether.h>
-#include <linux/if_infiniband.h>
-#include <sys/wait.h>
-#include <sys/resource.h>
-
-#include "nm-utils.h"
-#include "nm-gvaluearray-compat.h"
-
-#include "nm-setting-private.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-vpn.h"
-#include "nm-setting-gsm.h"
-#include "nm-setting-cdma.h"
-#include "nm-setting-wired.h"
-#include "nm-setting-wireless-security.h"
-#include "nm-setting-ip6-config.h"
-#include "nm-setting-ip4-config.h"
-#include "nm-setting-pppoe.h"
-#include "nm-setting-serial.h"
-#include "nm-setting-vlan.h"
-#include "nm-setting-bond.h"
-#include "nm-utils.h"
-#include "nm-dbus-glib-types.h"
-
-#include "nm-utils/nm-test-utils.h"
-
-static void
-vpn_check_func (const char *key, const char *value, gpointer user_data)
-{
- if (!strcmp (key, "foobar1")) {
- g_assert_cmpstr (value, ==, "blahblah1");
- return;
- }
-
- if (!strcmp (key, "foobar2")) {
- g_assert_cmpstr (value, ==, "blahblah2");
- return;
- }
-
- if (!strcmp (key, "foobar3")) {
- g_assert_cmpstr (value, ==, "blahblah3");
- return;
- }
-
- if (!strcmp (key, "foobar4")) {
- g_assert_cmpstr (value, ==, "blahblah4");
- return;
- }
-
- g_assert_not_reached ();
-}
-
-static void
-vpn_check_empty_func (const char *key, const char *value, gpointer user_data)
-{
- g_assert_not_reached ();
-}
-
-static void
-test_setting_vpn_items (void)
-{
- NMSettingVPN *s_vpn;
-
- s_vpn = (NMSettingVPN *) nm_setting_vpn_new ();
- g_assert (s_vpn);
-
- nm_setting_vpn_add_data_item (s_vpn, "foobar1", "blahblah1");
- nm_setting_vpn_add_data_item (s_vpn, "foobar2", "blahblah2");
- nm_setting_vpn_add_data_item (s_vpn, "foobar3", "blahblah3");
- nm_setting_vpn_add_data_item (s_vpn, "foobar4", "blahblah4");
-
- /* Ensure that added values are all present */
- nm_setting_vpn_foreach_data_item (s_vpn, vpn_check_func, NULL);
- nm_setting_vpn_remove_data_item (s_vpn, "foobar1");
- nm_setting_vpn_remove_data_item (s_vpn, "foobar2");
- nm_setting_vpn_remove_data_item (s_vpn, "foobar3");
- nm_setting_vpn_remove_data_item (s_vpn, "foobar4");
-
- nm_setting_vpn_add_secret (s_vpn, "foobar1", "blahblah1");
- nm_setting_vpn_add_secret (s_vpn, "foobar2", "blahblah2");
- nm_setting_vpn_add_secret (s_vpn, "foobar3", "blahblah3");
- nm_setting_vpn_add_secret (s_vpn, "foobar4", "blahblah4");
-
- /* Ensure that added values are all present */
- nm_setting_vpn_foreach_secret (s_vpn, vpn_check_func, NULL);
- nm_setting_vpn_remove_secret (s_vpn, "foobar1");
- nm_setting_vpn_remove_secret (s_vpn, "foobar2");
- nm_setting_vpn_remove_secret (s_vpn, "foobar3");
- nm_setting_vpn_remove_secret (s_vpn, "foobar4");
-
- /* Try to add some blank values and make sure they are rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (key != NULL));
- nm_setting_vpn_add_data_item (s_vpn, NULL, NULL);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strlen (key) > 0));
- nm_setting_vpn_add_data_item (s_vpn, "", "");
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (item != NULL));
- nm_setting_vpn_add_data_item (s_vpn, "foobar1", NULL);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strlen (item) > 0));
- nm_setting_vpn_add_data_item (s_vpn, "foobar1", "");
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (key != NULL));
- nm_setting_vpn_add_data_item (s_vpn, NULL, "blahblah1");
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strlen (key) > 0));
- nm_setting_vpn_add_data_item (s_vpn, "", "blahblah1");
- g_test_assert_expected_messages ();
-
- nm_setting_vpn_foreach_data_item (s_vpn, vpn_check_empty_func, NULL);
-
- /* Try to add some blank secrets and make sure they are rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (key != NULL));
- nm_setting_vpn_add_secret (s_vpn, NULL, NULL);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strlen (key) > 0));
- nm_setting_vpn_add_secret (s_vpn, "", "");
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (secret != NULL));
- nm_setting_vpn_add_secret (s_vpn, "foobar1", NULL);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strlen (secret) > 0));
- nm_setting_vpn_add_secret (s_vpn, "foobar1", "");
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (key != NULL));
- nm_setting_vpn_add_secret (s_vpn, NULL, "blahblah1");
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strlen (key) > 0));
- nm_setting_vpn_add_secret (s_vpn, "", "blahblah1");
- g_test_assert_expected_messages ();
-
- nm_setting_vpn_foreach_secret (s_vpn, vpn_check_empty_func, NULL);
-
- g_object_unref (s_vpn);
-}
-
-static void
-test_setting_vpn_update_secrets (void)
-{
- NMConnection *connection;
- NMSettingVPN *s_vpn;
- GHashTable *settings, *vpn, *secrets;
- GValue val = G_VALUE_INIT;
- gboolean success;
- GError *error = NULL;
- const char *tmp;
- const char *key1 = "foobar";
- const char *key2 = "blahblah";
- const char *val1 = "value1";
- const char *val2 = "value2";
-
- connection = nm_connection_new ();
- g_assert (connection);
-
- s_vpn = (NMSettingVPN *) nm_setting_vpn_new ();
- g_assert (s_vpn);
- nm_connection_add_setting (connection, NM_SETTING (s_vpn));
-
- settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_hash_table_destroy);
- vpn = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_value_unset);
- g_hash_table_insert (settings, NM_SETTING_VPN_SETTING_NAME, vpn);
-
- secrets = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
- g_value_init (&val, DBUS_TYPE_G_MAP_OF_STRING);
- g_value_take_boxed (&val, secrets);
- g_hash_table_insert (vpn, NM_SETTING_VPN_SECRETS, &val);
-
- /* Add some secrets */
- g_hash_table_insert (secrets, (char *) key1, (char *) val1);
- g_hash_table_insert (secrets, (char *) key2, (char *) val2);
-
- success = nm_connection_update_secrets (connection, NM_SETTING_VPN_SETTING_NAME, settings, &error);
- g_assert_no_error (error);
- g_assert (success);
-
- /* Read the secrets back out */
- tmp = nm_setting_vpn_get_secret (s_vpn, key1);
- g_assert (tmp);
- g_assert_cmpstr (tmp, ==, val1);
-
- tmp = nm_setting_vpn_get_secret (s_vpn, key2);
- g_assert (tmp);
- g_assert_cmpstr (tmp, ==, val2);
-
- g_hash_table_destroy (settings);
- g_object_unref (connection);
-}
-
-#define TO_DEL_NUM 50
-typedef struct {
- NMSettingVPN *s_vpn;
- char *to_del[TO_DEL_NUM];
- guint called;
-} IterInfo;
-
-static void
-del_iter_func (const char *key, const char *value, gpointer user_data)
-{
- IterInfo *info = user_data;
- int i;
-
- /* Record how many times this function gets called; it should get called
- * exactly as many times as there are keys in the hash table, regardless
- * of what keys we delete from the table.
- */
- info->called++;
-
- /* During the iteration, remove a bunch of stuff from the table */
- if (info->called == 1) {
- for (i = 0; i < TO_DEL_NUM; i++)
- nm_setting_vpn_remove_data_item (info->s_vpn, info->to_del[i]);
- }
-}
-
-static void
-test_setting_vpn_modify_during_foreach (void)
-{
- NMSettingVPN *s_vpn;
- IterInfo info;
- char *key, *val;
- int i, u = 0;
-
- s_vpn = (NMSettingVPN *) nm_setting_vpn_new ();
- g_assert (s_vpn);
-
- for (i = 0; i < TO_DEL_NUM * 2; i++) {
- key = g_strdup_printf ("adsfasdfadf%d", i);
- val = g_strdup_printf ("42263236236awt%d", i);
- nm_setting_vpn_add_data_item (s_vpn, key, val);
-
- /* Cache some keys to delete */
- if (i % 2)
- info.to_del[u++] = g_strdup (key);
-
- g_free (key);
- g_free (val);
- }
-
- /* Iterate over current table keys */
- info.s_vpn = s_vpn;
- info.called = 0;
- nm_setting_vpn_foreach_data_item (s_vpn, del_iter_func, &info);
-
- /* Make sure all the things we removed during iteration are really gone */
- for (i = 0; i < TO_DEL_NUM; i++) {
- g_assert_cmpstr (nm_setting_vpn_get_data_item (s_vpn, info.to_del[i]), ==, NULL);
- g_free (info.to_del[i]);
- }
-
- /* And make sure the foreach callback was called the same number of times
- * as there were keys in the table at the beginning of the foreach.
- */
- g_assert_cmpint (info.called, ==, TO_DEL_NUM * 2);
-
- g_object_unref (s_vpn);
-}
-
-static void
-_g_value_array_free (void *ptr)
-{
- if (ptr)
- g_value_array_free ((GValueArray *) ptr);
-}
-
-#define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
-#define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS))
-
-/* Test that setting the IPv6 setting's 'addresses' property using the old
- * IPv6 address format still works, i.e. that the GValue transformation function
- * from old->new is working correctly.
- */
-static void
-test_setting_ip6_config_old_address_array (void)
-{
- NMSettingIP6Config *s_ip6;
- GPtrArray *addresses, *read_addresses;
- GValueArray *array, *read_array;
- GValue element = G_VALUE_INIT, written_value = G_VALUE_INIT, read_value = G_VALUE_INIT;
- GByteArray *ba;
- const guint8 addr[16] = { 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11,
- 0x11, 0x22, 0x33, 0x44, 0x66, 0x77, 0x88, 0x99 };
- const guint8 gw[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- guint32 prefix = 56;
- GValue *read_addr, *read_prefix, *read_gw;
-
- s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
- g_assert (s_ip6);
-
- g_value_init (&written_value, OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS);
-
- addresses = g_ptr_array_new_full (0, _g_value_array_free);
- array = g_value_array_new (3);
-
- /* IP address */
- g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
- ba = g_byte_array_new ();
- g_byte_array_append (ba, &addr[0], sizeof (addr));
- g_value_take_boxed (&element, ba);
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- /* Prefix */
- g_value_init (&element, G_TYPE_UINT);
- g_value_set_uint (&element, prefix);
- g_value_array_append (array, &element);
- g_value_unset (&element);
-
- g_ptr_array_add (addresses, array);
- g_value_set_boxed (&written_value, addresses);
-
- /* Set the address array on the object */
- g_object_set_property (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_ADDRESSES, &written_value);
-
- /* Get it back so we can compare it */
- g_value_init (&read_value, DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS);
- g_object_get_property (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_ADDRESSES, &read_value);
-
- g_assert (G_VALUE_HOLDS (&read_value, DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS));
-
- read_addresses = (GPtrArray *) g_value_get_boxed (&read_value);
- g_assert (read_addresses);
- g_assert_cmpint (read_addresses->len, ==, 1);
-
- read_array = (GValueArray *) g_ptr_array_index (read_addresses, 0);
-
- read_addr = g_value_array_get_nth (read_array, 0);
- ba = g_value_get_boxed (read_addr);
- g_assert_cmpint (ba->len, ==, sizeof (addr));
- g_assert_cmpmem (ba->data, ba->len, &addr[0], sizeof (addr));
-
- read_prefix = g_value_array_get_nth (read_array, 1);
- g_assert_cmpint (g_value_get_uint (read_prefix), ==, prefix);
-
- /* Ensure the gateway is all zeros, which is how the 2-item to 3-item
- * conversion happens.
- */
- read_gw = g_value_array_get_nth (read_array, 2);
- ba = g_value_get_boxed (read_gw);
- g_assert_cmpint (ba->len, ==, sizeof (gw));
- g_assert_cmpmem (ba->data, ba->len, &gw[0], sizeof (gw));
-
- g_ptr_array_unref (addresses);
- g_value_unset (&written_value);
- g_value_unset (&read_value);
- g_object_unref (s_ip6);
-}
-
-static void
-test_setting_gsm_apn_spaces (void)
-{
- gs_unref_object NMSettingGsm *s_gsm = NULL;
- const char *tmp;
-
- s_gsm = (NMSettingGsm *) nm_setting_gsm_new ();
- g_assert (s_gsm);
-
- /* Trailing space */
- g_object_set (s_gsm, NM_SETTING_GSM_APN, "foobar ", NULL);
- tmp = nm_setting_gsm_get_apn (s_gsm);
- g_assert_cmpstr (tmp, ==, "foobar");
-
- /* Leading space */
- g_object_set (s_gsm, NM_SETTING_GSM_APN, " foobar", NULL);
- tmp = nm_setting_gsm_get_apn (s_gsm);
- g_assert_cmpstr (tmp, ==, "foobar");
-}
-
-static void
-test_setting_gsm_apn_bad_chars (void)
-{
- gs_unref_object NMSettingGsm *s_gsm = NULL;
-
- s_gsm = (NMSettingGsm *) nm_setting_gsm_new ();
- g_assert (s_gsm);
-
- g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "*99#", NULL);
-
- /* Make sure a valid APN works */
- g_object_set (s_gsm, NM_SETTING_GSM_APN, "foobar123.-baz", NULL);
- g_assert (nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL));
-
- /* Random invalid chars */
- g_object_set (s_gsm, NM_SETTING_GSM_APN, "@#%$@#%@#%", NULL);
- g_assert (!nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL));
-
- /* Spaces */
- g_object_set (s_gsm, NM_SETTING_GSM_APN, "foobar baz", NULL);
- g_assert (!nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL));
-
- /* 0 characters long */
- g_object_set (s_gsm, NM_SETTING_GSM_APN, "", NULL);
- g_assert (!nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL));
-
- /* 65-character long */
- g_object_set (s_gsm, NM_SETTING_GSM_APN, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl1", NULL);
- g_assert (!nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL));
-}
-
-static void
-test_setting_gsm_apn_underscore (void)
-{
- gs_unref_object NMSettingGsm *s_gsm = NULL;
- GError *error = NULL;
- gboolean success;
-
- s_gsm = (NMSettingGsm *) nm_setting_gsm_new ();
- g_assert (s_gsm);
-
- g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "*99#", NULL);
-
- /* 65-character long */
- g_object_set (s_gsm, NM_SETTING_GSM_APN, "foobar_baz", NULL);
- success = nm_setting_verify (NM_SETTING (s_gsm), NULL, &error);
- g_assert_no_error (error);
- g_assert (success == TRUE);
-}
-
-static void
-test_setting_gsm_without_number (void)
-{
- gs_unref_object NMSettingGsm *s_gsm = NULL;
- GError *error = NULL;
- gboolean success;
-
- s_gsm = (NMSettingGsm *) nm_setting_gsm_new ();
- g_assert (s_gsm);
-
- g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, NULL, NULL);
- success = nm_setting_verify (NM_SETTING (s_gsm), NULL, &error);
- g_assert_no_error (error);
- g_assert (success == TRUE);
-
- g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "", NULL);
- success = nm_setting_verify (NM_SETTING (s_gsm), NULL, &error);
- g_assert_error (error, NM_SETTING_GSM_ERROR, NM_SETTING_GSM_ERROR_INVALID_PROPERTY);
- g_error_free (error);
-}
-
-static NMSettingWirelessSecurity *
-make_test_wsec_setting (const char *detail)
-{
- NMSettingWirelessSecurity *s_wsec;
-
- s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
- g_assert (s_wsec);
- g_object_set (s_wsec,
- NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk",
- NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "foobarbaz",
- NM_SETTING_WIRELESS_SECURITY_PSK, "random psk",
- NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "aaaaaaaaaa",
- NULL);
- return s_wsec;
-}
-
-static void
-test_setting_to_hash_all (void)
-{
- NMSettingWirelessSecurity *s_wsec;
- GHashTable *hash;
-
- s_wsec = make_test_wsec_setting ("setting-to-hash-all");
-
- hash = nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ALL);
-
- /* Make sure all keys are there */
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT));
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME));
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_PSK));
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0));
-
- g_hash_table_destroy (hash);
- g_object_unref (s_wsec);
-}
-
-static void
-test_setting_to_hash_no_secrets (void)
-{
- NMSettingWirelessSecurity *s_wsec;
- GHashTable *hash;
-
- s_wsec = make_test_wsec_setting ("setting-to-hash-no-secrets");
-
- hash = nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_NO_SECRETS);
-
- /* Make sure non-secret keys are there */
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT));
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME));
-
- /* Make sure secrets are not there */
- g_assert (!g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_PSK));
- g_assert (!g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0));
-
- g_hash_table_destroy (hash);
- g_object_unref (s_wsec);
-}
-
-static void
-test_setting_to_hash_only_secrets (void)
-{
- NMSettingWirelessSecurity *s_wsec;
- GHashTable *hash;
-
- s_wsec = make_test_wsec_setting ("setting-to-hash-only-secrets");
-
- hash = nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ONLY_SECRETS);
-
- /* Make sure non-secret keys are there */
- g_assert (!g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT));
- g_assert (!g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME));
-
- /* Make sure secrets are not there */
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_PSK));
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0));
-
- g_hash_table_destroy (hash);
- g_object_unref (s_wsec);
-}
-
-static void
-test_connection_to_hash_setting_name (void)
-{
- NMConnection *connection;
- NMSettingWirelessSecurity *s_wsec;
- GHashTable *hash;
-
- connection = nm_connection_new ();
- s_wsec = make_test_wsec_setting ("connection-to-hash-setting-name");
- nm_connection_add_setting (connection, NM_SETTING (s_wsec));
-
- hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
-
- /* Make sure the keys of the first level hash are setting names, not
- * the GType name of the setting objects.
- */
- g_assert (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME));
-
- g_hash_table_destroy (hash);
- g_object_unref (connection);
-}
-
-static void
-test_setting_new_from_hash (void)
-{
- NMSettingWirelessSecurity *s_wsec;
- GHashTable *hash;
-
- s_wsec = make_test_wsec_setting ("setting-to-hash-all");
- hash = nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ALL);
- g_object_unref (s_wsec);
-
- s_wsec = (NMSettingWirelessSecurity *) nm_setting_new_from_hash (NM_TYPE_SETTING_WIRELESS_SECURITY, hash);
- g_hash_table_destroy (hash);
-
- g_assert (s_wsec);
- g_assert_cmpstr (nm_setting_wireless_security_get_key_mgmt (s_wsec), ==, "wpa-psk");
- g_assert_cmpstr (nm_setting_wireless_security_get_leap_username (s_wsec), ==, "foobarbaz");
- g_assert_cmpstr (nm_setting_wireless_security_get_psk (s_wsec), ==, "random psk");
- g_object_unref (s_wsec);
-}
-
-static NMConnection *
-new_test_connection (void)
-{
- NMConnection *connection;
- NMSetting *setting;
- char *uuid;
- guint64 timestamp = time (NULL);
-
- connection = nm_connection_new ();
-
- setting = nm_setting_connection_new ();
- uuid = nm_utils_uuid_generate ();
- g_object_set (G_OBJECT (setting),
- NM_SETTING_CONNECTION_ID, "foobar",
- NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
- NM_SETTING_CONNECTION_TIMESTAMP, timestamp,
- NULL);
- g_free (uuid);
- nm_connection_add_setting (connection, setting);
-
- setting = nm_setting_wired_new ();
- g_object_set (G_OBJECT (setting),
- NM_SETTING_WIRED_MTU, 1592,
- NULL);
- nm_connection_add_setting (connection, setting);
-
- setting = nm_setting_ip4_config_new ();
- g_object_set (G_OBJECT (setting),
- NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
- NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, "eyeofthetiger",
- NULL);
- nm_connection_add_setting (connection, setting);
-
- return connection;
-}
-
-static GValue *
-string_to_gvalue (const char *str)
-{
- GValue *val;
-
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_STRING);
- g_value_set_string (val, str);
- return val;
-}
-
-static void
-destroy_gvalue (gpointer data)
-{
- g_value_unset ((GValue *) data);
- g_slice_free (GValue, data);
-}
-
-static GHashTable *
-new_connection_hash (char **out_uuid,
- const char **out_expected_id,
- const char **out_expected_ip6_method)
-{
- GHashTable *hash;
- GHashTable *setting;
-
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
-
- *out_uuid = nm_utils_uuid_generate ();
- *out_expected_id = "My happy connection";
- *out_expected_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL;
-
- /* Connection setting */
- setting = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_gvalue);
- g_hash_table_insert (setting,
- g_strdup (NM_SETTING_NAME),
- string_to_gvalue (NM_SETTING_CONNECTION_SETTING_NAME));
- g_hash_table_insert (setting,
- g_strdup (NM_SETTING_CONNECTION_ID),
- string_to_gvalue (*out_expected_id));
- g_hash_table_insert (setting,
- g_strdup (NM_SETTING_CONNECTION_UUID),
- string_to_gvalue (*out_uuid));
- g_hash_table_insert (setting,
- g_strdup (NM_SETTING_CONNECTION_TYPE),
- string_to_gvalue (NM_SETTING_WIRED_SETTING_NAME));
- g_hash_table_insert (hash, g_strdup (NM_SETTING_CONNECTION_SETTING_NAME), setting);
-
- /* Wired setting */
- setting = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_gvalue);
- g_hash_table_insert (hash, g_strdup (NM_SETTING_WIRED_SETTING_NAME), setting);
-
- /* IP6 */
- setting = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_gvalue);
- g_hash_table_insert (setting,
- g_strdup (NM_SETTING_IP6_CONFIG_METHOD),
- string_to_gvalue (*out_expected_ip6_method));
- g_hash_table_insert (hash, g_strdup (NM_SETTING_IP6_CONFIG_SETTING_NAME), setting);
-
- return hash;
-}
-
-static void
-test_connection_replace_settings (void)
-{
- NMConnection *connection;
- GHashTable *new_settings;
- GError *error = NULL;
- gboolean success;
- NMSettingConnection *s_con;
- NMSettingIP6Config *s_ip6;
- char *uuid = NULL;
- const char *expected_id = NULL, *expected_method = NULL;
-
- connection = new_test_connection ();
-
- new_settings = new_connection_hash (&uuid, &expected_id, &expected_method);
- g_assert (new_settings);
-
- /* Replace settings and test */
- success = nm_connection_replace_settings (connection, new_settings, &error);
- g_assert_no_error (error);
- g_assert (success);
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
- g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, expected_id);
- g_assert_cmpstr (nm_setting_connection_get_uuid (s_con), ==, uuid);
-
- g_assert (nm_connection_get_setting_wired (connection));
- g_assert (!nm_connection_get_setting_ip4_config (connection));
-
- s_ip6 = nm_connection_get_setting_ip6_config (connection);
- g_assert (s_ip6);
- g_assert_cmpstr (nm_setting_ip6_config_get_method (s_ip6), ==, expected_method);
-
- g_free (uuid);
- g_hash_table_destroy (new_settings);
- g_object_unref (connection);
-}
-
-static void
-test_connection_replace_settings_from_connection (void)
-{
- NMConnection *connection, *replacement;
- GError *error = NULL;
- gboolean success;
- NMSettingConnection *s_con;
- NMSetting *setting;
- GByteArray *ssid;
- char *uuid = NULL;
- const char *expected_id = "Awesome connection";
-
- connection = new_test_connection ();
- g_assert (connection);
-
- replacement = nm_connection_new ();
- g_assert (replacement);
-
- /* New connection setting */
- setting = nm_setting_connection_new ();
- g_assert (setting);
-
- uuid = nm_utils_uuid_generate ();
- g_object_set (setting,
- NM_SETTING_CONNECTION_ID, expected_id,
- NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME,
- NULL);
- nm_connection_add_setting (replacement, setting);
-
- /* New wifi setting */
- setting = nm_setting_wireless_new ();
- g_assert (setting);
-
- ssid = g_byte_array_new ();
- g_byte_array_append (ssid, (const guint8 *) "1234567", 7);
- g_object_set (setting,
- NM_SETTING_WIRELESS_SSID, ssid,
- NM_SETTING_WIRELESS_MODE, "infrastructure",
- NULL);
- g_byte_array_free (ssid, TRUE);
- nm_connection_add_setting (replacement, setting);
-
- /* Replace settings and test */
- success = nm_connection_replace_settings_from_connection (connection, replacement, &error);
- g_assert_no_error (error);
- g_assert (success);
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
- g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, expected_id);
- g_assert_cmpstr (nm_setting_connection_get_uuid (s_con), ==, uuid);
-
- g_assert (!nm_connection_get_setting_wired (connection));
- g_assert (!nm_connection_get_setting_ip6_config (connection));
- g_assert (nm_connection_get_setting_wireless (connection));
-
- g_free (uuid);
- g_object_unref (replacement);
- g_object_unref (connection);
-}
-
-static void
-test_connection_new_from_hash (void)
-{
- NMConnection *connection;
- GHashTable *new_settings;
- GError *error = NULL;
- NMSettingConnection *s_con;
- NMSettingIP6Config *s_ip6;
- char *uuid = NULL;
- const char *expected_id = NULL, *expected_method = NULL;
-
- new_settings = new_connection_hash (&uuid, &expected_id, &expected_method);
- g_assert (new_settings);
-
- /* Replace settings and test */
- connection = nm_connection_new_from_hash (new_settings, &error);
- g_assert_no_error (error);
- g_assert (connection);
-
- s_con = nm_connection_get_setting_connection (connection);
- g_assert (s_con);
- g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, expected_id);
- g_assert_cmpstr (nm_setting_connection_get_uuid (s_con), ==, uuid);
-
- g_assert (nm_connection_get_setting_wired (connection));
- g_assert (!nm_connection_get_setting_ip4_config (connection));
-
- s_ip6 = nm_connection_get_setting_ip6_config (connection);
- g_assert (s_ip6);
- g_assert_cmpstr (nm_setting_ip6_config_get_method (s_ip6), ==, expected_method);
-
- g_free (uuid);
- g_hash_table_destroy (new_settings);
- g_object_unref (connection);
-}
-
-static void
-check_permission (NMSettingConnection *s_con,
- guint32 idx,
- const char *expected_uname)
-{
- gboolean success;
- const char *ptype = NULL, *pitem = NULL, *detail = NULL;
-
- success = nm_setting_connection_get_permission (s_con, 0, &ptype, &pitem, &detail);
- g_assert (success);
-
- g_assert_cmpstr (ptype, ==, "user");
-
- g_assert (pitem);
- g_assert_cmpstr (pitem, ==, expected_uname);
-
- g_assert (!detail);
-}
-
-#define TEST_UNAME "asdfasfasdf"
-
-static void
-test_setting_connection_permissions_helpers (void)
-{
- NMSettingConnection *s_con;
- gboolean success;
- char buf[9] = { 0x61, 0x62, 0x63, 0xff, 0xfe, 0xfd, 0x23, 0x01, 0x00 };
- GSList *list = NULL;
- const char *expected_perm = "user:" TEST_UNAME ":";
-
- s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
-
- /* Ensure a bad [type] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strcmp (ptype, "user") == 0));
- success = nm_setting_connection_add_permission (s_con, "foobar", "blah", NULL);
- g_test_assert_expected_messages ();
- g_assert (!success);
-
- /* Ensure a bad [type] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (ptype));
- success = nm_setting_connection_add_permission (s_con, NULL, "blah", NULL);
- g_test_assert_expected_messages ();
- g_assert (!success);
-
- /* Ensure a bad [item] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (uname));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (p != NULL));
- success = nm_setting_connection_add_permission (s_con, "user", NULL, NULL);
- g_test_assert_expected_messages ();
- g_assert (!success);
-
- /* Ensure a bad [item] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (uname[0] != '\0'));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (p != NULL));
- success = nm_setting_connection_add_permission (s_con, "user", "", NULL);
- g_test_assert_expected_messages ();
- g_assert (!success);
-
- /* Ensure an [item] with ':' is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strchr (uname, ':') == NULL));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (p != NULL));
- success = nm_setting_connection_add_permission (s_con, "user", "ad:asdf", NULL);
- g_test_assert_expected_messages ();
- g_assert (!success);
-
- /* Ensure a non-UTF-8 [item] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (g_utf8_validate (uname, -1, NULL) == TRUE));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (p != NULL));
- success = nm_setting_connection_add_permission (s_con, "user", buf, NULL);
- g_test_assert_expected_messages ();
- g_assert (!success);
-
- /* Ensure a non-NULL [detail] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (detail == NULL));
- success = nm_setting_connection_add_permission (s_con, "user", "dafasdf", "asdf");
- g_test_assert_expected_messages ();
- g_assert (!success);
-
- /* Ensure a valid call results in success */
- success = nm_setting_connection_add_permission (s_con, "user", TEST_UNAME, NULL);
- g_assert (success);
-
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 1);
-
- check_permission (s_con, 0, TEST_UNAME);
-
- /* Check the actual GObject property just to be paranoid */
- g_object_get (G_OBJECT (s_con), NM_SETTING_CONNECTION_PERMISSIONS, &list, NULL);
- g_assert (list);
- g_assert_cmpint (g_slist_length (list), ==, 1);
- g_assert_cmpstr (list->data, ==, expected_perm);
- g_slist_free_full (list, g_free);
-
- /* Now remove that permission and ensure we have 0 permissions */
- nm_setting_connection_remove_permission (s_con, 0);
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- g_object_unref (s_con);
-}
-
-static void
-add_permission_property (NMSettingConnection *s_con,
- const char *ptype,
- const char *pitem,
- int pitem_len,
- const char *detail)
-{
- GString *str;
- GSList *list = NULL;
-
- str = g_string_sized_new (50);
- if (ptype)
- g_string_append (str, ptype);
- g_string_append_c (str, ':');
-
- if (pitem) {
- if (pitem_len >= 0)
- g_string_append_len (str, pitem, pitem_len);
- else
- g_string_append (str, pitem);
- }
-
- g_string_append_c (str, ':');
-
- if (detail)
- g_string_append (str, detail);
-
- list = g_slist_append (list, str->str);
- g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_PERMISSIONS, list, NULL);
-
- g_string_free (str, TRUE);
- g_slist_free (list);
-}
-
-static void
-test_setting_connection_permissions_property (void)
-{
- NMSettingConnection *s_con;
- gboolean success;
- char buf[9] = { 0x61, 0x62, 0x63, 0xff, 0xfe, 0xfd, 0x23, 0x01, 0x00 };
-
- s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
-
- /* Ensure a bad [type] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strncmp (str, PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0));
- add_permission_property (s_con, "foobar", "blah", -1, NULL);
- g_test_assert_expected_messages ();
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- /* Ensure a bad [type] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (strncmp (str, PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0));
- add_permission_property (s_con, NULL, "blah", -1, NULL);
- g_test_assert_expected_messages ();
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- /* Ensure a bad [item] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (last_colon > str));
- add_permission_property (s_con, "user", NULL, -1, NULL);
- g_test_assert_expected_messages ();
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- /* Ensure a bad [item] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (last_colon > str));
- add_permission_property (s_con, "user", "", -1, NULL);
- g_test_assert_expected_messages ();
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- /* Ensure an [item] with ':' in the middle is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (str[i] != ':'));
- add_permission_property (s_con, "user", "ad:asdf", -1, NULL);
- g_test_assert_expected_messages ();
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- /* Ensure an [item] with ':' at the end is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (str[i] != ':'));
- add_permission_property (s_con, "user", "adasdfaf:", -1, NULL);
- g_test_assert_expected_messages ();
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- /* Ensure a non-UTF-8 [item] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (g_utf8_validate (str, -1, NULL) == TRUE));
- add_permission_property (s_con, "user", buf, (int) sizeof (buf), NULL);
- g_test_assert_expected_messages ();
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- /* Ensure a non-NULL [detail] is rejected */
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (*(last_colon + 1) == '\0'));
- add_permission_property (s_con, "user", "dafasdf", -1, "asdf");
- g_test_assert_expected_messages ();
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- /* Ensure a valid call results in success */
- success = nm_setting_connection_add_permission (s_con, "user", TEST_UNAME, NULL);
- g_assert (success);
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 1);
-
- check_permission (s_con, 0, TEST_UNAME);
-
- /* Now remove that permission and ensure we have 0 permissions */
- nm_setting_connection_remove_permission (s_con, 0);
- g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 0);
-
- g_object_unref (s_con);
-}
-
-static void
-test_connection_compare_same (void)
-{
- NMConnection *a, *b;
-
- a = new_test_connection ();
- b = nm_connection_duplicate (a);
- g_assert (nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT));
- g_object_unref (a);
- g_object_unref (b);
-}
-
-static void
-test_connection_compare_key_only_in_a (void)
-{
- NMConnection *a, *b;
- NMSettingConnection *s_con;
-
- a = new_test_connection ();
- b = nm_connection_duplicate (a);
- s_con = (NMSettingConnection *) nm_connection_get_setting (b, NM_TYPE_SETTING_CONNECTION);
- g_assert (s_con);
- g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) 0, NULL);
-
- g_assert (!nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT));
- g_object_unref (a);
- g_object_unref (b);
-}
-
-static void
-test_connection_compare_setting_only_in_a (void)
-{
- NMConnection *a, *b;
-
- a = new_test_connection ();
- b = nm_connection_duplicate (a);
- nm_connection_remove_setting (b, NM_TYPE_SETTING_IP4_CONFIG);
- g_assert (!nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT));
- g_object_unref (a);
- g_object_unref (b);
-}
-
-static void
-test_connection_compare_key_only_in_b (void)
-{
- NMConnection *a, *b;
- NMSettingConnection *s_con;
-
- a = new_test_connection ();
- b = nm_connection_duplicate (a);
- s_con = (NMSettingConnection *) nm_connection_get_setting (b, NM_TYPE_SETTING_CONNECTION);
- g_assert (s_con);
- g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) 0, NULL);
-
- g_assert (!nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT));
- g_object_unref (a);
- g_object_unref (b);
-}
-
-static void
-test_connection_compare_setting_only_in_b (void)
-{
- NMConnection *a, *b;
-
- a = new_test_connection ();
- b = nm_connection_duplicate (a);
- nm_connection_remove_setting (a, NM_TYPE_SETTING_IP4_CONFIG);
- g_assert (!nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT));
- g_object_unref (a);
- g_object_unref (b);
-}
-
-typedef struct {
- const char *key_name;
- guint32 result;
-} DiffKey;
-
-typedef struct {
- const char *name;
- DiffKey keys[30];
-} DiffSetting;
-
-#define ARRAY_LEN(a) (sizeof (a) / sizeof (a[0]))
-
-static void
-ensure_diffs (GHashTable *diffs, const DiffSetting *check, gsize n_check)
-{
- guint i;
-
- g_assert (g_hash_table_size (diffs) == n_check);
-
- /* Loop through the settings */
- for (i = 0; i < n_check; i++) {
- GHashTable *setting_hash;
- guint z = 0;
-
- setting_hash = g_hash_table_lookup (diffs, check[i].name);
- g_assert (setting_hash);
-
- /* Get the number of keys to check */
- while (check[i].keys[z].key_name)
- z++;
- g_assert (g_hash_table_size (setting_hash) == z);
-
- /* Now compare the actual keys */
- for (z = 0; check[i].keys[z].key_name; z++) {
- NMSettingDiffResult result;
-
- result = GPOINTER_TO_UINT (g_hash_table_lookup (setting_hash, check[i].keys[z].key_name));
- g_assert (result == check[i].keys[z].result);
- }
- }
-}
-
-static void
-test_connection_diff_a_only (void)
-{
- NMConnection *connection;
- GHashTable *out_diffs = NULL;
- gboolean same;
- const DiffSetting settings[] = {
- { NM_SETTING_CONNECTION_SETTING_NAME, {
- { NM_SETTING_CONNECTION_ID, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_UUID, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_INTERFACE_NAME, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_TYPE, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_TIMESTAMP, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_AUTOCONNECT, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_READ_ONLY, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_PERMISSIONS, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_ZONE, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_MASTER, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_SECONDARIES, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
- { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN }
- } },
- { NM_SETTING_WIRED_SETTING_NAME, {
- { NM_SETTING_WIRED_PORT, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_SPEED, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_DUPLEX, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_AUTO_NEGOTIATE, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_MAC_ADDRESS, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_CLONED_MAC_ADDRESS, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_MTU, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_S390_SUBCHANNELS, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_S390_NETTYPE, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_WIRED_S390_OPTIONS, NM_SETTING_DIFF_RESULT_IN_A },
- { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
- } },
- { NM_SETTING_IP4_CONFIG_SETTING_NAME, {
- { NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_DNS, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_DNS_SEARCH, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_ADDRESSES, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_ROUTE_METRIC, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, NM_SETTING_DIFF_RESULT_IN_A },
- { NM_SETTING_IP4_CONFIG_MAY_FAIL, NM_SETTING_DIFF_RESULT_IN_A },
- { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
- } },
- };
-
- connection = new_test_connection ();
-
- same = nm_connection_diff (connection, NULL, NM_SETTING_COMPARE_FLAG_EXACT, &out_diffs);
- g_assert (same == FALSE);
- g_assert (out_diffs != NULL);
- g_assert (g_hash_table_size (out_diffs) > 0);
-
- ensure_diffs (out_diffs, settings, ARRAY_LEN (settings));
-
- g_hash_table_destroy (out_diffs);
- g_object_unref (connection);
-}
-
-static void
-test_connection_diff_same (void)
-{
- NMConnection *a, *b;
- GHashTable *out_diffs = NULL;
- gboolean same;
-
- a = new_test_connection ();
- b = nm_connection_duplicate (a);
-
- same = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_EXACT, &out_diffs);
- g_assert (same == TRUE);
- g_assert (out_diffs == NULL);
- g_object_unref (a);
- g_object_unref (b);
-}
-
-static void
-test_connection_diff_different (void)
-{
- NMConnection *a, *b;
- GHashTable *out_diffs = NULL;
- NMSettingIP4Config *s_ip4;
- gboolean same;
- const DiffSetting settings[] = {
- { NM_SETTING_IP4_CONFIG_SETTING_NAME, {
- { NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_DIFF_RESULT_IN_A | NM_SETTING_DIFF_RESULT_IN_B },
- { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
- } },
- };
-
- a = new_test_connection ();
- b = nm_connection_duplicate (a);
- s_ip4 = nm_connection_get_setting_ip4_config (a);
- g_assert (s_ip4);
- g_object_set (G_OBJECT (s_ip4),
- NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
- NULL);
-
- same = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_EXACT, &out_diffs);
- g_assert (same == FALSE);
- g_assert (out_diffs != NULL);
- g_assert (g_hash_table_size (out_diffs) > 0);
-
- ensure_diffs (out_diffs, settings, ARRAY_LEN (settings));
-
- g_hash_table_destroy (out_diffs);
- g_object_unref (a);
- g_object_unref (b);
-}
-
-static void
-test_connection_diff_no_secrets (void)
-{
- NMConnection *a, *b;
- GHashTable *out_diffs = NULL;
- NMSetting *s_pppoe;
- gboolean same;
- const DiffSetting settings[] = {
- { NM_SETTING_PPPOE_SETTING_NAME, {
- { NM_SETTING_PPPOE_PASSWORD, NM_SETTING_DIFF_RESULT_IN_B },
- { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
- } },
- };
-
- a = new_test_connection ();
- s_pppoe = nm_setting_pppoe_new ();
- g_object_set (G_OBJECT (s_pppoe),
- NM_SETTING_PPPOE_USERNAME, "thomas",
- NULL);
- nm_connection_add_setting (a, s_pppoe);
-
- b = nm_connection_duplicate (a);
-
- /* Add a secret to B */
- s_pppoe = NM_SETTING (nm_connection_get_setting_pppoe (b));
- g_assert (s_pppoe);
- g_object_set (G_OBJECT (s_pppoe),
- NM_SETTING_PPPOE_PASSWORD, "secretpassword",
- NULL);
-
- /* Make sure the diff returns no results as secrets are ignored */
- same = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS, &out_diffs);
- g_assert (same == TRUE);
- g_assert (out_diffs == NULL);
-
- /* Now make sure the diff returns results if secrets are not ignored */
- same = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_EXACT, &out_diffs);
- g_assert (same == FALSE);
- g_assert (out_diffs != NULL);
- g_assert (g_hash_table_size (out_diffs) > 0);
-
- ensure_diffs (out_diffs, settings, ARRAY_LEN (settings));
-
- g_hash_table_destroy (out_diffs);
- g_object_unref (a);
- g_object_unref (b);
-}
-
-static void
-test_connection_diff_inferrable (void)
-{
- NMConnection *a, *b;
- GHashTable *out_diffs = NULL;
- gboolean same;
- NMSettingConnection *s_con;
- NMSettingWired *s_wired;
- NMSettingIP4Config *s_ip4;
- char *uuid;
- const DiffSetting settings[] = {
- { NM_SETTING_CONNECTION_SETTING_NAME, {
- { NM_SETTING_CONNECTION_INTERFACE_NAME, NM_SETTING_DIFF_RESULT_IN_A },
- { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
- } },
- };
-
- a = new_test_connection ();
- b = nm_connection_duplicate (a);
-
- /* Change the UUID, wired MTU, and set ignore-auto-dns */
- s_con = nm_connection_get_setting_connection (a);
- g_assert (s_con);
- uuid = nm_utils_uuid_generate ();
- g_object_set (G_OBJECT (s_con),
- NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_ID, "really neat connection",
- NULL);
- g_free (uuid);
-
- s_wired = nm_connection_get_setting_wired (a);
- g_assert (s_wired);
- g_object_set (G_OBJECT (s_wired), NM_SETTING_WIRED_MTU, 300, NULL);
-
- s_ip4 = nm_connection_get_setting_ip4_config (a);
- g_assert (s_ip4);
- g_object_set (G_OBJECT (s_ip4), NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, TRUE, NULL);
-
- /* Make sure the diff returns no results as secrets are ignored */
- same = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_INFERRABLE, &out_diffs);
- g_assert (same == TRUE);
- g_assert (out_diffs == NULL);
-
- /* And change a INFERRABLE property to ensure that it shows up in the diff results */
- g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, "usb0", NULL);
-
- /* Make sure the diff returns no results as secrets are ignored */
- same = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_INFERRABLE, &out_diffs);
- g_assert (same == FALSE);
- g_assert (out_diffs != NULL);
- g_assert (g_hash_table_size (out_diffs) > 0);
-
- ensure_diffs (out_diffs, settings, ARRAY_LEN (settings));
-
- g_hash_table_destroy (out_diffs);
- g_object_unref (a);
- g_object_unref (b);
-}
-
-static void
-add_generic_settings (NMConnection *connection, const char *ctype)
-{
- NMSetting *setting;
- char *uuid;
-
- uuid = nm_utils_uuid_generate ();
-
- setting = nm_setting_connection_new ();
- g_object_set (setting,
- NM_SETTING_CONNECTION_ID, "asdfasdfadf",
- NM_SETTING_CONNECTION_TYPE, ctype,
- NM_SETTING_CONNECTION_UUID, uuid,
- NULL);
- nm_connection_add_setting (connection, setting);
-
- g_free (uuid);
-
- setting = nm_setting_ip4_config_new ();
- g_object_set (setting, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
- nm_connection_add_setting (connection, setting);
-
- setting = nm_setting_ip6_config_new ();
- g_object_set (setting, NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
- nm_connection_add_setting (connection, setting);
-}
-
-static void
-test_connection_good_base_types (void)
-{
- NMConnection *connection;
- NMSetting *setting;
- gboolean success;
- GError *error = NULL;
- GByteArray *array;
- const guint8 bdaddr[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
-
- /* Try a basic wired connection */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_WIRED_SETTING_NAME);
- setting = nm_setting_wired_new ();
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_no_error (error);
- g_assert (success);
- g_object_unref (connection);
-
- /* Try a wired PPPoE connection */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_PPPOE_SETTING_NAME);
- setting = nm_setting_pppoe_new ();
- g_object_set (setting, NM_SETTING_PPPOE_USERNAME, "bob smith", NULL);
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_no_error (error);
- g_assert (success);
- g_object_unref (connection);
-
- /* Wifi connection */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_WIRELESS_SETTING_NAME);
-
- setting = nm_setting_wireless_new ();
- array = g_byte_array_new ();
- g_byte_array_append (array, (const guint8 *) "1234567", 7);
- g_object_set (setting,
- NM_SETTING_WIRELESS_SSID, array,
- NM_SETTING_WIRELESS_MODE, "infrastructure",
- NULL);
- g_byte_array_free (array, TRUE);
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_no_error (error);
- g_assert (success);
- g_object_unref (connection);
-
- /* Bluetooth connection */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_BLUETOOTH_SETTING_NAME);
-
- setting = nm_setting_bluetooth_new ();
- array = g_byte_array_new ();
- g_byte_array_append (array, bdaddr, sizeof (bdaddr));
- g_object_set (setting,
- NM_SETTING_BLUETOOTH_BDADDR, array,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU,
- NULL);
- g_byte_array_free (array, TRUE);
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_no_error (error);
- g_assert (success);
- g_object_unref (connection);
-
- /* WiMAX connection */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_WIMAX_SETTING_NAME);
- setting = nm_setting_wimax_new ();
- g_object_set (setting, NM_SETTING_WIMAX_NETWORK_NAME, "CLEAR", NULL);
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_no_error (error);
- g_assert (success);
- g_object_unref (connection);
-
- /* GSM connection */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_GSM_SETTING_NAME);
-
- setting = nm_setting_gsm_new ();
- g_object_set (setting,
- NM_SETTING_GSM_NUMBER, "*99#",
- NM_SETTING_GSM_APN, "metered.billing.sucks",
- NULL);
- nm_connection_add_setting (connection, setting);
- g_clear_object (&connection);
-
- /* CDMA connection */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_CDMA_SETTING_NAME);
-
- setting = nm_setting_cdma_new ();
- g_object_set (setting,
- NM_SETTING_CDMA_NUMBER, "#777",
- NM_SETTING_CDMA_USERNAME, "foobar@vzw.com",
- NULL);
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_no_error (error);
- g_assert (success);
- g_object_unref (connection);
-}
-
-static void
-test_connection_bad_base_types (void)
-{
- NMConnection *connection;
- NMSetting *setting;
- gboolean success;
- 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
- */
-
- /* Connection setting */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_CONNECTION_SETTING_NAME);
- setting = nm_setting_wired_new ();
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID);
- g_assert (success == FALSE);
- g_object_unref (connection);
- g_clear_error (&error);
-
- /* PPP setting */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_PPP_SETTING_NAME);
- setting = nm_setting_wired_new ();
- nm_connection_add_setting (connection, setting);
- setting = nm_setting_ppp_new ();
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID);
- g_assert (success == FALSE);
- g_object_unref (connection);
- g_clear_error (&error);
-
- /* Serial setting */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_SERIAL_SETTING_NAME);
- setting = nm_setting_wired_new ();
- nm_connection_add_setting (connection, setting);
- setting = nm_setting_serial_new ();
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID);
- g_assert (success == FALSE);
- g_object_unref (connection);
- g_clear_error (&error);
-
- /* IP4 setting */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_IP4_CONFIG_SETTING_NAME);
- setting = nm_setting_wired_new ();
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID);
- g_assert (success == FALSE);
- g_object_unref (connection);
- g_clear_error (&error);
-
- /* IP6 setting */
- connection = nm_connection_new ();
- add_generic_settings (connection, NM_SETTING_IP6_CONFIG_SETTING_NAME);
- setting = nm_setting_wired_new ();
- nm_connection_add_setting (connection, setting);
-
- success = nm_connection_verify (connection, &error);
- g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID);
- g_assert (success == FALSE);
- g_object_unref (connection);
- g_clear_error (&error);
-}
-
-static void
-test_setting_compare_id (void)
-{
- gs_unref_object NMSetting *old = NULL, *new = NULL;
- gboolean success;
-
- old = nm_setting_connection_new ();
- g_object_set (old,
- NM_SETTING_CONNECTION_ID, "really awesome cool connection",
- NM_SETTING_CONNECTION_UUID, "fbbd59d5-acab-4e30-8f86-258d272617e7",
- NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
- NULL);
-
- new = nm_setting_duplicate (old);
- g_object_set (new, NM_SETTING_CONNECTION_ID, "some different connection id", NULL);
-
- /* First make sure they are different */
- success = nm_setting_compare (old, new, NM_SETTING_COMPARE_FLAG_EXACT);
- g_assert (success == FALSE);
-
- success = nm_setting_compare (old, new, NM_SETTING_COMPARE_FLAG_IGNORE_ID);
- g_assert (success);
-}
-
-static void
-_compare_secrets (NMSettingSecretFlags secret_flags,
- NMSettingCompareFlags comp_flags,
- gboolean remove_secret)
-{
- 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.
- */
-
- old = nm_setting_wireless_security_new ();
- g_object_set (old,
- NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk",
- NM_SETTING_WIRELESS_SECURITY_PSK, "really cool psk",
- NULL);
- nm_setting_set_secret_flags (old, NM_SETTING_WIRELESS_SECURITY_PSK, secret_flags, NULL);
-
- /* Clear the PSK from the duplicated setting */
- new = nm_setting_duplicate (old);
- if (remove_secret) {
- g_object_set (new, NM_SETTING_WIRELESS_SECURITY_PSK, NULL, NULL);
-
- success = nm_setting_compare (old, new, NM_SETTING_COMPARE_FLAG_EXACT);
- g_assert (success == FALSE);
- }
-
- success = nm_setting_compare (old, new, comp_flags);
- g_assert (success);
-}
-
-static void
-test_setting_compare_secrets (void)
-{
- _compare_secrets (NM_SETTING_SECRET_FLAG_AGENT_OWNED, NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS, TRUE);
- _compare_secrets (NM_SETTING_SECRET_FLAG_NOT_SAVED, NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS, TRUE);
- _compare_secrets (NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS, TRUE);
- _compare_secrets (NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_EXACT, FALSE);
-}
-
-static void
-_compare_vpn_secrets (NMSettingSecretFlags secret_flags,
- NMSettingCompareFlags comp_flags,
- gboolean remove_secret)
-{
- 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.
- */
-
- old = nm_setting_vpn_new ();
- nm_setting_vpn_add_secret (NM_SETTING_VPN (old), "foobarbaz", "really secret password");
- nm_setting_vpn_add_secret (NM_SETTING_VPN (old), "asdfasdfasdf", "really adfasdfasdfasdf");
- nm_setting_vpn_add_secret (NM_SETTING_VPN (old), "0123456778", "abcdefghijklmnpqrstuvqxyz");
- nm_setting_vpn_add_secret (NM_SETTING_VPN (old), "borkbork", "yet another really secret password");
- nm_setting_set_secret_flags (old, "borkbork", secret_flags, NULL);
-
- /* Clear "borkbork" from the duplicated setting */
- new = nm_setting_duplicate (old);
- if (remove_secret) {
- nm_setting_vpn_remove_secret (NM_SETTING_VPN (new), "borkbork");
-
- /* First make sure they are different */
- success = nm_setting_compare (old, new, NM_SETTING_COMPARE_FLAG_EXACT);
- g_assert (success == FALSE);
- }
-
- success = nm_setting_compare (old, new, comp_flags);
- g_assert (success);
-}
-
-static void
-test_setting_compare_vpn_secrets (void)
-{
- _compare_vpn_secrets (NM_SETTING_SECRET_FLAG_AGENT_OWNED, NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS, TRUE);
- _compare_vpn_secrets (NM_SETTING_SECRET_FLAG_NOT_SAVED, NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS, TRUE);
- _compare_vpn_secrets (NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS, TRUE);
- _compare_vpn_secrets (NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_EXACT, FALSE);
-}
-
-static void
-test_hwaddr_aton_ether_normal (void)
-{
- guint8 buf[100];
- guint8 expected[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
-
- g_assert (nm_utils_hwaddr_aton ("00:11:22:33:44:55", ARPHRD_ETHER, buf) != NULL);
- g_assert (memcmp (buf, expected, sizeof (expected)) == 0);
-}
-
-static void
-test_hwaddr_aton_ib_normal (void)
-{
- guint8 buf[100];
- const char *source = "00:11:22:33:44:55:66:77:88:99:01:12:23:34:45:56:67:78:89:90";
- guint8 expected[INFINIBAND_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
- 0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89,
- 0x90 };
-
- g_assert (nm_utils_hwaddr_aton (source, ARPHRD_INFINIBAND, buf) != NULL);
- g_assert (memcmp (buf, expected, sizeof (expected)) == 0);
-}
-
-static void
-test_hwaddr_aton_no_leading_zeros (void)
-{
- guint8 buf[100];
- guint8 expected[ETH_ALEN] = { 0x00, 0x1A, 0x2B, 0x03, 0x44, 0x05 };
-
- g_assert (nm_utils_hwaddr_aton ("0:1a:2B:3:44:5", ARPHRD_ETHER, buf) != NULL);
- g_assert (memcmp (buf, expected, sizeof (expected)) == 0);
-}
-
-static void
-test_hwaddr_aton_malformed (void)
-{
- guint8 buf[100];
-
- g_assert (nm_utils_hwaddr_aton ("0:1a:2B:3:a@%%", ARPHRD_ETHER, buf) == NULL);
-}
-
-static void
-test_connection_changed_cb (NMConnection *connection, gboolean *data)
-{
- *data = TRUE;
-}
-
-static void
-test_ip4_prefix_to_netmask (void)
-{
- int i;
-
- for (i = 0; i<=32; i++) {
- guint32 netmask = nm_utils_ip4_prefix_to_netmask (i);
- int plen = nm_utils_ip4_netmask_to_prefix (netmask);
-
- g_assert_cmpint (i, ==, plen);
- {
- guint32 msk = 0x80000000;
- guint32 netmask2 = 0;
- guint32 prefix = i;
- while (prefix > 0) {
- netmask2 |= msk;
- msk >>= 1;
- prefix--;
- }
- g_assert_cmpint (netmask, ==, (guint32) htonl (netmask2));
- }
- }
-}
-
-static void
-test_ip4_netmask_to_prefix (void)
-{
- int i, j;
-
- GRand *r = g_rand_new ();
-
- g_rand_set_seed (r, 1);
-
- for (i = 2; i<=32; i++) {
- guint32 netmask = nm_utils_ip4_prefix_to_netmask (i);
- guint32 netmask_lowest_bit = netmask & ~nm_utils_ip4_prefix_to_netmask (i-1);
-
- g_assert_cmpint (i, ==, nm_utils_ip4_netmask_to_prefix (netmask));
-
- for (j = 0; j < 2*i; j++) {
- guint32 n = g_rand_int (r);
- guint32 netmask_holey;
- guint32 prefix_holey;
-
- netmask_holey = (netmask & n) | netmask_lowest_bit;
-
- if (netmask_holey == netmask)
- continue;
-
- /* create an invalid netmask with holes and check that the function
- * returns the longest prefix. */
- prefix_holey = nm_utils_ip4_netmask_to_prefix (netmask_holey);
-
- g_assert_cmpint (i, ==, prefix_holey);
- }
- }
-
- g_rand_free (r);
-}
-
-#define ASSERT_CHANGED(statement) \
-{ \
- changed = FALSE; \
- statement; \
- g_assert (changed); \
-}
-
-#define ASSERT_UNCHANGED(statement) \
-{ \
- changed = FALSE; \
- statement; \
- g_assert (!changed); \
-}
-
-static void
-test_connection_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
-
- connection = new_test_connection ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- /* Add new setting */
- ASSERT_CHANGED (nm_connection_add_setting (connection, nm_setting_vlan_new ()));
-
- /* Remove existing setting */
- ASSERT_CHANGED (nm_connection_remove_setting (connection, NM_TYPE_SETTING_VLAN));
-
- /* Remove non-existing setting */
- ASSERT_UNCHANGED (nm_connection_remove_setting (connection, NM_TYPE_SETTING_VLAN));
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_connection_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingConnection *s_con;
- gs_free char *uuid = NULL;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_con));
-
- ASSERT_CHANGED (g_object_set (s_con, NM_SETTING_CONNECTION_ID, "adfadfasdfaf", NULL));
-
- ASSERT_CHANGED (nm_setting_connection_add_permission (s_con, "user", "billsmith", NULL));
- ASSERT_CHANGED (nm_setting_connection_remove_permission (s_con, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (iter != NULL));
- ASSERT_UNCHANGED (nm_setting_connection_remove_permission (s_con, 1));
- g_test_assert_expected_messages ();
-
- uuid = nm_utils_uuid_generate ();
- ASSERT_CHANGED (nm_setting_connection_add_secondary (s_con, uuid));
- ASSERT_CHANGED (nm_setting_connection_remove_secondary (s_con, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_connection_remove_secondary (s_con, 1));
- g_test_assert_expected_messages ();
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_bond_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingBond *s_bond;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_bond = (NMSettingBond *) nm_setting_bond_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_bond));
-
- ASSERT_CHANGED (nm_setting_bond_add_option (s_bond, NM_SETTING_BOND_OPTION_DOWNDELAY, "10"));
- ASSERT_CHANGED (nm_setting_bond_remove_option (s_bond, NM_SETTING_BOND_OPTION_DOWNDELAY));
- ASSERT_UNCHANGED (nm_setting_bond_remove_option (s_bond, NM_SETTING_BOND_OPTION_UPDELAY));
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_ip4_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingIP4Config *s_ip4;
- NMIP4Address *addr;
- NMIP4Route *route;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_ip4));
-
- ASSERT_CHANGED (nm_setting_ip4_config_add_dns (s_ip4, 0x1122));
- ASSERT_CHANGED (nm_setting_ip4_config_remove_dns (s_ip4, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (i <= priv->dns->len));
- ASSERT_UNCHANGED (nm_setting_ip4_config_remove_dns (s_ip4, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_ip4_config_add_dns (s_ip4, 0x3344);
- ASSERT_CHANGED (nm_setting_ip4_config_clear_dns (s_ip4));
-
- ASSERT_CHANGED (nm_setting_ip4_config_add_dns_search (s_ip4, "foobar.com"));
- ASSERT_CHANGED (nm_setting_ip4_config_remove_dns_search (s_ip4, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_ip4_config_remove_dns_search (s_ip4, 1));
- g_test_assert_expected_messages ();
-
- ASSERT_CHANGED (nm_setting_ip4_config_add_dns_search (s_ip4, "foobar.com"));
- ASSERT_CHANGED (nm_setting_ip4_config_clear_dns_searches (s_ip4));
-
- addr = nm_ip4_address_new ();
- nm_ip4_address_set_address (addr, 0x2233);
- nm_ip4_address_set_prefix (addr, 24);
- ASSERT_CHANGED (nm_setting_ip4_config_add_address (s_ip4, addr));
- ASSERT_CHANGED (nm_setting_ip4_config_remove_address (s_ip4, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_ip4_config_remove_address (s_ip4, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_ip4_config_add_address (s_ip4, addr);
- ASSERT_CHANGED (nm_setting_ip4_config_clear_addresses (s_ip4));
-
- route = nm_ip4_route_new ();
- nm_ip4_route_set_dest (route, 0x2233);
- nm_ip4_route_set_prefix (route, 24);
-
- ASSERT_CHANGED (nm_setting_ip4_config_add_route (s_ip4, route));
- ASSERT_CHANGED (nm_setting_ip4_config_remove_route (s_ip4, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_ip4_config_remove_route (s_ip4, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_ip4_config_add_route (s_ip4, route);
- ASSERT_CHANGED (nm_setting_ip4_config_clear_routes (s_ip4));
-
- nm_ip4_address_unref (addr);
- nm_ip4_route_unref (route);
- g_object_unref (connection);
-}
-
-static void
-test_setting_ip6_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingIP6Config *s_ip6;
- NMIP6Address *addr;
- NMIP6Route *route;
- const struct in6_addr t = { { { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 } } };
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_ip6));
-
- ASSERT_CHANGED (nm_setting_ip6_config_add_dns (s_ip6, &t));
- ASSERT_CHANGED (nm_setting_ip6_config_remove_dns (s_ip6, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_ip6_config_remove_dns (s_ip6, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_ip6_config_add_dns (s_ip6, &t);
- ASSERT_CHANGED (nm_setting_ip6_config_clear_dns (s_ip6));
-
- ASSERT_CHANGED (nm_setting_ip6_config_add_dns_search (s_ip6, "foobar.com"));
- ASSERT_CHANGED (nm_setting_ip6_config_remove_dns_search (s_ip6, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_ip6_config_remove_dns_search (s_ip6, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_ip6_config_add_dns_search (s_ip6, "foobar.com");
- ASSERT_CHANGED (nm_setting_ip6_config_clear_dns_searches (s_ip6));
-
- addr = nm_ip6_address_new ();
- nm_ip6_address_set_address (addr, &t);
- nm_ip6_address_set_prefix (addr, 64);
-
- ASSERT_CHANGED (nm_setting_ip6_config_add_address (s_ip6, addr));
- ASSERT_CHANGED (nm_setting_ip6_config_remove_address (s_ip6, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_ip6_config_remove_address (s_ip6, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_ip6_config_add_address (s_ip6, addr);
- ASSERT_CHANGED (nm_setting_ip6_config_clear_addresses (s_ip6));
-
- route = nm_ip6_route_new ();
- nm_ip6_route_set_dest (route, &t);
- nm_ip6_route_set_prefix (route, 128);
-
- ASSERT_CHANGED (nm_setting_ip6_config_add_route (s_ip6, route));
- ASSERT_CHANGED (nm_setting_ip6_config_remove_route (s_ip6, 0));
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_ip6_config_remove_route (s_ip6, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_ip6_config_add_route (s_ip6, route);
- ASSERT_CHANGED (nm_setting_ip6_config_clear_routes (s_ip6));
-
- nm_ip6_address_unref (addr);
- nm_ip6_route_unref (route);
- g_object_unref (connection);
-}
-
-static void
-test_setting_vlan_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingVlan *s_vlan;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_vlan = (NMSettingVlan *) nm_setting_vlan_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_vlan));
-
- ASSERT_CHANGED (nm_setting_vlan_add_priority (s_vlan, NM_VLAN_INGRESS_MAP, 1, 3));
- ASSERT_CHANGED (nm_setting_vlan_remove_priority (s_vlan, NM_VLAN_INGRESS_MAP, 0));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (idx < g_slist_length (list)));
- ASSERT_UNCHANGED (nm_setting_vlan_remove_priority (s_vlan, NM_VLAN_INGRESS_MAP, 1));
- g_test_assert_expected_messages ();
- ASSERT_CHANGED (nm_setting_vlan_add_priority_str (s_vlan, NM_VLAN_INGRESS_MAP, "1:3"));
- ASSERT_CHANGED (nm_setting_vlan_clear_priorities (s_vlan, NM_VLAN_INGRESS_MAP));
-
- ASSERT_CHANGED (nm_setting_vlan_add_priority (s_vlan, NM_VLAN_EGRESS_MAP, 1, 3));
- ASSERT_CHANGED (nm_setting_vlan_remove_priority (s_vlan, NM_VLAN_EGRESS_MAP, 0));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (idx < g_slist_length (list)));
- ASSERT_UNCHANGED (nm_setting_vlan_remove_priority (s_vlan, NM_VLAN_EGRESS_MAP, 1));
- g_test_assert_expected_messages ();
- ASSERT_CHANGED (nm_setting_vlan_add_priority_str (s_vlan, NM_VLAN_EGRESS_MAP, "1:3"));
- ASSERT_CHANGED (nm_setting_vlan_clear_priorities (s_vlan, NM_VLAN_EGRESS_MAP));
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_vpn_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingVPN *s_vpn;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_vpn = (NMSettingVPN *) nm_setting_vpn_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_vpn));
-
- ASSERT_CHANGED (nm_setting_vpn_add_data_item (s_vpn, "foobar", "baz"));
- ASSERT_CHANGED (nm_setting_vpn_remove_data_item (s_vpn, "foobar"));
- ASSERT_UNCHANGED (nm_setting_vpn_remove_data_item (s_vpn, "not added"));
-
- ASSERT_CHANGED (nm_setting_vpn_add_secret (s_vpn, "foobar", "baz"));
- ASSERT_CHANGED (nm_setting_vpn_remove_secret (s_vpn, "foobar"));
- ASSERT_UNCHANGED (nm_setting_vpn_remove_secret (s_vpn, "not added"));
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_wired_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingWired *s_wired;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_wired = (NMSettingWired *) nm_setting_wired_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_wired));
-
- ASSERT_CHANGED (nm_setting_wired_add_s390_option (s_wired, "portno", "1"));
- ASSERT_CHANGED (nm_setting_wired_remove_s390_option (s_wired, "portno"));
- ASSERT_UNCHANGED (nm_setting_wired_remove_s390_option (s_wired, "layer2"));
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_wireless_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingWireless *s_wifi;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_wifi));
-
- ASSERT_CHANGED (nm_setting_wireless_add_seen_bssid (s_wifi, "00:11:22:33:44:55"));
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_wireless_security_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSettingWirelessSecurity *s_wsec;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_wsec));
-
- /* Protos */
- ASSERT_CHANGED (nm_setting_wireless_security_add_proto (s_wsec, "wpa"));
- ASSERT_CHANGED (nm_setting_wireless_security_remove_proto (s_wsec, 0));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_wireless_security_remove_proto (s_wsec, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_wireless_security_add_proto (s_wsec, "wep");
- ASSERT_CHANGED (nm_setting_wireless_security_clear_protos (s_wsec));
-
- /* Pairwise ciphers */
- ASSERT_CHANGED (nm_setting_wireless_security_add_pairwise (s_wsec, "tkip"));
- ASSERT_CHANGED (nm_setting_wireless_security_remove_pairwise (s_wsec, 0));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_wireless_security_remove_pairwise (s_wsec, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_wireless_security_add_pairwise (s_wsec, "tkip");
- ASSERT_CHANGED (nm_setting_wireless_security_clear_pairwise (s_wsec));
-
- /* Group ciphers */
- ASSERT_CHANGED (nm_setting_wireless_security_add_group (s_wsec, "ccmp"));
- ASSERT_CHANGED (nm_setting_wireless_security_remove_group (s_wsec, 0));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_wireless_security_remove_group (s_wsec, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_wireless_security_add_group (s_wsec, "tkip");
- ASSERT_CHANGED (nm_setting_wireless_security_clear_groups (s_wsec));
-
- /* WEP key secret flags */
- ASSERT_CHANGED (g_assert (nm_setting_set_secret_flags (NM_SETTING (s_wsec), "wep-key0", NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL)));
- ASSERT_CHANGED (g_assert (nm_setting_set_secret_flags (NM_SETTING (s_wsec), "wep-key1", NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL)));
- ASSERT_CHANGED (g_assert (nm_setting_set_secret_flags (NM_SETTING (s_wsec), "wep-key2", NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL)));
- ASSERT_CHANGED (g_assert (nm_setting_set_secret_flags (NM_SETTING (s_wsec), "wep-key3", NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL)));
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_802_1x_changed_signal (void)
-{
- NMConnection *connection;
- gboolean changed = FALSE;
- NMSetting8021x *s_8021x;
-
- connection = nm_connection_new ();
- g_signal_connect (connection,
- NM_CONNECTION_CHANGED,
- (GCallback) test_connection_changed_cb,
- &changed);
-
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_8021x));
-
- /* EAP methods */
- ASSERT_CHANGED (nm_setting_802_1x_add_eap_method (s_8021x, "tls"));
- ASSERT_CHANGED (nm_setting_802_1x_remove_eap_method (s_8021x, 0));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_802_1x_remove_eap_method (s_8021x, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_802_1x_add_eap_method (s_8021x, "ttls");
- ASSERT_CHANGED (nm_setting_802_1x_clear_eap_methods (s_8021x));
-
- /* alternate subject matches */
- ASSERT_CHANGED (nm_setting_802_1x_add_altsubject_match (s_8021x, "EMAIL:server@example.com"));
- ASSERT_CHANGED (nm_setting_802_1x_remove_altsubject_match (s_8021x, 0));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_802_1x_remove_altsubject_match (s_8021x, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_802_1x_add_altsubject_match (s_8021x, "EMAIL:server@example.com");
- ASSERT_CHANGED (nm_setting_802_1x_clear_altsubject_matches (s_8021x));
-
- /* phase2 alternate subject matches */
- ASSERT_CHANGED (nm_setting_802_1x_add_phase2_altsubject_match (s_8021x, "EMAIL:server@example.com"));
- ASSERT_CHANGED (nm_setting_802_1x_remove_phase2_altsubject_match (s_8021x, 0));
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (elt != NULL));
- ASSERT_UNCHANGED (nm_setting_802_1x_remove_phase2_altsubject_match (s_8021x, 1));
- g_test_assert_expected_messages ();
-
- nm_setting_802_1x_add_phase2_altsubject_match (s_8021x, "EMAIL:server@example.com");
- ASSERT_CHANGED (nm_setting_802_1x_clear_phase2_altsubject_matches (s_8021x));
-
- g_object_unref (connection);
-}
-
-static void
-test_setting_old_uuid (void)
-{
- GError *error = NULL;
- gs_unref_object NMSetting *setting = NULL;
- gboolean success;
-
- /* NetworkManager-0.9.4.0 generated 40-character UUIDs with no dashes,
- * like this one. Test that we maintain compatibility. */
- const char *uuid = "f43bec2cdd60e5da381ebb1eb1fa39f3cc52660c";
-
- setting = nm_setting_connection_new ();
- g_object_set (G_OBJECT (setting),
- NM_SETTING_CONNECTION_ID, "uuidtest",
- NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
- NULL);
-
- success = nm_setting_verify (NM_SETTING (setting), NULL, &error);
- g_assert_no_error (error);
- g_assert (success == TRUE);
-}
-
-/*
- * nm_connection_verify() modifies the connection by setting
- * the interface-name property to the virtual_iface_name of
- * the type specific settings.
- *
- * It would be preferable of verify() not to touch the connection,
- * but as it is now, stick with it and test it.
- **/
-static void
-test_connection_verify_sets_interface_name (void)
-{
- NMConnection *con;
- NMSettingConnection *s_con;
- NMSettingBond *s_bond;
- GError *error = NULL;
- gboolean success;
-
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
- g_object_set (G_OBJECT (s_con),
- NM_SETTING_CONNECTION_ID, "test1",
- NM_SETTING_CONNECTION_UUID, "22001632-bbb4-4616-b277-363dce3dfb5b",
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_BOND_SETTING_NAME,
- NULL);
- s_bond = (NMSettingBond *) nm_setting_bond_new ();
- g_object_set (G_OBJECT (s_bond),
- NM_SETTING_BOND_INTERFACE_NAME, "bond-x",
- NULL);
-
- con = nm_connection_new ();
- nm_connection_add_setting (con, NM_SETTING (s_con));
- nm_connection_add_setting (con, NM_SETTING (s_bond));
-
- g_assert_cmpstr (nm_connection_get_interface_name (con), ==, NULL);
-
- /* for backward compatibility, normalizes the interface name */
- success = nm_connection_verify (con, &error);
- g_assert (success && !error);
-
- g_assert_cmpstr (nm_connection_get_interface_name (con), ==, "bond-x");
-
- g_object_unref (con);
-}
-
-/*
- * Test normalization of interface-name
- **/
-static void
-test_connection_normalize_virtual_iface_name (void)
-{
- NMConnection *con;
- NMSettingConnection *s_con;
- NMSettingVlan *s_vlan;
- NMSetting *setting;
- GError *error = NULL;
- gboolean success;
- const char *IFACE_NAME = "iface";
- const char *IFACE_VIRT = "iface-X";
- gboolean modified = FALSE;
-
- con = nm_connection_new ();
-
- setting = nm_setting_ip4_config_new ();
- g_object_set (setting,
- NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
- NULL);
- nm_connection_add_setting (con, setting);
-
- setting = nm_setting_ip6_config_new ();
- g_object_set (setting,
- NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
- NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
- NULL);
- nm_connection_add_setting (con, setting);
-
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
- g_object_set (G_OBJECT (s_con),
- NM_SETTING_CONNECTION_ID, "test1",
- NM_SETTING_CONNECTION_UUID, "22001632-bbb4-4616-b277-363dce3dfb5b",
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_VLAN_SETTING_NAME,
- NM_SETTING_CONNECTION_INTERFACE_NAME, IFACE_NAME,
- NULL);
- s_vlan = (NMSettingVlan *) nm_setting_vlan_new ();
- g_object_set (G_OBJECT (s_vlan),
- NM_SETTING_VLAN_INTERFACE_NAME, IFACE_VIRT,
- NM_SETTING_VLAN_PARENT, "eth0",
- NULL);
-
- nm_connection_add_setting (con, NM_SETTING (s_con));
- nm_connection_add_setting (con, NM_SETTING (s_vlan));
-
- g_assert_cmpstr (nm_connection_get_interface_name (con), ==, IFACE_NAME);
- g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, IFACE_VIRT);
-
- /* for backward compatibility, normalizes the interface name */
- success = nm_connection_verify (con, &error);
- g_assert (success && !error);
-
- g_assert_cmpstr (nm_connection_get_interface_name (con), ==, IFACE_NAME);
- g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, IFACE_VIRT);
-
- success = nm_connection_normalize (con, NULL, &modified, &error);
- g_assert (success && !error);
- g_assert (modified);
-
- g_assert_cmpstr (nm_connection_get_interface_name (con), ==, IFACE_NAME);
- g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, IFACE_NAME);
-
- success = nm_connection_verify (con, &error);
- g_assert (success && !error);
-
- g_object_unref (con);
-}
-
-#if defined (__SANITIZE_ADDRESS__)
-static void
-test_libnm_linking (void)
-{
- g_test_skip ("Skipping test since address sanitizer is enabled");
-}
-#else /* __SANITIZE_ADDRESS__ */
-static void
-_test_libnm_linking_setup_child_process (gpointer user_data)
-{
- int val;
- struct rlimit limit;
-
- /* the child process is supposed to crash. We don't want it
- * to write a core dump. */
-
- val = getrlimit (RLIMIT_CORE, &limit);
- if (val == 0) {
- limit.rlim_cur = 0;
- val = setrlimit (RLIMIT_CORE, &limit);
- if (val == 0)
- return;
- }
- /* on error, do not crash or fail assertion. Instead just exit */
- exit (1);
-}
-
-static void
-test_libnm_linking (void)
-{
- char *argv[] = { "./test-libnm-linking", NULL };
- char *out, *err;
- int status;
- GError *error = NULL;
-
- g_spawn_sync (NM_BUILD_BUILDDIR"/libnm-util/tests",
- argv, NULL, 0 /*G_SPAWN_DEFAULT*/,
- _test_libnm_linking_setup_child_process, NULL,
- &out, &err, &status, &error);
- g_assert_no_error (error);
-
- g_assert (WIFSIGNALED (status));
-
- g_assert (strstr (err, "Mixing libnm") != NULL);
- g_free (out);
- g_free (err);
-}
-#endif /* __SANITIZE_ADDRESS__ */
-
-/*****************************************************************************/
-
-static void
-_test_uuid (const char *expected_uuid, const char *str)
-{
- gs_free char *uuid_test = NULL;
-
- g_assert (str);
-
- uuid_test = nm_utils_uuid_generate_from_string (str);
-
- g_assert (uuid_test);
- g_assert (nm_utils_is_uuid (uuid_test));
-
- if (strcmp (uuid_test, expected_uuid)) {
- g_error ("UUID test failed: text=%s, uuid=%s, expected=%s",
- str, uuid_test, expected_uuid);
- }
-}
-
-static void
-test_nm_utils_uuid_generate_from_string (void)
-{
- gs_free char *uuid_test = NULL;
-
- _test_uuid ("0cc175b9-c0f1-b6a8-31c3-99e269772661", "a");
- _test_uuid ("098f6bcd-4621-d373-cade-4e832627b4f6", "test");
- _test_uuid ("59c0547b-7fe2-1c15-2cce-e328e8bf6742", "/etc/NetworkManager/system-connections/em1");
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (s && *s));
- uuid_test = nm_utils_uuid_generate_from_string ("");
- g_assert (uuid_test == NULL);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_U_CRITICAL (NMTST_G_RETURN_MSG (s && *s));
- uuid_test = nm_utils_uuid_generate_from_string (NULL);
- g_assert (uuid_test == NULL);
- g_test_assert_expected_messages ();
-}
-
-/*****************************************************************************/
-
-NMTST_DEFINE ();
-
-int main (int argc, char **argv)
-{
- nmtst_init (&argc, &argv, TRUE);
-
- /* The tests */
- g_test_add_func ("/libnm/setting_vpn_items", test_setting_vpn_items);
- g_test_add_func ("/libnm/setting_vpn_update_secrets", test_setting_vpn_update_secrets);
- g_test_add_func ("/libnm/setting_vpn_modify_during_foreach", test_setting_vpn_modify_during_foreach);
- g_test_add_func ("/libnm/setting_ip6_config_old_address_array", test_setting_ip6_config_old_address_array);
- g_test_add_func ("/libnm/setting_gsm_apn_spaces", test_setting_gsm_apn_spaces);
- g_test_add_func ("/libnm/setting_gsm_apn_bad_chars", test_setting_gsm_apn_bad_chars);
- g_test_add_func ("/libnm/setting_gsm_apn_underscore", test_setting_gsm_apn_underscore);
- g_test_add_func ("/libnm/setting_gsm_without_number", test_setting_gsm_without_number);
- g_test_add_func ("/libnm/setting_to_hash_all", test_setting_to_hash_all);
- g_test_add_func ("/libnm/setting_to_hash_no_secrets", test_setting_to_hash_no_secrets);
- g_test_add_func ("/libnm/setting_to_hash_only_secrets", test_setting_to_hash_only_secrets);
- g_test_add_func ("/libnm/setting_compare_id", test_setting_compare_id);
- g_test_add_func ("/libnm/setting_compare_secrets", test_setting_compare_secrets);
- g_test_add_func ("/libnm/setting_compare_vpn_secrets", test_setting_compare_vpn_secrets);
- g_test_add_func ("/libnm/setting_old_uuid", test_setting_old_uuid);
-
- g_test_add_func ("/libnm/connection_to_hash_setting_name", test_connection_to_hash_setting_name);
- g_test_add_func ("/libnm/setting_new_from_hash", test_setting_new_from_hash);
- g_test_add_func ("/libnm/connection_replace_settings", test_connection_replace_settings);
- g_test_add_func ("/libnm/connection_replace_settings_from_connection", test_connection_replace_settings_from_connection);
- g_test_add_func ("/libnm/connection_new_from_hash", test_connection_new_from_hash);
- g_test_add_func ("/libnm/connection_verify_sets_interface_name", test_connection_verify_sets_interface_name);
- g_test_add_func ("/libnm/connection_normalize_virtual_iface_name", test_connection_normalize_virtual_iface_name);
-
- g_test_add_func ("/libnm/setting_connection_permissions_helpers", test_setting_connection_permissions_helpers);
- g_test_add_func ("/libnm/setting_connection_permissions_property", test_setting_connection_permissions_property);
-
- g_test_add_func ("/libnm/connection_compare_same", test_connection_compare_same);
- g_test_add_func ("/libnm/connection_compare_key_only_in_a", test_connection_compare_key_only_in_a);
- g_test_add_func ("/libnm/connection_compare_setting_only_in_a", test_connection_compare_setting_only_in_a);
- g_test_add_func ("/libnm/connection_compare_key_only_in_b", test_connection_compare_key_only_in_b);
- g_test_add_func ("/libnm/connection_compare_setting_only_in_b", test_connection_compare_setting_only_in_b);
-
- g_test_add_func ("/libnm/connection_diff_a_only", test_connection_diff_a_only);
- g_test_add_func ("/libnm/connection_diff_same", test_connection_diff_same);
- g_test_add_func ("/libnm/connection_diff_different", test_connection_diff_different);
- g_test_add_func ("/libnm/connection_diff_no_secrets", test_connection_diff_no_secrets);
- g_test_add_func ("/libnm/connection_diff_inferrable", test_connection_diff_inferrable);
- g_test_add_func ("/libnm/connection_good_base_types", test_connection_good_base_types);
- g_test_add_func ("/libnm/connection_bad_base_types", test_connection_bad_base_types);
-
- g_test_add_func ("/libnm/hwaddr_aton_ether_normal", test_hwaddr_aton_ether_normal);
- g_test_add_func ("/libnm/hwaddr_aton_ib_normal", test_hwaddr_aton_ib_normal);
- g_test_add_func ("/libnm/hwaddr_aton_no_leading_zeros", test_hwaddr_aton_no_leading_zeros);
- g_test_add_func ("/libnm/hwaddr_aton_malformed", test_hwaddr_aton_malformed);
- g_test_add_func ("/libnm/ip4_prefix_to_netmask", test_ip4_prefix_to_netmask);
- g_test_add_func ("/libnm/ip4_netmask_to_prefix", test_ip4_netmask_to_prefix);
-
- g_test_add_func ("/libnm/connection_changed_signal", test_connection_changed_signal);
- g_test_add_func ("/libnm/setting_connection_changed_signal", test_setting_connection_changed_signal);
- g_test_add_func ("/libnm/setting_bond_changed_signal", test_setting_bond_changed_signal);
- g_test_add_func ("/libnm/setting_ip4_changed_signal", test_setting_ip4_changed_signal);
- g_test_add_func ("/libnm/setting_ip6_changed_signal", test_setting_ip6_changed_signal);
- g_test_add_func ("/libnm/setting_vlan_changed_signal", test_setting_vlan_changed_signal);
- g_test_add_func ("/libnm/setting_vpn_changed_signal", test_setting_vpn_changed_signal);
- g_test_add_func ("/libnm/setting_wired_changed_signal", test_setting_wired_changed_signal);
- g_test_add_func ("/libnm/setting_wireless_changed_signal", test_setting_wireless_changed_signal);
- g_test_add_func ("/libnm/setting_wireless_security_changed_signal", test_setting_wireless_security_changed_signal);
- g_test_add_func ("/libnm/setting_802_1x_changed_signal", test_setting_802_1x_changed_signal);
-
- g_test_add_func ("/libnm/libnm_linking", test_libnm_linking);
-
- g_test_add_func ("/libnm/nm_utils_uuid_generate_from_string", test_nm_utils_uuid_generate_from_string);
-
- return g_test_run ();
-}
-
diff --git a/libnm-util/tests/test-libnm-linking.c b/libnm-util/tests/test-libnm-linking.c
deleted file mode 100644
index 0e143e739d..0000000000
--- a/libnm-util/tests/test-libnm-linking.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2014 Red Hat, Inc.
- *
- */
-
-#include "nm-default.h"
-
-#include "nm-utils.h"
-
-extern GType nm_state_get_type (void);
-
-int
-main (int argc, char **argv)
-{
- /* If we reach main(), then the test has failed. */
- g_printerr ("libnm/libnm-util constructor failed to detect symbol mixing\n");
-
- /* This is just to ensure that both libnm.so and libnm-util.so get pulled
- * in; libnm-util doesn't have "nm_state_get_type" and libnm doesn't have
- * "nm_utils_slist_free". (We intentionally choose different symbols than the
- * ones that the libraries check for.)
- */
- nm_state_get_type ();
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- nm_utils_slist_free (NULL, g_free);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- g_assert_not_reached ();
-}
diff --git a/libnm-util/tests/test-secrets.c b/libnm-util/tests/test-secrets.c
deleted file mode 100644
index 43c206ff76..0000000000
--- a/libnm-util/tests/test-secrets.c
+++ /dev/null
@@ -1,684 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2011 Red Hat, Inc.
- *
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-utils.h"
-
-#include "nm-setting-connection.h"
-#include "nm-setting-wired.h"
-#include "nm-setting-8021x.h"
-#include "nm-setting-ip4-config.h"
-#include "nm-setting-wireless.h"
-#include "nm-setting-wireless-security.h"
-#include "nm-setting-cdma.h"
-#include "nm-setting-gsm.h"
-#include "nm-setting-ppp.h"
-#include "nm-setting-pppoe.h"
-#include "nm-setting-vpn.h"
-
-#include "nm-utils/nm-test-utils.h"
-
-#define TEST_CERT_DIR NM_BUILD_SRCDIR"/libnm-core/tests/certs"
-#define TEST_NEED_SECRETS_EAP_TLS_CA_CERT TEST_CERT_DIR "/test_ca_cert.pem"
-#define TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT TEST_CERT_DIR "/test_key_and_cert.pem"
-#define TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY TEST_CERT_DIR "/test_key_and_cert.pem"
-
-static void
-_assert_hints_has (GPtrArray *hints, const char *item)
-{
- guint i;
- guint found = 0;
-
- g_assert (hints);
- g_assert (item);
- for (i = 0; i < hints->len; i++) {
- g_assert (hints->pdata[i]);
- if (!strcmp (item, hints->pdata[i]))
- found++;
- }
- g_assert_cmpint (found, ==, 1);
-}
-
-static NMConnection *
-make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
-{
- NMConnection *connection;
- NMSettingConnection *s_con;
- NMSetting8021x *s_8021x;
- NMSettingWired *s_wired;
- NMSettingIP4Config *s_ip4;
- char *uuid;
- gboolean success;
- GError *error = NULL;
-
- connection = nm_connection_new ();
-
- /* Connection setting */
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_con));
-
- uuid = nm_utils_uuid_generate ();
- g_object_set (s_con,
- NM_SETTING_CONNECTION_ID, "Test Need TLS Secrets",
- NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
- NULL);
- g_free (uuid);
-
- /* Wired setting */
- s_wired = (NMSettingWired *) nm_setting_wired_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_wired));
-
- /* Wireless security setting */
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_8021x));
-
- g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL);
-
- nm_setting_802_1x_add_eap_method (s_8021x, "tls");
-
- success = nm_setting_802_1x_set_ca_cert (s_8021x,
- TEST_NEED_SECRETS_EAP_TLS_CA_CERT,
- scheme,
- NULL,
- &error);
- nmtst_assert_success (success, error);
-
- success = nm_setting_802_1x_set_client_cert (s_8021x,
- TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT,
- scheme,
- NULL,
- &error);
- nmtst_assert_success (success, error);
-
- success = nm_setting_802_1x_set_private_key (s_8021x,
- TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY,
- "test",
- scheme,
- NULL,
- &error);
- nmtst_assert_success (success, error);
-
- /* IP4 setting */
- s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_ip4));
-
- g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
-
- nmtst_assert_connection_verifies_and_normalizable (connection);
-
- return connection;
-}
-
-static void
-test_need_tls_secrets_path (void)
-{
- NMConnection *connection;
- const char *setting_name;
- GPtrArray *hints = NULL;
-
- connection = make_tls_connection ("need-tls-secrets-path-key", NM_SETTING_802_1X_CK_SCHEME_PATH);
-
- /* Ensure we don't need any secrets since we just set up the connection */
- setting_name = nm_connection_need_secrets (connection, &hints);
- g_assert (!setting_name);
- g_assert (!hints);
-
- /* Connection is good; clear secrets and ensure private key password is then required */
- nm_connection_clear_secrets (connection);
-
- hints = NULL;
- setting_name = nm_connection_need_secrets (connection, &hints);
- g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
- _assert_hints_has (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
-
- g_ptr_array_free (hints, TRUE);
- g_object_unref (connection);
-}
-
-static void
-test_need_tls_secrets_blob (void)
-{
- NMConnection *connection;
- const char *setting_name;
- GPtrArray *hints = NULL;
-
- connection = make_tls_connection ("need-tls-secrets-blob-key", NM_SETTING_802_1X_CK_SCHEME_BLOB);
-
- /* Ensure we don't need any secrets since we just set up the connection */
- setting_name = nm_connection_need_secrets (connection, &hints);
- g_assert (!setting_name);
- g_assert (!hints);
-
- /* Clear secrets and ensure password is again required */
- nm_connection_clear_secrets (connection);
-
- hints = NULL;
- setting_name = nm_connection_need_secrets (connection, &hints);
- g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
- _assert_hints_has (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
-
- g_ptr_array_free (hints, TRUE);
- g_object_unref (connection);
-}
-
-static NMConnection *
-make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
-{
- NMConnection *connection;
- NMSettingConnection *s_con;
- NMSetting8021x *s_8021x;
- NMSettingWired *s_wired;
- NMSettingIP4Config *s_ip4;
- char *uuid;
- gboolean success;
- GError *error = NULL;
-
- connection = nm_connection_new ();
-
- /* Connection setting */
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_con));
-
- uuid = nm_utils_uuid_generate ();
- g_object_set (s_con,
- NM_SETTING_CONNECTION_ID, "Test Need TLS Secrets",
- NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
- NULL);
- g_free (uuid);
-
- /* Wired setting */
- s_wired = (NMSettingWired *) nm_setting_wired_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_wired));
-
- /* Wireless security setting */
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_8021x));
-
- g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, "blahblah", NULL);
- g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL);
-
- nm_setting_802_1x_add_eap_method (s_8021x, "ttls");
- g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, "tls", NULL);
-
- success = nm_setting_802_1x_set_phase2_ca_cert (s_8021x,
- TEST_NEED_SECRETS_EAP_TLS_CA_CERT,
- scheme,
- NULL,
- &error);
- nmtst_assert_success (success, error);
-
- success = nm_setting_802_1x_set_phase2_client_cert (s_8021x,
- TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT,
- scheme,
- NULL,
- &error);
- nmtst_assert_success (success, error);
-
- success = nm_setting_802_1x_set_phase2_private_key (s_8021x,
- TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY,
- "test",
- scheme,
- NULL,
- &error);
- nmtst_assert_success (success, error);
-
- /* IP4 setting */
- s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_ip4));
-
- g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
-
- nmtst_assert_connection_verifies_and_normalizable (connection);
-
- return connection;
-}
-
-static void
-test_need_tls_phase2_secrets_path (void)
-{
- NMConnection *connection;
- 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);
-
- /* Ensure we don't need any secrets since we just set up the connection */
- setting_name = nm_connection_need_secrets (connection, &hints);
- g_assert (!setting_name);
- g_assert (!hints);
-
- /* Connection is good; clear secrets and ensure private key password is then required */
- nm_connection_clear_secrets (connection);
-
- hints = NULL;
- setting_name = nm_connection_need_secrets (connection, &hints);
- g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
- _assert_hints_has (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
-
- g_ptr_array_free (hints, TRUE);
- g_object_unref (connection);
-}
-
-static void
-test_need_tls_phase2_secrets_blob (void)
-{
- NMConnection *connection;
- 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);
-
- /* Ensure we don't need any secrets since we just set up the connection */
- setting_name = nm_connection_need_secrets (connection, &hints);
- g_assert (!setting_name);
- g_assert (!hints);
-
- /* Connection is good; clear secrets and ensure private key password is then required */
- nm_connection_clear_secrets (connection);
-
- hints = NULL;
- setting_name = nm_connection_need_secrets (connection, &hints);
- g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
- _assert_hints_has (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
-
- g_ptr_array_free (hints, TRUE);
- g_object_unref (connection);
-}
-
-static NMConnection *
-wifi_connection_new (void)
-{
- NMConnection *connection;
- NMSettingConnection *s_con;
- NMSettingWireless *s_wifi;
- NMSettingWirelessSecurity *s_wsec;
- unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 };
- char *uuid;
- GByteArray *ssid;
-
- connection = nm_connection_new ();
- g_assert (connection);
-
- /* Connection setting */
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
- g_assert (s_con);
-
- uuid = nm_utils_uuid_generate ();
- g_object_set (s_con,
- NM_SETTING_CONNECTION_ID, "Test Wireless",
- NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
- NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME,
- NULL);
- g_free (uuid);
- nm_connection_add_setting (connection, NM_SETTING (s_con));
-
- /* Wireless setting */
- s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
- g_assert (s_wifi);
-
- ssid = g_byte_array_sized_new (sizeof (tmpssid));
- g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
- g_object_set (s_wifi,
- NM_SETTING_WIRELESS_SSID, ssid,
- NULL);
- g_byte_array_free (ssid, TRUE);
- nm_connection_add_setting (connection, NM_SETTING (s_wifi));
-
- /* Wifi security */
- s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
- g_assert (s_wsec);
-
- g_object_set (G_OBJECT (s_wsec),
- NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none",
- NULL);
- nm_connection_add_setting (connection, NM_SETTING (s_wsec));
-
- return connection;
-}
-
-static void
-value_destroy (gpointer data)
-{
- GValue *value = (GValue *) data;
-
- g_value_unset (value);
- g_slice_free (GValue, value);
-}
-
-static GValue *
-string_to_gvalue (const char *str)
-{
- GValue *val = g_slice_new0 (GValue);
-
- g_value_init (val, G_TYPE_STRING);
- g_value_set_string (val, str);
- return val;
-}
-
-static GValue *
-uint_to_gvalue (guint32 i)
-{
- GValue *val;
-
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_UINT);
- g_value_set_uint (val, i);
- return val;
-}
-
-static void
-test_update_secrets_wifi_single_setting (void)
-{
- NMConnection *connection;
- NMSettingWirelessSecurity *s_wsec;
- GHashTable *secrets;
- GError *error = NULL;
- gboolean success;
- const char *wepkey = "11111111111111111111111111";
- const char *tmp;
-
- /* Test update with a hashed setting of 802-11-wireless secrets */
-
- connection = wifi_connection_new ();
-
- /* Build up the secrets hash */
- secrets = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, value_destroy);
- g_hash_table_insert (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey));
- g_hash_table_insert (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, uint_to_gvalue (NM_WEP_KEY_TYPE_KEY));
-
- success = nm_connection_update_secrets (connection,
- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
- secrets,
- &error);
- g_assert_no_error (error);
- g_assert (success);
-
- /* Make sure the secret is now in the connection */
- s_wsec = nm_connection_get_setting_wireless_security (connection);
- g_assert (s_wsec);
- tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 0);
- g_assert_cmpstr (tmp, ==, wepkey);
-
- g_hash_table_unref (secrets);
- g_object_unref (connection);
-}
-
-static void
-test_update_secrets_wifi_full_hash (void)
-{
- NMConnection *connection;
- NMSettingWirelessSecurity *s_wsec;
- GHashTable *secrets, *all;
- GError *error = NULL;
- gboolean success;
- const char *wepkey = "11111111111111111111111111";
- const char *tmp;
-
- /* Test update with a hashed connection containing only 802-11-wireless
- * setting and secrets.
- */
-
- connection = wifi_connection_new ();
-
- /* Build up the secrets hash */
- all = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_hash_table_destroy);
- secrets = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, value_destroy);
- g_hash_table_insert (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey));
- g_hash_table_insert (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, uint_to_gvalue (NM_WEP_KEY_TYPE_KEY));
- g_hash_table_insert (all, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, secrets);
-
- success = nm_connection_update_secrets (connection,
- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
- all,
- &error);
- g_assert_no_error (error);
- g_assert (success);
-
- /* Make sure the secret is now in the connection */
- s_wsec = nm_connection_get_setting_wireless_security (connection);
- g_assert (s_wsec);
- tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 0);
- g_assert_cmpstr (tmp, ==, wepkey);
-
- g_hash_table_unref (all);
- g_object_unref (connection);
-}
-
-static void
-test_update_secrets_wifi_bad_setting_name (void)
-{
- NMConnection *connection;
- GHashTable *secrets;
- GError *error = NULL;
- gboolean success;
- const char *wepkey = "11111111111111111111111111";
-
- /* Test that passing an invalid setting name to
- * nm_connection_update_secrets() fails with the correct error.
- */
-
- connection = wifi_connection_new ();
-
- /* Build up the secrets hash */
- secrets = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, value_destroy);
- g_hash_table_insert (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey));
- g_hash_table_insert (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, uint_to_gvalue (NM_WEP_KEY_TYPE_KEY));
-
- success = nm_connection_update_secrets (connection,
- "asdfasdfasdfasf",
- secrets,
- &error);
- g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND);
- g_assert (success == FALSE);
-
- g_clear_error (&error);
- g_hash_table_unref (secrets);
- g_object_unref (connection);
-}
-
-static void
-test_update_secrets_whole_connection (void)
-{
- NMConnection *connection;
- NMSettingWirelessSecurity *s_wsec;
- GHashTable *secrets, *wsec_hash;
- GError *error = NULL;
- gboolean success;
- const char *wepkey = "11111111111111111111111111";
-
- /* Test calling nm_connection_update_secrets() with an entire hashed
- * connection including non-secrets.
- */
-
- connection = wifi_connection_new ();
-
- /* Build up the secrets hash */
- secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
- wsec_hash = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
- g_assert (wsec_hash);
- g_hash_table_insert (wsec_hash, g_strdup (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), string_to_gvalue (wepkey));
-
- success = nm_connection_update_secrets (connection, NULL, secrets, &error);
- g_assert_no_error (error);
- g_assert (success == TRUE);
-
- s_wsec = nm_connection_get_setting_wireless_security (connection);
- g_assert (s_wsec);
- g_assert_cmpstr (nm_setting_wireless_security_get_wep_key (s_wsec, 0), ==, wepkey);
-
- g_hash_table_unref (secrets);
- g_object_unref (connection);
-}
-
-static void
-test_update_secrets_whole_connection_empty_hash (void)
-{
- NMConnection *connection;
- GHashTable *secrets;
- GError *error = NULL;
- gboolean success;
-
- /* Test that updating secrets with an empty hash returns success */
-
- connection = wifi_connection_new ();
- secrets = g_hash_table_new (g_str_hash, g_str_equal);
- success = nm_connection_update_secrets (connection, NULL, secrets, &error);
- g_assert_no_error (error);
- g_assert (success == TRUE);
- g_object_unref (connection);
- g_hash_table_unref (secrets);
-}
-
-static void
-test_update_secrets_whole_connection_bad_setting (void)
-{
- NMConnection *connection;
- GHashTable *secrets, *wsec_hash;
- GError *error = NULL;
- gboolean success;
- const char *wepkey = "11111111111111111111111111";
-
- /* Test that sending a hashed connection containing an invalid setting
- * name fails with the right error.
- */
-
- connection = wifi_connection_new ();
-
- /* Build up the secrets hash */
- secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
- wsec_hash = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
- g_assert (wsec_hash);
- g_hash_table_insert (wsec_hash, g_strdup (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), string_to_gvalue (wepkey));
-
- /* Steal the wsec setting hash so it's not deallocated, and stuff it back
- * in with a different name so we ensure libnm-util is returning the right
- * error when it finds an entry in the connection hash that doesn't match
- * any setting in the connection.
- */
- g_hash_table_ref (wsec_hash);
- g_hash_table_remove (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
- g_hash_table_insert (secrets, g_strdup ("asdfasdfasdfasdf"), wsec_hash);
-
- success = nm_connection_update_secrets (connection, NULL, secrets, &error);
- g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND);
- g_assert (success == FALSE);
-
- g_clear_error (&error);
- g_hash_table_destroy (secrets);
- g_object_unref (connection);
-}
-
-static void
-test_update_secrets_whole_connection_empty_base_setting (void)
-{
- NMConnection *connection;
- GHashTable *secrets;
- GError *error = NULL;
- gboolean success;
-
- /* Test that a hashed connection which does not have any hashed secrets
- * for the requested setting returns success.
- */
-
- connection = wifi_connection_new ();
- secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ONLY_SECRETS);
- g_assert_cmpint (g_hash_table_size (secrets), ==, 3);
- g_assert (g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SETTING_NAME));
-
- success = nm_connection_update_secrets (connection,
- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
- secrets,
- &error);
- g_assert_no_error (error);
- g_assert (success);
-
- g_hash_table_destroy (secrets);
- g_object_unref (connection);
-}
-
-static void
-test_update_secrets_null_setting_name_with_setting_hash (void)
-{
- NMConnection *connection;
- GHashTable *secrets;
- GError *error = NULL;
- gboolean success;
- const char *wepkey = "11111111111111111111111111";
-
- /* Ensure that a NULL setting name and only a hashed setting fails */
-
- connection = wifi_connection_new ();
-
- secrets = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, value_destroy);
- g_hash_table_insert (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey));
- g_hash_table_insert (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, uint_to_gvalue (NM_WEP_KEY_TYPE_KEY));
-
- success = nm_connection_update_secrets (connection, NULL, secrets, &error);
- g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND);
- g_assert (!success);
-
- g_clear_error (&error);
- g_hash_table_destroy (secrets);
- g_object_unref (connection);
-}
-
-NMTST_DEFINE ();
-
-int main (int argc, char **argv)
-{
- GError *error = NULL;
- gboolean success;
-
- nmtst_init (&argc, &argv, TRUE);
-
- success = nm_utils_init (&error);
- g_assert_no_error (error);
- g_assert (success);
-
- /* The tests */
- g_test_add_func ("/libnm/need_tls_secrets_path", test_need_tls_secrets_path);
- g_test_add_func ("/libnm/need_tls_secrets_blob", test_need_tls_secrets_blob);
- g_test_add_func ("/libnm/need_tls_phase2_secrets_path", test_need_tls_phase2_secrets_path);
- g_test_add_func ("/libnm/need_tls_phase2_secrets_blob", test_need_tls_phase2_secrets_blob);
-
- g_test_add_func ("/libnm/update_secrets_wifi_single_setting", test_update_secrets_wifi_single_setting);
- g_test_add_func ("/libnm/update_secrets_wifi_full_hash", test_update_secrets_wifi_full_hash);
- g_test_add_func ("/libnm/update_secrets_wifi_bad_setting_name", test_update_secrets_wifi_bad_setting_name);
-
- g_test_add_func ("/libnm/update_secrets_whole_connection", test_update_secrets_whole_connection);
- g_test_add_func ("/libnm/update_secrets_whole_connection_empty_hash", test_update_secrets_whole_connection_empty_hash);
- g_test_add_func ("/libnm/update_secrets_whole_connection_bad_setting", test_update_secrets_whole_connection_bad_setting);
- g_test_add_func ("/libnm/update_secrets_whole_connection_empty_base_setting", test_update_secrets_whole_connection_empty_base_setting);
- g_test_add_func ("/libnm/update_secrets_null_setting_name_with_setting_hash", test_update_secrets_null_setting_name_with_setting_hash);
-
- return g_test_run ();
-}
-
diff --git a/libnm-util/tests/test-setting-8021x.c b/libnm-util/tests/test-setting-8021x.c
deleted file mode 100644
index 373b2a757d..0000000000
--- a/libnm-util/tests/test-setting-8021x.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2011 Red Hat, Inc.
- *
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-utils.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-8021x.h"
-
-#include "nm-utils/nm-test-utils.h"
-
-#define TEST_CERT_DIR NM_BUILD_SRCDIR"/libnm-core/tests/certs"
-
-static void
-compare_blob_data (const char *test,
- const char *key_path,
- const GByteArray *key)
-{
- char *contents = NULL;
- gsize len = 0;
- GError *error = NULL;
- gboolean success;
-
- g_assert (key && key->len > 0);
-
- success = g_file_get_contents (key_path, &contents, &len, &error);
- nmtst_assert_success (success, error);
-
- g_assert_cmpmem (contents, len, key->data, key->len);
- g_free (contents);
-}
-
-#define SCHEME_PATH "file://"
-
-static void
-check_scheme_path (GByteArray *value, const char *path)
-{
- guint8 *p;
-
- g_assert (value);
-
- p = value->data;
- g_assert (memcmp (p, SCHEME_PATH, strlen (SCHEME_PATH)) == 0);
- p += strlen (SCHEME_PATH);
- g_assert (memcmp (p, path, strlen (path)) == 0);
- p += strlen (path);
- g_assert (*p == '\0');
-}
-
-static void
-test_private_key_import (const char *path,
- const char *password,
- NMSetting8021xCKScheme scheme)
-{
- NMSetting8021x *s_8021x;
- gboolean success;
- NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- NMSetting8021xCKFormat tmp_fmt;
- GError *error = NULL;
- GByteArray *tmp_key = NULL, *client_cert = NULL;
- const char *pw;
-
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- g_assert (s_8021x);
-
- success = nm_setting_802_1x_set_private_key (s_8021x,
- path,
- password,
- scheme,
- &format,
- &error);
- nmtst_assert_success (success, error);
- g_assert (format != NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
- tmp_fmt = nm_setting_802_1x_get_private_key_format (s_8021x);
- g_assert (tmp_fmt == format);
-
- /* Make sure the password is what we expect */
- pw = nm_setting_802_1x_get_private_key_password (s_8021x);
- g_assert (pw);
- g_assert_cmpstr (pw, ==, password);
-
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
- tmp_key = (GByteArray *) nm_setting_802_1x_get_private_key_blob (s_8021x);
- compare_blob_data ("private-key-import", path, tmp_key);
- } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) {
- g_object_get (s_8021x, NM_SETTING_802_1X_PRIVATE_KEY, &tmp_key, NULL);
- check_scheme_path (tmp_key, path);
- g_byte_array_free (tmp_key, TRUE);
- } else
- g_assert_not_reached ();
-
- /* If it's PKCS#12 ensure the client cert is the same value */
- if (format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
- g_object_get (s_8021x, NM_SETTING_802_1X_PRIVATE_KEY, &tmp_key, NULL);
- g_assert (tmp_key);
-
- g_object_get (s_8021x, NM_SETTING_802_1X_CLIENT_CERT, &client_cert, NULL);
- g_assert (client_cert);
-
- /* make sure they are the same */
- g_assert_cmpmem (tmp_key->data, tmp_key->len, client_cert->data, client_cert->len);
-
- g_byte_array_free (tmp_key, TRUE);
- g_byte_array_free (client_cert, TRUE);
- }
-
- g_object_unref (s_8021x);
-}
-
-static void
-test_phase2_private_key_import (const char *path,
- const char *password,
- NMSetting8021xCKScheme scheme)
-{
- NMSetting8021x *s_8021x;
- gboolean success;
- NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- NMSetting8021xCKFormat tmp_fmt;
- GError *error = NULL;
- GByteArray *tmp_key = NULL, *client_cert = NULL;
- const char *pw;
-
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- g_assert (s_8021x);
-
- success = nm_setting_802_1x_set_phase2_private_key (s_8021x,
- path,
- password,
- scheme,
- &format,
- &error);
- nmtst_assert_success (success, error);
- g_assert (format != NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
- tmp_fmt = nm_setting_802_1x_get_phase2_private_key_format (s_8021x);
- g_assert (tmp_fmt == format);
-
- /* Make sure the password is what we expect */
- pw = nm_setting_802_1x_get_phase2_private_key_password (s_8021x);
- g_assert (pw);
- g_assert_cmpstr (pw, ==, password);
-
- if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
- tmp_key = (GByteArray *) nm_setting_802_1x_get_phase2_private_key_blob (s_8021x);
- compare_blob_data ("phase2-private-key-import", path, tmp_key);
- } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) {
- g_object_get (s_8021x, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &tmp_key, NULL);
- check_scheme_path (tmp_key, path);
- g_byte_array_free (tmp_key, TRUE);
- } else
- g_assert_not_reached ();
-
- /* If it's PKCS#12 ensure the client cert is the same value */
- if (format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
- g_object_get (s_8021x, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &tmp_key, NULL);
- g_assert (tmp_key);
-
- g_object_get (s_8021x, NM_SETTING_802_1X_PHASE2_CLIENT_CERT, &client_cert, NULL);
- g_assert (client_cert);
-
- /* make sure they are the same */
- g_assert_cmpmem (tmp_key->data, tmp_key->len, client_cert->data, client_cert->len);
-
- g_byte_array_free (tmp_key, TRUE);
- g_byte_array_free (client_cert, TRUE);
- }
-
- g_object_unref (s_8021x);
-}
-
-static void
-test_wrong_password_keeps_data (const char *path, const char *password)
-{
- NMSetting8021x *s_8021x;
- gboolean success;
- NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- GError *error = NULL;
- const char *pw;
-
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- g_assert (s_8021x);
-
- success = nm_setting_802_1x_set_private_key (s_8021x,
- path,
- password,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- &format,
- &error);
- nmtst_assert_success (success, error);
- g_assert (format != NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
-
- /* Now try to set it to something that's not a certificate */
- format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- success = nm_setting_802_1x_set_private_key (s_8021x,
- "Makefile.am",
- password,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- &format,
- &error);
- nmtst_assert_no_success (success, error);
- g_assert (format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
- g_clear_error (&error);
-
- /* Make sure the password hasn't changed */
- pw = nm_setting_802_1x_get_private_key_password (s_8021x);
- g_assert (pw);
- g_assert_cmpstr (pw, ==, password);
-
- g_object_unref (s_8021x);
-}
-
-static void
-test_clear_private_key (const char *path, const char *password)
-{
- NMSetting8021x *s_8021x;
- gboolean success;
- NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- GError *error = NULL;
- const char *pw;
-
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- g_assert (s_8021x);
-
- success = nm_setting_802_1x_set_private_key (s_8021x,
- path,
- password,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- &format,
- &error);
- nmtst_assert_success (success, error);
- g_assert (format != NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
-
- /* Make sure the password is what we expect */
- pw = nm_setting_802_1x_get_private_key_password (s_8021x);
- g_assert (pw);
- g_assert_cmpstr (pw, ==, password);
-
- /* Now clear it */
- success = nm_setting_802_1x_set_private_key (s_8021x,
- NULL,
- NULL,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- NULL,
- &error);
- nmtst_assert_success (success, error);
-
- /* Ensure the password is also now clear */
- g_assert (!nm_setting_802_1x_get_private_key_password (s_8021x));
-
- g_object_unref (s_8021x);
-}
-
-static void
-test_wrong_phase2_password_keeps_data (const char *path, const char *password)
-{
- NMSetting8021x *s_8021x;
- gboolean success;
- NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- GError *error = NULL;
- const char *pw;
-
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- g_assert (s_8021x);
-
- success = nm_setting_802_1x_set_phase2_private_key (s_8021x,
- path,
- password,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- &format,
- &error);
- nmtst_assert_success (success, error);
- g_assert (format != NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
-
- /* Now try to set it to something that's not a certificate */
- format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- success = nm_setting_802_1x_set_phase2_private_key (s_8021x,
- "Makefile.am",
- password,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- &format,
- &error);
- nmtst_assert_no_success (success, error);
- g_assert (format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
- g_clear_error (&error);
-
- /* Make sure the password hasn't changed */
- pw = nm_setting_802_1x_get_phase2_private_key_password (s_8021x);
- g_assert (pw);
- g_assert_cmpstr (pw, ==, password);
-
- g_object_unref (s_8021x);
-}
-
-static void
-test_clear_phase2_private_key (const char *path, const char *password)
-{
- NMSetting8021x *s_8021x;
- gboolean success;
- NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- GError *error = NULL;
- const char *pw;
-
- s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
- g_assert (s_8021x);
-
- success = nm_setting_802_1x_set_phase2_private_key (s_8021x,
- path,
- password,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- &format,
- &error);
- nmtst_assert_success (success, error);
- g_assert (format != NM_SETTING_802_1X_CK_FORMAT_UNKNOWN);
-
- /* Make sure the password is what we expect */
- pw = nm_setting_802_1x_get_phase2_private_key_password (s_8021x);
- g_assert (pw);
- g_assert_cmpstr (pw, ==, password);
-
- /* Now clear it */
- success = nm_setting_802_1x_set_phase2_private_key (s_8021x,
- NULL,
- NULL,
- NM_SETTING_802_1X_CK_SCHEME_BLOB,
- NULL,
- &error);
- nmtst_assert_success (success, error);
-
- /* Ensure the password is also now clear */
- g_assert (!nm_setting_802_1x_get_phase2_private_key_password (s_8021x));
-
- g_object_unref (s_8021x);
-}
-
-static void
-do_8021x_test (gconstpointer test_data)
-{
- char **parts, *path, *password;
-
- parts = g_strsplit ((const char *) test_data, ", ", -1);
- g_assert_cmpint (g_strv_length (parts), ==, 2);
-
- path = g_build_filename (TEST_CERT_DIR, parts[0], NULL);
- password = parts[1];
-
- /* Test phase1 and phase2 path scheme */
- test_private_key_import (path, password, NM_SETTING_802_1X_CK_SCHEME_PATH);
- test_phase2_private_key_import (path, password, NM_SETTING_802_1X_CK_SCHEME_PATH);
-
- /* Test phase1 and phase2 blob scheme */
- test_private_key_import (path, password, NM_SETTING_802_1X_CK_SCHEME_BLOB);
- test_phase2_private_key_import (path, password, NM_SETTING_802_1X_CK_SCHEME_BLOB);
-
- /* Test that using a wrong password does not change existing data */
- test_wrong_password_keeps_data (path, password);
- test_wrong_phase2_password_keeps_data (path, password);
-
- /* Test clearing the private key */
- test_clear_private_key (path, password);
- test_clear_phase2_private_key (path, password);
-
- g_free (path);
- g_strfreev (parts);
-}
-
-NMTST_DEFINE ();
-
-int
-main (int argc, char **argv)
-{
- nmtst_init (&argc, &argv, TRUE);
-
- g_test_add_data_func ("/libnm-utils/setting-8021x/key-and-cert",
- "test_key_and_cert.pem, test",
- do_8021x_test);
- g_test_add_data_func ("/libnm-utils/setting-8021x/key-only",
- "test-key-only.pem, test",
- do_8021x_test);
- g_test_add_data_func ("/libnm-utils/setting-8021x/pkcs8-enc-key",
- "pkcs8-enc-key.pem, 1234567890",
- do_8021x_test);
- g_test_add_data_func ("/libnm-utils/setting-8021x/pkcs12",
- "test-cert.p12, test",
- do_8021x_test);
-
- return g_test_run ();
-}
-
diff --git a/libnm-util/tests/test-setting-dcb.c b/libnm-util/tests/test-setting-dcb.c
deleted file mode 100644
index eb7113c32e..0000000000
--- a/libnm-util/tests/test-setting-dcb.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2013 Red Hat, Inc.
- *
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-utils.h"
-#include "nm-default.h"
-#include "nm-setting-dcb.h"
-
-#include "nm-utils/nm-test-utils.h"
-
-#define DCB_FLAGS_ALL (NM_SETTING_DCB_FLAG_ENABLE | \
- NM_SETTING_DCB_FLAG_ADVERTISE | \
- NM_SETTING_DCB_FLAG_WILLING)
-
-static void
-test_dcb_flags_valid (void)
-{
- gs_unref_object NMSettingDcb *s_dcb = NULL;
- GError *error = NULL;
- gboolean success;
- guint i;
-
- s_dcb = (NMSettingDcb *) nm_setting_dcb_new ();
- g_assert (s_dcb);
-
- g_assert_cmpint (nm_setting_dcb_get_app_fcoe_flags (s_dcb), ==, 0);
- g_assert_cmpint (nm_setting_dcb_get_app_iscsi_flags (s_dcb), ==, 0);
- g_assert_cmpint (nm_setting_dcb_get_app_fip_flags (s_dcb), ==, 0);
- g_assert_cmpint (nm_setting_dcb_get_priority_flow_control_flags (s_dcb), ==, 0);
- g_assert_cmpint (nm_setting_dcb_get_priority_group_flags (s_dcb), ==, 0);
-
- g_object_set (G_OBJECT (s_dcb),
- NM_SETTING_DCB_APP_FCOE_FLAGS, DCB_FLAGS_ALL,
- NM_SETTING_DCB_APP_ISCSI_FLAGS, DCB_FLAGS_ALL,
- NM_SETTING_DCB_APP_FIP_FLAGS, DCB_FLAGS_ALL,
- NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, DCB_FLAGS_ALL,
- NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, DCB_FLAGS_ALL,
- NULL);
- /* Priority Group Bandwidth must total 100% */
- for (i = 0; i < 7; i++)
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, i, 12);
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 7, 16);
-
- success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error);
- g_assert_no_error (error);
- g_assert (success);
-
- g_assert_cmpint (nm_setting_dcb_get_app_fcoe_flags (s_dcb), ==, DCB_FLAGS_ALL);
- g_assert_cmpint (nm_setting_dcb_get_app_iscsi_flags (s_dcb), ==, DCB_FLAGS_ALL);
- g_assert_cmpint (nm_setting_dcb_get_app_fip_flags (s_dcb), ==, DCB_FLAGS_ALL);
- g_assert_cmpint (nm_setting_dcb_get_priority_flow_control_flags (s_dcb), ==, DCB_FLAGS_ALL);
- g_assert_cmpint (nm_setting_dcb_get_priority_group_flags (s_dcb), ==, DCB_FLAGS_ALL);
-}
-
-#define TEST_FLAG(p, f, v) \
-{ \
- /* GObject property min/max should ensure the property does not get set to \
- * the invalid value, so we ensure the value we just tried to set is 0 and \
- * that verify is successful since the property never got set. \
- */ \
- g_object_set (G_OBJECT (s_dcb), p, v, NULL); \
- g_assert_cmpint (f (s_dcb), ==, 0); \
- success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error); \
- g_assert_no_error (error); \
- g_assert (success); \
-}
-
-static void
-test_dcb_flags_invalid (void)
-{
- gs_unref_object NMSettingDcb *s_dcb = NULL;
- GError *error = NULL;
- gboolean success;
-
- s_dcb = (NMSettingDcb *) nm_setting_dcb_new ();
- g_assert (s_dcb);
-
- NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
- TEST_FLAG (NM_SETTING_DCB_APP_FCOE_FLAGS, nm_setting_dcb_get_app_fcoe_flags, 0x332523);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
- TEST_FLAG (NM_SETTING_DCB_APP_ISCSI_FLAGS, nm_setting_dcb_get_app_iscsi_flags, 0xFF);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
- TEST_FLAG (NM_SETTING_DCB_APP_FIP_FLAGS, nm_setting_dcb_get_app_fip_flags, 0x1111);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
- TEST_FLAG (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, nm_setting_dcb_get_priority_flow_control_flags, G_MAXUINT32);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
- TEST_FLAG (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, nm_setting_dcb_get_priority_group_flags,
- (NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING) + 1);
- g_test_assert_expected_messages ();
-}
-
-#define TEST_APP_PRIORITY(lcprop, ucprop, v) \
-{ \
- g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_##ucprop##_FLAGS, NM_SETTING_DCB_FLAG_NONE, NULL); \
- \
- g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_##ucprop##_PRIORITY, v, NULL); \
- g_assert_cmpint (nm_setting_dcb_get_app_##lcprop##_priority (s_dcb), ==, v); \
- \
- /* Assert that the setting is invalid while the app is disabled unless v is default */ \
- success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error); \
- if (v >= 0) { \
- g_assert_error (error, NM_SETTING_DCB_ERROR, NM_SETTING_DCB_ERROR_INVALID_PROPERTY); \
- g_assert (success == FALSE); \
- } else { \
- g_assert_no_error (error); \
- g_assert (success); \
- } \
- g_clear_error (&error); \
- \
- /* Set the enable flag and re-verify, this time it should be valid */ \
- g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_##ucprop##_FLAGS, NM_SETTING_DCB_FLAG_ENABLE, NULL); \
- success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error); \
- g_assert_no_error (error); \
- g_assert (success); \
- \
- g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_##ucprop##_PRIORITY, 0, NULL); \
-}
-
-static void
-test_dcb_app_priorities (void)
-{
- gs_unref_object NMSettingDcb *s_dcb = NULL;
- GError *error = NULL;
- gboolean success;
-
- s_dcb = (NMSettingDcb *) nm_setting_dcb_new ();
- g_assert (s_dcb);
-
- /* Defaults */
- g_assert_cmpint (nm_setting_dcb_get_app_fcoe_priority (s_dcb), ==, -1);
- g_assert_cmpint (nm_setting_dcb_get_app_iscsi_priority (s_dcb), ==, -1);
- g_assert_cmpint (nm_setting_dcb_get_app_fip_priority (s_dcb), ==, -1);
-
- TEST_APP_PRIORITY (fcoe, FCOE, 6);
- TEST_APP_PRIORITY (iscsi, ISCSI, 5);
- TEST_APP_PRIORITY (fip, FIP, 4);
-
- TEST_APP_PRIORITY (fcoe, FCOE, -1);
- TEST_APP_PRIORITY (iscsi, ISCSI, -1);
- TEST_APP_PRIORITY (fip, FIP, -1);
-}
-
-#define TEST_PRIORITY_VALID(fn, id, val, flagsprop, verify) \
-{ \
- /* Assert that setting the value gets the same value back out */ \
- nm_setting_dcb_set_priority_##fn (s_dcb, id, val); \
- g_assert_cmpint (nm_setting_dcb_get_priority_##fn (s_dcb, id), ==, val); \
- \
- if (verify) { \
- if (val != 0) { \
- /* Assert that verify fails because the flags do not include 'enabled' \
- * and a value has been set. \
- */ \
- success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error); \
- g_assert_error (error, NM_SETTING_DCB_ERROR, NM_SETTING_DCB_ERROR_INVALID_PROPERTY); \
- g_assert (success == FALSE); \
- g_clear_error (&error); \
- } \
- \
- /* Assert that adding the 'enabled' flag verifies the setting */ \
- g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_PRIORITY_##flagsprop##_FLAGS, NM_SETTING_DCB_FLAG_ENABLE, NULL); \
- success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error); \
- g_assert_no_error (error); \
- g_assert (success); \
- } \
- \
- /* Reset everything */ \
- g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_PRIORITY_##flagsprop##_FLAGS, NM_SETTING_DCB_FLAG_NONE, NULL); \
- nm_setting_dcb_set_priority_##fn (s_dcb, id, 0); \
-}
-
-/* If Priority Groups are enabled, PG bandwidth must equal 100% */
-#define SET_VALID_PRIORITY_GROUP_BANDWIDTH \
-{ \
- guint x; \
- for (x = 0; x < 7; x++) \
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, x, 12); \
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 7, 16); \
-}
-
-static void
-test_dcb_priorities_valid (void)
-{
- gs_unref_object NMSettingDcb *s_dcb = NULL;
- GError *error = NULL;
- gboolean success;
- guint i;
-
- s_dcb = (NMSettingDcb *) nm_setting_dcb_new ();
- g_assert (s_dcb);
-
- for (i = 0; i < 8; i++)
- TEST_PRIORITY_VALID (flow_control, i, TRUE, FLOW_CONTROL, TRUE);
-
- SET_VALID_PRIORITY_GROUP_BANDWIDTH
- for (i = 0; i < 8; i++) {
- TEST_PRIORITY_VALID (group_id, i, i, GROUP, TRUE);
- TEST_PRIORITY_VALID (group_id, i, 7 - i, GROUP, TRUE);
- }
-
- /* Clear PG bandwidth from earlier tests */
- for (i = 0; i < 8; i++)
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, i, 0);
-
- /* Priority Group Bandwidth must add up to 100% if enabled, which requires
- * some dancing for verifying individual values here.
- */
- for (i = 0; i < 8; i++) {
- guint other = 7 - (i % 8);
-
- /* Set another priority group to the remaining bandwidth */
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, other, 100 - i);
- TEST_PRIORITY_VALID (group_bandwidth, i, i, GROUP, TRUE);
-
- /* Set another priority group to the remaining bandwidth */
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, other, 100 - (7 - i));
- TEST_PRIORITY_VALID (group_bandwidth, i, 7 - i, GROUP, TRUE);
-
- /* Clear remaining bandwidth */
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, other, 0);
- }
-
- SET_VALID_PRIORITY_GROUP_BANDWIDTH
- for (i = 0; i < 8; i++) {
- TEST_PRIORITY_VALID (bandwidth, i, i, GROUP, TRUE);
- TEST_PRIORITY_VALID (bandwidth, i, 7 - i, GROUP, TRUE);
- }
-
- SET_VALID_PRIORITY_GROUP_BANDWIDTH
- for (i = 0; i < 8; i++)
- TEST_PRIORITY_VALID (strict_bandwidth, i, TRUE, GROUP, TRUE);
-
- SET_VALID_PRIORITY_GROUP_BANDWIDTH
- for (i = 0; i < 8; i++) {
- TEST_PRIORITY_VALID (traffic_class, i, i, GROUP, TRUE);
- TEST_PRIORITY_VALID (traffic_class, i, 7 - i, GROUP, TRUE);
- }
-}
-
-static void
-test_dcb_bandwidth_sums (void)
-{
- gs_unref_object NMSettingDcb *s_dcb = NULL;
- GError *error = NULL;
- gboolean success;
-
- s_dcb = (NMSettingDcb *) nm_setting_dcb_new ();
- g_assert (s_dcb);
-
- /* Assert that setting the value gets the same value back out */
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 0, 9);
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 1, 10);
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 2, 11);
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 3, 12);
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 4, 13);
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 5, 14);
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 6, 15);
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 7, 16);
-
- /* Assert verify success when sums total 100% */
- g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, NM_SETTING_DCB_FLAG_ENABLE, NULL);
- success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error);
- g_assert_no_error (error);
- g_assert (success);
-
- /* Assert verify fails when sums do not total 100% */
- nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 4, 20);
- success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error);
- g_assert_error (error, NM_SETTING_DCB_ERROR, NM_SETTING_DCB_ERROR_INVALID_PROPERTY);
- g_assert (success == FALSE);
- g_clear_error (&error);
-}
-
-#define TPATH "/libnm-util/settings/dcb/"
-
-NMTST_DEFINE ();
-
-int main (int argc, char **argv)
-{
- nmtst_init (&argc, &argv, TRUE);
-
- g_test_add_func (TPATH "flags-valid", test_dcb_flags_valid);
- g_test_add_func (TPATH "flags-invalid", test_dcb_flags_invalid);
- g_test_add_func (TPATH "app-priorities", test_dcb_app_priorities);
- g_test_add_func (TPATH "priorities", test_dcb_priorities_valid);
- g_test_add_func (TPATH "bandwidth-sums", test_dcb_bandwidth_sums);
-
- return g_test_run ();
-}
-
diff --git a/libnm-util/tests/test-settings-defaults.c b/libnm-util/tests/test-settings-defaults.c
deleted file mode 100644
index 0bd4feee58..0000000000
--- a/libnm-util/tests/test-settings-defaults.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2011 Red Hat, Inc.
- *
- */
-
-#include "nm-default.h"
-
-#include <string.h>
-
-#include "nm-utils.h"
-#include "nm-setting-8021x.h"
-#include "nm-setting-cdma.h"
-#include "nm-setting-connection.h"
-#include "nm-setting-gsm.h"
-#include "nm-setting-ip4-config.h"
-#include "nm-setting-ip6-config.h"
-#include "nm-setting-ppp.h"
-#include "nm-setting-pppoe.h"
-#include "nm-setting-serial.h"
-#include "nm-setting-vpn.h"
-#include "nm-setting-wired.h"
-#include "nm-setting-wireless.h"
-#include "nm-setting-wireless-security.h"
-
-#include "nm-utils/nm-test-utils.h"
-
-static void
-test_defaults (GType type, const char *name)
-{
- GParamSpec **property_specs;
- guint n_property_specs;
- GObject *setting;
- int i;
-
- setting = g_object_new (type, NULL);
-
- property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
- g_assert (property_specs);
-
- for (i = 0; i < n_property_specs; i++) {
- GParamSpec *prop_spec = property_specs[i];
- GValue value = G_VALUE_INIT;
- GValue defvalue = G_VALUE_INIT;
- char *actual, *expected;
- gboolean ok = FALSE;
-
- /* Ignore non-fundamental types since they won't really have
- * defaults.
- */
- if (!G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
- continue;
-
- g_value_init (&value, prop_spec->value_type);
- g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
-
- g_value_init (&defvalue, prop_spec->value_type);
- g_param_value_set_default (prop_spec, &defvalue);
-
- actual = g_strdup_value_contents (&value);
- expected = g_strdup_value_contents (&defvalue);
-
- if (!strcmp (prop_spec->name, NM_SETTING_NAME)) {
- /* 'name' is always the setting name, not the default value */
- ok = !strcmp (nm_setting_get_name (NM_SETTING (setting)), name);
- g_free (expected);
- expected = g_strdup (name);
- } else
- ok = g_param_value_defaults (prop_spec, &value);
-
- g_assert (ok);
-
- g_free (actual);
- g_free (expected);
- g_value_unset (&value);
- g_value_unset (&defvalue);
- }
-
- g_free (property_specs);
- g_object_unref (setting);
-}
-
-static void
-defaults (void)
-{
- /* The tests */
- test_defaults (NM_TYPE_SETTING_CONNECTION, NM_SETTING_CONNECTION_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_802_1X, NM_SETTING_802_1X_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_CDMA, NM_SETTING_CDMA_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_GSM, NM_SETTING_GSM_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_IP4_CONFIG, NM_SETTING_IP4_CONFIG_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_IP6_CONFIG, NM_SETTING_IP6_CONFIG_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_PPP, NM_SETTING_PPP_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_PPPOE, NM_SETTING_PPPOE_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_SERIAL, NM_SETTING_SERIAL_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_VPN, NM_SETTING_VPN_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_WIRED, NM_SETTING_WIRED_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_WIRELESS, NM_SETTING_WIRELESS_SETTING_NAME);
- test_defaults (NM_TYPE_SETTING_WIRELESS_SECURITY, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
-}
-
-NMTST_DEFINE ();
-
-int
-main (int argc, char **argv)
-{
- nmtst_init (&argc, &argv, TRUE);
-
- g_test_add_func ("/libnm/defaults", defaults);
-
- return g_test_run ();
-}
diff --git a/libnm/fake-typelib/NMClient.gir b/libnm/fake-typelib/NMClient.gir
deleted file mode 100644
index 3002f8d630..0000000000
--- a/libnm/fake-typelib/NMClient.gir
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0"?>
-<!-- A lame duck typelib which prevents GIR from loading the
- real one (which would crash due to conflict with libnm) -->
-<repository version="1.2"
- xmlns="http://www.gtk.org/introspection/core/1.0"
- xmlns:c="http://www.gtk.org/introspection/c/1.0"
- xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
- <namespace name="NMClient" version="0.0" />
-</repository>
diff --git a/libnm/fake-typelib/NetworkManager.gir b/libnm/fake-typelib/NetworkManager.gir
deleted file mode 100644
index d15d29afc7..0000000000
--- a/libnm/fake-typelib/NetworkManager.gir
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<!-- A lame duck typelib which prevents GIR from loading the
- real one (which would crash due to conflict with libnm) -->
-<repository version="1.2"
- xmlns="http://www.gtk.org/introspection/core/1.0"
- xmlns:c="http://www.gtk.org/introspection/c/1.0"
- xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
- <namespace name="NetworkManager" version="0.0">
- </namespace>
-</repository>
diff --git a/libnm/fake-typelib/meson.build b/libnm/fake-typelib/meson.build
deleted file mode 100644
index fdbb29202e..0000000000
--- a/libnm/fake-typelib/meson.build
+++ /dev/null
@@ -1,30 +0,0 @@
-g_ir_compiler = find_program('g-ir-compiler')
-
-girs = [
- 'NetworkManager',
- 'NMClient',
-]
-
-resource_data = []
-
-foreach gir: girs
- gir_typelib = gir + '.typelib'
-
- resource_data += custom_target(
- gir_typelib,
- input: gir + '.gir',
- output: gir_typelib,
- command: [g_ir_compiler, '@INPUT@', '-o', '@OUTPUT@'],
- )
-endforeach
-
-resource = 'typelibs'
-
-libnm_utils_sources += gnome.compile_resources(
- resource,
- resource + '.gresource.xml',
- source_dir: '.',
- dependencies: resource_data,
- extra_args: '--manual-register',
- export: true,
-)
diff --git a/libnm/fake-typelib/typelibs.gresource.xml b/libnm/fake-typelib/typelibs.gresource.xml
deleted file mode 100644
index 9a71d97544..0000000000
--- a/libnm/fake-typelib/typelibs.gresource.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<gresources>
- <gresource prefix="/org/freedesktop/libnm/fake-typelib">
- <file>NetworkManager.typelib</file>
- <file>NMClient.typelib</file>
- </gresource>
-</gresources>
diff --git a/libnm/meson.build b/libnm/meson.build
index 4b3df97f15..84575425f0 100644
--- a/libnm/meson.build
+++ b/libnm/meson.build
@@ -13,11 +13,6 @@ deps = [
libnm_core_dep,
]
-if have_fake_typelibs
- deps += gir_dep
- subdir('fake-typelib')
-endif
-
libnm_utils = static_library(
'nm-utils',
sources: libnm_utils_sources,
diff --git a/libnm/nm-libnm-utils.c b/libnm/nm-libnm-utils.c
index f740c37caf..580d576be6 100644
--- a/libnm/nm-libnm-utils.c
+++ b/libnm/nm-libnm-utils.c
@@ -561,85 +561,3 @@ nm_utils_fixup_product_string (const char *desc)
return desc_full;
}
-
-#if WITH_FAKE_TYPELIBS
-
-/*
- * Here we register empty "NMClient" and "NetworkManager" GIR modules as soon
- * as we are loaded (if gnome-introspection is being used). This prevents the
- * real modules from being loaded because they would in turn load libnm-glib
- * and abort() and crash.
- *
- * For the high level languages that utilize GIR the crash is highly inconvenient
- * while the inability to resolve any methods and attributes is potentially
- * recoverable.
- */
-
-#include <girepository.h>
-
-GResource *typelibs_get_resource (void);
-void typelibs_register_resource (void);
-
-static void __attribute__((constructor))
-_nm_libnm_utils_init (void)
-{
- GITypelib *typelib;
- GBytes *data;
- const char *namespace;
- GModule *self;
- GITypelib *(*_g_typelib_new_from_const_memory) (const guint8 *memory,
- gsize len,
- GError **error) = NULL;
- const char *(*_g_irepository_load_typelib) (GIRepository *repository,
- GITypelib *typelib,
- GIRepositoryLoadFlags flags,
- GError **error) = NULL;
- const char *names[] = { "/org/freedesktop/libnm/fake-typelib/NetworkManager.typelib",
- "/org/freedesktop/libnm/fake-typelib/NMClient.typelib" };
- int i;
-
- self = g_module_open (NULL, 0);
- if (!self)
- return;
- g_module_symbol (self, "g_typelib_new_from_const_memory",
- (gpointer *) &_g_typelib_new_from_const_memory);
- if (_g_typelib_new_from_const_memory) {
- g_module_symbol (self, "g_irepository_load_typelib",
- (gpointer *) &_g_irepository_load_typelib);
- }
- g_module_close (self);
-
- if (!_g_typelib_new_from_const_memory || !_g_irepository_load_typelib)
- return;
-
- typelibs_register_resource ();
-
- for (i = 0; i < 2; i++) {
- gs_free_error GError *error = NULL;
-
- data = g_resource_lookup_data (typelibs_get_resource (),
- names[i],
- G_RESOURCE_LOOKUP_FLAGS_NONE,
- &error);
- if (!data) {
- g_warning ("Fake typelib %s could not be loaded: %s", names[i], error->message);
- return;
- }
-
- typelib = _g_typelib_new_from_const_memory (g_bytes_get_data (data, NULL),
- g_bytes_get_size (data),
- &error);
- if (!typelib) {
- g_warning ("Could not create fake typelib instance %s: %s", names[i], error->message);
- return;
- }
-
- namespace = _g_irepository_load_typelib (NULL, typelib, 0, &error);
- if (!namespace) {
- g_warning ("Could not load fake typelib %s: %s", names[i], error->message);
- return;
- }
- }
-}
-
-#endif /* WITH_FAKE_TYPELIBS */
diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4
index bf847bfc91..9f167a103b 100644
--- a/m4/compiler_options.m4
+++ b/m4/compiler_options.m4
@@ -142,7 +142,7 @@ fi
])
AC_DEFUN([NM_LTO],
-[AC_ARG_ENABLE(lto, AS_HELP_STRING([--enable-lto], [Enable Link Time Optimization for smaller size (default: no)]))
+[AC_ARG_ENABLE(lto, AS_HELP_STRING([--enable-lto], [Enable Link Time Optimization for smaller size [default=no]]))
if (test "${enable_lto}" = "yes"); then
CC_CHECK_FLAG_APPEND([lto_flags], [CFLAGS], [-flto -flto-partition=none])
if (test -n "${lto_flags}"); then
@@ -156,7 +156,7 @@ fi
])
AC_DEFUN([NM_LD_GC],
-[AC_ARG_ENABLE(ld-gc, AS_HELP_STRING([--enable-ld-gc], [Enable garbage collection of unused symbols on linking (default: auto)]))
+[AC_ARG_ENABLE(ld-gc, AS_HELP_STRING([--enable-ld-gc], [Enable garbage collection of unused symbols on linking [default=auto]]))
if (test "${enable_ld_gc}" != "no"); then
CC_CHECK_FLAG_APPEND([ld_gc_flags], [CFLAGS], [-fdata-sections -ffunction-sections -Wl,--gc-sections])
if (test -n "${ld_gc_flags}"); then
diff --git a/m4/vapigen.m4 b/m4/vapigen.m4
index 48051078d9..3ade411e3b 100644
--- a/m4/vapigen.m4
+++ b/m4/vapigen.m4
@@ -28,7 +28,7 @@ AC_DEFUN([VAPIGEN_CHECK],
AC_ARG_ENABLE([vala],
AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],
- [build Vala bindings [[default=auto]]]),,
+ [build Vala bindings [default=auto]]),,
[enable_vala=auto])
AS_CASE([$enable_vala], [no], [],
diff --git a/meson.build b/meson.build
index 27bcd03389..8804af51c1 100644
--- a/meson.build
+++ b/meson.build
@@ -4,7 +4,7 @@ project(
# - add corresponding NM_VERSION_x_y_z macros in
# "shared/nm-version-macros.h.in"
# - update number in configure.ac
- version: '1.18.0',
+ version: '1.19.1',
license: 'GPL2+',
default_options: [
'buildtype=debugoptimized',
@@ -63,28 +63,6 @@ libnm_version = '@0@.@1@.@2@'.format(current - age, age, revision)
libnm_pkgincludedir = join_paths(nm_includedir, libnm_name)
-libnm_util_name = 'libnm-util'
-
-current = 9
-revision = 0
-age = 7
-libnm_util_version = '@0@.@1@.@2@'.format(current - age, age, revision)
-
-libnm_glib_name = 'libnm-glib'
-libnm_glib_vpn_name = libnm_glib_name + '-vpn'
-
-current = 13
-revision = 0
-age = 9
-libnm_glib_version = '@0@.@1@.@2@'.format(current - age, age, revision)
-
-libnm_glib_pkgincludedir = join_paths(nm_includedir, libnm_glib_name)
-
-current = 3
-revision = 0
-age = 2
-libnm_glib_vpn_version = '@0@.@1@.@2@'.format(current - age, age, revision)
-
nm_debug = get_option('buildtype').contains('debug')
cc = meson.get_compiler('c')
@@ -281,7 +259,6 @@ config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_PLUGINS', config_plugins_default)
config_h.set_quoted('NM_DIST_VERSION', dist_version)
enable_wifi = get_option('wifi')
-config_h.set10('WITH_WIFI', enable_wifi)
enable_iwd = get_option('iwd')
if enable_iwd
@@ -320,20 +297,6 @@ if enable_introspection
assert(gir_dep.found(), 'introspection support was requested, but the gobject-introspection library is not available. Use -Dintrospection=false to build without it.')
endif
-enable_libnm_glib = get_option('libnm_glib')
-if enable_libnm_glib
- dbus_glib_dep = dependency('dbus-glib-1', version: '>= 0.94', required: false)
- assert(dbus_dep.found() and dbus_glib_dep.found(), 'Configure with -Dlibnm_glib=false if you do not need the legacy libraries')
-endif
-# FIXME: do this better!!!
-have_fake_typelibs = enable_libnm_glib and enable_introspection
-if have_fake_typelibs and gio_unix_dep.version().version_compare('< 2.51.1')
- warning('cannot build fake typelibs for libnm because glib is too old')
- have_fake_typelibs=false
-endif
-
-config_h.set10('WITH_FAKE_TYPELIBS', have_fake_typelibs)
-
udev_dir = get_option('udev_dir')
install_udev_dir = (udev_dir != 'no')
@@ -348,7 +311,6 @@ if install_systemd_unit_dir and systemd_system_unit_dir == ''
assert(systemd_dep.found(), 'systemd required but not found, please provide a valid systemd user unit dir or disable it')
systemd_system_unit_dir = systemd_dep.get_pkgconfig_variable('systemdsystemunitdir')
endif
-config_h.set10('HAVE_SYSTEMD', install_systemd_unit_dir)
enable_systemd_journal = get_option('systemd_journal')
if enable_systemd_journal
@@ -863,11 +825,6 @@ subdir('clients')
subdir('data')
subdir('po')
-if enable_libnm_glib
- subdir('libnm-util')
- subdir('libnm-glib')
-endif
-
if enable_vapi
subdir('vapi')
endif
@@ -978,7 +935,6 @@ output += ' ofono: ' + enable_ofono.to_string() + '\n'
output += ' concheck: ' + enable_concheck.to_string() + '\n'
output += ' libteamdctl: ' + enable_teamdctl.to_string() + '\n'
output += ' ovs: ' + enable_ovs.to_string() + '\n'
-output += ' libnm-glib: ' + enable_libnm_glib.to_string() + '\n'
output += ' nmcli: ' + enable_nmcli.to_string() + '\n'
output += ' nmtui: ' + enable_nmtui.to_string() + '\n'
output += '\nConfiguration_plugins (main.plugins=' + config_plugins_default + ')\n'
diff --git a/meson_options.txt b/meson_options.txt
index 5ea9e118e0..e2d53c252c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -34,7 +34,6 @@ option('ofono', type: 'boolean', value: false, description: 'Enable oFono suppor
option('concheck', type: 'boolean', value: true, description: 'enable connectivity checking support')
option('teamdctl', type: 'boolean', value: false, description: 'enable Teamd control support')
option('ovs', type: 'boolean', value: true, description: 'enable Open vSwitch support')
-option('libnm_glib', type: 'boolean', value: false, description: 'build legacy libraries')
option('nmcli', type: 'boolean', value: true, description: 'Build nmcli')
option('nmtui', type: 'boolean', value: true, description: 'Build nmtui')
option('bluez5_dun', type: 'boolean', value: false, description: 'enable Bluez5 DUN support')
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1edddb7f3a..dcce693109 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -105,37 +105,6 @@ libnm-core/nm-setting.c
libnm-core/nm-utils.c
libnm-core/nm-vpn-editor-plugin.c
libnm-core/nm-vpn-plugin-info.c
-libnm-glib/nm-device.c
-libnm-glib/nm-remote-connection.c
-libnm-util/crypto.c
-libnm-util/crypto_gnutls.c
-libnm-util/crypto_nss.c
-libnm-util/nm-connection.c
-libnm-util/nm-setting.c
-libnm-util/nm-setting-8021x.c
-libnm-util/nm-setting-adsl.c
-libnm-util/nm-setting-bluetooth.c
-libnm-util/nm-setting-bond.c
-libnm-util/nm-setting-bridge-port.c
-libnm-util/nm-setting-bridge.c
-libnm-util/nm-setting-cdma.c
-libnm-util/nm-setting-connection.c
-libnm-util/nm-setting-dcb.c
-libnm-util/nm-setting-gsm.c
-libnm-util/nm-setting-infiniband.c
-libnm-util/nm-setting-ip4-config.c
-libnm-util/nm-setting-ip6-config.c
-libnm-util/nm-setting-olpc-mesh.c
-libnm-util/nm-setting-ppp.c
-libnm-util/nm-setting-pppoe.c
-libnm-util/nm-setting-team.c
-libnm-util/nm-setting-vlan.c
-libnm-util/nm-setting-vpn.c
-libnm-util/nm-setting-wimax.c
-libnm-util/nm-setting-wired.c
-libnm-util/nm-setting-wireless-security.c
-libnm-util/nm-setting-wireless.c
-libnm-util/nm-utils.c
libnm/nm-device-6lowpan.c
libnm/nm-device-adsl.c
libnm/nm-device-bond.c
diff --git a/shared/c-list/AUTHORS b/shared/c-list/AUTHORS
index 9bd72c75ff..2327c052d4 100644
--- a/shared/c-list/AUTHORS
+++ b/shared/c-list/AUTHORS
@@ -30,9 +30,9 @@ AUTHORS-LGPL:
along with this program; If not, see <http://www.gnu.org/licenses/>.
COPYRIGHT: (ordered alphabetically)
- Copyright (C) 2015-2018 Red Hat, Inc.
+ Copyright (C) 2015-2019 Red Hat, Inc.
AUTHORS: (ordered alphabetically)
- David Herrmann <dh.herrmann@gmail.com>
+ David Rheinsberg <david.rheinsberg@gmail.com>
Thomas Haller <thaller@redhat.com>
Tom Gundersen <teg@jklm.no>
diff --git a/shared/c-list/AUTHORS-ASL b/shared/c-list/AUTHORS-ASL
deleted file mode 100644
index 5d501a7284..0000000000
--- a/shared/c-list/AUTHORS-ASL
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright {yyyy} {name of copyright owner}
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/shared/c-list/AUTHORS-LGPL b/shared/c-list/AUTHORS-LGPL
deleted file mode 100644
index 4362b49151..0000000000
--- a/shared/c-list/AUTHORS-LGPL
+++ /dev/null
@@ -1,502 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library 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.
-
- This library 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 this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/shared/c-list/LICENSE b/shared/c-list/LICENSE
deleted file mode 120000
index da24c5e4a6..0000000000
--- a/shared/c-list/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-AUTHORS-ASL \ No newline at end of file
diff --git a/shared/c-list/NEWS b/shared/c-list/NEWS.md
index 6695052414..0404389597 100644
--- a/shared/c-list/NEWS
+++ b/shared/c-list/NEWS.md
@@ -1,6 +1,6 @@
-c-list - Circular Intrusive Double Linked List Collection
+# c-list - Circular Intrusive Double Linked List Collection
-CHANGES WITH 3:
+## CHANGES WITH 3:
* API break: The c_list_loop_*() symbols were removed, since we saw
little use for them. No user was known at the time, so
@@ -33,7 +33,7 @@ CHANGES WITH 3:
- Berlin, 2017-08-13
-CHANGES WITH 2:
+## CHANGES WITH 2:
* Adjust project-name in build-system to reflect the actual project. The
previous releases incorrectly claimed to be c-rbtree in the build
@@ -53,7 +53,7 @@ CHANGES WITH 2:
- Lund, 2017-05-03
-CHANGES WITH 1:
+## CHANGES WITH 1:
* Initial release of c-list.
diff --git a/shared/c-list/README b/shared/c-list/README
deleted file mode 100644
index 1698f922ad..0000000000
--- a/shared/c-list/README
+++ /dev/null
@@ -1,48 +0,0 @@
-c-list - Circular Intrusive Double Linked List Collection
-
-ABOUT:
- The c-list project implements an intrusive collection based on circular
- double linked lists in ISO-C11. It aims for minimal API constraints,
- leaving maximum control over the data-structures to the API consumer.
-
-DETAILS:
- https://c-util.github.io/c-list
-
-BUG REPORTS:
- https://github.com/c-util/c-list/issues
-
-GIT:
- git@github.com:c-util/c-list.git
- https://github.com/c-util/c-list.git
-
-GITWEB:
- https://github.com/c-util/c-list
-
-LICENSE:
- Apache Software License 2.0
- Lesser General Public License 2.1+
- See AUTHORS for details.
-
-REQUIREMENTS:
- The requirements for c-list are:
-
- libc (e.g., glibc >= 2.16)
-
- At build-time, the following software is required:
-
- meson >= 0.41
- pkg-config >= 0.29
-
-INSTALL:
- The meson build-system is used for this project. Contact upstream
- documentation for detailed help. In most situations the following
- commands are sufficient to build and install from source:
-
- $ mkdir build
- $ cd build
- $ meson setup ..
- $ ninja
- $ meson test
- # ninja install
-
- No custom configuration options are available.
diff --git a/shared/c-list/README.md b/shared/c-list/README.md
new file mode 100644
index 0000000000..d14198999f
--- /dev/null
+++ b/shared/c-list/README.md
@@ -0,0 +1,52 @@
+c-list
+======
+
+Circular Intrusive Double Linked List Collection
+
+The c-list project implements an intrusive collection based on circular double
+linked lists in ISO-C11. It aims for minimal API constraints, leaving maximum
+control over the data-structures to the API consumer.
+
+### Project
+
+ * **Website**: <https://c-util.github.io/c-list>
+ * **Bug Tracker**: <https://github.com/c-util/c-list/issues>
+
+### Requirements
+
+The requirements for this project are:
+
+ * `libc` (e.g., `glibc >= 2.16`)
+
+At build-time, the following software is required:
+
+ * `meson >= 0.41`
+ * `pkg-config >= 0.29`
+
+### Build
+
+The meson build-system is used for this project. Contact upstream
+documentation for detailed help. In most situations the following
+commands are sufficient to build and install from source:
+
+```sh
+mkdir build
+cd build
+meson setup ..
+ninja
+meson test
+ninja install
+```
+
+No custom configuration options are available.
+
+### Repository:
+
+ - **web**: <https://github.com/c-util/c-list>
+ - **https**: `https://github.com/c-util/c-list.git`
+ - **ssh**: `git@github.com:c-util/c-list.git`
+
+### License:
+
+ - **Apache-2.0** OR **LGPL-2.1-or-later**
+ - See AUTHORS file for details.
diff --git a/shared/c-list/src/test-api.c b/shared/c-list/src/test-api.c
index 5ebc92867b..caba7fb0ff 100644
--- a/shared/c-list/src/test-api.c
+++ b/shared/c-list/src/test-api.c
@@ -4,6 +4,7 @@
* shared library. Its sole purpose is to test for symbol availability.
*/
+#undef NDEBUG
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/shared/c-list/src/test-basic.c b/shared/c-list/src/test-basic.c
index 21da348434..702f96a651 100644
--- a/shared/c-list/src/test-basic.c
+++ b/shared/c-list/src/test-basic.c
@@ -4,6 +4,7 @@
* functionality, and usage.
*/
+#undef NDEBUG
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/shared/c-list/src/test-embed.c b/shared/c-list/src/test-embed.c
index d30b1cd7fa..8b88575ffc 100644
--- a/shared/c-list/src/test-embed.c
+++ b/shared/c-list/src/test-embed.c
@@ -2,6 +2,7 @@
* Tests for embedded CList members
*/
+#undef NDEBUG
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/shared/c-rbtree/.cherryci/matrix b/shared/c-rbtree/.cherryci/matrix
new file mode 100755
index 0000000000..6cb6f71ebb
--- /dev/null
+++ b/shared/c-rbtree/.cherryci/matrix
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+
+_CHERRY_LIB_M_GCC_NDEBUG=("CC=gcc" "CFLAGS='${CHERRY_LIB_CFLAGS[*]} ${CHERRY_LIB_CFLAGS_GCC[*]} -O2 -DNDEBUG'")
+CHERRY_MATRIX+=("export ${_CHERRY_LIB_M_GCC_NDEBUG[*]}")
diff --git a/shared/c-rbtree/.gitmodules b/shared/c-rbtree/.gitmodules
new file mode 100644
index 0000000000..a86b29fd1c
--- /dev/null
+++ b/shared/c-rbtree/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "subprojects/c-stdaux"]
+ path = subprojects/c-stdaux
+ url = https://github.com/c-util/c-stdaux.git
diff --git a/shared/c-rbtree/AUTHORS b/shared/c-rbtree/AUTHORS
index 980d602337..b59660c5ee 100644
--- a/shared/c-rbtree/AUTHORS
+++ b/shared/c-rbtree/AUTHORS
@@ -30,8 +30,8 @@ AUTHORS-LGPL:
along with this program; If not, see <http://www.gnu.org/licenses/>.
COPYRIGHT: (ordered alphabetically)
- Copyright (C) 2015-2018 Red Hat, Inc.
+ Copyright (C) 2015-2019 Red Hat, Inc.
AUTHORS: (ordered alphabetically)
- David Herrmann <dh.herrmann@gmail.com>
+ David Rheinsberg <david.rheinsberg@gmail.com>
Tom Gundersen <teg@jklm.no>
diff --git a/shared/c-rbtree/AUTHORS-ASL b/shared/c-rbtree/AUTHORS-ASL
deleted file mode 100644
index 5d501a7284..0000000000
--- a/shared/c-rbtree/AUTHORS-ASL
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright {yyyy} {name of copyright owner}
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/shared/c-rbtree/AUTHORS-LGPL b/shared/c-rbtree/AUTHORS-LGPL
deleted file mode 100644
index 4362b49151..0000000000
--- a/shared/c-rbtree/AUTHORS-LGPL
+++ /dev/null
@@ -1,502 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library 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.
-
- This library 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 this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/shared/c-rbtree/LICENSE b/shared/c-rbtree/LICENSE
deleted file mode 120000
index da24c5e4a6..0000000000
--- a/shared/c-rbtree/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-AUTHORS-ASL \ No newline at end of file
diff --git a/shared/c-rbtree/NEWS b/shared/c-rbtree/NEWS.md
index 59c03c7ee8..d76a412908 100644
--- a/shared/c-rbtree/NEWS
+++ b/shared/c-rbtree/NEWS.md
@@ -1,6 +1,6 @@
-c-rbtree - Intrusive Red-Black Tree Collection
+# c-rbtree - Intrusive Red-Black Tree Collection
-CHANGES WITH 3:
+## CHANGES WITH 3:
* Add more helpers. Add both a collection of iteratiors and helpers
for initializing a tree and checking if a tree is empty, without
@@ -10,7 +10,7 @@ CHANGES WITH 3:
- Berlin, 2017-08-13
-CHANGES WITH 2:
+## CHANGES WITH 2:
* Relicense as ASL-2.0 to make c-rbtree useful for more projects. All
code is now fully available under the ASL-2.0. Nothing is covered by
@@ -25,7 +25,7 @@ CHANGES WITH 2:
- Berlin, 2016-12-14
-CHANGES WITH 1:
+## CHANGES WITH 1:
* Initial release of c-rbtree.
diff --git a/shared/c-rbtree/README b/shared/c-rbtree/README
deleted file mode 100644
index 069e15c65c..0000000000
--- a/shared/c-rbtree/README
+++ /dev/null
@@ -1,52 +0,0 @@
-c-rbtree - Intrusive Red-Black Tree Collection
-
-ABOUT:
- The c-rbtree project implements an intrusive collection based on
- red-black trees in ISO-C11. Its API guarantees the user full control
- over its data-structures, and rather limits itself to just the
- tree-specific rebalancing and coloring operations.
-
- For API documentation, see the c-rbtree.h header file, as well as the
- docbook comments for each function.
-
-DETAILS:
- https://c-util.github.io/c-rbtree
-
-BUG REPORTS:
- https://github.com/c-util/c-rbtree/issues
-
-GIT:
- git@github.com:c-util/c-rbtree.git
- https://github.com/c-util/c-rbtree.git
-
-GITWEB:
- https://github.com/c-util/c-rbtree
-
-LICENSE:
- Apache Software License 2.0
- Lesser General Public License 2.1+
- See AUTHORS for details.
-
-REQUIREMENTS:
- The requirements for c-siphash are:
-
- libc (e.g., glibc >= 2.16)
-
- At build-time, the following software is required:
-
- meson >= 0.41
- pkg-config >= 0.29
-
-INSTALL:
- The meson build-system is used for this project. Contact upstream
- documentation for detailed help. In most situations the following
- commands are sufficient to build and install from source:
-
- $ mkdir build
- $ cd build
- $ meson setup ..
- $ ninja
- $ meson test
- # ninja install
-
- No custom configuration options are available.
diff --git a/shared/c-rbtree/README.md b/shared/c-rbtree/README.md
new file mode 100644
index 0000000000..c725bbb8f4
--- /dev/null
+++ b/shared/c-rbtree/README.md
@@ -0,0 +1,54 @@
+c-rbtree
+========
+
+Intrusive Red-Black Tree Collection
+
+The c-rbtree project implements an intrusive collection based on red-black
+trees in ISO-C11. Its API guarantees the user full control over its
+data-structures, and rather limits itself to just the tree-specific rebalancing
+and coloring operations. For API documentation, see the c-rbtree.h header file,
+as well as the docbook comments for each function.
+
+### Project
+
+ * **Website**: <https://c-util.github.io/c-rbtree>
+ * **Bug Tracker**: <https://github.com/c-util/c-rbtree/issues>
+
+### Requirements
+
+The requirements for this project are:
+
+ * `libc` (e.g., `glibc >= 2.16`)
+
+At build-time, the following software is required:
+
+ * `meson >= 0.41`
+ * `pkg-config >= 0.29`
+
+### Build
+
+The meson build-system is used for this project. Contact upstream
+documentation for detailed help. In most situations the following
+commands are sufficient to build and install from source:
+
+```sh
+mkdir build
+cd build
+meson setup ..
+ninja
+meson test
+ninja install
+```
+
+No custom configuration options are available.
+
+### Repository:
+
+ - **web**: <https://github.com/c-util/c-rbtree>
+ - **https**: `https://github.com/c-util/c-rbtree.git`
+ - **ssh**: `git@github.com:c-util/c-rbtree.git`
+
+### License:
+
+ - **Apache-2.0** OR **LGPL-2.1-or-later**
+ - See AUTHORS file for details.
diff --git a/shared/c-rbtree/meson.build b/shared/c-rbtree/meson.build
index ce57651e4b..c131946762 100644
--- a/shared/c-rbtree/meson.build
+++ b/shared/c-rbtree/meson.build
@@ -12,4 +12,8 @@ project_description = 'Intrusive Red-Black Tree Collection'
add_project_arguments('-D_GNU_SOURCE', language: 'c')
mod_pkgconfig = import('pkgconfig')
+sub_cstdaux = subproject('c-stdaux')
+
+dep_cstdaux = sub_cstdaux.get_variable('libcstdaux_dep')
+
subdir('src')
diff --git a/shared/c-rbtree/src/c-rbtree-private.h b/shared/c-rbtree/src/c-rbtree-private.h
index 25b9ba01c0..c9befbf37c 100644
--- a/shared/c-rbtree/src/c-rbtree-private.h
+++ b/shared/c-rbtree/src/c-rbtree-private.h
@@ -6,16 +6,11 @@
* which are used by our test-suite.
*/
+#include <c-stdaux.h>
#include <stddef.h>
#include "c-rbtree.h"
/*
- * Macros
- */
-
-#define _public_ __attribute__((__visibility__("default")))
-
-/*
* Nodes
*/
diff --git a/shared/c-rbtree/src/c-rbtree.c b/shared/c-rbtree/src/c-rbtree.c
index 31d743002b..aacdcc2913 100644
--- a/shared/c-rbtree/src/c-rbtree.c
+++ b/shared/c-rbtree/src/c-rbtree.c
@@ -24,11 +24,11 @@
*/
#include <assert.h>
+#include <c-stdaux.h>
#include <stdalign.h>
#include <stddef.h>
-
-#include "c-rbtree-private.h"
#include "c-rbtree.h"
+#include "c-rbtree-private.h"
/*
* We use alignas(8) to enforce 64bit alignment of structure fields. This is
@@ -53,7 +53,7 @@ static_assert(alignof(CRBTree) >= 8, "Invalid CRBTree alignment");
*
* Return: Pointer to leftmost child, or NULL.
*/
-_public_ CRBNode *c_rbnode_leftmost(CRBNode *n) {
+_c_public_ CRBNode *c_rbnode_leftmost(CRBNode *n) {
if (n)
while (n->left)
n = n->left;
@@ -72,7 +72,7 @@ _public_ CRBNode *c_rbnode_leftmost(CRBNode *n) {
*
* Return: Pointer to rightmost child, or NULL.
*/
-_public_ CRBNode *c_rbnode_rightmost(CRBNode *n) {
+_c_public_ CRBNode *c_rbnode_rightmost(CRBNode *n) {
if (n)
while (n->right)
n = n->right;
@@ -94,7 +94,7 @@ _public_ CRBNode *c_rbnode_rightmost(CRBNode *n) {
*
* Return: Pointer to left-deepest child, or NULL.
*/
-_public_ CRBNode *c_rbnode_leftdeepest(CRBNode *n) {
+_c_public_ CRBNode *c_rbnode_leftdeepest(CRBNode *n) {
if (n) {
for (;;) {
if (n->left)
@@ -123,7 +123,7 @@ _public_ CRBNode *c_rbnode_leftdeepest(CRBNode *n) {
*
* Return: Pointer to right-deepest child, or NULL.
*/
-_public_ CRBNode *c_rbnode_rightdeepest(CRBNode *n) {
+_c_public_ CRBNode *c_rbnode_rightdeepest(CRBNode *n) {
if (n) {
for (;;) {
if (n->right)
@@ -149,7 +149,7 @@ _public_ CRBNode *c_rbnode_rightdeepest(CRBNode *n) {
*
* Return: Pointer to next node, or NULL.
*/
-_public_ CRBNode *c_rbnode_next(CRBNode *n) {
+_c_public_ CRBNode *c_rbnode_next(CRBNode *n) {
CRBNode *p;
if (!c_rbnode_is_linked(n))
@@ -175,7 +175,7 @@ _public_ CRBNode *c_rbnode_next(CRBNode *n) {
*
* Return: Pointer to previous node, or NULL.
*/
-_public_ CRBNode *c_rbnode_prev(CRBNode *n) {
+_c_public_ CRBNode *c_rbnode_prev(CRBNode *n) {
CRBNode *p;
if (!c_rbnode_is_linked(n))
@@ -209,7 +209,7 @@ _public_ CRBNode *c_rbnode_prev(CRBNode *n) {
*
* Return: Pointer to next node, or NULL.
*/
-_public_ CRBNode *c_rbnode_next_postorder(CRBNode *n) {
+_c_public_ CRBNode *c_rbnode_next_postorder(CRBNode *n) {
CRBNode *p;
if (!c_rbnode_is_linked(n))
@@ -253,7 +253,7 @@ _public_ CRBNode *c_rbnode_next_postorder(CRBNode *n) {
*
* Return: Pointer to previous node in post-order, or NULL.
*/
-_public_ CRBNode *c_rbnode_prev_postorder(CRBNode *n) {
+_c_public_ CRBNode *c_rbnode_prev_postorder(CRBNode *n) {
CRBNode *p;
if (!c_rbnode_is_linked(n))
@@ -283,8 +283,8 @@ _public_ CRBNode *c_rbnode_prev_postorder(CRBNode *n) {
*
* Return: Pointer to first node, or NULL.
*/
-_public_ CRBNode *c_rbtree_first(CRBTree *t) {
- assert(t);
+_c_public_ CRBNode *c_rbtree_first(CRBTree *t) {
+ c_assert(t);
return c_rbnode_leftmost(t->root);
}
@@ -299,8 +299,8 @@ _public_ CRBNode *c_rbtree_first(CRBTree *t) {
*
* Return: Pointer to last node, or NULL.
*/
-_public_ CRBNode *c_rbtree_last(CRBTree *t) {
- assert(t);
+_c_public_ CRBNode *c_rbtree_last(CRBTree *t) {
+ c_assert(t);
return c_rbnode_rightmost(t->root);
}
@@ -319,8 +319,8 @@ _public_ CRBNode *c_rbtree_last(CRBTree *t) {
*
* Return: Pointer to first node in post-order, or NULL.
*/
-_public_ CRBNode *c_rbtree_first_postorder(CRBTree *t) {
- assert(t);
+_c_public_ CRBNode *c_rbtree_first_postorder(CRBTree *t) {
+ c_assert(t);
return c_rbnode_leftdeepest(t->root);
}
@@ -338,8 +338,8 @@ _public_ CRBNode *c_rbtree_first_postorder(CRBTree *t) {
*
* Return: Pointer to last node in post-order, or NULL.
*/
-_public_ CRBNode *c_rbtree_last_postorder(CRBTree *t) {
- assert(t);
+_c_public_ CRBNode *c_rbtree_last_postorder(CRBTree *t) {
+ c_assert(t);
return t->root;
}
@@ -452,15 +452,14 @@ static inline void c_rbnode_swap_child(CRBNode *old, CRBNode *new) {
* Note that this operates in O(1) time. Only the root-entry is updated to
* point to the new tree-root.
*/
-_public_ void c_rbtree_move(CRBTree *to, CRBTree *from) {
+_c_public_ void c_rbtree_move(CRBTree *to, CRBTree *from) {
CRBTree *t;
- assert(!to->root);
+ c_assert(!to->root);
if (from->root) {
t = c_rbnode_pop_root(from->root);
- assert(t == from);
- (void)t;
+ c_assert(t == from);
to->root = from->root;
from->root = NULL;
@@ -487,10 +486,10 @@ static inline void c_rbtree_paint_terminal(CRBNode *n) {
g = c_rbnode_parent(p);
gg = c_rbnode_parent(g);
- assert(c_rbnode_is_red(p));
- assert(c_rbnode_is_black(g));
- assert(p == g->left || !g->left || c_rbnode_is_black(g->left));
- assert(p == g->right || !g->right || c_rbnode_is_black(g->right));
+ c_assert(c_rbnode_is_red(p));
+ c_assert(c_rbnode_is_black(g));
+ c_assert(p == g->left || !g->left || c_rbnode_is_black(g->left));
+ c_assert(p == g->right || !g->right || c_rbnode_is_black(g->right));
if (p == g->left) {
if (n == p->right) {
@@ -674,11 +673,11 @@ static inline void c_rbtree_paint(CRBNode *n) {
* In most cases you are better off using c_rbtree_add(). See there for details
* how tree-insertion works.
*/
-_public_ void c_rbnode_link(CRBNode *p, CRBNode **l, CRBNode *n) {
- assert(p);
- assert(l);
- assert(n);
- assert(l == &p->left || l == &p->right);
+_c_public_ void c_rbnode_link(CRBNode *p, CRBNode **l, CRBNode *n) {
+ c_assert(p);
+ c_assert(l);
+ c_assert(n);
+ c_assert(l == &p->left || l == &p->right);
c_rbnode_set_parent_and_flags(n, p, C_RBNODE_RED);
c_rbtree_store(&n->left, NULL);
@@ -739,12 +738,12 @@ _public_ void c_rbnode_link(CRBNode *p, CRBNode **l, CRBNode *n) {
* than c_rbnode_unlink_stale()). In those cases, you should validate that a
* node is unlinked before you call c_rbtree_add().
*/
-_public_ void c_rbtree_add(CRBTree *t, CRBNode *p, CRBNode **l, CRBNode *n) {
- assert(t);
- assert(l);
- assert(n);
- assert(!p || l == &p->left || l == &p->right);
- assert(p || l == &t->root);
+_c_public_ void c_rbtree_add(CRBTree *t, CRBNode *p, CRBNode **l, CRBNode *n) {
+ c_assert(t);
+ c_assert(l);
+ c_assert(n);
+ c_assert(!p || l == &p->left || l == &p->right);
+ c_assert(p || l == &t->root);
c_rbnode_set_parent_and_flags(n, p, C_RBNODE_RED);
c_rbtree_store(&n->left, NULL);
@@ -796,7 +795,7 @@ static inline void c_rbnode_rebalance_terminal(CRBNode *p, CRBNode *previous) {
* Note that the parent must be red, otherwise
* it must have been handled by our caller.
*/
- assert(c_rbnode_is_red(p));
+ c_assert(c_rbnode_is_red(p));
c_rbnode_set_parent_and_flags(s, p, c_rbnode_flags(s) | C_RBNODE_RED);
c_rbnode_set_parent_and_flags(p, c_rbnode_parent(p), c_rbnode_flags(p) & ~C_RBNODE_RED);
return;
@@ -856,7 +855,7 @@ static inline void c_rbnode_rebalance_terminal(CRBNode *p, CRBNode *previous) {
if (!x || c_rbnode_is_black(x)) {
y = s->right;
if (!y || c_rbnode_is_black(y)) {
- assert(c_rbnode_is_red(p));
+ c_assert(c_rbnode_is_red(p));
c_rbnode_set_parent_and_flags(s, p, c_rbnode_flags(s) | C_RBNODE_RED);
c_rbnode_set_parent_and_flags(p, c_rbnode_parent(p), c_rbnode_flags(p) & ~C_RBNODE_RED);
return;
@@ -963,11 +962,11 @@ static inline void c_rbnode_rebalance(CRBNode *n) {
* This does *NOT* reset @n to being unlinked. If you need this, use
* c_rbtree_unlink().
*/
-_public_ void c_rbnode_unlink_stale(CRBNode *n) {
+_c_public_ void c_rbnode_unlink_stale(CRBNode *n) {
CRBTree *t;
- assert(n);
- assert(c_rbnode_is_linked(n));
+ c_assert(n);
+ c_assert(c_rbnode_is_linked(n));
/*
* There are three distinct cases during node removal of a tree:
diff --git a/shared/c-rbtree/src/meson.build b/shared/c-rbtree/src/meson.build
index 47ccf63aaa..d0b4d63ce9 100644
--- a/shared/c-rbtree/src/meson.build
+++ b/shared/c-rbtree/src/meson.build
@@ -4,6 +4,10 @@
libcrbtree_symfile = join_paths(meson.current_source_dir(), 'libcrbtree.sym')
+libcrbtree_deps = [
+ dep_cstdaux,
+]
+
libcrbtree_private = static_library(
'crbtree-private',
[
@@ -13,12 +17,14 @@ libcrbtree_private = static_library(
'-fvisibility=hidden',
'-fno-common',
],
+ dependencies: libcrbtree_deps,
pic: true,
)
libcrbtree_shared = shared_library(
'crbtree',
objects: libcrbtree_private.extract_all_objects(),
+ dependencies: libcrbtree_deps,
install: not meson.is_subproject(),
soversion: 0,
link_depends: libcrbtree_symfile,
@@ -31,6 +37,7 @@ libcrbtree_shared = shared_library(
libcrbtree_dep = declare_dependency(
include_directories: include_directories('.'),
link_with: libcrbtree_private,
+ dependencies: libcrbtree_deps,
version: meson.project_version(),
)
diff --git a/shared/c-rbtree/src/test-api.c b/shared/c-rbtree/src/test-api.c
index 55c37af6c4..295f6b9b4c 100644
--- a/shared/c-rbtree/src/test-api.c
+++ b/shared/c-rbtree/src/test-api.c
@@ -9,7 +9,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#include "c-rbtree.h"
typedef struct TestNode {
diff --git a/shared/c-rbtree/src/test-basic.c b/shared/c-rbtree/src/test-basic.c
index 534a10966f..8fee646820 100644
--- a/shared/c-rbtree/src/test-basic.c
+++ b/shared/c-rbtree/src/test-basic.c
@@ -10,11 +10,11 @@
#undef NDEBUG
#include <assert.h>
+#include <c-stdaux.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include "c-rbtree.h"
#include "c-rbtree-private.h"
@@ -23,8 +23,8 @@ static size_t validate(CRBTree *t) {
CRBNode *n, *p, *o;
size_t count = 0;
- assert(t);
- assert(!t->root || c_rbnode_is_black(t->root));
+ c_assert(t);
+ c_assert(!t->root || c_rbnode_is_black(t->root));
/* traverse to left-most child, count black nodes */
i_black = 0;
@@ -52,29 +52,29 @@ static size_t validate(CRBTree *t) {
++count;
/* verify natural order */
- assert(n > o);
+ c_assert(n > o);
o = n;
/* verify consistency */
- assert(!n->right || c_rbnode_parent(n->right) == n);
- assert(!n->left || c_rbnode_parent(n->left) == n);
+ c_assert(!n->right || c_rbnode_parent(n->right) == n);
+ c_assert(!n->left || c_rbnode_parent(n->left) == n);
/* verify 2) */
if (!c_rbnode_parent(n))
- assert(c_rbnode_is_black(n));
+ c_assert(c_rbnode_is_black(n));
if (c_rbnode_is_red(n)) {
/* verify 4) */
- assert(!n->left || c_rbnode_is_black(n->left));
- assert(!n->right || c_rbnode_is_black(n->right));
+ c_assert(!n->left || c_rbnode_is_black(n->left));
+ c_assert(!n->right || c_rbnode_is_black(n->right));
} else {
/* verify 1) */
- assert(c_rbnode_is_black(n));
+ c_assert(c_rbnode_is_black(n));
}
/* verify 5) */
if (!n->left && !n->right)
- assert(i_black == n_black);
+ c_assert(i_black == n_black);
/* get next node */
if (n->right) {
@@ -106,9 +106,9 @@ static size_t validate(CRBTree *t) {
static void insert(CRBTree *t, CRBNode *n) {
CRBNode **i, *p;
- assert(t);
- assert(n);
- assert(!c_rbnode_is_linked(n));
+ c_assert(t);
+ c_assert(n);
+ c_assert(!c_rbnode_is_linked(n));
i = &t->root;
p = NULL;
@@ -117,7 +117,7 @@ static void insert(CRBTree *t, CRBNode *n) {
if (n < *i) {
i = &(*i)->left;
} else {
- assert(n > *i);
+ c_assert(n > *i);
i = &(*i)->right;
}
}
@@ -146,20 +146,20 @@ static void test_shuffle(void) {
/* allocate and initialize all nodes */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
nodes[i] = malloc(sizeof(*nodes[i]));
- assert(nodes[i]);
+ c_assert(nodes[i]);
c_rbnode_init(nodes[i]);
}
/* shuffle nodes and validate *empty* tree */
shuffle(nodes, sizeof(nodes) / sizeof(*nodes));
n = validate(&t);
- assert(n == 0);
+ c_assert(n == 0);
/* add all nodes and validate after each insertion */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
insert(&t, nodes[i]);
n = validate(&t);
- assert(n == i + 1);
+ c_assert(n == i + 1);
}
/* shuffle nodes again */
@@ -169,19 +169,19 @@ static void test_shuffle(void) {
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
c_rbnode_unlink(nodes[i]);
n = validate(&t);
- assert(n == sizeof(nodes) / sizeof(*nodes) - i - 1);
+ c_assert(n == sizeof(nodes) / sizeof(*nodes) - i - 1);
}
/* shuffle nodes and validate *empty* tree again */
shuffle(nodes, sizeof(nodes) / sizeof(*nodes));
n = validate(&t);
- assert(n == 0);
+ c_assert(n == 0);
/* add all nodes again */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
insert(&t, nodes[i]);
n = validate(&t);
- assert(n == i + 1);
+ c_assert(n == i + 1);
}
/* 4 times, remove half of the nodes and add them again */
@@ -193,7 +193,7 @@ static void test_shuffle(void) {
for (i = 0; i < sizeof(nodes) / sizeof(*nodes) / 2; ++i) {
c_rbnode_unlink(nodes[i]);
n = validate(&t);
- assert(n == sizeof(nodes) / sizeof(*nodes) - i - 1);
+ c_assert(n == sizeof(nodes) / sizeof(*nodes) - i - 1);
}
/* shuffle the removed half */
@@ -203,7 +203,7 @@ static void test_shuffle(void) {
for (i = 0; i < sizeof(nodes) / sizeof(*nodes) / 2; ++i) {
insert(&t, nodes[i]);
n = validate(&t);
- assert(n == sizeof(nodes) / sizeof(*nodes) / 2 + i + 1);
+ c_assert(n == sizeof(nodes) / sizeof(*nodes) / 2 + i + 1);
}
}
@@ -214,7 +214,7 @@ static void test_shuffle(void) {
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
c_rbnode_unlink(nodes[i]);
n = validate(&t);
- assert(n == sizeof(nodes) / sizeof(*nodes) - i - 1);
+ c_assert(n == sizeof(nodes) / sizeof(*nodes) - i - 1);
}
/* free nodes again */
diff --git a/shared/c-rbtree/src/test-map.c b/shared/c-rbtree/src/test-map.c
index 3601ee495e..48a300d6f4 100644
--- a/shared/c-rbtree/src/test-map.c
+++ b/shared/c-rbtree/src/test-map.c
@@ -6,11 +6,11 @@
#undef NDEBUG
#include <assert.h>
+#include <c-stdaux.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include "c-rbtree.h"
#include "c-rbtree-private.h"
@@ -50,7 +50,7 @@ static void test_map(void) {
/* allocate and initialize all nodes */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
nodes[i] = malloc(sizeof(*nodes[i]));
- assert(nodes[i]);
+ c_assert(nodes[i]);
nodes[i]->key = i;
nodes[i]->marker = 0;
c_rbnode_init(&nodes[i]->rb);
@@ -61,15 +61,15 @@ static void test_map(void) {
/* add all nodes, and verify that each node is linked */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
- assert(!c_rbnode_is_linked(&nodes[i]->rb));
- assert(!c_rbtree_find_entry(&t, test_compare, (void *)nodes[i]->key, Node, rb));
+ c_assert(!c_rbnode_is_linked(&nodes[i]->rb));
+ c_assert(!c_rbtree_find_entry(&t, test_compare, (void *)nodes[i]->key, Node, rb));
slot = c_rbtree_find_slot(&t, test_compare, (void *)nodes[i]->key, &p);
- assert(slot);
+ c_assert(slot);
c_rbtree_add(&t, p, slot, &nodes[i]->rb);
- assert(c_rbnode_is_linked(&nodes[i]->rb));
- assert(nodes[i] == c_rbtree_find_entry(&t, test_compare, (void *)nodes[i]->key, Node, rb));
+ c_assert(c_rbnode_is_linked(&nodes[i]->rb));
+ c_assert(nodes[i] == c_rbtree_find_entry(&t, test_compare, (void *)nodes[i]->key, Node, rb));
}
/* verify in-order traversal works */
@@ -77,128 +77,128 @@ static void test_map(void) {
v = 0;
for (p = c_rbtree_first(&t); p; p = c_rbnode_next(p)) {
++i;
- assert(!node_from_rb(p)->marker);
+ c_assert(!node_from_rb(p)->marker);
node_from_rb(p)->marker = 1;
- assert(v <= node_from_rb(p)->key);
+ c_assert(v <= node_from_rb(p)->key);
v = node_from_rb(p)->key;
- assert(!c_rbnode_next(p) || p == c_rbnode_prev(c_rbnode_next(p)));
+ c_assert(!c_rbnode_next(p) || p == c_rbnode_prev(c_rbnode_next(p)));
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
/* verify reverse in-order traversal works */
i = 0;
v = -1;
for (p = c_rbtree_last(&t); p; p = c_rbnode_prev(p)) {
++i;
- assert(node_from_rb(p)->marker);
+ c_assert(node_from_rb(p)->marker);
node_from_rb(p)->marker = 0;
- assert(v >= node_from_rb(p)->key);
+ c_assert(v >= node_from_rb(p)->key);
v = node_from_rb(p)->key;
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
/* verify post-order traversal works */
i = 0;
for (p = c_rbtree_first_postorder(&t); p; p = c_rbnode_next_postorder(p)) {
++i;
- assert(!node_from_rb(p)->marker);
- assert(!c_rbnode_parent(p) || !node_from_rb(c_rbnode_parent(p))->marker);
- assert(!p->left || node_from_rb(p->left)->marker);
- assert(!p->right || node_from_rb(p->right)->marker);
+ c_assert(!node_from_rb(p)->marker);
+ c_assert(!c_rbnode_parent(p) || !node_from_rb(c_rbnode_parent(p))->marker);
+ c_assert(!p->left || node_from_rb(p->left)->marker);
+ c_assert(!p->right || node_from_rb(p->right)->marker);
node_from_rb(p)->marker = 1;
- assert(!c_rbnode_next_postorder(p) || p == c_rbnode_prev_postorder(c_rbnode_next_postorder(p)));
+ c_assert(!c_rbnode_next_postorder(p) || p == c_rbnode_prev_postorder(c_rbnode_next_postorder(p)));
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
/* verify pre-order (inverse post-order) traversal works */
i = 0;
for (p = c_rbtree_last_postorder(&t); p; p = c_rbnode_prev_postorder(p)) {
++i;
- assert(node_from_rb(p)->marker);
- assert(!c_rbnode_parent(p) || !node_from_rb(c_rbnode_parent(p))->marker);
- assert(!p->left || node_from_rb(p->left)->marker);
- assert(!p->right || node_from_rb(p->right)->marker);
+ c_assert(node_from_rb(p)->marker);
+ c_assert(!c_rbnode_parent(p) || !node_from_rb(c_rbnode_parent(p))->marker);
+ c_assert(!p->left || node_from_rb(p->left)->marker);
+ c_assert(!p->right || node_from_rb(p->right)->marker);
node_from_rb(p)->marker = 0;
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
/* verify in-order traversal works via helper */
i = 0;
v = 0;
c_rbtree_for_each(p, &t) {
++i;
- assert(!node_from_rb(p)->marker);
+ c_assert(!node_from_rb(p)->marker);
node_from_rb(p)->marker = 1;
- assert(v <= node_from_rb(p)->key);
+ c_assert(v <= node_from_rb(p)->key);
v = node_from_rb(p)->key;
- assert(!c_rbnode_next(p) || p == c_rbnode_prev(c_rbnode_next(p)));
+ c_assert(!c_rbnode_next(p) || p == c_rbnode_prev(c_rbnode_next(p)));
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
/* verify in-order traversal works via entry-helper */
i = 0;
v = 0;
c_rbtree_for_each_entry(n, &t, rb) {
++i;
- assert(n->marker);
+ c_assert(n->marker);
n->marker = 0;
- assert(v <= n->key);
+ c_assert(v <= n->key);
v = n->key;
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
/* verify post-order traversal works via helper */
i = 0;
c_rbtree_for_each_postorder(p, &t) {
++i;
- assert(!node_from_rb(p)->marker);
- assert(!c_rbnode_parent(p) || !node_from_rb(c_rbnode_parent(p))->marker);
- assert(!p->left || node_from_rb(p->left)->marker);
- assert(!p->right || node_from_rb(p->right)->marker);
+ c_assert(!node_from_rb(p)->marker);
+ c_assert(!c_rbnode_parent(p) || !node_from_rb(c_rbnode_parent(p))->marker);
+ c_assert(!p->left || node_from_rb(p->left)->marker);
+ c_assert(!p->right || node_from_rb(p->right)->marker);
node_from_rb(p)->marker = 1;
- assert(!c_rbnode_next_postorder(p) || p == c_rbnode_prev_postorder(c_rbnode_next_postorder(p)));
+ c_assert(!c_rbnode_next_postorder(p) || p == c_rbnode_prev_postorder(c_rbnode_next_postorder(p)));
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
/* verify post-order traversal works via entry-helper */
i = 0;
c_rbtree_for_each_entry_postorder(n, &t, rb) {
++i;
- assert(n->marker);
- assert(!c_rbnode_parent(&n->rb) || node_from_rb(c_rbnode_parent(&n->rb))->marker);
- assert(!n->rb.left || !node_from_rb(n->rb.left)->marker);
- assert(!n->rb.right || !node_from_rb(n->rb.right)->marker);
+ c_assert(n->marker);
+ c_assert(!c_rbnode_parent(&n->rb) || node_from_rb(c_rbnode_parent(&n->rb))->marker);
+ c_assert(!n->rb.left || !node_from_rb(n->rb.left)->marker);
+ c_assert(!n->rb.right || !node_from_rb(n->rb.right)->marker);
n->marker = 0;
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
/* shuffle nodes again */
shuffle(nodes, sizeof(nodes) / sizeof(*nodes));
/* remove all nodes (in different order) */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
- assert(c_rbnode_is_linked(&nodes[i]->rb));
- assert(nodes[i] == c_rbtree_find_entry(&t, test_compare, (void *)nodes[i]->key, Node, rb));
+ c_assert(c_rbnode_is_linked(&nodes[i]->rb));
+ c_assert(nodes[i] == c_rbtree_find_entry(&t, test_compare, (void *)nodes[i]->key, Node, rb));
c_rbnode_unlink(&nodes[i]->rb);
- assert(!c_rbnode_is_linked(&nodes[i]->rb));
- assert(!c_rbtree_find_entry(&t, test_compare, (void *)nodes[i]->key, Node, rb));
+ c_assert(!c_rbnode_is_linked(&nodes[i]->rb));
+ c_assert(!c_rbtree_find_entry(&t, test_compare, (void *)nodes[i]->key, Node, rb));
}
- assert(c_rbtree_is_empty(&t));
+ c_assert(c_rbtree_is_empty(&t));
/* add all nodes again */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
slot = c_rbtree_find_slot(&t, test_compare, (void *)nodes[i]->key, &p);
- assert(slot);
+ c_assert(slot);
c_rbtree_add(&t, p, slot, &nodes[i]->rb);
}
@@ -208,13 +208,13 @@ static void test_map(void) {
++i;
c_rbnode_unlink(p);
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
- assert(c_rbtree_is_empty(&t));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(c_rbtree_is_empty(&t));
/* add all nodes again */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
slot = c_rbtree_find_slot(&t, test_compare, (void *)nodes[i]->key, &p);
- assert(slot);
+ c_assert(slot);
c_rbtree_add(&t, p, slot, &nodes[i]->rb);
}
@@ -224,13 +224,13 @@ static void test_map(void) {
++i;
c_rbnode_unlink(&n->rb);
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
- assert(c_rbtree_is_empty(&t));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(c_rbtree_is_empty(&t));
/* add all nodes again */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
slot = c_rbtree_find_slot(&t, test_compare, (void *)nodes[i]->key, &p);
- assert(slot);
+ c_assert(slot);
c_rbtree_add(&t, p, slot, &nodes[i]->rb);
}
@@ -238,15 +238,15 @@ static void test_map(void) {
i = 0;
c_rbtree_for_each_safe_postorder_unlink(p, safe_p, &t) {
++i;
- assert(!c_rbnode_is_linked(p));
+ c_assert(!c_rbnode_is_linked(p));
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
- assert(c_rbtree_is_empty(&t));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(c_rbtree_is_empty(&t));
/* add all nodes again */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
slot = c_rbtree_find_slot(&t, test_compare, (void *)nodes[i]->key, &p);
- assert(slot);
+ c_assert(slot);
c_rbtree_add(&t, p, slot, &nodes[i]->rb);
}
@@ -254,18 +254,18 @@ static void test_map(void) {
i = 0;
c_rbtree_for_each_entry_safe_postorder_unlink(n, safe_n, &t, rb) {
++i;
- assert(!c_rbnode_is_linked(&n->rb));
+ c_assert(!c_rbnode_is_linked(&n->rb));
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
- assert(c_rbtree_is_empty(&t));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(c_rbtree_is_empty(&t));
/* free nodes again */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
- assert(!nodes[i]->marker);
+ c_assert(!nodes[i]->marker);
free(nodes[i]);
}
- assert(c_rbtree_is_empty(&t));
+ c_assert(c_rbtree_is_empty(&t));
}
int main(int argc, char **argv) {
diff --git a/shared/c-rbtree/src/test-misc.c b/shared/c-rbtree/src/test-misc.c
index e5b3289c3c..ac2717cdc0 100644
--- a/shared/c-rbtree/src/test-misc.c
+++ b/shared/c-rbtree/src/test-misc.c
@@ -5,19 +5,19 @@
#undef NDEBUG
#include <assert.h>
+#include <c-stdaux.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#include "c-rbtree.h"
#include "c-rbtree-private.h"
static void insert(CRBTree *t, CRBNode *n) {
CRBNode **i, *p;
- assert(t);
- assert(n);
- assert(!c_rbnode_is_linked(n));
+ c_assert(t);
+ c_assert(n);
+ c_assert(!c_rbnode_is_linked(n));
i = &t->root;
p = NULL;
@@ -26,7 +26,7 @@ static void insert(CRBTree *t, CRBNode *n) {
if (n < *i) {
i = &(*i)->left;
} else {
- assert(n > *i);
+ c_assert(n > *i);
i = &(*i)->right;
}
}
@@ -44,19 +44,19 @@ static void test_move(void) {
insert(&t1, &n[i]);
}
- assert(!c_rbtree_is_empty(&t1));
- assert(c_rbtree_is_empty(&t2));
+ c_assert(!c_rbtree_is_empty(&t1));
+ c_assert(c_rbtree_is_empty(&t2));
c_rbtree_move(&t2, &t1);
- assert(c_rbtree_is_empty(&t1));
- assert(!c_rbtree_is_empty(&t2));
+ c_assert(c_rbtree_is_empty(&t1));
+ c_assert(!c_rbtree_is_empty(&t2));
while (t2.root)
c_rbnode_unlink(t2.root);
- assert(c_rbtree_is_empty(&t1));
- assert(c_rbtree_is_empty(&t2));
+ c_assert(c_rbtree_is_empty(&t1));
+ c_assert(c_rbtree_is_empty(&t2));
}
int main(int argc, char **argv) {
diff --git a/shared/c-rbtree/src/test-parallel.c b/shared/c-rbtree/src/test-parallel.c
index 4513d9ece2..1388722bf3 100644
--- a/shared/c-rbtree/src/test-parallel.c
+++ b/shared/c-rbtree/src/test-parallel.c
@@ -30,6 +30,7 @@
#undef NDEBUG
#include <assert.h>
+#include <c-stdaux.h>
#include <errno.h>
#include <inttypes.h>
#include <sched.h>
@@ -46,7 +47,6 @@
#include <sys/syscall.h>
#include <time.h>
#include <unistd.h>
-
#include "c-rbtree.h"
#include "c-rbtree-private.h"
@@ -132,7 +132,7 @@ static void test_parent_start(TestContext *ctx) {
ctx->mapsize += ctx->n_nodes * sizeof(CRBNode*);
ctx->map = mmap(NULL, ctx->mapsize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
- assert(ctx->map != MAP_FAILED);
+ c_assert(ctx->map != MAP_FAILED);
ctx->tree = (void *)ctx->map;
ctx->node_mem = (void *)(ctx->tree + 1);
@@ -161,10 +161,10 @@ static void test_parent_end(TestContext *ctx) {
int r;
for (i = 0; i < ctx->n_nodes; ++i)
- assert(!c_rbnode_is_linked(ctx->nodes[i]));
+ c_assert(!c_rbnode_is_linked(ctx->nodes[i]));
r = munmap(ctx->map, ctx->mapsize);
- assert(r >= 0);
+ c_assert(r >= 0);
}
static void test_parent_step(TestContext *ctx) {
@@ -176,13 +176,13 @@ static void test_parent_step(TestContext *ctx) {
while (n) {
/* verify that we haven't visited @n, yet */
- assert(!fetch_visit(n));
+ c_assert(!fetch_visit(n));
/* verify @n is a valid node */
for (i = 0; i < ctx->n_nodes; ++i)
if (n == ctx->nodes[i])
break;
- assert(i < ctx->n_nodes);
+ c_assert(i < ctx->n_nodes);
/* pre-order traversal and marker for cycle detection */
if (n->left) {
@@ -256,7 +256,7 @@ static int test_parallel(void) {
/* run child */
pid = fork();
- assert(pid >= 0);
+ c_assert(pid >= 0);
if (pid == 0) {
r = test_parallel_child(&ctx);
_exit(r);
@@ -293,7 +293,7 @@ static int test_parallel(void) {
if (r < 0 && errno == EIO)
return 77;
- assert(r >= 0);
+ c_assert(r >= 0);
break;
case SIGURG:
@@ -302,7 +302,7 @@ static int test_parallel(void) {
/* step child */
r = ptrace(PTRACE_SINGLESTEP, pid, 0, 0);
- assert(r >= 0);
+ c_assert(r >= 0);
break;
case SIGUSR2:
@@ -311,7 +311,7 @@ static int test_parallel(void) {
/* continue child */
r = ptrace(PTRACE_CONT, pid, 0, 0);
- assert(r >= 0);
+ c_assert(r >= 0);
break;
case SIGTRAP:
@@ -320,18 +320,18 @@ static int test_parallel(void) {
/* step repeatedly as long as we get SIGTRAP */
r = ptrace(PTRACE_SINGLESTEP, pid, 0, 0);
- assert(r >= 0);
+ c_assert(r >= 0);
break;
default:
- assert(0);
+ c_assert(0);
break;
}
}
/* verify our child exited cleanly */
- assert(r == pid);
- assert(!!WIFEXITED(status));
+ c_assert(r == pid);
+ c_assert(!!WIFEXITED(status));
/*
* 0xdf is signalled if ptrace is not allowed or we are already
@@ -347,15 +347,15 @@ static int test_parallel(void) {
case 0xdf:
return 77;
default:
- assert(0);
+ c_assert(0);
break;
}
/* verify we hit all child states */
- assert(n_event & 0x1);
- assert(n_event & 0x2);
- assert(n_event & 0x4);
- assert(n_instr > 0);
+ c_assert(n_event & 0x1);
+ c_assert(n_event & 0x2);
+ c_assert(n_event & 0x4);
+ c_assert(n_instr > 0);
return 0;
}
diff --git a/shared/c-rbtree/src/test-posix.c b/shared/c-rbtree/src/test-posix.c
index 213d85fefe..ee100ec52e 100644
--- a/shared/c-rbtree/src/test-posix.c
+++ b/shared/c-rbtree/src/test-posix.c
@@ -42,6 +42,7 @@
#undef NDEBUG
#include <assert.h>
+#include <c-stdaux.h>
#include <inttypes.h>
#include <limits.h>
#include <search.h>
@@ -49,7 +50,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include "c-rbtree.h"
#include "c-rbtree-private.h"
@@ -85,7 +85,7 @@ static uint64_t now(void) {
int r;
r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
- assert(r >= 0);
+ c_assert(r >= 0);
return ts.tv_sec * UINT64_C(1000000000) + ts.tv_nsec;
}
@@ -116,14 +116,14 @@ static void posix_rbtree_add(PosixRBTree *t, const Node *node) {
void *res;
res = tsearch(&node->key, &t->root, posix_rbtree_compare);
- assert(*(int **)res == &node->key);
+ c_assert(*(int **)res == &node->key);
}
static void posix_rbtree_remove(PosixRBTree *t, const Node *node) {
void *res;
res = tdelete(&node->key, &t->root, posix_rbtree_compare);
- assert(res);
+ c_assert(res);
}
static Node *posix_rbtree_find(PosixRBTree *t, int key) {
@@ -143,7 +143,7 @@ static void posix_rbtree_visit(const void *n, const VISIT o, const int depth) {
switch (o) {
case postorder:
case leaf:
- assert(v <= node_from_key(*(int **)n)->key);
+ c_assert(v <= node_from_key(*(int **)n)->key);
v = node_from_key(*(int **)n)->key;
break;
default:
@@ -178,7 +178,7 @@ static void test_posix(void) {
/* allocate and initialize all nodes */
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
nodes[i] = malloc(sizeof(*nodes[i]));
- assert(nodes[i]);
+ c_assert(nodes[i]);
nodes[i]->key = i;
c_rbnode_init(&nodes[i]->rb);
}
@@ -190,7 +190,7 @@ static void test_posix(void) {
ts = now();
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i) {
slot = c_rbtree_find_slot(&t, compare, (void *)(unsigned long)nodes[i]->key, &p);
- assert(slot);
+ c_assert(slot);
c_rbtree_add(&t, p, slot, &nodes[i]->rb);
}
ts_c1 = now() - ts;
@@ -210,10 +210,10 @@ static void test_posix(void) {
for (p = c_rbtree_first(&t); p; p = c_rbnode_next(p)) {
++i;
- assert(v <= node_from_rb(p)->key);
+ c_assert(v <= node_from_rb(p)->key);
v = node_from_rb(p)->key;
}
- assert(i == sizeof(nodes) / sizeof(*nodes));
+ c_assert(i == sizeof(nodes) / sizeof(*nodes));
ts_c2 = now() - ts;
ts = now();
@@ -226,14 +226,14 @@ static void test_posix(void) {
/* lookup all nodes (in different order) */
ts = now();
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i)
- assert(nodes[i] == c_rbtree_find_entry(&t, compare,
+ c_assert(nodes[i] == c_rbtree_find_entry(&t, compare,
(void *)(unsigned long)nodes[i]->key,
Node, rb));
ts_c3 = now() - ts;
ts = now();
for (i = 0; i < sizeof(nodes) / sizeof(*nodes); ++i)
- assert(nodes[i] == posix_rbtree_find(&pt, nodes[i]->key));
+ c_assert(nodes[i] == posix_rbtree_find(&pt, nodes[i]->key));
ts_p3 = now() - ts;
/* shuffle nodes again */
diff --git a/shared/c-rbtree/subprojects/c-stdaux b/shared/c-rbtree/subprojects/c-stdaux
new file mode 160000
+Subproject 1bcec740f7ee1d2e71f84ac574f70fb4ec30539
diff --git a/shared/c-siphash/.gitmodules b/shared/c-siphash/.gitmodules
new file mode 100644
index 0000000000..a86b29fd1c
--- /dev/null
+++ b/shared/c-siphash/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "subprojects/c-stdaux"]
+ path = subprojects/c-stdaux
+ url = https://github.com/c-util/c-stdaux.git
diff --git a/shared/c-siphash/AUTHORS b/shared/c-siphash/AUTHORS
index 980d602337..b59660c5ee 100644
--- a/shared/c-siphash/AUTHORS
+++ b/shared/c-siphash/AUTHORS
@@ -30,8 +30,8 @@ AUTHORS-LGPL:
along with this program; If not, see <http://www.gnu.org/licenses/>.
COPYRIGHT: (ordered alphabetically)
- Copyright (C) 2015-2018 Red Hat, Inc.
+ Copyright (C) 2015-2019 Red Hat, Inc.
AUTHORS: (ordered alphabetically)
- David Herrmann <dh.herrmann@gmail.com>
+ David Rheinsberg <david.rheinsberg@gmail.com>
Tom Gundersen <teg@jklm.no>
diff --git a/shared/c-siphash/AUTHORS-ASL b/shared/c-siphash/AUTHORS-ASL
deleted file mode 100644
index 5d501a7284..0000000000
--- a/shared/c-siphash/AUTHORS-ASL
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright {yyyy} {name of copyright owner}
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/shared/c-siphash/AUTHORS-LGPL b/shared/c-siphash/AUTHORS-LGPL
deleted file mode 100644
index 4362b49151..0000000000
--- a/shared/c-siphash/AUTHORS-LGPL
+++ /dev/null
@@ -1,502 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library 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.
-
- This library 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 this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/shared/c-siphash/LICENSE b/shared/c-siphash/LICENSE
deleted file mode 120000
index da24c5e4a6..0000000000
--- a/shared/c-siphash/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-AUTHORS-ASL \ No newline at end of file
diff --git a/shared/c-siphash/NEWS.md b/shared/c-siphash/NEWS.md
new file mode 100644
index 0000000000..0110711ff7
--- /dev/null
+++ b/shared/c-siphash/NEWS.md
@@ -0,0 +1,11 @@
+# c-siphash - Streaming-capable SipHash Implementation
+
+## CHANGES WITH 1:
+
+ * Initial release of c-siphash.
+
+ * TBD
+
+ Contributions from: TBD
+
+ - TBD, YYYY-MM-DD
diff --git a/shared/c-siphash/README b/shared/c-siphash/README
deleted file mode 100644
index 156fc8c0f6..0000000000
--- a/shared/c-siphash/README
+++ /dev/null
@@ -1,51 +0,0 @@
-c-siphash - Streaming-capable SipHash Implementation
-
-ABOUT:
- The c-siphash project is a standalone implementation of SipHash in
- Standard ISO-C11. It provides a streaming-capable API to compute data
- hashes according to the SipHash algorithm.
-
- For API documentation, see the c-siphash.h header file, as well as the
- docbook comments for each function.
-
-DETAILS:
- https://c-util.github.io/c-siphash
-
-BUG REPORTS:
- https://github.com/c-util/c-siphash/issues
-
-GIT:
- git@github.com:c-util/c-siphash.git
- https://github.com/c-util/c-siphash.git
-
-GITWEB:
- https://github.com/c-util/c-siphash
-
-LICENSE:
- Apache Software License 2.0
- Lesser General Public License 2.1+
- See AUTHORS for details.
-
-REQUIREMENTS:
- The requirements for c-siphash are:
-
- libc (e.g., glibc >= 2.16)
-
- At build-time, the following software is required:
-
- meson >= 0.41
- pkg-config >= 0.29
-
-INSTALL:
- The meson build-system is used for this project. Contact upstream
- documentation for detailed help. In most situations the following
- commands are sufficient to build and install from source:
-
- $ mkdir build
- $ cd build
- $ meson setup ..
- $ ninja
- $ meson test
- # ninja install
-
- No custom configuration options are available.
diff --git a/shared/c-siphash/README.md b/shared/c-siphash/README.md
new file mode 100644
index 0000000000..ba09041be4
--- /dev/null
+++ b/shared/c-siphash/README.md
@@ -0,0 +1,53 @@
+c-siphash
+=========
+
+Streaming-capable SipHash Implementation
+
+The c-siphash project is a standalone implementation of SipHash in Standard
+ISO-C11. It provides a streaming-capable API to compute data hashes according
+to the SipHash algorithm. For API documentation, see the c-siphash.h header
+file, as well as the docbook comments for each function.
+
+### Project
+
+ * **Website**: <https://c-util.github.io/c-siphash>
+ * **Bug Tracker**: <https://github.com/c-util/c-siphash/issues>
+
+### Requirements
+
+The requirements for this project are:
+
+ * `libc` (e.g., `glibc >= 2.16`)
+
+At build-time, the following software is required:
+
+ * `meson >= 0.41`
+ * `pkg-config >= 0.29`
+
+### Build
+
+The meson build-system is used for this project. Contact upstream
+documentation for detailed help. In most situations the following
+commands are sufficient to build and install from source:
+
+```sh
+mkdir build
+cd build
+meson setup ..
+ninja
+meson test
+ninja install
+```
+
+No custom configuration options are available.
+
+### Repository:
+
+ - **web**: <https://github.com/c-util/c-siphash>
+ - **https**: `https://github.com/c-util/c-siphash.git`
+ - **ssh**: `git@github.com:c-util/c-siphash.git`
+
+### License:
+
+ - **Apache-2.0** OR **LGPL-2.1-or-later**
+ - See AUTHORS file for details.
diff --git a/shared/c-siphash/meson.build b/shared/c-siphash/meson.build
index befeac4865..2b07b019b3 100644
--- a/shared/c-siphash/meson.build
+++ b/shared/c-siphash/meson.build
@@ -12,4 +12,8 @@ project_description = 'Streaming-capable SipHash Implementation'
add_project_arguments('-D_GNU_SOURCE', language: 'c')
mod_pkgconfig = import('pkgconfig')
+sub_cstdaux = subproject('c-stdaux')
+
+dep_cstdaux = sub_cstdaux.get_variable('libcstdaux_dep')
+
subdir('src')
diff --git a/shared/c-siphash/src/c-siphash.c b/shared/c-siphash/src/c-siphash.c
index 5cea6f2b52..fae3abadd7 100644
--- a/shared/c-siphash/src/c-siphash.c
+++ b/shared/c-siphash/src/c-siphash.c
@@ -11,12 +11,11 @@
* C_siphash_finalize_Y() can be easily provided, if required.
*/
+#include <c-stdaux.h>
#include <stddef.h>
#include <stdint.h>
#include "c-siphash.h"
-#define _public_ __attribute__((__visibility__("default")))
-
static inline uint64_t c_siphash_read_le64(const uint8_t bytes[8]) {
return ((uint64_t) bytes[0]) |
(((uint64_t) bytes[1]) << 8) |
@@ -68,7 +67,7 @@ static inline void c_siphash_sipround(CSipHash *state) {
* Right now, only SipHash24 is supported. Other SipHash parameters can be
* easily added if required.
*/
-_public_ void c_siphash_init(CSipHash *state, const uint8_t seed[16]) {
+_c_public_ void c_siphash_init(CSipHash *state, const uint8_t seed[16]) {
uint64_t k0, k1;
k0 = c_siphash_read_le64(seed);
@@ -105,7 +104,7 @@ _public_ void c_siphash_init(CSipHash *state, const uint8_t seed[16]) {
* Note that this implementation works best when used with chunk-sizes of
* multiples of 64bit (8-bytes). This is not a requirement, though.
*/
-_public_ void c_siphash_append(CSipHash *state, const uint8_t *bytes, size_t n_bytes) {
+_c_public_ void c_siphash_append(CSipHash *state, const uint8_t *bytes, size_t n_bytes) {
const uint8_t *end = bytes + n_bytes;
size_t left = state->n_bytes & 7;
uint64_t m;
@@ -195,7 +194,7 @@ _public_ void c_siphash_append(CSipHash *state, const uint8_t *bytes, size_t n_b
*
* Return: 64bit hash value
*/
-_public_ uint64_t c_siphash_finalize(CSipHash *state) {
+_c_public_ uint64_t c_siphash_finalize(CSipHash *state) {
uint64_t b;
b = state->padding | (((uint64_t) state->n_bytes) << 56);
@@ -236,7 +235,7 @@ _public_ uint64_t c_siphash_finalize(CSipHash *state) {
*
* Return: 64bit hash value
*/
-_public_ uint64_t c_siphash_hash(const uint8_t seed[16], const uint8_t *bytes, size_t n_bytes) {
+_c_public_ uint64_t c_siphash_hash(const uint8_t seed[16], const uint8_t *bytes, size_t n_bytes) {
CSipHash state;
c_siphash_init(&state, seed);
diff --git a/shared/c-siphash/src/meson.build b/shared/c-siphash/src/meson.build
index e5f26bfff7..7ee9c601e7 100644
--- a/shared/c-siphash/src/meson.build
+++ b/shared/c-siphash/src/meson.build
@@ -4,6 +4,10 @@
libcsiphash_symfile = join_paths(meson.current_source_dir(), 'libcsiphash.sym')
+libcsiphash_deps = [
+ dep_cstdaux,
+]
+
libcsiphash_private = static_library(
'csiphash-private',
[
@@ -13,12 +17,14 @@ libcsiphash_private = static_library(
'-fvisibility=hidden',
'-fno-common',
],
+ dependencies: libcsiphash_deps,
pic: true,
)
libcsiphash_shared = shared_library(
'csiphash',
objects: libcsiphash_private.extract_all_objects(),
+ dependencies: libcsiphash_deps,
install: not meson.is_subproject(),
soversion: 0,
link_depends: libcsiphash_symfile,
@@ -31,6 +37,7 @@ libcsiphash_shared = shared_library(
libcsiphash_dep = declare_dependency(
include_directories: include_directories('.'),
link_with: libcsiphash_private,
+ dependencies: libcsiphash_deps,
version: meson.project_version(),
)
diff --git a/shared/c-siphash/src/test-api.c b/shared/c-siphash/src/test-api.c
index 4ee4f8203b..8075a17ff4 100644
--- a/shared/c-siphash/src/test-api.c
+++ b/shared/c-siphash/src/test-api.c
@@ -9,7 +9,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#include "c-siphash.h"
static void test_api(void) {
diff --git a/shared/c-siphash/src/test-basic.c b/shared/c-siphash/src/test-basic.c
index a006180f67..6b80d0cdfa 100644
--- a/shared/c-siphash/src/test-basic.c
+++ b/shared/c-siphash/src/test-basic.c
@@ -6,10 +6,10 @@
#undef NDEBUG
#include <assert.h>
+#include <c-stdaux.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#include "c-siphash.h"
/* See https://131002.net/siphash/siphash.pdf, Appendix A. */
@@ -20,21 +20,21 @@ static void do_reference_test(const uint8_t *in, size_t len, const uint8_t *key)
/* verify the internal state as given in the above paper */
c_siphash_init(&state, key);
- assert(state.v0 == 0x7469686173716475);
- assert(state.v1 == 0x6b617f6d656e6665);
- assert(state.v2 == 0x6b7f62616d677361);
- assert(state.v3 == 0x7b6b696e727e6c7b);
+ c_assert(state.v0 == 0x7469686173716475);
+ c_assert(state.v1 == 0x6b617f6d656e6665);
+ c_assert(state.v2 == 0x6b7f62616d677361);
+ c_assert(state.v3 == 0x7b6b696e727e6c7b);
c_siphash_append(&state, in, len);
- assert(state.v0 == 0x4a017198de0a59e0);
- assert(state.v1 == 0x0d52f6f62a4f59a4);
- assert(state.v2 == 0x634cb3577b01fd3d);
- assert(state.v3 == 0xa5224d6f55c7d9c8);
+ c_assert(state.v0 == 0x4a017198de0a59e0);
+ c_assert(state.v1 == 0x0d52f6f62a4f59a4);
+ c_assert(state.v2 == 0x634cb3577b01fd3d);
+ c_assert(state.v3 == 0xa5224d6f55c7d9c8);
out = c_siphash_finalize(&state);
- assert(out == 0xa129ca6149be45e5);
- assert(state.v0 == 0xf6bcd53893fecff1);
- assert(state.v1 == 0x54b9964c7ea0d937);
- assert(state.v2 == 0x1b38329c099bb55a);
- assert(state.v3 == 0x1814bb89ad7be679);
+ c_assert(out == 0xa129ca6149be45e5);
+ c_assert(state.v0 == 0xf6bcd53893fecff1);
+ c_assert(state.v1 == 0x54b9964c7ea0d937);
+ c_assert(state.v2 == 0x1b38329c099bb55a);
+ c_assert(state.v3 == 0x1814bb89ad7be679);
/* verify that decomposing the input in three chunks gives the
same result */
@@ -45,12 +45,12 @@ static void do_reference_test(const uint8_t *in, size_t len, const uint8_t *key)
c_siphash_append(&state, &in[i], j - i);
c_siphash_append(&state, &in[j], len - j);
out = c_siphash_finalize(&state);
- assert(out == 0xa129ca6149be45e5);
+ c_assert(out == 0xa129ca6149be45e5);
}
}
/* verify c_siphash_hash() produces the same result */
- assert(out == c_siphash_hash(key, in, len));
+ c_assert(out == c_siphash_hash(key, in, len));
}
static void test_reference(void) {
@@ -92,7 +92,7 @@ static void test_short_hashes(void) {
two[i-1] = one[i-1];
c_siphash_append(&state2, two, i);
- assert(memcmp(&state1, &state2, sizeof state1) == 0);
+ c_assert(memcmp(&state1, &state2, sizeof state1) == 0);
}
/* hashing n and 1, n and 2, n and 3, ..., n-1 and 1, n-2 and 2, ... */
@@ -107,7 +107,7 @@ static void test_short_hashes(void) {
two[j-1] = one[j-1];
c_siphash_append(&state2, two, j);
- assert(memcmp(&state1, &state2, sizeof state1) == 0);
+ c_assert(memcmp(&state1, &state2, sizeof state1) == 0);
}
}
}
diff --git a/shared/c-siphash/subprojects/c-stdaux b/shared/c-siphash/subprojects/c-stdaux
new file mode 160000
+Subproject 1bcec740f7ee1d2e71f84ac574f70fb4ec30539
diff --git a/shared/c-stdaux/.cherryci/ci-test b/shared/c-stdaux/.cherryci/ci-test
new file mode 100755
index 0000000000..8ce5f5f70e
--- /dev/null
+++ b/shared/c-stdaux/.cherryci/ci-test
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+rm -Rf "./ci-build"
+mkdir "./ci-build"
+cd "./ci-build"
+
+${CHERRY_LIB_MESONSETUP} . "${CHERRY_LIB_SRCDIR}"
+${CHERRY_LIB_NINJABUILD}
+${CHERRY_LIB_MESONTEST}
+(( ! CHERRY_LIB_VALGRIND )) || ${CHERRY_LIB_MESONTEST} "--wrapper=${CHERRY_LIB_VALGRINDWRAP}"
diff --git a/shared/c-stdaux/.editorconfig b/shared/c-stdaux/.editorconfig
new file mode 100644
index 0000000000..b10bb4f3f8
--- /dev/null
+++ b/shared/c-stdaux/.editorconfig
@@ -0,0 +1,11 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+charset = utf-8
+
+[*.{c,h}]
+indent_style = space
+indent_size = 8
diff --git a/shared/c-stdaux/.travis.yml b/shared/c-stdaux/.travis.yml
new file mode 100644
index 0000000000..99a7bb9461
--- /dev/null
+++ b/shared/c-stdaux/.travis.yml
@@ -0,0 +1,21 @@
+os: linux
+dist: trusty
+language: c
+
+services:
+ - docker
+
+before_install:
+ - curl -O -L "https://raw.githubusercontent.com/cherry-pick/cherry-images/v1/scripts/vmrun"
+ - curl -O -L "https://raw.githubusercontent.com/cherry-pick/cherry-ci/v1/scripts/cherryci"
+ - chmod +x "./vmrun" "./cherryci"
+
+jobs:
+ include:
+ - stage: test
+ script:
+ - ./vmrun -- ../src/cherryci -d ../src/.cherryci -s c-util -m
+ - script:
+ - ./vmrun -T armv7hl -- ../src/cherryci -d ../src/.cherryci -s c-util
+ - script:
+ - ./vmrun -T i686 -- ../src/cherryci -d ../src/.cherryci -s c-util
diff --git a/shared/c-stdaux/AUTHORS b/shared/c-stdaux/AUTHORS
new file mode 100644
index 0000000000..6015c4f31c
--- /dev/null
+++ b/shared/c-stdaux/AUTHORS
@@ -0,0 +1,38 @@
+LICENSE:
+ This project is dual-licensed under both the Apache License, Version
+ 2.0, and the GNU Lesser General Public License, Version 2.1+.
+
+AUTHORS-ASL:
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+AUTHORS-LGPL:
+ This program 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.
+
+ This program 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 this program; If not, see <http://www.gnu.org/licenses/>.
+
+COPYRIGHT: (ordered alphabetically)
+ Copyright (C) 2018-2019 Red Hat, Inc.
+
+AUTHORS: (ordered alphabetically)
+ David Rheinsberg <david.rheinsberg@gmail.com>
+ Thomas Haller <thaller@redhat.com>
+ Tom Gundersen <teg@jklm.no>
diff --git a/shared/c-stdaux/NEWS.md b/shared/c-stdaux/NEWS.md
new file mode 100644
index 0000000000..d51af4cf60
--- /dev/null
+++ b/shared/c-stdaux/NEWS.md
@@ -0,0 +1,11 @@
+# c-stdaux - Auxiliary macros and functions for the C standard library
+
+## CHANGES WITH 1:
+
+ * Initial release of c-stdaux.
+
+ * TBD
+
+ Contributions from: TBD
+
+ - TBD, YYYY-MM-DD
diff --git a/shared/c-stdaux/README.md b/shared/c-stdaux/README.md
new file mode 100644
index 0000000000..51bff9778f
--- /dev/null
+++ b/shared/c-stdaux/README.md
@@ -0,0 +1,53 @@
+c-stdaux
+========
+
+Auxiliary macros and functions for the C standard library
+
+The c-stdaux project contains support-macros and auxiliary functions around the
+functionality of common C standard libraries. This includes helpers for the
+ISO-C Standard Library, but also other common specifications like POSIX or
+common extended features of wide-spread compilers like gcc and clang.
+
+### Project
+
+ * **Website**: <https://c-util.github.io/c-stdaux>
+ * **Bug Tracker**: <https://github.com/c-util/c-stdaux/issues>
+
+### Requirements
+
+The requirements for this project are:
+
+ * `libc` (e.g., `glibc >= 2.16`)
+
+At build-time, the following software is required:
+
+ * `meson >= 0.41`
+ * `pkg-config >= 0.29`
+
+### Build
+
+The meson build-system is used for this project. Contact upstream
+documentation for detailed help. In most situations the following
+commands are sufficient to build and install from source:
+
+```sh
+mkdir build
+cd build
+meson setup ..
+ninja
+meson test
+ninja install
+```
+
+No custom configuration options are available.
+
+### Repository:
+
+ - **web**: <https://github.com/c-util/c-stdaux>
+ - **https**: `https://github.com/c-util/c-stdaux.git`
+ - **ssh**: `git@github.com:c-util/c-stdaux.git`
+
+### License:
+
+ - **Apache-2.0** OR **LGPL-2.1-or-later**
+ - See AUTHORS file for details.
diff --git a/shared/c-stdaux/meson.build b/shared/c-stdaux/meson.build
new file mode 100644
index 0000000000..c8c5da536f
--- /dev/null
+++ b/shared/c-stdaux/meson.build
@@ -0,0 +1,15 @@
+project(
+ 'c-stdaux',
+ 'c',
+ version: '1',
+ license: 'Apache',
+ default_options: [
+ 'c_std=c11'
+ ],
+)
+project_description = 'Auxiliary macros and functions for the C standard library'
+
+add_project_arguments('-D_GNU_SOURCE', language: 'c')
+mod_pkgconfig = import('pkgconfig')
+
+subdir('src')
diff --git a/shared/c-stdaux/src/c-stdaux.h b/shared/c-stdaux/src/c-stdaux.h
new file mode 100644
index 0000000000..08d155cebc
--- /dev/null
+++ b/shared/c-stdaux/src/c-stdaux.h
@@ -0,0 +1,546 @@
+#pragma once
+
+/*
+ * Auxiliary macros and functions for the C standard library
+ *
+ * The `c-stdaux.h` header contains a collection of auxiliary macros and helper
+ * functions around the functionality provided by the different C standard
+ * library implementations, as well as other specifications implemented by
+ * them.
+ *
+ * Most of the helpers provided here provide aliases for common library and
+ * compiler features. Furthermore, several helpers simply provide other calling
+ * conventions than their standard counterparts (e.g., they allow for NULL to
+ * be passed with an object length of 0 where it makes sense to accept empty
+ * input).
+ *
+ * The namespace used by this project is:
+ *
+ * * `c_*` for all common C symbols or definitions that behave like proper C
+ * entities (e.g., macros that protect against double-evaluation would use
+ * lower-case names)
+ *
+ * * `C_*` for all constants, as well as macros that may not be safe against
+ * double evaluation.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <stdalign.h>
+#include <stdarg.h>
+#if 0 /* NM_IGNORED */
+#include <stdatomic.h>
+#endif /* NM_IGNORED */
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdnoreturn.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
+
+/*
+ * Shortcuts for gcc attributes. See GCC manual for details. They're 1-to-1
+ * mappings to the GCC equivalents. No additional magic here. They are
+ * supported by other compilers as well.
+ */
+#define _c_cleanup_(_x) __attribute__((__cleanup__(_x)))
+#define _c_const_ __attribute__((__const__))
+#define _c_deprecated_ __attribute__((__deprecated__))
+#define _c_hidden_ __attribute__((__visibility__("hidden")))
+#define _c_likely_(_x) (__builtin_expect(!!(_x), 1))
+#define _c_packed_ __attribute__((__packed__))
+#define _c_printf_(_a, _b) __attribute__((__format__(printf, _a, _b)))
+#define _c_public_ __attribute__((__visibility__("default")))
+#define _c_pure_ __attribute__((__pure__))
+#define _c_sentinel_ __attribute__((__sentinel__))
+#define _c_unlikely_(_x) (__builtin_expect(!!(_x), 0))
+#define _c_unused_ __attribute__((__unused__))
+
+/**
+ * C_EXPR_ASSERT() - create expression with assertion
+ * @_expr: expression to evaluate to
+ * @_assertion: arbitrary assertion
+ * @_message: message associated with the assertion
+ *
+ * This macro simply evaluates to @_expr. That is, it can be used in any
+ * context that expects an expression like @_expr. Additionally, it takes an
+ * assertion as @_assertion and evaluates it through _Static_assert(), using
+ * @_message as debug message.
+ *
+ * The _Static_assert() builtin of C11 is defined as statement and thus cannot
+ * be used in expressions. This macro circumvents this restriction.
+ *
+ * Return: Evaluates to @_expr.
+ */
+#define C_EXPR_ASSERT(_expr, _assertion, _message) \
+ /* indentation and line-split to get better diagnostics */ \
+ (__builtin_choose_expr( \
+ !!(1 + 0 * sizeof( \
+ struct { \
+_Static_assert(_assertion, _message); \
+ } \
+ )), \
+ (_expr), \
+ ((void)0) \
+ ))
+
+/**
+ * C_STRINGIFY() - stringify a token, but evaluate it first
+ * @_x: token to evaluate and stringify
+ *
+ * Return: Evaluates to a constant string literal
+ */
+#define C_STRINGIFY(_x) C_INTERNAL_STRINGIFY(_x)
+#define C_INTERNAL_STRINGIFY(_x) #_x
+
+/**
+ * C_CONCATENATE() - concatenate two tokens, but evaluate them first
+ * @_x: first token
+ * @_y: second token
+ *
+ * Return: Evaluates to a constant identifier
+ */
+#define C_CONCATENATE(_x, _y) C_INTERNAL_CONCATENATE(_x, _y)
+#define C_INTERNAL_CONCATENATE(_x, _y) _x ## _y
+
+/**
+ * C_EXPAND() - expand a tuple to a series of its values
+ * @_x: tuple to expand
+ *
+ * Return: Evaluates to the expanded tuple
+ */
+#define C_EXPAND(_x) C_INTERNAL_EXPAND _x
+#define C_INTERNAL_EXPAND(...) __VA_ARGS__
+
+/**
+ * C_VAR() - generate unique variable name
+ * @_x: name of variable, optional
+ * @_uniq: unique prefix, usually provided by __COUNTER__, optional
+ *
+ * This macro shall be used to generate unique variable names, that will not be
+ * shadowed by recursive macro invocations. It is effectively a
+ * C_CONCATENATE of both arguments, but also provides a globally separated
+ * prefix and makes the code better readable.
+ *
+ * The second argument is optional. If not given, __LINE__ is implied, and as
+ * such the macro will generate the same identifier if used multiple times on
+ * the same code-line (or within a macro). This should be used if recursive
+ * calls into the macro are not expected. In fact, no argument is necessary in
+ * this case, as a mere `C_VAR` will evaluate to a valid variable name.
+ *
+ * This helper may be used by macro implementations that might reasonable well
+ * be called in a stacked fasion, like:
+ *
+ * c_max(foo, c_max(bar, baz))
+ *
+ * Such a stacked call of c_max() might cause compiler warnings of shadowed
+ * variables in the definition of c_max(). By using C_VAR(), such warnings
+ * can be silenced as each evaluation of c_max() uses unique variable names.
+ *
+ * Return: This evaluates to a constant identifier.
+ */
+#define C_VAR(...) C_INTERNAL_VAR(__VA_ARGS__, 2, 1)
+#define C_INTERNAL_VAR(_x, _uniq, _num, ...) C_VAR ## _num (_x, _uniq)
+#define C_VAR1(_x, _unused) C_VAR2(_x, C_CONCATENATE(line, __LINE__))
+#define C_VAR2(_x, _uniq) C_CONCATENATE(c_internal_var_unique_, C_CONCATENATE(_uniq, _x))
+
+/**
+ * C_CC_MACRO1() - provide safe environment to a macro
+ * @_call: macro to call
+ * @_x1: first argument
+ * @...: further arguments to forward unmodified to @_call
+ *
+ * This function simplifies the implementation of macros. Whenever you
+ * implement a macro, provide the internal macro name as @_call and its
+ * argument as @_x1. Inside of your internal macro, you...
+ *
+ * - ...are safe against multiple evaluation errors, since C_CC_MACRO1 will
+ * store the initial parameters in temporary variables.
+ *
+ * - ...support constant folding, as C_CC_MACRO1 takes care to invoke your
+ * macro with the original values, if they are compile-time constant.
+ *
+ * - ...have unique variable names for recursive callers and will not run into
+ * variable-shadowing-warnings accidentally.
+ *
+ * - ...have properly typed arguments as C_CC_MACRO1 stores the original
+ * arguments in an `__auto_type` temporary variable.
+ *
+ * Return: Result of @_call is returned.
+ */
+#define C_CC_MACRO1(_call, _x1, ...) C_INTERNAL_CC_MACRO1(_call, __COUNTER__, (_x1), ## __VA_ARGS__)
+#define C_INTERNAL_CC_MACRO1(_call, _x1q, _x1, ...) \
+ __builtin_choose_expr( \
+ __builtin_constant_p(_x1), \
+ _call(_x1, ## __VA_ARGS__), \
+ __extension__ ({ \
+ const __auto_type C_VAR(X1, _x1q) = (_x1); \
+ _call(C_VAR(X1, _x1q), ## __VA_ARGS__); \
+ }))
+
+/**
+ * C_CC_MACRO2() - provide safe environment to a macro
+ * @_call: macro to call
+ * @_x1: first argument
+ * @_x2: second argument
+ * @...: further arguments to forward unmodified to @_call
+ *
+ * This is the 2-argument equivalent of C_CC_MACRO1().
+ *
+ * Return: Result of @_call is returned.
+ */
+#define C_CC_MACRO2(_call, _x1, _x2, ...) C_INTERNAL_CC_MACRO2(_call, __COUNTER__, (_x1), __COUNTER__, (_x2), ## __VA_ARGS__)
+#define C_INTERNAL_CC_MACRO2(_call, _x1q, _x1, _x2q, _x2, ...) \
+ __builtin_choose_expr( \
+ (__builtin_constant_p(_x1) && __builtin_constant_p(_x2)), \
+ _call((_x1), (_x2), ## __VA_ARGS__), \
+ __extension__ ({ \
+ const __auto_type C_VAR(X1, _x1q) = (_x1); \
+ const __auto_type C_VAR(X2, _x2q) = (_x2); \
+ _call(C_VAR(X1, _x1q), C_VAR(X2, _x2q), ## __VA_ARGS__); \
+ }))
+
+/**
+ * C_CC_MACRO3() - provide safe environment to a macro
+ * @_call: macro to call
+ * @_x1: first argument
+ * @_x2: second argument
+ * @_x3: third argument
+ * @...: further arguments to forward unmodified to @_call
+ *
+ * This is the 3-argument equivalent of C_CC_MACRO1().
+ *
+ * Return: Result of @_call is returned.
+ */
+#define C_CC_MACRO3(_call, _x1, _x2, _x3, ...) C_INTERNAL_CC_MACRO3(_call, __COUNTER__, (_x1), __COUNTER__, (_x2), __COUNTER__, (_x3), ## __VA_ARGS__)
+#define C_INTERNAL_CC_MACRO3(_call, _x1q, _x1, _x2q, _x2, _x3q, _x3, ...) \
+ __builtin_choose_expr( \
+ (__builtin_constant_p(_x1) && __builtin_constant_p(_x2) && __builtin_constant_p(_x3)), \
+ _call((_x1), (_x2), (_x3), ## __VA_ARGS__), \
+ __extension__ ({ \
+ const __auto_type C_VAR(X1, _x1q) = (_x1); \
+ const __auto_type C_VAR(X2, _x2q) = (_x2); \
+ const __auto_type C_VAR(X3, _x3q) = (_x3); \
+ _call(C_VAR(X1, _x1q), C_VAR(X2, _x2q), C_VAR(X3, _x3q), ## __VA_ARGS__); \
+ }))
+
+/**
+ * C_ARRAY_SIZE() - calculate number of array elements at compile time
+ * @_x: array to calculate size of
+ *
+ * Return: Evaluates to a constant integer expression.
+ */
+#define C_ARRAY_SIZE(_x) \
+ C_EXPR_ASSERT(sizeof(_x) / sizeof((_x)[0]), \
+ /* \
+ * Verify that `_x' is an array, not a pointer. Rely on \
+ * `&_x[0]' degrading arrays to pointers. \
+ */ \
+ !__builtin_types_compatible_p( \
+ __typeof__(_x), \
+ __typeof__(&(*(__typeof__(_x)*)0)[0]) \
+ ), \
+ "C_ARRAY_SIZE() called with non-array argument" \
+ )
+
+/**
+ * C_DECIMAL_MAX() - calculate maximum length of the decimal
+ * representation of an integer
+ * @_type: integer variable/type
+ *
+ * This calculates the bytes required for the decimal representation of an
+ * integer of the given type. It accounts for a possible +/- prefix, but it
+ * does *NOT* include the trailing terminating zero byte.
+ *
+ * Return: Evaluates to a constant integer expression
+ */
+#define C_DECIMAL_MAX(_arg) \
+ (_Generic((__typeof__(_arg)){ 0 }, \
+ char: C_INTERNAL_DECIMAL_MAX(sizeof(char)), \
+ signed char: C_INTERNAL_DECIMAL_MAX(sizeof(signed char)), \
+ unsigned char: C_INTERNAL_DECIMAL_MAX(sizeof(unsigned char)), \
+ signed short: C_INTERNAL_DECIMAL_MAX(sizeof(signed short)), \
+ unsigned short: C_INTERNAL_DECIMAL_MAX(sizeof(unsigned short)), \
+ signed int: C_INTERNAL_DECIMAL_MAX(sizeof(signed int)), \
+ unsigned int: C_INTERNAL_DECIMAL_MAX(sizeof(unsigned int)), \
+ signed long: C_INTERNAL_DECIMAL_MAX(sizeof(signed long)), \
+ unsigned long: C_INTERNAL_DECIMAL_MAX(sizeof(unsigned long)), \
+ signed long long: C_INTERNAL_DECIMAL_MAX(sizeof(signed long long)), \
+ unsigned long long: C_INTERNAL_DECIMAL_MAX(sizeof(unsigned long long))))
+#define C_INTERNAL_DECIMAL_MAX(_bytes) \
+ C_EXPR_ASSERT( \
+ 1 + ((_bytes) <= 1 ? 3 : \
+ (_bytes) <= 2 ? 5 : \
+ (_bytes) <= 4 ? 10 : \
+ 20), \
+ (_bytes) <= 8, \
+ "Invalid use of C_INTERNAL_DECIMAL_MAX()" \
+ )
+
+/**
+ * c_container_of() - cast a member of a structure out to the containing structure
+ * @_ptr: pointer to the member or NULL
+ * @_type: type of the container struct this is embedded in
+ * @_member: name of the member within the struct
+ *
+ * This uses `offsetof(3)` to turn a pointer to a structure-member into a
+ * pointer to the surrounding structure.
+ *
+ * Return: Pointer to the surrounding object.
+ */
+#define c_container_of(_ptr, _type, _member) C_CC_MACRO1(C_CONTAINER_OF, (_ptr), _type, _member)
+#define C_CONTAINER_OF(_ptr, _type, _member) \
+ __extension__ ({ \
+ /* trigger warning if types do not match */ \
+ (void)(&((_type *)0)->_member == (_ptr)); \
+ _ptr ? (_type*)( (char*)_ptr - offsetof(_type, _member) ) : NULL; \
+ })
+
+/**
+ * c_max() - compute maximum of two values
+ * @_a: value A
+ * @_b: value B
+ *
+ * Calculate the maximum of both passed values. Both arguments are evaluated
+ * exactly once, under all circumstances. Furthermore, if both values are
+ * constant expressions, the result will be constant as well.
+ *
+ * The comparison of their values is performed with the types given by the
+ * caller. It is the caller's responsibility to convert them to suitable types
+ * if necessary.
+ *
+ * Return: Maximum of both values is returned.
+ */
+#define c_max(_a, _b) C_CC_MACRO2(C_MAX, (_a), (_b))
+#define C_MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b))
+
+/**
+ * c_min() - compute minimum of two values
+ * @_a: value A
+ * @_b: value B
+ *
+ * Calculate the minimum of both passed values. Both arguments are evaluated
+ * exactly once, under all circumstances. Furthermore, if both values are
+ * constant expressions, the result will be constant as well.
+ *
+ * The comparison of their values is performed with the types given by the
+ * caller. It is the caller's responsibility to convert them to suitable types
+ * if necessary.
+ *
+ * Return: Minimum of both values is returned.
+ */
+#define c_min(_a, _b) C_CC_MACRO2(C_MIN, (_a), (_b))
+#define C_MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
+
+/**
+ * c_less_by() - calculate clamped difference of two values
+ * @_a: minuend
+ * @_b: subtrahend
+ *
+ * Calculate [_a - _b], but clamp the result to 0. Both arguments are evaluated
+ * exactly once, under all circumstances. Furthermore, if both values are
+ * constant expressions, the result will be constant as well.
+ *
+ * The comparison of their values is performed with the types given by the
+ * caller. It is the caller's responsibility to convert them to suitable types
+ * if necessary.
+ *
+ * Return: This computes [_a - _b], if [_a > _b]. Otherwise, 0 is returned.
+ */
+#define c_less_by(_a, _b) C_CC_MACRO2(C_LESS_BY, (_a), (_b))
+#define C_LESS_BY(_a, _b) ((_a) > (_b) ? (_a) - (_b) : 0)
+
+/**
+ * c_clamp() - clamp value to lower and upper boundary
+ * @_x: value to clamp
+ * @_low: lower boundary
+ * @_high: higher boundary
+ *
+ * This clamps @_x to the lower and higher bounds given as @_low and @_high.
+ * All arguments are evaluated exactly once, and yield a constant expression if
+ * all arguments are constant as well.
+ *
+ * The comparison of their values is performed with the types given by the
+ * caller. It is the caller's responsibility to convert them to suitable types
+ * if necessary.
+ *
+ * Return: Clamped integer value.
+ */
+#define c_clamp(_x, _low, _high) C_CC_MACRO3(C_CLAMP, (_x), (_low), (_high))
+#define C_CLAMP(_x, _low, _high) ((_x) > (_high) ? (_high) : (_x) < (_low) ? (_low) : (_x))
+
+/**
+ * c_div_round_up() - calculate integer quotient but round up
+ * @_x: dividend
+ * @_y: divisor
+ *
+ * Calculates [x / y] but rounds up the result to the next integer. All
+ * arguments are evaluated exactly once, and yield a constant expression if all
+ * arguments are constant.
+ *
+ * Note:
+ * [(x + y - 1) / y] suffers from an integer overflow, even though the
+ * computation should be possible in the given type. Therefore, we use
+ * [x / y + !!(x % y)]. Note that on most CPUs a division returns both the
+ * quotient and the remainder, so both should be equally fast. Furthermore, if
+ * the divisor is a power of two, the compiler will optimize it, anyway.
+ *
+ * The operationsare performed with the types given by the caller. It is the
+ * caller's responsibility to convert the arguments to suitable types if
+ * necessary.
+ *
+ * Return: The quotient is returned.
+ */
+#define c_div_round_up(_x, _y) C_CC_MACRO2(C_DIV_ROUND_UP, (_x), (_y))
+#define C_DIV_ROUND_UP(_x, _y) ((_x) / (_y) + !!((_x) % (_y)))
+
+/**
+ * c_align_to() - align value to a multiple
+ * @_val: value to align
+ * @_to: align to multiple of this
+ *
+ * This aligns @_val to a multiple of @_to. If @_val is already a multiple of
+ * @_to, @_val is returned unchanged. This function operates within the
+ * boundaries of the type of @_val and @_to. Make sure to cast them if needed.
+ *
+ * The arguments of this macro are evaluated exactly once. If both arguments
+ * are a constant expression, this also yields a constant return value.
+ *
+ * Note that @_to must be a power of 2, otherwise the behavior will not match
+ * expectations.
+ *
+ * Return: @_val aligned to a multiple of @_to
+ */
+#define c_align_to(_val, _to) C_CC_MACRO2(C_ALIGN_TO, (_val), (_to))
+#define C_ALIGN_TO(_val, _to) (((_val) + (_to) - 1) & ~((_to) - 1))
+
+/**
+ * c_assert() - runtime assertions
+ * @expr_result: result of an expression
+ *
+ * This function behaves like the standard `assert(3)` macro. That is, if
+ * `NDEBUG` is defined, it is a no-op. In all other cases it will assert that
+ * the result of the passed expression is true.
+ *
+ * Unlike the standard `assert(3)` macro, this function always evaluates its
+ * argument. This means side-effects will always be evaluated! However, if the
+ * macro is used with constant expressions, the compiler will be able to
+ * optimize it away.
+ */
+#define c_assert(_x) ({ \
+ const _c_unused_ bool c_assert_result = (_x); \
+ assert(c_assert_result && #_x); \
+ })
+
+/**
+ * c_errno() - return valid errno
+ *
+ * This helper should be used to shut up gcc if you know 'errno' is valid (ie.,
+ * errno is > 0). Instead of "return -errno;", use
+ * "return -c_errno();" It will suppress bogus gcc warnings in case it assumes
+ * 'errno' might be 0 (or <0) and thus the caller's error-handling might not be
+ * triggered.
+ *
+ * This helper should be avoided whenever possible. However, occasionally we
+ * really want to shut up gcc (especially with static/inline functions). In
+ * those cases, gcc usually cannot deduce that some error paths are guaranteed
+ * to be taken. Hence, making the return value explicit allows gcc to better
+ * optimize the code.
+ *
+ * Note that you really should never use this helper to work around broken libc
+ * calls or syscalls, not setting 'errno' correctly.
+ *
+ * Return: Positive error code is returned.
+ */
+static inline int c_errno(void) {
+ return _c_likely_(errno > 0) ? errno : ENOTRECOVERABLE;
+}
+
+/*
+ * Common Destructors
+ *
+ * Followingly, there're a bunch of common 'static inline' destructors, which
+ * simply call the function that they're named after, but return "INVALID"
+ * instead of "void". This allows direct assignment to any member-field and/or
+ * variable they're defined in, like:
+ *
+ * foo = c_free(foo);
+ *
+ * or
+ *
+ * foo->bar = c_close(foo->bar);
+ *
+ * Furthermore, all those destructors can be safely called with the "INVALID"
+ * value as argument, and they will be a no-op.
+ */
+
+static inline void *c_free(void *p) {
+ free(p);
+ return NULL;
+}
+
+static inline int c_close(int fd) {
+ if (fd >= 0)
+ close(fd);
+ return -1;
+}
+
+static inline FILE *c_fclose(FILE *f) {
+ if (f)
+ fclose(f);
+ return NULL;
+}
+
+static inline DIR *c_closedir(DIR *d) {
+ if (d)
+ closedir(d);
+ return NULL;
+}
+
+/*
+ * Common Cleanup Helpers
+ *
+ * A bunch of _c_cleanup_(foobarp) helpers that are used all over the place.
+ * Note that all of those have the "if (IS_INVALID(foobar))" check inline, so
+ * compilers can optimize most of the cleanup-paths in a function. However, if
+ * the function they call already does this _inline_, then it might be skipped.
+ */
+
+#define C_DEFINE_CLEANUP(_type, _func) \
+ static inline void _func ## p(_type *p) { \
+ if (*p) \
+ _func(*p); \
+ } struct c_internal_trailing_semicolon
+
+#define C_DEFINE_DIRECT_CLEANUP(_type, _func) \
+ static inline void _func ## p(_type *p) { \
+ _func(*p); \
+ } struct c_internal_trailing_semicolon
+
+static inline void c_freep(void *p) {
+ /*
+ * `foobar **` does not coerce to `void **`, so we need `void *` as
+ * argument type, and then we dereference manually.
+ */
+ c_free(*(void **)p);
+}
+
+C_DEFINE_DIRECT_CLEANUP(int, c_close);
+C_DEFINE_CLEANUP(FILE *, c_fclose);
+C_DEFINE_CLEANUP(DIR *, c_closedir);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/shared/c-stdaux/src/meson.build b/shared/c-stdaux/src/meson.build
new file mode 100644
index 0000000000..f6db824d24
--- /dev/null
+++ b/shared/c-stdaux/src/meson.build
@@ -0,0 +1,31 @@
+#
+# target: libcstdaux.so
+# (No .so is built so far, since we are header-only. This might change in the
+# future, if we add more complex helpers.)
+#
+
+libcstdaux_dep = declare_dependency(
+ include_directories: include_directories('.'),
+ version: meson.project_version(),
+)
+
+if not meson.is_subproject()
+ install_headers('c-stdaux.h')
+
+ mod_pkgconfig.generate(
+ version: meson.project_version(),
+ name: 'libcstdaux',
+ filebase: 'libcstdaux',
+ description: project_description,
+ )
+endif
+
+#
+# target: test-*
+#
+
+test_api = executable('test-api', ['test-api.c'], dependencies: libcstdaux_dep)
+test('API Symbol Visibility', test_api)
+
+test_basic = executable('test-basic', ['test-basic.c'], dependencies: libcstdaux_dep)
+test('Basic API Behavior', test_basic)
diff --git a/shared/c-stdaux/src/test-api.c b/shared/c-stdaux/src/test-api.c
new file mode 100644
index 0000000000..fb500660b0
--- /dev/null
+++ b/shared/c-stdaux/src/test-api.c
@@ -0,0 +1,209 @@
+/*
+ * API Visibility Tests
+ * This verifies the visibility and availability of the exported API.
+ */
+
+#undef NDEBUG
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "c-stdaux.h"
+
+static _c_const_ int const_fn(void) { return 0; }
+static _c_deprecated_ _c_unused_ int deprecated_fn(void) { return 0; }
+_c_hidden_ int c_internal_hidden_fn(void) { return 0; }
+static _c_printf_(1, 2) int printf_fn(const char *f, ...) { return 0; }
+_c_public_ int c_internal_public_fn(void) { return 0; }
+static _c_pure_ int pure_fn(void) { return 0; }
+static _c_sentinel_ int sentinel_fn(const char *f, ...) { return 0; }
+static _c_unused_ int unused_fn(void) { return 0; }
+
+static void cleanup_fn(int p) {}
+static void direct_cleanup_fn(int p) {}
+C_DEFINE_CLEANUP(int, cleanup_fn);
+C_DEFINE_DIRECT_CLEANUP(int, direct_cleanup_fn);
+
+static void test_api_macros(void) {
+ /* _c_cleanup_ */
+ {
+ _c_cleanup_(c_freep) void *foo = NULL;
+ c_assert(!foo);
+ }
+
+ /* _c_const_ */
+ {
+ c_assert(!const_fn());
+ }
+
+ /* _c_deprecated_ */
+ {
+ /* see deprecated_fn() */
+ }
+
+ /* _c_hidden_ */
+ {
+ c_assert(!c_internal_hidden_fn());
+ }
+
+ /* _c_likely_ */
+ {
+ c_assert(_c_likely_(true));
+ }
+
+ /* _c_packed_ */
+ {
+ struct _c_packed_ FooBar {
+ int member;
+ } foobar = {};
+
+ c_assert(!foobar.member);
+ }
+
+ /* _c_printf_ */
+ {
+ c_assert(!printf_fn("%d", 1));
+ }
+
+ /* _c_public_ */
+ {
+ c_assert(!c_internal_public_fn());
+ }
+
+ /* _c_pure_ */
+ {
+ c_assert(!pure_fn());
+ }
+
+ /* _c_sentinel_ */
+ {
+ c_assert(!sentinel_fn("", NULL));
+ }
+
+ /* _c_unlikely_ */
+ {
+ c_assert(!_c_unlikely_(false));
+ }
+
+ /* _c_unused_ */
+ {
+ c_assert(!unused_fn());
+ }
+
+ /* C_EXPR_ASSERT */
+ {
+ int v = C_EXPR_ASSERT(0, true, "");
+
+ c_assert(!v);
+ }
+
+ /* C_STRINGIFY */
+ {
+ const char v[] = C_STRINGIFY(foobar);
+
+ c_assert(!strcmp(v, "foobar"));
+ }
+
+ /* C_CONCATENATE */
+ {
+ int C_CONCATENATE(a, b) = 0;
+
+ c_assert(!ab);
+ }
+
+ /* C_EXPAND */
+ {
+ int x[] = { C_EXPAND((0, 1)) };
+
+ c_assert(sizeof(x) / sizeof(*x) == 2);
+ }
+
+ /* C_VAR */
+ {
+ int C_VAR = 0; c_assert(!C_VAR); /* must be on the same line */
+ }
+
+ /* C_CC_MACRO1, C_CC_MACRO2, C_CC_MACRO3 */
+ {
+#define MACRO_REAL(_x1, _x2, _x3) ((_x1 + _x2 + _x3) * 0)
+#define MACRO1(_x1) C_CC_MACRO1(MACRO_REAL, _x1, 0, 0)
+#define MACRO2(_x1, _x2) C_CC_MACRO2(MACRO_REAL, _x1, _x2, 0)
+#define MACRO3(_x1, _x2, _x3) C_CC_MACRO3(MACRO_REAL, _x1, _x2, _x3)
+ c_assert(!MACRO1(1));
+ c_assert(!MACRO2(1, 1));
+ c_assert(!MACRO3(1, 1, 1));
+#undef MACRO3
+#undef MACRO2
+#undef MACRO1
+ }
+
+ /* C_ARRAY_SIZE */
+ {
+ int v[] = { 0, 1, 2 };
+ c_assert(C_ARRAY_SIZE(v) == 3);
+ }
+
+ /* C_DECIMAL_MAX */
+ {
+ c_assert(C_DECIMAL_MAX(uint8_t) == 4);
+ }
+
+ /* c_container_of */
+ {
+ struct FooBarContainer {
+ int member;
+ } v = {};
+
+ c_assert(c_container_of(&v.member, struct FooBarContainer, member) == &v);
+ }
+
+ /* c_max, c_min, c_less_by, c_clamp, c_div_round_up */
+ {
+ c_assert(c_max(0, 0) == 0);
+ c_assert(c_min(0, 0) == 0);
+ c_assert(c_less_by(0, 0) == 0);
+ c_assert(c_clamp(0, 0, 0) == 0);
+ c_assert(c_div_round_up(1, 1) == 1);
+ }
+
+ /* c_align_to */
+ {
+ c_assert(c_align_to(0, 0) == 0);
+ }
+
+ /* c_assert */
+ {
+ c_assert(true);
+ }
+
+ /* C_DEFINE_CLEANUP / C_DEFINE_DIRECT_CLEANUP */
+ {
+ int v = 0;
+
+ cleanup_fnp(&v);
+ direct_cleanup_fnp(&v);
+ }
+}
+
+static void test_api_functions(void) {
+ void *fns[] = {
+ (void *)c_errno,
+ (void *)c_free,
+ (void *)c_close,
+ (void *)c_fclose,
+ (void *)c_closedir,
+ (void *)c_freep,
+ (void *)c_closep,
+ (void *)c_fclosep,
+ (void *)c_closedirp,
+ };
+ size_t i;
+
+ for (i = 0; i < sizeof(fns) / sizeof(*fns); ++i)
+ c_assert(!!fns[i]);
+}
+
+int main(int argc, char **argv) {
+ test_api_macros();
+ test_api_functions();
+ return 0;
+}
diff --git a/shared/c-stdaux/src/test-basic.c b/shared/c-stdaux/src/test-basic.c
new file mode 100644
index 0000000000..291a8e199b
--- /dev/null
+++ b/shared/c-stdaux/src/test-basic.c
@@ -0,0 +1,432 @@
+/*
+ * Tests for Basic Functionality
+ *
+ * This runs same basic verification that each feature does what we expect it
+ * to do. More elaborate tests and/or stress-tests are not included here.
+ */
+
+#undef NDEBUG
+#include <stdlib.h>
+#include <sys/eventfd.h>
+#include "c-stdaux.h"
+
+/*
+ * Tests for all remaining helpers
+ */
+static void test_misc(int non_constant_expr) {
+ int foo;
+
+ /*
+ * Test the C_EXPR_ASSERT() macro to work in static and non-static
+ * environments, and evaluate exactly to its passed expression.
+ */
+ {
+ static int v = C_EXPR_ASSERT(1, true, "");
+
+ c_assert(v == 1);
+ }
+
+ /*
+ * Test stringify/concatenation helpers. Also make sure to test that
+ * the passed arguments are evaluated first, before they're stringified
+ * and/or concatenated.
+ */
+ {
+#define TEST_TOKEN foobar
+ c_assert(!strcmp("foobar", C_STRINGIFY(foobar)));
+ c_assert(!strcmp("foobar", C_STRINGIFY(TEST_TOKEN)));
+ c_assert(!strcmp("foobar", C_STRINGIFY(C_CONCATENATE(foo, bar))));
+ c_assert(!strcmp("foobarfoobar", C_STRINGIFY(C_CONCATENATE(TEST_TOKEN, foobar))));
+ c_assert(!strcmp("foobarfoobar", C_STRINGIFY(C_CONCATENATE(foobar, TEST_TOKEN))));
+#undef TEST_TOKEN
+ }
+
+ /*
+ * Test tuple expansion. This is used to strip tuple-wrappers in the
+ * pre-processor.
+ * We make sure that it works with {0,1,2}-tuples, as well as only
+ * strips a single layer.
+ */
+ {
+ /*
+ * strcmp() might be a macro, so make sure we get a proper C
+ * expression below. Otherwise, C_EXPAND() cannot be used that
+ * way (since it would evaluate to a single macro argument).
+ */
+ int (*f) (const char *, const char *) = strcmp;
+
+ c_assert(!f(C_EXPAND(()) "foobar", "foo" "bar"));
+ c_assert(!f(C_EXPAND(("foobar")), "foo" "bar"));
+ c_assert(!f(C_EXPAND(("foobar", "foo" "bar"))));
+ c_assert(!f C_EXPAND((("foobar", "foo" "bar"))));
+ }
+
+ /*
+ * Test C_VAR() macro. It's sole purpose is to create a valid C
+ * identifier given a single argument (which itself must be a valid
+ * identifier).
+ * Just test that we can declare variables with it and use it in
+ * expressions.
+ */
+ {
+ {
+ int C_VAR(sub, UNIQUE) = 5;
+ /* make sure the variable name does not clash */
+ int sub = 12, subUNIQUE = 12, UNIQUEsub = 12;
+
+ c_assert(7 + C_VAR(sub, UNIQUE) == sub);
+ c_assert(sub == subUNIQUE);
+ c_assert(sub == UNIQUEsub);
+ }
+ {
+ /*
+ * Make sure both produce different names, even though they're
+ * exactly the same expression.
+ */
+ _c_unused_ int C_VAR(sub, __COUNTER__), C_VAR(sub, __COUNTER__);
+ }
+ {
+ /* verify C_VAR() with single argument works line-based */
+ int C_VAR(sub); C_VAR(sub) = 5; c_assert(C_VAR(sub) == 5);
+ }
+ {
+ /* verify C_VAR() with no argument works line-based */
+ int C_VAR(); C_VAR() = 5; c_assert(C_VAR() == 5);
+ }
+ }
+
+ /*
+ * Test array-size helper. This simply computes the number of elements
+ * of an array, instead of the binary size.
+ */
+ {
+ int bar[8];
+
+ static_assert(C_ARRAY_SIZE(bar) == 8, "");
+ c_assert(__builtin_constant_p(C_ARRAY_SIZE(bar)));
+ }
+
+ /*
+ * Test decimal-representation calculator. Make sure it is
+ * type-independent and just uses the size of the type to calculate how
+ * many bytes are needed to print that integer in decimal form. Also
+ * verify that it is a constant expression.
+ */
+ {
+ static_assert(C_DECIMAL_MAX(char) == 4, "");
+ static_assert(C_DECIMAL_MAX(signed char) == 4, "");
+ static_assert(C_DECIMAL_MAX(unsigned char) == 4, "");
+ static_assert(C_DECIMAL_MAX(unsigned long) == (sizeof(long) == 8 ? 21 : 11), "");
+ static_assert(C_DECIMAL_MAX(unsigned long long) == 21, "");
+ static_assert(C_DECIMAL_MAX(int32_t) == 11, "");
+ static_assert(C_DECIMAL_MAX(uint32_t) == 11, "");
+ static_assert(C_DECIMAL_MAX(uint64_t) == 21, "");
+ }
+
+ /*
+ * Test c_container_of(). We cannot test for type-safety, nor for
+ * other invalid uses, as they'd require negative compile-testing.
+ * However, we can test that the macro yields the correct values under
+ * normal use.
+ */
+ {
+ struct foobar {
+ int a;
+ char b;
+ } sub = {};
+
+ c_assert(&sub == c_container_of(&sub.a, struct foobar, a));
+ c_assert(&sub == c_container_of(&sub.b, struct foobar, b));
+ c_assert(&sub == c_container_of((const char *)&sub.b, struct foobar, b));
+ }
+
+ /*
+ * Test min/max macros. Especially check that macro arguments are never
+ * evaluated multiple times, and if both arguments are constant, the
+ * return value is constant as well.
+ */
+ {
+ foo = 0;
+ c_assert(c_max(1, 5) == 5);
+ c_assert(c_max(-1, 5) == 5);
+ c_assert(c_max(-1, -5) == -1);
+ c_assert(c_max(foo++, -1) == 0);
+ c_assert(foo == 1);
+ c_assert(c_max(foo++, foo++) > 0);
+ c_assert(foo == 3);
+
+ c_assert(__builtin_constant_p(c_max(1, 5)));
+ c_assert(!__builtin_constant_p(c_max(1, non_constant_expr)));
+
+ foo = 0;
+ c_assert(c_min(1, 5) == 1);
+ c_assert(c_min(-1, 5) == -1);
+ c_assert(c_min(-1, -5) == -5);
+ c_assert(c_min(foo++, 1) == 0);
+ c_assert(foo == 1);
+ c_assert(c_min(foo++, foo++) > 0);
+ c_assert(foo == 3);
+
+ c_assert(__builtin_constant_p(c_min(1, 5)));
+ c_assert(!__builtin_constant_p(c_min(1, non_constant_expr)));
+ }
+
+ /*
+ * Test c_less_by(), c_clamp(). Make sure they
+ * evaluate arguments exactly once, and yield a constant expression,
+ * if all arguments are constant.
+ */
+ {
+ foo = 8;
+ c_assert(c_less_by(1, 5) == 0);
+ c_assert(c_less_by(5, 1) == 4);
+ c_assert(c_less_by(foo++, 1) == 7);
+ c_assert(foo == 9);
+ c_assert(c_less_by(foo++, foo++) >= 0);
+ c_assert(foo == 11);
+
+ c_assert(__builtin_constant_p(c_less_by(1, 5)));
+ c_assert(!__builtin_constant_p(c_less_by(1, non_constant_expr)));
+
+ foo = 8;
+ c_assert(c_clamp(foo, 1, 5) == 5);
+ c_assert(c_clamp(foo, 9, 20) == 9);
+ c_assert(c_clamp(foo++, 1, 5) == 5);
+ c_assert(foo == 9);
+ c_assert(c_clamp(foo++, foo++, foo++) >= 0);
+ c_assert(foo == 12);
+
+ c_assert(__builtin_constant_p(c_clamp(0, 1, 5)));
+ c_assert(!__builtin_constant_p(c_clamp(1, 0, non_constant_expr)));
+ }
+
+ /*
+ * Div Round Up: Normal division, but round up to next integer, instead
+ * of clipping. Also verify that it does not suffer from the integer
+ * overflow in the prevalant, alternative implementation:
+ * [(x + y - 1) / y].
+ */
+ {
+ int i, j;
+
+#define TEST_ALT_DIV(_x, _y) (((_x) + (_y) - 1) / (_y))
+ foo = 8;
+ c_assert(c_div_round_up(0, 5) == 0);
+ c_assert(c_div_round_up(1, 5) == 1);
+ c_assert(c_div_round_up(5, 5) == 1);
+ c_assert(c_div_round_up(6, 5) == 2);
+ c_assert(c_div_round_up(foo++, 1) == 8);
+ c_assert(foo == 9);
+ c_assert(c_div_round_up(foo++, foo++) >= 0);
+ c_assert(foo == 11);
+
+ c_assert(__builtin_constant_p(c_div_round_up(1, 5)));
+ c_assert(!__builtin_constant_p(c_div_round_up(1, non_constant_expr)));
+
+ /* alternative calculation is [(x + y - 1) / y], but it may overflow */
+ for (i = 0; i <= 0xffff; ++i) {
+ for (j = 1; j <= 0xff; ++j)
+ c_assert(c_div_round_up(i, j) == TEST_ALT_DIV(i, j));
+ for (j = 0xff00; j <= 0xffff; ++j)
+ c_assert(c_div_round_up(i, j) == TEST_ALT_DIV(i, j));
+ }
+
+ /* make sure it doesn't suffer from high overflow */
+ c_assert(UINT32_C(0xfffffffa) % 10 == 0);
+ c_assert(UINT32_C(0xfffffffa) / 10 == UINT32_C(429496729));
+ c_assert(c_div_round_up(UINT32_C(0xfffffffa), 10) == UINT32_C(429496729));
+ c_assert(TEST_ALT_DIV(UINT32_C(0xfffffffa), 10) == 0); /* overflow */
+
+ c_assert(UINT32_C(0xfffffffd) % 10 == 3);
+ c_assert(UINT32_C(0xfffffffd) / 10 == UINT32_C(429496729));
+ c_assert(c_div_round_up(UINT32_C(0xfffffffd), 10) == UINT32_C(429496730));
+ c_assert(TEST_ALT_DIV(UINT32_C(0xfffffffd), 10) == 0);
+#undef TEST_ALT_DIV
+ }
+
+ /*
+ * Align to multiple of: Test the alignment macro. Check that it does
+ * not suffer from incorrect integer overflows, neither should it
+ * exceed the boundaries of the input type.
+ */
+ {
+ c_assert(c_align_to(UINT32_C(0), 1) == 0);
+ c_assert(c_align_to(UINT32_C(0), 2) == 0);
+ c_assert(c_align_to(UINT32_C(0), 4) == 0);
+ c_assert(c_align_to(UINT32_C(0), 8) == 0);
+ c_assert(c_align_to(UINT32_C(1), 8) == 8);
+
+ c_assert(c_align_to(UINT32_C(0xffffffff), 8) == 0);
+ c_assert(c_align_to(UINT32_C(0xfffffff1), 8) == 0xfffffff8);
+ c_assert(c_align_to(UINT32_C(0xfffffff1), 8) == 0xfffffff8);
+
+ c_assert(__builtin_constant_p(c_align_to(16, 8)));
+ c_assert(!__builtin_constant_p(c_align_to(non_constant_expr, 8)));
+ c_assert(!__builtin_constant_p(c_align_to(16, non_constant_expr)));
+ c_assert(!__builtin_constant_p(c_align_to(16, non_constant_expr ? 8 : 16)));
+ c_assert(__builtin_constant_p(c_align_to(16, 7 + 1)));
+ c_assert(c_align_to(15, non_constant_expr ? 8 : 16) == 16);
+ }
+
+ /*
+ * Test c_assert(). Make sure side-effects are always evaluated, and
+ * variables are marked as used regardless of NDEBUG.
+ */
+ {
+ int v1 = 0, v2 = 0;
+
+#define NDEBUG 1
+ c_assert(!v1);
+ if (v1)
+ abort();
+ c_assert(++v1);
+ if (v1 != 1)
+ abort();
+#undef NDEBUG
+ c_assert(!v2);
+ if (v2)
+ abort();
+ c_assert(++v2);
+ if (v2 != 1)
+ abort();
+ }
+
+ /*
+ * Test c_errno(). Simply verify that the correct value is returned. It
+ * must always be >0 and equivalent to `errno' if set.
+ */
+ {
+ c_assert(c_errno() > 0);
+
+ close(-1);
+ c_assert(c_errno() == errno);
+
+ errno = 0;
+ c_assert(c_errno() != errno);
+ }
+}
+
+/*
+ * Tests for:
+ * - c_free*()
+ * - c_close*()
+ * - c_fclose*()
+ * - c_closedir*()
+ */
+static void test_destructors(void) {
+ int i;
+
+ /*
+ * Verify that c_free*() works as expected. Since we want to support
+ * running under valgrind, there is no easy way to verify the
+ * correctness of free(). Hence, we simply rely on valgrind to catch
+ * the leaks.
+ */
+ {
+ for (i = 0; i < 16; ++i) {
+ _c_cleanup_(c_freep) void *foo;
+ _c_cleanup_(c_freep) int **bar; /* supports any type */
+ size_t sz = 128 * 1024;
+
+ foo = malloc(sz);
+ c_assert(foo);
+
+ bar = malloc(sz);
+ c_assert(bar);
+ bar = c_free(bar);
+ c_assert(!bar);
+ }
+
+ c_assert(c_free(NULL) == NULL);
+ }
+
+ /*
+ * Test c_close*(), rely on sparse FD allocation. Make sure all the
+ * helpers actually close the fd, and cope fine with negative numbers.
+ */
+ {
+ int fd;
+
+ fd = eventfd(0, EFD_CLOEXEC);
+ c_assert(fd >= 0);
+
+ /* verify c_close() returns -1 */
+ c_assert(c_close(fd) == -1);
+
+ /* verify c_close() deals fine with negative fds */
+ c_assert(c_close(-1) == -1);
+ c_assert(c_close(-16) == -1);
+
+ /* make sure c_closep() deals fine with negative FDs */
+ {
+ _c_cleanup_(c_closep) int t = 0;
+ t = -1;
+ }
+
+ /*
+ * Make sure the c_close() earlier worked, by allocating the
+ * FD again and relying on the same FD number to be reused. Do
+ * this twice, to verify that the c_closep() in the cleanup
+ * path works as well.
+ */
+ for (i = 0; i < 2; ++i) {
+ _c_cleanup_(c_closep) int t = -1;
+
+ t = eventfd(0, EFD_CLOEXEC);
+ c_assert(t >= 0);
+ c_assert(t == fd);
+ }
+ }
+
+ /*
+ * Test c_fclose() and c_fclosep(). This uses the same logic as the
+ * tests for c_close() (i.e., sparse FD allocation).
+ */
+ {
+ FILE *f;
+ int fd;
+
+ fd = eventfd(0, EFD_CLOEXEC);
+ c_assert(fd >= 0);
+
+ f = fdopen(fd, "r");
+ c_assert(f);
+
+ /* verify c_fclose() returns NULL */
+ f = c_fclose(f);
+ c_assert(!f);
+
+ /* verify c_fclose() deals fine with NULL */
+ c_assert(!c_fclose(NULL));
+
+ /* make sure c_flosep() deals fine with NULL */
+ {
+ _c_cleanup_(c_fclosep) FILE *t = (void *)0xdeadbeef;
+ t = NULL;
+ }
+
+ /*
+ * Make sure the c_fclose() earlier worked, by allocating the
+ * FD again and relying on the same FD number to be reused. Do
+ * this twice, to verify that the c_fclosep() in the cleanup
+ * path works as well.
+ */
+ for (i = 0; i < 2; ++i) {
+ _c_cleanup_(c_fclosep) FILE *t = NULL;
+ int tfd;
+
+ tfd = eventfd(0, EFD_CLOEXEC);
+ c_assert(tfd >= 0);
+ c_assert(tfd == fd); /* the same as before */
+
+ t = fdopen(tfd, "r");
+ c_assert(t);
+ }
+ }
+}
+
+int main(int argc, char **argv) {
+ test_misc(argc);
+ test_destructors();
+ return 0;
+}
diff --git a/shared/meson.build b/shared/meson.build
index ed9bf03f37..380758f00f 100644
--- a/shared/meson.build
+++ b/shared/meson.build
@@ -2,8 +2,23 @@ shared_inc = include_directories('.')
###############################################################################
+shared_c_stdaux = static_library(
+ 'c-stdaux',
+ c_args: '-std=c11',
+ sources: files('c-stdaux/src/c-stdaux.h'),
+)
+
+shared_c_stdaux_dep = declare_dependency(
+ include_directories: shared_inc,
+)
+
+###############################################################################
+
shared_c_siphash = static_library(
'c-siphash',
+ include_directories: [
+ include_directories('c-stdaux/src'),
+ ],
sources: 'c-siphash/src/c-siphash.c',
)
@@ -17,6 +32,9 @@ shared_c_siphash_dep = declare_dependency(
shared_c_rbtree = static_library(
'c-rbtree',
c_args: '-std=c11',
+ include_directories: [
+ include_directories('c-stdaux/src'),
+ ],
sources: files('c-rbtree/src/c-rbtree.c',
'c-rbtree/src/c-rbtree.h',
'c-rbtree/src/c-rbtree-private.h'),
@@ -52,6 +70,7 @@ shared_n_acd = static_library(
'-Wno-vla',
],
include_directories: [
+ include_directories('c-stdaux/src'),
include_directories('c-siphash/src'),
include_directories('c-list/src'),
include_directories('c-rbtree/src'),
diff --git a/shared/n-acd/.cherryci/ci-test b/shared/n-acd/.cherryci/ci-test
index 71f3457037..71f46a4202 100755
--- a/shared/n-acd/.cherryci/ci-test
+++ b/shared/n-acd/.cherryci/ci-test
@@ -8,5 +8,5 @@ cd "./ci-build"
${CHERRY_LIB_MESONSETUP} . "${CHERRY_LIB_SRCDIR}" ${N_ACD_CONF}
${CHERRY_LIB_NINJABUILD}
-sudo ${CHERRY_LIB_MESONTEST}
+${CHERRY_LIB_MESONTEST}
# no valgrind tests, since bpf(2) is not supported by it
diff --git a/shared/n-acd/.gitmodules b/shared/n-acd/.gitmodules
index d73d05a267..04829bdba8 100644
--- a/shared/n-acd/.gitmodules
+++ b/shared/n-acd/.gitmodules
@@ -7,3 +7,6 @@
[submodule "subprojects/c-rbtree"]
path = subprojects/c-rbtree
url = https://github.com/c-util/c-rbtree.git
+[submodule "subprojects/c-stdaux"]
+ path = subprojects/c-stdaux
+ url = https://github.com/c-util/c-stdaux.git
diff --git a/shared/n-acd/AUTHORS b/shared/n-acd/AUTHORS
index 89ee27d233..98ff148232 100644
--- a/shared/n-acd/AUTHORS
+++ b/shared/n-acd/AUTHORS
@@ -30,10 +30,10 @@ AUTHORS-LGPL:
along with this program; If not, see <http://www.gnu.org/licenses/>.
COPYRIGHT: (ordered alphabetically)
- Copyright (C) 2015-2018 Red Hat, Inc.
+ Copyright (C) 2015-2019 Red Hat, Inc.
AUTHORS: (ordered alphabetically)
Beniamino Galvani <bgalvani@redhat.com>
- David Herrmann <dh.herrmann@gmail.com>
+ David Rheinsberg <david.rheinsberg@gmail.com>
Thomas Haller <thaller@redhat.com>
Tom Gundersen <teg@jklm.no>
diff --git a/shared/n-acd/AUTHORS-ASL b/shared/n-acd/AUTHORS-ASL
deleted file mode 100644
index 5d501a7284..0000000000
--- a/shared/n-acd/AUTHORS-ASL
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright {yyyy} {name of copyright owner}
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/shared/n-acd/AUTHORS-LGPL b/shared/n-acd/AUTHORS-LGPL
deleted file mode 100644
index 4362b49151..0000000000
--- a/shared/n-acd/AUTHORS-LGPL
+++ /dev/null
@@ -1,502 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library 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.
-
- This library 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 this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/shared/n-acd/LICENSE b/shared/n-acd/LICENSE
deleted file mode 120000
index da24c5e4a6..0000000000
--- a/shared/n-acd/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-AUTHORS-ASL \ No newline at end of file
diff --git a/shared/n-acd/NEWS b/shared/n-acd/NEWS
deleted file mode 100644
index bb06abbc5a..0000000000
--- a/shared/n-acd/NEWS
+++ /dev/null
@@ -1,21 +0,0 @@
-n-acd - IPv4 Address Conflict Detection
-
-CHANGES WITH 1:
-
- * Initial release of n-acd. This project implements the IPv4 Address
- Conflict Detection standard as defined in RFC-5227. The state machine
- is implemented in a shared library and provides a stable ISO-C11 API.
- The implementation is linux-only and relies heavily on the API
- behavior of recent linux kernel releases.
-
- * Compared to the pre-releases, this release supports many parallel
- probes on a single n-acd context. This reduces the number of
- allocated network resources to O(1), based on the number of running
- parallel probes.
-
- * The n-acd project is now dual-licensed: ASL-2.0 and LGPL-2.1+
-
- Contributions from: Beniamino Galvani, David Herrmann, Thomas Haller,
- Tom Gundersen
-
- - Tübingen, 2018-08-08
diff --git a/shared/n-acd/NEWS.md b/shared/n-acd/NEWS.md
new file mode 100644
index 0000000000..7a9ccd67c0
--- /dev/null
+++ b/shared/n-acd/NEWS.md
@@ -0,0 +1,46 @@
+# n-acd - IPv4 Address Conflict Detection
+
+## CHANGES WITH 2:
+
+ * All public destructors now include a variant that returns `void`.
+ This was requested for easier integration with `glib` and friends.
+ Similar to the `cleanup` variants, these variants are denoted by a
+ single-character function-name suffix. E.g., `n_acd_freev()`
+
+ * A fallback to `CLOCK_MONOTONIC` is now provided in case
+ `CLOCK_BOOTTIME` is not supported by the kernel. Note that this is in
+ no way signalled through the API, so if timers should follow the
+ `BOOTTIME` rather than monotonic clock, a kernel with this clock is
+ required.
+
+ * The `c-sundry` dependency is no longer needed.
+
+ * The `transport` configuration property is now mandatory for
+ `n_acd_new()`. It defaulted to `ETHERNET` before, by mistake.
+
+ * In-source documentation for the public API is now provided.
+
+ Contributions from: Beniamino Galvani, David Herrmann, David
+ Rheinsberg, Thomas Haller, Tom Gundersen
+
+ - Tübingen, 2019-03-20
+
+## CHANGES WITH 1:
+
+ * Initial release of n-acd. This project implements the IPv4 Address
+ Conflict Detection standard as defined in RFC-5227. The state machine
+ is implemented in a shared library and provides a stable ISO-C11 API.
+ The implementation is linux-only and relies heavily on the API
+ behavior of recent linux kernel releases.
+
+ * Compared to the pre-releases, this release supports many parallel
+ probes on a single n-acd context. This reduces the number of
+ allocated network resources to O(1), based on the number of running
+ parallel probes.
+
+ * The n-acd project is now dual-licensed: ASL-2.0 and LGPL-2.1+
+
+ Contributions from: Beniamino Galvani, David Herrmann, Thomas Haller,
+ Tom Gundersen
+
+ - Tübingen, 2018-08-08
diff --git a/shared/n-acd/README b/shared/n-acd/README
deleted file mode 100644
index b88d31c713..0000000000
--- a/shared/n-acd/README
+++ /dev/null
@@ -1,54 +0,0 @@
-n-acd - IPv4 Address Conflict Detection
-
-ABOUT:
- The n-acd project implements the IPv4 Address Conflict Detection
- standard as defined in RFC-5227. The state machine is implemented in a
- shared library and provides a stable ISO-C11 API. The implementation is
- linux-only and relies heavily on the API behavior of recent linux
- kernel releases.
-
-DETAILS:
- https://nettools.github.io/n-acd
-
-BUG REPORTS:
- https://github.com/nettools/n-acd/issues
-
-GIT:
- git@github.com:nettools/n-acd.git
- https://github.com/nettools/n-acd.git
-
-GITWEB:
- https://github.com/nettools/n-acd
-
-MAILINGLIST:
- https://groups.google.com/forum/#!forum/nettools-devel
-
-LICENSE:
- Apache Software License 2.0
- Lesser General Public License 2.1+
- See AUTHORS for details.
-
-REQUIREMENTS:
- The requirements for n-acd are:
-
- Linux kernel >= 3.19
- libc (e.g., glibc >= 2.16)
-
- At build-time, the following software is required:
-
- meson >= 0.41
- pkg-config >= 0.29
-
-INSTALL:
- The meson build-system is used for this project. Contact upstream
- documentation for detailed help. In most situations the following
- commands are sufficient to build and install from source:
-
- $ mkdir build
- $ cd build
- $ meson setup ..
- $ ninja
- $ meson test
- # ninja install
-
- For custom configuration options see meson_options.txt.
diff --git a/shared/n-acd/README.md b/shared/n-acd/README.md
new file mode 100644
index 0000000000..089541825d
--- /dev/null
+++ b/shared/n-acd/README.md
@@ -0,0 +1,60 @@
+n-acd
+=====
+
+IPv4 Address Conflict Detection
+
+The n-acd project implements the IPv4 Address Conflict Detection standard as
+defined in RFC-5227. The state machine is implemented in a shared library and
+provides a stable ISO-C11 API. The implementation is linux-only and relies
+heavily on the API behavior of recent linux kernel releases.
+
+### Project
+
+ * **Website**: <https://nettools.github.io/n-acd>
+ * **Bug Tracker**: <https://github.com/nettools/n-acd/issues>
+ * **Mailing-List**: <https://groups.google.com/forum/#!forum/nettools-devel>
+
+### Requirements
+
+The requirements for this project are:
+
+ * `Linux kernel >= 3.19`
+ * `libc` (e.g., `glibc >= 2.16`)
+
+At build-time, the following software is required:
+
+ * `meson >= 0.41`
+ * `pkg-config >= 0.29`
+
+### Build
+
+The meson build-system is used for this project. Contact upstream
+documentation for detailed help. In most situations the following
+commands are sufficient to build and install from source:
+
+```sh
+mkdir build
+cd build
+meson setup ..
+ninja
+meson test
+ninja install
+```
+
+The following configuration options are available:
+
+ * `ebpf`: This boolean controls whether `ebpf` features are used to improve
+ the package filtering performance. If disabled, classic bpf will be
+ used. This feature requires a rather recent kernel (>=3.19).
+ Default is: true
+
+### Repository:
+
+ - **web**: <https://github.com/nettools/n-acd>
+ - **https**: `https://github.com/nettools/n-acd.git`
+ - **ssh**: `git@github.com:nettools/n-acd.git`
+
+### License:
+
+ - **Apache-2.0** OR **LGPL-2.1-or-later**
+ - See AUTHORS file for details.
diff --git a/shared/n-acd/meson.build b/shared/n-acd/meson.build
index a05164c048..017dec5669 100644
--- a/shared/n-acd/meson.build
+++ b/shared/n-acd/meson.build
@@ -1,7 +1,7 @@
project(
'n-acd',
'c',
- version: '1',
+ version: '2',
license: 'Apache',
default_options: [
'c_std=c11',
@@ -15,10 +15,12 @@ mod_pkgconfig = import('pkgconfig')
sub_clist = subproject('c-list')
sub_crbtree = subproject('c-rbtree')
sub_csiphash = subproject('c-siphash')
+sub_cstdaux = subproject('c-stdaux')
dep_clist = sub_clist.get_variable('libclist_dep')
dep_crbtree = sub_crbtree.get_variable('libcrbtree_dep')
dep_csiphash = sub_csiphash.get_variable('libcsiphash_dep')
+dep_cstdaux = sub_cstdaux.get_variable('libcstdaux_dep')
use_ebpf = get_option('ebpf')
diff --git a/shared/n-acd/src/meson.build b/shared/n-acd/src/meson.build
index 0a405f9c4d..3e92681f91 100644
--- a/shared/n-acd/src/meson.build
+++ b/shared/n-acd/src/meson.build
@@ -8,6 +8,7 @@ libnacd_deps = [
dep_clist,
dep_crbtree,
dep_csiphash,
+ dep_cstdaux,
]
libnacd_sources = [
diff --git a/shared/n-acd/src/n-acd-bpf-fallback.c b/shared/n-acd/src/n-acd-bpf-fallback.c
index 7270cfd9ff..3cf4eb0679 100644
--- a/shared/n-acd/src/n-acd-bpf-fallback.c
+++ b/shared/n-acd/src/n-acd-bpf-fallback.c
@@ -7,6 +7,7 @@
* See n-acd-bpf.c for documentation.
*/
+#include <c-stdaux.h>
#include <stddef.h>
#include "n-acd-private.h"
diff --git a/shared/n-acd/src/n-acd-bpf.c b/shared/n-acd/src/n-acd-bpf.c
index 771a28eeb2..57b29ddf2f 100644
--- a/shared/n-acd/src/n-acd-bpf.c
+++ b/shared/n-acd/src/n-acd-bpf.c
@@ -12,6 +12,7 @@
* that have already been removed.
*/
+#include <c-stdaux.h>
#include <errno.h>
#include <inttypes.h>
#include <linux/bpf.h>
diff --git a/shared/n-acd/src/n-acd-private.h b/shared/n-acd/src/n-acd-private.h
index 3f20791234..4583c018e2 100644
--- a/shared/n-acd/src/n-acd-private.h
+++ b/shared/n-acd/src/n-acd-private.h
@@ -2,6 +2,7 @@
#include <c-list.h>
#include <c-rbtree.h>
+#include <c-stdaux.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/if_ether.h>
@@ -13,9 +14,6 @@
typedef struct NAcdEventNode NAcdEventNode;
-#define _cleanup_(_x) __attribute__((__cleanup__(_x)))
-#define _public_ __attribute__((__visibility__("default")))
-
/* This augments the error-codes with internal ones that are never exposed. */
enum {
_N_ACD_INTERNAL = _N_ACD_E_N,
@@ -150,23 +148,7 @@ int n_acd_bpf_compile(int *progfdp, int mapfd, struct ether_addr *mac);
/* inline helpers */
-static inline int n_acd_errno(void) {
- /*
- * Compilers continuously warn about uninitialized variables since they
- * cannot deduce that `return -errno;` will always be negative. This
- * small wrapper makes sure compilers figure that out. Use it as
- * replacement for `errno` read access. Yes, it generates worse code,
- * but only marginally and only affects slow-paths.
- */
- return abs(errno) ? : EIO;
-}
-
static inline void n_acd_event_node_freep(NAcdEventNode **node) {
if (*node)
n_acd_event_node_free(*node);
}
-
-static inline void n_acd_closep(int *fdp) {
- if (*fdp >= 0)
- close(*fdp);
-}
diff --git a/shared/n-acd/src/n-acd-probe.c b/shared/n-acd/src/n-acd-probe.c
index d4da0fd5c7..43dd344c38 100644
--- a/shared/n-acd/src/n-acd-probe.c
+++ b/shared/n-acd/src/n-acd-probe.c
@@ -1,9 +1,14 @@
/*
* IPv4 Address Conflict Detection
+ *
+ * This file implements the probe object. A probe is basically the
+ * state-machine of a single ACD run. It takes an address to probe for, checks
+ * for conflicts and then defends it once configured.
*/
#include <assert.h>
#include <c-rbtree.h>
+#include <c-stdaux.h>
#include <endian.h>
#include <errno.h>
#include <inttypes.h>
@@ -19,8 +24,8 @@
#include "n-acd-private.h"
/*
- * These parameters and timing intervals specified in RFC-5227. The original
- * values are:
+ * These parameters and timing intervals are specified in RFC-5227. The
+ * original values are:
*
* PROBE_NUM 3
* PROBE_WAIT 1s
@@ -66,10 +71,19 @@
#define N_ACD_RFC_DEFEND_INTERVAL_NSEC (UINT64_C(10000000000)) /* 10s */
/**
- * XXX
+ * n_acd_probe_config_new() - create probe configuration
+ * @configp: output argument for new probe configuration
+ *
+ * This creates a new probe configuration. It will be returned in @configp to
+ * the caller, which upon return fully owns the object.
+ *
+ * A probe configuration collects parameters for probes. It never validates the
+ * input, but this is left to the consumer of the configuration to do.
+ *
+ * Return: 0 on success, negative error code on failure.
*/
-_public_ int n_acd_probe_config_new(NAcdProbeConfig **configp) {
- _cleanup_(n_acd_probe_config_freep) NAcdProbeConfig *config = NULL;
+_c_public_ int n_acd_probe_config_new(NAcdProbeConfig **configp) {
+ _c_cleanup_(n_acd_probe_config_freep) NAcdProbeConfig *config = NULL;
config = malloc(sizeof(*config));
if (!config)
@@ -83,9 +97,15 @@ _public_ int n_acd_probe_config_new(NAcdProbeConfig **configp) {
}
/**
- * XXX
+ * n_acd_probe_config_free() - destroy probe configuration
+ * @config: configuration to operate on, or NULL
+ *
+ * This destroys the probe configuration and all associated objects. If @config
+ * is NULL, this is a no-op.
+ *
+ * Return: NULL is returned.
*/
-_public_ NAcdProbeConfig *n_acd_probe_config_free(NAcdProbeConfig *config) {
+_c_public_ NAcdProbeConfig *n_acd_probe_config_free(NAcdProbeConfig *config) {
if (!config)
return NULL;
@@ -95,16 +115,45 @@ _public_ NAcdProbeConfig *n_acd_probe_config_free(NAcdProbeConfig *config) {
}
/**
- * XXX
+ * n_acd_probe_config_set_ip() - set ip property
+ * @config: configuration to operate on
+ * @ip: ip to set
+ *
+ * This sets the IP property to the value `ip`. The address is copied into the
+ * configuration object. No validation is performed.
+ *
+ * The IP property selects the IP address that a probe checks for. It is the
+ * caller's responsibility to guarantee the address is valid and can be used.
*/
-_public_ void n_acd_probe_config_set_ip(NAcdProbeConfig *config, struct in_addr ip) {
+_c_public_ void n_acd_probe_config_set_ip(NAcdProbeConfig *config, struct in_addr ip) {
config->ip = ip;
}
/**
- * XXX
+ * n_acd_probe_config_set_timeout() - set timeout property
+ * @config: configuration to operate on
+ * @msecs: timeout to set, in milliseconds
+ *
+ * This sets the timeout to use for a conflict detection probe. The
+ * specification default is provided as `N_ACD_TIMEOUT_RFC5227` and corresponds
+ * to 9 seconds.
+ *
+ * If set to 0, conflict detection is skipped and the address is immediately
+ * advertised and defended.
+ *
+ * Depending on the transport used, the API user should select a suitable
+ * timeout. Since `ACD` only operates on the link layer, timeouts in the
+ * hundreds of milliseconds range should be more than enough for any modern
+ * network. Note that increasing this value directly affects the time it takes
+ * to connect to a network, since an address should not be used unless conflict
+ * detection finishes.
+ *
+ * Using the specification default is **discouraged**. It is way too slow and
+ * not appropriate for modern networks.
+ *
+ * Default value is `N_ACD_TIMEOUT_RFC5227`.
*/
-_public_ void n_acd_probe_config_set_timeout(NAcdProbeConfig *config, uint64_t msecs) {
+_c_public_ void n_acd_probe_config_set_timeout(NAcdProbeConfig *config, uint64_t msecs) {
config->timeout_msecs = msecs;
}
@@ -214,15 +263,14 @@ static void n_acd_probe_unlink(NAcdProbe *probe) {
*/
if (n_acd_probe_is_unique(probe)) {
r = n_acd_bpf_map_remove(probe->acd->fd_bpf_map, &probe->ip);
- assert(r >= 0);
- (void)r;
+ c_assert(r >= 0);
--probe->acd->n_bpf_map;
}
c_rbnode_unlink(&probe->ip_node);
}
int n_acd_probe_new(NAcdProbe **probep, NAcd *acd, NAcdProbeConfig *config) {
- _cleanup_(n_acd_probe_freep) NAcdProbe *probe = NULL;
+ _c_cleanup_(n_acd_probe_freep) NAcdProbe *probe = NULL;
int r;
if (!config->ip.s_addr)
@@ -286,9 +334,20 @@ int n_acd_probe_new(NAcdProbe **probep, NAcd *acd, NAcdProbeConfig *config) {
}
/**
- * XXX
+ * n_acd_probe_free() - destroy a probe
+ * @probe: probe to operate on, or NULL
+ *
+ * This destroys the probe specified by @probe. All operations are immediately
+ * ceded and all associated objects are released.
+ *
+ * If @probe is NULL, this is a no-op.
+ *
+ * This function will flush all events associated with @probe from the event
+ * queue. That is, no events will be returned for this @probe anymore.
+ *
+ * Return: NULL is returned.
*/
-_public_ NAcdProbe *n_acd_probe_free(NAcdProbe *probe) {
+_c_public_ NAcdProbe *n_acd_probe_free(NAcdProbe *probe) {
NAcdEventNode *node, *t_node;
if (!probe)
@@ -306,7 +365,7 @@ _public_ NAcdProbe *n_acd_probe_free(NAcdProbe *probe) {
}
int n_acd_probe_raise(NAcdProbe *probe, NAcdEventNode **nodep, unsigned int event) {
- _cleanup_(n_acd_event_node_freep) NAcdEventNode *node = NULL;
+ _c_cleanup_(n_acd_event_node_freep) NAcdEventNode *node = NULL;
int r;
r = n_acd_raise(probe->acd, &node, event);
@@ -327,8 +386,8 @@ int n_acd_probe_raise(NAcdProbe *probe, NAcdEventNode **nodep, unsigned int even
node->event.conflict.probe = probe;
break;
default:
- assert(0);
- return -EIO;
+ c_assert(0);
+ return -ENOTRECOVERABLE;
}
c_list_link_tail(&probe->event_list, &node->probe_link);
@@ -451,8 +510,8 @@ int n_acd_probe_handle_timeout(NAcdProbe *probe) {
* There are no timeouts in these states. If we trigger one,
* something is fishy.
*/
- assert(0);
- return -EIO;
+ c_assert(0);
+ return -ENOTRECOVERABLE;
}
return 0;
@@ -583,31 +642,47 @@ int n_acd_probe_handle_packet(NAcdProbe *probe, struct ether_arp *packet, bool h
* We are not listening for packets in these states. If we receive one,
* something is fishy.
*/
- assert(0);
- return -EIO;
+ c_assert(0);
+ return -ENOTRECOVERABLE;
}
return 0;
}
/**
- * n_acd_probe_set_userdata - XXX
+ * n_acd_probe_set_userdata - set userdata
+ * @probe: probe to operate on
+ * @userdata: userdata pointer
+ *
+ * This can be used to set a caller-controlled user-data pointer on @probe. The
+ * value of the pointer is never inspected or used by `n-acd` and is fully
+ * under control of the caller.
+ *
+ * The default value is NULL.
*/
-_public_ void n_acd_probe_set_userdata(NAcdProbe *probe, void *userdata) {
+_c_public_ void n_acd_probe_set_userdata(NAcdProbe *probe, void *userdata) {
probe->userdata = userdata;
}
/**
- * n_acd_probe_get_userdata - XXX
+ * n_acd_probe_get_userdata - get userdata
+ * @probe: probe to operate on
+ *
+ * This queries the userdata pointer that was previously set through
+ * n_acd_probe_set_userdata().
+ *
+ * The default value is NULL.
+ *
+ * Return: The stored userdata pointer is returned.
*/
-_public_ void n_acd_probe_get_userdata(NAcdProbe *probe, void **userdatap) {
+_c_public_ void n_acd_probe_get_userdata(NAcdProbe *probe, void **userdatap) {
*userdatap = probe->userdata;
}
/**
* n_acd_probe_announce() - announce the configured IP address
- * @probe: probe object
- * @defend: defence policy
+ * @probe: probe to operate on
+ * @defend: defence policy
*
* Announce the IP address on the local link, and start defending it according
* to the given policy, which mut be one of N_ACD_DEFEND_ONCE,
@@ -619,7 +694,7 @@ _public_ void n_acd_probe_get_userdata(NAcdProbe *probe, void **userdatap) {
* Return: 0 on success, N_ACD_E_INVALID_ARGUMENT in case the defence policy
* is invalid, negative error code on failure.
*/
-_public_ int n_acd_probe_announce(NAcdProbe *probe, unsigned int defend) {
+_c_public_ int n_acd_probe_announce(NAcdProbe *probe, unsigned int defend) {
if (defend >= _N_ACD_DEFEND_N)
return N_ACD_E_INVALID_ARGUMENT;
diff --git a/shared/n-acd/src/n-acd.c b/shared/n-acd/src/n-acd.c
index def56a2152..a0a48c5889 100644
--- a/shared/n-acd/src/n-acd.c
+++ b/shared/n-acd/src/n-acd.c
@@ -1,11 +1,56 @@
/*
* IPv4 Address Conflict Detection
+ *
+ * This file contains the main context initialization and management functions,
+ * as well as a bunch of utilities used through the n-acd modules.
+ */
+
+/**
+ * DOC: IPv4 Address Conflict Detection
+ *
+ * The `n-acd` project implements the IPv4 Address Conflict Detection protocol
+ * as defined in RFC-5227. The protocol originates in the IPv4 Link Local
+ * Address selection but was later on generalized and resulted in `ACD`. The
+ * idea is to use `ARP` to query a link for an address to see whether it
+ * already exists on the network, as well as defending an address that is in
+ * use on a network interface. Furthermore, `ACD` provides passive diagnostics
+ * for administrators, as it will detect address conflicts automatically, which
+ * then can be logged or shown to a user.
+ *
+ * The main context object of `n-acd` is the `NAcd` structure. It is a passive
+ * ref-counted context object which drives `ACD` probes running on it. A
+ * context is specific to a linux network device and transport. If multiple
+ * network devices are used, then separate `NAcd` contexts must be deployed.
+ *
+ * The `NAcdProbe` object drives a single `ACD` state-machine. A probe is
+ * created on an `NAcd` context by providing an address to probe for. The probe
+ * will then raise notifications whether the address conflict detection found
+ * something, or whether the address is ready to be used. Optionally, the probe
+ * will then enter into passive mode and defend the address as long as it is
+ * kept active.
+ *
+ * Note that the `n-acd` project only implements the networking protocol. It
+ * never queries or modifies network interfaces. It completely relies on the
+ * API user to react to notifications and update network interfaces
+ * respectively. `n-acd` uses an event-mechanism on every context object. All
+ * events raise by any probe or operation on a given context will queue all
+ * events on that context object. The event-queue can then be drained by the
+ * API user. All events are properly asynchronous and designed in a way that no
+ * synchronous reaction to any event is required. That is, the events are
+ * carefully designed to allow forwarding via IPC (or even networks) to a
+ * controller that handles them and specifies how to react. Furthermore, none
+ * of the function calls of `n-acd` require synchronous error handling.
+ * Instead, functions only ever return values on fatal errors. Everything else
+ * is queued as events, thus guaranteeing that synchronous handling of return
+ * values is not required. Exceptions are functions that do not affect internal
+ * state or do not have an associated context object.
*/
#include <assert.h>
#include <c-list.h>
#include <c-rbtree.h>
#include <c-siphash.h>
+#include <c-stdaux.h>
#include <endian.h>
#include <errno.h>
#include <inttypes.h>
@@ -55,7 +100,7 @@ static int n_acd_get_random(unsigned int *random) {
r = clock_gettime(CLOCK_MONOTONIC, &ts);
if (r < 0)
- return -n_acd_errno();
+ return -c_errno();
c_siphash_append(&hash, (const uint8_t *)&ts.tv_sec, sizeof(ts.tv_sec));
c_siphash_append(&hash, (const uint8_t *)&ts.tv_nsec, sizeof(ts.tv_nsec));
@@ -76,19 +121,19 @@ static int n_acd_socket_new(int *fdp, int fd_bpf_prog, NAcdConfig *config) {
s = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
if (s < 0) {
- r = -n_acd_errno();
+ r = -c_errno();
goto error;
}
if (fd_bpf_prog >= 0) {
r = setsockopt(s, SOL_SOCKET, SO_ATTACH_BPF, &fd_bpf_prog, sizeof(fd_bpf_prog));
if (r < 0)
- return -n_acd_errno();
+ return -c_errno();
}
r = bind(s, (struct sockaddr *)&address, sizeof(address));
if (r < 0) {
- r = -n_acd_errno();
+ r = -c_errno();
goto error;
}
@@ -103,10 +148,21 @@ error:
}
/**
- * XXX
+ * n_acd_config_new() - create configuration object
+ * @configp: output argument for new configuration
+ *
+ * This creates a new configuration object and provides it to the caller. The
+ * object is fully owned by the caller upon function return.
+ *
+ * A configuration object is a passive structure that is used to collect
+ * information that is then passed to a constructor or other function. A
+ * configuration never validates the data, but it is up to the consumer of a
+ * configuration to do that.
+ *
+ * Return: 0 on success, negative error code on failure.
*/
-_public_ int n_acd_config_new(NAcdConfig **configp) {
- _cleanup_(n_acd_config_freep) NAcdConfig *config = NULL;
+_c_public_ int n_acd_config_new(NAcdConfig **configp) {
+ _c_cleanup_(n_acd_config_freep) NAcdConfig *config = NULL;
config = malloc(sizeof(*config));
if (!config)
@@ -120,9 +176,15 @@ _public_ int n_acd_config_new(NAcdConfig **configp) {
}
/**
- * XXX
+ * n_acd_config_free() - destroy configuration object
+ * @config: configuration to operate on, or NULL
+ *
+ * This destroys the configuration object @config. If @config is NULL, this is
+ * a no-op.
+ *
+ * Return: NULL is returned.
*/
-_public_ NAcdConfig *n_acd_config_free(NAcdConfig *config) {
+_c_public_ NAcdConfig *n_acd_config_free(NAcdConfig *config) {
if (!config)
return NULL;
@@ -132,23 +194,55 @@ _public_ NAcdConfig *n_acd_config_free(NAcdConfig *config) {
}
/**
- * XXX
+ * n_acd_config_set_ifindex() - set ifindex property
+ * @config: configuration to operate on
+ * @ifindex: ifindex to set
+ *
+ * This sets the @ifindex property of the configuration object. Any previous
+ * value is overwritten.
+ *
+ * A valid ifindex is a 32bit integer greater than 0. Any other value is
+ * treated as unspecified.
+ *
+ * The ifindex corresponds to the interface index provided by the linux kernel.
+ * It specifies the network device to be used.
*/
-_public_ void n_acd_config_set_ifindex(NAcdConfig *config, int ifindex) {
+_c_public_ void n_acd_config_set_ifindex(NAcdConfig *config, int ifindex) {
config->ifindex = ifindex;
}
/**
- * XXX
+ * n_acd_config_set_transport() - set transport property
+ * @config: configuration to operate on
+ * @transport: transport to set
+ *
+ * This specifies the transport to use. A transport must be one of the
+ * `N_ACD_TRANSPORT_*` identifiers. It selects which transport protocol `n-acd`
+ * will run on.
*/
-_public_ void n_acd_config_set_transport(NAcdConfig *config, unsigned int transport) {
+_c_public_ void n_acd_config_set_transport(NAcdConfig *config, unsigned int transport) {
config->transport = transport;
}
/**
- * XXX
+ * n_acd_config_set_mac() - set mac property
+ * @config: configuration to operate on
+ * @mac: mac to set
+ *
+ * This specifies the hardware address (also referred to as `MAC Address`) to
+ * use. Any hardware address can be specified. It is the caller's
+ * responsibility to make sure the address can actually be used.
+ *
+ * The address in @mac is copied into @config. It does not have to be retained
+ * by the caller.
*/
-_public_ void n_acd_config_set_mac(NAcdConfig *config, const uint8_t *mac, size_t n_mac) {
+_c_public_ void n_acd_config_set_mac(NAcdConfig *config, const uint8_t *mac, size_t n_mac) {
+ /*
+ * We truncate the address at the maximum we support. We still remember
+ * the original length, so any consumer of this configuration can then
+ * complain about an unsupported address length. This allows us to
+ * avoid a memory allocation here and having to return `int`.
+ */
config->n_mac = n_mac;
memcpy(config->mac, mac, n_mac > ETH_ALEN ? ETH_ALEN : n_mac);
}
@@ -179,7 +273,7 @@ NAcdEventNode *n_acd_event_node_free(NAcdEventNode *node) {
int n_acd_ensure_bpf_map_space(NAcd *acd) {
NAcdProbe *probe;
- _cleanup_(n_acd_closep) int fd_map = -1, fd_prog = -1;
+ _c_cleanup_(c_closep) int fd_map = -1, fd_prog = -1;
size_t max_map;
int r;
@@ -205,7 +299,7 @@ int n_acd_ensure_bpf_map_space(NAcd *acd) {
if (fd_prog >= 0) {
r = setsockopt(acd->fd_socket, SOL_SOCKET, SO_ATTACH_BPF, &fd_prog, sizeof(fd_prog));
if (r)
- return -n_acd_errno();
+ return -c_errno();
}
if (acd->fd_bpf_map >= 0)
@@ -218,16 +312,20 @@ int n_acd_ensure_bpf_map_space(NAcd *acd) {
/**
* n_acd_new() - create a new ACD context
- * @acdp: output argument for context
- * @config: configuration parameters
+ * @acdp: output argument for new context object
+ * @config: configuration parameters
*
- * Create a new ACD context and return it in @acdp.
+ * Create a new ACD context and return it in @acdp. The configuration @config
+ * must be initialized by the caller and must specify a valid network
+ * interface, transport mechanism, as well as hardware address compatible with
+ * the selected transport. The configuration is copied into the context. The
+ * @config object thus does not have to be retained by the caller.
*
- * Return: 0 on success, or a negative error code on failure.
+ * Return: 0 on success, negative error code on failure.
*/
-_public_ int n_acd_new(NAcd **acdp, NAcdConfig *config) {
- _cleanup_(n_acd_unrefp) NAcd *acd = NULL;
- _cleanup_(n_acd_closep) int fd_bpf_prog = -1;
+_c_public_ int n_acd_new(NAcd **acdp, NAcdConfig *config) {
+ _c_cleanup_(n_acd_unrefp) NAcd *acd = NULL;
+ _c_cleanup_(c_closep) int fd_bpf_prog = -1;
int r;
if (config->ifindex <= 0 ||
@@ -250,7 +348,7 @@ _public_ int n_acd_new(NAcd **acdp, NAcdConfig *config) {
acd->fd_epoll = epoll_create1(EPOLL_CLOEXEC);
if (acd->fd_epoll < 0)
- return -n_acd_errno();
+ return -c_errno();
r = timer_init(&acd->timer);
if (r < 0)
@@ -276,7 +374,7 @@ _public_ int n_acd_new(NAcd **acdp, NAcdConfig *config) {
.data.u32 = N_ACD_EPOLL_TIMER,
});
if (r < 0)
- return -n_acd_errno();
+ return -c_errno();
r = epoll_ctl(acd->fd_epoll, EPOLL_CTL_ADD, acd->fd_socket,
&(struct epoll_event){
@@ -284,14 +382,14 @@ _public_ int n_acd_new(NAcd **acdp, NAcdConfig *config) {
.data.u32 = N_ACD_EPOLL_SOCKET,
});
if (r < 0)
- return -n_acd_errno();
+ return -c_errno();
*acdp = acd;
acd = NULL;
return 0;
}
-static void n_acd_free(NAcd *acd) {
+static void n_acd_free_internal(NAcd *acd) {
NAcdEventNode *node, *t_node;
if (!acd)
@@ -300,10 +398,10 @@ static void n_acd_free(NAcd *acd) {
c_list_for_each_entry_safe(node, t_node, &acd->event_list, acd_link)
n_acd_event_node_free(node);
- assert(c_rbtree_is_empty(&acd->ip_tree));
+ c_assert(c_rbtree_is_empty(&acd->ip_tree));
if (acd->fd_socket >= 0) {
- assert(acd->fd_epoll >= 0);
+ c_assert(acd->fd_epoll >= 0);
epoll_ctl(acd->fd_epoll, EPOLL_CTL_DEL, acd->fd_socket, NULL);
close(acd->fd_socket);
acd->fd_socket = -1;
@@ -315,7 +413,7 @@ static void n_acd_free(NAcd *acd) {
}
if (acd->timer.fd >= 0) {
- assert(acd->fd_epoll >= 0);
+ c_assert(acd->fd_epoll >= 0);
epoll_ctl(acd->fd_epoll, EPOLL_CTL_DEL, acd->timer.fd, NULL);
timer_deinit(&acd->timer);
}
@@ -329,20 +427,32 @@ static void n_acd_free(NAcd *acd) {
}
/**
- * XXX
+ * n_acd_ref() - acquire reference
+ * @acd: context to operate on, or NULL
+ *
+ * This acquires a single reference to the context specified as @acd. If @acd
+ * is NULL, this is a no-op.
+ *
+ * Return: @acd is returned.
*/
-_public_ NAcd *n_acd_ref(NAcd *acd) {
+_c_public_ NAcd *n_acd_ref(NAcd *acd) {
if (acd)
++acd->n_refs;
return acd;
}
/**
- * XXX
+ * n_acd_unref() - release reference
+ * @acd: context to operate on, or NULL
+ *
+ * This releases a single reference to the context @acd. If this is the last
+ * reference, the context is torn down and deallocated.
+ *
+ * Return: NULL is returned.
*/
-_public_ NAcd *n_acd_unref(NAcd *acd) {
+_c_public_ NAcd *n_acd_unref(NAcd *acd) {
if (acd && !--acd->n_refs)
- n_acd_free(acd);
+ n_acd_free_internal(acd);
return NULL;
}
@@ -426,7 +536,7 @@ int n_acd_send(NAcd *acd, const struct in_addr *tpa, const struct in_addr *spa)
* Random network error. We treat this as fatal and propagate
* the error, so it is noticed and can be investigated.
*/
- return -n_acd_errno();
+ return -c_errno();
} else if (l != (ssize_t)sizeof(arp)) {
/*
* Ugh, the kernel modified the packet. This is unexpected. We
@@ -440,13 +550,22 @@ int n_acd_send(NAcd *acd, const struct in_addr *tpa, const struct in_addr *spa)
/**
* n_acd_get_fd() - get pollable file descriptor
- * @acd: ACD context
- * @fdp: output argument for file descriptor
+ * @acd: context object to operate on
+ * @fdp: output argument for file descriptor
+ *
+ * This returns the backing file-descriptor of the context object @acd. The
+ * file-descriptor is owned by @acd and valid as long as @acd is. The
+ * file-descriptor never changes, so it can be cached by the caller as long as
+ * they hold a reference to @acd.
+ *
+ * The file-descriptor is internal to the @acd context and should not be
+ * modified by the caller. It is only exposed to allow the caller to poll on
+ * it. Whenever the file-descriptor polls readable, n_acd_dispatch() should be
+ * called.
*
- * Returns a file descriptor in @fdp. This file descriptor can be polled by
- * the caller to indicate when the ACD context can be dispatched.
+ * Currently, the file-descriptor is an epoll-fd.
*/
-_public_ void n_acd_get_fd(NAcd *acd, int *fdp) {
+_c_public_ void n_acd_get_fd(NAcd *acd, int *fdp) {
*fdp = acd->fd_epoll;
}
@@ -597,7 +716,7 @@ static int n_acd_dispatch_timer(NAcd *acd, struct epoll_event *event) {
if (r <= 0)
return r;
- assert(r == TIMER_E_TRIGGERED);
+ c_assert(r == TIMER_E_TRIGGERED);
/*
* A timer triggered, handle all pending timeouts at a given
@@ -710,7 +829,7 @@ static int n_acd_dispatch_socket(NAcd *acd, struct epoll_event *event) {
* Something went wrong. Propagate the error-code, so
* this can be investigated.
*/
- return -n_acd_errno();
+ return -c_errno();
}
} else if (n >= (ssize_t)n_batch) {
/*
@@ -750,16 +869,34 @@ static int n_acd_dispatch_socket(NAcd *acd, struct epoll_event *event) {
}
/**
- * XXX
+ * n_acd_dispatch() - dispatch context
+ * @acd: context object to operate on
+ *
+ * This dispatches the internal state-machine of all probes and operations
+ * running on the context @acd.
+ *
+ * Any outside effect or event triggered by this dispatcher will be queued on
+ * the event-queue of @acd. Whenever the dispatcher returns, the caller is
+ * required to drain the event-queue via n_acd_pop_event() until it is empty.
+ *
+ * This function dispatches as many events as possible up to a static limit to
+ * prevent stalling execution. If the static limit is reached, this function
+ * will return with N_ACD_E_PREEMPTED, otherwise 0 is returned. In most cases
+ * preemption can be ignored, because level-triggered event notification
+ * handles it automatically. However, in case of edge-triggered event
+ * mechanisms, the caller must make sure to call the dispatcher again.
+ *
+ * Return: 0 on success, N_ACD_E_PREEMPTED on preemption, negative error code
+ * on failure.
*/
-_public_ int n_acd_dispatch(NAcd *acd) {
+_c_public_ int n_acd_dispatch(NAcd *acd) {
struct epoll_event events[2];
int n, i, r = 0;
n = epoll_wait(acd->fd_epoll, events, sizeof(events) / sizeof(*events), 0);
if (n < 0) {
/* Linux never returns EINTR if `timeout == 0'. */
- return -n_acd_errno();
+ return -c_errno();
}
acd->preempted = false;
@@ -773,7 +910,7 @@ _public_ int n_acd_dispatch(NAcd *acd) {
r = n_acd_dispatch_socket(acd, events + i);
break;
default:
- assert(0);
+ c_assert(0);
r = 0;
break;
}
@@ -787,8 +924,8 @@ _public_ int n_acd_dispatch(NAcd *acd) {
/**
* n_acd_pop_event() - get the next pending event
- * @acd: ACD context
- * @eventp: output argument for the event
+ * @acd: context object to operate on
+ * @eventp: output argument for the event
*
* Returns a pointer to the next pending event. The event is still owend by
* the context, and is only valid until the next call to n_acd_pop_event()
@@ -840,7 +977,7 @@ _public_ int n_acd_dispatch(NAcd *acd) {
* @eventp and 0 is returned. If an error is returned, @eventp is left
* untouched.
*/
-_public_ int n_acd_pop_event(NAcd *acd, NAcdEvent **eventp) {
+_c_public_ int n_acd_pop_event(NAcd *acd, NAcdEvent **eventp) {
NAcdEventNode *node, *t_node;
c_list_for_each_entry_safe(node, t_node, &acd->event_list, acd_link) {
@@ -859,8 +996,29 @@ _public_ int n_acd_pop_event(NAcd *acd, NAcdEvent **eventp) {
}
/**
- * XXX
+ * n_acd_probe() - start new probe
+ * @acd: context object to operate on
+ * @probep: output argument for new probe
+ * @config: probe configuration
+ *
+ * This creates a new probe on the context @acd and returns the probe in
+ * @probep. The configuration @config must provide valid probe parameters. At
+ * least a valid IP address must be provided through the configuration.
+ *
+ * This function does not reject duplicate probes for the same address. It is
+ * the caller's decision whether duplicates are allowed or not. But note that
+ * duplicate probes on the same context will not conflict each other. That is,
+ * running a probe for the same address twice on the same context will not
+ * cause them to consider each other a duplicate.
+ *
+ * Probes are rather lightweight objects. They do not create any
+ * file-descriptors or other kernel objects. Probes always re-use the
+ * infrastructure provided by the context object @acd. This allows running many
+ * probes simultaneously without exhausting resources.
+ *
+ * Return: 0 on success, N_ACD_E_INVALID_ARGUMENT on invalid configuration
+ * parameters, negative error code on failure.
*/
-_public_ int n_acd_probe(NAcd *acd, NAcdProbe **probep, NAcdProbeConfig *config) {
+_c_public_ int n_acd_probe(NAcd *acd, NAcdProbe **probep, NAcdProbeConfig *config) {
return n_acd_probe_new(probep, acd, config);
}
diff --git a/shared/n-acd/src/n-acd.h b/shared/n-acd/src/n-acd.h
index 74b0aacb59..e2b01270fa 100644
--- a/shared/n-acd/src/n-acd.h
+++ b/shared/n-acd/src/n-acd.h
@@ -13,7 +13,9 @@ extern "C" {
#endif
#include <netinet/in.h>
+#include <inttypes.h>
#include <stdbool.h>
+#include <stdlib.h>
typedef struct NAcd NAcd;
typedef struct NAcdConfig NAcdConfig;
diff --git a/shared/n-acd/src/test-api.c b/shared/n-acd/src/test-api.c
index e16de48b73..70f7520836 100644
--- a/shared/n-acd/src/test-api.c
+++ b/shared/n-acd/src/test-api.c
@@ -1,105 +1,88 @@
/*
* Tests for n-acd API
- * This verifies the visibility and availability of the public API of the
- * n-acd library.
+ * This verifies the visibility and availability of the public API.
*/
+#undef NDEBUG
+#include <assert.h>
#include <stdlib.h>
-#include "test.h"
-
-static void test_api(void) {
- NAcdConfig *config = NULL;
- NAcd *acd = NULL;
- int r;
-
- assert(N_ACD_E_PREEMPTED);
- assert(N_ACD_E_INVALID_ARGUMENT);
-
- assert(N_ACD_TRANSPORT_ETHERNET != _N_ACD_TRANSPORT_N);
-
- assert(N_ACD_EVENT_READY != _N_ACD_EVENT_N);
- assert(N_ACD_EVENT_USED != _N_ACD_EVENT_N);
- assert(N_ACD_EVENT_DEFENDED != _N_ACD_EVENT_N);
- assert(N_ACD_EVENT_CONFLICT != _N_ACD_EVENT_N);
- assert(N_ACD_EVENT_DOWN != _N_ACD_EVENT_N);
-
- assert(N_ACD_DEFEND_NEVER != _N_ACD_DEFEND_N);
- assert(N_ACD_DEFEND_ONCE != _N_ACD_DEFEND_N);
- assert(N_ACD_DEFEND_ALWAYS != _N_ACD_DEFEND_N);
-
- n_acd_config_freep(&config);
-
- r = n_acd_config_new(&config);
- assert(!r);
-
- n_acd_config_set_ifindex(config, 1);
- n_acd_config_set_transport(config, N_ACD_TRANSPORT_ETHERNET);
- n_acd_config_set_mac(config, (uint8_t[6]){ }, 6);
-
- {
- NAcdEvent *event;
- int fd;
-
- n_acd_unrefp(&acd);
- n_acd_ref(NULL);
-
- r = n_acd_new(&acd, config);
- assert(!r);
-
- n_acd_get_fd(acd, &fd);
- n_acd_dispatch(acd);
- n_acd_pop_event(acd, &event);
-
- {
- NAcdProbeConfig *c = NULL;
-
- n_acd_probe_config_freep(&c);
-
- r = n_acd_probe_config_new(&c);
- assert(!r);
-
- n_acd_probe_config_set_ip(c, (struct in_addr){ 1 });
- n_acd_probe_config_set_timeout(c, N_ACD_TIMEOUT_RFC5227);
-
- {
- NAcdProbe *probe = NULL;
- void *userdata;
-
- r = n_acd_probe(acd, &probe, c);
- assert(!r);
-
- n_acd_probe_get_userdata(probe, &userdata);
- assert(userdata == NULL);
- n_acd_probe_set_userdata(probe, acd);
- n_acd_probe_get_userdata(probe, &userdata);
- assert(userdata == acd);
-
- r = n_acd_probe_announce(probe, N_ACD_DEFEND_ONCE);
- assert(!r);
-
- n_acd_probe_free(probe);
- n_acd_probe_freev(NULL);
- }
-
- n_acd_probe_config_free(c);
- n_acd_probe_config_freev(NULL);
- }
+#include "n-acd.h"
+
+static void test_api_constants(void) {
+ assert(1 + N_ACD_TIMEOUT_RFC5227);
+
+ assert(1 + _N_ACD_E_SUCCESS);
+ assert(1 + N_ACD_E_PREEMPTED);
+ assert(1 + N_ACD_E_INVALID_ARGUMENT);
+ assert(1 + _N_ACD_E_N);
+
+ assert(1 + N_ACD_TRANSPORT_ETHERNET);
+ assert(1 + _N_ACD_TRANSPORT_N);
+
+ assert(1 + N_ACD_EVENT_READY);
+ assert(1 + N_ACD_EVENT_USED);
+ assert(1 + N_ACD_EVENT_DEFENDED);
+ assert(1 + N_ACD_EVENT_CONFLICT);
+ assert(1 + N_ACD_EVENT_DOWN);
+ assert(1 + _N_ACD_EVENT_N);
+
+ assert(1 + N_ACD_DEFEND_NEVER);
+ assert(1 + N_ACD_DEFEND_ONCE);
+ assert(1 + N_ACD_DEFEND_ALWAYS);
+ assert(1 + _N_ACD_DEFEND_N);
+}
- n_acd_unref(acd);
- n_acd_unrefv(NULL);
- }
+static void test_api_types(void) {
+ assert(sizeof(NAcdEvent*));
+ assert(sizeof(NAcdConfig*));
+ assert(sizeof(NAcdProbeConfig*));
+ assert(sizeof(NAcd*));
+ assert(sizeof(NAcdProbe*));
+}
- n_acd_config_free(config);
- n_acd_config_freev(NULL);
+static void test_api_functions(void) {
+ void *fns[] = {
+ (void *)n_acd_config_new,
+ (void *)n_acd_config_free,
+ (void *)n_acd_config_set_ifindex,
+ (void *)n_acd_config_set_transport,
+ (void *)n_acd_config_set_mac,
+ (void *)n_acd_probe_config_new,
+ (void *)n_acd_probe_config_free,
+ (void *)n_acd_probe_config_set_ip,
+ (void *)n_acd_probe_config_set_timeout,
+
+ (void *)n_acd_new,
+ (void *)n_acd_ref,
+ (void *)n_acd_unref,
+ (void *)n_acd_get_fd,
+ (void *)n_acd_dispatch,
+ (void *)n_acd_pop_event,
+ (void *)n_acd_probe,
+
+ (void *)n_acd_probe_free,
+ (void *)n_acd_probe_set_userdata,
+ (void *)n_acd_probe_get_userdata,
+ (void *)n_acd_probe_announce,
+
+ (void *)n_acd_config_freep,
+ (void *)n_acd_config_freev,
+ (void *)n_acd_probe_config_freep,
+ (void *)n_acd_probe_config_freev,
+ (void *)n_acd_unrefp,
+ (void *)n_acd_unrefv,
+ (void *)n_acd_probe_freep,
+ (void *)n_acd_probe_freev,
+ };
+ size_t i;
+
+ for (i = 0; i < sizeof(fns) / sizeof(*fns); ++i)
+ assert(!!fns[i]);
}
int main(int argc, char **argv) {
- int r;
-
- r = test_setup();
- if (r)
- return r;
-
- test_api();
+ test_api_constants();
+ test_api_types();
+ test_api_functions();
return 0;
}
diff --git a/shared/n-acd/src/test-bpf.c b/shared/n-acd/src/test-bpf.c
index aa8b20ec30..d1f11aaa27 100644
--- a/shared/n-acd/src/test-bpf.c
+++ b/shared/n-acd/src/test-bpf.c
@@ -2,7 +2,9 @@
* eBPF socket filter tests
*/
+#undef NDEBUG
#include <assert.h>
+#include <c-stdaux.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/if_ether.h>
@@ -46,23 +48,23 @@ static void test_map(void) {
struct in_addr addr = { 1 };
r = n_acd_bpf_map_create(&mapfd, 8);
- assert(r >= 0);
- assert(mapfd >= 0);
+ c_assert(r >= 0);
+ c_assert(mapfd >= 0);
r = n_acd_bpf_map_remove(mapfd, &addr);
- assert(r == -ENOENT);
+ c_assert(r == -ENOENT);
r = n_acd_bpf_map_add(mapfd, &addr);
- assert(r >= 0);
+ c_assert(r >= 0);
r = n_acd_bpf_map_add(mapfd, &addr);
- assert(r == -EEXIST);
+ c_assert(r == -EEXIST);
r = n_acd_bpf_map_remove(mapfd, &addr);
- assert(r >= 0);
+ c_assert(r >= 0);
r = n_acd_bpf_map_remove(mapfd, &addr);
- assert(r == -ENOENT);
+ c_assert(r == -ENOENT);
close(mapfd);
}
@@ -72,10 +74,10 @@ static void verify_success(struct ether_arp *packet, int out_fd, int in_fd) {
int r;
r = send(out_fd, packet, sizeof(struct ether_arp), 0);
- assert(r == sizeof(struct ether_arp));
+ c_assert(r == sizeof(struct ether_arp));
r = recv(in_fd, buf, sizeof(buf), 0);
- assert(r == sizeof(struct ether_arp));
+ c_assert(r == sizeof(struct ether_arp));
}
static void verify_failure(struct ether_arp *packet, int out_fd, int in_fd) {
@@ -83,11 +85,11 @@ static void verify_failure(struct ether_arp *packet, int out_fd, int in_fd) {
int r;
r = send(out_fd, packet, sizeof(struct ether_arp), 0);
- assert(r == sizeof(struct ether_arp));
+ c_assert(r == sizeof(struct ether_arp));
r = recv(in_fd, buf, sizeof(buf), 0);
- assert(r < 0);
- assert(errno == EAGAIN);
+ c_assert(r < 0);
+ c_assert(errno == EAGAIN);
}
static void test_filter(void) {
@@ -101,21 +103,21 @@ static void test_filter(void) {
int r, mapfd = -1, progfd = -1, pair[2];
r = n_acd_bpf_map_create(&mapfd, 1);
- assert(r >= 0);
+ c_assert(r >= 0);
r = n_acd_bpf_compile(&progfd, mapfd, &mac1);
- assert(r >= 0);
- assert(progfd >= 0);
+ c_assert(r >= 0);
+ c_assert(progfd >= 0);
r = socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, pair);
- assert(r >= 0);
+ c_assert(r >= 0);
r = setsockopt(pair[1], SOL_SOCKET, SO_ATTACH_BPF, &progfd,
sizeof(progfd));
- assert(r >= 0);
+ c_assert(r >= 0);
r = n_acd_bpf_map_add(mapfd, &ip1);
- assert(r >= 0);
+ c_assert(r >= 0);
/* valid */
*packet = (struct ether_arp)ETHER_ARP_PACKET_INIT(ARPOP_REQUEST, &mac2, &ip1, &ip2);
@@ -173,19 +175,19 @@ static void test_filter(void) {
/* long */
*packet = (struct ether_arp)ETHER_ARP_PACKET_INIT(ARPOP_REQUEST, &mac2, &ip1, &ip2);
r = send(pair[0], buf, sizeof(struct ether_arp) + 1, 0);
- assert(r == sizeof(struct ether_arp) + 1);
+ c_assert(r == sizeof(struct ether_arp) + 1);
r = recv(pair[1], buf, sizeof(buf), 0);
- assert(r == sizeof(struct ether_arp));
+ c_assert(r == sizeof(struct ether_arp));
/* short */
*packet = (struct ether_arp)ETHER_ARP_PACKET_INIT(ARPOP_REQUEST, &mac2, &ip1, &ip2);
r = send(pair[0], buf, sizeof(struct ether_arp) - 1, 0);
- assert(r == sizeof(struct ether_arp) - 1);
+ c_assert(r == sizeof(struct ether_arp) - 1);
r = recv(pair[1], buf, sizeof(buf), 0);
- assert(r < 0);
- assert(errno == EAGAIN);
+ c_assert(r < 0);
+ c_assert(errno == EAGAIN);
/*
* Send one packet before and one packet after modifying the map,
@@ -193,20 +195,20 @@ static void test_filter(void) {
*/
*packet = (struct ether_arp)ETHER_ARP_PACKET_INIT(ARPOP_REQUEST, &mac2, &ip1, &ip2);
r = send(pair[0], buf, sizeof(struct ether_arp), 0);
- assert(r == sizeof(struct ether_arp));
+ c_assert(r == sizeof(struct ether_arp));
r = n_acd_bpf_map_remove(mapfd, &ip1);
- assert(r >= 0);
+ c_assert(r >= 0);
r = send(pair[0], buf, sizeof(struct ether_arp), 0);
- assert(r == sizeof(struct ether_arp));
+ c_assert(r == sizeof(struct ether_arp));
r = recv(pair[1], buf, sizeof(buf), 0);
- assert(r == sizeof(struct ether_arp));
+ c_assert(r == sizeof(struct ether_arp));
r = recv(pair[1], buf, sizeof(buf), 0);
- assert(r < 0);
- assert(errno == EAGAIN);
+ c_assert(r < 0);
+ c_assert(errno == EAGAIN);
close(pair[0]);
close(pair[1]);
@@ -215,11 +217,7 @@ static void test_filter(void) {
}
int main(int argc, char **argv) {
- int r;
-
- r = test_setup();
- if (r)
- return r;
+ test_setup();
test_map();
test_filter();
diff --git a/shared/n-acd/src/test-loopback.c b/shared/n-acd/src/test-loopback.c
index 5c01d65b68..0671cf6691 100644
--- a/shared/n-acd/src/test-loopback.c
+++ b/shared/n-acd/src/test-loopback.c
@@ -5,6 +5,8 @@
* non-spanning-tree networks, or on networks that echo packets.
*/
+#undef NDEBUG
+#include <c-stdaux.h>
#include <stdlib.h>
#include "test.h"
@@ -15,14 +17,14 @@ static void test_loopback(int ifindex, uint8_t *mac, size_t n_mac) {
int r, fd;
r = n_acd_config_new(&config);
- assert(!r);
+ c_assert(!r);
n_acd_config_set_ifindex(config, ifindex);
n_acd_config_set_transport(config, N_ACD_TRANSPORT_ETHERNET);
n_acd_config_set_mac(config, mac, n_mac);
r = n_acd_new(&acd, config);
- assert(!r);
+ c_assert(!r);
n_acd_config_free(config);
@@ -32,13 +34,13 @@ static void test_loopback(int ifindex, uint8_t *mac, size_t n_mac) {
struct in_addr ip = { htobe32((192 << 24) | (168 << 16) | (1 << 0)) };
r = n_acd_probe_config_new(&probe_config);
- assert(!r);
+ c_assert(!r);
n_acd_probe_config_set_ip(probe_config, ip);
n_acd_probe_config_set_timeout(probe_config, 100);
r = n_acd_probe(acd, &probe, probe_config);
- assert(!r);
+ c_assert(!r);
n_acd_probe_config_free(probe_config);
@@ -48,15 +50,15 @@ static void test_loopback(int ifindex, uint8_t *mac, size_t n_mac) {
NAcdEvent *event;
pfds = (struct pollfd){ .fd = fd, .events = POLLIN };
r = poll(&pfds, 1, -1);
- assert(r >= 0);
+ c_assert(r >= 0);
r = n_acd_dispatch(acd);
- assert(!r);
+ c_assert(!r);
r = n_acd_pop_event(acd, &event);
- assert(!r);
+ c_assert(!r);
if (event) {
- assert(event->event == N_ACD_EVENT_READY);
+ c_assert(event->event == N_ACD_EVENT_READY);
break;
}
}
@@ -69,11 +71,9 @@ static void test_loopback(int ifindex, uint8_t *mac, size_t n_mac) {
int main(int argc, char **argv) {
struct ether_addr mac;
- int r, ifindex;
+ int ifindex;
- r = test_setup();
- if (r)
- return r;
+ test_setup();
test_loopback_up(&ifindex, &mac);
test_loopback(ifindex, mac.ether_addr_octet, sizeof(mac.ether_addr_octet));
diff --git a/shared/n-acd/src/test-twice.c b/shared/n-acd/src/test-twice.c
index 157e8a2b96..b474502ee3 100644
--- a/shared/n-acd/src/test-twice.c
+++ b/shared/n-acd/src/test-twice.c
@@ -4,6 +4,8 @@
* it on both ends. We expect the PROBE to fail on at least one of the devices.
*/
+#undef NDEBUG
+#include <c-stdaux.h>
#include <stdlib.h>
#include "test.h"
@@ -29,17 +31,17 @@ static void test_unused(int ifindex1, uint8_t *mac1, size_t n_mac1, int ifindex2
int r, fd1, fd2, state1, state2;
r = n_acd_new(&acd1);
- assert(!r);
+ c_assert(!r);
r = n_acd_new(&acd2);
- assert(!r);
+ c_assert(!r);
n_acd_get_fd(acd1, &fd1);
n_acd_get_fd(acd2, &fd2);
r = n_acd_start(acd1, &config1);
- assert(!r);
+ c_assert(!r);
r = n_acd_start(acd2, &config2);
- assert(!r);
+ c_assert(!r);
for (state1 = state2 = -1; state1 == -1 || state2 == -1; ) {
NAcdEvent *event;
@@ -47,31 +49,31 @@ static void test_unused(int ifindex1, uint8_t *mac1, size_t n_mac1, int ifindex2
pfds[1] = (struct pollfd){ .fd = fd2, .events = (state2 == -1) ? POLLIN : 0 };
r = poll(pfds, sizeof(pfds) / sizeof(*pfds), -1);
- assert(r >= 0);
+ c_assert(r >= 0);
if (state1 == -1) {
r = n_acd_dispatch(acd1);
- assert(!r);
+ c_assert(!r);
r = n_acd_pop_event(acd1, &event);
if (!r) {
- assert(event->event == N_ACD_EVENT_READY || event->event == N_ACD_EVENT_USED);
+ c_assert(event->event == N_ACD_EVENT_READY || event->event == N_ACD_EVENT_USED);
state1 = !!(event->event == N_ACD_EVENT_READY);
} else {
- assert(r == N_ACD_E_DONE);
+ c_assert(r == N_ACD_E_DONE);
}
}
if (state2 == -1) {
r = n_acd_dispatch(acd2);
- assert(!r);
+ c_assert(!r);
r = n_acd_pop_event(acd2, &event);
if (!r) {
- assert(event->event == N_ACD_EVENT_READY || event->event == N_ACD_EVENT_USED);
+ c_assert(event->event == N_ACD_EVENT_READY || event->event == N_ACD_EVENT_USED);
state2 = !!(event->event == N_ACD_EVENT_READY);
} else {
- assert(r == N_ACD_E_DONE);
+ c_assert(r == N_ACD_E_DONE);
}
}
}
@@ -79,16 +81,14 @@ static void test_unused(int ifindex1, uint8_t *mac1, size_t n_mac1, int ifindex2
n_acd_free(acd1);
n_acd_free(acd2);
- assert(!state1 || !state2);
+ c_assert(!state1 || !state2);
}
int main(int argc, char **argv) {
struct ether_addr mac1, mac2;
- int r, ifindex1, ifindex2;
+ int ifindex1, ifindex2;
- r = test_setup();
- if (r)
- return r;
+ test_setup();
test_veth_new(&ifindex1, &mac1, &ifindex2, &mac2);
test_unused(ifindex1, mac1.ether_addr_octet, sizeof(mac2.ether_addr_octet), ifindex2, mac2.ether_addr_octet, sizeof(mac2.ether_addr_octet));
diff --git a/shared/n-acd/src/test-unplug.c b/shared/n-acd/src/test-unplug.c
index dd457417ab..9ad88a9189 100644
--- a/shared/n-acd/src/test-unplug.c
+++ b/shared/n-acd/src/test-unplug.c
@@ -4,6 +4,8 @@
* link, but DOWN or UNPLUG the device while running.
*/
+#undef NDEBUG
+#include <c-stdaux.h>
#include <stdlib.h>
#include "test.h"
@@ -24,14 +26,14 @@ static void test_unplug_down(int ifindex, uint8_t *mac, size_t n_mac, unsigned i
test_veth_cmd(ifindex, "down");
r = n_acd_new(&acd);
- assert(!r);
+ c_assert(!r);
if (!run--)
test_veth_cmd(ifindex, "down");
n_acd_get_fd(acd, &fd);
r = n_acd_start(acd, &config);
- assert(!r);
+ c_assert(!r);
if (!run--)
test_veth_cmd(ifindex, "down");
@@ -40,24 +42,24 @@ static void test_unplug_down(int ifindex, uint8_t *mac, size_t n_mac, unsigned i
NAcdEvent *event;
pfds = (struct pollfd){ .fd = fd, .events = POLLIN };
r = poll(&pfds, 1, -1);
- assert(r >= 0);
+ c_assert(r >= 0);
if (!run--)
test_veth_cmd(ifindex, "down");
r = n_acd_dispatch(acd);
- assert(!r);
+ c_assert(!r);
r = n_acd_pop_event(acd, &event);
if (!r) {
if (event->event == N_ACD_EVENT_DOWN) {
break;
} else {
- assert(event->event == N_ACD_EVENT_READY);
+ c_assert(event->event == N_ACD_EVENT_READY);
test_veth_cmd(ifindex, "down");
}
} else {
- assert(r == N_ACD_E_DONE);
+ c_assert(r == N_ACD_E_DONE);
}
}
@@ -67,11 +69,9 @@ static void test_unplug_down(int ifindex, uint8_t *mac, size_t n_mac, unsigned i
int main(int argc, char **argv) {
struct ether_addr mac;
unsigned int i;
- int r, ifindex;
+ int ifindex;
- r = test_setup();
- if (r)
- return r;
+ test_setup();
test_veth_new(&ifindex, &mac, NULL, NULL);
diff --git a/shared/n-acd/src/test-unused.c b/shared/n-acd/src/test-unused.c
index af1da59c63..67ec2e4cee 100644
--- a/shared/n-acd/src/test-unused.c
+++ b/shared/n-acd/src/test-unused.c
@@ -4,6 +4,8 @@
* link. This should just pass through, with a short, random timeout.
*/
+#undef NDEBUG
+#include <c-stdaux.h>
#include <stdlib.h>
#include "test.h"
@@ -21,27 +23,27 @@ static void test_unused(int ifindex, const uint8_t *mac, size_t n_mac) {
int r, fd;
r = n_acd_new(&acd);
- assert(!r);
+ c_assert(!r);
n_acd_get_fd(acd, &fd);
r = n_acd_start(acd, &config);
- assert(!r);
+ c_assert(!r);
for (;;) {
NAcdEvent *event;
pfds = (struct pollfd){ .fd = fd, .events = POLLIN };
r = poll(&pfds, 1, -1);
- assert(r >= 0);
+ c_assert(r >= 0);
r = n_acd_dispatch(acd);
- assert(!r);
+ c_assert(!r);
r = n_acd_pop_event(acd, &event);
if (!r) {
- assert(event->event == N_ACD_EVENT_READY);
+ c_assert(event->event == N_ACD_EVENT_READY);
break;
} else {
- assert(r == N_ACD_E_DONE);
+ c_assert(r == N_ACD_E_DONE);
}
}
@@ -50,11 +52,9 @@ static void test_unused(int ifindex, const uint8_t *mac, size_t n_mac) {
int main(int argc, char **argv) {
struct ether_addr mac;
- int r, ifindex;
+ int ifindex;
- r = test_setup();
- if (r)
- return r;
+ test_setup();
test_veth_new(&ifindex, &mac, NULL, NULL);
test_unused(ifindex, mac.ether_addr_octet, sizeof(mac.ether_addr_octet));
diff --git a/shared/n-acd/src/test-veth.c b/shared/n-acd/src/test-veth.c
index 7e316ac42b..d19236838b 100644
--- a/shared/n-acd/src/test-veth.c
+++ b/shared/n-acd/src/test-veth.c
@@ -15,6 +15,8 @@
* want to verify that resizing the internal maps works correctly.
*/
+#undef NDEBUG
+#include <c-stdaux.h>
#include <stdlib.h>
#include "test.h"
@@ -37,19 +39,19 @@ static void test_veth(int ifindex1, uint8_t *mac1, size_t n_mac1,
int r;
r = n_acd_config_new(&config);
- assert(!r);
+ c_assert(!r);
n_acd_config_set_transport(config, N_ACD_TRANSPORT_ETHERNET);
n_acd_config_set_ifindex(config, ifindex1);
n_acd_config_set_mac(config, mac1, n_mac1);
r = n_acd_new(&acd1, config);
- assert(!r);
+ c_assert(!r);
n_acd_config_set_ifindex(config, ifindex2);
n_acd_config_set_mac(config, mac2, n_mac2);
r = n_acd_new(&acd2, config);
- assert(!r);
+ c_assert(!r);
n_acd_config_free(config);
@@ -57,10 +59,10 @@ static void test_veth(int ifindex1, uint8_t *mac1, size_t n_mac1,
NAcdProbeConfig *probe_config;
r = n_acd_probe_config_new(&probe_config);
- assert(!r);
- n_acd_probe_config_set_timeout(probe_config, 64);
+ c_assert(!r);
+ n_acd_probe_config_set_timeout(probe_config, 1024);
- assert(TEST_ACD_N_PROBES <= 10 << 24);
+ c_assert(TEST_ACD_N_PROBES <= 10 << 24);
for (size_t i = 0; i < TEST_ACD_N_PROBES; ++i) {
struct in_addr ip = { htobe32((10 << 24) | i) };
@@ -73,7 +75,6 @@ static void test_veth(int ifindex1, uint8_t *mac1, size_t n_mac1,
* Probe on one side, and leave the address
* unset on the other. The probe must succeed.
*/
-
break;
case 1:
/*
@@ -81,23 +82,26 @@ static void test_veth(int ifindex1, uint8_t *mac1, size_t n_mac1,
* probe on the other. The probe must fail.
*/
test_add_child_ip(&ip);
-
break;
case 2:
/*
* Probe both sides for the same address, at
* most one may succeed.
*/
+
r = n_acd_probe(acd2, &probes2[i], probe_config);
- assert(!r);
+ c_assert(!r);
++n_running;
-
+ break;
+ default:
+ c_assert(0);
+ abort();
break;
}
r = n_acd_probe(acd1, &probes1[i], probe_config);
- assert(!r);
+ c_assert(!r);
++n_running;
}
@@ -115,33 +119,33 @@ static void test_veth(int ifindex1, uint8_t *mac1, size_t n_mac1,
n_acd_get_fd(acd2, &pfds[1].fd);
r = poll(pfds, 2, -1);
- assert(r >= 0);
+ c_assert(r >= 0);
if (pfds[0].revents & POLLIN) {
r = n_acd_dispatch(acd1);
- assert(!r || r == N_ACD_E_PREEMPTED);
+ c_assert(!r || r == N_ACD_E_PREEMPTED);
for (;;) {
r = n_acd_pop_event(acd1, &event);
- assert(!r);
+ c_assert(!r);
if (event) {
switch (event->event) {
case N_ACD_EVENT_READY:
n_acd_probe_get_userdata(event->ready.probe, (void**)&state1);
- assert(state1 == TEST_ACD_STATE_UNKNOWN);
+ c_assert(state1 == TEST_ACD_STATE_UNKNOWN);
state1 = TEST_ACD_STATE_READY;
n_acd_probe_set_userdata(event->ready.probe, (void*)state1);
break;
case N_ACD_EVENT_USED:
n_acd_probe_get_userdata(event->used.probe, (void**)&state1);
- assert(state1 == TEST_ACD_STATE_UNKNOWN);
+ c_assert(state1 == TEST_ACD_STATE_UNKNOWN);
state1 = TEST_ACD_STATE_USED;
n_acd_probe_set_userdata(event->used.probe, (void*)state1);
break;
default:
- assert(0);
+ c_assert(0);
}
--n_running;
@@ -153,29 +157,29 @@ static void test_veth(int ifindex1, uint8_t *mac1, size_t n_mac1,
if (pfds[1].revents & POLLIN) {
r = n_acd_dispatch(acd2);
- assert(!r || r == N_ACD_E_PREEMPTED);
+ c_assert(!r || r == N_ACD_E_PREEMPTED);
for (;;) {
r = n_acd_pop_event(acd2, &event);
- assert(!r);
+ c_assert(!r);
if (event) {
switch (event->event) {
case N_ACD_EVENT_READY:
n_acd_probe_get_userdata(event->ready.probe, (void**)&state2);
- assert(state2 == TEST_ACD_STATE_UNKNOWN);
+ c_assert(state2 == TEST_ACD_STATE_UNKNOWN);
state2 = TEST_ACD_STATE_READY;
n_acd_probe_set_userdata(event->ready.probe, (void*)state2);
break;
case N_ACD_EVENT_USED:
n_acd_probe_get_userdata(event->used.probe, (void**)&state2);
- assert(state2 == TEST_ACD_STATE_UNKNOWN);
+ c_assert(state2 == TEST_ACD_STATE_UNKNOWN);
state2 = TEST_ACD_STATE_USED;
n_acd_probe_set_userdata(event->used.probe, (void*)state2);
break;
default:
- assert(0);
+ c_assert(0);
}
--n_running;
@@ -192,22 +196,22 @@ static void test_veth(int ifindex1, uint8_t *mac1, size_t n_mac1,
switch (i % 3) {
case 0:
n_acd_probe_get_userdata(probes1[i], (void **)&state1);
- assert(state1 == TEST_ACD_STATE_READY);
+ c_assert(state1 == TEST_ACD_STATE_READY);
break;
case 1:
test_del_child_ip(&ip);
n_acd_probe_get_userdata(probes1[i], (void **)&state1);
- assert(state1 == TEST_ACD_STATE_USED);
+ c_assert(state1 == TEST_ACD_STATE_USED);
break;
case 2:
n_acd_probe_get_userdata(probes1[i], (void **)&state1);
n_acd_probe_get_userdata(probes2[i], (void **)&state2);
- assert(state1 != TEST_ACD_STATE_UNKNOWN);
- assert(state2 != TEST_ACD_STATE_UNKNOWN);
- assert(state1 == TEST_ACD_STATE_USED || state2 == TEST_ACD_STATE_USED);
+ c_assert(state1 != TEST_ACD_STATE_UNKNOWN);
+ c_assert(state2 != TEST_ACD_STATE_UNKNOWN);
+ c_assert(state1 == TEST_ACD_STATE_USED || state2 == TEST_ACD_STATE_USED);
n_acd_probe_free(probes2[i]);
break;
@@ -222,11 +226,9 @@ static void test_veth(int ifindex1, uint8_t *mac1, size_t n_mac1,
int main(int argc, char **argv) {
struct ether_addr mac1, mac2;
- int r, ifindex1, ifindex2;
+ int ifindex1, ifindex2;
- r = test_setup();
- if (r)
- return r;
+ test_setup();
test_veth_new(&ifindex1, &mac1, &ifindex2, &mac2);
for (unsigned int i = 0; i < 8; ++i) {
diff --git a/shared/n-acd/src/test.h b/shared/n-acd/src/test.h
index f2cb801aab..4c6ffebb6a 100644
--- a/shared/n-acd/src/test.h
+++ b/shared/n-acd/src/test.h
@@ -6,9 +6,12 @@
* includes net-namespace setups, veth setups, and more.
*/
+#undef NDEBUG
#include <assert.h>
+#include <c-stdaux.h>
#include <endian.h>
#include <errno.h>
+#include <fcntl.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <sys/socket.h>
@@ -21,6 +24,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include "n-acd.h"
@@ -29,10 +36,10 @@ static inline void test_add_child_ip(const struct in_addr *addr) {
int r;
r = asprintf(&p, "ip addr add dev veth1 %s/8", inet_ntoa(*addr));
- assert(r >= 0);
+ c_assert(r >= 0);
r = system(p);
- assert(r >= 0);
+ c_assert(r >= 0);
free(p);
}
@@ -42,10 +49,10 @@ static inline void test_del_child_ip(const struct in_addr *addr) {
int r;
r = asprintf(&p, "ip addr del dev veth1 %s/8", inet_ntoa(*addr));
- assert(r >= 0);
+ c_assert(r >= 0);
r = system(p);
- assert(r >= 0);
+ c_assert(r >= 0);
free(p);
}
@@ -56,20 +63,20 @@ static inline void test_if_query(const char *name, int *indexp, struct ether_add
int r, s;
l = strlen(name);
- assert(l <= IF_NAMESIZE);
+ c_assert(l <= IF_NAMESIZE);
if (indexp) {
*indexp = if_nametoindex(name);
- assert(*indexp > 0);
+ c_assert(*indexp > 0);
}
if (macp) {
s = socket(AF_INET, SOCK_DGRAM, 0);
- assert(s >= 0);
+ c_assert(s >= 0);
strncpy(ifr.ifr_name, name, l + 1);
r = ioctl(s, SIOCGIFHWADDR, &ifr);
- assert(r >= 0);
+ c_assert(r >= 0);
memcpy(macp->ether_addr_octet, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
@@ -82,14 +89,14 @@ static inline void test_veth_cmd(int ifindex, const char *cmd) {
int r;
p = if_indextoname(ifindex, name);
- assert(p);
+ c_assert(p);
r = asprintf(&p, "ip link set %s %s", name, cmd);
- assert(r >= 0);
+ c_assert(r >= 0);
/* Again: Ewwww... */
r = system(p);
- assert(r == 0);
+ c_assert(r == 0);
free(p);
}
@@ -102,11 +109,11 @@ static inline void test_veth_new(int *parent_indexp,
/* Eww... but it works. */
r = system("ip link add type veth");
- assert(r == 0);
+ c_assert(r == 0);
r = system("ip link set veth0 up");
- assert(r == 0);
+ c_assert(r == 0);
r = system("ip link set veth1 up");
- assert(r == 0);
+ c_assert(r == 0);
test_if_query("veth0", parent_indexp, parent_macp);
test_if_query("veth1", child_indexp, child_macp);
@@ -116,19 +123,91 @@ static inline void test_loopback_up(int *indexp, struct ether_addr *macp) {
int r;
r = system("ip link set lo up");
- assert(r == 0);
+ c_assert(r == 0);
test_if_query("lo", indexp, macp);
}
-static inline int test_setup(void) {
+static inline void test_raise_memlock(void) {
+ const size_t wanted = 64 * 1024 * 1024;
+ struct rlimit get, set;
int r;
- r = unshare(CLONE_NEWNET);
- if (r < 0) {
- assert(errno == EPERM);
- return 77;
+ r = getrlimit(RLIMIT_MEMLOCK, &get);
+ c_assert(!r);
+
+ /* try raising limit to @wanted */
+ set.rlim_cur = wanted;
+ set.rlim_max = (wanted > get.rlim_max) ? wanted : get.rlim_max;
+ r = setrlimit(RLIMIT_MEMLOCK, &set);
+ if (r) {
+ c_assert(errno == EPERM);
+
+ /* not privileged to raise limit, so maximize soft limit */
+ set.rlim_cur = get.rlim_max;
+ set.rlim_max = get.rlim_max;
+ r = setrlimit(RLIMIT_MEMLOCK, &set);
+ c_assert(!r);
}
+}
+
+static inline void test_unshare_user_namespace(void) {
+ uid_t euid;
+ gid_t egid;
+ int r, fd;
+
+ /*
+ * Enter a new user namespace as root:root.
+ */
+
+ euid = geteuid();
+ egid = getegid();
+
+ r = unshare(CLONE_NEWUSER);
+ c_assert(r >= 0);
+
+ fd = open("/proc/self/uid_map", O_WRONLY);
+ c_assert(fd >= 0);
+ r = dprintf(fd, "0 %d 1\n", euid);
+ c_assert(r >= 0);
+ close(fd);
+
+ fd = open("/proc/self/setgroups", O_WRONLY);
+ c_assert(fd >= 0);
+ r = dprintf(fd, "deny");
+ c_assert(r >= 0);
+ close(fd);
+
+ fd = open("/proc/self/gid_map", O_WRONLY);
+ c_assert(fd >= 0);
+ r = dprintf(fd, "0 %d 1\n", egid);
+ c_assert(r >= 0);
+ close(fd);
+}
+
+static inline void test_setup(void) {
+ int r;
+
+ /*
+ * Move into a new network and mount namespace both associated
+ * with a new user namespace where the current eUID is mapped to
+ * 0. Then create a a private instance of /run/netns. This ensures
+ * that any network devices or network namespaces are private to
+ * the test process.
+ */
+
+ test_raise_memlock();
+ test_unshare_user_namespace();
+
+ r = unshare(CLONE_NEWNET | CLONE_NEWNS);
+ c_assert(r >= 0);
+
+ r = mount(NULL, "/", "", MS_PRIVATE | MS_REC, NULL);
+ c_assert(r >= 0);
+
+ r = mount(NULL, "/run", "tmpfs", 0, NULL);
+ c_assert(r >= 0);
- return 0;
+ r = mkdir("/run/netns", 0755);
+ c_assert(r >= 0);
}
diff --git a/shared/n-acd/src/util/test-timer.c b/shared/n-acd/src/util/test-timer.c
index 9cc3109b60..a0c908bd4a 100644
--- a/shared/n-acd/src/util/test-timer.c
+++ b/shared/n-acd/src/util/test-timer.c
@@ -2,11 +2,12 @@
* Tests for timer utility library
*/
-#include <stdio.h>
+#undef NDEBUG
+#include <c-stdaux.h>
#include <errno.h>
-
#include <poll.h>
#include <stdbool.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/timerfd.h>
#include "timer.h"
@@ -19,20 +20,20 @@ static void test_api(void) {
int r;
r = timer_init(&timer);
- assert(!r);
+ c_assert(!r);
timeout_schedule(&t1, &timer, 1);
timeout_schedule(&t2, &timer, 2);
r = timer_pop_timeout(&timer, 10, &t);
- assert(!r);
- assert(t == &t1);
+ c_assert(!r);
+ c_assert(t == &t1);
timeout_unschedule(&t2);
r = timer_pop_timeout(&timer, 10, &t);
- assert(!r);
- assert(!t);
+ c_assert(!r);
+ c_assert(!t);
timer_deinit(&timer);
}
@@ -47,7 +48,7 @@ static void test_pop(void) {
int r;
r = timer_init(&timer);
- assert(!r);
+ c_assert(!r);
for(size_t i = 0; i < N_TIMEOUTS; ++i) {
timeouts[i] = (Timeout)TIMEOUT_INIT(timeouts[i]);
@@ -66,11 +67,11 @@ static void test_pop(void) {
uint64_t count;
r = poll(&pfd, 1, -1);
- assert(r == 1);
+ c_assert(r == 1);
r = read(timer.fd, &count, sizeof(count));
- assert(r == sizeof(count));
- assert(count == 1);
+ c_assert(r == sizeof(count));
+ c_assert(count == 1);
armed = false;
}
@@ -78,24 +79,24 @@ static void test_pop(void) {
uint64_t current_time;
r = timer_pop_timeout(&timer, i, &t);
- assert(!r);
+ c_assert(!r);
if (!t) {
timer_rearm(&timer);
break;
}
current_time = times[t - timeouts];
- assert(current_time == i);
+ c_assert(current_time == i);
++n_timeouts;
armed = true;
}
}
- assert(n_timeouts == N_TIMEOUTS);
+ c_assert(n_timeouts == N_TIMEOUTS);
r = timer_pop_timeout(&timer, (uint64_t)-1, &t);
- assert(!r);
- assert(!t);
+ c_assert(!r);
+ c_assert(!t);
timer_deinit(&timer);
}
@@ -109,60 +110,60 @@ void test_arm(void) {
int fd1, fd2, r;
fd1 = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
- assert(fd1 >= 0);
+ c_assert(fd1 >= 0);
fd2 = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
- assert(fd1 >= 0);
+ c_assert(fd1 >= 0);
r = timerfd_settime(fd1, 0, &spec, NULL);
- assert(r >= 0);
+ c_assert(r >= 0);
r = timerfd_settime(fd2, 0, &spec, NULL);
- assert(r >= 0);
+ c_assert(r >= 0);
r = timerfd_gettime(fd1, &spec);
- assert(r >= 0);
- assert(spec.it_value.tv_sec);
+ c_assert(r >= 0);
+ c_assert(spec.it_value.tv_sec);
r = timerfd_gettime(fd2, &spec);
- assert(r >= 0);
- assert(spec.it_value.tv_sec);
+ c_assert(r >= 0);
+ c_assert(spec.it_value.tv_sec);
spec = (struct itimerspec){};
r = timerfd_settime(fd1, 0, &spec, NULL);
- assert(r >= 0);
+ c_assert(r >= 0);
r = timerfd_gettime(fd1, &spec);
- assert(r >= 0);
- assert(!spec.it_value.tv_sec);
- assert(!spec.it_value.tv_nsec);
+ c_assert(r >= 0);
+ c_assert(!spec.it_value.tv_sec);
+ c_assert(!spec.it_value.tv_nsec);
r = timerfd_gettime(fd2, &spec);
- assert(r >= 0);
- assert(spec.it_value.tv_sec);
+ c_assert(r >= 0);
+ c_assert(spec.it_value.tv_sec);
spec = (struct itimerspec){ .it_value = { .tv_nsec = 1, }, };
r = timerfd_settime(fd1, 0, &spec, NULL);
- assert(r >= 0);
+ c_assert(r >= 0);
r = poll(&(struct pollfd) { .fd = fd1, .events = POLLIN }, 1, -1);
- assert(r == 1);
+ c_assert(r == 1);
r = timerfd_settime(fd2, 0, &spec, NULL);
- assert(r >= 0);
+ c_assert(r >= 0);
r = poll(&(struct pollfd) { .fd = fd2, .events = POLLIN }, 1, -1);
- assert(r == 1);
+ c_assert(r == 1);
spec = (struct itimerspec){};
r = timerfd_settime(fd1, 0, &spec, NULL);
- assert(r >= 0);
+ c_assert(r >= 0);
r = poll(&(struct pollfd) { .fd = fd2, .events = POLLIN }, 1, -1);
- assert(r == 1);
+ c_assert(r == 1);
close(fd2);
close(fd1);
diff --git a/shared/n-acd/src/util/timer.c b/shared/n-acd/src/util/timer.c
index 07dbf34eb8..3c9570a1e8 100644
--- a/shared/n-acd/src/util/timer.c
+++ b/shared/n-acd/src/util/timer.c
@@ -4,6 +4,7 @@
#include <assert.h>
#include <c-rbtree.h>
+#include <c-stdaux.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/timerfd.h>
@@ -30,7 +31,7 @@ int timer_init(Timer *timer) {
}
void timer_deinit(Timer *timer) {
- assert(c_rbtree_is_empty(&timer->tree));
+ c_assert(c_rbtree_is_empty(&timer->tree));
if (timer->fd >= 0) {
close(timer->fd);
@@ -43,8 +44,7 @@ void timer_now(Timer *timer, uint64_t *nowp) {
int r;
r = clock_gettime(timer->clock, &ts);
- assert(r >= 0);
- (void)r;
+ c_assert(r >= 0);
*nowp = ts.tv_sec * UINT64_C(1000000000) + ts.tv_nsec;
}
@@ -60,7 +60,7 @@ void timer_rearm(Timer *timer) {
*/
timeout = c_rbnode_entry(c_rbtree_first(&timer->tree), Timeout, node);
- assert(!timeout || timeout->timeout);
+ c_assert(!timeout || timeout->timeout);
time = timeout ? timeout->timeout : 0;
@@ -74,8 +74,7 @@ void timer_rearm(Timer *timer) {
},
},
NULL);
- assert(r >= 0);
- (void)r;
+ c_assert(r >= 0);
timer->scheduled_timeout = time;
}
@@ -134,8 +133,7 @@ int timer_pop_timeout(Timer *timer, uint64_t until, Timeout **timeoutp) {
}
void timeout_schedule(Timeout *timeout, Timer *timer, uint64_t time) {
-
- assert(time);
+ c_assert(time);
/*
* In case @timeout was already scheduled, remove it from the
diff --git a/shared/n-acd/src/util/timer.h b/shared/n-acd/src/util/timer.h
index 2acc99e379..d01b27414b 100644
--- a/shared/n-acd/src/util/timer.h
+++ b/shared/n-acd/src/util/timer.h
@@ -1,6 +1,7 @@
#pragma once
#include <c-rbtree.h>
+#include <c-stdaux.h>
#include <inttypes.h>
#include <stdlib.h>
#include <time.h>
diff --git a/shared/n-acd/subprojects/c-list b/shared/n-acd/subprojects/c-list
-Subproject dda36d30c7d655b4d61358519168fa7ce0e9dae
+Subproject 2e4b605c6217cd3c8a1ef773f82f5cc329ba650
diff --git a/shared/n-acd/subprojects/c-rbtree b/shared/n-acd/subprojects/c-rbtree
-Subproject bf627e0c32241915108f66ad9738444e4d045b4
+Subproject b46392d25de7a7bab67d48ef18bf8350b429cff
diff --git a/shared/n-acd/subprojects/c-siphash b/shared/n-acd/subprojects/c-siphash
-Subproject b24d2e20489b08bb350d67b82f6fb354d6951a1
+Subproject 7c42c592581906fef19458372b8db2b64327821
diff --git a/shared/n-acd/subprojects/c-stdaux b/shared/n-acd/subprojects/c-stdaux
new file mode 160000
+Subproject 11930d259212605a15430523472ef54e0c7654e
diff --git a/shared/nm-default.h b/shared/nm-default.h
index 54e9916733..cfeb49e40f 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -30,8 +30,6 @@
#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE (1 << 5)
#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL (1 << 6)
#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE (1 << 7)
-#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL (1 << 8)
-#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB (1 << 9)
#define NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON (1 << 10)
#define NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD (1 << 11)
@@ -52,17 +50,6 @@
| NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL \
)
-#define NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL ( 0 \
- | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB \
- | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB \
- | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL \
- )
-
-#define NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB ( 0 \
- | NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL \
- | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB \
- )
-
#define NM_NETWORKMANAGER_COMPILATION_CLIENT ( 0 \
| NM_NETWORKMANAGER_COMPILATION_WITH_GLIB \
| NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG \
@@ -293,16 +280,11 @@ _nm_g_return_if_fail_warning (const char *log_domain,
#include "nm-glib-aux/nm-macros-internal.h"
#include "nm-glib-aux/nm-shared-utils.h"
#include "nm-glib-aux/nm-errno.h"
-
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL
-/* no hash-utils in legacy code. */
-#else
#include "nm-glib-aux/nm-hash-utils.h"
-#endif
/*****************************************************************************/
-#if (NETWORKMANAGER_COMPILATION) & (NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL)
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE
#include "nm-version.h"
#endif
diff --git a/shared/nm-test-libnm-utils.h b/shared/nm-test-libnm-utils.h
index 2b4fa600d2..69687a9642 100644
--- a/shared/nm-test-libnm-utils.h
+++ b/shared/nm-test-libnm-utils.h
@@ -22,22 +22,11 @@
#include "nm-utils/nm-test-utils.h"
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
-#include "nm-dbus-glib-types.h"
-#endif
-
-/*****************************************************************************/
-
typedef struct {
GDBusConnection *bus;
GDBusProxy *proxy;
GPid pid;
int keepalive_fd;
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
- struct {
- DBusGConnection *bus;
- } libdbus;
-#endif
} NMTstcServiceInfo;
NMTstcServiceInfo *nmtstc_service_init (void);
@@ -62,18 +51,6 @@ static inline void _nmtstc_auto_service_cleanup (NMTstcServiceInfo **info)
}); \
NM_PRAGMA_WARNING_REENABLE
-/*****************************************************************************/
-
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
-
-#include "nm-client.h"
-#include "nm-remote-settings.h"
-
-NMClient *nmtstc_nm_client_new (void);
-NMRemoteSettings *nmtstc_nm_remote_settings_new (void);
-
-#else
-
NMDevice *nmtstc_service_add_device (NMTstcServiceInfo *info,
NMClient *client,
const char *method,
@@ -85,10 +62,6 @@ NMDevice * nmtstc_service_add_wired_device (NMTstcServiceInfo *sinfo,
const char *hwaddr,
const char **subchannels);
-#endif
-
-/*****************************************************************************/
-
void nmtstc_service_add_connection (NMTstcServiceInfo *sinfo,
NMConnection *connection,
gboolean verify_connection,
diff --git a/shared/nm-test-utils-impl.c b/shared/nm-test-utils-impl.c
index 02d7159342..3fbf7a63f6 100644
--- a/shared/nm-test-utils-impl.c
+++ b/shared/nm-test-utils-impl.c
@@ -56,24 +56,6 @@ name_exists (GDBusConnection *c, const char *name)
return exists;
}
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
-static DBusGProxy *
-_libdbus_create_proxy_test (DBusGConnection *bus)
-{
- DBusGProxy *proxy;
-
- proxy = dbus_g_proxy_new_for_name (bus,
- NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- "org.freedesktop.NetworkManager.LibnmGlibTest");
- g_assert (proxy);
-
- dbus_g_proxy_set_default_timeout (proxy, G_MAXINT);
-
- return proxy;
-}
-#endif
-
typedef struct {
GMainLoop *mainloop;
GDBusConnection *bus;
@@ -201,11 +183,6 @@ nmtstc_service_init (void)
NULL, &error);
g_assert_no_error (error);
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
- info->libdbus.bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- g_assert_no_error (error);
- g_assert (info->libdbus.bus);
-#endif
return info;
}
@@ -223,10 +200,6 @@ nmtstc_service_cleanup (NMTstcServiceInfo *info)
g_clear_object (&info->proxy);
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
- g_clear_pointer (&info->libdbus.bus, dbus_g_connection_unref);
-#endif
-
if (info->pid != NM_PID_T_INVAL) {
kill (info->pid, SIGTERM);
@@ -255,7 +228,6 @@ again_wait:
g_free (info);
}
-#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB)
typedef struct {
GMainLoop *loop;
const char *ifname;
@@ -368,7 +340,6 @@ nmtstc_service_add_wired_device (NMTstcServiceInfo *sinfo, NMClient *client,
{
return add_device_common (sinfo, client, "AddWiredDevice", ifname, hwaddr, subchannels);
}
-#endif
void
nmtstc_service_add_connection (NMTstcServiceInfo *sinfo,
@@ -376,41 +347,10 @@ nmtstc_service_add_connection (NMTstcServiceInfo *sinfo,
gboolean verify_connection,
char **out_path)
{
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
- gs_unref_hashtable GHashTable *new_settings = NULL;
- gboolean success;
- gs_free_error GError *error = NULL;
- gs_free char *path = NULL;
- gs_unref_object DBusGProxy *proxy = NULL;
-
- g_assert (sinfo);
- g_assert (NM_IS_CONNECTION (connection));
-
- new_settings = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
-
- proxy = _libdbus_create_proxy_test (sinfo->libdbus.bus);
-
- success = dbus_g_proxy_call (proxy,
- "AddConnection",
- &error,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, new_settings,
- G_TYPE_BOOLEAN, verify_connection,
- G_TYPE_INVALID,
- DBUS_TYPE_G_OBJECT_PATH, &path,
- G_TYPE_INVALID);
- g_assert_no_error (error);
- g_assert (success);
-
- g_assert (path && *path);
-
- if (out_path)
- *out_path = g_strdup (path);
-#else
nmtstc_service_add_connection_variant (sinfo,
nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL),
verify_connection,
out_path);
-#endif
}
void
@@ -450,37 +390,10 @@ nmtstc_service_update_connection (NMTstcServiceInfo *sinfo,
path = nm_connection_get_path (connection);
g_assert (path);
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
- {
- gs_unref_hashtable GHashTable *new_settings = NULL;
- gboolean success;
- gs_free_error GError *error = NULL;
- gs_unref_object DBusGProxy *proxy = NULL;
-
- g_assert (sinfo);
- g_assert (NM_IS_CONNECTION (connection));
-
- new_settings = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
-
- proxy = _libdbus_create_proxy_test (sinfo->libdbus.bus);
-
- success = dbus_g_proxy_call (proxy,
- "UpdateConnection",
- &error,
- DBUS_TYPE_G_OBJECT_PATH, path,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, new_settings,
- G_TYPE_BOOLEAN, verify_connection,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- g_assert_no_error (error);
- g_assert (success);
- }
-#else
nmtstc_service_update_connection_variant (sinfo,
path,
nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL),
verify_connection);
-#endif
}
void
@@ -508,55 +421,3 @@ nmtstc_service_update_connection_variant (NMTstcServiceInfo *sinfo,
g_assert (g_variant_is_of_type (result, G_VARIANT_TYPE ("()")));
g_variant_unref (result);
}
-
-/*****************************************************************************/
-
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
-NMClient *
-nmtstc_nm_client_new (void)
-{
- NMClient *client;
- DBusGConnection *bus;
- GError *error = NULL;
- gboolean success;
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- g_assert_no_error (error);
- g_assert (bus);
-
- client = g_object_new (NM_TYPE_CLIENT,
- NM_OBJECT_DBUS_CONNECTION, bus,
- NM_OBJECT_DBUS_PATH, NM_DBUS_PATH,
- NULL);
- g_assert (client != NULL);
-
- dbus_g_connection_unref (bus);
-
- success = g_initable_init (G_INITABLE (client), NULL, &error);
- g_assert_no_error (error);
- g_assert (success == TRUE);
-
- return client;
-}
-
-NMRemoteSettings *
-nmtstc_nm_remote_settings_new (void)
-{
- NMRemoteSettings *settings;
- DBusGConnection *bus;
- GError *error = NULL;
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- g_assert_no_error (error);
- g_assert (bus);
-
- settings = nm_remote_settings_new (bus);
- g_assert (settings);
-
- dbus_g_connection_unref (bus);
-
- return settings;
-}
-#endif
-
-/*****************************************************************************/
diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h
index d0ec7d9f1a..26190a7460 100644
--- a/shared/nm-utils/nm-test-utils.h
+++ b/shared/nm-utils/nm-test-utils.h
@@ -710,18 +710,10 @@ nmtst_test_quick (void)
#define NMTST_EXPECT(domain, level, msg) g_test_expect_message (domain, level, msg)
-#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL
-#define NMTST_EXPECT_LIBNM_U(level, msg) NMTST_EXPECT ("libnm-util", level, msg)
-#define NMTST_EXPECT_LIBNM_G(level, msg) NMTST_EXPECT ("libnm-glib", level, msg)
-
-#define NMTST_EXPECT_LIBNM_U_CRITICAL(msg) NMTST_EXPECT_LIBNM_U (G_LOG_LEVEL_CRITICAL, msg)
-#define NMTST_EXPECT_LIBNM_G_CRITICAL(msg) NMTST_EXPECT_LIBNM_G (G_LOG_LEVEL_CRITICAL, msg)
-#else
#define NMTST_EXPECT_LIBNM(level, msg) NMTST_EXPECT ("libnm", level, msg)
#define NMTST_EXPECT_LIBNM_WARNING(msg) NMTST_EXPECT_LIBNM (G_LOG_LEVEL_WARNING, msg)
#define NMTST_EXPECT_LIBNM_CRITICAL(msg) NMTST_EXPECT_LIBNM (G_LOG_LEVEL_CRITICAL, msg)
-#endif
/*****************************************************************************/
diff --git a/shared/nm-version-macros.h.in b/shared/nm-version-macros.h.in
index 4b57529a30..49b6308c88 100644
--- a/shared/nm-version-macros.h.in
+++ b/shared/nm-version-macros.h.in
@@ -76,6 +76,7 @@
#define NM_VERSION_1_14 (NM_ENCODE_VERSION (1, 14, 0))
#define NM_VERSION_1_16 (NM_ENCODE_VERSION (1, 16, 0))
#define NM_VERSION_1_18 (NM_ENCODE_VERSION (1, 18, 0))
+#define NM_VERSION_1_20 (NM_ENCODE_VERSION (1, 20, 0))
/* For releases, NM_API_VERSION is equal to NM_VERSION.
*
diff --git a/tools/run-nm-test.sh b/tools/run-nm-test.sh
index 6e7d02c845..135310acd0 100755
--- a/tools/run-nm-test.sh
+++ b/tools/run-nm-test.sh
@@ -192,7 +192,7 @@ TEST_NAME="${TEST##*/}"
if [ -z "${NMTST_LAUNCH_DBUS}" ]; then
# autodetect whether to launch D-Bus based on the test path.
- if [[ $TEST_PATH == */libnm/tests || $TEST_PATH == */libnm-glib/tests ]]; then
+ if [[ $TEST_PATH == */libnm/tests ]]; then
NMTST_LAUNCH_DBUS=1
else
NMTST_LAUNCH_DBUS=0
diff --git a/tools/test-build.sh b/tools/test-build.sh
index 5edbcc0c16..17bcba7d1d 100755
--- a/tools/test-build.sh
+++ b/tools/test-build.sh
@@ -40,8 +40,6 @@ if [ "${#TARGETS}" -lt 1 ]; then
clients/tui/nmtui
src/platform/tests/monitor
src/ndisc/tests/test-ndisc-linux
- libnm-util/tests/test-libnm-linking
- libnm-glib/libnm-glib-test
$(git grep -h '\.l\?a\>' Makefile.am | sed 's/[a-zA-Z.0-9_-/]\+/\n\0\n/g' | sort -u | grep '\.l\?a$')
)
fi
diff --git a/valgrind.suppressions b/valgrind.suppressions
index 32d7ed5e2e..3109671ae6 100644
--- a/valgrind.suppressions
+++ b/valgrind.suppressions
@@ -3,7 +3,7 @@
# are mainly tested.
#
# Make sure to install debug information, otherwise the suppression trace might
-# not match. On Fedora, try 'debuginfo-install dbus-glib glib'.
+# not match. On Fedora, try 'dnf debuginfo-install glib2'.
{
NSS_NoDB_Init
Memcheck:Leak
diff --git a/vapi/NMClient-1.0.metadata b/vapi/NMClient-1.0.metadata
deleted file mode 100644
index b8a022f6b7..0000000000
--- a/vapi/NMClient-1.0.metadata
+++ /dev/null
@@ -1,121 +0,0 @@
-RemoteSettings.new_finish symbol_type="function"
-RemoteConnection.updated#virtual_method skip
-Client.new_finish symbol_type="function"
-
-ACTIVE_CONNECTION_* cheader_filename="nm-active-connection.h" name="ACTIVE_CONNECTION_(.+)" parent="NM.ActiveConnection"
-CLIENT_* cheader_filename="nm-client.h" name="CLIENT_(.+)" parent="NM.Client"
-ACCESS_POINT_* cheader_filename="nm-access-point.h" name="ACCESS_POINT_(.+)" parent="NM.AccessPoint"
-
-DEVICE_* cheader_filename="nm-device.h" name="DEVICE_(.+)" parent="NM.Device"
-DEVICE_ADSL_* cheader_filename="nm-device-adsl.h" name="DEVICE_ADSL_(.+)" parent="NM.DeviceAdsl"
-DEVICE_BOND_* cheader_filename="nm-device-bond.h" name="DEVICE_BOND_(.+)" parent="NM.DeviceBond"
-DEVICE_BRIDGE_* cheader_filename="nm-device-bridge.h" name="DEVICE_BRIDGE_(.+)" parent="NM.DeviceBridge"
-DEVICE_BT_* cheader_filename="nm-device-bt.h" name="DEVICE_BT_(.+)" parent="NM.DeviceBt"
-DEVICE_ETHERNET_* cheader_filename="nm-device-ethernet.h" name="DEVICE_ETHERNET_(.+)" parent="NM.DeviceEthernet"
-DEVICE_GENERIC_* cheader_filename="nm-device-generic.h" name="DEVICE_GENERIC_(.+)" parent="NM.DeviceGeneric"
-
-DEVICE_INFINIBAND_* cheader_filename="nm-device-infiniband.h" name="DEVICE_INFINIBAND_(.+)" parent="NM.DeviceInfiniband"
-DEVICE_MODEM_* cheader_filename="nm-device-modem.h" name="DEVICE_MODEM_(.+)" parent="NM.DeviceModem"
-DEVICE_OLPC_MESH_* cheader_filename="nm-device-olpc-mesh.h" name="DEVICE_OLPC_(.+)" parent="NM.DeviceOlpcMesh"
-
-DEVICE_TEAM_* cheader_filename="nm-device-team.h" name="DEVICE_TEAM_(.+)" parent="NM.DeviceTeam"
-DEVICE_VLAN_* cheader_filename="nm-device-vlan.h" name="DEVICE_VLAN_(.+)" parent="NM.DeviceVlan"
-DEVICE_WIFI_* cheader_filename="nm-device-wifi.h" name="DEVICE_WIFI_(.+)" parent="NM.DeviceWifi"
-DEVICE_WIMAX_* cheader_filename="nm-device-wimax.h" name="DEVICE_WIMAX_(.+)" parent="NM.DeviceWimax"
-DHCP4_CONFIG_OPTIONS cheader_filename="nm-dhcp4-config.h" name="DHCP4_CONFIG_(.+)" parent="NM.DHCP4Config"
-DHCP6_CONFIG_OPTIONS cheader_filename="nm-dhcp6-config.h" name="DHCP4_CONFIG_(.+)" parent="NM.DHCP6Config"
-IP4_CONFIG_* cheader_filename="nm-ip4-config.h" name="IP4_CONFIG_(.+)" parent="NM.IP4Config"
-IP6_CONFIG_* cheader_filename="nm-ip6-config.h" name="IP6_CONFIG_(.+)" parent="NM.IP6Config"
-OBJECT_* cheader_filename="nm-object.h" name="OBJECT_(.+)" parent="NM.Object"
-REMOTE_CONNECTION_* cheader_filename="nm-remote-connection.h" name="REMOTE_CONNECTION_(.+)" parent="NM.RemoteConnection"
-REMOTE_SETTINGS_* cheader_filename="nm-remote-settings.h" name="REMOTE_SETTINGS_(.+)" parent="NM.RemoteSettings"
-SECRET_AGENT_* cheader_filename="nm-secret-agent.h" name="SECRET_AGENT_(.+)" parent="NM.SecretAgent"
-VPN_CONNECTION_* cheader_filename="nm-vpn-connection.h" name="VPN_CONNECTION_(.+)" parent="NM.VPNConnection"
-WIMAX_NSP_* cheader_filename="nm-wimax-nsp.h" name="WIMAX_NSP_(.+)" parent="NM.WimaxNsp"
-
-AccessPoint cheader_filename="nm-access-point.h"
-ActiveConnection cheader_filename="nm-active-connection.h"
-Client cheader_filename="nm-client.h"
-DHCP4Config cheader_filename="nm-dhcp4-config.h"
-DHCP6Config cheader_filename="nm-dhcp6-config.h"
-Device cheader_filename="nm-device.h"
-DeviceAdsl cheader_filename="nm-device-adsl.h"
-DeviceBond cheader_filename="nm-device-bond.h"
-DeviceBridge cheader_filename="nm-device-bridge.h"
-DeviceBt cheader_filename="nm-device-bt.h"
-DeviceEthernet cheader_filename="nm-device-ethernet.h"
-DeviceGeneric cheader_filename="nm-device-generic.h"
-DeviceInfiniband cheader_filename="nm-device-infiniband.h"
-DeviceModem cheader_filename="nm-device-modem.h"
-DeviceOlpcMesh cheader_filename="nm-device-olpc-mesh.h"
-DeviceTeam cheader_filename="nm-device-team.h"
-DeviceVlan cheader_filename="nm-device-vlan.h"
-DeviceWifi cheader_filename="nm-device-wifi.h"
-DeviceWimax cheader_filename="nm-device-wimax.h"
-IP4Config cheader_filename="nm-ip4-config.h"
-IP6AddressArray cheader_filename="nm-types.h"
-IP6AddressObjectArray cheader_filename="nm-types.h"
-IP6Config cheader_filename="nm-ip6-config.h"
-IP6RouteObjectArray cheader_filename="nm-types.h"
-ObjectArray cheader_filename="nm-types.h"
-RemoteConnection cheader_filename="nm-remote-connection.h"
-RemoteSettings cheader_filename="nm-remote-settings.h"
-Ssid cheader_filename="nm-types.h"
-StringArray cheader_filename="nm-types.h"
-UintArray cheader_filename="nm-types.h"
-VPNConnection cheader_filename="nm-vpn-connection.h"
-WimaxNsp cheader_filename="nm-wimax-nsp.h"
-
-
-ClientPermission cheader_filename="nm-client.h"
-ClientPermissionResult cheader_filename="nm-client.h"
-DeviceAdslError cheader_filename="nm-device-adsl.h"
-DeviceBondError cheader_filename="nm-device-bond.h"
-DeviceBridgeError cheader_filename="nm-device-bridge.h"
-DeviceBtError cheader_filename="nm-device-bt.h"
-DeviceEthernetError cheader_filename="nm-device-ethernet.h"
-DeviceGenericError cheader_filename="nm-device-generic.h"
-DeviceInfinibandError cheader_filename="nm-device-infiniband.h"
-DeviceModemError cheader_filename="nm-device-modem.h"
-DeviceOlpcMeshError cheader_filename="nm-device-olpc-mesh.h"
-DeviceTeamError cheader_filename="nm-device-team.h"
-DeviceVlanError cheader_filename="nm-device-vlan.h"
-DeviceWifiError cheader_filename="nm-device-wifi.h"
-DeviceWimaxError cheader_filename="nm-device-wimax.h"
-ObjectError cheader_filename="nm-object.h"
-RemoteSettingsError cheader_filename="nm-remote-settings.h"
-SecretAgentError cheader_filename="nm-secret-agent.h"
-SecretAgentGetSecretsFlags cheader_filename="nm-secret-agent.h"
-WimaxNspNetworkType cheader_filename="nm-wimax-nsp.h"
-
-ClientActivateFn cheader_filename="nm-client.h"
-ClientAddActivateFn cheader_filename="nm-client.h"
-DeviceDeactivateFn cheader_filename="nm-device.h"
-RemoteConnectionCommitFunc cheader_filename="nm-remote-connection.h"
-RemoteConnectionDeleteFunc cheader_filename="nm-remote-connection.h"
-RemoteConnectionGetSecretsFunc cheader_filename="nm-remote-connection.h"
-RemoteSettingsAddConnectionFunc cheader_filename="nm-remote-settings.h"
-RemoteSettingsSaveHostnameFunc cheader_filename="nm-remote-settings.h"
-SecretAgentDeleteSecretsFunc cheader_filename="nm-secret-agent.h"
-SecretAgentGetSecretsFunc cheader_filename="nm-secret-agent.h"
-SecretAgentSaveSecretsFunc cheader_filename="nm-secret-agent.h"
-
-device_adsl_error_quark cheader_filename="nm-device-adsl.h" parent="NM.DeviceAdslError" name="device_adsl_error_(.+)"
-device_bond_error_quark cheader_filename="nm-device-bond.h" parent="NM.DeviceBondError" name="device_bond_error_(.+)"
-device_bridge_error_quark cheader_filename="nm-device-bridge.h" parent="NM.DeviceBridgeError" name="device_bridge_error_(.+)"
-device_bt_error_quark cheader_filename="nm-device-bt.h" parent="NM.DeviceBtError" name="device_bt_error_(.+)"
-device_ethernet_error_quark cheader_filename="nm-device-ethernet.h" parent="NM.DeviceEthernetError" name="device_ethernet_error_(.+)"
-device_generic_error_quark cheader_filename="nm-device-generic.h" parent="NM.DeviceGenericError" name="device_generic_error_(.+)"
-device_infiniband_error_quark cheader_filename="nm-device-infiniband.h" parent="NM.DeviceInfinibandError" name="device_infiniband_error_(.+)"
-device_modem_error_quark cheader_filename="nm-device-modem.h" parent="NM.DeviceModemError" name="device_modem_error_(.+)"
-device_olpc_mesh_error_quark cheader_filename="nm-device-olpc-mesh.h" parent="NM.DeviceOlpcMeshError" name="device_olpc_mesh_error_(.+)"
-device_team_error_quark cheader_filename="nm-device-team.h" parent="NM.DeviceTeamError" name="device_team_error(.+)"
-device_vlan_error_quark cheader_filename="nm-device-vlan.h" parent="NM.DeviceVlanError" name="device_vlan_error(.+)"
-device_wifi_error_quark cheader_filename="nm-device-wifi.h" parent="NM.DeviceWifiError" name="device_wifi_error_(.+)"
-device_wimax_error_quark cheader_filename="nm-device-wimax.h" parent="NM.DeviceWimaxError" name="device_wimax_error_(.+)"
-object_error_quark cheader_filename="nm-object.h" parent="NM.ObjectError" name="object_error_(.+)"
-remote_settings_error_quark cheader_filename="nm-remote-settings.h" name="remote_settings_error_(.+)" parent="NM.RemoteSettingsError"
-secret_agent_error_quark cheader_filename="nm-secret-agent.h" name="secret_agent_error_(.+)" parent="NM.SecretAgentError"
-
-Object cheader_filename="nm-object.h"
-SecretAgent cheader_filename="nm-secret-agent.h"
diff --git a/vapi/NetworkManager-1.0.metadata b/vapi/NetworkManager-1.0.metadata
deleted file mode 100644
index e568f6ddbb..0000000000
--- a/vapi/NetworkManager-1.0.metadata
+++ /dev/null
@@ -1,164 +0,0 @@
-Setting.get_secret_flags#virtual_method skip
-Setting.set_secret_flags#virtual_method skip
-
-Connection cheader_filename="nm-connection.h"
-IP4Address cheader_filename="nm-setting-ip4-config.h"
-IP4Route cheader_filename="nm-setting-ip4-config.h"
-IP6Address cheader_filename="nm-setting-ip6-config.h"
-IP6Route cheader_filename="nm-setting-ip6-config.h"
-Setting8021x cheader_filename="nm-setting-8021x.h"
-SettingAdsl cheader_filename="nm-setting-adsl.h"
-SettingBluetooth cheader_filename="nm-setting-bluetooth.h"
-SettingBond cheader_filename="nm-setting-bond.h"
-SettingBridge cheader_filename="nm-setting-bridge.h"
-SettingCdma cheader_filename="nm-setting-cdma.h"
-SettingConnection cheader_filename="nm-setting-connection.h"
-SettingGeneric cheader_filename="nm-setting-generic.h"
-SettingGsm cheader_filename="nm-setting-gsm.h"
-SettingIP4Config cheader_filename="nm-setting-ip4-config.h"
-SettingIP6Config cheader_filename="nm-setting-ip6-config.h"
-SettingInfiniband cheader_filename="nm-setting-infiniband.h"
-SettingOlpcMesh cheader_filename="nm-setting-olpc-mesh.h"
-SettingPPP cheader_filename="nm-setting-ppp.h"
-SettingPPPOE cheader_filename="nm-setting-pppoe.h"
-SettingSerial cheader_filename="nm-setting-serial.h"
-SettingVPN cheader_filename="nm-setting-vpn.h"
-SettingTeam cheader_filename="nm-setting-team.h"
-SettingVlan cheader_filename="nm-setting-vlan.h"
-SettingWimax cheader_filename="nm-setting-wimax.h"
-SettingWired cheader_filename="nm-setting-wired.h"
-SettingWireless cheader_filename="nm-setting-wireless.h"
-SettingWirelessSecurity cheader_filename="nm-setting-wireless-security.h"
-
-Setting cheader_filename="nm-setting.h"
-
-80211ApFlags cheader_filename="NetworkManager.h"
-80211ApSecurityFlags cheader_filename="NetworkManager.h"
-80211Mode cheader_filename="NetworkManager.h"
-ActiveConnectionState cheader_filename="NetworkManager.h"
-BluetoothCapabilities cheader_filename="NetworkManager.h"
-ConnectionError cheader_filename="nm-connection.h"
-DeviceCapabilities cheader_filename="NetworkManager.h"
-DeviceModemCapabilities cheader_filename="NetworkManager.h"
-DeviceState cheader_filename="NetworkManager.h"
-DeviceStateReason cheader_filename="NetworkManager.h"
-DeviceType cheader_filename="NetworkManager.h"
-DeviceWifiCapabilities cheader_filename="NetworkManager.h"
-Setting8021xCKFormat cheader_filename="nm-setting-8021x.h"
-Setting8021xCKScheme cheader_filename="nm-setting-8021x.h"
-Setting8021xError cheader_filename="nm-setting-8021x.h"
-SettingAdslError cheader_filename="nm-setting-adsl.h"
-SettingBluetoothError cheader_filename="nm-setting-bluetooth.h"
-SettingBondError cheader_filename="nm-setting-bond.h"
-SettingBridgeError cheader_filename="nm-setting-bridge.h"
-SettingCdmaError cheader_filename="nm-setting-cdma.h"
-SettingCompareFlags cheader_filename="nm-setting.h"
-SettingConnectionError cheader_filename="nm-setting-connection.h"
-SettingDiffResult cheader_filename="nm-setting.h"
-SettingError cheader_filename="nm-setting.h"
-SettingGenericError cheader_filename="nm-setting-generic.h"
-SettingGsmError cheader_filename="nm-setting-gsm.h"
-SettingGsmNetworkBand cheader_filename="nm-setting-gsm.h"
-SettingGsmNetworkType cheader_filename="nm-setting-gsm.h"
-SettingHashFlags cheader_filename="nm-setting.h"
-SettingIP4ConfigError cheader_filename="nm-setting-ip4-config.h"
-SettingIP6ConfigError cheader_filename="nm-setting-ip6-config.h"
-SettingIP6ConfigPrivacy cheader_filename="nm-setting-ip6-config.h"
-SettingInfinibandError cheader_filename="nm-setting-infiniband.h"
-SettingOlpcMeshError cheader_filename="nm-setting-olpc-mesh.h"
-SettingPPPError cheader_filename="nm-setting-ppp.h"
-SettingPPPOEError cheader_filename="nm-setting-pppoe.h"
-SettingSecretFlags cheader_filename="nm-setting.h"
-SettingSerialError cheader_filename="nm-setting-serial.h"
-SettingTeamError cheader_filename="nm-setting-team.h"
-SettingVlanError cheader_filename="nm-setting-vlan.h"
-SettingVpnError cheader_filename="nm-setting-vpn.h"
-SettingWimaxError cheader_filename="nm-setting-wimax.h"
-SettingWiredError cheader_filename="nm-setting-wired.h"
-SettingWirelessError cheader_filename="nm-setting-wireless.h"
-SettingWirelessSecurityError cheader_filename="nm-setting-wireless-security.h"
-State cheader_filename="NetworkManager.h"
-
-VPNConnectionState cheader_filename="NetworkManagerVPN.h"
-VPNConnectionStateReason cheader_filename="NetworkManagerVPN.h"
-VPNPluginFailure cheader_filename="NetworkManagerVPN.h"
-VPNServiceState cheader_filename="NetworkManagerVPN.h"
-
-VlanFlags cheader_filename="nm-setting-vlan.h"
-VlanPriorityMap cheader_filename="nm-setting-vlan.h"
-WepKeyType cheader_filename="nm-setting-wireless-security.h"
-
-SettingClearSecretsWithFlagsFn cheader_filename="nm-setting.h"
-SettingValueIterFn cheader_filename="nm-setting.h"
-VPNIterFunc cheader_filename="nm-setting-vpn.h"
-
-CONNECTION_PATH cheader_filename="nm-connection.h"
-DBUS_* cheader_filename="NetworkManager.h"
-DBUS_PATH_VPN cheader_filename="NetworkManagerVPN.h"
-DBUS_PATH_VPN_CONNECTION cheader_filename="NetworkManagerVPN.h"
-DBUS_VPN_* cheader_filename="NetworkManagerVPN.h"
-
-//DBUS_* parent="NM.DBus" cheader_filename="NetworkManager.h" name="DBUS_(.+)"
-//DBUS_PATH_VPN parent="NM.DBus" cheader_filename="NetworkManagerVPN.h" name="DBUS_(.+)"
-//DBUS_PATH_VPN_CONNECTION parent="NM.DBus" cheader_filename="NetworkManagerVPN.h" name="DBUS_(.+)"
-//DBUS_VPN_* parent="NM.DBus.VPN" cheader_filename="NetworkManagerVPN.h" name="DBUS_VPN_(.+)"
-
-SETTING_NAME cheader_filename="nm-setting.h"
-
-SETTING_802_1X_* parent="NM.Setting8021x" name="SETTING_802_1X_(.+)"
-SETTING_ADSL_* parent="NM.SettingAdsl" cheader_filename="nm-setting-adsl.h" name="SETTING_ADSL_(.+)"
-SETTING_BLUETOOTH_* parent="NM.SettingBluetooth" cheader_filename="nm-setting-bluetooth.h" name="SETTING_BLUETOOTH_(.+)"
-SETTING_BOND_* parent="NM.SettingBond" cheader_filename="nm-setting-bond.h" name="SETTING_BOND_(.+)"
-SETTING_BRIDGE_* parent="NM.SettingBridge" cheader_filename="nm-setting-bridge.h" name="SETTING_BRIDGE_(.+)"
-SETTING_CDMA_* parent="NM.SettingCdma" cheader_filename="nm-setting-cdma.h" name="SETTING_CDMA_(.+)"
-SETTING_CONNECTION_* parent="NM.SettingConnection" cheader_filename="nm-setting-connection.h" name="SETTING_CONNECTION_(.+)"
-SETTING_GENERIC_* parent="NM.SettingGeneric" cheader_filename="nm-setting-generic.h" name="SETTING_GENERIC_(.+)"
-SETTING_GSM_* parent="NM.SettingGsm" cheader_filename="nm-setting-gsm.h" name="SETTING_GSM_(.+)"
-SETTING_INFINIBAND_* parent="NM.SettingInfiniband" cheader_filename="nm-setting-infiniband.h" name="SETTING_INFINIBAND_(.+)"
-SETTING_IP4_* parent="NM.SettingIP4" cheader_filename="nm-setting-ip4-config.h" name="SETTING_IP4_(.+)"
-SETTING_IP6_* parent="NM.SettingIP6" cheader_filename="nm-setting-ip6-config.h" name="SETTING_IP6_(.+)"
-SETTING_OLPC_* parent="NM.SettingOLPC" cheader_filename="nm-setting-olpc-mesh.h" name="SETTING_OLPC_(.+)"
-SETTING_PPP_* parent="NM.SettingPPP" cheader_filename="nm-setting-ppp.h" name="SETTING_PPP_(.+)"
-SETTING_PPPOE_* parent="NM.SettingPPPOE" cheader_filename="nm-setting-pppoe.h" name="SETTING_PPPOE_(.+)"
-SETTING_SERIAL_* parent="NM.SettingSerial" cheader_filename="nm-setting-serial.h" name="SETTING_SERIAL_(.+)"
-SETTING_TEAM_* parent="NM.SettingTeam" cheader_filename="nm-setting-team.h" name="SETTING_TEAM_(.+)"
-SETTING_VLAN_* parent="NM.SettingVlan" cheader_filename="nm-setting-vlan.h" name="SETTING_VLAN_(.+)"
-SETTING_VPN_* parent="NM.SettingVpn" cheader_filename="nm-setting-vpn.h" name="SETTING_VPN_(.+)"
-SETTING_WIMAX_* parent="NM.SettingWimax" cheader_filename="nm-setting-wimax.h" name="SETTING_WIMAX_(.+)"
-SETTING_WIRED_* parent="NM.SettingWired" cheader_filename="nm-setting-wired.h" name="SETTING_WIRED_(.+)"
-SETTING_WIRELESS_* parent="NM.SettingWireless" cheader_filename="nm-setting-wireless.h" name="SETTING_WIRELESS_(.+)"
-SETTING_WIRELESS_SECURITY_* parent="NM.SettingWirelessSecurity" cheader_filename="nm-setting-wireless-security.h" name="SETTING_WIRELESS_SECURITY_(.+)"
-
-VPN_* parent="NM.VPN" name="VPN_(.+)" cheader_filename="NetworkManagerVPN.h"
-
-connection_error_quark cheader_filename="nm-connection.h" name="connection_(.+)" parent="NM.Connection"
-
-setting_802_1x_error_quark cheader_filename="nm-setting-8021x.h" name="setting_802_1x_error_(.+)" parent="NM.Setting8021xError"
-setting_adsl_error_quark cheader_filename="nm-setting-adsl.h" name="setting_adsl_error_(.+)" parent="NM.SettingAdslError"
-setting_bluetooth_error_quark cheader_filename="nm-setting-bluetooth.h" name="setting_bluetooth_error_(.+)" parent="NM.SettingBluetoothError"
-setting_bond_error_quark cheader_filename="nm-setting-bond.h" name="setting_bond_error_(.+)" parent="NM.SettingBondError"
-setting_bridge_error_quark cheader_filename="nm-setting-bridge.h" name="setting_bridge_error_(.+)" parent="NM.SettingBridgeError"
-setting_cdma_error_quark cheader_filename="nm-setting-cdma.h" name="setting_cdma_error_(.+)" parent="NM.SettingCdmaError"
-setting_connection_error_quark cheader_filename="nm-setting-connection.h" name="setting_connection_error_(.+)" parent="NM.SettingConnectionError"
-setting_error_quark cheader_filename="nm-setting.h" name="setting_error_(.+)" parent="NM.SettingError"
-setting_generic_error_quark cheader_filename="nm-setting-generic.h" name="setting_generic_error_(.+)" parent="NM.SettingGenericError"
-setting_gsm_error_quark cheader_filename="nm-setting-gsm.h" name="setting_gsm_error_(.+)" parent="NM.SettingGsmError"
-setting_infiniband_error_quark cheader_filename="nm-setting-infiniband.h" name="setting_infiniband_error_(.+)" parent="NM.SettingInfinibandError"
-setting_ip4_config_error_quark cheader_filename="nm-setting-ip4-config.h" name="setting_ip4_config_error_(.+)" parent="NM.SettingIP4ConfigError"
-setting_ip6_config_error_quark cheader_filename="nm-setting-ip6-config.h" name="setting_ip6_config_error_(.+)" parent="NM.SettingIP6ConfigError"
-setting_olpc_mesh_error_quark cheader_filename="nm-setting-olpc-mesh.h" name="setting_olpc_mesh_error_(.+)" parent="NM.SettingOlpcMeshError"
-setting_ppp_error_quark cheader_filename="nm-setting-ppp.h" name="setting_ppp_error_(.+)" parent="NM.SettingPPPError"
-setting_pppoe_error_quark cheader_filename="nm-setting-pppoe.h" name="setting_pppoe_error_(.+)" parent="NM.SettingPPPOEError"
-setting_serial_error_quark cheader_filename="nm-setting-serial.h" name="setting_serial_error_(.+)" parent="NM.SettingSerialError"
-setting_team_error_quark cheader_filename="nm-setting-team.h" name="setting_team_error_(.+)" parent="NM.SettingTeamError"
-setting_vlan_error_quark cheader_filename="nm-setting-vlan.h" name="setting_vlan_error_(.+)" parent="NM.SettingVlanError"
-setting_vpn_error_quark cheader_filename="nm-setting-vpn.h" name="setting_vpn_error_(.+)" parent="NM.SettingVpnError"
-setting_wimax_error_quark cheader_filename="nm-setting-wimax.h" name="setting_wimax_error_(.+)" parent="NM.SettingWimaxError"
-setting_wired_error_quark cheader_filename="nm-setting-wired.h" name="setting_wired_error_(.+)" parent="NM.SettingWiredError"
-setting_wireless_error_quark cheader_filename="nm-setting-wireless.h" name="setting_wireless_error_(.+)" parent="NM.SettingWirelessError"
-setting_wireless_security_error_quark cheader_filename="nm-setting-wireless-security.h" name="setting_wireless_security_error_(.+)" parent="NM.SettingWirelessSecurityError"
-
-SETTING_PARAM_* cheader_filename="nm-setting.h" parent="NM.Setting" name="SETTING_PARAM_(.+)"
-utils_* cheader_filename="nm-utils.h" parent="NM.Utils" name="utils_(.+)"
-UTILS_* cheader_filename="nm-utils.h" parent="NM.Utils" name="UTILS_(.+)"
-UtilsSecurityType cheader_filename="nm-utils.h" parent="NM.Utils" name="SecurityType"
diff --git a/vapi/libnm-glib.deps b/vapi/libnm-glib.deps
deleted file mode 100644
index 56e9985907..0000000000
--- a/vapi/libnm-glib.deps
+++ /dev/null
@@ -1,3 +0,0 @@
-dbus-glib-1
-libnm-util
-gio-2.0
diff --git a/vapi/libnm-util.deps b/vapi/libnm-util.deps
deleted file mode 100644
index efd2584db2..0000000000
--- a/vapi/libnm-util.deps
+++ /dev/null
@@ -1,2 +0,0 @@
-dbus-glib-1
-gio-2.0
diff --git a/vapi/meson.build b/vapi/meson.build
index addc8d7dd6..bc0984f22e 100644
--- a/vapi/meson.build
+++ b/vapi/meson.build
@@ -4,25 +4,3 @@ gnome.generate_vapi(
packages: 'gio-2.0',
install: true,
)
-
-if enable_libnm_glib
- packages = [
- 'dbus-glib-1',
- 'gio-2.0',
- ]
-
- libnm_util_vapi = gnome.generate_vapi(
- libnm_util_name,
- sources: libnm_util_gir[0],
- packages: packages,
- install: true,
- )
-
- gnome.generate_vapi(
- libnm_glib_name,
- sources: libnm_glib_gir[0],
- packages: packages + [libnm_util_vapi],
- gir_dirs: [join_paths(meson.current_build_dir(), '..', 'libnm-util')],
- install: true,
- )
-endif