mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-26 10:39:23 +01:00
wiphy: Add wiphy_create/wiphy_destroy API
Add wiphy_create, wiphy_update_from_genl and wiphy_destroy that together will let a new file command the wiphy creation, updates and deletion with the same functionality the current config notification handler implements in wiphy.c.
This commit is contained in:
parent
fd0892baf0
commit
4a969294f7
60
src/wiphy.c
60
src/wiphy.c
@ -781,6 +781,53 @@ static void wiphy_new_wiphy_event(struct l_genl_msg *msg)
|
|||||||
wiphy_register(wiphy);
|
wiphy_register(wiphy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wiphy *wiphy_create(uint32_t wiphy_id, const char *name)
|
||||||
|
{
|
||||||
|
struct wiphy *wiphy;
|
||||||
|
|
||||||
|
if (!wiphy_is_managed(name))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
wiphy = wiphy_new(wiphy_id);
|
||||||
|
l_strlcpy(wiphy->name, name, sizeof(wiphy->name));
|
||||||
|
l_queue_push_head(wiphy_list, wiphy);
|
||||||
|
|
||||||
|
wiphy_register(wiphy);
|
||||||
|
return wiphy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg)
|
||||||
|
{
|
||||||
|
struct l_genl_attr attr;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
l_debug("");
|
||||||
|
|
||||||
|
if (!l_genl_attr_init(&attr, msg))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!wiphy_parse_id_and_name(&attr, NULL, &name))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WIPHY_NAME is a NLA_NUL_STRING, so the kernel
|
||||||
|
* enforces the data to be null terminated.
|
||||||
|
*/
|
||||||
|
if (strncmp(wiphy->name, name, sizeof(wiphy->name))) {
|
||||||
|
struct l_dbus *dbus = dbus_get_bus();
|
||||||
|
|
||||||
|
l_strlcpy(wiphy->name, name, sizeof(wiphy->name));
|
||||||
|
l_dbus_property_changed(dbus, wiphy_get_path(wiphy),
|
||||||
|
IWD_WIPHY_INTERFACE, "Name");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wiphy->supported_iftypes) {
|
||||||
|
/* Most likely a new wiphy, set all the parameters */
|
||||||
|
wiphy_parse_attributes(wiphy, &attr);
|
||||||
|
wiphy_print_basic_info(wiphy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void wiphy_del_wiphy_event(struct l_genl_msg *msg)
|
static void wiphy_del_wiphy_event(struct l_genl_msg *msg)
|
||||||
{
|
{
|
||||||
struct wiphy *wiphy;
|
struct wiphy *wiphy;
|
||||||
@ -804,6 +851,19 @@ static void wiphy_del_wiphy_event(struct l_genl_msg *msg)
|
|||||||
wiphy_free(wiphy);
|
wiphy_free(wiphy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wiphy_destroy(struct wiphy *wiphy)
|
||||||
|
{
|
||||||
|
l_debug("");
|
||||||
|
|
||||||
|
if (!l_queue_remove(wiphy_list, wiphy))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
l_dbus_unregister_object(dbus_get_bus(), wiphy_get_path(wiphy));
|
||||||
|
|
||||||
|
wiphy_free(wiphy);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void wiphy_config_notify(struct l_genl_msg *msg, void *user_data)
|
static void wiphy_config_notify(struct l_genl_msg *msg, void *user_data)
|
||||||
{
|
{
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
|
@ -46,6 +46,10 @@ bool wiphy_parse_id_and_name(struct l_genl_attr *attr, uint32_t *out_id,
|
|||||||
|
|
||||||
struct wiphy *wiphy_find(int wiphy_id);
|
struct wiphy *wiphy_find(int wiphy_id);
|
||||||
|
|
||||||
|
struct wiphy *wiphy_create(uint32_t wiphy_id, const char *name);
|
||||||
|
bool wiphy_destroy(struct wiphy *wiphy);
|
||||||
|
void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg);
|
||||||
|
|
||||||
const char *wiphy_get_path(struct wiphy *wiphy);
|
const char *wiphy_get_path(struct wiphy *wiphy);
|
||||||
uint32_t wiphy_get_supported_bands(struct wiphy *wiphy);
|
uint32_t wiphy_get_supported_bands(struct wiphy *wiphy);
|
||||||
const struct scan_freq_set *wiphy_get_supported_freqs(
|
const struct scan_freq_set *wiphy_get_supported_freqs(
|
||||||
|
Loading…
Reference in New Issue
Block a user