mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-31 23:42:52 +01:00
wiphy: Remove wiphy_parse_id_and_name
in favor of using nl80211_parse_attrs
This commit is contained in:
parent
bf7e62fafb
commit
91784425ec
@ -330,17 +330,15 @@ static struct wiphy_setup_state *manager_rx_cmd_new_wiphy(
|
|||||||
{
|
{
|
||||||
struct wiphy_setup_state *state = NULL;
|
struct wiphy_setup_state *state = NULL;
|
||||||
struct wiphy *wiphy;
|
struct wiphy *wiphy;
|
||||||
struct l_genl_attr attr;
|
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *driver, **driver_bad;
|
const char *driver, **driver_bad;
|
||||||
bool use_default;
|
bool use_default;
|
||||||
const struct l_settings *settings = iwd_get_config();
|
const struct l_settings *settings = iwd_get_config();
|
||||||
|
|
||||||
if (!l_genl_attr_init(&attr, msg))
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_WIPHY, &id,
|
||||||
return NULL;
|
NL80211_ATTR_WIPHY_NAME, &name,
|
||||||
|
NL80211_ATTR_UNSPEC) < 0)
|
||||||
if (!wiphy_parse_id_and_name(&attr, &id, &name))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -386,7 +384,7 @@ static struct wiphy_setup_state *manager_rx_cmd_new_wiphy(
|
|||||||
l_info("Wiphy %s will only use the default interface", name);
|
l_info("Wiphy %s will only use the default interface", name);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
wiphy_update_from_genl(wiphy, msg);
|
wiphy_update_from_genl(wiphy, name, msg);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ static attr_handler handler_for_type(enum nl80211_attrs type)
|
|||||||
case NL80211_ATTR_WDEV:
|
case NL80211_ATTR_WDEV:
|
||||||
return extract_uint64;
|
return extract_uint64;
|
||||||
case NL80211_ATTR_IFNAME:
|
case NL80211_ATTR_IFNAME:
|
||||||
|
case NL80211_ATTR_WIPHY_NAME:
|
||||||
return extract_name;
|
return extract_name;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
97
src/wiphy.c
97
src/wiphy.c
@ -49,6 +49,7 @@
|
|||||||
#include "src/util.h"
|
#include "src/util.h"
|
||||||
#include "src/common.h"
|
#include "src/common.h"
|
||||||
#include "src/watchlist.h"
|
#include "src/watchlist.h"
|
||||||
|
#include "src/nl80211util.h"
|
||||||
|
|
||||||
#define EXT_CAP_LEN 10
|
#define EXT_CAP_LEN 10
|
||||||
|
|
||||||
@ -703,13 +704,17 @@ static void parse_iftype_extended_capabilities(struct wiphy *wiphy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void wiphy_parse_attributes(struct wiphy *wiphy,
|
static void wiphy_parse_attributes(struct wiphy *wiphy,
|
||||||
struct l_genl_attr *attr)
|
struct l_genl_msg *msg)
|
||||||
{
|
{
|
||||||
|
struct l_genl_attr attr;
|
||||||
struct l_genl_attr nested;
|
struct l_genl_attr nested;
|
||||||
uint16_t type, len;
|
uint16_t type, len;
|
||||||
const void *data;
|
const void *data;
|
||||||
|
|
||||||
while (l_genl_attr_next(attr, &type, &len, &data)) {
|
if (!l_genl_attr_init(&attr, msg))
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (l_genl_attr_next(&attr, &type, &len, &data)) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NL80211_ATTR_FEATURE_FLAGS:
|
case NL80211_ATTR_FEATURE_FLAGS:
|
||||||
if (len != sizeof(uint32_t))
|
if (len != sizeof(uint32_t))
|
||||||
@ -725,7 +730,7 @@ static void wiphy_parse_attributes(struct wiphy *wiphy,
|
|||||||
memcpy(wiphy->ext_features, data, len);
|
memcpy(wiphy->ext_features, data, len);
|
||||||
break;
|
break;
|
||||||
case NL80211_ATTR_SUPPORTED_COMMANDS:
|
case NL80211_ATTR_SUPPORTED_COMMANDS:
|
||||||
if (l_genl_attr_recurse(attr, &nested))
|
if (l_genl_attr_recurse(&attr, &nested))
|
||||||
parse_supported_commands(wiphy, &nested);
|
parse_supported_commands(wiphy, &nested);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -733,7 +738,7 @@ static void wiphy_parse_attributes(struct wiphy *wiphy,
|
|||||||
parse_supported_ciphers(wiphy, data, len);
|
parse_supported_ciphers(wiphy, data, len);
|
||||||
break;
|
break;
|
||||||
case NL80211_ATTR_WIPHY_BANDS:
|
case NL80211_ATTR_WIPHY_BANDS:
|
||||||
if (l_genl_attr_recurse(attr, &nested))
|
if (l_genl_attr_recurse(&attr, &nested))
|
||||||
parse_supported_bands(wiphy, &nested);
|
parse_supported_bands(wiphy, &nested);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -748,7 +753,7 @@ static void wiphy_parse_attributes(struct wiphy *wiphy,
|
|||||||
wiphy->support_adhoc_rsn = true;
|
wiphy->support_adhoc_rsn = true;
|
||||||
break;
|
break;
|
||||||
case NL80211_ATTR_SUPPORTED_IFTYPES:
|
case NL80211_ATTR_SUPPORTED_IFTYPES:
|
||||||
if (l_genl_attr_recurse(attr, &nested))
|
if (l_genl_attr_recurse(&attr, &nested))
|
||||||
parse_supported_iftypes(wiphy, &nested);
|
parse_supported_iftypes(wiphy, &nested);
|
||||||
break;
|
break;
|
||||||
case NL80211_ATTR_OFFCHANNEL_TX_OK:
|
case NL80211_ATTR_OFFCHANNEL_TX_OK:
|
||||||
@ -759,7 +764,7 @@ static void wiphy_parse_attributes(struct wiphy *wiphy,
|
|||||||
data, minsize(EXT_CAP_LEN, len));
|
data, minsize(EXT_CAP_LEN, len));
|
||||||
break;
|
break;
|
||||||
case NL80211_ATTR_IFTYPE_EXT_CAPA:
|
case NL80211_ATTR_IFTYPE_EXT_CAPA:
|
||||||
if (!l_genl_attr_recurse(attr, &nested))
|
if (!l_genl_attr_recurse(&attr, &nested))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
parse_iftype_extended_capabilities(wiphy, &nested);
|
parse_iftype_extended_capabilities(wiphy, &nested);
|
||||||
@ -768,68 +773,6 @@ static void wiphy_parse_attributes(struct wiphy *wiphy,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wiphy_parse_id_and_name(struct l_genl_attr *attr, uint32_t *out_id,
|
|
||||||
const char **out_name)
|
|
||||||
{
|
|
||||||
uint16_t type, len;
|
|
||||||
const void *data;
|
|
||||||
uint32_t id;
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The wiphy attribute, name and generation are always the first
|
|
||||||
* three attributes (in that order) in every NEW_WIPHY & DEL_WIPHY
|
|
||||||
* message. If not, then error out with a warning and ignore the
|
|
||||||
* whole message.
|
|
||||||
*/
|
|
||||||
if (!l_genl_attr_next(attr, &type, &len, &data))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (type != NL80211_ATTR_WIPHY)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (len != sizeof(uint32_t))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
id = *((uint32_t *) data);
|
|
||||||
|
|
||||||
if (!l_genl_attr_next(attr, &type, &len, &data))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (type != NL80211_ATTR_WIPHY_NAME)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (len > sizeof(((struct wiphy *) 0)->name))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
name = data;
|
|
||||||
|
|
||||||
if (len < 1 || !memchr(name + 1, 0, len - 1))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!l_genl_attr_next(attr, &type, &len, &data))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (type != NL80211_ATTR_GENERATION)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (len != sizeof(uint32_t))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: Handle GENERATION. In theory if we detect a changed generation
|
|
||||||
* number during a dump, it means that our dump needs to be re-started
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (out_id)
|
|
||||||
*out_id = id;
|
|
||||||
|
|
||||||
if (out_name)
|
|
||||||
*out_name = name;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool wiphy_get_driver_name(struct wiphy *wiphy)
|
static bool wiphy_get_driver_name(struct wiphy *wiphy)
|
||||||
{
|
{
|
||||||
L_AUTO_FREE_VAR(char *, driver_link) = NULL;
|
L_AUTO_FREE_VAR(char *, driver_link) = NULL;
|
||||||
@ -942,23 +885,11 @@ struct wiphy *wiphy_create(uint32_t wiphy_id, const char *name)
|
|||||||
return wiphy;
|
return wiphy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg)
|
void wiphy_update_from_genl(struct wiphy *wiphy, const char *name,
|
||||||
|
struct l_genl_msg *msg)
|
||||||
{
|
{
|
||||||
struct l_genl_attr attr;
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
l_debug("");
|
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))) {
|
if (strncmp(wiphy->name, name, sizeof(wiphy->name))) {
|
||||||
struct l_dbus *dbus = dbus_get_bus();
|
struct l_dbus *dbus = dbus_get_bus();
|
||||||
|
|
||||||
@ -967,7 +898,7 @@ void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg)
|
|||||||
IWD_WIPHY_INTERFACE, "Name");
|
IWD_WIPHY_INTERFACE, "Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
wiphy_parse_attributes(wiphy, &attr);
|
wiphy_parse_attributes(wiphy, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wiphy_set_station_capability_bits(struct wiphy *wiphy)
|
static void wiphy_set_station_capability_bits(struct wiphy *wiphy)
|
||||||
|
@ -43,15 +43,13 @@ enum ie_rsn_akm_suite wiphy_select_akm(struct wiphy *wiphy,
|
|||||||
struct scan_bss *bss,
|
struct scan_bss *bss,
|
||||||
bool fils_capable_hint);
|
bool fils_capable_hint);
|
||||||
|
|
||||||
bool wiphy_parse_id_and_name(struct l_genl_attr *attr, uint32_t *out_id,
|
|
||||||
const char **out_name);
|
|
||||||
|
|
||||||
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);
|
struct wiphy *wiphy_create(uint32_t wiphy_id, const char *name);
|
||||||
void wiphy_create_complete(struct wiphy *wiphy);
|
void wiphy_create_complete(struct wiphy *wiphy);
|
||||||
bool wiphy_destroy(struct wiphy *wiphy);
|
bool wiphy_destroy(struct wiphy *wiphy);
|
||||||
void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg);
|
void wiphy_update_from_genl(struct wiphy *wiphy, const char *name,
|
||||||
|
struct l_genl_msg *msg);
|
||||||
|
|
||||||
bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
|
bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
|
||||||
struct scan_freq_set *set);
|
struct scan_freq_set *set);
|
||||||
|
Loading…
Reference in New Issue
Block a user