summary refs log tree commit diff
path: root/src/devices/wifi
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/devices/wifi
parent33491bc4279481db8ae47213e34a6d695a0e8830 (diff)
Imported Upstream version 1.0.0 upstream/1.0.0
Diffstat (limited to 'src/devices/wifi')
-rw-r--r--src/devices/wifi/Makefile.am12
-rw-r--r--src/devices/wifi/Makefile.in18
-rw-r--r--src/devices/wifi/exports.ver1
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.c127
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.h12
-rw-r--r--src/devices/wifi/nm-device-wifi.c931
-rw-r--r--src/devices/wifi/nm-device-wifi.h16
-rw-r--r--src/devices/wifi/nm-wifi-ap-utils.c316
-rw-r--r--src/devices/wifi/nm-wifi-ap-utils.h9
-rw-r--r--src/devices/wifi/nm-wifi-ap.c211
-rw-r--r--src/devices/wifi/nm-wifi-ap.h76
-rw-r--r--src/devices/wifi/nm-wifi-enum-types.c44
-rw-r--r--src/devices/wifi/nm-wifi-enum-types.h4
-rw-r--r--src/devices/wifi/nm-wifi-factory.c18
-rw-r--r--src/devices/wifi/tests/Makefile.am9
-rw-r--r--src/devices/wifi/tests/Makefile.in15
-rw-r--r--src/devices/wifi/tests/test-wifi-ap-utils.c231
17 files changed, 978 insertions, 1072 deletions
diff --git a/src/devices/wifi/Makefile.am b/src/devices/wifi/Makefile.am
index 5f3ce286..230c00ac 100644
--- a/src/devices/wifi/Makefile.am
+++ b/src/devices/wifi/Makefile.am
@@ -7,21 +7,17 @@ SUBDIRS=. tests
 AM_CPPFLAGS = \
 	-I${top_srcdir}/src \
 	-I${top_builddir}/src \
-	-I${top_srcdir}/src/logging \
 	-I${top_srcdir}/src/devices \
 	-I${top_srcdir}/src/settings \
 	-I${top_srcdir}/src/platform \
 	-I${top_srcdir}/src/supplicant-manager \
-	-I${top_builddir}/include \
 	-I${top_srcdir}/include \
-	-I${top_builddir}/libnm-util \
-	-I${top_srcdir}/libnm-util \
+	-I${top_builddir}/libnm-core \
+	-I${top_srcdir}/libnm-core \
 	-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
+	-DNETWORKMANAGER_COMPILATION \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
-	$(DBUS_CFLAGS) \
-	$(POLKIT_CFLAGS) \
-	$(LIBNL_CFLAGS) \
-	$(GUDEV_CFLAGS)
+	$(DBUS_CFLAGS)
 
 GLIB_GENERATED = nm-wifi-enum-types.h nm-wifi-enum-types.c
 GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
diff --git a/src/devices/wifi/Makefile.in b/src/devices/wifi/Makefile.in
index cbf6826b..175dd900 100644
--- a/src/devices/wifi/Makefile.in
+++ b/src/devices/wifi/Makefile.in
@@ -261,6 +261,8 @@ AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
+BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@
+BLUEZ5_LIBS = @BLUEZ5_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -384,6 +386,7 @@ NEWT_CFLAGS = @NEWT_CFLAGS@
 NEWT_LIBS = @NEWT_LIBS@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@
 NM_MAJOR_VERSION = @NM_MAJOR_VERSION@
 NM_MICRO_VERSION = @NM_MICRO_VERSION@
 NM_MINOR_VERSION = @NM_MINOR_VERSION@
@@ -403,6 +406,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
@@ -429,7 +433,7 @@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@
 SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@
 SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@
 SYSTEM_CA_PATH = @SYSTEM_CA_PATH@
-UDEV_BASE_DIR = @UDEV_BASE_DIR@
+UDEV_DIR = @UDEV_DIR@
 USE_NLS = @USE_NLS@
 UUID_CFLAGS = @UUID_CFLAGS@
 UUID_LIBS = @UUID_LIBS@
@@ -512,21 +516,17 @@ SUBDIRS = . tests
 AM_CPPFLAGS = \
 	-I${top_srcdir}/src \
 	-I${top_builddir}/src \
-	-I${top_srcdir}/src/logging \
 	-I${top_srcdir}/src/devices \
 	-I${top_srcdir}/src/settings \
 	-I${top_srcdir}/src/platform \
 	-I${top_srcdir}/src/supplicant-manager \
-	-I${top_builddir}/include \
 	-I${top_srcdir}/include \
-	-I${top_builddir}/libnm-util \
-	-I${top_srcdir}/libnm-util \
+	-I${top_builddir}/libnm-core \
+	-I${top_srcdir}/libnm-core \
 	-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
+	-DNETWORKMANAGER_COMPILATION \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
-	$(DBUS_CFLAGS) \
-	$(POLKIT_CFLAGS) \
-	$(LIBNL_CFLAGS) \
-	$(GUDEV_CFLAGS)
+	$(DBUS_CFLAGS)
 
 GLIB_GENERATED = nm-wifi-enum-types.h nm-wifi-enum-types.c
 GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
diff --git a/src/devices/wifi/exports.ver b/src/devices/wifi/exports.ver
index d2c45124..24cd848c 100644
--- a/src/devices/wifi/exports.ver
+++ b/src/devices/wifi/exports.ver
@@ -1,7 +1,6 @@
 {
 global:
 	nm_device_factory_create;
-	nm_device_factory_get_device_type;
 local:
 	*;
 };
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c
index 85214a70..0f5aa164 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.c
+++ b/src/devices/wifi/nm-device-olpc-mesh.c
@@ -25,18 +25,16 @@
  */
 
 #include "config.h"
+
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <dbus/dbus.h>
 #include <netinet/in.h>
 #include <string.h>
-#include <net/ethernet.h>
-#include <netinet/ether.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <signal.h>
 #include <unistd.h>
-#include <linux/if.h>
 #include <sys/ioctl.h>
 #include <errno.h>
 
@@ -53,14 +51,18 @@
 #include "nm-manager.h"
 #include "nm-enum-types.h"
 #include "nm-dbus-manager.h"
+#include "nm-platform.h"
 #include "nm-wifi-enum-types.h"
 
 /* This is a bug; but we can't really change API now... */
-#include "NetworkManagerVPN.h"
+#include "nm-vpn-dbus-interface.h"
 
 
 #include "nm-device-olpc-mesh-glue.h"
 
+#include "nm-device-logging.h"
+_LOG_DECLARE_SELF(NMDeviceOlpcMesh);
+
 G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE)
 
 #define NM_DEVICE_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshPrivate))
@@ -80,19 +82,6 @@ struct _NMDeviceOlpcMeshPrivate {
 
 /*******************************************************************/
 
-static GQuark
-nm_olpc_mesh_error_quark (void)
-{
-	static GQuark quark = 0;
-	if (!quark)
-		quark = g_quark_from_static_string ("nm-mesh-error");
-	return quark;
-}
-
-#define NM_OLPC_MESH_ERROR (nm_olpc_mesh_error_quark ())
-
-/*******************************************************************/
-
 static gboolean
 check_connection_compatible (NMDevice *device, NMConnection *connection)
 {
@@ -149,19 +138,17 @@ complete_connection (NMDevice *device,
 	}
 
 	if (!nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh)) {
-		const guint8 anycast[ETH_ALEN] = { 0xC0, 0x27, 0xC0, 0x27, 0xC0, 0x27 };
+		const char *anycast = "c0:27:c0:27:c0:27";
 
-		tmp = g_byte_array_sized_new (ETH_ALEN);
-		g_byte_array_append (tmp, anycast, sizeof (anycast));
-		g_object_set (G_OBJECT (s_mesh), NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, tmp, NULL);
-		g_byte_array_free (tmp, TRUE);
+		g_object_set (G_OBJECT (s_mesh), NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, anycast, NULL);
 
 	}
 
 	nm_utils_complete_generic (connection,
 	                           NM_SETTING_OLPC_MESH_SETTING_NAME,
 	                           existing_connections,
-	                           _("Mesh %d"),
+	                           NULL,
+	                           _("Mesh"),
 	                           NULL,
 	                           FALSE); /* No IPv6 by default */
 
@@ -171,28 +158,27 @@ complete_connection (NMDevice *device,
 /****************************************************************************/
 
 static NMActStageReturn
-act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
+act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
 {
-	NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (dev);
+	NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
+	NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device);
 	NMActStageReturn ret;
 	gboolean scanning;
 
-	ret = NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->act_stage1_prepare (dev, reason);
+	ret = NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->act_stage1_prepare (device, reason);
 	if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
 		return ret;
 
 	/* disconnect companion device, if it is connected */
 	if (nm_device_get_act_request (NM_DEVICE (priv->companion))) {
-		nm_log_info (LOGD_OLPC, "(%s): disconnecting companion device %s",
-		             nm_device_get_iface (dev),
-		             nm_device_get_iface (priv->companion));
+		_LOGI (LOGD_OLPC, "disconnecting companion device %s",
+		       nm_device_get_iface (priv->companion));
 		/* FIXME: VPN stuff here is a bug; but we can't really change API now... */
 		nm_device_state_changed (NM_DEVICE (priv->companion),
 		                         NM_DEVICE_STATE_DISCONNECTED,
-		                         NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
-		nm_log_info (LOGD_OLPC, "(%s): companion %s disconnected",
-		             nm_device_get_iface (dev),
-		             nm_device_get_iface (priv->companion));
+		                         NM_DEVICE_STATE_REASON_USER_REQUESTED);
+		_LOGI (LOGD_OLPC, "companion %s disconnected",
+		       nm_device_get_iface (priv->companion));
 	}
 
 
@@ -218,16 +204,16 @@ _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel)
 }
 
 static NMActStageReturn
-act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
+act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
 {
-	NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (dev);
+	NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
 	NMConnection *connection;
 	NMSettingOlpcMesh *s_mesh;
 	guint32 channel;
-	const GByteArray *anycast_addr_array;
-	guint8 *anycast_addr = NULL;
+	GBytes *ssid;
+	const char *anycast_addr;
 
-	connection = nm_device_get_connection (dev);
+	connection = nm_device_get_connection (device);
 	g_assert (connection);
 
 	s_mesh = nm_connection_get_setting_olpc_mesh (connection);
@@ -236,25 +222,25 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
 	channel = nm_setting_olpc_mesh_get_channel (s_mesh);
 	if (channel != 0)
 		_mesh_set_channel (self, channel);
-	nm_platform_mesh_set_ssid (nm_device_get_ifindex (dev),
-	                           nm_setting_olpc_mesh_get_ssid (s_mesh));
 
-	anycast_addr_array = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh);
-	if (anycast_addr_array)
-		anycast_addr = anycast_addr_array->data;
+	ssid = nm_setting_olpc_mesh_get_ssid (s_mesh);
+	nm_platform_mesh_set_ssid (nm_device_get_ifindex (device),
+	                           g_bytes_get_data (ssid, NULL),
+	                           g_bytes_get_size (ssid));
+
+	anycast_addr = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh);
+	nm_device_set_dhcp_anycast_address (device, anycast_addr);
 
-	nm_device_set_dhcp_anycast_address (dev, anycast_addr);
 	return NM_ACT_STAGE_RETURN_SUCCESS;
 }
 
 static gboolean
-is_available (NMDevice *dev)
+is_available (NMDevice *device)
 {
-	NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (dev);
+	NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
 
 	if (!NM_DEVICE_OLPC_MESH_GET_PRIVATE (self)->companion) {
-		nm_log_dbg (LOGD_WIFI, "(%s): not available because companion not found",
-		            nm_device_get_iface (dev));
+		_LOGD (LOGD_WIFI, "not available because companion not found");
 		return FALSE;
 	}
 
@@ -310,12 +296,11 @@ companion_state_changed_cb (NMDeviceWifi *companion,
 	    || state > NM_DEVICE_STATE_ACTIVATED)
 		return;
 
-	nm_log_dbg (LOGD_OLPC, "(%s): disconnecting mesh due to companion connectivity",
-	            nm_device_get_iface (NM_DEVICE (self)));
+	_LOGD (LOGD_OLPC, "disconnecting mesh due to companion connectivity");
 	/* FIXME: VPN stuff here is a bug; but we can't really change API now... */
 	nm_device_state_changed (NM_DEVICE (self),
 	                         NM_DEVICE_STATE_DISCONNECTED,
-	                         NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
+	                         NM_DEVICE_STATE_REASON_USER_REQUESTED);
 }
 
 static gboolean
@@ -343,24 +328,21 @@ static gboolean
 check_companion (NMDeviceOlpcMesh *self, NMDevice *other)
 {
 	NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
-	const guint8 *my_addr, *their_addr;
-	guint their_addr_len;
+	const char *my_addr, *their_addr;
 
 	if (!NM_IS_DEVICE_WIFI (other))
 		return FALSE;
 
-	my_addr = nm_device_get_hw_address (NM_DEVICE (self), NULL);
-	their_addr = nm_device_get_hw_address (other, &their_addr_len);
-	if (   (their_addr_len != ETH_ALEN)
-	    || (memcmp (my_addr, their_addr, ETH_ALEN) != 0))
+	my_addr = nm_device_get_hw_address (NM_DEVICE (self));
+	their_addr = nm_device_get_hw_address (other);
+	if (!nm_utils_hwaddr_matches (my_addr, -1, their_addr, -1))
 		return FALSE;
 
 	g_assert (priv->companion == NULL);
 	priv->companion = g_object_ref (other);
 
-	nm_log_info (LOGD_OLPC, "(%s): found companion WiFi device %s",
-	             nm_device_get_iface (NM_DEVICE (self)),
-	             nm_device_get_iface (other));
+	_LOGI (LOGD_OLPC, "found companion WiFi device %s",
+	       nm_device_get_iface (other));
 
 	g_signal_connect (G_OBJECT (other), "state-changed",
 	                  G_CALLBACK (companion_state_changed_cb), self);
@@ -471,13 +453,8 @@ constructor (GType type,
 
 	self = NM_DEVICE_OLPC_MESH (object);
 
-	nm_log_dbg (LOGD_HW | LOGD_OLPC, "(%s): kernel ifindex %d",
-	            nm_device_get_iface (NM_DEVICE (self)),
-	            nm_device_get_ifindex (NM_DEVICE (self)));
-
 	if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)), &caps)) {
-		nm_log_warn (LOGD_HW | LOGD_OLPC, "(%s): failed to initialize WiFi driver",
-		             nm_device_get_iface (NM_DEVICE (self)));
+		_LOGW (LOGD_HW | LOGD_OLPC, "failed to initialize WiFi driver");
 		g_object_unref (object);
 		return NULL;
 	}
@@ -562,24 +539,20 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
 	/* Properties */
 	g_object_class_install_property
 		(object_class, PROP_COMPANION,
-		 g_param_spec_boxed (NM_DEVICE_OLPC_MESH_COMPANION,
-		                     "Companion device",
-		                     "Companion device object path",
+		 g_param_spec_boxed (NM_DEVICE_OLPC_MESH_COMPANION, "", "",
 		                     DBUS_TYPE_G_OBJECT_PATH,
-		                     G_PARAM_READABLE));
+		                     G_PARAM_READABLE |
+		                     G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_ACTIVE_CHANNEL,
-		 g_param_spec_uint (NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL,
-		                   "Active channel",
-		                   "Active channel",
-		                   0, G_MAXUINT32, 0,
-		                   G_PARAM_READABLE));
+		 g_param_spec_uint (NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL, "", "",
+		                    0, G_MAXUINT32, 0,
+		                    G_PARAM_READABLE |
+		                    G_PARAM_STATIC_STRINGS));
 
 	nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
 	                                        G_TYPE_FROM_CLASS (klass),
 	                                        &dbus_glib_nm_device_olpc_mesh_object_info);
-
-	dbus_g_error_domain_register (NM_OLPC_MESH_ERROR, NULL, NM_TYPE_OLPC_MESH_ERROR);
 }
 
diff --git a/src/devices/wifi/nm-device-olpc-mesh.h b/src/devices/wifi/nm-device-olpc-mesh.h
index c25dd8e5..67d83fb0 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.h
+++ b/src/devices/wifi/nm-device-olpc-mesh.h
@@ -25,11 +25,10 @@
  * (C) Copyright 2009 One Laptop per Child
  */
 
-#ifndef NM_DEVICE_OLPC_MESH_H
-#define NM_DEVICE_OLPC_MESH_H
+#ifndef __NETWORKMANAGER_DEVICE_OLPC_MESH_H__
+#define __NETWORKMANAGER_DEVICE_OLPC_MESH_H__
 
 #include <glib-object.h>
-#include <dbus/dbus.h>
 
 #include "nm-device.h"
 
@@ -42,13 +41,6 @@ G_BEGIN_DECLS
 #define NM_IS_DEVICE_OLPC_MESH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  NM_TYPE_DEVICE_OLPC_MESH))
 #define NM_DEVICE_OLPC_MESH_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshClass))
 
-typedef enum
-{
-	NM_OLPC_MESH_ERROR_CONNECTION_NOT_MESH = 0, /*< nick=ConnectionNotMesh >*/
-	NM_OLPC_MESH_ERROR_CONNECTION_INVALID,      /*< nick=ConnectionInvalid >*/
-	NM_OLPC_MESH_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/
-} NMOlpcMeshError;
-
 #define NM_DEVICE_OLPC_MESH_COMPANION      "companion"
 #define NM_DEVICE_OLPC_MESH_BITRATE        "bitrate"
 #define NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL "active-channel"
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 95173cf4..dd7754b3 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -19,12 +19,13 @@
  * Copyright (C) 2006 - 2008 Novell, Inc.
  */
 
+#include "config.h"
+
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <dbus/dbus.h>
 #include <netinet/in.h>
 #include <string.h>
-#include <net/ethernet.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <signal.h>
@@ -32,7 +33,6 @@
 #include <linux/sockios.h>
 #include <linux/ethtool.h>
 #include <sys/ioctl.h>
-#include <netinet/ether.h>
 #include <errno.h>
 
 #include "nm-glib-compat.h"
@@ -52,9 +52,10 @@
 #include "nm-setting-wireless-security.h"
 #include "nm-setting-8021x.h"
 #include "nm-setting-ip4-config.h"
+#include "nm-ip4-config.h"
 #include "nm-setting-ip6-config.h"
 #include "nm-platform.h"
-#include "nm-manager-auth.h"
+#include "nm-auth-utils.h"
 #include "nm-settings-connection.h"
 #include "nm-enum-types.h"
 #include "nm-dbus-glib-types.h"
@@ -76,6 +77,8 @@ static void impl_device_request_scan (NMDeviceWifi *device,
 
 #include "nm-device-wifi-glue.h"
 
+#include "nm-device-logging.h"
+_LOG_DECLARE_SELF(NMDeviceWifi);
 
 /* All of these are in seconds */
 #define SCAN_INTERVAL_MIN 3
@@ -115,8 +118,8 @@ static guint signals[LAST_SIGNAL] = { 0 };
 struct _NMDeviceWifiPrivate {
 	gboolean          disposed;
 
-	guint8            perm_hw_addr[ETH_ALEN];    /* Permanent MAC address */
-	guint8            initial_hw_addr[ETH_ALEN]; /* Initial MAC address (as seen when NM starts) */
+	char *            perm_hw_addr;    /* Permanent MAC address */
+	char *            initial_hw_addr; /* Initial MAC address (as seen when NM starts) */
 
 	gint8             invalid_strength_counter;
 
@@ -192,19 +195,6 @@ static void remove_supplicant_interface_error_handler (NMDeviceWifi *self);
 
 /*****************************************************************/
 
-#define NM_WIFI_ERROR (nm_wifi_error_quark ())
-
-static GQuark
-nm_wifi_error_quark (void)
-{
-	static GQuark quark = 0;
-	if (!quark)
-		quark = g_quark_from_static_string ("nm-wifi-error");
-	return quark;
-}
-
-/*****************************************************************/
-
 static GObject*
 constructor (GType type,
              guint n_construct_params,
@@ -223,22 +213,15 @@ constructor (GType type,
 	self = NM_DEVICE_WIFI (object);
 	priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 
-	nm_log_dbg (LOGD_HW | LOGD_WIFI, "(%s): kernel ifindex %d",
-	            nm_device_get_iface (NM_DEVICE (self)),
-	            nm_device_get_ifindex (NM_DEVICE (self)));
-
 	if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)),
 	                                        &priv->capabilities)) {
-		nm_log_warn (LOGD_HW | LOGD_WIFI, "(%s): failed to initialize WiFi driver",
-		             nm_device_get_iface (NM_DEVICE (self)));
+		_LOGW (LOGD_HW | LOGD_WIFI, "failed to initialize WiFi driver");
 		g_object_unref (object);
 		return NULL;
 	}
 
-	if (priv->capabilities & NM_WIFI_DEVICE_CAP_AP) {
-		nm_log_info (LOGD_HW | LOGD_WIFI, "(%s): driver supports Access Point (AP) mode",
-		             nm_device_get_iface (NM_DEVICE (self)));
-	}
+	if (priv->capabilities & NM_WIFI_DEVICE_CAP_AP)
+		_LOGI (LOGD_HW | LOGD_WIFI, "driver supports Access Point (AP) mode");
 
 	/* Connect to the supplicant manager */
 	priv->sup_mgr = nm_supplicant_manager_get ();
@@ -260,13 +243,12 @@ supplicant_interface_acquire (NMDeviceWifi *self)
 	                                                   nm_device_get_iface (NM_DEVICE (self)),
 	                                                   TRUE);
 	if (priv->sup_iface == NULL) {
-		nm_log_err (LOGD_WIFI, "Couldn't initialize supplicant interface for %s.",
-		            nm_device_get_iface (NM_DEVICE (self)));
+		_LOGE (LOGD_WIFI, "Couldn't initialize supplicant interface");
 		return FALSE;
 	}
 
 	if (nm_supplicant_interface_get_state (priv->sup_iface) < NM_SUPPLICANT_INTERFACE_STATE_READY)
-		nm_device_add_pending_action (NM_DEVICE (self), "waiting for supplicant", TRUE);
+		nm_device_add_pending_action (NM_DEVICE (self), "waiting for supplicant", FALSE);
 
 	g_signal_connect (priv->sup_iface,
 	                  NM_SUPPLICANT_INTERFACE_STATE,
@@ -309,9 +291,8 @@ supplicant_interface_release (NMDeviceWifi *self)
 
 	/* Reset the scan interval to be pretty frequent when disconnected */
 	priv->scan_interval = SCAN_INTERVAL_MIN + SCAN_INTERVAL_STEP;
-	nm_log_dbg (LOGD_WIFI_SCAN, "(%s): reset scanning interval to %d seconds",
-	            nm_device_get_iface (NM_DEVICE (self)),
-	            priv->scan_interval);
+	_LOGD (LOGD_WIFI_SCAN, "reset scanning interval to %d seconds",
+	       priv->scan_interval);
 
 	if (priv->scanlist_cull_id) {
 		g_source_remove (priv->scanlist_cull_id);
@@ -370,9 +351,8 @@ find_active_ap (NMDeviceWifi *self,
                 gboolean match_hidden)
 {
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
-	const char *iface = nm_device_get_iface (NM_DEVICE (self));
 	int ifindex = nm_device_get_ifindex (NM_DEVICE (self));
-	struct ether_addr bssid;
+	guint8 bssid[ETH_ALEN];
 	GByteArray *ssid;
 	GSList *iter;
 	int i = 0;
@@ -382,22 +362,18 @@ find_active_ap (NMDeviceWifi *self,
 	NM80211Mode devmode;
 	guint32 devfreq;
 
-	nm_platform_wifi_get_bssid (ifindex, &bssid);
-	nm_log_dbg (LOGD_WIFI, "(%s): active BSSID: %02x:%02x:%02x:%02x:%02x:%02x",
-	            iface,
-	            bssid.ether_addr_octet[0], bssid.ether_addr_octet[1],
-	            bssid.ether_addr_octet[2], bssid.ether_addr_octet[3],
-	            bssid.ether_addr_octet[4], bssid.ether_addr_octet[5]);
+	nm_platform_wifi_get_bssid (ifindex, bssid);
+	_LOGD (LOGD_WIFI, "active BSSID: %02x:%02x:%02x:%02x:%02x:%02x",
+	       bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);
 
-	if (!nm_ethernet_address_is_valid (&bssid))
+	if (!nm_ethernet_address_is_valid (bssid, ETH_ALEN))
 		return NULL;
 
 	ssid = nm_platform_wifi_get_ssid (ifindex);
-	nm_log_dbg (LOGD_WIFI, "(%s): active SSID: %s%s%s",
-	            iface,
-	            ssid ? "'" : "",
-	            ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
-	            ssid ? "'" : "");
+	_LOGD (LOGD_WIFI, "active SSID: %s%s%s",
+	       ssid ? "'" : "",
+	       ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
+	       ssid ? "'" : "");
 
 	devmode = nm_platform_wifi_get_mode (ifindex);
 	devfreq = nm_platform_wifi_get_frequency (ifindex);
@@ -407,50 +383,54 @@ find_active_ap (NMDeviceWifi *self,
 	 * and therefore it won't get matched the first time around.
 	 */
 	while (i++ < (match_hidden ? 2 : 1)) {
-		nm_log_dbg (LOGD_WIFI, "  Pass #%d %s", i, i > 1 ? "(ignoring SSID)" : "");
+		_LOGD (LOGD_WIFI, "  Pass #%d %s", i, i > 1 ? "(ignoring SSID)" : "");
 
 		/* Find this SSID + BSSID in the device's AP list */
 		for (iter = priv->ap_list; iter; iter = g_slist_next (iter)) {
 			NMAccessPoint *ap = NM_AP (iter->data);
-			const struct ether_addr	*ap_bssid = nm_ap_get_address (ap);
+			const char *ap_bssid = nm_ap_get_address (ap);
 			const GByteArray *ap_ssid = nm_ap_get_ssid (ap);
 			NM80211Mode apmode;
 			guint32 apfreq;
 
-			nm_log_dbg (LOGD_WIFI, "    AP: %s%s%s  %02x:%02x:%02x:%02x:%02x:%02x",
-			            ap_ssid ? "'" : "",
-			            ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)",
-			            ap_ssid ? "'" : "",
-			            ap_bssid->ether_addr_octet[0], ap_bssid->ether_addr_octet[1],
-			            ap_bssid->ether_addr_octet[2], ap_bssid->ether_addr_octet[3],
-			            ap_bssid->ether_addr_octet[4], ap_bssid->ether_addr_octet[5]);
+			_LOGD (LOGD_WIFI, "    AP: %s%s%s  %s",
+			       ap_ssid ? "'" : "",
+			       ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)",
+			       ap_ssid ? "'" : "",
+			       str_if_set (ap_bssid, "(none)"));
 
 			if (ap == ignore_ap) {
-				nm_log_dbg (LOGD_WIFI, "      ignored");
+				_LOGD (LOGD_WIFI, "      ignored");
 				continue;
 			}
 
-			if (memcmp (bssid.ether_addr_octet, ap_bssid->ether_addr_octet, ETH_ALEN)) {
-				nm_log_dbg (LOGD_WIFI, "      BSSID mismatch");
+			if (!nm_utils_hwaddr_matches (bssid, ETH_ALEN, ap_bssid, -1)) {
+				_LOGD (LOGD_WIFI, "      BSSID mismatch");
 				continue;
 			}
 
-			if ((i == 0) && !nm_utils_same_ssid (ssid, ap_ssid, TRUE)) {
-				nm_log_dbg (LOGD_WIFI, "      SSID mismatch");
-				continue;
+			if (i == 0) {
+				if (   (ssid && !ap_ssid)
+				    || (ap_ssid && !ssid)
+				    || (ssid && ap_ssid && !nm_utils_same_ssid (ssid->data, ssid->len,
+				                                                ap_ssid->data, ap_ssid->len,
+				                                                TRUE))) {
+					_LOGD (LOGD_WIFI, "      SSID mismatch");
+					continue;
+				}
 			}
 
 			apmode = nm_ap_get_mode (ap);
 			if (devmode != apmode) {
-				nm_log_dbg (LOGD_WIFI, "      mode mismatch (device %d, ap %d)",
-				            devmode, apmode);
+				_LOGD (LOGD_WIFI, "      mode mismatch (device %d, ap %d)",
+				       devmode, apmode);
 				continue;
 			}
 
 			apfreq = nm_ap_get_freq (ap);
 			if (devfreq != apfreq) {
-				nm_log_dbg (LOGD_WIFI, "      frequency mismatch (device %u, ap %u)",
-				            devfreq, apfreq);
+				_LOGD (LOGD_WIFI, "      frequency mismatch (device %u, ap %u)",
+				       devfreq, apfreq);
 
 				if (match_nofreq == NULL)
 					match_nofreq = ap;
@@ -463,7 +443,7 @@ find_active_ap (NMDeviceWifi *self,
 			}
 
 			// FIXME: handle security settings here too
-			nm_log_dbg (LOGD_WIFI, "      matched");
+			_LOGD (LOGD_WIFI, "      matched");
 			active_ap = ap;
 			goto done;
 		}
@@ -482,22 +462,19 @@ find_active_ap (NMDeviceWifi *self,
 	 * we can't match the AP based on frequency at all, just give up.
 	 */
 	if (match_nofreq && ((found_a_band != found_bg_band) || (devfreq == 0))) {
-		const struct ether_addr	*ap_bssid = nm_ap_get_address (match_nofreq);
 		const GByteArray *ap_ssid = nm_ap_get_ssid (match_nofreq);
 
-		nm_log_dbg (LOGD_WIFI, "    matched %s%s%s  %02x:%02x:%02x:%02x:%02x:%02x",
-		            ap_ssid ? "'" : "",
-		            ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)",
-		            ap_ssid ? "'" : "",
-		            ap_bssid->ether_addr_octet[0], ap_bssid->ether_addr_octet[1],
-		            ap_bssid->ether_addr_octet[2], ap_bssid->ether_addr_octet[3],
-		            ap_bssid->ether_addr_octet[4], ap_bssid->ether_addr_octet[5]);
+		_LOGD (LOGD_WIFI, "    matched %s%s%s  %s",
+		       ap_ssid ? "'" : "",
+		       ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)",
+		       ap_ssid ? "'" : "",
+		       str_if_set (nm_ap_get_address (match_nofreq), "(none)"));
 
 		active_ap = match_nofreq;
 		goto done;
 	}
 
-	nm_log_dbg (LOGD_WIFI, "  No matching AP found.");
+	_LOGD (LOGD_WIFI, "  No matching AP found.");
 
 done:
 	if (ssid)
@@ -612,15 +589,17 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
 	 * current AP with it, if the current AP is adhoc.
 	 */
 	if (priv->current_ap && (nm_ap_get_mode (priv->current_ap) == NM_802_11_MODE_ADHOC)) {
-		struct ether_addr bssid = { {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} };
+		guint8 bssid[ETH_ALEN] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
 
-		nm_platform_wifi_get_bssid (ifindex, &bssid);
+		nm_platform_wifi_get_bssid (ifindex, bssid);
 		/* 0x02 means "locally administered" and should be OR-ed into
 		 * the first byte of IBSS BSSIDs.
 		 */
-		if (   (bssid.ether_addr_octet[0] & 0x02)
-		    && nm_ethernet_address_is_valid (&bssid))
-			nm_ap_set_address (priv->current_ap, &bssid);
+		if ((bssid[0] & 0x02) && nm_ethernet_address_is_valid (bssid, ETH_ALEN)) {
+			char *bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
+			nm_ap_set_address (priv->current_ap, bssid_str);
+			g_free (bssid_str);
+		}
 	}
 
 	new_ap = find_active_ap (self, ignore_ap, FALSE);
@@ -636,32 +615,26 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
 	}
 
 	if (new_ap != priv->current_ap) {
-		const struct ether_addr *new_bssid = NULL;
+		const char *new_bssid = NULL;
 		const GByteArray *new_ssid = NULL;
-		const struct ether_addr *old_bssid = NULL;
+		const char *old_bssid = NULL;
 		const GByteArray *old_ssid = NULL;
-		char *old_addr = NULL, *new_addr = NULL;
 
 		if (new_ap) {
 			new_bssid = nm_ap_get_address (new_ap);
-			new_addr = nm_utils_hwaddr_ntoa (new_bssid, ARPHRD_ETHER);
 			new_ssid = nm_ap_get_ssid (new_ap);
 		}
 
 		if (priv->current_ap) {
 			old_bssid = nm_ap_get_address (priv->current_ap);
-			old_addr = nm_utils_hwaddr_ntoa (old_bssid, ARPHRD_ETHER);
 			old_ssid = nm_ap_get_ssid (priv->current_ap);
 		}
 
-		nm_log_info (LOGD_WIFI, "(%s): roamed from BSSID %s (%s) to %s (%s)",
-		             nm_device_get_iface (NM_DEVICE (self)),
-		             old_addr ? old_addr : "(none)",
-		             old_ssid ? nm_utils_escape_ssid (old_ssid->data, old_ssid->len) : "(none)",
-		             new_addr ? new_addr : "(none)",
-		             new_ssid ? nm_utils_escape_ssid (new_ssid->data, new_ssid->len) : "(none)");
-		g_free (old_addr);
-		g_free (new_addr);
+		_LOGI (LOGD_WIFI, "roamed from BSSID %s (%s) to %s (%s)",
+		       old_bssid ? old_bssid : "(none)",
+		       old_ssid ? nm_utils_escape_ssid (old_ssid->data, old_ssid->len) : "(none)",
+		       new_bssid ? new_bssid : "(none)",
+		       new_ssid ? nm_utils_escape_ssid (new_ssid->data, new_ssid->len) : "(none)");
 
 		set_current_ap (self, new_ap, TRUE, FALSE);
 	}
@@ -734,15 +707,15 @@ remove_all_aps (NMDeviceWifi *self)
 }
 
 static void
-deactivate (NMDevice *dev)
+deactivate (NMDevice *device)
 {
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
-	int ifindex = nm_device_get_ifindex (dev);
+	int ifindex = nm_device_get_ifindex (device);
 	NMConnection *connection;
 	NM80211Mode old_mode = priv->mode;
 
-	connection = nm_device_get_connection (dev);
+	connection = nm_device_get_connection (device);
 	if (connection) {
 		/* Clear wireless secrets tries when deactivating */
 		g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
@@ -768,7 +741,8 @@ deactivate (NMDevice *dev)
 	nm_platform_wifi_indicate_addressing_running (ifindex, FALSE);
 
 	/* Reset MAC address back to initial address */
-	nm_device_set_hw_addr (dev, priv->initial_hw_addr, "reset", LOGD_WIFI);
+	if (priv->initial_hw_addr)
+		nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_WIFI);
 
 	/* Ensure we're in infrastructure mode after deactivation; some devices
 	 * (usually older ones) don't scan well in adhoc mode.
@@ -828,8 +802,9 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
-	const GByteArray *mac;
-	const GSList *mac_blacklist, *mac_blacklist_iter;
+	const char *mac;
+	const char * const *mac_blacklist;
+	int i;
 	const char *mode;
 
 	if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->check_connection_compatible (device, connection))
@@ -846,21 +821,18 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
 		return FALSE;
 
 	mac = nm_setting_wireless_get_mac_address (s_wireless);
-	if (mac && memcmp (mac->data, &priv->perm_hw_addr, ETH_ALEN))
+	if (mac && !nm_utils_hwaddr_matches (mac, -1, priv->perm_hw_addr, -1))
 		return FALSE;
 
 	/* Check for MAC address blacklist */
 	mac_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless);
-	for (mac_blacklist_iter = mac_blacklist; mac_blacklist_iter;
-	     mac_blacklist_iter = g_slist_next (mac_blacklist_iter)) {
-		struct ether_addr addr;
-
-		if (!ether_aton_r (mac_blacklist_iter->data, &addr)) {
+	for (i = 0; mac_blacklist[i]; i++) {
+		if (!nm_utils_hwaddr_valid (mac_blacklist[i], ETH_ALEN)) {
 			g_warn_if_reached ();
-			continue;
+			return FALSE;
 		}
 
-		if (memcmp (&addr, &priv->perm_hw_addr, ETH_ALEN) == 0)
+		if (nm_utils_hwaddr_matches (mac_blacklist[i], -1, priv->perm_hw_addr, -1))
 			return FALSE;
 	}
 
@@ -998,10 +970,12 @@ complete_connection (NMDevice *device,
 	NMSettingWireless *s_wifi;
 	NMSettingWirelessSecurity *s_wsec;
 	NMSetting8021x *s_8021x;
-	const GByteArray *setting_mac;
-	char *format, *str_ssid = NULL;
+	const char *setting_mac;
+	char *str_ssid = NULL;
 	NMAccessPoint *ap = NULL;
 	const GByteArray *ssid = NULL;
+	GByteArray *tmp_ssid = NULL;
+	GBytes *setting_ssid = NULL;
 	GSList *iter;
 	gboolean hidden = FALSE;
 
@@ -1013,17 +987,17 @@ complete_connection (NMDevice *device,
 		/* If not given a specific object, we need at minimum an SSID */
 		if (!s_wifi) {
 			g_set_error_literal (error,
-			                     NM_WIFI_ERROR,
-			                     NM_WIFI_ERROR_CONNECTION_INVALID,
+			                     NM_DEVICE_ERROR,
+			                     NM_DEVICE_ERROR_INVALID_CONNECTION,
 			                     "A 'wireless' setting is required if no AP path was given.");
 			return FALSE;
 		}
 
-		ssid = nm_setting_wireless_get_ssid (s_wifi);
-		if (!ssid || !ssid->len) {
+		setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
+		if (!setting_ssid || g_bytes_get_size (setting_ssid) == 0) {
 			g_set_error_literal (error,
-			                     NM_WIFI_ERROR,
-			                     NM_WIFI_ERROR_CONNECTION_INVALID,
+			                     NM_DEVICE_ERROR,
+			                     NM_DEVICE_ERROR_INVALID_CONNECTION,
 			                     "A 'wireless' setting with a valid SSID is required if no AP path was given.");
 			return FALSE;
 		}
@@ -1041,17 +1015,7 @@ complete_connection (NMDevice *device,
 		 * if the network isn't broadcasting the SSID for example.
 		 */
 		if (!ap) {
-			GSList *settings = NULL;
-			gboolean valid;
-
-			settings = g_slist_prepend (settings, s_wifi);
-			if (s_wsec)
-				settings = g_slist_prepend (settings, s_wsec);
-			if (s_8021x)
-				settings = g_slist_prepend (settings, s_8021x);
-			valid = nm_setting_verify (NM_SETTING (s_wifi), settings, error);
-			g_slist_free (settings);
-			if (!valid)
+			if (!nm_setting_verify (NM_SETTING (s_wifi), connection, error))
 				return FALSE;
 
 			hidden = TRUE;
@@ -1060,8 +1024,8 @@ complete_connection (NMDevice *device,
 		ap = get_ap_by_path (self, specific_object);
 		if (!ap) {
 			g_set_error (error,
-			             NM_WIFI_ERROR,
-			             NM_WIFI_ERROR_ACCESS_POINT_NOT_FOUND,
+			             NM_DEVICE_ERROR,
+			             NM_DEVICE_ERROR_SPECIFIC_OBJECT_NOT_FOUND,
 			             "The access point %s was not in the scan list.",
 			             specific_object);
 			return FALSE;
@@ -1074,37 +1038,48 @@ complete_connection (NMDevice *device,
 		nm_connection_add_setting (connection, NM_SETTING (s_wifi));
 	}
 
-	if (ap) {
+	if (ap)
 		ssid = nm_ap_get_ssid (ap);
-
-		if (ssid == NULL) {
-			/* The AP must be hidden.  Connecting to a WiFi AP requires the SSID
-			 * as part of the initial handshake, so check the connection details
-			 * for the SSID.  The AP object will still be used for encryption
-			 * settings and such.
-			 */
-			ssid = nm_setting_wireless_get_ssid (s_wifi);
+	if (ssid == NULL) {
+		/* The AP must be hidden.  Connecting to a WiFi AP requires the SSID
+		 * as part of the initial handshake, so check the connection details
+		 * for the SSID.  The AP object will still be used for encryption
+		 * settings and such.
+		 */
+		setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
+		if (setting_ssid) {
+			ssid = tmp_ssid = g_byte_array_new ();
+			g_byte_array_append (tmp_ssid,
+			                     g_bytes_get_data (setting_ssid, NULL),
+			                     g_bytes_get_size (setting_ssid));
 		}
+	}
 
-		if (ssid == NULL) {
-			/* If there's no SSID on the AP itself, and no SSID in the
-			 * connection data, then we cannot connect at all.  Return an error.
-			 */
-			g_set_error_literal (error,
-			                     NM_WIFI_ERROR,
-			                     NM_WIFI_ERROR_CONNECTION_INVALID,
-			                     "A 'wireless' setting with a valid SSID is required for hidden access points.");
-			return FALSE;
-		}
+	if (ssid == NULL) {
+		/* If there's no SSID on the AP itself, and no SSID in the
+		 * connection data, then we cannot connect at all.  Return an error.
+		 */
+		g_set_error_literal (error,
+		                     NM_DEVICE_ERROR,
+		                     NM_DEVICE_ERROR_INVALID_CONNECTION,
+		                     ap
+		                         ? "A 'wireless' setting with a valid SSID is required for hidden access points."
+		                         : "Cannot create 'wireless' setting due to missing SSID.");
+		return FALSE;
+	}
 
+	if (ap) {
 		/* If the SSID is a well-known SSID, lock the connection to the AP's
 		 * specific BSSID so NM doesn't autoconnect to some random wifi net.
 		 */
 		if (!nm_ap_complete_connection (ap,
 		                                connection,
 		                                is_manf_default_ssid (ssid),
-		                                error))
+		                                error)) {
+			if (tmp_ssid)
+				g_byte_array_unref (tmp_ssid);
 			return FALSE;
+		}
 	}
 
 	/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
@@ -1113,24 +1088,27 @@ complete_connection (NMDevice *device,
 	 */
 	if (is_adhoc_wpa (connection)) {
 		g_set_error_literal (error,
-		                     NM_SETTING_WIRELESS_ERROR,
-		                     NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
-		                     "WPA Ad-Hoc disabled due to kernel bugs");
+		                     NM_CONNECTION_ERROR,
+		                     NM_CONNECTION_ERROR_INVALID_SETTING,
+		                     _("WPA Ad-Hoc disabled due to kernel bugs"));
+		g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
+		if (tmp_ssid)
+			g_byte_array_unref (tmp_ssid);
 		return FALSE;
 	}
 
-	g_assert (ssid);
-	str_ssid = nm_utils_ssid_to_utf8 (ssid);
-	format = g_strdup_printf ("%s %%d", str_ssid);
+	str_ssid = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
 
 	nm_utils_complete_generic (connection,
 	                           NM_SETTING_WIRELESS_SETTING_NAME,
 	                           existing_connections,
-	                           format,
 	                           str_ssid,
+	                           str_ssid,
+	                           NULL,
 	                           TRUE);
 	g_free (str_ssid);
-	g_free (format);
+	if (tmp_ssid)
+		g_byte_array_unref (tmp_ssid);
 
 	if (hidden)
 		g_object_set (s_wifi, NM_SETTING_WIRELESS_HIDDEN, TRUE, NULL);
@@ -1138,26 +1116,26 @@ complete_connection (NMDevice *device,
 	setting_mac = nm_setting_wireless_get_mac_address (s_wifi);
 	if (setting_mac) {
 		/* Make sure the setting MAC (if any) matches the device's permanent MAC */
-		if (memcmp (setting_mac->data, priv->perm_hw_addr, ETH_ALEN)) {
-			g_set_error (error,
-			             NM_SETTING_WIRELESS_ERROR,
-			             NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
-			             NM_SETTING_WIRELESS_MAC_ADDRESS);
+		if (!nm_utils_hwaddr_matches (setting_mac, -1, priv->perm_hw_addr, -1)) {
+			g_set_error_literal (error,
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			                     _("connection does not match device"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS);
 			return FALSE;
 		}
 	} else {
-		GByteArray *mac;
-		const guint8 null_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
+		guint8 perm_hw_addr[ETH_ALEN];
 
 		/* Lock the connection to this device by default if it uses a
 		 * permanent MAC address (ie not a 'locally administered' one)
 		 */
-		if (   !(priv->perm_hw_addr[0] & 0x02)
-		    && memcmp (priv->perm_hw_addr, null_mac, ETH_ALEN)) {
-			mac = g_byte_array_sized_new (ETH_ALEN);
-			g_byte_array_append (mac, priv->perm_hw_addr, ETH_ALEN);
-			g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MAC_ADDRESS, mac, NULL);
-			g_byte_array_free (mac, TRUE);
+		nm_utils_hwaddr_aton (priv->perm_hw_addr, perm_hw_addr, ETH_ALEN);
+		if (   !(perm_hw_addr[0] & 0x02)
+		    && !nm_utils_hwaddr_matches (perm_hw_addr, ETH_ALEN, NULL, ETH_ALEN)) {
+			g_object_set (G_OBJECT (s_wifi),
+			              NM_SETTING_WIRELESS_MAC_ADDRESS, priv->perm_hw_addr,
+			              NULL);
 		}
 	}
 
@@ -1165,31 +1143,26 @@ complete_connection (NMDevice *device,
 }
 
 static gboolean
-is_available (NMDevice *dev)
+is_available (NMDevice *device)
 {
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
-	NMSupplicantInterface *sup_iface;
 	guint32 state;
 
 	if (!priv->enabled) {
-		nm_log_dbg (LOGD_WIFI, "(%s): not available because not enabled",
-		            nm_device_get_iface (dev));
+		_LOGD (LOGD_WIFI, "not available because not enabled");
 		return FALSE;
 	}
 
-	sup_iface = priv->sup_iface;
-	if (!sup_iface) {
-		nm_log_dbg (LOGD_WIFI, "(%s): not available because supplicant not running",
-		            nm_device_get_iface (dev));
+	if (!priv->sup_iface) {
+		_LOGD (LOGD_WIFI, "not available because supplicant not running");
 		return FALSE;
 	}
 
-	state = nm_supplicant_interface_get_state (sup_iface);
+	state = nm_supplicant_interface_get_state (priv->sup_iface);
 	if (   state < NM_SUPPLICANT_INTERFACE_STATE_READY
 	    || state > NM_SUPPLICANT_INTERFACE_STATE_COMPLETED) {
-		nm_log_dbg (LOGD_WIFI, "(%s): not available because supplicant interface not ready",
-		            nm_device_get_iface (dev));
+		_LOGD (LOGD_WIFI, "not available because supplicant interface not ready");
 		return FALSE;
 	}
 
@@ -1197,17 +1170,17 @@ is_available (NMDevice *dev)
 }
 
 static gboolean
-can_auto_connect (NMDevice *dev,
+can_auto_connect (NMDevice *device,
                   NMConnection *connection,
                   char **specific_object)
 {
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 	GSList *ap_iter;
 	const char *method = NULL;
 	guint64 timestamp = 0;
 
-	if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (dev, connection, specific_object))
+	if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, specific_object))
 		return FALSE;
 
 	/* Don't autoconnect to networks that have been tried at least once
@@ -1246,12 +1219,12 @@ ap_list_dump (NMDeviceWifi *self)
 
 	g_return_if_fail (NM_IS_DEVICE_WIFI (self));
 
-	nm_log_dbg (LOGD_WIFI_SCAN, "Current AP list:");
+	_LOGD (LOGD_WIFI_SCAN, "Current AP list:");
 	for (elt = priv->ap_list; elt; elt = g_slist_next (elt), i++) {
 		NMAccessPoint * ap = NM_AP (elt->data);
 		nm_ap_dump (ap, "List AP: ");
 	}
-	nm_log_dbg (LOGD_WIFI_SCAN, "Current AP list: done");
+	_LOGD (LOGD_WIFI_SCAN, "Current AP list: done");
 }
 
 static gboolean
@@ -1301,8 +1274,8 @@ request_scan_cb (NMDevice *device,
 	}
 
 	if (!check_scanning_allowed (self)) {
-		local = g_error_new_literal (NM_WIFI_ERROR,
-		                             NM_WIFI_ERROR_SCAN_NOT_ALLOWED,
+		local = g_error_new_literal (NM_DEVICE_ERROR,
+		                             NM_DEVICE_ERROR_NOT_ALLOWED,
 		                             "Scanning not allowed at this time");
 		dbus_g_method_return_error (context, local);
 		g_error_free (local);
@@ -1328,23 +1301,23 @@ impl_device_request_scan (NMDeviceWifi *self,
 	    || !priv->sup_iface
 	    || nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED
 	    || nm_device_is_activating (device)) {
-		error = g_error_new_literal (NM_WIFI_ERROR,
-		                             NM_WIFI_ERROR_SCAN_NOT_ALLOWED,
+		error = g_error_new_literal (NM_DEVICE_ERROR,
+		                             NM_DEVICE_ERROR_NOT_ALLOWED,
 		                             "Scanning not allowed while unavailable or activating");
 		goto error;
 	}
 
 	if (nm_supplicant_interface_get_scanning (priv->sup_iface)) {
-		error = g_error_new_literal (NM_WIFI_ERROR,
-		                             NM_WIFI_ERROR_SCAN_NOT_ALLOWED,
+		error = g_error_new_literal (NM_DEVICE_ERROR,
+		                             NM_DEVICE_ERROR_NOT_ALLOWED,
 		                             "Scanning not allowed while already scanning");
 		goto error;
 	}
 
 	last_scan = nm_supplicant_interface_get_last_scan_time (priv->sup_iface);
 	if (last_scan && (nm_utils_get_monotonic_timestamp_s () - last_scan) < 10) {
-		error = g_error_new_literal (NM_WIFI_ERROR,
-		                             NM_WIFI_ERROR_SCAN_NOT_ALLOWED,
+		error = g_error_new_literal (NM_DEVICE_ERROR,
+		                             NM_DEVICE_ERROR_NOT_ALLOWED,
 		                             "Scanning not allowed immediately following previous scan");
 		goto error;
 	}
@@ -1413,7 +1386,6 @@ scanning_allowed (NMDeviceWifi *self)
 	if (connection) {
 		NMSettingWireless *s_wifi;
 		const char *ip4_method = NULL;
-		const GByteArray *bssid;
 
 		/* Don't scan when a shared connection is active; it makes drivers mad */
 		ip4_method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
@@ -1427,8 +1399,7 @@ scanning_allowed (NMDeviceWifi *self)
 		 */
 		s_wifi = nm_connection_get_setting_wireless (connection);
 		g_assert (s_wifi);
-		bssid = nm_setting_wireless_get_bssid (s_wifi);
-		if (bssid && bssid->len == ETH_ALEN)
+		if (nm_setting_wireless_get_bssid (s_wifi))
 			return FALSE;
 	}
 
@@ -1500,20 +1471,25 @@ build_hidden_probe_list (NMDeviceWifi *self)
 	                                                           hidden_filter_func,
 	                                                           NULL);
 	if (connections && connections->data) {
-		ssids = g_ptr_array_sized_new (max_scan_ssids - 1);
-		g_ptr_array_add (ssids, nullssid);  /* Add wildcard SSID */
+		ssids = g_ptr_array_new_full (max_scan_ssids - 1, (GDestroyNotify) g_byte_array_unref);
+		g_ptr_array_add (ssids, g_byte_array_ref (nullssid));  /* Add wildcard SSID */
 	}
 
 	for (iter = connections; iter; iter = g_slist_next (iter)) {
 		NMConnection *connection = iter->data;
 		NMSettingWireless *s_wifi;
-		const GByteArray *ssid;
+		GBytes *ssid;
+		GByteArray *ssid_array;
 
 		s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (connection);
 		g_assert (s_wifi);
 		ssid = nm_setting_wireless_get_ssid (s_wifi);
 		g_assert (ssid);
-		g_ptr_array_add (ssids, (gpointer) ssid);
+		ssid_array = g_byte_array_new ();
+		g_byte_array_append (ssid_array,
+		                     g_bytes_get_data (ssid, NULL),
+		                     g_bytes_get_size (ssid));
+		g_ptr_array_add (ssids, ssid_array);
 	}
 	g_slist_free (connections);
 
@@ -1534,27 +1510,25 @@ request_wireless_scan (gpointer user_data)
 	}
 
 	if (check_scanning_allowed (self)) {
-		nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scanning requested",
-		            nm_device_get_iface (NM_DEVICE (self)));
+		_LOGD (LOGD_WIFI_SCAN, "scanning requested");
 
 		ssids = build_hidden_probe_list (self);
 
 		if (nm_logging_enabled (LOGL_DEBUG, LOGD_WIFI_SCAN)) {
 			if (ssids) {
+				const GByteArray *ssid;
 				guint i;
 				char *foo;
 
 				for (i = 0; i < ssids->len; i++) {
-					foo = nm_utils_ssid_to_utf8 (g_ptr_array_index (ssids, i));
-					nm_log_dbg (LOGD_WIFI_SCAN, "(%s): (%d) probe scanning SSID '%s'",
-					            nm_device_get_iface (NM_DEVICE (self)),
+					ssid = g_ptr_array_index (ssids, i);
+					foo = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
+					_LOGD (LOGD_WIFI_SCAN, "(%d) probe scanning SSID '%s'",
 					            i, foo ? foo : "<hidden>");
 					g_free (foo);
 				}
-			} else {
-				nm_log_dbg (LOGD_WIFI_SCAN, "(%s): no SSIDs to probe scan",
-				            nm_device_get_iface (NM_DEVICE (self)));
-			}
+			} else
+				_LOGD (LOGD_WIFI_SCAN, "no SSIDs to probe scan");
 		}
 
 		if (nm_supplicant_interface_request_scan (priv->sup_iface, ssids)) {
@@ -1564,14 +1538,10 @@ request_wireless_scan (gpointer user_data)
 			nm_device_add_pending_action (NM_DEVICE (self), "scan", TRUE);
 		}
 
-		if (ssids) {
-			/* Elements owned by the connections, so we don't free them here */
-			g_ptr_array_free (ssids, TRUE);
-		}
-	} else {
-		nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scan requested but not allowed at this time",
-		            nm_device_get_iface (NM_DEVICE (self)));
-	}
+		if (ssids)
+			g_ptr_array_unref (ssids);
+	} else
+		_LOGD (LOGD_WIFI_SCAN, "scan requested but not allowed at this time");
 
 	priv->pending_scan_id = 0;
 	schedule_scan (self, backoff);
@@ -1622,11 +1592,8 @@ schedule_scan (NMDeviceWifi *self, gboolean backoff)
 			priv->scan_interval = 5;
 		}
 
-		nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scheduled scan in %d seconds (interval now %d seconds)",
-		            nm_device_get_iface (NM_DEVICE (self)),
-		            next_scan,
-		            priv->scan_interval);
-
+		_LOGD (LOGD_WIFI_SCAN, "scheduled scan in %d seconds (interval now %d seconds)",
+		       next_scan, priv->scan_interval);
 	}
 }
 
@@ -1649,9 +1616,7 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface,
 {
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 
-	nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scan %s",
-	            nm_device_get_iface (NM_DEVICE (self)),
-	            success ? "successful" : "failed");
+	_LOGD (LOGD_WIFI_SCAN, "scan %s", success ? "successful" : "failed");
 
 	schedule_scan (self, success);
 
@@ -1674,7 +1639,7 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface,
 static void
 try_fill_ssid_for_hidden_ap (NMAccessPoint *ap)
 {
-	const struct ether_addr *bssid;
+	const char *bssid;
 	const GSList *connections, *iter;
 
 	g_return_if_fail (nm_ap_get_ssid (ap) == NULL);
@@ -1692,16 +1657,17 @@ try_fill_ssid_for_hidden_ap (NMAccessPoint *ap)
 		s_wifi = nm_connection_get_setting_wireless (connection);
 		if (s_wifi) {
 			if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) {
-				nm_ap_set_ssid (ap, nm_setting_wireless_get_ssid (s_wifi));
+				GBytes *ssid = nm_setting_wireless_get_ssid (s_wifi);
+
+				nm_ap_set_ssid (ap,
+				                g_bytes_get_data (ssid, NULL),
+				                g_bytes_get_size (ssid));
 				break;
 			}
 		}
 	}
 }
 
-#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
-#define MAC_ARG(x) ((guint8*)(x))[0],((guint8*)(x))[1],((guint8*)(x))[2],((guint8*)(x))[3],((guint8*)(x))[4],((guint8*)(x))[5]
-
 /*
  * merge_scanned_ap
  *
@@ -1721,7 +1687,7 @@ merge_scanned_ap (NMDeviceWifi *self,
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 	NMAccessPoint *found_ap = NULL;
 	const GByteArray *ssid;
-	const struct ether_addr *bssid;
+	const char *bssid;
 	gboolean strict_match = TRUE;
 
 	/* Let the manager try to fill in the SSID from seen-bssids lists */
@@ -1734,16 +1700,13 @@ merge_scanned_ap (NMDeviceWifi *self,
 		ssid = nm_ap_get_ssid (merge_ap);
 		if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) {
 			/* Yay, matched it, no longer treat as hidden */
-			nm_log_dbg (LOGD_WIFI_SCAN, "(%s): matched hidden AP " MAC_FMT " => '%s'",
-			            nm_device_get_iface (NM_DEVICE (self)),
-			            MAC_ARG (bssid->ether_addr_octet),
-			            nm_utils_escape_ssid (ssid->data, ssid->len));
+			_LOGD (LOGD_WIFI_SCAN, "matched hidden AP %s => '%s'",
+			       str_if_set (bssid, "(none)"), nm_utils_escape_ssid (ssid->data, ssid->len));
 			nm_ap_set_broadcast (merge_ap, FALSE);
 		} else {
 			/* Didn't have an entry for this AP in the database */
-			nm_log_dbg (LOGD_WIFI_SCAN, "(%s): failed to match hidden AP " MAC_FMT,
-			            nm_device_get_iface (NM_DEVICE (self)),
-			            MAC_ARG (bssid->ether_addr_octet));
+			_LOGD (LOGD_WIFI_SCAN, "failed to match hidden AP %s",
+			       str_if_set (bssid, "(none)"));
 		}
 	}
 
@@ -1760,10 +1723,9 @@ merge_scanned_ap (NMDeviceWifi *self,
 	if (!found_ap)
 		found_ap = nm_ap_match_in_list (merge_ap, priv->ap_list, strict_match);
 	if (found_ap) {
-		nm_log_dbg (LOGD_WIFI_SCAN, "(%s): merging AP '%s' " MAC_FMT " (%p) with existing (%p)",
-		            nm_device_get_iface (NM_DEVICE (self)),
+		_LOGD (LOGD_WIFI_SCAN, "merging AP '%s' %s (%p) with existing (%p)",
 		            ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
-		            MAC_ARG (bssid->ether_addr_octet),
+		            str_if_set (bssid, "(none)"),
 		            merge_ap,
 		            found_ap);
 
@@ -1783,11 +1745,9 @@ merge_scanned_ap (NMDeviceWifi *self,
 		nm_ap_set_fake (found_ap, FALSE);
 	} else {
 		/* New entry in the list */
-		nm_log_dbg (LOGD_WIFI_SCAN, "(%s): adding new AP '%s' " MAC_FMT " (%p)",
-		            nm_device_get_iface (NM_DEVICE (self)),
-		            ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
-		            MAC_ARG (bssid->ether_addr_octet),
-		            merge_ap);
+		_LOGD (LOGD_WIFI_SCAN, "adding new AP '%s' %s (%p)",
+		       ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
+		       str_if_set (bssid, "(none)"), merge_ap);
 
 		g_object_ref (merge_ap);
 		priv->ap_list = g_slist_prepend (priv->ap_list, merge_ap);
@@ -1809,8 +1769,7 @@ cull_scan_list (NMDeviceWifi *self)
 
 	priv->scanlist_cull_id = 0;
 
-	nm_log_dbg (LOGD_WIFI_SCAN, "(%s): checking scan list for outdated APs",
-	            nm_device_get_iface (NM_DEVICE (self)));
+	_LOGD (LOGD_WIFI_SCAN, "checking scan list for outdated APs");
 
 	/* Walk the access point list and remove any access points older than
 	 * three times the inactive scan interval.
@@ -1844,28 +1803,23 @@ cull_scan_list (NMDeviceWifi *self)
 	/* Remove outdated APs */
 	for (elt = outdated_list; elt; elt = g_slist_next (elt)) {
 		NMAccessPoint *outdated_ap = NM_AP (elt->data);
-		const struct ether_addr *bssid;
 		const GByteArray *ssid;
 
-		bssid = nm_ap_get_address (outdated_ap);
 		ssid = nm_ap_get_ssid (outdated_ap);
-		nm_log_dbg (LOGD_WIFI_SCAN,
-		            "   removing %02x:%02x:%02x:%02x:%02x:%02x (%s%s%s)",
-		            bssid->ether_addr_octet[0], bssid->ether_addr_octet[1],
-		            bssid->ether_addr_octet[2], bssid->ether_addr_octet[3],
-		            bssid->ether_addr_octet[4], bssid->ether_addr_octet[5],
-		            ssid ? "'" : "",
-		            ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
-		            ssid ? "'" : "");
+		_LOGD (LOGD_WIFI_SCAN,
+		       "   removing %s (%s%s%s)",
+		       str_if_set (nm_ap_get_address (outdated_ap), "(none)"),
+		       ssid ? "'" : "",
+		       ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
+		       ssid ? "'" : "");
 
 		remove_access_point (self, outdated_ap);
 		removed++;
 	}
 	g_slist_free (outdated_list);
 
-	nm_log_dbg (LOGD_WIFI_SCAN, "(%s): removed %d APs (of %d)",
-	            nm_device_get_iface (NM_DEVICE (self)),
-	            removed, total);
+	_LOGD (LOGD_WIFI_SCAN, "removed %d APs (of %d)",
+	       removed, total);
 
 	ap_list_dump (self);
 
@@ -1913,10 +1867,8 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
 		/* Add the AP to the device's AP list */
 		merge_scanned_ap (self, ap);
 		g_object_unref (ap);
-	} else {
-		nm_log_warn (LOGD_WIFI_SCAN, "(%s): invalid AP properties received",
-		             nm_device_get_iface (NM_DEVICE (self)));
-	}
+	} else
+		_LOGW (LOGD_WIFI_SCAN, "invalid AP properties received");
 
 	/* Remove outdated access points */
 	schedule_scanlist_cull (self);
@@ -1998,19 +1950,20 @@ wifi_secrets_cb (NMActRequest *req,
                  GError *error,
                  gpointer user_data)
 {
-	NMDevice *dev = NM_DEVICE (user_data);
+	NMDevice *device = NM_DEVICE (user_data);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 
-	g_return_if_fail (req == nm_device_get_act_request (dev));
-	g_return_if_fail (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH);
+	g_return_if_fail (req == nm_device_get_act_request (device));
+	g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH);
 	g_return_if_fail (nm_act_request_get_connection (req) == connection);
 
 	if (error) {
-		nm_log_warn (LOGD_WIFI, "%s", error->message);
-		nm_device_state_changed (dev,
+		_LOGW (LOGD_WIFI, "%s", error->message);
+		nm_device_state_changed (device,
 		                         NM_DEVICE_STATE_FAILED,
 		                         NM_DEVICE_STATE_REASON_NO_SECRETS);
 	} else
-		nm_device_activate_schedule_stage1_device_prepare (dev);
+		nm_device_activate_schedule_stage1_device_prepare (device);
 }
 
 /*
@@ -2022,11 +1975,11 @@ wifi_secrets_cb (NMActRequest *req,
 static gboolean
 link_timeout_cb (gpointer user_data)
 {
-	NMDevice *dev = NM_DEVICE (user_data);
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDevice *device = NM_DEVICE (user_data);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 
-	nm_log_warn (LOGD_WIFI, "(%s): link timed out.", nm_device_get_iface (dev));
+	_LOGW (LOGD_WIFI, "link timed out.");
 
 	priv->link_timeout_id = 0;
 
@@ -2034,7 +1987,7 @@ link_timeout_cb (gpointer user_data)
 	 * to reassociate within the timeout period, so the connection must
 	 * fail.
 	 */
-	if (nm_device_get_state (dev) != NM_DEVICE_STATE_ACTIVATED)
+	if (nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED)
 		return FALSE;
 
 	/* If the access point failed, and wasn't found by the supplicant when it
@@ -2045,7 +1998,7 @@ link_timeout_cb (gpointer user_data)
 	if (priv->ssid_found == FALSE && priv->current_ap)
 		set_current_ap (self, NULL, TRUE, TRUE);
 
-	nm_device_state_changed (dev,
+	nm_device_state_changed (device,
 	                         NM_DEVICE_STATE_FAILED,
 	                         priv->ssid_found ? NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT :
 	                                            NM_DEVICE_STATE_REASON_SSID_NOT_FOUND);
@@ -2080,10 +2033,11 @@ need_new_8021x_secrets (NMDeviceWifi *self,
 
 	s_8021x = nm_connection_get_setting_802_1x (connection);
 	if (s_8021x) {
-		nm_setting_get_secret_flags (NM_SETTING (s_8021x),
-		                             NM_SETTING_802_1X_PASSWORD,
-		                             &secret_flags,
-		                             NULL);
+		if (!nm_setting_get_secret_flags (NM_SETTING (s_8021x),
+		                                  NM_SETTING_802_1X_PASSWORD,
+		                                  &secret_flags,
+		                                  NULL))
+			g_assert_not_reached ();
 		if (secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED)
 			*setting_name = NM_SETTING_802_1X_SETTING_NAME;
 		return *setting_name ? TRUE : FALSE;
@@ -2091,10 +2045,11 @@ need_new_8021x_secrets (NMDeviceWifi *self,
 
 	s_wsec = nm_connection_get_setting_wireless_security (connection);
 	if (s_wsec) {
-		nm_setting_get_secret_flags (NM_SETTING (s_wsec),
-		                             NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
-		                             &secret_flags,
-		                             NULL);
+		if (!nm_setting_get_secret_flags (NM_SETTING (s_wsec),
+		                                  NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
+		                                  &secret_flags,
+		                                  NULL))
+			g_assert_not_reached ();
 		if (secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED)
 			*setting_name = NM_SETTING_WIRELESS_SECURITY_SETTING_NAME;
 		return *setting_name ? TRUE : FALSE;
@@ -2160,16 +2115,15 @@ handle_8021x_or_psk_auth_fail (NMDeviceWifi *self,
 
 		nm_connection_clear_secrets (connection);
 
-		nm_log_info (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): disconnected during association,"
-		             " asking for new key.", nm_device_get_iface (device));
+		_LOGI (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) disconnected during association, asking for new key");
 
 		cleanup_association_attempt (self, TRUE);
 		nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT);
 		nm_act_request_get_secrets (req,
 		                            setting_name,
-		                            NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION
-		                              | NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW,
+		                            NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION
+		                              | NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW,
 		                            NULL,
 		                            wifi_secrets_cb,
 		                            self);
@@ -2195,11 +2149,10 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
 	if (new_state == old_state)
 		return;
 
-	nm_log_info (LOGD_DEVICE | LOGD_WIFI,
-	             "(%s): supplicant interface state: %s -> %s",
-	             nm_device_get_iface (device),
-	             nm_supplicant_interface_state_to_string (old_state),
-	             nm_supplicant_interface_state_to_string (new_state));
+	_LOGI (LOGD_DEVICE | LOGD_WIFI,
+	       "supplicant interface state: %s -> %s",
+	       nm_supplicant_interface_state_to_string (old_state),
+	       nm_supplicant_interface_state_to_string (new_state));
 
 	devstate = nm_device_get_state (device);
 	scanning = nm_supplicant_interface_get_scanning (iface);
@@ -2222,9 +2175,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
 			                         NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE);
 		}
 
-		nm_log_dbg (LOGD_WIFI_SCAN,
-		            "(%s): supplicant ready, requesting initial scan",
-		            nm_device_get_iface (device));
+		_LOGD (LOGD_WIFI_SCAN, "supplicant ready, requesting initial scan");
 
 		/* Request a scan to get latest results */
 		cancel_pending_scan (self);
@@ -2243,7 +2194,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
 		if (devstate == NM_DEVICE_STATE_CONFIG) {
 			NMConnection *connection;
 			NMSettingWireless *s_wifi;
-			const GByteArray *ssid;
+			GBytes *ssid;
 
 			connection = nm_device_get_connection (NM_DEVICE (self));
 			g_return_if_fail (connection);
@@ -2254,13 +2205,12 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
 			ssid = nm_setting_wireless_get_ssid (s_wifi);
 			g_return_if_fail (ssid);
 
-			nm_log_info (LOGD_DEVICE | LOGD_WIFI,
-			             "Activation (%s/wireless) Stage 2 of 5 (Device Configure) "
-			             "successful.  %s '%s'.",
-			             nm_device_get_iface (device),
-			             priv->mode == NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot" :
-			                 "Connected to wireless network",
-			             ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
+			_LOGI (LOGD_DEVICE | LOGD_WIFI,
+			       "Activation: (wifi) Stage 2 of 5 (Device Configure) successful.  %s '%s'.",
+			       priv->mode == NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot" :
+			       "Connected to wireless network",
+			       ssid ? nm_utils_escape_ssid (g_bytes_get_data (ssid, NULL),
+			                                    g_bytes_get_size (ssid)) : "(none)");
 			nm_device_activate_schedule_stage3_ip_config_start (device);
 		} else if (devstate == NM_DEVICE_STATE_ACTIVATED)
 			periodic_update (self, NULL);
@@ -2326,9 +2276,9 @@ supplicant_iface_connection_error_cb (NMSupplicantInterface *iface,
 	NMDevice *device = NM_DEVICE (self);
 
 	if (nm_device_is_activating (device)) {
-		nm_log_warn (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): supplicant association failed: %s - %s",
-		             nm_device_get_iface (device), name, message);
+		_LOGW (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) supplicant association failed: %s - %s",
+		       name, message);
 
 		cleanup_association_attempt (self, TRUE);
 		nm_device_queue_state (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
@@ -2356,9 +2306,7 @@ supplicant_iface_notify_scanning_cb (NMSupplicantInterface *iface,
 	gboolean scanning;
 
 	scanning = nm_supplicant_interface_get_scanning (iface);
-	nm_log_dbg (LOGD_WIFI_SCAN, "(%s): now %s",
-	            nm_device_get_iface (NM_DEVICE (self)),
-	            scanning ? "scanning" : "idle");
+	_LOGD (LOGD_WIFI_SCAN, "now %s", scanning ? "scanning" : "idle");
 
 	g_object_notify (G_OBJECT (self), "scanning");
 
@@ -2397,16 +2345,16 @@ handle_auth_or_fail (NMDeviceWifi *self,
 	nm_connection_clear_secrets (connection);
 	setting_name = nm_connection_need_secrets (connection, NULL);
 	if (setting_name) {
-		NMSettingsGetSecretsFlags flags = NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION;
+		NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
 
 		if (new_secrets)
-			flags |= NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW;
+			flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
 		nm_act_request_get_secrets (req, setting_name, flags, NULL, wifi_secrets_cb, self);
 
 		g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
 		ret = NM_ACT_STAGE_RETURN_POSTPONE;
 	} else
-		nm_log_warn (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets.");
+		_LOGW (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets.");
 
 	return ret;
 }
@@ -2420,7 +2368,7 @@ handle_auth_or_fail (NMDeviceWifi *self,
 static gboolean
 supplicant_connection_timeout_cb (gpointer user_data)
 {
-	NMDevice *dev = NM_DEVICE (user_data);
+	NMDevice *device = NM_DEVICE (user_data);
 	NMDeviceWifi *self = NM_DEVICE_WIFI (user_data);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 	NMActRequest *req;
@@ -2428,7 +2376,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
 
 	cleanup_association_attempt (self, TRUE);
 
-	if (!nm_device_is_activating (dev))
+	if (!nm_device_is_activating (device))
 		return FALSE;
 
 	/* Timed out waiting for a successful connection to the AP; if the AP's
@@ -2437,7 +2385,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
 	 * information (passwords, pin codes, etc) are wrong.
 	 */
 
-	req = nm_device_get_act_request (dev);
+	req = nm_device_get_act_request (device);
 	g_assert (req);
 
 	connection = nm_act_request_get_connection (req);
@@ -2449,12 +2397,10 @@ supplicant_connection_timeout_cb (gpointer user_data)
 		 * (if any), so supplicant timeouts here are almost certainly the wifi
 		 * driver being really stupid.
 		 */
-		nm_log_warn (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): %s network creation took "
-		             "too long, failing activation.",
-		             nm_device_get_iface (dev),
-		             priv->mode == NM_802_11_MODE_ADHOC ? "Ad-Hoc" : "Hotspot");
-		nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED,
+		_LOGW (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) %s network creation took too long, failing activation",
+		       priv->mode == NM_802_11_MODE_ADHOC ? "Ad-Hoc" : "Hotspot");
+		nm_device_state_changed (device, NM_DEVICE_STATE_FAILED,
 		                         NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT);
 		return FALSE;
 	}
@@ -2468,9 +2414,8 @@ supplicant_connection_timeout_cb (gpointer user_data)
 		/* Connection failed; either driver problems, the encryption key is
 		 * wrong, or the passwords or certificates were wrong.
 		 */
-		nm_log_warn (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): association took too long.",
-		             nm_device_get_iface (dev));
+		_LOGW (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) association took too long");
 
 		/* Ask for new secrets only if we've never activated this connection
 		 * before.  If we've connected before, don't bother the user with
@@ -2480,20 +2425,16 @@ supplicant_connection_timeout_cb (gpointer user_data)
 		if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), &timestamp))
 			new_secrets = !timestamp;
 
-		if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE) {
-			nm_log_warn (LOGD_DEVICE | LOGD_WIFI,
-			             "Activation (%s/wireless): asking for new secrets",
-			             nm_device_get_iface (dev));
-		} else {
-			nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED,
+		if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE)
+			_LOGW (LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) asking for new secrets");
+		else {
+			nm_device_state_changed (device, NM_DEVICE_STATE_FAILED,
 			                         NM_DEVICE_STATE_REASON_NO_SECRETS);
 		}
 	} else {
-		nm_log_warn (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): association took too long, "
-		             "failing activation.",
-		             nm_device_get_iface (dev));
-		nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED,
+		_LOGW (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) association took too long, failing activation");
+		nm_device_state_changed (device, NM_DEVICE_STATE_FAILED,
 		                         priv->ssid_found ? NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT :
 		                                            NM_DEVICE_STATE_REASON_SSID_NOT_FOUND);
 	}
@@ -2523,13 +2464,13 @@ build_supplicant_config (NMDeviceWifi *self,
 	/* Warn if AP mode may not be supported */
 	if (   g_strcmp0 (nm_setting_wireless_get_mode (s_wireless), NM_SETTING_WIRELESS_MODE_AP) == 0
 	    && nm_supplicant_interface_get_ap_support (priv->sup_iface) == AP_SUPPORT_UNKNOWN) {
-		nm_log_warn (LOGD_WIFI, "Supplicant may not support AP mode; connection may time out.");
+		_LOGW (LOGD_WIFI, "Supplicant may not support AP mode; connection may time out.");
 	}
 
 	if (!nm_supplicant_config_add_setting_wireless (config,
 	                                                s_wireless,
 	                                                fixed_freq)) {
-		nm_log_err (LOGD_WIFI, "Couldn't add 802-11-wireless setting to supplicant config.");
+		_LOGE (LOGD_WIFI, "Couldn't add 802-11-wireless setting to supplicant config.");
 		goto error;
 	}
 
@@ -2544,13 +2485,12 @@ build_supplicant_config (NMDeviceWifi *self,
 		                                                         s_wireless_sec,
 		                                                         s_8021x,
 		                                                         con_uuid)) {
-			nm_log_err (LOGD_WIFI, "Couldn't add 802-11-wireless-security setting to "
-			            "supplicant config.");
+			_LOGE (LOGD_WIFI, "Couldn't add 802-11-wireless-security setting to supplicant config.");
 			goto error;
 		}
 	} else {
 		if (!nm_supplicant_config_add_no_security (config)) {
-			nm_log_err (LOGD_WIFI, "Couldn't add unsecured option to supplicant config.");
+			_LOGE (LOGD_WIFI, "Couldn't add unsecured option to supplicant config.");
 			goto error;
 		}
 	}
@@ -2565,23 +2505,25 @@ error:
 /****************************************************************************/
 
 static void
-update_permanent_hw_address (NMDevice *dev)
+update_permanent_hw_address (NMDevice *device)
 {
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 	struct ifreq req;
 	struct ethtool_perm_addr *epaddr = NULL;
-	int fd, ret;
+	int fd, ret, errsv;
+
+	g_return_if_fail (priv->perm_hw_addr == NULL);
 
 	fd = socket (PF_INET, SOCK_DGRAM, 0);
 	if (fd < 0) {
-		nm_log_err (LOGD_HW, "could not open control socket.");
+		_LOGE (LOGD_HW, "could not open control socket.");
 		return;
 	}
 
 	/* Get permanent MAC address */
 	memset (&req, 0, sizeof (struct ifreq));
-	strncpy (req.ifr_name, nm_device_get_iface (dev), IFNAMSIZ);
+	strncpy (req.ifr_name, nm_device_get_iface (device), IFNAMSIZ);
 
 	epaddr = g_malloc0 (sizeof (struct ethtool_perm_addr) + ETH_ALEN);
 	epaddr->cmd = ETHTOOL_GPERMADDR;
@@ -2590,56 +2532,50 @@ update_permanent_hw_address (NMDevice *dev)
 
 	errno = 0;
 	ret = ioctl (fd, SIOCETHTOOL, &req);
-	if ((ret < 0) || !nm_ethernet_address_is_valid ((struct ether_addr *) epaddr->data)) {
-		nm_log_dbg (LOGD_HW | LOGD_ETHER, "(%s): unable to read permanent MAC address (error %d)",
-		            nm_device_get_iface (dev), errno);
+	errsv = errno;
+	if ((ret < 0) || !nm_ethernet_address_is_valid (epaddr->data, ETH_ALEN)) {
+		_LOGD (LOGD_HW | LOGD_ETHER, "unable to read permanent MAC address (error %d)",
+		       errsv);
 		/* Fall back to current address */
-		memcpy (epaddr->data, nm_device_get_hw_address (dev, NULL), ETH_ALEN);
+		nm_utils_hwaddr_aton (nm_device_get_hw_address (device), epaddr->data, ETH_ALEN);
 	}
 
-	if (memcmp (&priv->perm_hw_addr, epaddr->data, ETH_ALEN)) {
-		memcpy (&priv->perm_hw_addr, epaddr->data, ETH_ALEN);
-		g_object_notify (G_OBJECT (dev), NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS);
-	}
+	priv->perm_hw_addr = nm_utils_hwaddr_ntoa (epaddr->data, ETH_ALEN);
 
 	g_free (epaddr);
 	close (fd);
 }
 
 static void
-update_initial_hw_address (NMDevice *dev)
+update_initial_hw_address (NMDevice *device)
 {
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
-	char *mac_str;
 
 	/* This sets initial MAC address from current MAC address. It should only
 	 * be called from NMDevice constructor() to really get the initial address.
 	 */
-	memcpy (priv->initial_hw_addr, nm_device_get_hw_address (dev, NULL), ETH_ALEN);
+	priv->initial_hw_addr = g_strdup (nm_device_get_hw_address (device));
 
-	mac_str = nm_utils_hwaddr_ntoa (priv->initial_hw_addr, ARPHRD_ETHER);
-	nm_log_dbg (LOGD_DEVICE | LOGD_ETHER, "(%s): read initial MAC address %s",
-	            nm_device_get_iface (dev), mac_str);
-	g_free (mac_str);
+	_LOGD (LOGD_DEVICE | LOGD_ETHER, "read initial MAC address %s", priv->initial_hw_addr);
 }
 
 static NMActStageReturn
-act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
+act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
 {
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 	NMActStageReturn ret;
 	NMAccessPoint *ap = NULL;
 	NMActRequest *req;
 	NMConnection *connection;
 	NMSettingWireless *s_wireless;
-	const GByteArray *cloned_mac;
+	const char *cloned_mac;
 	GSList *iter;
 	const char *mode;
 	const char *ap_path;
 
-	ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage1_prepare (dev, reason);
+	ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage1_prepare (device, reason);
 	if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
 		return ret;
 
@@ -2670,15 +2606,15 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
 	 * 2.6.30 or so; until that's fixed, disable WPA-protected Ad-Hoc networks.
 	 */
 	if (is_adhoc_wpa (connection)) {
-		nm_log_warn (LOGD_WIFI, "Ad-Hoc WPA disabled due to kernel bugs");
+		_LOGW (LOGD_WIFI, "Ad-Hoc WPA disabled due to kernel bugs");
 		*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED;
 		return NM_ACT_STAGE_RETURN_FAILURE;
 	}
 
 	/* Set spoof MAC to the interface */
 	cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless);
-	if (cloned_mac && (cloned_mac->len == ETH_ALEN))
-		nm_device_set_hw_addr (dev, (const guint8 *) cloned_mac->data, "set", LOGD_WIFI);
+	if (cloned_mac)
+		nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_WIFI);
 
 	/* AP mode never uses a specific object or existing scanned AP */
 	if (priv->mode != NM_802_11_MODE_AP) {
@@ -2716,7 +2652,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
 	if (nm_ap_get_mode (ap) == NM_802_11_MODE_INFRA)
 		nm_ap_set_broadcast (ap, FALSE);
 	else if (nm_ap_is_hotspot (ap))
-		nm_ap_set_address (ap, (const struct ether_addr *) nm_device_get_hw_address (dev, NULL));
+		nm_ap_set_address (ap, nm_device_get_hw_address (device));
 
 	priv->ap_list = g_slist_prepend (priv->ap_list, ap);
 	nm_ap_export_to_dbus (ap);
@@ -2759,12 +2695,11 @@ ensure_hotspot_frequency (NMDeviceWifi *self,
 }
 
 static NMActStageReturn
-act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
+act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
 {
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
 	NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
-	const char *iface = nm_device_get_iface (dev);
 	NMSupplicantConfig *config = NULL;
 	NMActRequest *req;
 	NMAccessPoint *ap;
@@ -2776,7 +2711,7 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
 
 	remove_supplicant_timeouts (self);
 
-	req = nm_device_get_act_request (dev);
+	req = nm_device_get_act_request (device);
 	g_assert (req);
 
 	ap = priv->current_ap;
@@ -2794,10 +2729,9 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
 	/* If we need secrets, get them */
 	setting_name = nm_connection_need_secrets (connection, NULL);
 	if (setting_name) {
-		nm_log_info (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): access point '%s' has security,"
-		             " but secrets are required.",
-		             iface, nm_connection_get_id (connection));
+		_LOGI (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) access point '%s' has security, but secrets are required.",
+		       nm_connection_get_id (connection));
 
 		ret = handle_auth_or_fail (self, req, FALSE);
 		if (ret == NM_ACT_STAGE_RETURN_FAILURE)
@@ -2807,15 +2741,13 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
 
 	/* have secrets, or no secrets required */
 	if (nm_connection_get_setting_wireless_security (connection)) {
-		nm_log_info (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): connection '%s' has security"
-		             ", and secrets exist.  No new secrets needed.",
-		             iface, nm_connection_get_id (connection));
+		_LOGI (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) connection '%s' has security, and secrets exist.  No new secrets needed.",
+		       nm_connection_get_id (connection));
 	} else {
-		nm_log_info (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): connection '%s' requires no "
-		             "security.  No secrets needed.",
-		             iface, nm_connection_get_id (connection));
+		_LOGI (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) connection '%s' requires no security.  No secrets needed.",
+		       nm_connection_get_id (connection));
 	}
 
 	priv->ssid_found = FALSE;
@@ -2830,9 +2762,8 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
 	/* Build up the supplicant configuration */
 	config = build_supplicant_config (self, connection, nm_ap_get_freq (ap));
 	if (config == NULL) {
-		nm_log_err (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): couldn't build wireless configuration.",
-		             iface);
+		_LOGE (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) couldn't build wireless configuration.");
 		*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED;
 		goto out;
 	}
@@ -2844,9 +2775,8 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
 	                  self);
 
 	if (!nm_supplicant_interface_set_config (priv->sup_iface, config)) {
-		nm_log_err (LOGD_DEVICE | LOGD_WIFI,
-		            "Activation (%s/wireless): couldn't send wireless "
-		            "configuration to the supplicant.", iface);
+		_LOGE (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) couldn't send wireless configuration to the supplicant.");
 		*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED;
 		goto out;
 	}
@@ -2879,14 +2809,14 @@ act_stage3_ip4_config_start (NMDevice *device,
                              NMDeviceStateReason *reason)
 {
 	NMConnection *connection;
-	NMSettingIP4Config *s_ip4;
+	NMSettingIPConfig *s_ip4;
 	const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
 
 	connection = nm_device_get_connection (device);
 	g_assert (connection);
 	s_ip4 = nm_connection_get_setting_ip4_config (connection);
 	if (s_ip4)
-		method = nm_setting_ip4_config_get_method (s_ip4);
+		method = nm_setting_ip_config_get_method (s_ip4);
 
 	/* Indicate that a critical protocol is about to start */
 	if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0)
@@ -2901,14 +2831,14 @@ act_stage3_ip6_config_start (NMDevice *device,
                              NMDeviceStateReason *reason)
 {
 	NMConnection *connection;
-	NMSettingIP6Config *s_ip6;
+	NMSettingIPConfig *s_ip6;
 	const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
 
 	connection = nm_device_get_connection (device);
 	g_assert (connection);
 	s_ip6 = nm_connection_get_setting_ip6_config (connection);
 	if (s_ip6)
-		method = nm_setting_ip6_config_get_method (s_ip6);
+		method = nm_setting_ip_config_get_method (s_ip6);
 
 	/* Indicate that a critical protocol is about to start */
 	if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 ||
@@ -2933,7 +2863,7 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
 	/* MTU override */
 	mtu = nm_setting_wireless_get_mtu (s_wifi);
 	if (mtu)
-		nm_ip4_config_set_mtu (config, mtu);
+		nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
 }
 
 static gboolean
@@ -2984,17 +2914,14 @@ handle_ip_config_timeout (NMDeviceWifi *self,
 	 */
 	if (!may_fail && is_static_wep (connection)) {
 		/* Activation failed, we must have bad encryption key */
-		nm_log_warn (LOGD_DEVICE | LOGD_WIFI,
-		             "Activation (%s/wireless): could not get IP configuration for "
-		             "connection '%s'.",
-		             nm_device_get_iface (NM_DEVICE (self)),
-		             nm_connection_get_id (connection));
+		_LOGW (LOGD_DEVICE | LOGD_WIFI,
+		       "Activation: (wifi) could not get IP configuration for connection '%s'.",
+		       nm_connection_get_id (connection));
 
 		ret = handle_auth_or_fail (self, NULL, TRUE);
 		if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
-			nm_log_info (LOGD_DEVICE | LOGD_WIFI,
-			             "Activation (%s/wireless): asking for new secrets",
-			             nm_device_get_iface (NM_DEVICE (self)));
+			_LOGI (LOGD_DEVICE | LOGD_WIFI,
+			       "Activation: (wifi) asking for new secrets");
 		} else {
 			*reason = NM_DEVICE_STATE_REASON_NO_SECRETS;
 		}
@@ -3008,60 +2935,60 @@ handle_ip_config_timeout (NMDeviceWifi *self,
 
 
 static NMActStageReturn
-act_stage4_ip4_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
+act_stage4_ip4_config_timeout (NMDevice *device, NMDeviceStateReason *reason)
 {
 	NMConnection *connection;
-	NMSettingIP4Config *s_ip4;
+	NMSettingIPConfig *s_ip4;
 	gboolean may_fail = FALSE, chain_up = FALSE;
 	NMActStageReturn ret;
 
-	connection = nm_device_get_connection (dev);
+	connection = nm_device_get_connection (device);
 	g_assert (connection);
 
 	s_ip4 = nm_connection_get_setting_ip4_config (connection);
-	may_fail = nm_setting_ip4_config_get_may_fail (s_ip4);
+	may_fail = nm_setting_ip_config_get_may_fail (s_ip4);
 
-	ret = handle_ip_config_timeout (NM_DEVICE_WIFI (dev), connection, may_fail, &chain_up, reason);
+	ret = handle_ip_config_timeout (NM_DEVICE_WIFI (device), connection, may_fail, &chain_up, reason);
 	if (chain_up)
-		ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip4_config_timeout (dev, reason);
+		ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip4_config_timeout (device, reason);
 
 	return ret;
 }
 
 static NMActStageReturn
-act_stage4_ip6_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
+act_stage4_ip6_config_timeout (NMDevice *device, NMDeviceStateReason *reason)
 {
 	NMConnection *connection;
-	NMSettingIP6Config *s_ip6;
+	NMSettingIPConfig *s_ip6;
 	gboolean may_fail = FALSE, chain_up = FALSE;
 	NMActStageReturn ret;
 
-	connection = nm_device_get_connection (dev);
+	connection = nm_device_get_connection (device);
 	g_assert (connection);
 
 	s_ip6 = nm_connection_get_setting_ip6_config (connection);
-	may_fail = nm_setting_ip6_config_get_may_fail (s_ip6);
+	may_fail = nm_setting_ip_config_get_may_fail (s_ip6);
 
-	ret = handle_ip_config_timeout (NM_DEVICE_WIFI (dev), connection, may_fail, &chain_up, reason);
+	ret = handle_ip_config_timeout (NM_DEVICE_WIFI (device), connection, may_fail, &chain_up, reason);
 	if (chain_up)
-		ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip6_config_timeout (dev, reason);
+		ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip6_config_timeout (device, reason);
 
 	return ret;
 }
 
 static void
-activation_success_handler (NMDevice *dev)
+activation_success_handler (NMDevice *device)
 {
-	NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
+	NMDeviceWifi *self = NM_DEVICE_WIFI (device);
 	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
-	int ifindex = nm_device_get_ifindex (dev);
+	int ifindex = nm_device_get_ifindex (device);
 	NMAccessPoint *ap;
-	struct ether_addr bssid = { {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} };
+	guint8 bssid[ETH_ALEN] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
 	NMAccessPoint *tmp_ap = NULL;
 	NMActRequest *req;
 	NMConnection *connection;
 
-	req = nm_device_get_act_request (dev);
+	req = nm_device_get_act_request (device);
 	g_assert (req);
 
 	connection = nm_act_request_get_connection (req);
@@ -3087,9 +3014,12 @@ activation_success_handler (NMDevice *dev)
 	 * But if activation was successful, the card will know the BSSID.  Grab
 	 * the BSSID off the card and fill in the BSSID of the activation AP.
 	 */
-	nm_platform_wifi_get_bssid (ifindex, &bssid);
-	if (!nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
-		nm_ap_set_address (ap, &bssid);
+	nm_platform_wifi_get_bssid (ifindex, bssid);
+	if (!nm_ap_get_address (ap)) {
+		char *bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
+		nm_ap_set_address (ap, bssid_str);
+		g_free (bssid_str);
+	}
 	if (!nm_ap_get_freq (ap))
 		nm_ap_set_freq (ap, nm_platform_wifi_get_frequency (ifindex));
 	if (!nm_ap_get_max_bitrate (ap))
@@ -3103,9 +3033,11 @@ activation_success_handler (NMDevice *dev)
 		 * instead.
 		 */
 
-		/* If the better match was a hidden AP, update it's SSID */
-		if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len))
-			nm_ap_set_ssid (tmp_ap, nm_ap_get_ssid (ap));
+		/* If the better match was a hidden AP, update its SSID */
+		if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) {
+			ssid = nm_ap_get_ssid (ap);
+			nm_ap_set_ssid (tmp_ap, ssid->data, ssid->len);
+		}
 
 		nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
 		                                          nm_ap_get_dbus_path (tmp_ap));
@@ -3130,18 +3062,18 @@ done:
 }
 
 static void
-activation_failure_handler (NMDevice *dev)
+activation_failure_handler (NMDevice *device)
 {
 	NMConnection *connection;
 
-	connection = nm_device_get_connection (dev);
+	connection = nm_device_get_connection (device);
 	g_assert (connection);
 
 	/* Clear wireless secrets tries on failure */
 	g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
 
 	/* Clear any critical protocol notification in the wifi stack */
-	nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (dev), FALSE);
+	nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), FALSE);
 }
 
 static void
@@ -3225,15 +3157,12 @@ set_enabled (NMDevice *device, gboolean enabled)
 
 	priv->enabled = enabled;
 
-	nm_log_dbg (LOGD_WIFI, "(%s): device now %s",
-	            nm_device_get_iface (NM_DEVICE (device)),
-	            enabled ? "enabled" : "disabled");
+	_LOGD (LOGD_WIFI, "device now %s", enabled ? "enabled" : "disabled");
 
 	state = nm_device_get_state (NM_DEVICE (self));
 	if (state < NM_DEVICE_STATE_UNAVAILABLE) {
-		nm_log_dbg (LOGD_WIFI, "(%s): %s blocked by UNMANAGED state",
-		            enabled ? "enable" : "disable",
-		            nm_device_get_iface (NM_DEVICE (device)));
+		_LOGD (LOGD_WIFI, "(%s): device blocked by UNMANAGED state",
+		       enabled ? "enable" : "disable");
 		return;
 	}
 
@@ -3241,11 +3170,10 @@ set_enabled (NMDevice *device, gboolean enabled)
 		gboolean no_firmware = FALSE;
 
 		if (state != NM_DEVICE_STATE_UNAVAILABLE)
-			nm_log_warn (LOGD_CORE, "not in expected unavailable state!");
+			_LOGW (LOGD_CORE, "not in expected unavailable state!");
 
 		if (!nm_device_bring_up (NM_DEVICE (self), TRUE, &no_firmware)) {
-			nm_log_dbg (LOGD_WIFI, "(%s): enable blocked by failure to bring device up",
-			            nm_device_get_iface (NM_DEVICE (device)));
+			_LOGD (LOGD_WIFI, "enable blocked by failure to bring device up");
 
 			if (no_firmware)
 				nm_device_set_firmware_missing (NM_DEVICE (device), TRUE);
@@ -3261,8 +3189,7 @@ set_enabled (NMDevice *device, gboolean enabled)
 			supplicant_interface_release (self);
 		supplicant_interface_acquire (self);
 
-		nm_log_dbg (LOGD_WIFI, "(%s): enable waiting on supplicant state",
-		            nm_device_get_iface (NM_DEVICE (device)));
+		_LOGD (LOGD_WIFI, "enable waiting on supplicant state");
 	} else {
 		nm_device_state_changed (NM_DEVICE (self),
 		                         NM_DEVICE_STATE_UNAVAILABLE,
@@ -3321,6 +3248,18 @@ dispose (GObject *object)
 }
 
 static void
+finalize (GObject *object)
+{
+	NMDeviceWifi *self = NM_DEVICE_WIFI (object);
+	NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
+
+	g_free (priv->perm_hw_addr);
+	g_free (priv->initial_hw_addr);
+
+	G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object);
+}
+
+static void
 get_property (GObject *object, guint prop_id,
               GValue *value, GParamSpec *pspec)
 {
@@ -3331,7 +3270,7 @@ get_property (GObject *object, guint prop_id,
 
 	switch (prop_id) {
 	case PROP_PERM_HW_ADDRESS:
-		g_value_take_string (value, nm_utils_hwaddr_ntoa (&priv->perm_hw_addr, ARPHRD_ETHER));
+		g_value_set_string (value, priv->perm_hw_addr);
 		break;
 	case PROP_MODE:
 		g_value_set_uint (value, priv->mode);
@@ -3387,6 +3326,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
 	object_class->get_property = get_property;
 	object_class->set_property = set_property;
 	object_class->dispose = dispose;
+	object_class->finalize = finalize;
 
 	parent_class->bring_up = bring_up;
 	parent_class->update_permanent_hw_address = update_permanent_hw_address;
@@ -3413,57 +3353,56 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
 	klass->scanning_allowed = scanning_allowed;
 
 	/* Properties */
-	g_object_class_install_property (object_class, PROP_PERM_HW_ADDRESS,
-		g_param_spec_string (NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS,
-		                     "Permanent MAC Address",
-		                     "Permanent hardware MAC address",
-		                     NULL,
-		                     G_PARAM_READABLE));
-
-	g_object_class_install_property (object_class, PROP_MODE,
-		g_param_spec_uint (NM_DEVICE_WIFI_MODE,
-		                   "Mode",
-		                   "Mode",
-		                   NM_802_11_MODE_UNKNOWN,
-		                   NM_802_11_MODE_AP,
-		                   NM_802_11_MODE_INFRA,
-		                   G_PARAM_READABLE));
-
-	g_object_class_install_property (object_class, PROP_BITRATE,
-		g_param_spec_uint (NM_DEVICE_WIFI_BITRATE,
-		                   "Bitrate",
-		                   "Bitrate",
-		                   0, G_MAXUINT32, 0,
-		                   G_PARAM_READABLE));
+	g_object_class_install_property
+		(object_class, PROP_PERM_HW_ADDRESS,
+		 g_param_spec_string (NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, "", "",
+		                      NULL,
+		                      G_PARAM_READABLE |
+		                      G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property
+		(object_class, PROP_MODE,
+		 g_param_spec_uint (NM_DEVICE_WIFI_MODE, "", "",
+		                    NM_802_11_MODE_UNKNOWN,
+		                    NM_802_11_MODE_AP,
+		                    NM_802_11_MODE_INFRA,
+		                    G_PARAM_READABLE |
+		                    G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property
+		(object_class, PROP_BITRATE,
+		 g_param_spec_uint (NM_DEVICE_WIFI_BITRATE, "", "",
+		                    0, G_MAXUINT32, 0,
+		                    G_PARAM_READABLE |
+		                    G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_ACCESS_POINTS,
-		 g_param_spec_boxed (NM_DEVICE_WIFI_ACCESS_POINTS,
-		                     "Access points",
-		                     "Access points",
+		 g_param_spec_boxed (NM_DEVICE_WIFI_ACCESS_POINTS, "", "",
 		                     DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
-		                     G_PARAM_READABLE));
-
-	g_object_class_install_property (object_class, PROP_ACTIVE_ACCESS_POINT,
-		g_param_spec_boxed (NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT,
-		                    "Active access point",
-		                    "Currently active access point",
-		                    DBUS_TYPE_G_OBJECT_PATH,
-		                    G_PARAM_READABLE));
-
-	g_object_class_install_property (object_class, PROP_CAPABILITIES,
-		g_param_spec_uint (NM_DEVICE_WIFI_CAPABILITIES,
-		                   "Wireless Capabilities",
-		                   "Wireless Capabilities",
-		                   0, G_MAXUINT32, NM_WIFI_DEVICE_CAP_NONE,
-		                   G_PARAM_READABLE));
-
-	g_object_class_install_property (object_class, PROP_SCANNING,
-		g_param_spec_boolean (NM_DEVICE_WIFI_SCANNING,
-		                   "Scanning",
-		                   "Scanning",
-		                   FALSE,
-		                   G_PARAM_READABLE));
+		                     G_PARAM_READABLE |
+		                     G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property
+		(object_class, PROP_ACTIVE_ACCESS_POINT,
+		 g_param_spec_boxed (NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, "", "",
+		                     DBUS_TYPE_G_OBJECT_PATH,
+		                     G_PARAM_READABLE |
+		                     G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property
+		(object_class, PROP_CAPABILITIES,
+		 g_param_spec_uint (NM_DEVICE_WIFI_CAPABILITIES, "", "",
+		                    0, G_MAXUINT32, NM_WIFI_DEVICE_CAP_NONE,
+		                    G_PARAM_READABLE |
+		                    G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property
+		(object_class, PROP_SCANNING,
+		 g_param_spec_boolean (NM_DEVICE_WIFI_SCANNING, "", "",
+		                       FALSE,
+		                       G_PARAM_READABLE |
+		                       G_PARAM_STATIC_STRINGS));
 
 	/* Signals */
 	signals[ACCESS_POINT_ADDED] =
@@ -3495,8 +3434,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
 	nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
 	                                        G_TYPE_FROM_CLASS (klass),
 	                                        &dbus_glib_nm_device_wifi_object_info);
-
-	dbus_g_error_domain_register (NM_WIFI_ERROR, NULL, NM_TYPE_WIFI_ERROR);
 }
 
 
diff --git a/src/devices/wifi/nm-device-wifi.h b/src/devices/wifi/nm-device-wifi.h
index f0a1beac..bcba91da 100644
--- a/src/devices/wifi/nm-device-wifi.h
+++ b/src/devices/wifi/nm-device-wifi.h
@@ -19,12 +19,10 @@
  * Copyright (C) 2006 - 2008 Novell, Inc.
  */
 
-#ifndef NM_DEVICE_WIFI_H
-#define NM_DEVICE_WIFI_H
+#ifndef __NETWORKMANAGER_DEVICE_WIFI_H__
+#define __NETWORKMANAGER_DEVICE_WIFI_H__
 
 #include <glib-object.h>
-#include <dbus/dbus.h>
-#include <net/ethernet.h>
 
 #include "nm-device.h"
 #include "nm-wifi-ap.h"
@@ -40,16 +38,6 @@ G_BEGIN_DECLS
 #define NM_IS_DEVICE_WIFI_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass),  NM_TYPE_DEVICE_WIFI))
 #define NM_DEVICE_WIFI_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj),  NM_TYPE_DEVICE_WIFI, NMDeviceWifiClass))
 
-typedef enum {
-	NM_WIFI_ERROR_CONNECTION_NOT_WIRELESS = 0, /*< nick=ConnectionNotWireless >*/
-	NM_WIFI_ERROR_CONNECTION_INVALID,          /*< nick=ConnectionInvalid >*/
-	NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE,     /*< nick=ConnectionIncompatible >*/
-	NM_WIFI_ERROR_ACCESS_POINT_NOT_FOUND,      /*< nick=AccessPointNotFound >*/
-	NM_WIFI_ERROR_SCAN_NOT_ALLOWED,            /*< nick=ScanNotAllowed >*/
-	NM_WIFI_ERROR_AP_MODE_UNSUPPORTED,         /*< nick=ApModeUnsupported >*/
-	NM_WIFI_ERROR_ADHOC_MODE_UNSUPPORTED,      /*< nick=AdhocModeUnsupported >*/
-} NMWifiError;
-
 #define NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS "perm-hw-address"
 #define NM_DEVICE_WIFI_MODE                "mode"
 #define NM_DEVICE_WIFI_BITRATE             "bitrate"
diff --git a/src/devices/wifi/nm-wifi-ap-utils.c b/src/devices/wifi/nm-wifi-ap-utils.c
index 9b03cbd4..9ac7052e 100644
--- a/src/devices/wifi/nm-wifi-ap-utils.c
+++ b/src/devices/wifi/nm-wifi-ap-utils.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*-*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,11 +18,15 @@
  * (C) Copyright 2011 Red Hat, Inc.
  */
 
-#include <config.h>
+#include "config.h"
+
 #include <string.h>
 #include <stdlib.h>
 
+#include <glib/gi18n.h>
+
 #include "nm-wifi-ap-utils.h"
+#include "nm-utils.h"
 
 static gboolean
 verify_no_wep (NMSettingWirelessSecurity *s_wsec, const char *tag, GError **error)
@@ -35,9 +39,10 @@ verify_no_wep (NMSettingWirelessSecurity *s_wsec, const char *tag, GError **erro
 	    || nm_setting_wireless_security_get_wep_key_type (s_wsec)) {
 		/* Dynamic WEP cannot have any WEP keys set */
 		g_set_error (error,
-		             NM_SETTING_WIRELESS_SECURITY_ERROR,
-		             NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-		             "%s is incompatible with static WEP keys", tag);
+		             NM_CONNECTION_ERROR,
+		             NM_CONNECTION_ERROR_INVALID_SETTING,
+		             _("%s is incompatible with static WEP keys"), tag);
+		g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
 		return FALSE;
 	}
 
@@ -68,17 +73,21 @@ verify_leap (NMSettingWirelessSecurity *s_wsec,
 			/* LEAP authentication requires at least a LEAP username */
 			if (!leap_username) {
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME,
-				                     "LEAP requires a LEAP username");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_MISSING_PROPERTY,
+				                     _("LEAP authentication requires a LEAP username"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
 				return FALSE;
 			}
 		} else if (leap_username) {
 			/* Leap username requires 'leap' auth */
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "LEAP requires 'leap' authentication");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			                     _("LEAP username requires 'leap' authentication"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
 			return FALSE;
 		}
 	}
@@ -87,9 +96,11 @@ verify_leap (NMSettingWirelessSecurity *s_wsec,
 		if (key_mgmt && strcmp (key_mgmt, "ieee8021x")) {
 			/* LEAP requires ieee8021x key management */
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X,
-			                     "LEAP requires IEEE 802.1x key management");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			                     _("LEAP authentication requires IEEE 802.1x key management"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
 			return FALSE;
 		}
 	}
@@ -105,9 +116,10 @@ verify_leap (NMSettingWirelessSecurity *s_wsec,
 
 		if (adhoc) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "LEAP incompatible with Ad-Hoc mode");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_SETTING,
+			                     _("LEAP authentication is incompatible with Ad-Hoc mode"));
+			g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
 			return FALSE;
 		}
 
@@ -116,9 +128,10 @@ verify_leap (NMSettingWirelessSecurity *s_wsec,
 
 		if (s_8021x) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME,
-			                     "LEAP incompatible with 802.1x setting");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_SETTING,
+			                     _("LEAP authentication is incompatible with 802.1x setting"));
+			g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
 			return FALSE;
 		}
 	}
@@ -137,17 +150,23 @@ verify_no_wpa (NMSettingWirelessSecurity *s_wsec,
 	key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec);
 	if (key_mgmt && !strncmp (key_mgmt, "wpa", 3)) {
 		g_set_error (error,
-		             NM_SETTING_WIRELESS_SECURITY_ERROR,
-		             NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-		             "%s incompatible with any WPA key management", tag);
+		             NM_CONNECTION_ERROR,
+		             NM_CONNECTION_ERROR_INVALID_PROPERTY,
+		             _("a connection using '%s' authentication cannot use WPA key management"),
+		             tag);
+		g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+		                NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
 		return FALSE;
 	}
 
 	if (nm_setting_wireless_security_get_num_protos (s_wsec)) {
 		g_set_error (error,
-		             NM_SETTING_WIRELESS_SECURITY_ERROR,
-		             NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-		             "%s incompatible with any 'proto' setting", tag);
+		             NM_CONNECTION_ERROR,
+		             NM_CONNECTION_ERROR_INVALID_PROPERTY,
+		             _("a connection using '%s' authentication cannot specific WPA protocols"),
+		             tag);
+		g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+		                NM_SETTING_WIRELESS_SECURITY_PROTO);
 		return FALSE;
 	}
 
@@ -158,9 +177,12 @@ verify_no_wpa (NMSettingWirelessSecurity *s_wsec,
 		pw = nm_setting_wireless_security_get_pairwise (s_wsec, i);
 		if (!strcmp (pw, "tkip") || !strcmp (pw, "ccmp")) {
 			g_set_error (error,
-			             NM_SETTING_WIRELESS_SECURITY_ERROR,
-			             NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			             "%s is incompatible with WPA pairwise ciphers", tag);
+			             NM_CONNECTION_ERROR,
+			             NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			             _("a connection using '%s' authentication cannot specific WPA ciphers"),
+			             tag);
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
 			return FALSE;
 		}
 	}
@@ -172,18 +194,24 @@ verify_no_wpa (NMSettingWirelessSecurity *s_wsec,
 		gr = nm_setting_wireless_security_get_group (s_wsec, i);
 		if (strcmp (gr, "wep40") && strcmp (gr, "wep104")) {
 			g_set_error (error,
-			             NM_SETTING_WIRELESS_SECURITY_ERROR,
-			             NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			             "%s is incompatible with WPA group ciphers", tag);
+			             NM_CONNECTION_ERROR,
+			             NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			             _("a connection using '%s' authentication cannot specific WPA ciphers"),
+			             tag);
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_GROUP);
 			return FALSE;
 		}
 	}
 
 	if (nm_setting_wireless_security_get_psk (s_wsec)) {
 		g_set_error (error,
-		             NM_SETTING_WIRELESS_SECURITY_ERROR,
-		             NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-		             "%s is incompatible with a WPA Pre-Shared Key", tag);
+		             NM_CONNECTION_ERROR,
+		             NM_CONNECTION_ERROR_INVALID_PROPERTY,
+		             _("a connection using '%s' authentication cannot specific a WPA password"),
+		             tag);
+		g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+		                NM_SETTING_WIRELESS_SECURITY_PSK);
 		return FALSE;
 	}
 
@@ -209,18 +237,21 @@ verify_dynamic_wep (NMSettingWirelessSecurity *s_wsec,
 			if (!s_8021x) {
 				/* 802.1x key management requires an 802.1x setting */
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "Dynamic WEP requires an 802.1x setting");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_MISSING_SETTING,
+				                     _("Dynamic WEP requires an 802.1x setting"));
+				g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
 				return FALSE;
 			}
 
 			if (auth_alg && strcmp (auth_alg, "open")) {
 				/* 802.1x key management must use "open" authentication */
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "Dynamic WEP requires 'open' authentication");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("Dynamic WEP requires 'open' authentication"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
 				return FALSE;
 			}
 
@@ -231,9 +262,11 @@ verify_dynamic_wep (NMSettingWirelessSecurity *s_wsec,
 			if (s_8021x) {
 				/* 802.1x setting requires 802.1x key management */
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "Dynamic WEP requires 'ieee8021x' key management");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("Dynamic WEP requires 'ieee8021x' key management"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
 				return FALSE;
 			}
 		}
@@ -242,9 +275,11 @@ verify_dynamic_wep (NMSettingWirelessSecurity *s_wsec,
 		if (auth_alg && strcmp (auth_alg, "open")) {
 			/* 802.1x key management must use "open" authentication */
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "Dynamic WEP requires 'open' authentication");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			                     _("Dynamic WEP requires 'open' authentication"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
 			return FALSE;
 		}
 
@@ -274,18 +309,21 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec,
 		if (!strcmp (key_mgmt, "wpa-psk") || !strcmp (key_mgmt, "wpa-none")) {
 			if (s_8021x) {
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "WPA-PSK incompatible with 802.1x");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_SETTING,
+				                     _("WPA-PSK authentication is incompatible with 802.1x"));
+				g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
 				return FALSE;
 			}
 
 			if (auth_alg && strcmp (auth_alg, "open")) {
 				/* WPA must use "open" authentication */
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "WPA-PSK requires 'open' authentication");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("WPA-PSK requires 'open' authentication"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
 				return FALSE;
 			}
 		}
@@ -293,9 +331,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec,
 		if (!strcmp (key_mgmt, "wpa-none")) {
 			if (!adhoc) {
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "WPA Ad-Hoc requires an Ad-Hoc mode AP");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("WPA Ad-Hoc authentication requires an Ad-Hoc mode AP"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME,
+				                NM_SETTING_WIRELESS_MODE);
 				return FALSE;
 			}
 
@@ -304,9 +344,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec,
 			tmp = (n > 0) ? nm_setting_wireless_security_get_proto (s_wsec, 0) : NULL;
 			if (n > 1 || !tmp || strcmp (tmp, "wpa")) {
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "WPA Ad-Hoc requires 'wpa' proto");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("WPA Ad-Hoc authentication requires 'wpa' protocol"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_PROTO);
 				return FALSE;
 			}
 
@@ -314,9 +356,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec,
 			tmp = (n > 0) ? nm_setting_wireless_security_get_pairwise (s_wsec, 0) : NULL;
 			if (n > 1 || g_strcmp0 (tmp, "none")) {
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "WPA Ad-Hoc requires 'none' pairwise cipher");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("WPA Ad-Hoc authentication requires 'none' pairwise cipher"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
 				return FALSE;
 			}
 
@@ -324,9 +368,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec,
 			tmp = (n > 0) ? nm_setting_wireless_security_get_group (s_wsec, 0) : NULL;
 			if (n > 1 || !tmp || strcmp (tmp, "tkip")) {
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "WPA Ad-Hoc requires 'tkip' group cipher");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("WPA Ad-Hoc requires 'tkip' group cipher"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_GROUP);
 				return FALSE;
 			}
 		}
@@ -336,9 +382,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec,
 			if (   !(wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
 			    && !(rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)) {
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "AP does not support PSK but setting requires it");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("Access point does not support PSK but setting requires it"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
 				return FALSE;
 			}
 		}
@@ -364,27 +412,31 @@ verify_wpa_eap (NMSettingWirelessSecurity *s_wsec,
 		if (!strcmp (key_mgmt, "wpa-eap")) {
 			if (!s_8021x) {
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "WPA-EAP requires an 802.1x setting");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_MISSING_SETTING,
+				                     _("WPA-EAP authentication requires an 802.1x setting"));
+				g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
 				return FALSE;
 			}
 
 			if (auth_alg && strcmp (auth_alg, "open")) {
 				/* WPA must use "open" authentication */
 				g_set_error_literal (error,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-				                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-				                     "WPA-EAP requires 'open' authentication");
+				                     NM_CONNECTION_ERROR,
+				                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+				                     _("WPA-EAP requires 'open' authentication"));
+				g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+				                NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
 				return FALSE;
 			}
 
 			is_wpa_eap = TRUE;
 		} else if (s_8021x) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "Setting requires 802.1x but does not use 'wpa-eap' key management");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_SETTING,
+			                     _("802.1x setting requires 'wpa-eap' key management"));
+			g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
 			return FALSE;
 		}
 	}
@@ -394,9 +446,10 @@ verify_wpa_eap (NMSettingWirelessSecurity *s_wsec,
 		if (   !(wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
 		    && !(rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "AP does not support 802.1x but setting requires it");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_SETTING,
+			                     _("Access point does not support 802.1x but setting requires it"));
+			g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
 			return FALSE;
 		}
 	}
@@ -421,41 +474,50 @@ verify_adhoc (NMSettingWirelessSecurity *s_wsec,
 	if (adhoc) {
 		if (key_mgmt && strcmp (key_mgmt, "wpa-none") && strcmp (key_mgmt, "none")) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "AP mode is Ad-Hoc but setting requires Infrastructure security");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			                     _("Access point mode is Ad-Hoc but setting requires Infrastructure security"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
 			return FALSE;
 		}
 
 		if (s_8021x) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "Ad-Hoc mode incompatible with 802.1x security");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_SETTING,
+			                     _("Ad-Hoc mode is incompatible with 802.1x security"));
+			g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
 			return FALSE;
 		}
 
 		if (leap_username) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "Ad-Hoc mode incompatible with LEAP security");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			                     _("Ad-Hoc mode is incompatible with LEAP security"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
 			return FALSE;
 		}
 
 		if (auth_alg && strcmp (auth_alg, "open")) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "Ad-Hoc mode requires 'open' authentication");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			                     _("Ad-Hoc mode requires 'open' authentication"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
 			return FALSE;
 		}
 	} else {
 		if (key_mgmt && !strcmp (key_mgmt, "wpa-none")) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "AP mode is Infrastructure but setting requires Ad-Hoc security");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			                     _("Access point mode is Infrastructure but setting requires Ad-Hoc security"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+			                NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
 			return FALSE;
 		}
 	}
@@ -465,7 +527,7 @@ verify_adhoc (NMSettingWirelessSecurity *s_wsec,
 
 gboolean
 nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
-                                 const guint8 ap_bssid[ETH_ALEN],
+                                 const char *bssid,
                                  NM80211Mode ap_mode,
                                  guint32 ap_flags,
                                  guint32 ap_wpa_flags,
@@ -477,7 +539,7 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
 	NMSettingWireless *s_wifi;
 	NMSettingWirelessSecurity *s_wsec;
 	NMSetting8021x *s_8021x;
-	const GByteArray *ssid;
+	GBytes *ssid, *ap_ssid_bytes;
 	const char *mode, *key_mgmt, *auth_alg, *leap_username;
 	gboolean adhoc = FALSE;
 
@@ -487,26 +549,23 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
 	s_8021x = nm_connection_get_setting_802_1x (connection);
 
 	/* Fill in missing SSID */
+	ap_ssid_bytes = g_bytes_new (ap_ssid->data, ap_ssid->len);
 	ssid = nm_setting_wireless_get_ssid (s_wifi);
 	if (!ssid)
-		g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid, NULL);
-	else if (   ssid->len != ap_ssid->len
-	         || memcmp (ssid->data, ap_ssid->data, ssid->len)) {
+		g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid_bytes, NULL);
+	else if (!g_bytes_equal (ssid, ap_ssid_bytes)) {
 		g_set_error_literal (error,
-		                     NM_SETTING_WIRELESS_ERROR,
-		                     NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
-		                     "Setting SSID did not match AP SSID");
+		                     NM_CONNECTION_ERROR,
+		                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+		                     _("connection does not match access point"));
+		g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID);
+		g_bytes_unref (ap_ssid_bytes);
 		return FALSE;
 	}
+	g_bytes_unref (ap_ssid_bytes);
 
-	if (lock_bssid && !nm_setting_wireless_get_bssid (s_wifi)) {
-		GByteArray *bssid;
-
-		bssid = g_byte_array_sized_new (ETH_ALEN);
-		g_byte_array_append (bssid, ap_bssid, ETH_ALEN);
+	if (lock_bssid && !nm_setting_wireless_get_bssid (s_wifi))
 		g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL);
-		g_byte_array_free (bssid, TRUE);
-	}
 
 	/* And mode */
 	mode = nm_setting_wireless_get_mode (s_wifi);
@@ -526,9 +585,10 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
 
 		if (valid == FALSE) {
 			g_set_error (error,
-			             NM_SETTING_WIRELESS_ERROR,
-			             NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
-			             NM_SETTING_WIRELESS_MODE);
+			             NM_CONNECTION_ERROR,
+			             NM_CONNECTION_ERROR_INVALID_PROPERTY,
+			             _("connection does not match access point"));
+			g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MODE);
 			return FALSE;
 		}
 	} else {
@@ -549,9 +609,13 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
 		/* Make sure the connection doesn't specify security */
 		if (s_wsec || s_8021x) {
 			g_set_error_literal (error,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-			                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-			                     "AP is unencrypted but setting specifies security");
+			                     NM_CONNECTION_ERROR,
+			                     NM_CONNECTION_ERROR_INVALID_SETTING,
+			                     _("Access point is unencrypted but setting specifies security"));
+			if (s_wsec)
+				g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
+			else
+				g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
 			return FALSE;
 		}
 		return TRUE;
@@ -634,18 +698,20 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
 	/* Ensure key management is valid for WPA */
 	if ((key_mgmt && !strcmp (key_mgmt, "ieee8021x")) || leap_username) {
 		g_set_error_literal (error,
-		                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-		                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-		                     "WPA incompatible with non-EAP (original) LEAP or Dynamic WEP");
+		                     NM_CONNECTION_ERROR,
+		                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+		                     _("WPA authentication is incompatible with non-EAP (original) LEAP or Dynamic WEP"));
+		g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
 		return FALSE;
 	}
 
 	/* 'shared' auth incompatible with any type of WPA */
 	if (auth_alg && strcmp (auth_alg, "open")) {
 		g_set_error_literal (error,
-		                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-		                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-		                     "WPA incompatible with Shared Key authentication");
+		                     NM_CONNECTION_ERROR,
+		                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
+		                     _("WPA authentication is incompatible with Shared Key authentication"));
+		g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
 		return FALSE;
 	}
 
@@ -689,9 +755,9 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
 		 */
 	} else {
 		g_set_error_literal (error,
-		                     NM_SETTING_WIRELESS_SECURITY_ERROR,
-		                     NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
-		                     "Failed to determine AP security information");
+		                     NM_CONNECTION_ERROR,
+		                     NM_CONNECTION_ERROR_FAILED,
+		                     _("Failed to determine AP security information"));
 		return FALSE;
 	}
 
diff --git a/src/devices/wifi/nm-wifi-ap-utils.h b/src/devices/wifi/nm-wifi-ap-utils.h
index 992b839d..31c12cd7 100644
--- a/src/devices/wifi/nm-wifi-ap-utils.h
+++ b/src/devices/wifi/nm-wifi-ap-utils.h
@@ -18,19 +18,18 @@
  * (C) Copyright 2011 Red Hat, Inc.
  */
 
-#ifndef NM_WIFI_AP_UTILS_H
-#define NM_WIFI_AP_UTILS_H
+#ifndef __NETWORKMANAGER_WIFI_AP_UTILS_H__
+#define __NETWORKMANAGER_WIFI_AP_UTILS_H__
 
-#include <net/ethernet.h>
 
-#include <NetworkManager.h>
+#include <nm-dbus-interface.h>
 #include <nm-connection.h>
 #include <nm-setting-wireless.h>
 #include <nm-setting-wireless-security.h>
 #include <nm-setting-8021x.h>
 
 gboolean nm_ap_utils_complete_connection (const GByteArray *ssid,
-                                          const guint8 bssid[ETH_ALEN],
+                                          const char *bssid,
                                           NM80211Mode mode,
                                           guint32 flags,
                                           guint32 wpa_flags,
diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c
index 363be2e3..ee07cf40 100644
--- a/src/devices/wifi/nm-wifi-ap.c
+++ b/src/devices/wifi/nm-wifi-ap.c
@@ -19,9 +19,10 @@
  * Copyright (C) 2006 - 2008 Novell, Inc.
  */
 
+#include "config.h"
+
 #include <string.h>
 #include <stdlib.h>
-#include <netinet/ether.h>
 
 #include "nm-wifi-ap.h"
 #include "nm-wifi-ap-utils.h"
@@ -45,7 +46,7 @@ typedef struct
 
 	/* Scanned or cached values */
 	GByteArray *	ssid;
-	struct ether_addr	address;
+	char *          address;
 	NM80211Mode		mode;
 	gint8			strength;
 	guint32			freq;		/* Frequency in MHz; ie 2412 (== 2.412 GHz) */
@@ -102,6 +103,7 @@ finalize (GObject *object)
 	g_free (priv->supplicant_path);
 	if (priv->ssid)
 		g_byte_array_free (priv->ssid, TRUE);
+	g_free (priv->address);
 
 	G_OBJECT_CLASS (nm_ap_parent_class)->finalize (object);
 }
@@ -111,6 +113,7 @@ set_property (GObject *object, guint prop_id,
 		    const GValue *value, GParamSpec *pspec)
 {
 	NMAccessPoint *ap = NM_AP (object);
+	GByteArray *ssid;
 
 	switch (prop_id) {
 	case PROP_FLAGS:
@@ -123,7 +126,11 @@ set_property (GObject *object, guint prop_id,
 		nm_ap_set_rsn_flags (ap, g_value_get_uint (value));
 		break;
 	case PROP_SSID:
-		nm_ap_set_ssid (ap, (GByteArray *) g_value_get_boxed (value));
+		ssid = g_value_get_boxed (value);
+		if (ssid)
+			nm_ap_set_ssid (ap, ssid->data, ssid->len);
+		else
+			nm_ap_set_ssid (ap, NULL, 0);
 		break;
 	case PROP_FREQUENCY:
 		nm_ap_set_freq (ap, g_value_get_uint (value));
@@ -176,7 +183,7 @@ get_property (GObject *object, guint prop_id,
 		g_value_set_uint (value, priv->freq);
 		break;
 	case PROP_HW_ADDRESS:
-		g_value_take_string (value, nm_utils_hwaddr_ntoa (&priv->address, ARPHRD_ETHER));
+		g_value_set_string (value, priv->address);
 		break;
 	case PROP_MODE:
 		g_value_set_uint (value, priv->mode);
@@ -219,81 +226,72 @@ nm_ap_class_init (NMAccessPointClass *ap_class)
 	/* properties */
 	g_object_class_install_property
 		(object_class, PROP_FLAGS,
-		 g_param_spec_uint (NM_AP_FLAGS,
-							"Flags",
-							"Flags",
-							NM_802_11_AP_FLAGS_NONE,
-							NM_802_11_AP_FLAGS_PRIVACY,
-							NM_802_11_AP_FLAGS_NONE,
-							G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+		 g_param_spec_uint (NM_AP_FLAGS, "", "",
+		                    NM_802_11_AP_FLAGS_NONE,
+		                    NM_802_11_AP_FLAGS_PRIVACY,
+		                    NM_802_11_AP_FLAGS_NONE,
+		                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+		                    G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_WPA_FLAGS,
-		 g_param_spec_uint (NM_AP_WPA_FLAGS,
-							"WPA Flags",
-							"WPA Flags",
-							NM_802_11_AP_SEC_NONE,
-							all_sec_flags,
-							NM_802_11_AP_SEC_NONE,
-							G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+		 g_param_spec_uint (NM_AP_WPA_FLAGS, "", "",
+		                    NM_802_11_AP_SEC_NONE,
+		                    all_sec_flags,
+		                    NM_802_11_AP_SEC_NONE,
+		                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+		                    G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_RSN_FLAGS,
-		 g_param_spec_uint (NM_AP_RSN_FLAGS,
-							"RSN Flags",
-							"RSN Flags",
-							NM_802_11_AP_SEC_NONE,
-							all_sec_flags,
-							NM_802_11_AP_SEC_NONE,
-							G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+		 g_param_spec_uint (NM_AP_RSN_FLAGS, "", "",
+		                    NM_802_11_AP_SEC_NONE,
+		                    all_sec_flags,
+		                    NM_802_11_AP_SEC_NONE,
+		                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+		                    G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_SSID,
-	     g_param_spec_boxed (NM_AP_SSID,
-	                         "SSID",
-	                         "SSID",
+	     g_param_spec_boxed (NM_AP_SSID, "", "",
 	                         DBUS_TYPE_G_UCHAR_ARRAY,
-	                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+	                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+	                         G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_FREQUENCY,
-		 g_param_spec_uint (NM_AP_FREQUENCY,
-							"Frequency",
-							"Frequency",
-							0, 10000, 0,
-							G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+		 g_param_spec_uint (NM_AP_FREQUENCY, "", "",
+		                    0, 10000, 0,
+		                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+		                    G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_HW_ADDRESS,
-		 g_param_spec_string (NM_AP_HW_ADDRESS,
-							  "MAC Address",
-							  "Hardware MAC address",
-							  NULL,
-							  G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+		 g_param_spec_string (NM_AP_HW_ADDRESS, "", "",
+		                      NULL,
+		                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+		                      G_PARAM_STATIC_STRINGS));
 	
 	g_object_class_install_property
 		(object_class, PROP_MODE,
-		 g_param_spec_uint (NM_AP_MODE,
-						   "Mode",
-						   "Mode",
-						   NM_802_11_MODE_ADHOC, NM_802_11_MODE_INFRA, NM_802_11_MODE_INFRA,
-						   G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+		 g_param_spec_uint (NM_AP_MODE, "", "",
+		                    NM_802_11_MODE_ADHOC, NM_802_11_MODE_INFRA, NM_802_11_MODE_INFRA,
+		                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+		                    G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_MAX_BITRATE,
-		 g_param_spec_uint (NM_AP_MAX_BITRATE,
-							"Max Bitrate",
-							"Max Bitrate",
-							0, G_MAXUINT16, 0,
-							G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+		 g_param_spec_uint (NM_AP_MAX_BITRATE, "", "",
+		                    0, G_MAXUINT16, 0,
+		                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+		                    G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property
 		(object_class, PROP_STRENGTH,
-		 g_param_spec_char (NM_AP_STRENGTH,
-							"Strength",
-							"Strength",
-							G_MININT8, G_MAXINT8, 0,
-							G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+		 g_param_spec_char (NM_AP_STRENGTH, "", "",
+		                    G_MININT8, G_MAXINT8, 0,
+		                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+		                    G_PARAM_STATIC_STRINGS));
 
 	nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
 	                                        G_TYPE_FROM_CLASS (ap_class),
@@ -402,7 +400,6 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
 
 		if (!strcmp (key, "SSID")) {
 			guint32 len = MIN (32, array->len);
-			GByteArray *ssid;
 
 			/* Stupid ieee80211 layer uses <hidden> */
 			if (((len == 8) || (len == 9))
@@ -412,18 +409,15 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
 			if (nm_utils_is_empty_ssid ((const guint8 *) array->data, len))
 				return;
 
-			ssid = g_byte_array_sized_new (len);
-			g_byte_array_append (ssid, (const guint8 *) array->data, len);
-			nm_ap_set_ssid (ap, ssid);
-			g_byte_array_free (ssid, TRUE);
+			nm_ap_set_ssid (ap, (const guint8 *) array->data, len);
 		} else if (!strcmp (key, "BSSID")) {
-			struct ether_addr addr;
+			char *addr;
 
 			if (array->len != ETH_ALEN)
 				return;
-			memset (&addr, 0, sizeof (struct ether_addr));
-			memcpy (&addr, array->data, ETH_ALEN);
-			nm_ap_set_address (ap, &addr);
+			addr = nm_utils_hwaddr_ntoa (array->data, array->len);
+			nm_ap_set_address (ap, addr);
+			g_free (addr);
 		} else if (!strcmp (key, "Rates")) {
 			guint32 maxrate = 0;
 			int i;
@@ -483,7 +477,7 @@ NMAccessPoint *
 nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties)
 {
 	NMAccessPoint *ap;
-	const struct ether_addr * addr;
+	const char *addr;
 	const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 	const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
 
@@ -498,8 +492,8 @@ nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties)
 
 	/* ignore APs with invalid BSSIDs */
 	addr = nm_ap_get_address (ap);
-	if (   !(memcmp (addr->ether_addr_octet, bad_bssid1, ETH_ALEN))
-	    || !(memcmp (addr->ether_addr_octet, bad_bssid2, ETH_ALEN))) {
+	if (   nm_utils_hwaddr_matches (addr, -1, bad_bssid1, ETH_ALEN)
+	    || nm_utils_hwaddr_matches (addr, -1, bad_bssid2, ETH_ALEN)) {
 		g_object_unref (ap);
 		return NULL;
 	}
@@ -597,7 +591,7 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
 	NMAccessPoint *ap;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wireless_sec;
-	const GByteArray *ssid;
+	GBytes *ssid;
 	const char *mode, *band, *key_mgmt;
 	guint32 channel;
 	NM80211ApSecurityFlags flags;
@@ -610,11 +604,11 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
 
 	ssid = nm_setting_wireless_get_ssid (s_wireless);
 	g_return_val_if_fail (ssid != NULL, NULL);
-	g_return_val_if_fail (ssid->len > 0, NULL);
+	g_return_val_if_fail (g_bytes_get_size (ssid) > 0, NULL);
 
 	ap = nm_ap_new ();
 	nm_ap_set_fake (ap, TRUE);
-	nm_ap_set_ssid (ap, ssid);
+	nm_ap_set_ssid (ap, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
 
 	// FIXME: bssid too?
 
@@ -720,10 +714,6 @@ error:
 	return NULL;
 }
 
-
-#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
-#define MAC_ARG(x) ((guint8*)(x))[0],((guint8*)(x))[1],((guint8*)(x))[2],((guint8*)(x))[3],((guint8*)(x))[4],((guint8*)(x))[5]
-
 void
 nm_ap_dump (NMAccessPoint *ap, const char *prefix)
 {
@@ -737,7 +727,7 @@ nm_ap_dump (NMAccessPoint *ap, const char *prefix)
 	            prefix,
 	            priv->ssid ? nm_utils_escape_ssid (priv->ssid->data, priv->ssid->len) : "(none)",
 	            ap);
-	nm_log_dbg (LOGD_WIFI_SCAN, "    BSSID     " MAC_FMT, MAC_ARG (priv->address.ether_addr_octet));
+	nm_log_dbg (LOGD_WIFI_SCAN, "    BSSID     %s", str_if_set (priv->address, "(none)"));
 	nm_log_dbg (LOGD_WIFI_SCAN, "    mode      %d", priv->mode);
 	nm_log_dbg (LOGD_WIFI_SCAN, "    flags     0x%X", priv->flags);
 	nm_log_dbg (LOGD_WIFI_SCAN, "    wpa flags 0x%X", priv->wpa_flags);
@@ -786,20 +776,18 @@ const GByteArray * nm_ap_get_ssid (const NMAccessPoint *ap)
 }
 
 void
-nm_ap_set_ssid (NMAccessPoint *ap, const GByteArray * ssid)
+nm_ap_set_ssid (NMAccessPoint *ap, const guint8 *ssid, gsize len)
 {
 	NMAccessPointPrivate *priv;
 
 	g_return_if_fail (NM_IS_AP (ap));
+	g_return_if_fail (ssid == NULL || len > 0);
 
 	priv = NM_AP_GET_PRIVATE (ap);
 
-	if (ssid == priv->ssid)
-		return;
-
 	/* same SSID */
-	if ((ssid && priv->ssid) && (ssid->len == priv->ssid->len)) {
-		if (!memcmp (ssid->data, priv->ssid->data, ssid->len))
+	if ((ssid && priv->ssid) && (len == priv->ssid->len)) {
+		if (!memcmp (ssid, priv->ssid->data, len))
 			return;
 	}
 
@@ -809,14 +797,8 @@ nm_ap_set_ssid (NMAccessPoint *ap, const GByteArray * ssid)
 	}
 
 	if (ssid) {
-		/* Should never get zero-length SSIDs */
-		g_warn_if_fail (ssid->len > 0);
-
-		if (ssid->len) {
-			priv->ssid = g_byte_array_sized_new (ssid->len);
-			priv->ssid->len = ssid->len;
-			memcpy (priv->ssid->data, ssid->data, ssid->len);
-		}
+		priv->ssid = g_byte_array_new ();
+		g_byte_array_append (priv->ssid, ssid, len);
 	}
 
 	g_object_notify (G_OBJECT (ap), NM_AP_SSID);
@@ -897,24 +879,28 @@ nm_ap_set_rsn_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags)
  * Get/set functions for address
  *
  */
-const struct ether_addr * nm_ap_get_address (const NMAccessPoint *ap)
+const char *
+nm_ap_get_address (const NMAccessPoint *ap)
 {
 	g_return_val_if_fail (NM_IS_AP (ap), NULL);
 
-	return &NM_AP_GET_PRIVATE (ap)->address;
+	return NM_AP_GET_PRIVATE (ap)->address;
 }
 
-void nm_ap_set_address (NMAccessPoint *ap, const struct ether_addr * addr)
+void
+nm_ap_set_address (NMAccessPoint *ap, const char *addr)
 {
 	NMAccessPointPrivate *priv;
 
 	g_return_if_fail (NM_IS_AP (ap));
 	g_return_if_fail (addr != NULL);
+	g_return_if_fail (nm_utils_hwaddr_valid (addr, ETH_ALEN));
 
 	priv = NM_AP_GET_PRIVATE (ap);
 
-	if (memcmp (addr, &priv->address, sizeof (priv->address))) {
-		memcpy (&NM_AP_GET_PRIVATE (ap)->address, addr, sizeof (struct ether_addr));
+	if (!priv->address || !nm_utils_hwaddr_matches (addr, -1, priv->address, -1)) {
+		g_free (priv->address);
+		priv->address = g_strdup (addr);
 		g_object_notify (G_OBJECT (ap), NM_AP_HW_ADDRESS);
 	}
 }
@@ -1118,9 +1104,10 @@ nm_ap_check_compatible (NMAccessPoint *self,
 	NMAccessPointPrivate *priv;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wireless_sec;
+	GBytes *ssid;
 	const char *mode;
 	const char *band;
-	const GByteArray *bssid;
+	const char *bssid;
 	guint32 channel;
 
 	g_return_val_if_fail (NM_IS_AP (self), FALSE);
@@ -1132,11 +1119,19 @@ nm_ap_check_compatible (NMAccessPoint *self,
 	if (s_wireless == NULL)
 		return FALSE;
 	
-	if (!nm_utils_same_ssid (nm_setting_wireless_get_ssid (s_wireless), priv->ssid, TRUE))
+	ssid = nm_setting_wireless_get_ssid (s_wireless);
+	if (   (ssid && !priv->ssid)
+	    || (priv->ssid && !ssid))
+		return FALSE;
+
+	if (   ssid && priv->ssid &&
+	    !nm_utils_same_ssid (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid),
+	                         priv->ssid->data, priv->ssid->len,
+	                         TRUE))
 		return FALSE;
 
 	bssid = nm_setting_wireless_get_bssid (s_wireless);
-	if (bssid && memcmp (bssid->data, &priv->address, ETH_ALEN))
+	if (bssid && (!priv->address || !nm_utils_hwaddr_matches (bssid, -1, priv->address, -1)))
 		return FALSE;
 
 	mode = nm_setting_wireless_get_mode (s_wireless);
@@ -1190,7 +1185,7 @@ nm_ap_complete_connection (NMAccessPoint *self,
 	g_return_val_if_fail (connection != NULL, FALSE);
 
 	return nm_ap_utils_complete_connection (priv->ssid,
-	                                        priv->address.ether_addr_octet,
+	                                        priv->address,
 	                                        priv->mode,
 	                                        priv->flags,
 	                                        priv->wpa_flags,
@@ -1233,27 +1228,29 @@ nm_ap_match_in_list (NMAccessPoint *find_ap,
 	for (iter = ap_list; iter; iter = g_slist_next (iter)) {
 		NMAccessPoint * list_ap = NM_AP (iter->data);
 		const GByteArray * list_ssid = nm_ap_get_ssid (list_ap);
-		const struct ether_addr * list_addr = nm_ap_get_address (list_ap);
+		const char * list_addr = nm_ap_get_address (list_ap);
 
 		const GByteArray * find_ssid = nm_ap_get_ssid (find_ap);
-		const struct ether_addr * find_addr = nm_ap_get_address (find_ap);
+		const char * find_addr = nm_ap_get_address (find_ap);
 
 		/* SSID match; if both APs are hiding their SSIDs,
 		 * let matching continue on BSSID and other properties
 		 */
 		if (   (!list_ssid && find_ssid)
-		    || (list_ssid && !find_ssid)
-		    || !nm_utils_same_ssid (list_ssid, find_ssid, TRUE))
+		    || (list_ssid && !find_ssid))
+			continue;
+		if (   list_ssid
+		    && find_ssid
+		    && !nm_utils_same_ssid (list_ssid->data, list_ssid->len,
+		                            find_ssid->data, find_ssid->len,
+		                            TRUE))
 			continue;
 
 		/* BSSID match */
-		if (   (strict_match || nm_ethernet_address_is_valid (find_addr))
-		    && nm_ethernet_address_is_valid (list_addr)
-		    && memcmp (list_addr->ether_addr_octet, 
-		               find_addr->ether_addr_octet,
-		               ETH_ALEN) != 0) {
+		if (   (strict_match || nm_ethernet_address_is_valid (find_addr, -1))
+		    && nm_ethernet_address_is_valid (list_addr, -1)
+		    && !nm_utils_hwaddr_matches (list_addr, -1, find_addr, -1))
 			continue;
-		}
 
 		/* mode match */
 		if (nm_ap_get_mode (list_ap) != nm_ap_get_mode (find_ap))
diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h
index f51fa078..0abb28fc 100644
--- a/src/devices/wifi/nm-wifi-ap.h
+++ b/src/devices/wifi/nm-wifi-ap.h
@@ -19,12 +19,12 @@
  * Copyright (C) 2006 - 2008 Novell, Inc.
  */
 
-#ifndef NM_ACCESS_POINT_H
-#define NM_ACCESS_POINT_H
+#ifndef __NETWORKMANAGER_ACCESS_POINT_H__
+#define __NETWORKMANAGER_ACCESS_POINT_H__
 
 #include <glib.h>
 #include <glib-object.h>
-#include "NetworkManager.h"
+#include "nm-dbus-interface.h"
 #include "nm-connection.h"
 
 #define NM_TYPE_AP            (nm_ap_get_type ())
@@ -60,62 +60,62 @@ NMAccessPoint * nm_ap_new_from_properties (const char *supplicant_path,
 NMAccessPoint * nm_ap_new_fake_from_connection (NMConnection *connection);
 void            nm_ap_export_to_dbus    (NMAccessPoint *ap);
 
-const char *		nm_ap_get_dbus_path (NMAccessPoint *ap);
+const char *nm_ap_get_dbus_path (NMAccessPoint *ap);
 
-const char *        nm_ap_get_supplicant_path (NMAccessPoint *ap);
-void                nm_ap_set_supplicant_path (NMAccessPoint *ap,
-                                               const char *path);
+const char *nm_ap_get_supplicant_path (NMAccessPoint *ap);
+void        nm_ap_set_supplicant_path (NMAccessPoint *ap,
+                                       const char *path);
 
-const GByteArray *	nm_ap_get_ssid (const NMAccessPoint * ap);
-void				nm_ap_set_ssid (NMAccessPoint * ap, const GByteArray * ssid);
+const GByteArray *nm_ap_get_ssid (const NMAccessPoint * ap);
+void              nm_ap_set_ssid (NMAccessPoint * ap, const guint8 * ssid, gsize len);
 
-NM80211ApFlags         nm_ap_get_flags     (NMAccessPoint *ap);
-void                   nm_ap_set_flags     (NMAccessPoint *ap, NM80211ApFlags flags);
+NM80211ApFlags nm_ap_get_flags (NMAccessPoint *ap);
+void           nm_ap_set_flags (NMAccessPoint *ap, NM80211ApFlags flags);
 
 NM80211ApSecurityFlags nm_ap_get_wpa_flags (NMAccessPoint *ap);
 void                   nm_ap_set_wpa_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags);
 
-NM80211ApSecurityFlags nm_ap_get_rsn_flags	(NMAccessPoint *ap);
-void                   nm_ap_set_rsn_flags  (NMAccessPoint *ap, NM80211ApSecurityFlags flags);
+NM80211ApSecurityFlags nm_ap_get_rsn_flags (NMAccessPoint *ap);
+void                   nm_ap_set_rsn_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags);
 
-const struct ether_addr * nm_ap_get_address	(const NMAccessPoint *ap);
-void				nm_ap_set_address		(NMAccessPoint *ap, const struct ether_addr *addr);
+const char *nm_ap_get_address (const NMAccessPoint *ap);
+void        nm_ap_set_address (NMAccessPoint *ap, const char *addr);
 
-NM80211Mode			nm_ap_get_mode			(NMAccessPoint *ap);
-void				nm_ap_set_mode			(NMAccessPoint *ap, const NM80211Mode mode);
+NM80211Mode nm_ap_get_mode (NMAccessPoint *ap);
+void        nm_ap_set_mode (NMAccessPoint *ap, const NM80211Mode mode);
 
-gboolean            nm_ap_is_hotspot        (NMAccessPoint *ap);
+gboolean nm_ap_is_hotspot (NMAccessPoint *ap);
 
-gint8			nm_ap_get_strength		(NMAccessPoint *ap);
-void				nm_ap_set_strength		(NMAccessPoint *ap, gint8 strength);
+gint8 nm_ap_get_strength (NMAccessPoint *ap);
+void  nm_ap_set_strength (NMAccessPoint *ap, gint8 strength);
 
-guint32			nm_ap_get_freq			(NMAccessPoint *ap);
-void				nm_ap_set_freq			(NMAccessPoint *ap, guint32 freq);
+guint32 nm_ap_get_freq (NMAccessPoint *ap);
+void    nm_ap_set_freq (NMAccessPoint *ap, guint32 freq);
 
-guint32			nm_ap_get_max_bitrate			(NMAccessPoint *ap);
-void				nm_ap_set_max_bitrate		(NMAccessPoint *ap, guint32 bitrate);
+guint32 nm_ap_get_max_bitrate (NMAccessPoint *ap);
+void    nm_ap_set_max_bitrate (NMAccessPoint *ap, guint32 bitrate);
 
-gboolean			nm_ap_get_fake	(const NMAccessPoint *ap);
-void				nm_ap_set_fake	(NMAccessPoint *ap, gboolean fake);
+gboolean nm_ap_get_fake (const NMAccessPoint *ap);
+void     nm_ap_set_fake (NMAccessPoint *ap, gboolean fake);
 
-gboolean			nm_ap_get_broadcast		(NMAccessPoint *ap);
-void				nm_ap_set_broadcast		(NMAccessPoint *ap, gboolean broadcast);
+gboolean nm_ap_get_broadcast (NMAccessPoint *ap);
+void     nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast);
 
-gint32                  nm_ap_get_last_seen     (const NMAccessPoint *ap);
-void                    nm_ap_set_last_seen     (NMAccessPoint *ap, gint32 last_seen);
+gint32   nm_ap_get_last_seen (const NMAccessPoint *ap);
+void     nm_ap_set_last_seen (NMAccessPoint *ap, gint32 last_seen);
 
-gboolean			nm_ap_check_compatible (NMAccessPoint *self,
-                                            NMConnection *connection);
+gboolean nm_ap_check_compatible (NMAccessPoint *self,
+                                 NMConnection *connection);
 
-gboolean            nm_ap_complete_connection (NMAccessPoint *self,
-                                               NMConnection *connection,
-                                               gboolean lock_bssid,
-                                               GError **error);
+gboolean nm_ap_complete_connection (NMAccessPoint *self,
+                                    NMConnection *connection,
+                                    gboolean lock_bssid,
+                                    GError **error);
 
 NMAccessPoint *     nm_ap_match_in_list (NMAccessPoint *find_ap,
                                          GSList *ap_list,
                                          gboolean strict_match);
 
-void				nm_ap_dump (NMAccessPoint *ap, const char *prefix);
+void                nm_ap_dump (NMAccessPoint *ap, const char *prefix);
 
-#endif /* NM_ACCESS_POINT_H */
+#endif /* __NETWORKMANAGER_ACCESS_POINT_H__ */
diff --git a/src/devices/wifi/nm-wifi-enum-types.c b/src/devices/wifi/nm-wifi-enum-types.c
index e914cfd6..7cce51cd 100644
--- a/src/devices/wifi/nm-wifi-enum-types.c
+++ b/src/devices/wifi/nm-wifi-enum-types.c
@@ -9,50 +9,6 @@
 #include "nm-wifi-ap.h" 
 #include "nm-device-olpc-mesh.h"
 
-GType
-nm_wifi_error_get_type (void)
-{
-  static volatile gsize g_define_type_id__volatile = 0;
-
-  if (g_once_init_enter (&g_define_type_id__volatile))
-    {
-      static const GEnumValue values[] = {
-        { NM_WIFI_ERROR_CONNECTION_NOT_WIRELESS, "NM_WIFI_ERROR_CONNECTION_NOT_WIRELESS", "ConnectionNotWireless" },
-        { NM_WIFI_ERROR_CONNECTION_INVALID, "NM_WIFI_ERROR_CONNECTION_INVALID", "ConnectionInvalid" },
-        { NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE, "NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE", "ConnectionIncompatible" },
-        { NM_WIFI_ERROR_ACCESS_POINT_NOT_FOUND, "NM_WIFI_ERROR_ACCESS_POINT_NOT_FOUND", "AccessPointNotFound" },
-        { NM_WIFI_ERROR_SCAN_NOT_ALLOWED, "NM_WIFI_ERROR_SCAN_NOT_ALLOWED", "ScanNotAllowed" },
-        { NM_WIFI_ERROR_AP_MODE_UNSUPPORTED, "NM_WIFI_ERROR_AP_MODE_UNSUPPORTED", "ApModeUnsupported" },
-        { NM_WIFI_ERROR_ADHOC_MODE_UNSUPPORTED, "NM_WIFI_ERROR_ADHOC_MODE_UNSUPPORTED", "AdhocModeUnsupported" },
-        { 0, NULL, NULL }
-      };
-      GType g_define_type_id =
-        g_enum_register_static (g_intern_static_string ("NMWifiError"), values);
-      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
-    }
-
-  return g_define_type_id__volatile;
-}
-GType
-nm_olpc_mesh_error_get_type (void)
-{
-  static volatile gsize g_define_type_id__volatile = 0;
-
-  if (g_once_init_enter (&g_define_type_id__volatile))
-    {
-      static const GEnumValue values[] = {
-        { NM_OLPC_MESH_ERROR_CONNECTION_NOT_MESH, "NM_OLPC_MESH_ERROR_CONNECTION_NOT_MESH", "ConnectionNotMesh" },
-        { NM_OLPC_MESH_ERROR_CONNECTION_INVALID, "NM_OLPC_MESH_ERROR_CONNECTION_INVALID", "ConnectionInvalid" },
-        { NM_OLPC_MESH_ERROR_CONNECTION_INCOMPATIBLE, "NM_OLPC_MESH_ERROR_CONNECTION_INCOMPATIBLE", "ConnectionIncompatible" },
-        { 0, NULL, NULL }
-      };
-      GType g_define_type_id =
-        g_enum_register_static (g_intern_static_string ("NMOlpcMeshError"), values);
-      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
-    }
-
-  return g_define_type_id__volatile;
-}
 
 
 
diff --git a/src/devices/wifi/nm-wifi-enum-types.h b/src/devices/wifi/nm-wifi-enum-types.h
index d4dca5bf..7fc64cd1 100644
--- a/src/devices/wifi/nm-wifi-enum-types.h
+++ b/src/devices/wifi/nm-wifi-enum-types.h
@@ -9,10 +9,6 @@
 #include <glib-object.h>
 
 G_BEGIN_DECLS
-GType nm_wifi_error_get_type (void) G_GNUC_CONST;
-#define NM_TYPE_WIFI_ERROR (nm_wifi_error_get_type ())
-GType nm_olpc_mesh_error_get_type (void) G_GNUC_CONST;
-#define NM_TYPE_OLPC_MESH_ERROR (nm_olpc_mesh_error_get_type ())
 G_END_DECLS
 
 #endif /* __NM_WIFI_ENUM_TYPES_H__ */
diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c
index 02ad93f4..4093c612 100644
--- a/src/devices/wifi/nm-wifi-factory.c
+++ b/src/devices/wifi/nm-wifi-factory.c
@@ -18,12 +18,15 @@
  * Copyright (C) 2011 - 2014 Red Hat, Inc.
  */
 
+#include "config.h"
+
 #include <gmodule.h>
 
 #include "nm-device-factory.h"
 #include "nm-device-wifi.h"
 #include "nm-device-olpc-mesh.h"
 #include "nm-settings-connection.h"
+#include "nm-platform.h"
 
 #define NM_TYPE_WIFI_FACTORY (nm_wifi_factory_get_type ())
 #define NM_WIFI_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_FACTORY, NMWifiFactory))
@@ -45,20 +48,12 @@ G_DEFINE_TYPE_EXTENDED (NMWifiFactory, nm_wifi_factory, G_TYPE_OBJECT, 0,
 
 /**************************************************************************/
 
-#define PLUGIN_TYPE NM_DEVICE_TYPE_WIFI
-
 G_MODULE_EXPORT NMDeviceFactory *
 nm_device_factory_create (GError **error)
 {
 	return (NMDeviceFactory *) g_object_new (NM_TYPE_WIFI_FACTORY, NULL);
 }
 
-G_MODULE_EXPORT NMDeviceType
-nm_device_factory_get_device_type (void)
-{
-	return PLUGIN_TYPE;
-}
-
 /**************************************************************************/
 
 static NMDevice *
@@ -71,10 +66,17 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
 	return NULL;
 }
 
+static NMDeviceType
+get_device_type (NMDeviceFactory *factory)
+{
+	return NM_DEVICE_TYPE_WIFI;
+}
+
 static void
 device_factory_interface_init (NMDeviceFactory *factory_iface)
 {
 	factory_iface->new_link = new_link;
+	factory_iface->get_device_type = get_device_type;
 }
 
 static void
diff --git a/src/devices/wifi/tests/Makefile.am b/src/devices/wifi/tests/Makefile.am
index 2667c5f1..09c6401f 100644
--- a/src/devices/wifi/tests/Makefile.am
+++ b/src/devices/wifi/tests/Makefile.am
@@ -1,14 +1,13 @@
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/include \
-	-I$(top_builddir)/include \
-	-I$(top_srcdir)/libnm-util \
-	-I$(top_builddir)/libnm-util \
-	-I$(top_srcdir)/src/platform \
-	-I$(top_srcdir)/src/logging \
+	-I$(top_srcdir)/libnm-core \
+	-I$(top_builddir)/libnm-core \
+	-I${top_srcdir}/src/platform \
 	-I$(top_srcdir)/src \
 	-I$(top_srcdir)/src/devices/wifi \
 	-I$(top_builddir)/src \
 	-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
+	-DNETWORKMANAGER_COMPILATION \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
 	$(GLIB_CFLAGS) \
 	$(DBUS_CFLAGS)
diff --git a/src/devices/wifi/tests/Makefile.in b/src/devices/wifi/tests/Makefile.in
index c0e75eed..a8ae2e9d 100644
--- a/src/devices/wifi/tests/Makefile.in
+++ b/src/devices/wifi/tests/Makefile.in
@@ -205,6 +205,8 @@ AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
+BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@
+BLUEZ5_LIBS = @BLUEZ5_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -328,6 +330,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@
@@ -347,6 +350,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@
@@ -373,7 +377,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@
@@ -454,15 +458,14 @@ with_resolvconf = @with_resolvconf@
 with_valgrind = @with_valgrind@
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/include \
-	-I$(top_builddir)/include \
-	-I$(top_srcdir)/libnm-util \
-	-I$(top_builddir)/libnm-util \
-	-I$(top_srcdir)/src/platform \
-	-I$(top_srcdir)/src/logging \
+	-I$(top_srcdir)/libnm-core \
+	-I$(top_builddir)/libnm-core \
+	-I${top_srcdir}/src/platform \
 	-I$(top_srcdir)/src \
 	-I$(top_srcdir)/src/devices/wifi \
 	-I$(top_builddir)/src \
 	-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
+	-DNETWORKMANAGER_COMPILATION \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
 	$(GLIB_CFLAGS) \
 	$(DBUS_CFLAGS)
diff --git a/src/devices/wifi/tests/test-wifi-ap-utils.c b/src/devices/wifi/tests/test-wifi-ap-utils.c
index 36d58f2a..fb335b89 100644
--- a/src/devices/wifi/tests/test-wifi-ap-utils.c
+++ b/src/devices/wifi/tests/test-wifi-ap-utils.c
@@ -18,16 +18,15 @@
  *
  */
 
+#include "config.h"
+
 #include <glib.h>
 #include <string.h>
 
 #include "nm-wifi-ap-utils.h"
 #include "nm-dbus-glib-types.h"
 
-#include "nm-setting-connection.h"
-#include "nm-setting-wireless.h"
-#include "nm-setting-wireless-security.h"
-#include "nm-setting-8021x.h"
+#include "nm-core-internal.h"
 
 #define DEBUG 1
 
@@ -66,7 +65,7 @@
 
 static gboolean
 complete_connection (const char *ssid,
-                     const guint8 bssid[ETH_ALEN],
+                     const char *bssid,
                      NM80211Mode mode,
                      guint32 flags,
                      guint32 wpa_flags,
@@ -113,7 +112,7 @@ set_items (NMSetting *setting, const KeyData *items)
 {
 	const KeyData *item;
 	GParamSpec *pspec;
-	GByteArray *tmp;
+	GBytes *tmp;
 
 	for (item = items; item && item->key; item++) {
 		g_assert (item->key);
@@ -137,12 +136,11 @@ set_items (NMSetting *setting, const KeyData *items)
 
 			g_assert (item->str == NULL);
 			g_object_set (G_OBJECT (setting), item->key, foo, NULL);
-		} else if (pspec->value_type == DBUS_TYPE_G_UCHAR_ARRAY) {
+		} else if (pspec->value_type == G_TYPE_BYTES) {
 			g_assert (item->str);
-			tmp = g_byte_array_sized_new (strlen (item->str));
-			g_byte_array_append (tmp, (const guint8 *) item->str, strlen (item->str));
+			tmp = g_bytes_new (item->str, strlen (item->str));
 			g_object_set (G_OBJECT (setting), item->key, tmp, NULL);
-			g_byte_array_free (tmp, TRUE);
+			g_bytes_unref (tmp);
 		} else {
 			/* Special types, check based on property name */
 			if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_PROTO))
@@ -217,31 +215,26 @@ fill_8021x (NMConnection *connection, const KeyData items[])
 
 static NMConnection *
 create_basic (const char *ssid,
-              const guint8 *bssid,
+              const char *bssid,
               NM80211Mode mode)
 {
 	NMConnection *connection;
 	NMSettingWireless *s_wifi = NULL;
-	GByteArray *tmp;
+	GBytes *tmp;
 
-	connection = nm_connection_new ();
+	connection = nm_simple_connection_new ();
 
 	s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
 	nm_connection_add_setting (connection, NM_SETTING (s_wifi));
 
 	/* SSID */
-	tmp = g_byte_array_sized_new (strlen (ssid));
-	g_byte_array_append (tmp, (const guint8 *) ssid, strlen (ssid));
+	tmp = g_bytes_new (ssid, strlen (ssid));
 	g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, tmp, NULL);
-	g_byte_array_free (tmp, TRUE);
+	g_bytes_unref (tmp);
 
 	/* BSSID */
-	if (bssid) {
-		tmp = g_byte_array_sized_new (ETH_ALEN);
-		g_byte_array_append (tmp, bssid, ETH_ALEN);
-		g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, tmp, NULL);
-		g_byte_array_free (tmp, TRUE);
-	}
+	if (bssid)
+		g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL);
 
 	if (mode == NM_802_11_MODE_INFRA)
 		g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
@@ -259,12 +252,12 @@ static void
 test_lock_bssid (void)
 {
 	NMConnection *src, *expected;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const char *ssid = "blahblah";
 	gboolean success;
 	GError *error = NULL;
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	success = complete_connection (ssid, bssid,
 	                               NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE,
 	                               NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE,
@@ -283,7 +276,7 @@ static void
 test_open_ap_empty_connection (void)
 {
 	NMConnection *src, *expected;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const char *ssid = "blahblah";
 	gboolean success;
 	GError *error = NULL;
@@ -292,7 +285,7 @@ test_open_ap_empty_connection (void)
 	 * SSID and Infra modes of the given AP details.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	success = complete_connection (ssid, bssid,
 	                               NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE,
 	                               NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE,
@@ -311,7 +304,7 @@ static void
 test_open_ap_leap_connection_1 (gconstpointer add_wifi)
 {
 	NMConnection *src;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "Bill Smith", 0 }, { NULL } };
 	gboolean success;
 	GError *error = NULL;
@@ -321,7 +314,7 @@ test_open_ap_leap_connection_1 (gconstpointer add_wifi)
 	 * the AP to have the Privacy bit set.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	if (add_wifi)
 		fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
@@ -332,7 +325,7 @@ test_open_ap_leap_connection_1 (gconstpointer add_wifi)
 	                               FALSE,
 	                               src, &error);
 	/* We expect failure */
-	COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING);
 
 	g_object_unref (src);
 }
@@ -343,7 +336,7 @@ static void
 test_open_ap_leap_connection_2 (void)
 {
 	NMConnection *src;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, { NULL } };
 	gboolean success;
 	GError *error = NULL;
@@ -352,7 +345,7 @@ test_open_ap_leap_connection_2 (void)
 	 * WEP or LEAP) is rejected when completion is attempted with an open AP.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
 
@@ -362,7 +355,7 @@ test_open_ap_leap_connection_2 (void)
 	                               FALSE,
 	                               src, &error);
 	/* We expect failure */
-	COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING);
 
 	g_object_unref (src);
 }
@@ -373,7 +366,7 @@ static void
 test_open_ap_wep_connection (gconstpointer add_wifi)
 {
 	NMConnection *src;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "11111111111111111111111111", 0 },
 	    { NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, NULL, 0 },
@@ -386,7 +379,7 @@ test_open_ap_wep_connection (gconstpointer add_wifi)
 	 * attempted with an open AP.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	if (add_wifi)
 		fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
@@ -396,7 +389,7 @@ test_open_ap_wep_connection (gconstpointer add_wifi)
 	                               FALSE,
 	                               src, &error);
 	/* We expect failure */
-	COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING);
 
 	g_object_unref (src);
 }
@@ -410,11 +403,12 @@ test_ap_wpa_psk_connection_base (const char *key_mgmt,
                                  guint32 wpa_flags,
                                  guint32 rsn_flags,
                                  gboolean add_wifi,
+                                 guint error_code,
                                  NMConnection *expected)
 {
 	NMConnection *src;
 	const char *ssid = "blahblah";
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData exp_wifi[] = {
 		{ NM_SETTING_WIRELESS_SSID, ssid, 0 },
 		{ NM_SETTING_WIRELESS_MODE, "infrastructure", 0 },
@@ -427,7 +421,7 @@ test_ap_wpa_psk_connection_base (const char *key_mgmt,
 	gboolean success;
 	GError *error = NULL;
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	if (add_wifi)
 		fill_wifi_empty (src);
 	fill_wsec (src, both_wsec);
@@ -438,7 +432,7 @@ test_ap_wpa_psk_connection_base (const char *key_mgmt,
 		fill_wifi (expected, exp_wifi);
 		fill_wsec (expected, both_wsec);
 	}
-	COMPARE (src, expected, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY);
+	COMPARE (src, expected, success, error, NM_CONNECTION_ERROR, error_code);
 
 	g_object_unref (src);
 }
@@ -454,7 +448,9 @@ test_open_ap_wpa_psk_connection_1 (void)
 	                                 NM_802_11_AP_FLAGS_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_SETTING,
+	                                 NULL);
 }
 
 static void
@@ -468,7 +464,9 @@ test_open_ap_wpa_psk_connection_2 (void)
 	                                 NM_802_11_AP_FLAGS_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 TRUE, NULL);
+	                                 TRUE,
+	                                 NM_CONNECTION_ERROR_INVALID_SETTING,
+	                                 NULL);
 }
 
 static void
@@ -481,7 +479,9 @@ test_open_ap_wpa_psk_connection_3 (void)
 	                                 NM_802_11_AP_FLAGS_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_SETTING,
+	                                 NULL);
 }
 
 static void
@@ -495,7 +495,9 @@ test_open_ap_wpa_psk_connection_4 (void)
 	                                 NM_802_11_AP_FLAGS_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_SETTING,
+	                                 NULL);
 }
 
 static void
@@ -508,7 +510,9 @@ test_open_ap_wpa_psk_connection_5 (void)
 	                                 NM_802_11_AP_FLAGS_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_SETTING,
+	                                 NULL);
 }
 
 /*******************************************/
@@ -520,11 +524,10 @@ test_ap_wpa_eap_connection_base (const char *key_mgmt,
                                  guint32 wpa_flags,
                                  guint32 rsn_flags,
                                  gboolean add_wifi,
-                                 guint error_domain,
                                  guint error_code)
 {
 	NMConnection *src;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_empty[] = { { NULL } };
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0 },
@@ -533,7 +536,7 @@ test_ap_wpa_eap_connection_base (const char *key_mgmt,
 	gboolean success;
 	GError *error = NULL;
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	if (add_wifi)
 		fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
@@ -542,7 +545,7 @@ test_ap_wpa_eap_connection_base (const char *key_mgmt,
 	                               flags, wpa_flags, rsn_flags,
 	                               FALSE, src, &error);
 	/* Failure expected */
-	COMPARE (src, NULL, success, error, error_domain, error_code);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, error_code);
 
 	g_object_unref (src);
 }
@@ -619,37 +622,22 @@ rsn_flags_for_idx (guint32 idx)
 }
 
 static guint32
-error_domain_for_idx (guint32 idx, guint num)
-{
-	if (idx == IDX_OPEN)
-		return NM_SETTING_WIRELESS_SECURITY_ERROR;
-	else if (idx == IDX_PRIV) {
-		if (num <= 3)
-			return NM_SETTING_802_1X_ERROR;
-		else
-			return NM_SETTING_WIRELESS_SECURITY_ERROR;
-	} else if (idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP
-	           || idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP || idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP
-	           || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP || idx == IDX_RSN_PSK_PCCMP_GCCMP)
-		return NM_SETTING_WIRELESS_SECURITY_ERROR;
-	else
-		g_assert_not_reached ();
-}
-
-static guint32
 error_code_for_idx (guint32 idx, guint num)
 {
 	if (idx == IDX_OPEN)
-		return NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY;
+		return NM_CONNECTION_ERROR_INVALID_SETTING;
 	else if (idx == IDX_PRIV) {
 		if (num <= 3)
-			return NM_SETTING_802_1X_ERROR_MISSING_PROPERTY;
+			return NM_CONNECTION_ERROR_MISSING_PROPERTY;
 		else
-			return NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY;
-	} else if (idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP
+			return NM_CONNECTION_ERROR_INVALID_PROPERTY;
+	} else if (   idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP
 	           || idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP || idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP
 	           || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP || idx == IDX_RSN_PSK_PCCMP_GCCMP)
-		return NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY;
+		if (num == 4)
+			return NM_CONNECTION_ERROR_INVALID_PROPERTY;
+		else
+			return NM_CONNECTION_ERROR_INVALID_SETTING;
 	else
 		g_assert_not_reached ();
 }
@@ -664,7 +652,6 @@ test_ap_wpa_eap_connection_1 (gconstpointer data)
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
 	                                 FALSE,
-	                                 error_domain_for_idx (idx, 1),
 	                                 error_code_for_idx (idx, 1));
 }
 
@@ -678,7 +665,6 @@ test_ap_wpa_eap_connection_2 (gconstpointer data)
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
 	                                 TRUE,
-	                                 error_domain_for_idx (idx, 2),
 	                                 error_code_for_idx (idx, 2));
 }
 
@@ -692,7 +678,6 @@ test_ap_wpa_eap_connection_3 (gconstpointer data)
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
 	                                 FALSE,
-	                                 error_domain_for_idx (idx, 3),
 	                                 error_code_for_idx (idx, 3));
 }
 
@@ -706,7 +691,6 @@ test_ap_wpa_eap_connection_4 (gconstpointer data)
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
 	                                 FALSE,
-	                                 error_domain_for_idx (idx, 4),
 	                                 error_code_for_idx (idx, 4));
 }
 
@@ -720,7 +704,6 @@ test_ap_wpa_eap_connection_5 (gconstpointer data)
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
 	                                 FALSE,
-	                                 error_domain_for_idx (idx, 5),
 	                                 error_code_for_idx (idx, 5));
 }
 
@@ -730,7 +713,7 @@ static void
 test_priv_ap_empty_connection (void)
 {
 	NMConnection *src, *expected;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const char *ssid = "blahblah";
 	const KeyData exp_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", 0 },
@@ -742,7 +725,7 @@ test_priv_ap_empty_connection (void)
 	 * connection when completed with an AP with the Privacy bit set.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	success = complete_connection (ssid, bssid,
 	                               NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY,
 	                               NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE,
@@ -765,7 +748,7 @@ test_priv_ap_leap_connection_1 (gconstpointer add_wifi)
 {
 	NMConnection *src, *expected;
 	const char *ssid = "blahblah";
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const char *leap_username = "Bill Smith";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
@@ -784,7 +767,7 @@ test_priv_ap_leap_connection_1 (gconstpointer add_wifi)
 	 * with an AP with the Privacy bit set.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	if (add_wifi)
 		fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
@@ -810,7 +793,7 @@ static void
 test_priv_ap_leap_connection_2 (void)
 {
 	NMConnection *src;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 },
@@ -823,7 +806,7 @@ test_priv_ap_leap_connection_2 (void)
 	 * with an AP with the Privacy bit set.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
 	success = complete_connection ("blahblah", bssid,
@@ -832,7 +815,7 @@ test_priv_ap_leap_connection_2 (void)
 	                               FALSE,
 	                               src, &error);
 	/* We expect failure here, we need a LEAP username */
-	COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY);
 
 	g_object_unref (src);
 }
@@ -844,7 +827,7 @@ test_priv_ap_dynamic_wep_1 (void)
 {
 	NMConnection *src, *expected;
 	const char *ssid = "blahblah";
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 },
@@ -866,7 +849,7 @@ test_priv_ap_dynamic_wep_1 (void)
 	 * Dynamic WEP connection when completed with an AP with the Privacy bit set.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
 	fill_8021x (src, both_8021x);
@@ -892,7 +875,7 @@ test_priv_ap_dynamic_wep_2 (void)
 {
 	NMConnection *src, *expected;
 	const char *ssid = "blahblah";
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 },
 	    { NULL } };
@@ -913,7 +896,7 @@ test_priv_ap_dynamic_wep_2 (void)
 	 * WEP connection when completed with an AP with the Privacy bit set.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
 	fill_8021x (src, both_8021x);
@@ -938,7 +921,7 @@ static void
 test_priv_ap_dynamic_wep_3 (void)
 {
 	NMConnection *src;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", 0 },
 	    { NULL } };
@@ -954,7 +937,7 @@ test_priv_ap_dynamic_wep_3 (void)
 	 * setting is rejected, as 802.1x is incompatible with 'shared' auth.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
 	fill_8021x (src, src_8021x);
@@ -964,7 +947,7 @@ test_priv_ap_dynamic_wep_3 (void)
 	                               FALSE,
 	                               src, &error);
 	/* Expect failure; shared is not compatible with dynamic WEP */
-	COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
 
 	g_object_unref (src);
 }
@@ -982,7 +965,9 @@ test_priv_ap_wpa_psk_connection_1 (void)
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 NULL);
 }
 
 static void
@@ -996,7 +981,9 @@ test_priv_ap_wpa_psk_connection_2 (void)
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 TRUE, NULL);
+	                                 TRUE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 NULL);
 }
 
 static void
@@ -1011,7 +998,9 @@ test_priv_ap_wpa_psk_connection_3 (void)
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 NULL);
 }
 
 static void
@@ -1026,7 +1015,9 @@ test_priv_ap_wpa_psk_connection_4 (void)
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 NULL);
 }
 
 static void
@@ -1041,7 +1032,9 @@ test_priv_ap_wpa_psk_connection_5 (void)
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 NM_802_11_AP_SEC_NONE,
 	                                 NM_802_11_AP_SEC_NONE,
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 NULL);
 }
 
 /*******************************************/
@@ -1051,7 +1044,7 @@ test_wpa_ap_empty_connection (gconstpointer data)
 {
 	guint idx = GPOINTER_TO_UINT (data);
 	NMConnection *src, *expected;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const char *ssid = "blahblah";
 	const KeyData exp_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 },
@@ -1065,7 +1058,7 @@ test_wpa_ap_empty_connection (gconstpointer data)
 	 * or RSN flags.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	success = complete_connection (ssid, bssid,
 	                               NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY,
 	                               wpa_flags_for_idx (idx),
@@ -1089,7 +1082,7 @@ test_wpa_ap_leap_connection_1 (gconstpointer data)
 	guint idx = GPOINTER_TO_UINT (data);
 	NMConnection *src;
 	const char *ssid = "blahblah";
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const char *leap_username = "Bill Smith";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
@@ -1102,7 +1095,7 @@ test_wpa_ap_leap_connection_1 (gconstpointer data)
 	 * rejected since WPA APs (usually) do not support LEAP.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
 	success = complete_connection (ssid, bssid,
@@ -1112,7 +1105,7 @@ test_wpa_ap_leap_connection_1 (gconstpointer data)
 	                               FALSE,
 	                               src, &error);
 	/* Expect failure here; WPA APs don't support old-school LEAP */
-	COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
 
 	g_object_unref (src);
 }
@@ -1124,7 +1117,7 @@ test_wpa_ap_leap_connection_2 (gconstpointer data)
 {
 	guint idx = GPOINTER_TO_UINT (data);
 	NMConnection *src;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 },
@@ -1136,7 +1129,7 @@ test_wpa_ap_leap_connection_2 (gconstpointer data)
 	 * rejected since WPA APs (usually) do not support LEAP.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
 	success = complete_connection ("blahblah", bssid,
@@ -1146,7 +1139,7 @@ test_wpa_ap_leap_connection_2 (gconstpointer data)
 	                               FALSE,
 	                               src, &error);
 	/* We expect failure here, we need a LEAP username */
-	COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
 
 	g_object_unref (src);
 }
@@ -1158,7 +1151,7 @@ test_wpa_ap_dynamic_wep_connection (gconstpointer data)
 {
 	guint idx = GPOINTER_TO_UINT (data);
 	NMConnection *src;
-	const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+	const char *bssid = "01:02:03:04:05:06";
 	const KeyData src_wsec[] = {
 	    { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
 	    { NULL } };
@@ -1169,7 +1162,7 @@ test_wpa_ap_dynamic_wep_connection (gconstpointer data)
 	 * rejected since WPA APs (usually) do not support Dynamic WEP.
 	 */
 
-	src = nm_connection_new ();
+	src = nm_simple_connection_new ();
 	fill_wifi_empty (src);
 	fill_wsec (src, src_wsec);
 	success = complete_connection ("blahblah", bssid,
@@ -1179,7 +1172,7 @@ test_wpa_ap_dynamic_wep_connection (gconstpointer data)
 	                               FALSE,
 	                               src, &error);
 	/* We expect failure here since Dynamic WEP is incompatible with WPA */
-	COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY);
+	COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
 
 	g_object_unref (src);
 }
@@ -1196,13 +1189,15 @@ test_wpa_ap_wpa_psk_connection_1 (gconstpointer data)
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 },
 	    { NULL } };
 
-	expected = nm_connection_new ();
+	expected = nm_simple_connection_new ();
 	fill_wsec (expected, exp_wsec);
 	test_ap_wpa_psk_connection_base (NULL, NULL,
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
-	                                 FALSE, expected);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 expected);
 	g_object_unref (expected);
 }
 
@@ -1216,13 +1211,15 @@ test_wpa_ap_wpa_psk_connection_2 (gconstpointer data)
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 },
 	    { NULL } };
 
-	expected = nm_connection_new ();
+	expected = nm_simple_connection_new ();
 	fill_wsec (expected, exp_wsec);
 	test_ap_wpa_psk_connection_base (NULL, NULL,
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
-	                                 TRUE, expected);
+	                                 TRUE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 expected);
 	g_object_unref (expected);
 }
 
@@ -1236,13 +1233,15 @@ test_wpa_ap_wpa_psk_connection_3 (gconstpointer data)
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 },
 	    { NULL } };
 
-	expected = nm_connection_new ();
+	expected = nm_simple_connection_new ();
 	fill_wsec (expected, exp_wsec);
 	test_ap_wpa_psk_connection_base (NULL, "open",
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
-	                                 FALSE, expected);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 expected);
 	g_object_unref (expected);
 }
 
@@ -1254,7 +1253,9 @@ test_wpa_ap_wpa_psk_connection_4 (gconstpointer data)
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
-	                                 FALSE, NULL);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 NULL);
 }
 
 static void
@@ -1267,13 +1268,15 @@ test_wpa_ap_wpa_psk_connection_5 (gconstpointer data)
 	    { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 },
 	    { NULL } };
 
-	expected = nm_connection_new ();
+	expected = nm_simple_connection_new ();
 	fill_wsec (expected, exp_wsec);
 	test_ap_wpa_psk_connection_base ("wpa-psk", "open",
 	                                 NM_802_11_AP_FLAGS_PRIVACY,
 	                                 wpa_flags_for_idx (idx),
 	                                 rsn_flags_for_idx (idx),
-	                                 FALSE, expected);
+	                                 FALSE,
+	                                 NM_CONNECTION_ERROR_INVALID_PROPERTY,
+	                                 expected);
 	g_object_unref (expected);
 }