diff options
author | Thomas Haller <thaller@redhat.com> | 2016-11-20 20:24:51 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-11-21 00:17:11 +0100 |
commit | e27d9b2a0fe36ff252fd4aa66b21d14e6a802d04 (patch) | |
tree | 2428b0a0773f17f18ee250331196c870931d77be | |
parent | 9e2b28a4c69b8e74bfad8e03b77cf72e24921966 (diff) | |
download | NetworkManager-bg/ppp-manager-split-bgo773482.tar.gz |
fixup! ppp: split ppp manager into a pluginbg/ppp-manager-split-bgo773482
IMO NMManager/nm_manager_ppp_*() should be avoided,
because NMManager is already overly complicated.
The nm_manager_ppp_*() API is really independent from
NMManager. E.g., somebody could use nm_ppp_manager_*()
API without a NMManager instance.
also,
if (priv->ppp_manager) {
g_signal_handlers_disconnect_by_func (priv->ppp_manager, G_CALLBACK (ppp_state_changed), self);
g_signal_handlers_disconnect_by_func (priv->ppp_manager, G_CALLBACK (ppp_ip4_config), self);
- nm_manager_ppp_stop_sync (nm_manager_get (), priv->ppp_manager);
+ nm_ppp_manager_stop_sync (priv->ppp_manager);
g_clear_object (&priv->ppp_manager);
}
makes me wonder who guarantees that nm_manager_get() has a large enough
lifetime. That can be avoided.
-rw-r--r-- | Makefile.am | 13 | ||||
-rw-r--r-- | src/devices/adsl/nm-device-adsl.c | 8 | ||||
-rw-r--r-- | src/devices/nm-device-ethernet.c | 9 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem.c | 11 | ||||
-rw-r--r-- | src/nm-manager.c | 126 | ||||
-rw-r--r-- | src/nm-manager.h | 21 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-manager-call.c | 142 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-manager-call.h | 43 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-manager.c | 63 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-manager.h | 15 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-plugin-api.h (renamed from src/ppp-manager/nm-ppp-plugin.h) | 32 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-status.h | 43 | ||||
-rw-r--r-- | src/ppp-manager/nm-pppd-plugin.c | 2 |
13 files changed, 300 insertions, 228 deletions
diff --git a/Makefile.am b/Makefile.am index bdce69d1ba..652249bb2e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -898,7 +898,6 @@ src_cppflags = \ -I$(top_srcdir)/src/dnsmasq-manager \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/platform/wifi \ - -I$(top_srcdir)/src/ppp-manager \ -I$(top_srcdir)/src/ndisc \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/src/supplicant-manager \ @@ -1254,6 +1253,12 @@ src_libNetworkManager_la_SOURCES = \ src/dnsmasq-manager/nm-dnsmasq-utils.c \ src/dnsmasq-manager/nm-dnsmasq-utils.h \ \ + src/ppp-manager/nm-ppp-manager-call.c \ + src/ppp-manager/nm-ppp-manager-call.h \ + src/ppp-manager/nm-ppp-manager.h \ + src/ppp-manager/nm-ppp-plugin-api.h \ + src/ppp-manager/nm-ppp-status.h \ + \ src/settings/nm-agent-manager.c \ src/settings/nm-agent-manager.h \ src/settings/nm-inotify-helper.c \ @@ -1514,7 +1519,7 @@ src_ppp_manager_nm_pppd_plugin_la_CPPFLAGS = \ src_ppp_manager_nm_pppd_plugin_la_SOURCES = \ src/ppp-manager/nm-pppd-plugin.c \ src/ppp-manager/nm-pppd-plugin.h \ - src/ppp-manager/nm-ppp-plugin.h + src/ppp-manager/nm-ppp-status.h src_ppp_manager_nm_pppd_plugin_la_LDFLAGS = \ -module -avoid-version @@ -1524,9 +1529,11 @@ src_ppp_manager_nm_pppd_plugin_la_LIBADD = \ $(DL_LIBS) src_ppp_manager_libnm_ppp_plugin_la_SOURCES = \ + src/ppp-manager/nm-pppd-plugin.h \ src/ppp-manager/nm-ppp-manager.c \ src/ppp-manager/nm-ppp-manager.h \ - src/ppp-manager/nm-ppp-plugin.h + src/ppp-manager/nm-ppp-plugin-api.h \ + src/ppp-manager/nm-ppp-status.h EXTRA_src_ppp_manager_nm_ppp_plugin_la_DEPENDENCIES = \ src/ppp-manager/nm-ppp-plugin.ver diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index f659299b3b..a42d770678 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -37,6 +37,8 @@ #include "nm-manager.h" #include "nm-setting-adsl.h" #include "nm-utils.h" +#include "ppp-manager/nm-ppp-status.h" +#include "ppp-manager/nm-ppp-manager-call.h" #include "nmdbus-device-adsl.h" @@ -476,9 +478,9 @@ act_stage3_ip4_config_start (NMDevice *device, _LOGD (LOGD_ADSL, "starting PPPoA"); } - priv->ppp_manager = nm_manager_ppp_create (nm_manager_get (), ppp_iface, &err); + priv->ppp_manager = nm_ppp_manager_create (ppp_iface, &err); if ( priv->ppp_manager - && nm_manager_ppp_start (nm_manager_get (), priv->ppp_manager, req, + && nm_ppp_manager_start (priv->ppp_manager, req, nm_setting_adsl_get_username (s_adsl), 30, 0, &err)) { g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED, @@ -508,7 +510,7 @@ adsl_cleanup (NMDeviceAdsl *self) if (priv->ppp_manager) { g_signal_handlers_disconnect_by_func (priv->ppp_manager, G_CALLBACK (ppp_state_changed), self); g_signal_handlers_disconnect_by_func (priv->ppp_manager, G_CALLBACK (ppp_ip4_config), self); - nm_manager_ppp_stop_sync (nm_manager_get (), priv->ppp_manager); + nm_ppp_manager_stop_sync (priv->ppp_manager); g_clear_object (&priv->ppp_manager); } diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index a75a8c8878..3072e2cedc 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -48,6 +48,8 @@ #include "nm-settings.h" #include "nm-device-factory.h" #include "nm-core-internal.h" +#include "ppp-manager/nm-ppp-status.h" +#include "ppp-manager/nm-ppp-manager-call.h" #include "NetworkManagerUtils.h" #include "nmdbus-device-ethernet.h" @@ -931,11 +933,10 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE); g_assert (s_pppoe); - priv->ppp_manager = nm_manager_ppp_create (nm_manager_get (), - nm_device_get_iface (NM_DEVICE (self)), + priv->ppp_manager = nm_ppp_manager_create (nm_device_get_iface (NM_DEVICE (self)), &err); if ( priv->ppp_manager - && nm_manager_ppp_start (nm_manager_get(), priv->ppp_manager, req, + && nm_ppp_manager_start (priv->ppp_manager, req, nm_setting_pppoe_get_username (s_pppoe), 30, 0, &err)) { g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED, @@ -1315,7 +1316,7 @@ deactivate (NMDevice *device) } if (priv->ppp_manager) { - nm_manager_ppp_stop_sync (nm_manager_get (), priv->ppp_manager); + nm_ppp_manager_stop_sync (priv->ppp_manager); g_clear_object (&priv->ppp_manager); } diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index bd42f5d47d..2b050b21af 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -38,6 +38,8 @@ #include "nm-act-request.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" +#include "ppp-manager/nm-ppp-status.h" +#include "ppp-manager/nm-ppp-manager-call.h" /*****************************************************************************/ @@ -559,9 +561,9 @@ ppp_stage3_ip_config_start (NMModem *self, if (port_speed_is_zero (priv->data_port)) baud_override = 57600; - priv->ppp_manager = nm_manager_ppp_create (nm_manager_get (), priv->data_port, &error); + priv->ppp_manager = nm_ppp_manager_create (priv->data_port, &error); if ( priv->ppp_manager - && nm_manager_ppp_start (nm_manager_get (), priv->ppp_manager, req, ppp_name, + && nm_ppp_manager_start (priv->ppp_manager, req, ppp_name, ip_timeout, baud_override, &error)) { g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED, G_CALLBACK (ppp_state_changed), @@ -1095,7 +1097,7 @@ ppp_manager_stop_ready (NMPPPManager *ppp_manager, { GError *error = NULL; - if (!nm_manager_ppp_stop_finish (nm_manager_get (), ppp_manager, res, &error)) { + if (!nm_ppp_manager_stop_finish (ppp_manager, res, &error)) { nm_log_warn (LOGD_MB, "(%s): cannot stop PPP manager: %s", nm_modem_get_uid (ctx->self), error->message); @@ -1139,8 +1141,7 @@ deactivate_step (DeactivateContext *ctx) case DEACTIVATE_CONTEXT_STEP_PPP_MANAGER_STOP: /* If we have a PPP manager, stop it */ if (ctx->ppp_manager) { - nm_manager_ppp_stop_async (nm_manager_get (), - ctx->ppp_manager, + nm_ppp_manager_stop_async (ctx->ppp_manager, ctx->cancellable, (GAsyncReadyCallback) ppp_manager_stop_ready, ctx); diff --git a/src/nm-manager.c b/src/nm-manager.c index a106a7ac93..e6b60d1863 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -59,8 +59,6 @@ #include "nmdbus-manager.h" #include "nmdbus-device.h" -#define PPP_PLUGIN_PATH NMPLUGINDIR "/libnm-ppp-plugin.so" - static gboolean add_device (NMManager *self, NMDevice *device, GError **error); static NMActiveConnection *_new_active_connection (NMManager *self, @@ -151,7 +149,6 @@ typedef struct { gboolean startup; gboolean devices_inited; - NMPPPOps *ppp_ops; } NMManagerPrivate; struct _NMManager { @@ -5592,129 +5589,6 @@ nm_manager_set_capability (NMManager *self, /*****************************************************************************/ -NMPPPManager * -nm_manager_ppp_create (NMManager *self, const char *iface, GError **error) -{ - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); - NMPPPManager *ret; - GModule *plugin; - GError *error_local = NULL; - NMPPPOps *ops; - struct stat st; - int errsv; - - if (!priv->ppp_ops) { - if (stat (PPP_PLUGIN_PATH, &st) != 0) { - errsv = errno; - g_set_error_literal (error, - NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, - "the PPP plugin " PPP_PLUGIN_PATH " is not installed"); - return NULL; - } - - if (!nm_utils_validate_plugin (PPP_PLUGIN_PATH, &st, &error_local)) { - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, - "could not load the PPP plugin " PPP_PLUGIN_PATH ": %s", - error_local->message); - g_clear_error (&error_local); - return NULL; - } - - plugin = g_module_open (PPP_PLUGIN_PATH, G_MODULE_BIND_LOCAL); - if (!plugin) { - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, - "could not load the PPP plugin " PPP_PLUGIN_PATH ": %s", - g_module_error ()); - return NULL; - } - - if (!g_module_symbol (plugin, "ppp_ops", (gpointer) &ops)) { - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, - "error loading the PPP plugin: %s", g_module_error ()); - return NULL; - } - - /* after loading glib types from the plugin, we cannot unload the library anymore. - * Make it resident. */ - g_module_make_resident (plugin); - - nm_assert (ops); - nm_assert (ops->create); - nm_assert (ops->start); - nm_assert (ops->stop_async); - nm_assert (ops->stop_finish); - nm_assert (ops->stop_sync); - - priv->ppp_ops = ops; - } - - _LOGI (LOGD_CORE | LOGD_PPP, "loaded PPP plugin " PPP_PLUGIN_PATH); - - ret = priv->ppp_ops->create (iface); - if (!ret) { - g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, - "the PPP plugin failed to create a PPP instance"); - return NULL; - } - - return ret; -} - -gboolean -nm_manager_ppp_start (NMManager *self, - NMPPPManager *ppp_manager, - NMActRequest *req, - const char *ppp_name, - guint32 timeout_secs, - guint baud_override, - GError **err) -{ - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); - - g_return_val_if_fail (priv->ppp_ops, FALSE); - - return priv->ppp_ops->start (ppp_manager, req, ppp_name, timeout_secs, baud_override, err); -} - -void -nm_manager_ppp_stop_async (NMManager *self, - NMPPPManager *ppp_manager, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); - - g_return_if_fail (priv->ppp_ops); - - priv->ppp_ops->stop_async (ppp_manager, cancellable, callback, user_data); -} - -gboolean -nm_manager_ppp_stop_finish (NMManager *self, - NMPPPManager *ppp_manager, - GAsyncResult *res, - GError **error) -{ - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); - - g_return_val_if_fail (priv->ppp_ops, FALSE); - - return priv->ppp_ops->stop_finish (ppp_manager, res, error); -} - -void -nm_manager_ppp_stop_sync (NMManager *self, NMPPPManager *ppp_manager) -{ - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); - - g_return_if_fail (priv->ppp_ops); - - priv->ppp_ops->stop_sync (ppp_manager); -} - -/*****************************************************************************/ - NM_DEFINE_SINGLETON_REGISTER (NMManager); NMManager * diff --git a/src/nm-manager.h b/src/nm-manager.h index 14e385c48f..90041ccd7d 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -24,7 +24,6 @@ #include "nm-exported-object.h" #include "nm-settings-connection.h" -#include "ppp-manager/nm-ppp-plugin.h" #define NM_TYPE_MANAGER (nm_manager_get_type ()) #define NM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MANAGER, NMManager)) @@ -119,24 +118,4 @@ gboolean nm_manager_deactivate_connection (NMManager *manager, void nm_manager_set_capability (NMManager *self, NMCapability cap); -NMPPPManager * nm_manager_ppp_create (NMManager *self, const char *iface, GError **error); -gboolean nm_manager_ppp_start (NMManager *self, - NMPPPManager *ppp_manager, - NMActRequest *req, - const char *ppp_name, - guint32 timeout_secs, - guint baud_override, - GError **error); -void nm_manager_ppp_stop_async (NMManager *self, - NMPPPManager *ppp_manager, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean nm_manager_ppp_stop_finish (NMManager *self, - NMPPPManager *ppp_manager, - GAsyncResult *res, - GError **error); -void nm_manager_ppp_stop_sync (NMManager *self, - NMPPPManager *ppp_manager); - #endif /* __NETWORKMANAGER_MANAGER_H__ */ diff --git a/src/ppp-manager/nm-ppp-manager-call.c b/src/ppp-manager/nm-ppp-manager-call.c new file mode 100644 index 0000000000..d67c0a99ce --- /dev/null +++ b/src/ppp-manager/nm-ppp-manager-call.c @@ -0,0 +1,142 @@ +/* -*- 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) 2016 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-ppp-manager-call.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> + +#include "nm-manager.h" +#include "nm-core-utils.h" +#include "nm-ppp-plugin-api.h" + +#define PPP_PLUGIN_PATH NMPLUGINDIR "/libnm-ppp-plugin.so" + +/*****************************************************************************/ + +static NMPPPOps *ppp_ops = NULL; + +NMPPPManager * +nm_ppp_manager_create (const char *iface, GError **error) +{ + NMPPPManager *ret; + GModule *plugin; + GError *error_local = NULL; + NMPPPOps *ops; + struct stat st; + int errsv; + + if (G_UNLIKELY (!ppp_ops)) { + if (stat (PPP_PLUGIN_PATH, &st) != 0) { + errsv = errno; + g_set_error_literal (error, + NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, + "the PPP plugin " PPP_PLUGIN_PATH " is not installed"); + return NULL; + } + + if (!nm_utils_validate_plugin (PPP_PLUGIN_PATH, &st, &error_local)) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, + "could not load the PPP plugin " PPP_PLUGIN_PATH ": %s", + error_local->message); + g_clear_error (&error_local); + return NULL; + } + + plugin = g_module_open (PPP_PLUGIN_PATH, G_MODULE_BIND_LOCAL); + if (!plugin) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, + "could not load the PPP plugin " PPP_PLUGIN_PATH ": %s", + g_module_error ()); + return NULL; + } + + if (!g_module_symbol (plugin, "ppp_ops", (gpointer) &ops)) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, + "error loading the PPP plugin: %s", g_module_error ()); + return NULL; + } + + /* after loading glib types from the plugin, we cannot unload the library anymore. + * Make it resident. */ + g_module_make_resident (plugin); + + nm_assert (ops); + nm_assert (ops->create); + nm_assert (ops->start); + nm_assert (ops->stop_async); + nm_assert (ops->stop_finish); + nm_assert (ops->stop_sync); + + ppp_ops = ops; + + nm_log_info (LOGD_CORE | LOGD_PPP, "loaded PPP plugin " PPP_PLUGIN_PATH); + } + + ret = ppp_ops->create (iface); + g_return_val_if_fail (ret, NULL); + return ret; +} + +gboolean +nm_ppp_manager_start (NMPPPManager *self, + NMActRequest *req, + const char *ppp_name, + guint32 timeout_secs, + guint baud_override, + GError **err) +{ + g_return_val_if_fail (ppp_ops, FALSE); + + return ppp_ops->start (self, req, ppp_name, timeout_secs, baud_override, err); +} + +void +nm_ppp_manager_stop_async (NMPPPManager *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (ppp_ops); + + ppp_ops->stop_async (self, cancellable, callback, user_data); +} + +gboolean +nm_ppp_manager_stop_finish (NMPPPManager *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (ppp_ops, FALSE); + + return ppp_ops->stop_finish (self, res, error); +} + +void +nm_ppp_manager_stop_sync (NMPPPManager *self) +{ + g_return_if_fail (ppp_ops); + + ppp_ops->stop_sync (self); +} + diff --git a/src/ppp-manager/nm-ppp-manager-call.h b/src/ppp-manager/nm-ppp-manager-call.h new file mode 100644 index 0000000000..f21005f0fd --- /dev/null +++ b/src/ppp-manager/nm-ppp-manager-call.h @@ -0,0 +1,43 @@ +/* -*- 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) 2016 Red Hat, Inc. + */ + +#ifndef __NM_PPP_MANAGER_CALL_H__ +#define __NM_PPP_MANAGER_CALL_H__ + +#include "nm-ppp-manager.h" + +NMPPPManager * nm_ppp_manager_create (const char *iface, + GError **error); +gboolean nm_ppp_manager_start (NMPPPManager *self, + NMActRequest *req, + const char *ppp_name, + guint32 timeout_secs, + guint baud_override, + GError **error); +void nm_ppp_manager_stop_async (NMPPPManager *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean nm_ppp_manager_stop_finish (NMPPPManager *self, + GAsyncResult *res, + GError **error); +void nm_ppp_manager_stop_sync (NMPPPManager *self); + +#endif /* __NM_PPP_MANAGER_CALL_H__ */ diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index 23a9b6fc0f..eebc48ecea 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -49,8 +49,10 @@ #include "nm-act-request.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" + #include "nm-pppd-plugin.h" -#include "nm-ppp-plugin.h" +#include "nm-ppp-plugin-api.h" +#include "nm-ppp-status.h" #include "nmdbus-ppp-manager.h" @@ -59,6 +61,17 @@ /*****************************************************************************/ +#define NM_TYPE_PPP_MANAGER (nm_ppp_manager_get_type ()) +#define NM_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PPP_MANAGER, NMPPPManager)) +#define NM_PPP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PPP_MANAGER, NMPPPManagerClass)) +#define NM_IS_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PPP_MANAGER)) +#define NM_IS_PPP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_PPP_MANAGER)) +#define NM_PPP_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PPP_MANAGER, NMPPPManagerClass)) + +GType nm_ppp_manager_get_type (void); + +/*****************************************************************************/ + enum { STATE_CHANGED, IP4_CONFIG, @@ -98,11 +111,9 @@ struct _NMPPPManager { NMPPPManagerPrivate _priv; }; -struct _NMPPPManagerClass { +typedef struct { NMExportedObjectClass parent; -}; - -GType nm_ppp_manager_get_type (void); +} NMPPPManagerClass; G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_EXPORTED_OBJECT) @@ -890,12 +901,12 @@ pppoe_fill_defaults (NMSettingPpp *setting) } static gboolean -nm_ppp_manager_start (NMPPPManager *manager, - NMActRequest *req, - const char *ppp_name, - guint32 timeout_secs, - guint baud_override, - GError **err) +_ppp_manager_start (NMPPPManager *manager, + NMActRequest *req, + const char *ppp_name, + guint32 timeout_secs, + guint baud_override, + GError **err) { NMPPPManagerPrivate *priv; NMConnection *connection; @@ -1058,9 +1069,9 @@ stop_context_complete_if_cancelled (StopContext *ctx) } static gboolean -nm_ppp_manager_stop_finish (NMPPPManager *manager, - GAsyncResult *res, - GError **error) +_ppp_manager_stop_finish (NMPPPManager *manager, + GAsyncResult *res, + GError **error) { return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); } @@ -1077,10 +1088,10 @@ kill_child_ready (pid_t pid, } static void -nm_ppp_manager_stop_async (NMPPPManager *manager, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +_ppp_manager_stop_async (NMPPPManager *manager, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); StopContext *ctx; @@ -1092,7 +1103,7 @@ nm_ppp_manager_stop_async (NMPPPManager *manager, ctx->result = g_simple_async_result_new (G_OBJECT (manager), callback, user_data, - nm_ppp_manager_stop_async); + _ppp_manager_stop_async); /* Setup cancellable */ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL; @@ -1120,7 +1131,7 @@ nm_ppp_manager_stop_async (NMPPPManager *manager, } static void -nm_ppp_manager_stop_sync (NMPPPManager *manager) +_ppp_manager_stop_sync (NMPPPManager *manager) { NMExportedObject *exported = NM_EXPORTED_OBJECT (manager); @@ -1175,7 +1186,7 @@ nm_ppp_manager_init (NMPPPManager *manager) } static NMPPPManager * -nm_ppp_manager_new (const char *iface) +_ppp_manager_new (const char *iface) { g_return_val_if_fail (iface != NULL, NULL); @@ -1277,9 +1288,9 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class) } NMPPPOps ppp_ops = { - .create = nm_ppp_manager_new, - .start = nm_ppp_manager_start, - .stop_async = nm_ppp_manager_stop_async, - .stop_finish = nm_ppp_manager_stop_finish, - .stop_sync = nm_ppp_manager_stop_sync, + .create = _ppp_manager_new, + .start = _ppp_manager_start, + .stop_async = _ppp_manager_stop_async, + .stop_finish = _ppp_manager_stop_finish, + .stop_sync = _ppp_manager_stop_sync, }; diff --git a/src/ppp-manager/nm-ppp-manager.h b/src/ppp-manager/nm-ppp-manager.h index db26a86bb3..a86fe26ae5 100644 --- a/src/ppp-manager/nm-ppp-manager.h +++ b/src/ppp-manager/nm-ppp-manager.h @@ -19,19 +19,12 @@ * Copyright (C) 2008 - 2016 Red Hat, Inc. */ -#ifndef __NETWORKMANAGER_PPP_MANAGER_H__ -#define __NETWORKMANAGER_PPP_MANAGER_H__ - -#define NM_TYPE_PPP_MANAGER (nm_ppp_manager_get_type ()) -#define NM_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PPP_MANAGER, NMPPPManager)) -#define NM_PPP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PPP_MANAGER, NMPPPManagerClass)) -#define NM_IS_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PPP_MANAGER)) -#define NM_IS_PPP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_PPP_MANAGER)) -#define NM_PPP_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PPP_MANAGER, NMPPPManagerClass)) +#ifndef __NM_PPP_MANAGER_H__ +#define __NM_PPP_MANAGER_H__ #define NM_PPP_MANAGER_PARENT_IFACE "parent-iface" #define NM_PPP_MANAGER_STATE_CHANGED "state-changed" -typedef struct _NMPPPManagerClass NMPPPManagerClass; +typedef struct _NMPPPManager NMPPPManager; -#endif /* __NETWORKMANAGER_PPP_MANAGER_H__ */ +#endif /* __NM_PPP_MANAGER_H__ */ diff --git a/src/ppp-manager/nm-ppp-plugin.h b/src/ppp-manager/nm-ppp-plugin-api.h index 36e23defbf..0a38fe0551 100644 --- a/src/ppp-manager/nm-ppp-plugin.h +++ b/src/ppp-manager/nm-ppp-plugin-api.h @@ -15,17 +15,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008-2016 Red Hat, Inc. + * Copyright (C) 2016 Red Hat, Inc. */ -#ifndef __NETWORKMANAGER_PPP_PLUGIN_H__ -#define __NETWORKMANAGER_PPP_PLUGIN_H__ - -typedef struct _NMPPPManager NMPPPManager; - -#define NM_PPP_MANAGER_PARENT_IFACE "parent-iface" -#define NM_PPP_MANAGER_STATE_CHANGED "state-changed" +#ifndef __NM_PPP_PLUGIN_API_H__ +#define __NM_PPP_PLUGIN_API_H__ typedef const struct { NMPPPManager *(*create) (const char *iface); @@ -49,22 +43,4 @@ typedef const struct { void (*stop_sync) (NMPPPManager *manager); } NMPPPOps; -typedef enum { - NM_PPP_STATUS_UNKNOWN, - - NM_PPP_STATUS_DEAD, - NM_PPP_STATUS_INITIALIZE, - NM_PPP_STATUS_SERIALCONN, - NM_PPP_STATUS_DORMANT, - NM_PPP_STATUS_ESTABLISH, - NM_PPP_STATUS_AUTHENTICATE, - NM_PPP_STATUS_CALLBACK, - NM_PPP_STATUS_NETWORK, - NM_PPP_STATUS_RUNNING, - NM_PPP_STATUS_TERMINATE, - NM_PPP_STATUS_DISCONNECT, - NM_PPP_STATUS_HOLDOFF, - NM_PPP_STATUS_MASTER -} NMPPPStatus; - -#endif /* __NETWORKMANAGER_PPP_MANAGER_API_H__ */ +#endif /* __NM_PPP_PLUGIN_API_H__ */ diff --git a/src/ppp-manager/nm-ppp-status.h b/src/ppp-manager/nm-ppp-status.h new file mode 100644 index 0000000000..d785cc2cc6 --- /dev/null +++ b/src/ppp-manager/nm-ppp-status.h @@ -0,0 +1,43 @@ +/* -*- 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) 2008 Novell, Inc. + * Copyright (C) 2008-2016 Red Hat, Inc. + */ + +#ifndef __NM_PPP_STATUS_H__ +#define __NM_PPP_STATUS_H__ + +typedef enum { + NM_PPP_STATUS_UNKNOWN, + + NM_PPP_STATUS_DEAD, + NM_PPP_STATUS_INITIALIZE, + NM_PPP_STATUS_SERIALCONN, + NM_PPP_STATUS_DORMANT, + NM_PPP_STATUS_ESTABLISH, + NM_PPP_STATUS_AUTHENTICATE, + NM_PPP_STATUS_CALLBACK, + NM_PPP_STATUS_NETWORK, + NM_PPP_STATUS_RUNNING, + NM_PPP_STATUS_TERMINATE, + NM_PPP_STATUS_DISCONNECT, + NM_PPP_STATUS_HOLDOFF, + NM_PPP_STATUS_MASTER +} NMPPPStatus; + +#endif /* __NM_PPP_STATUS_H__ */ diff --git a/src/ppp-manager/nm-pppd-plugin.c b/src/ppp-manager/nm-pppd-plugin.c index 8d24ffdb23..9c47c339a3 100644 --- a/src/ppp-manager/nm-pppd-plugin.c +++ b/src/ppp-manager/nm-pppd-plugin.c @@ -38,7 +38,7 @@ #include "nm-default.h" #include "nm-dbus-interface.h" #include "nm-pppd-plugin.h" -#include "nm-ppp-plugin.h" +#include "nm-ppp-status.h" int plugin_init (void); |