diff options
author | Dan Williams <dcbw@redhat.com> | 2014-05-13 15:32:03 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-05-13 15:32:03 -0500 |
commit | c97e1dd507f480e516023f8245e2d324af5a47b0 (patch) | |
tree | a31794ec984f9165a664b10b5289b2de2defc87f | |
parent | 454cc0a1685c2ac9287c8d56af22f83a3c01b252 (diff) | |
parent | 795d1d8a82a45f4097481a99ea82062a48c411fd (diff) | |
download | NetworkManager-c97e1dd507f480e516023f8245e2d324af5a47b0.tar.gz |
merge: device plugin cleanups and symbol visibility (bgo #728432)
https://bugzilla.gnome.org/show_bug.cgi?id=728432
27 files changed, 241 insertions, 304 deletions
diff --git a/src/devices/adsl/Makefile.am b/src/devices/adsl/Makefile.am index a4ec50abf8..0430f47d02 100644 --- a/src/devices/adsl/Makefile.am +++ b/src/devices/adsl/Makefile.am @@ -33,6 +33,8 @@ BUILT_SOURCES = $(GLIB_GENERATED) nm-device-adsl-glue.h pkglib_LTLIBRARIES = libnm-device-plugin-adsl.la +SYMBOL_VIS_FILE=$(srcdir)/exports.ver + libnm_device_plugin_adsl_la_SOURCES = \ nm-atm-manager.c \ nm-atm-manager.h \ @@ -41,10 +43,21 @@ libnm_device_plugin_adsl_la_SOURCES = \ \ $(BUILT_SOURCES) -libnm_device_plugin_adsl_la_LDFLAGS = -module -avoid-version +libnm_device_plugin_adsl_la_LDFLAGS = \ + -module -avoid-version \ + -Wl,--version-script=$(SYMBOL_VIS_FILE) + libnm_device_plugin_adsl_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-adsl.so $(SYMBOL_VIS_FILE) + +endif diff --git a/src/devices/adsl/exports.ver b/src/devices/adsl/exports.ver new file mode 100644 index 0000000000..d2c451244b --- /dev/null +++ b/src/devices/adsl/exports.ver @@ -0,0 +1,7 @@ +{ +global: + nm_device_factory_create; + nm_device_factory_get_device_type; +local: + *; +}; diff --git a/src/devices/adsl/nm-atm-manager.c b/src/devices/adsl/nm-atm-manager.c index 908e961e7d..e8db3596d7 100644 --- a/src/devices/adsl/nm-atm-manager.c +++ b/src/devices/adsl/nm-atm-manager.c @@ -44,12 +44,6 @@ static void device_factory_interface_init (NMDeviceFactory *factory_iface); G_DEFINE_TYPE_EXTENDED (NMAtmManager, nm_atm_manager, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) -enum { - PROP_0, - PROP_DEVICE_TYPE, - LAST_PROP -}; - /**************************************************************************/ #define PLUGIN_TYPE NM_DEVICE_TYPE_ADSL @@ -238,20 +232,6 @@ device_factory_interface_init (NMDeviceFactory *factory_iface) } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case PROP_DEVICE_TYPE: - g_value_set_uint (value, PLUGIN_TYPE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void dispose (GObject *object) { NMAtmManager *self = NM_ATM_MANAGER (object); @@ -283,9 +263,4 @@ nm_atm_manager_class_init (NMAtmManagerClass *klass) /* virtual methods */ object_class->dispose = dispose; - object_class->get_property = get_property; - - g_object_class_override_property (object_class, - PROP_DEVICE_TYPE, - NM_DEVICE_FACTORY_DEVICE_TYPE); } diff --git a/src/devices/bluetooth/Makefile.am b/src/devices/bluetooth/Makefile.am index 22777beeec..639a1ad7a2 100644 --- a/src/devices/bluetooth/Makefile.am +++ b/src/devices/bluetooth/Makefile.am @@ -33,6 +33,8 @@ BUILT_SOURCES = $(GLIB_GENERATED) nm-device-bt-glue.h pkglib_LTLIBRARIES = libnm-device-plugin-bluetooth.la +SYMBOL_VIS_FILE=$(srcdir)/exports.ver + libnm_device_plugin_bluetooth_la_SOURCES = \ nm-bluez-manager.c \ nm-bluez-manager.h \ @@ -51,11 +53,22 @@ libnm_device_plugin_bluetooth_la_SOURCES = \ \ $(BUILT_SOURCES) -libnm_device_plugin_bluetooth_la_LDFLAGS = -module -avoid-version +libnm_device_plugin_bluetooth_la_LDFLAGS = \ + -module -avoid-version \ + -Wl,--version-script=$(SYMBOL_VIS_FILE) + libnm_device_plugin_bluetooth_la_LIBADD = \ $(top_builddir)/src/devices/wwan/libnm-wwan.la \ $(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-bluetooth.so $(SYMBOL_VIS_FILE) + +endif diff --git a/src/devices/bluetooth/exports.ver b/src/devices/bluetooth/exports.ver new file mode 100644 index 0000000000..d2c451244b --- /dev/null +++ b/src/devices/bluetooth/exports.ver @@ -0,0 +1,7 @@ +{ +global: + nm_device_factory_create; + nm_device_factory_get_device_type; +local: + *; +}; diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c index 2857cc4e17..04ffb0a476 100644 --- a/src/devices/bluetooth/nm-bluez-manager.c +++ b/src/devices/bluetooth/nm-bluez-manager.c @@ -58,12 +58,6 @@ static void device_factory_interface_init (NMDeviceFactory *factory_iface); G_DEFINE_TYPE_EXTENDED (NMBluezManager, nm_bluez_manager, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) -enum { - PROP_0, - PROP_DEVICE_TYPE, - LAST_PROP -}; - static void check_bluez_and_try_setup (NMBluezManager *self); /**************************************************************************/ @@ -377,20 +371,6 @@ check_bluez_and_try_setup (NMBluezManager *self) /*********************************************************************/ static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case PROP_DEVICE_TYPE: - g_value_set_uint (value, PLUGIN_TYPE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void dispose (GObject *object) { NMBluezManager *self = NM_BLUEZ_MANAGER (object); @@ -443,11 +423,6 @@ nm_bluez_manager_class_init (NMBluezManagerClass *klass) /* virtual methods */ object_class->dispose = dispose; - object_class->get_property = get_property; object_class->constructed = constructed; - - g_object_class_override_property (object_class, - PROP_DEVICE_TYPE, - NM_DEVICE_FACTORY_DEVICE_TYPE); } diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c index e947b9da8e..fc4d1c248a 100644 --- a/src/devices/nm-device-factory.c +++ b/src/devices/nm-device-factory.c @@ -45,14 +45,6 @@ interface_init (gpointer g_iface) if (G_LIKELY (initialized)) return; - g_object_interface_install_property - (g_iface, - g_param_spec_uint (NM_DEVICE_FACTORY_DEVICE_TYPE, - "Device type", - "Device type", - 0, G_MAXUINT32, NM_DEVICE_TYPE_UNKNOWN, - G_PARAM_READABLE)); - /* Signals */ signals[DEVICE_ADDED] = g_signal_new (NM_DEVICE_FACTORY_DEVICE_ADDED, iface_type, diff --git a/src/devices/nm-device-factory.h b/src/devices/nm-device-factory.h index 45ae77a9fb..f0e3dc1978 100644 --- a/src/devices/nm-device-factory.h +++ b/src/devices/nm-device-factory.h @@ -69,9 +69,6 @@ typedef NMDeviceType (*NMDeviceFactoryDeviceTypeFunc) (void); #define NM_IS_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_FACTORY)) #define NM_DEVICE_FACTORY_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactory)) -/* properties */ -#define NM_DEVICE_FACTORY_DEVICE_TYPE "device-type" - /* signals */ #define NM_DEVICE_FACTORY_COMPONENT_ADDED "component-added" #define NM_DEVICE_FACTORY_DEVICE_ADDED "device-added" diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 9c25fd026a..5631eec571 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -416,7 +416,7 @@ static void find_companion (NMDeviceOlpcMesh *self) { NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); - GSList *list; + const GSList *list; if (priv->companion) return; diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c index e4a140a324..02ad93f46d 100644 --- a/src/devices/wifi/nm-wifi-factory.c +++ b/src/devices/wifi/nm-wifi-factory.c @@ -43,11 +43,6 @@ 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 @@ -77,19 +72,6 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) } 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; @@ -103,12 +85,5 @@ 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); } diff --git a/src/devices/wimax/Makefile.am b/src/devices/wimax/Makefile.am index 3ed5955c08..def8bf62b7 100644 --- a/src/devices/wimax/Makefile.am +++ b/src/devices/wimax/Makefile.am @@ -18,6 +18,8 @@ AM_CPPFLAGS = \ pkglib_LTLIBRARIES = libnm-device-plugin-wimax.la +SYMBOL_VIS_FILE=$(srcdir)/exports.ver + libnm_device_plugin_wimax_la_SOURCES = \ nm-wimax-factory.c \ nm-device-wimax.c \ @@ -30,7 +32,10 @@ libnm_device_plugin_wimax_la_SOURCES = \ iwmxsdk.c \ iwmxsdk.h -libnm_device_plugin_wimax_la_LDFLAGS = -module -avoid-version +libnm_device_plugin_wimax_la_LDFLAGS = \ + -module -avoid-version \ + -Wl,--version-script=$(SYMBOL_VIS_FILE) + libnm_device_plugin_wimax_la_LIBADD = \ $(DBUS_LIBS) \ $(IWMX_SDK_LIBS) \ @@ -47,3 +52,12 @@ BUILT_SOURCES = \ nm-device-wimax-glue.h CLEANFILES = $(BUILT_SOURCES) +EXTRA_DIST = $(SYMBOL_VIS_FILE) + +if ENABLE_TESTS + +check-local: + $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-wimax.so $(SYMBOL_VIS_FILE) + +endif + diff --git a/src/devices/wimax/exports.ver b/src/devices/wimax/exports.ver new file mode 100644 index 0000000000..d2c451244b --- /dev/null +++ b/src/devices/wimax/exports.ver @@ -0,0 +1,7 @@ +{ +global: + nm_device_factory_create; + nm_device_factory_get_device_type; +local: + *; +}; diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index bdf7d9d6e8..4024ba8463 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -123,46 +123,6 @@ nm_wimax_error_quark (void) /***********************************************************/ -guint32 -nm_device_wimax_get_center_frequency (NMDeviceWimax *self) -{ - g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); - - return NM_DEVICE_WIMAX_GET_PRIVATE (self)->center_freq; -} - -gint -nm_device_wimax_get_rssi (NMDeviceWimax *self) -{ - g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); - - return NM_DEVICE_WIMAX_GET_PRIVATE (self)->rssi; -} - -gint -nm_device_wimax_get_cinr (NMDeviceWimax *self) -{ - g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); - - return NM_DEVICE_WIMAX_GET_PRIVATE (self)->cinr; -} - -gint -nm_device_wimax_get_tx_power (NMDeviceWimax *self) -{ - g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); - - return NM_DEVICE_WIMAX_GET_PRIVATE (self)->tx_power; -} - -const char * -nm_device_wimax_get_bsid (NMDeviceWimax *self) -{ - g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), NULL); - - return NM_DEVICE_WIMAX_GET_PRIVATE (self)->bsid; -} - static gboolean impl_device_get_nsp_list (NMDeviceWimax *self, GPtrArray **nsps, GError **error) { @@ -202,14 +162,6 @@ set_current_nsp (NMDeviceWimax *self, NMWimaxNsp *new_nsp) g_object_unref (old_nsp); } -NMWimaxNsp * -nm_device_wimax_get_active_nsp (NMDeviceWimax *self) -{ - g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), NULL); - - return NM_DEVICE_WIMAX_GET_PRIVATE (self)->current_nsp; -} - static gboolean activation_timed_out (gpointer data) { diff --git a/src/devices/wimax/nm-device-wimax.h b/src/devices/wimax/nm-device-wimax.h index 938c8d06c9..8b252ee161 100644 --- a/src/devices/wimax/nm-device-wimax.h +++ b/src/devices/wimax/nm-device-wimax.h @@ -68,18 +68,6 @@ GType nm_device_wimax_get_type (void); NMDevice *nm_device_wimax_new (NMPlatformLink *platform_device); -NMWimaxNsp *nm_device_wimax_get_active_nsp (NMDeviceWimax *self); - -guint nm_device_wimax_get_center_frequency (NMDeviceWimax *self); - -gint nm_device_wimax_get_rssi (NMDeviceWimax *self); - -gint nm_device_wimax_get_cinr (NMDeviceWimax *self); - -gint nm_device_wimax_get_tx_power (NMDeviceWimax *self); - -const char *nm_device_wimax_get_bsid (NMDeviceWimax *self); - G_END_DECLS #endif /* NM_DEVICE_WIMAX_H */ diff --git a/src/devices/wimax/nm-wimax-factory.c b/src/devices/wimax/nm-wimax-factory.c index d5bf57f602..ca962e6866 100644 --- a/src/devices/wimax/nm-wimax-factory.c +++ b/src/devices/wimax/nm-wimax-factory.c @@ -71,24 +71,6 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) return (NMDevice *) nm_device_wimax_new (plink); } -enum { - PROP_0 = 0x1000, - PROP_DEVICE_TYPE, -}; - -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) { @@ -103,12 +85,5 @@ nm_wimax_factory_init (NMWimaxFactory *factory) static void nm_wimax_factory_class_init (NMWimaxFactoryClass *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); } diff --git a/src/devices/wwan/Makefile.am b/src/devices/wwan/Makefile.am index 3740fa4fc9..988f467920 100644 --- a/src/devices/wwan/Makefile.am +++ b/src/devices/wwan/Makefile.am @@ -49,7 +49,11 @@ libnm_wwan_la_SOURCES += \ nm-modem-broadband.h endif -libnm_wwan_la_LDFLAGS = -avoid-version +WWAN_SYMBOL_VIS_FILE=$(srcdir)/wwan-exports.ver + +libnm_wwan_la_LDFLAGS = \ + -avoid-version \ + -Wl,--version-script=$(WWAN_SYMBOL_VIS_FILE) libnm_wwan_la_LIBADD = $(DBUS_LIBS) $(MM_GLIB_LIBS) ########################################################### @@ -59,6 +63,8 @@ nm-device-modem-glue.h: $(top_srcdir)/introspection/nm-device-modem.xml BUILT_SOURCES += nm-device-modem-glue.h +SYMBOL_VIS_FILE=$(srcdir)/exports.ver + libnm_device_plugin_wwan_la_SOURCES = \ nm-wwan-factory.c \ nm-wwan-factory.h \ @@ -66,7 +72,10 @@ libnm_device_plugin_wwan_la_SOURCES = \ nm-device-modem.h \ nm-device-modem-glue.h -libnm_device_plugin_wwan_la_LDFLAGS = -module -avoid-version +libnm_device_plugin_wwan_la_LDFLAGS = \ + -module -avoid-version \ + -Wl,--version-script=$(SYMBOL_VIS_FILE) + libnm_device_plugin_wwan_la_LIBADD = \ libnm-wwan.la \ $(DBUS_LIBS) @@ -74,4 +83,13 @@ libnm_device_plugin_wwan_la_LIBADD = \ ########################################################### CLEANFILES = $(BUILT_SOURCES) +EXTRA_DIST = $(SYMBOL_VIS_FILE) $(WWAN_SYMBOL_VIS_FILE) + +if ENABLE_TESTS + +check-local: + $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-wwan.so $(SYMBOL_VIS_FILE) + $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-wwan.so $(WWAN_SYMBOL_VIS_FILE) + +endif diff --git a/src/devices/wwan/exports.ver b/src/devices/wwan/exports.ver new file mode 100644 index 0000000000..d2c451244b --- /dev/null +++ b/src/devices/wwan/exports.ver @@ -0,0 +1,7 @@ +{ +global: + nm_device_factory_create; + nm_device_factory_get_device_type; +local: + *; +}; diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index b686967ab5..c9a83ca549 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -241,14 +241,6 @@ modem_removed_cb (NMModem *modem, gpointer user_data) /*****************************************************************************/ -NMModem * -nm_device_modem_get_modem (NMDeviceModem *self) -{ - g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NULL); - - return NM_DEVICE_MODEM_GET_PRIVATE (self)->modem; -} - static gboolean owns_iface (NMDevice *device, const char *iface) { diff --git a/src/devices/wwan/nm-device-modem.h b/src/devices/wwan/nm-device-modem.h index 7751ce6bbd..ee6b2988c4 100644 --- a/src/devices/wwan/nm-device-modem.h +++ b/src/devices/wwan/nm-device-modem.h @@ -51,7 +51,4 @@ GType nm_device_modem_get_type (void); NMDevice *nm_device_modem_new (NMModem *modem); -/* Private for subclases */ -NMModem *nm_device_modem_get_modem (NMDeviceModem *self); - #endif /* NM_DEVICE_MODEM_H */ diff --git a/src/devices/wwan/nm-modem-old.c b/src/devices/wwan/nm-modem-old.c index 6bed4cdf8d..70a8acabcf 100644 --- a/src/devices/wwan/nm-modem-old.c +++ b/src/devices/wwan/nm-modem-old.c @@ -169,7 +169,7 @@ mm_state_to_nm (MMOldModemState mm_state, const char *unlock_required) /*****************************************************************************/ -DBusGProxy * +static DBusGProxy * nm_modem_old_get_proxy (NMModemOld *self, const char *interface) { diff --git a/src/devices/wwan/nm-modem-old.h b/src/devices/wwan/nm-modem-old.h index 828da6a6d4..65e3db2d11 100644 --- a/src/devices/wwan/nm-modem-old.h +++ b/src/devices/wwan/nm-modem-old.h @@ -48,9 +48,6 @@ GType nm_modem_old_get_type (void); NMModem *nm_modem_old_new (const char *path, GHashTable *properties, GError **error); -/* Protected */ -DBusGProxy *nm_modem_old_get_proxy (NMModemOld *modem, const gchar *interface); - G_END_DECLS #endif /* NM_MODEM_OLD_H */ diff --git a/src/devices/wwan/nm-wwan-factory.c b/src/devices/wwan/nm-wwan-factory.c index 8a7898942e..b1e2307e6a 100644 --- a/src/devices/wwan/nm-wwan-factory.c +++ b/src/devices/wwan/nm-wwan-factory.c @@ -41,13 +41,6 @@ typedef struct { NMModemManager *mm; } NMWwanFactoryPrivate; -enum { - PROP_0, - PROP_DEVICE_TYPE, - - LAST_PROP -}; - /************************************************************************/ #define PLUGIN_TYPE NM_DEVICE_TYPE_MODEM @@ -119,20 +112,6 @@ device_factory_interface_init (NMDeviceFactory *factory_iface) } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case PROP_DEVICE_TYPE: - g_value_set_uint (value, PLUGIN_TYPE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void dispose (GObject *object) { NMWwanFactory *self = NM_WWAN_FACTORY (object); @@ -154,9 +133,4 @@ nm_wwan_factory_class_init (NMWwanFactoryClass *klass) g_type_class_add_private (object_class, sizeof (NMWwanFactoryPrivate)); object_class->dispose = dispose; - object_class->get_property = get_property; - - g_object_class_override_property (object_class, - PROP_DEVICE_TYPE, - NM_DEVICE_FACTORY_DEVICE_TYPE); } diff --git a/src/devices/wwan/wwan-exports.ver b/src/devices/wwan/wwan-exports.ver new file mode 100644 index 0000000000..e78208a45d --- /dev/null +++ b/src/devices/wwan/wwan-exports.ver @@ -0,0 +1,27 @@ +{ +global: + nm_modem_act_stage1_prepare; + nm_modem_act_stage2_config; + nm_modem_check_connection_compatible; + nm_modem_complete_connection; + nm_modem_deactivate; + nm_modem_device_state_changed; + nm_modem_error_quark; + nm_modem_get_capabilities; + nm_modem_get_control_port; + nm_modem_get_data_port; + nm_modem_get_driver; + nm_modem_get_path; + nm_modem_get_secrets; + nm_modem_get_state; + nm_modem_get_type; + nm_modem_get_uid; + nm_modem_ip4_pre_commit; + nm_modem_owns_port; + nm_modem_set_mm_enabled; + nm_modem_stage3_ip4_config_start; + nm_modem_stage3_ip6_config_start; + nm_modem_state_to_string; +local: + *; +}; diff --git a/src/nm-manager.c b/src/nm-manager.c index dde273923d..43eb2caf85 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1804,6 +1804,7 @@ factory_component_added_cb (NMDeviceFactory *factory, #define PLUGIN_PREFIX "libnm-device-plugin-" #define PLUGIN_PATH_TAG "NMManager-plugin-path" +#define PLUGIN_TYPEFUNC_TAG "typefunc" static void load_device_factories (NMManager *self) @@ -1856,12 +1857,10 @@ load_device_factories (NMManager *self) /* Make sure we don't double-load plugins */ dev_type = type_func (); for (iter = priv->factories; iter; iter = iter->next) { - NMDeviceType t = NM_DEVICE_TYPE_UNKNOWN; + NMDeviceFactoryDeviceTypeFunc loaded_type_func; - g_object_get (G_OBJECT (iter->data), - NM_DEVICE_FACTORY_DEVICE_TYPE, &t, - NULL); - if (dev_type == t) { + loaded_type_func = g_object_get_data (G_OBJECT (iter->data), PLUGIN_TYPEFUNC_TAG); + if (dev_type == loaded_type_func ()) { found = g_object_get_data (G_OBJECT (iter->data), PLUGIN_PATH_TAG); break; } @@ -1902,6 +1901,7 @@ load_device_factories (NMManager *self) self); g_object_set_data_full (G_OBJECT (factory), PLUGIN_PATH_TAG, g_strdup (g_module_name (plugin)), g_free); + g_object_set_data (G_OBJECT (factory), PLUGIN_TYPEFUNC_TAG, type_func); nm_log_info (LOGD_HW, "Loaded device plugin: %s", g_module_name (plugin)); }; @@ -2011,12 +2011,12 @@ platform_link_added (NMManager *self, */ break; + case NM_LINK_TYPE_OLPC_MESH: + case NM_LINK_TYPE_WIFI: case NM_LINK_TYPE_WIMAX: - /* If the WiMAX plugin is not installed, we can't control the - * interface, so ignore it. - */ - break; - + nm_log_info (LOGD_HW, "(%s): '%s' plugin not available; creating generic device", + plink->name, plink->type_name); + /* fall through */ default: device = nm_device_generic_new (plink); break; @@ -2064,7 +2064,7 @@ rfkill_manager_rfkill_changed_cb (NMRfkillManager *rfkill_mgr, nm_manager_rfkill_update (NM_MANAGER (user_data), rtype); } -GSList * +const GSList * nm_manager_get_devices (NMManager *manager) { g_return_val_if_fail (NM_IS_MANAGER (manager), NULL); diff --git a/src/nm-manager.h b/src/nm-manager.h index 1b0865fe0d..81eefc7b00 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -110,7 +110,7 @@ GSList *nm_manager_get_activatable_connections (NMManager *manager); /* Device handling */ -GSList *nm_manager_get_devices (NMManager *manager); +const GSList *nm_manager_get_devices (NMManager *manager); NMDevice *nm_manager_get_device_by_master (NMManager *manager, const char *master, diff --git a/src/nm-policy.c b/src/nm-policy.c index d751606ed8..da56f96d9f 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -95,12 +95,11 @@ static NMDevice * get_best_ip4_device (NMPolicy *self, gboolean fully_activated) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); - GSList *devices, *iter; + const GSList *iter; NMDevice *best = NULL; int best_prio = G_MAXINT; - devices = nm_manager_get_devices (priv->manager); - for (iter = devices; iter; iter = g_slist_next (iter)) { + for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) { NMDevice *dev = NM_DEVICE (iter->data); NMDeviceType devtype = nm_device_get_device_type (dev); NMDeviceState state = nm_device_get_state (dev); @@ -177,12 +176,11 @@ static NMDevice * get_best_ip6_device (NMPolicy *self, gboolean fully_activated) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); - GSList *devices, *iter; + const GSList *iter; NMDevice *best = NULL; int best_prio = G_MAXINT; - devices = nm_manager_get_devices (priv->manager); - for (iter = devices; iter; iter = g_slist_next (iter)) { + for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) { NMDevice *dev = NM_DEVICE (iter->data); NMDeviceType devtype = nm_device_get_device_type (dev); NMDeviceState state = nm_device_get_state (dev); @@ -1814,10 +1812,9 @@ static void schedule_activate_all (NMPolicy *policy) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy); - GSList *iter, *devices; + const GSList *iter; - devices = nm_manager_get_devices (priv->manager); - for (iter = devices; iter; iter = g_slist_next (iter)) + for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) schedule_activate_check (policy, NM_DEVICE (iter->data)); } @@ -1848,11 +1845,10 @@ firewall_update_zone (NMPolicy *policy, NMConnection *connection) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy); NMSettingConnection *s_con = nm_connection_get_setting_connection (connection); - GSList *iter, *devices; + const GSList *iter; - devices = nm_manager_get_devices (priv->manager); /* find dev with passed connection and change zone its interface belongs to */ - for (iter = devices; iter; iter = g_slist_next (iter)) { + for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) { NMDevice *dev = NM_DEVICE (iter->data); if ( (nm_device_get_connection (dev) == connection) @@ -1875,11 +1871,10 @@ firewall_started (NMFirewallManager *manager, NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy); NMConnection *connection; NMSettingConnection *s_con; - GSList *iter, *devices; + const GSList *iter; - devices = nm_manager_get_devices (priv->manager); /* add interface of each device to correct zone */ - for (iter = devices; iter; iter = g_slist_next (iter)) { + for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) { NMDevice *dev = NM_DEVICE (iter->data); connection = nm_device_get_connection (dev); diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 95f9854805..44a119ce05 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -128,8 +128,73 @@ put_nl_addr (void *ptr) } } -/* libnl doesn't use const where due */ -#define nl_addr_build(family, addr, addrlen) nl_addr_build (family, (gpointer) addr, addrlen) +/*******************************************************************/ + +/* wrap the libnl alloc functions and abort on out-of-memory*/ + +static struct nl_addr * +_nm_nl_addr_build (int family, const void *buf, size_t size) +{ + struct nl_addr *addr; + + addr = nl_addr_build (family, (void *) buf, size); + if (!addr) + g_error ("nl_addr_build() failed with out of memory"); + + return addr; +} + +static struct rtnl_link * +_nm_rtnl_link_alloc (int ifindex, const char*name) +{ + struct rtnl_link *rtnllink; + + rtnllink = rtnl_link_alloc (); + if (!rtnllink) + g_error ("rtnl_link_alloc() failed with out of memory"); + + if (ifindex > 0) + rtnl_link_set_ifindex (rtnllink, ifindex); + if (name) + rtnl_link_set_name (rtnllink, name); + return rtnllink; +} + +static struct rtnl_addr * +_nm_rtnl_addr_alloc (int ifindex) +{ + struct rtnl_addr *rtnladdr; + + rtnladdr = rtnl_addr_alloc (); + if (!rtnladdr) + g_error ("rtnl_addr_alloc() failed with out of memory"); + if (ifindex > 0) + rtnl_addr_set_ifindex (rtnladdr, ifindex); + return rtnladdr; +} + +static struct rtnl_route * +_nm_rtnl_route_alloc () +{ + struct rtnl_route *rtnlroute = rtnl_route_alloc (); + + if (!rtnlroute) + g_error ("rtnl_route_alloc() failed with out of memory"); + return rtnlroute; +} + +static struct rtnl_nexthop * +_nm_rtnl_route_nh_alloc () +{ + struct rtnl_nexthop *nexthop; + + nexthop = rtnl_route_nh_alloc (); + if (!nexthop) + g_error ("rtnl_route_nh_alloc () failed with out of memory"); + return nexthop; +} + +/*******************************************************************/ /* rtnl_addr_set_prefixlen fails to update the nl_addr prefixlen */ static void @@ -1754,17 +1819,11 @@ build_rtnl_link (int ifindex, const char *name, NMLinkType type) struct rtnl_link *rtnllink; int nle; - rtnllink = rtnl_link_alloc (); - g_assert (rtnllink); - if (ifindex) - rtnl_link_set_ifindex (rtnllink, ifindex); - if (name) - rtnl_link_set_name (rtnllink, name); + rtnllink = _nm_rtnl_link_alloc (ifindex, name); if (type) { nle = rtnl_link_set_type (rtnllink, type_to_string (type)); g_assert (!nle); } - return (struct nl_object *) rtnllink; } @@ -1913,15 +1972,9 @@ link_get_flags (NMPlatform *platform, int ifindex) static gboolean link_refresh (NMPlatform *platform, int ifindex) { - auto_nl_object struct rtnl_link *rtnllink = rtnl_link_alloc (); - - if (rtnllink) { - rtnl_link_set_ifindex (rtnllink, ifindex); - return refresh_object (platform, (struct nl_object *) rtnllink, FALSE, NM_PLATFORM_REASON_EXTERNAL); - } else - error ("link_refresh failed with out of memory"); + auto_nl_object struct rtnl_link *rtnllink = _nm_rtnl_link_alloc (ifindex, NULL); - return FALSE; + return refresh_object (platform, (struct nl_object *) rtnllink, FALSE, NM_PLATFORM_REASON_EXTERNAL); } static gboolean @@ -1945,10 +1998,7 @@ link_uses_arp (NMPlatform *platform, int ifindex) static gboolean link_change_flags (NMPlatform *platform, int ifindex, unsigned int flags, gboolean value) { - auto_nl_object struct rtnl_link *change = rtnl_link_alloc (); - - g_return_val_if_fail (change != NULL, FALSE); - rtnl_link_set_ifindex (change, ifindex); + auto_nl_object struct rtnl_link *change = _nm_rtnl_link_alloc (ifindex, NULL); if (value) rtnl_link_set_flags (change, flags); @@ -2094,15 +2144,8 @@ link_supports_vlans (NMPlatform *platform, int ifindex) static gboolean link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size_t length) { - auto_nl_object struct rtnl_link *change = NULL; - auto_nl_addr struct nl_addr *nladdr = NULL; - - change = rtnl_link_alloc (); - g_return_val_if_fail (change, FALSE); - rtnl_link_set_ifindex (change, ifindex); - - nladdr = nl_addr_build (AF_LLC, address, length); - g_return_val_if_fail (nladdr, FALSE); + auto_nl_object struct rtnl_link *change = _nm_rtnl_link_alloc (ifindex, NULL); + auto_nl_addr struct nl_addr *nladdr = _nm_nl_addr_build (AF_LLC, address, length); rtnl_link_set_addr (change, nladdr); @@ -2133,12 +2176,9 @@ link_get_address (NMPlatform *platform, int ifindex, size_t *length) static gboolean link_set_mtu (NMPlatform *platform, int ifindex, guint32 mtu) { - auto_nl_object struct rtnl_link *change = rtnl_link_alloc (); + auto_nl_object struct rtnl_link *change = _nm_rtnl_link_alloc (ifindex, NULL); - g_return_val_if_fail (change != NULL, FALSE); - rtnl_link_set_ifindex (change, ifindex); rtnl_link_set_mtu (change, mtu); - debug ("link: change %d: mtu %lu", ifindex, (unsigned long)mtu); return link_change (platform, ifindex, change); @@ -2244,13 +2284,9 @@ vlan_set_egress_map (NMPlatform *platform, int ifindex, int from, int to) static gboolean link_enslave (NMPlatform *platform, int master, int slave) { - auto_nl_object struct rtnl_link *change = rtnl_link_alloc (); - - g_return_val_if_fail (change != NULL, FALSE); + auto_nl_object struct rtnl_link *change = _nm_rtnl_link_alloc (slave, NULL); - rtnl_link_set_ifindex (change, slave); rtnl_link_set_master (change, master); - debug ("link: change %d: enslave to master %d", slave, master); return link_change (platform, slave, change); @@ -2374,10 +2410,9 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key) g_free (path); if (success) { - auto_nl_object struct rtnl_link *rtnllink = rtnl_link_alloc (); auto_g_free char *ifname = g_strdup_printf ("%s.%04x", parent_name, p_key); + auto_nl_object struct rtnl_link *rtnllink = _nm_rtnl_link_alloc (0, ifname); - rtnl_link_set_name (rtnllink, ifname); success = refresh_object (platform, (struct nl_object *) rtnllink, FALSE, NM_PLATFORM_REASON_INTERNAL); } @@ -2975,17 +3010,18 @@ build_rtnl_addr (int family, guint flags, const char *label) { - struct rtnl_addr *rtnladdr = rtnl_addr_alloc (); + auto_nl_addr struct rtnl_addr *rtnladdr = _nm_rtnl_addr_alloc (ifindex); + struct rtnl_addr *rtnladdr_copy; int addrlen = family == AF_INET ? sizeof (in_addr_t) : sizeof (struct in6_addr); - auto_nl_addr struct nl_addr *nladdr = nl_addr_build (family, addr, addrlen); + auto_nl_addr struct nl_addr *nladdr = _nm_nl_addr_build (family, addr, addrlen); int nle; - g_assert (rtnladdr && nladdr); - /* IP address */ - rtnl_addr_set_ifindex (rtnladdr, ifindex); nle = rtnl_addr_set_local (rtnladdr, nladdr); - g_assert (!nle); + if (nle) { + error ("build_rtnl_addr(): rtnl_addr_set_local failed with %s (%d)", nl_geterror (nle), nle); + return NULL; + } /* Tighten scope (IPv4 only) */ if (family == AF_INET && ip4_is_link_local (addr)) @@ -2997,18 +3033,21 @@ build_rtnl_addr (int family, auto_nl_addr struct nl_addr *bcaddr = NULL; bcast = *((in_addr_t *) addr) | ~nm_utils_ip4_prefix_to_netmask (plen); - bcaddr = nl_addr_build (family, &bcast, addrlen); + bcaddr = _nm_nl_addr_build (family, &bcast, addrlen); g_assert (bcaddr); rtnl_addr_set_broadcast (rtnladdr, bcaddr); } /* Peer/point-to-point address */ if (peer_addr) { - auto_nl_addr struct nl_addr *nlpeer = nl_addr_build (family, peer_addr, addrlen); + auto_nl_addr struct nl_addr *nlpeer = _nm_nl_addr_build (family, peer_addr, addrlen); nle = rtnl_addr_set_peer (rtnladdr, nlpeer); - /* IPv6 doesn't support peer addresses yet */ - g_assert (!nle || (nle == -NLE_AF_NOSUPPORT)); + if (nle && nle != -NLE_AF_NOSUPPORT) { + /* IPv6 doesn't support peer addresses yet */ + error ("build_rtnl_addr(): rtnl_addr_set_peer failed with %s (%d)", nl_geterror (nle), nle); + return NULL; + } } rtnl_addr_set_prefixlen (rtnladdr, plen); @@ -3032,7 +3071,9 @@ build_rtnl_addr (int family, if (label && *label) rtnl_addr_set_label (rtnladdr, label); - return (struct nl_object *) rtnladdr; + rtnladdr_copy = rtnladdr; + rtnladdr = NULL; + return (struct nl_object *) rtnladdr_copy; } static gboolean @@ -3188,30 +3229,29 @@ static struct nl_object * build_rtnl_route (int family, int ifindex, gconstpointer network, int plen, gconstpointer gateway, int metric, int mss) { guint32 network_clean[4]; - struct rtnl_route *rtnlroute = rtnl_route_alloc (); - struct rtnl_nexthop *nexthop = rtnl_route_nh_alloc (); + struct rtnl_route *rtnlroute; + struct rtnl_nexthop *nexthop; int addrlen = (family == AF_INET) ? sizeof (in_addr_t) : sizeof (struct in6_addr); /* Workaround a libnl bug by using zero destination address length for default routes */ auto_nl_addr struct nl_addr *dst = NULL; - auto_nl_addr struct nl_addr *gw = gateway ? nl_addr_build (family, gateway, addrlen) : NULL; + auto_nl_addr struct nl_addr *gw = gateway ? _nm_nl_addr_build (family, gateway, addrlen) : NULL; /* There seem to be problems adding a route with non-zero host identifier. * Adding IPv6 routes is simply ignored, without error message. * In the IPv4 case, we got an error. Thus, we have to make sure, that * the address is sane. */ clear_host_address (family, network, plen, network_clean); - dst = nl_addr_build (family, network_clean, plen ? addrlen : 0); - - g_assert (rtnlroute && dst && nexthop); - + dst = _nm_nl_addr_build (family, network_clean, plen ? addrlen : 0); nl_addr_set_prefixlen (dst, plen); + rtnlroute = _nm_rtnl_route_alloc (); rtnl_route_set_table (rtnlroute, RT_TABLE_MAIN); rtnl_route_set_tos (rtnlroute, 0); rtnl_route_set_dst (rtnlroute, dst); rtnl_route_set_priority (rtnlroute, metric); rtnl_route_set_family (rtnlroute, family); + nexthop = _nm_rtnl_route_nh_alloc (); rtnl_route_nh_set_ifindex (nexthop, ifindex); if (gw && !nl_addr_iszero (gw)) rtnl_route_nh_set_gateway (nexthop, gw); |