mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-20 17:54:05 +01:00
dbus: Remove Manager interface, add AgentManager
Move the Agent-related methods to a new interface, AgentManager, and drop the remaining methods and signals made redundant by the ObjectManager.
This commit is contained in:
parent
3e2562a5a8
commit
15bab067fc
@ -62,7 +62,6 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h \
|
||||
src/device.h src/device.c \
|
||||
src/ie.h src/ie.c \
|
||||
src/dbus.h src/dbus.c \
|
||||
src/manager.h src/manager.c \
|
||||
src/crypto.h src/crypto.c \
|
||||
src/mpdu.h src/mpdu.c \
|
||||
src/eapol.h src/eapol.c \
|
||||
|
34
src/agent.c
34
src/agent.c
@ -406,7 +406,7 @@ static struct l_dbus_message *agent_unregister(struct l_dbus *dbus,
|
||||
return reply;
|
||||
}
|
||||
|
||||
bool agent_setup(struct l_dbus_interface *interface)
|
||||
static void setup_agent_interface(struct l_dbus_interface *interface)
|
||||
{
|
||||
l_dbus_interface_method(interface, "RegisterAgent", 0,
|
||||
agent_register,
|
||||
@ -414,8 +414,6 @@ bool agent_setup(struct l_dbus_interface *interface)
|
||||
l_dbus_interface_method(interface, "UnregisterAgent", 0,
|
||||
agent_unregister,
|
||||
"", "o", "path");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void release_agent(struct agent *agent)
|
||||
@ -425,15 +423,35 @@ static void release_agent(struct agent *agent)
|
||||
agent_free(agent);
|
||||
}
|
||||
|
||||
bool agent_init(void)
|
||||
bool agent_init(struct l_dbus *dbus)
|
||||
{
|
||||
if (!l_dbus_register_interface(dbus, IWD_AGENT_MANAGER_INTERFACE,
|
||||
setup_agent_interface,
|
||||
NULL, true)) {
|
||||
l_info("Unable to register %s interface",
|
||||
IWD_AGENT_MANAGER_INTERFACE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!l_dbus_object_add_interface(dbus, IWD_AGENT_MANAGER_PATH,
|
||||
IWD_AGENT_MANAGER_INTERFACE,
|
||||
NULL)) {
|
||||
l_info("Unable to register the agent manager object on '%s'",
|
||||
IWD_AGENT_MANAGER_PATH);
|
||||
l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void agent_exit(void)
|
||||
bool agent_exit(struct l_dbus *dbus)
|
||||
{
|
||||
if (!default_agent)
|
||||
return;
|
||||
|
||||
if (default_agent)
|
||||
release_agent(default_agent);
|
||||
|
||||
l_dbus_unregister_object(dbus, IWD_AGENT_MANAGER_PATH);
|
||||
l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ typedef void (*agent_request_passphrase_func_t) (enum agent_result result,
|
||||
struct l_dbus_message *message,
|
||||
void *user_data);
|
||||
|
||||
bool agent_init(void);
|
||||
void agent_exit(void);
|
||||
bool agent_init(struct l_dbus *dbus);
|
||||
bool agent_exit(struct l_dbus *dbus);
|
||||
bool agent_setup(struct l_dbus_interface *interface);
|
||||
|
||||
unsigned int agent_request_passphrase(const char *path,
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <ell/ell.h>
|
||||
#include <ell/dbus-private.h>
|
||||
#include "src/dbus.h"
|
||||
#include "src/manager.h"
|
||||
#include "src/agent.h"
|
||||
|
||||
struct l_dbus *g_dbus = 0;
|
||||
static int kdbus_fd = -1;
|
||||
@ -185,7 +185,7 @@ static void ready_callback(void *user_data)
|
||||
if (!l_dbus_object_manager_enable(g_dbus))
|
||||
l_info("Unable to register the ObjectManager");
|
||||
|
||||
manager_init(g_dbus);
|
||||
agent_init(g_dbus);
|
||||
}
|
||||
|
||||
static void disconnect_callback(void *user_data)
|
||||
@ -236,7 +236,8 @@ bool dbus_init(bool enable_debug, bool use_kdbus)
|
||||
|
||||
bool dbus_exit(void)
|
||||
{
|
||||
manager_exit(g_dbus);
|
||||
agent_exit(g_dbus);
|
||||
|
||||
l_dbus_destroy(g_dbus);
|
||||
g_dbus = NULL;
|
||||
|
||||
|
@ -24,13 +24,13 @@
|
||||
|
||||
#define IWD_SERVICE "net.connman.iwd"
|
||||
|
||||
#define IWD_MANAGER_INTERFACE "net.connman.iwd.Manager"
|
||||
#define IWD_AGENT_MANAGER_INTERFACE "net.connman.iwd.AgentManager"
|
||||
#define IWD_DEVICE_INTERFACE "net.connman.iwd.Device"
|
||||
#define IWD_NETWORK_INTERFACE "net.connman.iwd.Network"
|
||||
#define IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
|
||||
#define IWD_WSC_INTERFACE "net.connman.iwd.WiFiSimpleConfiguration"
|
||||
|
||||
#define IWD_MANAGER_PATH "/"
|
||||
#define IWD_AGENT_MANAGER_PATH "/"
|
||||
|
||||
struct l_dbus;
|
||||
|
||||
|
@ -59,8 +59,6 @@ static void signal_handler(struct l_signal *signal, uint32_t signo,
|
||||
case SIGTERM:
|
||||
l_info("Terminate");
|
||||
|
||||
agent_exit();
|
||||
|
||||
timeout = l_timeout_create(1, main_loop_quit, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
|
109
src/manager.c
109
src/manager.c
@ -1,109 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Wireless daemon for Linux
|
||||
*
|
||||
* Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <ell/ell.h>
|
||||
#include "src/manager.h"
|
||||
#include "src/dbus.h"
|
||||
#include "src/wiphy.h"
|
||||
#include "src/agent.h"
|
||||
#include "src/device.h"
|
||||
|
||||
static void append_device(struct netdev *netdev, void *user_data)
|
||||
{
|
||||
struct l_dbus_message_builder *builder = user_data;
|
||||
|
||||
l_dbus_message_builder_enter_dict(builder, "oa{sv}");
|
||||
l_dbus_message_builder_append_basic(builder, 'o',
|
||||
device_get_path(netdev));
|
||||
__iwd_device_append_properties(netdev, builder);
|
||||
l_dbus_message_builder_leave_dict(builder);
|
||||
}
|
||||
|
||||
static struct l_dbus_message *manager_get_devices(struct l_dbus *dbus,
|
||||
struct l_dbus_message *message,
|
||||
void *user_data)
|
||||
{
|
||||
struct l_dbus_message *reply;
|
||||
struct l_dbus_message_builder *builder;
|
||||
|
||||
reply = l_dbus_message_new_method_return(message);
|
||||
builder = l_dbus_message_builder_new(reply);
|
||||
|
||||
l_dbus_message_builder_enter_array(builder, "{oa{sv}}");
|
||||
__iwd_device_foreach(append_device, builder);
|
||||
l_dbus_message_builder_leave_array(builder);
|
||||
|
||||
l_dbus_message_builder_finalize(builder);
|
||||
l_dbus_message_builder_destroy(builder);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static void setup_manager_interface(struct l_dbus_interface *interface)
|
||||
{
|
||||
l_dbus_interface_method(interface, "GetDevices", 0,
|
||||
manager_get_devices,
|
||||
"a{oa{sv}}", "", "devices");
|
||||
|
||||
l_dbus_interface_signal(interface, "DeviceAdded", 0,
|
||||
"oa{sv}", "path", "properties");
|
||||
l_dbus_interface_signal(interface, "DeviceRemoved", 0,
|
||||
"o", "path");
|
||||
|
||||
agent_setup(interface);
|
||||
}
|
||||
|
||||
bool manager_init(struct l_dbus *dbus)
|
||||
{
|
||||
agent_init();
|
||||
|
||||
if (!l_dbus_register_interface(dbus, IWD_MANAGER_INTERFACE,
|
||||
setup_manager_interface,
|
||||
NULL, true)) {
|
||||
l_info("Unable to register %s interface",
|
||||
IWD_MANAGER_INTERFACE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!l_dbus_object_add_interface(dbus, IWD_MANAGER_PATH,
|
||||
IWD_MANAGER_INTERFACE, NULL)) {
|
||||
l_info("Unable to register manager object on '%s'",
|
||||
IWD_MANAGER_PATH);
|
||||
l_dbus_unregister_interface(dbus, IWD_MANAGER_INTERFACE);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool manager_exit(struct l_dbus *dbus)
|
||||
{
|
||||
|
||||
l_dbus_unregister_object(dbus, IWD_MANAGER_PATH);
|
||||
l_dbus_unregister_interface(dbus, IWD_MANAGER_INTERFACE);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Wireless daemon for Linux
|
||||
*
|
||||
* Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool manager_init(struct l_dbus *dbus);
|
||||
bool manager_exit(struct l_dbus *dbus);
|
66
src/wiphy.c
66
src/wiphy.c
@ -330,22 +330,6 @@ const char *device_get_path(struct netdev *netdev)
|
||||
return path;
|
||||
}
|
||||
|
||||
bool __iwd_device_append_properties(struct netdev *netdev,
|
||||
struct l_dbus_message_builder *builder)
|
||||
{
|
||||
l_dbus_message_builder_enter_array(builder, "{sv}");
|
||||
|
||||
dbus_dict_append_string(builder, "Name", netdev->name);
|
||||
|
||||
if (netdev->connected_network)
|
||||
dbus_dict_append_object(builder, "ConnectedNetwork",
|
||||
network_get_path(netdev->connected_network));
|
||||
|
||||
l_dbus_message_builder_leave_array(builder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void __iwd_device_foreach(iwd_device_foreach_func func, void *user_data)
|
||||
{
|
||||
const struct l_queue_entry *wiphy_entry;
|
||||
@ -366,50 +350,6 @@ void __iwd_device_foreach(iwd_device_foreach_func func, void *user_data)
|
||||
}
|
||||
}
|
||||
|
||||
static void device_emit_added(struct netdev *netdev)
|
||||
{
|
||||
struct l_dbus *dbus = dbus_get_bus();
|
||||
struct l_dbus_message *signal;
|
||||
struct l_dbus_message_builder *builder;
|
||||
|
||||
signal = l_dbus_message_new_signal(dbus, IWD_MANAGER_PATH,
|
||||
IWD_MANAGER_INTERFACE,
|
||||
"DeviceAdded");
|
||||
|
||||
if (!signal)
|
||||
return;
|
||||
|
||||
builder = l_dbus_message_builder_new(signal);
|
||||
if (!builder) {
|
||||
l_dbus_message_unref(signal);
|
||||
return;
|
||||
}
|
||||
|
||||
l_dbus_message_builder_append_basic(builder, 'o',
|
||||
device_get_path(netdev));
|
||||
__iwd_device_append_properties(netdev, builder);
|
||||
|
||||
l_dbus_message_builder_finalize(builder);
|
||||
l_dbus_message_builder_destroy(builder);
|
||||
l_dbus_send(dbus, signal);
|
||||
}
|
||||
|
||||
static void device_emit_removed(struct netdev *netdev)
|
||||
{
|
||||
struct l_dbus *dbus = dbus_get_bus();
|
||||
struct l_dbus_message *signal;
|
||||
|
||||
signal = l_dbus_message_new_signal(dbus, IWD_MANAGER_PATH,
|
||||
IWD_MANAGER_INTERFACE,
|
||||
"DeviceRemoved");
|
||||
|
||||
if (!signal)
|
||||
return;
|
||||
|
||||
l_dbus_message_set_arguments(signal, "o", device_get_path(netdev));
|
||||
l_dbus_send(dbus, signal);
|
||||
}
|
||||
|
||||
static void device_scan_triggered(int err, void *user_data)
|
||||
{
|
||||
struct netdev *netdev = user_data;
|
||||
@ -613,8 +553,6 @@ static void netdev_free(void *data)
|
||||
dbus = dbus_get_bus();
|
||||
l_dbus_unregister_object(dbus, device_get_path(netdev));
|
||||
|
||||
device_emit_removed(netdev);
|
||||
|
||||
l_debug("Freeing interface %s", netdev->name);
|
||||
|
||||
l_hashmap_destroy(netdev->networks, network_free);
|
||||
@ -1556,10 +1494,8 @@ static void interface_dump_callback(struct l_genl_msg *msg, void *user_data)
|
||||
IWD_DEVICE_INTERFACE, netdev))
|
||||
l_info("Unable to register %s interface",
|
||||
IWD_DEVICE_INTERFACE);
|
||||
else {
|
||||
|
||||
__device_watch_call_added(netdev);
|
||||
device_emit_added(netdev);
|
||||
}
|
||||
|
||||
netdev_set_linkmode_and_operstate(netdev->index, 1,
|
||||
IF_OPER_DORMANT, NULL, NULL);
|
||||
|
@ -36,6 +36,4 @@ bool wiphy_exit(void);
|
||||
|
||||
void wiphy_notify_dellink(uint32_t index);
|
||||
|
||||
bool __iwd_device_append_properties(struct netdev *netdev,
|
||||
struct l_dbus_message_builder *builder);
|
||||
void __iwd_device_foreach(iwd_device_foreach_func func, void *user_data);
|
||||
|
Loading…
Reference in New Issue
Block a user