diff options
Diffstat (limited to 'src/settings/plugins/ifcfg-rh')
36 files changed, 2449 insertions, 4198 deletions
diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am index c5e458af..4989f4ba 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/Makefile.am @@ -19,27 +19,21 @@ libifcfg_rh_io_la_SOURCES = \ reader.h \ writer.c \ writer.h \ - errors.c \ common.h \ utils.c \ utils.h AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/logging \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/src/posix-signals \ - -I$(top_srcdir)/src/config \ -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-glib \ - -I$(top_srcdir)/libnm-util \ - -I$(top_builddir)/libnm-util \ + -I$(top_srcdir)/libnm-core \ + -I$(top_builddir)/libnm-core \ + -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ - $(POLKIT_CFLAGS) \ $(NSS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -52,11 +46,7 @@ libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ nm-ifcfg-connection.h libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifcfg_rh_la_LIBADD = \ - $(top_builddir)/libnm-util/libnm-util.la \ - $(top_builddir)/libnm-glib/libnm-glib.la \ - libifcfg-rh-io.la \ - $(GLIB_LIBS) +libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = nm-ifcfg-rh.conf diff --git a/src/settings/plugins/ifcfg-rh/Makefile.in b/src/settings/plugins/ifcfg-rh/Makefile.in index 7b1a7dda..5d396273 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/Makefile.in @@ -133,18 +133,13 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)" \ "$(DESTDIR)$(dbusservicedir)" LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES) libifcfg_rh_io_la_LIBADD = -am_libifcfg_rh_io_la_OBJECTS = shvar.lo reader.lo writer.lo errors.lo \ - utils.lo +am_libifcfg_rh_io_la_OBJECTS = shvar.lo reader.lo writer.lo utils.lo libifcfg_rh_io_la_OBJECTS = $(am_libifcfg_rh_io_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -am__DEPENDENCIES_1 = -libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES = \ - $(top_builddir)/libnm-util/libnm-util.la \ - $(top_builddir)/libnm-glib/libnm-glib.la libifcfg-rh-io.la \ - $(am__DEPENDENCIES_1) +libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES = libifcfg-rh-io.la am_libnm_settings_plugin_ifcfg_rh_la_OBJECTS = plugin.lo \ nm-ifcfg-connection.lo libnm_settings_plugin_ifcfg_rh_la_OBJECTS = \ @@ -268,6 +263,8 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ +BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -391,6 +388,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@ @@ -410,6 +408,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@ @@ -436,7 +435,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@ @@ -528,27 +527,21 @@ libifcfg_rh_io_la_SOURCES = \ reader.h \ writer.c \ writer.h \ - errors.c \ common.h \ utils.c \ utils.h AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/logging \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/src/posix-signals \ - -I$(top_srcdir)/src/config \ -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-glib \ - -I$(top_srcdir)/libnm-util \ - -I$(top_builddir)/libnm-util \ + -I$(top_srcdir)/libnm-core \ + -I$(top_builddir)/libnm-core \ + -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ - $(POLKIT_CFLAGS) \ $(NSS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -561,12 +554,7 @@ libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ nm-ifcfg-connection.h libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifcfg_rh_la_LIBADD = \ - $(top_builddir)/libnm-util/libnm-util.la \ - $(top_builddir)/libnm-glib/libnm-glib.la \ - libifcfg-rh-io.la \ - $(GLIB_LIBS) - +libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = nm-ifcfg-rh.conf EXTRA_DIST = \ @@ -668,7 +656,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errors.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ifcfg-connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ diff --git a/src/settings/plugins/ifcfg-rh/common.h b/src/settings/plugins/ifcfg-rh/common.h index d9627bdd..d78f3752 100644 --- a/src/settings/plugins/ifcfg-rh/common.h +++ b/src/settings/plugins/ifcfg-rh/common.h @@ -78,9 +78,5 @@ #define KEY_DCB_PG_STRICT "DCB_PG_STRICT" #define KEY_DCB_PG_UP2TC "DCB_PG_UP2TC" -#define IFCFG_PLUGIN_ERROR (ifcfg_plugin_error_quark ()) -GQuark ifcfg_plugin_error_quark (void); - - #endif /* __COMMON_H__ */ diff --git a/src/settings/plugins/ifcfg-rh/errors.c b/src/settings/plugins/ifcfg-rh/errors.c deleted file mode 100644 index 25039104..00000000 --- a/src/settings/plugins/ifcfg-rh/errors.c +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * 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 2008 - 2009 Red Hat, Inc. - */ - -#include <glib.h> -#include "common.h" - -GQuark -ifcfg_plugin_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("ifcfg-plugin-error-quark"); - - return error_quark; -} - - diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c index 3db06f17..7596cbd5 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c @@ -18,13 +18,13 @@ * Copyright (C) 2008 - 2011 Red Hat, Inc. */ +#include "config.h" + #include <string.h> -#include <net/ethernet.h> -#include <netinet/ether.h> #include <glib/gstdio.h> -#include <NetworkManager.h> +#include <nm-dbus-interface.h> #include <nm-setting-connection.h> #include <nm-setting-wired.h> #include <nm-setting-wireless.h> @@ -119,7 +119,7 @@ nm_ifcfg_connection_new (NMConnection *source, else { char *keyfile = NULL, *routefile = NULL, *route6file = NULL; - tmp = connection_from_file (full_path, NULL, NULL, NULL, + tmp = connection_from_file (full_path, NULL, NULL, &unhandled_spec, &keyfile, &routefile, @@ -145,20 +145,16 @@ nm_ifcfg_connection_new (NMConnection *source, NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec, NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec, NULL); - if (object) { - /* Update our settings with what was read from the file */ - if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - tmp, - update_unsaved, - error)) { - /* Set the path and start monitoring */ - if (full_path) - nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (object), full_path); - } else { - g_object_unref (object); - object = NULL; - } - } + /* Update our settings with what was read from the file */ + if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), + tmp, + update_unsaved, + error)) { + /* Set the path and start monitoring */ + if (full_path) + nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (object), full_path); + } else + g_clear_object (&object); g_object_unref (tmp); g_free (unhandled_spec); @@ -271,7 +267,7 @@ commit_changes (NMSettingsConnection *connection, * it if it's really changed. */ if (priv->path) { - reread = connection_from_file (priv->path, NULL, NULL, NULL, + reread = connection_from_file (priv->path, NULL, NULL, NULL, NULL, NULL, NULL, &error, NULL); g_clear_error (&error); @@ -345,17 +341,6 @@ nm_ifcfg_connection_init (NMIfcfgConnection *connection) } static void -finalize (GObject *object) -{ - nm_connection_clear_secrets (NM_CONNECTION (object)); - - path_watch_stop (NM_IFCFG_CONNECTION (object)); - g_free (NM_IFCFG_CONNECTION_GET_PRIVATE (object)->path); - - G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->finalize (object); -} - -static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { @@ -394,6 +379,22 @@ get_property (GObject *object, guint prop_id, } static void +dispose (GObject *object) +{ + path_watch_stop (NM_IFCFG_CONNECTION (object)); + + G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + g_free (NM_IFCFG_CONNECTION_GET_PRIVATE (object)->path); + + G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->finalize (object); +} + +static void nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) { GObjectClass *object_class = G_OBJECT_CLASS (ifcfg_connection_class); @@ -404,6 +405,7 @@ nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) /* Virtual methods */ object_class->set_property = set_property; object_class->get_property = get_property; + object_class->dispose = dispose; object_class->finalize = finalize; settings_class->delete = do_delete; settings_class->commit_changes = commit_changes; @@ -411,18 +413,16 @@ nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) /* Properties */ g_object_class_install_property (object_class, PROP_UNMANAGED_SPEC, - g_param_spec_string (NM_IFCFG_CONNECTION_UNMANAGED_SPEC, - "Unmanaged spec", - "Unmanaged spec", - NULL, - G_PARAM_READWRITE)); + g_param_spec_string (NM_IFCFG_CONNECTION_UNMANAGED_SPEC, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_UNRECOGNIZED_SPEC, - g_param_spec_string (NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, - "Unrecognized spec", - "Unrecognized spec", + g_param_spec_string (NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, "", "", NULL, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); signals[IFCFG_CHANGED] = g_signal_new ("ifcfg-changed", diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h index 47422b5d..37eacaf0 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h @@ -18,12 +18,12 @@ * Copyright (C) 2008 - 2011 Red Hat, Inc. */ -#ifndef NM_IFCFG_CONNECTION_H -#define NM_IFCFG_CONNECTION_H +#ifndef __NETWORKMANAGER_IFCFG_CONNECTION_H__ +#define __NETWORKMANAGER_IFCFG_CONNECTION_H__ G_BEGIN_DECLS -#include <NetworkManager.h> +#include <nm-dbus-interface.h> #include <nm-settings-connection.h> #define NM_TYPE_IFCFG_CONNECTION (nm_ifcfg_connection_get_type ()) @@ -65,4 +65,4 @@ gboolean nm_ifcfg_connection_update (NMIfcfgConnection *self, G_END_DECLS -#endif /* NM_IFCFG_CONNECTION_H */ +#endif /* __NETWORKMANAGER_IFCFG_CONNECTION_H__ */ diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index 8a3f328c..2dced56b 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -21,12 +21,11 @@ * Copyright (C) 2007 - 2011 Red Hat, Inc. */ -#include <config.h> +#include "config.h" + #include <string.h> #include <unistd.h> #include <errno.h> -#include <net/ethernet.h> -#include <netinet/ether.h> #include <sys/types.h> #include <sys/stat.h> @@ -49,9 +48,9 @@ #include "nm-dbus-glib-types.h" #include "plugin.h" #include "nm-system-config-interface.h" -#include "nm-settings-error.h" #include "nm-config.h" #include "nm-logging.h" +#include "NetworkManagerUtils.h" #include "nm-ifcfg-connection.h" #include "nm-inotify-helper.h" @@ -143,7 +142,8 @@ _internal_new_connection (SCPluginIfcfg *self, if (local) g_propagate_error (error, local); else - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "(unknown)"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "(unknown)"); return NULL; } @@ -648,10 +648,10 @@ plugin_get_hostname (SCPluginIfcfg *plugin) hostname = svGetValue (network, "HOSTNAME", FALSE); ignore_localhost = svTrueValue (network, "NM_IGNORE_HOSTNAME_LOCALHOST", FALSE); if (ignore_localhost) { - /* Ignore a hostname of 'localhost' or 'localhost.localdomain' to preserve - * 'network' service behavior. + /* Ignore a default hostname ('localhost[6]' or 'localhost[6].localdomain[6]') + * to preserve 'network' service behavior. */ - if (hostname && (!strcmp (hostname, "localhost") || !strcmp (hostname, "localhost.localdomain"))) { + if (hostname && !nm_utils_is_specific_hostname (hostname)) { g_free (hostname); hostname = NULL; } @@ -669,12 +669,14 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) char *hostname_eol; gboolean ret; #if HAVE_SELINUX - security_context_t se_ctx_prev, se_ctx = NULL; + security_context_t se_ctx_prev = NULL, se_ctx = NULL; struct stat file_stat = { .st_mode = 0 }; + mode_t st_mode = 0; /* Get default context for HOSTNAME_FILE and set it for fscreate */ - stat (HOSTNAME_FILE, &file_stat); - matchpathcon (HOSTNAME_FILE, file_stat.st_mode, &se_ctx); + if (stat (HOSTNAME_FILE, &file_stat) == 0) + st_mode = file_stat.st_mode; + matchpathcon (HOSTNAME_FILE, st_mode, &se_ctx); matchpathcon_fini (); getfscreatecon (&se_ctx_prev); setfscreatecon (se_ctx); @@ -790,7 +792,7 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, if (!s_con) { g_set_error (error, NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INTERNAL_ERROR, + NM_SETTINGS_ERROR_FAILED, "unable to retrieve the connection setting"); return FALSE; } @@ -799,7 +801,7 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, if (!uuid) { g_set_error (error, NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INTERNAL_ERROR, + NM_SETTINGS_ERROR_FAILED, "unable to get the UUID"); return FALSE; } @@ -808,7 +810,7 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, if (!path) { g_set_error (error, NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INTERNAL_ERROR, + NM_SETTINGS_ERROR_FAILED, "unable to get the connection D-Bus path"); return FALSE; } diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 7a616707..145a0a39 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -15,10 +15,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2008 - 2013 Red Hat, Inc. + * Copyright 2008 - 2014 Red Hat, Inc. */ -#include <config.h> +#include "config.h" + #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -29,13 +30,11 @@ #include <errno.h> #include <sys/ioctl.h> #include <unistd.h> -#include <netinet/ether.h> -#include <linux/if.h> #include <glib.h> #include <glib/gi18n.h> #include <nm-connection.h> -#include <NetworkManager.h> +#include <nm-dbus-interface.h> #include <nm-setting-connection.h> #include <nm-setting-ip4-config.h> #include <nm-setting-vlan.h> @@ -50,7 +49,7 @@ #include <nm-setting-bridge-port.h> #include <nm-setting-dcb.h> #include <nm-setting-generic.h> -#include <nm-utils-private.h> +#include "nm-core-internal.h" #include <nm-utils.h> #include "nm-platform.h" @@ -149,7 +148,7 @@ make_connection_setting (const char *file, uuid = svGetValue (ifcfg, "UUID", FALSE); if (!uuid || !strlen (uuid)) { g_free (uuid); - uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName); + uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); } g_object_set (s_con, @@ -170,8 +169,14 @@ make_connection_setting (const char *file, } /* Missing ONBOOT is treated as "ONBOOT=true" by the old network service */ - g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, + g_object_set (s_con, + NM_SETTING_CONNECTION_AUTOCONNECT, svTrueValue (ifcfg, "ONBOOT", TRUE), + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, + (gint) svGetValueInt64 (ifcfg, "AUTOCONNECT_PRIORITY", 10, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT), NULL); value = svGetValue (ifcfg, "USERS", FALSE); @@ -246,292 +251,14 @@ make_connection_setting (const char *file, return NM_SETTING (s_con); } -static gboolean -read_mac_address (shvarFile *ifcfg, const char *key, int type, - GByteArray **array, GError **error) -{ - char *value = NULL; - - g_return_val_if_fail (ifcfg != NULL, FALSE); - g_return_val_if_fail (array != NULL, FALSE); - g_return_val_if_fail (*array == NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); - - value = svGetValue (ifcfg, key, FALSE); - if (!value || !strlen (value)) { - g_free (value); - return TRUE; - } - - *array = nm_utils_hwaddr_atoba (value, type); - if (!*array) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "%s: the MAC address '%s' was invalid.", key, value); - g_free (value); - return FALSE; - } - - g_free (value); - return TRUE; -} - -static void -iscsiadm_child_setup (gpointer user_data G_GNUC_UNUSED) -{ - /* We are in the child process here; set a different process group to - * ensure signal isolation between child and parent. - */ - pid_t pid = getpid (); - setpgid (pid, pid); - - /* - * We blocked signals in main(). We need to restore original signal - * mask for iscsiadm here so that it can receive signals. - */ - nm_unblock_posix_signals (NULL); -} - -static char * -match_iscsiadm_tag (const char *line, const char *tag, gboolean *skip) -{ - char *p; - - if (g_ascii_strncasecmp (line, tag, strlen (tag))) - return NULL; - - p = strchr (line, '='); - if (!p) { - PARSE_WARNING ("malformed iscsiadm record: no = in '%s'.", line); - *skip = TRUE; - return NULL; - } - - p++; /* advance past = */ - return g_strstrip (p); -} - -#define ISCSI_HWADDR_TAG "iface.hwaddress" -#define ISCSI_BOOTPROTO_TAG "iface.bootproto" -#define ISCSI_IPADDR_TAG "iface.ipaddress" -#define ISCSI_SUBNET_TAG "iface.subnet_mask" -#define ISCSI_GATEWAY_TAG "iface.gateway" -#define ISCSI_DNS1_TAG "iface.primary_dns" -#define ISCSI_DNS2_TAG "iface.secondary_dns" - -static gboolean -fill_ip4_setting_from_ibft (shvarFile *ifcfg, - NMSettingIP4Config *s_ip4, - const char *iscsiadm_path, - GError **error) -{ - const char *argv[4] = { iscsiadm_path, "-m", "fw", NULL }; - const char *envp[1] = { NULL }; - gboolean success = FALSE, in_record = FALSE, hwaddr_matched = FALSE, skip = FALSE; - char *out = NULL, *err = NULL; - gint status = 0; - GByteArray *ifcfg_mac = NULL; - char **lines = NULL, **iter; - const char *method = NULL; - guint32 ipaddr; - guint32 gateway; - guint32 dns1; - guint32 dns2; - guint32 prefix = 0; - - g_return_val_if_fail (s_ip4 != NULL, FALSE); - g_return_val_if_fail (iscsiadm_path != NULL, FALSE); - - if (!g_spawn_sync ("/", (char **) argv, (char **) envp, 0, - iscsiadm_child_setup, NULL, &out, &err, &status, error)) - return FALSE; - - if (!WIFEXITED (status)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "%s exited abnormally.", iscsiadm_path); - goto done; - } - - if (WEXITSTATUS (status) != 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "%s exited with error %d. Message: '%s'", - iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)"); - goto done; - } - - if (!read_mac_address (ifcfg, "HWADDR", ARPHRD_ETHER, &ifcfg_mac, error)) - goto done; - /* Ensure we got a MAC */ - if (!ifcfg_mac) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Missing device MAC address (no HWADDR tag present)."); - goto done; - } - - memset (&ipaddr, 0, sizeof (ipaddr)); - memset (&gateway, 0, sizeof (gateway)); - memset (&dns1, 0, sizeof (dns1)); - memset (&dns2, 0, sizeof (dns2)); - - /* Success, lets parse the output */ - lines = g_strsplit_set (out, "\n\r", -1); - for (iter = lines; iter && *iter; iter++) { - char *p; - - if (!g_ascii_strcasecmp (*iter, "# BEGIN RECORD")) { - if (in_record) { - PARSE_WARNING ("malformed iscsiadm record: already parsing record."); - skip = TRUE; - } - } else if (!g_ascii_strcasecmp (*iter, "# END RECORD")) { - if (!skip && hwaddr_matched) { - /* Record is good; fill IP4 config with its info */ - if (!method) { - PARSE_WARNING ("malformed iscsiadm record: missing BOOTPROTO."); - goto done; - } - - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, method, NULL); - - if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { - NMIP4Address *addr; - - if (!ipaddr || !prefix) { - PARSE_WARNING ("malformed iscsiadm record: BOOTPROTO=static " - "but missing IP address or prefix."); - goto done; - } - - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ipaddr); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gateway); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); - - if (dns1) - nm_setting_ip4_config_add_dns (s_ip4, dns1); - if (dns2) - nm_setting_ip4_config_add_dns (s_ip4, dns2); - - // FIXME: DNS search domains? - } - success = TRUE; - goto done; - } - skip = FALSE; - hwaddr_matched = FALSE; - memset (&ipaddr, 0, sizeof (ipaddr)); - memset (&gateway, 0, sizeof (gateway)); - memset (&dns1, 0, sizeof (dns1)); - memset (&dns2, 0, sizeof (dns2)); - prefix = 0; - method = NULL; - } - - if (skip) - continue; - - /* HWADDR */ - if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_HWADDR_TAG, &skip))) { - struct ether_addr *ibft_mac; - - ibft_mac = ether_aton (p); - if (!ibft_mac) { - PARSE_WARNING ("malformed iscsiadm record: invalid hwaddress."); - skip = TRUE; - continue; - } - - if (memcmp (ifcfg_mac->data, (guint8 *) ibft_mac->ether_addr_octet, ETH_ALEN)) { - /* This record isn't for the current device, ignore it */ - skip = TRUE; - continue; - } - - /* Success, this record is for this device */ - hwaddr_matched = TRUE; - } - - /* BOOTPROTO */ - if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_BOOTPROTO_TAG, &skip))) { - if (!g_ascii_strcasecmp (p, "dhcp")) - method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; - else if (!g_ascii_strcasecmp (p, "static")) - method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; - else { - PARSE_WARNING ("malformed iscsiadm record: unknown BOOTPROTO '%s'.", p); - skip = TRUE; - continue; - } - } - - if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_IPADDR_TAG, &skip))) { - if (inet_pton (AF_INET, p, &ipaddr) < 1) { - PARSE_WARNING ("malformed iscsiadm record: invalid IP address '%s'.", p); - skip = TRUE; - continue; - } - } - - if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_SUBNET_TAG, &skip))) { - guint32 mask; - - if (inet_pton (AF_INET, p, &mask) < 1) { - PARSE_WARNING ("malformed iscsiadm record: invalid subnet mask '%s'.", p); - skip = TRUE; - continue; - } - - prefix = nm_utils_ip4_netmask_to_prefix (mask); - } - - if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_GATEWAY_TAG, &skip))) { - if (inet_pton (AF_INET, p, &gateway) < 1) { - PARSE_WARNING ("malformed iscsiadm record: invalid IP gateway '%s'.", p); - skip = TRUE; - continue; - } - } - - if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_DNS1_TAG, &skip))) { - if (inet_pton (AF_INET, p, &dns1) < 1) { - PARSE_WARNING ("malformed iscsiadm record: invalid DNS1 address '%s'.", p); - skip = TRUE; - continue; - } - } - - if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_DNS2_TAG, &skip))) { - if (inet_pton (AF_INET, p, &dns2) < 1) { - PARSE_WARNING ("malformed iscsiadm record: invalid DNS2 address '%s'.", p); - skip = TRUE; - continue; - } - } - } - - success = TRUE; - -done: - if (ifcfg_mac) - g_byte_array_free (ifcfg_mac, TRUE); - g_strfreev (lines); - g_free (out); - g_free (err); - return success; -} - /* Returns TRUE on missing address or valid address */ static gboolean read_ip4_address (shvarFile *ifcfg, const char *tag, - guint32 *out_addr, + char **out_addr, GError **error) { char *value = NULL; - guint32 ip4_addr; - gboolean success = FALSE; g_return_val_if_fail (ifcfg != NULL, FALSE); g_return_val_if_fail (tag != NULL, FALSE); @@ -539,45 +266,21 @@ read_ip4_address (shvarFile *ifcfg, if (error) g_return_val_if_fail (*error == NULL, FALSE); - *out_addr = 0; + *out_addr = NULL; value = svGetValue (ifcfg, tag, FALSE); if (!value) return TRUE; - if (inet_pton (AF_INET, value, &ip4_addr) > 0) { - *out_addr = ip4_addr; - success = TRUE; + if (nm_utils_ipaddr_valid (AF_INET, value)) { + *out_addr = value; + return TRUE; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid %s IP4 address '%s'", tag, value); - } - g_free (value); - return success; -} - -/* Returns TRUE on valid address, including unspecified (::) */ -static gboolean -parse_ip6_address (const char *value, - struct in6_addr *out_addr, - GError **error) -{ - struct in6_addr ip6_addr; - - g_return_val_if_fail (value != NULL, FALSE); - g_return_val_if_fail (out_addr != NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); - - *out_addr = in6addr_any; - if (inet_pton (AF_INET6, value, &ip6_addr) <= 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP6 address '%s'", value); + g_free (value); return FALSE; } - - *out_addr = ip6_addr; - return TRUE; } static char * @@ -629,19 +332,23 @@ static gboolean read_full_ip4_address (shvarFile *ifcfg, const char *network_file, gint32 which, - NMIP4Address *addr, + NMIPAddress *base_addr, + NMIPAddress **out_address, + char **out_gateway, GError **error) { char *ip_tag, *prefix_tag, *netmask_tag, *gw_tag; - guint32 tmp; + char *ip = NULL; + long prefix = 0; gboolean success = FALSE; - shvarFile *network_ifcfg; char *value; + guint32 tmp; g_return_val_if_fail (which >= -1, FALSE); g_return_val_if_fail (ifcfg != NULL, FALSE); g_return_val_if_fail (network_file != NULL, FALSE); - g_return_val_if_fail (addr != NULL, FALSE); + g_return_val_if_fail (out_address != NULL, FALSE); + g_return_val_if_fail (*out_address == NULL, FALSE); if (error) g_return_val_if_fail (*error == NULL, FALSE); @@ -651,82 +358,73 @@ read_full_ip4_address (shvarFile *ifcfg, gw_tag = get_numbered_tag ("GATEWAY", which); /* IP address */ - if (!read_ip4_address (ifcfg, ip_tag, &tmp, error)) - goto done; - if (tmp) - nm_ip4_address_set_address (addr, tmp); - else if (!nm_ip4_address_get_address (addr)) { - success = TRUE; + if (!read_ip4_address (ifcfg, ip_tag, &ip, error)) goto done; + if (!ip) { + if (base_addr) + ip = g_strdup (nm_ip_address_get_address (base_addr)); + else { + success = TRUE; + goto done; + } } /* Gateway */ - if (!read_ip4_address (ifcfg, gw_tag, &tmp, error)) - goto done; - if (tmp) - nm_ip4_address_set_gateway (addr, tmp); - else { - gboolean read_success; - - /* If no gateway in the ifcfg, try /etc/sysconfig/network instead */ - network_ifcfg = svOpenFile (network_file, NULL); - if (network_ifcfg) { - read_success = read_ip4_address (network_ifcfg, "GATEWAY", &tmp, error); - svCloseFile (network_ifcfg); - if (!read_success) - goto done; - nm_ip4_address_set_gateway (addr, tmp); - } + if (out_gateway && !*out_gateway) { + if (!read_ip4_address (ifcfg, gw_tag, out_gateway, error)) + goto done; } /* Prefix */ value = svGetValue (ifcfg, prefix_tag, FALSE); if (value) { - long int prefix; - errno = 0; prefix = strtol (value, NULL, 10); - if (errno || prefix <= 0 || prefix > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + if (errno || prefix < 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP4 prefix '%s'", value); g_free (value); goto done; } - nm_ip4_address_set_prefix (addr, (guint32) prefix); g_free (value); } /* Fall back to NETMASK if no PREFIX was specified */ - if (!nm_ip4_address_get_prefix (addr)) { - if (!read_ip4_address (ifcfg, netmask_tag, &tmp, error)) + if (prefix == 0) { + if (!read_ip4_address (ifcfg, netmask_tag, &value, error)) goto done; - if (tmp) - nm_ip4_address_set_prefix (addr, nm_utils_ip4_netmask_to_prefix (tmp)); + if (value) { + inet_pton (AF_INET, value, &tmp); + prefix = nm_utils_ip4_netmask_to_prefix (tmp); + g_free (value); + } } - /* Try to autodetermine the prefix for the address' class */ - if (!nm_ip4_address_get_prefix (addr)) { - guint32 prefix = 0; + if (prefix == 0 && base_addr) + prefix = nm_ip_address_get_prefix (base_addr); - prefix = nm_utils_ip4_get_default_prefix (nm_ip4_address_get_address (addr)); - nm_ip4_address_set_prefix (addr, prefix); + /* Try to autodetermine the prefix for the address' class */ + if (prefix == 0) { + if (inet_pton (AF_INET, ip, &tmp) == 1) { + prefix = nm_utils_ip4_get_default_prefix (tmp); - value = svGetValue (ifcfg, ip_tag, FALSE); - PARSE_WARNING ("missing %s, assuming %s/%u", prefix_tag, value, prefix); - g_free (value); + PARSE_WARNING ("missing %s, assuming %s/%ld", prefix_tag, ip, prefix); + } } /* Validate the prefix */ - if (nm_ip4_address_get_prefix (addr) > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Missing or invalid IP4 prefix '%d'", - nm_ip4_address_get_prefix (addr)); + if (prefix == 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP4 prefix"); goto done; } - success = TRUE; + *out_address = nm_ip_address_new (AF_INET, ip, prefix, error); + if (*out_address) + success = TRUE; done: + g_free (ip); g_free (ip_tag); g_free (prefix_tag); g_free (netmask_tag); @@ -740,12 +438,12 @@ static gboolean read_one_ip4_route (shvarFile *ifcfg, const char *network_file, guint32 which, - NMIP4Route **out_route, + NMIPRoute **out_route, GError **error) { - NMIP4Route *route; char *ip_tag, *netmask_tag, *gw_tag, *metric_tag, *value; - guint32 tmp; + char *dest = NULL, *next_hop = NULL; + gint64 prefix, metric; gboolean success = FALSE; g_return_val_if_fail (ifcfg != NULL, FALSE); @@ -755,75 +453,72 @@ read_one_ip4_route (shvarFile *ifcfg, if (error) g_return_val_if_fail (*error == NULL, FALSE); - route = nm_ip4_route_new (); - ip_tag = g_strdup_printf ("ADDRESS%u", which); netmask_tag = g_strdup_printf ("NETMASK%u", which); gw_tag = g_strdup_printf ("GATEWAY%u", which); metric_tag = g_strdup_printf ("METRIC%u", which); /* Destination */ - if (!read_ip4_address (ifcfg, ip_tag, &tmp, error)) + if (!read_ip4_address (ifcfg, ip_tag, &dest, error)) goto out; - if (!tmp) { + if (!dest) { /* Check whether IP is missing or 0.0.0.0 */ char *val; val = svGetValue (ifcfg, ip_tag, FALSE); if (!val) { - nm_ip4_route_unref (route); - route = NULL; + *out_route = NULL; success = TRUE; /* missing route = success */ goto out; } g_free (val); } - nm_ip4_route_set_dest (route, tmp); /* Next hop */ - if (!read_ip4_address (ifcfg, gw_tag, &tmp, error)) + if (!read_ip4_address (ifcfg, gw_tag, &next_hop, error)) goto out; - /* No need to check tmp, because we don't make distinction between missing GATEWAY IP and 0.0.0.0 */ - nm_ip4_route_set_next_hop (route, tmp); + /* We don't make distinction between missing GATEWAY IP and 0.0.0.0 */ /* Prefix */ - if (!read_ip4_address (ifcfg, netmask_tag, &tmp, error)) + if (!read_ip4_address (ifcfg, netmask_tag, &value, error)) goto out; - if (tmp) - nm_ip4_route_set_prefix (route, nm_utils_ip4_netmask_to_prefix (tmp)); + if (value) { + guint32 netmask; - /* Validate the prefix */ - if ( !nm_ip4_route_get_prefix (route) - || nm_ip4_route_get_prefix (route) > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Missing or invalid IP4 prefix '%d'", - nm_ip4_route_get_prefix (route)); + inet_pton (AF_INET, value, &netmask); + prefix = nm_utils_ip4_netmask_to_prefix (netmask); + g_free (value); + if (prefix == 0 || netmask != nm_utils_ip4_prefix_to_netmask (prefix)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 netmask '%s' \"%s\"", netmask_tag, nm_utils_inet4_ntop (netmask, NULL)); + goto out; + } + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP4 route element '%s'", netmask_tag); goto out; } /* Metric */ value = svGetValue (ifcfg, metric_tag, FALSE); if (value) { - long int metric; - - errno = 0; - metric = strtol (value, NULL, 10); - if (errno || metric < 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + metric = nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1); + if (metric < 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP4 route metric '%s'", value); g_free (value); goto out; } - nm_ip4_route_set_metric (route, (guint32) metric); g_free (value); - } + } else + metric = -1; - *out_route = route; - success = TRUE; + *out_route = nm_ip_route_new (AF_INET, dest, prefix, next_hop, metric, error); + if (*out_route) + success = TRUE; out: - if (!success && route) - nm_ip4_route_unref (route); - + g_free (dest); + g_free (next_hop); g_free (ip_tag); g_free (netmask_tag); g_free (gw_tag); @@ -832,17 +527,16 @@ out: } static gboolean -read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError **error) +read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError **error) { char *contents = NULL; gsize len = 0; char **lines = NULL, **iter; GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric; GMatchInfo *match_info; - NMIP4Route *route; - guint32 ip4_addr; - char *dest = NULL, *prefix = NULL, *metric = NULL; - long int prefix_int, metric_int; + NMIPRoute *route = NULL; + char *dest = NULL, *prefix = NULL, *next_hop = NULL, *metric = NULL; + gint64 prefix_int, metric_int; gboolean success = FALSE; const char *pattern_empty = "^\\s*(\\#.*)?$"; @@ -870,9 +564,6 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError regex_via = g_regex_new (pattern_via, 0, 0, NULL); regex_metric = g_regex_new (pattern_metric, 0, 0, NULL); - /* New NMIP4Route structure */ - route = nm_ip4_route_new (); - /* Iterate through file lines */ lines = g_strsplit_set (contents, "\n\r", -1); for (iter = lines; iter && *iter; iter++) { @@ -888,22 +579,21 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError g_regex_match (regex_to2, *iter, 0, &match_info); if (!g_match_info_matches (match_info)) { g_match_info_free (match_info); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Missing IP4 route destination address in record: '%s'", *iter); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP4 route destination address in record: '%s'", *iter); goto error; } } dest = g_match_info_fetch (match_info, 1); if (!strcmp (dest, "default")) strcpy (dest, "0.0.0.0"); - if (inet_pton (AF_INET, dest, &ip4_addr) != 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP4 route destination address '%s'", dest); + if (!nm_utils_ipaddr_valid (AF_INET, dest)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route destination address '%s'", dest); g_free (dest); + g_match_info_free (match_info); goto error; } - nm_ip4_route_set_dest (route, ip4_addr); - g_free (dest); /* Prefix - is optional; 32 if missing */ prefix = g_match_info_fetch (match_info, 2); @@ -913,58 +603,62 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError errno = 0; prefix_int = strtol (prefix, NULL, 10); if (errno || prefix_int <= 0 || prefix_int > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP4 route destination prefix '%s'", prefix); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route destination prefix '%s'", prefix); + g_free (dest); g_free (prefix); goto error; } } - nm_ip4_route_set_prefix (route, (guint32) prefix_int); g_free (prefix); /* Next hop */ g_regex_match (regex_via, *iter, 0, &match_info); if (g_match_info_matches (match_info)) { - char *next_hop = g_match_info_fetch (match_info, 1); - if (inet_pton (AF_INET, next_hop, &ip4_addr) != 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + next_hop = g_match_info_fetch (match_info, 1); + if (!nm_utils_ipaddr_valid (AF_INET, next_hop)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP4 route gateway address '%s'", next_hop); g_match_info_free (match_info); + g_free (dest); g_free (next_hop); goto error; } - g_free (next_hop); } else { /* we don't make distinction between missing GATEWAY IP and 0.0.0.0 */ - ip4_addr = 0; + next_hop = NULL; } - nm_ip4_route_set_next_hop (route, ip4_addr); g_match_info_free (match_info); /* Metric */ g_regex_match (regex_metric, *iter, 0, &match_info); - metric_int = 0; + metric_int = -1; if (g_match_info_matches (match_info)) { metric = g_match_info_fetch (match_info, 1); errno = 0; metric_int = strtol (metric, NULL, 10); if (errno || metric_int < 0) { g_match_info_free (match_info); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP4 route metric '%s'", metric); + g_free (dest); + g_free (next_hop); g_free (metric); goto error; } g_free (metric); } - - nm_ip4_route_set_metric (route, (guint32) metric_int); g_match_info_free (match_info); - if (!nm_setting_ip4_config_add_route (s_ip4, route)) + route = nm_ip_route_new (AF_INET, dest, prefix_int, next_hop, metric_int, error); + if (!route) { + g_free (dest); + g_free (next_hop); + goto error; + } + if (!nm_setting_ip_config_add_route (s_ip4, route)) PARSE_WARNING ("duplicate IP4 route"); - } success = TRUE; @@ -972,7 +666,8 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError error: g_free (contents); g_strfreev (lines); - nm_ip4_route_unref (route); + if (route) + nm_ip_route_unref (route); g_regex_unref (regex_to1); g_regex_unref (regex_to2); g_regex_unref (regex_via); @@ -986,15 +681,12 @@ parse_full_ip6_address (shvarFile *ifcfg, const char *network_file, const char *addr_str, int i, - NMIP6Address **out_address, + NMIPAddress **out_address, GError **error) { - NMIP6Address *addr = NULL; char **list; char *ip_val, *prefix_val; - shvarFile *network_ifcfg; - char *value = NULL; - struct in6_addr tmp = IN6ADDR_ANY_INIT; + long prefix; gboolean success = FALSE; g_return_val_if_fail (addr_str != NULL, FALSE); @@ -1006,77 +698,33 @@ parse_full_ip6_address (shvarFile *ifcfg, /* Split the address and prefix */ list = g_strsplit_set (addr_str, "/", 2); if (g_strv_length (list) < 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP6 address '%s'", addr_str); goto error; } ip_val = list[0]; - prefix_val = list[1]; - addr = nm_ip6_address_new (); - /* IP address */ - if (!parse_ip6_address (ip_val, &tmp, error)) - goto error; - if (IN6_IS_ADDR_UNSPECIFIED (&tmp)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP6 address '%s'", ip_val); - goto error; - } - nm_ip6_address_set_address (addr, &tmp); - - /* Prefix */ + prefix_val = list[1]; if (prefix_val) { - long int prefix; - errno = 0; prefix = strtol (prefix_val, NULL, 10); if (errno || prefix <= 0 || prefix > 128) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP6 prefix '%s'", prefix_val); goto error; } - nm_ip6_address_set_prefix (addr, (guint32) prefix); } else { /* Missing prefix is treated as prefix of 64 */ - nm_ip6_address_set_prefix (addr, 64); + prefix = 64; } - /* Gateway */ - tmp = in6addr_any; - value = svGetValue (ifcfg, "IPV6_DEFAULTGW", FALSE); - if (i != 0) { - /* We don't support gateways for IPV6ADDR_SECONDARIES yet */ - g_free (value); - value = NULL; - } - if (!value) { - /* If no gateway in the ifcfg, try global /etc/sysconfig/network instead */ - network_ifcfg = svOpenFile (network_file, NULL); - if (network_ifcfg) { - value = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE); - svCloseFile (network_ifcfg); - } - } - if (value) { - char *ptr; - - if ((ptr = strchr (value, '%')) != NULL) - *ptr = '\0'; /* remove %interface prefix if present */ - if (!parse_ip6_address (value, &tmp, error)) - goto error; - nm_ip6_address_set_gateway (addr, &tmp); - } - - *out_address = addr; - success = TRUE; + *out_address = nm_ip_address_new (AF_INET6, ip_val, prefix, error); + if (*out_address) + success = TRUE; error: - if (!success && addr) - nm_ip6_address_unref (addr); - g_strfreev (list); - g_free (value); return success; } @@ -1088,17 +736,16 @@ error: #define IPV6_ADDR_REGEX "[0-9A-Fa-f:.]+" static gboolean -read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **error) +read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error) { char *contents = NULL; gsize len = 0; char **lines = NULL, **iter; GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric; GMatchInfo *match_info; - NMIP6Route *route; - struct in6_addr ip6_addr; - char *dest = NULL, *prefix = NULL, *metric = NULL; - long int prefix_int, metric_int; + NMIPRoute *route = NULL; + char *dest = NULL, *prefix = NULL, *next_hop = NULL, *metric = NULL; + gint64 prefix_int, metric_int; gboolean success = FALSE; const char *pattern_empty = "^\\s*(\\#.*)?$"; @@ -1126,9 +773,6 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro regex_via = g_regex_new (pattern_via, 0, 0, NULL); regex_metric = g_regex_new (pattern_metric, 0, 0, NULL); - /* New NMIP6Route structure */ - route = nm_ip6_route_new (); - /* Iterate through file lines */ lines = g_strsplit_set (contents, "\n\r", -1); for (iter = lines; iter && *iter; iter++) { @@ -1144,27 +788,19 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro g_regex_match (regex_to2, *iter, 0, &match_info); if (!g_match_info_matches (match_info)) { g_match_info_free (match_info); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Missing IP6 route destination address in record: '%s'", *iter); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP6 route destination address in record: '%s'", *iter); goto error; } } dest = g_match_info_fetch (match_info, 1); if (!g_strcmp0 (dest, "default")) { /* Ignore default route - NM handles it internally */ - g_free (dest); + g_clear_pointer (&dest, g_free); g_match_info_free (match_info); PARSE_WARNING ("ignoring manual default route: '%s' (%s)", *iter, filename); continue; } - if (inet_pton (AF_INET6, dest, &ip6_addr) != 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP6 route destination address '%s'", dest); - g_free (dest); - goto error; - } - nm_ip6_route_set_dest (route, &ip6_addr); - g_free (dest); /* Prefix - is optional; 128 if missing */ prefix = g_match_info_fetch (match_info, 2); @@ -1174,56 +810,60 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro errno = 0; prefix_int = strtol (prefix, NULL, 10); if (errno || prefix_int <= 0 || prefix_int > 128) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP6 route destination prefix '%s'", prefix); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 route destination prefix '%s'", prefix); + g_free (dest); g_free (prefix); goto error; } } - nm_ip6_route_set_prefix (route, (guint32) prefix_int); g_free (prefix); /* Next hop */ g_regex_match (regex_via, *iter, 0, &match_info); if (g_match_info_matches (match_info)) { - char *next_hop = g_match_info_fetch (match_info, 1); - if (inet_pton (AF_INET6, next_hop, &ip6_addr) != 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + next_hop = g_match_info_fetch (match_info, 1); + if (!nm_utils_ipaddr_valid (AF_INET6, next_hop)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IPv6 route nexthop address '%s'", next_hop); g_match_info_free (match_info); + g_free (dest); g_free (next_hop); goto error; } - g_free (next_hop); } else { /* Missing "via" is taken as :: */ - ip6_addr = in6addr_any; + next_hop = NULL; } - nm_ip6_route_set_next_hop (route, &ip6_addr); g_match_info_free (match_info); /* Metric */ g_regex_match (regex_metric, *iter, 0, &match_info); - metric_int = 0; + metric_int = -1; if (g_match_info_matches (match_info)) { metric = g_match_info_fetch (match_info, 1); errno = 0; metric_int = strtol (metric, NULL, 10); if (errno || metric_int < 0 || metric_int > G_MAXUINT32) { g_match_info_free (match_info); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP6 route metric '%s'", metric); + g_free (dest); + g_free (next_hop); g_free (metric); goto error; } g_free (metric); } - - nm_ip6_route_set_metric (route, (guint32) metric_int); g_match_info_free (match_info); - if (!nm_setting_ip6_config_add_route (s_ip6, route)) + route = nm_ip_route_new (AF_INET6, dest, prefix_int, next_hop, metric_int, error); + g_free (dest); + g_free (next_hop); + if (!route) + goto error; + if (!nm_setting_ip_config_add_route (s_ip6, route)) PARSE_WARNING ("duplicate IP6 route"); } @@ -1232,7 +872,8 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro error: g_free (contents); g_strfreev (lines); - nm_ip6_route_unref (route); + if (route) + nm_ip_route_unref (route); g_regex_unref (regex_to1); g_regex_unref (regex_to2); g_regex_unref (regex_via); @@ -1245,19 +886,19 @@ error: static NMSetting * make_ip4_setting (shvarFile *ifcfg, const char *network_file, - const char *iscsiadm_path, GError **error) { - NMSettingIP4Config *s_ip4 = NULL; + NMSettingIPConfig *s_ip4 = NULL; char *value = NULL; char *route_path = NULL; char *method; + char *gateway = NULL; gint32 i; shvarFile *network_ifcfg; shvarFile *route_ifcfg; gboolean never_default = FALSE; - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); /* First check if DEFROUTE is set for this device; DEFROUTE has the * opposite meaning from never-default. The default if DEFROUTE is not @@ -1297,32 +938,22 @@ make_ip4_setting (shvarFile *ifcfg, method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; } else if (!g_ascii_strcasecmp (value, "static")) { method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; - } else if (!g_ascii_strcasecmp (value, "ibft")) { - g_free (value); - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, never_default, NULL); - /* iSCSI Boot Firmware Table: need to read values from the iSCSI - * firmware for this device and create the IP4 setting using those. - */ - if (fill_ip4_setting_from_ibft (ifcfg, s_ip4, iscsiadm_path, error)) - return NM_SETTING (s_ip4); - g_object_unref (s_ip4); - return NULL; } else if (!g_ascii_strcasecmp (value, "autoip")) { g_free (value); g_object_set (s_ip4, - NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL, - NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, never_default, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL, + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, NULL); return NM_SETTING (s_ip4); } else if (!g_ascii_strcasecmp (value, "shared")) { g_free (value); g_object_set (s_ip4, - NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED, - NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, never_default, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED, + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, NULL); return NM_SETTING (s_ip4); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown BOOTPROTO '%s'", value); g_free (value); goto done; @@ -1330,11 +961,11 @@ make_ip4_setting (shvarFile *ifcfg, g_free (value); g_object_set (s_ip4, - NM_SETTING_IP4_CONFIG_METHOD, method, - NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, !svTrueValue (ifcfg, "PEERDNS", TRUE), - NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "PEERROUTES", TRUE), - NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, never_default, - NM_SETTING_IP4_CONFIG_MAY_FAIL, !svTrueValue (ifcfg, "IPV4_FAILURE_FATAL", FALSE), + NM_SETTING_IP_CONFIG_METHOD, method, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svTrueValue (ifcfg, "PEERDNS", TRUE), + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "PEERROUTES", TRUE), + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, + NM_SETTING_IP_CONFIG_MAY_FAIL, !svTrueValue (ifcfg, "IPV4_FAILURE_FATAL", FALSE), NULL); if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) @@ -1344,11 +975,11 @@ make_ip4_setting (shvarFile *ifcfg, if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE); if (value && strlen (value)) - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, value, NULL); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); g_free (value); g_object_set (s_ip4, - NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME, + NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svTrueValue (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), NULL); @@ -1364,16 +995,12 @@ make_ip4_setting (shvarFile *ifcfg, * the legacy 'network' service (ifup-eth). */ for (i = -1; i < 256; i++) { - NMIP4Address *addr = NULL; + NMIPAddress *addr = NULL; - addr = nm_ip4_address_new (); - if (!read_full_ip4_address (ifcfg, network_file, i, addr, error)) { - nm_ip4_address_unref (addr); + if (!read_full_ip4_address (ifcfg, network_file, i, NULL, &addr, &gateway, error)) goto done; - } - if (!nm_ip4_address_get_address (addr)) { - nm_ip4_address_unref (addr); + if (!addr) { /* The first mandatory variable is 2-indexed (IPADDR2) * Variables IPADDR, IPADDR0 and IPADDR1 are optional */ if (i > 1) @@ -1381,39 +1008,49 @@ make_ip4_setting (shvarFile *ifcfg, continue; } - if (!nm_setting_ip4_config_add_address (s_ip4, addr)) + if (!nm_setting_ip_config_add_address (s_ip4, addr)) PARSE_WARNING ("duplicate IP4 address"); - nm_ip4_address_unref (addr); + nm_ip_address_unref (addr); } + /* Gateway */ + if (!gateway) { + network_ifcfg = svOpenFile (network_file, NULL); + if (network_ifcfg) { + gboolean read_success; + + read_success = read_ip4_address (network_ifcfg, "GATEWAY", &gateway, error); + svCloseFile (network_ifcfg); + if (!read_success) + goto done; + } + } + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL); + /* DNS servers * Pick up just IPv4 addresses (IPv6 addresses are taken by make_ip6_setting()) */ for (i = 1; i <= 10; i++) { char *tag; - guint32 dns; - struct in6_addr ip6_dns; tag = g_strdup_printf ("DNS%u", i); - if (!read_ip4_address (ifcfg, tag, &dns, error)) { - gboolean valid = TRUE; - - /* Ignore IPv6 addresses */ - dns = 0; - value = svGetValue (ifcfg, tag, FALSE); - if (value) - valid = parse_ip6_address (value, &ip6_dns, NULL); - g_free (value); - - if (!valid) { + value = svGetValue (ifcfg, tag, FALSE); + if (value) { + if (nm_utils_ipaddr_valid (AF_INET, value)) { + if (!nm_setting_ip_config_add_dns (s_ip4, value)) + PARSE_WARNING ("duplicate DNS server %s", tag); + } else if (nm_utils_ipaddr_valid (AF_INET6, value)) { + /* Ignore IPv6 addresses */ + } else { + PARSE_WARNING ("invalid DNS server address %s", value); g_free (tag); + g_free (value); goto done; } - g_clear_error (error); + + g_free (value); } - if (dns && !nm_setting_ip4_config_add_dns (s_ip4, dns)) - PARSE_WARNING ("duplicate DNS server %s", tag); g_free (tag); } @@ -1427,7 +1064,7 @@ make_ip4_setting (shvarFile *ifcfg, char **item; for (item = searches; *item; item++) { if (strlen (*item)) { - if (!nm_setting_ip4_config_add_dns_search (s_ip4, *item)) + if (!nm_setting_ip_config_add_dns_search (s_ip4, *item)) PARSE_WARNING ("duplicate DNS domain '%s'", *item); } } @@ -1439,7 +1076,7 @@ make_ip4_setting (shvarFile *ifcfg, /* Static routes - route-<name> file */ route_path = utils_get_route_path (ifcfg->fileName); if (!route_path) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Could not get route file path for '%s'", ifcfg->fileName); goto done; } @@ -1450,7 +1087,7 @@ make_ip4_setting (shvarFile *ifcfg, route_ifcfg = utils_get_route_ifcfg (ifcfg->fileName, FALSE); if (route_ifcfg) { for (i = 0; i < 256; i++) { - NMIP4Route *route = NULL; + NMIPRoute *route = NULL; if (!read_one_ip4_route (route_ifcfg, network_file, i, &route, error)) { svCloseFile (route_ifcfg); @@ -1460,9 +1097,9 @@ make_ip4_setting (shvarFile *ifcfg, if (!route) break; - if (!nm_setting_ip4_config_add_route (s_ip4, route)) + if (!nm_setting_ip_config_add_route (s_ip4, route)) PARSE_WARNING ("duplicate IP4 route"); - nm_ip4_route_unref (route); + nm_ip_route_unref (route); } svCloseFile (route_ifcfg); } @@ -1472,7 +1109,7 @@ make_ip4_setting (shvarFile *ifcfg, } /* Legacy value NM used for a while but is incorrect (rh #459370) */ - if (!nm_setting_ip4_config_get_num_dns_searches (s_ip4)) { + if (!nm_setting_ip_config_get_num_dns_searches (s_ip4)) { value = svGetValue (ifcfg, "SEARCH", FALSE); if (value) { char **searches = NULL; @@ -1482,7 +1119,7 @@ make_ip4_setting (shvarFile *ifcfg, char **item; for (item = searches; *item; item++) { if (strlen (*item)) { - if (!nm_setting_ip4_config_add_dns_search (s_ip4, *item)) + if (!nm_setting_ip_config_add_dns_search (s_ip4, *item)) PARSE_WARNING ("duplicate DNS search '%s'", *item); } } @@ -1495,27 +1132,29 @@ make_ip4_setting (shvarFile *ifcfg, return NM_SETTING (s_ip4); done: + g_free (gateway); g_free (route_path); g_object_unref (s_ip4); return NULL; } static void -read_aliases (NMSettingIP4Config *s_ip4, const char *filename, const char *network_file) +read_aliases (NMSettingIPConfig *s_ip4, const char *filename, const char *network_file) { GDir *dir; char *dirname, *base; shvarFile *parsed; - NMIP4Address *base_addr; + NMIPAddress *base_addr; GError *err = NULL; g_return_if_fail (s_ip4 != NULL); g_return_if_fail (filename != NULL); - base_addr = nm_setting_ip4_config_get_address (s_ip4, 0); - if (!base_addr) + if (nm_setting_ip_config_get_num_addresses (s_ip4) == 0) return; + base_addr = nm_setting_ip_config_get_address (s_ip4, 0); + dirname = g_path_get_dirname (filename); g_return_if_fail (dirname != NULL); base = g_path_get_basename (filename); @@ -1524,7 +1163,7 @@ read_aliases (NMSettingIP4Config *s_ip4, const char *filename, const char *netwo dir = g_dir_open (dirname, 0, &err); if (dir) { const char *item; - NMIP4Address *addr; + NMIPAddress *addr; gboolean ok; while ((item = g_dir_read_name (dir))) { @@ -1573,18 +1212,19 @@ read_aliases (NMSettingIP4Config *s_ip4, const char *filename, const char *netwo continue; } - addr = nm_ip4_address_dup (base_addr); - ok = read_full_ip4_address (parsed, network_file, -1, addr, &err); + addr = NULL; + ok = read_full_ip4_address (parsed, network_file, -1, base_addr, &addr, NULL, &err); svCloseFile (parsed); if (ok) { - if (!NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, device))) + nm_ip_address_set_attribute (addr, "label", g_variant_new_string (device)); + if (!nm_setting_ip_config_add_address (s_ip4, addr)) PARSE_WARNING ("duplicate IP4 address in alias file %s", item); } else { PARSE_WARNING ("error reading IP4 address from alias file '%s': %s", full_path, err ? err->message : "no address"); g_clear_error (&err); } - nm_ip4_address_unref (addr); + nm_ip_address_unref (addr); g_free (device); g_free (full_path); @@ -1603,10 +1243,9 @@ read_aliases (NMSettingIP4Config *s_ip4, const char *filename, const char *netwo static NMSetting * make_ip6_setting (shvarFile *ifcfg, const char *network_file, - const char *iscsiadm_path, GError **error) { - NMSettingIP6Config *s_ip6 = NULL; + NMSettingIPConfig *s_ip6 = NULL; char *value = NULL; char *str_value; char *route6_path = NULL; @@ -1621,7 +1260,7 @@ make_ip6_setting (shvarFile *ifcfg, char *ip6_privacy_str; NMSettingIP6ConfigPrivacy ip6_privacy_val; - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); /* First check if IPV6_DEFROUTE is set for this device; IPV6_DEFROUTE has the * opposite meaning from never-default. The default if IPV6_DEFROUTE is not @@ -1718,11 +1357,11 @@ make_ip6_setting (shvarFile *ifcfg, g_free (ip6_privacy_str); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, method, - NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS, !svTrueValue (ifcfg, "IPV6_PEERDNS", TRUE), - NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "IPV6_PEERROUTES", TRUE), - NM_SETTING_IP6_CONFIG_NEVER_DEFAULT, never_default, - NM_SETTING_IP6_CONFIG_MAY_FAIL, !svTrueValue (ifcfg, "IPV6_FAILURE_FATAL", FALSE), + NM_SETTING_IP_CONFIG_METHOD, method, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svTrueValue (ifcfg, "IPV6_PEERDNS", TRUE), + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "IPV6_PEERROUTES", TRUE), + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, + NM_SETTING_IP_CONFIG_MAY_FAIL, !svTrueValue (ifcfg, "IPV6_FAILURE_FATAL", FALSE), NM_SETTING_IP6_CONFIG_IP6_PRIVACY, ip6_privacy_val, NULL); @@ -1735,7 +1374,7 @@ make_ip6_setting (shvarFile *ifcfg, /* METHOD_AUTO may trigger DHCPv6, so save the hostname to send to DHCP */ value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE); if (value && value[0]) - g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME, value, NULL); + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); g_free (value); } @@ -1757,26 +1396,51 @@ make_ip6_setting (shvarFile *ifcfg, list = g_strsplit_set (value, " ", 0); g_free (value); for (iter = list, i = 0; iter && *iter; iter++, i++) { - NMIP6Address *addr = NULL; + NMIPAddress *addr = NULL; if (!parse_full_ip6_address (ifcfg, network_file, *iter, i, &addr, error)) { g_strfreev (list); goto error; } - if (!nm_setting_ip6_config_add_address (s_ip6, addr)) + if (!nm_setting_ip_config_add_address (s_ip6, addr)) PARSE_WARNING ("duplicate IP6 address"); - nm_ip6_address_unref (addr); + nm_ip_address_unref (addr); } g_strfreev (list); + /* Gateway */ + if (nm_setting_ip_config_get_num_addresses (s_ip6)) { + value = svGetValue (ifcfg, "IPV6_DEFAULTGW", FALSE); + if (!value) { + /* If no gateway in the ifcfg, try global /etc/sysconfig/network instead */ + network_ifcfg = svOpenFile (network_file, NULL); + if (network_ifcfg) { + value = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE); + svCloseFile (network_ifcfg); + } + } + if (value) { + char *ptr; + if ((ptr = strchr (value, '%')) != NULL) + *ptr = '\0'; /* remove %interface prefix if present */ + if (!nm_utils_ipaddr_valid (AF_INET6, value)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 address '%s'", value); + g_free (value); + goto error; + } + + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, value, NULL); + g_free (value); + } + } + /* DNS servers * Pick up just IPv6 addresses (IPv4 addresses are taken by make_ip4_setting()) */ for (i = 1; i <= 10; i++) { char *tag; - struct in6_addr ip6_dns; - guint32 ip4_addr; tag = g_strdup_printf ("DNS%u", i); value = svGetValue (ifcfg, tag, FALSE); @@ -1785,30 +1449,28 @@ make_ip6_setting (shvarFile *ifcfg, break; /* all done */ } - ip6_dns = in6addr_any; - if (parse_ip6_address (value, &ip6_dns, NULL)) { - if (!IN6_IS_ADDR_UNSPECIFIED (&ip6_dns) && !nm_setting_ip6_config_add_dns (s_ip6, &ip6_dns)) + if (nm_utils_ipaddr_valid (AF_INET6, value)) { + if (!nm_setting_ip_config_add_dns (s_ip6, value)) PARSE_WARNING ("duplicate DNS server %s", tag); + } else if (nm_utils_ipaddr_valid (AF_INET, value)) { + /* Ignore IPv4 addresses */ } else { - /* Maybe an IPv4 address? If so ignore it */ - if (inet_pton (AF_INET, value, &ip4_addr) != 1) { - g_free (tag); - g_free (value); - PARSE_WARNING ("duplicate IP6 address"); - goto error; - } + PARSE_WARNING ("invalid DNS server address %s", value); + g_free (tag); + g_free (value); + goto error; } g_free (tag); g_free (value); } - /* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIP4Config */ + /* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIPConfig */ /* Read static routes from route6-<interface> file */ route6_path = utils_get_route6_path (ifcfg->fileName); if (!route6_path) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Could not get route6 file path for '%s'", ifcfg->fileName); goto error; } @@ -1929,7 +1591,7 @@ read_dcb_app (shvarFile *ifcfg, if (success) success = (priority >= 0 && priority <= 7); if (!success) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid %s value '%s' (expected 0 - 7)", tmp, val); } @@ -1978,7 +1640,8 @@ read_dcb_bool_array (shvarFile *ifcfg, val = g_strstrip (val); if (strlen (val) != 8) { PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "boolean array must be 8 characters"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "boolean array must be 8 characters"); goto out; } @@ -1986,7 +1649,8 @@ read_dcb_bool_array (shvarFile *ifcfg, for (i = 0; i < 8; i++) { if (val[i] != '0' && val[i] != '1') { PARSE_WARNING ("invalid %s value '%s': not all 0s and 1s", prop, val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid boolean digit"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid boolean digit"); goto out; } set_func (s_dcb, i, (val[i] == '1')); @@ -2027,7 +1691,8 @@ read_dcb_uint_array (shvarFile *ifcfg, val = g_strstrip (val); if (strlen (val) != 8) { PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "uint array must be 8 characters"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "uint array must be 8 characters"); goto out; } @@ -2040,7 +1705,8 @@ read_dcb_uint_array (shvarFile *ifcfg, else { PARSE_WARNING ("invalid %s value '%s': not 0 - 7%s", prop, val, f_allowed ? " or 'f'" : ""); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid uint digit"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid uint digit"); goto out; } } @@ -2081,14 +1747,16 @@ read_dcb_percent_array (shvarFile *ifcfg, split = g_strsplit_set (val, ",", 0); if (!split || (g_strv_length (split) != 8)) { PARSE_WARNING ("invalid %s percentage list value '%s'", prop, val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "percent array must be 8 elements"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "percent array must be 8 elements"); goto out; } for (iter = split, i = 0; iter && *iter; iter++, i++) { if (!get_int (*iter, &tmp) || tmp < 0 || tmp > 100) { PARSE_WARNING ("invalid %s percentage value '%s'", prop, *iter); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid percent element"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid percent element"); goto out; } set_func (s_dcb, i, (guint) tmp); @@ -2097,7 +1765,8 @@ read_dcb_percent_array (shvarFile *ifcfg, if (sum_pct && (sum != 100)) { PARSE_WARNING ("%s percentages do not equal 100%%", prop); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid percentage sum"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid percentage sum"); goto out; } @@ -2146,7 +1815,8 @@ make_dcb_setting (shvarFile *ifcfg, g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_FCOE_MODE, val, NULL); else { PARSE_WARNING ("invalid FCoE mode '%s'", val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid FCoE mode"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid FCoE mode"); g_free (val); g_object_unref (s_dcb); return FALSE; @@ -2297,7 +1967,7 @@ add_one_wep_key (shvarFile *ifcfg, while (*p) { if (!g_ascii_isxdigit (*p)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid hexadecimal WEP key."); goto out; } @@ -2311,7 +1981,7 @@ add_one_wep_key (shvarFile *ifcfg, while (*p) { if (!g_ascii_isprint ((int) (*p))) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid ASCII WEP key."); goto out; } @@ -2333,7 +2003,8 @@ add_one_wep_key (shvarFile *ifcfg, g_free (key); success = TRUE; } else - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid WEP key length."); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WEP key length."); out: g_free (value); @@ -2418,7 +2089,7 @@ make_wep_setting (shvarFile *ifcfg, default_key_idx--; /* convert to [0...3] */ g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, default_key_idx, NULL); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid default WEP key '%s'", value); g_free (value); goto error; @@ -2459,7 +2130,7 @@ make_wep_setting (shvarFile *ifcfg, } else if (!strcmp (lcase, "restricted")) { g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", NULL); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WEP authentication algorithm '%s'", lcase); g_free (lcase); @@ -2481,7 +2152,7 @@ make_wep_setting (shvarFile *ifcfg, auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); if (auth_alg && !strcmp (auth_alg, "shared")) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "WEP Shared Key authentication is invalid for " "unencrypted connections."); goto error; @@ -2570,7 +2241,7 @@ fill_wpa_ciphers (shvarFile *ifcfg, static char * parse_wpa_psk (shvarFile *ifcfg, const char *file, - const GByteArray *ssid, + GBytes *ssid, GError **error) { shvarFile *keys_ifcfg; @@ -2609,7 +2280,7 @@ parse_wpa_psk (shvarFile *ifcfg, /* Verify the hex PSK; 64 digits */ while (*p) { if (!g_ascii_isxdigit (*p++)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (contains non-hexadecimal characters)"); goto out; } @@ -2627,7 +2298,7 @@ parse_wpa_psk (shvarFile *ifcfg, /* Length check */ if (strlen (hashed) < 8 || strlen (hashed) > 63) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (passphrases must be between " "8 and 63 characters long (inclusive))"); g_free (hashed); @@ -2637,7 +2308,7 @@ parse_wpa_psk (shvarFile *ifcfg, } if (!hashed) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (doesn't look like a passphrase or hex key)"); goto out; } @@ -2660,7 +2331,7 @@ eap_simple_reader (const char *eap_method, value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); if (!value) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", eap_method); return FALSE; @@ -2680,7 +2351,7 @@ eap_simple_reader (const char *eap_method, } if (!value) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_PASSWORD for EAP method '%s'.", eap_method); return FALSE; @@ -2741,7 +2412,7 @@ eap_tls_reader (const char *eap_method, value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); if (!value) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", eap_method); return FALSE; @@ -2788,7 +2459,7 @@ eap_tls_reader (const char *eap_method, } if (!privkey_password) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", pk_pw_key, eap_method); @@ -2799,7 +2470,7 @@ eap_tls_reader (const char *eap_method, /* The private key itself */ privkey = svGetValue (ifcfg, pk_key, FALSE); if (!privkey) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", pk_key, eap_method); @@ -2836,7 +2507,7 @@ eap_tls_reader (const char *eap_method, || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) { client_cert = svGetValue (ifcfg, cli_cert_key, FALSE); if (!client_cert) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", cli_cert_key, eap_method); @@ -2912,7 +2583,7 @@ eap_peap_reader (const char *eap_method, else if (!strcmp (peapver, "1")) g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "1", NULL); else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_PEAP_VERSION value '%s'", peapver); goto done; @@ -2928,7 +2599,7 @@ eap_peap_reader (const char *eap_method, inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); if (!inner_auth) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); goto done; } @@ -2948,7 +2619,7 @@ eap_peap_reader (const char *eap_method, if (!eap_tls_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) goto done; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", *iter); goto done; @@ -2961,7 +2632,7 @@ eap_peap_reader (const char *eap_method, } if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No valid IEEE_8021X_INNER_AUTH_METHODS found."); goto done; } @@ -3015,7 +2686,7 @@ eap_ttls_reader (const char *eap_method, tmp = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); if (!tmp) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); goto done; } @@ -3047,7 +2718,7 @@ eap_ttls_reader (const char *eap_method, goto done; g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, (*iter + STRLEN ("eap-")), NULL); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", *iter); goto done; @@ -3115,7 +2786,7 @@ eap_fast_reader (const char *eap_method, g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, pac_prov_str, NULL); if (!pac_file && !(allow_unauth || allow_auth)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "IEEE_8021X_PAC_FILE not provided and EAP-FAST automatic PAC provisioning disabled."); goto done; } @@ -3126,7 +2797,7 @@ eap_fast_reader (const char *eap_method, inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); if (!inner_auth) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); goto done; } @@ -3142,7 +2813,7 @@ eap_fast_reader (const char *eap_method, if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) goto done; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", *iter); goto done; @@ -3155,7 +2826,7 @@ eap_fast_reader (const char *eap_method, } if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No valid IEEE_8021X_INNER_AUTH_METHODS found."); goto done; } @@ -3205,8 +2876,7 @@ read_8021x_list_value (shvarFile *ifcfg, const char *prop_name) { char *value; - char **strv, **iter; - GSList *gslist = NULL; + char **strv; g_return_if_fail (ifcfg != NULL); g_return_if_fail (ifcfg_var_name != NULL); @@ -3217,16 +2887,8 @@ read_8021x_list_value (shvarFile *ifcfg, return; strv = g_strsplit_set (value, " \t", 0); - for (iter = strv; iter && *iter; iter++) { - if (*iter[0] == '\0') - continue; - gslist = g_slist_prepend (gslist, *iter); - } - if (gslist) { - gslist = g_slist_reverse (gslist); - g_object_set (setting, prop_name, gslist, NULL); - g_slist_free (gslist); - } + if (strv && strv[0]) + g_object_set (setting, prop_name, strv, NULL); g_strfreev (strv); g_free (value); } @@ -3245,7 +2907,7 @@ fill_8021x (shvarFile *ifcfg, value = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE); if (!value) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_EAP_METHODS for key management '%s'", key_mgmt); return NULL; @@ -3266,7 +2928,7 @@ fill_8021x (shvarFile *ifcfg, char *lower = NULL; lower = g_ascii_strdown (*iter, -1); - while (eap->method && !found) { + while (eap->method) { if (strcmp (eap->method, lower)) goto next; @@ -3287,6 +2949,7 @@ fill_8021x (shvarFile *ifcfg, } nm_setting_802_1x_add_eap_method (s_8021x, lower); found = TRUE; + break; next: eap++; @@ -3298,7 +2961,7 @@ fill_8021x (shvarFile *ifcfg, } if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No valid EAP methods found in IEEE_8021X_EAP_METHODS."); goto error; } @@ -3334,7 +2997,7 @@ error: static NMSetting * make_wpa_setting (shvarFile *ifcfg, const char *file, - const GByteArray *ssid, + GBytes *ssid, gboolean adhoc, NMSetting8021x **s_8021x, GError **error) @@ -3408,7 +3071,7 @@ make_wpa_setting (shvarFile *ifcfg, } else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) { /* Adhoc mode is mutually exclusive with any 802.1x-based authentication */ if (adhoc) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", value); goto error; } @@ -3421,7 +3084,7 @@ make_wpa_setting (shvarFile *ifcfg, g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, lower, NULL); g_free (lower); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown wireless KEY_MGMT type '%s'", value); goto error; } @@ -3480,7 +3143,7 @@ make_leap_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); if (!value || !strlen (value)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing LEAP identity"); goto error; } @@ -3504,7 +3167,7 @@ error: static NMSetting * make_wireless_security_setting (shvarFile *ifcfg, const char *file, - const GByteArray *ssid, + GBytes *ssid, gboolean adhoc, NMSetting8021x **s_8021x, GError **error) @@ -3534,118 +3197,110 @@ make_wireless_security_setting (shvarFile *ifcfg, return NULL; /* unencrypted */ } +static char ** +transform_hwaddr_blacklist (const char *blacklist) +{ + char **strv, **iter; + int shift = 0; + + strv = _nm_utils_strsplit_set (blacklist, " \t", 0); + for (iter = strv; iter && *iter; iter++) { + if (shift) { + *(iter - shift) = *iter; + *iter = NULL; + } + if (!nm_utils_hwaddr_valid (*(iter - shift), ETH_ALEN)) { + PARSE_WARNING ("invalid MAC in HWADDR_BLACKLIST '%s'", *(iter - shift)); + g_free (*(iter - shift)); + *(iter - shift) = NULL; + shift++; + } + } + return strv; +} + static NMSetting * make_wireless_setting (shvarFile *ifcfg, GError **error) { NMSettingWireless *s_wireless; - GByteArray *array = NULL; - GSList *macaddr_blacklist = NULL; - char *value; + char *value = NULL; + gint64 chan = 0; s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); - if (read_mac_address (ifcfg, "HWADDR", ARPHRD_ETHER, &array, error)) { - if (array) { - g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS, array, NULL); - g_byte_array_free (array, TRUE); - } - } else { - g_object_unref (s_wireless); - return NULL; + value = svGetValue (ifcfg, "HWADDR", FALSE); + if (value) { + value = g_strstrip (value); + g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS, value, NULL); + g_free (value); } - array = NULL; - if (read_mac_address (ifcfg, "MACADDR", ARPHRD_ETHER, &array, error)) { - if (array) { - g_object_set (s_wireless, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, array, NULL); - g_byte_array_free (array, TRUE); - } - } else { - PARSE_WARNING ("%s", (*error)->message); - g_clear_error (error); + value = svGetValue (ifcfg, "MACADDR", FALSE); + if (value) { + value = g_strstrip (value); + g_object_set (s_wireless, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, value, NULL); + g_free (value); } value = svGetValue (ifcfg, "HWADDR_BLACKLIST", FALSE); if (value) { - char **list = NULL, **iter; - struct ether_addr addr; + char **strv; - list = g_strsplit_set (value, " \t", 0); - for (iter = list; iter && *iter; iter++) { - if (**iter == '\0') - continue; - if (!ether_aton_r (*iter, &addr)) { - PARSE_WARNING ("invalid MAC in HWADDR_BLACKLIST '%s'", *iter); - continue; - } - macaddr_blacklist = g_slist_prepend (macaddr_blacklist, *iter); - } - if (macaddr_blacklist) { - macaddr_blacklist = g_slist_reverse (macaddr_blacklist); - g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, macaddr_blacklist, NULL); - g_slist_free (macaddr_blacklist); - } + strv = transform_hwaddr_blacklist (value); + g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, strv, NULL); + g_strfreev (strv); g_free (value); - g_strfreev (list); } value = svGetValue (ifcfg, "ESSID", TRUE); if (value) { - gsize ssid_len = 0, value_len = strlen (value); - char *p = value, *tmp; - char buf[33]; + GBytes *bytes = NULL; + gsize ssid_len = 0; + gsize value_len = strlen (value); - ssid_len = value_len; if ( (value_len >= 2) && (value[0] == '"') && (value[value_len - 1] == '"')) { /* Strip the quotes and unescape */ - p = value + 1; + char *p = value + 1; + value[value_len - 1] = '\0'; svUnescape (p); - ssid_len = strlen (p); + bytes = g_bytes_new (p, strlen (p)); } else if ((value_len > 2) && (strncmp (value, "0x", 2) == 0)) { /* Hex representation */ if (value_len % 2) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' size (looks like hex but length not multiple of 2)", value); g_free (value); goto error; } - p = value + 2; - while (*p) { - if (!g_ascii_isxdigit (*p)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid SSID '%s' character (looks like hex SSID but '%c' isn't a hex digit)", - value, *p); - g_free (value); - goto error; - } - p++; + bytes = nm_utils_hexstr2bin (value); + if (!bytes) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid SSID '%s' (looks like hex SSID but isn't)", + value); + g_free (value); + goto error; } + } else + bytes = g_bytes_new (value, value_len); - tmp = nm_utils_hexstr2bin (value + 2, value_len - 2); - ssid_len = (value_len - 2) / 2; - memcpy (buf, tmp, ssid_len); - p = &buf[0]; - g_free (tmp); - } - + ssid_len = g_bytes_get_size (bytes); if (ssid_len > 32 || ssid_len == 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)", value, ssid_len); + g_bytes_unref (bytes); g_free (value); goto error; } - array = g_byte_array_sized_new (ssid_len); - g_byte_array_append (array, (const guint8 *) p, ssid_len); - g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, array, NULL); - g_byte_array_free (array, TRUE); + g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, bytes, NULL); + g_bytes_unref (bytes); g_free (value); } @@ -3659,11 +3314,13 @@ make_wireless_setting (shvarFile *ifcfg, if (!strcmp (lcase, "ad-hoc")) { mode = "adhoc"; + } else if (!strcmp (lcase, "ap")) { + mode = "ap"; } else if (!strcmp (lcase, "managed") || !strcmp (lcase, "auto")) { mode = "infrastructure"; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid mode '%s' (not 'Ad-Hoc', 'Managed', or 'Auto')", + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid mode '%s' (not 'Ad-Hoc', 'Ap', 'Managed', or 'Auto')", lcase); g_free (lcase); goto error; @@ -3675,39 +3332,54 @@ make_wireless_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "BSSID", FALSE); if (value) { - GByteArray *bssid; - - bssid = nm_utils_hwaddr_atoba (value, ARPHRD_ETHER); - if (!bssid) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid BSSID '%s'", value); - g_free (value); - goto error; - } - - g_object_set (s_wireless, NM_SETTING_WIRELESS_BSSID, bssid, NULL); - g_byte_array_free (bssid, TRUE); + value = g_strstrip (value); + g_object_set (s_wireless, NM_SETTING_WIRELESS_BSSID, value, NULL); g_free (value); } value = svGetValue (ifcfg, "CHANNEL", FALSE); if (value) { - long int chan; - errno = 0; - chan = strtol (value, NULL, 10); - if (errno || chan <= 0 || chan > 196) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + chan = nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0); + if (errno || (chan == 0)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid wireless channel '%s'", value); g_free (value); goto error; } g_object_set (s_wireless, NM_SETTING_WIRELESS_CHANNEL, (guint32) chan, NULL); + g_free (value); + } + + value = svGetValue (ifcfg, "BAND", FALSE); + if (value) { + if (!strcmp (value, "a")) { + if (chan && chan <= 14) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Band '%s' invalid for channel %u", value, (guint32) chan); + g_free (value); + goto error; + } + } else if (!strcmp (value, "bg")) { + if (chan && chan > 14) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Band '%s' invalid for channel %u", value, (guint32) chan); + g_free (value); + goto error; + } + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid wireless band '%s'", value); + g_free (value); + goto error; + } + g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, value, NULL); + g_free (value); + } else if (chan > 0) { if (chan > 14) g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "a", NULL); else g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "bg", NULL); - g_free (value); } value = svGetValue (ifcfg, "MTU", FALSE); @@ -3717,7 +3389,7 @@ make_wireless_setting (shvarFile *ifcfg, errno = 0; mtu = strtol (value, NULL, 10); if (errno || mtu < 0 || mtu > 50000) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid wireless MTU '%s'", value); g_free (value); goto error; @@ -3748,7 +3420,7 @@ wireless_connection_from_ifcfg (const char *file, NMSetting *con_setting = NULL; NMSetting *wireless_setting = NULL; NMSetting8021x *s_8021x = NULL; - const GByteArray *ssid; + GBytes *ssid; NMSetting *security_setting = NULL; char *printable_ssid = NULL; const char *mode; @@ -3759,7 +3431,7 @@ wireless_connection_from_ifcfg (const char *file, g_return_val_if_fail (error != NULL, NULL); g_return_val_if_fail (*error == NULL, NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Wireless */ wireless_setting = make_wireless_setting (ifcfg, error); @@ -3770,9 +3442,10 @@ wireless_connection_from_ifcfg (const char *file, nm_connection_add_setting (connection, wireless_setting); ssid = nm_setting_wireless_get_ssid (NM_SETTING_WIRELESS (wireless_setting)); - if (ssid) - printable_ssid = nm_utils_ssid_to_utf8 (ssid); - else + if (ssid) { + printable_ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), + g_bytes_get_size (ssid)); + } else printable_ssid = g_strdup_printf ("unmanaged"); mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (wireless_setting)); @@ -3798,18 +3471,13 @@ wireless_connection_from_ifcfg (const char *file, printable_ssid, NULL); g_free (printable_ssid); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; } nm_connection_add_setting (connection, con_setting); - if (!nm_connection_verify (connection, error)) { - g_object_unref (connection); - return NULL; - } - return connection; } @@ -3822,8 +3490,6 @@ make_wired_setting (shvarFile *ifcfg, NMSettingWired *s_wired; char *value = NULL; int mtu; - GByteArray *mac = NULL; - GSList *macaddr_blacklist = NULL; char *nettype; s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); @@ -3840,14 +3506,11 @@ make_wired_setting (shvarFile *ifcfg, g_free (value); } - if (read_mac_address (ifcfg, "HWADDR", ARPHRD_ETHER, &mac, error)) { - if (mac) { - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL); - g_byte_array_free (mac, TRUE); - } - } else { - g_object_unref (s_wired); - return NULL; + value = svGetValue (ifcfg, "HWADDR", FALSE); + if (value) { + value = g_strstrip (value); + g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, value, NULL); + g_free (value); } value = svGetValue (ifcfg, "SUBCHANNELS", FALSE); @@ -3874,17 +3537,8 @@ make_wired_setting (shvarFile *ifcfg, if (num_chans < 2 || num_chans > 3) { PARSE_WARNING ("invalid SUBCHANNELS '%s' (%d channels, 2 or 3 expected)", value, g_strv_length (chans)); - } else { - GPtrArray *array = g_ptr_array_sized_new (num_chans); - - g_ptr_array_add (array, chans[0]); - g_ptr_array_add (array, chans[1]); - if (num_chans == 3) - g_ptr_array_add (array, chans[2]); - - g_object_set (s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, array, NULL); - g_ptr_array_free (array, TRUE); - } + } else + g_object_set (s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, chans, NULL); g_strfreev (chans); } g_free (value); @@ -3931,39 +3585,21 @@ make_wired_setting (shvarFile *ifcfg, } g_free (value); - mac = NULL; - if (read_mac_address (ifcfg, "MACADDR", ARPHRD_ETHER, &mac, error)) { - if (mac) { - g_object_set (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, mac, NULL); - g_byte_array_free (mac, TRUE); - } - } else { - PARSE_WARNING ("%s", (*error)->message); - g_clear_error (error); + value = svGetValue (ifcfg, "MACADDR", FALSE); + if (value) { + value = g_strstrip (value); + g_object_set (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, value, NULL); + g_free (value); } value = svGetValue (ifcfg, "HWADDR_BLACKLIST", FALSE); if (value) { - char **list = NULL, **iter; - struct ether_addr addr; + char **strv; - list = g_strsplit_set (value, " \t", 0); - for (iter = list; iter && *iter; iter++) { - if (**iter == '\0') - continue; - if (!ether_aton_r (*iter, &addr)) { - PARSE_WARNING ("invalid MAC in HWADDR_BLACKLIST '%s'", *iter); - continue; - } - macaddr_blacklist = g_slist_prepend (macaddr_blacklist, *iter); - } - if (macaddr_blacklist) { - macaddr_blacklist = g_slist_reverse (macaddr_blacklist); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, macaddr_blacklist, NULL); - g_slist_free (macaddr_blacklist); - } + strv = transform_hwaddr_blacklist (value); + g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, strv, NULL); + g_strfreev (strv); g_free (value); - g_strfreev (list); } value = svGetValue (ifcfg, "KEY_MGMT", FALSE); @@ -3973,7 +3609,7 @@ make_wired_setting (shvarFile *ifcfg, if (!*s_8021x) goto error; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown wired KEY_MGMT type '%s'", value); goto error; } @@ -4001,11 +3637,11 @@ wired_connection_from_ifcfg (const char *file, g_return_val_if_fail (file != NULL, NULL); g_return_val_if_fail (ifcfg != NULL, NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); con_setting = make_connection_setting (file, ifcfg, NM_SETTING_WIRED_SETTING_NAME, NULL, NULL); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -4024,11 +3660,6 @@ wired_connection_from_ifcfg (const char *file, if (s_8021x) nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - if (!nm_connection_verify (connection, error)) { - g_object_unref (connection); - return NULL; - } - return connection; } @@ -4091,7 +3722,7 @@ parse_infiniband_p_key (shvarFile *ifcfg, g_free (ifname); if (!ret) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create InfiniBand setting."); } return ret; @@ -4105,7 +3736,6 @@ make_infiniband_setting (shvarFile *ifcfg, { NMSettingInfiniband *s_infiniband; char *value = NULL; - GByteArray *mac = NULL; int mtu; s_infiniband = NM_SETTING_INFINIBAND (nm_setting_infiniband_new ()); @@ -4122,14 +3752,11 @@ make_infiniband_setting (shvarFile *ifcfg, g_free (value); } - if (read_mac_address (ifcfg, "HWADDR", ARPHRD_INFINIBAND, &mac, error)) { - if (mac) { - g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, NULL); - g_byte_array_free (mac, TRUE); - } - } else { - g_object_unref (s_infiniband); - return NULL; + value = svGetValue (ifcfg, "HWADDR", FALSE); + if (value) { + value = g_strstrip (value); + g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, value, NULL); + g_free (value); } if (svTrueValue (ifcfg, "CONNECTED_MODE", FALSE)) @@ -4167,11 +3794,11 @@ infiniband_connection_from_ifcfg (const char *file, g_return_val_if_fail (file != NULL, NULL); g_return_val_if_fail (ifcfg != NULL, NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); con_setting = make_connection_setting (file, ifcfg, NM_SETTING_INFINIBAND_SETTING_NAME, NULL, NULL); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -4187,11 +3814,6 @@ infiniband_connection_from_ifcfg (const char *file, } nm_connection_add_setting (connection, infiniband_setting); - if (!nm_connection_verify (connection, error)) { - g_object_unref (connection); - return NULL; - } - return connection; } @@ -4232,11 +3854,10 @@ make_bond_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "DEVICE", FALSE); if (!value || !strlen (value)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); goto error; } - - g_object_set (s_bond, NM_SETTING_BOND_INTERFACE_NAME, value, NULL); g_free (value); value = svGetValue (ifcfg, "BONDING_OPTS", FALSE); @@ -4284,11 +3905,11 @@ bond_connection_from_ifcfg (const char *file, g_return_val_if_fail (file != NULL, NULL); g_return_val_if_fail (ifcfg != NULL, NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BOND_SETTING_NAME, NULL, _("Bond")); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -4312,11 +3933,6 @@ bond_connection_from_ifcfg (const char *file, if (s_8021x) nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - if (!nm_connection_verify (connection, error)) { - g_object_unref (connection); - return NULL; - } - return connection; } @@ -4338,7 +3954,8 @@ read_team_config (shvarFile *ifcfg, const char *key, GError **error) */ l = strlen (value); if (l > 20000) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "%s too long (size %zd)", key, l); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "%s too long (size %zd)", key, l); g_free (value); return NULL; } @@ -4359,11 +3976,10 @@ make_team_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "DEVICE", FALSE); if (!value || !strlen (value)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); goto error; } - - g_object_set (s_team, NM_SETTING_TEAM_INTERFACE_NAME, value, NULL); g_free (value); value = read_team_config (ifcfg, "TEAM_CONFIG", &local_err); @@ -4395,11 +4011,11 @@ team_connection_from_ifcfg (const char *file, g_return_val_if_fail (file != NULL, NULL); g_return_val_if_fail (ifcfg != NULL, NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); con_setting = make_connection_setting (file, ifcfg, NM_SETTING_TEAM_SETTING_NAME, NULL, _("Team")); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -4423,11 +4039,6 @@ team_connection_from_ifcfg (const char *file, if (s_8021x) nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - if (!nm_connection_verify (connection, error)) { - g_object_unref (connection); - return NULL; - } - return connection; } @@ -4511,27 +4122,22 @@ make_bridge_setting (shvarFile *ifcfg, guint32 u; gboolean stp = FALSE; gboolean stp_set = FALSE; - GByteArray *array = NULL; s_bridge = NM_SETTING_BRIDGE (nm_setting_bridge_new ()); value = svGetValue (ifcfg, "DEVICE", FALSE); if (!value || !strlen (value)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); goto error; } - - g_object_set (s_bridge, NM_SETTING_BRIDGE_INTERFACE_NAME, value, NULL); g_free (value); - if (read_mac_address (ifcfg, "MACADDR", ARPHRD_ETHER, &array, error)) { - if (array) { - g_object_set (s_bridge, NM_SETTING_BRIDGE_MAC_ADDRESS, array, NULL); - g_byte_array_free (array, TRUE); - } - } else { - PARSE_WARNING ("%s", (*error)->message); - g_clear_error (error); + value = svGetValue (ifcfg, "MACADDR", FALSE); + if (value) { + value = g_strstrip (value); + g_object_set (s_bridge, NM_SETTING_BRIDGE_MAC_ADDRESS, value, NULL); + g_free (value); } value = svGetValue (ifcfg, "STP", FALSE); @@ -4590,11 +4196,11 @@ bridge_connection_from_ifcfg (const char *file, g_return_val_if_fail (file != NULL, NULL); g_return_val_if_fail (ifcfg != NULL, NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BRIDGE_SETTING_NAME, NULL, _("Bridge")); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -4608,11 +4214,6 @@ bridge_connection_from_ifcfg (const char *file, } nm_connection_add_setting (connection, bridge_setting); - if (!nm_connection_verify (connection, error)) { - g_object_unref (connection); - return NULL; - } - return connection; } @@ -4757,8 +4358,6 @@ parse_prio_map_list (NMSettingVlan *s_vlan, static NMSetting * make_vlan_setting (shvarFile *ifcfg, const char *file, - char **out_master, - NMSetting8021x **s_8021x, GError **error) { NMSettingVlan *s_vlan = NULL; @@ -4775,7 +4374,8 @@ make_vlan_setting (shvarFile *ifcfg, errno = 0; vlan_id = (gint) g_ascii_strtoll (value, NULL, 10); if (vlan_id < 0 || vlan_id > 4096 || errno) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid VLAN_ID '%s'", value); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid VLAN_ID '%s'", value); g_free (value); return NULL; } @@ -4785,7 +4385,7 @@ make_vlan_setting (shvarFile *ifcfg, /* Need DEVICE if we don't have a separate VLAN_ID property */ iface_name = svGetValue (ifcfg, "DEVICE", FALSE); if (!iface_name && vlan_id < 0) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing DEVICE property; cannot determine VLAN ID."); return NULL; } @@ -4796,8 +4396,6 @@ make_vlan_setting (shvarFile *ifcfg, parent = svGetValue (ifcfg, "PHYSDEV", FALSE); if (iface_name) { - g_object_set (s_vlan, NM_SETTING_VLAN_INTERFACE_NAME, iface_name, NULL); - p = strchr (iface_name, '.'); if (p) { /* eth0.43; PHYSDEV is assumed from it if unknown */ @@ -4813,7 +4411,7 @@ make_vlan_setting (shvarFile *ifcfg, } p++; } else { - /* format like vlan43; PHYSDEV or MASTER must be set */ + /* format like vlan43; PHYSDEV must be set */ if (g_str_has_prefix (iface_name, "vlan")) p = iface_name + 4; } @@ -4824,7 +4422,7 @@ make_vlan_setting (shvarFile *ifcfg, */ vlan_id = (gint) g_ascii_strtoll (p, &end, 10); if (vlan_id < 0 || vlan_id > 4095 || end == p || *end) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to determine VLAN ID from DEVICE '%s'", iface_name); goto error; @@ -4833,14 +4431,14 @@ make_vlan_setting (shvarFile *ifcfg, } if (vlan_id < 0) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to determine VLAN ID from DEVICE or VLAN_ID."); goto error; } g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL); if (parent == NULL) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to determine VLAN parent from DEVICE or PHYSDEV"); goto error; } @@ -4863,8 +4461,6 @@ make_vlan_setting (shvarFile *ifcfg, parse_prio_map_list (s_vlan, ifcfg, "VLAN_INGRESS_PRIORITY_MAP", NM_VLAN_INGRESS_MAP); parse_prio_map_list (s_vlan, ifcfg, "VLAN_EGRESS_PRIORITY_MAP", NM_VLAN_EGRESS_MAP); - if (out_master) - *out_master = svGetValue (ifcfg, "MASTER", FALSE); return (NMSetting *) s_vlan; error: @@ -4884,38 +4480,30 @@ vlan_connection_from_ifcfg (const char *file, NMSetting *wired_setting = NULL; NMSetting *vlan_setting = NULL; NMSetting8021x *s_8021x = NULL; - char *master = NULL; g_return_val_if_fail (file != NULL, NULL); g_return_val_if_fail (ifcfg != NULL, NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); con_setting = make_connection_setting (file, ifcfg, NM_SETTING_VLAN_SETTING_NAME, NULL, "Vlan"); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Failed to create connection setting."); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); g_object_unref (connection); return NULL; } + check_if_bond_slave (ifcfg, NM_SETTING_CONNECTION (con_setting)); + check_if_team_slave (ifcfg, NM_SETTING_CONNECTION (con_setting)); nm_connection_add_setting (connection, con_setting); - vlan_setting = make_vlan_setting (ifcfg, file, &master, &s_8021x, error); + vlan_setting = make_vlan_setting (ifcfg, file, error); if (!vlan_setting) { g_object_unref (connection); return NULL; } nm_connection_add_setting (connection, vlan_setting); - /* Handle master interface or connection */ - if (master) { - g_object_set (con_setting, NM_SETTING_CONNECTION_MASTER, master, NULL); - g_object_set (con_setting, - NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_VLAN_SETTING_NAME, - NULL); - g_free (master); - } - wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); if (!wired_setting) { g_object_unref (connection); @@ -4925,10 +4513,6 @@ vlan_connection_from_ifcfg (const char *file, if (s_8021x) nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - if (!nm_connection_verify (connection, error)) { - g_object_unref (connection); - return NULL; - } return connection; } @@ -4943,7 +4527,7 @@ create_unhandled_connection (const char *filename, shvarFile *ifcfg, g_assert (out_spec != NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Get NAME, UUID, etc. We need to set a connection type (generic) and add * an empty type-specific setting as well, to make sure it passes @@ -5004,7 +4588,7 @@ uuid_from_file (const char *filename) uuid = svGetValue (ifcfg, "UUID", FALSE); if (!uuid || !strlen (uuid)) { g_free (uuid); - uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName); + uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); } svCloseFile (ifcfg); @@ -5020,7 +4604,7 @@ check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) /* If there is no IPv4 config or it doesn't contain DNS searches, * read DOMAIN and put the domains into IPv6. */ - if (!s_ip4 || nm_setting_ip4_config_get_num_dns_searches (NM_SETTING_IP4_CONFIG (s_ip4)) == 0) { + if (!s_ip4 || nm_setting_ip_config_get_num_dns_searches (NM_SETTING_IP_CONFIG (s_ip4)) == 0) { /* DNS searches */ char *value = svGetValue (ifcfg, "DOMAIN", FALSE); if (value) { @@ -5029,7 +4613,7 @@ check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) char **item; for (item = searches; *item; item++) { if (strlen (*item)) { - if (!nm_setting_ip6_config_add_dns_search (NM_SETTING_IP6_CONFIG (s_ip6), *item)) + if (!nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (s_ip6), *item)) PARSE_WARNING ("duplicate DNS domain '%s'", *item); } } @@ -5044,7 +4628,6 @@ NMConnection * connection_from_file (const char *filename, const char *network_file, /* for unit tests only */ const char *test_type, /* for unit tests only */ - const char *iscsiadm_path, /* for unit tests only */ char **out_unhandled, char **out_keyfile, char **out_routefile, @@ -5072,12 +4655,9 @@ connection_from_file (const char *filename, if (!network_file) network_file = SYSCONFDIR "/sysconfig/network"; - if (!iscsiadm_path) - iscsiadm_path = "/sbin/iscsiadm"; - ifcfg_name = utils_get_ifcfg_name (filename, TRUE); if (!ifcfg_name) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ignoring connection '%s' because it's not an ifcfg file.", filename); return NULL; } @@ -5095,6 +4675,17 @@ connection_from_file (const char *filename, goto done; } + /* iBFT is handled by the iBFT settings plugin */ + bootproto = svGetValue (parsed, "BOOTPROTO", FALSE); + if (bootproto && !g_ascii_strcasecmp (bootproto, "ibft")) { + if (out_ignore_error) + *out_ignore_error = TRUE; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ignoring iBFT configuration"); + g_free (bootproto); + goto done; + } + type = NULL; devtype = svGetValue (parsed, "DEVICETYPE", FALSE); @@ -5114,7 +4705,7 @@ connection_from_file (const char *filename, device = svGetValue (parsed, "DEVICE", FALSE); if (!device) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "File '%s' had neither TYPE nor DEVICE keys.", filename); goto done; } @@ -5122,7 +4713,7 @@ connection_from_file (const char *filename, if (!strcmp (device, "lo")) { if (out_ignore_error) *out_ignore_error = TRUE; - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ignoring loopback device config."); g_free (device); goto done; @@ -5156,7 +4747,7 @@ connection_from_file (const char *filename, if (svTrueValue (parsed, "BONDING_MASTER", FALSE) && strcasecmp (type, TYPE_BOND)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "BONDING_MASTER=yes key only allowed in TYPE=bond connections"); goto done; } @@ -5189,7 +4780,7 @@ connection_from_file (const char *filename, if (!connection) goto done; - s_ip6 = make_ip6_setting (parsed, network_file, iscsiadm_path, error); + s_ip6 = make_ip6_setting (parsed, network_file, error); if (!s_ip6) { g_object_unref (connection); connection = NULL; @@ -5197,13 +4788,13 @@ connection_from_file (const char *filename, } else nm_connection_add_setting (connection, s_ip6); - s_ip4 = make_ip4_setting (parsed, network_file, iscsiadm_path, error); + s_ip4 = make_ip4_setting (parsed, network_file, error); if (!s_ip4) { g_object_unref (connection); connection = NULL; goto done; } else { - read_aliases (NM_SETTING_IP4_CONFIG (s_ip4), filename, network_file); + read_aliases (NM_SETTING_IP_CONFIG (s_ip4), filename, network_file); nm_connection_add_setting (connection, s_ip4); } @@ -5231,25 +4822,7 @@ connection_from_file (const char *filename, if (s_dcb) nm_connection_add_setting (connection, s_dcb); - /* iSCSI / ibft connections are read-only since their settings are - * stored in NVRAM and can only be changed in BIOS. - */ - bootproto = svGetValue (parsed, "BOOTPROTO", FALSE); - if ( bootproto - && connection - && !g_ascii_strcasecmp (bootproto, "ibft")) { - NMSettingConnection *s_con; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_READ_ONLY, TRUE, NULL); - } - g_free (bootproto); - - nm_utils_normalize_connection (connection, TRUE); - - if (!nm_connection_verify (connection, error)) { + if (!nm_connection_normalize (connection, NULL, NULL, error)) { g_object_unref (connection); connection = NULL; } diff --git a/src/settings/plugins/ifcfg-rh/reader.h b/src/settings/plugins/ifcfg-rh/reader.h index 371f4504..c23e5870 100644 --- a/src/settings/plugins/ifcfg-rh/reader.h +++ b/src/settings/plugins/ifcfg-rh/reader.h @@ -29,7 +29,6 @@ NMConnection *connection_from_file (const char *filename, const char *network_file, /* for unit tests only */ const char *test_type, /* for unit tests only */ - const char *iscsiadm_path, /* for unit tests only */ char **out_unhandled, char **out_keyfile, char **out_routefile, diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 4e8e29ce..6c9769b2 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -23,6 +23,8 @@ * */ +#include "config.h" + #include <errno.h> #include <fcntl.h> #include <stdio.h> @@ -34,6 +36,11 @@ #include "shvar.h" +#include "NetworkManagerUtils.h" +#include "nm-logging.h" + +#define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg) + /* Open the file <name>, returning a shvarFile on success and NULL on failure. * Add a wrinkle to let the caller specify whether or not to create the file * (actually, return a structure anyway) if it doesn't exist. @@ -233,8 +240,7 @@ svEscape (const char *s) new[j++] = s[i]; } new[j++] = '"'; - new[j++] = '\0' -; + new[j++] = '\0'; g_assert (j == slen + mangle - newline + 3); return new; @@ -261,7 +267,8 @@ svGetValue (shvarFile *s, const char *key, gboolean verbatim) for (s->current = s->lineList; s->current; s->current = s->current->next) { line = s->current->data; if (!strncmp (keyString, line, len)) { - value = g_strdup (line + len); + /* Strip trailing spaces before unescaping to preserve spaces quoted whitespace */ + value = g_strchomp (g_strdup (line + len)); if (!verbatim) svUnescape (value); break; @@ -306,6 +313,38 @@ svTrueValue (shvarFile *s, const char *key, gboolean def) return returnValue; } +/* svGetValueInt64: + * @s: fhe file + * @key: the name of the key to read + * @base: the numeric base (usually 10). Setting to 0 means "auto". Usually you want 10. + * @min: the minimum for range-check + * @max: the maximum for range-check + * @fallback: the fallback value in any error case + * + * Reads a value @key and converts it to an integer using nm_utils_ascii_str_to_int64(). + * In case of error, @errno will be set and @fallback returned. */ +gint64 +svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback) +{ + char *tmp; + gint64 result; + int errsv; + + tmp = svGetValue (s, key, FALSE); + if (!tmp) { + errno = 0; + return fallback; + } + + result = nm_utils_ascii_str_to_int64 (tmp, base, min, max, fallback); + errsv = errno; + if (errsv != 0) + PARSE_WARNING ("Error reading '%s' value '%s' as integer (%d)", key, tmp, errsv); + + g_free (tmp); + + return result; +} /* Set the variable <key> equal to the value <value>. * If <key> does not exist, and the <current> pointer is set, append diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index 4cbf1a31..b2a2f263 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -63,6 +63,8 @@ char *svGetValue (shvarFile *s, const char *key, gboolean verbatim); */ gboolean svTrueValue (shvarFile *s, const char *key, gboolean def); +gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback); + /* Set the variable <key> equal to the value <value>. * If <key> does not exist, and the <current> pointer is set, append * the key=value pair after that line. Otherwise, prepend the pair diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am index e758776d..5a17ed9b 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.am @@ -6,20 +6,16 @@ SUBDIRS=network-scripts AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-util \ - -I$(top_builddir)/libnm-util \ - -I$(top_srcdir)/libnm-glib \ + -I$(top_srcdir)/libnm-core \ + -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/logging \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/src/posix-signals \ -I$(srcdir)/../ \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ + -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ @@ -31,15 +27,10 @@ AM_LDFLAGS = \ $(DBUS_LIBS) \ $(CODE_COVERAGE_LDFLAGS) -AM_LDADD = \ - $(top_builddir)/libnm-util/libnm-util.la \ - $(top_builddir)/libnm-glib/libnm-glib.la - noinst_PROGRAMS = test-ifcfg-rh test-ifcfg-rh-utils test_ifcfg_rh_SOURCES = \ test-ifcfg-rh.c \ - ../errors.c \ ../reader.c \ ../shvar.c \ ../utils.c \ @@ -54,19 +45,9 @@ test_ifcfg_rh_utils_SOURCES = \ ../shvar.c test_ifcfg_rh_utils_LDADD = \ - $(AM_LDADD) + $(top_builddir)/src/libNetworkManager.la TESTS = test-ifcfg-rh-utils test-ifcfg-rh -EXTRA_DIST = \ - iscsiadm-test-dhcp \ - iscsiadm-test-static \ - iscsiadm-test-bad-ipaddr \ - iscsiadm-test-bad-gateway \ - iscsiadm-test-bad-dns1 \ - iscsiadm-test-bad-dns2 \ - iscsiadm-test-bad-entry \ - iscsiadm-test-bad-record - endif diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/Makefile.in index 2018134a..f34e759d 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.in @@ -106,12 +106,11 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) -am__test_ifcfg_rh_SOURCES_DIST = test-ifcfg-rh.c ../errors.c \ - ../reader.c ../shvar.c ../utils.c ../writer.c +am__test_ifcfg_rh_SOURCES_DIST = test-ifcfg-rh.c ../reader.c \ + ../shvar.c ../utils.c ../writer.c @ENABLE_TESTS_TRUE@am_test_ifcfg_rh_OBJECTS = test-ifcfg-rh.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ errors.$(OBJEXT) reader.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ shvar.$(OBJEXT) utils.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ writer.$(OBJEXT) +@ENABLE_TESTS_TRUE@ reader.$(OBJEXT) shvar.$(OBJEXT) \ +@ENABLE_TESTS_TRUE@ utils.$(OBJEXT) writer.$(OBJEXT) test_ifcfg_rh_OBJECTS = $(am_test_ifcfg_rh_OBJECTS) @ENABLE_TESTS_TRUE@test_ifcfg_rh_DEPENDENCIES = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la @@ -125,7 +124,8 @@ am__test_ifcfg_rh_utils_SOURCES_DIST = test-ifcfg-rh-utils.c \ @ENABLE_TESTS_TRUE@ test-ifcfg-rh-utils.$(OBJEXT) \ @ENABLE_TESTS_TRUE@ utils.$(OBJEXT) shvar.$(OBJEXT) test_ifcfg_rh_utils_OBJECTS = $(am_test_ifcfg_rh_utils_OBJECTS) -@ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_DEPENDENCIES = $(AM_LDADD) +@ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_DEPENDENCIES = \ +@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -261,6 +261,8 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ +BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -384,6 +386,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@ @@ -403,6 +406,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@ @@ -429,7 +433,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@ @@ -511,20 +515,16 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@SUBDIRS = network-scripts @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(DBUS_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-util \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-util \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-glib \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/ \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/logging \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/platform \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/posix-signals \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ @ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ @@ -536,13 +536,8 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@ $(DBUS_LIBS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) -@ENABLE_TESTS_TRUE@AM_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-util/libnm-util.la \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-glib/libnm-glib.la - @ENABLE_TESTS_TRUE@test_ifcfg_rh_SOURCES = \ @ENABLE_TESTS_TRUE@ test-ifcfg-rh.c \ -@ENABLE_TESTS_TRUE@ ../errors.c \ @ENABLE_TESTS_TRUE@ ../reader.c \ @ENABLE_TESTS_TRUE@ ../shvar.c \ @ENABLE_TESTS_TRUE@ ../utils.c \ @@ -557,17 +552,7 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@ ../shvar.c @ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_LDADD = \ -@ENABLE_TESTS_TRUE@ $(AM_LDADD) - -@ENABLE_TESTS_TRUE@EXTRA_DIST = \ -@ENABLE_TESTS_TRUE@ iscsiadm-test-dhcp \ -@ENABLE_TESTS_TRUE@ iscsiadm-test-static \ -@ENABLE_TESTS_TRUE@ iscsiadm-test-bad-ipaddr \ -@ENABLE_TESTS_TRUE@ iscsiadm-test-bad-gateway \ -@ENABLE_TESTS_TRUE@ iscsiadm-test-bad-dns1 \ -@ENABLE_TESTS_TRUE@ iscsiadm-test-bad-dns2 \ -@ENABLE_TESTS_TRUE@ iscsiadm-test-bad-entry \ -@ENABLE_TESTS_TRUE@ iscsiadm-test-bad-record +@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la all: all-recursive @@ -627,7 +612,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errors.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shvar.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifcfg-rh-utils.Po@am__quote@ @@ -656,20 +640,6 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< -errors.o: ../errors.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT errors.o -MD -MP -MF $(DEPDIR)/errors.Tpo -c -o errors.o `test -f '../errors.c' || echo '$(srcdir)/'`../errors.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/errors.Tpo $(DEPDIR)/errors.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../errors.c' object='errors.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o errors.o `test -f '../errors.c' || echo '$(srcdir)/'`../errors.c - -errors.obj: ../errors.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT errors.obj -MD -MP -MF $(DEPDIR)/errors.Tpo -c -o errors.obj `if test -f '../errors.c'; then $(CYGPATH_W) '../errors.c'; else $(CYGPATH_W) '$(srcdir)/../errors.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/errors.Tpo $(DEPDIR)/errors.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../errors.c' object='errors.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o errors.obj `if test -f '../errors.c'; then $(CYGPATH_W) '../errors.c'; else $(CYGPATH_W) '$(srcdir)/../errors.c'; fi` - reader.o: ../reader.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.o -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po diff --git a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-dns1 b/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-dns1 deleted file mode 100755 index 4a6a9382..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-dns1 +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -cat << EOF -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f0 -iface.bootproto = STATIC -iface.ipaddress = 192.168.32.72 -iface.subnet_mask = 255.255.252.0 -iface.gateway = 192.168.35.254 -iface.primary_dns = 10000.500.250.1 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth0 -node.name = iqn.0.2008-11.com.blahblah:iscsi0 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -EOF - diff --git a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-dns2 b/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-dns2 deleted file mode 100755 index 9bd5839b..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-dns2 +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -cat << EOF -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f0 -iface.bootproto = STATIC -iface.ipaddress = 192.168.32.72 -iface.subnet_mask = 255.255.252.0 -iface.gateway = 192.168.35.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = blah.foo.bar.baz -iface.vlan = 0 -iface.net_ifacename = eth0 -node.name = iqn.0.2008-11.com.blahblah:iscsi0 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -EOF - diff --git a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-entry b/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-entry deleted file mode 100755 index eba0ec67..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-entry +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -cat << EOF -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f0 -iface.bootproto = STATIC -iface.ipaddress 192.168.32.72 -iface.subnet_mask = 255.255.252.0 -iface.gateway = 192.168.35.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth0 -node.name = iqn.0.2008-11.com.blahblah:iscsi0 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f1 -iface.bootproto = DHCP -iface.gateway = 10.16.52.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth1 -node.name = iqn.1.2008-11.com.blahblah:iscsi1 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -EOF - diff --git a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-gateway b/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-gateway deleted file mode 100755 index b3dc7447..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-gateway +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -cat << EOF -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f0 -iface.bootproto = STATIC -iface.ipaddress = aa.bb.cc.dd -iface.subnet_mask = 255.255.252.0 -iface.gateway = 192.168.35.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth0 -node.name = iqn.0.2008-11.com.blahblah:iscsi0 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -EOF - diff --git a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-ipaddr b/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-ipaddr deleted file mode 100755 index 92f44777..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-ipaddr +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -cat << EOF -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f0 -iface.bootproto = STATIC -iface.ipaddress = 192.168.32.72 -iface.subnet_mask = 255.255.252.0 -iface.gateway = bb.cc.dd.ee -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth0 -node.name = iqn.0.2008-11.com.blahblah:iscsi0 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -EOF - diff --git a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-record b/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-record deleted file mode 100755 index a2d215fe..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-bad-record +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -cat << EOF -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f0 -iface.bootproto = DHCP -iface.gateway = 10.16.52.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth0 -node.name = iqn.0.2008-11.com.blahblah:iscsi0 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -EOF - diff --git a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-dhcp b/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-dhcp deleted file mode 100755 index 6de0637c..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-dhcp +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -cat << EOF -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f0 -iface.bootproto = DHCP -iface.gateway = 10.16.52.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth0 -node.name = iqn.0.2008-11.com.blahblah:iscsi0 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f1 -iface.bootproto = DHCP -iface.gateway = 10.16.52.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth1 -node.name = iqn.1.2008-11.com.blahblah:iscsi1 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -EOF - diff --git a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-static b/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-static deleted file mode 100755 index 99a6e7c1..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/iscsiadm-test-static +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -cat << EOF -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f0 -iface.bootproto = STATIC -iface.ipaddress = 192.168.32.72 -iface.subnet_mask = 255.255.252.0 -iface.gateway = 192.168.35.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth0 -node.name = iqn.0.2008-11.com.blahblah:iscsi0 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -# BEGIN RECORD -iface.initiatorname = iqn.pjones6 -iface.hwaddress = 00:33:21:98:b9:f1 -iface.bootproto = DHCP -iface.gateway = 10.16.52.254 -iface.primary_dns = 10.16.255.2 -iface.secondary_dns = 10.16.255.3 -iface.vlan = 0 -iface.net_ifacename = eth1 -node.name = iqn.1.2008-11.com.blahblah:iscsi1 -node.conn[0].address = 10.16.52.16 -node.conn[0].port = 3260 -node.boot_lun = 00000000 -# END RECORD -EOF - diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am index 1701aeeb..8941da3a 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -1,5 +1,6 @@ EXTRA_DIST = \ ifcfg-test-minimal \ + ifcfg-test-misc-variables \ ifcfg-test-variables-corner-cases-1 \ ifcfg-test-nm-controlled \ ifcfg-test-nm-controlled-unrecognized \ @@ -59,10 +60,12 @@ EXTRA_DIST = \ ifcfg-test-wifi-wpa-eap-ttls-tls \ keys-test-wifi-wpa-eap-ttls-tls \ ifcfg-test-wifi-hidden \ + ifcfg-test-wifi-band-a \ + ifcfg-test-wifi-band-a-channel-mismatch \ + ifcfg-test-wifi-band-bg-channel-mismatch \ test_ca_cert.pem \ test1_key_and_cert.pem \ - ifcfg-test-ibft-dhcp \ - ifcfg-test-ibft-static \ + ifcfg-test-ibft \ ifcfg-test-static-routes-legacy \ route-test-static-routes-legacy \ ifcfg-test-wired-static-routes \ @@ -116,7 +119,8 @@ EXTRA_DIST = \ ifcfg-test-fcoe-vn2vn \ ifcfg-test-team-master \ ifcfg-test-team-port \ - ifcfg-test-team-port-empty-config + ifcfg-test-team-port-empty-config \ + ifcfg-test-vlan-trailing-spaces # make target dependencies can't have colons in their names, which ends up # meaning that we can't add the alias files to EXTRA_DIST diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in index eff763e8..aac646f8 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in @@ -129,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@ @@ -252,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@ @@ -271,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@ @@ -297,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@ @@ -378,6 +382,7 @@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ EXTRA_DIST = \ ifcfg-test-minimal \ + ifcfg-test-misc-variables \ ifcfg-test-variables-corner-cases-1 \ ifcfg-test-nm-controlled \ ifcfg-test-nm-controlled-unrecognized \ @@ -437,10 +442,12 @@ EXTRA_DIST = \ ifcfg-test-wifi-wpa-eap-ttls-tls \ keys-test-wifi-wpa-eap-ttls-tls \ ifcfg-test-wifi-hidden \ + ifcfg-test-wifi-band-a \ + ifcfg-test-wifi-band-a-channel-mismatch \ + ifcfg-test-wifi-band-bg-channel-mismatch \ test_ca_cert.pem \ test1_key_and_cert.pem \ - ifcfg-test-ibft-dhcp \ - ifcfg-test-ibft-static \ + ifcfg-test-ibft \ ifcfg-test-static-routes-legacy \ route-test-static-routes-legacy \ ifcfg-test-wired-static-routes \ @@ -494,7 +501,8 @@ EXTRA_DIST = \ ifcfg-test-fcoe-vn2vn \ ifcfg-test-team-master \ ifcfg-test-team-port \ - ifcfg-test-team-port-empty-config + ifcfg-test-team-port-empty-config \ + ifcfg-test-vlan-trailing-spaces # make target dependencies can't have colons in their names, which ends up diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft new file mode 100644 index 00000000..d3e4edca --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft @@ -0,0 +1,10 @@ +# Generated by dracut initrd +DEVICE="ibft0" +ONBOOT=yes +NETBOOT=yes +UUID="2aa8c19d-9744-4ca4-b74f-c37e73f2918e" +BOOTPROTO=ibft +HWADDR="00:33:21:98:b9:f0" +TYPE=Ethernet +NAME="ibft0" + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft-dhcp b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft-dhcp deleted file mode 100644 index abfcd6e4..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft-dhcp +++ /dev/null @@ -1,4 +0,0 @@ -# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) -DEVICE=eth0 -HWADDR=00:33:21:98:b9:f1 -BOOTPROTO=ibft diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft-static b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft-static deleted file mode 100644 index 99b02e42..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft-static +++ /dev/null @@ -1,4 +0,0 @@ -# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) -DEVICE=eth0 -HWADDR=00:33:21:98:b9:f0 -BOOTPROTO=ibft diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables new file mode 100644 index 00000000..c7892a21 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables @@ -0,0 +1,3 @@ +DEVICE=eth0 +HWADDR_BLACKLIST="00:16:41:11:22:88 00:16:41:11:22:99 XX:aa:invalid 6A:5D:5A:FA:DD:F0" + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-trailing-spaces b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-trailing-spaces new file mode 100644 index 00000000..4a31e475 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-trailing-spaces @@ -0,0 +1,11 @@ +DEVICE="vlan201" +ONBOOT=yes +NETBOOT=yes +BOOTPROTO=none +IPADDR="10.130.70.7" +NETMASK="255.255.0.0" +TYPE=Vlan +NAME="vlan201" +VLAN=yes +PHYSDEV="enccw0.0.fb00" + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-a b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-a new file mode 100644 index 00000000..43286111 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-a @@ -0,0 +1,13 @@ +TYPE=Wireless +DEVICE=eth2 +HWADDR=00:16:41:11:22:33 +NM_CONTROLLED=yes +BOOTPROTO=dhcp +ESSID=blahblah +BAND=a +MODE=Managed +RATE=auto +ONBOOT=yes +USERCTL=yes +PEERDNS=yes +IPV6INIT=no diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-a-channel-mismatch b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-a-channel-mismatch new file mode 100644 index 00000000..8905ba0b --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-a-channel-mismatch @@ -0,0 +1,9 @@ +TYPE=Wireless +DEVICE=eth2 +HWADDR=00:16:41:11:22:33 +BOOTPROTO=dhcp +ESSID=blahblah +CHANNEL=9 +BAND=a +MODE=Managed + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-bg-channel-mismatch b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-bg-channel-mismatch new file mode 100644 index 00000000..e02e21ad --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-band-bg-channel-mismatch @@ -0,0 +1,9 @@ +TYPE=Wireless +DEVICE=eth2 +HWADDR=00:16:41:11:22:33 +BOOTPROTO=dhcp +ESSID=blahblah +CHANNEL=183 +BAND=bg +MODE=Managed + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open index d4bb8f75..48db45b2 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open @@ -3,6 +3,7 @@ DEVICE=eth2 HWADDR=00:16:41:11:22:33 NM_CONTROLLED=yes BOOTPROTO=dhcp +AUTOCONNECT_PRIORITY=-1 ESSID=blahblah CHANNEL=1 MODE=Managed diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c index 39c81027..d82a3270 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c @@ -18,6 +18,8 @@ * Copyright (C) 2008 - 2011 Red Hat, Inc. */ +#include "config.h" + #include <stdio.h> #include <stdarg.h> #include <unistd.h> diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index c1b14f12..4a6940d0 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -18,12 +18,12 @@ * Copyright (C) 2008 - 2011 Red Hat, Inc. */ +#include "config.h" + #include <stdio.h> #include <stdarg.h> #include <unistd.h> #include <string.h> -#include <netinet/ether.h> -#include <linux/if_infiniband.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/socket.h> @@ -46,7 +46,7 @@ #include <nm-setting-serial.h> #include <nm-setting-vlan.h> #include <nm-setting-dcb.h> -#include <nm-utils-private.h> +#include "nm-core-internal.h" #include "NetworkManagerUtils.h" @@ -185,17 +185,17 @@ test_read_basic (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; GError *error = NULL; - const GByteArray *array; + const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 }; const char *expected_id = "System test-minimal"; guint64 expected_timestamp = 0; gboolean success; connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-minimal", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -220,22 +220,71 @@ test_read_basic (void) g_assert_cmpint (nm_setting_wired_get_mtu (s_wired), ==, 0); /* MAC address */ - array = nm_setting_wired_get_mac_address (s_wired); - g_assert (array); - g_assert_cmpint (array->len, ==, ETH_ALEN); - g_assert (memcmp (array->data, &expected_mac_address[0], ETH_ALEN) == 0); + mac = nm_setting_wired_get_mac_address (s_wired); + g_assert (mac); + g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, ETH_ALEN)); /* ===== IPv4 SETTING ===== */ s_ip4 = nm_connection_get_setting_ip4_config (connection); g_assert (s_ip4); - g_assert_cmpstr (nm_setting_ip4_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); - g_assert (nm_setting_ip4_config_get_never_default (s_ip4) == FALSE); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); + g_assert (nm_setting_ip_config_get_never_default (s_ip4) == FALSE); /* ===== IPv6 SETTING ===== */ s_ip6 = nm_connection_get_setting_ip6_config (connection); g_assert (s_ip6); - g_assert_cmpstr (nm_setting_ip6_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); - g_assert (nm_setting_ip6_config_get_never_default (s_ip6) == FALSE); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); + g_assert (nm_setting_ip_config_get_never_default (s_ip6) == FALSE); + + g_object_unref (connection); +} + +static void +test_read_miscellaneous_variables (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + GError *error = NULL; + char *expected_mac_blacklist[3] = { "00:16:41:11:22:88", "00:16:41:11:22:99", "6a:5d:5a:fa:dd:f0" }; + int mac_blacklist_num, i; + guint64 expected_timestamp = 0; + gboolean success; + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + "*invalid MAC in HWADDR_BLACKLIST 'XX:aa:invalid'*"); + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-misc-variables", + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); + g_test_assert_expected_messages (); + g_assert_no_error (error); + g_assert (connection); + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* ===== CONNECTION SETTING ===== */ + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, expected_timestamp); + g_assert (nm_setting_connection_get_autoconnect (s_con)); + + /* ===== WIRED SETTING ===== */ + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + g_assert_cmpint (nm_setting_wired_get_mtu (s_wired), ==, 0); + + /* MAC blacklist */ + mac_blacklist_num = nm_setting_wired_get_num_mac_blacklist_items (s_wired); + g_assert_cmpint (mac_blacklist_num, ==, 3); + for (i = 0; i < mac_blacklist_num; i++) + g_assert (nm_utils_hwaddr_matches (nm_setting_wired_get_mac_blacklist_item (s_wired, i), -1, expected_mac_blacklist[i], -1)); + + /* ===== IPv4 SETTING ===== */ + s_ip4 = nm_connection_get_setting_ip4_config (connection); + g_assert (s_ip4); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); + g_assert (nm_setting_ip_config_get_never_default (s_ip4) == FALSE); g_object_unref (connection); } @@ -246,9 +295,9 @@ test_read_variables_corner_cases (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; GError *error = NULL; - const GByteArray *array; + const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 }; const char *expected_zone = "'"; const char *expected_id = "\""; @@ -256,7 +305,7 @@ test_read_variables_corner_cases (void) gboolean success; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-variables-corner-cases-1", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -277,16 +326,15 @@ test_read_variables_corner_cases (void) g_assert_cmpint (nm_setting_wired_get_mtu (s_wired), ==, 0); /* MAC address */ - array = nm_setting_wired_get_mac_address (s_wired); - g_assert (array); - g_assert_cmpint (array->len, ==, ETH_ALEN); - g_assert (memcmp (array->data, &expected_mac_address[0], ETH_ALEN) == 0); + mac = nm_setting_wired_get_mac_address (s_wired); + g_assert (mac); + g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, ETH_ALEN)); /* ===== IPv4 SETTING ===== */ s_ip4 = nm_connection_get_setting_ip4_config (connection); g_assert (s_ip4); - g_assert_cmpstr (nm_setting_ip4_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); - g_assert (nm_setting_ip4_config_get_never_default (s_ip4) == FALSE); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); + g_assert (nm_setting_ip_config_get_never_default (s_ip4) == FALSE); g_object_unref (connection); } @@ -303,7 +351,7 @@ test_read_unmanaged (void) gboolean success; connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-nm-controlled", - NULL, TYPE_ETHERNET, NULL, + NULL, TYPE_ETHERNET, &unhandled_spec, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); @@ -336,7 +384,7 @@ test_read_unmanaged_unrecognized (void) gboolean success; connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-nm-controlled-unrecognized", - NULL, NULL, NULL, + NULL, NULL, &unhandled_spec, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); @@ -367,7 +415,7 @@ test_read_unrecognized (void) gboolean success; connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-unrecognized", - NULL, NULL, NULL, + NULL, NULL, &unhandled_spec, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); @@ -394,27 +442,17 @@ test_read_wired_static (const char *file, NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *unmanaged = NULL; GError *error = NULL; - const GByteArray *array; + const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0xee }; - const char *expected_dns1 = "4.2.2.1"; - const char *expected_dns2 = "4.2.2.2"; - guint32 addr; - struct in6_addr addr6; - const char *expected_address1 = "192.168.1.5"; - const char *expected_address1_gw = "192.168.1.1"; - const char *expected6_address1 = "dead:beaf::1"; - const char *expected6_address2 = "dead:beaf::2"; - const char *expected6_dns1 = "1:2:3:4::a"; - const char *expected6_dns2 = "1:2:3:4::b"; - NMIP4Address *ip4_addr; - NMIP6Address *ip6_addr; + NMIPAddress *ip4_addr; + NMIPAddress *ip6_addr; gboolean success; - connection = connection_from_file (file, NULL, TYPE_ETHERNET, NULL, + connection = connection_from_file (file, NULL, TYPE_ETHERNET, &unmanaged, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); @@ -436,64 +474,57 @@ test_read_wired_static (const char *file, g_assert_cmpint (nm_setting_wired_get_mtu (s_wired), ==, 1492); /* MAC address */ - array = nm_setting_wired_get_mac_address (s_wired); - g_assert (array); - g_assert_cmpint (array->len, ==, ETH_ALEN); - g_assert (memcmp (array->data, &expected_mac_address[0], ETH_ALEN) == 0); + mac = nm_setting_wired_get_mac_address (s_wired); + g_assert (mac); + g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, ETH_ALEN)); /* ===== IPv4 SETTING ===== */ s_ip4 = nm_connection_get_setting_ip4_config (connection); g_assert (s_ip4); - g_assert_cmpstr (nm_setting_ip4_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); - g_assert (nm_setting_ip4_config_get_may_fail (s_ip4)); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); + g_assert (nm_setting_ip_config_get_may_fail (s_ip4)); /* DNS Addresses */ - g_assert_cmpint (nm_setting_ip4_config_get_num_dns (s_ip4), ==, 2); - g_assert_cmpint (inet_pton (AF_INET, expected_dns1, &addr), >, 0); - g_assert_cmpint (nm_setting_ip4_config_get_dns (s_ip4, 0), ==, addr); - g_assert_cmpint (inet_pton (AF_INET, expected_dns2, &addr), >, 0); - g_assert_cmpint (nm_setting_ip4_config_get_dns (s_ip4, 1), ==, addr); + g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 2); + g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 0), ==, "4.2.2.1"); + g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 1), ==, "4.2.2.2"); /* IP addresses */ - g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 1); - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 1); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); g_assert (ip4_addr); - g_assert_cmpint (nm_ip4_address_get_prefix (ip4_addr), ==, 24); - g_assert_cmpint (inet_pton (AF_INET, expected_address1, &addr), >, 0); - g_assert_cmpint (nm_ip4_address_get_address (ip4_addr), ==, addr); - g_assert_cmpint (inet_pton (AF_INET, expected_address1_gw, &addr), >, 0); - g_assert_cmpint (nm_ip4_address_get_gateway (ip4_addr), ==, addr); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "192.168.1.5"); + + /* Gateway */ + g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "192.168.1.1"); /* ===== IPv6 SETTING ===== */ s_ip6 = nm_connection_get_setting_ip6_config (connection); g_assert (s_ip6); if (expect_ip6) { - g_assert_cmpstr (nm_setting_ip6_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_MANUAL); - g_assert (nm_setting_ip6_config_get_may_fail (s_ip6)); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_MANUAL); + g_assert (nm_setting_ip_config_get_may_fail (s_ip6)); /* DNS Addresses */ - g_assert_cmpint (nm_setting_ip6_config_get_num_dns (s_ip6), ==, 2); - g_assert_cmpint (inet_pton (AF_INET6, expected6_dns1, &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 0), &addr6)); - g_assert_cmpint (inet_pton (AF_INET6, expected6_dns2, &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 1), &addr6)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 2); + g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip6, 0), ==, "1:2:3:4::a"); + g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip6, 1), ==, "1:2:3:4::b"); /* IP addresses */ - g_assert_cmpint (nm_setting_ip6_config_get_num_addresses (s_ip6), ==, 2); + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip6), ==, 2); - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 0); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 0); g_assert (ip6_addr); - g_assert_cmpint (nm_ip6_address_get_prefix (ip6_addr), ==, 64); - g_assert_cmpint (inet_pton (AF_INET6, expected6_address1, &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr6)); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 64); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "dead:beaf::1"); - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 1); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 1); g_assert (ip6_addr); - g_assert_cmpint (nm_ip6_address_get_prefix (ip6_addr), ==, 56); - g_assert_cmpint (inet_pton (AF_INET6, expected6_address2, &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr6)); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 56); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "dead:beaf::2"); } else { - g_assert_cmpstr (nm_setting_ip6_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); } g_free (unmanaged); @@ -506,9 +537,9 @@ test_read_wired_static_no_prefix (gconstpointer user_data) guint32 expected_prefix = GPOINTER_TO_UINT (user_data); NMConnection *connection; NMSettingConnection *s_con; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; GError *error = NULL; - NMIP4Address *ip4_addr; + NMIPAddress *ip4_addr; char *file, *expected_id; file = g_strdup_printf (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wired-static-no-prefix-%u", expected_prefix); @@ -516,7 +547,7 @@ test_read_wired_static_no_prefix (gconstpointer user_data) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*missing PREFIX, assuming*"); - connection = connection_from_file (file, NULL, TYPE_ETHERNET, NULL, NULL, + connection = connection_from_file (file, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); g_assert_no_error (error); @@ -531,12 +562,12 @@ test_read_wired_static_no_prefix (gconstpointer user_data) /* ===== IPv4 SETTING ===== */ s_ip4 = nm_connection_get_setting_ip4_config (connection); g_assert (s_ip4); - g_assert_cmpstr (nm_setting_ip4_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); - g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 1); - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 1); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); g_assert (ip4_addr); - g_assert_cmpint (nm_ip4_address_get_prefix (ip4_addr), ==, expected_prefix); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, expected_prefix); g_free (file); g_free (expected_id); @@ -551,26 +582,22 @@ test_read_wired_dhcp (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; GError *error = NULL; - const GByteArray *array; + const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0xee }; const char *tmp; const char *expected_id = "System test-wired-dhcp"; - const char *expected_dns1 = "4.2.2.1"; - const char *expected_dns2 = "4.2.2.2"; - guint32 addr; const char *expected_dhcp_hostname = "foobar"; connection = connection_from_file (TEST_IFCFG_WIRED_DHCP, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -630,18 +657,13 @@ test_read_wired_dhcp (void) NM_SETTING_WIRED_SETTING_NAME); /* MAC address */ - array = nm_setting_wired_get_mac_address (s_wired); - ASSERT (array != NULL, + mac = nm_setting_wired_get_mac_address (s_wired); + ASSERT (mac != NULL, "wired-dhcp-verify-wired", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIRED_DHCP, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS); - ASSERT (array->len == ETH_ALEN, - "wired-dhcp-verify-wired", "failed to verify %s: unexpected %s / %s key value length", - TEST_IFCFG_WIRED_DHCP, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MAC_ADDRESS); - ASSERT (memcmp (array->data, &expected_mac_address[0], sizeof (expected_mac_address)) == 0, + ASSERT (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, sizeof (expected_mac_address)), "wired-dhcp-verify-wired", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DHCP, NM_SETTING_WIRED_SETTING_NAME, @@ -656,59 +678,49 @@ test_read_wired_dhcp (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wired-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DHCP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - tmp = nm_setting_ip4_config_get_dhcp_hostname (s_ip4); + tmp = nm_setting_ip_config_get_dhcp_hostname (s_ip4); ASSERT (tmp != NULL, "wired-dhcp-verify-ip4", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIRED_DHCP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME); + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME); ASSERT (strcmp (tmp, expected_dhcp_hostname) == 0, "wired-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DHCP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME); + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME); - ASSERT (nm_setting_ip4_config_get_ignore_auto_dns (s_ip4) == TRUE, + ASSERT (nm_setting_ip_config_get_ignore_auto_dns (s_ip4) == TRUE, "wired-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DHCP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS); + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS); /* DNS Addresses */ - ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 2, + ASSERT (nm_setting_ip_config_get_num_dns (s_ip4) == 2, "wired-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DHCP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET, expected_dns1, &addr) > 0, - "wired-dhcp-verify-ip4", "failed to verify %s: couldn't convert DNS IP address #1", - TEST_IFCFG_WIRED_DHCP, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr, + ASSERT (strcmp (nm_setting_ip_config_get_dns (s_ip4, 0), "4.2.2.1") == 0, "wired-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1", TEST_IFCFG_WIRED_DHCP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET, expected_dns2, &addr) > 0, - "wired-dhcp-verify-ip4", "failed to verify %s: couldn't convert DNS IP address #2", - TEST_IFCFG_WIRED_DHCP, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr, + ASSERT (strcmp (nm_setting_ip_config_get_dns (s_ip4, 1), "4.2.2.2") == 0, "wired-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2", TEST_IFCFG_WIRED_DHCP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); g_free (unmanaged); g_free (keyfile); @@ -721,17 +733,15 @@ static void test_read_wired_dhcp_plus_ip (void) { NMConnection *connection; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; GError *error = NULL; - guint32 addr4; - struct in6_addr addr6; - NMIP4Address *ip4_addr; - NMIP6Address *ip6_addr; + NMIPAddress *ip4_addr; + NMIPAddress *ip6_addr; gboolean success; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-plus-ip", - NULL, TYPE_ETHERNET, NULL, NULL, + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); @@ -742,321 +752,132 @@ test_read_wired_dhcp_plus_ip (void) /* ===== IPv4 SETTING ===== */ s_ip4 = nm_connection_get_setting_ip4_config (connection); g_assert (s_ip4); - g_assert_cmpstr (nm_setting_ip4_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - g_assert (nm_setting_ip4_config_get_may_fail (s_ip4)); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); + g_assert (nm_setting_ip_config_get_may_fail (s_ip4)); /* DNS Addresses */ - g_assert_cmpint (nm_setting_ip4_config_get_num_dns (s_ip4), ==, 2); - g_assert_cmpint (inet_pton (AF_INET, "4.2.2.1", &addr4), >, 0); - g_assert_cmpint (nm_setting_ip4_config_get_dns (s_ip4, 0), ==, addr4); - g_assert_cmpint (inet_pton (AF_INET, "4.2.2.2", &addr4), >, 0); - g_assert_cmpint (nm_setting_ip4_config_get_dns (s_ip4, 1), ==, addr4); + g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 2); + g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 0), ==, "4.2.2.1"); + g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 1), ==, "4.2.2.2"); /* IP addresses */ - g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 2); - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 2); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); g_assert (ip4_addr); - g_assert_cmpint (nm_ip4_address_get_prefix (ip4_addr), ==, 24); - g_assert_cmpint (inet_pton (AF_INET, "1.2.3.4", &addr4), >, 0); - g_assert_cmpint (nm_ip4_address_get_address (ip4_addr), ==, addr4); - g_assert_cmpint (inet_pton (AF_INET, "1.1.1.1", &addr4), >, 0); - g_assert_cmpint (nm_ip4_address_get_gateway (ip4_addr), ==, addr4); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "1.2.3.4"); + + /* Gateway */ + g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "1.1.1.1"); - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 1); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 1); g_assert (ip4_addr); - g_assert_cmpint (nm_ip4_address_get_prefix (ip4_addr), ==, 16); - g_assert_cmpint (inet_pton (AF_INET, "9.8.7.6", &addr4), >, 0); - g_assert_cmpint (nm_ip4_address_get_address (ip4_addr), ==, addr4); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 16); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "9.8.7.6"); /* ===== IPv6 SETTING ===== */ s_ip6 = nm_connection_get_setting_ip6_config (connection); g_assert (s_ip6); - g_assert_cmpstr (nm_setting_ip6_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO); - g_assert (nm_setting_ip6_config_get_may_fail (s_ip6)); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO); + g_assert (nm_setting_ip_config_get_may_fail (s_ip6)); /* DNS Addresses */ - g_assert_cmpint (nm_setting_ip6_config_get_num_dns (s_ip6), ==, 2); - g_assert_cmpint (inet_pton (AF_INET6, "1:2:3:4::a", &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 0), &addr6)); - g_assert_cmpint (inet_pton (AF_INET6, "1:2:3:4::b", &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 1), &addr6)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 2); + g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip6, 0), ==, "1:2:3:4::a"); + g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip6, 1), ==, "1:2:3:4::b"); /* IP addresses */ - g_assert_cmpint (nm_setting_ip6_config_get_num_addresses (s_ip6), ==, 3); - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 0); + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip6), ==, 3); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 0); g_assert (ip6_addr); - g_assert_cmpint (nm_ip6_address_get_prefix (ip6_addr), ==, 56); - g_assert_cmpint (inet_pton (AF_INET6, "1001:abba::1234", &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr6)); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 56); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "1001:abba::1234"); - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 1); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 1); g_assert (ip6_addr); - g_assert_cmpint (nm_ip6_address_get_prefix (ip6_addr), ==, 64); - g_assert_cmpint (inet_pton (AF_INET6, "2001:abba::2234", &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr6)); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 64); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "2001:abba::2234"); - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 2); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 2); g_assert (ip6_addr); - g_assert_cmpint (nm_ip6_address_get_prefix (ip6_addr), ==, 96); - g_assert_cmpint (inet_pton (AF_INET6, "3001:abba::3234", &addr6), >, 0); - g_assert (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr6)); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 96); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "3001:abba::3234"); g_object_unref (connection); } -#define TEST_IFCFG_WIRED_GLOBAL_GATEWAY TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-global-gateway" -#define TEST_NETWORK_WIRED_GLOBAL_GATEWAY TEST_IFCFG_DIR"/network-scripts/network-test-wired-global-gateway" - static void test_read_wired_global_gateway (void) { NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - char *unmanaged = NULL; - char *keyfile = NULL; - char *routefile = NULL; - char *route6file = NULL; - gboolean ignore_error = FALSE; + NMSettingIPConfig *s_ip4; GError *error = NULL; - const char *tmp; - const char *expected_id = "System test-wired-global-gateway"; - guint32 addr; - const char *expected_address1 = "192.168.1.5"; - const char *expected_address1_gw = "192.168.1.2"; - NMIP4Address *ip4_addr; - - connection = connection_from_file (TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - TEST_NETWORK_WIRED_GLOBAL_GATEWAY, - TYPE_ETHERNET, - NULL, - &unmanaged, - &keyfile, - &routefile, - &route6file, - &error, - &ignore_error); - ASSERT (connection != NULL, - "wired-global-gateway-read", "failed to read %s: %s", TEST_IFCFG_WIRED_GLOBAL_GATEWAY, error->message); - - ASSERT (nm_connection_verify (connection, &error), - "wired-global-gateway-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_GLOBAL_GATEWAY, error->message); + NMIPAddress *ip4_addr; + char *unmanaged = NULL; - ASSERT (unmanaged == NULL, - "wired-global-gateway-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_GLOBAL_GATEWAY); + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-global-gateway", + TEST_IFCFG_DIR"/network-scripts/network-test-wired-global-gateway", + TYPE_ETHERNET, &unmanaged, NULL, NULL, NULL, &error, NULL); + nmtst_assert_connection_verifies_without_normalization (connection); + g_assert (unmanaged == NULL); /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection (connection); - ASSERT (s_con != NULL, - "wired-global-gateway-verify-connection", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_CONNECTION_SETTING_NAME); - - /* ID */ - tmp = nm_setting_connection_get_id (s_con); - ASSERT (tmp != NULL, - "wired-global-gateway-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, expected_id) == 0, - "wired-global-gateway-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-wired-global-gateway"); /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired (connection); - ASSERT (s_wired != NULL, - "wired-global-gateway-verify-wired", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_WIRED_SETTING_NAME); + g_assert (s_wired); /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config (connection); - ASSERT (s_ip4 != NULL, - "wired-global-gateway-verify-ip4", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_IP4_CONFIG_SETTING_NAME); - - /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); - ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, - "wired-global-gateway-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + g_assert (s_ip4); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); /* Address #1 */ - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); - ASSERT (ip4_addr, - "wired-global-gateway-verify-ip4", "failed to verify %s: missing IP4 address #1", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == 24, - "wired-global-gateway-verify-ip4", "failed to verify %s: unexpected IP4 address #1 prefix", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - - ASSERT (inet_pton (AF_INET, expected_address1, &addr) > 0, - "wired-global-gateway-verify-ip4", "failed to verify %s: couldn't convert IP address #1", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_ip4_address_get_address (ip4_addr) == addr, - "wired-global-gateway-verify-ip4", "failed to verify %s: unexpected IP4 address #1", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); + g_assert (ip4_addr); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "192.168.1.5"); - ASSERT (inet_pton (AF_INET, expected_address1_gw, &addr) > 0, - "wired-global-gateway-verify-ip4", "failed to verify %s: couldn't convert IP address #1 gateway", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - ASSERT (nm_ip4_address_get_gateway (ip4_addr) == addr, - "wired-global-gateway-verify-ip4", "failed to verify %s: unexpected IP4 address #1 gateway", - TEST_IFCFG_WIRED_GLOBAL_GATEWAY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); + /* Gateway */ + g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "192.168.1.2"); - g_free (unmanaged); - g_free (keyfile); - g_free (routefile); - g_free (route6file); g_object_unref (connection); } -#define TEST_IFCFG_WIRED_NEVER_DEFAULT TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-never-default" -#define TEST_NETWORK_WIRED_NEVER_DEFAULT TEST_IFCFG_DIR"/network-scripts/network-test-wired-never-default" - static void test_read_wired_never_default (void) { NMConnection *connection; - NMSettingConnection *s_con; - NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; - char *unmanaged = NULL; - char *keyfile = NULL; - char *routefile = NULL; - char *route6file = NULL; - gboolean ignore_error = FALSE; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; GError *error = NULL; - const char *tmp; - const char *expected_id = "System test-wired-never-default"; - - connection = connection_from_file (TEST_IFCFG_WIRED_NEVER_DEFAULT, - TEST_NETWORK_WIRED_NEVER_DEFAULT, - TYPE_ETHERNET, - NULL, - &unmanaged, - &keyfile, - &routefile, - &route6file, - &error, - &ignore_error); - ASSERT (connection != NULL, - "wired-never-default-read", "failed to read %s: %s", TEST_IFCFG_WIRED_NEVER_DEFAULT, error->message); - - ASSERT (nm_connection_verify (connection, &error), - "wired-never-default-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_NEVER_DEFAULT, error->message); - - ASSERT (unmanaged == NULL, - "wired-never-default-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_NEVER_DEFAULT); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection (connection); - ASSERT (s_con != NULL, - "wired-never-default-verify-connection", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_CONNECTION_SETTING_NAME); - - /* ID */ - tmp = nm_setting_connection_get_id (s_con); - ASSERT (tmp != NULL, - "wired-never-default-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, expected_id) == 0, - "wired-never-default-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-never-default", + TEST_IFCFG_DIR"/network-scripts/network-test-wired-never-default", + TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); + nmtst_assert_connection_verifies_without_normalization (connection); /* ===== WIRED SETTING ===== */ - - s_wired = nm_connection_get_setting_wired (connection); - ASSERT (s_wired != NULL, - "wired-never-default-verify-wired", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_WIRED_SETTING_NAME); + g_assert (nm_connection_get_setting_wired (connection)); /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config (connection); - ASSERT (s_ip4 != NULL, - "wired-never-default-verify-ip4", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_IP4_CONFIG_SETTING_NAME); - - /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); - ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, - "wired-never-default-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); - - ASSERT (nm_setting_ip4_config_get_never_default (s_ip4) == TRUE, - "wired-never-default-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_NEVER_DEFAULT); - - /* DNS Addresses */ - ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 0, - "wired-never-default-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + g_assert (s_ip4); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); + g_assert (nm_setting_ip_config_get_never_default (s_ip4)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 0); /* ===== IPv6 SETTING ===== */ - s_ip6 = nm_connection_get_setting_ip6_config (connection); - ASSERT (s_ip6 != NULL, - "wired-never-default-verify-ip6", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_IP6_CONFIG_SETTING_NAME); - - /* Method */ - tmp = nm_setting_ip6_config_get_method (s_ip6); - ASSERT (strcmp (tmp, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0, - "wired-never-default-verify-ip6", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_METHOD); - - ASSERT (nm_setting_ip6_config_get_never_default (s_ip6) == TRUE, - "wired-never-default-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_NEVER_DEFAULT, - NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_NEVER_DEFAULT); + g_assert (s_ip6); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO); + g_assert (nm_setting_ip_config_get_never_default (s_ip6)); - g_free (unmanaged); - g_free (keyfile); - g_free (routefile); - g_free (route6file); g_object_unref (connection); } @@ -1068,8 +889,8 @@ test_read_wired_defroute_no (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -1082,7 +903,6 @@ test_read_wired_defroute_no (void) connection = connection_from_file (TEST_IFCFG_WIRED_DEFROUTE_NO, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -1136,18 +956,18 @@ test_read_wired_defroute_no (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wired-defroute-no-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DEFROUTE_NO, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - ASSERT (nm_setting_ip4_config_get_never_default (s_ip4) == TRUE, + ASSERT (nm_setting_ip_config_get_never_default (s_ip4) == TRUE, "wired-defroute-no-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DEFROUTE_NO, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_NEVER_DEFAULT); + NM_SETTING_IP_CONFIG_NEVER_DEFAULT); /* ===== IPv6 SETTING ===== */ @@ -1158,18 +978,18 @@ test_read_wired_defroute_no (void) NM_SETTING_IP6_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip6_config_get_method (s_ip6); + tmp = nm_setting_ip_config_get_method (s_ip6); ASSERT (strcmp (tmp, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0, "wired-defroute-no-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DEFROUTE_NO, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - ASSERT (nm_setting_ip6_config_get_never_default (s_ip6) == TRUE, + ASSERT (nm_setting_ip_config_get_never_default (s_ip6) == TRUE, "wired-defroute-no-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DEFROUTE_NO, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_NEVER_DEFAULT); + NM_SETTING_IP_CONFIG_NEVER_DEFAULT); g_free (unmanaged); g_free (keyfile); @@ -1187,8 +1007,8 @@ test_read_wired_defroute_no_gatewaydev_yes (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -1201,7 +1021,6 @@ test_read_wired_defroute_no_gatewaydev_yes (void) connection = connection_from_file (TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES, TEST_NETWORK_WIRED_DEFROUTE_NO_GATEWAYDEV_YES, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -1263,18 +1082,18 @@ test_read_wired_defroute_no_gatewaydev_yes (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wired-defroute-no-gatewaydev-yes-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - ASSERT (nm_setting_ip4_config_get_never_default (s_ip4) == FALSE, + ASSERT (nm_setting_ip_config_get_never_default (s_ip4) == FALSE, "wired-defroute-no-gatewaydev-yes-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_NEVER_DEFAULT); + NM_SETTING_IP_CONFIG_NEVER_DEFAULT); /* ===== IPv6 SETTING ===== */ @@ -1285,18 +1104,18 @@ test_read_wired_defroute_no_gatewaydev_yes (void) NM_SETTING_IP6_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip6_config_get_method (s_ip6); - ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, - "wired-defroute-no-gatewaydev-yes-verify-ip4", "failed to verify %s: unexpected %s / %s key value", + tmp = nm_setting_ip_config_get_method (s_ip6); + ASSERT (strcmp (tmp, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0, + "wired-defroute-no-gatewaydev-yes-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - ASSERT (nm_setting_ip6_config_get_never_default (s_ip6) == FALSE, - "wired-defroute-no-gatewaydev-yes-verify-ip4", "failed to verify %s: unexpected %s / %s key value", + ASSERT (nm_setting_ip_config_get_never_default (s_ip6) == FALSE, + "wired-defroute-no-gatewaydev-yes-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_NEVER_DEFAULT); + NM_SETTING_IP_CONFIG_NEVER_DEFAULT); g_free (unmanaged); g_free (keyfile); @@ -1305,168 +1124,51 @@ test_read_wired_defroute_no_gatewaydev_yes (void) g_object_unref (connection); } -#define TEST_IFCFG_WIRED_STATIC_ROUTES TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-static-routes" - static void test_read_wired_static_routes (void) { NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - char *unmanaged = NULL; - char *keyfile = NULL; - char *routefile = NULL; - char *route6file = NULL; - gboolean ignore_error = FALSE; + NMSettingIPConfig *s_ip4; GError *error = NULL; - const char *tmp; - NMIP4Route *ip4_route; - guint32 addr; - const char *expected_id = "System test-wired-static-routes"; - const char *expected_dst1 = "11.22.33.0"; - const char *expected_dst2 = "44.55.66.77"; - const char *expected_gw1 = "192.168.1.5"; - const char *expected_gw2 = "192.168.1.7"; - - connection = connection_from_file (TEST_IFCFG_WIRED_STATIC_ROUTES, - NULL, - TYPE_ETHERNET, - NULL, - &unmanaged, - &keyfile, - &routefile, - &route6file, - &error, - &ignore_error); - - ASSERT (connection != NULL, - "wired-static-routes-read", - "failed to read %s: %s", - TEST_IFCFG_WIRED_STATIC_ROUTES, error->message); + NMIPRoute *ip4_route; - ASSERT (nm_connection_verify (connection, &error), - "wired-static-routes-verify", "failed to verify %s: %s", - TEST_IFCFG_WIRED_STATIC_ROUTES, error->message); - - ASSERT (unmanaged == NULL, - "wired-static-routes-verify", - "failed to verify %s: unexpected unmanaged value", - TEST_IFCFG_WIRED_STATIC_ROUTES); + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-static-routes", + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); + nmtst_assert_connection_verifies_without_normalization (connection); /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection (connection); - ASSERT (s_con != NULL, - "wired-static-routes-verify-connection", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_CONNECTION_SETTING_NAME); - - /* ID */ - tmp = nm_setting_connection_get_id (s_con); - ASSERT (tmp != NULL, - "wired-static-routes-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, expected_id) == 0, - "wired-static-routes-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-wired-static-routes"); /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired (connection); - ASSERT (s_wired != NULL, - "wired-static-routes-verify-wired", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_WIRED_SETTING_NAME); + g_assert (s_wired); /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config (connection); - ASSERT (s_ip4 != NULL, - "wired-static-routes-verify-ip4", "failed to verify %s: missing %s setting", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_IP4_CONFIG_SETTING_NAME); - - /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); - ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + g_assert (s_ip4); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); /* Routes */ - ASSERT (nm_setting_ip4_config_get_num_routes (s_ip4) == 2, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ip4_route = nm_setting_ip4_config_get_route (s_ip4, 0); - ASSERT (ip4_route, - "wired-static-routes-verify-ip4", "failed to verify %s: missing IP4 route #1", - TEST_IFCFG_WIRED_STATIC_ROUTES); - - ASSERT (inet_pton (AF_INET, expected_dst1, &addr) > 0, - "wired-static-routes-verify-ip4", "failed to verify %s: couldn't convert destination IP address #1", - TEST_IFCFG_WIRED_STATIC_ROUTES); - ASSERT (nm_ip4_route_get_dest (ip4_route) == addr, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ASSERT (nm_ip4_route_get_prefix (ip4_route) == 24, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected destination route #1 prefix", - TEST_IFCFG_WIRED_STATIC_ROUTES); - - ASSERT (inet_pton (AF_INET, expected_gw1, &addr) > 0, - "wired-static-routes-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #1", - TEST_IFCFG_WIRED_STATIC_ROUTES); - ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ip4_route = nm_setting_ip4_config_get_route (s_ip4, 1); - ASSERT (ip4_route, - "wired-static-routes-verify-ip4", "failed to verify %s: missing IP4 route #2", - TEST_IFCFG_WIRED_STATIC_ROUTES); - - ASSERT (inet_pton (AF_INET, expected_dst2, &addr) > 0, - "wired-static-routes-verify-ip4", "failed to verify %s: couldn't convert destination IP address #2", - TEST_IFCFG_WIRED_STATIC_ROUTES); - ASSERT (nm_ip4_route_get_dest (ip4_route) == addr, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ASSERT (nm_ip4_route_get_prefix (ip4_route) == 32, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected destination route #2 prefix", - TEST_IFCFG_WIRED_STATIC_ROUTES); - - ASSERT (inet_pton (AF_INET, expected_gw2, &addr) > 0, - "wired-static-routes-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #2", - TEST_IFCFG_WIRED_STATIC_ROUTES); - ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2", - TEST_IFCFG_WIRED_STATIC_ROUTES, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - ASSERT (nm_ip4_route_get_metric (ip4_route) == 3, - "wired-static-routes-verify-ip4", "failed to verify %s: unexpected route metric #2", - TEST_IFCFG_WIRED_STATIC_ROUTES); + g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 2); + + ip4_route = nm_setting_ip_config_get_route (s_ip4, 0); + g_assert (ip4_route); + g_assert_cmpstr (nm_ip_route_get_dest (ip4_route), ==, "11.22.33.0"); + g_assert_cmpint (nm_ip_route_get_prefix (ip4_route), ==, 24); + g_assert_cmpstr (nm_ip_route_get_next_hop (ip4_route), ==, "192.168.1.5"); + g_assert_cmpint (nm_ip_route_get_metric (ip4_route), ==, -1); + + ip4_route = nm_setting_ip_config_get_route (s_ip4, 1); + g_assert (ip4_route); + g_assert_cmpstr (nm_ip_route_get_dest (ip4_route), ==, "44.55.66.77"); + g_assert_cmpint (nm_ip_route_get_prefix (ip4_route), ==, 32); + g_assert_cmpstr (nm_ip_route_get_next_hop (ip4_route), ==, "192.168.1.7"); + g_assert_cmpint (nm_ip_route_get_metric (ip4_route), ==, 3); - g_free (unmanaged); - g_free (keyfile); - g_free (routefile); - g_free (route6file); g_object_unref (connection); } @@ -1478,7 +1180,7 @@ test_read_wired_static_routes_legacy (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -1486,20 +1188,12 @@ test_read_wired_static_routes_legacy (void) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - NMIP4Route *ip4_route; - guint32 addr; + NMIPRoute *ip4_route; const char *expected_id = "System test-wired-static-routes-legacy"; - const char *expected_dst1 = "21.31.41.0"; - const char *expected_dst2 = "32.42.52.62"; - const char *expected_dst3 = "43.53.0.0"; - const char *expected_gw1 = "9.9.9.9"; - const char *expected_gw2 = "8.8.8.8"; - const char *expected_gw3 = "7.7.7.7"; connection = connection_from_file (TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -1559,115 +1253,43 @@ test_read_wired_static_routes_legacy (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* Routes */ - ASSERT (nm_setting_ip4_config_get_num_routes (s_ip4) == 3, + ASSERT (nm_setting_ip_config_get_num_routes (s_ip4) == 3, "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); + NM_SETTING_IP_CONFIG_ROUTES); /* Route #1 */ - ip4_route = nm_setting_ip4_config_get_route (s_ip4, 0); - ASSERT (ip4_route, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: missing IP4 route #1", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - - ASSERT (inet_pton (AF_INET, expected_dst1, &addr) > 0, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert destination IP address #1", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - ASSERT (nm_ip4_route_get_dest (ip4_route) == addr, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ASSERT (nm_ip4_route_get_prefix (ip4_route) == 24, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected destination route #1 prefix", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - - ASSERT (inet_pton (AF_INET, expected_gw1, &addr) > 0, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #1", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ASSERT (nm_ip4_route_get_metric (ip4_route) == 1, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected destination route #1 metric", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); + ip4_route = nm_setting_ip_config_get_route (s_ip4, 0); + g_assert (ip4_route != NULL); + g_assert_cmpstr (nm_ip_route_get_dest (ip4_route), ==, "21.31.41.0"); + g_assert_cmpint (nm_ip_route_get_prefix (ip4_route), ==, 24); + g_assert_cmpstr (nm_ip_route_get_next_hop (ip4_route), ==, "9.9.9.9"); + g_assert_cmpint (nm_ip_route_get_metric (ip4_route), ==, 1); /* Route #2 */ - ip4_route = nm_setting_ip4_config_get_route (s_ip4, 1); - ASSERT (ip4_route, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: missing IP4 route #2", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - - ASSERT (inet_pton (AF_INET, expected_dst2, &addr) > 0, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert destination IP address #2", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - ASSERT (nm_ip4_route_get_dest (ip4_route) == addr, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ASSERT (nm_ip4_route_get_prefix (ip4_route) == 32, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected destination route #2 prefix", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - - ASSERT (inet_pton (AF_INET, expected_gw2, &addr) > 0, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #2", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ASSERT (nm_ip4_route_get_metric (ip4_route) == 0, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected destination route #2 metric", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); + ip4_route = nm_setting_ip_config_get_route (s_ip4, 1); + g_assert (ip4_route != NULL); + g_assert_cmpstr (nm_ip_route_get_dest (ip4_route), ==, "32.42.52.62"); + g_assert_cmpint (nm_ip_route_get_prefix (ip4_route), ==, 32); + g_assert_cmpstr (nm_ip_route_get_next_hop (ip4_route), ==, "8.8.8.8"); + g_assert_cmpint (nm_ip_route_get_metric (ip4_route), ==, -1); /* Route #3 */ - ip4_route = nm_setting_ip4_config_get_route (s_ip4, 2); - ASSERT (ip4_route, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: missing IP4 route #3", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - - ASSERT (inet_pton (AF_INET, expected_dst3, &addr) > 0, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert destination IP address #3", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - ASSERT (nm_ip4_route_get_dest (ip4_route) == addr, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #3", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ASSERT (nm_ip4_route_get_prefix (ip4_route) == 16, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected destination route #3 prefix", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - - ASSERT (inet_pton (AF_INET, expected_gw3, &addr) > 0, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: couldn't convert next hop IP address #3", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); - ASSERT (nm_ip4_route_get_next_hop (ip4_route) == addr, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value #3", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ROUTES); - - ASSERT (nm_ip4_route_get_metric (ip4_route) == 3, - "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected destination route #3 metric", - TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); + ip4_route = nm_setting_ip_config_get_route (s_ip4, 2); + g_assert (ip4_route != NULL); + g_assert_cmpstr (nm_ip_route_get_dest (ip4_route), ==, "43.53.0.0"); + g_assert_cmpint (nm_ip_route_get_prefix (ip4_route), ==, 16); + g_assert_cmpstr (nm_ip_route_get_next_hop (ip4_route), ==, "7.7.7.7"); + g_assert_cmpint (nm_ip_route_get_metric (ip4_route), ==, 3); g_free (unmanaged); g_free (keyfile); @@ -1682,7 +1304,7 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -1690,19 +1312,11 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - const char *expected_address1 = "1.2.3.4"; - const char *expected_address2 = "9.8.7.6"; - const char *expected_address3 = "3.3.3.3"; - guint32 expected_prefix1 = 24; - guint32 expected_prefix2 = 16; - guint32 expected_prefix3 = 8; - NMIP4Address *ip4_addr; - guint32 addr; + NMIPAddress *ip4_addr; connection = connection_from_file (file, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -1756,70 +1370,37 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* IP addresses */ - ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == 3, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip4) == 3, "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); + NM_SETTING_IP_CONFIG_ADDRESSES); /* Address #1 */ - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); - ASSERT (ip4_addr, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: missing IP4 address #1", - file); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix1, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #1 prefix", - file); - - ASSERT (inet_pton (AF_INET, expected_address1, &addr) > 0, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #1", - file); - ASSERT (nm_ip4_address_get_address (ip4_addr) == addr, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #1", - file); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); + g_assert (ip4_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "1.2.3.4"); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24); /* Address #2 */ - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 1); - ASSERT (ip4_addr, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: missing IP4 address #2", - file); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix2, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #2 prefix", - file); - - ASSERT (inet_pton (AF_INET, expected_address2, &addr) > 0, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #2", - file); - ASSERT (nm_ip4_address_get_address (ip4_addr) == addr, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #2", - file); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 1); + g_assert (ip4_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "9.8.7.6"); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 16); /* Address #3 */ - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 2); - ASSERT (ip4_addr, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: missing IP4 address #3", - file); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix3, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #3 prefix", - file); - - ASSERT (inet_pton (AF_INET, expected_address3, &addr) > 0, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #3", - file); - ASSERT (nm_ip4_address_get_address (ip4_addr) == addr, - "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #3", - file); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 2); + g_assert (ip4_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "3.3.3.3"); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 8); g_free (unmanaged); g_free (keyfile); @@ -1836,8 +1417,8 @@ test_read_wired_ipv6_manual (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -1846,24 +1427,14 @@ test_read_wired_ipv6_manual (void) GError *error = NULL; const char *tmp; const char *expected_id = "System test-wired-ipv6-manual"; - const char *expected_address1 = "1001:abba::1234"; - const char *expected_address2 = "2001:abba::2234"; - const char *expected_address3 = "3001:abba::3234"; - guint32 expected_prefix1 = 56; - guint32 expected_prefix2 = 64; - guint32 expected_prefix3 = 96; - const char *expected_dns1 = "1:2:3:4::a"; - const char *expected_dns2 = "1:2:3:4::b"; - NMIP6Address *ip6_addr; - NMIP6Route *ip6_route; - struct in6_addr addr; + NMIPAddress *ip6_addr; + NMIPRoute *ip6_route; g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*ignoring manual default route*"); connection = connection_from_file (TEST_IFCFG_WIRED_IPV6_MANUAL, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -1919,54 +1490,54 @@ test_read_wired_ipv6_manual (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* DNS Addresses */ - ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 2, + ASSERT (nm_setting_ip_config_get_num_dns (s_ip4) == 2, "wired-ipv6-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); /* DNS search domains */ - ASSERT (nm_setting_ip4_config_get_num_dns_searches (s_ip4) == 3, + ASSERT (nm_setting_ip_config_get_num_dns_searches (s_ip4) == 3, "wired-ipv6-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - tmp = nm_setting_ip4_config_get_dns_search (s_ip4, 0); + tmp = nm_setting_ip_config_get_dns_search (s_ip4, 0); ASSERT (tmp != NULL, "wired-ipv6-manual-verify-ip4", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); ASSERT (strcmp (tmp, "lorem.com") == 0, "wired-ipv6-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); - tmp = nm_setting_ip4_config_get_dns_search (s_ip4, 1); + tmp = nm_setting_ip_config_get_dns_search (s_ip4, 1); ASSERT (tmp != NULL, "wired-ipv6-manual-verify-ip4", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); ASSERT (strcmp (tmp, "ipsum.org") == 0, "wired-ipv6-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); - tmp = nm_setting_ip4_config_get_dns_search (s_ip4, 2); + tmp = nm_setting_ip_config_get_dns_search (s_ip4, 2); ASSERT (tmp != NULL, "wired-ipv6-manual-verify-ip4", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); ASSERT (strcmp (tmp, "dolor.edu") == 0, "wired-ipv6-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); /* ===== IPv6 SETTING ===== */ @@ -1977,135 +1548,92 @@ test_read_wired_ipv6_manual (void) NM_SETTING_IP6_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip6_config_get_method (s_ip6); + tmp = nm_setting_ip_config_get_method (s_ip6); ASSERT (strcmp (tmp, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - ASSERT (nm_setting_ip6_config_get_never_default (s_ip6) == FALSE, + ASSERT (nm_setting_ip_config_get_never_default (s_ip6) == FALSE, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_NEVER_DEFAULT); + NM_SETTING_IP_CONFIG_NEVER_DEFAULT); - ASSERT (nm_setting_ip6_config_get_may_fail (s_ip6) == TRUE, + ASSERT (nm_setting_ip_config_get_may_fail (s_ip6) == TRUE, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_MAY_FAIL); + NM_SETTING_IP_CONFIG_MAY_FAIL); /* IP addresses */ - ASSERT (nm_setting_ip6_config_get_num_addresses (s_ip6) == 3, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip6) == 3, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_ADDRESSES); + NM_SETTING_IP_CONFIG_ADDRESSES); /* Address #1 */ - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 0); - ASSERT (ip6_addr, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: missing IP6 address #1", - TEST_IFCFG_WIRED_IPV6_MANUAL); - - ASSERT (nm_ip6_address_get_prefix (ip6_addr) == expected_prefix1, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected IP6 address #1 prefix", - TEST_IFCFG_WIRED_IPV6_MANUAL); - - ASSERT (inet_pton (AF_INET6, expected_address1, &addr) > 0, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: couldn't convert IP address #1", - TEST_IFCFG_WIRED_IPV6_MANUAL); - ASSERT (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr), - "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected IP6 address #1", - TEST_IFCFG_WIRED_IPV6_MANUAL); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 0); + g_assert (ip6_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "1001:abba::1234"); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 56); /* Address #2 */ - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 1); - ASSERT (ip6_addr, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: missing IP6 address #2", - TEST_IFCFG_WIRED_IPV6_MANUAL); - - ASSERT (nm_ip6_address_get_prefix (ip6_addr) == expected_prefix2, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected IP6 address #2 prefix", - TEST_IFCFG_WIRED_IPV6_MANUAL); - - ASSERT (inet_pton (AF_INET6, expected_address2, &addr) > 0, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: couldn't convert IP address #2", - TEST_IFCFG_WIRED_IPV6_MANUAL); - ASSERT (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr), - "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected IP6 address #2", - TEST_IFCFG_WIRED_IPV6_MANUAL); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 1); + g_assert (ip6_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "2001:abba::2234"); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 64); /* Address #3 */ - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 2); - ASSERT (ip6_addr, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: missing IP6 address #3", - TEST_IFCFG_WIRED_IPV6_MANUAL); - - ASSERT (nm_ip6_address_get_prefix (ip6_addr) == expected_prefix3, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected IP6 address #3 prefix", - TEST_IFCFG_WIRED_IPV6_MANUAL); - - ASSERT (inet_pton (AF_INET6, expected_address3, &addr) > 0, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: couldn't convert IP address #3", - TEST_IFCFG_WIRED_IPV6_MANUAL); - ASSERT (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr), - "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected IP6 address #3", - TEST_IFCFG_WIRED_IPV6_MANUAL); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 2); + g_assert (ip6_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "3001:abba::3234"); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 96); /* Routes */ - g_assert_cmpint (nm_setting_ip6_config_get_num_routes (s_ip6), ==, 2); + g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip6), ==, 2); /* Route #1 */ - ip6_route = nm_setting_ip6_config_get_route (s_ip6, 0); + ip6_route = nm_setting_ip_config_get_route (s_ip6, 0); g_assert (ip6_route); - g_assert_cmpint (inet_pton (AF_INET6, "9876::1234", &addr), >, 0); - g_assert_cmpint (memcmp (nm_ip6_route_get_dest (ip6_route), &addr, sizeof (struct in6_addr)), ==, 0); - g_assert_cmpint (nm_ip6_route_get_prefix (ip6_route), ==, 96); - g_assert_cmpint (inet_pton (AF_INET6, "9876::7777", &addr), >, 0); - g_assert_cmpint (memcmp (nm_ip6_route_get_next_hop (ip6_route), &addr, sizeof (struct in6_addr)), ==, 0); - g_assert_cmpint (nm_ip6_route_get_metric (ip6_route), ==, 2); + g_assert_cmpstr (nm_ip_route_get_dest (ip6_route), ==, "9876::1234"); + g_assert_cmpint (nm_ip_route_get_prefix (ip6_route), ==, 96); + g_assert_cmpstr (nm_ip_route_get_next_hop (ip6_route), ==, "9876::7777"); + g_assert_cmpint (nm_ip_route_get_metric (ip6_route), ==, 2); /* Route #2 */ - ip6_route = nm_setting_ip6_config_get_route (s_ip6, 1); + ip6_route = nm_setting_ip_config_get_route (s_ip6, 1); g_assert (ip6_route); - g_assert_cmpint (inet_pton (AF_INET6, "abbe::cafe", &addr), >, 0); - g_assert_cmpint (memcmp (nm_ip6_route_get_dest (ip6_route), &addr, sizeof (struct in6_addr)), ==, 0); - g_assert_cmpint (nm_ip6_route_get_prefix (ip6_route), ==, 64); - g_assert_cmpint (inet_pton (AF_INET6, "::", &addr), >, 0); - g_assert_cmpint (memcmp (nm_ip6_route_get_next_hop (ip6_route), &addr, sizeof (struct in6_addr)), ==, 0); - g_assert_cmpint (nm_ip6_route_get_metric (ip6_route), ==, 777); + g_assert_cmpstr (nm_ip_route_get_dest (ip6_route), ==, "abbe::cafe"); + g_assert_cmpint (nm_ip_route_get_prefix (ip6_route), ==, 64); + g_assert_cmpstr (nm_ip_route_get_next_hop (ip6_route), ==, NULL); + g_assert_cmpint (nm_ip_route_get_metric (ip6_route), ==, 777); /* DNS Addresses */ - ASSERT (nm_setting_ip6_config_get_num_dns (s_ip6) == 2, + ASSERT (nm_setting_ip_config_get_num_dns (s_ip6) == 2, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET6, expected_dns1, &addr) > 0, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: couldn't convert DNS IP address #1", - TEST_IFCFG_WIRED_IPV6_MANUAL); - ASSERT (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 0), &addr), + ASSERT (strcmp (nm_setting_ip_config_get_dns (s_ip6, 0), "1:2:3:4::a") == 0, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value #1", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET6, expected_dns2, &addr) > 0, - "wired-ipv6-manual-verify-ip6", "failed to verify %s: couldn't convert DNS IP address #2", - TEST_IFCFG_WIRED_IPV6_MANUAL); - ASSERT (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 1), &addr), + ASSERT (strcmp (nm_setting_ip_config_get_dns (s_ip6, 1), "1:2:3:4::b") == 0, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value #2", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); /* DNS domains - none as domains are stuffed to 'ipv4' setting */ - ASSERT (nm_setting_ip6_config_get_num_dns_searches (s_ip6) == 0, + ASSERT (nm_setting_ip_config_get_num_dns_searches (s_ip6) == 0, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); g_free (unmanaged); g_free (keyfile); @@ -2122,8 +1650,8 @@ test_read_wired_ipv6_only (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -2132,17 +1660,12 @@ test_read_wired_ipv6_only (void) GError *error = NULL; const char *tmp; const char *expected_id = "System test-wired-ipv6-only"; - const char *expected_address1 = "1001:abba::1234"; - guint32 expected_prefix1 = 56; - const char *expected_dns1 = "1:2:3:4::a"; - NMIP6Address *ip6_addr; - struct in6_addr addr; + NMIPAddress *ip6_addr; const char *method; connection = connection_from_file (TEST_IFCFG_WIRED_IPV6_ONLY, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -2195,12 +1718,12 @@ test_read_wired_ipv6_only (void) TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME); - method = nm_setting_ip4_config_get_method (s_ip4); + method = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0, "wired-ipv6-only-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* ===== IPv6 SETTING ===== */ @@ -2211,58 +1734,44 @@ test_read_wired_ipv6_only (void) NM_SETTING_IP6_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip6_config_get_method (s_ip6); + tmp = nm_setting_ip_config_get_method (s_ip6); ASSERT (strcmp (tmp, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0, "wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* IP addresses */ - ASSERT (nm_setting_ip6_config_get_num_addresses (s_ip6) == 1, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip6) == 1, "wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_ADDRESSES); + NM_SETTING_IP_CONFIG_ADDRESSES); /* Address #1 */ - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 0); - ASSERT (ip6_addr, - "wired-ipv6-only-verify-ip6", "failed to verify %s: missing IP6 address #1", - TEST_IFCFG_WIRED_IPV6_MANUAL); - - ASSERT (nm_ip6_address_get_prefix (ip6_addr) == expected_prefix1, - "wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected IP6 address #1 prefix", - TEST_IFCFG_WIRED_IPV6_MANUAL); - - ASSERT (inet_pton (AF_INET6, expected_address1, &addr) > 0, - "wired-ipv6-only-verify-ip6", "failed to verify %s: couldn't convert IP address #1", - TEST_IFCFG_WIRED_IPV6_MANUAL); - ASSERT (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr), - "wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected IP6 address #1", - TEST_IFCFG_WIRED_IPV6_MANUAL); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 0); + g_assert (ip6_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "1001:abba::1234"); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 56); /* DNS Addresses */ - ASSERT (nm_setting_ip6_config_get_num_dns (s_ip6) == 1, + ASSERT (nm_setting_ip_config_get_num_dns (s_ip6) == 1, "wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET6, expected_dns1, &addr) > 0, - "wired-ipv6-only-verify-ip6", "failed to verify %s: couldn't convert DNS IP address #1", - TEST_IFCFG_WIRED_IPV6_MANUAL); - ASSERT (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 0), &addr), + ASSERT (strcmp (nm_setting_ip_config_get_dns (s_ip6, 0), "1:2:3:4::a") == 0, "wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value #1", TEST_IFCFG_WIRED_IPV6_MANUAL, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); /* DNS domains should be in IPv6, because IPv4 is disabled */ - g_assert_cmpint (nm_setting_ip6_config_get_num_dns_searches (s_ip6), ==, 3); - g_assert_cmpstr (nm_setting_ip6_config_get_dns_search (s_ip6, 0), ==, "lorem.com"); - g_assert_cmpstr (nm_setting_ip6_config_get_dns_search (s_ip6, 1), ==, "ipsum.org"); - g_assert_cmpstr (nm_setting_ip6_config_get_dns_search (s_ip6, 2), ==, "dolor.edu"); + g_assert_cmpint (nm_setting_ip_config_get_num_dns_searches (s_ip6), ==, 3); + g_assert_cmpstr (nm_setting_ip_config_get_dns_search (s_ip6, 0), ==, "lorem.com"); + g_assert_cmpstr (nm_setting_ip_config_get_dns_search (s_ip6, 1), ==, "ipsum.org"); + g_assert_cmpstr (nm_setting_ip_config_get_dns_search (s_ip6, 2), ==, "dolor.edu"); g_free (unmanaged); g_free (keyfile); @@ -2279,8 +1788,8 @@ test_read_wired_dhcp6_only (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -2294,7 +1803,6 @@ test_read_wired_dhcp6_only (void) connection = connection_from_file (TEST_IFCFG_WIRED_DHCP6_ONLY, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -2347,12 +1855,12 @@ test_read_wired_dhcp6_only (void) TEST_IFCFG_WIRED_DHCP6_ONLY, NM_SETTING_IP4_CONFIG_SETTING_NAME); - method = nm_setting_ip4_config_get_method (s_ip4); + method = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0, "wired-dhcp6-only-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DHCP6_ONLY, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* ===== IPv6 SETTING ===== */ @@ -2363,12 +1871,12 @@ test_read_wired_dhcp6_only (void) NM_SETTING_IP6_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip6_config_get_method (s_ip6); + tmp = nm_setting_ip_config_get_method (s_ip6); ASSERT (strcmp (tmp, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0, "wired-dhcp6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_DHCP6_ONLY, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); g_free (unmanaged); g_free (keyfile); @@ -2394,7 +1902,6 @@ test_read_onboot_no (void) connection = connection_from_file (TEST_IFCFG_ONBOOT_NO, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -2438,8 +1945,8 @@ static void test_read_noip (void) { NMConnection *connection; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -2450,7 +1957,6 @@ test_read_noip (void) connection = connection_from_file (TEST_IFCFG_NOIP, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -2463,13 +1969,13 @@ test_read_noip (void) s_ip4 = nm_connection_get_setting_ip4_config (connection); g_assert (s_ip4); - g_assert_cmpstr (nm_setting_ip4_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); - g_assert (nm_setting_ip4_config_get_never_default (s_ip4) == FALSE); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); + g_assert (nm_setting_ip_config_get_never_default (s_ip4) == FALSE); s_ip6 = nm_connection_get_setting_ip6_config (connection); g_assert (s_ip6); - g_assert_cmpstr (nm_setting_ip6_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); - g_assert (nm_setting_ip6_config_get_never_default (s_ip6) == FALSE); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); + g_assert (nm_setting_ip_config_get_never_default (s_ip6) == FALSE); g_free (unmanaged); g_free (keyfile); @@ -2486,7 +1992,7 @@ test_read_wired_8021x_peap_mschapv2 (void) { NMConnection *connection; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; NMSetting8021x *s_8021x; NMSetting8021x *tmp_8021x; char *unmanaged = NULL; @@ -2506,7 +2012,6 @@ test_read_wired_8021x_peap_mschapv2 (void) connection = connection_from_file (TEST_IFCFG_WIRED_8021x_PEAP_MSCHAPV2, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -2539,12 +2044,12 @@ test_read_wired_8021x_peap_mschapv2 (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wired-8021x-peap-mschapv2-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_8021x_PEAP_MSCHAPV2, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* ===== 802.1x SETTING ===== */ s_8021x = nm_connection_get_setting_802_1x (connection); @@ -2700,7 +2205,6 @@ test_read_wired_8021x_tls_secret_flags (const char *ifcfg, NMSettingSecretFlags connection = connection_from_file (ifcfg, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -2757,7 +2261,7 @@ test_read_write_802_1X_subj_matches (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*missing IEEE_8021X_CA_CERT*peap*"); connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-802-1X-subj-matches", - NULL, TYPE_ETHERNET, NULL, NULL, + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); g_assert_no_error (error); @@ -2786,12 +2290,12 @@ test_read_write_802_1X_subj_matches (void) g_assert (success); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*missing IEEE_8021X_CA_CERT*peap*"); - reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL, NULL, + reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); unlink (written); @@ -2840,7 +2344,7 @@ test_read_802_1x_ttls_eapgtc (void) */ connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-802-1x-ttls-eapgtc", - NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2869,7 +2373,7 @@ test_read_wired_aliases_good (void) { NMConnection *connection; NMSettingConnection *s_con; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -2878,16 +2382,15 @@ test_read_wired_aliases_good (void) GError *error = NULL; const char *tmp; const char *expected_id = "System aliasem0"; - int expected_num_addresses = 4, expected_prefix = 24; + int expected_num_addresses = 4; const char *expected_address[4] = { "192.168.1.5", "192.168.1.6", "192.168.1.9", "192.168.1.99" }; const char *expected_label[4] = { NULL, "aliasem0:1", "aliasem0:2", "aliasem0:99" }; - const char *expected_gateway[4] = { "192.168.1.1", "192.168.1.1", "192.168.1.1", "192.168.1.1" }; + const char *expected_gateway = "192.168.1.1"; int i, j; connection = connection_from_file (TEST_IFCFG_ALIASES_GOOD, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -2930,74 +2433,51 @@ test_read_wired_aliases_good (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, "aliases-good-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_ALIASES_GOOD, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == expected_num_addresses, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip4) == expected_num_addresses, "aliases-good-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_ALIASES_GOOD, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); + NM_SETTING_IP_CONFIG_ADDRESSES); /* Addresses */ for (i = 0; i < expected_num_addresses; i++) { - NMIP4Address *ip4_addr; - char buf[INET_ADDRSTRLEN]; - struct in_addr addr; + NMIPAddress *ip4_addr; + const char *addr; + GVariant *label; - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, i); - ASSERT (ip4_addr, - "aliases-good-verify-ip4", "failed to verify %s: missing IP4 address #%d", - TEST_IFCFG_ALIASES_GOOD, - i); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, i); + g_assert (ip4_addr != NULL); - addr.s_addr = nm_ip4_address_get_address (ip4_addr); - ASSERT (inet_ntop (AF_INET, &addr, buf, sizeof (buf)) > 0, - "aliases-good-verify-ip4", "failed to verify %s: couldn't convert IP address #%d", - TEST_IFCFG_ALIASES_GOOD, - i); + addr = nm_ip_address_get_address (ip4_addr); + g_assert (nm_utils_ipaddr_valid (AF_INET, addr)); for (j = 0; j < expected_num_addresses; j++) { - if (!g_strcmp0 (buf, expected_address[j])) + if (!g_strcmp0 (addr, expected_address[j])) break; } + g_assert (j < expected_num_addresses); - ASSERT (j < expected_num_addresses, - "aliases-good-verify-ip4", "failed to verify %s: unexpected IP4 address #%d", - TEST_IFCFG_ALIASES_GOOD, - i); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix, - "aliases-good-verify-ip4", "failed to verify %s: unexpected IP4 address prefix #%d", - TEST_IFCFG_ALIASES_GOOD, - i); - - if (expected_gateway[j]) { - ASSERT (inet_pton (AF_INET, expected_gateway[j], &addr) > 0, - "aliases-good-verify-ip4", "failed to verify %s: couldn't convert IP address gateway #%d", - TEST_IFCFG_ALIASES_GOOD, - i); - } else - addr.s_addr = 0; - ASSERT (nm_ip4_address_get_gateway (ip4_addr) == addr.s_addr, - "aliases-good-verify-ip4", "failed to verify %s: unexpected IP4 address gateway #%d", - TEST_IFCFG_ALIASES_GOOD, - i); - - ASSERT (g_strcmp0 (NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)), expected_label[j]) == 0, - "aliases-good-verify-ip4", "failed to verify %s: unexpected IP4 address label #%d", - TEST_IFCFG_ALIASES_GOOD, - i); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24); + label = nm_ip_address_get_attribute (ip4_addr, "label"); + if (expected_label[j]) + g_assert_cmpstr (g_variant_get_string (label, NULL), ==, expected_label[j]); + else + g_assert (label == NULL); expected_address[j] = NULL; - expected_gateway[j] = NULL; expected_label[j] = NULL; } + /* Gateway */ + g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, expected_gateway); + for (i = 0; i < expected_num_addresses; i++) { ASSERT (expected_address[i] == NULL, "aliases-good-verify-ip4", "failed to verify %s: did not find IP4 address %s", @@ -3016,7 +2496,7 @@ test_read_wired_aliases_bad (const char *base, const char *expected_id) { NMConnection *connection; NMSettingConnection *s_con; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -3024,17 +2504,11 @@ test_read_wired_aliases_bad (const char *base, const char *expected_id) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - int expected_num_addresses = 1, expected_prefix = 24; - const char *expected_address = "192.168.1.5"; - const char *expected_label = NULL; - const char *expected_gateway = "192.168.1.1"; - NMIP4Address *ip4_addr; - struct in_addr addr; + NMIPAddress *ip4_addr; connection = connection_from_file (base, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -3078,46 +2552,28 @@ test_read_wired_aliases_bad (const char *base, const char *expected_id) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, "aliases-bad-verify-ip4", "failed to verify %s: unexpected %s / %s key value", base, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == expected_num_addresses, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip4) == 1, "aliases-bad-verify-ip4", "failed to verify %s: unexpected %s / %s key value", base, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); + NM_SETTING_IP_CONFIG_ADDRESSES); /* Addresses */ - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); - ASSERT (ip4_addr, - "aliases-bad-verify-ip4", "failed to verify %s: missing IP4 address", - base); - - ASSERT (inet_pton (AF_INET, expected_address, &addr) > 0, - "aliases-bad-verify-ip4", "failed to verify %s: couldn't convert IP address", - base); - ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr, - "aliases-bad-verify-ip4", "failed to verify %s: unexpected IP4 address", - base); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix, - "aliases-bad-verify-ip4", "failed to verify %s: unexpected IP4 address prefix", - base); - - ASSERT (inet_pton (AF_INET, expected_gateway, &addr) > 0, - "aliases-bad-verify-ip4", "failed to verify %s: couldn't convert IP address gateway", - base); - ASSERT (nm_ip4_address_get_gateway (ip4_addr) == addr.s_addr, - "aliases-bad-verify-ip4", "failed to verify %s: unexpected IP4 address gateway", - base); - - ASSERT (g_strcmp0 (NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)), expected_label) == 0, - "aliases-bad-verify-ip4", "failed to verify %s: unexpected IP4 address label", - base); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); + g_assert (ip4_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "192.168.1.5"); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24); + g_assert (nm_ip_address_get_attribute (ip4_addr, "label") == NULL); + + /* Gateway */ + g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "192.168.1.1"); g_free (keyfile); g_free (routefile); @@ -3154,7 +2610,7 @@ test_read_wifi_open (void) NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -3162,7 +2618,8 @@ test_read_wifi_open (void) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - const GByteArray *array; + GBytes *ssid; + const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 }; const char *expected_id = "System blahblah (test-wifi-open)"; guint64 expected_timestamp = 0; @@ -3173,7 +2630,6 @@ test_read_wifi_open (void) connection = connection_from_file (TEST_IFCFG_WIFI_OPEN, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -3226,6 +2682,8 @@ test_read_wifi_open (void) NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_AUTOCONNECT); + g_assert_cmpint (nm_setting_connection_get_autoconnect_priority (s_con), ==, -1); + /* ===== WIRELESS SETTING ===== */ s_wireless = nm_connection_get_setting_wireless (connection); @@ -3235,18 +2693,13 @@ test_read_wifi_open (void) NM_SETTING_WIRELESS_SETTING_NAME); /* MAC address */ - array = nm_setting_wireless_get_mac_address (s_wireless); - ASSERT (array != NULL, + mac = nm_setting_wireless_get_mac_address (s_wireless); + ASSERT (mac != NULL, "wifi-open-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_OPEN, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS); - ASSERT (array->len == ETH_ALEN, - "wifi-open-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", - TEST_IFCFG_WIFI_OPEN, - NM_SETTING_WIRELESS_SETTING_NAME, - NM_SETTING_WIRELESS_MAC_ADDRESS); - ASSERT (memcmp (array->data, &expected_mac_address[0], sizeof (expected_mac_address)) == 0, + ASSERT (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, sizeof (expected_mac_address)), "wifi-open-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_OPEN, NM_SETTING_WIRELESS_SETTING_NAME, @@ -3258,18 +2711,18 @@ test_read_wifi_open (void) NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MTU); - array = nm_setting_wireless_get_ssid (s_wireless); - ASSERT (array != NULL, + ssid = nm_setting_wireless_get_ssid (s_wireless); + ASSERT (ssid != NULL, "wifi-open-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_OPEN, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (array->len == strlen (expected_ssid), + ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid), "wifi-open-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", TEST_IFCFG_WIFI_OPEN, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0, + ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0, "wifi-open-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_OPEN, NM_SETTING_WIRELESS_SETTING_NAME, @@ -3312,12 +2765,12 @@ test_read_wifi_open (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-open-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_OPEN, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); g_free (unmanaged); g_free (keyfile); @@ -3347,7 +2800,6 @@ test_read_wifi_open_auto (void) connection = connection_from_file (TEST_IFCFG_WIFI_OPEN_AUTO, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -3423,14 +2875,13 @@ test_read_wifi_open_ssid_hex (void) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - const GByteArray *array; + GBytes *ssid; const char *expected_id = "System blahblah (test-wifi-open-ssid-hex)"; const char *expected_ssid = "blahblah"; connection = connection_from_file (TEST_IFCFG_WIFI_OPEN_SSID_HEX, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -3473,18 +2924,18 @@ test_read_wifi_open_ssid_hex (void) NM_SETTING_WIRELESS_SETTING_NAME); /* SSID */ - array = nm_setting_wireless_get_ssid (s_wireless); - ASSERT (array != NULL, + ssid = nm_setting_wireless_get_ssid (s_wireless); + ASSERT (ssid != NULL, "wifi-open-ssid-hex-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_OPEN_SSID_HEX, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (array->len == strlen (expected_ssid), + ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid), "wifi-open-ssid-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", TEST_IFCFG_WIFI_OPEN_SSID_HEX, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0, + ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0, "wifi-open-ssid-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_OPEN_SSID_HEX, NM_SETTING_WIRELESS_SETTING_NAME, @@ -3511,7 +2962,6 @@ test_read_wifi_open_ssid_bad (const char *file, const char *test) connection = connection_from_file (file, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -3542,14 +2992,13 @@ test_read_wifi_open_ssid_quoted (void) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - const GByteArray *array; + GBytes *ssid; const char *expected_id = "System foo\"bar\\ (test-wifi-open-ssid-quoted)"; const char *expected_ssid = "foo\"bar\\"; connection = connection_from_file (TEST_IFCFG_WIFI_OPEN_SSID_QUOTED, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -3592,18 +3041,18 @@ test_read_wifi_open_ssid_quoted (void) NM_SETTING_WIRELESS_SETTING_NAME); /* SSID */ - array = nm_setting_wireless_get_ssid (s_wireless); - ASSERT (array != NULL, + ssid = nm_setting_wireless_get_ssid (s_wireless); + ASSERT (ssid != NULL, "wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_OPEN_SSID_QUOTED, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (array->len == strlen (expected_ssid), + ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid), "wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", TEST_IFCFG_WIFI_OPEN_SSID_QUOTED, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0, + ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0, "wifi-open-ssid-quoted-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_OPEN_SSID_QUOTED, NM_SETTING_WIRELESS_SETTING_NAME, @@ -3625,7 +3074,7 @@ test_read_wifi_wep (void) NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -3633,7 +3082,8 @@ test_read_wifi_wep (void) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - const GByteArray *array; + GBytes *ssid; + const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 }; const char *expected_id = "System blahblah (test-wifi-wep)"; guint64 expected_timestamp = 0; @@ -3646,7 +3096,6 @@ test_read_wifi_wep (void) connection = connection_from_file (TEST_IFCFG_WIFI_WEP, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -3708,18 +3157,13 @@ test_read_wifi_wep (void) NM_SETTING_WIRELESS_SETTING_NAME); /* MAC address */ - array = nm_setting_wireless_get_mac_address (s_wireless); - ASSERT (array != NULL, + mac = nm_setting_wireless_get_mac_address (s_wireless); + ASSERT (mac != NULL, "wifi-wep-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_WEP, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS); - ASSERT (array->len == ETH_ALEN, - "wifi-wep-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", - TEST_IFCFG_WIFI_WEP, - NM_SETTING_WIRELESS_SETTING_NAME, - NM_SETTING_WIRELESS_MAC_ADDRESS); - ASSERT (memcmp (array->data, &expected_mac_address[0], sizeof (expected_mac_address)) == 0, + ASSERT (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, sizeof (expected_mac_address)), "wifi-wep-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WEP, NM_SETTING_WIRELESS_SETTING_NAME, @@ -3733,18 +3177,18 @@ test_read_wifi_wep (void) NM_SETTING_WIRELESS_MTU); /* SSID */ - array = nm_setting_wireless_get_ssid (s_wireless); - ASSERT (array != NULL, + ssid = nm_setting_wireless_get_ssid (s_wireless); + ASSERT (ssid != NULL, "wifi-wep-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_WEP, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (array->len == strlen (expected_ssid), + ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid), "wifi-wep-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", TEST_IFCFG_WIFI_WEP, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0, + ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0, "wifi-wep-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WEP, NM_SETTING_WIRELESS_SETTING_NAME, @@ -3865,12 +3309,12 @@ test_read_wifi_wep (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-wep-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WEP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); g_free (unmanaged); g_free (keyfile); @@ -3888,7 +3332,7 @@ test_read_wifi_wep_adhoc (void) NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -3896,19 +3340,15 @@ test_read_wifi_wep_adhoc (void) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - const GByteArray *array; + GBytes *ssid; const char *expected_id = "System blahblah (test-wifi-wep-adhoc)"; const char *expected_ssid = "blahblah"; const char *expected_mode = "adhoc"; const char *expected_wep_key0 = "0123456789abcdef0123456789"; - guint32 addr; - const char *expected_dns1 = "4.2.2.1"; - const char *expected_dns2 = "4.2.2.2"; connection = connection_from_file (TEST_IFCFG_WIFI_WEP_ADHOC, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -3963,18 +3403,18 @@ test_read_wifi_wep_adhoc (void) NM_SETTING_WIRELESS_SETTING_NAME); /* SSID */ - array = nm_setting_wireless_get_ssid (s_wireless); - ASSERT (array != NULL, + ssid = nm_setting_wireless_get_ssid (s_wireless); + ASSERT (ssid != NULL, "wifi-wep-adhoc-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_WEP_ADHOC, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (array->len == strlen (expected_ssid), + ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid), "wifi-wep-adhoc-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", TEST_IFCFG_WIFI_WEP_ADHOC, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0, + ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0, "wifi-wep-adhoc-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WEP_ADHOC, NM_SETTING_WIRELESS_SETTING_NAME, @@ -4083,48 +3523,38 @@ test_read_wifi_wep_adhoc (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-wep-adhoc-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WEP_ADHOC, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* Ignore auto DNS */ - ASSERT (nm_setting_ip4_config_get_ignore_auto_dns (s_ip4) == TRUE, + ASSERT (nm_setting_ip_config_get_ignore_auto_dns (s_ip4) == TRUE, "wifi-wep-adhoc-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WEP_ADHOC, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS); + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS); /* DNS Addresses */ - ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 2, + ASSERT (nm_setting_ip_config_get_num_dns (s_ip4) == 2, "wifi-wep-adhoc-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WEP_ADHOC, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET, expected_dns1, &addr) > 0, - "wifi-wep-adhoc-verify-ip4", "failed to verify %s: couldn't convert DNS IP address #1", - TEST_IFCFG_WIFI_WEP_ADHOC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr, + ASSERT (strcmp (nm_setting_ip_config_get_dns (s_ip4, 0), "4.2.2.1") == 0, "wifi-wep-adhoc-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1", TEST_IFCFG_WIFI_WEP_ADHOC, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET, expected_dns2, &addr) > 0, - "wifi-wep-adhoc-verify-ip4", "failed to verify %s: couldn't convert DNS IP address #2", - TEST_IFCFG_WIFI_WEP_ADHOC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr, + ASSERT (strcmp (nm_setting_ip_config_get_dns (s_ip4, 1), "4.2.2.2") == 0, "wifi-wep-adhoc-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2", TEST_IFCFG_WIFI_WEP_ADHOC, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); g_free (unmanaged); g_free (keyfile); @@ -4155,7 +3585,6 @@ test_read_wifi_wep_passphrase (void) connection = connection_from_file (TEST_IFCFG_WIFI_WEP_PASSPHRASE, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -4281,7 +3710,6 @@ test_read_wifi_wep_40_ascii (void) connection = connection_from_file (TEST_IFCFG_WIFI_WEP_40_ASCII, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -4405,7 +3833,6 @@ test_read_wifi_wep_104_ascii (void) connection = connection_from_file (TEST_IFCFG_WIFI_WEP_104_ASCII, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -4530,7 +3957,6 @@ test_read_wifi_leap (void) connection = connection_from_file (TEST_IFCFG_WIFI_LEAP, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -4654,7 +4080,6 @@ test_read_wifi_leap_secret_flags (const char *file, NMSettingSecretFlags expecte connection = connection_from_file (file, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -4699,7 +4124,7 @@ test_read_wifi_wpa_psk (void) NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -4707,7 +4132,8 @@ test_read_wifi_wpa_psk (void) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - const GByteArray *array; + GBytes *ssid; + const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 }; const char *expected_id = "System blahblah (test-wifi-wpa-psk)"; guint64 expected_timestamp = 0; @@ -4729,7 +4155,6 @@ test_read_wifi_wpa_psk (void) connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -4791,18 +4216,13 @@ test_read_wifi_wpa_psk (void) NM_SETTING_WIRELESS_SETTING_NAME); /* MAC address */ - array = nm_setting_wireless_get_mac_address (s_wireless); - ASSERT (array != NULL, + mac = nm_setting_wireless_get_mac_address (s_wireless); + ASSERT (mac != NULL, "wifi-wpa-psk-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_WPA_PSK, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS); - ASSERT (array->len == ETH_ALEN, - "wifi-wpa-psk-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", - TEST_IFCFG_WIFI_WPA_PSK, - NM_SETTING_WIRELESS_SETTING_NAME, - NM_SETTING_WIRELESS_MAC_ADDRESS); - ASSERT (memcmp (array->data, &expected_mac_address[0], sizeof (expected_mac_address)) == 0, + ASSERT (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, sizeof (expected_mac_address)), "wifi-wpa-psk-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WPA_PSK, NM_SETTING_WIRELESS_SETTING_NAME, @@ -4816,18 +4236,18 @@ test_read_wifi_wpa_psk (void) NM_SETTING_WIRELESS_MTU); /* SSID */ - array = nm_setting_wireless_get_ssid (s_wireless); - ASSERT (array != NULL, + ssid = nm_setting_wireless_get_ssid (s_wireless); + ASSERT (ssid != NULL, "wifi-wpa-psk-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_WPA_PSK, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (array->len == strlen (expected_ssid), + ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid), "wifi-wpa-psk-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", TEST_IFCFG_WIFI_WPA_PSK, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0, + ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0, "wifi-wpa-psk-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WPA_PSK, NM_SETTING_WIRELESS_SETTING_NAME, @@ -4982,12 +4402,12 @@ test_read_wifi_wpa_psk (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-wpa-psk-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WPA_PSK, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); g_free (unmanaged); g_free (keyfile); @@ -5018,7 +4438,6 @@ test_read_wifi_wpa_psk_2 (void) connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_2, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -5110,7 +4529,6 @@ test_read_wifi_wpa_psk_unquoted (void) connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -5200,7 +4618,6 @@ test_read_wifi_wpa_psk_unquoted2 (void) connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED2, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -5226,7 +4643,7 @@ test_read_wifi_wpa_psk_adhoc (void) NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -5244,7 +4661,6 @@ test_read_wifi_wpa_psk_adhoc (void) connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_ADHOC, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -5382,12 +4798,12 @@ test_read_wifi_wpa_psk_adhoc (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-wpa-psk-adhoc-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WPA_PSK_ADHOC, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); g_free (unmanaged); g_free (keyfile); @@ -5405,7 +4821,7 @@ test_read_wifi_wpa_psk_hex (void) NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -5413,7 +4829,7 @@ test_read_wifi_wpa_psk_hex (void) gboolean ignore_error = FALSE; GError *error = NULL; const char *tmp; - const GByteArray *array; + GBytes *ssid; const char *expected_id = "System blahblah (test-wifi-wpa-psk-hex)"; const char *expected_ssid = "blahblah"; const char *expected_key_mgmt = "wpa-psk"; @@ -5422,7 +4838,6 @@ test_read_wifi_wpa_psk_hex (void) connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_HEX, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -5465,18 +4880,18 @@ test_read_wifi_wpa_psk_hex (void) NM_SETTING_WIRELESS_SETTING_NAME); /* SSID */ - array = nm_setting_wireless_get_ssid (s_wireless); - ASSERT (array != NULL, + ssid = nm_setting_wireless_get_ssid (s_wireless); + ASSERT (ssid != NULL, "wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: missing %s / %s key", TEST_IFCFG_WIFI_WPA_PSK_HEX, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (array->len == strlen (expected_ssid), + ASSERT (g_bytes_get_size (ssid) == strlen (expected_ssid), "wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value length", TEST_IFCFG_WIFI_WPA_PSK_HEX, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - ASSERT (memcmp (array->data, expected_ssid, strlen (expected_ssid)) == 0, + ASSERT (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0, "wifi-wpa-psk-hex-verify-wireless", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WPA_PSK_HEX, NM_SETTING_WIRELESS_SETTING_NAME, @@ -5525,12 +4940,12 @@ test_read_wifi_wpa_psk_hex (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-wpa-psk-hex-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WPA_PSK_HEX, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); g_free (unmanaged); g_free (keyfile); @@ -5549,7 +4964,7 @@ test_read_wifi_wpa_eap_tls (void) { NMConnection *connection; NMSettingWireless *s_wireless; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; NMSetting8021x *s_8021x; char *unmanaged = NULL; char *keyfile = NULL; @@ -5564,7 +4979,6 @@ test_read_wifi_wpa_eap_tls (void) connection = connection_from_file (TEST_IFCFG_WIFI_WPA_EAP_TLS, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -5597,12 +5011,12 @@ test_read_wifi_wpa_eap_tls (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-wpa-eap-tls-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WPA_EAP_TLS, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* ===== 802.1x SETTING ===== */ s_8021x = nm_connection_get_setting_802_1x (connection); @@ -5690,7 +5104,7 @@ test_read_wifi_wpa_eap_ttls_tls (void) { NMConnection *connection; NMSettingWireless *s_wireless; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; NMSetting8021x *s_8021x; char *unmanaged = NULL; char *keyfile = NULL; @@ -5705,7 +5119,6 @@ test_read_wifi_wpa_eap_ttls_tls (void) connection = connection_from_file (TEST_IFCFG_WIFI_WPA_EAP_TTLS_TLS, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -5738,12 +5151,12 @@ test_read_wifi_wpa_eap_ttls_tls (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-wpa-eap-ttls-tls-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WPA_EAP_TTLS_TLS, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* ===== 802.1x SETTING ===== */ s_8021x = nm_connection_get_setting_802_1x (connection); @@ -5860,7 +5273,6 @@ test_read_wifi_dynamic_wep_leap (void) connection = connection_from_file (TEST_IFCFG_WIFI_DYNAMIC_WEP_LEAP, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -5923,7 +5335,7 @@ test_read_wifi_wep_eap_ttls_chap (void) NMConnection *connection; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; NMSetting8021x *s_8021x; char *unmanaged = NULL; char *keyfile = NULL; @@ -5939,7 +5351,6 @@ test_read_wifi_wep_eap_ttls_chap (void) connection = connection_from_file (TEST_IFCFG_WIFI_WEP_EAP_TTLS_CHAP, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -5972,12 +5383,12 @@ test_read_wifi_wep_eap_ttls_chap (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "wifi-wep-eap-ttls-chap-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIFI_WEP_EAP_TTLS_CHAP, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* ===== 802.1x SETTING ===== */ s_wsec = nm_connection_get_setting_wireless_security (connection); @@ -6086,7 +5497,7 @@ test_read_wifi_hidden (void) GError *error = NULL; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-hidden", - NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); @@ -6115,10 +5526,10 @@ test_write_wifi_hidden (void) gboolean success; GError *error = NULL; shvarFile *f; - GByteArray *ssid; + GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -6136,8 +5547,7 @@ test_write_wifi_hidden (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -6145,7 +5555,7 @@ test_write_wifi_hidden (void) NM_SETTING_WIRELESS_HIDDEN, TRUE, NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -6171,10 +5581,124 @@ test_write_wifi_hidden (void) svCloseFile (f); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, + NULL, NULL, NULL, NULL, &error, NULL); + unlink (testfile); + g_assert_no_error (error); + g_assert (reread); + + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + g_assert (success); + + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + g_free (testfile); + g_object_unref (connection); + g_object_unref (reread); +} + +static void +test_read_wifi_band_a (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + gboolean success; + GError *error = NULL; + + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-a", + NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &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_connection_type (s_con), ==, NM_SETTING_WIRELESS_SETTING_NAME); + + s_wifi = nm_connection_get_setting_wireless (connection); + g_assert (s_wifi); + g_assert_cmpstr (nm_setting_wireless_get_band (s_wifi), ==, "a"); + + g_object_unref (connection); +} + +static void +test_write_wifi_band_a (void) +{ + NMConnection *connection, *reread; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + char *uuid, *testfile = NULL, *val; + gboolean success; + GError *error = NULL; + shvarFile *f; + GBytes *ssid; + const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; + + connection = nm_simple_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 Write WiFi Band A", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wifi setting */ + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); + + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_MODE, "infrastructure", + NM_SETTING_WIRELESS_BAND, "a", + NULL); + + g_bytes_unref (ssid); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Save the ifcfg */ + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile, + &error); + g_assert_no_error (error); + g_assert (success); + + f = svOpenFile (testfile, &error); + g_assert_no_error (error); + g_assert (f); + + /* re-read the file to check that what key was written. */ + val = svGetValue (f, "BAND", FALSE); + g_assert (val); + g_assert_cmpstr (val, ==, "a"); + g_free (val); + svCloseFile (f); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ - reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL, + reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); unlink (testfile); g_assert_no_error (error); @@ -6191,6 +5715,30 @@ test_write_wifi_hidden (void) g_object_unref (reread); } +static void +test_read_wifi_band_a_channel_mismatch (void) +{ + NMConnection *connection; + GError *error = NULL; + + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-a-channel-mismatch", + NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); + g_assert (connection == NULL); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); +} + +static void +test_read_wifi_band_bg_channel_mismatch (void) +{ + NMConnection *connection; + GError *error = NULL; + + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-bg-channel-mismatch", + NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); + g_assert (connection == NULL); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); +} + #define TEST_IFCFG_WIRED_QETH_STATIC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-qeth-static" static void @@ -6199,7 +5747,7 @@ test_read_wired_qeth_static (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; @@ -6208,16 +5756,15 @@ test_read_wired_qeth_static (void) GError *error = NULL; const char *tmp; const char *expected_id = "System test-wired-qeth-static"; - const GByteArray *array; + const char *mac; const char *expected_channel0 = "0.0.0600"; const char *expected_channel1 = "0.0.0601"; const char *expected_channel2 = "0.0.0602"; - const GPtrArray *subchannels; + const char * const *subchannels; connection = connection_from_file (TEST_IFCFG_WIRED_QETH_STATIC, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -6263,8 +5810,8 @@ test_read_wired_qeth_static (void) NM_SETTING_WIRED_SETTING_NAME); /* MAC address */ - array = nm_setting_wired_get_mac_address (s_wired); - ASSERT (array == NULL, + mac = nm_setting_wired_get_mac_address (s_wired); + ASSERT (mac == NULL, "wired-qeth-static-verify-wired", "failed to verify %s: unexpected %s / %s key", TEST_IFCFG_WIRED_QETH_STATIC, NM_SETTING_WIRED_SETTING_NAME, @@ -6277,24 +5824,19 @@ test_read_wired_qeth_static (void) TEST_IFCFG_WIRED_QETH_STATIC, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS); - ASSERT (subchannels->len == 3, + ASSERT (subchannels[0] && subchannels[1] && subchannels[2] && !subchannels[3], "wired-qeth-static-verify-wired", "failed to verify %s: invalid %s / %s key (not 3 elements)", TEST_IFCFG_WIRED_QETH_STATIC, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS); - tmp = (const char *) g_ptr_array_index (subchannels, 0); - ASSERT (strcmp (tmp, expected_channel0) == 0, + ASSERT (strcmp (subchannels[0], expected_channel0) == 0, "wired-qeth-static-verify-wired", "failed to verify %s: unexpected subchannel #0", TEST_IFCFG_WIRED_QETH_STATIC); - - tmp = (const char *) g_ptr_array_index (subchannels, 1); - ASSERT (strcmp (tmp, expected_channel1) == 0, + ASSERT (strcmp (subchannels[1], expected_channel1) == 0, "wired-qeth-static-verify-wired", "failed to verify %s: unexpected subchannel #1", TEST_IFCFG_WIRED_QETH_STATIC); - - tmp = (const char *) g_ptr_array_index (subchannels, 2); - ASSERT (strcmp (tmp, expected_channel2) == 0, + ASSERT (strcmp (subchannels[2], expected_channel2) == 0, "wired-qeth-static-verify-wired", "failed to verify %s: unexpected subchannel #2", TEST_IFCFG_WIRED_QETH_STATIC); @@ -6353,12 +5895,12 @@ test_read_wired_qeth_static (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, "wired-qeth-static-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_WIRED_QETH_STATIC, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); g_free (unmanaged); g_free (keyfile); @@ -6385,13 +5927,12 @@ test_read_wired_ctc_static (void) const char *expected_id = "System test-wired-ctc-static"; const char *expected_channel0 = "0.0.1b00"; const char *expected_channel1 = "0.0.1b01"; - const GPtrArray *subchannels; + const char * const *subchannels; gboolean success; connection = connection_from_file (TEST_IFCFG_WIRED_CTC_STATIC, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -6420,10 +5961,10 @@ test_read_wired_ctc_static (void) /* Subchannels */ subchannels = nm_setting_wired_get_s390_subchannels (s_wired); g_assert (subchannels != NULL); - g_assert_cmpint (subchannels->len, ==, 2); + g_assert (subchannels[0] && subchannels[1] && !subchannels[2]); - g_assert_cmpstr (g_ptr_array_index (subchannels, 0), ==, expected_channel0); - g_assert_cmpstr (g_ptr_array_index (subchannels, 1), ==, expected_channel1); + g_assert_cmpstr (subchannels[0], ==, expected_channel0); + g_assert_cmpstr (subchannels[1], ==, expected_channel1); /* Nettype */ g_assert_cmpstr (nm_setting_wired_get_s390_nettype (s_wired), ==, "ctc"); @@ -6462,7 +6003,6 @@ test_read_wifi_wep_no_keys (void) connection = connection_from_file (TEST_IFCFG_WIFI_WEP_NO_KEYS, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -6572,7 +6112,6 @@ test_read_permissions (void) connection = connection_from_file (TEST_IFCFG_PERMISSIONS, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -6648,7 +6187,6 @@ test_read_wifi_wep_agent_keys (void) connection = connection_from_file (TEST_IFCFG_WIFI_WEP_AGENT_KEYS, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -6699,30 +6237,22 @@ test_write_wired_static (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4, *reread_s_ip4; - NMSettingIP6Config *s_ip6, *reread_s_ip6; - static unsigned char tmpmac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd }; - GByteArray *mac; + NMSettingIPConfig *s_ip4, *reread_s_ip4; + NMSettingIPConfig *s_ip6, *reread_s_ip6; + static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; char *uuid; - const guint32 ip1 = htonl (0x01010103); - const guint32 ip2 = htonl (0x01010105); - const guint32 gw = htonl (0x01010101); - const guint32 dns1 = htonl (0x04020201); - const guint32 dns2 = htonl (0x04020202); - const guint32 prefix = 24; + const char *dns1 = "4.2.2.1"; + const char *dns2 = "4.2.2.2"; const char *dns_search1 = "foobar.com"; const char *dns_search2 = "lab.foobar.com"; const char *dns_search3 = "foobar6.com"; const char *dns_search4 = "lab6.foobar.com"; - struct in6_addr ip6, ip6_1, ip6_2; - struct in6_addr route1_dest, route2_dest, route1_nexthop, route2_nexthop; - struct in6_addr dns6_1, dns6_2; - const guint32 route1_prefix = 64, route2_prefix = 128; - const guint32 route1_metric = 99, route2_metric = 1; - NMIP4Address *addr; - NMIP6Address *addr6; - NMIP6Route *route6; + const char *dns6_1 = "fade:0102:0103::face"; + const char *dns6_2 = "cafe:ffff:eeee:dddd:cccc:bbbb:aaaa:feed"; + NMIPAddress *addr; + NMIPAddress *addr6; + NMIPRoute *route6; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -6732,17 +6262,7 @@ test_write_wired_static (void) char *route6file = NULL; gboolean ignore_error = FALSE; - inet_pton (AF_INET6, "1003:1234:abcd::1", &ip6); - inet_pton (AF_INET6, "2003:1234:abcd::2", &ip6_1); - inet_pton (AF_INET6, "3003:1234:abcd::3", &ip6_2); - inet_pton (AF_INET6, "2222:aaaa:bbbb:cccc::", &route1_dest); - inet_pton (AF_INET6, "2222:aaaa:bbbb:cccc:dddd:eeee:5555:6666", &route1_nexthop); - inet_pton (AF_INET6, "::", &route2_dest); - inet_pton (AF_INET6, "2222:aaaa::9999", &route2_nexthop); - inet_pton (AF_INET6, "fade:0102:0103::face", &dns6_1); - inet_pton (AF_INET6, "cafe:ffff:eeee:dddd:cccc:bbbb:aaaa:feed", &dns6_2); - - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -6761,96 +6281,82 @@ test_write_wired_static (void) s_wired = (NMSettingWired *) nm_setting_wired_new (); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - mac = g_byte_array_sized_new (sizeof (tmpmac)); - g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac)); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NM_SETTING_WIRED_MTU, mtu, NULL); - g_byte_array_free (mac, TRUE); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_MANUAL, - NM_SETTING_IP4_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", NULL); - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip1); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip2); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.5", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); - nm_setting_ip4_config_add_dns (s_ip4, dns1); - nm_setting_ip4_config_add_dns (s_ip4, dns2); + nm_setting_ip_config_add_dns (s_ip4, dns1); + nm_setting_ip_config_add_dns (s_ip4, dns2); - nm_setting_ip4_config_add_dns_search (s_ip4, dns_search1); - nm_setting_ip4_config_add_dns_search (s_ip4, dns_search2); + nm_setting_ip_config_add_dns_search (s_ip4, dns_search1); + nm_setting_ip_config_add_dns_search (s_ip4, dns_search2); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); /* Add addresses */ - addr6 = nm_ip6_address_new (); - nm_ip6_address_set_address (addr6, &ip6); - nm_ip6_address_set_prefix (addr6, 11); - nm_setting_ip6_config_add_address (s_ip6, addr6); - nm_ip6_address_unref (addr6); - - addr6 = nm_ip6_address_new (); - nm_ip6_address_set_address (addr6, &ip6_1); - nm_ip6_address_set_prefix (addr6, 22); - nm_setting_ip6_config_add_address (s_ip6, addr6); - nm_ip6_address_unref (addr6); - - addr6 = nm_ip6_address_new (); - nm_ip6_address_set_address (addr6, &ip6_2); - nm_ip6_address_set_prefix (addr6, 33); - nm_setting_ip6_config_add_address (s_ip6, addr6); - nm_ip6_address_unref (addr6); + addr6 = nm_ip_address_new (AF_INET6, "1003:1234:abcd::1", 11, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip6, addr6); + nm_ip_address_unref (addr6); + + addr6 = nm_ip_address_new (AF_INET6, "2003:1234:abcd::2", 22, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip6, addr6); + nm_ip_address_unref (addr6); + + addr6 = nm_ip_address_new (AF_INET6, "3003:1234:abcd::3", 33, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip6, addr6); + nm_ip_address_unref (addr6); /* Add routes */ - route6 = nm_ip6_route_new (); - nm_ip6_route_set_dest (route6, &route1_dest); - nm_ip6_route_set_prefix (route6, route1_prefix); - nm_ip6_route_set_next_hop (route6, &route1_nexthop); - nm_ip6_route_set_metric (route6, route1_metric); - nm_setting_ip6_config_add_route (s_ip6, route6); - nm_ip6_route_unref (route6); - - route6 = nm_ip6_route_new (); - nm_ip6_route_set_dest (route6, &route2_dest); - nm_ip6_route_set_prefix (route6, route2_prefix); - nm_ip6_route_set_next_hop (route6, &route2_nexthop); - nm_ip6_route_set_metric (route6, route2_metric); - nm_setting_ip6_config_add_route (s_ip6, route6); - nm_ip6_route_unref (route6); + route6 = nm_ip_route_new (AF_INET6, + "2222:aaaa:bbbb:cccc::", 64, + "2222:aaaa:bbbb:cccc:dddd:eeee:5555:6666", 99, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_route (s_ip6, route6); + nm_ip_route_unref (route6); + + route6 = nm_ip_route_new (AF_INET6, "::", 128, "2222:aaaa::9999", 1, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_route (s_ip6, route6); + nm_ip_route_unref (route6); /* DNS servers */ - nm_setting_ip6_config_add_dns (s_ip6, &dns6_1); - nm_setting_ip6_config_add_dns (s_ip6, &dns6_2); + nm_setting_ip_config_add_dns (s_ip6, dns6_1); + nm_setting_ip_config_add_dns (s_ip6, dns6_2); /* DNS domains */ - nm_setting_ip6_config_add_dns_search (s_ip6, dns_search3); - nm_setting_ip6_config_add_dns_search (s_ip6, dns_search4); + nm_setting_ip_config_add_dns_search (s_ip6, dns_search3); + nm_setting_ip_config_add_dns_search (s_ip6, dns_search4); ASSERT (nm_connection_verify (connection, &error) == TRUE, "wired-static-write", "failed to verify connection: %s", @@ -6869,13 +6375,12 @@ test_write_wired_static (void) "wired-static-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -6896,10 +6401,10 @@ test_write_wired_static (void) */ reread_s_ip4 = nm_connection_get_setting_ip4_config (reread); reread_s_ip6 = nm_connection_get_setting_ip6_config (reread); - nm_setting_ip6_config_add_dns_search (reread_s_ip6, nm_setting_ip4_config_get_dns_search (reread_s_ip4, 2)); - nm_setting_ip6_config_add_dns_search (reread_s_ip6, nm_setting_ip4_config_get_dns_search (reread_s_ip4, 3)); - nm_setting_ip4_config_remove_dns_search (reread_s_ip4, 3); - nm_setting_ip4_config_remove_dns_search (reread_s_ip4, 2); + nm_setting_ip_config_add_dns_search (reread_s_ip6, nm_setting_ip_config_get_dns_search (reread_s_ip4, 2)); + nm_setting_ip_config_add_dns_search (reread_s_ip6, nm_setting_ip_config_get_dns_search (reread_s_ip4, 3)); + nm_setting_ip_config_remove_dns_search (reread_s_ip4, 3); + nm_setting_ip_config_remove_dns_search (reread_s_ip4, 2); ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE, "wired-static-write", "written and re-read connection weren't the same."); @@ -6923,8 +6428,8 @@ test_write_wired_dhcp (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -6935,7 +6440,7 @@ test_write_wired_dhcp (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -6955,15 +6460,15 @@ test_write_wired_dhcp (void) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, "random-client-id-00:22:33", - NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, "awesome-hostname", - NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, TRUE, - NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, TRUE, + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, "awesome-hostname", + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, TRUE, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -6971,12 +6476,12 @@ test_write_wired_dhcp (void) (error && error->message) ? error->message : "(unknown)"); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); /* Save the ifcfg */ @@ -6992,13 +6497,12 @@ test_write_wired_dhcp (void) "wired-dhcp-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -7034,7 +6538,7 @@ test_write_wired_dhcp_plus_ip (void) gboolean success = FALSE; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-plus-ip", - NULL, TYPE_ETHERNET, NULL, NULL, + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection != NULL); @@ -7046,10 +6550,10 @@ test_write_wired_dhcp_plus_ip (void) g_assert (success); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ - reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL, NULL, + reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); unlink (written); g_free (written); @@ -7072,15 +6576,15 @@ static void test_read_write_wired_dhcp_send_hostname (void) { NMConnection *connection, *reread; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; const char * dhcp_hostname = "kamil-patka"; char *written = NULL; GError *error = NULL; gboolean success = FALSE; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-send-hostname", - NULL, TYPE_ETHERNET, NULL, NULL, + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection != NULL); @@ -7090,14 +6594,14 @@ test_read_write_wired_dhcp_send_hostname (void) s_ip6 = nm_connection_get_setting_ip6_config (connection); g_assert (s_ip4); g_assert (s_ip6); - g_assert (nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4) == TRUE); - g_assert_cmpstr (nm_setting_ip4_config_get_dhcp_hostname (s_ip4), ==, "svata-pulec"); - g_assert_cmpstr (nm_setting_ip6_config_get_dhcp_hostname (s_ip6), ==, "svata-pulec"); + g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) == TRUE); + g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, "svata-pulec"); + g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, "svata-pulec"); /* Set dhcp-send-hostname=false dhcp-hostname="kamil-patka" and write the connection. */ - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME, FALSE, NULL); - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, dhcp_hostname, NULL); - g_object_set (s_ip6, NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, dhcp_hostname, NULL); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, FALSE, NULL); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, dhcp_hostname, NULL); + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, dhcp_hostname, NULL); success = writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", @@ -7106,10 +6610,10 @@ test_read_write_wired_dhcp_send_hostname (void) g_assert (success); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ - reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL, NULL, + reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); unlink (written); g_free (written); @@ -7129,9 +6633,9 @@ test_read_write_wired_dhcp_send_hostname (void) s_ip6 = nm_connection_get_setting_ip6_config (reread); g_assert (s_ip4); g_assert (s_ip6); - g_assert (nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4) == FALSE); - g_assert_cmpstr (nm_setting_ip4_config_get_dhcp_hostname (s_ip4), ==, dhcp_hostname); - g_assert_cmpstr (nm_setting_ip6_config_get_dhcp_hostname (s_ip6), ==, dhcp_hostname); + g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) == FALSE); + g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, dhcp_hostname); + g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, dhcp_hostname); g_object_unref (connection); g_object_unref (reread); @@ -7144,14 +6648,12 @@ test_write_wired_static_ip6_only (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; - static unsigned char tmpmac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd }; - GByteArray *mac; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + static const char *mac = "31:33:33:37:be:cd"; char *uuid; - struct in6_addr ip6; - struct in6_addr dns6; - NMIP6Address *addr6; + const char *dns6 = "fade:0102:0103::face"; + NMIPAddress *addr6; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -7161,10 +6663,7 @@ test_write_wired_static_ip6_only (void) char *route6file = NULL; gboolean ignore_error = FALSE; - inet_pton (AF_INET6, "1003:1234:abcd::1", &ip6); - inet_pton (AF_INET6, "fade:0102:0103::face", &dns6); - - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -7183,36 +6682,32 @@ test_write_wired_static_ip6_only (void) s_wired = (NMSettingWired *) nm_setting_wired_new (); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - mac = g_byte_array_sized_new (sizeof (tmpmac)); - g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac)); g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL); - g_byte_array_free (mac, TRUE); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_DISABLED, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, NULL); /* Add addresses */ - addr6 = nm_ip6_address_new (); - nm_ip6_address_set_address (addr6, &ip6); - nm_ip6_address_set_prefix (addr6, 11); - nm_setting_ip6_config_add_address (s_ip6, addr6); - nm_ip6_address_unref (addr6); + addr6 = nm_ip_address_new (AF_INET6, "1003:1234:abcd::1", 11, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip6, addr6); + nm_ip_address_unref (addr6); /* DNS server */ - nm_setting_ip6_config_add_dns (s_ip6, &dns6); + nm_setting_ip_config_add_dns (s_ip6, dns6); ASSERT (nm_connection_verify (connection, &error) == TRUE, "wired-static-ip6-only-write", "failed to verify connection: %s", @@ -7231,13 +6726,12 @@ test_write_wired_static_ip6_only (void) "wired-static-ip6-only-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -7282,44 +6776,28 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; - static unsigned char tmpmac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd }; - GByteArray *mac; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + static const char *mac = "31:33:33:37:be:cd"; char *uuid; - struct in6_addr ip6; - struct in6_addr dns6; - NMIP6Address *addr6; + const char *dns6 = "fade:0102:0103::face"; + NMIPAddress *addr6; gboolean success; GError *error = NULL; char *testfile = NULL; char *id = NULL; gboolean ignore_error = FALSE; char *written_ifcfg_gateway; - char s_gateway6[INET6_ADDRSTRLEN] = { 0 }; - struct in6_addr gateway6_autovar; - const struct in6_addr *gateway6 = NULL; - - /* parsing the input argument and set the struct in6_addr "gateway6" to - * the gateway address. NULL means "do not set the gateway explicitly". */ - if (user_data) { - g_assert_cmpint (inet_pton (AF_INET6, user_data, &gateway6_autovar), ==, 1); - gateway6 = &gateway6_autovar; - } - - inet_pton (AF_INET6, "1003:1234:abcd::1", &ip6); - inet_pton (AF_INET6, "fade:0102:0103::face", &dns6); - if (gateway6) - inet_ntop (AF_INET6, gateway6, s_gateway6, sizeof (s_gateway6)); + const char *gateway6 = user_data; - connection = nm_connection_new (); + connection = nm_simple_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 (); - id = g_strdup_printf ("Test Write Wired Static IP6 Only With Gateway %s", gateway6 ? s_gateway6 : "NULL"); + id = g_strdup_printf ("Test Write Wired Static IP6 Only With Gateway %s", gateway6 ? gateway6 : "NULL"); g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, NM_SETTING_CONNECTION_UUID, uuid, @@ -7333,38 +6811,33 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) s_wired = (NMSettingWired *) nm_setting_wired_new (); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - mac = g_byte_array_sized_new (sizeof (tmpmac)); - g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac)); g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL); - g_byte_array_free (mac, TRUE); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_DISABLED, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, gateway6, NULL); /* Add addresses */ - addr6 = nm_ip6_address_new (); - nm_ip6_address_set_address (addr6, &ip6); - nm_ip6_address_set_prefix (addr6, 11); - if (gateway6) - nm_ip6_address_set_gateway (addr6, gateway6); - nm_setting_ip6_config_add_address (s_ip6, addr6); - nm_ip6_address_unref (addr6); + addr6 = nm_ip_address_new (AF_INET6, "1003:1234:abcd::1", 11, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip6, addr6); + nm_ip_address_unref (addr6); /* DNS server */ - nm_setting_ip6_config_add_dns (s_ip6, &dns6); + nm_setting_ip_config_add_dns (s_ip6, dns6); g_assert (nm_connection_verify (connection, &error)); @@ -7378,13 +6851,13 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) g_assert (testfile); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, &error, &ignore_error); @@ -7407,18 +6880,18 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) /* access the gateway from the loaded connection. */ s_ip6 = nm_connection_get_setting_ip6_config (reread); - g_assert (s_ip6 && nm_setting_ip6_config_get_num_addresses (s_ip6)==1); - addr6 = nm_setting_ip6_config_get_address (s_ip6, 0); + g_assert (s_ip6 && nm_setting_ip_config_get_num_addresses (s_ip6)==1); + addr6 = nm_setting_ip_config_get_address (s_ip6, 0); g_assert (addr6); /* assert that the gateway was written and reloaded as expected */ - if (!gateway6 || IN6_IS_ADDR_UNSPECIFIED (gateway6)) { - g_assert (IN6_IS_ADDR_UNSPECIFIED (nm_ip6_address_get_gateway (addr6))); - g_assert (written_ifcfg_gateway==NULL); + if (!gateway6 || !strcmp (gateway6, "::")) { + g_assert (nm_setting_ip_config_get_gateway (s_ip6) == NULL); + g_assert (written_ifcfg_gateway == NULL); } else { - g_assert (!IN6_IS_ADDR_UNSPECIFIED (nm_ip6_address_get_gateway (addr6))); - g_assert_cmpint (memcmp (nm_ip6_address_get_gateway (addr6), gateway6, sizeof (struct in6_addr)), ==, 0); - g_assert_cmpstr (written_ifcfg_gateway, ==, s_gateway6); + g_assert (nm_setting_ip_config_get_gateway (s_ip6) != NULL); + g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip6), ==, gateway6); + g_assert_cmpstr (written_ifcfg_gateway, ==, gateway6); } g_free (testfile); @@ -7435,7 +6908,7 @@ test_read_write_static_routes_legacy (void) NMConnection *connection, *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; char *testfile = NULL; char *keyfile = NULL; @@ -7452,7 +6925,6 @@ test_read_write_static_routes_legacy (void) connection = connection_from_file (TEST_IFCFG_READ_WRITE_STATIC_ROUTES_LEGACY, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -7507,18 +6979,18 @@ test_read_write_static_routes_legacy (void) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, "read-write-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_READ_WRITE_STATIC_ROUTES_LEGACY, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); - ASSERT (nm_setting_ip4_config_get_never_default (s_ip4) == FALSE, + ASSERT (nm_setting_ip_config_get_never_default (s_ip4) == FALSE, "read-write-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_READ_WRITE_STATIC_ROUTES_LEGACY, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_NEVER_DEFAULT); + NM_SETTING_IP_CONFIG_NEVER_DEFAULT); /* Save the ifcfg; use a special different scratch dir to ensure that * we can clean up after the written connection in both the original @@ -7536,13 +7008,12 @@ test_read_write_static_routes_legacy (void) "read-write-static-routes-legacy-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile2, &routefile2, @@ -7584,26 +7055,17 @@ test_write_wired_static_routes (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; - static unsigned char tmpmac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd }; - GByteArray *mac; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; char *uuid; - const guint32 ip1 = htonl (0x01010103); - const guint32 ip2 = htonl (0x01010105); - const guint32 gw = htonl (0x01010101); - const guint32 dns1 = htonl (0x04020201); - const guint32 dns2 = htonl (0x04020202); - const guint32 route_dst1 = htonl (0x01020300); - const guint32 route_dst2= htonl (0x03020100); - const guint32 route_gw1 = htonl (0xdeadbeef); - const guint32 route_gw2 = htonl (0xcafeabbe); - const guint32 prefix = 24; + const char *dns1 = "4.2.2.1"; + const char *dns2 = "4.2.2.2"; const char *dns_search1 = "foobar.com"; const char *dns_search2 = "lab.foobar.com"; - NMIP4Address *addr; - NMIP4Route *route; + NMIPAddress *addr; + NMIPRoute *route; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -7613,7 +7075,7 @@ test_write_wired_static_routes (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -7632,66 +7094,54 @@ test_write_wired_static_routes (void) s_wired = (NMSettingWired *) nm_setting_wired_new (); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - mac = g_byte_array_sized_new (sizeof (tmpmac)); - g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac)); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NM_SETTING_WIRED_MTU, mtu, NULL); - g_byte_array_free (mac, TRUE); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_MANUAL, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", NULL); - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip1); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip2); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.5", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); /* Write out routes */ - route = nm_ip4_route_new (); - nm_ip4_route_set_dest (route, route_dst1); - nm_ip4_route_set_prefix (route, prefix); - nm_ip4_route_set_next_hop (route, route_gw1); - nm_setting_ip4_config_add_route (s_ip4, route); - nm_ip4_route_unref (route); - - route = nm_ip4_route_new (); - nm_ip4_route_set_dest (route, route_dst2); - nm_ip4_route_set_prefix (route, prefix); - nm_ip4_route_set_next_hop (route, route_gw2); - nm_ip4_route_set_metric (route, 77); - nm_setting_ip4_config_add_route (s_ip4, route); - nm_ip4_route_unref (route); - - nm_setting_ip4_config_add_dns (s_ip4, dns1); - nm_setting_ip4_config_add_dns (s_ip4, dns2); - - nm_setting_ip4_config_add_dns_search (s_ip4, dns_search1); - nm_setting_ip4_config_add_dns_search (s_ip4, dns_search2); + route = nm_ip_route_new (AF_INET, "1.2.3.0", 24, "222.173.190.239", 0, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_route (s_ip4, route); + nm_ip_route_unref (route); + + route = nm_ip_route_new (AF_INET, "3.2.1.0", 24, "202.254.186.190", 77, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_route (s_ip4, route); + nm_ip_route_unref (route); + + nm_setting_ip_config_add_dns (s_ip4, dns1); + nm_setting_ip_config_add_dns (s_ip4, dns2); + + nm_setting_ip_config_add_dns_search (s_ip4, dns_search1); + nm_setting_ip_config_add_dns_search (s_ip4, dns_search2); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -7711,13 +7161,12 @@ test_write_wired_static_routes (void) "wired-static-routes-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -7755,8 +7204,8 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; NMSetting8021x *s_8021x; char *uuid; gboolean success; @@ -7768,7 +7217,7 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -7788,18 +7237,18 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); /* 802.1x setting */ @@ -7843,13 +7292,12 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) "wired-dhcp-8021x-peap-mschapv2write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -7910,8 +7358,8 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme, NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; NMSetting8021x *s_8021x; char *uuid; gboolean success; @@ -7926,7 +7374,7 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme, const char *pw; char *tmp; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection != NULL); /* Connection setting */ @@ -7949,17 +7397,17 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme, nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); @@ -8028,13 +7476,12 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme, g_assert (testfile != NULL); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -8125,14 +7572,12 @@ test_write_wired_aliases (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *uuid; int num_addresses = 4; - guint32 ip[] = { 0x01010101, 0x01010102, 0x01010103, 0x01010104 }; + const char *ip[] = { "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" }; const char *label[] = { NULL, "alias0:2", NULL, "alias0:3" }; - const guint32 gw = htonl (0x01010101); - const guint32 prefix = 24; - NMIP4Address *addr; + NMIPAddress *addr; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -8144,7 +7589,7 @@ test_write_wired_aliases (void) shvarFile *ifcfg; int i, j; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); ASSERT (connection != NULL, "wired-aliases-write", "failed to allocate new connection"); @@ -8171,24 +7616,25 @@ test_write_wired_aliases (void) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); ASSERT (s_ip4 != NULL, "wired-aliases-write", "failed to allocate new %s setting", NM_SETTING_IP4_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, - NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, - NM_SETTING_IP4_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); for (i = 0; i < num_addresses; i++) { - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip[i]); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, label[i])); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, ip[i], 24, &error); + g_assert_no_error (error); + if (label[i]) + nm_ip_address_set_attribute (addr, "label", g_variant_new_string (label[i])); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); } ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -8236,7 +7682,6 @@ test_write_wired_aliases (void) reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -8258,49 +7703,33 @@ test_write_wired_aliases (void) * verify the aliases manually. */ s_ip4 = nm_connection_get_setting_ip4_config (connection); - ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == num_addresses, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip4) == num_addresses, "wired-aliases-write-verify-ip4", "failed to verify %s: unexpected %s / %s key value", testfile, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); + NM_SETTING_IP_CONFIG_ADDRESSES); /* Addresses */ for (i = 0; i < num_addresses; i++) { - guint32 addrbytes; + const char *addrstr; - addr = nm_setting_ip4_config_get_address (s_ip4, i); - ASSERT (addr, - "wired-aliases-write-verify-ip4", "failed to verify %s: missing IP4 address #%d", - testfile, - i); + addr = nm_setting_ip_config_get_address (s_ip4, i); + g_assert (addr != NULL); - addrbytes = nm_ip4_address_get_address (addr); + addrstr = nm_ip_address_get_address (addr); for (j = 0; j < num_addresses; j++) { - if (addrbytes == ip[j]) + if (!g_strcmp0 (addrstr, ip[j])) break; } + g_assert (j < num_addresses); - ASSERT (j < num_addresses, - "wired-aliases-write-verify-ip4", "failed to verify %s: unexpected IP4 address #%d", - testfile, - i); - - ASSERT (nm_ip4_address_get_prefix (addr) == prefix, - "wired-aliases-write-verify-ip4", "failed to verify %s: unexpected IP4 address prefix #%d", - testfile, - i); - - ASSERT (nm_ip4_address_get_gateway (addr) == gw, - "wired-aliases-write-verify-ip4", "failed to verify %s: unexpected IP4 address gateway #%d", - testfile, - i); - - ASSERT (g_strcmp0 (NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)), label[j]) == 0, - "wired-aliases-write-verify-ip4", "failed to verify %s: unexpected IP4 address label #%d", - testfile, - i); + g_assert_cmpint (nm_ip_address_get_prefix (addr), ==, 24); + if (label[j]) + g_assert_cmpstr (g_variant_get_string (nm_ip_address_get_attribute (addr, "label"), NULL), ==, label[j]); + else + g_assert (nm_ip_address_get_attribute (addr, "label") == NULL); - ip[j] = 0; + ip[j] = NULL; } for (i = 0; i < num_addresses; i++) { @@ -8310,6 +7739,9 @@ test_write_wired_aliases (void) ip[i]); } + /* Gateway */ + g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "1.1.1.1"); + g_free (testfile); g_free (keyfile); g_free (routefile); @@ -8324,20 +7756,14 @@ test_write_gateway (void) NMConnection *connection, *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *uuid, *testfile = NULL, *val; gboolean success; GError *error = NULL; shvarFile *f; - NMIP4Address *addr; - const char *ip1_str = "1.1.1.3"; - const char *ip2_str = "2.2.2.5"; - const char *gw1_str = "1.1.1.254"; - const char *gw2_str = "2.2.2.254"; - struct in_addr ip1, ip2, gw1, gw2; - const guint32 prefix = 24; + NMIPAddress *addr; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -8356,32 +7782,24 @@ test_write_gateway (void) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_MANUAL, - NM_SETTING_IP4_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.254", + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); - inet_pton (AF_INET, ip1_str, &ip1); - inet_pton (AF_INET, ip2_str, &ip2); - inet_pton (AF_INET, gw1_str, &gw1); - inet_pton (AF_INET, gw2_str, &gw2); - - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip1.s_addr); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw1.s_addr); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip2.s_addr); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw2.s_addr); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "2.2.2.5", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -8402,12 +7820,12 @@ test_write_gateway (void) /* re-read the file to check that the keys was written as IPADDR, GATEWAY and IPADDR1, GATEWAY1 */ val = svGetValue (f, "IPADDR", FALSE); g_assert (val); - g_assert_cmpstr (val, ==, ip1_str); + g_assert_cmpstr (val, ==, "1.1.1.3"); g_free (val); val = svGetValue (f, "IPADDR1", FALSE); g_assert (val); - g_assert_cmpstr (val, ==, ip2_str); + g_assert_cmpstr (val, ==, "2.2.2.5"); g_free (val); val = svGetValue (f, "IPADDR0", FALSE); @@ -8428,25 +7846,22 @@ test_write_gateway (void) val = svGetValue (f, "GATEWAY", FALSE); g_assert (val); - g_assert_cmpstr (val, ==, gw1_str); - g_free (val); - - val = svGetValue (f, "GATEWAY1", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, gw2_str); + g_assert_cmpstr (val, ==, "1.1.1.254"); g_free (val); val = svGetValue (f, "GATEWAY0", FALSE); g_assert (val == NULL); + val = svGetValue (f, "GATEWAY1", FALSE); + g_assert (val == NULL); svCloseFile (f); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ - reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL, + reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); unlink (testfile); g_assert_no_error (error); @@ -8471,8 +7886,8 @@ test_write_wifi_open (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWireless *s_wifi; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -8482,17 +7897,15 @@ test_write_wifi_open (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; + GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; - GByteArray *bssid; - const unsigned char bssid_data[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }; + const char *bssid = "11:22:33:44:55:66"; guint32 channel = 9, mtu = 1345; - GByteArray *mac; - const unsigned char mac_data[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; + const char *mac = "aa:bb:cc:dd:ee:ff"; shvarFile *ifcfg; char *tmp; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -8511,12 +7924,7 @@ test_write_wifi_open (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); - bssid = g_byte_array_sized_new (sizeof (bssid_data)); - g_byte_array_append (bssid, bssid_data, sizeof (bssid_data)); - mac = g_byte_array_sized_new (sizeof (mac_data)); - g_byte_array_append (mac, mac_data, sizeof (mac_data)); + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -8528,23 +7936,21 @@ test_write_wifi_open (void) NM_SETTING_WIRELESS_MTU, mtu, NULL); - g_byte_array_free (ssid, TRUE); - g_byte_array_free (bssid, TRUE); - g_byte_array_free (mac, TRUE); + g_bytes_unref (ssid); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -8564,13 +7970,12 @@ test_write_wifi_open (void) "wifi-open-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -8621,8 +8026,8 @@ test_write_wifi_open_hex_ssid (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWireless *s_wifi; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -8632,10 +8037,10 @@ test_write_wifi_open_hex_ssid (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; + GBytes *ssid; const unsigned char ssid_data[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd }; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -8654,29 +8059,28 @@ test_write_wifi_open_hex_ssid (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -8696,13 +8100,12 @@ test_write_wifi_open_hex_ssid (void) "wifi-open-hex-ssid-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -8737,8 +8140,8 @@ test_write_wifi_wep (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -8748,11 +8151,11 @@ test_write_wifi_wep (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah"; + GBytes *ssid; + const char *ssid_data = "blahblah"; struct stat statbuf; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -8771,15 +8174,14 @@ test_write_wifi_wep (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -8796,18 +8198,18 @@ test_write_wifi_wep (void) nm_setting_wireless_security_set_wep_key (s_wsec, 3, "BBBBBBBBBBBBBBBBBBBBBBBBBB"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -8827,13 +8229,12 @@ test_write_wifi_wep (void) "wifi-wep-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -8880,8 +8281,8 @@ test_write_wifi_wep_adhoc (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -8891,16 +8292,13 @@ test_write_wifi_wep_adhoc (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah"; + GBytes *ssid; + const char *ssid_data = "blahblah"; struct stat statbuf; - NMIP4Address *addr; - const guint32 ip1 = htonl (0x01010103); - const guint32 gw = htonl (0x01010101); - const guint32 dns1 = htonl (0x04020201); - const guint32 prefix = 24; + NMIPAddress *addr; + const char *dns1 = "4.2.2.1"; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -8919,15 +8317,14 @@ test_write_wifi_wep_adhoc (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "adhoc", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -8937,28 +8334,29 @@ test_write_wifi_wep_adhoc (void) nm_setting_wireless_security_set_wep_key (s_wsec, 0, "0123456789abcdef0123456789"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_MANUAL, NULL); + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", + NULL); /* IP Address */ - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip1); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); - nm_setting_ip4_config_add_dns (s_ip4, dns1); + nm_setting_ip_config_add_dns (s_ip4, dns1); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -8978,13 +8376,12 @@ test_write_wifi_wep_adhoc (void) "wifi-wep-adhoc-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -9031,8 +8428,8 @@ test_write_wifi_wep_passphrase (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -9042,11 +8439,11 @@ test_write_wifi_wep_passphrase (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah"; + GBytes *ssid; + const char *ssid_data = "blahblah"; struct stat statbuf; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -9065,15 +8462,14 @@ test_write_wifi_wep_passphrase (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -9088,18 +8484,18 @@ test_write_wifi_wep_passphrase (void) nm_setting_wireless_security_set_wep_key (s_wsec, 0, "asdfdjaslfjasd;flasjdfl;aksdf"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -9119,13 +8515,12 @@ test_write_wifi_wep_passphrase (void) "wifi-wep-passphrase-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -9172,8 +8567,8 @@ test_write_wifi_wep_40_ascii (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -9183,11 +8578,11 @@ test_write_wifi_wep_40_ascii (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah40"; + GBytes *ssid; + const char *ssid_data = "blahblah40"; struct stat statbuf; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -9206,15 +8601,14 @@ test_write_wifi_wep_40_ascii (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -9231,18 +8625,18 @@ test_write_wifi_wep_40_ascii (void) nm_setting_wireless_security_set_wep_key (s_wsec, 3, "donec"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -9262,13 +8656,12 @@ test_write_wifi_wep_40_ascii (void) "wifi-wep-40-ascii-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -9315,8 +8708,8 @@ test_write_wifi_wep_104_ascii (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -9326,11 +8719,11 @@ test_write_wifi_wep_104_ascii (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah104"; + GBytes *ssid; + const char *ssid_data = "blahblah104"; struct stat statbuf; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -9349,15 +8742,14 @@ test_write_wifi_wep_104_ascii (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -9374,18 +8766,18 @@ test_write_wifi_wep_104_ascii (void) nm_setting_wireless_security_set_wep_key (s_wsec, 3, "thisismyascii"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -9405,13 +8797,12 @@ test_write_wifi_wep_104_ascii (void) "wifi-wep-104-ascii-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -9458,8 +8849,8 @@ test_write_wifi_leap (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -9469,11 +8860,11 @@ test_write_wifi_leap (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah"; + GBytes *ssid; + const char *ssid_data = "blahblah"; struct stat statbuf; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -9492,15 +8883,14 @@ test_write_wifi_leap (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -9514,18 +8904,18 @@ test_write_wifi_leap (void) NULL); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -9545,13 +8935,12 @@ test_write_wifi_leap (void) "wifi-leap-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -9598,8 +8987,8 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -9609,10 +8998,10 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah"; + GBytes *ssid; + const char *ssid_data = "blahblah"; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ @@ -9633,13 +9022,12 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags) g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -9655,19 +9043,19 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags) NULL); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); success = nm_connection_verify (connection, &error); @@ -9684,13 +9072,12 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags) g_assert (testfile); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -9739,8 +9126,8 @@ test_write_wifi_wpa_psk (const char *name, NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid, *tmp; gboolean success; GError *error = NULL; @@ -9750,12 +9137,12 @@ test_write_wifi_wpa_psk (const char *name, char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah"; + GBytes *ssid; + const char *ssid_data = "blahblah"; g_return_if_fail (psk != NULL); - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -9774,15 +9161,14 @@ test_write_wifi_wpa_psk (const char *name, s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -9809,18 +9195,18 @@ test_write_wifi_wpa_psk (const char *name, } /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -9840,13 +9226,12 @@ test_write_wifi_wpa_psk (const char *name, test_name, "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -9887,8 +9272,8 @@ test_write_wifi_wpa_psk_adhoc (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -9898,15 +9283,12 @@ test_write_wifi_wpa_psk_adhoc (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah"; - NMIP4Address *addr; - const guint32 ip1 = htonl (0x01010103); - const guint32 gw = htonl (0x01010101); - const guint32 dns1 = htonl (0x04020201); - const guint32 prefix = 24; + GBytes *ssid; + const char *ssid_data = "blahblah"; + NMIPAddress *addr; + const char *dns1 = "4.2.2.1"; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -9925,8 +9307,7 @@ test_write_wifi_wpa_psk_adhoc (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -9935,7 +9316,7 @@ test_write_wifi_wpa_psk_adhoc (void) NM_SETTING_WIRELESS_BAND, "bg", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -9950,28 +9331,29 @@ test_write_wifi_wpa_psk_adhoc (void) nm_setting_wireless_security_add_group (s_wsec, "tkip"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_MANUAL, NULL); + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", + NULL); /* IP Address */ - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip1); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 25, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); - nm_setting_ip4_config_add_dns (s_ip4, dns1); + nm_setting_ip_config_add_dns (s_ip4, dns1); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -9991,13 +9373,12 @@ test_write_wifi_wpa_psk_adhoc (void) "wifi-wpa-psk-adhoc-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -10037,8 +9418,8 @@ test_write_wifi_wpa_eap_tls (void) NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -10048,10 +9429,10 @@ test_write_wifi_wpa_eap_tls (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; + GBytes *ssid; const char *ssid_data = "blahblah"; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -10070,15 +9451,14 @@ test_write_wifi_wpa_eap_tls (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (strlen (ssid_data)); - g_byte_array_append (ssid, (const unsigned char *) ssid_data, strlen (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -10126,18 +9506,18 @@ test_write_wifi_wpa_eap_tls (void) TEST_IFCFG_WIFI_WPA_EAP_TLS_PRIVATE_KEY, error->message); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -10157,13 +9537,12 @@ test_write_wifi_wpa_eap_tls (void) "wifi-wpa-eap-tls-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -10203,8 +9582,8 @@ test_write_wifi_wpa_eap_ttls_tls (void) NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -10214,10 +9593,10 @@ test_write_wifi_wpa_eap_ttls_tls (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; + GBytes *ssid; const char *ssid_data = "blahblah"; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -10236,15 +9615,14 @@ test_write_wifi_wpa_eap_ttls_tls (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (strlen (ssid_data)); - g_byte_array_append (ssid, (const unsigned char *) ssid_data, strlen (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -10310,18 +9688,18 @@ test_write_wifi_wpa_eap_ttls_tls (void) TEST_IFCFG_WIFI_WPA_EAP_TLS_PRIVATE_KEY, error->message); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -10341,13 +9719,12 @@ test_write_wifi_wpa_eap_ttls_tls (void) "wifi-wpa-eap-ttls-tls-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -10387,8 +9764,8 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -10398,10 +9775,10 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; + GBytes *ssid; const char *ssid_data = "blahblah"; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -10420,15 +9797,14 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (strlen (ssid_data)); - g_byte_array_append (ssid, (const unsigned char *) ssid_data, strlen (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -10466,18 +9842,18 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -10497,13 +9873,12 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) "wifi-wpa-eap-ttls-mschapv2-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -10542,8 +9917,8 @@ test_write_wifi_wpa_then_open (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -10553,14 +9928,14 @@ test_write_wifi_wpa_then_open (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - const unsigned char ssid_data[] = "blahblah"; + GBytes *ssid; + const char *ssid_data = "blahblah"; /* Test that writing out a WPA config then changing that to an open * config doesn't leave various WPA-related keys lying around in the ifcfg. */ - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ @@ -10582,15 +9957,14 @@ test_write_wifi_wpa_then_open (void) g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -10611,20 +9985,20 @@ test_write_wifi_wpa_then_open (void) nm_setting_wireless_security_add_group (s_wsec, "ccmp"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); success = nm_connection_verify (connection, &error); @@ -10641,13 +10015,12 @@ test_write_wifi_wpa_then_open (void) g_assert (testfile); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -10688,13 +10061,12 @@ test_write_wifi_wpa_then_open (void) keyfile = NULL; /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read it for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -10735,8 +10107,8 @@ test_write_wifi_wpa_then_wep_with_perms (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -10746,15 +10118,15 @@ test_write_wifi_wpa_then_wep_with_perms (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; - GSList *perm_list = NULL; - const unsigned char ssid_data[] = "SomeSSID"; + GBytes *ssid; + char **perms; + const char *ssid_data = "SomeSSID"; /* Test that writing out a WPA config then changing that to a WEP * config works and doesn't cause infinite loop or other issues. */ - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ @@ -10763,16 +10135,16 @@ test_write_wifi_wpa_then_wep_with_perms (void) nm_connection_add_setting (connection, NM_SETTING (s_con)); uuid = nm_utils_uuid_generate (); - perm_list = g_slist_append (perm_list, "user:superman:"); + perms = g_strsplit ("user:superman:", ",", -1); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "random wifi connection 2", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, - NM_SETTING_CONNECTION_PERMISSIONS, perm_list, + NM_SETTING_CONNECTION_PERMISSIONS, perms, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); g_free (uuid); - g_slist_free (perm_list); + g_strfreev (perms); ASSERT (nm_setting_connection_get_num_permissions (s_con) == 1, "test_write_wifi_wpa_then_wep_with_perms", "unexpected failure adding valid user permisson"); @@ -10781,15 +10153,14 @@ test_write_wifi_wpa_then_wep_with_perms (void) g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (sizeof (ssid_data)); - g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -10810,20 +10181,20 @@ test_write_wifi_wpa_then_wep_with_perms (void) nm_setting_wireless_security_add_group (s_wsec, "ccmp"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); success = nm_connection_verify (connection, &error); @@ -10840,13 +10211,12 @@ test_write_wifi_wpa_then_wep_with_perms (void) g_assert (testfile); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -10893,13 +10263,12 @@ test_write_wifi_wpa_then_wep_with_perms (void) keyfile = NULL; /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read it for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -10942,8 +10311,8 @@ test_write_wifi_dynamic_wep_leap (void) NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -10953,12 +10322,12 @@ test_write_wifi_dynamic_wep_leap (void) char *routefile = NULL; char *route6file = NULL; gboolean ignore_error = FALSE; - GByteArray *ssid; + GBytes *ssid; const char *ssid_data = "blahblah"; shvarFile *ifcfg; char *tmp; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ @@ -10979,15 +10348,14 @@ test_write_wifi_dynamic_wep_leap (void) g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (strlen (ssid_data)); - g_byte_array_append (ssid, (const unsigned char *) ssid_data, strlen (ssid_data)); + ssid = g_bytes_new (ssid_data, strlen (ssid_data)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -11009,19 +10377,19 @@ test_write_wifi_dynamic_wep_leap (void) NULL); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); success = nm_connection_verify (connection, &error); @@ -11038,13 +10406,12 @@ test_write_wifi_dynamic_wep_leap (void) g_assert (testfile); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -11090,399 +10457,6 @@ test_write_wifi_dynamic_wep_leap (void) g_object_unref (reread); } -#define TEST_IFCFG_IBFT_DHCP TEST_IFCFG_DIR"/network-scripts/ifcfg-test-ibft-dhcp" - -static void -test_read_ibft_dhcp (void) -{ - NMConnection *connection; - NMSettingConnection *s_con; - NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - char *unmanaged = NULL; - char *keyfile = NULL; - char *routefile = NULL; - char *route6file = NULL; - gboolean ignore_error = FALSE; - GError *error = NULL; - const char *tmp; - const GByteArray *array; - char expected_mac_address[ETH_ALEN] = { 0x00, 0x33, 0x21, 0x98, 0xb9, 0xf1 }; - const char *expected_id = "System test-ibft-dhcp"; - guint64 expected_timestamp = 0; - - connection = connection_from_file (TEST_IFCFG_IBFT_DHCP, - NULL, - TYPE_ETHERNET, - TEST_IFCFG_DIR "/iscsiadm-test-dhcp", - &unmanaged, - &keyfile, - &routefile, - &route6file, - &error, - &ignore_error); - ASSERT (connection != NULL, - "ibft-dhcp-read", "failed to read %s: %s", TEST_IFCFG_IBFT_DHCP, error->message); - - ASSERT (nm_connection_verify (connection, &error), - "ibft-dhcp-verify", "failed to verify %s: %s", TEST_IFCFG_IBFT_DHCP, error->message); - - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection (connection); - ASSERT (s_con != NULL, - "ibft-dhcp-verify-connection", "failed to verify %s: missing %s setting", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_CONNECTION_SETTING_NAME); - - /* ID */ - tmp = nm_setting_connection_get_id (s_con); - ASSERT (tmp != NULL, - "ibft-dhcp-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, expected_id) == 0, - "ibft-dhcp-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - - /* UUID can't be tested if the ifcfg does not contain the UUID key, because - * the UUID is generated on the full path of the ifcfg file, which can change - * depending on where the tests are run. - */ - - /* Timestamp */ - ASSERT (nm_setting_connection_get_timestamp (s_con) == expected_timestamp, - "ibft-dhcp-verify-connection", "failed to verify %s: unexpected %s /%s key value", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_TIMESTAMP); - - /* Autoconnect */ - ASSERT (nm_setting_connection_get_autoconnect (s_con) == TRUE, - "ibft-dhcp-verify-connection", "failed to verify %s: unexpected %s /%s key value", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_AUTOCONNECT); - - /* Read-only */ - ASSERT (nm_setting_connection_get_read_only (s_con) == TRUE, - "ibft-dhcp-verify-connection", "failed to verify %s: unexpected %s /%s key value", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_READ_ONLY); - - /* ===== WIRED SETTING ===== */ - - s_wired = nm_connection_get_setting_wired (connection); - ASSERT (s_wired != NULL, - "ibft-dhcp-verify-wired", "failed to verify %s: missing %s setting", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_WIRED_SETTING_NAME); - - /* MAC address */ - array = nm_setting_wired_get_mac_address (s_wired); - ASSERT (array != NULL, - "ibft-dhcp-verify-wired", "failed to verify %s: missing %s / %s key", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MAC_ADDRESS); - ASSERT (array->len == ETH_ALEN, - "ibft-dhcp-verify-wired", "failed to verify %s: unexpected %s / %s key value length", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MAC_ADDRESS); - ASSERT (memcmp (array->data, &expected_mac_address[0], sizeof (expected_mac_address)) == 0, - "ibft-dhcp-verify-wired", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MAC_ADDRESS); - - ASSERT (nm_setting_wired_get_mtu (s_wired) == 0, - "ibft-dhcp-verify-wired", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MTU); - - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config (connection); - ASSERT (s_ip4 != NULL, - "ibft-dhcp-verify-ip4", "failed to verify %s: missing %s setting", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_IP4_CONFIG_SETTING_NAME); - - /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); - ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, - "ibft-dhcp-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_DHCP, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); - - g_free (unmanaged); - g_free (keyfile); - g_free (routefile); - g_free (route6file); - g_object_unref (connection); -} - -#define TEST_IFCFG_IBFT_STATIC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-ibft-static" - -static void -test_read_ibft_static (void) -{ - NMConnection *connection; - NMSettingConnection *s_con; - NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - char *unmanaged = NULL; - char *keyfile = NULL; - char *routefile = NULL; - char *route6file = NULL; - gboolean ignore_error = FALSE; - GError *error = NULL; - const char *tmp; - const GByteArray *array; - char expected_mac_address[ETH_ALEN] = { 0x00, 0x33, 0x21, 0x98, 0xb9, 0xf0 }; - const char *expected_id = "System test-ibft-static"; - guint64 expected_timestamp = 0; - const char *expected_dns1 = "10.16.255.2"; - const char *expected_dns2 = "10.16.255.3"; - guint32 addr; - const char *expected_address1 = "192.168.32.72"; - const char *expected_address1_gw = "192.168.35.254"; - NMIP4Address *ip4_addr; - - connection = connection_from_file (TEST_IFCFG_IBFT_STATIC, - NULL, - TYPE_ETHERNET, - TEST_IFCFG_DIR "/iscsiadm-test-static", - &unmanaged, - &keyfile, - &routefile, - &route6file, - &error, - &ignore_error); - ASSERT (connection != NULL, - "ibft-static-read", "failed to read %s: %s", TEST_IFCFG_IBFT_STATIC, error->message); - - ASSERT (nm_connection_verify (connection, &error), - "ibft-static-verify", "failed to verify %s: %s", TEST_IFCFG_IBFT_STATIC, error->message); - - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection (connection); - ASSERT (s_con != NULL, - "ibft-static-verify-connection", "failed to verify %s: missing %s setting", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_CONNECTION_SETTING_NAME); - - /* ID */ - tmp = nm_setting_connection_get_id (s_con); - ASSERT (tmp != NULL, - "ibft-static-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, expected_id) == 0, - "ibft-static-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - - /* UUID can't be tested if the ifcfg does not contain the UUID key, because - * the UUID is generated on the full path of the ifcfg file, which can change - * depending on where the tests are run. - */ - - /* Timestamp */ - ASSERT (nm_setting_connection_get_timestamp (s_con) == expected_timestamp, - "ibft-static-verify-connection", "failed to verify %s: unexpected %s /%s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_TIMESTAMP); - - /* Autoconnect */ - ASSERT (nm_setting_connection_get_autoconnect (s_con) == TRUE, - "ibft-static-verify-connection", "failed to verify %s: unexpected %s /%s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_AUTOCONNECT); - - /* Read-only */ - ASSERT (nm_setting_connection_get_read_only (s_con) == TRUE, - "ibft-static-verify-connection", "failed to verify %s: unexpected %s /%s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_READ_ONLY); - - /* ===== WIRED SETTING ===== */ - - s_wired = nm_connection_get_setting_wired (connection); - ASSERT (s_wired != NULL, - "ibft-static-verify-wired", "failed to verify %s: missing %s setting", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_WIRED_SETTING_NAME); - - /* MAC address */ - array = nm_setting_wired_get_mac_address (s_wired); - ASSERT (array != NULL, - "ibft-static-verify-wired", "failed to verify %s: missing %s / %s key", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MAC_ADDRESS); - ASSERT (array->len == ETH_ALEN, - "ibft-static-verify-wired", "failed to verify %s: unexpected %s / %s key value length", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MAC_ADDRESS); - ASSERT (memcmp (array->data, &expected_mac_address[0], sizeof (expected_mac_address)) == 0, - "ibft-static-verify-wired", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MAC_ADDRESS); - - ASSERT (nm_setting_wired_get_mtu (s_wired) == 0, - "ibft-static-verify-wired", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_WIRED_SETTING_NAME, - NM_SETTING_WIRED_MTU); - - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config (connection); - ASSERT (s_ip4 != NULL, - "ibft-static-verify-ip4", "failed to verify %s: missing %s setting", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME); - - /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); - ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, - "ibft-static-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); - - /* DNS Addresses */ - ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 2, - "ibft-static-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - - ASSERT (inet_pton (AF_INET, expected_dns1, &addr) > 0, - "ibft-static-verify-ip4", "failed to verify %s: couldn't convert DNS IP address #1", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr, - "ibft-static-verify-ip4", "failed to verify %s: unexpected %s / %s key value #1", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - - ASSERT (inet_pton (AF_INET, expected_dns2, &addr) > 0, - "ibft-static-verify-ip4", "failed to verify %s: couldn't convert DNS IP address #2", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr, - "ibft-static-verify-ip4", "failed to verify %s: unexpected %s / %s key value #2", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - - ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == 1, - "ibft-static-verify-ip4", "failed to verify %s: unexpected %s / %s key value", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - - /* Address #1 */ - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); - ASSERT (ip4_addr, - "ibft-static-verify-ip4", "failed to verify %s: missing IP4 address #1", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == 22, - "ibft-static-verify-ip4", "failed to verify %s: unexpected IP4 address #1 prefix", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - - ASSERT (inet_pton (AF_INET, expected_address1, &addr) > 0, - "ibft-static-verify-ip4", "failed to verify %s: couldn't convert IP address #1", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_ip4_address_get_address (ip4_addr) == addr, - "ibft-static-verify-ip4", "failed to verify %s: unexpected IP4 address #1", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - - ASSERT (inet_pton (AF_INET, expected_address1_gw, &addr) > 0, - "ibft-static-verify-ip4", "failed to verify %s: couldn't convert IP address #1 gateway", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - ASSERT (nm_ip4_address_get_gateway (ip4_addr) == addr, - "ibft-static-verify-ip4", "failed to verify %s: unexpected IP4 address #1 gateway", - TEST_IFCFG_IBFT_STATIC, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - - g_free (unmanaged); - g_free (keyfile); - g_free (routefile); - g_free (route6file); - g_object_unref (connection); -} - -static void -test_read_ibft_malformed (const char *name, const char *iscsiadm_path, gboolean expect_warning) -{ - NMConnection *connection; - char *unmanaged = NULL; - char *keyfile = NULL; - char *routefile = NULL; - char *route6file = NULL; - gboolean ignore_error = FALSE; - GError *error = NULL; - - g_assert (g_file_test (iscsiadm_path, G_FILE_TEST_EXISTS)); - - if (expect_warning) { - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, - "*malformed iscsiadm record*"); - } - connection = connection_from_file (TEST_IFCFG_IBFT_STATIC, - NULL, - TYPE_ETHERNET, - iscsiadm_path, - &unmanaged, - &keyfile, - &routefile, - &route6file, - &error, - &ignore_error); - if (expect_warning) - g_test_assert_expected_messages (); - ASSERT (connection == NULL, - name, "unexpectedly able to read %s", TEST_IFCFG_IBFT_STATIC); - - g_free (unmanaged); - g_free (keyfile); - g_free (routefile); - g_free (route6file); -} - static void test_write_wired_qeth_dhcp (void) { @@ -11490,10 +10464,10 @@ test_write_wired_qeth_dhcp (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; - GPtrArray *subchans; + char **subchans; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -11503,7 +10477,7 @@ test_write_wired_qeth_dhcp (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -11522,15 +10496,12 @@ test_write_wired_qeth_dhcp (void) s_wired = (NMSettingWired *) nm_setting_wired_new (); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - subchans = g_ptr_array_sized_new (3); - g_ptr_array_add (subchans, "0.0.600"); - g_ptr_array_add (subchans, "0.0.601"); - g_ptr_array_add (subchans, "0.0.602"); + subchans = g_strsplit ("0.0.600,0.0.601,0.0.602", ",", -1); g_object_set (s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, subchans, NM_SETTING_WIRED_S390_NETTYPE, "qeth", NULL); - g_ptr_array_free (subchans, TRUE); + g_strfreev (subchans); nm_setting_wired_add_s390_option (s_wired, "portname", "FOOBAR"); nm_setting_wired_add_s390_option (s_wired, "portno", "1"); @@ -11538,20 +10509,20 @@ test_write_wired_qeth_dhcp (void) nm_setting_wired_add_s390_option (s_wired, "protocol", "blahbalh"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); /* Verify */ @@ -11572,13 +10543,12 @@ test_write_wired_qeth_dhcp (void) "wired-qeth-dhcp-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -11615,10 +10585,10 @@ test_write_wired_ctc_dhcp (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; - GPtrArray *subchans; + char **subchans; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -11630,7 +10600,7 @@ test_write_wired_ctc_dhcp (void) shvarFile *ifcfg; char *tmp; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ @@ -11651,30 +10621,28 @@ test_write_wired_ctc_dhcp (void) g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - subchans = g_ptr_array_sized_new (2); - g_ptr_array_add (subchans, "0.0.600"); - g_ptr_array_add (subchans, "0.0.601"); + subchans = g_strsplit ("0.0.600,0.0.601", ",", -1); g_object_set (s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, subchans, NM_SETTING_WIRED_S390_NETTYPE, "ctc", NULL); - g_ptr_array_free (subchans, TRUE); + g_strfreev (subchans); nm_setting_wired_add_s390_option (s_wired, "ctcprot", "0"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); /* Verify */ @@ -11709,13 +10677,12 @@ test_write_wired_ctc_dhcp (void) svCloseFile (ifcfg); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -11751,8 +10718,8 @@ test_write_permissions (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -11763,7 +10730,7 @@ test_write_permissions (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -11787,20 +10754,20 @@ test_write_permissions (void) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); /* Verify */ @@ -11821,13 +10788,12 @@ test_write_permissions (void) "permissions-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -11865,11 +10831,11 @@ test_write_wifi_wep_agent_keys (void) NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; const char *str_ssid = "foobarbaz"; - GByteArray *ssid; + GBytes *ssid; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -11879,7 +10845,7 @@ test_write_wifi_wep_agent_keys (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection != NULL); /* Connection setting */ @@ -11896,19 +10862,19 @@ test_write_wifi_wep_agent_keys (void) g_free (uuid); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); 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); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); /* Wifi setting */ @@ -11916,13 +10882,12 @@ test_write_wifi_wep_agent_keys (void) g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - ssid = g_byte_array_sized_new (strlen (str_ssid)); - g_byte_array_append (ssid, (guint8 *) str_ssid, strlen (str_ssid)); + ssid = g_bytes_new (str_ssid, strlen (str_ssid)); g_object_set (s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_byte_array_free (ssid, TRUE); + g_bytes_unref (ssid); /* Wifi security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); @@ -11951,13 +10916,12 @@ test_write_wifi_wep_agent_keys (void) g_assert (testfile != NULL); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_WIRELESS, - NULL, &unmanaged, &keyfile, &routefile, @@ -12005,15 +10969,15 @@ test_write_wired_pppoe (void) NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingPPPOE *s_pppoe; - NMSettingPPP *s_ppp; + NMSettingIPConfig *s_ip4; + NMSettingPppoe *s_pppoe; + NMSettingPpp *s_ppp; char *uuid; gboolean success; GError *error = NULL; char *testfile = NULL; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -12033,15 +10997,15 @@ test_write_wired_pppoe (void) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* PPPoE setting */ - s_pppoe = (NMSettingPPPOE *) nm_setting_pppoe_new (); + s_pppoe = (NMSettingPppoe *) nm_setting_pppoe_new (); nm_connection_add_setting (connection, NM_SETTING (s_pppoe)); g_object_set (G_OBJECT (s_pppoe), @@ -12051,7 +11015,7 @@ test_write_wired_pppoe (void) NULL); /* PPP setting */ - s_ppp = (NMSettingPPP *) nm_setting_ppp_new (); + s_ppp = (NMSettingPpp *) nm_setting_ppp_new (); nm_connection_add_setting (connection, NM_SETTING (s_ppp)); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -12074,14 +11038,14 @@ test_write_vpn (void) { NMConnection *connection; NMSettingConnection *s_con; - NMSettingIP4Config *s_ip4; - NMSettingVPN *s_vpn; + NMSettingIPConfig *s_ip4; + NMSettingVpn *s_vpn; char *uuid; gboolean success; GError *error = NULL; char *testfile = NULL; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -12097,7 +11061,7 @@ test_write_vpn (void) g_free (uuid); /* VPN setting */ - s_vpn = (NMSettingVPN *) nm_setting_vpn_new (); + s_vpn = (NMSettingVpn *) nm_setting_vpn_new (); nm_connection_add_setting (connection, NM_SETTING (s_vpn)); g_object_set (s_vpn, @@ -12109,11 +11073,11 @@ test_write_vpn (void) nm_setting_vpn_add_secret (s_vpn, "password", "sup3rs3cr3t"); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -12136,17 +11100,17 @@ test_write_mobile_broadband (gboolean gsm) { NMConnection *connection; NMSettingConnection *s_con; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; NMSettingGsm *s_gsm; NMSettingCdma *s_cdma; - NMSettingPPP *s_ppp; + NMSettingPpp *s_ppp; NMSettingSerial *s_serial; char *uuid; gboolean success; GError *error = NULL; char *testfile = NULL; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -12182,20 +11146,20 @@ test_write_mobile_broadband (gboolean gsm) g_object_set (s_serial, NM_SETTING_SERIAL_BAUD, 115200, NM_SETTING_SERIAL_BITS, 8, - NM_SETTING_SERIAL_PARITY, 'n', + NM_SETTING_SERIAL_PARITY, NM_SETTING_SERIAL_PARITY_NONE, NM_SETTING_SERIAL_STOPBITS, 1, NULL); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* PPP setting */ - s_ppp = (NMSettingPPP *) nm_setting_ppp_new (); + s_ppp = (NMSettingPpp *) nm_setting_ppp_new (); nm_connection_add_setting (connection, NM_SETTING (s_ppp)); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -12220,7 +11184,7 @@ test_read_bridge_main (void) { NMConnection *connection; NMSettingBridge *s_bridge; - const GByteArray *array; + const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 }; char *unmanaged = NULL; char *keyfile = NULL; @@ -12232,7 +11196,6 @@ test_read_bridge_main (void) connection = connection_from_file (TEST_IFCFG_BRIDGE_MAIN, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -12243,22 +11206,23 @@ test_read_bridge_main (void) g_assert (nm_connection_verify (connection, &error)); g_assert_no_error (error); + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "br0"); + /* ===== Bridging SETTING ===== */ s_bridge = nm_connection_get_setting_bridge (connection); g_assert (s_bridge); - g_assert_cmpstr (nm_setting_bridge_get_interface_name (s_bridge), ==, "br0"); g_assert_cmpuint (nm_setting_bridge_get_forward_delay (s_bridge), ==, 0); g_assert (nm_setting_bridge_get_stp (s_bridge)); g_assert_cmpuint (nm_setting_bridge_get_priority (s_bridge), ==, 32744); g_assert_cmpuint (nm_setting_bridge_get_hello_time (s_bridge), ==, 7); g_assert_cmpuint (nm_setting_bridge_get_max_age (s_bridge), ==, 39); g_assert_cmpuint (nm_setting_bridge_get_ageing_time (s_bridge), ==, 235352); + /* MAC address */ - array = nm_setting_bridge_get_mac_address (s_bridge); - g_assert (array); - g_assert_cmpint (array->len, ==, ETH_ALEN); - g_assert (memcmp (array->data, &expected_mac_address[0], ETH_ALEN) == 0); + mac = nm_setting_bridge_get_mac_address (s_bridge); + g_assert (mac); + g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, ETH_ALEN)); g_free (unmanaged); g_free (keyfile); @@ -12274,15 +11238,11 @@ test_write_bridge_main (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingBridge *s_bridge; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; - const guint32 ip1 = htonl (0x01010103); - const guint32 gw = htonl (0x01010101); - const guint32 prefix = 24; - NMIP4Address *addr; - static unsigned char bridge_mac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd }; - GByteArray *mac_array; + NMIPAddress *addr; + static const char *mac = "31:33:33:37:be:cd"; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -12292,7 +11252,7 @@ test_write_bridge_main (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ @@ -12305,6 +11265,7 @@ test_write_bridge_main (void) NM_SETTING_CONNECTION_ID, "Test Write Bridge Main", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_INTERFACE_NAME, "br0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_BRIDGE_SETTING_NAME, NULL); g_free (uuid); @@ -12314,42 +11275,36 @@ test_write_bridge_main (void) g_assert (s_bridge); nm_connection_add_setting (connection, NM_SETTING (s_bridge)); - mac_array = g_byte_array_sized_new (sizeof (bridge_mac)); - g_byte_array_append (mac_array, bridge_mac, sizeof (bridge_mac)); g_object_set (s_bridge, - NM_SETTING_BRIDGE_INTERFACE_NAME, "br0", - NM_SETTING_BRIDGE_MAC_ADDRESS, mac_array, + NM_SETTING_BRIDGE_MAC_ADDRESS, mac, NULL); - g_byte_array_free (mac_array, TRUE); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, - NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, - NM_SETTING_IP4_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip1); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - g_assert (nm_connection_verify (connection, &error)); - g_assert_no_error (error); + nmtst_assert_connection_verifies_without_normalization (connection); /* Save the ifcfg */ success = writer_new_connection (connection, @@ -12360,13 +11315,12 @@ test_write_bridge_main (void) g_assert_cmpstr (testfile, !=, NULL); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_BRIDGE, - NULL, &unmanaged, &keyfile, &routefile, @@ -12408,7 +11362,6 @@ test_read_bridge_component (void) connection = connection_from_file (TEST_IFCFG_BRIDGE_COMPONENT, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -12447,8 +11400,7 @@ test_write_bridge_component (void) NMSettingConnection *s_con; NMSettingWired *s_wired; NMSetting *s_port; - static unsigned char tmpmac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd }; - GByteArray *mac; + static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; char *uuid; gboolean success; @@ -12460,7 +11412,7 @@ test_write_bridge_component (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ @@ -12484,14 +11436,10 @@ test_write_bridge_component (void) g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - mac = g_byte_array_sized_new (sizeof (tmpmac)); - g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac)); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NM_SETTING_WIRED_MTU, mtu, NULL); - g_byte_array_free (mac, TRUE); /* Bridge port */ s_port = nm_setting_bridge_port_new (); @@ -12515,13 +11463,12 @@ test_write_bridge_component (void) g_assert (testfile); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -12564,7 +11511,6 @@ test_read_bridge_missing_stp (void) connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bridge-missing-stp", NULL, TYPE_BRIDGE, - NULL, &unmanaged, &keyfile, &routefile, @@ -12575,11 +11521,12 @@ test_read_bridge_missing_stp (void) g_assert (nm_connection_verify (connection, &error)); g_assert_no_error (error); + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "br0"); + /* ===== Bridging SETTING ===== */ s_bridge = nm_connection_get_setting_bridge (connection); g_assert (s_bridge); - g_assert_cmpstr (nm_setting_bridge_get_interface_name (s_bridge), ==, "br0"); g_assert (nm_setting_bridge_get_stp (s_bridge) == FALSE); g_free (unmanaged); @@ -12607,7 +11554,6 @@ test_read_vlan_interface (void) connection = connection_from_file (TEST_IFCFG_VLAN_INTERFACE, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -12622,10 +11568,11 @@ test_read_vlan_interface (void) g_free (routefile); g_free (route6file); + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "vlan43"); + s_vlan = nm_connection_get_setting_vlan (connection); g_assert (s_vlan); - g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, "vlan43"); g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9"); g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 43); g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, @@ -12677,7 +11624,6 @@ test_read_vlan_only_vlan_id (void) connection = connection_from_file (TEST_IFCFG_VLAN_ONLY_VLANID, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -12692,10 +11638,11 @@ test_read_vlan_only_vlan_id (void) g_free (routefile); g_free (route6file); + g_assert (nm_connection_get_interface_name (connection) == NULL); + s_vlan = nm_connection_get_setting_vlan (connection); g_assert (s_vlan); - g_assert (nm_setting_vlan_get_interface_name (s_vlan) == NULL); g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9"); g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 43); @@ -12719,7 +11666,6 @@ test_read_vlan_only_device (void) connection = connection_from_file (TEST_IFCFG_VLAN_ONLY_DEVICE, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -12734,10 +11680,11 @@ test_read_vlan_only_device (void) g_free (routefile); g_free (route6file); + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "eth0.9"); + s_vlan = nm_connection_get_setting_vlan (connection); g_assert (s_vlan); - g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, "eth0.9"); g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth0"); g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 9); @@ -12752,16 +11699,17 @@ test_read_vlan_physdev (void) NMSettingVlan *s_vlan; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-physdev", - NULL, TYPE_ETHERNET, NULL, NULL, + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); g_assert (nm_connection_verify (connection, &error)); + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "vlan0.3"); + s_vlan = nm_connection_get_setting_vlan (connection); g_assert (s_vlan); - g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, "vlan0.3"); g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth0"); g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 3); @@ -12784,7 +11732,6 @@ test_write_vlan (void) connection = connection_from_file (TEST_IFCFG_VLAN_INTERFACE, NULL, TYPE_VLAN, - NULL, &unmanaged, &keyfile, &routefile, @@ -12824,7 +11771,6 @@ test_write_vlan_only_vlanid (void) connection = connection_from_file (TEST_IFCFG_VLAN_ONLY_VLANID, NULL, TYPE_VLAN, - NULL, &unmanaged, &keyfile, &routefile, @@ -12850,13 +11796,12 @@ test_write_vlan_only_vlanid (void) g_assert (success); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (written, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -12891,8 +11836,8 @@ test_write_ethernet_missing_ipv6 (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid; gboolean success; GError *error = NULL; @@ -12903,7 +11848,7 @@ test_write_ethernet_missing_ipv6 (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ @@ -12926,14 +11871,14 @@ test_write_ethernet_missing_ipv6 (void) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); g_assert (s_ip4); 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, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, "random-client-id-00:22:33", - NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, TRUE, - NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, TRUE, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, TRUE, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, TRUE, NULL); /* IP6 setting */ @@ -12959,13 +11904,12 @@ test_write_ethernet_missing_ipv6 (void) "ethernet-missing-ipv6", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -12985,12 +11929,12 @@ test_write_ethernet_missing_ipv6 (void) * the comparison can succeed. Missing IPv6 setting should have been * written out (and re-read) as Automatic IPv6. */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE, @@ -13005,6 +11949,19 @@ test_write_ethernet_missing_ipv6 (void) g_object_unref (reread); } +static void +test_read_ibft_ignored (void) +{ + NMConnection *connection; + GError *error = NULL; + + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-ibft", + NULL, TYPE_ETHERNET, + NULL, NULL, NULL, NULL, &error, NULL); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); + g_assert (connection == NULL); +} + #define TEST_IFCFG_BOND_MAIN TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bond-main" static void @@ -13022,7 +11979,6 @@ test_read_bond_main (void) connection = connection_from_file (TEST_IFCFG_BOND_MAIN, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -13035,6 +11991,10 @@ test_read_bond_main (void) ASSERT (nm_connection_verify (connection, &error), "bond-main-read", "failed to verify %s: %s", TEST_IFCFG_BOND_MAIN, error->message); + ASSERT (g_strcmp0 (nm_connection_get_interface_name (connection), "bond0") == 0, + "bond-main", "failed to verify %s: DEVICE=%s does not match bond0", + TEST_IFCFG_BOND_MAIN, nm_connection_get_interface_name (connection)); + /* ===== Bonding SETTING ===== */ s_bond = nm_connection_get_setting_bond (connection); @@ -13043,10 +12003,6 @@ test_read_bond_main (void) TEST_IFCFG_BOND_MAIN, NM_SETTING_BOND_SETTING_NAME); - ASSERT (g_strcmp0 (nm_setting_bond_get_interface_name (s_bond), "bond0") == 0, - "bond-main", "failed to verify %s: DEVICE=%s does not match bond0", - TEST_IFCFG_BOND_MAIN, nm_setting_bond_get_interface_name (s_bond)); - ASSERT (g_strcmp0 (nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MIIMON), "100") == 0, "bond-main", "failed to verify %s: miimon=%s does not match 100", TEST_IFCFG_BOND_MAIN, nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MIIMON)); @@ -13065,14 +12021,11 @@ test_write_bond_main (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingBond *s_bond; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; NMSettingWired *s_wired; char *uuid; - const guint32 ip1 = htonl (0x01010103); - const guint32 gw = htonl (0x01010101); - const guint32 prefix = 24; - NMIP4Address *addr; + NMIPAddress *addr; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -13082,7 +12035,7 @@ test_write_bond_main (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -13093,6 +12046,7 @@ test_write_bond_main (void) NM_SETTING_CONNECTION_ID, "Test Write Bond Main", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_INTERFACE_NAME, "bond0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_BOND_SETTING_NAME, NULL); g_free (uuid); @@ -13105,37 +12059,30 @@ test_write_bond_main (void) s_bond = (NMSettingBond *) nm_setting_bond_new (); nm_connection_add_setting (connection, NM_SETTING (s_bond)); - g_object_set (s_bond, - NM_SETTING_BOND_INTERFACE_NAME, "bond0", - NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_MANUAL, - NM_SETTING_IP4_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip1); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - ASSERT (nm_connection_verify (connection, &error) == TRUE, - "bond-main-write", "failed to verify connection: %s", - (error && error->message) ? error->message : "(unknown)"); + nmtst_assert_connection_verifies_without_normalization (connection); /* Save the ifcfg */ success = writer_new_connection (connection, @@ -13150,13 +12097,12 @@ test_write_bond_main (void) "bond-main-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_BOND, - NULL, &unmanaged, &keyfile, &routefile, @@ -13197,12 +12143,9 @@ test_read_bond_slave (void) gboolean ignore_error = FALSE; GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, - "*ignoring IP4 config on slave*"); connection = connection_from_file (TEST_IFCFG_BOND_SLAVE, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -13244,8 +12187,7 @@ test_write_bond_slave (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingWired *s_wired; - static unsigned char tmpmac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd }; - GByteArray *mac; + static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; char *uuid; gboolean success; @@ -13257,7 +12199,7 @@ test_write_bond_slave (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -13278,14 +12220,10 @@ test_write_bond_slave (void) s_wired = (NMSettingWired *) nm_setting_wired_new (); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - mac = g_byte_array_sized_new (sizeof (tmpmac)); - g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac)); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NM_SETTING_WIRED_MTU, mtu, NULL); - g_byte_array_free (mac, TRUE); ASSERT (nm_connection_verify (connection, &error) == TRUE, "bond-slave-write", "failed to verify connection: %s", @@ -13304,13 +12242,12 @@ test_write_bond_slave (void) "bond-slave-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, &unmanaged, &keyfile, &routefile, @@ -13353,14 +12290,13 @@ test_read_infiniband (void) char *route6file = NULL; gboolean ignore_error = FALSE; GError *error = NULL; - const GByteArray *array; + const char *mac; char expected_mac_address[INFINIBAND_ALEN] = { 0x80, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22 }; const char *transport_mode; connection = connection_from_file (TEST_IFCFG_INFINIBAND, NULL, TYPE_INFINIBAND, - NULL, &unmanaged, &keyfile, &routefile, @@ -13385,18 +12321,13 @@ test_read_infiniband (void) NM_SETTING_INFINIBAND_SETTING_NAME); /* MAC address */ - array = nm_setting_infiniband_get_mac_address (s_infiniband); - ASSERT (array != NULL, + mac = nm_setting_infiniband_get_mac_address (s_infiniband); + ASSERT (mac != NULL, "infiniband-verify-infiniband", "failed to verify %s: missing %s / %s key", TEST_IFCFG_INFINIBAND, NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_MAC_ADDRESS); - ASSERT (array->len == INFINIBAND_ALEN, - "infiniband-verify-infiniband", "failed to verify %s: unexpected %s / %s key value length", - TEST_IFCFG_INFINIBAND, - NM_SETTING_INFINIBAND_SETTING_NAME, - NM_SETTING_INFINIBAND_MAC_ADDRESS); - ASSERT (memcmp (array->data, &expected_mac_address[0], sizeof (expected_mac_address)) == 0, + ASSERT (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, sizeof (expected_mac_address)), "infiniband-verify-infiniband", "failed to verify %s: unexpected %s / %s key value", TEST_IFCFG_INFINIBAND, NM_SETTING_INFINIBAND_SETTING_NAME, @@ -13429,16 +12360,12 @@ test_write_infiniband (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingInfiniband *s_infiniband; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; - unsigned char tmpmac[INFINIBAND_ALEN] = { 0x80, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22 }; - GByteArray *mac; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; guint32 mtu = 65520; char *uuid; - const guint32 ip1 = htonl (0x01010103); - const guint32 gw = htonl (0x01010101); - const guint32 prefix = 24; - NMIP4Address *addr; + NMIPAddress *addr; gboolean success; GError *error = NULL; char *testfile = NULL; @@ -13448,7 +12375,7 @@ test_write_infiniband (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -13467,38 +12394,33 @@ test_write_infiniband (void) s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new (); nm_connection_add_setting (connection, NM_SETTING (s_infiniband)); - mac = g_byte_array_sized_new (sizeof (tmpmac)); - g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac)); - g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, NM_SETTING_INFINIBAND_MTU, mtu, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "connected", NULL); - g_byte_array_free (mac, TRUE); /* IP4 setting */ - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) 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_MANUAL, - NM_SETTING_IP4_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, ip1); - nm_ip4_address_set_prefix (addr, prefix); - nm_ip4_address_set_gateway (addr, gw); - nm_setting_ip4_config_add_address (s_ip4, addr); - nm_ip4_address_unref (addr); + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + g_assert_no_error (error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); /* IP6 setting */ - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); ASSERT (nm_connection_verify (connection, &error) == TRUE, @@ -13518,13 +12440,12 @@ test_write_infiniband (void) "infiniband-write", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, TYPE_INFINIBAND, - NULL, &unmanaged, &keyfile, &routefile, @@ -13565,12 +12486,9 @@ test_read_bond_slave_ib (void) gboolean ignore_error = FALSE; GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, - "*ignoring IP4 config on slave*"); connection = connection_from_file (TEST_IFCFG_BOND_SLAVE_IB, NULL, NULL, - NULL, &unmanaged, &keyfile, &routefile, @@ -13612,11 +12530,7 @@ test_write_bond_slave_ib (void) NMConnection *reread; NMSettingConnection *s_con; NMSettingInfiniband *s_infiniband; - static unsigned char tmpmac[] = { - 0x80, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, - 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22 - }; - GByteArray *mac; + static const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; char *uuid; gboolean success; GError *error = NULL; @@ -13627,7 +12541,7 @@ test_write_bond_slave_ib (void) char *route6file = NULL; gboolean ignore_error = FALSE; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -13648,15 +12562,11 @@ test_write_bond_slave_ib (void) s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new (); nm_connection_add_setting (connection, NM_SETTING (s_infiniband)); - mac = g_byte_array_sized_new (sizeof (tmpmac)); - g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac)); - g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, NM_SETTING_INFINIBAND_MTU, 2044, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); - g_byte_array_free (mac, TRUE); ASSERT (nm_connection_verify (connection, &error) == TRUE, "bond-slave-write-ib", "failed to verify connection: %s", @@ -13675,13 +12585,12 @@ test_write_bond_slave_ib (void) "bond-slave-write-ib", "didn't get ifcfg file path back after writing connection"); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ reread = connection_from_file (testfile, NULL, NULL, - NULL, &unmanaged, &keyfile, &routefile, @@ -13731,7 +12640,7 @@ test_read_dcb_basic (void) gboolean expected_pfcs[8] = { TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE }; connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -13787,8 +12696,8 @@ test_write_dcb_basic (void) NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingDcb *s_dcb; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; gboolean success, ignore_error; guint i; char *uuid, *testfile; @@ -13799,7 +12708,7 @@ test_write_dcb_basic (void) const guint traffic_classes[8] = { 3, 4, 7, 2, 1, 0, 5, 6 }; const gboolean pfcs[8] = { TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE }; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); @@ -13817,12 +12726,12 @@ test_write_dcb_basic (void) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP stuff */ - 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); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + g_object_set (G_OBJECT (s_ip4), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); - g_object_set (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); + g_object_set (G_OBJECT (s_ip6), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); /* DCB */ @@ -13864,7 +12773,7 @@ test_write_dcb_basic (void) reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, &error, &ignore_error); @@ -13889,7 +12798,7 @@ test_read_dcb_default_app_priorities (void) gboolean success; connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-default-app-priorities", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -13920,10 +12829,10 @@ test_read_dcb_bad_booleans (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*invalid DCB_PG_STRICT value*not all 0s and 1s*"); connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-booleans", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "invalid boolean digit")); g_assert (connection == NULL); } @@ -13937,10 +12846,10 @@ test_read_dcb_short_booleans (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*DCB_PG_STRICT value*8 characters*"); connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-booleans", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "boolean array must be 8 characters")); g_assert (connection == NULL); } @@ -13954,10 +12863,10 @@ test_read_dcb_bad_uints (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*invalid DCB_PG_UP2TC value*not 0 - 7*"); connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-uints", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "invalid uint digit")); g_assert (connection == NULL); } @@ -13971,10 +12880,10 @@ test_read_dcb_short_uints (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*DCB_PG_UP2TC value*8 characters*"); connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-uints", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "uint array must be 8 characters")); g_assert (connection == NULL); } @@ -13988,10 +12897,10 @@ test_read_dcb_bad_percent (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*invalid DCB_PG_PCT percentage value*"); connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-percent", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "invalid percent element")); g_assert (connection == NULL); } @@ -14005,10 +12914,10 @@ test_read_dcb_short_percent (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*invalid DCB_PG_PCT percentage list value*"); connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-percent", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "percent array must be 8 elements")); g_assert (connection == NULL); } @@ -14022,10 +12931,10 @@ test_read_dcb_pgpct_not_100 (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*DCB_PG_PCT percentages do not equal 100*"); connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-pgpct-not-100", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "invalid percentage sum")); g_assert (connection == NULL); } @@ -14041,7 +12950,7 @@ test_read_fcoe_mode (gconstpointer user_data) char *file; file = g_strdup_printf (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-fcoe-%s", expected_mode); - connection = connection_from_file (file, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + connection = connection_from_file (file, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_free (file); g_assert_no_error (error); g_assert (connection); @@ -14067,12 +12976,12 @@ test_write_fcoe_mode (gconstpointer user_data) NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingDcb *s_dcb; - NMSettingIP4Config *s_ip4; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; gboolean success, ignore_error; char *uuid, *testfile; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); @@ -14090,12 +12999,12 @@ test_write_fcoe_mode (gconstpointer user_data) nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP stuff */ - 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); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + g_object_set (G_OBJECT (s_ip4), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); - g_object_set (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); + g_object_set (G_OBJECT (s_ip6), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); /* DCB */ @@ -14134,7 +13043,7 @@ test_write_fcoe_mode (gconstpointer user_data) reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, &error, &ignore_error); @@ -14161,7 +13070,7 @@ test_read_team_master (void) const char *expected_config = "{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }"; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-master", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); @@ -14169,13 +13078,14 @@ test_read_team_master (void) g_assert_no_error (error); g_assert (success); + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "team0"); + s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_TEAM_SETTING_NAME); s_team = nm_connection_get_setting_team (connection); g_assert (s_team); - g_assert_cmpstr (nm_setting_team_get_interface_name (s_team), ==, "team0"); g_assert_cmpstr (nm_setting_team_get_config (s_team), ==, expected_config); g_object_unref (connection); @@ -14188,6 +13098,8 @@ test_write_team_master (void) NMSettingConnection *s_con; NMSettingTeam *s_team; NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; char *uuid, *testfile = NULL, *val; gboolean success; GError *error = NULL; @@ -14195,7 +13107,7 @@ test_write_team_master (void) const char *escaped_expected_config = "\"{ \\\"device\\\": \\\"team0\\\", \\\"link_watch\\\": { \\\"name\\\": \\\"ethtool\\\" } }\""; shvarFile *f; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -14205,6 +13117,7 @@ test_write_team_master (void) g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Team Master", NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_INTERFACE_NAME, "team0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); g_free (uuid); @@ -14214,7 +13127,6 @@ test_write_team_master (void) nm_connection_add_setting (connection, NM_SETTING (s_team)); g_object_set (s_team, - NM_SETTING_TEAM_INTERFACE_NAME, "team0", NM_SETTING_TEAM_CONFIG, expected_config, NULL); @@ -14222,9 +13134,25 @@ test_write_team_master (void) s_wired = (NMSettingWired *) nm_setting_wired_new (); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - success = nm_connection_verify (connection, &error); - g_assert_no_error (error); - g_assert (success); + /* IP4 setting */ + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + g_assert (s_ip4); + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, + NULL); + + /* IP6 setting */ + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); + g_assert (s_ip6); + nm_connection_add_setting (connection, NM_SETTING (s_ip6)); + + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, + NULL); + + nmtst_assert_connection_verifies_without_normalization (connection); /* Save the ifcfg */ success = writer_new_connection (connection, @@ -14250,10 +13178,10 @@ test_write_team_master (void) svCloseFile (f); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ - reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL, + reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); unlink (testfile); g_assert_no_error (error); @@ -14281,7 +13209,7 @@ test_read_team_port (void) const char *expected_config = "{ \"p4p1\": { \"prio\": -10, \"sticky\": true } }"; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); @@ -14315,7 +13243,7 @@ test_write_team_port (void) const char *escaped_expected_config = "\"{ \\\"p4p1\\\": { \\\"prio\\\": -10, \\\"sticky\\\": true } }\""; shvarFile *f; - connection = nm_connection_new (); + connection = nm_simple_connection_new (); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -14373,10 +13301,10 @@ test_write_team_port (void) svCloseFile (f); /* reread will be normalized, so we must normalize connection too. */ - nm_utils_normalize_connection (connection, TRUE); + nm_connection_normalize (connection, NULL, NULL, NULL); /* re-read the connection for comparison */ - reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL, + reread = connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); unlink (testfile); g_assert_no_error (error); @@ -14402,7 +13330,7 @@ test_read_team_port_empty_config (void) GError *error = NULL; connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port-empty-config", - NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_assert_no_error (error); g_assert (connection); @@ -14415,8 +13343,11 @@ test_read_team_port_empty_config (void) g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); g_assert_cmpstr (nm_setting_connection_get_master (s_con), ==, "team0"); - /* Empty TEAM_PORT_CONFIG means no team-port setting */ - g_assert (nm_connection_get_setting_team_port (connection) == NULL); + /* Normalization adds a team-port setting */ + g_assert (nm_connection_get_setting_team_port (connection)); + + /* empty/missing config */ + g_assert (!nm_setting_team_port_get_config (nm_connection_get_setting_team_port (connection))); g_object_unref (connection); } @@ -14468,13 +13399,13 @@ test_svUnescape_assert (const char *str) } static void -test_svUnescape () +test_svUnescape (void) { int len, repeat, i, k; - GRand *rand = g_rand_new (); + GRand *r = g_rand_new (); guint32 seed = g_random_int (); - g_rand_set_seed (rand, seed); + g_rand_set_seed (r, seed); test_svUnescape_assert (""); test_svUnescape_assert ("'"); @@ -14495,16 +13426,16 @@ test_svUnescape () /* fill the entire string with random. */ for (i = 0; i < len; i++) - s[i] = g_rand_int (rand); + s[i] = g_rand_int (r); /* randomly place escape characters into the string */ - k = g_rand_int (rand) % (len); + k = g_rand_int (r) % (len); while (k-- > 0) - s[g_rand_int (rand) % len] = '\\'; + s[g_rand_int (r) % len] = '\\'; if (len > 1) { /* quote the string. */ - k = g_rand_int (rand) % (10); + k = g_rand_int (r) % (10); if (k < 4) { char quote = k < 2 ? '"' : '\''; @@ -14520,7 +13451,44 @@ test_svUnescape () g_free (s); } - g_rand_free (rand); + g_rand_free (r); +} + +static void +test_read_vlan_trailing_spaces (void) +{ + const char *testfile = TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-trailing-spaces"; + NMConnection *connection; + gboolean success; + GError *error = NULL; + NMSettingVlan *s_vlan; + char *contents = NULL; + + /* Ensure there is whitespace at the end of the VLAN interface name, + * to prevent the whitespace getting stripped off and committed mistakenly + * by something in the future. + */ + success = g_file_get_contents (testfile, &contents, NULL, &error); + g_assert_no_error (error); + g_assert (success); + g_assert (contents && contents[0]); + g_assert (strstr (contents, "DEVICE=\"vlan201\" \n")); + g_free (contents); + + connection = connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL, + NULL, NULL, NULL, &error, NULL); + g_assert_no_error (error); + g_assert (connection != NULL); + + s_vlan = nm_connection_get_setting_vlan (connection); + g_assert (s_vlan); + + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "vlan201"); + g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "enccw0.0.fb00"); + g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 201); + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 0); + + g_object_unref (connection); } @@ -14548,11 +13516,13 @@ int main (int argc, char **argv) nmtst_init_assert_logging (&argc, &argv); g_test_add_func (TPATH "svUnescape", test_svUnescape); + g_test_add_func (TPATH "vlan-trailing-spaces", test_read_vlan_trailing_spaces); g_test_add_func (TPATH "unmanaged", test_read_unmanaged); g_test_add_func (TPATH "unmanaged-unrecognized", test_read_unmanaged_unrecognized); g_test_add_func (TPATH "unrecognized", test_read_unrecognized); g_test_add_func (TPATH "basic", test_read_basic); + g_test_add_func (TPATH "miscellaneous-variables", test_read_miscellaneous_variables); g_test_add_func (TPATH "variables-corner-cases", test_read_variables_corner_cases); g_test_add_data_func (TPATH "no-prefix/8", GUINT_TO_POINTER (8), test_read_wired_static_no_prefix); g_test_add_data_func (TPATH "no-prefix/16", GUINT_TO_POINTER (16), test_read_wired_static_no_prefix); @@ -14560,18 +13530,18 @@ int main (int argc, char **argv) g_test_add_data_func (TPATH "static-ip6-only-gw/_NULL_", NULL, test_write_wired_static_ip6_only_gw); g_test_add_data_func (TPATH "static-ip6-only-gw/::", "::", test_write_wired_static_ip6_only_gw); g_test_add_data_func (TPATH "static-ip6-only-gw/2001:db8:8:4::2", "2001:db8:8:4::2", test_write_wired_static_ip6_only_gw); - g_test_add_data_func (TPATH "static-ip6-only-gw/ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255", "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255", test_write_wired_static_ip6_only_gw); + g_test_add_data_func (TPATH "static-ip6-only-gw/::ffff:255.255.255.255", "::ffff:255.255.255.255", test_write_wired_static_ip6_only_gw); test_read_wired_static (TEST_IFCFG_WIRED_STATIC, "System test-wired-static", TRUE); test_read_wired_static (TEST_IFCFG_WIRED_STATIC_BOOTPROTO, "System test-wired-static-bootproto", FALSE); test_read_wired_dhcp (); g_test_add_func (TPATH "dhcp-plus-ip", test_read_wired_dhcp_plus_ip); g_test_add_func (TPATH "dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname); - test_read_wired_global_gateway (); - test_read_wired_never_default (); + g_test_add_func (TPATH "global-gateway", test_read_wired_global_gateway); + g_test_add_func (TPATH "never-default", test_read_wired_never_default); test_read_wired_defroute_no (); test_read_wired_defroute_no_gatewaydev_yes (); - test_read_wired_static_routes (); + g_test_add_func (TPATH "routes/read-static", test_read_wired_static_routes); test_read_wired_static_routes_legacy (); test_read_wired_ipv4_manual (TEST_IFCFG_WIRED_IPV4_MANUAL_1, "System test-wired-ipv4-manual-1"); test_read_wired_ipv4_manual (TEST_IFCFG_WIRED_IPV4_MANUAL_2, "System test-wired-ipv4-manual-2"); @@ -14617,6 +13587,9 @@ int main (int argc, char **argv) test_read_wifi_wpa_eap_tls (); test_read_wifi_wpa_eap_ttls_tls (); test_read_wifi_wep_eap_ttls_chap (); + g_test_add_func (TPATH "wifi/read-band-a", test_read_wifi_band_a); + g_test_add_func (TPATH "wifi/read-band-a-channel-mismatch", test_read_wifi_band_a_channel_mismatch); + g_test_add_func (TPATH "wifi/read-band-bg-channel-mismatch", test_read_wifi_band_bg_channel_mismatch); g_test_add_func (TPATH "wifi/read-hidden", test_read_wifi_hidden); test_read_wired_qeth_static (); test_read_wired_ctc_static (); @@ -14697,6 +13670,7 @@ int main (int argc, char **argv) test_write_wifi_wpa_then_open (); test_write_wifi_wpa_then_wep_with_perms (); g_test_add_func (TPATH "wifi/write-hidden", test_write_wifi_hidden); + g_test_add_func (TPATH "wifi/write-band-a", test_write_wifi_band_a); test_write_wired_qeth_dhcp (); test_write_wired_ctc_dhcp (); test_write_permissions (); @@ -14707,14 +13681,9 @@ int main (int argc, char **argv) test_write_ethernet_missing_ipv6 (); /* iSCSI / ibft */ - test_read_ibft_dhcp (); - test_read_ibft_static (); - test_read_ibft_malformed ("ibft-bad-record-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-record", FALSE); - test_read_ibft_malformed ("ibft-bad-entry-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-entry", TRUE); - test_read_ibft_malformed ("ibft-bad-ipaddr-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-ipaddr", TRUE); - test_read_ibft_malformed ("ibft-bad-gateway-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-gateway", TRUE); - test_read_ibft_malformed ("ibft-bad-dns1-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-dns1", TRUE); - test_read_ibft_malformed ("ibft-bad-dns2-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-dns2", TRUE); + g_test_add_func (TPATH "ibft/ignored", test_read_ibft_ignored); + + /* Data Center Bridging (DCB) */ g_test_add_func (TPATH "dcb/read-basic", test_read_dcb_basic); g_test_add_func (TPATH "dcb/write-basic", test_write_dcb_basic); g_test_add_func (TPATH "dcb/default-app-priorities", test_read_dcb_default_app_priorities); diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c index 8318a65d..5b9e9d79 100644 --- a/src/settings/plugins/ifcfg-rh/utils.c +++ b/src/settings/plugins/ifcfg-rh/utils.c @@ -18,9 +18,14 @@ * (C) Copyright 2008 - 2012 Red Hat, Inc. */ +#include "config.h" + #include <glib.h> #include <stdlib.h> #include <string.h> + +#include "nm-core-internal.h" + #include "utils.h" #include "shvar.h" @@ -37,7 +42,7 @@ char * utils_single_quote_string (const char *str) { - static const char const drop_chars[] = "\r\n"; /* drop CR and LF */ + static const char *drop_chars = "\r\n"; /* drop CR and LF */ static const char escape_char = '\\'; /* escape char is backslash */ static const char quote_char = '\''; /* quote char is single quote */ size_t i, slen, j = 0; diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 60af599b..f4ffffd6 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -15,9 +15,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2009 - 2013 Red Hat, Inc. + * Copyright 2009 - 2014 Red Hat, Inc. */ +#include "config.h" + #include <string.h> #include <sys/types.h> #include <sys/socket.h> @@ -27,7 +29,6 @@ #include <sys/stat.h> #include <unistd.h> #include <stdio.h> -#include <netinet/ether.h> #include <nm-setting-connection.h> #include <nm-setting-wired.h> @@ -39,7 +40,7 @@ #include <nm-setting-vlan.h> #include <nm-setting-team.h> #include <nm-setting-team-port.h> -#include <nm-utils-private.h> +#include "nm-core-internal.h" #include <nm-utils.h> #include "nm-logging.h" @@ -52,13 +53,6 @@ static void -svSetValue_free (shvarFile *s, const char *key, char *value, gboolean verbatim) -{ - svSetValue (s, key, value, verbatim); - g_free (value); -} - -static void save_secret_flags (shvarFile *ifcfg, const char *key, NMSettingSecretFlags flags) @@ -156,7 +150,7 @@ write_secret_file (const char *path, errno = 0; fd = mkstemp (tmppath); if (fd < 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create temporary file for '%s': %d", path, errno); goto out; @@ -167,7 +161,7 @@ write_secret_file (const char *path, if (fchmod (fd, S_IRUSR | S_IWUSR)) { close (fd); unlink (tmppath); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not set permissions for temporary file '%s': %d", path, errno); goto out; @@ -178,7 +172,7 @@ write_secret_file (const char *path, if (written != len) { close (fd); unlink (tmppath); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not write temporary file for '%s': %d", path, errno); goto out; @@ -189,7 +183,7 @@ write_secret_file (const char *path, errno = 0; if (rename (tmppath, path)) { unlink (tmppath); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not rename temporary file to '%s': %d", path, errno); goto out; @@ -205,7 +199,7 @@ typedef struct ObjectType { const char *setting_key; NMSetting8021xCKScheme (*scheme_func)(NMSetting8021x *setting); const char * (*path_func) (NMSetting8021x *setting); - const GByteArray * (*blob_func) (NMSetting8021x *setting); + GBytes * (*blob_func) (NMSetting8021x *setting); const char *ifcfg_key; const char *suffix; } ObjectType; @@ -290,7 +284,7 @@ write_object (NMSetting8021x *s_8021x, { NMSetting8021xCKScheme scheme; const char *path = NULL; - const GByteArray *blob = NULL; + GBytes *blob = NULL; g_return_val_if_fail (ifcfg != NULL, FALSE); g_return_val_if_fail (objtype != NULL, FALSE); @@ -345,7 +339,7 @@ write_object (NMSetting8021x *s_8021x, new_file = utils_cert_path (ifcfg->fileName, objtype->suffix); if (!new_file) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create file path for %s / %s", NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key); return FALSE; @@ -355,13 +349,16 @@ write_object (NMSetting8021x *s_8021x, * can use paths from now on instead of pushing around the certificate * data itself. */ - success = write_secret_file (new_file, (const char *) blob->data, blob->len, &write_error); + success = write_secret_file (new_file, + (const char *) g_bytes_get_data (blob, NULL), + g_bytes_get_size (blob), + &write_error); if (success) { svSetValue (ifcfg, objtype->ifcfg_key, new_file, FALSE); g_free (new_file); return TRUE; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not write certificate/key for %s / %s: %s", NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key, (write_error && write_error->message) ? write_error->message : "(unknown)"); @@ -614,7 +611,7 @@ write_wireless_security_setting (NMConnection *connection, s_wsec = nm_connection_get_setting_wireless_security (connection); if (!s_wsec) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); return FALSE; } @@ -808,49 +805,37 @@ write_wireless_setting (NMConnection *connection, { NMSettingWireless *s_wireless; char *tmp, *tmp2; - const GByteArray *ssid, *device_mac, *cloned_mac, *bssid; - const char *mode; + GBytes *ssid; + const guint8 *ssid_data; + gsize ssid_len; + const char *mode, *bssid; + const char *device_mac, *cloned_mac; char buf[33]; guint32 mtu, chan, i; gboolean adhoc = FALSE, hex_ssid = FALSE; - const GSList *macaddr_blacklist; + const char * const *macaddr_blacklist; s_wireless = nm_connection_get_setting_wireless (connection); if (!s_wireless) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; } - svSetValue (ifcfg, "HWADDR", NULL, FALSE); device_mac = nm_setting_wireless_get_mac_address (s_wireless); - if (device_mac) { - svSetValue_free (ifcfg, "HWADDR", - nm_utils_hwaddr_ntoa_len (device_mac->data, device_mac->len), FALSE); - } + svSetValue (ifcfg, "HWADDR", device_mac, FALSE); - svSetValue (ifcfg, "MACADDR", NULL, FALSE); cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless); - if (cloned_mac) { - svSetValue_free (ifcfg, "MACADDR", - nm_utils_hwaddr_ntoa_len (cloned_mac->data, cloned_mac->len), FALSE); - } + svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); svSetValue (ifcfg, "HWADDR_BLACKLIST", NULL, FALSE); macaddr_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless); - if (macaddr_blacklist) { - const GSList *iter; - GString *blacklist_str = g_string_new (NULL); + if (macaddr_blacklist[0]) { + char *blacklist_str; - for (iter = macaddr_blacklist; iter; iter = g_slist_next (iter)) { - g_string_append (blacklist_str, iter->data); - g_string_append_c (blacklist_str, ' '); - - } - if (blacklist_str->len > 0) - g_string_truncate (blacklist_str, blacklist_str->len - 1); - svSetValue (ifcfg, "HWADDR_BLACKLIST", blacklist_str->str, FALSE); - g_string_free (blacklist_str, TRUE); + blacklist_str = g_strjoinv (" ", (char **) macaddr_blacklist); + svSetValue (ifcfg, "HWADDR_BLACKLIST", blacklist_str, FALSE); + g_free (blacklist_str); } svSetValue (ifcfg, "MTU", NULL, FALSE); @@ -863,12 +848,13 @@ write_wireless_setting (NMConnection *connection, ssid = nm_setting_wireless_get_ssid (s_wireless); if (!ssid) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; } - if (!ssid->len || ssid->len > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + ssid_data = g_bytes_get_data (ssid, &ssid_len); + if (!ssid_len || ssid_len > 32) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; } @@ -876,8 +862,8 @@ write_wireless_setting (NMConnection *connection, /* If the SSID contains any non-printable characters, we need to use the * hex notation of the SSID instead. */ - for (i = 0; i < ssid->len; i++) { - if (!g_ascii_isprint (ssid->data[i])) { + for (i = 0; i < ssid_len; i++) { + if (!g_ascii_isprint (ssid_data[i])) { hex_ssid = TRUE; break; } @@ -887,16 +873,16 @@ write_wireless_setting (NMConnection *connection, GString *str; /* Hex SSIDs don't get quoted */ - str = g_string_sized_new (ssid->len * 2 + 3); + str = g_string_sized_new (ssid_len * 2 + 3); g_string_append (str, "0x"); - for (i = 0; i < ssid->len; i++) - g_string_append_printf (str, "%02X", ssid->data[i]); + for (i = 0; i < ssid_len; i++) + g_string_append_printf (str, "%02X", ssid_data[i]); svSetValue (ifcfg, "ESSID", str->str, TRUE); g_string_free (str, TRUE); } else { /* Printable SSIDs always get quoted */ memset (buf, 0, sizeof (buf)); - memcpy (buf, ssid->data, ssid->len); + memcpy (buf, ssid_data, ssid_len); tmp = svEscape (buf); /* svEscape will usually quote the string, but just for consistency, @@ -917,27 +903,29 @@ write_wireless_setting (NMConnection *connection, } else if (!strcmp (mode, "adhoc")) { svSetValue (ifcfg, "MODE", "Ad-Hoc", FALSE); adhoc = TRUE; + } else if (!strcmp (mode, "ap")) { + svSetValue (ifcfg, "MODE", "Ap", FALSE); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Invalid mode '%s' in '%s' setting", mode, NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; } svSetValue (ifcfg, "CHANNEL", NULL, FALSE); + svSetValue (ifcfg, "BAND", NULL, FALSE); chan = nm_setting_wireless_get_channel (s_wireless); if (chan) { tmp = g_strdup_printf ("%u", chan); svSetValue (ifcfg, "CHANNEL", tmp, FALSE); g_free (tmp); + } else { + /* Band only set if channel is not, since channel implies band */ + svSetValue (ifcfg, "BAND", nm_setting_wireless_get_band (s_wireless), FALSE); } - svSetValue (ifcfg, "BSSID", NULL, FALSE); bssid = nm_setting_wireless_get_bssid (s_wireless); - if (bssid) { - svSetValue_free (ifcfg, "BSSID", - nm_utils_hwaddr_ntoa_len (bssid->data, bssid->len), FALSE); - } + svSetValue (ifcfg, "BSSID", bssid, FALSE); /* Ensure DEFAULTKEY and SECURITYMODE are cleared unless there's security; * otherwise there's no way to detect WEP vs. open when WEP keys aren't @@ -994,26 +982,20 @@ static gboolean write_infiniband_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) { NMSettingInfiniband *s_infiniband; - const GByteArray *mac; char *tmp; - const char *transport_mode, *parent; + const char *mac, *transport_mode, *parent; guint32 mtu; int p_key; s_infiniband = nm_connection_get_setting_infiniband (connection); if (!s_infiniband) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_INFINIBAND_SETTING_NAME); return FALSE; } - svSetValue (ifcfg, "HWADDR", NULL, FALSE); mac = nm_setting_infiniband_get_mac_address (s_infiniband); - if (mac) { - tmp = nm_utils_hwaddr_ntoa (mac->data, ARPHRD_INFINIBAND); - svSetValue (ifcfg, "HWADDR", tmp, FALSE); - g_free (tmp); - } + svSetValue (ifcfg, "HWADDR", mac, FALSE); svSetValue (ifcfg, "MTU", NULL, FALSE); mtu = nm_setting_infiniband_get_mtu (s_infiniband); @@ -1049,50 +1031,35 @@ static gboolean write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) { NMSettingWired *s_wired; - const GByteArray *device_mac, *cloned_mac; + const char *device_mac, *cloned_mac; char *tmp; const char *nettype, *portname, *ctcprot, *s390_key, *s390_val; guint32 mtu, num_opts, i; - const GPtrArray *s390_subchannels; + const char *const *s390_subchannels; GString *str; - const GSList *macaddr_blacklist; + const char * const *macaddr_blacklist; s_wired = nm_connection_get_setting_wired (connection); if (!s_wired) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_WIRED_SETTING_NAME); return FALSE; } - svSetValue (ifcfg, "HWADDR", NULL, FALSE); device_mac = nm_setting_wired_get_mac_address (s_wired); - if (device_mac) { - svSetValue_free (ifcfg, "HWADDR", - nm_utils_hwaddr_ntoa_len (device_mac->data, device_mac->len), FALSE); - } + svSetValue (ifcfg, "HWADDR", device_mac, FALSE); - svSetValue (ifcfg, "MACADDR", NULL, FALSE); cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - if (cloned_mac) { - svSetValue_free (ifcfg, "MACADDR", - nm_utils_hwaddr_ntoa_len (cloned_mac->data, cloned_mac->len), FALSE); - } + svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); svSetValue (ifcfg, "HWADDR_BLACKLIST", NULL, FALSE); macaddr_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired); - if (macaddr_blacklist) { - const GSList *iter; - GString *blacklist_str = g_string_new (NULL); - - for (iter = macaddr_blacklist; iter; iter = g_slist_next (iter)) { - g_string_append (blacklist_str, iter->data); - g_string_append_c (blacklist_str, ' '); + if (macaddr_blacklist[0]) { + char *blacklist_str; - } - if (blacklist_str->len > 0) - g_string_truncate (blacklist_str, blacklist_str->len - 1); - svSetValue (ifcfg, "HWADDR_BLACKLIST", blacklist_str->str, FALSE); - g_string_free (blacklist_str, TRUE); + blacklist_str = g_strjoinv (" ", (char **) macaddr_blacklist); + svSetValue (ifcfg, "HWADDR_BLACKLIST", blacklist_str, FALSE); + g_free (blacklist_str); } svSetValue (ifcfg, "MTU", NULL, FALSE); @@ -1106,16 +1073,14 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) svSetValue (ifcfg, "SUBCHANNELS", NULL, FALSE); s390_subchannels = nm_setting_wired_get_s390_subchannels (s_wired); if (s390_subchannels) { + int len = g_strv_length ((char **)s390_subchannels); + tmp = NULL; - if (s390_subchannels->len == 2) { - tmp = g_strdup_printf ("%s,%s", - (const char *) g_ptr_array_index (s390_subchannels, 0), - (const char *) g_ptr_array_index (s390_subchannels, 1)); - } else if (s390_subchannels->len == 3) { - tmp = g_strdup_printf ("%s,%s,%s", - (const char *) g_ptr_array_index (s390_subchannels, 0), - (const char *) g_ptr_array_index (s390_subchannels, 1), - (const char *) g_ptr_array_index (s390_subchannels, 2)); + if (len == 2) { + tmp = g_strdup_printf ("%s,%s", s390_subchannels[0], s390_subchannels[1]); + } else if (len == 3) { + tmp = g_strdup_printf ("%s,%s,%s", s390_subchannels[0], s390_subchannels[1], + s390_subchannels[2]); } svSetValue (ifcfg, "SUBCHANNELS", tmp, FALSE); g_free (tmp); @@ -1161,11 +1126,11 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) return TRUE; } -static GString * +static char * vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVlanPriorityMap map) { - GSList *strlist = NULL, *iter; - GString *value = NULL; + char **strlist; + char *value; if (map == NM_VLAN_INGRESS_MAP) g_object_get (G_OBJECT (s_vlan), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, &strlist, NULL); @@ -1174,11 +1139,11 @@ vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVlanPriorityMap ma else return NULL; - value = g_string_new (""); - for (iter = strlist; iter; iter = g_slist_next (iter)) - g_string_append_printf (value, "%s%s", value->len ? "," : "", (const char *) iter->data); - - g_slist_free_full (strlist, g_free); + if (strlist[0]) + value = g_strjoinv (",", strlist); + else + value = NULL; + g_strfreev (strlist); return value; } @@ -1191,25 +1156,25 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, NMSettingWired *s_wired; char *tmp; guint32 vlan_flags = 0; - GString *text = NULL; s_con = nm_connection_get_setting_connection (connection); if (!s_con) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "Missing connection setting"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing connection setting"); return FALSE; } s_vlan = nm_connection_get_setting_vlan (connection); if (!s_vlan) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "Missing VLAN setting"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing VLAN setting"); return FALSE; } svSetValue (ifcfg, "VLAN", "yes", FALSE); svSetValue (ifcfg, "TYPE", TYPE_VLAN, FALSE); - svSetValue (ifcfg, "DEVICE", nm_setting_vlan_get_interface_name (s_vlan), FALSE); + svSetValue (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con), FALSE); svSetValue (ifcfg, "PHYSDEV", nm_setting_vlan_get_parent (s_vlan), FALSE); - svSetValue (ifcfg, "MASTER", nm_setting_connection_get_master (s_con), FALSE); tmp = g_strdup_printf ("%d", nm_setting_vlan_get_id (s_vlan)); svSetValue (ifcfg, "VLAN_ID", tmp, FALSE); @@ -1230,15 +1195,13 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, } else if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING) svSetValue (ifcfg, "VLAN_FLAGS", "LOOSE_BINDING", FALSE); - text = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_INGRESS_MAP); - svSetValue (ifcfg, "VLAN_INGRESS_PRIORITY_MAP", text ? text->str : NULL, FALSE); - if (text) - g_string_free (text, TRUE); + tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_INGRESS_MAP); + svSetValue (ifcfg, "VLAN_INGRESS_PRIORITY_MAP", tmp, FALSE); + g_free (tmp); - text = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_EGRESS_MAP); - svSetValue (ifcfg, "VLAN_EGRESS_PRIORITY_MAP", text ? text->str : NULL, FALSE); - if (text) - g_string_free (text, TRUE); + tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_EGRESS_MAP); + svSetValue (ifcfg, "VLAN_EGRESS_PRIORITY_MAP", tmp, FALSE); + g_free (tmp); svSetValue (ifcfg, "HWADDR", NULL, FALSE); svSetValue (ifcfg, "MACADDR", NULL, FALSE); @@ -1246,24 +1209,18 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, s_wired = nm_connection_get_setting_wired (connection); if (s_wired) { - const GByteArray *device_mac, *cloned_mac; + const char *device_mac, *cloned_mac; guint32 mtu; *wired = TRUE; device_mac = nm_setting_wired_get_mac_address (s_wired); - if (device_mac) { - tmp = nm_utils_hwaddr_ntoa (device_mac->data, ARPHRD_ETHER); - svSetValue (ifcfg, "HWADDR", tmp, FALSE); - g_free (tmp); - } + if (device_mac) + svSetValue (ifcfg, "HWADDR", device_mac, FALSE); cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - if (cloned_mac) { - tmp = nm_utils_hwaddr_ntoa (cloned_mac->data, ARPHRD_ETHER); - svSetValue (ifcfg, "MACADDR", tmp, FALSE); - g_free (tmp); - } + if (cloned_mac) + svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); mtu = nm_setting_wired_get_mtu (s_wired); if (mtu) { @@ -1285,14 +1242,15 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro s_bond = nm_connection_get_setting_bond (connection); if (!s_bond) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_BOND_SETTING_NAME); return FALSE; } - iface = nm_setting_bond_get_interface_name (s_bond); + iface = nm_connection_get_interface_name (connection); if (!iface) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); return FALSE; } @@ -1336,14 +1294,15 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) s_team = nm_connection_get_setting_team (connection); if (!s_team) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_TEAM_SETTING_NAME); return FALSE; } - iface = nm_setting_team_get_interface_name (s_team); + iface = nm_connection_get_interface_name (connection); if (!iface) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); return FALSE; } @@ -1379,19 +1338,20 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error const char *iface; guint32 i; GString *opts; - const GByteArray *mac; + const char *mac; char *s; s_bridge = nm_connection_get_setting_bridge (connection); if (!s_bridge) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_BRIDGE_SETTING_NAME); return FALSE; } - iface = nm_setting_bridge_get_interface_name (s_bridge); + iface = nm_connection_get_interface_name (connection); if (!iface) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); return FALSE; } @@ -1399,11 +1359,9 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error svSetValue (ifcfg, "BRIDGING_OPTS", NULL, FALSE); svSetValue (ifcfg, "STP", "no", FALSE); svSetValue (ifcfg, "DELAY", NULL, FALSE); - svSetValue (ifcfg, "MACADDR", NULL, FALSE); mac = nm_setting_bridge_get_mac_address (s_bridge); - if (mac) - svSetValue_free (ifcfg, "MACADDR", nm_utils_hwaddr_ntoa_len (mac->data, mac->len), FALSE); + svSetValue (ifcfg, "MACADDR", mac, FALSE); /* Bridge options */ opts = g_string_sized_new (32); @@ -1701,6 +1659,7 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) GString *str; const char *master; char *tmp; + gint i_int; svSetValue (ifcfg, "NAME", nm_setting_connection_get_id (s_con), FALSE); svSetValue (ifcfg, "UUID", nm_setting_connection_get_uuid (s_con), FALSE); @@ -1709,6 +1668,12 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) nm_setting_connection_get_autoconnect (s_con) ? "yes" : "no", FALSE); + i_int = nm_setting_connection_get_autoconnect_priority (s_con); + tmp = i_int != NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT + ? g_strdup_printf ("%d", i_int) : NULL; + svSetValue (ifcfg, "AUTOCONNECT_PRIORITY", tmp, FALSE); + g_free (tmp); + /* Permissions */ svSetValue (ifcfg, "USERS", NULL, FALSE); n = nm_setting_connection_get_num_permissions (s_con); @@ -1778,14 +1743,14 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) } static gboolean -write_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError **error) +write_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError **error) { - char dest[INET_ADDRSTRLEN]; - char next_hop[INET_ADDRSTRLEN]; + const char *dest, *next_hop; char **route_items; char *route_contents; - NMIP4Route *route; - guint32 ip, prefix, metric; + NMIPRoute *route; + guint32 prefix; + gint64 metric; guint32 i, num; gboolean success = FALSE; @@ -1794,7 +1759,7 @@ write_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError g_return_val_if_fail (error != NULL, FALSE); g_return_val_if_fail (*error == NULL, FALSE); - num = nm_setting_ip4_config_get_num_routes (s_ip4); + num = nm_setting_ip_config_get_num_routes (s_ip4); if (num == 0) { unlink (filename); return TRUE; @@ -1802,28 +1767,24 @@ write_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError route_items = g_malloc0 (sizeof (char*) * (num + 1)); for (i = 0; i < num; i++) { - route = nm_setting_ip4_config_get_route (s_ip4, i); - - memset (dest, 0, sizeof (dest)); - ip = nm_ip4_route_get_dest (route); - inet_ntop (AF_INET, (const void *) &ip, &dest[0], sizeof (dest)); - - prefix = nm_ip4_route_get_prefix (route); + route = nm_setting_ip_config_get_route (s_ip4, i); - memset (next_hop, 0, sizeof (next_hop)); - ip = nm_ip4_route_get_next_hop (route); - inet_ntop (AF_INET, (const void *) &ip, &next_hop[0], sizeof (next_hop)); + dest = nm_ip_route_get_dest (route); + prefix = nm_ip_route_get_prefix (route); + next_hop = nm_ip_route_get_next_hop (route); + metric = nm_ip_route_get_metric (route); - metric = nm_ip4_route_get_metric (route); - - route_items[i] = g_strdup_printf ("%s/%u via %s metric %u\n", dest, prefix, next_hop, metric); + if (metric == -1) + route_items[i] = g_strdup_printf ("%s/%u via %s\n", dest, prefix, next_hop); + else + route_items[i] = g_strdup_printf ("%s/%u via %s metric %u\n", dest, prefix, next_hop, (guint32) metric); } route_items[num] = NULL; route_contents = g_strjoinv (NULL, route_items); g_strfreev (route_items); if (!g_file_set_contents (filename, route_contents, -1, NULL)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Writing route file '%s' failed", filename); goto error; } @@ -1839,7 +1800,7 @@ error: static gboolean write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) { - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; const char *value; char *addr_key, *prefix_key, *netmask_key, *gw_key, *metric_key, *tmp; char *route_path = NULL; @@ -1852,7 +1813,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) s_ip4 = nm_connection_get_setting_ip4_config (connection); if (s_ip4) - method = nm_setting_ip4_config_get_method (s_ip4); + method = nm_setting_ip_config_get_method (s_ip4); /* Missing IP4 setting is assumed to be DHCP */ if (!method) @@ -1895,7 +1856,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) /* Temporarily create fake IP4 setting if missing; method set to DHCP above */ if (!s_ip4) { - s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); fake_ip4 = TRUE; } @@ -1922,14 +1883,19 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) /* Write out IPADDR<n>, PREFIX<n>, GATEWAY<n> for current IP addresses * without labels. Unset obsolete NETMASK<n>. */ - num = nm_setting_ip4_config_get_num_addresses (s_ip4); + num = nm_setting_ip_config_get_num_addresses (s_ip4); for (i = n = 0; i < num; i++) { - char buf[INET_ADDRSTRLEN]; - NMIP4Address *addr; - guint32 ip; + NMIPAddress *addr; - if (i > 0 && NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i))) - continue; + addr = nm_setting_ip_config_get_address (s_ip4, i); + + if (i > 0) { + GVariant *label; + + label = nm_ip_address_get_attribute (addr, "label"); + if (label) + continue; + } if (n == 0) { /* Instead of index 0 use un-numbered variables. @@ -1948,26 +1914,14 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) gw_key = g_strdup_printf ("GATEWAY%d", n); } - addr = nm_setting_ip4_config_get_address (s_ip4, i); - - memset (buf, 0, sizeof (buf)); - ip = nm_ip4_address_get_address (addr); - inet_ntop (AF_INET, (const void *) &ip, &buf[0], sizeof (buf)); - svSetValue (ifcfg, addr_key, &buf[0], FALSE); + svSetValue (ifcfg, addr_key, nm_ip_address_get_address (addr), FALSE); - tmp = g_strdup_printf ("%u", nm_ip4_address_get_prefix (addr)); + tmp = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr)); svSetValue (ifcfg, prefix_key, tmp, FALSE); g_free (tmp); svSetValue (ifcfg, netmask_key, NULL, FALSE); - - if (nm_ip4_address_get_gateway (addr)) { - memset (buf, 0, sizeof (buf)); - ip = nm_ip4_address_get_gateway (addr); - inet_ntop (AF_INET, (const void *) &ip, &buf[0], sizeof (buf)); - svSetValue (ifcfg, gw_key, &buf[0], FALSE); - } else - svSetValue (ifcfg, gw_key, NULL, FALSE); + svSetValue (ifcfg, gw_key, NULL, FALSE); g_free (addr_key); g_free (prefix_key); @@ -1994,32 +1948,30 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) g_free (gw_key); } - num = nm_setting_ip4_config_get_num_dns (s_ip4); + svSetValue (ifcfg, "GATEWAY", nm_setting_ip_config_get_gateway (s_ip4), FALSE); + + num = nm_setting_ip_config_get_num_dns (s_ip4); for (i = 0; i < 254; i++) { - char buf[INET_ADDRSTRLEN + 1]; - guint32 ip; + const char *dns; addr_key = g_strdup_printf ("DNS%d", i + 1); if (i >= num) svSetValue (ifcfg, addr_key, NULL, FALSE); else { - ip = nm_setting_ip4_config_get_dns (s_ip4, i); - - memset (buf, 0, sizeof (buf)); - inet_ntop (AF_INET, (const void *) &ip, &buf[0], sizeof (buf)); - svSetValue (ifcfg, addr_key, &buf[0], FALSE); + dns = nm_setting_ip_config_get_dns (s_ip4, i); + svSetValue (ifcfg, addr_key, dns, FALSE); } g_free (addr_key); } - num = nm_setting_ip4_config_get_num_dns_searches (s_ip4); + num = nm_setting_ip_config_get_num_dns_searches (s_ip4); if (num > 0) { searches = g_string_new (NULL); for (i = 0; i < num; i++) { if (i > 0) g_string_append_c (searches, ' '); - g_string_append (searches, nm_setting_ip4_config_get_dns_search (s_ip4, i)); + g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip4, i)); } svSetValue (ifcfg, "DOMAIN", searches->str, FALSE); g_string_free (searches, TRUE); @@ -2028,7 +1980,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) /* DEFROUTE; remember that it has the opposite meaning from never-default */ svSetValue (ifcfg, "DEFROUTE", - nm_setting_ip4_config_get_never_default (s_ip4) ? "no" : "yes", + nm_setting_ip_config_get_never_default (s_ip4) ? "no" : "yes", FALSE); svSetValue (ifcfg, "PEERDNS", NULL, FALSE); @@ -2036,14 +1988,14 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) svSetValue (ifcfg, "DHCP_CLIENT_ID", NULL, FALSE); if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { svSetValue (ifcfg, "PEERDNS", - nm_setting_ip4_config_get_ignore_auto_dns (s_ip4) ? "no" : "yes", + nm_setting_ip_config_get_ignore_auto_dns (s_ip4) ? "no" : "yes", FALSE); svSetValue (ifcfg, "PEERROUTES", - nm_setting_ip4_config_get_ignore_auto_routes (s_ip4) ? "no" : "yes", + nm_setting_ip_config_get_ignore_auto_routes (s_ip4) ? "no" : "yes", FALSE); - value = nm_setting_ip4_config_get_dhcp_hostname (s_ip4); + value = nm_setting_ip_config_get_dhcp_hostname (s_ip4); if (value) svSetValue (ifcfg, "DHCP_HOSTNAME", value, FALSE); @@ -2051,22 +2003,22 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) * in that case, because it is NM-specific variable */ svSetValue (ifcfg, "DHCP_SEND_HOSTNAME", - nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4) ? NULL : "no", + nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) ? NULL : "no", FALSE); - value = nm_setting_ip4_config_get_dhcp_client_id (s_ip4); + value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4)); if (value) svSetValue (ifcfg, "DHCP_CLIENT_ID", value, FALSE); } svSetValue (ifcfg, "IPV4_FAILURE_FATAL", - nm_setting_ip4_config_get_may_fail (s_ip4) ? "no" : "yes", + nm_setting_ip_config_get_may_fail (s_ip4) ? "no" : "yes", FALSE); /* Static routes - route-<name> file */ route_path = utils_get_route_path (ifcfg->fileName); if (!route_path) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not get route file path for '%s'", ifcfg->fileName); goto out; } @@ -2076,18 +2028,19 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) routefile = utils_get_route_ifcfg (ifcfg->fileName, TRUE); if (!routefile) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create route file '%s'", route_path); g_free (route_path); goto out; } g_free (route_path); - num = nm_setting_ip4_config_get_num_routes (s_ip4); + num = nm_setting_ip_config_get_num_routes (s_ip4); for (i = 0; i < 256; i++) { char buf[INET_ADDRSTRLEN]; - NMIP4Route *route; - guint32 ip, metric; + NMIPRoute *route; + guint32 netmask; + gint64 metric; addr_key = g_strdup_printf ("ADDRESS%d", i); netmask_key = g_strdup_printf ("NETMASK%d", i); @@ -2100,29 +2053,23 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) svSetValue (routefile, gw_key, NULL, FALSE); svSetValue (routefile, metric_key, NULL, FALSE); } else { - route = nm_setting_ip4_config_get_route (s_ip4, i); + route = nm_setting_ip_config_get_route (s_ip4, i); - memset (buf, 0, sizeof (buf)); - ip = nm_ip4_route_get_dest (route); - inet_ntop (AF_INET, (const void *) &ip, &buf[0], sizeof (buf)); - svSetValue (routefile, addr_key, &buf[0], FALSE); + svSetValue (routefile, addr_key, nm_ip_route_get_dest (route), FALSE); memset (buf, 0, sizeof (buf)); - ip = nm_utils_ip4_prefix_to_netmask (nm_ip4_route_get_prefix (route)); - inet_ntop (AF_INET, (const void *) &ip, &buf[0], sizeof (buf)); + netmask = nm_utils_ip4_prefix_to_netmask (nm_ip_route_get_prefix (route)); + inet_ntop (AF_INET, (const void *) &netmask, &buf[0], sizeof (buf)); svSetValue (routefile, netmask_key, &buf[0], FALSE); - memset (buf, 0, sizeof (buf)); - ip = nm_ip4_route_get_next_hop (route); - inet_ntop (AF_INET, (const void *) &ip, &buf[0], sizeof (buf)); - svSetValue (routefile, gw_key, &buf[0], FALSE); + svSetValue (routefile, gw_key, nm_ip_route_get_next_hop (route), FALSE); memset (buf, 0, sizeof (buf)); - metric = nm_ip4_route_get_metric (route); - if (metric == 0) + metric = nm_ip_route_get_metric (route); + if (metric == -1) svSetValue (routefile, metric_key, NULL, FALSE); else { - tmp = g_strdup_printf ("%u", metric); + tmp = g_strdup_printf ("%u", (guint32) metric); svSetValue (routefile, metric_key, tmp, FALSE); g_free (tmp); } @@ -2157,7 +2104,7 @@ out: static void write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) { - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *base_ifcfg_dir, *base_ifcfg_name, *base_name; int i, num, base_ifcfg_name_len, base_name_len; GDir *dir; @@ -2195,17 +2142,20 @@ write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) if (!s_ip4) return; - num = nm_setting_ip4_config_get_num_addresses (s_ip4); + num = nm_setting_ip_config_get_num_addresses (s_ip4); for (i = 0; i < num; i++) { + GVariant *label_var; const char *label, *p; - char buf[INET_ADDRSTRLEN], *path, *tmp; - NMIP4Address *addr; - guint32 ip; + char *path, *tmp; + NMIPAddress *addr; shvarFile *ifcfg; - label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)); - if (!label) + addr = nm_setting_ip_config_get_address (s_ip4, i); + + label_var = nm_ip_address_get_attribute (addr, "label"); + if (!label_var) continue; + label = g_variant_get_string (label_var, NULL); if ( strncmp (label, base_name, base_name_len) != 0 || label[base_name_len] != ':') continue; @@ -2223,24 +2173,13 @@ write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) svSetValue (ifcfg, "DEVICE", label, FALSE); - addr = nm_setting_ip4_config_get_address (s_ip4, i); - - memset (buf, 0, sizeof (buf)); - ip = nm_ip4_address_get_address (addr); - inet_ntop (AF_INET, (const void *) &ip, &buf[0], sizeof (buf)); - svSetValue (ifcfg, "IPADDR", &buf[0], FALSE); + addr = nm_setting_ip_config_get_address (s_ip4, i); + svSetValue (ifcfg, "IPADDR", nm_ip_address_get_address (addr), FALSE); - tmp = g_strdup_printf ("%u", nm_ip4_address_get_prefix (addr)); + tmp = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr)); svSetValue (ifcfg, "PREFIX", tmp, FALSE); g_free (tmp); - if (nm_ip4_address_get_gateway (addr)) { - memset (buf, 0, sizeof (buf)); - ip = nm_ip4_address_get_gateway (addr); - inet_ntop (AF_INET, (const void *) &ip, &buf[0], sizeof (buf)); - svSetValue (ifcfg, "GATEWAY", &buf[0], FALSE); - } - svWriteFile (ifcfg, 0644, NULL); svCloseFile (ifcfg); } @@ -2250,15 +2189,11 @@ write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) } static gboolean -write_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **error) +write_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error) { - char dest[INET6_ADDRSTRLEN]; - char next_hop[INET6_ADDRSTRLEN]; char **route_items; char *route_contents; - NMIP6Route *route; - const struct in6_addr *ip; - guint32 prefix, metric; + NMIPRoute *route; guint32 i, num; gboolean success = FALSE; @@ -2267,7 +2202,7 @@ write_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **err g_return_val_if_fail (error != NULL, FALSE); g_return_val_if_fail (*error == NULL, FALSE); - num = nm_setting_ip6_config_get_num_routes (s_ip6); + num = nm_setting_ip_config_get_num_routes (s_ip6); if (num == 0) { unlink (filename); return TRUE; @@ -2275,28 +2210,27 @@ write_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **err route_items = g_malloc0 (sizeof (char*) * (num + 1)); for (i = 0; i < num; i++) { - route = nm_setting_ip6_config_get_route (s_ip6, i); - - memset (dest, 0, sizeof (dest)); - ip = nm_ip6_route_get_dest (route); - inet_ntop (AF_INET6, (const void *) ip, &dest[0], sizeof (dest)); - - prefix = nm_ip6_route_get_prefix (route); + route = nm_setting_ip_config_get_route (s_ip6, i); - memset (next_hop, 0, sizeof (next_hop)); - ip = nm_ip6_route_get_next_hop (route); - inet_ntop (AF_INET6, (const void *) ip, &next_hop[0], sizeof (next_hop)); - - metric = nm_ip6_route_get_metric (route); - - route_items[i] = g_strdup_printf ("%s/%u via %s metric %u\n", dest, prefix, next_hop, metric); + if (nm_ip_route_get_metric (route) == -1) { + route_items[i] = g_strdup_printf ("%s/%u via %s\n", + nm_ip_route_get_dest (route), + nm_ip_route_get_prefix (route), + nm_ip_route_get_next_hop (route)); + } else { + route_items[i] = g_strdup_printf ("%s/%u via %s metric %u\n", + nm_ip_route_get_dest (route), + nm_ip_route_get_prefix (route), + nm_ip_route_get_next_hop (route), + (guint32) nm_ip_route_get_metric (route)); + } } route_items[num] = NULL; route_contents = g_strjoinv (NULL, route_items); g_strfreev (route_items); if (!g_file_set_contents (filename, route_contents, -1, NULL)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Writing route6 file '%s' failed", filename); goto error; } @@ -2311,16 +2245,14 @@ error: static gboolean write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) { - NMSettingIP6Config *s_ip6; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingIPConfig *s_ip4; const char *value; - char *addr_key, *prefix; + char *addr_key; guint32 i, num, num4; GString *searches; - char buf[INET6_ADDRSTRLEN]; - char ipv6_defaultgw[INET6_ADDRSTRLEN]; - NMIP6Address *addr; - const struct in6_addr *ip; + NMIPAddress *addr; + const char *dns; GString *ip_str1, *ip_str2, *ip_ptr; char *route6_path; @@ -2337,7 +2269,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) return TRUE; } - value = nm_setting_ip6_config_get_method (s_ip6); + value = nm_setting_ip_config_get_method (s_ip6); g_assert (value); if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { svSetValue (ifcfg, "IPV6INIT", "no", FALSE); @@ -2352,7 +2284,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); svSetValue (ifcfg, "IPV6_AUTOCONF", "no", FALSE); svSetValue (ifcfg, "DHCPV6C", "yes", FALSE); - hostname = nm_setting_ip6_config_get_dhcp_hostname (s_ip6); + hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6); if (hostname) svSetValue (ifcfg, "DHCP_HOSTNAME", hostname, FALSE); } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { @@ -2370,62 +2302,47 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) } /* Write out IP addresses */ - num = nm_setting_ip6_config_get_num_addresses (s_ip6); + num = nm_setting_ip_config_get_num_addresses (s_ip6); ip_str1 = g_string_new (NULL); ip_str2 = g_string_new (NULL); - ipv6_defaultgw[0] = 0; for (i = 0; i < num; i++) { if (i == 0) ip_ptr = ip_str1; else ip_ptr = ip_str2; - addr = nm_setting_ip6_config_get_address (s_ip6, i); - ip = nm_ip6_address_get_address (addr); - prefix = g_strdup_printf ("%u", nm_ip6_address_get_prefix (addr)); - memset (buf, 0, sizeof (buf)); - inet_ntop (AF_INET6, (const void *) ip, buf, sizeof (buf)); + addr = nm_setting_ip_config_get_address (s_ip6, i); + if (i > 1) g_string_append_c (ip_ptr, ' '); /* separate addresses in IPV6ADDR_SECONDARIES */ - g_string_append (ip_ptr, buf); - g_string_append_c (ip_ptr, '/'); - g_string_append (ip_ptr, prefix); - g_free (prefix); - - /* We only support gateway for the first IP address for now */ - if (i == 0) { - ip = nm_ip6_address_get_gateway (addr); - if (!IN6_IS_ADDR_UNSPECIFIED (ip)) - inet_ntop (AF_INET6, ip, ipv6_defaultgw, sizeof (ipv6_defaultgw)); - } + g_string_append_printf (ip_ptr, "%s/%u", + nm_ip_address_get_address (addr), + nm_ip_address_get_prefix (addr)); } svSetValue (ifcfg, "IPV6ADDR", ip_str1->str, FALSE); svSetValue (ifcfg, "IPV6ADDR_SECONDARIES", ip_str2->str, FALSE); - svSetValue (ifcfg, "IPV6_DEFAULTGW", ipv6_defaultgw, FALSE); + svSetValue (ifcfg, "IPV6_DEFAULTGW", nm_setting_ip_config_get_gateway (s_ip6), FALSE); g_string_free (ip_str1, TRUE); g_string_free (ip_str2, TRUE); /* Write out DNS - 'DNS' key is used both for IPv4 and IPv6 */ s_ip4 = nm_connection_get_setting_ip4_config (connection); - num4 = s_ip4 ? nm_setting_ip4_config_get_num_dns (s_ip4) : 0; /* from where to start with IPv6 entries */ - num = nm_setting_ip6_config_get_num_dns (s_ip6); + num4 = s_ip4 ? nm_setting_ip_config_get_num_dns (s_ip4) : 0; /* from where to start with IPv6 entries */ + num = nm_setting_ip_config_get_num_dns (s_ip6); for (i = 0; i < 254; i++) { addr_key = g_strdup_printf ("DNS%d", i + num4 + 1); if (i >= num) svSetValue (ifcfg, addr_key, NULL, FALSE); else { - ip = nm_setting_ip6_config_get_dns (s_ip6, i); - - memset (buf, 0, sizeof (buf)); - inet_ntop (AF_INET6, (const void *) ip, buf, sizeof (buf)); - svSetValue (ifcfg, addr_key, buf, FALSE); + dns = nm_setting_ip_config_get_dns (s_ip6, i); + svSetValue (ifcfg, addr_key, dns, FALSE); } g_free (addr_key); } /* Write out DNS domains - 'DOMAIN' key is shared for both IPv4 and IPv6 domains */ - num = nm_setting_ip6_config_get_num_dns_searches (s_ip6); + num = nm_setting_ip_config_get_num_dns_searches (s_ip6); if (num > 0) { char *ip4_domains; ip4_domains = svGetValue (ifcfg, "DOMAIN", FALSE); @@ -2433,7 +2350,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) for (i = 0; i < num; i++) { if (searches->len > 0) g_string_append_c (searches, ' '); - g_string_append (searches, nm_setting_ip6_config_get_dns_search (s_ip6, i)); + g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip6, i)); } svSetValue (ifcfg, "DOMAIN", searches->str, FALSE); g_string_free (searches, TRUE); @@ -2442,7 +2359,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) /* handle IPV6_DEFROUTE */ /* IPV6_DEFROUTE has the opposite meaning from 'never-default' */ - if (nm_setting_ip6_config_get_never_default(s_ip6)) + if (nm_setting_ip_config_get_never_default(s_ip6)) svSetValue (ifcfg, "IPV6_DEFROUTE", "no", FALSE); else svSetValue (ifcfg, "IPV6_DEFROUTE", "yes", FALSE); @@ -2451,22 +2368,22 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) svSetValue (ifcfg, "IPV6_PEERROUTES", NULL, FALSE); if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { svSetValue (ifcfg, "IPV6_PEERDNS", - nm_setting_ip6_config_get_ignore_auto_dns (s_ip6) ? "no" : "yes", + nm_setting_ip_config_get_ignore_auto_dns (s_ip6) ? "no" : "yes", FALSE); svSetValue (ifcfg, "IPV6_PEERROUTES", - nm_setting_ip6_config_get_ignore_auto_routes (s_ip6) ? "no" : "yes", + nm_setting_ip_config_get_ignore_auto_routes (s_ip6) ? "no" : "yes", FALSE); } svSetValue (ifcfg, "IPV6_FAILURE_FATAL", - nm_setting_ip6_config_get_may_fail (s_ip6) ? "no" : "yes", + nm_setting_ip_config_get_may_fail (s_ip6) ? "no" : "yes", FALSE); /* IPv6 Privacy Extensions */ svSetValue (ifcfg, "IPV6_PRIVACY", NULL, FALSE); svSetValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", NULL, FALSE); - switch (nm_setting_ip6_config_get_ip6_privacy (s_ip6)){ + switch (nm_setting_ip6_config_get_ip6_privacy (NM_SETTING_IP6_CONFIG (s_ip6))){ case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: svSetValue (ifcfg, "IPV6_PRIVACY", "no", FALSE); break; @@ -2484,7 +2401,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) /* Static routes go to route6-<dev> file */ route6_path = utils_get_route6_path (ifcfg->fileName); if (!route6_path) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not get route6 file path for '%s'", ifcfg->fileName); goto error; } @@ -2502,7 +2419,6 @@ error: static char * escape_id (const char *id) { - static const char const as_dash[] = "\\][|/=()!"; char *escaped = g_strdup (id); char *p = escaped; @@ -2510,7 +2426,7 @@ escape_id (const char *id) while (*p) { if (*p == ' ') *p = '_'; - else if (strchr (as_dash, *p)) + else if (strchr ("\\][|/=()!", *p)) *p = '-'; p++; } @@ -2573,7 +2489,7 @@ write_connection (NMConnection *connection, g_free (escaped); if (ifcfg_name == NULL) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Failed to find usable ifcfg file name"); return FALSE; } @@ -2583,7 +2499,7 @@ write_connection (NMConnection *connection, type = nm_setting_connection_get_connection_type (s_con); if (!type) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing connection type!"); goto out; } @@ -2591,7 +2507,7 @@ write_connection (NMConnection *connection, if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) { // FIXME: can't write PPPoE at this time if (nm_connection_get_setting_pppoe (connection)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Can't write connection type '%s'", NM_SETTING_PPPOE_SETTING_NAME); goto out; @@ -2619,7 +2535,7 @@ write_connection (NMConnection *connection, if (!write_bridge_setting (connection, ifcfg, error)) goto out; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Can't write connection type '%s'", type); goto out; } @@ -2684,7 +2600,7 @@ writer_can_write_connection (NMConnection *connection, GError **error) s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "The ifcfg-rh plugin cannot write the connection '%s' (type '%s' pppoe %d)", nm_connection_get_id (connection), nm_setting_connection_get_connection_type (s_con), |