summary refs log tree commit diff
path: root/src/settings/plugins/ifnet
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2015-01-22 00:29:39 +0100
committerMichael Biebl <biebl@debian.org>2015-01-22 00:29:39 +0100
commit2c032d8f1c6292c1338a615e6ec40252889ba85c (patch)
tree1f77182220b2b0264288ba4a476ab47e5bc48716 /src/settings/plugins/ifnet
parent33491bc4279481db8ae47213e34a6d695a0e8830 (diff)
Imported Upstream version 1.0.0 upstream/1.0.0
Diffstat (limited to 'src/settings/plugins/ifnet')
-rw-r--r--src/settings/plugins/ifnet/Makefile.am27
-rw-r--r--src/settings/plugins/ifnet/Makefile.in46
-rw-r--r--src/settings/plugins/ifnet/connection_parser.c710
-rw-r--r--src/settings/plugins/ifnet/errors.c35
-rw-r--r--src/settings/plugins/ifnet/errors.h30
-rw-r--r--src/settings/plugins/ifnet/net_parser.c2
-rw-r--r--src/settings/plugins/ifnet/net_utils.c229
-rw-r--r--src/settings/plugins/ifnet/net_utils.h22
-rw-r--r--src/settings/plugins/ifnet/nm-ifnet-connection.c5
-rw-r--r--src/settings/plugins/ifnet/nm-ifnet-connection.h4
-rw-r--r--src/settings/plugins/ifnet/plugin.c4
-rw-r--r--src/settings/plugins/ifnet/tests/Makefile.am18
-rw-r--r--src/settings/plugins/ifnet/tests/Makefile.in53
-rw-r--r--src/settings/plugins/ifnet/tests/test_all.c68
-rw-r--r--src/settings/plugins/ifnet/wpa_parser.c4
15 files changed, 530 insertions, 727 deletions
diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am
index a22ea557..b0cfd9a1 100644
--- a/src/settings/plugins/ifnet/Makefile.am
+++ b/src/settings/plugins/ifnet/Makefile.am
@@ -4,21 +4,15 @@ SUBDIRS = . tests
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src \
-	-I$(top_srcdir)/src/config \
-	-I$(top_srcdir)/src/logging \
 	-I$(top_srcdir)/src/platform \
 	-I$(top_srcdir)/src/settings \
 	-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 \
 	-DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \
+	-DNETWORKMANAGER_COMPILATION \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
 	$(GLIB_CFLAGS) \
-	$(DBUS_CFLAGS) \
-	$(POLKIT_CFLAGS) \
-	$(GUDEV_CFLAGS) \
 	-DSYSCONFDIR=\"$(sysconfdir)\"
 	-DSBINDIR=\"$(sbindir)\"
 
@@ -34,12 +28,7 @@ libnm_settings_plugin_ifnet_la_SOURCES = \
 
 libnm_settings_plugin_ifnet_la_LDFLAGS = -module -avoid-version
 
-libnm_settings_plugin_ifnet_la_LIBADD = \
-	$(top_builddir)/libnm-util/libnm-util.la \
-	$(top_builddir)/libnm-glib/libnm-glib.la \
-	lib-ifnet-io.la\
-	$(GLIB_LIBS) \
-	$(GUDEV_LIBS)
+libnm_settings_plugin_ifnet_la_LIBADD = lib-ifnet-io.la
 
 lib_ifnet_io_la_SOURCES = \
 	net_parser.c\
@@ -49,10 +38,4 @@ lib_ifnet_io_la_SOURCES = \
 	net_utils.h\
 	net_utils.c\
 	wpa_parser.h\
-	wpa_parser.c \
-	errors.h \
-	errors.c
-
-lib_ifnet_io_la_LIBADD = \
-	 $(top_builddir)/libnm-util/libnm-util.la \
-	 $(GLIB_LIBS)
+	wpa_parser.c
diff --git a/src/settings/plugins/ifnet/Makefile.in b/src/settings/plugins/ifnet/Makefile.in
index 6a658189..11e9297f 100644
--- a/src/settings/plugins/ifnet/Makefile.in
+++ b/src/settings/plugins/ifnet/Makefile.in
@@ -130,20 +130,15 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES)
-am__DEPENDENCIES_1 =
-lib_ifnet_io_la_DEPENDENCIES =  \
-	$(top_builddir)/libnm-util/libnm-util.la $(am__DEPENDENCIES_1)
+lib_ifnet_io_la_LIBADD =
 am_lib_ifnet_io_la_OBJECTS = net_parser.lo connection_parser.lo \
-	net_utils.lo wpa_parser.lo errors.lo
+	net_utils.lo wpa_parser.lo
 lib_ifnet_io_la_OBJECTS = $(am_lib_ifnet_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 = 
-libnm_settings_plugin_ifnet_la_DEPENDENCIES =  \
-	$(top_builddir)/libnm-util/libnm-util.la \
-	$(top_builddir)/libnm-glib/libnm-glib.la lib-ifnet-io.la \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+libnm_settings_plugin_ifnet_la_DEPENDENCIES = lib-ifnet-io.la
 am_libnm_settings_plugin_ifnet_la_OBJECTS = nm-ifnet-connection.lo \
 	plugin.lo
 libnm_settings_plugin_ifnet_la_OBJECTS =  \
@@ -266,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@
@@ -389,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@
@@ -408,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@
@@ -434,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@
@@ -516,21 +515,15 @@ with_valgrind = @with_valgrind@
 SUBDIRS = . tests
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src \
-	-I$(top_srcdir)/src/config \
-	-I$(top_srcdir)/src/logging \
 	-I$(top_srcdir)/src/platform \
 	-I$(top_srcdir)/src/settings \
 	-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 \
 	-DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \
+	-DNETWORKMANAGER_COMPILATION \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
 	$(GLIB_CFLAGS) \
-	$(DBUS_CFLAGS) \
-	$(POLKIT_CFLAGS) \
-	$(GUDEV_CFLAGS) \
 	-DSYSCONFDIR=\"$(sysconfdir)\"
 
 pkglib_LTLIBRARIES = libnm-settings-plugin-ifnet.la
@@ -542,13 +535,7 @@ libnm_settings_plugin_ifnet_la_SOURCES = \
 	plugin.h 
 
 libnm_settings_plugin_ifnet_la_LDFLAGS = -module -avoid-version
-libnm_settings_plugin_ifnet_la_LIBADD = \
-	$(top_builddir)/libnm-util/libnm-util.la \
-	$(top_builddir)/libnm-glib/libnm-glib.la \
-	lib-ifnet-io.la\
-	$(GLIB_LIBS) \
-	$(GUDEV_LIBS)
-
+libnm_settings_plugin_ifnet_la_LIBADD = lib-ifnet-io.la
 lib_ifnet_io_la_SOURCES = \
 	net_parser.c\
 	net_parser.h\
@@ -557,13 +544,7 @@ lib_ifnet_io_la_SOURCES = \
 	net_utils.h\
 	net_utils.c\
 	wpa_parser.h\
-	wpa_parser.c \
-	errors.h \
-	errors.c
-
-lib_ifnet_io_la_LIBADD = \
-	 $(top_builddir)/libnm-util/libnm-util.la \
-	 $(GLIB_LIBS)
+	wpa_parser.c
 
 all: all-recursive
 
@@ -659,7 +640,6 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_parser.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errors.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_parser.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_utils.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ifnet-connection.Plo@am__quote@
diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c
index 85873d5f..41baf315 100644
--- a/src/settings/plugins/ifnet/connection_parser.c
+++ b/src/settings/plugins/ifnet/connection_parser.c
@@ -24,27 +24,18 @@
 #include <string.h>
 #include <arpa/inet.h>
 #include <stdlib.h>
-#include <netinet/ether.h>
 #include <errno.h>
 #include <glib/gi18n.h>
 
-#include <nm-setting-connection.h>
-#include <nm-setting-ip4-config.h>
-#include <nm-setting-ip6-config.h>
-#include <nm-setting-ppp.h>
-#include <nm-setting-pppoe.h>
-#include <nm-setting-wired.h>
-#include <nm-setting-wireless.h>
-#include <nm-setting-8021x.h>
-#include <nm-system-config-interface.h>
-#include <nm-logging.h>
-#include <nm-utils.h>
+#include "nm-system-config-interface.h"
+#include "nm-logging.h"
+#include "nm-core-internal.h"
+#include "NetworkManagerUtils.h"
 
 #include "net_utils.h"
 #include "wpa_parser.h"
 #include "connection_parser.h"
 #include "nm-ifnet-connection.h"
-#include "errors.h"
 
 static char *
 connection_id_from_ifnet_name (const char *conn_name)
@@ -52,8 +43,16 @@ connection_id_from_ifnet_name (const char *conn_name)
 	int name_len = strlen (conn_name);
 
 	/* Convert a hex-encoded conn_name (only used for wifi SSIDs) to human-readable one */
-	if ((name_len > 2) && (g_str_has_prefix (conn_name, "0x")))
-		return nm_utils_hexstr2bin (conn_name + 2, name_len - 2);
+	if ((name_len > 2) && (g_str_has_prefix (conn_name, "0x"))) {
+		GBytes *bytes = nm_utils_hexstr2bin (conn_name);
+		char *buf;
+
+		if (bytes) {
+			buf = g_strndup (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
+			g_bytes_unref (bytes);
+			return buf;
+		}
+	}
 
 	return g_strdup (conn_name);
 }
@@ -125,7 +124,7 @@ eap_simple_reader (const char *eap_method,
 	/* identity */
 	value = wpa_get_value (ssid, "identity");
 	if (!value) {
-		g_set_error (error, ifnet_plugin_error_quark (), 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;
@@ -135,7 +134,7 @@ eap_simple_reader (const char *eap_method,
 	/* password */
 	value = wpa_get_value (ssid, "password");
 	if (!value) {
-		g_set_error (error, ifnet_plugin_error_quark (), 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;
@@ -177,7 +176,7 @@ eap_tls_reader (const char *eap_method,
 	/* identity */
 	value = wpa_get_value (ssid, "identity");
 	if (!value) {
-		g_set_error (error, ifnet_plugin_error_quark (), 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;
@@ -208,11 +207,11 @@ eap_tls_reader (const char *eap_method,
 
 	/* Private key password */
 	privkey_password = wpa_get_value (ssid,
-					  phase2 ? "private_key_passwd2" :
+					  phase2 ? "private_key2_passwd" :
 					  "private_key_passwd");
 
 	if (!privkey_password) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing %s for EAP method '%s'.",
 			     phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD" :
 			     "IEEE_8021X_PRIVATE_KEY_PASSWORD", eap_method);
@@ -222,7 +221,7 @@ eap_tls_reader (const char *eap_method,
 	/* The private key itself */
 	privkey = get_cert (ssid, phase2 ? "private_key2" : "private_key", basepath);
 	if (!privkey) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing %s for EAP method '%s'.",
 			     phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" :
 			     "IEEE_8021X_PRIVATE_KEY", eap_method);
@@ -255,7 +254,7 @@ eap_tls_reader (const char *eap_method,
 	    || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) {
 		client_cert = get_cert (ssid, phase2 ? "client_cert2" : "client_cert", basepath);
 		if (!client_cert) {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Missing %s for EAP method '%s'.",
 				     phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" :
 				     "IEEE_8021X_CLIENT_CERT", eap_method);
@@ -323,7 +322,7 @@ eap_peap_reader (const char *eap_method,
 			g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER,
 				      "1", NULL);
 		else {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Unknown IEEE_8021X_PEAP_VERSION value '%s'",
 				     peapver);
 			goto done;
@@ -337,7 +336,7 @@ eap_peap_reader (const char *eap_method,
 
 	inner_auth = wpa_get_value (ssid, "phase2");
 	if (!inner_auth) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing IEEE_8021X_INNER_AUTH_METHODS.");
 		goto done;
 	}
@@ -358,7 +357,7 @@ eap_peap_reader (const char *eap_method,
 			if (!eap_tls_reader (pos, ssid, s_8021x, TRUE, basepath, error))
 				goto done;
 		} else {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
 				     *iter);
 			goto done;
@@ -374,7 +373,7 @@ eap_peap_reader (const char *eap_method,
 	}
 
 	if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "No valid IEEE_8021X_INNER_AUTH_METHODS found.");
 		goto done;
 	}
@@ -423,7 +422,7 @@ eap_ttls_reader (const char *eap_method,
 
 	tmp = wpa_get_value (ssid, "phase2");
 	if (!tmp) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing IEEE_8021X_INNER_AUTH_METHODS.");
 		goto done;
 	}
@@ -458,7 +457,7 @@ eap_ttls_reader (const char *eap_method,
 			g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP,
 				      pos, NULL);
 		} else {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
 				     *iter);
 			goto done;
@@ -499,20 +498,20 @@ guess_connection_type (const char *conn_name)
 /* Reading mac address for setting connection option.
  * Unmanaged device mac address is required by NetworkManager*/
 static gboolean
-read_mac_address (const char *conn_name, GByteArray **array, GError **error)
+read_mac_address (const char *conn_name, const char **mac, GError **error)
 {
 	const char *value = ifnet_get_data (conn_name, "mac");
 
 	if (!value || !strlen (value))
 		return TRUE;
 
-	*array = nm_utils_hwaddr_atoba (value, ARPHRD_ETHER);
-	if (!*array) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
-					 "The MAC address '%s' was invalid.", value);
+	if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) {
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+		             "The MAC address '%s' was invalid.", value);
 		return FALSE;
 	}
 
+	*mac = value;
 	return TRUE;
 }
 
@@ -521,7 +520,7 @@ make_wired_connection_setting (NMConnection *connection,
                                const char *conn_name,
                                GError **error)
 {
-	GByteArray *mac = NULL;
+	const char *mac = NULL;
 	NMSettingWired *s_wired = NULL;
 	const char *value = NULL;
 
@@ -545,7 +544,6 @@ make_wired_connection_setting (NMConnection *connection,
 		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);
@@ -555,56 +553,56 @@ make_wired_connection_setting (NMConnection *connection,
 		nm_connection_add_setting (connection, NM_SETTING (s_wired));
 }
 
-/* add NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME,
- * NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID in future*/
+/* add NM_SETTING_IP_CONFIG_DHCP_HOSTNAME,
+ * NM_SETTING_IP_CONFIG_DHCP_CLIENT_ID in future*/
 static void
 make_ip4_setting (NMConnection *connection,
                   const char *conn_name,
                   GError **error)
 {
 
-	NMSettingIP4Config *ip4_setting =
-	    NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
+	NMSettingIPConfig *ip4_setting =
+	    NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new ());
 	const char *value, *method = NULL;
 	gboolean is_static_block = is_static_ip4 (conn_name);
 	ip_block *iblock = NULL;
 
 	/* set dhcp options (dhcp_xxx) */
 	value = ifnet_get_data (conn_name, "dhcp");
-	g_object_set (ip4_setting, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, value
+	g_object_set (ip4_setting, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, value
 		      && strstr (value, "nodns") ? TRUE : FALSE,
-		      NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, value
+		      NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, value
 		      && strstr (value, "nogateway") ? TRUE : FALSE, NULL);
 
 	if (!is_static_block) {
 		method = ifnet_get_data (conn_name, "config");
 		if (!method){
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 						 "Unknown config for %s", conn_name);
 			g_object_unref (ip4_setting);
 			return;
 		}
 		if (strstr (method, "dhcp"))
 			g_object_set (ip4_setting,
-						  NM_SETTING_IP4_CONFIG_METHOD,
+						  NM_SETTING_IP_CONFIG_METHOD,
 						  NM_SETTING_IP4_CONFIG_METHOD_AUTO,
-						  NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
+						  NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL);
 		else if (strstr (method, "autoip")) {
 			g_object_set (ip4_setting,
-						  NM_SETTING_IP4_CONFIG_METHOD,
+						  NM_SETTING_IP_CONFIG_METHOD,
 						  NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
-						  NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
+						  NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL);
 			nm_connection_add_setting (connection, NM_SETTING (ip4_setting));
 			return;
 		} else if (strstr (method, "shared")) {
 			g_object_set (ip4_setting,
-						  NM_SETTING_IP4_CONFIG_METHOD,
+						  NM_SETTING_IP_CONFIG_METHOD,
 						  NM_SETTING_IP4_CONFIG_METHOD_SHARED,
-						  NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
+						  NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL);
 			nm_connection_add_setting (connection, NM_SETTING (ip4_setting));
 			return;
 		} else {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 						 "Unknown config for %s", conn_name);
 			g_object_unref (ip4_setting);
 			return;
@@ -613,7 +611,7 @@ make_ip4_setting (NMConnection *connection,
 	}else {
 		iblock = convert_ip4_config_block (conn_name);
 		if (!iblock) {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Ifnet plugin: can't aquire ip configuration for %s",
 				     conn_name);
 			g_object_unref (ip4_setting);
@@ -622,29 +620,32 @@ make_ip4_setting (NMConnection *connection,
 		/************** add all ip settings to the connection**********/
 		while (iblock) {
 			ip_block *current_iblock;
-			NMIP4Address *ip4_addr = nm_ip4_address_new ();
-
-			nm_ip4_address_set_address (ip4_addr, iblock->ip);
-			nm_ip4_address_set_prefix (ip4_addr,
-						   nm_utils_ip4_netmask_to_prefix
-						   (iblock->netmask));
-			/* currently all the IPs has the same gateway */
-			nm_ip4_address_set_gateway (ip4_addr, iblock->gateway);
-			if (iblock->gateway)
+			NMIPAddress *ip4_addr;
+			GError *local = NULL;
+
+			ip4_addr = nm_ip_address_new (AF_INET, iblock->ip, iblock->prefix, &local);
+			if (iblock->next_hop)
 				g_object_set (ip4_setting,
-					      NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES,
+					      NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES,
 					      TRUE, NULL);
-			if (!nm_setting_ip4_config_add_address (ip4_setting, ip4_addr))
-				nm_log_warn (LOGD_SETTINGS, "ignoring duplicate IP4 address");
-			nm_ip4_address_unref (ip4_addr);
+
+			if (ip4_addr) {
+				if (!nm_setting_ip_config_add_address (ip4_setting, ip4_addr))
+					nm_log_warn (LOGD_SETTINGS, "ignoring duplicate IP4 address");
+				nm_ip_address_unref (ip4_addr);
+			} else {
+				nm_log_warn (LOGD_SETTINGS, "    ignoring invalid address entry: %s", local->message);
+				g_clear_error (&local);
+			}
+
 			current_iblock = iblock;
 			iblock = iblock->next;
 			destroy_ip_block (current_iblock);
 
 		}
 		g_object_set (ip4_setting,
-		              NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
-		              NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, !has_default_ip4_route (conn_name),
+		              NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
+		              NM_SETTING_IP_CONFIG_NEVER_DEFAULT, !has_default_ip4_route (conn_name),
 		              NULL);
 	}
 
@@ -655,7 +656,7 @@ make_ip4_setting (NMConnection *connection,
 		get_dhcp_hostname_and_client_id (&dhcp_hostname, &client_id);
 		if (dhcp_hostname) {
 			g_object_set (ip4_setting,
-				      NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME,
+				      NM_SETTING_IP_CONFIG_DHCP_HOSTNAME,
 				      dhcp_hostname, NULL);
 			nm_log_info (LOGD_SETTINGS, "DHCP hostname: %s", dhcp_hostname);
 			g_free (dhcp_hostname);
@@ -686,7 +687,7 @@ make_ip4_setting (NMConnection *connection,
 
 			for (item = searches; *item; item++) {
 				if (strlen (*item)) {
-					if (!nm_setting_ip4_config_add_dns_search (ip4_setting, *item))
+					if (!nm_setting_ip_config_add_dns_search (ip4_setting, *item))
 						nm_log_warn (LOGD_SETTINGS, "    duplicate DNS domain '%s'", *item);
 				}
 			}
@@ -700,34 +701,34 @@ make_ip4_setting (NMConnection *connection,
 		ip_block *current_iblock = iblock;
 		const char *metric_str;
 		char *stripped;
-		long int metric;
-		NMIP4Route *route = nm_ip4_route_new ();
-
-		nm_ip4_route_set_dest (route, iblock->ip);
-		nm_ip4_route_set_next_hop (route, iblock->gateway);
-		nm_ip4_route_set_prefix (route,
-					 nm_utils_ip4_netmask_to_prefix
-					 (iblock->netmask));
+		gint64 metric;
+		NMIPRoute *route;
+		GError *local = NULL;
+
 		if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) {
-			metric = strtol (metric_str, NULL, 10);
-			nm_ip4_route_set_metric (route, (guint32) metric);
+			metric = nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
 		} else {
 			metric_str = ifnet_get_global_data ("metric");
 			if (metric_str) {
 				stripped = g_strdup (metric_str);
 				strip_string (stripped, '"');
-				metric = strtol (metric_str, NULL, 10);
-				nm_ip4_route_set_metric (route,
-							 (guint32) metric);
+				metric = nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
 				g_free (stripped);
-			}
+			} else
+				metric = -1;
 		}
 
-		if (!nm_setting_ip4_config_add_route (ip4_setting, route))
-			nm_log_warn (LOGD_SETTINGS, "duplicate IP4 route");
-		nm_log_info (LOGD_SETTINGS, "new IP4 route:%d\n", iblock->ip);
-
-		nm_ip4_route_unref (route);
+		route = nm_ip_route_new (AF_INET, iblock->ip, iblock->prefix, iblock->next_hop, metric, &local);
+		if (route) {
+			if (nm_setting_ip_config_add_route (ip4_setting, route))
+				nm_log_info (LOGD_SETTINGS, "new IP4 route:%s\n", iblock->ip);
+			else
+				nm_log_warn (LOGD_SETTINGS, "duplicate IP4 route");
+			nm_ip_route_unref (route);
+		} else {
+			nm_log_warn (LOGD_SETTINGS, "    ignoring invalid route entry: %s", local->message);
+			g_clear_error (&local);
+		}
 
 		current_iblock = iblock;
 		iblock = iblock->next;
@@ -743,17 +744,17 @@ make_ip6_setting (NMConnection *connection,
                   const char *conn_name,
                   GError **error)
 {
-	NMSettingIP6Config *s_ip6 = NULL;
+	NMSettingIPConfig *s_ip6 = NULL;
 	gboolean is_static_block = is_static_ip6 (conn_name);
 
 	// used to disable IPv6
 	gboolean ipv6_enabled = FALSE;
 	gchar *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL;
 	const char *value;
-	ip6_block *iblock;
+	ip_block *iblock;
 	gboolean never_default = !has_default_ip6_route (conn_name);
 
-	s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
+	s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new ();
 
 	value = ifnet_get_data (conn_name, "enable_ipv6");
 	if (value && is_true (value))
@@ -763,7 +764,7 @@ make_ip6_setting (NMConnection *connection,
 	// Currently only Manual and DHCP are supported
 	if (!ipv6_enabled) {
 		g_object_set (s_ip6,
-			      NM_SETTING_IP6_CONFIG_METHOD,
+			      NM_SETTING_IP_CONFIG_METHOD,
 			      NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL);
 		goto done;
 	} else if (!is_static_block) {
@@ -780,91 +781,98 @@ make_ip6_setting (NMConnection *connection,
 	nm_log_info (LOGD_SETTINGS, "IPv6 for %s enabled, using %s", conn_name, method);
 
 	g_object_set (s_ip6,
-		      NM_SETTING_IP6_CONFIG_METHOD, method,
-		      NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS, FALSE,
-		      NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES, FALSE,
-		      NM_SETTING_IP6_CONFIG_NEVER_DEFAULT, never_default, NULL);
+		      NM_SETTING_IP_CONFIG_METHOD, method,
+		      NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, FALSE,
+		      NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, FALSE,
+		      NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, NULL);
 
 	/* Make manual settings */
 	if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
-		ip6_block *current_iblock;
+		ip_block *current_iblock;
 
 		iblock = convert_ip6_config_block (conn_name);
 		if (!iblock) {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Ifnet plugin: can't aquire ip6 configuration for %s",
 				     conn_name);
 			goto error;
 		}
 		/* add all IPv6 addresses */
 		while (iblock) {
-			NMIP6Address *ip6_addr = nm_ip6_address_new ();
-
-			nm_ip6_address_set_address (ip6_addr, iblock->ip);
-			nm_ip6_address_set_prefix (ip6_addr, iblock->prefix);
-			if (nm_setting_ip6_config_add_address (s_ip6, ip6_addr)) {
-				nm_log_info (LOGD_SETTINGS, "ipv6 addresses count: %d",
-				             nm_setting_ip6_config_get_num_addresses (s_ip6));
+			NMIPAddress *ip6_addr;
+			GError *local = NULL;
+
+			ip6_addr = nm_ip_address_new (AF_INET6, iblock->ip, iblock->prefix, &local);
+			if (ip6_addr) {
+				if (nm_setting_ip_config_add_address (s_ip6, ip6_addr)) {
+					nm_log_info (LOGD_SETTINGS, "ipv6 addresses count: %d",
+					             nm_setting_ip_config_get_num_addresses (s_ip6));
+				} else {
+					nm_log_warn (LOGD_SETTINGS, "ignoring duplicate IP6 address");
+				}
+				nm_ip_address_unref (ip6_addr);
 			} else {
-				nm_log_warn (LOGD_SETTINGS, "ignoring duplicate IP4 address");
+				nm_log_warn (LOGD_SETTINGS, "    ignoring invalid address entry: %s", local->message);
+				g_clear_error (&local);
 			}
-			nm_ip6_address_unref (ip6_addr);
+
 			current_iblock = iblock;
 			iblock = iblock->next;
-			destroy_ip6_block (current_iblock);
+			destroy_ip_block (current_iblock);
 		}
 
 	} else if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) {
 		/* - autoconf or DHCPv6 stuff goes here */
 	}
-	// DNS Servers, set NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS TRUE here
+	// DNS Servers, set NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS TRUE here
 	set_ip6_dns_servers (s_ip6, conn_name);
 
-	/* 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 */
 
 	// Add routes
 	iblock = convert_ip6_routes_block (conn_name);
 	if (iblock)
-		g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES,
+		g_object_set (s_ip6, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES,
 			      TRUE, NULL);
 	/* Add all IPv6 routes */
 	while (iblock) {
-		ip6_block *current_iblock = iblock;
+		ip_block *current_iblock = iblock;
 		const char *metric_str;
 		char *stripped;
-		long int metric = 1;
-		NMIP6Route *route = nm_ip6_route_new ();
+		gint64 metric;
+		NMIPRoute *route;
+		GError *local = NULL;
 
-		nm_ip6_route_set_dest (route, iblock->ip);
-		nm_ip6_route_set_next_hop (route, iblock->next_hop);
-		nm_ip6_route_set_prefix (route, iblock->prefix);
 		/* metric is not per routes configuration right now
 		 * global metric is also supported (metric="x") */
-		if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) {
-			metric = strtol (metric_str, NULL, 10);
-			nm_ip6_route_set_metric (route, (guint32) metric);
-		} else {
+		if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL)
+			metric = nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
+		else {
 			metric_str = ifnet_get_global_data ("metric");
 			if (metric_str) {
 				stripped = g_strdup (metric_str);
 				strip_string (stripped, '"');
-				metric = strtol (metric_str, NULL, 10);
-				nm_ip6_route_set_metric (route,
-							 (guint32) metric);
+				metric = nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
 				g_free (stripped);
 			} else
-				nm_ip6_route_set_metric (route, (guint32) 1);
+				metric = 1;
 		}
 
-		if (nm_setting_ip6_config_add_route (s_ip6, route))
-			nm_log_info (LOGD_SETTINGS, "    new IP6 route");
-		else
-			nm_log_warn (LOGD_SETTINGS, "    duplicate IP6 route");
-		nm_ip6_route_unref (route);
+		route = nm_ip_route_new (AF_INET6, iblock->ip, iblock->prefix, iblock->next_hop, metric, &local);
+		if (route) {
+			if (nm_setting_ip_config_add_route (s_ip6, route))
+				nm_log_info (LOGD_SETTINGS, "    new IP6 route");
+			else
+				nm_log_warn (LOGD_SETTINGS, "    duplicate IP6 route");
+			nm_ip_route_unref (route);
+		} else {
+			nm_log_warn (LOGD_SETTINGS, "    ignoring invalid route entry: %s", local->message);
+			g_clear_error (&local);
+		}
 
 		current_iblock = iblock;
 		iblock = iblock->next;
-		destroy_ip6_block (current_iblock);
+		destroy_ip_block (current_iblock);
 	}
 
 done:
@@ -882,7 +890,7 @@ make_wireless_connection_setting (const char *conn_name,
                                   NMSetting8021x **s_8021x,
                                   GError **error)
 {
-	GByteArray *array, *mac = NULL;
+	const char *mac = NULL;
 	NMSettingWireless *wireless_setting = NULL;
 	gboolean adhoc = FALSE;
 	const char *value;
@@ -904,8 +912,6 @@ make_wireless_connection_setting (const char *conn_name,
 			g_object_set (wireless_setting,
 				      NM_SETTING_WIRELESS_MAC_ADDRESS, mac,
 				      NULL);
-			g_byte_array_free (mac, TRUE);
-
 		}
 	} else {
 		g_object_unref (wireless_setting);
@@ -914,51 +920,41 @@ make_wireless_connection_setting (const char *conn_name,
 
 	/* handle ssid (hex and ascii) */
 	if (conn_name) {
+		GBytes *bytes;
 		gsize ssid_len = 0, value_len = strlen (conn_name);
-		const char *p;
-		char *tmp, *converted = NULL;
 
 		ssid_len = value_len;
 		if ((value_len > 2) && (g_str_has_prefix (conn_name, "0x"))) {
 			/* Hex representation */
 			if (value_len % 2) {
-				g_set_error (error, ifnet_plugin_error_quark (),
-					     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)",
 					     conn_name);
 				goto error;
 			}
-			// ignore "0x"
-			p = conn_name + 2;
-			if (!is_hex (p)) {
-				g_set_error (error,
-					     ifnet_plugin_error_quark (),
-					     0,
-					     "Invalid SSID '%s' character (looks like hex SSID but '%c' isn't a hex digit)",
-					     conn_name, *p);
-				goto error;
 
+			bytes = nm_utils_hexstr2bin (conn_name);
+			if (!bytes) {
+				g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+				             "Invalid SSID '%s' (looks like hex SSID but isn't)",
+				             conn_name);
+				goto error;
 			}
-			tmp = nm_utils_hexstr2bin (p, value_len - 2);
-			ssid_len = (value_len - 2) / 2;
-			converted = g_malloc0 (ssid_len + 1);
-			memcpy (converted, tmp, ssid_len);
-			g_free (tmp);
-		}
+		} else
+			bytes = g_bytes_new (conn_name, value_len);
 
+		ssid_len = g_bytes_get_size (bytes);
 		if (ssid_len > 32 || ssid_len == 0) {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)",
 				     conn_name, ssid_len);
 			goto error;
 		}
-		array = g_byte_array_sized_new (ssid_len);
-		g_byte_array_append (array, (const guint8 *) (converted ? converted : conn_name), ssid_len);
-		g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, array, NULL);
-		g_byte_array_free (array, TRUE);
-		g_free (converted);
+
+		g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, bytes, NULL);
+		g_bytes_unref (bytes);
 	} else {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing SSID");
 		goto error;
 	}
@@ -980,18 +976,14 @@ make_wireless_connection_setting (const char *conn_name,
 	/* BSSID setting */
 	value = wpa_get_value (conn_name, "bssid");
 	if (value) {
-		GByteArray *bssid;
-
-		bssid = nm_utils_hwaddr_atoba (value, ARPHRD_ETHER);
-		if (!bssid) {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+		if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) {
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 						 "Invalid BSSID '%s'", value);
 			goto error;
 		}
 
 		g_object_set (wireless_setting, NM_SETTING_WIRELESS_BSSID,
-			      bssid, NULL);
-		g_byte_array_free (bssid, TRUE);
+			      value, NULL);
 
 	}
 
@@ -1043,7 +1035,7 @@ make_leap_setting (const char *ssid, GError **error)
 
 	value = wpa_get_value (ssid, "identity");
 	if (!value || !strlen (value)) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing LEAP identity");
 		goto error;
 	}
@@ -1085,8 +1077,8 @@ add_one_wep_key (const char *ssid,
 	if (strlen (value) == 10 || strlen (value) == 26) {
 		/* Hexadecimal WEP key */
 		if (!is_hex (value)) {
-			g_set_error (error, ifnet_plugin_error_quark (),
-				     0, "Invalid hexadecimal WEP key.");
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+			             "Invalid hexadecimal WEP key.");
 			goto out;
 		}
 		converted = g_strdup (value);
@@ -1097,17 +1089,17 @@ add_one_wep_key (const char *ssid,
 		char *p = strip_string (tmp, '"');
 
 		if (!is_ascii (p)) {
-			g_set_error (error, ifnet_plugin_error_quark (),
-				     0, "Invalid ASCII WEP passphrase.");
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+			             "Invalid ASCII WEP passphrase.");
 			g_free (tmp);
 			goto out;
 
 		}
 
-		converted = nm_utils_bin2hexstr (tmp, strlen (tmp), strlen (tmp) * 2);
+		converted = nm_utils_bin2hexstr (tmp, strlen (tmp), -1);
 		g_free (tmp);
 	} else {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Invalid WEP key length. Key: %s", value);
 		goto out;
 	}
@@ -1161,7 +1153,7 @@ make_wep_setting (const char *ssid, GError **error)
 				      default_key_idx, NULL);
 			nm_log_info (LOGD_SETTINGS, "Default key index: %d", default_key_idx);
 		} else {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Invalid default WEP key '%s'", value);
 			goto error;
 		}
@@ -1173,19 +1165,19 @@ make_wep_setting (const char *ssid, GError **error)
 	/* If there's a default key, ensure that key exists */
 	if ((default_key_idx == 1)
 	    && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1)) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Default WEP key index was 2, but no valid KEY2 exists.");
 		goto error;
 	} else if ((default_key_idx == 2)
 		   && !nm_setting_wireless_security_get_wep_key (s_wireless_sec,
 								 2)) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Default WEP key index was 3, but no valid KEY3 exists.");
 		goto error;
 	} else if ((default_key_idx == 3)
 		   && !nm_setting_wireless_security_get_wep_key (s_wireless_sec,
 								 3)) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Default WEP key index was 4, but no valid KEY4 exists.");
 		goto error;
 	}
@@ -1204,7 +1196,7 @@ make_wep_setting (const char *ssid, GError **error)
 				      "shared", NULL);
 			nm_log_info (LOGD_SETTINGS, "WEP: Use shared system authentication");
 		} else {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "Invalid WEP authentication algorithm '%s'",
 				     auth_alg);
 			goto error;
@@ -1218,7 +1210,7 @@ make_wep_setting (const char *ssid, GError **error)
 	    && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3)
 	    && !nm_setting_wireless_security_get_wep_tx_keyidx (s_wireless_sec)) {
 		if (auth_alg && !strcmp (auth_alg, "shared")) {
-			g_set_error (error, ifnet_plugin_error_quark (), 0,
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				     "WEP Shared Key authentication is invalid for "
 				     "unencrypted connections.");
 			goto error;
@@ -1242,7 +1234,7 @@ parse_wpa_psk (const char *psk, GError **error)
 	gboolean quoted = FALSE;
 
 	if (!psk) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing WPA_PSK for WPA-PSK key management");
 		return NULL;
 	}
@@ -1258,9 +1250,8 @@ parse_wpa_psk (const char *psk, GError **error)
 	if (!quoted && (strlen (psk) == 64)) {
 		/* Verify the hex PSK; 64 digits */
 		if (!is_hex (psk)) {
-			g_set_error (error, ifnet_plugin_error_quark (),
-				     0,
-				     "Invalid WPA_PSK (contains non-hexadecimal characters)");
+			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+			             "Invalid WPA_PSK (contains non-hexadecimal characters)");
 			goto out;
 		}
 		hashed = g_strdup (psk);
@@ -1271,7 +1262,7 @@ parse_wpa_psk (const char *psk, GError **error)
 
 		/* Length check */
 		if (strlen (stripped) < 8 || strlen (stripped) > 63) {
-			g_set_error (error, ifnet_plugin_error_quark (), 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 (stripped);
@@ -1283,7 +1274,7 @@ parse_wpa_psk (const char *psk, GError **error)
 	}
 
 	if (!hashed) {
-		g_set_error (error, ifnet_plugin_error_quark (), 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;
 	}
@@ -1367,7 +1358,7 @@ fill_8021x (const char *ssid,
 
 	value = wpa_get_value (ssid, "eap");
 	if (!value) {
-		g_set_error (error, ifnet_plugin_error_quark (), 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;
@@ -1383,7 +1374,7 @@ fill_8021x (const char *ssid,
 		char *lower = NULL;
 
 		lower = g_ascii_strdown (*iter, -1);
-		while (eap->method && !found) {
+		while (eap->method) {
 			if (strcmp (eap->method, lower))
 				goto next;
 
@@ -1404,6 +1395,7 @@ fill_8021x (const char *ssid,
 			}
 			nm_setting_802_1x_add_eap_method (s_8021x, lower);
 			found = TRUE;
+			break;
 
 		next:
 			eap++;
@@ -1417,7 +1409,7 @@ fill_8021x (const char *ssid,
 	g_strfreev (list);
 
 	if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) {
-		g_set_error (error, ifnet_plugin_error_quark (), 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;
 	}
@@ -1441,7 +1433,7 @@ make_wpa_setting (const char *ssid,
 	gboolean adhoc = FALSE;
 
 	if (!exist_ssid (ssid)) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "No security info found for ssid: %s", ssid);
 		return NULL;
 	}
@@ -1493,7 +1485,7 @@ make_wpa_setting (const char *ssid,
 				      "wpa-psk", NULL);
 	} else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) {
 		if (adhoc) {
-			g_set_error (error, ifnet_plugin_error_quark (), 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;
@@ -1507,7 +1499,7 @@ make_wpa_setting (const char *ssid,
 			      lower, NULL);
 		g_free (lower);
 	} else {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Unknown wireless KEY_MGMT type '%s'", value);
 		goto error;
 	}
@@ -1558,7 +1550,7 @@ make_wireless_security_setting (const char *conn_name,
 	}
 
 	if (!wsec) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Can't handle security information for ssid: %s",
 			     conn_name);
 	}
@@ -1574,8 +1566,8 @@ make_pppoe_connection_setting (NMConnection *connection,
                                const char *conn_name,
                                GError **error)
 {
-	NMSettingPPPOE *s_pppoe;
-	NMSettingPPP *s_ppp;
+	NMSettingPppoe *s_pppoe;
+	NMSettingPpp *s_ppp;
 	const char *value;
 
 	s_pppoe = NM_SETTING_PPPOE (nm_setting_pppoe_new ());
@@ -1583,7 +1575,7 @@ make_pppoe_connection_setting (NMConnection *connection,
 	/* username */
 	value = ifnet_get_data (conn_name, "username");
 	if (!value) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "ppp requires at lease a username");
 		return;
 	}
@@ -1599,7 +1591,7 @@ make_pppoe_connection_setting (NMConnection *connection,
 	nm_connection_add_setting (connection, NM_SETTING (s_pppoe));
 
 	/* 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));
 }
 
@@ -1618,7 +1610,7 @@ ifnet_update_connection_from_config_block (const char *conn_name,
 	gchar *id, *uuid;
 	gboolean success = FALSE;
 
-	connection = nm_connection_new ();
+	connection = nm_simple_connection_new ();
 	setting = nm_connection_get_setting_connection (connection);
 	if (!setting) {
 		setting = NM_SETTING_CONNECTION (nm_setting_connection_new ());
@@ -1637,7 +1629,7 @@ ifnet_update_connection_from_config_block (const char *conn_name,
 	id = connection_id_from_ifnet_name (conn_name);
 	uuid = g_strdup (ifnet_get_data (conn_name, "uuid"));
 	if (!uuid)
-		uuid = nm_utils_uuid_generate_from_string (id);
+		uuid = nm_utils_uuid_generate_from_string (id, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
 
 	g_object_set (setting,
 	              NM_SETTING_CONNECTION_TYPE, type,
@@ -1727,7 +1719,7 @@ error:
 
 typedef NMSetting8021xCKScheme (*SchemeFunc) (NMSetting8021x * setting);
 typedef const char *(*PathFunc) (NMSetting8021x * setting);
-typedef const GByteArray *(*BlobFunc) (NMSetting8021x * setting);
+typedef GBytes *(*BlobFunc) (NMSetting8021x * setting);
 
 typedef struct ObjectType {
 	const char *setting_key;
@@ -1813,13 +1805,13 @@ static const ObjectType phase2_p12_type = {
 static gboolean
 write_object (NMSetting8021x *s_8021x,
               const char *conn_name,
-              const GByteArray *override_data,
+              GBytes *override_data,
               const ObjectType *objtype,
               GError **error)
 {
 	NMSetting8021xCKScheme scheme;
 	const char *path = NULL;
-	const GByteArray *blob = NULL;
+	GBytes *blob = NULL;
 
 	g_return_val_if_fail (conn_name != NULL, FALSE);
 	g_return_val_if_fail (objtype != NULL, FALSE);
@@ -1867,8 +1859,8 @@ write_8021x_certs (NMSetting8021x *s_8021x,
 	char *password = NULL;
 	const ObjectType *otype = NULL;
 	gboolean is_pkcs12 = FALSE, success = FALSE;
-	const GByteArray *blob = NULL;
-	GByteArray *enc_key = NULL;
+	GBytes *blob = NULL;
+	GBytes *enc_key = NULL;
 	gchar *generated_pw = NULL;
 
 	/* CA certificate */
@@ -1915,13 +1907,17 @@ write_8021x_certs (NMSetting8021x *s_8021x,
 	 * private key file, it'll be encrypted, so we don't need to re-encrypt.
 	 */
 	if (blob && !is_pkcs12) {
+		GByteArray *tmp_enc_key;
+
 		/* Encrypt the unencrypted private key with the fake password */
-		enc_key =
-		    nm_utils_rsa_key_encrypt (blob, password, &generated_pw,
-					      error);
-		if (!enc_key)
+		tmp_enc_key =
+		    nm_utils_rsa_key_encrypt (g_bytes_get_data (blob, NULL), g_bytes_get_size (blob),
+					      password, &generated_pw, error);
+		if (!tmp_enc_key)
 			goto out;
 
+		enc_key = g_byte_array_free_to_bytes (tmp_enc_key);
+
 		if (generated_pw)
 			password = generated_pw;
 	}
@@ -1932,7 +1928,7 @@ write_8021x_certs (NMSetting8021x *s_8021x,
 		goto out;
 
 	if (phase2)
-		wpa_set_data (conn_name, "private_key_passwd2", password);
+		wpa_set_data (conn_name, "private_key2_passwd", password);
 	else
 		wpa_set_data (conn_name, "private_key_passwd", password);
 
@@ -1958,8 +1954,8 @@ out:
 		g_free (generated_pw);
 	}
 	if (enc_key) {
-		memset (enc_key->data, 0, enc_key->len);
-		g_byte_array_free (enc_key, TRUE);
+		memset ((gpointer) g_bytes_get_data (enc_key, NULL), 0, g_bytes_get_size (enc_key));
+		g_bytes_unref (enc_key);
 	}
 	return success;
 }
@@ -2073,7 +2069,7 @@ write_wireless_security_setting (NMConnection * connection,
 
 	s_wsec = nm_connection_get_setting_wireless_security (connection);
 	if (!s_wsec) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing '%s' setting",
 			     NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
 		return FALSE;
@@ -2230,8 +2226,10 @@ write_wireless_setting (NMConnection *connection,
                         GError **error)
 {
 	NMSettingWireless *s_wireless;
-	const GByteArray *ssid, *mac, *bssid;
-	const char *mode;
+	GBytes *ssid;
+	const guint8 *ssid_data;
+	gsize ssid_len;
+	const char *mac, *bssid, *mode;
 	char buf[33];
 	guint32 mtu, i;
 	gboolean adhoc = FALSE, hex_ssid = FALSE;
@@ -2239,7 +2237,7 @@ write_wireless_setting (NMConnection *connection,
 
 	s_wireless = nm_connection_get_setting_wireless (connection);
 	if (!s_wireless) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing '%s' setting",
 			     NM_SETTING_WIRELESS_SETTING_NAME);
 		return FALSE;
@@ -2247,13 +2245,14 @@ write_wireless_setting (NMConnection *connection,
 
 	ssid = nm_setting_wireless_get_ssid (s_wireless);
 	if (!ssid) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing SSID in '%s' setting",
 			     NM_SETTING_WIRELESS_SETTING_NAME);
 		return FALSE;
 	}
-	if (!ssid->len || ssid->len > 32) {
-		g_set_error (error, ifnet_plugin_error_quark (), 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_INVALID_CONNECTION,
 			     "Invalid SSID in '%s' setting",
 			     NM_SETTING_WIRELESS_SETTING_NAME);
 		return FALSE;
@@ -2263,8 +2262,8 @@ write_wireless_setting (NMConnection *connection,
 	 * the hex notation of the SSID instead. (Because openrc doesn't
 	 * support these characters, see bug #356337)
 	 */
-	for (i = 0; i < ssid->len; i++) {
-		if (!g_ascii_isalnum (ssid->data[i])) {
+	for (i = 0; i < ssid_len; i++) {
+		if (!g_ascii_isalnum (ssid_data[i])) {
 			hex_ssid = TRUE;
 			break;
 		}
@@ -2274,16 +2273,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]);
 		update_wireless_ssid (connection, conn_name, str->str, hex_ssid);
 		ssid_str = g_string_free (str, FALSE);
 	} else {
 		/* Printable SSIDs get quoted */
 		memset (buf, 0, sizeof (buf));
-		memcpy (buf, ssid->data, ssid->len);
+		memcpy (buf, ssid_data, ssid_len);
 		g_strstrip (buf);
 		update_wireless_ssid (connection, conn_name, buf, hex_ssid);
 		ssid_str = g_strdup (buf);
@@ -2291,11 +2290,8 @@ write_wireless_setting (NMConnection *connection,
 
 	ifnet_set_data (ssid_str, "mac", NULL);
 	mac = nm_setting_wireless_get_mac_address (s_wireless);
-	if (mac) {
-		tmp = nm_utils_hwaddr_ntoa_len (mac->data, mac->len);
-		ifnet_set_data (ssid_str, "mac", tmp);
-		g_free (tmp);
-	}
+	if (mac)
+		ifnet_set_data (ssid_str, "mac", mac);
 
 	ifnet_set_data (ssid_str, "mtu", NULL);
 	mtu = nm_setting_wireless_get_mtu (s_wireless);
@@ -2320,11 +2316,8 @@ write_wireless_setting (NMConnection *connection,
 
 	wpa_set_data (ssid_str, "bssid", NULL);
 	bssid = nm_setting_wireless_get_bssid (s_wireless);
-	if (bssid) {
-		tmp = nm_utils_hwaddr_ntoa_len (bssid->data, bssid->len);
-		wpa_set_data (ssid_str, "bssid", tmp);
-		g_free (tmp);
-	}
+	if (bssid)
+		wpa_set_data (ssid_str, "bssid", bssid);
 
 	if (nm_connection_get_setting_wireless_security (connection)) {
 		if (!write_wireless_security_setting
@@ -2345,13 +2338,13 @@ write_wired_setting (NMConnection *connection,
                      GError **error)
 {
 	NMSettingWired *s_wired;
-	const GByteArray *mac;
+	const char *mac;
 	char *tmp;
 	guint32 mtu;
 
 	s_wired = nm_connection_get_setting_wired (connection);
 	if (!s_wired) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing '%s' setting",
 			     NM_SETTING_WIRED_SETTING_NAME);
 		return FALSE;
@@ -2359,11 +2352,8 @@ write_wired_setting (NMConnection *connection,
 
 	ifnet_set_data (conn_name, "mac", NULL);
 	mac = nm_setting_wired_get_mac_address (s_wired);
-	if (mac) {
-		tmp = nm_utils_hwaddr_ntoa_len (mac->data, mac->len);
-		ifnet_set_data (conn_name, "mac", tmp);
-		g_free (tmp);
-	}
+	if (mac)
+		ifnet_set_data (conn_name, "mac", mac);
 
 	ifnet_set_data (conn_name, "mtu", NULL);
 	mtu = nm_setting_wired_get_mtu (s_wired);
@@ -2381,62 +2371,45 @@ write_wired_setting (NMConnection *connection,
 static gboolean
 write_ip4_setting (NMConnection *connection, const char *conn_name, GError **error)
 {
-	NMSettingIP4Config *s_ip4;
+	NMSettingIPConfig *s_ip4;
 	const char *value;
-	char *tmp;
 	guint32 i, num;
 	GString *searches;
 	GString *ips;
 	GString *routes;
 	GString *dns;
-	gboolean has_def_route = FALSE;
 	gboolean success = FALSE;
 
 	s_ip4 = nm_connection_get_setting_ip4_config (connection);
 	if (!s_ip4) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing '%s' setting",
 			     NM_SETTING_IP4_CONFIG_SETTING_NAME);
 		return FALSE;
 	}
 	routes = g_string_new (NULL);
 
-	value = nm_setting_ip4_config_get_method (s_ip4);
+	value = nm_setting_ip_config_get_method (s_ip4);
 	g_assert (value);
 	if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
 
-		num = nm_setting_ip4_config_get_num_addresses (s_ip4);
+		num = nm_setting_ip_config_get_num_addresses (s_ip4);
 		ips = g_string_new (NULL);
 		/* IPv4 addresses */
 		for (i = 0; i < num; i++) {
-			char buf[INET_ADDRSTRLEN + 1];
-			NMIP4Address *addr;
-			guint32 ip;
-
-			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));
-			g_string_append_printf (ips, "\"%s", &buf[0]);
-
-			tmp =
-			    g_strdup_printf ("%u",
-					     nm_ip4_address_get_prefix (addr));
-			g_string_append_printf (ips, "/%s\" ", tmp);
-			g_free (tmp);
+			NMIPAddress *addr;
+
+			addr = nm_setting_ip_config_get_address (s_ip4, i);
+
+			g_string_append_printf (ips, "\"%s/%u",
+			                        nm_ip_address_get_address (addr),
+			                        nm_ip_address_get_prefix (addr));
 
 			/* only the first gateway will be written */
-			if (!has_def_route && 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));
+			if (i == 0 && nm_setting_ip_config_get_gateway (s_ip4)) {
 				g_string_append_printf (routes,
-							"\"default via %s\" ",
-							&buf[0]);
-				has_def_route = TRUE;
+				                        "\"default via %s\" ",
+				                        nm_setting_ip_config_get_gateway (s_ip4));
 			}
 		}
 		ifnet_set_data (conn_name, "config", ips->str);
@@ -2449,19 +2422,14 @@ write_ip4_setting (NMConnection *connection, const char *conn_name, GError **err
 		ifnet_set_data (conn_name, "config", "dhcp");
 
 	/* DNS Servers */
-	num = nm_setting_ip4_config_get_num_dns (s_ip4);
+	num = nm_setting_ip_config_get_num_dns (s_ip4);
 	if (num > 0) {
 		dns = g_string_new (NULL);
 		for (i = 0; i < num; i++) {
-			char buf[INET_ADDRSTRLEN + 1];
-			guint32 ip;
-
-			ip = nm_setting_ip4_config_get_dns (s_ip4, i);
+			const char *ip;
 
-			memset (buf, 0, sizeof (buf));
-			inet_ntop (AF_INET, (const void *) &ip, &buf[0],
-				   sizeof (buf));
-			g_string_append_printf (dns, " %s", buf);
+			ip = nm_setting_ip_config_get_dns (s_ip4, i);
+			g_string_append_printf (dns, " %s", ip);
 		}
 		ifnet_set_data (conn_name, "dns_servers", dns->str);
 		g_string_free (dns, TRUE);
@@ -2469,14 +2437,14 @@ write_ip4_setting (NMConnection *connection, const char *conn_name, GError **err
 		ifnet_set_data (conn_name, "dns_servers", NULL);
 
 	/* DNS Searches */
-	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
+					 nm_setting_ip_config_get_dns_search
 					 (s_ip4, i));
 		}
 		ifnet_set_data (conn_name, "dns_search", searches->str);
@@ -2485,12 +2453,12 @@ write_ip4_setting (NMConnection *connection, const char *conn_name, GError **err
 		ifnet_set_data (conn_name, "dns_search", NULL);
 	/* FIXME Will be implemented when configuration supports it
 	   if (!strcmp(value, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
-	   value = nm_setting_ip4_config_get_dhcp_hostname(s_ip4);
+	   value = nm_setting_ip_config_get_dhcp_hostname(s_ip4);
 	   if (value)
 	   ifnet_set_data(conn_name, "DHCP_HOSTNAME", value,
 	   FALSE);
 
-	   value = nm_setting_ip4_config_get_dhcp_client_id(s_ip4);
+	   value = nm_setting_ip_config_get_dhcp_client_id(s_ip4);
 	   if (value)
 	   ifnet_set_data(conn_name, "DHCP_CLIENT_ID", value,
 	   FALSE);
@@ -2498,32 +2466,22 @@ write_ip4_setting (NMConnection *connection, const char *conn_name, GError **err
 	 */
 
 	/* Static routes */
-	num = nm_setting_ip4_config_get_num_routes (s_ip4);
+	num = nm_setting_ip_config_get_num_routes (s_ip4);
 	if (num > 0) {
 		for (i = 0; i < num; i++) {
-			char buf[INET_ADDRSTRLEN + 1];
-			NMIP4Route *route;
-			guint32 ip;
-
-			route = nm_setting_ip4_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));
-			g_string_append_printf (routes, "\"%s", buf);
-
-			tmp =
-			    g_strdup_printf ("%u",
-					     nm_ip4_route_get_prefix (route));
-			g_string_append_printf (routes, "/%s via ", tmp);
-			g_free (tmp);
+			NMIPRoute *route;
+			const char *next_hop;
+
+			route = nm_setting_ip_config_get_route (s_ip4, i);
+
+			next_hop = nm_ip_route_get_next_hop (route);
+			if (!next_hop)
+				next_hop = "0.0.0.0";
 
-			memset (buf, 0, sizeof (buf));
-			ip = nm_ip4_route_get_next_hop (route);
-			inet_ntop (AF_INET, (const void *) &ip, &buf[0],
-				   sizeof (buf));
-			g_string_append_printf (routes, "%s\" ", buf);
+			g_string_append_printf (routes, "\"%s/%u via %s\" ",
+			                        nm_ip_route_get_dest (route),
+			                        nm_ip_route_get_prefix (route),
+			                        next_hop);
 		}
 	}
 	if (routes->len > 0)
@@ -2538,19 +2496,16 @@ write_ip4_setting (NMConnection *connection, const char *conn_name, GError **err
 }
 
 static gboolean
-write_route6_file (NMSettingIP6Config *s_ip6, const char *conn_name, GError **error)
+write_route6_file (NMSettingIPConfig *s_ip6, const char *conn_name, GError **error)
 {
-	char dest[INET6_ADDRSTRLEN + 1];
-	char next_hop[INET6_ADDRSTRLEN + 1];
-	NMIP6Route *route;
-	const struct in6_addr *ip;
-	guint32 prefix;
+	NMIPRoute *route;
+	const char *next_hop;
 	guint32 i, num;
 	GString *routes_string;
 	const char *old_routes;
 
 	g_return_val_if_fail (s_ip6 != 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) {
 		return TRUE;
 	}
@@ -2560,22 +2515,16 @@ write_route6_file (NMSettingIP6Config *s_ip6, const char *conn_name, GError **er
 	if (old_routes)
 		g_string_append (routes_string, "\" ");
 	for (i = 0; i < num; i++) {
-		route = nm_setting_ip6_config_get_route (s_ip6, i);
+		route = nm_setting_ip_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);
-
-		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));
+		next_hop = nm_ip_route_get_next_hop (route);
+		if (!next_hop)
+			next_hop = "::";
 
 		g_string_append_printf (routes_string, "\"%s/%u via %s\" ",
-					dest, prefix, next_hop);
+		                        nm_ip_route_get_dest (route),
+		                        nm_ip_route_get_prefix (route),
+		                        next_hop);
 	}
 	if (num > 0)
 		ifnet_set_data (conn_name, "routes", routes_string->str);
@@ -2587,24 +2536,21 @@ write_route6_file (NMSettingIP6Config *s_ip6, const char *conn_name, GError **er
 static gboolean
 write_ip6_setting (NMConnection *connection, const char *conn_name, GError **error)
 {
-	NMSettingIP6Config *s_ip6;
+	NMSettingIPConfig *s_ip6;
 	const char *value;
-	char *prefix;
 	guint32 i, num;
 	GString *searches;
-	char buf[INET6_ADDRSTRLEN + 1];
-	NMIP6Address *addr;
-	const struct in6_addr *ip;
+	NMIPAddress *addr;
 
 	s_ip6 = nm_connection_get_setting_ip6_config (connection);
 	if (!s_ip6) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing '%s' setting",
 			     NM_SETTING_IP6_CONFIG_SETTING_NAME);
 		return FALSE;
 	}
 
-	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)) {
 		ifnet_set_data (conn_name, "enable_ipv6", "false");
@@ -2638,22 +2584,16 @@ write_ip6_setting (NMConnection *connection, const char *conn_name, GError **err
 
 		if (!config)
 			config = "";
-		num = nm_setting_ip6_config_get_num_addresses (s_ip6);
+		num = nm_setting_ip_config_get_num_addresses (s_ip6);
 
 		/* IPv6 addresses */
 		ip_str = g_string_new (NULL);
 		for (i = 0; i < num; i++) {
-			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));
-			g_string_append_printf (ip_str, "\"%s/", buf);
-			g_string_append_printf (ip_str, "%s\" ", prefix);
-			g_free (prefix);
+			addr = nm_setting_ip_config_get_address (s_ip6, i);
+
+			g_string_append_printf (ip_str, "\"%s/%u\"",
+			                        nm_ip_address_get_address (addr),
+			                        nm_ip_address_get_prefix (addr));
 		}
 		tmp = g_strdup_printf ("%s\" %s", config, ip_str->str);
 		ifnet_set_data (conn_name, "config", tmp);
@@ -2662,22 +2602,20 @@ write_ip6_setting (NMConnection *connection, const char *conn_name, GError **err
 	}
 
 	/* DNS Servers */
-	num = nm_setting_ip6_config_get_num_dns (s_ip6);
+	num = nm_setting_ip_config_get_num_dns (s_ip6);
 	if (num > 0) {
 		const char *dns_servers = ifnet_get_data (conn_name, "dns_servers");
 		gchar *tmp;
 		GString *dns_string = g_string_new (NULL);
+		const char *dns;
 
 		if (!dns_servers)
 			dns_servers = "";
 		for (i = 0; i < num; i++) {
-			ip = nm_setting_ip6_config_get_dns (s_ip6, i);
+			dns = nm_setting_ip_config_get_dns (s_ip6, i);
 
-			memset (buf, 0, sizeof (buf));
-			inet_ntop (AF_INET6, (const void *) ip, buf,
-				   sizeof (buf));
-			if (!strstr (dns_servers, buf))
-				g_string_append_printf (dns_string, "%s ", buf);
+			if (!strstr (dns_servers, dns))
+				g_string_append_printf (dns_string, "%s ", dns);
 		}
 		tmp = g_strdup_printf ("%s %s", dns_servers, dns_string->str);
 		ifnet_set_data (conn_name, "dns_servers", tmp);
@@ -2686,7 +2624,7 @@ write_ip6_setting (NMConnection *connection, const char *conn_name, GError **err
 
 	} else
 		/* DNS Searches */
-		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) {
 		const char *ip4_domains;
 
@@ -2698,7 +2636,7 @@ write_ip6_setting (NMConnection *connection, const char *conn_name, GError **err
 			const gchar *search = NULL;
 
 			search =
-			    nm_setting_ip6_config_get_dns_search (s_ip6, i);
+			    nm_setting_ip_config_get_dns_search (s_ip6, i);
 			if (search && !strstr (searches->str, search)) {
 				if (searches->len > 0)
 					g_string_append_c (searches, ' ');
@@ -2716,7 +2654,7 @@ write_ip6_setting (NMConnection *connection, const char *conn_name, GError **err
 }
 
 static gboolean
-write_pppoe_setting (const char *conn_name, NMSettingPPPOE * s_pppoe)
+write_pppoe_setting (const char *conn_name, NMSettingPppoe * s_pppoe)
 {
 	const gchar *value;
 
@@ -2744,7 +2682,7 @@ ifnet_update_parsers_by_connection (NMConnection *connection,
                                     GError **error)
 {
 	NMSettingConnection *s_con;
-	NMSettingIP6Config *s_ip6;
+	NMSettingIPConfig *s_ip6;
 	gboolean success = FALSE;
 	const char *type;
 	gboolean no_8021x = FALSE;
@@ -2759,7 +2697,7 @@ ifnet_update_parsers_by_connection (NMConnection *connection,
 
 	type = nm_setting_connection_get_connection_type (s_con);
 	if (!type) {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			     "Missing connection type!");
 		goto out;
 	}
@@ -2775,7 +2713,7 @@ ifnet_update_parsers_by_connection (NMConnection *connection,
 		if (!write_wireless_setting (connection, conn_name, &no_8021x, &new_name, error))
 			goto out;
 	} else if (!strcmp (type, NM_SETTING_PPPOE_SETTING_NAME)) {
-		NMSettingPPPOE *s_pppoe;
+		NMSettingPppoe *s_pppoe;
 
 		/* Writing pppoe setting */
 		s_pppoe = nm_connection_get_setting_pppoe (connection);
@@ -2785,7 +2723,7 @@ ifnet_update_parsers_by_connection (NMConnection *connection,
 		wired = TRUE;
 		no_8021x = TRUE;
 	} else {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
 			     "Can't write connection type '%s'", type);
 		goto out;
 	}
@@ -2862,7 +2800,8 @@ check_unsupported_secrets (NMSetting  *setting,
 	if (flags & NM_SETTING_PARAM_SECRET) {
 		NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
 
-		nm_setting_get_secret_flags (setting, key, &secret_flags, NULL);
+		if (!nm_setting_get_secret_flags (setting, key, &secret_flags, NULL))
+			g_return_if_reached ();
 		if (secret_flags != NM_SETTING_SECRET_FLAG_NONE)
 			*unsupported_secret = TRUE;
 	}
@@ -2880,39 +2819,39 @@ ifnet_can_write_connection (NMConnection *connection, GError **error)
 	/* If the connection is not available for all users, ignore
 	 * it as this plugin only deals with System Connections */
 	if (nm_setting_connection_get_num_permissions (s_con)) {
-		g_set_error_literal (error, IFNET_PLUGIN_ERROR, 0,
+		g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
 		                     "The ifnet plugin does not support non-system-wide connections.");
 		return FALSE;
 	}
 
-	/* If the connection has flagged secrets, ignore
-	 * it as this plugin does not deal with user agent service */
-	nm_connection_for_each_setting_value (connection,
-	                                      check_unsupported_secrets,
-	                                      &has_unsupported_secrets);
-	if (has_unsupported_secrets) {
-		g_set_error_literal (error, IFNET_PLUGIN_ERROR, 0,
-		                     "The ifnet plugin only supports persistent system secrets.");
-		return FALSE;
-	}
-
 	/* Only support wired, wifi, and PPPoE */
 	if (   !nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)
 	    && !nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME)
 	    && !nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) {
-		g_set_error (error, IFNET_PLUGIN_ERROR, 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
 		             "The ifnet plugin cannot write the connection '%s' (type '%s')",
 		             nm_connection_get_id (connection),
 		             nm_setting_connection_get_connection_type (s_con));
 		return FALSE;
 	}
 
+	/* If the connection has flagged secrets, ignore
+	 * it as this plugin does not deal with user agent service */
+	nm_connection_for_each_setting_value (connection,
+	                                      check_unsupported_secrets,
+	                                      &has_unsupported_secrets);
+	if (has_unsupported_secrets) {
+		g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
+		                     "The ifnet plugin only supports persistent system secrets.");
+		return FALSE;
+	}
+
 	return TRUE;
 }
 
 /* get the available wired name(eth*). */
 static gchar *
-get_wired_name ()
+get_wired_name (void)
 {
 	int i = 0;
 
@@ -2929,7 +2868,7 @@ get_wired_name ()
 
 /* get the available pppoe name(ppp*). */
 static gchar *
-get_ppp_name ()
+get_ppp_name (void)
 {
 	int i = 0;
 
@@ -2949,7 +2888,9 @@ static gchar *
 get_wireless_name (NMConnection * connection)
 {
 	NMSettingWireless *s_wireless;
-	const GByteArray *ssid;
+	GBytes *ssid;
+	const guint8 *ssid_data;
+	gsize ssid_len;
 	gboolean hex_ssid = FALSE;
 	gchar *result = NULL;
 	char buf[33];
@@ -2960,12 +2901,13 @@ get_wireless_name (NMConnection * connection)
 		return NULL;
 
 	ssid = nm_setting_wireless_get_ssid (s_wireless);
-	if (!ssid->len || ssid->len > 32) {
+	ssid_data = g_bytes_get_data (ssid, &ssid_len);
+	if (!ssid_len || ssid_len > 32) {
 		return NULL;
 	}
 
-	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;
 		}
@@ -2974,15 +2916,15 @@ get_wireless_name (NMConnection * connection)
 	if (hex_ssid) {
 		GString *str;
 
-		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]);
 		result = g_strdup (str->str);
 		g_string_free (str, TRUE);
 	} else {
 		memset (buf, 0, sizeof (buf));
-		memcpy (buf, ssid->data, ssid->len);
+		memcpy (buf, ssid_data, ssid_len);
 		result = g_strdup_printf ("%s", buf);
 		g_strstrip (result);
 	}
@@ -3031,7 +2973,7 @@ ifnet_add_new_connection (NMConnection *connection,
 			goto out;
 		new_type = "ppp";
 	} else {
-		g_set_error (error, ifnet_plugin_error_quark (), 0,
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
 			     "Can't write connection type '%s'", type);
 		goto out;
 	}
diff --git a/src/settings/plugins/ifnet/errors.c b/src/settings/plugins/ifnet/errors.c
deleted file mode 100644
index 295db18b..00000000
--- a/src/settings/plugins/ifnet/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 2013 Red Hat, Inc.
- */
-
-#include <glib.h>
-#include "errors.h"
-
-GQuark
-ifnet_plugin_error_quark (void)
-{
-	static GQuark error_quark = 0;
-
-	if (G_UNLIKELY (error_quark == 0))
-		error_quark = g_quark_from_static_string ("ifnet-plugin-error-quark");
-
-	return error_quark;
-}
-
-
diff --git a/src/settings/plugins/ifnet/errors.h b/src/settings/plugins/ifnet/errors.h
deleted file mode 100644
index 52517d00..00000000
--- a/src/settings/plugins/ifnet/errors.h
+++ /dev/null
@@ -1,30 +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 2013 Red Hat, Inc.
- */
-
-#ifndef __ERRORS_H__
-#define __ERRORS_H__
-
-#include <glib.h>
-
-#define IFNET_PLUGIN_ERROR (ifnet_plugin_error_quark ())
-GQuark ifnet_plugin_error_quark (void);
-
-#endif  /* __ERRORS_H__ */
-
diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c
index 95add14f..1cf46fbf 100644
--- a/src/settings/plugins/ifnet/net_parser.c
+++ b/src/settings/plugins/ifnet/net_parser.c
@@ -19,6 +19,8 @@
  * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
  */
 
+#include "config.h"
+
 #include <string.h>
 #include <stdio.h>
 #include <sys/ioctl.h>
diff --git a/src/settings/plugins/ifnet/net_utils.c b/src/settings/plugins/ifnet/net_utils.c
index 86ab8537..adb23c43 100644
--- a/src/settings/plugins/ifnet/net_utils.c
+++ b/src/settings/plugins/ifnet/net_utils.c
@@ -19,11 +19,14 @@
  * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include <nm-utils.h>
+#include <NetworkManagerUtils.h>
 #include <nm-system-config-interface.h>
 #include <nm-logging.h>
 #include <nm-config.h>
@@ -365,23 +368,21 @@ create_ip4_block (gchar * ip)
 
 		ip_mask = g_strsplit (ip, "/", 0);
 		length = g_strv_length (ip_mask);
-		if (!inet_pton (AF_INET, ip_mask[0], &tmp_ip4_addr))
+		if (!nm_utils_ipaddr_valid (AF_INET, ip_mask[0]))
 			goto error;
-		iblock->ip = tmp_ip4_addr;
+		iblock->ip = g_strdup (ip_mask[0]);
 		prefix = ip_mask[1];
 		i = 0;
 		while (i < length && g_ascii_isdigit (prefix[i]))
 			i++;
 		prefix[i] = '\0';
-		iblock->netmask = nm_utils_ip4_prefix_to_netmask ((guint32)
-								  atoi (ip_mask
-									[1]));
+		iblock->prefix = (guint32) atoi (ip_mask[1]);
 	} else if (strstr (ip, "netmask")) {
 		ip_mask = g_strsplit (ip, " ", 0);
 		length = g_strv_length (ip_mask);
-		if (!inet_pton (AF_INET, ip_mask[0], &tmp_ip4_addr))
+		if (!nm_utils_ipaddr_valid (AF_INET, ip_mask[0]))
 			goto error;
-		iblock->ip = tmp_ip4_addr;
+		iblock->ip = g_strdup (ip_mask[0]);
 		i = 0;
 		while (i < length && !strstr (ip_mask[++i], "netmask")) ;
 		while (i < length && ip_mask[++i][0] == '\0') ;
@@ -389,39 +390,42 @@ create_ip4_block (gchar * ip)
 			goto error;
 		if (!inet_pton (AF_INET, ip_mask[i], &tmp_ip4_addr))
 			goto error;
-		iblock->netmask = tmp_ip4_addr;
+		iblock->prefix = nm_utils_ip4_netmask_to_prefix (tmp_ip4_addr);
 	} else {
 		g_slice_free (ip_block, iblock);
 		if (!is_ip6_address (ip) && !strstr (ip, "dhcp"))
 			nm_log_warn (LOGD_SETTINGS, "Can't handle ipv4 address: %s, missing netmask or prefix", ip);
 		return NULL;
 	}
+	if (iblock->prefix == 0 || iblock->prefix > 32) {
+		nm_log_warn (LOGD_SETTINGS, "Can't handle ipv4 address: %s, invalid prefix", ip);
+		goto error;
+	}
 	g_strfreev (ip_mask);
 	return iblock;
 error:
 	if (!is_ip6_address (ip))
 		nm_log_warn (LOGD_SETTINGS, "Can't handle IPv4 address: %s", ip);
 	g_strfreev (ip_mask);
+	g_free (iblock->ip);
 	g_slice_free (ip_block, iblock);
 	return NULL;
 }
 
-static ip6_block *
-create_ip6_block (gchar * ip)
+static ip_block *
+create_ip_block (gchar * ip)
 {
-	ip6_block *iblock = g_slice_new0 (ip6_block);
+	ip_block *iblock = g_slice_new0 (ip_block);
 	gchar *dup_ip = g_strdup (ip);
-	struct in6_addr *tmp_ip6_addr = g_slice_new0 (struct in6_addr);
 	gchar *prefix = NULL;
 
 	if ((prefix = strstr (dup_ip, "/")) != NULL) {
 		*prefix = '\0';
 		prefix++;
 	}
-	if (!inet_pton (AF_INET6, dup_ip, tmp_ip6_addr)) {
+	if (!nm_utils_ipaddr_valid (AF_INET6, dup_ip))
 		goto error;
-	}
-	iblock->ip = tmp_ip6_addr;
+	iblock->ip = dup_ip;
 	if (prefix) {
 		errno = 0;
 		iblock->prefix = strtol (prefix, NULL, 10);
@@ -430,30 +434,26 @@ create_ip6_block (gchar * ip)
 		}
 	} else
 		iblock->prefix = 64;
-	g_free (dup_ip);
 	return iblock;
 error:
 	if (!is_ip4_address (ip))
 		nm_log_warn (LOGD_SETTINGS, "Can't handle IPv6 address: %s", ip);
-	g_slice_free (ip6_block, iblock);
-	g_slice_free (struct in6_addr, tmp_ip6_addr);
-
+	g_slice_free (ip_block, iblock);
 	g_free (dup_ip);
 	return NULL;
 }
 
-static guint32
+static char *
 get_ip4_gateway (gchar * gateway)
 {
 	gchar *tmp, *split;
-	guint32 tmp_ip4_addr;
 
 	if (!gateway)
-		return 0;
+		return NULL;
 	tmp = find_gateway_str (gateway);
 	if (!tmp) {
 		nm_log_warn (LOGD_SETTINGS, "Couldn't obtain gateway in \"%s\"", gateway);
-		return 0;
+		return NULL;
 	}
 	tmp = g_strdup (tmp);
 	strip_string (tmp, ' ');
@@ -463,43 +463,39 @@ get_ip4_gateway (gchar * gateway)
 	if ((split = strstr (tmp, "\"")) != NULL)
 		*split = '\0';
 
-	if (!inet_pton (AF_INET, tmp, &tmp_ip4_addr))
+	if (!nm_utils_ipaddr_valid (AF_INET, tmp))
 		goto error;
-	g_free (tmp);
-	return tmp_ip4_addr;
+	return tmp;
 error:
 	if (!is_ip6_address (tmp))
 		nm_log_warn (LOGD_SETTINGS, "Can't handle IPv4 gateway: %s", tmp);
 	g_free (tmp);
-	return 0;
+	return NULL;
 }
 
-static struct in6_addr *
+static char *
 get_ip6_next_hop (gchar * next_hop)
 {
 	gchar *tmp;
-	struct in6_addr *tmp_ip6_addr = g_slice_new0 (struct in6_addr);
 
 	if (!next_hop)
-		return 0;
+		return NULL;
 	tmp = find_gateway_str (next_hop);
 	if (!tmp) {
 		nm_log_warn (LOGD_SETTINGS, "Couldn't obtain next_hop in \"%s\"", next_hop);
-		return 0;
+		return NULL;
 	}
 	tmp = g_strdup (tmp);
 	strip_string (tmp, ' ');
 	strip_string (tmp, '"');
 	g_strstrip (tmp);
-	if (!inet_pton (AF_INET6, tmp, tmp_ip6_addr))
+	if (!nm_utils_ipaddr_valid (AF_INET6, tmp))
 		goto error;
-	g_free (tmp);
-	return tmp_ip6_addr;
+	return tmp;
 error:
 	if (!is_ip4_address (tmp))
 		nm_log_warn (LOGD_SETTINGS, "Can't handle IPv6 next_hop: %s", tmp);
 	g_free (tmp);
-	g_slice_free (struct in6_addr, tmp_ip6_addr);
 
 	return NULL;
 }
@@ -511,7 +507,7 @@ convert_ip4_config_block (const char *conn_name)
 	guint length;
 	guint i;
 	gchar *ip;
-	guint32 def_gateway = 0;
+	char *def_gateway = NULL;
 	const char *routes;
 	ip_block *start = NULL, *current = NULL, *iblock = NULL;
 
@@ -530,8 +526,8 @@ convert_ip4_config_block (const char *conn_name)
 		iblock = create_ip4_block (ip);
 		if (iblock == NULL)
 			continue;
-		if (!iblock->gateway && def_gateway != 0)
-			iblock->gateway = def_gateway;
+		if (!iblock->next_hop && def_gateway != NULL)
+			iblock->next_hop = g_strdup (def_gateway);
 		if (start == NULL)
 			start = current = iblock;
 		else {
@@ -540,17 +536,18 @@ convert_ip4_config_block (const char *conn_name)
 		}
 	}
 	g_strfreev (ipset);
+	g_free (def_gateway);
 	return start;
 }
 
-ip6_block *
+ip_block *
 convert_ip6_config_block (const char *conn_name)
 {
 	gchar **ipset;
 	guint length;
 	guint i;
 	gchar *ip;
-	ip6_block *start = NULL, *current = NULL, *iblock = NULL;
+	ip_block *start = NULL, *current = NULL, *iblock = NULL;
 
 	g_return_val_if_fail (conn_name != NULL, NULL);
 	ipset = split_addresses (ifnet_get_data (conn_name, "config"));
@@ -558,7 +555,7 @@ convert_ip6_config_block (const char *conn_name)
 	for (i = 0; i < length; i++) {
 		ip = ipset[i];
 		ip = strip_string (ip, '"');
-		iblock = create_ip6_block (ip);
+		iblock = create_ip_block (ip);
 		if (iblock == NULL)
 			continue;
 		if (start == NULL)
@@ -594,7 +591,7 @@ convert_ip4_routes_block (const char *conn_name)
 		iblock = create_ip4_block (ip);
 		if (iblock == NULL)
 			continue;
-		iblock->gateway = get_ip4_gateway (ip);
+		iblock->next_hop = get_ip4_gateway (ip);
 		if (start == NULL)
 			start = current = iblock;
 		else {
@@ -606,15 +603,14 @@ convert_ip4_routes_block (const char *conn_name)
 	return start;
 }
 
-ip6_block *
+ip_block *
 convert_ip6_routes_block (const char *conn_name)
 {
 	gchar **ipset;
 	guint length;
 	guint i;
 	gchar *ip, *tmp_addr;
-	ip6_block *start = NULL, *current = NULL, *iblock = NULL;
-	struct in6_addr *tmp_ip6_addr;
+	ip_block *start = NULL, *current = NULL, *iblock = NULL;
 
 	g_return_val_if_fail (conn_name != NULL, NULL);
 	ipset = split_routes (ifnet_get_data (conn_name, "routes"));
@@ -628,25 +624,17 @@ convert_ip6_routes_block (const char *conn_name)
 			if (!is_ip6_address (tmp_addr))
 				continue;
 			else {
-				tmp_ip6_addr = g_slice_new0 (struct in6_addr);
-
-				if (inet_pton (AF_INET6, "::", tmp_ip6_addr)) {
-					iblock = g_slice_new0 (ip6_block);
-					iblock->ip = tmp_ip6_addr;
-					iblock->prefix = 128;
-				} else {
-					g_slice_free (struct in6_addr,
-						      tmp_ip6_addr);
-					continue;
-				}
+				iblock = g_slice_new0 (ip_block);
+				iblock->ip = g_strdup ("::");
+				iblock->prefix = 128;
 			}
 		} else
-			iblock = create_ip6_block (ip);
+			iblock = create_ip_block (ip);
 		if (iblock == NULL)
 			continue;
 		iblock->next_hop = get_ip6_next_hop (ip);
 		if (iblock->next_hop == NULL) {
-			destroy_ip6_block (iblock);
+			destroy_ip_block (iblock);
 			continue;
 		}
 		if (start == NULL)
@@ -663,26 +651,18 @@ convert_ip6_routes_block (const char *conn_name)
 void
 destroy_ip_block (ip_block * iblock)
 {
+	g_free (iblock->ip);
+	g_free (iblock->next_hop);
 	g_slice_free (ip_block, iblock);
 }
 
 void
-destroy_ip6_block (ip6_block * iblock)
-{
-	g_slice_free (struct in6_addr, iblock->ip);
-	g_slice_free (struct in6_addr, iblock->next_hop);
-
-	g_slice_free (ip6_block, iblock);
-}
-
-void
-set_ip4_dns_servers (NMSettingIP4Config *s_ip4, const char *conn_name)
+set_ip4_dns_servers (NMSettingIPConfig *s_ip4, const char *conn_name)
 {
 	const char *dns_servers;
 	gchar **server_list, *stripped;
 	guint length, i;
 	guint32 tmp_ip4_addr;
-	guint32 new_dns;
 
 	dns_servers = ifnet_get_data (conn_name, "dns_servers");
 	if (!dns_servers)
@@ -694,7 +674,7 @@ set_ip4_dns_servers (NMSettingIP4Config *s_ip4, const char *conn_name)
 
 	length = g_strv_length (server_list);
 	if (length)
-		g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS,
+		g_object_set (s_ip4, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS,
 			      TRUE, NULL);
 	for (i = 0; i < length; i++) {
 		g_strstrip (server_list[i]);
@@ -705,15 +685,14 @@ set_ip4_dns_servers (NMSettingIP4Config *s_ip4, const char *conn_name)
 				nm_log_warn (LOGD_SETTINGS, "ignored dns: %s\n", server_list[i]);
 			continue;
 		}
-		new_dns = tmp_ip4_addr;
-		if (new_dns && !nm_setting_ip4_config_add_dns (s_ip4, new_dns))
+		if (!nm_setting_ip_config_add_dns (s_ip4, server_list[i]))
 			nm_log_warn (LOGD_SETTINGS, "warning: duplicate DNS server %s", server_list[i]);
 	}
 	g_strfreev (server_list);
 }
 
 void
-set_ip6_dns_servers (NMSettingIP6Config *s_ip6, const char *conn_name)
+set_ip6_dns_servers (NMSettingIPConfig *s_ip6, const char *conn_name)
 {
 	const char *dns_servers;
 	gchar **server_list, *stripped;
@@ -731,7 +710,7 @@ set_ip6_dns_servers (NMSettingIP6Config *s_ip6, const char *conn_name)
 
 	length = g_strv_length (server_list);
 	if (length)
-		g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS,
+		g_object_set (s_ip6, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS,
 			      TRUE, NULL);
 	for (i = 0; i < length; i++) {
 		g_strstrip (server_list[i]);
@@ -742,8 +721,7 @@ set_ip6_dns_servers (NMSettingIP6Config *s_ip6, const char *conn_name)
 				nm_log_warn (LOGD_SETTINGS, "ignored dns: %s\n", server_list[i]);
 			continue;
 		}
-		if (!IN6_IS_ADDR_UNSPECIFIED (&tmp_ip6_addr)
-		    && !nm_setting_ip6_config_add_dns (s_ip6, &tmp_ip6_addr))
+		if (!nm_setting_ip_config_add_dns (s_ip6, server_list[i]))
 			nm_log_warn (LOGD_SETTINGS, "warning: duplicate DNS server %s", server_list[i]);
 	}
 	g_strfreev (server_list);
@@ -763,30 +741,49 @@ is_managed (const char *conn_name)
 	return TRUE;
 }
 
+static char *
+_has_prefix_impl (char *str, const char *prefix, gsize prefix_len)
+{
+	if (!g_str_has_prefix (str, prefix))
+		return NULL;
+	str += prefix_len;
+	if (!g_ascii_isspace (str[0]))
+		return NULL;
+	do {
+		str++;
+	} while (g_ascii_isspace (str[0]));
+	return str;
+}
+#define _has_prefix(STR, PREFIX) _has_prefix_impl (STR, PREFIX, STRLEN (PREFIX))
+
 void
 get_dhcp_hostname_and_client_id (char **hostname, char **client_id)
 {
 	const char *dhcp_client;
 	const gchar *dhcpcd_conf = SYSCONFDIR "/dhcpcd.conf";
 	const gchar *dhclient_conf = SYSCONFDIR "/dhcp/dhclient.conf";
-	gchar *line = NULL, *tmp = NULL, *contents = NULL;
+	gchar *line = NULL, *tmp = NULL, *contents = NULL, *tmp1;
 	gchar **all_lines;
 	guint line_num, i;
+	gboolean use_dhclient = FALSE;
 
 	*hostname = NULL;
 	*client_id = NULL;
 	dhcp_client = nm_config_get_dhcp_client (nm_config_get ());
 	if (dhcp_client) {
-		if (!strcmp (dhcp_client, "dhclient"))
+		if (!strcmp (dhcp_client, "dhclient")) {
 			g_file_get_contents (dhclient_conf, &contents, NULL,
 					     NULL);
-		else if (!strcmp (dhcp_client, "dhcpcd"))
+			use_dhclient = TRUE;
+		} else if (!strcmp (dhcp_client, "dhcpcd"))
 			g_file_get_contents (dhcpcd_conf, &contents, NULL,
 					     NULL);
 	} else {
-		if (g_file_test (dhclient_conf, G_FILE_TEST_IS_REGULAR))
+		if (g_file_test (dhclient_conf, G_FILE_TEST_IS_REGULAR)) {
 			g_file_get_contents (dhclient_conf, &contents, NULL,
 					     NULL);
+			use_dhclient = TRUE;
+		}
 		else if (g_file_test (dhcpcd_conf, G_FILE_TEST_IS_REGULAR))
 			g_file_get_contents (dhcpcd_conf, &contents, NULL,
 					     NULL);
@@ -797,42 +794,44 @@ get_dhcp_hostname_and_client_id (char **hostname, char **client_id)
 	line_num = g_strv_length (all_lines);
 	for (i = 0; i < line_num; i++) {
 		line = all_lines[i];
-		// dhcpcd.conf
 		g_strstrip (line);
-		if (g_str_has_prefix (line, "hostname")) {
-			tmp = line + strlen ("hostname");
-			g_strstrip (tmp);
-			if (tmp[0] != '\0')
-				*hostname = g_strdup (tmp);
-			else
-				nm_log_info (LOGD_SETTINGS, "dhcpcd hostname not defined, ignoring");
-		} else if (g_str_has_prefix (line, "clientid")) {
-			tmp = line + strlen ("clientid");
-			g_strstrip (tmp);
-			if (tmp[0] != '\0')
-				*client_id = g_strdup (tmp);
-			else
-				nm_log_info (LOGD_SETTINGS, "dhcpcd clientid not defined, ignoring");
-		}
-		// dhclient.conf
-		else if ((tmp = strstr (line, "send host-name")) != NULL) {
-			tmp += strlen ("send host-name");
-			g_strstrip (tmp);
-			strip_string (tmp, ';');
-			strip_string (tmp, '"');
-			if (tmp[0] != '\0')
-				*hostname = g_strdup (tmp);
-			else
-				nm_log_info (LOGD_SETTINGS, "dhclient hostname not defined, ignoring");
-		} else if ((tmp = strstr (line, "send dhcp-client-identifier"))
-			   != NULL) {
-			tmp += strlen ("send dhcp-client-identifier");
-			g_strstrip (tmp);
-			strip_string (tmp, ';');
-			if (tmp[0] != '\0')
-				*client_id = g_strdup (tmp);
-			else
-				nm_log_info (LOGD_SETTINGS, "dhclient clientid not defined, ignoring");
+		if (line[0] == '#' || line[0] == '\0')
+			continue;
+		if (!use_dhclient) {
+			// dhcpcd.conf
+			if ((tmp = _has_prefix (line, "hostname"))) {
+				if (tmp[0] != '\0') {
+					g_free (*hostname);
+					*hostname = g_strdup (tmp);
+				} else
+					nm_log_info (LOGD_SETTINGS, "dhcpcd hostname not defined, ignoring");
+			} else if ((tmp = _has_prefix (line, "clientid"))) {
+				if (tmp[0] != '\0') {
+					g_free (*client_id);
+					*client_id = g_strdup (tmp);
+				} else
+					nm_log_info (LOGD_SETTINGS, "dhcpcd clientid not defined, ignoring");
+			}
+		} else {
+			// dhclient.conf
+			if ((tmp1 = _has_prefix (line, "send"))) {
+				if ((tmp = _has_prefix (tmp1, "host-name"))) {
+					strip_string (tmp, ';');
+					strip_string (tmp, '"');
+					if (tmp[0] != '\0') {
+						g_free (*hostname);
+						*hostname = g_strdup (tmp);
+					} else
+						nm_log_info (LOGD_SETTINGS, "dhclient hostname not defined, ignoring");
+				} else if ((tmp = _has_prefix (tmp1, "dhcp-client-identifier"))) {
+					strip_string (tmp, ';');
+					if (tmp[0] != '\0') {
+						g_free (*client_id);
+						*client_id = g_strdup (tmp);
+					} else
+						nm_log_info (LOGD_SETTINGS, "dhclient clientid not defined, ignoring");
+				}
+			}
 		}
 	}
 	g_strfreev (all_lines);
diff --git a/src/settings/plugins/ifnet/net_utils.h b/src/settings/plugins/ifnet/net_utils.h
index cee71d57..d58e7ec6 100644
--- a/src/settings/plugins/ifnet/net_utils.h
+++ b/src/settings/plugins/ifnet/net_utils.h
@@ -31,19 +31,12 @@
 #define has_default_ip6_route(conn_name) has_default_route((conn_name), &is_ip6_address)
 
 typedef struct _ip_block {
-	guint32 ip;
-	guint32 netmask;
-	guint32 gateway;
+	char *ip;
+	guint32 prefix;
+	char *next_hop;
 	struct _ip_block *next;
 } ip_block;
 
-typedef struct _ip6_block {
-	struct in6_addr *ip;
-	long int prefix;
-	struct in6_addr *next_hop;
-	struct _ip6_block *next;
-} ip6_block;
-
 gchar *read_hostname (const char *path);
 gboolean write_hostname (const char *path, const char *hostname);
 gboolean is_static_ip4 (const char *conn_name);
@@ -55,14 +48,13 @@ gboolean has_default_route (const char *conn_name, gboolean (*check_fn) (const c
 gboolean reload_parsers (void);
 
 ip_block *convert_ip4_config_block (const char *conn_name);
-ip6_block *convert_ip6_config_block (const char *conn_name);
+ip_block *convert_ip6_config_block (const char *conn_name);
 ip_block *convert_ip4_routes_block (const char *conn_name);
-ip6_block *convert_ip6_routes_block (const char *conn_name);
+ip_block *convert_ip6_routes_block (const char *conn_name);
 void destroy_ip_block (ip_block * iblock);
-void destroy_ip6_block (ip6_block * iblock);
 
-void set_ip4_dns_servers (NMSettingIP4Config * s_ip4, const char *conn_name);
-void set_ip6_dns_servers (NMSettingIP6Config * s_ip6, const char *conn_name);
+void set_ip4_dns_servers (NMSettingIPConfig * s_ip4, const char *conn_name);
+void set_ip6_dns_servers (NMSettingIPConfig * s_ip6, const char *conn_name);
 
 gchar *strip_string (gchar *str, gchar t);
 gboolean is_managed (const char *conn_name);
diff --git a/src/settings/plugins/ifnet/nm-ifnet-connection.c b/src/settings/plugins/ifnet/nm-ifnet-connection.c
index 478d6e32..c84ad5ed 100644
--- a/src/settings/plugins/ifnet/nm-ifnet-connection.c
+++ b/src/settings/plugins/ifnet/nm-ifnet-connection.c
@@ -19,15 +19,16 @@
  * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
  */
 
+#include "config.h"
+
 #include <string.h>
 #include <glib/gstdio.h>
-#include <NetworkManager.h>
+#include <nm-dbus-interface.h>
 #include <nm-utils.h>
 #include <nm-setting-wireless-security.h>
 #include <nm-settings-connection.h>
 #include <nm-system-config-interface.h>
 #include <nm-logging.h>
-#include <nm-settings-error.h>
 #include "nm-ifnet-connection.h"
 #include "connection_parser.h"
 #include "net_parser.h"
diff --git a/src/settings/plugins/ifnet/nm-ifnet-connection.h b/src/settings/plugins/ifnet/nm-ifnet-connection.h
index 1cb67c34..baa4c07e 100644
--- a/src/settings/plugins/ifnet/nm-ifnet-connection.h
+++ b/src/settings/plugins/ifnet/nm-ifnet-connection.h
@@ -19,8 +19,8 @@
  * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
  */
 
-#ifndef NM_IFNET_CONNECTION_H
-#define NM_IFNET_CONNECTION_H
+#ifndef __NETWORKMANAGER_IFNET_CONNECTION_H__
+#define __NETWORKMANAGER_IFNET_CONNECTION_H__
 
 #include <nm-settings-connection.h>
 #include "net_parser.h"
diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c
index ab07b8d6..3eb1ed52 100644
--- a/src/settings/plugins/ifnet/plugin.c
+++ b/src/settings/plugins/ifnet/plugin.c
@@ -20,6 +20,8 @@
  * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
  */
 
+#include "config.h"
+
 #include <string.h>
 
 #include <gmodule.h>
@@ -29,7 +31,7 @@
 #include <nm-utils.h>
 #include <nm-setting-connection.h>
 
-#include "NetworkManager.h"
+#include "nm-dbus-interface.h"
 #include "nm-system-config-interface.h"
 #include "nm-logging.h"
 #include "nm-ifnet-connection.h"
diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am
index f66a6a3d..66409a54 100644
--- a/src/settings/plugins/ifnet/tests/Makefile.am
+++ b/src/settings/plugins/ifnet/tests/Makefile.am
@@ -4,22 +4,17 @@ if ENABLE_TESTS
 
 AM_CPPFLAGS= \
 	-I$(srcdir)/../ \
-	-I$(top_srcdir)/libnm-glib \
-	-I$(top_srcdir)/libnm-util \
-	-I$(top_builddir)/libnm-util \
 	-I$(top_srcdir)/include \
-	-I$(top_builddir)/include \
+	-I$(top_srcdir)/libnm-core \
+	-I$(top_builddir)/libnm-core \
 	-I$(top_srcdir)/src \
-	-I$(top_srcdir)/src/config \
-	-I$(top_srcdir)/src/logging \
 	-I$(top_srcdir)/src/settings \
 	-I$(top_srcdir)/src/platform \
 	-DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \
+	-DNETWORKMANAGER_COMPILATION \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
 	$(CHECK_CFLAGS) \
 	$(GLIB_CFLAGS) \
-	$(DBUS_CFLAGS) \
-	$(POLKIT_CFLAGS) \
 	$(CODE_COVERAGE_CFLAGS) \
 	-DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \
 	-DSYSCONFDIR=\"nonexistent\"
@@ -30,8 +25,7 @@ check_ifnet_SOURCES = \
 	../connection_parser.c \
 	../net_parser.c \
 	../net_utils.c \
-	../wpa_parser.c \
-	../errors.c
+	../wpa_parser.c
 
 check_ifnet_LDFLAGS = \
 	$(CODE_COVERAGE_LDFLAGS)
@@ -41,6 +35,8 @@ check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la
 check-local: check_ifnet
 	$(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir)
 
+endif
+
 EXTRA_DIST = \
 	hostname \
 	net \
@@ -48,5 +44,3 @@ EXTRA_DIST = \
 	nm-system-settings.conf \
 	wpa_supplicant.conf \
 	test_ca_cert.pem
-
-endif
diff --git a/src/settings/plugins/ifnet/tests/Makefile.in b/src/settings/plugins/ifnet/tests/Makefile.in
index cd604237..8293c869 100644
--- a/src/settings/plugins/ifnet/tests/Makefile.in
+++ b/src/settings/plugins/ifnet/tests/Makefile.in
@@ -104,11 +104,11 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 PROGRAMS = $(noinst_PROGRAMS)
 am__check_ifnet_SOURCES_DIST = test_all.c ../connection_parser.c \
-	../net_parser.c ../net_utils.c ../wpa_parser.c ../errors.c
+	../net_parser.c ../net_utils.c ../wpa_parser.c
 @ENABLE_TESTS_TRUE@am_check_ifnet_OBJECTS = test_all.$(OBJEXT) \
 @ENABLE_TESTS_TRUE@	connection_parser.$(OBJEXT) \
 @ENABLE_TESTS_TRUE@	net_parser.$(OBJEXT) net_utils.$(OBJEXT) \
-@ENABLE_TESTS_TRUE@	wpa_parser.$(OBJEXT) errors.$(OBJEXT)
+@ENABLE_TESTS_TRUE@	wpa_parser.$(OBJEXT)
 check_ifnet_OBJECTS = $(am_check_ifnet_OBJECTS)
 @ENABLE_TESTS_TRUE@check_ifnet_DEPENDENCIES =  \
 @ENABLE_TESTS_TRUE@	$(top_builddir)/src/libNetworkManager.la
@@ -189,6 +189,8 @@ AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
+BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@
+BLUEZ5_LIBS = @BLUEZ5_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -312,6 +314,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@
@@ -331,6 +334,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@
@@ -357,7 +361,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@
@@ -438,22 +442,17 @@ with_resolvconf = @with_resolvconf@
 with_valgrind = @with_valgrind@
 @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \
 @ENABLE_TESTS_TRUE@	-I$(srcdir)/../ \
-@ENABLE_TESTS_TRUE@	-I$(top_srcdir)/libnm-glib \
-@ENABLE_TESTS_TRUE@	-I$(top_srcdir)/libnm-util \
-@ENABLE_TESTS_TRUE@	-I$(top_builddir)/libnm-util \
 @ENABLE_TESTS_TRUE@	-I$(top_srcdir)/include \
-@ENABLE_TESTS_TRUE@	-I$(top_builddir)/include \
+@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/config \
-@ENABLE_TESTS_TRUE@	-I$(top_srcdir)/src/logging \
 @ENABLE_TESTS_TRUE@	-I$(top_srcdir)/src/settings \
 @ENABLE_TESTS_TRUE@	-I$(top_srcdir)/src/platform \
 @ENABLE_TESTS_TRUE@	-DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \
+@ENABLE_TESTS_TRUE@	-DNETWORKMANAGER_COMPILATION \
 @ENABLE_TESTS_TRUE@	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
 @ENABLE_TESTS_TRUE@	$(CHECK_CFLAGS) \
 @ENABLE_TESTS_TRUE@	$(GLIB_CFLAGS) \
-@ENABLE_TESTS_TRUE@	$(DBUS_CFLAGS) \
-@ENABLE_TESTS_TRUE@	$(POLKIT_CFLAGS) \
 @ENABLE_TESTS_TRUE@	$(CODE_COVERAGE_CFLAGS) \
 @ENABLE_TESTS_TRUE@	-DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \
 @ENABLE_TESTS_TRUE@	-DSYSCONFDIR=\"nonexistent\"
@@ -463,20 +462,19 @@ with_valgrind = @with_valgrind@
 @ENABLE_TESTS_TRUE@	../connection_parser.c \
 @ENABLE_TESTS_TRUE@	../net_parser.c \
 @ENABLE_TESTS_TRUE@	../net_utils.c \
-@ENABLE_TESTS_TRUE@	../wpa_parser.c \
-@ENABLE_TESTS_TRUE@	../errors.c
+@ENABLE_TESTS_TRUE@	../wpa_parser.c
 
 @ENABLE_TESTS_TRUE@check_ifnet_LDFLAGS = \
 @ENABLE_TESTS_TRUE@	$(CODE_COVERAGE_LDFLAGS)
 
 @ENABLE_TESTS_TRUE@check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la
-@ENABLE_TESTS_TRUE@EXTRA_DIST = \
-@ENABLE_TESTS_TRUE@	hostname \
-@ENABLE_TESTS_TRUE@	net \
-@ENABLE_TESTS_TRUE@	net.all \
-@ENABLE_TESTS_TRUE@	nm-system-settings.conf \
-@ENABLE_TESTS_TRUE@	wpa_supplicant.conf \
-@ENABLE_TESTS_TRUE@	test_ca_cert.pem
+EXTRA_DIST = \
+	hostname \
+	net \
+	net.all \
+	nm-system-settings.conf \
+	wpa_supplicant.conf \
+	test_ca_cert.pem
 
 all: all-am
 
@@ -533,7 +531,6 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_parser.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errors.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_parser.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_utils.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_all.Po@am__quote@
@@ -616,20 +613,6 @@ wpa_parser.obj: ../wpa_parser.c
 @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 wpa_parser.obj `if test -f '../wpa_parser.c'; then $(CYGPATH_W) '../wpa_parser.c'; else $(CYGPATH_W) '$(srcdir)/../wpa_parser.c'; fi`
 
-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`
-
 mostlyclean-libtool:
 	-rm -f *.lo
 
diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test_all.c
index c320ed5f..9c399128 100644
--- a/src/settings/plugins/ifnet/tests/test_all.c
+++ b/src/settings/plugins/ifnet/tests/test_all.c
@@ -20,6 +20,8 @@
  * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
  */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <glib.h>
@@ -55,7 +57,7 @@ nm_config_get_dhcp_client (NMConfig *config)
 }
 
 static void
-test_getdata ()
+test_getdata (void)
 {
 	ASSERT (ifnet_get_data ("eth1", "config")
 		&& strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0,
@@ -103,7 +105,7 @@ test_write_hostname (const char *temp_path)
 }
 
 static void
-test_is_static ()
+test_is_static (void)
 {
 	ASSERT (is_static_ip4 ("eth1") == FALSE, "is static",
 		"a dhcp interface is recognized as static");
@@ -114,7 +116,7 @@ test_is_static ()
 }
 
 static void
-test_has_default_route ()
+test_has_default_route (void)
 {
 	ASSERT (has_default_ip4_route ("eth0"),
 		"has default route", "eth0 should have a default ipv4 route");
@@ -126,7 +128,7 @@ test_has_default_route ()
 }
 
 static void
-test_has_ip6_address ()
+test_has_ip6_address (void)
 {
 	ASSERT (has_ip6_address ("eth2"), "has ip6 address",
 		"eth2 should have a ipv6 address");
@@ -136,7 +138,7 @@ test_has_ip6_address ()
 }
 
 static void
-test_is_ip4_address ()
+test_is_ip4_address (void)
 {
 	gchar *address1 = "192.168.4.232/24";
 	gchar *address2 = "192.168.100.{1..254}/24";
@@ -151,7 +153,7 @@ test_is_ip4_address ()
 }
 
 static void
-test_is_ip6_address ()
+test_is_ip6_address (void)
 {
 	gchar *address1 = "4321:0:1:2:3:4:567:89ac/24";
 
@@ -160,43 +162,30 @@ test_is_ip6_address ()
 }
 
 static void
-check_ip_block (ip_block * iblock, gchar * ip, gchar * netmask, gchar * gateway)
+check_ip_block (ip_block * iblock, gchar * ip, guint32 prefix, gchar * gateway)
 {
-	char *str;
-	guint32 tmp_ip4_addr;
-
-	str = malloc (INET_ADDRSTRLEN);
-	tmp_ip4_addr = iblock->ip;
-	inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
-	ASSERT (strcmp (ip, str) == 0, "check ip",
-		"ip expected:%s, find:%s", ip, str);
-	tmp_ip4_addr = iblock->netmask;
-	inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
-	ASSERT (strcmp (netmask, str) == 0, "check netmask",
-		"netmask expected:%s, find:%s", netmask, str);
-	tmp_ip4_addr = iblock->gateway;
-	inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
-	ASSERT (strcmp (gateway, str) == 0, "check gateway",
-		"gateway expected:%s, find:%s", gateway, str);
-	free (str);
+	ASSERT (strcmp (ip, iblock->ip) == 0, "check ip",
+		"ip expected:%s, find:%s", ip, iblock->ip);
+	ASSERT (prefix == iblock->prefix, "check netmask",
+		"prefix expected:%d, find:%d", prefix, iblock->prefix);
+	ASSERT (g_strcmp0 (gateway, iblock->next_hop) == 0, "check gateway",
+		"gateway expected:%s, find:%s", gateway, iblock->next_hop);
 }
 
 static void
-test_convert_ipv4_config_block ()
+test_convert_ipv4_config_block (void)
 {
 	ip_block *iblock = convert_ip4_config_block ("eth0");
 	ip_block *tmp = iblock;
 
 	ASSERT (iblock != NULL, "convert ipv4 block",
 		"block eth0 should not be NULL");
-	check_ip_block (iblock, "202.117.16.121", "255.255.255.0",
-			"202.117.16.1");
+	check_ip_block (iblock, "202.117.16.121", 24, "202.117.16.1");
 	iblock = iblock->next;
 	destroy_ip_block (tmp);
 	ASSERT (iblock != NULL, "convert ipv4 block",
 		"block eth0 should have a second IP address");
-	check_ip_block (iblock, "192.168.4.121", "255.255.255.0",
-			"202.117.16.1");
+	check_ip_block (iblock, "192.168.4.121", 24, "202.117.16.1");
 	destroy_ip_block (iblock);
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
@@ -206,7 +195,7 @@ test_convert_ipv4_config_block ()
 	ASSERT (iblock != NULL
 		&& iblock->next == NULL,
 		"convert error IPv4 address", "should only get one address");
-	check_ip_block (iblock, "192.168.4.121", "255.255.255.0", "0.0.0.0");
+	check_ip_block (iblock, "192.168.4.121", 24, NULL);
 	destroy_ip_block (iblock);
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
@@ -214,17 +203,16 @@ test_convert_ipv4_config_block ()
 	iblock = convert_ip4_config_block ("eth3");
 	ASSERT (iblock == NULL, "convert config_block",
 		"convert error configuration");
-	destroy_ip_block (iblock);
 }
 
 static void
-test_convert_ipv4_routes_block ()
+test_convert_ipv4_routes_block (void)
 {
 	ip_block *iblock = convert_ip4_routes_block ("eth0");
 	ip_block *tmp = iblock;
 
 	ASSERT (iblock != NULL, "convert ip4 routes", "should get one route");
-	check_ip_block (iblock, "192.168.4.0", "255.255.255.0", "192.168.4.1");
+	check_ip_block (iblock, "192.168.4.0", 24, "192.168.4.1");
 	iblock = iblock->next;
 	destroy_ip_block (tmp);
 	ASSERT (iblock == NULL, "convert ip4 routes",
@@ -234,7 +222,7 @@ test_convert_ipv4_routes_block ()
 	tmp = iblock;
 
 	ASSERT (iblock != NULL, "convert ip4 routes", "should get one route");
-	check_ip_block (iblock, "10.0.0.0", "255.0.0.0", "192.168.0.1");
+	check_ip_block (iblock, "10.0.0.0", 8, "192.168.0.1");
 	iblock = iblock->next;
 	destroy_ip_block (tmp);
 	ASSERT (iblock == NULL, "convert ip4 routes",
@@ -242,7 +230,7 @@ test_convert_ipv4_routes_block ()
 }
 
 static void
-test_wpa_parser ()
+test_wpa_parser (void)
 {
 	const char *value;
 
@@ -261,7 +249,7 @@ test_wpa_parser ()
 }
 
 static void
-test_strip_string ()
+test_strip_string (void)
 {
 	gchar *str = "( \"default via     202.117.16.1\" )";
 	gchar *result = g_strdup (str);
@@ -277,7 +265,7 @@ test_strip_string ()
 }
 
 static void
-test_is_unmanaged ()
+test_is_unmanaged (void)
 {
 	ASSERT (is_managed ("eth0"), "test_is_unmanaged",
 		"eth0 should be managed");
@@ -286,7 +274,7 @@ test_is_unmanaged ()
 }
 
 static void
-test_new_connection ()
+test_new_connection (void)
 {
 	GError *error = NULL;
 	NMConnection *connection;
@@ -409,7 +397,7 @@ test_add_connection (const char *basepath)
 }
 
 static void
-test_delete_connection ()
+test_delete_connection (void)
 {
 	GError *error = NULL;
 	NMConnection *connection;
@@ -438,7 +426,7 @@ test_delete_connection ()
 }
 
 static void
-test_missing_config ()
+test_missing_config (void)
 {
 	GError *error = NULL;
 	NMConnection *connection;
diff --git a/src/settings/plugins/ifnet/wpa_parser.c b/src/settings/plugins/ifnet/wpa_parser.c
index 748eb351..3f912da8 100644
--- a/src/settings/plugins/ifnet/wpa_parser.c
+++ b/src/settings/plugins/ifnet/wpa_parser.c
@@ -19,6 +19,8 @@
  * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
  */
 
+#include "config.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <nm-system-config-interface.h>
@@ -166,7 +168,7 @@ add_one_wep_key (GHashTable * table, int key_num, gchar * one_wep_key)
 /* Reading wep security information from /etc/conf.d/net.
  * This should not be used in future, use wpa_supplicant instead. */
 static void
-add_keys_from_net ()
+add_keys_from_net (void)
 {
 	GList *names = ifnet_get_connection_names ();
 	GList *iter = names;