diff options
| author | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
| commit | 2c032d8f1c6292c1338a615e6ec40252889ba85c (patch) | |
| tree | 1f77182220b2b0264288ba4a476ab47e5bc48716 /include | |
| parent | 33491bc4279481db8ae47213e34a6d695a0e8830 (diff) | |
Imported Upstream version 1.0.0 upstream/1.0.0
Diffstat (limited to 'include')
| -rw-r--r-- | include/Makefile.am | 14 | ||||
| -rw-r--r-- | include/Makefile.in | 185 | ||||
| -rw-r--r-- | include/NetworkManager.h | 592 | ||||
| -rw-r--r-- | include/NetworkManagerVPN.h | 232 | ||||
| -rw-r--r-- | include/gsystem-local-alloc.h | 183 | ||||
| -rw-r--r-- | include/nm-dbus-glib-types.h | 18 | ||||
| -rw-r--r-- | include/nm-glib-compat.h | 125 | ||||
| -rw-r--r-- | include/nm-gvaluearray-compat.h | 11 | ||||
| -rw-r--r-- | include/nm-settings-flags.h | 39 | ||||
| -rw-r--r-- | include/nm-test-utils.h | 465 | ||||
| -rw-r--r-- | include/nm-utils-internal.h | 103 | ||||
| -rw-r--r-- | include/nm-version.h | 118 | ||||
| -rw-r--r-- | include/nm-version.h.in | 118 |
13 files changed, 872 insertions, 1331 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 087afe48..6e84a5b6 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,17 +1,9 @@ EXTRA_DIST = \ - NetworkManager.h \ - NetworkManagerVPN.h \ + gsystem-local-alloc.h \ nm-dbus-glib-types.h \ nm-glib-compat.h \ nm-gvaluearray-compat.h \ nm-test-utils.h \ - nm-version.h.in \ - nm-settings-flags.h - -NetworkManagerincludedir=$(includedir)/NetworkManager - -NetworkManagerinclude_HEADERS = \ - NetworkManager.h \ - NetworkManagerVPN.h \ - nm-version.h + nm-utils-internal.h +CLEANFILES=nm-version.h diff --git a/include/Makefile.in b/include/Makefile.in index 4ec32b8b..07ade2fb 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -13,7 +13,6 @@ # PARTICULAR PURPOSE. @SET_MAKE@ - VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ @@ -79,8 +78,7 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = include -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/nm-version.h.in $(NetworkManagerinclude_HEADERS) +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ $(top_srcdir)/m4/compiler_warnings.m4 \ @@ -99,7 +97,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = nm-version.h +CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -120,54 +118,7 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(NetworkManagerincludedir)" -HEADERS = $(NetworkManagerinclude_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ @@ -178,6 +129,8 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ +BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -301,6 +254,7 @@ NEWT_CFLAGS = @NEWT_CFLAGS@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ +NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -320,6 +274,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ @@ -346,7 +301,7 @@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_BASE_DIR = @UDEV_BASE_DIR@ +UDEV_DIR = @UDEV_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ @@ -426,21 +381,14 @@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ EXTRA_DIST = \ - NetworkManager.h \ - NetworkManagerVPN.h \ + gsystem-local-alloc.h \ nm-dbus-glib-types.h \ nm-glib-compat.h \ nm-gvaluearray-compat.h \ nm-test-utils.h \ - nm-version.h.in \ - nm-settings-flags.h - -NetworkManagerincludedir = $(includedir)/NetworkManager -NetworkManagerinclude_HEADERS = \ - NetworkManager.h \ - NetworkManagerVPN.h \ - nm-version.h + nm-utils-internal.h +CLEANFILES = nm-version.h all: all-am .SUFFIXES: @@ -474,87 +422,18 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -nm-version.h: $(top_builddir)/config.status $(srcdir)/nm-version.h.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -install-NetworkManagerincludeHEADERS: $(NetworkManagerinclude_HEADERS) - @$(NORMAL_INSTALL) - @list='$(NetworkManagerinclude_HEADERS)'; test -n "$(NetworkManagerincludedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(NetworkManagerincludedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(NetworkManagerincludedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(NetworkManagerincludedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(NetworkManagerincludedir)" || exit $$?; \ - done +tags TAGS: -uninstall-NetworkManagerincludeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(NetworkManagerinclude_HEADERS)'; test -n "$(NetworkManagerincludedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(NetworkManagerincludedir)'; $(am__uninstall_files_from_dir) - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files +ctags CTAGS: + +cscope cscopelist: -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -588,11 +467,8 @@ distdir: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(HEADERS) +all-am: Makefile installdirs: - for dir in "$(DESTDIR)$(NetworkManagerincludedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done install: install-am install-exec: install-exec-am install-data: install-data-am @@ -615,6 +491,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -629,7 +506,7 @@ clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags +distclean-am: clean-am distclean-generic dvi: dvi-am @@ -643,7 +520,7 @@ info: info-am info-am: -install-data-am: install-NetworkManagerincludeHEADERS +install-data-am: install-dvi: install-dvi-am @@ -687,23 +564,21 @@ ps: ps-am ps-am: -uninstall-am: uninstall-NetworkManagerincludeHEADERS +uninstall-am: .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool cscopelist-am ctags ctags-am distclean \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install \ - install-NetworkManagerincludeHEADERS install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-NetworkManagerincludeHEADERS uninstall-am +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/include/NetworkManager.h b/include/NetworkManager.h deleted file mode 100644 index 3fee1af0..00000000 --- a/include/NetworkManager.h +++ /dev/null @@ -1,592 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * Dan Williams <dcbw@redhat.com> - * - * 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. - * - * (C) Copyright 2004 - 2013 Red Hat, Inc. - */ - -#ifndef NETWORK_MANAGER_H -#define NETWORK_MANAGER_H - -#include "nm-version.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, - NM_CONNECTIVITY_NONE, - NM_CONNECTIVITY_PORTAL, - NM_CONNECTIVITY_LIMITED, - NM_CONNECTIVITY_FULL -} 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 WiFi 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 - * - * #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, -} 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 - * - * General device capability flags. - **/ -typedef enum { - NM_DEVICE_CAP_NONE = 0x00000000, - NM_DEVICE_CAP_NM_SUPPORTED = 0x00000001, - NM_DEVICE_CAP_CARRIER_DETECT = 0x00000002 -} 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 - * - * 802.11 specific device encryption and authentication capabilities. - **/ -typedef enum { - 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 -} 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 { - 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 { - 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 { - NM_802_11_MODE_UNKNOWN = 0, - NM_802_11_MODE_ADHOC, - NM_802_11_MODE_INFRA, - NM_802_11_MODE_AP -} 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 { - 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 { - 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 WiFi 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; - - -/* - * Device state change reason codes - */ -typedef enum { - /* No reason given */ - NM_DEVICE_STATE_REASON_NONE = 0, - - /* Unknown error */ - NM_DEVICE_STATE_REASON_UNKNOWN = 1, - - /* Device is now managed */ - NM_DEVICE_STATE_REASON_NOW_MANAGED = 2, - - /* Device is now unmanaged */ - NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3, - - /* The device could not be readied for configuration */ - NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4, - - /* IP configuration could not be reserved (no available address, timeout, etc) */ - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5, - - /* The IP config is no longer valid */ - NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6, - - /* Secrets were required, but not provided */ - NM_DEVICE_STATE_REASON_NO_SECRETS = 7, - - /* 802.1x supplicant disconnected */ - NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8, - - /* 802.1x supplicant configuration failed */ - NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9, - - /* 802.1x supplicant failed */ - NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10, - - /* 802.1x supplicant took too long to authenticate */ - NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11, - - /* PPP service failed to start */ - NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12, - - /* PPP service disconnected */ - NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13, - - /* PPP failed */ - NM_DEVICE_STATE_REASON_PPP_FAILED = 14, - - /* DHCP client failed to start */ - NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15, - - /* DHCP client error */ - NM_DEVICE_STATE_REASON_DHCP_ERROR = 16, - - /* DHCP client failed */ - NM_DEVICE_STATE_REASON_DHCP_FAILED = 17, - - /* Shared connection service failed to start */ - NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18, - - /* Shared connection service failed */ - NM_DEVICE_STATE_REASON_SHARED_FAILED = 19, - - /* AutoIP service failed to start */ - NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20, - - /* AutoIP service error */ - NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21, - - /* AutoIP service failed */ - NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22, - - /* The line is busy */ - NM_DEVICE_STATE_REASON_MODEM_BUSY = 23, - - /* No dial tone */ - NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24, - - /* No carrier could be established */ - NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25, - - /* The dialing request timed out */ - NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26, - - /* The dialing attempt failed */ - NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27, - - /* Modem initialization failed */ - NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28, - - /* Failed to select the specified APN */ - NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29, - - /* Not searching for networks */ - NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING = 30, - - /* Network registration denied */ - NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31, - - /* Network registration timed out */ - NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32, - - /* Failed to register with the requested network */ - NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33, - - /* PIN check failed */ - NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34, - - /* Necessary firmware for the device may be missing */ - NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35, - - /* The device was removed */ - NM_DEVICE_STATE_REASON_REMOVED = 36, - - /* NetworkManager went to sleep */ - NM_DEVICE_STATE_REASON_SLEEPING = 37, - - /* The device's active connection disappeared */ - NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38, - - /* Device disconnected by user or client */ - NM_DEVICE_STATE_REASON_USER_REQUESTED = 39, - - /* Carrier/link changed */ - NM_DEVICE_STATE_REASON_CARRIER = 40, - - /* The device's existing connection was assumed */ - NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41, - - /* The supplicant is now available */ - NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42, - - /* The modem could not be found */ - NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43, - - /* The Bluetooth connection failed or timed out */ - NM_DEVICE_STATE_REASON_BT_FAILED = 44, - - /* GSM Modem's SIM Card not inserted */ - NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45, - - /* GSM Modem's SIM Pin required */ - NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46, - - /* GSM Modem's SIM Puk required */ - NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47, - - /* GSM Modem's SIM wrong */ - NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48, - - /* InfiniBand device does not support connected mode */ - NM_DEVICE_STATE_REASON_INFINIBAND_MODE = 49, - - /* A dependency of the connection failed */ - NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED = 50, - - /* Problem with the RFC 2684 Ethernet over ADSL bridge */ - NM_DEVICE_STATE_REASON_BR2684_FAILED = 51, - - /* ModemManager not running */ - NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52, - - /* The WiFi network could not be found */ - NM_DEVICE_STATE_REASON_SSID_NOT_FOUND = 53, - - /* A secondary connection of the base connection failed */ - NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED = 54, - - /* DCB or FCoE setup failed */ - NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED = 55, - - /* teamd control failed */ - NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED = 56, - - /* Modem failed or no longer available */ - NM_DEVICE_STATE_REASON_MODEM_FAILED = 57, - - /* Modem now ready and available */ - NM_DEVICE_STATE_REASON_MODEM_AVAILABLE = 58, - - /* SIM PIN was incorrect */ - NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT = 59, - - /* Unused */ - 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, - NM_ACTIVE_CONNECTION_STATE_ACTIVATED, - NM_ACTIVE_CONNECTION_STATE_DEACTIVATING, - NM_ACTIVE_CONNECTION_STATE_DEACTIVATED -} NMActiveConnectionState; - -#endif /* NETWORK_MANAGER_H */ - diff --git a/include/NetworkManagerVPN.h b/include/NetworkManagerVPN.h deleted file mode 100644 index 5997c99f..00000000 --- a/include/NetworkManagerVPN.h +++ /dev/null @@ -1,232 +0,0 @@ -/* NetworkManager -- Network link manager - * - * Dan Williams <dcbw@redhat.com> - * - * 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. - * - * (C) Copyright 2004 Red Hat, Inc. - */ - -#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" - -/* - * 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; - - -/* - * 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; - -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; - -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" - - -/*** 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/include/gsystem-local-alloc.h b/include/gsystem-local-alloc.h new file mode 100644 index 00000000..68b12274 --- /dev/null +++ b/include/gsystem-local-alloc.h @@ -0,0 +1,183 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2012 Colin Walters <walters@verbum.org>. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GSYSTEM_LOCAL_ALLOC_H__ +#define __GSYSTEM_LOCAL_ALLOC_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + +#define GS_DEFINE_CLEANUP_FUNCTION(Type, name, func) \ + static inline void name (void *v) \ + { \ + func (*(Type*)v); \ + } + +#define GS_DEFINE_CLEANUP_FUNCTION0(Type, name, func) \ + static inline void name (void *v) \ + { \ + if (*(Type*)v) \ + func (*(Type*)v); \ + } + +/* These functions shouldn't be invoked directly; + * they are stubs that: + * 1) Take a pointer to the location (typically itself a pointer). + * 2) Provide %NULL-safety where it doesn't exist already (e.g. g_object_unref) + */ +GS_DEFINE_CLEANUP_FUNCTION0(GArray*, gs_local_array_unref, g_array_unref) +GS_DEFINE_CLEANUP_FUNCTION0(GBytes*, gs_local_bytes_unref, g_bytes_unref) +GS_DEFINE_CLEANUP_FUNCTION0(GChecksum*, gs_local_checksum_free, g_checksum_free) +GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, gs_local_keyfile_unref, g_key_file_unref) +GS_DEFINE_CLEANUP_FUNCTION0(GError*, gs_local_free_error, g_error_free) +GS_DEFINE_CLEANUP_FUNCTION0(GHashTable*, gs_local_hashtable_unref, g_hash_table_unref) +GS_DEFINE_CLEANUP_FUNCTION(GList*, gs_local_free_list, g_list_free) +GS_DEFINE_CLEANUP_FUNCTION(GSList*, gs_local_free_slist, g_slist_free) +GS_DEFINE_CLEANUP_FUNCTION0(GObject*, gs_local_obj_unref, g_object_unref) +GS_DEFINE_CLEANUP_FUNCTION0(GPtrArray*, gs_local_ptrarray_unref, g_ptr_array_unref) +GS_DEFINE_CLEANUP_FUNCTION0(GVariant*, gs_local_variant_unref, g_variant_unref) +GS_DEFINE_CLEANUP_FUNCTION0(GVariantBuilder*, gs_local_variant_builder_unref, g_variant_builder_unref) +GS_DEFINE_CLEANUP_FUNCTION0(GVariantIter*, gs_local_variant_iter_free, g_variant_iter_free) + +GS_DEFINE_CLEANUP_FUNCTION(char**, gs_local_strfreev, g_strfreev) +GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free) + +/** + * gs_free: + * + * Call g_free() on a variable location when it goes out of scope. + */ +#define gs_free __attribute__ ((cleanup(gs_local_free))) + +/** + * gs_unref_object: + * + * Call g_object_unref() on a variable location when it goes out of + * scope. Note that unlike g_object_unref(), the variable may be + * %NULL. + */ +#define gs_unref_object __attribute__ ((cleanup(gs_local_obj_unref))) + +/** + * gs_unref_variant: + * + * Call g_variant_unref() on a variable location when it goes out of + * scope. Note that unlike g_variant_unref(), the variable may be + * %NULL. + */ +#define gs_unref_variant __attribute__ ((cleanup(gs_local_variant_unref))) + +/** + * gs_free_variant_iter: + * + * Call g_variant_iter_free() on a variable location when it goes out of + * scope. + */ +#define gs_free_variant_iter __attribute__ ((cleanup(gs_local_variant_iter_free))) + +/** + * gs_free_variant_builder: + * + * Call g_variant_builder_unref() on a variable location when it goes out of + * scope. + */ +#define gs_unref_variant_builder __attribute__ ((cleanup(gs_local_variant_builder_unref))) + +/** + * gs_unref_array: + * + * Call g_array_unref() on a variable location when it goes out of + * scope. Note that unlike g_array_unref(), the variable may be + * %NULL. + + */ +#define gs_unref_array __attribute__ ((cleanup(gs_local_array_unref))) + +/** + * gs_unref_ptrarray: + * + * Call g_ptr_array_unref() on a variable location when it goes out of + * scope. Note that unlike g_ptr_array_unref(), the variable may be + * %NULL. + + */ +#define gs_unref_ptrarray __attribute__ ((cleanup(gs_local_ptrarray_unref))) + +/** + * gs_unref_hashtable: + * + * Call g_hash_table_unref() on a variable location when it goes out + * of scope. Note that unlike g_hash_table_unref(), the variable may + * be %NULL. + */ +#define gs_unref_hashtable __attribute__ ((cleanup(gs_local_hashtable_unref))) + +/** + * gs_free_list: + * + * Call g_list_free() on a variable location when it goes out + * of scope. + */ +#define gs_free_list __attribute__ ((cleanup(gs_local_free_list))) + +/** + * gs_free_slist: + * + * Call g_slist_free() on a variable location when it goes out + * of scope. + */ +#define gs_free_slist __attribute__ ((cleanup(gs_local_free_slist))) + +/** + * gs_free_checksum: + * + * Call g_checksum_free() on a variable location when it goes out + * of scope. Note that unlike g_checksum_free(), the variable may + * be %NULL. + */ +#define gs_free_checksum __attribute__ ((cleanup(gs_local_checksum_free))) + +/** + * gs_unref_bytes: + * + * Call g_bytes_unref() on a variable location when it goes out + * of scope. Note that unlike g_bytes_unref(), the variable may + * be %NULL. + */ +#define gs_unref_bytes __attribute__ ((cleanup(gs_local_bytes_unref))) + +/** + * gs_strfreev: + * + * Call g_strfreev() on a variable location when it goes out of scope. + */ +#define gs_strfreev __attribute__ ((cleanup(gs_local_strfreev))) + +/** + * gs_free_error: + * + * Call g_error_free() on a variable location when it goes out of scope. + */ +#define gs_free_error __attribute__ ((cleanup(gs_local_free_error))) + +G_END_DECLS + +#endif diff --git a/include/nm-dbus-glib-types.h b/include/nm-dbus-glib-types.h index 0f8c542e..ad11ab68 100644 --- a/include/nm-dbus-glib-types.h +++ b/include/nm-dbus-glib-types.h @@ -1,7 +1,5 @@ -/* NetworkManager -- Network link manager - * - * Dan Williams <dcbw@redhat.com> - * +/* -*- 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 @@ -16,11 +14,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * (C) Copyright 2008 Red Hat, Inc. + * Copyright 2008 Red Hat, Inc. */ -#ifndef DBUS_GLIB_TYPES_H -#define DBUS_GLIB_TYPES_H +#ifndef __NM_DBUS_GLIB_TYPES_H__ +#define __NM_DBUS_GLIB_TYPES_H__ #include <dbus/dbus-glib.h> @@ -39,5 +37,9 @@ #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)) -#endif /* DBUS_GLIB_TYPES_H */ +#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/include/nm-glib-compat.h b/include/nm-glib-compat.h index cfaddb7d..1dc939fe 100644 --- a/include/nm-glib-compat.h +++ b/include/nm-glib-compat.h @@ -1,8 +1,5 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * Dan Williams <dcbw@redhat.com> - * +/* * 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 @@ -17,43 +14,67 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * (C) Copyright 2008 - 2011 Red Hat, Inc. + * Copyright 2008 - 2011 Red Hat, Inc. */ -#ifndef NM_GLIB_COMPAT_H -#define NM_GLIB_COMPAT_H +#ifndef __NM_GLIB_COMPAT_H__ +#define __NM_GLIB_COMPAT_H__ #include <glib.h> #include <glib-object.h> + +#ifdef __clang__ + +#undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS +#undef G_GNUC_END_IGNORE_DEPRECATIONS + +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") + +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic pop") + +#endif + + #include "nm-gvaluearray-compat.h" -#if !GLIB_CHECK_VERSION(2,34,0) + static inline void -g_type_ensure (GType type) +__g_type_ensure (GType type) { - if (G_UNLIKELY (type == (GType)-1)) - g_error ("can't happen"); +#if !GLIB_CHECK_VERSION(2,34,0) + if (G_UNLIKELY (type == (GType)-1)) + g_error ("can't happen"); +#else + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + g_type_ensure (type); + G_GNUC_END_IGNORE_DEPRECATIONS; +#endif } +#define g_type_ensure __g_type_ensure -#define g_clear_pointer(pp, destroy) \ - G_STMT_START { \ - G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ - /* Only one access, please */ \ - gpointer *_pp = (gpointer *) (pp); \ - gpointer _p; \ - /* This assignment is needed to avoid a gcc warning */ \ - GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ - \ - (void) (0 ? (gpointer) *(pp) : 0); \ - do \ - _p = g_atomic_pointer_get (_pp); \ - while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_pp, _p, NULL)); \ - \ - if (_p) \ - _destroy (_p); \ - } G_STMT_END +#if !GLIB_CHECK_VERSION(2,34,0) + +#define g_clear_pointer(pp, destroy) \ + G_STMT_START { \ + G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ + /* Only one access, please */ \ + gpointer *_pp = (gpointer *) (pp); \ + gpointer _p; \ + /* This assignment is needed to avoid a gcc warning */ \ + GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ + \ + _p = *_pp; \ + if (_p) \ + { \ + *_pp = NULL; \ + _destroy (_p); \ + } \ + } G_STMT_END /* These are used to clean up the output of test programs; we can just let * them no-op in older glib. @@ -68,13 +89,6 @@ g_type_ensure (GType type) * the APIs that we emulate above. */ -#define g_type_ensure(t) \ - G_STMT_START { \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - g_type_ensure (t); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - } G_STMT_END - #define g_test_expect_message(domain, level, format...) \ G_STMT_START { \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ @@ -110,4 +124,43 @@ __nmtst_g_test_skip (const gchar *msg) } #define g_test_skip __nmtst_g_test_skip -#endif /* NM_GLIB_COMPAT_H */ + +/* g_test_add_data_func_full() is only available since glib 2.34. Add a compatibility wrapper. */ +inline static void +__g_test_add_data_func_full (const char *testpath, + gpointer test_data, + GTestDataFunc test_func, + GDestroyNotify data_free_func) +{ +#if GLIB_CHECK_VERSION (2, 34, 0) + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_test_add_data_func_full (testpath, test_data, test_func, data_free_func); + G_GNUC_END_IGNORE_DEPRECATIONS +#else + g_return_if_fail (testpath != NULL); + g_return_if_fail (testpath[0] == '/'); + g_return_if_fail (test_func != NULL); + + g_test_add_vtable (testpath, 0, test_data, NULL, + (GTestFixtureFunc) test_func, + (GTestFixtureFunc) data_free_func); +#endif +} +#define g_test_add_data_func_full __g_test_add_data_func_full + + +#if !GLIB_CHECK_VERSION (2, 34, 0) +#define G_DEFINE_QUARK(QN, q_n) \ +GQuark \ +q_n##_quark (void) \ +{ \ + static GQuark q; \ + \ + if G_UNLIKELY (q == 0) \ + q = g_quark_from_static_string (#QN); \ + \ + return q; \ +} +#endif + +#endif /* __NM_GLIB_COMPAT_H__ */ diff --git a/include/nm-gvaluearray-compat.h b/include/nm-gvaluearray-compat.h index e26ce371..f0b4a6cd 100644 --- a/include/nm-gvaluearray-compat.h +++ b/include/nm-gvaluearray-compat.h @@ -1,6 +1,5 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * +/* * 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 @@ -18,11 +17,13 @@ * Copyright 2013 Red Hat, Inc. */ -#ifndef NM_GVALUEARRAY_COMPAT_H -#define NM_GVALUEARRAY_COMPAT_H +#ifndef __NM_GVALUEARRAY_COMPAT_H__ +#define __NM_GVALUEARRAY_COMPAT_H__ #include <glib.h> +#include "nm-glib-compat.h" + #define g_value_array_get_type() \ G_GNUC_EXTENSION ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ @@ -104,4 +105,4 @@ __g_value_array_free (GValueArray *value_array) G_GNUC_END_IGNORE_DEPRECATIONS \ }) -#endif /* NM_GVALUEARRAY_COMPAT_H */ +#endif /* __NM_GVALUEARRAY_COMPAT_H__ */ diff --git a/include/nm-settings-flags.h b/include/nm-settings-flags.h deleted file mode 100644 index 57f38ea5..00000000 --- a/include/nm-settings-flags.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * 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) 2011 Red Hat, Inc. - */ - -#ifndef NM_SETTINGS_FLAGS_H -#define NM_SETTINGS_FLAGS_H - -/* NOTE: these values should match the NM_SECRET_AGENT_GET_SECRETS_FLAGS in - * the nm-secret-agent.xml introspection file; except ONLY_SYSTEM which is - * internal to NM. - */ -typedef enum { - NM_SETTINGS_GET_SECRETS_FLAG_NONE = 0x0, - NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1, - NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW = 0x2, - NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED = 0x4, - - /* Internal only to NM */ - NM_SETTINGS_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000 -} NMSettingsGetSecretsFlags; - -#endif /* NM_SETTINGS_FLAGS_H */ - diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index 83c4080f..dcfa46eb 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -1,5 +1,4 @@ /* -*- 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 @@ -16,7 +15,7 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * (C) Copyright 2014 Red Hat, Inc. + * Copyright 2014 Red Hat, Inc. */ #ifndef __NM_TEST_UTILS_H__ @@ -34,7 +33,32 @@ #include "nm-utils.h" #include "nm-glib-compat.h" +#include "gsystem-local-alloc.h" + + +/*******************************************************************************/ + +/* general purpose functions that have no dependency on other nmtst functions */ + +inline static void +nmtst_assert_error (GError *error, + GQuark expect_error_domain, + gint expect_error_code, + const char *expect_error_pattern) +{ + if (expect_error_domain) + g_assert_error (error, expect_error_domain, expect_error_code); + else + g_assert (error); + g_assert (error->message); + if ( expect_error_pattern + && !g_pattern_match_simple (expect_error_pattern, error->message)) { + g_error ("error message does not have expected pattern '%s'. Instead it is '%s' (%s, %d)", + expect_error_pattern, error->message, g_quark_to_string (error->domain), error->code); + } +} +/*******************************************************************************/ struct __nmtst_internal { @@ -140,7 +164,6 @@ inline static void __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_level, const char *log_domains) { static gsize atexit_registered = 0; - GError *error = NULL; const char *nmtst_debug; gboolean is_debug = FALSE; char *c_log_level = NULL, *c_log_domains = NULL; @@ -243,7 +266,7 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_ if (!__nmtst_internal.assert_logging) { gboolean success = TRUE; -#ifdef NM_LOGGING_H +#ifdef __NETWORKMANAGER_LOGGING_H__ success = nm_logging_setup (log_level, log_domains, NULL, NULL); #endif g_assert (success); @@ -276,10 +299,6 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_ g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); } - if (!nm_utils_init (&error)) - g_error ("failed to initialize libnm-util: %s", error->message); - g_assert (!error); - /* Delay messages until we setup logging. */ for (i = 0; i < debug_messages->len; i++) __NMTST_LOG (g_message, "%s", g_array_index (debug_messages, const char *, i)); @@ -292,9 +311,14 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_ atexit (nmtst_free); g_once_init_leave (&atexit_registered, 1); } + +#ifdef __NETWORKMANAGER_UTILS_H__ + /* ensure that monotonic timestamp is called (because it initially logs a line) */ + nm_utils_get_monotonic_timestamp_s (); +#endif } -#ifdef NM_LOGGING_H +#ifdef __NETWORKMANAGER_LOGGING_H__ inline static void nmtst_init_with_logging (int *argc, char ***argv, const char *log_level, const char *log_domains) { @@ -336,14 +360,14 @@ nmtst_is_debug (void) #endif inline static GRand * -nmtst_get_rand0 () +nmtst_get_rand0 (void) { g_assert (nmtst_initialized ()); return __nmtst_internal.rand0; } inline static GRand * -nmtst_get_rand () +nmtst_get_rand (void) { g_assert (nmtst_initialized ()); @@ -539,7 +563,7 @@ __nmtst_spawn_sync (const char *working_directory, char **standard_out, char **s /*******************************************************************************/ -#ifdef NM_PLATFORM_H +#ifdef __NETWORKMANAGER_PLATFORM_H__ inline static NMPlatformIP6Address * nmtst_platform_ip6_address (const char *address, const char *peer_address, guint plen) @@ -556,7 +580,7 @@ nmtst_platform_ip6_address (const char *address, const char *peer_address, guint inline static NMPlatformIP6Address * nmtst_platform_ip6_address_full (const char *address, const char *peer_address, guint plen, - int ifindex, NMPlatformSource source, guint32 timestamp, + int ifindex, NMIPConfigSource source, guint32 timestamp, guint32 lifetime, guint32 preferred, guint flags) { NMPlatformIP6Address *addr = nmtst_platform_ip6_address (address, peer_address, plen); @@ -586,7 +610,7 @@ nmtst_platform_ip6_route (const char *network, guint plen, const char *gateway) inline static NMPlatformIP6Route * nmtst_platform_ip6_route_full (const char *network, guint plen, const char *gateway, - int ifindex, NMPlatformSource source, + int ifindex, NMIPConfigSource source, guint metric, guint mss) { NMPlatformIP6Route *route = nmtst_platform_ip6_route (network, plen, gateway); @@ -644,7 +668,7 @@ nmtst_platform_ip6_routes_equal (const NMPlatformIP6Route *a, const NMPlatformIP #endif -#ifdef NM_IP4_CONFIG_H +#ifdef __NETWORKMANAGER_IP4_CONFIG_H__ inline static NMIP4Config * nmtst_ip4_config_clone (NMIP4Config *config) @@ -660,7 +684,7 @@ nmtst_ip4_config_clone (NMIP4Config *config) #endif -#ifdef NM_IP6_CONFIG_H +#ifdef __NETWORKMANAGER_IP6_CONFIG_H__ inline static NMIP6Config * nmtst_ip6_config_clone (NMIP6Config *config) @@ -675,6 +699,413 @@ nmtst_ip6_config_clone (NMIP6Config *config) #endif +#ifdef __NM_SIMPLE_CONNECTION_H__ -#endif /* __NM_TEST_UTILS_H__ */ +inline static NMConnection * +nmtst_create_minimal_connection (const char *id, const char *uuid, const char *type, NMSettingConnection **out_s_con) +{ + NMConnection *con; + NMSetting *s_base = NULL; + NMSettingConnection *s_con; + gs_free char *uuid_free = NULL; + + g_assert (id); + + if (uuid) + g_assert (nm_utils_is_uuid (uuid)); + else + uuid = uuid_free = nm_utils_uuid_generate (); + + if (type) { + GType type_g = nm_setting_lookup_type (type); + + g_assert (type_g != G_TYPE_INVALID); + + s_base = g_object_new (type_g, NULL); + g_assert (NM_IS_SETTING (s_base)); + } + + con = nm_simple_connection_new (); + s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); + + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, id, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, type, + NULL); + nm_connection_add_setting (con, NM_SETTING (s_con)); + + if (s_base) + nm_connection_add_setting (con, s_base); + + if (out_s_con) + *out_s_con = s_con; + return con; +} + +inline static gboolean +_nmtst_connection_normalize_v (NMConnection *connection, va_list args) +{ + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + GHashTable *parameters = NULL; + const char *p_name; + + g_assert (NM_IS_CONNECTION (connection)); + + while ((p_name = va_arg (args, const char *))) { + if (!parameters) + parameters = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (parameters, (gpointer *) p_name, va_arg (args, gpointer)); + } + + success = nm_connection_normalize (connection, + parameters, + &was_modified, + &error); + g_assert_no_error (error); + g_assert (success); + + if (parameters) + g_hash_table_destroy (parameters); + + return was_modified; +} + +inline static gboolean +_nmtst_connection_normalize (NMConnection *connection, ...) +{ + gboolean was_modified; + va_list args; + + va_start (args, connection); + was_modified = _nmtst_connection_normalize_v (connection, args); + va_end (args); + + return was_modified; +} +#define nmtst_connection_normalize(connection, ...) \ + _nmtst_connection_normalize(connection, ##__VA_ARGS__, NULL) + +inline static NMConnection * +_nmtst_connection_duplicate_and_normalize (NMConnection *connection, ...) +{ + gboolean was_modified; + va_list args; + + g_assert (NM_IS_CONNECTION (connection)); + + connection = nm_simple_connection_new_clone (connection); + + va_start (args, connection); + was_modified = _nmtst_connection_normalize_v (connection, args); + va_end (args); + + return connection; +} +#define nmtst_connection_duplicate_and_normalize(connection, ...) \ + _nmtst_connection_duplicate_and_normalize(connection, ##__VA_ARGS__, NULL) + +inline static void +nmtst_assert_connection_equals (NMConnection *a, gboolean normalize_a, NMConnection *b, gboolean normalize_b) +{ + gboolean compare; + gs_unref_object NMConnection *a2 = NULL; + gs_unref_object NMConnection *b2 = NULL; + GHashTable *out_settings = NULL; + + g_assert (NM_IS_CONNECTION (a)); + g_assert (NM_IS_CONNECTION (b)); + + if (normalize_a) + a = a2 = nmtst_connection_duplicate_and_normalize (a); + if (normalize_b) + b = b2 = nmtst_connection_duplicate_and_normalize (b); + + compare = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_EXACT, &out_settings); + if (!compare && out_settings) { + const char *name, *pname; + GHashTable *setting; + GHashTableIter iter, iter2; + + g_hash_table_iter_init (&iter, out_settings); + while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &setting)) { + __NMTST_LOG (g_message, ">>> differences in setting '%s':", name); + + g_hash_table_iter_init (&iter2, out_settings); + while (g_hash_table_iter_next (&iter2, (gpointer *) &pname, NULL)) + __NMTST_LOG (g_message, ">>> differences in setting '%s.%s':", name, pname); + } + } + g_assert (compare); + g_assert (!out_settings); + + compare = nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT); + g_assert (compare); +} + +inline static void +nmtst_assert_connection_verifies_without_normalization (NMConnection *con) +{ + /* assert that the connection verifies and does not need any normalization */ + + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + gs_unref_object NMConnection *clone = NULL; + + g_assert (NM_IS_CONNECTION (con)); + + clone = nm_simple_connection_new_clone (con); + + success = nm_connection_verify (con, &error); + g_assert_no_error (error); + g_assert (success); + + success = nm_connection_normalize (con, NULL, &was_modified, &error); + g_assert_no_error (error); + g_assert (success); + nmtst_assert_connection_equals (con, FALSE, clone, FALSE); + g_assert (!was_modified); +} + +inline static void +nmtst_assert_connection_verifies_and_normalizable (NMConnection *con) +{ + /* assert that the connection does verify, but normalization still modifies it */ + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + + g_assert (NM_IS_CONNECTION (con)); + + success = nm_connection_verify (con, &error); + g_assert_no_error (error); + g_assert (success); + g_clear_error (&error); + + success = nm_connection_normalize (con, NULL, &was_modified, &error); + g_assert_no_error (error); + g_assert (success); + g_assert (was_modified); + + /* again! */ + nmtst_assert_connection_verifies_without_normalization (con); +} + +inline static void +nmtst_assert_connection_verifies_after_normalization (NMConnection *con, + GQuark expect_error_domain, + gint expect_error_code) +{ + /* assert that the connection does not verify, but normalization does fix it */ + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + + g_assert (NM_IS_CONNECTION (con)); + + success = nm_connection_verify (con, &error); + nmtst_assert_error (error, expect_error_domain, expect_error_code, NULL); + g_assert (!success); + g_clear_error (&error); + + success = nm_connection_normalize (con, NULL, &was_modified, &error); + g_assert_no_error (error); + g_assert (success); + g_assert (was_modified); + + /* again! */ + nmtst_assert_connection_verifies_without_normalization (con); +} + +inline static void +nmtst_assert_connection_unnormalizable (NMConnection *con, + GQuark expect_error_domain, + gint expect_error_code) +{ + /* assert that the connection does not verify, and it cannot be fixed by normalization */ + + GError *error = NULL; + gboolean success; + gboolean was_modified = FALSE; + + g_assert (NM_IS_CONNECTION (con)); + + success = nm_connection_verify (con, &error); + nmtst_assert_error (error, expect_error_domain, expect_error_code, NULL); + g_assert (!success); + g_clear_error (&error); + + success = nm_connection_normalize (con, NULL, &was_modified, &error); + nmtst_assert_error (error, expect_error_domain, expect_error_code, NULL); + g_assert (!success); + g_assert (!was_modified); + g_clear_error (&error); +} + +inline static void +nmtst_assert_setting_verifies (NMSetting *setting) +{ + /* assert that the setting verifies without an error */ + + GError *error = NULL; + gboolean success; + + g_assert (NM_IS_SETTING (setting)); + + success = nm_setting_verify (setting, NULL, &error); + g_assert_no_error (error); + g_assert (success); +} + +inline static void +nmtst_assert_setting_verify_fails (NMSetting *setting, + GQuark expect_error_domain, + gint expect_error_code) +{ + /* assert that the setting verification fails */ + + GError *error = NULL; + gboolean success; + + g_assert (NM_IS_SETTING (setting)); + + success = nm_setting_verify (setting, NULL, &error); + nmtst_assert_error (error, expect_error_domain, expect_error_code, NULL); + g_assert (!success); + g_clear_error (&error); +} + +#endif + +#ifdef __NM_UTILS_H__ +static inline void +nmtst_assert_hwaddr_equals (gconstpointer hwaddr1, gssize hwaddr1_len, const char *expected, const char *loc) +{ + guint8 buf2[NM_UTILS_HWADDR_LEN_MAX]; + gsize hwaddr2_len = 1; + const char *p; + gboolean success; + + g_assert (hwaddr1_len > 0 && hwaddr1_len <= NM_UTILS_HWADDR_LEN_MAX); + + g_assert (expected); + for (p = expected; *p; p++) { + if (*p == ':' || *p == '-') + hwaddr2_len++; + } + g_assert (hwaddr2_len <= NM_UTILS_HWADDR_LEN_MAX); + g_assert (nm_utils_hwaddr_aton (expected, buf2, hwaddr2_len)); + + /* Manually check the entire hardware address instead of using + * nm_utils_hwaddr_matches() because that function doesn't compare + * entire InfiniBand addresses for various (legitimate) reasons. + */ + success = (hwaddr1_len == hwaddr2_len); + if (success) + success = !memcmp (hwaddr1, buf2, hwaddr1_len); + if (!success) { + g_error ("assert: %s: hwaddr '%s' (%zd) expected, but got %s (%zd)", + loc, expected, hwaddr2_len, nm_utils_hwaddr_ntoa (hwaddr1, hwaddr1_len), hwaddr1_len); + } +} +#define nmtst_assert_hwaddr_equals(hwaddr1, hwaddr1_len, expected) \ + nmtst_assert_hwaddr_equals (hwaddr1, hwaddr1_len, expected, G_STRLOC) +#endif + +#ifdef __NM_CONNECTION_H__ + +typedef enum { + NMTST_VARIANT_EDITOR_CONNECTION, + NMTST_VARIANT_EDITOR_SETTING, + NMTST_VARIANT_EDITOR_PROPERTY +} NmtstVariantEditorPhase; + +#define NMTST_VARIANT_EDITOR(__connection_variant, __code) \ + G_STMT_START { \ + GVariantIter __connection_iter, *__setting_iter; \ + GVariantBuilder __connection_builder, __setting_builder; \ + const char *__cur_setting_name, *__cur_property_name; \ + GVariant *__property_val; \ + NmtstVariantEditorPhase __phase; \ + \ + g_variant_builder_init (&__connection_builder, NM_VARIANT_TYPE_CONNECTION); \ + g_variant_iter_init (&__connection_iter, __connection_variant); \ + \ + __phase = NMTST_VARIANT_EDITOR_CONNECTION; \ + __cur_setting_name = NULL; \ + __cur_property_name = NULL; \ + __code; \ + while (g_variant_iter_next (&__connection_iter, "{&sa{sv}}", &__cur_setting_name, &__setting_iter)) { \ + g_variant_builder_init (&__setting_builder, NM_VARIANT_TYPE_SETTING); \ + __phase = NMTST_VARIANT_EDITOR_SETTING; \ + __cur_property_name = NULL; \ + __code; \ + \ + while ( __cur_setting_name \ + && g_variant_iter_next (__setting_iter, "{&sv}", &__cur_property_name, &__property_val)) { \ + __phase = NMTST_VARIANT_EDITOR_PROPERTY; \ + __code; \ + \ + if (__cur_property_name) { \ + g_variant_builder_add (&__setting_builder, "{sv}", \ + __cur_property_name, \ + __property_val); \ + } else \ + g_variant_unref (__property_val); \ + } \ + \ + if (__cur_setting_name) \ + g_variant_builder_add (&__connection_builder, "{sa{sv}}", __cur_setting_name, &__setting_builder); \ + g_variant_iter_free (__setting_iter); \ + } \ + \ + g_variant_unref (__connection_variant); \ + \ + __connection_variant = g_variant_builder_end (&__connection_builder); \ + } G_STMT_END; +#define NMTST_VARIANT_ADD_SETTING(__setting_name, __setting_variant) \ + G_STMT_START { \ + if (__phase == NMTST_VARIANT_EDITOR_CONNECTION) \ + g_variant_builder_add (&__connection_builder, "{s@a{sv}}", __setting_name, __setting_variant); \ + } G_STMT_END + +#define NMTST_VARIANT_DROP_SETTING(__setting_name) \ + G_STMT_START { \ + if (__phase == NMTST_VARIANT_EDITOR_SETTING && __cur_setting_name) { \ + if (!strcmp (__cur_setting_name, __setting_name)) \ + __cur_setting_name = NULL; \ + } \ + } G_STMT_END + +#define NMTST_VARIANT_ADD_PROPERTY(__setting_name, __property_name, __format_string, __value) \ + G_STMT_START { \ + if (__phase == NMTST_VARIANT_EDITOR_SETTING) { \ + if (!strcmp (__cur_setting_name, __setting_name)) { \ + g_variant_builder_add (&__setting_builder, "{sv}", __property_name, \ + g_variant_new (__format_string, __value)); \ + } \ + } \ + } G_STMT_END + +#define NMTST_VARIANT_DROP_PROPERTY(__setting_name, __property_name) \ + G_STMT_START { \ + if (__phase == NMTST_VARIANT_EDITOR_PROPERTY && __cur_property_name) { \ + if ( !strcmp (__cur_setting_name, __setting_name) \ + && !strcmp (__cur_property_name, __property_name)) \ + __cur_property_name = NULL; \ + } \ + } G_STMT_END + +#define NMTST_VARIANT_CHANGE_PROPERTY(__setting_name, __property_name, __format_string, __value) \ + G_STMT_START { \ + NMTST_VARIANT_DROP_PROPERTY (__setting_name, __property_name); \ + NMTST_VARIANT_ADD_PROPERTY (__setting_name, __property_name, __format_string, __value); \ + } G_STMT_END + +#endif /* __NM_CONNECTION_H__ */ + +#endif /* __NM_TEST_UTILS_H__ */ diff --git a/include/nm-utils-internal.h b/include/nm-utils-internal.h new file mode 100644 index 00000000..c002b6c1 --- /dev/null +++ b/include/nm-utils-internal.h @@ -0,0 +1,103 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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. + * + * (C) Copyright 2014 Red Hat, Inc. + */ + +#ifndef __NM_UTILS_INTERNAL_H__ +#define __NM_UTILS_INTERNAL_H__ + + +#include <glib.h> + +/********************************************************/ + +/* http://stackoverflow.com/a/11172679 */ +#define _NM_UTILS_MACRO_FIRST(...) __NM_UTILS_MACRO_FIRST_HELPER(__VA_ARGS__, throwaway) +#define __NM_UTILS_MACRO_FIRST_HELPER(first, ...) first + +#define _NM_UTILS_MACRO_REST(...) __NM_UTILS_MACRO_REST_HELPER(__NM_UTILS_MACRO_REST_NUM(__VA_ARGS__), __VA_ARGS__) +#define __NM_UTILS_MACRO_REST_HELPER(qty, ...) __NM_UTILS_MACRO_REST_HELPER2(qty, __VA_ARGS__) +#define __NM_UTILS_MACRO_REST_HELPER2(qty, ...) __NM_UTILS_MACRO_REST_HELPER_##qty(__VA_ARGS__) +#define __NM_UTILS_MACRO_REST_HELPER_ONE(first) +#define __NM_UTILS_MACRO_REST_HELPER_TWOORMORE(first, ...) , __VA_ARGS__ +#define __NM_UTILS_MACRO_REST_NUM(...) \ + __NM_UTILS_MACRO_REST_SELECT_20TH(__VA_ARGS__, \ + TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ + TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ + TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ + TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway) +#define __NM_UTILS_MACRO_REST_SELECT_20TH(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, ...) a20 + +/********************************************************/ + +#if defined (__GNUC__) +#define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(GCC diagnostic ignored warning) +#elif defined (__clang__) +#define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(clang diagnostic ignored warning) +#endif + +/* you can only suppress a specific warning that the compiler + * understands. Otherwise you will get another compiler warning + * about invalid pragma option. + * It's not that bad however, because gcc and clang often have the + * same name for the same warning. */ + +#if defined (__GNUC__) +#define NM_PRAGMA_WARNING_DISABLE(warning) \ + _Pragma("GCC diagnostic push"); \ + _Pragma(_NM_PRAGMA_WARNING_DO(warning)) +#elif defined (__clang__) +#define NM_PRAGMA_WARNING_DISABLE(warning) \ + _Pragma("clang diagnostic push"); \ + _Pragma(_NM_PRAGMA_WARNING_DO(warning)) +#else +#define NM_PRAGMA_WARNING_DISABLE(warning) +#endif + +#if defined (__GNUC__) +#define NM_PRAGMA_WARNING_REENABLE \ + _Pragma("GCC diagnostic pop") +#elif defined (__clang__) +#define NM_PRAGMA_WARNING_REENABLE \ + _Pragma("clang diagnostic pop") +#else +#define NM_PRAGMA_WARNING_REENABLE +#endif + +/********************************************************/ + +/* macro to return strlen() of a compile time string. */ +#define STRLEN(str) ( sizeof ("" str) - 1 ) + +#define NM_IN_SET(x, y, ...) \ + ({ \ + const typeof(y) _y = (y); \ + typeof(_y) _x = (x); \ + unsigned _i; \ + gboolean _found = FALSE; \ + for (_i = 0; _i < 1 + sizeof((typeof(_x)[]) { __VA_ARGS__ })/sizeof(typeof(_x)); _i++) { \ + if (((typeof(_x)[]) { _y, __VA_ARGS__ })[_i] == _x) { \ + _found = TRUE; \ + break; \ + } \ + } \ + _found; \ + }) + +#endif diff --git a/include/nm-version.h b/include/nm-version.h deleted file mode 100644 index 5769156c..00000000 --- a/include/nm-version.h +++ /dev/null @@ -1,118 +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 (C) 2011 Red Hat, Inc. - */ - -#ifndef NM_VERSION_H -#define NM_VERSION_H - -/** - * NM_MAJOR_VERSION: - * - * Evaluates to the major version number of NetworkManager which this source - * is compiled against. - */ -#define NM_MAJOR_VERSION (0) - -/** - * NM_MINOR_VERSION: - * - * Evaluates to the minor version number of NetworkManager which this source - * is compiled against. - */ -#define NM_MINOR_VERSION (9) - -/** - * NM_MICRO_VERSION: - * - * Evaluates to the micro version number of NetworkManager which this source - * compiled against. - */ -#define NM_MICRO_VERSION (10) - -/** - * NM_CHECK_VERSION: - * @major: major version (e.g. 1 for version 1.2.5) - * @minor: minor version (e.g. 2 for version 1.2.5) - * @micro: micro version (e.g. 5 for version 1.2.5) - * - * Returns %TRUE if the version of the NetworkManager header files - * is the same as or newer than the passed-in version. - */ -#define NM_CHECK_VERSION(major,minor,micro) \ - (NM_MAJOR_VERSION > (major) || \ - (NM_MAJOR_VERSION == (major) && NM_MINOR_VERSION > (minor)) || \ - (NM_MAJOR_VERSION == (major) && NM_MINOR_VERSION == (minor) && NM_MICRO_VERSION >= (micro))) - - -/* Deprecation / Availability macros */ - -#define NM_ENCODE_VERSION(major,minor,micro) ((major) << 16 | (minor) << 8 | (micro)) - -#define NM_VERSION_0_9_8 (NM_ENCODE_VERSION (0, 9, 8)) -#define NM_VERSION_0_9_10 (NM_ENCODE_VERSION (0, 9, 10)) - -#if (NM_MICRO_VERSION % 2) -#define NM_VERSION_CUR_STABLE (NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION - 1)) -#else -#define NM_VERSION_CUR_STABLE (NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION)) -#endif - -#if (NM_MICRO_VERSION % 2) -#define NM_VERSION_NEXT_STABLE (NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION +1)) -#else -#define NM_VERSION_NEXT_STABLE (NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION + 2)) -#endif - -#if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) -# undef NM_VERSION_MIN_REQUIRED -# define NM_VERSION_MIN_REQUIRED (NM_VERSION_CUR_STABLE) -#endif - -#if !defined (NM_VERSION_MAX_ALLOWED) || (NM_VERSION_MAX_ALLOWED == 0) -# undef NM_VERSION_MAX_ALLOWED -# define NM_VERSION_MAX_ALLOWED (NM_VERSION_CUR_STABLE) -#endif - -/* sanity checks */ -#if NM_VERSION_MIN_REQUIRED > NM_VERSION_NEXT_STABLE -#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_NEXT_STABLE" -#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 - -#endif /* NM_VERSION_H */ - diff --git a/include/nm-version.h.in b/include/nm-version.h.in deleted file mode 100644 index 711bfa9f..00000000 --- a/include/nm-version.h.in +++ /dev/null @@ -1,118 +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 (C) 2011 Red Hat, Inc. - */ - -#ifndef NM_VERSION_H -#define NM_VERSION_H - -/** - * NM_MAJOR_VERSION: - * - * Evaluates to the major version number of NetworkManager which this source - * is compiled against. - */ -#define NM_MAJOR_VERSION (@NM_MAJOR_VERSION@) - -/** - * NM_MINOR_VERSION: - * - * Evaluates to the minor version number of NetworkManager which this source - * is compiled against. - */ -#define NM_MINOR_VERSION (@NM_MINOR_VERSION@) - -/** - * NM_MICRO_VERSION: - * - * Evaluates to the micro version number of NetworkManager which this source - * compiled against. - */ -#define NM_MICRO_VERSION (@NM_MICRO_VERSION@) - -/** - * NM_CHECK_VERSION: - * @major: major version (e.g. 1 for version 1.2.5) - * @minor: minor version (e.g. 2 for version 1.2.5) - * @micro: micro version (e.g. 5 for version 1.2.5) - * - * Returns %TRUE if the version of the NetworkManager header files - * is the same as or newer than the passed-in version. - */ -#define NM_CHECK_VERSION(major,minor,micro) \ - (NM_MAJOR_VERSION > (major) || \ - (NM_MAJOR_VERSION == (major) && NM_MINOR_VERSION > (minor)) || \ - (NM_MAJOR_VERSION == (major) && NM_MINOR_VERSION == (minor) && NM_MICRO_VERSION >= (micro))) - - -/* Deprecation / Availability macros */ - -#define NM_ENCODE_VERSION(major,minor,micro) ((major) << 16 | (minor) << 8 | (micro)) - -#define NM_VERSION_0_9_8 (NM_ENCODE_VERSION (0, 9, 8)) -#define NM_VERSION_0_9_10 (NM_ENCODE_VERSION (0, 9, 10)) - -#if (NM_MICRO_VERSION % 2) -#define NM_VERSION_CUR_STABLE (NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION - 1)) -#else -#define NM_VERSION_CUR_STABLE (NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION)) -#endif - -#if (NM_MICRO_VERSION % 2) -#define NM_VERSION_NEXT_STABLE (NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION +1)) -#else -#define NM_VERSION_NEXT_STABLE (NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION + 2)) -#endif - -#if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) -# undef NM_VERSION_MIN_REQUIRED -# define NM_VERSION_MIN_REQUIRED (NM_VERSION_CUR_STABLE) -#endif - -#if !defined (NM_VERSION_MAX_ALLOWED) || (NM_VERSION_MAX_ALLOWED == 0) -# undef NM_VERSION_MAX_ALLOWED -# define NM_VERSION_MAX_ALLOWED (NM_VERSION_CUR_STABLE) -#endif - -/* sanity checks */ -#if NM_VERSION_MIN_REQUIRED > NM_VERSION_NEXT_STABLE -#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_NEXT_STABLE" -#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 - -#endif /* NM_VERSION_H */ - |