[kernel] Some build fixes.
[openwrt/svn-archive/archive.git] / package / iw / patches / 000-upstream.patch
1 --- a/Makefile
2 +++ b/Makefile
3 @@ -3,7 +3,7 @@
4 MAKEFLAGS += --no-print-directory
5
6 PREFIX ?= /usr
7 -BINDIR ?= $(PREFIX)/bin
8 +SBINDIR ?= $(PREFIX)/sbin
9 MANDIR ?= $(PREFIX)/share/man
10 PKG_CONFIG ?= pkg-config
11
12 @@ -85,8 +85,8 @@ check:
13
14 install: iw iw.8.gz
15 @$(NQ) ' INST iw'
16 - $(Q)$(MKDIR) $(DESTDIR)$(BINDIR)
17 - $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) iw
18 + $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
19 + $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(SBINDIR) iw
20 @$(NQ) ' INST iw.8'
21 $(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
22 $(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man8/ iw.8.gz
23 --- a/iw.c
24 +++ b/iw.c
25 @@ -223,9 +223,12 @@ static int phy_lookup(char *name)
26 if (fd < 0)
27 return -1;
28 pos = read(fd, buf, sizeof(buf) - 1);
29 - if (pos < 0)
30 + if (pos < 0) {
31 + close(fd);
32 return -1;
33 + }
34 buf[pos] = '\0';
35 + close(fd);
36 return atoi(buf);
37 }
38
39 --- a/nl80211.h
40 +++ b/nl80211.h
41 @@ -262,6 +262,9 @@
42 * reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
43 * %NL80211_ATTR_REASON_CODE attributes are used.
44 *
45 + * @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices
46 + * associated with this wiphy must be down and will follow.
47 + *
48 * @NL80211_CMD_MAX: highest used command number
49 * @__NL80211_CMD_AFTER_LAST: internal use
50 */
51 @@ -336,6 +339,8 @@ enum nl80211_commands {
52 NL80211_CMD_ROAM,
53 NL80211_CMD_DISCONNECT,
54
55 + NL80211_CMD_SET_WIPHY_NETNS,
56 +
57 /* add new commands above here */
58
59 /* used to define NL80211_CMD_MAX below */
60 @@ -475,10 +480,6 @@ enum nl80211_commands {
61 * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
62 * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
63 * scanning and include a zero-length SSID (wildcard) for wildcard scan
64 - * @NL80211_ATTR_SCAN_GENERATION: the scan generation increases whenever the
65 - * scan result list changes (BSS expired or added) so that applications
66 - * can verify that they got a single, consistent snapshot (when all dump
67 - * messages carried the same generation number)
68 * @NL80211_ATTR_BSS: scan result BSS
69 *
70 * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
71 @@ -573,6 +574,16 @@ enum nl80211_commands {
72 * and join_ibss(), key information is in a nested attribute each
73 * with %NL80211_KEY_* sub-attributes
74 *
75 + * @NL80211_ATTR_PID: Process ID of a network namespace.
76 + *
77 + * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for
78 + * dumps. This number increases whenever the object list being
79 + * dumped changes, and as such userspace can verify that it has
80 + * obtained a complete and consistent snapshot by verifying that
81 + * all dump messages contain the same generation number. If it
82 + * changed then the list changed and the dump should be repeated
83 + * completely from scratch.
84 + *
85 * @NL80211_ATTR_MAX: highest attribute number currently defined
86 * @__NL80211_ATTR_AFTER_LAST: internal use
87 */
88 @@ -644,7 +655,7 @@ enum nl80211_attrs {
89
90 NL80211_ATTR_SCAN_FREQUENCIES,
91 NL80211_ATTR_SCAN_SSIDS,
92 - NL80211_ATTR_SCAN_GENERATION,
93 + NL80211_ATTR_GENERATION, /* replaces old SCAN_GENERATION */
94 NL80211_ATTR_BSS,
95
96 NL80211_ATTR_REG_INITIATOR,
97 @@ -701,12 +712,17 @@ enum nl80211_attrs {
98 NL80211_ATTR_KEY,
99 NL80211_ATTR_KEYS,
100
101 + NL80211_ATTR_PID,
102 +
103 /* add attributes here, update the policy in nl80211.c */
104
105 __NL80211_ATTR_AFTER_LAST,
106 NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
107 };
108
109 +/* source-level API compatibility */
110 +#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
111 +
112 /*
113 * Allow user space programs to use #ifdef on new attributes by defining them
114 * here
115 --- a/phy.c
116 +++ b/phy.c
117 @@ -140,3 +140,27 @@ static int handle_rts(struct nl80211_sta
118 COMMAND(set, rts, "<rts threshold|off>",
119 NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_rts,
120 "Set rts threshold.");
121 +
122 +static int handle_netns(struct nl80211_state *state,
123 + struct nl_cb *cb,
124 + struct nl_msg *msg,
125 + int argc, char **argv)
126 +{
127 + char *end;
128 +
129 + if (argc != 1)
130 + return 1;
131 +
132 + NLA_PUT_U32(msg, NL80211_ATTR_PID,
133 + strtoul(argv[0], &end, 10));
134 +
135 + if (*end != '\0')
136 + return 1;
137 +
138 + return 0;
139 + nla_put_failure:
140 + return -ENOBUFS;
141 +}
142 +COMMAND(set, netns, "<pid>",
143 + NL80211_CMD_SET_WIPHY_NETNS, 0, CIB_PHY, handle_netns,
144 + "Put this wireless device into a different network namespace");
145 --- a/station.c
146 +++ b/station.c
147 @@ -127,7 +127,7 @@ static int print_sta_handler(struct nl_m
148 printf("\n\tmesh plid:\t%d",
149 nla_get_u16(sinfo[NL80211_STA_INFO_PLID]));
150 if (sinfo[NL80211_STA_INFO_PLINK_STATE]) {
151 - switch (nla_get_u16(sinfo[NL80211_STA_INFO_PLINK_STATE])) {
152 + switch (nla_get_u8(sinfo[NL80211_STA_INFO_PLINK_STATE])) {
153 case LISTEN:
154 strcpy(state_name, "LISTEN");
155 break;