summaryrefslogtreecommitdiff
path: root/src/ppp
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-03-12 18:37:24 +0100
committerThomas Haller <thaller@redhat.com>2018-03-12 18:37:24 +0100
commit1e535789cfd8dbc94da1e4f6393d27ccc2a209fc (patch)
treead3a5f30986b7708a1e12a7485c41681da8c78e9 /src/ppp
parent6a54f4279f792facb17a9c1dc3508ac155521256 (diff)
parent297d4985abcc7b571b8c090ee90622357fc60e16 (diff)
downloadNetworkManager-1e535789cfd8dbc94da1e4f6393d27ccc2a209fc.tar.gz
core/dbus: merge branch 'th/dbus'
https://github.com/NetworkManager/NetworkManager/pull/74
Diffstat (limited to 'src/ppp')
-rw-r--r--src/ppp/meson.build1
-rw-r--r--src/ppp/nm-ppp-manager.c187
2 files changed, 135 insertions, 53 deletions
diff --git a/src/ppp/meson.build b/src/ppp/meson.build
index 9c2045efff..20edb9d055 100644
--- a/src/ppp/meson.build
+++ b/src/ppp/meson.build
@@ -22,7 +22,6 @@ nm_pppd_plugin = shared_module(
name = 'nm-ppp-plugin'
deps = [
- libnmdbus_dep,
nm_dep
]
diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c
index 36697f082f..2bf230a86b 100644
--- a/src/ppp/nm-ppp-manager.c
+++ b/src/ppp/nm-ppp-manager.c
@@ -50,13 +50,12 @@
#include "nm-act-request.h"
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"
+#include "nm-dbus-object.h"
#include "nm-pppd-plugin.h"
#include "nm-ppp-plugin-api.h"
#include "nm-ppp-status.h"
-#include "introspection/org.freedesktop.NetworkManager.PPP.h"
-
#define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so"
static NM_CACHED_QUARK_FCN ("ppp-manager-secret-tries", ppp_manager_secret_tries_quark)
@@ -116,17 +115,17 @@ typedef struct {
} NMPPPManagerPrivate;
struct _NMPPPManager {
- NMExportedObject parent;
+ NMDBusObject parent;
NMPPPManagerPrivate _priv;
};
typedef struct {
- NMExportedObjectClass parent;
+ NMDBusObjectClass parent;
} NMPPPManagerClass;
-G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_EXPORTED_OBJECT)
+G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_DBUS_OBJECT)
-#define NM_PPP_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPPPManager, NM_IS_PPP_MANAGER)
+#define NM_PPP_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPPPManager, NM_IS_PPP_MANAGER, NMDBusObject)
/*****************************************************************************/
@@ -332,20 +331,27 @@ ppp_secrets_cb (NMActRequest *req,
* against libnm just to parse this. So instead, let's just send what
* it needs.
*/
- g_dbus_method_invocation_return_value (
- priv->pending_secrets_context,
- g_variant_new ("(ss)", username ? username : "", password ? password : ""));
+ g_dbus_method_invocation_return_value (priv->pending_secrets_context,
+ g_variant_new ("(ss)",
+ username ?: "",
+ password ?: ""));
- out:
+out:
priv->pending_secrets_context = NULL;
priv->secrets_id = NULL;
priv->secrets_setting_name = NULL;
}
static void
-impl_ppp_manager_need_secrets (NMPPPManager *manager,
- GDBusMethodInvocation *context)
+impl_ppp_manager_need_secrets (NMDBusObject *obj,
+ const NMDBusInterfaceInfoExtended *interface_info,
+ const NMDBusMethodInfoExtended *method_info,
+ GDBusConnection *connection,
+ const char *sender,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
{
+ NMPPPManager *manager = NM_PPP_MANAGER (obj);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
NMConnection *applied_connection;
const char *username = NULL;
@@ -364,7 +370,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
/* Use existing secrets from the connection */
if (extract_details_from_connection (applied_connection, NULL, &username, &password, &error)) {
/* Send existing secrets to the PPP plugin */
- priv->pending_secrets_context = context;
+ priv->pending_secrets_context = invocation;
ppp_secrets_cb (priv->act_req, priv->secrets_id, NULL, NULL, manager);
} else {
_LOGW ("%s", error->message);
@@ -389,30 +395,45 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
ppp_secrets_cb,
manager);
g_object_set_qdata (G_OBJECT (applied_connection), ppp_manager_secret_tries_quark (), GUINT_TO_POINTER (++tries));
- priv->pending_secrets_context = context;
+ priv->pending_secrets_context = invocation;
if (hints)
g_ptr_array_free (hints, TRUE);
}
static void
-impl_ppp_manager_set_state (NMPPPManager *manager,
- GDBusMethodInvocation *context,
- guint32 state)
+impl_ppp_manager_set_state (NMDBusObject *obj,
+ const NMDBusInterfaceInfoExtended *interface_info,
+ const NMDBusMethodInfoExtended *method_info,
+ GDBusConnection *connection,
+ const char *sender,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
{
- g_signal_emit (manager, signals[STATE_CHANGED], 0, (guint) state);
+ NMPPPManager *manager = NM_PPP_MANAGER (obj);
+ guint32 state;
- g_dbus_method_invocation_return_value (context, NULL);
+ g_variant_get (parameters, "(u)", &state);
+ g_signal_emit (manager, signals[STATE_CHANGED], 0, (guint) state);
+ g_dbus_method_invocation_return_value (invocation, NULL);
}
static void
-impl_ppp_manager_set_ifindex (NMPPPManager *manager,
- GDBusMethodInvocation *context,
- gint32 ifindex)
+impl_ppp_manager_set_ifindex (NMDBusObject *obj,
+ const NMDBusInterfaceInfoExtended *interface_info,
+ const NMDBusMethodInfoExtended *method_info,
+ GDBusConnection *connection,
+ const char *sender,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
{
+ NMPPPManager *manager = NM_PPP_MANAGER (obj);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
const NMPlatformLink *plink = NULL;
nm_auto_nmpobj const NMPObject *obj_keep_alive = NULL;
+ gint32 ifindex;
+
+ g_variant_get (parameters, "(i)", &ifindex);
_LOGD ("set-ifindex %d", (int) ifindex);
@@ -439,7 +460,7 @@ impl_ppp_manager_set_ifindex (NMPPPManager *manager,
obj_keep_alive = nmp_object_ref (NMP_OBJECT_UP_CAST (plink));
g_signal_emit (manager, signals[IFINDEX_SET], 0, ifindex, plink->name);
- g_dbus_method_invocation_return_value (context, NULL);
+ g_dbus_method_invocation_return_value (invocation, NULL);
}
static gboolean
@@ -469,18 +490,26 @@ set_ip_config_common (NMPPPManager *self,
}
static void
-impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
- GDBusMethodInvocation *context,
- GVariant *config_dict)
+impl_ppp_manager_set_ip4_config (NMDBusObject *obj,
+ const NMDBusInterfaceInfoExtended *interface_info,
+ const NMDBusMethodInfoExtended *method_info,
+ GDBusConnection *connection,
+ const char *sender,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
{
+ NMPPPManager *manager = NM_PPP_MANAGER (obj);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
gs_unref_object NMIP4Config *config = NULL;
NMPlatformIP4Address address;
guint32 u32, mtu;
GVariantIter *iter;
+ gs_unref_variant GVariant *config_dict = NULL;
_LOGI ("(IPv4 Config Get) reply received.");
+ g_variant_get (parameters, "(@a{sv})", &config_dict);
+
nm_clear_g_source (&priv->ppp_timeout_handler);
if (!set_ip_config_common (manager, config_dict, &mtu))
@@ -538,7 +567,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
g_signal_emit (manager, signals[IP4_CONFIG], 0, config);
out:
- g_dbus_method_invocation_return_value (context, NULL);
+ g_dbus_method_invocation_return_value (invocation, NULL);
}
/* Converts the named Interface Identifier item to an IPv6 LL address and
@@ -571,19 +600,27 @@ iid_value_to_ll6_addr (GVariant *dict,
}
static void
-impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
- GDBusMethodInvocation *context,
- GVariant *config_dict)
+impl_ppp_manager_set_ip6_config (NMDBusObject *obj,
+ const NMDBusInterfaceInfoExtended *interface_info,
+ const NMDBusMethodInfoExtended *method_info,
+ GDBusConnection *connection,
+ const char *sender,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
{
+ NMPPPManager *manager = NM_PPP_MANAGER (obj);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
gs_unref_object NMIP6Config *config = NULL;
NMPlatformIP6Address addr;
struct in6_addr a;
NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT;
gboolean has_peer = FALSE;
+ gs_unref_variant GVariant *config_dict = NULL;
_LOGI ("(IPv6 Config Get) reply received.");
+ g_variant_get (parameters, "(@a{sv})", &config_dict);
+
nm_clear_g_source (&priv->ppp_timeout_handler);
if (!set_ip_config_common (manager, config_dict, NULL))
@@ -619,7 +656,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
_LOGE ("invalid IPv6 address received!");
out:
- g_dbus_method_invocation_return_value (context, NULL);
+ g_dbus_method_invocation_return_value (invocation, NULL);
}
/*****************************************************************************/
@@ -926,7 +963,7 @@ create_pppd_cmd_line (NMPPPManager *self,
nm_cmd_line_add_int (cmd, 0);
nm_cmd_line_add_string (cmd, "ipparam");
- nm_cmd_line_add_string (cmd, nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)));
+ nm_cmd_line_add_string (cmd, nm_dbus_object_get_path (NM_DBUS_OBJECT (self)));
nm_cmd_line_add_string (cmd, "plugin");
nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN);
@@ -1005,7 +1042,7 @@ _ppp_manager_start (NMPPPManager *manager,
return FALSE;
#endif
- nm_exported_object_export (NM_EXPORTED_OBJECT (manager));
+ nm_dbus_object_export (NM_DBUS_OBJECT (manager));
priv->pid = 0;
@@ -1079,7 +1116,7 @@ out:
nm_cmd_line_destroy (ppp_cmd);
if (priv->pid <= 0)
- nm_exported_object_unexport (NM_EXPORTED_OBJECT (manager));
+ nm_dbus_object_unexport (NM_DBUS_OBJECT (manager));
return priv->pid > 0;
}
@@ -1183,7 +1220,7 @@ _ppp_manager_stop_async (NMPPPManager *manager,
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
StopContext *ctx;
- nm_exported_object_unexport (NM_EXPORTED_OBJECT (manager));
+ nm_dbus_object_unexport (NM_DBUS_OBJECT (manager));
ctx = g_slice_new0 (StopContext);
ctx->manager = g_object_ref (manager);
@@ -1220,10 +1257,10 @@ _ppp_manager_stop_async (NMPPPManager *manager,
static void
_ppp_manager_stop_sync (NMPPPManager *manager)
{
- NMExportedObject *exported = NM_EXPORTED_OBJECT (manager);
+ NMDBusObject *dbus = NM_DBUS_OBJECT (manager);
- if (nm_exported_object_is_exported (exported))
- nm_exported_object_unexport (exported);
+ if (nm_dbus_object_is_exported (dbus))
+ nm_dbus_object_unexport (dbus);
_ppp_cleanup (manager);
_ppp_kill (manager);
@@ -1293,11 +1330,11 @@ static void
dispose (GObject *object)
{
NMPPPManager *self = (NMPPPManager *) object;
- NMExportedObject *exported = NM_EXPORTED_OBJECT (self);
+ NMDBusObject *dbus = NM_DBUS_OBJECT (self);
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
- if (nm_exported_object_is_exported (exported))
- nm_exported_object_unexport (exported);
+ if (nm_dbus_object_is_exported (dbus))
+ nm_dbus_object_unexport (dbus);
_ppp_cleanup (self);
_ppp_kill (self);
@@ -1317,18 +1354,73 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_ppp_manager_parent_class)->finalize (object);
}
+static const NMDBusInterfaceInfoExtended interface_info_ppp = {
+ .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
+ NM_DBUS_INTERFACE_PPP,
+ .methods = NM_DEFINE_GDBUS_METHOD_INFOS (
+ NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
+ NM_DEFINE_GDBUS_METHOD_INFO_INIT (
+ "NeedSecrets",
+ .out_args = NM_DEFINE_GDBUS_ARG_INFOS (
+ NM_DEFINE_GDBUS_ARG_INFO ("username", "s"),
+ NM_DEFINE_GDBUS_ARG_INFO ("password", "s"),
+ ),
+ ),
+ .handle = impl_ppp_manager_need_secrets,
+ ),
+ NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
+ NM_DEFINE_GDBUS_METHOD_INFO_INIT (
+ "SetIp4Config",
+ .in_args = NM_DEFINE_GDBUS_ARG_INFOS (
+ NM_DEFINE_GDBUS_ARG_INFO ("config", "a{sv}"),
+ ),
+ ),
+ .handle = impl_ppp_manager_set_ip4_config,
+ ),
+ NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
+ NM_DEFINE_GDBUS_METHOD_INFO_INIT (
+ "SetIp6Config",
+ .in_args = NM_DEFINE_GDBUS_ARG_INFOS (
+ NM_DEFINE_GDBUS_ARG_INFO ("config", "a{sv}"),
+ ),
+ ),
+ .handle = impl_ppp_manager_set_ip6_config,
+ ),
+ NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
+ NM_DEFINE_GDBUS_METHOD_INFO_INIT (
+ "SetState",
+ .in_args = NM_DEFINE_GDBUS_ARG_INFOS (
+ NM_DEFINE_GDBUS_ARG_INFO ("state", "u"),
+ ),
+ ),
+ .handle = impl_ppp_manager_set_state,
+ ),
+ NM_DEFINE_DBUS_METHOD_INFO_EXTENDED (
+ NM_DEFINE_GDBUS_METHOD_INFO_INIT (
+ "SetIfindex",
+ .in_args = NM_DEFINE_GDBUS_ARG_INFOS (
+ NM_DEFINE_GDBUS_ARG_INFO ("ifindex", "i"),
+ ),
+ ),
+ .handle = impl_ppp_manager_set_ifindex,
+ ),
+ ),
+ ),
+};
+
static void
nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (manager_class);
- NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (manager_class);
+ NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (manager_class);
object_class->dispose = dispose;
object_class->finalize = finalize;
object_class->get_property = get_property;
object_class->set_property = set_property;
- exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/PPP");
+ dbus_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/PPP");
+ dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_ppp);
obj_properties[PROP_PARENT_IFACE] =
g_param_spec_string (NM_PPP_MANAGER_PARENT_IFACE, "", "",
@@ -1385,15 +1477,6 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
G_TYPE_NONE, 2,
G_TYPE_UINT /*guint32 in_bytes*/,
G_TYPE_UINT /*guint32 out_bytes*/);
-
- nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (manager_class),
- NMDBUS_TYPE_PPP_MANAGER_SKELETON,
- "NeedSecrets", impl_ppp_manager_need_secrets,
- "SetIp4Config", impl_ppp_manager_set_ip4_config,
- "SetIp6Config", impl_ppp_manager_set_ip6_config,
- "SetState", impl_ppp_manager_set_state,
- "SetIfindex", impl_ppp_manager_set_ifindex,
- NULL);
}
NMPPPOps ppp_ops = {