mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-30 14:22:37 +01:00
wiphy: Add Adapter objects above Device
Change the path for net.connman.iwd.Device objects to /phyX/Y and register net.connman.iwd.Adapter at /phyX grouping devices of the same wiphy. Turns out no changes to the test/* scripts are needed.
This commit is contained in:
parent
28fc8e613d
commit
4ebdf4e2ca
@ -25,6 +25,7 @@
|
||||
#define IWD_SERVICE "net.connman.iwd"
|
||||
|
||||
#define IWD_AGENT_MANAGER_INTERFACE "net.connman.iwd.AgentManager"
|
||||
#define IWD_WIPHY_INTERFACE "net.connman.iwd.Adapter"
|
||||
#define IWD_DEVICE_INTERFACE "net.connman.iwd.Device"
|
||||
#define IWD_NETWORK_INTERFACE "net.connman.iwd.Network"
|
||||
#define IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
|
||||
|
@ -442,9 +442,10 @@ struct network *device_get_connected_network(struct device *device)
|
||||
|
||||
const char *device_get_path(struct device *device)
|
||||
{
|
||||
static char path[12];
|
||||
static char path[26];
|
||||
|
||||
snprintf(path, sizeof(path), "/%u", device->index);
|
||||
snprintf(path, sizeof(path), "%s/%u", wiphy_get_path(device->wiphy),
|
||||
device->index);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
38
src/wiphy.c
38
src/wiphy.c
@ -38,6 +38,7 @@
|
||||
#include "src/crypto.h"
|
||||
#include "src/scan.h"
|
||||
#include "src/netdev.h"
|
||||
#include "src/dbus.h"
|
||||
#include "src/wiphy.h"
|
||||
|
||||
static struct l_genl_family *nl80211 = NULL;
|
||||
@ -90,6 +91,14 @@ struct wiphy *wiphy_find(int wiphy_id)
|
||||
return l_queue_find(wiphy_list, wiphy_match, L_UINT_TO_PTR(wiphy_id));
|
||||
}
|
||||
|
||||
const char *wiphy_get_path(struct wiphy *wiphy)
|
||||
{
|
||||
static char path[15];
|
||||
|
||||
snprintf(path, sizeof(path), "/phy%u", wiphy->id);
|
||||
return path;
|
||||
}
|
||||
|
||||
static void wiphy_print_basic_info(struct wiphy *wiphy)
|
||||
{
|
||||
uint32_t bands;
|
||||
@ -324,6 +333,16 @@ static void wiphy_dump_callback(struct l_genl_msg *msg, void *user_data)
|
||||
wiphy_parse_attributes(wiphy, &attr);
|
||||
}
|
||||
|
||||
static void wiphy_register(struct wiphy *wiphy)
|
||||
{
|
||||
struct l_dbus *dbus = dbus_get_bus();
|
||||
|
||||
if (!l_dbus_object_add_interface(dbus, wiphy_get_path(wiphy),
|
||||
IWD_WIPHY_INTERFACE, wiphy))
|
||||
l_info("Unable to add the %s interface to %s",
|
||||
IWD_WIPHY_INTERFACE, wiphy_get_path(wiphy));
|
||||
}
|
||||
|
||||
static void wiphy_dump_done(void *user)
|
||||
{
|
||||
const struct l_queue_entry *wiphy_entry;
|
||||
@ -332,6 +351,8 @@ static void wiphy_dump_done(void *user)
|
||||
wiphy_entry = wiphy_entry->next) {
|
||||
struct wiphy *wiphy = wiphy_entry->data;
|
||||
|
||||
wiphy_register(wiphy);
|
||||
|
||||
wiphy_print_basic_info(wiphy);
|
||||
}
|
||||
}
|
||||
@ -377,6 +398,8 @@ static void wiphy_new_wiphy_event(struct l_genl_msg *msg)
|
||||
wiphy_parse_attributes(wiphy, &attr);
|
||||
wiphy_print_basic_info(wiphy);
|
||||
|
||||
wiphy_register(wiphy);
|
||||
|
||||
netdev_new_wiphy_hint(wiphy->id);
|
||||
}
|
||||
|
||||
@ -408,6 +431,8 @@ static void wiphy_del_wiphy_event(struct l_genl_msg *msg)
|
||||
if (!wiphy)
|
||||
return;
|
||||
|
||||
l_dbus_unregister_object(dbus_get_bus(), wiphy_get_path(wiphy));
|
||||
|
||||
wiphy_free(wiphy);
|
||||
}
|
||||
|
||||
@ -497,6 +522,10 @@ static void protocol_features_callback(struct l_genl_msg *msg, void *user_data)
|
||||
l_debug("Found split wiphy dump support");
|
||||
}
|
||||
|
||||
static void setup_wiphy_interface(struct l_dbus_interface *interface)
|
||||
{
|
||||
}
|
||||
|
||||
bool wiphy_init(struct l_genl_family *in)
|
||||
{
|
||||
struct l_genl_msg *msg;
|
||||
@ -537,6 +566,13 @@ bool wiphy_init(struct l_genl_family *in)
|
||||
NULL, wiphy_dump_done))
|
||||
l_error("Getting all wiphy devices failed");
|
||||
|
||||
if (!l_dbus_register_interface(dbus_get_bus(),
|
||||
IWD_WIPHY_INTERFACE,
|
||||
setup_wiphy_interface,
|
||||
NULL, true))
|
||||
l_error("Unable to register the %s interface",
|
||||
IWD_WIPHY_INTERFACE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -547,5 +583,7 @@ bool wiphy_exit(void)
|
||||
|
||||
nl80211 = NULL;
|
||||
|
||||
l_dbus_unregister_interface(dbus_get_bus(), IWD_WIPHY_INTERFACE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -30,5 +30,7 @@ enum ie_rsn_cipher_suite wiphy_select_cipher(struct wiphy *wiphy,
|
||||
|
||||
struct wiphy *wiphy_find(int wiphy_id);
|
||||
|
||||
const char *wiphy_get_path(struct wiphy *wiphy);
|
||||
|
||||
bool wiphy_init(struct l_genl_family *in);
|
||||
bool wiphy_exit(void);
|
||||
|
Loading…
Reference in New Issue
Block a user