[package] use a common way of marking packages as not supported on specific targets
[openwrt.git] / package / iw / patches / 100-coverage_class.patch
1 --- a/info.c
2 +++ b/info.c
3 @@ -156,6 +156,14 @@ static int print_phy_handler(struct nl_m
4 printf("\tRTS threshold: %d\n", rts);
5 }
6
7 + if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) {
8 + unsigned char coverage;
9 +
10 + coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]);
11 + /* See handle_distance() for an explanation where the '450' comes from */
12 + printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
13 + }
14 +
15 if (!tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES])
16 goto commands;
17
18 --- a/phy.c
19 +++ b/phy.c
20 @@ -164,3 +164,61 @@ static int handle_netns(struct nl80211_s
21 COMMAND(set, netns, "<pid>",
22 NL80211_CMD_SET_WIPHY_NETNS, 0, CIB_PHY, handle_netns,
23 "Put this wireless device into a different network namespace");
24 +
25 +static int handle_coverage(struct nl80211_state *state,
26 + struct nl_cb *cb,
27 + struct nl_msg *msg,
28 + int argc, char **argv)
29 +{
30 + unsigned int coverage;
31 +
32 + if (argc != 1)
33 + return 1;
34 +
35 + coverage = strtoul(argv[0], NULL, 10);
36 + if (coverage > 255)
37 + return 1;
38 +
39 + NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, coverage);
40 +
41 + return 0;
42 + nla_put_failure:
43 + return -ENOBUFS;
44 +}
45 +COMMAND(set, coverage, "<coverage class>",
46 + NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_coverage,
47 + "Set coverage class (1 for every 3 usec of air propagation time).\n"
48 + "Valid values: 0 - 255.");
49 +
50 +static int handle_distance(struct nl80211_state *state,
51 + struct nl_cb *cb,
52 + struct nl_msg *msg,
53 + int argc, char **argv)
54 +{
55 + unsigned int distance, coverage;
56 +
57 + if (argc != 1)
58 + return 1;
59 +
60 + distance = strtoul(argv[0], NULL, 10);
61 +
62 + /*
63 + * Divide double the distance by the speed of light in m/usec (300) to
64 + * get round-trip time in microseconds and then divide the result by
65 + * three to get coverage class as specified in IEEE 802.11-2007 table
66 + * 7-27. Values are rounded upwards.
67 + */
68 + coverage = (distance + 449) / 450;
69 + if (coverage > 255)
70 + return 1;
71 +
72 + NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, coverage);
73 +
74 + return 0;
75 + nla_put_failure:
76 + return -ENOBUFS;
77 +}
78 +COMMAND(set, distance, "<distance>",
79 + NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_distance,
80 + "Set appropriate coverage class for given link distance in meters.\n"
81 + "Valid values: 0 - 114750");
This page took 0.04562 seconds and 5 git commands to generate.