Commit 06e3c6d0 authored by Dan Williams's avatar Dan Williams

wifi: make Wi-Fi support a plugin

Make Wi-Fi support a plugin using the new device factory interface.
Provides a 7% size reduction in the core NM binary.

        Before    After
NM:    1154104  1071992  (-7%)
Wi-Fi:       0   110464

(all results from stripped files)
parent b46b28d1
......@@ -186,6 +186,7 @@ valgrind-*.log
/src/tests/test-ip6-config
/src/tests/test-wifi-ap-utils
/src/tests/test-resolvconf-capture
/src/devices/wifi/tests/test-wifi-ap-utils
/src/dnsmasq-manager/tests/test-dnsmasq-utils
/src/dhcp-manager/tests/test-dhcp-dhclient
/src/dhcp-manager/tests/test-dnsmasq-utils
......
......@@ -800,6 +800,8 @@ src/rdisc/tests/Makefile
src/devices/adsl/Makefile
src/devices/wimax/Makefile
src/devices/bluetooth/Makefile
src/devices/wifi/Makefile
src/devices/wifi/tests/Makefile
src/devices/wwan/Makefile
libnm-util/libnm-util.pc
libnm-util/Makefile
......
......@@ -53,9 +53,9 @@ src/devices/nm-device-bond.c
src/devices/nm-device-bridge.c
src/devices/nm-device-ethernet.c
src/devices/nm-device-infiniband.c
src/devices/nm-device-olpc-mesh.c
src/devices/nm-device-team.c
src/devices/nm-device-vlan.c
src/devices/wifi/nm-device-olpc-mesh.c
src/devices/wwan/nm-modem-broadband.c
src/devices/wwan/nm-modem-old.c
src/nm-manager.c
......
......@@ -7,6 +7,7 @@ SUBDIRS = \
devices/adsl \
devices/wwan \
devices/bluetooth \
devices/wifi \
dhcp-manager \
ppp-manager \
settings/plugins
......@@ -78,8 +79,6 @@ nm_sources = \
devices/nm-device-infiniband.h \
devices/nm-device-macvlan.c \
devices/nm-device-macvlan.h \
devices/nm-device-olpc-mesh.c \
devices/nm-device-olpc-mesh.h \
devices/nm-device-private.h \
devices/nm-device-team.c \
devices/nm-device-team.h \
......@@ -91,8 +90,6 @@ nm_sources = \
devices/nm-device-vlan.h \
devices/nm-device-vxlan.c \
devices/nm-device-vxlan.h \
devices/nm-device-wifi.c \
devices/nm-device-wifi.h \
\
dhcp-manager/nm-dhcp-client.c \
dhcp-manager/nm-dhcp-client.h \
......@@ -241,10 +238,6 @@ nm_sources = \
nm-session-utils.h \
nm-sleep-monitor.h \
nm-types.h \
nm-wifi-ap-utils.c \
nm-wifi-ap-utils.h \
nm-wifi-ap.c \
nm-wifi-ap.h \
NetworkManagerUtils.c \
NetworkManagerUtils.h
......@@ -297,13 +290,11 @@ glue_sources = \
nm-device-gre-glue.h \
nm-device-infiniband-glue.h \
nm-device-macvlan-glue.h \
nm-device-olpc-mesh-glue.h \
nm-device-team-glue.h \
nm-device-tun-glue.h \
nm-device-veth-glue.h \
nm-device-vlan-glue.h \
nm-device-vxlan-glue.h \
nm-device-wifi-glue.h \
nm-dhcp4-config-glue.h \
nm-dhcp6-config-glue.h \
nm-ip4-config-glue.h \
......
include $(GLIB_MAKEFILE)
@GNOME_CODE_COVERAGE_RULES@
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 \
-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(DBUS_CFLAGS) \
$(POLKIT_CFLAGS) \
$(LIBNL_CFLAGS) \
$(GUDEV_CFLAGS)
GLIB_GENERATED = nm-wifi-enum-types.h nm-wifi-enum-types.c
GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
nm_wifi_enum_types_sources = \
$(srcdir)/nm-device-wifi.h \
$(srcdir)/nm-wifi-ap.h \
$(srcdir)/nm-device-olpc-mesh.h
glue_sources = \
nm-device-wifi-glue.h \
nm-device-olpc-mesh-glue.h
%-glue.h: $(top_srcdir)/introspection/%.xml
$(AM_V_GEN) dbus-binding-tool --prefix=$(subst -,_,$(subst -glue.h,,$@)) --mode=glib-server --output=$@ $<
BUILT_SOURCES = $(GLIB_GENERATED) $(glue_sources)
pkglib_LTLIBRARIES = libnm-device-plugin-wifi.la
libnm_device_plugin_wifi_la_SOURCES = \
nm-wifi-factory.c \
nm-device-wifi.c \
nm-device-wifi.h \
nm-wifi-ap.c \
nm-wifi-ap.h \
nm-wifi-ap-utils.c \
nm-wifi-ap-utils.h \
nm-device-olpc-mesh.c \
nm-device-olpc-mesh.h \
\
$(BUILT_SOURCES)
SYMBOL_VIS_FILE=$(srcdir)/exports.ver
libnm_device_plugin_wifi_la_LDFLAGS = \
-module -avoid-version \
-Wl,--version-script=$(SYMBOL_VIS_FILE)
libnm_device_plugin_wifi_la_LIBADD = \
$(DBUS_LIBS) \
$(GUDEV_LIBS)
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = $(SYMBOL_VIS_FILE)
if ENABLE_TESTS
check-local:
$(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-wifi.so $(SYMBOL_VIS_FILE)
endif
{
global:
nm_device_factory_create;
nm_device_factory_get_device_type;
local:
*;
};
......@@ -53,6 +53,7 @@
#include "nm-manager.h"
#include "nm-enum-types.h"
#include "nm-dbus-manager.h"
#include "nm-wifi-enum-types.h"
/* This is a bug; but we can't really change API now... */
#include "NetworkManagerVPN.h"
......
......@@ -58,6 +58,8 @@
#include "nm-settings-connection.h"
#include "nm-enum-types.h"
#include "nm-dbus-glib-types.h"
#include "nm-wifi-enum-types.h"
#include "nm-connection-provider.h"
static gboolean impl_device_get_access_points (NMDeviceWifi *device,
......@@ -103,7 +105,6 @@ enum {
enum {
ACCESS_POINT_ADDED,
ACCESS_POINT_REMOVED,
HIDDEN_AP_FOUND,
SCANNING_ALLOWED,
LAST_SIGNAL
......@@ -1748,6 +1749,34 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface,
*
*/
static void
try_fill_ssid_for_hidden_ap (NMAccessPoint *ap)
{
const struct ether_addr *bssid;
const GSList *connections, *iter;
g_return_if_fail (nm_ap_get_ssid (ap) == NULL);
bssid = nm_ap_get_address (ap);
g_assert (bssid);
/* Look for this AP's BSSID in the seen-bssids list of a connection,
* and if a match is found, copy over the SSID */
connections = nm_connection_provider_get_connections (nm_connection_provider_get ());
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingWireless *s_wifi;
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));
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]
......@@ -1777,8 +1806,8 @@ merge_scanned_ap (NMDeviceWifi *self,
bssid = nm_ap_get_address (merge_ap);
ssid = nm_ap_get_ssid (merge_ap);
if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) {
/* Let the manager try to fill the AP's SSID from the database */
g_signal_emit (self, signals[HIDDEN_AP_FOUND], 0, merge_ap);
/* Try to fill the SSID from the AP database */
try_fill_ssid_for_hidden_ap (merge_ap);
ssid = nm_ap_get_ssid (merge_ap);
if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) {
......@@ -3621,15 +3650,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
signals[HIDDEN_AP_FOUND] =
g_signal_new ("hidden-ap-found",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMDeviceWifiClass, hidden_ap_found),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
signals[SCANNING_ALLOWED] =
g_signal_new ("scanning-allowed",
G_OBJECT_CLASS_TYPE (object_class),
......
......@@ -81,7 +81,6 @@ struct _NMDeviceWifiClass
/* Signals */
void (*access_point_added) (NMDeviceWifi *device, NMAccessPoint *ap);
void (*access_point_removed) (NMDeviceWifi *device, NMAccessPoint *ap);
void (*hidden_ap_found) (NMDeviceWifi *device, NMAccessPoint *ap);
gboolean (*scanning_allowed) (NMDeviceWifi *device);
};
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2011 - 2014 Red Hat, Inc.
*/
#include <gmodule.h>
#include "nm-device-factory.h"
#include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h"
#include "nm-settings-connection.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))
typedef struct {
GObject parent;
} NMWifiFactory;
typedef struct {
GObjectClass parent;
} NMWifiFactoryClass;
static GType nm_wifi_factory_get_type (void);
static void device_factory_interface_init (NMDeviceFactory *factory_iface);
G_DEFINE_TYPE_EXTENDED (NMWifiFactory, nm_wifi_factory, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init))
enum {
PROP_0,
PROP_DEVICE_TYPE,
};
/**************************************************************************/
#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 *
new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
{
if (plink->type == NM_LINK_TYPE_WIFI)
return nm_device_wifi_new (plink);
else if (plink->type == NM_LINK_TYPE_OLPC_MESH)
return nm_device_olpc_mesh_new (plink);
return NULL;
}
static void
get_property (GObject *object, guint prop, GValue *value, GParamSpec *pspec)
{
switch (prop) {
case PROP_DEVICE_TYPE:
g_value_set_uint (value, PLUGIN_TYPE);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop, pspec);
break;
}
}
static void
device_factory_interface_init (NMDeviceFactory *factory_iface)
{
factory_iface->new_link = new_link;
}
static void
nm_wifi_factory_init (NMWifiFactory *self)
{
}
static void
nm_wifi_factory_class_init (NMWifiFactoryClass *wf_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (wf_class);
object_class->get_property = get_property;
g_object_class_override_property (object_class,
PROP_DEVICE_TYPE,
NM_DEVICE_FACTORY_DEVICE_TYPE);
}
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)/src \
-I$(top_srcdir)/src/devices/wifi \
-I$(top_builddir)/src \
-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS)
noinst_PROGRAMS = test-wifi-ap-utils
test_wifi_ap_utils_SOURCES = \
test-wifi-ap-utils.c \
$(srcdir)/../nm-wifi-ap.c \
$(srcdir)/../nm-wifi-ap.h \
$(srcdir)/../nm-wifi-ap-utils.c \
$(srcdir)/../nm-wifi-ap-utils.h
test_wifi_ap_utils_LDADD = $(top_builddir)/src/libNetworkManager.la
TESTS = test-wifi-ap-utils
......@@ -41,8 +41,6 @@
#include "nm-vpn-manager.h"
#include "nm-device.h"
#include "nm-device-ethernet.h"
#include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h"
#include "nm-device-infiniband.h"
#include "nm-device-bond.h"
#include "nm-device-team.h"
......@@ -1309,39 +1307,6 @@ manager_update_radio_enabled (NMManager *self,
}
}
static void
manager_hidden_ap_found (NMDevice *device,
NMAccessPoint *ap,
gpointer user_data)
{
NMManager *manager = NM_MANAGER (user_data);
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
const struct ether_addr *bssid;
GSList *iter;
GSList *connections;
gboolean done = FALSE;
g_return_if_fail (nm_ap_get_ssid (ap) == NULL);
bssid = nm_ap_get_address (ap);
g_assert (bssid);
/* Look for this AP's BSSID in the seen-bssids list of a connection,
* and if a match is found, copy over the SSID */
connections = nm_settings_get_connections (priv->settings);
for (iter = connections; iter && !done; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingWireless *s_wifi;
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));
}
}
g_slist_free (connections);
}
static void
update_rstate_from_rfkill (NMRfkillManager *rfkill_mgr, RadioState *rstate)
{
......@@ -1644,11 +1609,8 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con)
NMConnection *connection = NULL;
gboolean enabled = FALSE;
RfKillType rtype;
NMDeviceType devtype;
GSList *iter, *remove = NULL;
devtype = nm_device_get_device_type (device);
/* No duplicates */
if (nm_manager_get_device_by_udi (self, nm_device_get_udi (device)))
return;
......@@ -1689,15 +1651,6 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con)
self);
}
if (devtype == NM_DEVICE_TYPE_WIFI) {
/* Attach to the access-point-added signal so that the manager can fill
* non-SSID-broadcasting APs with an SSID.
*/
g_signal_connect (device, "hidden-ap-found",
G_CALLBACK (manager_hidden_ap_found),
self);
}
/* Update global rfkill state for this device type with the device's
* rfkill state, and then set this device's rfkill state based on the
* global state.
......@@ -2007,12 +1960,6 @@ platform_link_added (NMManager *self,
case NM_LINK_TYPE_INFINIBAND:
device = nm_device_infiniband_new (plink);
break;
case NM_LINK_TYPE_OLPC_MESH:
device = nm_device_olpc_mesh_new (plink);
break;
case NM_LINK_TYPE_WIFI:
device = nm_device_wifi_new (plink);
break;
case NM_LINK_TYPE_BOND:
device = nm_device_bond_new (plink);
break;
......
......@@ -29,7 +29,6 @@
#include "nm-policy.h"
#include "NetworkManagerUtils.h"
#include "nm-wifi-ap.h"
#include "nm-activation-request.h"
#include "nm-logging.h"
#include "nm-device.h"
......
......@@ -16,7 +16,6 @@ AM_CPPFLAGS = \
noinst_PROGRAMS = \
test-dhcp-options \
test-general \
test-wifi-ap-utils \
test-ip4-config \
test-ip6-config \
test-dcb \
......@@ -35,14 +34,6 @@ test_dhcp_options_CPPFLAGS = \
test_dhcp_options_LDADD = \
$(top_builddir)/src/libNetworkManager.la
####### wifi ap utils test #######
test_wifi_ap_utils_SOURCES = \
test-wifi-ap-utils.c
test_wifi_ap_utils_LDADD = \
$(top_builddir)/src/libNetworkManager.la
####### ip4 config test #######
test_ip4_config_SOURCES = \
......@@ -89,5 +80,5 @@ EXTRA_DIST = test-secret-agent.py
###########################################
TESTS = test-dhcp-options test-wifi-ap-utils test-ip4-config test-ip6-config test-dcb test-resolvconf-capture test-general
TESTS = test-dhcp-options test-ip4-config test-ip6-config test-dcb test-resolvconf-capture test-general
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment