summaryrefslogtreecommitdiff
path: root/package/hostapd/patches/540-optional_rfkill.patch
blob: c70bcf4a52826704492dbb7467bbd57d86b553b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -115,7 +115,9 @@ struct wpa_driver_nl80211_data {
 	int ifindex;
 	int if_removed;
 	int if_disabled;
+#ifdef CONFIG_RFKILL
 	struct rfkill_data *rfkill;
+#endif
 	struct wpa_driver_capa capa;
 	int has_capability;
 
@@ -1630,7 +1632,7 @@ err1:
 	return -1;
 }
 
-
+#ifdef CONFIG_RFKILL
 static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
 {
 	wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
@@ -1652,6 +1654,7 @@ static void wpa_driver_nl80211_rfkill_un
 	}
 	/* rtnetlink ifup handler will report interface as enabled */
 }
+#endif /* CONFIG_RFKILL */
 
 
 /**
@@ -1665,7 +1668,9 @@ static void * wpa_driver_nl80211_init(vo
 {
 	struct wpa_driver_nl80211_data *drv;
 	struct netlink_config *cfg;
+#ifdef CONFIG_RFKILL
 	struct rfkill_config *rcfg;
+#endif
 	struct i802_bss *bss;
 
 	drv = os_zalloc(sizeof(*drv));
@@ -1703,6 +1708,7 @@ static void * wpa_driver_nl80211_init(vo
 		goto failed;
 	}
 
+#ifdef CONFIG_RFKILL
 	rcfg = os_zalloc(sizeof(*rcfg));
 	if (rcfg == NULL)
 		goto failed;
@@ -1715,6 +1721,7 @@ static void * wpa_driver_nl80211_init(vo
 		wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
 		os_free(rcfg);
 	}
+#endif /* CONFIG_RFKILL */
 
 	if (wpa_driver_nl80211_finish_drv_init(drv))
 		goto failed;
@@ -1722,7 +1729,9 @@ static void * wpa_driver_nl80211_init(vo
 	return bss;
 
 failed:
+#ifdef CONFIG_RFKILL
 	rfkill_deinit(drv->rfkill);
+#endif
 	netlink_deinit(drv->netlink);
 	if (drv->ioctl_sock >= 0)
 		close(drv->ioctl_sock);
@@ -1820,10 +1829,12 @@ static int nl80211_register_action_frame
 }
 
 
+#ifdef CONFIG_RFKILL
 static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
 {
 	wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
 }
+#endif /* CONFIG_RFKILL */
 
 
 static int
@@ -1842,13 +1853,16 @@ wpa_driver_nl80211_finish_drv_init(struc
 		}
 
 		if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
+#ifdef CONFIG_RFKILL
 			if (rfkill_is_blocked(drv->rfkill)) {
 				wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
 					   "interface '%s' due to rfkill",
 					   bss->ifname);
 				drv->if_disabled = 1;
 				send_rfkill_event = 1;
-			} else {
+			} else
+#endif
+			{
 				wpa_printf(MSG_ERROR, "nl80211: Could not set "
 					   "interface '%s' UP", bss->ifname);
 				return -1;
@@ -1873,8 +1887,10 @@ wpa_driver_nl80211_finish_drv_init(struc
 	}
 
 	if (send_rfkill_event) {
+#ifdef CONFIG_RFKILL
 		eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
 				       drv, drv->ctx);
+#endif
 	}
 
 	return 0;
@@ -1955,7 +1971,9 @@ static void wpa_driver_nl80211_deinit(vo
 
 	netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
 	netlink_deinit(drv->netlink);
+#ifdef CONFIG_RFKILL
 	rfkill_deinit(drv->rfkill);
+#endif
 
 	eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
 
--- a/src/drivers/driver_wext.c
+++ b/src/drivers/driver_wext.c
@@ -700,7 +700,7 @@ static void wpa_driver_wext_event_rtm_de
 	}
 }
 
-
+#ifdef CONFIG_RFKILL
 static void wpa_driver_wext_rfkill_blocked(void *ctx)
 {
 	wpa_printf(MSG_DEBUG, "WEXT: RFKILL blocked");
@@ -722,7 +722,7 @@ static void wpa_driver_wext_rfkill_unblo
 	}
 	/* rtnetlink ifup handler will report interface as enabled */
 }
-
+#endif /* CONFIG_RFKILL */
 
 /**
  * wpa_driver_wext_init - Initialize WE driver interface
@@ -735,7 +735,9 @@ void * wpa_driver_wext_init(void *ctx, c
 {
 	struct wpa_driver_wext_data *drv;
 	struct netlink_config *cfg;
+#ifdef CONFIG_RFKILL
 	struct rfkill_config *rcfg;
+#endif
 	char path[128];
 	struct stat buf;
 
@@ -769,6 +771,7 @@ void * wpa_driver_wext_init(void *ctx, c
 		goto err2;
 	}
 
+#ifdef CONFIG_RFKILL
 	rcfg = os_zalloc(sizeof(*rcfg));
 	if (rcfg == NULL)
 		goto err3;
@@ -781,6 +784,7 @@ void * wpa_driver_wext_init(void *ctx, c
 		wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
 		os_free(rcfg);
 	}
+#endif /* CONFIG_RFKILL */
 
 	drv->mlme_sock = -1;
 
@@ -792,7 +796,9 @@ void * wpa_driver_wext_init(void *ctx, c
 	return drv;
 
 err3:
+#ifdef CONFIG_RFKILL
 	rfkill_deinit(drv->rfkill);
+#endif
 	netlink_deinit(drv->netlink);
 err2:
 	close(drv->ioctl_sock);
@@ -802,10 +808,12 @@ err1:
 }
 
 
+#ifdef CONFIG_RFKILL
 static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
 {
 	wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
 }
+#endif /* CONFIG_RFKILL */
 
 
 static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
@@ -813,13 +821,16 @@ static int wpa_driver_wext_finish_drv_in
 	int send_rfkill_event = 0;
 
 	if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
+#ifdef CONFIG_RFKILL
 		if (rfkill_is_blocked(drv->rfkill)) {
 			wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
 				   "interface '%s' due to rfkill",
 				   drv->ifname);
 			drv->if_disabled = 1;
 			send_rfkill_event = 1;
-		} else {
+		} else
+#endif
+		{
 			wpa_printf(MSG_ERROR, "WEXT: Could not set "
 				   "interface '%s' UP", drv->ifname);
 			return -1;
@@ -867,8 +878,10 @@ static int wpa_driver_wext_finish_drv_in
 			       1, IF_OPER_DORMANT);
 
 	if (send_rfkill_event) {
+#ifdef CONFIG_RFKILL
 		eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
 				       drv, drv->ctx);
+#endif
 	}
 
 	return 0;
@@ -898,7 +911,9 @@ void wpa_driver_wext_deinit(void *priv)
 
 	netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
 	netlink_deinit(drv->netlink);
+#ifdef CONFIG_RFKILL
 	rfkill_deinit(drv->rfkill);
+#endif
 
 	if (drv->mlme_sock >= 0)
 		eloop_unregister_read_sock(drv->mlme_sock);
--- a/src/drivers/drivers.mak
+++ b/src/drivers/drivers.mak
@@ -43,7 +43,6 @@ NEED_SME=y
 NEED_AP_MLME=y
 NEED_NETLINK=y
 NEED_LINUX_IOCTL=y
-NEED_RFKILL=y
 ifdef CONFIG_LIBNL_TINY
 DRV_LIBS += -lnl-tiny
 else
@@ -94,7 +93,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
 CONFIG_WIRELESS_EXTENSION=y
 NEED_NETLINK=y
 NEED_LINUX_IOCTL=y
-NEED_RFKILL=y
 endif
 
 ifdef CONFIG_DRIVER_HERMES
@@ -170,7 +168,6 @@ endif
 ifdef CONFIG_WIRELESS_EXTENSION
 DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
 DRV_WPA_OBJS += ../src/drivers/driver_wext.o
-NEED_RFKILL=y
 endif
 
 ifdef NEED_NETLINK
@@ -183,6 +180,7 @@ endif
 
 ifdef NEED_RFKILL
 DRV_OBJS += ../src/drivers/rfkill.o
+DRV_WPA_CFLAGS += -DCONFIG_RFKILL
 endif
 
 
--- a/src/drivers/driver_wext.h
+++ b/src/drivers/driver_wext.h
@@ -27,7 +27,9 @@ struct wpa_driver_wext_data {
 	int ifindex2;
 	int if_removed;
 	int if_disabled;
+#ifdef CONFIG_RFKILL
 	struct rfkill_data *rfkill;
+#endif
 	u8 *assoc_req_ies;
 	size_t assoc_req_ies_len;
 	u8 *assoc_resp_ies;