mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
nl80211util: Add chandef parser
Parse chandef elements from NL80211_CMD_GET_INTERFACE. This provides information on the current operating channel.
This commit is contained in:
parent
5e631c8af8
commit
85a6fc25f1
16
src/band.h
16
src/band.h
@ -27,6 +27,22 @@ enum ofdm_channel_width {
|
|||||||
OFDM_CHANNEL_WIDTH_160MHZ,
|
OFDM_CHANNEL_WIDTH_160MHZ,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum band_chandef_width {
|
||||||
|
BAND_CHANDEF_WIDTH_20NOHT = 0,
|
||||||
|
BAND_CHANDEF_WIDTH_20,
|
||||||
|
BAND_CHANDEF_WIDTH_40,
|
||||||
|
BAND_CHANDEF_WIDTH_80,
|
||||||
|
BAND_CHANDEF_WIDTH_80P80,
|
||||||
|
BAND_CHANDEF_WIDTH_160,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct band_chandef {
|
||||||
|
uint32_t frequency;
|
||||||
|
uint32_t channel_width;
|
||||||
|
uint32_t center1_frequency;
|
||||||
|
uint32_t center2_frequency;
|
||||||
|
};
|
||||||
|
|
||||||
struct band {
|
struct band {
|
||||||
uint8_t vht_mcs_set[8];
|
uint8_t vht_mcs_set[8];
|
||||||
uint8_t vht_capabilities[4];
|
uint8_t vht_capabilities[4];
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "linux/nl80211.h"
|
#include "linux/nl80211.h"
|
||||||
|
|
||||||
#include "src/nl80211util.h"
|
#include "src/nl80211util.h"
|
||||||
|
#include "src/band.h"
|
||||||
|
|
||||||
typedef bool (*attr_handler)(const void *data, uint16_t len, void *o);
|
typedef bool (*attr_handler)(const void *data, uint16_t len, void *o);
|
||||||
|
|
||||||
@ -138,6 +139,11 @@ static attr_handler handler_for_type(enum nl80211_attrs type)
|
|||||||
case NL80211_ATTR_ACK:
|
case NL80211_ATTR_ACK:
|
||||||
return extract_flag;
|
return extract_flag;
|
||||||
case NL80211_ATTR_WIPHY_FREQ:
|
case NL80211_ATTR_WIPHY_FREQ:
|
||||||
|
case NL80211_ATTR_WIPHY_FREQ_OFFSET:
|
||||||
|
case NL80211_ATTR_WIPHY_CHANNEL_TYPE:
|
||||||
|
case NL80211_ATTR_CHANNEL_WIDTH:
|
||||||
|
case NL80211_ATTR_CENTER_FREQ1:
|
||||||
|
case NL80211_ATTR_CENTER_FREQ2:
|
||||||
return extract_uint32;
|
return extract_uint32;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -430,3 +436,27 @@ struct l_genl_msg *nl80211_build_cmd_frame(uint32_t ifindex,
|
|||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nl80211_parse_chandef(struct l_genl_msg *msg, struct band_chandef *out)
|
||||||
|
{
|
||||||
|
struct band_chandef t;
|
||||||
|
|
||||||
|
if (nl80211_parse_attrs(msg,
|
||||||
|
NL80211_ATTR_WIPHY_FREQ, &t.frequency,
|
||||||
|
NL80211_ATTR_CHANNEL_WIDTH, &t.channel_width,
|
||||||
|
NL80211_ATTR_CENTER_FREQ1, &t.center1_frequency,
|
||||||
|
NL80211_ATTR_UNSPEC) < 0)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
t.center2_frequency = 0;
|
||||||
|
|
||||||
|
/* Try to parse CENTER_FREQ2, but it is given only for 80P80 */
|
||||||
|
if (t.channel_width == NL80211_CHAN_WIDTH_80P80 &&
|
||||||
|
nl80211_parse_attrs(msg,
|
||||||
|
NL80211_ATTR_CENTER_FREQ2, &t.center2_frequency,
|
||||||
|
NL80211_ATTR_UNSPEC) < 0)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
memcpy(out, &t, sizeof(t));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <ell/ell.h>
|
#include <ell/ell.h>
|
||||||
|
|
||||||
|
struct band_chandef;
|
||||||
|
|
||||||
int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...);
|
int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...);
|
||||||
|
|
||||||
struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex,
|
struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex,
|
||||||
@ -51,3 +53,5 @@ struct l_genl_msg *nl80211_build_cmd_frame(uint32_t ifindex,
|
|||||||
uint32_t freq,
|
uint32_t freq,
|
||||||
struct iovec *iov,
|
struct iovec *iov,
|
||||||
size_t iov_len);
|
size_t iov_len);
|
||||||
|
|
||||||
|
int nl80211_parse_chandef(struct l_genl_msg *msg, struct band_chandef *out);
|
||||||
|
Loading…
Reference in New Issue
Block a user