uClibc: fix version check for 0.9.32
[openwrt.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 --- a/info.c
19 +++ b/info.c
20 @@ -168,6 +168,13 @@ static int print_phy_handler(struct nl_m
21 printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
22 }
23
24 + if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
25 + tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
26 + printf("\tAntenna: TX %#x RX %#x\n",
27 + nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_TX]),
28 + nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_ANTENNA_RX]));
29 + }
30 +
31 if (tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]) {
32 printf("\tSupported interface modes:\n");
33 nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode)
34 --- a/phy.c
35 +++ b/phy.c
36 @@ -307,3 +307,51 @@ COMMAND(set, txpower, "<auto|fixed|limit
37 COMMAND(set, txpower, "<auto|fixed|limit> [<tx power in mBm>]",
38 NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_txpower,
39 "Specify transmit power level and setting type.");
40 +
41 +static int handle_antenna(struct nl80211_state *state,
42 + struct nl_cb *cb,
43 + struct nl_msg *msg,
44 + int argc, char **argv)
45 +{
46 + char *end;
47 + uint32_t tx_ant = 0, rx_ant = 0;
48 +
49 + if (argc == 1) {
50 + if (strcmp(argv[0], "all") == 0)
51 + tx_ant = rx_ant = 0xffffffff;
52 + else {
53 + tx_ant = rx_ant = strtoul(argv[0], &end, 0);
54 + if (*end)
55 + return 1;
56 + }
57 + }
58 + else if (argc == 2) {
59 + if (strcmp(argv[0], "all") == 0)
60 + tx_ant = 0xffffffff;
61 + else {
62 + tx_ant = strtoul(argv[0], &end, 0);
63 + if (*end)
64 + return 1;
65 + }
66 + if (strcmp(argv[1], "all") == 0)
67 + rx_ant = 0xffffffff;
68 + else {
69 + rx_ant = strtoul(argv[1], &end, 0);
70 + if (*end)
71 + return 1;
72 + }
73 + } else
74 + return 1;
75 +
76 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant);
77 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant);
78 +
79 + return 0;
80 +
81 + nla_put_failure:
82 + return -ENOBUFS;
83 +}
84 +COMMAND(set, antenna, "<bitmap> | all | <tx bitmap> <rx bitmap>",
85 + NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna,
86 + "Set a bitmap of allowed antennas to use for TX and RX.\n"
87 + "The driver may reject antenna configurations it cannot support.");
This page took 0.04742 seconds and 5 git commands to generate.