1 iw: Add antenna configuration commands
3 From: Bruno Randolf <br1@einfach.org>
5 Add command to set the antenna configuration (iw phyX set antenna ...) and
6 include antenna setting in wiphy information (iw phyX info).
8 iw phyX set antenna all | <bitmap> | <tx bitmap> <rx bitmap>
10 Signed-off-by: Bruno Randolf <br1@einfach.org>
12 v8: Simplfied option parser as requested.
15 phy.c | 39 +++++++++++++++++++++++++++++++++++++++
16 2 files changed, 46 insertions(+), 0 deletions(-)
18 diff --git a/info.c b/info.c
19 index ce85514..75cadf0 100644
22 @@ -168,6 +168,13 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
23 printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
26 + if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
27 + tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
28 + printf("\tAntenna: TX %#x RX %#x\n",
29 + nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
30 + nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
33 if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) {
34 printf("\tSupported interface modes:\n");
35 nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode)
36 diff --git a/phy.c b/phy.c
37 index 7c6c7c8..e3bd4e8 100644
40 @@ -307,3 +307,42 @@ COMMAND(set, txpower, "<auto|fixed|limit> [<tx power in mBm>]",
41 COMMAND(set, txpower, "<auto|fixed|limit> [<tx power in mBm>]",
42 NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_txpower,
43 "Specify transmit power level and setting type.");
45 +static int handle_antenna(struct nl80211_state *state,
48 + int argc, char **argv)
51 + uint32_t tx_ant = 0, rx_ant = 0;
53 + if (argc == 1 && strcmp(argv[0], "all") == 0) {
54 + tx_ant = 0xffffffff;
55 + rx_ant = 0xffffffff;
56 + } else if (argc == 1) {
57 + tx_ant = rx_ant = strtoul(argv[0], &end, 0);
61 + else if (argc == 2) {
62 + tx_ant = strtoul(argv[0], &end, 0);
65 + rx_ant = strtoul(argv[1], &end, 0);
71 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant);
72 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant);
79 +COMMAND(set, antenna, "<bitmap> | all | <tx bitmap> <rx bitmap>",
80 + NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna,
81 + "Set a bitmap of allowed antennas to use for TX and RX.\n"
82 + "The driver may reject antenna configurations it cannot support.");