iw: Fix data types for iw survey channel time
[openwrt/svn-archive/archive.git] / package / iw / patches / 401-antenna.patch
1 iw: Add antenna configuration commands
2
3 From: Bruno Randolf <br1@einfach.org>
4
5 Add command to set the antenna configuration (iw phyX set antenna ...) and
6 include antenna setting in wiphy information (iw phyX info).
7
8 iw phyX set antenna all | <bitmap> | <tx bitmap> <rx bitmap>
9
10 Signed-off-by: Bruno Randolf <br1@einfach.org>
11
12 v8: Simplfied option parser as requested.
13 ---
14 info.c | 7 +++++++
15 phy.c | 39 +++++++++++++++++++++++++++++++++++++++
16 2 files changed, 46 insertions(+), 0 deletions(-)
17
18 diff --git a/info.c b/info.c
19 index ce85514..75cadf0 100644
20 --- a/info.c
21 +++ b/info.c
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);
24 }
25
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]));
31 + }
32 +
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
38 --- a/phy.c
39 +++ b/phy.c
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.");
44 +
45 +static int handle_antenna(struct nl80211_state *state,
46 + struct nl_cb *cb,
47 + struct nl_msg *msg,
48 + int argc, char **argv)
49 +{
50 + char *end;
51 + uint32_t tx_ant = 0, rx_ant = 0;
52 +
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);
58 + if (*end)
59 + return 1;
60 + }
61 + else if (argc == 2) {
62 + tx_ant = strtoul(argv[0], &end, 0);
63 + if (*end)
64 + return 1;
65 + rx_ant = strtoul(argv[1], &end, 0);
66 + if (*end)
67 + return 1;
68 + } else
69 + return 1;
70 +
71 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant);
72 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant);
73 +
74 + return 0;
75 +
76 + nla_put_failure:
77 + return -ENOBUFS;
78 +}
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.");